github.com/mmatczuk/gohan@v0.0.0-20170206152520-30e45d9bdb69/public/webui/bundle.84f1a38f969fae5c6ad6.js (about) 1 /******/ (function(modules) { // webpackBootstrap 2 /******/ // The module cache 3 /******/ var installedModules = {}; 4 5 /******/ // The require function 6 /******/ function __webpack_require__(moduleId) { 7 8 /******/ // Check if module is in cache 9 /******/ if(installedModules[moduleId]) 10 /******/ return installedModules[moduleId].exports; 11 12 /******/ // Create a new module (and put it into the cache) 13 /******/ var module = installedModules[moduleId] = { 14 /******/ exports: {}, 15 /******/ id: moduleId, 16 /******/ loaded: false 17 /******/ }; 18 19 /******/ // Execute the module function 20 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21 22 /******/ // Flag the module as loaded 23 /******/ module.loaded = true; 24 25 /******/ // Return the exports of the module 26 /******/ return module.exports; 27 /******/ } 28 29 30 /******/ // expose the modules object (__webpack_modules__) 31 /******/ __webpack_require__.m = modules; 32 33 /******/ // expose the module cache 34 /******/ __webpack_require__.c = installedModules; 35 36 /******/ // __webpack_public_path__ 37 /******/ __webpack_require__.p = ""; 38 39 /******/ // Load entry module and return exports 40 /******/ return __webpack_require__(0); 41 /******/ }) 42 /************************************************************************/ 43 /******/ ([ 44 /* 0 */ 45 /***/ function(module, exports, __webpack_require__) { 46 47 module.exports = __webpack_require__(70); 48 49 50 /***/ }, 51 /* 1 */, 52 /* 2 */, 53 /* 3 */, 54 /* 4 */, 55 /* 5 */, 56 /* 6 */, 57 /* 7 */, 58 /* 8 */, 59 /* 9 */, 60 /* 10 */, 61 /* 11 */, 62 /* 12 */, 63 /* 13 */, 64 /* 14 */, 65 /* 15 */, 66 /* 16 */, 67 /* 17 */, 68 /* 18 */, 69 /* 19 */, 70 /* 20 */, 71 /* 21 */, 72 /* 22 */, 73 /* 23 */, 74 /* 24 */, 75 /* 25 */, 76 /* 26 */, 77 /* 27 */, 78 /* 28 */, 79 /* 29 */, 80 /* 30 */, 81 /* 31 */, 82 /* 32 */, 83 /* 33 */, 84 /* 34 */, 85 /* 35 */, 86 /* 36 */, 87 /* 37 */, 88 /* 38 */, 89 /* 39 */, 90 /* 40 */, 91 /* 41 */, 92 /* 42 */, 93 /* 43 */, 94 /* 44 */, 95 /* 45 */, 96 /* 46 */, 97 /* 47 */, 98 /* 48 */, 99 /* 49 */, 100 /* 50 */, 101 /* 51 */, 102 /* 52 */, 103 /* 53 */, 104 /* 54 */, 105 /* 55 */, 106 /* 56 */, 107 /* 57 */, 108 /* 58 */, 109 /* 59 */, 110 /* 60 */, 111 /* 61 */, 112 /* 62 */, 113 /* 63 */, 114 /* 64 */, 115 /* 65 */, 116 /* 66 */, 117 /* 67 */, 118 /* 68 */, 119 /* 69 */, 120 /* 70 */ 121 /***/ function(module, exports, __webpack_require__) { 122 123 /* WEBPACK VAR INJECTION */(function($) {'use strict';__webpack_require__(72);__webpack_require__(85);__webpack_require__(86);__webpack_require__(87);__webpack_require__(96);__webpack_require__(98);__webpack_require__(106);__webpack_require__(108);__webpack_require__(111);var _backbone=__webpack_require__(113);__webpack_require__(115);var _appView=__webpack_require__(116),_appView2=_interopRequireDefault(_appView),_schemaView=__webpack_require__(191),_schemaView2=_interopRequireDefault(_schemaView),_router=__webpack_require__(202),_router2=_interopRequireDefault(_router),_configModel=__webpack_require__(203),_configModel2=_interopRequireDefault(_configModel);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}// Import JS. 124 // Import css. 125 const config=new _configModel2.default({url:'config.json'});/* global $, document */// Import bootstraps. 126 config.fetch().then(()=>{const a=new _appView2.default({router:new _router2.default({title:document.title}),config,viewClass:{schema:{table:_schemaView2.default}}});$('body').append(a.render().el),_backbone.history.start()},()=>{$('body').append('Failed to load config.json')}); 127 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71))) 128 129 /***/ }, 130 /* 71 */ 131 /***/ function(module, exports, __webpack_require__) { 132 133 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 134 * jQuery JavaScript Library v2.2.4 135 * http://jquery.com/ 136 * 137 * Includes Sizzle.js 138 * http://sizzlejs.com/ 139 * 140 * Copyright jQuery Foundation and other contributors 141 * Released under the MIT license 142 * http://jquery.org/license 143 * 144 * Date: 2016-05-20T17:23Z 145 */ 146 147 (function( global, factory ) { 148 149 if ( typeof module === "object" && typeof module.exports === "object" ) { 150 // For CommonJS and CommonJS-like environments where a proper `window` 151 // is present, execute the factory and get jQuery. 152 // For environments that do not have a `window` with a `document` 153 // (such as Node.js), expose a factory as module.exports. 154 // This accentuates the need for the creation of a real `window`. 155 // e.g. var jQuery = require("jquery")(window); 156 // See ticket #14549 for more info. 157 module.exports = global.document ? 158 factory( global, true ) : 159 function( w ) { 160 if ( !w.document ) { 161 throw new Error( "jQuery requires a window with a document" ); 162 } 163 return factory( w ); 164 }; 165 } else { 166 factory( global ); 167 } 168 169 // Pass this if window is not defined yet 170 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) { 171 172 // Support: Firefox 18+ 173 // Can't be in strict mode, several libs including ASP.NET trace 174 // the stack via arguments.caller.callee and Firefox dies if 175 // you try to trace through "use strict" call chains. (#13335) 176 //"use strict"; 177 var arr = []; 178 179 var document = window.document; 180 181 var slice = arr.slice; 182 183 var concat = arr.concat; 184 185 var push = arr.push; 186 187 var indexOf = arr.indexOf; 188 189 var class2type = {}; 190 191 var toString = class2type.toString; 192 193 var hasOwn = class2type.hasOwnProperty; 194 195 var support = {}; 196 197 198 199 var 200 version = "2.2.4", 201 202 // Define a local copy of jQuery 203 jQuery = function( selector, context ) { 204 205 // The jQuery object is actually just the init constructor 'enhanced' 206 // Need init if jQuery is called (just allow error to be thrown if not included) 207 return new jQuery.fn.init( selector, context ); 208 }, 209 210 // Support: Android<4.1 211 // Make sure we trim BOM and NBSP 212 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, 213 214 // Matches dashed string for camelizing 215 rmsPrefix = /^-ms-/, 216 rdashAlpha = /-([\da-z])/gi, 217 218 // Used by jQuery.camelCase as callback to replace() 219 fcamelCase = function( all, letter ) { 220 return letter.toUpperCase(); 221 }; 222 223 jQuery.fn = jQuery.prototype = { 224 225 // The current version of jQuery being used 226 jquery: version, 227 228 constructor: jQuery, 229 230 // Start with an empty selector 231 selector: "", 232 233 // The default length of a jQuery object is 0 234 length: 0, 235 236 toArray: function() { 237 return slice.call( this ); 238 }, 239 240 // Get the Nth element in the matched element set OR 241 // Get the whole matched element set as a clean array 242 get: function( num ) { 243 return num != null ? 244 245 // Return just the one element from the set 246 ( num < 0 ? this[ num + this.length ] : this[ num ] ) : 247 248 // Return all the elements in a clean array 249 slice.call( this ); 250 }, 251 252 // Take an array of elements and push it onto the stack 253 // (returning the new matched element set) 254 pushStack: function( elems ) { 255 256 // Build a new jQuery matched element set 257 var ret = jQuery.merge( this.constructor(), elems ); 258 259 // Add the old object onto the stack (as a reference) 260 ret.prevObject = this; 261 ret.context = this.context; 262 263 // Return the newly-formed element set 264 return ret; 265 }, 266 267 // Execute a callback for every element in the matched set. 268 each: function( callback ) { 269 return jQuery.each( this, callback ); 270 }, 271 272 map: function( callback ) { 273 return this.pushStack( jQuery.map( this, function( elem, i ) { 274 return callback.call( elem, i, elem ); 275 } ) ); 276 }, 277 278 slice: function() { 279 return this.pushStack( slice.apply( this, arguments ) ); 280 }, 281 282 first: function() { 283 return this.eq( 0 ); 284 }, 285 286 last: function() { 287 return this.eq( -1 ); 288 }, 289 290 eq: function( i ) { 291 var len = this.length, 292 j = +i + ( i < 0 ? len : 0 ); 293 return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] ); 294 }, 295 296 end: function() { 297 return this.prevObject || this.constructor(); 298 }, 299 300 // For internal use only. 301 // Behaves like an Array's method, not like a jQuery method. 302 push: push, 303 sort: arr.sort, 304 splice: arr.splice 305 }; 306 307 jQuery.extend = jQuery.fn.extend = function() { 308 var options, name, src, copy, copyIsArray, clone, 309 target = arguments[ 0 ] || {}, 310 i = 1, 311 length = arguments.length, 312 deep = false; 313 314 // Handle a deep copy situation 315 if ( typeof target === "boolean" ) { 316 deep = target; 317 318 // Skip the boolean and the target 319 target = arguments[ i ] || {}; 320 i++; 321 } 322 323 // Handle case when target is a string or something (possible in deep copy) 324 if ( typeof target !== "object" && !jQuery.isFunction( target ) ) { 325 target = {}; 326 } 327 328 // Extend jQuery itself if only one argument is passed 329 if ( i === length ) { 330 target = this; 331 i--; 332 } 333 334 for ( ; i < length; i++ ) { 335 336 // Only deal with non-null/undefined values 337 if ( ( options = arguments[ i ] ) != null ) { 338 339 // Extend the base object 340 for ( name in options ) { 341 src = target[ name ]; 342 copy = options[ name ]; 343 344 // Prevent never-ending loop 345 if ( target === copy ) { 346 continue; 347 } 348 349 // Recurse if we're merging plain objects or arrays 350 if ( deep && copy && ( jQuery.isPlainObject( copy ) || 351 ( copyIsArray = jQuery.isArray( copy ) ) ) ) { 352 353 if ( copyIsArray ) { 354 copyIsArray = false; 355 clone = src && jQuery.isArray( src ) ? src : []; 356 357 } else { 358 clone = src && jQuery.isPlainObject( src ) ? src : {}; 359 } 360 361 // Never move original objects, clone them 362 target[ name ] = jQuery.extend( deep, clone, copy ); 363 364 // Don't bring in undefined values 365 } else if ( copy !== undefined ) { 366 target[ name ] = copy; 367 } 368 } 369 } 370 } 371 372 // Return the modified object 373 return target; 374 }; 375 376 jQuery.extend( { 377 378 // Unique for each copy of jQuery on the page 379 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), 380 381 // Assume jQuery is ready without the ready module 382 isReady: true, 383 384 error: function( msg ) { 385 throw new Error( msg ); 386 }, 387 388 noop: function() {}, 389 390 isFunction: function( obj ) { 391 return jQuery.type( obj ) === "function"; 392 }, 393 394 isArray: Array.isArray, 395 396 isWindow: function( obj ) { 397 return obj != null && obj === obj.window; 398 }, 399 400 isNumeric: function( obj ) { 401 402 // parseFloat NaNs numeric-cast false positives (null|true|false|"") 403 // ...but misinterprets leading-number strings, particularly hex literals ("0x...") 404 // subtraction forces infinities to NaN 405 // adding 1 corrects loss of precision from parseFloat (#15100) 406 var realStringObj = obj && obj.toString(); 407 return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0; 408 }, 409 410 isPlainObject: function( obj ) { 411 var key; 412 413 // Not plain objects: 414 // - Any object or value whose internal [[Class]] property is not "[object Object]" 415 // - DOM nodes 416 // - window 417 if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { 418 return false; 419 } 420 421 // Not own constructor property must be Object 422 if ( obj.constructor && 423 !hasOwn.call( obj, "constructor" ) && 424 !hasOwn.call( obj.constructor.prototype || {}, "isPrototypeOf" ) ) { 425 return false; 426 } 427 428 // Own properties are enumerated firstly, so to speed up, 429 // if last one is own, then all properties are own 430 for ( key in obj ) {} 431 432 return key === undefined || hasOwn.call( obj, key ); 433 }, 434 435 isEmptyObject: function( obj ) { 436 var name; 437 for ( name in obj ) { 438 return false; 439 } 440 return true; 441 }, 442 443 type: function( obj ) { 444 if ( obj == null ) { 445 return obj + ""; 446 } 447 448 // Support: Android<4.0, iOS<6 (functionish RegExp) 449 return typeof obj === "object" || typeof obj === "function" ? 450 class2type[ toString.call( obj ) ] || "object" : 451 typeof obj; 452 }, 453 454 // Evaluates a script in a global context 455 globalEval: function( code ) { 456 var script, 457 indirect = eval; 458 459 code = jQuery.trim( code ); 460 461 if ( code ) { 462 463 // If the code includes a valid, prologue position 464 // strict mode pragma, execute code by injecting a 465 // script tag into the document. 466 if ( code.indexOf( "use strict" ) === 1 ) { 467 script = document.createElement( "script" ); 468 script.text = code; 469 document.head.appendChild( script ).parentNode.removeChild( script ); 470 } else { 471 472 // Otherwise, avoid the DOM node creation, insertion 473 // and removal by using an indirect global eval 474 475 indirect( code ); 476 } 477 } 478 }, 479 480 // Convert dashed to camelCase; used by the css and data modules 481 // Support: IE9-11+ 482 // Microsoft forgot to hump their vendor prefix (#9572) 483 camelCase: function( string ) { 484 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); 485 }, 486 487 nodeName: function( elem, name ) { 488 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); 489 }, 490 491 each: function( obj, callback ) { 492 var length, i = 0; 493 494 if ( isArrayLike( obj ) ) { 495 length = obj.length; 496 for ( ; i < length; i++ ) { 497 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { 498 break; 499 } 500 } 501 } else { 502 for ( i in obj ) { 503 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { 504 break; 505 } 506 } 507 } 508 509 return obj; 510 }, 511 512 // Support: Android<4.1 513 trim: function( text ) { 514 return text == null ? 515 "" : 516 ( text + "" ).replace( rtrim, "" ); 517 }, 518 519 // results is for internal usage only 520 makeArray: function( arr, results ) { 521 var ret = results || []; 522 523 if ( arr != null ) { 524 if ( isArrayLike( Object( arr ) ) ) { 525 jQuery.merge( ret, 526 typeof arr === "string" ? 527 [ arr ] : arr 528 ); 529 } else { 530 push.call( ret, arr ); 531 } 532 } 533 534 return ret; 535 }, 536 537 inArray: function( elem, arr, i ) { 538 return arr == null ? -1 : indexOf.call( arr, elem, i ); 539 }, 540 541 merge: function( first, second ) { 542 var len = +second.length, 543 j = 0, 544 i = first.length; 545 546 for ( ; j < len; j++ ) { 547 first[ i++ ] = second[ j ]; 548 } 549 550 first.length = i; 551 552 return first; 553 }, 554 555 grep: function( elems, callback, invert ) { 556 var callbackInverse, 557 matches = [], 558 i = 0, 559 length = elems.length, 560 callbackExpect = !invert; 561 562 // Go through the array, only saving the items 563 // that pass the validator function 564 for ( ; i < length; i++ ) { 565 callbackInverse = !callback( elems[ i ], i ); 566 if ( callbackInverse !== callbackExpect ) { 567 matches.push( elems[ i ] ); 568 } 569 } 570 571 return matches; 572 }, 573 574 // arg is for internal usage only 575 map: function( elems, callback, arg ) { 576 var length, value, 577 i = 0, 578 ret = []; 579 580 // Go through the array, translating each of the items to their new values 581 if ( isArrayLike( elems ) ) { 582 length = elems.length; 583 for ( ; i < length; i++ ) { 584 value = callback( elems[ i ], i, arg ); 585 586 if ( value != null ) { 587 ret.push( value ); 588 } 589 } 590 591 // Go through every key on the object, 592 } else { 593 for ( i in elems ) { 594 value = callback( elems[ i ], i, arg ); 595 596 if ( value != null ) { 597 ret.push( value ); 598 } 599 } 600 } 601 602 // Flatten any nested arrays 603 return concat.apply( [], ret ); 604 }, 605 606 // A global GUID counter for objects 607 guid: 1, 608 609 // Bind a function to a context, optionally partially applying any 610 // arguments. 611 proxy: function( fn, context ) { 612 var tmp, args, proxy; 613 614 if ( typeof context === "string" ) { 615 tmp = fn[ context ]; 616 context = fn; 617 fn = tmp; 618 } 619 620 // Quick check to determine if target is callable, in the spec 621 // this throws a TypeError, but we will just return undefined. 622 if ( !jQuery.isFunction( fn ) ) { 623 return undefined; 624 } 625 626 // Simulated bind 627 args = slice.call( arguments, 2 ); 628 proxy = function() { 629 return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); 630 }; 631 632 // Set the guid of unique handler to the same of original handler, so it can be removed 633 proxy.guid = fn.guid = fn.guid || jQuery.guid++; 634 635 return proxy; 636 }, 637 638 now: Date.now, 639 640 // jQuery.support is not used in Core but other projects attach their 641 // properties to it so it needs to exist. 642 support: support 643 } ); 644 645 // JSHint would error on this code due to the Symbol not being defined in ES5. 646 // Defining this global in .jshintrc would create a danger of using the global 647 // unguarded in another place, it seems safer to just disable JSHint for these 648 // three lines. 649 /* jshint ignore: start */ 650 if ( typeof Symbol === "function" ) { 651 jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ]; 652 } 653 /* jshint ignore: end */ 654 655 // Populate the class2type map 656 jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), 657 function( i, name ) { 658 class2type[ "[object " + name + "]" ] = name.toLowerCase(); 659 } ); 660 661 function isArrayLike( obj ) { 662 663 // Support: iOS 8.2 (not reproducible in simulator) 664 // `in` check used to prevent JIT error (gh-2145) 665 // hasOwn isn't used here due to false negatives 666 // regarding Nodelist length in IE 667 var length = !!obj && "length" in obj && obj.length, 668 type = jQuery.type( obj ); 669 670 if ( type === "function" || jQuery.isWindow( obj ) ) { 671 return false; 672 } 673 674 return type === "array" || length === 0 || 675 typeof length === "number" && length > 0 && ( length - 1 ) in obj; 676 } 677 var Sizzle = 678 /*! 679 * Sizzle CSS Selector Engine v2.2.1 680 * http://sizzlejs.com/ 681 * 682 * Copyright jQuery Foundation and other contributors 683 * Released under the MIT license 684 * http://jquery.org/license 685 * 686 * Date: 2015-10-17 687 */ 688 (function( window ) { 689 690 var i, 691 support, 692 Expr, 693 getText, 694 isXML, 695 tokenize, 696 compile, 697 select, 698 outermostContext, 699 sortInput, 700 hasDuplicate, 701 702 // Local document vars 703 setDocument, 704 document, 705 docElem, 706 documentIsHTML, 707 rbuggyQSA, 708 rbuggyMatches, 709 matches, 710 contains, 711 712 // Instance-specific data 713 expando = "sizzle" + 1 * new Date(), 714 preferredDoc = window.document, 715 dirruns = 0, 716 done = 0, 717 classCache = createCache(), 718 tokenCache = createCache(), 719 compilerCache = createCache(), 720 sortOrder = function( a, b ) { 721 if ( a === b ) { 722 hasDuplicate = true; 723 } 724 return 0; 725 }, 726 727 // General-purpose constants 728 MAX_NEGATIVE = 1 << 31, 729 730 // Instance methods 731 hasOwn = ({}).hasOwnProperty, 732 arr = [], 733 pop = arr.pop, 734 push_native = arr.push, 735 push = arr.push, 736 slice = arr.slice, 737 // Use a stripped-down indexOf as it's faster than native 738 // http://jsperf.com/thor-indexof-vs-for/5 739 indexOf = function( list, elem ) { 740 var i = 0, 741 len = list.length; 742 for ( ; i < len; i++ ) { 743 if ( list[i] === elem ) { 744 return i; 745 } 746 } 747 return -1; 748 }, 749 750 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", 751 752 // Regular expressions 753 754 // http://www.w3.org/TR/css3-selectors/#whitespace 755 whitespace = "[\\x20\\t\\r\\n\\f]", 756 757 // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier 758 identifier = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", 759 760 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors 761 attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + 762 // Operator (capture 2) 763 "*([*^$|!~]?=)" + whitespace + 764 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" 765 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + 766 "*\\]", 767 768 pseudos = ":(" + identifier + ")(?:\\((" + 769 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: 770 // 1. quoted (capture 3; capture 4 or capture 5) 771 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + 772 // 2. simple (capture 6) 773 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + 774 // 3. anything else (capture 2) 775 ".*" + 776 ")\\)|)", 777 778 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter 779 rwhitespace = new RegExp( whitespace + "+", "g" ), 780 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), 781 782 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), 783 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), 784 785 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ), 786 787 rpseudo = new RegExp( pseudos ), 788 ridentifier = new RegExp( "^" + identifier + "$" ), 789 790 matchExpr = { 791 "ID": new RegExp( "^#(" + identifier + ")" ), 792 "CLASS": new RegExp( "^\\.(" + identifier + ")" ), 793 "TAG": new RegExp( "^(" + identifier + "|[*])" ), 794 "ATTR": new RegExp( "^" + attributes ), 795 "PSEUDO": new RegExp( "^" + pseudos ), 796 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + 797 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + 798 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), 799 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), 800 // For use in libraries implementing .is() 801 // We use this for POS matching in `select` 802 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + 803 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) 804 }, 805 806 rinputs = /^(?:input|select|textarea|button)$/i, 807 rheader = /^h\d$/i, 808 809 rnative = /^[^{]+\{\s*\[native \w/, 810 811 // Easily-parseable/retrievable ID or TAG or CLASS selectors 812 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, 813 814 rsibling = /[+~]/, 815 rescape = /'|\\/g, 816 817 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters 818 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), 819 funescape = function( _, escaped, escapedWhitespace ) { 820 var high = "0x" + escaped - 0x10000; 821 // NaN means non-codepoint 822 // Support: Firefox<24 823 // Workaround erroneous numeric interpretation of +"0x" 824 return high !== high || escapedWhitespace ? 825 escaped : 826 high < 0 ? 827 // BMP codepoint 828 String.fromCharCode( high + 0x10000 ) : 829 // Supplemental Plane codepoint (surrogate pair) 830 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); 831 }, 832 833 // Used for iframes 834 // See setDocument() 835 // Removing the function wrapper causes a "Permission Denied" 836 // error in IE 837 unloadHandler = function() { 838 setDocument(); 839 }; 840 841 // Optimize for push.apply( _, NodeList ) 842 try { 843 push.apply( 844 (arr = slice.call( preferredDoc.childNodes )), 845 preferredDoc.childNodes 846 ); 847 // Support: Android<4.0 848 // Detect silently failing push.apply 849 arr[ preferredDoc.childNodes.length ].nodeType; 850 } catch ( e ) { 851 push = { apply: arr.length ? 852 853 // Leverage slice if possible 854 function( target, els ) { 855 push_native.apply( target, slice.call(els) ); 856 } : 857 858 // Support: IE<9 859 // Otherwise append directly 860 function( target, els ) { 861 var j = target.length, 862 i = 0; 863 // Can't trust NodeList.length 864 while ( (target[j++] = els[i++]) ) {} 865 target.length = j - 1; 866 } 867 }; 868 } 869 870 function Sizzle( selector, context, results, seed ) { 871 var m, i, elem, nid, nidselect, match, groups, newSelector, 872 newContext = context && context.ownerDocument, 873 874 // nodeType defaults to 9, since context defaults to document 875 nodeType = context ? context.nodeType : 9; 876 877 results = results || []; 878 879 // Return early from calls with invalid selector or context 880 if ( typeof selector !== "string" || !selector || 881 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { 882 883 return results; 884 } 885 886 // Try to shortcut find operations (as opposed to filters) in HTML documents 887 if ( !seed ) { 888 889 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { 890 setDocument( context ); 891 } 892 context = context || document; 893 894 if ( documentIsHTML ) { 895 896 // If the selector is sufficiently simple, try using a "get*By*" DOM method 897 // (excepting DocumentFragment context, where the methods don't exist) 898 if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) { 899 900 // ID selector 901 if ( (m = match[1]) ) { 902 903 // Document context 904 if ( nodeType === 9 ) { 905 if ( (elem = context.getElementById( m )) ) { 906 907 // Support: IE, Opera, Webkit 908 // TODO: identify versions 909 // getElementById can match elements by name instead of ID 910 if ( elem.id === m ) { 911 results.push( elem ); 912 return results; 913 } 914 } else { 915 return results; 916 } 917 918 // Element context 919 } else { 920 921 // Support: IE, Opera, Webkit 922 // TODO: identify versions 923 // getElementById can match elements by name instead of ID 924 if ( newContext && (elem = newContext.getElementById( m )) && 925 contains( context, elem ) && 926 elem.id === m ) { 927 928 results.push( elem ); 929 return results; 930 } 931 } 932 933 // Type selector 934 } else if ( match[2] ) { 935 push.apply( results, context.getElementsByTagName( selector ) ); 936 return results; 937 938 // Class selector 939 } else if ( (m = match[3]) && support.getElementsByClassName && 940 context.getElementsByClassName ) { 941 942 push.apply( results, context.getElementsByClassName( m ) ); 943 return results; 944 } 945 } 946 947 // Take advantage of querySelectorAll 948 if ( support.qsa && 949 !compilerCache[ selector + " " ] && 950 (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { 951 952 if ( nodeType !== 1 ) { 953 newContext = context; 954 newSelector = selector; 955 956 // qSA looks outside Element context, which is not what we want 957 // Thanks to Andrew Dupont for this workaround technique 958 // Support: IE <=8 959 // Exclude object elements 960 } else if ( context.nodeName.toLowerCase() !== "object" ) { 961 962 // Capture the context ID, setting it first if necessary 963 if ( (nid = context.getAttribute( "id" )) ) { 964 nid = nid.replace( rescape, "\\$&" ); 965 } else { 966 context.setAttribute( "id", (nid = expando) ); 967 } 968 969 // Prefix every selector in the list 970 groups = tokenize( selector ); 971 i = groups.length; 972 nidselect = ridentifier.test( nid ) ? "#" + nid : "[id='" + nid + "']"; 973 while ( i-- ) { 974 groups[i] = nidselect + " " + toSelector( groups[i] ); 975 } 976 newSelector = groups.join( "," ); 977 978 // Expand context for sibling selectors 979 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || 980 context; 981 } 982 983 if ( newSelector ) { 984 try { 985 push.apply( results, 986 newContext.querySelectorAll( newSelector ) 987 ); 988 return results; 989 } catch ( qsaError ) { 990 } finally { 991 if ( nid === expando ) { 992 context.removeAttribute( "id" ); 993 } 994 } 995 } 996 } 997 } 998 } 999 1000 // All others 1001 return select( selector.replace( rtrim, "$1" ), context, results, seed ); 1002 } 1003 1004 /** 1005 * Create key-value caches of limited size 1006 * @returns {function(string, object)} Returns the Object data after storing it on itself with 1007 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) 1008 * deleting the oldest entry 1009 */ 1010 function createCache() { 1011 var keys = []; 1012 1013 function cache( key, value ) { 1014 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) 1015 if ( keys.push( key + " " ) > Expr.cacheLength ) { 1016 // Only keep the most recent entries 1017 delete cache[ keys.shift() ]; 1018 } 1019 return (cache[ key + " " ] = value); 1020 } 1021 return cache; 1022 } 1023 1024 /** 1025 * Mark a function for special use by Sizzle 1026 * @param {Function} fn The function to mark 1027 */ 1028 function markFunction( fn ) { 1029 fn[ expando ] = true; 1030 return fn; 1031 } 1032 1033 /** 1034 * Support testing using an element 1035 * @param {Function} fn Passed the created div and expects a boolean result 1036 */ 1037 function assert( fn ) { 1038 var div = document.createElement("div"); 1039 1040 try { 1041 return !!fn( div ); 1042 } catch (e) { 1043 return false; 1044 } finally { 1045 // Remove from its parent by default 1046 if ( div.parentNode ) { 1047 div.parentNode.removeChild( div ); 1048 } 1049 // release memory in IE 1050 div = null; 1051 } 1052 } 1053 1054 /** 1055 * Adds the same handler for all of the specified attrs 1056 * @param {String} attrs Pipe-separated list of attributes 1057 * @param {Function} handler The method that will be applied 1058 */ 1059 function addHandle( attrs, handler ) { 1060 var arr = attrs.split("|"), 1061 i = arr.length; 1062 1063 while ( i-- ) { 1064 Expr.attrHandle[ arr[i] ] = handler; 1065 } 1066 } 1067 1068 /** 1069 * Checks document order of two siblings 1070 * @param {Element} a 1071 * @param {Element} b 1072 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b 1073 */ 1074 function siblingCheck( a, b ) { 1075 var cur = b && a, 1076 diff = cur && a.nodeType === 1 && b.nodeType === 1 && 1077 ( ~b.sourceIndex || MAX_NEGATIVE ) - 1078 ( ~a.sourceIndex || MAX_NEGATIVE ); 1079 1080 // Use IE sourceIndex if available on both nodes 1081 if ( diff ) { 1082 return diff; 1083 } 1084 1085 // Check if b follows a 1086 if ( cur ) { 1087 while ( (cur = cur.nextSibling) ) { 1088 if ( cur === b ) { 1089 return -1; 1090 } 1091 } 1092 } 1093 1094 return a ? 1 : -1; 1095 } 1096 1097 /** 1098 * Returns a function to use in pseudos for input types 1099 * @param {String} type 1100 */ 1101 function createInputPseudo( type ) { 1102 return function( elem ) { 1103 var name = elem.nodeName.toLowerCase(); 1104 return name === "input" && elem.type === type; 1105 }; 1106 } 1107 1108 /** 1109 * Returns a function to use in pseudos for buttons 1110 * @param {String} type 1111 */ 1112 function createButtonPseudo( type ) { 1113 return function( elem ) { 1114 var name = elem.nodeName.toLowerCase(); 1115 return (name === "input" || name === "button") && elem.type === type; 1116 }; 1117 } 1118 1119 /** 1120 * Returns a function to use in pseudos for positionals 1121 * @param {Function} fn 1122 */ 1123 function createPositionalPseudo( fn ) { 1124 return markFunction(function( argument ) { 1125 argument = +argument; 1126 return markFunction(function( seed, matches ) { 1127 var j, 1128 matchIndexes = fn( [], seed.length, argument ), 1129 i = matchIndexes.length; 1130 1131 // Match elements found at the specified indexes 1132 while ( i-- ) { 1133 if ( seed[ (j = matchIndexes[i]) ] ) { 1134 seed[j] = !(matches[j] = seed[j]); 1135 } 1136 } 1137 }); 1138 }); 1139 } 1140 1141 /** 1142 * Checks a node for validity as a Sizzle context 1143 * @param {Element|Object=} context 1144 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value 1145 */ 1146 function testContext( context ) { 1147 return context && typeof context.getElementsByTagName !== "undefined" && context; 1148 } 1149 1150 // Expose support vars for convenience 1151 support = Sizzle.support = {}; 1152 1153 /** 1154 * Detects XML nodes 1155 * @param {Element|Object} elem An element or a document 1156 * @returns {Boolean} True iff elem is a non-HTML XML node 1157 */ 1158 isXML = Sizzle.isXML = function( elem ) { 1159 // documentElement is verified for cases where it doesn't yet exist 1160 // (such as loading iframes in IE - #4833) 1161 var documentElement = elem && (elem.ownerDocument || elem).documentElement; 1162 return documentElement ? documentElement.nodeName !== "HTML" : false; 1163 }; 1164 1165 /** 1166 * Sets document-related variables once based on the current document 1167 * @param {Element|Object} [doc] An element or document object to use to set the document 1168 * @returns {Object} Returns the current document 1169 */ 1170 setDocument = Sizzle.setDocument = function( node ) { 1171 var hasCompare, parent, 1172 doc = node ? node.ownerDocument || node : preferredDoc; 1173 1174 // Return early if doc is invalid or already selected 1175 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { 1176 return document; 1177 } 1178 1179 // Update global variables 1180 document = doc; 1181 docElem = document.documentElement; 1182 documentIsHTML = !isXML( document ); 1183 1184 // Support: IE 9-11, Edge 1185 // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) 1186 if ( (parent = document.defaultView) && parent.top !== parent ) { 1187 // Support: IE 11 1188 if ( parent.addEventListener ) { 1189 parent.addEventListener( "unload", unloadHandler, false ); 1190 1191 // Support: IE 9 - 10 only 1192 } else if ( parent.attachEvent ) { 1193 parent.attachEvent( "onunload", unloadHandler ); 1194 } 1195 } 1196 1197 /* Attributes 1198 ---------------------------------------------------------------------- */ 1199 1200 // Support: IE<8 1201 // Verify that getAttribute really returns attributes and not properties 1202 // (excepting IE8 booleans) 1203 support.attributes = assert(function( div ) { 1204 div.className = "i"; 1205 return !div.getAttribute("className"); 1206 }); 1207 1208 /* getElement(s)By* 1209 ---------------------------------------------------------------------- */ 1210 1211 // Check if getElementsByTagName("*") returns only elements 1212 support.getElementsByTagName = assert(function( div ) { 1213 div.appendChild( document.createComment("") ); 1214 return !div.getElementsByTagName("*").length; 1215 }); 1216 1217 // Support: IE<9 1218 support.getElementsByClassName = rnative.test( document.getElementsByClassName ); 1219 1220 // Support: IE<10 1221 // Check if getElementById returns elements by name 1222 // The broken getElementById methods don't pick up programatically-set names, 1223 // so use a roundabout getElementsByName test 1224 support.getById = assert(function( div ) { 1225 docElem.appendChild( div ).id = expando; 1226 return !document.getElementsByName || !document.getElementsByName( expando ).length; 1227 }); 1228 1229 // ID find and filter 1230 if ( support.getById ) { 1231 Expr.find["ID"] = function( id, context ) { 1232 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { 1233 var m = context.getElementById( id ); 1234 return m ? [ m ] : []; 1235 } 1236 }; 1237 Expr.filter["ID"] = function( id ) { 1238 var attrId = id.replace( runescape, funescape ); 1239 return function( elem ) { 1240 return elem.getAttribute("id") === attrId; 1241 }; 1242 }; 1243 } else { 1244 // Support: IE6/7 1245 // getElementById is not reliable as a find shortcut 1246 delete Expr.find["ID"]; 1247 1248 Expr.filter["ID"] = function( id ) { 1249 var attrId = id.replace( runescape, funescape ); 1250 return function( elem ) { 1251 var node = typeof elem.getAttributeNode !== "undefined" && 1252 elem.getAttributeNode("id"); 1253 return node && node.value === attrId; 1254 }; 1255 }; 1256 } 1257 1258 // Tag 1259 Expr.find["TAG"] = support.getElementsByTagName ? 1260 function( tag, context ) { 1261 if ( typeof context.getElementsByTagName !== "undefined" ) { 1262 return context.getElementsByTagName( tag ); 1263 1264 // DocumentFragment nodes don't have gEBTN 1265 } else if ( support.qsa ) { 1266 return context.querySelectorAll( tag ); 1267 } 1268 } : 1269 1270 function( tag, context ) { 1271 var elem, 1272 tmp = [], 1273 i = 0, 1274 // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too 1275 results = context.getElementsByTagName( tag ); 1276 1277 // Filter out possible comments 1278 if ( tag === "*" ) { 1279 while ( (elem = results[i++]) ) { 1280 if ( elem.nodeType === 1 ) { 1281 tmp.push( elem ); 1282 } 1283 } 1284 1285 return tmp; 1286 } 1287 return results; 1288 }; 1289 1290 // Class 1291 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { 1292 if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { 1293 return context.getElementsByClassName( className ); 1294 } 1295 }; 1296 1297 /* QSA/matchesSelector 1298 ---------------------------------------------------------------------- */ 1299 1300 // QSA and matchesSelector support 1301 1302 // matchesSelector(:active) reports false when true (IE9/Opera 11.5) 1303 rbuggyMatches = []; 1304 1305 // qSa(:focus) reports false when true (Chrome 21) 1306 // We allow this because of a bug in IE8/9 that throws an error 1307 // whenever `document.activeElement` is accessed on an iframe 1308 // So, we allow :focus to pass through QSA all the time to avoid the IE error 1309 // See http://bugs.jquery.com/ticket/13378 1310 rbuggyQSA = []; 1311 1312 if ( (support.qsa = rnative.test( document.querySelectorAll )) ) { 1313 // Build QSA regex 1314 // Regex strategy adopted from Diego Perini 1315 assert(function( div ) { 1316 // Select is set to empty string on purpose 1317 // This is to test IE's treatment of not explicitly 1318 // setting a boolean content attribute, 1319 // since its presence should be enough 1320 // http://bugs.jquery.com/ticket/12359 1321 docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" + 1322 "<select id='" + expando + "-\r\\' msallowcapture=''>" + 1323 "<option selected=''></option></select>"; 1324 1325 // Support: IE8, Opera 11-12.16 1326 // Nothing should be selected when empty strings follow ^= or $= or *= 1327 // The test attribute must be unknown in Opera but "safe" for WinRT 1328 // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section 1329 if ( div.querySelectorAll("[msallowcapture^='']").length ) { 1330 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); 1331 } 1332 1333 // Support: IE8 1334 // Boolean attributes and "value" are not treated correctly 1335 if ( !div.querySelectorAll("[selected]").length ) { 1336 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); 1337 } 1338 1339 // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+ 1340 if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) { 1341 rbuggyQSA.push("~="); 1342 } 1343 1344 // Webkit/Opera - :checked should return selected option elements 1345 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked 1346 // IE8 throws error here and will not see later tests 1347 if ( !div.querySelectorAll(":checked").length ) { 1348 rbuggyQSA.push(":checked"); 1349 } 1350 1351 // Support: Safari 8+, iOS 8+ 1352 // https://bugs.webkit.org/show_bug.cgi?id=136851 1353 // In-page `selector#id sibing-combinator selector` fails 1354 if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) { 1355 rbuggyQSA.push(".#.+[+~]"); 1356 } 1357 }); 1358 1359 assert(function( div ) { 1360 // Support: Windows 8 Native Apps 1361 // The type and name attributes are restricted during .innerHTML assignment 1362 var input = document.createElement("input"); 1363 input.setAttribute( "type", "hidden" ); 1364 div.appendChild( input ).setAttribute( "name", "D" ); 1365 1366 // Support: IE8 1367 // Enforce case-sensitivity of name attribute 1368 if ( div.querySelectorAll("[name=d]").length ) { 1369 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); 1370 } 1371 1372 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) 1373 // IE8 throws error here and will not see later tests 1374 if ( !div.querySelectorAll(":enabled").length ) { 1375 rbuggyQSA.push( ":enabled", ":disabled" ); 1376 } 1377 1378 // Opera 10-11 does not throw on post-comma invalid pseudos 1379 div.querySelectorAll("*,:x"); 1380 rbuggyQSA.push(",.*:"); 1381 }); 1382 } 1383 1384 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches || 1385 docElem.webkitMatchesSelector || 1386 docElem.mozMatchesSelector || 1387 docElem.oMatchesSelector || 1388 docElem.msMatchesSelector) )) ) { 1389 1390 assert(function( div ) { 1391 // Check to see if it's possible to do matchesSelector 1392 // on a disconnected node (IE 9) 1393 support.disconnectedMatch = matches.call( div, "div" ); 1394 1395 // This should fail with an exception 1396 // Gecko does not error, returns false instead 1397 matches.call( div, "[s!='']:x" ); 1398 rbuggyMatches.push( "!=", pseudos ); 1399 }); 1400 } 1401 1402 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); 1403 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); 1404 1405 /* Contains 1406 ---------------------------------------------------------------------- */ 1407 hasCompare = rnative.test( docElem.compareDocumentPosition ); 1408 1409 // Element contains another 1410 // Purposefully self-exclusive 1411 // As in, an element does not contain itself 1412 contains = hasCompare || rnative.test( docElem.contains ) ? 1413 function( a, b ) { 1414 var adown = a.nodeType === 9 ? a.documentElement : a, 1415 bup = b && b.parentNode; 1416 return a === bup || !!( bup && bup.nodeType === 1 && ( 1417 adown.contains ? 1418 adown.contains( bup ) : 1419 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 1420 )); 1421 } : 1422 function( a, b ) { 1423 if ( b ) { 1424 while ( (b = b.parentNode) ) { 1425 if ( b === a ) { 1426 return true; 1427 } 1428 } 1429 } 1430 return false; 1431 }; 1432 1433 /* Sorting 1434 ---------------------------------------------------------------------- */ 1435 1436 // Document order sorting 1437 sortOrder = hasCompare ? 1438 function( a, b ) { 1439 1440 // Flag for duplicate removal 1441 if ( a === b ) { 1442 hasDuplicate = true; 1443 return 0; 1444 } 1445 1446 // Sort on method existence if only one input has compareDocumentPosition 1447 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; 1448 if ( compare ) { 1449 return compare; 1450 } 1451 1452 // Calculate position if both inputs belong to the same document 1453 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? 1454 a.compareDocumentPosition( b ) : 1455 1456 // Otherwise we know they are disconnected 1457 1; 1458 1459 // Disconnected nodes 1460 if ( compare & 1 || 1461 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { 1462 1463 // Choose the first element that is related to our preferred document 1464 if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { 1465 return -1; 1466 } 1467 if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { 1468 return 1; 1469 } 1470 1471 // Maintain original order 1472 return sortInput ? 1473 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : 1474 0; 1475 } 1476 1477 return compare & 4 ? -1 : 1; 1478 } : 1479 function( a, b ) { 1480 // Exit early if the nodes are identical 1481 if ( a === b ) { 1482 hasDuplicate = true; 1483 return 0; 1484 } 1485 1486 var cur, 1487 i = 0, 1488 aup = a.parentNode, 1489 bup = b.parentNode, 1490 ap = [ a ], 1491 bp = [ b ]; 1492 1493 // Parentless nodes are either documents or disconnected 1494 if ( !aup || !bup ) { 1495 return a === document ? -1 : 1496 b === document ? 1 : 1497 aup ? -1 : 1498 bup ? 1 : 1499 sortInput ? 1500 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : 1501 0; 1502 1503 // If the nodes are siblings, we can do a quick check 1504 } else if ( aup === bup ) { 1505 return siblingCheck( a, b ); 1506 } 1507 1508 // Otherwise we need full lists of their ancestors for comparison 1509 cur = a; 1510 while ( (cur = cur.parentNode) ) { 1511 ap.unshift( cur ); 1512 } 1513 cur = b; 1514 while ( (cur = cur.parentNode) ) { 1515 bp.unshift( cur ); 1516 } 1517 1518 // Walk down the tree looking for a discrepancy 1519 while ( ap[i] === bp[i] ) { 1520 i++; 1521 } 1522 1523 return i ? 1524 // Do a sibling check if the nodes have a common ancestor 1525 siblingCheck( ap[i], bp[i] ) : 1526 1527 // Otherwise nodes in our document sort first 1528 ap[i] === preferredDoc ? -1 : 1529 bp[i] === preferredDoc ? 1 : 1530 0; 1531 }; 1532 1533 return document; 1534 }; 1535 1536 Sizzle.matches = function( expr, elements ) { 1537 return Sizzle( expr, null, null, elements ); 1538 }; 1539 1540 Sizzle.matchesSelector = function( elem, expr ) { 1541 // Set document vars if needed 1542 if ( ( elem.ownerDocument || elem ) !== document ) { 1543 setDocument( elem ); 1544 } 1545 1546 // Make sure that attribute selectors are quoted 1547 expr = expr.replace( rattributeQuotes, "='$1']" ); 1548 1549 if ( support.matchesSelector && documentIsHTML && 1550 !compilerCache[ expr + " " ] && 1551 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && 1552 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { 1553 1554 try { 1555 var ret = matches.call( elem, expr ); 1556 1557 // IE 9's matchesSelector returns false on disconnected nodes 1558 if ( ret || support.disconnectedMatch || 1559 // As well, disconnected nodes are said to be in a document 1560 // fragment in IE 9 1561 elem.document && elem.document.nodeType !== 11 ) { 1562 return ret; 1563 } 1564 } catch (e) {} 1565 } 1566 1567 return Sizzle( expr, document, null, [ elem ] ).length > 0; 1568 }; 1569 1570 Sizzle.contains = function( context, elem ) { 1571 // Set document vars if needed 1572 if ( ( context.ownerDocument || context ) !== document ) { 1573 setDocument( context ); 1574 } 1575 return contains( context, elem ); 1576 }; 1577 1578 Sizzle.attr = function( elem, name ) { 1579 // Set document vars if needed 1580 if ( ( elem.ownerDocument || elem ) !== document ) { 1581 setDocument( elem ); 1582 } 1583 1584 var fn = Expr.attrHandle[ name.toLowerCase() ], 1585 // Don't get fooled by Object.prototype properties (jQuery #13807) 1586 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? 1587 fn( elem, name, !documentIsHTML ) : 1588 undefined; 1589 1590 return val !== undefined ? 1591 val : 1592 support.attributes || !documentIsHTML ? 1593 elem.getAttribute( name ) : 1594 (val = elem.getAttributeNode(name)) && val.specified ? 1595 val.value : 1596 null; 1597 }; 1598 1599 Sizzle.error = function( msg ) { 1600 throw new Error( "Syntax error, unrecognized expression: " + msg ); 1601 }; 1602 1603 /** 1604 * Document sorting and removing duplicates 1605 * @param {ArrayLike} results 1606 */ 1607 Sizzle.uniqueSort = function( results ) { 1608 var elem, 1609 duplicates = [], 1610 j = 0, 1611 i = 0; 1612 1613 // Unless we *know* we can detect duplicates, assume their presence 1614 hasDuplicate = !support.detectDuplicates; 1615 sortInput = !support.sortStable && results.slice( 0 ); 1616 results.sort( sortOrder ); 1617 1618 if ( hasDuplicate ) { 1619 while ( (elem = results[i++]) ) { 1620 if ( elem === results[ i ] ) { 1621 j = duplicates.push( i ); 1622 } 1623 } 1624 while ( j-- ) { 1625 results.splice( duplicates[ j ], 1 ); 1626 } 1627 } 1628 1629 // Clear input after sorting to release objects 1630 // See https://github.com/jquery/sizzle/pull/225 1631 sortInput = null; 1632 1633 return results; 1634 }; 1635 1636 /** 1637 * Utility function for retrieving the text value of an array of DOM nodes 1638 * @param {Array|Element} elem 1639 */ 1640 getText = Sizzle.getText = function( elem ) { 1641 var node, 1642 ret = "", 1643 i = 0, 1644 nodeType = elem.nodeType; 1645 1646 if ( !nodeType ) { 1647 // If no nodeType, this is expected to be an array 1648 while ( (node = elem[i++]) ) { 1649 // Do not traverse comment nodes 1650 ret += getText( node ); 1651 } 1652 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { 1653 // Use textContent for elements 1654 // innerText usage removed for consistency of new lines (jQuery #11153) 1655 if ( typeof elem.textContent === "string" ) { 1656 return elem.textContent; 1657 } else { 1658 // Traverse its children 1659 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { 1660 ret += getText( elem ); 1661 } 1662 } 1663 } else if ( nodeType === 3 || nodeType === 4 ) { 1664 return elem.nodeValue; 1665 } 1666 // Do not include comment or processing instruction nodes 1667 1668 return ret; 1669 }; 1670 1671 Expr = Sizzle.selectors = { 1672 1673 // Can be adjusted by the user 1674 cacheLength: 50, 1675 1676 createPseudo: markFunction, 1677 1678 match: matchExpr, 1679 1680 attrHandle: {}, 1681 1682 find: {}, 1683 1684 relative: { 1685 ">": { dir: "parentNode", first: true }, 1686 " ": { dir: "parentNode" }, 1687 "+": { dir: "previousSibling", first: true }, 1688 "~": { dir: "previousSibling" } 1689 }, 1690 1691 preFilter: { 1692 "ATTR": function( match ) { 1693 match[1] = match[1].replace( runescape, funescape ); 1694 1695 // Move the given value to match[3] whether quoted or unquoted 1696 match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape ); 1697 1698 if ( match[2] === "~=" ) { 1699 match[3] = " " + match[3] + " "; 1700 } 1701 1702 return match.slice( 0, 4 ); 1703 }, 1704 1705 "CHILD": function( match ) { 1706 /* matches from matchExpr["CHILD"] 1707 1 type (only|nth|...) 1708 2 what (child|of-type) 1709 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) 1710 4 xn-component of xn+y argument ([+-]?\d*n|) 1711 5 sign of xn-component 1712 6 x of xn-component 1713 7 sign of y-component 1714 8 y of y-component 1715 */ 1716 match[1] = match[1].toLowerCase(); 1717 1718 if ( match[1].slice( 0, 3 ) === "nth" ) { 1719 // nth-* requires argument 1720 if ( !match[3] ) { 1721 Sizzle.error( match[0] ); 1722 } 1723 1724 // numeric x and y parameters for Expr.filter.CHILD 1725 // remember that false/true cast respectively to 0/1 1726 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); 1727 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); 1728 1729 // other types prohibit arguments 1730 } else if ( match[3] ) { 1731 Sizzle.error( match[0] ); 1732 } 1733 1734 return match; 1735 }, 1736 1737 "PSEUDO": function( match ) { 1738 var excess, 1739 unquoted = !match[6] && match[2]; 1740 1741 if ( matchExpr["CHILD"].test( match[0] ) ) { 1742 return null; 1743 } 1744 1745 // Accept quoted arguments as-is 1746 if ( match[3] ) { 1747 match[2] = match[4] || match[5] || ""; 1748 1749 // Strip excess characters from unquoted arguments 1750 } else if ( unquoted && rpseudo.test( unquoted ) && 1751 // Get excess from tokenize (recursively) 1752 (excess = tokenize( unquoted, true )) && 1753 // advance to the next closing parenthesis 1754 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { 1755 1756 // excess is a negative index 1757 match[0] = match[0].slice( 0, excess ); 1758 match[2] = unquoted.slice( 0, excess ); 1759 } 1760 1761 // Return only captures needed by the pseudo filter method (type and argument) 1762 return match.slice( 0, 3 ); 1763 } 1764 }, 1765 1766 filter: { 1767 1768 "TAG": function( nodeNameSelector ) { 1769 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); 1770 return nodeNameSelector === "*" ? 1771 function() { return true; } : 1772 function( elem ) { 1773 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; 1774 }; 1775 }, 1776 1777 "CLASS": function( className ) { 1778 var pattern = classCache[ className + " " ]; 1779 1780 return pattern || 1781 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && 1782 classCache( className, function( elem ) { 1783 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" ); 1784 }); 1785 }, 1786 1787 "ATTR": function( name, operator, check ) { 1788 return function( elem ) { 1789 var result = Sizzle.attr( elem, name ); 1790 1791 if ( result == null ) { 1792 return operator === "!="; 1793 } 1794 if ( !operator ) { 1795 return true; 1796 } 1797 1798 result += ""; 1799 1800 return operator === "=" ? result === check : 1801 operator === "!=" ? result !== check : 1802 operator === "^=" ? check && result.indexOf( check ) === 0 : 1803 operator === "*=" ? check && result.indexOf( check ) > -1 : 1804 operator === "$=" ? check && result.slice( -check.length ) === check : 1805 operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : 1806 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : 1807 false; 1808 }; 1809 }, 1810 1811 "CHILD": function( type, what, argument, first, last ) { 1812 var simple = type.slice( 0, 3 ) !== "nth", 1813 forward = type.slice( -4 ) !== "last", 1814 ofType = what === "of-type"; 1815 1816 return first === 1 && last === 0 ? 1817 1818 // Shortcut for :nth-*(n) 1819 function( elem ) { 1820 return !!elem.parentNode; 1821 } : 1822 1823 function( elem, context, xml ) { 1824 var cache, uniqueCache, outerCache, node, nodeIndex, start, 1825 dir = simple !== forward ? "nextSibling" : "previousSibling", 1826 parent = elem.parentNode, 1827 name = ofType && elem.nodeName.toLowerCase(), 1828 useCache = !xml && !ofType, 1829 diff = false; 1830 1831 if ( parent ) { 1832 1833 // :(first|last|only)-(child|of-type) 1834 if ( simple ) { 1835 while ( dir ) { 1836 node = elem; 1837 while ( (node = node[ dir ]) ) { 1838 if ( ofType ? 1839 node.nodeName.toLowerCase() === name : 1840 node.nodeType === 1 ) { 1841 1842 return false; 1843 } 1844 } 1845 // Reverse direction for :only-* (if we haven't yet done so) 1846 start = dir = type === "only" && !start && "nextSibling"; 1847 } 1848 return true; 1849 } 1850 1851 start = [ forward ? parent.firstChild : parent.lastChild ]; 1852 1853 // non-xml :nth-child(...) stores cache data on `parent` 1854 if ( forward && useCache ) { 1855 1856 // Seek `elem` from a previously-cached index 1857 1858 // ...in a gzip-friendly way 1859 node = parent; 1860 outerCache = node[ expando ] || (node[ expando ] = {}); 1861 1862 // Support: IE <9 only 1863 // Defend against cloned attroperties (jQuery gh-1709) 1864 uniqueCache = outerCache[ node.uniqueID ] || 1865 (outerCache[ node.uniqueID ] = {}); 1866 1867 cache = uniqueCache[ type ] || []; 1868 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; 1869 diff = nodeIndex && cache[ 2 ]; 1870 node = nodeIndex && parent.childNodes[ nodeIndex ]; 1871 1872 while ( (node = ++nodeIndex && node && node[ dir ] || 1873 1874 // Fallback to seeking `elem` from the start 1875 (diff = nodeIndex = 0) || start.pop()) ) { 1876 1877 // When found, cache indexes on `parent` and break 1878 if ( node.nodeType === 1 && ++diff && node === elem ) { 1879 uniqueCache[ type ] = [ dirruns, nodeIndex, diff ]; 1880 break; 1881 } 1882 } 1883 1884 } else { 1885 // Use previously-cached element index if available 1886 if ( useCache ) { 1887 // ...in a gzip-friendly way 1888 node = elem; 1889 outerCache = node[ expando ] || (node[ expando ] = {}); 1890 1891 // Support: IE <9 only 1892 // Defend against cloned attroperties (jQuery gh-1709) 1893 uniqueCache = outerCache[ node.uniqueID ] || 1894 (outerCache[ node.uniqueID ] = {}); 1895 1896 cache = uniqueCache[ type ] || []; 1897 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; 1898 diff = nodeIndex; 1899 } 1900 1901 // xml :nth-child(...) 1902 // or :nth-last-child(...) or :nth(-last)?-of-type(...) 1903 if ( diff === false ) { 1904 // Use the same loop as above to seek `elem` from the start 1905 while ( (node = ++nodeIndex && node && node[ dir ] || 1906 (diff = nodeIndex = 0) || start.pop()) ) { 1907 1908 if ( ( ofType ? 1909 node.nodeName.toLowerCase() === name : 1910 node.nodeType === 1 ) && 1911 ++diff ) { 1912 1913 // Cache the index of each encountered element 1914 if ( useCache ) { 1915 outerCache = node[ expando ] || (node[ expando ] = {}); 1916 1917 // Support: IE <9 only 1918 // Defend against cloned attroperties (jQuery gh-1709) 1919 uniqueCache = outerCache[ node.uniqueID ] || 1920 (outerCache[ node.uniqueID ] = {}); 1921 1922 uniqueCache[ type ] = [ dirruns, diff ]; 1923 } 1924 1925 if ( node === elem ) { 1926 break; 1927 } 1928 } 1929 } 1930 } 1931 } 1932 1933 // Incorporate the offset, then check against cycle size 1934 diff -= last; 1935 return diff === first || ( diff % first === 0 && diff / first >= 0 ); 1936 } 1937 }; 1938 }, 1939 1940 "PSEUDO": function( pseudo, argument ) { 1941 // pseudo-class names are case-insensitive 1942 // http://www.w3.org/TR/selectors/#pseudo-classes 1943 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters 1944 // Remember that setFilters inherits from pseudos 1945 var args, 1946 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || 1947 Sizzle.error( "unsupported pseudo: " + pseudo ); 1948 1949 // The user may use createPseudo to indicate that 1950 // arguments are needed to create the filter function 1951 // just as Sizzle does 1952 if ( fn[ expando ] ) { 1953 return fn( argument ); 1954 } 1955 1956 // But maintain support for old signatures 1957 if ( fn.length > 1 ) { 1958 args = [ pseudo, pseudo, "", argument ]; 1959 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? 1960 markFunction(function( seed, matches ) { 1961 var idx, 1962 matched = fn( seed, argument ), 1963 i = matched.length; 1964 while ( i-- ) { 1965 idx = indexOf( seed, matched[i] ); 1966 seed[ idx ] = !( matches[ idx ] = matched[i] ); 1967 } 1968 }) : 1969 function( elem ) { 1970 return fn( elem, 0, args ); 1971 }; 1972 } 1973 1974 return fn; 1975 } 1976 }, 1977 1978 pseudos: { 1979 // Potentially complex pseudos 1980 "not": markFunction(function( selector ) { 1981 // Trim the selector passed to compile 1982 // to avoid treating leading and trailing 1983 // spaces as combinators 1984 var input = [], 1985 results = [], 1986 matcher = compile( selector.replace( rtrim, "$1" ) ); 1987 1988 return matcher[ expando ] ? 1989 markFunction(function( seed, matches, context, xml ) { 1990 var elem, 1991 unmatched = matcher( seed, null, xml, [] ), 1992 i = seed.length; 1993 1994 // Match elements unmatched by `matcher` 1995 while ( i-- ) { 1996 if ( (elem = unmatched[i]) ) { 1997 seed[i] = !(matches[i] = elem); 1998 } 1999 } 2000 }) : 2001 function( elem, context, xml ) { 2002 input[0] = elem; 2003 matcher( input, null, xml, results ); 2004 // Don't keep the element (issue #299) 2005 input[0] = null; 2006 return !results.pop(); 2007 }; 2008 }), 2009 2010 "has": markFunction(function( selector ) { 2011 return function( elem ) { 2012 return Sizzle( selector, elem ).length > 0; 2013 }; 2014 }), 2015 2016 "contains": markFunction(function( text ) { 2017 text = text.replace( runescape, funescape ); 2018 return function( elem ) { 2019 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; 2020 }; 2021 }), 2022 2023 // "Whether an element is represented by a :lang() selector 2024 // is based solely on the element's language value 2025 // being equal to the identifier C, 2026 // or beginning with the identifier C immediately followed by "-". 2027 // The matching of C against the element's language value is performed case-insensitively. 2028 // The identifier C does not have to be a valid language name." 2029 // http://www.w3.org/TR/selectors/#lang-pseudo 2030 "lang": markFunction( function( lang ) { 2031 // lang value must be a valid identifier 2032 if ( !ridentifier.test(lang || "") ) { 2033 Sizzle.error( "unsupported lang: " + lang ); 2034 } 2035 lang = lang.replace( runescape, funescape ).toLowerCase(); 2036 return function( elem ) { 2037 var elemLang; 2038 do { 2039 if ( (elemLang = documentIsHTML ? 2040 elem.lang : 2041 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { 2042 2043 elemLang = elemLang.toLowerCase(); 2044 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; 2045 } 2046 } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); 2047 return false; 2048 }; 2049 }), 2050 2051 // Miscellaneous 2052 "target": function( elem ) { 2053 var hash = window.location && window.location.hash; 2054 return hash && hash.slice( 1 ) === elem.id; 2055 }, 2056 2057 "root": function( elem ) { 2058 return elem === docElem; 2059 }, 2060 2061 "focus": function( elem ) { 2062 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); 2063 }, 2064 2065 // Boolean properties 2066 "enabled": function( elem ) { 2067 return elem.disabled === false; 2068 }, 2069 2070 "disabled": function( elem ) { 2071 return elem.disabled === true; 2072 }, 2073 2074 "checked": function( elem ) { 2075 // In CSS3, :checked should return both checked and selected elements 2076 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked 2077 var nodeName = elem.nodeName.toLowerCase(); 2078 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); 2079 }, 2080 2081 "selected": function( elem ) { 2082 // Accessing this property makes selected-by-default 2083 // options in Safari work properly 2084 if ( elem.parentNode ) { 2085 elem.parentNode.selectedIndex; 2086 } 2087 2088 return elem.selected === true; 2089 }, 2090 2091 // Contents 2092 "empty": function( elem ) { 2093 // http://www.w3.org/TR/selectors/#empty-pseudo 2094 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), 2095 // but not by others (comment: 8; processing instruction: 7; etc.) 2096 // nodeType < 6 works because attributes (2) do not appear as children 2097 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { 2098 if ( elem.nodeType < 6 ) { 2099 return false; 2100 } 2101 } 2102 return true; 2103 }, 2104 2105 "parent": function( elem ) { 2106 return !Expr.pseudos["empty"]( elem ); 2107 }, 2108 2109 // Element/input types 2110 "header": function( elem ) { 2111 return rheader.test( elem.nodeName ); 2112 }, 2113 2114 "input": function( elem ) { 2115 return rinputs.test( elem.nodeName ); 2116 }, 2117 2118 "button": function( elem ) { 2119 var name = elem.nodeName.toLowerCase(); 2120 return name === "input" && elem.type === "button" || name === "button"; 2121 }, 2122 2123 "text": function( elem ) { 2124 var attr; 2125 return elem.nodeName.toLowerCase() === "input" && 2126 elem.type === "text" && 2127 2128 // Support: IE<8 2129 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" 2130 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); 2131 }, 2132 2133 // Position-in-collection 2134 "first": createPositionalPseudo(function() { 2135 return [ 0 ]; 2136 }), 2137 2138 "last": createPositionalPseudo(function( matchIndexes, length ) { 2139 return [ length - 1 ]; 2140 }), 2141 2142 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { 2143 return [ argument < 0 ? argument + length : argument ]; 2144 }), 2145 2146 "even": createPositionalPseudo(function( matchIndexes, length ) { 2147 var i = 0; 2148 for ( ; i < length; i += 2 ) { 2149 matchIndexes.push( i ); 2150 } 2151 return matchIndexes; 2152 }), 2153 2154 "odd": createPositionalPseudo(function( matchIndexes, length ) { 2155 var i = 1; 2156 for ( ; i < length; i += 2 ) { 2157 matchIndexes.push( i ); 2158 } 2159 return matchIndexes; 2160 }), 2161 2162 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { 2163 var i = argument < 0 ? argument + length : argument; 2164 for ( ; --i >= 0; ) { 2165 matchIndexes.push( i ); 2166 } 2167 return matchIndexes; 2168 }), 2169 2170 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { 2171 var i = argument < 0 ? argument + length : argument; 2172 for ( ; ++i < length; ) { 2173 matchIndexes.push( i ); 2174 } 2175 return matchIndexes; 2176 }) 2177 } 2178 }; 2179 2180 Expr.pseudos["nth"] = Expr.pseudos["eq"]; 2181 2182 // Add button/input type pseudos 2183 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { 2184 Expr.pseudos[ i ] = createInputPseudo( i ); 2185 } 2186 for ( i in { submit: true, reset: true } ) { 2187 Expr.pseudos[ i ] = createButtonPseudo( i ); 2188 } 2189 2190 // Easy API for creating new setFilters 2191 function setFilters() {} 2192 setFilters.prototype = Expr.filters = Expr.pseudos; 2193 Expr.setFilters = new setFilters(); 2194 2195 tokenize = Sizzle.tokenize = function( selector, parseOnly ) { 2196 var matched, match, tokens, type, 2197 soFar, groups, preFilters, 2198 cached = tokenCache[ selector + " " ]; 2199 2200 if ( cached ) { 2201 return parseOnly ? 0 : cached.slice( 0 ); 2202 } 2203 2204 soFar = selector; 2205 groups = []; 2206 preFilters = Expr.preFilter; 2207 2208 while ( soFar ) { 2209 2210 // Comma and first run 2211 if ( !matched || (match = rcomma.exec( soFar )) ) { 2212 if ( match ) { 2213 // Don't consume trailing commas as valid 2214 soFar = soFar.slice( match[0].length ) || soFar; 2215 } 2216 groups.push( (tokens = []) ); 2217 } 2218 2219 matched = false; 2220 2221 // Combinators 2222 if ( (match = rcombinators.exec( soFar )) ) { 2223 matched = match.shift(); 2224 tokens.push({ 2225 value: matched, 2226 // Cast descendant combinators to space 2227 type: match[0].replace( rtrim, " " ) 2228 }); 2229 soFar = soFar.slice( matched.length ); 2230 } 2231 2232 // Filters 2233 for ( type in Expr.filter ) { 2234 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || 2235 (match = preFilters[ type ]( match ))) ) { 2236 matched = match.shift(); 2237 tokens.push({ 2238 value: matched, 2239 type: type, 2240 matches: match 2241 }); 2242 soFar = soFar.slice( matched.length ); 2243 } 2244 } 2245 2246 if ( !matched ) { 2247 break; 2248 } 2249 } 2250 2251 // Return the length of the invalid excess 2252 // if we're just parsing 2253 // Otherwise, throw an error or return tokens 2254 return parseOnly ? 2255 soFar.length : 2256 soFar ? 2257 Sizzle.error( selector ) : 2258 // Cache the tokens 2259 tokenCache( selector, groups ).slice( 0 ); 2260 }; 2261 2262 function toSelector( tokens ) { 2263 var i = 0, 2264 len = tokens.length, 2265 selector = ""; 2266 for ( ; i < len; i++ ) { 2267 selector += tokens[i].value; 2268 } 2269 return selector; 2270 } 2271 2272 function addCombinator( matcher, combinator, base ) { 2273 var dir = combinator.dir, 2274 checkNonElements = base && dir === "parentNode", 2275 doneName = done++; 2276 2277 return combinator.first ? 2278 // Check against closest ancestor/preceding element 2279 function( elem, context, xml ) { 2280 while ( (elem = elem[ dir ]) ) { 2281 if ( elem.nodeType === 1 || checkNonElements ) { 2282 return matcher( elem, context, xml ); 2283 } 2284 } 2285 } : 2286 2287 // Check against all ancestor/preceding elements 2288 function( elem, context, xml ) { 2289 var oldCache, uniqueCache, outerCache, 2290 newCache = [ dirruns, doneName ]; 2291 2292 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching 2293 if ( xml ) { 2294 while ( (elem = elem[ dir ]) ) { 2295 if ( elem.nodeType === 1 || checkNonElements ) { 2296 if ( matcher( elem, context, xml ) ) { 2297 return true; 2298 } 2299 } 2300 } 2301 } else { 2302 while ( (elem = elem[ dir ]) ) { 2303 if ( elem.nodeType === 1 || checkNonElements ) { 2304 outerCache = elem[ expando ] || (elem[ expando ] = {}); 2305 2306 // Support: IE <9 only 2307 // Defend against cloned attroperties (jQuery gh-1709) 2308 uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {}); 2309 2310 if ( (oldCache = uniqueCache[ dir ]) && 2311 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { 2312 2313 // Assign to newCache so results back-propagate to previous elements 2314 return (newCache[ 2 ] = oldCache[ 2 ]); 2315 } else { 2316 // Reuse newcache so results back-propagate to previous elements 2317 uniqueCache[ dir ] = newCache; 2318 2319 // A match means we're done; a fail means we have to keep checking 2320 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { 2321 return true; 2322 } 2323 } 2324 } 2325 } 2326 } 2327 }; 2328 } 2329 2330 function elementMatcher( matchers ) { 2331 return matchers.length > 1 ? 2332 function( elem, context, xml ) { 2333 var i = matchers.length; 2334 while ( i-- ) { 2335 if ( !matchers[i]( elem, context, xml ) ) { 2336 return false; 2337 } 2338 } 2339 return true; 2340 } : 2341 matchers[0]; 2342 } 2343 2344 function multipleContexts( selector, contexts, results ) { 2345 var i = 0, 2346 len = contexts.length; 2347 for ( ; i < len; i++ ) { 2348 Sizzle( selector, contexts[i], results ); 2349 } 2350 return results; 2351 } 2352 2353 function condense( unmatched, map, filter, context, xml ) { 2354 var elem, 2355 newUnmatched = [], 2356 i = 0, 2357 len = unmatched.length, 2358 mapped = map != null; 2359 2360 for ( ; i < len; i++ ) { 2361 if ( (elem = unmatched[i]) ) { 2362 if ( !filter || filter( elem, context, xml ) ) { 2363 newUnmatched.push( elem ); 2364 if ( mapped ) { 2365 map.push( i ); 2366 } 2367 } 2368 } 2369 } 2370 2371 return newUnmatched; 2372 } 2373 2374 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { 2375 if ( postFilter && !postFilter[ expando ] ) { 2376 postFilter = setMatcher( postFilter ); 2377 } 2378 if ( postFinder && !postFinder[ expando ] ) { 2379 postFinder = setMatcher( postFinder, postSelector ); 2380 } 2381 return markFunction(function( seed, results, context, xml ) { 2382 var temp, i, elem, 2383 preMap = [], 2384 postMap = [], 2385 preexisting = results.length, 2386 2387 // Get initial elements from seed or context 2388 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), 2389 2390 // Prefilter to get matcher input, preserving a map for seed-results synchronization 2391 matcherIn = preFilter && ( seed || !selector ) ? 2392 condense( elems, preMap, preFilter, context, xml ) : 2393 elems, 2394 2395 matcherOut = matcher ? 2396 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, 2397 postFinder || ( seed ? preFilter : preexisting || postFilter ) ? 2398 2399 // ...intermediate processing is necessary 2400 [] : 2401 2402 // ...otherwise use results directly 2403 results : 2404 matcherIn; 2405 2406 // Find primary matches 2407 if ( matcher ) { 2408 matcher( matcherIn, matcherOut, context, xml ); 2409 } 2410 2411 // Apply postFilter 2412 if ( postFilter ) { 2413 temp = condense( matcherOut, postMap ); 2414 postFilter( temp, [], context, xml ); 2415 2416 // Un-match failing elements by moving them back to matcherIn 2417 i = temp.length; 2418 while ( i-- ) { 2419 if ( (elem = temp[i]) ) { 2420 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); 2421 } 2422 } 2423 } 2424 2425 if ( seed ) { 2426 if ( postFinder || preFilter ) { 2427 if ( postFinder ) { 2428 // Get the final matcherOut by condensing this intermediate into postFinder contexts 2429 temp = []; 2430 i = matcherOut.length; 2431 while ( i-- ) { 2432 if ( (elem = matcherOut[i]) ) { 2433 // Restore matcherIn since elem is not yet a final match 2434 temp.push( (matcherIn[i] = elem) ); 2435 } 2436 } 2437 postFinder( null, (matcherOut = []), temp, xml ); 2438 } 2439 2440 // Move matched elements from seed to results to keep them synchronized 2441 i = matcherOut.length; 2442 while ( i-- ) { 2443 if ( (elem = matcherOut[i]) && 2444 (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) { 2445 2446 seed[temp] = !(results[temp] = elem); 2447 } 2448 } 2449 } 2450 2451 // Add elements to results, through postFinder if defined 2452 } else { 2453 matcherOut = condense( 2454 matcherOut === results ? 2455 matcherOut.splice( preexisting, matcherOut.length ) : 2456 matcherOut 2457 ); 2458 if ( postFinder ) { 2459 postFinder( null, results, matcherOut, xml ); 2460 } else { 2461 push.apply( results, matcherOut ); 2462 } 2463 } 2464 }); 2465 } 2466 2467 function matcherFromTokens( tokens ) { 2468 var checkContext, matcher, j, 2469 len = tokens.length, 2470 leadingRelative = Expr.relative[ tokens[0].type ], 2471 implicitRelative = leadingRelative || Expr.relative[" "], 2472 i = leadingRelative ? 1 : 0, 2473 2474 // The foundational matcher ensures that elements are reachable from top-level context(s) 2475 matchContext = addCombinator( function( elem ) { 2476 return elem === checkContext; 2477 }, implicitRelative, true ), 2478 matchAnyContext = addCombinator( function( elem ) { 2479 return indexOf( checkContext, elem ) > -1; 2480 }, implicitRelative, true ), 2481 matchers = [ function( elem, context, xml ) { 2482 var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( 2483 (checkContext = context).nodeType ? 2484 matchContext( elem, context, xml ) : 2485 matchAnyContext( elem, context, xml ) ); 2486 // Avoid hanging onto element (issue #299) 2487 checkContext = null; 2488 return ret; 2489 } ]; 2490 2491 for ( ; i < len; i++ ) { 2492 if ( (matcher = Expr.relative[ tokens[i].type ]) ) { 2493 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; 2494 } else { 2495 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); 2496 2497 // Return special upon seeing a positional matcher 2498 if ( matcher[ expando ] ) { 2499 // Find the next relative operator (if any) for proper handling 2500 j = ++i; 2501 for ( ; j < len; j++ ) { 2502 if ( Expr.relative[ tokens[j].type ] ) { 2503 break; 2504 } 2505 } 2506 return setMatcher( 2507 i > 1 && elementMatcher( matchers ), 2508 i > 1 && toSelector( 2509 // If the preceding token was a descendant combinator, insert an implicit any-element `*` 2510 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) 2511 ).replace( rtrim, "$1" ), 2512 matcher, 2513 i < j && matcherFromTokens( tokens.slice( i, j ) ), 2514 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), 2515 j < len && toSelector( tokens ) 2516 ); 2517 } 2518 matchers.push( matcher ); 2519 } 2520 } 2521 2522 return elementMatcher( matchers ); 2523 } 2524 2525 function matcherFromGroupMatchers( elementMatchers, setMatchers ) { 2526 var bySet = setMatchers.length > 0, 2527 byElement = elementMatchers.length > 0, 2528 superMatcher = function( seed, context, xml, results, outermost ) { 2529 var elem, j, matcher, 2530 matchedCount = 0, 2531 i = "0", 2532 unmatched = seed && [], 2533 setMatched = [], 2534 contextBackup = outermostContext, 2535 // We must always have either seed elements or outermost context 2536 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), 2537 // Use integer dirruns iff this is the outermost matcher 2538 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), 2539 len = elems.length; 2540 2541 if ( outermost ) { 2542 outermostContext = context === document || context || outermost; 2543 } 2544 2545 // Add elements passing elementMatchers directly to results 2546 // Support: IE<9, Safari 2547 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id 2548 for ( ; i !== len && (elem = elems[i]) != null; i++ ) { 2549 if ( byElement && elem ) { 2550 j = 0; 2551 if ( !context && elem.ownerDocument !== document ) { 2552 setDocument( elem ); 2553 xml = !documentIsHTML; 2554 } 2555 while ( (matcher = elementMatchers[j++]) ) { 2556 if ( matcher( elem, context || document, xml) ) { 2557 results.push( elem ); 2558 break; 2559 } 2560 } 2561 if ( outermost ) { 2562 dirruns = dirrunsUnique; 2563 } 2564 } 2565 2566 // Track unmatched elements for set filters 2567 if ( bySet ) { 2568 // They will have gone through all possible matchers 2569 if ( (elem = !matcher && elem) ) { 2570 matchedCount--; 2571 } 2572 2573 // Lengthen the array for every element, matched or not 2574 if ( seed ) { 2575 unmatched.push( elem ); 2576 } 2577 } 2578 } 2579 2580 // `i` is now the count of elements visited above, and adding it to `matchedCount` 2581 // makes the latter nonnegative. 2582 matchedCount += i; 2583 2584 // Apply set filters to unmatched elements 2585 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount` 2586 // equals `i`), unless we didn't visit _any_ elements in the above loop because we have 2587 // no element matchers and no seed. 2588 // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that 2589 // case, which will result in a "00" `matchedCount` that differs from `i` but is also 2590 // numerically zero. 2591 if ( bySet && i !== matchedCount ) { 2592 j = 0; 2593 while ( (matcher = setMatchers[j++]) ) { 2594 matcher( unmatched, setMatched, context, xml ); 2595 } 2596 2597 if ( seed ) { 2598 // Reintegrate element matches to eliminate the need for sorting 2599 if ( matchedCount > 0 ) { 2600 while ( i-- ) { 2601 if ( !(unmatched[i] || setMatched[i]) ) { 2602 setMatched[i] = pop.call( results ); 2603 } 2604 } 2605 } 2606 2607 // Discard index placeholder values to get only actual matches 2608 setMatched = condense( setMatched ); 2609 } 2610 2611 // Add matches to results 2612 push.apply( results, setMatched ); 2613 2614 // Seedless set matches succeeding multiple successful matchers stipulate sorting 2615 if ( outermost && !seed && setMatched.length > 0 && 2616 ( matchedCount + setMatchers.length ) > 1 ) { 2617 2618 Sizzle.uniqueSort( results ); 2619 } 2620 } 2621 2622 // Override manipulation of globals by nested matchers 2623 if ( outermost ) { 2624 dirruns = dirrunsUnique; 2625 outermostContext = contextBackup; 2626 } 2627 2628 return unmatched; 2629 }; 2630 2631 return bySet ? 2632 markFunction( superMatcher ) : 2633 superMatcher; 2634 } 2635 2636 compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { 2637 var i, 2638 setMatchers = [], 2639 elementMatchers = [], 2640 cached = compilerCache[ selector + " " ]; 2641 2642 if ( !cached ) { 2643 // Generate a function of recursive functions that can be used to check each element 2644 if ( !match ) { 2645 match = tokenize( selector ); 2646 } 2647 i = match.length; 2648 while ( i-- ) { 2649 cached = matcherFromTokens( match[i] ); 2650 if ( cached[ expando ] ) { 2651 setMatchers.push( cached ); 2652 } else { 2653 elementMatchers.push( cached ); 2654 } 2655 } 2656 2657 // Cache the compiled function 2658 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); 2659 2660 // Save selector and tokenization 2661 cached.selector = selector; 2662 } 2663 return cached; 2664 }; 2665 2666 /** 2667 * A low-level selection function that works with Sizzle's compiled 2668 * selector functions 2669 * @param {String|Function} selector A selector or a pre-compiled 2670 * selector function built with Sizzle.compile 2671 * @param {Element} context 2672 * @param {Array} [results] 2673 * @param {Array} [seed] A set of elements to match against 2674 */ 2675 select = Sizzle.select = function( selector, context, results, seed ) { 2676 var i, tokens, token, type, find, 2677 compiled = typeof selector === "function" && selector, 2678 match = !seed && tokenize( (selector = compiled.selector || selector) ); 2679 2680 results = results || []; 2681 2682 // Try to minimize operations if there is only one selector in the list and no seed 2683 // (the latter of which guarantees us context) 2684 if ( match.length === 1 ) { 2685 2686 // Reduce context if the leading compound selector is an ID 2687 tokens = match[0] = match[0].slice( 0 ); 2688 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && 2689 support.getById && context.nodeType === 9 && documentIsHTML && 2690 Expr.relative[ tokens[1].type ] ) { 2691 2692 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; 2693 if ( !context ) { 2694 return results; 2695 2696 // Precompiled matchers will still verify ancestry, so step up a level 2697 } else if ( compiled ) { 2698 context = context.parentNode; 2699 } 2700 2701 selector = selector.slice( tokens.shift().value.length ); 2702 } 2703 2704 // Fetch a seed set for right-to-left matching 2705 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; 2706 while ( i-- ) { 2707 token = tokens[i]; 2708 2709 // Abort if we hit a combinator 2710 if ( Expr.relative[ (type = token.type) ] ) { 2711 break; 2712 } 2713 if ( (find = Expr.find[ type ]) ) { 2714 // Search, expanding context for leading sibling combinators 2715 if ( (seed = find( 2716 token.matches[0].replace( runescape, funescape ), 2717 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context 2718 )) ) { 2719 2720 // If seed is empty or no tokens remain, we can return early 2721 tokens.splice( i, 1 ); 2722 selector = seed.length && toSelector( tokens ); 2723 if ( !selector ) { 2724 push.apply( results, seed ); 2725 return results; 2726 } 2727 2728 break; 2729 } 2730 } 2731 } 2732 } 2733 2734 // Compile and execute a filtering function if one is not provided 2735 // Provide `match` to avoid retokenization if we modified the selector above 2736 ( compiled || compile( selector, match ) )( 2737 seed, 2738 context, 2739 !documentIsHTML, 2740 results, 2741 !context || rsibling.test( selector ) && testContext( context.parentNode ) || context 2742 ); 2743 return results; 2744 }; 2745 2746 // One-time assignments 2747 2748 // Sort stability 2749 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; 2750 2751 // Support: Chrome 14-35+ 2752 // Always assume duplicates if they aren't passed to the comparison function 2753 support.detectDuplicates = !!hasDuplicate; 2754 2755 // Initialize against the default document 2756 setDocument(); 2757 2758 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) 2759 // Detached nodes confoundingly follow *each other* 2760 support.sortDetached = assert(function( div1 ) { 2761 // Should return 1, but returns 4 (following) 2762 return div1.compareDocumentPosition( document.createElement("div") ) & 1; 2763 }); 2764 2765 // Support: IE<8 2766 // Prevent attribute/property "interpolation" 2767 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx 2768 if ( !assert(function( div ) { 2769 div.innerHTML = "<a href='#'></a>"; 2770 return div.firstChild.getAttribute("href") === "#" ; 2771 }) ) { 2772 addHandle( "type|href|height|width", function( elem, name, isXML ) { 2773 if ( !isXML ) { 2774 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); 2775 } 2776 }); 2777 } 2778 2779 // Support: IE<9 2780 // Use defaultValue in place of getAttribute("value") 2781 if ( !support.attributes || !assert(function( div ) { 2782 div.innerHTML = "<input/>"; 2783 div.firstChild.setAttribute( "value", "" ); 2784 return div.firstChild.getAttribute( "value" ) === ""; 2785 }) ) { 2786 addHandle( "value", function( elem, name, isXML ) { 2787 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { 2788 return elem.defaultValue; 2789 } 2790 }); 2791 } 2792 2793 // Support: IE<9 2794 // Use getAttributeNode to fetch booleans when getAttribute lies 2795 if ( !assert(function( div ) { 2796 return div.getAttribute("disabled") == null; 2797 }) ) { 2798 addHandle( booleans, function( elem, name, isXML ) { 2799 var val; 2800 if ( !isXML ) { 2801 return elem[ name ] === true ? name.toLowerCase() : 2802 (val = elem.getAttributeNode( name )) && val.specified ? 2803 val.value : 2804 null; 2805 } 2806 }); 2807 } 2808 2809 return Sizzle; 2810 2811 })( window ); 2812 2813 2814 2815 jQuery.find = Sizzle; 2816 jQuery.expr = Sizzle.selectors; 2817 jQuery.expr[ ":" ] = jQuery.expr.pseudos; 2818 jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort; 2819 jQuery.text = Sizzle.getText; 2820 jQuery.isXMLDoc = Sizzle.isXML; 2821 jQuery.contains = Sizzle.contains; 2822 2823 2824 2825 var dir = function( elem, dir, until ) { 2826 var matched = [], 2827 truncate = until !== undefined; 2828 2829 while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { 2830 if ( elem.nodeType === 1 ) { 2831 if ( truncate && jQuery( elem ).is( until ) ) { 2832 break; 2833 } 2834 matched.push( elem ); 2835 } 2836 } 2837 return matched; 2838 }; 2839 2840 2841 var siblings = function( n, elem ) { 2842 var matched = []; 2843 2844 for ( ; n; n = n.nextSibling ) { 2845 if ( n.nodeType === 1 && n !== elem ) { 2846 matched.push( n ); 2847 } 2848 } 2849 2850 return matched; 2851 }; 2852 2853 2854 var rneedsContext = jQuery.expr.match.needsContext; 2855 2856 var rsingleTag = ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ ); 2857 2858 2859 2860 var risSimple = /^.[^:#\[\.,]*$/; 2861 2862 // Implement the identical functionality for filter and not 2863 function winnow( elements, qualifier, not ) { 2864 if ( jQuery.isFunction( qualifier ) ) { 2865 return jQuery.grep( elements, function( elem, i ) { 2866 /* jshint -W018 */ 2867 return !!qualifier.call( elem, i, elem ) !== not; 2868 } ); 2869 2870 } 2871 2872 if ( qualifier.nodeType ) { 2873 return jQuery.grep( elements, function( elem ) { 2874 return ( elem === qualifier ) !== not; 2875 } ); 2876 2877 } 2878 2879 if ( typeof qualifier === "string" ) { 2880 if ( risSimple.test( qualifier ) ) { 2881 return jQuery.filter( qualifier, elements, not ); 2882 } 2883 2884 qualifier = jQuery.filter( qualifier, elements ); 2885 } 2886 2887 return jQuery.grep( elements, function( elem ) { 2888 return ( indexOf.call( qualifier, elem ) > -1 ) !== not; 2889 } ); 2890 } 2891 2892 jQuery.filter = function( expr, elems, not ) { 2893 var elem = elems[ 0 ]; 2894 2895 if ( not ) { 2896 expr = ":not(" + expr + ")"; 2897 } 2898 2899 return elems.length === 1 && elem.nodeType === 1 ? 2900 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : 2901 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { 2902 return elem.nodeType === 1; 2903 } ) ); 2904 }; 2905 2906 jQuery.fn.extend( { 2907 find: function( selector ) { 2908 var i, 2909 len = this.length, 2910 ret = [], 2911 self = this; 2912 2913 if ( typeof selector !== "string" ) { 2914 return this.pushStack( jQuery( selector ).filter( function() { 2915 for ( i = 0; i < len; i++ ) { 2916 if ( jQuery.contains( self[ i ], this ) ) { 2917 return true; 2918 } 2919 } 2920 } ) ); 2921 } 2922 2923 for ( i = 0; i < len; i++ ) { 2924 jQuery.find( selector, self[ i ], ret ); 2925 } 2926 2927 // Needed because $( selector, context ) becomes $( context ).find( selector ) 2928 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); 2929 ret.selector = this.selector ? this.selector + " " + selector : selector; 2930 return ret; 2931 }, 2932 filter: function( selector ) { 2933 return this.pushStack( winnow( this, selector || [], false ) ); 2934 }, 2935 not: function( selector ) { 2936 return this.pushStack( winnow( this, selector || [], true ) ); 2937 }, 2938 is: function( selector ) { 2939 return !!winnow( 2940 this, 2941 2942 // If this is a positional/relative selector, check membership in the returned set 2943 // so $("p:first").is("p:last") won't return true for a doc with two "p". 2944 typeof selector === "string" && rneedsContext.test( selector ) ? 2945 jQuery( selector ) : 2946 selector || [], 2947 false 2948 ).length; 2949 } 2950 } ); 2951 2952 2953 // Initialize a jQuery object 2954 2955 2956 // A central reference to the root jQuery(document) 2957 var rootjQuery, 2958 2959 // A simple way to check for HTML strings 2960 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521) 2961 // Strict HTML recognition (#11290: must start with <) 2962 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, 2963 2964 init = jQuery.fn.init = function( selector, context, root ) { 2965 var match, elem; 2966 2967 // HANDLE: $(""), $(null), $(undefined), $(false) 2968 if ( !selector ) { 2969 return this; 2970 } 2971 2972 // Method init() accepts an alternate rootjQuery 2973 // so migrate can support jQuery.sub (gh-2101) 2974 root = root || rootjQuery; 2975 2976 // Handle HTML strings 2977 if ( typeof selector === "string" ) { 2978 if ( selector[ 0 ] === "<" && 2979 selector[ selector.length - 1 ] === ">" && 2980 selector.length >= 3 ) { 2981 2982 // Assume that strings that start and end with <> are HTML and skip the regex check 2983 match = [ null, selector, null ]; 2984 2985 } else { 2986 match = rquickExpr.exec( selector ); 2987 } 2988 2989 // Match html or make sure no context is specified for #id 2990 if ( match && ( match[ 1 ] || !context ) ) { 2991 2992 // HANDLE: $(html) -> $(array) 2993 if ( match[ 1 ] ) { 2994 context = context instanceof jQuery ? context[ 0 ] : context; 2995 2996 // Option to run scripts is true for back-compat 2997 // Intentionally let the error be thrown if parseHTML is not present 2998 jQuery.merge( this, jQuery.parseHTML( 2999 match[ 1 ], 3000 context && context.nodeType ? context.ownerDocument || context : document, 3001 true 3002 ) ); 3003 3004 // HANDLE: $(html, props) 3005 if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { 3006 for ( match in context ) { 3007 3008 // Properties of context are called as methods if possible 3009 if ( jQuery.isFunction( this[ match ] ) ) { 3010 this[ match ]( context[ match ] ); 3011 3012 // ...and otherwise set as attributes 3013 } else { 3014 this.attr( match, context[ match ] ); 3015 } 3016 } 3017 } 3018 3019 return this; 3020 3021 // HANDLE: $(#id) 3022 } else { 3023 elem = document.getElementById( match[ 2 ] ); 3024 3025 // Support: Blackberry 4.6 3026 // gEBID returns nodes no longer in the document (#6963) 3027 if ( elem && elem.parentNode ) { 3028 3029 // Inject the element directly into the jQuery object 3030 this.length = 1; 3031 this[ 0 ] = elem; 3032 } 3033 3034 this.context = document; 3035 this.selector = selector; 3036 return this; 3037 } 3038 3039 // HANDLE: $(expr, $(...)) 3040 } else if ( !context || context.jquery ) { 3041 return ( context || root ).find( selector ); 3042 3043 // HANDLE: $(expr, context) 3044 // (which is just equivalent to: $(context).find(expr) 3045 } else { 3046 return this.constructor( context ).find( selector ); 3047 } 3048 3049 // HANDLE: $(DOMElement) 3050 } else if ( selector.nodeType ) { 3051 this.context = this[ 0 ] = selector; 3052 this.length = 1; 3053 return this; 3054 3055 // HANDLE: $(function) 3056 // Shortcut for document ready 3057 } else if ( jQuery.isFunction( selector ) ) { 3058 return root.ready !== undefined ? 3059 root.ready( selector ) : 3060 3061 // Execute immediately if ready is not present 3062 selector( jQuery ); 3063 } 3064 3065 if ( selector.selector !== undefined ) { 3066 this.selector = selector.selector; 3067 this.context = selector.context; 3068 } 3069 3070 return jQuery.makeArray( selector, this ); 3071 }; 3072 3073 // Give the init function the jQuery prototype for later instantiation 3074 init.prototype = jQuery.fn; 3075 3076 // Initialize central reference 3077 rootjQuery = jQuery( document ); 3078 3079 3080 var rparentsprev = /^(?:parents|prev(?:Until|All))/, 3081 3082 // Methods guaranteed to produce a unique set when starting from a unique set 3083 guaranteedUnique = { 3084 children: true, 3085 contents: true, 3086 next: true, 3087 prev: true 3088 }; 3089 3090 jQuery.fn.extend( { 3091 has: function( target ) { 3092 var targets = jQuery( target, this ), 3093 l = targets.length; 3094 3095 return this.filter( function() { 3096 var i = 0; 3097 for ( ; i < l; i++ ) { 3098 if ( jQuery.contains( this, targets[ i ] ) ) { 3099 return true; 3100 } 3101 } 3102 } ); 3103 }, 3104 3105 closest: function( selectors, context ) { 3106 var cur, 3107 i = 0, 3108 l = this.length, 3109 matched = [], 3110 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? 3111 jQuery( selectors, context || this.context ) : 3112 0; 3113 3114 for ( ; i < l; i++ ) { 3115 for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) { 3116 3117 // Always skip document fragments 3118 if ( cur.nodeType < 11 && ( pos ? 3119 pos.index( cur ) > -1 : 3120 3121 // Don't pass non-elements to Sizzle 3122 cur.nodeType === 1 && 3123 jQuery.find.matchesSelector( cur, selectors ) ) ) { 3124 3125 matched.push( cur ); 3126 break; 3127 } 3128 } 3129 } 3130 3131 return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched ); 3132 }, 3133 3134 // Determine the position of an element within the set 3135 index: function( elem ) { 3136 3137 // No argument, return index in parent 3138 if ( !elem ) { 3139 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; 3140 } 3141 3142 // Index in selector 3143 if ( typeof elem === "string" ) { 3144 return indexOf.call( jQuery( elem ), this[ 0 ] ); 3145 } 3146 3147 // Locate the position of the desired element 3148 return indexOf.call( this, 3149 3150 // If it receives a jQuery object, the first element is used 3151 elem.jquery ? elem[ 0 ] : elem 3152 ); 3153 }, 3154 3155 add: function( selector, context ) { 3156 return this.pushStack( 3157 jQuery.uniqueSort( 3158 jQuery.merge( this.get(), jQuery( selector, context ) ) 3159 ) 3160 ); 3161 }, 3162 3163 addBack: function( selector ) { 3164 return this.add( selector == null ? 3165 this.prevObject : this.prevObject.filter( selector ) 3166 ); 3167 } 3168 } ); 3169 3170 function sibling( cur, dir ) { 3171 while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {} 3172 return cur; 3173 } 3174 3175 jQuery.each( { 3176 parent: function( elem ) { 3177 var parent = elem.parentNode; 3178 return parent && parent.nodeType !== 11 ? parent : null; 3179 }, 3180 parents: function( elem ) { 3181 return dir( elem, "parentNode" ); 3182 }, 3183 parentsUntil: function( elem, i, until ) { 3184 return dir( elem, "parentNode", until ); 3185 }, 3186 next: function( elem ) { 3187 return sibling( elem, "nextSibling" ); 3188 }, 3189 prev: function( elem ) { 3190 return sibling( elem, "previousSibling" ); 3191 }, 3192 nextAll: function( elem ) { 3193 return dir( elem, "nextSibling" ); 3194 }, 3195 prevAll: function( elem ) { 3196 return dir( elem, "previousSibling" ); 3197 }, 3198 nextUntil: function( elem, i, until ) { 3199 return dir( elem, "nextSibling", until ); 3200 }, 3201 prevUntil: function( elem, i, until ) { 3202 return dir( elem, "previousSibling", until ); 3203 }, 3204 siblings: function( elem ) { 3205 return siblings( ( elem.parentNode || {} ).firstChild, elem ); 3206 }, 3207 children: function( elem ) { 3208 return siblings( elem.firstChild ); 3209 }, 3210 contents: function( elem ) { 3211 return elem.contentDocument || jQuery.merge( [], elem.childNodes ); 3212 } 3213 }, function( name, fn ) { 3214 jQuery.fn[ name ] = function( until, selector ) { 3215 var matched = jQuery.map( this, fn, until ); 3216 3217 if ( name.slice( -5 ) !== "Until" ) { 3218 selector = until; 3219 } 3220 3221 if ( selector && typeof selector === "string" ) { 3222 matched = jQuery.filter( selector, matched ); 3223 } 3224 3225 if ( this.length > 1 ) { 3226 3227 // Remove duplicates 3228 if ( !guaranteedUnique[ name ] ) { 3229 jQuery.uniqueSort( matched ); 3230 } 3231 3232 // Reverse order for parents* and prev-derivatives 3233 if ( rparentsprev.test( name ) ) { 3234 matched.reverse(); 3235 } 3236 } 3237 3238 return this.pushStack( matched ); 3239 }; 3240 } ); 3241 var rnotwhite = ( /\S+/g ); 3242 3243 3244 3245 // Convert String-formatted options into Object-formatted ones 3246 function createOptions( options ) { 3247 var object = {}; 3248 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) { 3249 object[ flag ] = true; 3250 } ); 3251 return object; 3252 } 3253 3254 /* 3255 * Create a callback list using the following parameters: 3256 * 3257 * options: an optional list of space-separated options that will change how 3258 * the callback list behaves or a more traditional option object 3259 * 3260 * By default a callback list will act like an event callback list and can be 3261 * "fired" multiple times. 3262 * 3263 * Possible options: 3264 * 3265 * once: will ensure the callback list can only be fired once (like a Deferred) 3266 * 3267 * memory: will keep track of previous values and will call any callback added 3268 * after the list has been fired right away with the latest "memorized" 3269 * values (like a Deferred) 3270 * 3271 * unique: will ensure a callback can only be added once (no duplicate in the list) 3272 * 3273 * stopOnFalse: interrupt callings when a callback returns false 3274 * 3275 */ 3276 jQuery.Callbacks = function( options ) { 3277 3278 // Convert options from String-formatted to Object-formatted if needed 3279 // (we check in cache first) 3280 options = typeof options === "string" ? 3281 createOptions( options ) : 3282 jQuery.extend( {}, options ); 3283 3284 var // Flag to know if list is currently firing 3285 firing, 3286 3287 // Last fire value for non-forgettable lists 3288 memory, 3289 3290 // Flag to know if list was already fired 3291 fired, 3292 3293 // Flag to prevent firing 3294 locked, 3295 3296 // Actual callback list 3297 list = [], 3298 3299 // Queue of execution data for repeatable lists 3300 queue = [], 3301 3302 // Index of currently firing callback (modified by add/remove as needed) 3303 firingIndex = -1, 3304 3305 // Fire callbacks 3306 fire = function() { 3307 3308 // Enforce single-firing 3309 locked = options.once; 3310 3311 // Execute callbacks for all pending executions, 3312 // respecting firingIndex overrides and runtime changes 3313 fired = firing = true; 3314 for ( ; queue.length; firingIndex = -1 ) { 3315 memory = queue.shift(); 3316 while ( ++firingIndex < list.length ) { 3317 3318 // Run callback and check for early termination 3319 if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && 3320 options.stopOnFalse ) { 3321 3322 // Jump to end and forget the data so .add doesn't re-fire 3323 firingIndex = list.length; 3324 memory = false; 3325 } 3326 } 3327 } 3328 3329 // Forget the data if we're done with it 3330 if ( !options.memory ) { 3331 memory = false; 3332 } 3333 3334 firing = false; 3335 3336 // Clean up if we're done firing for good 3337 if ( locked ) { 3338 3339 // Keep an empty list if we have data for future add calls 3340 if ( memory ) { 3341 list = []; 3342 3343 // Otherwise, this object is spent 3344 } else { 3345 list = ""; 3346 } 3347 } 3348 }, 3349 3350 // Actual Callbacks object 3351 self = { 3352 3353 // Add a callback or a collection of callbacks to the list 3354 add: function() { 3355 if ( list ) { 3356 3357 // If we have memory from a past run, we should fire after adding 3358 if ( memory && !firing ) { 3359 firingIndex = list.length - 1; 3360 queue.push( memory ); 3361 } 3362 3363 ( function add( args ) { 3364 jQuery.each( args, function( _, arg ) { 3365 if ( jQuery.isFunction( arg ) ) { 3366 if ( !options.unique || !self.has( arg ) ) { 3367 list.push( arg ); 3368 } 3369 } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) { 3370 3371 // Inspect recursively 3372 add( arg ); 3373 } 3374 } ); 3375 } )( arguments ); 3376 3377 if ( memory && !firing ) { 3378 fire(); 3379 } 3380 } 3381 return this; 3382 }, 3383 3384 // Remove a callback from the list 3385 remove: function() { 3386 jQuery.each( arguments, function( _, arg ) { 3387 var index; 3388 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { 3389 list.splice( index, 1 ); 3390 3391 // Handle firing indexes 3392 if ( index <= firingIndex ) { 3393 firingIndex--; 3394 } 3395 } 3396 } ); 3397 return this; 3398 }, 3399 3400 // Check if a given callback is in the list. 3401 // If no argument is given, return whether or not list has callbacks attached. 3402 has: function( fn ) { 3403 return fn ? 3404 jQuery.inArray( fn, list ) > -1 : 3405 list.length > 0; 3406 }, 3407 3408 // Remove all callbacks from the list 3409 empty: function() { 3410 if ( list ) { 3411 list = []; 3412 } 3413 return this; 3414 }, 3415 3416 // Disable .fire and .add 3417 // Abort any current/pending executions 3418 // Clear all callbacks and values 3419 disable: function() { 3420 locked = queue = []; 3421 list = memory = ""; 3422 return this; 3423 }, 3424 disabled: function() { 3425 return !list; 3426 }, 3427 3428 // Disable .fire 3429 // Also disable .add unless we have memory (since it would have no effect) 3430 // Abort any pending executions 3431 lock: function() { 3432 locked = queue = []; 3433 if ( !memory ) { 3434 list = memory = ""; 3435 } 3436 return this; 3437 }, 3438 locked: function() { 3439 return !!locked; 3440 }, 3441 3442 // Call all callbacks with the given context and arguments 3443 fireWith: function( context, args ) { 3444 if ( !locked ) { 3445 args = args || []; 3446 args = [ context, args.slice ? args.slice() : args ]; 3447 queue.push( args ); 3448 if ( !firing ) { 3449 fire(); 3450 } 3451 } 3452 return this; 3453 }, 3454 3455 // Call all the callbacks with the given arguments 3456 fire: function() { 3457 self.fireWith( this, arguments ); 3458 return this; 3459 }, 3460 3461 // To know if the callbacks have already been called at least once 3462 fired: function() { 3463 return !!fired; 3464 } 3465 }; 3466 3467 return self; 3468 }; 3469 3470 3471 jQuery.extend( { 3472 3473 Deferred: function( func ) { 3474 var tuples = [ 3475 3476 // action, add listener, listener list, final state 3477 [ "resolve", "done", jQuery.Callbacks( "once memory" ), "resolved" ], 3478 [ "reject", "fail", jQuery.Callbacks( "once memory" ), "rejected" ], 3479 [ "notify", "progress", jQuery.Callbacks( "memory" ) ] 3480 ], 3481 state = "pending", 3482 promise = { 3483 state: function() { 3484 return state; 3485 }, 3486 always: function() { 3487 deferred.done( arguments ).fail( arguments ); 3488 return this; 3489 }, 3490 then: function( /* fnDone, fnFail, fnProgress */ ) { 3491 var fns = arguments; 3492 return jQuery.Deferred( function( newDefer ) { 3493 jQuery.each( tuples, function( i, tuple ) { 3494 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; 3495 3496 // deferred[ done | fail | progress ] for forwarding actions to newDefer 3497 deferred[ tuple[ 1 ] ]( function() { 3498 var returned = fn && fn.apply( this, arguments ); 3499 if ( returned && jQuery.isFunction( returned.promise ) ) { 3500 returned.promise() 3501 .progress( newDefer.notify ) 3502 .done( newDefer.resolve ) 3503 .fail( newDefer.reject ); 3504 } else { 3505 newDefer[ tuple[ 0 ] + "With" ]( 3506 this === promise ? newDefer.promise() : this, 3507 fn ? [ returned ] : arguments 3508 ); 3509 } 3510 } ); 3511 } ); 3512 fns = null; 3513 } ).promise(); 3514 }, 3515 3516 // Get a promise for this deferred 3517 // If obj is provided, the promise aspect is added to the object 3518 promise: function( obj ) { 3519 return obj != null ? jQuery.extend( obj, promise ) : promise; 3520 } 3521 }, 3522 deferred = {}; 3523 3524 // Keep pipe for back-compat 3525 promise.pipe = promise.then; 3526 3527 // Add list-specific methods 3528 jQuery.each( tuples, function( i, tuple ) { 3529 var list = tuple[ 2 ], 3530 stateString = tuple[ 3 ]; 3531 3532 // promise[ done | fail | progress ] = list.add 3533 promise[ tuple[ 1 ] ] = list.add; 3534 3535 // Handle state 3536 if ( stateString ) { 3537 list.add( function() { 3538 3539 // state = [ resolved | rejected ] 3540 state = stateString; 3541 3542 // [ reject_list | resolve_list ].disable; progress_list.lock 3543 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); 3544 } 3545 3546 // deferred[ resolve | reject | notify ] 3547 deferred[ tuple[ 0 ] ] = function() { 3548 deferred[ tuple[ 0 ] + "With" ]( this === deferred ? promise : this, arguments ); 3549 return this; 3550 }; 3551 deferred[ tuple[ 0 ] + "With" ] = list.fireWith; 3552 } ); 3553 3554 // Make the deferred a promise 3555 promise.promise( deferred ); 3556 3557 // Call given func if any 3558 if ( func ) { 3559 func.call( deferred, deferred ); 3560 } 3561 3562 // All done! 3563 return deferred; 3564 }, 3565 3566 // Deferred helper 3567 when: function( subordinate /* , ..., subordinateN */ ) { 3568 var i = 0, 3569 resolveValues = slice.call( arguments ), 3570 length = resolveValues.length, 3571 3572 // the count of uncompleted subordinates 3573 remaining = length !== 1 || 3574 ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, 3575 3576 // the master Deferred. 3577 // If resolveValues consist of only a single Deferred, just use that. 3578 deferred = remaining === 1 ? subordinate : jQuery.Deferred(), 3579 3580 // Update function for both resolve and progress values 3581 updateFunc = function( i, contexts, values ) { 3582 return function( value ) { 3583 contexts[ i ] = this; 3584 values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; 3585 if ( values === progressValues ) { 3586 deferred.notifyWith( contexts, values ); 3587 } else if ( !( --remaining ) ) { 3588 deferred.resolveWith( contexts, values ); 3589 } 3590 }; 3591 }, 3592 3593 progressValues, progressContexts, resolveContexts; 3594 3595 // Add listeners to Deferred subordinates; treat others as resolved 3596 if ( length > 1 ) { 3597 progressValues = new Array( length ); 3598 progressContexts = new Array( length ); 3599 resolveContexts = new Array( length ); 3600 for ( ; i < length; i++ ) { 3601 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { 3602 resolveValues[ i ].promise() 3603 .progress( updateFunc( i, progressContexts, progressValues ) ) 3604 .done( updateFunc( i, resolveContexts, resolveValues ) ) 3605 .fail( deferred.reject ); 3606 } else { 3607 --remaining; 3608 } 3609 } 3610 } 3611 3612 // If we're not waiting on anything, resolve the master 3613 if ( !remaining ) { 3614 deferred.resolveWith( resolveContexts, resolveValues ); 3615 } 3616 3617 return deferred.promise(); 3618 } 3619 } ); 3620 3621 3622 // The deferred used on DOM ready 3623 var readyList; 3624 3625 jQuery.fn.ready = function( fn ) { 3626 3627 // Add the callback 3628 jQuery.ready.promise().done( fn ); 3629 3630 return this; 3631 }; 3632 3633 jQuery.extend( { 3634 3635 // Is the DOM ready to be used? Set to true once it occurs. 3636 isReady: false, 3637 3638 // A counter to track how many items to wait for before 3639 // the ready event fires. See #6781 3640 readyWait: 1, 3641 3642 // Hold (or release) the ready event 3643 holdReady: function( hold ) { 3644 if ( hold ) { 3645 jQuery.readyWait++; 3646 } else { 3647 jQuery.ready( true ); 3648 } 3649 }, 3650 3651 // Handle when the DOM is ready 3652 ready: function( wait ) { 3653 3654 // Abort if there are pending holds or we're already ready 3655 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { 3656 return; 3657 } 3658 3659 // Remember that the DOM is ready 3660 jQuery.isReady = true; 3661 3662 // If a normal DOM Ready event fired, decrement, and wait if need be 3663 if ( wait !== true && --jQuery.readyWait > 0 ) { 3664 return; 3665 } 3666 3667 // If there are functions bound, to execute 3668 readyList.resolveWith( document, [ jQuery ] ); 3669 3670 // Trigger any bound ready events 3671 if ( jQuery.fn.triggerHandler ) { 3672 jQuery( document ).triggerHandler( "ready" ); 3673 jQuery( document ).off( "ready" ); 3674 } 3675 } 3676 } ); 3677 3678 /** 3679 * The ready event handler and self cleanup method 3680 */ 3681 function completed() { 3682 document.removeEventListener( "DOMContentLoaded", completed ); 3683 window.removeEventListener( "load", completed ); 3684 jQuery.ready(); 3685 } 3686 3687 jQuery.ready.promise = function( obj ) { 3688 if ( !readyList ) { 3689 3690 readyList = jQuery.Deferred(); 3691 3692 // Catch cases where $(document).ready() is called 3693 // after the browser event has already occurred. 3694 // Support: IE9-10 only 3695 // Older IE sometimes signals "interactive" too soon 3696 if ( document.readyState === "complete" || 3697 ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { 3698 3699 // Handle it asynchronously to allow scripts the opportunity to delay ready 3700 window.setTimeout( jQuery.ready ); 3701 3702 } else { 3703 3704 // Use the handy event callback 3705 document.addEventListener( "DOMContentLoaded", completed ); 3706 3707 // A fallback to window.onload, that will always work 3708 window.addEventListener( "load", completed ); 3709 } 3710 } 3711 return readyList.promise( obj ); 3712 }; 3713 3714 // Kick off the DOM ready check even if the user does not 3715 jQuery.ready.promise(); 3716 3717 3718 3719 3720 // Multifunctional method to get and set values of a collection 3721 // The value/s can optionally be executed if it's a function 3722 var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { 3723 var i = 0, 3724 len = elems.length, 3725 bulk = key == null; 3726 3727 // Sets many values 3728 if ( jQuery.type( key ) === "object" ) { 3729 chainable = true; 3730 for ( i in key ) { 3731 access( elems, fn, i, key[ i ], true, emptyGet, raw ); 3732 } 3733 3734 // Sets one value 3735 } else if ( value !== undefined ) { 3736 chainable = true; 3737 3738 if ( !jQuery.isFunction( value ) ) { 3739 raw = true; 3740 } 3741 3742 if ( bulk ) { 3743 3744 // Bulk operations run against the entire set 3745 if ( raw ) { 3746 fn.call( elems, value ); 3747 fn = null; 3748 3749 // ...except when executing function values 3750 } else { 3751 bulk = fn; 3752 fn = function( elem, key, value ) { 3753 return bulk.call( jQuery( elem ), value ); 3754 }; 3755 } 3756 } 3757 3758 if ( fn ) { 3759 for ( ; i < len; i++ ) { 3760 fn( 3761 elems[ i ], key, raw ? 3762 value : 3763 value.call( elems[ i ], i, fn( elems[ i ], key ) ) 3764 ); 3765 } 3766 } 3767 } 3768 3769 return chainable ? 3770 elems : 3771 3772 // Gets 3773 bulk ? 3774 fn.call( elems ) : 3775 len ? fn( elems[ 0 ], key ) : emptyGet; 3776 }; 3777 var acceptData = function( owner ) { 3778 3779 // Accepts only: 3780 // - Node 3781 // - Node.ELEMENT_NODE 3782 // - Node.DOCUMENT_NODE 3783 // - Object 3784 // - Any 3785 /* jshint -W018 */ 3786 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); 3787 }; 3788 3789 3790 3791 3792 function Data() { 3793 this.expando = jQuery.expando + Data.uid++; 3794 } 3795 3796 Data.uid = 1; 3797 3798 Data.prototype = { 3799 3800 register: function( owner, initial ) { 3801 var value = initial || {}; 3802 3803 // If it is a node unlikely to be stringify-ed or looped over 3804 // use plain assignment 3805 if ( owner.nodeType ) { 3806 owner[ this.expando ] = value; 3807 3808 // Otherwise secure it in a non-enumerable, non-writable property 3809 // configurability must be true to allow the property to be 3810 // deleted with the delete operator 3811 } else { 3812 Object.defineProperty( owner, this.expando, { 3813 value: value, 3814 writable: true, 3815 configurable: true 3816 } ); 3817 } 3818 return owner[ this.expando ]; 3819 }, 3820 cache: function( owner ) { 3821 3822 // We can accept data for non-element nodes in modern browsers, 3823 // but we should not, see #8335. 3824 // Always return an empty object. 3825 if ( !acceptData( owner ) ) { 3826 return {}; 3827 } 3828 3829 // Check if the owner object already has a cache 3830 var value = owner[ this.expando ]; 3831 3832 // If not, create one 3833 if ( !value ) { 3834 value = {}; 3835 3836 // We can accept data for non-element nodes in modern browsers, 3837 // but we should not, see #8335. 3838 // Always return an empty object. 3839 if ( acceptData( owner ) ) { 3840 3841 // If it is a node unlikely to be stringify-ed or looped over 3842 // use plain assignment 3843 if ( owner.nodeType ) { 3844 owner[ this.expando ] = value; 3845 3846 // Otherwise secure it in a non-enumerable property 3847 // configurable must be true to allow the property to be 3848 // deleted when data is removed 3849 } else { 3850 Object.defineProperty( owner, this.expando, { 3851 value: value, 3852 configurable: true 3853 } ); 3854 } 3855 } 3856 } 3857 3858 return value; 3859 }, 3860 set: function( owner, data, value ) { 3861 var prop, 3862 cache = this.cache( owner ); 3863 3864 // Handle: [ owner, key, value ] args 3865 if ( typeof data === "string" ) { 3866 cache[ data ] = value; 3867 3868 // Handle: [ owner, { properties } ] args 3869 } else { 3870 3871 // Copy the properties one-by-one to the cache object 3872 for ( prop in data ) { 3873 cache[ prop ] = data[ prop ]; 3874 } 3875 } 3876 return cache; 3877 }, 3878 get: function( owner, key ) { 3879 return key === undefined ? 3880 this.cache( owner ) : 3881 owner[ this.expando ] && owner[ this.expando ][ key ]; 3882 }, 3883 access: function( owner, key, value ) { 3884 var stored; 3885 3886 // In cases where either: 3887 // 3888 // 1. No key was specified 3889 // 2. A string key was specified, but no value provided 3890 // 3891 // Take the "read" path and allow the get method to determine 3892 // which value to return, respectively either: 3893 // 3894 // 1. The entire cache object 3895 // 2. The data stored at the key 3896 // 3897 if ( key === undefined || 3898 ( ( key && typeof key === "string" ) && value === undefined ) ) { 3899 3900 stored = this.get( owner, key ); 3901 3902 return stored !== undefined ? 3903 stored : this.get( owner, jQuery.camelCase( key ) ); 3904 } 3905 3906 // When the key is not a string, or both a key and value 3907 // are specified, set or extend (existing objects) with either: 3908 // 3909 // 1. An object of properties 3910 // 2. A key and value 3911 // 3912 this.set( owner, key, value ); 3913 3914 // Since the "set" path can have two possible entry points 3915 // return the expected data based on which path was taken[*] 3916 return value !== undefined ? value : key; 3917 }, 3918 remove: function( owner, key ) { 3919 var i, name, camel, 3920 cache = owner[ this.expando ]; 3921 3922 if ( cache === undefined ) { 3923 return; 3924 } 3925 3926 if ( key === undefined ) { 3927 this.register( owner ); 3928 3929 } else { 3930 3931 // Support array or space separated string of keys 3932 if ( jQuery.isArray( key ) ) { 3933 3934 // If "name" is an array of keys... 3935 // When data is initially created, via ("key", "val") signature, 3936 // keys will be converted to camelCase. 3937 // Since there is no way to tell _how_ a key was added, remove 3938 // both plain key and camelCase key. #12786 3939 // This will only penalize the array argument path. 3940 name = key.concat( key.map( jQuery.camelCase ) ); 3941 } else { 3942 camel = jQuery.camelCase( key ); 3943 3944 // Try the string as a key before any manipulation 3945 if ( key in cache ) { 3946 name = [ key, camel ]; 3947 } else { 3948 3949 // If a key with the spaces exists, use it. 3950 // Otherwise, create an array by matching non-whitespace 3951 name = camel; 3952 name = name in cache ? 3953 [ name ] : ( name.match( rnotwhite ) || [] ); 3954 } 3955 } 3956 3957 i = name.length; 3958 3959 while ( i-- ) { 3960 delete cache[ name[ i ] ]; 3961 } 3962 } 3963 3964 // Remove the expando if there's no more data 3965 if ( key === undefined || jQuery.isEmptyObject( cache ) ) { 3966 3967 // Support: Chrome <= 35-45+ 3968 // Webkit & Blink performance suffers when deleting properties 3969 // from DOM nodes, so set to undefined instead 3970 // https://code.google.com/p/chromium/issues/detail?id=378607 3971 if ( owner.nodeType ) { 3972 owner[ this.expando ] = undefined; 3973 } else { 3974 delete owner[ this.expando ]; 3975 } 3976 } 3977 }, 3978 hasData: function( owner ) { 3979 var cache = owner[ this.expando ]; 3980 return cache !== undefined && !jQuery.isEmptyObject( cache ); 3981 } 3982 }; 3983 var dataPriv = new Data(); 3984 3985 var dataUser = new Data(); 3986 3987 3988 3989 // Implementation Summary 3990 // 3991 // 1. Enforce API surface and semantic compatibility with 1.9.x branch 3992 // 2. Improve the module's maintainability by reducing the storage 3993 // paths to a single mechanism. 3994 // 3. Use the same single mechanism to support "private" and "user" data. 3995 // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) 3996 // 5. Avoid exposing implementation details on user objects (eg. expando properties) 3997 // 6. Provide a clear path for implementation upgrade to WeakMap in 2014 3998 3999 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, 4000 rmultiDash = /[A-Z]/g; 4001 4002 function dataAttr( elem, key, data ) { 4003 var name; 4004 4005 // If nothing was found internally, try to fetch any 4006 // data from the HTML5 data-* attribute 4007 if ( data === undefined && elem.nodeType === 1 ) { 4008 name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase(); 4009 data = elem.getAttribute( name ); 4010 4011 if ( typeof data === "string" ) { 4012 try { 4013 data = data === "true" ? true : 4014 data === "false" ? false : 4015 data === "null" ? null : 4016 4017 // Only convert to a number if it doesn't change the string 4018 +data + "" === data ? +data : 4019 rbrace.test( data ) ? jQuery.parseJSON( data ) : 4020 data; 4021 } catch ( e ) {} 4022 4023 // Make sure we set the data so it isn't changed later 4024 dataUser.set( elem, key, data ); 4025 } else { 4026 data = undefined; 4027 } 4028 } 4029 return data; 4030 } 4031 4032 jQuery.extend( { 4033 hasData: function( elem ) { 4034 return dataUser.hasData( elem ) || dataPriv.hasData( elem ); 4035 }, 4036 4037 data: function( elem, name, data ) { 4038 return dataUser.access( elem, name, data ); 4039 }, 4040 4041 removeData: function( elem, name ) { 4042 dataUser.remove( elem, name ); 4043 }, 4044 4045 // TODO: Now that all calls to _data and _removeData have been replaced 4046 // with direct calls to dataPriv methods, these can be deprecated. 4047 _data: function( elem, name, data ) { 4048 return dataPriv.access( elem, name, data ); 4049 }, 4050 4051 _removeData: function( elem, name ) { 4052 dataPriv.remove( elem, name ); 4053 } 4054 } ); 4055 4056 jQuery.fn.extend( { 4057 data: function( key, value ) { 4058 var i, name, data, 4059 elem = this[ 0 ], 4060 attrs = elem && elem.attributes; 4061 4062 // Gets all values 4063 if ( key === undefined ) { 4064 if ( this.length ) { 4065 data = dataUser.get( elem ); 4066 4067 if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) { 4068 i = attrs.length; 4069 while ( i-- ) { 4070 4071 // Support: IE11+ 4072 // The attrs elements can be null (#14894) 4073 if ( attrs[ i ] ) { 4074 name = attrs[ i ].name; 4075 if ( name.indexOf( "data-" ) === 0 ) { 4076 name = jQuery.camelCase( name.slice( 5 ) ); 4077 dataAttr( elem, name, data[ name ] ); 4078 } 4079 } 4080 } 4081 dataPriv.set( elem, "hasDataAttrs", true ); 4082 } 4083 } 4084 4085 return data; 4086 } 4087 4088 // Sets multiple values 4089 if ( typeof key === "object" ) { 4090 return this.each( function() { 4091 dataUser.set( this, key ); 4092 } ); 4093 } 4094 4095 return access( this, function( value ) { 4096 var data, camelKey; 4097 4098 // The calling jQuery object (element matches) is not empty 4099 // (and therefore has an element appears at this[ 0 ]) and the 4100 // `value` parameter was not undefined. An empty jQuery object 4101 // will result in `undefined` for elem = this[ 0 ] which will 4102 // throw an exception if an attempt to read a data cache is made. 4103 if ( elem && value === undefined ) { 4104 4105 // Attempt to get data from the cache 4106 // with the key as-is 4107 data = dataUser.get( elem, key ) || 4108 4109 // Try to find dashed key if it exists (gh-2779) 4110 // This is for 2.2.x only 4111 dataUser.get( elem, key.replace( rmultiDash, "-$&" ).toLowerCase() ); 4112 4113 if ( data !== undefined ) { 4114 return data; 4115 } 4116 4117 camelKey = jQuery.camelCase( key ); 4118 4119 // Attempt to get data from the cache 4120 // with the key camelized 4121 data = dataUser.get( elem, camelKey ); 4122 if ( data !== undefined ) { 4123 return data; 4124 } 4125 4126 // Attempt to "discover" the data in 4127 // HTML5 custom data-* attrs 4128 data = dataAttr( elem, camelKey, undefined ); 4129 if ( data !== undefined ) { 4130 return data; 4131 } 4132 4133 // We tried really hard, but the data doesn't exist. 4134 return; 4135 } 4136 4137 // Set the data... 4138 camelKey = jQuery.camelCase( key ); 4139 this.each( function() { 4140 4141 // First, attempt to store a copy or reference of any 4142 // data that might've been store with a camelCased key. 4143 var data = dataUser.get( this, camelKey ); 4144 4145 // For HTML5 data-* attribute interop, we have to 4146 // store property names with dashes in a camelCase form. 4147 // This might not apply to all properties...* 4148 dataUser.set( this, camelKey, value ); 4149 4150 // *... In the case of properties that might _actually_ 4151 // have dashes, we need to also store a copy of that 4152 // unchanged property. 4153 if ( key.indexOf( "-" ) > -1 && data !== undefined ) { 4154 dataUser.set( this, key, value ); 4155 } 4156 } ); 4157 }, null, value, arguments.length > 1, null, true ); 4158 }, 4159 4160 removeData: function( key ) { 4161 return this.each( function() { 4162 dataUser.remove( this, key ); 4163 } ); 4164 } 4165 } ); 4166 4167 4168 jQuery.extend( { 4169 queue: function( elem, type, data ) { 4170 var queue; 4171 4172 if ( elem ) { 4173 type = ( type || "fx" ) + "queue"; 4174 queue = dataPriv.get( elem, type ); 4175 4176 // Speed up dequeue by getting out quickly if this is just a lookup 4177 if ( data ) { 4178 if ( !queue || jQuery.isArray( data ) ) { 4179 queue = dataPriv.access( elem, type, jQuery.makeArray( data ) ); 4180 } else { 4181 queue.push( data ); 4182 } 4183 } 4184 return queue || []; 4185 } 4186 }, 4187 4188 dequeue: function( elem, type ) { 4189 type = type || "fx"; 4190 4191 var queue = jQuery.queue( elem, type ), 4192 startLength = queue.length, 4193 fn = queue.shift(), 4194 hooks = jQuery._queueHooks( elem, type ), 4195 next = function() { 4196 jQuery.dequeue( elem, type ); 4197 }; 4198 4199 // If the fx queue is dequeued, always remove the progress sentinel 4200 if ( fn === "inprogress" ) { 4201 fn = queue.shift(); 4202 startLength--; 4203 } 4204 4205 if ( fn ) { 4206 4207 // Add a progress sentinel to prevent the fx queue from being 4208 // automatically dequeued 4209 if ( type === "fx" ) { 4210 queue.unshift( "inprogress" ); 4211 } 4212 4213 // Clear up the last queue stop function 4214 delete hooks.stop; 4215 fn.call( elem, next, hooks ); 4216 } 4217 4218 if ( !startLength && hooks ) { 4219 hooks.empty.fire(); 4220 } 4221 }, 4222 4223 // Not public - generate a queueHooks object, or return the current one 4224 _queueHooks: function( elem, type ) { 4225 var key = type + "queueHooks"; 4226 return dataPriv.get( elem, key ) || dataPriv.access( elem, key, { 4227 empty: jQuery.Callbacks( "once memory" ).add( function() { 4228 dataPriv.remove( elem, [ type + "queue", key ] ); 4229 } ) 4230 } ); 4231 } 4232 } ); 4233 4234 jQuery.fn.extend( { 4235 queue: function( type, data ) { 4236 var setter = 2; 4237 4238 if ( typeof type !== "string" ) { 4239 data = type; 4240 type = "fx"; 4241 setter--; 4242 } 4243 4244 if ( arguments.length < setter ) { 4245 return jQuery.queue( this[ 0 ], type ); 4246 } 4247 4248 return data === undefined ? 4249 this : 4250 this.each( function() { 4251 var queue = jQuery.queue( this, type, data ); 4252 4253 // Ensure a hooks for this queue 4254 jQuery._queueHooks( this, type ); 4255 4256 if ( type === "fx" && queue[ 0 ] !== "inprogress" ) { 4257 jQuery.dequeue( this, type ); 4258 } 4259 } ); 4260 }, 4261 dequeue: function( type ) { 4262 return this.each( function() { 4263 jQuery.dequeue( this, type ); 4264 } ); 4265 }, 4266 clearQueue: function( type ) { 4267 return this.queue( type || "fx", [] ); 4268 }, 4269 4270 // Get a promise resolved when queues of a certain type 4271 // are emptied (fx is the type by default) 4272 promise: function( type, obj ) { 4273 var tmp, 4274 count = 1, 4275 defer = jQuery.Deferred(), 4276 elements = this, 4277 i = this.length, 4278 resolve = function() { 4279 if ( !( --count ) ) { 4280 defer.resolveWith( elements, [ elements ] ); 4281 } 4282 }; 4283 4284 if ( typeof type !== "string" ) { 4285 obj = type; 4286 type = undefined; 4287 } 4288 type = type || "fx"; 4289 4290 while ( i-- ) { 4291 tmp = dataPriv.get( elements[ i ], type + "queueHooks" ); 4292 if ( tmp && tmp.empty ) { 4293 count++; 4294 tmp.empty.add( resolve ); 4295 } 4296 } 4297 resolve(); 4298 return defer.promise( obj ); 4299 } 4300 } ); 4301 var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source; 4302 4303 var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); 4304 4305 4306 var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; 4307 4308 var isHidden = function( elem, el ) { 4309 4310 // isHidden might be called from jQuery#filter function; 4311 // in that case, element will be second argument 4312 elem = el || elem; 4313 return jQuery.css( elem, "display" ) === "none" || 4314 !jQuery.contains( elem.ownerDocument, elem ); 4315 }; 4316 4317 4318 4319 function adjustCSS( elem, prop, valueParts, tween ) { 4320 var adjusted, 4321 scale = 1, 4322 maxIterations = 20, 4323 currentValue = tween ? 4324 function() { return tween.cur(); } : 4325 function() { return jQuery.css( elem, prop, "" ); }, 4326 initial = currentValue(), 4327 unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), 4328 4329 // Starting value computation is required for potential unit mismatches 4330 initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && 4331 rcssNum.exec( jQuery.css( elem, prop ) ); 4332 4333 if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { 4334 4335 // Trust units reported by jQuery.css 4336 unit = unit || initialInUnit[ 3 ]; 4337 4338 // Make sure we update the tween properties later on 4339 valueParts = valueParts || []; 4340 4341 // Iteratively approximate from a nonzero starting point 4342 initialInUnit = +initial || 1; 4343 4344 do { 4345 4346 // If previous iteration zeroed out, double until we get *something*. 4347 // Use string for doubling so we don't accidentally see scale as unchanged below 4348 scale = scale || ".5"; 4349 4350 // Adjust and apply 4351 initialInUnit = initialInUnit / scale; 4352 jQuery.style( elem, prop, initialInUnit + unit ); 4353 4354 // Update scale, tolerating zero or NaN from tween.cur() 4355 // Break the loop if scale is unchanged or perfect, or if we've just had enough. 4356 } while ( 4357 scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations 4358 ); 4359 } 4360 4361 if ( valueParts ) { 4362 initialInUnit = +initialInUnit || +initial || 0; 4363 4364 // Apply relative offset (+=/-=) if specified 4365 adjusted = valueParts[ 1 ] ? 4366 initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : 4367 +valueParts[ 2 ]; 4368 if ( tween ) { 4369 tween.unit = unit; 4370 tween.start = initialInUnit; 4371 tween.end = adjusted; 4372 } 4373 } 4374 return adjusted; 4375 } 4376 var rcheckableType = ( /^(?:checkbox|radio)$/i ); 4377 4378 var rtagName = ( /<([\w:-]+)/ ); 4379 4380 var rscriptType = ( /^$|\/(?:java|ecma)script/i ); 4381 4382 4383 4384 // We have to close these tags to support XHTML (#13200) 4385 var wrapMap = { 4386 4387 // Support: IE9 4388 option: [ 1, "<select multiple='multiple'>", "</select>" ], 4389 4390 // XHTML parsers do not magically insert elements in the 4391 // same way that tag soup parsers do. So we cannot shorten 4392 // this by omitting <tbody> or other required elements. 4393 thead: [ 1, "<table>", "</table>" ], 4394 col: [ 2, "<table><colgroup>", "</colgroup></table>" ], 4395 tr: [ 2, "<table><tbody>", "</tbody></table>" ], 4396 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], 4397 4398 _default: [ 0, "", "" ] 4399 }; 4400 4401 // Support: IE9 4402 wrapMap.optgroup = wrapMap.option; 4403 4404 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; 4405 wrapMap.th = wrapMap.td; 4406 4407 4408 function getAll( context, tag ) { 4409 4410 // Support: IE9-11+ 4411 // Use typeof to avoid zero-argument method invocation on host objects (#15151) 4412 var ret = typeof context.getElementsByTagName !== "undefined" ? 4413 context.getElementsByTagName( tag || "*" ) : 4414 typeof context.querySelectorAll !== "undefined" ? 4415 context.querySelectorAll( tag || "*" ) : 4416 []; 4417 4418 return tag === undefined || tag && jQuery.nodeName( context, tag ) ? 4419 jQuery.merge( [ context ], ret ) : 4420 ret; 4421 } 4422 4423 4424 // Mark scripts as having already been evaluated 4425 function setGlobalEval( elems, refElements ) { 4426 var i = 0, 4427 l = elems.length; 4428 4429 for ( ; i < l; i++ ) { 4430 dataPriv.set( 4431 elems[ i ], 4432 "globalEval", 4433 !refElements || dataPriv.get( refElements[ i ], "globalEval" ) 4434 ); 4435 } 4436 } 4437 4438 4439 var rhtml = /<|&#?\w+;/; 4440 4441 function buildFragment( elems, context, scripts, selection, ignored ) { 4442 var elem, tmp, tag, wrap, contains, j, 4443 fragment = context.createDocumentFragment(), 4444 nodes = [], 4445 i = 0, 4446 l = elems.length; 4447 4448 for ( ; i < l; i++ ) { 4449 elem = elems[ i ]; 4450 4451 if ( elem || elem === 0 ) { 4452 4453 // Add nodes directly 4454 if ( jQuery.type( elem ) === "object" ) { 4455 4456 // Support: Android<4.1, PhantomJS<2 4457 // push.apply(_, arraylike) throws on ancient WebKit 4458 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); 4459 4460 // Convert non-html into a text node 4461 } else if ( !rhtml.test( elem ) ) { 4462 nodes.push( context.createTextNode( elem ) ); 4463 4464 // Convert html into DOM nodes 4465 } else { 4466 tmp = tmp || fragment.appendChild( context.createElement( "div" ) ); 4467 4468 // Deserialize a standard representation 4469 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); 4470 wrap = wrapMap[ tag ] || wrapMap._default; 4471 tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ]; 4472 4473 // Descend through wrappers to the right content 4474 j = wrap[ 0 ]; 4475 while ( j-- ) { 4476 tmp = tmp.lastChild; 4477 } 4478 4479 // Support: Android<4.1, PhantomJS<2 4480 // push.apply(_, arraylike) throws on ancient WebKit 4481 jQuery.merge( nodes, tmp.childNodes ); 4482 4483 // Remember the top-level container 4484 tmp = fragment.firstChild; 4485 4486 // Ensure the created nodes are orphaned (#12392) 4487 tmp.textContent = ""; 4488 } 4489 } 4490 } 4491 4492 // Remove wrapper from fragment 4493 fragment.textContent = ""; 4494 4495 i = 0; 4496 while ( ( elem = nodes[ i++ ] ) ) { 4497 4498 // Skip elements already in the context collection (trac-4087) 4499 if ( selection && jQuery.inArray( elem, selection ) > -1 ) { 4500 if ( ignored ) { 4501 ignored.push( elem ); 4502 } 4503 continue; 4504 } 4505 4506 contains = jQuery.contains( elem.ownerDocument, elem ); 4507 4508 // Append to fragment 4509 tmp = getAll( fragment.appendChild( elem ), "script" ); 4510 4511 // Preserve script evaluation history 4512 if ( contains ) { 4513 setGlobalEval( tmp ); 4514 } 4515 4516 // Capture executables 4517 if ( scripts ) { 4518 j = 0; 4519 while ( ( elem = tmp[ j++ ] ) ) { 4520 if ( rscriptType.test( elem.type || "" ) ) { 4521 scripts.push( elem ); 4522 } 4523 } 4524 } 4525 } 4526 4527 return fragment; 4528 } 4529 4530 4531 ( function() { 4532 var fragment = document.createDocumentFragment(), 4533 div = fragment.appendChild( document.createElement( "div" ) ), 4534 input = document.createElement( "input" ); 4535 4536 // Support: Android 4.0-4.3, Safari<=5.1 4537 // Check state lost if the name is set (#11217) 4538 // Support: Windows Web Apps (WWA) 4539 // `name` and `type` must use .setAttribute for WWA (#14901) 4540 input.setAttribute( "type", "radio" ); 4541 input.setAttribute( "checked", "checked" ); 4542 input.setAttribute( "name", "t" ); 4543 4544 div.appendChild( input ); 4545 4546 // Support: Safari<=5.1, Android<4.2 4547 // Older WebKit doesn't clone checked state correctly in fragments 4548 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; 4549 4550 // Support: IE<=11+ 4551 // Make sure textarea (and checkbox) defaultValue is properly cloned 4552 div.innerHTML = "<textarea>x</textarea>"; 4553 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; 4554 } )(); 4555 4556 4557 var 4558 rkeyEvent = /^key/, 4559 rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/, 4560 rtypenamespace = /^([^.]*)(?:\.(.+)|)/; 4561 4562 function returnTrue() { 4563 return true; 4564 } 4565 4566 function returnFalse() { 4567 return false; 4568 } 4569 4570 // Support: IE9 4571 // See #13393 for more info 4572 function safeActiveElement() { 4573 try { 4574 return document.activeElement; 4575 } catch ( err ) { } 4576 } 4577 4578 function on( elem, types, selector, data, fn, one ) { 4579 var origFn, type; 4580 4581 // Types can be a map of types/handlers 4582 if ( typeof types === "object" ) { 4583 4584 // ( types-Object, selector, data ) 4585 if ( typeof selector !== "string" ) { 4586 4587 // ( types-Object, data ) 4588 data = data || selector; 4589 selector = undefined; 4590 } 4591 for ( type in types ) { 4592 on( elem, type, selector, data, types[ type ], one ); 4593 } 4594 return elem; 4595 } 4596 4597 if ( data == null && fn == null ) { 4598 4599 // ( types, fn ) 4600 fn = selector; 4601 data = selector = undefined; 4602 } else if ( fn == null ) { 4603 if ( typeof selector === "string" ) { 4604 4605 // ( types, selector, fn ) 4606 fn = data; 4607 data = undefined; 4608 } else { 4609 4610 // ( types, data, fn ) 4611 fn = data; 4612 data = selector; 4613 selector = undefined; 4614 } 4615 } 4616 if ( fn === false ) { 4617 fn = returnFalse; 4618 } else if ( !fn ) { 4619 return elem; 4620 } 4621 4622 if ( one === 1 ) { 4623 origFn = fn; 4624 fn = function( event ) { 4625 4626 // Can use an empty set, since event contains the info 4627 jQuery().off( event ); 4628 return origFn.apply( this, arguments ); 4629 }; 4630 4631 // Use same guid so caller can remove using origFn 4632 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); 4633 } 4634 return elem.each( function() { 4635 jQuery.event.add( this, types, fn, data, selector ); 4636 } ); 4637 } 4638 4639 /* 4640 * Helper functions for managing events -- not part of the public interface. 4641 * Props to Dean Edwards' addEvent library for many of the ideas. 4642 */ 4643 jQuery.event = { 4644 4645 global: {}, 4646 4647 add: function( elem, types, handler, data, selector ) { 4648 4649 var handleObjIn, eventHandle, tmp, 4650 events, t, handleObj, 4651 special, handlers, type, namespaces, origType, 4652 elemData = dataPriv.get( elem ); 4653 4654 // Don't attach events to noData or text/comment nodes (but allow plain objects) 4655 if ( !elemData ) { 4656 return; 4657 } 4658 4659 // Caller can pass in an object of custom data in lieu of the handler 4660 if ( handler.handler ) { 4661 handleObjIn = handler; 4662 handler = handleObjIn.handler; 4663 selector = handleObjIn.selector; 4664 } 4665 4666 // Make sure that the handler has a unique ID, used to find/remove it later 4667 if ( !handler.guid ) { 4668 handler.guid = jQuery.guid++; 4669 } 4670 4671 // Init the element's event structure and main handler, if this is the first 4672 if ( !( events = elemData.events ) ) { 4673 events = elemData.events = {}; 4674 } 4675 if ( !( eventHandle = elemData.handle ) ) { 4676 eventHandle = elemData.handle = function( e ) { 4677 4678 // Discard the second event of a jQuery.event.trigger() and 4679 // when an event is called after a page has unloaded 4680 return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? 4681 jQuery.event.dispatch.apply( elem, arguments ) : undefined; 4682 }; 4683 } 4684 4685 // Handle multiple events separated by a space 4686 types = ( types || "" ).match( rnotwhite ) || [ "" ]; 4687 t = types.length; 4688 while ( t-- ) { 4689 tmp = rtypenamespace.exec( types[ t ] ) || []; 4690 type = origType = tmp[ 1 ]; 4691 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); 4692 4693 // There *must* be a type, no attaching namespace-only handlers 4694 if ( !type ) { 4695 continue; 4696 } 4697 4698 // If event changes its type, use the special event handlers for the changed type 4699 special = jQuery.event.special[ type ] || {}; 4700 4701 // If selector defined, determine special event api type, otherwise given type 4702 type = ( selector ? special.delegateType : special.bindType ) || type; 4703 4704 // Update special based on newly reset type 4705 special = jQuery.event.special[ type ] || {}; 4706 4707 // handleObj is passed to all event handlers 4708 handleObj = jQuery.extend( { 4709 type: type, 4710 origType: origType, 4711 data: data, 4712 handler: handler, 4713 guid: handler.guid, 4714 selector: selector, 4715 needsContext: selector && jQuery.expr.match.needsContext.test( selector ), 4716 namespace: namespaces.join( "." ) 4717 }, handleObjIn ); 4718 4719 // Init the event handler queue if we're the first 4720 if ( !( handlers = events[ type ] ) ) { 4721 handlers = events[ type ] = []; 4722 handlers.delegateCount = 0; 4723 4724 // Only use addEventListener if the special events handler returns false 4725 if ( !special.setup || 4726 special.setup.call( elem, data, namespaces, eventHandle ) === false ) { 4727 4728 if ( elem.addEventListener ) { 4729 elem.addEventListener( type, eventHandle ); 4730 } 4731 } 4732 } 4733 4734 if ( special.add ) { 4735 special.add.call( elem, handleObj ); 4736 4737 if ( !handleObj.handler.guid ) { 4738 handleObj.handler.guid = handler.guid; 4739 } 4740 } 4741 4742 // Add to the element's handler list, delegates in front 4743 if ( selector ) { 4744 handlers.splice( handlers.delegateCount++, 0, handleObj ); 4745 } else { 4746 handlers.push( handleObj ); 4747 } 4748 4749 // Keep track of which events have ever been used, for event optimization 4750 jQuery.event.global[ type ] = true; 4751 } 4752 4753 }, 4754 4755 // Detach an event or set of events from an element 4756 remove: function( elem, types, handler, selector, mappedTypes ) { 4757 4758 var j, origCount, tmp, 4759 events, t, handleObj, 4760 special, handlers, type, namespaces, origType, 4761 elemData = dataPriv.hasData( elem ) && dataPriv.get( elem ); 4762 4763 if ( !elemData || !( events = elemData.events ) ) { 4764 return; 4765 } 4766 4767 // Once for each type.namespace in types; type may be omitted 4768 types = ( types || "" ).match( rnotwhite ) || [ "" ]; 4769 t = types.length; 4770 while ( t-- ) { 4771 tmp = rtypenamespace.exec( types[ t ] ) || []; 4772 type = origType = tmp[ 1 ]; 4773 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); 4774 4775 // Unbind all events (on this namespace, if provided) for the element 4776 if ( !type ) { 4777 for ( type in events ) { 4778 jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); 4779 } 4780 continue; 4781 } 4782 4783 special = jQuery.event.special[ type ] || {}; 4784 type = ( selector ? special.delegateType : special.bindType ) || type; 4785 handlers = events[ type ] || []; 4786 tmp = tmp[ 2 ] && 4787 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ); 4788 4789 // Remove matching events 4790 origCount = j = handlers.length; 4791 while ( j-- ) { 4792 handleObj = handlers[ j ]; 4793 4794 if ( ( mappedTypes || origType === handleObj.origType ) && 4795 ( !handler || handler.guid === handleObj.guid ) && 4796 ( !tmp || tmp.test( handleObj.namespace ) ) && 4797 ( !selector || selector === handleObj.selector || 4798 selector === "**" && handleObj.selector ) ) { 4799 handlers.splice( j, 1 ); 4800 4801 if ( handleObj.selector ) { 4802 handlers.delegateCount--; 4803 } 4804 if ( special.remove ) { 4805 special.remove.call( elem, handleObj ); 4806 } 4807 } 4808 } 4809 4810 // Remove generic event handler if we removed something and no more handlers exist 4811 // (avoids potential for endless recursion during removal of special event handlers) 4812 if ( origCount && !handlers.length ) { 4813 if ( !special.teardown || 4814 special.teardown.call( elem, namespaces, elemData.handle ) === false ) { 4815 4816 jQuery.removeEvent( elem, type, elemData.handle ); 4817 } 4818 4819 delete events[ type ]; 4820 } 4821 } 4822 4823 // Remove data and the expando if it's no longer used 4824 if ( jQuery.isEmptyObject( events ) ) { 4825 dataPriv.remove( elem, "handle events" ); 4826 } 4827 }, 4828 4829 dispatch: function( event ) { 4830 4831 // Make a writable jQuery.Event from the native event object 4832 event = jQuery.event.fix( event ); 4833 4834 var i, j, ret, matched, handleObj, 4835 handlerQueue = [], 4836 args = slice.call( arguments ), 4837 handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [], 4838 special = jQuery.event.special[ event.type ] || {}; 4839 4840 // Use the fix-ed jQuery.Event rather than the (read-only) native event 4841 args[ 0 ] = event; 4842 event.delegateTarget = this; 4843 4844 // Call the preDispatch hook for the mapped type, and let it bail if desired 4845 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { 4846 return; 4847 } 4848 4849 // Determine handlers 4850 handlerQueue = jQuery.event.handlers.call( this, event, handlers ); 4851 4852 // Run delegates first; they may want to stop propagation beneath us 4853 i = 0; 4854 while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) { 4855 event.currentTarget = matched.elem; 4856 4857 j = 0; 4858 while ( ( handleObj = matched.handlers[ j++ ] ) && 4859 !event.isImmediatePropagationStopped() ) { 4860 4861 // Triggered event must either 1) have no namespace, or 2) have namespace(s) 4862 // a subset or equal to those in the bound event (both can have no namespace). 4863 if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) { 4864 4865 event.handleObj = handleObj; 4866 event.data = handleObj.data; 4867 4868 ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle || 4869 handleObj.handler ).apply( matched.elem, args ); 4870 4871 if ( ret !== undefined ) { 4872 if ( ( event.result = ret ) === false ) { 4873 event.preventDefault(); 4874 event.stopPropagation(); 4875 } 4876 } 4877 } 4878 } 4879 } 4880 4881 // Call the postDispatch hook for the mapped type 4882 if ( special.postDispatch ) { 4883 special.postDispatch.call( this, event ); 4884 } 4885 4886 return event.result; 4887 }, 4888 4889 handlers: function( event, handlers ) { 4890 var i, matches, sel, handleObj, 4891 handlerQueue = [], 4892 delegateCount = handlers.delegateCount, 4893 cur = event.target; 4894 4895 // Support (at least): Chrome, IE9 4896 // Find delegate handlers 4897 // Black-hole SVG <use> instance trees (#13180) 4898 // 4899 // Support: Firefox<=42+ 4900 // Avoid non-left-click in FF but don't block IE radio events (#3861, gh-2343) 4901 if ( delegateCount && cur.nodeType && 4902 ( event.type !== "click" || isNaN( event.button ) || event.button < 1 ) ) { 4903 4904 for ( ; cur !== this; cur = cur.parentNode || this ) { 4905 4906 // Don't check non-elements (#13208) 4907 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) 4908 if ( cur.nodeType === 1 && ( cur.disabled !== true || event.type !== "click" ) ) { 4909 matches = []; 4910 for ( i = 0; i < delegateCount; i++ ) { 4911 handleObj = handlers[ i ]; 4912 4913 // Don't conflict with Object.prototype properties (#13203) 4914 sel = handleObj.selector + " "; 4915 4916 if ( matches[ sel ] === undefined ) { 4917 matches[ sel ] = handleObj.needsContext ? 4918 jQuery( sel, this ).index( cur ) > -1 : 4919 jQuery.find( sel, this, null, [ cur ] ).length; 4920 } 4921 if ( matches[ sel ] ) { 4922 matches.push( handleObj ); 4923 } 4924 } 4925 if ( matches.length ) { 4926 handlerQueue.push( { elem: cur, handlers: matches } ); 4927 } 4928 } 4929 } 4930 } 4931 4932 // Add the remaining (directly-bound) handlers 4933 if ( delegateCount < handlers.length ) { 4934 handlerQueue.push( { elem: this, handlers: handlers.slice( delegateCount ) } ); 4935 } 4936 4937 return handlerQueue; 4938 }, 4939 4940 // Includes some event props shared by KeyEvent and MouseEvent 4941 props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " + 4942 "metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " ), 4943 4944 fixHooks: {}, 4945 4946 keyHooks: { 4947 props: "char charCode key keyCode".split( " " ), 4948 filter: function( event, original ) { 4949 4950 // Add which for key events 4951 if ( event.which == null ) { 4952 event.which = original.charCode != null ? original.charCode : original.keyCode; 4953 } 4954 4955 return event; 4956 } 4957 }, 4958 4959 mouseHooks: { 4960 props: ( "button buttons clientX clientY offsetX offsetY pageX pageY " + 4961 "screenX screenY toElement" ).split( " " ), 4962 filter: function( event, original ) { 4963 var eventDoc, doc, body, 4964 button = original.button; 4965 4966 // Calculate pageX/Y if missing and clientX/Y available 4967 if ( event.pageX == null && original.clientX != null ) { 4968 eventDoc = event.target.ownerDocument || document; 4969 doc = eventDoc.documentElement; 4970 body = eventDoc.body; 4971 4972 event.pageX = original.clientX + 4973 ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - 4974 ( doc && doc.clientLeft || body && body.clientLeft || 0 ); 4975 event.pageY = original.clientY + 4976 ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - 4977 ( doc && doc.clientTop || body && body.clientTop || 0 ); 4978 } 4979 4980 // Add which for click: 1 === left; 2 === middle; 3 === right 4981 // Note: button is not normalized, so don't use it 4982 if ( !event.which && button !== undefined ) { 4983 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); 4984 } 4985 4986 return event; 4987 } 4988 }, 4989 4990 fix: function( event ) { 4991 if ( event[ jQuery.expando ] ) { 4992 return event; 4993 } 4994 4995 // Create a writable copy of the event object and normalize some properties 4996 var i, prop, copy, 4997 type = event.type, 4998 originalEvent = event, 4999 fixHook = this.fixHooks[ type ]; 5000 5001 if ( !fixHook ) { 5002 this.fixHooks[ type ] = fixHook = 5003 rmouseEvent.test( type ) ? this.mouseHooks : 5004 rkeyEvent.test( type ) ? this.keyHooks : 5005 {}; 5006 } 5007 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; 5008 5009 event = new jQuery.Event( originalEvent ); 5010 5011 i = copy.length; 5012 while ( i-- ) { 5013 prop = copy[ i ]; 5014 event[ prop ] = originalEvent[ prop ]; 5015 } 5016 5017 // Support: Cordova 2.5 (WebKit) (#13255) 5018 // All events should have a target; Cordova deviceready doesn't 5019 if ( !event.target ) { 5020 event.target = document; 5021 } 5022 5023 // Support: Safari 6.0+, Chrome<28 5024 // Target should not be a text node (#504, #13143) 5025 if ( event.target.nodeType === 3 ) { 5026 event.target = event.target.parentNode; 5027 } 5028 5029 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event; 5030 }, 5031 5032 special: { 5033 load: { 5034 5035 // Prevent triggered image.load events from bubbling to window.load 5036 noBubble: true 5037 }, 5038 focus: { 5039 5040 // Fire native event if possible so blur/focus sequence is correct 5041 trigger: function() { 5042 if ( this !== safeActiveElement() && this.focus ) { 5043 this.focus(); 5044 return false; 5045 } 5046 }, 5047 delegateType: "focusin" 5048 }, 5049 blur: { 5050 trigger: function() { 5051 if ( this === safeActiveElement() && this.blur ) { 5052 this.blur(); 5053 return false; 5054 } 5055 }, 5056 delegateType: "focusout" 5057 }, 5058 click: { 5059 5060 // For checkbox, fire native event so checked state will be right 5061 trigger: function() { 5062 if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) { 5063 this.click(); 5064 return false; 5065 } 5066 }, 5067 5068 // For cross-browser consistency, don't fire native .click() on links 5069 _default: function( event ) { 5070 return jQuery.nodeName( event.target, "a" ); 5071 } 5072 }, 5073 5074 beforeunload: { 5075 postDispatch: function( event ) { 5076 5077 // Support: Firefox 20+ 5078 // Firefox doesn't alert if the returnValue field is not set. 5079 if ( event.result !== undefined && event.originalEvent ) { 5080 event.originalEvent.returnValue = event.result; 5081 } 5082 } 5083 } 5084 } 5085 }; 5086 5087 jQuery.removeEvent = function( elem, type, handle ) { 5088 5089 // This "if" is needed for plain objects 5090 if ( elem.removeEventListener ) { 5091 elem.removeEventListener( type, handle ); 5092 } 5093 }; 5094 5095 jQuery.Event = function( src, props ) { 5096 5097 // Allow instantiation without the 'new' keyword 5098 if ( !( this instanceof jQuery.Event ) ) { 5099 return new jQuery.Event( src, props ); 5100 } 5101 5102 // Event object 5103 if ( src && src.type ) { 5104 this.originalEvent = src; 5105 this.type = src.type; 5106 5107 // Events bubbling up the document may have been marked as prevented 5108 // by a handler lower down the tree; reflect the correct value. 5109 this.isDefaultPrevented = src.defaultPrevented || 5110 src.defaultPrevented === undefined && 5111 5112 // Support: Android<4.0 5113 src.returnValue === false ? 5114 returnTrue : 5115 returnFalse; 5116 5117 // Event type 5118 } else { 5119 this.type = src; 5120 } 5121 5122 // Put explicitly provided properties onto the event object 5123 if ( props ) { 5124 jQuery.extend( this, props ); 5125 } 5126 5127 // Create a timestamp if incoming event doesn't have one 5128 this.timeStamp = src && src.timeStamp || jQuery.now(); 5129 5130 // Mark it as fixed 5131 this[ jQuery.expando ] = true; 5132 }; 5133 5134 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding 5135 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html 5136 jQuery.Event.prototype = { 5137 constructor: jQuery.Event, 5138 isDefaultPrevented: returnFalse, 5139 isPropagationStopped: returnFalse, 5140 isImmediatePropagationStopped: returnFalse, 5141 isSimulated: false, 5142 5143 preventDefault: function() { 5144 var e = this.originalEvent; 5145 5146 this.isDefaultPrevented = returnTrue; 5147 5148 if ( e && !this.isSimulated ) { 5149 e.preventDefault(); 5150 } 5151 }, 5152 stopPropagation: function() { 5153 var e = this.originalEvent; 5154 5155 this.isPropagationStopped = returnTrue; 5156 5157 if ( e && !this.isSimulated ) { 5158 e.stopPropagation(); 5159 } 5160 }, 5161 stopImmediatePropagation: function() { 5162 var e = this.originalEvent; 5163 5164 this.isImmediatePropagationStopped = returnTrue; 5165 5166 if ( e && !this.isSimulated ) { 5167 e.stopImmediatePropagation(); 5168 } 5169 5170 this.stopPropagation(); 5171 } 5172 }; 5173 5174 // Create mouseenter/leave events using mouseover/out and event-time checks 5175 // so that event delegation works in jQuery. 5176 // Do the same for pointerenter/pointerleave and pointerover/pointerout 5177 // 5178 // Support: Safari 7 only 5179 // Safari sends mouseenter too often; see: 5180 // https://code.google.com/p/chromium/issues/detail?id=470258 5181 // for the description of the bug (it existed in older Chrome versions as well). 5182 jQuery.each( { 5183 mouseenter: "mouseover", 5184 mouseleave: "mouseout", 5185 pointerenter: "pointerover", 5186 pointerleave: "pointerout" 5187 }, function( orig, fix ) { 5188 jQuery.event.special[ orig ] = { 5189 delegateType: fix, 5190 bindType: fix, 5191 5192 handle: function( event ) { 5193 var ret, 5194 target = this, 5195 related = event.relatedTarget, 5196 handleObj = event.handleObj; 5197 5198 // For mouseenter/leave call the handler if related is outside the target. 5199 // NB: No relatedTarget if the mouse left/entered the browser window 5200 if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) { 5201 event.type = handleObj.origType; 5202 ret = handleObj.handler.apply( this, arguments ); 5203 event.type = fix; 5204 } 5205 return ret; 5206 } 5207 }; 5208 } ); 5209 5210 jQuery.fn.extend( { 5211 on: function( types, selector, data, fn ) { 5212 return on( this, types, selector, data, fn ); 5213 }, 5214 one: function( types, selector, data, fn ) { 5215 return on( this, types, selector, data, fn, 1 ); 5216 }, 5217 off: function( types, selector, fn ) { 5218 var handleObj, type; 5219 if ( types && types.preventDefault && types.handleObj ) { 5220 5221 // ( event ) dispatched jQuery.Event 5222 handleObj = types.handleObj; 5223 jQuery( types.delegateTarget ).off( 5224 handleObj.namespace ? 5225 handleObj.origType + "." + handleObj.namespace : 5226 handleObj.origType, 5227 handleObj.selector, 5228 handleObj.handler 5229 ); 5230 return this; 5231 } 5232 if ( typeof types === "object" ) { 5233 5234 // ( types-object [, selector] ) 5235 for ( type in types ) { 5236 this.off( type, selector, types[ type ] ); 5237 } 5238 return this; 5239 } 5240 if ( selector === false || typeof selector === "function" ) { 5241 5242 // ( types [, fn] ) 5243 fn = selector; 5244 selector = undefined; 5245 } 5246 if ( fn === false ) { 5247 fn = returnFalse; 5248 } 5249 return this.each( function() { 5250 jQuery.event.remove( this, types, fn, selector ); 5251 } ); 5252 } 5253 } ); 5254 5255 5256 var 5257 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi, 5258 5259 // Support: IE 10-11, Edge 10240+ 5260 // In IE/Edge using regex groups here causes severe slowdowns. 5261 // See https://connect.microsoft.com/IE/feedback/details/1736512/ 5262 rnoInnerhtml = /<script|<style|<link/i, 5263 5264 // checked="checked" or checked 5265 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, 5266 rscriptTypeMasked = /^true\/(.*)/, 5267 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g; 5268 5269 // Manipulating tables requires a tbody 5270 function manipulationTarget( elem, content ) { 5271 return jQuery.nodeName( elem, "table" ) && 5272 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ? 5273 5274 elem.getElementsByTagName( "tbody" )[ 0 ] || 5275 elem.appendChild( elem.ownerDocument.createElement( "tbody" ) ) : 5276 elem; 5277 } 5278 5279 // Replace/restore the type attribute of script elements for safe DOM manipulation 5280 function disableScript( elem ) { 5281 elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type; 5282 return elem; 5283 } 5284 function restoreScript( elem ) { 5285 var match = rscriptTypeMasked.exec( elem.type ); 5286 5287 if ( match ) { 5288 elem.type = match[ 1 ]; 5289 } else { 5290 elem.removeAttribute( "type" ); 5291 } 5292 5293 return elem; 5294 } 5295 5296 function cloneCopyEvent( src, dest ) { 5297 var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; 5298 5299 if ( dest.nodeType !== 1 ) { 5300 return; 5301 } 5302 5303 // 1. Copy private data: events, handlers, etc. 5304 if ( dataPriv.hasData( src ) ) { 5305 pdataOld = dataPriv.access( src ); 5306 pdataCur = dataPriv.set( dest, pdataOld ); 5307 events = pdataOld.events; 5308 5309 if ( events ) { 5310 delete pdataCur.handle; 5311 pdataCur.events = {}; 5312 5313 for ( type in events ) { 5314 for ( i = 0, l = events[ type ].length; i < l; i++ ) { 5315 jQuery.event.add( dest, type, events[ type ][ i ] ); 5316 } 5317 } 5318 } 5319 } 5320 5321 // 2. Copy user data 5322 if ( dataUser.hasData( src ) ) { 5323 udataOld = dataUser.access( src ); 5324 udataCur = jQuery.extend( {}, udataOld ); 5325 5326 dataUser.set( dest, udataCur ); 5327 } 5328 } 5329 5330 // Fix IE bugs, see support tests 5331 function fixInput( src, dest ) { 5332 var nodeName = dest.nodeName.toLowerCase(); 5333 5334 // Fails to persist the checked state of a cloned checkbox or radio button. 5335 if ( nodeName === "input" && rcheckableType.test( src.type ) ) { 5336 dest.checked = src.checked; 5337 5338 // Fails to return the selected option to the default selected state when cloning options 5339 } else if ( nodeName === "input" || nodeName === "textarea" ) { 5340 dest.defaultValue = src.defaultValue; 5341 } 5342 } 5343 5344 function domManip( collection, args, callback, ignored ) { 5345 5346 // Flatten any nested arrays 5347 args = concat.apply( [], args ); 5348 5349 var fragment, first, scripts, hasScripts, node, doc, 5350 i = 0, 5351 l = collection.length, 5352 iNoClone = l - 1, 5353 value = args[ 0 ], 5354 isFunction = jQuery.isFunction( value ); 5355 5356 // We can't cloneNode fragments that contain checked, in WebKit 5357 if ( isFunction || 5358 ( l > 1 && typeof value === "string" && 5359 !support.checkClone && rchecked.test( value ) ) ) { 5360 return collection.each( function( index ) { 5361 var self = collection.eq( index ); 5362 if ( isFunction ) { 5363 args[ 0 ] = value.call( this, index, self.html() ); 5364 } 5365 domManip( self, args, callback, ignored ); 5366 } ); 5367 } 5368 5369 if ( l ) { 5370 fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored ); 5371 first = fragment.firstChild; 5372 5373 if ( fragment.childNodes.length === 1 ) { 5374 fragment = first; 5375 } 5376 5377 // Require either new content or an interest in ignored elements to invoke the callback 5378 if ( first || ignored ) { 5379 scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); 5380 hasScripts = scripts.length; 5381 5382 // Use the original fragment for the last item 5383 // instead of the first because it can end up 5384 // being emptied incorrectly in certain situations (#8070). 5385 for ( ; i < l; i++ ) { 5386 node = fragment; 5387 5388 if ( i !== iNoClone ) { 5389 node = jQuery.clone( node, true, true ); 5390 5391 // Keep references to cloned scripts for later restoration 5392 if ( hasScripts ) { 5393 5394 // Support: Android<4.1, PhantomJS<2 5395 // push.apply(_, arraylike) throws on ancient WebKit 5396 jQuery.merge( scripts, getAll( node, "script" ) ); 5397 } 5398 } 5399 5400 callback.call( collection[ i ], node, i ); 5401 } 5402 5403 if ( hasScripts ) { 5404 doc = scripts[ scripts.length - 1 ].ownerDocument; 5405 5406 // Reenable scripts 5407 jQuery.map( scripts, restoreScript ); 5408 5409 // Evaluate executable scripts on first document insertion 5410 for ( i = 0; i < hasScripts; i++ ) { 5411 node = scripts[ i ]; 5412 if ( rscriptType.test( node.type || "" ) && 5413 !dataPriv.access( node, "globalEval" ) && 5414 jQuery.contains( doc, node ) ) { 5415 5416 if ( node.src ) { 5417 5418 // Optional AJAX dependency, but won't run scripts if not present 5419 if ( jQuery._evalUrl ) { 5420 jQuery._evalUrl( node.src ); 5421 } 5422 } else { 5423 jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) ); 5424 } 5425 } 5426 } 5427 } 5428 } 5429 } 5430 5431 return collection; 5432 } 5433 5434 function remove( elem, selector, keepData ) { 5435 var node, 5436 nodes = selector ? jQuery.filter( selector, elem ) : elem, 5437 i = 0; 5438 5439 for ( ; ( node = nodes[ i ] ) != null; i++ ) { 5440 if ( !keepData && node.nodeType === 1 ) { 5441 jQuery.cleanData( getAll( node ) ); 5442 } 5443 5444 if ( node.parentNode ) { 5445 if ( keepData && jQuery.contains( node.ownerDocument, node ) ) { 5446 setGlobalEval( getAll( node, "script" ) ); 5447 } 5448 node.parentNode.removeChild( node ); 5449 } 5450 } 5451 5452 return elem; 5453 } 5454 5455 jQuery.extend( { 5456 htmlPrefilter: function( html ) { 5457 return html.replace( rxhtmlTag, "<$1></$2>" ); 5458 }, 5459 5460 clone: function( elem, dataAndEvents, deepDataAndEvents ) { 5461 var i, l, srcElements, destElements, 5462 clone = elem.cloneNode( true ), 5463 inPage = jQuery.contains( elem.ownerDocument, elem ); 5464 5465 // Fix IE cloning issues 5466 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && 5467 !jQuery.isXMLDoc( elem ) ) { 5468 5469 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 5470 destElements = getAll( clone ); 5471 srcElements = getAll( elem ); 5472 5473 for ( i = 0, l = srcElements.length; i < l; i++ ) { 5474 fixInput( srcElements[ i ], destElements[ i ] ); 5475 } 5476 } 5477 5478 // Copy the events from the original to the clone 5479 if ( dataAndEvents ) { 5480 if ( deepDataAndEvents ) { 5481 srcElements = srcElements || getAll( elem ); 5482 destElements = destElements || getAll( clone ); 5483 5484 for ( i = 0, l = srcElements.length; i < l; i++ ) { 5485 cloneCopyEvent( srcElements[ i ], destElements[ i ] ); 5486 } 5487 } else { 5488 cloneCopyEvent( elem, clone ); 5489 } 5490 } 5491 5492 // Preserve script evaluation history 5493 destElements = getAll( clone, "script" ); 5494 if ( destElements.length > 0 ) { 5495 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); 5496 } 5497 5498 // Return the cloned set 5499 return clone; 5500 }, 5501 5502 cleanData: function( elems ) { 5503 var data, elem, type, 5504 special = jQuery.event.special, 5505 i = 0; 5506 5507 for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) { 5508 if ( acceptData( elem ) ) { 5509 if ( ( data = elem[ dataPriv.expando ] ) ) { 5510 if ( data.events ) { 5511 for ( type in data.events ) { 5512 if ( special[ type ] ) { 5513 jQuery.event.remove( elem, type ); 5514 5515 // This is a shortcut to avoid jQuery.event.remove's overhead 5516 } else { 5517 jQuery.removeEvent( elem, type, data.handle ); 5518 } 5519 } 5520 } 5521 5522 // Support: Chrome <= 35-45+ 5523 // Assign undefined instead of using delete, see Data#remove 5524 elem[ dataPriv.expando ] = undefined; 5525 } 5526 if ( elem[ dataUser.expando ] ) { 5527 5528 // Support: Chrome <= 35-45+ 5529 // Assign undefined instead of using delete, see Data#remove 5530 elem[ dataUser.expando ] = undefined; 5531 } 5532 } 5533 } 5534 } 5535 } ); 5536 5537 jQuery.fn.extend( { 5538 5539 // Keep domManip exposed until 3.0 (gh-2225) 5540 domManip: domManip, 5541 5542 detach: function( selector ) { 5543 return remove( this, selector, true ); 5544 }, 5545 5546 remove: function( selector ) { 5547 return remove( this, selector ); 5548 }, 5549 5550 text: function( value ) { 5551 return access( this, function( value ) { 5552 return value === undefined ? 5553 jQuery.text( this ) : 5554 this.empty().each( function() { 5555 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 5556 this.textContent = value; 5557 } 5558 } ); 5559 }, null, value, arguments.length ); 5560 }, 5561 5562 append: function() { 5563 return domManip( this, arguments, function( elem ) { 5564 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 5565 var target = manipulationTarget( this, elem ); 5566 target.appendChild( elem ); 5567 } 5568 } ); 5569 }, 5570 5571 prepend: function() { 5572 return domManip( this, arguments, function( elem ) { 5573 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { 5574 var target = manipulationTarget( this, elem ); 5575 target.insertBefore( elem, target.firstChild ); 5576 } 5577 } ); 5578 }, 5579 5580 before: function() { 5581 return domManip( this, arguments, function( elem ) { 5582 if ( this.parentNode ) { 5583 this.parentNode.insertBefore( elem, this ); 5584 } 5585 } ); 5586 }, 5587 5588 after: function() { 5589 return domManip( this, arguments, function( elem ) { 5590 if ( this.parentNode ) { 5591 this.parentNode.insertBefore( elem, this.nextSibling ); 5592 } 5593 } ); 5594 }, 5595 5596 empty: function() { 5597 var elem, 5598 i = 0; 5599 5600 for ( ; ( elem = this[ i ] ) != null; i++ ) { 5601 if ( elem.nodeType === 1 ) { 5602 5603 // Prevent memory leaks 5604 jQuery.cleanData( getAll( elem, false ) ); 5605 5606 // Remove any remaining nodes 5607 elem.textContent = ""; 5608 } 5609 } 5610 5611 return this; 5612 }, 5613 5614 clone: function( dataAndEvents, deepDataAndEvents ) { 5615 dataAndEvents = dataAndEvents == null ? false : dataAndEvents; 5616 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; 5617 5618 return this.map( function() { 5619 return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); 5620 } ); 5621 }, 5622 5623 html: function( value ) { 5624 return access( this, function( value ) { 5625 var elem = this[ 0 ] || {}, 5626 i = 0, 5627 l = this.length; 5628 5629 if ( value === undefined && elem.nodeType === 1 ) { 5630 return elem.innerHTML; 5631 } 5632 5633 // See if we can take a shortcut and just use innerHTML 5634 if ( typeof value === "string" && !rnoInnerhtml.test( value ) && 5635 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { 5636 5637 value = jQuery.htmlPrefilter( value ); 5638 5639 try { 5640 for ( ; i < l; i++ ) { 5641 elem = this[ i ] || {}; 5642 5643 // Remove element nodes and prevent memory leaks 5644 if ( elem.nodeType === 1 ) { 5645 jQuery.cleanData( getAll( elem, false ) ); 5646 elem.innerHTML = value; 5647 } 5648 } 5649 5650 elem = 0; 5651 5652 // If using innerHTML throws an exception, use the fallback method 5653 } catch ( e ) {} 5654 } 5655 5656 if ( elem ) { 5657 this.empty().append( value ); 5658 } 5659 }, null, value, arguments.length ); 5660 }, 5661 5662 replaceWith: function() { 5663 var ignored = []; 5664 5665 // Make the changes, replacing each non-ignored context element with the new content 5666 return domManip( this, arguments, function( elem ) { 5667 var parent = this.parentNode; 5668 5669 if ( jQuery.inArray( this, ignored ) < 0 ) { 5670 jQuery.cleanData( getAll( this ) ); 5671 if ( parent ) { 5672 parent.replaceChild( elem, this ); 5673 } 5674 } 5675 5676 // Force callback invocation 5677 }, ignored ); 5678 } 5679 } ); 5680 5681 jQuery.each( { 5682 appendTo: "append", 5683 prependTo: "prepend", 5684 insertBefore: "before", 5685 insertAfter: "after", 5686 replaceAll: "replaceWith" 5687 }, function( name, original ) { 5688 jQuery.fn[ name ] = function( selector ) { 5689 var elems, 5690 ret = [], 5691 insert = jQuery( selector ), 5692 last = insert.length - 1, 5693 i = 0; 5694 5695 for ( ; i <= last; i++ ) { 5696 elems = i === last ? this : this.clone( true ); 5697 jQuery( insert[ i ] )[ original ]( elems ); 5698 5699 // Support: QtWebKit 5700 // .get() because push.apply(_, arraylike) throws 5701 push.apply( ret, elems.get() ); 5702 } 5703 5704 return this.pushStack( ret ); 5705 }; 5706 } ); 5707 5708 5709 var iframe, 5710 elemdisplay = { 5711 5712 // Support: Firefox 5713 // We have to pre-define these values for FF (#10227) 5714 HTML: "block", 5715 BODY: "block" 5716 }; 5717 5718 /** 5719 * Retrieve the actual display of a element 5720 * @param {String} name nodeName of the element 5721 * @param {Object} doc Document object 5722 */ 5723 5724 // Called only from within defaultDisplay 5725 function actualDisplay( name, doc ) { 5726 var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), 5727 5728 display = jQuery.css( elem[ 0 ], "display" ); 5729 5730 // We don't have any data stored on the element, 5731 // so use "detach" method as fast way to get rid of the element 5732 elem.detach(); 5733 5734 return display; 5735 } 5736 5737 /** 5738 * Try to determine the default display value of an element 5739 * @param {String} nodeName 5740 */ 5741 function defaultDisplay( nodeName ) { 5742 var doc = document, 5743 display = elemdisplay[ nodeName ]; 5744 5745 if ( !display ) { 5746 display = actualDisplay( nodeName, doc ); 5747 5748 // If the simple way fails, read from inside an iframe 5749 if ( display === "none" || !display ) { 5750 5751 // Use the already-created iframe if possible 5752 iframe = ( iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" ) ) 5753 .appendTo( doc.documentElement ); 5754 5755 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse 5756 doc = iframe[ 0 ].contentDocument; 5757 5758 // Support: IE 5759 doc.write(); 5760 doc.close(); 5761 5762 display = actualDisplay( nodeName, doc ); 5763 iframe.detach(); 5764 } 5765 5766 // Store the correct default display 5767 elemdisplay[ nodeName ] = display; 5768 } 5769 5770 return display; 5771 } 5772 var rmargin = ( /^margin/ ); 5773 5774 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); 5775 5776 var getStyles = function( elem ) { 5777 5778 // Support: IE<=11+, Firefox<=30+ (#15098, #14150) 5779 // IE throws on elements created in popups 5780 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" 5781 var view = elem.ownerDocument.defaultView; 5782 5783 if ( !view || !view.opener ) { 5784 view = window; 5785 } 5786 5787 return view.getComputedStyle( elem ); 5788 }; 5789 5790 var swap = function( elem, options, callback, args ) { 5791 var ret, name, 5792 old = {}; 5793 5794 // Remember the old values, and insert the new ones 5795 for ( name in options ) { 5796 old[ name ] = elem.style[ name ]; 5797 elem.style[ name ] = options[ name ]; 5798 } 5799 5800 ret = callback.apply( elem, args || [] ); 5801 5802 // Revert the old values 5803 for ( name in options ) { 5804 elem.style[ name ] = old[ name ]; 5805 } 5806 5807 return ret; 5808 }; 5809 5810 5811 var documentElement = document.documentElement; 5812 5813 5814 5815 ( function() { 5816 var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, reliableMarginLeftVal, 5817 container = document.createElement( "div" ), 5818 div = document.createElement( "div" ); 5819 5820 // Finish early in limited (non-browser) environments 5821 if ( !div.style ) { 5822 return; 5823 } 5824 5825 // Support: IE9-11+ 5826 // Style of cloned element affects source element cloned (#8908) 5827 div.style.backgroundClip = "content-box"; 5828 div.cloneNode( true ).style.backgroundClip = ""; 5829 support.clearCloneStyle = div.style.backgroundClip === "content-box"; 5830 5831 container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" + 5832 "padding:0;margin-top:1px;position:absolute"; 5833 container.appendChild( div ); 5834 5835 // Executing both pixelPosition & boxSizingReliable tests require only one layout 5836 // so they're executed at the same time to save the second computation. 5837 function computeStyleTests() { 5838 div.style.cssText = 5839 5840 // Support: Firefox<29, Android 2.3 5841 // Vendor-prefix box-sizing 5842 "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;" + 5843 "position:relative;display:block;" + 5844 "margin:auto;border:1px;padding:1px;" + 5845 "top:1%;width:50%"; 5846 div.innerHTML = ""; 5847 documentElement.appendChild( container ); 5848 5849 var divStyle = window.getComputedStyle( div ); 5850 pixelPositionVal = divStyle.top !== "1%"; 5851 reliableMarginLeftVal = divStyle.marginLeft === "2px"; 5852 boxSizingReliableVal = divStyle.width === "4px"; 5853 5854 // Support: Android 4.0 - 4.3 only 5855 // Some styles come back with percentage values, even though they shouldn't 5856 div.style.marginRight = "50%"; 5857 pixelMarginRightVal = divStyle.marginRight === "4px"; 5858 5859 documentElement.removeChild( container ); 5860 } 5861 5862 jQuery.extend( support, { 5863 pixelPosition: function() { 5864 5865 // This test is executed only once but we still do memoizing 5866 // since we can use the boxSizingReliable pre-computing. 5867 // No need to check if the test was already performed, though. 5868 computeStyleTests(); 5869 return pixelPositionVal; 5870 }, 5871 boxSizingReliable: function() { 5872 if ( boxSizingReliableVal == null ) { 5873 computeStyleTests(); 5874 } 5875 return boxSizingReliableVal; 5876 }, 5877 pixelMarginRight: function() { 5878 5879 // Support: Android 4.0-4.3 5880 // We're checking for boxSizingReliableVal here instead of pixelMarginRightVal 5881 // since that compresses better and they're computed together anyway. 5882 if ( boxSizingReliableVal == null ) { 5883 computeStyleTests(); 5884 } 5885 return pixelMarginRightVal; 5886 }, 5887 reliableMarginLeft: function() { 5888 5889 // Support: IE <=8 only, Android 4.0 - 4.3 only, Firefox <=3 - 37 5890 if ( boxSizingReliableVal == null ) { 5891 computeStyleTests(); 5892 } 5893 return reliableMarginLeftVal; 5894 }, 5895 reliableMarginRight: function() { 5896 5897 // Support: Android 2.3 5898 // Check if div with explicit width and no margin-right incorrectly 5899 // gets computed margin-right based on width of container. (#3333) 5900 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right 5901 // This support function is only executed once so no memoizing is needed. 5902 var ret, 5903 marginDiv = div.appendChild( document.createElement( "div" ) ); 5904 5905 // Reset CSS: box-sizing; display; margin; border; padding 5906 marginDiv.style.cssText = div.style.cssText = 5907 5908 // Support: Android 2.3 5909 // Vendor-prefix box-sizing 5910 "-webkit-box-sizing:content-box;box-sizing:content-box;" + 5911 "display:block;margin:0;border:0;padding:0"; 5912 marginDiv.style.marginRight = marginDiv.style.width = "0"; 5913 div.style.width = "1px"; 5914 documentElement.appendChild( container ); 5915 5916 ret = !parseFloat( window.getComputedStyle( marginDiv ).marginRight ); 5917 5918 documentElement.removeChild( container ); 5919 div.removeChild( marginDiv ); 5920 5921 return ret; 5922 } 5923 } ); 5924 } )(); 5925 5926 5927 function curCSS( elem, name, computed ) { 5928 var width, minWidth, maxWidth, ret, 5929 style = elem.style; 5930 5931 computed = computed || getStyles( elem ); 5932 ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined; 5933 5934 // Support: Opera 12.1x only 5935 // Fall back to style even without computed 5936 // computed is undefined for elems on document fragments 5937 if ( ( ret === "" || ret === undefined ) && !jQuery.contains( elem.ownerDocument, elem ) ) { 5938 ret = jQuery.style( elem, name ); 5939 } 5940 5941 // Support: IE9 5942 // getPropertyValue is only needed for .css('filter') (#12537) 5943 if ( computed ) { 5944 5945 // A tribute to the "awesome hack by Dean Edwards" 5946 // Android Browser returns percentage for some values, 5947 // but width seems to be reliably pixels. 5948 // This is against the CSSOM draft spec: 5949 // http://dev.w3.org/csswg/cssom/#resolved-values 5950 if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) { 5951 5952 // Remember the original values 5953 width = style.width; 5954 minWidth = style.minWidth; 5955 maxWidth = style.maxWidth; 5956 5957 // Put in the new values to get a computed value out 5958 style.minWidth = style.maxWidth = style.width = ret; 5959 ret = computed.width; 5960 5961 // Revert the changed values 5962 style.width = width; 5963 style.minWidth = minWidth; 5964 style.maxWidth = maxWidth; 5965 } 5966 } 5967 5968 return ret !== undefined ? 5969 5970 // Support: IE9-11+ 5971 // IE returns zIndex value as an integer. 5972 ret + "" : 5973 ret; 5974 } 5975 5976 5977 function addGetHookIf( conditionFn, hookFn ) { 5978 5979 // Define the hook, we'll check on the first run if it's really needed. 5980 return { 5981 get: function() { 5982 if ( conditionFn() ) { 5983 5984 // Hook not needed (or it's not possible to use it due 5985 // to missing dependency), remove it. 5986 delete this.get; 5987 return; 5988 } 5989 5990 // Hook needed; redefine it so that the support test is not executed again. 5991 return ( this.get = hookFn ).apply( this, arguments ); 5992 } 5993 }; 5994 } 5995 5996 5997 var 5998 5999 // Swappable if display is none or starts with table 6000 // except "table", "table-cell", or "table-caption" 6001 // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display 6002 rdisplayswap = /^(none|table(?!-c[ea]).+)/, 6003 6004 cssShow = { position: "absolute", visibility: "hidden", display: "block" }, 6005 cssNormalTransform = { 6006 letterSpacing: "0", 6007 fontWeight: "400" 6008 }, 6009 6010 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ], 6011 emptyStyle = document.createElement( "div" ).style; 6012 6013 // Return a css property mapped to a potentially vendor prefixed property 6014 function vendorPropName( name ) { 6015 6016 // Shortcut for names that are not vendor prefixed 6017 if ( name in emptyStyle ) { 6018 return name; 6019 } 6020 6021 // Check for vendor prefixed names 6022 var capName = name[ 0 ].toUpperCase() + name.slice( 1 ), 6023 i = cssPrefixes.length; 6024 6025 while ( i-- ) { 6026 name = cssPrefixes[ i ] + capName; 6027 if ( name in emptyStyle ) { 6028 return name; 6029 } 6030 } 6031 } 6032 6033 function setPositiveNumber( elem, value, subtract ) { 6034 6035 // Any relative (+/-) values have already been 6036 // normalized at this point 6037 var matches = rcssNum.exec( value ); 6038 return matches ? 6039 6040 // Guard against undefined "subtract", e.g., when used as in cssHooks 6041 Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) : 6042 value; 6043 } 6044 6045 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { 6046 var i = extra === ( isBorderBox ? "border" : "content" ) ? 6047 6048 // If we already have the right measurement, avoid augmentation 6049 4 : 6050 6051 // Otherwise initialize for horizontal or vertical properties 6052 name === "width" ? 1 : 0, 6053 6054 val = 0; 6055 6056 for ( ; i < 4; i += 2 ) { 6057 6058 // Both box models exclude margin, so add it if we want it 6059 if ( extra === "margin" ) { 6060 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); 6061 } 6062 6063 if ( isBorderBox ) { 6064 6065 // border-box includes padding, so remove it if we want content 6066 if ( extra === "content" ) { 6067 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); 6068 } 6069 6070 // At this point, extra isn't border nor margin, so remove border 6071 if ( extra !== "margin" ) { 6072 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); 6073 } 6074 } else { 6075 6076 // At this point, extra isn't content, so add padding 6077 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); 6078 6079 // At this point, extra isn't content nor padding, so add border 6080 if ( extra !== "padding" ) { 6081 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); 6082 } 6083 } 6084 } 6085 6086 return val; 6087 } 6088 6089 function getWidthOrHeight( elem, name, extra ) { 6090 6091 // Start with offset property, which is equivalent to the border-box value 6092 var valueIsBorderBox = true, 6093 val = name === "width" ? elem.offsetWidth : elem.offsetHeight, 6094 styles = getStyles( elem ), 6095 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; 6096 6097 // Some non-html elements return undefined for offsetWidth, so check for null/undefined 6098 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 6099 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 6100 if ( val <= 0 || val == null ) { 6101 6102 // Fall back to computed then uncomputed css if necessary 6103 val = curCSS( elem, name, styles ); 6104 if ( val < 0 || val == null ) { 6105 val = elem.style[ name ]; 6106 } 6107 6108 // Computed unit is not pixels. Stop here and return. 6109 if ( rnumnonpx.test( val ) ) { 6110 return val; 6111 } 6112 6113 // Check for style in case a browser which returns unreliable values 6114 // for getComputedStyle silently falls back to the reliable elem.style 6115 valueIsBorderBox = isBorderBox && 6116 ( support.boxSizingReliable() || val === elem.style[ name ] ); 6117 6118 // Normalize "", auto, and prepare for extra 6119 val = parseFloat( val ) || 0; 6120 } 6121 6122 // Use the active box-sizing model to add/subtract irrelevant styles 6123 return ( val + 6124 augmentWidthOrHeight( 6125 elem, 6126 name, 6127 extra || ( isBorderBox ? "border" : "content" ), 6128 valueIsBorderBox, 6129 styles 6130 ) 6131 ) + "px"; 6132 } 6133 6134 function showHide( elements, show ) { 6135 var display, elem, hidden, 6136 values = [], 6137 index = 0, 6138 length = elements.length; 6139 6140 for ( ; index < length; index++ ) { 6141 elem = elements[ index ]; 6142 if ( !elem.style ) { 6143 continue; 6144 } 6145 6146 values[ index ] = dataPriv.get( elem, "olddisplay" ); 6147 display = elem.style.display; 6148 if ( show ) { 6149 6150 // Reset the inline display of this element to learn if it is 6151 // being hidden by cascaded rules or not 6152 if ( !values[ index ] && display === "none" ) { 6153 elem.style.display = ""; 6154 } 6155 6156 // Set elements which have been overridden with display: none 6157 // in a stylesheet to whatever the default browser style is 6158 // for such an element 6159 if ( elem.style.display === "" && isHidden( elem ) ) { 6160 values[ index ] = dataPriv.access( 6161 elem, 6162 "olddisplay", 6163 defaultDisplay( elem.nodeName ) 6164 ); 6165 } 6166 } else { 6167 hidden = isHidden( elem ); 6168 6169 if ( display !== "none" || !hidden ) { 6170 dataPriv.set( 6171 elem, 6172 "olddisplay", 6173 hidden ? display : jQuery.css( elem, "display" ) 6174 ); 6175 } 6176 } 6177 } 6178 6179 // Set the display of most of the elements in a second loop 6180 // to avoid the constant reflow 6181 for ( index = 0; index < length; index++ ) { 6182 elem = elements[ index ]; 6183 if ( !elem.style ) { 6184 continue; 6185 } 6186 if ( !show || elem.style.display === "none" || elem.style.display === "" ) { 6187 elem.style.display = show ? values[ index ] || "" : "none"; 6188 } 6189 } 6190 6191 return elements; 6192 } 6193 6194 jQuery.extend( { 6195 6196 // Add in style property hooks for overriding the default 6197 // behavior of getting and setting a style property 6198 cssHooks: { 6199 opacity: { 6200 get: function( elem, computed ) { 6201 if ( computed ) { 6202 6203 // We should always get a number back from opacity 6204 var ret = curCSS( elem, "opacity" ); 6205 return ret === "" ? "1" : ret; 6206 } 6207 } 6208 } 6209 }, 6210 6211 // Don't automatically add "px" to these possibly-unitless properties 6212 cssNumber: { 6213 "animationIterationCount": true, 6214 "columnCount": true, 6215 "fillOpacity": true, 6216 "flexGrow": true, 6217 "flexShrink": true, 6218 "fontWeight": true, 6219 "lineHeight": true, 6220 "opacity": true, 6221 "order": true, 6222 "orphans": true, 6223 "widows": true, 6224 "zIndex": true, 6225 "zoom": true 6226 }, 6227 6228 // Add in properties whose names you wish to fix before 6229 // setting or getting the value 6230 cssProps: { 6231 "float": "cssFloat" 6232 }, 6233 6234 // Get and set the style property on a DOM Node 6235 style: function( elem, name, value, extra ) { 6236 6237 // Don't set styles on text and comment nodes 6238 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { 6239 return; 6240 } 6241 6242 // Make sure that we're working with the right name 6243 var ret, type, hooks, 6244 origName = jQuery.camelCase( name ), 6245 style = elem.style; 6246 6247 name = jQuery.cssProps[ origName ] || 6248 ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName ); 6249 6250 // Gets hook for the prefixed version, then unprefixed version 6251 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; 6252 6253 // Check if we're setting a value 6254 if ( value !== undefined ) { 6255 type = typeof value; 6256 6257 // Convert "+=" or "-=" to relative numbers (#7345) 6258 if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) { 6259 value = adjustCSS( elem, name, ret ); 6260 6261 // Fixes bug #9237 6262 type = "number"; 6263 } 6264 6265 // Make sure that null and NaN values aren't set (#7116) 6266 if ( value == null || value !== value ) { 6267 return; 6268 } 6269 6270 // If a number was passed in, add the unit (except for certain CSS properties) 6271 if ( type === "number" ) { 6272 value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" ); 6273 } 6274 6275 // Support: IE9-11+ 6276 // background-* props affect original clone's values 6277 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { 6278 style[ name ] = "inherit"; 6279 } 6280 6281 // If a hook was provided, use that value, otherwise just set the specified value 6282 if ( !hooks || !( "set" in hooks ) || 6283 ( value = hooks.set( elem, value, extra ) ) !== undefined ) { 6284 6285 style[ name ] = value; 6286 } 6287 6288 } else { 6289 6290 // If a hook was provided get the non-computed value from there 6291 if ( hooks && "get" in hooks && 6292 ( ret = hooks.get( elem, false, extra ) ) !== undefined ) { 6293 6294 return ret; 6295 } 6296 6297 // Otherwise just get the value from the style object 6298 return style[ name ]; 6299 } 6300 }, 6301 6302 css: function( elem, name, extra, styles ) { 6303 var val, num, hooks, 6304 origName = jQuery.camelCase( name ); 6305 6306 // Make sure that we're working with the right name 6307 name = jQuery.cssProps[ origName ] || 6308 ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName ); 6309 6310 // Try prefixed name followed by the unprefixed name 6311 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; 6312 6313 // If a hook was provided get the computed value from there 6314 if ( hooks && "get" in hooks ) { 6315 val = hooks.get( elem, true, extra ); 6316 } 6317 6318 // Otherwise, if a way to get the computed value exists, use that 6319 if ( val === undefined ) { 6320 val = curCSS( elem, name, styles ); 6321 } 6322 6323 // Convert "normal" to computed value 6324 if ( val === "normal" && name in cssNormalTransform ) { 6325 val = cssNormalTransform[ name ]; 6326 } 6327 6328 // Make numeric if forced or a qualifier was provided and val looks numeric 6329 if ( extra === "" || extra ) { 6330 num = parseFloat( val ); 6331 return extra === true || isFinite( num ) ? num || 0 : val; 6332 } 6333 return val; 6334 } 6335 } ); 6336 6337 jQuery.each( [ "height", "width" ], function( i, name ) { 6338 jQuery.cssHooks[ name ] = { 6339 get: function( elem, computed, extra ) { 6340 if ( computed ) { 6341 6342 // Certain elements can have dimension info if we invisibly show them 6343 // but it must have a current display style that would benefit 6344 return rdisplayswap.test( jQuery.css( elem, "display" ) ) && 6345 elem.offsetWidth === 0 ? 6346 swap( elem, cssShow, function() { 6347 return getWidthOrHeight( elem, name, extra ); 6348 } ) : 6349 getWidthOrHeight( elem, name, extra ); 6350 } 6351 }, 6352 6353 set: function( elem, value, extra ) { 6354 var matches, 6355 styles = extra && getStyles( elem ), 6356 subtract = extra && augmentWidthOrHeight( 6357 elem, 6358 name, 6359 extra, 6360 jQuery.css( elem, "boxSizing", false, styles ) === "border-box", 6361 styles 6362 ); 6363 6364 // Convert to pixels if value adjustment is needed 6365 if ( subtract && ( matches = rcssNum.exec( value ) ) && 6366 ( matches[ 3 ] || "px" ) !== "px" ) { 6367 6368 elem.style[ name ] = value; 6369 value = jQuery.css( elem, name ); 6370 } 6371 6372 return setPositiveNumber( elem, value, subtract ); 6373 } 6374 }; 6375 } ); 6376 6377 jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft, 6378 function( elem, computed ) { 6379 if ( computed ) { 6380 return ( parseFloat( curCSS( elem, "marginLeft" ) ) || 6381 elem.getBoundingClientRect().left - 6382 swap( elem, { marginLeft: 0 }, function() { 6383 return elem.getBoundingClientRect().left; 6384 } ) 6385 ) + "px"; 6386 } 6387 } 6388 ); 6389 6390 // Support: Android 2.3 6391 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight, 6392 function( elem, computed ) { 6393 if ( computed ) { 6394 return swap( elem, { "display": "inline-block" }, 6395 curCSS, [ elem, "marginRight" ] ); 6396 } 6397 } 6398 ); 6399 6400 // These hooks are used by animate to expand properties 6401 jQuery.each( { 6402 margin: "", 6403 padding: "", 6404 border: "Width" 6405 }, function( prefix, suffix ) { 6406 jQuery.cssHooks[ prefix + suffix ] = { 6407 expand: function( value ) { 6408 var i = 0, 6409 expanded = {}, 6410 6411 // Assumes a single number if not a string 6412 parts = typeof value === "string" ? value.split( " " ) : [ value ]; 6413 6414 for ( ; i < 4; i++ ) { 6415 expanded[ prefix + cssExpand[ i ] + suffix ] = 6416 parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; 6417 } 6418 6419 return expanded; 6420 } 6421 }; 6422 6423 if ( !rmargin.test( prefix ) ) { 6424 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; 6425 } 6426 } ); 6427 6428 jQuery.fn.extend( { 6429 css: function( name, value ) { 6430 return access( this, function( elem, name, value ) { 6431 var styles, len, 6432 map = {}, 6433 i = 0; 6434 6435 if ( jQuery.isArray( name ) ) { 6436 styles = getStyles( elem ); 6437 len = name.length; 6438 6439 for ( ; i < len; i++ ) { 6440 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); 6441 } 6442 6443 return map; 6444 } 6445 6446 return value !== undefined ? 6447 jQuery.style( elem, name, value ) : 6448 jQuery.css( elem, name ); 6449 }, name, value, arguments.length > 1 ); 6450 }, 6451 show: function() { 6452 return showHide( this, true ); 6453 }, 6454 hide: function() { 6455 return showHide( this ); 6456 }, 6457 toggle: function( state ) { 6458 if ( typeof state === "boolean" ) { 6459 return state ? this.show() : this.hide(); 6460 } 6461 6462 return this.each( function() { 6463 if ( isHidden( this ) ) { 6464 jQuery( this ).show(); 6465 } else { 6466 jQuery( this ).hide(); 6467 } 6468 } ); 6469 } 6470 } ); 6471 6472 6473 function Tween( elem, options, prop, end, easing ) { 6474 return new Tween.prototype.init( elem, options, prop, end, easing ); 6475 } 6476 jQuery.Tween = Tween; 6477 6478 Tween.prototype = { 6479 constructor: Tween, 6480 init: function( elem, options, prop, end, easing, unit ) { 6481 this.elem = elem; 6482 this.prop = prop; 6483 this.easing = easing || jQuery.easing._default; 6484 this.options = options; 6485 this.start = this.now = this.cur(); 6486 this.end = end; 6487 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); 6488 }, 6489 cur: function() { 6490 var hooks = Tween.propHooks[ this.prop ]; 6491 6492 return hooks && hooks.get ? 6493 hooks.get( this ) : 6494 Tween.propHooks._default.get( this ); 6495 }, 6496 run: function( percent ) { 6497 var eased, 6498 hooks = Tween.propHooks[ this.prop ]; 6499 6500 if ( this.options.duration ) { 6501 this.pos = eased = jQuery.easing[ this.easing ]( 6502 percent, this.options.duration * percent, 0, 1, this.options.duration 6503 ); 6504 } else { 6505 this.pos = eased = percent; 6506 } 6507 this.now = ( this.end - this.start ) * eased + this.start; 6508 6509 if ( this.options.step ) { 6510 this.options.step.call( this.elem, this.now, this ); 6511 } 6512 6513 if ( hooks && hooks.set ) { 6514 hooks.set( this ); 6515 } else { 6516 Tween.propHooks._default.set( this ); 6517 } 6518 return this; 6519 } 6520 }; 6521 6522 Tween.prototype.init.prototype = Tween.prototype; 6523 6524 Tween.propHooks = { 6525 _default: { 6526 get: function( tween ) { 6527 var result; 6528 6529 // Use a property on the element directly when it is not a DOM element, 6530 // or when there is no matching style property that exists. 6531 if ( tween.elem.nodeType !== 1 || 6532 tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) { 6533 return tween.elem[ tween.prop ]; 6534 } 6535 6536 // Passing an empty string as a 3rd parameter to .css will automatically 6537 // attempt a parseFloat and fallback to a string if the parse fails. 6538 // Simple values such as "10px" are parsed to Float; 6539 // complex values such as "rotate(1rad)" are returned as-is. 6540 result = jQuery.css( tween.elem, tween.prop, "" ); 6541 6542 // Empty strings, null, undefined and "auto" are converted to 0. 6543 return !result || result === "auto" ? 0 : result; 6544 }, 6545 set: function( tween ) { 6546 6547 // Use step hook for back compat. 6548 // Use cssHook if its there. 6549 // Use .style if available and use plain properties where available. 6550 if ( jQuery.fx.step[ tween.prop ] ) { 6551 jQuery.fx.step[ tween.prop ]( tween ); 6552 } else if ( tween.elem.nodeType === 1 && 6553 ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || 6554 jQuery.cssHooks[ tween.prop ] ) ) { 6555 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); 6556 } else { 6557 tween.elem[ tween.prop ] = tween.now; 6558 } 6559 } 6560 } 6561 }; 6562 6563 // Support: IE9 6564 // Panic based approach to setting things on disconnected nodes 6565 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { 6566 set: function( tween ) { 6567 if ( tween.elem.nodeType && tween.elem.parentNode ) { 6568 tween.elem[ tween.prop ] = tween.now; 6569 } 6570 } 6571 }; 6572 6573 jQuery.easing = { 6574 linear: function( p ) { 6575 return p; 6576 }, 6577 swing: function( p ) { 6578 return 0.5 - Math.cos( p * Math.PI ) / 2; 6579 }, 6580 _default: "swing" 6581 }; 6582 6583 jQuery.fx = Tween.prototype.init; 6584 6585 // Back Compat <1.8 extension point 6586 jQuery.fx.step = {}; 6587 6588 6589 6590 6591 var 6592 fxNow, timerId, 6593 rfxtypes = /^(?:toggle|show|hide)$/, 6594 rrun = /queueHooks$/; 6595 6596 // Animations created synchronously will run synchronously 6597 function createFxNow() { 6598 window.setTimeout( function() { 6599 fxNow = undefined; 6600 } ); 6601 return ( fxNow = jQuery.now() ); 6602 } 6603 6604 // Generate parameters to create a standard animation 6605 function genFx( type, includeWidth ) { 6606 var which, 6607 i = 0, 6608 attrs = { height: type }; 6609 6610 // If we include width, step value is 1 to do all cssExpand values, 6611 // otherwise step value is 2 to skip over Left and Right 6612 includeWidth = includeWidth ? 1 : 0; 6613 for ( ; i < 4 ; i += 2 - includeWidth ) { 6614 which = cssExpand[ i ]; 6615 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; 6616 } 6617 6618 if ( includeWidth ) { 6619 attrs.opacity = attrs.width = type; 6620 } 6621 6622 return attrs; 6623 } 6624 6625 function createTween( value, prop, animation ) { 6626 var tween, 6627 collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ), 6628 index = 0, 6629 length = collection.length; 6630 for ( ; index < length; index++ ) { 6631 if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) { 6632 6633 // We're done with this property 6634 return tween; 6635 } 6636 } 6637 } 6638 6639 function defaultPrefilter( elem, props, opts ) { 6640 /* jshint validthis: true */ 6641 var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay, 6642 anim = this, 6643 orig = {}, 6644 style = elem.style, 6645 hidden = elem.nodeType && isHidden( elem ), 6646 dataShow = dataPriv.get( elem, "fxshow" ); 6647 6648 // Handle queue: false promises 6649 if ( !opts.queue ) { 6650 hooks = jQuery._queueHooks( elem, "fx" ); 6651 if ( hooks.unqueued == null ) { 6652 hooks.unqueued = 0; 6653 oldfire = hooks.empty.fire; 6654 hooks.empty.fire = function() { 6655 if ( !hooks.unqueued ) { 6656 oldfire(); 6657 } 6658 }; 6659 } 6660 hooks.unqueued++; 6661 6662 anim.always( function() { 6663 6664 // Ensure the complete handler is called before this completes 6665 anim.always( function() { 6666 hooks.unqueued--; 6667 if ( !jQuery.queue( elem, "fx" ).length ) { 6668 hooks.empty.fire(); 6669 } 6670 } ); 6671 } ); 6672 } 6673 6674 // Height/width overflow pass 6675 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) { 6676 6677 // Make sure that nothing sneaks out 6678 // Record all 3 overflow attributes because IE9-10 do not 6679 // change the overflow attribute when overflowX and 6680 // overflowY are set to the same value 6681 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; 6682 6683 // Set display property to inline-block for height/width 6684 // animations on inline elements that are having width/height animated 6685 display = jQuery.css( elem, "display" ); 6686 6687 // Test default display if display is currently "none" 6688 checkDisplay = display === "none" ? 6689 dataPriv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display; 6690 6691 if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) { 6692 style.display = "inline-block"; 6693 } 6694 } 6695 6696 if ( opts.overflow ) { 6697 style.overflow = "hidden"; 6698 anim.always( function() { 6699 style.overflow = opts.overflow[ 0 ]; 6700 style.overflowX = opts.overflow[ 1 ]; 6701 style.overflowY = opts.overflow[ 2 ]; 6702 } ); 6703 } 6704 6705 // show/hide pass 6706 for ( prop in props ) { 6707 value = props[ prop ]; 6708 if ( rfxtypes.exec( value ) ) { 6709 delete props[ prop ]; 6710 toggle = toggle || value === "toggle"; 6711 if ( value === ( hidden ? "hide" : "show" ) ) { 6712 6713 // If there is dataShow left over from a stopped hide or show 6714 // and we are going to proceed with show, we should pretend to be hidden 6715 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { 6716 hidden = true; 6717 } else { 6718 continue; 6719 } 6720 } 6721 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); 6722 6723 // Any non-fx value stops us from restoring the original display value 6724 } else { 6725 display = undefined; 6726 } 6727 } 6728 6729 if ( !jQuery.isEmptyObject( orig ) ) { 6730 if ( dataShow ) { 6731 if ( "hidden" in dataShow ) { 6732 hidden = dataShow.hidden; 6733 } 6734 } else { 6735 dataShow = dataPriv.access( elem, "fxshow", {} ); 6736 } 6737 6738 // Store state if its toggle - enables .stop().toggle() to "reverse" 6739 if ( toggle ) { 6740 dataShow.hidden = !hidden; 6741 } 6742 if ( hidden ) { 6743 jQuery( elem ).show(); 6744 } else { 6745 anim.done( function() { 6746 jQuery( elem ).hide(); 6747 } ); 6748 } 6749 anim.done( function() { 6750 var prop; 6751 6752 dataPriv.remove( elem, "fxshow" ); 6753 for ( prop in orig ) { 6754 jQuery.style( elem, prop, orig[ prop ] ); 6755 } 6756 } ); 6757 for ( prop in orig ) { 6758 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); 6759 6760 if ( !( prop in dataShow ) ) { 6761 dataShow[ prop ] = tween.start; 6762 if ( hidden ) { 6763 tween.end = tween.start; 6764 tween.start = prop === "width" || prop === "height" ? 1 : 0; 6765 } 6766 } 6767 } 6768 6769 // If this is a noop like .hide().hide(), restore an overwritten display value 6770 } else if ( ( display === "none" ? defaultDisplay( elem.nodeName ) : display ) === "inline" ) { 6771 style.display = display; 6772 } 6773 } 6774 6775 function propFilter( props, specialEasing ) { 6776 var index, name, easing, value, hooks; 6777 6778 // camelCase, specialEasing and expand cssHook pass 6779 for ( index in props ) { 6780 name = jQuery.camelCase( index ); 6781 easing = specialEasing[ name ]; 6782 value = props[ index ]; 6783 if ( jQuery.isArray( value ) ) { 6784 easing = value[ 1 ]; 6785 value = props[ index ] = value[ 0 ]; 6786 } 6787 6788 if ( index !== name ) { 6789 props[ name ] = value; 6790 delete props[ index ]; 6791 } 6792 6793 hooks = jQuery.cssHooks[ name ]; 6794 if ( hooks && "expand" in hooks ) { 6795 value = hooks.expand( value ); 6796 delete props[ name ]; 6797 6798 // Not quite $.extend, this won't overwrite existing keys. 6799 // Reusing 'index' because we have the correct "name" 6800 for ( index in value ) { 6801 if ( !( index in props ) ) { 6802 props[ index ] = value[ index ]; 6803 specialEasing[ index ] = easing; 6804 } 6805 } 6806 } else { 6807 specialEasing[ name ] = easing; 6808 } 6809 } 6810 } 6811 6812 function Animation( elem, properties, options ) { 6813 var result, 6814 stopped, 6815 index = 0, 6816 length = Animation.prefilters.length, 6817 deferred = jQuery.Deferred().always( function() { 6818 6819 // Don't match elem in the :animated selector 6820 delete tick.elem; 6821 } ), 6822 tick = function() { 6823 if ( stopped ) { 6824 return false; 6825 } 6826 var currentTime = fxNow || createFxNow(), 6827 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), 6828 6829 // Support: Android 2.3 6830 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497) 6831 temp = remaining / animation.duration || 0, 6832 percent = 1 - temp, 6833 index = 0, 6834 length = animation.tweens.length; 6835 6836 for ( ; index < length ; index++ ) { 6837 animation.tweens[ index ].run( percent ); 6838 } 6839 6840 deferred.notifyWith( elem, [ animation, percent, remaining ] ); 6841 6842 if ( percent < 1 && length ) { 6843 return remaining; 6844 } else { 6845 deferred.resolveWith( elem, [ animation ] ); 6846 return false; 6847 } 6848 }, 6849 animation = deferred.promise( { 6850 elem: elem, 6851 props: jQuery.extend( {}, properties ), 6852 opts: jQuery.extend( true, { 6853 specialEasing: {}, 6854 easing: jQuery.easing._default 6855 }, options ), 6856 originalProperties: properties, 6857 originalOptions: options, 6858 startTime: fxNow || createFxNow(), 6859 duration: options.duration, 6860 tweens: [], 6861 createTween: function( prop, end ) { 6862 var tween = jQuery.Tween( elem, animation.opts, prop, end, 6863 animation.opts.specialEasing[ prop ] || animation.opts.easing ); 6864 animation.tweens.push( tween ); 6865 return tween; 6866 }, 6867 stop: function( gotoEnd ) { 6868 var index = 0, 6869 6870 // If we are going to the end, we want to run all the tweens 6871 // otherwise we skip this part 6872 length = gotoEnd ? animation.tweens.length : 0; 6873 if ( stopped ) { 6874 return this; 6875 } 6876 stopped = true; 6877 for ( ; index < length ; index++ ) { 6878 animation.tweens[ index ].run( 1 ); 6879 } 6880 6881 // Resolve when we played the last frame; otherwise, reject 6882 if ( gotoEnd ) { 6883 deferred.notifyWith( elem, [ animation, 1, 0 ] ); 6884 deferred.resolveWith( elem, [ animation, gotoEnd ] ); 6885 } else { 6886 deferred.rejectWith( elem, [ animation, gotoEnd ] ); 6887 } 6888 return this; 6889 } 6890 } ), 6891 props = animation.props; 6892 6893 propFilter( props, animation.opts.specialEasing ); 6894 6895 for ( ; index < length ; index++ ) { 6896 result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts ); 6897 if ( result ) { 6898 if ( jQuery.isFunction( result.stop ) ) { 6899 jQuery._queueHooks( animation.elem, animation.opts.queue ).stop = 6900 jQuery.proxy( result.stop, result ); 6901 } 6902 return result; 6903 } 6904 } 6905 6906 jQuery.map( props, createTween, animation ); 6907 6908 if ( jQuery.isFunction( animation.opts.start ) ) { 6909 animation.opts.start.call( elem, animation ); 6910 } 6911 6912 jQuery.fx.timer( 6913 jQuery.extend( tick, { 6914 elem: elem, 6915 anim: animation, 6916 queue: animation.opts.queue 6917 } ) 6918 ); 6919 6920 // attach callbacks from options 6921 return animation.progress( animation.opts.progress ) 6922 .done( animation.opts.done, animation.opts.complete ) 6923 .fail( animation.opts.fail ) 6924 .always( animation.opts.always ); 6925 } 6926 6927 jQuery.Animation = jQuery.extend( Animation, { 6928 tweeners: { 6929 "*": [ function( prop, value ) { 6930 var tween = this.createTween( prop, value ); 6931 adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween ); 6932 return tween; 6933 } ] 6934 }, 6935 6936 tweener: function( props, callback ) { 6937 if ( jQuery.isFunction( props ) ) { 6938 callback = props; 6939 props = [ "*" ]; 6940 } else { 6941 props = props.match( rnotwhite ); 6942 } 6943 6944 var prop, 6945 index = 0, 6946 length = props.length; 6947 6948 for ( ; index < length ; index++ ) { 6949 prop = props[ index ]; 6950 Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || []; 6951 Animation.tweeners[ prop ].unshift( callback ); 6952 } 6953 }, 6954 6955 prefilters: [ defaultPrefilter ], 6956 6957 prefilter: function( callback, prepend ) { 6958 if ( prepend ) { 6959 Animation.prefilters.unshift( callback ); 6960 } else { 6961 Animation.prefilters.push( callback ); 6962 } 6963 } 6964 } ); 6965 6966 jQuery.speed = function( speed, easing, fn ) { 6967 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { 6968 complete: fn || !fn && easing || 6969 jQuery.isFunction( speed ) && speed, 6970 duration: speed, 6971 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing 6972 }; 6973 6974 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? 6975 opt.duration : opt.duration in jQuery.fx.speeds ? 6976 jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; 6977 6978 // Normalize opt.queue - true/undefined/null -> "fx" 6979 if ( opt.queue == null || opt.queue === true ) { 6980 opt.queue = "fx"; 6981 } 6982 6983 // Queueing 6984 opt.old = opt.complete; 6985 6986 opt.complete = function() { 6987 if ( jQuery.isFunction( opt.old ) ) { 6988 opt.old.call( this ); 6989 } 6990 6991 if ( opt.queue ) { 6992 jQuery.dequeue( this, opt.queue ); 6993 } 6994 }; 6995 6996 return opt; 6997 }; 6998 6999 jQuery.fn.extend( { 7000 fadeTo: function( speed, to, easing, callback ) { 7001 7002 // Show any hidden elements after setting opacity to 0 7003 return this.filter( isHidden ).css( "opacity", 0 ).show() 7004 7005 // Animate to the value specified 7006 .end().animate( { opacity: to }, speed, easing, callback ); 7007 }, 7008 animate: function( prop, speed, easing, callback ) { 7009 var empty = jQuery.isEmptyObject( prop ), 7010 optall = jQuery.speed( speed, easing, callback ), 7011 doAnimation = function() { 7012 7013 // Operate on a copy of prop so per-property easing won't be lost 7014 var anim = Animation( this, jQuery.extend( {}, prop ), optall ); 7015 7016 // Empty animations, or finishing resolves immediately 7017 if ( empty || dataPriv.get( this, "finish" ) ) { 7018 anim.stop( true ); 7019 } 7020 }; 7021 doAnimation.finish = doAnimation; 7022 7023 return empty || optall.queue === false ? 7024 this.each( doAnimation ) : 7025 this.queue( optall.queue, doAnimation ); 7026 }, 7027 stop: function( type, clearQueue, gotoEnd ) { 7028 var stopQueue = function( hooks ) { 7029 var stop = hooks.stop; 7030 delete hooks.stop; 7031 stop( gotoEnd ); 7032 }; 7033 7034 if ( typeof type !== "string" ) { 7035 gotoEnd = clearQueue; 7036 clearQueue = type; 7037 type = undefined; 7038 } 7039 if ( clearQueue && type !== false ) { 7040 this.queue( type || "fx", [] ); 7041 } 7042 7043 return this.each( function() { 7044 var dequeue = true, 7045 index = type != null && type + "queueHooks", 7046 timers = jQuery.timers, 7047 data = dataPriv.get( this ); 7048 7049 if ( index ) { 7050 if ( data[ index ] && data[ index ].stop ) { 7051 stopQueue( data[ index ] ); 7052 } 7053 } else { 7054 for ( index in data ) { 7055 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { 7056 stopQueue( data[ index ] ); 7057 } 7058 } 7059 } 7060 7061 for ( index = timers.length; index--; ) { 7062 if ( timers[ index ].elem === this && 7063 ( type == null || timers[ index ].queue === type ) ) { 7064 7065 timers[ index ].anim.stop( gotoEnd ); 7066 dequeue = false; 7067 timers.splice( index, 1 ); 7068 } 7069 } 7070 7071 // Start the next in the queue if the last step wasn't forced. 7072 // Timers currently will call their complete callbacks, which 7073 // will dequeue but only if they were gotoEnd. 7074 if ( dequeue || !gotoEnd ) { 7075 jQuery.dequeue( this, type ); 7076 } 7077 } ); 7078 }, 7079 finish: function( type ) { 7080 if ( type !== false ) { 7081 type = type || "fx"; 7082 } 7083 return this.each( function() { 7084 var index, 7085 data = dataPriv.get( this ), 7086 queue = data[ type + "queue" ], 7087 hooks = data[ type + "queueHooks" ], 7088 timers = jQuery.timers, 7089 length = queue ? queue.length : 0; 7090 7091 // Enable finishing flag on private data 7092 data.finish = true; 7093 7094 // Empty the queue first 7095 jQuery.queue( this, type, [] ); 7096 7097 if ( hooks && hooks.stop ) { 7098 hooks.stop.call( this, true ); 7099 } 7100 7101 // Look for any active animations, and finish them 7102 for ( index = timers.length; index--; ) { 7103 if ( timers[ index ].elem === this && timers[ index ].queue === type ) { 7104 timers[ index ].anim.stop( true ); 7105 timers.splice( index, 1 ); 7106 } 7107 } 7108 7109 // Look for any animations in the old queue and finish them 7110 for ( index = 0; index < length; index++ ) { 7111 if ( queue[ index ] && queue[ index ].finish ) { 7112 queue[ index ].finish.call( this ); 7113 } 7114 } 7115 7116 // Turn off finishing flag 7117 delete data.finish; 7118 } ); 7119 } 7120 } ); 7121 7122 jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) { 7123 var cssFn = jQuery.fn[ name ]; 7124 jQuery.fn[ name ] = function( speed, easing, callback ) { 7125 return speed == null || typeof speed === "boolean" ? 7126 cssFn.apply( this, arguments ) : 7127 this.animate( genFx( name, true ), speed, easing, callback ); 7128 }; 7129 } ); 7130 7131 // Generate shortcuts for custom animations 7132 jQuery.each( { 7133 slideDown: genFx( "show" ), 7134 slideUp: genFx( "hide" ), 7135 slideToggle: genFx( "toggle" ), 7136 fadeIn: { opacity: "show" }, 7137 fadeOut: { opacity: "hide" }, 7138 fadeToggle: { opacity: "toggle" } 7139 }, function( name, props ) { 7140 jQuery.fn[ name ] = function( speed, easing, callback ) { 7141 return this.animate( props, speed, easing, callback ); 7142 }; 7143 } ); 7144 7145 jQuery.timers = []; 7146 jQuery.fx.tick = function() { 7147 var timer, 7148 i = 0, 7149 timers = jQuery.timers; 7150 7151 fxNow = jQuery.now(); 7152 7153 for ( ; i < timers.length; i++ ) { 7154 timer = timers[ i ]; 7155 7156 // Checks the timer has not already been removed 7157 if ( !timer() && timers[ i ] === timer ) { 7158 timers.splice( i--, 1 ); 7159 } 7160 } 7161 7162 if ( !timers.length ) { 7163 jQuery.fx.stop(); 7164 } 7165 fxNow = undefined; 7166 }; 7167 7168 jQuery.fx.timer = function( timer ) { 7169 jQuery.timers.push( timer ); 7170 if ( timer() ) { 7171 jQuery.fx.start(); 7172 } else { 7173 jQuery.timers.pop(); 7174 } 7175 }; 7176 7177 jQuery.fx.interval = 13; 7178 jQuery.fx.start = function() { 7179 if ( !timerId ) { 7180 timerId = window.setInterval( jQuery.fx.tick, jQuery.fx.interval ); 7181 } 7182 }; 7183 7184 jQuery.fx.stop = function() { 7185 window.clearInterval( timerId ); 7186 7187 timerId = null; 7188 }; 7189 7190 jQuery.fx.speeds = { 7191 slow: 600, 7192 fast: 200, 7193 7194 // Default speed 7195 _default: 400 7196 }; 7197 7198 7199 // Based off of the plugin by Clint Helfers, with permission. 7200 // http://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/ 7201 jQuery.fn.delay = function( time, type ) { 7202 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; 7203 type = type || "fx"; 7204 7205 return this.queue( type, function( next, hooks ) { 7206 var timeout = window.setTimeout( next, time ); 7207 hooks.stop = function() { 7208 window.clearTimeout( timeout ); 7209 }; 7210 } ); 7211 }; 7212 7213 7214 ( function() { 7215 var input = document.createElement( "input" ), 7216 select = document.createElement( "select" ), 7217 opt = select.appendChild( document.createElement( "option" ) ); 7218 7219 input.type = "checkbox"; 7220 7221 // Support: iOS<=5.1, Android<=4.2+ 7222 // Default value for a checkbox should be "on" 7223 support.checkOn = input.value !== ""; 7224 7225 // Support: IE<=11+ 7226 // Must access selectedIndex to make default options select 7227 support.optSelected = opt.selected; 7228 7229 // Support: Android<=2.3 7230 // Options inside disabled selects are incorrectly marked as disabled 7231 select.disabled = true; 7232 support.optDisabled = !opt.disabled; 7233 7234 // Support: IE<=11+ 7235 // An input loses its value after becoming a radio 7236 input = document.createElement( "input" ); 7237 input.value = "t"; 7238 input.type = "radio"; 7239 support.radioValue = input.value === "t"; 7240 } )(); 7241 7242 7243 var boolHook, 7244 attrHandle = jQuery.expr.attrHandle; 7245 7246 jQuery.fn.extend( { 7247 attr: function( name, value ) { 7248 return access( this, jQuery.attr, name, value, arguments.length > 1 ); 7249 }, 7250 7251 removeAttr: function( name ) { 7252 return this.each( function() { 7253 jQuery.removeAttr( this, name ); 7254 } ); 7255 } 7256 } ); 7257 7258 jQuery.extend( { 7259 attr: function( elem, name, value ) { 7260 var ret, hooks, 7261 nType = elem.nodeType; 7262 7263 // Don't get/set attributes on text, comment and attribute nodes 7264 if ( nType === 3 || nType === 8 || nType === 2 ) { 7265 return; 7266 } 7267 7268 // Fallback to prop when attributes are not supported 7269 if ( typeof elem.getAttribute === "undefined" ) { 7270 return jQuery.prop( elem, name, value ); 7271 } 7272 7273 // All attributes are lowercase 7274 // Grab necessary hook if one is defined 7275 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { 7276 name = name.toLowerCase(); 7277 hooks = jQuery.attrHooks[ name ] || 7278 ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined ); 7279 } 7280 7281 if ( value !== undefined ) { 7282 if ( value === null ) { 7283 jQuery.removeAttr( elem, name ); 7284 return; 7285 } 7286 7287 if ( hooks && "set" in hooks && 7288 ( ret = hooks.set( elem, value, name ) ) !== undefined ) { 7289 return ret; 7290 } 7291 7292 elem.setAttribute( name, value + "" ); 7293 return value; 7294 } 7295 7296 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { 7297 return ret; 7298 } 7299 7300 ret = jQuery.find.attr( elem, name ); 7301 7302 // Non-existent attributes return null, we normalize to undefined 7303 return ret == null ? undefined : ret; 7304 }, 7305 7306 attrHooks: { 7307 type: { 7308 set: function( elem, value ) { 7309 if ( !support.radioValue && value === "radio" && 7310 jQuery.nodeName( elem, "input" ) ) { 7311 var val = elem.value; 7312 elem.setAttribute( "type", value ); 7313 if ( val ) { 7314 elem.value = val; 7315 } 7316 return value; 7317 } 7318 } 7319 } 7320 }, 7321 7322 removeAttr: function( elem, value ) { 7323 var name, propName, 7324 i = 0, 7325 attrNames = value && value.match( rnotwhite ); 7326 7327 if ( attrNames && elem.nodeType === 1 ) { 7328 while ( ( name = attrNames[ i++ ] ) ) { 7329 propName = jQuery.propFix[ name ] || name; 7330 7331 // Boolean attributes get special treatment (#10870) 7332 if ( jQuery.expr.match.bool.test( name ) ) { 7333 7334 // Set corresponding property to false 7335 elem[ propName ] = false; 7336 } 7337 7338 elem.removeAttribute( name ); 7339 } 7340 } 7341 } 7342 } ); 7343 7344 // Hooks for boolean attributes 7345 boolHook = { 7346 set: function( elem, value, name ) { 7347 if ( value === false ) { 7348 7349 // Remove boolean attributes when set to false 7350 jQuery.removeAttr( elem, name ); 7351 } else { 7352 elem.setAttribute( name, name ); 7353 } 7354 return name; 7355 } 7356 }; 7357 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) { 7358 var getter = attrHandle[ name ] || jQuery.find.attr; 7359 7360 attrHandle[ name ] = function( elem, name, isXML ) { 7361 var ret, handle; 7362 if ( !isXML ) { 7363 7364 // Avoid an infinite loop by temporarily removing this function from the getter 7365 handle = attrHandle[ name ]; 7366 attrHandle[ name ] = ret; 7367 ret = getter( elem, name, isXML ) != null ? 7368 name.toLowerCase() : 7369 null; 7370 attrHandle[ name ] = handle; 7371 } 7372 return ret; 7373 }; 7374 } ); 7375 7376 7377 7378 7379 var rfocusable = /^(?:input|select|textarea|button)$/i, 7380 rclickable = /^(?:a|area)$/i; 7381 7382 jQuery.fn.extend( { 7383 prop: function( name, value ) { 7384 return access( this, jQuery.prop, name, value, arguments.length > 1 ); 7385 }, 7386 7387 removeProp: function( name ) { 7388 return this.each( function() { 7389 delete this[ jQuery.propFix[ name ] || name ]; 7390 } ); 7391 } 7392 } ); 7393 7394 jQuery.extend( { 7395 prop: function( elem, name, value ) { 7396 var ret, hooks, 7397 nType = elem.nodeType; 7398 7399 // Don't get/set properties on text, comment and attribute nodes 7400 if ( nType === 3 || nType === 8 || nType === 2 ) { 7401 return; 7402 } 7403 7404 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { 7405 7406 // Fix name and attach hooks 7407 name = jQuery.propFix[ name ] || name; 7408 hooks = jQuery.propHooks[ name ]; 7409 } 7410 7411 if ( value !== undefined ) { 7412 if ( hooks && "set" in hooks && 7413 ( ret = hooks.set( elem, value, name ) ) !== undefined ) { 7414 return ret; 7415 } 7416 7417 return ( elem[ name ] = value ); 7418 } 7419 7420 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { 7421 return ret; 7422 } 7423 7424 return elem[ name ]; 7425 }, 7426 7427 propHooks: { 7428 tabIndex: { 7429 get: function( elem ) { 7430 7431 // elem.tabIndex doesn't always return the 7432 // correct value when it hasn't been explicitly set 7433 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ 7434 // Use proper attribute retrieval(#12072) 7435 var tabindex = jQuery.find.attr( elem, "tabindex" ); 7436 7437 return tabindex ? 7438 parseInt( tabindex, 10 ) : 7439 rfocusable.test( elem.nodeName ) || 7440 rclickable.test( elem.nodeName ) && elem.href ? 7441 0 : 7442 -1; 7443 } 7444 } 7445 }, 7446 7447 propFix: { 7448 "for": "htmlFor", 7449 "class": "className" 7450 } 7451 } ); 7452 7453 // Support: IE <=11 only 7454 // Accessing the selectedIndex property 7455 // forces the browser to respect setting selected 7456 // on the option 7457 // The getter ensures a default option is selected 7458 // when in an optgroup 7459 if ( !support.optSelected ) { 7460 jQuery.propHooks.selected = { 7461 get: function( elem ) { 7462 var parent = elem.parentNode; 7463 if ( parent && parent.parentNode ) { 7464 parent.parentNode.selectedIndex; 7465 } 7466 return null; 7467 }, 7468 set: function( elem ) { 7469 var parent = elem.parentNode; 7470 if ( parent ) { 7471 parent.selectedIndex; 7472 7473 if ( parent.parentNode ) { 7474 parent.parentNode.selectedIndex; 7475 } 7476 } 7477 } 7478 }; 7479 } 7480 7481 jQuery.each( [ 7482 "tabIndex", 7483 "readOnly", 7484 "maxLength", 7485 "cellSpacing", 7486 "cellPadding", 7487 "rowSpan", 7488 "colSpan", 7489 "useMap", 7490 "frameBorder", 7491 "contentEditable" 7492 ], function() { 7493 jQuery.propFix[ this.toLowerCase() ] = this; 7494 } ); 7495 7496 7497 7498 7499 var rclass = /[\t\r\n\f]/g; 7500 7501 function getClass( elem ) { 7502 return elem.getAttribute && elem.getAttribute( "class" ) || ""; 7503 } 7504 7505 jQuery.fn.extend( { 7506 addClass: function( value ) { 7507 var classes, elem, cur, curValue, clazz, j, finalValue, 7508 i = 0; 7509 7510 if ( jQuery.isFunction( value ) ) { 7511 return this.each( function( j ) { 7512 jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); 7513 } ); 7514 } 7515 7516 if ( typeof value === "string" && value ) { 7517 classes = value.match( rnotwhite ) || []; 7518 7519 while ( ( elem = this[ i++ ] ) ) { 7520 curValue = getClass( elem ); 7521 cur = elem.nodeType === 1 && 7522 ( " " + curValue + " " ).replace( rclass, " " ); 7523 7524 if ( cur ) { 7525 j = 0; 7526 while ( ( clazz = classes[ j++ ] ) ) { 7527 if ( cur.indexOf( " " + clazz + " " ) < 0 ) { 7528 cur += clazz + " "; 7529 } 7530 } 7531 7532 // Only assign if different to avoid unneeded rendering. 7533 finalValue = jQuery.trim( cur ); 7534 if ( curValue !== finalValue ) { 7535 elem.setAttribute( "class", finalValue ); 7536 } 7537 } 7538 } 7539 } 7540 7541 return this; 7542 }, 7543 7544 removeClass: function( value ) { 7545 var classes, elem, cur, curValue, clazz, j, finalValue, 7546 i = 0; 7547 7548 if ( jQuery.isFunction( value ) ) { 7549 return this.each( function( j ) { 7550 jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) ); 7551 } ); 7552 } 7553 7554 if ( !arguments.length ) { 7555 return this.attr( "class", "" ); 7556 } 7557 7558 if ( typeof value === "string" && value ) { 7559 classes = value.match( rnotwhite ) || []; 7560 7561 while ( ( elem = this[ i++ ] ) ) { 7562 curValue = getClass( elem ); 7563 7564 // This expression is here for better compressibility (see addClass) 7565 cur = elem.nodeType === 1 && 7566 ( " " + curValue + " " ).replace( rclass, " " ); 7567 7568 if ( cur ) { 7569 j = 0; 7570 while ( ( clazz = classes[ j++ ] ) ) { 7571 7572 // Remove *all* instances 7573 while ( cur.indexOf( " " + clazz + " " ) > -1 ) { 7574 cur = cur.replace( " " + clazz + " ", " " ); 7575 } 7576 } 7577 7578 // Only assign if different to avoid unneeded rendering. 7579 finalValue = jQuery.trim( cur ); 7580 if ( curValue !== finalValue ) { 7581 elem.setAttribute( "class", finalValue ); 7582 } 7583 } 7584 } 7585 } 7586 7587 return this; 7588 }, 7589 7590 toggleClass: function( value, stateVal ) { 7591 var type = typeof value; 7592 7593 if ( typeof stateVal === "boolean" && type === "string" ) { 7594 return stateVal ? this.addClass( value ) : this.removeClass( value ); 7595 } 7596 7597 if ( jQuery.isFunction( value ) ) { 7598 return this.each( function( i ) { 7599 jQuery( this ).toggleClass( 7600 value.call( this, i, getClass( this ), stateVal ), 7601 stateVal 7602 ); 7603 } ); 7604 } 7605 7606 return this.each( function() { 7607 var className, i, self, classNames; 7608 7609 if ( type === "string" ) { 7610 7611 // Toggle individual class names 7612 i = 0; 7613 self = jQuery( this ); 7614 classNames = value.match( rnotwhite ) || []; 7615 7616 while ( ( className = classNames[ i++ ] ) ) { 7617 7618 // Check each className given, space separated list 7619 if ( self.hasClass( className ) ) { 7620 self.removeClass( className ); 7621 } else { 7622 self.addClass( className ); 7623 } 7624 } 7625 7626 // Toggle whole class name 7627 } else if ( value === undefined || type === "boolean" ) { 7628 className = getClass( this ); 7629 if ( className ) { 7630 7631 // Store className if set 7632 dataPriv.set( this, "__className__", className ); 7633 } 7634 7635 // If the element has a class name or if we're passed `false`, 7636 // then remove the whole classname (if there was one, the above saved it). 7637 // Otherwise bring back whatever was previously saved (if anything), 7638 // falling back to the empty string if nothing was stored. 7639 if ( this.setAttribute ) { 7640 this.setAttribute( "class", 7641 className || value === false ? 7642 "" : 7643 dataPriv.get( this, "__className__" ) || "" 7644 ); 7645 } 7646 } 7647 } ); 7648 }, 7649 7650 hasClass: function( selector ) { 7651 var className, elem, 7652 i = 0; 7653 7654 className = " " + selector + " "; 7655 while ( ( elem = this[ i++ ] ) ) { 7656 if ( elem.nodeType === 1 && 7657 ( " " + getClass( elem ) + " " ).replace( rclass, " " ) 7658 .indexOf( className ) > -1 7659 ) { 7660 return true; 7661 } 7662 } 7663 7664 return false; 7665 } 7666 } ); 7667 7668 7669 7670 7671 var rreturn = /\r/g, 7672 rspaces = /[\x20\t\r\n\f]+/g; 7673 7674 jQuery.fn.extend( { 7675 val: function( value ) { 7676 var hooks, ret, isFunction, 7677 elem = this[ 0 ]; 7678 7679 if ( !arguments.length ) { 7680 if ( elem ) { 7681 hooks = jQuery.valHooks[ elem.type ] || 7682 jQuery.valHooks[ elem.nodeName.toLowerCase() ]; 7683 7684 if ( hooks && 7685 "get" in hooks && 7686 ( ret = hooks.get( elem, "value" ) ) !== undefined 7687 ) { 7688 return ret; 7689 } 7690 7691 ret = elem.value; 7692 7693 return typeof ret === "string" ? 7694 7695 // Handle most common string cases 7696 ret.replace( rreturn, "" ) : 7697 7698 // Handle cases where value is null/undef or number 7699 ret == null ? "" : ret; 7700 } 7701 7702 return; 7703 } 7704 7705 isFunction = jQuery.isFunction( value ); 7706 7707 return this.each( function( i ) { 7708 var val; 7709 7710 if ( this.nodeType !== 1 ) { 7711 return; 7712 } 7713 7714 if ( isFunction ) { 7715 val = value.call( this, i, jQuery( this ).val() ); 7716 } else { 7717 val = value; 7718 } 7719 7720 // Treat null/undefined as ""; convert numbers to string 7721 if ( val == null ) { 7722 val = ""; 7723 7724 } else if ( typeof val === "number" ) { 7725 val += ""; 7726 7727 } else if ( jQuery.isArray( val ) ) { 7728 val = jQuery.map( val, function( value ) { 7729 return value == null ? "" : value + ""; 7730 } ); 7731 } 7732 7733 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; 7734 7735 // If set returns undefined, fall back to normal setting 7736 if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) { 7737 this.value = val; 7738 } 7739 } ); 7740 } 7741 } ); 7742 7743 jQuery.extend( { 7744 valHooks: { 7745 option: { 7746 get: function( elem ) { 7747 7748 var val = jQuery.find.attr( elem, "value" ); 7749 return val != null ? 7750 val : 7751 7752 // Support: IE10-11+ 7753 // option.text throws exceptions (#14686, #14858) 7754 // Strip and collapse whitespace 7755 // https://html.spec.whatwg.org/#strip-and-collapse-whitespace 7756 jQuery.trim( jQuery.text( elem ) ).replace( rspaces, " " ); 7757 } 7758 }, 7759 select: { 7760 get: function( elem ) { 7761 var value, option, 7762 options = elem.options, 7763 index = elem.selectedIndex, 7764 one = elem.type === "select-one" || index < 0, 7765 values = one ? null : [], 7766 max = one ? index + 1 : options.length, 7767 i = index < 0 ? 7768 max : 7769 one ? index : 0; 7770 7771 // Loop through all the selected options 7772 for ( ; i < max; i++ ) { 7773 option = options[ i ]; 7774 7775 // IE8-9 doesn't update selected after form reset (#2551) 7776 if ( ( option.selected || i === index ) && 7777 7778 // Don't return options that are disabled or in a disabled optgroup 7779 ( support.optDisabled ? 7780 !option.disabled : option.getAttribute( "disabled" ) === null ) && 7781 ( !option.parentNode.disabled || 7782 !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) { 7783 7784 // Get the specific value for the option 7785 value = jQuery( option ).val(); 7786 7787 // We don't need an array for one selects 7788 if ( one ) { 7789 return value; 7790 } 7791 7792 // Multi-Selects return an array 7793 values.push( value ); 7794 } 7795 } 7796 7797 return values; 7798 }, 7799 7800 set: function( elem, value ) { 7801 var optionSet, option, 7802 options = elem.options, 7803 values = jQuery.makeArray( value ), 7804 i = options.length; 7805 7806 while ( i-- ) { 7807 option = options[ i ]; 7808 if ( option.selected = 7809 jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 7810 ) { 7811 optionSet = true; 7812 } 7813 } 7814 7815 // Force browsers to behave consistently when non-matching value is set 7816 if ( !optionSet ) { 7817 elem.selectedIndex = -1; 7818 } 7819 return values; 7820 } 7821 } 7822 } 7823 } ); 7824 7825 // Radios and checkboxes getter/setter 7826 jQuery.each( [ "radio", "checkbox" ], function() { 7827 jQuery.valHooks[ this ] = { 7828 set: function( elem, value ) { 7829 if ( jQuery.isArray( value ) ) { 7830 return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 ); 7831 } 7832 } 7833 }; 7834 if ( !support.checkOn ) { 7835 jQuery.valHooks[ this ].get = function( elem ) { 7836 return elem.getAttribute( "value" ) === null ? "on" : elem.value; 7837 }; 7838 } 7839 } ); 7840 7841 7842 7843 7844 // Return jQuery for attributes-only inclusion 7845 7846 7847 var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/; 7848 7849 jQuery.extend( jQuery.event, { 7850 7851 trigger: function( event, data, elem, onlyHandlers ) { 7852 7853 var i, cur, tmp, bubbleType, ontype, handle, special, 7854 eventPath = [ elem || document ], 7855 type = hasOwn.call( event, "type" ) ? event.type : event, 7856 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : []; 7857 7858 cur = tmp = elem = elem || document; 7859 7860 // Don't do events on text and comment nodes 7861 if ( elem.nodeType === 3 || elem.nodeType === 8 ) { 7862 return; 7863 } 7864 7865 // focus/blur morphs to focusin/out; ensure we're not firing them right now 7866 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { 7867 return; 7868 } 7869 7870 if ( type.indexOf( "." ) > -1 ) { 7871 7872 // Namespaced trigger; create a regexp to match event type in handle() 7873 namespaces = type.split( "." ); 7874 type = namespaces.shift(); 7875 namespaces.sort(); 7876 } 7877 ontype = type.indexOf( ":" ) < 0 && "on" + type; 7878 7879 // Caller can pass in a jQuery.Event object, Object, or just an event type string 7880 event = event[ jQuery.expando ] ? 7881 event : 7882 new jQuery.Event( type, typeof event === "object" && event ); 7883 7884 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) 7885 event.isTrigger = onlyHandlers ? 2 : 3; 7886 event.namespace = namespaces.join( "." ); 7887 event.rnamespace = event.namespace ? 7888 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) : 7889 null; 7890 7891 // Clean up the event in case it is being reused 7892 event.result = undefined; 7893 if ( !event.target ) { 7894 event.target = elem; 7895 } 7896 7897 // Clone any incoming data and prepend the event, creating the handler arg list 7898 data = data == null ? 7899 [ event ] : 7900 jQuery.makeArray( data, [ event ] ); 7901 7902 // Allow special events to draw outside the lines 7903 special = jQuery.event.special[ type ] || {}; 7904 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { 7905 return; 7906 } 7907 7908 // Determine event propagation path in advance, per W3C events spec (#9951) 7909 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) 7910 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { 7911 7912 bubbleType = special.delegateType || type; 7913 if ( !rfocusMorph.test( bubbleType + type ) ) { 7914 cur = cur.parentNode; 7915 } 7916 for ( ; cur; cur = cur.parentNode ) { 7917 eventPath.push( cur ); 7918 tmp = cur; 7919 } 7920 7921 // Only add window if we got to document (e.g., not plain obj or detached DOM) 7922 if ( tmp === ( elem.ownerDocument || document ) ) { 7923 eventPath.push( tmp.defaultView || tmp.parentWindow || window ); 7924 } 7925 } 7926 7927 // Fire handlers on the event path 7928 i = 0; 7929 while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) { 7930 7931 event.type = i > 1 ? 7932 bubbleType : 7933 special.bindType || type; 7934 7935 // jQuery handler 7936 handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] && 7937 dataPriv.get( cur, "handle" ); 7938 if ( handle ) { 7939 handle.apply( cur, data ); 7940 } 7941 7942 // Native handler 7943 handle = ontype && cur[ ontype ]; 7944 if ( handle && handle.apply && acceptData( cur ) ) { 7945 event.result = handle.apply( cur, data ); 7946 if ( event.result === false ) { 7947 event.preventDefault(); 7948 } 7949 } 7950 } 7951 event.type = type; 7952 7953 // If nobody prevented the default action, do it now 7954 if ( !onlyHandlers && !event.isDefaultPrevented() ) { 7955 7956 if ( ( !special._default || 7957 special._default.apply( eventPath.pop(), data ) === false ) && 7958 acceptData( elem ) ) { 7959 7960 // Call a native DOM method on the target with the same name name as the event. 7961 // Don't do default actions on window, that's where global variables be (#6170) 7962 if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) { 7963 7964 // Don't re-trigger an onFOO event when we call its FOO() method 7965 tmp = elem[ ontype ]; 7966 7967 if ( tmp ) { 7968 elem[ ontype ] = null; 7969 } 7970 7971 // Prevent re-triggering of the same event, since we already bubbled it above 7972 jQuery.event.triggered = type; 7973 elem[ type ](); 7974 jQuery.event.triggered = undefined; 7975 7976 if ( tmp ) { 7977 elem[ ontype ] = tmp; 7978 } 7979 } 7980 } 7981 } 7982 7983 return event.result; 7984 }, 7985 7986 // Piggyback on a donor event to simulate a different one 7987 // Used only for `focus(in | out)` events 7988 simulate: function( type, elem, event ) { 7989 var e = jQuery.extend( 7990 new jQuery.Event(), 7991 event, 7992 { 7993 type: type, 7994 isSimulated: true 7995 } 7996 ); 7997 7998 jQuery.event.trigger( e, null, elem ); 7999 } 8000 8001 } ); 8002 8003 jQuery.fn.extend( { 8004 8005 trigger: function( type, data ) { 8006 return this.each( function() { 8007 jQuery.event.trigger( type, data, this ); 8008 } ); 8009 }, 8010 triggerHandler: function( type, data ) { 8011 var elem = this[ 0 ]; 8012 if ( elem ) { 8013 return jQuery.event.trigger( type, data, elem, true ); 8014 } 8015 } 8016 } ); 8017 8018 8019 jQuery.each( ( "blur focus focusin focusout load resize scroll unload click dblclick " + 8020 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + 8021 "change select submit keydown keypress keyup error contextmenu" ).split( " " ), 8022 function( i, name ) { 8023 8024 // Handle event binding 8025 jQuery.fn[ name ] = function( data, fn ) { 8026 return arguments.length > 0 ? 8027 this.on( name, null, data, fn ) : 8028 this.trigger( name ); 8029 }; 8030 } ); 8031 8032 jQuery.fn.extend( { 8033 hover: function( fnOver, fnOut ) { 8034 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); 8035 } 8036 } ); 8037 8038 8039 8040 8041 support.focusin = "onfocusin" in window; 8042 8043 8044 // Support: Firefox 8045 // Firefox doesn't have focus(in | out) events 8046 // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787 8047 // 8048 // Support: Chrome, Safari 8049 // focus(in | out) events fire after focus & blur events, 8050 // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order 8051 // Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857 8052 if ( !support.focusin ) { 8053 jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) { 8054 8055 // Attach a single capturing handler on the document while someone wants focusin/focusout 8056 var handler = function( event ) { 8057 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) ); 8058 }; 8059 8060 jQuery.event.special[ fix ] = { 8061 setup: function() { 8062 var doc = this.ownerDocument || this, 8063 attaches = dataPriv.access( doc, fix ); 8064 8065 if ( !attaches ) { 8066 doc.addEventListener( orig, handler, true ); 8067 } 8068 dataPriv.access( doc, fix, ( attaches || 0 ) + 1 ); 8069 }, 8070 teardown: function() { 8071 var doc = this.ownerDocument || this, 8072 attaches = dataPriv.access( doc, fix ) - 1; 8073 8074 if ( !attaches ) { 8075 doc.removeEventListener( orig, handler, true ); 8076 dataPriv.remove( doc, fix ); 8077 8078 } else { 8079 dataPriv.access( doc, fix, attaches ); 8080 } 8081 } 8082 }; 8083 } ); 8084 } 8085 var location = window.location; 8086 8087 var nonce = jQuery.now(); 8088 8089 var rquery = ( /\?/ ); 8090 8091 8092 8093 // Support: Android 2.3 8094 // Workaround failure to string-cast null input 8095 jQuery.parseJSON = function( data ) { 8096 return JSON.parse( data + "" ); 8097 }; 8098 8099 8100 // Cross-browser xml parsing 8101 jQuery.parseXML = function( data ) { 8102 var xml; 8103 if ( !data || typeof data !== "string" ) { 8104 return null; 8105 } 8106 8107 // Support: IE9 8108 try { 8109 xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" ); 8110 } catch ( e ) { 8111 xml = undefined; 8112 } 8113 8114 if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) { 8115 jQuery.error( "Invalid XML: " + data ); 8116 } 8117 return xml; 8118 }; 8119 8120 8121 var 8122 rhash = /#.*$/, 8123 rts = /([?&])_=[^&]*/, 8124 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, 8125 8126 // #7653, #8125, #8152: local protocol detection 8127 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, 8128 rnoContent = /^(?:GET|HEAD)$/, 8129 rprotocol = /^\/\//, 8130 8131 /* Prefilters 8132 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) 8133 * 2) These are called: 8134 * - BEFORE asking for a transport 8135 * - AFTER param serialization (s.data is a string if s.processData is true) 8136 * 3) key is the dataType 8137 * 4) the catchall symbol "*" can be used 8138 * 5) execution will start with transport dataType and THEN continue down to "*" if needed 8139 */ 8140 prefilters = {}, 8141 8142 /* Transports bindings 8143 * 1) key is the dataType 8144 * 2) the catchall symbol "*" can be used 8145 * 3) selection will start with transport dataType and THEN go to "*" if needed 8146 */ 8147 transports = {}, 8148 8149 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression 8150 allTypes = "*/".concat( "*" ), 8151 8152 // Anchor tag for parsing the document origin 8153 originAnchor = document.createElement( "a" ); 8154 originAnchor.href = location.href; 8155 8156 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport 8157 function addToPrefiltersOrTransports( structure ) { 8158 8159 // dataTypeExpression is optional and defaults to "*" 8160 return function( dataTypeExpression, func ) { 8161 8162 if ( typeof dataTypeExpression !== "string" ) { 8163 func = dataTypeExpression; 8164 dataTypeExpression = "*"; 8165 } 8166 8167 var dataType, 8168 i = 0, 8169 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || []; 8170 8171 if ( jQuery.isFunction( func ) ) { 8172 8173 // For each dataType in the dataTypeExpression 8174 while ( ( dataType = dataTypes[ i++ ] ) ) { 8175 8176 // Prepend if requested 8177 if ( dataType[ 0 ] === "+" ) { 8178 dataType = dataType.slice( 1 ) || "*"; 8179 ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func ); 8180 8181 // Otherwise append 8182 } else { 8183 ( structure[ dataType ] = structure[ dataType ] || [] ).push( func ); 8184 } 8185 } 8186 } 8187 }; 8188 } 8189 8190 // Base inspection function for prefilters and transports 8191 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) { 8192 8193 var inspected = {}, 8194 seekingTransport = ( structure === transports ); 8195 8196 function inspect( dataType ) { 8197 var selected; 8198 inspected[ dataType ] = true; 8199 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { 8200 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); 8201 if ( typeof dataTypeOrTransport === "string" && 8202 !seekingTransport && !inspected[ dataTypeOrTransport ] ) { 8203 8204 options.dataTypes.unshift( dataTypeOrTransport ); 8205 inspect( dataTypeOrTransport ); 8206 return false; 8207 } else if ( seekingTransport ) { 8208 return !( selected = dataTypeOrTransport ); 8209 } 8210 } ); 8211 return selected; 8212 } 8213 8214 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" ); 8215 } 8216 8217 // A special extend for ajax options 8218 // that takes "flat" options (not to be deep extended) 8219 // Fixes #9887 8220 function ajaxExtend( target, src ) { 8221 var key, deep, 8222 flatOptions = jQuery.ajaxSettings.flatOptions || {}; 8223 8224 for ( key in src ) { 8225 if ( src[ key ] !== undefined ) { 8226 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; 8227 } 8228 } 8229 if ( deep ) { 8230 jQuery.extend( true, target, deep ); 8231 } 8232 8233 return target; 8234 } 8235 8236 /* Handles responses to an ajax request: 8237 * - finds the right dataType (mediates between content-type and expected dataType) 8238 * - returns the corresponding response 8239 */ 8240 function ajaxHandleResponses( s, jqXHR, responses ) { 8241 8242 var ct, type, finalDataType, firstDataType, 8243 contents = s.contents, 8244 dataTypes = s.dataTypes; 8245 8246 // Remove auto dataType and get content-type in the process 8247 while ( dataTypes[ 0 ] === "*" ) { 8248 dataTypes.shift(); 8249 if ( ct === undefined ) { 8250 ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" ); 8251 } 8252 } 8253 8254 // Check if we're dealing with a known content-type 8255 if ( ct ) { 8256 for ( type in contents ) { 8257 if ( contents[ type ] && contents[ type ].test( ct ) ) { 8258 dataTypes.unshift( type ); 8259 break; 8260 } 8261 } 8262 } 8263 8264 // Check to see if we have a response for the expected dataType 8265 if ( dataTypes[ 0 ] in responses ) { 8266 finalDataType = dataTypes[ 0 ]; 8267 } else { 8268 8269 // Try convertible dataTypes 8270 for ( type in responses ) { 8271 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) { 8272 finalDataType = type; 8273 break; 8274 } 8275 if ( !firstDataType ) { 8276 firstDataType = type; 8277 } 8278 } 8279 8280 // Or just use first one 8281 finalDataType = finalDataType || firstDataType; 8282 } 8283 8284 // If we found a dataType 8285 // We add the dataType to the list if needed 8286 // and return the corresponding response 8287 if ( finalDataType ) { 8288 if ( finalDataType !== dataTypes[ 0 ] ) { 8289 dataTypes.unshift( finalDataType ); 8290 } 8291 return responses[ finalDataType ]; 8292 } 8293 } 8294 8295 /* Chain conversions given the request and the original response 8296 * Also sets the responseXXX fields on the jqXHR instance 8297 */ 8298 function ajaxConvert( s, response, jqXHR, isSuccess ) { 8299 var conv2, current, conv, tmp, prev, 8300 converters = {}, 8301 8302 // Work with a copy of dataTypes in case we need to modify it for conversion 8303 dataTypes = s.dataTypes.slice(); 8304 8305 // Create converters map with lowercased keys 8306 if ( dataTypes[ 1 ] ) { 8307 for ( conv in s.converters ) { 8308 converters[ conv.toLowerCase() ] = s.converters[ conv ]; 8309 } 8310 } 8311 8312 current = dataTypes.shift(); 8313 8314 // Convert to each sequential dataType 8315 while ( current ) { 8316 8317 if ( s.responseFields[ current ] ) { 8318 jqXHR[ s.responseFields[ current ] ] = response; 8319 } 8320 8321 // Apply the dataFilter if provided 8322 if ( !prev && isSuccess && s.dataFilter ) { 8323 response = s.dataFilter( response, s.dataType ); 8324 } 8325 8326 prev = current; 8327 current = dataTypes.shift(); 8328 8329 if ( current ) { 8330 8331 // There's only work to do if current dataType is non-auto 8332 if ( current === "*" ) { 8333 8334 current = prev; 8335 8336 // Convert response if prev dataType is non-auto and differs from current 8337 } else if ( prev !== "*" && prev !== current ) { 8338 8339 // Seek a direct converter 8340 conv = converters[ prev + " " + current ] || converters[ "* " + current ]; 8341 8342 // If none found, seek a pair 8343 if ( !conv ) { 8344 for ( conv2 in converters ) { 8345 8346 // If conv2 outputs current 8347 tmp = conv2.split( " " ); 8348 if ( tmp[ 1 ] === current ) { 8349 8350 // If prev can be converted to accepted input 8351 conv = converters[ prev + " " + tmp[ 0 ] ] || 8352 converters[ "* " + tmp[ 0 ] ]; 8353 if ( conv ) { 8354 8355 // Condense equivalence converters 8356 if ( conv === true ) { 8357 conv = converters[ conv2 ]; 8358 8359 // Otherwise, insert the intermediate dataType 8360 } else if ( converters[ conv2 ] !== true ) { 8361 current = tmp[ 0 ]; 8362 dataTypes.unshift( tmp[ 1 ] ); 8363 } 8364 break; 8365 } 8366 } 8367 } 8368 } 8369 8370 // Apply converter (if not an equivalence) 8371 if ( conv !== true ) { 8372 8373 // Unless errors are allowed to bubble, catch and return them 8374 if ( conv && s.throws ) { 8375 response = conv( response ); 8376 } else { 8377 try { 8378 response = conv( response ); 8379 } catch ( e ) { 8380 return { 8381 state: "parsererror", 8382 error: conv ? e : "No conversion from " + prev + " to " + current 8383 }; 8384 } 8385 } 8386 } 8387 } 8388 } 8389 } 8390 8391 return { state: "success", data: response }; 8392 } 8393 8394 jQuery.extend( { 8395 8396 // Counter for holding the number of active queries 8397 active: 0, 8398 8399 // Last-Modified header cache for next request 8400 lastModified: {}, 8401 etag: {}, 8402 8403 ajaxSettings: { 8404 url: location.href, 8405 type: "GET", 8406 isLocal: rlocalProtocol.test( location.protocol ), 8407 global: true, 8408 processData: true, 8409 async: true, 8410 contentType: "application/x-www-form-urlencoded; charset=UTF-8", 8411 /* 8412 timeout: 0, 8413 data: null, 8414 dataType: null, 8415 username: null, 8416 password: null, 8417 cache: null, 8418 throws: false, 8419 traditional: false, 8420 headers: {}, 8421 */ 8422 8423 accepts: { 8424 "*": allTypes, 8425 text: "text/plain", 8426 html: "text/html", 8427 xml: "application/xml, text/xml", 8428 json: "application/json, text/javascript" 8429 }, 8430 8431 contents: { 8432 xml: /\bxml\b/, 8433 html: /\bhtml/, 8434 json: /\bjson\b/ 8435 }, 8436 8437 responseFields: { 8438 xml: "responseXML", 8439 text: "responseText", 8440 json: "responseJSON" 8441 }, 8442 8443 // Data converters 8444 // Keys separate source (or catchall "*") and destination types with a single space 8445 converters: { 8446 8447 // Convert anything to text 8448 "* text": String, 8449 8450 // Text to html (true = no transformation) 8451 "text html": true, 8452 8453 // Evaluate text as a json expression 8454 "text json": jQuery.parseJSON, 8455 8456 // Parse text as xml 8457 "text xml": jQuery.parseXML 8458 }, 8459 8460 // For options that shouldn't be deep extended: 8461 // you can add your own custom options here if 8462 // and when you create one that shouldn't be 8463 // deep extended (see ajaxExtend) 8464 flatOptions: { 8465 url: true, 8466 context: true 8467 } 8468 }, 8469 8470 // Creates a full fledged settings object into target 8471 // with both ajaxSettings and settings fields. 8472 // If target is omitted, writes into ajaxSettings. 8473 ajaxSetup: function( target, settings ) { 8474 return settings ? 8475 8476 // Building a settings object 8477 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) : 8478 8479 // Extending ajaxSettings 8480 ajaxExtend( jQuery.ajaxSettings, target ); 8481 }, 8482 8483 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), 8484 ajaxTransport: addToPrefiltersOrTransports( transports ), 8485 8486 // Main method 8487 ajax: function( url, options ) { 8488 8489 // If url is an object, simulate pre-1.5 signature 8490 if ( typeof url === "object" ) { 8491 options = url; 8492 url = undefined; 8493 } 8494 8495 // Force options to be an object 8496 options = options || {}; 8497 8498 var transport, 8499 8500 // URL without anti-cache param 8501 cacheURL, 8502 8503 // Response headers 8504 responseHeadersString, 8505 responseHeaders, 8506 8507 // timeout handle 8508 timeoutTimer, 8509 8510 // Url cleanup var 8511 urlAnchor, 8512 8513 // To know if global events are to be dispatched 8514 fireGlobals, 8515 8516 // Loop variable 8517 i, 8518 8519 // Create the final options object 8520 s = jQuery.ajaxSetup( {}, options ), 8521 8522 // Callbacks context 8523 callbackContext = s.context || s, 8524 8525 // Context for global events is callbackContext if it is a DOM node or jQuery collection 8526 globalEventContext = s.context && 8527 ( callbackContext.nodeType || callbackContext.jquery ) ? 8528 jQuery( callbackContext ) : 8529 jQuery.event, 8530 8531 // Deferreds 8532 deferred = jQuery.Deferred(), 8533 completeDeferred = jQuery.Callbacks( "once memory" ), 8534 8535 // Status-dependent callbacks 8536 statusCode = s.statusCode || {}, 8537 8538 // Headers (they are sent all at once) 8539 requestHeaders = {}, 8540 requestHeadersNames = {}, 8541 8542 // The jqXHR state 8543 state = 0, 8544 8545 // Default abort message 8546 strAbort = "canceled", 8547 8548 // Fake xhr 8549 jqXHR = { 8550 readyState: 0, 8551 8552 // Builds headers hashtable if needed 8553 getResponseHeader: function( key ) { 8554 var match; 8555 if ( state === 2 ) { 8556 if ( !responseHeaders ) { 8557 responseHeaders = {}; 8558 while ( ( match = rheaders.exec( responseHeadersString ) ) ) { 8559 responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ]; 8560 } 8561 } 8562 match = responseHeaders[ key.toLowerCase() ]; 8563 } 8564 return match == null ? null : match; 8565 }, 8566 8567 // Raw string 8568 getAllResponseHeaders: function() { 8569 return state === 2 ? responseHeadersString : null; 8570 }, 8571 8572 // Caches the header 8573 setRequestHeader: function( name, value ) { 8574 var lname = name.toLowerCase(); 8575 if ( !state ) { 8576 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name; 8577 requestHeaders[ name ] = value; 8578 } 8579 return this; 8580 }, 8581 8582 // Overrides response content-type header 8583 overrideMimeType: function( type ) { 8584 if ( !state ) { 8585 s.mimeType = type; 8586 } 8587 return this; 8588 }, 8589 8590 // Status-dependent callbacks 8591 statusCode: function( map ) { 8592 var code; 8593 if ( map ) { 8594 if ( state < 2 ) { 8595 for ( code in map ) { 8596 8597 // Lazy-add the new callback in a way that preserves old ones 8598 statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; 8599 } 8600 } else { 8601 8602 // Execute the appropriate callbacks 8603 jqXHR.always( map[ jqXHR.status ] ); 8604 } 8605 } 8606 return this; 8607 }, 8608 8609 // Cancel the request 8610 abort: function( statusText ) { 8611 var finalText = statusText || strAbort; 8612 if ( transport ) { 8613 transport.abort( finalText ); 8614 } 8615 done( 0, finalText ); 8616 return this; 8617 } 8618 }; 8619 8620 // Attach deferreds 8621 deferred.promise( jqXHR ).complete = completeDeferred.add; 8622 jqXHR.success = jqXHR.done; 8623 jqXHR.error = jqXHR.fail; 8624 8625 // Remove hash character (#7531: and string promotion) 8626 // Add protocol if not provided (prefilters might expect it) 8627 // Handle falsy url in the settings object (#10093: consistency with old signature) 8628 // We also use the url parameter if available 8629 s.url = ( ( url || s.url || location.href ) + "" ).replace( rhash, "" ) 8630 .replace( rprotocol, location.protocol + "//" ); 8631 8632 // Alias method option to type as per ticket #12004 8633 s.type = options.method || options.type || s.method || s.type; 8634 8635 // Extract dataTypes list 8636 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ]; 8637 8638 // A cross-domain request is in order when the origin doesn't match the current origin. 8639 if ( s.crossDomain == null ) { 8640 urlAnchor = document.createElement( "a" ); 8641 8642 // Support: IE8-11+ 8643 // IE throws exception if url is malformed, e.g. http://example.com:80x/ 8644 try { 8645 urlAnchor.href = s.url; 8646 8647 // Support: IE8-11+ 8648 // Anchor's host property isn't correctly set when s.url is relative 8649 urlAnchor.href = urlAnchor.href; 8650 s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !== 8651 urlAnchor.protocol + "//" + urlAnchor.host; 8652 } catch ( e ) { 8653 8654 // If there is an error parsing the URL, assume it is crossDomain, 8655 // it can be rejected by the transport if it is invalid 8656 s.crossDomain = true; 8657 } 8658 } 8659 8660 // Convert data if not already a string 8661 if ( s.data && s.processData && typeof s.data !== "string" ) { 8662 s.data = jQuery.param( s.data, s.traditional ); 8663 } 8664 8665 // Apply prefilters 8666 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); 8667 8668 // If request was aborted inside a prefilter, stop there 8669 if ( state === 2 ) { 8670 return jqXHR; 8671 } 8672 8673 // We can fire global events as of now if asked to 8674 // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118) 8675 fireGlobals = jQuery.event && s.global; 8676 8677 // Watch for a new set of requests 8678 if ( fireGlobals && jQuery.active++ === 0 ) { 8679 jQuery.event.trigger( "ajaxStart" ); 8680 } 8681 8682 // Uppercase the type 8683 s.type = s.type.toUpperCase(); 8684 8685 // Determine if request has content 8686 s.hasContent = !rnoContent.test( s.type ); 8687 8688 // Save the URL in case we're toying with the If-Modified-Since 8689 // and/or If-None-Match header later on 8690 cacheURL = s.url; 8691 8692 // More options handling for requests with no content 8693 if ( !s.hasContent ) { 8694 8695 // If data is available, append data to url 8696 if ( s.data ) { 8697 cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data ); 8698 8699 // #9682: remove data so that it's not used in an eventual retry 8700 delete s.data; 8701 } 8702 8703 // Add anti-cache in url if needed 8704 if ( s.cache === false ) { 8705 s.url = rts.test( cacheURL ) ? 8706 8707 // If there is already a '_' parameter, set its value 8708 cacheURL.replace( rts, "$1_=" + nonce++ ) : 8709 8710 // Otherwise add one to the end 8711 cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++; 8712 } 8713 } 8714 8715 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. 8716 if ( s.ifModified ) { 8717 if ( jQuery.lastModified[ cacheURL ] ) { 8718 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] ); 8719 } 8720 if ( jQuery.etag[ cacheURL ] ) { 8721 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] ); 8722 } 8723 } 8724 8725 // Set the correct header, if data is being sent 8726 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { 8727 jqXHR.setRequestHeader( "Content-Type", s.contentType ); 8728 } 8729 8730 // Set the Accepts header for the server, depending on the dataType 8731 jqXHR.setRequestHeader( 8732 "Accept", 8733 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ? 8734 s.accepts[ s.dataTypes[ 0 ] ] + 8735 ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : 8736 s.accepts[ "*" ] 8737 ); 8738 8739 // Check for headers option 8740 for ( i in s.headers ) { 8741 jqXHR.setRequestHeader( i, s.headers[ i ] ); 8742 } 8743 8744 // Allow custom headers/mimetypes and early abort 8745 if ( s.beforeSend && 8746 ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { 8747 8748 // Abort if not done already and return 8749 return jqXHR.abort(); 8750 } 8751 8752 // Aborting is no longer a cancellation 8753 strAbort = "abort"; 8754 8755 // Install callbacks on deferreds 8756 for ( i in { success: 1, error: 1, complete: 1 } ) { 8757 jqXHR[ i ]( s[ i ] ); 8758 } 8759 8760 // Get transport 8761 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); 8762 8763 // If no transport, we auto-abort 8764 if ( !transport ) { 8765 done( -1, "No Transport" ); 8766 } else { 8767 jqXHR.readyState = 1; 8768 8769 // Send global event 8770 if ( fireGlobals ) { 8771 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); 8772 } 8773 8774 // If request was aborted inside ajaxSend, stop there 8775 if ( state === 2 ) { 8776 return jqXHR; 8777 } 8778 8779 // Timeout 8780 if ( s.async && s.timeout > 0 ) { 8781 timeoutTimer = window.setTimeout( function() { 8782 jqXHR.abort( "timeout" ); 8783 }, s.timeout ); 8784 } 8785 8786 try { 8787 state = 1; 8788 transport.send( requestHeaders, done ); 8789 } catch ( e ) { 8790 8791 // Propagate exception as error if not done 8792 if ( state < 2 ) { 8793 done( -1, e ); 8794 8795 // Simply rethrow otherwise 8796 } else { 8797 throw e; 8798 } 8799 } 8800 } 8801 8802 // Callback for when everything is done 8803 function done( status, nativeStatusText, responses, headers ) { 8804 var isSuccess, success, error, response, modified, 8805 statusText = nativeStatusText; 8806 8807 // Called once 8808 if ( state === 2 ) { 8809 return; 8810 } 8811 8812 // State is "done" now 8813 state = 2; 8814 8815 // Clear timeout if it exists 8816 if ( timeoutTimer ) { 8817 window.clearTimeout( timeoutTimer ); 8818 } 8819 8820 // Dereference transport for early garbage collection 8821 // (no matter how long the jqXHR object will be used) 8822 transport = undefined; 8823 8824 // Cache response headers 8825 responseHeadersString = headers || ""; 8826 8827 // Set readyState 8828 jqXHR.readyState = status > 0 ? 4 : 0; 8829 8830 // Determine if successful 8831 isSuccess = status >= 200 && status < 300 || status === 304; 8832 8833 // Get response data 8834 if ( responses ) { 8835 response = ajaxHandleResponses( s, jqXHR, responses ); 8836 } 8837 8838 // Convert no matter what (that way responseXXX fields are always set) 8839 response = ajaxConvert( s, response, jqXHR, isSuccess ); 8840 8841 // If successful, handle type chaining 8842 if ( isSuccess ) { 8843 8844 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. 8845 if ( s.ifModified ) { 8846 modified = jqXHR.getResponseHeader( "Last-Modified" ); 8847 if ( modified ) { 8848 jQuery.lastModified[ cacheURL ] = modified; 8849 } 8850 modified = jqXHR.getResponseHeader( "etag" ); 8851 if ( modified ) { 8852 jQuery.etag[ cacheURL ] = modified; 8853 } 8854 } 8855 8856 // if no content 8857 if ( status === 204 || s.type === "HEAD" ) { 8858 statusText = "nocontent"; 8859 8860 // if not modified 8861 } else if ( status === 304 ) { 8862 statusText = "notmodified"; 8863 8864 // If we have data, let's convert it 8865 } else { 8866 statusText = response.state; 8867 success = response.data; 8868 error = response.error; 8869 isSuccess = !error; 8870 } 8871 } else { 8872 8873 // Extract error from statusText and normalize for non-aborts 8874 error = statusText; 8875 if ( status || !statusText ) { 8876 statusText = "error"; 8877 if ( status < 0 ) { 8878 status = 0; 8879 } 8880 } 8881 } 8882 8883 // Set data for the fake xhr object 8884 jqXHR.status = status; 8885 jqXHR.statusText = ( nativeStatusText || statusText ) + ""; 8886 8887 // Success/Error 8888 if ( isSuccess ) { 8889 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); 8890 } else { 8891 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); 8892 } 8893 8894 // Status-dependent callbacks 8895 jqXHR.statusCode( statusCode ); 8896 statusCode = undefined; 8897 8898 if ( fireGlobals ) { 8899 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError", 8900 [ jqXHR, s, isSuccess ? success : error ] ); 8901 } 8902 8903 // Complete 8904 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); 8905 8906 if ( fireGlobals ) { 8907 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); 8908 8909 // Handle the global AJAX counter 8910 if ( !( --jQuery.active ) ) { 8911 jQuery.event.trigger( "ajaxStop" ); 8912 } 8913 } 8914 } 8915 8916 return jqXHR; 8917 }, 8918 8919 getJSON: function( url, data, callback ) { 8920 return jQuery.get( url, data, callback, "json" ); 8921 }, 8922 8923 getScript: function( url, callback ) { 8924 return jQuery.get( url, undefined, callback, "script" ); 8925 } 8926 } ); 8927 8928 jQuery.each( [ "get", "post" ], function( i, method ) { 8929 jQuery[ method ] = function( url, data, callback, type ) { 8930 8931 // Shift arguments if data argument was omitted 8932 if ( jQuery.isFunction( data ) ) { 8933 type = type || callback; 8934 callback = data; 8935 data = undefined; 8936 } 8937 8938 // The url can be an options object (which then must have .url) 8939 return jQuery.ajax( jQuery.extend( { 8940 url: url, 8941 type: method, 8942 dataType: type, 8943 data: data, 8944 success: callback 8945 }, jQuery.isPlainObject( url ) && url ) ); 8946 }; 8947 } ); 8948 8949 8950 jQuery._evalUrl = function( url ) { 8951 return jQuery.ajax( { 8952 url: url, 8953 8954 // Make this explicit, since user can override this through ajaxSetup (#11264) 8955 type: "GET", 8956 dataType: "script", 8957 async: false, 8958 global: false, 8959 "throws": true 8960 } ); 8961 }; 8962 8963 8964 jQuery.fn.extend( { 8965 wrapAll: function( html ) { 8966 var wrap; 8967 8968 if ( jQuery.isFunction( html ) ) { 8969 return this.each( function( i ) { 8970 jQuery( this ).wrapAll( html.call( this, i ) ); 8971 } ); 8972 } 8973 8974 if ( this[ 0 ] ) { 8975 8976 // The elements to wrap the target around 8977 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); 8978 8979 if ( this[ 0 ].parentNode ) { 8980 wrap.insertBefore( this[ 0 ] ); 8981 } 8982 8983 wrap.map( function() { 8984 var elem = this; 8985 8986 while ( elem.firstElementChild ) { 8987 elem = elem.firstElementChild; 8988 } 8989 8990 return elem; 8991 } ).append( this ); 8992 } 8993 8994 return this; 8995 }, 8996 8997 wrapInner: function( html ) { 8998 if ( jQuery.isFunction( html ) ) { 8999 return this.each( function( i ) { 9000 jQuery( this ).wrapInner( html.call( this, i ) ); 9001 } ); 9002 } 9003 9004 return this.each( function() { 9005 var self = jQuery( this ), 9006 contents = self.contents(); 9007 9008 if ( contents.length ) { 9009 contents.wrapAll( html ); 9010 9011 } else { 9012 self.append( html ); 9013 } 9014 } ); 9015 }, 9016 9017 wrap: function( html ) { 9018 var isFunction = jQuery.isFunction( html ); 9019 9020 return this.each( function( i ) { 9021 jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html ); 9022 } ); 9023 }, 9024 9025 unwrap: function() { 9026 return this.parent().each( function() { 9027 if ( !jQuery.nodeName( this, "body" ) ) { 9028 jQuery( this ).replaceWith( this.childNodes ); 9029 } 9030 } ).end(); 9031 } 9032 } ); 9033 9034 9035 jQuery.expr.filters.hidden = function( elem ) { 9036 return !jQuery.expr.filters.visible( elem ); 9037 }; 9038 jQuery.expr.filters.visible = function( elem ) { 9039 9040 // Support: Opera <= 12.12 9041 // Opera reports offsetWidths and offsetHeights less than zero on some elements 9042 // Use OR instead of AND as the element is not visible if either is true 9043 // See tickets #10406 and #13132 9044 return elem.offsetWidth > 0 || elem.offsetHeight > 0 || elem.getClientRects().length > 0; 9045 }; 9046 9047 9048 9049 9050 var r20 = /%20/g, 9051 rbracket = /\[\]$/, 9052 rCRLF = /\r?\n/g, 9053 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, 9054 rsubmittable = /^(?:input|select|textarea|keygen)/i; 9055 9056 function buildParams( prefix, obj, traditional, add ) { 9057 var name; 9058 9059 if ( jQuery.isArray( obj ) ) { 9060 9061 // Serialize array item. 9062 jQuery.each( obj, function( i, v ) { 9063 if ( traditional || rbracket.test( prefix ) ) { 9064 9065 // Treat each array item as a scalar. 9066 add( prefix, v ); 9067 9068 } else { 9069 9070 // Item is non-scalar (array or object), encode its numeric index. 9071 buildParams( 9072 prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]", 9073 v, 9074 traditional, 9075 add 9076 ); 9077 } 9078 } ); 9079 9080 } else if ( !traditional && jQuery.type( obj ) === "object" ) { 9081 9082 // Serialize object item. 9083 for ( name in obj ) { 9084 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); 9085 } 9086 9087 } else { 9088 9089 // Serialize scalar item. 9090 add( prefix, obj ); 9091 } 9092 } 9093 9094 // Serialize an array of form elements or a set of 9095 // key/values into a query string 9096 jQuery.param = function( a, traditional ) { 9097 var prefix, 9098 s = [], 9099 add = function( key, value ) { 9100 9101 // If value is a function, invoke it and return its value 9102 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value ); 9103 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); 9104 }; 9105 9106 // Set traditional to true for jQuery <= 1.3.2 behavior. 9107 if ( traditional === undefined ) { 9108 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional; 9109 } 9110 9111 // If an array was passed in, assume that it is an array of form elements. 9112 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { 9113 9114 // Serialize the form elements 9115 jQuery.each( a, function() { 9116 add( this.name, this.value ); 9117 } ); 9118 9119 } else { 9120 9121 // If traditional, encode the "old" way (the way 1.3.2 or older 9122 // did it), otherwise encode params recursively. 9123 for ( prefix in a ) { 9124 buildParams( prefix, a[ prefix ], traditional, add ); 9125 } 9126 } 9127 9128 // Return the resulting serialization 9129 return s.join( "&" ).replace( r20, "+" ); 9130 }; 9131 9132 jQuery.fn.extend( { 9133 serialize: function() { 9134 return jQuery.param( this.serializeArray() ); 9135 }, 9136 serializeArray: function() { 9137 return this.map( function() { 9138 9139 // Can add propHook for "elements" to filter or add form elements 9140 var elements = jQuery.prop( this, "elements" ); 9141 return elements ? jQuery.makeArray( elements ) : this; 9142 } ) 9143 .filter( function() { 9144 var type = this.type; 9145 9146 // Use .is( ":disabled" ) so that fieldset[disabled] works 9147 return this.name && !jQuery( this ).is( ":disabled" ) && 9148 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && 9149 ( this.checked || !rcheckableType.test( type ) ); 9150 } ) 9151 .map( function( i, elem ) { 9152 var val = jQuery( this ).val(); 9153 9154 return val == null ? 9155 null : 9156 jQuery.isArray( val ) ? 9157 jQuery.map( val, function( val ) { 9158 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; 9159 } ) : 9160 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; 9161 } ).get(); 9162 } 9163 } ); 9164 9165 9166 jQuery.ajaxSettings.xhr = function() { 9167 try { 9168 return new window.XMLHttpRequest(); 9169 } catch ( e ) {} 9170 }; 9171 9172 var xhrSuccessStatus = { 9173 9174 // File protocol always yields status code 0, assume 200 9175 0: 200, 9176 9177 // Support: IE9 9178 // #1450: sometimes IE returns 1223 when it should be 204 9179 1223: 204 9180 }, 9181 xhrSupported = jQuery.ajaxSettings.xhr(); 9182 9183 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); 9184 support.ajax = xhrSupported = !!xhrSupported; 9185 9186 jQuery.ajaxTransport( function( options ) { 9187 var callback, errorCallback; 9188 9189 // Cross domain only allowed if supported through XMLHttpRequest 9190 if ( support.cors || xhrSupported && !options.crossDomain ) { 9191 return { 9192 send: function( headers, complete ) { 9193 var i, 9194 xhr = options.xhr(); 9195 9196 xhr.open( 9197 options.type, 9198 options.url, 9199 options.async, 9200 options.username, 9201 options.password 9202 ); 9203 9204 // Apply custom fields if provided 9205 if ( options.xhrFields ) { 9206 for ( i in options.xhrFields ) { 9207 xhr[ i ] = options.xhrFields[ i ]; 9208 } 9209 } 9210 9211 // Override mime type if needed 9212 if ( options.mimeType && xhr.overrideMimeType ) { 9213 xhr.overrideMimeType( options.mimeType ); 9214 } 9215 9216 // X-Requested-With header 9217 // For cross-domain requests, seeing as conditions for a preflight are 9218 // akin to a jigsaw puzzle, we simply never set it to be sure. 9219 // (it can always be set on a per-request basis or even using ajaxSetup) 9220 // For same-domain requests, won't change header if already provided. 9221 if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) { 9222 headers[ "X-Requested-With" ] = "XMLHttpRequest"; 9223 } 9224 9225 // Set headers 9226 for ( i in headers ) { 9227 xhr.setRequestHeader( i, headers[ i ] ); 9228 } 9229 9230 // Callback 9231 callback = function( type ) { 9232 return function() { 9233 if ( callback ) { 9234 callback = errorCallback = xhr.onload = 9235 xhr.onerror = xhr.onabort = xhr.onreadystatechange = null; 9236 9237 if ( type === "abort" ) { 9238 xhr.abort(); 9239 } else if ( type === "error" ) { 9240 9241 // Support: IE9 9242 // On a manual native abort, IE9 throws 9243 // errors on any property access that is not readyState 9244 if ( typeof xhr.status !== "number" ) { 9245 complete( 0, "error" ); 9246 } else { 9247 complete( 9248 9249 // File: protocol always yields status 0; see #8605, #14207 9250 xhr.status, 9251 xhr.statusText 9252 ); 9253 } 9254 } else { 9255 complete( 9256 xhrSuccessStatus[ xhr.status ] || xhr.status, 9257 xhr.statusText, 9258 9259 // Support: IE9 only 9260 // IE9 has no XHR2 but throws on binary (trac-11426) 9261 // For XHR2 non-text, let the caller handle it (gh-2498) 9262 ( xhr.responseType || "text" ) !== "text" || 9263 typeof xhr.responseText !== "string" ? 9264 { binary: xhr.response } : 9265 { text: xhr.responseText }, 9266 xhr.getAllResponseHeaders() 9267 ); 9268 } 9269 } 9270 }; 9271 }; 9272 9273 // Listen to events 9274 xhr.onload = callback(); 9275 errorCallback = xhr.onerror = callback( "error" ); 9276 9277 // Support: IE9 9278 // Use onreadystatechange to replace onabort 9279 // to handle uncaught aborts 9280 if ( xhr.onabort !== undefined ) { 9281 xhr.onabort = errorCallback; 9282 } else { 9283 xhr.onreadystatechange = function() { 9284 9285 // Check readyState before timeout as it changes 9286 if ( xhr.readyState === 4 ) { 9287 9288 // Allow onerror to be called first, 9289 // but that will not handle a native abort 9290 // Also, save errorCallback to a variable 9291 // as xhr.onerror cannot be accessed 9292 window.setTimeout( function() { 9293 if ( callback ) { 9294 errorCallback(); 9295 } 9296 } ); 9297 } 9298 }; 9299 } 9300 9301 // Create the abort callback 9302 callback = callback( "abort" ); 9303 9304 try { 9305 9306 // Do send the request (this may raise an exception) 9307 xhr.send( options.hasContent && options.data || null ); 9308 } catch ( e ) { 9309 9310 // #14683: Only rethrow if this hasn't been notified as an error yet 9311 if ( callback ) { 9312 throw e; 9313 } 9314 } 9315 }, 9316 9317 abort: function() { 9318 if ( callback ) { 9319 callback(); 9320 } 9321 } 9322 }; 9323 } 9324 } ); 9325 9326 9327 9328 9329 // Install script dataType 9330 jQuery.ajaxSetup( { 9331 accepts: { 9332 script: "text/javascript, application/javascript, " + 9333 "application/ecmascript, application/x-ecmascript" 9334 }, 9335 contents: { 9336 script: /\b(?:java|ecma)script\b/ 9337 }, 9338 converters: { 9339 "text script": function( text ) { 9340 jQuery.globalEval( text ); 9341 return text; 9342 } 9343 } 9344 } ); 9345 9346 // Handle cache's special case and crossDomain 9347 jQuery.ajaxPrefilter( "script", function( s ) { 9348 if ( s.cache === undefined ) { 9349 s.cache = false; 9350 } 9351 if ( s.crossDomain ) { 9352 s.type = "GET"; 9353 } 9354 } ); 9355 9356 // Bind script tag hack transport 9357 jQuery.ajaxTransport( "script", function( s ) { 9358 9359 // This transport only deals with cross domain requests 9360 if ( s.crossDomain ) { 9361 var script, callback; 9362 return { 9363 send: function( _, complete ) { 9364 script = jQuery( "<script>" ).prop( { 9365 charset: s.scriptCharset, 9366 src: s.url 9367 } ).on( 9368 "load error", 9369 callback = function( evt ) { 9370 script.remove(); 9371 callback = null; 9372 if ( evt ) { 9373 complete( evt.type === "error" ? 404 : 200, evt.type ); 9374 } 9375 } 9376 ); 9377 9378 // Use native DOM manipulation to avoid our domManip AJAX trickery 9379 document.head.appendChild( script[ 0 ] ); 9380 }, 9381 abort: function() { 9382 if ( callback ) { 9383 callback(); 9384 } 9385 } 9386 }; 9387 } 9388 } ); 9389 9390 9391 9392 9393 var oldCallbacks = [], 9394 rjsonp = /(=)\?(?=&|$)|\?\?/; 9395 9396 // Default jsonp settings 9397 jQuery.ajaxSetup( { 9398 jsonp: "callback", 9399 jsonpCallback: function() { 9400 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); 9401 this[ callback ] = true; 9402 return callback; 9403 } 9404 } ); 9405 9406 // Detect, normalize options and install callbacks for jsonp requests 9407 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { 9408 9409 var callbackName, overwritten, responseContainer, 9410 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? 9411 "url" : 9412 typeof s.data === "string" && 9413 ( s.contentType || "" ) 9414 .indexOf( "application/x-www-form-urlencoded" ) === 0 && 9415 rjsonp.test( s.data ) && "data" 9416 ); 9417 9418 // Handle iff the expected data type is "jsonp" or we have a parameter to set 9419 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { 9420 9421 // Get callback name, remembering preexisting value associated with it 9422 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? 9423 s.jsonpCallback() : 9424 s.jsonpCallback; 9425 9426 // Insert callback into url or form data 9427 if ( jsonProp ) { 9428 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); 9429 } else if ( s.jsonp !== false ) { 9430 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; 9431 } 9432 9433 // Use data converter to retrieve json after script execution 9434 s.converters[ "script json" ] = function() { 9435 if ( !responseContainer ) { 9436 jQuery.error( callbackName + " was not called" ); 9437 } 9438 return responseContainer[ 0 ]; 9439 }; 9440 9441 // Force json dataType 9442 s.dataTypes[ 0 ] = "json"; 9443 9444 // Install callback 9445 overwritten = window[ callbackName ]; 9446 window[ callbackName ] = function() { 9447 responseContainer = arguments; 9448 }; 9449 9450 // Clean-up function (fires after converters) 9451 jqXHR.always( function() { 9452 9453 // If previous value didn't exist - remove it 9454 if ( overwritten === undefined ) { 9455 jQuery( window ).removeProp( callbackName ); 9456 9457 // Otherwise restore preexisting value 9458 } else { 9459 window[ callbackName ] = overwritten; 9460 } 9461 9462 // Save back as free 9463 if ( s[ callbackName ] ) { 9464 9465 // Make sure that re-using the options doesn't screw things around 9466 s.jsonpCallback = originalSettings.jsonpCallback; 9467 9468 // Save the callback name for future use 9469 oldCallbacks.push( callbackName ); 9470 } 9471 9472 // Call if it was a function and we have a response 9473 if ( responseContainer && jQuery.isFunction( overwritten ) ) { 9474 overwritten( responseContainer[ 0 ] ); 9475 } 9476 9477 responseContainer = overwritten = undefined; 9478 } ); 9479 9480 // Delegate to script 9481 return "script"; 9482 } 9483 } ); 9484 9485 9486 9487 9488 // Argument "data" should be string of html 9489 // context (optional): If specified, the fragment will be created in this context, 9490 // defaults to document 9491 // keepScripts (optional): If true, will include scripts passed in the html string 9492 jQuery.parseHTML = function( data, context, keepScripts ) { 9493 if ( !data || typeof data !== "string" ) { 9494 return null; 9495 } 9496 if ( typeof context === "boolean" ) { 9497 keepScripts = context; 9498 context = false; 9499 } 9500 context = context || document; 9501 9502 var parsed = rsingleTag.exec( data ), 9503 scripts = !keepScripts && []; 9504 9505 // Single tag 9506 if ( parsed ) { 9507 return [ context.createElement( parsed[ 1 ] ) ]; 9508 } 9509 9510 parsed = buildFragment( [ data ], context, scripts ); 9511 9512 if ( scripts && scripts.length ) { 9513 jQuery( scripts ).remove(); 9514 } 9515 9516 return jQuery.merge( [], parsed.childNodes ); 9517 }; 9518 9519 9520 // Keep a copy of the old load method 9521 var _load = jQuery.fn.load; 9522 9523 /** 9524 * Load a url into a page 9525 */ 9526 jQuery.fn.load = function( url, params, callback ) { 9527 if ( typeof url !== "string" && _load ) { 9528 return _load.apply( this, arguments ); 9529 } 9530 9531 var selector, type, response, 9532 self = this, 9533 off = url.indexOf( " " ); 9534 9535 if ( off > -1 ) { 9536 selector = jQuery.trim( url.slice( off ) ); 9537 url = url.slice( 0, off ); 9538 } 9539 9540 // If it's a function 9541 if ( jQuery.isFunction( params ) ) { 9542 9543 // We assume that it's the callback 9544 callback = params; 9545 params = undefined; 9546 9547 // Otherwise, build a param string 9548 } else if ( params && typeof params === "object" ) { 9549 type = "POST"; 9550 } 9551 9552 // If we have elements to modify, make the request 9553 if ( self.length > 0 ) { 9554 jQuery.ajax( { 9555 url: url, 9556 9557 // If "type" variable is undefined, then "GET" method will be used. 9558 // Make value of this field explicit since 9559 // user can override it through ajaxSetup method 9560 type: type || "GET", 9561 dataType: "html", 9562 data: params 9563 } ).done( function( responseText ) { 9564 9565 // Save response for use in complete callback 9566 response = arguments; 9567 9568 self.html( selector ? 9569 9570 // If a selector was specified, locate the right elements in a dummy div 9571 // Exclude scripts to avoid IE 'Permission Denied' errors 9572 jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) : 9573 9574 // Otherwise use the full result 9575 responseText ); 9576 9577 // If the request succeeds, this function gets "data", "status", "jqXHR" 9578 // but they are ignored because response was set above. 9579 // If it fails, this function gets "jqXHR", "status", "error" 9580 } ).always( callback && function( jqXHR, status ) { 9581 self.each( function() { 9582 callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] ); 9583 } ); 9584 } ); 9585 } 9586 9587 return this; 9588 }; 9589 9590 9591 9592 9593 // Attach a bunch of functions for handling common AJAX events 9594 jQuery.each( [ 9595 "ajaxStart", 9596 "ajaxStop", 9597 "ajaxComplete", 9598 "ajaxError", 9599 "ajaxSuccess", 9600 "ajaxSend" 9601 ], function( i, type ) { 9602 jQuery.fn[ type ] = function( fn ) { 9603 return this.on( type, fn ); 9604 }; 9605 } ); 9606 9607 9608 9609 9610 jQuery.expr.filters.animated = function( elem ) { 9611 return jQuery.grep( jQuery.timers, function( fn ) { 9612 return elem === fn.elem; 9613 } ).length; 9614 }; 9615 9616 9617 9618 9619 /** 9620 * Gets a window from an element 9621 */ 9622 function getWindow( elem ) { 9623 return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView; 9624 } 9625 9626 jQuery.offset = { 9627 setOffset: function( elem, options, i ) { 9628 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, 9629 position = jQuery.css( elem, "position" ), 9630 curElem = jQuery( elem ), 9631 props = {}; 9632 9633 // Set position first, in-case top/left are set even on static elem 9634 if ( position === "static" ) { 9635 elem.style.position = "relative"; 9636 } 9637 9638 curOffset = curElem.offset(); 9639 curCSSTop = jQuery.css( elem, "top" ); 9640 curCSSLeft = jQuery.css( elem, "left" ); 9641 calculatePosition = ( position === "absolute" || position === "fixed" ) && 9642 ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1; 9643 9644 // Need to be able to calculate position if either 9645 // top or left is auto and position is either absolute or fixed 9646 if ( calculatePosition ) { 9647 curPosition = curElem.position(); 9648 curTop = curPosition.top; 9649 curLeft = curPosition.left; 9650 9651 } else { 9652 curTop = parseFloat( curCSSTop ) || 0; 9653 curLeft = parseFloat( curCSSLeft ) || 0; 9654 } 9655 9656 if ( jQuery.isFunction( options ) ) { 9657 9658 // Use jQuery.extend here to allow modification of coordinates argument (gh-1848) 9659 options = options.call( elem, i, jQuery.extend( {}, curOffset ) ); 9660 } 9661 9662 if ( options.top != null ) { 9663 props.top = ( options.top - curOffset.top ) + curTop; 9664 } 9665 if ( options.left != null ) { 9666 props.left = ( options.left - curOffset.left ) + curLeft; 9667 } 9668 9669 if ( "using" in options ) { 9670 options.using.call( elem, props ); 9671 9672 } else { 9673 curElem.css( props ); 9674 } 9675 } 9676 }; 9677 9678 jQuery.fn.extend( { 9679 offset: function( options ) { 9680 if ( arguments.length ) { 9681 return options === undefined ? 9682 this : 9683 this.each( function( i ) { 9684 jQuery.offset.setOffset( this, options, i ); 9685 } ); 9686 } 9687 9688 var docElem, win, 9689 elem = this[ 0 ], 9690 box = { top: 0, left: 0 }, 9691 doc = elem && elem.ownerDocument; 9692 9693 if ( !doc ) { 9694 return; 9695 } 9696 9697 docElem = doc.documentElement; 9698 9699 // Make sure it's not a disconnected DOM node 9700 if ( !jQuery.contains( docElem, elem ) ) { 9701 return box; 9702 } 9703 9704 box = elem.getBoundingClientRect(); 9705 win = getWindow( doc ); 9706 return { 9707 top: box.top + win.pageYOffset - docElem.clientTop, 9708 left: box.left + win.pageXOffset - docElem.clientLeft 9709 }; 9710 }, 9711 9712 position: function() { 9713 if ( !this[ 0 ] ) { 9714 return; 9715 } 9716 9717 var offsetParent, offset, 9718 elem = this[ 0 ], 9719 parentOffset = { top: 0, left: 0 }; 9720 9721 // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, 9722 // because it is its only offset parent 9723 if ( jQuery.css( elem, "position" ) === "fixed" ) { 9724 9725 // Assume getBoundingClientRect is there when computed position is fixed 9726 offset = elem.getBoundingClientRect(); 9727 9728 } else { 9729 9730 // Get *real* offsetParent 9731 offsetParent = this.offsetParent(); 9732 9733 // Get correct offsets 9734 offset = this.offset(); 9735 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) { 9736 parentOffset = offsetParent.offset(); 9737 } 9738 9739 // Add offsetParent borders 9740 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ); 9741 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true ); 9742 } 9743 9744 // Subtract parent offsets and element margins 9745 return { 9746 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ), 9747 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true ) 9748 }; 9749 }, 9750 9751 // This method will return documentElement in the following cases: 9752 // 1) For the element inside the iframe without offsetParent, this method will return 9753 // documentElement of the parent window 9754 // 2) For the hidden or detached element 9755 // 3) For body or html element, i.e. in case of the html node - it will return itself 9756 // 9757 // but those exceptions were never presented as a real life use-cases 9758 // and might be considered as more preferable results. 9759 // 9760 // This logic, however, is not guaranteed and can change at any point in the future 9761 offsetParent: function() { 9762 return this.map( function() { 9763 var offsetParent = this.offsetParent; 9764 9765 while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) { 9766 offsetParent = offsetParent.offsetParent; 9767 } 9768 9769 return offsetParent || documentElement; 9770 } ); 9771 } 9772 } ); 9773 9774 // Create scrollLeft and scrollTop methods 9775 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) { 9776 var top = "pageYOffset" === prop; 9777 9778 jQuery.fn[ method ] = function( val ) { 9779 return access( this, function( elem, method, val ) { 9780 var win = getWindow( elem ); 9781 9782 if ( val === undefined ) { 9783 return win ? win[ prop ] : elem[ method ]; 9784 } 9785 9786 if ( win ) { 9787 win.scrollTo( 9788 !top ? val : win.pageXOffset, 9789 top ? val : win.pageYOffset 9790 ); 9791 9792 } else { 9793 elem[ method ] = val; 9794 } 9795 }, method, val, arguments.length ); 9796 }; 9797 } ); 9798 9799 // Support: Safari<7-8+, Chrome<37-44+ 9800 // Add the top/left cssHooks using jQuery.fn.position 9801 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 9802 // Blink bug: https://code.google.com/p/chromium/issues/detail?id=229280 9803 // getComputedStyle returns percent when specified for top/left/bottom/right; 9804 // rather than make the css module depend on the offset module, just check for it here 9805 jQuery.each( [ "top", "left" ], function( i, prop ) { 9806 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition, 9807 function( elem, computed ) { 9808 if ( computed ) { 9809 computed = curCSS( elem, prop ); 9810 9811 // If curCSS returns percentage, fallback to offset 9812 return rnumnonpx.test( computed ) ? 9813 jQuery( elem ).position()[ prop ] + "px" : 9814 computed; 9815 } 9816 } 9817 ); 9818 } ); 9819 9820 9821 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods 9822 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { 9823 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, 9824 function( defaultExtra, funcName ) { 9825 9826 // Margin is only for outerHeight, outerWidth 9827 jQuery.fn[ funcName ] = function( margin, value ) { 9828 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), 9829 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" ); 9830 9831 return access( this, function( elem, type, value ) { 9832 var doc; 9833 9834 if ( jQuery.isWindow( elem ) ) { 9835 9836 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there 9837 // isn't a whole lot we can do. See pull request at this URL for discussion: 9838 // https://github.com/jquery/jquery/pull/764 9839 return elem.document.documentElement[ "client" + name ]; 9840 } 9841 9842 // Get document width or height 9843 if ( elem.nodeType === 9 ) { 9844 doc = elem.documentElement; 9845 9846 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], 9847 // whichever is greatest 9848 return Math.max( 9849 elem.body[ "scroll" + name ], doc[ "scroll" + name ], 9850 elem.body[ "offset" + name ], doc[ "offset" + name ], 9851 doc[ "client" + name ] 9852 ); 9853 } 9854 9855 return value === undefined ? 9856 9857 // Get width or height on the element, requesting but not forcing parseFloat 9858 jQuery.css( elem, type, extra ) : 9859 9860 // Set width or height on the element 9861 jQuery.style( elem, type, value, extra ); 9862 }, type, chainable ? margin : undefined, chainable, null ); 9863 }; 9864 } ); 9865 } ); 9866 9867 9868 jQuery.fn.extend( { 9869 9870 bind: function( types, data, fn ) { 9871 return this.on( types, null, data, fn ); 9872 }, 9873 unbind: function( types, fn ) { 9874 return this.off( types, null, fn ); 9875 }, 9876 9877 delegate: function( selector, types, data, fn ) { 9878 return this.on( types, selector, data, fn ); 9879 }, 9880 undelegate: function( selector, types, fn ) { 9881 9882 // ( namespace ) or ( selector, types [, fn] ) 9883 return arguments.length === 1 ? 9884 this.off( selector, "**" ) : 9885 this.off( types, selector || "**", fn ); 9886 }, 9887 size: function() { 9888 return this.length; 9889 } 9890 } ); 9891 9892 jQuery.fn.andSelf = jQuery.fn.addBack; 9893 9894 9895 9896 9897 // Register as a named AMD module, since jQuery can be concatenated with other 9898 // files that may use define, but not via a proper concatenation script that 9899 // understands anonymous AMD modules. A named AMD is safest and most robust 9900 // way to register. Lowercase jquery is used because AMD module names are 9901 // derived from file names, and jQuery is normally delivered in a lowercase 9902 // file name. Do this after creating the global so that if an AMD module wants 9903 // to call noConflict to hide this version of jQuery, it will work. 9904 9905 // Note that for maximum portability, libraries that are not jQuery should 9906 // declare themselves as anonymous modules, and avoid setting a global if an 9907 // AMD loader is present. jQuery is a special case. For more information, see 9908 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon 9909 9910 if ( true ) { 9911 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() { 9912 return jQuery; 9913 }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 9914 } 9915 9916 9917 9918 var 9919 9920 // Map over jQuery in case of overwrite 9921 _jQuery = window.jQuery, 9922 9923 // Map over the $ in case of overwrite 9924 _$ = window.$; 9925 9926 jQuery.noConflict = function( deep ) { 9927 if ( window.$ === jQuery ) { 9928 window.$ = _$; 9929 } 9930 9931 if ( deep && window.jQuery === jQuery ) { 9932 window.jQuery = _jQuery; 9933 } 9934 9935 return jQuery; 9936 }; 9937 9938 // Expose jQuery and $ identifiers, even in AMD 9939 // (#7102#comment:10, https://github.com/jquery/jquery/pull/557) 9940 // and CommonJS for browser emulators (#13566) 9941 if ( !noGlobal ) { 9942 window.jQuery = window.$ = jQuery; 9943 } 9944 9945 return jQuery; 9946 })); 9947 9948 9949 /***/ }, 9950 /* 72 */ 9951 /***/ function(module, exports, __webpack_require__) { 9952 9953 // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 9954 __webpack_require__(73) 9955 __webpack_require__(74) 9956 __webpack_require__(75) 9957 __webpack_require__(76) 9958 __webpack_require__(77) 9959 __webpack_require__(78) 9960 __webpack_require__(79) 9961 __webpack_require__(80) 9962 __webpack_require__(81) 9963 __webpack_require__(82) 9964 __webpack_require__(83) 9965 __webpack_require__(84) 9966 9967 /***/ }, 9968 /* 73 */ 9969 /***/ function(module, exports, __webpack_require__) { 9970 9971 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 9972 * Bootstrap: transition.js v3.3.7 9973 * http://getbootstrap.com/javascript/#transitions 9974 * ======================================================================== 9975 * Copyright 2011-2016 Twitter, Inc. 9976 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 9977 * ======================================================================== */ 9978 9979 9980 +function ($) { 9981 'use strict'; 9982 9983 // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) 9984 // ============================================================ 9985 9986 function transitionEnd() { 9987 var el = document.createElement('bootstrap') 9988 9989 var transEndEventNames = { 9990 WebkitTransition : 'webkitTransitionEnd', 9991 MozTransition : 'transitionend', 9992 OTransition : 'oTransitionEnd otransitionend', 9993 transition : 'transitionend' 9994 } 9995 9996 for (var name in transEndEventNames) { 9997 if (el.style[name] !== undefined) { 9998 return { end: transEndEventNames[name] } 9999 } 10000 } 10001 10002 return false // explicit for ie8 ( ._.) 10003 } 10004 10005 // http://blog.alexmaccaw.com/css-transitions 10006 $.fn.emulateTransitionEnd = function (duration) { 10007 var called = false 10008 var $el = this 10009 $(this).one('bsTransitionEnd', function () { called = true }) 10010 var callback = function () { if (!called) $($el).trigger($.support.transition.end) } 10011 setTimeout(callback, duration) 10012 return this 10013 } 10014 10015 $(function () { 10016 $.support.transition = transitionEnd() 10017 10018 if (!$.support.transition) return 10019 10020 $.event.special.bsTransitionEnd = { 10021 bindType: $.support.transition.end, 10022 delegateType: $.support.transition.end, 10023 handle: function (e) { 10024 if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments) 10025 } 10026 } 10027 }) 10028 10029 }(jQuery); 10030 10031 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71))) 10032 10033 /***/ }, 10034 /* 74 */ 10035 /***/ function(module, exports, __webpack_require__) { 10036 10037 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 10038 * Bootstrap: alert.js v3.3.7 10039 * http://getbootstrap.com/javascript/#alerts 10040 * ======================================================================== 10041 * Copyright 2011-2016 Twitter, Inc. 10042 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 10043 * ======================================================================== */ 10044 10045 10046 +function ($) { 10047 'use strict'; 10048 10049 // ALERT CLASS DEFINITION 10050 // ====================== 10051 10052 var dismiss = '[data-dismiss="alert"]' 10053 var Alert = function (el) { 10054 $(el).on('click', dismiss, this.close) 10055 } 10056 10057 Alert.VERSION = '3.3.7' 10058 10059 Alert.TRANSITION_DURATION = 150 10060 10061 Alert.prototype.close = function (e) { 10062 var $this = $(this) 10063 var selector = $this.attr('data-target') 10064 10065 if (!selector) { 10066 selector = $this.attr('href') 10067 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 10068 } 10069 10070 var $parent = $(selector === '#' ? [] : selector) 10071 10072 if (e) e.preventDefault() 10073 10074 if (!$parent.length) { 10075 $parent = $this.closest('.alert') 10076 } 10077 10078 $parent.trigger(e = $.Event('close.bs.alert')) 10079 10080 if (e.isDefaultPrevented()) return 10081 10082 $parent.removeClass('in') 10083 10084 function removeElement() { 10085 // detach from parent, fire event then clean up data 10086 $parent.detach().trigger('closed.bs.alert').remove() 10087 } 10088 10089 $.support.transition && $parent.hasClass('fade') ? 10090 $parent 10091 .one('bsTransitionEnd', removeElement) 10092 .emulateTransitionEnd(Alert.TRANSITION_DURATION) : 10093 removeElement() 10094 } 10095 10096 10097 // ALERT PLUGIN DEFINITION 10098 // ======================= 10099 10100 function Plugin(option) { 10101 return this.each(function () { 10102 var $this = $(this) 10103 var data = $this.data('bs.alert') 10104 10105 if (!data) $this.data('bs.alert', (data = new Alert(this))) 10106 if (typeof option == 'string') data[option].call($this) 10107 }) 10108 } 10109 10110 var old = $.fn.alert 10111 10112 $.fn.alert = Plugin 10113 $.fn.alert.Constructor = Alert 10114 10115 10116 // ALERT NO CONFLICT 10117 // ================= 10118 10119 $.fn.alert.noConflict = function () { 10120 $.fn.alert = old 10121 return this 10122 } 10123 10124 10125 // ALERT DATA-API 10126 // ============== 10127 10128 $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close) 10129 10130 }(jQuery); 10131 10132 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71))) 10133 10134 /***/ }, 10135 /* 75 */ 10136 /***/ function(module, exports, __webpack_require__) { 10137 10138 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 10139 * Bootstrap: button.js v3.3.7 10140 * http://getbootstrap.com/javascript/#buttons 10141 * ======================================================================== 10142 * Copyright 2011-2016 Twitter, Inc. 10143 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 10144 * ======================================================================== */ 10145 10146 10147 +function ($) { 10148 'use strict'; 10149 10150 // BUTTON PUBLIC CLASS DEFINITION 10151 // ============================== 10152 10153 var Button = function (element, options) { 10154 this.$element = $(element) 10155 this.options = $.extend({}, Button.DEFAULTS, options) 10156 this.isLoading = false 10157 } 10158 10159 Button.VERSION = '3.3.7' 10160 10161 Button.DEFAULTS = { 10162 loadingText: 'loading...' 10163 } 10164 10165 Button.prototype.setState = function (state) { 10166 var d = 'disabled' 10167 var $el = this.$element 10168 var val = $el.is('input') ? 'val' : 'html' 10169 var data = $el.data() 10170 10171 state += 'Text' 10172 10173 if (data.resetText == null) $el.data('resetText', $el[val]()) 10174 10175 // push to event loop to allow forms to submit 10176 setTimeout($.proxy(function () { 10177 $el[val](data[state] == null ? this.options[state] : data[state]) 10178 10179 if (state == 'loadingText') { 10180 this.isLoading = true 10181 $el.addClass(d).attr(d, d).prop(d, true) 10182 } else if (this.isLoading) { 10183 this.isLoading = false 10184 $el.removeClass(d).removeAttr(d).prop(d, false) 10185 } 10186 }, this), 0) 10187 } 10188 10189 Button.prototype.toggle = function () { 10190 var changed = true 10191 var $parent = this.$element.closest('[data-toggle="buttons"]') 10192 10193 if ($parent.length) { 10194 var $input = this.$element.find('input') 10195 if ($input.prop('type') == 'radio') { 10196 if ($input.prop('checked')) changed = false 10197 $parent.find('.active').removeClass('active') 10198 this.$element.addClass('active') 10199 } else if ($input.prop('type') == 'checkbox') { 10200 if (($input.prop('checked')) !== this.$element.hasClass('active')) changed = false 10201 this.$element.toggleClass('active') 10202 } 10203 $input.prop('checked', this.$element.hasClass('active')) 10204 if (changed) $input.trigger('change') 10205 } else { 10206 this.$element.attr('aria-pressed', !this.$element.hasClass('active')) 10207 this.$element.toggleClass('active') 10208 } 10209 } 10210 10211 10212 // BUTTON PLUGIN DEFINITION 10213 // ======================== 10214 10215 function Plugin(option) { 10216 return this.each(function () { 10217 var $this = $(this) 10218 var data = $this.data('bs.button') 10219 var options = typeof option == 'object' && option 10220 10221 if (!data) $this.data('bs.button', (data = new Button(this, options))) 10222 10223 if (option == 'toggle') data.toggle() 10224 else if (option) data.setState(option) 10225 }) 10226 } 10227 10228 var old = $.fn.button 10229 10230 $.fn.button = Plugin 10231 $.fn.button.Constructor = Button 10232 10233 10234 // BUTTON NO CONFLICT 10235 // ================== 10236 10237 $.fn.button.noConflict = function () { 10238 $.fn.button = old 10239 return this 10240 } 10241 10242 10243 // BUTTON DATA-API 10244 // =============== 10245 10246 $(document) 10247 .on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) { 10248 var $btn = $(e.target).closest('.btn') 10249 Plugin.call($btn, 'toggle') 10250 if (!($(e.target).is('input[type="radio"], input[type="checkbox"]'))) { 10251 // Prevent double click on radios, and the double selections (so cancellation) on checkboxes 10252 e.preventDefault() 10253 // The target component still receive the focus 10254 if ($btn.is('input,button')) $btn.trigger('focus') 10255 else $btn.find('input:visible,button:visible').first().trigger('focus') 10256 } 10257 }) 10258 .on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]', function (e) { 10259 $(e.target).closest('.btn').toggleClass('focus', /^focus(in)?$/.test(e.type)) 10260 }) 10261 10262 }(jQuery); 10263 10264 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71))) 10265 10266 /***/ }, 10267 /* 76 */ 10268 /***/ function(module, exports, __webpack_require__) { 10269 10270 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 10271 * Bootstrap: carousel.js v3.3.7 10272 * http://getbootstrap.com/javascript/#carousel 10273 * ======================================================================== 10274 * Copyright 2011-2016 Twitter, Inc. 10275 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 10276 * ======================================================================== */ 10277 10278 10279 +function ($) { 10280 'use strict'; 10281 10282 // CAROUSEL CLASS DEFINITION 10283 // ========================= 10284 10285 var Carousel = function (element, options) { 10286 this.$element = $(element) 10287 this.$indicators = this.$element.find('.carousel-indicators') 10288 this.options = options 10289 this.paused = null 10290 this.sliding = null 10291 this.interval = null 10292 this.$active = null 10293 this.$items = null 10294 10295 this.options.keyboard && this.$element.on('keydown.bs.carousel', $.proxy(this.keydown, this)) 10296 10297 this.options.pause == 'hover' && !('ontouchstart' in document.documentElement) && this.$element 10298 .on('mouseenter.bs.carousel', $.proxy(this.pause, this)) 10299 .on('mouseleave.bs.carousel', $.proxy(this.cycle, this)) 10300 } 10301 10302 Carousel.VERSION = '3.3.7' 10303 10304 Carousel.TRANSITION_DURATION = 600 10305 10306 Carousel.DEFAULTS = { 10307 interval: 5000, 10308 pause: 'hover', 10309 wrap: true, 10310 keyboard: true 10311 } 10312 10313 Carousel.prototype.keydown = function (e) { 10314 if (/input|textarea/i.test(e.target.tagName)) return 10315 switch (e.which) { 10316 case 37: this.prev(); break 10317 case 39: this.next(); break 10318 default: return 10319 } 10320 10321 e.preventDefault() 10322 } 10323 10324 Carousel.prototype.cycle = function (e) { 10325 e || (this.paused = false) 10326 10327 this.interval && clearInterval(this.interval) 10328 10329 this.options.interval 10330 && !this.paused 10331 && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) 10332 10333 return this 10334 } 10335 10336 Carousel.prototype.getItemIndex = function (item) { 10337 this.$items = item.parent().children('.item') 10338 return this.$items.index(item || this.$active) 10339 } 10340 10341 Carousel.prototype.getItemForDirection = function (direction, active) { 10342 var activeIndex = this.getItemIndex(active) 10343 var willWrap = (direction == 'prev' && activeIndex === 0) 10344 || (direction == 'next' && activeIndex == (this.$items.length - 1)) 10345 if (willWrap && !this.options.wrap) return active 10346 var delta = direction == 'prev' ? -1 : 1 10347 var itemIndex = (activeIndex + delta) % this.$items.length 10348 return this.$items.eq(itemIndex) 10349 } 10350 10351 Carousel.prototype.to = function (pos) { 10352 var that = this 10353 var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active')) 10354 10355 if (pos > (this.$items.length - 1) || pos < 0) return 10356 10357 if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid" 10358 if (activeIndex == pos) return this.pause().cycle() 10359 10360 return this.slide(pos > activeIndex ? 'next' : 'prev', this.$items.eq(pos)) 10361 } 10362 10363 Carousel.prototype.pause = function (e) { 10364 e || (this.paused = true) 10365 10366 if (this.$element.find('.next, .prev').length && $.support.transition) { 10367 this.$element.trigger($.support.transition.end) 10368 this.cycle(true) 10369 } 10370 10371 this.interval = clearInterval(this.interval) 10372 10373 return this 10374 } 10375 10376 Carousel.prototype.next = function () { 10377 if (this.sliding) return 10378 return this.slide('next') 10379 } 10380 10381 Carousel.prototype.prev = function () { 10382 if (this.sliding) return 10383 return this.slide('prev') 10384 } 10385 10386 Carousel.prototype.slide = function (type, next) { 10387 var $active = this.$element.find('.item.active') 10388 var $next = next || this.getItemForDirection(type, $active) 10389 var isCycling = this.interval 10390 var direction = type == 'next' ? 'left' : 'right' 10391 var that = this 10392 10393 if ($next.hasClass('active')) return (this.sliding = false) 10394 10395 var relatedTarget = $next[0] 10396 var slideEvent = $.Event('slide.bs.carousel', { 10397 relatedTarget: relatedTarget, 10398 direction: direction 10399 }) 10400 this.$element.trigger(slideEvent) 10401 if (slideEvent.isDefaultPrevented()) return 10402 10403 this.sliding = true 10404 10405 isCycling && this.pause() 10406 10407 if (this.$indicators.length) { 10408 this.$indicators.find('.active').removeClass('active') 10409 var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)]) 10410 $nextIndicator && $nextIndicator.addClass('active') 10411 } 10412 10413 var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid" 10414 if ($.support.transition && this.$element.hasClass('slide')) { 10415 $next.addClass(type) 10416 $next[0].offsetWidth // force reflow 10417 $active.addClass(direction) 10418 $next.addClass(direction) 10419 $active 10420 .one('bsTransitionEnd', function () { 10421 $next.removeClass([type, direction].join(' ')).addClass('active') 10422 $active.removeClass(['active', direction].join(' ')) 10423 that.sliding = false 10424 setTimeout(function () { 10425 that.$element.trigger(slidEvent) 10426 }, 0) 10427 }) 10428 .emulateTransitionEnd(Carousel.TRANSITION_DURATION) 10429 } else { 10430 $active.removeClass('active') 10431 $next.addClass('active') 10432 this.sliding = false 10433 this.$element.trigger(slidEvent) 10434 } 10435 10436 isCycling && this.cycle() 10437 10438 return this 10439 } 10440 10441 10442 // CAROUSEL PLUGIN DEFINITION 10443 // ========================== 10444 10445 function Plugin(option) { 10446 return this.each(function () { 10447 var $this = $(this) 10448 var data = $this.data('bs.carousel') 10449 var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option) 10450 var action = typeof option == 'string' ? option : options.slide 10451 10452 if (!data) $this.data('bs.carousel', (data = new Carousel(this, options))) 10453 if (typeof option == 'number') data.to(option) 10454 else if (action) data[action]() 10455 else if (options.interval) data.pause().cycle() 10456 }) 10457 } 10458 10459 var old = $.fn.carousel 10460 10461 $.fn.carousel = Plugin 10462 $.fn.carousel.Constructor = Carousel 10463 10464 10465 // CAROUSEL NO CONFLICT 10466 // ==================== 10467 10468 $.fn.carousel.noConflict = function () { 10469 $.fn.carousel = old 10470 return this 10471 } 10472 10473 10474 // CAROUSEL DATA-API 10475 // ================= 10476 10477 var clickHandler = function (e) { 10478 var href 10479 var $this = $(this) 10480 var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7 10481 if (!$target.hasClass('carousel')) return 10482 var options = $.extend({}, $target.data(), $this.data()) 10483 var slideIndex = $this.attr('data-slide-to') 10484 if (slideIndex) options.interval = false 10485 10486 Plugin.call($target, options) 10487 10488 if (slideIndex) { 10489 $target.data('bs.carousel').to(slideIndex) 10490 } 10491 10492 e.preventDefault() 10493 } 10494 10495 $(document) 10496 .on('click.bs.carousel.data-api', '[data-slide]', clickHandler) 10497 .on('click.bs.carousel.data-api', '[data-slide-to]', clickHandler) 10498 10499 $(window).on('load', function () { 10500 $('[data-ride="carousel"]').each(function () { 10501 var $carousel = $(this) 10502 Plugin.call($carousel, $carousel.data()) 10503 }) 10504 }) 10505 10506 }(jQuery); 10507 10508 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71))) 10509 10510 /***/ }, 10511 /* 77 */ 10512 /***/ function(module, exports, __webpack_require__) { 10513 10514 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 10515 * Bootstrap: collapse.js v3.3.7 10516 * http://getbootstrap.com/javascript/#collapse 10517 * ======================================================================== 10518 * Copyright 2011-2016 Twitter, Inc. 10519 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 10520 * ======================================================================== */ 10521 10522 /* jshint latedef: false */ 10523 10524 +function ($) { 10525 'use strict'; 10526 10527 // COLLAPSE PUBLIC CLASS DEFINITION 10528 // ================================ 10529 10530 var Collapse = function (element, options) { 10531 this.$element = $(element) 10532 this.options = $.extend({}, Collapse.DEFAULTS, options) 10533 this.$trigger = $('[data-toggle="collapse"][href="#' + element.id + '"],' + 10534 '[data-toggle="collapse"][data-target="#' + element.id + '"]') 10535 this.transitioning = null 10536 10537 if (this.options.parent) { 10538 this.$parent = this.getParent() 10539 } else { 10540 this.addAriaAndCollapsedClass(this.$element, this.$trigger) 10541 } 10542 10543 if (this.options.toggle) this.toggle() 10544 } 10545 10546 Collapse.VERSION = '3.3.7' 10547 10548 Collapse.TRANSITION_DURATION = 350 10549 10550 Collapse.DEFAULTS = { 10551 toggle: true 10552 } 10553 10554 Collapse.prototype.dimension = function () { 10555 var hasWidth = this.$element.hasClass('width') 10556 return hasWidth ? 'width' : 'height' 10557 } 10558 10559 Collapse.prototype.show = function () { 10560 if (this.transitioning || this.$element.hasClass('in')) return 10561 10562 var activesData 10563 var actives = this.$parent && this.$parent.children('.panel').children('.in, .collapsing') 10564 10565 if (actives && actives.length) { 10566 activesData = actives.data('bs.collapse') 10567 if (activesData && activesData.transitioning) return 10568 } 10569 10570 var startEvent = $.Event('show.bs.collapse') 10571 this.$element.trigger(startEvent) 10572 if (startEvent.isDefaultPrevented()) return 10573 10574 if (actives && actives.length) { 10575 Plugin.call(actives, 'hide') 10576 activesData || actives.data('bs.collapse', null) 10577 } 10578 10579 var dimension = this.dimension() 10580 10581 this.$element 10582 .removeClass('collapse') 10583 .addClass('collapsing')[dimension](0) 10584 .attr('aria-expanded', true) 10585 10586 this.$trigger 10587 .removeClass('collapsed') 10588 .attr('aria-expanded', true) 10589 10590 this.transitioning = 1 10591 10592 var complete = function () { 10593 this.$element 10594 .removeClass('collapsing') 10595 .addClass('collapse in')[dimension]('') 10596 this.transitioning = 0 10597 this.$element 10598 .trigger('shown.bs.collapse') 10599 } 10600 10601 if (!$.support.transition) return complete.call(this) 10602 10603 var scrollSize = $.camelCase(['scroll', dimension].join('-')) 10604 10605 this.$element 10606 .one('bsTransitionEnd', $.proxy(complete, this)) 10607 .emulateTransitionEnd(Collapse.TRANSITION_DURATION)[dimension](this.$element[0][scrollSize]) 10608 } 10609 10610 Collapse.prototype.hide = function () { 10611 if (this.transitioning || !this.$element.hasClass('in')) return 10612 10613 var startEvent = $.Event('hide.bs.collapse') 10614 this.$element.trigger(startEvent) 10615 if (startEvent.isDefaultPrevented()) return 10616 10617 var dimension = this.dimension() 10618 10619 this.$element[dimension](this.$element[dimension]())[0].offsetHeight 10620 10621 this.$element 10622 .addClass('collapsing') 10623 .removeClass('collapse in') 10624 .attr('aria-expanded', false) 10625 10626 this.$trigger 10627 .addClass('collapsed') 10628 .attr('aria-expanded', false) 10629 10630 this.transitioning = 1 10631 10632 var complete = function () { 10633 this.transitioning = 0 10634 this.$element 10635 .removeClass('collapsing') 10636 .addClass('collapse') 10637 .trigger('hidden.bs.collapse') 10638 } 10639 10640 if (!$.support.transition) return complete.call(this) 10641 10642 this.$element 10643 [dimension](0) 10644 .one('bsTransitionEnd', $.proxy(complete, this)) 10645 .emulateTransitionEnd(Collapse.TRANSITION_DURATION) 10646 } 10647 10648 Collapse.prototype.toggle = function () { 10649 this[this.$element.hasClass('in') ? 'hide' : 'show']() 10650 } 10651 10652 Collapse.prototype.getParent = function () { 10653 return $(this.options.parent) 10654 .find('[data-toggle="collapse"][data-parent="' + this.options.parent + '"]') 10655 .each($.proxy(function (i, element) { 10656 var $element = $(element) 10657 this.addAriaAndCollapsedClass(getTargetFromTrigger($element), $element) 10658 }, this)) 10659 .end() 10660 } 10661 10662 Collapse.prototype.addAriaAndCollapsedClass = function ($element, $trigger) { 10663 var isOpen = $element.hasClass('in') 10664 10665 $element.attr('aria-expanded', isOpen) 10666 $trigger 10667 .toggleClass('collapsed', !isOpen) 10668 .attr('aria-expanded', isOpen) 10669 } 10670 10671 function getTargetFromTrigger($trigger) { 10672 var href 10673 var target = $trigger.attr('data-target') 10674 || (href = $trigger.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7 10675 10676 return $(target) 10677 } 10678 10679 10680 // COLLAPSE PLUGIN DEFINITION 10681 // ========================== 10682 10683 function Plugin(option) { 10684 return this.each(function () { 10685 var $this = $(this) 10686 var data = $this.data('bs.collapse') 10687 var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option) 10688 10689 if (!data && options.toggle && /show|hide/.test(option)) options.toggle = false 10690 if (!data) $this.data('bs.collapse', (data = new Collapse(this, options))) 10691 if (typeof option == 'string') data[option]() 10692 }) 10693 } 10694 10695 var old = $.fn.collapse 10696 10697 $.fn.collapse = Plugin 10698 $.fn.collapse.Constructor = Collapse 10699 10700 10701 // COLLAPSE NO CONFLICT 10702 // ==================== 10703 10704 $.fn.collapse.noConflict = function () { 10705 $.fn.collapse = old 10706 return this 10707 } 10708 10709 10710 // COLLAPSE DATA-API 10711 // ================= 10712 10713 $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) { 10714 var $this = $(this) 10715 10716 if (!$this.attr('data-target')) e.preventDefault() 10717 10718 var $target = getTargetFromTrigger($this) 10719 var data = $target.data('bs.collapse') 10720 var option = data ? 'toggle' : $this.data() 10721 10722 Plugin.call($target, option) 10723 }) 10724 10725 }(jQuery); 10726 10727 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71))) 10728 10729 /***/ }, 10730 /* 78 */ 10731 /***/ function(module, exports, __webpack_require__) { 10732 10733 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 10734 * Bootstrap: dropdown.js v3.3.7 10735 * http://getbootstrap.com/javascript/#dropdowns 10736 * ======================================================================== 10737 * Copyright 2011-2016 Twitter, Inc. 10738 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 10739 * ======================================================================== */ 10740 10741 10742 +function ($) { 10743 'use strict'; 10744 10745 // DROPDOWN CLASS DEFINITION 10746 // ========================= 10747 10748 var backdrop = '.dropdown-backdrop' 10749 var toggle = '[data-toggle="dropdown"]' 10750 var Dropdown = function (element) { 10751 $(element).on('click.bs.dropdown', this.toggle) 10752 } 10753 10754 Dropdown.VERSION = '3.3.7' 10755 10756 function getParent($this) { 10757 var selector = $this.attr('data-target') 10758 10759 if (!selector) { 10760 selector = $this.attr('href') 10761 selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 10762 } 10763 10764 var $parent = selector && $(selector) 10765 10766 return $parent && $parent.length ? $parent : $this.parent() 10767 } 10768 10769 function clearMenus(e) { 10770 if (e && e.which === 3) return 10771 $(backdrop).remove() 10772 $(toggle).each(function () { 10773 var $this = $(this) 10774 var $parent = getParent($this) 10775 var relatedTarget = { relatedTarget: this } 10776 10777 if (!$parent.hasClass('open')) return 10778 10779 if (e && e.type == 'click' && /input|textarea/i.test(e.target.tagName) && $.contains($parent[0], e.target)) return 10780 10781 $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget)) 10782 10783 if (e.isDefaultPrevented()) return 10784 10785 $this.attr('aria-expanded', 'false') 10786 $parent.removeClass('open').trigger($.Event('hidden.bs.dropdown', relatedTarget)) 10787 }) 10788 } 10789 10790 Dropdown.prototype.toggle = function (e) { 10791 var $this = $(this) 10792 10793 if ($this.is('.disabled, :disabled')) return 10794 10795 var $parent = getParent($this) 10796 var isActive = $parent.hasClass('open') 10797 10798 clearMenus() 10799 10800 if (!isActive) { 10801 if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) { 10802 // if mobile we use a backdrop because click events don't delegate 10803 $(document.createElement('div')) 10804 .addClass('dropdown-backdrop') 10805 .insertAfter($(this)) 10806 .on('click', clearMenus) 10807 } 10808 10809 var relatedTarget = { relatedTarget: this } 10810 $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget)) 10811 10812 if (e.isDefaultPrevented()) return 10813 10814 $this 10815 .trigger('focus') 10816 .attr('aria-expanded', 'true') 10817 10818 $parent 10819 .toggleClass('open') 10820 .trigger($.Event('shown.bs.dropdown', relatedTarget)) 10821 } 10822 10823 return false 10824 } 10825 10826 Dropdown.prototype.keydown = function (e) { 10827 if (!/(38|40|27|32)/.test(e.which) || /input|textarea/i.test(e.target.tagName)) return 10828 10829 var $this = $(this) 10830 10831 e.preventDefault() 10832 e.stopPropagation() 10833 10834 if ($this.is('.disabled, :disabled')) return 10835 10836 var $parent = getParent($this) 10837 var isActive = $parent.hasClass('open') 10838 10839 if (!isActive && e.which != 27 || isActive && e.which == 27) { 10840 if (e.which == 27) $parent.find(toggle).trigger('focus') 10841 return $this.trigger('click') 10842 } 10843 10844 var desc = ' li:not(.disabled):visible a' 10845 var $items = $parent.find('.dropdown-menu' + desc) 10846 10847 if (!$items.length) return 10848 10849 var index = $items.index(e.target) 10850 10851 if (e.which == 38 && index > 0) index-- // up 10852 if (e.which == 40 && index < $items.length - 1) index++ // down 10853 if (!~index) index = 0 10854 10855 $items.eq(index).trigger('focus') 10856 } 10857 10858 10859 // DROPDOWN PLUGIN DEFINITION 10860 // ========================== 10861 10862 function Plugin(option) { 10863 return this.each(function () { 10864 var $this = $(this) 10865 var data = $this.data('bs.dropdown') 10866 10867 if (!data) $this.data('bs.dropdown', (data = new Dropdown(this))) 10868 if (typeof option == 'string') data[option].call($this) 10869 }) 10870 } 10871 10872 var old = $.fn.dropdown 10873 10874 $.fn.dropdown = Plugin 10875 $.fn.dropdown.Constructor = Dropdown 10876 10877 10878 // DROPDOWN NO CONFLICT 10879 // ==================== 10880 10881 $.fn.dropdown.noConflict = function () { 10882 $.fn.dropdown = old 10883 return this 10884 } 10885 10886 10887 // APPLY TO STANDARD DROPDOWN ELEMENTS 10888 // =================================== 10889 10890 $(document) 10891 .on('click.bs.dropdown.data-api', clearMenus) 10892 .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) 10893 .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle) 10894 .on('keydown.bs.dropdown.data-api', toggle, Dropdown.prototype.keydown) 10895 .on('keydown.bs.dropdown.data-api', '.dropdown-menu', Dropdown.prototype.keydown) 10896 10897 }(jQuery); 10898 10899 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71))) 10900 10901 /***/ }, 10902 /* 79 */ 10903 /***/ function(module, exports, __webpack_require__) { 10904 10905 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 10906 * Bootstrap: modal.js v3.3.7 10907 * http://getbootstrap.com/javascript/#modals 10908 * ======================================================================== 10909 * Copyright 2011-2016 Twitter, Inc. 10910 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 10911 * ======================================================================== */ 10912 10913 10914 +function ($) { 10915 'use strict'; 10916 10917 // MODAL CLASS DEFINITION 10918 // ====================== 10919 10920 var Modal = function (element, options) { 10921 this.options = options 10922 this.$body = $(document.body) 10923 this.$element = $(element) 10924 this.$dialog = this.$element.find('.modal-dialog') 10925 this.$backdrop = null 10926 this.isShown = null 10927 this.originalBodyPad = null 10928 this.scrollbarWidth = 0 10929 this.ignoreBackdropClick = false 10930 10931 if (this.options.remote) { 10932 this.$element 10933 .find('.modal-content') 10934 .load(this.options.remote, $.proxy(function () { 10935 this.$element.trigger('loaded.bs.modal') 10936 }, this)) 10937 } 10938 } 10939 10940 Modal.VERSION = '3.3.7' 10941 10942 Modal.TRANSITION_DURATION = 300 10943 Modal.BACKDROP_TRANSITION_DURATION = 150 10944 10945 Modal.DEFAULTS = { 10946 backdrop: true, 10947 keyboard: true, 10948 show: true 10949 } 10950 10951 Modal.prototype.toggle = function (_relatedTarget) { 10952 return this.isShown ? this.hide() : this.show(_relatedTarget) 10953 } 10954 10955 Modal.prototype.show = function (_relatedTarget) { 10956 var that = this 10957 var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget }) 10958 10959 this.$element.trigger(e) 10960 10961 if (this.isShown || e.isDefaultPrevented()) return 10962 10963 this.isShown = true 10964 10965 this.checkScrollbar() 10966 this.setScrollbar() 10967 this.$body.addClass('modal-open') 10968 10969 this.escape() 10970 this.resize() 10971 10972 this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this)) 10973 10974 this.$dialog.on('mousedown.dismiss.bs.modal', function () { 10975 that.$element.one('mouseup.dismiss.bs.modal', function (e) { 10976 if ($(e.target).is(that.$element)) that.ignoreBackdropClick = true 10977 }) 10978 }) 10979 10980 this.backdrop(function () { 10981 var transition = $.support.transition && that.$element.hasClass('fade') 10982 10983 if (!that.$element.parent().length) { 10984 that.$element.appendTo(that.$body) // don't move modals dom position 10985 } 10986 10987 that.$element 10988 .show() 10989 .scrollTop(0) 10990 10991 that.adjustDialog() 10992 10993 if (transition) { 10994 that.$element[0].offsetWidth // force reflow 10995 } 10996 10997 that.$element.addClass('in') 10998 10999 that.enforceFocus() 11000 11001 var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget }) 11002 11003 transition ? 11004 that.$dialog // wait for modal to slide in 11005 .one('bsTransitionEnd', function () { 11006 that.$element.trigger('focus').trigger(e) 11007 }) 11008 .emulateTransitionEnd(Modal.TRANSITION_DURATION) : 11009 that.$element.trigger('focus').trigger(e) 11010 }) 11011 } 11012 11013 Modal.prototype.hide = function (e) { 11014 if (e) e.preventDefault() 11015 11016 e = $.Event('hide.bs.modal') 11017 11018 this.$element.trigger(e) 11019 11020 if (!this.isShown || e.isDefaultPrevented()) return 11021 11022 this.isShown = false 11023 11024 this.escape() 11025 this.resize() 11026 11027 $(document).off('focusin.bs.modal') 11028 11029 this.$element 11030 .removeClass('in') 11031 .off('click.dismiss.bs.modal') 11032 .off('mouseup.dismiss.bs.modal') 11033 11034 this.$dialog.off('mousedown.dismiss.bs.modal') 11035 11036 $.support.transition && this.$element.hasClass('fade') ? 11037 this.$element 11038 .one('bsTransitionEnd', $.proxy(this.hideModal, this)) 11039 .emulateTransitionEnd(Modal.TRANSITION_DURATION) : 11040 this.hideModal() 11041 } 11042 11043 Modal.prototype.enforceFocus = function () { 11044 $(document) 11045 .off('focusin.bs.modal') // guard against infinite focus loop 11046 .on('focusin.bs.modal', $.proxy(function (e) { 11047 if (document !== e.target && 11048 this.$element[0] !== e.target && 11049 !this.$element.has(e.target).length) { 11050 this.$element.trigger('focus') 11051 } 11052 }, this)) 11053 } 11054 11055 Modal.prototype.escape = function () { 11056 if (this.isShown && this.options.keyboard) { 11057 this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) { 11058 e.which == 27 && this.hide() 11059 }, this)) 11060 } else if (!this.isShown) { 11061 this.$element.off('keydown.dismiss.bs.modal') 11062 } 11063 } 11064 11065 Modal.prototype.resize = function () { 11066 if (this.isShown) { 11067 $(window).on('resize.bs.modal', $.proxy(this.handleUpdate, this)) 11068 } else { 11069 $(window).off('resize.bs.modal') 11070 } 11071 } 11072 11073 Modal.prototype.hideModal = function () { 11074 var that = this 11075 this.$element.hide() 11076 this.backdrop(function () { 11077 that.$body.removeClass('modal-open') 11078 that.resetAdjustments() 11079 that.resetScrollbar() 11080 that.$element.trigger('hidden.bs.modal') 11081 }) 11082 } 11083 11084 Modal.prototype.removeBackdrop = function () { 11085 this.$backdrop && this.$backdrop.remove() 11086 this.$backdrop = null 11087 } 11088 11089 Modal.prototype.backdrop = function (callback) { 11090 var that = this 11091 var animate = this.$element.hasClass('fade') ? 'fade' : '' 11092 11093 if (this.isShown && this.options.backdrop) { 11094 var doAnimate = $.support.transition && animate 11095 11096 this.$backdrop = $(document.createElement('div')) 11097 .addClass('modal-backdrop ' + animate) 11098 .appendTo(this.$body) 11099 11100 this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) { 11101 if (this.ignoreBackdropClick) { 11102 this.ignoreBackdropClick = false 11103 return 11104 } 11105 if (e.target !== e.currentTarget) return 11106 this.options.backdrop == 'static' 11107 ? this.$element[0].focus() 11108 : this.hide() 11109 }, this)) 11110 11111 if (doAnimate) this.$backdrop[0].offsetWidth // force reflow 11112 11113 this.$backdrop.addClass('in') 11114 11115 if (!callback) return 11116 11117 doAnimate ? 11118 this.$backdrop 11119 .one('bsTransitionEnd', callback) 11120 .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) : 11121 callback() 11122 11123 } else if (!this.isShown && this.$backdrop) { 11124 this.$backdrop.removeClass('in') 11125 11126 var callbackRemove = function () { 11127 that.removeBackdrop() 11128 callback && callback() 11129 } 11130 $.support.transition && this.$element.hasClass('fade') ? 11131 this.$backdrop 11132 .one('bsTransitionEnd', callbackRemove) 11133 .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) : 11134 callbackRemove() 11135 11136 } else if (callback) { 11137 callback() 11138 } 11139 } 11140 11141 // these following methods are used to handle overflowing modals 11142 11143 Modal.prototype.handleUpdate = function () { 11144 this.adjustDialog() 11145 } 11146 11147 Modal.prototype.adjustDialog = function () { 11148 var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight 11149 11150 this.$element.css({ 11151 paddingLeft: !this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : '', 11152 paddingRight: this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : '' 11153 }) 11154 } 11155 11156 Modal.prototype.resetAdjustments = function () { 11157 this.$element.css({ 11158 paddingLeft: '', 11159 paddingRight: '' 11160 }) 11161 } 11162 11163 Modal.prototype.checkScrollbar = function () { 11164 var fullWindowWidth = window.innerWidth 11165 if (!fullWindowWidth) { // workaround for missing window.innerWidth in IE8 11166 var documentElementRect = document.documentElement.getBoundingClientRect() 11167 fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left) 11168 } 11169 this.bodyIsOverflowing = document.body.clientWidth < fullWindowWidth 11170 this.scrollbarWidth = this.measureScrollbar() 11171 } 11172 11173 Modal.prototype.setScrollbar = function () { 11174 var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10) 11175 this.originalBodyPad = document.body.style.paddingRight || '' 11176 if (this.bodyIsOverflowing) this.$body.css('padding-right', bodyPad + this.scrollbarWidth) 11177 } 11178 11179 Modal.prototype.resetScrollbar = function () { 11180 this.$body.css('padding-right', this.originalBodyPad) 11181 } 11182 11183 Modal.prototype.measureScrollbar = function () { // thx walsh 11184 var scrollDiv = document.createElement('div') 11185 scrollDiv.className = 'modal-scrollbar-measure' 11186 this.$body.append(scrollDiv) 11187 var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth 11188 this.$body[0].removeChild(scrollDiv) 11189 return scrollbarWidth 11190 } 11191 11192 11193 // MODAL PLUGIN DEFINITION 11194 // ======================= 11195 11196 function Plugin(option, _relatedTarget) { 11197 return this.each(function () { 11198 var $this = $(this) 11199 var data = $this.data('bs.modal') 11200 var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option) 11201 11202 if (!data) $this.data('bs.modal', (data = new Modal(this, options))) 11203 if (typeof option == 'string') data[option](_relatedTarget) 11204 else if (options.show) data.show(_relatedTarget) 11205 }) 11206 } 11207 11208 var old = $.fn.modal 11209 11210 $.fn.modal = Plugin 11211 $.fn.modal.Constructor = Modal 11212 11213 11214 // MODAL NO CONFLICT 11215 // ================= 11216 11217 $.fn.modal.noConflict = function () { 11218 $.fn.modal = old 11219 return this 11220 } 11221 11222 11223 // MODAL DATA-API 11224 // ============== 11225 11226 $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) { 11227 var $this = $(this) 11228 var href = $this.attr('href') 11229 var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7 11230 var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data()) 11231 11232 if ($this.is('a')) e.preventDefault() 11233 11234 $target.one('show.bs.modal', function (showEvent) { 11235 if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown 11236 $target.one('hidden.bs.modal', function () { 11237 $this.is(':visible') && $this.trigger('focus') 11238 }) 11239 }) 11240 Plugin.call($target, option, this) 11241 }) 11242 11243 }(jQuery); 11244 11245 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71))) 11246 11247 /***/ }, 11248 /* 80 */ 11249 /***/ function(module, exports, __webpack_require__) { 11250 11251 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 11252 * Bootstrap: tooltip.js v3.3.7 11253 * http://getbootstrap.com/javascript/#tooltip 11254 * Inspired by the original jQuery.tipsy by Jason Frame 11255 * ======================================================================== 11256 * Copyright 2011-2016 Twitter, Inc. 11257 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 11258 * ======================================================================== */ 11259 11260 11261 +function ($) { 11262 'use strict'; 11263 11264 // TOOLTIP PUBLIC CLASS DEFINITION 11265 // =============================== 11266 11267 var Tooltip = function (element, options) { 11268 this.type = null 11269 this.options = null 11270 this.enabled = null 11271 this.timeout = null 11272 this.hoverState = null 11273 this.$element = null 11274 this.inState = null 11275 11276 this.init('tooltip', element, options) 11277 } 11278 11279 Tooltip.VERSION = '3.3.7' 11280 11281 Tooltip.TRANSITION_DURATION = 150 11282 11283 Tooltip.DEFAULTS = { 11284 animation: true, 11285 placement: 'top', 11286 selector: false, 11287 template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>', 11288 trigger: 'hover focus', 11289 title: '', 11290 delay: 0, 11291 html: false, 11292 container: false, 11293 viewport: { 11294 selector: 'body', 11295 padding: 0 11296 } 11297 } 11298 11299 Tooltip.prototype.init = function (type, element, options) { 11300 this.enabled = true 11301 this.type = type 11302 this.$element = $(element) 11303 this.options = this.getOptions(options) 11304 this.$viewport = this.options.viewport && $($.isFunction(this.options.viewport) ? this.options.viewport.call(this, this.$element) : (this.options.viewport.selector || this.options.viewport)) 11305 this.inState = { click: false, hover: false, focus: false } 11306 11307 if (this.$element[0] instanceof document.constructor && !this.options.selector) { 11308 throw new Error('`selector` option must be specified when initializing ' + this.type + ' on the window.document object!') 11309 } 11310 11311 var triggers = this.options.trigger.split(' ') 11312 11313 for (var i = triggers.length; i--;) { 11314 var trigger = triggers[i] 11315 11316 if (trigger == 'click') { 11317 this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this)) 11318 } else if (trigger != 'manual') { 11319 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin' 11320 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout' 11321 11322 this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this)) 11323 this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this)) 11324 } 11325 } 11326 11327 this.options.selector ? 11328 (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) : 11329 this.fixTitle() 11330 } 11331 11332 Tooltip.prototype.getDefaults = function () { 11333 return Tooltip.DEFAULTS 11334 } 11335 11336 Tooltip.prototype.getOptions = function (options) { 11337 options = $.extend({}, this.getDefaults(), this.$element.data(), options) 11338 11339 if (options.delay && typeof options.delay == 'number') { 11340 options.delay = { 11341 show: options.delay, 11342 hide: options.delay 11343 } 11344 } 11345 11346 return options 11347 } 11348 11349 Tooltip.prototype.getDelegateOptions = function () { 11350 var options = {} 11351 var defaults = this.getDefaults() 11352 11353 this._options && $.each(this._options, function (key, value) { 11354 if (defaults[key] != value) options[key] = value 11355 }) 11356 11357 return options 11358 } 11359 11360 Tooltip.prototype.enter = function (obj) { 11361 var self = obj instanceof this.constructor ? 11362 obj : $(obj.currentTarget).data('bs.' + this.type) 11363 11364 if (!self) { 11365 self = new this.constructor(obj.currentTarget, this.getDelegateOptions()) 11366 $(obj.currentTarget).data('bs.' + this.type, self) 11367 } 11368 11369 if (obj instanceof $.Event) { 11370 self.inState[obj.type == 'focusin' ? 'focus' : 'hover'] = true 11371 } 11372 11373 if (self.tip().hasClass('in') || self.hoverState == 'in') { 11374 self.hoverState = 'in' 11375 return 11376 } 11377 11378 clearTimeout(self.timeout) 11379 11380 self.hoverState = 'in' 11381 11382 if (!self.options.delay || !self.options.delay.show) return self.show() 11383 11384 self.timeout = setTimeout(function () { 11385 if (self.hoverState == 'in') self.show() 11386 }, self.options.delay.show) 11387 } 11388 11389 Tooltip.prototype.isInStateTrue = function () { 11390 for (var key in this.inState) { 11391 if (this.inState[key]) return true 11392 } 11393 11394 return false 11395 } 11396 11397 Tooltip.prototype.leave = function (obj) { 11398 var self = obj instanceof this.constructor ? 11399 obj : $(obj.currentTarget).data('bs.' + this.type) 11400 11401 if (!self) { 11402 self = new this.constructor(obj.currentTarget, this.getDelegateOptions()) 11403 $(obj.currentTarget).data('bs.' + this.type, self) 11404 } 11405 11406 if (obj instanceof $.Event) { 11407 self.inState[obj.type == 'focusout' ? 'focus' : 'hover'] = false 11408 } 11409 11410 if (self.isInStateTrue()) return 11411 11412 clearTimeout(self.timeout) 11413 11414 self.hoverState = 'out' 11415 11416 if (!self.options.delay || !self.options.delay.hide) return self.hide() 11417 11418 self.timeout = setTimeout(function () { 11419 if (self.hoverState == 'out') self.hide() 11420 }, self.options.delay.hide) 11421 } 11422 11423 Tooltip.prototype.show = function () { 11424 var e = $.Event('show.bs.' + this.type) 11425 11426 if (this.hasContent() && this.enabled) { 11427 this.$element.trigger(e) 11428 11429 var inDom = $.contains(this.$element[0].ownerDocument.documentElement, this.$element[0]) 11430 if (e.isDefaultPrevented() || !inDom) return 11431 var that = this 11432 11433 var $tip = this.tip() 11434 11435 var tipId = this.getUID(this.type) 11436 11437 this.setContent() 11438 $tip.attr('id', tipId) 11439 this.$element.attr('aria-describedby', tipId) 11440 11441 if (this.options.animation) $tip.addClass('fade') 11442 11443 var placement = typeof this.options.placement == 'function' ? 11444 this.options.placement.call(this, $tip[0], this.$element[0]) : 11445 this.options.placement 11446 11447 var autoToken = /\s?auto?\s?/i 11448 var autoPlace = autoToken.test(placement) 11449 if (autoPlace) placement = placement.replace(autoToken, '') || 'top' 11450 11451 $tip 11452 .detach() 11453 .css({ top: 0, left: 0, display: 'block' }) 11454 .addClass(placement) 11455 .data('bs.' + this.type, this) 11456 11457 this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element) 11458 this.$element.trigger('inserted.bs.' + this.type) 11459 11460 var pos = this.getPosition() 11461 var actualWidth = $tip[0].offsetWidth 11462 var actualHeight = $tip[0].offsetHeight 11463 11464 if (autoPlace) { 11465 var orgPlacement = placement 11466 var viewportDim = this.getPosition(this.$viewport) 11467 11468 placement = placement == 'bottom' && pos.bottom + actualHeight > viewportDim.bottom ? 'top' : 11469 placement == 'top' && pos.top - actualHeight < viewportDim.top ? 'bottom' : 11470 placement == 'right' && pos.right + actualWidth > viewportDim.width ? 'left' : 11471 placement == 'left' && pos.left - actualWidth < viewportDim.left ? 'right' : 11472 placement 11473 11474 $tip 11475 .removeClass(orgPlacement) 11476 .addClass(placement) 11477 } 11478 11479 var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight) 11480 11481 this.applyPlacement(calculatedOffset, placement) 11482 11483 var complete = function () { 11484 var prevHoverState = that.hoverState 11485 that.$element.trigger('shown.bs.' + that.type) 11486 that.hoverState = null 11487 11488 if (prevHoverState == 'out') that.leave(that) 11489 } 11490 11491 $.support.transition && this.$tip.hasClass('fade') ? 11492 $tip 11493 .one('bsTransitionEnd', complete) 11494 .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) : 11495 complete() 11496 } 11497 } 11498 11499 Tooltip.prototype.applyPlacement = function (offset, placement) { 11500 var $tip = this.tip() 11501 var width = $tip[0].offsetWidth 11502 var height = $tip[0].offsetHeight 11503 11504 // manually read margins because getBoundingClientRect includes difference 11505 var marginTop = parseInt($tip.css('margin-top'), 10) 11506 var marginLeft = parseInt($tip.css('margin-left'), 10) 11507 11508 // we must check for NaN for ie 8/9 11509 if (isNaN(marginTop)) marginTop = 0 11510 if (isNaN(marginLeft)) marginLeft = 0 11511 11512 offset.top += marginTop 11513 offset.left += marginLeft 11514 11515 // $.fn.offset doesn't round pixel values 11516 // so we use setOffset directly with our own function B-0 11517 $.offset.setOffset($tip[0], $.extend({ 11518 using: function (props) { 11519 $tip.css({ 11520 top: Math.round(props.top), 11521 left: Math.round(props.left) 11522 }) 11523 } 11524 }, offset), 0) 11525 11526 $tip.addClass('in') 11527 11528 // check to see if placing tip in new offset caused the tip to resize itself 11529 var actualWidth = $tip[0].offsetWidth 11530 var actualHeight = $tip[0].offsetHeight 11531 11532 if (placement == 'top' && actualHeight != height) { 11533 offset.top = offset.top + height - actualHeight 11534 } 11535 11536 var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight) 11537 11538 if (delta.left) offset.left += delta.left 11539 else offset.top += delta.top 11540 11541 var isVertical = /top|bottom/.test(placement) 11542 var arrowDelta = isVertical ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight 11543 var arrowOffsetPosition = isVertical ? 'offsetWidth' : 'offsetHeight' 11544 11545 $tip.offset(offset) 11546 this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], isVertical) 11547 } 11548 11549 Tooltip.prototype.replaceArrow = function (delta, dimension, isVertical) { 11550 this.arrow() 11551 .css(isVertical ? 'left' : 'top', 50 * (1 - delta / dimension) + '%') 11552 .css(isVertical ? 'top' : 'left', '') 11553 } 11554 11555 Tooltip.prototype.setContent = function () { 11556 var $tip = this.tip() 11557 var title = this.getTitle() 11558 11559 $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title) 11560 $tip.removeClass('fade in top bottom left right') 11561 } 11562 11563 Tooltip.prototype.hide = function (callback) { 11564 var that = this 11565 var $tip = $(this.$tip) 11566 var e = $.Event('hide.bs.' + this.type) 11567 11568 function complete() { 11569 if (that.hoverState != 'in') $tip.detach() 11570 if (that.$element) { // TODO: Check whether guarding this code with this `if` is really necessary. 11571 that.$element 11572 .removeAttr('aria-describedby') 11573 .trigger('hidden.bs.' + that.type) 11574 } 11575 callback && callback() 11576 } 11577 11578 this.$element.trigger(e) 11579 11580 if (e.isDefaultPrevented()) return 11581 11582 $tip.removeClass('in') 11583 11584 $.support.transition && $tip.hasClass('fade') ? 11585 $tip 11586 .one('bsTransitionEnd', complete) 11587 .emulateTransitionEnd(Tooltip.TRANSITION_DURATION) : 11588 complete() 11589 11590 this.hoverState = null 11591 11592 return this 11593 } 11594 11595 Tooltip.prototype.fixTitle = function () { 11596 var $e = this.$element 11597 if ($e.attr('title') || typeof $e.attr('data-original-title') != 'string') { 11598 $e.attr('data-original-title', $e.attr('title') || '').attr('title', '') 11599 } 11600 } 11601 11602 Tooltip.prototype.hasContent = function () { 11603 return this.getTitle() 11604 } 11605 11606 Tooltip.prototype.getPosition = function ($element) { 11607 $element = $element || this.$element 11608 11609 var el = $element[0] 11610 var isBody = el.tagName == 'BODY' 11611 11612 var elRect = el.getBoundingClientRect() 11613 if (elRect.width == null) { 11614 // width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093 11615 elRect = $.extend({}, elRect, { width: elRect.right - elRect.left, height: elRect.bottom - elRect.top }) 11616 } 11617 var isSvg = window.SVGElement && el instanceof window.SVGElement 11618 // Avoid using $.offset() on SVGs since it gives incorrect results in jQuery 3. 11619 // See https://github.com/twbs/bootstrap/issues/20280 11620 var elOffset = isBody ? { top: 0, left: 0 } : (isSvg ? null : $element.offset()) 11621 var scroll = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() } 11622 var outerDims = isBody ? { width: $(window).width(), height: $(window).height() } : null 11623 11624 return $.extend({}, elRect, scroll, outerDims, elOffset) 11625 } 11626 11627 Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) { 11628 return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } : 11629 placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } : 11630 placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } : 11631 /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width } 11632 11633 } 11634 11635 Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) { 11636 var delta = { top: 0, left: 0 } 11637 if (!this.$viewport) return delta 11638 11639 var viewportPadding = this.options.viewport && this.options.viewport.padding || 0 11640 var viewportDimensions = this.getPosition(this.$viewport) 11641 11642 if (/right|left/.test(placement)) { 11643 var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll 11644 var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight 11645 if (topEdgeOffset < viewportDimensions.top) { // top overflow 11646 delta.top = viewportDimensions.top - topEdgeOffset 11647 } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow 11648 delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset 11649 } 11650 } else { 11651 var leftEdgeOffset = pos.left - viewportPadding 11652 var rightEdgeOffset = pos.left + viewportPadding + actualWidth 11653 if (leftEdgeOffset < viewportDimensions.left) { // left overflow 11654 delta.left = viewportDimensions.left - leftEdgeOffset 11655 } else if (rightEdgeOffset > viewportDimensions.right) { // right overflow 11656 delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset 11657 } 11658 } 11659 11660 return delta 11661 } 11662 11663 Tooltip.prototype.getTitle = function () { 11664 var title 11665 var $e = this.$element 11666 var o = this.options 11667 11668 title = $e.attr('data-original-title') 11669 || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title) 11670 11671 return title 11672 } 11673 11674 Tooltip.prototype.getUID = function (prefix) { 11675 do prefix += ~~(Math.random() * 1000000) 11676 while (document.getElementById(prefix)) 11677 return prefix 11678 } 11679 11680 Tooltip.prototype.tip = function () { 11681 if (!this.$tip) { 11682 this.$tip = $(this.options.template) 11683 if (this.$tip.length != 1) { 11684 throw new Error(this.type + ' `template` option must consist of exactly 1 top-level element!') 11685 } 11686 } 11687 return this.$tip 11688 } 11689 11690 Tooltip.prototype.arrow = function () { 11691 return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')) 11692 } 11693 11694 Tooltip.prototype.enable = function () { 11695 this.enabled = true 11696 } 11697 11698 Tooltip.prototype.disable = function () { 11699 this.enabled = false 11700 } 11701 11702 Tooltip.prototype.toggleEnabled = function () { 11703 this.enabled = !this.enabled 11704 } 11705 11706 Tooltip.prototype.toggle = function (e) { 11707 var self = this 11708 if (e) { 11709 self = $(e.currentTarget).data('bs.' + this.type) 11710 if (!self) { 11711 self = new this.constructor(e.currentTarget, this.getDelegateOptions()) 11712 $(e.currentTarget).data('bs.' + this.type, self) 11713 } 11714 } 11715 11716 if (e) { 11717 self.inState.click = !self.inState.click 11718 if (self.isInStateTrue()) self.enter(self) 11719 else self.leave(self) 11720 } else { 11721 self.tip().hasClass('in') ? self.leave(self) : self.enter(self) 11722 } 11723 } 11724 11725 Tooltip.prototype.destroy = function () { 11726 var that = this 11727 clearTimeout(this.timeout) 11728 this.hide(function () { 11729 that.$element.off('.' + that.type).removeData('bs.' + that.type) 11730 if (that.$tip) { 11731 that.$tip.detach() 11732 } 11733 that.$tip = null 11734 that.$arrow = null 11735 that.$viewport = null 11736 that.$element = null 11737 }) 11738 } 11739 11740 11741 // TOOLTIP PLUGIN DEFINITION 11742 // ========================= 11743 11744 function Plugin(option) { 11745 return this.each(function () { 11746 var $this = $(this) 11747 var data = $this.data('bs.tooltip') 11748 var options = typeof option == 'object' && option 11749 11750 if (!data && /destroy|hide/.test(option)) return 11751 if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options))) 11752 if (typeof option == 'string') data[option]() 11753 }) 11754 } 11755 11756 var old = $.fn.tooltip 11757 11758 $.fn.tooltip = Plugin 11759 $.fn.tooltip.Constructor = Tooltip 11760 11761 11762 // TOOLTIP NO CONFLICT 11763 // =================== 11764 11765 $.fn.tooltip.noConflict = function () { 11766 $.fn.tooltip = old 11767 return this 11768 } 11769 11770 }(jQuery); 11771 11772 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71))) 11773 11774 /***/ }, 11775 /* 81 */ 11776 /***/ function(module, exports, __webpack_require__) { 11777 11778 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 11779 * Bootstrap: popover.js v3.3.7 11780 * http://getbootstrap.com/javascript/#popovers 11781 * ======================================================================== 11782 * Copyright 2011-2016 Twitter, Inc. 11783 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 11784 * ======================================================================== */ 11785 11786 11787 +function ($) { 11788 'use strict'; 11789 11790 // POPOVER PUBLIC CLASS DEFINITION 11791 // =============================== 11792 11793 var Popover = function (element, options) { 11794 this.init('popover', element, options) 11795 } 11796 11797 if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js') 11798 11799 Popover.VERSION = '3.3.7' 11800 11801 Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, { 11802 placement: 'right', 11803 trigger: 'click', 11804 content: '', 11805 template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>' 11806 }) 11807 11808 11809 // NOTE: POPOVER EXTENDS tooltip.js 11810 // ================================ 11811 11812 Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype) 11813 11814 Popover.prototype.constructor = Popover 11815 11816 Popover.prototype.getDefaults = function () { 11817 return Popover.DEFAULTS 11818 } 11819 11820 Popover.prototype.setContent = function () { 11821 var $tip = this.tip() 11822 var title = this.getTitle() 11823 var content = this.getContent() 11824 11825 $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title) 11826 $tip.find('.popover-content').children().detach().end()[ // we use append for html objects to maintain js events 11827 this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text' 11828 ](content) 11829 11830 $tip.removeClass('fade top bottom left right in') 11831 11832 // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do 11833 // this manually by checking the contents. 11834 if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide() 11835 } 11836 11837 Popover.prototype.hasContent = function () { 11838 return this.getTitle() || this.getContent() 11839 } 11840 11841 Popover.prototype.getContent = function () { 11842 var $e = this.$element 11843 var o = this.options 11844 11845 return $e.attr('data-content') 11846 || (typeof o.content == 'function' ? 11847 o.content.call($e[0]) : 11848 o.content) 11849 } 11850 11851 Popover.prototype.arrow = function () { 11852 return (this.$arrow = this.$arrow || this.tip().find('.arrow')) 11853 } 11854 11855 11856 // POPOVER PLUGIN DEFINITION 11857 // ========================= 11858 11859 function Plugin(option) { 11860 return this.each(function () { 11861 var $this = $(this) 11862 var data = $this.data('bs.popover') 11863 var options = typeof option == 'object' && option 11864 11865 if (!data && /destroy|hide/.test(option)) return 11866 if (!data) $this.data('bs.popover', (data = new Popover(this, options))) 11867 if (typeof option == 'string') data[option]() 11868 }) 11869 } 11870 11871 var old = $.fn.popover 11872 11873 $.fn.popover = Plugin 11874 $.fn.popover.Constructor = Popover 11875 11876 11877 // POPOVER NO CONFLICT 11878 // =================== 11879 11880 $.fn.popover.noConflict = function () { 11881 $.fn.popover = old 11882 return this 11883 } 11884 11885 }(jQuery); 11886 11887 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71))) 11888 11889 /***/ }, 11890 /* 82 */ 11891 /***/ function(module, exports, __webpack_require__) { 11892 11893 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 11894 * Bootstrap: scrollspy.js v3.3.7 11895 * http://getbootstrap.com/javascript/#scrollspy 11896 * ======================================================================== 11897 * Copyright 2011-2016 Twitter, Inc. 11898 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 11899 * ======================================================================== */ 11900 11901 11902 +function ($) { 11903 'use strict'; 11904 11905 // SCROLLSPY CLASS DEFINITION 11906 // ========================== 11907 11908 function ScrollSpy(element, options) { 11909 this.$body = $(document.body) 11910 this.$scrollElement = $(element).is(document.body) ? $(window) : $(element) 11911 this.options = $.extend({}, ScrollSpy.DEFAULTS, options) 11912 this.selector = (this.options.target || '') + ' .nav li > a' 11913 this.offsets = [] 11914 this.targets = [] 11915 this.activeTarget = null 11916 this.scrollHeight = 0 11917 11918 this.$scrollElement.on('scroll.bs.scrollspy', $.proxy(this.process, this)) 11919 this.refresh() 11920 this.process() 11921 } 11922 11923 ScrollSpy.VERSION = '3.3.7' 11924 11925 ScrollSpy.DEFAULTS = { 11926 offset: 10 11927 } 11928 11929 ScrollSpy.prototype.getScrollHeight = function () { 11930 return this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight) 11931 } 11932 11933 ScrollSpy.prototype.refresh = function () { 11934 var that = this 11935 var offsetMethod = 'offset' 11936 var offsetBase = 0 11937 11938 this.offsets = [] 11939 this.targets = [] 11940 this.scrollHeight = this.getScrollHeight() 11941 11942 if (!$.isWindow(this.$scrollElement[0])) { 11943 offsetMethod = 'position' 11944 offsetBase = this.$scrollElement.scrollTop() 11945 } 11946 11947 this.$body 11948 .find(this.selector) 11949 .map(function () { 11950 var $el = $(this) 11951 var href = $el.data('target') || $el.attr('href') 11952 var $href = /^#./.test(href) && $(href) 11953 11954 return ($href 11955 && $href.length 11956 && $href.is(':visible') 11957 && [[$href[offsetMethod]().top + offsetBase, href]]) || null 11958 }) 11959 .sort(function (a, b) { return a[0] - b[0] }) 11960 .each(function () { 11961 that.offsets.push(this[0]) 11962 that.targets.push(this[1]) 11963 }) 11964 } 11965 11966 ScrollSpy.prototype.process = function () { 11967 var scrollTop = this.$scrollElement.scrollTop() + this.options.offset 11968 var scrollHeight = this.getScrollHeight() 11969 var maxScroll = this.options.offset + scrollHeight - this.$scrollElement.height() 11970 var offsets = this.offsets 11971 var targets = this.targets 11972 var activeTarget = this.activeTarget 11973 var i 11974 11975 if (this.scrollHeight != scrollHeight) { 11976 this.refresh() 11977 } 11978 11979 if (scrollTop >= maxScroll) { 11980 return activeTarget != (i = targets[targets.length - 1]) && this.activate(i) 11981 } 11982 11983 if (activeTarget && scrollTop < offsets[0]) { 11984 this.activeTarget = null 11985 return this.clear() 11986 } 11987 11988 for (i = offsets.length; i--;) { 11989 activeTarget != targets[i] 11990 && scrollTop >= offsets[i] 11991 && (offsets[i + 1] === undefined || scrollTop < offsets[i + 1]) 11992 && this.activate(targets[i]) 11993 } 11994 } 11995 11996 ScrollSpy.prototype.activate = function (target) { 11997 this.activeTarget = target 11998 11999 this.clear() 12000 12001 var selector = this.selector + 12002 '[data-target="' + target + '"],' + 12003 this.selector + '[href="' + target + '"]' 12004 12005 var active = $(selector) 12006 .parents('li') 12007 .addClass('active') 12008 12009 if (active.parent('.dropdown-menu').length) { 12010 active = active 12011 .closest('li.dropdown') 12012 .addClass('active') 12013 } 12014 12015 active.trigger('activate.bs.scrollspy') 12016 } 12017 12018 ScrollSpy.prototype.clear = function () { 12019 $(this.selector) 12020 .parentsUntil(this.options.target, '.active') 12021 .removeClass('active') 12022 } 12023 12024 12025 // SCROLLSPY PLUGIN DEFINITION 12026 // =========================== 12027 12028 function Plugin(option) { 12029 return this.each(function () { 12030 var $this = $(this) 12031 var data = $this.data('bs.scrollspy') 12032 var options = typeof option == 'object' && option 12033 12034 if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options))) 12035 if (typeof option == 'string') data[option]() 12036 }) 12037 } 12038 12039 var old = $.fn.scrollspy 12040 12041 $.fn.scrollspy = Plugin 12042 $.fn.scrollspy.Constructor = ScrollSpy 12043 12044 12045 // SCROLLSPY NO CONFLICT 12046 // ===================== 12047 12048 $.fn.scrollspy.noConflict = function () { 12049 $.fn.scrollspy = old 12050 return this 12051 } 12052 12053 12054 // SCROLLSPY DATA-API 12055 // ================== 12056 12057 $(window).on('load.bs.scrollspy.data-api', function () { 12058 $('[data-spy="scroll"]').each(function () { 12059 var $spy = $(this) 12060 Plugin.call($spy, $spy.data()) 12061 }) 12062 }) 12063 12064 }(jQuery); 12065 12066 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71))) 12067 12068 /***/ }, 12069 /* 83 */ 12070 /***/ function(module, exports, __webpack_require__) { 12071 12072 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 12073 * Bootstrap: tab.js v3.3.7 12074 * http://getbootstrap.com/javascript/#tabs 12075 * ======================================================================== 12076 * Copyright 2011-2016 Twitter, Inc. 12077 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 12078 * ======================================================================== */ 12079 12080 12081 +function ($) { 12082 'use strict'; 12083 12084 // TAB CLASS DEFINITION 12085 // ==================== 12086 12087 var Tab = function (element) { 12088 // jscs:disable requireDollarBeforejQueryAssignment 12089 this.element = $(element) 12090 // jscs:enable requireDollarBeforejQueryAssignment 12091 } 12092 12093 Tab.VERSION = '3.3.7' 12094 12095 Tab.TRANSITION_DURATION = 150 12096 12097 Tab.prototype.show = function () { 12098 var $this = this.element 12099 var $ul = $this.closest('ul:not(.dropdown-menu)') 12100 var selector = $this.data('target') 12101 12102 if (!selector) { 12103 selector = $this.attr('href') 12104 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 12105 } 12106 12107 if ($this.parent('li').hasClass('active')) return 12108 12109 var $previous = $ul.find('.active:last a') 12110 var hideEvent = $.Event('hide.bs.tab', { 12111 relatedTarget: $this[0] 12112 }) 12113 var showEvent = $.Event('show.bs.tab', { 12114 relatedTarget: $previous[0] 12115 }) 12116 12117 $previous.trigger(hideEvent) 12118 $this.trigger(showEvent) 12119 12120 if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) return 12121 12122 var $target = $(selector) 12123 12124 this.activate($this.closest('li'), $ul) 12125 this.activate($target, $target.parent(), function () { 12126 $previous.trigger({ 12127 type: 'hidden.bs.tab', 12128 relatedTarget: $this[0] 12129 }) 12130 $this.trigger({ 12131 type: 'shown.bs.tab', 12132 relatedTarget: $previous[0] 12133 }) 12134 }) 12135 } 12136 12137 Tab.prototype.activate = function (element, container, callback) { 12138 var $active = container.find('> .active') 12139 var transition = callback 12140 && $.support.transition 12141 && ($active.length && $active.hasClass('fade') || !!container.find('> .fade').length) 12142 12143 function next() { 12144 $active 12145 .removeClass('active') 12146 .find('> .dropdown-menu > .active') 12147 .removeClass('active') 12148 .end() 12149 .find('[data-toggle="tab"]') 12150 .attr('aria-expanded', false) 12151 12152 element 12153 .addClass('active') 12154 .find('[data-toggle="tab"]') 12155 .attr('aria-expanded', true) 12156 12157 if (transition) { 12158 element[0].offsetWidth // reflow for transition 12159 element.addClass('in') 12160 } else { 12161 element.removeClass('fade') 12162 } 12163 12164 if (element.parent('.dropdown-menu').length) { 12165 element 12166 .closest('li.dropdown') 12167 .addClass('active') 12168 .end() 12169 .find('[data-toggle="tab"]') 12170 .attr('aria-expanded', true) 12171 } 12172 12173 callback && callback() 12174 } 12175 12176 $active.length && transition ? 12177 $active 12178 .one('bsTransitionEnd', next) 12179 .emulateTransitionEnd(Tab.TRANSITION_DURATION) : 12180 next() 12181 12182 $active.removeClass('in') 12183 } 12184 12185 12186 // TAB PLUGIN DEFINITION 12187 // ===================== 12188 12189 function Plugin(option) { 12190 return this.each(function () { 12191 var $this = $(this) 12192 var data = $this.data('bs.tab') 12193 12194 if (!data) $this.data('bs.tab', (data = new Tab(this))) 12195 if (typeof option == 'string') data[option]() 12196 }) 12197 } 12198 12199 var old = $.fn.tab 12200 12201 $.fn.tab = Plugin 12202 $.fn.tab.Constructor = Tab 12203 12204 12205 // TAB NO CONFLICT 12206 // =============== 12207 12208 $.fn.tab.noConflict = function () { 12209 $.fn.tab = old 12210 return this 12211 } 12212 12213 12214 // TAB DATA-API 12215 // ============ 12216 12217 var clickHandler = function (e) { 12218 e.preventDefault() 12219 Plugin.call($(this), 'show') 12220 } 12221 12222 $(document) 12223 .on('click.bs.tab.data-api', '[data-toggle="tab"]', clickHandler) 12224 .on('click.bs.tab.data-api', '[data-toggle="pill"]', clickHandler) 12225 12226 }(jQuery); 12227 12228 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71))) 12229 12230 /***/ }, 12231 /* 84 */ 12232 /***/ function(module, exports, __webpack_require__) { 12233 12234 /* WEBPACK VAR INJECTION */(function(jQuery) {/* ======================================================================== 12235 * Bootstrap: affix.js v3.3.7 12236 * http://getbootstrap.com/javascript/#affix 12237 * ======================================================================== 12238 * Copyright 2011-2016 Twitter, Inc. 12239 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 12240 * ======================================================================== */ 12241 12242 12243 +function ($) { 12244 'use strict'; 12245 12246 // AFFIX CLASS DEFINITION 12247 // ====================== 12248 12249 var Affix = function (element, options) { 12250 this.options = $.extend({}, Affix.DEFAULTS, options) 12251 12252 this.$target = $(this.options.target) 12253 .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this)) 12254 .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this)) 12255 12256 this.$element = $(element) 12257 this.affixed = null 12258 this.unpin = null 12259 this.pinnedOffset = null 12260 12261 this.checkPosition() 12262 } 12263 12264 Affix.VERSION = '3.3.7' 12265 12266 Affix.RESET = 'affix affix-top affix-bottom' 12267 12268 Affix.DEFAULTS = { 12269 offset: 0, 12270 target: window 12271 } 12272 12273 Affix.prototype.getState = function (scrollHeight, height, offsetTop, offsetBottom) { 12274 var scrollTop = this.$target.scrollTop() 12275 var position = this.$element.offset() 12276 var targetHeight = this.$target.height() 12277 12278 if (offsetTop != null && this.affixed == 'top') return scrollTop < offsetTop ? 'top' : false 12279 12280 if (this.affixed == 'bottom') { 12281 if (offsetTop != null) return (scrollTop + this.unpin <= position.top) ? false : 'bottom' 12282 return (scrollTop + targetHeight <= scrollHeight - offsetBottom) ? false : 'bottom' 12283 } 12284 12285 var initializing = this.affixed == null 12286 var colliderTop = initializing ? scrollTop : position.top 12287 var colliderHeight = initializing ? targetHeight : height 12288 12289 if (offsetTop != null && scrollTop <= offsetTop) return 'top' 12290 if (offsetBottom != null && (colliderTop + colliderHeight >= scrollHeight - offsetBottom)) return 'bottom' 12291 12292 return false 12293 } 12294 12295 Affix.prototype.getPinnedOffset = function () { 12296 if (this.pinnedOffset) return this.pinnedOffset 12297 this.$element.removeClass(Affix.RESET).addClass('affix') 12298 var scrollTop = this.$target.scrollTop() 12299 var position = this.$element.offset() 12300 return (this.pinnedOffset = position.top - scrollTop) 12301 } 12302 12303 Affix.prototype.checkPositionWithEventLoop = function () { 12304 setTimeout($.proxy(this.checkPosition, this), 1) 12305 } 12306 12307 Affix.prototype.checkPosition = function () { 12308 if (!this.$element.is(':visible')) return 12309 12310 var height = this.$element.height() 12311 var offset = this.options.offset 12312 var offsetTop = offset.top 12313 var offsetBottom = offset.bottom 12314 var scrollHeight = Math.max($(document).height(), $(document.body).height()) 12315 12316 if (typeof offset != 'object') offsetBottom = offsetTop = offset 12317 if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element) 12318 if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element) 12319 12320 var affix = this.getState(scrollHeight, height, offsetTop, offsetBottom) 12321 12322 if (this.affixed != affix) { 12323 if (this.unpin != null) this.$element.css('top', '') 12324 12325 var affixType = 'affix' + (affix ? '-' + affix : '') 12326 var e = $.Event(affixType + '.bs.affix') 12327 12328 this.$element.trigger(e) 12329 12330 if (e.isDefaultPrevented()) return 12331 12332 this.affixed = affix 12333 this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null 12334 12335 this.$element 12336 .removeClass(Affix.RESET) 12337 .addClass(affixType) 12338 .trigger(affixType.replace('affix', 'affixed') + '.bs.affix') 12339 } 12340 12341 if (affix == 'bottom') { 12342 this.$element.offset({ 12343 top: scrollHeight - height - offsetBottom 12344 }) 12345 } 12346 } 12347 12348 12349 // AFFIX PLUGIN DEFINITION 12350 // ======================= 12351 12352 function Plugin(option) { 12353 return this.each(function () { 12354 var $this = $(this) 12355 var data = $this.data('bs.affix') 12356 var options = typeof option == 'object' && option 12357 12358 if (!data) $this.data('bs.affix', (data = new Affix(this, options))) 12359 if (typeof option == 'string') data[option]() 12360 }) 12361 } 12362 12363 var old = $.fn.affix 12364 12365 $.fn.affix = Plugin 12366 $.fn.affix.Constructor = Affix 12367 12368 12369 // AFFIX NO CONFLICT 12370 // ================= 12371 12372 $.fn.affix.noConflict = function () { 12373 $.fn.affix = old 12374 return this 12375 } 12376 12377 12378 // AFFIX DATA-API 12379 // ============== 12380 12381 $(window).on('load', function () { 12382 $('[data-spy="affix"]').each(function () { 12383 var $spy = $(this) 12384 var data = $spy.data() 12385 12386 data.offset = data.offset || {} 12387 12388 if (data.offsetBottom != null) data.offset.bottom = data.offsetBottom 12389 if (data.offsetTop != null) data.offset.top = data.offsetTop 12390 12391 Plugin.call($spy, data) 12392 }) 12393 }) 12394 12395 }(jQuery); 12396 12397 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71))) 12398 12399 /***/ }, 12400 /* 85 */ 12401 /***/ function(module, exports, __webpack_require__) { 12402 12403 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* global define */ 12404 12405 /* ================================================ 12406 * Make use of Bootstrap's modal more monkey-friendly. 12407 * 12408 * For Bootstrap 3. 12409 * 12410 * javanoob@hotmail.com 12411 * 12412 * https://github.com/nakupanda/bootstrap3-dialog 12413 * 12414 * Licensed under The MIT License. 12415 * ================================================ */ 12416 (function(root, factory) { 12417 12418 "use strict"; 12419 12420 // CommonJS module is defined 12421 if (typeof module !== 'undefined' && module.exports) { 12422 module.exports = factory(__webpack_require__(71), __webpack_require__(72)); 12423 } 12424 // AMD module is defined 12425 else if (true) { 12426 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(71), __webpack_require__(72)], __WEBPACK_AMD_DEFINE_RESULT__ = function($) { 12427 return factory($); 12428 }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 12429 } else { 12430 // planted over the root! 12431 root.BootstrapDialog = factory(root.jQuery); 12432 } 12433 12434 }(this, function($) { 12435 12436 "use strict"; 12437 12438 /* ================================================ 12439 * Definition of BootstrapDialogModal. 12440 * Extend Bootstrap Modal and override some functions. 12441 * BootstrapDialogModal === Modified Modal. 12442 * ================================================ */ 12443 var Modal = $.fn.modal.Constructor; 12444 var BootstrapDialogModal = function(element, options) { 12445 Modal.call(this, element, options); 12446 }; 12447 BootstrapDialogModal.getModalVersion = function() { 12448 var version = null; 12449 if (typeof $.fn.modal.Constructor.VERSION === 'undefined') { 12450 version = 'v3.1'; 12451 } else if (/3\.2\.\d+/.test($.fn.modal.Constructor.VERSION)) { 12452 version = 'v3.2'; 12453 } else if (/3\.3\.[1,2]/.test($.fn.modal.Constructor.VERSION)) { 12454 version = 'v3.3'; // v3.3.1, v3.3.2 12455 } else { 12456 version = 'v3.3.4'; 12457 } 12458 12459 return version; 12460 }; 12461 BootstrapDialogModal.ORIGINAL_BODY_PADDING = parseInt(($('body').css('padding-right') || 0), 10); 12462 BootstrapDialogModal.METHODS_TO_OVERRIDE = {}; 12463 BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.1'] = {}; 12464 BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.2'] = { 12465 hide: function(e) { 12466 if (e) { 12467 e.preventDefault(); 12468 } 12469 e = $.Event('hide.bs.modal'); 12470 12471 this.$element.trigger(e); 12472 12473 if (!this.isShown || e.isDefaultPrevented()) { 12474 return; 12475 } 12476 12477 this.isShown = false; 12478 12479 // Remove css class 'modal-open' when the last opened dialog is closing. 12480 var openedDialogs = this.getGlobalOpenedDialogs(); 12481 if (openedDialogs.length === 0) { 12482 this.$body.removeClass('modal-open'); 12483 } 12484 12485 this.resetScrollbar(); 12486 this.escape(); 12487 12488 $(document).off('focusin.bs.modal'); 12489 12490 this.$element 12491 .removeClass('in') 12492 .attr('aria-hidden', true) 12493 .off('click.dismiss.bs.modal'); 12494 12495 $.support.transition && this.$element.hasClass('fade') ? 12496 this.$element 12497 .one('bsTransitionEnd', $.proxy(this.hideModal, this)) 12498 .emulateTransitionEnd(300) : 12499 this.hideModal(); 12500 } 12501 }; 12502 BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3'] = { 12503 /** 12504 * Overrided. 12505 * 12506 * @returns {undefined} 12507 */ 12508 setScrollbar: function() { 12509 var bodyPad = BootstrapDialogModal.ORIGINAL_BODY_PADDING; 12510 if (this.bodyIsOverflowing) { 12511 this.$body.css('padding-right', bodyPad + this.scrollbarWidth); 12512 } 12513 }, 12514 /** 12515 * Overrided. 12516 * 12517 * @returns {undefined} 12518 */ 12519 resetScrollbar: function() { 12520 var openedDialogs = this.getGlobalOpenedDialogs(); 12521 if (openedDialogs.length === 0) { 12522 this.$body.css('padding-right', BootstrapDialogModal.ORIGINAL_BODY_PADDING); 12523 } 12524 }, 12525 /** 12526 * Overrided. 12527 * 12528 * @returns {undefined} 12529 */ 12530 hideModal: function() { 12531 this.$element.hide(); 12532 this.backdrop($.proxy(function() { 12533 var openedDialogs = this.getGlobalOpenedDialogs(); 12534 if (openedDialogs.length === 0) { 12535 this.$body.removeClass('modal-open'); 12536 } 12537 this.resetAdjustments(); 12538 this.resetScrollbar(); 12539 this.$element.trigger('hidden.bs.modal'); 12540 }, this)); 12541 } 12542 }; 12543 BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3.4'] = $.extend({}, BootstrapDialogModal.METHODS_TO_OVERRIDE['v3.3']); 12544 BootstrapDialogModal.prototype = { 12545 constructor: BootstrapDialogModal, 12546 /** 12547 * New function, to get the dialogs that opened by BootstrapDialog. 12548 * 12549 * @returns {undefined} 12550 */ 12551 getGlobalOpenedDialogs: function() { 12552 var openedDialogs = []; 12553 $.each(BootstrapDialog.dialogs, function(id, dialogInstance) { 12554 if (dialogInstance.isRealized() && dialogInstance.isOpened()) { 12555 openedDialogs.push(dialogInstance); 12556 } 12557 }); 12558 12559 return openedDialogs; 12560 } 12561 }; 12562 12563 // Add compatible methods. 12564 BootstrapDialogModal.prototype = $.extend(BootstrapDialogModal.prototype, Modal.prototype, BootstrapDialogModal.METHODS_TO_OVERRIDE[BootstrapDialogModal.getModalVersion()]); 12565 12566 /* ================================================ 12567 * Definition of BootstrapDialog. 12568 * ================================================ */ 12569 var BootstrapDialog = function(options) { 12570 this.defaultOptions = $.extend(true, { 12571 id: BootstrapDialog.newGuid(), 12572 buttons: [], 12573 data: {}, 12574 onshow: null, 12575 onshown: null, 12576 onhide: null, 12577 onhidden: null 12578 }, BootstrapDialog.defaultOptions); 12579 this.indexedButtons = {}; 12580 this.registeredButtonHotkeys = {}; 12581 this.draggableData = { 12582 isMouseDown: false, 12583 mouseOffset: {} 12584 }; 12585 this.realized = false; 12586 this.opened = false; 12587 this.initOptions(options); 12588 this.holdThisInstance(); 12589 }; 12590 12591 BootstrapDialog.BootstrapDialogModal = BootstrapDialogModal; 12592 12593 /** 12594 * Some constants. 12595 */ 12596 BootstrapDialog.NAMESPACE = 'bootstrap-dialog'; 12597 BootstrapDialog.TYPE_DEFAULT = 'type-default'; 12598 BootstrapDialog.TYPE_INFO = 'type-info'; 12599 BootstrapDialog.TYPE_PRIMARY = 'type-primary'; 12600 BootstrapDialog.TYPE_SUCCESS = 'type-success'; 12601 BootstrapDialog.TYPE_WARNING = 'type-warning'; 12602 BootstrapDialog.TYPE_DANGER = 'type-danger'; 12603 BootstrapDialog.DEFAULT_TEXTS = {}; 12604 BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DEFAULT] = 'Information'; 12605 BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_INFO] = 'Information'; 12606 BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_PRIMARY] = 'Information'; 12607 BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_SUCCESS] = 'Success'; 12608 BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_WARNING] = 'Warning'; 12609 BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DANGER] = 'Danger'; 12610 BootstrapDialog.DEFAULT_TEXTS['OK'] = 'OK'; 12611 BootstrapDialog.DEFAULT_TEXTS['CANCEL'] = 'Cancel'; 12612 BootstrapDialog.DEFAULT_TEXTS['CONFIRM'] = 'Confirmation'; 12613 BootstrapDialog.SIZE_NORMAL = 'size-normal'; 12614 BootstrapDialog.SIZE_SMALL = 'size-small'; 12615 BootstrapDialog.SIZE_WIDE = 'size-wide'; // size-wide is equal to modal-lg 12616 BootstrapDialog.SIZE_LARGE = 'size-large'; 12617 BootstrapDialog.BUTTON_SIZES = {}; 12618 BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_NORMAL] = ''; 12619 BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_SMALL] = ''; 12620 BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_WIDE] = ''; 12621 BootstrapDialog.BUTTON_SIZES[BootstrapDialog.SIZE_LARGE] = 'btn-lg'; 12622 BootstrapDialog.ICON_SPINNER = 'glyphicon glyphicon-asterisk'; 12623 12624 /** 12625 * Default options. 12626 */ 12627 BootstrapDialog.defaultOptions = { 12628 type: BootstrapDialog.TYPE_PRIMARY, 12629 size: BootstrapDialog.SIZE_NORMAL, 12630 cssClass: '', 12631 title: null, 12632 message: null, 12633 nl2br: true, 12634 closable: true, 12635 closeByBackdrop: true, 12636 closeByKeyboard: true, 12637 spinicon: BootstrapDialog.ICON_SPINNER, 12638 autodestroy: true, 12639 draggable: false, 12640 animate: true, 12641 description: '', 12642 tabindex: -1 12643 }; 12644 12645 /** 12646 * Config default options. 12647 */ 12648 BootstrapDialog.configDefaultOptions = function(options) { 12649 BootstrapDialog.defaultOptions = $.extend(true, BootstrapDialog.defaultOptions, options); 12650 }; 12651 12652 /** 12653 * Open / Close all created dialogs all at once. 12654 */ 12655 BootstrapDialog.dialogs = {}; 12656 BootstrapDialog.openAll = function() { 12657 $.each(BootstrapDialog.dialogs, function(id, dialogInstance) { 12658 dialogInstance.open(); 12659 }); 12660 }; 12661 BootstrapDialog.closeAll = function() { 12662 $.each(BootstrapDialog.dialogs, function(id, dialogInstance) { 12663 dialogInstance.close(); 12664 }); 12665 }; 12666 12667 /** 12668 * Move focus to next visible dialog. 12669 */ 12670 BootstrapDialog.moveFocus = function() { 12671 var lastDialogInstance = null; 12672 $.each(BootstrapDialog.dialogs, function(id, dialogInstance) { 12673 lastDialogInstance = dialogInstance; 12674 }); 12675 if (lastDialogInstance !== null && lastDialogInstance.isRealized()) { 12676 lastDialogInstance.getModal().focus(); 12677 } 12678 }; 12679 12680 BootstrapDialog.METHODS_TO_OVERRIDE = {}; 12681 BootstrapDialog.METHODS_TO_OVERRIDE['v3.1'] = { 12682 handleModalBackdropEvent: function() { 12683 this.getModal().on('click', {dialog: this}, function(event) { 12684 event.target === this && event.data.dialog.isClosable() && event.data.dialog.canCloseByBackdrop() && event.data.dialog.close(); 12685 }); 12686 12687 return this; 12688 }, 12689 /** 12690 * To make multiple opened dialogs look better. 12691 * 12692 * Will be removed in later version, after Bootstrap Modal >= 3.3.0, updating z-index is unnecessary. 12693 */ 12694 updateZIndex: function() { 12695 var zIndexBackdrop = 1040; 12696 var zIndexModal = 1050; 12697 var dialogCount = 0; 12698 $.each(BootstrapDialog.dialogs, function(dialogId, dialogInstance) { 12699 dialogCount++; 12700 }); 12701 var $modal = this.getModal(); 12702 var $backdrop = $modal.data('bs.modal').$backdrop; 12703 $modal.css('z-index', zIndexModal + (dialogCount - 1) * 20); 12704 $backdrop.css('z-index', zIndexBackdrop + (dialogCount - 1) * 20); 12705 12706 return this; 12707 }, 12708 open: function() { 12709 !this.isRealized() && this.realize(); 12710 this.getModal().modal('show'); 12711 this.updateZIndex(); 12712 12713 return this; 12714 } 12715 }; 12716 BootstrapDialog.METHODS_TO_OVERRIDE['v3.2'] = { 12717 handleModalBackdropEvent: BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']['handleModalBackdropEvent'], 12718 updateZIndex: BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']['updateZIndex'], 12719 open: BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']['open'] 12720 }; 12721 BootstrapDialog.METHODS_TO_OVERRIDE['v3.3'] = {}; 12722 BootstrapDialog.METHODS_TO_OVERRIDE['v3.3.4'] = $.extend({}, BootstrapDialog.METHODS_TO_OVERRIDE['v3.1']); 12723 BootstrapDialog.prototype = { 12724 constructor: BootstrapDialog, 12725 initOptions: function(options) { 12726 this.options = $.extend(true, this.defaultOptions, options); 12727 12728 return this; 12729 }, 12730 holdThisInstance: function() { 12731 BootstrapDialog.dialogs[this.getId()] = this; 12732 12733 return this; 12734 }, 12735 initModalStuff: function() { 12736 this.setModal(this.createModal()) 12737 .setModalDialog(this.createModalDialog()) 12738 .setModalContent(this.createModalContent()) 12739 .setModalHeader(this.createModalHeader()) 12740 .setModalBody(this.createModalBody()) 12741 .setModalFooter(this.createModalFooter()); 12742 12743 this.getModal().append(this.getModalDialog()); 12744 this.getModalDialog().append(this.getModalContent()); 12745 this.getModalContent() 12746 .append(this.getModalHeader()) 12747 .append(this.getModalBody()) 12748 .append(this.getModalFooter()); 12749 12750 return this; 12751 }, 12752 createModal: function() { 12753 var $modal = $('<div class="modal" role="dialog" aria-hidden="true"></div>'); 12754 $modal.prop('id', this.getId()); 12755 $modal.attr('aria-labelledby', this.getId() + '_title'); 12756 12757 return $modal; 12758 }, 12759 getModal: function() { 12760 return this.$modal; 12761 }, 12762 setModal: function($modal) { 12763 this.$modal = $modal; 12764 12765 return this; 12766 }, 12767 createModalDialog: function() { 12768 return $('<div class="modal-dialog"></div>'); 12769 }, 12770 getModalDialog: function() { 12771 return this.$modalDialog; 12772 }, 12773 setModalDialog: function($modalDialog) { 12774 this.$modalDialog = $modalDialog; 12775 12776 return this; 12777 }, 12778 createModalContent: function() { 12779 return $('<div class="modal-content"></div>'); 12780 }, 12781 getModalContent: function() { 12782 return this.$modalContent; 12783 }, 12784 setModalContent: function($modalContent) { 12785 this.$modalContent = $modalContent; 12786 12787 return this; 12788 }, 12789 createModalHeader: function() { 12790 return $('<div class="modal-header"></div>'); 12791 }, 12792 getModalHeader: function() { 12793 return this.$modalHeader; 12794 }, 12795 setModalHeader: function($modalHeader) { 12796 this.$modalHeader = $modalHeader; 12797 12798 return this; 12799 }, 12800 createModalBody: function() { 12801 return $('<div class="modal-body"></div>'); 12802 }, 12803 getModalBody: function() { 12804 return this.$modalBody; 12805 }, 12806 setModalBody: function($modalBody) { 12807 this.$modalBody = $modalBody; 12808 12809 return this; 12810 }, 12811 createModalFooter: function() { 12812 return $('<div class="modal-footer"></div>'); 12813 }, 12814 getModalFooter: function() { 12815 return this.$modalFooter; 12816 }, 12817 setModalFooter: function($modalFooter) { 12818 this.$modalFooter = $modalFooter; 12819 12820 return this; 12821 }, 12822 createDynamicContent: function(rawContent) { 12823 var content = null; 12824 if (typeof rawContent === 'function') { 12825 content = rawContent.call(rawContent, this); 12826 } else { 12827 content = rawContent; 12828 } 12829 if (typeof content === 'string') { 12830 content = this.formatStringContent(content); 12831 } 12832 12833 return content; 12834 }, 12835 formatStringContent: function(content) { 12836 if (this.options.nl2br) { 12837 return content.replace(/\r\n/g, '<br />').replace(/[\r\n]/g, '<br />'); 12838 } 12839 12840 return content; 12841 }, 12842 setData: function(key, value) { 12843 this.options.data[key] = value; 12844 12845 return this; 12846 }, 12847 getData: function(key) { 12848 return this.options.data[key]; 12849 }, 12850 setId: function(id) { 12851 this.options.id = id; 12852 12853 return this; 12854 }, 12855 getId: function() { 12856 return this.options.id; 12857 }, 12858 getType: function() { 12859 return this.options.type; 12860 }, 12861 setType: function(type) { 12862 this.options.type = type; 12863 this.updateType(); 12864 12865 return this; 12866 }, 12867 updateType: function() { 12868 if (this.isRealized()) { 12869 var types = [BootstrapDialog.TYPE_DEFAULT, 12870 BootstrapDialog.TYPE_INFO, 12871 BootstrapDialog.TYPE_PRIMARY, 12872 BootstrapDialog.TYPE_SUCCESS, 12873 BootstrapDialog.TYPE_WARNING, 12874 BootstrapDialog.TYPE_DANGER]; 12875 12876 this.getModal().removeClass(types.join(' ')).addClass(this.getType()); 12877 } 12878 12879 return this; 12880 }, 12881 getSize: function() { 12882 return this.options.size; 12883 }, 12884 setSize: function(size) { 12885 this.options.size = size; 12886 this.updateSize(); 12887 12888 return this; 12889 }, 12890 updateSize: function() { 12891 if (this.isRealized()) { 12892 var dialog = this; 12893 12894 // Dialog size 12895 this.getModal().removeClass(BootstrapDialog.SIZE_NORMAL) 12896 .removeClass(BootstrapDialog.SIZE_SMALL) 12897 .removeClass(BootstrapDialog.SIZE_WIDE) 12898 .removeClass(BootstrapDialog.SIZE_LARGE); 12899 this.getModal().addClass(this.getSize()); 12900 12901 // Smaller dialog. 12902 this.getModalDialog().removeClass('modal-sm'); 12903 if (this.getSize() === BootstrapDialog.SIZE_SMALL) { 12904 this.getModalDialog().addClass('modal-sm'); 12905 } 12906 12907 // Wider dialog. 12908 this.getModalDialog().removeClass('modal-lg'); 12909 if (this.getSize() === BootstrapDialog.SIZE_WIDE) { 12910 this.getModalDialog().addClass('modal-lg'); 12911 } 12912 12913 // Button size 12914 $.each(this.options.buttons, function(index, button) { 12915 var $button = dialog.getButton(button.id); 12916 var buttonSizes = ['btn-lg', 'btn-sm', 'btn-xs']; 12917 var sizeClassSpecified = false; 12918 if (typeof button['cssClass'] === 'string') { 12919 var btnClasses = button['cssClass'].split(' '); 12920 $.each(btnClasses, function(index, btnClass) { 12921 if ($.inArray(btnClass, buttonSizes) !== -1) { 12922 sizeClassSpecified = true; 12923 } 12924 }); 12925 } 12926 if (!sizeClassSpecified) { 12927 $button.removeClass(buttonSizes.join(' ')); 12928 $button.addClass(dialog.getButtonSize()); 12929 } 12930 }); 12931 } 12932 12933 return this; 12934 }, 12935 getCssClass: function() { 12936 return this.options.cssClass; 12937 }, 12938 setCssClass: function(cssClass) { 12939 this.options.cssClass = cssClass; 12940 12941 return this; 12942 }, 12943 getTitle: function() { 12944 return this.options.title; 12945 }, 12946 setTitle: function(title) { 12947 this.options.title = title; 12948 this.updateTitle(); 12949 12950 return this; 12951 }, 12952 updateTitle: function() { 12953 if (this.isRealized()) { 12954 var title = this.getTitle() !== null ? this.createDynamicContent(this.getTitle()) : this.getDefaultText(); 12955 this.getModalHeader().find('.' + this.getNamespace('title')).html('').append(title).prop('id', this.getId() + '_title'); 12956 } 12957 12958 return this; 12959 }, 12960 getMessage: function() { 12961 return this.options.message; 12962 }, 12963 setMessage: function(message) { 12964 this.options.message = message; 12965 this.updateMessage(); 12966 12967 return this; 12968 }, 12969 updateMessage: function() { 12970 if (this.isRealized()) { 12971 var message = this.createDynamicContent(this.getMessage()); 12972 this.getModalBody().find('.' + this.getNamespace('message')).html('').append(message); 12973 } 12974 12975 return this; 12976 }, 12977 isClosable: function() { 12978 return this.options.closable; 12979 }, 12980 setClosable: function(closable) { 12981 this.options.closable = closable; 12982 this.updateClosable(); 12983 12984 return this; 12985 }, 12986 setCloseByBackdrop: function(closeByBackdrop) { 12987 this.options.closeByBackdrop = closeByBackdrop; 12988 12989 return this; 12990 }, 12991 canCloseByBackdrop: function() { 12992 return this.options.closeByBackdrop; 12993 }, 12994 setCloseByKeyboard: function(closeByKeyboard) { 12995 this.options.closeByKeyboard = closeByKeyboard; 12996 12997 return this; 12998 }, 12999 canCloseByKeyboard: function() { 13000 return this.options.closeByKeyboard; 13001 }, 13002 isAnimate: function() { 13003 return this.options.animate; 13004 }, 13005 setAnimate: function(animate) { 13006 this.options.animate = animate; 13007 13008 return this; 13009 }, 13010 updateAnimate: function() { 13011 if (this.isRealized()) { 13012 this.getModal().toggleClass('fade', this.isAnimate()); 13013 } 13014 13015 return this; 13016 }, 13017 getSpinicon: function() { 13018 return this.options.spinicon; 13019 }, 13020 setSpinicon: function(spinicon) { 13021 this.options.spinicon = spinicon; 13022 13023 return this; 13024 }, 13025 addButton: function(button) { 13026 this.options.buttons.push(button); 13027 13028 return this; 13029 }, 13030 addButtons: function(buttons) { 13031 var that = this; 13032 $.each(buttons, function(index, button) { 13033 that.addButton(button); 13034 }); 13035 13036 return this; 13037 }, 13038 getButtons: function() { 13039 return this.options.buttons; 13040 }, 13041 setButtons: function(buttons) { 13042 this.options.buttons = buttons; 13043 this.updateButtons(); 13044 13045 return this; 13046 }, 13047 /** 13048 * If there is id provided for a button option, it will be in dialog.indexedButtons list. 13049 * 13050 * In that case you can use dialog.getButton(id) to find the button. 13051 * 13052 * @param {type} id 13053 * @returns {undefined} 13054 */ 13055 getButton: function(id) { 13056 if (typeof this.indexedButtons[id] !== 'undefined') { 13057 return this.indexedButtons[id]; 13058 } 13059 13060 return null; 13061 }, 13062 getButtonSize: function() { 13063 if (typeof BootstrapDialog.BUTTON_SIZES[this.getSize()] !== 'undefined') { 13064 return BootstrapDialog.BUTTON_SIZES[this.getSize()]; 13065 } 13066 13067 return ''; 13068 }, 13069 updateButtons: function() { 13070 if (this.isRealized()) { 13071 if (this.getButtons().length === 0) { 13072 this.getModalFooter().hide(); 13073 } else { 13074 this.getModalFooter().show().find('.' + this.getNamespace('footer')).html('').append(this.createFooterButtons()); 13075 } 13076 } 13077 13078 return this; 13079 }, 13080 isAutodestroy: function() { 13081 return this.options.autodestroy; 13082 }, 13083 setAutodestroy: function(autodestroy) { 13084 this.options.autodestroy = autodestroy; 13085 }, 13086 getDescription: function() { 13087 return this.options.description; 13088 }, 13089 setDescription: function(description) { 13090 this.options.description = description; 13091 13092 return this; 13093 }, 13094 setTabindex: function(tabindex) { 13095 this.options.tabindex = tabindex; 13096 13097 return this; 13098 }, 13099 getTabindex: function() { 13100 return this.options.tabindex; 13101 }, 13102 updateTabindex: function() { 13103 if (this.isRealized()) { 13104 this.getModal().attr('tabindex', this.getTabindex()); 13105 } 13106 13107 return this; 13108 }, 13109 getDefaultText: function() { 13110 return BootstrapDialog.DEFAULT_TEXTS[this.getType()]; 13111 }, 13112 getNamespace: function(name) { 13113 return BootstrapDialog.NAMESPACE + '-' + name; 13114 }, 13115 createHeaderContent: function() { 13116 var $container = $('<div></div>'); 13117 $container.addClass(this.getNamespace('header')); 13118 13119 // title 13120 $container.append(this.createTitleContent()); 13121 13122 // Close button 13123 $container.prepend(this.createCloseButton()); 13124 13125 return $container; 13126 }, 13127 createTitleContent: function() { 13128 var $title = $('<div></div>'); 13129 $title.addClass(this.getNamespace('title')); 13130 13131 return $title; 13132 }, 13133 createCloseButton: function() { 13134 var $container = $('<div></div>'); 13135 $container.addClass(this.getNamespace('close-button')); 13136 var $icon = $('<button class="close">×</button>'); 13137 $container.append($icon); 13138 $container.on('click', {dialog: this}, function(event) { 13139 event.data.dialog.close(); 13140 }); 13141 13142 return $container; 13143 }, 13144 createBodyContent: function() { 13145 var $container = $('<div></div>'); 13146 $container.addClass(this.getNamespace('body')); 13147 13148 // Message 13149 $container.append(this.createMessageContent()); 13150 13151 return $container; 13152 }, 13153 createMessageContent: function() { 13154 var $message = $('<div></div>'); 13155 $message.addClass(this.getNamespace('message')); 13156 13157 return $message; 13158 }, 13159 createFooterContent: function() { 13160 var $container = $('<div></div>'); 13161 $container.addClass(this.getNamespace('footer')); 13162 13163 return $container; 13164 }, 13165 createFooterButtons: function() { 13166 var that = this; 13167 var $container = $('<div></div>'); 13168 $container.addClass(this.getNamespace('footer-buttons')); 13169 this.indexedButtons = {}; 13170 $.each(this.options.buttons, function(index, button) { 13171 if (!button.id) { 13172 button.id = BootstrapDialog.newGuid(); 13173 } 13174 var $button = that.createButton(button); 13175 that.indexedButtons[button.id] = $button; 13176 $container.append($button); 13177 }); 13178 13179 return $container; 13180 }, 13181 createButton: function(button) { 13182 var $button = $('<button class="btn"></button>'); 13183 $button.prop('id', button.id); 13184 $button.data('button', button); 13185 13186 // Icon 13187 if (typeof button.icon !== 'undefined' && $.trim(button.icon) !== '') { 13188 $button.append(this.createButtonIcon(button.icon)); 13189 } 13190 13191 // Label 13192 if (typeof button.label !== 'undefined') { 13193 $button.append(button.label); 13194 } 13195 13196 // Css class 13197 if (typeof button.cssClass !== 'undefined' && $.trim(button.cssClass) !== '') { 13198 $button.addClass(button.cssClass); 13199 } else { 13200 $button.addClass('btn-default'); 13201 } 13202 13203 // Hotkey 13204 if (typeof button.hotkey !== 'undefined') { 13205 this.registeredButtonHotkeys[button.hotkey] = $button; 13206 } 13207 13208 // Button on click 13209 $button.on('click', {dialog: this, $button: $button, button: button}, function(event) { 13210 var dialog = event.data.dialog; 13211 var $button = event.data.$button; 13212 var button = $button.data('button'); 13213 if (typeof button.action === 'function') { 13214 button.action.call($button, dialog, event); 13215 } 13216 13217 if (button.autospin) { 13218 $button.toggleSpin(true); 13219 } 13220 }); 13221 13222 // Dynamically add extra functions to $button 13223 this.enhanceButton($button); 13224 13225 return $button; 13226 }, 13227 /** 13228 * Dynamically add extra functions to $button 13229 * 13230 * Using '$this' to reference 'this' is just for better readability. 13231 * 13232 * @param {type} $button 13233 * @returns {_L13.BootstrapDialog.prototype} 13234 */ 13235 enhanceButton: function($button) { 13236 $button.dialog = this; 13237 13238 // Enable / Disable 13239 $button.toggleEnable = function(enable) { 13240 var $this = this; 13241 if (typeof enable !== 'undefined') { 13242 $this.prop("disabled", !enable).toggleClass('disabled', !enable); 13243 } else { 13244 $this.prop("disabled", !$this.prop("disabled")); 13245 } 13246 13247 return $this; 13248 }; 13249 $button.enable = function() { 13250 var $this = this; 13251 $this.toggleEnable(true); 13252 13253 return $this; 13254 }; 13255 $button.disable = function() { 13256 var $this = this; 13257 $this.toggleEnable(false); 13258 13259 return $this; 13260 }; 13261 13262 // Icon spinning, helpful for indicating ajax loading status. 13263 $button.toggleSpin = function(spin) { 13264 var $this = this; 13265 var dialog = $this.dialog; 13266 var $icon = $this.find('.' + dialog.getNamespace('button-icon')); 13267 if (typeof spin === 'undefined') { 13268 spin = !($button.find('.icon-spin').length > 0); 13269 } 13270 if (spin) { 13271 $icon.hide(); 13272 $button.prepend(dialog.createButtonIcon(dialog.getSpinicon()).addClass('icon-spin')); 13273 } else { 13274 $icon.show(); 13275 $button.find('.icon-spin').remove(); 13276 } 13277 13278 return $this; 13279 }; 13280 $button.spin = function() { 13281 var $this = this; 13282 $this.toggleSpin(true); 13283 13284 return $this; 13285 }; 13286 $button.stopSpin = function() { 13287 var $this = this; 13288 $this.toggleSpin(false); 13289 13290 return $this; 13291 }; 13292 13293 return this; 13294 }, 13295 createButtonIcon: function(icon) { 13296 var $icon = $('<span></span>'); 13297 $icon.addClass(this.getNamespace('button-icon')).addClass(icon); 13298 13299 return $icon; 13300 }, 13301 /** 13302 * Invoke this only after the dialog is realized. 13303 * 13304 * @param {type} enable 13305 * @returns {undefined} 13306 */ 13307 enableButtons: function(enable) { 13308 $.each(this.indexedButtons, function(id, $button) { 13309 $button.toggleEnable(enable); 13310 }); 13311 13312 return this; 13313 }, 13314 /** 13315 * Invoke this only after the dialog is realized. 13316 * 13317 * @returns {undefined} 13318 */ 13319 updateClosable: function() { 13320 if (this.isRealized()) { 13321 // Close button 13322 this.getModalHeader().find('.' + this.getNamespace('close-button')).toggle(this.isClosable()); 13323 } 13324 13325 return this; 13326 }, 13327 /** 13328 * Set handler for modal event 'show.bs.modal'. 13329 * This is a setter! 13330 */ 13331 onShow: function(onshow) { 13332 this.options.onshow = onshow; 13333 13334 return this; 13335 }, 13336 /** 13337 * Set handler for modal event 'shown.bs.modal'. 13338 * This is a setter! 13339 */ 13340 onShown: function(onshown) { 13341 this.options.onshown = onshown; 13342 13343 return this; 13344 }, 13345 /** 13346 * Set handler for modal event 'hide.bs.modal'. 13347 * This is a setter! 13348 */ 13349 onHide: function(onhide) { 13350 this.options.onhide = onhide; 13351 13352 return this; 13353 }, 13354 /** 13355 * Set handler for modal event 'hidden.bs.modal'. 13356 * This is a setter! 13357 */ 13358 onHidden: function(onhidden) { 13359 this.options.onhidden = onhidden; 13360 13361 return this; 13362 }, 13363 isRealized: function() { 13364 return this.realized; 13365 }, 13366 setRealized: function(realized) { 13367 this.realized = realized; 13368 13369 return this; 13370 }, 13371 isOpened: function() { 13372 return this.opened; 13373 }, 13374 setOpened: function(opened) { 13375 this.opened = opened; 13376 13377 return this; 13378 }, 13379 handleModalEvents: function() { 13380 this.getModal().on('show.bs.modal', {dialog: this}, function(event) { 13381 var dialog = event.data.dialog; 13382 dialog.setOpened(true); 13383 if (dialog.isModalEvent(event) && typeof dialog.options.onshow === 'function') { 13384 var openIt = dialog.options.onshow(dialog); 13385 if (openIt === false) { 13386 dialog.setOpened(false); 13387 } 13388 13389 return openIt; 13390 } 13391 }); 13392 this.getModal().on('shown.bs.modal', {dialog: this}, function(event) { 13393 var dialog = event.data.dialog; 13394 dialog.isModalEvent(event) && typeof dialog.options.onshown === 'function' && dialog.options.onshown(dialog); 13395 }); 13396 this.getModal().on('hide.bs.modal', {dialog: this}, function(event) { 13397 var dialog = event.data.dialog; 13398 dialog.setOpened(false); 13399 if (dialog.isModalEvent(event) && typeof dialog.options.onhide === 'function') { 13400 var hideIt = dialog.options.onhide(dialog); 13401 if (hideIt === false) { 13402 dialog.setOpened(true); 13403 } 13404 13405 return hideIt; 13406 } 13407 }); 13408 this.getModal().on('hidden.bs.modal', {dialog: this}, function(event) { 13409 var dialog = event.data.dialog; 13410 dialog.isModalEvent(event) && typeof dialog.options.onhidden === 'function' && dialog.options.onhidden(dialog); 13411 if (dialog.isAutodestroy()) { 13412 delete BootstrapDialog.dialogs[dialog.getId()]; 13413 $(this).remove(); 13414 } 13415 BootstrapDialog.moveFocus(); 13416 }); 13417 13418 // Backdrop, I did't find a way to change bs3 backdrop option after the dialog is popped up, so here's a new wheel. 13419 this.handleModalBackdropEvent(); 13420 13421 // ESC key support 13422 this.getModal().on('keyup', {dialog: this}, function(event) { 13423 event.which === 27 && event.data.dialog.isClosable() && event.data.dialog.canCloseByKeyboard() && event.data.dialog.close(); 13424 }); 13425 13426 // Button hotkey 13427 this.getModal().on('keyup', {dialog: this}, function(event) { 13428 var dialog = event.data.dialog; 13429 if (typeof dialog.registeredButtonHotkeys[event.which] !== 'undefined') { 13430 var $button = $(dialog.registeredButtonHotkeys[event.which]); 13431 !$button.prop('disabled') && $button.focus().trigger('click'); 13432 } 13433 }); 13434 13435 return this; 13436 }, 13437 handleModalBackdropEvent: function() { 13438 this.getModal().on('click', {dialog: this}, function(event) { 13439 $(event.target).hasClass('modal-backdrop') && event.data.dialog.isClosable() && event.data.dialog.canCloseByBackdrop() && event.data.dialog.close(); 13440 }); 13441 13442 return this; 13443 }, 13444 isModalEvent: function(event) { 13445 return typeof event.namespace !== 'undefined' && event.namespace === 'bs.modal'; 13446 }, 13447 makeModalDraggable: function() { 13448 if (this.options.draggable) { 13449 this.getModalHeader().addClass(this.getNamespace('draggable')).on('mousedown', {dialog: this}, function(event) { 13450 var dialog = event.data.dialog; 13451 dialog.draggableData.isMouseDown = true; 13452 var dialogOffset = dialog.getModalDialog().offset(); 13453 dialog.draggableData.mouseOffset = { 13454 top: event.clientY - dialogOffset.top, 13455 left: event.clientX - dialogOffset.left 13456 }; 13457 }); 13458 this.getModal().on('mouseup mouseleave', {dialog: this}, function(event) { 13459 event.data.dialog.draggableData.isMouseDown = false; 13460 }); 13461 $('body').on('mousemove', {dialog: this}, function(event) { 13462 var dialog = event.data.dialog; 13463 if (!dialog.draggableData.isMouseDown) { 13464 return; 13465 } 13466 dialog.getModalDialog().offset({ 13467 top: event.clientY - dialog.draggableData.mouseOffset.top, 13468 left: event.clientX - dialog.draggableData.mouseOffset.left 13469 }); 13470 }); 13471 } 13472 13473 return this; 13474 }, 13475 realize: function() { 13476 this.initModalStuff(); 13477 this.getModal().addClass(BootstrapDialog.NAMESPACE) 13478 .addClass(this.getCssClass()); 13479 this.updateSize(); 13480 if (this.getDescription()) { 13481 this.getModal().attr('aria-describedby', this.getDescription()); 13482 } 13483 this.getModalFooter().append(this.createFooterContent()); 13484 this.getModalHeader().append(this.createHeaderContent()); 13485 this.getModalBody().append(this.createBodyContent()); 13486 this.getModal().data('bs.modal', new BootstrapDialogModal(this.getModal(), { 13487 backdrop: 'static', 13488 keyboard: false, 13489 show: false 13490 })); 13491 this.makeModalDraggable(); 13492 this.handleModalEvents(); 13493 this.setRealized(true); 13494 this.updateButtons(); 13495 this.updateType(); 13496 this.updateTitle(); 13497 this.updateMessage(); 13498 this.updateClosable(); 13499 this.updateAnimate(); 13500 this.updateSize(); 13501 this.updateTabindex(); 13502 13503 return this; 13504 }, 13505 open: function() { 13506 !this.isRealized() && this.realize(); 13507 this.getModal().modal('show'); 13508 13509 return this; 13510 }, 13511 close: function() { 13512 this.getModal().modal('hide'); 13513 13514 return this; 13515 } 13516 }; 13517 13518 // Add compatible methods. 13519 BootstrapDialog.prototype = $.extend(BootstrapDialog.prototype, BootstrapDialog.METHODS_TO_OVERRIDE[BootstrapDialogModal.getModalVersion()]); 13520 13521 /** 13522 * RFC4122 version 4 compliant unique id creator. 13523 * 13524 * Added by https://github.com/tufanbarisyildirim/ 13525 * 13526 * @returns {String} 13527 */ 13528 BootstrapDialog.newGuid = function() { 13529 return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { 13530 var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8); 13531 return v.toString(16); 13532 }); 13533 }; 13534 13535 /* ================================================ 13536 * For lazy people 13537 * ================================================ */ 13538 13539 /** 13540 * Shortcut function: show 13541 * 13542 * @param {type} options 13543 * @returns the created dialog instance 13544 */ 13545 BootstrapDialog.show = function(options) { 13546 return new BootstrapDialog(options).open(); 13547 }; 13548 13549 /** 13550 * Alert window 13551 * 13552 * @returns the created dialog instance 13553 */ 13554 BootstrapDialog.alert = function() { 13555 var options = {}; 13556 var defaultOptions = { 13557 type: BootstrapDialog.TYPE_PRIMARY, 13558 title: null, 13559 message: null, 13560 closable: false, 13561 draggable: false, 13562 buttonLabel: BootstrapDialog.DEFAULT_TEXTS.OK, 13563 callback: null 13564 }; 13565 13566 if (typeof arguments[0] === 'object' && arguments[0].constructor === {}.constructor) { 13567 options = $.extend(true, defaultOptions, arguments[0]); 13568 } else { 13569 options = $.extend(true, defaultOptions, { 13570 message: arguments[0], 13571 callback: typeof arguments[1] !== 'undefined' ? arguments[1] : null 13572 }); 13573 } 13574 13575 return new BootstrapDialog({ 13576 type: options.type, 13577 title: options.title, 13578 message: options.message, 13579 closable: options.closable, 13580 draggable: options.draggable, 13581 data: { 13582 callback: options.callback 13583 }, 13584 onhide: function(dialog) { 13585 !dialog.getData('btnClicked') && dialog.isClosable() && typeof dialog.getData('callback') === 'function' && dialog.getData('callback')(false); 13586 }, 13587 buttons: [{ 13588 label: options.buttonLabel, 13589 action: function(dialog) { 13590 dialog.setData('btnClicked', true); 13591 typeof dialog.getData('callback') === 'function' && dialog.getData('callback')(true); 13592 dialog.close(); 13593 } 13594 }] 13595 }).open(); 13596 }; 13597 13598 /** 13599 * Confirm window 13600 * 13601 * @returns the created dialog instance 13602 */ 13603 BootstrapDialog.confirm = function() { 13604 var options = {}; 13605 var defaultOptions = { 13606 type: BootstrapDialog.TYPE_PRIMARY, 13607 title: null, 13608 message: null, 13609 closable: false, 13610 draggable: false, 13611 btnCancelLabel: BootstrapDialog.DEFAULT_TEXTS.CANCEL, 13612 btnOKLabel: BootstrapDialog.DEFAULT_TEXTS.OK, 13613 btnOKClass: null, 13614 callback: null 13615 }; 13616 if (typeof arguments[0] === 'object' && arguments[0].constructor === {}.constructor) { 13617 options = $.extend(true, defaultOptions, arguments[0]); 13618 } else { 13619 options = $.extend(true, defaultOptions, { 13620 message: arguments[0], 13621 closable: false, 13622 buttonLabel: BootstrapDialog.DEFAULT_TEXTS.OK, 13623 callback: typeof arguments[1] !== 'undefined' ? arguments[1] : null 13624 }); 13625 } 13626 if (options.btnOKClass === null) { 13627 options.btnOKClass = ['btn', options.type.split('-')[1]].join('-'); 13628 } 13629 13630 return new BootstrapDialog({ 13631 type: options.type, 13632 title: options.title, 13633 message: options.message, 13634 closable: options.closable, 13635 draggable: options.draggable, 13636 data: { 13637 callback: options.callback 13638 }, 13639 buttons: [{ 13640 label: options.btnCancelLabel, 13641 action: function(dialog) { 13642 typeof dialog.getData('callback') === 'function' && dialog.getData('callback')(false); 13643 dialog.close(); 13644 } 13645 }, { 13646 label: options.btnOKLabel, 13647 cssClass: options.btnOKClass, 13648 action: function(dialog) { 13649 typeof dialog.getData('callback') === 'function' && dialog.getData('callback')(true); 13650 dialog.close(); 13651 } 13652 }] 13653 }).open(); 13654 }; 13655 13656 /** 13657 * Warning window 13658 * 13659 * @param {type} message 13660 * @returns the created dialog instance 13661 */ 13662 BootstrapDialog.warning = function(message, callback) { 13663 return new BootstrapDialog({ 13664 type: BootstrapDialog.TYPE_WARNING, 13665 message: message 13666 }).open(); 13667 }; 13668 13669 /** 13670 * Danger window 13671 * 13672 * @param {type} message 13673 * @returns the created dialog instance 13674 */ 13675 BootstrapDialog.danger = function(message, callback) { 13676 return new BootstrapDialog({ 13677 type: BootstrapDialog.TYPE_DANGER, 13678 message: message 13679 }).open(); 13680 }; 13681 13682 /** 13683 * Success window 13684 * 13685 * @param {type} message 13686 * @returns the created dialog instance 13687 */ 13688 BootstrapDialog.success = function(message, callback) { 13689 return new BootstrapDialog({ 13690 type: BootstrapDialog.TYPE_SUCCESS, 13691 message: message 13692 }).open(); 13693 }; 13694 13695 return BootstrapDialog; 13696 13697 })); 13698 13699 13700 /***/ }, 13701 /* 86 */ 13702 /***/ function(module, exports, __webpack_require__) { 13703 13704 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 13705 * Bootstrap-select v1.12.1 (http://silviomoreto.github.io/bootstrap-select) 13706 * 13707 * Copyright 2013-2016 bootstrap-select 13708 * Licensed under MIT (https://github.com/silviomoreto/bootstrap-select/blob/master/LICENSE) 13709 */ 13710 13711 (function (root, factory) { 13712 if (true) { 13713 // AMD. Register as an anonymous module unless amdModuleId is set 13714 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(71)], __WEBPACK_AMD_DEFINE_RESULT__ = function (a0) { 13715 return (factory(a0)); 13716 }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 13717 } else if (typeof module === 'object' && module.exports) { 13718 // Node. Does not work with strict CommonJS, but 13719 // only CommonJS-like environments that support module.exports, 13720 // like Node. 13721 module.exports = factory(require("jquery")); 13722 } else { 13723 factory(root["jQuery"]); 13724 } 13725 }(this, function (jQuery) { 13726 13727 (function ($) { 13728 'use strict'; 13729 13730 //<editor-fold desc="Shims"> 13731 if (!String.prototype.includes) { 13732 (function () { 13733 'use strict'; // needed to support `apply`/`call` with `undefined`/`null` 13734 var toString = {}.toString; 13735 var defineProperty = (function () { 13736 // IE 8 only supports `Object.defineProperty` on DOM elements 13737 try { 13738 var object = {}; 13739 var $defineProperty = Object.defineProperty; 13740 var result = $defineProperty(object, object, object) && $defineProperty; 13741 } catch (error) { 13742 } 13743 return result; 13744 }()); 13745 var indexOf = ''.indexOf; 13746 var includes = function (search) { 13747 if (this == null) { 13748 throw new TypeError(); 13749 } 13750 var string = String(this); 13751 if (search && toString.call(search) == '[object RegExp]') { 13752 throw new TypeError(); 13753 } 13754 var stringLength = string.length; 13755 var searchString = String(search); 13756 var searchLength = searchString.length; 13757 var position = arguments.length > 1 ? arguments[1] : undefined; 13758 // `ToInteger` 13759 var pos = position ? Number(position) : 0; 13760 if (pos != pos) { // better `isNaN` 13761 pos = 0; 13762 } 13763 var start = Math.min(Math.max(pos, 0), stringLength); 13764 // Avoid the `indexOf` call if no match is possible 13765 if (searchLength + start > stringLength) { 13766 return false; 13767 } 13768 return indexOf.call(string, searchString, pos) != -1; 13769 }; 13770 if (defineProperty) { 13771 defineProperty(String.prototype, 'includes', { 13772 'value': includes, 13773 'configurable': true, 13774 'writable': true 13775 }); 13776 } else { 13777 String.prototype.includes = includes; 13778 } 13779 }()); 13780 } 13781 13782 if (!String.prototype.startsWith) { 13783 (function () { 13784 'use strict'; // needed to support `apply`/`call` with `undefined`/`null` 13785 var defineProperty = (function () { 13786 // IE 8 only supports `Object.defineProperty` on DOM elements 13787 try { 13788 var object = {}; 13789 var $defineProperty = Object.defineProperty; 13790 var result = $defineProperty(object, object, object) && $defineProperty; 13791 } catch (error) { 13792 } 13793 return result; 13794 }()); 13795 var toString = {}.toString; 13796 var startsWith = function (search) { 13797 if (this == null) { 13798 throw new TypeError(); 13799 } 13800 var string = String(this); 13801 if (search && toString.call(search) == '[object RegExp]') { 13802 throw new TypeError(); 13803 } 13804 var stringLength = string.length; 13805 var searchString = String(search); 13806 var searchLength = searchString.length; 13807 var position = arguments.length > 1 ? arguments[1] : undefined; 13808 // `ToInteger` 13809 var pos = position ? Number(position) : 0; 13810 if (pos != pos) { // better `isNaN` 13811 pos = 0; 13812 } 13813 var start = Math.min(Math.max(pos, 0), stringLength); 13814 // Avoid the `indexOf` call if no match is possible 13815 if (searchLength + start > stringLength) { 13816 return false; 13817 } 13818 var index = -1; 13819 while (++index < searchLength) { 13820 if (string.charCodeAt(start + index) != searchString.charCodeAt(index)) { 13821 return false; 13822 } 13823 } 13824 return true; 13825 }; 13826 if (defineProperty) { 13827 defineProperty(String.prototype, 'startsWith', { 13828 'value': startsWith, 13829 'configurable': true, 13830 'writable': true 13831 }); 13832 } else { 13833 String.prototype.startsWith = startsWith; 13834 } 13835 }()); 13836 } 13837 13838 if (!Object.keys) { 13839 Object.keys = function ( 13840 o, // object 13841 k, // key 13842 r // result array 13843 ){ 13844 // initialize object and result 13845 r=[]; 13846 // iterate over object keys 13847 for (k in o) 13848 // fill result array with non-prototypical keys 13849 r.hasOwnProperty.call(o, k) && r.push(k); 13850 // return result 13851 return r; 13852 }; 13853 } 13854 13855 // set data-selected on select element if the value has been programmatically selected 13856 // prior to initialization of bootstrap-select 13857 // * consider removing or replacing an alternative method * 13858 var valHooks = { 13859 useDefault: false, 13860 _set: $.valHooks.select.set 13861 }; 13862 13863 $.valHooks.select.set = function(elem, value) { 13864 if (value && !valHooks.useDefault) $(elem).data('selected', true); 13865 13866 return valHooks._set.apply(this, arguments); 13867 }; 13868 13869 var changed_arguments = null; 13870 $.fn.triggerNative = function (eventName) { 13871 var el = this[0], 13872 event; 13873 13874 if (el.dispatchEvent) { // for modern browsers & IE9+ 13875 if (typeof Event === 'function') { 13876 // For modern browsers 13877 event = new Event(eventName, { 13878 bubbles: true 13879 }); 13880 } else { 13881 // For IE since it doesn't support Event constructor 13882 event = document.createEvent('Event'); 13883 event.initEvent(eventName, true, false); 13884 } 13885 13886 el.dispatchEvent(event); 13887 } else if (el.fireEvent) { // for IE8 13888 event = document.createEventObject(); 13889 event.eventType = eventName; 13890 el.fireEvent('on' + eventName, event); 13891 } else { 13892 // fall back to jQuery.trigger 13893 this.trigger(eventName); 13894 } 13895 }; 13896 //</editor-fold> 13897 13898 // Case insensitive contains search 13899 $.expr.pseudos.icontains = function (obj, index, meta) { 13900 var $obj = $(obj); 13901 var haystack = ($obj.data('tokens') || $obj.text()).toString().toUpperCase(); 13902 return haystack.includes(meta[3].toUpperCase()); 13903 }; 13904 13905 // Case insensitive begins search 13906 $.expr.pseudos.ibegins = function (obj, index, meta) { 13907 var $obj = $(obj); 13908 var haystack = ($obj.data('tokens') || $obj.text()).toString().toUpperCase(); 13909 return haystack.startsWith(meta[3].toUpperCase()); 13910 }; 13911 13912 // Case and accent insensitive contains search 13913 $.expr.pseudos.aicontains = function (obj, index, meta) { 13914 var $obj = $(obj); 13915 var haystack = ($obj.data('tokens') || $obj.data('normalizedText') || $obj.text()).toString().toUpperCase(); 13916 return haystack.includes(meta[3].toUpperCase()); 13917 }; 13918 13919 // Case and accent insensitive begins search 13920 $.expr.pseudos.aibegins = function (obj, index, meta) { 13921 var $obj = $(obj); 13922 var haystack = ($obj.data('tokens') || $obj.data('normalizedText') || $obj.text()).toString().toUpperCase(); 13923 return haystack.startsWith(meta[3].toUpperCase()); 13924 }; 13925 13926 /** 13927 * Remove all diatrics from the given text. 13928 * @access private 13929 * @param {String} text 13930 * @returns {String} 13931 */ 13932 function normalizeToBase(text) { 13933 var rExps = [ 13934 {re: /[\xC0-\xC6]/g, ch: "A"}, 13935 {re: /[\xE0-\xE6]/g, ch: "a"}, 13936 {re: /[\xC8-\xCB]/g, ch: "E"}, 13937 {re: /[\xE8-\xEB]/g, ch: "e"}, 13938 {re: /[\xCC-\xCF]/g, ch: "I"}, 13939 {re: /[\xEC-\xEF]/g, ch: "i"}, 13940 {re: /[\xD2-\xD6]/g, ch: "O"}, 13941 {re: /[\xF2-\xF6]/g, ch: "o"}, 13942 {re: /[\xD9-\xDC]/g, ch: "U"}, 13943 {re: /[\xF9-\xFC]/g, ch: "u"}, 13944 {re: /[\xC7-\xE7]/g, ch: "c"}, 13945 {re: /[\xD1]/g, ch: "N"}, 13946 {re: /[\xF1]/g, ch: "n"} 13947 ]; 13948 $.each(rExps, function () { 13949 text = text ? text.replace(this.re, this.ch) : ''; 13950 }); 13951 return text; 13952 } 13953 13954 13955 // List of HTML entities for escaping. 13956 var escapeMap = { 13957 '&': '&', 13958 '<': '<', 13959 '>': '>', 13960 '"': '"', 13961 "'": ''', 13962 '`': '`' 13963 }; 13964 13965 var unescapeMap = { 13966 '&': '&', 13967 '<': '<', 13968 '>': '>', 13969 '"': '"', 13970 ''': "'", 13971 '`': '`' 13972 }; 13973 13974 // Functions for escaping and unescaping strings to/from HTML interpolation. 13975 var createEscaper = function(map) { 13976 var escaper = function(match) { 13977 return map[match]; 13978 }; 13979 // Regexes for identifying a key that needs to be escaped. 13980 var source = '(?:' + Object.keys(map).join('|') + ')'; 13981 var testRegexp = RegExp(source); 13982 var replaceRegexp = RegExp(source, 'g'); 13983 return function(string) { 13984 string = string == null ? '' : '' + string; 13985 return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string; 13986 }; 13987 }; 13988 13989 var htmlEscape = createEscaper(escapeMap); 13990 var htmlUnescape = createEscaper(unescapeMap); 13991 13992 var Selectpicker = function (element, options) { 13993 // bootstrap-select has been initialized - revert valHooks.select.set back to its original function 13994 if (!valHooks.useDefault) { 13995 $.valHooks.select.set = valHooks._set; 13996 valHooks.useDefault = true; 13997 } 13998 13999 this.$element = $(element); 14000 this.$newElement = null; 14001 this.$button = null; 14002 this.$menu = null; 14003 this.$lis = null; 14004 this.options = options; 14005 14006 // If we have no title yet, try to pull it from the html title attribute (jQuery doesnt' pick it up as it's not a 14007 // data-attribute) 14008 if (this.options.title === null) { 14009 this.options.title = this.$element.attr('title'); 14010 } 14011 14012 // Format window padding 14013 var winPad = this.options.windowPadding; 14014 if (typeof winPad === 'number') { 14015 this.options.windowPadding = [winPad, winPad, winPad, winPad]; 14016 } 14017 14018 //Expose public methods 14019 this.val = Selectpicker.prototype.val; 14020 this.render = Selectpicker.prototype.render; 14021 this.refresh = Selectpicker.prototype.refresh; 14022 this.setStyle = Selectpicker.prototype.setStyle; 14023 this.selectAll = Selectpicker.prototype.selectAll; 14024 this.deselectAll = Selectpicker.prototype.deselectAll; 14025 this.destroy = Selectpicker.prototype.destroy; 14026 this.remove = Selectpicker.prototype.remove; 14027 this.show = Selectpicker.prototype.show; 14028 this.hide = Selectpicker.prototype.hide; 14029 14030 this.init(); 14031 }; 14032 14033 Selectpicker.VERSION = '1.12.1'; 14034 14035 // part of this is duplicated in i18n/defaults-en_US.js. Make sure to update both. 14036 Selectpicker.DEFAULTS = { 14037 noneSelectedText: 'Nothing selected', 14038 noneResultsText: 'No results matched {0}', 14039 countSelectedText: function (numSelected, numTotal) { 14040 return (numSelected == 1) ? "{0} item selected" : "{0} items selected"; 14041 }, 14042 maxOptionsText: function (numAll, numGroup) { 14043 return [ 14044 (numAll == 1) ? 'Limit reached ({n} item max)' : 'Limit reached ({n} items max)', 14045 (numGroup == 1) ? 'Group limit reached ({n} item max)' : 'Group limit reached ({n} items max)' 14046 ]; 14047 }, 14048 selectAllText: 'Select All', 14049 deselectAllText: 'Deselect All', 14050 doneButton: false, 14051 doneButtonText: 'Close', 14052 multipleSeparator: ', ', 14053 styleBase: 'btn', 14054 style: 'btn-default', 14055 size: 'auto', 14056 title: null, 14057 selectedTextFormat: 'values', 14058 width: false, 14059 container: false, 14060 hideDisabled: false, 14061 showSubtext: false, 14062 showIcon: true, 14063 showContent: true, 14064 dropupAuto: true, 14065 header: false, 14066 liveSearch: false, 14067 liveSearchPlaceholder: null, 14068 liveSearchNormalize: false, 14069 liveSearchStyle: 'contains', 14070 actionsBox: false, 14071 iconBase: 'glyphicon', 14072 tickIcon: 'glyphicon-ok', 14073 showTick: false, 14074 template: { 14075 caret: '<span class="caret"></span>' 14076 }, 14077 maxOptions: false, 14078 mobile: false, 14079 selectOnTab: false, 14080 dropdownAlignRight: false, 14081 windowPadding: 0 14082 }; 14083 14084 Selectpicker.prototype = { 14085 14086 constructor: Selectpicker, 14087 14088 init: function () { 14089 var that = this, 14090 id = this.$element.attr('id'); 14091 14092 this.$element.addClass('bs-select-hidden'); 14093 14094 // store originalIndex (key) and newIndex (value) in this.liObj for fast accessibility 14095 // allows us to do this.$lis.eq(that.liObj[index]) instead of this.$lis.filter('[data-original-index="' + index + '"]') 14096 this.liObj = {}; 14097 this.multiple = this.$element.prop('multiple'); 14098 this.autofocus = this.$element.prop('autofocus'); 14099 this.$newElement = this.createView(); 14100 this.$element 14101 .after(this.$newElement) 14102 .appendTo(this.$newElement); 14103 this.$button = this.$newElement.children('button'); 14104 this.$menu = this.$newElement.children('.dropdown-menu'); 14105 this.$menuInner = this.$menu.children('.inner'); 14106 this.$searchbox = this.$menu.find('input'); 14107 14108 this.$element.removeClass('bs-select-hidden'); 14109 14110 if (this.options.dropdownAlignRight === true) this.$menu.addClass('dropdown-menu-right'); 14111 14112 if (typeof id !== 'undefined') { 14113 this.$button.attr('data-id', id); 14114 $('label[for="' + id + '"]').click(function (e) { 14115 e.preventDefault(); 14116 that.$button.focus(); 14117 }); 14118 } 14119 14120 this.checkDisabled(); 14121 this.clickListener(); 14122 if (this.options.liveSearch) this.liveSearchListener(); 14123 this.render(); 14124 this.setStyle(); 14125 this.setWidth(); 14126 if (this.options.container) this.selectPosition(); 14127 this.$menu.data('this', this); 14128 this.$newElement.data('this', this); 14129 if (this.options.mobile) this.mobile(); 14130 14131 this.$newElement.on({ 14132 'hide.bs.dropdown': function (e) { 14133 that.$menuInner.attr('aria-expanded', false); 14134 that.$element.trigger('hide.bs.select', e); 14135 }, 14136 'hidden.bs.dropdown': function (e) { 14137 that.$element.trigger('hidden.bs.select', e); 14138 }, 14139 'show.bs.dropdown': function (e) { 14140 that.$menuInner.attr('aria-expanded', true); 14141 that.$element.trigger('show.bs.select', e); 14142 }, 14143 'shown.bs.dropdown': function (e) { 14144 that.$element.trigger('shown.bs.select', e); 14145 } 14146 }); 14147 14148 if (that.$element[0].hasAttribute('required')) { 14149 this.$element.on('invalid', function () { 14150 that.$button 14151 .addClass('bs-invalid') 14152 .focus(); 14153 14154 that.$element.on({ 14155 'focus.bs.select': function () { 14156 that.$button.focus(); 14157 that.$element.off('focus.bs.select'); 14158 }, 14159 'shown.bs.select': function () { 14160 that.$element 14161 .val(that.$element.val()) // set the value to hide the validation message in Chrome when menu is opened 14162 .off('shown.bs.select'); 14163 }, 14164 'rendered.bs.select': function () { 14165 // if select is no longer invalid, remove the bs-invalid class 14166 if (this.validity.valid) that.$button.removeClass('bs-invalid'); 14167 that.$element.off('rendered.bs.select'); 14168 } 14169 }); 14170 }); 14171 } 14172 14173 setTimeout(function () { 14174 that.$element.trigger('loaded.bs.select'); 14175 }); 14176 }, 14177 14178 createDropdown: function () { 14179 // Options 14180 // If we are multiple or showTick option is set, then add the show-tick class 14181 var showTick = (this.multiple || this.options.showTick) ? ' show-tick' : '', 14182 inputGroup = this.$element.parent().hasClass('input-group') ? ' input-group-btn' : '', 14183 autofocus = this.autofocus ? ' autofocus' : ''; 14184 // Elements 14185 var header = this.options.header ? '<div class="popover-title"><button type="button" class="close" aria-hidden="true">×</button>' + this.options.header + '</div>' : ''; 14186 var searchbox = this.options.liveSearch ? 14187 '<div class="bs-searchbox">' + 14188 '<input type="text" class="form-control" autocomplete="off"' + 14189 (null === this.options.liveSearchPlaceholder ? '' : ' placeholder="' + htmlEscape(this.options.liveSearchPlaceholder) + '"') + ' role="textbox" aria-label="Search">' + 14190 '</div>' 14191 : ''; 14192 var actionsbox = this.multiple && this.options.actionsBox ? 14193 '<div class="bs-actionsbox">' + 14194 '<div class="btn-group btn-group-sm btn-block">' + 14195 '<button type="button" class="actions-btn bs-select-all btn btn-default">' + 14196 this.options.selectAllText + 14197 '</button>' + 14198 '<button type="button" class="actions-btn bs-deselect-all btn btn-default">' + 14199 this.options.deselectAllText + 14200 '</button>' + 14201 '</div>' + 14202 '</div>' 14203 : ''; 14204 var donebutton = this.multiple && this.options.doneButton ? 14205 '<div class="bs-donebutton">' + 14206 '<div class="btn-group btn-block">' + 14207 '<button type="button" class="btn btn-sm btn-default">' + 14208 this.options.doneButtonText + 14209 '</button>' + 14210 '</div>' + 14211 '</div>' 14212 : ''; 14213 var drop = 14214 '<div class="btn-group bootstrap-select' + showTick + inputGroup + '">' + 14215 '<button type="button" class="' + this.options.styleBase + ' dropdown-toggle" data-toggle="dropdown"' + autofocus + ' role="button">' + 14216 '<span class="filter-option pull-left"></span> ' + 14217 '<span class="bs-caret">' + 14218 this.options.template.caret + 14219 '</span>' + 14220 '</button>' + 14221 '<div class="dropdown-menu open" role="combobox">' + 14222 header + 14223 searchbox + 14224 actionsbox + 14225 '<ul class="dropdown-menu inner" role="listbox" aria-expanded="false">' + 14226 '</ul>' + 14227 donebutton + 14228 '</div>' + 14229 '</div>'; 14230 14231 return $(drop); 14232 }, 14233 14234 createView: function () { 14235 var $drop = this.createDropdown(), 14236 li = this.createLi(); 14237 14238 $drop.find('ul')[0].innerHTML = li; 14239 return $drop; 14240 }, 14241 14242 reloadLi: function () { 14243 // rebuild 14244 var li = this.createLi(); 14245 this.$menuInner[0].innerHTML = li; 14246 }, 14247 14248 createLi: function () { 14249 var that = this, 14250 _li = [], 14251 optID = 0, 14252 titleOption = document.createElement('option'), 14253 liIndex = -1; // increment liIndex whenever a new <li> element is created to ensure liObj is correct 14254 14255 // Helper functions 14256 /** 14257 * @param content 14258 * @param [index] 14259 * @param [classes] 14260 * @param [optgroup] 14261 * @returns {string} 14262 */ 14263 var generateLI = function (content, index, classes, optgroup) { 14264 return '<li' + 14265 ((typeof classes !== 'undefined' & '' !== classes) ? ' class="' + classes + '"' : '') + 14266 ((typeof index !== 'undefined' & null !== index) ? ' data-original-index="' + index + '"' : '') + 14267 ((typeof optgroup !== 'undefined' & null !== optgroup) ? 'data-optgroup="' + optgroup + '"' : '') + 14268 '>' + content + '</li>'; 14269 }; 14270 14271 /** 14272 * @param text 14273 * @param [classes] 14274 * @param [inline] 14275 * @param [tokens] 14276 * @returns {string} 14277 */ 14278 var generateA = function (text, classes, inline, tokens) { 14279 return '<a tabindex="0"' + 14280 (typeof classes !== 'undefined' ? ' class="' + classes + '"' : '') + 14281 (inline ? ' style="' + inline + '"' : '') + 14282 (that.options.liveSearchNormalize ? ' data-normalized-text="' + normalizeToBase(htmlEscape($(text).html())) + '"' : '') + 14283 (typeof tokens !== 'undefined' || tokens !== null ? ' data-tokens="' + tokens + '"' : '') + 14284 ' role="option">' + text + 14285 '<span class="' + that.options.iconBase + ' ' + that.options.tickIcon + ' check-mark"></span>' + 14286 '</a>'; 14287 }; 14288 14289 if (this.options.title && !this.multiple) { 14290 // this option doesn't create a new <li> element, but does add a new option, so liIndex is decreased 14291 // since liObj is recalculated on every refresh, liIndex needs to be decreased even if the titleOption is already appended 14292 liIndex--; 14293 14294 if (!this.$element.find('.bs-title-option').length) { 14295 // Use native JS to prepend option (faster) 14296 var element = this.$element[0]; 14297 titleOption.className = 'bs-title-option'; 14298 titleOption.innerHTML = this.options.title; 14299 titleOption.value = ''; 14300 element.insertBefore(titleOption, element.firstChild); 14301 // Check if selected or data-selected attribute is already set on an option. If not, select the titleOption option. 14302 // the selected item may have been changed by user or programmatically before the bootstrap select plugin runs, 14303 // if so, the select will have the data-selected attribute 14304 var $opt = $(element.options[element.selectedIndex]); 14305 if ($opt.attr('selected') === undefined && this.$element.data('selected') === undefined) { 14306 titleOption.selected = true; 14307 } 14308 } 14309 } 14310 14311 this.$element.find('option').each(function (index) { 14312 var $this = $(this); 14313 14314 liIndex++; 14315 14316 if ($this.hasClass('bs-title-option')) return; 14317 14318 // Get the class and text for the option 14319 var optionClass = this.className || '', 14320 inline = this.style.cssText, 14321 text = $this.data('content') ? $this.data('content') : $this.html(), 14322 tokens = $this.data('tokens') ? $this.data('tokens') : null, 14323 subtext = typeof $this.data('subtext') !== 'undefined' ? '<small class="text-muted">' + $this.data('subtext') + '</small>' : '', 14324 icon = typeof $this.data('icon') !== 'undefined' ? '<span class="' + that.options.iconBase + ' ' + $this.data('icon') + '"></span> ' : '', 14325 $parent = $this.parent(), 14326 isOptgroup = $parent[0].tagName === 'OPTGROUP', 14327 isOptgroupDisabled = isOptgroup && $parent[0].disabled, 14328 isDisabled = this.disabled || isOptgroupDisabled; 14329 14330 if (icon !== '' && isDisabled) { 14331 icon = '<span>' + icon + '</span>'; 14332 } 14333 14334 if (that.options.hideDisabled && (isDisabled && !isOptgroup || isOptgroupDisabled)) { 14335 liIndex--; 14336 return; 14337 } 14338 14339 if (!$this.data('content')) { 14340 // Prepend any icon and append any subtext to the main text. 14341 text = icon + '<span class="text">' + text + subtext + '</span>'; 14342 } 14343 14344 if (isOptgroup && $this.data('divider') !== true) { 14345 if (that.options.hideDisabled && isDisabled) { 14346 if ($parent.data('allOptionsDisabled') === undefined) { 14347 var $options = $parent.children(); 14348 $parent.data('allOptionsDisabled', $options.filter(':disabled').length === $options.length); 14349 } 14350 14351 if ($parent.data('allOptionsDisabled')) { 14352 liIndex--; 14353 return; 14354 } 14355 } 14356 14357 var optGroupClass = ' ' + $parent[0].className || ''; 14358 14359 if ($this.index() === 0) { // Is it the first option of the optgroup? 14360 optID += 1; 14361 14362 // Get the opt group label 14363 var label = $parent[0].label, 14364 labelSubtext = typeof $parent.data('subtext') !== 'undefined' ? '<small class="text-muted">' + $parent.data('subtext') + '</small>' : '', 14365 labelIcon = $parent.data('icon') ? '<span class="' + that.options.iconBase + ' ' + $parent.data('icon') + '"></span> ' : ''; 14366 14367 label = labelIcon + '<span class="text">' + htmlEscape(label) + labelSubtext + '</span>'; 14368 14369 if (index !== 0 && _li.length > 0) { // Is it NOT the first option of the select && are there elements in the dropdown? 14370 liIndex++; 14371 _li.push(generateLI('', null, 'divider', optID + 'div')); 14372 } 14373 liIndex++; 14374 _li.push(generateLI(label, null, 'dropdown-header' + optGroupClass, optID)); 14375 } 14376 14377 if (that.options.hideDisabled && isDisabled) { 14378 liIndex--; 14379 return; 14380 } 14381 14382 _li.push(generateLI(generateA(text, 'opt ' + optionClass + optGroupClass, inline, tokens), index, '', optID)); 14383 } else if ($this.data('divider') === true) { 14384 _li.push(generateLI('', index, 'divider')); 14385 } else if ($this.data('hidden') === true) { 14386 _li.push(generateLI(generateA(text, optionClass, inline, tokens), index, 'hidden is-hidden')); 14387 } else { 14388 var showDivider = this.previousElementSibling && this.previousElementSibling.tagName === 'OPTGROUP'; 14389 14390 // if previous element is not an optgroup and hideDisabled is true 14391 if (!showDivider && that.options.hideDisabled) { 14392 // get previous elements 14393 var $prev = $(this).prevAll(); 14394 14395 for (var i = 0; i < $prev.length; i++) { 14396 // find the first element in the previous elements that is an optgroup 14397 if ($prev[i].tagName === 'OPTGROUP') { 14398 var optGroupDistance = 0; 14399 14400 // loop through the options in between the current option and the optgroup 14401 // and check if they are hidden or disabled 14402 for (var d = 0; d < i; d++) { 14403 var prevOption = $prev[d]; 14404 if (prevOption.disabled || $(prevOption).data('hidden') === true) optGroupDistance++; 14405 } 14406 14407 // if all of the options between the current option and the optgroup are hidden or disabled, show the divider 14408 if (optGroupDistance === i) showDivider = true; 14409 14410 break; 14411 } 14412 } 14413 } 14414 14415 if (showDivider) { 14416 liIndex++; 14417 _li.push(generateLI('', null, 'divider', optID + 'div')); 14418 } 14419 _li.push(generateLI(generateA(text, optionClass, inline, tokens), index)); 14420 } 14421 14422 that.liObj[index] = liIndex; 14423 }); 14424 14425 //If we are not multiple, we don't have a selected item, and we don't have a title, select the first element so something is set in the button 14426 if (!this.multiple && this.$element.find('option:selected').length === 0 && !this.options.title) { 14427 this.$element.find('option').eq(0).prop('selected', true).attr('selected', 'selected'); 14428 } 14429 14430 return _li.join(''); 14431 }, 14432 14433 findLis: function () { 14434 if (this.$lis == null) this.$lis = this.$menu.find('li'); 14435 return this.$lis; 14436 }, 14437 14438 /** 14439 * @param [updateLi] defaults to true 14440 */ 14441 render: function (updateLi) { 14442 var that = this, 14443 notDisabled; 14444 14445 //Update the LI to match the SELECT 14446 if (updateLi !== false) { 14447 this.$element.find('option').each(function (index) { 14448 var $lis = that.findLis().eq(that.liObj[index]); 14449 14450 that.setDisabled(index, this.disabled || this.parentNode.tagName === 'OPTGROUP' && this.parentNode.disabled, $lis); 14451 that.setSelected(index, this.selected, $lis); 14452 }); 14453 } 14454 14455 this.togglePlaceholder(); 14456 14457 this.tabIndex(); 14458 14459 var selectedItems = this.$element.find('option').map(function () { 14460 if (this.selected) { 14461 if (that.options.hideDisabled && (this.disabled || this.parentNode.tagName === 'OPTGROUP' && this.parentNode.disabled)) return; 14462 14463 var $this = $(this), 14464 icon = $this.data('icon') && that.options.showIcon ? '<i class="' + that.options.iconBase + ' ' + $this.data('icon') + '"></i> ' : '', 14465 subtext; 14466 14467 if (that.options.showSubtext && $this.data('subtext') && !that.multiple) { 14468 subtext = ' <small class="text-muted">' + $this.data('subtext') + '</small>'; 14469 } else { 14470 subtext = ''; 14471 } 14472 if (typeof $this.attr('title') !== 'undefined') { 14473 return $this.attr('title'); 14474 } else if ($this.data('content') && that.options.showContent) { 14475 return $this.data('content').toString(); 14476 } else { 14477 return icon + $this.html() + subtext; 14478 } 14479 } 14480 }).toArray(); 14481 14482 //Fixes issue in IE10 occurring when no default option is selected and at least one option is disabled 14483 //Convert all the values into a comma delimited string 14484 var title = !this.multiple ? selectedItems[0] : selectedItems.join(this.options.multipleSeparator); 14485 14486 //If this is multi select, and the selectText type is count, the show 1 of 2 selected etc.. 14487 if (this.multiple && this.options.selectedTextFormat.indexOf('count') > -1) { 14488 var max = this.options.selectedTextFormat.split('>'); 14489 if ((max.length > 1 && selectedItems.length > max[1]) || (max.length == 1 && selectedItems.length >= 2)) { 14490 notDisabled = this.options.hideDisabled ? ', [disabled]' : ''; 14491 var totalCount = this.$element.find('option').not('[data-divider="true"], [data-hidden="true"]' + notDisabled).length, 14492 tr8nText = (typeof this.options.countSelectedText === 'function') ? this.options.countSelectedText(selectedItems.length, totalCount) : this.options.countSelectedText; 14493 title = tr8nText.replace('{0}', selectedItems.length.toString()).replace('{1}', totalCount.toString()); 14494 } 14495 } 14496 14497 if (this.options.title == undefined) { 14498 this.options.title = this.$element.attr('title'); 14499 } 14500 14501 if (this.options.selectedTextFormat == 'static') { 14502 title = this.options.title; 14503 } 14504 14505 //If we dont have a title, then use the default, or if nothing is set at all, use the not selected text 14506 if (!title) { 14507 title = typeof this.options.title !== 'undefined' ? this.options.title : this.options.noneSelectedText; 14508 } 14509 14510 //strip all HTML tags and trim the result, then unescape any escaped tags 14511 this.$button.attr('title', htmlUnescape($.trim(title.replace(/<[^>]*>?/g, '')))); 14512 this.$button.children('.filter-option').html(title); 14513 14514 this.$element.trigger('rendered.bs.select'); 14515 }, 14516 14517 /** 14518 * @param [style] 14519 * @param [status] 14520 */ 14521 setStyle: function (style, status) { 14522 if (this.$element.attr('class')) { 14523 this.$newElement.addClass(this.$element.attr('class').replace(/selectpicker|mobile-device|bs-select-hidden|validate\[.*\]/gi, '')); 14524 } 14525 14526 var buttonClass = style ? style : this.options.style; 14527 14528 if (status == 'add') { 14529 this.$button.addClass(buttonClass); 14530 } else if (status == 'remove') { 14531 this.$button.removeClass(buttonClass); 14532 } else { 14533 this.$button.removeClass(this.options.style); 14534 this.$button.addClass(buttonClass); 14535 } 14536 }, 14537 14538 liHeight: function (refresh) { 14539 if (!refresh && (this.options.size === false || this.sizeInfo)) return; 14540 14541 var newElement = document.createElement('div'), 14542 menu = document.createElement('div'), 14543 menuInner = document.createElement('ul'), 14544 divider = document.createElement('li'), 14545 li = document.createElement('li'), 14546 a = document.createElement('a'), 14547 text = document.createElement('span'), 14548 header = this.options.header && this.$menu.find('.popover-title').length > 0 ? this.$menu.find('.popover-title')[0].cloneNode(true) : null, 14549 search = this.options.liveSearch ? document.createElement('div') : null, 14550 actions = this.options.actionsBox && this.multiple && this.$menu.find('.bs-actionsbox').length > 0 ? this.$menu.find('.bs-actionsbox')[0].cloneNode(true) : null, 14551 doneButton = this.options.doneButton && this.multiple && this.$menu.find('.bs-donebutton').length > 0 ? this.$menu.find('.bs-donebutton')[0].cloneNode(true) : null; 14552 14553 text.className = 'text'; 14554 newElement.className = this.$menu[0].parentNode.className + ' open'; 14555 menu.className = 'dropdown-menu open'; 14556 menuInner.className = 'dropdown-menu inner'; 14557 divider.className = 'divider'; 14558 14559 text.appendChild(document.createTextNode('Inner text')); 14560 a.appendChild(text); 14561 li.appendChild(a); 14562 menuInner.appendChild(li); 14563 menuInner.appendChild(divider); 14564 if (header) menu.appendChild(header); 14565 if (search) { 14566 // create a span instead of input as creating an input element is slower 14567 var input = document.createElement('span'); 14568 search.className = 'bs-searchbox'; 14569 input.className = 'form-control'; 14570 search.appendChild(input); 14571 menu.appendChild(search); 14572 } 14573 if (actions) menu.appendChild(actions); 14574 menu.appendChild(menuInner); 14575 if (doneButton) menu.appendChild(doneButton); 14576 newElement.appendChild(menu); 14577 14578 document.body.appendChild(newElement); 14579 14580 var liHeight = a.offsetHeight, 14581 headerHeight = header ? header.offsetHeight : 0, 14582 searchHeight = search ? search.offsetHeight : 0, 14583 actionsHeight = actions ? actions.offsetHeight : 0, 14584 doneButtonHeight = doneButton ? doneButton.offsetHeight : 0, 14585 dividerHeight = $(divider).outerHeight(true), 14586 // fall back to jQuery if getComputedStyle is not supported 14587 menuStyle = typeof getComputedStyle === 'function' ? getComputedStyle(menu) : false, 14588 $menu = menuStyle ? null : $(menu), 14589 menuPadding = { 14590 vert: parseInt(menuStyle ? menuStyle.paddingTop : $menu.css('paddingTop')) + 14591 parseInt(menuStyle ? menuStyle.paddingBottom : $menu.css('paddingBottom')) + 14592 parseInt(menuStyle ? menuStyle.borderTopWidth : $menu.css('borderTopWidth')) + 14593 parseInt(menuStyle ? menuStyle.borderBottomWidth : $menu.css('borderBottomWidth')), 14594 horiz: parseInt(menuStyle ? menuStyle.paddingLeft : $menu.css('paddingLeft')) + 14595 parseInt(menuStyle ? menuStyle.paddingRight : $menu.css('paddingRight')) + 14596 parseInt(menuStyle ? menuStyle.borderLeftWidth : $menu.css('borderLeftWidth')) + 14597 parseInt(menuStyle ? menuStyle.borderRightWidth : $menu.css('borderRightWidth')) 14598 }, 14599 menuExtras = { 14600 vert: menuPadding.vert + 14601 parseInt(menuStyle ? menuStyle.marginTop : $menu.css('marginTop')) + 14602 parseInt(menuStyle ? menuStyle.marginBottom : $menu.css('marginBottom')) + 2, 14603 horiz: menuPadding.horiz + 14604 parseInt(menuStyle ? menuStyle.marginLeft : $menu.css('marginLeft')) + 14605 parseInt(menuStyle ? menuStyle.marginRight : $menu.css('marginRight')) + 2 14606 } 14607 14608 document.body.removeChild(newElement); 14609 14610 this.sizeInfo = { 14611 liHeight: liHeight, 14612 headerHeight: headerHeight, 14613 searchHeight: searchHeight, 14614 actionsHeight: actionsHeight, 14615 doneButtonHeight: doneButtonHeight, 14616 dividerHeight: dividerHeight, 14617 menuPadding: menuPadding, 14618 menuExtras: menuExtras 14619 }; 14620 }, 14621 14622 setSize: function () { 14623 this.findLis(); 14624 this.liHeight(); 14625 14626 if (this.options.header) this.$menu.css('padding-top', 0); 14627 if (this.options.size === false) return; 14628 14629 var that = this, 14630 $menu = this.$menu, 14631 $menuInner = this.$menuInner, 14632 $window = $(window), 14633 selectHeight = this.$newElement[0].offsetHeight, 14634 selectWidth = this.$newElement[0].offsetWidth, 14635 liHeight = this.sizeInfo['liHeight'], 14636 headerHeight = this.sizeInfo['headerHeight'], 14637 searchHeight = this.sizeInfo['searchHeight'], 14638 actionsHeight = this.sizeInfo['actionsHeight'], 14639 doneButtonHeight = this.sizeInfo['doneButtonHeight'], 14640 divHeight = this.sizeInfo['dividerHeight'], 14641 menuPadding = this.sizeInfo['menuPadding'], 14642 menuExtras = this.sizeInfo['menuExtras'], 14643 notDisabled = this.options.hideDisabled ? '.disabled' : '', 14644 menuHeight, 14645 menuWidth, 14646 getHeight, 14647 getWidth, 14648 selectOffsetTop, 14649 selectOffsetBot, 14650 selectOffsetLeft, 14651 selectOffsetRight, 14652 getPos = function() { 14653 var pos = that.$newElement.offset(), 14654 $container = $(that.options.container), 14655 containerPos; 14656 14657 if (that.options.container && !$container.is('body')) { 14658 containerPos = $container.offset(); 14659 containerPos.top += parseInt($container.css('borderTopWidth')); 14660 containerPos.left += parseInt($container.css('borderLeftWidth')); 14661 } else { 14662 containerPos = { top: 0, left: 0 }; 14663 } 14664 14665 var winPad = that.options.windowPadding; 14666 selectOffsetTop = pos.top - containerPos.top - $window.scrollTop(); 14667 selectOffsetBot = $window.height() - selectOffsetTop - selectHeight - containerPos.top - winPad[2]; 14668 selectOffsetLeft = pos.left - containerPos.left - $window.scrollLeft(); 14669 selectOffsetRight = $window.width() - selectOffsetLeft - selectWidth - containerPos.left - winPad[1]; 14670 selectOffsetTop -= winPad[0]; 14671 selectOffsetLeft -= winPad[3]; 14672 }; 14673 14674 getPos(); 14675 14676 if (this.options.size === 'auto') { 14677 var getSize = function () { 14678 var minHeight, 14679 hasClass = function (className, include) { 14680 return function (element) { 14681 if (include) { 14682 return (element.classList ? element.classList.contains(className) : $(element).hasClass(className)); 14683 } else { 14684 return !(element.classList ? element.classList.contains(className) : $(element).hasClass(className)); 14685 } 14686 }; 14687 }, 14688 lis = that.$menuInner[0].getElementsByTagName('li'), 14689 lisVisible = Array.prototype.filter ? Array.prototype.filter.call(lis, hasClass('hidden', false)) : that.$lis.not('.hidden'), 14690 optGroup = Array.prototype.filter ? Array.prototype.filter.call(lisVisible, hasClass('dropdown-header', true)) : lisVisible.filter('.dropdown-header'); 14691 14692 getPos(); 14693 menuHeight = selectOffsetBot - menuExtras.vert; 14694 menuWidth = selectOffsetRight - menuExtras.horiz; 14695 14696 if (that.options.container) { 14697 if (!$menu.data('height')) $menu.data('height', $menu.height()); 14698 getHeight = $menu.data('height'); 14699 14700 if (!$menu.data('width')) $menu.data('width', $menu.width()); 14701 getWidth = $menu.data('width'); 14702 } else { 14703 getHeight = $menu.height(); 14704 getWidth = $menu.width(); 14705 } 14706 14707 if (that.options.dropupAuto) { 14708 that.$newElement.toggleClass('dropup', selectOffsetTop > selectOffsetBot && (menuHeight - menuExtras.vert) < getHeight); 14709 } 14710 14711 if (that.$newElement.hasClass('dropup')) { 14712 menuHeight = selectOffsetTop - menuExtras.vert; 14713 } 14714 14715 if (that.options.dropdownAlignRight === 'auto') { 14716 $menu.toggleClass('dropdown-menu-right', selectOffsetLeft > selectOffsetRight && (menuWidth - menuExtras.horiz) < (getWidth - selectWidth)); 14717 } 14718 14719 if ((lisVisible.length + optGroup.length) > 3) { 14720 minHeight = liHeight * 3 + menuExtras.vert - 2; 14721 } else { 14722 minHeight = 0; 14723 } 14724 14725 $menu.css({ 14726 'max-height': menuHeight + 'px', 14727 'overflow': 'hidden', 14728 'min-height': minHeight + headerHeight + searchHeight + actionsHeight + doneButtonHeight + 'px' 14729 }); 14730 $menuInner.css({ 14731 'max-height': menuHeight - headerHeight - searchHeight - actionsHeight - doneButtonHeight - menuPadding.vert + 'px', 14732 'overflow-y': 'auto', 14733 'min-height': Math.max(minHeight - menuPadding.vert, 0) + 'px' 14734 }); 14735 }; 14736 getSize(); 14737 this.$searchbox.off('input.getSize propertychange.getSize').on('input.getSize propertychange.getSize', getSize); 14738 $window.off('resize.getSize scroll.getSize').on('resize.getSize scroll.getSize', getSize); 14739 } else if (this.options.size && this.options.size != 'auto' && this.$lis.not(notDisabled).length > this.options.size) { 14740 var optIndex = this.$lis.not('.divider').not(notDisabled).children().slice(0, this.options.size).last().parent().index(), 14741 divLength = this.$lis.slice(0, optIndex + 1).filter('.divider').length; 14742 menuHeight = liHeight * this.options.size + divLength * divHeight + menuPadding.vert; 14743 14744 if (that.options.container) { 14745 if (!$menu.data('height')) $menu.data('height', $menu.height()); 14746 getHeight = $menu.data('height'); 14747 } else { 14748 getHeight = $menu.height(); 14749 } 14750 14751 if (that.options.dropupAuto) { 14752 //noinspection JSUnusedAssignment 14753 this.$newElement.toggleClass('dropup', selectOffsetTop > selectOffsetBot && (menuHeight - menuExtras.vert) < getHeight); 14754 } 14755 $menu.css({ 14756 'max-height': menuHeight + headerHeight + searchHeight + actionsHeight + doneButtonHeight + 'px', 14757 'overflow': 'hidden', 14758 'min-height': '' 14759 }); 14760 $menuInner.css({ 14761 'max-height': menuHeight - menuPadding.vert + 'px', 14762 'overflow-y': 'auto', 14763 'min-height': '' 14764 }); 14765 } 14766 }, 14767 14768 setWidth: function () { 14769 if (this.options.width === 'auto') { 14770 this.$menu.css('min-width', '0'); 14771 14772 // Get correct width if element is hidden 14773 var $selectClone = this.$menu.parent().clone().appendTo('body'), 14774 $selectClone2 = this.options.container ? this.$newElement.clone().appendTo('body') : $selectClone, 14775 ulWidth = $selectClone.children('.dropdown-menu').outerWidth(), 14776 btnWidth = $selectClone2.css('width', 'auto').children('button').outerWidth(); 14777 14778 $selectClone.remove(); 14779 $selectClone2.remove(); 14780 14781 // Set width to whatever's larger, button title or longest option 14782 this.$newElement.css('width', Math.max(ulWidth, btnWidth) + 'px'); 14783 } else if (this.options.width === 'fit') { 14784 // Remove inline min-width so width can be changed from 'auto' 14785 this.$menu.css('min-width', ''); 14786 this.$newElement.css('width', '').addClass('fit-width'); 14787 } else if (this.options.width) { 14788 // Remove inline min-width so width can be changed from 'auto' 14789 this.$menu.css('min-width', ''); 14790 this.$newElement.css('width', this.options.width); 14791 } else { 14792 // Remove inline min-width/width so width can be changed 14793 this.$menu.css('min-width', ''); 14794 this.$newElement.css('width', ''); 14795 } 14796 // Remove fit-width class if width is changed programmatically 14797 if (this.$newElement.hasClass('fit-width') && this.options.width !== 'fit') { 14798 this.$newElement.removeClass('fit-width'); 14799 } 14800 }, 14801 14802 selectPosition: function () { 14803 this.$bsContainer = $('<div class="bs-container" />'); 14804 14805 var that = this, 14806 $container = $(this.options.container), 14807 pos, 14808 containerPos, 14809 actualHeight, 14810 getPlacement = function ($element) { 14811 that.$bsContainer.addClass($element.attr('class').replace(/form-control|fit-width/gi, '')).toggleClass('dropup', $element.hasClass('dropup')); 14812 pos = $element.offset(); 14813 14814 if (!$container.is('body')) { 14815 containerPos = $container.offset(); 14816 containerPos.top += parseInt($container.css('borderTopWidth')) - $container.scrollTop(); 14817 containerPos.left += parseInt($container.css('borderLeftWidth')) - $container.scrollLeft(); 14818 } else { 14819 containerPos = { top: 0, left: 0 }; 14820 } 14821 14822 actualHeight = $element.hasClass('dropup') ? 0 : $element[0].offsetHeight; 14823 14824 that.$bsContainer.css({ 14825 'top': pos.top - containerPos.top + actualHeight, 14826 'left': pos.left - containerPos.left, 14827 'width': $element[0].offsetWidth 14828 }); 14829 }; 14830 14831 this.$button.on('click', function () { 14832 var $this = $(this); 14833 14834 if (that.isDisabled()) { 14835 return; 14836 } 14837 14838 getPlacement(that.$newElement); 14839 14840 that.$bsContainer 14841 .appendTo(that.options.container) 14842 .toggleClass('open', !$this.hasClass('open')) 14843 .append(that.$menu); 14844 }); 14845 14846 $(window).on('resize scroll', function () { 14847 getPlacement(that.$newElement); 14848 }); 14849 14850 this.$element.on('hide.bs.select', function () { 14851 that.$menu.data('height', that.$menu.height()); 14852 that.$bsContainer.detach(); 14853 }); 14854 }, 14855 14856 /** 14857 * @param {number} index - the index of the option that is being changed 14858 * @param {boolean} selected - true if the option is being selected, false if being deselected 14859 * @param {JQuery} $lis - the 'li' element that is being modified 14860 */ 14861 setSelected: function (index, selected, $lis) { 14862 if (!$lis) { 14863 this.togglePlaceholder(); // check if setSelected is being called by changing the value of the select 14864 $lis = this.findLis().eq(this.liObj[index]); 14865 } 14866 14867 $lis.toggleClass('selected', selected).find('a').attr('aria-selected', selected); 14868 }, 14869 14870 /** 14871 * @param {number} index - the index of the option that is being disabled 14872 * @param {boolean} disabled - true if the option is being disabled, false if being enabled 14873 * @param {JQuery} $lis - the 'li' element that is being modified 14874 */ 14875 setDisabled: function (index, disabled, $lis) { 14876 if (!$lis) { 14877 $lis = this.findLis().eq(this.liObj[index]); 14878 } 14879 14880 if (disabled) { 14881 $lis.addClass('disabled').children('a').attr('href', '#').attr('tabindex', -1).attr('aria-disabled', true); 14882 } else { 14883 $lis.removeClass('disabled').children('a').removeAttr('href').attr('tabindex', 0).attr('aria-disabled', false); 14884 } 14885 }, 14886 14887 isDisabled: function () { 14888 return this.$element[0].disabled; 14889 }, 14890 14891 checkDisabled: function () { 14892 var that = this; 14893 14894 if (this.isDisabled()) { 14895 this.$newElement.addClass('disabled'); 14896 this.$button.addClass('disabled').attr('tabindex', -1).attr('aria-disabled', true); 14897 } else { 14898 if (this.$button.hasClass('disabled')) { 14899 this.$newElement.removeClass('disabled'); 14900 this.$button.removeClass('disabled').attr('aria-disabled', false); 14901 } 14902 14903 if (this.$button.attr('tabindex') == -1 && !this.$element.data('tabindex')) { 14904 this.$button.removeAttr('tabindex'); 14905 } 14906 } 14907 14908 this.$button.click(function () { 14909 return !that.isDisabled(); 14910 }); 14911 }, 14912 14913 togglePlaceholder: function () { 14914 var value = this.$element.val(); 14915 this.$button.toggleClass('bs-placeholder', value === null || value === '' || (value.constructor === Array && value.length === 0)); 14916 }, 14917 14918 tabIndex: function () { 14919 if (this.$element.data('tabindex') !== this.$element.attr('tabindex') && 14920 (this.$element.attr('tabindex') !== -98 && this.$element.attr('tabindex') !== '-98')) { 14921 this.$element.data('tabindex', this.$element.attr('tabindex')); 14922 this.$button.attr('tabindex', this.$element.data('tabindex')); 14923 } 14924 14925 this.$element.attr('tabindex', -98); 14926 }, 14927 14928 clickListener: function () { 14929 var that = this, 14930 $document = $(document); 14931 14932 $document.data('spaceSelect', false); 14933 14934 this.$button.on('keyup', function (e) { 14935 if (/(32)/.test(e.keyCode.toString(10)) && $document.data('spaceSelect')) { 14936 e.preventDefault(); 14937 $document.data('spaceSelect', false); 14938 } 14939 }); 14940 14941 this.$button.on('click', function () { 14942 that.setSize(); 14943 }); 14944 14945 this.$element.on('shown.bs.select', function () { 14946 if (!that.options.liveSearch && !that.multiple) { 14947 that.$menuInner.find('.selected a').focus(); 14948 } else if (!that.multiple) { 14949 var selectedIndex = that.liObj[that.$element[0].selectedIndex]; 14950 14951 if (typeof selectedIndex !== 'number' || that.options.size === false) return; 14952 14953 // scroll to selected option 14954 var offset = that.$lis.eq(selectedIndex)[0].offsetTop - that.$menuInner[0].offsetTop; 14955 offset = offset - that.$menuInner[0].offsetHeight/2 + that.sizeInfo.liHeight/2; 14956 that.$menuInner[0].scrollTop = offset; 14957 } 14958 }); 14959 14960 this.$menuInner.on('click', 'li a', function (e) { 14961 var $this = $(this), 14962 clickedIndex = $this.parent().data('originalIndex'), 14963 prevValue = that.$element.val(), 14964 prevIndex = that.$element.prop('selectedIndex'), 14965 triggerChange = true; 14966 14967 // Don't close on multi choice menu 14968 if (that.multiple && that.options.maxOptions !== 1) { 14969 e.stopPropagation(); 14970 } 14971 14972 e.preventDefault(); 14973 14974 //Don't run if we have been disabled 14975 if (!that.isDisabled() && !$this.parent().hasClass('disabled')) { 14976 var $options = that.$element.find('option'), 14977 $option = $options.eq(clickedIndex), 14978 state = $option.prop('selected'), 14979 $optgroup = $option.parent('optgroup'), 14980 maxOptions = that.options.maxOptions, 14981 maxOptionsGrp = $optgroup.data('maxOptions') || false; 14982 14983 if (!that.multiple) { // Deselect all others if not multi select box 14984 $options.prop('selected', false); 14985 $option.prop('selected', true); 14986 that.$menuInner.find('.selected').removeClass('selected').find('a').attr('aria-selected', false); 14987 that.setSelected(clickedIndex, true); 14988 } else { // Toggle the one we have chosen if we are multi select. 14989 $option.prop('selected', !state); 14990 that.setSelected(clickedIndex, !state); 14991 $this.blur(); 14992 14993 if (maxOptions !== false || maxOptionsGrp !== false) { 14994 var maxReached = maxOptions < $options.filter(':selected').length, 14995 maxReachedGrp = maxOptionsGrp < $optgroup.find('option:selected').length; 14996 14997 if ((maxOptions && maxReached) || (maxOptionsGrp && maxReachedGrp)) { 14998 if (maxOptions && maxOptions == 1) { 14999 $options.prop('selected', false); 15000 $option.prop('selected', true); 15001 that.$menuInner.find('.selected').removeClass('selected'); 15002 that.setSelected(clickedIndex, true); 15003 } else if (maxOptionsGrp && maxOptionsGrp == 1) { 15004 $optgroup.find('option:selected').prop('selected', false); 15005 $option.prop('selected', true); 15006 var optgroupID = $this.parent().data('optgroup'); 15007 that.$menuInner.find('[data-optgroup="' + optgroupID + '"]').removeClass('selected'); 15008 that.setSelected(clickedIndex, true); 15009 } else { 15010 var maxOptionsText = typeof that.options.maxOptionsText === 'string' ? [that.options.maxOptionsText, that.options.maxOptionsText] : that.options.maxOptionsText, 15011 maxOptionsArr = typeof maxOptionsText === 'function' ? maxOptionsText(maxOptions, maxOptionsGrp) : maxOptionsText, 15012 maxTxt = maxOptionsArr[0].replace('{n}', maxOptions), 15013 maxTxtGrp = maxOptionsArr[1].replace('{n}', maxOptionsGrp), 15014 $notify = $('<div class="notify"></div>'); 15015 // If {var} is set in array, replace it 15016 /** @deprecated */ 15017 if (maxOptionsArr[2]) { 15018 maxTxt = maxTxt.replace('{var}', maxOptionsArr[2][maxOptions > 1 ? 0 : 1]); 15019 maxTxtGrp = maxTxtGrp.replace('{var}', maxOptionsArr[2][maxOptionsGrp > 1 ? 0 : 1]); 15020 } 15021 15022 $option.prop('selected', false); 15023 15024 that.$menu.append($notify); 15025 15026 if (maxOptions && maxReached) { 15027 $notify.append($('<div>' + maxTxt + '</div>')); 15028 triggerChange = false; 15029 that.$element.trigger('maxReached.bs.select'); 15030 } 15031 15032 if (maxOptionsGrp && maxReachedGrp) { 15033 $notify.append($('<div>' + maxTxtGrp + '</div>')); 15034 triggerChange = false; 15035 that.$element.trigger('maxReachedGrp.bs.select'); 15036 } 15037 15038 setTimeout(function () { 15039 that.setSelected(clickedIndex, false); 15040 }, 10); 15041 15042 $notify.delay(750).fadeOut(300, function () { 15043 $(this).remove(); 15044 }); 15045 } 15046 } 15047 } 15048 } 15049 15050 if (!that.multiple || (that.multiple && that.options.maxOptions === 1)) { 15051 that.$button.focus(); 15052 } else if (that.options.liveSearch) { 15053 that.$searchbox.focus(); 15054 } 15055 15056 // Trigger select 'change' 15057 if (triggerChange) { 15058 if ((prevValue != that.$element.val() && that.multiple) || (prevIndex != that.$element.prop('selectedIndex') && !that.multiple)) { 15059 // $option.prop('selected') is current option state (selected/unselected). state is previous option state. 15060 changed_arguments = [clickedIndex, $option.prop('selected'), state]; 15061 that.$element 15062 .triggerNative('change'); 15063 } 15064 } 15065 } 15066 }); 15067 15068 this.$menu.on('click', 'li.disabled a, .popover-title, .popover-title :not(.close)', function (e) { 15069 if (e.currentTarget == this) { 15070 e.preventDefault(); 15071 e.stopPropagation(); 15072 if (that.options.liveSearch && !$(e.target).hasClass('close')) { 15073 that.$searchbox.focus(); 15074 } else { 15075 that.$button.focus(); 15076 } 15077 } 15078 }); 15079 15080 this.$menuInner.on('click', '.divider, .dropdown-header', function (e) { 15081 e.preventDefault(); 15082 e.stopPropagation(); 15083 if (that.options.liveSearch) { 15084 that.$searchbox.focus(); 15085 } else { 15086 that.$button.focus(); 15087 } 15088 }); 15089 15090 this.$menu.on('click', '.popover-title .close', function () { 15091 that.$button.click(); 15092 }); 15093 15094 this.$searchbox.on('click', function (e) { 15095 e.stopPropagation(); 15096 }); 15097 15098 this.$menu.on('click', '.actions-btn', function (e) { 15099 if (that.options.liveSearch) { 15100 that.$searchbox.focus(); 15101 } else { 15102 that.$button.focus(); 15103 } 15104 15105 e.preventDefault(); 15106 e.stopPropagation(); 15107 15108 if ($(this).hasClass('bs-select-all')) { 15109 that.selectAll(); 15110 } else { 15111 that.deselectAll(); 15112 } 15113 }); 15114 15115 this.$element.change(function () { 15116 that.render(false); 15117 that.$element.trigger('changed.bs.select', changed_arguments); 15118 changed_arguments = null; 15119 }); 15120 }, 15121 15122 liveSearchListener: function () { 15123 var that = this, 15124 $no_results = $('<li class="no-results"></li>'); 15125 15126 this.$button.on('click.dropdown.data-api', function () { 15127 that.$menuInner.find('.active').removeClass('active'); 15128 if (!!that.$searchbox.val()) { 15129 that.$searchbox.val(''); 15130 that.$lis.not('.is-hidden').removeClass('hidden'); 15131 if (!!$no_results.parent().length) $no_results.remove(); 15132 } 15133 if (!that.multiple) that.$menuInner.find('.selected').addClass('active'); 15134 setTimeout(function () { 15135 that.$searchbox.focus(); 15136 }, 10); 15137 }); 15138 15139 this.$searchbox.on('click.dropdown.data-api focus.dropdown.data-api touchend.dropdown.data-api', function (e) { 15140 e.stopPropagation(); 15141 }); 15142 15143 this.$searchbox.on('input propertychange', function () { 15144 that.$lis.not('.is-hidden').removeClass('hidden'); 15145 that.$lis.filter('.active').removeClass('active'); 15146 $no_results.remove(); 15147 15148 if (that.$searchbox.val()) { 15149 var $searchBase = that.$lis.not('.is-hidden, .divider, .dropdown-header'), 15150 $hideItems; 15151 if (that.options.liveSearchNormalize) { 15152 $hideItems = $searchBase.not(':a' + that._searchStyle() + '("' + normalizeToBase(that.$searchbox.val()) + '")'); 15153 } else { 15154 $hideItems = $searchBase.not(':' + that._searchStyle() + '("' + that.$searchbox.val() + '")'); 15155 } 15156 15157 if ($hideItems.length === $searchBase.length) { 15158 $no_results.html(that.options.noneResultsText.replace('{0}', '"' + htmlEscape(that.$searchbox.val()) + '"')); 15159 that.$menuInner.append($no_results); 15160 that.$lis.addClass('hidden'); 15161 } else { 15162 $hideItems.addClass('hidden'); 15163 15164 var $lisVisible = that.$lis.not('.hidden'), 15165 $foundDiv; 15166 15167 // hide divider if first or last visible, or if followed by another divider 15168 $lisVisible.each(function (index) { 15169 var $this = $(this); 15170 15171 if ($this.hasClass('divider')) { 15172 if ($foundDiv === undefined) { 15173 $this.addClass('hidden'); 15174 } else { 15175 if ($foundDiv) $foundDiv.addClass('hidden'); 15176 $foundDiv = $this; 15177 } 15178 } else if ($this.hasClass('dropdown-header') && $lisVisible.eq(index + 1).data('optgroup') !== $this.data('optgroup')) { 15179 $this.addClass('hidden'); 15180 } else { 15181 $foundDiv = null; 15182 } 15183 }); 15184 if ($foundDiv) $foundDiv.addClass('hidden'); 15185 15186 $searchBase.not('.hidden').first().addClass('active'); 15187 } 15188 } 15189 }); 15190 }, 15191 15192 _searchStyle: function () { 15193 var styles = { 15194 begins: 'ibegins', 15195 startsWith: 'ibegins' 15196 }; 15197 15198 return styles[this.options.liveSearchStyle] || 'icontains'; 15199 }, 15200 15201 val: function (value) { 15202 if (typeof value !== 'undefined') { 15203 this.$element.val(value); 15204 this.render(); 15205 15206 return this.$element; 15207 } else { 15208 return this.$element.val(); 15209 } 15210 }, 15211 15212 changeAll: function (status) { 15213 if (!this.multiple) return; 15214 if (typeof status === 'undefined') status = true; 15215 15216 this.findLis(); 15217 15218 var $options = this.$element.find('option'), 15219 $lisVisible = this.$lis.not('.divider, .dropdown-header, .disabled, .hidden'), 15220 lisVisLen = $lisVisible.length, 15221 selectedOptions = []; 15222 15223 if (status) { 15224 if ($lisVisible.filter('.selected').length === $lisVisible.length) return; 15225 } else { 15226 if ($lisVisible.filter('.selected').length === 0) return; 15227 } 15228 15229 $lisVisible.toggleClass('selected', status); 15230 15231 for (var i = 0; i < lisVisLen; i++) { 15232 var origIndex = $lisVisible[i].getAttribute('data-original-index'); 15233 selectedOptions[selectedOptions.length] = $options.eq(origIndex)[0]; 15234 } 15235 15236 $(selectedOptions).prop('selected', status); 15237 15238 this.render(false); 15239 15240 this.togglePlaceholder(); 15241 15242 this.$element 15243 .triggerNative('change'); 15244 }, 15245 15246 selectAll: function () { 15247 return this.changeAll(true); 15248 }, 15249 15250 deselectAll: function () { 15251 return this.changeAll(false); 15252 }, 15253 15254 toggle: function (e) { 15255 e = e || window.event; 15256 15257 if (e) e.stopPropagation(); 15258 15259 this.$button.trigger('click'); 15260 }, 15261 15262 keydown: function (e) { 15263 var $this = $(this), 15264 $parent = $this.is('input') ? $this.parent().parent() : $this.parent(), 15265 $items, 15266 that = $parent.data('this'), 15267 index, 15268 next, 15269 first, 15270 last, 15271 prev, 15272 nextPrev, 15273 prevIndex, 15274 isActive, 15275 selector = ':not(.disabled, .hidden, .dropdown-header, .divider)', 15276 keyCodeMap = { 15277 32: ' ', 15278 48: '0', 15279 49: '1', 15280 50: '2', 15281 51: '3', 15282 52: '4', 15283 53: '5', 15284 54: '6', 15285 55: '7', 15286 56: '8', 15287 57: '9', 15288 59: ';', 15289 65: 'a', 15290 66: 'b', 15291 67: 'c', 15292 68: 'd', 15293 69: 'e', 15294 70: 'f', 15295 71: 'g', 15296 72: 'h', 15297 73: 'i', 15298 74: 'j', 15299 75: 'k', 15300 76: 'l', 15301 77: 'm', 15302 78: 'n', 15303 79: 'o', 15304 80: 'p', 15305 81: 'q', 15306 82: 'r', 15307 83: 's', 15308 84: 't', 15309 85: 'u', 15310 86: 'v', 15311 87: 'w', 15312 88: 'x', 15313 89: 'y', 15314 90: 'z', 15315 96: '0', 15316 97: '1', 15317 98: '2', 15318 99: '3', 15319 100: '4', 15320 101: '5', 15321 102: '6', 15322 103: '7', 15323 104: '8', 15324 105: '9' 15325 }; 15326 15327 if (that.options.liveSearch) $parent = $this.parent().parent(); 15328 15329 if (that.options.container) $parent = that.$menu; 15330 15331 $items = $('[role="listbox"] li', $parent); 15332 15333 isActive = that.$newElement.hasClass('open'); 15334 15335 if (!isActive && (e.keyCode >= 48 && e.keyCode <= 57 || e.keyCode >= 96 && e.keyCode <= 105 || e.keyCode >= 65 && e.keyCode <= 90)) { 15336 if (!that.options.container) { 15337 that.setSize(); 15338 that.$menu.parent().addClass('open'); 15339 isActive = true; 15340 } else { 15341 that.$button.trigger('click'); 15342 } 15343 that.$searchbox.focus(); 15344 return; 15345 } 15346 15347 if (that.options.liveSearch) { 15348 if (/(^9$|27)/.test(e.keyCode.toString(10)) && isActive) { 15349 e.preventDefault(); 15350 e.stopPropagation(); 15351 that.$menuInner.click(); 15352 that.$button.focus(); 15353 } 15354 // $items contains li elements when liveSearch is enabled 15355 $items = $('[role="listbox"] li' + selector, $parent); 15356 if (!$this.val() && !/(38|40)/.test(e.keyCode.toString(10))) { 15357 if ($items.filter('.active').length === 0) { 15358 $items = that.$menuInner.find('li'); 15359 if (that.options.liveSearchNormalize) { 15360 $items = $items.filter(':a' + that._searchStyle() + '(' + normalizeToBase(keyCodeMap[e.keyCode]) + ')'); 15361 } else { 15362 $items = $items.filter(':' + that._searchStyle() + '(' + keyCodeMap[e.keyCode] + ')'); 15363 } 15364 } 15365 } 15366 } 15367 15368 if (!$items.length) return; 15369 15370 if (/(38|40)/.test(e.keyCode.toString(10))) { 15371 index = $items.index($items.find('a').filter(':focus').parent()); 15372 first = $items.filter(selector).first().index(); 15373 last = $items.filter(selector).last().index(); 15374 next = $items.eq(index).nextAll(selector).eq(0).index(); 15375 prev = $items.eq(index).prevAll(selector).eq(0).index(); 15376 nextPrev = $items.eq(next).prevAll(selector).eq(0).index(); 15377 15378 if (that.options.liveSearch) { 15379 $items.each(function (i) { 15380 if (!$(this).hasClass('disabled')) { 15381 $(this).data('index', i); 15382 } 15383 }); 15384 index = $items.index($items.filter('.active')); 15385 first = $items.first().data('index'); 15386 last = $items.last().data('index'); 15387 next = $items.eq(index).nextAll().eq(0).data('index'); 15388 prev = $items.eq(index).prevAll().eq(0).data('index'); 15389 nextPrev = $items.eq(next).prevAll().eq(0).data('index'); 15390 } 15391 15392 prevIndex = $this.data('prevIndex'); 15393 15394 if (e.keyCode == 38) { 15395 if (that.options.liveSearch) index--; 15396 if (index != nextPrev && index > prev) index = prev; 15397 if (index < first) index = first; 15398 if (index == prevIndex) index = last; 15399 } else if (e.keyCode == 40) { 15400 if (that.options.liveSearch) index++; 15401 if (index == -1) index = 0; 15402 if (index != nextPrev && index < next) index = next; 15403 if (index > last) index = last; 15404 if (index == prevIndex) index = first; 15405 } 15406 15407 $this.data('prevIndex', index); 15408 15409 if (!that.options.liveSearch) { 15410 $items.eq(index).children('a').focus(); 15411 } else { 15412 e.preventDefault(); 15413 if (!$this.hasClass('dropdown-toggle')) { 15414 $items.removeClass('active').eq(index).addClass('active').children('a').focus(); 15415 $this.focus(); 15416 } 15417 } 15418 15419 } else if (!$this.is('input')) { 15420 var keyIndex = [], 15421 count, 15422 prevKey; 15423 15424 $items.each(function () { 15425 if (!$(this).hasClass('disabled')) { 15426 if ($.trim($(this).children('a').text().toLowerCase()).substring(0, 1) == keyCodeMap[e.keyCode]) { 15427 keyIndex.push($(this).index()); 15428 } 15429 } 15430 }); 15431 15432 count = $(document).data('keycount'); 15433 count++; 15434 $(document).data('keycount', count); 15435 15436 prevKey = $.trim($(':focus').text().toLowerCase()).substring(0, 1); 15437 15438 if (prevKey != keyCodeMap[e.keyCode]) { 15439 count = 1; 15440 $(document).data('keycount', count); 15441 } else if (count >= keyIndex.length) { 15442 $(document).data('keycount', 0); 15443 if (count > keyIndex.length) count = 1; 15444 } 15445 15446 $items.eq(keyIndex[count - 1]).children('a').focus(); 15447 } 15448 15449 // Select focused option if "Enter", "Spacebar" or "Tab" (when selectOnTab is true) are pressed inside the menu. 15450 if ((/(13|32)/.test(e.keyCode.toString(10)) || (/(^9$)/.test(e.keyCode.toString(10)) && that.options.selectOnTab)) && isActive) { 15451 if (!/(32)/.test(e.keyCode.toString(10))) e.preventDefault(); 15452 if (!that.options.liveSearch) { 15453 var elem = $(':focus'); 15454 elem.click(); 15455 // Bring back focus for multiselects 15456 elem.focus(); 15457 // Prevent screen from scrolling if the user hit the spacebar 15458 e.preventDefault(); 15459 // Fixes spacebar selection of dropdown items in FF & IE 15460 $(document).data('spaceSelect', true); 15461 } else if (!/(32)/.test(e.keyCode.toString(10))) { 15462 that.$menuInner.find('.active a').click(); 15463 $this.focus(); 15464 } 15465 $(document).data('keycount', 0); 15466 } 15467 15468 if ((/(^9$|27)/.test(e.keyCode.toString(10)) && isActive && (that.multiple || that.options.liveSearch)) || (/(27)/.test(e.keyCode.toString(10)) && !isActive)) { 15469 that.$menu.parent().removeClass('open'); 15470 if (that.options.container) that.$newElement.removeClass('open'); 15471 that.$button.focus(); 15472 } 15473 }, 15474 15475 mobile: function () { 15476 this.$element.addClass('mobile-device'); 15477 }, 15478 15479 refresh: function () { 15480 this.$lis = null; 15481 this.liObj = {}; 15482 this.reloadLi(); 15483 this.render(); 15484 this.checkDisabled(); 15485 this.liHeight(true); 15486 this.setStyle(); 15487 this.setWidth(); 15488 if (this.$lis) this.$searchbox.trigger('propertychange'); 15489 15490 this.$element.trigger('refreshed.bs.select'); 15491 }, 15492 15493 hide: function () { 15494 this.$newElement.hide(); 15495 }, 15496 15497 show: function () { 15498 this.$newElement.show(); 15499 }, 15500 15501 remove: function () { 15502 this.$newElement.remove(); 15503 this.$element.remove(); 15504 }, 15505 15506 destroy: function () { 15507 this.$newElement.before(this.$element).remove(); 15508 15509 if (this.$bsContainer) { 15510 this.$bsContainer.remove(); 15511 } else { 15512 this.$menu.remove(); 15513 } 15514 15515 this.$element 15516 .off('.bs.select') 15517 .removeData('selectpicker') 15518 .removeClass('bs-select-hidden selectpicker'); 15519 } 15520 }; 15521 15522 // SELECTPICKER PLUGIN DEFINITION 15523 // ============================== 15524 function Plugin(option) { 15525 // get the args of the outer function.. 15526 var args = arguments; 15527 // The arguments of the function are explicitly re-defined from the argument list, because the shift causes them 15528 // to get lost/corrupted in android 2.3 and IE9 #715 #775 15529 var _option = option; 15530 15531 [].shift.apply(args); 15532 15533 var value; 15534 var chain = this.each(function () { 15535 var $this = $(this); 15536 if ($this.is('select')) { 15537 var data = $this.data('selectpicker'), 15538 options = typeof _option == 'object' && _option; 15539 15540 if (!data) { 15541 var config = $.extend({}, Selectpicker.DEFAULTS, $.fn.selectpicker.defaults || {}, $this.data(), options); 15542 config.template = $.extend({}, Selectpicker.DEFAULTS.template, ($.fn.selectpicker.defaults ? $.fn.selectpicker.defaults.template : {}), $this.data().template, options.template); 15543 $this.data('selectpicker', (data = new Selectpicker(this, config))); 15544 } else if (options) { 15545 for (var i in options) { 15546 if (options.hasOwnProperty(i)) { 15547 data.options[i] = options[i]; 15548 } 15549 } 15550 } 15551 15552 if (typeof _option == 'string') { 15553 if (data[_option] instanceof Function) { 15554 value = data[_option].apply(data, args); 15555 } else { 15556 value = data.options[_option]; 15557 } 15558 } 15559 } 15560 }); 15561 15562 if (typeof value !== 'undefined') { 15563 //noinspection JSUnusedAssignment 15564 return value; 15565 } else { 15566 return chain; 15567 } 15568 } 15569 15570 var old = $.fn.selectpicker; 15571 $.fn.selectpicker = Plugin; 15572 $.fn.selectpicker.Constructor = Selectpicker; 15573 15574 // SELECTPICKER NO CONFLICT 15575 // ======================== 15576 $.fn.selectpicker.noConflict = function () { 15577 $.fn.selectpicker = old; 15578 return this; 15579 }; 15580 15581 $(document) 15582 .data('keycount', 0) 15583 .on('keydown.bs.select', '.bootstrap-select [data-toggle=dropdown], .bootstrap-select [role="listbox"], .bs-searchbox input', Selectpicker.prototype.keydown) 15584 .on('focusin.modal', '.bootstrap-select [data-toggle=dropdown], .bootstrap-select [role="listbox"], .bs-searchbox input', function (e) { 15585 e.stopPropagation(); 15586 }); 15587 15588 // SELECTPICKER DATA-API 15589 // ===================== 15590 $(window).on('load.bs.select.data-api', function () { 15591 $('.selectpicker').each(function () { 15592 var $selectpicker = $(this); 15593 Plugin.call($selectpicker, $selectpicker.data()); 15594 }) 15595 }); 15596 })(jQuery); 15597 15598 15599 })); 15600 15601 15602 /***/ }, 15603 /* 87 */ 15604 /***/ function(module, exports) { 15605 15606 // removed by extract-text-webpack-plugin 15607 15608 /***/ }, 15609 /* 88 */, 15610 /* 89 */, 15611 /* 90 */, 15612 /* 91 */, 15613 /* 92 */, 15614 /* 93 */, 15615 /* 94 */, 15616 /* 95 */, 15617 /* 96 */ 15618 /***/ function(module, exports) { 15619 15620 // removed by extract-text-webpack-plugin 15621 15622 /***/ }, 15623 /* 97 */, 15624 /* 98 */ 15625 /***/ function(module, exports) { 15626 15627 // removed by extract-text-webpack-plugin 15628 15629 /***/ }, 15630 /* 99 */, 15631 /* 100 */, 15632 /* 101 */, 15633 /* 102 */, 15634 /* 103 */, 15635 /* 104 */, 15636 /* 105 */, 15637 /* 106 */ 15638 /***/ function(module, exports) { 15639 15640 // removed by extract-text-webpack-plugin 15641 15642 /***/ }, 15643 /* 107 */, 15644 /* 108 */ 15645 /***/ function(module, exports) { 15646 15647 // removed by extract-text-webpack-plugin 15648 15649 /***/ }, 15650 /* 109 */, 15651 /* 110 */, 15652 /* 111 */ 15653 /***/ function(module, exports) { 15654 15655 // removed by extract-text-webpack-plugin 15656 15657 /***/ }, 15658 /* 112 */, 15659 /* 113 */ 15660 /***/ function(module, exports, __webpack_require__) { 15661 15662 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(global) {// Backbone.js 1.3.3 15663 15664 // (c) 2010-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 15665 // Backbone may be freely distributed under the MIT license. 15666 // For all details and documentation: 15667 // http://backbonejs.org 15668 15669 (function(factory) { 15670 15671 // Establish the root object, `window` (`self`) in the browser, or `global` on the server. 15672 // We use `self` instead of `window` for `WebWorker` support. 15673 var root = (typeof self == 'object' && self.self === self && self) || 15674 (typeof global == 'object' && global.global === global && global); 15675 15676 // Set up Backbone appropriately for the environment. Start with AMD. 15677 if (true) { 15678 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(114), __webpack_require__(71), exports], __WEBPACK_AMD_DEFINE_RESULT__ = function(_, $, exports) { 15679 // Export global even in AMD case in case this script is loaded with 15680 // others that may still expect a global Backbone. 15681 root.Backbone = factory(root, exports, _, $); 15682 }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 15683 15684 // Next for Node.js or CommonJS. jQuery may not be needed as a module. 15685 } else if (typeof exports !== 'undefined') { 15686 var _ = require('underscore'), $; 15687 try { $ = require('jquery'); } catch (e) {} 15688 factory(root, exports, _, $); 15689 15690 // Finally, as a browser global. 15691 } else { 15692 root.Backbone = factory(root, {}, root._, (root.jQuery || root.Zepto || root.ender || root.$)); 15693 } 15694 15695 })(function(root, Backbone, _, $) { 15696 15697 // Initial Setup 15698 // ------------- 15699 15700 // Save the previous value of the `Backbone` variable, so that it can be 15701 // restored later on, if `noConflict` is used. 15702 var previousBackbone = root.Backbone; 15703 15704 // Create a local reference to a common array method we'll want to use later. 15705 var slice = Array.prototype.slice; 15706 15707 // Current version of the library. Keep in sync with `package.json`. 15708 Backbone.VERSION = '1.3.3'; 15709 15710 // For Backbone's purposes, jQuery, Zepto, Ender, or My Library (kidding) owns 15711 // the `$` variable. 15712 Backbone.$ = $; 15713 15714 // Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable 15715 // to its previous owner. Returns a reference to this Backbone object. 15716 Backbone.noConflict = function() { 15717 root.Backbone = previousBackbone; 15718 return this; 15719 }; 15720 15721 // Turn on `emulateHTTP` to support legacy HTTP servers. Setting this option 15722 // will fake `"PATCH"`, `"PUT"` and `"DELETE"` requests via the `_method` parameter and 15723 // set a `X-Http-Method-Override` header. 15724 Backbone.emulateHTTP = false; 15725 15726 // Turn on `emulateJSON` to support legacy servers that can't deal with direct 15727 // `application/json` requests ... this will encode the body as 15728 // `application/x-www-form-urlencoded` instead and will send the model in a 15729 // form param named `model`. 15730 Backbone.emulateJSON = false; 15731 15732 // Proxy Backbone class methods to Underscore functions, wrapping the model's 15733 // `attributes` object or collection's `models` array behind the scenes. 15734 // 15735 // collection.filter(function(model) { return model.get('age') > 10 }); 15736 // collection.each(this.addView); 15737 // 15738 // `Function#apply` can be slow so we use the method's arg count, if we know it. 15739 var addMethod = function(length, method, attribute) { 15740 switch (length) { 15741 case 1: return function() { 15742 return _[method](this[attribute]); 15743 }; 15744 case 2: return function(value) { 15745 return _[method](this[attribute], value); 15746 }; 15747 case 3: return function(iteratee, context) { 15748 return _[method](this[attribute], cb(iteratee, this), context); 15749 }; 15750 case 4: return function(iteratee, defaultVal, context) { 15751 return _[method](this[attribute], cb(iteratee, this), defaultVal, context); 15752 }; 15753 default: return function() { 15754 var args = slice.call(arguments); 15755 args.unshift(this[attribute]); 15756 return _[method].apply(_, args); 15757 }; 15758 } 15759 }; 15760 var addUnderscoreMethods = function(Class, methods, attribute) { 15761 _.each(methods, function(length, method) { 15762 if (_[method]) Class.prototype[method] = addMethod(length, method, attribute); 15763 }); 15764 }; 15765 15766 // Support `collection.sortBy('attr')` and `collection.findWhere({id: 1})`. 15767 var cb = function(iteratee, instance) { 15768 if (_.isFunction(iteratee)) return iteratee; 15769 if (_.isObject(iteratee) && !instance._isModel(iteratee)) return modelMatcher(iteratee); 15770 if (_.isString(iteratee)) return function(model) { return model.get(iteratee); }; 15771 return iteratee; 15772 }; 15773 var modelMatcher = function(attrs) { 15774 var matcher = _.matches(attrs); 15775 return function(model) { 15776 return matcher(model.attributes); 15777 }; 15778 }; 15779 15780 // Backbone.Events 15781 // --------------- 15782 15783 // A module that can be mixed in to *any object* in order to provide it with 15784 // a custom event channel. You may bind a callback to an event with `on` or 15785 // remove with `off`; `trigger`-ing an event fires all callbacks in 15786 // succession. 15787 // 15788 // var object = {}; 15789 // _.extend(object, Backbone.Events); 15790 // object.on('expand', function(){ alert('expanded'); }); 15791 // object.trigger('expand'); 15792 // 15793 var Events = Backbone.Events = {}; 15794 15795 // Regular expression used to split event strings. 15796 var eventSplitter = /\s+/; 15797 15798 // Iterates over the standard `event, callback` (as well as the fancy multiple 15799 // space-separated events `"change blur", callback` and jQuery-style event 15800 // maps `{event: callback}`). 15801 var eventsApi = function(iteratee, events, name, callback, opts) { 15802 var i = 0, names; 15803 if (name && typeof name === 'object') { 15804 // Handle event maps. 15805 if (callback !== void 0 && 'context' in opts && opts.context === void 0) opts.context = callback; 15806 for (names = _.keys(name); i < names.length ; i++) { 15807 events = eventsApi(iteratee, events, names[i], name[names[i]], opts); 15808 } 15809 } else if (name && eventSplitter.test(name)) { 15810 // Handle space-separated event names by delegating them individually. 15811 for (names = name.split(eventSplitter); i < names.length; i++) { 15812 events = iteratee(events, names[i], callback, opts); 15813 } 15814 } else { 15815 // Finally, standard events. 15816 events = iteratee(events, name, callback, opts); 15817 } 15818 return events; 15819 }; 15820 15821 // Bind an event to a `callback` function. Passing `"all"` will bind 15822 // the callback to all events fired. 15823 Events.on = function(name, callback, context) { 15824 return internalOn(this, name, callback, context); 15825 }; 15826 15827 // Guard the `listening` argument from the public API. 15828 var internalOn = function(obj, name, callback, context, listening) { 15829 obj._events = eventsApi(onApi, obj._events || {}, name, callback, { 15830 context: context, 15831 ctx: obj, 15832 listening: listening 15833 }); 15834 15835 if (listening) { 15836 var listeners = obj._listeners || (obj._listeners = {}); 15837 listeners[listening.id] = listening; 15838 } 15839 15840 return obj; 15841 }; 15842 15843 // Inversion-of-control versions of `on`. Tell *this* object to listen to 15844 // an event in another object... keeping track of what it's listening to 15845 // for easier unbinding later. 15846 Events.listenTo = function(obj, name, callback) { 15847 if (!obj) return this; 15848 var id = obj._listenId || (obj._listenId = _.uniqueId('l')); 15849 var listeningTo = this._listeningTo || (this._listeningTo = {}); 15850 var listening = listeningTo[id]; 15851 15852 // This object is not listening to any other events on `obj` yet. 15853 // Setup the necessary references to track the listening callbacks. 15854 if (!listening) { 15855 var thisId = this._listenId || (this._listenId = _.uniqueId('l')); 15856 listening = listeningTo[id] = {obj: obj, objId: id, id: thisId, listeningTo: listeningTo, count: 0}; 15857 } 15858 15859 // Bind callbacks on obj, and keep track of them on listening. 15860 internalOn(obj, name, callback, this, listening); 15861 return this; 15862 }; 15863 15864 // The reducing API that adds a callback to the `events` object. 15865 var onApi = function(events, name, callback, options) { 15866 if (callback) { 15867 var handlers = events[name] || (events[name] = []); 15868 var context = options.context, ctx = options.ctx, listening = options.listening; 15869 if (listening) listening.count++; 15870 15871 handlers.push({callback: callback, context: context, ctx: context || ctx, listening: listening}); 15872 } 15873 return events; 15874 }; 15875 15876 // Remove one or many callbacks. If `context` is null, removes all 15877 // callbacks with that function. If `callback` is null, removes all 15878 // callbacks for the event. If `name` is null, removes all bound 15879 // callbacks for all events. 15880 Events.off = function(name, callback, context) { 15881 if (!this._events) return this; 15882 this._events = eventsApi(offApi, this._events, name, callback, { 15883 context: context, 15884 listeners: this._listeners 15885 }); 15886 return this; 15887 }; 15888 15889 // Tell this object to stop listening to either specific events ... or 15890 // to every object it's currently listening to. 15891 Events.stopListening = function(obj, name, callback) { 15892 var listeningTo = this._listeningTo; 15893 if (!listeningTo) return this; 15894 15895 var ids = obj ? [obj._listenId] : _.keys(listeningTo); 15896 15897 for (var i = 0; i < ids.length; i++) { 15898 var listening = listeningTo[ids[i]]; 15899 15900 // If listening doesn't exist, this object is not currently 15901 // listening to obj. Break out early. 15902 if (!listening) break; 15903 15904 listening.obj.off(name, callback, this); 15905 } 15906 15907 return this; 15908 }; 15909 15910 // The reducing API that removes a callback from the `events` object. 15911 var offApi = function(events, name, callback, options) { 15912 if (!events) return; 15913 15914 var i = 0, listening; 15915 var context = options.context, listeners = options.listeners; 15916 15917 // Delete all events listeners and "drop" events. 15918 if (!name && !callback && !context) { 15919 var ids = _.keys(listeners); 15920 for (; i < ids.length; i++) { 15921 listening = listeners[ids[i]]; 15922 delete listeners[listening.id]; 15923 delete listening.listeningTo[listening.objId]; 15924 } 15925 return; 15926 } 15927 15928 var names = name ? [name] : _.keys(events); 15929 for (; i < names.length; i++) { 15930 name = names[i]; 15931 var handlers = events[name]; 15932 15933 // Bail out if there are no events stored. 15934 if (!handlers) break; 15935 15936 // Replace events if there are any remaining. Otherwise, clean up. 15937 var remaining = []; 15938 for (var j = 0; j < handlers.length; j++) { 15939 var handler = handlers[j]; 15940 if ( 15941 callback && callback !== handler.callback && 15942 callback !== handler.callback._callback || 15943 context && context !== handler.context 15944 ) { 15945 remaining.push(handler); 15946 } else { 15947 listening = handler.listening; 15948 if (listening && --listening.count === 0) { 15949 delete listeners[listening.id]; 15950 delete listening.listeningTo[listening.objId]; 15951 } 15952 } 15953 } 15954 15955 // Update tail event if the list has any events. Otherwise, clean up. 15956 if (remaining.length) { 15957 events[name] = remaining; 15958 } else { 15959 delete events[name]; 15960 } 15961 } 15962 return events; 15963 }; 15964 15965 // Bind an event to only be triggered a single time. After the first time 15966 // the callback is invoked, its listener will be removed. If multiple events 15967 // are passed in using the space-separated syntax, the handler will fire 15968 // once for each event, not once for a combination of all events. 15969 Events.once = function(name, callback, context) { 15970 // Map the event into a `{event: once}` object. 15971 var events = eventsApi(onceMap, {}, name, callback, _.bind(this.off, this)); 15972 if (typeof name === 'string' && context == null) callback = void 0; 15973 return this.on(events, callback, context); 15974 }; 15975 15976 // Inversion-of-control versions of `once`. 15977 Events.listenToOnce = function(obj, name, callback) { 15978 // Map the event into a `{event: once}` object. 15979 var events = eventsApi(onceMap, {}, name, callback, _.bind(this.stopListening, this, obj)); 15980 return this.listenTo(obj, events); 15981 }; 15982 15983 // Reduces the event callbacks into a map of `{event: onceWrapper}`. 15984 // `offer` unbinds the `onceWrapper` after it has been called. 15985 var onceMap = function(map, name, callback, offer) { 15986 if (callback) { 15987 var once = map[name] = _.once(function() { 15988 offer(name, once); 15989 callback.apply(this, arguments); 15990 }); 15991 once._callback = callback; 15992 } 15993 return map; 15994 }; 15995 15996 // Trigger one or many events, firing all bound callbacks. Callbacks are 15997 // passed the same arguments as `trigger` is, apart from the event name 15998 // (unless you're listening on `"all"`, which will cause your callback to 15999 // receive the true name of the event as the first argument). 16000 Events.trigger = function(name) { 16001 if (!this._events) return this; 16002 16003 var length = Math.max(0, arguments.length - 1); 16004 var args = Array(length); 16005 for (var i = 0; i < length; i++) args[i] = arguments[i + 1]; 16006 16007 eventsApi(triggerApi, this._events, name, void 0, args); 16008 return this; 16009 }; 16010 16011 // Handles triggering the appropriate event callbacks. 16012 var triggerApi = function(objEvents, name, callback, args) { 16013 if (objEvents) { 16014 var events = objEvents[name]; 16015 var allEvents = objEvents.all; 16016 if (events && allEvents) allEvents = allEvents.slice(); 16017 if (events) triggerEvents(events, args); 16018 if (allEvents) triggerEvents(allEvents, [name].concat(args)); 16019 } 16020 return objEvents; 16021 }; 16022 16023 // A difficult-to-believe, but optimized internal dispatch function for 16024 // triggering events. Tries to keep the usual cases speedy (most internal 16025 // Backbone events have 3 arguments). 16026 var triggerEvents = function(events, args) { 16027 var ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2]; 16028 switch (args.length) { 16029 case 0: while (++i < l) (ev = events[i]).callback.call(ev.ctx); return; 16030 case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1); return; 16031 case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2); return; 16032 case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3); return; 16033 default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args); return; 16034 } 16035 }; 16036 16037 // Aliases for backwards compatibility. 16038 Events.bind = Events.on; 16039 Events.unbind = Events.off; 16040 16041 // Allow the `Backbone` object to serve as a global event bus, for folks who 16042 // want global "pubsub" in a convenient place. 16043 _.extend(Backbone, Events); 16044 16045 // Backbone.Model 16046 // -------------- 16047 16048 // Backbone **Models** are the basic data object in the framework -- 16049 // frequently representing a row in a table in a database on your server. 16050 // A discrete chunk of data and a bunch of useful, related methods for 16051 // performing computations and transformations on that data. 16052 16053 // Create a new model with the specified attributes. A client id (`cid`) 16054 // is automatically generated and assigned for you. 16055 var Model = Backbone.Model = function(attributes, options) { 16056 var attrs = attributes || {}; 16057 options || (options = {}); 16058 this.cid = _.uniqueId(this.cidPrefix); 16059 this.attributes = {}; 16060 if (options.collection) this.collection = options.collection; 16061 if (options.parse) attrs = this.parse(attrs, options) || {}; 16062 var defaults = _.result(this, 'defaults'); 16063 attrs = _.defaults(_.extend({}, defaults, attrs), defaults); 16064 this.set(attrs, options); 16065 this.changed = {}; 16066 this.initialize.apply(this, arguments); 16067 }; 16068 16069 // Attach all inheritable methods to the Model prototype. 16070 _.extend(Model.prototype, Events, { 16071 16072 // A hash of attributes whose current and previous value differ. 16073 changed: null, 16074 16075 // The value returned during the last failed validation. 16076 validationError: null, 16077 16078 // The default name for the JSON `id` attribute is `"id"`. MongoDB and 16079 // CouchDB users may want to set this to `"_id"`. 16080 idAttribute: 'id', 16081 16082 // The prefix is used to create the client id which is used to identify models locally. 16083 // You may want to override this if you're experiencing name clashes with model ids. 16084 cidPrefix: 'c', 16085 16086 // Initialize is an empty function by default. Override it with your own 16087 // initialization logic. 16088 initialize: function(){}, 16089 16090 // Return a copy of the model's `attributes` object. 16091 toJSON: function(options) { 16092 return _.clone(this.attributes); 16093 }, 16094 16095 // Proxy `Backbone.sync` by default -- but override this if you need 16096 // custom syncing semantics for *this* particular model. 16097 sync: function() { 16098 return Backbone.sync.apply(this, arguments); 16099 }, 16100 16101 // Get the value of an attribute. 16102 get: function(attr) { 16103 return this.attributes[attr]; 16104 }, 16105 16106 // Get the HTML-escaped value of an attribute. 16107 escape: function(attr) { 16108 return _.escape(this.get(attr)); 16109 }, 16110 16111 // Returns `true` if the attribute contains a value that is not null 16112 // or undefined. 16113 has: function(attr) { 16114 return this.get(attr) != null; 16115 }, 16116 16117 // Special-cased proxy to underscore's `_.matches` method. 16118 matches: function(attrs) { 16119 return !!_.iteratee(attrs, this)(this.attributes); 16120 }, 16121 16122 // Set a hash of model attributes on the object, firing `"change"`. This is 16123 // the core primitive operation of a model, updating the data and notifying 16124 // anyone who needs to know about the change in state. The heart of the beast. 16125 set: function(key, val, options) { 16126 if (key == null) return this; 16127 16128 // Handle both `"key", value` and `{key: value}` -style arguments. 16129 var attrs; 16130 if (typeof key === 'object') { 16131 attrs = key; 16132 options = val; 16133 } else { 16134 (attrs = {})[key] = val; 16135 } 16136 16137 options || (options = {}); 16138 16139 // Run validation. 16140 if (!this._validate(attrs, options)) return false; 16141 16142 // Extract attributes and options. 16143 var unset = options.unset; 16144 var silent = options.silent; 16145 var changes = []; 16146 var changing = this._changing; 16147 this._changing = true; 16148 16149 if (!changing) { 16150 this._previousAttributes = _.clone(this.attributes); 16151 this.changed = {}; 16152 } 16153 16154 var current = this.attributes; 16155 var changed = this.changed; 16156 var prev = this._previousAttributes; 16157 16158 // For each `set` attribute, update or delete the current value. 16159 for (var attr in attrs) { 16160 val = attrs[attr]; 16161 if (!_.isEqual(current[attr], val)) changes.push(attr); 16162 if (!_.isEqual(prev[attr], val)) { 16163 changed[attr] = val; 16164 } else { 16165 delete changed[attr]; 16166 } 16167 unset ? delete current[attr] : current[attr] = val; 16168 } 16169 16170 // Update the `id`. 16171 if (this.idAttribute in attrs) this.id = this.get(this.idAttribute); 16172 16173 // Trigger all relevant attribute changes. 16174 if (!silent) { 16175 if (changes.length) this._pending = options; 16176 for (var i = 0; i < changes.length; i++) { 16177 this.trigger('change:' + changes[i], this, current[changes[i]], options); 16178 } 16179 } 16180 16181 // You might be wondering why there's a `while` loop here. Changes can 16182 // be recursively nested within `"change"` events. 16183 if (changing) return this; 16184 if (!silent) { 16185 while (this._pending) { 16186 options = this._pending; 16187 this._pending = false; 16188 this.trigger('change', this, options); 16189 } 16190 } 16191 this._pending = false; 16192 this._changing = false; 16193 return this; 16194 }, 16195 16196 // Remove an attribute from the model, firing `"change"`. `unset` is a noop 16197 // if the attribute doesn't exist. 16198 unset: function(attr, options) { 16199 return this.set(attr, void 0, _.extend({}, options, {unset: true})); 16200 }, 16201 16202 // Clear all attributes on the model, firing `"change"`. 16203 clear: function(options) { 16204 var attrs = {}; 16205 for (var key in this.attributes) attrs[key] = void 0; 16206 return this.set(attrs, _.extend({}, options, {unset: true})); 16207 }, 16208 16209 // Determine if the model has changed since the last `"change"` event. 16210 // If you specify an attribute name, determine if that attribute has changed. 16211 hasChanged: function(attr) { 16212 if (attr == null) return !_.isEmpty(this.changed); 16213 return _.has(this.changed, attr); 16214 }, 16215 16216 // Return an object containing all the attributes that have changed, or 16217 // false if there are no changed attributes. Useful for determining what 16218 // parts of a view need to be updated and/or what attributes need to be 16219 // persisted to the server. Unset attributes will be set to undefined. 16220 // You can also pass an attributes object to diff against the model, 16221 // determining if there *would be* a change. 16222 changedAttributes: function(diff) { 16223 if (!diff) return this.hasChanged() ? _.clone(this.changed) : false; 16224 var old = this._changing ? this._previousAttributes : this.attributes; 16225 var changed = {}; 16226 for (var attr in diff) { 16227 var val = diff[attr]; 16228 if (_.isEqual(old[attr], val)) continue; 16229 changed[attr] = val; 16230 } 16231 return _.size(changed) ? changed : false; 16232 }, 16233 16234 // Get the previous value of an attribute, recorded at the time the last 16235 // `"change"` event was fired. 16236 previous: function(attr) { 16237 if (attr == null || !this._previousAttributes) return null; 16238 return this._previousAttributes[attr]; 16239 }, 16240 16241 // Get all of the attributes of the model at the time of the previous 16242 // `"change"` event. 16243 previousAttributes: function() { 16244 return _.clone(this._previousAttributes); 16245 }, 16246 16247 // Fetch the model from the server, merging the response with the model's 16248 // local attributes. Any changed attributes will trigger a "change" event. 16249 fetch: function(options) { 16250 options = _.extend({parse: true}, options); 16251 var model = this; 16252 var success = options.success; 16253 options.success = function(resp) { 16254 var serverAttrs = options.parse ? model.parse(resp, options) : resp; 16255 if (!model.set(serverAttrs, options)) return false; 16256 if (success) success.call(options.context, model, resp, options); 16257 model.trigger('sync', model, resp, options); 16258 }; 16259 wrapError(this, options); 16260 return this.sync('read', this, options); 16261 }, 16262 16263 // Set a hash of model attributes, and sync the model to the server. 16264 // If the server returns an attributes hash that differs, the model's 16265 // state will be `set` again. 16266 save: function(key, val, options) { 16267 // Handle both `"key", value` and `{key: value}` -style arguments. 16268 var attrs; 16269 if (key == null || typeof key === 'object') { 16270 attrs = key; 16271 options = val; 16272 } else { 16273 (attrs = {})[key] = val; 16274 } 16275 16276 options = _.extend({validate: true, parse: true}, options); 16277 var wait = options.wait; 16278 16279 // If we're not waiting and attributes exist, save acts as 16280 // `set(attr).save(null, opts)` with validation. Otherwise, check if 16281 // the model will be valid when the attributes, if any, are set. 16282 if (attrs && !wait) { 16283 if (!this.set(attrs, options)) return false; 16284 } else if (!this._validate(attrs, options)) { 16285 return false; 16286 } 16287 16288 // After a successful server-side save, the client is (optionally) 16289 // updated with the server-side state. 16290 var model = this; 16291 var success = options.success; 16292 var attributes = this.attributes; 16293 options.success = function(resp) { 16294 // Ensure attributes are restored during synchronous saves. 16295 model.attributes = attributes; 16296 var serverAttrs = options.parse ? model.parse(resp, options) : resp; 16297 if (wait) serverAttrs = _.extend({}, attrs, serverAttrs); 16298 if (serverAttrs && !model.set(serverAttrs, options)) return false; 16299 if (success) success.call(options.context, model, resp, options); 16300 model.trigger('sync', model, resp, options); 16301 }; 16302 wrapError(this, options); 16303 16304 // Set temporary attributes if `{wait: true}` to properly find new ids. 16305 if (attrs && wait) this.attributes = _.extend({}, attributes, attrs); 16306 16307 var method = this.isNew() ? 'create' : (options.patch ? 'patch' : 'update'); 16308 if (method === 'patch' && !options.attrs) options.attrs = attrs; 16309 var xhr = this.sync(method, this, options); 16310 16311 // Restore attributes. 16312 this.attributes = attributes; 16313 16314 return xhr; 16315 }, 16316 16317 // Destroy this model on the server if it was already persisted. 16318 // Optimistically removes the model from its collection, if it has one. 16319 // If `wait: true` is passed, waits for the server to respond before removal. 16320 destroy: function(options) { 16321 options = options ? _.clone(options) : {}; 16322 var model = this; 16323 var success = options.success; 16324 var wait = options.wait; 16325 16326 var destroy = function() { 16327 model.stopListening(); 16328 model.trigger('destroy', model, model.collection, options); 16329 }; 16330 16331 options.success = function(resp) { 16332 if (wait) destroy(); 16333 if (success) success.call(options.context, model, resp, options); 16334 if (!model.isNew()) model.trigger('sync', model, resp, options); 16335 }; 16336 16337 var xhr = false; 16338 if (this.isNew()) { 16339 _.defer(options.success); 16340 } else { 16341 wrapError(this, options); 16342 xhr = this.sync('delete', this, options); 16343 } 16344 if (!wait) destroy(); 16345 return xhr; 16346 }, 16347 16348 // Default URL for the model's representation on the server -- if you're 16349 // using Backbone's restful methods, override this to change the endpoint 16350 // that will be called. 16351 url: function() { 16352 var base = 16353 _.result(this, 'urlRoot') || 16354 _.result(this.collection, 'url') || 16355 urlError(); 16356 if (this.isNew()) return base; 16357 var id = this.get(this.idAttribute); 16358 return base.replace(/[^\/]$/, '$&/') + encodeURIComponent(id); 16359 }, 16360 16361 // **parse** converts a response into the hash of attributes to be `set` on 16362 // the model. The default implementation is just to pass the response along. 16363 parse: function(resp, options) { 16364 return resp; 16365 }, 16366 16367 // Create a new model with identical attributes to this one. 16368 clone: function() { 16369 return new this.constructor(this.attributes); 16370 }, 16371 16372 // A model is new if it has never been saved to the server, and lacks an id. 16373 isNew: function() { 16374 return !this.has(this.idAttribute); 16375 }, 16376 16377 // Check if the model is currently in a valid state. 16378 isValid: function(options) { 16379 return this._validate({}, _.extend({}, options, {validate: true})); 16380 }, 16381 16382 // Run validation against the next complete set of model attributes, 16383 // returning `true` if all is well. Otherwise, fire an `"invalid"` event. 16384 _validate: function(attrs, options) { 16385 if (!options.validate || !this.validate) return true; 16386 attrs = _.extend({}, this.attributes, attrs); 16387 var error = this.validationError = this.validate(attrs, options) || null; 16388 if (!error) return true; 16389 this.trigger('invalid', this, error, _.extend(options, {validationError: error})); 16390 return false; 16391 } 16392 16393 }); 16394 16395 // Underscore methods that we want to implement on the Model, mapped to the 16396 // number of arguments they take. 16397 var modelMethods = {keys: 1, values: 1, pairs: 1, invert: 1, pick: 0, 16398 omit: 0, chain: 1, isEmpty: 1}; 16399 16400 // Mix in each Underscore method as a proxy to `Model#attributes`. 16401 addUnderscoreMethods(Model, modelMethods, 'attributes'); 16402 16403 // Backbone.Collection 16404 // ------------------- 16405 16406 // If models tend to represent a single row of data, a Backbone Collection is 16407 // more analogous to a table full of data ... or a small slice or page of that 16408 // table, or a collection of rows that belong together for a particular reason 16409 // -- all of the messages in this particular folder, all of the documents 16410 // belonging to this particular author, and so on. Collections maintain 16411 // indexes of their models, both in order, and for lookup by `id`. 16412 16413 // Create a new **Collection**, perhaps to contain a specific type of `model`. 16414 // If a `comparator` is specified, the Collection will maintain 16415 // its models in sort order, as they're added and removed. 16416 var Collection = Backbone.Collection = function(models, options) { 16417 options || (options = {}); 16418 if (options.model) this.model = options.model; 16419 if (options.comparator !== void 0) this.comparator = options.comparator; 16420 this._reset(); 16421 this.initialize.apply(this, arguments); 16422 if (models) this.reset(models, _.extend({silent: true}, options)); 16423 }; 16424 16425 // Default options for `Collection#set`. 16426 var setOptions = {add: true, remove: true, merge: true}; 16427 var addOptions = {add: true, remove: false}; 16428 16429 // Splices `insert` into `array` at index `at`. 16430 var splice = function(array, insert, at) { 16431 at = Math.min(Math.max(at, 0), array.length); 16432 var tail = Array(array.length - at); 16433 var length = insert.length; 16434 var i; 16435 for (i = 0; i < tail.length; i++) tail[i] = array[i + at]; 16436 for (i = 0; i < length; i++) array[i + at] = insert[i]; 16437 for (i = 0; i < tail.length; i++) array[i + length + at] = tail[i]; 16438 }; 16439 16440 // Define the Collection's inheritable methods. 16441 _.extend(Collection.prototype, Events, { 16442 16443 // The default model for a collection is just a **Backbone.Model**. 16444 // This should be overridden in most cases. 16445 model: Model, 16446 16447 // Initialize is an empty function by default. Override it with your own 16448 // initialization logic. 16449 initialize: function(){}, 16450 16451 // The JSON representation of a Collection is an array of the 16452 // models' attributes. 16453 toJSON: function(options) { 16454 return this.map(function(model) { return model.toJSON(options); }); 16455 }, 16456 16457 // Proxy `Backbone.sync` by default. 16458 sync: function() { 16459 return Backbone.sync.apply(this, arguments); 16460 }, 16461 16462 // Add a model, or list of models to the set. `models` may be Backbone 16463 // Models or raw JavaScript objects to be converted to Models, or any 16464 // combination of the two. 16465 add: function(models, options) { 16466 return this.set(models, _.extend({merge: false}, options, addOptions)); 16467 }, 16468 16469 // Remove a model, or a list of models from the set. 16470 remove: function(models, options) { 16471 options = _.extend({}, options); 16472 var singular = !_.isArray(models); 16473 models = singular ? [models] : models.slice(); 16474 var removed = this._removeModels(models, options); 16475 if (!options.silent && removed.length) { 16476 options.changes = {added: [], merged: [], removed: removed}; 16477 this.trigger('update', this, options); 16478 } 16479 return singular ? removed[0] : removed; 16480 }, 16481 16482 // Update a collection by `set`-ing a new list of models, adding new ones, 16483 // removing models that are no longer present, and merging models that 16484 // already exist in the collection, as necessary. Similar to **Model#set**, 16485 // the core operation for updating the data contained by the collection. 16486 set: function(models, options) { 16487 if (models == null) return; 16488 16489 options = _.extend({}, setOptions, options); 16490 if (options.parse && !this._isModel(models)) { 16491 models = this.parse(models, options) || []; 16492 } 16493 16494 var singular = !_.isArray(models); 16495 models = singular ? [models] : models.slice(); 16496 16497 var at = options.at; 16498 if (at != null) at = +at; 16499 if (at > this.length) at = this.length; 16500 if (at < 0) at += this.length + 1; 16501 16502 var set = []; 16503 var toAdd = []; 16504 var toMerge = []; 16505 var toRemove = []; 16506 var modelMap = {}; 16507 16508 var add = options.add; 16509 var merge = options.merge; 16510 var remove = options.remove; 16511 16512 var sort = false; 16513 var sortable = this.comparator && at == null && options.sort !== false; 16514 var sortAttr = _.isString(this.comparator) ? this.comparator : null; 16515 16516 // Turn bare objects into model references, and prevent invalid models 16517 // from being added. 16518 var model, i; 16519 for (i = 0; i < models.length; i++) { 16520 model = models[i]; 16521 16522 // If a duplicate is found, prevent it from being added and 16523 // optionally merge it into the existing model. 16524 var existing = this.get(model); 16525 if (existing) { 16526 if (merge && model !== existing) { 16527 var attrs = this._isModel(model) ? model.attributes : model; 16528 if (options.parse) attrs = existing.parse(attrs, options); 16529 existing.set(attrs, options); 16530 toMerge.push(existing); 16531 if (sortable && !sort) sort = existing.hasChanged(sortAttr); 16532 } 16533 if (!modelMap[existing.cid]) { 16534 modelMap[existing.cid] = true; 16535 set.push(existing); 16536 } 16537 models[i] = existing; 16538 16539 // If this is a new, valid model, push it to the `toAdd` list. 16540 } else if (add) { 16541 model = models[i] = this._prepareModel(model, options); 16542 if (model) { 16543 toAdd.push(model); 16544 this._addReference(model, options); 16545 modelMap[model.cid] = true; 16546 set.push(model); 16547 } 16548 } 16549 } 16550 16551 // Remove stale models. 16552 if (remove) { 16553 for (i = 0; i < this.length; i++) { 16554 model = this.models[i]; 16555 if (!modelMap[model.cid]) toRemove.push(model); 16556 } 16557 if (toRemove.length) this._removeModels(toRemove, options); 16558 } 16559 16560 // See if sorting is needed, update `length` and splice in new models. 16561 var orderChanged = false; 16562 var replace = !sortable && add && remove; 16563 if (set.length && replace) { 16564 orderChanged = this.length !== set.length || _.some(this.models, function(m, index) { 16565 return m !== set[index]; 16566 }); 16567 this.models.length = 0; 16568 splice(this.models, set, 0); 16569 this.length = this.models.length; 16570 } else if (toAdd.length) { 16571 if (sortable) sort = true; 16572 splice(this.models, toAdd, at == null ? this.length : at); 16573 this.length = this.models.length; 16574 } 16575 16576 // Silently sort the collection if appropriate. 16577 if (sort) this.sort({silent: true}); 16578 16579 // Unless silenced, it's time to fire all appropriate add/sort/update events. 16580 if (!options.silent) { 16581 for (i = 0; i < toAdd.length; i++) { 16582 if (at != null) options.index = at + i; 16583 model = toAdd[i]; 16584 model.trigger('add', model, this, options); 16585 } 16586 if (sort || orderChanged) this.trigger('sort', this, options); 16587 if (toAdd.length || toRemove.length || toMerge.length) { 16588 options.changes = { 16589 added: toAdd, 16590 removed: toRemove, 16591 merged: toMerge 16592 }; 16593 this.trigger('update', this, options); 16594 } 16595 } 16596 16597 // Return the added (or merged) model (or models). 16598 return singular ? models[0] : models; 16599 }, 16600 16601 // When you have more items than you want to add or remove individually, 16602 // you can reset the entire set with a new list of models, without firing 16603 // any granular `add` or `remove` events. Fires `reset` when finished. 16604 // Useful for bulk operations and optimizations. 16605 reset: function(models, options) { 16606 options = options ? _.clone(options) : {}; 16607 for (var i = 0; i < this.models.length; i++) { 16608 this._removeReference(this.models[i], options); 16609 } 16610 options.previousModels = this.models; 16611 this._reset(); 16612 models = this.add(models, _.extend({silent: true}, options)); 16613 if (!options.silent) this.trigger('reset', this, options); 16614 return models; 16615 }, 16616 16617 // Add a model to the end of the collection. 16618 push: function(model, options) { 16619 return this.add(model, _.extend({at: this.length}, options)); 16620 }, 16621 16622 // Remove a model from the end of the collection. 16623 pop: function(options) { 16624 var model = this.at(this.length - 1); 16625 return this.remove(model, options); 16626 }, 16627 16628 // Add a model to the beginning of the collection. 16629 unshift: function(model, options) { 16630 return this.add(model, _.extend({at: 0}, options)); 16631 }, 16632 16633 // Remove a model from the beginning of the collection. 16634 shift: function(options) { 16635 var model = this.at(0); 16636 return this.remove(model, options); 16637 }, 16638 16639 // Slice out a sub-array of models from the collection. 16640 slice: function() { 16641 return slice.apply(this.models, arguments); 16642 }, 16643 16644 // Get a model from the set by id, cid, model object with id or cid 16645 // properties, or an attributes object that is transformed through modelId. 16646 get: function(obj) { 16647 if (obj == null) return void 0; 16648 return this._byId[obj] || 16649 this._byId[this.modelId(obj.attributes || obj)] || 16650 obj.cid && this._byId[obj.cid]; 16651 }, 16652 16653 // Returns `true` if the model is in the collection. 16654 has: function(obj) { 16655 return this.get(obj) != null; 16656 }, 16657 16658 // Get the model at the given index. 16659 at: function(index) { 16660 if (index < 0) index += this.length; 16661 return this.models[index]; 16662 }, 16663 16664 // Return models with matching attributes. Useful for simple cases of 16665 // `filter`. 16666 where: function(attrs, first) { 16667 return this[first ? 'find' : 'filter'](attrs); 16668 }, 16669 16670 // Return the first model with matching attributes. Useful for simple cases 16671 // of `find`. 16672 findWhere: function(attrs) { 16673 return this.where(attrs, true); 16674 }, 16675 16676 // Force the collection to re-sort itself. You don't need to call this under 16677 // normal circumstances, as the set will maintain sort order as each item 16678 // is added. 16679 sort: function(options) { 16680 var comparator = this.comparator; 16681 if (!comparator) throw new Error('Cannot sort a set without a comparator'); 16682 options || (options = {}); 16683 16684 var length = comparator.length; 16685 if (_.isFunction(comparator)) comparator = _.bind(comparator, this); 16686 16687 // Run sort based on type of `comparator`. 16688 if (length === 1 || _.isString(comparator)) { 16689 this.models = this.sortBy(comparator); 16690 } else { 16691 this.models.sort(comparator); 16692 } 16693 if (!options.silent) this.trigger('sort', this, options); 16694 return this; 16695 }, 16696 16697 // Pluck an attribute from each model in the collection. 16698 pluck: function(attr) { 16699 return this.map(attr + ''); 16700 }, 16701 16702 // Fetch the default set of models for this collection, resetting the 16703 // collection when they arrive. If `reset: true` is passed, the response 16704 // data will be passed through the `reset` method instead of `set`. 16705 fetch: function(options) { 16706 options = _.extend({parse: true}, options); 16707 var success = options.success; 16708 var collection = this; 16709 options.success = function(resp) { 16710 var method = options.reset ? 'reset' : 'set'; 16711 collection[method](resp, options); 16712 if (success) success.call(options.context, collection, resp, options); 16713 collection.trigger('sync', collection, resp, options); 16714 }; 16715 wrapError(this, options); 16716 return this.sync('read', this, options); 16717 }, 16718 16719 // Create a new instance of a model in this collection. Add the model to the 16720 // collection immediately, unless `wait: true` is passed, in which case we 16721 // wait for the server to agree. 16722 create: function(model, options) { 16723 options = options ? _.clone(options) : {}; 16724 var wait = options.wait; 16725 model = this._prepareModel(model, options); 16726 if (!model) return false; 16727 if (!wait) this.add(model, options); 16728 var collection = this; 16729 var success = options.success; 16730 options.success = function(m, resp, callbackOpts) { 16731 if (wait) collection.add(m, callbackOpts); 16732 if (success) success.call(callbackOpts.context, m, resp, callbackOpts); 16733 }; 16734 model.save(null, options); 16735 return model; 16736 }, 16737 16738 // **parse** converts a response into a list of models to be added to the 16739 // collection. The default implementation is just to pass it through. 16740 parse: function(resp, options) { 16741 return resp; 16742 }, 16743 16744 // Create a new collection with an identical list of models as this one. 16745 clone: function() { 16746 return new this.constructor(this.models, { 16747 model: this.model, 16748 comparator: this.comparator 16749 }); 16750 }, 16751 16752 // Define how to uniquely identify models in the collection. 16753 modelId: function(attrs) { 16754 return attrs[this.model.prototype.idAttribute || 'id']; 16755 }, 16756 16757 // Private method to reset all internal state. Called when the collection 16758 // is first initialized or reset. 16759 _reset: function() { 16760 this.length = 0; 16761 this.models = []; 16762 this._byId = {}; 16763 }, 16764 16765 // Prepare a hash of attributes (or other model) to be added to this 16766 // collection. 16767 _prepareModel: function(attrs, options) { 16768 if (this._isModel(attrs)) { 16769 if (!attrs.collection) attrs.collection = this; 16770 return attrs; 16771 } 16772 options = options ? _.clone(options) : {}; 16773 options.collection = this; 16774 var model = new this.model(attrs, options); 16775 if (!model.validationError) return model; 16776 this.trigger('invalid', this, model.validationError, options); 16777 return false; 16778 }, 16779 16780 // Internal method called by both remove and set. 16781 _removeModels: function(models, options) { 16782 var removed = []; 16783 for (var i = 0; i < models.length; i++) { 16784 var model = this.get(models[i]); 16785 if (!model) continue; 16786 16787 var index = this.indexOf(model); 16788 this.models.splice(index, 1); 16789 this.length--; 16790 16791 // Remove references before triggering 'remove' event to prevent an 16792 // infinite loop. #3693 16793 delete this._byId[model.cid]; 16794 var id = this.modelId(model.attributes); 16795 if (id != null) delete this._byId[id]; 16796 16797 if (!options.silent) { 16798 options.index = index; 16799 model.trigger('remove', model, this, options); 16800 } 16801 16802 removed.push(model); 16803 this._removeReference(model, options); 16804 } 16805 return removed; 16806 }, 16807 16808 // Method for checking whether an object should be considered a model for 16809 // the purposes of adding to the collection. 16810 _isModel: function(model) { 16811 return model instanceof Model; 16812 }, 16813 16814 // Internal method to create a model's ties to a collection. 16815 _addReference: function(model, options) { 16816 this._byId[model.cid] = model; 16817 var id = this.modelId(model.attributes); 16818 if (id != null) this._byId[id] = model; 16819 model.on('all', this._onModelEvent, this); 16820 }, 16821 16822 // Internal method to sever a model's ties to a collection. 16823 _removeReference: function(model, options) { 16824 delete this._byId[model.cid]; 16825 var id = this.modelId(model.attributes); 16826 if (id != null) delete this._byId[id]; 16827 if (this === model.collection) delete model.collection; 16828 model.off('all', this._onModelEvent, this); 16829 }, 16830 16831 // Internal method called every time a model in the set fires an event. 16832 // Sets need to update their indexes when models change ids. All other 16833 // events simply proxy through. "add" and "remove" events that originate 16834 // in other collections are ignored. 16835 _onModelEvent: function(event, model, collection, options) { 16836 if (model) { 16837 if ((event === 'add' || event === 'remove') && collection !== this) return; 16838 if (event === 'destroy') this.remove(model, options); 16839 if (event === 'change') { 16840 var prevId = this.modelId(model.previousAttributes()); 16841 var id = this.modelId(model.attributes); 16842 if (prevId !== id) { 16843 if (prevId != null) delete this._byId[prevId]; 16844 if (id != null) this._byId[id] = model; 16845 } 16846 } 16847 } 16848 this.trigger.apply(this, arguments); 16849 } 16850 16851 }); 16852 16853 // Underscore methods that we want to implement on the Collection. 16854 // 90% of the core usefulness of Backbone Collections is actually implemented 16855 // right here: 16856 var collectionMethods = {forEach: 3, each: 3, map: 3, collect: 3, reduce: 0, 16857 foldl: 0, inject: 0, reduceRight: 0, foldr: 0, find: 3, detect: 3, filter: 3, 16858 select: 3, reject: 3, every: 3, all: 3, some: 3, any: 3, include: 3, includes: 3, 16859 contains: 3, invoke: 0, max: 3, min: 3, toArray: 1, size: 1, first: 3, 16860 head: 3, take: 3, initial: 3, rest: 3, tail: 3, drop: 3, last: 3, 16861 without: 0, difference: 0, indexOf: 3, shuffle: 1, lastIndexOf: 3, 16862 isEmpty: 1, chain: 1, sample: 3, partition: 3, groupBy: 3, countBy: 3, 16863 sortBy: 3, indexBy: 3, findIndex: 3, findLastIndex: 3}; 16864 16865 // Mix in each Underscore method as a proxy to `Collection#models`. 16866 addUnderscoreMethods(Collection, collectionMethods, 'models'); 16867 16868 // Backbone.View 16869 // ------------- 16870 16871 // Backbone Views are almost more convention than they are actual code. A View 16872 // is simply a JavaScript object that represents a logical chunk of UI in the 16873 // DOM. This might be a single item, an entire list, a sidebar or panel, or 16874 // even the surrounding frame which wraps your whole app. Defining a chunk of 16875 // UI as a **View** allows you to define your DOM events declaratively, without 16876 // having to worry about render order ... and makes it easy for the view to 16877 // react to specific changes in the state of your models. 16878 16879 // Creating a Backbone.View creates its initial element outside of the DOM, 16880 // if an existing element is not provided... 16881 var View = Backbone.View = function(options) { 16882 this.cid = _.uniqueId('view'); 16883 _.extend(this, _.pick(options, viewOptions)); 16884 this._ensureElement(); 16885 this.initialize.apply(this, arguments); 16886 }; 16887 16888 // Cached regex to split keys for `delegate`. 16889 var delegateEventSplitter = /^(\S+)\s*(.*)$/; 16890 16891 // List of view options to be set as properties. 16892 var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events']; 16893 16894 // Set up all inheritable **Backbone.View** properties and methods. 16895 _.extend(View.prototype, Events, { 16896 16897 // The default `tagName` of a View's element is `"div"`. 16898 tagName: 'div', 16899 16900 // jQuery delegate for element lookup, scoped to DOM elements within the 16901 // current view. This should be preferred to global lookups where possible. 16902 $: function(selector) { 16903 return this.$el.find(selector); 16904 }, 16905 16906 // Initialize is an empty function by default. Override it with your own 16907 // initialization logic. 16908 initialize: function(){}, 16909 16910 // **render** is the core function that your view should override, in order 16911 // to populate its element (`this.el`), with the appropriate HTML. The 16912 // convention is for **render** to always return `this`. 16913 render: function() { 16914 return this; 16915 }, 16916 16917 // Remove this view by taking the element out of the DOM, and removing any 16918 // applicable Backbone.Events listeners. 16919 remove: function() { 16920 this._removeElement(); 16921 this.stopListening(); 16922 return this; 16923 }, 16924 16925 // Remove this view's element from the document and all event listeners 16926 // attached to it. Exposed for subclasses using an alternative DOM 16927 // manipulation API. 16928 _removeElement: function() { 16929 this.$el.remove(); 16930 }, 16931 16932 // Change the view's element (`this.el` property) and re-delegate the 16933 // view's events on the new element. 16934 setElement: function(element) { 16935 this.undelegateEvents(); 16936 this._setElement(element); 16937 this.delegateEvents(); 16938 return this; 16939 }, 16940 16941 // Creates the `this.el` and `this.$el` references for this view using the 16942 // given `el`. `el` can be a CSS selector or an HTML string, a jQuery 16943 // context or an element. Subclasses can override this to utilize an 16944 // alternative DOM manipulation API and are only required to set the 16945 // `this.el` property. 16946 _setElement: function(el) { 16947 this.$el = el instanceof Backbone.$ ? el : Backbone.$(el); 16948 this.el = this.$el[0]; 16949 }, 16950 16951 // Set callbacks, where `this.events` is a hash of 16952 // 16953 // *{"event selector": "callback"}* 16954 // 16955 // { 16956 // 'mousedown .title': 'edit', 16957 // 'click .button': 'save', 16958 // 'click .open': function(e) { ... } 16959 // } 16960 // 16961 // pairs. Callbacks will be bound to the view, with `this` set properly. 16962 // Uses event delegation for efficiency. 16963 // Omitting the selector binds the event to `this.el`. 16964 delegateEvents: function(events) { 16965 events || (events = _.result(this, 'events')); 16966 if (!events) return this; 16967 this.undelegateEvents(); 16968 for (var key in events) { 16969 var method = events[key]; 16970 if (!_.isFunction(method)) method = this[method]; 16971 if (!method) continue; 16972 var match = key.match(delegateEventSplitter); 16973 this.delegate(match[1], match[2], _.bind(method, this)); 16974 } 16975 return this; 16976 }, 16977 16978 // Add a single event listener to the view's element (or a child element 16979 // using `selector`). This only works for delegate-able events: not `focus`, 16980 // `blur`, and not `change`, `submit`, and `reset` in Internet Explorer. 16981 delegate: function(eventName, selector, listener) { 16982 this.$el.on(eventName + '.delegateEvents' + this.cid, selector, listener); 16983 return this; 16984 }, 16985 16986 // Clears all callbacks previously bound to the view by `delegateEvents`. 16987 // You usually don't need to use this, but may wish to if you have multiple 16988 // Backbone views attached to the same DOM element. 16989 undelegateEvents: function() { 16990 if (this.$el) this.$el.off('.delegateEvents' + this.cid); 16991 return this; 16992 }, 16993 16994 // A finer-grained `undelegateEvents` for removing a single delegated event. 16995 // `selector` and `listener` are both optional. 16996 undelegate: function(eventName, selector, listener) { 16997 this.$el.off(eventName + '.delegateEvents' + this.cid, selector, listener); 16998 return this; 16999 }, 17000 17001 // Produces a DOM element to be assigned to your view. Exposed for 17002 // subclasses using an alternative DOM manipulation API. 17003 _createElement: function(tagName) { 17004 return document.createElement(tagName); 17005 }, 17006 17007 // Ensure that the View has a DOM element to render into. 17008 // If `this.el` is a string, pass it through `$()`, take the first 17009 // matching element, and re-assign it to `el`. Otherwise, create 17010 // an element from the `id`, `className` and `tagName` properties. 17011 _ensureElement: function() { 17012 if (!this.el) { 17013 var attrs = _.extend({}, _.result(this, 'attributes')); 17014 if (this.id) attrs.id = _.result(this, 'id'); 17015 if (this.className) attrs['class'] = _.result(this, 'className'); 17016 this.setElement(this._createElement(_.result(this, 'tagName'))); 17017 this._setAttributes(attrs); 17018 } else { 17019 this.setElement(_.result(this, 'el')); 17020 } 17021 }, 17022 17023 // Set attributes from a hash on this view's element. Exposed for 17024 // subclasses using an alternative DOM manipulation API. 17025 _setAttributes: function(attributes) { 17026 this.$el.attr(attributes); 17027 } 17028 17029 }); 17030 17031 // Backbone.sync 17032 // ------------- 17033 17034 // Override this function to change the manner in which Backbone persists 17035 // models to the server. You will be passed the type of request, and the 17036 // model in question. By default, makes a RESTful Ajax request 17037 // to the model's `url()`. Some possible customizations could be: 17038 // 17039 // * Use `setTimeout` to batch rapid-fire updates into a single request. 17040 // * Send up the models as XML instead of JSON. 17041 // * Persist models via WebSockets instead of Ajax. 17042 // 17043 // Turn on `Backbone.emulateHTTP` in order to send `PUT` and `DELETE` requests 17044 // as `POST`, with a `_method` parameter containing the true HTTP method, 17045 // as well as all requests with the body as `application/x-www-form-urlencoded` 17046 // instead of `application/json` with the model in a param named `model`. 17047 // Useful when interfacing with server-side languages like **PHP** that make 17048 // it difficult to read the body of `PUT` requests. 17049 Backbone.sync = function(method, model, options) { 17050 var type = methodMap[method]; 17051 17052 // Default options, unless specified. 17053 _.defaults(options || (options = {}), { 17054 emulateHTTP: Backbone.emulateHTTP, 17055 emulateJSON: Backbone.emulateJSON 17056 }); 17057 17058 // Default JSON-request options. 17059 var params = {type: type, dataType: 'json'}; 17060 17061 // Ensure that we have a URL. 17062 if (!options.url) { 17063 params.url = _.result(model, 'url') || urlError(); 17064 } 17065 17066 // Ensure that we have the appropriate request data. 17067 if (options.data == null && model && (method === 'create' || method === 'update' || method === 'patch')) { 17068 params.contentType = 'application/json'; 17069 params.data = JSON.stringify(options.attrs || model.toJSON(options)); 17070 } 17071 17072 // For older servers, emulate JSON by encoding the request into an HTML-form. 17073 if (options.emulateJSON) { 17074 params.contentType = 'application/x-www-form-urlencoded'; 17075 params.data = params.data ? {model: params.data} : {}; 17076 } 17077 17078 // For older servers, emulate HTTP by mimicking the HTTP method with `_method` 17079 // And an `X-HTTP-Method-Override` header. 17080 if (options.emulateHTTP && (type === 'PUT' || type === 'DELETE' || type === 'PATCH')) { 17081 params.type = 'POST'; 17082 if (options.emulateJSON) params.data._method = type; 17083 var beforeSend = options.beforeSend; 17084 options.beforeSend = function(xhr) { 17085 xhr.setRequestHeader('X-HTTP-Method-Override', type); 17086 if (beforeSend) return beforeSend.apply(this, arguments); 17087 }; 17088 } 17089 17090 // Don't process data on a non-GET request. 17091 if (params.type !== 'GET' && !options.emulateJSON) { 17092 params.processData = false; 17093 } 17094 17095 // Pass along `textStatus` and `errorThrown` from jQuery. 17096 var error = options.error; 17097 options.error = function(xhr, textStatus, errorThrown) { 17098 options.textStatus = textStatus; 17099 options.errorThrown = errorThrown; 17100 if (error) error.call(options.context, xhr, textStatus, errorThrown); 17101 }; 17102 17103 // Make the request, allowing the user to override any Ajax options. 17104 var xhr = options.xhr = Backbone.ajax(_.extend(params, options)); 17105 model.trigger('request', model, xhr, options); 17106 return xhr; 17107 }; 17108 17109 // Map from CRUD to HTTP for our default `Backbone.sync` implementation. 17110 var methodMap = { 17111 'create': 'POST', 17112 'update': 'PUT', 17113 'patch': 'PATCH', 17114 'delete': 'DELETE', 17115 'read': 'GET' 17116 }; 17117 17118 // Set the default implementation of `Backbone.ajax` to proxy through to `$`. 17119 // Override this if you'd like to use a different library. 17120 Backbone.ajax = function() { 17121 return Backbone.$.ajax.apply(Backbone.$, arguments); 17122 }; 17123 17124 // Backbone.Router 17125 // --------------- 17126 17127 // Routers map faux-URLs to actions, and fire events when routes are 17128 // matched. Creating a new one sets its `routes` hash, if not set statically. 17129 var Router = Backbone.Router = function(options) { 17130 options || (options = {}); 17131 if (options.routes) this.routes = options.routes; 17132 this._bindRoutes(); 17133 this.initialize.apply(this, arguments); 17134 }; 17135 17136 // Cached regular expressions for matching named param parts and splatted 17137 // parts of route strings. 17138 var optionalParam = /\((.*?)\)/g; 17139 var namedParam = /(\(\?)?:\w+/g; 17140 var splatParam = /\*\w+/g; 17141 var escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g; 17142 17143 // Set up all inheritable **Backbone.Router** properties and methods. 17144 _.extend(Router.prototype, Events, { 17145 17146 // Initialize is an empty function by default. Override it with your own 17147 // initialization logic. 17148 initialize: function(){}, 17149 17150 // Manually bind a single named route to a callback. For example: 17151 // 17152 // this.route('search/:query/p:num', 'search', function(query, num) { 17153 // ... 17154 // }); 17155 // 17156 route: function(route, name, callback) { 17157 if (!_.isRegExp(route)) route = this._routeToRegExp(route); 17158 if (_.isFunction(name)) { 17159 callback = name; 17160 name = ''; 17161 } 17162 if (!callback) callback = this[name]; 17163 var router = this; 17164 Backbone.history.route(route, function(fragment) { 17165 var args = router._extractParameters(route, fragment); 17166 if (router.execute(callback, args, name) !== false) { 17167 router.trigger.apply(router, ['route:' + name].concat(args)); 17168 router.trigger('route', name, args); 17169 Backbone.history.trigger('route', router, name, args); 17170 } 17171 }); 17172 return this; 17173 }, 17174 17175 // Execute a route handler with the provided parameters. This is an 17176 // excellent place to do pre-route setup or post-route cleanup. 17177 execute: function(callback, args, name) { 17178 if (callback) callback.apply(this, args); 17179 }, 17180 17181 // Simple proxy to `Backbone.history` to save a fragment into the history. 17182 navigate: function(fragment, options) { 17183 Backbone.history.navigate(fragment, options); 17184 return this; 17185 }, 17186 17187 // Bind all defined routes to `Backbone.history`. We have to reverse the 17188 // order of the routes here to support behavior where the most general 17189 // routes can be defined at the bottom of the route map. 17190 _bindRoutes: function() { 17191 if (!this.routes) return; 17192 this.routes = _.result(this, 'routes'); 17193 var route, routes = _.keys(this.routes); 17194 while ((route = routes.pop()) != null) { 17195 this.route(route, this.routes[route]); 17196 } 17197 }, 17198 17199 // Convert a route string into a regular expression, suitable for matching 17200 // against the current location hash. 17201 _routeToRegExp: function(route) { 17202 route = route.replace(escapeRegExp, '\\$&') 17203 .replace(optionalParam, '(?:$1)?') 17204 .replace(namedParam, function(match, optional) { 17205 return optional ? match : '([^/?]+)'; 17206 }) 17207 .replace(splatParam, '([^?]*?)'); 17208 return new RegExp('^' + route + '(?:\\?([\\s\\S]*))?$'); 17209 }, 17210 17211 // Given a route, and a URL fragment that it matches, return the array of 17212 // extracted decoded parameters. Empty or unmatched parameters will be 17213 // treated as `null` to normalize cross-browser behavior. 17214 _extractParameters: function(route, fragment) { 17215 var params = route.exec(fragment).slice(1); 17216 return _.map(params, function(param, i) { 17217 // Don't decode the search params. 17218 if (i === params.length - 1) return param || null; 17219 return param ? decodeURIComponent(param) : null; 17220 }); 17221 } 17222 17223 }); 17224 17225 // Backbone.History 17226 // ---------------- 17227 17228 // Handles cross-browser history management, based on either 17229 // [pushState](http://diveintohtml5.info/history.html) and real URLs, or 17230 // [onhashchange](https://developer.mozilla.org/en-US/docs/DOM/window.onhashchange) 17231 // and URL fragments. If the browser supports neither (old IE, natch), 17232 // falls back to polling. 17233 var History = Backbone.History = function() { 17234 this.handlers = []; 17235 this.checkUrl = _.bind(this.checkUrl, this); 17236 17237 // Ensure that `History` can be used outside of the browser. 17238 if (typeof window !== 'undefined') { 17239 this.location = window.location; 17240 this.history = window.history; 17241 } 17242 }; 17243 17244 // Cached regex for stripping a leading hash/slash and trailing space. 17245 var routeStripper = /^[#\/]|\s+$/g; 17246 17247 // Cached regex for stripping leading and trailing slashes. 17248 var rootStripper = /^\/+|\/+$/g; 17249 17250 // Cached regex for stripping urls of hash. 17251 var pathStripper = /#.*$/; 17252 17253 // Has the history handling already been started? 17254 History.started = false; 17255 17256 // Set up all inheritable **Backbone.History** properties and methods. 17257 _.extend(History.prototype, Events, { 17258 17259 // The default interval to poll for hash changes, if necessary, is 17260 // twenty times a second. 17261 interval: 50, 17262 17263 // Are we at the app root? 17264 atRoot: function() { 17265 var path = this.location.pathname.replace(/[^\/]$/, '$&/'); 17266 return path === this.root && !this.getSearch(); 17267 }, 17268 17269 // Does the pathname match the root? 17270 matchRoot: function() { 17271 var path = this.decodeFragment(this.location.pathname); 17272 var rootPath = path.slice(0, this.root.length - 1) + '/'; 17273 return rootPath === this.root; 17274 }, 17275 17276 // Unicode characters in `location.pathname` are percent encoded so they're 17277 // decoded for comparison. `%25` should not be decoded since it may be part 17278 // of an encoded parameter. 17279 decodeFragment: function(fragment) { 17280 return decodeURI(fragment.replace(/%25/g, '%2525')); 17281 }, 17282 17283 // In IE6, the hash fragment and search params are incorrect if the 17284 // fragment contains `?`. 17285 getSearch: function() { 17286 var match = this.location.href.replace(/#.*/, '').match(/\?.+/); 17287 return match ? match[0] : ''; 17288 }, 17289 17290 // Gets the true hash value. Cannot use location.hash directly due to bug 17291 // in Firefox where location.hash will always be decoded. 17292 getHash: function(window) { 17293 var match = (window || this).location.href.match(/#(.*)$/); 17294 return match ? match[1] : ''; 17295 }, 17296 17297 // Get the pathname and search params, without the root. 17298 getPath: function() { 17299 var path = this.decodeFragment( 17300 this.location.pathname + this.getSearch() 17301 ).slice(this.root.length - 1); 17302 return path.charAt(0) === '/' ? path.slice(1) : path; 17303 }, 17304 17305 // Get the cross-browser normalized URL fragment from the path or hash. 17306 getFragment: function(fragment) { 17307 if (fragment == null) { 17308 if (this._usePushState || !this._wantsHashChange) { 17309 fragment = this.getPath(); 17310 } else { 17311 fragment = this.getHash(); 17312 } 17313 } 17314 return fragment.replace(routeStripper, ''); 17315 }, 17316 17317 // Start the hash change handling, returning `true` if the current URL matches 17318 // an existing route, and `false` otherwise. 17319 start: function(options) { 17320 if (History.started) throw new Error('Backbone.history has already been started'); 17321 History.started = true; 17322 17323 // Figure out the initial configuration. Do we need an iframe? 17324 // Is pushState desired ... is it available? 17325 this.options = _.extend({root: '/'}, this.options, options); 17326 this.root = this.options.root; 17327 this._wantsHashChange = this.options.hashChange !== false; 17328 this._hasHashChange = 'onhashchange' in window && (document.documentMode === void 0 || document.documentMode > 7); 17329 this._useHashChange = this._wantsHashChange && this._hasHashChange; 17330 this._wantsPushState = !!this.options.pushState; 17331 this._hasPushState = !!(this.history && this.history.pushState); 17332 this._usePushState = this._wantsPushState && this._hasPushState; 17333 this.fragment = this.getFragment(); 17334 17335 // Normalize root to always include a leading and trailing slash. 17336 this.root = ('/' + this.root + '/').replace(rootStripper, '/'); 17337 17338 // Transition from hashChange to pushState or vice versa if both are 17339 // requested. 17340 if (this._wantsHashChange && this._wantsPushState) { 17341 17342 // If we've started off with a route from a `pushState`-enabled 17343 // browser, but we're currently in a browser that doesn't support it... 17344 if (!this._hasPushState && !this.atRoot()) { 17345 var rootPath = this.root.slice(0, -1) || '/'; 17346 this.location.replace(rootPath + '#' + this.getPath()); 17347 // Return immediately as browser will do redirect to new url 17348 return true; 17349 17350 // Or if we've started out with a hash-based route, but we're currently 17351 // in a browser where it could be `pushState`-based instead... 17352 } else if (this._hasPushState && this.atRoot()) { 17353 this.navigate(this.getHash(), {replace: true}); 17354 } 17355 17356 } 17357 17358 // Proxy an iframe to handle location events if the browser doesn't 17359 // support the `hashchange` event, HTML5 history, or the user wants 17360 // `hashChange` but not `pushState`. 17361 if (!this._hasHashChange && this._wantsHashChange && !this._usePushState) { 17362 this.iframe = document.createElement('iframe'); 17363 this.iframe.src = 'javascript:0'; 17364 this.iframe.style.display = 'none'; 17365 this.iframe.tabIndex = -1; 17366 var body = document.body; 17367 // Using `appendChild` will throw on IE < 9 if the document is not ready. 17368 var iWindow = body.insertBefore(this.iframe, body.firstChild).contentWindow; 17369 iWindow.document.open(); 17370 iWindow.document.close(); 17371 iWindow.location.hash = '#' + this.fragment; 17372 } 17373 17374 // Add a cross-platform `addEventListener` shim for older browsers. 17375 var addEventListener = window.addEventListener || function(eventName, listener) { 17376 return attachEvent('on' + eventName, listener); 17377 }; 17378 17379 // Depending on whether we're using pushState or hashes, and whether 17380 // 'onhashchange' is supported, determine how we check the URL state. 17381 if (this._usePushState) { 17382 addEventListener('popstate', this.checkUrl, false); 17383 } else if (this._useHashChange && !this.iframe) { 17384 addEventListener('hashchange', this.checkUrl, false); 17385 } else if (this._wantsHashChange) { 17386 this._checkUrlInterval = setInterval(this.checkUrl, this.interval); 17387 } 17388 17389 if (!this.options.silent) return this.loadUrl(); 17390 }, 17391 17392 // Disable Backbone.history, perhaps temporarily. Not useful in a real app, 17393 // but possibly useful for unit testing Routers. 17394 stop: function() { 17395 // Add a cross-platform `removeEventListener` shim for older browsers. 17396 var removeEventListener = window.removeEventListener || function(eventName, listener) { 17397 return detachEvent('on' + eventName, listener); 17398 }; 17399 17400 // Remove window listeners. 17401 if (this._usePushState) { 17402 removeEventListener('popstate', this.checkUrl, false); 17403 } else if (this._useHashChange && !this.iframe) { 17404 removeEventListener('hashchange', this.checkUrl, false); 17405 } 17406 17407 // Clean up the iframe if necessary. 17408 if (this.iframe) { 17409 document.body.removeChild(this.iframe); 17410 this.iframe = null; 17411 } 17412 17413 // Some environments will throw when clearing an undefined interval. 17414 if (this._checkUrlInterval) clearInterval(this._checkUrlInterval); 17415 History.started = false; 17416 }, 17417 17418 // Add a route to be tested when the fragment changes. Routes added later 17419 // may override previous routes. 17420 route: function(route, callback) { 17421 this.handlers.unshift({route: route, callback: callback}); 17422 }, 17423 17424 // Checks the current URL to see if it has changed, and if it has, 17425 // calls `loadUrl`, normalizing across the hidden iframe. 17426 checkUrl: function(e) { 17427 var current = this.getFragment(); 17428 17429 // If the user pressed the back button, the iframe's hash will have 17430 // changed and we should use that for comparison. 17431 if (current === this.fragment && this.iframe) { 17432 current = this.getHash(this.iframe.contentWindow); 17433 } 17434 17435 if (current === this.fragment) return false; 17436 if (this.iframe) this.navigate(current); 17437 this.loadUrl(); 17438 }, 17439 17440 // Attempt to load the current URL fragment. If a route succeeds with a 17441 // match, returns `true`. If no defined routes matches the fragment, 17442 // returns `false`. 17443 loadUrl: function(fragment) { 17444 // If the root doesn't match, no routes can match either. 17445 if (!this.matchRoot()) return false; 17446 fragment = this.fragment = this.getFragment(fragment); 17447 return _.some(this.handlers, function(handler) { 17448 if (handler.route.test(fragment)) { 17449 handler.callback(fragment); 17450 return true; 17451 } 17452 }); 17453 }, 17454 17455 // Save a fragment into the hash history, or replace the URL state if the 17456 // 'replace' option is passed. You are responsible for properly URL-encoding 17457 // the fragment in advance. 17458 // 17459 // The options object can contain `trigger: true` if you wish to have the 17460 // route callback be fired (not usually desirable), or `replace: true`, if 17461 // you wish to modify the current URL without adding an entry to the history. 17462 navigate: function(fragment, options) { 17463 if (!History.started) return false; 17464 if (!options || options === true) options = {trigger: !!options}; 17465 17466 // Normalize the fragment. 17467 fragment = this.getFragment(fragment || ''); 17468 17469 // Don't include a trailing slash on the root. 17470 var rootPath = this.root; 17471 if (fragment === '' || fragment.charAt(0) === '?') { 17472 rootPath = rootPath.slice(0, -1) || '/'; 17473 } 17474 var url = rootPath + fragment; 17475 17476 // Strip the hash and decode for matching. 17477 fragment = this.decodeFragment(fragment.replace(pathStripper, '')); 17478 17479 if (this.fragment === fragment) return; 17480 this.fragment = fragment; 17481 17482 // If pushState is available, we use it to set the fragment as a real URL. 17483 if (this._usePushState) { 17484 this.history[options.replace ? 'replaceState' : 'pushState']({}, document.title, url); 17485 17486 // If hash changes haven't been explicitly disabled, update the hash 17487 // fragment to store history. 17488 } else if (this._wantsHashChange) { 17489 this._updateHash(this.location, fragment, options.replace); 17490 if (this.iframe && fragment !== this.getHash(this.iframe.contentWindow)) { 17491 var iWindow = this.iframe.contentWindow; 17492 17493 // Opening and closing the iframe tricks IE7 and earlier to push a 17494 // history entry on hash-tag change. When replace is true, we don't 17495 // want this. 17496 if (!options.replace) { 17497 iWindow.document.open(); 17498 iWindow.document.close(); 17499 } 17500 17501 this._updateHash(iWindow.location, fragment, options.replace); 17502 } 17503 17504 // If you've told us that you explicitly don't want fallback hashchange- 17505 // based history, then `navigate` becomes a page refresh. 17506 } else { 17507 return this.location.assign(url); 17508 } 17509 if (options.trigger) return this.loadUrl(fragment); 17510 }, 17511 17512 // Update the hash location, either replacing the current entry, or adding 17513 // a new one to the browser history. 17514 _updateHash: function(location, fragment, replace) { 17515 if (replace) { 17516 var href = location.href.replace(/(javascript:|#).*$/, ''); 17517 location.replace(href + '#' + fragment); 17518 } else { 17519 // Some browsers require that `hash` contains a leading #. 17520 location.hash = '#' + fragment; 17521 } 17522 } 17523 17524 }); 17525 17526 // Create the default Backbone.history. 17527 Backbone.history = new History; 17528 17529 // Helpers 17530 // ------- 17531 17532 // Helper function to correctly set up the prototype chain for subclasses. 17533 // Similar to `goog.inherits`, but uses a hash of prototype properties and 17534 // class properties to be extended. 17535 var extend = function(protoProps, staticProps) { 17536 var parent = this; 17537 var child; 17538 17539 // The constructor function for the new subclass is either defined by you 17540 // (the "constructor" property in your `extend` definition), or defaulted 17541 // by us to simply call the parent constructor. 17542 if (protoProps && _.has(protoProps, 'constructor')) { 17543 child = protoProps.constructor; 17544 } else { 17545 child = function(){ return parent.apply(this, arguments); }; 17546 } 17547 17548 // Add static properties to the constructor function, if supplied. 17549 _.extend(child, parent, staticProps); 17550 17551 // Set the prototype chain to inherit from `parent`, without calling 17552 // `parent`'s constructor function and add the prototype properties. 17553 child.prototype = _.create(parent.prototype, protoProps); 17554 child.prototype.constructor = child; 17555 17556 // Set a convenience property in case the parent's prototype is needed 17557 // later. 17558 child.__super__ = parent.prototype; 17559 17560 return child; 17561 }; 17562 17563 // Set up inheritance for the model, collection, router, view and history. 17564 Model.extend = Collection.extend = Router.extend = View.extend = History.extend = extend; 17565 17566 // Throw an error when a URL is needed, and none is supplied. 17567 var urlError = function() { 17568 throw new Error('A "url" property or function must be specified'); 17569 }; 17570 17571 // Wrap an optional error callback with a fallback error event. 17572 var wrapError = function(model, options) { 17573 var error = options.error; 17574 options.error = function(resp) { 17575 if (error) error.call(options.context, model, resp, options); 17576 model.trigger('error', model, resp, options); 17577 }; 17578 }; 17579 17580 return Backbone; 17581 }); 17582 17583 /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) 17584 17585 /***/ }, 17586 /* 114 */ 17587 /***/ function(module, exports, __webpack_require__) { 17588 17589 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscore.js 1.8.3 17590 // http://underscorejs.org 17591 // (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 17592 // Underscore may be freely distributed under the MIT license. 17593 17594 (function() { 17595 17596 // Baseline setup 17597 // -------------- 17598 17599 // Establish the root object, `window` in the browser, or `exports` on the server. 17600 var root = this; 17601 17602 // Save the previous value of the `_` variable. 17603 var previousUnderscore = root._; 17604 17605 // Save bytes in the minified (but not gzipped) version: 17606 var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; 17607 17608 // Create quick reference variables for speed access to core prototypes. 17609 var 17610 push = ArrayProto.push, 17611 slice = ArrayProto.slice, 17612 toString = ObjProto.toString, 17613 hasOwnProperty = ObjProto.hasOwnProperty; 17614 17615 // All **ECMAScript 5** native function implementations that we hope to use 17616 // are declared here. 17617 var 17618 nativeIsArray = Array.isArray, 17619 nativeKeys = Object.keys, 17620 nativeBind = FuncProto.bind, 17621 nativeCreate = Object.create; 17622 17623 // Naked function reference for surrogate-prototype-swapping. 17624 var Ctor = function(){}; 17625 17626 // Create a safe reference to the Underscore object for use below. 17627 var _ = function(obj) { 17628 if (obj instanceof _) return obj; 17629 if (!(this instanceof _)) return new _(obj); 17630 this._wrapped = obj; 17631 }; 17632 17633 // Export the Underscore object for **Node.js**, with 17634 // backwards-compatibility for the old `require()` API. If we're in 17635 // the browser, add `_` as a global object. 17636 if (true) { 17637 if (typeof module !== 'undefined' && module.exports) { 17638 exports = module.exports = _; 17639 } 17640 exports._ = _; 17641 } else { 17642 root._ = _; 17643 } 17644 17645 // Current version. 17646 _.VERSION = '1.8.3'; 17647 17648 // Internal function that returns an efficient (for current engines) version 17649 // of the passed-in callback, to be repeatedly applied in other Underscore 17650 // functions. 17651 var optimizeCb = function(func, context, argCount) { 17652 if (context === void 0) return func; 17653 switch (argCount == null ? 3 : argCount) { 17654 case 1: return function(value) { 17655 return func.call(context, value); 17656 }; 17657 case 2: return function(value, other) { 17658 return func.call(context, value, other); 17659 }; 17660 case 3: return function(value, index, collection) { 17661 return func.call(context, value, index, collection); 17662 }; 17663 case 4: return function(accumulator, value, index, collection) { 17664 return func.call(context, accumulator, value, index, collection); 17665 }; 17666 } 17667 return function() { 17668 return func.apply(context, arguments); 17669 }; 17670 }; 17671 17672 // A mostly-internal function to generate callbacks that can be applied 17673 // to each element in a collection, returning the desired result — either 17674 // identity, an arbitrary callback, a property matcher, or a property accessor. 17675 var cb = function(value, context, argCount) { 17676 if (value == null) return _.identity; 17677 if (_.isFunction(value)) return optimizeCb(value, context, argCount); 17678 if (_.isObject(value)) return _.matcher(value); 17679 return _.property(value); 17680 }; 17681 _.iteratee = function(value, context) { 17682 return cb(value, context, Infinity); 17683 }; 17684 17685 // An internal function for creating assigner functions. 17686 var createAssigner = function(keysFunc, undefinedOnly) { 17687 return function(obj) { 17688 var length = arguments.length; 17689 if (length < 2 || obj == null) return obj; 17690 for (var index = 1; index < length; index++) { 17691 var source = arguments[index], 17692 keys = keysFunc(source), 17693 l = keys.length; 17694 for (var i = 0; i < l; i++) { 17695 var key = keys[i]; 17696 if (!undefinedOnly || obj[key] === void 0) obj[key] = source[key]; 17697 } 17698 } 17699 return obj; 17700 }; 17701 }; 17702 17703 // An internal function for creating a new object that inherits from another. 17704 var baseCreate = function(prototype) { 17705 if (!_.isObject(prototype)) return {}; 17706 if (nativeCreate) return nativeCreate(prototype); 17707 Ctor.prototype = prototype; 17708 var result = new Ctor; 17709 Ctor.prototype = null; 17710 return result; 17711 }; 17712 17713 var property = function(key) { 17714 return function(obj) { 17715 return obj == null ? void 0 : obj[key]; 17716 }; 17717 }; 17718 17719 // Helper for collection methods to determine whether a collection 17720 // should be iterated as an array or as an object 17721 // Related: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength 17722 // Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094 17723 var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1; 17724 var getLength = property('length'); 17725 var isArrayLike = function(collection) { 17726 var length = getLength(collection); 17727 return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX; 17728 }; 17729 17730 // Collection Functions 17731 // -------------------- 17732 17733 // The cornerstone, an `each` implementation, aka `forEach`. 17734 // Handles raw objects in addition to array-likes. Treats all 17735 // sparse array-likes as if they were dense. 17736 _.each = _.forEach = function(obj, iteratee, context) { 17737 iteratee = optimizeCb(iteratee, context); 17738 var i, length; 17739 if (isArrayLike(obj)) { 17740 for (i = 0, length = obj.length; i < length; i++) { 17741 iteratee(obj[i], i, obj); 17742 } 17743 } else { 17744 var keys = _.keys(obj); 17745 for (i = 0, length = keys.length; i < length; i++) { 17746 iteratee(obj[keys[i]], keys[i], obj); 17747 } 17748 } 17749 return obj; 17750 }; 17751 17752 // Return the results of applying the iteratee to each element. 17753 _.map = _.collect = function(obj, iteratee, context) { 17754 iteratee = cb(iteratee, context); 17755 var keys = !isArrayLike(obj) && _.keys(obj), 17756 length = (keys || obj).length, 17757 results = Array(length); 17758 for (var index = 0; index < length; index++) { 17759 var currentKey = keys ? keys[index] : index; 17760 results[index] = iteratee(obj[currentKey], currentKey, obj); 17761 } 17762 return results; 17763 }; 17764 17765 // Create a reducing function iterating left or right. 17766 function createReduce(dir) { 17767 // Optimized iterator function as using arguments.length 17768 // in the main function will deoptimize the, see #1991. 17769 function iterator(obj, iteratee, memo, keys, index, length) { 17770 for (; index >= 0 && index < length; index += dir) { 17771 var currentKey = keys ? keys[index] : index; 17772 memo = iteratee(memo, obj[currentKey], currentKey, obj); 17773 } 17774 return memo; 17775 } 17776 17777 return function(obj, iteratee, memo, context) { 17778 iteratee = optimizeCb(iteratee, context, 4); 17779 var keys = !isArrayLike(obj) && _.keys(obj), 17780 length = (keys || obj).length, 17781 index = dir > 0 ? 0 : length - 1; 17782 // Determine the initial value if none is provided. 17783 if (arguments.length < 3) { 17784 memo = obj[keys ? keys[index] : index]; 17785 index += dir; 17786 } 17787 return iterator(obj, iteratee, memo, keys, index, length); 17788 }; 17789 } 17790 17791 // **Reduce** builds up a single result from a list of values, aka `inject`, 17792 // or `foldl`. 17793 _.reduce = _.foldl = _.inject = createReduce(1); 17794 17795 // The right-associative version of reduce, also known as `foldr`. 17796 _.reduceRight = _.foldr = createReduce(-1); 17797 17798 // Return the first value which passes a truth test. Aliased as `detect`. 17799 _.find = _.detect = function(obj, predicate, context) { 17800 var key; 17801 if (isArrayLike(obj)) { 17802 key = _.findIndex(obj, predicate, context); 17803 } else { 17804 key = _.findKey(obj, predicate, context); 17805 } 17806 if (key !== void 0 && key !== -1) return obj[key]; 17807 }; 17808 17809 // Return all the elements that pass a truth test. 17810 // Aliased as `select`. 17811 _.filter = _.select = function(obj, predicate, context) { 17812 var results = []; 17813 predicate = cb(predicate, context); 17814 _.each(obj, function(value, index, list) { 17815 if (predicate(value, index, list)) results.push(value); 17816 }); 17817 return results; 17818 }; 17819 17820 // Return all the elements for which a truth test fails. 17821 _.reject = function(obj, predicate, context) { 17822 return _.filter(obj, _.negate(cb(predicate)), context); 17823 }; 17824 17825 // Determine whether all of the elements match a truth test. 17826 // Aliased as `all`. 17827 _.every = _.all = function(obj, predicate, context) { 17828 predicate = cb(predicate, context); 17829 var keys = !isArrayLike(obj) && _.keys(obj), 17830 length = (keys || obj).length; 17831 for (var index = 0; index < length; index++) { 17832 var currentKey = keys ? keys[index] : index; 17833 if (!predicate(obj[currentKey], currentKey, obj)) return false; 17834 } 17835 return true; 17836 }; 17837 17838 // Determine if at least one element in the object matches a truth test. 17839 // Aliased as `any`. 17840 _.some = _.any = function(obj, predicate, context) { 17841 predicate = cb(predicate, context); 17842 var keys = !isArrayLike(obj) && _.keys(obj), 17843 length = (keys || obj).length; 17844 for (var index = 0; index < length; index++) { 17845 var currentKey = keys ? keys[index] : index; 17846 if (predicate(obj[currentKey], currentKey, obj)) return true; 17847 } 17848 return false; 17849 }; 17850 17851 // Determine if the array or object contains a given item (using `===`). 17852 // Aliased as `includes` and `include`. 17853 _.contains = _.includes = _.include = function(obj, item, fromIndex, guard) { 17854 if (!isArrayLike(obj)) obj = _.values(obj); 17855 if (typeof fromIndex != 'number' || guard) fromIndex = 0; 17856 return _.indexOf(obj, item, fromIndex) >= 0; 17857 }; 17858 17859 // Invoke a method (with arguments) on every item in a collection. 17860 _.invoke = function(obj, method) { 17861 var args = slice.call(arguments, 2); 17862 var isFunc = _.isFunction(method); 17863 return _.map(obj, function(value) { 17864 var func = isFunc ? method : value[method]; 17865 return func == null ? func : func.apply(value, args); 17866 }); 17867 }; 17868 17869 // Convenience version of a common use case of `map`: fetching a property. 17870 _.pluck = function(obj, key) { 17871 return _.map(obj, _.property(key)); 17872 }; 17873 17874 // Convenience version of a common use case of `filter`: selecting only objects 17875 // containing specific `key:value` pairs. 17876 _.where = function(obj, attrs) { 17877 return _.filter(obj, _.matcher(attrs)); 17878 }; 17879 17880 // Convenience version of a common use case of `find`: getting the first object 17881 // containing specific `key:value` pairs. 17882 _.findWhere = function(obj, attrs) { 17883 return _.find(obj, _.matcher(attrs)); 17884 }; 17885 17886 // Return the maximum element (or element-based computation). 17887 _.max = function(obj, iteratee, context) { 17888 var result = -Infinity, lastComputed = -Infinity, 17889 value, computed; 17890 if (iteratee == null && obj != null) { 17891 obj = isArrayLike(obj) ? obj : _.values(obj); 17892 for (var i = 0, length = obj.length; i < length; i++) { 17893 value = obj[i]; 17894 if (value > result) { 17895 result = value; 17896 } 17897 } 17898 } else { 17899 iteratee = cb(iteratee, context); 17900 _.each(obj, function(value, index, list) { 17901 computed = iteratee(value, index, list); 17902 if (computed > lastComputed || computed === -Infinity && result === -Infinity) { 17903 result = value; 17904 lastComputed = computed; 17905 } 17906 }); 17907 } 17908 return result; 17909 }; 17910 17911 // Return the minimum element (or element-based computation). 17912 _.min = function(obj, iteratee, context) { 17913 var result = Infinity, lastComputed = Infinity, 17914 value, computed; 17915 if (iteratee == null && obj != null) { 17916 obj = isArrayLike(obj) ? obj : _.values(obj); 17917 for (var i = 0, length = obj.length; i < length; i++) { 17918 value = obj[i]; 17919 if (value < result) { 17920 result = value; 17921 } 17922 } 17923 } else { 17924 iteratee = cb(iteratee, context); 17925 _.each(obj, function(value, index, list) { 17926 computed = iteratee(value, index, list); 17927 if (computed < lastComputed || computed === Infinity && result === Infinity) { 17928 result = value; 17929 lastComputed = computed; 17930 } 17931 }); 17932 } 17933 return result; 17934 }; 17935 17936 // Shuffle a collection, using the modern version of the 17937 // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle). 17938 _.shuffle = function(obj) { 17939 var set = isArrayLike(obj) ? obj : _.values(obj); 17940 var length = set.length; 17941 var shuffled = Array(length); 17942 for (var index = 0, rand; index < length; index++) { 17943 rand = _.random(0, index); 17944 if (rand !== index) shuffled[index] = shuffled[rand]; 17945 shuffled[rand] = set[index]; 17946 } 17947 return shuffled; 17948 }; 17949 17950 // Sample **n** random values from a collection. 17951 // If **n** is not specified, returns a single random element. 17952 // The internal `guard` argument allows it to work with `map`. 17953 _.sample = function(obj, n, guard) { 17954 if (n == null || guard) { 17955 if (!isArrayLike(obj)) obj = _.values(obj); 17956 return obj[_.random(obj.length - 1)]; 17957 } 17958 return _.shuffle(obj).slice(0, Math.max(0, n)); 17959 }; 17960 17961 // Sort the object's values by a criterion produced by an iteratee. 17962 _.sortBy = function(obj, iteratee, context) { 17963 iteratee = cb(iteratee, context); 17964 return _.pluck(_.map(obj, function(value, index, list) { 17965 return { 17966 value: value, 17967 index: index, 17968 criteria: iteratee(value, index, list) 17969 }; 17970 }).sort(function(left, right) { 17971 var a = left.criteria; 17972 var b = right.criteria; 17973 if (a !== b) { 17974 if (a > b || a === void 0) return 1; 17975 if (a < b || b === void 0) return -1; 17976 } 17977 return left.index - right.index; 17978 }), 'value'); 17979 }; 17980 17981 // An internal function used for aggregate "group by" operations. 17982 var group = function(behavior) { 17983 return function(obj, iteratee, context) { 17984 var result = {}; 17985 iteratee = cb(iteratee, context); 17986 _.each(obj, function(value, index) { 17987 var key = iteratee(value, index, obj); 17988 behavior(result, value, key); 17989 }); 17990 return result; 17991 }; 17992 }; 17993 17994 // Groups the object's values by a criterion. Pass either a string attribute 17995 // to group by, or a function that returns the criterion. 17996 _.groupBy = group(function(result, value, key) { 17997 if (_.has(result, key)) result[key].push(value); else result[key] = [value]; 17998 }); 17999 18000 // Indexes the object's values by a criterion, similar to `groupBy`, but for 18001 // when you know that your index values will be unique. 18002 _.indexBy = group(function(result, value, key) { 18003 result[key] = value; 18004 }); 18005 18006 // Counts instances of an object that group by a certain criterion. Pass 18007 // either a string attribute to count by, or a function that returns the 18008 // criterion. 18009 _.countBy = group(function(result, value, key) { 18010 if (_.has(result, key)) result[key]++; else result[key] = 1; 18011 }); 18012 18013 // Safely create a real, live array from anything iterable. 18014 _.toArray = function(obj) { 18015 if (!obj) return []; 18016 if (_.isArray(obj)) return slice.call(obj); 18017 if (isArrayLike(obj)) return _.map(obj, _.identity); 18018 return _.values(obj); 18019 }; 18020 18021 // Return the number of elements in an object. 18022 _.size = function(obj) { 18023 if (obj == null) return 0; 18024 return isArrayLike(obj) ? obj.length : _.keys(obj).length; 18025 }; 18026 18027 // Split a collection into two arrays: one whose elements all satisfy the given 18028 // predicate, and one whose elements all do not satisfy the predicate. 18029 _.partition = function(obj, predicate, context) { 18030 predicate = cb(predicate, context); 18031 var pass = [], fail = []; 18032 _.each(obj, function(value, key, obj) { 18033 (predicate(value, key, obj) ? pass : fail).push(value); 18034 }); 18035 return [pass, fail]; 18036 }; 18037 18038 // Array Functions 18039 // --------------- 18040 18041 // Get the first element of an array. Passing **n** will return the first N 18042 // values in the array. Aliased as `head` and `take`. The **guard** check 18043 // allows it to work with `_.map`. 18044 _.first = _.head = _.take = function(array, n, guard) { 18045 if (array == null) return void 0; 18046 if (n == null || guard) return array[0]; 18047 return _.initial(array, array.length - n); 18048 }; 18049 18050 // Returns everything but the last entry of the array. Especially useful on 18051 // the arguments object. Passing **n** will return all the values in 18052 // the array, excluding the last N. 18053 _.initial = function(array, n, guard) { 18054 return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n))); 18055 }; 18056 18057 // Get the last element of an array. Passing **n** will return the last N 18058 // values in the array. 18059 _.last = function(array, n, guard) { 18060 if (array == null) return void 0; 18061 if (n == null || guard) return array[array.length - 1]; 18062 return _.rest(array, Math.max(0, array.length - n)); 18063 }; 18064 18065 // Returns everything but the first entry of the array. Aliased as `tail` and `drop`. 18066 // Especially useful on the arguments object. Passing an **n** will return 18067 // the rest N values in the array. 18068 _.rest = _.tail = _.drop = function(array, n, guard) { 18069 return slice.call(array, n == null || guard ? 1 : n); 18070 }; 18071 18072 // Trim out all falsy values from an array. 18073 _.compact = function(array) { 18074 return _.filter(array, _.identity); 18075 }; 18076 18077 // Internal implementation of a recursive `flatten` function. 18078 var flatten = function(input, shallow, strict, startIndex) { 18079 var output = [], idx = 0; 18080 for (var i = startIndex || 0, length = getLength(input); i < length; i++) { 18081 var value = input[i]; 18082 if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) { 18083 //flatten current level of array or arguments object 18084 if (!shallow) value = flatten(value, shallow, strict); 18085 var j = 0, len = value.length; 18086 output.length += len; 18087 while (j < len) { 18088 output[idx++] = value[j++]; 18089 } 18090 } else if (!strict) { 18091 output[idx++] = value; 18092 } 18093 } 18094 return output; 18095 }; 18096 18097 // Flatten out an array, either recursively (by default), or just one level. 18098 _.flatten = function(array, shallow) { 18099 return flatten(array, shallow, false); 18100 }; 18101 18102 // Return a version of the array that does not contain the specified value(s). 18103 _.without = function(array) { 18104 return _.difference(array, slice.call(arguments, 1)); 18105 }; 18106 18107 // Produce a duplicate-free version of the array. If the array has already 18108 // been sorted, you have the option of using a faster algorithm. 18109 // Aliased as `unique`. 18110 _.uniq = _.unique = function(array, isSorted, iteratee, context) { 18111 if (!_.isBoolean(isSorted)) { 18112 context = iteratee; 18113 iteratee = isSorted; 18114 isSorted = false; 18115 } 18116 if (iteratee != null) iteratee = cb(iteratee, context); 18117 var result = []; 18118 var seen = []; 18119 for (var i = 0, length = getLength(array); i < length; i++) { 18120 var value = array[i], 18121 computed = iteratee ? iteratee(value, i, array) : value; 18122 if (isSorted) { 18123 if (!i || seen !== computed) result.push(value); 18124 seen = computed; 18125 } else if (iteratee) { 18126 if (!_.contains(seen, computed)) { 18127 seen.push(computed); 18128 result.push(value); 18129 } 18130 } else if (!_.contains(result, value)) { 18131 result.push(value); 18132 } 18133 } 18134 return result; 18135 }; 18136 18137 // Produce an array that contains the union: each distinct element from all of 18138 // the passed-in arrays. 18139 _.union = function() { 18140 return _.uniq(flatten(arguments, true, true)); 18141 }; 18142 18143 // Produce an array that contains every item shared between all the 18144 // passed-in arrays. 18145 _.intersection = function(array) { 18146 var result = []; 18147 var argsLength = arguments.length; 18148 for (var i = 0, length = getLength(array); i < length; i++) { 18149 var item = array[i]; 18150 if (_.contains(result, item)) continue; 18151 for (var j = 1; j < argsLength; j++) { 18152 if (!_.contains(arguments[j], item)) break; 18153 } 18154 if (j === argsLength) result.push(item); 18155 } 18156 return result; 18157 }; 18158 18159 // Take the difference between one array and a number of other arrays. 18160 // Only the elements present in just the first array will remain. 18161 _.difference = function(array) { 18162 var rest = flatten(arguments, true, true, 1); 18163 return _.filter(array, function(value){ 18164 return !_.contains(rest, value); 18165 }); 18166 }; 18167 18168 // Zip together multiple lists into a single array -- elements that share 18169 // an index go together. 18170 _.zip = function() { 18171 return _.unzip(arguments); 18172 }; 18173 18174 // Complement of _.zip. Unzip accepts an array of arrays and groups 18175 // each array's elements on shared indices 18176 _.unzip = function(array) { 18177 var length = array && _.max(array, getLength).length || 0; 18178 var result = Array(length); 18179 18180 for (var index = 0; index < length; index++) { 18181 result[index] = _.pluck(array, index); 18182 } 18183 return result; 18184 }; 18185 18186 // Converts lists into objects. Pass either a single array of `[key, value]` 18187 // pairs, or two parallel arrays of the same length -- one of keys, and one of 18188 // the corresponding values. 18189 _.object = function(list, values) { 18190 var result = {}; 18191 for (var i = 0, length = getLength(list); i < length; i++) { 18192 if (values) { 18193 result[list[i]] = values[i]; 18194 } else { 18195 result[list[i][0]] = list[i][1]; 18196 } 18197 } 18198 return result; 18199 }; 18200 18201 // Generator function to create the findIndex and findLastIndex functions 18202 function createPredicateIndexFinder(dir) { 18203 return function(array, predicate, context) { 18204 predicate = cb(predicate, context); 18205 var length = getLength(array); 18206 var index = dir > 0 ? 0 : length - 1; 18207 for (; index >= 0 && index < length; index += dir) { 18208 if (predicate(array[index], index, array)) return index; 18209 } 18210 return -1; 18211 }; 18212 } 18213 18214 // Returns the first index on an array-like that passes a predicate test 18215 _.findIndex = createPredicateIndexFinder(1); 18216 _.findLastIndex = createPredicateIndexFinder(-1); 18217 18218 // Use a comparator function to figure out the smallest index at which 18219 // an object should be inserted so as to maintain order. Uses binary search. 18220 _.sortedIndex = function(array, obj, iteratee, context) { 18221 iteratee = cb(iteratee, context, 1); 18222 var value = iteratee(obj); 18223 var low = 0, high = getLength(array); 18224 while (low < high) { 18225 var mid = Math.floor((low + high) / 2); 18226 if (iteratee(array[mid]) < value) low = mid + 1; else high = mid; 18227 } 18228 return low; 18229 }; 18230 18231 // Generator function to create the indexOf and lastIndexOf functions 18232 function createIndexFinder(dir, predicateFind, sortedIndex) { 18233 return function(array, item, idx) { 18234 var i = 0, length = getLength(array); 18235 if (typeof idx == 'number') { 18236 if (dir > 0) { 18237 i = idx >= 0 ? idx : Math.max(idx + length, i); 18238 } else { 18239 length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1; 18240 } 18241 } else if (sortedIndex && idx && length) { 18242 idx = sortedIndex(array, item); 18243 return array[idx] === item ? idx : -1; 18244 } 18245 if (item !== item) { 18246 idx = predicateFind(slice.call(array, i, length), _.isNaN); 18247 return idx >= 0 ? idx + i : -1; 18248 } 18249 for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) { 18250 if (array[idx] === item) return idx; 18251 } 18252 return -1; 18253 }; 18254 } 18255 18256 // Return the position of the first occurrence of an item in an array, 18257 // or -1 if the item is not included in the array. 18258 // If the array is large and already in sort order, pass `true` 18259 // for **isSorted** to use binary search. 18260 _.indexOf = createIndexFinder(1, _.findIndex, _.sortedIndex); 18261 _.lastIndexOf = createIndexFinder(-1, _.findLastIndex); 18262 18263 // Generate an integer Array containing an arithmetic progression. A port of 18264 // the native Python `range()` function. See 18265 // [the Python documentation](http://docs.python.org/library/functions.html#range). 18266 _.range = function(start, stop, step) { 18267 if (stop == null) { 18268 stop = start || 0; 18269 start = 0; 18270 } 18271 step = step || 1; 18272 18273 var length = Math.max(Math.ceil((stop - start) / step), 0); 18274 var range = Array(length); 18275 18276 for (var idx = 0; idx < length; idx++, start += step) { 18277 range[idx] = start; 18278 } 18279 18280 return range; 18281 }; 18282 18283 // Function (ahem) Functions 18284 // ------------------ 18285 18286 // Determines whether to execute a function as a constructor 18287 // or a normal function with the provided arguments 18288 var executeBound = function(sourceFunc, boundFunc, context, callingContext, args) { 18289 if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args); 18290 var self = baseCreate(sourceFunc.prototype); 18291 var result = sourceFunc.apply(self, args); 18292 if (_.isObject(result)) return result; 18293 return self; 18294 }; 18295 18296 // Create a function bound to a given object (assigning `this`, and arguments, 18297 // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if 18298 // available. 18299 _.bind = function(func, context) { 18300 if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); 18301 if (!_.isFunction(func)) throw new TypeError('Bind must be called on a function'); 18302 var args = slice.call(arguments, 2); 18303 var bound = function() { 18304 return executeBound(func, bound, context, this, args.concat(slice.call(arguments))); 18305 }; 18306 return bound; 18307 }; 18308 18309 // Partially apply a function by creating a version that has had some of its 18310 // arguments pre-filled, without changing its dynamic `this` context. _ acts 18311 // as a placeholder, allowing any combination of arguments to be pre-filled. 18312 _.partial = function(func) { 18313 var boundArgs = slice.call(arguments, 1); 18314 var bound = function() { 18315 var position = 0, length = boundArgs.length; 18316 var args = Array(length); 18317 for (var i = 0; i < length; i++) { 18318 args[i] = boundArgs[i] === _ ? arguments[position++] : boundArgs[i]; 18319 } 18320 while (position < arguments.length) args.push(arguments[position++]); 18321 return executeBound(func, bound, this, this, args); 18322 }; 18323 return bound; 18324 }; 18325 18326 // Bind a number of an object's methods to that object. Remaining arguments 18327 // are the method names to be bound. Useful for ensuring that all callbacks 18328 // defined on an object belong to it. 18329 _.bindAll = function(obj) { 18330 var i, length = arguments.length, key; 18331 if (length <= 1) throw new Error('bindAll must be passed function names'); 18332 for (i = 1; i < length; i++) { 18333 key = arguments[i]; 18334 obj[key] = _.bind(obj[key], obj); 18335 } 18336 return obj; 18337 }; 18338 18339 // Memoize an expensive function by storing its results. 18340 _.memoize = function(func, hasher) { 18341 var memoize = function(key) { 18342 var cache = memoize.cache; 18343 var address = '' + (hasher ? hasher.apply(this, arguments) : key); 18344 if (!_.has(cache, address)) cache[address] = func.apply(this, arguments); 18345 return cache[address]; 18346 }; 18347 memoize.cache = {}; 18348 return memoize; 18349 }; 18350 18351 // Delays a function for the given number of milliseconds, and then calls 18352 // it with the arguments supplied. 18353 _.delay = function(func, wait) { 18354 var args = slice.call(arguments, 2); 18355 return setTimeout(function(){ 18356 return func.apply(null, args); 18357 }, wait); 18358 }; 18359 18360 // Defers a function, scheduling it to run after the current call stack has 18361 // cleared. 18362 _.defer = _.partial(_.delay, _, 1); 18363 18364 // Returns a function, that, when invoked, will only be triggered at most once 18365 // during a given window of time. Normally, the throttled function will run 18366 // as much as it can, without ever going more than once per `wait` duration; 18367 // but if you'd like to disable the execution on the leading edge, pass 18368 // `{leading: false}`. To disable execution on the trailing edge, ditto. 18369 _.throttle = function(func, wait, options) { 18370 var context, args, result; 18371 var timeout = null; 18372 var previous = 0; 18373 if (!options) options = {}; 18374 var later = function() { 18375 previous = options.leading === false ? 0 : _.now(); 18376 timeout = null; 18377 result = func.apply(context, args); 18378 if (!timeout) context = args = null; 18379 }; 18380 return function() { 18381 var now = _.now(); 18382 if (!previous && options.leading === false) previous = now; 18383 var remaining = wait - (now - previous); 18384 context = this; 18385 args = arguments; 18386 if (remaining <= 0 || remaining > wait) { 18387 if (timeout) { 18388 clearTimeout(timeout); 18389 timeout = null; 18390 } 18391 previous = now; 18392 result = func.apply(context, args); 18393 if (!timeout) context = args = null; 18394 } else if (!timeout && options.trailing !== false) { 18395 timeout = setTimeout(later, remaining); 18396 } 18397 return result; 18398 }; 18399 }; 18400 18401 // Returns a function, that, as long as it continues to be invoked, will not 18402 // be triggered. The function will be called after it stops being called for 18403 // N milliseconds. If `immediate` is passed, trigger the function on the 18404 // leading edge, instead of the trailing. 18405 _.debounce = function(func, wait, immediate) { 18406 var timeout, args, context, timestamp, result; 18407 18408 var later = function() { 18409 var last = _.now() - timestamp; 18410 18411 if (last < wait && last >= 0) { 18412 timeout = setTimeout(later, wait - last); 18413 } else { 18414 timeout = null; 18415 if (!immediate) { 18416 result = func.apply(context, args); 18417 if (!timeout) context = args = null; 18418 } 18419 } 18420 }; 18421 18422 return function() { 18423 context = this; 18424 args = arguments; 18425 timestamp = _.now(); 18426 var callNow = immediate && !timeout; 18427 if (!timeout) timeout = setTimeout(later, wait); 18428 if (callNow) { 18429 result = func.apply(context, args); 18430 context = args = null; 18431 } 18432 18433 return result; 18434 }; 18435 }; 18436 18437 // Returns the first function passed as an argument to the second, 18438 // allowing you to adjust arguments, run code before and after, and 18439 // conditionally execute the original function. 18440 _.wrap = function(func, wrapper) { 18441 return _.partial(wrapper, func); 18442 }; 18443 18444 // Returns a negated version of the passed-in predicate. 18445 _.negate = function(predicate) { 18446 return function() { 18447 return !predicate.apply(this, arguments); 18448 }; 18449 }; 18450 18451 // Returns a function that is the composition of a list of functions, each 18452 // consuming the return value of the function that follows. 18453 _.compose = function() { 18454 var args = arguments; 18455 var start = args.length - 1; 18456 return function() { 18457 var i = start; 18458 var result = args[start].apply(this, arguments); 18459 while (i--) result = args[i].call(this, result); 18460 return result; 18461 }; 18462 }; 18463 18464 // Returns a function that will only be executed on and after the Nth call. 18465 _.after = function(times, func) { 18466 return function() { 18467 if (--times < 1) { 18468 return func.apply(this, arguments); 18469 } 18470 }; 18471 }; 18472 18473 // Returns a function that will only be executed up to (but not including) the Nth call. 18474 _.before = function(times, func) { 18475 var memo; 18476 return function() { 18477 if (--times > 0) { 18478 memo = func.apply(this, arguments); 18479 } 18480 if (times <= 1) func = null; 18481 return memo; 18482 }; 18483 }; 18484 18485 // Returns a function that will be executed at most one time, no matter how 18486 // often you call it. Useful for lazy initialization. 18487 _.once = _.partial(_.before, 2); 18488 18489 // Object Functions 18490 // ---------------- 18491 18492 // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed. 18493 var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString'); 18494 var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString', 18495 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; 18496 18497 function collectNonEnumProps(obj, keys) { 18498 var nonEnumIdx = nonEnumerableProps.length; 18499 var constructor = obj.constructor; 18500 var proto = (_.isFunction(constructor) && constructor.prototype) || ObjProto; 18501 18502 // Constructor is a special case. 18503 var prop = 'constructor'; 18504 if (_.has(obj, prop) && !_.contains(keys, prop)) keys.push(prop); 18505 18506 while (nonEnumIdx--) { 18507 prop = nonEnumerableProps[nonEnumIdx]; 18508 if (prop in obj && obj[prop] !== proto[prop] && !_.contains(keys, prop)) { 18509 keys.push(prop); 18510 } 18511 } 18512 } 18513 18514 // Retrieve the names of an object's own properties. 18515 // Delegates to **ECMAScript 5**'s native `Object.keys` 18516 _.keys = function(obj) { 18517 if (!_.isObject(obj)) return []; 18518 if (nativeKeys) return nativeKeys(obj); 18519 var keys = []; 18520 for (var key in obj) if (_.has(obj, key)) keys.push(key); 18521 // Ahem, IE < 9. 18522 if (hasEnumBug) collectNonEnumProps(obj, keys); 18523 return keys; 18524 }; 18525 18526 // Retrieve all the property names of an object. 18527 _.allKeys = function(obj) { 18528 if (!_.isObject(obj)) return []; 18529 var keys = []; 18530 for (var key in obj) keys.push(key); 18531 // Ahem, IE < 9. 18532 if (hasEnumBug) collectNonEnumProps(obj, keys); 18533 return keys; 18534 }; 18535 18536 // Retrieve the values of an object's properties. 18537 _.values = function(obj) { 18538 var keys = _.keys(obj); 18539 var length = keys.length; 18540 var values = Array(length); 18541 for (var i = 0; i < length; i++) { 18542 values[i] = obj[keys[i]]; 18543 } 18544 return values; 18545 }; 18546 18547 // Returns the results of applying the iteratee to each element of the object 18548 // In contrast to _.map it returns an object 18549 _.mapObject = function(obj, iteratee, context) { 18550 iteratee = cb(iteratee, context); 18551 var keys = _.keys(obj), 18552 length = keys.length, 18553 results = {}, 18554 currentKey; 18555 for (var index = 0; index < length; index++) { 18556 currentKey = keys[index]; 18557 results[currentKey] = iteratee(obj[currentKey], currentKey, obj); 18558 } 18559 return results; 18560 }; 18561 18562 // Convert an object into a list of `[key, value]` pairs. 18563 _.pairs = function(obj) { 18564 var keys = _.keys(obj); 18565 var length = keys.length; 18566 var pairs = Array(length); 18567 for (var i = 0; i < length; i++) { 18568 pairs[i] = [keys[i], obj[keys[i]]]; 18569 } 18570 return pairs; 18571 }; 18572 18573 // Invert the keys and values of an object. The values must be serializable. 18574 _.invert = function(obj) { 18575 var result = {}; 18576 var keys = _.keys(obj); 18577 for (var i = 0, length = keys.length; i < length; i++) { 18578 result[obj[keys[i]]] = keys[i]; 18579 } 18580 return result; 18581 }; 18582 18583 // Return a sorted list of the function names available on the object. 18584 // Aliased as `methods` 18585 _.functions = _.methods = function(obj) { 18586 var names = []; 18587 for (var key in obj) { 18588 if (_.isFunction(obj[key])) names.push(key); 18589 } 18590 return names.sort(); 18591 }; 18592 18593 // Extend a given object with all the properties in passed-in object(s). 18594 _.extend = createAssigner(_.allKeys); 18595 18596 // Assigns a given object with all the own properties in the passed-in object(s) 18597 // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) 18598 _.extendOwn = _.assign = createAssigner(_.keys); 18599 18600 // Returns the first key on an object that passes a predicate test 18601 _.findKey = function(obj, predicate, context) { 18602 predicate = cb(predicate, context); 18603 var keys = _.keys(obj), key; 18604 for (var i = 0, length = keys.length; i < length; i++) { 18605 key = keys[i]; 18606 if (predicate(obj[key], key, obj)) return key; 18607 } 18608 }; 18609 18610 // Return a copy of the object only containing the whitelisted properties. 18611 _.pick = function(object, oiteratee, context) { 18612 var result = {}, obj = object, iteratee, keys; 18613 if (obj == null) return result; 18614 if (_.isFunction(oiteratee)) { 18615 keys = _.allKeys(obj); 18616 iteratee = optimizeCb(oiteratee, context); 18617 } else { 18618 keys = flatten(arguments, false, false, 1); 18619 iteratee = function(value, key, obj) { return key in obj; }; 18620 obj = Object(obj); 18621 } 18622 for (var i = 0, length = keys.length; i < length; i++) { 18623 var key = keys[i]; 18624 var value = obj[key]; 18625 if (iteratee(value, key, obj)) result[key] = value; 18626 } 18627 return result; 18628 }; 18629 18630 // Return a copy of the object without the blacklisted properties. 18631 _.omit = function(obj, iteratee, context) { 18632 if (_.isFunction(iteratee)) { 18633 iteratee = _.negate(iteratee); 18634 } else { 18635 var keys = _.map(flatten(arguments, false, false, 1), String); 18636 iteratee = function(value, key) { 18637 return !_.contains(keys, key); 18638 }; 18639 } 18640 return _.pick(obj, iteratee, context); 18641 }; 18642 18643 // Fill in a given object with default properties. 18644 _.defaults = createAssigner(_.allKeys, true); 18645 18646 // Creates an object that inherits from the given prototype object. 18647 // If additional properties are provided then they will be added to the 18648 // created object. 18649 _.create = function(prototype, props) { 18650 var result = baseCreate(prototype); 18651 if (props) _.extendOwn(result, props); 18652 return result; 18653 }; 18654 18655 // Create a (shallow-cloned) duplicate of an object. 18656 _.clone = function(obj) { 18657 if (!_.isObject(obj)) return obj; 18658 return _.isArray(obj) ? obj.slice() : _.extend({}, obj); 18659 }; 18660 18661 // Invokes interceptor with the obj, and then returns obj. 18662 // The primary purpose of this method is to "tap into" a method chain, in 18663 // order to perform operations on intermediate results within the chain. 18664 _.tap = function(obj, interceptor) { 18665 interceptor(obj); 18666 return obj; 18667 }; 18668 18669 // Returns whether an object has a given set of `key:value` pairs. 18670 _.isMatch = function(object, attrs) { 18671 var keys = _.keys(attrs), length = keys.length; 18672 if (object == null) return !length; 18673 var obj = Object(object); 18674 for (var i = 0; i < length; i++) { 18675 var key = keys[i]; 18676 if (attrs[key] !== obj[key] || !(key in obj)) return false; 18677 } 18678 return true; 18679 }; 18680 18681 18682 // Internal recursive comparison function for `isEqual`. 18683 var eq = function(a, b, aStack, bStack) { 18684 // Identical objects are equal. `0 === -0`, but they aren't identical. 18685 // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). 18686 if (a === b) return a !== 0 || 1 / a === 1 / b; 18687 // A strict comparison is necessary because `null == undefined`. 18688 if (a == null || b == null) return a === b; 18689 // Unwrap any wrapped objects. 18690 if (a instanceof _) a = a._wrapped; 18691 if (b instanceof _) b = b._wrapped; 18692 // Compare `[[Class]]` names. 18693 var className = toString.call(a); 18694 if (className !== toString.call(b)) return false; 18695 switch (className) { 18696 // Strings, numbers, regular expressions, dates, and booleans are compared by value. 18697 case '[object RegExp]': 18698 // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i') 18699 case '[object String]': 18700 // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is 18701 // equivalent to `new String("5")`. 18702 return '' + a === '' + b; 18703 case '[object Number]': 18704 // `NaN`s are equivalent, but non-reflexive. 18705 // Object(NaN) is equivalent to NaN 18706 if (+a !== +a) return +b !== +b; 18707 // An `egal` comparison is performed for other numeric values. 18708 return +a === 0 ? 1 / +a === 1 / b : +a === +b; 18709 case '[object Date]': 18710 case '[object Boolean]': 18711 // Coerce dates and booleans to numeric primitive values. Dates are compared by their 18712 // millisecond representations. Note that invalid dates with millisecond representations 18713 // of `NaN` are not equivalent. 18714 return +a === +b; 18715 } 18716 18717 var areArrays = className === '[object Array]'; 18718 if (!areArrays) { 18719 if (typeof a != 'object' || typeof b != 'object') return false; 18720 18721 // Objects with different constructors are not equivalent, but `Object`s or `Array`s 18722 // from different frames are. 18723 var aCtor = a.constructor, bCtor = b.constructor; 18724 if (aCtor !== bCtor && !(_.isFunction(aCtor) && aCtor instanceof aCtor && 18725 _.isFunction(bCtor) && bCtor instanceof bCtor) 18726 && ('constructor' in a && 'constructor' in b)) { 18727 return false; 18728 } 18729 } 18730 // Assume equality for cyclic structures. The algorithm for detecting cyclic 18731 // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. 18732 18733 // Initializing stack of traversed objects. 18734 // It's done here since we only need them for objects and arrays comparison. 18735 aStack = aStack || []; 18736 bStack = bStack || []; 18737 var length = aStack.length; 18738 while (length--) { 18739 // Linear search. Performance is inversely proportional to the number of 18740 // unique nested structures. 18741 if (aStack[length] === a) return bStack[length] === b; 18742 } 18743 18744 // Add the first object to the stack of traversed objects. 18745 aStack.push(a); 18746 bStack.push(b); 18747 18748 // Recursively compare objects and arrays. 18749 if (areArrays) { 18750 // Compare array lengths to determine if a deep comparison is necessary. 18751 length = a.length; 18752 if (length !== b.length) return false; 18753 // Deep compare the contents, ignoring non-numeric properties. 18754 while (length--) { 18755 if (!eq(a[length], b[length], aStack, bStack)) return false; 18756 } 18757 } else { 18758 // Deep compare objects. 18759 var keys = _.keys(a), key; 18760 length = keys.length; 18761 // Ensure that both objects contain the same number of properties before comparing deep equality. 18762 if (_.keys(b).length !== length) return false; 18763 while (length--) { 18764 // Deep compare each member 18765 key = keys[length]; 18766 if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) return false; 18767 } 18768 } 18769 // Remove the first object from the stack of traversed objects. 18770 aStack.pop(); 18771 bStack.pop(); 18772 return true; 18773 }; 18774 18775 // Perform a deep comparison to check if two objects are equal. 18776 _.isEqual = function(a, b) { 18777 return eq(a, b); 18778 }; 18779 18780 // Is a given array, string, or object empty? 18781 // An "empty" object has no enumerable own-properties. 18782 _.isEmpty = function(obj) { 18783 if (obj == null) return true; 18784 if (isArrayLike(obj) && (_.isArray(obj) || _.isString(obj) || _.isArguments(obj))) return obj.length === 0; 18785 return _.keys(obj).length === 0; 18786 }; 18787 18788 // Is a given value a DOM element? 18789 _.isElement = function(obj) { 18790 return !!(obj && obj.nodeType === 1); 18791 }; 18792 18793 // Is a given value an array? 18794 // Delegates to ECMA5's native Array.isArray 18795 _.isArray = nativeIsArray || function(obj) { 18796 return toString.call(obj) === '[object Array]'; 18797 }; 18798 18799 // Is a given variable an object? 18800 _.isObject = function(obj) { 18801 var type = typeof obj; 18802 return type === 'function' || type === 'object' && !!obj; 18803 }; 18804 18805 // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError. 18806 _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error'], function(name) { 18807 _['is' + name] = function(obj) { 18808 return toString.call(obj) === '[object ' + name + ']'; 18809 }; 18810 }); 18811 18812 // Define a fallback version of the method in browsers (ahem, IE < 9), where 18813 // there isn't any inspectable "Arguments" type. 18814 if (!_.isArguments(arguments)) { 18815 _.isArguments = function(obj) { 18816 return _.has(obj, 'callee'); 18817 }; 18818 } 18819 18820 // Optimize `isFunction` if appropriate. Work around some typeof bugs in old v8, 18821 // IE 11 (#1621), and in Safari 8 (#1929). 18822 if (typeof /./ != 'function' && typeof Int8Array != 'object') { 18823 _.isFunction = function(obj) { 18824 return typeof obj == 'function' || false; 18825 }; 18826 } 18827 18828 // Is a given object a finite number? 18829 _.isFinite = function(obj) { 18830 return isFinite(obj) && !isNaN(parseFloat(obj)); 18831 }; 18832 18833 // Is the given value `NaN`? (NaN is the only number which does not equal itself). 18834 _.isNaN = function(obj) { 18835 return _.isNumber(obj) && obj !== +obj; 18836 }; 18837 18838 // Is a given value a boolean? 18839 _.isBoolean = function(obj) { 18840 return obj === true || obj === false || toString.call(obj) === '[object Boolean]'; 18841 }; 18842 18843 // Is a given value equal to null? 18844 _.isNull = function(obj) { 18845 return obj === null; 18846 }; 18847 18848 // Is a given variable undefined? 18849 _.isUndefined = function(obj) { 18850 return obj === void 0; 18851 }; 18852 18853 // Shortcut function for checking if an object has a given property directly 18854 // on itself (in other words, not on a prototype). 18855 _.has = function(obj, key) { 18856 return obj != null && hasOwnProperty.call(obj, key); 18857 }; 18858 18859 // Utility Functions 18860 // ----------------- 18861 18862 // Run Underscore.js in *noConflict* mode, returning the `_` variable to its 18863 // previous owner. Returns a reference to the Underscore object. 18864 _.noConflict = function() { 18865 root._ = previousUnderscore; 18866 return this; 18867 }; 18868 18869 // Keep the identity function around for default iteratees. 18870 _.identity = function(value) { 18871 return value; 18872 }; 18873 18874 // Predicate-generating functions. Often useful outside of Underscore. 18875 _.constant = function(value) { 18876 return function() { 18877 return value; 18878 }; 18879 }; 18880 18881 _.noop = function(){}; 18882 18883 _.property = property; 18884 18885 // Generates a function for a given object that returns a given property. 18886 _.propertyOf = function(obj) { 18887 return obj == null ? function(){} : function(key) { 18888 return obj[key]; 18889 }; 18890 }; 18891 18892 // Returns a predicate for checking whether an object has a given set of 18893 // `key:value` pairs. 18894 _.matcher = _.matches = function(attrs) { 18895 attrs = _.extendOwn({}, attrs); 18896 return function(obj) { 18897 return _.isMatch(obj, attrs); 18898 }; 18899 }; 18900 18901 // Run a function **n** times. 18902 _.times = function(n, iteratee, context) { 18903 var accum = Array(Math.max(0, n)); 18904 iteratee = optimizeCb(iteratee, context, 1); 18905 for (var i = 0; i < n; i++) accum[i] = iteratee(i); 18906 return accum; 18907 }; 18908 18909 // Return a random integer between min and max (inclusive). 18910 _.random = function(min, max) { 18911 if (max == null) { 18912 max = min; 18913 min = 0; 18914 } 18915 return min + Math.floor(Math.random() * (max - min + 1)); 18916 }; 18917 18918 // A (possibly faster) way to get the current timestamp as an integer. 18919 _.now = Date.now || function() { 18920 return new Date().getTime(); 18921 }; 18922 18923 // List of HTML entities for escaping. 18924 var escapeMap = { 18925 '&': '&', 18926 '<': '<', 18927 '>': '>', 18928 '"': '"', 18929 "'": ''', 18930 '`': '`' 18931 }; 18932 var unescapeMap = _.invert(escapeMap); 18933 18934 // Functions for escaping and unescaping strings to/from HTML interpolation. 18935 var createEscaper = function(map) { 18936 var escaper = function(match) { 18937 return map[match]; 18938 }; 18939 // Regexes for identifying a key that needs to be escaped 18940 var source = '(?:' + _.keys(map).join('|') + ')'; 18941 var testRegexp = RegExp(source); 18942 var replaceRegexp = RegExp(source, 'g'); 18943 return function(string) { 18944 string = string == null ? '' : '' + string; 18945 return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string; 18946 }; 18947 }; 18948 _.escape = createEscaper(escapeMap); 18949 _.unescape = createEscaper(unescapeMap); 18950 18951 // If the value of the named `property` is a function then invoke it with the 18952 // `object` as context; otherwise, return it. 18953 _.result = function(object, property, fallback) { 18954 var value = object == null ? void 0 : object[property]; 18955 if (value === void 0) { 18956 value = fallback; 18957 } 18958 return _.isFunction(value) ? value.call(object) : value; 18959 }; 18960 18961 // Generate a unique integer id (unique within the entire client session). 18962 // Useful for temporary DOM ids. 18963 var idCounter = 0; 18964 _.uniqueId = function(prefix) { 18965 var id = ++idCounter + ''; 18966 return prefix ? prefix + id : id; 18967 }; 18968 18969 // By default, Underscore uses ERB-style template delimiters, change the 18970 // following template settings to use alternative delimiters. 18971 _.templateSettings = { 18972 evaluate : /<%([\s\S]+?)%>/g, 18973 interpolate : /<%=([\s\S]+?)%>/g, 18974 escape : /<%-([\s\S]+?)%>/g 18975 }; 18976 18977 // When customizing `templateSettings`, if you don't want to define an 18978 // interpolation, evaluation or escaping regex, we need one that is 18979 // guaranteed not to match. 18980 var noMatch = /(.)^/; 18981 18982 // Certain characters need to be escaped so that they can be put into a 18983 // string literal. 18984 var escapes = { 18985 "'": "'", 18986 '\\': '\\', 18987 '\r': 'r', 18988 '\n': 'n', 18989 '\u2028': 'u2028', 18990 '\u2029': 'u2029' 18991 }; 18992 18993 var escaper = /\\|'|\r|\n|\u2028|\u2029/g; 18994 18995 var escapeChar = function(match) { 18996 return '\\' + escapes[match]; 18997 }; 18998 18999 // JavaScript micro-templating, similar to John Resig's implementation. 19000 // Underscore templating handles arbitrary delimiters, preserves whitespace, 19001 // and correctly escapes quotes within interpolated code. 19002 // NB: `oldSettings` only exists for backwards compatibility. 19003 _.template = function(text, settings, oldSettings) { 19004 if (!settings && oldSettings) settings = oldSettings; 19005 settings = _.defaults({}, settings, _.templateSettings); 19006 19007 // Combine delimiters into one regular expression via alternation. 19008 var matcher = RegExp([ 19009 (settings.escape || noMatch).source, 19010 (settings.interpolate || noMatch).source, 19011 (settings.evaluate || noMatch).source 19012 ].join('|') + '|$', 'g'); 19013 19014 // Compile the template source, escaping string literals appropriately. 19015 var index = 0; 19016 var source = "__p+='"; 19017 text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { 19018 source += text.slice(index, offset).replace(escaper, escapeChar); 19019 index = offset + match.length; 19020 19021 if (escape) { 19022 source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; 19023 } else if (interpolate) { 19024 source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; 19025 } else if (evaluate) { 19026 source += "';\n" + evaluate + "\n__p+='"; 19027 } 19028 19029 // Adobe VMs need the match returned to produce the correct offest. 19030 return match; 19031 }); 19032 source += "';\n"; 19033 19034 // If a variable is not specified, place data values in local scope. 19035 if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; 19036 19037 source = "var __t,__p='',__j=Array.prototype.join," + 19038 "print=function(){__p+=__j.call(arguments,'');};\n" + 19039 source + 'return __p;\n'; 19040 19041 try { 19042 var render = new Function(settings.variable || 'obj', '_', source); 19043 } catch (e) { 19044 e.source = source; 19045 throw e; 19046 } 19047 19048 var template = function(data) { 19049 return render.call(this, data, _); 19050 }; 19051 19052 // Provide the compiled source as a convenience for precompilation. 19053 var argument = settings.variable || 'obj'; 19054 template.source = 'function(' + argument + '){\n' + source + '}'; 19055 19056 return template; 19057 }; 19058 19059 // Add a "chain" function. Start chaining a wrapped Underscore object. 19060 _.chain = function(obj) { 19061 var instance = _(obj); 19062 instance._chain = true; 19063 return instance; 19064 }; 19065 19066 // OOP 19067 // --------------- 19068 // If Underscore is called as a function, it returns a wrapped object that 19069 // can be used OO-style. This wrapper holds altered versions of all the 19070 // underscore functions. Wrapped objects may be chained. 19071 19072 // Helper function to continue chaining intermediate results. 19073 var result = function(instance, obj) { 19074 return instance._chain ? _(obj).chain() : obj; 19075 }; 19076 19077 // Add your own custom functions to the Underscore object. 19078 _.mixin = function(obj) { 19079 _.each(_.functions(obj), function(name) { 19080 var func = _[name] = obj[name]; 19081 _.prototype[name] = function() { 19082 var args = [this._wrapped]; 19083 push.apply(args, arguments); 19084 return result(this, func.apply(_, args)); 19085 }; 19086 }); 19087 }; 19088 19089 // Add all of the Underscore functions to the wrapper object. 19090 _.mixin(_); 19091 19092 // Add all mutator Array functions to the wrapper. 19093 _.each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { 19094 var method = ArrayProto[name]; 19095 _.prototype[name] = function() { 19096 var obj = this._wrapped; 19097 method.apply(obj, arguments); 19098 if ((name === 'shift' || name === 'splice') && obj.length === 0) delete obj[0]; 19099 return result(this, obj); 19100 }; 19101 }); 19102 19103 // Add all accessor Array functions to the wrapper. 19104 _.each(['concat', 'join', 'slice'], function(name) { 19105 var method = ArrayProto[name]; 19106 _.prototype[name] = function() { 19107 return result(this, method.apply(this._wrapped, arguments)); 19108 }; 19109 }); 19110 19111 // Extracts the result from a wrapped and chained object. 19112 _.prototype.value = function() { 19113 return this._wrapped; 19114 }; 19115 19116 // Provide unwrapping proxy for some methods used in engine operations 19117 // such as arithmetic and JSON stringification. 19118 _.prototype.valueOf = _.prototype.toJSON = _.prototype.value; 19119 19120 _.prototype.toString = function() { 19121 return '' + this._wrapped; 19122 }; 19123 19124 // AMD registration happens at the end for compatibility with AMD loaders 19125 // that may not enforce next-turn semantics on modules. Even though general 19126 // practice for AMD registration is to be anonymous, underscore registers 19127 // as a named module because, like jQuery, it is a base library that is 19128 // popular enough to be bundled in a third party lib, but not be part of 19129 // an AMD load request. Those cases could generate an error when an 19130 // anonymous define() is called outside of a loader request. 19131 if (true) { 19132 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() { 19133 return _; 19134 }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 19135 } 19136 }.call(this)); 19137 19138 19139 /***/ }, 19140 /* 115 */ 19141 /***/ function(module, exports) { 19142 19143 'use strict';(function(){var c,a={Chrome:52,Firefox:48,Edge:38,Safari:10},b=navigator.userAgent,d=b.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];if(/trident/i.test(d[1]))return c=/\brv[ :]+(\d+)/g.exec(b)||[],'IE '+(c[1]||'');if('Chrome'===d[1]&&(c=b.match(/\b(OPR|Edge)\/(\d+)/),null!==c))return c.slice(1).join(' ').replace('OPR','Opera');if(d=d[2]?[d[1],d[2]]:[navigator.appName,navigator.appVersion,'-?'],null!==(c=b.match(/version\/(\d+)/i))&&d.splice(1,1,c[1]),!a.hasOwnProperty(d[0])||a[d[0]]>+d[1]){var e=document.createElement('div');e.className='browser-info',e.innerHTML='<div class="alert alert-warning fade in out" role="alert" style="text-align: center;"><a data-gohan="close" class="close" data-dismiss="alert" aria-label="close">×</a><strong>You\'re using an unsupported or outdated browser: </strong><span style="display: inline-block;">Please refer to the list of supported browsers <a href="https://github.com/cloudwan/gohan_webui" target="_blank">here</a></span></div>',document.body.appendChild(e)}})(); 19144 19145 /***/ }, 19146 /* 116 */ 19147 /***/ function(module, exports, __webpack_require__) { 19148 19149 /* WEBPACK VAR INJECTION */(function($) {'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _backbone=__webpack_require__(113),_userModel=__webpack_require__(117),_userModel2=_interopRequireDefault(_userModel),_schemaCollection=__webpack_require__(118),_schemaCollection2=_interopRequireDefault(_schemaCollection),_sidebarView=__webpack_require__(156),_sidebarView2=_interopRequireDefault(_sidebarView),_headerView=__webpack_require__(158),_headerView2=_interopRequireDefault(_headerView),_tableView=__webpack_require__(160),_tableView2=_interopRequireDefault(_tableView),_detailView=__webpack_require__(182),_detailView2=_interopRequireDefault(_detailView),_loginView=__webpack_require__(184),_loginView2=_interopRequireDefault(_loginView),_topView=__webpack_require__(186),_topView2=_interopRequireDefault(_topView),_errorView=__webpack_require__(162),_errorView2=_interopRequireDefault(_errorView),_breadCrumbView=__webpack_require__(188),_breadCrumbView2=_interopRequireDefault(_breadCrumbView),_app=__webpack_require__(190),_app2=_interopRequireDefault(_app);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}/* global window, document, $ */class AppView extends _backbone.View{get className(){return'appview'}constructor(a){super(a),this.template=a.template||_app2.default,this.router=a.router,this.config=a.config,this.viewClass=Object.assign({table:_tableView2.default,detail:_detailView2.default,topView:_topView2.default},a.viewClass),this.menuCollection=new _backbone.Collection,this.userModel=a.userModel||new _userModel2.default({config:this.config,url:this.config.get('authUrl')}),this.schemas=a.schemas||new _schemaCollection2.default({baseUrl:this.config.get('gohan').url,userModel:this.userModel,url:this.config.get('gohan').url+this.config.get('gohan').schema,additionalForms:this.config.get('additionalForms'),pageLimit:this.config.get('pageLimit'),addingRelationDialog:this.config.get('addingRelationDialog')}),this.view=null;const b=this.config.get('extendTokenTime')||3e5,c=()=>{const e=`The token will expire in less than ${(b/6e4).toFixed()} minutes.`+' Enter your password for extends token.';this.errorView.render({status:1,readyState:1,statusText:`<p class="extend-token-message">${e}</p>`+'<p id="extend-token-error" class="extend-token-error" /><form accept-charset="UTF-8" method="" action="" role="form" class="form-inline"><input class="form-control extend-token" placeholder="Password" name="password" id="password" type="password" value=""/><input class="btn btn-primary extend-token-btn" data-gohan="extend" type="submit" value="Extend"></form>'}),$('[data-gohan="extend"]',this.errorView.el).on('click',f=>{f.currentTarget.disabled=!0,this.userModel.extendToken(document.getElementById('password').value).then(()=>this.errorView.close()).catch(()=>{f.currentTarget.disabled=!1,document.getElementById('extend-token-error').innerText='Error: Wrong password!'})})},d=()=>{let e;e=this.config.get('errorMessages')&&this.config.get('errorMessages').tokenExpire?this.config.get('errorMessages').tokenExpire:'The token is expired. Please re-login. ',this.errorView.render({status:1,readyState:1,statusText:e+' <a href="#" data-gohan="logout" class="alert-link">Logout</a>'}),this.userModel.unsetAuthData(),$('[data-gohan="logout"]',this.errorView.el).on('click',f=>{f.preventDefault(),window.location.reload()})};this.userModel.authToken()?(this.listenTo(this.userModel,'change:authData',()=>{clearTimeout(this.extendPopupTimeoutId),clearTimeout(this.expirePopupTimeoutId),this.extendPopupTimeoutId=setTimeout(c,this.userModel.expiresTokenDate()-new Date-b),this.expirePopupTimeoutId=setTimeout(d,this.userModel.expiresTokenDate()-new Date)}),this.extendPopupTimeoutId=setTimeout(c,this.userModel.expiresTokenDate()-new Date-b),this.expirePopupTimeoutId=setTimeout(d,this.userModel.expiresTokenDate()-new Date),this.schemas.fetch().then(()=>{this.buildUi()},e=>{this.errorView.render(...e)})):this.listenToOnce(this.userModel,'change:authData',()=>{this.extendPopupTimeoutId=setTimeout(c,this.userModel.expiresTokenDate()-new Date-b),this.expirePopupTimeoutId=setTimeout(d,this.userModel.expiresTokenDate()-new Date),this.listenTo(this.userModel,'change:authData',()=>{clearTimeout(this.extendPopupTimeoutId),clearTimeout(this.expirePopupTimeoutId),this.extendPopupTimeoutId=setTimeout(c,this.userModel.expiresTokenDate()-new Date-b),this.expirePopupTimeoutId=setTimeout(d,this.userModel.expiresTokenDate()-new Date)}),this.$('#main_body').empty(),this.schemas.fetch().then(()=>{this.buildUi()}),this.render()}),this.SidebarClass=a.SidebarClass||_sidebarView2.default,this.HeaderClass=a.HeaderClass||_headerView2.default,this.BreadCrumbClass=a.BreadCrumbClass||_breadCrumbView2.default,this.LoginClass=a.LoginClass||_loginView2.default,this.ErrorClass=a.ErrorClass||_errorView2.default,this.ErrorClass=a.ErrorClass||_errorView2.default,this.errorView=new this.ErrorClass,$('[data-gohan="error"]').append(this.errorView.el),this.breadCrumb=new this.BreadCrumbClass,this.sidebarView=new this.SidebarClass({collection:this.menuCollection,config:this.config.toJSON(),app:this}),this.headerView=new this.HeaderClass({collection:this.menuCollection,config:this.config.toJSON(),model:this.userModel,app:this}),$(document).on('click',function(e){$('[data-toggle="popover"],[data-original-title]').each(function(){$(this).is(e.target)||0!==$(this).has(e.target).length||0!==$('.popover').has(e.target).length||((($(this).popover('hide').data('bs.popover')||{}).inState||{}).click=!1)})})}closeActivePage(){this.view&&(this.view.close?this.view.close():this.view.remove())}buildUi(){const a=this.router.getQueryParams();this.schemas.each(b=>{const c=b.get('metadata'),d=a.type||'tenant';if(!(c&&void 0!==c.type&&c.type!==d)){const e=Object.assign({},this.viewClass,this.viewClass[b.id]),f=b.url().substr(1);b.hasParent()||void 0!==this.config.get('sidebar')||this.menuCollection.add({path:b.get('url'),title:b.get('title')}),this.router.route(f,'table_view',()=>{let g={};if(b.hasParent()){const h=b.apiEndpointBase()+'/'+_backbone.history.fragment;g=b.makeCollection(h)}else g=b.makeCollection();$('#alerts').empty(),this.closeActivePage(),this.view=new e.table({params:this.router.getQueryParams(),schema:b,collection:g,childview:b.hasParent(),fragment:_backbone.history.fragment,app:this}),this.$('#main_body').html(this.view.el)}),this.router.route(f+'/:id','detail_view',(...g)=>{const h=2<=g.length?g[g.length-2]:'',i=b.makeCollection(),j=i.get(h)||new i.model({id:h});$('#alerts').empty(),this.closeActivePage(),this.view=new e.detail({schema:b,collection:i,model:j,fragment:_backbone.history.fragment,app:this,polling:this.config.get('polling'),params:this.router.getQueryParams()}),this.$('#main_body').html(this.view.el)})}}),void 0!==this.config.get('sidebar')&&this.config.get('sidebar').forEach((b,c)=>{this.sidebarView.collection.add({path:b.path,title:b.title,cssClass:b.cssClass,order:c})}),this.config.get('routes').forEach(b=>{this.router.route(b.path,b.name,(...c)=>{const d=this.schemas.get(b.name);if(this.closeActivePage(),void 0===d)this.view=new this.viewClass[b.viewClass]({params:this.router.getQueryParams(),arguments:c,fragment:_backbone.history.fragment,app:this}),this.$('#main_body').append(this.view.el);else{const e=d.makeCollection();if(c){const f=2<=c.length?c[c.length-2]:'',g=e.get(f)||new e.model({id:f});this.view=new this.viewClass[b.viewClass]({arguments:c,fragment:_backbone.history.fragment,app:this,schema:d,model:g,params:this.router.getQueryParams(),collection:e}),this.$('#main_body').append(this.view.el)}else this.view=new this.viewClass[b.viewClass]({arguments:c,fragment:_backbone.history.fragment,app:this,schema:d,params:this.router.getQueryParams(),collection:e}),this.$('#main_body').append(this.view.el)}})}),_backbone.history.loadUrl(_backbone.history.fragment)}/** 19150 * Shows login page. 19151 */showLogin(){const a=new this.LoginClass({model:this.userModel});this.$el.html(a.render().el)}/** 19152 * Renders page content. 19153 * @override View.render 19154 * @returns {AppView} 19155 */render(){return this.userModel.authToken()?(this.$el.html(this.template()),this.$('#header').append(this.headerView.render().el),this.$('#sidebar').append(this.sidebarView.render().el),this.$('#bread-crumb').append(this.breadCrumb.render().el)):this.showLogin(),this}}exports.default=AppView; 19156 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71))) 19157 19158 /***/ }, 19159 /* 117 */ 19160 /***/ function(module, exports, __webpack_require__) { 19161 19162 'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _backbone=__webpack_require__(113),_backbone2=_interopRequireDefault(_backbone);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}/** 19163 * Class contains logic of user authority in application. 19164 * @class UserModel 19165 * @extends Model 19166 */class UserModel extends _backbone.Model{defaults(){return{authData:void 0}}/** 19167 * Constructs the object. 19168 * @constructor 19169 * @extends Model.constructor 19170 * @param {Object} options 19171 */constructor(a){super(a),this.url=a.url+'/tokens',this.tenantURL=a.url+'/tenants',this.config=a.config,window.addEventListener('storage',this.sessionStorageTransfer.bind(this),!1),sessionStorage.length||(localStorage.setItem('getSessionStorage','true'),setTimeout(()=>{localStorage.removeItem('getSessionStorage')},500))}sessionStorageTransfer(a){if(a.newValue)if('getSessionStorage'===a.key)localStorage.setItem('sessionStorage',JSON.stringify(sessionStorage)),setTimeout(()=>{localStorage.removeItem('sessionStorage'),localStorage.removeItem('getSessionStorage')},0);else if('sessionStorage'===a.key&&!sessionStorage.length){const b=JSON.parse(a.newValue);for(let c in b)sessionStorage.setItem(c,b[c]);b.unscopedToken&&this.set('authData',JSON.parse(b.unscopedToken))}else'clearSessionStorage'===a.key&&this.unsetAuthData()}/** 19172 * Calls setAuthData function. 19173 * @override Model.parse 19174 * @param {Object} data 19175 */parse(a){this.saveScopedToken(a)}/** 19176 * Syncs model data. 19177 * @extends Model.sync 19178 * @param {string} method 19179 * @param {Object} model 19180 * @param {Object} options 19181 */sync(a,b,c={}){c.headers={'Content-Type':'application/json'},super.sync(a,b,c)}/** 19182 * Login to the server 19183 * @param {string} username 19184 * @param {string} password 19185 * @returns {Promise} 19186 */login(a,b){return new Promise((c,d)=>{const e=this.tenants();return e?void c(e):void _backbone2.default.ajax({dataType:'json',url:this.url,data:JSON.stringify({auth:{passwordCredentials:{username:a,password:b}}}),method:'POST',timeout:this.config.get('loginRequestTimeout'),headers:{'Content-Type':'application/json'},success:f=>{this.saveUnscopedToken(f),this.fetchTenant(c,d)},error:(...f)=>{d(f)}})})}extendToken(a){return new Promise((b,c)=>{const d={auth:{tenantName:this.tenantName(),passwordCredentials:{username:this.userName(),password:a}}};_backbone2.default.ajax({dataType:'json',url:this.url,data:JSON.stringify(d),method:'POST',timeout:this.config.get('loginRequestTimeout'),headers:{'Content-Type':'application/json'},success:e=>{const f=this.getItem('scopedToken');f[this.tenantName()].access.token=e.access.token,this.saveScopedToken(f[this.tenantName()]),b()},error:(...e)=>{c(e)}})})}/** 19187 * Fetch tenants from server 19188 */fetchTenant(a,b){_backbone2.default.ajax({method:'GET',dataType:'json',url:this.tenantURL,headers:{'Content-Type':'application/json','X-Auth-Token':this.unscopedToken()},success:c=>{const d=c.tenants;this.saveTenants(d),a(d)},error:(...c)=>{b(c)}})}/** 19189 * Login to the server with tenant. 19190 * @param {String} tenant 19191 * @returns {Promise} 19192 */loginTenant(a){return new Promise((b,c)=>{const d={auth:{token:{id:this.unscopedToken()},tenantName:a}};this.saveTenant(a),this.save(d,{data:JSON.stringify(d),success:(...e)=>{b(e)},error:(...e)=>{c(e)}})})}/** 19193 * Save item to sessionStorage 19194 * @param {Object} data 19195 */setItem(a,b){sessionStorage.setItem(a,JSON.stringify(b))}/** 19196 * Get item to from sessionStorage 19197 * @param {Object} data 19198 */getItem(a){const b=sessionStorage.getItem(a);if(b)return JSON.parse(b)}/** 19199 * Save unscoped token 19200 * @param {Object} data 19201 */saveUnscopedToken(a){this.setItem('unscopedToken',a)}/** 19202 * Save tenants 19203 * @param {Object} data 19204 */saveTenants(a){this.setItem('tenants',a)}/** 19205 * Save tenant selection 19206 * @param {Object} data 19207 */saveTenant(a){this.setItem('tenant',a)}/** 19208 * Save scoped token 19209 * @param {Object} data 19210 */saveScopedToken(a){const b=this.tenantName();let c=this.getItem('scopedToken');c||(c={}),c[b]=a,this.setItem('scopedToken',c),this.set('authData',a)}/** 19211 * Reset auth data 19212 */unsetAuthData(){localStorage.setItem('clearSessionStorage','true'),setTimeout(()=>{localStorage.removeItem('clearSessionStorage')},0),sessionStorage.removeItem('scopedToken'),sessionStorage.removeItem('unscopedToken'),sessionStorage.removeItem('tenant'),sessionStorage.removeItem('tenants')}/** 19213 * Returns scoped token. 19214 * @returns {string} 19215 */authToken(){const a=this.tenantName(),b=this.getItem('scopedToken');if(b){const c=b[a];if(c)return c.access.token.id}}/** 19216 * Returns scoped token expires date. 19217 * @returns {Date} 19218 */expiresTokenDate(){const a=this.tenantName(),b=this.getItem('scopedToken');if(b){const c=b[a];if(c)return new Date(c.access.token.expires)}}/** 19219 * Returns unscoped token. 19220 * @returns {string} 19221 */unscopedToken(){const a=this.getItem('unscopedToken');if(a)return a.access.token.id}/** 19222 * Returns tenant name. 19223 * @returns {string} 19224 */tenantName(){return this.getItem('tenant')}/** 19225 * Returns tenants. 19226 * @returns {Object} 19227 */tenants(){return this.getItem('tenants')}/** 19228 * Returns user name. 19229 * @returns {string} 19230 */userName(){const a=this.tenantName(),b=this.getItem('scopedToken');if(b){const c=b[a];if(c)return c.access.user.name}}}exports.default=UserModel;/* global window, sessionStorage, localStorage */ 19231 19232 /***/ }, 19233 /* 118 */ 19234 /***/ function(module, exports, __webpack_require__) { 19235 19236 'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _backbone=__webpack_require__(113),_schemaModel=__webpack_require__(119),_schemaModel2=_interopRequireDefault(_schemaModel);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}/** 19237 * Class contains logic of router in application. 19238 * @class AppRouter 19239 * @extends Router 19240 */class SchemaCollection extends _backbone.Collection{/** 19241 * Constructs the object. 19242 * @constructor 19243 * @override Collection.constructor 19244 * @param options 19245 */constructor(a){super(a),this.model=_schemaModel2.default,this.baseUrl=a.baseUrl,this.url=a.url,this.userModel=a.userModel,this.additionalForms=a.additionalForms,this.addingRelationDialog=a.addingRelationDialog,this.pageLimit=a.pageLimit}/** 19246 * Parses data. 19247 * @override Collection.parse 19248 * @param {Object} resp 19249 * @returns {Object} 19250 */parse(a){return a.schemas}/** 19251 * Unsets auth data. 19252 */unsetAuthData(){this.userModel.unsetAuthData()}/** 19253 * Fetches data from server. 19254 * @extends Collection.fetch 19255 * @param {Object} [options] 19256 * @returns {Promise} 19257 */fetch(a){return new Promise((b,c)=>{super.fetch(Object.assign({success:(...d)=>{b(d)},error:(...d)=>{c(d)}},a))})}/** 19258 * Syncs model data. 19259 * @extends Collection.sync 19260 * @param {string} method 19261 * @param {Object} collection 19262 * @param {Object} options 19263 */sync(a,b,c={}){c.headers={'X-Auth-Token':this.userModel.authToken(),'Content-Type':'application/json'},super.sync(a,b,c)}}exports.default=SchemaCollection; 19264 19265 /***/ }, 19266 /* 119 */ 19267 /***/ function(module, exports, __webpack_require__) { 19268 19269 'use strict';Object.defineProperty(exports,'__esModule',{value:!0});__webpack_require__(120);var _jsYaml=__webpack_require__(121),_jsYaml2=_interopRequireDefault(_jsYaml),_backbone=__webpack_require__(113);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}/** 19270 * Class contains logic of schema model in application. 19271 * @class SchemaModel 19272 * @extends Model 19273 */class SchemaModel extends _backbone.Model{collections(){return[]}/** 19274 * Returns API endpoint. 19275 * @returns {string} 19276 */apiEndpoint(){return this.apiEndpointBase()+this.get('url')}/** 19277 * Returns base API endpoint. 19278 * @returns {string} 19279 */apiEndpointBase(){return this.collection.baseUrl}/** 19280 * Returns detail path. 19281 * @returns {string} 19282 */detailPath(a){return this.get('prefix')+'/'+a}/** 19283 * Returns full url. 19284 * @returns {string} 19285 */url(){if(!this.hasParent())return this.get('url');const a=this.parent();return a.url()+'/:'+a.get('singular')+'/'+this.get('plural')}/** 19286 * Returns schema parent. 19287 * @returns {Model} 19288 */parent(){return this.collection.get(this.get('parent'))}/** 19289 * Returns parent property. 19290 * @returns {string} 19291 */parentProperty(){return this.get('parent')+'_id'}/** 19292 * Returns true if schema has parent otherwise false. 19293 * @returns {boolean} 19294 */hasParent(){return void 0!==this.get('parent')&&''!==this.get('parent')}/** 19295 * Returns new model class. 19296 * @param baseUrl 19297 * @returns {any} 19298 */makeModel(a=this.apiEndpoint()){const b=this,c=this.collection.userModel;return class extends _backbone.Model{/** 19299 * Constructs the object. 19300 * @constructor 19301 * @extends Model.constructor 19302 * @param {Object} options 19303 */constructor(f){super(f),this.schema=b,this.baseUrl=a,this.url=this.baseUrl,this.longPolling=!1,this.timeOutId=-1,this.intervalSeconds=10,this.isSelected=!1,this.isDeleting=!1}/** 19304 * Returns state of isNew, true when model is new otherwise false. 19305 * @returns {boolean} 19306 */isNew(){return!!this.get('isNew')}/** 19307 * Destroys object. 19308 * @extend Model.destroy 19309 * @param {Object} options 19310 * @returns {Promise} 19311 */destroy(f={}){return new Promise((g,h)=>{super.destroy(Object.assign({success:(...i)=>{g(i)},error:(...i)=>{h(i)}},f))})}/** 19312 * Saves model data. 19313 * @extend Model.save 19314 * @param {Model} model 19315 * @param {Object} options 19316 * @returns {Promise} 19317 */save(f,g={}){return new Promise((h,i)=>{super.save(f,Object.assign({success:(...j)=>{h(j)},error:(...j)=>{i(j)}},g))})}/** 19318 * Fetches data from server 19319 * @extend Model.fetch 19320 * @param {Object} options 19321 * @returns {Promise} 19322 */fetch(f={}){return new Promise((g,h)=>{super.fetch(Object.assign({success:(...i)=>{g(i)},error:(...i)=>{h(i)}},f))})}/** 19323 * Parses data from the server. 19324 * @override Model.parse 19325 * @param {Object} resp 19326 * @returns {Object} 19327 */parse(f){return void 0===f.id?f[b.get('singular')]:f}/** 19328 * Syncs model data. 19329 * @extends Model.sync 19330 * @param method 19331 * @param model 19332 * @param options 19333 */sync(f,g,h={}){this.isNew()||(this.url=this.baseUrl+'/'+this.id),'patch'===f&&(f='update'),h.headers={'X-Auth-Token':c.authToken(),'Content-Type':'application/json'},this.unset('isNew');const i={},j=g.clone(),k={};return'read'===f.toLowerCase()?void super.sync(f,g,h):void this.schema.filterByAction(f).then(l=>{for(let m in l.properties)k[m]=j.get(m);i[this.schema.get('singular')]=k,h.data=JSON.stringify(i),super.sync(f,g,h)})}/** 19334 * Starts long polling. 19335 * @param {number} intervalSeconds 19336 */startLongPolling(f){this.longPolling=!0,f&&(this.intervalSeconds=f),this.executeLongPolling()}/** 19337 * Stops long polling. 19338 */stopLongPolling(){this.longPolling=!1,clearTimeout(this.timeOutId),this.timeOutId=-1}/** 19339 * Fetches data from server. 19340 */executeLongPolling(){this.fetch().then(()=>{this.longPolling&&(this.timeOutId=setTimeout(this.executeLongPolling.bind(this),1e3*this.intervalSeconds))})}/** 19341 * Returns parent id of model. 19342 * @returns {string | undefined} 19343 */parentId(){return this.schema.hasParent()?this.get(this.schema.parentProperty()):void 0}/** 19344 * Returns path fragment. 19345 * @returns {string} 19346 */fragment(){return this.schema.detailPath(this.id).substr(1)}/** 19347 * Returns ancestors. 19348 * @param {function} callback 19349 * @param {Array} ancestors 19350 */getAncestors(f,g=[]){if(!this.schema.hasParent())return void f(g);if(void 0!==this.parentId()){const h=this.schema.parent().makeModel(),i=new h({id:this.parentId()});i.fetch().then(()=>{g.push(i),i.getAncestors(f,g)})}}}}/** 19351 * Returns new collection of models. 19352 * @param {string} url 19353 * @param {object} options 19354 * @param {*} options.pageLimit 19355 * @param {string} options.sortKey 19356 * @param {string} options.sortOrder 19357 * @param {object} options.filters 19358 * @returns {CollectionClass} 19359 */makeCollection(a=this.apiEndpoint(),b={pageLimit:this.collection.pageLimit}){let c;if('object'!=typeof b&&(console.warn('2nd argument of makeCollection should be options object.'),b=Object.assign({},{pageLimit:b})),b.filters){let l='';for(let m in b.filters)b.filters.hasOwnProperty(m)&&(l+=''==l?'?':'&',l+=m+'='+b.filters[m]);c=a+l}else c=a;if(/\?/.test(a)){let l=a.match(/(\?.*)$/g)[0].slice(1),m=l.split('&');b.filters=Object.assign({},b.filters);for(let n of m){let o=n.split('=');o[0]&&o[1]&&(b.filters[o[0]]=o[1])}a=a.match(/^(.*?)\?/g)[0].replace('?','')}if(this.collections[c])return this.collections[c].filters=b.filters||{},this.collections[c]._pageLimit=b.pageLimit,this.collections[c].sortKey=b.sortKey||'id',this.collections[c].sortOrder=b.sortOrder||'asc',this.collections[c];const e=this.makeModel(a),f=this.collection.userModel,g=this.collection.additionalForms,h=this.collection.addingRelationDialog,i=this;this.additionalForm=void 0!==g&&void 0===g[this.id]?g[i.id]:['*'],h&&(this.addingRelationDialog=h);class j extends _backbone.Collection{/** 19360 * Constructs the object. 19361 * @constructor 19362 * @extends Collection.constructor 19363 * @param {Object} options 19364 */constructor(l={}){super(l),this._pageLimit=~~l.pageLimit,this.total=0,this.offset=0,this.sortKey=l.sortKey||'id',this.sortOrder=l.sortOrder||'asc',this.baseUrl=a,this.url=a,this.model=e,this.schema=i,this.filters=l.filters||{},this.longPolling=!1,this.timeOutId=-1,this.intervalSeconds=10}get pageLimit(){return this._pageLimit}set pageLimit(l){this._pageLimit=l}/** 19365 * Updates collection url to filter, sort and paging. 19366 */updateUrl(){void 0===this.sortKey||Object.keys(this.schema.get('schema').properties).includes(this.sortKey)||(console.warn('sortKey is invalid, as sortKey will be set "id" key.'),this.sortKey='id'),void 0===this.sortOrder||'asc'===this.sortOrder||'desc'===this.sortOrder||(console.warn('sortOrder should be asc or desc, as sortOrder will be set "asc".'),this.sortOrder='asc');let l='',m='',n='?';for(let o in this.filters)this.filters.hasOwnProperty(o)&&(l+='&'+o+'='+this.filters[o]);0!==this.pageLimit&&(m='&limit='+this.pageLimit+'&offset='+this.offset),this.baseUrl.includes('?')&&(n='&'),this.url=this.baseUrl+n+'sort_key='+this.sortKey+'&sort_order='+this.sortOrder+m+l}/** 19367 * Sorts by specified key and specified order (asc or desc). 19368 * @param {string} key 19369 * @param {string} order 19370 * @returns {Promise} 19371 */sort(l='id',m='asc'){return new Promise((n,o)=>{this.sortKey=l,this.sortOrder=m,this.fetch().then(n,o)})}resetFilters(){this.filters={}}filterByQuery(l,m){return new Promise((n,o)=>{void 0===l?this.filters={}:void 0===m?delete this.filters[l]:this.filters[l]=m,this.offset=0,this.fetch().then(n,o)})}/** 19372 * Returns count of pages. 19373 * @returns {number} 19374 */getPageCount(){return 0===this.pageLimit?this.pageLimit:Math.ceil(this.total/this.pageLimit)}/** 19375 * Updates collection data to data from specified page. 19376 * @param {number} pageNo 19377 * @returns {Promise} 19378 */getPage(l=0){return new Promise((m,n)=>{const o=this.pageLimit*l;return 0!==this.total&&(o>this.total||0>o)?void n('Wrong page number!'):void(this.offset=o,this.fetch().then(m,n))})}/** 19379 * Updated collection data to next page. 19380 * @returns {Promise} 19381 */getNextPage(){return new Promise((l,m)=>{const n=this.offset+this.pageLimit;return n>=this.total?void m('This was last page!'):void(this.offset=n,this.fetch().then(l,m))})}/** 19382 * Updated collection data to prev page. 19383 * @returns {Promise} 19384 */getPrevPage(){return new Promise((l,m)=>{const n=this.offset-this.pageLimit;return 0>n?void m('This was first page!'):void(this.offset=n,this.fetch().then(l,m))})}/** 19385 * Fetches data from server. 19386 * @extend Collection.fetch 19387 * @param {Object} options 19388 * @returns {Promise} 19389 */fetch(l){return this.updateUrl(),new Promise((m,n)=>{super.fetch(Object.assign({success:(...o)=>{m(o)},error:(...o)=>{n(o)}},l))})}/** 19390 * Removes data from server. 19391 * @extend Collection.remove 19392 * @param {Model} model 19393 * @param {Object} options 19394 * @returns {Promise} 19395 */remove(l,m){return new Promise((n,o)=>{super.remove(l,Object.assign({success:(...p)=>{n(p)},error:(...p)=>{o(p)}},m))})}/** 19396 * Creates data from server. 19397 * @extend Collection.create 19398 * @param {Model} model 19399 * @param {Object} options 19400 * @returns {Promise} 19401 */create(l,m){return new Promise((n,o)=>{super.create(l,Object.assign({success:(...p)=>{n(p)},error:(...p)=>{o(p)}},m))})}/** 19402 * Parses response from the server. 19403 * @override Collection.parse 19404 * @param {Object} resp 19405 * @param {Object} options 19406 * @returns {Object} 19407 */parse(l,m){return this.total=+m.xhr.getResponseHeader('X-Total-Count'),l[i.get('plural')]}/** 19408 * Loges out user. 19409 */unsetAuthData(){this.userModel.unsetAuthData()}/** 19410 * Starts long polling. 19411 * @param {number} intervalSeconds 19412 */startLongPolling(l){this.longPolling=!0,l&&(this.intervalSeconds=l),this.executeLongPolling()}/** 19413 * Stops long polling. 19414 */stopLongPolling(){this.longPolling=!1,clearTimeout(this.timeOutId),this.timeOutId=-1}/** 19415 * Fetches data from server. 19416 */executeLongPolling(){this.fetch().then(()=>{this.longPolling&&(this.timeOutId=setTimeout(this.executeLongPolling.bind(this),1e3*this.intervalSeconds))})}/** 19417 * Syncs model data. 19418 * @extends Collection.sync 19419 * @param {string} method 19420 * @param {Object} collection 19421 * @param {Object} options 19422 */sync(l,m,n={}){n.headers={'X-Auth-Token':f.authToken(),'Content-Type':'application/json'},super.sync(l,m,n)}}const k=new j(b);return this.collections[c]=k,k}toFormJSON(a){const b={};for(let c in a.properties)if(void 0===a.propertiesOrder||a.propertiesOrder.includes(c)){const e=a.properties[c];b[c]={title:e.title,type:'Text',help:e.description,validators:[]},e.relation&&(b[c].relation=e.relation),e.nullable&&(b[c].nullable=!0),'string'===e.type?void 0===e.enum?void 0!==e.format&&('yaml'===e.format||'javascript'===e.format)?(b[c].format=e.format,b[c].type='CodeEditor'):b[c].type='Text':(b[c].type='Select',b[c].options=[],b[c].options=void 0===e.options?e.enum:e.options):'integer'===e.type||'number'===e.type?b[c].type='Number':'array'===e.type?(b[c].type='List',b[c].default=this.defaultValue(e.items),'object'===e.items.type?(b[c].itemType='Object',b[c].order=e.items.propertiesOrder,b[c].subSchema=this.toFormJSON(e.items)):'boolean'===e.items.type?b[c].itemType='Checkbox':'number'===e.items.type||'integer'===e.items.type?b[c].itemType='Number':'string'===e.items.type&&(void 0===e.items.enum?void 0!==e.format&&('yaml'===e.format||'javascript'===e.format)?(b[c].format=e.format,b[c].itemType='CodeEditor'):b[c].itemType='Text':(b[c].itemType='Select',b[c].options=[],b[c].options=void 0===e.items.options?e.items.enum:e.items.options))):'object'===e.type?e.properties?(b[c].type='Object',b[c].subSchema=this.toFormJSON(e)):(b[c].type='CodeEditor',b[c].format=e.format):'boolean'===e.type&&(b[c].type='Checkbox'),void 0!==e.format&&b[c].validators.push(e.format),void 0!==a.required&&a.required.includes(c)&&(b[c].title+='<span class="form-asterisk">*</span>',b[c].validators.push('required'))}return b}/** 19423 * Returns local schema for popup with content. 19424 * @param {Object} schema 19425 * @returns {Promise} 19426 */toLocalSchema(a){// Convert dict in schema to array for form generation 19427 // In json schema, we can't type dict element, so gohan 19428 // extend json schema using items property for object. 19429 // If object type has items property, items is considered to 19430 // schema for object of dict. 19431 // We will transform schema here for jsonform lib. 19432 return new Promise((b,c)=>{const e=this;if(Array.isArray(a.type)&&(a.type.includes('null')&&(a.nullable=!0),a.type=a.type[0]),void 0!==a.relation){const g=[],h={},i={},j=[];i['X-Auth-Token']=this.collection.userModel.authToken();const k=this.collection.get(a.relation);return void fetch(k.apiEndpoint(),{headers:i}).then(l=>l.json()).then(l=>{for(let m in l)for(let n of l[m])g.push(n.id),h[n.id]=n.name,j.push(n);a.enum=g,a.options=h,a.properties=j,b(a)},l=>{c(l)})}const f=Object.assign({},a);if('array'===a.type){const g=this.toLocalSchema(f.items);return void g.then(h=>{f.items=h,b(f)})}if('object'!==a.type)return void b(a);if(void 0!==a.properties){const g=[];for(let h in a.properties)// workaround for Firefox 49 19433 (i=>{const j=e.toLocalSchema(a.properties[i]);g.push(j),j.then(function(l){f.properties[i]=l})})(h);Promise.all(g).then(()=>{b(f)},h=>{c(h)})}else void 0===a.items?(f.type=a.type,f.format='yaml',f.originalType='object',b(f)):(f.type='array',this.toLocalSchema(f.items).then(g=>{void 0===g.title&&(g.title='value'),f.items={type:'object',required:a.required,properties:{id:{title:'key',type:'string'},value:g}},b(f)},g=>{c(g)}))})}/** 19434 * Returns default values in schema. 19435 * @param {Object} schema 19436 * @returns {*} 19437 */defaultValue(a){if('object'===a.type){if(void 0===a.default&&void 0!==a.properties){const b={};for(let c in a.properties)b[c]=this.defaultValue(a.properties[c]);return b}}else if('array'===a.type){if(void 0!==a.items.properties){const b={};for(let c in a.items.properties)b[c]=this.defaultValue(a.items.properties[c]);return[b]}return}return a.default}/** 19438 * Format data to local. 19439 * @param {Object} data 19440 * @returns {Object} 19441 */toLocal(a){const b=this.get('schema'),c=this.defaultValue(b);return a=void 0===c?void 0:Object.assign({},c,a),this.toLocalData(b,a)}/** 19442 * Format data to local. 19443 * @param {Object} schema 19444 * @param {Object} data 19445 * @returns {Object} 19446 */toLocalData(a,b){if('object'!==a.type)return b;if(void 0!==b){if('jsonschema'===a.format)return _jsYaml2.default.safeDump(b);if(void 0===a.properties){if(void 0!==a.items){const c=[];if(void 0===a.items.propertiesOrder)for(let e in b)c.push({id:e,value:this.toLocalData(a.items,b[e])});else for(let e of a.items.propertiesOrder){const f=b[e];c.push({id:e,value:this.toLocalData(a.items,f)})}return c}return _jsYaml2.default.safeDump(b)}if(b)for(let c in a.properties)b[c]=this.toLocalData(a.properties[c],b[c]);return b}}/** 19447 * Format data to server format. 19448 * @param {Object} data 19449 * @returns {Object} 19450 */toServer(a){return this.toServerData(this.get('schema'),a)}/** 19451 * Format data to server format. 19452 * @param {Object} schema 19453 * @param {Object} data 19454 * @returns {Object} 19455 */toServerData(a,b){const c=this;if(a.nullable&&(null===b||''===b))return null;if(void 0!==b&&null!==b&&''!==b){if('array'===a.type)return b.map(e=>this.toServerData(a.items,e));if('object'!==a.type&&'object'!==a.originalType)return b;if(void 0!==a.properties){const e={};for(let f in a.properties)'id'!=f&&(e[f]=c.toServerData(a.properties[f],b[f]));return e}if(void 0!==a.items){const e={};for(let f of b)e[f.id]=c.toServerData(a.items,f.value);return e}return _jsYaml2.default.safeLoad(b)}}/** 19456 * Filters schema by action. 19457 * @param {string} action 19458 * @param {string} [parentProperty] 19459 * @returns {Promise} 19460 */filterByAction(a,b){return new Promise((c,e)=>{let f={};const g=this.toJSON();this.toLocalSchema(g.schema).then(h=>{for(let j in h.properties){const k=h.properties[j];if(('id'!=j||'uuid'!==k.format)&&j!==b&&null!==k.permission&&void 0!==k.permission){const l=k.view;l&&0>l.indexOf(a)||0<=k.permission.indexOf(a)&&(f[j]=k)}}let i=[];g.schema.required&&(i=g.schema.required.filter(j=>{return f.hasOwnProperty(j)})),f={type:'object',properties:f,propertiesOrder:g.schema.propertiesOrder,required:i},c(f)},h=>{e(h),console.error(h)})})}/** 19461 * Returns children of schema. 19462 * @returns {TModel[]} 19463 */children(){return this.collection.filter(a=>{return a.get('parent')===this.id})}}exports.default=SchemaModel;/* global fetch */ 19464 19465 /***/ }, 19466 /* 120 */ 19467 /***/ function(module, exports) { 19468 19469 (function(self) { 19470 'use strict'; 19471 19472 if (self.fetch) { 19473 return 19474 } 19475 19476 var support = { 19477 searchParams: 'URLSearchParams' in self, 19478 iterable: 'Symbol' in self && 'iterator' in Symbol, 19479 blob: 'FileReader' in self && 'Blob' in self && (function() { 19480 try { 19481 new Blob() 19482 return true 19483 } catch(e) { 19484 return false 19485 } 19486 })(), 19487 formData: 'FormData' in self, 19488 arrayBuffer: 'ArrayBuffer' in self 19489 } 19490 19491 if (support.arrayBuffer) { 19492 var viewClasses = [ 19493 '[object Int8Array]', 19494 '[object Uint8Array]', 19495 '[object Uint8ClampedArray]', 19496 '[object Int16Array]', 19497 '[object Uint16Array]', 19498 '[object Int32Array]', 19499 '[object Uint32Array]', 19500 '[object Float32Array]', 19501 '[object Float64Array]' 19502 ] 19503 19504 var isDataView = function(obj) { 19505 return obj && DataView.prototype.isPrototypeOf(obj) 19506 } 19507 19508 var isArrayBufferView = ArrayBuffer.isView || function(obj) { 19509 return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1 19510 } 19511 } 19512 19513 function normalizeName(name) { 19514 if (typeof name !== 'string') { 19515 name = String(name) 19516 } 19517 if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) { 19518 throw new TypeError('Invalid character in header field name') 19519 } 19520 return name.toLowerCase() 19521 } 19522 19523 function normalizeValue(value) { 19524 if (typeof value !== 'string') { 19525 value = String(value) 19526 } 19527 return value 19528 } 19529 19530 // Build a destructive iterator for the value list 19531 function iteratorFor(items) { 19532 var iterator = { 19533 next: function() { 19534 var value = items.shift() 19535 return {done: value === undefined, value: value} 19536 } 19537 } 19538 19539 if (support.iterable) { 19540 iterator[Symbol.iterator] = function() { 19541 return iterator 19542 } 19543 } 19544 19545 return iterator 19546 } 19547 19548 function Headers(headers) { 19549 this.map = {} 19550 19551 if (headers instanceof Headers) { 19552 headers.forEach(function(value, name) { 19553 this.append(name, value) 19554 }, this) 19555 19556 } else if (headers) { 19557 Object.getOwnPropertyNames(headers).forEach(function(name) { 19558 this.append(name, headers[name]) 19559 }, this) 19560 } 19561 } 19562 19563 Headers.prototype.append = function(name, value) { 19564 name = normalizeName(name) 19565 value = normalizeValue(value) 19566 var oldValue = this.map[name] 19567 this.map[name] = oldValue ? oldValue+','+value : value 19568 } 19569 19570 Headers.prototype['delete'] = function(name) { 19571 delete this.map[normalizeName(name)] 19572 } 19573 19574 Headers.prototype.get = function(name) { 19575 name = normalizeName(name) 19576 return this.has(name) ? this.map[name] : null 19577 } 19578 19579 Headers.prototype.has = function(name) { 19580 return this.map.hasOwnProperty(normalizeName(name)) 19581 } 19582 19583 Headers.prototype.set = function(name, value) { 19584 this.map[normalizeName(name)] = normalizeValue(value) 19585 } 19586 19587 Headers.prototype.forEach = function(callback, thisArg) { 19588 for (var name in this.map) { 19589 if (this.map.hasOwnProperty(name)) { 19590 callback.call(thisArg, this.map[name], name, this) 19591 } 19592 } 19593 } 19594 19595 Headers.prototype.keys = function() { 19596 var items = [] 19597 this.forEach(function(value, name) { items.push(name) }) 19598 return iteratorFor(items) 19599 } 19600 19601 Headers.prototype.values = function() { 19602 var items = [] 19603 this.forEach(function(value) { items.push(value) }) 19604 return iteratorFor(items) 19605 } 19606 19607 Headers.prototype.entries = function() { 19608 var items = [] 19609 this.forEach(function(value, name) { items.push([name, value]) }) 19610 return iteratorFor(items) 19611 } 19612 19613 if (support.iterable) { 19614 Headers.prototype[Symbol.iterator] = Headers.prototype.entries 19615 } 19616 19617 function consumed(body) { 19618 if (body.bodyUsed) { 19619 return Promise.reject(new TypeError('Already read')) 19620 } 19621 body.bodyUsed = true 19622 } 19623 19624 function fileReaderReady(reader) { 19625 return new Promise(function(resolve, reject) { 19626 reader.onload = function() { 19627 resolve(reader.result) 19628 } 19629 reader.onerror = function() { 19630 reject(reader.error) 19631 } 19632 }) 19633 } 19634 19635 function readBlobAsArrayBuffer(blob) { 19636 var reader = new FileReader() 19637 var promise = fileReaderReady(reader) 19638 reader.readAsArrayBuffer(blob) 19639 return promise 19640 } 19641 19642 function readBlobAsText(blob) { 19643 var reader = new FileReader() 19644 var promise = fileReaderReady(reader) 19645 reader.readAsText(blob) 19646 return promise 19647 } 19648 19649 function readArrayBufferAsText(buf) { 19650 var view = new Uint8Array(buf) 19651 var chars = new Array(view.length) 19652 19653 for (var i = 0; i < view.length; i++) { 19654 chars[i] = String.fromCharCode(view[i]) 19655 } 19656 return chars.join('') 19657 } 19658 19659 function bufferClone(buf) { 19660 if (buf.slice) { 19661 return buf.slice(0) 19662 } else { 19663 var view = new Uint8Array(buf.byteLength) 19664 view.set(new Uint8Array(buf)) 19665 return view.buffer 19666 } 19667 } 19668 19669 function Body() { 19670 this.bodyUsed = false 19671 19672 this._initBody = function(body) { 19673 this._bodyInit = body 19674 if (!body) { 19675 this._bodyText = '' 19676 } else if (typeof body === 'string') { 19677 this._bodyText = body 19678 } else if (support.blob && Blob.prototype.isPrototypeOf(body)) { 19679 this._bodyBlob = body 19680 } else if (support.formData && FormData.prototype.isPrototypeOf(body)) { 19681 this._bodyFormData = body 19682 } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { 19683 this._bodyText = body.toString() 19684 } else if (support.arrayBuffer && support.blob && isDataView(body)) { 19685 this._bodyArrayBuffer = bufferClone(body.buffer) 19686 // IE 10-11 can't handle a DataView body. 19687 this._bodyInit = new Blob([this._bodyArrayBuffer]) 19688 } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) { 19689 this._bodyArrayBuffer = bufferClone(body) 19690 } else { 19691 throw new Error('unsupported BodyInit type') 19692 } 19693 19694 if (!this.headers.get('content-type')) { 19695 if (typeof body === 'string') { 19696 this.headers.set('content-type', 'text/plain;charset=UTF-8') 19697 } else if (this._bodyBlob && this._bodyBlob.type) { 19698 this.headers.set('content-type', this._bodyBlob.type) 19699 } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { 19700 this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8') 19701 } 19702 } 19703 } 19704 19705 if (support.blob) { 19706 this.blob = function() { 19707 var rejected = consumed(this) 19708 if (rejected) { 19709 return rejected 19710 } 19711 19712 if (this._bodyBlob) { 19713 return Promise.resolve(this._bodyBlob) 19714 } else if (this._bodyArrayBuffer) { 19715 return Promise.resolve(new Blob([this._bodyArrayBuffer])) 19716 } else if (this._bodyFormData) { 19717 throw new Error('could not read FormData body as blob') 19718 } else { 19719 return Promise.resolve(new Blob([this._bodyText])) 19720 } 19721 } 19722 19723 this.arrayBuffer = function() { 19724 if (this._bodyArrayBuffer) { 19725 return consumed(this) || Promise.resolve(this._bodyArrayBuffer) 19726 } else { 19727 return this.blob().then(readBlobAsArrayBuffer) 19728 } 19729 } 19730 } 19731 19732 this.text = function() { 19733 var rejected = consumed(this) 19734 if (rejected) { 19735 return rejected 19736 } 19737 19738 if (this._bodyBlob) { 19739 return readBlobAsText(this._bodyBlob) 19740 } else if (this._bodyArrayBuffer) { 19741 return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer)) 19742 } else if (this._bodyFormData) { 19743 throw new Error('could not read FormData body as text') 19744 } else { 19745 return Promise.resolve(this._bodyText) 19746 } 19747 } 19748 19749 if (support.formData) { 19750 this.formData = function() { 19751 return this.text().then(decode) 19752 } 19753 } 19754 19755 this.json = function() { 19756 return this.text().then(JSON.parse) 19757 } 19758 19759 return this 19760 } 19761 19762 // HTTP methods whose capitalization should be normalized 19763 var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'] 19764 19765 function normalizeMethod(method) { 19766 var upcased = method.toUpperCase() 19767 return (methods.indexOf(upcased) > -1) ? upcased : method 19768 } 19769 19770 function Request(input, options) { 19771 options = options || {} 19772 var body = options.body 19773 19774 if (typeof input === 'string') { 19775 this.url = input 19776 } else { 19777 if (input.bodyUsed) { 19778 throw new TypeError('Already read') 19779 } 19780 this.url = input.url 19781 this.credentials = input.credentials 19782 if (!options.headers) { 19783 this.headers = new Headers(input.headers) 19784 } 19785 this.method = input.method 19786 this.mode = input.mode 19787 if (!body && input._bodyInit != null) { 19788 body = input._bodyInit 19789 input.bodyUsed = true 19790 } 19791 } 19792 19793 this.credentials = options.credentials || this.credentials || 'omit' 19794 if (options.headers || !this.headers) { 19795 this.headers = new Headers(options.headers) 19796 } 19797 this.method = normalizeMethod(options.method || this.method || 'GET') 19798 this.mode = options.mode || this.mode || null 19799 this.referrer = null 19800 19801 if ((this.method === 'GET' || this.method === 'HEAD') && body) { 19802 throw new TypeError('Body not allowed for GET or HEAD requests') 19803 } 19804 this._initBody(body) 19805 } 19806 19807 Request.prototype.clone = function() { 19808 return new Request(this, { body: this._bodyInit }) 19809 } 19810 19811 function decode(body) { 19812 var form = new FormData() 19813 body.trim().split('&').forEach(function(bytes) { 19814 if (bytes) { 19815 var split = bytes.split('=') 19816 var name = split.shift().replace(/\+/g, ' ') 19817 var value = split.join('=').replace(/\+/g, ' ') 19818 form.append(decodeURIComponent(name), decodeURIComponent(value)) 19819 } 19820 }) 19821 return form 19822 } 19823 19824 function parseHeaders(rawHeaders) { 19825 var headers = new Headers() 19826 rawHeaders.split('\r\n').forEach(function(line) { 19827 var parts = line.split(':') 19828 var key = parts.shift().trim() 19829 if (key) { 19830 var value = parts.join(':').trim() 19831 headers.append(key, value) 19832 } 19833 }) 19834 return headers 19835 } 19836 19837 Body.call(Request.prototype) 19838 19839 function Response(bodyInit, options) { 19840 if (!options) { 19841 options = {} 19842 } 19843 19844 this.type = 'default' 19845 this.status = 'status' in options ? options.status : 200 19846 this.ok = this.status >= 200 && this.status < 300 19847 this.statusText = 'statusText' in options ? options.statusText : 'OK' 19848 this.headers = new Headers(options.headers) 19849 this.url = options.url || '' 19850 this._initBody(bodyInit) 19851 } 19852 19853 Body.call(Response.prototype) 19854 19855 Response.prototype.clone = function() { 19856 return new Response(this._bodyInit, { 19857 status: this.status, 19858 statusText: this.statusText, 19859 headers: new Headers(this.headers), 19860 url: this.url 19861 }) 19862 } 19863 19864 Response.error = function() { 19865 var response = new Response(null, {status: 0, statusText: ''}) 19866 response.type = 'error' 19867 return response 19868 } 19869 19870 var redirectStatuses = [301, 302, 303, 307, 308] 19871 19872 Response.redirect = function(url, status) { 19873 if (redirectStatuses.indexOf(status) === -1) { 19874 throw new RangeError('Invalid status code') 19875 } 19876 19877 return new Response(null, {status: status, headers: {location: url}}) 19878 } 19879 19880 self.Headers = Headers 19881 self.Request = Request 19882 self.Response = Response 19883 19884 self.fetch = function(input, init) { 19885 return new Promise(function(resolve, reject) { 19886 var request = new Request(input, init) 19887 var xhr = new XMLHttpRequest() 19888 19889 xhr.onload = function() { 19890 var options = { 19891 status: xhr.status, 19892 statusText: xhr.statusText, 19893 headers: parseHeaders(xhr.getAllResponseHeaders() || '') 19894 } 19895 options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL') 19896 var body = 'response' in xhr ? xhr.response : xhr.responseText 19897 resolve(new Response(body, options)) 19898 } 19899 19900 xhr.onerror = function() { 19901 reject(new TypeError('Network request failed')) 19902 } 19903 19904 xhr.ontimeout = function() { 19905 reject(new TypeError('Network request failed')) 19906 } 19907 19908 xhr.open(request.method, request.url, true) 19909 19910 if (request.credentials === 'include') { 19911 xhr.withCredentials = true 19912 } 19913 19914 if ('responseType' in xhr && support.blob) { 19915 xhr.responseType = 'blob' 19916 } 19917 19918 request.headers.forEach(function(value, name) { 19919 xhr.setRequestHeader(name, value) 19920 }) 19921 19922 xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit) 19923 }) 19924 } 19925 self.fetch.polyfill = true 19926 })(typeof self !== 'undefined' ? self : this); 19927 19928 19929 /***/ }, 19930 /* 121 */ 19931 /***/ function(module, exports, __webpack_require__) { 19932 19933 'use strict'; 19934 19935 19936 var yaml = __webpack_require__(122); 19937 19938 19939 module.exports = yaml; 19940 19941 19942 /***/ }, 19943 /* 122 */ 19944 /***/ function(module, exports, __webpack_require__) { 19945 19946 'use strict'; 19947 19948 19949 var loader = __webpack_require__(123); 19950 var dumper = __webpack_require__(155); 19951 19952 19953 function deprecated(name) { 19954 return function () { 19955 throw new Error('Function ' + name + ' is deprecated and cannot be used.'); 19956 }; 19957 } 19958 19959 19960 module.exports.Type = __webpack_require__(129); 19961 module.exports.Schema = __webpack_require__(128); 19962 module.exports.FAILSAFE_SCHEMA = __webpack_require__(132); 19963 module.exports.JSON_SCHEMA = __webpack_require__(131); 19964 module.exports.CORE_SCHEMA = __webpack_require__(130); 19965 module.exports.DEFAULT_SAFE_SCHEMA = __webpack_require__(127); 19966 module.exports.DEFAULT_FULL_SCHEMA = __webpack_require__(150); 19967 module.exports.load = loader.load; 19968 module.exports.loadAll = loader.loadAll; 19969 module.exports.safeLoad = loader.safeLoad; 19970 module.exports.safeLoadAll = loader.safeLoadAll; 19971 module.exports.dump = dumper.dump; 19972 module.exports.safeDump = dumper.safeDump; 19973 module.exports.YAMLException = __webpack_require__(125); 19974 19975 // Deprecated schema names from JS-YAML 2.0.x 19976 module.exports.MINIMAL_SCHEMA = __webpack_require__(132); 19977 module.exports.SAFE_SCHEMA = __webpack_require__(127); 19978 module.exports.DEFAULT_SCHEMA = __webpack_require__(150); 19979 19980 // Deprecated functions from JS-YAML 1.x.x 19981 module.exports.scan = deprecated('scan'); 19982 module.exports.parse = deprecated('parse'); 19983 module.exports.compose = deprecated('compose'); 19984 module.exports.addConstructor = deprecated('addConstructor'); 19985 19986 19987 /***/ }, 19988 /* 123 */ 19989 /***/ function(module, exports, __webpack_require__) { 19990 19991 'use strict'; 19992 19993 /*eslint-disable max-len,no-use-before-define*/ 19994 19995 var common = __webpack_require__(124); 19996 var YAMLException = __webpack_require__(125); 19997 var Mark = __webpack_require__(126); 19998 var DEFAULT_SAFE_SCHEMA = __webpack_require__(127); 19999 var DEFAULT_FULL_SCHEMA = __webpack_require__(150); 20000 20001 20002 var _hasOwnProperty = Object.prototype.hasOwnProperty; 20003 20004 20005 var CONTEXT_FLOW_IN = 1; 20006 var CONTEXT_FLOW_OUT = 2; 20007 var CONTEXT_BLOCK_IN = 3; 20008 var CONTEXT_BLOCK_OUT = 4; 20009 20010 20011 var CHOMPING_CLIP = 1; 20012 var CHOMPING_STRIP = 2; 20013 var CHOMPING_KEEP = 3; 20014 20015 20016 var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; 20017 var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; 20018 var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; 20019 var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; 20020 var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; 20021 20022 20023 function is_EOL(c) { 20024 return (c === 0x0A/* LF */) || (c === 0x0D/* CR */); 20025 } 20026 20027 function is_WHITE_SPACE(c) { 20028 return (c === 0x09/* Tab */) || (c === 0x20/* Space */); 20029 } 20030 20031 function is_WS_OR_EOL(c) { 20032 return (c === 0x09/* Tab */) || 20033 (c === 0x20/* Space */) || 20034 (c === 0x0A/* LF */) || 20035 (c === 0x0D/* CR */); 20036 } 20037 20038 function is_FLOW_INDICATOR(c) { 20039 return c === 0x2C/* , */ || 20040 c === 0x5B/* [ */ || 20041 c === 0x5D/* ] */ || 20042 c === 0x7B/* { */ || 20043 c === 0x7D/* } */; 20044 } 20045 20046 function fromHexCode(c) { 20047 var lc; 20048 20049 if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { 20050 return c - 0x30; 20051 } 20052 20053 /*eslint-disable no-bitwise*/ 20054 lc = c | 0x20; 20055 20056 if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) { 20057 return lc - 0x61 + 10; 20058 } 20059 20060 return -1; 20061 } 20062 20063 function escapedHexLen(c) { 20064 if (c === 0x78/* x */) { return 2; } 20065 if (c === 0x75/* u */) { return 4; } 20066 if (c === 0x55/* U */) { return 8; } 20067 return 0; 20068 } 20069 20070 function fromDecimalCode(c) { 20071 if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { 20072 return c - 0x30; 20073 } 20074 20075 return -1; 20076 } 20077 20078 function simpleEscapeSequence(c) { 20079 return (c === 0x30/* 0 */) ? '\x00' : 20080 (c === 0x61/* a */) ? '\x07' : 20081 (c === 0x62/* b */) ? '\x08' : 20082 (c === 0x74/* t */) ? '\x09' : 20083 (c === 0x09/* Tab */) ? '\x09' : 20084 (c === 0x6E/* n */) ? '\x0A' : 20085 (c === 0x76/* v */) ? '\x0B' : 20086 (c === 0x66/* f */) ? '\x0C' : 20087 (c === 0x72/* r */) ? '\x0D' : 20088 (c === 0x65/* e */) ? '\x1B' : 20089 (c === 0x20/* Space */) ? ' ' : 20090 (c === 0x22/* " */) ? '\x22' : 20091 (c === 0x2F/* / */) ? '/' : 20092 (c === 0x5C/* \ */) ? '\x5C' : 20093 (c === 0x4E/* N */) ? '\x85' : 20094 (c === 0x5F/* _ */) ? '\xA0' : 20095 (c === 0x4C/* L */) ? '\u2028' : 20096 (c === 0x50/* P */) ? '\u2029' : ''; 20097 } 20098 20099 function charFromCodepoint(c) { 20100 if (c <= 0xFFFF) { 20101 return String.fromCharCode(c); 20102 } 20103 // Encode UTF-16 surrogate pair 20104 // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF 20105 return String.fromCharCode(((c - 0x010000) >> 10) + 0xD800, 20106 ((c - 0x010000) & 0x03FF) + 0xDC00); 20107 } 20108 20109 var simpleEscapeCheck = new Array(256); // integer, for fast access 20110 var simpleEscapeMap = new Array(256); 20111 for (var i = 0; i < 256; i++) { 20112 simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0; 20113 simpleEscapeMap[i] = simpleEscapeSequence(i); 20114 } 20115 20116 20117 function State(input, options) { 20118 this.input = input; 20119 20120 this.filename = options['filename'] || null; 20121 this.schema = options['schema'] || DEFAULT_FULL_SCHEMA; 20122 this.onWarning = options['onWarning'] || null; 20123 this.legacy = options['legacy'] || false; 20124 this.json = options['json'] || false; 20125 this.listener = options['listener'] || null; 20126 20127 this.implicitTypes = this.schema.compiledImplicit; 20128 this.typeMap = this.schema.compiledTypeMap; 20129 20130 this.length = input.length; 20131 this.position = 0; 20132 this.line = 0; 20133 this.lineStart = 0; 20134 this.lineIndent = 0; 20135 20136 this.documents = []; 20137 20138 /* 20139 this.version; 20140 this.checkLineBreaks; 20141 this.tagMap; 20142 this.anchorMap; 20143 this.tag; 20144 this.anchor; 20145 this.kind; 20146 this.result;*/ 20147 20148 } 20149 20150 20151 function generateError(state, message) { 20152 return new YAMLException( 20153 message, 20154 new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart))); 20155 } 20156 20157 function throwError(state, message) { 20158 throw generateError(state, message); 20159 } 20160 20161 function throwWarning(state, message) { 20162 if (state.onWarning) { 20163 state.onWarning.call(null, generateError(state, message)); 20164 } 20165 } 20166 20167 20168 var directiveHandlers = { 20169 20170 YAML: function handleYamlDirective(state, name, args) { 20171 20172 var match, major, minor; 20173 20174 if (state.version !== null) { 20175 throwError(state, 'duplication of %YAML directive'); 20176 } 20177 20178 if (args.length !== 1) { 20179 throwError(state, 'YAML directive accepts exactly one argument'); 20180 } 20181 20182 match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); 20183 20184 if (match === null) { 20185 throwError(state, 'ill-formed argument of the YAML directive'); 20186 } 20187 20188 major = parseInt(match[1], 10); 20189 minor = parseInt(match[2], 10); 20190 20191 if (major !== 1) { 20192 throwError(state, 'unacceptable YAML version of the document'); 20193 } 20194 20195 state.version = args[0]; 20196 state.checkLineBreaks = (minor < 2); 20197 20198 if (minor !== 1 && minor !== 2) { 20199 throwWarning(state, 'unsupported YAML version of the document'); 20200 } 20201 }, 20202 20203 TAG: function handleTagDirective(state, name, args) { 20204 20205 var handle, prefix; 20206 20207 if (args.length !== 2) { 20208 throwError(state, 'TAG directive accepts exactly two arguments'); 20209 } 20210 20211 handle = args[0]; 20212 prefix = args[1]; 20213 20214 if (!PATTERN_TAG_HANDLE.test(handle)) { 20215 throwError(state, 'ill-formed tag handle (first argument) of the TAG directive'); 20216 } 20217 20218 if (_hasOwnProperty.call(state.tagMap, handle)) { 20219 throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle'); 20220 } 20221 20222 if (!PATTERN_TAG_URI.test(prefix)) { 20223 throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive'); 20224 } 20225 20226 state.tagMap[handle] = prefix; 20227 } 20228 }; 20229 20230 20231 function captureSegment(state, start, end, checkJson) { 20232 var _position, _length, _character, _result; 20233 20234 if (start < end) { 20235 _result = state.input.slice(start, end); 20236 20237 if (checkJson) { 20238 for (_position = 0, _length = _result.length; 20239 _position < _length; 20240 _position += 1) { 20241 _character = _result.charCodeAt(_position); 20242 if (!(_character === 0x09 || 20243 (0x20 <= _character && _character <= 0x10FFFF))) { 20244 throwError(state, 'expected valid JSON character'); 20245 } 20246 } 20247 } else if (PATTERN_NON_PRINTABLE.test(_result)) { 20248 throwError(state, 'the stream contains non-printable characters'); 20249 } 20250 20251 state.result += _result; 20252 } 20253 } 20254 20255 function mergeMappings(state, destination, source, overridableKeys) { 20256 var sourceKeys, key, index, quantity; 20257 20258 if (!common.isObject(source)) { 20259 throwError(state, 'cannot merge mappings; the provided source object is unacceptable'); 20260 } 20261 20262 sourceKeys = Object.keys(source); 20263 20264 for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { 20265 key = sourceKeys[index]; 20266 20267 if (!_hasOwnProperty.call(destination, key)) { 20268 destination[key] = source[key]; 20269 overridableKeys[key] = true; 20270 } 20271 } 20272 } 20273 20274 function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode) { 20275 var index, quantity; 20276 20277 keyNode = String(keyNode); 20278 20279 if (_result === null) { 20280 _result = {}; 20281 } 20282 20283 if (keyTag === 'tag:yaml.org,2002:merge') { 20284 if (Array.isArray(valueNode)) { 20285 for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { 20286 mergeMappings(state, _result, valueNode[index], overridableKeys); 20287 } 20288 } else { 20289 mergeMappings(state, _result, valueNode, overridableKeys); 20290 } 20291 } else { 20292 if (!state.json && 20293 !_hasOwnProperty.call(overridableKeys, keyNode) && 20294 _hasOwnProperty.call(_result, keyNode)) { 20295 throwError(state, 'duplicated mapping key'); 20296 } 20297 _result[keyNode] = valueNode; 20298 delete overridableKeys[keyNode]; 20299 } 20300 20301 return _result; 20302 } 20303 20304 function readLineBreak(state) { 20305 var ch; 20306 20307 ch = state.input.charCodeAt(state.position); 20308 20309 if (ch === 0x0A/* LF */) { 20310 state.position++; 20311 } else if (ch === 0x0D/* CR */) { 20312 state.position++; 20313 if (state.input.charCodeAt(state.position) === 0x0A/* LF */) { 20314 state.position++; 20315 } 20316 } else { 20317 throwError(state, 'a line break is expected'); 20318 } 20319 20320 state.line += 1; 20321 state.lineStart = state.position; 20322 } 20323 20324 function skipSeparationSpace(state, allowComments, checkIndent) { 20325 var lineBreaks = 0, 20326 ch = state.input.charCodeAt(state.position); 20327 20328 while (ch !== 0) { 20329 while (is_WHITE_SPACE(ch)) { 20330 ch = state.input.charCodeAt(++state.position); 20331 } 20332 20333 if (allowComments && ch === 0x23/* # */) { 20334 do { 20335 ch = state.input.charCodeAt(++state.position); 20336 } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0); 20337 } 20338 20339 if (is_EOL(ch)) { 20340 readLineBreak(state); 20341 20342 ch = state.input.charCodeAt(state.position); 20343 lineBreaks++; 20344 state.lineIndent = 0; 20345 20346 while (ch === 0x20/* Space */) { 20347 state.lineIndent++; 20348 ch = state.input.charCodeAt(++state.position); 20349 } 20350 } else { 20351 break; 20352 } 20353 } 20354 20355 if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { 20356 throwWarning(state, 'deficient indentation'); 20357 } 20358 20359 return lineBreaks; 20360 } 20361 20362 function testDocumentSeparator(state) { 20363 var _position = state.position, 20364 ch; 20365 20366 ch = state.input.charCodeAt(_position); 20367 20368 // Condition state.position === state.lineStart is tested 20369 // in parent on each call, for efficiency. No needs to test here again. 20370 if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) && 20371 ch === state.input.charCodeAt(_position + 1) && 20372 ch === state.input.charCodeAt(_position + 2)) { 20373 20374 _position += 3; 20375 20376 ch = state.input.charCodeAt(_position); 20377 20378 if (ch === 0 || is_WS_OR_EOL(ch)) { 20379 return true; 20380 } 20381 } 20382 20383 return false; 20384 } 20385 20386 function writeFoldedLines(state, count) { 20387 if (count === 1) { 20388 state.result += ' '; 20389 } else if (count > 1) { 20390 state.result += common.repeat('\n', count - 1); 20391 } 20392 } 20393 20394 20395 function readPlainScalar(state, nodeIndent, withinFlowCollection) { 20396 var preceding, 20397 following, 20398 captureStart, 20399 captureEnd, 20400 hasPendingContent, 20401 _line, 20402 _lineStart, 20403 _lineIndent, 20404 _kind = state.kind, 20405 _result = state.result, 20406 ch; 20407 20408 ch = state.input.charCodeAt(state.position); 20409 20410 if (is_WS_OR_EOL(ch) || 20411 is_FLOW_INDICATOR(ch) || 20412 ch === 0x23/* # */ || 20413 ch === 0x26/* & */ || 20414 ch === 0x2A/* * */ || 20415 ch === 0x21/* ! */ || 20416 ch === 0x7C/* | */ || 20417 ch === 0x3E/* > */ || 20418 ch === 0x27/* ' */ || 20419 ch === 0x22/* " */ || 20420 ch === 0x25/* % */ || 20421 ch === 0x40/* @ */ || 20422 ch === 0x60/* ` */) { 20423 return false; 20424 } 20425 20426 if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) { 20427 following = state.input.charCodeAt(state.position + 1); 20428 20429 if (is_WS_OR_EOL(following) || 20430 withinFlowCollection && is_FLOW_INDICATOR(following)) { 20431 return false; 20432 } 20433 } 20434 20435 state.kind = 'scalar'; 20436 state.result = ''; 20437 captureStart = captureEnd = state.position; 20438 hasPendingContent = false; 20439 20440 while (ch !== 0) { 20441 if (ch === 0x3A/* : */) { 20442 following = state.input.charCodeAt(state.position + 1); 20443 20444 if (is_WS_OR_EOL(following) || 20445 withinFlowCollection && is_FLOW_INDICATOR(following)) { 20446 break; 20447 } 20448 20449 } else if (ch === 0x23/* # */) { 20450 preceding = state.input.charCodeAt(state.position - 1); 20451 20452 if (is_WS_OR_EOL(preceding)) { 20453 break; 20454 } 20455 20456 } else if ((state.position === state.lineStart && testDocumentSeparator(state)) || 20457 withinFlowCollection && is_FLOW_INDICATOR(ch)) { 20458 break; 20459 20460 } else if (is_EOL(ch)) { 20461 _line = state.line; 20462 _lineStart = state.lineStart; 20463 _lineIndent = state.lineIndent; 20464 skipSeparationSpace(state, false, -1); 20465 20466 if (state.lineIndent >= nodeIndent) { 20467 hasPendingContent = true; 20468 ch = state.input.charCodeAt(state.position); 20469 continue; 20470 } else { 20471 state.position = captureEnd; 20472 state.line = _line; 20473 state.lineStart = _lineStart; 20474 state.lineIndent = _lineIndent; 20475 break; 20476 } 20477 } 20478 20479 if (hasPendingContent) { 20480 captureSegment(state, captureStart, captureEnd, false); 20481 writeFoldedLines(state, state.line - _line); 20482 captureStart = captureEnd = state.position; 20483 hasPendingContent = false; 20484 } 20485 20486 if (!is_WHITE_SPACE(ch)) { 20487 captureEnd = state.position + 1; 20488 } 20489 20490 ch = state.input.charCodeAt(++state.position); 20491 } 20492 20493 captureSegment(state, captureStart, captureEnd, false); 20494 20495 if (state.result) { 20496 return true; 20497 } 20498 20499 state.kind = _kind; 20500 state.result = _result; 20501 return false; 20502 } 20503 20504 function readSingleQuotedScalar(state, nodeIndent) { 20505 var ch, 20506 captureStart, captureEnd; 20507 20508 ch = state.input.charCodeAt(state.position); 20509 20510 if (ch !== 0x27/* ' */) { 20511 return false; 20512 } 20513 20514 state.kind = 'scalar'; 20515 state.result = ''; 20516 state.position++; 20517 captureStart = captureEnd = state.position; 20518 20519 while ((ch = state.input.charCodeAt(state.position)) !== 0) { 20520 if (ch === 0x27/* ' */) { 20521 captureSegment(state, captureStart, state.position, true); 20522 ch = state.input.charCodeAt(++state.position); 20523 20524 if (ch === 0x27/* ' */) { 20525 captureStart = state.position; 20526 state.position++; 20527 captureEnd = state.position; 20528 } else { 20529 return true; 20530 } 20531 20532 } else if (is_EOL(ch)) { 20533 captureSegment(state, captureStart, captureEnd, true); 20534 writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); 20535 captureStart = captureEnd = state.position; 20536 20537 } else if (state.position === state.lineStart && testDocumentSeparator(state)) { 20538 throwError(state, 'unexpected end of the document within a single quoted scalar'); 20539 20540 } else { 20541 state.position++; 20542 captureEnd = state.position; 20543 } 20544 } 20545 20546 throwError(state, 'unexpected end of the stream within a single quoted scalar'); 20547 } 20548 20549 function readDoubleQuotedScalar(state, nodeIndent) { 20550 var captureStart, 20551 captureEnd, 20552 hexLength, 20553 hexResult, 20554 tmp, 20555 ch; 20556 20557 ch = state.input.charCodeAt(state.position); 20558 20559 if (ch !== 0x22/* " */) { 20560 return false; 20561 } 20562 20563 state.kind = 'scalar'; 20564 state.result = ''; 20565 state.position++; 20566 captureStart = captureEnd = state.position; 20567 20568 while ((ch = state.input.charCodeAt(state.position)) !== 0) { 20569 if (ch === 0x22/* " */) { 20570 captureSegment(state, captureStart, state.position, true); 20571 state.position++; 20572 return true; 20573 20574 } else if (ch === 0x5C/* \ */) { 20575 captureSegment(state, captureStart, state.position, true); 20576 ch = state.input.charCodeAt(++state.position); 20577 20578 if (is_EOL(ch)) { 20579 skipSeparationSpace(state, false, nodeIndent); 20580 20581 // TODO: rework to inline fn with no type cast? 20582 } else if (ch < 256 && simpleEscapeCheck[ch]) { 20583 state.result += simpleEscapeMap[ch]; 20584 state.position++; 20585 20586 } else if ((tmp = escapedHexLen(ch)) > 0) { 20587 hexLength = tmp; 20588 hexResult = 0; 20589 20590 for (; hexLength > 0; hexLength--) { 20591 ch = state.input.charCodeAt(++state.position); 20592 20593 if ((tmp = fromHexCode(ch)) >= 0) { 20594 hexResult = (hexResult << 4) + tmp; 20595 20596 } else { 20597 throwError(state, 'expected hexadecimal character'); 20598 } 20599 } 20600 20601 state.result += charFromCodepoint(hexResult); 20602 20603 state.position++; 20604 20605 } else { 20606 throwError(state, 'unknown escape sequence'); 20607 } 20608 20609 captureStart = captureEnd = state.position; 20610 20611 } else if (is_EOL(ch)) { 20612 captureSegment(state, captureStart, captureEnd, true); 20613 writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); 20614 captureStart = captureEnd = state.position; 20615 20616 } else if (state.position === state.lineStart && testDocumentSeparator(state)) { 20617 throwError(state, 'unexpected end of the document within a double quoted scalar'); 20618 20619 } else { 20620 state.position++; 20621 captureEnd = state.position; 20622 } 20623 } 20624 20625 throwError(state, 'unexpected end of the stream within a double quoted scalar'); 20626 } 20627 20628 function readFlowCollection(state, nodeIndent) { 20629 var readNext = true, 20630 _line, 20631 _tag = state.tag, 20632 _result, 20633 _anchor = state.anchor, 20634 following, 20635 terminator, 20636 isPair, 20637 isExplicitPair, 20638 isMapping, 20639 overridableKeys = {}, 20640 keyNode, 20641 keyTag, 20642 valueNode, 20643 ch; 20644 20645 ch = state.input.charCodeAt(state.position); 20646 20647 if (ch === 0x5B/* [ */) { 20648 terminator = 0x5D;/* ] */ 20649 isMapping = false; 20650 _result = []; 20651 } else if (ch === 0x7B/* { */) { 20652 terminator = 0x7D;/* } */ 20653 isMapping = true; 20654 _result = {}; 20655 } else { 20656 return false; 20657 } 20658 20659 if (state.anchor !== null) { 20660 state.anchorMap[state.anchor] = _result; 20661 } 20662 20663 ch = state.input.charCodeAt(++state.position); 20664 20665 while (ch !== 0) { 20666 skipSeparationSpace(state, true, nodeIndent); 20667 20668 ch = state.input.charCodeAt(state.position); 20669 20670 if (ch === terminator) { 20671 state.position++; 20672 state.tag = _tag; 20673 state.anchor = _anchor; 20674 state.kind = isMapping ? 'mapping' : 'sequence'; 20675 state.result = _result; 20676 return true; 20677 } else if (!readNext) { 20678 throwError(state, 'missed comma between flow collection entries'); 20679 } 20680 20681 keyTag = keyNode = valueNode = null; 20682 isPair = isExplicitPair = false; 20683 20684 if (ch === 0x3F/* ? */) { 20685 following = state.input.charCodeAt(state.position + 1); 20686 20687 if (is_WS_OR_EOL(following)) { 20688 isPair = isExplicitPair = true; 20689 state.position++; 20690 skipSeparationSpace(state, true, nodeIndent); 20691 } 20692 } 20693 20694 _line = state.line; 20695 composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); 20696 keyTag = state.tag; 20697 keyNode = state.result; 20698 skipSeparationSpace(state, true, nodeIndent); 20699 20700 ch = state.input.charCodeAt(state.position); 20701 20702 if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) { 20703 isPair = true; 20704 ch = state.input.charCodeAt(++state.position); 20705 skipSeparationSpace(state, true, nodeIndent); 20706 composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); 20707 valueNode = state.result; 20708 } 20709 20710 if (isMapping) { 20711 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode); 20712 } else if (isPair) { 20713 _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode)); 20714 } else { 20715 _result.push(keyNode); 20716 } 20717 20718 skipSeparationSpace(state, true, nodeIndent); 20719 20720 ch = state.input.charCodeAt(state.position); 20721 20722 if (ch === 0x2C/* , */) { 20723 readNext = true; 20724 ch = state.input.charCodeAt(++state.position); 20725 } else { 20726 readNext = false; 20727 } 20728 } 20729 20730 throwError(state, 'unexpected end of the stream within a flow collection'); 20731 } 20732 20733 function readBlockScalar(state, nodeIndent) { 20734 var captureStart, 20735 folding, 20736 chomping = CHOMPING_CLIP, 20737 didReadContent = false, 20738 detectedIndent = false, 20739 textIndent = nodeIndent, 20740 emptyLines = 0, 20741 atMoreIndented = false, 20742 tmp, 20743 ch; 20744 20745 ch = state.input.charCodeAt(state.position); 20746 20747 if (ch === 0x7C/* | */) { 20748 folding = false; 20749 } else if (ch === 0x3E/* > */) { 20750 folding = true; 20751 } else { 20752 return false; 20753 } 20754 20755 state.kind = 'scalar'; 20756 state.result = ''; 20757 20758 while (ch !== 0) { 20759 ch = state.input.charCodeAt(++state.position); 20760 20761 if (ch === 0x2B/* + */ || ch === 0x2D/* - */) { 20762 if (CHOMPING_CLIP === chomping) { 20763 chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP; 20764 } else { 20765 throwError(state, 'repeat of a chomping mode identifier'); 20766 } 20767 20768 } else if ((tmp = fromDecimalCode(ch)) >= 0) { 20769 if (tmp === 0) { 20770 throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one'); 20771 } else if (!detectedIndent) { 20772 textIndent = nodeIndent + tmp - 1; 20773 detectedIndent = true; 20774 } else { 20775 throwError(state, 'repeat of an indentation width identifier'); 20776 } 20777 20778 } else { 20779 break; 20780 } 20781 } 20782 20783 if (is_WHITE_SPACE(ch)) { 20784 do { ch = state.input.charCodeAt(++state.position); } 20785 while (is_WHITE_SPACE(ch)); 20786 20787 if (ch === 0x23/* # */) { 20788 do { ch = state.input.charCodeAt(++state.position); } 20789 while (!is_EOL(ch) && (ch !== 0)); 20790 } 20791 } 20792 20793 while (ch !== 0) { 20794 readLineBreak(state); 20795 state.lineIndent = 0; 20796 20797 ch = state.input.charCodeAt(state.position); 20798 20799 while ((!detectedIndent || state.lineIndent < textIndent) && 20800 (ch === 0x20/* Space */)) { 20801 state.lineIndent++; 20802 ch = state.input.charCodeAt(++state.position); 20803 } 20804 20805 if (!detectedIndent && state.lineIndent > textIndent) { 20806 textIndent = state.lineIndent; 20807 } 20808 20809 if (is_EOL(ch)) { 20810 emptyLines++; 20811 continue; 20812 } 20813 20814 // End of the scalar. 20815 if (state.lineIndent < textIndent) { 20816 20817 // Perform the chomping. 20818 if (chomping === CHOMPING_KEEP) { 20819 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); 20820 } else if (chomping === CHOMPING_CLIP) { 20821 if (didReadContent) { // i.e. only if the scalar is not empty. 20822 state.result += '\n'; 20823 } 20824 } 20825 20826 // Break this `while` cycle and go to the funciton's epilogue. 20827 break; 20828 } 20829 20830 // Folded style: use fancy rules to handle line breaks. 20831 if (folding) { 20832 20833 // Lines starting with white space characters (more-indented lines) are not folded. 20834 if (is_WHITE_SPACE(ch)) { 20835 atMoreIndented = true; 20836 // except for the first content line (cf. Example 8.1) 20837 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); 20838 20839 // End of more-indented block. 20840 } else if (atMoreIndented) { 20841 atMoreIndented = false; 20842 state.result += common.repeat('\n', emptyLines + 1); 20843 20844 // Just one line break - perceive as the same line. 20845 } else if (emptyLines === 0) { 20846 if (didReadContent) { // i.e. only if we have already read some scalar content. 20847 state.result += ' '; 20848 } 20849 20850 // Several line breaks - perceive as different lines. 20851 } else { 20852 state.result += common.repeat('\n', emptyLines); 20853 } 20854 20855 // Literal style: just add exact number of line breaks between content lines. 20856 } else { 20857 // Keep all line breaks except the header line break. 20858 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); 20859 } 20860 20861 didReadContent = true; 20862 detectedIndent = true; 20863 emptyLines = 0; 20864 captureStart = state.position; 20865 20866 while (!is_EOL(ch) && (ch !== 0)) { 20867 ch = state.input.charCodeAt(++state.position); 20868 } 20869 20870 captureSegment(state, captureStart, state.position, false); 20871 } 20872 20873 return true; 20874 } 20875 20876 function readBlockSequence(state, nodeIndent) { 20877 var _line, 20878 _tag = state.tag, 20879 _anchor = state.anchor, 20880 _result = [], 20881 following, 20882 detected = false, 20883 ch; 20884 20885 if (state.anchor !== null) { 20886 state.anchorMap[state.anchor] = _result; 20887 } 20888 20889 ch = state.input.charCodeAt(state.position); 20890 20891 while (ch !== 0) { 20892 20893 if (ch !== 0x2D/* - */) { 20894 break; 20895 } 20896 20897 following = state.input.charCodeAt(state.position + 1); 20898 20899 if (!is_WS_OR_EOL(following)) { 20900 break; 20901 } 20902 20903 detected = true; 20904 state.position++; 20905 20906 if (skipSeparationSpace(state, true, -1)) { 20907 if (state.lineIndent <= nodeIndent) { 20908 _result.push(null); 20909 ch = state.input.charCodeAt(state.position); 20910 continue; 20911 } 20912 } 20913 20914 _line = state.line; 20915 composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true); 20916 _result.push(state.result); 20917 skipSeparationSpace(state, true, -1); 20918 20919 ch = state.input.charCodeAt(state.position); 20920 20921 if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { 20922 throwError(state, 'bad indentation of a sequence entry'); 20923 } else if (state.lineIndent < nodeIndent) { 20924 break; 20925 } 20926 } 20927 20928 if (detected) { 20929 state.tag = _tag; 20930 state.anchor = _anchor; 20931 state.kind = 'sequence'; 20932 state.result = _result; 20933 return true; 20934 } 20935 return false; 20936 } 20937 20938 function readBlockMapping(state, nodeIndent, flowIndent) { 20939 var following, 20940 allowCompact, 20941 _line, 20942 _tag = state.tag, 20943 _anchor = state.anchor, 20944 _result = {}, 20945 overridableKeys = {}, 20946 keyTag = null, 20947 keyNode = null, 20948 valueNode = null, 20949 atExplicitKey = false, 20950 detected = false, 20951 ch; 20952 20953 if (state.anchor !== null) { 20954 state.anchorMap[state.anchor] = _result; 20955 } 20956 20957 ch = state.input.charCodeAt(state.position); 20958 20959 while (ch !== 0) { 20960 following = state.input.charCodeAt(state.position + 1); 20961 _line = state.line; // Save the current line. 20962 20963 // 20964 // Explicit notation case. There are two separate blocks: 20965 // first for the key (denoted by "?") and second for the value (denoted by ":") 20966 // 20967 if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) { 20968 20969 if (ch === 0x3F/* ? */) { 20970 if (atExplicitKey) { 20971 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null); 20972 keyTag = keyNode = valueNode = null; 20973 } 20974 20975 detected = true; 20976 atExplicitKey = true; 20977 allowCompact = true; 20978 20979 } else if (atExplicitKey) { 20980 // i.e. 0x3A/* : */ === character after the explicit key. 20981 atExplicitKey = false; 20982 allowCompact = true; 20983 20984 } else { 20985 throwError(state, 'incomplete explicit mapping pair; a key node is missed'); 20986 } 20987 20988 state.position += 1; 20989 ch = following; 20990 20991 // 20992 // Implicit notation case. Flow-style node as the key first, then ":", and the value. 20993 // 20994 } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) { 20995 20996 if (state.line === _line) { 20997 ch = state.input.charCodeAt(state.position); 20998 20999 while (is_WHITE_SPACE(ch)) { 21000 ch = state.input.charCodeAt(++state.position); 21001 } 21002 21003 if (ch === 0x3A/* : */) { 21004 ch = state.input.charCodeAt(++state.position); 21005 21006 if (!is_WS_OR_EOL(ch)) { 21007 throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping'); 21008 } 21009 21010 if (atExplicitKey) { 21011 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null); 21012 keyTag = keyNode = valueNode = null; 21013 } 21014 21015 detected = true; 21016 atExplicitKey = false; 21017 allowCompact = false; 21018 keyTag = state.tag; 21019 keyNode = state.result; 21020 21021 } else if (detected) { 21022 throwError(state, 'can not read an implicit mapping pair; a colon is missed'); 21023 21024 } else { 21025 state.tag = _tag; 21026 state.anchor = _anchor; 21027 return true; // Keep the result of `composeNode`. 21028 } 21029 21030 } else if (detected) { 21031 throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key'); 21032 21033 } else { 21034 state.tag = _tag; 21035 state.anchor = _anchor; 21036 return true; // Keep the result of `composeNode`. 21037 } 21038 21039 } else { 21040 break; // Reading is done. Go to the epilogue. 21041 } 21042 21043 // 21044 // Common reading code for both explicit and implicit notations. 21045 // 21046 if (state.line === _line || state.lineIndent > nodeIndent) { 21047 if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { 21048 if (atExplicitKey) { 21049 keyNode = state.result; 21050 } else { 21051 valueNode = state.result; 21052 } 21053 } 21054 21055 if (!atExplicitKey) { 21056 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode); 21057 keyTag = keyNode = valueNode = null; 21058 } 21059 21060 skipSeparationSpace(state, true, -1); 21061 ch = state.input.charCodeAt(state.position); 21062 } 21063 21064 if (state.lineIndent > nodeIndent && (ch !== 0)) { 21065 throwError(state, 'bad indentation of a mapping entry'); 21066 } else if (state.lineIndent < nodeIndent) { 21067 break; 21068 } 21069 } 21070 21071 // 21072 // Epilogue. 21073 // 21074 21075 // Special case: last mapping's node contains only the key in explicit notation. 21076 if (atExplicitKey) { 21077 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null); 21078 } 21079 21080 // Expose the resulting mapping. 21081 if (detected) { 21082 state.tag = _tag; 21083 state.anchor = _anchor; 21084 state.kind = 'mapping'; 21085 state.result = _result; 21086 } 21087 21088 return detected; 21089 } 21090 21091 function readTagProperty(state) { 21092 var _position, 21093 isVerbatim = false, 21094 isNamed = false, 21095 tagHandle, 21096 tagName, 21097 ch; 21098 21099 ch = state.input.charCodeAt(state.position); 21100 21101 if (ch !== 0x21/* ! */) return false; 21102 21103 if (state.tag !== null) { 21104 throwError(state, 'duplication of a tag property'); 21105 } 21106 21107 ch = state.input.charCodeAt(++state.position); 21108 21109 if (ch === 0x3C/* < */) { 21110 isVerbatim = true; 21111 ch = state.input.charCodeAt(++state.position); 21112 21113 } else if (ch === 0x21/* ! */) { 21114 isNamed = true; 21115 tagHandle = '!!'; 21116 ch = state.input.charCodeAt(++state.position); 21117 21118 } else { 21119 tagHandle = '!'; 21120 } 21121 21122 _position = state.position; 21123 21124 if (isVerbatim) { 21125 do { ch = state.input.charCodeAt(++state.position); } 21126 while (ch !== 0 && ch !== 0x3E/* > */); 21127 21128 if (state.position < state.length) { 21129 tagName = state.input.slice(_position, state.position); 21130 ch = state.input.charCodeAt(++state.position); 21131 } else { 21132 throwError(state, 'unexpected end of the stream within a verbatim tag'); 21133 } 21134 } else { 21135 while (ch !== 0 && !is_WS_OR_EOL(ch)) { 21136 21137 if (ch === 0x21/* ! */) { 21138 if (!isNamed) { 21139 tagHandle = state.input.slice(_position - 1, state.position + 1); 21140 21141 if (!PATTERN_TAG_HANDLE.test(tagHandle)) { 21142 throwError(state, 'named tag handle cannot contain such characters'); 21143 } 21144 21145 isNamed = true; 21146 _position = state.position + 1; 21147 } else { 21148 throwError(state, 'tag suffix cannot contain exclamation marks'); 21149 } 21150 } 21151 21152 ch = state.input.charCodeAt(++state.position); 21153 } 21154 21155 tagName = state.input.slice(_position, state.position); 21156 21157 if (PATTERN_FLOW_INDICATORS.test(tagName)) { 21158 throwError(state, 'tag suffix cannot contain flow indicator characters'); 21159 } 21160 } 21161 21162 if (tagName && !PATTERN_TAG_URI.test(tagName)) { 21163 throwError(state, 'tag name cannot contain such characters: ' + tagName); 21164 } 21165 21166 if (isVerbatim) { 21167 state.tag = tagName; 21168 21169 } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) { 21170 state.tag = state.tagMap[tagHandle] + tagName; 21171 21172 } else if (tagHandle === '!') { 21173 state.tag = '!' + tagName; 21174 21175 } else if (tagHandle === '!!') { 21176 state.tag = 'tag:yaml.org,2002:' + tagName; 21177 21178 } else { 21179 throwError(state, 'undeclared tag handle "' + tagHandle + '"'); 21180 } 21181 21182 return true; 21183 } 21184 21185 function readAnchorProperty(state) { 21186 var _position, 21187 ch; 21188 21189 ch = state.input.charCodeAt(state.position); 21190 21191 if (ch !== 0x26/* & */) return false; 21192 21193 if (state.anchor !== null) { 21194 throwError(state, 'duplication of an anchor property'); 21195 } 21196 21197 ch = state.input.charCodeAt(++state.position); 21198 _position = state.position; 21199 21200 while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { 21201 ch = state.input.charCodeAt(++state.position); 21202 } 21203 21204 if (state.position === _position) { 21205 throwError(state, 'name of an anchor node must contain at least one character'); 21206 } 21207 21208 state.anchor = state.input.slice(_position, state.position); 21209 return true; 21210 } 21211 21212 function readAlias(state) { 21213 var _position, alias, 21214 ch; 21215 21216 ch = state.input.charCodeAt(state.position); 21217 21218 if (ch !== 0x2A/* * */) return false; 21219 21220 ch = state.input.charCodeAt(++state.position); 21221 _position = state.position; 21222 21223 while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { 21224 ch = state.input.charCodeAt(++state.position); 21225 } 21226 21227 if (state.position === _position) { 21228 throwError(state, 'name of an alias node must contain at least one character'); 21229 } 21230 21231 alias = state.input.slice(_position, state.position); 21232 21233 if (!state.anchorMap.hasOwnProperty(alias)) { 21234 throwError(state, 'unidentified alias "' + alias + '"'); 21235 } 21236 21237 state.result = state.anchorMap[alias]; 21238 skipSeparationSpace(state, true, -1); 21239 return true; 21240 } 21241 21242 function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) { 21243 var allowBlockStyles, 21244 allowBlockScalars, 21245 allowBlockCollections, 21246 indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this<parent 21247 atNewLine = false, 21248 hasContent = false, 21249 typeIndex, 21250 typeQuantity, 21251 type, 21252 flowIndent, 21253 blockIndent; 21254 21255 if (state.listener !== null) { 21256 state.listener('open', state); 21257 } 21258 21259 state.tag = null; 21260 state.anchor = null; 21261 state.kind = null; 21262 state.result = null; 21263 21264 allowBlockStyles = allowBlockScalars = allowBlockCollections = 21265 CONTEXT_BLOCK_OUT === nodeContext || 21266 CONTEXT_BLOCK_IN === nodeContext; 21267 21268 if (allowToSeek) { 21269 if (skipSeparationSpace(state, true, -1)) { 21270 atNewLine = true; 21271 21272 if (state.lineIndent > parentIndent) { 21273 indentStatus = 1; 21274 } else if (state.lineIndent === parentIndent) { 21275 indentStatus = 0; 21276 } else if (state.lineIndent < parentIndent) { 21277 indentStatus = -1; 21278 } 21279 } 21280 } 21281 21282 if (indentStatus === 1) { 21283 while (readTagProperty(state) || readAnchorProperty(state)) { 21284 if (skipSeparationSpace(state, true, -1)) { 21285 atNewLine = true; 21286 allowBlockCollections = allowBlockStyles; 21287 21288 if (state.lineIndent > parentIndent) { 21289 indentStatus = 1; 21290 } else if (state.lineIndent === parentIndent) { 21291 indentStatus = 0; 21292 } else if (state.lineIndent < parentIndent) { 21293 indentStatus = -1; 21294 } 21295 } else { 21296 allowBlockCollections = false; 21297 } 21298 } 21299 } 21300 21301 if (allowBlockCollections) { 21302 allowBlockCollections = atNewLine || allowCompact; 21303 } 21304 21305 if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { 21306 if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { 21307 flowIndent = parentIndent; 21308 } else { 21309 flowIndent = parentIndent + 1; 21310 } 21311 21312 blockIndent = state.position - state.lineStart; 21313 21314 if (indentStatus === 1) { 21315 if (allowBlockCollections && 21316 (readBlockSequence(state, blockIndent) || 21317 readBlockMapping(state, blockIndent, flowIndent)) || 21318 readFlowCollection(state, flowIndent)) { 21319 hasContent = true; 21320 } else { 21321 if ((allowBlockScalars && readBlockScalar(state, flowIndent)) || 21322 readSingleQuotedScalar(state, flowIndent) || 21323 readDoubleQuotedScalar(state, flowIndent)) { 21324 hasContent = true; 21325 21326 } else if (readAlias(state)) { 21327 hasContent = true; 21328 21329 if (state.tag !== null || state.anchor !== null) { 21330 throwError(state, 'alias node should not have any properties'); 21331 } 21332 21333 } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { 21334 hasContent = true; 21335 21336 if (state.tag === null) { 21337 state.tag = '?'; 21338 } 21339 } 21340 21341 if (state.anchor !== null) { 21342 state.anchorMap[state.anchor] = state.result; 21343 } 21344 } 21345 } else if (indentStatus === 0) { 21346 // Special case: block sequences are allowed to have same indentation level as the parent. 21347 // http://www.yaml.org/spec/1.2/spec.html#id2799784 21348 hasContent = allowBlockCollections && readBlockSequence(state, blockIndent); 21349 } 21350 } 21351 21352 if (state.tag !== null && state.tag !== '!') { 21353 if (state.tag === '?') { 21354 for (typeIndex = 0, typeQuantity = state.implicitTypes.length; 21355 typeIndex < typeQuantity; 21356 typeIndex += 1) { 21357 type = state.implicitTypes[typeIndex]; 21358 21359 // Implicit resolving is not allowed for non-scalar types, and '?' 21360 // non-specific tag is only assigned to plain scalars. So, it isn't 21361 // needed to check for 'kind' conformity. 21362 21363 if (type.resolve(state.result)) { // `state.result` updated in resolver if matched 21364 state.result = type.construct(state.result); 21365 state.tag = type.tag; 21366 if (state.anchor !== null) { 21367 state.anchorMap[state.anchor] = state.result; 21368 } 21369 break; 21370 } 21371 } 21372 } else if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) { 21373 type = state.typeMap[state.kind || 'fallback'][state.tag]; 21374 21375 if (state.result !== null && type.kind !== state.kind) { 21376 throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"'); 21377 } 21378 21379 if (!type.resolve(state.result)) { // `state.result` updated in resolver if matched 21380 throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag'); 21381 } else { 21382 state.result = type.construct(state.result); 21383 if (state.anchor !== null) { 21384 state.anchorMap[state.anchor] = state.result; 21385 } 21386 } 21387 } else { 21388 throwError(state, 'unknown tag !<' + state.tag + '>'); 21389 } 21390 } 21391 21392 if (state.listener !== null) { 21393 state.listener('close', state); 21394 } 21395 return state.tag !== null || state.anchor !== null || hasContent; 21396 } 21397 21398 function readDocument(state) { 21399 var documentStart = state.position, 21400 _position, 21401 directiveName, 21402 directiveArgs, 21403 hasDirectives = false, 21404 ch; 21405 21406 state.version = null; 21407 state.checkLineBreaks = state.legacy; 21408 state.tagMap = {}; 21409 state.anchorMap = {}; 21410 21411 while ((ch = state.input.charCodeAt(state.position)) !== 0) { 21412 skipSeparationSpace(state, true, -1); 21413 21414 ch = state.input.charCodeAt(state.position); 21415 21416 if (state.lineIndent > 0 || ch !== 0x25/* % */) { 21417 break; 21418 } 21419 21420 hasDirectives = true; 21421 ch = state.input.charCodeAt(++state.position); 21422 _position = state.position; 21423 21424 while (ch !== 0 && !is_WS_OR_EOL(ch)) { 21425 ch = state.input.charCodeAt(++state.position); 21426 } 21427 21428 directiveName = state.input.slice(_position, state.position); 21429 directiveArgs = []; 21430 21431 if (directiveName.length < 1) { 21432 throwError(state, 'directive name must not be less than one character in length'); 21433 } 21434 21435 while (ch !== 0) { 21436 while (is_WHITE_SPACE(ch)) { 21437 ch = state.input.charCodeAt(++state.position); 21438 } 21439 21440 if (ch === 0x23/* # */) { 21441 do { ch = state.input.charCodeAt(++state.position); } 21442 while (ch !== 0 && !is_EOL(ch)); 21443 break; 21444 } 21445 21446 if (is_EOL(ch)) break; 21447 21448 _position = state.position; 21449 21450 while (ch !== 0 && !is_WS_OR_EOL(ch)) { 21451 ch = state.input.charCodeAt(++state.position); 21452 } 21453 21454 directiveArgs.push(state.input.slice(_position, state.position)); 21455 } 21456 21457 if (ch !== 0) readLineBreak(state); 21458 21459 if (_hasOwnProperty.call(directiveHandlers, directiveName)) { 21460 directiveHandlers[directiveName](state, directiveName, directiveArgs); 21461 } else { 21462 throwWarning(state, 'unknown document directive "' + directiveName + '"'); 21463 } 21464 } 21465 21466 skipSeparationSpace(state, true, -1); 21467 21468 if (state.lineIndent === 0 && 21469 state.input.charCodeAt(state.position) === 0x2D/* - */ && 21470 state.input.charCodeAt(state.position + 1) === 0x2D/* - */ && 21471 state.input.charCodeAt(state.position + 2) === 0x2D/* - */) { 21472 state.position += 3; 21473 skipSeparationSpace(state, true, -1); 21474 21475 } else if (hasDirectives) { 21476 throwError(state, 'directives end mark is expected'); 21477 } 21478 21479 composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); 21480 skipSeparationSpace(state, true, -1); 21481 21482 if (state.checkLineBreaks && 21483 PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) { 21484 throwWarning(state, 'non-ASCII line breaks are interpreted as content'); 21485 } 21486 21487 state.documents.push(state.result); 21488 21489 if (state.position === state.lineStart && testDocumentSeparator(state)) { 21490 21491 if (state.input.charCodeAt(state.position) === 0x2E/* . */) { 21492 state.position += 3; 21493 skipSeparationSpace(state, true, -1); 21494 } 21495 return; 21496 } 21497 21498 if (state.position < (state.length - 1)) { 21499 throwError(state, 'end of the stream or a document separator is expected'); 21500 } else { 21501 return; 21502 } 21503 } 21504 21505 21506 function loadDocuments(input, options) { 21507 input = String(input); 21508 options = options || {}; 21509 21510 if (input.length !== 0) { 21511 21512 // Add tailing `\n` if not exists 21513 if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ && 21514 input.charCodeAt(input.length - 1) !== 0x0D/* CR */) { 21515 input += '\n'; 21516 } 21517 21518 // Strip BOM 21519 if (input.charCodeAt(0) === 0xFEFF) { 21520 input = input.slice(1); 21521 } 21522 } 21523 21524 var state = new State(input, options); 21525 21526 // Use 0 as string terminator. That significantly simplifies bounds check. 21527 state.input += '\0'; 21528 21529 while (state.input.charCodeAt(state.position) === 0x20/* Space */) { 21530 state.lineIndent += 1; 21531 state.position += 1; 21532 } 21533 21534 while (state.position < (state.length - 1)) { 21535 readDocument(state); 21536 } 21537 21538 return state.documents; 21539 } 21540 21541 21542 function loadAll(input, iterator, options) { 21543 var documents = loadDocuments(input, options), index, length; 21544 21545 for (index = 0, length = documents.length; index < length; index += 1) { 21546 iterator(documents[index]); 21547 } 21548 } 21549 21550 21551 function load(input, options) { 21552 var documents = loadDocuments(input, options); 21553 21554 if (documents.length === 0) { 21555 /*eslint-disable no-undefined*/ 21556 return undefined; 21557 } else if (documents.length === 1) { 21558 return documents[0]; 21559 } 21560 throw new YAMLException('expected a single document in the stream, but found more'); 21561 } 21562 21563 21564 function safeLoadAll(input, output, options) { 21565 loadAll(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); 21566 } 21567 21568 21569 function safeLoad(input, options) { 21570 return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); 21571 } 21572 21573 21574 module.exports.loadAll = loadAll; 21575 module.exports.load = load; 21576 module.exports.safeLoadAll = safeLoadAll; 21577 module.exports.safeLoad = safeLoad; 21578 21579 21580 /***/ }, 21581 /* 124 */ 21582 /***/ function(module, exports) { 21583 21584 'use strict'; 21585 21586 21587 function isNothing(subject) { 21588 return (typeof subject === 'undefined') || (subject === null); 21589 } 21590 21591 21592 function isObject(subject) { 21593 return (typeof subject === 'object') && (subject !== null); 21594 } 21595 21596 21597 function toArray(sequence) { 21598 if (Array.isArray(sequence)) return sequence; 21599 else if (isNothing(sequence)) return []; 21600 21601 return [ sequence ]; 21602 } 21603 21604 21605 function extend(target, source) { 21606 var index, length, key, sourceKeys; 21607 21608 if (source) { 21609 sourceKeys = Object.keys(source); 21610 21611 for (index = 0, length = sourceKeys.length; index < length; index += 1) { 21612 key = sourceKeys[index]; 21613 target[key] = source[key]; 21614 } 21615 } 21616 21617 return target; 21618 } 21619 21620 21621 function repeat(string, count) { 21622 var result = '', cycle; 21623 21624 for (cycle = 0; cycle < count; cycle += 1) { 21625 result += string; 21626 } 21627 21628 return result; 21629 } 21630 21631 21632 function isNegativeZero(number) { 21633 return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number); 21634 } 21635 21636 21637 module.exports.isNothing = isNothing; 21638 module.exports.isObject = isObject; 21639 module.exports.toArray = toArray; 21640 module.exports.repeat = repeat; 21641 module.exports.isNegativeZero = isNegativeZero; 21642 module.exports.extend = extend; 21643 21644 21645 /***/ }, 21646 /* 125 */ 21647 /***/ function(module, exports) { 21648 21649 // YAML error class. http://stackoverflow.com/questions/8458984 21650 // 21651 'use strict'; 21652 21653 function YAMLException(reason, mark) { 21654 // Super constructor 21655 Error.call(this); 21656 21657 // Include stack trace in error object 21658 if (Error.captureStackTrace) { 21659 // Chrome and NodeJS 21660 Error.captureStackTrace(this, this.constructor); 21661 } else { 21662 // FF, IE 10+ and Safari 6+. Fallback for others 21663 this.stack = (new Error()).stack || ''; 21664 } 21665 21666 this.name = 'YAMLException'; 21667 this.reason = reason; 21668 this.mark = mark; 21669 this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : ''); 21670 } 21671 21672 21673 // Inherit from Error 21674 YAMLException.prototype = Object.create(Error.prototype); 21675 YAMLException.prototype.constructor = YAMLException; 21676 21677 21678 YAMLException.prototype.toString = function toString(compact) { 21679 var result = this.name + ': '; 21680 21681 result += this.reason || '(unknown reason)'; 21682 21683 if (!compact && this.mark) { 21684 result += ' ' + this.mark.toString(); 21685 } 21686 21687 return result; 21688 }; 21689 21690 21691 module.exports = YAMLException; 21692 21693 21694 /***/ }, 21695 /* 126 */ 21696 /***/ function(module, exports, __webpack_require__) { 21697 21698 'use strict'; 21699 21700 21701 var common = __webpack_require__(124); 21702 21703 21704 function Mark(name, buffer, position, line, column) { 21705 this.name = name; 21706 this.buffer = buffer; 21707 this.position = position; 21708 this.line = line; 21709 this.column = column; 21710 } 21711 21712 21713 Mark.prototype.getSnippet = function getSnippet(indent, maxLength) { 21714 var head, start, tail, end, snippet; 21715 21716 if (!this.buffer) return null; 21717 21718 indent = indent || 4; 21719 maxLength = maxLength || 75; 21720 21721 head = ''; 21722 start = this.position; 21723 21724 while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) { 21725 start -= 1; 21726 if (this.position - start > (maxLength / 2 - 1)) { 21727 head = ' ... '; 21728 start += 5; 21729 break; 21730 } 21731 } 21732 21733 tail = ''; 21734 end = this.position; 21735 21736 while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) { 21737 end += 1; 21738 if (end - this.position > (maxLength / 2 - 1)) { 21739 tail = ' ... '; 21740 end -= 5; 21741 break; 21742 } 21743 } 21744 21745 snippet = this.buffer.slice(start, end); 21746 21747 return common.repeat(' ', indent) + head + snippet + tail + '\n' + 21748 common.repeat(' ', indent + this.position - start + head.length) + '^'; 21749 }; 21750 21751 21752 Mark.prototype.toString = function toString(compact) { 21753 var snippet, where = ''; 21754 21755 if (this.name) { 21756 where += 'in "' + this.name + '" '; 21757 } 21758 21759 where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1); 21760 21761 if (!compact) { 21762 snippet = this.getSnippet(); 21763 21764 if (snippet) { 21765 where += ':\n' + snippet; 21766 } 21767 } 21768 21769 return where; 21770 }; 21771 21772 21773 module.exports = Mark; 21774 21775 21776 /***/ }, 21777 /* 127 */ 21778 /***/ function(module, exports, __webpack_require__) { 21779 21780 // JS-YAML's default schema for `safeLoad` function. 21781 // It is not described in the YAML specification. 21782 // 21783 // This schema is based on standard YAML's Core schema and includes most of 21784 // extra types described at YAML tag repository. (http://yaml.org/type/) 21785 21786 21787 'use strict'; 21788 21789 21790 var Schema = __webpack_require__(128); 21791 21792 21793 module.exports = new Schema({ 21794 include: [ 21795 __webpack_require__(130) 21796 ], 21797 implicit: [ 21798 __webpack_require__(140), 21799 __webpack_require__(141) 21800 ], 21801 explicit: [ 21802 __webpack_require__(142), 21803 __webpack_require__(147), 21804 __webpack_require__(148), 21805 __webpack_require__(149) 21806 ] 21807 }); 21808 21809 21810 /***/ }, 21811 /* 128 */ 21812 /***/ function(module, exports, __webpack_require__) { 21813 21814 'use strict'; 21815 21816 /*eslint-disable max-len*/ 21817 21818 var common = __webpack_require__(124); 21819 var YAMLException = __webpack_require__(125); 21820 var Type = __webpack_require__(129); 21821 21822 21823 function compileList(schema, name, result) { 21824 var exclude = []; 21825 21826 schema.include.forEach(function (includedSchema) { 21827 result = compileList(includedSchema, name, result); 21828 }); 21829 21830 schema[name].forEach(function (currentType) { 21831 result.forEach(function (previousType, previousIndex) { 21832 if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) { 21833 exclude.push(previousIndex); 21834 } 21835 }); 21836 21837 result.push(currentType); 21838 }); 21839 21840 return result.filter(function (type, index) { 21841 return exclude.indexOf(index) === -1; 21842 }); 21843 } 21844 21845 21846 function compileMap(/* lists... */) { 21847 var result = { 21848 scalar: {}, 21849 sequence: {}, 21850 mapping: {}, 21851 fallback: {} 21852 }, index, length; 21853 21854 function collectType(type) { 21855 result[type.kind][type.tag] = result['fallback'][type.tag] = type; 21856 } 21857 21858 for (index = 0, length = arguments.length; index < length; index += 1) { 21859 arguments[index].forEach(collectType); 21860 } 21861 return result; 21862 } 21863 21864 21865 function Schema(definition) { 21866 this.include = definition.include || []; 21867 this.implicit = definition.implicit || []; 21868 this.explicit = definition.explicit || []; 21869 21870 this.implicit.forEach(function (type) { 21871 if (type.loadKind && type.loadKind !== 'scalar') { 21872 throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.'); 21873 } 21874 }); 21875 21876 this.compiledImplicit = compileList(this, 'implicit', []); 21877 this.compiledExplicit = compileList(this, 'explicit', []); 21878 this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit); 21879 } 21880 21881 21882 Schema.DEFAULT = null; 21883 21884 21885 Schema.create = function createSchema() { 21886 var schemas, types; 21887 21888 switch (arguments.length) { 21889 case 1: 21890 schemas = Schema.DEFAULT; 21891 types = arguments[0]; 21892 break; 21893 21894 case 2: 21895 schemas = arguments[0]; 21896 types = arguments[1]; 21897 break; 21898 21899 default: 21900 throw new YAMLException('Wrong number of arguments for Schema.create function'); 21901 } 21902 21903 schemas = common.toArray(schemas); 21904 types = common.toArray(types); 21905 21906 if (!schemas.every(function (schema) { return schema instanceof Schema; })) { 21907 throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.'); 21908 } 21909 21910 if (!types.every(function (type) { return type instanceof Type; })) { 21911 throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.'); 21912 } 21913 21914 return new Schema({ 21915 include: schemas, 21916 explicit: types 21917 }); 21918 }; 21919 21920 21921 module.exports = Schema; 21922 21923 21924 /***/ }, 21925 /* 129 */ 21926 /***/ function(module, exports, __webpack_require__) { 21927 21928 'use strict'; 21929 21930 var YAMLException = __webpack_require__(125); 21931 21932 var TYPE_CONSTRUCTOR_OPTIONS = [ 21933 'kind', 21934 'resolve', 21935 'construct', 21936 'instanceOf', 21937 'predicate', 21938 'represent', 21939 'defaultStyle', 21940 'styleAliases' 21941 ]; 21942 21943 var YAML_NODE_KINDS = [ 21944 'scalar', 21945 'sequence', 21946 'mapping' 21947 ]; 21948 21949 function compileStyleAliases(map) { 21950 var result = {}; 21951 21952 if (map !== null) { 21953 Object.keys(map).forEach(function (style) { 21954 map[style].forEach(function (alias) { 21955 result[String(alias)] = style; 21956 }); 21957 }); 21958 } 21959 21960 return result; 21961 } 21962 21963 function Type(tag, options) { 21964 options = options || {}; 21965 21966 Object.keys(options).forEach(function (name) { 21967 if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { 21968 throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); 21969 } 21970 }); 21971 21972 // TODO: Add tag format check. 21973 this.tag = tag; 21974 this.kind = options['kind'] || null; 21975 this.resolve = options['resolve'] || function () { return true; }; 21976 this.construct = options['construct'] || function (data) { return data; }; 21977 this.instanceOf = options['instanceOf'] || null; 21978 this.predicate = options['predicate'] || null; 21979 this.represent = options['represent'] || null; 21980 this.defaultStyle = options['defaultStyle'] || null; 21981 this.styleAliases = compileStyleAliases(options['styleAliases'] || null); 21982 21983 if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { 21984 throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); 21985 } 21986 } 21987 21988 module.exports = Type; 21989 21990 21991 /***/ }, 21992 /* 130 */ 21993 /***/ function(module, exports, __webpack_require__) { 21994 21995 // Standard YAML's Core schema. 21996 // http://www.yaml.org/spec/1.2/spec.html#id2804923 21997 // 21998 // NOTE: JS-YAML does not support schema-specific tag resolution restrictions. 21999 // So, Core schema has no distinctions from JSON schema is JS-YAML. 22000 22001 22002 'use strict'; 22003 22004 22005 var Schema = __webpack_require__(128); 22006 22007 22008 module.exports = new Schema({ 22009 include: [ 22010 __webpack_require__(131) 22011 ] 22012 }); 22013 22014 22015 /***/ }, 22016 /* 131 */ 22017 /***/ function(module, exports, __webpack_require__) { 22018 22019 // Standard YAML's JSON schema. 22020 // http://www.yaml.org/spec/1.2/spec.html#id2803231 22021 // 22022 // NOTE: JS-YAML does not support schema-specific tag resolution restrictions. 22023 // So, this schema is not such strict as defined in the YAML specification. 22024 // It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc. 22025 22026 22027 'use strict'; 22028 22029 22030 var Schema = __webpack_require__(128); 22031 22032 22033 module.exports = new Schema({ 22034 include: [ 22035 __webpack_require__(132) 22036 ], 22037 implicit: [ 22038 __webpack_require__(136), 22039 __webpack_require__(137), 22040 __webpack_require__(138), 22041 __webpack_require__(139) 22042 ] 22043 }); 22044 22045 22046 /***/ }, 22047 /* 132 */ 22048 /***/ function(module, exports, __webpack_require__) { 22049 22050 // Standard YAML's Failsafe schema. 22051 // http://www.yaml.org/spec/1.2/spec.html#id2802346 22052 22053 22054 'use strict'; 22055 22056 22057 var Schema = __webpack_require__(128); 22058 22059 22060 module.exports = new Schema({ 22061 explicit: [ 22062 __webpack_require__(133), 22063 __webpack_require__(134), 22064 __webpack_require__(135) 22065 ] 22066 }); 22067 22068 22069 /***/ }, 22070 /* 133 */ 22071 /***/ function(module, exports, __webpack_require__) { 22072 22073 'use strict'; 22074 22075 var Type = __webpack_require__(129); 22076 22077 module.exports = new Type('tag:yaml.org,2002:str', { 22078 kind: 'scalar', 22079 construct: function (data) { return data !== null ? data : ''; } 22080 }); 22081 22082 22083 /***/ }, 22084 /* 134 */ 22085 /***/ function(module, exports, __webpack_require__) { 22086 22087 'use strict'; 22088 22089 var Type = __webpack_require__(129); 22090 22091 module.exports = new Type('tag:yaml.org,2002:seq', { 22092 kind: 'sequence', 22093 construct: function (data) { return data !== null ? data : []; } 22094 }); 22095 22096 22097 /***/ }, 22098 /* 135 */ 22099 /***/ function(module, exports, __webpack_require__) { 22100 22101 'use strict'; 22102 22103 var Type = __webpack_require__(129); 22104 22105 module.exports = new Type('tag:yaml.org,2002:map', { 22106 kind: 'mapping', 22107 construct: function (data) { return data !== null ? data : {}; } 22108 }); 22109 22110 22111 /***/ }, 22112 /* 136 */ 22113 /***/ function(module, exports, __webpack_require__) { 22114 22115 'use strict'; 22116 22117 var Type = __webpack_require__(129); 22118 22119 function resolveYamlNull(data) { 22120 if (data === null) return true; 22121 22122 var max = data.length; 22123 22124 return (max === 1 && data === '~') || 22125 (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL')); 22126 } 22127 22128 function constructYamlNull() { 22129 return null; 22130 } 22131 22132 function isNull(object) { 22133 return object === null; 22134 } 22135 22136 module.exports = new Type('tag:yaml.org,2002:null', { 22137 kind: 'scalar', 22138 resolve: resolveYamlNull, 22139 construct: constructYamlNull, 22140 predicate: isNull, 22141 represent: { 22142 canonical: function () { return '~'; }, 22143 lowercase: function () { return 'null'; }, 22144 uppercase: function () { return 'NULL'; }, 22145 camelcase: function () { return 'Null'; } 22146 }, 22147 defaultStyle: 'lowercase' 22148 }); 22149 22150 22151 /***/ }, 22152 /* 137 */ 22153 /***/ function(module, exports, __webpack_require__) { 22154 22155 'use strict'; 22156 22157 var Type = __webpack_require__(129); 22158 22159 function resolveYamlBoolean(data) { 22160 if (data === null) return false; 22161 22162 var max = data.length; 22163 22164 return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) || 22165 (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE')); 22166 } 22167 22168 function constructYamlBoolean(data) { 22169 return data === 'true' || 22170 data === 'True' || 22171 data === 'TRUE'; 22172 } 22173 22174 function isBoolean(object) { 22175 return Object.prototype.toString.call(object) === '[object Boolean]'; 22176 } 22177 22178 module.exports = new Type('tag:yaml.org,2002:bool', { 22179 kind: 'scalar', 22180 resolve: resolveYamlBoolean, 22181 construct: constructYamlBoolean, 22182 predicate: isBoolean, 22183 represent: { 22184 lowercase: function (object) { return object ? 'true' : 'false'; }, 22185 uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; }, 22186 camelcase: function (object) { return object ? 'True' : 'False'; } 22187 }, 22188 defaultStyle: 'lowercase' 22189 }); 22190 22191 22192 /***/ }, 22193 /* 138 */ 22194 /***/ function(module, exports, __webpack_require__) { 22195 22196 'use strict'; 22197 22198 var common = __webpack_require__(124); 22199 var Type = __webpack_require__(129); 22200 22201 function isHexCode(c) { 22202 return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) || 22203 ((0x41/* A */ <= c) && (c <= 0x46/* F */)) || 22204 ((0x61/* a */ <= c) && (c <= 0x66/* f */)); 22205 } 22206 22207 function isOctCode(c) { 22208 return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */)); 22209 } 22210 22211 function isDecCode(c) { 22212 return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)); 22213 } 22214 22215 function resolveYamlInteger(data) { 22216 if (data === null) return false; 22217 22218 var max = data.length, 22219 index = 0, 22220 hasDigits = false, 22221 ch; 22222 22223 if (!max) return false; 22224 22225 ch = data[index]; 22226 22227 // sign 22228 if (ch === '-' || ch === '+') { 22229 ch = data[++index]; 22230 } 22231 22232 if (ch === '0') { 22233 // 0 22234 if (index + 1 === max) return true; 22235 ch = data[++index]; 22236 22237 // base 2, base 8, base 16 22238 22239 if (ch === 'b') { 22240 // base 2 22241 index++; 22242 22243 for (; index < max; index++) { 22244 ch = data[index]; 22245 if (ch === '_') continue; 22246 if (ch !== '0' && ch !== '1') return false; 22247 hasDigits = true; 22248 } 22249 return hasDigits; 22250 } 22251 22252 22253 if (ch === 'x') { 22254 // base 16 22255 index++; 22256 22257 for (; index < max; index++) { 22258 ch = data[index]; 22259 if (ch === '_') continue; 22260 if (!isHexCode(data.charCodeAt(index))) return false; 22261 hasDigits = true; 22262 } 22263 return hasDigits; 22264 } 22265 22266 // base 8 22267 for (; index < max; index++) { 22268 ch = data[index]; 22269 if (ch === '_') continue; 22270 if (!isOctCode(data.charCodeAt(index))) return false; 22271 hasDigits = true; 22272 } 22273 return hasDigits; 22274 } 22275 22276 // base 10 (except 0) or base 60 22277 22278 for (; index < max; index++) { 22279 ch = data[index]; 22280 if (ch === '_') continue; 22281 if (ch === ':') break; 22282 if (!isDecCode(data.charCodeAt(index))) { 22283 return false; 22284 } 22285 hasDigits = true; 22286 } 22287 22288 if (!hasDigits) return false; 22289 22290 // if !base60 - done; 22291 if (ch !== ':') return true; 22292 22293 // base60 almost not used, no needs to optimize 22294 return /^(:[0-5]?[0-9])+$/.test(data.slice(index)); 22295 } 22296 22297 function constructYamlInteger(data) { 22298 var value = data, sign = 1, ch, base, digits = []; 22299 22300 if (value.indexOf('_') !== -1) { 22301 value = value.replace(/_/g, ''); 22302 } 22303 22304 ch = value[0]; 22305 22306 if (ch === '-' || ch === '+') { 22307 if (ch === '-') sign = -1; 22308 value = value.slice(1); 22309 ch = value[0]; 22310 } 22311 22312 if (value === '0') return 0; 22313 22314 if (ch === '0') { 22315 if (value[1] === 'b') return sign * parseInt(value.slice(2), 2); 22316 if (value[1] === 'x') return sign * parseInt(value, 16); 22317 return sign * parseInt(value, 8); 22318 } 22319 22320 if (value.indexOf(':') !== -1) { 22321 value.split(':').forEach(function (v) { 22322 digits.unshift(parseInt(v, 10)); 22323 }); 22324 22325 value = 0; 22326 base = 1; 22327 22328 digits.forEach(function (d) { 22329 value += (d * base); 22330 base *= 60; 22331 }); 22332 22333 return sign * value; 22334 22335 } 22336 22337 return sign * parseInt(value, 10); 22338 } 22339 22340 function isInteger(object) { 22341 return (Object.prototype.toString.call(object)) === '[object Number]' && 22342 (object % 1 === 0 && !common.isNegativeZero(object)); 22343 } 22344 22345 module.exports = new Type('tag:yaml.org,2002:int', { 22346 kind: 'scalar', 22347 resolve: resolveYamlInteger, 22348 construct: constructYamlInteger, 22349 predicate: isInteger, 22350 represent: { 22351 binary: function (object) { return '0b' + object.toString(2); }, 22352 octal: function (object) { return '0' + object.toString(8); }, 22353 decimal: function (object) { return object.toString(10); }, 22354 hexadecimal: function (object) { return '0x' + object.toString(16).toUpperCase(); } 22355 }, 22356 defaultStyle: 'decimal', 22357 styleAliases: { 22358 binary: [ 2, 'bin' ], 22359 octal: [ 8, 'oct' ], 22360 decimal: [ 10, 'dec' ], 22361 hexadecimal: [ 16, 'hex' ] 22362 } 22363 }); 22364 22365 22366 /***/ }, 22367 /* 139 */ 22368 /***/ function(module, exports, __webpack_require__) { 22369 22370 'use strict'; 22371 22372 var common = __webpack_require__(124); 22373 var Type = __webpack_require__(129); 22374 22375 var YAML_FLOAT_PATTERN = new RegExp( 22376 '^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?' + 22377 '|\\.[0-9_]+(?:[eE][-+][0-9]+)?' + 22378 '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' + 22379 '|[-+]?\\.(?:inf|Inf|INF)' + 22380 '|\\.(?:nan|NaN|NAN))$'); 22381 22382 function resolveYamlFloat(data) { 22383 if (data === null) return false; 22384 22385 if (!YAML_FLOAT_PATTERN.test(data)) return false; 22386 22387 return true; 22388 } 22389 22390 function constructYamlFloat(data) { 22391 var value, sign, base, digits; 22392 22393 value = data.replace(/_/g, '').toLowerCase(); 22394 sign = value[0] === '-' ? -1 : 1; 22395 digits = []; 22396 22397 if ('+-'.indexOf(value[0]) >= 0) { 22398 value = value.slice(1); 22399 } 22400 22401 if (value === '.inf') { 22402 return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; 22403 22404 } else if (value === '.nan') { 22405 return NaN; 22406 22407 } else if (value.indexOf(':') >= 0) { 22408 value.split(':').forEach(function (v) { 22409 digits.unshift(parseFloat(v, 10)); 22410 }); 22411 22412 value = 0.0; 22413 base = 1; 22414 22415 digits.forEach(function (d) { 22416 value += d * base; 22417 base *= 60; 22418 }); 22419 22420 return sign * value; 22421 22422 } 22423 return sign * parseFloat(value, 10); 22424 } 22425 22426 22427 var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; 22428 22429 function representYamlFloat(object, style) { 22430 var res; 22431 22432 if (isNaN(object)) { 22433 switch (style) { 22434 case 'lowercase': return '.nan'; 22435 case 'uppercase': return '.NAN'; 22436 case 'camelcase': return '.NaN'; 22437 } 22438 } else if (Number.POSITIVE_INFINITY === object) { 22439 switch (style) { 22440 case 'lowercase': return '.inf'; 22441 case 'uppercase': return '.INF'; 22442 case 'camelcase': return '.Inf'; 22443 } 22444 } else if (Number.NEGATIVE_INFINITY === object) { 22445 switch (style) { 22446 case 'lowercase': return '-.inf'; 22447 case 'uppercase': return '-.INF'; 22448 case 'camelcase': return '-.Inf'; 22449 } 22450 } else if (common.isNegativeZero(object)) { 22451 return '-0.0'; 22452 } 22453 22454 res = object.toString(10); 22455 22456 // JS stringifier can build scientific format without dots: 5e-100, 22457 // while YAML requres dot: 5.e-100. Fix it with simple hack 22458 22459 return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res; 22460 } 22461 22462 function isFloat(object) { 22463 return (Object.prototype.toString.call(object) === '[object Number]') && 22464 (object % 1 !== 0 || common.isNegativeZero(object)); 22465 } 22466 22467 module.exports = new Type('tag:yaml.org,2002:float', { 22468 kind: 'scalar', 22469 resolve: resolveYamlFloat, 22470 construct: constructYamlFloat, 22471 predicate: isFloat, 22472 represent: representYamlFloat, 22473 defaultStyle: 'lowercase' 22474 }); 22475 22476 22477 /***/ }, 22478 /* 140 */ 22479 /***/ function(module, exports, __webpack_require__) { 22480 22481 'use strict'; 22482 22483 var Type = __webpack_require__(129); 22484 22485 var YAML_DATE_REGEXP = new RegExp( 22486 '^([0-9][0-9][0-9][0-9])' + // [1] year 22487 '-([0-9][0-9])' + // [2] month 22488 '-([0-9][0-9])$'); // [3] day 22489 22490 var YAML_TIMESTAMP_REGEXP = new RegExp( 22491 '^([0-9][0-9][0-9][0-9])' + // [1] year 22492 '-([0-9][0-9]?)' + // [2] month 22493 '-([0-9][0-9]?)' + // [3] day 22494 '(?:[Tt]|[ \\t]+)' + // ... 22495 '([0-9][0-9]?)' + // [4] hour 22496 ':([0-9][0-9])' + // [5] minute 22497 ':([0-9][0-9])' + // [6] second 22498 '(?:\\.([0-9]*))?' + // [7] fraction 22499 '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour 22500 '(?::([0-9][0-9]))?))?$'); // [11] tz_minute 22501 22502 function resolveYamlTimestamp(data) { 22503 if (data === null) return false; 22504 if (YAML_DATE_REGEXP.exec(data) !== null) return true; 22505 if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true; 22506 return false; 22507 } 22508 22509 function constructYamlTimestamp(data) { 22510 var match, year, month, day, hour, minute, second, fraction = 0, 22511 delta = null, tz_hour, tz_minute, date; 22512 22513 match = YAML_DATE_REGEXP.exec(data); 22514 if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data); 22515 22516 if (match === null) throw new Error('Date resolve error'); 22517 22518 // match: [1] year [2] month [3] day 22519 22520 year = +(match[1]); 22521 month = +(match[2]) - 1; // JS month starts with 0 22522 day = +(match[3]); 22523 22524 if (!match[4]) { // no hour 22525 return new Date(Date.UTC(year, month, day)); 22526 } 22527 22528 // match: [4] hour [5] minute [6] second [7] fraction 22529 22530 hour = +(match[4]); 22531 minute = +(match[5]); 22532 second = +(match[6]); 22533 22534 if (match[7]) { 22535 fraction = match[7].slice(0, 3); 22536 while (fraction.length < 3) { // milli-seconds 22537 fraction += '0'; 22538 } 22539 fraction = +fraction; 22540 } 22541 22542 // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute 22543 22544 if (match[9]) { 22545 tz_hour = +(match[10]); 22546 tz_minute = +(match[11] || 0); 22547 delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds 22548 if (match[9] === '-') delta = -delta; 22549 } 22550 22551 date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); 22552 22553 if (delta) date.setTime(date.getTime() - delta); 22554 22555 return date; 22556 } 22557 22558 function representYamlTimestamp(object /*, style*/) { 22559 return object.toISOString(); 22560 } 22561 22562 module.exports = new Type('tag:yaml.org,2002:timestamp', { 22563 kind: 'scalar', 22564 resolve: resolveYamlTimestamp, 22565 construct: constructYamlTimestamp, 22566 instanceOf: Date, 22567 represent: representYamlTimestamp 22568 }); 22569 22570 22571 /***/ }, 22572 /* 141 */ 22573 /***/ function(module, exports, __webpack_require__) { 22574 22575 'use strict'; 22576 22577 var Type = __webpack_require__(129); 22578 22579 function resolveYamlMerge(data) { 22580 return data === '<<' || data === null; 22581 } 22582 22583 module.exports = new Type('tag:yaml.org,2002:merge', { 22584 kind: 'scalar', 22585 resolve: resolveYamlMerge 22586 }); 22587 22588 22589 /***/ }, 22590 /* 142 */ 22591 /***/ function(module, exports, __webpack_require__) { 22592 22593 var require;'use strict'; 22594 22595 /*eslint-disable no-bitwise*/ 22596 22597 var NodeBuffer; 22598 22599 try { 22600 // A trick for browserified version, to not include `Buffer` shim 22601 var _require = require; 22602 NodeBuffer = __webpack_require__(143).Buffer; 22603 } catch (__) {} 22604 22605 var Type = __webpack_require__(129); 22606 22607 22608 // [ 64, 65, 66 ] -> [ padding, CR, LF ] 22609 var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r'; 22610 22611 22612 function resolveYamlBinary(data) { 22613 if (data === null) return false; 22614 22615 var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP; 22616 22617 // Convert one by one. 22618 for (idx = 0; idx < max; idx++) { 22619 code = map.indexOf(data.charAt(idx)); 22620 22621 // Skip CR/LF 22622 if (code > 64) continue; 22623 22624 // Fail on illegal characters 22625 if (code < 0) return false; 22626 22627 bitlen += 6; 22628 } 22629 22630 // If there are any bits left, source was corrupted 22631 return (bitlen % 8) === 0; 22632 } 22633 22634 function constructYamlBinary(data) { 22635 var idx, tailbits, 22636 input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan 22637 max = input.length, 22638 map = BASE64_MAP, 22639 bits = 0, 22640 result = []; 22641 22642 // Collect by 6*4 bits (3 bytes) 22643 22644 for (idx = 0; idx < max; idx++) { 22645 if ((idx % 4 === 0) && idx) { 22646 result.push((bits >> 16) & 0xFF); 22647 result.push((bits >> 8) & 0xFF); 22648 result.push(bits & 0xFF); 22649 } 22650 22651 bits = (bits << 6) | map.indexOf(input.charAt(idx)); 22652 } 22653 22654 // Dump tail 22655 22656 tailbits = (max % 4) * 6; 22657 22658 if (tailbits === 0) { 22659 result.push((bits >> 16) & 0xFF); 22660 result.push((bits >> 8) & 0xFF); 22661 result.push(bits & 0xFF); 22662 } else if (tailbits === 18) { 22663 result.push((bits >> 10) & 0xFF); 22664 result.push((bits >> 2) & 0xFF); 22665 } else if (tailbits === 12) { 22666 result.push((bits >> 4) & 0xFF); 22667 } 22668 22669 // Wrap into Buffer for NodeJS and leave Array for browser 22670 if (NodeBuffer) return new NodeBuffer(result); 22671 22672 return result; 22673 } 22674 22675 function representYamlBinary(object /*, style*/) { 22676 var result = '', bits = 0, idx, tail, 22677 max = object.length, 22678 map = BASE64_MAP; 22679 22680 // Convert every three bytes to 4 ASCII characters. 22681 22682 for (idx = 0; idx < max; idx++) { 22683 if ((idx % 3 === 0) && idx) { 22684 result += map[(bits >> 18) & 0x3F]; 22685 result += map[(bits >> 12) & 0x3F]; 22686 result += map[(bits >> 6) & 0x3F]; 22687 result += map[bits & 0x3F]; 22688 } 22689 22690 bits = (bits << 8) + object[idx]; 22691 } 22692 22693 // Dump tail 22694 22695 tail = max % 3; 22696 22697 if (tail === 0) { 22698 result += map[(bits >> 18) & 0x3F]; 22699 result += map[(bits >> 12) & 0x3F]; 22700 result += map[(bits >> 6) & 0x3F]; 22701 result += map[bits & 0x3F]; 22702 } else if (tail === 2) { 22703 result += map[(bits >> 10) & 0x3F]; 22704 result += map[(bits >> 4) & 0x3F]; 22705 result += map[(bits << 2) & 0x3F]; 22706 result += map[64]; 22707 } else if (tail === 1) { 22708 result += map[(bits >> 2) & 0x3F]; 22709 result += map[(bits << 4) & 0x3F]; 22710 result += map[64]; 22711 result += map[64]; 22712 } 22713 22714 return result; 22715 } 22716 22717 function isBinary(object) { 22718 return NodeBuffer && NodeBuffer.isBuffer(object); 22719 } 22720 22721 module.exports = new Type('tag:yaml.org,2002:binary', { 22722 kind: 'scalar', 22723 resolve: resolveYamlBinary, 22724 construct: constructYamlBinary, 22725 predicate: isBinary, 22726 represent: representYamlBinary 22727 }); 22728 22729 22730 /***/ }, 22731 /* 143 */ 22732 /***/ function(module, exports, __webpack_require__) { 22733 22734 /* WEBPACK VAR INJECTION */(function(Buffer, global) {/*! 22735 * The buffer module from node.js, for the browser. 22736 * 22737 * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org> 22738 * @license MIT 22739 */ 22740 /* eslint-disable no-proto */ 22741 22742 'use strict' 22743 22744 var base64 = __webpack_require__(144) 22745 var ieee754 = __webpack_require__(145) 22746 var isArray = __webpack_require__(146) 22747 22748 exports.Buffer = Buffer 22749 exports.SlowBuffer = SlowBuffer 22750 exports.INSPECT_MAX_BYTES = 50 22751 22752 /** 22753 * If `Buffer.TYPED_ARRAY_SUPPORT`: 22754 * === true Use Uint8Array implementation (fastest) 22755 * === false Use Object implementation (most compatible, even IE6) 22756 * 22757 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, 22758 * Opera 11.6+, iOS 4.2+. 22759 * 22760 * Due to various browser bugs, sometimes the Object implementation will be used even 22761 * when the browser supports typed arrays. 22762 * 22763 * Note: 22764 * 22765 * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, 22766 * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. 22767 * 22768 * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. 22769 * 22770 * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of 22771 * incorrect length in some situations. 22772 22773 * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they 22774 * get the Object implementation, which is slower but behaves correctly. 22775 */ 22776 Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined 22777 ? global.TYPED_ARRAY_SUPPORT 22778 : typedArraySupport() 22779 22780 /* 22781 * Export kMaxLength after typed array support is determined. 22782 */ 22783 exports.kMaxLength = kMaxLength() 22784 22785 function typedArraySupport () { 22786 try { 22787 var arr = new Uint8Array(1) 22788 arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} 22789 return arr.foo() === 42 && // typed array instances can be augmented 22790 typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` 22791 arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` 22792 } catch (e) { 22793 return false 22794 } 22795 } 22796 22797 function kMaxLength () { 22798 return Buffer.TYPED_ARRAY_SUPPORT 22799 ? 0x7fffffff 22800 : 0x3fffffff 22801 } 22802 22803 function createBuffer (that, length) { 22804 if (kMaxLength() < length) { 22805 throw new RangeError('Invalid typed array length') 22806 } 22807 if (Buffer.TYPED_ARRAY_SUPPORT) { 22808 // Return an augmented `Uint8Array` instance, for best performance 22809 that = new Uint8Array(length) 22810 that.__proto__ = Buffer.prototype 22811 } else { 22812 // Fallback: Return an object instance of the Buffer class 22813 if (that === null) { 22814 that = new Buffer(length) 22815 } 22816 that.length = length 22817 } 22818 22819 return that 22820 } 22821 22822 /** 22823 * The Buffer constructor returns instances of `Uint8Array` that have their 22824 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of 22825 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods 22826 * and the `Uint8Array` methods. Square bracket notation works as expected -- it 22827 * returns a single octet. 22828 * 22829 * The `Uint8Array` prototype remains unmodified. 22830 */ 22831 22832 function Buffer (arg, encodingOrOffset, length) { 22833 if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { 22834 return new Buffer(arg, encodingOrOffset, length) 22835 } 22836 22837 // Common case. 22838 if (typeof arg === 'number') { 22839 if (typeof encodingOrOffset === 'string') { 22840 throw new Error( 22841 'If encoding is specified then the first argument must be a string' 22842 ) 22843 } 22844 return allocUnsafe(this, arg) 22845 } 22846 return from(this, arg, encodingOrOffset, length) 22847 } 22848 22849 Buffer.poolSize = 8192 // not used by this implementation 22850 22851 // TODO: Legacy, not needed anymore. Remove in next major version. 22852 Buffer._augment = function (arr) { 22853 arr.__proto__ = Buffer.prototype 22854 return arr 22855 } 22856 22857 function from (that, value, encodingOrOffset, length) { 22858 if (typeof value === 'number') { 22859 throw new TypeError('"value" argument must not be a number') 22860 } 22861 22862 if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { 22863 return fromArrayBuffer(that, value, encodingOrOffset, length) 22864 } 22865 22866 if (typeof value === 'string') { 22867 return fromString(that, value, encodingOrOffset) 22868 } 22869 22870 return fromObject(that, value) 22871 } 22872 22873 /** 22874 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError 22875 * if value is a number. 22876 * Buffer.from(str[, encoding]) 22877 * Buffer.from(array) 22878 * Buffer.from(buffer) 22879 * Buffer.from(arrayBuffer[, byteOffset[, length]]) 22880 **/ 22881 Buffer.from = function (value, encodingOrOffset, length) { 22882 return from(null, value, encodingOrOffset, length) 22883 } 22884 22885 if (Buffer.TYPED_ARRAY_SUPPORT) { 22886 Buffer.prototype.__proto__ = Uint8Array.prototype 22887 Buffer.__proto__ = Uint8Array 22888 if (typeof Symbol !== 'undefined' && Symbol.species && 22889 Buffer[Symbol.species] === Buffer) { 22890 // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 22891 Object.defineProperty(Buffer, Symbol.species, { 22892 value: null, 22893 configurable: true 22894 }) 22895 } 22896 } 22897 22898 function assertSize (size) { 22899 if (typeof size !== 'number') { 22900 throw new TypeError('"size" argument must be a number') 22901 } else if (size < 0) { 22902 throw new RangeError('"size" argument must not be negative') 22903 } 22904 } 22905 22906 function alloc (that, size, fill, encoding) { 22907 assertSize(size) 22908 if (size <= 0) { 22909 return createBuffer(that, size) 22910 } 22911 if (fill !== undefined) { 22912 // Only pay attention to encoding if it's a string. This 22913 // prevents accidentally sending in a number that would 22914 // be interpretted as a start offset. 22915 return typeof encoding === 'string' 22916 ? createBuffer(that, size).fill(fill, encoding) 22917 : createBuffer(that, size).fill(fill) 22918 } 22919 return createBuffer(that, size) 22920 } 22921 22922 /** 22923 * Creates a new filled Buffer instance. 22924 * alloc(size[, fill[, encoding]]) 22925 **/ 22926 Buffer.alloc = function (size, fill, encoding) { 22927 return alloc(null, size, fill, encoding) 22928 } 22929 22930 function allocUnsafe (that, size) { 22931 assertSize(size) 22932 that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) 22933 if (!Buffer.TYPED_ARRAY_SUPPORT) { 22934 for (var i = 0; i < size; ++i) { 22935 that[i] = 0 22936 } 22937 } 22938 return that 22939 } 22940 22941 /** 22942 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. 22943 * */ 22944 Buffer.allocUnsafe = function (size) { 22945 return allocUnsafe(null, size) 22946 } 22947 /** 22948 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. 22949 */ 22950 Buffer.allocUnsafeSlow = function (size) { 22951 return allocUnsafe(null, size) 22952 } 22953 22954 function fromString (that, string, encoding) { 22955 if (typeof encoding !== 'string' || encoding === '') { 22956 encoding = 'utf8' 22957 } 22958 22959 if (!Buffer.isEncoding(encoding)) { 22960 throw new TypeError('"encoding" must be a valid string encoding') 22961 } 22962 22963 var length = byteLength(string, encoding) | 0 22964 that = createBuffer(that, length) 22965 22966 var actual = that.write(string, encoding) 22967 22968 if (actual !== length) { 22969 // Writing a hex string, for example, that contains invalid characters will 22970 // cause everything after the first invalid character to be ignored. (e.g. 22971 // 'abxxcd' will be treated as 'ab') 22972 that = that.slice(0, actual) 22973 } 22974 22975 return that 22976 } 22977 22978 function fromArrayLike (that, array) { 22979 var length = array.length < 0 ? 0 : checked(array.length) | 0 22980 that = createBuffer(that, length) 22981 for (var i = 0; i < length; i += 1) { 22982 that[i] = array[i] & 255 22983 } 22984 return that 22985 } 22986 22987 function fromArrayBuffer (that, array, byteOffset, length) { 22988 array.byteLength // this throws if `array` is not a valid ArrayBuffer 22989 22990 if (byteOffset < 0 || array.byteLength < byteOffset) { 22991 throw new RangeError('\'offset\' is out of bounds') 22992 } 22993 22994 if (array.byteLength < byteOffset + (length || 0)) { 22995 throw new RangeError('\'length\' is out of bounds') 22996 } 22997 22998 if (byteOffset === undefined && length === undefined) { 22999 array = new Uint8Array(array) 23000 } else if (length === undefined) { 23001 array = new Uint8Array(array, byteOffset) 23002 } else { 23003 array = new Uint8Array(array, byteOffset, length) 23004 } 23005 23006 if (Buffer.TYPED_ARRAY_SUPPORT) { 23007 // Return an augmented `Uint8Array` instance, for best performance 23008 that = array 23009 that.__proto__ = Buffer.prototype 23010 } else { 23011 // Fallback: Return an object instance of the Buffer class 23012 that = fromArrayLike(that, array) 23013 } 23014 return that 23015 } 23016 23017 function fromObject (that, obj) { 23018 if (Buffer.isBuffer(obj)) { 23019 var len = checked(obj.length) | 0 23020 that = createBuffer(that, len) 23021 23022 if (that.length === 0) { 23023 return that 23024 } 23025 23026 obj.copy(that, 0, 0, len) 23027 return that 23028 } 23029 23030 if (obj) { 23031 if ((typeof ArrayBuffer !== 'undefined' && 23032 obj.buffer instanceof ArrayBuffer) || 'length' in obj) { 23033 if (typeof obj.length !== 'number' || isnan(obj.length)) { 23034 return createBuffer(that, 0) 23035 } 23036 return fromArrayLike(that, obj) 23037 } 23038 23039 if (obj.type === 'Buffer' && isArray(obj.data)) { 23040 return fromArrayLike(that, obj.data) 23041 } 23042 } 23043 23044 throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') 23045 } 23046 23047 function checked (length) { 23048 // Note: cannot use `length < kMaxLength()` here because that fails when 23049 // length is NaN (which is otherwise coerced to zero.) 23050 if (length >= kMaxLength()) { 23051 throw new RangeError('Attempt to allocate Buffer larger than maximum ' + 23052 'size: 0x' + kMaxLength().toString(16) + ' bytes') 23053 } 23054 return length | 0 23055 } 23056 23057 function SlowBuffer (length) { 23058 if (+length != length) { // eslint-disable-line eqeqeq 23059 length = 0 23060 } 23061 return Buffer.alloc(+length) 23062 } 23063 23064 Buffer.isBuffer = function isBuffer (b) { 23065 return !!(b != null && b._isBuffer) 23066 } 23067 23068 Buffer.compare = function compare (a, b) { 23069 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { 23070 throw new TypeError('Arguments must be Buffers') 23071 } 23072 23073 if (a === b) return 0 23074 23075 var x = a.length 23076 var y = b.length 23077 23078 for (var i = 0, len = Math.min(x, y); i < len; ++i) { 23079 if (a[i] !== b[i]) { 23080 x = a[i] 23081 y = b[i] 23082 break 23083 } 23084 } 23085 23086 if (x < y) return -1 23087 if (y < x) return 1 23088 return 0 23089 } 23090 23091 Buffer.isEncoding = function isEncoding (encoding) { 23092 switch (String(encoding).toLowerCase()) { 23093 case 'hex': 23094 case 'utf8': 23095 case 'utf-8': 23096 case 'ascii': 23097 case 'latin1': 23098 case 'binary': 23099 case 'base64': 23100 case 'ucs2': 23101 case 'ucs-2': 23102 case 'utf16le': 23103 case 'utf-16le': 23104 return true 23105 default: 23106 return false 23107 } 23108 } 23109 23110 Buffer.concat = function concat (list, length) { 23111 if (!isArray(list)) { 23112 throw new TypeError('"list" argument must be an Array of Buffers') 23113 } 23114 23115 if (list.length === 0) { 23116 return Buffer.alloc(0) 23117 } 23118 23119 var i 23120 if (length === undefined) { 23121 length = 0 23122 for (i = 0; i < list.length; ++i) { 23123 length += list[i].length 23124 } 23125 } 23126 23127 var buffer = Buffer.allocUnsafe(length) 23128 var pos = 0 23129 for (i = 0; i < list.length; ++i) { 23130 var buf = list[i] 23131 if (!Buffer.isBuffer(buf)) { 23132 throw new TypeError('"list" argument must be an Array of Buffers') 23133 } 23134 buf.copy(buffer, pos) 23135 pos += buf.length 23136 } 23137 return buffer 23138 } 23139 23140 function byteLength (string, encoding) { 23141 if (Buffer.isBuffer(string)) { 23142 return string.length 23143 } 23144 if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && 23145 (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { 23146 return string.byteLength 23147 } 23148 if (typeof string !== 'string') { 23149 string = '' + string 23150 } 23151 23152 var len = string.length 23153 if (len === 0) return 0 23154 23155 // Use a for loop to avoid recursion 23156 var loweredCase = false 23157 for (;;) { 23158 switch (encoding) { 23159 case 'ascii': 23160 case 'latin1': 23161 case 'binary': 23162 return len 23163 case 'utf8': 23164 case 'utf-8': 23165 case undefined: 23166 return utf8ToBytes(string).length 23167 case 'ucs2': 23168 case 'ucs-2': 23169 case 'utf16le': 23170 case 'utf-16le': 23171 return len * 2 23172 case 'hex': 23173 return len >>> 1 23174 case 'base64': 23175 return base64ToBytes(string).length 23176 default: 23177 if (loweredCase) return utf8ToBytes(string).length // assume utf8 23178 encoding = ('' + encoding).toLowerCase() 23179 loweredCase = true 23180 } 23181 } 23182 } 23183 Buffer.byteLength = byteLength 23184 23185 function slowToString (encoding, start, end) { 23186 var loweredCase = false 23187 23188 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only 23189 // property of a typed array. 23190 23191 // This behaves neither like String nor Uint8Array in that we set start/end 23192 // to their upper/lower bounds if the value passed is out of range. 23193 // undefined is handled specially as per ECMA-262 6th Edition, 23194 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. 23195 if (start === undefined || start < 0) { 23196 start = 0 23197 } 23198 // Return early if start > this.length. Done here to prevent potential uint32 23199 // coercion fail below. 23200 if (start > this.length) { 23201 return '' 23202 } 23203 23204 if (end === undefined || end > this.length) { 23205 end = this.length 23206 } 23207 23208 if (end <= 0) { 23209 return '' 23210 } 23211 23212 // Force coersion to uint32. This will also coerce falsey/NaN values to 0. 23213 end >>>= 0 23214 start >>>= 0 23215 23216 if (end <= start) { 23217 return '' 23218 } 23219 23220 if (!encoding) encoding = 'utf8' 23221 23222 while (true) { 23223 switch (encoding) { 23224 case 'hex': 23225 return hexSlice(this, start, end) 23226 23227 case 'utf8': 23228 case 'utf-8': 23229 return utf8Slice(this, start, end) 23230 23231 case 'ascii': 23232 return asciiSlice(this, start, end) 23233 23234 case 'latin1': 23235 case 'binary': 23236 return latin1Slice(this, start, end) 23237 23238 case 'base64': 23239 return base64Slice(this, start, end) 23240 23241 case 'ucs2': 23242 case 'ucs-2': 23243 case 'utf16le': 23244 case 'utf-16le': 23245 return utf16leSlice(this, start, end) 23246 23247 default: 23248 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) 23249 encoding = (encoding + '').toLowerCase() 23250 loweredCase = true 23251 } 23252 } 23253 } 23254 23255 // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect 23256 // Buffer instances. 23257 Buffer.prototype._isBuffer = true 23258 23259 function swap (b, n, m) { 23260 var i = b[n] 23261 b[n] = b[m] 23262 b[m] = i 23263 } 23264 23265 Buffer.prototype.swap16 = function swap16 () { 23266 var len = this.length 23267 if (len % 2 !== 0) { 23268 throw new RangeError('Buffer size must be a multiple of 16-bits') 23269 } 23270 for (var i = 0; i < len; i += 2) { 23271 swap(this, i, i + 1) 23272 } 23273 return this 23274 } 23275 23276 Buffer.prototype.swap32 = function swap32 () { 23277 var len = this.length 23278 if (len % 4 !== 0) { 23279 throw new RangeError('Buffer size must be a multiple of 32-bits') 23280 } 23281 for (var i = 0; i < len; i += 4) { 23282 swap(this, i, i + 3) 23283 swap(this, i + 1, i + 2) 23284 } 23285 return this 23286 } 23287 23288 Buffer.prototype.swap64 = function swap64 () { 23289 var len = this.length 23290 if (len % 8 !== 0) { 23291 throw new RangeError('Buffer size must be a multiple of 64-bits') 23292 } 23293 for (var i = 0; i < len; i += 8) { 23294 swap(this, i, i + 7) 23295 swap(this, i + 1, i + 6) 23296 swap(this, i + 2, i + 5) 23297 swap(this, i + 3, i + 4) 23298 } 23299 return this 23300 } 23301 23302 Buffer.prototype.toString = function toString () { 23303 var length = this.length | 0 23304 if (length === 0) return '' 23305 if (arguments.length === 0) return utf8Slice(this, 0, length) 23306 return slowToString.apply(this, arguments) 23307 } 23308 23309 Buffer.prototype.equals = function equals (b) { 23310 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') 23311 if (this === b) return true 23312 return Buffer.compare(this, b) === 0 23313 } 23314 23315 Buffer.prototype.inspect = function inspect () { 23316 var str = '' 23317 var max = exports.INSPECT_MAX_BYTES 23318 if (this.length > 0) { 23319 str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') 23320 if (this.length > max) str += ' ... ' 23321 } 23322 return '<Buffer ' + str + '>' 23323 } 23324 23325 Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { 23326 if (!Buffer.isBuffer(target)) { 23327 throw new TypeError('Argument must be a Buffer') 23328 } 23329 23330 if (start === undefined) { 23331 start = 0 23332 } 23333 if (end === undefined) { 23334 end = target ? target.length : 0 23335 } 23336 if (thisStart === undefined) { 23337 thisStart = 0 23338 } 23339 if (thisEnd === undefined) { 23340 thisEnd = this.length 23341 } 23342 23343 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { 23344 throw new RangeError('out of range index') 23345 } 23346 23347 if (thisStart >= thisEnd && start >= end) { 23348 return 0 23349 } 23350 if (thisStart >= thisEnd) { 23351 return -1 23352 } 23353 if (start >= end) { 23354 return 1 23355 } 23356 23357 start >>>= 0 23358 end >>>= 0 23359 thisStart >>>= 0 23360 thisEnd >>>= 0 23361 23362 if (this === target) return 0 23363 23364 var x = thisEnd - thisStart 23365 var y = end - start 23366 var len = Math.min(x, y) 23367 23368 var thisCopy = this.slice(thisStart, thisEnd) 23369 var targetCopy = target.slice(start, end) 23370 23371 for (var i = 0; i < len; ++i) { 23372 if (thisCopy[i] !== targetCopy[i]) { 23373 x = thisCopy[i] 23374 y = targetCopy[i] 23375 break 23376 } 23377 } 23378 23379 if (x < y) return -1 23380 if (y < x) return 1 23381 return 0 23382 } 23383 23384 // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, 23385 // OR the last index of `val` in `buffer` at offset <= `byteOffset`. 23386 // 23387 // Arguments: 23388 // - buffer - a Buffer to search 23389 // - val - a string, Buffer, or number 23390 // - byteOffset - an index into `buffer`; will be clamped to an int32 23391 // - encoding - an optional encoding, relevant is val is a string 23392 // - dir - true for indexOf, false for lastIndexOf 23393 function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { 23394 // Empty buffer means no match 23395 if (buffer.length === 0) return -1 23396 23397 // Normalize byteOffset 23398 if (typeof byteOffset === 'string') { 23399 encoding = byteOffset 23400 byteOffset = 0 23401 } else if (byteOffset > 0x7fffffff) { 23402 byteOffset = 0x7fffffff 23403 } else if (byteOffset < -0x80000000) { 23404 byteOffset = -0x80000000 23405 } 23406 byteOffset = +byteOffset // Coerce to Number. 23407 if (isNaN(byteOffset)) { 23408 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer 23409 byteOffset = dir ? 0 : (buffer.length - 1) 23410 } 23411 23412 // Normalize byteOffset: negative offsets start from the end of the buffer 23413 if (byteOffset < 0) byteOffset = buffer.length + byteOffset 23414 if (byteOffset >= buffer.length) { 23415 if (dir) return -1 23416 else byteOffset = buffer.length - 1 23417 } else if (byteOffset < 0) { 23418 if (dir) byteOffset = 0 23419 else return -1 23420 } 23421 23422 // Normalize val 23423 if (typeof val === 'string') { 23424 val = Buffer.from(val, encoding) 23425 } 23426 23427 // Finally, search either indexOf (if dir is true) or lastIndexOf 23428 if (Buffer.isBuffer(val)) { 23429 // Special case: looking for empty string/buffer always fails 23430 if (val.length === 0) { 23431 return -1 23432 } 23433 return arrayIndexOf(buffer, val, byteOffset, encoding, dir) 23434 } else if (typeof val === 'number') { 23435 val = val & 0xFF // Search for a byte value [0-255] 23436 if (Buffer.TYPED_ARRAY_SUPPORT && 23437 typeof Uint8Array.prototype.indexOf === 'function') { 23438 if (dir) { 23439 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) 23440 } else { 23441 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) 23442 } 23443 } 23444 return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) 23445 } 23446 23447 throw new TypeError('val must be string, number or Buffer') 23448 } 23449 23450 function arrayIndexOf (arr, val, byteOffset, encoding, dir) { 23451 var indexSize = 1 23452 var arrLength = arr.length 23453 var valLength = val.length 23454 23455 if (encoding !== undefined) { 23456 encoding = String(encoding).toLowerCase() 23457 if (encoding === 'ucs2' || encoding === 'ucs-2' || 23458 encoding === 'utf16le' || encoding === 'utf-16le') { 23459 if (arr.length < 2 || val.length < 2) { 23460 return -1 23461 } 23462 indexSize = 2 23463 arrLength /= 2 23464 valLength /= 2 23465 byteOffset /= 2 23466 } 23467 } 23468 23469 function read (buf, i) { 23470 if (indexSize === 1) { 23471 return buf[i] 23472 } else { 23473 return buf.readUInt16BE(i * indexSize) 23474 } 23475 } 23476 23477 var i 23478 if (dir) { 23479 var foundIndex = -1 23480 for (i = byteOffset; i < arrLength; i++) { 23481 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { 23482 if (foundIndex === -1) foundIndex = i 23483 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize 23484 } else { 23485 if (foundIndex !== -1) i -= i - foundIndex 23486 foundIndex = -1 23487 } 23488 } 23489 } else { 23490 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength 23491 for (i = byteOffset; i >= 0; i--) { 23492 var found = true 23493 for (var j = 0; j < valLength; j++) { 23494 if (read(arr, i + j) !== read(val, j)) { 23495 found = false 23496 break 23497 } 23498 } 23499 if (found) return i 23500 } 23501 } 23502 23503 return -1 23504 } 23505 23506 Buffer.prototype.includes = function includes (val, byteOffset, encoding) { 23507 return this.indexOf(val, byteOffset, encoding) !== -1 23508 } 23509 23510 Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { 23511 return bidirectionalIndexOf(this, val, byteOffset, encoding, true) 23512 } 23513 23514 Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { 23515 return bidirectionalIndexOf(this, val, byteOffset, encoding, false) 23516 } 23517 23518 function hexWrite (buf, string, offset, length) { 23519 offset = Number(offset) || 0 23520 var remaining = buf.length - offset 23521 if (!length) { 23522 length = remaining 23523 } else { 23524 length = Number(length) 23525 if (length > remaining) { 23526 length = remaining 23527 } 23528 } 23529 23530 // must be an even number of digits 23531 var strLen = string.length 23532 if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') 23533 23534 if (length > strLen / 2) { 23535 length = strLen / 2 23536 } 23537 for (var i = 0; i < length; ++i) { 23538 var parsed = parseInt(string.substr(i * 2, 2), 16) 23539 if (isNaN(parsed)) return i 23540 buf[offset + i] = parsed 23541 } 23542 return i 23543 } 23544 23545 function utf8Write (buf, string, offset, length) { 23546 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) 23547 } 23548 23549 function asciiWrite (buf, string, offset, length) { 23550 return blitBuffer(asciiToBytes(string), buf, offset, length) 23551 } 23552 23553 function latin1Write (buf, string, offset, length) { 23554 return asciiWrite(buf, string, offset, length) 23555 } 23556 23557 function base64Write (buf, string, offset, length) { 23558 return blitBuffer(base64ToBytes(string), buf, offset, length) 23559 } 23560 23561 function ucs2Write (buf, string, offset, length) { 23562 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) 23563 } 23564 23565 Buffer.prototype.write = function write (string, offset, length, encoding) { 23566 // Buffer#write(string) 23567 if (offset === undefined) { 23568 encoding = 'utf8' 23569 length = this.length 23570 offset = 0 23571 // Buffer#write(string, encoding) 23572 } else if (length === undefined && typeof offset === 'string') { 23573 encoding = offset 23574 length = this.length 23575 offset = 0 23576 // Buffer#write(string, offset[, length][, encoding]) 23577 } else if (isFinite(offset)) { 23578 offset = offset | 0 23579 if (isFinite(length)) { 23580 length = length | 0 23581 if (encoding === undefined) encoding = 'utf8' 23582 } else { 23583 encoding = length 23584 length = undefined 23585 } 23586 // legacy write(string, encoding, offset, length) - remove in v0.13 23587 } else { 23588 throw new Error( 23589 'Buffer.write(string, encoding, offset[, length]) is no longer supported' 23590 ) 23591 } 23592 23593 var remaining = this.length - offset 23594 if (length === undefined || length > remaining) length = remaining 23595 23596 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { 23597 throw new RangeError('Attempt to write outside buffer bounds') 23598 } 23599 23600 if (!encoding) encoding = 'utf8' 23601 23602 var loweredCase = false 23603 for (;;) { 23604 switch (encoding) { 23605 case 'hex': 23606 return hexWrite(this, string, offset, length) 23607 23608 case 'utf8': 23609 case 'utf-8': 23610 return utf8Write(this, string, offset, length) 23611 23612 case 'ascii': 23613 return asciiWrite(this, string, offset, length) 23614 23615 case 'latin1': 23616 case 'binary': 23617 return latin1Write(this, string, offset, length) 23618 23619 case 'base64': 23620 // Warning: maxLength not taken into account in base64Write 23621 return base64Write(this, string, offset, length) 23622 23623 case 'ucs2': 23624 case 'ucs-2': 23625 case 'utf16le': 23626 case 'utf-16le': 23627 return ucs2Write(this, string, offset, length) 23628 23629 default: 23630 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) 23631 encoding = ('' + encoding).toLowerCase() 23632 loweredCase = true 23633 } 23634 } 23635 } 23636 23637 Buffer.prototype.toJSON = function toJSON () { 23638 return { 23639 type: 'Buffer', 23640 data: Array.prototype.slice.call(this._arr || this, 0) 23641 } 23642 } 23643 23644 function base64Slice (buf, start, end) { 23645 if (start === 0 && end === buf.length) { 23646 return base64.fromByteArray(buf) 23647 } else { 23648 return base64.fromByteArray(buf.slice(start, end)) 23649 } 23650 } 23651 23652 function utf8Slice (buf, start, end) { 23653 end = Math.min(buf.length, end) 23654 var res = [] 23655 23656 var i = start 23657 while (i < end) { 23658 var firstByte = buf[i] 23659 var codePoint = null 23660 var bytesPerSequence = (firstByte > 0xEF) ? 4 23661 : (firstByte > 0xDF) ? 3 23662 : (firstByte > 0xBF) ? 2 23663 : 1 23664 23665 if (i + bytesPerSequence <= end) { 23666 var secondByte, thirdByte, fourthByte, tempCodePoint 23667 23668 switch (bytesPerSequence) { 23669 case 1: 23670 if (firstByte < 0x80) { 23671 codePoint = firstByte 23672 } 23673 break 23674 case 2: 23675 secondByte = buf[i + 1] 23676 if ((secondByte & 0xC0) === 0x80) { 23677 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) 23678 if (tempCodePoint > 0x7F) { 23679 codePoint = tempCodePoint 23680 } 23681 } 23682 break 23683 case 3: 23684 secondByte = buf[i + 1] 23685 thirdByte = buf[i + 2] 23686 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { 23687 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) 23688 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { 23689 codePoint = tempCodePoint 23690 } 23691 } 23692 break 23693 case 4: 23694 secondByte = buf[i + 1] 23695 thirdByte = buf[i + 2] 23696 fourthByte = buf[i + 3] 23697 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { 23698 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) 23699 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { 23700 codePoint = tempCodePoint 23701 } 23702 } 23703 } 23704 } 23705 23706 if (codePoint === null) { 23707 // we did not generate a valid codePoint so insert a 23708 // replacement char (U+FFFD) and advance only 1 byte 23709 codePoint = 0xFFFD 23710 bytesPerSequence = 1 23711 } else if (codePoint > 0xFFFF) { 23712 // encode to utf16 (surrogate pair dance) 23713 codePoint -= 0x10000 23714 res.push(codePoint >>> 10 & 0x3FF | 0xD800) 23715 codePoint = 0xDC00 | codePoint & 0x3FF 23716 } 23717 23718 res.push(codePoint) 23719 i += bytesPerSequence 23720 } 23721 23722 return decodeCodePointsArray(res) 23723 } 23724 23725 // Based on http://stackoverflow.com/a/22747272/680742, the browser with 23726 // the lowest limit is Chrome, with 0x10000 args. 23727 // We go 1 magnitude less, for safety 23728 var MAX_ARGUMENTS_LENGTH = 0x1000 23729 23730 function decodeCodePointsArray (codePoints) { 23731 var len = codePoints.length 23732 if (len <= MAX_ARGUMENTS_LENGTH) { 23733 return String.fromCharCode.apply(String, codePoints) // avoid extra slice() 23734 } 23735 23736 // Decode in chunks to avoid "call stack size exceeded". 23737 var res = '' 23738 var i = 0 23739 while (i < len) { 23740 res += String.fromCharCode.apply( 23741 String, 23742 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) 23743 ) 23744 } 23745 return res 23746 } 23747 23748 function asciiSlice (buf, start, end) { 23749 var ret = '' 23750 end = Math.min(buf.length, end) 23751 23752 for (var i = start; i < end; ++i) { 23753 ret += String.fromCharCode(buf[i] & 0x7F) 23754 } 23755 return ret 23756 } 23757 23758 function latin1Slice (buf, start, end) { 23759 var ret = '' 23760 end = Math.min(buf.length, end) 23761 23762 for (var i = start; i < end; ++i) { 23763 ret += String.fromCharCode(buf[i]) 23764 } 23765 return ret 23766 } 23767 23768 function hexSlice (buf, start, end) { 23769 var len = buf.length 23770 23771 if (!start || start < 0) start = 0 23772 if (!end || end < 0 || end > len) end = len 23773 23774 var out = '' 23775 for (var i = start; i < end; ++i) { 23776 out += toHex(buf[i]) 23777 } 23778 return out 23779 } 23780 23781 function utf16leSlice (buf, start, end) { 23782 var bytes = buf.slice(start, end) 23783 var res = '' 23784 for (var i = 0; i < bytes.length; i += 2) { 23785 res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) 23786 } 23787 return res 23788 } 23789 23790 Buffer.prototype.slice = function slice (start, end) { 23791 var len = this.length 23792 start = ~~start 23793 end = end === undefined ? len : ~~end 23794 23795 if (start < 0) { 23796 start += len 23797 if (start < 0) start = 0 23798 } else if (start > len) { 23799 start = len 23800 } 23801 23802 if (end < 0) { 23803 end += len 23804 if (end < 0) end = 0 23805 } else if (end > len) { 23806 end = len 23807 } 23808 23809 if (end < start) end = start 23810 23811 var newBuf 23812 if (Buffer.TYPED_ARRAY_SUPPORT) { 23813 newBuf = this.subarray(start, end) 23814 newBuf.__proto__ = Buffer.prototype 23815 } else { 23816 var sliceLen = end - start 23817 newBuf = new Buffer(sliceLen, undefined) 23818 for (var i = 0; i < sliceLen; ++i) { 23819 newBuf[i] = this[i + start] 23820 } 23821 } 23822 23823 return newBuf 23824 } 23825 23826 /* 23827 * Need to make sure that buffer isn't trying to write out of bounds. 23828 */ 23829 function checkOffset (offset, ext, length) { 23830 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') 23831 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') 23832 } 23833 23834 Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { 23835 offset = offset | 0 23836 byteLength = byteLength | 0 23837 if (!noAssert) checkOffset(offset, byteLength, this.length) 23838 23839 var val = this[offset] 23840 var mul = 1 23841 var i = 0 23842 while (++i < byteLength && (mul *= 0x100)) { 23843 val += this[offset + i] * mul 23844 } 23845 23846 return val 23847 } 23848 23849 Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { 23850 offset = offset | 0 23851 byteLength = byteLength | 0 23852 if (!noAssert) { 23853 checkOffset(offset, byteLength, this.length) 23854 } 23855 23856 var val = this[offset + --byteLength] 23857 var mul = 1 23858 while (byteLength > 0 && (mul *= 0x100)) { 23859 val += this[offset + --byteLength] * mul 23860 } 23861 23862 return val 23863 } 23864 23865 Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { 23866 if (!noAssert) checkOffset(offset, 1, this.length) 23867 return this[offset] 23868 } 23869 23870 Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { 23871 if (!noAssert) checkOffset(offset, 2, this.length) 23872 return this[offset] | (this[offset + 1] << 8) 23873 } 23874 23875 Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { 23876 if (!noAssert) checkOffset(offset, 2, this.length) 23877 return (this[offset] << 8) | this[offset + 1] 23878 } 23879 23880 Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { 23881 if (!noAssert) checkOffset(offset, 4, this.length) 23882 23883 return ((this[offset]) | 23884 (this[offset + 1] << 8) | 23885 (this[offset + 2] << 16)) + 23886 (this[offset + 3] * 0x1000000) 23887 } 23888 23889 Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { 23890 if (!noAssert) checkOffset(offset, 4, this.length) 23891 23892 return (this[offset] * 0x1000000) + 23893 ((this[offset + 1] << 16) | 23894 (this[offset + 2] << 8) | 23895 this[offset + 3]) 23896 } 23897 23898 Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { 23899 offset = offset | 0 23900 byteLength = byteLength | 0 23901 if (!noAssert) checkOffset(offset, byteLength, this.length) 23902 23903 var val = this[offset] 23904 var mul = 1 23905 var i = 0 23906 while (++i < byteLength && (mul *= 0x100)) { 23907 val += this[offset + i] * mul 23908 } 23909 mul *= 0x80 23910 23911 if (val >= mul) val -= Math.pow(2, 8 * byteLength) 23912 23913 return val 23914 } 23915 23916 Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { 23917 offset = offset | 0 23918 byteLength = byteLength | 0 23919 if (!noAssert) checkOffset(offset, byteLength, this.length) 23920 23921 var i = byteLength 23922 var mul = 1 23923 var val = this[offset + --i] 23924 while (i > 0 && (mul *= 0x100)) { 23925 val += this[offset + --i] * mul 23926 } 23927 mul *= 0x80 23928 23929 if (val >= mul) val -= Math.pow(2, 8 * byteLength) 23930 23931 return val 23932 } 23933 23934 Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { 23935 if (!noAssert) checkOffset(offset, 1, this.length) 23936 if (!(this[offset] & 0x80)) return (this[offset]) 23937 return ((0xff - this[offset] + 1) * -1) 23938 } 23939 23940 Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { 23941 if (!noAssert) checkOffset(offset, 2, this.length) 23942 var val = this[offset] | (this[offset + 1] << 8) 23943 return (val & 0x8000) ? val | 0xFFFF0000 : val 23944 } 23945 23946 Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { 23947 if (!noAssert) checkOffset(offset, 2, this.length) 23948 var val = this[offset + 1] | (this[offset] << 8) 23949 return (val & 0x8000) ? val | 0xFFFF0000 : val 23950 } 23951 23952 Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { 23953 if (!noAssert) checkOffset(offset, 4, this.length) 23954 23955 return (this[offset]) | 23956 (this[offset + 1] << 8) | 23957 (this[offset + 2] << 16) | 23958 (this[offset + 3] << 24) 23959 } 23960 23961 Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { 23962 if (!noAssert) checkOffset(offset, 4, this.length) 23963 23964 return (this[offset] << 24) | 23965 (this[offset + 1] << 16) | 23966 (this[offset + 2] << 8) | 23967 (this[offset + 3]) 23968 } 23969 23970 Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { 23971 if (!noAssert) checkOffset(offset, 4, this.length) 23972 return ieee754.read(this, offset, true, 23, 4) 23973 } 23974 23975 Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { 23976 if (!noAssert) checkOffset(offset, 4, this.length) 23977 return ieee754.read(this, offset, false, 23, 4) 23978 } 23979 23980 Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { 23981 if (!noAssert) checkOffset(offset, 8, this.length) 23982 return ieee754.read(this, offset, true, 52, 8) 23983 } 23984 23985 Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { 23986 if (!noAssert) checkOffset(offset, 8, this.length) 23987 return ieee754.read(this, offset, false, 52, 8) 23988 } 23989 23990 function checkInt (buf, value, offset, ext, max, min) { 23991 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') 23992 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') 23993 if (offset + ext > buf.length) throw new RangeError('Index out of range') 23994 } 23995 23996 Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { 23997 value = +value 23998 offset = offset | 0 23999 byteLength = byteLength | 0 24000 if (!noAssert) { 24001 var maxBytes = Math.pow(2, 8 * byteLength) - 1 24002 checkInt(this, value, offset, byteLength, maxBytes, 0) 24003 } 24004 24005 var mul = 1 24006 var i = 0 24007 this[offset] = value & 0xFF 24008 while (++i < byteLength && (mul *= 0x100)) { 24009 this[offset + i] = (value / mul) & 0xFF 24010 } 24011 24012 return offset + byteLength 24013 } 24014 24015 Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { 24016 value = +value 24017 offset = offset | 0 24018 byteLength = byteLength | 0 24019 if (!noAssert) { 24020 var maxBytes = Math.pow(2, 8 * byteLength) - 1 24021 checkInt(this, value, offset, byteLength, maxBytes, 0) 24022 } 24023 24024 var i = byteLength - 1 24025 var mul = 1 24026 this[offset + i] = value & 0xFF 24027 while (--i >= 0 && (mul *= 0x100)) { 24028 this[offset + i] = (value / mul) & 0xFF 24029 } 24030 24031 return offset + byteLength 24032 } 24033 24034 Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { 24035 value = +value 24036 offset = offset | 0 24037 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) 24038 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) 24039 this[offset] = (value & 0xff) 24040 return offset + 1 24041 } 24042 24043 function objectWriteUInt16 (buf, value, offset, littleEndian) { 24044 if (value < 0) value = 0xffff + value + 1 24045 for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { 24046 buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> 24047 (littleEndian ? i : 1 - i) * 8 24048 } 24049 } 24050 24051 Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { 24052 value = +value 24053 offset = offset | 0 24054 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) 24055 if (Buffer.TYPED_ARRAY_SUPPORT) { 24056 this[offset] = (value & 0xff) 24057 this[offset + 1] = (value >>> 8) 24058 } else { 24059 objectWriteUInt16(this, value, offset, true) 24060 } 24061 return offset + 2 24062 } 24063 24064 Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { 24065 value = +value 24066 offset = offset | 0 24067 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) 24068 if (Buffer.TYPED_ARRAY_SUPPORT) { 24069 this[offset] = (value >>> 8) 24070 this[offset + 1] = (value & 0xff) 24071 } else { 24072 objectWriteUInt16(this, value, offset, false) 24073 } 24074 return offset + 2 24075 } 24076 24077 function objectWriteUInt32 (buf, value, offset, littleEndian) { 24078 if (value < 0) value = 0xffffffff + value + 1 24079 for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { 24080 buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff 24081 } 24082 } 24083 24084 Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { 24085 value = +value 24086 offset = offset | 0 24087 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) 24088 if (Buffer.TYPED_ARRAY_SUPPORT) { 24089 this[offset + 3] = (value >>> 24) 24090 this[offset + 2] = (value >>> 16) 24091 this[offset + 1] = (value >>> 8) 24092 this[offset] = (value & 0xff) 24093 } else { 24094 objectWriteUInt32(this, value, offset, true) 24095 } 24096 return offset + 4 24097 } 24098 24099 Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { 24100 value = +value 24101 offset = offset | 0 24102 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) 24103 if (Buffer.TYPED_ARRAY_SUPPORT) { 24104 this[offset] = (value >>> 24) 24105 this[offset + 1] = (value >>> 16) 24106 this[offset + 2] = (value >>> 8) 24107 this[offset + 3] = (value & 0xff) 24108 } else { 24109 objectWriteUInt32(this, value, offset, false) 24110 } 24111 return offset + 4 24112 } 24113 24114 Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { 24115 value = +value 24116 offset = offset | 0 24117 if (!noAssert) { 24118 var limit = Math.pow(2, 8 * byteLength - 1) 24119 24120 checkInt(this, value, offset, byteLength, limit - 1, -limit) 24121 } 24122 24123 var i = 0 24124 var mul = 1 24125 var sub = 0 24126 this[offset] = value & 0xFF 24127 while (++i < byteLength && (mul *= 0x100)) { 24128 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { 24129 sub = 1 24130 } 24131 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF 24132 } 24133 24134 return offset + byteLength 24135 } 24136 24137 Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { 24138 value = +value 24139 offset = offset | 0 24140 if (!noAssert) { 24141 var limit = Math.pow(2, 8 * byteLength - 1) 24142 24143 checkInt(this, value, offset, byteLength, limit - 1, -limit) 24144 } 24145 24146 var i = byteLength - 1 24147 var mul = 1 24148 var sub = 0 24149 this[offset + i] = value & 0xFF 24150 while (--i >= 0 && (mul *= 0x100)) { 24151 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { 24152 sub = 1 24153 } 24154 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF 24155 } 24156 24157 return offset + byteLength 24158 } 24159 24160 Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { 24161 value = +value 24162 offset = offset | 0 24163 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) 24164 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) 24165 if (value < 0) value = 0xff + value + 1 24166 this[offset] = (value & 0xff) 24167 return offset + 1 24168 } 24169 24170 Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { 24171 value = +value 24172 offset = offset | 0 24173 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) 24174 if (Buffer.TYPED_ARRAY_SUPPORT) { 24175 this[offset] = (value & 0xff) 24176 this[offset + 1] = (value >>> 8) 24177 } else { 24178 objectWriteUInt16(this, value, offset, true) 24179 } 24180 return offset + 2 24181 } 24182 24183 Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { 24184 value = +value 24185 offset = offset | 0 24186 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) 24187 if (Buffer.TYPED_ARRAY_SUPPORT) { 24188 this[offset] = (value >>> 8) 24189 this[offset + 1] = (value & 0xff) 24190 } else { 24191 objectWriteUInt16(this, value, offset, false) 24192 } 24193 return offset + 2 24194 } 24195 24196 Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { 24197 value = +value 24198 offset = offset | 0 24199 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) 24200 if (Buffer.TYPED_ARRAY_SUPPORT) { 24201 this[offset] = (value & 0xff) 24202 this[offset + 1] = (value >>> 8) 24203 this[offset + 2] = (value >>> 16) 24204 this[offset + 3] = (value >>> 24) 24205 } else { 24206 objectWriteUInt32(this, value, offset, true) 24207 } 24208 return offset + 4 24209 } 24210 24211 Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { 24212 value = +value 24213 offset = offset | 0 24214 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) 24215 if (value < 0) value = 0xffffffff + value + 1 24216 if (Buffer.TYPED_ARRAY_SUPPORT) { 24217 this[offset] = (value >>> 24) 24218 this[offset + 1] = (value >>> 16) 24219 this[offset + 2] = (value >>> 8) 24220 this[offset + 3] = (value & 0xff) 24221 } else { 24222 objectWriteUInt32(this, value, offset, false) 24223 } 24224 return offset + 4 24225 } 24226 24227 function checkIEEE754 (buf, value, offset, ext, max, min) { 24228 if (offset + ext > buf.length) throw new RangeError('Index out of range') 24229 if (offset < 0) throw new RangeError('Index out of range') 24230 } 24231 24232 function writeFloat (buf, value, offset, littleEndian, noAssert) { 24233 if (!noAssert) { 24234 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) 24235 } 24236 ieee754.write(buf, value, offset, littleEndian, 23, 4) 24237 return offset + 4 24238 } 24239 24240 Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { 24241 return writeFloat(this, value, offset, true, noAssert) 24242 } 24243 24244 Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { 24245 return writeFloat(this, value, offset, false, noAssert) 24246 } 24247 24248 function writeDouble (buf, value, offset, littleEndian, noAssert) { 24249 if (!noAssert) { 24250 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) 24251 } 24252 ieee754.write(buf, value, offset, littleEndian, 52, 8) 24253 return offset + 8 24254 } 24255 24256 Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { 24257 return writeDouble(this, value, offset, true, noAssert) 24258 } 24259 24260 Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { 24261 return writeDouble(this, value, offset, false, noAssert) 24262 } 24263 24264 // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) 24265 Buffer.prototype.copy = function copy (target, targetStart, start, end) { 24266 if (!start) start = 0 24267 if (!end && end !== 0) end = this.length 24268 if (targetStart >= target.length) targetStart = target.length 24269 if (!targetStart) targetStart = 0 24270 if (end > 0 && end < start) end = start 24271 24272 // Copy 0 bytes; we're done 24273 if (end === start) return 0 24274 if (target.length === 0 || this.length === 0) return 0 24275 24276 // Fatal error conditions 24277 if (targetStart < 0) { 24278 throw new RangeError('targetStart out of bounds') 24279 } 24280 if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') 24281 if (end < 0) throw new RangeError('sourceEnd out of bounds') 24282 24283 // Are we oob? 24284 if (end > this.length) end = this.length 24285 if (target.length - targetStart < end - start) { 24286 end = target.length - targetStart + start 24287 } 24288 24289 var len = end - start 24290 var i 24291 24292 if (this === target && start < targetStart && targetStart < end) { 24293 // descending copy from end 24294 for (i = len - 1; i >= 0; --i) { 24295 target[i + targetStart] = this[i + start] 24296 } 24297 } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { 24298 // ascending copy from start 24299 for (i = 0; i < len; ++i) { 24300 target[i + targetStart] = this[i + start] 24301 } 24302 } else { 24303 Uint8Array.prototype.set.call( 24304 target, 24305 this.subarray(start, start + len), 24306 targetStart 24307 ) 24308 } 24309 24310 return len 24311 } 24312 24313 // Usage: 24314 // buffer.fill(number[, offset[, end]]) 24315 // buffer.fill(buffer[, offset[, end]]) 24316 // buffer.fill(string[, offset[, end]][, encoding]) 24317 Buffer.prototype.fill = function fill (val, start, end, encoding) { 24318 // Handle string cases: 24319 if (typeof val === 'string') { 24320 if (typeof start === 'string') { 24321 encoding = start 24322 start = 0 24323 end = this.length 24324 } else if (typeof end === 'string') { 24325 encoding = end 24326 end = this.length 24327 } 24328 if (val.length === 1) { 24329 var code = val.charCodeAt(0) 24330 if (code < 256) { 24331 val = code 24332 } 24333 } 24334 if (encoding !== undefined && typeof encoding !== 'string') { 24335 throw new TypeError('encoding must be a string') 24336 } 24337 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { 24338 throw new TypeError('Unknown encoding: ' + encoding) 24339 } 24340 } else if (typeof val === 'number') { 24341 val = val & 255 24342 } 24343 24344 // Invalid ranges are not set to a default, so can range check early. 24345 if (start < 0 || this.length < start || this.length < end) { 24346 throw new RangeError('Out of range index') 24347 } 24348 24349 if (end <= start) { 24350 return this 24351 } 24352 24353 start = start >>> 0 24354 end = end === undefined ? this.length : end >>> 0 24355 24356 if (!val) val = 0 24357 24358 var i 24359 if (typeof val === 'number') { 24360 for (i = start; i < end; ++i) { 24361 this[i] = val 24362 } 24363 } else { 24364 var bytes = Buffer.isBuffer(val) 24365 ? val 24366 : utf8ToBytes(new Buffer(val, encoding).toString()) 24367 var len = bytes.length 24368 for (i = 0; i < end - start; ++i) { 24369 this[i + start] = bytes[i % len] 24370 } 24371 } 24372 24373 return this 24374 } 24375 24376 // HELPER FUNCTIONS 24377 // ================ 24378 24379 var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g 24380 24381 function base64clean (str) { 24382 // Node strips out invalid characters like \n and \t from the string, base64-js does not 24383 str = stringtrim(str).replace(INVALID_BASE64_RE, '') 24384 // Node converts strings with length < 2 to '' 24385 if (str.length < 2) return '' 24386 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not 24387 while (str.length % 4 !== 0) { 24388 str = str + '=' 24389 } 24390 return str 24391 } 24392 24393 function stringtrim (str) { 24394 if (str.trim) return str.trim() 24395 return str.replace(/^\s+|\s+$/g, '') 24396 } 24397 24398 function toHex (n) { 24399 if (n < 16) return '0' + n.toString(16) 24400 return n.toString(16) 24401 } 24402 24403 function utf8ToBytes (string, units) { 24404 units = units || Infinity 24405 var codePoint 24406 var length = string.length 24407 var leadSurrogate = null 24408 var bytes = [] 24409 24410 for (var i = 0; i < length; ++i) { 24411 codePoint = string.charCodeAt(i) 24412 24413 // is surrogate component 24414 if (codePoint > 0xD7FF && codePoint < 0xE000) { 24415 // last char was a lead 24416 if (!leadSurrogate) { 24417 // no lead yet 24418 if (codePoint > 0xDBFF) { 24419 // unexpected trail 24420 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) 24421 continue 24422 } else if (i + 1 === length) { 24423 // unpaired lead 24424 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) 24425 continue 24426 } 24427 24428 // valid lead 24429 leadSurrogate = codePoint 24430 24431 continue 24432 } 24433 24434 // 2 leads in a row 24435 if (codePoint < 0xDC00) { 24436 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) 24437 leadSurrogate = codePoint 24438 continue 24439 } 24440 24441 // valid surrogate pair 24442 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 24443 } else if (leadSurrogate) { 24444 // valid bmp char, but last char was a lead 24445 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) 24446 } 24447 24448 leadSurrogate = null 24449 24450 // encode utf8 24451 if (codePoint < 0x80) { 24452 if ((units -= 1) < 0) break 24453 bytes.push(codePoint) 24454 } else if (codePoint < 0x800) { 24455 if ((units -= 2) < 0) break 24456 bytes.push( 24457 codePoint >> 0x6 | 0xC0, 24458 codePoint & 0x3F | 0x80 24459 ) 24460 } else if (codePoint < 0x10000) { 24461 if ((units -= 3) < 0) break 24462 bytes.push( 24463 codePoint >> 0xC | 0xE0, 24464 codePoint >> 0x6 & 0x3F | 0x80, 24465 codePoint & 0x3F | 0x80 24466 ) 24467 } else if (codePoint < 0x110000) { 24468 if ((units -= 4) < 0) break 24469 bytes.push( 24470 codePoint >> 0x12 | 0xF0, 24471 codePoint >> 0xC & 0x3F | 0x80, 24472 codePoint >> 0x6 & 0x3F | 0x80, 24473 codePoint & 0x3F | 0x80 24474 ) 24475 } else { 24476 throw new Error('Invalid code point') 24477 } 24478 } 24479 24480 return bytes 24481 } 24482 24483 function asciiToBytes (str) { 24484 var byteArray = [] 24485 for (var i = 0; i < str.length; ++i) { 24486 // Node's code seems to be doing this and not & 0x7F.. 24487 byteArray.push(str.charCodeAt(i) & 0xFF) 24488 } 24489 return byteArray 24490 } 24491 24492 function utf16leToBytes (str, units) { 24493 var c, hi, lo 24494 var byteArray = [] 24495 for (var i = 0; i < str.length; ++i) { 24496 if ((units -= 2) < 0) break 24497 24498 c = str.charCodeAt(i) 24499 hi = c >> 8 24500 lo = c % 256 24501 byteArray.push(lo) 24502 byteArray.push(hi) 24503 } 24504 24505 return byteArray 24506 } 24507 24508 function base64ToBytes (str) { 24509 return base64.toByteArray(base64clean(str)) 24510 } 24511 24512 function blitBuffer (src, dst, offset, length) { 24513 for (var i = 0; i < length; ++i) { 24514 if ((i + offset >= dst.length) || (i >= src.length)) break 24515 dst[i + offset] = src[i] 24516 } 24517 return i 24518 } 24519 24520 function isnan (val) { 24521 return val !== val // eslint-disable-line no-self-compare 24522 } 24523 24524 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(143).Buffer, (function() { return this; }()))) 24525 24526 /***/ }, 24527 /* 144 */ 24528 /***/ function(module, exports) { 24529 24530 'use strict' 24531 24532 exports.byteLength = byteLength 24533 exports.toByteArray = toByteArray 24534 exports.fromByteArray = fromByteArray 24535 24536 var lookup = [] 24537 var revLookup = [] 24538 var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array 24539 24540 var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' 24541 for (var i = 0, len = code.length; i < len; ++i) { 24542 lookup[i] = code[i] 24543 revLookup[code.charCodeAt(i)] = i 24544 } 24545 24546 revLookup['-'.charCodeAt(0)] = 62 24547 revLookup['_'.charCodeAt(0)] = 63 24548 24549 function placeHoldersCount (b64) { 24550 var len = b64.length 24551 if (len % 4 > 0) { 24552 throw new Error('Invalid string. Length must be a multiple of 4') 24553 } 24554 24555 // the number of equal signs (place holders) 24556 // if there are two placeholders, than the two characters before it 24557 // represent one byte 24558 // if there is only one, then the three characters before it represent 2 bytes 24559 // this is just a cheap hack to not do indexOf twice 24560 return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 24561 } 24562 24563 function byteLength (b64) { 24564 // base64 is 4/3 + up to two characters of the original data 24565 return b64.length * 3 / 4 - placeHoldersCount(b64) 24566 } 24567 24568 function toByteArray (b64) { 24569 var i, j, l, tmp, placeHolders, arr 24570 var len = b64.length 24571 placeHolders = placeHoldersCount(b64) 24572 24573 arr = new Arr(len * 3 / 4 - placeHolders) 24574 24575 // if there are placeholders, only get up to the last complete 4 chars 24576 l = placeHolders > 0 ? len - 4 : len 24577 24578 var L = 0 24579 24580 for (i = 0, j = 0; i < l; i += 4, j += 3) { 24581 tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] 24582 arr[L++] = (tmp >> 16) & 0xFF 24583 arr[L++] = (tmp >> 8) & 0xFF 24584 arr[L++] = tmp & 0xFF 24585 } 24586 24587 if (placeHolders === 2) { 24588 tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) 24589 arr[L++] = tmp & 0xFF 24590 } else if (placeHolders === 1) { 24591 tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) 24592 arr[L++] = (tmp >> 8) & 0xFF 24593 arr[L++] = tmp & 0xFF 24594 } 24595 24596 return arr 24597 } 24598 24599 function tripletToBase64 (num) { 24600 return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] 24601 } 24602 24603 function encodeChunk (uint8, start, end) { 24604 var tmp 24605 var output = [] 24606 for (var i = start; i < end; i += 3) { 24607 tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) 24608 output.push(tripletToBase64(tmp)) 24609 } 24610 return output.join('') 24611 } 24612 24613 function fromByteArray (uint8) { 24614 var tmp 24615 var len = uint8.length 24616 var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes 24617 var output = '' 24618 var parts = [] 24619 var maxChunkLength = 16383 // must be multiple of 3 24620 24621 // go through the array every three bytes, we'll deal with trailing stuff later 24622 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { 24623 parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) 24624 } 24625 24626 // pad the end with zeros, but make sure to not forget the extra bytes 24627 if (extraBytes === 1) { 24628 tmp = uint8[len - 1] 24629 output += lookup[tmp >> 2] 24630 output += lookup[(tmp << 4) & 0x3F] 24631 output += '==' 24632 } else if (extraBytes === 2) { 24633 tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) 24634 output += lookup[tmp >> 10] 24635 output += lookup[(tmp >> 4) & 0x3F] 24636 output += lookup[(tmp << 2) & 0x3F] 24637 output += '=' 24638 } 24639 24640 parts.push(output) 24641 24642 return parts.join('') 24643 } 24644 24645 24646 /***/ }, 24647 /* 145 */ 24648 /***/ function(module, exports) { 24649 24650 exports.read = function (buffer, offset, isLE, mLen, nBytes) { 24651 var e, m 24652 var eLen = nBytes * 8 - mLen - 1 24653 var eMax = (1 << eLen) - 1 24654 var eBias = eMax >> 1 24655 var nBits = -7 24656 var i = isLE ? (nBytes - 1) : 0 24657 var d = isLE ? -1 : 1 24658 var s = buffer[offset + i] 24659 24660 i += d 24661 24662 e = s & ((1 << (-nBits)) - 1) 24663 s >>= (-nBits) 24664 nBits += eLen 24665 for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} 24666 24667 m = e & ((1 << (-nBits)) - 1) 24668 e >>= (-nBits) 24669 nBits += mLen 24670 for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} 24671 24672 if (e === 0) { 24673 e = 1 - eBias 24674 } else if (e === eMax) { 24675 return m ? NaN : ((s ? -1 : 1) * Infinity) 24676 } else { 24677 m = m + Math.pow(2, mLen) 24678 e = e - eBias 24679 } 24680 return (s ? -1 : 1) * m * Math.pow(2, e - mLen) 24681 } 24682 24683 exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { 24684 var e, m, c 24685 var eLen = nBytes * 8 - mLen - 1 24686 var eMax = (1 << eLen) - 1 24687 var eBias = eMax >> 1 24688 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) 24689 var i = isLE ? 0 : (nBytes - 1) 24690 var d = isLE ? 1 : -1 24691 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 24692 24693 value = Math.abs(value) 24694 24695 if (isNaN(value) || value === Infinity) { 24696 m = isNaN(value) ? 1 : 0 24697 e = eMax 24698 } else { 24699 e = Math.floor(Math.log(value) / Math.LN2) 24700 if (value * (c = Math.pow(2, -e)) < 1) { 24701 e-- 24702 c *= 2 24703 } 24704 if (e + eBias >= 1) { 24705 value += rt / c 24706 } else { 24707 value += rt * Math.pow(2, 1 - eBias) 24708 } 24709 if (value * c >= 2) { 24710 e++ 24711 c /= 2 24712 } 24713 24714 if (e + eBias >= eMax) { 24715 m = 0 24716 e = eMax 24717 } else if (e + eBias >= 1) { 24718 m = (value * c - 1) * Math.pow(2, mLen) 24719 e = e + eBias 24720 } else { 24721 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) 24722 e = 0 24723 } 24724 } 24725 24726 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} 24727 24728 e = (e << mLen) | m 24729 eLen += mLen 24730 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} 24731 24732 buffer[offset + i - d] |= s * 128 24733 } 24734 24735 24736 /***/ }, 24737 /* 146 */ 24738 /***/ function(module, exports) { 24739 24740 var toString = {}.toString; 24741 24742 module.exports = Array.isArray || function (arr) { 24743 return toString.call(arr) == '[object Array]'; 24744 }; 24745 24746 24747 /***/ }, 24748 /* 147 */ 24749 /***/ function(module, exports, __webpack_require__) { 24750 24751 'use strict'; 24752 24753 var Type = __webpack_require__(129); 24754 24755 var _hasOwnProperty = Object.prototype.hasOwnProperty; 24756 var _toString = Object.prototype.toString; 24757 24758 function resolveYamlOmap(data) { 24759 if (data === null) return true; 24760 24761 var objectKeys = [], index, length, pair, pairKey, pairHasKey, 24762 object = data; 24763 24764 for (index = 0, length = object.length; index < length; index += 1) { 24765 pair = object[index]; 24766 pairHasKey = false; 24767 24768 if (_toString.call(pair) !== '[object Object]') return false; 24769 24770 for (pairKey in pair) { 24771 if (_hasOwnProperty.call(pair, pairKey)) { 24772 if (!pairHasKey) pairHasKey = true; 24773 else return false; 24774 } 24775 } 24776 24777 if (!pairHasKey) return false; 24778 24779 if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey); 24780 else return false; 24781 } 24782 24783 return true; 24784 } 24785 24786 function constructYamlOmap(data) { 24787 return data !== null ? data : []; 24788 } 24789 24790 module.exports = new Type('tag:yaml.org,2002:omap', { 24791 kind: 'sequence', 24792 resolve: resolveYamlOmap, 24793 construct: constructYamlOmap 24794 }); 24795 24796 24797 /***/ }, 24798 /* 148 */ 24799 /***/ function(module, exports, __webpack_require__) { 24800 24801 'use strict'; 24802 24803 var Type = __webpack_require__(129); 24804 24805 var _toString = Object.prototype.toString; 24806 24807 function resolveYamlPairs(data) { 24808 if (data === null) return true; 24809 24810 var index, length, pair, keys, result, 24811 object = data; 24812 24813 result = new Array(object.length); 24814 24815 for (index = 0, length = object.length; index < length; index += 1) { 24816 pair = object[index]; 24817 24818 if (_toString.call(pair) !== '[object Object]') return false; 24819 24820 keys = Object.keys(pair); 24821 24822 if (keys.length !== 1) return false; 24823 24824 result[index] = [ keys[0], pair[keys[0]] ]; 24825 } 24826 24827 return true; 24828 } 24829 24830 function constructYamlPairs(data) { 24831 if (data === null) return []; 24832 24833 var index, length, pair, keys, result, 24834 object = data; 24835 24836 result = new Array(object.length); 24837 24838 for (index = 0, length = object.length; index < length; index += 1) { 24839 pair = object[index]; 24840 24841 keys = Object.keys(pair); 24842 24843 result[index] = [ keys[0], pair[keys[0]] ]; 24844 } 24845 24846 return result; 24847 } 24848 24849 module.exports = new Type('tag:yaml.org,2002:pairs', { 24850 kind: 'sequence', 24851 resolve: resolveYamlPairs, 24852 construct: constructYamlPairs 24853 }); 24854 24855 24856 /***/ }, 24857 /* 149 */ 24858 /***/ function(module, exports, __webpack_require__) { 24859 24860 'use strict'; 24861 24862 var Type = __webpack_require__(129); 24863 24864 var _hasOwnProperty = Object.prototype.hasOwnProperty; 24865 24866 function resolveYamlSet(data) { 24867 if (data === null) return true; 24868 24869 var key, object = data; 24870 24871 for (key in object) { 24872 if (_hasOwnProperty.call(object, key)) { 24873 if (object[key] !== null) return false; 24874 } 24875 } 24876 24877 return true; 24878 } 24879 24880 function constructYamlSet(data) { 24881 return data !== null ? data : {}; 24882 } 24883 24884 module.exports = new Type('tag:yaml.org,2002:set', { 24885 kind: 'mapping', 24886 resolve: resolveYamlSet, 24887 construct: constructYamlSet 24888 }); 24889 24890 24891 /***/ }, 24892 /* 150 */ 24893 /***/ function(module, exports, __webpack_require__) { 24894 24895 // JS-YAML's default schema for `load` function. 24896 // It is not described in the YAML specification. 24897 // 24898 // This schema is based on JS-YAML's default safe schema and includes 24899 // JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function. 24900 // 24901 // Also this schema is used as default base schema at `Schema.create` function. 24902 24903 24904 'use strict'; 24905 24906 24907 var Schema = __webpack_require__(128); 24908 24909 24910 module.exports = Schema.DEFAULT = new Schema({ 24911 include: [ 24912 __webpack_require__(127) 24913 ], 24914 explicit: [ 24915 __webpack_require__(151), 24916 __webpack_require__(152), 24917 __webpack_require__(153) 24918 ] 24919 }); 24920 24921 24922 /***/ }, 24923 /* 151 */ 24924 /***/ function(module, exports, __webpack_require__) { 24925 24926 'use strict'; 24927 24928 var Type = __webpack_require__(129); 24929 24930 function resolveJavascriptUndefined() { 24931 return true; 24932 } 24933 24934 function constructJavascriptUndefined() { 24935 /*eslint-disable no-undefined*/ 24936 return undefined; 24937 } 24938 24939 function representJavascriptUndefined() { 24940 return ''; 24941 } 24942 24943 function isUndefined(object) { 24944 return typeof object === 'undefined'; 24945 } 24946 24947 module.exports = new Type('tag:yaml.org,2002:js/undefined', { 24948 kind: 'scalar', 24949 resolve: resolveJavascriptUndefined, 24950 construct: constructJavascriptUndefined, 24951 predicate: isUndefined, 24952 represent: representJavascriptUndefined 24953 }); 24954 24955 24956 /***/ }, 24957 /* 152 */ 24958 /***/ function(module, exports, __webpack_require__) { 24959 24960 'use strict'; 24961 24962 var Type = __webpack_require__(129); 24963 24964 function resolveJavascriptRegExp(data) { 24965 if (data === null) return false; 24966 if (data.length === 0) return false; 24967 24968 var regexp = data, 24969 tail = /\/([gim]*)$/.exec(data), 24970 modifiers = ''; 24971 24972 // if regexp starts with '/' it can have modifiers and must be properly closed 24973 // `/foo/gim` - modifiers tail can be maximum 3 chars 24974 if (regexp[0] === '/') { 24975 if (tail) modifiers = tail[1]; 24976 24977 if (modifiers.length > 3) return false; 24978 // if expression starts with /, is should be properly terminated 24979 if (regexp[regexp.length - modifiers.length - 1] !== '/') return false; 24980 } 24981 24982 return true; 24983 } 24984 24985 function constructJavascriptRegExp(data) { 24986 var regexp = data, 24987 tail = /\/([gim]*)$/.exec(data), 24988 modifiers = ''; 24989 24990 // `/foo/gim` - tail can be maximum 4 chars 24991 if (regexp[0] === '/') { 24992 if (tail) modifiers = tail[1]; 24993 regexp = regexp.slice(1, regexp.length - modifiers.length - 1); 24994 } 24995 24996 return new RegExp(regexp, modifiers); 24997 } 24998 24999 function representJavascriptRegExp(object /*, style*/) { 25000 var result = '/' + object.source + '/'; 25001 25002 if (object.global) result += 'g'; 25003 if (object.multiline) result += 'm'; 25004 if (object.ignoreCase) result += 'i'; 25005 25006 return result; 25007 } 25008 25009 function isRegExp(object) { 25010 return Object.prototype.toString.call(object) === '[object RegExp]'; 25011 } 25012 25013 module.exports = new Type('tag:yaml.org,2002:js/regexp', { 25014 kind: 'scalar', 25015 resolve: resolveJavascriptRegExp, 25016 construct: constructJavascriptRegExp, 25017 predicate: isRegExp, 25018 represent: representJavascriptRegExp 25019 }); 25020 25021 25022 /***/ }, 25023 /* 153 */ 25024 /***/ function(module, exports, __webpack_require__) { 25025 25026 var require;'use strict'; 25027 25028 var esprima; 25029 25030 // Browserified version does not have esprima 25031 // 25032 // 1. For node.js just require module as deps 25033 // 2. For browser try to require mudule via external AMD system. 25034 // If not found - try to fallback to window.esprima. If not 25035 // found too - then fail to parse. 25036 // 25037 try { 25038 // workaround to exclude package from browserify list. 25039 var _require = require; 25040 esprima = __webpack_require__(154); 25041 } catch (_) { 25042 /*global window */ 25043 if (typeof window !== 'undefined') esprima = window.esprima; 25044 } 25045 25046 var Type = __webpack_require__(129); 25047 25048 function resolveJavascriptFunction(data) { 25049 if (data === null) return false; 25050 25051 try { 25052 var source = '(' + data + ')', 25053 ast = esprima.parse(source, { range: true }); 25054 25055 if (ast.type !== 'Program' || 25056 ast.body.length !== 1 || 25057 ast.body[0].type !== 'ExpressionStatement' || 25058 ast.body[0].expression.type !== 'FunctionExpression') { 25059 return false; 25060 } 25061 25062 return true; 25063 } catch (err) { 25064 return false; 25065 } 25066 } 25067 25068 function constructJavascriptFunction(data) { 25069 /*jslint evil:true*/ 25070 25071 var source = '(' + data + ')', 25072 ast = esprima.parse(source, { range: true }), 25073 params = [], 25074 body; 25075 25076 if (ast.type !== 'Program' || 25077 ast.body.length !== 1 || 25078 ast.body[0].type !== 'ExpressionStatement' || 25079 ast.body[0].expression.type !== 'FunctionExpression') { 25080 throw new Error('Failed to resolve function'); 25081 } 25082 25083 ast.body[0].expression.params.forEach(function (param) { 25084 params.push(param.name); 25085 }); 25086 25087 body = ast.body[0].expression.body.range; 25088 25089 // Esprima's ranges include the first '{' and the last '}' characters on 25090 // function expressions. So cut them out. 25091 /*eslint-disable no-new-func*/ 25092 return new Function(params, source.slice(body[0] + 1, body[1] - 1)); 25093 } 25094 25095 function representJavascriptFunction(object /*, style*/) { 25096 return object.toString(); 25097 } 25098 25099 function isFunction(object) { 25100 return Object.prototype.toString.call(object) === '[object Function]'; 25101 } 25102 25103 module.exports = new Type('tag:yaml.org,2002:js/function', { 25104 kind: 'scalar', 25105 resolve: resolveJavascriptFunction, 25106 construct: constructJavascriptFunction, 25107 predicate: isFunction, 25108 represent: representJavascriptFunction 25109 }); 25110 25111 25112 /***/ }, 25113 /* 154 */ 25114 /***/ function(module, exports, __webpack_require__) { 25115 25116 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* 25117 Copyright (c) jQuery Foundation, Inc. and Contributors, All Rights Reserved. 25118 25119 Redistribution and use in source and binary forms, with or without 25120 modification, are permitted provided that the following conditions are met: 25121 25122 * Redistributions of source code must retain the above copyright 25123 notice, this list of conditions and the following disclaimer. 25124 * Redistributions in binary form must reproduce the above copyright 25125 notice, this list of conditions and the following disclaimer in the 25126 documentation and/or other materials provided with the distribution. 25127 25128 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25129 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25130 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25131 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY 25132 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25133 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25134 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25135 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25136 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25137 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25138 */ 25139 25140 (function (root, factory) { 25141 'use strict'; 25142 25143 // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, 25144 // Rhino, and plain browser loading. 25145 25146 /* istanbul ignore next */ 25147 if (true) { 25148 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 25149 } else if (typeof exports !== 'undefined') { 25150 factory(exports); 25151 } else { 25152 factory((root.esprima = {})); 25153 } 25154 }(this, function (exports) { 25155 'use strict'; 25156 25157 var Token, 25158 TokenName, 25159 FnExprTokens, 25160 Syntax, 25161 PlaceHolders, 25162 Messages, 25163 Regex, 25164 source, 25165 strict, 25166 index, 25167 lineNumber, 25168 lineStart, 25169 hasLineTerminator, 25170 lastIndex, 25171 lastLineNumber, 25172 lastLineStart, 25173 startIndex, 25174 startLineNumber, 25175 startLineStart, 25176 scanning, 25177 length, 25178 lookahead, 25179 state, 25180 extra, 25181 isBindingElement, 25182 isAssignmentTarget, 25183 firstCoverInitializedNameError; 25184 25185 Token = { 25186 BooleanLiteral: 1, 25187 EOF: 2, 25188 Identifier: 3, 25189 Keyword: 4, 25190 NullLiteral: 5, 25191 NumericLiteral: 6, 25192 Punctuator: 7, 25193 StringLiteral: 8, 25194 RegularExpression: 9, 25195 Template: 10 25196 }; 25197 25198 TokenName = {}; 25199 TokenName[Token.BooleanLiteral] = 'Boolean'; 25200 TokenName[Token.EOF] = '<end>'; 25201 TokenName[Token.Identifier] = 'Identifier'; 25202 TokenName[Token.Keyword] = 'Keyword'; 25203 TokenName[Token.NullLiteral] = 'Null'; 25204 TokenName[Token.NumericLiteral] = 'Numeric'; 25205 TokenName[Token.Punctuator] = 'Punctuator'; 25206 TokenName[Token.StringLiteral] = 'String'; 25207 TokenName[Token.RegularExpression] = 'RegularExpression'; 25208 TokenName[Token.Template] = 'Template'; 25209 25210 // A function following one of those tokens is an expression. 25211 FnExprTokens = ['(', '{', '[', 'in', 'typeof', 'instanceof', 'new', 25212 'return', 'case', 'delete', 'throw', 'void', 25213 // assignment operators 25214 '=', '+=', '-=', '*=', '/=', '%=', '<<=', '>>=', '>>>=', 25215 '&=', '|=', '^=', ',', 25216 // binary/unary operators 25217 '+', '-', '*', '/', '%', '++', '--', '<<', '>>', '>>>', '&', 25218 '|', '^', '!', '~', '&&', '||', '?', ':', '===', '==', '>=', 25219 '<=', '<', '>', '!=', '!==']; 25220 25221 Syntax = { 25222 AssignmentExpression: 'AssignmentExpression', 25223 AssignmentPattern: 'AssignmentPattern', 25224 ArrayExpression: 'ArrayExpression', 25225 ArrayPattern: 'ArrayPattern', 25226 ArrowFunctionExpression: 'ArrowFunctionExpression', 25227 BlockStatement: 'BlockStatement', 25228 BinaryExpression: 'BinaryExpression', 25229 BreakStatement: 'BreakStatement', 25230 CallExpression: 'CallExpression', 25231 CatchClause: 'CatchClause', 25232 ClassBody: 'ClassBody', 25233 ClassDeclaration: 'ClassDeclaration', 25234 ClassExpression: 'ClassExpression', 25235 ConditionalExpression: 'ConditionalExpression', 25236 ContinueStatement: 'ContinueStatement', 25237 DoWhileStatement: 'DoWhileStatement', 25238 DebuggerStatement: 'DebuggerStatement', 25239 EmptyStatement: 'EmptyStatement', 25240 ExportAllDeclaration: 'ExportAllDeclaration', 25241 ExportDefaultDeclaration: 'ExportDefaultDeclaration', 25242 ExportNamedDeclaration: 'ExportNamedDeclaration', 25243 ExportSpecifier: 'ExportSpecifier', 25244 ExpressionStatement: 'ExpressionStatement', 25245 ForStatement: 'ForStatement', 25246 ForOfStatement: 'ForOfStatement', 25247 ForInStatement: 'ForInStatement', 25248 FunctionDeclaration: 'FunctionDeclaration', 25249 FunctionExpression: 'FunctionExpression', 25250 Identifier: 'Identifier', 25251 IfStatement: 'IfStatement', 25252 ImportDeclaration: 'ImportDeclaration', 25253 ImportDefaultSpecifier: 'ImportDefaultSpecifier', 25254 ImportNamespaceSpecifier: 'ImportNamespaceSpecifier', 25255 ImportSpecifier: 'ImportSpecifier', 25256 Literal: 'Literal', 25257 LabeledStatement: 'LabeledStatement', 25258 LogicalExpression: 'LogicalExpression', 25259 MemberExpression: 'MemberExpression', 25260 MetaProperty: 'MetaProperty', 25261 MethodDefinition: 'MethodDefinition', 25262 NewExpression: 'NewExpression', 25263 ObjectExpression: 'ObjectExpression', 25264 ObjectPattern: 'ObjectPattern', 25265 Program: 'Program', 25266 Property: 'Property', 25267 RestElement: 'RestElement', 25268 ReturnStatement: 'ReturnStatement', 25269 SequenceExpression: 'SequenceExpression', 25270 SpreadElement: 'SpreadElement', 25271 Super: 'Super', 25272 SwitchCase: 'SwitchCase', 25273 SwitchStatement: 'SwitchStatement', 25274 TaggedTemplateExpression: 'TaggedTemplateExpression', 25275 TemplateElement: 'TemplateElement', 25276 TemplateLiteral: 'TemplateLiteral', 25277 ThisExpression: 'ThisExpression', 25278 ThrowStatement: 'ThrowStatement', 25279 TryStatement: 'TryStatement', 25280 UnaryExpression: 'UnaryExpression', 25281 UpdateExpression: 'UpdateExpression', 25282 VariableDeclaration: 'VariableDeclaration', 25283 VariableDeclarator: 'VariableDeclarator', 25284 WhileStatement: 'WhileStatement', 25285 WithStatement: 'WithStatement', 25286 YieldExpression: 'YieldExpression' 25287 }; 25288 25289 PlaceHolders = { 25290 ArrowParameterPlaceHolder: 'ArrowParameterPlaceHolder' 25291 }; 25292 25293 // Error messages should be identical to V8. 25294 Messages = { 25295 UnexpectedToken: 'Unexpected token %0', 25296 UnexpectedNumber: 'Unexpected number', 25297 UnexpectedString: 'Unexpected string', 25298 UnexpectedIdentifier: 'Unexpected identifier', 25299 UnexpectedReserved: 'Unexpected reserved word', 25300 UnexpectedTemplate: 'Unexpected quasi %0', 25301 UnexpectedEOS: 'Unexpected end of input', 25302 NewlineAfterThrow: 'Illegal newline after throw', 25303 InvalidRegExp: 'Invalid regular expression', 25304 UnterminatedRegExp: 'Invalid regular expression: missing /', 25305 InvalidLHSInAssignment: 'Invalid left-hand side in assignment', 25306 InvalidLHSInForIn: 'Invalid left-hand side in for-in', 25307 InvalidLHSInForLoop: 'Invalid left-hand side in for-loop', 25308 MultipleDefaultsInSwitch: 'More than one default clause in switch statement', 25309 NoCatchOrFinally: 'Missing catch or finally after try', 25310 UnknownLabel: 'Undefined label \'%0\'', 25311 Redeclaration: '%0 \'%1\' has already been declared', 25312 IllegalContinue: 'Illegal continue statement', 25313 IllegalBreak: 'Illegal break statement', 25314 IllegalReturn: 'Illegal return statement', 25315 StrictModeWith: 'Strict mode code may not include a with statement', 25316 StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode', 25317 StrictVarName: 'Variable name may not be eval or arguments in strict mode', 25318 StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode', 25319 StrictParamDupe: 'Strict mode function may not have duplicate parameter names', 25320 StrictFunctionName: 'Function name may not be eval or arguments in strict mode', 25321 StrictOctalLiteral: 'Octal literals are not allowed in strict mode.', 25322 StrictDelete: 'Delete of an unqualified identifier in strict mode.', 25323 StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode', 25324 StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode', 25325 StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode', 25326 StrictReservedWord: 'Use of future reserved word in strict mode', 25327 TemplateOctalLiteral: 'Octal literals are not allowed in template strings.', 25328 ParameterAfterRestParameter: 'Rest parameter must be last formal parameter', 25329 DefaultRestParameter: 'Unexpected token =', 25330 ObjectPatternAsRestParameter: 'Unexpected token {', 25331 DuplicateProtoProperty: 'Duplicate __proto__ fields are not allowed in object literals', 25332 ConstructorSpecialMethod: 'Class constructor may not be an accessor', 25333 DuplicateConstructor: 'A class may only have one constructor', 25334 StaticPrototype: 'Classes may not have static property named prototype', 25335 MissingFromClause: 'Unexpected token', 25336 NoAsAfterImportNamespace: 'Unexpected token', 25337 InvalidModuleSpecifier: 'Unexpected token', 25338 IllegalImportDeclaration: 'Unexpected token', 25339 IllegalExportDeclaration: 'Unexpected token', 25340 DuplicateBinding: 'Duplicate binding %0' 25341 }; 25342 25343 // See also tools/generate-unicode-regex.js. 25344 Regex = { 25345 // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierStart: 25346 NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDE00-\uDE11\uDE13-\uDE2B\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDE00-\uDE2F\uDE44\uDE80-\uDEAA]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]/, 25347 25348 // ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierPart: 25349 NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B2\u08E4-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDD0-\uDDDA\uDE00-\uDE11\uDE13-\uDE37\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF01-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|\uD809[\uDC00-\uDC6E]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/ 25350 }; 25351 25352 // Ensure the condition is true, otherwise throw an error. 25353 // This is only to have a better contract semantic, i.e. another safety net 25354 // to catch a logic error. The condition shall be fulfilled in normal case. 25355 // Do NOT use this to enforce a certain condition on any user input. 25356 25357 function assert(condition, message) { 25358 /* istanbul ignore if */ 25359 if (!condition) { 25360 throw new Error('ASSERT: ' + message); 25361 } 25362 } 25363 25364 function isDecimalDigit(ch) { 25365 return (ch >= 0x30 && ch <= 0x39); // 0..9 25366 } 25367 25368 function isHexDigit(ch) { 25369 return '0123456789abcdefABCDEF'.indexOf(ch) >= 0; 25370 } 25371 25372 function isOctalDigit(ch) { 25373 return '01234567'.indexOf(ch) >= 0; 25374 } 25375 25376 function octalToDecimal(ch) { 25377 // \0 is not octal escape sequence 25378 var octal = (ch !== '0'), code = '01234567'.indexOf(ch); 25379 25380 if (index < length && isOctalDigit(source[index])) { 25381 octal = true; 25382 code = code * 8 + '01234567'.indexOf(source[index++]); 25383 25384 // 3 digits are only allowed when string starts 25385 // with 0, 1, 2, 3 25386 if ('0123'.indexOf(ch) >= 0 && 25387 index < length && 25388 isOctalDigit(source[index])) { 25389 code = code * 8 + '01234567'.indexOf(source[index++]); 25390 } 25391 } 25392 25393 return { 25394 code: code, 25395 octal: octal 25396 }; 25397 } 25398 25399 // ECMA-262 11.2 White Space 25400 25401 function isWhiteSpace(ch) { 25402 return (ch === 0x20) || (ch === 0x09) || (ch === 0x0B) || (ch === 0x0C) || (ch === 0xA0) || 25403 (ch >= 0x1680 && [0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF].indexOf(ch) >= 0); 25404 } 25405 25406 // ECMA-262 11.3 Line Terminators 25407 25408 function isLineTerminator(ch) { 25409 return (ch === 0x0A) || (ch === 0x0D) || (ch === 0x2028) || (ch === 0x2029); 25410 } 25411 25412 // ECMA-262 11.6 Identifier Names and Identifiers 25413 25414 function fromCodePoint(cp) { 25415 return (cp < 0x10000) ? String.fromCharCode(cp) : 25416 String.fromCharCode(0xD800 + ((cp - 0x10000) >> 10)) + 25417 String.fromCharCode(0xDC00 + ((cp - 0x10000) & 1023)); 25418 } 25419 25420 function isIdentifierStart(ch) { 25421 return (ch === 0x24) || (ch === 0x5F) || // $ (dollar) and _ (underscore) 25422 (ch >= 0x41 && ch <= 0x5A) || // A..Z 25423 (ch >= 0x61 && ch <= 0x7A) || // a..z 25424 (ch === 0x5C) || // \ (backslash) 25425 ((ch >= 0x80) && Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch))); 25426 } 25427 25428 function isIdentifierPart(ch) { 25429 return (ch === 0x24) || (ch === 0x5F) || // $ (dollar) and _ (underscore) 25430 (ch >= 0x41 && ch <= 0x5A) || // A..Z 25431 (ch >= 0x61 && ch <= 0x7A) || // a..z 25432 (ch >= 0x30 && ch <= 0x39) || // 0..9 25433 (ch === 0x5C) || // \ (backslash) 25434 ((ch >= 0x80) && Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch))); 25435 } 25436 25437 // ECMA-262 11.6.2.2 Future Reserved Words 25438 25439 function isFutureReservedWord(id) { 25440 switch (id) { 25441 case 'enum': 25442 case 'export': 25443 case 'import': 25444 case 'super': 25445 return true; 25446 default: 25447 return false; 25448 } 25449 } 25450 25451 function isStrictModeReservedWord(id) { 25452 switch (id) { 25453 case 'implements': 25454 case 'interface': 25455 case 'package': 25456 case 'private': 25457 case 'protected': 25458 case 'public': 25459 case 'static': 25460 case 'yield': 25461 case 'let': 25462 return true; 25463 default: 25464 return false; 25465 } 25466 } 25467 25468 function isRestrictedWord(id) { 25469 return id === 'eval' || id === 'arguments'; 25470 } 25471 25472 // ECMA-262 11.6.2.1 Keywords 25473 25474 function isKeyword(id) { 25475 switch (id.length) { 25476 case 2: 25477 return (id === 'if') || (id === 'in') || (id === 'do'); 25478 case 3: 25479 return (id === 'var') || (id === 'for') || (id === 'new') || 25480 (id === 'try') || (id === 'let'); 25481 case 4: 25482 return (id === 'this') || (id === 'else') || (id === 'case') || 25483 (id === 'void') || (id === 'with') || (id === 'enum'); 25484 case 5: 25485 return (id === 'while') || (id === 'break') || (id === 'catch') || 25486 (id === 'throw') || (id === 'const') || (id === 'yield') || 25487 (id === 'class') || (id === 'super'); 25488 case 6: 25489 return (id === 'return') || (id === 'typeof') || (id === 'delete') || 25490 (id === 'switch') || (id === 'export') || (id === 'import'); 25491 case 7: 25492 return (id === 'default') || (id === 'finally') || (id === 'extends'); 25493 case 8: 25494 return (id === 'function') || (id === 'continue') || (id === 'debugger'); 25495 case 10: 25496 return (id === 'instanceof'); 25497 default: 25498 return false; 25499 } 25500 } 25501 25502 // ECMA-262 11.4 Comments 25503 25504 function addComment(type, value, start, end, loc) { 25505 var comment; 25506 25507 assert(typeof start === 'number', 'Comment must have valid position'); 25508 25509 state.lastCommentStart = start; 25510 25511 comment = { 25512 type: type, 25513 value: value 25514 }; 25515 if (extra.range) { 25516 comment.range = [start, end]; 25517 } 25518 if (extra.loc) { 25519 comment.loc = loc; 25520 } 25521 extra.comments.push(comment); 25522 if (extra.attachComment) { 25523 extra.leadingComments.push(comment); 25524 extra.trailingComments.push(comment); 25525 } 25526 if (extra.tokenize) { 25527 comment.type = comment.type + 'Comment'; 25528 if (extra.delegate) { 25529 comment = extra.delegate(comment); 25530 } 25531 extra.tokens.push(comment); 25532 } 25533 } 25534 25535 function skipSingleLineComment(offset) { 25536 var start, loc, ch, comment; 25537 25538 start = index - offset; 25539 loc = { 25540 start: { 25541 line: lineNumber, 25542 column: index - lineStart - offset 25543 } 25544 }; 25545 25546 while (index < length) { 25547 ch = source.charCodeAt(index); 25548 ++index; 25549 if (isLineTerminator(ch)) { 25550 hasLineTerminator = true; 25551 if (extra.comments) { 25552 comment = source.slice(start + offset, index - 1); 25553 loc.end = { 25554 line: lineNumber, 25555 column: index - lineStart - 1 25556 }; 25557 addComment('Line', comment, start, index - 1, loc); 25558 } 25559 if (ch === 13 && source.charCodeAt(index) === 10) { 25560 ++index; 25561 } 25562 ++lineNumber; 25563 lineStart = index; 25564 return; 25565 } 25566 } 25567 25568 if (extra.comments) { 25569 comment = source.slice(start + offset, index); 25570 loc.end = { 25571 line: lineNumber, 25572 column: index - lineStart 25573 }; 25574 addComment('Line', comment, start, index, loc); 25575 } 25576 } 25577 25578 function skipMultiLineComment() { 25579 var start, loc, ch, comment; 25580 25581 if (extra.comments) { 25582 start = index - 2; 25583 loc = { 25584 start: { 25585 line: lineNumber, 25586 column: index - lineStart - 2 25587 } 25588 }; 25589 } 25590 25591 while (index < length) { 25592 ch = source.charCodeAt(index); 25593 if (isLineTerminator(ch)) { 25594 if (ch === 0x0D && source.charCodeAt(index + 1) === 0x0A) { 25595 ++index; 25596 } 25597 hasLineTerminator = true; 25598 ++lineNumber; 25599 ++index; 25600 lineStart = index; 25601 } else if (ch === 0x2A) { 25602 // Block comment ends with '*/'. 25603 if (source.charCodeAt(index + 1) === 0x2F) { 25604 ++index; 25605 ++index; 25606 if (extra.comments) { 25607 comment = source.slice(start + 2, index - 2); 25608 loc.end = { 25609 line: lineNumber, 25610 column: index - lineStart 25611 }; 25612 addComment('Block', comment, start, index, loc); 25613 } 25614 return; 25615 } 25616 ++index; 25617 } else { 25618 ++index; 25619 } 25620 } 25621 25622 // Ran off the end of the file - the whole thing is a comment 25623 if (extra.comments) { 25624 loc.end = { 25625 line: lineNumber, 25626 column: index - lineStart 25627 }; 25628 comment = source.slice(start + 2, index); 25629 addComment('Block', comment, start, index, loc); 25630 } 25631 tolerateUnexpectedToken(); 25632 } 25633 25634 function skipComment() { 25635 var ch, start; 25636 hasLineTerminator = false; 25637 25638 start = (index === 0); 25639 while (index < length) { 25640 ch = source.charCodeAt(index); 25641 25642 if (isWhiteSpace(ch)) { 25643 ++index; 25644 } else if (isLineTerminator(ch)) { 25645 hasLineTerminator = true; 25646 ++index; 25647 if (ch === 0x0D && source.charCodeAt(index) === 0x0A) { 25648 ++index; 25649 } 25650 ++lineNumber; 25651 lineStart = index; 25652 start = true; 25653 } else if (ch === 0x2F) { // U+002F is '/' 25654 ch = source.charCodeAt(index + 1); 25655 if (ch === 0x2F) { 25656 ++index; 25657 ++index; 25658 skipSingleLineComment(2); 25659 start = true; 25660 } else if (ch === 0x2A) { // U+002A is '*' 25661 ++index; 25662 ++index; 25663 skipMultiLineComment(); 25664 } else { 25665 break; 25666 } 25667 } else if (start && ch === 0x2D) { // U+002D is '-' 25668 // U+003E is '>' 25669 if ((source.charCodeAt(index + 1) === 0x2D) && (source.charCodeAt(index + 2) === 0x3E)) { 25670 // '-->' is a single-line comment 25671 index += 3; 25672 skipSingleLineComment(3); 25673 } else { 25674 break; 25675 } 25676 } else if (ch === 0x3C) { // U+003C is '<' 25677 if (source.slice(index + 1, index + 4) === '!--') { 25678 ++index; // `<` 25679 ++index; // `!` 25680 ++index; // `-` 25681 ++index; // `-` 25682 skipSingleLineComment(4); 25683 } else { 25684 break; 25685 } 25686 } else { 25687 break; 25688 } 25689 } 25690 } 25691 25692 function scanHexEscape(prefix) { 25693 var i, len, ch, code = 0; 25694 25695 len = (prefix === 'u') ? 4 : 2; 25696 for (i = 0; i < len; ++i) { 25697 if (index < length && isHexDigit(source[index])) { 25698 ch = source[index++]; 25699 code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase()); 25700 } else { 25701 return ''; 25702 } 25703 } 25704 return String.fromCharCode(code); 25705 } 25706 25707 function scanUnicodeCodePointEscape() { 25708 var ch, code; 25709 25710 ch = source[index]; 25711 code = 0; 25712 25713 // At least, one hex digit is required. 25714 if (ch === '}') { 25715 throwUnexpectedToken(); 25716 } 25717 25718 while (index < length) { 25719 ch = source[index++]; 25720 if (!isHexDigit(ch)) { 25721 break; 25722 } 25723 code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase()); 25724 } 25725 25726 if (code > 0x10FFFF || ch !== '}') { 25727 throwUnexpectedToken(); 25728 } 25729 25730 return fromCodePoint(code); 25731 } 25732 25733 function codePointAt(i) { 25734 var cp, first, second; 25735 25736 cp = source.charCodeAt(i); 25737 if (cp >= 0xD800 && cp <= 0xDBFF) { 25738 second = source.charCodeAt(i + 1); 25739 if (second >= 0xDC00 && second <= 0xDFFF) { 25740 first = cp; 25741 cp = (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; 25742 } 25743 } 25744 25745 return cp; 25746 } 25747 25748 function getComplexIdentifier() { 25749 var cp, ch, id; 25750 25751 cp = codePointAt(index); 25752 id = fromCodePoint(cp); 25753 index += id.length; 25754 25755 // '\u' (U+005C, U+0075) denotes an escaped character. 25756 if (cp === 0x5C) { 25757 if (source.charCodeAt(index) !== 0x75) { 25758 throwUnexpectedToken(); 25759 } 25760 ++index; 25761 if (source[index] === '{') { 25762 ++index; 25763 ch = scanUnicodeCodePointEscape(); 25764 } else { 25765 ch = scanHexEscape('u'); 25766 cp = ch.charCodeAt(0); 25767 if (!ch || ch === '\\' || !isIdentifierStart(cp)) { 25768 throwUnexpectedToken(); 25769 } 25770 } 25771 id = ch; 25772 } 25773 25774 while (index < length) { 25775 cp = codePointAt(index); 25776 if (!isIdentifierPart(cp)) { 25777 break; 25778 } 25779 ch = fromCodePoint(cp); 25780 id += ch; 25781 index += ch.length; 25782 25783 // '\u' (U+005C, U+0075) denotes an escaped character. 25784 if (cp === 0x5C) { 25785 id = id.substr(0, id.length - 1); 25786 if (source.charCodeAt(index) !== 0x75) { 25787 throwUnexpectedToken(); 25788 } 25789 ++index; 25790 if (source[index] === '{') { 25791 ++index; 25792 ch = scanUnicodeCodePointEscape(); 25793 } else { 25794 ch = scanHexEscape('u'); 25795 cp = ch.charCodeAt(0); 25796 if (!ch || ch === '\\' || !isIdentifierPart(cp)) { 25797 throwUnexpectedToken(); 25798 } 25799 } 25800 id += ch; 25801 } 25802 } 25803 25804 return id; 25805 } 25806 25807 function getIdentifier() { 25808 var start, ch; 25809 25810 start = index++; 25811 while (index < length) { 25812 ch = source.charCodeAt(index); 25813 if (ch === 0x5C) { 25814 // Blackslash (U+005C) marks Unicode escape sequence. 25815 index = start; 25816 return getComplexIdentifier(); 25817 } else if (ch >= 0xD800 && ch < 0xDFFF) { 25818 // Need to handle surrogate pairs. 25819 index = start; 25820 return getComplexIdentifier(); 25821 } 25822 if (isIdentifierPart(ch)) { 25823 ++index; 25824 } else { 25825 break; 25826 } 25827 } 25828 25829 return source.slice(start, index); 25830 } 25831 25832 function scanIdentifier() { 25833 var start, id, type; 25834 25835 start = index; 25836 25837 // Backslash (U+005C) starts an escaped character. 25838 id = (source.charCodeAt(index) === 0x5C) ? getComplexIdentifier() : getIdentifier(); 25839 25840 // There is no keyword or literal with only one character. 25841 // Thus, it must be an identifier. 25842 if (id.length === 1) { 25843 type = Token.Identifier; 25844 } else if (isKeyword(id)) { 25845 type = Token.Keyword; 25846 } else if (id === 'null') { 25847 type = Token.NullLiteral; 25848 } else if (id === 'true' || id === 'false') { 25849 type = Token.BooleanLiteral; 25850 } else { 25851 type = Token.Identifier; 25852 } 25853 25854 return { 25855 type: type, 25856 value: id, 25857 lineNumber: lineNumber, 25858 lineStart: lineStart, 25859 start: start, 25860 end: index 25861 }; 25862 } 25863 25864 25865 // ECMA-262 11.7 Punctuators 25866 25867 function scanPunctuator() { 25868 var token, str; 25869 25870 token = { 25871 type: Token.Punctuator, 25872 value: '', 25873 lineNumber: lineNumber, 25874 lineStart: lineStart, 25875 start: index, 25876 end: index 25877 }; 25878 25879 // Check for most common single-character punctuators. 25880 str = source[index]; 25881 switch (str) { 25882 25883 case '(': 25884 if (extra.tokenize) { 25885 extra.openParenToken = extra.tokenValues.length; 25886 } 25887 ++index; 25888 break; 25889 25890 case '{': 25891 if (extra.tokenize) { 25892 extra.openCurlyToken = extra.tokenValues.length; 25893 } 25894 state.curlyStack.push('{'); 25895 ++index; 25896 break; 25897 25898 case '.': 25899 ++index; 25900 if (source[index] === '.' && source[index + 1] === '.') { 25901 // Spread operator: ... 25902 index += 2; 25903 str = '...'; 25904 } 25905 break; 25906 25907 case '}': 25908 ++index; 25909 state.curlyStack.pop(); 25910 break; 25911 case ')': 25912 case ';': 25913 case ',': 25914 case '[': 25915 case ']': 25916 case ':': 25917 case '?': 25918 case '~': 25919 ++index; 25920 break; 25921 25922 default: 25923 // 4-character punctuator. 25924 str = source.substr(index, 4); 25925 if (str === '>>>=') { 25926 index += 4; 25927 } else { 25928 25929 // 3-character punctuators. 25930 str = str.substr(0, 3); 25931 if (str === '===' || str === '!==' || str === '>>>' || 25932 str === '<<=' || str === '>>=') { 25933 index += 3; 25934 } else { 25935 25936 // 2-character punctuators. 25937 str = str.substr(0, 2); 25938 if (str === '&&' || str === '||' || str === '==' || str === '!=' || 25939 str === '+=' || str === '-=' || str === '*=' || str === '/=' || 25940 str === '++' || str === '--' || str === '<<' || str === '>>' || 25941 str === '&=' || str === '|=' || str === '^=' || str === '%=' || 25942 str === '<=' || str === '>=' || str === '=>') { 25943 index += 2; 25944 } else { 25945 25946 // 1-character punctuators. 25947 str = source[index]; 25948 if ('<>=!+-*%&|^/'.indexOf(str) >= 0) { 25949 ++index; 25950 } 25951 } 25952 } 25953 } 25954 } 25955 25956 if (index === token.start) { 25957 throwUnexpectedToken(); 25958 } 25959 25960 token.end = index; 25961 token.value = str; 25962 return token; 25963 } 25964 25965 // ECMA-262 11.8.3 Numeric Literals 25966 25967 function scanHexLiteral(start) { 25968 var number = ''; 25969 25970 while (index < length) { 25971 if (!isHexDigit(source[index])) { 25972 break; 25973 } 25974 number += source[index++]; 25975 } 25976 25977 if (number.length === 0) { 25978 throwUnexpectedToken(); 25979 } 25980 25981 if (isIdentifierStart(source.charCodeAt(index))) { 25982 throwUnexpectedToken(); 25983 } 25984 25985 return { 25986 type: Token.NumericLiteral, 25987 value: parseInt('0x' + number, 16), 25988 lineNumber: lineNumber, 25989 lineStart: lineStart, 25990 start: start, 25991 end: index 25992 }; 25993 } 25994 25995 function scanBinaryLiteral(start) { 25996 var ch, number; 25997 25998 number = ''; 25999 26000 while (index < length) { 26001 ch = source[index]; 26002 if (ch !== '0' && ch !== '1') { 26003 break; 26004 } 26005 number += source[index++]; 26006 } 26007 26008 if (number.length === 0) { 26009 // only 0b or 0B 26010 throwUnexpectedToken(); 26011 } 26012 26013 if (index < length) { 26014 ch = source.charCodeAt(index); 26015 /* istanbul ignore else */ 26016 if (isIdentifierStart(ch) || isDecimalDigit(ch)) { 26017 throwUnexpectedToken(); 26018 } 26019 } 26020 26021 return { 26022 type: Token.NumericLiteral, 26023 value: parseInt(number, 2), 26024 lineNumber: lineNumber, 26025 lineStart: lineStart, 26026 start: start, 26027 end: index 26028 }; 26029 } 26030 26031 function scanOctalLiteral(prefix, start) { 26032 var number, octal; 26033 26034 if (isOctalDigit(prefix)) { 26035 octal = true; 26036 number = '0' + source[index++]; 26037 } else { 26038 octal = false; 26039 ++index; 26040 number = ''; 26041 } 26042 26043 while (index < length) { 26044 if (!isOctalDigit(source[index])) { 26045 break; 26046 } 26047 number += source[index++]; 26048 } 26049 26050 if (!octal && number.length === 0) { 26051 // only 0o or 0O 26052 throwUnexpectedToken(); 26053 } 26054 26055 if (isIdentifierStart(source.charCodeAt(index)) || isDecimalDigit(source.charCodeAt(index))) { 26056 throwUnexpectedToken(); 26057 } 26058 26059 return { 26060 type: Token.NumericLiteral, 26061 value: parseInt(number, 8), 26062 octal: octal, 26063 lineNumber: lineNumber, 26064 lineStart: lineStart, 26065 start: start, 26066 end: index 26067 }; 26068 } 26069 26070 function isImplicitOctalLiteral() { 26071 var i, ch; 26072 26073 // Implicit octal, unless there is a non-octal digit. 26074 // (Annex B.1.1 on Numeric Literals) 26075 for (i = index + 1; i < length; ++i) { 26076 ch = source[i]; 26077 if (ch === '8' || ch === '9') { 26078 return false; 26079 } 26080 if (!isOctalDigit(ch)) { 26081 return true; 26082 } 26083 } 26084 26085 return true; 26086 } 26087 26088 function scanNumericLiteral() { 26089 var number, start, ch; 26090 26091 ch = source[index]; 26092 assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'), 26093 'Numeric literal must start with a decimal digit or a decimal point'); 26094 26095 start = index; 26096 number = ''; 26097 if (ch !== '.') { 26098 number = source[index++]; 26099 ch = source[index]; 26100 26101 // Hex number starts with '0x'. 26102 // Octal number starts with '0'. 26103 // Octal number in ES6 starts with '0o'. 26104 // Binary number in ES6 starts with '0b'. 26105 if (number === '0') { 26106 if (ch === 'x' || ch === 'X') { 26107 ++index; 26108 return scanHexLiteral(start); 26109 } 26110 if (ch === 'b' || ch === 'B') { 26111 ++index; 26112 return scanBinaryLiteral(start); 26113 } 26114 if (ch === 'o' || ch === 'O') { 26115 return scanOctalLiteral(ch, start); 26116 } 26117 26118 if (isOctalDigit(ch)) { 26119 if (isImplicitOctalLiteral()) { 26120 return scanOctalLiteral(ch, start); 26121 } 26122 } 26123 } 26124 26125 while (isDecimalDigit(source.charCodeAt(index))) { 26126 number += source[index++]; 26127 } 26128 ch = source[index]; 26129 } 26130 26131 if (ch === '.') { 26132 number += source[index++]; 26133 while (isDecimalDigit(source.charCodeAt(index))) { 26134 number += source[index++]; 26135 } 26136 ch = source[index]; 26137 } 26138 26139 if (ch === 'e' || ch === 'E') { 26140 number += source[index++]; 26141 26142 ch = source[index]; 26143 if (ch === '+' || ch === '-') { 26144 number += source[index++]; 26145 } 26146 if (isDecimalDigit(source.charCodeAt(index))) { 26147 while (isDecimalDigit(source.charCodeAt(index))) { 26148 number += source[index++]; 26149 } 26150 } else { 26151 throwUnexpectedToken(); 26152 } 26153 } 26154 26155 if (isIdentifierStart(source.charCodeAt(index))) { 26156 throwUnexpectedToken(); 26157 } 26158 26159 return { 26160 type: Token.NumericLiteral, 26161 value: parseFloat(number), 26162 lineNumber: lineNumber, 26163 lineStart: lineStart, 26164 start: start, 26165 end: index 26166 }; 26167 } 26168 26169 // ECMA-262 11.8.4 String Literals 26170 26171 function scanStringLiteral() { 26172 var str = '', quote, start, ch, unescaped, octToDec, octal = false; 26173 26174 quote = source[index]; 26175 assert((quote === '\'' || quote === '"'), 26176 'String literal must starts with a quote'); 26177 26178 start = index; 26179 ++index; 26180 26181 while (index < length) { 26182 ch = source[index++]; 26183 26184 if (ch === quote) { 26185 quote = ''; 26186 break; 26187 } else if (ch === '\\') { 26188 ch = source[index++]; 26189 if (!ch || !isLineTerminator(ch.charCodeAt(0))) { 26190 switch (ch) { 26191 case 'u': 26192 case 'x': 26193 if (source[index] === '{') { 26194 ++index; 26195 str += scanUnicodeCodePointEscape(); 26196 } else { 26197 unescaped = scanHexEscape(ch); 26198 if (!unescaped) { 26199 throw throwUnexpectedToken(); 26200 } 26201 str += unescaped; 26202 } 26203 break; 26204 case 'n': 26205 str += '\n'; 26206 break; 26207 case 'r': 26208 str += '\r'; 26209 break; 26210 case 't': 26211 str += '\t'; 26212 break; 26213 case 'b': 26214 str += '\b'; 26215 break; 26216 case 'f': 26217 str += '\f'; 26218 break; 26219 case 'v': 26220 str += '\x0B'; 26221 break; 26222 case '8': 26223 case '9': 26224 str += ch; 26225 tolerateUnexpectedToken(); 26226 break; 26227 26228 default: 26229 if (isOctalDigit(ch)) { 26230 octToDec = octalToDecimal(ch); 26231 26232 octal = octToDec.octal || octal; 26233 str += String.fromCharCode(octToDec.code); 26234 } else { 26235 str += ch; 26236 } 26237 break; 26238 } 26239 } else { 26240 ++lineNumber; 26241 if (ch === '\r' && source[index] === '\n') { 26242 ++index; 26243 } 26244 lineStart = index; 26245 } 26246 } else if (isLineTerminator(ch.charCodeAt(0))) { 26247 break; 26248 } else { 26249 str += ch; 26250 } 26251 } 26252 26253 if (quote !== '') { 26254 index = start; 26255 throwUnexpectedToken(); 26256 } 26257 26258 return { 26259 type: Token.StringLiteral, 26260 value: str, 26261 octal: octal, 26262 lineNumber: startLineNumber, 26263 lineStart: startLineStart, 26264 start: start, 26265 end: index 26266 }; 26267 } 26268 26269 // ECMA-262 11.8.6 Template Literal Lexical Components 26270 26271 function scanTemplate() { 26272 var cooked = '', ch, start, rawOffset, terminated, head, tail, restore, unescaped; 26273 26274 terminated = false; 26275 tail = false; 26276 start = index; 26277 head = (source[index] === '`'); 26278 rawOffset = 2; 26279 26280 ++index; 26281 26282 while (index < length) { 26283 ch = source[index++]; 26284 if (ch === '`') { 26285 rawOffset = 1; 26286 tail = true; 26287 terminated = true; 26288 break; 26289 } else if (ch === '$') { 26290 if (source[index] === '{') { 26291 state.curlyStack.push('${'); 26292 ++index; 26293 terminated = true; 26294 break; 26295 } 26296 cooked += ch; 26297 } else if (ch === '\\') { 26298 ch = source[index++]; 26299 if (!isLineTerminator(ch.charCodeAt(0))) { 26300 switch (ch) { 26301 case 'n': 26302 cooked += '\n'; 26303 break; 26304 case 'r': 26305 cooked += '\r'; 26306 break; 26307 case 't': 26308 cooked += '\t'; 26309 break; 26310 case 'u': 26311 case 'x': 26312 if (source[index] === '{') { 26313 ++index; 26314 cooked += scanUnicodeCodePointEscape(); 26315 } else { 26316 restore = index; 26317 unescaped = scanHexEscape(ch); 26318 if (unescaped) { 26319 cooked += unescaped; 26320 } else { 26321 index = restore; 26322 cooked += ch; 26323 } 26324 } 26325 break; 26326 case 'b': 26327 cooked += '\b'; 26328 break; 26329 case 'f': 26330 cooked += '\f'; 26331 break; 26332 case 'v': 26333 cooked += '\v'; 26334 break; 26335 26336 default: 26337 if (ch === '0') { 26338 if (isDecimalDigit(source.charCodeAt(index))) { 26339 // Illegal: \01 \02 and so on 26340 throwError(Messages.TemplateOctalLiteral); 26341 } 26342 cooked += '\0'; 26343 } else if (isOctalDigit(ch)) { 26344 // Illegal: \1 \2 26345 throwError(Messages.TemplateOctalLiteral); 26346 } else { 26347 cooked += ch; 26348 } 26349 break; 26350 } 26351 } else { 26352 ++lineNumber; 26353 if (ch === '\r' && source[index] === '\n') { 26354 ++index; 26355 } 26356 lineStart = index; 26357 } 26358 } else if (isLineTerminator(ch.charCodeAt(0))) { 26359 ++lineNumber; 26360 if (ch === '\r' && source[index] === '\n') { 26361 ++index; 26362 } 26363 lineStart = index; 26364 cooked += '\n'; 26365 } else { 26366 cooked += ch; 26367 } 26368 } 26369 26370 if (!terminated) { 26371 throwUnexpectedToken(); 26372 } 26373 26374 if (!head) { 26375 state.curlyStack.pop(); 26376 } 26377 26378 return { 26379 type: Token.Template, 26380 value: { 26381 cooked: cooked, 26382 raw: source.slice(start + 1, index - rawOffset) 26383 }, 26384 head: head, 26385 tail: tail, 26386 lineNumber: lineNumber, 26387 lineStart: lineStart, 26388 start: start, 26389 end: index 26390 }; 26391 } 26392 26393 // ECMA-262 11.8.5 Regular Expression Literals 26394 26395 function testRegExp(pattern, flags) { 26396 // The BMP character to use as a replacement for astral symbols when 26397 // translating an ES6 "u"-flagged pattern to an ES5-compatible 26398 // approximation. 26399 // Note: replacing with '\uFFFF' enables false positives in unlikely 26400 // scenarios. For example, `[\u{1044f}-\u{10440}]` is an invalid 26401 // pattern that would not be detected by this substitution. 26402 var astralSubstitute = '\uFFFF', 26403 tmp = pattern; 26404 26405 if (flags.indexOf('u') >= 0) { 26406 tmp = tmp 26407 // Replace every Unicode escape sequence with the equivalent 26408 // BMP character or a constant ASCII code point in the case of 26409 // astral symbols. (See the above note on `astralSubstitute` 26410 // for more information.) 26411 .replace(/\\u\{([0-9a-fA-F]+)\}|\\u([a-fA-F0-9]{4})/g, function ($0, $1, $2) { 26412 var codePoint = parseInt($1 || $2, 16); 26413 if (codePoint > 0x10FFFF) { 26414 throwUnexpectedToken(null, Messages.InvalidRegExp); 26415 } 26416 if (codePoint <= 0xFFFF) { 26417 return String.fromCharCode(codePoint); 26418 } 26419 return astralSubstitute; 26420 }) 26421 // Replace each paired surrogate with a single ASCII symbol to 26422 // avoid throwing on regular expressions that are only valid in 26423 // combination with the "u" flag. 26424 .replace( 26425 /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 26426 astralSubstitute 26427 ); 26428 } 26429 26430 // First, detect invalid regular expressions. 26431 try { 26432 RegExp(tmp); 26433 } catch (e) { 26434 throwUnexpectedToken(null, Messages.InvalidRegExp); 26435 } 26436 26437 // Return a regular expression object for this pattern-flag pair, or 26438 // `null` in case the current environment doesn't support the flags it 26439 // uses. 26440 try { 26441 return new RegExp(pattern, flags); 26442 } catch (exception) { 26443 /* istanbul ignore next */ 26444 return null; 26445 } 26446 } 26447 26448 function scanRegExpBody() { 26449 var ch, str, classMarker, terminated, body; 26450 26451 ch = source[index]; 26452 assert(ch === '/', 'Regular expression literal must start with a slash'); 26453 str = source[index++]; 26454 26455 classMarker = false; 26456 terminated = false; 26457 while (index < length) { 26458 ch = source[index++]; 26459 str += ch; 26460 if (ch === '\\') { 26461 ch = source[index++]; 26462 // ECMA-262 7.8.5 26463 if (isLineTerminator(ch.charCodeAt(0))) { 26464 throwUnexpectedToken(null, Messages.UnterminatedRegExp); 26465 } 26466 str += ch; 26467 } else if (isLineTerminator(ch.charCodeAt(0))) { 26468 throwUnexpectedToken(null, Messages.UnterminatedRegExp); 26469 } else if (classMarker) { 26470 if (ch === ']') { 26471 classMarker = false; 26472 } 26473 } else { 26474 if (ch === '/') { 26475 terminated = true; 26476 break; 26477 } else if (ch === '[') { 26478 classMarker = true; 26479 } 26480 } 26481 } 26482 26483 if (!terminated) { 26484 throwUnexpectedToken(null, Messages.UnterminatedRegExp); 26485 } 26486 26487 // Exclude leading and trailing slash. 26488 body = str.substr(1, str.length - 2); 26489 return { 26490 value: body, 26491 literal: str 26492 }; 26493 } 26494 26495 function scanRegExpFlags() { 26496 var ch, str, flags, restore; 26497 26498 str = ''; 26499 flags = ''; 26500 while (index < length) { 26501 ch = source[index]; 26502 if (!isIdentifierPart(ch.charCodeAt(0))) { 26503 break; 26504 } 26505 26506 ++index; 26507 if (ch === '\\' && index < length) { 26508 ch = source[index]; 26509 if (ch === 'u') { 26510 ++index; 26511 restore = index; 26512 ch = scanHexEscape('u'); 26513 if (ch) { 26514 flags += ch; 26515 for (str += '\\u'; restore < index; ++restore) { 26516 str += source[restore]; 26517 } 26518 } else { 26519 index = restore; 26520 flags += 'u'; 26521 str += '\\u'; 26522 } 26523 tolerateUnexpectedToken(); 26524 } else { 26525 str += '\\'; 26526 tolerateUnexpectedToken(); 26527 } 26528 } else { 26529 flags += ch; 26530 str += ch; 26531 } 26532 } 26533 26534 return { 26535 value: flags, 26536 literal: str 26537 }; 26538 } 26539 26540 function scanRegExp() { 26541 var start, body, flags, value; 26542 scanning = true; 26543 26544 lookahead = null; 26545 skipComment(); 26546 start = index; 26547 26548 body = scanRegExpBody(); 26549 flags = scanRegExpFlags(); 26550 value = testRegExp(body.value, flags.value); 26551 scanning = false; 26552 if (extra.tokenize) { 26553 return { 26554 type: Token.RegularExpression, 26555 value: value, 26556 regex: { 26557 pattern: body.value, 26558 flags: flags.value 26559 }, 26560 lineNumber: lineNumber, 26561 lineStart: lineStart, 26562 start: start, 26563 end: index 26564 }; 26565 } 26566 26567 return { 26568 literal: body.literal + flags.literal, 26569 value: value, 26570 regex: { 26571 pattern: body.value, 26572 flags: flags.value 26573 }, 26574 start: start, 26575 end: index 26576 }; 26577 } 26578 26579 function collectRegex() { 26580 var pos, loc, regex, token; 26581 26582 skipComment(); 26583 26584 pos = index; 26585 loc = { 26586 start: { 26587 line: lineNumber, 26588 column: index - lineStart 26589 } 26590 }; 26591 26592 regex = scanRegExp(); 26593 26594 loc.end = { 26595 line: lineNumber, 26596 column: index - lineStart 26597 }; 26598 26599 /* istanbul ignore next */ 26600 if (!extra.tokenize) { 26601 // Pop the previous token, which is likely '/' or '/=' 26602 if (extra.tokens.length > 0) { 26603 token = extra.tokens[extra.tokens.length - 1]; 26604 if (token.range[0] === pos && token.type === 'Punctuator') { 26605 if (token.value === '/' || token.value === '/=') { 26606 extra.tokens.pop(); 26607 } 26608 } 26609 } 26610 26611 extra.tokens.push({ 26612 type: 'RegularExpression', 26613 value: regex.literal, 26614 regex: regex.regex, 26615 range: [pos, index], 26616 loc: loc 26617 }); 26618 } 26619 26620 return regex; 26621 } 26622 26623 function isIdentifierName(token) { 26624 return token.type === Token.Identifier || 26625 token.type === Token.Keyword || 26626 token.type === Token.BooleanLiteral || 26627 token.type === Token.NullLiteral; 26628 } 26629 26630 // Using the following algorithm: 26631 // https://github.com/mozilla/sweet.js/wiki/design 26632 26633 function advanceSlash() { 26634 var regex, previous, check; 26635 26636 function testKeyword(value) { 26637 return value && (value.length > 1) && (value[0] >= 'a') && (value[0] <= 'z'); 26638 } 26639 26640 previous = extra.tokenValues[extra.tokenValues.length - 1]; 26641 regex = (previous !== null); 26642 26643 switch (previous) { 26644 case 'this': 26645 case ']': 26646 regex = false; 26647 break; 26648 26649 case ')': 26650 check = extra.tokenValues[extra.openParenToken - 1]; 26651 regex = (check === 'if' || check === 'while' || check === 'for' || check === 'with'); 26652 break; 26653 26654 case '}': 26655 // Dividing a function by anything makes little sense, 26656 // but we have to check for that. 26657 regex = false; 26658 if (testKeyword(extra.tokenValues[extra.openCurlyToken - 3])) { 26659 // Anonymous function, e.g. function(){} /42 26660 check = extra.tokenValues[extra.openCurlyToken - 4]; 26661 regex = check ? (FnExprTokens.indexOf(check) < 0) : false; 26662 } else if (testKeyword(extra.tokenValues[extra.openCurlyToken - 4])) { 26663 // Named function, e.g. function f(){} /42/ 26664 check = extra.tokenValues[extra.openCurlyToken - 5]; 26665 regex = check ? (FnExprTokens.indexOf(check) < 0) : true; 26666 } 26667 } 26668 26669 return regex ? collectRegex() : scanPunctuator(); 26670 } 26671 26672 function advance() { 26673 var cp, token; 26674 26675 if (index >= length) { 26676 return { 26677 type: Token.EOF, 26678 lineNumber: lineNumber, 26679 lineStart: lineStart, 26680 start: index, 26681 end: index 26682 }; 26683 } 26684 26685 cp = source.charCodeAt(index); 26686 26687 if (isIdentifierStart(cp)) { 26688 token = scanIdentifier(); 26689 if (strict && isStrictModeReservedWord(token.value)) { 26690 token.type = Token.Keyword; 26691 } 26692 return token; 26693 } 26694 26695 // Very common: ( and ) and ; 26696 if (cp === 0x28 || cp === 0x29 || cp === 0x3B) { 26697 return scanPunctuator(); 26698 } 26699 26700 // String literal starts with single quote (U+0027) or double quote (U+0022). 26701 if (cp === 0x27 || cp === 0x22) { 26702 return scanStringLiteral(); 26703 } 26704 26705 // Dot (.) U+002E can also start a floating-point number, hence the need 26706 // to check the next character. 26707 if (cp === 0x2E) { 26708 if (isDecimalDigit(source.charCodeAt(index + 1))) { 26709 return scanNumericLiteral(); 26710 } 26711 return scanPunctuator(); 26712 } 26713 26714 if (isDecimalDigit(cp)) { 26715 return scanNumericLiteral(); 26716 } 26717 26718 // Slash (/) U+002F can also start a regex. 26719 if (extra.tokenize && cp === 0x2F) { 26720 return advanceSlash(); 26721 } 26722 26723 // Template literals start with ` (U+0060) for template head 26724 // or } (U+007D) for template middle or template tail. 26725 if (cp === 0x60 || (cp === 0x7D && state.curlyStack[state.curlyStack.length - 1] === '${')) { 26726 return scanTemplate(); 26727 } 26728 26729 // Possible identifier start in a surrogate pair. 26730 if (cp >= 0xD800 && cp < 0xDFFF) { 26731 cp = codePointAt(index); 26732 if (isIdentifierStart(cp)) { 26733 return scanIdentifier(); 26734 } 26735 } 26736 26737 return scanPunctuator(); 26738 } 26739 26740 function collectToken() { 26741 var loc, token, value, entry; 26742 26743 loc = { 26744 start: { 26745 line: lineNumber, 26746 column: index - lineStart 26747 } 26748 }; 26749 26750 token = advance(); 26751 loc.end = { 26752 line: lineNumber, 26753 column: index - lineStart 26754 }; 26755 26756 if (token.type !== Token.EOF) { 26757 value = source.slice(token.start, token.end); 26758 entry = { 26759 type: TokenName[token.type], 26760 value: value, 26761 range: [token.start, token.end], 26762 loc: loc 26763 }; 26764 if (token.regex) { 26765 entry.regex = { 26766 pattern: token.regex.pattern, 26767 flags: token.regex.flags 26768 }; 26769 } 26770 if (extra.tokenValues) { 26771 extra.tokenValues.push((entry.type === 'Punctuator' || entry.type === 'Keyword') ? entry.value : null); 26772 } 26773 if (extra.tokenize) { 26774 if (!extra.range) { 26775 delete entry.range; 26776 } 26777 if (!extra.loc) { 26778 delete entry.loc; 26779 } 26780 if (extra.delegate) { 26781 entry = extra.delegate(entry); 26782 } 26783 } 26784 extra.tokens.push(entry); 26785 } 26786 26787 return token; 26788 } 26789 26790 function lex() { 26791 var token; 26792 scanning = true; 26793 26794 lastIndex = index; 26795 lastLineNumber = lineNumber; 26796 lastLineStart = lineStart; 26797 26798 skipComment(); 26799 26800 token = lookahead; 26801 26802 startIndex = index; 26803 startLineNumber = lineNumber; 26804 startLineStart = lineStart; 26805 26806 lookahead = (typeof extra.tokens !== 'undefined') ? collectToken() : advance(); 26807 scanning = false; 26808 return token; 26809 } 26810 26811 function peek() { 26812 scanning = true; 26813 26814 skipComment(); 26815 26816 lastIndex = index; 26817 lastLineNumber = lineNumber; 26818 lastLineStart = lineStart; 26819 26820 startIndex = index; 26821 startLineNumber = lineNumber; 26822 startLineStart = lineStart; 26823 26824 lookahead = (typeof extra.tokens !== 'undefined') ? collectToken() : advance(); 26825 scanning = false; 26826 } 26827 26828 function Position() { 26829 this.line = startLineNumber; 26830 this.column = startIndex - startLineStart; 26831 } 26832 26833 function SourceLocation() { 26834 this.start = new Position(); 26835 this.end = null; 26836 } 26837 26838 function WrappingSourceLocation(startToken) { 26839 this.start = { 26840 line: startToken.lineNumber, 26841 column: startToken.start - startToken.lineStart 26842 }; 26843 this.end = null; 26844 } 26845 26846 function Node() { 26847 if (extra.range) { 26848 this.range = [startIndex, 0]; 26849 } 26850 if (extra.loc) { 26851 this.loc = new SourceLocation(); 26852 } 26853 } 26854 26855 function WrappingNode(startToken) { 26856 if (extra.range) { 26857 this.range = [startToken.start, 0]; 26858 } 26859 if (extra.loc) { 26860 this.loc = new WrappingSourceLocation(startToken); 26861 } 26862 } 26863 26864 WrappingNode.prototype = Node.prototype = { 26865 26866 processComment: function () { 26867 var lastChild, 26868 innerComments, 26869 leadingComments, 26870 trailingComments, 26871 bottomRight = extra.bottomRightStack, 26872 i, 26873 comment, 26874 last = bottomRight[bottomRight.length - 1]; 26875 26876 if (this.type === Syntax.Program) { 26877 if (this.body.length > 0) { 26878 return; 26879 } 26880 } 26881 /** 26882 * patch innnerComments for properties empty block 26883 * `function a() {/** comments **\/}` 26884 */ 26885 26886 if (this.type === Syntax.BlockStatement && this.body.length === 0) { 26887 innerComments = []; 26888 for (i = extra.leadingComments.length - 1; i >= 0; --i) { 26889 comment = extra.leadingComments[i]; 26890 if (this.range[1] >= comment.range[1]) { 26891 innerComments.unshift(comment); 26892 extra.leadingComments.splice(i, 1); 26893 extra.trailingComments.splice(i, 1); 26894 } 26895 } 26896 if (innerComments.length) { 26897 this.innerComments = innerComments; 26898 //bottomRight.push(this); 26899 return; 26900 } 26901 } 26902 26903 if (extra.trailingComments.length > 0) { 26904 trailingComments = []; 26905 for (i = extra.trailingComments.length - 1; i >= 0; --i) { 26906 comment = extra.trailingComments[i]; 26907 if (comment.range[0] >= this.range[1]) { 26908 trailingComments.unshift(comment); 26909 extra.trailingComments.splice(i, 1); 26910 } 26911 } 26912 extra.trailingComments = []; 26913 } else { 26914 if (last && last.trailingComments && last.trailingComments[0].range[0] >= this.range[1]) { 26915 trailingComments = last.trailingComments; 26916 delete last.trailingComments; 26917 } 26918 } 26919 26920 // Eating the stack. 26921 while (last && last.range[0] >= this.range[0]) { 26922 lastChild = bottomRight.pop(); 26923 last = bottomRight[bottomRight.length - 1]; 26924 } 26925 26926 if (lastChild) { 26927 if (lastChild.leadingComments) { 26928 leadingComments = []; 26929 for (i = lastChild.leadingComments.length - 1; i >= 0; --i) { 26930 comment = lastChild.leadingComments[i]; 26931 if (comment.range[1] <= this.range[0]) { 26932 leadingComments.unshift(comment); 26933 lastChild.leadingComments.splice(i, 1); 26934 } 26935 } 26936 26937 if (!lastChild.leadingComments.length) { 26938 lastChild.leadingComments = undefined; 26939 } 26940 } 26941 } else if (extra.leadingComments.length > 0) { 26942 leadingComments = []; 26943 for (i = extra.leadingComments.length - 1; i >= 0; --i) { 26944 comment = extra.leadingComments[i]; 26945 if (comment.range[1] <= this.range[0]) { 26946 leadingComments.unshift(comment); 26947 extra.leadingComments.splice(i, 1); 26948 } 26949 } 26950 } 26951 26952 26953 if (leadingComments && leadingComments.length > 0) { 26954 this.leadingComments = leadingComments; 26955 } 26956 if (trailingComments && trailingComments.length > 0) { 26957 this.trailingComments = trailingComments; 26958 } 26959 26960 bottomRight.push(this); 26961 }, 26962 26963 finish: function () { 26964 if (extra.range) { 26965 this.range[1] = lastIndex; 26966 } 26967 if (extra.loc) { 26968 this.loc.end = { 26969 line: lastLineNumber, 26970 column: lastIndex - lastLineStart 26971 }; 26972 if (extra.source) { 26973 this.loc.source = extra.source; 26974 } 26975 } 26976 26977 if (extra.attachComment) { 26978 this.processComment(); 26979 } 26980 }, 26981 26982 finishArrayExpression: function (elements) { 26983 this.type = Syntax.ArrayExpression; 26984 this.elements = elements; 26985 this.finish(); 26986 return this; 26987 }, 26988 26989 finishArrayPattern: function (elements) { 26990 this.type = Syntax.ArrayPattern; 26991 this.elements = elements; 26992 this.finish(); 26993 return this; 26994 }, 26995 26996 finishArrowFunctionExpression: function (params, defaults, body, expression) { 26997 this.type = Syntax.ArrowFunctionExpression; 26998 this.id = null; 26999 this.params = params; 27000 this.defaults = defaults; 27001 this.body = body; 27002 this.generator = false; 27003 this.expression = expression; 27004 this.finish(); 27005 return this; 27006 }, 27007 27008 finishAssignmentExpression: function (operator, left, right) { 27009 this.type = Syntax.AssignmentExpression; 27010 this.operator = operator; 27011 this.left = left; 27012 this.right = right; 27013 this.finish(); 27014 return this; 27015 }, 27016 27017 finishAssignmentPattern: function (left, right) { 27018 this.type = Syntax.AssignmentPattern; 27019 this.left = left; 27020 this.right = right; 27021 this.finish(); 27022 return this; 27023 }, 27024 27025 finishBinaryExpression: function (operator, left, right) { 27026 this.type = (operator === '||' || operator === '&&') ? Syntax.LogicalExpression : Syntax.BinaryExpression; 27027 this.operator = operator; 27028 this.left = left; 27029 this.right = right; 27030 this.finish(); 27031 return this; 27032 }, 27033 27034 finishBlockStatement: function (body) { 27035 this.type = Syntax.BlockStatement; 27036 this.body = body; 27037 this.finish(); 27038 return this; 27039 }, 27040 27041 finishBreakStatement: function (label) { 27042 this.type = Syntax.BreakStatement; 27043 this.label = label; 27044 this.finish(); 27045 return this; 27046 }, 27047 27048 finishCallExpression: function (callee, args) { 27049 this.type = Syntax.CallExpression; 27050 this.callee = callee; 27051 this.arguments = args; 27052 this.finish(); 27053 return this; 27054 }, 27055 27056 finishCatchClause: function (param, body) { 27057 this.type = Syntax.CatchClause; 27058 this.param = param; 27059 this.body = body; 27060 this.finish(); 27061 return this; 27062 }, 27063 27064 finishClassBody: function (body) { 27065 this.type = Syntax.ClassBody; 27066 this.body = body; 27067 this.finish(); 27068 return this; 27069 }, 27070 27071 finishClassDeclaration: function (id, superClass, body) { 27072 this.type = Syntax.ClassDeclaration; 27073 this.id = id; 27074 this.superClass = superClass; 27075 this.body = body; 27076 this.finish(); 27077 return this; 27078 }, 27079 27080 finishClassExpression: function (id, superClass, body) { 27081 this.type = Syntax.ClassExpression; 27082 this.id = id; 27083 this.superClass = superClass; 27084 this.body = body; 27085 this.finish(); 27086 return this; 27087 }, 27088 27089 finishConditionalExpression: function (test, consequent, alternate) { 27090 this.type = Syntax.ConditionalExpression; 27091 this.test = test; 27092 this.consequent = consequent; 27093 this.alternate = alternate; 27094 this.finish(); 27095 return this; 27096 }, 27097 27098 finishContinueStatement: function (label) { 27099 this.type = Syntax.ContinueStatement; 27100 this.label = label; 27101 this.finish(); 27102 return this; 27103 }, 27104 27105 finishDebuggerStatement: function () { 27106 this.type = Syntax.DebuggerStatement; 27107 this.finish(); 27108 return this; 27109 }, 27110 27111 finishDoWhileStatement: function (body, test) { 27112 this.type = Syntax.DoWhileStatement; 27113 this.body = body; 27114 this.test = test; 27115 this.finish(); 27116 return this; 27117 }, 27118 27119 finishEmptyStatement: function () { 27120 this.type = Syntax.EmptyStatement; 27121 this.finish(); 27122 return this; 27123 }, 27124 27125 finishExpressionStatement: function (expression) { 27126 this.type = Syntax.ExpressionStatement; 27127 this.expression = expression; 27128 this.finish(); 27129 return this; 27130 }, 27131 27132 finishForStatement: function (init, test, update, body) { 27133 this.type = Syntax.ForStatement; 27134 this.init = init; 27135 this.test = test; 27136 this.update = update; 27137 this.body = body; 27138 this.finish(); 27139 return this; 27140 }, 27141 27142 finishForOfStatement: function (left, right, body) { 27143 this.type = Syntax.ForOfStatement; 27144 this.left = left; 27145 this.right = right; 27146 this.body = body; 27147 this.finish(); 27148 return this; 27149 }, 27150 27151 finishForInStatement: function (left, right, body) { 27152 this.type = Syntax.ForInStatement; 27153 this.left = left; 27154 this.right = right; 27155 this.body = body; 27156 this.each = false; 27157 this.finish(); 27158 return this; 27159 }, 27160 27161 finishFunctionDeclaration: function (id, params, defaults, body, generator) { 27162 this.type = Syntax.FunctionDeclaration; 27163 this.id = id; 27164 this.params = params; 27165 this.defaults = defaults; 27166 this.body = body; 27167 this.generator = generator; 27168 this.expression = false; 27169 this.finish(); 27170 return this; 27171 }, 27172 27173 finishFunctionExpression: function (id, params, defaults, body, generator) { 27174 this.type = Syntax.FunctionExpression; 27175 this.id = id; 27176 this.params = params; 27177 this.defaults = defaults; 27178 this.body = body; 27179 this.generator = generator; 27180 this.expression = false; 27181 this.finish(); 27182 return this; 27183 }, 27184 27185 finishIdentifier: function (name) { 27186 this.type = Syntax.Identifier; 27187 this.name = name; 27188 this.finish(); 27189 return this; 27190 }, 27191 27192 finishIfStatement: function (test, consequent, alternate) { 27193 this.type = Syntax.IfStatement; 27194 this.test = test; 27195 this.consequent = consequent; 27196 this.alternate = alternate; 27197 this.finish(); 27198 return this; 27199 }, 27200 27201 finishLabeledStatement: function (label, body) { 27202 this.type = Syntax.LabeledStatement; 27203 this.label = label; 27204 this.body = body; 27205 this.finish(); 27206 return this; 27207 }, 27208 27209 finishLiteral: function (token) { 27210 this.type = Syntax.Literal; 27211 this.value = token.value; 27212 this.raw = source.slice(token.start, token.end); 27213 if (token.regex) { 27214 this.regex = token.regex; 27215 } 27216 this.finish(); 27217 return this; 27218 }, 27219 27220 finishMemberExpression: function (accessor, object, property) { 27221 this.type = Syntax.MemberExpression; 27222 this.computed = accessor === '['; 27223 this.object = object; 27224 this.property = property; 27225 this.finish(); 27226 return this; 27227 }, 27228 27229 finishMetaProperty: function (meta, property) { 27230 this.type = Syntax.MetaProperty; 27231 this.meta = meta; 27232 this.property = property; 27233 this.finish(); 27234 return this; 27235 }, 27236 27237 finishNewExpression: function (callee, args) { 27238 this.type = Syntax.NewExpression; 27239 this.callee = callee; 27240 this.arguments = args; 27241 this.finish(); 27242 return this; 27243 }, 27244 27245 finishObjectExpression: function (properties) { 27246 this.type = Syntax.ObjectExpression; 27247 this.properties = properties; 27248 this.finish(); 27249 return this; 27250 }, 27251 27252 finishObjectPattern: function (properties) { 27253 this.type = Syntax.ObjectPattern; 27254 this.properties = properties; 27255 this.finish(); 27256 return this; 27257 }, 27258 27259 finishPostfixExpression: function (operator, argument) { 27260 this.type = Syntax.UpdateExpression; 27261 this.operator = operator; 27262 this.argument = argument; 27263 this.prefix = false; 27264 this.finish(); 27265 return this; 27266 }, 27267 27268 finishProgram: function (body, sourceType) { 27269 this.type = Syntax.Program; 27270 this.body = body; 27271 this.sourceType = sourceType; 27272 this.finish(); 27273 return this; 27274 }, 27275 27276 finishProperty: function (kind, key, computed, value, method, shorthand) { 27277 this.type = Syntax.Property; 27278 this.key = key; 27279 this.computed = computed; 27280 this.value = value; 27281 this.kind = kind; 27282 this.method = method; 27283 this.shorthand = shorthand; 27284 this.finish(); 27285 return this; 27286 }, 27287 27288 finishRestElement: function (argument) { 27289 this.type = Syntax.RestElement; 27290 this.argument = argument; 27291 this.finish(); 27292 return this; 27293 }, 27294 27295 finishReturnStatement: function (argument) { 27296 this.type = Syntax.ReturnStatement; 27297 this.argument = argument; 27298 this.finish(); 27299 return this; 27300 }, 27301 27302 finishSequenceExpression: function (expressions) { 27303 this.type = Syntax.SequenceExpression; 27304 this.expressions = expressions; 27305 this.finish(); 27306 return this; 27307 }, 27308 27309 finishSpreadElement: function (argument) { 27310 this.type = Syntax.SpreadElement; 27311 this.argument = argument; 27312 this.finish(); 27313 return this; 27314 }, 27315 27316 finishSwitchCase: function (test, consequent) { 27317 this.type = Syntax.SwitchCase; 27318 this.test = test; 27319 this.consequent = consequent; 27320 this.finish(); 27321 return this; 27322 }, 27323 27324 finishSuper: function () { 27325 this.type = Syntax.Super; 27326 this.finish(); 27327 return this; 27328 }, 27329 27330 finishSwitchStatement: function (discriminant, cases) { 27331 this.type = Syntax.SwitchStatement; 27332 this.discriminant = discriminant; 27333 this.cases = cases; 27334 this.finish(); 27335 return this; 27336 }, 27337 27338 finishTaggedTemplateExpression: function (tag, quasi) { 27339 this.type = Syntax.TaggedTemplateExpression; 27340 this.tag = tag; 27341 this.quasi = quasi; 27342 this.finish(); 27343 return this; 27344 }, 27345 27346 finishTemplateElement: function (value, tail) { 27347 this.type = Syntax.TemplateElement; 27348 this.value = value; 27349 this.tail = tail; 27350 this.finish(); 27351 return this; 27352 }, 27353 27354 finishTemplateLiteral: function (quasis, expressions) { 27355 this.type = Syntax.TemplateLiteral; 27356 this.quasis = quasis; 27357 this.expressions = expressions; 27358 this.finish(); 27359 return this; 27360 }, 27361 27362 finishThisExpression: function () { 27363 this.type = Syntax.ThisExpression; 27364 this.finish(); 27365 return this; 27366 }, 27367 27368 finishThrowStatement: function (argument) { 27369 this.type = Syntax.ThrowStatement; 27370 this.argument = argument; 27371 this.finish(); 27372 return this; 27373 }, 27374 27375 finishTryStatement: function (block, handler, finalizer) { 27376 this.type = Syntax.TryStatement; 27377 this.block = block; 27378 this.guardedHandlers = []; 27379 this.handlers = handler ? [handler] : []; 27380 this.handler = handler; 27381 this.finalizer = finalizer; 27382 this.finish(); 27383 return this; 27384 }, 27385 27386 finishUnaryExpression: function (operator, argument) { 27387 this.type = (operator === '++' || operator === '--') ? Syntax.UpdateExpression : Syntax.UnaryExpression; 27388 this.operator = operator; 27389 this.argument = argument; 27390 this.prefix = true; 27391 this.finish(); 27392 return this; 27393 }, 27394 27395 finishVariableDeclaration: function (declarations) { 27396 this.type = Syntax.VariableDeclaration; 27397 this.declarations = declarations; 27398 this.kind = 'var'; 27399 this.finish(); 27400 return this; 27401 }, 27402 27403 finishLexicalDeclaration: function (declarations, kind) { 27404 this.type = Syntax.VariableDeclaration; 27405 this.declarations = declarations; 27406 this.kind = kind; 27407 this.finish(); 27408 return this; 27409 }, 27410 27411 finishVariableDeclarator: function (id, init) { 27412 this.type = Syntax.VariableDeclarator; 27413 this.id = id; 27414 this.init = init; 27415 this.finish(); 27416 return this; 27417 }, 27418 27419 finishWhileStatement: function (test, body) { 27420 this.type = Syntax.WhileStatement; 27421 this.test = test; 27422 this.body = body; 27423 this.finish(); 27424 return this; 27425 }, 27426 27427 finishWithStatement: function (object, body) { 27428 this.type = Syntax.WithStatement; 27429 this.object = object; 27430 this.body = body; 27431 this.finish(); 27432 return this; 27433 }, 27434 27435 finishExportSpecifier: function (local, exported) { 27436 this.type = Syntax.ExportSpecifier; 27437 this.exported = exported || local; 27438 this.local = local; 27439 this.finish(); 27440 return this; 27441 }, 27442 27443 finishImportDefaultSpecifier: function (local) { 27444 this.type = Syntax.ImportDefaultSpecifier; 27445 this.local = local; 27446 this.finish(); 27447 return this; 27448 }, 27449 27450 finishImportNamespaceSpecifier: function (local) { 27451 this.type = Syntax.ImportNamespaceSpecifier; 27452 this.local = local; 27453 this.finish(); 27454 return this; 27455 }, 27456 27457 finishExportNamedDeclaration: function (declaration, specifiers, src) { 27458 this.type = Syntax.ExportNamedDeclaration; 27459 this.declaration = declaration; 27460 this.specifiers = specifiers; 27461 this.source = src; 27462 this.finish(); 27463 return this; 27464 }, 27465 27466 finishExportDefaultDeclaration: function (declaration) { 27467 this.type = Syntax.ExportDefaultDeclaration; 27468 this.declaration = declaration; 27469 this.finish(); 27470 return this; 27471 }, 27472 27473 finishExportAllDeclaration: function (src) { 27474 this.type = Syntax.ExportAllDeclaration; 27475 this.source = src; 27476 this.finish(); 27477 return this; 27478 }, 27479 27480 finishImportSpecifier: function (local, imported) { 27481 this.type = Syntax.ImportSpecifier; 27482 this.local = local || imported; 27483 this.imported = imported; 27484 this.finish(); 27485 return this; 27486 }, 27487 27488 finishImportDeclaration: function (specifiers, src) { 27489 this.type = Syntax.ImportDeclaration; 27490 this.specifiers = specifiers; 27491 this.source = src; 27492 this.finish(); 27493 return this; 27494 }, 27495 27496 finishYieldExpression: function (argument, delegate) { 27497 this.type = Syntax.YieldExpression; 27498 this.argument = argument; 27499 this.delegate = delegate; 27500 this.finish(); 27501 return this; 27502 } 27503 }; 27504 27505 27506 function recordError(error) { 27507 var e, existing; 27508 27509 for (e = 0; e < extra.errors.length; e++) { 27510 existing = extra.errors[e]; 27511 // Prevent duplicated error. 27512 /* istanbul ignore next */ 27513 if (existing.index === error.index && existing.message === error.message) { 27514 return; 27515 } 27516 } 27517 27518 extra.errors.push(error); 27519 } 27520 27521 function constructError(msg, column) { 27522 var error = new Error(msg); 27523 try { 27524 throw error; 27525 } catch (base) { 27526 /* istanbul ignore else */ 27527 if (Object.create && Object.defineProperty) { 27528 error = Object.create(base); 27529 Object.defineProperty(error, 'column', { value: column }); 27530 } 27531 } finally { 27532 return error; 27533 } 27534 } 27535 27536 function createError(line, pos, description) { 27537 var msg, column, error; 27538 27539 msg = 'Line ' + line + ': ' + description; 27540 column = pos - (scanning ? lineStart : lastLineStart) + 1; 27541 error = constructError(msg, column); 27542 error.lineNumber = line; 27543 error.description = description; 27544 error.index = pos; 27545 return error; 27546 } 27547 27548 // Throw an exception 27549 27550 function throwError(messageFormat) { 27551 var args, msg; 27552 27553 args = Array.prototype.slice.call(arguments, 1); 27554 msg = messageFormat.replace(/%(\d)/g, 27555 function (whole, idx) { 27556 assert(idx < args.length, 'Message reference must be in range'); 27557 return args[idx]; 27558 } 27559 ); 27560 27561 throw createError(lastLineNumber, lastIndex, msg); 27562 } 27563 27564 function tolerateError(messageFormat) { 27565 var args, msg, error; 27566 27567 args = Array.prototype.slice.call(arguments, 1); 27568 /* istanbul ignore next */ 27569 msg = messageFormat.replace(/%(\d)/g, 27570 function (whole, idx) { 27571 assert(idx < args.length, 'Message reference must be in range'); 27572 return args[idx]; 27573 } 27574 ); 27575 27576 error = createError(lineNumber, lastIndex, msg); 27577 if (extra.errors) { 27578 recordError(error); 27579 } else { 27580 throw error; 27581 } 27582 } 27583 27584 // Throw an exception because of the token. 27585 27586 function unexpectedTokenError(token, message) { 27587 var value, msg = message || Messages.UnexpectedToken; 27588 27589 if (token) { 27590 if (!message) { 27591 msg = (token.type === Token.EOF) ? Messages.UnexpectedEOS : 27592 (token.type === Token.Identifier) ? Messages.UnexpectedIdentifier : 27593 (token.type === Token.NumericLiteral) ? Messages.UnexpectedNumber : 27594 (token.type === Token.StringLiteral) ? Messages.UnexpectedString : 27595 (token.type === Token.Template) ? Messages.UnexpectedTemplate : 27596 Messages.UnexpectedToken; 27597 27598 if (token.type === Token.Keyword) { 27599 if (isFutureReservedWord(token.value)) { 27600 msg = Messages.UnexpectedReserved; 27601 } else if (strict && isStrictModeReservedWord(token.value)) { 27602 msg = Messages.StrictReservedWord; 27603 } 27604 } 27605 } 27606 27607 value = (token.type === Token.Template) ? token.value.raw : token.value; 27608 } else { 27609 value = 'ILLEGAL'; 27610 } 27611 27612 msg = msg.replace('%0', value); 27613 27614 return (token && typeof token.lineNumber === 'number') ? 27615 createError(token.lineNumber, token.start, msg) : 27616 createError(scanning ? lineNumber : lastLineNumber, scanning ? index : lastIndex, msg); 27617 } 27618 27619 function throwUnexpectedToken(token, message) { 27620 throw unexpectedTokenError(token, message); 27621 } 27622 27623 function tolerateUnexpectedToken(token, message) { 27624 var error = unexpectedTokenError(token, message); 27625 if (extra.errors) { 27626 recordError(error); 27627 } else { 27628 throw error; 27629 } 27630 } 27631 27632 // Expect the next token to match the specified punctuator. 27633 // If not, an exception will be thrown. 27634 27635 function expect(value) { 27636 var token = lex(); 27637 if (token.type !== Token.Punctuator || token.value !== value) { 27638 throwUnexpectedToken(token); 27639 } 27640 } 27641 27642 /** 27643 * @name expectCommaSeparator 27644 * @description Quietly expect a comma when in tolerant mode, otherwise delegates 27645 * to <code>expect(value)</code> 27646 * @since 2.0 27647 */ 27648 function expectCommaSeparator() { 27649 var token; 27650 27651 if (extra.errors) { 27652 token = lookahead; 27653 if (token.type === Token.Punctuator && token.value === ',') { 27654 lex(); 27655 } else if (token.type === Token.Punctuator && token.value === ';') { 27656 lex(); 27657 tolerateUnexpectedToken(token); 27658 } else { 27659 tolerateUnexpectedToken(token, Messages.UnexpectedToken); 27660 } 27661 } else { 27662 expect(','); 27663 } 27664 } 27665 27666 // Expect the next token to match the specified keyword. 27667 // If not, an exception will be thrown. 27668 27669 function expectKeyword(keyword) { 27670 var token = lex(); 27671 if (token.type !== Token.Keyword || token.value !== keyword) { 27672 throwUnexpectedToken(token); 27673 } 27674 } 27675 27676 // Return true if the next token matches the specified punctuator. 27677 27678 function match(value) { 27679 return lookahead.type === Token.Punctuator && lookahead.value === value; 27680 } 27681 27682 // Return true if the next token matches the specified keyword 27683 27684 function matchKeyword(keyword) { 27685 return lookahead.type === Token.Keyword && lookahead.value === keyword; 27686 } 27687 27688 // Return true if the next token matches the specified contextual keyword 27689 // (where an identifier is sometimes a keyword depending on the context) 27690 27691 function matchContextualKeyword(keyword) { 27692 return lookahead.type === Token.Identifier && lookahead.value === keyword; 27693 } 27694 27695 // Return true if the next token is an assignment operator 27696 27697 function matchAssign() { 27698 var op; 27699 27700 if (lookahead.type !== Token.Punctuator) { 27701 return false; 27702 } 27703 op = lookahead.value; 27704 return op === '=' || 27705 op === '*=' || 27706 op === '/=' || 27707 op === '%=' || 27708 op === '+=' || 27709 op === '-=' || 27710 op === '<<=' || 27711 op === '>>=' || 27712 op === '>>>=' || 27713 op === '&=' || 27714 op === '^=' || 27715 op === '|='; 27716 } 27717 27718 function consumeSemicolon() { 27719 // Catch the very common case first: immediately a semicolon (U+003B). 27720 if (source.charCodeAt(startIndex) === 0x3B || match(';')) { 27721 lex(); 27722 return; 27723 } 27724 27725 if (hasLineTerminator) { 27726 return; 27727 } 27728 27729 // FIXME(ikarienator): this is seemingly an issue in the previous location info convention. 27730 lastIndex = startIndex; 27731 lastLineNumber = startLineNumber; 27732 lastLineStart = startLineStart; 27733 27734 if (lookahead.type !== Token.EOF && !match('}')) { 27735 throwUnexpectedToken(lookahead); 27736 } 27737 } 27738 27739 // Cover grammar support. 27740 // 27741 // When an assignment expression position starts with an left parenthesis, the determination of the type 27742 // of the syntax is to be deferred arbitrarily long until the end of the parentheses pair (plus a lookahead) 27743 // or the first comma. This situation also defers the determination of all the expressions nested in the pair. 27744 // 27745 // There are three productions that can be parsed in a parentheses pair that needs to be determined 27746 // after the outermost pair is closed. They are: 27747 // 27748 // 1. AssignmentExpression 27749 // 2. BindingElements 27750 // 3. AssignmentTargets 27751 // 27752 // In order to avoid exponential backtracking, we use two flags to denote if the production can be 27753 // binding element or assignment target. 27754 // 27755 // The three productions have the relationship: 27756 // 27757 // BindingElements ⊆ AssignmentTargets ⊆ AssignmentExpression 27758 // 27759 // with a single exception that CoverInitializedName when used directly in an Expression, generates 27760 // an early error. Therefore, we need the third state, firstCoverInitializedNameError, to track the 27761 // first usage of CoverInitializedName and report it when we reached the end of the parentheses pair. 27762 // 27763 // isolateCoverGrammar function runs the given parser function with a new cover grammar context, and it does not 27764 // effect the current flags. This means the production the parser parses is only used as an expression. Therefore 27765 // the CoverInitializedName check is conducted. 27766 // 27767 // inheritCoverGrammar function runs the given parse function with a new cover grammar context, and it propagates 27768 // the flags outside of the parser. This means the production the parser parses is used as a part of a potential 27769 // pattern. The CoverInitializedName check is deferred. 27770 function isolateCoverGrammar(parser) { 27771 var oldIsBindingElement = isBindingElement, 27772 oldIsAssignmentTarget = isAssignmentTarget, 27773 oldFirstCoverInitializedNameError = firstCoverInitializedNameError, 27774 result; 27775 isBindingElement = true; 27776 isAssignmentTarget = true; 27777 firstCoverInitializedNameError = null; 27778 result = parser(); 27779 if (firstCoverInitializedNameError !== null) { 27780 throwUnexpectedToken(firstCoverInitializedNameError); 27781 } 27782 isBindingElement = oldIsBindingElement; 27783 isAssignmentTarget = oldIsAssignmentTarget; 27784 firstCoverInitializedNameError = oldFirstCoverInitializedNameError; 27785 return result; 27786 } 27787 27788 function inheritCoverGrammar(parser) { 27789 var oldIsBindingElement = isBindingElement, 27790 oldIsAssignmentTarget = isAssignmentTarget, 27791 oldFirstCoverInitializedNameError = firstCoverInitializedNameError, 27792 result; 27793 isBindingElement = true; 27794 isAssignmentTarget = true; 27795 firstCoverInitializedNameError = null; 27796 result = parser(); 27797 isBindingElement = isBindingElement && oldIsBindingElement; 27798 isAssignmentTarget = isAssignmentTarget && oldIsAssignmentTarget; 27799 firstCoverInitializedNameError = oldFirstCoverInitializedNameError || firstCoverInitializedNameError; 27800 return result; 27801 } 27802 27803 // ECMA-262 13.3.3 Destructuring Binding Patterns 27804 27805 function parseArrayPattern(params, kind) { 27806 var node = new Node(), elements = [], rest, restNode; 27807 expect('['); 27808 27809 while (!match(']')) { 27810 if (match(',')) { 27811 lex(); 27812 elements.push(null); 27813 } else { 27814 if (match('...')) { 27815 restNode = new Node(); 27816 lex(); 27817 params.push(lookahead); 27818 rest = parseVariableIdentifier(kind); 27819 elements.push(restNode.finishRestElement(rest)); 27820 break; 27821 } else { 27822 elements.push(parsePatternWithDefault(params, kind)); 27823 } 27824 if (!match(']')) { 27825 expect(','); 27826 } 27827 } 27828 27829 } 27830 27831 expect(']'); 27832 27833 return node.finishArrayPattern(elements); 27834 } 27835 27836 function parsePropertyPattern(params, kind) { 27837 var node = new Node(), key, keyToken, computed = match('['), init; 27838 if (lookahead.type === Token.Identifier) { 27839 keyToken = lookahead; 27840 key = parseVariableIdentifier(); 27841 if (match('=')) { 27842 params.push(keyToken); 27843 lex(); 27844 init = parseAssignmentExpression(); 27845 27846 return node.finishProperty( 27847 'init', key, false, 27848 new WrappingNode(keyToken).finishAssignmentPattern(key, init), false, true); 27849 } else if (!match(':')) { 27850 params.push(keyToken); 27851 return node.finishProperty('init', key, false, key, false, true); 27852 } 27853 } else { 27854 key = parseObjectPropertyKey(); 27855 } 27856 expect(':'); 27857 init = parsePatternWithDefault(params, kind); 27858 return node.finishProperty('init', key, computed, init, false, false); 27859 } 27860 27861 function parseObjectPattern(params, kind) { 27862 var node = new Node(), properties = []; 27863 27864 expect('{'); 27865 27866 while (!match('}')) { 27867 properties.push(parsePropertyPattern(params, kind)); 27868 if (!match('}')) { 27869 expect(','); 27870 } 27871 } 27872 27873 lex(); 27874 27875 return node.finishObjectPattern(properties); 27876 } 27877 27878 function parsePattern(params, kind) { 27879 if (match('[')) { 27880 return parseArrayPattern(params, kind); 27881 } else if (match('{')) { 27882 return parseObjectPattern(params, kind); 27883 } else if (matchKeyword('let')) { 27884 if (kind === 'const' || kind === 'let') { 27885 tolerateUnexpectedToken(lookahead, Messages.UnexpectedToken); 27886 } 27887 } 27888 27889 params.push(lookahead); 27890 return parseVariableIdentifier(kind); 27891 } 27892 27893 function parsePatternWithDefault(params, kind) { 27894 var startToken = lookahead, pattern, previousAllowYield, right; 27895 pattern = parsePattern(params, kind); 27896 if (match('=')) { 27897 lex(); 27898 previousAllowYield = state.allowYield; 27899 state.allowYield = true; 27900 right = isolateCoverGrammar(parseAssignmentExpression); 27901 state.allowYield = previousAllowYield; 27902 pattern = new WrappingNode(startToken).finishAssignmentPattern(pattern, right); 27903 } 27904 return pattern; 27905 } 27906 27907 // ECMA-262 12.2.5 Array Initializer 27908 27909 function parseArrayInitializer() { 27910 var elements = [], node = new Node(), restSpread; 27911 27912 expect('['); 27913 27914 while (!match(']')) { 27915 if (match(',')) { 27916 lex(); 27917 elements.push(null); 27918 } else if (match('...')) { 27919 restSpread = new Node(); 27920 lex(); 27921 restSpread.finishSpreadElement(inheritCoverGrammar(parseAssignmentExpression)); 27922 27923 if (!match(']')) { 27924 isAssignmentTarget = isBindingElement = false; 27925 expect(','); 27926 } 27927 elements.push(restSpread); 27928 } else { 27929 elements.push(inheritCoverGrammar(parseAssignmentExpression)); 27930 27931 if (!match(']')) { 27932 expect(','); 27933 } 27934 } 27935 } 27936 27937 lex(); 27938 27939 return node.finishArrayExpression(elements); 27940 } 27941 27942 // ECMA-262 12.2.6 Object Initializer 27943 27944 function parsePropertyFunction(node, paramInfo, isGenerator) { 27945 var previousStrict, body; 27946 27947 isAssignmentTarget = isBindingElement = false; 27948 27949 previousStrict = strict; 27950 body = isolateCoverGrammar(parseFunctionSourceElements); 27951 27952 if (strict && paramInfo.firstRestricted) { 27953 tolerateUnexpectedToken(paramInfo.firstRestricted, paramInfo.message); 27954 } 27955 if (strict && paramInfo.stricted) { 27956 tolerateUnexpectedToken(paramInfo.stricted, paramInfo.message); 27957 } 27958 27959 strict = previousStrict; 27960 return node.finishFunctionExpression(null, paramInfo.params, paramInfo.defaults, body, isGenerator); 27961 } 27962 27963 function parsePropertyMethodFunction() { 27964 var params, method, node = new Node(), 27965 previousAllowYield = state.allowYield; 27966 27967 state.allowYield = false; 27968 params = parseParams(); 27969 state.allowYield = previousAllowYield; 27970 27971 state.allowYield = false; 27972 method = parsePropertyFunction(node, params, false); 27973 state.allowYield = previousAllowYield; 27974 27975 return method; 27976 } 27977 27978 function parseObjectPropertyKey() { 27979 var token, node = new Node(), expr; 27980 27981 token = lex(); 27982 27983 // Note: This function is called only from parseObjectProperty(), where 27984 // EOF and Punctuator tokens are already filtered out. 27985 27986 switch (token.type) { 27987 case Token.StringLiteral: 27988 case Token.NumericLiteral: 27989 if (strict && token.octal) { 27990 tolerateUnexpectedToken(token, Messages.StrictOctalLiteral); 27991 } 27992 return node.finishLiteral(token); 27993 case Token.Identifier: 27994 case Token.BooleanLiteral: 27995 case Token.NullLiteral: 27996 case Token.Keyword: 27997 return node.finishIdentifier(token.value); 27998 case Token.Punctuator: 27999 if (token.value === '[') { 28000 expr = isolateCoverGrammar(parseAssignmentExpression); 28001 expect(']'); 28002 return expr; 28003 } 28004 break; 28005 } 28006 throwUnexpectedToken(token); 28007 } 28008 28009 function lookaheadPropertyName() { 28010 switch (lookahead.type) { 28011 case Token.Identifier: 28012 case Token.StringLiteral: 28013 case Token.BooleanLiteral: 28014 case Token.NullLiteral: 28015 case Token.NumericLiteral: 28016 case Token.Keyword: 28017 return true; 28018 case Token.Punctuator: 28019 return lookahead.value === '['; 28020 } 28021 return false; 28022 } 28023 28024 // This function is to try to parse a MethodDefinition as defined in 14.3. But in the case of object literals, 28025 // it might be called at a position where there is in fact a short hand identifier pattern or a data property. 28026 // This can only be determined after we consumed up to the left parentheses. 28027 // 28028 // In order to avoid back tracking, it returns `null` if the position is not a MethodDefinition and the caller 28029 // is responsible to visit other options. 28030 function tryParseMethodDefinition(token, key, computed, node) { 28031 var value, options, methodNode, params, 28032 previousAllowYield = state.allowYield; 28033 28034 if (token.type === Token.Identifier) { 28035 // check for `get` and `set`; 28036 28037 if (token.value === 'get' && lookaheadPropertyName()) { 28038 computed = match('['); 28039 key = parseObjectPropertyKey(); 28040 methodNode = new Node(); 28041 expect('('); 28042 expect(')'); 28043 28044 state.allowYield = false; 28045 value = parsePropertyFunction(methodNode, { 28046 params: [], 28047 defaults: [], 28048 stricted: null, 28049 firstRestricted: null, 28050 message: null 28051 }, false); 28052 state.allowYield = previousAllowYield; 28053 28054 return node.finishProperty('get', key, computed, value, false, false); 28055 } else if (token.value === 'set' && lookaheadPropertyName()) { 28056 computed = match('['); 28057 key = parseObjectPropertyKey(); 28058 methodNode = new Node(); 28059 expect('('); 28060 28061 options = { 28062 params: [], 28063 defaultCount: 0, 28064 defaults: [], 28065 firstRestricted: null, 28066 paramSet: {} 28067 }; 28068 if (match(')')) { 28069 tolerateUnexpectedToken(lookahead); 28070 } else { 28071 state.allowYield = false; 28072 parseParam(options); 28073 state.allowYield = previousAllowYield; 28074 if (options.defaultCount === 0) { 28075 options.defaults = []; 28076 } 28077 } 28078 expect(')'); 28079 28080 state.allowYield = false; 28081 value = parsePropertyFunction(methodNode, options, false); 28082 state.allowYield = previousAllowYield; 28083 28084 return node.finishProperty('set', key, computed, value, false, false); 28085 } 28086 } else if (token.type === Token.Punctuator && token.value === '*' && lookaheadPropertyName()) { 28087 computed = match('['); 28088 key = parseObjectPropertyKey(); 28089 methodNode = new Node(); 28090 28091 state.allowYield = true; 28092 params = parseParams(); 28093 state.allowYield = previousAllowYield; 28094 28095 state.allowYield = false; 28096 value = parsePropertyFunction(methodNode, params, true); 28097 state.allowYield = previousAllowYield; 28098 28099 return node.finishProperty('init', key, computed, value, true, false); 28100 } 28101 28102 if (key && match('(')) { 28103 value = parsePropertyMethodFunction(); 28104 return node.finishProperty('init', key, computed, value, true, false); 28105 } 28106 28107 // Not a MethodDefinition. 28108 return null; 28109 } 28110 28111 function parseObjectProperty(hasProto) { 28112 var token = lookahead, node = new Node(), computed, key, maybeMethod, proto, value; 28113 28114 computed = match('['); 28115 if (match('*')) { 28116 lex(); 28117 } else { 28118 key = parseObjectPropertyKey(); 28119 } 28120 maybeMethod = tryParseMethodDefinition(token, key, computed, node); 28121 if (maybeMethod) { 28122 return maybeMethod; 28123 } 28124 28125 if (!key) { 28126 throwUnexpectedToken(lookahead); 28127 } 28128 28129 // Check for duplicated __proto__ 28130 if (!computed) { 28131 proto = (key.type === Syntax.Identifier && key.name === '__proto__') || 28132 (key.type === Syntax.Literal && key.value === '__proto__'); 28133 if (hasProto.value && proto) { 28134 tolerateError(Messages.DuplicateProtoProperty); 28135 } 28136 hasProto.value |= proto; 28137 } 28138 28139 if (match(':')) { 28140 lex(); 28141 value = inheritCoverGrammar(parseAssignmentExpression); 28142 return node.finishProperty('init', key, computed, value, false, false); 28143 } 28144 28145 if (token.type === Token.Identifier) { 28146 if (match('=')) { 28147 firstCoverInitializedNameError = lookahead; 28148 lex(); 28149 value = isolateCoverGrammar(parseAssignmentExpression); 28150 return node.finishProperty('init', key, computed, 28151 new WrappingNode(token).finishAssignmentPattern(key, value), false, true); 28152 } 28153 return node.finishProperty('init', key, computed, key, false, true); 28154 } 28155 28156 throwUnexpectedToken(lookahead); 28157 } 28158 28159 function parseObjectInitializer() { 28160 var properties = [], hasProto = {value: false}, node = new Node(); 28161 28162 expect('{'); 28163 28164 while (!match('}')) { 28165 properties.push(parseObjectProperty(hasProto)); 28166 28167 if (!match('}')) { 28168 expectCommaSeparator(); 28169 } 28170 } 28171 28172 expect('}'); 28173 28174 return node.finishObjectExpression(properties); 28175 } 28176 28177 function reinterpretExpressionAsPattern(expr) { 28178 var i; 28179 switch (expr.type) { 28180 case Syntax.Identifier: 28181 case Syntax.MemberExpression: 28182 case Syntax.RestElement: 28183 case Syntax.AssignmentPattern: 28184 break; 28185 case Syntax.SpreadElement: 28186 expr.type = Syntax.RestElement; 28187 reinterpretExpressionAsPattern(expr.argument); 28188 break; 28189 case Syntax.ArrayExpression: 28190 expr.type = Syntax.ArrayPattern; 28191 for (i = 0; i < expr.elements.length; i++) { 28192 if (expr.elements[i] !== null) { 28193 reinterpretExpressionAsPattern(expr.elements[i]); 28194 } 28195 } 28196 break; 28197 case Syntax.ObjectExpression: 28198 expr.type = Syntax.ObjectPattern; 28199 for (i = 0; i < expr.properties.length; i++) { 28200 reinterpretExpressionAsPattern(expr.properties[i].value); 28201 } 28202 break; 28203 case Syntax.AssignmentExpression: 28204 expr.type = Syntax.AssignmentPattern; 28205 reinterpretExpressionAsPattern(expr.left); 28206 break; 28207 default: 28208 // Allow other node type for tolerant parsing. 28209 break; 28210 } 28211 } 28212 28213 // ECMA-262 12.2.9 Template Literals 28214 28215 function parseTemplateElement(option) { 28216 var node, token; 28217 28218 if (lookahead.type !== Token.Template || (option.head && !lookahead.head)) { 28219 throwUnexpectedToken(); 28220 } 28221 28222 node = new Node(); 28223 token = lex(); 28224 28225 return node.finishTemplateElement({ raw: token.value.raw, cooked: token.value.cooked }, token.tail); 28226 } 28227 28228 function parseTemplateLiteral() { 28229 var quasi, quasis, expressions, node = new Node(); 28230 28231 quasi = parseTemplateElement({ head: true }); 28232 quasis = [quasi]; 28233 expressions = []; 28234 28235 while (!quasi.tail) { 28236 expressions.push(parseExpression()); 28237 quasi = parseTemplateElement({ head: false }); 28238 quasis.push(quasi); 28239 } 28240 28241 return node.finishTemplateLiteral(quasis, expressions); 28242 } 28243 28244 // ECMA-262 12.2.10 The Grouping Operator 28245 28246 function parseGroupExpression() { 28247 var expr, expressions, startToken, i, params = []; 28248 28249 expect('('); 28250 28251 if (match(')')) { 28252 lex(); 28253 if (!match('=>')) { 28254 expect('=>'); 28255 } 28256 return { 28257 type: PlaceHolders.ArrowParameterPlaceHolder, 28258 params: [], 28259 rawParams: [] 28260 }; 28261 } 28262 28263 startToken = lookahead; 28264 if (match('...')) { 28265 expr = parseRestElement(params); 28266 expect(')'); 28267 if (!match('=>')) { 28268 expect('=>'); 28269 } 28270 return { 28271 type: PlaceHolders.ArrowParameterPlaceHolder, 28272 params: [expr] 28273 }; 28274 } 28275 28276 isBindingElement = true; 28277 expr = inheritCoverGrammar(parseAssignmentExpression); 28278 28279 if (match(',')) { 28280 isAssignmentTarget = false; 28281 expressions = [expr]; 28282 28283 while (startIndex < length) { 28284 if (!match(',')) { 28285 break; 28286 } 28287 lex(); 28288 28289 if (match('...')) { 28290 if (!isBindingElement) { 28291 throwUnexpectedToken(lookahead); 28292 } 28293 expressions.push(parseRestElement(params)); 28294 expect(')'); 28295 if (!match('=>')) { 28296 expect('=>'); 28297 } 28298 isBindingElement = false; 28299 for (i = 0; i < expressions.length; i++) { 28300 reinterpretExpressionAsPattern(expressions[i]); 28301 } 28302 return { 28303 type: PlaceHolders.ArrowParameterPlaceHolder, 28304 params: expressions 28305 }; 28306 } 28307 28308 expressions.push(inheritCoverGrammar(parseAssignmentExpression)); 28309 } 28310 28311 expr = new WrappingNode(startToken).finishSequenceExpression(expressions); 28312 } 28313 28314 28315 expect(')'); 28316 28317 if (match('=>')) { 28318 if (expr.type === Syntax.Identifier && expr.name === 'yield') { 28319 return { 28320 type: PlaceHolders.ArrowParameterPlaceHolder, 28321 params: [expr] 28322 }; 28323 } 28324 28325 if (!isBindingElement) { 28326 throwUnexpectedToken(lookahead); 28327 } 28328 28329 if (expr.type === Syntax.SequenceExpression) { 28330 for (i = 0; i < expr.expressions.length; i++) { 28331 reinterpretExpressionAsPattern(expr.expressions[i]); 28332 } 28333 } else { 28334 reinterpretExpressionAsPattern(expr); 28335 } 28336 28337 expr = { 28338 type: PlaceHolders.ArrowParameterPlaceHolder, 28339 params: expr.type === Syntax.SequenceExpression ? expr.expressions : [expr] 28340 }; 28341 } 28342 isBindingElement = false; 28343 return expr; 28344 } 28345 28346 28347 // ECMA-262 12.2 Primary Expressions 28348 28349 function parsePrimaryExpression() { 28350 var type, token, expr, node; 28351 28352 if (match('(')) { 28353 isBindingElement = false; 28354 return inheritCoverGrammar(parseGroupExpression); 28355 } 28356 28357 if (match('[')) { 28358 return inheritCoverGrammar(parseArrayInitializer); 28359 } 28360 28361 if (match('{')) { 28362 return inheritCoverGrammar(parseObjectInitializer); 28363 } 28364 28365 type = lookahead.type; 28366 node = new Node(); 28367 28368 if (type === Token.Identifier) { 28369 if (state.sourceType === 'module' && lookahead.value === 'await') { 28370 tolerateUnexpectedToken(lookahead); 28371 } 28372 expr = node.finishIdentifier(lex().value); 28373 } else if (type === Token.StringLiteral || type === Token.NumericLiteral) { 28374 isAssignmentTarget = isBindingElement = false; 28375 if (strict && lookahead.octal) { 28376 tolerateUnexpectedToken(lookahead, Messages.StrictOctalLiteral); 28377 } 28378 expr = node.finishLiteral(lex()); 28379 } else if (type === Token.Keyword) { 28380 if (!strict && state.allowYield && matchKeyword('yield')) { 28381 return parseNonComputedProperty(); 28382 } 28383 if (!strict && matchKeyword('let')) { 28384 return node.finishIdentifier(lex().value); 28385 } 28386 isAssignmentTarget = isBindingElement = false; 28387 if (matchKeyword('function')) { 28388 return parseFunctionExpression(); 28389 } 28390 if (matchKeyword('this')) { 28391 lex(); 28392 return node.finishThisExpression(); 28393 } 28394 if (matchKeyword('class')) { 28395 return parseClassExpression(); 28396 } 28397 throwUnexpectedToken(lex()); 28398 } else if (type === Token.BooleanLiteral) { 28399 isAssignmentTarget = isBindingElement = false; 28400 token = lex(); 28401 token.value = (token.value === 'true'); 28402 expr = node.finishLiteral(token); 28403 } else if (type === Token.NullLiteral) { 28404 isAssignmentTarget = isBindingElement = false; 28405 token = lex(); 28406 token.value = null; 28407 expr = node.finishLiteral(token); 28408 } else if (match('/') || match('/=')) { 28409 isAssignmentTarget = isBindingElement = false; 28410 index = startIndex; 28411 28412 if (typeof extra.tokens !== 'undefined') { 28413 token = collectRegex(); 28414 } else { 28415 token = scanRegExp(); 28416 } 28417 lex(); 28418 expr = node.finishLiteral(token); 28419 } else if (type === Token.Template) { 28420 expr = parseTemplateLiteral(); 28421 } else { 28422 throwUnexpectedToken(lex()); 28423 } 28424 28425 return expr; 28426 } 28427 28428 // ECMA-262 12.3 Left-Hand-Side Expressions 28429 28430 function parseArguments() { 28431 var args = [], expr; 28432 28433 expect('('); 28434 28435 if (!match(')')) { 28436 while (startIndex < length) { 28437 if (match('...')) { 28438 expr = new Node(); 28439 lex(); 28440 expr.finishSpreadElement(isolateCoverGrammar(parseAssignmentExpression)); 28441 } else { 28442 expr = isolateCoverGrammar(parseAssignmentExpression); 28443 } 28444 args.push(expr); 28445 if (match(')')) { 28446 break; 28447 } 28448 expectCommaSeparator(); 28449 } 28450 } 28451 28452 expect(')'); 28453 28454 return args; 28455 } 28456 28457 function parseNonComputedProperty() { 28458 var token, node = new Node(); 28459 28460 token = lex(); 28461 28462 if (!isIdentifierName(token)) { 28463 throwUnexpectedToken(token); 28464 } 28465 28466 return node.finishIdentifier(token.value); 28467 } 28468 28469 function parseNonComputedMember() { 28470 expect('.'); 28471 28472 return parseNonComputedProperty(); 28473 } 28474 28475 function parseComputedMember() { 28476 var expr; 28477 28478 expect('['); 28479 28480 expr = isolateCoverGrammar(parseExpression); 28481 28482 expect(']'); 28483 28484 return expr; 28485 } 28486 28487 // ECMA-262 12.3.3 The new Operator 28488 28489 function parseNewExpression() { 28490 var callee, args, node = new Node(); 28491 28492 expectKeyword('new'); 28493 28494 if (match('.')) { 28495 lex(); 28496 if (lookahead.type === Token.Identifier && lookahead.value === 'target') { 28497 if (state.inFunctionBody) { 28498 lex(); 28499 return node.finishMetaProperty('new', 'target'); 28500 } 28501 } 28502 throwUnexpectedToken(lookahead); 28503 } 28504 28505 callee = isolateCoverGrammar(parseLeftHandSideExpression); 28506 args = match('(') ? parseArguments() : []; 28507 28508 isAssignmentTarget = isBindingElement = false; 28509 28510 return node.finishNewExpression(callee, args); 28511 } 28512 28513 // ECMA-262 12.3.4 Function Calls 28514 28515 function parseLeftHandSideExpressionAllowCall() { 28516 var quasi, expr, args, property, startToken, previousAllowIn = state.allowIn; 28517 28518 startToken = lookahead; 28519 state.allowIn = true; 28520 28521 if (matchKeyword('super') && state.inFunctionBody) { 28522 expr = new Node(); 28523 lex(); 28524 expr = expr.finishSuper(); 28525 if (!match('(') && !match('.') && !match('[')) { 28526 throwUnexpectedToken(lookahead); 28527 } 28528 } else { 28529 expr = inheritCoverGrammar(matchKeyword('new') ? parseNewExpression : parsePrimaryExpression); 28530 } 28531 28532 for (;;) { 28533 if (match('.')) { 28534 isBindingElement = false; 28535 isAssignmentTarget = true; 28536 property = parseNonComputedMember(); 28537 expr = new WrappingNode(startToken).finishMemberExpression('.', expr, property); 28538 } else if (match('(')) { 28539 isBindingElement = false; 28540 isAssignmentTarget = false; 28541 args = parseArguments(); 28542 expr = new WrappingNode(startToken).finishCallExpression(expr, args); 28543 } else if (match('[')) { 28544 isBindingElement = false; 28545 isAssignmentTarget = true; 28546 property = parseComputedMember(); 28547 expr = new WrappingNode(startToken).finishMemberExpression('[', expr, property); 28548 } else if (lookahead.type === Token.Template && lookahead.head) { 28549 quasi = parseTemplateLiteral(); 28550 expr = new WrappingNode(startToken).finishTaggedTemplateExpression(expr, quasi); 28551 } else { 28552 break; 28553 } 28554 } 28555 state.allowIn = previousAllowIn; 28556 28557 return expr; 28558 } 28559 28560 // ECMA-262 12.3 Left-Hand-Side Expressions 28561 28562 function parseLeftHandSideExpression() { 28563 var quasi, expr, property, startToken; 28564 assert(state.allowIn, 'callee of new expression always allow in keyword.'); 28565 28566 startToken = lookahead; 28567 28568 if (matchKeyword('super') && state.inFunctionBody) { 28569 expr = new Node(); 28570 lex(); 28571 expr = expr.finishSuper(); 28572 if (!match('[') && !match('.')) { 28573 throwUnexpectedToken(lookahead); 28574 } 28575 } else { 28576 expr = inheritCoverGrammar(matchKeyword('new') ? parseNewExpression : parsePrimaryExpression); 28577 } 28578 28579 for (;;) { 28580 if (match('[')) { 28581 isBindingElement = false; 28582 isAssignmentTarget = true; 28583 property = parseComputedMember(); 28584 expr = new WrappingNode(startToken).finishMemberExpression('[', expr, property); 28585 } else if (match('.')) { 28586 isBindingElement = false; 28587 isAssignmentTarget = true; 28588 property = parseNonComputedMember(); 28589 expr = new WrappingNode(startToken).finishMemberExpression('.', expr, property); 28590 } else if (lookahead.type === Token.Template && lookahead.head) { 28591 quasi = parseTemplateLiteral(); 28592 expr = new WrappingNode(startToken).finishTaggedTemplateExpression(expr, quasi); 28593 } else { 28594 break; 28595 } 28596 } 28597 return expr; 28598 } 28599 28600 // ECMA-262 12.4 Postfix Expressions 28601 28602 function parsePostfixExpression() { 28603 var expr, token, startToken = lookahead; 28604 28605 expr = inheritCoverGrammar(parseLeftHandSideExpressionAllowCall); 28606 28607 if (!hasLineTerminator && lookahead.type === Token.Punctuator) { 28608 if (match('++') || match('--')) { 28609 // ECMA-262 11.3.1, 11.3.2 28610 if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { 28611 tolerateError(Messages.StrictLHSPostfix); 28612 } 28613 28614 if (!isAssignmentTarget) { 28615 tolerateError(Messages.InvalidLHSInAssignment); 28616 } 28617 28618 isAssignmentTarget = isBindingElement = false; 28619 28620 token = lex(); 28621 expr = new WrappingNode(startToken).finishPostfixExpression(token.value, expr); 28622 } 28623 } 28624 28625 return expr; 28626 } 28627 28628 // ECMA-262 12.5 Unary Operators 28629 28630 function parseUnaryExpression() { 28631 var token, expr, startToken; 28632 28633 if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) { 28634 expr = parsePostfixExpression(); 28635 } else if (match('++') || match('--')) { 28636 startToken = lookahead; 28637 token = lex(); 28638 expr = inheritCoverGrammar(parseUnaryExpression); 28639 // ECMA-262 11.4.4, 11.4.5 28640 if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) { 28641 tolerateError(Messages.StrictLHSPrefix); 28642 } 28643 28644 if (!isAssignmentTarget) { 28645 tolerateError(Messages.InvalidLHSInAssignment); 28646 } 28647 expr = new WrappingNode(startToken).finishUnaryExpression(token.value, expr); 28648 isAssignmentTarget = isBindingElement = false; 28649 } else if (match('+') || match('-') || match('~') || match('!')) { 28650 startToken = lookahead; 28651 token = lex(); 28652 expr = inheritCoverGrammar(parseUnaryExpression); 28653 expr = new WrappingNode(startToken).finishUnaryExpression(token.value, expr); 28654 isAssignmentTarget = isBindingElement = false; 28655 } else if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) { 28656 startToken = lookahead; 28657 token = lex(); 28658 expr = inheritCoverGrammar(parseUnaryExpression); 28659 expr = new WrappingNode(startToken).finishUnaryExpression(token.value, expr); 28660 if (strict && expr.operator === 'delete' && expr.argument.type === Syntax.Identifier) { 28661 tolerateError(Messages.StrictDelete); 28662 } 28663 isAssignmentTarget = isBindingElement = false; 28664 } else { 28665 expr = parsePostfixExpression(); 28666 } 28667 28668 return expr; 28669 } 28670 28671 function binaryPrecedence(token, allowIn) { 28672 var prec = 0; 28673 28674 if (token.type !== Token.Punctuator && token.type !== Token.Keyword) { 28675 return 0; 28676 } 28677 28678 switch (token.value) { 28679 case '||': 28680 prec = 1; 28681 break; 28682 28683 case '&&': 28684 prec = 2; 28685 break; 28686 28687 case '|': 28688 prec = 3; 28689 break; 28690 28691 case '^': 28692 prec = 4; 28693 break; 28694 28695 case '&': 28696 prec = 5; 28697 break; 28698 28699 case '==': 28700 case '!=': 28701 case '===': 28702 case '!==': 28703 prec = 6; 28704 break; 28705 28706 case '<': 28707 case '>': 28708 case '<=': 28709 case '>=': 28710 case 'instanceof': 28711 prec = 7; 28712 break; 28713 28714 case 'in': 28715 prec = allowIn ? 7 : 0; 28716 break; 28717 28718 case '<<': 28719 case '>>': 28720 case '>>>': 28721 prec = 8; 28722 break; 28723 28724 case '+': 28725 case '-': 28726 prec = 9; 28727 break; 28728 28729 case '*': 28730 case '/': 28731 case '%': 28732 prec = 11; 28733 break; 28734 28735 default: 28736 break; 28737 } 28738 28739 return prec; 28740 } 28741 28742 // ECMA-262 12.6 Multiplicative Operators 28743 // ECMA-262 12.7 Additive Operators 28744 // ECMA-262 12.8 Bitwise Shift Operators 28745 // ECMA-262 12.9 Relational Operators 28746 // ECMA-262 12.10 Equality Operators 28747 // ECMA-262 12.11 Binary Bitwise Operators 28748 // ECMA-262 12.12 Binary Logical Operators 28749 28750 function parseBinaryExpression() { 28751 var marker, markers, expr, token, prec, stack, right, operator, left, i; 28752 28753 marker = lookahead; 28754 left = inheritCoverGrammar(parseUnaryExpression); 28755 28756 token = lookahead; 28757 prec = binaryPrecedence(token, state.allowIn); 28758 if (prec === 0) { 28759 return left; 28760 } 28761 isAssignmentTarget = isBindingElement = false; 28762 token.prec = prec; 28763 lex(); 28764 28765 markers = [marker, lookahead]; 28766 right = isolateCoverGrammar(parseUnaryExpression); 28767 28768 stack = [left, token, right]; 28769 28770 while ((prec = binaryPrecedence(lookahead, state.allowIn)) > 0) { 28771 28772 // Reduce: make a binary expression from the three topmost entries. 28773 while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) { 28774 right = stack.pop(); 28775 operator = stack.pop().value; 28776 left = stack.pop(); 28777 markers.pop(); 28778 expr = new WrappingNode(markers[markers.length - 1]).finishBinaryExpression(operator, left, right); 28779 stack.push(expr); 28780 } 28781 28782 // Shift. 28783 token = lex(); 28784 token.prec = prec; 28785 stack.push(token); 28786 markers.push(lookahead); 28787 expr = isolateCoverGrammar(parseUnaryExpression); 28788 stack.push(expr); 28789 } 28790 28791 // Final reduce to clean-up the stack. 28792 i = stack.length - 1; 28793 expr = stack[i]; 28794 markers.pop(); 28795 while (i > 1) { 28796 expr = new WrappingNode(markers.pop()).finishBinaryExpression(stack[i - 1].value, stack[i - 2], expr); 28797 i -= 2; 28798 } 28799 28800 return expr; 28801 } 28802 28803 28804 // ECMA-262 12.13 Conditional Operator 28805 28806 function parseConditionalExpression() { 28807 var expr, previousAllowIn, consequent, alternate, startToken; 28808 28809 startToken = lookahead; 28810 28811 expr = inheritCoverGrammar(parseBinaryExpression); 28812 if (match('?')) { 28813 lex(); 28814 previousAllowIn = state.allowIn; 28815 state.allowIn = true; 28816 consequent = isolateCoverGrammar(parseAssignmentExpression); 28817 state.allowIn = previousAllowIn; 28818 expect(':'); 28819 alternate = isolateCoverGrammar(parseAssignmentExpression); 28820 28821 expr = new WrappingNode(startToken).finishConditionalExpression(expr, consequent, alternate); 28822 isAssignmentTarget = isBindingElement = false; 28823 } 28824 28825 return expr; 28826 } 28827 28828 // ECMA-262 14.2 Arrow Function Definitions 28829 28830 function parseConciseBody() { 28831 if (match('{')) { 28832 return parseFunctionSourceElements(); 28833 } 28834 return isolateCoverGrammar(parseAssignmentExpression); 28835 } 28836 28837 function checkPatternParam(options, param) { 28838 var i; 28839 switch (param.type) { 28840 case Syntax.Identifier: 28841 validateParam(options, param, param.name); 28842 break; 28843 case Syntax.RestElement: 28844 checkPatternParam(options, param.argument); 28845 break; 28846 case Syntax.AssignmentPattern: 28847 checkPatternParam(options, param.left); 28848 break; 28849 case Syntax.ArrayPattern: 28850 for (i = 0; i < param.elements.length; i++) { 28851 if (param.elements[i] !== null) { 28852 checkPatternParam(options, param.elements[i]); 28853 } 28854 } 28855 break; 28856 case Syntax.YieldExpression: 28857 break; 28858 default: 28859 assert(param.type === Syntax.ObjectPattern, 'Invalid type'); 28860 for (i = 0; i < param.properties.length; i++) { 28861 checkPatternParam(options, param.properties[i].value); 28862 } 28863 break; 28864 } 28865 } 28866 function reinterpretAsCoverFormalsList(expr) { 28867 var i, len, param, params, defaults, defaultCount, options, token; 28868 28869 defaults = []; 28870 defaultCount = 0; 28871 params = [expr]; 28872 28873 switch (expr.type) { 28874 case Syntax.Identifier: 28875 break; 28876 case PlaceHolders.ArrowParameterPlaceHolder: 28877 params = expr.params; 28878 break; 28879 default: 28880 return null; 28881 } 28882 28883 options = { 28884 paramSet: {} 28885 }; 28886 28887 for (i = 0, len = params.length; i < len; i += 1) { 28888 param = params[i]; 28889 switch (param.type) { 28890 case Syntax.AssignmentPattern: 28891 params[i] = param.left; 28892 if (param.right.type === Syntax.YieldExpression) { 28893 if (param.right.argument) { 28894 throwUnexpectedToken(lookahead); 28895 } 28896 param.right.type = Syntax.Identifier; 28897 param.right.name = 'yield'; 28898 delete param.right.argument; 28899 delete param.right.delegate; 28900 } 28901 defaults.push(param.right); 28902 ++defaultCount; 28903 checkPatternParam(options, param.left); 28904 break; 28905 default: 28906 checkPatternParam(options, param); 28907 params[i] = param; 28908 defaults.push(null); 28909 break; 28910 } 28911 } 28912 28913 if (strict || !state.allowYield) { 28914 for (i = 0, len = params.length; i < len; i += 1) { 28915 param = params[i]; 28916 if (param.type === Syntax.YieldExpression) { 28917 throwUnexpectedToken(lookahead); 28918 } 28919 } 28920 } 28921 28922 if (options.message === Messages.StrictParamDupe) { 28923 token = strict ? options.stricted : options.firstRestricted; 28924 throwUnexpectedToken(token, options.message); 28925 } 28926 28927 if (defaultCount === 0) { 28928 defaults = []; 28929 } 28930 28931 return { 28932 params: params, 28933 defaults: defaults, 28934 stricted: options.stricted, 28935 firstRestricted: options.firstRestricted, 28936 message: options.message 28937 }; 28938 } 28939 28940 function parseArrowFunctionExpression(options, node) { 28941 var previousStrict, previousAllowYield, body; 28942 28943 if (hasLineTerminator) { 28944 tolerateUnexpectedToken(lookahead); 28945 } 28946 expect('=>'); 28947 28948 previousStrict = strict; 28949 previousAllowYield = state.allowYield; 28950 state.allowYield = true; 28951 28952 body = parseConciseBody(); 28953 28954 if (strict && options.firstRestricted) { 28955 throwUnexpectedToken(options.firstRestricted, options.message); 28956 } 28957 if (strict && options.stricted) { 28958 tolerateUnexpectedToken(options.stricted, options.message); 28959 } 28960 28961 strict = previousStrict; 28962 state.allowYield = previousAllowYield; 28963 28964 return node.finishArrowFunctionExpression(options.params, options.defaults, body, body.type !== Syntax.BlockStatement); 28965 } 28966 28967 // ECMA-262 14.4 Yield expression 28968 28969 function parseYieldExpression() { 28970 var argument, expr, delegate, previousAllowYield; 28971 28972 argument = null; 28973 expr = new Node(); 28974 delegate = false; 28975 28976 expectKeyword('yield'); 28977 28978 if (!hasLineTerminator) { 28979 previousAllowYield = state.allowYield; 28980 state.allowYield = false; 28981 delegate = match('*'); 28982 if (delegate) { 28983 lex(); 28984 argument = parseAssignmentExpression(); 28985 } else { 28986 if (!match(';') && !match('}') && !match(')') && lookahead.type !== Token.EOF) { 28987 argument = parseAssignmentExpression(); 28988 } 28989 } 28990 state.allowYield = previousAllowYield; 28991 } 28992 28993 return expr.finishYieldExpression(argument, delegate); 28994 } 28995 28996 // ECMA-262 12.14 Assignment Operators 28997 28998 function parseAssignmentExpression() { 28999 var token, expr, right, list, startToken; 29000 29001 startToken = lookahead; 29002 token = lookahead; 29003 29004 if (!state.allowYield && matchKeyword('yield')) { 29005 return parseYieldExpression(); 29006 } 29007 29008 expr = parseConditionalExpression(); 29009 29010 if (expr.type === PlaceHolders.ArrowParameterPlaceHolder || match('=>')) { 29011 isAssignmentTarget = isBindingElement = false; 29012 list = reinterpretAsCoverFormalsList(expr); 29013 29014 if (list) { 29015 firstCoverInitializedNameError = null; 29016 return parseArrowFunctionExpression(list, new WrappingNode(startToken)); 29017 } 29018 29019 return expr; 29020 } 29021 29022 if (matchAssign()) { 29023 if (!isAssignmentTarget) { 29024 tolerateError(Messages.InvalidLHSInAssignment); 29025 } 29026 29027 // ECMA-262 12.1.1 29028 if (strict && expr.type === Syntax.Identifier) { 29029 if (isRestrictedWord(expr.name)) { 29030 tolerateUnexpectedToken(token, Messages.StrictLHSAssignment); 29031 } 29032 if (isStrictModeReservedWord(expr.name)) { 29033 tolerateUnexpectedToken(token, Messages.StrictReservedWord); 29034 } 29035 } 29036 29037 if (!match('=')) { 29038 isAssignmentTarget = isBindingElement = false; 29039 } else { 29040 reinterpretExpressionAsPattern(expr); 29041 } 29042 29043 token = lex(); 29044 right = isolateCoverGrammar(parseAssignmentExpression); 29045 expr = new WrappingNode(startToken).finishAssignmentExpression(token.value, expr, right); 29046 firstCoverInitializedNameError = null; 29047 } 29048 29049 return expr; 29050 } 29051 29052 // ECMA-262 12.15 Comma Operator 29053 29054 function parseExpression() { 29055 var expr, startToken = lookahead, expressions; 29056 29057 expr = isolateCoverGrammar(parseAssignmentExpression); 29058 29059 if (match(',')) { 29060 expressions = [expr]; 29061 29062 while (startIndex < length) { 29063 if (!match(',')) { 29064 break; 29065 } 29066 lex(); 29067 expressions.push(isolateCoverGrammar(parseAssignmentExpression)); 29068 } 29069 29070 expr = new WrappingNode(startToken).finishSequenceExpression(expressions); 29071 } 29072 29073 return expr; 29074 } 29075 29076 // ECMA-262 13.2 Block 29077 29078 function parseStatementListItem() { 29079 if (lookahead.type === Token.Keyword) { 29080 switch (lookahead.value) { 29081 case 'export': 29082 if (state.sourceType !== 'module') { 29083 tolerateUnexpectedToken(lookahead, Messages.IllegalExportDeclaration); 29084 } 29085 return parseExportDeclaration(); 29086 case 'import': 29087 if (state.sourceType !== 'module') { 29088 tolerateUnexpectedToken(lookahead, Messages.IllegalImportDeclaration); 29089 } 29090 return parseImportDeclaration(); 29091 case 'const': 29092 return parseLexicalDeclaration({inFor: false}); 29093 case 'function': 29094 return parseFunctionDeclaration(new Node()); 29095 case 'class': 29096 return parseClassDeclaration(); 29097 } 29098 } 29099 29100 if (matchKeyword('let') && isLexicalDeclaration()) { 29101 return parseLexicalDeclaration({inFor: false}); 29102 } 29103 29104 return parseStatement(); 29105 } 29106 29107 function parseStatementList() { 29108 var list = []; 29109 while (startIndex < length) { 29110 if (match('}')) { 29111 break; 29112 } 29113 list.push(parseStatementListItem()); 29114 } 29115 29116 return list; 29117 } 29118 29119 function parseBlock() { 29120 var block, node = new Node(); 29121 29122 expect('{'); 29123 29124 block = parseStatementList(); 29125 29126 expect('}'); 29127 29128 return node.finishBlockStatement(block); 29129 } 29130 29131 // ECMA-262 13.3.2 Variable Statement 29132 29133 function parseVariableIdentifier(kind) { 29134 var token, node = new Node(); 29135 29136 token = lex(); 29137 29138 if (token.type === Token.Keyword && token.value === 'yield') { 29139 if (strict) { 29140 tolerateUnexpectedToken(token, Messages.StrictReservedWord); 29141 } if (!state.allowYield) { 29142 throwUnexpectedToken(token); 29143 } 29144 } else if (token.type !== Token.Identifier) { 29145 if (strict && token.type === Token.Keyword && isStrictModeReservedWord(token.value)) { 29146 tolerateUnexpectedToken(token, Messages.StrictReservedWord); 29147 } else { 29148 if (strict || token.value !== 'let' || kind !== 'var') { 29149 throwUnexpectedToken(token); 29150 } 29151 } 29152 } else if (state.sourceType === 'module' && token.type === Token.Identifier && token.value === 'await') { 29153 tolerateUnexpectedToken(token); 29154 } 29155 29156 return node.finishIdentifier(token.value); 29157 } 29158 29159 function parseVariableDeclaration(options) { 29160 var init = null, id, node = new Node(), params = []; 29161 29162 id = parsePattern(params, 'var'); 29163 29164 // ECMA-262 12.2.1 29165 if (strict && isRestrictedWord(id.name)) { 29166 tolerateError(Messages.StrictVarName); 29167 } 29168 29169 if (match('=')) { 29170 lex(); 29171 init = isolateCoverGrammar(parseAssignmentExpression); 29172 } else if (id.type !== Syntax.Identifier && !options.inFor) { 29173 expect('='); 29174 } 29175 29176 return node.finishVariableDeclarator(id, init); 29177 } 29178 29179 function parseVariableDeclarationList(options) { 29180 var opt, list; 29181 29182 opt = { inFor: options.inFor }; 29183 list = [parseVariableDeclaration(opt)]; 29184 29185 while (match(',')) { 29186 lex(); 29187 list.push(parseVariableDeclaration(opt)); 29188 } 29189 29190 return list; 29191 } 29192 29193 function parseVariableStatement(node) { 29194 var declarations; 29195 29196 expectKeyword('var'); 29197 29198 declarations = parseVariableDeclarationList({ inFor: false }); 29199 29200 consumeSemicolon(); 29201 29202 return node.finishVariableDeclaration(declarations); 29203 } 29204 29205 // ECMA-262 13.3.1 Let and Const Declarations 29206 29207 function parseLexicalBinding(kind, options) { 29208 var init = null, id, node = new Node(), params = []; 29209 29210 id = parsePattern(params, kind); 29211 29212 // ECMA-262 12.2.1 29213 if (strict && id.type === Syntax.Identifier && isRestrictedWord(id.name)) { 29214 tolerateError(Messages.StrictVarName); 29215 } 29216 29217 if (kind === 'const') { 29218 if (!matchKeyword('in') && !matchContextualKeyword('of')) { 29219 expect('='); 29220 init = isolateCoverGrammar(parseAssignmentExpression); 29221 } 29222 } else if ((!options.inFor && id.type !== Syntax.Identifier) || match('=')) { 29223 expect('='); 29224 init = isolateCoverGrammar(parseAssignmentExpression); 29225 } 29226 29227 return node.finishVariableDeclarator(id, init); 29228 } 29229 29230 function parseBindingList(kind, options) { 29231 var list = [parseLexicalBinding(kind, options)]; 29232 29233 while (match(',')) { 29234 lex(); 29235 list.push(parseLexicalBinding(kind, options)); 29236 } 29237 29238 return list; 29239 } 29240 29241 29242 function tokenizerState() { 29243 return { 29244 index: index, 29245 lineNumber: lineNumber, 29246 lineStart: lineStart, 29247 hasLineTerminator: hasLineTerminator, 29248 lastIndex: lastIndex, 29249 lastLineNumber: lastLineNumber, 29250 lastLineStart: lastLineStart, 29251 startIndex: startIndex, 29252 startLineNumber: startLineNumber, 29253 startLineStart: startLineStart, 29254 lookahead: lookahead, 29255 tokenCount: extra.tokens ? extra.tokens.length : 0 29256 }; 29257 } 29258 29259 function resetTokenizerState(ts) { 29260 index = ts.index; 29261 lineNumber = ts.lineNumber; 29262 lineStart = ts.lineStart; 29263 hasLineTerminator = ts.hasLineTerminator; 29264 lastIndex = ts.lastIndex; 29265 lastLineNumber = ts.lastLineNumber; 29266 lastLineStart = ts.lastLineStart; 29267 startIndex = ts.startIndex; 29268 startLineNumber = ts.startLineNumber; 29269 startLineStart = ts.startLineStart; 29270 lookahead = ts.lookahead; 29271 if (extra.tokens) { 29272 extra.tokens.splice(ts.tokenCount, extra.tokens.length); 29273 } 29274 } 29275 29276 function isLexicalDeclaration() { 29277 var lexical, ts; 29278 29279 ts = tokenizerState(); 29280 29281 lex(); 29282 lexical = (lookahead.type === Token.Identifier) || match('[') || match('{') || 29283 matchKeyword('let') || matchKeyword('yield'); 29284 29285 resetTokenizerState(ts); 29286 29287 return lexical; 29288 } 29289 29290 function parseLexicalDeclaration(options) { 29291 var kind, declarations, node = new Node(); 29292 29293 kind = lex().value; 29294 assert(kind === 'let' || kind === 'const', 'Lexical declaration must be either let or const'); 29295 29296 declarations = parseBindingList(kind, options); 29297 29298 consumeSemicolon(); 29299 29300 return node.finishLexicalDeclaration(declarations, kind); 29301 } 29302 29303 function parseRestElement(params) { 29304 var param, node = new Node(); 29305 29306 lex(); 29307 29308 if (match('{')) { 29309 throwError(Messages.ObjectPatternAsRestParameter); 29310 } 29311 29312 params.push(lookahead); 29313 29314 param = parseVariableIdentifier(); 29315 29316 if (match('=')) { 29317 throwError(Messages.DefaultRestParameter); 29318 } 29319 29320 if (!match(')')) { 29321 throwError(Messages.ParameterAfterRestParameter); 29322 } 29323 29324 return node.finishRestElement(param); 29325 } 29326 29327 // ECMA-262 13.4 Empty Statement 29328 29329 function parseEmptyStatement(node) { 29330 expect(';'); 29331 return node.finishEmptyStatement(); 29332 } 29333 29334 // ECMA-262 12.4 Expression Statement 29335 29336 function parseExpressionStatement(node) { 29337 var expr = parseExpression(); 29338 consumeSemicolon(); 29339 return node.finishExpressionStatement(expr); 29340 } 29341 29342 // ECMA-262 13.6 If statement 29343 29344 function parseIfStatement(node) { 29345 var test, consequent, alternate; 29346 29347 expectKeyword('if'); 29348 29349 expect('('); 29350 29351 test = parseExpression(); 29352 29353 expect(')'); 29354 29355 consequent = parseStatement(); 29356 29357 if (matchKeyword('else')) { 29358 lex(); 29359 alternate = parseStatement(); 29360 } else { 29361 alternate = null; 29362 } 29363 29364 return node.finishIfStatement(test, consequent, alternate); 29365 } 29366 29367 // ECMA-262 13.7 Iteration Statements 29368 29369 function parseDoWhileStatement(node) { 29370 var body, test, oldInIteration; 29371 29372 expectKeyword('do'); 29373 29374 oldInIteration = state.inIteration; 29375 state.inIteration = true; 29376 29377 body = parseStatement(); 29378 29379 state.inIteration = oldInIteration; 29380 29381 expectKeyword('while'); 29382 29383 expect('('); 29384 29385 test = parseExpression(); 29386 29387 expect(')'); 29388 29389 if (match(';')) { 29390 lex(); 29391 } 29392 29393 return node.finishDoWhileStatement(body, test); 29394 } 29395 29396 function parseWhileStatement(node) { 29397 var test, body, oldInIteration; 29398 29399 expectKeyword('while'); 29400 29401 expect('('); 29402 29403 test = parseExpression(); 29404 29405 expect(')'); 29406 29407 oldInIteration = state.inIteration; 29408 state.inIteration = true; 29409 29410 body = parseStatement(); 29411 29412 state.inIteration = oldInIteration; 29413 29414 return node.finishWhileStatement(test, body); 29415 } 29416 29417 function parseForStatement(node) { 29418 var init, forIn, initSeq, initStartToken, test, update, left, right, kind, declarations, 29419 body, oldInIteration, previousAllowIn = state.allowIn; 29420 29421 init = test = update = null; 29422 forIn = true; 29423 29424 expectKeyword('for'); 29425 29426 expect('('); 29427 29428 if (match(';')) { 29429 lex(); 29430 } else { 29431 if (matchKeyword('var')) { 29432 init = new Node(); 29433 lex(); 29434 29435 state.allowIn = false; 29436 declarations = parseVariableDeclarationList({ inFor: true }); 29437 state.allowIn = previousAllowIn; 29438 29439 if (declarations.length === 1 && matchKeyword('in')) { 29440 init = init.finishVariableDeclaration(declarations); 29441 lex(); 29442 left = init; 29443 right = parseExpression(); 29444 init = null; 29445 } else if (declarations.length === 1 && declarations[0].init === null && matchContextualKeyword('of')) { 29446 init = init.finishVariableDeclaration(declarations); 29447 lex(); 29448 left = init; 29449 right = parseAssignmentExpression(); 29450 init = null; 29451 forIn = false; 29452 } else { 29453 init = init.finishVariableDeclaration(declarations); 29454 expect(';'); 29455 } 29456 } else if (matchKeyword('const') || matchKeyword('let')) { 29457 init = new Node(); 29458 kind = lex().value; 29459 29460 if (!strict && lookahead.value === 'in') { 29461 init = init.finishIdentifier(kind); 29462 lex(); 29463 left = init; 29464 right = parseExpression(); 29465 init = null; 29466 } else { 29467 state.allowIn = false; 29468 declarations = parseBindingList(kind, {inFor: true}); 29469 state.allowIn = previousAllowIn; 29470 29471 if (declarations.length === 1 && declarations[0].init === null && matchKeyword('in')) { 29472 init = init.finishLexicalDeclaration(declarations, kind); 29473 lex(); 29474 left = init; 29475 right = parseExpression(); 29476 init = null; 29477 } else if (declarations.length === 1 && declarations[0].init === null && matchContextualKeyword('of')) { 29478 init = init.finishLexicalDeclaration(declarations, kind); 29479 lex(); 29480 left = init; 29481 right = parseAssignmentExpression(); 29482 init = null; 29483 forIn = false; 29484 } else { 29485 consumeSemicolon(); 29486 init = init.finishLexicalDeclaration(declarations, kind); 29487 } 29488 } 29489 } else { 29490 initStartToken = lookahead; 29491 state.allowIn = false; 29492 init = inheritCoverGrammar(parseAssignmentExpression); 29493 state.allowIn = previousAllowIn; 29494 29495 if (matchKeyword('in')) { 29496 if (!isAssignmentTarget) { 29497 tolerateError(Messages.InvalidLHSInForIn); 29498 } 29499 29500 lex(); 29501 reinterpretExpressionAsPattern(init); 29502 left = init; 29503 right = parseExpression(); 29504 init = null; 29505 } else if (matchContextualKeyword('of')) { 29506 if (!isAssignmentTarget) { 29507 tolerateError(Messages.InvalidLHSInForLoop); 29508 } 29509 29510 lex(); 29511 reinterpretExpressionAsPattern(init); 29512 left = init; 29513 right = parseAssignmentExpression(); 29514 init = null; 29515 forIn = false; 29516 } else { 29517 if (match(',')) { 29518 initSeq = [init]; 29519 while (match(',')) { 29520 lex(); 29521 initSeq.push(isolateCoverGrammar(parseAssignmentExpression)); 29522 } 29523 init = new WrappingNode(initStartToken).finishSequenceExpression(initSeq); 29524 } 29525 expect(';'); 29526 } 29527 } 29528 } 29529 29530 if (typeof left === 'undefined') { 29531 29532 if (!match(';')) { 29533 test = parseExpression(); 29534 } 29535 expect(';'); 29536 29537 if (!match(')')) { 29538 update = parseExpression(); 29539 } 29540 } 29541 29542 expect(')'); 29543 29544 oldInIteration = state.inIteration; 29545 state.inIteration = true; 29546 29547 body = isolateCoverGrammar(parseStatement); 29548 29549 state.inIteration = oldInIteration; 29550 29551 return (typeof left === 'undefined') ? 29552 node.finishForStatement(init, test, update, body) : 29553 forIn ? node.finishForInStatement(left, right, body) : 29554 node.finishForOfStatement(left, right, body); 29555 } 29556 29557 // ECMA-262 13.8 The continue statement 29558 29559 function parseContinueStatement(node) { 29560 var label = null, key; 29561 29562 expectKeyword('continue'); 29563 29564 // Optimize the most common form: 'continue;'. 29565 if (source.charCodeAt(startIndex) === 0x3B) { 29566 lex(); 29567 29568 if (!state.inIteration) { 29569 throwError(Messages.IllegalContinue); 29570 } 29571 29572 return node.finishContinueStatement(null); 29573 } 29574 29575 if (hasLineTerminator) { 29576 if (!state.inIteration) { 29577 throwError(Messages.IllegalContinue); 29578 } 29579 29580 return node.finishContinueStatement(null); 29581 } 29582 29583 if (lookahead.type === Token.Identifier) { 29584 label = parseVariableIdentifier(); 29585 29586 key = '$' + label.name; 29587 if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) { 29588 throwError(Messages.UnknownLabel, label.name); 29589 } 29590 } 29591 29592 consumeSemicolon(); 29593 29594 if (label === null && !state.inIteration) { 29595 throwError(Messages.IllegalContinue); 29596 } 29597 29598 return node.finishContinueStatement(label); 29599 } 29600 29601 // ECMA-262 13.9 The break statement 29602 29603 function parseBreakStatement(node) { 29604 var label = null, key; 29605 29606 expectKeyword('break'); 29607 29608 // Catch the very common case first: immediately a semicolon (U+003B). 29609 if (source.charCodeAt(lastIndex) === 0x3B) { 29610 lex(); 29611 29612 if (!(state.inIteration || state.inSwitch)) { 29613 throwError(Messages.IllegalBreak); 29614 } 29615 29616 return node.finishBreakStatement(null); 29617 } 29618 29619 if (hasLineTerminator) { 29620 if (!(state.inIteration || state.inSwitch)) { 29621 throwError(Messages.IllegalBreak); 29622 } 29623 } else if (lookahead.type === Token.Identifier) { 29624 label = parseVariableIdentifier(); 29625 29626 key = '$' + label.name; 29627 if (!Object.prototype.hasOwnProperty.call(state.labelSet, key)) { 29628 throwError(Messages.UnknownLabel, label.name); 29629 } 29630 } 29631 29632 consumeSemicolon(); 29633 29634 if (label === null && !(state.inIteration || state.inSwitch)) { 29635 throwError(Messages.IllegalBreak); 29636 } 29637 29638 return node.finishBreakStatement(label); 29639 } 29640 29641 // ECMA-262 13.10 The return statement 29642 29643 function parseReturnStatement(node) { 29644 var argument = null; 29645 29646 expectKeyword('return'); 29647 29648 if (!state.inFunctionBody) { 29649 tolerateError(Messages.IllegalReturn); 29650 } 29651 29652 // 'return' followed by a space and an identifier is very common. 29653 if (source.charCodeAt(lastIndex) === 0x20) { 29654 if (isIdentifierStart(source.charCodeAt(lastIndex + 1))) { 29655 argument = parseExpression(); 29656 consumeSemicolon(); 29657 return node.finishReturnStatement(argument); 29658 } 29659 } 29660 29661 if (hasLineTerminator) { 29662 // HACK 29663 return node.finishReturnStatement(null); 29664 } 29665 29666 if (!match(';')) { 29667 if (!match('}') && lookahead.type !== Token.EOF) { 29668 argument = parseExpression(); 29669 } 29670 } 29671 29672 consumeSemicolon(); 29673 29674 return node.finishReturnStatement(argument); 29675 } 29676 29677 // ECMA-262 13.11 The with statement 29678 29679 function parseWithStatement(node) { 29680 var object, body; 29681 29682 if (strict) { 29683 tolerateError(Messages.StrictModeWith); 29684 } 29685 29686 expectKeyword('with'); 29687 29688 expect('('); 29689 29690 object = parseExpression(); 29691 29692 expect(')'); 29693 29694 body = parseStatement(); 29695 29696 return node.finishWithStatement(object, body); 29697 } 29698 29699 // ECMA-262 13.12 The switch statement 29700 29701 function parseSwitchCase() { 29702 var test, consequent = [], statement, node = new Node(); 29703 29704 if (matchKeyword('default')) { 29705 lex(); 29706 test = null; 29707 } else { 29708 expectKeyword('case'); 29709 test = parseExpression(); 29710 } 29711 expect(':'); 29712 29713 while (startIndex < length) { 29714 if (match('}') || matchKeyword('default') || matchKeyword('case')) { 29715 break; 29716 } 29717 statement = parseStatementListItem(); 29718 consequent.push(statement); 29719 } 29720 29721 return node.finishSwitchCase(test, consequent); 29722 } 29723 29724 function parseSwitchStatement(node) { 29725 var discriminant, cases, clause, oldInSwitch, defaultFound; 29726 29727 expectKeyword('switch'); 29728 29729 expect('('); 29730 29731 discriminant = parseExpression(); 29732 29733 expect(')'); 29734 29735 expect('{'); 29736 29737 cases = []; 29738 29739 if (match('}')) { 29740 lex(); 29741 return node.finishSwitchStatement(discriminant, cases); 29742 } 29743 29744 oldInSwitch = state.inSwitch; 29745 state.inSwitch = true; 29746 defaultFound = false; 29747 29748 while (startIndex < length) { 29749 if (match('}')) { 29750 break; 29751 } 29752 clause = parseSwitchCase(); 29753 if (clause.test === null) { 29754 if (defaultFound) { 29755 throwError(Messages.MultipleDefaultsInSwitch); 29756 } 29757 defaultFound = true; 29758 } 29759 cases.push(clause); 29760 } 29761 29762 state.inSwitch = oldInSwitch; 29763 29764 expect('}'); 29765 29766 return node.finishSwitchStatement(discriminant, cases); 29767 } 29768 29769 // ECMA-262 13.14 The throw statement 29770 29771 function parseThrowStatement(node) { 29772 var argument; 29773 29774 expectKeyword('throw'); 29775 29776 if (hasLineTerminator) { 29777 throwError(Messages.NewlineAfterThrow); 29778 } 29779 29780 argument = parseExpression(); 29781 29782 consumeSemicolon(); 29783 29784 return node.finishThrowStatement(argument); 29785 } 29786 29787 // ECMA-262 13.15 The try statement 29788 29789 function parseCatchClause() { 29790 var param, params = [], paramMap = {}, key, i, body, node = new Node(); 29791 29792 expectKeyword('catch'); 29793 29794 expect('('); 29795 if (match(')')) { 29796 throwUnexpectedToken(lookahead); 29797 } 29798 29799 param = parsePattern(params); 29800 for (i = 0; i < params.length; i++) { 29801 key = '$' + params[i].value; 29802 if (Object.prototype.hasOwnProperty.call(paramMap, key)) { 29803 tolerateError(Messages.DuplicateBinding, params[i].value); 29804 } 29805 paramMap[key] = true; 29806 } 29807 29808 // ECMA-262 12.14.1 29809 if (strict && isRestrictedWord(param.name)) { 29810 tolerateError(Messages.StrictCatchVariable); 29811 } 29812 29813 expect(')'); 29814 body = parseBlock(); 29815 return node.finishCatchClause(param, body); 29816 } 29817 29818 function parseTryStatement(node) { 29819 var block, handler = null, finalizer = null; 29820 29821 expectKeyword('try'); 29822 29823 block = parseBlock(); 29824 29825 if (matchKeyword('catch')) { 29826 handler = parseCatchClause(); 29827 } 29828 29829 if (matchKeyword('finally')) { 29830 lex(); 29831 finalizer = parseBlock(); 29832 } 29833 29834 if (!handler && !finalizer) { 29835 throwError(Messages.NoCatchOrFinally); 29836 } 29837 29838 return node.finishTryStatement(block, handler, finalizer); 29839 } 29840 29841 // ECMA-262 13.16 The debugger statement 29842 29843 function parseDebuggerStatement(node) { 29844 expectKeyword('debugger'); 29845 29846 consumeSemicolon(); 29847 29848 return node.finishDebuggerStatement(); 29849 } 29850 29851 // 13 Statements 29852 29853 function parseStatement() { 29854 var type = lookahead.type, 29855 expr, 29856 labeledBody, 29857 key, 29858 node; 29859 29860 if (type === Token.EOF) { 29861 throwUnexpectedToken(lookahead); 29862 } 29863 29864 if (type === Token.Punctuator && lookahead.value === '{') { 29865 return parseBlock(); 29866 } 29867 isAssignmentTarget = isBindingElement = true; 29868 node = new Node(); 29869 29870 if (type === Token.Punctuator) { 29871 switch (lookahead.value) { 29872 case ';': 29873 return parseEmptyStatement(node); 29874 case '(': 29875 return parseExpressionStatement(node); 29876 default: 29877 break; 29878 } 29879 } else if (type === Token.Keyword) { 29880 switch (lookahead.value) { 29881 case 'break': 29882 return parseBreakStatement(node); 29883 case 'continue': 29884 return parseContinueStatement(node); 29885 case 'debugger': 29886 return parseDebuggerStatement(node); 29887 case 'do': 29888 return parseDoWhileStatement(node); 29889 case 'for': 29890 return parseForStatement(node); 29891 case 'function': 29892 return parseFunctionDeclaration(node); 29893 case 'if': 29894 return parseIfStatement(node); 29895 case 'return': 29896 return parseReturnStatement(node); 29897 case 'switch': 29898 return parseSwitchStatement(node); 29899 case 'throw': 29900 return parseThrowStatement(node); 29901 case 'try': 29902 return parseTryStatement(node); 29903 case 'var': 29904 return parseVariableStatement(node); 29905 case 'while': 29906 return parseWhileStatement(node); 29907 case 'with': 29908 return parseWithStatement(node); 29909 default: 29910 break; 29911 } 29912 } 29913 29914 expr = parseExpression(); 29915 29916 // ECMA-262 12.12 Labelled Statements 29917 if ((expr.type === Syntax.Identifier) && match(':')) { 29918 lex(); 29919 29920 key = '$' + expr.name; 29921 if (Object.prototype.hasOwnProperty.call(state.labelSet, key)) { 29922 throwError(Messages.Redeclaration, 'Label', expr.name); 29923 } 29924 29925 state.labelSet[key] = true; 29926 labeledBody = parseStatement(); 29927 delete state.labelSet[key]; 29928 return node.finishLabeledStatement(expr, labeledBody); 29929 } 29930 29931 consumeSemicolon(); 29932 29933 return node.finishExpressionStatement(expr); 29934 } 29935 29936 // ECMA-262 14.1 Function Definition 29937 29938 function parseFunctionSourceElements() { 29939 var statement, body = [], token, directive, firstRestricted, 29940 oldLabelSet, oldInIteration, oldInSwitch, oldInFunctionBody, 29941 node = new Node(); 29942 29943 expect('{'); 29944 29945 while (startIndex < length) { 29946 if (lookahead.type !== Token.StringLiteral) { 29947 break; 29948 } 29949 token = lookahead; 29950 29951 statement = parseStatementListItem(); 29952 body.push(statement); 29953 if (statement.expression.type !== Syntax.Literal) { 29954 // this is not directive 29955 break; 29956 } 29957 directive = source.slice(token.start + 1, token.end - 1); 29958 if (directive === 'use strict') { 29959 strict = true; 29960 if (firstRestricted) { 29961 tolerateUnexpectedToken(firstRestricted, Messages.StrictOctalLiteral); 29962 } 29963 } else { 29964 if (!firstRestricted && token.octal) { 29965 firstRestricted = token; 29966 } 29967 } 29968 } 29969 29970 oldLabelSet = state.labelSet; 29971 oldInIteration = state.inIteration; 29972 oldInSwitch = state.inSwitch; 29973 oldInFunctionBody = state.inFunctionBody; 29974 29975 state.labelSet = {}; 29976 state.inIteration = false; 29977 state.inSwitch = false; 29978 state.inFunctionBody = true; 29979 29980 while (startIndex < length) { 29981 if (match('}')) { 29982 break; 29983 } 29984 body.push(parseStatementListItem()); 29985 } 29986 29987 expect('}'); 29988 29989 state.labelSet = oldLabelSet; 29990 state.inIteration = oldInIteration; 29991 state.inSwitch = oldInSwitch; 29992 state.inFunctionBody = oldInFunctionBody; 29993 29994 return node.finishBlockStatement(body); 29995 } 29996 29997 function validateParam(options, param, name) { 29998 var key = '$' + name; 29999 if (strict) { 30000 if (isRestrictedWord(name)) { 30001 options.stricted = param; 30002 options.message = Messages.StrictParamName; 30003 } 30004 if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) { 30005 options.stricted = param; 30006 options.message = Messages.StrictParamDupe; 30007 } 30008 } else if (!options.firstRestricted) { 30009 if (isRestrictedWord(name)) { 30010 options.firstRestricted = param; 30011 options.message = Messages.StrictParamName; 30012 } else if (isStrictModeReservedWord(name)) { 30013 options.firstRestricted = param; 30014 options.message = Messages.StrictReservedWord; 30015 } else if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) { 30016 options.stricted = param; 30017 options.message = Messages.StrictParamDupe; 30018 } 30019 } 30020 options.paramSet[key] = true; 30021 } 30022 30023 function parseParam(options) { 30024 var token, param, params = [], i, def; 30025 30026 token = lookahead; 30027 if (token.value === '...') { 30028 param = parseRestElement(params); 30029 validateParam(options, param.argument, param.argument.name); 30030 options.params.push(param); 30031 options.defaults.push(null); 30032 return false; 30033 } 30034 30035 param = parsePatternWithDefault(params); 30036 for (i = 0; i < params.length; i++) { 30037 validateParam(options, params[i], params[i].value); 30038 } 30039 30040 if (param.type === Syntax.AssignmentPattern) { 30041 def = param.right; 30042 param = param.left; 30043 ++options.defaultCount; 30044 } 30045 30046 options.params.push(param); 30047 options.defaults.push(def); 30048 30049 return !match(')'); 30050 } 30051 30052 function parseParams(firstRestricted) { 30053 var options; 30054 30055 options = { 30056 params: [], 30057 defaultCount: 0, 30058 defaults: [], 30059 firstRestricted: firstRestricted 30060 }; 30061 30062 expect('('); 30063 30064 if (!match(')')) { 30065 options.paramSet = {}; 30066 while (startIndex < length) { 30067 if (!parseParam(options)) { 30068 break; 30069 } 30070 expect(','); 30071 } 30072 } 30073 30074 expect(')'); 30075 30076 if (options.defaultCount === 0) { 30077 options.defaults = []; 30078 } 30079 30080 return { 30081 params: options.params, 30082 defaults: options.defaults, 30083 stricted: options.stricted, 30084 firstRestricted: options.firstRestricted, 30085 message: options.message 30086 }; 30087 } 30088 30089 function parseFunctionDeclaration(node, identifierIsOptional) { 30090 var id = null, params = [], defaults = [], body, token, stricted, tmp, firstRestricted, message, previousStrict, 30091 isGenerator, previousAllowYield; 30092 30093 previousAllowYield = state.allowYield; 30094 30095 expectKeyword('function'); 30096 30097 isGenerator = match('*'); 30098 if (isGenerator) { 30099 lex(); 30100 } 30101 30102 if (!identifierIsOptional || !match('(')) { 30103 token = lookahead; 30104 id = parseVariableIdentifier(); 30105 if (strict) { 30106 if (isRestrictedWord(token.value)) { 30107 tolerateUnexpectedToken(token, Messages.StrictFunctionName); 30108 } 30109 } else { 30110 if (isRestrictedWord(token.value)) { 30111 firstRestricted = token; 30112 message = Messages.StrictFunctionName; 30113 } else if (isStrictModeReservedWord(token.value)) { 30114 firstRestricted = token; 30115 message = Messages.StrictReservedWord; 30116 } 30117 } 30118 } 30119 30120 state.allowYield = !isGenerator; 30121 tmp = parseParams(firstRestricted); 30122 params = tmp.params; 30123 defaults = tmp.defaults; 30124 stricted = tmp.stricted; 30125 firstRestricted = tmp.firstRestricted; 30126 if (tmp.message) { 30127 message = tmp.message; 30128 } 30129 30130 30131 previousStrict = strict; 30132 body = parseFunctionSourceElements(); 30133 if (strict && firstRestricted) { 30134 throwUnexpectedToken(firstRestricted, message); 30135 } 30136 if (strict && stricted) { 30137 tolerateUnexpectedToken(stricted, message); 30138 } 30139 30140 strict = previousStrict; 30141 state.allowYield = previousAllowYield; 30142 30143 return node.finishFunctionDeclaration(id, params, defaults, body, isGenerator); 30144 } 30145 30146 function parseFunctionExpression() { 30147 var token, id = null, stricted, firstRestricted, message, tmp, 30148 params = [], defaults = [], body, previousStrict, node = new Node(), 30149 isGenerator, previousAllowYield; 30150 30151 previousAllowYield = state.allowYield; 30152 30153 expectKeyword('function'); 30154 30155 isGenerator = match('*'); 30156 if (isGenerator) { 30157 lex(); 30158 } 30159 30160 state.allowYield = !isGenerator; 30161 if (!match('(')) { 30162 token = lookahead; 30163 id = (!strict && !isGenerator && matchKeyword('yield')) ? parseNonComputedProperty() : parseVariableIdentifier(); 30164 if (strict) { 30165 if (isRestrictedWord(token.value)) { 30166 tolerateUnexpectedToken(token, Messages.StrictFunctionName); 30167 } 30168 } else { 30169 if (isRestrictedWord(token.value)) { 30170 firstRestricted = token; 30171 message = Messages.StrictFunctionName; 30172 } else if (isStrictModeReservedWord(token.value)) { 30173 firstRestricted = token; 30174 message = Messages.StrictReservedWord; 30175 } 30176 } 30177 } 30178 30179 tmp = parseParams(firstRestricted); 30180 params = tmp.params; 30181 defaults = tmp.defaults; 30182 stricted = tmp.stricted; 30183 firstRestricted = tmp.firstRestricted; 30184 if (tmp.message) { 30185 message = tmp.message; 30186 } 30187 30188 previousStrict = strict; 30189 body = parseFunctionSourceElements(); 30190 if (strict && firstRestricted) { 30191 throwUnexpectedToken(firstRestricted, message); 30192 } 30193 if (strict && stricted) { 30194 tolerateUnexpectedToken(stricted, message); 30195 } 30196 strict = previousStrict; 30197 state.allowYield = previousAllowYield; 30198 30199 return node.finishFunctionExpression(id, params, defaults, body, isGenerator); 30200 } 30201 30202 // ECMA-262 14.5 Class Definitions 30203 30204 function parseClassBody() { 30205 var classBody, token, isStatic, hasConstructor = false, body, method, computed, key; 30206 30207 classBody = new Node(); 30208 30209 expect('{'); 30210 body = []; 30211 while (!match('}')) { 30212 if (match(';')) { 30213 lex(); 30214 } else { 30215 method = new Node(); 30216 token = lookahead; 30217 isStatic = false; 30218 computed = match('['); 30219 if (match('*')) { 30220 lex(); 30221 } else { 30222 key = parseObjectPropertyKey(); 30223 if (key.name === 'static' && (lookaheadPropertyName() || match('*'))) { 30224 token = lookahead; 30225 isStatic = true; 30226 computed = match('['); 30227 if (match('*')) { 30228 lex(); 30229 } else { 30230 key = parseObjectPropertyKey(); 30231 } 30232 } 30233 } 30234 method = tryParseMethodDefinition(token, key, computed, method); 30235 if (method) { 30236 method['static'] = isStatic; // jscs:ignore requireDotNotation 30237 if (method.kind === 'init') { 30238 method.kind = 'method'; 30239 } 30240 if (!isStatic) { 30241 if (!method.computed && (method.key.name || method.key.value.toString()) === 'constructor') { 30242 if (method.kind !== 'method' || !method.method || method.value.generator) { 30243 throwUnexpectedToken(token, Messages.ConstructorSpecialMethod); 30244 } 30245 if (hasConstructor) { 30246 throwUnexpectedToken(token, Messages.DuplicateConstructor); 30247 } else { 30248 hasConstructor = true; 30249 } 30250 method.kind = 'constructor'; 30251 } 30252 } else { 30253 if (!method.computed && (method.key.name || method.key.value.toString()) === 'prototype') { 30254 throwUnexpectedToken(token, Messages.StaticPrototype); 30255 } 30256 } 30257 method.type = Syntax.MethodDefinition; 30258 delete method.method; 30259 delete method.shorthand; 30260 body.push(method); 30261 } else { 30262 throwUnexpectedToken(lookahead); 30263 } 30264 } 30265 } 30266 lex(); 30267 return classBody.finishClassBody(body); 30268 } 30269 30270 function parseClassDeclaration(identifierIsOptional) { 30271 var id = null, superClass = null, classNode = new Node(), classBody, previousStrict = strict; 30272 strict = true; 30273 30274 expectKeyword('class'); 30275 30276 if (!identifierIsOptional || lookahead.type === Token.Identifier) { 30277 id = parseVariableIdentifier(); 30278 } 30279 30280 if (matchKeyword('extends')) { 30281 lex(); 30282 superClass = isolateCoverGrammar(parseLeftHandSideExpressionAllowCall); 30283 } 30284 classBody = parseClassBody(); 30285 strict = previousStrict; 30286 30287 return classNode.finishClassDeclaration(id, superClass, classBody); 30288 } 30289 30290 function parseClassExpression() { 30291 var id = null, superClass = null, classNode = new Node(), classBody, previousStrict = strict; 30292 strict = true; 30293 30294 expectKeyword('class'); 30295 30296 if (lookahead.type === Token.Identifier) { 30297 id = parseVariableIdentifier(); 30298 } 30299 30300 if (matchKeyword('extends')) { 30301 lex(); 30302 superClass = isolateCoverGrammar(parseLeftHandSideExpressionAllowCall); 30303 } 30304 classBody = parseClassBody(); 30305 strict = previousStrict; 30306 30307 return classNode.finishClassExpression(id, superClass, classBody); 30308 } 30309 30310 // ECMA-262 15.2 Modules 30311 30312 function parseModuleSpecifier() { 30313 var node = new Node(); 30314 30315 if (lookahead.type !== Token.StringLiteral) { 30316 throwError(Messages.InvalidModuleSpecifier); 30317 } 30318 return node.finishLiteral(lex()); 30319 } 30320 30321 // ECMA-262 15.2.3 Exports 30322 30323 function parseExportSpecifier() { 30324 var exported, local, node = new Node(), def; 30325 if (matchKeyword('default')) { 30326 // export {default} from 'something'; 30327 def = new Node(); 30328 lex(); 30329 local = def.finishIdentifier('default'); 30330 } else { 30331 local = parseVariableIdentifier(); 30332 } 30333 if (matchContextualKeyword('as')) { 30334 lex(); 30335 exported = parseNonComputedProperty(); 30336 } 30337 return node.finishExportSpecifier(local, exported); 30338 } 30339 30340 function parseExportNamedDeclaration(node) { 30341 var declaration = null, 30342 isExportFromIdentifier, 30343 src = null, specifiers = []; 30344 30345 // non-default export 30346 if (lookahead.type === Token.Keyword) { 30347 // covers: 30348 // export var f = 1; 30349 switch (lookahead.value) { 30350 case 'let': 30351 case 'const': 30352 declaration = parseLexicalDeclaration({inFor: false}); 30353 return node.finishExportNamedDeclaration(declaration, specifiers, null); 30354 case 'var': 30355 case 'class': 30356 case 'function': 30357 declaration = parseStatementListItem(); 30358 return node.finishExportNamedDeclaration(declaration, specifiers, null); 30359 } 30360 } 30361 30362 expect('{'); 30363 while (!match('}')) { 30364 isExportFromIdentifier = isExportFromIdentifier || matchKeyword('default'); 30365 specifiers.push(parseExportSpecifier()); 30366 if (!match('}')) { 30367 expect(','); 30368 if (match('}')) { 30369 break; 30370 } 30371 } 30372 } 30373 expect('}'); 30374 30375 if (matchContextualKeyword('from')) { 30376 // covering: 30377 // export {default} from 'foo'; 30378 // export {foo} from 'foo'; 30379 lex(); 30380 src = parseModuleSpecifier(); 30381 consumeSemicolon(); 30382 } else if (isExportFromIdentifier) { 30383 // covering: 30384 // export {default}; // missing fromClause 30385 throwError(lookahead.value ? 30386 Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value); 30387 } else { 30388 // cover 30389 // export {foo}; 30390 consumeSemicolon(); 30391 } 30392 return node.finishExportNamedDeclaration(declaration, specifiers, src); 30393 } 30394 30395 function parseExportDefaultDeclaration(node) { 30396 var declaration = null, 30397 expression = null; 30398 30399 // covers: 30400 // export default ... 30401 expectKeyword('default'); 30402 30403 if (matchKeyword('function')) { 30404 // covers: 30405 // export default function foo () {} 30406 // export default function () {} 30407 declaration = parseFunctionDeclaration(new Node(), true); 30408 return node.finishExportDefaultDeclaration(declaration); 30409 } 30410 if (matchKeyword('class')) { 30411 declaration = parseClassDeclaration(true); 30412 return node.finishExportDefaultDeclaration(declaration); 30413 } 30414 30415 if (matchContextualKeyword('from')) { 30416 throwError(Messages.UnexpectedToken, lookahead.value); 30417 } 30418 30419 // covers: 30420 // export default {}; 30421 // export default []; 30422 // export default (1 + 2); 30423 if (match('{')) { 30424 expression = parseObjectInitializer(); 30425 } else if (match('[')) { 30426 expression = parseArrayInitializer(); 30427 } else { 30428 expression = parseAssignmentExpression(); 30429 } 30430 consumeSemicolon(); 30431 return node.finishExportDefaultDeclaration(expression); 30432 } 30433 30434 function parseExportAllDeclaration(node) { 30435 var src; 30436 30437 // covers: 30438 // export * from 'foo'; 30439 expect('*'); 30440 if (!matchContextualKeyword('from')) { 30441 throwError(lookahead.value ? 30442 Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value); 30443 } 30444 lex(); 30445 src = parseModuleSpecifier(); 30446 consumeSemicolon(); 30447 30448 return node.finishExportAllDeclaration(src); 30449 } 30450 30451 function parseExportDeclaration() { 30452 var node = new Node(); 30453 if (state.inFunctionBody) { 30454 throwError(Messages.IllegalExportDeclaration); 30455 } 30456 30457 expectKeyword('export'); 30458 30459 if (matchKeyword('default')) { 30460 return parseExportDefaultDeclaration(node); 30461 } 30462 if (match('*')) { 30463 return parseExportAllDeclaration(node); 30464 } 30465 return parseExportNamedDeclaration(node); 30466 } 30467 30468 // ECMA-262 15.2.2 Imports 30469 30470 function parseImportSpecifier() { 30471 // import {<foo as bar>} ...; 30472 var local, imported, node = new Node(); 30473 30474 imported = parseNonComputedProperty(); 30475 if (matchContextualKeyword('as')) { 30476 lex(); 30477 local = parseVariableIdentifier(); 30478 } 30479 30480 return node.finishImportSpecifier(local, imported); 30481 } 30482 30483 function parseNamedImports() { 30484 var specifiers = []; 30485 // {foo, bar as bas} 30486 expect('{'); 30487 while (!match('}')) { 30488 specifiers.push(parseImportSpecifier()); 30489 if (!match('}')) { 30490 expect(','); 30491 if (match('}')) { 30492 break; 30493 } 30494 } 30495 } 30496 expect('}'); 30497 return specifiers; 30498 } 30499 30500 function parseImportDefaultSpecifier() { 30501 // import <foo> ...; 30502 var local, node = new Node(); 30503 30504 local = parseNonComputedProperty(); 30505 30506 return node.finishImportDefaultSpecifier(local); 30507 } 30508 30509 function parseImportNamespaceSpecifier() { 30510 // import <* as foo> ...; 30511 var local, node = new Node(); 30512 30513 expect('*'); 30514 if (!matchContextualKeyword('as')) { 30515 throwError(Messages.NoAsAfterImportNamespace); 30516 } 30517 lex(); 30518 local = parseNonComputedProperty(); 30519 30520 return node.finishImportNamespaceSpecifier(local); 30521 } 30522 30523 function parseImportDeclaration() { 30524 var specifiers = [], src, node = new Node(); 30525 30526 if (state.inFunctionBody) { 30527 throwError(Messages.IllegalImportDeclaration); 30528 } 30529 30530 expectKeyword('import'); 30531 30532 if (lookahead.type === Token.StringLiteral) { 30533 // import 'foo'; 30534 src = parseModuleSpecifier(); 30535 } else { 30536 30537 if (match('{')) { 30538 // import {bar} 30539 specifiers = specifiers.concat(parseNamedImports()); 30540 } else if (match('*')) { 30541 // import * as foo 30542 specifiers.push(parseImportNamespaceSpecifier()); 30543 } else if (isIdentifierName(lookahead) && !matchKeyword('default')) { 30544 // import foo 30545 specifiers.push(parseImportDefaultSpecifier()); 30546 if (match(',')) { 30547 lex(); 30548 if (match('*')) { 30549 // import foo, * as foo 30550 specifiers.push(parseImportNamespaceSpecifier()); 30551 } else if (match('{')) { 30552 // import foo, {bar} 30553 specifiers = specifiers.concat(parseNamedImports()); 30554 } else { 30555 throwUnexpectedToken(lookahead); 30556 } 30557 } 30558 } else { 30559 throwUnexpectedToken(lex()); 30560 } 30561 30562 if (!matchContextualKeyword('from')) { 30563 throwError(lookahead.value ? 30564 Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value); 30565 } 30566 lex(); 30567 src = parseModuleSpecifier(); 30568 } 30569 30570 consumeSemicolon(); 30571 return node.finishImportDeclaration(specifiers, src); 30572 } 30573 30574 // ECMA-262 15.1 Scripts 30575 30576 function parseScriptBody() { 30577 var statement, body = [], token, directive, firstRestricted; 30578 30579 while (startIndex < length) { 30580 token = lookahead; 30581 if (token.type !== Token.StringLiteral) { 30582 break; 30583 } 30584 30585 statement = parseStatementListItem(); 30586 body.push(statement); 30587 if (statement.expression.type !== Syntax.Literal) { 30588 // this is not directive 30589 break; 30590 } 30591 directive = source.slice(token.start + 1, token.end - 1); 30592 if (directive === 'use strict') { 30593 strict = true; 30594 if (firstRestricted) { 30595 tolerateUnexpectedToken(firstRestricted, Messages.StrictOctalLiteral); 30596 } 30597 } else { 30598 if (!firstRestricted && token.octal) { 30599 firstRestricted = token; 30600 } 30601 } 30602 } 30603 30604 while (startIndex < length) { 30605 statement = parseStatementListItem(); 30606 /* istanbul ignore if */ 30607 if (typeof statement === 'undefined') { 30608 break; 30609 } 30610 body.push(statement); 30611 } 30612 return body; 30613 } 30614 30615 function parseProgram() { 30616 var body, node; 30617 30618 peek(); 30619 node = new Node(); 30620 30621 body = parseScriptBody(); 30622 return node.finishProgram(body, state.sourceType); 30623 } 30624 30625 function filterTokenLocation() { 30626 var i, entry, token, tokens = []; 30627 30628 for (i = 0; i < extra.tokens.length; ++i) { 30629 entry = extra.tokens[i]; 30630 token = { 30631 type: entry.type, 30632 value: entry.value 30633 }; 30634 if (entry.regex) { 30635 token.regex = { 30636 pattern: entry.regex.pattern, 30637 flags: entry.regex.flags 30638 }; 30639 } 30640 if (extra.range) { 30641 token.range = entry.range; 30642 } 30643 if (extra.loc) { 30644 token.loc = entry.loc; 30645 } 30646 tokens.push(token); 30647 } 30648 30649 extra.tokens = tokens; 30650 } 30651 30652 function tokenize(code, options, delegate) { 30653 var toString, 30654 tokens; 30655 30656 toString = String; 30657 if (typeof code !== 'string' && !(code instanceof String)) { 30658 code = toString(code); 30659 } 30660 30661 source = code; 30662 index = 0; 30663 lineNumber = (source.length > 0) ? 1 : 0; 30664 lineStart = 0; 30665 startIndex = index; 30666 startLineNumber = lineNumber; 30667 startLineStart = lineStart; 30668 length = source.length; 30669 lookahead = null; 30670 state = { 30671 allowIn: true, 30672 allowYield: true, 30673 labelSet: {}, 30674 inFunctionBody: false, 30675 inIteration: false, 30676 inSwitch: false, 30677 lastCommentStart: -1, 30678 curlyStack: [] 30679 }; 30680 30681 extra = {}; 30682 30683 // Options matching. 30684 options = options || {}; 30685 30686 // Of course we collect tokens here. 30687 options.tokens = true; 30688 extra.tokens = []; 30689 extra.tokenValues = []; 30690 extra.tokenize = true; 30691 extra.delegate = delegate; 30692 30693 // The following two fields are necessary to compute the Regex tokens. 30694 extra.openParenToken = -1; 30695 extra.openCurlyToken = -1; 30696 30697 extra.range = (typeof options.range === 'boolean') && options.range; 30698 extra.loc = (typeof options.loc === 'boolean') && options.loc; 30699 30700 if (typeof options.comment === 'boolean' && options.comment) { 30701 extra.comments = []; 30702 } 30703 if (typeof options.tolerant === 'boolean' && options.tolerant) { 30704 extra.errors = []; 30705 } 30706 30707 try { 30708 peek(); 30709 if (lookahead.type === Token.EOF) { 30710 return extra.tokens; 30711 } 30712 30713 lex(); 30714 while (lookahead.type !== Token.EOF) { 30715 try { 30716 lex(); 30717 } catch (lexError) { 30718 if (extra.errors) { 30719 recordError(lexError); 30720 // We have to break on the first error 30721 // to avoid infinite loops. 30722 break; 30723 } else { 30724 throw lexError; 30725 } 30726 } 30727 } 30728 30729 tokens = extra.tokens; 30730 if (typeof extra.errors !== 'undefined') { 30731 tokens.errors = extra.errors; 30732 } 30733 } catch (e) { 30734 throw e; 30735 } finally { 30736 extra = {}; 30737 } 30738 return tokens; 30739 } 30740 30741 function parse(code, options) { 30742 var program, toString; 30743 30744 toString = String; 30745 if (typeof code !== 'string' && !(code instanceof String)) { 30746 code = toString(code); 30747 } 30748 30749 source = code; 30750 index = 0; 30751 lineNumber = (source.length > 0) ? 1 : 0; 30752 lineStart = 0; 30753 startIndex = index; 30754 startLineNumber = lineNumber; 30755 startLineStart = lineStart; 30756 length = source.length; 30757 lookahead = null; 30758 state = { 30759 allowIn: true, 30760 allowYield: true, 30761 labelSet: {}, 30762 inFunctionBody: false, 30763 inIteration: false, 30764 inSwitch: false, 30765 lastCommentStart: -1, 30766 curlyStack: [], 30767 sourceType: 'script' 30768 }; 30769 strict = false; 30770 30771 extra = {}; 30772 if (typeof options !== 'undefined') { 30773 extra.range = (typeof options.range === 'boolean') && options.range; 30774 extra.loc = (typeof options.loc === 'boolean') && options.loc; 30775 extra.attachComment = (typeof options.attachComment === 'boolean') && options.attachComment; 30776 30777 if (extra.loc && options.source !== null && options.source !== undefined) { 30778 extra.source = toString(options.source); 30779 } 30780 30781 if (typeof options.tokens === 'boolean' && options.tokens) { 30782 extra.tokens = []; 30783 } 30784 if (typeof options.comment === 'boolean' && options.comment) { 30785 extra.comments = []; 30786 } 30787 if (typeof options.tolerant === 'boolean' && options.tolerant) { 30788 extra.errors = []; 30789 } 30790 if (extra.attachComment) { 30791 extra.range = true; 30792 extra.comments = []; 30793 extra.bottomRightStack = []; 30794 extra.trailingComments = []; 30795 extra.leadingComments = []; 30796 } 30797 if (options.sourceType === 'module') { 30798 // very restrictive condition for now 30799 state.sourceType = options.sourceType; 30800 strict = true; 30801 } 30802 } 30803 30804 try { 30805 program = parseProgram(); 30806 if (typeof extra.comments !== 'undefined') { 30807 program.comments = extra.comments; 30808 } 30809 if (typeof extra.tokens !== 'undefined') { 30810 filterTokenLocation(); 30811 program.tokens = extra.tokens; 30812 } 30813 if (typeof extra.errors !== 'undefined') { 30814 program.errors = extra.errors; 30815 } 30816 } catch (e) { 30817 throw e; 30818 } finally { 30819 extra = {}; 30820 } 30821 30822 return program; 30823 } 30824 30825 // Sync with *.json manifests. 30826 exports.version = '2.7.3'; 30827 30828 exports.tokenize = tokenize; 30829 30830 exports.parse = parse; 30831 30832 // Deep copy. 30833 /* istanbul ignore next */ 30834 exports.Syntax = (function () { 30835 var name, types = {}; 30836 30837 if (typeof Object.create === 'function') { 30838 types = Object.create(null); 30839 } 30840 30841 for (name in Syntax) { 30842 if (Syntax.hasOwnProperty(name)) { 30843 types[name] = Syntax[name]; 30844 } 30845 } 30846 30847 if (typeof Object.freeze === 'function') { 30848 Object.freeze(types); 30849 } 30850 30851 return types; 30852 }()); 30853 30854 })); 30855 /* vim: set sw=4 ts=4 et tw=80 : */ 30856 30857 30858 /***/ }, 30859 /* 155 */ 30860 /***/ function(module, exports, __webpack_require__) { 30861 30862 'use strict'; 30863 30864 /*eslint-disable no-use-before-define*/ 30865 30866 var common = __webpack_require__(124); 30867 var YAMLException = __webpack_require__(125); 30868 var DEFAULT_FULL_SCHEMA = __webpack_require__(150); 30869 var DEFAULT_SAFE_SCHEMA = __webpack_require__(127); 30870 30871 var _toString = Object.prototype.toString; 30872 var _hasOwnProperty = Object.prototype.hasOwnProperty; 30873 30874 var CHAR_TAB = 0x09; /* Tab */ 30875 var CHAR_LINE_FEED = 0x0A; /* LF */ 30876 var CHAR_SPACE = 0x20; /* Space */ 30877 var CHAR_EXCLAMATION = 0x21; /* ! */ 30878 var CHAR_DOUBLE_QUOTE = 0x22; /* " */ 30879 var CHAR_SHARP = 0x23; /* # */ 30880 var CHAR_PERCENT = 0x25; /* % */ 30881 var CHAR_AMPERSAND = 0x26; /* & */ 30882 var CHAR_SINGLE_QUOTE = 0x27; /* ' */ 30883 var CHAR_ASTERISK = 0x2A; /* * */ 30884 var CHAR_COMMA = 0x2C; /* , */ 30885 var CHAR_MINUS = 0x2D; /* - */ 30886 var CHAR_COLON = 0x3A; /* : */ 30887 var CHAR_GREATER_THAN = 0x3E; /* > */ 30888 var CHAR_QUESTION = 0x3F; /* ? */ 30889 var CHAR_COMMERCIAL_AT = 0x40; /* @ */ 30890 var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */ 30891 var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */ 30892 var CHAR_GRAVE_ACCENT = 0x60; /* ` */ 30893 var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */ 30894 var CHAR_VERTICAL_LINE = 0x7C; /* | */ 30895 var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */ 30896 30897 var ESCAPE_SEQUENCES = {}; 30898 30899 ESCAPE_SEQUENCES[0x00] = '\\0'; 30900 ESCAPE_SEQUENCES[0x07] = '\\a'; 30901 ESCAPE_SEQUENCES[0x08] = '\\b'; 30902 ESCAPE_SEQUENCES[0x09] = '\\t'; 30903 ESCAPE_SEQUENCES[0x0A] = '\\n'; 30904 ESCAPE_SEQUENCES[0x0B] = '\\v'; 30905 ESCAPE_SEQUENCES[0x0C] = '\\f'; 30906 ESCAPE_SEQUENCES[0x0D] = '\\r'; 30907 ESCAPE_SEQUENCES[0x1B] = '\\e'; 30908 ESCAPE_SEQUENCES[0x22] = '\\"'; 30909 ESCAPE_SEQUENCES[0x5C] = '\\\\'; 30910 ESCAPE_SEQUENCES[0x85] = '\\N'; 30911 ESCAPE_SEQUENCES[0xA0] = '\\_'; 30912 ESCAPE_SEQUENCES[0x2028] = '\\L'; 30913 ESCAPE_SEQUENCES[0x2029] = '\\P'; 30914 30915 var DEPRECATED_BOOLEANS_SYNTAX = [ 30916 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', 30917 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' 30918 ]; 30919 30920 function compileStyleMap(schema, map) { 30921 var result, keys, index, length, tag, style, type; 30922 30923 if (map === null) return {}; 30924 30925 result = {}; 30926 keys = Object.keys(map); 30927 30928 for (index = 0, length = keys.length; index < length; index += 1) { 30929 tag = keys[index]; 30930 style = String(map[tag]); 30931 30932 if (tag.slice(0, 2) === '!!') { 30933 tag = 'tag:yaml.org,2002:' + tag.slice(2); 30934 } 30935 type = schema.compiledTypeMap['fallback'][tag]; 30936 30937 if (type && _hasOwnProperty.call(type.styleAliases, style)) { 30938 style = type.styleAliases[style]; 30939 } 30940 30941 result[tag] = style; 30942 } 30943 30944 return result; 30945 } 30946 30947 function encodeHex(character) { 30948 var string, handle, length; 30949 30950 string = character.toString(16).toUpperCase(); 30951 30952 if (character <= 0xFF) { 30953 handle = 'x'; 30954 length = 2; 30955 } else if (character <= 0xFFFF) { 30956 handle = 'u'; 30957 length = 4; 30958 } else if (character <= 0xFFFFFFFF) { 30959 handle = 'U'; 30960 length = 8; 30961 } else { 30962 throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF'); 30963 } 30964 30965 return '\\' + handle + common.repeat('0', length - string.length) + string; 30966 } 30967 30968 function State(options) { 30969 this.schema = options['schema'] || DEFAULT_FULL_SCHEMA; 30970 this.indent = Math.max(1, (options['indent'] || 2)); 30971 this.skipInvalid = options['skipInvalid'] || false; 30972 this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']); 30973 this.styleMap = compileStyleMap(this.schema, options['styles'] || null); 30974 this.sortKeys = options['sortKeys'] || false; 30975 this.lineWidth = options['lineWidth'] || 80; 30976 this.noRefs = options['noRefs'] || false; 30977 this.noCompatMode = options['noCompatMode'] || false; 30978 30979 this.implicitTypes = this.schema.compiledImplicit; 30980 this.explicitTypes = this.schema.compiledExplicit; 30981 30982 this.tag = null; 30983 this.result = ''; 30984 30985 this.duplicates = []; 30986 this.usedDuplicates = null; 30987 } 30988 30989 // Indents every line in a string. Empty lines (\n only) are not indented. 30990 function indentString(string, spaces) { 30991 var ind = common.repeat(' ', spaces), 30992 position = 0, 30993 next = -1, 30994 result = '', 30995 line, 30996 length = string.length; 30997 30998 while (position < length) { 30999 next = string.indexOf('\n', position); 31000 if (next === -1) { 31001 line = string.slice(position); 31002 position = length; 31003 } else { 31004 line = string.slice(position, next + 1); 31005 position = next + 1; 31006 } 31007 31008 if (line.length && line !== '\n') result += ind; 31009 31010 result += line; 31011 } 31012 31013 return result; 31014 } 31015 31016 function generateNextLine(state, level) { 31017 return '\n' + common.repeat(' ', state.indent * level); 31018 } 31019 31020 function testImplicitResolving(state, str) { 31021 var index, length, type; 31022 31023 for (index = 0, length = state.implicitTypes.length; index < length; index += 1) { 31024 type = state.implicitTypes[index]; 31025 31026 if (type.resolve(str)) { 31027 return true; 31028 } 31029 } 31030 31031 return false; 31032 } 31033 31034 // [33] s-white ::= s-space | s-tab 31035 function isWhitespace(c) { 31036 return c === CHAR_SPACE || c === CHAR_TAB; 31037 } 31038 31039 // Returns true if the character can be printed without escaping. 31040 // From YAML 1.2: "any allowed characters known to be non-printable 31041 // should also be escaped. [However,] This isn’t mandatory" 31042 // Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029. 31043 function isPrintable(c) { 31044 return (0x00020 <= c && c <= 0x00007E) 31045 || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029) 31046 || ((0x0E000 <= c && c <= 0x00FFFD) && c !== 0xFEFF /* BOM */) 31047 || (0x10000 <= c && c <= 0x10FFFF); 31048 } 31049 31050 // Simplified test for values allowed after the first character in plain style. 31051 function isPlainSafe(c) { 31052 // Uses a subset of nb-char - c-flow-indicator - ":" - "#" 31053 // where nb-char ::= c-printable - b-char - c-byte-order-mark. 31054 return isPrintable(c) && c !== 0xFEFF 31055 // - c-flow-indicator 31056 && c !== CHAR_COMMA 31057 && c !== CHAR_LEFT_SQUARE_BRACKET 31058 && c !== CHAR_RIGHT_SQUARE_BRACKET 31059 && c !== CHAR_LEFT_CURLY_BRACKET 31060 && c !== CHAR_RIGHT_CURLY_BRACKET 31061 // - ":" - "#" 31062 && c !== CHAR_COLON 31063 && c !== CHAR_SHARP; 31064 } 31065 31066 // Simplified test for values allowed as the first character in plain style. 31067 function isPlainSafeFirst(c) { 31068 // Uses a subset of ns-char - c-indicator 31069 // where ns-char = nb-char - s-white. 31070 return isPrintable(c) && c !== 0xFEFF 31071 && !isWhitespace(c) // - s-white 31072 // - (c-indicator ::= 31073 // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}” 31074 && c !== CHAR_MINUS 31075 && c !== CHAR_QUESTION 31076 && c !== CHAR_COLON 31077 && c !== CHAR_COMMA 31078 && c !== CHAR_LEFT_SQUARE_BRACKET 31079 && c !== CHAR_RIGHT_SQUARE_BRACKET 31080 && c !== CHAR_LEFT_CURLY_BRACKET 31081 && c !== CHAR_RIGHT_CURLY_BRACKET 31082 // | “#” | “&” | “*” | “!” | “|” | “>” | “'” | “"” 31083 && c !== CHAR_SHARP 31084 && c !== CHAR_AMPERSAND 31085 && c !== CHAR_ASTERISK 31086 && c !== CHAR_EXCLAMATION 31087 && c !== CHAR_VERTICAL_LINE 31088 && c !== CHAR_GREATER_THAN 31089 && c !== CHAR_SINGLE_QUOTE 31090 && c !== CHAR_DOUBLE_QUOTE 31091 // | “%” | “@” | “`”) 31092 && c !== CHAR_PERCENT 31093 && c !== CHAR_COMMERCIAL_AT 31094 && c !== CHAR_GRAVE_ACCENT; 31095 } 31096 31097 var STYLE_PLAIN = 1, 31098 STYLE_SINGLE = 2, 31099 STYLE_LITERAL = 3, 31100 STYLE_FOLDED = 4, 31101 STYLE_DOUBLE = 5; 31102 31103 // Determines which scalar styles are possible and returns the preferred style. 31104 // lineWidth = -1 => no limit. 31105 // Pre-conditions: str.length > 0. 31106 // Post-conditions: 31107 // STYLE_PLAIN or STYLE_SINGLE => no \n are in the string. 31108 // STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1). 31109 // STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1). 31110 function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) { 31111 var i; 31112 var char; 31113 var hasLineBreak = false; 31114 var hasFoldableLine = false; // only checked if shouldTrackWidth 31115 var shouldTrackWidth = lineWidth !== -1; 31116 var previousLineBreak = -1; // count the first line correctly 31117 var plain = isPlainSafeFirst(string.charCodeAt(0)) 31118 && !isWhitespace(string.charCodeAt(string.length - 1)); 31119 31120 if (singleLineOnly) { 31121 // Case: no block styles. 31122 // Check for disallowed characters to rule out plain and single. 31123 for (i = 0; i < string.length; i++) { 31124 char = string.charCodeAt(i); 31125 if (!isPrintable(char)) { 31126 return STYLE_DOUBLE; 31127 } 31128 plain = plain && isPlainSafe(char); 31129 } 31130 } else { 31131 // Case: block styles permitted. 31132 for (i = 0; i < string.length; i++) { 31133 char = string.charCodeAt(i); 31134 if (char === CHAR_LINE_FEED) { 31135 hasLineBreak = true; 31136 // Check if any line can be folded. 31137 if (shouldTrackWidth) { 31138 hasFoldableLine = hasFoldableLine || 31139 // Foldable line = too long, and not more-indented. 31140 (i - previousLineBreak - 1 > lineWidth && 31141 string[previousLineBreak + 1] !== ' '); 31142 previousLineBreak = i; 31143 } 31144 } else if (!isPrintable(char)) { 31145 return STYLE_DOUBLE; 31146 } 31147 plain = plain && isPlainSafe(char); 31148 } 31149 // in case the end is missing a \n 31150 hasFoldableLine = hasFoldableLine || (shouldTrackWidth && 31151 (i - previousLineBreak - 1 > lineWidth && 31152 string[previousLineBreak + 1] !== ' ')); 31153 } 31154 // Although every style can represent \n without escaping, prefer block styles 31155 // for multiline, since they're more readable and they don't add empty lines. 31156 // Also prefer folding a super-long line. 31157 if (!hasLineBreak && !hasFoldableLine) { 31158 // Strings interpretable as another type have to be quoted; 31159 // e.g. the string 'true' vs. the boolean true. 31160 return plain && !testAmbiguousType(string) 31161 ? STYLE_PLAIN : STYLE_SINGLE; 31162 } 31163 // Edge case: block indentation indicator can only have one digit. 31164 if (string[0] === ' ' && indentPerLevel > 9) { 31165 return STYLE_DOUBLE; 31166 } 31167 // At this point we know block styles are valid. 31168 // Prefer literal style unless we want to fold. 31169 return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL; 31170 } 31171 31172 // Note: line breaking/folding is implemented for only the folded style. 31173 // NB. We drop the last trailing newline (if any) of a returned block scalar 31174 // since the dumper adds its own newline. This always works: 31175 // • No ending newline => unaffected; already using strip "-" chomping. 31176 // • Ending newline => removed then restored. 31177 // Importantly, this keeps the "+" chomp indicator from gaining an extra line. 31178 function writeScalar(state, string, level, iskey) { 31179 state.dump = (function () { 31180 if (string.length === 0) { 31181 return "''"; 31182 } 31183 if (!state.noCompatMode && 31184 DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) { 31185 return "'" + string + "'"; 31186 } 31187 31188 var indent = state.indent * Math.max(1, level); // no 0-indent scalars 31189 // As indentation gets deeper, let the width decrease monotonically 31190 // to the lower bound min(state.lineWidth, 40). 31191 // Note that this implies 31192 // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound. 31193 // state.lineWidth > 40 + state.indent: width decreases until the lower bound. 31194 // This behaves better than a constant minimum width which disallows narrower options, 31195 // or an indent threshold which causes the width to suddenly increase. 31196 var lineWidth = state.lineWidth === -1 31197 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); 31198 31199 // Without knowing if keys are implicit/explicit, assume implicit for safety. 31200 var singleLineOnly = iskey 31201 // No block styles in flow mode. 31202 || (state.flowLevel > -1 && level >= state.flowLevel); 31203 function testAmbiguity(string) { 31204 return testImplicitResolving(state, string); 31205 } 31206 31207 switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) { 31208 case STYLE_PLAIN: 31209 return string; 31210 case STYLE_SINGLE: 31211 return "'" + string.replace(/'/g, "''") + "'"; 31212 case STYLE_LITERAL: 31213 return '|' + blockHeader(string, state.indent) 31214 + dropEndingNewline(indentString(string, indent)); 31215 case STYLE_FOLDED: 31216 return '>' + blockHeader(string, state.indent) 31217 + dropEndingNewline(indentString(foldString(string, lineWidth), indent)); 31218 case STYLE_DOUBLE: 31219 return '"' + escapeString(string, lineWidth) + '"'; 31220 default: 31221 throw new YAMLException('impossible error: invalid scalar style'); 31222 } 31223 }()); 31224 } 31225 31226 // Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9. 31227 function blockHeader(string, indentPerLevel) { 31228 var indentIndicator = (string[0] === ' ') ? String(indentPerLevel) : ''; 31229 31230 // note the special case: the string '\n' counts as a "trailing" empty line. 31231 var clip = string[string.length - 1] === '\n'; 31232 var keep = clip && (string[string.length - 2] === '\n' || string === '\n'); 31233 var chomp = keep ? '+' : (clip ? '' : '-'); 31234 31235 return indentIndicator + chomp + '\n'; 31236 } 31237 31238 // (See the note for writeScalar.) 31239 function dropEndingNewline(string) { 31240 return string[string.length - 1] === '\n' ? string.slice(0, -1) : string; 31241 } 31242 31243 // Note: a long line without a suitable break point will exceed the width limit. 31244 // Pre-conditions: every char in str isPrintable, str.length > 0, width > 0. 31245 function foldString(string, width) { 31246 // In folded style, $k$ consecutive newlines output as $k+1$ newlines— 31247 // unless they're before or after a more-indented line, or at the very 31248 // beginning or end, in which case $k$ maps to $k$. 31249 // Therefore, parse each chunk as newline(s) followed by a content line. 31250 var lineRe = /(\n+)([^\n]*)/g; 31251 31252 // first line (possibly an empty line) 31253 var result = (function () { 31254 var nextLF = string.indexOf('\n'); 31255 nextLF = nextLF !== -1 ? nextLF : string.length; 31256 lineRe.lastIndex = nextLF; 31257 return foldLine(string.slice(0, nextLF), width); 31258 }()); 31259 // If we haven't reached the first content line yet, don't add an extra \n. 31260 var prevMoreIndented = string[0] === '\n' || string[0] === ' '; 31261 var moreIndented; 31262 31263 // rest of the lines 31264 var match; 31265 while ((match = lineRe.exec(string))) { 31266 var prefix = match[1], line = match[2]; 31267 moreIndented = (line[0] === ' '); 31268 result += prefix 31269 + (!prevMoreIndented && !moreIndented && line !== '' 31270 ? '\n' : '') 31271 + foldLine(line, width); 31272 prevMoreIndented = moreIndented; 31273 } 31274 31275 return result; 31276 } 31277 31278 // Greedy line breaking. 31279 // Picks the longest line under the limit each time, 31280 // otherwise settles for the shortest line over the limit. 31281 // NB. More-indented lines *cannot* be folded, as that would add an extra \n. 31282 function foldLine(line, width) { 31283 if (line === '' || line[0] === ' ') return line; 31284 31285 // Since a more-indented line adds a \n, breaks can't be followed by a space. 31286 var breakRe = / [^ ]/g; // note: the match index will always be <= length-2. 31287 var match; 31288 // start is an inclusive index. end, curr, and next are exclusive. 31289 var start = 0, end, curr = 0, next = 0; 31290 var result = ''; 31291 31292 // Invariants: 0 <= start <= length-1. 31293 // 0 <= curr <= next <= max(0, length-2). curr - start <= width. 31294 // Inside the loop: 31295 // A match implies length >= 2, so curr and next are <= length-2. 31296 while ((match = breakRe.exec(line))) { 31297 next = match.index; 31298 // maintain invariant: curr - start <= width 31299 if (next - start > width) { 31300 end = (curr > start) ? curr : next; // derive end <= length-2 31301 result += '\n' + line.slice(start, end); 31302 // skip the space that was output as \n 31303 start = end + 1; // derive start <= length-1 31304 } 31305 curr = next; 31306 } 31307 31308 // By the invariants, start <= length-1, so there is something left over. 31309 // It is either the whole string or a part starting from non-whitespace. 31310 result += '\n'; 31311 // Insert a break if the remainder is too long and there is a break available. 31312 if (line.length - start > width && curr > start) { 31313 result += line.slice(start, curr) + '\n' + line.slice(curr + 1); 31314 } else { 31315 result += line.slice(start); 31316 } 31317 31318 return result.slice(1); // drop extra \n joiner 31319 } 31320 31321 // Escapes a double-quoted string. 31322 function escapeString(string) { 31323 var result = ''; 31324 var char; 31325 var escapeSeq; 31326 31327 for (var i = 0; i < string.length; i++) { 31328 char = string.charCodeAt(i); 31329 escapeSeq = ESCAPE_SEQUENCES[char]; 31330 result += !escapeSeq && isPrintable(char) 31331 ? string[i] 31332 : escapeSeq || encodeHex(char); 31333 } 31334 31335 return result; 31336 } 31337 31338 function writeFlowSequence(state, level, object) { 31339 var _result = '', 31340 _tag = state.tag, 31341 index, 31342 length; 31343 31344 for (index = 0, length = object.length; index < length; index += 1) { 31345 // Write only valid elements. 31346 if (writeNode(state, level, object[index], false, false)) { 31347 if (index !== 0) _result += ', '; 31348 _result += state.dump; 31349 } 31350 } 31351 31352 state.tag = _tag; 31353 state.dump = '[' + _result + ']'; 31354 } 31355 31356 function writeBlockSequence(state, level, object, compact) { 31357 var _result = '', 31358 _tag = state.tag, 31359 index, 31360 length; 31361 31362 for (index = 0, length = object.length; index < length; index += 1) { 31363 // Write only valid elements. 31364 if (writeNode(state, level + 1, object[index], true, true)) { 31365 if (!compact || index !== 0) { 31366 _result += generateNextLine(state, level); 31367 } 31368 _result += '- ' + state.dump; 31369 } 31370 } 31371 31372 state.tag = _tag; 31373 state.dump = _result || '[]'; // Empty sequence if no valid values. 31374 } 31375 31376 function writeFlowMapping(state, level, object) { 31377 var _result = '', 31378 _tag = state.tag, 31379 objectKeyList = Object.keys(object), 31380 index, 31381 length, 31382 objectKey, 31383 objectValue, 31384 pairBuffer; 31385 31386 for (index = 0, length = objectKeyList.length; index < length; index += 1) { 31387 pairBuffer = ''; 31388 31389 if (index !== 0) pairBuffer += ', '; 31390 31391 objectKey = objectKeyList[index]; 31392 objectValue = object[objectKey]; 31393 31394 if (!writeNode(state, level, objectKey, false, false)) { 31395 continue; // Skip this pair because of invalid key; 31396 } 31397 31398 if (state.dump.length > 1024) pairBuffer += '? '; 31399 31400 pairBuffer += state.dump + ': '; 31401 31402 if (!writeNode(state, level, objectValue, false, false)) { 31403 continue; // Skip this pair because of invalid value. 31404 } 31405 31406 pairBuffer += state.dump; 31407 31408 // Both key and value are valid. 31409 _result += pairBuffer; 31410 } 31411 31412 state.tag = _tag; 31413 state.dump = '{' + _result + '}'; 31414 } 31415 31416 function writeBlockMapping(state, level, object, compact) { 31417 var _result = '', 31418 _tag = state.tag, 31419 objectKeyList = Object.keys(object), 31420 index, 31421 length, 31422 objectKey, 31423 objectValue, 31424 explicitPair, 31425 pairBuffer; 31426 31427 // Allow sorting keys so that the output file is deterministic 31428 if (state.sortKeys === true) { 31429 // Default sorting 31430 objectKeyList.sort(); 31431 } else if (typeof state.sortKeys === 'function') { 31432 // Custom sort function 31433 objectKeyList.sort(state.sortKeys); 31434 } else if (state.sortKeys) { 31435 // Something is wrong 31436 throw new YAMLException('sortKeys must be a boolean or a function'); 31437 } 31438 31439 for (index = 0, length = objectKeyList.length; index < length; index += 1) { 31440 pairBuffer = ''; 31441 31442 if (!compact || index !== 0) { 31443 pairBuffer += generateNextLine(state, level); 31444 } 31445 31446 objectKey = objectKeyList[index]; 31447 objectValue = object[objectKey]; 31448 31449 if (!writeNode(state, level + 1, objectKey, true, true, true)) { 31450 continue; // Skip this pair because of invalid key. 31451 } 31452 31453 explicitPair = (state.tag !== null && state.tag !== '?') || 31454 (state.dump && state.dump.length > 1024); 31455 31456 if (explicitPair) { 31457 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { 31458 pairBuffer += '?'; 31459 } else { 31460 pairBuffer += '? '; 31461 } 31462 } 31463 31464 pairBuffer += state.dump; 31465 31466 if (explicitPair) { 31467 pairBuffer += generateNextLine(state, level); 31468 } 31469 31470 if (!writeNode(state, level + 1, objectValue, true, explicitPair)) { 31471 continue; // Skip this pair because of invalid value. 31472 } 31473 31474 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { 31475 pairBuffer += ':'; 31476 } else { 31477 pairBuffer += ': '; 31478 } 31479 31480 pairBuffer += state.dump; 31481 31482 // Both key and value are valid. 31483 _result += pairBuffer; 31484 } 31485 31486 state.tag = _tag; 31487 state.dump = _result || '{}'; // Empty mapping if no valid pairs. 31488 } 31489 31490 function detectType(state, object, explicit) { 31491 var _result, typeList, index, length, type, style; 31492 31493 typeList = explicit ? state.explicitTypes : state.implicitTypes; 31494 31495 for (index = 0, length = typeList.length; index < length; index += 1) { 31496 type = typeList[index]; 31497 31498 if ((type.instanceOf || type.predicate) && 31499 (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) && 31500 (!type.predicate || type.predicate(object))) { 31501 31502 state.tag = explicit ? type.tag : '?'; 31503 31504 if (type.represent) { 31505 style = state.styleMap[type.tag] || type.defaultStyle; 31506 31507 if (_toString.call(type.represent) === '[object Function]') { 31508 _result = type.represent(object, style); 31509 } else if (_hasOwnProperty.call(type.represent, style)) { 31510 _result = type.represent[style](object, style); 31511 } else { 31512 throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style'); 31513 } 31514 31515 state.dump = _result; 31516 } 31517 31518 return true; 31519 } 31520 } 31521 31522 return false; 31523 } 31524 31525 // Serializes `object` and writes it to global `result`. 31526 // Returns true on success, or false on invalid object. 31527 // 31528 function writeNode(state, level, object, block, compact, iskey) { 31529 state.tag = null; 31530 state.dump = object; 31531 31532 if (!detectType(state, object, false)) { 31533 detectType(state, object, true); 31534 } 31535 31536 var type = _toString.call(state.dump); 31537 31538 if (block) { 31539 block = (state.flowLevel < 0 || state.flowLevel > level); 31540 } 31541 31542 var objectOrArray = type === '[object Object]' || type === '[object Array]', 31543 duplicateIndex, 31544 duplicate; 31545 31546 if (objectOrArray) { 31547 duplicateIndex = state.duplicates.indexOf(object); 31548 duplicate = duplicateIndex !== -1; 31549 } 31550 31551 if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) { 31552 compact = false; 31553 } 31554 31555 if (duplicate && state.usedDuplicates[duplicateIndex]) { 31556 state.dump = '*ref_' + duplicateIndex; 31557 } else { 31558 if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) { 31559 state.usedDuplicates[duplicateIndex] = true; 31560 } 31561 if (type === '[object Object]') { 31562 if (block && (Object.keys(state.dump).length !== 0)) { 31563 writeBlockMapping(state, level, state.dump, compact); 31564 if (duplicate) { 31565 state.dump = '&ref_' + duplicateIndex + state.dump; 31566 } 31567 } else { 31568 writeFlowMapping(state, level, state.dump); 31569 if (duplicate) { 31570 state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; 31571 } 31572 } 31573 } else if (type === '[object Array]') { 31574 if (block && (state.dump.length !== 0)) { 31575 writeBlockSequence(state, level, state.dump, compact); 31576 if (duplicate) { 31577 state.dump = '&ref_' + duplicateIndex + state.dump; 31578 } 31579 } else { 31580 writeFlowSequence(state, level, state.dump); 31581 if (duplicate) { 31582 state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; 31583 } 31584 } 31585 } else if (type === '[object String]') { 31586 if (state.tag !== '?') { 31587 writeScalar(state, state.dump, level, iskey); 31588 } 31589 } else { 31590 if (state.skipInvalid) return false; 31591 throw new YAMLException('unacceptable kind of an object to dump ' + type); 31592 } 31593 31594 if (state.tag !== null && state.tag !== '?') { 31595 state.dump = '!<' + state.tag + '> ' + state.dump; 31596 } 31597 } 31598 31599 return true; 31600 } 31601 31602 function getDuplicateReferences(object, state) { 31603 var objects = [], 31604 duplicatesIndexes = [], 31605 index, 31606 length; 31607 31608 inspectNode(object, objects, duplicatesIndexes); 31609 31610 for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) { 31611 state.duplicates.push(objects[duplicatesIndexes[index]]); 31612 } 31613 state.usedDuplicates = new Array(length); 31614 } 31615 31616 function inspectNode(object, objects, duplicatesIndexes) { 31617 var objectKeyList, 31618 index, 31619 length; 31620 31621 if (object !== null && typeof object === 'object') { 31622 index = objects.indexOf(object); 31623 if (index !== -1) { 31624 if (duplicatesIndexes.indexOf(index) === -1) { 31625 duplicatesIndexes.push(index); 31626 } 31627 } else { 31628 objects.push(object); 31629 31630 if (Array.isArray(object)) { 31631 for (index = 0, length = object.length; index < length; index += 1) { 31632 inspectNode(object[index], objects, duplicatesIndexes); 31633 } 31634 } else { 31635 objectKeyList = Object.keys(object); 31636 31637 for (index = 0, length = objectKeyList.length; index < length; index += 1) { 31638 inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes); 31639 } 31640 } 31641 } 31642 } 31643 } 31644 31645 function dump(input, options) { 31646 options = options || {}; 31647 31648 var state = new State(options); 31649 31650 if (!state.noRefs) getDuplicateReferences(input, state); 31651 31652 if (writeNode(state, 0, input, true, true)) return state.dump + '\n'; 31653 31654 return ''; 31655 } 31656 31657 function safeDump(input, options) { 31658 return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); 31659 } 31660 31661 module.exports.dump = dump; 31662 module.exports.safeDump = safeDump; 31663 31664 31665 /***/ }, 31666 /* 156 */ 31667 /***/ function(module, exports, __webpack_require__) { 31668 31669 /* WEBPACK VAR INJECTION */(function($) {'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _backbone=__webpack_require__(113),_sidebar=__webpack_require__(157),_sidebar2=_interopRequireDefault(_sidebar);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}/** 31670 * Class contains logic of sidebar view in application. 31671 * @class SidebarView 31672 * @extends View 31673 *//* global VERSION, $ */class SidebarView extends _backbone.View{get tagName(){return'div'}get className(){return'nav-sidebar'}get events(){return{'focus [data-gohan="menu-filter"]':'onFilter','blur [data-gohan="menu-filter"]':'onFilter','click [data-gohan="sidebar-open"]':'openSidebar','click [data-gohan="sidebar-close"]':'closeSidebar'}}/** 31674 * Constructs the object. 31675 * @constructor 31676 * @override View.constructor 31677 * @param {Object} options 31678 */constructor(a){super(a),this.schemas=a.schemas,this.router=a.app.router,this.filterDelay=300,this.filterTimeout=void 0,this.filterCache='',this.listenTo(this.collection,'sync',this.render),this.router.on('route',this.onRoute.bind(this))}/** 31679 * Handles on route event. 31680 * Selects item in menu, by url fragment. 31681 */onRoute(){const a=this.collection.findWhere({active:!0}),b=this.collection.findWhere({path:'/'+_backbone.history.getFragment()});void 0!==a&&a.set('active',!1),void 0!==b&&b.set('active',!0),this.closeSidebar(),this.render()}/** 31682 * Handles on focus event for the filter input field. 31683 */onFilter(a){'focusin'===a.type?this.menuFilter():'focusout'===a.type&&clearTimeout(this.filterTimeout)}/** 31684 * Handles each menu dom visibility as to input text. 31685 */menuFilter(){clearTimeout(this.filterTimeout);const a=$('.menu-filter',this.$el).val().toLowerCase(),b=$('.nav > li > a',this.$el);if(''!==a&&this.filterCache!==a){b.hide();const c=b.filter(function(){return $(this).text().toLowerCase().includes(a)});c.show(),this.filterCache=a}else''===a&&this.filterCache!==a&&(this.filterCache='',b.show());this.filterTimeout=setTimeout(()=>{this.menuFilter()},this.filterDelay)}/** 31686 * Handles sidebar visivility when screen size is smaller than sm. 31687 */openSidebar(){this.$el.parent().addClass('open')}/** 31688 * Handles sidebar visivility when screen size is smaller than sm. 31689 */closeSidebar(){this.$el.parent().removeClass('open')}/** 31690 * Renders component content. 31691 * @override View.render 31692 * @returns {SidebarView} 31693 */render(){return this.$el.html((0,_sidebar2.default)({version:({"hash":"6dcff1bb53b13f1b7be1d9c04608d69ee4a382dd","tag":"1.16.2","version":"1.16.2"}),defaultMenu:this.collection.toJSON()})),this}}exports.default=SidebarView; 31694 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71))) 31695 31696 /***/ }, 31697 /* 157 */ 31698 /***/ function(module, exports) { 31699 31700 module.exports = function(obj){ 31701 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 31702 with(obj||{}){ 31703 __p+='<button type="button" class="sidebar-open" data-gohan="sidebar-open">\n <span class="glyphicon glyphicon-menu-hamburger" aria-label="Open Sidebar"></span>\n</button>\n\n<button type="button" class="sidebar-close" data-gohan="sidebar-close">\n <span class="glyphicon glyphicon glyphicon-menu-left" aria-label="Close Sidebar"></span>\n</button>\n\n<div class="brand">\n <h1>\n <a href="#/">Gohan WebUI</a>\n </h1>\n <div class="version-info">\n <span>version:'+ 31704 ((__t=( version.version ))==null?'':__t)+ 31705 '</span>\n </div>\n <div class="search">\n <input class="form-control menu-filter" data-gohan="menu-filter" type="text" placeholder="Menu Search">\n </div>\n</div>\n\n<div class="default-menu">\n <ul class="default-ul nav">\n '; 31706 defaultMenu.forEach( function(menu) { 31707 __p+='\n <li '; 31708 if (menu.active) { 31709 __p+=' class="active" '; 31710 } 31711 __p+=' >\n <a href="#'+ 31712 ((__t=( menu.path ))==null?'':__t)+ 31713 '">\n '+ 31714 ((__t=( menu.title ))==null?'':__t)+ 31715 '\n </a>\n </li>\n '; 31716 }); 31717 __p+='\n </ul>\n</div>\n'; 31718 } 31719 return __p; 31720 }; 31721 31722 31723 /***/ }, 31724 /* 158 */ 31725 /***/ function(module, exports, __webpack_require__) { 31726 31727 /* WEBPACK VAR INJECTION */(function($) {'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _backbone=__webpack_require__(113),_header=__webpack_require__(159),_header2=_interopRequireDefault(_header);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}/** 31728 * Class contains logic of header view in application. 31729 * @class HeaderView 31730 * @extends View 31731 *//* global window, $ */class HeaderView extends _backbone.View{get tagName(){return'div'}get events(){return{'click [data-gohan="logout"]':'logout','click [data-gohan="change-tenant"]':'changeTenant'}}/** 31732 * Constructs the object. 31733 * @constructor 31734 * @override View.constructor 31735 * @param {Object} options 31736 */constructor(a){super(a),this.config=a.config}/** 31737 * Logs out user and reloads page. 31738 */logout(){this.model.unsetAuthData(),window.location.reload()}/** 31739 * Change Tenant 31740 */changeTenant(a){const b=$(a.currentTarget).data('tenant');this.model.loginTenant(b).then(()=>{window.location.reload()})}/** 31741 * Renders component content. 31742 * @override View.render 31743 * @returns {HeaderView} 31744 */render(){return this.$el.html((0,_header2.default)({config:this.config,username:this.model.userName(),authToken:this.model.authToken(),tenantName:this.model.tenantName(),tenants:this.model.tenants()})),this}}exports.default=HeaderView; 31745 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71))) 31746 31747 /***/ }, 31748 /* 159 */ 31749 /***/ function(module, exports, __webpack_require__) { 31750 31751 /* WEBPACK VAR INJECTION */(function(_) {module.exports = function(obj){ 31752 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 31753 with(obj||{}){ 31754 __p+=''; 31755 if (authToken) { 31756 __p+='\n<ul class="nav navbar-nav navbar-right">\n '; 31757 if (tenants.length > 1) { 31758 __p+='\n <li class="dropdown">\n <a id="tenant-ddm" href="#" class="dropdown-toggle" data-toggle="dropdown" \n role="button" aria-haspopup="true" aria-expanded="false">Tenant: '+ 31759 ((__t=( tenantName ))==null?'':__t)+ 31760 ' <span class="caret"></span> </a>\n <ul class="dropdown-menu" aria-labelledby="tenant-ddm">\n '; 31761 _.each(tenants, function(tenant){ 31762 __p+='\n <li><a href="#" data-gohan="change-tenant" data-tenant="'+ 31763 ((__t=( tenant.name ))==null?'':__t)+ 31764 '">'+ 31765 ((__t=( tenant.name ))==null?'':__t)+ 31766 '</a></li>\n '; 31767 }); 31768 __p+='\n </ul>\n </li>\n '; 31769 } else { 31770 __p+='\n <li><a style="pointer-events: none;">Tenant: '+ 31771 ((__t=( tenantName ))==null?'':__t)+ 31772 '</a></li>\n '; 31773 } 31774 __p+='\n <li class="dropdown">\n <a id="user-ddm" href="#" class="dropdown-toggle" data-toggle="dropdown" \n role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> '+ 31775 ((__t=( username ))==null?'':__t)+ 31776 ' <span class="caret"></span> </a>\n <ul class="dropdown-menu" aria-labelledby="user-ddm">\n <li>\n <a href="#" data-gohan="logout">Log Out</a>\n </li>\n </ul>\n </li>\n </ul>\n '; 31777 } 31778 __p+='\n'; 31779 } 31780 return __p; 31781 }; 31782 31783 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(114))) 31784 31785 /***/ }, 31786 /* 160 */ 31787 /***/ function(module, exports, __webpack_require__) { 31788 31789 /* WEBPACK VAR INJECTION */(function($) {'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _backbone=__webpack_require__(113),_underscore=__webpack_require__(114),_underscore2=_interopRequireDefault(_underscore);__webpack_require__(72);var _jsYaml=__webpack_require__(121),_jsYaml2=_interopRequireDefault(_jsYaml),_bootstrapDialog=__webpack_require__(85),_bootstrapDialog2=_interopRequireDefault(_bootstrapDialog),_dialogView=__webpack_require__(161),_dialogView2=_interopRequireDefault(_dialogView),_errorView=__webpack_require__(162),_errorView2=_interopRequireDefault(_errorView),_loader=__webpack_require__(179),_loader2=_interopRequireDefault(_loader),_dataPopup=__webpack_require__(180),_dataPopup2=_interopRequireDefault(_dataPopup),_table=__webpack_require__(181),_table2=_interopRequireDefault(_table);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}/* global $ */class TableView extends _backbone.View{get tagName(){return'div'}get className(){return'tableview'}get events(){return{'click [data-gohan="create"]':'createModel','click [data-gohan="delete"]':'deleteModel','click [data-gohan="update"]':'updateModel','click [data-gohan="sort-title"]':'sortData','keyup [data-gohan="search"]':'searchByKey','change [data-gohan="search"]':'searchByField','click [data-gohan="pagination"] li:not(.disabled) a':'paginationHandler','click [data-gohan="toggle-row"]':'toggleRow','click [data-gohan="toggle-all-row"]':'toggleAllRow','click [data-gohan="delete-all"]':'deleteSelectedModel'}}constructor(a){super(a),this.app=a.app,this.errorView=this.app.ErrorClass?new this.app.ErrorClass:new _errorView2.default,this.template=a.template||_table2.default,this.loaderTemplate=a.loaderTemplate||_loader2.default,this.dialogTemplate=a.dialogTemplate,this.params=a.params,this.schema=a.schema,this.parent=a.parent,this.parentId=a.parentId,this.fragment=a.fragment,this.childview=a.childview,this.polling=a.polling,void 0!==a.pageLimit&&(this.collection.pageLimit=+a.pageLimit),this.activePage=this.params&&this.params.page?+this.params.page:1,this.paginationSettings={start:1,limit:7},this.activeSortFilter={by:'',reverse:!1},this.searchQuery={property:'name',value:void 0},this.searchDelay=500,this.searchTimeout=void 0,this.childview&&(this.parentProperty=(this.parent||this.schema.get('parent'))+'_id'),this.$el.html(this.loaderTemplate()),void 0!==this.collection&&(a.sortKey&&(this.collection.sortKey=a.sortKey),a.sortOrder&&(this.collection.sortOrder=a.sortOrder),this.collection.getPage(this.activePage-1).then(()=>{this.render(),this.searchQuery.property=$('[data-gohan="search"] select',this.$el).val()||'name',this.polling&&this.collection.startLongPolling()},b=>{this.errorView.render(...b)}),this.activeSortFilter.reverse='asc'!==this.collection.sortOrder,this.activeSortFilter.by=this.collection.sortKey),this.listenTo(this.collection,'update',this.render)}searchByKey(a){a.preventDefault(),a.stopPropagation(),clearTimeout(this.searchTimeout),this.searchTimeout=setTimeout(()=>{const b=$('[data-gohan="search"] input',this.$el).val();this.searchQuery.value=b||void 0,this.collection.filterByQuery(this.searchQuery.property,this.searchQuery.value).then(()=>{$('[data-gohan="search"] input',this.$el).focus().val(this.searchQuery.value)},c=>{this.errorView.render(...c)})},this.searchDelay)}searchByField(a){if(a.preventDefault(),a.stopPropagation(),!!$('[data-gohan="search"] select',this.$el)){const b=$('[data-gohan="search"] select',this.$el).val();b&&this.searchQuery.property!==b&&(this.searchQuery.property=b,this.searchQuery.value&&this.collection.filterByQuery(this.searchQuery.property,this.searchQuery.value).then(()=>{$('[data-gohan="search"] select',this.$el).val(this.searchQuery.property)},c=>{this.errorView.render(...c)}))}}getPage(a){this.collection.getPage(a-1).then(()=>{$('[data-gohan="search"] select',this.$el).val(this.searchQuery.property)},b=>{this.errorView.render(...b)})}sortData(a){a.preventDefault(),a.stopPropagation();const b=a.currentTarget.dataset.id;this.activeSortFilter.by===b?this.activeSortFilter.by!==b||this.activeSortFilter.reverse?(this.activeSortFilter.by='',this.activeSortFilter.reverse=!1):this.activeSortFilter.reverse=!0:(this.activeSortFilter.by=b,this.activeSortFilter.reverse=!1);const c=this.activeSortFilter.by,d=this.activeSortFilter.reverse?'desc':'asc';this.collection.sort(c,d).then(()=>{},e=>{this.errorView.render(...e)})}paginationHandler(a){a.preventDefault(),a.stopPropagation();let b=a.currentTarget.dataset.id,c=a.currentTarget.dataset.more;'next'===b?b=+this.activePage+1:'prev'==b&&(b=+this.activePage-1),this.activePage===+b||(b===this.paginationSettings.start-1?c='left':b==this.paginationSettings.start+this.paginationSettings.limit-1&&(c='right'),'right'===c?this.paginationSettings.start=+b:'left'==c&&(this.paginationSettings.start=this.paginationSettings.start-this.paginationSettings.limit+1,1>this.paginationSettings.start&&(this.paginationSettings.start=1)),this.activePage=+b,!this.childview&&this.app.router.setQueryParams({page:this.activePage}),this.getPage(+b))}toggleRow(a){a.preventDefault(),a.stopPropagation();const b=$(a.currentTarget),c=b.data('id'),d=this.collection.get(c+'');d.isSelected=!d.isSelected,this.render()}toggleAllRow(a){a.preventDefault(),a.stopPropagation();const b=this.collection.some(c=>{return c.isSelected});this.collection.each(c=>{c.isSelected=!b}),this.render()}dialogForm(a,b,c,d,e){this.schema.filterByAction(a,this.parentProperty).then(f=>{this.dialog=new _dialogView2.default({app:this.app,template:this.dialogTemplate,formTitle:b,data:c,onsubmit:d,onhide:e,schema:this.schema.toFormJSON(f),unformattedSchema:this.schema,fields:f.propertiesOrder,action:a}),this.dialog.render()})}toLocal(a){return this.schema.toLocal(a)}toServer(a){return this.schema.toServer(a)}createModel(a){a.preventDefault(),a.stopPropagation(),a.currentTarget.disabled=!0;const b=this.toLocal({}),c='<h4>Create '+this.schema.get('title')+'</h4>';this.dialogForm('create',c,b,d=>{d=this.toServer(d),d.isNew=!0,this.parentId&&Object.assign(d,{[this.parent+'_id']:this.parentId}),this.collection.create(d,{wait:!0}).then(()=>{this.dialog.close(),this.collection.fetch()},e=>{this.dialog.errorView.render(...e),this.dialog.stopSpin()})},()=>{a.currentTarget.disabled=!1})}updateModel(a){a.preventDefault(),a.stopPropagation(),a.currentTarget.disabled=!0;const b=$(a.currentTarget),c=b.data('id'),d=this.collection.get(c+''),e=this.toLocal(d.toJSON()),f='<h4>Update '+this.schema.get('title')+'</h4>';this.dialogForm('update',f,e,g=>{g=this.toServer(g),d.save(g,{wait:!0}).then(()=>{this.collection.trigger('update'),this.dialog.close(),a.currentTarget.disabled=!1},h=>{this.dialog.errorView.render(...h),this.dialog.stopSpin()})},()=>{a.currentTarget.disabled=!1})}deleteModel(a){a.preventDefault(),a.stopPropagation(),_bootstrapDialog2.default.confirm({title:'Delete',message:'Are you sure to delete?',closable:!0,btnOKLabel:'Delete',callback:b=>{if(b){const c=$(a.currentTarget),d=c.data('id'),e=this.collection.get(d+'');e.isDeleting=!0,this.render(),e.destroy({wait:!0}).then(()=>{this.collection.fetch().catch(f=>this.errorView.render(...f))},f=>{e.isDeleting=!1,this.render(),this.errorView.render(...f)})}}})}deleteSelectedModel(a){a.preventDefault(),a.stopPropagation(),_bootstrapDialog2.default.confirm({title:'Delete',message:'Are you sure to delete?',closable:!0,btnOKLabel:'Delete',callback:b=>{b&&(this.collection.each(c=>{c.isSelected&&!c.isDeleting&&(c.isDeleting=!0,c.destroy({wait:!0}).then(()=>{this.collection.fetch().catch(d=>this.errorView.render(...d))},d=>{c.isDeleting=!1,this.render(),this.errorView.render(...d)}))}),this.render())}})}renderProperty(a,b){let c;const d=this.schema.get('schema').properties[b],e=a[b];if(void 0===d)return _underscore2.default.escape(e);if(void 0===e)return'';const f=a[d.relation_property];// jscs:ignore requireCamelCaseOrUpperCaseIdentifiers 31790 if(void 0!==f&&void 0!==f.name)return f.name;try{if(d.type.includes('object')||d.originalType&&d.originalType.includes('object'))return c=$('<pre style="width:500px;"></pre>').text('<pre>'+_jsYaml2.default.safeDump(e)+'</pre>').html(),c=c.replace(/\'/g,'''),(0,_dataPopup2.default)({content:c})}catch(g){console.error(g)}try{if(d.type.includes('array'))return'<pre>'+_jsYaml2.default.safeDump(e)+'</pre>'}catch(g){console.error(g)}return _underscore2.default.escape(e)}render(){const a=this.collection.map(c=>{const d=c.toJSON(),e=Object.assign({},d);for(let f in d)e[f]=this.renderProperty(d,f);return e}),b=this.collection.map(c=>{return{isSelected:c.isSelected,isDeleting:c.isDeleting}});if(this.app&&!this.childview){this.app.router.changeTitle(this.schema.get('title'));const c=[],d=this.collection.schema.get('url');let e;e=this.collection.schema.hasParent()?this.collection.schema.parent().get('url')+'/'+this.collection.parentId()+'/'+this.collection.schema.get('plural'):d,c.push({title:this.collection.schema.get('title'),url:e}),c.reverse(),this.app.breadCrumb.update(c)}return this.$el.html(this.template({data:a,uiState:b,activePage:this.activePage,pageCount:this.collection.getPageCount(),schema:this.schema.toJSON(),searchQuery:this.searchQuery,sort:this.activeSortFilter,parentProperty:this.parentProperty,pagination:this.paginationSettings,fragment:this.fragment,params:this.params})),$('a[data-toggle="popover"]',this.el).popover(),$('a[data-toggle="tooltip"]',this.el).tooltip(),$('[data-gohan="error"]',this.el).append(this.errorView.el),this}close(){this.childview||this.app.router.setQueryParams(),this.polling&&this.collection.stopLongPolling(),this.collection&&this.collection.resetFilters(),this.remove()}}exports.default=TableView; 31791 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71))) 31792 31793 /***/ }, 31794 /* 161 */ 31795 /***/ function(module, exports, __webpack_require__) { 31796 31797 /* WEBPACK VAR INJECTION */(function($) {'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _backbone=__webpack_require__(113),_backbone2=_interopRequireDefault(_backbone),_bootstrapDialog=__webpack_require__(85),_bootstrapDialog2=_interopRequireDefault(_bootstrapDialog),_errorView=__webpack_require__(162),_errorView2=_interopRequireDefault(_errorView);__webpack_require__(164);__webpack_require__(166);__webpack_require__(167);__webpack_require__(169);__webpack_require__(175);__webpack_require__(176);__webpack_require__(177);__webpack_require__(178);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}class DialogView extends _backbone.View{/** 31798 * Initialize of object properties. 31799 * 31800 * @class {DialogView} 31801 * @constructor 31802 * @param {string} options.action 31803 * @param {string} options.formTitle 31804 * @param {Object} options.data 31805 * @param {function} options.onsubmit 31806 * @param {Object} options.schema 31807 * @param {Object} options.parentProperty 31808 */constructor(a){super(a),this.errorView=new _errorView2.default,this.formTitle=a.formTitle,this.template=a.template,this.data=a.data,this.onshow=a.onshow,this.onsubmit=a.onsubmit,this.onhide=a.onhide,this.unformattedSchema=a.unformattedSchema,this.schema=a.schema,this.fields=a.fields,this.events=a.events,this.addingRelationDialog=this.unformattedSchema.addingRelationDialog||[],this.dialog=new _bootstrapDialog2.default({size:_bootstrapDialog2.default.SIZE_WIDE,type:_bootstrapDialog2.default.TYPE_DEFAULT,title:this.formTitle,closeByKeyboard:!1,spinicon:'glyphicon glyphicon-refresh',onshown:()=>{this.form.focus()},onhide:this.onhide,onshow:this.onshow}),this.action=a.action}/** 31809 * Stops spin in button and enables buttons. 31810 */stopSpin(){this.dialog.enableButtons(!0),this.dialog.setClosable(!0),this.dialog.getButton('submit').stopSpin()}/** 31811 * Closes dialog. 31812 */close(){this.dialog.close(),this.remove(),this.off()}/** 31813 * Attaches event to form. 31814 * 31815 * @param {string} name 31816 * @param {function} callback 31817 */on(a,b){this.form&&this.form.on(a,b)}createRelationModel(a){const b=a.toLocal({}),c='<h4>Create '+a.get('title')+'</h4>',d=f=>{f=a.toServer(f),f.isNew=!0;const g=a.makeCollection();g.create(f).then(h=>{this.updateSelectEditor(h[1]),this.updateDialogSchema(),this.nestedDialog.close()},h=>{this.nestedDialog.errorView.render(...h),this.nestedDialog.stopSpin()})},e=()=>{const f=this.form.fields[a.id+'_id'].editor;f.getValue()==='addNew'+a.id&&f.setValue(void 0)};a.filterByAction('create',this.parentProperty).then(f=>{this.nestedDialog=new DialogView({formTitle:c,data:b,onsubmit:d,onhide:e,schema:a.toFormJSON(f),unformattedSchema:a,fields:f.propertiesOrder}),this.nestedDialog.render()},f=>{console.error(f)})}updateSelectEditor(a){const b=Object.keys(a)[0],c=a[b],d=this.form.fields[b+'_id'].editor;this.schema[b+'_id'].options[c.id]=c.name,d.setOptions(this.schema[b+'_id'].options),d.setValue(c.id)}updateDialogSchema(){for(let a in this.schema)if(this.schema.hasOwnProperty(a)){const b=this.schema[a],c=this.addingRelationDialog.includes(b.title);b.hasOwnProperty('relation')&&'select'===b.type.toLowerCase()&&c&&(b.options['addNew'+b.relation]=' + New '+b.title)}}/** 31818 * Renders dialog view. 31819 * @returns {DialogView} 31820 */render(){for(let a in this.updateDialogSchema(),this.form=new _backbone2.default.Form({schema:this.schema,data:this.data,fields:this.fields.filter(a=>Object.keys(this.schema).includes(a)),template:this.template}),this.schema)if(this.schema.hasOwnProperty(a)){const b=this.schema[a];'select'===b.type.toLowerCase()&&this.on(a+':change',(c,d)=>{const e=d.getValue();if(e&&e.includes('addNew')){const f=this.unformattedSchema.collection.get(d.schema.relation);this.createRelationModel(f)}})}if(this.events)for(let a in this.events)this.on(a,this.events[a]);this.form.render(),this.form.$el.prepend('<div data-gohan="error"></div>'),this.dialog.setMessage(this.form.el),this.dialog.addButton({id:'submit',label:'create'===this.action?'Create':'Update',cssClass:'btn-primary',action:()=>{const a=this.form.validate();return a?void console.error(a):void(this.dialog.enableButtons(!1),this.dialog.setClosable(!1),this.onsubmit(this.form.getValue()))}}),$('[data-gohan="error"]',this.form.el).append(this.errorView.el),this.dialog.open(),this.dialog.$modalBody.css({'max-height':$(window).height()-200+'px','overflow-y':'auto'})}}exports.default=DialogView;/* global $, window */ 31821 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71))) 31822 31823 /***/ }, 31824 /* 162 */ 31825 /***/ function(module, exports, __webpack_require__) { 31826 31827 'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _backbone=__webpack_require__(113),_error=__webpack_require__(163),_error2=_interopRequireDefault(_error);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}/* global window */class ErrorView extends _backbone.View{get tagName(){return'div'}get events(){return{'click [data-gohan="reload"]':'reload','click [data-gohan="close"]':'close'}}constructor(){super(),this.message='Unknown Error',this.messageDetail=''}reload(){window.location.reload()}render(...a){const b=a.find(d=>{return d.hasOwnProperty('status')&&d.hasOwnProperty('readyState')});if(void 0!==b){switch(this.message=b.statusText,b.hasOwnProperty('responseJSON')&&b.responseJSON&&b.responseJSON.hasOwnProperty('error')&&('object'==typeof b.responseJSON.error&&b.responseJSON.error.message?this.messageDetail=b.responseJSON.error.message:this.messageDetail=b.responseJSON.error),b.status){case 0:{this.message='Server Connection failed (<a href="#" data-gohan="reload" class="alert-link">Reload</a>)';break}case 400:{this.message='Bad Request';break}case 401:{this.message='Unauthorized Error';break}case 404:{this.message='Data Not Found';break}case 500:{this.message='Server Side Error';break}}const c=(0,_error2.default)({message:this.message,messageDetail:this.messageDetail});return this.$el.html(c),this.delegateEvents(),this}}close(){this.$el.html('<div></div>')}}exports.default=ErrorView; 31828 31829 /***/ }, 31830 /* 163 */ 31831 /***/ function(module, exports) { 31832 31833 module.exports = function(obj){ 31834 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 31835 with(obj||{}){ 31836 __p+='<div class="alert alert-warning fade in out" role="alert">\n <a data-gohan="close" class="close" data-dismiss="alert" aria-label="close">×</a>\n <strong>'+ 31837 ((__t=( message ))==null?'':__t)+ 31838 ' </strong>\n <span>'+ 31839 ((__t=( messageDetail ))==null?'':__t)+ 31840 '</span>\n</div>\n'; 31841 } 31842 return __p; 31843 }; 31844 31845 31846 /***/ }, 31847 /* 164 */ 31848 /***/ function(module, exports, __webpack_require__) { 31849 31850 /* WEBPACK VAR INJECTION */(function(global, $) {/** 31851 * Backbone Forms v0.14.1 31852 * 31853 * Copyright (c) 2014 Charles Davison, Pow Media Ltd 31854 * 31855 * License and more information at: 31856 * http://github.com/powmedia/backbone-forms 31857 */ 31858 ;(function(root) { 31859 31860 //DEPENDENCIES 31861 //CommonJS 31862 if (true) { 31863 var _ = root._ || __webpack_require__(114), 31864 Backbone = root.Backbone || __webpack_require__(165); 31865 } 31866 31867 //Browser 31868 else { 31869 var _ = root._, 31870 Backbone = root.Backbone; 31871 } 31872 31873 31874 //SOURCE 31875 //================================================================================================== 31876 //FORM 31877 //================================================================================================== 31878 31879 var Form = Backbone.View.extend({ 31880 31881 events: { 31882 'submit': function(event) { 31883 this.trigger('submit', event); 31884 } 31885 }, 31886 31887 /** 31888 * Constructor 31889 * 31890 * @param {Object} [options.schema] 31891 * @param {Backbone.Model} [options.model] 31892 * @param {Object} [options.data] 31893 * @param {String[]|Object[]} [options.fieldsets] 31894 * @param {String[]} [options.fields] 31895 * @param {String} [options.idPrefix] 31896 * @param {Form.Field} [options.Field] 31897 * @param {Form.Fieldset} [options.Fieldset] 31898 * @param {Function} [options.template] 31899 * @param {Boolean|String} [options.submitButton] 31900 */ 31901 initialize: function(options) { 31902 var self = this; 31903 31904 //Merge default options 31905 options = this.options = _.extend({ 31906 submitButton: false 31907 }, options); 31908 31909 //Find the schema to use 31910 var schema = this.schema = (function() { 31911 //Prefer schema from options 31912 if (options.schema) return _.result(options, 'schema'); 31913 31914 //Then schema on model 31915 var model = options.model; 31916 if (model && model.schema) return _.result(model, 'schema'); 31917 31918 //Then built-in schema 31919 if (self.schema) return _.result(self, 'schema'); 31920 31921 //Fallback to empty schema 31922 return {}; 31923 })(); 31924 31925 //Store important data 31926 _.extend(this, _.pick(options, 'model', 'data', 'idPrefix', 'templateData')); 31927 31928 //Override defaults 31929 var constructor = this.constructor; 31930 this.template = options.template || this.template || constructor.template; 31931 this.Fieldset = options.Fieldset || this.Fieldset || constructor.Fieldset; 31932 this.Field = options.Field || this.Field || constructor.Field; 31933 this.NestedField = options.NestedField || this.NestedField || constructor.NestedField; 31934 31935 //Check which fields will be included (defaults to all) 31936 var selectedFields = this.selectedFields = options.fields || _.keys(schema); 31937 31938 //Create fields 31939 var fields = this.fields = {}; 31940 31941 _.each(selectedFields, function(key) { 31942 var fieldSchema = schema[key]; 31943 fields[key] = this.createField(key, fieldSchema); 31944 }, this); 31945 31946 //Create fieldsets 31947 var fieldsetSchema = options.fieldsets || _.result(this, 'fieldsets') || [selectedFields], 31948 fieldsets = this.fieldsets = []; 31949 31950 _.each(fieldsetSchema, function(itemSchema) { 31951 this.fieldsets.push(this.createFieldset(itemSchema)); 31952 }, this); 31953 }, 31954 31955 /** 31956 * Creates a Fieldset instance 31957 * 31958 * @param {String[]|Object[]} schema Fieldset schema 31959 * 31960 * @return {Form.Fieldset} 31961 */ 31962 createFieldset: function(schema) { 31963 var options = { 31964 schema: schema, 31965 fields: this.fields 31966 }; 31967 31968 return new this.Fieldset(options); 31969 }, 31970 31971 /** 31972 * Creates a Field instance 31973 * 31974 * @param {String} key 31975 * @param {Object} schema Field schema 31976 * 31977 * @return {Form.Field} 31978 */ 31979 createField: function(key, schema) { 31980 var options = { 31981 form: this, 31982 key: key, 31983 schema: schema, 31984 idPrefix: this.idPrefix 31985 }; 31986 31987 if (this.model) { 31988 options.model = this.model; 31989 } else if (this.data) { 31990 options.value = this.data[key]; 31991 } else { 31992 options.value = null; 31993 } 31994 31995 var field = new this.Field(options); 31996 31997 this.listenTo(field.editor, 'all', this.handleEditorEvent); 31998 31999 return field; 32000 }, 32001 32002 /** 32003 * Callback for when an editor event is fired. 32004 * Re-triggers events on the form as key:event and triggers additional form-level events 32005 * 32006 * @param {String} event 32007 * @param {Editor} editor 32008 */ 32009 handleEditorEvent: function(event, editor) { 32010 //Re-trigger editor events on the form 32011 var formEvent = editor.key+':'+event; 32012 32013 this.trigger.call(this, formEvent, this, editor, Array.prototype.slice.call(arguments, 2)); 32014 32015 //Trigger additional events 32016 switch (event) { 32017 case 'change': 32018 this.trigger('change', this); 32019 break; 32020 32021 case 'focus': 32022 if (!this.hasFocus) this.trigger('focus', this); 32023 break; 32024 32025 case 'blur': 32026 if (this.hasFocus) { 32027 //TODO: Is the timeout etc needed? 32028 var self = this; 32029 setTimeout(function() { 32030 var focusedField = _.find(self.fields, function(field) { 32031 return field.editor.hasFocus; 32032 }); 32033 32034 if (!focusedField) self.trigger('blur', self); 32035 }, 0); 32036 } 32037 break; 32038 } 32039 }, 32040 32041 templateData: function() { 32042 var options = this.options; 32043 32044 return { 32045 submitButton: options.submitButton 32046 } 32047 }, 32048 32049 render: function() { 32050 var self = this, 32051 fields = this.fields, 32052 $ = Backbone.$; 32053 32054 //Render form 32055 var $form = $($.trim(this.template(_.result(this, 'templateData')))); 32056 32057 //Render standalone editors 32058 $form.find('[data-editors]').add($form).each(function(i, el) { 32059 var $container = $(el), 32060 selection = $container.attr('data-editors'); 32061 32062 if (_.isUndefined(selection)) return; 32063 32064 //Work out which fields to include 32065 var keys = (selection == '*') 32066 ? self.selectedFields || _.keys(fields) 32067 : selection.split(','); 32068 32069 //Add them 32070 _.each(keys, function(key) { 32071 var field = fields[key]; 32072 32073 $container.append(field.editor.render().el); 32074 }); 32075 }); 32076 32077 //Render standalone fields 32078 $form.find('[data-fields]').add($form).each(function(i, el) { 32079 var $container = $(el), 32080 selection = $container.attr('data-fields'); 32081 32082 if (_.isUndefined(selection)) return; 32083 32084 //Work out which fields to include 32085 var keys = (selection == '*') 32086 ? self.selectedFields || _.keys(fields) 32087 : selection.split(','); 32088 32089 //Add them 32090 _.each(keys, function(key) { 32091 var field = fields[key]; 32092 32093 $container.append(field.render().el); 32094 }); 32095 }); 32096 32097 //Render fieldsets 32098 $form.find('[data-fieldsets]').add($form).each(function(i, el) { 32099 var $container = $(el), 32100 selection = $container.attr('data-fieldsets'); 32101 32102 if (_.isUndefined(selection)) return; 32103 32104 _.each(self.fieldsets, function(fieldset) { 32105 $container.append(fieldset.render().el); 32106 }); 32107 }); 32108 32109 //Set the main element 32110 this.setElement($form); 32111 32112 //Set class 32113 $form.addClass(this.className); 32114 32115 return this; 32116 }, 32117 32118 /** 32119 * Validate the data 32120 * 32121 * @return {Object} Validation errors 32122 */ 32123 validate: function(options) { 32124 var self = this, 32125 fields = this.fields, 32126 model = this.model, 32127 errors = {}; 32128 32129 options = options || {}; 32130 32131 //Collect errors from schema validation 32132 _.each(fields, function(field) { 32133 var error = field.validate(); 32134 if (error) { 32135 errors[field.key] = error; 32136 } 32137 }); 32138 32139 //Get errors from default Backbone model validator 32140 if (!options.skipModelValidate && model && model.validate) { 32141 var modelErrors = model.validate(this.getValue()); 32142 32143 if (modelErrors) { 32144 var isDictionary = _.isObject(modelErrors) && !_.isArray(modelErrors); 32145 32146 //If errors are not in object form then just store on the error object 32147 if (!isDictionary) { 32148 errors._others = errors._others || []; 32149 errors._others.push(modelErrors); 32150 } 32151 32152 //Merge programmatic errors (requires model.validate() to return an object e.g. { fieldKey: 'error' }) 32153 if (isDictionary) { 32154 _.each(modelErrors, function(val, key) { 32155 //Set error on field if there isn't one already 32156 if (fields[key] && !errors[key]) { 32157 fields[key].setError(val); 32158 errors[key] = val; 32159 } 32160 32161 else { 32162 //Otherwise add to '_others' key 32163 errors._others = errors._others || []; 32164 var tmpErr = {}; 32165 tmpErr[key] = val; 32166 errors._others.push(tmpErr); 32167 } 32168 }); 32169 } 32170 } 32171 } 32172 32173 return _.isEmpty(errors) ? null : errors; 32174 }, 32175 32176 /** 32177 * Update the model with all latest values. 32178 * 32179 * @param {Object} [options] Options to pass to Model#set (e.g. { silent: true }) 32180 * 32181 * @return {Object} Validation errors 32182 */ 32183 commit: function(options) { 32184 //Validate 32185 options = options || {}; 32186 32187 var validateOptions = { 32188 skipModelValidate: !options.validate 32189 }; 32190 32191 var errors = this.validate(validateOptions); 32192 if (errors) return errors; 32193 32194 //Commit 32195 var modelError; 32196 32197 var setOptions = _.extend({ 32198 error: function(model, e) { 32199 modelError = e; 32200 } 32201 }, options); 32202 32203 this.model.set(this.getValue(), setOptions); 32204 32205 if (modelError) return modelError; 32206 }, 32207 32208 /** 32209 * Get all the field values as an object. 32210 * Use this method when passing data instead of objects 32211 * 32212 * @param {String} [key] Specific field value to get 32213 */ 32214 getValue: function(key) { 32215 //Return only given key if specified 32216 if (key) return this.fields[key].getValue(); 32217 32218 //Otherwise return entire form 32219 var values = {}; 32220 _.each(this.fields, function(field) { 32221 values[field.key] = field.getValue(); 32222 }); 32223 32224 return values; 32225 }, 32226 32227 /** 32228 * Update field values, referenced by key 32229 * 32230 * @param {Object|String} key New values to set, or property to set 32231 * @param val Value to set 32232 */ 32233 setValue: function(prop, val) { 32234 var data = {}; 32235 if (typeof prop === 'string') { 32236 data[prop] = val; 32237 } else { 32238 data = prop; 32239 } 32240 32241 var key; 32242 for (key in this.schema) { 32243 if (data[key] !== undefined) { 32244 this.fields[key].setValue(data[key]); 32245 } 32246 } 32247 }, 32248 32249 /** 32250 * Returns the editor for a given field key 32251 * 32252 * @param {String} key 32253 * 32254 * @return {Editor} 32255 */ 32256 getEditor: function(key) { 32257 var field = this.fields[key]; 32258 if (!field) throw new Error('Field not found: '+key); 32259 32260 return field.editor; 32261 }, 32262 32263 /** 32264 * Gives the first editor in the form focus 32265 */ 32266 focus: function() { 32267 if (this.hasFocus) return; 32268 32269 //Get the first field 32270 var fieldset = this.fieldsets[0], 32271 field = fieldset.getFieldAt(0); 32272 32273 if (!field) return; 32274 32275 //Set focus 32276 field.editor.focus(); 32277 }, 32278 32279 /** 32280 * Removes focus from the currently focused editor 32281 */ 32282 blur: function() { 32283 if (!this.hasFocus) return; 32284 32285 var focusedField = _.find(this.fields, function(field) { 32286 return field.editor.hasFocus; 32287 }); 32288 32289 if (focusedField) focusedField.editor.blur(); 32290 }, 32291 32292 /** 32293 * Manages the hasFocus property 32294 * 32295 * @param {String} event 32296 */ 32297 trigger: function(event) { 32298 if (event === 'focus') { 32299 this.hasFocus = true; 32300 } 32301 else if (event === 'blur') { 32302 this.hasFocus = false; 32303 } 32304 32305 return Backbone.View.prototype.trigger.apply(this, arguments); 32306 }, 32307 32308 /** 32309 * Override default remove function in order to remove embedded views 32310 * 32311 * TODO: If editors are included directly with data-editors="x", they need to be removed 32312 * May be best to use XView to manage adding/removing views 32313 */ 32314 remove: function() { 32315 _.each(this.fieldsets, function(fieldset) { 32316 fieldset.remove(); 32317 }); 32318 32319 _.each(this.fields, function(field) { 32320 field.remove(); 32321 }); 32322 32323 return Backbone.View.prototype.remove.apply(this, arguments); 32324 } 32325 32326 }, { 32327 32328 //STATICS 32329 template: _.template('\ 32330 <form>\ 32331 <div data-fieldsets></div>\ 32332 <% if (submitButton) { %>\ 32333 <button type="submit"><%= submitButton %></button>\ 32334 <% } %>\ 32335 </form>\ 32336 ', null, this.templateSettings), 32337 32338 templateSettings: { 32339 evaluate: /<%([\s\S]+?)%>/g, 32340 interpolate: /<%=([\s\S]+?)%>/g, 32341 escape: /<%-([\s\S]+?)%>/g 32342 }, 32343 32344 editors: {} 32345 32346 }); 32347 32348 32349 //================================================================================================== 32350 //VALIDATORS 32351 //================================================================================================== 32352 32353 Form.validators = (function() { 32354 32355 var validators = {}; 32356 32357 validators.errMessages = { 32358 required: 'Required', 32359 regexp: 'Invalid', 32360 number: 'Must be a number', 32361 email: 'Invalid email address', 32362 url: 'Invalid URL', 32363 match: _.template('Must match field "<%= field %>"', null, Form.templateSettings) 32364 }; 32365 32366 validators.required = function(options) { 32367 options = _.extend({ 32368 type: 'required', 32369 message: this.errMessages.required 32370 }, options); 32371 32372 return function required(value) { 32373 options.value = value; 32374 32375 var err = { 32376 type: options.type, 32377 message: _.isFunction(options.message) ? options.message(options) : options.message 32378 }; 32379 32380 if (value === null || value === undefined || value === false || value === '') return err; 32381 }; 32382 }; 32383 32384 validators.regexp = function(options) { 32385 if (!options.regexp) throw new Error('Missing required "regexp" option for "regexp" validator'); 32386 32387 options = _.extend({ 32388 type: 'regexp', 32389 match: true, 32390 message: this.errMessages.regexp 32391 }, options); 32392 32393 return function regexp(value) { 32394 options.value = value; 32395 32396 var err = { 32397 type: options.type, 32398 message: _.isFunction(options.message) ? options.message(options) : options.message 32399 }; 32400 32401 //Don't check empty values (add a 'required' validator for this) 32402 if (value === null || value === undefined || value === '') return; 32403 32404 //Create RegExp from string if it's valid 32405 if ('string' === typeof options.regexp) options.regexp = new RegExp(options.regexp, options.flags); 32406 32407 if ((options.match) ? !options.regexp.test(value) : options.regexp.test(value)) return err; 32408 }; 32409 }; 32410 32411 validators.number = function(options) { 32412 options = _.extend({ 32413 type: 'number', 32414 message: this.errMessages.number, 32415 regexp: /^[0-9]*\.?[0-9]*?$/ 32416 }, options); 32417 32418 return validators.regexp(options); 32419 }; 32420 32421 validators.email = function(options) { 32422 options = _.extend({ 32423 type: 'email', 32424 message: this.errMessages.email, 32425 regexp: /^[\w\-]{1,}([\w\-\+.]{1,1}[\w\-]{1,}){0,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/ 32426 }, options); 32427 32428 return validators.regexp(options); 32429 }; 32430 32431 validators.url = function(options) { 32432 options = _.extend({ 32433 type: 'url', 32434 message: this.errMessages.url, 32435 regexp: /^(http|https):\/\/(([A-Z0-9][A-Z0-9_\-]*)(\.[A-Z0-9][A-Z0-9_\-]*)+)(:(\d+))?\/?/i 32436 }, options); 32437 32438 return validators.regexp(options); 32439 }; 32440 32441 validators.match = function(options) { 32442 if (!options.field) throw new Error('Missing required "field" options for "match" validator'); 32443 32444 options = _.extend({ 32445 type: 'match', 32446 message: this.errMessages.match 32447 }, options); 32448 32449 return function match(value, attrs) { 32450 options.value = value; 32451 32452 var err = { 32453 type: options.type, 32454 message: _.isFunction(options.message) ? options.message(options) : options.message 32455 }; 32456 32457 //Don't check empty values (add a 'required' validator for this) 32458 if (value === null || value === undefined || value === '') return; 32459 32460 if (value !== attrs[options.field]) return err; 32461 }; 32462 }; 32463 32464 32465 return validators; 32466 32467 })(); 32468 32469 32470 //================================================================================================== 32471 //FIELDSET 32472 //================================================================================================== 32473 32474 Form.Fieldset = Backbone.View.extend({ 32475 32476 /** 32477 * Constructor 32478 * 32479 * Valid fieldset schemas: 32480 * ['field1', 'field2'] 32481 * { legend: 'Some Fieldset', fields: ['field1', 'field2'] } 32482 * 32483 * @param {String[]|Object[]} options.schema Fieldset schema 32484 * @param {Object} options.fields Form fields 32485 */ 32486 initialize: function(options) { 32487 options = options || {}; 32488 32489 //Create the full fieldset schema, merging defaults etc. 32490 var schema = this.schema = this.createSchema(options.schema); 32491 32492 //Store the fields for this fieldset 32493 this.fields = _.pick(options.fields, schema.fields); 32494 32495 //Override defaults 32496 this.template = options.template || schema.template || this.template || this.constructor.template; 32497 }, 32498 32499 /** 32500 * Creates the full fieldset schema, normalising, merging defaults etc. 32501 * 32502 * @param {String[]|Object[]} schema 32503 * 32504 * @return {Object} 32505 */ 32506 createSchema: function(schema) { 32507 //Normalise to object 32508 if (_.isArray(schema)) { 32509 schema = { fields: schema }; 32510 } 32511 32512 //Add null legend to prevent template error 32513 schema.legend = schema.legend || null; 32514 32515 return schema; 32516 }, 32517 32518 /** 32519 * Returns the field for a given index 32520 * 32521 * @param {Number} index 32522 * 32523 * @return {Field} 32524 */ 32525 getFieldAt: function(index) { 32526 var key = this.schema.fields[index]; 32527 32528 return this.fields[key]; 32529 }, 32530 32531 /** 32532 * Returns data to pass to template 32533 * 32534 * @return {Object} 32535 */ 32536 templateData: function() { 32537 return this.schema; 32538 }, 32539 32540 /** 32541 * Renders the fieldset and fields 32542 * 32543 * @return {Fieldset} this 32544 */ 32545 render: function() { 32546 var schema = this.schema, 32547 fields = this.fields, 32548 $ = Backbone.$; 32549 32550 //Render fieldset 32551 var $fieldset = $($.trim(this.template(_.result(this, 'templateData')))); 32552 32553 //Render fields 32554 $fieldset.find('[data-fields]').add($fieldset).each(function(i, el) { 32555 var $container = $(el), 32556 selection = $container.attr('data-fields'); 32557 32558 if (_.isUndefined(selection)) return; 32559 32560 _.each(fields, function(field) { 32561 $container.append(field.render().el); 32562 }); 32563 }); 32564 32565 this.setElement($fieldset); 32566 32567 return this; 32568 }, 32569 32570 /** 32571 * Remove embedded views then self 32572 */ 32573 remove: function() { 32574 _.each(this.fields, function(field) { 32575 field.remove(); 32576 }); 32577 32578 Backbone.View.prototype.remove.call(this); 32579 } 32580 32581 }, { 32582 //STATICS 32583 32584 template: _.template('\ 32585 <fieldset data-fields>\ 32586 <% if (legend) { %>\ 32587 <legend><%= legend %></legend>\ 32588 <% } %>\ 32589 </fieldset>\ 32590 ', null, Form.templateSettings) 32591 32592 }); 32593 32594 32595 //================================================================================================== 32596 //FIELD 32597 //================================================================================================== 32598 32599 Form.Field = Backbone.View.extend({ 32600 32601 /** 32602 * Constructor 32603 * 32604 * @param {Object} options.key 32605 * @param {Object} options.form 32606 * @param {Object} [options.schema] 32607 * @param {Function} [options.schema.template] 32608 * @param {Backbone.Model} [options.model] 32609 * @param {Object} [options.value] 32610 * @param {String} [options.idPrefix] 32611 * @param {Function} [options.template] 32612 * @param {Function} [options.errorClassName] 32613 */ 32614 initialize: function(options) { 32615 options = options || {}; 32616 32617 //Store important data 32618 _.extend(this, _.pick(options, 'form', 'key', 'model', 'value', 'idPrefix')); 32619 32620 //Create the full field schema, merging defaults etc. 32621 var schema = this.schema = this.createSchema(options.schema); 32622 32623 //Override defaults 32624 this.template = options.template || schema.template || this.template || this.constructor.template; 32625 this.errorClassName = options.errorClassName || this.errorClassName || this.constructor.errorClassName; 32626 32627 //Create editor 32628 this.editor = this.createEditor(); 32629 }, 32630 32631 /** 32632 * Creates the full field schema, merging defaults etc. 32633 * 32634 * @param {Object|String} schema 32635 * 32636 * @return {Object} 32637 */ 32638 createSchema: function(schema) { 32639 if (_.isString(schema)) schema = { type: schema }; 32640 32641 //Set defaults 32642 schema = _.extend({ 32643 type: 'Text', 32644 title: this.createTitle() 32645 }, schema); 32646 32647 //Get the real constructor function i.e. if type is a string such as 'Text' 32648 schema.type = (_.isString(schema.type)) ? Form.editors[schema.type] : schema.type; 32649 32650 return schema; 32651 }, 32652 32653 /** 32654 * Creates the editor specified in the schema; either an editor string name or 32655 * a constructor function 32656 * 32657 * @return {View} 32658 */ 32659 createEditor: function() { 32660 var options = _.extend( 32661 _.pick(this, 'schema', 'form', 'key', 'model', 'value'), 32662 { id: this.createEditorId() } 32663 ); 32664 32665 var constructorFn = this.schema.type; 32666 32667 return new constructorFn(options); 32668 }, 32669 32670 /** 32671 * Creates the ID that will be assigned to the editor 32672 * 32673 * @return {String} 32674 */ 32675 createEditorId: function() { 32676 var prefix = this.idPrefix, 32677 id = this.key; 32678 32679 //Replace periods with underscores (e.g. for when using paths) 32680 id = id.replace(/\./g, '_'); 32681 32682 //If a specific ID prefix is set, use it 32683 if (_.isString(prefix) || _.isNumber(prefix)) return prefix + id; 32684 if (_.isNull(prefix)) return id; 32685 32686 //Otherwise, if there is a model use it's CID to avoid conflicts when multiple forms are on the page 32687 if (this.model) return this.model.cid + '_' + id; 32688 32689 return id; 32690 }, 32691 32692 /** 32693 * Create the default field title (label text) from the key name. 32694 * (Converts 'camelCase' to 'Camel Case') 32695 * 32696 * @return {String} 32697 */ 32698 createTitle: function() { 32699 var str = this.key; 32700 32701 //Add spaces 32702 str = str.replace(/([A-Z])/g, ' $1'); 32703 32704 //Uppercase first character 32705 str = str.replace(/^./, function(str) { return str.toUpperCase(); }); 32706 32707 return str; 32708 }, 32709 32710 /** 32711 * Returns the data to be passed to the template 32712 * 32713 * @return {Object} 32714 */ 32715 templateData: function() { 32716 var schema = this.schema; 32717 32718 return { 32719 help: schema.help || '', 32720 title: schema.title, 32721 fieldAttrs: schema.fieldAttrs, 32722 editorAttrs: schema.editorAttrs, 32723 key: this.key, 32724 editorId: this.editor.id 32725 }; 32726 }, 32727 32728 /** 32729 * Render the field and editor 32730 * 32731 * @return {Field} self 32732 */ 32733 render: function() { 32734 var schema = this.schema, 32735 editor = this.editor, 32736 $ = Backbone.$; 32737 32738 //Only render the editor if Hidden 32739 if (schema.type == Form.editors.Hidden) { 32740 return this.setElement(editor.render().el); 32741 } 32742 32743 //Render field 32744 var $field = $($.trim(this.template(_.result(this, 'templateData')))); 32745 32746 if (schema.fieldClass) $field.addClass(schema.fieldClass); 32747 if (schema.fieldAttrs) $field.attr(schema.fieldAttrs); 32748 32749 //Render editor 32750 $field.find('[data-editor]').add($field).each(function(i, el) { 32751 var $container = $(el), 32752 selection = $container.attr('data-editor'); 32753 32754 if (_.isUndefined(selection)) return; 32755 32756 $container.append(editor.render().el); 32757 }); 32758 32759 this.setElement($field); 32760 32761 return this; 32762 }, 32763 32764 /** 32765 * Check the validity of the field 32766 * 32767 * @return {String} 32768 */ 32769 validate: function() { 32770 var error = this.editor.validate(); 32771 32772 if (error) { 32773 this.setError(error.message); 32774 } else { 32775 this.clearError(); 32776 } 32777 32778 return error; 32779 }, 32780 32781 /** 32782 * Set the field into an error state, adding the error class and setting the error message 32783 * 32784 * @param {String} msg Error message 32785 */ 32786 setError: function(msg) { 32787 //Nested form editors (e.g. Object) set their errors internally 32788 if (this.editor.hasNestedForm) return; 32789 32790 //Add error CSS class 32791 this.$el.addClass(this.errorClassName); 32792 32793 //Set error message 32794 this.$('[data-error]').html(msg); 32795 }, 32796 32797 /** 32798 * Clear the error state and reset the help message 32799 */ 32800 clearError: function() { 32801 //Remove error CSS class 32802 this.$el.removeClass(this.errorClassName); 32803 32804 //Clear error message 32805 this.$('[data-error]').empty(); 32806 }, 32807 32808 /** 32809 * Update the model with the new value from the editor 32810 * 32811 * @return {Mixed} 32812 */ 32813 commit: function() { 32814 return this.editor.commit(); 32815 }, 32816 32817 /** 32818 * Get the value from the editor 32819 * 32820 * @return {Mixed} 32821 */ 32822 getValue: function() { 32823 return this.editor.getValue(); 32824 }, 32825 32826 /** 32827 * Set/change the value of the editor 32828 * 32829 * @param {Mixed} value 32830 */ 32831 setValue: function(value) { 32832 this.editor.setValue(value); 32833 }, 32834 32835 /** 32836 * Give the editor focus 32837 */ 32838 focus: function() { 32839 this.editor.focus(); 32840 }, 32841 32842 /** 32843 * Remove focus from the editor 32844 */ 32845 blur: function() { 32846 this.editor.blur(); 32847 }, 32848 32849 /** 32850 * Remove the field and editor views 32851 */ 32852 remove: function() { 32853 this.editor.remove(); 32854 32855 Backbone.View.prototype.remove.call(this); 32856 } 32857 32858 }, { 32859 //STATICS 32860 32861 template: _.template('\ 32862 <div>\ 32863 <label for="<%= editorId %>"><%= title %></label>\ 32864 <div>\ 32865 <span data-editor></span>\ 32866 <div data-error></div>\ 32867 <div><%= help %></div>\ 32868 </div>\ 32869 </div>\ 32870 ', null, Form.templateSettings), 32871 32872 /** 32873 * CSS class name added to the field when there is a validation error 32874 */ 32875 errorClassName: 'error' 32876 32877 }); 32878 32879 32880 //================================================================================================== 32881 //NESTEDFIELD 32882 //================================================================================================== 32883 32884 Form.NestedField = Form.Field.extend({ 32885 32886 template: _.template('\ 32887 <div>\ 32888 <span data-editor></span>\ 32889 <% if (help) { %>\ 32890 <div><%= help %></div>\ 32891 <% } %>\ 32892 <div data-error></div>\ 32893 </div>\ 32894 ', null, Form.templateSettings) 32895 32896 }); 32897 32898 /** 32899 * Base editor (interface). To be extended, not used directly 32900 * 32901 * @param {Object} options 32902 * @param {String} [options.id] Editor ID 32903 * @param {Model} [options.model] Use instead of value, and use commit() 32904 * @param {String} [options.key] The model attribute key. Required when using 'model' 32905 * @param {Mixed} [options.value] When not using a model. If neither provided, defaultValue will be used 32906 * @param {Object} [options.schema] Field schema; may be required by some editors 32907 * @param {Object} [options.validators] Validators; falls back to those stored on schema 32908 * @param {Object} [options.form] The form 32909 */ 32910 Form.Editor = Form.editors.Base = Backbone.View.extend({ 32911 32912 defaultValue: null, 32913 32914 hasFocus: false, 32915 32916 initialize: function(options) { 32917 var options = options || {}; 32918 32919 //Set initial value 32920 if (options.model) { 32921 if (!options.key) throw new Error("Missing option: 'key'"); 32922 32923 this.model = options.model; 32924 32925 this.value = this.model.get(options.key); 32926 } 32927 else if (options.value !== undefined) { 32928 this.value = options.value; 32929 } 32930 32931 if (this.value === undefined) this.value = this.defaultValue; 32932 32933 //Store important data 32934 _.extend(this, _.pick(options, 'key', 'form')); 32935 32936 var schema = this.schema = options.schema || {}; 32937 32938 this.validators = options.validators || schema.validators; 32939 32940 //Main attributes 32941 this.$el.attr('id', this.id); 32942 this.$el.attr('name', this.getName()); 32943 if (schema.editorClass) this.$el.addClass(schema.editorClass); 32944 if (schema.editorAttrs) this.$el.attr(schema.editorAttrs); 32945 }, 32946 32947 /** 32948 * Get the value for the form input 'name' attribute 32949 * 32950 * @return {String} 32951 * 32952 * @api private 32953 */ 32954 getName: function() { 32955 var key = this.key || ''; 32956 32957 //Replace periods with underscores (e.g. for when using paths) 32958 return key.replace(/\./g, '_'); 32959 }, 32960 32961 /** 32962 * Get editor value 32963 * Extend and override this method to reflect changes in the DOM 32964 * 32965 * @return {Mixed} 32966 */ 32967 getValue: function() { 32968 return this.value; 32969 }, 32970 32971 /** 32972 * Set editor value 32973 * Extend and override this method to reflect changes in the DOM 32974 * 32975 * @param {Mixed} value 32976 */ 32977 setValue: function(value) { 32978 this.value = value; 32979 }, 32980 32981 /** 32982 * Give the editor focus 32983 * Extend and override this method 32984 */ 32985 focus: function() { 32986 throw new Error('Not implemented'); 32987 }, 32988 32989 /** 32990 * Remove focus from the editor 32991 * Extend and override this method 32992 */ 32993 blur: function() { 32994 throw new Error('Not implemented'); 32995 }, 32996 32997 /** 32998 * Update the model with the current value 32999 * 33000 * @param {Object} [options] Options to pass to model.set() 33001 * @param {Boolean} [options.validate] Set to true to trigger built-in model validation 33002 * 33003 * @return {Mixed} error 33004 */ 33005 commit: function(options) { 33006 var error = this.validate(); 33007 if (error) return error; 33008 33009 this.listenTo(this.model, 'invalid', function(model, e) { 33010 error = e; 33011 }); 33012 this.model.set(this.key, this.getValue(), options); 33013 33014 if (error) return error; 33015 }, 33016 33017 /** 33018 * Check validity 33019 * 33020 * @return {Object|Undefined} 33021 */ 33022 validate: function() { 33023 var $el = this.$el, 33024 error = null, 33025 value = this.getValue(), 33026 formValues = this.form ? this.form.getValue() : {}, 33027 validators = this.validators, 33028 getValidator = this.getValidator; 33029 33030 if (validators) { 33031 //Run through validators until an error is found 33032 _.every(validators, function(validator) { 33033 error = getValidator(validator)(value, formValues); 33034 33035 return error ? false : true; 33036 }); 33037 } 33038 33039 return error; 33040 }, 33041 33042 /** 33043 * Set this.hasFocus, or call parent trigger() 33044 * 33045 * @param {String} event 33046 */ 33047 trigger: function(event) { 33048 if (event === 'focus') { 33049 this.hasFocus = true; 33050 } 33051 else if (event === 'blur') { 33052 this.hasFocus = false; 33053 } 33054 33055 return Backbone.View.prototype.trigger.apply(this, arguments); 33056 }, 33057 33058 /** 33059 * Returns a validation function based on the type defined in the schema 33060 * 33061 * @param {RegExp|String|Function} validator 33062 * @return {Function} 33063 */ 33064 getValidator: function(validator) { 33065 var validators = Form.validators; 33066 33067 //Convert regular expressions to validators 33068 if (_.isRegExp(validator)) { 33069 return validators.regexp({ regexp: validator }); 33070 } 33071 33072 //Use a built-in validator if given a string 33073 if (_.isString(validator)) { 33074 if (!validators[validator]) throw new Error('Validator "'+validator+'" not found'); 33075 33076 return validators[validator](); 33077 } 33078 33079 //Functions can be used directly 33080 if (_.isFunction(validator)) return validator; 33081 33082 //Use a customised built-in validator if given an object 33083 if (_.isObject(validator) && validator.type) { 33084 var config = validator; 33085 33086 return validators[config.type](config); 33087 } 33088 33089 //Unkown validator type 33090 throw new Error('Invalid validator: ' + validator); 33091 } 33092 }); 33093 33094 /** 33095 * Text 33096 * 33097 * Text input with focus, blur and change events 33098 */ 33099 Form.editors.Text = Form.Editor.extend({ 33100 33101 tagName: 'input', 33102 33103 defaultValue: '', 33104 33105 previousValue: '', 33106 33107 events: { 33108 'keyup': 'determineChange', 33109 'keypress': function(event) { 33110 var self = this; 33111 setTimeout(function() { 33112 self.determineChange(); 33113 }, 0); 33114 }, 33115 'select': function(event) { 33116 this.trigger('select', this); 33117 }, 33118 'focus': function(event) { 33119 this.trigger('focus', this); 33120 }, 33121 'blur': function(event) { 33122 this.trigger('blur', this); 33123 } 33124 }, 33125 33126 initialize: function(options) { 33127 Form.editors.Base.prototype.initialize.call(this, options); 33128 33129 var schema = this.schema; 33130 33131 //Allow customising text type (email, phone etc.) for HTML5 browsers 33132 var type = 'text'; 33133 33134 if (schema && schema.editorAttrs && schema.editorAttrs.type) type = schema.editorAttrs.type; 33135 if (schema && schema.dataType) type = schema.dataType; 33136 33137 this.$el.attr('type', type); 33138 }, 33139 33140 /** 33141 * Adds the editor to the DOM 33142 */ 33143 render: function() { 33144 this.setValue(this.value); 33145 33146 return this; 33147 }, 33148 33149 determineChange: function(event) { 33150 var currentValue = this.$el.val(); 33151 var changed = (currentValue !== this.previousValue); 33152 33153 if (changed) { 33154 this.previousValue = currentValue; 33155 33156 this.trigger('change', this); 33157 } 33158 }, 33159 33160 /** 33161 * Returns the current editor value 33162 * @return {String} 33163 */ 33164 getValue: function() { 33165 return this.$el.val(); 33166 }, 33167 33168 /** 33169 * Sets the value of the form element 33170 * @param {String} 33171 */ 33172 setValue: function(value) { 33173 this.$el.val(value); 33174 }, 33175 33176 focus: function() { 33177 if (this.hasFocus) return; 33178 33179 this.$el.focus(); 33180 }, 33181 33182 blur: function() { 33183 if (!this.hasFocus) return; 33184 33185 this.$el.blur(); 33186 }, 33187 33188 select: function() { 33189 this.$el.select(); 33190 } 33191 33192 }); 33193 33194 /** 33195 * TextArea editor 33196 */ 33197 Form.editors.TextArea = Form.editors.Text.extend({ 33198 33199 tagName: 'textarea', 33200 33201 /** 33202 * Override Text constructor so type property isn't set (issue #261) 33203 */ 33204 initialize: function(options) { 33205 Form.editors.Base.prototype.initialize.call(this, options); 33206 } 33207 33208 }); 33209 33210 /** 33211 * Password editor 33212 */ 33213 Form.editors.Password = Form.editors.Text.extend({ 33214 33215 initialize: function(options) { 33216 Form.editors.Text.prototype.initialize.call(this, options); 33217 33218 this.$el.attr('type', 'password'); 33219 } 33220 33221 }); 33222 33223 /** 33224 * NUMBER 33225 * 33226 * Normal text input that only allows a number. Letters etc. are not entered. 33227 */ 33228 Form.editors.Number = Form.editors.Text.extend({ 33229 33230 defaultValue: 0, 33231 33232 events: _.extend({}, Form.editors.Text.prototype.events, { 33233 'keypress': 'onKeyPress', 33234 'change': 'onKeyPress' 33235 }), 33236 33237 initialize: function(options) { 33238 Form.editors.Text.prototype.initialize.call(this, options); 33239 33240 var schema = this.schema; 33241 33242 this.$el.attr('type', 'number'); 33243 33244 if (!schema || !schema.editorAttrs || !schema.editorAttrs.step) { 33245 // provide a default for `step` attr, 33246 // but don't overwrite if already specified 33247 this.$el.attr('step', 'any'); 33248 } 33249 }, 33250 33251 /** 33252 * Check value is numeric 33253 */ 33254 onKeyPress: function(event) { 33255 var self = this, 33256 delayedDetermineChange = function() { 33257 setTimeout(function() { 33258 self.determineChange(); 33259 }, 0); 33260 }; 33261 33262 //Allow backspace 33263 if (event.charCode === 0) { 33264 delayedDetermineChange(); 33265 return; 33266 } 33267 33268 //Get the whole new value so that we can prevent things like double decimals points etc. 33269 var newVal = this.$el.val() 33270 if( event.charCode != undefined ) { 33271 newVal = newVal + String.fromCharCode(event.charCode); 33272 } 33273 33274 var numeric = /^[0-9]*\.?[0-9]*?$/.test(newVal); 33275 33276 if (numeric) { 33277 delayedDetermineChange(); 33278 } 33279 else { 33280 event.preventDefault(); 33281 } 33282 }, 33283 33284 getValue: function() { 33285 var value = this.$el.val(); 33286 33287 return value === "" ? null : parseFloat(value, 10); 33288 }, 33289 33290 setValue: function(value) { 33291 value = (function() { 33292 if (_.isNumber(value)) return value; 33293 33294 if (_.isString(value) && value !== '') return parseFloat(value, 10); 33295 33296 return null; 33297 })(); 33298 33299 if (_.isNaN(value)) value = null; 33300 33301 Form.editors.Text.prototype.setValue.call(this, value); 33302 } 33303 33304 }); 33305 33306 /** 33307 * Hidden editor 33308 */ 33309 Form.editors.Hidden = Form.editors.Text.extend({ 33310 33311 defaultValue: '', 33312 33313 initialize: function(options) { 33314 Form.editors.Text.prototype.initialize.call(this, options); 33315 33316 this.$el.attr('type', 'hidden'); 33317 }, 33318 33319 focus: function() { 33320 33321 }, 33322 33323 blur: function() { 33324 33325 } 33326 33327 }); 33328 33329 /** 33330 * Checkbox editor 33331 * 33332 * Creates a single checkbox, i.e. boolean value 33333 */ 33334 Form.editors.Checkbox = Form.editors.Base.extend({ 33335 33336 defaultValue: false, 33337 33338 tagName: 'input', 33339 33340 events: { 33341 'click': function(event) { 33342 this.trigger('change', this); 33343 }, 33344 'focus': function(event) { 33345 this.trigger('focus', this); 33346 }, 33347 'blur': function(event) { 33348 this.trigger('blur', this); 33349 } 33350 }, 33351 33352 initialize: function(options) { 33353 Form.editors.Base.prototype.initialize.call(this, options); 33354 33355 this.$el.attr('type', 'checkbox'); 33356 }, 33357 33358 /** 33359 * Adds the editor to the DOM 33360 */ 33361 render: function() { 33362 this.setValue(this.value); 33363 33364 return this; 33365 }, 33366 33367 getValue: function() { 33368 return this.$el.prop('checked'); 33369 }, 33370 33371 setValue: function(value) { 33372 if (value) { 33373 this.$el.prop('checked', true); 33374 }else{ 33375 this.$el.prop('checked', false); 33376 } 33377 }, 33378 33379 focus: function() { 33380 if (this.hasFocus) return; 33381 33382 this.$el.focus(); 33383 }, 33384 33385 blur: function() { 33386 if (!this.hasFocus) return; 33387 33388 this.$el.blur(); 33389 } 33390 33391 }); 33392 33393 /** 33394 * Select editor 33395 * 33396 * Renders a <select> with given options 33397 * 33398 * Requires an 'options' value on the schema. 33399 * Can be an array of options, a function that calls back with the array of options, a string of HTML 33400 * or a Backbone collection. If a collection, the models must implement a toString() method 33401 */ 33402 Form.editors.Select = Form.editors.Base.extend({ 33403 33404 tagName: 'select', 33405 33406 previousValue: '', 33407 33408 events: { 33409 'keyup': 'determineChange', 33410 'keypress': function(event) { 33411 var self = this; 33412 setTimeout(function() { 33413 self.determineChange(); 33414 }, 0); 33415 }, 33416 'change': function(event) { 33417 this.trigger('change', this); 33418 }, 33419 'focus': function(event) { 33420 this.trigger('focus', this); 33421 }, 33422 'blur': function(event) { 33423 this.trigger('blur', this); 33424 } 33425 }, 33426 33427 initialize: function(options) { 33428 Form.editors.Base.prototype.initialize.call(this, options); 33429 33430 if (!this.schema || !this.schema.options) throw new Error("Missing required 'schema.options'"); 33431 }, 33432 33433 render: function() { 33434 this.setOptions(this.schema.options); 33435 33436 return this; 33437 }, 33438 33439 /** 33440 * Sets the options that populate the <select> 33441 * 33442 * @param {Mixed} options 33443 */ 33444 setOptions: function(options) { 33445 var self = this; 33446 33447 //If a collection was passed, check if it needs fetching 33448 if (options instanceof Backbone.Collection) { 33449 var collection = options; 33450 33451 //Don't do the fetch if it's already populated 33452 if (collection.length > 0) { 33453 this.renderOptions(options); 33454 } else { 33455 collection.fetch({ 33456 success: function(collection) { 33457 self.renderOptions(options); 33458 } 33459 }); 33460 } 33461 } 33462 33463 //If a function was passed, run it to get the options 33464 else if (_.isFunction(options)) { 33465 options(function(result) { 33466 self.renderOptions(result); 33467 }, self); 33468 } 33469 33470 //Otherwise, ready to go straight to renderOptions 33471 else { 33472 this.renderOptions(options); 33473 } 33474 }, 33475 33476 /** 33477 * Adds the <option> html to the DOM 33478 * @param {Mixed} Options as a simple array e.g. ['option1', 'option2'] 33479 * or as an array of objects e.g. [{val: 543, label: 'Title for object 543'}] 33480 * or as a string of <option> HTML to insert into the <select> 33481 * or any object 33482 */ 33483 renderOptions: function(options) { 33484 var $select = this.$el, 33485 html; 33486 33487 html = this._getOptionsHtml(options); 33488 33489 //Insert options 33490 $select.html(html); 33491 33492 //Select correct option 33493 this.setValue(this.value); 33494 }, 33495 33496 _getOptionsHtml: function(options) { 33497 var html; 33498 //Accept string of HTML 33499 if (_.isString(options)) { 33500 html = options; 33501 } 33502 33503 //Or array 33504 else if (_.isArray(options)) { 33505 html = this._arrayToHtml(options); 33506 } 33507 33508 //Or Backbone collection 33509 else if (options instanceof Backbone.Collection) { 33510 html = this._collectionToHtml(options); 33511 } 33512 33513 else if (_.isFunction(options)) { 33514 var newOptions; 33515 33516 options(function(opts) { 33517 newOptions = opts; 33518 }, this); 33519 33520 html = this._getOptionsHtml(newOptions); 33521 //Or any object 33522 }else{ 33523 html=this._objectToHtml(options); 33524 } 33525 33526 return html; 33527 }, 33528 33529 determineChange: function(event) { 33530 var currentValue = this.getValue(); 33531 var changed = (currentValue !== this.previousValue); 33532 33533 if (changed) { 33534 this.previousValue = currentValue; 33535 33536 this.trigger('change', this); 33537 } 33538 }, 33539 33540 getValue: function() { 33541 return this.$el.val(); 33542 }, 33543 33544 setValue: function(value) { 33545 this.$el.val(value); 33546 }, 33547 33548 focus: function() { 33549 if (this.hasFocus) return; 33550 33551 this.$el.focus(); 33552 }, 33553 33554 blur: function() { 33555 if (!this.hasFocus) return; 33556 33557 this.$el.blur(); 33558 }, 33559 33560 /** 33561 * Transforms a collection into HTML ready to use in the renderOptions method 33562 * @param {Backbone.Collection} 33563 * @return {String} 33564 */ 33565 _collectionToHtml: function(collection) { 33566 //Convert collection to array first 33567 var array = []; 33568 collection.each(function(model) { 33569 array.push({ val: model.id, label: model.toString() }); 33570 }); 33571 33572 //Now convert to HTML 33573 var html = this._arrayToHtml(array); 33574 33575 return html; 33576 }, 33577 /** 33578 * Transforms an object into HTML ready to use in the renderOptions method 33579 * @param {Object} 33580 * @return {String} 33581 */ 33582 _objectToHtml: function(obj) { 33583 //Convert object to array first 33584 var array = []; 33585 for(var key in obj){ 33586 if( obj.hasOwnProperty( key ) ) { 33587 array.push({ val: key, label: obj[key] }); 33588 } 33589 } 33590 33591 //Now convert to HTML 33592 var html = this._arrayToHtml(array); 33593 33594 return html; 33595 }, 33596 33597 33598 33599 /** 33600 * Create the <option> HTML 33601 * @param {Array} Options as a simple array e.g. ['option1', 'option2'] 33602 * or as an array of objects e.g. [{val: 543, label: 'Title for object 543'}] 33603 * @return {String} HTML 33604 */ 33605 _arrayToHtml: function(array) { 33606 var html = []; 33607 33608 //Generate HTML 33609 _.each(array, function(option) { 33610 if (_.isObject(option)) { 33611 if (option.group) { 33612 html.push('<optgroup label="'+option.group+'">'); 33613 html.push(this._getOptionsHtml(option.options)) 33614 html.push('</optgroup>'); 33615 } else { 33616 var val = (option.val || option.val === 0) ? option.val : ''; 33617 html.push('<option value="'+val+'">'+option.label+'</option>'); 33618 } 33619 } 33620 else { 33621 html.push('<option>'+option+'</option>'); 33622 } 33623 }, this); 33624 33625 return html.join(''); 33626 } 33627 33628 }); 33629 33630 /** 33631 * Radio editor 33632 * 33633 * Renders a <ul> with given options represented as <li> objects containing radio buttons 33634 * 33635 * Requires an 'options' value on the schema. 33636 * Can be an array of options, a function that calls back with the array of options, a string of HTML 33637 * or a Backbone collection. If a collection, the models must implement a toString() method 33638 */ 33639 Form.editors.Radio = Form.editors.Select.extend({ 33640 33641 tagName: 'ul', 33642 33643 events: { 33644 'change input[type=radio]': function() { 33645 this.trigger('change', this); 33646 }, 33647 'focus input[type=radio]': function() { 33648 if (this.hasFocus) return; 33649 this.trigger('focus', this); 33650 }, 33651 'blur input[type=radio]': function() { 33652 if (!this.hasFocus) return; 33653 var self = this; 33654 setTimeout(function() { 33655 if (self.$('input[type=radio]:focus')[0]) return; 33656 self.trigger('blur', self); 33657 }, 0); 33658 } 33659 }, 33660 33661 /** 33662 * Returns the template. Override for custom templates 33663 * 33664 * @return {Function} Compiled template 33665 */ 33666 getTemplate: function() { 33667 return this.schema.template || this.constructor.template; 33668 }, 33669 33670 getValue: function() { 33671 return this.$('input[type=radio]:checked').val(); 33672 }, 33673 33674 setValue: function(value) { 33675 this.$('input[type=radio]').val([value]); 33676 }, 33677 33678 focus: function() { 33679 if (this.hasFocus) return; 33680 33681 var checked = this.$('input[type=radio]:checked'); 33682 if (checked[0]) { 33683 checked.focus(); 33684 return; 33685 } 33686 33687 this.$('input[type=radio]').first().focus(); 33688 }, 33689 33690 blur: function() { 33691 if (!this.hasFocus) return; 33692 33693 this.$('input[type=radio]:focus').blur(); 33694 }, 33695 33696 /** 33697 * Create the radio list HTML 33698 * @param {Array} Options as a simple array e.g. ['option1', 'option2'] 33699 * or as an array of objects e.g. [{val: 543, label: 'Title for object 543'}] 33700 * @return {String} HTML 33701 */ 33702 _arrayToHtml: function (array) { 33703 var self = this; 33704 33705 var template = this.getTemplate(), 33706 name = self.getName(), 33707 id = self.id; 33708 33709 var items = _.map(array, function(option, index) { 33710 var item = { 33711 name: name, 33712 id: id + '-' + index 33713 } 33714 33715 if (_.isObject(option)) { 33716 item.value = (option.val || option.val === 0) ? option.val : ''; 33717 item.label = option.label; 33718 } else { 33719 item.value = option; 33720 item.label = option; 33721 } 33722 33723 return item; 33724 }); 33725 33726 return template({ items: items }); 33727 } 33728 33729 }, { 33730 33731 //STATICS 33732 template: _.template('\ 33733 <% _.each(items, function(item) { %>\ 33734 <li>\ 33735 <input type="radio" name="<%= item.name %>" value="<%= item.value %>" id="<%= item.id %>" />\ 33736 <label for="<%= item.id %>"><%= item.label %></label>\ 33737 </li>\ 33738 <% }); %>\ 33739 ', null, Form.templateSettings) 33740 33741 }); 33742 33743 /** 33744 * Checkboxes editor 33745 * 33746 * Renders a <ul> with given options represented as <li> objects containing checkboxes 33747 * 33748 * Requires an 'options' value on the schema. 33749 * Can be an array of options, a function that calls back with the array of options, a string of HTML 33750 * or a Backbone collection. If a collection, the models must implement a toString() method 33751 */ 33752 Form.editors.Checkboxes = Form.editors.Select.extend({ 33753 33754 tagName: 'ul', 33755 33756 groupNumber: 0, 33757 33758 events: { 33759 'click input[type=checkbox]': function() { 33760 this.trigger('change', this); 33761 }, 33762 'focus input[type=checkbox]': function() { 33763 if (this.hasFocus) return; 33764 this.trigger('focus', this); 33765 }, 33766 'blur input[type=checkbox]': function() { 33767 if (!this.hasFocus) return; 33768 var self = this; 33769 setTimeout(function() { 33770 if (self.$('input[type=checkbox]:focus')[0]) return; 33771 self.trigger('blur', self); 33772 }, 0); 33773 } 33774 }, 33775 33776 getValue: function() { 33777 var values = []; 33778 this.$('input[type=checkbox]:checked').each(function() { 33779 values.push($(this).val()); 33780 }); 33781 return values; 33782 }, 33783 33784 setValue: function(values) { 33785 if (!_.isArray(values)) values = [values]; 33786 this.$('input[type=checkbox]').val(values); 33787 }, 33788 33789 focus: function() { 33790 if (this.hasFocus) return; 33791 33792 this.$('input[type=checkbox]').first().focus(); 33793 }, 33794 33795 blur: function() { 33796 if (!this.hasFocus) return; 33797 33798 this.$('input[type=checkbox]:focus').blur(); 33799 }, 33800 33801 /** 33802 * Create the checkbox list HTML 33803 * @param {Array} Options as a simple array e.g. ['option1', 'option2'] 33804 * or as an array of objects e.g. [{val: 543, label: 'Title for object 543'}] 33805 * @return {String} HTML 33806 */ 33807 _arrayToHtml: function (array) { 33808 var html = []; 33809 var self = this; 33810 33811 _.each(array, function(option, index) { 33812 var itemHtml = '<li>'; 33813 var close = true; 33814 if (_.isObject(option)) { 33815 if (option.group) { 33816 var originalId = self.id; 33817 self.id += "-" + self.groupNumber++; 33818 itemHtml = ('<fieldset class="group"> <legend>'+option.group+'</legend>'); 33819 itemHtml += (self._arrayToHtml(option.options)); 33820 itemHtml += ('</fieldset>'); 33821 self.id = originalId; 33822 close = false; 33823 }else{ 33824 var val = (option.val || option.val === 0) ? option.val : ''; 33825 itemHtml += ('<input type="checkbox" name="'+self.getName()+'" value="'+val+'" id="'+self.id+'-'+index+'" />'); 33826 itemHtml += ('<label for="'+self.id+'-'+index+'">'+option.label+'</label>'); 33827 } 33828 } 33829 else { 33830 itemHtml += ('<input type="checkbox" name="'+self.getName()+'" value="'+option+'" id="'+self.id+'-'+index+'" />'); 33831 itemHtml += ('<label for="'+self.id+'-'+index+'">'+option+'</label>'); 33832 } 33833 if(close){ 33834 itemHtml += '</li>'; 33835 } 33836 html.push(itemHtml); 33837 }); 33838 33839 return html.join(''); 33840 } 33841 33842 }); 33843 33844 /** 33845 * Object editor 33846 * 33847 * Creates a child form. For editing Javascript objects 33848 * 33849 * @param {Object} options 33850 * @param {Form} options.form The form this editor belongs to; used to determine the constructor for the nested form 33851 * @param {Object} options.schema The schema for the object 33852 * @param {Object} options.schema.subSchema The schema for the nested form 33853 */ 33854 Form.editors.Object = Form.editors.Base.extend({ 33855 //Prevent error classes being set on the main control; they are internally on the individual fields 33856 hasNestedForm: true, 33857 33858 initialize: function(options) { 33859 //Set default value for the instance so it's not a shared object 33860 this.value = {}; 33861 33862 //Init 33863 Form.editors.Base.prototype.initialize.call(this, options); 33864 33865 //Check required options 33866 if (!this.form) throw new Error('Missing required option "form"'); 33867 if (!this.schema.subSchema) throw new Error("Missing required 'schema.subSchema' option for Object editor"); 33868 }, 33869 33870 render: function() { 33871 //Get the constructor for creating the nested form; i.e. the same constructor as used by the parent form 33872 var NestedForm = this.form.constructor; 33873 33874 //Create the nested form 33875 this.nestedForm = new NestedForm({ 33876 schema: this.schema.subSchema, 33877 data: this.value, 33878 idPrefix: this.id + '_', 33879 Field: NestedForm.NestedField 33880 }); 33881 33882 this._observeFormEvents(); 33883 33884 this.$el.html(this.nestedForm.render().el); 33885 33886 if (this.hasFocus) this.trigger('blur', this); 33887 33888 return this; 33889 }, 33890 33891 getValue: function() { 33892 if (this.nestedForm) return this.nestedForm.getValue(); 33893 33894 return this.value; 33895 }, 33896 33897 setValue: function(value) { 33898 this.value = value; 33899 33900 this.render(); 33901 }, 33902 33903 focus: function() { 33904 if (this.hasFocus) return; 33905 33906 this.nestedForm.focus(); 33907 }, 33908 33909 blur: function() { 33910 if (!this.hasFocus) return; 33911 33912 this.nestedForm.blur(); 33913 }, 33914 33915 remove: function() { 33916 this.nestedForm.remove(); 33917 33918 Backbone.View.prototype.remove.call(this); 33919 }, 33920 33921 validate: function() { 33922 return this.nestedForm.validate(); 33923 }, 33924 33925 _observeFormEvents: function() { 33926 if (!this.nestedForm) return; 33927 33928 this.nestedForm.on('all', function() { 33929 // args = ["key:change", form, fieldEditor] 33930 var args = _.toArray(arguments); 33931 args[1] = this; 33932 // args = ["key:change", this=objectEditor, fieldEditor] 33933 33934 this.trigger.apply(this, args); 33935 }, this); 33936 } 33937 33938 }); 33939 33940 /** 33941 * NestedModel editor 33942 * 33943 * Creates a child form. For editing nested Backbone models 33944 * 33945 * Special options: 33946 * schema.model: Embedded model constructor 33947 */ 33948 Form.editors.NestedModel = Form.editors.Object.extend({ 33949 initialize: function(options) { 33950 Form.editors.Base.prototype.initialize.call(this, options); 33951 33952 if (!this.form) throw new Error('Missing required option "form"'); 33953 if (!options.schema.model) throw new Error('Missing required "schema.model" option for NestedModel editor'); 33954 }, 33955 33956 render: function() { 33957 //Get the constructor for creating the nested form; i.e. the same constructor as used by the parent form 33958 var NestedForm = this.form.constructor; 33959 33960 var data = this.value || {}, 33961 key = this.key, 33962 nestedModel = this.schema.model; 33963 33964 //Wrap the data in a model if it isn't already a model instance 33965 var modelInstance = (data.constructor === nestedModel) ? data : new nestedModel(data); 33966 33967 this.nestedForm = new NestedForm({ 33968 model: modelInstance, 33969 idPrefix: this.id + '_', 33970 fieldTemplate: 'nestedField' 33971 }); 33972 33973 this._observeFormEvents(); 33974 33975 //Render form 33976 this.$el.html(this.nestedForm.render().el); 33977 33978 if (this.hasFocus) this.trigger('blur', this); 33979 33980 return this; 33981 }, 33982 33983 /** 33984 * Update the embedded model, checking for nested validation errors and pass them up 33985 * Then update the main model if all OK 33986 * 33987 * @return {Error|null} Validation error or null 33988 */ 33989 commit: function() { 33990 var error = this.nestedForm.commit(); 33991 if (error) { 33992 this.$el.addClass('error'); 33993 return error; 33994 } 33995 33996 return Form.editors.Object.prototype.commit.call(this); 33997 } 33998 33999 }); 34000 34001 /** 34002 * Date editor 34003 * 34004 * Schema options 34005 * @param {Number|String} [options.schema.yearStart] First year in list. Default: 100 years ago 34006 * @param {Number|String} [options.schema.yearEnd] Last year in list. Default: current year 34007 * 34008 * Config options (if not set, defaults to options stored on the main Date class) 34009 * @param {Boolean} [options.showMonthNames] Use month names instead of numbers. Default: true 34010 * @param {String[]} [options.monthNames] Month names. Default: Full English names 34011 */ 34012 Form.editors.Date = Form.editors.Base.extend({ 34013 34014 events: { 34015 'change select': function() { 34016 this.updateHidden(); 34017 this.trigger('change', this); 34018 }, 34019 'focus select': function() { 34020 if (this.hasFocus) return; 34021 this.trigger('focus', this); 34022 }, 34023 'blur select': function() { 34024 if (!this.hasFocus) return; 34025 var self = this; 34026 setTimeout(function() { 34027 if (self.$('select:focus')[0]) return; 34028 self.trigger('blur', self); 34029 }, 0); 34030 } 34031 }, 34032 34033 initialize: function(options) { 34034 options = options || {}; 34035 34036 Form.editors.Base.prototype.initialize.call(this, options); 34037 34038 var Self = Form.editors.Date, 34039 today = new Date(); 34040 34041 //Option defaults 34042 this.options = _.extend({ 34043 monthNames: Self.monthNames, 34044 showMonthNames: Self.showMonthNames 34045 }, options); 34046 34047 //Schema defaults 34048 this.schema = _.extend({ 34049 yearStart: today.getFullYear() - 100, 34050 yearEnd: today.getFullYear() 34051 }, options.schema || {}); 34052 34053 //Cast to Date 34054 if (this.value && !_.isDate(this.value)) { 34055 this.value = new Date(this.value); 34056 } 34057 34058 //Set default date 34059 if (!this.value) { 34060 var date = new Date(); 34061 date.setSeconds(0); 34062 date.setMilliseconds(0); 34063 34064 this.value = date; 34065 } 34066 34067 //Template 34068 this.template = options.template || this.constructor.template; 34069 }, 34070 34071 render: function() { 34072 var options = this.options, 34073 schema = this.schema, 34074 $ = Backbone.$; 34075 34076 var datesOptions = _.map(_.range(1, 32), function(date) { 34077 return '<option value="'+date+'">' + date + '</option>'; 34078 }); 34079 34080 var monthsOptions = _.map(_.range(0, 12), function(month) { 34081 var value = (options.showMonthNames) 34082 ? options.monthNames[month] 34083 : (month + 1); 34084 34085 return '<option value="'+month+'">' + value + '</option>'; 34086 }); 34087 34088 var yearRange = (schema.yearStart < schema.yearEnd) 34089 ? _.range(schema.yearStart, schema.yearEnd + 1) 34090 : _.range(schema.yearStart, schema.yearEnd - 1, -1); 34091 34092 var yearsOptions = _.map(yearRange, function(year) { 34093 return '<option value="'+year+'">' + year + '</option>'; 34094 }); 34095 34096 //Render the selects 34097 var $el = $($.trim(this.template({ 34098 dates: datesOptions.join(''), 34099 months: monthsOptions.join(''), 34100 years: yearsOptions.join('') 34101 }))); 34102 34103 //Store references to selects 34104 this.$date = $el.find('[data-type="date"]'); 34105 this.$month = $el.find('[data-type="month"]'); 34106 this.$year = $el.find('[data-type="year"]'); 34107 34108 //Create the hidden field to store values in case POSTed to server 34109 this.$hidden = $('<input type="hidden" name="'+this.key+'" />'); 34110 $el.append(this.$hidden); 34111 34112 //Set value on this and hidden field 34113 this.setValue(this.value); 34114 34115 //Remove the wrapper tag 34116 this.setElement($el); 34117 this.$el.attr('id', this.id); 34118 this.$el.attr('name', this.getName()); 34119 34120 if (this.hasFocus) this.trigger('blur', this); 34121 34122 return this; 34123 }, 34124 34125 /** 34126 * @return {Date} Selected date 34127 */ 34128 getValue: function() { 34129 var year = this.$year.val(), 34130 month = this.$month.val(), 34131 date = this.$date.val(); 34132 34133 if (!year || !month || !date) return null; 34134 34135 return new Date(year, month, date); 34136 }, 34137 34138 /** 34139 * @param {Date} date 34140 */ 34141 setValue: function(date) { 34142 this.$date.val(date.getDate()); 34143 this.$month.val(date.getMonth()); 34144 this.$year.val(date.getFullYear()); 34145 34146 this.updateHidden(); 34147 }, 34148 34149 focus: function() { 34150 if (this.hasFocus) return; 34151 34152 this.$('select').first().focus(); 34153 }, 34154 34155 blur: function() { 34156 if (!this.hasFocus) return; 34157 34158 this.$('select:focus').blur(); 34159 }, 34160 34161 /** 34162 * Update the hidden input which is maintained for when submitting a form 34163 * via a normal browser POST 34164 */ 34165 updateHidden: function() { 34166 var val = this.getValue(); 34167 34168 if (_.isDate(val)) val = val.toISOString(); 34169 34170 this.$hidden.val(val); 34171 } 34172 34173 }, { 34174 //STATICS 34175 template: _.template('\ 34176 <div>\ 34177 <select data-type="date"><%= dates %></select>\ 34178 <select data-type="month"><%= months %></select>\ 34179 <select data-type="year"><%= years %></select>\ 34180 </div>\ 34181 ', null, Form.templateSettings), 34182 34183 //Whether to show month names instead of numbers 34184 showMonthNames: true, 34185 34186 //Month names to use if showMonthNames is true 34187 //Replace for localisation, e.g. Form.editors.Date.monthNames = ['Janvier', 'Fevrier'...] 34188 monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] 34189 }); 34190 34191 /** 34192 * DateTime editor 34193 * 34194 * @param {Editor} [options.DateEditor] Date editor view to use (not definition) 34195 * @param {Number} [options.schema.minsInterval] Interval between minutes. Default: 15 34196 */ 34197 Form.editors.DateTime = Form.editors.Base.extend({ 34198 34199 events: { 34200 'change select': function() { 34201 this.updateHidden(); 34202 this.trigger('change', this); 34203 }, 34204 'focus select': function() { 34205 if (this.hasFocus) return; 34206 this.trigger('focus', this); 34207 }, 34208 'blur select': function() { 34209 if (!this.hasFocus) return; 34210 var self = this; 34211 setTimeout(function() { 34212 if (self.$('select:focus')[0]) return; 34213 self.trigger('blur', self); 34214 }, 0); 34215 } 34216 }, 34217 34218 initialize: function(options) { 34219 options = options || {}; 34220 34221 Form.editors.Base.prototype.initialize.call(this, options); 34222 34223 //Option defaults 34224 this.options = _.extend({ 34225 DateEditor: Form.editors.DateTime.DateEditor 34226 }, options); 34227 34228 //Schema defaults 34229 this.schema = _.extend({ 34230 minsInterval: 15 34231 }, options.schema || {}); 34232 34233 //Create embedded date editor 34234 this.dateEditor = new this.options.DateEditor(options); 34235 34236 this.value = this.dateEditor.value; 34237 34238 //Template 34239 this.template = options.template || this.constructor.template; 34240 }, 34241 34242 render: function() { 34243 function pad(n) { 34244 return n < 10 ? '0' + n : n; 34245 } 34246 34247 var schema = this.schema, 34248 $ = Backbone.$; 34249 34250 //Create options 34251 var hoursOptions = _.map(_.range(0, 24), function(hour) { 34252 return '<option value="'+hour+'">' + pad(hour) + '</option>'; 34253 }); 34254 34255 var minsOptions = _.map(_.range(0, 60, schema.minsInterval), function(min) { 34256 return '<option value="'+min+'">' + pad(min) + '</option>'; 34257 }); 34258 34259 //Render time selects 34260 var $el = $($.trim(this.template({ 34261 hours: hoursOptions.join(), 34262 mins: minsOptions.join() 34263 }))); 34264 34265 //Include the date editor 34266 $el.find('[data-date]').append(this.dateEditor.render().el); 34267 34268 //Store references to selects 34269 this.$hour = $el.find('select[data-type="hour"]'); 34270 this.$min = $el.find('select[data-type="min"]'); 34271 34272 //Get the hidden date field to store values in case POSTed to server 34273 this.$hidden = $el.find('input[type="hidden"]'); 34274 34275 //Set time 34276 this.setValue(this.value); 34277 34278 this.setElement($el); 34279 this.$el.attr('id', this.id); 34280 this.$el.attr('name', this.getName()); 34281 34282 if (this.hasFocus) this.trigger('blur', this); 34283 34284 return this; 34285 }, 34286 34287 /** 34288 * @return {Date} Selected datetime 34289 */ 34290 getValue: function() { 34291 var date = this.dateEditor.getValue(); 34292 34293 var hour = this.$hour.val(), 34294 min = this.$min.val(); 34295 34296 if (!date || !hour || !min) return null; 34297 34298 date.setHours(hour); 34299 date.setMinutes(min); 34300 34301 return date; 34302 }, 34303 34304 /** 34305 * @param {Date} 34306 */ 34307 setValue: function(date) { 34308 if (!_.isDate(date)) date = new Date(date); 34309 34310 this.dateEditor.setValue(date); 34311 34312 this.$hour.val(date.getHours()); 34313 this.$min.val(date.getMinutes()); 34314 34315 this.updateHidden(); 34316 }, 34317 34318 focus: function() { 34319 if (this.hasFocus) return; 34320 34321 this.$('select').first().focus(); 34322 }, 34323 34324 blur: function() { 34325 if (!this.hasFocus) return; 34326 34327 this.$('select:focus').blur(); 34328 }, 34329 34330 /** 34331 * Update the hidden input which is maintained for when submitting a form 34332 * via a normal browser POST 34333 */ 34334 updateHidden: function() { 34335 var val = this.getValue(); 34336 if (_.isDate(val)) val = val.toISOString(); 34337 34338 this.$hidden.val(val); 34339 }, 34340 34341 /** 34342 * Remove the Date editor before removing self 34343 */ 34344 remove: function() { 34345 this.dateEditor.remove(); 34346 34347 Form.editors.Base.prototype.remove.call(this); 34348 } 34349 34350 }, { 34351 //STATICS 34352 template: _.template('\ 34353 <div class="bbf-datetime">\ 34354 <div class="bbf-date-container" data-date></div>\ 34355 <select data-type="hour"><%= hours %></select>\ 34356 :\ 34357 <select data-type="min"><%= mins %></select>\ 34358 </div>\ 34359 ', null, Form.templateSettings), 34360 34361 //The date editor to use (constructor function, not instance) 34362 DateEditor: Form.editors.Date 34363 }); 34364 34365 34366 34367 //Metadata 34368 Form.VERSION = '0.14.1'; 34369 34370 34371 //Exports 34372 Backbone.Form = Form; 34373 if (true) module.exports = Form; 34374 34375 })(window || global || this); 34376 34377 /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(71))) 34378 34379 /***/ }, 34380 /* 165 */ 34381 /***/ function(module, exports, __webpack_require__) { 34382 34383 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Backbone.js 1.1.2 34384 34385 // (c) 2010-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 34386 // Backbone may be freely distributed under the MIT license. 34387 // For all details and documentation: 34388 // http://backbonejs.org 34389 34390 (function(root, factory) { 34391 34392 // Set up Backbone appropriately for the environment. Start with AMD. 34393 if (true) { 34394 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(114), __webpack_require__(71), exports], __WEBPACK_AMD_DEFINE_RESULT__ = function(_, $, exports) { 34395 // Export global even in AMD case in case this script is loaded with 34396 // others that may still expect a global Backbone. 34397 root.Backbone = factory(root, exports, _, $); 34398 }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 34399 34400 // Next for Node.js or CommonJS. jQuery may not be needed as a module. 34401 } else if (typeof exports !== 'undefined') { 34402 var _ = require('underscore'); 34403 factory(root, exports, _); 34404 34405 // Finally, as a browser global. 34406 } else { 34407 root.Backbone = factory(root, {}, root._, (root.jQuery || root.Zepto || root.ender || root.$)); 34408 } 34409 34410 }(this, function(root, Backbone, _, $) { 34411 34412 // Initial Setup 34413 // ------------- 34414 34415 // Save the previous value of the `Backbone` variable, so that it can be 34416 // restored later on, if `noConflict` is used. 34417 var previousBackbone = root.Backbone; 34418 34419 // Create local references to array methods we'll want to use later. 34420 var array = []; 34421 var push = array.push; 34422 var slice = array.slice; 34423 var splice = array.splice; 34424 34425 // Current version of the library. Keep in sync with `package.json`. 34426 Backbone.VERSION = '1.1.2'; 34427 34428 // For Backbone's purposes, jQuery, Zepto, Ender, or My Library (kidding) owns 34429 // the `$` variable. 34430 Backbone.$ = $; 34431 34432 // Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable 34433 // to its previous owner. Returns a reference to this Backbone object. 34434 Backbone.noConflict = function() { 34435 root.Backbone = previousBackbone; 34436 return this; 34437 }; 34438 34439 // Turn on `emulateHTTP` to support legacy HTTP servers. Setting this option 34440 // will fake `"PATCH"`, `"PUT"` and `"DELETE"` requests via the `_method` parameter and 34441 // set a `X-Http-Method-Override` header. 34442 Backbone.emulateHTTP = false; 34443 34444 // Turn on `emulateJSON` to support legacy servers that can't deal with direct 34445 // `application/json` requests ... will encode the body as 34446 // `application/x-www-form-urlencoded` instead and will send the model in a 34447 // form param named `model`. 34448 Backbone.emulateJSON = false; 34449 34450 // Backbone.Events 34451 // --------------- 34452 34453 // A module that can be mixed in to *any object* in order to provide it with 34454 // custom events. You may bind with `on` or remove with `off` callback 34455 // functions to an event; `trigger`-ing an event fires all callbacks in 34456 // succession. 34457 // 34458 // var object = {}; 34459 // _.extend(object, Backbone.Events); 34460 // object.on('expand', function(){ alert('expanded'); }); 34461 // object.trigger('expand'); 34462 // 34463 var Events = Backbone.Events = { 34464 34465 // Bind an event to a `callback` function. Passing `"all"` will bind 34466 // the callback to all events fired. 34467 on: function(name, callback, context) { 34468 if (!eventsApi(this, 'on', name, [callback, context]) || !callback) return this; 34469 this._events || (this._events = {}); 34470 var events = this._events[name] || (this._events[name] = []); 34471 events.push({callback: callback, context: context, ctx: context || this}); 34472 return this; 34473 }, 34474 34475 // Bind an event to only be triggered a single time. After the first time 34476 // the callback is invoked, it will be removed. 34477 once: function(name, callback, context) { 34478 if (!eventsApi(this, 'once', name, [callback, context]) || !callback) return this; 34479 var self = this; 34480 var once = _.once(function() { 34481 self.off(name, once); 34482 callback.apply(this, arguments); 34483 }); 34484 once._callback = callback; 34485 return this.on(name, once, context); 34486 }, 34487 34488 // Remove one or many callbacks. If `context` is null, removes all 34489 // callbacks with that function. If `callback` is null, removes all 34490 // callbacks for the event. If `name` is null, removes all bound 34491 // callbacks for all events. 34492 off: function(name, callback, context) { 34493 var retain, ev, events, names, i, l, j, k; 34494 if (!this._events || !eventsApi(this, 'off', name, [callback, context])) return this; 34495 if (!name && !callback && !context) { 34496 this._events = void 0; 34497 return this; 34498 } 34499 names = name ? [name] : _.keys(this._events); 34500 for (i = 0, l = names.length; i < l; i++) { 34501 name = names[i]; 34502 if (events = this._events[name]) { 34503 this._events[name] = retain = []; 34504 if (callback || context) { 34505 for (j = 0, k = events.length; j < k; j++) { 34506 ev = events[j]; 34507 if ((callback && callback !== ev.callback && callback !== ev.callback._callback) || 34508 (context && context !== ev.context)) { 34509 retain.push(ev); 34510 } 34511 } 34512 } 34513 if (!retain.length) delete this._events[name]; 34514 } 34515 } 34516 34517 return this; 34518 }, 34519 34520 // Trigger one or many events, firing all bound callbacks. Callbacks are 34521 // passed the same arguments as `trigger` is, apart from the event name 34522 // (unless you're listening on `"all"`, which will cause your callback to 34523 // receive the true name of the event as the first argument). 34524 trigger: function(name) { 34525 if (!this._events) return this; 34526 var args = slice.call(arguments, 1); 34527 if (!eventsApi(this, 'trigger', name, args)) return this; 34528 var events = this._events[name]; 34529 var allEvents = this._events.all; 34530 if (events) triggerEvents(events, args); 34531 if (allEvents) triggerEvents(allEvents, arguments); 34532 return this; 34533 }, 34534 34535 // Tell this object to stop listening to either specific events ... or 34536 // to every object it's currently listening to. 34537 stopListening: function(obj, name, callback) { 34538 var listeningTo = this._listeningTo; 34539 if (!listeningTo) return this; 34540 var remove = !name && !callback; 34541 if (!callback && typeof name === 'object') callback = this; 34542 if (obj) (listeningTo = {})[obj._listenId] = obj; 34543 for (var id in listeningTo) { 34544 obj = listeningTo[id]; 34545 obj.off(name, callback, this); 34546 if (remove || _.isEmpty(obj._events)) delete this._listeningTo[id]; 34547 } 34548 return this; 34549 } 34550 34551 }; 34552 34553 // Regular expression used to split event strings. 34554 var eventSplitter = /\s+/; 34555 34556 // Implement fancy features of the Events API such as multiple event 34557 // names `"change blur"` and jQuery-style event maps `{change: action}` 34558 // in terms of the existing API. 34559 var eventsApi = function(obj, action, name, rest) { 34560 if (!name) return true; 34561 34562 // Handle event maps. 34563 if (typeof name === 'object') { 34564 for (var key in name) { 34565 obj[action].apply(obj, [key, name[key]].concat(rest)); 34566 } 34567 return false; 34568 } 34569 34570 // Handle space separated event names. 34571 if (eventSplitter.test(name)) { 34572 var names = name.split(eventSplitter); 34573 for (var i = 0, l = names.length; i < l; i++) { 34574 obj[action].apply(obj, [names[i]].concat(rest)); 34575 } 34576 return false; 34577 } 34578 34579 return true; 34580 }; 34581 34582 // A difficult-to-believe, but optimized internal dispatch function for 34583 // triggering events. Tries to keep the usual cases speedy (most internal 34584 // Backbone events have 3 arguments). 34585 var triggerEvents = function(events, args) { 34586 var ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2]; 34587 switch (args.length) { 34588 case 0: while (++i < l) (ev = events[i]).callback.call(ev.ctx); return; 34589 case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1); return; 34590 case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2); return; 34591 case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3); return; 34592 default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args); return; 34593 } 34594 }; 34595 34596 var listenMethods = {listenTo: 'on', listenToOnce: 'once'}; 34597 34598 // Inversion-of-control versions of `on` and `once`. Tell *this* object to 34599 // listen to an event in another object ... keeping track of what it's 34600 // listening to. 34601 _.each(listenMethods, function(implementation, method) { 34602 Events[method] = function(obj, name, callback) { 34603 var listeningTo = this._listeningTo || (this._listeningTo = {}); 34604 var id = obj._listenId || (obj._listenId = _.uniqueId('l')); 34605 listeningTo[id] = obj; 34606 if (!callback && typeof name === 'object') callback = this; 34607 obj[implementation](name, callback, this); 34608 return this; 34609 }; 34610 }); 34611 34612 // Aliases for backwards compatibility. 34613 Events.bind = Events.on; 34614 Events.unbind = Events.off; 34615 34616 // Allow the `Backbone` object to serve as a global event bus, for folks who 34617 // want global "pubsub" in a convenient place. 34618 _.extend(Backbone, Events); 34619 34620 // Backbone.Model 34621 // -------------- 34622 34623 // Backbone **Models** are the basic data object in the framework -- 34624 // frequently representing a row in a table in a database on your server. 34625 // A discrete chunk of data and a bunch of useful, related methods for 34626 // performing computations and transformations on that data. 34627 34628 // Create a new model with the specified attributes. A client id (`cid`) 34629 // is automatically generated and assigned for you. 34630 var Model = Backbone.Model = function(attributes, options) { 34631 var attrs = attributes || {}; 34632 options || (options = {}); 34633 this.cid = _.uniqueId('c'); 34634 this.attributes = {}; 34635 if (options.collection) this.collection = options.collection; 34636 if (options.parse) attrs = this.parse(attrs, options) || {}; 34637 attrs = _.defaults({}, attrs, _.result(this, 'defaults')); 34638 this.set(attrs, options); 34639 this.changed = {}; 34640 this.initialize.apply(this, arguments); 34641 }; 34642 34643 // Attach all inheritable methods to the Model prototype. 34644 _.extend(Model.prototype, Events, { 34645 34646 // A hash of attributes whose current and previous value differ. 34647 changed: null, 34648 34649 // The value returned during the last failed validation. 34650 validationError: null, 34651 34652 // The default name for the JSON `id` attribute is `"id"`. MongoDB and 34653 // CouchDB users may want to set this to `"_id"`. 34654 idAttribute: 'id', 34655 34656 // Initialize is an empty function by default. Override it with your own 34657 // initialization logic. 34658 initialize: function(){}, 34659 34660 // Return a copy of the model's `attributes` object. 34661 toJSON: function(options) { 34662 return _.clone(this.attributes); 34663 }, 34664 34665 // Proxy `Backbone.sync` by default -- but override this if you need 34666 // custom syncing semantics for *this* particular model. 34667 sync: function() { 34668 return Backbone.sync.apply(this, arguments); 34669 }, 34670 34671 // Get the value of an attribute. 34672 get: function(attr) { 34673 return this.attributes[attr]; 34674 }, 34675 34676 // Get the HTML-escaped value of an attribute. 34677 escape: function(attr) { 34678 return _.escape(this.get(attr)); 34679 }, 34680 34681 // Returns `true` if the attribute contains a value that is not null 34682 // or undefined. 34683 has: function(attr) { 34684 return this.get(attr) != null; 34685 }, 34686 34687 // Set a hash of model attributes on the object, firing `"change"`. This is 34688 // the core primitive operation of a model, updating the data and notifying 34689 // anyone who needs to know about the change in state. The heart of the beast. 34690 set: function(key, val, options) { 34691 var attr, attrs, unset, changes, silent, changing, prev, current; 34692 if (key == null) return this; 34693 34694 // Handle both `"key", value` and `{key: value}` -style arguments. 34695 if (typeof key === 'object') { 34696 attrs = key; 34697 options = val; 34698 } else { 34699 (attrs = {})[key] = val; 34700 } 34701 34702 options || (options = {}); 34703 34704 // Run validation. 34705 if (!this._validate(attrs, options)) return false; 34706 34707 // Extract attributes and options. 34708 unset = options.unset; 34709 silent = options.silent; 34710 changes = []; 34711 changing = this._changing; 34712 this._changing = true; 34713 34714 if (!changing) { 34715 this._previousAttributes = _.clone(this.attributes); 34716 this.changed = {}; 34717 } 34718 current = this.attributes, prev = this._previousAttributes; 34719 34720 // Check for changes of `id`. 34721 if (this.idAttribute in attrs) this.id = attrs[this.idAttribute]; 34722 34723 // For each `set` attribute, update or delete the current value. 34724 for (attr in attrs) { 34725 val = attrs[attr]; 34726 if (!_.isEqual(current[attr], val)) changes.push(attr); 34727 if (!_.isEqual(prev[attr], val)) { 34728 this.changed[attr] = val; 34729 } else { 34730 delete this.changed[attr]; 34731 } 34732 unset ? delete current[attr] : current[attr] = val; 34733 } 34734 34735 // Trigger all relevant attribute changes. 34736 if (!silent) { 34737 if (changes.length) this._pending = options; 34738 for (var i = 0, l = changes.length; i < l; i++) { 34739 this.trigger('change:' + changes[i], this, current[changes[i]], options); 34740 } 34741 } 34742 34743 // You might be wondering why there's a `while` loop here. Changes can 34744 // be recursively nested within `"change"` events. 34745 if (changing) return this; 34746 if (!silent) { 34747 while (this._pending) { 34748 options = this._pending; 34749 this._pending = false; 34750 this.trigger('change', this, options); 34751 } 34752 } 34753 this._pending = false; 34754 this._changing = false; 34755 return this; 34756 }, 34757 34758 // Remove an attribute from the model, firing `"change"`. `unset` is a noop 34759 // if the attribute doesn't exist. 34760 unset: function(attr, options) { 34761 return this.set(attr, void 0, _.extend({}, options, {unset: true})); 34762 }, 34763 34764 // Clear all attributes on the model, firing `"change"`. 34765 clear: function(options) { 34766 var attrs = {}; 34767 for (var key in this.attributes) attrs[key] = void 0; 34768 return this.set(attrs, _.extend({}, options, {unset: true})); 34769 }, 34770 34771 // Determine if the model has changed since the last `"change"` event. 34772 // If you specify an attribute name, determine if that attribute has changed. 34773 hasChanged: function(attr) { 34774 if (attr == null) return !_.isEmpty(this.changed); 34775 return _.has(this.changed, attr); 34776 }, 34777 34778 // Return an object containing all the attributes that have changed, or 34779 // false if there are no changed attributes. Useful for determining what 34780 // parts of a view need to be updated and/or what attributes need to be 34781 // persisted to the server. Unset attributes will be set to undefined. 34782 // You can also pass an attributes object to diff against the model, 34783 // determining if there *would be* a change. 34784 changedAttributes: function(diff) { 34785 if (!diff) return this.hasChanged() ? _.clone(this.changed) : false; 34786 var val, changed = false; 34787 var old = this._changing ? this._previousAttributes : this.attributes; 34788 for (var attr in diff) { 34789 if (_.isEqual(old[attr], (val = diff[attr]))) continue; 34790 (changed || (changed = {}))[attr] = val; 34791 } 34792 return changed; 34793 }, 34794 34795 // Get the previous value of an attribute, recorded at the time the last 34796 // `"change"` event was fired. 34797 previous: function(attr) { 34798 if (attr == null || !this._previousAttributes) return null; 34799 return this._previousAttributes[attr]; 34800 }, 34801 34802 // Get all of the attributes of the model at the time of the previous 34803 // `"change"` event. 34804 previousAttributes: function() { 34805 return _.clone(this._previousAttributes); 34806 }, 34807 34808 // Fetch the model from the server. If the server's representation of the 34809 // model differs from its current attributes, they will be overridden, 34810 // triggering a `"change"` event. 34811 fetch: function(options) { 34812 options = options ? _.clone(options) : {}; 34813 if (options.parse === void 0) options.parse = true; 34814 var model = this; 34815 var success = options.success; 34816 options.success = function(resp) { 34817 if (!model.set(model.parse(resp, options), options)) return false; 34818 if (success) success(model, resp, options); 34819 model.trigger('sync', model, resp, options); 34820 }; 34821 wrapError(this, options); 34822 return this.sync('read', this, options); 34823 }, 34824 34825 // Set a hash of model attributes, and sync the model to the server. 34826 // If the server returns an attributes hash that differs, the model's 34827 // state will be `set` again. 34828 save: function(key, val, options) { 34829 var attrs, method, xhr, attributes = this.attributes; 34830 34831 // Handle both `"key", value` and `{key: value}` -style arguments. 34832 if (key == null || typeof key === 'object') { 34833 attrs = key; 34834 options = val; 34835 } else { 34836 (attrs = {})[key] = val; 34837 } 34838 34839 options = _.extend({validate: true}, options); 34840 34841 // If we're not waiting and attributes exist, save acts as 34842 // `set(attr).save(null, opts)` with validation. Otherwise, check if 34843 // the model will be valid when the attributes, if any, are set. 34844 if (attrs && !options.wait) { 34845 if (!this.set(attrs, options)) return false; 34846 } else { 34847 if (!this._validate(attrs, options)) return false; 34848 } 34849 34850 // Set temporary attributes if `{wait: true}`. 34851 if (attrs && options.wait) { 34852 this.attributes = _.extend({}, attributes, attrs); 34853 } 34854 34855 // After a successful server-side save, the client is (optionally) 34856 // updated with the server-side state. 34857 if (options.parse === void 0) options.parse = true; 34858 var model = this; 34859 var success = options.success; 34860 options.success = function(resp) { 34861 // Ensure attributes are restored during synchronous saves. 34862 model.attributes = attributes; 34863 var serverAttrs = model.parse(resp, options); 34864 if (options.wait) serverAttrs = _.extend(attrs || {}, serverAttrs); 34865 if (_.isObject(serverAttrs) && !model.set(serverAttrs, options)) { 34866 return false; 34867 } 34868 if (success) success(model, resp, options); 34869 model.trigger('sync', model, resp, options); 34870 }; 34871 wrapError(this, options); 34872 34873 method = this.isNew() ? 'create' : (options.patch ? 'patch' : 'update'); 34874 if (method === 'patch') options.attrs = attrs; 34875 xhr = this.sync(method, this, options); 34876 34877 // Restore attributes. 34878 if (attrs && options.wait) this.attributes = attributes; 34879 34880 return xhr; 34881 }, 34882 34883 // Destroy this model on the server if it was already persisted. 34884 // Optimistically removes the model from its collection, if it has one. 34885 // If `wait: true` is passed, waits for the server to respond before removal. 34886 destroy: function(options) { 34887 options = options ? _.clone(options) : {}; 34888 var model = this; 34889 var success = options.success; 34890 34891 var destroy = function() { 34892 model.trigger('destroy', model, model.collection, options); 34893 }; 34894 34895 options.success = function(resp) { 34896 if (options.wait || model.isNew()) destroy(); 34897 if (success) success(model, resp, options); 34898 if (!model.isNew()) model.trigger('sync', model, resp, options); 34899 }; 34900 34901 if (this.isNew()) { 34902 options.success(); 34903 return false; 34904 } 34905 wrapError(this, options); 34906 34907 var xhr = this.sync('delete', this, options); 34908 if (!options.wait) destroy(); 34909 return xhr; 34910 }, 34911 34912 // Default URL for the model's representation on the server -- if you're 34913 // using Backbone's restful methods, override this to change the endpoint 34914 // that will be called. 34915 url: function() { 34916 var base = 34917 _.result(this, 'urlRoot') || 34918 _.result(this.collection, 'url') || 34919 urlError(); 34920 if (this.isNew()) return base; 34921 return base.replace(/([^\/])$/, '$1/') + encodeURIComponent(this.id); 34922 }, 34923 34924 // **parse** converts a response into the hash of attributes to be `set` on 34925 // the model. The default implementation is just to pass the response along. 34926 parse: function(resp, options) { 34927 return resp; 34928 }, 34929 34930 // Create a new model with identical attributes to this one. 34931 clone: function() { 34932 return new this.constructor(this.attributes); 34933 }, 34934 34935 // A model is new if it has never been saved to the server, and lacks an id. 34936 isNew: function() { 34937 return !this.has(this.idAttribute); 34938 }, 34939 34940 // Check if the model is currently in a valid state. 34941 isValid: function(options) { 34942 return this._validate({}, _.extend(options || {}, { validate: true })); 34943 }, 34944 34945 // Run validation against the next complete set of model attributes, 34946 // returning `true` if all is well. Otherwise, fire an `"invalid"` event. 34947 _validate: function(attrs, options) { 34948 if (!options.validate || !this.validate) return true; 34949 attrs = _.extend({}, this.attributes, attrs); 34950 var error = this.validationError = this.validate(attrs, options) || null; 34951 if (!error) return true; 34952 this.trigger('invalid', this, error, _.extend(options, {validationError: error})); 34953 return false; 34954 } 34955 34956 }); 34957 34958 // Underscore methods that we want to implement on the Model. 34959 var modelMethods = ['keys', 'values', 'pairs', 'invert', 'pick', 'omit']; 34960 34961 // Mix in each Underscore method as a proxy to `Model#attributes`. 34962 _.each(modelMethods, function(method) { 34963 Model.prototype[method] = function() { 34964 var args = slice.call(arguments); 34965 args.unshift(this.attributes); 34966 return _[method].apply(_, args); 34967 }; 34968 }); 34969 34970 // Backbone.Collection 34971 // ------------------- 34972 34973 // If models tend to represent a single row of data, a Backbone Collection is 34974 // more analagous to a table full of data ... or a small slice or page of that 34975 // table, or a collection of rows that belong together for a particular reason 34976 // -- all of the messages in this particular folder, all of the documents 34977 // belonging to this particular author, and so on. Collections maintain 34978 // indexes of their models, both in order, and for lookup by `id`. 34979 34980 // Create a new **Collection**, perhaps to contain a specific type of `model`. 34981 // If a `comparator` is specified, the Collection will maintain 34982 // its models in sort order, as they're added and removed. 34983 var Collection = Backbone.Collection = function(models, options) { 34984 options || (options = {}); 34985 if (options.model) this.model = options.model; 34986 if (options.comparator !== void 0) this.comparator = options.comparator; 34987 this._reset(); 34988 this.initialize.apply(this, arguments); 34989 if (models) this.reset(models, _.extend({silent: true}, options)); 34990 }; 34991 34992 // Default options for `Collection#set`. 34993 var setOptions = {add: true, remove: true, merge: true}; 34994 var addOptions = {add: true, remove: false}; 34995 34996 // Define the Collection's inheritable methods. 34997 _.extend(Collection.prototype, Events, { 34998 34999 // The default model for a collection is just a **Backbone.Model**. 35000 // This should be overridden in most cases. 35001 model: Model, 35002 35003 // Initialize is an empty function by default. Override it with your own 35004 // initialization logic. 35005 initialize: function(){}, 35006 35007 // The JSON representation of a Collection is an array of the 35008 // models' attributes. 35009 toJSON: function(options) { 35010 return this.map(function(model){ return model.toJSON(options); }); 35011 }, 35012 35013 // Proxy `Backbone.sync` by default. 35014 sync: function() { 35015 return Backbone.sync.apply(this, arguments); 35016 }, 35017 35018 // Add a model, or list of models to the set. 35019 add: function(models, options) { 35020 return this.set(models, _.extend({merge: false}, options, addOptions)); 35021 }, 35022 35023 // Remove a model, or a list of models from the set. 35024 remove: function(models, options) { 35025 var singular = !_.isArray(models); 35026 models = singular ? [models] : _.clone(models); 35027 options || (options = {}); 35028 var i, l, index, model; 35029 for (i = 0, l = models.length; i < l; i++) { 35030 model = models[i] = this.get(models[i]); 35031 if (!model) continue; 35032 delete this._byId[model.id]; 35033 delete this._byId[model.cid]; 35034 index = this.indexOf(model); 35035 this.models.splice(index, 1); 35036 this.length--; 35037 if (!options.silent) { 35038 options.index = index; 35039 model.trigger('remove', model, this, options); 35040 } 35041 this._removeReference(model, options); 35042 } 35043 return singular ? models[0] : models; 35044 }, 35045 35046 // Update a collection by `set`-ing a new list of models, adding new ones, 35047 // removing models that are no longer present, and merging models that 35048 // already exist in the collection, as necessary. Similar to **Model#set**, 35049 // the core operation for updating the data contained by the collection. 35050 set: function(models, options) { 35051 options = _.defaults({}, options, setOptions); 35052 if (options.parse) models = this.parse(models, options); 35053 var singular = !_.isArray(models); 35054 models = singular ? (models ? [models] : []) : _.clone(models); 35055 var i, l, id, model, attrs, existing, sort; 35056 var at = options.at; 35057 var targetModel = this.model; 35058 var sortable = this.comparator && (at == null) && options.sort !== false; 35059 var sortAttr = _.isString(this.comparator) ? this.comparator : null; 35060 var toAdd = [], toRemove = [], modelMap = {}; 35061 var add = options.add, merge = options.merge, remove = options.remove; 35062 var order = !sortable && add && remove ? [] : false; 35063 35064 // Turn bare objects into model references, and prevent invalid models 35065 // from being added. 35066 for (i = 0, l = models.length; i < l; i++) { 35067 attrs = models[i] || {}; 35068 if (attrs instanceof Model) { 35069 id = model = attrs; 35070 } else { 35071 id = attrs[targetModel.prototype.idAttribute || 'id']; 35072 } 35073 35074 // If a duplicate is found, prevent it from being added and 35075 // optionally merge it into the existing model. 35076 if (existing = this.get(id)) { 35077 if (remove) modelMap[existing.cid] = true; 35078 if (merge) { 35079 attrs = attrs === model ? model.attributes : attrs; 35080 if (options.parse) attrs = existing.parse(attrs, options); 35081 existing.set(attrs, options); 35082 if (sortable && !sort && existing.hasChanged(sortAttr)) sort = true; 35083 } 35084 models[i] = existing; 35085 35086 // If this is a new, valid model, push it to the `toAdd` list. 35087 } else if (add) { 35088 model = models[i] = this._prepareModel(attrs, options); 35089 if (!model) continue; 35090 toAdd.push(model); 35091 this._addReference(model, options); 35092 } 35093 35094 // Do not add multiple models with the same `id`. 35095 model = existing || model; 35096 if (order && (model.isNew() || !modelMap[model.id])) order.push(model); 35097 modelMap[model.id] = true; 35098 } 35099 35100 // Remove nonexistent models if appropriate. 35101 if (remove) { 35102 for (i = 0, l = this.length; i < l; ++i) { 35103 if (!modelMap[(model = this.models[i]).cid]) toRemove.push(model); 35104 } 35105 if (toRemove.length) this.remove(toRemove, options); 35106 } 35107 35108 // See if sorting is needed, update `length` and splice in new models. 35109 if (toAdd.length || (order && order.length)) { 35110 if (sortable) sort = true; 35111 this.length += toAdd.length; 35112 if (at != null) { 35113 for (i = 0, l = toAdd.length; i < l; i++) { 35114 this.models.splice(at + i, 0, toAdd[i]); 35115 } 35116 } else { 35117 if (order) this.models.length = 0; 35118 var orderedModels = order || toAdd; 35119 for (i = 0, l = orderedModels.length; i < l; i++) { 35120 this.models.push(orderedModels[i]); 35121 } 35122 } 35123 } 35124 35125 // Silently sort the collection if appropriate. 35126 if (sort) this.sort({silent: true}); 35127 35128 // Unless silenced, it's time to fire all appropriate add/sort events. 35129 if (!options.silent) { 35130 for (i = 0, l = toAdd.length; i < l; i++) { 35131 (model = toAdd[i]).trigger('add', model, this, options); 35132 } 35133 if (sort || (order && order.length)) this.trigger('sort', this, options); 35134 } 35135 35136 // Return the added (or merged) model (or models). 35137 return singular ? models[0] : models; 35138 }, 35139 35140 // When you have more items than you want to add or remove individually, 35141 // you can reset the entire set with a new list of models, without firing 35142 // any granular `add` or `remove` events. Fires `reset` when finished. 35143 // Useful for bulk operations and optimizations. 35144 reset: function(models, options) { 35145 options || (options = {}); 35146 for (var i = 0, l = this.models.length; i < l; i++) { 35147 this._removeReference(this.models[i], options); 35148 } 35149 options.previousModels = this.models; 35150 this._reset(); 35151 models = this.add(models, _.extend({silent: true}, options)); 35152 if (!options.silent) this.trigger('reset', this, options); 35153 return models; 35154 }, 35155 35156 // Add a model to the end of the collection. 35157 push: function(model, options) { 35158 return this.add(model, _.extend({at: this.length}, options)); 35159 }, 35160 35161 // Remove a model from the end of the collection. 35162 pop: function(options) { 35163 var model = this.at(this.length - 1); 35164 this.remove(model, options); 35165 return model; 35166 }, 35167 35168 // Add a model to the beginning of the collection. 35169 unshift: function(model, options) { 35170 return this.add(model, _.extend({at: 0}, options)); 35171 }, 35172 35173 // Remove a model from the beginning of the collection. 35174 shift: function(options) { 35175 var model = this.at(0); 35176 this.remove(model, options); 35177 return model; 35178 }, 35179 35180 // Slice out a sub-array of models from the collection. 35181 slice: function() { 35182 return slice.apply(this.models, arguments); 35183 }, 35184 35185 // Get a model from the set by id. 35186 get: function(obj) { 35187 if (obj == null) return void 0; 35188 return this._byId[obj] || this._byId[obj.id] || this._byId[obj.cid]; 35189 }, 35190 35191 // Get the model at the given index. 35192 at: function(index) { 35193 return this.models[index]; 35194 }, 35195 35196 // Return models with matching attributes. Useful for simple cases of 35197 // `filter`. 35198 where: function(attrs, first) { 35199 if (_.isEmpty(attrs)) return first ? void 0 : []; 35200 return this[first ? 'find' : 'filter'](function(model) { 35201 for (var key in attrs) { 35202 if (attrs[key] !== model.get(key)) return false; 35203 } 35204 return true; 35205 }); 35206 }, 35207 35208 // Return the first model with matching attributes. Useful for simple cases 35209 // of `find`. 35210 findWhere: function(attrs) { 35211 return this.where(attrs, true); 35212 }, 35213 35214 // Force the collection to re-sort itself. You don't need to call this under 35215 // normal circumstances, as the set will maintain sort order as each item 35216 // is added. 35217 sort: function(options) { 35218 if (!this.comparator) throw new Error('Cannot sort a set without a comparator'); 35219 options || (options = {}); 35220 35221 // Run sort based on type of `comparator`. 35222 if (_.isString(this.comparator) || this.comparator.length === 1) { 35223 this.models = this.sortBy(this.comparator, this); 35224 } else { 35225 this.models.sort(_.bind(this.comparator, this)); 35226 } 35227 35228 if (!options.silent) this.trigger('sort', this, options); 35229 return this; 35230 }, 35231 35232 // Pluck an attribute from each model in the collection. 35233 pluck: function(attr) { 35234 return _.invoke(this.models, 'get', attr); 35235 }, 35236 35237 // Fetch the default set of models for this collection, resetting the 35238 // collection when they arrive. If `reset: true` is passed, the response 35239 // data will be passed through the `reset` method instead of `set`. 35240 fetch: function(options) { 35241 options = options ? _.clone(options) : {}; 35242 if (options.parse === void 0) options.parse = true; 35243 var success = options.success; 35244 var collection = this; 35245 options.success = function(resp) { 35246 var method = options.reset ? 'reset' : 'set'; 35247 collection[method](resp, options); 35248 if (success) success(collection, resp, options); 35249 collection.trigger('sync', collection, resp, options); 35250 }; 35251 wrapError(this, options); 35252 return this.sync('read', this, options); 35253 }, 35254 35255 // Create a new instance of a model in this collection. Add the model to the 35256 // collection immediately, unless `wait: true` is passed, in which case we 35257 // wait for the server to agree. 35258 create: function(model, options) { 35259 options = options ? _.clone(options) : {}; 35260 if (!(model = this._prepareModel(model, options))) return false; 35261 if (!options.wait) this.add(model, options); 35262 var collection = this; 35263 var success = options.success; 35264 options.success = function(model, resp) { 35265 if (options.wait) collection.add(model, options); 35266 if (success) success(model, resp, options); 35267 }; 35268 model.save(null, options); 35269 return model; 35270 }, 35271 35272 // **parse** converts a response into a list of models to be added to the 35273 // collection. The default implementation is just to pass it through. 35274 parse: function(resp, options) { 35275 return resp; 35276 }, 35277 35278 // Create a new collection with an identical list of models as this one. 35279 clone: function() { 35280 return new this.constructor(this.models); 35281 }, 35282 35283 // Private method to reset all internal state. Called when the collection 35284 // is first initialized or reset. 35285 _reset: function() { 35286 this.length = 0; 35287 this.models = []; 35288 this._byId = {}; 35289 }, 35290 35291 // Prepare a hash of attributes (or other model) to be added to this 35292 // collection. 35293 _prepareModel: function(attrs, options) { 35294 if (attrs instanceof Model) return attrs; 35295 options = options ? _.clone(options) : {}; 35296 options.collection = this; 35297 var model = new this.model(attrs, options); 35298 if (!model.validationError) return model; 35299 this.trigger('invalid', this, model.validationError, options); 35300 return false; 35301 }, 35302 35303 // Internal method to create a model's ties to a collection. 35304 _addReference: function(model, options) { 35305 this._byId[model.cid] = model; 35306 if (model.id != null) this._byId[model.id] = model; 35307 if (!model.collection) model.collection = this; 35308 model.on('all', this._onModelEvent, this); 35309 }, 35310 35311 // Internal method to sever a model's ties to a collection. 35312 _removeReference: function(model, options) { 35313 if (this === model.collection) delete model.collection; 35314 model.off('all', this._onModelEvent, this); 35315 }, 35316 35317 // Internal method called every time a model in the set fires an event. 35318 // Sets need to update their indexes when models change ids. All other 35319 // events simply proxy through. "add" and "remove" events that originate 35320 // in other collections are ignored. 35321 _onModelEvent: function(event, model, collection, options) { 35322 if ((event === 'add' || event === 'remove') && collection !== this) return; 35323 if (event === 'destroy') this.remove(model, options); 35324 if (model && event === 'change:' + model.idAttribute) { 35325 delete this._byId[model.previous(model.idAttribute)]; 35326 if (model.id != null) this._byId[model.id] = model; 35327 } 35328 this.trigger.apply(this, arguments); 35329 } 35330 35331 }); 35332 35333 // Underscore methods that we want to implement on the Collection. 35334 // 90% of the core usefulness of Backbone Collections is actually implemented 35335 // right here: 35336 var methods = ['forEach', 'each', 'map', 'collect', 'reduce', 'foldl', 35337 'inject', 'reduceRight', 'foldr', 'find', 'detect', 'filter', 'select', 35338 'reject', 'every', 'all', 'some', 'any', 'include', 'contains', 'invoke', 35339 'max', 'min', 'toArray', 'size', 'first', 'head', 'take', 'initial', 'rest', 35340 'tail', 'drop', 'last', 'without', 'difference', 'indexOf', 'shuffle', 35341 'lastIndexOf', 'isEmpty', 'chain', 'sample']; 35342 35343 // Mix in each Underscore method as a proxy to `Collection#models`. 35344 _.each(methods, function(method) { 35345 Collection.prototype[method] = function() { 35346 var args = slice.call(arguments); 35347 args.unshift(this.models); 35348 return _[method].apply(_, args); 35349 }; 35350 }); 35351 35352 // Underscore methods that take a property name as an argument. 35353 var attributeMethods = ['groupBy', 'countBy', 'sortBy', 'indexBy']; 35354 35355 // Use attributes instead of properties. 35356 _.each(attributeMethods, function(method) { 35357 Collection.prototype[method] = function(value, context) { 35358 var iterator = _.isFunction(value) ? value : function(model) { 35359 return model.get(value); 35360 }; 35361 return _[method](this.models, iterator, context); 35362 }; 35363 }); 35364 35365 // Backbone.View 35366 // ------------- 35367 35368 // Backbone Views are almost more convention than they are actual code. A View 35369 // is simply a JavaScript object that represents a logical chunk of UI in the 35370 // DOM. This might be a single item, an entire list, a sidebar or panel, or 35371 // even the surrounding frame which wraps your whole app. Defining a chunk of 35372 // UI as a **View** allows you to define your DOM events declaratively, without 35373 // having to worry about render order ... and makes it easy for the view to 35374 // react to specific changes in the state of your models. 35375 35376 // Creating a Backbone.View creates its initial element outside of the DOM, 35377 // if an existing element is not provided... 35378 var View = Backbone.View = function(options) { 35379 this.cid = _.uniqueId('view'); 35380 options || (options = {}); 35381 _.extend(this, _.pick(options, viewOptions)); 35382 this._ensureElement(); 35383 this.initialize.apply(this, arguments); 35384 this.delegateEvents(); 35385 }; 35386 35387 // Cached regex to split keys for `delegate`. 35388 var delegateEventSplitter = /^(\S+)\s*(.*)$/; 35389 35390 // List of view options to be merged as properties. 35391 var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events']; 35392 35393 // Set up all inheritable **Backbone.View** properties and methods. 35394 _.extend(View.prototype, Events, { 35395 35396 // The default `tagName` of a View's element is `"div"`. 35397 tagName: 'div', 35398 35399 // jQuery delegate for element lookup, scoped to DOM elements within the 35400 // current view. This should be preferred to global lookups where possible. 35401 $: function(selector) { 35402 return this.$el.find(selector); 35403 }, 35404 35405 // Initialize is an empty function by default. Override it with your own 35406 // initialization logic. 35407 initialize: function(){}, 35408 35409 // **render** is the core function that your view should override, in order 35410 // to populate its element (`this.el`), with the appropriate HTML. The 35411 // convention is for **render** to always return `this`. 35412 render: function() { 35413 return this; 35414 }, 35415 35416 // Remove this view by taking the element out of the DOM, and removing any 35417 // applicable Backbone.Events listeners. 35418 remove: function() { 35419 this.$el.remove(); 35420 this.stopListening(); 35421 return this; 35422 }, 35423 35424 // Change the view's element (`this.el` property), including event 35425 // re-delegation. 35426 setElement: function(element, delegate) { 35427 if (this.$el) this.undelegateEvents(); 35428 this.$el = element instanceof Backbone.$ ? element : Backbone.$(element); 35429 this.el = this.$el[0]; 35430 if (delegate !== false) this.delegateEvents(); 35431 return this; 35432 }, 35433 35434 // Set callbacks, where `this.events` is a hash of 35435 // 35436 // *{"event selector": "callback"}* 35437 // 35438 // { 35439 // 'mousedown .title': 'edit', 35440 // 'click .button': 'save', 35441 // 'click .open': function(e) { ... } 35442 // } 35443 // 35444 // pairs. Callbacks will be bound to the view, with `this` set properly. 35445 // Uses event delegation for efficiency. 35446 // Omitting the selector binds the event to `this.el`. 35447 // This only works for delegate-able events: not `focus`, `blur`, and 35448 // not `change`, `submit`, and `reset` in Internet Explorer. 35449 delegateEvents: function(events) { 35450 if (!(events || (events = _.result(this, 'events')))) return this; 35451 this.undelegateEvents(); 35452 for (var key in events) { 35453 var method = events[key]; 35454 if (!_.isFunction(method)) method = this[events[key]]; 35455 if (!method) continue; 35456 35457 var match = key.match(delegateEventSplitter); 35458 var eventName = match[1], selector = match[2]; 35459 method = _.bind(method, this); 35460 eventName += '.delegateEvents' + this.cid; 35461 if (selector === '') { 35462 this.$el.on(eventName, method); 35463 } else { 35464 this.$el.on(eventName, selector, method); 35465 } 35466 } 35467 return this; 35468 }, 35469 35470 // Clears all callbacks previously bound to the view with `delegateEvents`. 35471 // You usually don't need to use this, but may wish to if you have multiple 35472 // Backbone views attached to the same DOM element. 35473 undelegateEvents: function() { 35474 this.$el.off('.delegateEvents' + this.cid); 35475 return this; 35476 }, 35477 35478 // Ensure that the View has a DOM element to render into. 35479 // If `this.el` is a string, pass it through `$()`, take the first 35480 // matching element, and re-assign it to `el`. Otherwise, create 35481 // an element from the `id`, `className` and `tagName` properties. 35482 _ensureElement: function() { 35483 if (!this.el) { 35484 var attrs = _.extend({}, _.result(this, 'attributes')); 35485 if (this.id) attrs.id = _.result(this, 'id'); 35486 if (this.className) attrs['class'] = _.result(this, 'className'); 35487 var $el = Backbone.$('<' + _.result(this, 'tagName') + '>').attr(attrs); 35488 this.setElement($el, false); 35489 } else { 35490 this.setElement(_.result(this, 'el'), false); 35491 } 35492 } 35493 35494 }); 35495 35496 // Backbone.sync 35497 // ------------- 35498 35499 // Override this function to change the manner in which Backbone persists 35500 // models to the server. You will be passed the type of request, and the 35501 // model in question. By default, makes a RESTful Ajax request 35502 // to the model's `url()`. Some possible customizations could be: 35503 // 35504 // * Use `setTimeout` to batch rapid-fire updates into a single request. 35505 // * Send up the models as XML instead of JSON. 35506 // * Persist models via WebSockets instead of Ajax. 35507 // 35508 // Turn on `Backbone.emulateHTTP` in order to send `PUT` and `DELETE` requests 35509 // as `POST`, with a `_method` parameter containing the true HTTP method, 35510 // as well as all requests with the body as `application/x-www-form-urlencoded` 35511 // instead of `application/json` with the model in a param named `model`. 35512 // Useful when interfacing with server-side languages like **PHP** that make 35513 // it difficult to read the body of `PUT` requests. 35514 Backbone.sync = function(method, model, options) { 35515 var type = methodMap[method]; 35516 35517 // Default options, unless specified. 35518 _.defaults(options || (options = {}), { 35519 emulateHTTP: Backbone.emulateHTTP, 35520 emulateJSON: Backbone.emulateJSON 35521 }); 35522 35523 // Default JSON-request options. 35524 var params = {type: type, dataType: 'json'}; 35525 35526 // Ensure that we have a URL. 35527 if (!options.url) { 35528 params.url = _.result(model, 'url') || urlError(); 35529 } 35530 35531 // Ensure that we have the appropriate request data. 35532 if (options.data == null && model && (method === 'create' || method === 'update' || method === 'patch')) { 35533 params.contentType = 'application/json'; 35534 params.data = JSON.stringify(options.attrs || model.toJSON(options)); 35535 } 35536 35537 // For older servers, emulate JSON by encoding the request into an HTML-form. 35538 if (options.emulateJSON) { 35539 params.contentType = 'application/x-www-form-urlencoded'; 35540 params.data = params.data ? {model: params.data} : {}; 35541 } 35542 35543 // For older servers, emulate HTTP by mimicking the HTTP method with `_method` 35544 // And an `X-HTTP-Method-Override` header. 35545 if (options.emulateHTTP && (type === 'PUT' || type === 'DELETE' || type === 'PATCH')) { 35546 params.type = 'POST'; 35547 if (options.emulateJSON) params.data._method = type; 35548 var beforeSend = options.beforeSend; 35549 options.beforeSend = function(xhr) { 35550 xhr.setRequestHeader('X-HTTP-Method-Override', type); 35551 if (beforeSend) return beforeSend.apply(this, arguments); 35552 }; 35553 } 35554 35555 // Don't process data on a non-GET request. 35556 if (params.type !== 'GET' && !options.emulateJSON) { 35557 params.processData = false; 35558 } 35559 35560 // If we're sending a `PATCH` request, and we're in an old Internet Explorer 35561 // that still has ActiveX enabled by default, override jQuery to use that 35562 // for XHR instead. Remove this line when jQuery supports `PATCH` on IE8. 35563 if (params.type === 'PATCH' && noXhrPatch) { 35564 params.xhr = function() { 35565 return new ActiveXObject("Microsoft.XMLHTTP"); 35566 }; 35567 } 35568 35569 // Make the request, allowing the user to override any Ajax options. 35570 var xhr = options.xhr = Backbone.ajax(_.extend(params, options)); 35571 model.trigger('request', model, xhr, options); 35572 return xhr; 35573 }; 35574 35575 var noXhrPatch = 35576 typeof window !== 'undefined' && !!window.ActiveXObject && 35577 !(window.XMLHttpRequest && (new XMLHttpRequest).dispatchEvent); 35578 35579 // Map from CRUD to HTTP for our default `Backbone.sync` implementation. 35580 var methodMap = { 35581 'create': 'POST', 35582 'update': 'PUT', 35583 'patch': 'PATCH', 35584 'delete': 'DELETE', 35585 'read': 'GET' 35586 }; 35587 35588 // Set the default implementation of `Backbone.ajax` to proxy through to `$`. 35589 // Override this if you'd like to use a different library. 35590 Backbone.ajax = function() { 35591 return Backbone.$.ajax.apply(Backbone.$, arguments); 35592 }; 35593 35594 // Backbone.Router 35595 // --------------- 35596 35597 // Routers map faux-URLs to actions, and fire events when routes are 35598 // matched. Creating a new one sets its `routes` hash, if not set statically. 35599 var Router = Backbone.Router = function(options) { 35600 options || (options = {}); 35601 if (options.routes) this.routes = options.routes; 35602 this._bindRoutes(); 35603 this.initialize.apply(this, arguments); 35604 }; 35605 35606 // Cached regular expressions for matching named param parts and splatted 35607 // parts of route strings. 35608 var optionalParam = /\((.*?)\)/g; 35609 var namedParam = /(\(\?)?:\w+/g; 35610 var splatParam = /\*\w+/g; 35611 var escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g; 35612 35613 // Set up all inheritable **Backbone.Router** properties and methods. 35614 _.extend(Router.prototype, Events, { 35615 35616 // Initialize is an empty function by default. Override it with your own 35617 // initialization logic. 35618 initialize: function(){}, 35619 35620 // Manually bind a single named route to a callback. For example: 35621 // 35622 // this.route('search/:query/p:num', 'search', function(query, num) { 35623 // ... 35624 // }); 35625 // 35626 route: function(route, name, callback) { 35627 if (!_.isRegExp(route)) route = this._routeToRegExp(route); 35628 if (_.isFunction(name)) { 35629 callback = name; 35630 name = ''; 35631 } 35632 if (!callback) callback = this[name]; 35633 var router = this; 35634 Backbone.history.route(route, function(fragment) { 35635 var args = router._extractParameters(route, fragment); 35636 router.execute(callback, args); 35637 router.trigger.apply(router, ['route:' + name].concat(args)); 35638 router.trigger('route', name, args); 35639 Backbone.history.trigger('route', router, name, args); 35640 }); 35641 return this; 35642 }, 35643 35644 // Execute a route handler with the provided parameters. This is an 35645 // excellent place to do pre-route setup or post-route cleanup. 35646 execute: function(callback, args) { 35647 if (callback) callback.apply(this, args); 35648 }, 35649 35650 // Simple proxy to `Backbone.history` to save a fragment into the history. 35651 navigate: function(fragment, options) { 35652 Backbone.history.navigate(fragment, options); 35653 return this; 35654 }, 35655 35656 // Bind all defined routes to `Backbone.history`. We have to reverse the 35657 // order of the routes here to support behavior where the most general 35658 // routes can be defined at the bottom of the route map. 35659 _bindRoutes: function() { 35660 if (!this.routes) return; 35661 this.routes = _.result(this, 'routes'); 35662 var route, routes = _.keys(this.routes); 35663 while ((route = routes.pop()) != null) { 35664 this.route(route, this.routes[route]); 35665 } 35666 }, 35667 35668 // Convert a route string into a regular expression, suitable for matching 35669 // against the current location hash. 35670 _routeToRegExp: function(route) { 35671 route = route.replace(escapeRegExp, '\\$&') 35672 .replace(optionalParam, '(?:$1)?') 35673 .replace(namedParam, function(match, optional) { 35674 return optional ? match : '([^/?]+)'; 35675 }) 35676 .replace(splatParam, '([^?]*?)'); 35677 return new RegExp('^' + route + '(?:\\?([\\s\\S]*))?$'); 35678 }, 35679 35680 // Given a route, and a URL fragment that it matches, return the array of 35681 // extracted decoded parameters. Empty or unmatched parameters will be 35682 // treated as `null` to normalize cross-browser behavior. 35683 _extractParameters: function(route, fragment) { 35684 var params = route.exec(fragment).slice(1); 35685 return _.map(params, function(param, i) { 35686 // Don't decode the search params. 35687 if (i === params.length - 1) return param || null; 35688 return param ? decodeURIComponent(param) : null; 35689 }); 35690 } 35691 35692 }); 35693 35694 // Backbone.History 35695 // ---------------- 35696 35697 // Handles cross-browser history management, based on either 35698 // [pushState](http://diveintohtml5.info/history.html) and real URLs, or 35699 // [onhashchange](https://developer.mozilla.org/en-US/docs/DOM/window.onhashchange) 35700 // and URL fragments. If the browser supports neither (old IE, natch), 35701 // falls back to polling. 35702 var History = Backbone.History = function() { 35703 this.handlers = []; 35704 _.bindAll(this, 'checkUrl'); 35705 35706 // Ensure that `History` can be used outside of the browser. 35707 if (typeof window !== 'undefined') { 35708 this.location = window.location; 35709 this.history = window.history; 35710 } 35711 }; 35712 35713 // Cached regex for stripping a leading hash/slash and trailing space. 35714 var routeStripper = /^[#\/]|\s+$/g; 35715 35716 // Cached regex for stripping leading and trailing slashes. 35717 var rootStripper = /^\/+|\/+$/g; 35718 35719 // Cached regex for detecting MSIE. 35720 var isExplorer = /msie [\w.]+/; 35721 35722 // Cached regex for removing a trailing slash. 35723 var trailingSlash = /\/$/; 35724 35725 // Cached regex for stripping urls of hash. 35726 var pathStripper = /#.*$/; 35727 35728 // Has the history handling already been started? 35729 History.started = false; 35730 35731 // Set up all inheritable **Backbone.History** properties and methods. 35732 _.extend(History.prototype, Events, { 35733 35734 // The default interval to poll for hash changes, if necessary, is 35735 // twenty times a second. 35736 interval: 50, 35737 35738 // Are we at the app root? 35739 atRoot: function() { 35740 return this.location.pathname.replace(/[^\/]$/, '$&/') === this.root; 35741 }, 35742 35743 // Gets the true hash value. Cannot use location.hash directly due to bug 35744 // in Firefox where location.hash will always be decoded. 35745 getHash: function(window) { 35746 var match = (window || this).location.href.match(/#(.*)$/); 35747 return match ? match[1] : ''; 35748 }, 35749 35750 // Get the cross-browser normalized URL fragment, either from the URL, 35751 // the hash, or the override. 35752 getFragment: function(fragment, forcePushState) { 35753 if (fragment == null) { 35754 if (this._hasPushState || !this._wantsHashChange || forcePushState) { 35755 fragment = decodeURI(this.location.pathname + this.location.search); 35756 var root = this.root.replace(trailingSlash, ''); 35757 if (!fragment.indexOf(root)) fragment = fragment.slice(root.length); 35758 } else { 35759 fragment = this.getHash(); 35760 } 35761 } 35762 return fragment.replace(routeStripper, ''); 35763 }, 35764 35765 // Start the hash change handling, returning `true` if the current URL matches 35766 // an existing route, and `false` otherwise. 35767 start: function(options) { 35768 if (History.started) throw new Error("Backbone.history has already been started"); 35769 History.started = true; 35770 35771 // Figure out the initial configuration. Do we need an iframe? 35772 // Is pushState desired ... is it available? 35773 this.options = _.extend({root: '/'}, this.options, options); 35774 this.root = this.options.root; 35775 this._wantsHashChange = this.options.hashChange !== false; 35776 this._wantsPushState = !!this.options.pushState; 35777 this._hasPushState = !!(this.options.pushState && this.history && this.history.pushState); 35778 var fragment = this.getFragment(); 35779 var docMode = document.documentMode; 35780 var oldIE = (isExplorer.exec(navigator.userAgent.toLowerCase()) && (!docMode || docMode <= 7)); 35781 35782 // Normalize root to always include a leading and trailing slash. 35783 this.root = ('/' + this.root + '/').replace(rootStripper, '/'); 35784 35785 if (oldIE && this._wantsHashChange) { 35786 var frame = Backbone.$('<iframe src="javascript:0" tabindex="-1">'); 35787 this.iframe = frame.hide().appendTo('body')[0].contentWindow; 35788 this.navigate(fragment); 35789 } 35790 35791 // Depending on whether we're using pushState or hashes, and whether 35792 // 'onhashchange' is supported, determine how we check the URL state. 35793 if (this._hasPushState) { 35794 Backbone.$(window).on('popstate', this.checkUrl); 35795 } else if (this._wantsHashChange && ('onhashchange' in window) && !oldIE) { 35796 Backbone.$(window).on('hashchange', this.checkUrl); 35797 } else if (this._wantsHashChange) { 35798 this._checkUrlInterval = setInterval(this.checkUrl, this.interval); 35799 } 35800 35801 // Determine if we need to change the base url, for a pushState link 35802 // opened by a non-pushState browser. 35803 this.fragment = fragment; 35804 var loc = this.location; 35805 35806 // Transition from hashChange to pushState or vice versa if both are 35807 // requested. 35808 if (this._wantsHashChange && this._wantsPushState) { 35809 35810 // If we've started off with a route from a `pushState`-enabled 35811 // browser, but we're currently in a browser that doesn't support it... 35812 if (!this._hasPushState && !this.atRoot()) { 35813 this.fragment = this.getFragment(null, true); 35814 this.location.replace(this.root + '#' + this.fragment); 35815 // Return immediately as browser will do redirect to new url 35816 return true; 35817 35818 // Or if we've started out with a hash-based route, but we're currently 35819 // in a browser where it could be `pushState`-based instead... 35820 } else if (this._hasPushState && this.atRoot() && loc.hash) { 35821 this.fragment = this.getHash().replace(routeStripper, ''); 35822 this.history.replaceState({}, document.title, this.root + this.fragment); 35823 } 35824 35825 } 35826 35827 if (!this.options.silent) return this.loadUrl(); 35828 }, 35829 35830 // Disable Backbone.history, perhaps temporarily. Not useful in a real app, 35831 // but possibly useful for unit testing Routers. 35832 stop: function() { 35833 Backbone.$(window).off('popstate', this.checkUrl).off('hashchange', this.checkUrl); 35834 if (this._checkUrlInterval) clearInterval(this._checkUrlInterval); 35835 History.started = false; 35836 }, 35837 35838 // Add a route to be tested when the fragment changes. Routes added later 35839 // may override previous routes. 35840 route: function(route, callback) { 35841 this.handlers.unshift({route: route, callback: callback}); 35842 }, 35843 35844 // Checks the current URL to see if it has changed, and if it has, 35845 // calls `loadUrl`, normalizing across the hidden iframe. 35846 checkUrl: function(e) { 35847 var current = this.getFragment(); 35848 if (current === this.fragment && this.iframe) { 35849 current = this.getFragment(this.getHash(this.iframe)); 35850 } 35851 if (current === this.fragment) return false; 35852 if (this.iframe) this.navigate(current); 35853 this.loadUrl(); 35854 }, 35855 35856 // Attempt to load the current URL fragment. If a route succeeds with a 35857 // match, returns `true`. If no defined routes matches the fragment, 35858 // returns `false`. 35859 loadUrl: function(fragment) { 35860 fragment = this.fragment = this.getFragment(fragment); 35861 return _.any(this.handlers, function(handler) { 35862 if (handler.route.test(fragment)) { 35863 handler.callback(fragment); 35864 return true; 35865 } 35866 }); 35867 }, 35868 35869 // Save a fragment into the hash history, or replace the URL state if the 35870 // 'replace' option is passed. You are responsible for properly URL-encoding 35871 // the fragment in advance. 35872 // 35873 // The options object can contain `trigger: true` if you wish to have the 35874 // route callback be fired (not usually desirable), or `replace: true`, if 35875 // you wish to modify the current URL without adding an entry to the history. 35876 navigate: function(fragment, options) { 35877 if (!History.started) return false; 35878 if (!options || options === true) options = {trigger: !!options}; 35879 35880 var url = this.root + (fragment = this.getFragment(fragment || '')); 35881 35882 // Strip the hash for matching. 35883 fragment = fragment.replace(pathStripper, ''); 35884 35885 if (this.fragment === fragment) return; 35886 this.fragment = fragment; 35887 35888 // Don't include a trailing slash on the root. 35889 if (fragment === '' && url !== '/') url = url.slice(0, -1); 35890 35891 // If pushState is available, we use it to set the fragment as a real URL. 35892 if (this._hasPushState) { 35893 this.history[options.replace ? 'replaceState' : 'pushState']({}, document.title, url); 35894 35895 // If hash changes haven't been explicitly disabled, update the hash 35896 // fragment to store history. 35897 } else if (this._wantsHashChange) { 35898 this._updateHash(this.location, fragment, options.replace); 35899 if (this.iframe && (fragment !== this.getFragment(this.getHash(this.iframe)))) { 35900 // Opening and closing the iframe tricks IE7 and earlier to push a 35901 // history entry on hash-tag change. When replace is true, we don't 35902 // want this. 35903 if(!options.replace) this.iframe.document.open().close(); 35904 this._updateHash(this.iframe.location, fragment, options.replace); 35905 } 35906 35907 // If you've told us that you explicitly don't want fallback hashchange- 35908 // based history, then `navigate` becomes a page refresh. 35909 } else { 35910 return this.location.assign(url); 35911 } 35912 if (options.trigger) return this.loadUrl(fragment); 35913 }, 35914 35915 // Update the hash location, either replacing the current entry, or adding 35916 // a new one to the browser history. 35917 _updateHash: function(location, fragment, replace) { 35918 if (replace) { 35919 var href = location.href.replace(/(javascript:|#).*$/, ''); 35920 location.replace(href + '#' + fragment); 35921 } else { 35922 // Some browsers require that `hash` contains a leading #. 35923 location.hash = '#' + fragment; 35924 } 35925 } 35926 35927 }); 35928 35929 // Create the default Backbone.history. 35930 Backbone.history = new History; 35931 35932 // Helpers 35933 // ------- 35934 35935 // Helper function to correctly set up the prototype chain, for subclasses. 35936 // Similar to `goog.inherits`, but uses a hash of prototype properties and 35937 // class properties to be extended. 35938 var extend = function(protoProps, staticProps) { 35939 var parent = this; 35940 var child; 35941 35942 // The constructor function for the new subclass is either defined by you 35943 // (the "constructor" property in your `extend` definition), or defaulted 35944 // by us to simply call the parent's constructor. 35945 if (protoProps && _.has(protoProps, 'constructor')) { 35946 child = protoProps.constructor; 35947 } else { 35948 child = function(){ return parent.apply(this, arguments); }; 35949 } 35950 35951 // Add static properties to the constructor function, if supplied. 35952 _.extend(child, parent, staticProps); 35953 35954 // Set the prototype chain to inherit from `parent`, without calling 35955 // `parent`'s constructor function. 35956 var Surrogate = function(){ this.constructor = child; }; 35957 Surrogate.prototype = parent.prototype; 35958 child.prototype = new Surrogate; 35959 35960 // Add prototype properties (instance properties) to the subclass, 35961 // if supplied. 35962 if (protoProps) _.extend(child.prototype, protoProps); 35963 35964 // Set a convenience property in case the parent's prototype is needed 35965 // later. 35966 child.__super__ = parent.prototype; 35967 35968 return child; 35969 }; 35970 35971 // Set up inheritance for the model, collection, router, view and history. 35972 Model.extend = Collection.extend = Router.extend = View.extend = History.extend = extend; 35973 35974 // Throw an error when a URL is needed, and none is supplied. 35975 var urlError = function() { 35976 throw new Error('A "url" property or function must be specified'); 35977 }; 35978 35979 // Wrap an optional error callback with a fallback error event. 35980 var wrapError = function(model, options) { 35981 var error = options.error; 35982 options.error = function(resp) { 35983 if (error) error(model, resp, options); 35984 model.trigger('error', model, resp, options); 35985 }; 35986 }; 35987 35988 return Backbone; 35989 35990 })); 35991 35992 35993 /***/ }, 35994 /* 166 */ 35995 /***/ function(module, exports, __webpack_require__) { 35996 35997 var __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(jQuery, _, Backbone) {/** 35998 * Bootstrap Modal wrapper for use with Backbone. 35999 * 36000 * Takes care of instantiation, manages multiple modals, 36001 * adds several options and removes the element from the DOM when closed 36002 * 36003 * @author Charles Davison <charlie@powmedia.co.uk> 36004 * 36005 * Events: 36006 * shown: Fired when the modal has finished animating in 36007 * hidden: Fired when the modal has finished animating out 36008 * cancel: The user dismissed the modal 36009 * ok: The user clicked OK 36010 */ 36011 (function($, _, Backbone) { 36012 36013 //Set custom template settings 36014 var _interpolateBackup = _.templateSettings; 36015 _.templateSettings = { 36016 interpolate: /\{\{(.+?)\}\}/g, 36017 evaluate: /<%([\s\S]+?)%>/g 36018 } 36019 36020 var template = _.template('\ 36021 <% if (title) { %>\ 36022 <div class="modal-header">\ 36023 <% if (allowCancel) { %>\ 36024 <a class="close">×</a>\ 36025 <% } %>\ 36026 <h3>{{title}}</h3>\ 36027 </div>\ 36028 <% } %>\ 36029 <div class="modal-body">{{content}}</div>\ 36030 <div class="modal-footer">\ 36031 <% if (allowCancel) { %>\ 36032 <% if (cancelText) { %>\ 36033 <a href="#" class="btn cancel">{{cancelText}}</a>\ 36034 <% } %>\ 36035 <% } %>\ 36036 <a href="#" class="btn ok btn-primary">{{okText}}</a>\ 36037 </div>\ 36038 '); 36039 36040 //Reset to users' template settings 36041 _.templateSettings = _interpolateBackup; 36042 36043 36044 var Modal = Backbone.View.extend({ 36045 36046 className: 'modal', 36047 36048 events: { 36049 'click .close': function(event) { 36050 event.preventDefault(); 36051 36052 this.trigger('cancel'); 36053 }, 36054 'click .cancel': function(event) { 36055 event.preventDefault(); 36056 36057 this.trigger('cancel'); 36058 }, 36059 'click .ok': function(event) { 36060 event.preventDefault(); 36061 36062 this.trigger('ok'); 36063 this.close(); 36064 } 36065 }, 36066 36067 /** 36068 * Creates an instance of a Bootstrap Modal 36069 * 36070 * @see http://twitter.github.com/bootstrap/javascript.html#modals 36071 * 36072 * @param {Object} options 36073 * @param {String|View} [options.content] Modal content. Default: none 36074 * @param {String} [options.title] Title. Default: none 36075 * @param {String} [options.okText] Text for the OK button. Default: 'OK' 36076 * @param {String} [options.cancelText] Text for the cancel button. Default: 'Cancel'. If passed a falsey value, the button will be removed 36077 * @param {Boolean} [options.allowCancel Whether the modal can be closed, other than by pressing OK. Default: true 36078 * @param {Boolean} [options.escape] Whether the 'esc' key can dismiss the modal. Default: true, but false if options.cancellable is true 36079 * @param {Boolean} [options.animate] Whether to animate in/out. Default: false 36080 * @param {Function} [options.template] Compiled underscore template to override the default one 36081 */ 36082 initialize: function(options) { 36083 this.options = _.extend({ 36084 title: null, 36085 okText: 'OK', 36086 cancelText: 'Cancel', 36087 allowCancel: true, 36088 escape: true, 36089 animate: false, 36090 template: template 36091 }, options); 36092 }, 36093 36094 /** 36095 * Creates the DOM element 36096 * 36097 * @api private 36098 */ 36099 render: function() { 36100 var $el = this.$el, 36101 options = this.options, 36102 content = options.content; 36103 36104 //Create the modal container 36105 $el.html(options.template(options)); 36106 36107 var $content = this.$content = $el.find('.modal-body') 36108 36109 //Insert the main content if it's a view 36110 if (content.$el) { 36111 $el.find('.modal-body').html(content.render().$el); 36112 } 36113 36114 if (options.animate) $el.addClass('fade'); 36115 36116 this.isRendered = true; 36117 36118 return this; 36119 }, 36120 36121 /** 36122 * Renders and shows the modal 36123 * 36124 * @param {Function} [cb] Optional callback that runs only when OK is pressed. 36125 */ 36126 open: function(cb) { 36127 if (!this.isRendered) this.render(); 36128 36129 var self = this, 36130 $el = this.$el; 36131 36132 //Create it 36133 $el.modal({ 36134 keyboard: this.options.allowCancel, 36135 backdrop: this.options.allowCancel ? true : 'static' 36136 }); 36137 36138 //Focus OK button 36139 $el.one('shown', function() { 36140 $el.find('.btn.ok').focus(); 36141 36142 self.trigger('shown'); 36143 }); 36144 36145 //Adjust the modal and backdrop z-index; for dealing with multiple modals 36146 var numModals = Modal.count, 36147 $backdrop = $('.modal-backdrop:eq('+numModals+')'), 36148 backdropIndex = $backdrop.css('z-index'), 36149 elIndex = $backdrop.css('z-index'); 36150 36151 $backdrop.css('z-index', backdropIndex + numModals); 36152 this.$el.css('z-index', elIndex + numModals); 36153 36154 if (this.options.allowCancel) { 36155 $backdrop.one('click', function() { 36156 self.trigger('cancel'); 36157 }); 36158 36159 $(document).one('keyup.dismiss.modal', function (e) { 36160 e.which == 27 && self.trigger('cancel'); 36161 }); 36162 } 36163 36164 this.on('cancel', function() { 36165 self.close(); 36166 }); 36167 36168 Modal.count++; 36169 36170 //Run callback on OK if provided 36171 if (cb) { 36172 self.on('ok', cb); 36173 } 36174 36175 return this; 36176 }, 36177 36178 /** 36179 * Closes the modal 36180 */ 36181 close: function() { 36182 var self = this, 36183 $el = this.$el; 36184 36185 //Check if the modal should stay open 36186 if (this._preventClose) { 36187 this._preventClose = false; 36188 return; 36189 } 36190 36191 $el.modal('hide'); 36192 36193 $el.one('hidden', function() { 36194 self.remove(); 36195 36196 self.trigger('hidden'); 36197 }); 36198 36199 Modal.count--; 36200 }, 36201 36202 /** 36203 * Stop the modal from closing. 36204 * Can be called from within a 'close' or 'ok' event listener. 36205 */ 36206 preventClose: function() { 36207 this._preventClose = true; 36208 } 36209 }, { 36210 //STATICS 36211 36212 //The number of modals on display 36213 count: 0 36214 }); 36215 36216 36217 //EXPORTS 36218 //CommonJS 36219 if ("function" == 'function' && typeof module !== 'undefined' && exports) { 36220 module.exports = Modal; 36221 } 36222 36223 //AMD / RequireJS 36224 if (true) { 36225 return !(__WEBPACK_AMD_DEFINE_RESULT__ = function() { 36226 Backbone.BootstrapModal = Modal; 36227 }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) 36228 } 36229 36230 //Regular; add to Backbone.Bootstrap.Modal 36231 else { 36232 Backbone.BootstrapModal = Modal; 36233 } 36234 36235 })(jQuery, _, Backbone); 36236 36237 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71), __webpack_require__(114), __webpack_require__(165))) 36238 36239 /***/ }, 36240 /* 167 */ 36241 /***/ function(module, exports, __webpack_require__) { 36242 36243 /* WEBPACK VAR INJECTION */(function(_, $) {'use strict';var _backbone=__webpack_require__(113),_backbone2=_interopRequireDefault(_backbone);__webpack_require__(164);var _objectListEditor=__webpack_require__(168),_objectListEditor2=_interopRequireDefault(_objectListEditor);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}_backbone2.default.Form.editors.List=class a extends _backbone2.default.Form.editors.Base{get events(){return{'click [data-action="add"]':b=>{b.stopPropagation(),b.preventDefault(),this.addItem(this.schema.default,!0)},'click span.tab-delete':b=>{b.stopPropagation(),b.preventDefault();const c=_.findWhere(this.items,{cid:$(b.target).data('cid')});c&&this.removeItem(c)}}}static template(){return _.template('<div> <div data-items></div> <button type="button" data-action="add">Add</button></div>',_backbone2.default.Form.templateSettings)()}static objectTemplate(){return _.template('<div class="object-list-container"> <a class="add-item" data-action="add"><span class="fa fa-plus-circle"></span> Add Item</a> <ul class="nav nav-tabs object-list-tabs" role="tablist" data-tabs></ul> <div class="tab-content" data-items></div></div>',_backbone2.default.Form.templateSettings)()}constructor(b){super(b);const c=_backbone2.default.Form.editors,d=this.schema.itemType;if(!this.schema)throw new Error('Missing required option \'schema\'');// Default to Text 36244 this.Editor=d?c.List[d]?c.List[d]:c[d]:c.Text,this.isObjectType='Object'===d,this.items=[]}render(){const b=this.value||[],c=this.isObjectType?$($.trim(a.objectTemplate())):$($.trim(a.template()));return this.$list=c.is('[data-items]')?c:c.find('[data-items]'),this.isObjectType&&(this.$tab=c.find('[data-tabs]')),b.length?b.forEach(d=>{this.addItem(d)}):!this.Editor.isAsync&&this.addItem(this.schema.default),this.isObjectType&&(this.$tab.find('a[href="#tab-'+this.items[0].cid+'"]').tab('show'),this.items[0].$el.addClass('active in')),this.setElement(c),this.$el.attr('id',this.id),this.$el.attr('name',this.key),this.hasFocus&&this.trigger('blur',this),this}/** 36245 * Add a new item to the list 36246 * @param {Mixed} [value] Value for the new item editor 36247 * @param {Boolean} [userInitiated] If the item was added by the user clicking 'add' 36248 */addItem(b,c){const d=_backbone2.default.Form.editors,e=new d.List.Item({list:this,form:this.form,schema:this.schema,value:b,Editor:this.Editor,key:this.key}).render(),f=_.template('<li role="presentation" class="object-list-tab"> <a href="#tab-<%= cid %>" class="tab-link" aria-controls="tab-<%= cid %>" role="tab" data-toggle="tab"> <span class="tab-title">Item</span> <span class="tab-delete fa fa-times-circle" data-cid="<%= cid %>"></span> </a></li>',_backbone2.default.Form.templateSettings)({cid:e.cid}),g=()=>{this.items.push(e),this.$list.append(e.el),this.isObjectType&&(this.$tab.append(f),this.$tab.find('a[href="#tab-'+e.cid+'"]').tab('show')),e.editor.on('all',h=>{if('change'!==h){// args = ["key:change", itemEditor, fieldEditor] 36249 var i=_.toArray(arguments);i[0]='item:'+h,i.splice(1,0,this),d.List.prototype.trigger.apply(this,i)}},this),e.editor.on('change',function(){e.addEventTriggered||(e.addEventTriggered=!0,this.trigger('add',this,e.editor)),this.trigger('item:change',this,e.editor),this.trigger('change',this)},this),e.editor.on('focus',function(){this.hasFocus||this.trigger('focus',this)},this),e.editor.on('blur',()=>{this.hasFocus&&setTimeout(()=>{_.find(this.items,h=>{return h.editor.hasFocus})||this.trigger('blur',this)},0)},this),(c||b)&&(e.addEventTriggered=!0),c&&(this.trigger('add',this,e.editor),this.trigger('change',this))};// Create the item 36250 // Check if we need to wait for the item to complete before adding to the list 36251 return this.Editor.isAsync?e.editor.on('readyToAdd',g,this):(g(),e.editor.focus()),e}/** 36252 * Remove an item from the list 36253 * @param {List.Item} item 36254 */removeItem(b){// Confirm delete 36255 const c=this.schema.confirmDelete;if(!c||confirm(c)){const d=_.indexOf(this.items,b);if(this.items[d].remove(),this.items.splice(d,1),this.isObjectType){let e=0>d-1?0:d-1;this.$tab.children().eq(d).remove(),0<this.items.length&&this.$tab.find('a[href="#tab-'+this.items[e].cid+'"]').tab('show')}b.addEventTriggered&&(this.trigger('remove',this,b.editor),this.trigger('change',this))}}/** 36256 * Move an item in the list 36257 * @param {List.Item} item 36258 * @param {String} direction 36259 */moveItem(b,c){const d=_.indexOf(this.items,b),e=this.$list.children().eq(d);let f=d-1;if('left'===c?e.insertBefore(e.prev()):'right'==c&&(e.insertAfter(e.next()),f++),this.isObjectType){const g=this.$tab.children().eq(d);'left'===c?g.insertBefore(g.prev()):'right'==c&&g.insertAfter(g.next())}this.items.splice(f,2,this.items[f+1],this.items[f])}getValue(){const b=_.map(this.items,function(c){return c.getValue()});// Filter empty items 36260 return _.without(b,void 0,'')}setValue(b){this.value=b,this.render()}focus(){this.hasFocus||this.items[0]&&this.items[0].editor.focus()}blur(){if(this.hasFocus){var b=_.find(this.items,function(c){return c.editor.hasFocus});b&&b.editor.blur()}}/** 36261 * Override default remove function in order to remove item views 36262 */remove(){_.invoke(this.items,'remove'),_backbone2.default.Form.editors.Base.prototype.remove.call(this)}/** 36263 * Run validation 36264 * 36265 * @return {Object|Null} 36266 */validate(){if(!this.validators)return null;// Collect errors 36267 const b=_.map(this.items,function(d){return d.validate()}),c=!!_.compact(b).length;// Check if any item has errors 36268 return c?{type:'list',message:'Some of the items in the list failed validation',errors:b}:null;// If so create a shared error 36269 }},_backbone2.default.Form.editors.List.Item=class extends _backbone2.default.Form.editors.Base{get events(){return{'click [data-action="remove"]':b=>{b.stopPropagation(),b.preventDefault(),this.list.removeItem(this)},'click [data-action="move-left"]':b=>{b.stopPropagation(),b.preventDefault(),this.list.moveItem(this,'left')},'click [data-action="move-right"]':b=>{b.stopPropagation(),b.preventDefault(),this.list.moveItem(this,'right')},'keydown input[type=text]':b=>{13!==b.keyCode||(b.stopPropagation(),b.preventDefault(),this.list.addItem(),this.list.$list.find('> li:last input').focus())}}}static template(){return _.template('<div style="margin-bottom: 5px"> <span data-editor></span> <button type="button" data-action="move-left">∧ up</button> <button type="button" data-action="move-right">∨ down</button> <button type="button" data-action="remove">× delete</button></div>',_backbone2.default.Form.templateSettings)()}static objectTemplate(b){return _.template('<div role="tabpanel" class="list-tab-pane tab-pane fade" id="tab-<%= cid %>"> <div class="object-list-tab-pane"> <div class="tab-pane-action"> <a class="tab-pane-move-left" data-action="move-left"> <span class="fa fa-angle-left"></span> Move Left </a> <a class="tab-pane-move-right" data-action="move-right"> Move Right <span class="fa fa-angle-right"></span> </a> </div> <span data-editor></span> </div></div>',_backbone2.default.Form.templateSettings)(b)}static errorClassName(){return'error'}constructor(b){super(b),this.list=b.list,this.schema=b.schema||this.list.schema,this.value=b.value,this.Editor=b.Editor||_backbone2.default.Form.editors.Text,this.key=b.key,this.template=b.template||this.schema.itemTemplate||this.constructor.template,this.errorClassName=b.errorClassName||this.constructor.errorClassName,this.form=b.form}render(){this.editor=new this.Editor({key:this.key,schema:this.schema,value:this.value,list:this.list,item:this,form:this.form}).render();// Create main element 36270 const b=this.list.isObjectType?$($.trim(this.constructor.objectTemplate({cid:this.cid}))):$($.trim(this.template()));return b.find('[data-editor]').append(this.editor.el),this.setElement(b),this}getValue(){return this.editor.getValue()}setValue(b){this.editor.setValue(b)}focus(){this.editor.focus()}blur(){this.editor.blur()}remove(){this.editor.remove(),_backbone2.default.View.prototype.remove.call(this)}validate(){const b=this.getValue(),c=this.list.form?this.list.form.getValue():{},d=this.schema.validators,e=this.getValidator;if(!d)return null;// Run through validators until an error is found 36271 let f=null;// Return error to be aggregated by list 36272 return _.every(d,function(g){return f=e(g)(b,c),!f}),f?this.setError(f):this.clearError(),f?f:null}/** 36273 * Show a validation error 36274 */setError(b){this.$el.addClass(this.errorClassName),this.$el.attr('title',b.message)}/** 36275 * Hide validation errors 36276 */clearError(){this.$el.removeClass(this.errorClassName),this.$el.attr('title',null)}},_backbone2.default.Form.editors.List.Object=_objectListEditor2.default;/* global $ _ confirm*/ 36277 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(114), __webpack_require__(71))) 36278 36279 /***/ }, 36280 /* 168 */ 36281 /***/ function(module, exports, __webpack_require__) { 36282 36283 'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _backbone=__webpack_require__(113),_backbone2=_interopRequireDefault(_backbone);__webpack_require__(164);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}class ObjectListEditor extends _backbone2.default.Form.editors.Base{get hasNestedForm(){return!1}constructor(a,...b){if(super(a,...b),!this.form)throw new Error('Missing required option \'form"\'');if(!this.schema.subSchema)throw new Error('Missing required \'schema.subSchema\' option for Object editor')}render(){const a=this.form.constructor;return this.nestedForm=new a({schema:this.schema.subSchema,fields:this.schema.order||void 0,data:this.value,Field:a.NestedField}),this.$el.html(this.nestedForm.render().el),this.hasFocus&&this.trigger('blur',this),this}getValue(){return this.nestedForm?this.nestedForm.getValue():this.value}setValue(a){this.value=a,this.render()}focus(){this.hasFocus||this.nestedForm.focus()}blur(){this.hasFocus&&this.nestedForm.blur()}remove(){this.nestedForm.remove(),super.remove()}validate(){return this.nestedForm.validate()}}exports.default=ObjectListEditor; 36284 36285 /***/ }, 36286 /* 169 */ 36287 /***/ function(module, exports, __webpack_require__) { 36288 36289 'use strict';var _backbone=__webpack_require__(113),_backbone2=_interopRequireDefault(_backbone);__webpack_require__(164);__webpack_require__(170);__webpack_require__(172);__webpack_require__(173);__webpack_require__(174);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}/* global window */class CodeEditor extends _backbone2.default.Form.editors.Base{constructor(a){super(a),this.format=a.schema.format,this.editor=window.ace.edit(this.el),this.$el.css('height','300px'),this.editor.setTheme('ace/theme/monokai'),this.editor.getSession().setMode('ace/mode/'+this.format),this.editor.$blockScrolling=Infinity}render(){return this.setValue(this.value),this}getValue(){return this.editor.getValue()}setValue(a){a&&this.editor.setValue(a)}focus(){this.hasFocus||this.$el.focus()}blur(){this.hasFocus&&this.$el.blur()}}_backbone2.default.Form.editors.CodeEditor=CodeEditor; 36290 36291 /***/ }, 36292 /* 170 */ 36293 /***/ function(module, exports, __webpack_require__) { 36294 36295 (function(){function o(n){var i=e;n&&(e[n]||(e[n]={}),i=e[n]);if(!i.define||!i.define.packaged)t.original=i.define,i.define=t,i.define.packaged=!0;if(!i.require||!i.require.packaged)r.original=i.require,i.require=r,i.require.packaged=!0}var ACE_NAMESPACE = "ace",e=function(){return this}();!e&&typeof window!="undefined"&&(e=window);if(!ACE_NAMESPACE&&typeof requirejs!="undefined")return;var t=function(e,n,r){if(typeof e!="string"){t.original?t.original.apply(this,arguments):(console.error("dropping module because define wasn't a string."),console.trace());return}arguments.length==2&&(r=n),t.modules[e]||(t.payloads[e]=r,t.modules[e]=null)};t.modules={},t.payloads={};var n=function(e,t,n){if(typeof t=="string"){var i=s(e,t);if(i!=undefined)return n&&n(),i}else if(Object.prototype.toString.call(t)==="[object Array]"){var o=[];for(var u=0,a=t.length;u<a;++u){var f=s(e,t[u]);if(f==undefined&&r.original)return;o.push(f)}return n&&n.apply(null,o)||!0}},r=function(e,t){var i=n("",e,t);return i==undefined&&r.original?r.original.apply(this,arguments):i},i=function(e,t){if(t.indexOf("!")!==-1){var n=t.split("!");return i(e,n[0])+"!"+i(e,n[1])}if(t.charAt(0)=="."){var r=e.split("/").slice(0,-1).join("/");t=r+"/"+t;while(t.indexOf(".")!==-1&&s!=t){var s=t;t=t.replace(/\/\.\//,"/").replace(/[^\/]+\/\.\.\//,"")}}return t},s=function(e,r){r=i(e,r);var s=t.modules[r];if(!s){s=t.payloads[r];if(typeof s=="function"){var o={},u={id:r,uri:"",exports:o,packaged:!0},a=function(e,t){return n(r,e,t)},f=s(a,o,u);o=f||u.exports,t.modules[r]=o,delete t.payloads[r]}s=t.modules[r]=o||s}return s};o(ACE_NAMESPACE)})(),ace.define("ace/lib/regexp",["require","exports","module"],function(e,t,n){"use strict";function o(e){return(e.global?"g":"")+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.extended?"x":"")+(e.sticky?"y":"")}function u(e,t,n){if(Array.prototype.indexOf)return e.indexOf(t,n);for(var r=n||0;r<e.length;r++)if(e[r]===t)return r;return-1}var r={exec:RegExp.prototype.exec,test:RegExp.prototype.test,match:String.prototype.match,replace:String.prototype.replace,split:String.prototype.split},i=r.exec.call(/()??/,"")[1]===undefined,s=function(){var e=/^/g;return r.test.call(e,""),!e.lastIndex}();if(s&&i)return;RegExp.prototype.exec=function(e){var t=r.exec.apply(this,arguments),n,a;if(typeof e=="string"&&t){!i&&t.length>1&&u(t,"")>-1&&(a=RegExp(this.source,r.replace.call(o(this),"g","")),r.replace.call(e.slice(t.index),a,function(){for(var e=1;e<arguments.length-2;e++)arguments[e]===undefined&&(t[e]=undefined)}));if(this._xregexp&&this._xregexp.captureNames)for(var f=1;f<t.length;f++)n=this._xregexp.captureNames[f-1],n&&(t[n]=t[f]);!s&&this.global&&!t[0].length&&this.lastIndex>t.index&&this.lastIndex--}return t},s||(RegExp.prototype.test=function(e){var t=r.exec.call(this,e);return t&&this.global&&!t[0].length&&this.lastIndex>t.index&&this.lastIndex--,!!t})}),ace.define("ace/lib/es5-shim",["require","exports","module"],function(e,t,n){function r(){}function w(e){try{return Object.defineProperty(e,"sentinel",{}),"sentinel"in e}catch(t){}}function H(e){return e=+e,e!==e?e=0:e!==0&&e!==1/0&&e!==-1/0&&(e=(e>0||-1)*Math.floor(Math.abs(e))),e}function B(e){var t=typeof e;return e===null||t==="undefined"||t==="boolean"||t==="number"||t==="string"}function j(e){var t,n,r;if(B(e))return e;n=e.valueOf;if(typeof n=="function"){t=n.call(e);if(B(t))return t}r=e.toString;if(typeof r=="function"){t=r.call(e);if(B(t))return t}throw new TypeError}Function.prototype.bind||(Function.prototype.bind=function(t){var n=this;if(typeof n!="function")throw new TypeError("Function.prototype.bind called on incompatible "+n);var i=u.call(arguments,1),s=function(){if(this instanceof s){var e=n.apply(this,i.concat(u.call(arguments)));return Object(e)===e?e:this}return n.apply(t,i.concat(u.call(arguments)))};return n.prototype&&(r.prototype=n.prototype,s.prototype=new r,r.prototype=null),s});var i=Function.prototype.call,s=Array.prototype,o=Object.prototype,u=s.slice,a=i.bind(o.toString),f=i.bind(o.hasOwnProperty),l,c,h,p,d;if(d=f(o,"__defineGetter__"))l=i.bind(o.__defineGetter__),c=i.bind(o.__defineSetter__),h=i.bind(o.__lookupGetter__),p=i.bind(o.__lookupSetter__);if([1,2].splice(0).length!=2)if(!function(){function e(e){var t=new Array(e+2);return t[0]=t[1]=0,t}var t=[],n;t.splice.apply(t,e(20)),t.splice.apply(t,e(26)),n=t.length,t.splice(5,0,"XXX"),n+1==t.length;if(n+1==t.length)return!0}())Array.prototype.splice=function(e,t){var n=this.length;e>0?e>n&&(e=n):e==void 0?e=0:e<0&&(e=Math.max(n+e,0)),e+t<n||(t=n-e);var r=this.slice(e,e+t),i=u.call(arguments,2),s=i.length;if(e===n)s&&this.push.apply(this,i);else{var o=Math.min(t,n-e),a=e+o,f=a+s-o,l=n-a,c=n-o;if(f<a)for(var h=0;h<l;++h)this[f+h]=this[a+h];else if(f>a)for(h=l;h--;)this[f+h]=this[a+h];if(s&&e===c)this.length=c,this.push.apply(this,i);else{this.length=c+s;for(h=0;h<s;++h)this[e+h]=i[h]}}return r};else{var v=Array.prototype.splice;Array.prototype.splice=function(e,t){return arguments.length?v.apply(this,[e===void 0?0:e,t===void 0?this.length-e:t].concat(u.call(arguments,2))):[]}}Array.isArray||(Array.isArray=function(t){return a(t)=="[object Array]"});var m=Object("a"),g=m[0]!="a"||!(0 in m);Array.prototype.forEach||(Array.prototype.forEach=function(t){var n=F(this),r=g&&a(this)=="[object String]"?this.split(""):n,i=arguments[1],s=-1,o=r.length>>>0;if(a(t)!="[object Function]")throw new TypeError;while(++s<o)s in r&&t.call(i,r[s],s,n)}),Array.prototype.map||(Array.prototype.map=function(t){var n=F(this),r=g&&a(this)=="[object String]"?this.split(""):n,i=r.length>>>0,s=Array(i),o=arguments[1];if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");for(var u=0;u<i;u++)u in r&&(s[u]=t.call(o,r[u],u,n));return s}),Array.prototype.filter||(Array.prototype.filter=function(t){var n=F(this),r=g&&a(this)=="[object String]"?this.split(""):n,i=r.length>>>0,s=[],o,u=arguments[1];if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");for(var f=0;f<i;f++)f in r&&(o=r[f],t.call(u,o,f,n)&&s.push(o));return s}),Array.prototype.every||(Array.prototype.every=function(t){var n=F(this),r=g&&a(this)=="[object String]"?this.split(""):n,i=r.length>>>0,s=arguments[1];if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");for(var o=0;o<i;o++)if(o in r&&!t.call(s,r[o],o,n))return!1;return!0}),Array.prototype.some||(Array.prototype.some=function(t){var n=F(this),r=g&&a(this)=="[object String]"?this.split(""):n,i=r.length>>>0,s=arguments[1];if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");for(var o=0;o<i;o++)if(o in r&&t.call(s,r[o],o,n))return!0;return!1}),Array.prototype.reduce||(Array.prototype.reduce=function(t){var n=F(this),r=g&&a(this)=="[object String]"?this.split(""):n,i=r.length>>>0;if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");if(!i&&arguments.length==1)throw new TypeError("reduce of empty array with no initial value");var s=0,o;if(arguments.length>=2)o=arguments[1];else do{if(s in r){o=r[s++];break}if(++s>=i)throw new TypeError("reduce of empty array with no initial value")}while(!0);for(;s<i;s++)s in r&&(o=t.call(void 0,o,r[s],s,n));return o}),Array.prototype.reduceRight||(Array.prototype.reduceRight=function(t){var n=F(this),r=g&&a(this)=="[object String]"?this.split(""):n,i=r.length>>>0;if(a(t)!="[object Function]")throw new TypeError(t+" is not a function");if(!i&&arguments.length==1)throw new TypeError("reduceRight of empty array with no initial value");var s,o=i-1;if(arguments.length>=2)s=arguments[1];else do{if(o in r){s=r[o--];break}if(--o<0)throw new TypeError("reduceRight of empty array with no initial value")}while(!0);do o in this&&(s=t.call(void 0,s,r[o],o,n));while(o--);return s});if(!Array.prototype.indexOf||[0,1].indexOf(1,2)!=-1)Array.prototype.indexOf=function(t){var n=g&&a(this)=="[object String]"?this.split(""):F(this),r=n.length>>>0;if(!r)return-1;var i=0;arguments.length>1&&(i=H(arguments[1])),i=i>=0?i:Math.max(0,r+i);for(;i<r;i++)if(i in n&&n[i]===t)return i;return-1};if(!Array.prototype.lastIndexOf||[0,1].lastIndexOf(0,-3)!=-1)Array.prototype.lastIndexOf=function(t){var n=g&&a(this)=="[object String]"?this.split(""):F(this),r=n.length>>>0;if(!r)return-1;var i=r-1;arguments.length>1&&(i=Math.min(i,H(arguments[1]))),i=i>=0?i:r-Math.abs(i);for(;i>=0;i--)if(i in n&&t===n[i])return i;return-1};Object.getPrototypeOf||(Object.getPrototypeOf=function(t){return t.__proto__||(t.constructor?t.constructor.prototype:o)});if(!Object.getOwnPropertyDescriptor){var y="Object.getOwnPropertyDescriptor called on a non-object: ";Object.getOwnPropertyDescriptor=function(t,n){if(typeof t!="object"&&typeof t!="function"||t===null)throw new TypeError(y+t);if(!f(t,n))return;var r,i,s;r={enumerable:!0,configurable:!0};if(d){var u=t.__proto__;t.__proto__=o;var i=h(t,n),s=p(t,n);t.__proto__=u;if(i||s)return i&&(r.get=i),s&&(r.set=s),r}return r.value=t[n],r}}Object.getOwnPropertyNames||(Object.getOwnPropertyNames=function(t){return Object.keys(t)});if(!Object.create){var b;Object.prototype.__proto__===null?b=function(){return{__proto__:null}}:b=function(){var e={};for(var t in e)e[t]=null;return e.constructor=e.hasOwnProperty=e.propertyIsEnumerable=e.isPrototypeOf=e.toLocaleString=e.toString=e.valueOf=e.__proto__=null,e},Object.create=function(t,n){var r;if(t===null)r=b();else{if(typeof t!="object")throw new TypeError("typeof prototype["+typeof t+"] != 'object'");var i=function(){};i.prototype=t,r=new i,r.__proto__=t}return n!==void 0&&Object.defineProperties(r,n),r}}if(Object.defineProperty){var E=w({}),S=typeof document=="undefined"||w(document.createElement("div"));if(!E||!S)var x=Object.defineProperty}if(!Object.defineProperty||x){var T="Property description must be an object: ",N="Object.defineProperty called on non-object: ",C="getters & setters can not be defined on this javascript engine";Object.defineProperty=function(t,n,r){if(typeof t!="object"&&typeof t!="function"||t===null)throw new TypeError(N+t);if(typeof r!="object"&&typeof r!="function"||r===null)throw new TypeError(T+r);if(x)try{return x.call(Object,t,n,r)}catch(i){}if(f(r,"value"))if(d&&(h(t,n)||p(t,n))){var s=t.__proto__;t.__proto__=o,delete t[n],t[n]=r.value,t.__proto__=s}else t[n]=r.value;else{if(!d)throw new TypeError(C);f(r,"get")&&l(t,n,r.get),f(r,"set")&&c(t,n,r.set)}return t}}Object.defineProperties||(Object.defineProperties=function(t,n){for(var r in n)f(n,r)&&Object.defineProperty(t,r,n[r]);return t}),Object.seal||(Object.seal=function(t){return t}),Object.freeze||(Object.freeze=function(t){return t});try{Object.freeze(function(){})}catch(k){Object.freeze=function(t){return function(n){return typeof n=="function"?n:t(n)}}(Object.freeze)}Object.preventExtensions||(Object.preventExtensions=function(t){return t}),Object.isSealed||(Object.isSealed=function(t){return!1}),Object.isFrozen||(Object.isFrozen=function(t){return!1}),Object.isExtensible||(Object.isExtensible=function(t){if(Object(t)===t)throw new TypeError;var n="";while(f(t,n))n+="?";t[n]=!0;var r=f(t,n);return delete t[n],r});if(!Object.keys){var L=!0,A=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],O=A.length;for(var M in{toString:null})L=!1;Object.keys=function I(e){if(typeof e!="object"&&typeof e!="function"||e===null)throw new TypeError("Object.keys called on a non-object");var I=[];for(var t in e)f(e,t)&&I.push(t);if(L)for(var n=0,r=O;n<r;n++){var i=A[n];f(e,i)&&I.push(i)}return I}}Date.now||(Date.now=function(){return(new Date).getTime()});var _=" \n\f\r \u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029\ufeff";if(!String.prototype.trim||_.trim()){_="["+_+"]";var D=new RegExp("^"+_+_+"*"),P=new RegExp(_+_+"*$");String.prototype.trim=function(){return String(this).replace(D,"").replace(P,"")}}var F=function(e){if(e==null)throw new TypeError("can't convert "+e+" to object");return Object(e)}}),ace.define("ace/lib/fixoldbrowsers",["require","exports","module","ace/lib/regexp","ace/lib/es5-shim"],function(e,t,n){"use strict";e("./regexp"),e("./es5-shim")}),ace.define("ace/lib/dom",["require","exports","module"],function(e,t,n){"use strict";var r="http://www.w3.org/1999/xhtml";t.getDocumentHead=function(e){return e||(e=document),e.head||e.getElementsByTagName("head")[0]||e.documentElement},t.createElement=function(e,t){return document.createElementNS?document.createElementNS(t||r,e):document.createElement(e)},t.hasCssClass=function(e,t){var n=(e.className+"").split(/\s+/g);return n.indexOf(t)!==-1},t.addCssClass=function(e,n){t.hasCssClass(e,n)||(e.className+=" "+n)},t.removeCssClass=function(e,t){var n=e.className.split(/\s+/g);for(;;){var r=n.indexOf(t);if(r==-1)break;n.splice(r,1)}e.className=n.join(" ")},t.toggleCssClass=function(e,t){var n=e.className.split(/\s+/g),r=!0;for(;;){var i=n.indexOf(t);if(i==-1)break;r=!1,n.splice(i,1)}return r&&n.push(t),e.className=n.join(" "),r},t.setCssClass=function(e,n,r){r?t.addCssClass(e,n):t.removeCssClass(e,n)},t.hasCssString=function(e,t){var n=0,r;t=t||document;if(t.createStyleSheet&&(r=t.styleSheets)){while(n<r.length)if(r[n++].owningElement.id===e)return!0}else if(r=t.getElementsByTagName("style"))while(n<r.length)if(r[n++].id===e)return!0;return!1},t.importCssString=function(n,r,i){i=i||document;if(r&&t.hasCssString(r,i))return null;var s;r&&(n+="\n/*# sourceURL=ace/css/"+r+" */"),i.createStyleSheet?(s=i.createStyleSheet(),s.cssText=n,r&&(s.owningElement.id=r)):(s=t.createElement("style"),s.appendChild(i.createTextNode(n)),r&&(s.id=r),t.getDocumentHead(i).appendChild(s))},t.importCssStylsheet=function(e,n){if(n.createStyleSheet)n.createStyleSheet(e);else{var r=t.createElement("link");r.rel="stylesheet",r.href=e,t.getDocumentHead(n).appendChild(r)}},t.getInnerWidth=function(e){return parseInt(t.computedStyle(e,"paddingLeft"),10)+parseInt(t.computedStyle(e,"paddingRight"),10)+e.clientWidth},t.getInnerHeight=function(e){return parseInt(t.computedStyle(e,"paddingTop"),10)+parseInt(t.computedStyle(e,"paddingBottom"),10)+e.clientHeight},t.scrollbarWidth=function(e){var n=t.createElement("ace_inner");n.style.width="100%",n.style.minWidth="0px",n.style.height="200px",n.style.display="block";var r=t.createElement("ace_outer"),i=r.style;i.position="absolute",i.left="-10000px",i.overflow="hidden",i.width="200px",i.minWidth="0px",i.height="150px",i.display="block",r.appendChild(n);var s=e.documentElement;s.appendChild(r);var o=n.offsetWidth;i.overflow="scroll";var u=n.offsetWidth;return o==u&&(u=r.clientWidth),s.removeChild(r),o-u};if(typeof document=="undefined"){t.importCssString=function(){};return}window.pageYOffset!==undefined?(t.getPageScrollTop=function(){return window.pageYOffset},t.getPageScrollLeft=function(){return window.pageXOffset}):(t.getPageScrollTop=function(){return document.body.scrollTop},t.getPageScrollLeft=function(){return document.body.scrollLeft}),window.getComputedStyle?t.computedStyle=function(e,t){return t?(window.getComputedStyle(e,"")||{})[t]||"":window.getComputedStyle(e,"")||{}}:t.computedStyle=function(e,t){return t?e.currentStyle[t]:e.currentStyle},t.setInnerHtml=function(e,t){var n=e.cloneNode(!1);return n.innerHTML=t,e.parentNode.replaceChild(n,e),n},"textContent"in document.documentElement?(t.setInnerText=function(e,t){e.textContent=t},t.getInnerText=function(e){return e.textContent}):(t.setInnerText=function(e,t){e.innerText=t},t.getInnerText=function(e){return e.innerText}),t.getParentWindow=function(e){return e.defaultView||e.parentWindow}}),ace.define("ace/lib/oop",["require","exports","module"],function(e,t,n){"use strict";t.inherits=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})},t.mixin=function(e,t){for(var n in t)e[n]=t[n];return e},t.implement=function(e,n){t.mixin(e,n)}}),ace.define("ace/lib/keys",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop"],function(e,t,n){"use strict";e("./fixoldbrowsers");var r=e("./oop"),i=function(){var e={MODIFIER_KEYS:{16:"Shift",17:"Ctrl",18:"Alt",224:"Meta"},KEY_MODS:{ctrl:1,alt:2,option:2,shift:4,"super":8,meta:8,command:8,cmd:8},FUNCTION_KEYS:{8:"Backspace",9:"Tab",13:"Return",19:"Pause",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"Print",45:"Insert",46:"Delete",96:"Numpad0",97:"Numpad1",98:"Numpad2",99:"Numpad3",100:"Numpad4",101:"Numpad5",102:"Numpad6",103:"Numpad7",104:"Numpad8",105:"Numpad9","-13":"NumpadEnter",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"Numlock",145:"Scrolllock"},PRINTABLE_KEYS:{32:" ",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",61:"=",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",107:"+",109:"-",110:".",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",111:"/",106:"*"}},t,n;for(n in e.FUNCTION_KEYS)t=e.FUNCTION_KEYS[n].toLowerCase(),e[t]=parseInt(n,10);for(n in e.PRINTABLE_KEYS)t=e.PRINTABLE_KEYS[n].toLowerCase(),e[t]=parseInt(n,10);return r.mixin(e,e.MODIFIER_KEYS),r.mixin(e,e.PRINTABLE_KEYS),r.mixin(e,e.FUNCTION_KEYS),e.enter=e["return"],e.escape=e.esc,e.del=e["delete"],e[173]="-",function(){var t=["cmd","ctrl","alt","shift"];for(var n=Math.pow(2,t.length);n--;)e.KEY_MODS[n]=t.filter(function(t){return n&e.KEY_MODS[t]}).join("-")+"-"}(),e.KEY_MODS[0]="",e.KEY_MODS[-1]="input-",e}();r.mixin(t,i),t.keyCodeToString=function(e){var t=i[e];return typeof t!="string"&&(t=String.fromCharCode(e)),t.toLowerCase()}}),ace.define("ace/lib/useragent",["require","exports","module"],function(e,t,n){"use strict";t.OS={LINUX:"LINUX",MAC:"MAC",WINDOWS:"WINDOWS"},t.getOS=function(){return t.isMac?t.OS.MAC:t.isLinux?t.OS.LINUX:t.OS.WINDOWS};if(typeof navigator!="object")return;var r=(navigator.platform.match(/mac|win|linux/i)||["other"])[0].toLowerCase(),i=navigator.userAgent;t.isWin=r=="win",t.isMac=r=="mac",t.isLinux=r=="linux",t.isIE=navigator.appName=="Microsoft Internet Explorer"||navigator.appName.indexOf("MSAppHost")>=0?parseFloat((i.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]):parseFloat((i.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]),t.isOldIE=t.isIE&&t.isIE<9,t.isGecko=t.isMozilla=(window.Controllers||window.controllers)&&window.navigator.product==="Gecko",t.isOldGecko=t.isGecko&&parseInt((i.match(/rv:(\d+)/)||[])[1],10)<4,t.isOpera=window.opera&&Object.prototype.toString.call(window.opera)=="[object Opera]",t.isWebKit=parseFloat(i.split("WebKit/")[1])||undefined,t.isChrome=parseFloat(i.split(" Chrome/")[1])||undefined,t.isAIR=i.indexOf("AdobeAIR")>=0,t.isIPad=i.indexOf("iPad")>=0,t.isTouchPad=i.indexOf("TouchPad")>=0,t.isChromeOS=i.indexOf(" CrOS ")>=0}),ace.define("ace/lib/event",["require","exports","module","ace/lib/keys","ace/lib/useragent"],function(e,t,n){"use strict";function a(e,t,n){var a=u(t);if(!i.isMac&&s){t.getModifierState&&(t.getModifierState("OS")||t.getModifierState("Win"))&&(a|=8);if(s.altGr){if((3&a)==3)return;s.altGr=0}if(n===18||n===17){var f="location"in t?t.location:t.keyLocation;if(n===17&&f===1)s[n]==1&&(o=t.timeStamp);else if(n===18&&a===3&&f===2){var l=t.timeStamp-o;l<50&&(s.altGr=!0)}}}n in r.MODIFIER_KEYS&&(n=-1),a&8&&n>=91&&n<=93&&(n=-1);if(!a&&n===13){var f="location"in t?t.location:t.keyLocation;if(f===3){e(t,a,-n);if(t.defaultPrevented)return}}if(i.isChromeOS&&a&8){e(t,a,n);if(t.defaultPrevented)return;a&=-9}return!!a||n in r.FUNCTION_KEYS||n in r.PRINTABLE_KEYS?e(t,a,n):!1}function f(){s=Object.create(null)}var r=e("./keys"),i=e("./useragent"),s=null,o=0;t.addListener=function(e,t,n){if(e.addEventListener)return e.addEventListener(t,n,!1);if(e.attachEvent){var r=function(){n.call(e,window.event)};n._wrapper=r,e.attachEvent("on"+t,r)}},t.removeListener=function(e,t,n){if(e.removeEventListener)return e.removeEventListener(t,n,!1);e.detachEvent&&e.detachEvent("on"+t,n._wrapper||n)},t.stopEvent=function(e){return t.stopPropagation(e),t.preventDefault(e),!1},t.stopPropagation=function(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},t.preventDefault=function(e){e.preventDefault?e.preventDefault():e.returnValue=!1},t.getButton=function(e){return e.type=="dblclick"?0:e.type=="contextmenu"||i.isMac&&e.ctrlKey&&!e.altKey&&!e.shiftKey?2:e.preventDefault?e.button:{1:0,2:2,4:1}[e.button]},t.capture=function(e,n,r){function i(e){n&&n(e),r&&r(e),t.removeListener(document,"mousemove",n,!0),t.removeListener(document,"mouseup",i,!0),t.removeListener(document,"dragstart",i,!0)}return t.addListener(document,"mousemove",n,!0),t.addListener(document,"mouseup",i,!0),t.addListener(document,"dragstart",i,!0),i},t.addTouchMoveListener=function(e,n){if("ontouchmove"in e){var r,i;t.addListener(e,"touchstart",function(e){var t=e.changedTouches[0];r=t.clientX,i=t.clientY}),t.addListener(e,"touchmove",function(e){var t=1,s=e.changedTouches[0];e.wheelX=-(s.clientX-r)/t,e.wheelY=-(s.clientY-i)/t,r=s.clientX,i=s.clientY,n(e)})}},t.addMouseWheelListener=function(e,n){"onmousewheel"in e?t.addListener(e,"mousewheel",function(e){var t=8;e.wheelDeltaX!==undefined?(e.wheelX=-e.wheelDeltaX/t,e.wheelY=-e.wheelDeltaY/t):(e.wheelX=0,e.wheelY=-e.wheelDelta/t),n(e)}):"onwheel"in e?t.addListener(e,"wheel",function(e){var t=.35;switch(e.deltaMode){case e.DOM_DELTA_PIXEL:e.wheelX=e.deltaX*t||0,e.wheelY=e.deltaY*t||0;break;case e.DOM_DELTA_LINE:case e.DOM_DELTA_PAGE:e.wheelX=(e.deltaX||0)*5,e.wheelY=(e.deltaY||0)*5}n(e)}):t.addListener(e,"DOMMouseScroll",function(e){e.axis&&e.axis==e.HORIZONTAL_AXIS?(e.wheelX=(e.detail||0)*5,e.wheelY=0):(e.wheelX=0,e.wheelY=(e.detail||0)*5),n(e)})},t.addMultiMouseDownListener=function(e,n,r,s){function c(e){t.getButton(e)!==0?o=0:e.detail>1?(o++,o>4&&(o=1)):o=1;if(i.isIE){var c=Math.abs(e.clientX-u)>5||Math.abs(e.clientY-a)>5;if(!f||c)o=1;f&&clearTimeout(f),f=setTimeout(function(){f=null},n[o-1]||600),o==1&&(u=e.clientX,a=e.clientY)}e._clicks=o,r[s]("mousedown",e);if(o>4)o=0;else if(o>1)return r[s](l[o],e)}function h(e){o=2,f&&clearTimeout(f),f=setTimeout(function(){f=null},n[o-1]||600),r[s]("mousedown",e),r[s](l[o],e)}var o=0,u,a,f,l={2:"dblclick",3:"tripleclick",4:"quadclick"};Array.isArray(e)||(e=[e]),e.forEach(function(e){t.addListener(e,"mousedown",c),i.isOldIE&&t.addListener(e,"dblclick",h)})};var u=!i.isMac||!i.isOpera||"KeyboardEvent"in window?function(e){return 0|(e.ctrlKey?1:0)|(e.altKey?2:0)|(e.shiftKey?4:0)|(e.metaKey?8:0)}:function(e){return 0|(e.metaKey?1:0)|(e.altKey?2:0)|(e.shiftKey?4:0)|(e.ctrlKey?8:0)};t.getModifierString=function(e){return r.KEY_MODS[u(e)]},t.addCommandKeyListener=function(e,n){var r=t.addListener;if(i.isOldGecko||i.isOpera&&!("KeyboardEvent"in window)){var o=null;r(e,"keydown",function(e){o=e.keyCode}),r(e,"keypress",function(e){return a(n,e,o)})}else{var u=null;r(e,"keydown",function(e){s[e.keyCode]=(s[e.keyCode]||0)+1;var t=a(n,e,e.keyCode);return u=e.defaultPrevented,t}),r(e,"keypress",function(e){u&&(e.ctrlKey||e.altKey||e.shiftKey||e.metaKey)&&(t.stopEvent(e),u=null)}),r(e,"keyup",function(e){s[e.keyCode]=null}),s||(f(),r(window,"focus",f))}};if(typeof window=="object"&&window.postMessage&&!i.isOldIE){var l=1;t.nextTick=function(e,n){n=n||window;var r="zero-timeout-message-"+l;t.addListener(n,"message",function i(s){s.data==r&&(t.stopPropagation(s),t.removeListener(n,"message",i),e())}),n.postMessage(r,"*")}}t.nextFrame=typeof window=="object"&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame),t.nextFrame?t.nextFrame=t.nextFrame.bind(window):t.nextFrame=function(e){setTimeout(e,17)}}),ace.define("ace/lib/lang",["require","exports","module"],function(e,t,n){"use strict";t.last=function(e){return e[e.length-1]},t.stringReverse=function(e){return e.split("").reverse().join("")},t.stringRepeat=function(e,t){var n="";while(t>0){t&1&&(n+=e);if(t>>=1)e+=e}return n};var r=/^\s\s*/,i=/\s\s*$/;t.stringTrimLeft=function(e){return e.replace(r,"")},t.stringTrimRight=function(e){return e.replace(i,"")},t.copyObject=function(e){var t={};for(var n in e)t[n]=e[n];return t},t.copyArray=function(e){var t=[];for(var n=0,r=e.length;n<r;n++)e[n]&&typeof e[n]=="object"?t[n]=this.copyObject(e[n]):t[n]=e[n];return t},t.deepCopy=function s(e){if(typeof e!="object"||!e)return e;var t;if(Array.isArray(e)){t=[];for(var n=0;n<e.length;n++)t[n]=s(e[n]);return t}if(Object.prototype.toString.call(e)!=="[object Object]")return e;t={};for(var n in e)t[n]=s(e[n]);return t},t.arrayToMap=function(e){var t={};for(var n=0;n<e.length;n++)t[e[n]]=1;return t},t.createMap=function(e){var t=Object.create(null);for(var n in e)t[n]=e[n];return t},t.arrayRemove=function(e,t){for(var n=0;n<=e.length;n++)t===e[n]&&e.splice(n,1)},t.escapeRegExp=function(e){return e.replace(/([.*+?^${}()|[\]\/\\])/g,"\\$1")},t.escapeHTML=function(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<")},t.getMatchOffsets=function(e,t){var n=[];return e.replace(t,function(e){n.push({offset:arguments[arguments.length-2],length:e.length})}),n},t.deferredCall=function(e){var t=null,n=function(){t=null,e()},r=function(e){return r.cancel(),t=setTimeout(n,e||0),r};return r.schedule=r,r.call=function(){return this.cancel(),e(),r},r.cancel=function(){return clearTimeout(t),t=null,r},r.isPending=function(){return t},r},t.delayedCall=function(e,t){var n=null,r=function(){n=null,e()},i=function(e){n==null&&(n=setTimeout(r,e||t))};return i.delay=function(e){n&&clearTimeout(n),n=setTimeout(r,e||t)},i.schedule=i,i.call=function(){this.cancel(),e()},i.cancel=function(){n&&clearTimeout(n),n=null},i.isPending=function(){return n},i}}),ace.define("ace/keyboard/textinput",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/dom","ace/lib/lang"],function(e,t,n){"use strict";var r=e("../lib/event"),i=e("../lib/useragent"),s=e("../lib/dom"),o=e("../lib/lang"),u=i.isChrome<18,a=i.isIE,f=function(e,t){function b(e){if(h)return;h=!0;if(k)t=0,r=e?0:n.value.length-1;else var t=e?2:1,r=2;try{n.setSelectionRange(t,r)}catch(i){}h=!1}function w(){if(h)return;n.value=f,i.isWebKit&&y.schedule()}function R(){clearTimeout(q),q=setTimeout(function(){p&&(n.style.cssText=p,p=""),t.renderer.$keepTextAreaAtCursor==null&&(t.renderer.$keepTextAreaAtCursor=!0,t.renderer.$moveTextAreaToCursor())},i.isOldIE?200:0)}var n=s.createElement("textarea");n.className="ace_text-input",i.isTouchPad&&n.setAttribute("x-palm-disable-auto-cap",!0),n.setAttribute("wrap","off"),n.setAttribute("autocorrect","off"),n.setAttribute("autocapitalize","off"),n.setAttribute("spellcheck",!1),n.style.opacity="0",i.isOldIE&&(n.style.top="-1000px"),e.insertBefore(n,e.firstChild);var f="",l=!1,c=!1,h=!1,p="",d=!0;try{var v=document.activeElement===n}catch(m){}r.addListener(n,"blur",function(e){t.onBlur(e),v=!1}),r.addListener(n,"focus",function(e){v=!0,t.onFocus(e),b()}),this.focus=function(){if(p)return n.focus();var e=n.style.top;n.style.position="fixed",n.style.top="0px",n.focus(),setTimeout(function(){n.style.position="",n.style.top=="0px"&&(n.style.top=e)},0)},this.blur=function(){n.blur()},this.isFocused=function(){return v};var g=o.delayedCall(function(){v&&b(d)}),y=o.delayedCall(function(){h||(n.value=f,v&&b())});i.isWebKit||t.addEventListener("changeSelection",function(){t.selection.isEmpty()!=d&&(d=!d,g.schedule())}),w(),v&&t.onFocus();var E=function(e){return e.selectionStart===0&&e.selectionEnd===e.value.length};!n.setSelectionRange&&n.createTextRange&&(n.setSelectionRange=function(e,t){var n=this.createTextRange();n.collapse(!0),n.moveStart("character",e),n.moveEnd("character",t),n.select()},E=function(e){try{var t=e.ownerDocument.selection.createRange()}catch(n){}return!t||t.parentElement()!=e?!1:t.text==e.value});if(i.isOldIE){var S=!1,x=function(e){if(S)return;var t=n.value;if(h||!t||t==f)return;if(e&&t==f[0])return T.schedule();A(t),S=!0,w(),S=!1},T=o.delayedCall(x);r.addListener(n,"propertychange",x);var N={13:1,27:1};r.addListener(n,"keyup",function(e){h&&(!n.value||N[e.keyCode])&&setTimeout(F,0);if((n.value.charCodeAt(0)||0)<129)return T.call();h?j():B()}),r.addListener(n,"keydown",function(e){T.schedule(50)})}var C=function(e){l?l=!1:E(n)?(t.selectAll(),b()):k&&b(t.selection.isEmpty())},k=null;this.setInputHandler=function(e){k=e},this.getInputHandler=function(){return k};var L=!1,A=function(e){k&&(e=k(e),k=null),c?(b(),e&&t.onPaste(e),c=!1):e==f.charAt(0)?L?t.execCommand("del",{source:"ace"}):t.execCommand("backspace",{source:"ace"}):(e.substring(0,2)==f?e=e.substr(2):e.charAt(0)==f.charAt(0)?e=e.substr(1):e.charAt(e.length-1)==f.charAt(0)&&(e=e.slice(0,-1)),e.charAt(e.length-1)==f.charAt(0)&&(e=e.slice(0,-1)),e&&t.onTextInput(e)),L&&(L=!1)},O=function(e){if(h)return;var t=n.value;A(t),w()},M=function(e,t,n){var r=e.clipboardData||window.clipboardData;if(!r||u)return;var i=a||n?"Text":"text/plain";try{return t?r.setData(i,t)!==!1:r.getData(i)}catch(e){if(!n)return M(e,t,!0)}},_=function(e,i){var s=t.getCopyText();if(!s)return r.preventDefault(e);M(e,s)?(i?t.onCut():t.onCopy(),r.preventDefault(e)):(l=!0,n.value=s,n.select(),setTimeout(function(){l=!1,w(),b(),i?t.onCut():t.onCopy()}))},D=function(e){_(e,!0)},P=function(e){_(e,!1)},H=function(e){var s=M(e);typeof s=="string"?(s&&t.onPaste(s,e),i.isIE&&setTimeout(b),r.preventDefault(e)):(n.value="",c=!0)};r.addCommandKeyListener(n,t.onCommandKey.bind(t)),r.addListener(n,"select",C),r.addListener(n,"input",O),r.addListener(n,"cut",D),r.addListener(n,"copy",P),r.addListener(n,"paste",H),(!("oncut"in n)||!("oncopy"in n)||!("onpaste"in n))&&r.addListener(e,"keydown",function(e){if(i.isMac&&!e.metaKey||!e.ctrlKey)return;switch(e.keyCode){case 67:P(e);break;case 86:H(e);break;case 88:D(e)}});var B=function(e){if(h||!t.onCompositionStart||t.$readOnly)return;h={},h.canUndo=t.session.$undoManager,t.onCompositionStart(),setTimeout(j,0),t.on("mousedown",F),h.canUndo&&!t.selection.isEmpty()&&(t.insert(""),t.session.markUndoGroup(),t.selection.clearSelection()),t.session.markUndoGroup()},j=function(){if(!h||!t.onCompositionUpdate||t.$readOnly)return;var e=n.value.replace(/\x01/g,"");if(h.lastValue===e)return;t.onCompositionUpdate(e),h.lastValue&&t.undo(),h.canUndo&&(h.lastValue=e);if(h.lastValue){var r=t.selection.getRange();t.insert(h.lastValue),t.session.markUndoGroup(),h.range=t.selection.getRange(),t.selection.setRange(r),t.selection.clearSelection()}},F=function(e){if(!t.onCompositionEnd||t.$readOnly)return;var r=h;h=!1;var i=setTimeout(function(){i=null;var e=n.value.replace(/\x01/g,"");if(h)return;e==r.lastValue?w():!r.lastValue&&e&&(w(),A(e))});k=function(n){return i&&clearTimeout(i),n=n.replace(/\x01/g,""),n==r.lastValue?"":(r.lastValue&&i&&t.undo(),n)},t.onCompositionEnd(),t.removeListener("mousedown",F),e.type=="compositionend"&&r.range&&t.selection.setRange(r.range)},I=o.delayedCall(j,50);r.addListener(n,"compositionstart",B),i.isGecko?r.addListener(n,"text",function(){I.schedule()}):(r.addListener(n,"keyup",function(){I.schedule()}),r.addListener(n,"keydown",function(){I.schedule()})),r.addListener(n,"compositionend",F),this.getElement=function(){return n},this.setReadOnly=function(e){n.readOnly=e},this.onContextMenu=function(e){L=!0,b(t.selection.isEmpty()),t._emit("nativecontextmenu",{target:t,domEvent:e}),this.moveToMouse(e,!0)},this.moveToMouse=function(e,o){if(!o&&i.isOldIE)return;p||(p=n.style.cssText),n.style.cssText=(o?"z-index:100000;":"")+"height:"+n.style.height+";"+(i.isIE?"opacity:0.1;":"");var u=t.container.getBoundingClientRect(),a=s.computedStyle(t.container),f=u.top+(parseInt(a.borderTopWidth)||0),l=u.left+(parseInt(u.borderLeftWidth)||0),c=u.bottom-f-n.clientHeight-2,h=function(e){n.style.left=e.clientX-l-2+"px",n.style.top=Math.min(e.clientY-f-2,c)+"px"};h(e);if(e.type!="mousedown")return;t.renderer.$keepTextAreaAtCursor&&(t.renderer.$keepTextAreaAtCursor=null),clearTimeout(q),i.isWin&&!i.isOldIE&&r.capture(t.container,h,R)},this.onContextMenuClose=R;var q,U=function(e){t.textInput.onContextMenu(e),R()};r.addListener(n,"mouseup",U),r.addListener(n,"mousedown",function(e){e.preventDefault(),R()}),r.addListener(t.renderer.scroller,"contextmenu",U),r.addListener(n,"contextmenu",U)};t.TextInput=f}),ace.define("ace/mouse/default_handlers",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"],function(e,t,n){"use strict";function u(e){e.$clickSelection=null;var t=e.editor;t.setDefaultHandler("mousedown",this.onMouseDown.bind(e)),t.setDefaultHandler("dblclick",this.onDoubleClick.bind(e)),t.setDefaultHandler("tripleclick",this.onTripleClick.bind(e)),t.setDefaultHandler("quadclick",this.onQuadClick.bind(e)),t.setDefaultHandler("mousewheel",this.onMouseWheel.bind(e)),t.setDefaultHandler("touchmove",this.onTouchMove.bind(e));var n=["select","startSelect","selectEnd","selectAllEnd","selectByWordsEnd","selectByLinesEnd","dragWait","dragWaitEnd","focusWait"];n.forEach(function(t){e[t]=this[t]},this),e.selectByLines=this.extendSelectionBy.bind(e,"getLineRange"),e.selectByWords=this.extendSelectionBy.bind(e,"getWordRange")}function a(e,t,n,r){return Math.sqrt(Math.pow(n-e,2)+Math.pow(r-t,2))}function f(e,t){if(e.start.row==e.end.row)var n=2*t.column-e.start.column-e.end.column;else if(e.start.row==e.end.row-1&&!e.start.column&&!e.end.column)var n=t.column-4;else var n=2*t.row-e.start.row-e.end.row;return n<0?{cursor:e.start,anchor:e.end}:{cursor:e.end,anchor:e.start}}var r=e("../lib/dom"),i=e("../lib/event"),s=e("../lib/useragent"),o=0;(function(){this.onMouseDown=function(e){var t=e.inSelection(),n=e.getDocumentPosition();this.mousedownEvent=e;var r=this.editor,i=e.getButton();if(i!==0){var s=r.getSelectionRange(),o=s.isEmpty();r.$blockScrolling++,(o||i==1)&&r.selection.moveToPosition(n),r.$blockScrolling--,i==2&&r.textInput.onContextMenu(e.domEvent);return}this.mousedownEvent.time=Date.now();if(t&&!r.isFocused()){r.focus();if(this.$focusTimout&&!this.$clickSelection&&!r.inMultiSelectMode){this.setState("focusWait"),this.captureMouse(e);return}}return this.captureMouse(e),this.startSelect(n,e.domEvent._clicks>1),e.preventDefault()},this.startSelect=function(e,t){e=e||this.editor.renderer.screenToTextCoordinates(this.x,this.y);var n=this.editor;n.$blockScrolling++,this.mousedownEvent.getShiftKey()?n.selection.selectToPosition(e):t||n.selection.moveToPosition(e),t||this.select(),n.renderer.scroller.setCapture&&n.renderer.scroller.setCapture(),n.setStyle("ace_selecting"),this.setState("select"),n.$blockScrolling--},this.select=function(){var e,t=this.editor,n=t.renderer.screenToTextCoordinates(this.x,this.y);t.$blockScrolling++;if(this.$clickSelection){var r=this.$clickSelection.comparePoint(n);if(r==-1)e=this.$clickSelection.end;else if(r==1)e=this.$clickSelection.start;else{var i=f(this.$clickSelection,n);n=i.cursor,e=i.anchor}t.selection.setSelectionAnchor(e.row,e.column)}t.selection.selectToPosition(n),t.$blockScrolling--,t.renderer.scrollCursorIntoView()},this.extendSelectionBy=function(e){var t,n=this.editor,r=n.renderer.screenToTextCoordinates(this.x,this.y),i=n.selection[e](r.row,r.column);n.$blockScrolling++;if(this.$clickSelection){var s=this.$clickSelection.comparePoint(i.start),o=this.$clickSelection.comparePoint(i.end);if(s==-1&&o<=0){t=this.$clickSelection.end;if(i.end.row!=r.row||i.end.column!=r.column)r=i.start}else if(o==1&&s>=0){t=this.$clickSelection.start;if(i.start.row!=r.row||i.start.column!=r.column)r=i.end}else if(s==-1&&o==1)r=i.end,t=i.start;else{var u=f(this.$clickSelection,r);r=u.cursor,t=u.anchor}n.selection.setSelectionAnchor(t.row,t.column)}n.selection.selectToPosition(r),n.$blockScrolling--,n.renderer.scrollCursorIntoView()},this.selectEnd=this.selectAllEnd=this.selectByWordsEnd=this.selectByLinesEnd=function(){this.$clickSelection=null,this.editor.unsetStyle("ace_selecting"),this.editor.renderer.scroller.releaseCapture&&this.editor.renderer.scroller.releaseCapture()},this.focusWait=function(){var e=a(this.mousedownEvent.x,this.mousedownEvent.y,this.x,this.y),t=Date.now();(e>o||t-this.mousedownEvent.time>this.$focusTimout)&&this.startSelect(this.mousedownEvent.getDocumentPosition())},this.onDoubleClick=function(e){var t=e.getDocumentPosition(),n=this.editor,r=n.session,i=r.getBracketRange(t);i?(i.isEmpty()&&(i.start.column--,i.end.column++),this.setState("select")):(i=n.selection.getWordRange(t.row,t.column),this.setState("selectByWords")),this.$clickSelection=i,this.select()},this.onTripleClick=function(e){var t=e.getDocumentPosition(),n=this.editor;this.setState("selectByLines");var r=n.getSelectionRange();r.isMultiLine()&&r.contains(t.row,t.column)?(this.$clickSelection=n.selection.getLineRange(r.start.row),this.$clickSelection.end=n.selection.getLineRange(r.end.row).end):this.$clickSelection=n.selection.getLineRange(t.row),this.select()},this.onQuadClick=function(e){var t=this.editor;t.selectAll(),this.$clickSelection=t.getSelectionRange(),this.setState("selectAll")},this.onMouseWheel=function(e){if(e.getAccelKey())return;e.getShiftKey()&&e.wheelY&&!e.wheelX&&(e.wheelX=e.wheelY,e.wheelY=0);var t=e.domEvent.timeStamp,n=t-(this.$lastScrollTime||0),r=this.editor,i=r.renderer.isScrollableBy(e.wheelX*e.speed,e.wheelY*e.speed);if(i||n<200)return this.$lastScrollTime=t,r.renderer.scrollBy(e.wheelX*e.speed,e.wheelY*e.speed),e.stop()},this.onTouchMove=function(e){var t=e.domEvent.timeStamp,n=t-(this.$lastScrollTime||0),r=this.editor,i=r.renderer.isScrollableBy(e.wheelX*e.speed,e.wheelY*e.speed);if(i||n<200)return this.$lastScrollTime=t,r.renderer.scrollBy(e.wheelX*e.speed,e.wheelY*e.speed),e.stop()}}).call(u.prototype),t.DefaultHandlers=u}),ace.define("ace/tooltip",["require","exports","module","ace/lib/oop","ace/lib/dom"],function(e,t,n){"use strict";function s(e){this.isOpen=!1,this.$element=null,this.$parentNode=e}var r=e("./lib/oop"),i=e("./lib/dom");(function(){this.$init=function(){return this.$element=i.createElement("div"),this.$element.className="ace_tooltip",this.$element.style.display="none",this.$parentNode.appendChild(this.$element),this.$element},this.getElement=function(){return this.$element||this.$init()},this.setText=function(e){i.setInnerText(this.getElement(),e)},this.setHtml=function(e){this.getElement().innerHTML=e},this.setPosition=function(e,t){this.getElement().style.left=e+"px",this.getElement().style.top=t+"px"},this.setClassName=function(e){i.addCssClass(this.getElement(),e)},this.show=function(e,t,n){e!=null&&this.setText(e),t!=null&&n!=null&&this.setPosition(t,n),this.isOpen||(this.getElement().style.display="block",this.isOpen=!0)},this.hide=function(){this.isOpen&&(this.getElement().style.display="none",this.isOpen=!1)},this.getHeight=function(){return this.getElement().offsetHeight},this.getWidth=function(){return this.getElement().offsetWidth}}).call(s.prototype),t.Tooltip=s}),ace.define("ace/mouse/default_gutter_handler",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event","ace/tooltip"],function(e,t,n){"use strict";function u(e){function l(){var r=u.getDocumentPosition().row,s=n.$annotations[r];if(!s)return c();var o=t.session.getLength();if(r==o){var a=t.renderer.pixelToScreenCoordinates(0,u.y).row,l=u.$pos;if(a>t.session.documentToScreenRow(l.row,l.column))return c()}if(f==s)return;f=s.text.join("<br/>"),i.setHtml(f),i.show(),t._signal("showGutterTooltip",i),t.on("mousewheel",c);if(e.$tooltipFollowsMouse)h(u);else{var p=u.domEvent.target,d=p.getBoundingClientRect(),v=i.getElement().style;v.left=d.right+"px",v.top=d.bottom+"px"}}function c(){o&&(o=clearTimeout(o)),f&&(i.hide(),f=null,t._signal("hideGutterTooltip",i),t.removeEventListener("mousewheel",c))}function h(e){i.setPosition(e.x,e.y)}var t=e.editor,n=t.renderer.$gutterLayer,i=new a(t.container);e.editor.setDefaultHandler("guttermousedown",function(r){if(!t.isFocused()||r.getButton()!=0)return;var i=n.getRegion(r);if(i=="foldWidgets")return;var s=r.getDocumentPosition().row,o=t.session.selection;if(r.getShiftKey())o.selectTo(s,0);else{if(r.domEvent.detail==2)return t.selectAll(),r.preventDefault();e.$clickSelection=t.selection.getLineRange(s)}return e.setState("selectByLines"),e.captureMouse(r),r.preventDefault()});var o,u,f;e.editor.setDefaultHandler("guttermousemove",function(t){var n=t.domEvent.target||t.domEvent.srcElement;if(r.hasCssClass(n,"ace_fold-widget"))return c();f&&e.$tooltipFollowsMouse&&h(t),u=t;if(o)return;o=setTimeout(function(){o=null,u&&!e.isMousePressed?l():c()},50)}),s.addListener(t.renderer.$gutter,"mouseout",function(e){u=null;if(!f||o)return;o=setTimeout(function(){o=null,c()},50)}),t.on("changeSession",c)}function a(e){o.call(this,e)}var r=e("../lib/dom"),i=e("../lib/oop"),s=e("../lib/event"),o=e("../tooltip").Tooltip;i.inherits(a,o),function(){this.setPosition=function(e,t){var n=window.innerWidth||document.documentElement.clientWidth,r=window.innerHeight||document.documentElement.clientHeight,i=this.getWidth(),s=this.getHeight();e+=15,t+=15,e+i>n&&(e-=e+i-n),t+s>r&&(t-=20+s),o.prototype.setPosition.call(this,e,t)}}.call(a.prototype),t.GutterHandler=u}),ace.define("ace/mouse/mouse_event",["require","exports","module","ace/lib/event","ace/lib/useragent"],function(e,t,n){"use strict";var r=e("../lib/event"),i=e("../lib/useragent"),s=t.MouseEvent=function(e,t){this.domEvent=e,this.editor=t,this.x=this.clientX=e.clientX,this.y=this.clientY=e.clientY,this.$pos=null,this.$inSelection=null,this.propagationStopped=!1,this.defaultPrevented=!1};(function(){this.stopPropagation=function(){r.stopPropagation(this.domEvent),this.propagationStopped=!0},this.preventDefault=function(){r.preventDefault(this.domEvent),this.defaultPrevented=!0},this.stop=function(){this.stopPropagation(),this.preventDefault()},this.getDocumentPosition=function(){return this.$pos?this.$pos:(this.$pos=this.editor.renderer.screenToTextCoordinates(this.clientX,this.clientY),this.$pos)},this.inSelection=function(){if(this.$inSelection!==null)return this.$inSelection;var e=this.editor,t=e.getSelectionRange();if(t.isEmpty())this.$inSelection=!1;else{var n=this.getDocumentPosition();this.$inSelection=t.contains(n.row,n.column)}return this.$inSelection},this.getButton=function(){return r.getButton(this.domEvent)},this.getShiftKey=function(){return this.domEvent.shiftKey},this.getAccelKey=i.isMac?function(){return this.domEvent.metaKey}:function(){return this.domEvent.ctrlKey}}).call(s.prototype)}),ace.define("ace/mouse/dragdrop_handler",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"],function(e,t,n){"use strict";function f(e){function T(e,n){var r=Date.now(),i=!n||e.row!=n.row,s=!n||e.column!=n.column;if(!S||i||s)t.$blockScrolling+=1,t.moveCursorToPosition(e),t.$blockScrolling-=1,S=r,x={x:p,y:d};else{var o=l(x.x,x.y,p,d);o>a?S=null:r-S>=u&&(t.renderer.scrollCursorIntoView(),S=null)}}function N(e,n){var r=Date.now(),i=t.renderer.layerConfig.lineHeight,s=t.renderer.layerConfig.characterWidth,u=t.renderer.scroller.getBoundingClientRect(),a={x:{left:p-u.left,right:u.right-p},y:{top:d-u.top,bottom:u.bottom-d}},f=Math.min(a.x.left,a.x.right),l=Math.min(a.y.top,a.y.bottom),c={row:e.row,column:e.column};f/s<=2&&(c.column+=a.x.left<a.x.right?-3:2),l/i<=1&&(c.row+=a.y.top<a.y.bottom?-1:1);var h=e.row!=c.row,v=e.column!=c.column,m=!n||e.row!=n.row;h||v&&!m?E?r-E>=o&&t.renderer.scrollCursorIntoView(c):E=r:E=null}function C(){var e=g;g=t.renderer.screenToTextCoordinates(p,d),T(g,e),N(g,e)}function k(){m=t.selection.toOrientedRange(),h=t.session.addMarker(m,"ace_selection",t.getSelectionStyle()),t.clearSelection(),t.isFocused()&&t.renderer.$cursorLayer.setBlinking(!1),clearInterval(v),C(),v=setInterval(C,20),y=0,i.addListener(document,"mousemove",O)}function L(){clearInterval(v),t.session.removeMarker(h),h=null,t.$blockScrolling+=1,t.selection.fromOrientedRange(m),t.$blockScrolling-=1,t.isFocused()&&!w&&t.renderer.$cursorLayer.setBlinking(!t.getReadOnly()),m=null,g=null,y=0,E=null,S=null,i.removeListener(document,"mousemove",O)}function O(){A==null&&(A=setTimeout(function(){A!=null&&h&&L()},20))}function M(e){var t=e.types;return!t||Array.prototype.some.call(t,function(e){return e=="text/plain"||e=="Text"})}function _(e){var t=["copy","copymove","all","uninitialized"],n=["move","copymove","linkmove","all","uninitialized"],r=s.isMac?e.altKey:e.ctrlKey,i="uninitialized";try{i=e.dataTransfer.effectAllowed.toLowerCase()}catch(e){}var o="none";return r&&t.indexOf(i)>=0?o="copy":n.indexOf(i)>=0?o="move":t.indexOf(i)>=0&&(o="copy"),o}var t=e.editor,n=r.createElement("img");n.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",s.isOpera&&(n.style.cssText="width:1px;height:1px;position:fixed;top:0;left:0;z-index:2147483647;opacity:0;");var f=["dragWait","dragWaitEnd","startDrag","dragReadyEnd","onMouseDrag"];f.forEach(function(t){e[t]=this[t]},this),t.addEventListener("mousedown",this.onMouseDown.bind(e));var c=t.container,h,p,d,v,m,g,y=0,b,w,E,S,x;this.onDragStart=function(e){if(this.cancelDrag||!c.draggable){var r=this;return setTimeout(function(){r.startSelect(),r.captureMouse(e)},0),e.preventDefault()}m=t.getSelectionRange();var i=e.dataTransfer;i.effectAllowed=t.getReadOnly()?"copy":"copyMove",s.isOpera&&(t.container.appendChild(n),n.scrollTop=0),i.setDragImage&&i.setDragImage(n,0,0),s.isOpera&&t.container.removeChild(n),i.clearData(),i.setData("Text",t.session.getTextRange()),w=!0,this.setState("drag")},this.onDragEnd=function(e){c.draggable=!1,w=!1,this.setState(null);if(!t.getReadOnly()){var n=e.dataTransfer.dropEffect;!b&&n=="move"&&t.session.remove(t.getSelectionRange()),t.renderer.$cursorLayer.setBlinking(!0)}this.editor.unsetStyle("ace_dragging"),this.editor.renderer.setCursorStyle("")},this.onDragEnter=function(e){if(t.getReadOnly()||!M(e.dataTransfer))return;return p=e.clientX,d=e.clientY,h||k(),y++,e.dataTransfer.dropEffect=b=_(e),i.preventDefault(e)},this.onDragOver=function(e){if(t.getReadOnly()||!M(e.dataTransfer))return;return p=e.clientX,d=e.clientY,h||(k(),y++),A!==null&&(A=null),e.dataTransfer.dropEffect=b=_(e),i.preventDefault(e)},this.onDragLeave=function(e){y--;if(y<=0&&h)return L(),b=null,i.preventDefault(e)},this.onDrop=function(e){if(!g)return;var n=e.dataTransfer;if(w)switch(b){case"move":m.contains(g.row,g.column)?m={start:g,end:g}:m=t.moveText(m,g);break;case"copy":m=t.moveText(m,g,!0)}else{var r=n.getData("Text");m={start:g,end:t.session.insert(g,r)},t.focus(),b=null}return L(),i.preventDefault(e)},i.addListener(c,"dragstart",this.onDragStart.bind(e)),i.addListener(c,"dragend",this.onDragEnd.bind(e)),i.addListener(c,"dragenter",this.onDragEnter.bind(e)),i.addListener(c,"dragover",this.onDragOver.bind(e)),i.addListener(c,"dragleave",this.onDragLeave.bind(e)),i.addListener(c,"drop",this.onDrop.bind(e));var A=null}function l(e,t,n,r){return Math.sqrt(Math.pow(n-e,2)+Math.pow(r-t,2))}var r=e("../lib/dom"),i=e("../lib/event"),s=e("../lib/useragent"),o=200,u=200,a=5;(function(){this.dragWait=function(){var e=Date.now()-this.mousedownEvent.time;e>this.editor.getDragDelay()&&this.startDrag()},this.dragWaitEnd=function(){var e=this.editor.container;e.draggable=!1,this.startSelect(this.mousedownEvent.getDocumentPosition()),this.selectEnd()},this.dragReadyEnd=function(e){this.editor.renderer.$cursorLayer.setBlinking(!this.editor.getReadOnly()),this.editor.unsetStyle("ace_dragging"),this.editor.renderer.setCursorStyle(""),this.dragWaitEnd()},this.startDrag=function(){this.cancelDrag=!1;var e=this.editor,t=e.container;t.draggable=!0,e.renderer.$cursorLayer.setBlinking(!1),e.setStyle("ace_dragging");var n=s.isWin?"default":"move";e.renderer.setCursorStyle(n),this.setState("dragReady")},this.onMouseDrag=function(e){var t=this.editor.container;if(s.isIE&&this.state=="dragReady"){var n=l(this.mousedownEvent.x,this.mousedownEvent.y,this.x,this.y);n>3&&t.dragDrop()}if(this.state==="dragWait"){var n=l(this.mousedownEvent.x,this.mousedownEvent.y,this.x,this.y);n>0&&(t.draggable=!1,this.startSelect(this.mousedownEvent.getDocumentPosition()))}},this.onMouseDown=function(e){if(!this.$dragEnabled)return;this.mousedownEvent=e;var t=this.editor,n=e.inSelection(),r=e.getButton(),i=e.domEvent.detail||1;if(i===1&&r===0&&n){if(e.editor.inMultiSelectMode&&(e.getAccelKey()||e.getShiftKey()))return;this.mousedownEvent.time=Date.now();var o=e.domEvent.target||e.domEvent.srcElement;"unselectable"in o&&(o.unselectable="on");if(t.getDragDelay()){if(s.isWebKit){this.cancelDrag=!0;var u=t.container;u.draggable=!0}this.setState("dragWait")}else this.startDrag();this.captureMouse(e,this.onMouseDrag.bind(this)),e.defaultPrevented=!0}}}).call(f.prototype),t.DragdropHandler=f}),ace.define("ace/lib/net",["require","exports","module","ace/lib/dom"],function(e,t,n){"use strict";var r=e("./dom");t.get=function(e,t){var n=new XMLHttpRequest;n.open("GET",e,!0),n.onreadystatechange=function(){n.readyState===4&&t(n.responseText)},n.send(null)},t.loadScript=function(e,t){var n=r.getDocumentHead(),i=document.createElement("script");i.src=e,n.appendChild(i),i.onload=i.onreadystatechange=function(e,n){if(n||!i.readyState||i.readyState=="loaded"||i.readyState=="complete")i=i.onload=i.onreadystatechange=null,n||t()}},t.qualifyURL=function(e){var t=document.createElement("a");return t.href=e,t.href}}),ace.define("ace/lib/event_emitter",["require","exports","module"],function(e,t,n){"use strict";var r={},i=function(){this.propagationStopped=!0},s=function(){this.defaultPrevented=!0};r._emit=r._dispatchEvent=function(e,t){this._eventRegistry||(this._eventRegistry={}),this._defaultHandlers||(this._defaultHandlers={});var n=this._eventRegistry[e]||[],r=this._defaultHandlers[e];if(!n.length&&!r)return;if(typeof t!="object"||!t)t={};t.type||(t.type=e),t.stopPropagation||(t.stopPropagation=i),t.preventDefault||(t.preventDefault=s),n=n.slice();for(var o=0;o<n.length;o++){n[o](t,this);if(t.propagationStopped)break}if(r&&!t.defaultPrevented)return r(t,this)},r._signal=function(e,t){var n=(this._eventRegistry||{})[e];if(!n)return;n=n.slice();for(var r=0;r<n.length;r++)n[r](t,this)},r.once=function(e,t){var n=this;t&&this.addEventListener(e,function r(){n.removeEventListener(e,r),t.apply(null,arguments)})},r.setDefaultHandler=function(e,t){var n=this._defaultHandlers;n||(n=this._defaultHandlers={_disabled_:{}});if(n[e]){var r=n[e],i=n._disabled_[e];i||(n._disabled_[e]=i=[]),i.push(r);var s=i.indexOf(t);s!=-1&&i.splice(s,1)}n[e]=t},r.removeDefaultHandler=function(e,t){var n=this._defaultHandlers;if(!n)return;var r=n._disabled_[e];if(n[e]==t){var i=n[e];r&&this.setDefaultHandler(e,r.pop())}else if(r){var s=r.indexOf(t);s!=-1&&r.splice(s,1)}},r.on=r.addEventListener=function(e,t,n){this._eventRegistry=this._eventRegistry||{};var r=this._eventRegistry[e];return r||(r=this._eventRegistry[e]=[]),r.indexOf(t)==-1&&r[n?"unshift":"push"](t),t},r.off=r.removeListener=r.removeEventListener=function(e,t){this._eventRegistry=this._eventRegistry||{};var n=this._eventRegistry[e];if(!n)return;var r=n.indexOf(t);r!==-1&&n.splice(r,1)},r.removeAllListeners=function(e){this._eventRegistry&&(this._eventRegistry[e]=[])},t.EventEmitter=r}),ace.define("ace/lib/app_config",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"],function(e,t,n){"no use strict";function o(e){typeof console!="undefined"&&console.warn&&console.warn.apply(console,arguments)}function u(e,t){var n=new Error(e);n.data=t,typeof console=="object"&&console.error&&console.error(n),setTimeout(function(){throw n})}var r=e("./oop"),i=e("./event_emitter").EventEmitter,s={setOptions:function(e){Object.keys(e).forEach(function(t){this.setOption(t,e[t])},this)},getOptions:function(e){var t={};return e?Array.isArray(e)||(t=e,e=Object.keys(t)):e=Object.keys(this.$options),e.forEach(function(e){t[e]=this.getOption(e)},this),t},setOption:function(e,t){if(this["$"+e]===t)return;var n=this.$options[e];if(!n)return o('misspelled option "'+e+'"');if(n.forwardTo)return this[n.forwardTo]&&this[n.forwardTo].setOption(e,t);n.handlesSet||(this["$"+e]=t),n&&n.set&&n.set.call(this,t)},getOption:function(e){var t=this.$options[e];return t?t.forwardTo?this[t.forwardTo]&&this[t.forwardTo].getOption(e):t&&t.get?t.get.call(this):this["$"+e]:o('misspelled option "'+e+'"')}},a=function(){this.$defaultOptions={}};(function(){r.implement(this,i),this.defineOptions=function(e,t,n){return e.$options||(this.$defaultOptions[t]=e.$options={}),Object.keys(n).forEach(function(t){var r=n[t];typeof r=="string"&&(r={forwardTo:r}),r.name||(r.name=t),e.$options[r.name]=r,"initialValue"in r&&(e["$"+r.name]=r.initialValue)}),r.implement(e,s),this},this.resetOptions=function(e){Object.keys(e.$options).forEach(function(t){var n=e.$options[t];"value"in n&&e.setOption(t,n.value)})},this.setDefaultValue=function(e,t,n){var r=this.$defaultOptions[e]||(this.$defaultOptions[e]={});r[t]&&(r.forwardTo?this.setDefaultValue(r.forwardTo,t,n):r[t].value=n)},this.setDefaultValues=function(e,t){Object.keys(t).forEach(function(n){this.setDefaultValue(e,n,t[n])},this)},this.warn=o,this.reportError=u}).call(a.prototype),t.AppConfig=a}),ace.define("ace/config",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/lib/net","ace/lib/app_config"],function(e,t,n){"no use strict";function f(r){if(!u||!u.document)return;a.packaged=r||e.packaged||n.packaged||u.define&&__webpack_require__(171).packaged;var i={},s="",o=document.currentScript||document._currentScript,f=o&&o.ownerDocument||document,c=f.getElementsByTagName("script");for(var h=0;h<c.length;h++){var p=c[h],d=p.src||p.getAttribute("src");if(!d)continue;var v=p.attributes;for(var m=0,g=v.length;m<g;m++){var y=v[m];y.name.indexOf("data-ace-")===0&&(i[l(y.name.replace(/^data-ace-/,""))]=y.value)}var b=d.match(/^(.*)\/ace(\-\w+)?\.js(\?|$)/);b&&(s=b[1])}s&&(i.base=i.base||s,i.packaged=!0),i.basePath=i.base,i.workerPath=i.workerPath||i.base,i.modePath=i.modePath||i.base,i.themePath=i.themePath||i.base,delete i.base;for(var w in i)typeof i[w]!="undefined"&&t.set(w,i[w])}function l(e){return e.replace(/-(.)/g,function(e,t){return t.toUpperCase()})}var r=e("./lib/lang"),i=e("./lib/oop"),s=e("./lib/net"),o=e("./lib/app_config").AppConfig;n.exports=t=new o;var u=function(){return this||typeof window!="undefined"&&window}(),a={packaged:!1,workerPath:null,modePath:null,themePath:null,basePath:"",suffix:".js",$moduleUrls:{}};t.get=function(e){if(!a.hasOwnProperty(e))throw new Error("Unknown config key: "+e);return a[e]},t.set=function(e,t){if(!a.hasOwnProperty(e))throw new Error("Unknown config key: "+e);a[e]=t},t.all=function(){return r.copyObject(a)},t.moduleUrl=function(e,t){if(a.$moduleUrls[e])return a.$moduleUrls[e];var n=e.split("/");t=t||n[n.length-2]||"";var r=t=="snippets"?"/":"-",i=n[n.length-1];if(t=="worker"&&r=="-"){var s=new RegExp("^"+t+"[\\-_]|[\\-_]"+t+"$","g");i=i.replace(s,"")}(!i||i==t)&&n.length>1&&(i=n[n.length-2]);var o=a[t+"Path"];return o==null?o=a.basePath:r=="/"&&(t=r=""),o&&o.slice(-1)!="/"&&(o+="/"),o+t+r+i+this.get("suffix")},t.setModuleUrl=function(e,t){return a.$moduleUrls[e]=t},t.$loading={},t.loadModule=function(n,r){var i,o;Array.isArray(n)&&(o=n[0],n=n[1]);try{i=e(n)}catch(u){}if(i&&!t.$loading[n])return r&&r(i);t.$loading[n]||(t.$loading[n]=[]),t.$loading[n].push(r);if(t.$loading[n].length>1)return;var a=function(){e([n],function(e){t._emit("load.module",{name:n,module:e});var r=t.$loading[n];t.$loading[n]=null,r.forEach(function(t){t&&t(e)})})};if(!t.get("packaged"))return a();s.loadScript(t.moduleUrl(n,o),a)},t.init=f}),ace.define("ace/mouse/mouse_handler",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/mouse/default_handlers","ace/mouse/default_gutter_handler","ace/mouse/mouse_event","ace/mouse/dragdrop_handler","ace/config"],function(e,t,n){"use strict";var r=e("../lib/event"),i=e("../lib/useragent"),s=e("./default_handlers").DefaultHandlers,o=e("./default_gutter_handler").GutterHandler,u=e("./mouse_event").MouseEvent,a=e("./dragdrop_handler").DragdropHandler,f=e("../config"),l=function(e){var t=this;this.editor=e,new s(this),new o(this),new a(this);var n=function(t){var n=!document.hasFocus||!document.hasFocus()||!e.isFocused()&&document.activeElement==(e.textInput&&e.textInput.getElement());n&&window.focus(),e.focus()},u=e.renderer.getMouseEventTarget();r.addListener(u,"click",this.onMouseEvent.bind(this,"click")),r.addListener(u,"mousemove",this.onMouseMove.bind(this,"mousemove")),r.addMultiMouseDownListener([u,e.renderer.scrollBarV&&e.renderer.scrollBarV.inner,e.renderer.scrollBarH&&e.renderer.scrollBarH.inner,e.textInput&&e.textInput.getElement()].filter(Boolean),[400,300,250],this,"onMouseEvent"),r.addMouseWheelListener(e.container,this.onMouseWheel.bind(this,"mousewheel")),r.addTouchMoveListener(e.container,this.onTouchMove.bind(this,"touchmove"));var f=e.renderer.$gutter;r.addListener(f,"mousedown",this.onMouseEvent.bind(this,"guttermousedown")),r.addListener(f,"click",this.onMouseEvent.bind(this,"gutterclick")),r.addListener(f,"dblclick",this.onMouseEvent.bind(this,"gutterdblclick")),r.addListener(f,"mousemove",this.onMouseEvent.bind(this,"guttermousemove")),r.addListener(u,"mousedown",n),r.addListener(f,"mousedown",n),i.isIE&&e.renderer.scrollBarV&&(r.addListener(e.renderer.scrollBarV.element,"mousedown",n),r.addListener(e.renderer.scrollBarH.element,"mousedown",n)),e.on("mousemove",function(n){if(t.state||t.$dragDelay||!t.$dragEnabled)return;var r=e.renderer.screenToTextCoordinates(n.x,n.y),i=e.session.selection.getRange(),s=e.renderer;!i.isEmpty()&&i.insideStart(r.row,r.column)?s.setCursorStyle("default"):s.setCursorStyle("")})};(function(){this.onMouseEvent=function(e,t){this.editor._emit(e,new u(t,this.editor))},this.onMouseMove=function(e,t){var n=this.editor._eventRegistry&&this.editor._eventRegistry.mousemove;if(!n||!n.length)return;this.editor._emit(e,new u(t,this.editor))},this.onMouseWheel=function(e,t){var n=new u(t,this.editor);n.speed=this.$scrollSpeed*2,n.wheelX=t.wheelX,n.wheelY=t.wheelY,this.editor._emit(e,n)},this.onTouchMove=function(e,t){var n=new u(t,this.editor);n.speed=1,n.wheelX=t.wheelX,n.wheelY=t.wheelY,this.editor._emit(e,n)},this.setState=function(e){this.state=e},this.captureMouse=function(e,t){this.x=e.x,this.y=e.y,this.isMousePressed=!0;var n=this.editor.renderer;n.$keepTextAreaAtCursor&&(n.$keepTextAreaAtCursor=null);var s=this,o=function(e){if(!e)return;if(i.isWebKit&&!e.which&&s.releaseMouse)return s.releaseMouse();s.x=e.clientX,s.y=e.clientY,t&&t(e),s.mouseEvent=new u(e,s.editor),s.$mouseMoved=!0},a=function(e){clearInterval(l),f(),s[s.state+"End"]&&s[s.state+"End"](e),s.state="",n.$keepTextAreaAtCursor==null&&(n.$keepTextAreaAtCursor=!0,n.$moveTextAreaToCursor()),s.isMousePressed=!1,s.$onCaptureMouseMove=s.releaseMouse=null,e&&s.onMouseEvent("mouseup",e)},f=function(){s[s.state]&&s[s.state](),s.$mouseMoved=!1};if(i.isOldIE&&e.domEvent.type=="dblclick")return setTimeout(function(){a(e)});s.$onCaptureMouseMove=o,s.releaseMouse=r.capture(this.editor.container,o,a);var l=setInterval(f,20)},this.releaseMouse=null,this.cancelContextMenu=function(){var e=function(t){if(t&&t.domEvent&&t.domEvent.type!="contextmenu")return;this.editor.off("nativecontextmenu",e),t&&t.domEvent&&r.stopEvent(t.domEvent)}.bind(this);setTimeout(e,10),this.editor.on("nativecontextmenu",e)}}).call(l.prototype),f.defineOptions(l.prototype,"mouseHandler",{scrollSpeed:{initialValue:2},dragDelay:{initialValue:i.isMac?150:0},dragEnabled:{initialValue:!0},focusTimout:{initialValue:0},tooltipFollowsMouse:{initialValue:!0}}),t.MouseHandler=l}),ace.define("ace/mouse/fold_handler",["require","exports","module"],function(e,t,n){"use strict";function r(e){e.on("click",function(t){var n=t.getDocumentPosition(),r=e.session,i=r.getFoldAt(n.row,n.column,1);i&&(t.getAccelKey()?r.removeFold(i):r.expandFold(i),t.stop())}),e.on("gutterclick",function(t){var n=e.renderer.$gutterLayer.getRegion(t);if(n=="foldWidgets"){var r=t.getDocumentPosition().row,i=e.session;i.foldWidgets&&i.foldWidgets[r]&&e.session.onFoldWidgetClick(r,t),e.isFocused()||e.focus(),t.stop()}}),e.on("gutterdblclick",function(t){var n=e.renderer.$gutterLayer.getRegion(t);if(n=="foldWidgets"){var r=t.getDocumentPosition().row,i=e.session,s=i.getParentFoldRangeData(r,!0),o=s.range||s.firstRange;if(o){r=o.start.row;var u=i.getFoldAt(r,i.getLine(r).length,1);u?i.removeFold(u):(i.addFold("...",o),e.renderer.scrollCursorIntoView({row:o.start.row,column:0}))}t.stop()}})}t.FoldHandler=r}),ace.define("ace/keyboard/keybinding",["require","exports","module","ace/lib/keys","ace/lib/event"],function(e,t,n){"use strict";var r=e("../lib/keys"),i=e("../lib/event"),s=function(e){this.$editor=e,this.$data={editor:e},this.$handlers=[],this.setDefaultHandler(e.commands)};(function(){this.setDefaultHandler=function(e){this.removeKeyboardHandler(this.$defaultHandler),this.$defaultHandler=e,this.addKeyboardHandler(e,0)},this.setKeyboardHandler=function(e){var t=this.$handlers;if(t[t.length-1]==e)return;while(t[t.length-1]&&t[t.length-1]!=this.$defaultHandler)this.removeKeyboardHandler(t[t.length-1]);this.addKeyboardHandler(e,1)},this.addKeyboardHandler=function(e,t){if(!e)return;typeof e=="function"&&!e.handleKeyboard&&(e.handleKeyboard=e);var n=this.$handlers.indexOf(e);n!=-1&&this.$handlers.splice(n,1),t==undefined?this.$handlers.push(e):this.$handlers.splice(t,0,e),n==-1&&e.attach&&e.attach(this.$editor)},this.removeKeyboardHandler=function(e){var t=this.$handlers.indexOf(e);return t==-1?!1:(this.$handlers.splice(t,1),e.detach&&e.detach(this.$editor),!0)},this.getKeyboardHandler=function(){return this.$handlers[this.$handlers.length-1]},this.getStatusText=function(){var e=this.$data,t=e.editor;return this.$handlers.map(function(n){return n.getStatusText&&n.getStatusText(t,e)||""}).filter(Boolean).join(" ")},this.$callKeyboardHandlers=function(e,t,n,r){var s,o=!1,u=this.$editor.commands;for(var a=this.$handlers.length;a--;){s=this.$handlers[a].handleKeyboard(this.$data,e,t,n,r);if(!s||!s.command)continue;s.command=="null"?o=!0:o=u.exec(s.command,this.$editor,s.args,r),o&&r&&e!=-1&&s.passEvent!=1&&s.command.passEvent!=1&&i.stopEvent(r);if(o)break}return!o&&e==-1&&(s={command:"insertstring"},o=u.exec("insertstring",this.$editor,t)),o&&this.$editor._signal&&this.$editor._signal("keyboardActivity",s),o},this.onCommandKey=function(e,t,n){var i=r.keyCodeToString(n);this.$callKeyboardHandlers(t,i,n,e)},this.onTextInput=function(e){this.$callKeyboardHandlers(-1,e)}}).call(s.prototype),t.KeyBinding=s}),ace.define("ace/range",["require","exports","module"],function(e,t,n){"use strict";var r=function(e,t){return e.row-t.row||e.column-t.column},i=function(e,t,n,r){this.start={row:e,column:t},this.end={row:n,column:r}};(function(){this.isEqual=function(e){return this.start.row===e.start.row&&this.end.row===e.end.row&&this.start.column===e.start.column&&this.end.column===e.end.column},this.toString=function(){return"Range: ["+this.start.row+"/"+this.start.column+"] -> ["+this.end.row+"/"+this.end.column+"]"},this.contains=function(e,t){return this.compare(e,t)==0},this.compareRange=function(e){var t,n=e.end,r=e.start;return t=this.compare(n.row,n.column),t==1?(t=this.compare(r.row,r.column),t==1?2:t==0?1:0):t==-1?-2:(t=this.compare(r.row,r.column),t==-1?-1:t==1?42:0)},this.comparePoint=function(e){return this.compare(e.row,e.column)},this.containsRange=function(e){return this.comparePoint(e.start)==0&&this.comparePoint(e.end)==0},this.intersects=function(e){var t=this.compareRange(e);return t==-1||t==0||t==1},this.isEnd=function(e,t){return this.end.row==e&&this.end.column==t},this.isStart=function(e,t){return this.start.row==e&&this.start.column==t},this.setStart=function(e,t){typeof e=="object"?(this.start.column=e.column,this.start.row=e.row):(this.start.row=e,this.start.column=t)},this.setEnd=function(e,t){typeof e=="object"?(this.end.column=e.column,this.end.row=e.row):(this.end.row=e,this.end.column=t)},this.inside=function(e,t){return this.compare(e,t)==0?this.isEnd(e,t)||this.isStart(e,t)?!1:!0:!1},this.insideStart=function(e,t){return this.compare(e,t)==0?this.isEnd(e,t)?!1:!0:!1},this.insideEnd=function(e,t){return this.compare(e,t)==0?this.isStart(e,t)?!1:!0:!1},this.compare=function(e,t){return!this.isMultiLine()&&e===this.start.row?t<this.start.column?-1:t>this.end.column?1:0:e<this.start.row?-1:e>this.end.row?1:this.start.row===e?t>=this.start.column?0:-1:this.end.row===e?t<=this.end.column?0:1:0},this.compareStart=function(e,t){return this.start.row==e&&this.start.column==t?-1:this.compare(e,t)},this.compareEnd=function(e,t){return this.end.row==e&&this.end.column==t?1:this.compare(e,t)},this.compareInside=function(e,t){return this.end.row==e&&this.end.column==t?1:this.start.row==e&&this.start.column==t?-1:this.compare(e,t)},this.clipRows=function(e,t){if(this.end.row>t)var n={row:t+1,column:0};else if(this.end.row<e)var n={row:e,column:0};if(this.start.row>t)var r={row:t+1,column:0};else if(this.start.row<e)var r={row:e,column:0};return i.fromPoints(r||this.start,n||this.end)},this.extend=function(e,t){var n=this.compare(e,t);if(n==0)return this;if(n==-1)var r={row:e,column:t};else var s={row:e,column:t};return i.fromPoints(r||this.start,s||this.end)},this.isEmpty=function(){return this.start.row===this.end.row&&this.start.column===this.end.column},this.isMultiLine=function(){return this.start.row!==this.end.row},this.clone=function(){return i.fromPoints(this.start,this.end)},this.collapseRows=function(){return this.end.column==0?new i(this.start.row,0,Math.max(this.start.row,this.end.row-1),0):new i(this.start.row,0,this.end.row,0)},this.toScreenRange=function(e){var t=e.documentToScreenPosition(this.start),n=e.documentToScreenPosition(this.end);return new i(t.row,t.column,n.row,n.column)},this.moveBy=function(e,t){this.start.row+=e,this.start.column+=t,this.end.row+=e,this.end.column+=t}}).call(i.prototype),i.fromPoints=function(e,t){return new i(e.row,e.column,t.row,t.column)},i.comparePoints=r,i.comparePoints=function(e,t){return e.row-t.row||e.column-t.column},t.Range=i}),ace.define("ace/selection",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/range"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/lang"),s=e("./lib/event_emitter").EventEmitter,o=e("./range").Range,u=function(e){this.session=e,this.doc=e.getDocument(),this.clearSelection(),this.lead=this.selectionLead=this.doc.createAnchor(0,0),this.anchor=this.selectionAnchor=this.doc.createAnchor(0,0);var t=this;this.lead.on("change",function(e){t._emit("changeCursor"),t.$isEmpty||t._emit("changeSelection"),!t.$keepDesiredColumnOnChange&&e.old.column!=e.value.column&&(t.$desiredColumn=null)}),this.selectionAnchor.on("change",function(){t.$isEmpty||t._emit("changeSelection")})};(function(){r.implement(this,s),this.isEmpty=function(){return this.$isEmpty||this.anchor.row==this.lead.row&&this.anchor.column==this.lead.column},this.isMultiLine=function(){return this.isEmpty()?!1:this.getRange().isMultiLine()},this.getCursor=function(){return this.lead.getPosition()},this.setSelectionAnchor=function(e,t){this.anchor.setPosition(e,t),this.$isEmpty&&(this.$isEmpty=!1,this._emit("changeSelection"))},this.getSelectionAnchor=function(){return this.$isEmpty?this.getSelectionLead():this.anchor.getPosition()},this.getSelectionLead=function(){return this.lead.getPosition()},this.shiftSelection=function(e){if(this.$isEmpty){this.moveCursorTo(this.lead.row,this.lead.column+e);return}var t=this.getSelectionAnchor(),n=this.getSelectionLead(),r=this.isBackwards();(!r||t.column!==0)&&this.setSelectionAnchor(t.row,t.column+e),(r||n.column!==0)&&this.$moveSelection(function(){this.moveCursorTo(n.row,n.column+e)})},this.isBackwards=function(){var e=this.anchor,t=this.lead;return e.row>t.row||e.row==t.row&&e.column>t.column},this.getRange=function(){var e=this.anchor,t=this.lead;return this.isEmpty()?o.fromPoints(t,t):this.isBackwards()?o.fromPoints(t,e):o.fromPoints(e,t)},this.clearSelection=function(){this.$isEmpty||(this.$isEmpty=!0,this._emit("changeSelection"))},this.selectAll=function(){var e=this.doc.getLength()-1;this.setSelectionAnchor(0,0),this.moveCursorTo(e,this.doc.getLine(e).length)},this.setRange=this.setSelectionRange=function(e,t){t?(this.setSelectionAnchor(e.end.row,e.end.column),this.selectTo(e.start.row,e.start.column)):(this.setSelectionAnchor(e.start.row,e.start.column),this.selectTo(e.end.row,e.end.column)),this.getRange().isEmpty()&&(this.$isEmpty=!0),this.$desiredColumn=null},this.$moveSelection=function(e){var t=this.lead;this.$isEmpty&&this.setSelectionAnchor(t.row,t.column),e.call(this)},this.selectTo=function(e,t){this.$moveSelection(function(){this.moveCursorTo(e,t)})},this.selectToPosition=function(e){this.$moveSelection(function(){this.moveCursorToPosition(e)})},this.moveTo=function(e,t){this.clearSelection(),this.moveCursorTo(e,t)},this.moveToPosition=function(e){this.clearSelection(),this.moveCursorToPosition(e)},this.selectUp=function(){this.$moveSelection(this.moveCursorUp)},this.selectDown=function(){this.$moveSelection(this.moveCursorDown)},this.selectRight=function(){this.$moveSelection(this.moveCursorRight)},this.selectLeft=function(){this.$moveSelection(this.moveCursorLeft)},this.selectLineStart=function(){this.$moveSelection(this.moveCursorLineStart)},this.selectLineEnd=function(){this.$moveSelection(this.moveCursorLineEnd)},this.selectFileEnd=function(){this.$moveSelection(this.moveCursorFileEnd)},this.selectFileStart=function(){this.$moveSelection(this.moveCursorFileStart)},this.selectWordRight=function(){this.$moveSelection(this.moveCursorWordRight)},this.selectWordLeft=function(){this.$moveSelection(this.moveCursorWordLeft)},this.getWordRange=function(e,t){if(typeof t=="undefined"){var n=e||this.lead;e=n.row,t=n.column}return this.session.getWordRange(e,t)},this.selectWord=function(){this.setSelectionRange(this.getWordRange())},this.selectAWord=function(){var e=this.getCursor(),t=this.session.getAWordRange(e.row,e.column);this.setSelectionRange(t)},this.getLineRange=function(e,t){var n=typeof e=="number"?e:this.lead.row,r,i=this.session.getFoldLine(n);return i?(n=i.start.row,r=i.end.row):r=n,t===!0?new o(n,0,r,this.session.getLine(r).length):new o(n,0,r+1,0)},this.selectLine=function(){this.setSelectionRange(this.getLineRange())},this.moveCursorUp=function(){this.moveCursorBy(-1,0)},this.moveCursorDown=function(){this.moveCursorBy(1,0)},this.moveCursorLeft=function(){var e=this.lead.getPosition(),t;if(t=this.session.getFoldAt(e.row,e.column,-1))this.moveCursorTo(t.start.row,t.start.column);else if(e.column===0)e.row>0&&this.moveCursorTo(e.row-1,this.doc.getLine(e.row-1).length);else{var n=this.session.getTabSize();this.session.isTabStop(e)&&this.doc.getLine(e.row).slice(e.column-n,e.column).split(" ").length-1==n?this.moveCursorBy(0,-n):this.moveCursorBy(0,-1)}},this.moveCursorRight=function(){var e=this.lead.getPosition(),t;if(t=this.session.getFoldAt(e.row,e.column,1))this.moveCursorTo(t.end.row,t.end.column);else if(this.lead.column==this.doc.getLine(this.lead.row).length)this.lead.row<this.doc.getLength()-1&&this.moveCursorTo(this.lead.row+1,0);else{var n=this.session.getTabSize(),e=this.lead;this.session.isTabStop(e)&&this.doc.getLine(e.row).slice(e.column,e.column+n).split(" ").length-1==n?this.moveCursorBy(0,n):this.moveCursorBy(0,1)}},this.moveCursorLineStart=function(){var e=this.lead.row,t=this.lead.column,n=this.session.documentToScreenRow(e,t),r=this.session.screenToDocumentPosition(n,0),i=this.session.getDisplayLine(e,null,r.row,r.column),s=i.match(/^\s*/);s[0].length!=t&&!this.session.$useEmacsStyleLineStart&&(r.column+=s[0].length),this.moveCursorToPosition(r)},this.moveCursorLineEnd=function(){var e=this.lead,t=this.session.getDocumentLastRowColumnPosition(e.row,e.column);if(this.lead.column==t.column){var n=this.session.getLine(t.row);if(t.column==n.length){var r=n.search(/\s+$/);r>0&&(t.column=r)}}this.moveCursorTo(t.row,t.column)},this.moveCursorFileEnd=function(){var e=this.doc.getLength()-1,t=this.doc.getLine(e).length;this.moveCursorTo(e,t)},this.moveCursorFileStart=function(){this.moveCursorTo(0,0)},this.moveCursorLongWordRight=function(){var e=this.lead.row,t=this.lead.column,n=this.doc.getLine(e),r=n.substring(t),i;this.session.nonTokenRe.lastIndex=0,this.session.tokenRe.lastIndex=0;var s=this.session.getFoldAt(e,t,1);if(s){this.moveCursorTo(s.end.row,s.end.column);return}if(i=this.session.nonTokenRe.exec(r))t+=this.session.nonTokenRe.lastIndex,this.session.nonTokenRe.lastIndex=0,r=n.substring(t);if(t>=n.length){this.moveCursorTo(e,n.length),this.moveCursorRight(),e<this.doc.getLength()-1&&this.moveCursorWordRight();return}if(i=this.session.tokenRe.exec(r))t+=this.session.tokenRe.lastIndex,this.session.tokenRe.lastIndex=0;this.moveCursorTo(e,t)},this.moveCursorLongWordLeft=function(){var e=this.lead.row,t=this.lead.column,n;if(n=this.session.getFoldAt(e,t,-1)){this.moveCursorTo(n.start.row,n.start.column);return}var r=this.session.getFoldStringAt(e,t,-1);r==null&&(r=this.doc.getLine(e).substring(0,t));var s=i.stringReverse(r),o;this.session.nonTokenRe.lastIndex=0,this.session.tokenRe.lastIndex=0;if(o=this.session.nonTokenRe.exec(s))t-=this.session.nonTokenRe.lastIndex,s=s.slice(this.session.nonTokenRe.lastIndex),this.session.nonTokenRe.lastIndex=0;if(t<=0){this.moveCursorTo(e,0),this.moveCursorLeft(),e>0&&this.moveCursorWordLeft();return}if(o=this.session.tokenRe.exec(s))t-=this.session.tokenRe.lastIndex,this.session.tokenRe.lastIndex=0;this.moveCursorTo(e,t)},this.$shortWordEndIndex=function(e){var t,n=0,r,i=/\s/,s=this.session.tokenRe;s.lastIndex=0;if(t=this.session.tokenRe.exec(e))n=this.session.tokenRe.lastIndex;else{while((r=e[n])&&i.test(r))n++;if(n<1){s.lastIndex=0;while((r=e[n])&&!s.test(r)){s.lastIndex=0,n++;if(i.test(r)){if(n>2){n--;break}while((r=e[n])&&i.test(r))n++;if(n>2)break}}}}return s.lastIndex=0,n},this.moveCursorShortWordRight=function(){var e=this.lead.row,t=this.lead.column,n=this.doc.getLine(e),r=n.substring(t),i=this.session.getFoldAt(e,t,1);if(i)return this.moveCursorTo(i.end.row,i.end.column);if(t==n.length){var s=this.doc.getLength();do e++,r=this.doc.getLine(e);while(e<s&&/^\s*$/.test(r));/^\s+/.test(r)||(r=""),t=0}var o=this.$shortWordEndIndex(r);this.moveCursorTo(e,t+o)},this.moveCursorShortWordLeft=function(){var e=this.lead.row,t=this.lead.column,n;if(n=this.session.getFoldAt(e,t,-1))return this.moveCursorTo(n.start.row,n.start.column);var r=this.session.getLine(e).substring(0,t);if(t===0){do e--,r=this.doc.getLine(e);while(e>0&&/^\s*$/.test(r));t=r.length,/\s+$/.test(r)||(r="")}var s=i.stringReverse(r),o=this.$shortWordEndIndex(s);return this.moveCursorTo(e,t-o)},this.moveCursorWordRight=function(){this.session.$selectLongWords?this.moveCursorLongWordRight():this.moveCursorShortWordRight()},this.moveCursorWordLeft=function(){this.session.$selectLongWords?this.moveCursorLongWordLeft():this.moveCursorShortWordLeft()},this.moveCursorBy=function(e,t){var n=this.session.documentToScreenPosition(this.lead.row,this.lead.column);t===0&&(this.$desiredColumn?n.column=this.$desiredColumn:this.$desiredColumn=n.column);var r=this.session.screenToDocumentPosition(n.row+e,n.column);e!==0&&t===0&&r.row===this.lead.row&&r.column===this.lead.column&&this.session.lineWidgets&&this.session.lineWidgets[r.row]&&(r.row>0||e>0)&&r.row++,this.moveCursorTo(r.row,r.column+t,t===0)},this.moveCursorToPosition=function(e){this.moveCursorTo(e.row,e.column)},this.moveCursorTo=function(e,t,n){var r=this.session.getFoldAt(e,t,1);r&&(e=r.start.row,t=r.start.column),this.$keepDesiredColumnOnChange=!0,this.lead.setPosition(e,t),this.$keepDesiredColumnOnChange=!1,n||(this.$desiredColumn=null)},this.moveCursorToScreen=function(e,t,n){var r=this.session.screenToDocumentPosition(e,t);this.moveCursorTo(r.row,r.column,n)},this.detach=function(){this.lead.detach(),this.anchor.detach(),this.session=this.doc=null},this.fromOrientedRange=function(e){this.setSelectionRange(e,e.cursor==e.start),this.$desiredColumn=e.desiredColumn||this.$desiredColumn},this.toOrientedRange=function(e){var t=this.getRange();return e?(e.start.column=t.start.column,e.start.row=t.start.row,e.end.column=t.end.column,e.end.row=t.end.row):e=t,e.cursor=this.isBackwards()?e.start:e.end,e.desiredColumn=this.$desiredColumn,e},this.getRangeOfMovements=function(e){var t=this.getCursor();try{e(this);var n=this.getCursor();return o.fromPoints(t,n)}catch(r){return o.fromPoints(t,t)}finally{this.moveCursorToPosition(t)}},this.toJSON=function(){if(this.rangeCount)var e=this.ranges.map(function(e){var t=e.clone();return t.isBackwards=e.cursor==e.start,t});else{var e=this.getRange();e.isBackwards=this.isBackwards()}return e},this.fromJSON=function(e){if(e.start==undefined){if(this.rangeList){this.toSingleRange(e[0]);for(var t=e.length;t--;){var n=o.fromPoints(e[t].start,e[t].end);e[t].isBackwards&&(n.cursor=n.start),this.addRange(n,!0)}return}e=e[0]}this.rangeList&&this.toSingleRange(e),this.setSelectionRange(e,e.isBackwards)},this.isEqual=function(e){if((e.length||this.rangeCount)&&e.length!=this.rangeCount)return!1;if(!e.length||!this.ranges)return this.getRange().isEqual(e);for(var t=this.ranges.length;t--;)if(!this.ranges[t].isEqual(e[t]))return!1;return!0}}).call(u.prototype),t.Selection=u}),ace.define("ace/tokenizer",["require","exports","module","ace/config"],function(e,t,n){"use strict";var r=e("./config"),i=2e3,s=function(e){this.states=e,this.regExps={},this.matchMappings={};for(var t in this.states){var n=this.states[t],r=[],i=0,s=this.matchMappings[t]={defaultToken:"text"},o="g",u=[];for(var a=0;a<n.length;a++){var f=n[a];f.defaultToken&&(s.defaultToken=f.defaultToken),f.caseInsensitive&&(o="gi");if(f.regex==null)continue;f.regex instanceof RegExp&&(f.regex=f.regex.toString().slice(1,-1));var l=f.regex,c=(new RegExp("(?:("+l+")|(.))")).exec("a").length-2;Array.isArray(f.token)?f.token.length==1||c==1?f.token=f.token[0]:c-1!=f.token.length?(this.reportError("number of classes and regexp groups doesn't match",{rule:f,groupCount:c-1}),f.token=f.token[0]):(f.tokenArray=f.token,f.token=null,f.onMatch=this.$arrayTokens):typeof f.token=="function"&&!f.onMatch&&(c>1?f.onMatch=this.$applyToken:f.onMatch=f.token),c>1&&(/\\\d/.test(f.regex)?l=f.regex.replace(/\\([0-9]+)/g,function(e,t){return"\\"+(parseInt(t,10)+i+1)}):(c=1,l=this.removeCapturingGroups(f.regex)),!f.splitRegex&&typeof f.token!="string"&&u.push(f)),s[i]=a,i+=c,r.push(l),f.onMatch||(f.onMatch=null)}r.length||(s[0]=0,r.push("$")),u.forEach(function(e){e.splitRegex=this.createSplitterRegexp(e.regex,o)},this),this.regExps[t]=new RegExp("("+r.join(")|(")+")|($)",o)}};(function(){this.$setMaxTokenCount=function(e){i=e|0},this.$applyToken=function(e){var t=this.splitRegex.exec(e).slice(1),n=this.token.apply(this,t);if(typeof n=="string")return[{type:n,value:e}];var r=[];for(var i=0,s=n.length;i<s;i++)t[i]&&(r[r.length]={type:n[i],value:t[i]});return r},this.$arrayTokens=function(e){if(!e)return[];var t=this.splitRegex.exec(e);if(!t)return"text";var n=[],r=this.tokenArray;for(var i=0,s=r.length;i<s;i++)t[i+1]&&(n[n.length]={type:r[i],value:t[i+1]});return n},this.removeCapturingGroups=function(e){var t=e.replace(/\[(?:\\.|[^\]])*?\]|\\.|\(\?[:=!]|(\()/g,function(e,t){return t?"(?:":e});return t},this.createSplitterRegexp=function(e,t){if(e.indexOf("(?=")!=-1){var n=0,r=!1,i={};e.replace(/(\\.)|(\((?:\?[=!])?)|(\))|([\[\]])/g,function(e,t,s,o,u,a){return r?r=u!="]":u?r=!0:o?(n==i.stack&&(i.end=a+1,i.stack=-1),n--):s&&(n++,s.length!=1&&(i.stack=n,i.start=a)),e}),i.end!=null&&/^\)*$/.test(e.substr(i.end))&&(e=e.substring(0,i.start)+e.substr(i.end))}return e.charAt(0)!="^"&&(e="^"+e),e.charAt(e.length-1)!="$"&&(e+="$"),new RegExp(e,(t||"").replace("g",""))},this.getLineTokens=function(e,t){if(t&&typeof t!="string"){var n=t.slice(0);t=n[0],t==="#tmp"&&(n.shift(),t=n.shift())}else var n=[];var r=t||"start",s=this.states[r];s||(r="start",s=this.states[r]);var o=this.matchMappings[r],u=this.regExps[r];u.lastIndex=0;var a,f=[],l=0,c=0,h={type:null,value:""};while(a=u.exec(e)){var p=o.defaultToken,d=null,v=a[0],m=u.lastIndex;if(m-v.length>l){var g=e.substring(l,m-v.length);h.type==p?h.value+=g:(h.type&&f.push(h),h={type:p,value:g})}for(var y=0;y<a.length-2;y++){if(a[y+1]===undefined)continue;d=s[o[y]],d.onMatch?p=d.onMatch(v,r,n):p=d.token,d.next&&(typeof d.next=="string"?r=d.next:r=d.next(r,n),s=this.states[r],s||(this.reportError("state doesn't exist",r),r="start",s=this.states[r]),o=this.matchMappings[r],l=m,u=this.regExps[r],u.lastIndex=m);break}if(v)if(typeof p=="string")!!d&&d.merge===!1||h.type!==p?(h.type&&f.push(h),h={type:p,value:v}):h.value+=v;else if(p){h.type&&f.push(h),h={type:null,value:""};for(var y=0;y<p.length;y++)f.push(p[y])}if(l==e.length)break;l=m;if(c++>i){c>2*e.length&&this.reportError("infinite loop with in ace tokenizer",{startState:t,line:e});while(l<e.length)h.type&&f.push(h),h={value:e.substring(l,l+=2e3),type:"overflow"};r="start",n=[];break}}return h.type&&f.push(h),n.length>1&&n[0]!==r&&n.unshift("#tmp",r),{tokens:f,state:n.length?n:r}},this.reportError=r.reportError}).call(s.prototype),t.Tokenizer=s}),ace.define("ace/mode/text_highlight_rules",["require","exports","module","ace/lib/lang"],function(e,t,n){"use strict";var r=e("../lib/lang"),i=function(){this.$rules={start:[{token:"empty_line",regex:"^$"},{defaultToken:"text"}]}};(function(){this.addRules=function(e,t){if(!t){for(var n in e)this.$rules[n]=e[n];return}for(var n in e){var r=e[n];for(var i=0;i<r.length;i++){var s=r[i];if(s.next||s.onMatch)typeof s.next=="string"&&s.next.indexOf(t)!==0&&(s.next=t+s.next),s.nextState&&s.nextState.indexOf(t)!==0&&(s.nextState=t+s.nextState)}this.$rules[t+n]=r}},this.getRules=function(){return this.$rules},this.embedRules=function(e,t,n,i,s){var o=typeof e=="function"?(new e).getRules():e;if(i)for(var u=0;u<i.length;u++)i[u]=t+i[u];else{i=[];for(var a in o)i.push(t+a)}this.addRules(o,t);if(n){var f=Array.prototype[s?"push":"unshift"];for(var u=0;u<i.length;u++)f.apply(this.$rules[i[u]],r.deepCopy(n))}this.$embeds||(this.$embeds=[]),this.$embeds.push(t)},this.getEmbeds=function(){return this.$embeds};var e=function(e,t){return(e!="start"||t.length)&&t.unshift(this.nextState,e),this.nextState},t=function(e,t){return t.shift(),t.shift()||"start"};this.normalizeRules=function(){function i(s){var o=r[s];o.processed=!0;for(var u=0;u<o.length;u++){var a=o[u],f=null;Array.isArray(a)&&(f=a,a={}),!a.regex&&a.start&&(a.regex=a.start,a.next||(a.next=[]),a.next.push({defaultToken:a.token},{token:a.token+".end",regex:a.end||a.start,next:"pop"}),a.token=a.token+".start",a.push=!0);var l=a.next||a.push;if(l&&Array.isArray(l)){var c=a.stateName;c||(c=a.token,typeof c!="string"&&(c=c[0]||""),r[c]&&(c+=n++)),r[c]=l,a.next=c,i(c)}else l=="pop"&&(a.next=t);a.push&&(a.nextState=a.next||a.push,a.next=e,delete a.push);if(a.rules)for(var h in a.rules)r[h]?r[h].push&&r[h].push.apply(r[h],a.rules[h]):r[h]=a.rules[h];var p=typeof a=="string"?a:typeof a.include=="string"?a.include:"";p&&(f=r[p]);if(f){var d=[u,1].concat(f);a.noEscape&&(d=d.filter(function(e){return!e.next})),o.splice.apply(o,d),u--}a.keywordMap&&(a.token=this.createKeywordMapper(a.keywordMap,a.defaultToken||"text",a.caseInsensitive),delete a.defaultToken)}}var n=0,r=this.$rules;Object.keys(r).forEach(i,this)},this.createKeywordMapper=function(e,t,n,r){var i=Object.create(null);return Object.keys(e).forEach(function(t){var s=e[t];n&&(s=s.toLowerCase());var o=s.split(r||"|");for(var u=o.length;u--;)i[o[u]]=t}),Object.getPrototypeOf(i)&&(i.__proto__=null),this.$keywordList=Object.keys(i),e=null,n?function(e){return i[e.toLowerCase()]||t}:function(e){return i[e]||t}},this.getKeywords=function(){return this.$keywords}}).call(i.prototype),t.TextHighlightRules=i}),ace.define("ace/mode/behaviour",["require","exports","module"],function(e,t,n){"use strict";var r=function(){this.$behaviours={}};(function(){this.add=function(e,t,n){switch(undefined){case this.$behaviours:this.$behaviours={};case this.$behaviours[e]:this.$behaviours[e]={}}this.$behaviours[e][t]=n},this.addBehaviours=function(e){for(var t in e)for(var n in e[t])this.add(t,n,e[t][n])},this.remove=function(e){this.$behaviours&&this.$behaviours[e]&&delete this.$behaviours[e]},this.inherit=function(e,t){if(typeof e=="function")var n=(new e).getBehaviours(t);else var n=e.getBehaviours(t);this.addBehaviours(n)},this.getBehaviours=function(e){if(!e)return this.$behaviours;var t={};for(var n=0;n<e.length;n++)this.$behaviours[e[n]]&&(t[e[n]]=this.$behaviours[e[n]]);return t}}).call(r.prototype),t.Behaviour=r}),ace.define("ace/token_iterator",["require","exports","module"],function(e,t,n){"use strict";var r=function(e,t,n){this.$session=e,this.$row=t,this.$rowTokens=e.getTokens(t);var r=e.getTokenAt(t,n);this.$tokenIndex=r?r.index:-1};(function(){this.stepBackward=function(){this.$tokenIndex-=1;while(this.$tokenIndex<0){this.$row-=1;if(this.$row<0)return this.$row=0,null;this.$rowTokens=this.$session.getTokens(this.$row),this.$tokenIndex=this.$rowTokens.length-1}return this.$rowTokens[this.$tokenIndex]},this.stepForward=function(){this.$tokenIndex+=1;var e;while(this.$tokenIndex>=this.$rowTokens.length){this.$row+=1,e||(e=this.$session.getLength());if(this.$row>=e)return this.$row=e-1,null;this.$rowTokens=this.$session.getTokens(this.$row),this.$tokenIndex=0}return this.$rowTokens[this.$tokenIndex]},this.getCurrentToken=function(){return this.$rowTokens[this.$tokenIndex]},this.getCurrentTokenRow=function(){return this.$row},this.getCurrentTokenColumn=function(){var e=this.$rowTokens,t=this.$tokenIndex,n=e[t].start;if(n!==undefined)return n;n=0;while(t>0)t-=1,n+=e[t].value.length;return n},this.getCurrentTokenPosition=function(){return{row:this.$row,column:this.getCurrentTokenColumn()}}}).call(r.prototype),t.TokenIterator=r}),ace.define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"],function(e,t,n){"use strict";var r=e("../../lib/oop"),i=e("../behaviour").Behaviour,s=e("../../token_iterator").TokenIterator,o=e("../../lib/lang"),u=["text","paren.rparen","punctuation.operator"],a=["text","paren.rparen","punctuation.operator","comment"],f,l={},c=function(e){var t=-1;e.multiSelect&&(t=e.selection.index,l.rangeCount!=e.multiSelect.rangeCount&&(l={rangeCount:e.multiSelect.rangeCount}));if(l[t])return f=l[t];f=l[t]={autoInsertedBrackets:0,autoInsertedRow:-1,autoInsertedLineEnd:"",maybeInsertedBrackets:0,maybeInsertedRow:-1,maybeInsertedLineStart:"",maybeInsertedLineEnd:""}},h=function(e,t,n,r){var i=e.end.row-e.start.row;return{text:n+t+r,selection:[0,e.start.column+1,i,e.end.column+(i?0:1)]}},p=function(){this.add("braces","insertion",function(e,t,n,r,i){var s=n.getCursorPosition(),u=r.doc.getLine(s.row);if(i=="{"){c(n);var a=n.getSelectionRange(),l=r.doc.getTextRange(a);if(l!==""&&l!=="{"&&n.getWrapBehavioursEnabled())return h(a,l,"{","}");if(p.isSaneInsertion(n,r))return/[\]\}\)]/.test(u[s.column])||n.inMultiSelectMode?(p.recordAutoInsert(n,r,"}"),{text:"{}",selection:[1,1]}):(p.recordMaybeInsert(n,r,"{"),{text:"{",selection:[1,1]})}else if(i=="}"){c(n);var d=u.substring(s.column,s.column+1);if(d=="}"){var v=r.$findOpeningBracket("}",{column:s.column+1,row:s.row});if(v!==null&&p.isAutoInsertedClosing(s,u,i))return p.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}else{if(i=="\n"||i=="\r\n"){c(n);var m="";p.isMaybeInsertedClosing(s,u)&&(m=o.stringRepeat("}",f.maybeInsertedBrackets),p.clearMaybeInsertedClosing());var d=u.substring(s.column,s.column+1);if(d==="}"){var g=r.findMatchingBracket({row:s.row,column:s.column+1},"}");if(!g)return null;var y=this.$getIndent(r.getLine(g.row))}else{if(!m){p.clearMaybeInsertedClosing();return}var y=this.$getIndent(u)}var b=y+r.getTabString();return{text:"\n"+b+"\n"+y+m,selection:[1,b.length,1,b.length]}}p.clearMaybeInsertedClosing()}}),this.add("braces","deletion",function(e,t,n,r,i){var s=r.doc.getTextRange(i);if(!i.isMultiLine()&&s=="{"){c(n);var o=r.doc.getLine(i.start.row),u=o.substring(i.end.column,i.end.column+1);if(u=="}")return i.end.column++,i;f.maybeInsertedBrackets--}}),this.add("parens","insertion",function(e,t,n,r,i){if(i=="("){c(n);var s=n.getSelectionRange(),o=r.doc.getTextRange(s);if(o!==""&&n.getWrapBehavioursEnabled())return h(s,o,"(",")");if(p.isSaneInsertion(n,r))return p.recordAutoInsert(n,r,")"),{text:"()",selection:[1,1]}}else if(i==")"){c(n);var u=n.getCursorPosition(),a=r.doc.getLine(u.row),f=a.substring(u.column,u.column+1);if(f==")"){var l=r.$findOpeningBracket(")",{column:u.column+1,row:u.row});if(l!==null&&p.isAutoInsertedClosing(u,a,i))return p.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}}),this.add("parens","deletion",function(e,t,n,r,i){var s=r.doc.getTextRange(i);if(!i.isMultiLine()&&s=="("){c(n);var o=r.doc.getLine(i.start.row),u=o.substring(i.start.column+1,i.start.column+2);if(u==")")return i.end.column++,i}}),this.add("brackets","insertion",function(e,t,n,r,i){if(i=="["){c(n);var s=n.getSelectionRange(),o=r.doc.getTextRange(s);if(o!==""&&n.getWrapBehavioursEnabled())return h(s,o,"[","]");if(p.isSaneInsertion(n,r))return p.recordAutoInsert(n,r,"]"),{text:"[]",selection:[1,1]}}else if(i=="]"){c(n);var u=n.getCursorPosition(),a=r.doc.getLine(u.row),f=a.substring(u.column,u.column+1);if(f=="]"){var l=r.$findOpeningBracket("]",{column:u.column+1,row:u.row});if(l!==null&&p.isAutoInsertedClosing(u,a,i))return p.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}}),this.add("brackets","deletion",function(e,t,n,r,i){var s=r.doc.getTextRange(i);if(!i.isMultiLine()&&s=="["){c(n);var o=r.doc.getLine(i.start.row),u=o.substring(i.start.column+1,i.start.column+2);if(u=="]")return i.end.column++,i}}),this.add("string_dquotes","insertion",function(e,t,n,r,i){if(i=='"'||i=="'"){if(this.lineCommentStart&&this.lineCommentStart.indexOf(i)!=-1)return;c(n);var s=i,o=n.getSelectionRange(),u=r.doc.getTextRange(o);if(u!==""&&u!=="'"&&u!='"'&&n.getWrapBehavioursEnabled())return h(o,u,s,s);if(!u){var a=n.getCursorPosition(),f=r.doc.getLine(a.row),l=f.substring(a.column-1,a.column),p=f.substring(a.column,a.column+1),d=r.getTokenAt(a.row,a.column),v=r.getTokenAt(a.row,a.column+1);if(l=="\\"&&d&&/escape/.test(d.type))return null;var m=d&&/string|escape/.test(d.type),g=!v||/string|escape/.test(v.type),y;if(p==s)y=m!==g,y&&/string\.end/.test(v.type)&&(y=!1);else{if(m&&!g)return null;if(m&&g)return null;var b=r.$mode.tokenRe;b.lastIndex=0;var w=b.test(l);b.lastIndex=0;var E=b.test(l);if(w||E)return null;if(p&&!/[\s;,.})\]\\]/.test(p))return null;y=!0}return{text:y?s+s:"",selection:[1,1]}}}}),this.add("string_dquotes","deletion",function(e,t,n,r,i){var s=r.doc.getTextRange(i);if(!i.isMultiLine()&&(s=='"'||s=="'")){c(n);var o=r.doc.getLine(i.start.row),u=o.substring(i.start.column+1,i.start.column+2);if(u==s)return i.end.column++,i}})};p.isSaneInsertion=function(e,t){var n=e.getCursorPosition(),r=new s(t,n.row,n.column);if(!this.$matchTokenType(r.getCurrentToken()||"text",u)){var i=new s(t,n.row,n.column+1);if(!this.$matchTokenType(i.getCurrentToken()||"text",u))return!1}return r.stepForward(),r.getCurrentTokenRow()!==n.row||this.$matchTokenType(r.getCurrentToken()||"text",a)},p.$matchTokenType=function(e,t){return t.indexOf(e.type||e)>-1},p.recordAutoInsert=function(e,t,n){var r=e.getCursorPosition(),i=t.doc.getLine(r.row);this.isAutoInsertedClosing(r,i,f.autoInsertedLineEnd[0])||(f.autoInsertedBrackets=0),f.autoInsertedRow=r.row,f.autoInsertedLineEnd=n+i.substr(r.column),f.autoInsertedBrackets++},p.recordMaybeInsert=function(e,t,n){var r=e.getCursorPosition(),i=t.doc.getLine(r.row);this.isMaybeInsertedClosing(r,i)||(f.maybeInsertedBrackets=0),f.maybeInsertedRow=r.row,f.maybeInsertedLineStart=i.substr(0,r.column)+n,f.maybeInsertedLineEnd=i.substr(r.column),f.maybeInsertedBrackets++},p.isAutoInsertedClosing=function(e,t,n){return f.autoInsertedBrackets>0&&e.row===f.autoInsertedRow&&n===f.autoInsertedLineEnd[0]&&t.substr(e.column)===f.autoInsertedLineEnd},p.isMaybeInsertedClosing=function(e,t){return f.maybeInsertedBrackets>0&&e.row===f.maybeInsertedRow&&t.substr(e.column)===f.maybeInsertedLineEnd&&t.substr(0,e.column)==f.maybeInsertedLineStart},p.popAutoInsertedClosing=function(){f.autoInsertedLineEnd=f.autoInsertedLineEnd.substr(1),f.autoInsertedBrackets--},p.clearMaybeInsertedClosing=function(){f&&(f.maybeInsertedBrackets=0,f.maybeInsertedRow=-1)},r.inherits(p,i),t.CstyleBehaviour=p}),ace.define("ace/unicode",["require","exports","module"],function(e,t,n){"use strict";function r(e){var n=/\w{4}/g;for(var r in e)t.packages[r]=e[r].replace(n,"\\u$&")}t.packages={},r({L:"0041-005A0061-007A00AA00B500BA00C0-00D600D8-00F600F8-02C102C6-02D102E0-02E402EC02EE0370-037403760377037A-037D03860388-038A038C038E-03A103A3-03F503F7-0481048A-05250531-055605590561-058705D0-05EA05F0-05F20621-064A066E066F0671-06D306D506E506E606EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA07F407F507FA0800-0815081A082408280904-0939093D09500958-0961097109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E460E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EC60EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10A0-10C510D0-10FA10FC1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317D717DC1820-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541AA71B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C7D1CE9-1CEC1CEE-1CF11D00-1DBF1E00-1F151F18-1F1D1F20-1F451F48-1F4D1F50-1F571F591F5B1F5D1F5F-1F7D1F80-1FB41FB6-1FBC1FBE1FC2-1FC41FC6-1FCC1FD0-1FD31FD6-1FDB1FE0-1FEC1FF2-1FF41FF6-1FFC2071207F2090-209421022107210A-211321152119-211D212421262128212A-212D212F-2139213C-213F2145-2149214E218321842C00-2C2E2C30-2C5E2C60-2CE42CEB-2CEE2D00-2D252D30-2D652D6F2D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE2E2F300530063031-3035303B303C3041-3096309D-309F30A1-30FA30FC-30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A48CA4D0-A4FDA500-A60CA610-A61FA62AA62BA640-A65FA662-A66EA67F-A697A6A0-A6E5A717-A71FA722-A788A78BA78CA7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2A9CFAA00-AA28AA40-AA42AA44-AA4BAA60-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADB-AADDABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB00-FB06FB13-FB17FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF21-FF3AFF41-FF5AFF66-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC",Ll:"0061-007A00AA00B500BA00DF-00F600F8-00FF01010103010501070109010B010D010F01110113011501170119011B011D011F01210123012501270129012B012D012F01310133013501370138013A013C013E014001420144014601480149014B014D014F01510153015501570159015B015D015F01610163016501670169016B016D016F0171017301750177017A017C017E-0180018301850188018C018D019201950199-019B019E01A101A301A501A801AA01AB01AD01B001B401B601B901BA01BD-01BF01C601C901CC01CE01D001D201D401D601D801DA01DC01DD01DF01E101E301E501E701E901EB01ED01EF01F001F301F501F901FB01FD01FF02010203020502070209020B020D020F02110213021502170219021B021D021F02210223022502270229022B022D022F02310233-0239023C023F0240024202470249024B024D024F-02930295-02AF037103730377037B-037D039003AC-03CE03D003D103D5-03D703D903DB03DD03DF03E103E303E503E703E903EB03ED03EF-03F303F503F803FB03FC0430-045F04610463046504670469046B046D046F04710473047504770479047B047D047F0481048B048D048F04910493049504970499049B049D049F04A104A304A504A704A904AB04AD04AF04B104B304B504B704B904BB04BD04BF04C204C404C604C804CA04CC04CE04CF04D104D304D504D704D904DB04DD04DF04E104E304E504E704E904EB04ED04EF04F104F304F504F704F904FB04FD04FF05010503050505070509050B050D050F05110513051505170519051B051D051F0521052305250561-05871D00-1D2B1D62-1D771D79-1D9A1E011E031E051E071E091E0B1E0D1E0F1E111E131E151E171E191E1B1E1D1E1F1E211E231E251E271E291E2B1E2D1E2F1E311E331E351E371E391E3B1E3D1E3F1E411E431E451E471E491E4B1E4D1E4F1E511E531E551E571E591E5B1E5D1E5F1E611E631E651E671E691E6B1E6D1E6F1E711E731E751E771E791E7B1E7D1E7F1E811E831E851E871E891E8B1E8D1E8F1E911E931E95-1E9D1E9F1EA11EA31EA51EA71EA91EAB1EAD1EAF1EB11EB31EB51EB71EB91EBB1EBD1EBF1EC11EC31EC51EC71EC91ECB1ECD1ECF1ED11ED31ED51ED71ED91EDB1EDD1EDF1EE11EE31EE51EE71EE91EEB1EED1EEF1EF11EF31EF51EF71EF91EFB1EFD1EFF-1F071F10-1F151F20-1F271F30-1F371F40-1F451F50-1F571F60-1F671F70-1F7D1F80-1F871F90-1F971FA0-1FA71FB0-1FB41FB61FB71FBE1FC2-1FC41FC61FC71FD0-1FD31FD61FD71FE0-1FE71FF2-1FF41FF61FF7210A210E210F2113212F21342139213C213D2146-2149214E21842C30-2C5E2C612C652C662C682C6A2C6C2C712C732C742C76-2C7C2C812C832C852C872C892C8B2C8D2C8F2C912C932C952C972C992C9B2C9D2C9F2CA12CA32CA52CA72CA92CAB2CAD2CAF2CB12CB32CB52CB72CB92CBB2CBD2CBF2CC12CC32CC52CC72CC92CCB2CCD2CCF2CD12CD32CD52CD72CD92CDB2CDD2CDF2CE12CE32CE42CEC2CEE2D00-2D25A641A643A645A647A649A64BA64DA64FA651A653A655A657A659A65BA65DA65FA663A665A667A669A66BA66DA681A683A685A687A689A68BA68DA68FA691A693A695A697A723A725A727A729A72BA72DA72F-A731A733A735A737A739A73BA73DA73FA741A743A745A747A749A74BA74DA74FA751A753A755A757A759A75BA75DA75FA761A763A765A767A769A76BA76DA76FA771-A778A77AA77CA77FA781A783A785A787A78CFB00-FB06FB13-FB17FF41-FF5A",Lu:"0041-005A00C0-00D600D8-00DE01000102010401060108010A010C010E01100112011401160118011A011C011E01200122012401260128012A012C012E01300132013401360139013B013D013F0141014301450147014A014C014E01500152015401560158015A015C015E01600162016401660168016A016C016E017001720174017601780179017B017D018101820184018601870189-018B018E-0191019301940196-0198019C019D019F01A001A201A401A601A701A901AC01AE01AF01B1-01B301B501B701B801BC01C401C701CA01CD01CF01D101D301D501D701D901DB01DE01E001E201E401E601E801EA01EC01EE01F101F401F6-01F801FA01FC01FE02000202020402060208020A020C020E02100212021402160218021A021C021E02200222022402260228022A022C022E02300232023A023B023D023E02410243-02460248024A024C024E03700372037603860388-038A038C038E038F0391-03A103A3-03AB03CF03D2-03D403D803DA03DC03DE03E003E203E403E603E803EA03EC03EE03F403F703F903FA03FD-042F04600462046404660468046A046C046E04700472047404760478047A047C047E0480048A048C048E04900492049404960498049A049C049E04A004A204A404A604A804AA04AC04AE04B004B204B404B604B804BA04BC04BE04C004C104C304C504C704C904CB04CD04D004D204D404D604D804DA04DC04DE04E004E204E404E604E804EA04EC04EE04F004F204F404F604F804FA04FC04FE05000502050405060508050A050C050E05100512051405160518051A051C051E0520052205240531-055610A0-10C51E001E021E041E061E081E0A1E0C1E0E1E101E121E141E161E181E1A1E1C1E1E1E201E221E241E261E281E2A1E2C1E2E1E301E321E341E361E381E3A1E3C1E3E1E401E421E441E461E481E4A1E4C1E4E1E501E521E541E561E581E5A1E5C1E5E1E601E621E641E661E681E6A1E6C1E6E1E701E721E741E761E781E7A1E7C1E7E1E801E821E841E861E881E8A1E8C1E8E1E901E921E941E9E1EA01EA21EA41EA61EA81EAA1EAC1EAE1EB01EB21EB41EB61EB81EBA1EBC1EBE1EC01EC21EC41EC61EC81ECA1ECC1ECE1ED01ED21ED41ED61ED81EDA1EDC1EDE1EE01EE21EE41EE61EE81EEA1EEC1EEE1EF01EF21EF41EF61EF81EFA1EFC1EFE1F08-1F0F1F18-1F1D1F28-1F2F1F38-1F3F1F48-1F4D1F591F5B1F5D1F5F1F68-1F6F1FB8-1FBB1FC8-1FCB1FD8-1FDB1FE8-1FEC1FF8-1FFB21022107210B-210D2110-211221152119-211D212421262128212A-212D2130-2133213E213F214521832C00-2C2E2C602C62-2C642C672C692C6B2C6D-2C702C722C752C7E-2C802C822C842C862C882C8A2C8C2C8E2C902C922C942C962C982C9A2C9C2C9E2CA02CA22CA42CA62CA82CAA2CAC2CAE2CB02CB22CB42CB62CB82CBA2CBC2CBE2CC02CC22CC42CC62CC82CCA2CCC2CCE2CD02CD22CD42CD62CD82CDA2CDC2CDE2CE02CE22CEB2CEDA640A642A644A646A648A64AA64CA64EA650A652A654A656A658A65AA65CA65EA662A664A666A668A66AA66CA680A682A684A686A688A68AA68CA68EA690A692A694A696A722A724A726A728A72AA72CA72EA732A734A736A738A73AA73CA73EA740A742A744A746A748A74AA74CA74EA750A752A754A756A758A75AA75CA75EA760A762A764A766A768A76AA76CA76EA779A77BA77DA77EA780A782A784A786A78BFF21-FF3A",Lt:"01C501C801CB01F21F88-1F8F1F98-1F9F1FA8-1FAF1FBC1FCC1FFC",Lm:"02B0-02C102C6-02D102E0-02E402EC02EE0374037A0559064006E506E607F407F507FA081A0824082809710E460EC610FC17D718431AA71C78-1C7D1D2C-1D611D781D9B-1DBF2071207F2090-20942C7D2D6F2E2F30053031-3035303B309D309E30FC-30FEA015A4F8-A4FDA60CA67FA717-A71FA770A788A9CFAA70AADDFF70FF9EFF9F",Lo:"01BB01C0-01C3029405D0-05EA05F0-05F20621-063F0641-064A066E066F0671-06D306D506EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA0800-08150904-0939093D09500958-096109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E450E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10D0-10FA1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317DC1820-18421844-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C771CE9-1CEC1CEE-1CF12135-21382D30-2D652D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE3006303C3041-3096309F30A1-30FA30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A014A016-A48CA4D0-A4F7A500-A60BA610-A61FA62AA62BA66EA6A0-A6E5A7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2AA00-AA28AA40-AA42AA44-AA4BAA60-AA6FAA71-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADBAADCABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF66-FF6FFF71-FF9DFFA0-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC",M:"0300-036F0483-04890591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DE-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0903093C093E-094E0951-0955096209630981-098309BC09BE-09C409C709C809CB-09CD09D709E209E30A01-0A030A3C0A3E-0A420A470A480A4B-0A4D0A510A700A710A750A81-0A830ABC0ABE-0AC50AC7-0AC90ACB-0ACD0AE20AE30B01-0B030B3C0B3E-0B440B470B480B4B-0B4D0B560B570B620B630B820BBE-0BC20BC6-0BC80BCA-0BCD0BD70C01-0C030C3E-0C440C46-0C480C4A-0C4D0C550C560C620C630C820C830CBC0CBE-0CC40CC6-0CC80CCA-0CCD0CD50CD60CE20CE30D020D030D3E-0D440D46-0D480D4A-0D4D0D570D620D630D820D830DCA0DCF-0DD40DD60DD8-0DDF0DF20DF30E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F3E0F3F0F71-0F840F860F870F90-0F970F99-0FBC0FC6102B-103E1056-1059105E-10601062-10641067-106D1071-10741082-108D108F109A-109D135F1712-17141732-1734175217531772177317B6-17D317DD180B-180D18A91920-192B1930-193B19B0-19C019C819C91A17-1A1B1A55-1A5E1A60-1A7C1A7F1B00-1B041B34-1B441B6B-1B731B80-1B821BA1-1BAA1C24-1C371CD0-1CD21CD4-1CE81CED1CF21DC0-1DE61DFD-1DFF20D0-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66F-A672A67CA67DA6F0A6F1A802A806A80BA823-A827A880A881A8B4-A8C4A8E0-A8F1A926-A92DA947-A953A980-A983A9B3-A9C0AA29-AA36AA43AA4CAA4DAA7BAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE3-ABEAABECABEDFB1EFE00-FE0FFE20-FE26",Mn:"0300-036F0483-04870591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DF-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0902093C0941-0948094D0951-095509620963098109BC09C1-09C409CD09E209E30A010A020A3C0A410A420A470A480A4B-0A4D0A510A700A710A750A810A820ABC0AC1-0AC50AC70AC80ACD0AE20AE30B010B3C0B3F0B41-0B440B4D0B560B620B630B820BC00BCD0C3E-0C400C46-0C480C4A-0C4D0C550C560C620C630CBC0CBF0CC60CCC0CCD0CE20CE30D41-0D440D4D0D620D630DCA0DD2-0DD40DD60E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F71-0F7E0F80-0F840F860F870F90-0F970F99-0FBC0FC6102D-10301032-10371039103A103D103E10581059105E-10601071-1074108210851086108D109D135F1712-17141732-1734175217531772177317B7-17BD17C617C9-17D317DD180B-180D18A91920-19221927192819321939-193B1A171A181A561A58-1A5E1A601A621A65-1A6C1A73-1A7C1A7F1B00-1B031B341B36-1B3A1B3C1B421B6B-1B731B801B811BA2-1BA51BA81BA91C2C-1C331C361C371CD0-1CD21CD4-1CE01CE2-1CE81CED1DC0-1DE61DFD-1DFF20D0-20DC20E120E5-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66FA67CA67DA6F0A6F1A802A806A80BA825A826A8C4A8E0-A8F1A926-A92DA947-A951A980-A982A9B3A9B6-A9B9A9BCAA29-AA2EAA31AA32AA35AA36AA43AA4CAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE5ABE8ABEDFB1EFE00-FE0FFE20-FE26",Mc:"0903093E-09400949-094C094E0982098309BE-09C009C709C809CB09CC09D70A030A3E-0A400A830ABE-0AC00AC90ACB0ACC0B020B030B3E0B400B470B480B4B0B4C0B570BBE0BBF0BC10BC20BC6-0BC80BCA-0BCC0BD70C01-0C030C41-0C440C820C830CBE0CC0-0CC40CC70CC80CCA0CCB0CD50CD60D020D030D3E-0D400D46-0D480D4A-0D4C0D570D820D830DCF-0DD10DD8-0DDF0DF20DF30F3E0F3F0F7F102B102C10311038103B103C105610571062-10641067-106D108310841087-108C108F109A-109C17B617BE-17C517C717C81923-19261929-192B193019311933-193819B0-19C019C819C91A19-1A1B1A551A571A611A631A641A6D-1A721B041B351B3B1B3D-1B411B431B441B821BA11BA61BA71BAA1C24-1C2B1C341C351CE11CF2A823A824A827A880A881A8B4-A8C3A952A953A983A9B4A9B5A9BAA9BBA9BD-A9C0AA2FAA30AA33AA34AA4DAA7BABE3ABE4ABE6ABE7ABE9ABEAABEC",Me:"0488048906DE20DD-20E020E2-20E4A670-A672",N:"0030-003900B200B300B900BC-00BE0660-066906F0-06F907C0-07C90966-096F09E6-09EF09F4-09F90A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BF20C66-0C6F0C78-0C7E0CE6-0CEF0D66-0D750E50-0E590ED0-0ED90F20-0F331040-10491090-10991369-137C16EE-16F017E0-17E917F0-17F91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C5920702074-20792080-20892150-21822185-21892460-249B24EA-24FF2776-27932CFD30073021-30293038-303A3192-31953220-32293251-325F3280-328932B1-32BFA620-A629A6E6-A6EFA830-A835A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19",Nd:"0030-00390660-066906F0-06F907C0-07C90966-096F09E6-09EF0A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BEF0C66-0C6F0CE6-0CEF0D66-0D6F0E50-0E590ED0-0ED90F20-0F291040-10491090-109917E0-17E91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C59A620-A629A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19",Nl:"16EE-16F02160-21822185-218830073021-30293038-303AA6E6-A6EF",No:"00B200B300B900BC-00BE09F4-09F90BF0-0BF20C78-0C7E0D70-0D750F2A-0F331369-137C17F0-17F920702074-20792080-20892150-215F21892460-249B24EA-24FF2776-27932CFD3192-31953220-32293251-325F3280-328932B1-32BFA830-A835",P:"0021-00230025-002A002C-002F003A003B003F0040005B-005D005F007B007D00A100AB00B700BB00BF037E0387055A-055F0589058A05BE05C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F3A-0F3D0F850FD0-0FD4104A-104F10FB1361-13681400166D166E169B169C16EB-16ED1735173617D4-17D617D8-17DA1800-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD32010-20272030-20432045-20512053-205E207D207E208D208E2329232A2768-277527C527C627E6-27EF2983-299829D8-29DB29FC29FD2CF9-2CFC2CFE2CFF2E00-2E2E2E302E313001-30033008-30113014-301F3030303D30A030FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFD3EFD3FFE10-FE19FE30-FE52FE54-FE61FE63FE68FE6AFE6BFF01-FF03FF05-FF0AFF0C-FF0FFF1AFF1BFF1FFF20FF3B-FF3DFF3FFF5BFF5DFF5F-FF65",Pd:"002D058A05BE140018062010-20152E172E1A301C303030A0FE31FE32FE58FE63FF0D",Ps:"0028005B007B0F3A0F3C169B201A201E2045207D208D23292768276A276C276E27702772277427C527E627E827EA27EC27EE2983298529872989298B298D298F299129932995299729D829DA29FC2E222E242E262E283008300A300C300E3010301430163018301A301DFD3EFE17FE35FE37FE39FE3BFE3DFE3FFE41FE43FE47FE59FE5BFE5DFF08FF3BFF5BFF5FFF62",Pe:"0029005D007D0F3B0F3D169C2046207E208E232A2769276B276D276F27712773277527C627E727E927EB27ED27EF298429862988298A298C298E2990299229942996299829D929DB29FD2E232E252E272E293009300B300D300F3011301530173019301B301E301FFD3FFE18FE36FE38FE3AFE3CFE3EFE40FE42FE44FE48FE5AFE5CFE5EFF09FF3DFF5DFF60FF63",Pi:"00AB2018201B201C201F20392E022E042E092E0C2E1C2E20",Pf:"00BB2019201D203A2E032E052E0A2E0D2E1D2E21",Pc:"005F203F20402054FE33FE34FE4D-FE4FFF3F",Po:"0021-00230025-0027002A002C002E002F003A003B003F0040005C00A100B700BF037E0387055A-055F058905C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F850FD0-0FD4104A-104F10FB1361-1368166D166E16EB-16ED1735173617D4-17D617D8-17DA1800-18051807-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD3201620172020-20272030-2038203B-203E2041-20432047-205120532055-205E2CF9-2CFC2CFE2CFF2E002E012E06-2E082E0B2E0E-2E162E182E192E1B2E1E2E1F2E2A-2E2E2E302E313001-3003303D30FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFE10-FE16FE19FE30FE45FE46FE49-FE4CFE50-FE52FE54-FE57FE5F-FE61FE68FE6AFE6BFF01-FF03FF05-FF07FF0AFF0CFF0EFF0FFF1AFF1BFF1FFF20FF3CFF61FF64FF65",S:"0024002B003C-003E005E0060007C007E00A2-00A900AC00AE-00B100B400B600B800D700F702C2-02C502D2-02DF02E5-02EB02ED02EF-02FF03750384038503F604820606-0608060B060E060F06E906FD06FE07F609F209F309FA09FB0AF10B700BF3-0BFA0C7F0CF10CF20D790E3F0F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-139917DB194019E0-19FF1B61-1B6A1B74-1B7C1FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE20442052207A-207C208A-208C20A0-20B8210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B2140-2144214A-214D214F2190-2328232B-23E82400-24262440-244A249C-24E92500-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE27C0-27C427C7-27CA27CC27D0-27E527F0-29822999-29D729DC-29FB29FE-2B4C2B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F309B309C319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A700-A716A720A721A789A78AA828-A82BA836-A839AA77-AA79FB29FDFCFDFDFE62FE64-FE66FE69FF04FF0BFF1C-FF1EFF3EFF40FF5CFF5EFFE0-FFE6FFE8-FFEEFFFCFFFD",Sm:"002B003C-003E007C007E00AC00B100D700F703F60606-060820442052207A-207C208A-208C2140-2144214B2190-2194219A219B21A021A321A621AE21CE21CF21D221D421F4-22FF2308-230B23202321237C239B-23B323DC-23E125B725C125F8-25FF266F27C0-27C427C7-27CA27CC27D0-27E527F0-27FF2900-29822999-29D729DC-29FB29FE-2AFF2B30-2B442B47-2B4CFB29FE62FE64-FE66FF0BFF1C-FF1EFF5CFF5EFFE2FFE9-FFEC",Sc:"002400A2-00A5060B09F209F309FB0AF10BF90E3F17DB20A0-20B8A838FDFCFE69FF04FFE0FFE1FFE5FFE6",Sk:"005E006000A800AF00B400B802C2-02C502D2-02DF02E5-02EB02ED02EF-02FF0375038403851FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE309B309CA700-A716A720A721A789A78AFF3EFF40FFE3",So:"00A600A700A900AE00B000B60482060E060F06E906FD06FE07F609FA0B700BF3-0BF80BFA0C7F0CF10CF20D790F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-1399194019E0-19FF1B61-1B6A1B74-1B7C210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B214A214C214D214F2195-2199219C-219F21A121A221A421A521A7-21AD21AF-21CD21D021D121D321D5-21F32300-2307230C-231F2322-2328232B-237B237D-239A23B4-23DB23E2-23E82400-24262440-244A249C-24E92500-25B625B8-25C025C2-25F72600-266E2670-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE2800-28FF2B00-2B2F2B452B462B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A828-A82BA836A837A839AA77-AA79FDFDFFE4FFE8FFEDFFEEFFFCFFFD",Z:"002000A01680180E2000-200A20282029202F205F3000",Zs:"002000A01680180E2000-200A202F205F3000",Zl:"2028",Zp:"2029",C:"0000-001F007F-009F00AD03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-0605061C061D0620065F06DD070E070F074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17B417B517DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF200B-200F202A-202E2060-206F20722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-F8FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFD-FF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFFBFFFEFFFF",Cc:"0000-001F007F-009F",Cf:"00AD0600-060306DD070F17B417B5200B-200F202A-202E2060-2064206A-206FFEFFFFF9-FFFB",Co:"E000-F8FF",Cs:"D800-DFFF",Cn:"03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-05FF06040605061C061D0620065F070E074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF2065-206920722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-D7FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFDFEFEFF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFF8FFFEFFFF"})}),ace.define("ace/mode/text",["require","exports","module","ace/tokenizer","ace/mode/text_highlight_rules","ace/mode/behaviour/cstyle","ace/unicode","ace/lib/lang","ace/token_iterator","ace/range"],function(e,t,n){"use strict";var r=e("../tokenizer").Tokenizer,i=e("./text_highlight_rules").TextHighlightRules,s=e("./behaviour/cstyle").CstyleBehaviour,o=e("../unicode"),u=e("../lib/lang"),a=e("../token_iterator").TokenIterator,f=e("../range").Range,l=function(){this.HighlightRules=i};(function(){this.$behaviour=new s,this.tokenRe=new RegExp("^["+o.packages.L+o.packages.Mn+o.packages.Mc+o.packages.Nd+o.packages.Pc+"\\$_]+","g"),this.nonTokenRe=new RegExp("^(?:[^"+o.packages.L+o.packages.Mn+o.packages.Mc+o.packages.Nd+o.packages.Pc+"\\$_]|\\s])+","g"),this.getTokenizer=function(){return this.$tokenizer||(this.$highlightRules=this.$highlightRules||new this.HighlightRules(this.$highlightRuleConfig),this.$tokenizer=new r(this.$highlightRules.getRules())),this.$tokenizer},this.lineCommentStart="",this.blockComment="",this.toggleCommentLines=function(e,t,n,r){function w(e){for(var t=n;t<=r;t++)e(i.getLine(t),t)}var i=t.doc,s=!0,o=!0,a=Infinity,f=t.getTabSize(),l=!1;if(!this.lineCommentStart){if(!this.blockComment)return!1;var c=this.blockComment.start,h=this.blockComment.end,p=new RegExp("^(\\s*)(?:"+u.escapeRegExp(c)+")"),d=new RegExp("(?:"+u.escapeRegExp(h)+")\\s*$"),v=function(e,t){if(g(e,t))return;if(!s||/\S/.test(e))i.insertInLine({row:t,column:e.length},h),i.insertInLine({row:t,column:a},c)},m=function(e,t){var n;(n=e.match(d))&&i.removeInLine(t,e.length-n[0].length,e.length),(n=e.match(p))&&i.removeInLine(t,n[1].length,n[0].length)},g=function(e,n){if(p.test(e))return!0;var r=t.getTokens(n);for(var i=0;i<r.length;i++)if(r[i].type==="comment")return!0}}else{if(Array.isArray(this.lineCommentStart))var p=this.lineCommentStart.map(u.escapeRegExp).join("|"),c=this.lineCommentStart[0];else var p=u.escapeRegExp(this.lineCommentStart),c=this.lineCommentStart;p=new RegExp("^(\\s*)(?:"+p+") ?"),l=t.getUseSoftTabs();var m=function(e,t){var n=e.match(p);if(!n)return;var r=n[1].length,s=n[0].length;!b(e,r,s)&&n[0][s-1]==" "&&s--,i.removeInLine(t,r,s)},y=c+" ",v=function(e,t){if(!s||/\S/.test(e))b(e,a,a)?i.insertInLine({row:t,column:a},y):i.insertInLine({row:t,column:a},c)},g=function(e,t){return p.test(e)},b=function(e,t,n){var r=0;while(t--&&e.charAt(t)==" ")r++;if(r%f!=0)return!1;var r=0;while(e.charAt(n++)==" ")r++;return f>2?r%f!=f-1:r%f==0}}var E=Infinity;w(function(e,t){var n=e.search(/\S/);n!==-1?(n<a&&(a=n),o&&!g(e,t)&&(o=!1)):E>e.length&&(E=e.length)}),a==Infinity&&(a=E,s=!1,o=!1),l&&a%f!=0&&(a=Math.floor(a/f)*f),w(o?m:v)},this.toggleBlockComment=function(e,t,n,r){var i=this.blockComment;if(!i)return;!i.start&&i[0]&&(i=i[0]);var s=new a(t,r.row,r.column),o=s.getCurrentToken(),u=t.selection,l=t.selection.toOrientedRange(),c,h;if(o&&/comment/.test(o.type)){var p,d;while(o&&/comment/.test(o.type)){var v=o.value.indexOf(i.start);if(v!=-1){var m=s.getCurrentTokenRow(),g=s.getCurrentTokenColumn()+v;p=new f(m,g,m,g+i.start.length);break}o=s.stepBackward()}var s=new a(t,r.row,r.column),o=s.getCurrentToken();while(o&&/comment/.test(o.type)){var v=o.value.indexOf(i.end);if(v!=-1){var m=s.getCurrentTokenRow(),g=s.getCurrentTokenColumn()+v;d=new f(m,g,m,g+i.end.length);break}o=s.stepForward()}d&&t.remove(d),p&&(t.remove(p),c=p.start.row,h=-i.start.length)}else h=i.start.length,c=n.start.row,t.insert(n.end,i.end),t.insert(n.start,i.start);l.start.row==c&&(l.start.column+=h),l.end.row==c&&(l.end.column+=h),t.selection.fromOrientedRange(l)},this.getNextLineIndent=function(e,t,n){return this.$getIndent(t)},this.checkOutdent=function(e,t,n){return!1},this.autoOutdent=function(e,t,n){},this.$getIndent=function(e){return e.match(/^\s*/)[0]},this.createWorker=function(e){return null},this.createModeDelegates=function(e){this.$embeds=[],this.$modes={};for(var t in e)e[t]&&(this.$embeds.push(t),this.$modes[t]=new e[t]);var n=["toggleBlockComment","toggleCommentLines","getNextLineIndent","checkOutdent","autoOutdent","transformAction","getCompletions"];for(var t=0;t<n.length;t++)(function(e){var r=n[t],i=e[r];e[n[t]]=function(){return this.$delegator(r,arguments,i)}})(this)},this.$delegator=function(e,t,n){var r=t[0];typeof r!="string"&&(r=r[0]);for(var i=0;i<this.$embeds.length;i++){if(!this.$modes[this.$embeds[i]])continue;var s=r.split(this.$embeds[i]);if(!s[0]&&s[1]){t[0]=s[1];var o=this.$modes[this.$embeds[i]];return o[e].apply(o,t)}}var u=n.apply(this,t);return n?u:undefined},this.transformAction=function(e,t,n,r,i){if(this.$behaviour){var s=this.$behaviour.getBehaviours();for(var o in s)if(s[o][t]){var u=s[o][t].apply(this,arguments);if(u)return u}}},this.getKeywords=function(e){if(!this.completionKeywords){var t=this.$tokenizer.rules,n=[];for(var r in t){var i=t[r];for(var s=0,o=i.length;s<o;s++)if(typeof i[s].token=="string")/keyword|support|storage/.test(i[s].token)&&n.push(i[s].regex);else if(typeof i[s].token=="object")for(var u=0,a=i[s].token.length;u<a;u++)if(/keyword|support|storage/.test(i[s].token[u])){var r=i[s].regex.match(/\(.+?\)/g)[u];n.push(r.substr(1,r.length-2))}}this.completionKeywords=n}return e?n.concat(this.$keywordList||[]):this.$keywordList},this.$createKeywordList=function(){return this.$highlightRules||this.getTokenizer(),this.$keywordList=this.$highlightRules.$keywordList||[]},this.getCompletions=function(e,t,n,r){var i=this.$keywordList||this.$createKeywordList();return i.map(function(e){return{name:e,value:e,score:0,meta:"keyword"}})},this.$id="ace/mode/text"}).call(l.prototype),t.Mode=l}),ace.define("ace/apply_delta",["require","exports","module"],function(e,t,n){"use strict";function r(e,t){throw console.log("Invalid Delta:",e),"Invalid Delta: "+t}function i(e,t){return t.row>=0&&t.row<e.length&&t.column>=0&&t.column<=e[t.row].length}function s(e,t){t.action!="insert"&&t.action!="remove"&&r(t,"delta.action must be 'insert' or 'remove'"),t.lines instanceof Array||r(t,"delta.lines must be an Array"),(!t.start||!t.end)&&r(t,"delta.start/end must be an present");var n=t.start;i(e,t.start)||r(t,"delta.start must be contained in document");var s=t.end;t.action=="remove"&&!i(e,s)&&r(t,"delta.end must contained in document for 'remove' actions");var o=s.row-n.row,u=s.column-(o==0?n.column:0);(o!=t.lines.length-1||t.lines[o].length!=u)&&r(t,"delta.range must match delta lines")}t.applyDelta=function(e,t,n){var r=t.start.row,i=t.start.column,s=e[r]||"";switch(t.action){case"insert":var o=t.lines;if(o.length===1)e[r]=s.substring(0,i)+t.lines[0]+s.substring(i);else{var u=[r,1].concat(t.lines);e.splice.apply(e,u),e[r]=s.substring(0,i)+e[r],e[r+t.lines.length-1]+=s.substring(i)}break;case"remove":var a=t.end.column,f=t.end.row;r===f?e[r]=s.substring(0,i)+s.substring(a):e.splice(r,f-r+1,s.substring(0,i)+e[f].substring(a))}}}),ace.define("ace/anchor",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/event_emitter").EventEmitter,s=t.Anchor=function(e,t,n){this.$onChange=this.onChange.bind(this),this.attach(e),typeof n=="undefined"?this.setPosition(t.row,t.column):this.setPosition(t,n)};(function(){function e(e,t,n){var r=n?e.column<=t.column:e.column<t.column;return e.row<t.row||e.row==t.row&&r}function t(t,n,r){var i=t.action=="insert",s=(i?1:-1)*(t.end.row-t.start.row),o=(i?1:-1)*(t.end.column-t.start.column),u=t.start,a=i?u:t.end;return e(n,u,r)?{row:n.row,column:n.column}:e(a,n,!r)?{row:n.row+s,column:n.column+(n.row==a.row?o:0)}:{row:u.row,column:u.column}}r.implement(this,i),this.getPosition=function(){return this.$clipPositionToDocument(this.row,this.column)},this.getDocument=function(){return this.document},this.$insertRight=!1,this.onChange=function(e){if(e.start.row==e.end.row&&e.start.row!=this.row)return;if(e.start.row>this.row)return;var n=t(e,{row:this.row,column:this.column},this.$insertRight);this.setPosition(n.row,n.column,!0)},this.setPosition=function(e,t,n){var r;n?r={row:e,column:t}:r=this.$clipPositionToDocument(e,t);if(this.row==r.row&&this.column==r.column)return;var i={row:this.row,column:this.column};this.row=r.row,this.column=r.column,this._signal("change",{old:i,value:r})},this.detach=function(){this.document.removeEventListener("change",this.$onChange)},this.attach=function(e){this.document=e||this.document,this.document.on("change",this.$onChange)},this.$clipPositionToDocument=function(e,t){var n={};return e>=this.document.getLength()?(n.row=Math.max(0,this.document.getLength()-1),n.column=this.document.getLine(n.row).length):e<0?(n.row=0,n.column=0):(n.row=e,n.column=Math.min(this.document.getLine(n.row).length,Math.max(0,t))),t<0&&(n.column=0),n}}).call(s.prototype)}),ace.define("ace/document",["require","exports","module","ace/lib/oop","ace/apply_delta","ace/lib/event_emitter","ace/range","ace/anchor"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./apply_delta").applyDelta,s=e("./lib/event_emitter").EventEmitter,o=e("./range").Range,u=e("./anchor").Anchor,a=function(e){this.$lines=[""],e.length===0?this.$lines=[""]:Array.isArray(e)?this.insertMergedLines({row:0,column:0},e):this.insert({row:0,column:0},e)};(function(){r.implement(this,s),this.setValue=function(e){var t=this.getLength()-1;this.remove(new o(0,0,t,this.getLine(t).length)),this.insert({row:0,column:0},e)},this.getValue=function(){return this.getAllLines().join(this.getNewLineCharacter())},this.createAnchor=function(e,t){return new u(this,e,t)},"aaa".split(/a/).length===0?this.$split=function(e){return e.replace(/\r\n|\r/g,"\n").split("\n")}:this.$split=function(e){return e.split(/\r\n|\r|\n/)},this.$detectNewLine=function(e){var t=e.match(/^.*?(\r\n|\r|\n)/m);this.$autoNewLine=t?t[1]:"\n",this._signal("changeNewLineMode")},this.getNewLineCharacter=function(){switch(this.$newLineMode){case"windows":return"\r\n";case"unix":return"\n";default:return this.$autoNewLine||"\n"}},this.$autoNewLine="",this.$newLineMode="auto",this.setNewLineMode=function(e){if(this.$newLineMode===e)return;this.$newLineMode=e,this._signal("changeNewLineMode")},this.getNewLineMode=function(){return this.$newLineMode},this.isNewLine=function(e){return e=="\r\n"||e=="\r"||e=="\n"},this.getLine=function(e){return this.$lines[e]||""},this.getLines=function(e,t){return this.$lines.slice(e,t+1)},this.getAllLines=function(){return this.getLines(0,this.getLength())},this.getLength=function(){return this.$lines.length},this.getTextRange=function(e){return this.getLinesForRange(e).join(this.getNewLineCharacter())},this.getLinesForRange=function(e){var t;if(e.start.row===e.end.row)t=[this.getLine(e.start.row).substring(e.start.column,e.end.column)];else{t=this.getLines(e.start.row,e.end.row),t[0]=(t[0]||"").substring(e.start.column);var n=t.length-1;e.end.row-e.start.row==n&&(t[n]=t[n].substring(0,e.end.column))}return t},this.insertLines=function(e,t){return console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead."),this.insertFullLines(e,t)},this.removeLines=function(e,t){return console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead."),this.removeFullLines(e,t)},this.insertNewLine=function(e){return console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead."),this.insertMergedLines(e,["",""])},this.insert=function(e,t){return this.getLength()<=1&&this.$detectNewLine(t),this.insertMergedLines(e,this.$split(t))},this.insertInLine=function(e,t){var n=this.clippedPos(e.row,e.column),r=this.pos(e.row,e.column+t.length);return this.applyDelta({start:n,end:r,action:"insert",lines:[t]},!0),this.clonePos(r)},this.clippedPos=function(e,t){var n=this.getLength();e===undefined?e=n:e<0?e=0:e>=n&&(e=n-1,t=undefined);var r=this.getLine(e);return t==undefined&&(t=r.length),t=Math.min(Math.max(t,0),r.length),{row:e,column:t}},this.clonePos=function(e){return{row:e.row,column:e.column}},this.pos=function(e,t){return{row:e,column:t}},this.$clipPosition=function(e){var t=this.getLength();return e.row>=t?(e.row=Math.max(0,t-1),e.column=this.getLine(t-1).length):(e.row=Math.max(0,e.row),e.column=Math.min(Math.max(e.column,0),this.getLine(e.row).length)),e},this.insertFullLines=function(e,t){e=Math.min(Math.max(e,0),this.getLength());var n=0;e<this.getLength()?(t=t.concat([""]),n=0):(t=[""].concat(t),e--,n=this.$lines[e].length),this.insertMergedLines({row:e,column:n},t)},this.insertMergedLines=function(e,t){var n=this.clippedPos(e.row,e.column),r={row:n.row+t.length-1,column:(t.length==1?n.column:0)+t[t.length-1].length};return this.applyDelta({start:n,end:r,action:"insert",lines:t}),this.clonePos(r)},this.remove=function(e){var t=this.clippedPos(e.start.row,e.start.column),n=this.clippedPos(e.end.row,e.end.column);return this.applyDelta({start:t,end:n,action:"remove",lines:this.getLinesForRange({start:t,end:n})}),this.clonePos(t)},this.removeInLine=function(e,t,n){var r=this.clippedPos(e,t),i=this.clippedPos(e,n);return this.applyDelta({start:r,end:i,action:"remove",lines:this.getLinesForRange({start:r,end:i})},!0),this.clonePos(r)},this.removeFullLines=function(e,t){e=Math.min(Math.max(0,e),this.getLength()-1),t=Math.min(Math.max(0,t),this.getLength()-1);var n=t==this.getLength()-1&&e>0,r=t<this.getLength()-1,i=n?e-1:e,s=n?this.getLine(i).length:0,u=r?t+1:t,a=r?0:this.getLine(u).length,f=new o(i,s,u,a),l=this.$lines.slice(e,t+1);return this.applyDelta({start:f.start,end:f.end,action:"remove",lines:this.getLinesForRange(f)}),l},this.removeNewLine=function(e){e<this.getLength()-1&&e>=0&&this.applyDelta({start:this.pos(e,this.getLine(e).length),end:this.pos(e+1,0),action:"remove",lines:["",""]})},this.replace=function(e,t){e instanceof o||(e=o.fromPoints(e.start,e.end));if(t.length===0&&e.isEmpty())return e.start;if(t==this.getTextRange(e))return e.end;this.remove(e);var n;return t?n=this.insert(e.start,t):n=e.start,n},this.applyDeltas=function(e){for(var t=0;t<e.length;t++)this.applyDelta(e[t])},this.revertDeltas=function(e){for(var t=e.length-1;t>=0;t--)this.revertDelta(e[t])},this.applyDelta=function(e,t){var n=e.action=="insert";if(n?e.lines.length<=1&&!e.lines[0]:!o.comparePoints(e.start,e.end))return;n&&e.lines.length>2e4&&this.$splitAndapplyLargeDelta(e,2e4),i(this.$lines,e,t),this._signal("change",e)},this.$splitAndapplyLargeDelta=function(e,t){var n=e.lines,r=n.length,i=e.start.row,s=e.start.column,o=0,u=0;do{o=u,u+=t-1;var a=n.slice(o,u);if(u>r){e.lines=a,e.start.row=i+o,e.start.column=s;break}a.push(""),this.applyDelta({start:this.pos(i+o,s),end:this.pos(i+u,s=0),action:e.action,lines:a},!0)}while(!0)},this.revertDelta=function(e){this.applyDelta({start:this.clonePos(e.start),end:this.clonePos(e.end),action:e.action=="insert"?"remove":"insert",lines:e.lines.slice()})},this.indexToPosition=function(e,t){var n=this.$lines||this.getAllLines(),r=this.getNewLineCharacter().length;for(var i=t||0,s=n.length;i<s;i++){e-=n[i].length+r;if(e<0)return{row:i,column:e+n[i].length+r}}return{row:s-1,column:n[s-1].length}},this.positionToIndex=function(e,t){var n=this.$lines||this.getAllLines(),r=this.getNewLineCharacter().length,i=0,s=Math.min(e.row,n.length);for(var o=t||0;o<s;++o)i+=n[o].length+r;return i+e.column}}).call(a.prototype),t.Document=a}),ace.define("ace/background_tokenizer",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/event_emitter").EventEmitter,s=function(e,t){this.running=!1,this.lines=[],this.states=[],this.currentLine=0,this.tokenizer=e;var n=this;this.$worker=function(){if(!n.running)return;var e=new Date,t=n.currentLine,r=-1,i=n.doc,s=t;while(n.lines[t])t++;var o=i.getLength(),u=0;n.running=!1;while(t<o){n.$tokenizeRow(t),r=t;do t++;while(n.lines[t]);u++;if(u%5===0&&new Date-e>20){n.running=setTimeout(n.$worker,20);break}}n.currentLine=t,s<=r&&n.fireUpdateEvent(s,r)}};(function(){r.implement(this,i),this.setTokenizer=function(e){this.tokenizer=e,this.lines=[],this.states=[],this.start(0)},this.setDocument=function(e){this.doc=e,this.lines=[],this.states=[],this.stop()},this.fireUpdateEvent=function(e,t){var n={first:e,last:t};this._signal("update",{data:n})},this.start=function(e){this.currentLine=Math.min(e||0,this.currentLine,this.doc.getLength()),this.lines.splice(this.currentLine,this.lines.length),this.states.splice(this.currentLine,this.states.length),this.stop(),this.running=setTimeout(this.$worker,700)},this.scheduleStart=function(){this.running||(this.running=setTimeout(this.$worker,700))},this.$updateOnChange=function(e){var t=e.start.row,n=e.end.row-t;if(n===0)this.lines[t]=null;else if(e.action=="remove")this.lines.splice(t,n+1,null),this.states.splice(t,n+1,null);else{var r=Array(n+1);r.unshift(t,1),this.lines.splice.apply(this.lines,r),this.states.splice.apply(this.states,r)}this.currentLine=Math.min(t,this.currentLine,this.doc.getLength()),this.stop()},this.stop=function(){this.running&&clearTimeout(this.running),this.running=!1},this.getTokens=function(e){return this.lines[e]||this.$tokenizeRow(e)},this.getState=function(e){return this.currentLine==e&&this.$tokenizeRow(e),this.states[e]||"start"},this.$tokenizeRow=function(e){var t=this.doc.getLine(e),n=this.states[e-1],r=this.tokenizer.getLineTokens(t,n,e);return this.states[e]+""!=r.state+""?(this.states[e]=r.state,this.lines[e+1]=null,this.currentLine>e+1&&(this.currentLine=e+1)):this.currentLine==e&&(this.currentLine=e+1),this.lines[e]=r.tokens}}).call(s.prototype),t.BackgroundTokenizer=s}),ace.define("ace/search_highlight",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"],function(e,t,n){"use strict";var r=e("./lib/lang"),i=e("./lib/oop"),s=e("./range").Range,o=function(e,t,n){this.setRegexp(e),this.clazz=t,this.type=n||"text"};(function(){this.MAX_RANGES=500,this.setRegexp=function(e){if(this.regExp+""==e+"")return;this.regExp=e,this.cache=[]},this.update=function(e,t,n,i){if(!this.regExp)return;var o=i.firstRow,u=i.lastRow;for(var a=o;a<=u;a++){var f=this.cache[a];f==null&&(f=r.getMatchOffsets(n.getLine(a),this.regExp),f.length>this.MAX_RANGES&&(f=f.slice(0,this.MAX_RANGES)),f=f.map(function(e){return new s(a,e.offset,a,e.offset+e.length)}),this.cache[a]=f.length?f:"");for(var l=f.length;l--;)t.drawSingleLineMarker(e,f[l].toScreenRange(n),this.clazz,i)}}}).call(o.prototype),t.SearchHighlight=o}),ace.define("ace/edit_session/fold_line",["require","exports","module","ace/range"],function(e,t,n){"use strict";function i(e,t){this.foldData=e,Array.isArray(t)?this.folds=t:t=this.folds=[t];var n=t[t.length-1];this.range=new r(t[0].start.row,t[0].start.column,n.end.row,n.end.column),this.start=this.range.start,this.end=this.range.end,this.folds.forEach(function(e){e.setFoldLine(this)},this)}var r=e("../range").Range;(function(){this.shiftRow=function(e){this.start.row+=e,this.end.row+=e,this.folds.forEach(function(t){t.start.row+=e,t.end.row+=e})},this.addFold=function(e){if(e.sameRow){if(e.start.row<this.startRow||e.endRow>this.endRow)throw new Error("Can't add a fold to this FoldLine as it has no connection");this.folds.push(e),this.folds.sort(function(e,t){return-e.range.compareEnd(t.start.row,t.start.column)}),this.range.compareEnd(e.start.row,e.start.column)>0?(this.end.row=e.end.row,this.end.column=e.end.column):this.range.compareStart(e.end.row,e.end.column)<0&&(this.start.row=e.start.row,this.start.column=e.start.column)}else if(e.start.row==this.end.row)this.folds.push(e),this.end.row=e.end.row,this.end.column=e.end.column;else{if(e.end.row!=this.start.row)throw new Error("Trying to add fold to FoldRow that doesn't have a matching row");this.folds.unshift(e),this.start.row=e.start.row,this.start.column=e.start.column}e.foldLine=this},this.containsRow=function(e){return e>=this.start.row&&e<=this.end.row},this.walk=function(e,t,n){var r=0,i=this.folds,s,o,u,a=!0;t==null&&(t=this.end.row,n=this.end.column);for(var f=0;f<i.length;f++){s=i[f],o=s.range.compareStart(t,n);if(o==-1){e(null,t,n,r,a);return}u=e(null,s.start.row,s.start.column,r,a),u=!u&&e(s.placeholder,s.start.row,s.start.column,r);if(u||o===0)return;a=!s.sameRow,r=s.end.column}e(null,t,n,r,a)},this.getNextFoldTo=function(e,t){var n,r;for(var i=0;i<this.folds.length;i++){n=this.folds[i],r=n.range.compareEnd(e,t);if(r==-1)return{fold:n,kind:"after"};if(r===0)return{fold:n,kind:"inside"}}return null},this.addRemoveChars=function(e,t,n){var r=this.getNextFoldTo(e,t),i,s;if(r){i=r.fold;if(r.kind=="inside"&&i.start.column!=t&&i.start.row!=e)window.console&&window.console.log(e,t,i);else if(i.start.row==e){s=this.folds;var o=s.indexOf(i);o===0&&(this.start.column+=n);for(o;o<s.length;o++){i=s[o],i.start.column+=n;if(!i.sameRow)return;i.end.column+=n}this.end.column+=n}}},this.split=function(e,t){var n=this.getNextFoldTo(e,t);if(!n||n.kind=="inside")return null;var r=n.fold,s=this.folds,o=this.foldData,u=s.indexOf(r),a=s[u-1];this.end.row=a.end.row,this.end.column=a.end.column,s=s.splice(u,s.length-u);var f=new i(o,s);return o.splice(o.indexOf(this)+1,0,f),f},this.merge=function(e){var t=e.folds;for(var n=0;n<t.length;n++)this.addFold(t[n]);var r=this.foldData;r.splice(r.indexOf(e),1)},this.toString=function(){var e=[this.range.toString()+": ["];return this.folds.forEach(function(t){e.push(" "+t.toString())}),e.push("]"),e.join("\n")},this.idxToPosition=function(e){var t=0;for(var n=0;n<this.folds.length;n++){var r=this.folds[n];e-=r.start.column-t;if(e<0)return{row:r.start.row,column:r.start.column+e};e-=r.placeholder.length;if(e<0)return r.start;t=r.end.column}return{row:this.end.row,column:this.end.column+e}}}).call(i.prototype),t.FoldLine=i}),ace.define("ace/range_list",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("./range").Range,i=r.comparePoints,s=function(){this.ranges=[]};(function(){this.comparePoints=i,this.pointIndex=function(e,t,n){var r=this.ranges;for(var s=n||0;s<r.length;s++){var o=r[s],u=i(e,o.end);if(u>0)continue;var a=i(e,o.start);return u===0?t&&a!==0?-s-2:s:a>0||a===0&&!t?s:-s-1}return-s-1},this.add=function(e){var t=!e.isEmpty(),n=this.pointIndex(e.start,t);n<0&&(n=-n-1);var r=this.pointIndex(e.end,t,n);return r<0?r=-r-1:r++,this.ranges.splice(n,r-n,e)},this.addList=function(e){var t=[];for(var n=e.length;n--;)t.push.apply(t,this.add(e[n]));return t},this.substractPoint=function(e){var t=this.pointIndex(e);if(t>=0)return this.ranges.splice(t,1)},this.merge=function(){var e=[],t=this.ranges;t=t.sort(function(e,t){return i(e.start,t.start)});var n=t[0],r;for(var s=1;s<t.length;s++){r=n,n=t[s];var o=i(r.end,n.start);if(o<0)continue;if(o==0&&!r.isEmpty()&&!n.isEmpty())continue;i(r.end,n.end)<0&&(r.end.row=n.end.row,r.end.column=n.end.column),t.splice(s,1),e.push(n),n=r,s--}return this.ranges=t,e},this.contains=function(e,t){return this.pointIndex({row:e,column:t})>=0},this.containsPoint=function(e){return this.pointIndex(e)>=0},this.rangeAtPoint=function(e){var t=this.pointIndex(e);if(t>=0)return this.ranges[t]},this.clipRows=function(e,t){var n=this.ranges;if(n[0].start.row>t||n[n.length-1].start.row<e)return[];var r=this.pointIndex({row:e,column:0});r<0&&(r=-r-1);var i=this.pointIndex({row:t,column:0},r);i<0&&(i=-i-1);var s=[];for(var o=r;o<i;o++)s.push(n[o]);return s},this.removeAll=function(){return this.ranges.splice(0,this.ranges.length)},this.attach=function(e){this.session&&this.detach(),this.session=e,this.onChange=this.$onChange.bind(this),this.session.on("change",this.onChange)},this.detach=function(){if(!this.session)return;this.session.removeListener("change",this.onChange),this.session=null},this.$onChange=function(e){if(e.action=="insert")var t=e.start,n=e.end;else var n=e.start,t=e.end;var r=t.row,i=n.row,s=i-r,o=-t.column+n.column,u=this.ranges;for(var a=0,f=u.length;a<f;a++){var l=u[a];if(l.end.row<r)continue;if(l.start.row>r)break;l.start.row==r&&l.start.column>=t.column&&(l.start.column!=t.column||!this.$insertRight)&&(l.start.column+=o,l.start.row+=s);if(l.end.row==r&&l.end.column>=t.column){if(l.end.column==t.column&&this.$insertRight)continue;l.end.column==t.column&&o>0&&a<f-1&&l.end.column>l.start.column&&l.end.column==u[a+1].start.column&&(l.end.column-=o),l.end.column+=o,l.end.row+=s}}if(s!=0&&a<f)for(;a<f;a++){var l=u[a];l.start.row+=s,l.end.row+=s}}}).call(s.prototype),t.RangeList=s}),ace.define("ace/edit_session/fold",["require","exports","module","ace/range","ace/range_list","ace/lib/oop"],function(e,t,n){"use strict";function u(e,t){e.row-=t.row,e.row==0&&(e.column-=t.column)}function a(e,t){u(e.start,t),u(e.end,t)}function f(e,t){e.row==0&&(e.column+=t.column),e.row+=t.row}function l(e,t){f(e.start,t),f(e.end,t)}var r=e("../range").Range,i=e("../range_list").RangeList,s=e("../lib/oop"),o=t.Fold=function(e,t){this.foldLine=null,this.placeholder=t,this.range=e,this.start=e.start,this.end=e.end,this.sameRow=e.start.row==e.end.row,this.subFolds=this.ranges=[]};s.inherits(o,i),function(){this.toString=function(){return'"'+this.placeholder+'" '+this.range.toString()},this.setFoldLine=function(e){this.foldLine=e,this.subFolds.forEach(function(t){t.setFoldLine(e)})},this.clone=function(){var e=this.range.clone(),t=new o(e,this.placeholder);return this.subFolds.forEach(function(e){t.subFolds.push(e.clone())}),t.collapseChildren=this.collapseChildren,t},this.addSubFold=function(e){if(this.range.isEqual(e))return;if(!this.range.containsRange(e))throw new Error("A fold can't intersect already existing fold"+e.range+this.range);a(e,this.start);var t=e.start.row,n=e.start.column;for(var r=0,i=-1;r<this.subFolds.length;r++){i=this.subFolds[r].range.compare(t,n);if(i!=1)break}var s=this.subFolds[r];if(i==0)return s.addSubFold(e);var t=e.range.end.row,n=e.range.end.column;for(var o=r,i=-1;o<this.subFolds.length;o++){i=this.subFolds[o].range.compare(t,n);if(i!=1)break}var u=this.subFolds[o];if(i==0)throw new Error("A fold can't intersect already existing fold"+e.range+this.range);var f=this.subFolds.splice(r,o-r,e);return e.setFoldLine(this.foldLine),e},this.restoreRange=function(e){return l(e,this.start)}}.call(o.prototype)}),ace.define("ace/edit_session/folding",["require","exports","module","ace/range","ace/edit_session/fold_line","ace/edit_session/fold","ace/token_iterator"],function(e,t,n){"use strict";function u(){this.getFoldAt=function(e,t,n){var r=this.getFoldLine(e);if(!r)return null;var i=r.folds;for(var s=0;s<i.length;s++){var o=i[s];if(o.range.contains(e,t)){if(n==1&&o.range.isEnd(e,t))continue;if(n==-1&&o.range.isStart(e,t))continue;return o}}},this.getFoldsInRange=function(e){var t=e.start,n=e.end,r=this.$foldData,i=[];t.column+=1,n.column-=1;for(var s=0;s<r.length;s++){var o=r[s].range.compareRange(e);if(o==2)continue;if(o==-2)break;var u=r[s].folds;for(var a=0;a<u.length;a++){var f=u[a];o=f.range.compareRange(e);if(o==-2)break;if(o==2)continue;if(o==42)break;i.push(f)}}return t.column-=1,n.column+=1,i},this.getFoldsInRangeList=function(e){if(Array.isArray(e)){var t=[];e.forEach(function(e){t=t.concat(this.getFoldsInRange(e))},this)}else var t=this.getFoldsInRange(e);return t},this.getAllFolds=function(){var e=[],t=this.$foldData;for(var n=0;n<t.length;n++)for(var r=0;r<t[n].folds.length;r++)e.push(t[n].folds[r]);return e},this.getFoldStringAt=function(e,t,n,r){r=r||this.getFoldLine(e);if(!r)return null;var i={end:{column:0}},s,o;for(var u=0;u<r.folds.length;u++){o=r.folds[u];var a=o.range.compareEnd(e,t);if(a==-1){s=this.getLine(o.start.row).substring(i.end.column,o.start.column);break}if(a===0)return null;i=o}return s||(s=this.getLine(o.start.row).substring(i.end.column)),n==-1?s.substring(0,t-i.end.column):n==1?s.substring(t-i.end.column):s},this.getFoldLine=function(e,t){var n=this.$foldData,r=0;t&&(r=n.indexOf(t)),r==-1&&(r=0);for(r;r<n.length;r++){var i=n[r];if(i.start.row<=e&&i.end.row>=e)return i;if(i.end.row>e)return null}return null},this.getNextFoldLine=function(e,t){var n=this.$foldData,r=0;t&&(r=n.indexOf(t)),r==-1&&(r=0);for(r;r<n.length;r++){var i=n[r];if(i.end.row>=e)return i}return null},this.getFoldedRowCount=function(e,t){var n=this.$foldData,r=t-e+1;for(var i=0;i<n.length;i++){var s=n[i],o=s.end.row,u=s.start.row;if(o>=t){u<t&&(u>=e?r-=t-u:r=0);break}o>=e&&(u>=e?r-=o-u:r-=o-e+1)}return r},this.$addFoldLine=function(e){return this.$foldData.push(e),this.$foldData.sort(function(e,t){return e.start.row-t.start.row}),e},this.addFold=function(e,t){var n=this.$foldData,r=!1,o;e instanceof s?o=e:(o=new s(t,e),o.collapseChildren=t.collapseChildren),this.$clipRangeToDocument(o.range);var u=o.start.row,a=o.start.column,f=o.end.row,l=o.end.column;if(u<f||u==f&&a<=l-2){var c=this.getFoldAt(u,a,1),h=this.getFoldAt(f,l,-1);if(c&&h==c)return c.addSubFold(o);c&&!c.range.isStart(u,a)&&this.removeFold(c),h&&!h.range.isEnd(f,l)&&this.removeFold(h);var p=this.getFoldsInRange(o.range);p.length>0&&(this.removeFolds(p),p.forEach(function(e){o.addSubFold(e)}));for(var d=0;d<n.length;d++){var v=n[d];if(f==v.start.row){v.addFold(o),r=!0;break}if(u==v.end.row){v.addFold(o),r=!0;if(!o.sameRow){var m=n[d+1];if(m&&m.start.row==f){v.merge(m);break}}break}if(f<=v.start.row)break}return r||(v=this.$addFoldLine(new i(this.$foldData,o))),this.$useWrapMode?this.$updateWrapData(v.start.row,v.start.row):this.$updateRowLengthCache(v.start.row,v.start.row),this.$modified=!0,this._signal("changeFold",{data:o,action:"add"}),o}throw new Error("The range has to be at least 2 characters width")},this.addFolds=function(e){e.forEach(function(e){this.addFold(e)},this)},this.removeFold=function(e){var t=e.foldLine,n=t.start.row,r=t.end.row,i=this.$foldData,s=t.folds;if(s.length==1)i.splice(i.indexOf(t),1);else if(t.range.isEnd(e.end.row,e.end.column))s.pop(),t.end.row=s[s.length-1].end.row,t.end.column=s[s.length-1].end.column;else if(t.range.isStart(e.start.row,e.start.column))s.shift(),t.start.row=s[0].start.row,t.start.column=s[0].start.column;else if(e.sameRow)s.splice(s.indexOf(e),1);else{var o=t.split(e.start.row,e.start.column);s=o.folds,s.shift(),o.start.row=s[0].start.row,o.start.column=s[0].start.column}this.$updating||(this.$useWrapMode?this.$updateWrapData(n,r):this.$updateRowLengthCache(n,r)),this.$modified=!0,this._signal("changeFold",{data:e,action:"remove"})},this.removeFolds=function(e){var t=[];for(var n=0;n<e.length;n++)t.push(e[n]);t.forEach(function(e){this.removeFold(e)},this),this.$modified=!0},this.expandFold=function(e){this.removeFold(e),e.subFolds.forEach(function(t){e.restoreRange(t),this.addFold(t)},this),e.collapseChildren>0&&this.foldAll(e.start.row+1,e.end.row,e.collapseChildren-1),e.subFolds=[]},this.expandFolds=function(e){e.forEach(function(e){this.expandFold(e)},this)},this.unfold=function(e,t){var n,i;e==null?(n=new r(0,0,this.getLength(),0),t=!0):typeof e=="number"?n=new r(e,0,e,this.getLine(e).length):"row"in e?n=r.fromPoints(e,e):n=e,i=this.getFoldsInRangeList(n);if(t)this.removeFolds(i);else{var s=i;while(s.length)this.expandFolds(s),s=this.getFoldsInRangeList(n)}if(i.length)return i},this.isRowFolded=function(e,t){return!!this.getFoldLine(e,t)},this.getRowFoldEnd=function(e,t){var n=this.getFoldLine(e,t);return n?n.end.row:e},this.getRowFoldStart=function(e,t){var n=this.getFoldLine(e,t);return n?n.start.row:e},this.getFoldDisplayLine=function(e,t,n,r,i){r==null&&(r=e.start.row),i==null&&(i=0),t==null&&(t=e.end.row),n==null&&(n=this.getLine(t).length);var s=this.doc,o="";return e.walk(function(e,t,n,u){if(t<r)return;if(t==r){if(n<i)return;u=Math.max(i,u)}e!=null?o+=e:o+=s.getLine(t).substring(u,n)},t,n),o},this.getDisplayLine=function(e,t,n,r){var i=this.getFoldLine(e);if(!i){var s;return s=this.doc.getLine(e),s.substring(r||0,t||s.length)}return this.getFoldDisplayLine(i,e,t,n,r)},this.$cloneFoldData=function(){var e=[];return e=this.$foldData.map(function(t){var n=t.folds.map(function(e){return e.clone()});return new i(e,n)}),e},this.toggleFold=function(e){var t=this.selection,n=t.getRange(),r,i;if(n.isEmpty()){var s=n.start;r=this.getFoldAt(s.row,s.column);if(r){this.expandFold(r);return}(i=this.findMatchingBracket(s))?n.comparePoint(i)==1?n.end=i:(n.start=i,n.start.column++,n.end.column--):(i=this.findMatchingBracket({row:s.row,column:s.column+1}))?(n.comparePoint(i)==1?n.end=i:n.start=i,n.start.column++):n=this.getCommentFoldRange(s.row,s.column)||n}else{var o=this.getFoldsInRange(n);if(e&&o.length){this.expandFolds(o);return}o.length==1&&(r=o[0])}r||(r=this.getFoldAt(n.start.row,n.start.column));if(r&&r.range.toString()==n.toString()){this.expandFold(r);return}var u="...";if(!n.isMultiLine()){u=this.getTextRange(n);if(u.length<4)return;u=u.trim().substring(0,2)+".."}this.addFold(u,n)},this.getCommentFoldRange=function(e,t,n){var i=new o(this,e,t),s=i.getCurrentToken();if(s&&/^comment|string/.test(s.type)){var u=new r,a=new RegExp(s.type.replace(/\..*/,"\\."));if(n!=1){do s=i.stepBackward();while(s&&a.test(s.type));i.stepForward()}u.start.row=i.getCurrentTokenRow(),u.start.column=i.getCurrentTokenColumn()+2,i=new o(this,e,t);if(n!=-1){do s=i.stepForward();while(s&&a.test(s.type));s=i.stepBackward()}else s=i.getCurrentToken();return u.end.row=i.getCurrentTokenRow(),u.end.column=i.getCurrentTokenColumn()+s.value.length-2,u}},this.foldAll=function(e,t,n){n==undefined&&(n=1e5);var r=this.foldWidgets;if(!r)return;t=t||this.getLength(),e=e||0;for(var i=e;i<t;i++){r[i]==null&&(r[i]=this.getFoldWidget(i));if(r[i]!="start")continue;var s=this.getFoldWidgetRange(i);if(s&&s.isMultiLine()&&s.end.row<=t&&s.start.row>=e){i=s.end.row;try{var o=this.addFold("...",s);o&&(o.collapseChildren=n)}catch(u){}}}},this.$foldStyles={manual:1,markbegin:1,markbeginend:1},this.$foldStyle="markbegin",this.setFoldStyle=function(e){if(!this.$foldStyles[e])throw new Error("invalid fold style: "+e+"["+Object.keys(this.$foldStyles).join(", ")+"]");if(this.$foldStyle==e)return;this.$foldStyle=e,e=="manual"&&this.unfold();var t=this.$foldMode;this.$setFolding(null),this.$setFolding(t)},this.$setFolding=function(e){if(this.$foldMode==e)return;this.$foldMode=e,this.off("change",this.$updateFoldWidgets),this.off("tokenizerUpdate",this.$tokenizerUpdateFoldWidgets),this._signal("changeAnnotation");if(!e||this.$foldStyle=="manual"){this.foldWidgets=null;return}this.foldWidgets=[],this.getFoldWidget=e.getFoldWidget.bind(e,this,this.$foldStyle),this.getFoldWidgetRange=e.getFoldWidgetRange.bind(e,this,this.$foldStyle),this.$updateFoldWidgets=this.updateFoldWidgets.bind(this),this.$tokenizerUpdateFoldWidgets=this.tokenizerUpdateFoldWidgets.bind(this),this.on("change",this.$updateFoldWidgets),this.on("tokenizerUpdate",this.$tokenizerUpdateFoldWidgets)},this.getParentFoldRangeData=function(e,t){var n=this.foldWidgets;if(!n||t&&n[e])return{};var r=e-1,i;while(r>=0){var s=n[r];s==null&&(s=n[r]=this.getFoldWidget(r));if(s=="start"){var o=this.getFoldWidgetRange(r);i||(i=o);if(o&&o.end.row>=e)break}r--}return{range:r!==-1&&o,firstRange:i}},this.onFoldWidgetClick=function(e,t){t=t.domEvent;var n={children:t.shiftKey,all:t.ctrlKey||t.metaKey,siblings:t.altKey},r=this.$toggleFoldWidget(e,n);if(!r){var i=t.target||t.srcElement;i&&/ace_fold-widget/.test(i.className)&&(i.className+=" ace_invalid")}},this.$toggleFoldWidget=function(e,t){if(!this.getFoldWidget)return;var n=this.getFoldWidget(e),r=this.getLine(e),i=n==="end"?-1:1,s=this.getFoldAt(e,i===-1?0:r.length,i);if(s)return t.children||t.all?this.removeFold(s):this.expandFold(s),s;var o=this.getFoldWidgetRange(e,!0);if(o&&!o.isMultiLine()){s=this.getFoldAt(o.start.row,o.start.column,1);if(s&&o.isEqual(s.range))return this.removeFold(s),s}if(t.siblings){var u=this.getParentFoldRangeData(e);if(u.range)var a=u.range.start.row+1,f=u.range.end.row;this.foldAll(a,f,t.all?1e4:0)}else t.children?(f=o?o.end.row:this.getLength(),this.foldAll(e+1,f,t.all?1e4:0)):o&&(t.all&&(o.collapseChildren=1e4),this.addFold("...",o));return o},this.toggleFoldWidget=function(e){var t=this.selection.getCursor().row;t=this.getRowFoldStart(t);var n=this.$toggleFoldWidget(t,{});if(n)return;var r=this.getParentFoldRangeData(t,!0);n=r.range||r.firstRange;if(n){t=n.start.row;var i=this.getFoldAt(t,this.getLine(t).length,1);i?this.removeFold(i):this.addFold("...",n)}},this.updateFoldWidgets=function(e){var t=e.start.row,n=e.end.row-t;if(n===0)this.foldWidgets[t]=null;else if(e.action=="remove")this.foldWidgets.splice(t,n+1,null);else{var r=Array(n+1);r.unshift(t,1),this.foldWidgets.splice.apply(this.foldWidgets,r)}},this.tokenizerUpdateFoldWidgets=function(e){var t=e.data;t.first!=t.last&&this.foldWidgets.length>t.first&&this.foldWidgets.splice(t.first,this.foldWidgets.length)}}var r=e("../range").Range,i=e("./fold_line").FoldLine,s=e("./fold").Fold,o=e("../token_iterator").TokenIterator;t.Folding=u}),ace.define("ace/edit_session/bracket_match",["require","exports","module","ace/token_iterator","ace/range"],function(e,t,n){"use strict";function s(){this.findMatchingBracket=function(e,t){if(e.column==0)return null;var n=t||this.getLine(e.row).charAt(e.column-1);if(n=="")return null;var r=n.match(/([\(\[\{])|([\)\]\}])/);return r?r[1]?this.$findClosingBracket(r[1],e):this.$findOpeningBracket(r[2],e):null},this.getBracketRange=function(e){var t=this.getLine(e.row),n=!0,r,s=t.charAt(e.column-1),o=s&&s.match(/([\(\[\{])|([\)\]\}])/);o||(s=t.charAt(e.column),e={row:e.row,column:e.column+1},o=s&&s.match(/([\(\[\{])|([\)\]\}])/),n=!1);if(!o)return null;if(o[1]){var u=this.$findClosingBracket(o[1],e);if(!u)return null;r=i.fromPoints(e,u),n||(r.end.column++,r.start.column--),r.cursor=r.end}else{var u=this.$findOpeningBracket(o[2],e);if(!u)return null;r=i.fromPoints(u,e),n||(r.start.column++,r.end.column--),r.cursor=r.start}return r},this.$brackets={")":"(","(":")","]":"[","[":"]","{":"}","}":"{"},this.$findOpeningBracket=function(e,t,n){var i=this.$brackets[e],s=1,o=new r(this,t.row,t.column),u=o.getCurrentToken();u||(u=o.stepForward());if(!u)return;n||(n=new RegExp("(\\.?"+u.type.replace(".","\\.").replace("rparen",".paren").replace(/\b(?:end)\b/,"(?:start|begin|end)")+")+"));var a=t.column-o.getCurrentTokenColumn()-2,f=u.value;for(;;){while(a>=0){var l=f.charAt(a);if(l==i){s-=1;if(s==0)return{row:o.getCurrentTokenRow(),column:a+o.getCurrentTokenColumn()}}else l==e&&(s+=1);a-=1}do u=o.stepBackward();while(u&&!n.test(u.type));if(u==null)break;f=u.value,a=f.length-1}return null},this.$findClosingBracket=function(e,t,n){var i=this.$brackets[e],s=1,o=new r(this,t.row,t.column),u=o.getCurrentToken();u||(u=o.stepForward());if(!u)return;n||(n=new RegExp("(\\.?"+u.type.replace(".","\\.").replace("lparen",".paren").replace(/\b(?:start|begin)\b/,"(?:start|begin|end)")+")+"));var a=t.column-o.getCurrentTokenColumn();for(;;){var f=u.value,l=f.length;while(a<l){var c=f.charAt(a);if(c==i){s-=1;if(s==0)return{row:o.getCurrentTokenRow(),column:a+o.getCurrentTokenColumn()}}else c==e&&(s+=1);a+=1}do u=o.stepForward();while(u&&!n.test(u.type));if(u==null)break;a=0}return null}}var r=e("../token_iterator").TokenIterator,i=e("../range").Range;t.BracketMatch=s}),ace.define("ace/edit_session",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/config","ace/lib/event_emitter","ace/selection","ace/mode/text","ace/range","ace/document","ace/background_tokenizer","ace/search_highlight","ace/edit_session/folding","ace/edit_session/bracket_match"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/lang"),s=e("./config"),o=e("./lib/event_emitter").EventEmitter,u=e("./selection").Selection,a=e("./mode/text").Mode,f=e("./range").Range,l=e("./document").Document,c=e("./background_tokenizer").BackgroundTokenizer,h=e("./search_highlight").SearchHighlight,p=function(e,t){this.$breakpoints=[],this.$decorations=[],this.$frontMarkers={},this.$backMarkers={},this.$markerId=1,this.$undoSelect=!0,this.$foldData=[],this.id="session"+ ++p.$uid,this.$foldData.toString=function(){return this.join("\n")},this.on("changeFold",this.onChangeFold.bind(this)),this.$onChange=this.onChange.bind(this);if(typeof e!="object"||!e.getLine)e=new l(e);this.setDocument(e),this.selection=new u(this),s.resetOptions(this),this.setMode(t),s._signal("session",this)};(function(){function m(e){return e<4352?!1:e>=4352&&e<=4447||e>=4515&&e<=4519||e>=4602&&e<=4607||e>=9001&&e<=9002||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12283||e>=12288&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12589||e>=12593&&e<=12686||e>=12688&&e<=12730||e>=12736&&e<=12771||e>=12784&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=13054||e>=13056&&e<=19903||e>=19968&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=55216&&e<=55238||e>=55243&&e<=55291||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=65281&&e<=65376||e>=65504&&e<=65510}r.implement(this,o),this.setDocument=function(e){this.doc&&this.doc.removeListener("change",this.$onChange),this.doc=e,e.on("change",this.$onChange),this.bgTokenizer&&this.bgTokenizer.setDocument(this.getDocument()),this.resetCaches()},this.getDocument=function(){return this.doc},this.$resetRowCache=function(e){if(!e){this.$docRowCache=[],this.$screenRowCache=[];return}var t=this.$docRowCache.length,n=this.$getRowCacheIndex(this.$docRowCache,e)+1;t>n&&(this.$docRowCache.splice(n,t),this.$screenRowCache.splice(n,t))},this.$getRowCacheIndex=function(e,t){var n=0,r=e.length-1;while(n<=r){var i=n+r>>1,s=e[i];if(t>s)n=i+1;else{if(!(t<s))return i;r=i-1}}return n-1},this.resetCaches=function(){this.$modified=!0,this.$wrapData=[],this.$rowLengthCache=[],this.$resetRowCache(0),this.bgTokenizer&&this.bgTokenizer.start(0)},this.onChangeFold=function(e){var t=e.data;this.$resetRowCache(t.start.row)},this.onChange=function(e){this.$modified=!0,this.$resetRowCache(e.start.row);var t=this.$updateInternalDataOnChange(e);!this.$fromUndo&&this.$undoManager&&!e.ignore&&(this.$deltasDoc.push(e),t&&t.length!=0&&this.$deltasFold.push({action:"removeFolds",folds:t}),this.$informUndoManager.schedule()),this.bgTokenizer&&this.bgTokenizer.$updateOnChange(e),this._signal("change",e)},this.setValue=function(e){this.doc.setValue(e),this.selection.moveTo(0,0),this.$resetRowCache(0),this.$deltas=[],this.$deltasDoc=[],this.$deltasFold=[],this.setUndoManager(this.$undoManager),this.getUndoManager().reset()},this.getValue=this.toString=function(){return this.doc.getValue()},this.getSelection=function(){return this.selection},this.getState=function(e){return this.bgTokenizer.getState(e)},this.getTokens=function(e){return this.bgTokenizer.getTokens(e)},this.getTokenAt=function(e,t){var n=this.bgTokenizer.getTokens(e),r,i=0;if(t==null)s=n.length-1,i=this.getLine(e).length;else for(var s=0;s<n.length;s++){i+=n[s].value.length;if(i>=t)break}return r=n[s],r?(r.index=s,r.start=i-r.value.length,r):null},this.setUndoManager=function(e){this.$undoManager=e,this.$deltas=[],this.$deltasDoc=[],this.$deltasFold=[],this.$informUndoManager&&this.$informUndoManager.cancel();if(e){var t=this;this.$syncInformUndoManager=function(){t.$informUndoManager.cancel(),t.$deltasFold.length&&(t.$deltas.push({group:"fold",deltas:t.$deltasFold}),t.$deltasFold=[]),t.$deltasDoc.length&&(t.$deltas.push({group:"doc",deltas:t.$deltasDoc}),t.$deltasDoc=[]),t.$deltas.length>0&&e.execute({action:"aceupdate",args:[t.$deltas,t],merge:t.mergeUndoDeltas}),t.mergeUndoDeltas=!1,t.$deltas=[]},this.$informUndoManager=i.delayedCall(this.$syncInformUndoManager)}},this.markUndoGroup=function(){this.$syncInformUndoManager&&this.$syncInformUndoManager()},this.$defaultUndoManager={undo:function(){},redo:function(){},reset:function(){}},this.getUndoManager=function(){return this.$undoManager||this.$defaultUndoManager},this.getTabString=function(){return this.getUseSoftTabs()?i.stringRepeat(" ",this.getTabSize()):" "},this.setUseSoftTabs=function(e){this.setOption("useSoftTabs",e)},this.getUseSoftTabs=function(){return this.$useSoftTabs&&!this.$mode.$indentWithTabs},this.setTabSize=function(e){this.setOption("tabSize",e)},this.getTabSize=function(){return this.$tabSize},this.isTabStop=function(e){return this.$useSoftTabs&&e.column%this.$tabSize===0},this.$overwrite=!1,this.setOverwrite=function(e){this.setOption("overwrite",e)},this.getOverwrite=function(){return this.$overwrite},this.toggleOverwrite=function(){this.setOverwrite(!this.$overwrite)},this.addGutterDecoration=function(e,t){this.$decorations[e]||(this.$decorations[e]=""),this.$decorations[e]+=" "+t,this._signal("changeBreakpoint",{})},this.removeGutterDecoration=function(e,t){this.$decorations[e]=(this.$decorations[e]||"").replace(" "+t,""),this._signal("changeBreakpoint",{})},this.getBreakpoints=function(){return this.$breakpoints},this.setBreakpoints=function(e){this.$breakpoints=[];for(var t=0;t<e.length;t++)this.$breakpoints[e[t]]="ace_breakpoint";this._signal("changeBreakpoint",{})},this.clearBreakpoints=function(){this.$breakpoints=[],this._signal("changeBreakpoint",{})},this.setBreakpoint=function(e,t){t===undefined&&(t="ace_breakpoint"),t?this.$breakpoints[e]=t:delete this.$breakpoints[e],this._signal("changeBreakpoint",{})},this.clearBreakpoint=function(e){delete this.$breakpoints[e],this._signal("changeBreakpoint",{})},this.addMarker=function(e,t,n,r){var i=this.$markerId++,s={range:e,type:n||"line",renderer:typeof n=="function"?n:null,clazz:t,inFront:!!r,id:i};return r?(this.$frontMarkers[i]=s,this._signal("changeFrontMarker")):(this.$backMarkers[i]=s,this._signal("changeBackMarker")),i},this.addDynamicMarker=function(e,t){if(!e.update)return;var n=this.$markerId++;return e.id=n,e.inFront=!!t,t?(this.$frontMarkers[n]=e,this._signal("changeFrontMarker")):(this.$backMarkers[n]=e,this._signal("changeBackMarker")),e},this.removeMarker=function(e){var t=this.$frontMarkers[e]||this.$backMarkers[e];if(!t)return;var n=t.inFront?this.$frontMarkers:this.$backMarkers;t&&(delete n[e],this._signal(t.inFront?"changeFrontMarker":"changeBackMarker"))},this.getMarkers=function(e){return e?this.$frontMarkers:this.$backMarkers},this.highlight=function(e){if(!this.$searchHighlight){var t=new h(null,"ace_selected-word","text");this.$searchHighlight=this.addDynamicMarker(t)}this.$searchHighlight.setRegexp(e)},this.highlightLines=function(e,t,n,r){typeof t!="number"&&(n=t,t=e),n||(n="ace_step");var i=new f(e,0,t,Infinity);return i.id=this.addMarker(i,n,"fullLine",r),i},this.setAnnotations=function(e){this.$annotations=e,this._signal("changeAnnotation",{})},this.getAnnotations=function(){return this.$annotations||[]},this.clearAnnotations=function(){this.setAnnotations([])},this.$detectNewLine=function(e){var t=e.match(/^.*?(\r?\n)/m);t?this.$autoNewLine=t[1]:this.$autoNewLine="\n"},this.getWordRange=function(e,t){var n=this.getLine(e),r=!1;t>0&&(r=!!n.charAt(t-1).match(this.tokenRe)),r||(r=!!n.charAt(t).match(this.tokenRe));if(r)var i=this.tokenRe;else if(/^\s+$/.test(n.slice(t-1,t+1)))var i=/\s/;else var i=this.nonTokenRe;var s=t;if(s>0){do s--;while(s>=0&&n.charAt(s).match(i));s++}var o=t;while(o<n.length&&n.charAt(o).match(i))o++;return new f(e,s,e,o)},this.getAWordRange=function(e,t){var n=this.getWordRange(e,t),r=this.getLine(n.end.row);while(r.charAt(n.end.column).match(/[ \t]/))n.end.column+=1;return n},this.setNewLineMode=function(e){this.doc.setNewLineMode(e)},this.getNewLineMode=function(){return this.doc.getNewLineMode()},this.setUseWorker=function(e){this.setOption("useWorker",e)},this.getUseWorker=function(){return this.$useWorker},this.onReloadTokenizer=function(e){var t=e.data;this.bgTokenizer.start(t.first),this._signal("tokenizerUpdate",e)},this.$modes={},this.$mode=null,this.$modeId=null,this.setMode=function(e,t){if(e&&typeof e=="object"){if(e.getTokenizer)return this.$onChangeMode(e);var n=e,r=n.path}else r=e||"ace/mode/text";this.$modes["ace/mode/text"]||(this.$modes["ace/mode/text"]=new a);if(this.$modes[r]&&!n){this.$onChangeMode(this.$modes[r]),t&&t();return}this.$modeId=r,s.loadModule(["mode",r],function(e){if(this.$modeId!==r)return t&&t();this.$modes[r]&&!n?this.$onChangeMode(this.$modes[r]):e&&e.Mode&&(e=new e.Mode(n),n||(this.$modes[r]=e,e.$id=r),this.$onChangeMode(e)),t&&t()}.bind(this)),this.$mode||this.$onChangeMode(this.$modes["ace/mode/text"],!0)},this.$onChangeMode=function(e,t){t||(this.$modeId=e.$id);if(this.$mode===e)return;this.$mode=e,this.$stopWorker(),this.$useWorker&&this.$startWorker();var n=e.getTokenizer();if(n.addEventListener!==undefined){var r=this.onReloadTokenizer.bind(this);n.addEventListener("update",r)}if(!this.bgTokenizer){this.bgTokenizer=new c(n);var i=this;this.bgTokenizer.addEventListener("update",function(e){i._signal("tokenizerUpdate",e)})}else this.bgTokenizer.setTokenizer(n);this.bgTokenizer.setDocument(this.getDocument()),this.tokenRe=e.tokenRe,this.nonTokenRe=e.nonTokenRe,t||(e.attachToSession&&e.attachToSession(this),this.$options.wrapMethod.set.call(this,this.$wrapMethod),this.$setFolding(e.foldingRules),this.bgTokenizer.start(0),this._emit("changeMode"))},this.$stopWorker=function(){this.$worker&&(this.$worker.terminate(),this.$worker=null)},this.$startWorker=function(){try{this.$worker=this.$mode.createWorker(this)}catch(e){s.warn("Could not load worker",e),this.$worker=null}},this.getMode=function(){return this.$mode},this.$scrollTop=0,this.setScrollTop=function(e){if(this.$scrollTop===e||isNaN(e))return;this.$scrollTop=e,this._signal("changeScrollTop",e)},this.getScrollTop=function(){return this.$scrollTop},this.$scrollLeft=0,this.setScrollLeft=function(e){if(this.$scrollLeft===e||isNaN(e))return;this.$scrollLeft=e,this._signal("changeScrollLeft",e)},this.getScrollLeft=function(){return this.$scrollLeft},this.getScreenWidth=function(){return this.$computeWidth(),this.lineWidgets?Math.max(this.getLineWidgetMaxWidth(),this.screenWidth):this.screenWidth},this.getLineWidgetMaxWidth=function(){if(this.lineWidgetsWidth!=null)return this.lineWidgetsWidth;var e=0;return this.lineWidgets.forEach(function(t){t&&t.screenWidth>e&&(e=t.screenWidth)}),this.lineWidgetWidth=e},this.$computeWidth=function(e){if(this.$modified||e){this.$modified=!1;if(this.$useWrapMode)return this.screenWidth=this.$wrapLimit;var t=this.doc.getAllLines(),n=this.$rowLengthCache,r=0,i=0,s=this.$foldData[i],o=s?s.start.row:Infinity,u=t.length;for(var a=0;a<u;a++){if(a>o){a=s.end.row+1;if(a>=u)break;s=this.$foldData[i++],o=s?s.start.row:Infinity}n[a]==null&&(n[a]=this.$getStringScreenWidth(t[a])[0]),n[a]>r&&(r=n[a])}this.screenWidth=r}},this.getLine=function(e){return this.doc.getLine(e)},this.getLines=function(e,t){return this.doc.getLines(e,t)},this.getLength=function(){return this.doc.getLength()},this.getTextRange=function(e){return this.doc.getTextRange(e||this.selection.getRange())},this.insert=function(e,t){return this.doc.insert(e,t)},this.remove=function(e){return this.doc.remove(e)},this.removeFullLines=function(e,t){return this.doc.removeFullLines(e,t)},this.undoChanges=function(e,t){if(!e.length)return;this.$fromUndo=!0;var n=null;for(var r=e.length-1;r!=-1;r--){var i=e[r];i.group=="doc"?(this.doc.revertDeltas(i.deltas),n=this.$getUndoSelection(i.deltas,!0,n)):i.deltas.forEach(function(e){this.addFolds(e.folds)},this)}return this.$fromUndo=!1,n&&this.$undoSelect&&!t&&this.selection.setSelectionRange(n),n},this.redoChanges=function(e,t){if(!e.length)return;this.$fromUndo=!0;var n=null;for(var r=0;r<e.length;r++){var i=e[r];i.group=="doc"&&(this.doc.applyDeltas(i.deltas),n=this.$getUndoSelection(i.deltas,!1,n))}return this.$fromUndo=!1,n&&this.$undoSelect&&!t&&this.selection.setSelectionRange(n),n},this.setUndoSelect=function(e){this.$undoSelect=e},this.$getUndoSelection=function(e,t,n){function r(e){return t?e.action!=="insert":e.action==="insert"}var i=e[0],s,o,u=!1;r(i)?(s=f.fromPoints(i.start,i.end),u=!0):(s=f.fromPoints(i.start,i.start),u=!1);for(var a=1;a<e.length;a++)i=e[a],r(i)?(o=i.start,s.compare(o.row,o.column)==-1&&s.setStart(o),o=i.end,s.compare(o.row,o.column)==1&&s.setEnd(o),u=!0):(o=i.start,s.compare(o.row,o.column)==-1&&(s=f.fromPoints(i.start,i.start)),u=!1);if(n!=null){f.comparePoints(n.start,s.start)===0&&(n.start.column+=s.end.column-s.start.column,n.end.column+=s.end.column-s.start.column);var l=n.compareRange(s);l==1?s.setStart(n.start):l==-1&&s.setEnd(n.end)}return s},this.replace=function(e,t){return this.doc.replace(e,t)},this.moveText=function(e,t,n){var r=this.getTextRange(e),i=this.getFoldsInRange(e),s=f.fromPoints(t,t);if(!n){this.remove(e);var o=e.start.row-e.end.row,u=o?-e.end.column:e.start.column-e.end.column;u&&(s.start.row==e.end.row&&s.start.column>e.end.column&&(s.start.column+=u),s.end.row==e.end.row&&s.end.column>e.end.column&&(s.end.column+=u)),o&&s.start.row>=e.end.row&&(s.start.row+=o,s.end.row+=o)}s.end=this.insert(s.start,r);if(i.length){var a=e.start,l=s.start,o=l.row-a.row,u=l.column-a.column;this.addFolds(i.map(function(e){return e=e.clone(),e.start.row==a.row&&(e.start.column+=u),e.end.row==a.row&&(e.end.column+=u),e.start.row+=o,e.end.row+=o,e}))}return s},this.indentRows=function(e,t,n){n=n.replace(/\t/g,this.getTabString());for(var r=e;r<=t;r++)this.doc.insertInLine({row:r,column:0},n)},this.outdentRows=function(e){var t=e.collapseRows(),n=new f(0,0,0,0),r=this.getTabSize();for(var i=t.start.row;i<=t.end.row;++i){var s=this.getLine(i);n.start.row=i,n.end.row=i;for(var o=0;o<r;++o)if(s.charAt(o)!=" ")break;o<r&&s.charAt(o)==" "?(n.start.column=o,n.end.column=o+1):(n.start.column=0,n.end.column=o),this.remove(n)}},this.$moveLines=function(e,t,n){e=this.getRowFoldStart(e),t=this.getRowFoldEnd(t);if(n<0){var r=this.getRowFoldStart(e+n);if(r<0)return 0;var i=r-e}else if(n>0){var r=this.getRowFoldEnd(t+n);if(r>this.doc.getLength()-1)return 0;var i=r-t}else{e=this.$clipRowToDocument(e),t=this.$clipRowToDocument(t);var i=t-e+1}var s=new f(e,0,t,Number.MAX_VALUE),o=this.getFoldsInRange(s).map(function(e){return e=e.clone(),e.start.row+=i,e.end.row+=i,e}),u=n==0?this.doc.getLines(e,t):this.doc.removeFullLines(e,t);return this.doc.insertFullLines(e+i,u),o.length&&this.addFolds(o),i},this.moveLinesUp=function(e,t){return this.$moveLines(e,t,-1)},this.moveLinesDown=function(e,t){return this.$moveLines(e,t,1)},this.duplicateLines=function(e,t){return this.$moveLines(e,t,0)},this.$clipRowToDocument=function(e){return Math.max(0,Math.min(e,this.doc.getLength()-1))},this.$clipColumnToRow=function(e,t){return t<0?0:Math.min(this.doc.getLine(e).length,t)},this.$clipPositionToDocument=function(e,t){t=Math.max(0,t);if(e<0)e=0,t=0;else{var n=this.doc.getLength();e>=n?(e=n-1,t=this.doc.getLine(n-1).length):t=Math.min(this.doc.getLine(e).length,t)}return{row:e,column:t}},this.$clipRangeToDocument=function(e){e.start.row<0?(e.start.row=0,e.start.column=0):e.start.column=this.$clipColumnToRow(e.start.row,e.start.column);var t=this.doc.getLength()-1;return e.end.row>t?(e.end.row=t,e.end.column=this.doc.getLine(t).length):e.end.column=this.$clipColumnToRow(e.end.row,e.end.column),e},this.$wrapLimit=80,this.$useWrapMode=!1,this.$wrapLimitRange={min:null,max:null},this.setUseWrapMode=function(e){if(e!=this.$useWrapMode){this.$useWrapMode=e,this.$modified=!0,this.$resetRowCache(0);if(e){var t=this.getLength();this.$wrapData=Array(t),this.$updateWrapData(0,t-1)}this._signal("changeWrapMode")}},this.getUseWrapMode=function(){return this.$useWrapMode},this.setWrapLimitRange=function(e,t){if(this.$wrapLimitRange.min!==e||this.$wrapLimitRange.max!==t)this.$wrapLimitRange={min:e,max:t},this.$modified=!0,this.$useWrapMode&&this._signal("changeWrapMode")},this.adjustWrapLimit=function(e,t){var n=this.$wrapLimitRange;n.max<0&&(n={min:t,max:t});var r=this.$constrainWrapLimit(e,n.min,n.max);return r!=this.$wrapLimit&&r>1?(this.$wrapLimit=r,this.$modified=!0,this.$useWrapMode&&(this.$updateWrapData(0,this.getLength()-1),this.$resetRowCache(0),this._signal("changeWrapLimit")),!0):!1},this.$constrainWrapLimit=function(e,t,n){return t&&(e=Math.max(t,e)),n&&(e=Math.min(n,e)),e},this.getWrapLimit=function(){return this.$wrapLimit},this.setWrapLimit=function(e){this.setWrapLimitRange(e,e)},this.getWrapLimitRange=function(){return{min:this.$wrapLimitRange.min,max:this.$wrapLimitRange.max}},this.$updateInternalDataOnChange=function(e){var t=this.$useWrapMode,n=e.action,r=e.start,i=e.end,s=r.row,o=i.row,u=o-s,a=null;this.$updating=!0;if(u!=0)if(n==="remove"){this[t?"$wrapData":"$rowLengthCache"].splice(s,u);var f=this.$foldData;a=this.getFoldsInRange(e),this.removeFolds(a);var l=this.getFoldLine(i.row),c=0;if(l){l.addRemoveChars(i.row,i.column,r.column-i.column),l.shiftRow(-u);var h=this.getFoldLine(s);h&&h!==l&&(h.merge(l),l=h),c=f.indexOf(l)+1}for(c;c<f.length;c++){var l=f[c];l.start.row>=i.row&&l.shiftRow(-u)}o=s}else{var p=Array(u);p.unshift(s,0);var d=t?this.$wrapData:this.$rowLengthCache;d.splice.apply(d,p);var f=this.$foldData,l=this.getFoldLine(s),c=0;if(l){var v=l.range.compareInside(r.row,r.column);v==0?(l=l.split(r.row,r.column),l&&(l.shiftRow(u),l.addRemoveChars(o,0,i.column-r.column))):v==-1&&(l.addRemoveChars(s,0,i.column-r.column),l.shiftRow(u)),c=f.indexOf(l)+1}for(c;c<f.length;c++){var l=f[c];l.start.row>=s&&l.shiftRow(u)}}else{u=Math.abs(e.start.column-e.end.column),n==="remove"&&(a=this.getFoldsInRange(e),this.removeFolds(a),u=-u);var l=this.getFoldLine(s);l&&l.addRemoveChars(s,r.column,u)}return t&&this.$wrapData.length!=this.doc.getLength()&&console.error("doc.getLength() and $wrapData.length have to be the same!"),this.$updating=!1,t?this.$updateWrapData(s,o):this.$updateRowLengthCache(s,o),a},this.$updateRowLengthCache=function(e,t,n){this.$rowLengthCache[e]=null,this.$rowLengthCache[t]=null},this.$updateWrapData=function(e,t){var r=this.doc.getAllLines(),i=this.getTabSize(),s=this.$wrapData,o=this.$wrapLimit,a,f,l=e;t=Math.min(t,r.length-1);while(l<=t)f=this.getFoldLine(l,f),f?(a=[],f.walk(function(e,t,i,s){var o;if(e!=null){o=this.$getDisplayTokens(e,a.length),o[0]=n;for(var f=1;f<o.length;f++)o[f]=u}else o=this.$getDisplayTokens(r[t].substring(s,i),a.length);a=a.concat(o)}.bind(this),f.end.row,r[f.end.row].length+1),s[f.start.row]=this.$computeWrapSplits(a,o,i),l=f.end.row+1):(a=this.$getDisplayTokens(r[l]),s[l]=this.$computeWrapSplits(a,o,i),l++)};var e=1,t=2,n=3,u=4,l=9,p=10,d=11,v=12;this.$computeWrapSplits=function(e,r,i){function g(){var t=0;if(m===0)return t;if(h)for(var n=0;n<e.length;n++){var r=e[n];if(r==p)t+=1;else{if(r!=d){if(r==v)continue;break}t+=i}}return c&&h!==!1&&(t+=i),Math.min(t,m)}function y(t){var n=e.slice(a,t),r=n.length;n.join("").replace(/12/g,function(){r-=1}).replace(/2/g,function(){r-=1}),s.length||(b=g(),s.indent=b),f+=r,s.push(f),a=t}if(e.length==0)return[];var s=[],o=e.length,a=0,f=0,c=this.$wrapAsCode,h=this.$indentedSoftWrap,m=r<=Math.max(2*i,8)||h===!1?0:Math.floor(r/2),b=0;while(o-a>r-b){var w=a+r-b;if(e[w-1]>=p&&e[w]>=p){y(w);continue}if(e[w]==n||e[w]==u){for(w;w!=a-1;w--)if(e[w]==n)break;if(w>a){y(w);continue}w=a+r;for(w;w<e.length;w++)if(e[w]!=u)break;if(w==e.length)break;y(w);continue}var E=Math.max(w-(r-(r>>2)),a-1);while(w>E&&e[w]<n)w--;if(c){while(w>E&&e[w]<n)w--;while(w>E&&e[w]==l)w--}else while(w>E&&e[w]<p)w--;if(w>E){y(++w);continue}w=a+r,e[w]==t&&w--,y(w-b)}return s},this.$getDisplayTokens=function(n,r){var i=[],s;r=r||0;for(var o=0;o<n.length;o++){var u=n.charCodeAt(o);if(u==9){s=this.getScreenTabSize(i.length+r),i.push(d);for(var a=1;a<s;a++)i.push(v)}else u==32?i.push(p):u>39&&u<48||u>57&&u<64?i.push(l):u>=4352&&m(u)?i.push(e,t):i.push(e)}return i},this.$getStringScreenWidth=function(e,t,n){if(t==0)return[0,0];t==null&&(t=Infinity),n=n||0;var r,i;for(i=0;i<e.length;i++){r=e.charCodeAt(i),r==9?n+=this.getScreenTabSize(n):r>=4352&&m(r)?n+=2:n+=1;if(n>t)break}return[n,i]},this.lineWidgets=null,this.getRowLength=function(e){if(this.lineWidgets)var t=this.lineWidgets[e]&&this.lineWidgets[e].rowCount||0;else t=0;return!this.$useWrapMode||!this.$wrapData[e]?1+t:this.$wrapData[e].length+1+t},this.getRowLineCount=function(e){return!this.$useWrapMode||!this.$wrapData[e]?1:this.$wrapData[e].length+1},this.getRowWrapIndent=function(e){if(this.$useWrapMode){var t=this.screenToDocumentPosition(e,Number.MAX_VALUE),n=this.$wrapData[t.row];return n.length&&n[0]<t.column?n.indent:0}return 0},this.getScreenLastRowColumn=function(e){var t=this.screenToDocumentPosition(e,Number.MAX_VALUE);return this.documentToScreenColumn(t.row,t.column)},this.getDocumentLastRowColumn=function(e,t){var n=this.documentToScreenRow(e,t);return this.getScreenLastRowColumn(n)},this.getDocumentLastRowColumnPosition=function(e,t){var n=this.documentToScreenRow(e,t);return this.screenToDocumentPosition(n,Number.MAX_VALUE/10)},this.getRowSplitData=function(e){return this.$useWrapMode?this.$wrapData[e]:undefined},this.getScreenTabSize=function(e){return this.$tabSize-e%this.$tabSize},this.screenToDocumentRow=function(e,t){return this.screenToDocumentPosition(e,t).row},this.screenToDocumentColumn=function(e,t){return this.screenToDocumentPosition(e,t).column},this.screenToDocumentPosition=function(e,t){if(e<0)return{row:0,column:0};var n,r=0,i=0,s,o=0,u=0,a=this.$screenRowCache,f=this.$getRowCacheIndex(a,e),l=a.length;if(l&&f>=0)var o=a[f],r=this.$docRowCache[f],c=e>a[l-1];else var c=!l;var h=this.getLength()-1,p=this.getNextFoldLine(r),d=p?p.start.row:Infinity;while(o<=e){u=this.getRowLength(r);if(o+u>e||r>=h)break;o+=u,r++,r>d&&(r=p.end.row+1,p=this.getNextFoldLine(r,p),d=p?p.start.row:Infinity),c&&(this.$docRowCache.push(r),this.$screenRowCache.push(o))}if(p&&p.start.row<=r)n=this.getFoldDisplayLine(p),r=p.start.row;else{if(o+u<=e||r>h)return{row:h,column:this.getLine(h).length};n=this.getLine(r),p=null}var v=0;if(this.$useWrapMode){var m=this.$wrapData[r];if(m){var g=Math.floor(e-o);s=m[g],g>0&&m.length&&(v=m.indent,i=m[g-1]||m[m.length-1],n=n.substring(i))}}return i+=this.$getStringScreenWidth(n,t-v)[1],this.$useWrapMode&&i>=s&&(i=s-1),p?p.idxToPosition(i):{row:r,column:i}},this.documentToScreenPosition=function(e,t){if(typeof t=="undefined")var n=this.$clipPositionToDocument(e.row,e.column);else n=this.$clipPositionToDocument(e,t);e=n.row,t=n.column;var r=0,i=null,s=null;s=this.getFoldAt(e,t,1),s&&(e=s.start.row,t=s.start.column);var o,u=0,a=this.$docRowCache,f=this.$getRowCacheIndex(a,e),l=a.length;if(l&&f>=0)var u=a[f],r=this.$screenRowCache[f],c=e>a[l-1];else var c=!l;var h=this.getNextFoldLine(u),p=h?h.start.row:Infinity;while(u<e){if(u>=p){o=h.end.row+1;if(o>e)break;h=this.getNextFoldLine(o,h),p=h?h.start.row:Infinity}else o=u+1;r+=this.getRowLength(u),u=o,c&&(this.$docRowCache.push(u),this.$screenRowCache.push(r))}var d="";h&&u>=p?(d=this.getFoldDisplayLine(h,e,t),i=h.start.row):(d=this.getLine(e).substring(0,t),i=e);var v=0;if(this.$useWrapMode){var m=this.$wrapData[i];if(m){var g=0;while(d.length>=m[g])r++,g++;d=d.substring(m[g-1]||0,d.length),v=g>0?m.indent:0}}return{row:r,column:v+this.$getStringScreenWidth(d)[0]}},this.documentToScreenColumn=function(e,t){return this.documentToScreenPosition(e,t).column},this.documentToScreenRow=function(e,t){return this.documentToScreenPosition(e,t).row},this.getScreenLength=function(){var e=0,t=null;if(!this.$useWrapMode){e=this.getLength();var n=this.$foldData;for(var r=0;r<n.length;r++)t=n[r],e-=t.end.row-t.start.row}else{var i=this.$wrapData.length,s=0,r=0,t=this.$foldData[r++],o=t?t.start.row:Infinity;while(s<i){var u=this.$wrapData[s];e+=u?u.length+1:1,s++,s>o&&(s=t.end.row+1,t=this.$foldData[r++],o=t?t.start.row:Infinity)}}return this.lineWidgets&&(e+=this.$getWidgetScreenLength()),e},this.$setFontMetrics=function(e){if(!this.$enableVarChar)return;this.$getStringScreenWidth=function(t,n,r){if(n===0)return[0,0];n||(n=Infinity),r=r||0;var i,s;for(s=0;s<t.length;s++){i=t.charAt(s),i===" "?r+=this.getScreenTabSize(r):r+=e.getCharacterWidth(i);if(r>n)break}return[r,s]}},this.destroy=function(){this.bgTokenizer&&(this.bgTokenizer.setDocument(null),this.bgTokenizer=null),this.$stopWorker()}}).call(p.prototype),e("./edit_session/folding").Folding.call(p.prototype),e("./edit_session/bracket_match").BracketMatch.call(p.prototype),s.defineOptions(p.prototype,"session",{wrap:{set:function(e){!e||e=="off"?e=!1:e=="free"?e=!0:e=="printMargin"?e=-1:typeof e=="string"&&(e=parseInt(e,10)||!1);if(this.$wrap==e)return;this.$wrap=e;if(!e)this.setUseWrapMode(!1);else{var t=typeof e=="number"?e:null;this.setWrapLimitRange(t,t),this.setUseWrapMode(!0)}},get:function(){return this.getUseWrapMode()?this.$wrap==-1?"printMargin":this.getWrapLimitRange().min?this.$wrap:"free":"off"},handlesSet:!0},wrapMethod:{set:function(e){e=e=="auto"?this.$mode.type!="text":e!="text",e!=this.$wrapAsCode&&(this.$wrapAsCode=e,this.$useWrapMode&&(this.$modified=!0,this.$resetRowCache(0),this.$updateWrapData(0,this.getLength()-1)))},initialValue:"auto"},indentedSoftWrap:{initialValue:!0},firstLineNumber:{set:function(){this._signal("changeBreakpoint")},initialValue:1},useWorker:{set:function(e){this.$useWorker=e,this.$stopWorker(),e&&this.$startWorker()},initialValue:!0},useSoftTabs:{initialValue:!0},tabSize:{set:function(e){if(isNaN(e)||this.$tabSize===e)return;this.$modified=!0,this.$rowLengthCache=[],this.$tabSize=e,this._signal("changeTabSize")},initialValue:4,handlesSet:!0},overwrite:{set:function(e){this._signal("changeOverwrite")},initialValue:!1},newLineMode:{set:function(e){this.doc.setNewLineMode(e)},get:function(){return this.doc.getNewLineMode()},handlesSet:!0},mode:{set:function(e){this.setMode(e)},get:function(){return this.$modeId}}}),t.EditSession=p}),ace.define("ace/search",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"],function(e,t,n){"use strict";var r=e("./lib/lang"),i=e("./lib/oop"),s=e("./range").Range,o=function(){this.$options={}};(function(){this.set=function(e){return i.mixin(this.$options,e),this},this.getOptions=function(){return r.copyObject(this.$options)},this.setOptions=function(e){this.$options=e},this.find=function(e){var t=this.$options,n=this.$matchIterator(e,t);if(!n)return!1;var r=null;return n.forEach(function(e,n,i){if(!e.start){var o=e.offset+(i||0);r=new s(n,o,n,o+e.length);if(!e.length&&t.start&&t.start.start&&t.skipCurrent!=0&&r.isEqual(t.start))return r=null,!1}else r=e;return!0}),r},this.findAll=function(e){var t=this.$options;if(!t.needle)return[];this.$assembleRegExp(t);var n=t.range,i=n?e.getLines(n.start.row,n.end.row):e.doc.getAllLines(),o=[],u=t.re;if(t.$isMultiLine){var a=u.length,f=i.length-a,l;e:for(var c=u.offset||0;c<=f;c++){for(var h=0;h<a;h++)if(i[c+h].search(u[h])==-1)continue e;var p=i[c],d=i[c+a-1],v=p.length-p.match(u[0])[0].length,m=d.match(u[a-1])[0].length;if(l&&l.end.row===c&&l.end.column>v)continue;o.push(l=new s(c,v,c+a-1,m)),a>2&&(c=c+a-2)}}else for(var g=0;g<i.length;g++){var y=r.getMatchOffsets(i[g],u);for(var h=0;h<y.length;h++){var b=y[h];o.push(new s(g,b.offset,g,b.offset+b.length))}}if(n){var w=n.start.column,E=n.start.column,g=0,h=o.length-1;while(g<h&&o[g].start.column<w&&o[g].start.row==n.start.row)g++;while(g<h&&o[h].end.column>E&&o[h].end.row==n.end.row)h--;o=o.slice(g,h+1);for(g=0,h=o.length;g<h;g++)o[g].start.row+=n.start.row,o[g].end.row+=n.start.row}return o},this.replace=function(e,t){var n=this.$options,r=this.$assembleRegExp(n);if(n.$isMultiLine)return t;if(!r)return;var i=r.exec(e);if(!i||i[0].length!=e.length)return null;t=e.replace(r,t);if(n.preserveCase){t=t.split("");for(var s=Math.min(e.length,e.length);s--;){var o=e[s];o&&o.toLowerCase()!=o?t[s]=t[s].toUpperCase():t[s]=t[s].toLowerCase()}t=t.join("")}return t},this.$matchIterator=function(e,t){var n=this.$assembleRegExp(t);if(!n)return!1;var i;if(t.$isMultiLine)var o=n.length,u=function(t,r,u){var a=t.search(n[0]);if(a==-1)return;for(var f=1;f<o;f++){t=e.getLine(r+f);if(t.search(n[f])==-1)return}var l=t.match(n[o-1])[0].length,c=new s(r,a,r+o-1,l);n.offset==1?(c.start.row--,c.start.column=Number.MAX_VALUE):u&&(c.start.column+=u);if(i(c))return!0};else if(t.backwards)var u=function(e,t,s){var o=r.getMatchOffsets(e,n);for(var u=o.length-1;u>=0;u--)if(i(o[u],t,s))return!0};else var u=function(e,t,s){var o=r.getMatchOffsets(e,n);for(var u=0;u<o.length;u++)if(i(o[u],t,s))return!0};var a=this.$lineIterator(e,t);return{forEach:function(e){i=e,a.forEach(u)}}},this.$assembleRegExp=function(e,t){if(e.needle instanceof RegExp)return e.re=e.needle;var n=e.needle;if(!e.needle)return e.re=!1;e.regExp||(n=r.escapeRegExp(n)),e.wholeWord&&(n="\\b"+n+"\\b");var i=e.caseSensitive?"gm":"gmi";e.$isMultiLine=!t&&/[\n\r]/.test(n);if(e.$isMultiLine)return e.re=this.$assembleMultilineRegExp(n,i);try{var s=new RegExp(n,i)}catch(o){s=!1}return e.re=s},this.$assembleMultilineRegExp=function(e,t){var n=e.replace(/\r\n|\r|\n/g,"$\n^").split("\n"),r=[];for(var i=0;i<n.length;i++)try{r.push(new RegExp(n[i],t))}catch(s){return!1}return n[0]==""?(r.shift(),r.offset=1):r.offset=0,r},this.$lineIterator=function(e,t){var n=t.backwards==1,r=t.skipCurrent!=0,i=t.range,s=t.start;s||(s=i?i[n?"end":"start"]:e.selection.getRange()),s.start&&(s=s[r!=n?"end":"start"]);var o=i?i.start.row:0,u=i?i.end.row:e.getLength()-1,a=n?function(n){var r=s.row,i=e.getLine(r).substring(0,s.column);if(n(i,r))return;for(r--;r>=o;r--)if(n(e.getLine(r),r))return;if(t.wrap==0)return;for(r=u,o=s.row;r>=o;r--)if(n(e.getLine(r),r))return}:function(n){var r=s.row,i=e.getLine(r).substr(s.column);if(n(i,r,s.column))return;for(r+=1;r<=u;r++)if(n(e.getLine(r),r))return;if(t.wrap==0)return;for(r=o,u=s.row;r<=u;r++)if(n(e.getLine(r),r))return};return{forEach:a}}}).call(o.prototype),t.Search=o}),ace.define("ace/keyboard/hash_handler",["require","exports","module","ace/lib/keys","ace/lib/useragent"],function(e,t,n){"use strict";function o(e,t){this.platform=t||(i.isMac?"mac":"win"),this.commands={},this.commandKeyBinding={},this.addCommands(e),this.$singleCommand=!0}function u(e,t){o.call(this,e,t),this.$singleCommand=!1}var r=e("../lib/keys"),i=e("../lib/useragent"),s=r.KEY_MODS;u.prototype=o.prototype,function(){function e(e){return typeof e=="object"&&e.bindKey&&e.bindKey.position||0}this.addCommand=function(e){this.commands[e.name]&&this.removeCommand(e),this.commands[e.name]=e,e.bindKey&&this._buildKeyHash(e)},this.removeCommand=function(e,t){var n=e&&(typeof e=="string"?e:e.name);e=this.commands[n],t||delete this.commands[n];var r=this.commandKeyBinding;for(var i in r){var s=r[i];if(s==e)delete r[i];else if(Array.isArray(s)){var o=s.indexOf(e);o!=-1&&(s.splice(o,1),s.length==1&&(r[i]=s[0]))}}},this.bindKey=function(e,t,n){typeof e=="object"&&e&&(n==undefined&&(n=e.position),e=e[this.platform]);if(!e)return;if(typeof t=="function")return this.addCommand({exec:t,bindKey:e,name:t.name||e});e.split("|").forEach(function(e){var r="";if(e.indexOf(" ")!=-1){var i=e.split(/\s+/);e=i.pop(),i.forEach(function(e){var t=this.parseKeys(e),n=s[t.hashId]+t.key;r+=(r?" ":"")+n,this._addCommandToBinding(r,"chainKeys")},this),r+=" "}var o=this.parseKeys(e),u=s[o.hashId]+o.key;this._addCommandToBinding(r+u,t,n)},this)},this._addCommandToBinding=function(t,n,r){var i=this.commandKeyBinding,s;if(!n)delete i[t];else if(!i[t]||this.$singleCommand)i[t]=n;else{Array.isArray(i[t])?(s=i[t].indexOf(n))!=-1&&i[t].splice(s,1):i[t]=[i[t]],typeof r!="number"&&(r||n.isDefault?r=-100:r=e(n));var o=i[t];for(s=0;s<o.length;s++){var u=o[s],a=e(u);if(a>r)break}o.splice(s,0,n)}},this.addCommands=function(e){e&&Object.keys(e).forEach(function(t){var n=e[t];if(!n)return;if(typeof n=="string")return this.bindKey(n,t);typeof n=="function"&&(n={exec:n});if(typeof n!="object")return;n.name||(n.name=t),this.addCommand(n)},this)},this.removeCommands=function(e){Object.keys(e).forEach(function(t){this.removeCommand(e[t])},this)},this.bindKeys=function(e){Object.keys(e).forEach(function(t){this.bindKey(t,e[t])},this)},this._buildKeyHash=function(e){this.bindKey(e.bindKey,e)},this.parseKeys=function(e){var t=e.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(e){return e}),n=t.pop(),i=r[n];if(r.FUNCTION_KEYS[i])n=r.FUNCTION_KEYS[i].toLowerCase();else{if(!t.length)return{key:n,hashId:-1};if(t.length==1&&t[0]=="shift")return{key:n.toUpperCase(),hashId:-1}}var s=0;for(var o=t.length;o--;){var u=r.KEY_MODS[t[o]];if(u==null)return typeof console!="undefined"&&console.error("invalid modifier "+t[o]+" in "+e),!1;s|=u}return{key:n,hashId:s}},this.findKeyCommand=function(t,n){var r=s[t]+n;return this.commandKeyBinding[r]},this.handleKeyboard=function(e,t,n,r){if(r<0)return;var i=s[t]+n,o=this.commandKeyBinding[i];e.$keyChain&&(e.$keyChain+=" "+i,o=this.commandKeyBinding[e.$keyChain]||o);if(o)if(o=="chainKeys"||o[o.length-1]=="chainKeys")return e.$keyChain=e.$keyChain||i,{command:"null"};if(e.$keyChain)if(!!t&&t!=4||n.length!=1){if(t==-1||r>0)e.$keyChain=""}else e.$keyChain=e.$keyChain.slice(0,-i.length-1);return{command:o}},this.getStatusText=function(e,t){return t.$keyChain||""}}.call(o.prototype),t.HashHandler=o,t.MultiHashHandler=u}),ace.define("ace/commands/command_manager",["require","exports","module","ace/lib/oop","ace/keyboard/hash_handler","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("../keyboard/hash_handler").MultiHashHandler,s=e("../lib/event_emitter").EventEmitter,o=function(e,t){i.call(this,t,e),this.byName=this.commands,this.setDefaultHandler("exec",function(e){return e.command.exec(e.editor,e.args||{})})};r.inherits(o,i),function(){r.implement(this,s),this.exec=function(e,t,n){if(Array.isArray(e)){for(var r=e.length;r--;)if(this.exec(e[r],t,n))return!0;return!1}typeof e=="string"&&(e=this.commands[e]);if(!e)return!1;if(t&&t.$readOnly&&!e.readOnly)return!1;var i={editor:t,command:e,args:n};return i.returnValue=this._emit("exec",i),this._signal("afterExec",i),i.returnValue===!1?!1:!0},this.toggleRecording=function(e){if(this.$inReplay)return;return e&&e._emit("changeStatus"),this.recording?(this.macro.pop(),this.removeEventListener("exec",this.$addCommandToMacro),this.macro.length||(this.macro=this.oldMacro),this.recording=!1):(this.$addCommandToMacro||(this.$addCommandToMacro=function(e){this.macro.push([e.command,e.args])}.bind(this)),this.oldMacro=this.macro,this.macro=[],this.on("exec",this.$addCommandToMacro),this.recording=!0)},this.replay=function(e){if(this.$inReplay||!this.macro)return;if(this.recording)return this.toggleRecording(e);try{this.$inReplay=!0,this.macro.forEach(function(t){typeof t=="string"?this.exec(t,e):this.exec(t[0],e,t[1])},this)}finally{this.$inReplay=!1}},this.trimMacro=function(e){return e.map(function(e){return typeof e[0]!="string"&&(e[0]=e[0].name),e[1]||(e=e[0]),e})}}.call(o.prototype),t.CommandManager=o}),ace.define("ace/commands/default_commands",["require","exports","module","ace/lib/lang","ace/config","ace/range"],function(e,t,n){"use strict";function o(e,t){return{win:e,mac:t}}var r=e("../lib/lang"),i=e("../config"),s=e("../range").Range;t.commands=[{name:"showSettingsMenu",bindKey:o("Ctrl-,","Command-,"),exec:function(e){i.loadModule("ace/ext/settings_menu",function(t){t.init(e),e.showSettingsMenu()})},readOnly:!0},{name:"goToNextError",bindKey:o("Alt-E","Ctrl-E"),exec:function(e){i.loadModule("ace/ext/error_marker",function(t){t.showErrorMarker(e,1)})},scrollIntoView:"animate",readOnly:!0},{name:"goToPreviousError",bindKey:o("Alt-Shift-E","Ctrl-Shift-E"),exec:function(e){i.loadModule("ace/ext/error_marker",function(t){t.showErrorMarker(e,-1)})},scrollIntoView:"animate",readOnly:!0},{name:"selectall",bindKey:o("Ctrl-A","Command-A"),exec:function(e){e.selectAll()},readOnly:!0},{name:"centerselection",bindKey:o(null,"Ctrl-L"),exec:function(e){e.centerSelection()},readOnly:!0},{name:"gotoline",bindKey:o("Ctrl-L","Command-L"),exec:function(e){var t=parseInt(prompt("Enter line number:"),10);isNaN(t)||e.gotoLine(t)},readOnly:!0},{name:"fold",bindKey:o("Alt-L|Ctrl-F1","Command-Alt-L|Command-F1"),exec:function(e){e.session.toggleFold(!1)},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"unfold",bindKey:o("Alt-Shift-L|Ctrl-Shift-F1","Command-Alt-Shift-L|Command-Shift-F1"),exec:function(e){e.session.toggleFold(!0)},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"toggleFoldWidget",bindKey:o("F2","F2"),exec:function(e){e.session.toggleFoldWidget()},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"toggleParentFoldWidget",bindKey:o("Alt-F2","Alt-F2"),exec:function(e){e.session.toggleFoldWidget(!0)},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"foldall",bindKey:o(null,"Ctrl-Command-Option-0"),exec:function(e){e.session.foldAll()},scrollIntoView:"center",readOnly:!0},{name:"foldOther",bindKey:o("Alt-0","Command-Option-0"),exec:function(e){e.session.foldAll(),e.session.unfold(e.selection.getAllRanges())},scrollIntoView:"center",readOnly:!0},{name:"unfoldall",bindKey:o("Alt-Shift-0","Command-Option-Shift-0"),exec:function(e){e.session.unfold()},scrollIntoView:"center",readOnly:!0},{name:"findnext",bindKey:o("Ctrl-K","Command-G"),exec:function(e){e.findNext()},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"findprevious",bindKey:o("Ctrl-Shift-K","Command-Shift-G"),exec:function(e){e.findPrevious()},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"selectOrFindNext",bindKey:o("Alt-K","Ctrl-G"),exec:function(e){e.selection.isEmpty()?e.selection.selectWord():e.findNext()},readOnly:!0},{name:"selectOrFindPrevious",bindKey:o("Alt-Shift-K","Ctrl-Shift-G"),exec:function(e){e.selection.isEmpty()?e.selection.selectWord():e.findPrevious()},readOnly:!0},{name:"find",bindKey:o("Ctrl-F","Command-F"),exec:function(e){i.loadModule("ace/ext/searchbox",function(t){t.Search(e)})},readOnly:!0},{name:"overwrite",bindKey:"Insert",exec:function(e){e.toggleOverwrite()},readOnly:!0},{name:"selecttostart",bindKey:o("Ctrl-Shift-Home","Command-Shift-Up"),exec:function(e){e.getSelection().selectFileStart()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"gotostart",bindKey:o("Ctrl-Home","Command-Home|Command-Up"),exec:function(e){e.navigateFileStart()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"selectup",bindKey:o("Shift-Up","Shift-Up"),exec:function(e){e.getSelection().selectUp()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"golineup",bindKey:o("Up","Up|Ctrl-P"),exec:function(e,t){e.navigateUp(t.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selecttoend",bindKey:o("Ctrl-Shift-End","Command-Shift-Down"),exec:function(e){e.getSelection().selectFileEnd()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"gotoend",bindKey:o("Ctrl-End","Command-End|Command-Down"),exec:function(e){e.navigateFileEnd()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"selectdown",bindKey:o("Shift-Down","Shift-Down"),exec:function(e){e.getSelection().selectDown()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"golinedown",bindKey:o("Down","Down|Ctrl-N"),exec:function(e,t){e.navigateDown(t.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectwordleft",bindKey:o("Ctrl-Shift-Left","Option-Shift-Left"),exec:function(e){e.getSelection().selectWordLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotowordleft",bindKey:o("Ctrl-Left","Option-Left"),exec:function(e){e.navigateWordLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selecttolinestart",bindKey:o("Alt-Shift-Left","Command-Shift-Left"),exec:function(e){e.getSelection().selectLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotolinestart",bindKey:o("Alt-Left|Home","Command-Left|Home|Ctrl-A"),exec:function(e){e.navigateLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectleft",bindKey:o("Shift-Left","Shift-Left"),exec:function(e){e.getSelection().selectLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotoleft",bindKey:o("Left","Left|Ctrl-B"),exec:function(e,t){e.navigateLeft(t.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectwordright",bindKey:o("Ctrl-Shift-Right","Option-Shift-Right"),exec:function(e){e.getSelection().selectWordRight()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotowordright",bindKey:o("Ctrl-Right","Option-Right"),exec:function(e){e.navigateWordRight()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selecttolineend",bindKey:o("Alt-Shift-Right","Command-Shift-Right"),exec:function(e){e.getSelection().selectLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotolineend",bindKey:o("Alt-Right|End","Command-Right|End|Ctrl-E"),exec:function(e){e.navigateLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectright",bindKey:o("Shift-Right","Shift-Right"),exec:function(e){e.getSelection().selectRight()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotoright",bindKey:o("Right","Right|Ctrl-F"),exec:function(e,t){e.navigateRight(t.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectpagedown",bindKey:"Shift-PageDown",exec:function(e){e.selectPageDown()},readOnly:!0},{name:"pagedown",bindKey:o(null,"Option-PageDown"),exec:function(e){e.scrollPageDown()},readOnly:!0},{name:"gotopagedown",bindKey:o("PageDown","PageDown|Ctrl-V"),exec:function(e){e.gotoPageDown()},readOnly:!0},{name:"selectpageup",bindKey:"Shift-PageUp",exec:function(e){e.selectPageUp()},readOnly:!0},{name:"pageup",bindKey:o(null,"Option-PageUp"),exec:function(e){e.scrollPageUp()},readOnly:!0},{name:"gotopageup",bindKey:"PageUp",exec:function(e){e.gotoPageUp()},readOnly:!0},{name:"scrollup",bindKey:o("Ctrl-Up",null),exec:function(e){e.renderer.scrollBy(0,-2*e.renderer.layerConfig.lineHeight)},readOnly:!0},{name:"scrolldown",bindKey:o("Ctrl-Down",null),exec:function(e){e.renderer.scrollBy(0,2*e.renderer.layerConfig.lineHeight)},readOnly:!0},{name:"selectlinestart",bindKey:"Shift-Home",exec:function(e){e.getSelection().selectLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectlineend",bindKey:"Shift-End",exec:function(e){e.getSelection().selectLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"togglerecording",bindKey:o("Ctrl-Alt-E","Command-Option-E"),exec:function(e){e.commands.toggleRecording(e)},readOnly:!0},{name:"replaymacro",bindKey:o("Ctrl-Shift-E","Command-Shift-E"),exec:function(e){e.commands.replay(e)},readOnly:!0},{name:"jumptomatching",bindKey:o("Ctrl-P","Ctrl-P"),exec:function(e){e.jumpToMatching()},multiSelectAction:"forEach",scrollIntoView:"animate",readOnly:!0},{name:"selecttomatching",bindKey:o("Ctrl-Shift-P","Ctrl-Shift-P"),exec:function(e){e.jumpToMatching(!0)},multiSelectAction:"forEach",scrollIntoView:"animate",readOnly:!0},{name:"expandToMatching",bindKey:o("Ctrl-Shift-M","Ctrl-Shift-M"),exec:function(e){e.jumpToMatching(!0,!0)},multiSelectAction:"forEach",scrollIntoView:"animate",readOnly:!0},{name:"passKeysToBrowser",bindKey:o(null,null),exec:function(){},passEvent:!0,readOnly:!0},{name:"copy",exec:function(e){},readOnly:!0},{name:"cut",exec:function(e){var t=e.getSelectionRange();e._emit("cut",t),e.selection.isEmpty()||(e.session.remove(t),e.clearSelection())},scrollIntoView:"cursor",multiSelectAction:"forEach"},{name:"paste",exec:function(e,t){e.$handlePaste(t)},scrollIntoView:"cursor"},{name:"removeline",bindKey:o("Ctrl-D","Command-D"),exec:function(e){e.removeLines()},scrollIntoView:"cursor",multiSelectAction:"forEachLine"},{name:"duplicateSelection",bindKey:o("Ctrl-Shift-D","Command-Shift-D"),exec:function(e){e.duplicateSelection()},scrollIntoView:"cursor",multiSelectAction:"forEach"},{name:"sortlines",bindKey:o("Ctrl-Alt-S","Command-Alt-S"),exec:function(e){e.sortLines()},scrollIntoView:"selection",multiSelectAction:"forEachLine"},{name:"togglecomment",bindKey:o("Ctrl-/","Command-/"),exec:function(e){e.toggleCommentLines()},multiSelectAction:"forEachLine",scrollIntoView:"selectionPart"},{name:"toggleBlockComment",bindKey:o("Ctrl-Shift-/","Command-Shift-/"),exec:function(e){e.toggleBlockComment()},multiSelectAction:"forEach",scrollIntoView:"selectionPart"},{name:"modifyNumberUp",bindKey:o("Ctrl-Shift-Up","Alt-Shift-Up"),exec:function(e){e.modifyNumber(1)},scrollIntoView:"cursor",multiSelectAction:"forEach"},{name:"modifyNumberDown",bindKey:o("Ctrl-Shift-Down","Alt-Shift-Down"),exec:function(e){e.modifyNumber(-1)},scrollIntoView:"cursor",multiSelectAction:"forEach"},{name:"replace",bindKey:o("Ctrl-H","Command-Option-F"),exec:function(e){i.loadModule("ace/ext/searchbox",function(t){t.Search(e,!0)})}},{name:"undo",bindKey:o("Ctrl-Z","Command-Z"),exec:function(e){e.undo()}},{name:"redo",bindKey:o("Ctrl-Shift-Z|Ctrl-Y","Command-Shift-Z|Command-Y"),exec:function(e){e.redo()}},{name:"copylinesup",bindKey:o("Alt-Shift-Up","Command-Option-Up"),exec:function(e){e.copyLinesUp()},scrollIntoView:"cursor"},{name:"movelinesup",bindKey:o("Alt-Up","Option-Up"),exec:function(e){e.moveLinesUp()},scrollIntoView:"cursor"},{name:"copylinesdown",bindKey:o("Alt-Shift-Down","Command-Option-Down"),exec:function(e){e.copyLinesDown()},scrollIntoView:"cursor"},{name:"movelinesdown",bindKey:o("Alt-Down","Option-Down"),exec:function(e){e.moveLinesDown()},scrollIntoView:"cursor"},{name:"del",bindKey:o("Delete","Delete|Ctrl-D|Shift-Delete"),exec:function(e){e.remove("right")},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"backspace",bindKey:o("Shift-Backspace|Backspace","Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H"),exec:function(e){e.remove("left")},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"cut_or_delete",bindKey:o("Shift-Delete",null),exec:function(e){if(!e.selection.isEmpty())return!1;e.remove("left")},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removetolinestart",bindKey:o("Alt-Backspace","Command-Backspace"),exec:function(e){e.removeToLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removetolineend",bindKey:o("Alt-Delete","Ctrl-K"),exec:function(e){e.removeToLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removewordleft",bindKey:o("Ctrl-Backspace","Alt-Backspace|Ctrl-Alt-Backspace"),exec:function(e){e.removeWordLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removewordright",bindKey:o("Ctrl-Delete","Alt-Delete"),exec:function(e){e.removeWordRight()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"outdent",bindKey:o("Shift-Tab","Shift-Tab"),exec:function(e){e.blockOutdent()},multiSelectAction:"forEach",scrollIntoView:"selectionPart"},{name:"indent",bindKey:o("Tab","Tab"),exec:function(e){e.indent()},multiSelectAction:"forEach",scrollIntoView:"selectionPart"},{name:"blockoutdent",bindKey:o("Ctrl-[","Ctrl-["),exec:function(e){e.blockOutdent()},multiSelectAction:"forEachLine",scrollIntoView:"selectionPart"},{name:"blockindent",bindKey:o("Ctrl-]","Ctrl-]"),exec:function(e){e.blockIndent()},multiSelectAction:"forEachLine",scrollIntoView:"selectionPart"},{name:"insertstring",exec:function(e,t){e.insert(t)},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"inserttext",exec:function(e,t){e.insert(r.stringRepeat(t.text||"",t.times||1))},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"splitline",bindKey:o(null,"Ctrl-O"),exec:function(e){e.splitLine()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"transposeletters",bindKey:o("Ctrl-T","Ctrl-T"),exec:function(e){e.transposeLetters()},multiSelectAction:function(e){e.transposeSelections(1)},scrollIntoView:"cursor"},{name:"touppercase",bindKey:o("Ctrl-U","Ctrl-U"),exec:function(e){e.toUpperCase()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"tolowercase",bindKey:o("Ctrl-Shift-U","Ctrl-Shift-U"),exec:function(e){e.toLowerCase()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"expandtoline",bindKey:o("Ctrl-Shift-L","Command-Shift-L"),exec:function(e){var t=e.selection.getRange();t.start.column=t.end.column=0,t.end.row++,e.selection.setRange(t,!1)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"joinlines",bindKey:o(null,null),exec:function(e){var t=e.selection.isBackwards(),n=t?e.selection.getSelectionLead():e.selection.getSelectionAnchor(),i=t?e.selection.getSelectionAnchor():e.selection.getSelectionLead(),o=e.session.doc.getLine(n.row).length,u=e.session.doc.getTextRange(e.selection.getRange()),a=u.replace(/\n\s*/," ").length,f=e.session.doc.getLine(n.row);for(var l=n.row+1;l<=i.row+1;l++){var c=r.stringTrimLeft(r.stringTrimRight(e.session.doc.getLine(l)));c.length!==0&&(c=" "+c),f+=c}i.row+1<e.session.doc.getLength()-1&&(f+=e.session.doc.getNewLineCharacter()),e.clearSelection(),e.session.doc.replace(new s(n.row,0,i.row+2,0),f),a>0?(e.selection.moveCursorTo(n.row,n.column),e.selection.selectTo(n.row,n.column+a)):(o=e.session.doc.getLine(n.row).length>o?o+1:o,e.selection.moveCursorTo(n.row,o))},multiSelectAction:"forEach",readOnly:!0},{name:"invertSelection",bindKey:o(null,null),exec:function(e){var t=e.session.doc.getLength()-1,n=e.session.doc.getLine(t).length,r=e.selection.rangeList.ranges,i=[];r.length<1&&(r=[e.selection.getRange()]);for(var o=0;o<r.length;o++)o==r.length-1&&(r[o].end.row!==t||r[o].end.column!==n)&&i.push(new s(r[o].end.row,r[o].end.column,t,n)),o===0?(r[o].start.row!==0||r[o].start.column!==0)&&i.push(new s(0,0,r[o].start.row,r[o].start.column)):i.push(new s(r[o-1].end.row,r[o-1].end.column,r[o].start.row,r[o].start.column));e.exitMultiSelectMode(),e.clearSelection();for(var o=0;o<i.length;o++)e.selection.addRange(i[o],!1)},readOnly:!0,scrollIntoView:"none"}]}),ace.define("ace/editor",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/keyboard/textinput","ace/mouse/mouse_handler","ace/mouse/fold_handler","ace/keyboard/keybinding","ace/edit_session","ace/search","ace/range","ace/lib/event_emitter","ace/commands/command_manager","ace/commands/default_commands","ace/config","ace/token_iterator"],function(e,t,n){"use strict";e("./lib/fixoldbrowsers");var r=e("./lib/oop"),i=e("./lib/dom"),s=e("./lib/lang"),o=e("./lib/useragent"),u=e("./keyboard/textinput").TextInput,a=e("./mouse/mouse_handler").MouseHandler,f=e("./mouse/fold_handler").FoldHandler,l=e("./keyboard/keybinding").KeyBinding,c=e("./edit_session").EditSession,h=e("./search").Search,p=e("./range").Range,d=e("./lib/event_emitter").EventEmitter,v=e("./commands/command_manager").CommandManager,m=e("./commands/default_commands").commands,g=e("./config"),y=e("./token_iterator").TokenIterator,b=function(e,t){var n=e.getContainerElement();this.container=n,this.renderer=e,this.commands=new v(o.isMac?"mac":"win",m),this.textInput=new u(e.getTextAreaContainer(),this),this.renderer.textarea=this.textInput.getElement(),this.keyBinding=new l(this),this.$mouseHandler=new a(this),new f(this),this.$blockScrolling=0,this.$search=(new h).set({wrap:!0}),this.$historyTracker=this.$historyTracker.bind(this),this.commands.on("exec",this.$historyTracker),this.$initOperationListeners(),this._$emitInputEvent=s.delayedCall(function(){this._signal("input",{}),this.session&&this.session.bgTokenizer&&this.session.bgTokenizer.scheduleStart()}.bind(this)),this.on("change",function(e,t){t._$emitInputEvent.schedule(31)}),this.setSession(t||new c("")),g.resetOptions(this),g._signal("editor",this)};(function(){r.implement(this,d),this.$initOperationListeners=function(){function e(e){return e[e.length-1]}this.selections=[],this.commands.on("exec",this.startOperation.bind(this),!0),this.commands.on("afterExec",this.endOperation.bind(this),!0),this.$opResetTimer=s.delayedCall(this.endOperation.bind(this)),this.on("change",function(){this.curOp||this.startOperation(),this.curOp.docChanged=!0}.bind(this),!0),this.on("changeSelection",function(){this.curOp||this.startOperation(),this.curOp.selectionChanged=!0}.bind(this),!0)},this.curOp=null,this.prevOp={},this.startOperation=function(e){if(this.curOp){if(!e||this.curOp.command)return;this.prevOp=this.curOp}e||(this.previousCommand=null,e={}),this.$opResetTimer.schedule(),this.curOp={command:e.command||{},args:e.args,scrollTop:this.renderer.scrollTop},this.curOp.command.name&&this.curOp.command.scrollIntoView!==undefined&&this.$blockScrolling++},this.endOperation=function(e){if(this.curOp){if(e&&e.returnValue===!1)return this.curOp=null;this._signal("beforeEndOperation");var t=this.curOp.command;t.name&&this.$blockScrolling>0&&this.$blockScrolling--;var n=t&&t.scrollIntoView;if(n){switch(n){case"center-animate":n="animate";case"center":this.renderer.scrollCursorIntoView(null,.5);break;case"animate":case"cursor":this.renderer.scrollCursorIntoView();break;case"selectionPart":var r=this.selection.getRange(),i=this.renderer.layerConfig;(r.start.row>=i.lastRow||r.end.row<=i.firstRow)&&this.renderer.scrollSelectionIntoView(this.selection.anchor,this.selection.lead);break;default:}n=="animate"&&this.renderer.animateScrolling(this.curOp.scrollTop)}this.prevOp=this.curOp,this.curOp=null}},this.$mergeableCommands=["backspace","del","insertstring"],this.$historyTracker=function(e){if(!this.$mergeUndoDeltas)return;var t=this.prevOp,n=this.$mergeableCommands,r=t.command&&e.command.name==t.command.name;if(e.command.name=="insertstring"){var i=e.args;this.mergeNextCommand===undefined&&(this.mergeNextCommand=!0),r=r&&this.mergeNextCommand&&(!/\s/.test(i)||/\s/.test(t.args)),this.mergeNextCommand=!0}else r=r&&n.indexOf(e.command.name)!==-1;this.$mergeUndoDeltas!="always"&&Date.now()-this.sequenceStartTime>2e3&&(r=!1),r?this.session.mergeUndoDeltas=!0:n.indexOf(e.command.name)!==-1&&(this.sequenceStartTime=Date.now())},this.setKeyboardHandler=function(e,t){if(e&&typeof e=="string"){this.$keybindingId=e;var n=this;g.loadModule(["keybinding",e],function(r){n.$keybindingId==e&&n.keyBinding.setKeyboardHandler(r&&r.handler),t&&t()})}else this.$keybindingId=null,this.keyBinding.setKeyboardHandler(e),t&&t()},this.getKeyboardHandler=function(){return this.keyBinding.getKeyboardHandler()},this.setSession=function(e){if(this.session==e)return;this.curOp&&this.endOperation(),this.curOp={};var t=this.session;if(t){this.session.off("change",this.$onDocumentChange),this.session.off("changeMode",this.$onChangeMode),this.session.off("tokenizerUpdate",this.$onTokenizerUpdate),this.session.off("changeTabSize",this.$onChangeTabSize),this.session.off("changeWrapLimit",this.$onChangeWrapLimit),this.session.off("changeWrapMode",this.$onChangeWrapMode),this.session.off("changeFold",this.$onChangeFold),this.session.off("changeFrontMarker",this.$onChangeFrontMarker),this.session.off("changeBackMarker",this.$onChangeBackMarker),this.session.off("changeBreakpoint",this.$onChangeBreakpoint),this.session.off("changeAnnotation",this.$onChangeAnnotation),this.session.off("changeOverwrite",this.$onCursorChange),this.session.off("changeScrollTop",this.$onScrollTopChange),this.session.off("changeScrollLeft",this.$onScrollLeftChange);var n=this.session.getSelection();n.off("changeCursor",this.$onCursorChange),n.off("changeSelection",this.$onSelectionChange)}this.session=e,e?(this.$onDocumentChange=this.onDocumentChange.bind(this),e.on("change",this.$onDocumentChange),this.renderer.setSession(e),this.$onChangeMode=this.onChangeMode.bind(this),e.on("changeMode",this.$onChangeMode),this.$onTokenizerUpdate=this.onTokenizerUpdate.bind(this),e.on("tokenizerUpdate",this.$onTokenizerUpdate),this.$onChangeTabSize=this.renderer.onChangeTabSize.bind(this.renderer),e.on("changeTabSize",this.$onChangeTabSize),this.$onChangeWrapLimit=this.onChangeWrapLimit.bind(this),e.on("changeWrapLimit",this.$onChangeWrapLimit),this.$onChangeWrapMode=this.onChangeWrapMode.bind(this),e.on("changeWrapMode",this.$onChangeWrapMode),this.$onChangeFold=this.onChangeFold.bind(this),e.on("changeFold",this.$onChangeFold),this.$onChangeFrontMarker=this.onChangeFrontMarker.bind(this),this.session.on("changeFrontMarker",this.$onChangeFrontMarker),this.$onChangeBackMarker=this.onChangeBackMarker.bind(this),this.session.on("changeBackMarker",this.$onChangeBackMarker),this.$onChangeBreakpoint=this.onChangeBreakpoint.bind(this),this.session.on("changeBreakpoint",this.$onChangeBreakpoint),this.$onChangeAnnotation=this.onChangeAnnotation.bind(this),this.session.on("changeAnnotation",this.$onChangeAnnotation),this.$onCursorChange=this.onCursorChange.bind(this),this.session.on("changeOverwrite",this.$onCursorChange),this.$onScrollTopChange=this.onScrollTopChange.bind(this),this.session.on("changeScrollTop",this.$onScrollTopChange),this.$onScrollLeftChange=this.onScrollLeftChange.bind(this),this.session.on("changeScrollLeft",this.$onScrollLeftChange),this.selection=e.getSelection(),this.selection.on("changeCursor",this.$onCursorChange),this.$onSelectionChange=this.onSelectionChange.bind(this),this.selection.on("changeSelection",this.$onSelectionChange),this.onChangeMode(),this.$blockScrolling+=1,this.onCursorChange(),this.$blockScrolling-=1,this.onScrollTopChange(),this.onScrollLeftChange(),this.onSelectionChange(),this.onChangeFrontMarker(),this.onChangeBackMarker(),this.onChangeBreakpoint(),this.onChangeAnnotation(),this.session.getUseWrapMode()&&this.renderer.adjustWrapLimit(),this.renderer.updateFull()):(this.selection=null,this.renderer.setSession(e)),this._signal("changeSession",{session:e,oldSession:t}),this.curOp=null,t&&t._signal("changeEditor",{oldEditor:this}),e&&e._signal("changeEditor",{editor:this})},this.getSession=function(){return this.session},this.setValue=function(e,t){return this.session.doc.setValue(e),t?t==1?this.navigateFileEnd():t==-1&&this.navigateFileStart():this.selectAll(),e},this.getValue=function(){return this.session.getValue()},this.getSelection=function(){return this.selection},this.resize=function(e){this.renderer.onResize(e)},this.setTheme=function(e,t){this.renderer.setTheme(e,t)},this.getTheme=function(){return this.renderer.getTheme()},this.setStyle=function(e){this.renderer.setStyle(e)},this.unsetStyle=function(e){this.renderer.unsetStyle(e)},this.getFontSize=function(){return this.getOption("fontSize")||i.computedStyle(this.container,"fontSize")},this.setFontSize=function(e){this.setOption("fontSize",e)},this.$highlightBrackets=function(){this.session.$bracketHighlight&&(this.session.removeMarker(this.session.$bracketHighlight),this.session.$bracketHighlight=null);if(this.$highlightPending)return;var e=this;this.$highlightPending=!0,setTimeout(function(){e.$highlightPending=!1;var t=e.session;if(!t||!t.bgTokenizer)return;var n=t.findMatchingBracket(e.getCursorPosition());if(n)var r=new p(n.row,n.column,n.row,n.column+1);else if(t.$mode.getMatching)var r=t.$mode.getMatching(e.session);r&&(t.$bracketHighlight=t.addMarker(r,"ace_bracket","text"))},50)},this.$highlightTags=function(){if(this.$highlightTagPending)return;var e=this;this.$highlightTagPending=!0,setTimeout(function(){e.$highlightTagPending=!1;var t=e.session;if(!t||!t.bgTokenizer)return;var n=e.getCursorPosition(),r=new y(e.session,n.row,n.column),i=r.getCurrentToken();if(!i||!/\b(?:tag-open|tag-name)/.test(i.type)){t.removeMarker(t.$tagHighlight),t.$tagHighlight=null;return}if(i.type.indexOf("tag-open")!=-1){i=r.stepForward();if(!i)return}var s=i.value,o=0,u=r.stepBackward();if(u.value=="<"){do u=i,i=r.stepForward(),i&&i.value===s&&i.type.indexOf("tag-name")!==-1&&(u.value==="<"?o++:u.value==="</"&&o--);while(i&&o>=0)}else{do i=u,u=r.stepBackward(),i&&i.value===s&&i.type.indexOf("tag-name")!==-1&&(u.value==="<"?o++:u.value==="</"&&o--);while(u&&o<=0);r.stepForward()}if(!i){t.removeMarker(t.$tagHighlight),t.$tagHighlight=null;return}var a=r.getCurrentTokenRow(),f=r.getCurrentTokenColumn(),l=new p(a,f,a,f+i.value.length);t.$tagHighlight&&l.compareRange(t.$backMarkers[t.$tagHighlight].range)!==0&&(t.removeMarker(t.$tagHighlight),t.$tagHighlight=null),l&&!t.$tagHighlight&&(t.$tagHighlight=t.addMarker(l,"ace_bracket","text"))},50)},this.focus=function(){var e=this;setTimeout(function(){e.textInput.focus()}),this.textInput.focus()},this.isFocused=function(){return this.textInput.isFocused()},this.blur=function(){this.textInput.blur()},this.onFocus=function(e){if(this.$isFocused)return;this.$isFocused=!0,this.renderer.showCursor(),this.renderer.visualizeFocus(),this._emit("focus",e)},this.onBlur=function(e){if(!this.$isFocused)return;this.$isFocused=!1,this.renderer.hideCursor(),this.renderer.visualizeBlur(),this._emit("blur",e)},this.$cursorChange=function(){this.renderer.updateCursor()},this.onDocumentChange=function(e){var t=this.session.$useWrapMode,n=e.start.row==e.end.row?e.end.row:Infinity;this.renderer.updateLines(e.start.row,n,t),this._signal("change",e),this.$cursorChange(),this.$updateHighlightActiveLine()},this.onTokenizerUpdate=function(e){var t=e.data;this.renderer.updateLines(t.first,t.last)},this.onScrollTopChange=function(){this.renderer.scrollToY(this.session.getScrollTop())},this.onScrollLeftChange=function(){this.renderer.scrollToX(this.session.getScrollLeft())},this.onCursorChange=function(){this.$cursorChange(),this.$blockScrolling||(g.warn("Automatically scrolling cursor into view after selection change","this will be disabled in the next version","set editor.$blockScrolling = Infinity to disable this message"),this.renderer.scrollCursorIntoView()),this.$highlightBrackets(),this.$highlightTags(),this.$updateHighlightActiveLine(),this._signal("changeSelection")},this.$updateHighlightActiveLine=function(){var e=this.getSession(),t;if(this.$highlightActiveLine){if(this.$selectionStyle!="line"||!this.selection.isMultiLine())t=this.getCursorPosition();this.renderer.$maxLines&&this.session.getLength()===1&&!(this.renderer.$minLines>1)&&(t=!1)}if(e.$highlightLineMarker&&!t)e.removeMarker(e.$highlightLineMarker.id),e.$highlightLineMarker=null;else if(!e.$highlightLineMarker&&t){var n=new p(t.row,t.column,t.row,Infinity);n.id=e.addMarker(n,"ace_active-line","screenLine"),e.$highlightLineMarker=n}else t&&(e.$highlightLineMarker.start.row=t.row,e.$highlightLineMarker.end.row=t.row,e.$highlightLineMarker.start.column=t.column,e._signal("changeBackMarker"))},this.onSelectionChange=function(e){var t=this.session;t.$selectionMarker&&t.removeMarker(t.$selectionMarker),t.$selectionMarker=null;if(!this.selection.isEmpty()){var n=this.selection.getRange(),r=this.getSelectionStyle();t.$selectionMarker=t.addMarker(n,"ace_selection",r)}else this.$updateHighlightActiveLine();var i=this.$highlightSelectedWord&&this.$getSelectionHighLightRegexp();this.session.highlight(i),this._signal("changeSelection")},this.$getSelectionHighLightRegexp=function(){var e=this.session,t=this.getSelectionRange();if(t.isEmpty()||t.isMultiLine())return;var n=t.start.column-1,r=t.end.column+1,i=e.getLine(t.start.row),s=i.length,o=i.substring(Math.max(n,0),Math.min(r,s));if(n>=0&&/^[\w\d]/.test(o)||r<=s&&/[\w\d]$/.test(o))return;o=i.substring(t.start.column,t.end.column);if(!/^[\w\d]+$/.test(o))return;var u=this.$search.$assembleRegExp({wholeWord:!0,caseSensitive:!0,needle:o});return u},this.onChangeFrontMarker=function(){this.renderer.updateFrontMarkers()},this.onChangeBackMarker=function(){this.renderer.updateBackMarkers()},this.onChangeBreakpoint=function(){this.renderer.updateBreakpoints()},this.onChangeAnnotation=function(){this.renderer.setAnnotations(this.session.getAnnotations())},this.onChangeMode=function(e){this.renderer.updateText(),this._emit("changeMode",e)},this.onChangeWrapLimit=function(){this.renderer.updateFull()},this.onChangeWrapMode=function(){this.renderer.onResize(!0)},this.onChangeFold=function(){this.$updateHighlightActiveLine(),this.renderer.updateFull()},this.getSelectedText=function(){return this.session.getTextRange(this.getSelectionRange())},this.getCopyText=function(){var e=this.getSelectedText();return this._signal("copy",e),e},this.onCopy=function(){this.commands.exec("copy",this)},this.onCut=function(){this.commands.exec("cut",this)},this.onPaste=function(e,t){var n={text:e,event:t};this.commands.exec("paste",this,n)},this.$handlePaste=function(e){typeof e=="string"&&(e={text:e}),this._signal("paste",e);var t=e.text;if(!this.inMultiSelectMode||this.inVirtualSelectionMode)this.insert(t);else{var n=t.split(/\r\n|\r|\n/),r=this.selection.rangeList.ranges;if(n.length>r.length||n.length<2||!n[1])return this.commands.exec("insertstring",this,t);for(var i=r.length;i--;){var s=r[i];s.isEmpty()||this.session.remove(s),this.session.insert(s.start,n[i])}}},this.execCommand=function(e,t){return this.commands.exec(e,this,t)},this.insert=function(e,t){var n=this.session,r=n.getMode(),i=this.getCursorPosition();if(this.getBehavioursEnabled()&&!t){var s=r.transformAction(n.getState(i.row),"insertion",this,n,e);s&&(e!==s.text&&(this.session.mergeUndoDeltas=!1,this.$mergeNextCommand=!1),e=s.text)}e==" "&&(e=this.session.getTabString());if(!this.selection.isEmpty()){var o=this.getSelectionRange();i=this.session.remove(o),this.clearSelection()}else if(this.session.getOverwrite()){var o=new p.fromPoints(i,i);o.end.column+=e.length,this.session.remove(o)}if(e=="\n"||e=="\r\n"){var u=n.getLine(i.row);if(i.column>u.search(/\S|$/)){var a=u.substr(i.column).search(/\S|$/);n.doc.removeInLine(i.row,i.column,i.column+a)}}this.clearSelection();var f=i.column,l=n.getState(i.row),u=n.getLine(i.row),c=r.checkOutdent(l,u,e),h=n.insert(i,e);s&&s.selection&&(s.selection.length==2?this.selection.setSelectionRange(new p(i.row,f+s.selection[0],i.row,f+s.selection[1])):this.selection.setSelectionRange(new p(i.row+s.selection[0],s.selection[1],i.row+s.selection[2],s.selection[3])));if(n.getDocument().isNewLine(e)){var d=r.getNextLineIndent(l,u.slice(0,i.column),n.getTabString());n.insert({row:i.row+1,column:0},d)}c&&r.autoOutdent(l,n,i.row)},this.onTextInput=function(e){this.keyBinding.onTextInput(e)},this.onCommandKey=function(e,t,n){this.keyBinding.onCommandKey(e,t,n)},this.setOverwrite=function(e){this.session.setOverwrite(e)},this.getOverwrite=function(){return this.session.getOverwrite()},this.toggleOverwrite=function(){this.session.toggleOverwrite()},this.setScrollSpeed=function(e){this.setOption("scrollSpeed",e)},this.getScrollSpeed=function(){return this.getOption("scrollSpeed")},this.setDragDelay=function(e){this.setOption("dragDelay",e)},this.getDragDelay=function(){return this.getOption("dragDelay")},this.setSelectionStyle=function(e){this.setOption("selectionStyle",e)},this.getSelectionStyle=function(){return this.getOption("selectionStyle")},this.setHighlightActiveLine=function(e){this.setOption("highlightActiveLine",e)},this.getHighlightActiveLine=function(){return this.getOption("highlightActiveLine")},this.setHighlightGutterLine=function(e){this.setOption("highlightGutterLine",e)},this.getHighlightGutterLine=function(){return this.getOption("highlightGutterLine")},this.setHighlightSelectedWord=function(e){this.setOption("highlightSelectedWord",e)},this.getHighlightSelectedWord=function(){return this.$highlightSelectedWord},this.setAnimatedScroll=function(e){this.renderer.setAnimatedScroll(e)},this.getAnimatedScroll=function(){return this.renderer.getAnimatedScroll()},this.setShowInvisibles=function(e){this.renderer.setShowInvisibles(e)},this.getShowInvisibles=function(){return this.renderer.getShowInvisibles()},this.setDisplayIndentGuides=function(e){this.renderer.setDisplayIndentGuides(e)},this.getDisplayIndentGuides=function(){return this.renderer.getDisplayIndentGuides()},this.setShowPrintMargin=function(e){this.renderer.setShowPrintMargin(e)},this.getShowPrintMargin=function(){return this.renderer.getShowPrintMargin()},this.setPrintMarginColumn=function(e){this.renderer.setPrintMarginColumn(e)},this.getPrintMarginColumn=function(){return this.renderer.getPrintMarginColumn()},this.setReadOnly=function(e){this.setOption("readOnly",e)},this.getReadOnly=function(){return this.getOption("readOnly")},this.setBehavioursEnabled=function(e){this.setOption("behavioursEnabled",e)},this.getBehavioursEnabled=function(){return this.getOption("behavioursEnabled")},this.setWrapBehavioursEnabled=function(e){this.setOption("wrapBehavioursEnabled",e)},this.getWrapBehavioursEnabled=function(){return this.getOption("wrapBehavioursEnabled")},this.setShowFoldWidgets=function(e){this.setOption("showFoldWidgets",e)},this.getShowFoldWidgets=function(){return this.getOption("showFoldWidgets")},this.setFadeFoldWidgets=function(e){this.setOption("fadeFoldWidgets",e)},this.getFadeFoldWidgets=function(){return this.getOption("fadeFoldWidgets")},this.remove=function(e){this.selection.isEmpty()&&(e=="left"?this.selection.selectLeft():this.selection.selectRight());var t=this.getSelectionRange();if(this.getBehavioursEnabled()){var n=this.session,r=n.getState(t.start.row),i=n.getMode().transformAction(r,"deletion",this,n,t);if(t.end.column===0){var s=n.getTextRange(t);if(s[s.length-1]=="\n"){var o=n.getLine(t.end.row);/^\s+$/.test(o)&&(t.end.column=o.length)}}i&&(t=i)}this.session.remove(t),this.clearSelection()},this.removeWordRight=function(){this.selection.isEmpty()&&this.selection.selectWordRight(),this.session.remove(this.getSelectionRange()),this.clearSelection()},this.removeWordLeft=function(){this.selection.isEmpty()&&this.selection.selectWordLeft(),this.session.remove(this.getSelectionRange()),this.clearSelection()},this.removeToLineStart=function(){this.selection.isEmpty()&&this.selection.selectLineStart(),this.session.remove(this.getSelectionRange()),this.clearSelection()},this.removeToLineEnd=function(){this.selection.isEmpty()&&this.selection.selectLineEnd();var e=this.getSelectionRange();e.start.column==e.end.column&&e.start.row==e.end.row&&(e.end.column=0,e.end.row++),this.session.remove(e),this.clearSelection()},this.splitLine=function(){this.selection.isEmpty()||(this.session.remove(this.getSelectionRange()),this.clearSelection());var e=this.getCursorPosition();this.insert("\n"),this.moveCursorToPosition(e)},this.transposeLetters=function(){if(!this.selection.isEmpty())return;var e=this.getCursorPosition(),t=e.column;if(t===0)return;var n=this.session.getLine(e.row),r,i;t<n.length?(r=n.charAt(t)+n.charAt(t-1),i=new p(e.row,t-1,e.row,t+1)):(r=n.charAt(t-1)+n.charAt(t-2),i=new p(e.row,t-2,e.row,t)),this.session.replace(i,r)},this.toLowerCase=function(){var e=this.getSelectionRange();this.selection.isEmpty()&&this.selection.selectWord();var t=this.getSelectionRange(),n=this.session.getTextRange(t);this.session.replace(t,n.toLowerCase()),this.selection.setSelectionRange(e)},this.toUpperCase=function(){var e=this.getSelectionRange();this.selection.isEmpty()&&this.selection.selectWord();var t=this.getSelectionRange(),n=this.session.getTextRange(t);this.session.replace(t,n.toUpperCase()),this.selection.setSelectionRange(e)},this.indent=function(){var e=this.session,t=this.getSelectionRange();if(t.start.row<t.end.row){var n=this.$getSelectedRows();e.indentRows(n.first,n.last," ");return}if(t.start.column<t.end.column){var r=e.getTextRange(t);if(!/^\s+$/.test(r)){var n=this.$getSelectedRows();e.indentRows(n.first,n.last," ");return}}var i=e.getLine(t.start.row),o=t.start,u=e.getTabSize(),a=e.documentToScreenColumn(o.row,o.column);if(this.session.getUseSoftTabs())var f=u-a%u,l=s.stringRepeat(" ",f);else{var f=a%u;while(i[t.start.column-1]==" "&&f)t.start.column--,f--;this.selection.setSelectionRange(t),l=" "}return this.insert(l)},this.blockIndent=function(){var e=this.$getSelectedRows();this.session.indentRows(e.first,e.last," ")},this.blockOutdent=function(){var e=this.session.getSelection();this.session.outdentRows(e.getRange())},this.sortLines=function(){var e=this.$getSelectedRows(),t=this.session,n=[];for(i=e.first;i<=e.last;i++)n.push(t.getLine(i));n.sort(function(e,t){return e.toLowerCase()<t.toLowerCase()?-1:e.toLowerCase()>t.toLowerCase()?1:0});var r=new p(0,0,0,0);for(var i=e.first;i<=e.last;i++){var s=t.getLine(i);r.start.row=i,r.end.row=i,r.end.column=s.length,t.replace(r,n[i-e.first])}},this.toggleCommentLines=function(){var e=this.session.getState(this.getCursorPosition().row),t=this.$getSelectedRows();this.session.getMode().toggleCommentLines(e,this.session,t.first,t.last)},this.toggleBlockComment=function(){var e=this.getCursorPosition(),t=this.session.getState(e.row),n=this.getSelectionRange();this.session.getMode().toggleBlockComment(t,this.session,n,e)},this.getNumberAt=function(e,t){var n=/[\-]?[0-9]+(?:\.[0-9]+)?/g;n.lastIndex=0;var r=this.session.getLine(e);while(n.lastIndex<t){var i=n.exec(r);if(i.index<=t&&i.index+i[0].length>=t){var s={value:i[0],start:i.index,end:i.index+i[0].length};return s}}return null},this.modifyNumber=function(e){var t=this.selection.getCursor().row,n=this.selection.getCursor().column,r=new p(t,n-1,t,n),i=this.session.getTextRange(r);if(!isNaN(parseFloat(i))&&isFinite(i)){var s=this.getNumberAt(t,n);if(s){var o=s.value.indexOf(".")>=0?s.start+s.value.indexOf(".")+1:s.end,u=s.start+s.value.length-o,a=parseFloat(s.value);a*=Math.pow(10,u),o!==s.end&&n<o?e*=Math.pow(10,s.end-n-1):e*=Math.pow(10,s.end-n),a+=e,a/=Math.pow(10,u);var f=a.toFixed(u),l=new p(t,s.start,t,s.end);this.session.replace(l,f),this.moveCursorTo(t,Math.max(s.start+1,n+f.length-s.value.length))}}},this.removeLines=function(){var e=this.$getSelectedRows();this.session.removeFullLines(e.first,e.last),this.clearSelection()},this.duplicateSelection=function(){var e=this.selection,t=this.session,n=e.getRange(),r=e.isBackwards();if(n.isEmpty()){var i=n.start.row;t.duplicateLines(i,i)}else{var s=r?n.start:n.end,o=t.insert(s,t.getTextRange(n),!1);n.start=s,n.end=o,e.setSelectionRange(n,r)}},this.moveLinesDown=function(){this.$moveLines(1,!1)},this.moveLinesUp=function(){this.$moveLines(-1,!1)},this.moveText=function(e,t,n){return this.session.moveText(e,t,n)},this.copyLinesUp=function(){this.$moveLines(-1,!0)},this.copyLinesDown=function(){this.$moveLines(1,!0)},this.$moveLines=function(e,t){var n,r,i=this.selection;if(!i.inMultiSelectMode||this.inVirtualSelectionMode){var s=i.toOrientedRange();n=this.$getSelectedRows(s),r=this.session.$moveLines(n.first,n.last,t?0:e),t&&e==-1&&(r=0),s.moveBy(r,0),i.fromOrientedRange(s)}else{var o=i.rangeList.ranges;i.rangeList.detach(this.session),this.inVirtualSelectionMode=!0;var u=0,a=0,f=o.length;for(var l=0;l<f;l++){var c=l;o[l].moveBy(u,0),n=this.$getSelectedRows(o[l]);var h=n.first,p=n.last;while(++l<f){a&&o[l].moveBy(a,0);var d=this.$getSelectedRows(o[l]);if(t&&d.first!=p)break;if(!t&&d.first>p+1)break;p=d.last}l--,u=this.session.$moveLines(h,p,t?0:e),t&&e==-1&&(c=l+1);while(c<=l)o[c].moveBy(u,0),c++;t||(u=0),a+=u}i.fromOrientedRange(i.ranges[0]),i.rangeList.attach(this.session),this.inVirtualSelectionMode=!1}},this.$getSelectedRows=function(e){return e=(e||this.getSelectionRange()).collapseRows(),{first:this.session.getRowFoldStart(e.start.row),last:this.session.getRowFoldEnd(e.end.row)}},this.onCompositionStart=function(e){this.renderer.showComposition(this.getCursorPosition())},this.onCompositionUpdate=function(e){this.renderer.setCompositionText(e)},this.onCompositionEnd=function(){this.renderer.hideComposition()},this.getFirstVisibleRow=function(){return this.renderer.getFirstVisibleRow()},this.getLastVisibleRow=function(){return this.renderer.getLastVisibleRow()},this.isRowVisible=function(e){return e>=this.getFirstVisibleRow()&&e<=this.getLastVisibleRow()},this.isRowFullyVisible=function(e){return e>=this.renderer.getFirstFullyVisibleRow()&&e<=this.renderer.getLastFullyVisibleRow()},this.$getVisibleRowCount=function(){return this.renderer.getScrollBottomRow()-this.renderer.getScrollTopRow()+1},this.$moveByPage=function(e,t){var n=this.renderer,r=this.renderer.layerConfig,i=e*Math.floor(r.height/r.lineHeight);this.$blockScrolling++,t===!0?this.selection.$moveSelection(function(){this.moveCursorBy(i,0)}):t===!1&&(this.selection.moveCursorBy(i,0),this.selection.clearSelection()),this.$blockScrolling--;var s=n.scrollTop;n.scrollBy(0,i*r.lineHeight),t!=null&&n.scrollCursorIntoView(null,.5),n.animateScrolling(s)},this.selectPageDown=function(){this.$moveByPage(1,!0)},this.selectPageUp=function(){this.$moveByPage(-1,!0)},this.gotoPageDown=function(){this.$moveByPage(1,!1)},this.gotoPageUp=function(){this.$moveByPage(-1,!1)},this.scrollPageDown=function(){this.$moveByPage(1)},this.scrollPageUp=function(){this.$moveByPage(-1)},this.scrollToRow=function(e){this.renderer.scrollToRow(e)},this.scrollToLine=function(e,t,n,r){this.renderer.scrollToLine(e,t,n,r)},this.centerSelection=function(){var e=this.getSelectionRange(),t={row:Math.floor(e.start.row+(e.end.row-e.start.row)/2),column:Math.floor(e.start.column+(e.end.column-e.start.column)/2)};this.renderer.alignCursor(t,.5)},this.getCursorPosition=function(){return this.selection.getCursor()},this.getCursorPositionScreen=function(){return this.session.documentToScreenPosition(this.getCursorPosition())},this.getSelectionRange=function(){return this.selection.getRange()},this.selectAll=function(){this.$blockScrolling+=1,this.selection.selectAll(),this.$blockScrolling-=1},this.clearSelection=function(){this.selection.clearSelection()},this.moveCursorTo=function(e,t){this.selection.moveCursorTo(e,t)},this.moveCursorToPosition=function(e){this.selection.moveCursorToPosition(e)},this.jumpToMatching=function(e,t){var n=this.getCursorPosition(),r=new y(this.session,n.row,n.column),i=r.getCurrentToken(),s=i||r.stepForward();if(!s)return;var o,u=!1,a={},f=n.column-s.start,l,c={")":"(","(":"(","]":"[","[":"[","{":"{","}":"{"};do{if(s.value.match(/[{}()\[\]]/g))for(;f<s.value.length&&!u;f++){if(!c[s.value[f]])continue;l=c[s.value[f]]+"."+s.type.replace("rparen","lparen"),isNaN(a[l])&&(a[l]=0);switch(s.value[f]){case"(":case"[":case"{":a[l]++;break;case")":case"]":case"}":a[l]--,a[l]===-1&&(o="bracket",u=!0)}}else s&&s.type.indexOf("tag-name")!==-1&&(isNaN(a[s.value])&&(a[s.value]=0),i.value==="<"?a[s.value]++:i.value==="</"&&a[s.value]--,a[s.value]===-1&&(o="tag",u=!0));u||(i=s,s=r.stepForward(),f=0)}while(s&&!u);if(!o)return;var h,d;if(o==="bracket"){h=this.session.getBracketRange(n);if(!h){h=new p(r.getCurrentTokenRow(),r.getCurrentTokenColumn()+f-1,r.getCurrentTokenRow(),r.getCurrentTokenColumn()+f-1),d=h.start;if(t||d.row===n.row&&Math.abs(d.column-n.column)<2)h=this.session.getBracketRange(d)}}else if(o==="tag"){if(!s||s.type.indexOf("tag-name")===-1)return;var v=s.value;h=new p(r.getCurrentTokenRow(),r.getCurrentTokenColumn()-2,r.getCurrentTokenRow(),r.getCurrentTokenColumn()-2);if(h.compare(n.row,n.column)===0){u=!1;do s=i,i=r.stepBackward(),i&&(i.type.indexOf("tag-close")!==-1&&h.setEnd(r.getCurrentTokenRow(),r.getCurrentTokenColumn()+1),s.value===v&&s.type.indexOf("tag-name")!==-1&&(i.value==="<"?a[v]++:i.value==="</"&&a[v]--,a[v]===0&&(u=!0)));while(i&&!u)}s&&s.type.indexOf("tag-name")&&(d=h.start,d.row==n.row&&Math.abs(d.column-n.column)<2&&(d=h.end))}d=h&&h.cursor||d,d&&(e?h&&t?this.selection.setRange(h):h&&h.isEqual(this.getSelectionRange())?this.clearSelection():this.selection.selectTo(d.row,d.column):this.selection.moveTo(d.row,d.column))},this.gotoLine=function(e,t,n){this.selection.clearSelection(),this.session.unfold({row:e-1,column:t||0}),this.$blockScrolling+=1,this.exitMultiSelectMode&&this.exitMultiSelectMode(),this.moveCursorTo(e-1,t||0),this.$blockScrolling-=1,this.isRowFullyVisible(e-1)||this.scrollToLine(e-1,!0,n)},this.navigateTo=function(e,t){this.selection.moveTo(e,t)},this.navigateUp=function(e){if(this.selection.isMultiLine()&&!this.selection.isBackwards()){var t=this.selection.anchor.getPosition();return this.moveCursorToPosition(t)}this.selection.clearSelection(),this.selection.moveCursorBy(-e||-1,0)},this.navigateDown=function(e){if(this.selection.isMultiLine()&&this.selection.isBackwards()){var t=this.selection.anchor.getPosition();return this.moveCursorToPosition(t)}this.selection.clearSelection(),this.selection.moveCursorBy(e||1,0)},this.navigateLeft=function(e){if(!this.selection.isEmpty()){var t=this.getSelectionRange().start;this.moveCursorToPosition(t)}else{e=e||1;while(e--)this.selection.moveCursorLeft()}this.clearSelection()},this.navigateRight=function(e){if(!this.selection.isEmpty()){var t=this.getSelectionRange().end;this.moveCursorToPosition(t)}else{e=e||1;while(e--)this.selection.moveCursorRight()}this.clearSelection()},this.navigateLineStart=function(){this.selection.moveCursorLineStart(),this.clearSelection()},this.navigateLineEnd=function(){this.selection.moveCursorLineEnd(),this.clearSelection()},this.navigateFileEnd=function(){this.selection.moveCursorFileEnd(),this.clearSelection()},this.navigateFileStart=function(){this.selection.moveCursorFileStart(),this.clearSelection()},this.navigateWordRight=function(){this.selection.moveCursorWordRight(),this.clearSelection()},this.navigateWordLeft=function(){this.selection.moveCursorWordLeft(),this.clearSelection()},this.replace=function(e,t){t&&this.$search.set(t);var n=this.$search.find(this.session),r=0;return n?(this.$tryReplace(n,e)&&(r=1),n!==null&&(this.selection.setSelectionRange(n),this.renderer.scrollSelectionIntoView(n.start,n.end)),r):r},this.replaceAll=function(e,t){t&&this.$search.set(t);var n=this.$search.findAll(this.session),r=0;if(!n.length)return r;this.$blockScrolling+=1;var i=this.getSelectionRange();this.selection.moveTo(0,0);for(var s=n.length-1;s>=0;--s)this.$tryReplace(n[s],e)&&r++;return this.selection.setSelectionRange(i),this.$blockScrolling-=1,r},this.$tryReplace=function(e,t){var n=this.session.getTextRange(e);return t=this.$search.replace(n,t),t!==null?(e.end=this.session.replace(e,t),e):null},this.getLastSearchOptions=function(){return this.$search.getOptions()},this.find=function(e,t,n){t||(t={}),typeof e=="string"||e instanceof RegExp?t.needle=e:typeof e=="object"&&r.mixin(t,e);var i=this.selection.getRange();t.needle==null&&(e=this.session.getTextRange(i)||this.$search.$options.needle,e||(i=this.session.getWordRange(i.start.row,i.start.column),e=this.session.getTextRange(i)),this.$search.set({needle:e})),this.$search.set(t),t.start||this.$search.set({start:i});var s=this.$search.find(this.session);if(t.preventScroll)return s;if(s)return this.revealRange(s,n),s;t.backwards?i.start=i.end:i.end=i.start,this.selection.setRange(i)},this.findNext=function(e,t){this.find({skipCurrent:!0,backwards:!1},e,t)},this.findPrevious=function(e,t){this.find(e,{skipCurrent:!0,backwards:!0},t)},this.revealRange=function(e,t){this.$blockScrolling+=1,this.session.unfold(e),this.selection.setSelectionRange(e),this.$blockScrolling-=1;var n=this.renderer.scrollTop;this.renderer.scrollSelectionIntoView(e.start,e.end,.5),t!==!1&&this.renderer.animateScrolling(n)},this.undo=function(){this.$blockScrolling++,this.session.getUndoManager().undo(),this.$blockScrolling--,this.renderer.scrollCursorIntoView(null,.5)},this.redo=function(){this.$blockScrolling++,this.session.getUndoManager().redo(),this.$blockScrolling--,this.renderer.scrollCursorIntoView(null,.5)},this.destroy=function(){this.renderer.destroy(),this._signal("destroy",this),this.session&&this.session.destroy()},this.setAutoScrollEditorIntoView=function(e){if(!e)return;var t,n=this,r=!1;this.$scrollAnchor||(this.$scrollAnchor=document.createElement("div"));var i=this.$scrollAnchor;i.style.cssText="position:absolute",this.container.insertBefore(i,this.container.firstChild);var s=this.on("changeSelection",function(){r=!0}),o=this.renderer.on("beforeRender",function(){r&&(t=n.renderer.container.getBoundingClientRect())}),u=this.renderer.on("afterRender",function(){if(r&&t&&(n.isFocused()||n.searchBox&&n.searchBox.isFocused())){var e=n.renderer,s=e.$cursorLayer.$pixelPos,o=e.layerConfig,u=s.top-o.offset;s.top>=0&&u+t.top<0?r=!0:s.top<o.height&&s.top+t.top+o.lineHeight>window.innerHeight?r=!1:r=null,r!=null&&(i.style.top=u+"px",i.style.left=s.left+"px",i.style.height=o.lineHeight+"px",i.scrollIntoView(r)),r=t=null}});this.setAutoScrollEditorIntoView=function(e){if(e)return;delete this.setAutoScrollEditorIntoView,this.off("changeSelection",s),this.renderer.off("afterRender",u),this.renderer.off("beforeRender",o)}},this.$resetCursorStyle=function(){var e=this.$cursorStyle||"ace",t=this.renderer.$cursorLayer;if(!t)return;t.setSmoothBlinking(/smooth/.test(e)),t.isBlinking=!this.$readOnly&&e!="wide",i.setCssClass(t.element,"ace_slim-cursors",/slim/.test(e))}}).call(b.prototype),g.defineOptions(b.prototype,"editor",{selectionStyle:{set:function(e){this.onSelectionChange(),this._signal("changeSelectionStyle",{data:e})},initialValue:"line"},highlightActiveLine:{set:function(){this.$updateHighlightActiveLine()},initialValue:!0},highlightSelectedWord:{set:function(e){this.$onSelectionChange()},initialValue:!0},readOnly:{set:function(e){this.$resetCursorStyle()},initialValue:!1},cursorStyle:{set:function(e){this.$resetCursorStyle()},values:["ace","slim","smooth","wide"],initialValue:"ace"},mergeUndoDeltas:{values:[!1,!0,"always"],initialValue:!0},behavioursEnabled:{initialValue:!0},wrapBehavioursEnabled:{initialValue:!0},autoScrollEditorIntoView:{set:function(e){this.setAutoScrollEditorIntoView(e)}},keyboardHandler:{set:function(e){this.setKeyboardHandler(e)},get:function(){return this.keybindingId},handlesSet:!0},hScrollBarAlwaysVisible:"renderer",vScrollBarAlwaysVisible:"renderer",highlightGutterLine:"renderer",animatedScroll:"renderer",showInvisibles:"renderer",showPrintMargin:"renderer",printMarginColumn:"renderer",printMargin:"renderer",fadeFoldWidgets:"renderer",showFoldWidgets:"renderer",showLineNumbers:"renderer",showGutter:"renderer",displayIndentGuides:"renderer",fontSize:"renderer",fontFamily:"renderer",maxLines:"renderer",minLines:"renderer",scrollPastEnd:"renderer",fixedWidthGutter:"renderer",theme:"renderer",scrollSpeed:"$mouseHandler",dragDelay:"$mouseHandler",dragEnabled:"$mouseHandler",focusTimout:"$mouseHandler",tooltipFollowsMouse:"$mouseHandler",firstLineNumber:"session",overwrite:"session",newLineMode:"session",useWorker:"session",useSoftTabs:"session",tabSize:"session",wrap:"session",indentedSoftWrap:"session",foldStyle:"session",mode:"session"}),t.Editor=b}),ace.define("ace/undomanager",["require","exports","module"],function(e,t,n){"use strict";var r=function(){this.reset()};(function(){function e(e){return{action:e.action,start:e.start,end:e.end,lines:e.lines.length==1?null:e.lines,text:e.lines.length==1?e.lines[0]:null}}function t(e){return{action:e.action,start:e.start,end:e.end,lines:e.lines||[e.text]}}function n(e,t){var n=new Array(e.length);for(var r=0;r<e.length;r++){var i=e[r],s={group:i.group,deltas:new Array(i.length)};for(var o=0;o<i.deltas.length;o++){var u=i.deltas[o];s.deltas[o]=t(u)}n[r]=s}return n}this.execute=function(e){var t=e.args[0];this.$doc=e.args[1],e.merge&&this.hasUndo()&&(this.dirtyCounter--,t=this.$undoStack.pop().concat(t)),this.$undoStack.push(t),this.$redoStack=[],this.dirtyCounter<0&&(this.dirtyCounter=NaN),this.dirtyCounter++},this.undo=function(e){var t=this.$undoStack.pop(),n=null;return t&&(n=this.$doc.undoChanges(t,e),this.$redoStack.push(t),this.dirtyCounter--),n},this.redo=function(e){var t=this.$redoStack.pop(),n=null;return t&&(n=this.$doc.redoChanges(this.$deserializeDeltas(t),e),this.$undoStack.push(t),this.dirtyCounter++),n},this.reset=function(){this.$undoStack=[],this.$redoStack=[],this.dirtyCounter=0},this.hasUndo=function(){return this.$undoStack.length>0},this.hasRedo=function(){return this.$redoStack.length>0},this.markClean=function(){this.dirtyCounter=0},this.isClean=function(){return this.dirtyCounter===0},this.$serializeDeltas=function(t){return n(t,e)},this.$deserializeDeltas=function(e){return n(e,t)}}).call(r.prototype),t.UndoManager=r}),ace.define("ace/layer/gutter",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("../lib/dom"),i=e("../lib/oop"),s=e("../lib/lang"),o=e("../lib/event_emitter").EventEmitter,u=function(e){this.element=r.createElement("div"),this.element.className="ace_layer ace_gutter-layer",e.appendChild(this.element),this.setShowFoldWidgets(this.$showFoldWidgets),this.gutterWidth=0,this.$annotations=[],this.$updateAnnotations=this.$updateAnnotations.bind(this),this.$cells=[]};(function(){i.implement(this,o),this.setSession=function(e){this.session&&this.session.removeEventListener("change",this.$updateAnnotations),this.session=e,e&&e.on("change",this.$updateAnnotations)},this.addGutterDecoration=function(e,t){window.console&&console.warn&&console.warn("deprecated use session.addGutterDecoration"),this.session.addGutterDecoration(e,t)},this.removeGutterDecoration=function(e,t){window.console&&console.warn&&console.warn("deprecated use session.removeGutterDecoration"),this.session.removeGutterDecoration(e,t)},this.setAnnotations=function(e){this.$annotations=[];for(var t=0;t<e.length;t++){var n=e[t],r=n.row,i=this.$annotations[r];i||(i=this.$annotations[r]={text:[]});var o=n.text;o=o?s.escapeHTML(o):n.html||"",i.text.indexOf(o)===-1&&i.text.push(o);var u=n.type;u=="error"?i.className=" ace_error":u=="warning"&&i.className!=" ace_error"?i.className=" ace_warning":u=="info"&&!i.className&&(i.className=" ace_info")}},this.$updateAnnotations=function(e){if(!this.$annotations.length)return;var t=e.start.row,n=e.end.row-t;if(n!==0)if(e.action=="remove")this.$annotations.splice(t,n+1,null);else{var r=new Array(n+1);r.unshift(t,1),this.$annotations.splice.apply(this.$annotations,r)}},this.update=function(e){var t=this.session,n=e.firstRow,i=Math.min(e.lastRow+e.gutterOffset,t.getLength()-1),s=t.getNextFoldLine(n),o=s?s.start.row:Infinity,u=this.$showFoldWidgets&&t.foldWidgets,a=t.$breakpoints,f=t.$decorations,l=t.$firstLineNumber,c=0,h=t.gutterRenderer||this.$renderer,p=null,d=-1,v=n;for(;;){v>o&&(v=s.end.row+1,s=t.getNextFoldLine(v,s),o=s?s.start.row:Infinity);if(v>i){while(this.$cells.length>d+1)p=this.$cells.pop(),this.element.removeChild(p.element);break}p=this.$cells[++d],p||(p={element:null,textNode:null,foldWidget:null},p.element=r.createElement("div"),p.textNode=document.createTextNode(""),p.element.appendChild(p.textNode),this.element.appendChild(p.element),this.$cells[d]=p);var m="ace_gutter-cell ";a[v]&&(m+=a[v]),f[v]&&(m+=f[v]),this.$annotations[v]&&(m+=this.$annotations[v].className),p.element.className!=m&&(p.element.className=m);var g=t.getRowLength(v)*e.lineHeight+"px";g!=p.element.style.height&&(p.element.style.height=g);if(u){var y=u[v];y==null&&(y=u[v]=t.getFoldWidget(v))}if(y){p.foldWidget||(p.foldWidget=r.createElement("span"),p.element.appendChild(p.foldWidget));var m="ace_fold-widget ace_"+y;y=="start"&&v==o&&v<s.end.row?m+=" ace_closed":m+=" ace_open",p.foldWidget.className!=m&&(p.foldWidget.className=m);var g=e.lineHeight+"px";p.foldWidget.style.height!=g&&(p.foldWidget.style.height=g)}else p.foldWidget&&(p.element.removeChild(p.foldWidget),p.foldWidget=null);var b=c=h?h.getText(t,v):v+l;b!=p.textNode.data&&(p.textNode.data=b),v++}this.element.style.height=e.minHeight+"px";if(this.$fixedWidth||t.$useWrapMode)c=t.getLength()+l;var w=h?h.getWidth(t,c,e):c.toString().length*e.characterWidth,E=this.$padding||this.$computePadding();w+=E.left+E.right,w!==this.gutterWidth&&!isNaN(w)&&(this.gutterWidth=w,this.element.style.width=Math.ceil(this.gutterWidth)+"px",this._emit("changeGutterWidth",w))},this.$fixedWidth=!1,this.$showLineNumbers=!0,this.$renderer="",this.setShowLineNumbers=function(e){this.$renderer=!e&&{getWidth:function(){return""},getText:function(){return""}}},this.getShowLineNumbers=function(){return this.$showLineNumbers},this.$showFoldWidgets=!0,this.setShowFoldWidgets=function(e){e?r.addCssClass(this.element,"ace_folding-enabled"):r.removeCssClass(this.element,"ace_folding-enabled"),this.$showFoldWidgets=e,this.$padding=null},this.getShowFoldWidgets=function(){return this.$showFoldWidgets},this.$computePadding=function(){if(!this.element.firstChild)return{left:0,right:0};var e=r.computedStyle(this.element.firstChild);return this.$padding={},this.$padding.left=parseInt(e.paddingLeft)+1||0,this.$padding.right=parseInt(e.paddingRight)||0,this.$padding},this.getRegion=function(e){var t=this.$padding||this.$computePadding(),n=this.element.getBoundingClientRect();if(e.x<t.left+n.left)return"markers";if(this.$showFoldWidgets&&e.x>n.right-t.right)return"foldWidgets"}}).call(u.prototype),t.Gutter=u}),ace.define("ace/layer/marker",["require","exports","module","ace/range","ace/lib/dom"],function(e,t,n){"use strict";var r=e("../range").Range,i=e("../lib/dom"),s=function(e){this.element=i.createElement("div"),this.element.className="ace_layer ace_marker-layer",e.appendChild(this.element)};(function(){function e(e,t,n,r){return(e?1:0)|(t?2:0)|(n?4:0)|(r?8:0)}this.$padding=0,this.setPadding=function(e){this.$padding=e},this.setSession=function(e){this.session=e},this.setMarkers=function(e){this.markers=e},this.update=function(e){var e=e||this.config;if(!e)return;this.config=e;var t=[];for(var n in this.markers){var r=this.markers[n];if(!r.range){r.update(t,this,this.session,e);continue}var i=r.range.clipRows(e.firstRow,e.lastRow);if(i.isEmpty())continue;i=i.toScreenRange(this.session);if(r.renderer){var s=this.$getTop(i.start.row,e),o=this.$padding+i.start.column*e.characterWidth;r.renderer(t,i,o,s,e)}else r.type=="fullLine"?this.drawFullLineMarker(t,i,r.clazz,e):r.type=="screenLine"?this.drawScreenLineMarker(t,i,r.clazz,e):i.isMultiLine()?r.type=="text"?this.drawTextMarker(t,i,r.clazz,e):this.drawMultiLineMarker(t,i,r.clazz,e):this.drawSingleLineMarker(t,i,r.clazz+" ace_start"+" ace_br15",e)}this.element.innerHTML=t.join("")},this.$getTop=function(e,t){return(e-t.firstRowScreen)*t.lineHeight},this.drawTextMarker=function(t,n,i,s,o){var u=this.session,a=n.start.row,f=n.end.row,l=a,c=0,h=0,p=u.getScreenLastRowColumn(l),d=new r(l,n.start.column,l,h);for(;l<=f;l++)d.start.row=d.end.row=l,d.start.column=l==a?n.start.column:u.getRowWrapIndent(l),d.end.column=p,c=h,h=p,p=l+1<f?u.getScreenLastRowColumn(l+1):l==f?0:n.end.column,this.drawSingleLineMarker(t,d,i+(l==a?" ace_start":"")+" ace_br"+e(l==a||l==a+1&&n.start.column,c<h,h>p,l==f),s,l==f?0:1,o)},this.drawMultiLineMarker=function(e,t,n,r,i){var s=this.$padding,o=r.lineHeight,u=this.$getTop(t.start.row,r),a=s+t.start.column*r.characterWidth;i=i||"",e.push("<div class='",n," ace_br1 ace_start' style='","height:",o,"px;","right:0;","top:",u,"px;","left:",a,"px;",i,"'></div>"),u=this.$getTop(t.end.row,r);var f=t.end.column*r.characterWidth;e.push("<div class='",n," ace_br12' style='","height:",o,"px;","width:",f,"px;","top:",u,"px;","left:",s,"px;",i,"'></div>"),o=(t.end.row-t.start.row-1)*r.lineHeight;if(o<=0)return;u=this.$getTop(t.start.row+1,r);var l=(t.start.column?1:0)|(t.end.column?0:8);e.push("<div class='",n,l?" ace_br"+l:"","' style='","height:",o,"px;","right:0;","top:",u,"px;","left:",s,"px;",i,"'></div>")},this.drawSingleLineMarker=function(e,t,n,r,i,s){var o=r.lineHeight,u=(t.end.column+(i||0)-t.start.column)*r.characterWidth,a=this.$getTop(t.start.row,r),f=this.$padding+t.start.column*r.characterWidth;e.push("<div class='",n,"' style='","height:",o,"px;","width:",u,"px;","top:",a,"px;","left:",f,"px;",s||"","'></div>")},this.drawFullLineMarker=function(e,t,n,r,i){var s=this.$getTop(t.start.row,r),o=r.lineHeight;t.start.row!=t.end.row&&(o+=this.$getTop(t.end.row,r)-s),e.push("<div class='",n,"' style='","height:",o,"px;","top:",s,"px;","left:0;right:0;",i||"","'></div>")},this.drawScreenLineMarker=function(e,t,n,r,i){var s=this.$getTop(t.start.row,r),o=r.lineHeight;e.push("<div class='",n,"' style='","height:",o,"px;","top:",s,"px;","left:0;right:0;",i||"","'></div>")}}).call(s.prototype),t.Marker=s}),ace.define("ace/layer/text",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("../lib/dom"),s=e("../lib/lang"),o=e("../lib/useragent"),u=e("../lib/event_emitter").EventEmitter,a=function(e){this.element=i.createElement("div"),this.element.className="ace_layer ace_text-layer",e.appendChild(this.element),this.$updateEolChar=this.$updateEolChar.bind(this)};(function(){r.implement(this,u),this.EOF_CHAR="\u00b6",this.EOL_CHAR_LF="\u00ac",this.EOL_CHAR_CRLF="\u00a4",this.EOL_CHAR=this.EOL_CHAR_LF,this.TAB_CHAR="\u2014",this.SPACE_CHAR="\u00b7",this.$padding=0,this.$updateEolChar=function(){var e=this.session.doc.getNewLineCharacter()=="\n"?this.EOL_CHAR_LF:this.EOL_CHAR_CRLF;if(this.EOL_CHAR!=e)return this.EOL_CHAR=e,!0},this.setPadding=function(e){this.$padding=e,this.element.style.padding="0 "+e+"px"},this.getLineHeight=function(){return this.$fontMetrics.$characterSize.height||0},this.getCharacterWidth=function(){return this.$fontMetrics.$characterSize.width||0},this.$setFontMetrics=function(e){this.$fontMetrics=e,this.$fontMetrics.on("changeCharacterSize",function(e){this._signal("changeCharacterSize",e)}.bind(this)),this.$pollSizeChanges()},this.checkForSizeChanges=function(){this.$fontMetrics.checkForSizeChanges()},this.$pollSizeChanges=function(){return this.$pollSizeChangesTimer=this.$fontMetrics.$pollSizeChanges()},this.setSession=function(e){this.session=e,e&&this.$computeTabString()},this.showInvisibles=!1,this.setShowInvisibles=function(e){return this.showInvisibles==e?!1:(this.showInvisibles=e,this.$computeTabString(),!0)},this.displayIndentGuides=!0,this.setDisplayIndentGuides=function(e){return this.displayIndentGuides==e?!1:(this.displayIndentGuides=e,this.$computeTabString(),!0)},this.$tabStrings=[],this.onChangeTabSize=this.$computeTabString=function(){var e=this.session.getTabSize();this.tabSize=e;var t=this.$tabStrings=[0];for(var n=1;n<e+1;n++)this.showInvisibles?t.push("<span class='ace_invisible ace_invisible_tab'>"+s.stringRepeat(this.TAB_CHAR,n)+"</span>"):t.push(s.stringRepeat(" ",n));if(this.displayIndentGuides){this.$indentGuideRe=/\s\S| \t|\t |\s$/;var r="ace_indent-guide",i="",o="";if(this.showInvisibles){r+=" ace_invisible",i=" ace_invisible_space",o=" ace_invisible_tab";var u=s.stringRepeat(this.SPACE_CHAR,this.tabSize),a=s.stringRepeat(this.TAB_CHAR,this.tabSize)}else var u=s.stringRepeat(" ",this.tabSize),a=u;this.$tabStrings[" "]="<span class='"+r+i+"'>"+u+"</span>",this.$tabStrings[" "]="<span class='"+r+o+"'>"+a+"</span>"}},this.updateLines=function(e,t,n){(this.config.lastRow!=e.lastRow||this.config.firstRow!=e.firstRow)&&this.scrollLines(e),this.config=e;var r=Math.max(t,e.firstRow),i=Math.min(n,e.lastRow),s=this.element.childNodes,o=0;for(var u=e.firstRow;u<r;u++){var a=this.session.getFoldLine(u);if(a){if(a.containsRow(r)){r=a.start.row;break}u=a.end.row}o++}var u=r,a=this.session.getNextFoldLine(u),f=a?a.start.row:Infinity;for(;;){u>f&&(u=a.end.row+1,a=this.session.getNextFoldLine(u,a),f=a?a.start.row:Infinity);if(u>i)break;var l=s[o++];if(l){var c=[];this.$renderLine(c,u,!this.$useLineGroups(),u==f?a:!1),l.style.height=e.lineHeight*this.session.getRowLength(u)+"px",l.innerHTML=c.join("")}u++}},this.scrollLines=function(e){var t=this.config;this.config=e;if(!t||t.lastRow<e.firstRow)return this.update(e);if(e.lastRow<t.firstRow)return this.update(e);var n=this.element;if(t.firstRow<e.firstRow)for(var r=this.session.getFoldedRowCount(t.firstRow,e.firstRow-1);r>0;r--)n.removeChild(n.firstChild);if(t.lastRow>e.lastRow)for(var r=this.session.getFoldedRowCount(e.lastRow+1,t.lastRow);r>0;r--)n.removeChild(n.lastChild);if(e.firstRow<t.firstRow){var i=this.$renderLinesFragment(e,e.firstRow,t.firstRow-1);n.firstChild?n.insertBefore(i,n.firstChild):n.appendChild(i)}if(e.lastRow>t.lastRow){var i=this.$renderLinesFragment(e,t.lastRow+1,e.lastRow);n.appendChild(i)}},this.$renderLinesFragment=function(e,t,n){var r=this.element.ownerDocument.createDocumentFragment(),s=t,o=this.session.getNextFoldLine(s),u=o?o.start.row:Infinity;for(;;){s>u&&(s=o.end.row+1,o=this.session.getNextFoldLine(s,o),u=o?o.start.row:Infinity);if(s>n)break;var a=i.createElement("div"),f=[];this.$renderLine(f,s,!1,s==u?o:!1),a.innerHTML=f.join("");if(this.$useLineGroups())a.className="ace_line_group",r.appendChild(a),a.style.height=e.lineHeight*this.session.getRowLength(s)+"px";else while(a.firstChild)r.appendChild(a.firstChild);s++}return r},this.update=function(e){this.config=e;var t=[],n=e.firstRow,r=e.lastRow,i=n,s=this.session.getNextFoldLine(i),o=s?s.start.row:Infinity;for(;;){i>o&&(i=s.end.row+1,s=this.session.getNextFoldLine(i,s),o=s?s.start.row:Infinity);if(i>r)break;this.$useLineGroups()&&t.push("<div class='ace_line_group' style='height:",e.lineHeight*this.session.getRowLength(i),"px'>"),this.$renderLine(t,i,!1,i==o?s:!1),this.$useLineGroups()&&t.push("</div>"),i++}this.element.innerHTML=t.join("")},this.$textToken={text:!0,rparen:!0,lparen:!0},this.$renderToken=function(e,t,n,r){var i=this,o=/\t|&|<|>|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF\uFFF9-\uFFFC])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g,u=function(e,n,r,o,u){if(n)return i.showInvisibles?"<span class='ace_invisible ace_invisible_space'>"+s.stringRepeat(i.SPACE_CHAR,e.length)+"</span>":e;if(e=="&")return"&";if(e=="<")return"<";if(e==">")return">";if(e==" "){var a=i.session.getScreenTabSize(t+o);return t+=a-1,i.$tabStrings[a]}if(e=="\u3000"){var f=i.showInvisibles?"ace_cjk ace_invisible ace_invisible_space":"ace_cjk",l=i.showInvisibles?i.SPACE_CHAR:"";return t+=1,"<span class='"+f+"' style='width:"+i.config.characterWidth*2+"px'>"+l+"</span>"}return r?"<span class='ace_invisible ace_invisible_space ace_invalid'>"+i.SPACE_CHAR+"</span>":(t+=1,"<span class='ace_cjk' style='width:"+i.config.characterWidth*2+"px'>"+e+"</span>")},a=r.replace(o,u);if(!this.$textToken[n.type]){var f="ace_"+n.type.replace(/\./g," ace_"),l="";n.type=="fold"&&(l=" style='width:"+n.value.length*this.config.characterWidth+"px;' "),e.push("<span class='",f,"'",l,">",a,"</span>")}else e.push(a);return t+r.length},this.renderIndentGuide=function(e,t,n){var r=t.search(this.$indentGuideRe);return r<=0||r>=n?t:t[0]==" "?(r-=r%this.tabSize,e.push(s.stringRepeat(this.$tabStrings[" "],r/this.tabSize)),t.substr(r)):t[0]==" "?(e.push(s.stringRepeat(this.$tabStrings[" "],r)),t.substr(r)):t},this.$renderWrappedLine=function(e,t,n,r){var i=0,o=0,u=n[0],a=0;for(var f=0;f<t.length;f++){var l=t[f],c=l.value;if(f==0&&this.displayIndentGuides){i=c.length,c=this.renderIndentGuide(e,c,u);if(!c)continue;i-=c.length}if(i+c.length<u)a=this.$renderToken(e,a,l,c),i+=c.length;else{while(i+c.length>=u)a=this.$renderToken(e,a,l,c.substring(0,u-i)),c=c.substring(u-i),i=u,r||e.push("</div>","<div class='ace_line' style='height:",this.config.lineHeight,"px'>"),e.push(s.stringRepeat("\u00a0",n.indent)),o++,a=0,u=n[o]||Number.MAX_VALUE;c.length!=0&&(i+=c.length,a=this.$renderToken(e,a,l,c))}}},this.$renderSimpleLine=function(e,t){var n=0,r=t[0],i=r.value;this.displayIndentGuides&&(i=this.renderIndentGuide(e,i)),i&&(n=this.$renderToken(e,n,r,i));for(var s=1;s<t.length;s++)r=t[s],i=r.value,n=this.$renderToken(e,n,r,i)},this.$renderLine=function(e,t,n,r){!r&&r!=0&&(r=this.session.getFoldLine(t));if(r)var i=this.$getFoldLineTokens(t,r);else var i=this.session.getTokens(t);n||e.push("<div class='ace_line' style='height:",this.config.lineHeight*(this.$useLineGroups()?1:this.session.getRowLength(t)),"px'>");if(i.length){var s=this.session.getRowSplitData(t);s&&s.length?this.$renderWrappedLine(e,i,s,n):this.$renderSimpleLine(e,i)}this.showInvisibles&&(r&&(t=r.end.row),e.push("<span class='ace_invisible ace_invisible_eol'>",t==this.session.getLength()-1?this.EOF_CHAR:this.EOL_CHAR,"</span>")),n||e.push("</div>")},this.$getFoldLineTokens=function(e,t){function i(e,t,n){var i=0,s=0;while(s+e[i].value.length<t){s+=e[i].value.length,i++;if(i==e.length)return}if(s!=t){var o=e[i].value.substring(t-s);o.length>n-t&&(o=o.substring(0,n-t)),r.push({type:e[i].type,value:o}),s=t+o.length,i+=1}while(s<n&&i<e.length){var o=e[i].value;o.length+s>n?r.push({type:e[i].type,value:o.substring(0,n-s)}):r.push(e[i]),s+=o.length,i+=1}}var n=this.session,r=[],s=n.getTokens(e);return t.walk(function(e,t,o,u,a){e!=null?r.push({type:"fold",value:e}):(a&&(s=n.getTokens(t)),s.length&&i(s,u,o))},t.end.row,this.session.getLine(t.end.row).length),r},this.$useLineGroups=function(){return this.session.getUseWrapMode()},this.destroy=function(){clearInterval(this.$pollSizeChangesTimer),this.$measureNode&&this.$measureNode.parentNode.removeChild(this.$measureNode),delete this.$measureNode}}).call(a.prototype),t.Text=a}),ace.define("ace/layer/cursor",["require","exports","module","ace/lib/dom"],function(e,t,n){"use strict";var r=e("../lib/dom"),i,s=function(e){this.element=r.createElement("div"),this.element.className="ace_layer ace_cursor-layer",e.appendChild(this.element),i===undefined&&(i=!("opacity"in this.element.style)),this.isVisible=!1,this.isBlinking=!0,this.blinkInterval=1e3,this.smoothBlinking=!1,this.cursors=[],this.cursor=this.addCursor(),r.addCssClass(this.element,"ace_hidden-cursors"),this.$updateCursors=(i?this.$updateVisibility:this.$updateOpacity).bind(this)};(function(){this.$updateVisibility=function(e){var t=this.cursors;for(var n=t.length;n--;)t[n].style.visibility=e?"":"hidden"},this.$updateOpacity=function(e){var t=this.cursors;for(var n=t.length;n--;)t[n].style.opacity=e?"":"0"},this.$padding=0,this.setPadding=function(e){this.$padding=e},this.setSession=function(e){this.session=e},this.setBlinking=function(e){e!=this.isBlinking&&(this.isBlinking=e,this.restartTimer())},this.setBlinkInterval=function(e){e!=this.blinkInterval&&(this.blinkInterval=e,this.restartTimer())},this.setSmoothBlinking=function(e){e!=this.smoothBlinking&&!i&&(this.smoothBlinking=e,r.setCssClass(this.element,"ace_smooth-blinking",e),this.$updateCursors(!0),this.$updateCursors=this.$updateOpacity.bind(this),this.restartTimer())},this.addCursor=function(){var e=r.createElement("div");return e.className="ace_cursor",this.element.appendChild(e),this.cursors.push(e),e},this.removeCursor=function(){if(this.cursors.length>1){var e=this.cursors.pop();return e.parentNode.removeChild(e),e}},this.hideCursor=function(){this.isVisible=!1,r.addCssClass(this.element,"ace_hidden-cursors"),this.restartTimer()},this.showCursor=function(){this.isVisible=!0,r.removeCssClass(this.element,"ace_hidden-cursors"),this.restartTimer()},this.restartTimer=function(){var e=this.$updateCursors;clearInterval(this.intervalId),clearTimeout(this.timeoutId),this.smoothBlinking&&r.removeCssClass(this.element,"ace_smooth-blinking"),e(!0);if(!this.isBlinking||!this.blinkInterval||!this.isVisible)return;this.smoothBlinking&&setTimeout(function(){r.addCssClass(this.element,"ace_smooth-blinking")}.bind(this));var t=function(){this.timeoutId=setTimeout(function(){e(!1)},.6*this.blinkInterval)}.bind(this);this.intervalId=setInterval(function(){e(!0),t()},this.blinkInterval),t()},this.getPixelPosition=function(e,t){if(!this.config||!this.session)return{left:0,top:0};e||(e=this.session.selection.getCursor());var n=this.session.documentToScreenPosition(e),r=this.$padding+n.column*this.config.characterWidth,i=(n.row-(t?this.config.firstRowScreen:0))*this.config.lineHeight;return{left:r,top:i}},this.update=function(e){this.config=e;var t=this.session.$selectionMarkers,n=0,r=0;if(t===undefined||t.length===0)t=[{cursor:null}];for(var n=0,i=t.length;n<i;n++){var s=this.getPixelPosition(t[n].cursor,!0);if((s.top>e.height+e.offset||s.top<0)&&n>1)continue;var o=(this.cursors[r++]||this.addCursor()).style;this.drawCursor?this.drawCursor(o,s,e,t[n],this.session):(o.left=s.left+"px",o.top=s.top+"px",o.width=e.characterWidth+"px",o.height=e.lineHeight+"px")}while(this.cursors.length>r)this.removeCursor();var u=this.session.getOverwrite();this.$setOverwrite(u),this.$pixelPos=s,this.restartTimer()},this.drawCursor=null,this.$setOverwrite=function(e){e!=this.overwrite&&(this.overwrite=e,e?r.addCssClass(this.element,"ace_overwrite-cursors"):r.removeCssClass(this.element,"ace_overwrite-cursors"))},this.destroy=function(){clearInterval(this.intervalId),clearTimeout(this.timeoutId)}}).call(s.prototype),t.Cursor=s}),ace.define("ace/scrollbar",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/dom"),s=e("./lib/event"),o=e("./lib/event_emitter").EventEmitter,u=32768,a=function(e){this.element=i.createElement("div"),this.element.className="ace_scrollbar ace_scrollbar"+this.classSuffix,this.inner=i.createElement("div"),this.inner.className="ace_scrollbar-inner",this.element.appendChild(this.inner),e.appendChild(this.element),this.setVisible(!1),this.skipEvent=!1,s.addListener(this.element,"scroll",this.onScroll.bind(this)),s.addListener(this.element,"mousedown",s.preventDefault)};(function(){r.implement(this,o),this.setVisible=function(e){this.element.style.display=e?"":"none",this.isVisible=e,this.coeff=1}}).call(a.prototype);var f=function(e,t){a.call(this,e),this.scrollTop=0,this.scrollHeight=0,t.$scrollbarWidth=this.width=i.scrollbarWidth(e.ownerDocument),this.inner.style.width=this.element.style.width=(this.width||15)+5+"px"};r.inherits(f,a),function(){this.classSuffix="-v",this.onScroll=function(){if(!this.skipEvent){this.scrollTop=this.element.scrollTop;if(this.coeff!=1){var e=this.element.clientHeight/this.scrollHeight;this.scrollTop=this.scrollTop*(1-e)/(this.coeff-e)}this._emit("scroll",{data:this.scrollTop})}this.skipEvent=!1},this.getWidth=function(){return this.isVisible?this.width:0},this.setHeight=function(e){this.element.style.height=e+"px"},this.setInnerHeight=this.setScrollHeight=function(e){this.scrollHeight=e,e>u?(this.coeff=u/e,e=u):this.coeff!=1&&(this.coeff=1),this.inner.style.height=e+"px"},this.setScrollTop=function(e){this.scrollTop!=e&&(this.skipEvent=!0,this.scrollTop=e,this.element.scrollTop=e*this.coeff)}}.call(f.prototype);var l=function(e,t){a.call(this,e),this.scrollLeft=0,this.height=t.$scrollbarWidth,this.inner.style.height=this.element.style.height=(this.height||15)+5+"px"};r.inherits(l,a),function(){this.classSuffix="-h",this.onScroll=function(){this.skipEvent||(this.scrollLeft=this.element.scrollLeft,this._emit("scroll",{data:this.scrollLeft})),this.skipEvent=!1},this.getHeight=function(){return this.isVisible?this.height:0},this.setWidth=function(e){this.element.style.width=e+"px"},this.setInnerWidth=function(e){this.inner.style.width=e+"px"},this.setScrollWidth=function(e){this.inner.style.width=e+"px"},this.setScrollLeft=function(e){this.scrollLeft!=e&&(this.skipEvent=!0,this.scrollLeft=this.element.scrollLeft=e)}}.call(l.prototype),t.ScrollBar=f,t.ScrollBarV=f,t.ScrollBarH=l,t.VScrollBar=f,t.HScrollBar=l}),ace.define("ace/renderloop",["require","exports","module","ace/lib/event"],function(e,t,n){"use strict";var r=e("./lib/event"),i=function(e,t){this.onRender=e,this.pending=!1,this.changes=0,this.window=t||window};(function(){this.schedule=function(e){this.changes=this.changes|e;if(!this.pending&&this.changes){this.pending=!0;var t=this;r.nextFrame(function(){t.pending=!1;var e;while(e=t.changes)t.changes=0,t.onRender(e)},this.window)}}}).call(i.prototype),t.RenderLoop=i}),ace.define("ace/layer/font_metrics",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/lib/event_emitter"],function(e,t,n){var r=e("../lib/oop"),i=e("../lib/dom"),s=e("../lib/lang"),o=e("../lib/useragent"),u=e("../lib/event_emitter").EventEmitter,a=0,f=t.FontMetrics=function(e){this.el=i.createElement("div"),this.$setMeasureNodeStyles(this.el.style,!0),this.$main=i.createElement("div"),this.$setMeasureNodeStyles(this.$main.style),this.$measureNode=i.createElement("div"),this.$setMeasureNodeStyles(this.$measureNode.style),this.el.appendChild(this.$main),this.el.appendChild(this.$measureNode),e.appendChild(this.el),a||this.$testFractionalRect(),this.$measureNode.innerHTML=s.stringRepeat("X",a),this.$characterSize={width:0,height:0},this.checkForSizeChanges()};(function(){r.implement(this,u),this.$characterSize={width:0,height:0},this.$testFractionalRect=function(){var e=i.createElement("div");this.$setMeasureNodeStyles(e.style),e.style.width="0.2px",document.documentElement.appendChild(e);var t=e.getBoundingClientRect().width;t>0&&t<1?a=50:a=100,e.parentNode.removeChild(e)},this.$setMeasureNodeStyles=function(e,t){e.width=e.height="auto",e.left=e.top="0px",e.visibility="hidden",e.position="absolute",e.whiteSpace="pre",o.isIE<8?e["font-family"]="inherit":e.font="inherit",e.overflow=t?"hidden":"visible"},this.checkForSizeChanges=function(){var e=this.$measureSizes();if(e&&(this.$characterSize.width!==e.width||this.$characterSize.height!==e.height)){this.$measureNode.style.fontWeight="bold";var t=this.$measureSizes();this.$measureNode.style.fontWeight="",this.$characterSize=e,this.charSizes=Object.create(null),this.allowBoldFonts=t&&t.width===e.width&&t.height===e.height,this._emit("changeCharacterSize",{data:e})}},this.$pollSizeChanges=function(){if(this.$pollSizeChangesTimer)return this.$pollSizeChangesTimer;var e=this;return this.$pollSizeChangesTimer=setInterval(function(){e.checkForSizeChanges()},500)},this.setPolling=function(e){e?this.$pollSizeChanges():this.$pollSizeChangesTimer&&(clearInterval(this.$pollSizeChangesTimer),this.$pollSizeChangesTimer=0)},this.$measureSizes=function(){if(a===50){var e=null;try{e=this.$measureNode.getBoundingClientRect()}catch(t){e={width:0,height:0}}var n={height:e.height,width:e.width/a}}else var n={height:this.$measureNode.clientHeight,width:this.$measureNode.clientWidth/a};return n.width===0||n.height===0?null:n},this.$measureCharWidth=function(e){this.$main.innerHTML=s.stringRepeat(e,a);var t=this.$main.getBoundingClientRect();return t.width/a},this.getCharacterWidth=function(e){var t=this.charSizes[e];return t===undefined&&(t=this.charSizes[e]=this.$measureCharWidth(e)/this.$characterSize.width),t},this.destroy=function(){clearInterval(this.$pollSizeChangesTimer),this.el&&this.el.parentNode&&this.el.parentNode.removeChild(this.el)}}).call(f.prototype)}),ace.define("ace/virtual_renderer",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/config","ace/lib/useragent","ace/layer/gutter","ace/layer/marker","ace/layer/text","ace/layer/cursor","ace/scrollbar","ace/scrollbar","ace/renderloop","ace/layer/font_metrics","ace/lib/event_emitter"],function(e,t,n){"use strict";var r=e("./lib/oop"),i=e("./lib/dom"),s=e("./config"),o=e("./lib/useragent"),u=e("./layer/gutter").Gutter,a=e("./layer/marker").Marker,f=e("./layer/text").Text,l=e("./layer/cursor").Cursor,c=e("./scrollbar").HScrollBar,h=e("./scrollbar").VScrollBar,p=e("./renderloop").RenderLoop,d=e("./layer/font_metrics").FontMetrics,v=e("./lib/event_emitter").EventEmitter,m='.ace_editor {position: relative;overflow: hidden;font: 12px/normal \'Monaco\', \'Menlo\', \'Ubuntu Mono\', \'Consolas\', \'source-code-pro\', monospace;direction: ltr;text-align: left;}.ace_scroller {position: absolute;overflow: hidden;top: 0;bottom: 0;background-color: inherit;-ms-user-select: none;-moz-user-select: none;-webkit-user-select: none;user-select: none;cursor: text;}.ace_content {position: absolute;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;min-width: 100%;}.ace_dragging .ace_scroller:before{position: absolute;top: 0;left: 0;right: 0;bottom: 0;content: \'\';background: rgba(250, 250, 250, 0.01);z-index: 1000;}.ace_dragging.ace_dark .ace_scroller:before{background: rgba(0, 0, 0, 0.01);}.ace_selecting, .ace_selecting * {cursor: text !important;}.ace_gutter {position: absolute;overflow : hidden;width: auto;top: 0;bottom: 0;left: 0;cursor: default;z-index: 4;-ms-user-select: none;-moz-user-select: none;-webkit-user-select: none;user-select: none;}.ace_gutter-active-line {position: absolute;left: 0;right: 0;}.ace_scroller.ace_scroll-left {box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;}.ace_gutter-cell {padding-left: 19px;padding-right: 6px;background-repeat: no-repeat;}.ace_gutter-cell.ace_error {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAABOFBMVEX/////////QRswFAb/Ui4wFAYwFAYwFAaWGAfDRymzOSH/PxswFAb/SiUwFAYwFAbUPRvjQiDllog5HhHdRybsTi3/Tyv9Tir+Syj/UC3////XurebMBIwFAb/RSHbPx/gUzfdwL3kzMivKBAwFAbbvbnhPx66NhowFAYwFAaZJg8wFAaxKBDZurf/RB6mMxb/SCMwFAYwFAbxQB3+RB4wFAb/Qhy4Oh+4QifbNRcwFAYwFAYwFAb/QRzdNhgwFAYwFAbav7v/Uy7oaE68MBK5LxLewr/r2NXewLswFAaxJw4wFAbkPRy2PyYwFAaxKhLm1tMwFAazPiQwFAaUGAb/QBrfOx3bvrv/VC/maE4wFAbRPBq6MRO8Qynew8Dp2tjfwb0wFAbx6eju5+by6uns4uH9/f36+vr/GkHjAAAAYnRSTlMAGt+64rnWu/bo8eAA4InH3+DwoN7j4eLi4xP99Nfg4+b+/u9B/eDs1MD1mO7+4PHg2MXa347g7vDizMLN4eG+Pv7i5evs/v79yu7S3/DV7/498Yv24eH+4ufQ3Ozu/v7+y13sRqwAAADLSURBVHjaZc/XDsFgGIBhtDrshlitmk2IrbHFqL2pvXf/+78DPokj7+Fz9qpU/9UXJIlhmPaTaQ6QPaz0mm+5gwkgovcV6GZzd5JtCQwgsxoHOvJO15kleRLAnMgHFIESUEPmawB9ngmelTtipwwfASilxOLyiV5UVUyVAfbG0cCPHig+GBkzAENHS0AstVF6bacZIOzgLmxsHbt2OecNgJC83JERmePUYq8ARGkJx6XtFsdddBQgZE2nPR6CICZhawjA4Fb/chv+399kfR+MMMDGOQAAAABJRU5ErkJggg==");background-repeat: no-repeat;background-position: 2px center;}.ace_gutter-cell.ace_warning {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAmVBMVEX///8AAAD///8AAAAAAABPSzb/5sAAAAB/blH/73z/ulkAAAAAAAD85pkAAAAAAAACAgP/vGz/rkDerGbGrV7/pkQICAf////e0IsAAAD/oED/qTvhrnUAAAD/yHD/njcAAADuv2r/nz//oTj/p064oGf/zHAAAAA9Nir/tFIAAAD/tlTiuWf/tkIAAACynXEAAAAAAAAtIRW7zBpBAAAAM3RSTlMAABR1m7RXO8Ln31Z36zT+neXe5OzooRDfn+TZ4p3h2hTf4t3k3ucyrN1K5+Xaks52Sfs9CXgrAAAAjklEQVR42o3PbQ+CIBQFYEwboPhSYgoYunIqqLn6/z8uYdH8Vmdnu9vz4WwXgN/xTPRD2+sgOcZjsge/whXZgUaYYvT8QnuJaUrjrHUQreGczuEafQCO/SJTufTbroWsPgsllVhq3wJEk2jUSzX3CUEDJC84707djRc5MTAQxoLgupWRwW6UB5fS++NV8AbOZgnsC7BpEAAAAABJRU5ErkJggg==");background-position: 2px center;}.ace_gutter-cell.ace_info {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=");background-position: 2px center;}.ace_dark .ace_gutter-cell.ace_info {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC");}.ace_scrollbar {position: absolute;right: 0;bottom: 0;z-index: 6;}.ace_scrollbar-inner {position: absolute;cursor: text;left: 0;top: 0;}.ace_scrollbar-v{overflow-x: hidden;overflow-y: scroll;top: 0;}.ace_scrollbar-h {overflow-x: scroll;overflow-y: hidden;left: 0;}.ace_print-margin {position: absolute;height: 100%;}.ace_text-input {position: absolute;z-index: 0;width: 0.5em;height: 1em;opacity: 0;background: transparent;-moz-appearance: none;appearance: none;border: none;resize: none;outline: none;overflow: hidden;font: inherit;padding: 0 1px;margin: 0 -1px;text-indent: -1em;-ms-user-select: text;-moz-user-select: text;-webkit-user-select: text;user-select: text;white-space: pre!important;}.ace_text-input.ace_composition {background: inherit;color: inherit;z-index: 1000;opacity: 1;text-indent: 0;}.ace_layer {z-index: 1;position: absolute;overflow: hidden;word-wrap: normal;white-space: pre;height: 100%;width: 100%;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;pointer-events: none;}.ace_gutter-layer {position: relative;width: auto;text-align: right;pointer-events: auto;}.ace_text-layer {font: inherit !important;}.ace_cjk {display: inline-block;text-align: center;}.ace_cursor-layer {z-index: 4;}.ace_cursor {z-index: 4;position: absolute;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;border-left: 2px solid;transform: translatez(0);}.ace_slim-cursors .ace_cursor {border-left-width: 1px;}.ace_overwrite-cursors .ace_cursor {border-left-width: 0;border-bottom: 1px solid;}.ace_hidden-cursors .ace_cursor {opacity: 0.2;}.ace_smooth-blinking .ace_cursor {-webkit-transition: opacity 0.18s;transition: opacity 0.18s;}.ace_editor.ace_multiselect .ace_cursor {border-left-width: 1px;}.ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {position: absolute;z-index: 3;}.ace_marker-layer .ace_selection {position: absolute;z-index: 5;}.ace_marker-layer .ace_bracket {position: absolute;z-index: 6;}.ace_marker-layer .ace_active-line {position: absolute;z-index: 2;}.ace_marker-layer .ace_selected-word {position: absolute;z-index: 4;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;}.ace_line .ace_fold {-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;display: inline-block;height: 11px;margin-top: -2px;vertical-align: middle;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII="),url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=");background-repeat: no-repeat, repeat-x;background-position: center center, top left;color: transparent;border: 1px solid black;border-radius: 2px;cursor: pointer;pointer-events: auto;}.ace_dark .ace_fold {}.ace_fold:hover{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII="),url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC");}.ace_tooltip {background-color: #FFF;background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1));background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));border: 1px solid gray;border-radius: 1px;box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);color: black;max-width: 100%;padding: 3px 4px;position: fixed;z-index: 999999;-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;cursor: default;white-space: pre;word-wrap: break-word;line-height: normal;font-style: normal;font-weight: normal;letter-spacing: normal;pointer-events: none;}.ace_folding-enabled > .ace_gutter-cell {padding-right: 13px;}.ace_fold-widget {-moz-box-sizing: border-box;-webkit-box-sizing: border-box;box-sizing: border-box;margin: 0 -12px 0 1px;display: none;width: 11px;vertical-align: top;background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==");background-repeat: no-repeat;background-position: center;border-radius: 3px;border: 1px solid transparent;cursor: pointer;}.ace_folding-enabled .ace_fold-widget {display: inline-block; }.ace_fold-widget.ace_end {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==");}.ace_fold-widget.ace_closed {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==");}.ace_fold-widget:hover {border: 1px solid rgba(0, 0, 0, 0.3);background-color: rgba(255, 255, 255, 0.2);box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);}.ace_fold-widget:active {border: 1px solid rgba(0, 0, 0, 0.4);background-color: rgba(0, 0, 0, 0.05);box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);}.ace_dark .ace_fold-widget {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC");}.ace_dark .ace_fold-widget.ace_end {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==");}.ace_dark .ace_fold-widget.ace_closed {background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==");}.ace_dark .ace_fold-widget:hover {box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);background-color: rgba(255, 255, 255, 0.1);}.ace_dark .ace_fold-widget:active {box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);}.ace_fold-widget.ace_invalid {background-color: #FFB4B4;border-color: #DE5555;}.ace_fade-fold-widgets .ace_fold-widget {-webkit-transition: opacity 0.4s ease 0.05s;transition: opacity 0.4s ease 0.05s;opacity: 0;}.ace_fade-fold-widgets:hover .ace_fold-widget {-webkit-transition: opacity 0.05s ease 0.05s;transition: opacity 0.05s ease 0.05s;opacity:1;}.ace_underline {text-decoration: underline;}.ace_bold {font-weight: bold;}.ace_nobold .ace_bold {font-weight: normal;}.ace_italic {font-style: italic;}.ace_error-marker {background-color: rgba(255, 0, 0,0.2);position: absolute;z-index: 9;}.ace_highlight-marker {background-color: rgba(255, 255, 0,0.2);position: absolute;z-index: 8;}.ace_br1 {border-top-left-radius : 3px;}.ace_br2 {border-top-right-radius : 3px;}.ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}.ace_br4 {border-bottom-right-radius: 3px;}.ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}.ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}.ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}.ace_br8 {border-bottom-left-radius : 3px;}.ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}.ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}.ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}.ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}.ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}.ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}.ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}';i.importCssString(m,"ace_editor.css");var g=function(e,t){var n=this;this.container=e||i.createElement("div"),this.$keepTextAreaAtCursor=!o.isOldIE,i.addCssClass(this.container,"ace_editor"),this.setTheme(t),this.$gutter=i.createElement("div"),this.$gutter.className="ace_gutter",this.container.appendChild(this.$gutter),this.scroller=i.createElement("div"),this.scroller.className="ace_scroller",this.container.appendChild(this.scroller),this.content=i.createElement("div"),this.content.className="ace_content",this.scroller.appendChild(this.content),this.$gutterLayer=new u(this.$gutter),this.$gutterLayer.on("changeGutterWidth",this.onGutterResize.bind(this)),this.$markerBack=new a(this.content);var r=this.$textLayer=new f(this.content);this.canvas=r.element,this.$markerFront=new a(this.content),this.$cursorLayer=new l(this.content),this.$horizScroll=!1,this.$vScroll=!1,this.scrollBar=this.scrollBarV=new h(this.container,this),this.scrollBarH=new c(this.container,this),this.scrollBarV.addEventListener("scroll",function(e){n.$scrollAnimation||n.session.setScrollTop(e.data-n.scrollMargin.top)}),this.scrollBarH.addEventListener("scroll",function(e){n.$scrollAnimation||n.session.setScrollLeft(e.data-n.scrollMargin.left)}),this.scrollTop=0,this.scrollLeft=0,this.cursorPos={row:0,column:0},this.$fontMetrics=new d(this.container),this.$textLayer.$setFontMetrics(this.$fontMetrics),this.$textLayer.addEventListener("changeCharacterSize",function(e){n.updateCharacterSize(),n.onResize(!0,n.gutterWidth,n.$size.width,n.$size.height),n._signal("changeCharacterSize",e)}),this.$size={width:0,height:0,scrollerHeight:0,scrollerWidth:0,$dirty:!0},this.layerConfig={width:1,padding:0,firstRow:0,firstRowScreen:0,lastRow:0,lineHeight:0,characterWidth:0,minHeight:1,maxHeight:1,offset:0,height:1,gutterOffset:1},this.scrollMargin={left:0,right:0,top:0,bottom:0,v:0,h:0},this.$loop=new p(this.$renderChanges.bind(this),this.container.ownerDocument.defaultView),this.$loop.schedule(this.CHANGE_FULL),this.updateCharacterSize(),this.setPadding(4),s.resetOptions(this),s._emit("renderer",this)};(function(){this.CHANGE_CURSOR=1,this.CHANGE_MARKER=2,this.CHANGE_GUTTER=4,this.CHANGE_SCROLL=8,this.CHANGE_LINES=16,this.CHANGE_TEXT=32,this.CHANGE_SIZE=64,this.CHANGE_MARKER_BACK=128,this.CHANGE_MARKER_FRONT=256,this.CHANGE_FULL=512,this.CHANGE_H_SCROLL=1024,r.implement(this,v),this.updateCharacterSize=function(){this.$textLayer.allowBoldFonts!=this.$allowBoldFonts&&(this.$allowBoldFonts=this.$textLayer.allowBoldFonts,this.setStyle("ace_nobold",!this.$allowBoldFonts)),this.layerConfig.characterWidth=this.characterWidth=this.$textLayer.getCharacterWidth(),this.layerConfig.lineHeight=this.lineHeight=this.$textLayer.getLineHeight(),this.$updatePrintMargin()},this.setSession=function(e){this.session&&this.session.doc.off("changeNewLineMode",this.onChangeNewLineMode),this.session=e,e&&this.scrollMargin.top&&e.getScrollTop()<=0&&e.setScrollTop(-this.scrollMargin.top),this.$cursorLayer.setSession(e),this.$markerBack.setSession(e),this.$markerFront.setSession(e),this.$gutterLayer.setSession(e),this.$textLayer.setSession(e);if(!e)return;this.$loop.schedule(this.CHANGE_FULL),this.session.$setFontMetrics(this.$fontMetrics),this.scrollBarV.scrollLeft=this.scrollBarV.scrollTop=null,this.onChangeNewLineMode=this.onChangeNewLineMode.bind(this),this.onChangeNewLineMode(),this.session.doc.on("changeNewLineMode",this.onChangeNewLineMode)},this.updateLines=function(e,t,n){t===undefined&&(t=Infinity),this.$changedLines?(this.$changedLines.firstRow>e&&(this.$changedLines.firstRow=e),this.$changedLines.lastRow<t&&(this.$changedLines.lastRow=t)):this.$changedLines={firstRow:e,lastRow:t};if(this.$changedLines.lastRow<this.layerConfig.firstRow){if(!n)return;this.$changedLines.lastRow=this.layerConfig.lastRow}if(this.$changedLines.firstRow>this.layerConfig.lastRow)return;this.$loop.schedule(this.CHANGE_LINES)},this.onChangeNewLineMode=function(){this.$loop.schedule(this.CHANGE_TEXT),this.$textLayer.$updateEolChar()},this.onChangeTabSize=function(){this.$loop.schedule(this.CHANGE_TEXT|this.CHANGE_MARKER),this.$textLayer.onChangeTabSize()},this.updateText=function(){this.$loop.schedule(this.CHANGE_TEXT)},this.updateFull=function(e){e?this.$renderChanges(this.CHANGE_FULL,!0):this.$loop.schedule(this.CHANGE_FULL)},this.updateFontSize=function(){this.$textLayer.checkForSizeChanges()},this.$changes=0,this.$updateSizeAsync=function(){this.$loop.pending?this.$size.$dirty=!0:this.onResize()},this.onResize=function(e,t,n,r){if(this.resizing>2)return;this.resizing>0?this.resizing++:this.resizing=e?1:0;var i=this.container;r||(r=i.clientHeight||i.scrollHeight),n||(n=i.clientWidth||i.scrollWidth);var s=this.$updateCachedSize(e,t,n,r);if(!this.$size.scrollerHeight||!n&&!r)return this.resizing=0;e&&(this.$gutterLayer.$padding=null),e?this.$renderChanges(s|this.$changes,!0):this.$loop.schedule(s|this.$changes),this.resizing&&(this.resizing=0),this.scrollBarV.scrollLeft=this.scrollBarV.scrollTop=null},this.$updateCachedSize=function(e,t,n,r){r-=this.$extraHeight||0;var i=0,s=this.$size,o={width:s.width,height:s.height,scrollerHeight:s.scrollerHeight,scrollerWidth:s.scrollerWidth};r&&(e||s.height!=r)&&(s.height=r,i|=this.CHANGE_SIZE,s.scrollerHeight=s.height,this.$horizScroll&&(s.scrollerHeight-=this.scrollBarH.getHeight()),this.scrollBarV.element.style.bottom=this.scrollBarH.getHeight()+"px",i|=this.CHANGE_SCROLL);if(n&&(e||s.width!=n)){i|=this.CHANGE_SIZE,s.width=n,t==null&&(t=this.$showGutter?this.$gutter.offsetWidth:0),this.gutterWidth=t,this.scrollBarH.element.style.left=this.scroller.style.left=t+"px",s.scrollerWidth=Math.max(0,n-t-this.scrollBarV.getWidth()),this.scrollBarH.element.style.right=this.scroller.style.right=this.scrollBarV.getWidth()+"px",this.scroller.style.bottom=this.scrollBarH.getHeight()+"px";if(this.session&&this.session.getUseWrapMode()&&this.adjustWrapLimit()||e)i|=this.CHANGE_FULL}return s.$dirty=!n||!r,i&&this._signal("resize",o),i},this.onGutterResize=function(){var e=this.$showGutter?this.$gutter.offsetWidth:0;e!=this.gutterWidth&&(this.$changes|=this.$updateCachedSize(!0,e,this.$size.width,this.$size.height)),this.session.getUseWrapMode()&&this.adjustWrapLimit()?this.$loop.schedule(this.CHANGE_FULL):this.$size.$dirty?this.$loop.schedule(this.CHANGE_FULL):(this.$computeLayerConfig(),this.$loop.schedule(this.CHANGE_MARKER))},this.adjustWrapLimit=function(){var e=this.$size.scrollerWidth-this.$padding*2,t=Math.floor(e/this.characterWidth);return this.session.adjustWrapLimit(t,this.$showPrintMargin&&this.$printMarginColumn)},this.setAnimatedScroll=function(e){this.setOption("animatedScroll",e)},this.getAnimatedScroll=function(){return this.$animatedScroll},this.setShowInvisibles=function(e){this.setOption("showInvisibles",e)},this.getShowInvisibles=function(){return this.getOption("showInvisibles")},this.getDisplayIndentGuides=function(){return this.getOption("displayIndentGuides")},this.setDisplayIndentGuides=function(e){this.setOption("displayIndentGuides",e)},this.setShowPrintMargin=function(e){this.setOption("showPrintMargin",e)},this.getShowPrintMargin=function(){return this.getOption("showPrintMargin")},this.setPrintMarginColumn=function(e){this.setOption("printMarginColumn",e)},this.getPrintMarginColumn=function(){return this.getOption("printMarginColumn")},this.getShowGutter=function(){return this.getOption("showGutter")},this.setShowGutter=function(e){return this.setOption("showGutter",e)},this.getFadeFoldWidgets=function(){return this.getOption("fadeFoldWidgets")},this.setFadeFoldWidgets=function(e){this.setOption("fadeFoldWidgets",e)},this.setHighlightGutterLine=function(e){this.setOption("highlightGutterLine",e)},this.getHighlightGutterLine=function(){return this.getOption("highlightGutterLine")},this.$updateGutterLineHighlight=function(){var e=this.$cursorLayer.$pixelPos,t=this.layerConfig.lineHeight;if(this.session.getUseWrapMode()){var n=this.session.selection.getCursor();n.column=0,e=this.$cursorLayer.getPixelPosition(n,!0),t*=this.session.getRowLength(n.row)}this.$gutterLineHighlight.style.top=e.top-this.layerConfig.offset+"px",this.$gutterLineHighlight.style.height=t+"px"},this.$updatePrintMargin=function(){if(!this.$showPrintMargin&&!this.$printMarginEl)return;if(!this.$printMarginEl){var e=i.createElement("div");e.className="ace_layer ace_print-margin-layer",this.$printMarginEl=i.createElement("div"),this.$printMarginEl.className="ace_print-margin",e.appendChild(this.$printMarginEl),this.content.insertBefore(e,this.content.firstChild)}var t=this.$printMarginEl.style;t.left=this.characterWidth*this.$printMarginColumn+this.$padding+"px",t.visibility=this.$showPrintMargin?"visible":"hidden",this.session&&this.session.$wrap==-1&&this.adjustWrapLimit()},this.getContainerElement=function(){return this.container},this.getMouseEventTarget=function(){return this.scroller},this.getTextAreaContainer=function(){return this.container},this.$moveTextAreaToCursor=function(){if(!this.$keepTextAreaAtCursor)return;var e=this.layerConfig,t=this.$cursorLayer.$pixelPos.top,n=this.$cursorLayer.$pixelPos.left;t-=e.offset;var r=this.textarea.style,i=this.lineHeight;if(t<0||t>e.height-i){r.top=r.left="0";return}var s=this.characterWidth;if(this.$composition){var o=this.textarea.value.replace(/^\x01+/,"");s*=this.session.$getStringScreenWidth(o)[0]+2,i+=2}n-=this.scrollLeft,n>this.$size.scrollerWidth-s&&(n=this.$size.scrollerWidth-s),n+=this.gutterWidth,r.height=i+"px",r.width=s+"px",r.left=Math.min(n,this.$size.scrollerWidth-s)+"px",r.top=Math.min(t,this.$size.height-i)+"px"},this.getFirstVisibleRow=function(){return this.layerConfig.firstRow},this.getFirstFullyVisibleRow=function(){return this.layerConfig.firstRow+(this.layerConfig.offset===0?0:1)},this.getLastFullyVisibleRow=function(){var e=this.layerConfig,t=e.lastRow,n=this.session.documentToScreenRow(t,0)*e.lineHeight;return n-this.session.getScrollTop()>e.height-e.lineHeight?t-1:t},this.getLastVisibleRow=function(){return this.layerConfig.lastRow},this.$padding=null,this.setPadding=function(e){this.$padding=e,this.$textLayer.setPadding(e),this.$cursorLayer.setPadding(e),this.$markerFront.setPadding(e),this.$markerBack.setPadding(e),this.$loop.schedule(this.CHANGE_FULL),this.$updatePrintMargin()},this.setScrollMargin=function(e,t,n,r){var i=this.scrollMargin;i.top=e|0,i.bottom=t|0,i.right=r|0,i.left=n|0,i.v=i.top+i.bottom,i.h=i.left+i.right,i.top&&this.scrollTop<=0&&this.session&&this.session.setScrollTop(-i.top),this.updateFull()},this.getHScrollBarAlwaysVisible=function(){return this.$hScrollBarAlwaysVisible},this.setHScrollBarAlwaysVisible=function(e){this.setOption("hScrollBarAlwaysVisible",e)},this.getVScrollBarAlwaysVisible=function(){return this.$vScrollBarAlwaysVisible},this.setVScrollBarAlwaysVisible=function(e){this.setOption("vScrollBarAlwaysVisible",e)},this.$updateScrollBarV=function(){var e=this.layerConfig.maxHeight,t=this.$size.scrollerHeight;!this.$maxLines&&this.$scrollPastEnd&&(e-=(t-this.lineHeight)*this.$scrollPastEnd,this.scrollTop>e-t&&(e=this.scrollTop+t,this.scrollBarV.scrollTop=null)),this.scrollBarV.setScrollHeight(e+this.scrollMargin.v),this.scrollBarV.setScrollTop(this.scrollTop+this.scrollMargin.top)},this.$updateScrollBarH=function(){this.scrollBarH.setScrollWidth(this.layerConfig.width+2*this.$padding+this.scrollMargin.h),this.scrollBarH.setScrollLeft(this.scrollLeft+this.scrollMargin.left)},this.$frozen=!1,this.freeze=function(){this.$frozen=!0},this.unfreeze=function(){this.$frozen=!1},this.$renderChanges=function(e,t){this.$changes&&(e|=this.$changes,this.$changes=0);if(!this.session||!this.container.offsetWidth||this.$frozen||!e&&!t){this.$changes|=e;return}if(this.$size.$dirty)return this.$changes|=e,this.onResize(!0);this.lineHeight||this.$textLayer.checkForSizeChanges(),this._signal("beforeRender");var n=this.layerConfig;if(e&this.CHANGE_FULL||e&this.CHANGE_SIZE||e&this.CHANGE_TEXT||e&this.CHANGE_LINES||e&this.CHANGE_SCROLL||e&this.CHANGE_H_SCROLL){e|=this.$computeLayerConfig();if(n.firstRow!=this.layerConfig.firstRow&&n.firstRowScreen==this.layerConfig.firstRowScreen){var r=this.scrollTop+(n.firstRow-this.layerConfig.firstRow)*this.lineHeight;r>0&&(this.scrollTop=r,e|=this.CHANGE_SCROLL,e|=this.$computeLayerConfig())}n=this.layerConfig,this.$updateScrollBarV(),e&this.CHANGE_H_SCROLL&&this.$updateScrollBarH(),this.$gutterLayer.element.style.marginTop=-n.offset+"px",this.content.style.marginTop=-n.offset+"px",this.content.style.width=n.width+2*this.$padding+"px",this.content.style.height=n.minHeight+"px"}e&this.CHANGE_H_SCROLL&&(this.content.style.marginLeft=-this.scrollLeft+"px",this.scroller.className=this.scrollLeft<=0?"ace_scroller":"ace_scroller ace_scroll-left");if(e&this.CHANGE_FULL){this.$textLayer.update(n),this.$showGutter&&this.$gutterLayer.update(n),this.$markerBack.update(n),this.$markerFront.update(n),this.$cursorLayer.update(n),this.$moveTextAreaToCursor(),this.$highlightGutterLine&&this.$updateGutterLineHighlight(),this._signal("afterRender");return}if(e&this.CHANGE_SCROLL){e&this.CHANGE_TEXT||e&this.CHANGE_LINES?this.$textLayer.update(n):this.$textLayer.scrollLines(n),this.$showGutter&&this.$gutterLayer.update(n),this.$markerBack.update(n),this.$markerFront.update(n),this.$cursorLayer.update(n),this.$highlightGutterLine&&this.$updateGutterLineHighlight(),this.$moveTextAreaToCursor(),this._signal("afterRender");return}e&this.CHANGE_TEXT?(this.$textLayer.update(n),this.$showGutter&&this.$gutterLayer.update(n)):e&this.CHANGE_LINES?(this.$updateLines()||e&this.CHANGE_GUTTER&&this.$showGutter)&&this.$gutterLayer.update(n):(e&this.CHANGE_TEXT||e&this.CHANGE_GUTTER)&&this.$showGutter&&this.$gutterLayer.update(n),e&this.CHANGE_CURSOR&&(this.$cursorLayer.update(n),this.$moveTextAreaToCursor(),this.$highlightGutterLine&&this.$updateGutterLineHighlight()),e&(this.CHANGE_MARKER|this.CHANGE_MARKER_FRONT)&&this.$markerFront.update(n),e&(this.CHANGE_MARKER|this.CHANGE_MARKER_BACK)&&this.$markerBack.update(n),this._signal("afterRender")},this.$autosize=function(){var e=this.session.getScreenLength()*this.lineHeight,t=this.$maxLines*this.lineHeight,n=Math.min(t,Math.max((this.$minLines||1)*this.lineHeight,e))+this.scrollMargin.v+(this.$extraHeight||0);this.$horizScroll&&(n+=this.scrollBarH.getHeight()),this.$maxPixelHeight&&n>this.$maxPixelHeight&&(n=this.$maxPixelHeight);var r=e>t;if(n!=this.desiredHeight||this.$size.height!=this.desiredHeight||r!=this.$vScroll){r!=this.$vScroll&&(this.$vScroll=r,this.scrollBarV.setVisible(r));var i=this.container.clientWidth;this.container.style.height=n+"px",this.$updateCachedSize(!0,this.$gutterWidth,i,n),this.desiredHeight=n,this._signal("autosize")}},this.$computeLayerConfig=function(){var e=this.session,t=this.$size,n=t.height<=2*this.lineHeight,r=this.session.getScreenLength(),i=r*this.lineHeight,s=this.$getLongestLine(),o=!n&&(this.$hScrollBarAlwaysVisible||t.scrollerWidth-s-2*this.$padding<0),u=this.$horizScroll!==o;u&&(this.$horizScroll=o,this.scrollBarH.setVisible(o));var a=this.$vScroll;this.$maxLines&&this.lineHeight>1&&this.$autosize();var f=this.scrollTop%this.lineHeight,l=t.scrollerHeight+this.lineHeight,c=!this.$maxLines&&this.$scrollPastEnd?(t.scrollerHeight-this.lineHeight)*this.$scrollPastEnd:0;i+=c;var h=this.scrollMargin;this.session.setScrollTop(Math.max(-h.top,Math.min(this.scrollTop,i-t.scrollerHeight+h.bottom))),this.session.setScrollLeft(Math.max(-h.left,Math.min(this.scrollLeft,s+2*this.$padding-t.scrollerWidth+h.right)));var p=!n&&(this.$vScrollBarAlwaysVisible||t.scrollerHeight-i+c<0||this.scrollTop>h.top),d=a!==p;d&&(this.$vScroll=p,this.scrollBarV.setVisible(p));var v=Math.ceil(l/this.lineHeight)-1,m=Math.max(0,Math.round((this.scrollTop-f)/this.lineHeight)),g=m+v,y,b,w=this.lineHeight;m=e.screenToDocumentRow(m,0);var E=e.getFoldLine(m);E&&(m=E.start.row),y=e.documentToScreenRow(m,0),b=e.getRowLength(m)*w,g=Math.min(e.screenToDocumentRow(g,0),e.getLength()-1),l=t.scrollerHeight+e.getRowLength(g)*w+b,f=this.scrollTop-y*w;var S=0;this.layerConfig.width!=s&&(S=this.CHANGE_H_SCROLL);if(u||d)S=this.$updateCachedSize(!0,this.gutterWidth,t.width,t.height),this._signal("scrollbarVisibilityChanged"),d&&(s=this.$getLongestLine());return this.layerConfig={width:s,padding:this.$padding,firstRow:m,firstRowScreen:y,lastRow:g,lineHeight:w,characterWidth:this.characterWidth,minHeight:l,maxHeight:i,offset:f,gutterOffset:w?Math.max(0,Math.ceil((f+t.height-t.scrollerHeight)/w)):0,height:this.$size.scrollerHeight},S},this.$updateLines=function(){var e=this.$changedLines.firstRow,t=this.$changedLines.lastRow;this.$changedLines=null;var n=this.layerConfig;if(e>n.lastRow+1)return;if(t<n.firstRow)return;if(t===Infinity){this.$showGutter&&this.$gutterLayer.update(n),this.$textLayer.update(n);return}return this.$textLayer.updateLines(n,e,t),!0},this.$getLongestLine=function(){var e=this.session.getScreenWidth();return this.showInvisibles&&!this.session.$useWrapMode&&(e+=1),Math.max(this.$size.scrollerWidth-2*this.$padding,Math.round(e*this.characterWidth))},this.updateFrontMarkers=function(){this.$markerFront.setMarkers(this.session.getMarkers(!0)),this.$loop.schedule(this.CHANGE_MARKER_FRONT)},this.updateBackMarkers=function(){this.$markerBack.setMarkers(this.session.getMarkers()),this.$loop.schedule(this.CHANGE_MARKER_BACK)},this.addGutterDecoration=function(e,t){this.$gutterLayer.addGutterDecoration(e,t)},this.removeGutterDecoration=function(e,t){this.$gutterLayer.removeGutterDecoration(e,t)},this.updateBreakpoints=function(e){this.$loop.schedule(this.CHANGE_GUTTER)},this.setAnnotations=function(e){this.$gutterLayer.setAnnotations(e),this.$loop.schedule(this.CHANGE_GUTTER)},this.updateCursor=function(){this.$loop.schedule(this.CHANGE_CURSOR)},this.hideCursor=function(){this.$cursorLayer.hideCursor()},this.showCursor=function(){this.$cursorLayer.showCursor()},this.scrollSelectionIntoView=function(e,t,n){this.scrollCursorIntoView(e,n),this.scrollCursorIntoView(t,n)},this.scrollCursorIntoView=function(e,t,n){if(this.$size.scrollerHeight===0)return;var r=this.$cursorLayer.getPixelPosition(e),i=r.left,s=r.top,o=n&&n.top||0,u=n&&n.bottom||0,a=this.$scrollAnimation?this.session.getScrollTop():this.scrollTop;a+o>s?(t&&a+o>s+this.lineHeight&&(s-=t*this.$size.scrollerHeight),s===0&&(s=-this.scrollMargin.top),this.session.setScrollTop(s)):a+this.$size.scrollerHeight-u<s+this.lineHeight&&(t&&a+this.$size.scrollerHeight-u<s-this.lineHeight&&(s+=t*this.$size.scrollerHeight),this.session.setScrollTop(s+this.lineHeight-this.$size.scrollerHeight));var f=this.scrollLeft;f>i?(i<this.$padding+2*this.layerConfig.characterWidth&&(i=-this.scrollMargin.left),this.session.setScrollLeft(i)):f+this.$size.scrollerWidth<i+this.characterWidth?this.session.setScrollLeft(Math.round(i+this.characterWidth-this.$size.scrollerWidth)):f<=this.$padding&&i-f<this.characterWidth&&this.session.setScrollLeft(0)},this.getScrollTop=function(){return this.session.getScrollTop()},this.getScrollLeft=function(){return this.session.getScrollLeft()},this.getScrollTopRow=function(){return this.scrollTop/this.lineHeight},this.getScrollBottomRow=function(){return Math.max(0,Math.floor((this.scrollTop+this.$size.scrollerHeight)/this.lineHeight)-1)},this.scrollToRow=function(e){this.session.setScrollTop(e*this.lineHeight)},this.alignCursor=function(e,t){typeof e=="number"&&(e={row:e,column:0});var n=this.$cursorLayer.getPixelPosition(e),r=this.$size.scrollerHeight-this.lineHeight,i=n.top-r*(t||0);return this.session.setScrollTop(i),i},this.STEPS=8,this.$calcSteps=function(e,t){var n=0,r=this.STEPS,i=[],s=function(e,t,n){return n*(Math.pow(e-1,3)+1)+t};for(n=0;n<r;++n)i.push(s(n/this.STEPS,e,t-e));return i},this.scrollToLine=function(e,t,n,r){var i=this.$cursorLayer.getPixelPosition({row:e,column:0}),s=i.top;t&&(s-=this.$size.scrollerHeight/2);var o=this.scrollTop;this.session.setScrollTop(s),n!==!1&&this.animateScrolling(o,r)},this.animateScrolling=function(e,t){var n=this.scrollTop;if(!this.$animatedScroll)return;var r=this;if(e==n)return;if(this.$scrollAnimation){var i=this.$scrollAnimation.steps;if(i.length){e=i[0];if(e==n)return}}var s=r.$calcSteps(e,n);this.$scrollAnimation={from:e,to:n,steps:s},clearInterval(this.$timer),r.session.setScrollTop(s.shift()),r.session.$scrollTop=n,this.$timer=setInterval(function(){s.length?(r.session.setScrollTop(s.shift()),r.session.$scrollTop=n):n!=null?(r.session.$scrollTop=-1,r.session.setScrollTop(n),n=null):(r.$timer=clearInterval(r.$timer),r.$scrollAnimation=null,t&&t())},10)},this.scrollToY=function(e){this.scrollTop!==e&&(this.$loop.schedule(this.CHANGE_SCROLL),this.scrollTop=e)},this.scrollToX=function(e){this.scrollLeft!==e&&(this.scrollLeft=e),this.$loop.schedule(this.CHANGE_H_SCROLL)},this.scrollTo=function(e,t){this.session.setScrollTop(t),this.session.setScrollLeft(t)},this.scrollBy=function(e,t){t&&this.session.setScrollTop(this.session.getScrollTop()+t),e&&this.session.setScrollLeft(this.session.getScrollLeft()+e)},this.isScrollableBy=function(e,t){if(t<0&&this.session.getScrollTop()>=1-this.scrollMargin.top)return!0;if(t>0&&this.session.getScrollTop()+this.$size.scrollerHeight-this.layerConfig.maxHeight<-1+this.scrollMargin.bottom)return!0;if(e<0&&this.session.getScrollLeft()>=1-this.scrollMargin.left)return!0;if(e>0&&this.session.getScrollLeft()+this.$size.scrollerWidth-this.layerConfig.width<-1+this.scrollMargin.right)return!0},this.pixelToScreenCoordinates=function(e,t){var n=this.scroller.getBoundingClientRect(),r=(e+this.scrollLeft-n.left-this.$padding)/this.characterWidth,i=Math.floor((t+this.scrollTop-n.top)/this.lineHeight),s=Math.round(r);return{row:i,column:s,side:r-s>0?1:-1}},this.screenToTextCoordinates=function(e,t){var n=this.scroller.getBoundingClientRect(),r=Math.round((e+this.scrollLeft-n.left-this.$padding)/this.characterWidth),i=(t+this.scrollTop-n.top)/this.lineHeight;return this.session.screenToDocumentPosition(i,Math.max(r,0))},this.textToScreenCoordinates=function(e,t){var n=this.scroller.getBoundingClientRect(),r=this.session.documentToScreenPosition(e,t),i=this.$padding+Math.round(r.column*this.characterWidth),s=r.row*this.lineHeight;return{pageX:n.left+i-this.scrollLeft,pageY:n.top+s-this.scrollTop}},this.visualizeFocus=function(){i.addCssClass(this.container,"ace_focus")},this.visualizeBlur=function(){i.removeCssClass(this.container,"ace_focus")},this.showComposition=function(e){this.$composition||(this.$composition={keepTextAreaAtCursor:this.$keepTextAreaAtCursor,cssText:this.textarea.style.cssText}),this.$keepTextAreaAtCursor=!0,i.addCssClass(this.textarea,"ace_composition"),this.textarea.style.cssText="",this.$moveTextAreaToCursor()},this.setCompositionText=function(e){this.$moveTextAreaToCursor()},this.hideComposition=function(){if(!this.$composition)return;i.removeCssClass(this.textarea,"ace_composition"),this.$keepTextAreaAtCursor=this.$composition.keepTextAreaAtCursor,this.textarea.style.cssText=this.$composition.cssText,this.$composition=null},this.setTheme=function(e,t){function o(r){if(n.$themeId!=e)return t&&t();if(!r||!r.cssClass)throw new Error("couldn't load module "+e+" or it didn't call define");i.importCssString(r.cssText,r.cssClass,n.container.ownerDocument),n.theme&&i.removeCssClass(n.container,n.theme.cssClass);var s="padding"in r?r.padding:"padding"in(n.theme||{})?4:n.$padding;n.$padding&&s!=n.$padding&&n.setPadding(s),n.$theme=r.cssClass,n.theme=r,i.addCssClass(n.container,r.cssClass),i.setCssClass(n.container,"ace_dark",r.isDark),n.$size&&(n.$size.width=0,n.$updateSizeAsync()),n._dispatchEvent("themeLoaded",{theme:r}),t&&t()}var n=this;this.$themeId=e,n._dispatchEvent("themeChange",{theme:e});if(!e||typeof e=="string"){var r=e||this.$options.theme.initialValue;s.loadModule(["theme",r],o)}else o(e)},this.getTheme=function(){return this.$themeId},this.setStyle=function(e,t){i.setCssClass(this.container,e,t!==!1)},this.unsetStyle=function(e){i.removeCssClass(this.container,e)},this.setCursorStyle=function(e){this.scroller.style.cursor!=e&&(this.scroller.style.cursor=e)},this.setMouseCursor=function(e){this.scroller.style.cursor=e},this.destroy=function(){this.$textLayer.destroy(),this.$cursorLayer.destroy()}}).call(g.prototype),s.defineOptions(g.prototype,"renderer",{animatedScroll:{initialValue:!1},showInvisibles:{set:function(e){this.$textLayer.setShowInvisibles(e)&&this.$loop.schedule(this.CHANGE_TEXT)},initialValue:!1},showPrintMargin:{set:function(){this.$updatePrintMargin()},initialValue:!0},printMarginColumn:{set:function(){this.$updatePrintMargin()},initialValue:80},printMargin:{set:function(e){typeof e=="number"&&(this.$printMarginColumn=e),this.$showPrintMargin=!!e,this.$updatePrintMargin()},get:function(){return this.$showPrintMargin&&this.$printMarginColumn}},showGutter:{set:function(e){this.$gutter.style.display=e?"block":"none",this.$loop.schedule(this.CHANGE_FULL),this.onGutterResize()},initialValue:!0},fadeFoldWidgets:{set:function(e){i.setCssClass(this.$gutter,"ace_fade-fold-widgets",e)},initialValue:!1},showFoldWidgets:{set:function(e){this.$gutterLayer.setShowFoldWidgets(e)},initialValue:!0},showLineNumbers:{set:function(e){this.$gutterLayer.setShowLineNumbers(e),this.$loop.schedule(this.CHANGE_GUTTER)},initialValue:!0},displayIndentGuides:{set:function(e){this.$textLayer.setDisplayIndentGuides(e)&&this.$loop.schedule(this.CHANGE_TEXT)},initialValue:!0},highlightGutterLine:{set:function(e){if(!this.$gutterLineHighlight){this.$gutterLineHighlight=i.createElement("div"),this.$gutterLineHighlight.className="ace_gutter-active-line",this.$gutter.appendChild(this.$gutterLineHighlight);return}this.$gutterLineHighlight.style.display=e?"":"none",this.$cursorLayer.$pixelPos&&this.$updateGutterLineHighlight()},initialValue:!1,value:!0},hScrollBarAlwaysVisible:{set:function(e){(!this.$hScrollBarAlwaysVisible||!this.$horizScroll)&&this.$loop.schedule(this.CHANGE_SCROLL)},initialValue:!1},vScrollBarAlwaysVisible:{set:function(e){(!this.$vScrollBarAlwaysVisible||!this.$vScroll)&&this.$loop.schedule(this.CHANGE_SCROLL)},initialValue:!1},fontSize:{set:function(e){typeof e=="number"&&(e+="px"),this.container.style.fontSize=e,this.updateFontSize()},initialValue:12},fontFamily:{set:function(e){this.container.style.fontFamily=e,this.updateFontSize()}},maxLines:{set:function(e){this.updateFull()}},minLines:{set:function(e){this.updateFull()}},maxPixelHeight:{set:function(e){this.updateFull()},initialValue:0},scrollPastEnd:{set:function(e){e=+e||0;if(this.$scrollPastEnd==e)return;this.$scrollPastEnd=e,this.$loop.schedule(this.CHANGE_SCROLL)},initialValue:0,handlesSet:!0},fixedWidthGutter:{set:function(e){this.$gutterLayer.$fixedWidth=!!e,this.$loop.schedule(this.CHANGE_GUTTER)}},theme:{set:function(e){this.setTheme(e)},get:function(){return this.$themeId||this.theme},initialValue:"./theme/textmate",handlesSet:!0}}),t.VirtualRenderer=g}),ace.define("ace/worker/worker_client",["require","exports","module","ace/lib/oop","ace/lib/net","ace/lib/event_emitter","ace/config"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("../lib/net"),s=e("../lib/event_emitter").EventEmitter,o=e("../config"),u=function(t,n,r,i){this.$sendDeltaQueue=this.$sendDeltaQueue.bind(this),this.changeListener=this.changeListener.bind(this),this.onMessage=this.onMessage.bind(this),e.nameToUrl&&!e.toUrl&&(e.toUrl=e.nameToUrl);if(o.get("packaged")||!e.toUrl)i=i||o.moduleUrl(n,"worker");else{var s=this.$normalizePath;i=i||s(e.toUrl("ace/worker/worker.js",null,"_"));var u={};t.forEach(function(t){u[t]=s(e.toUrl(t,null,"_").replace(/(\.js)?(\?.*)?$/,""))})}try{this.$worker=new Worker(i)}catch(a){if(!(a instanceof window.DOMException))throw a;var f=this.$workerBlob(i),l=window.URL||window.webkitURL,c=l.createObjectURL(f);this.$worker=new Worker(c),l.revokeObjectURL(c)}this.$worker.postMessage({init:!0,tlns:u,module:n,classname:r}),this.callbackId=1,this.callbacks={},this.$worker.onmessage=this.onMessage};(function(){r.implement(this,s),this.onMessage=function(e){var t=e.data;switch(t.type){case"event":this._signal(t.name,{data:t.data});break;case"call":var n=this.callbacks[t.id];n&&(n(t.data),delete this.callbacks[t.id]);break;case"error":this.reportError(t.data);break;case"log":window.console&&console.log&&console.log.apply(console,t.data)}},this.reportError=function(e){window.console&&console.error&&console.error(e)},this.$normalizePath=function(e){return i.qualifyURL(e)},this.terminate=function(){this._signal("terminate",{}),this.deltaQueue=null,this.$worker.terminate(),this.$worker=null,this.$doc&&this.$doc.off("change",this.changeListener),this.$doc=null},this.send=function(e,t){this.$worker.postMessage({command:e,args:t})},this.call=function(e,t,n){if(n){var r=this.callbackId++;this.callbacks[r]=n,t.push(r)}this.send(e,t)},this.emit=function(e,t){try{this.$worker.postMessage({event:e,data:{data:t.data}})}catch(n){console.error(n.stack)}},this.attachToDocument=function(e){this.$doc&&this.terminate(),this.$doc=e,this.call("setValue",[e.getValue()]),e.on("change",this.changeListener)},this.changeListener=function(e){this.deltaQueue||(this.deltaQueue=[],setTimeout(this.$sendDeltaQueue,0)),e.action=="insert"?this.deltaQueue.push(e.start,e.lines):this.deltaQueue.push(e.start,e.end)},this.$sendDeltaQueue=function(){var e=this.deltaQueue;if(!e)return;this.deltaQueue=null,e.length>50&&e.length>this.$doc.getLength()>>1?this.call("setValue",[this.$doc.getValue()]):this.emit("change",{data:e})},this.$workerBlob=function(e){var t="importScripts('"+i.qualifyURL(e)+"');";try{return new Blob([t],{type:"application/javascript"})}catch(n){var r=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder,s=new r;return s.append(t),s.getBlob("application/javascript")}}}).call(u.prototype);var a=function(e,t,n){this.$sendDeltaQueue=this.$sendDeltaQueue.bind(this),this.changeListener=this.changeListener.bind(this),this.callbackId=1,this.callbacks={},this.messageBuffer=[];var r=null,i=!1,u=Object.create(s),a=this;this.$worker={},this.$worker.terminate=function(){},this.$worker.postMessage=function(e){a.messageBuffer.push(e),r&&(i?setTimeout(f):f())},this.setEmitSync=function(e){i=e};var f=function(){var e=a.messageBuffer.shift();e.command?r[e.command].apply(r,e.args):e.event&&u._signal(e.event,e.data)};u.postMessage=function(e){a.onMessage({data:e})},u.callback=function(e,t){this.postMessage({type:"call",id:t,data:e})},u.emit=function(e,t){this.postMessage({type:"event",name:e,data:t})},o.loadModule(["worker",t],function(e){r=new e[n](u);while(a.messageBuffer.length)f()})};a.prototype=u.prototype,t.UIWorkerClient=a,t.WorkerClient=u}),ace.define("ace/placeholder",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/oop"],function(e,t,n){"use strict";var r=e("./range").Range,i=e("./lib/event_emitter").EventEmitter,s=e("./lib/oop"),o=function(e,t,n,r,i,s){var o=this;this.length=t,this.session=e,this.doc=e.getDocument(),this.mainClass=i,this.othersClass=s,this.$onUpdate=this.onUpdate.bind(this),this.doc.on("change",this.$onUpdate),this.$others=r,this.$onCursorChange=function(){setTimeout(function(){o.onCursorChange()})},this.$pos=n;var u=e.getUndoManager().$undoStack||e.getUndoManager().$undostack||{length:-1};this.$undoStackDepth=u.length,this.setup(),e.selection.on("changeCursor",this.$onCursorChange)};(function(){s.implement(this,i),this.setup=function(){var e=this,t=this.doc,n=this.session;this.selectionBefore=n.selection.toJSON(),n.selection.inMultiSelectMode&&n.selection.toSingleRange(),this.pos=t.createAnchor(this.$pos.row,this.$pos.column);var i=this.pos;i.$insertRight=!0,i.detach(),i.markerId=n.addMarker(new r(i.row,i.column,i.row,i.column+this.length),this.mainClass,null,!1),this.others=[],this.$others.forEach(function(n){var r=t.createAnchor(n.row,n.column);r.$insertRight=!0,r.detach(),e.others.push(r)}),n.setUndoSelect(!1)},this.showOtherMarkers=function(){if(this.othersActive)return;var e=this.session,t=this;this.othersActive=!0,this.others.forEach(function(n){n.markerId=e.addMarker(new r(n.row,n.column,n.row,n.column+t.length),t.othersClass,null,!1)})},this.hideOtherMarkers=function(){if(!this.othersActive)return;this.othersActive=!1;for(var e=0;e<this.others.length;e++)this.session.removeMarker(this.others[e].markerId)},this.onUpdate=function(e){if(this.$updating)return this.updateAnchors(e);var t=e;if(t.start.row!==t.end.row)return;if(t.start.row!==this.pos.row)return;this.$updating=!0;var n=e.action==="insert"?t.end.column-t.start.column:t.start.column-t.end.column,i=t.start.column>=this.pos.column&&t.start.column<=this.pos.column+this.length+1,s=t.start.column-this.pos.column;this.updateAnchors(e),i&&(this.length+=n);if(i&&!this.session.$fromUndo)if(e.action==="insert")for(var o=this.others.length-1;o>=0;o--){var u=this.others[o],a={row:u.row,column:u.column+s};this.doc.insertMergedLines(a,e.lines)}else if(e.action==="remove")for(var o=this.others.length-1;o>=0;o--){var u=this.others[o],a={row:u.row,column:u.column+s};this.doc.remove(new r(a.row,a.column,a.row,a.column-n))}this.$updating=!1,this.updateMarkers()},this.updateAnchors=function(e){this.pos.onChange(e);for(var t=this.others.length;t--;)this.others[t].onChange(e);this.updateMarkers()},this.updateMarkers=function(){if(this.$updating)return;var e=this,t=this.session,n=function(n,i){t.removeMarker(n.markerId),n.markerId=t.addMarker(new r(n.row,n.column,n.row,n.column+e.length),i,null,!1)};n(this.pos,this.mainClass);for(var i=this.others.length;i--;)n(this.others[i],this.othersClass)},this.onCursorChange=function(e){if(this.$updating||!this.session)return;var t=this.session.selection.getCursor();t.row===this.pos.row&&t.column>=this.pos.column&&t.column<=this.pos.column+this.length?(this.showOtherMarkers(),this._emit("cursorEnter",e)):(this.hideOtherMarkers(),this._emit("cursorLeave",e))},this.detach=function(){this.session.removeMarker(this.pos&&this.pos.markerId),this.hideOtherMarkers(),this.doc.removeEventListener("change",this.$onUpdate),this.session.selection.removeEventListener("changeCursor",this.$onCursorChange),this.session.setUndoSelect(!0),this.session=null},this.cancel=function(){if(this.$undoStackDepth===-1)return;var e=this.session.getUndoManager(),t=(e.$undoStack||e.$undostack).length-this.$undoStackDepth;for(var n=0;n<t;n++)e.undo(!0);this.selectionBefore&&this.session.selection.fromJSON(this.selectionBefore)}}).call(o.prototype),t.PlaceHolder=o}),ace.define("ace/mouse/multi_select_handler",["require","exports","module","ace/lib/event","ace/lib/useragent"],function(e,t,n){function s(e,t){return e.row==t.row&&e.column==t.column}function o(e){var t=e.domEvent,n=t.altKey,o=t.shiftKey,u=t.ctrlKey,a=e.getAccelKey(),f=e.getButton();u&&i.isMac&&(f=t.button);if(e.editor.inMultiSelectMode&&f==2){e.editor.textInput.onContextMenu(e.domEvent);return}if(!u&&!n&&!a){f===0&&e.editor.inMultiSelectMode&&e.editor.exitMultiSelectMode();return}if(f!==0)return;var l=e.editor,c=l.selection,h=l.inMultiSelectMode,p=e.getDocumentPosition(),d=c.getCursor(),v=e.inSelection()||c.isEmpty()&&s(p,d),m=e.x,g=e.y,y=function(e){m=e.clientX,g=e.clientY},b=l.session,w=l.renderer.pixelToScreenCoordinates(m,g),E=w,S;if(l.$mouseHandler.$enableJumpToDef)u&&n||a&&n?S=o?"block":"add":n&&l.$blockSelectEnabled&&(S="block");else if(a&&!n){S="add";if(!h&&o)return}else n&&l.$blockSelectEnabled&&(S="block");S&&i.isMac&&t.ctrlKey&&l.$mouseHandler.cancelContextMenu();if(S=="add"){if(!h&&v)return;if(!h){var x=c.toOrientedRange();l.addSelectionMarker(x)}var T=c.rangeList.rangeAtPoint(p);l.$blockScrolling++,l.inVirtualSelectionMode=!0,o&&(T=null,x=c.ranges[0]||x,l.removeSelectionMarker(x)),l.once("mouseup",function(){var e=c.toOrientedRange();T&&e.isEmpty()&&s(T.cursor,e.cursor)?c.substractPoint(e.cursor):(o?c.substractPoint(x.cursor):x&&(l.removeSelectionMarker(x),c.addRange(x)),c.addRange(e)),l.$blockScrolling--,l.inVirtualSelectionMode=!1})}else if(S=="block"){e.stop(),l.inVirtualSelectionMode=!0;var N,C=[],k=function(){var e=l.renderer.pixelToScreenCoordinates(m,g),t=b.screenToDocumentPosition(e.row,e.column);if(s(E,e)&&s(t,c.lead))return;E=e,l.$blockScrolling++,l.selection.moveToPosition(t),l.renderer.scrollCursorIntoView(),l.removeSelectionMarkers(C),C=c.rectangularRangeBlock(E,w),l.$mouseHandler.$clickSelection&&C.length==1&&C[0].isEmpty()&&(C[0]=l.$mouseHandler.$clickSelection.clone()),C.forEach(l.addSelectionMarker,l),l.updateSelectionMarkers(),l.$blockScrolling--};l.$blockScrolling++,h&&!a?c.toSingleRange():!h&&a&&(N=c.toOrientedRange(),l.addSelectionMarker(N)),o?w=b.documentToScreenPosition(c.lead):c.moveToPosition(p),l.$blockScrolling--,E={row:-1,column:-1};var L=function(e){clearInterval(O),l.removeSelectionMarkers(C),C.length||(C=[c.toOrientedRange()]),l.$blockScrolling++,N&&(l.removeSelectionMarker(N),c.toSingleRange(N));for(var t=0;t<C.length;t++)c.addRange(C[t]);l.inVirtualSelectionMode=!1,l.$mouseHandler.$clickSelection=null,l.$blockScrolling--},A=k;r.capture(l.container,y,L);var O=setInterval(function(){A()},20);return e.preventDefault()}}var r=e("../lib/event"),i=e("../lib/useragent");t.onMouseDown=o}),ace.define("ace/commands/multi_select_commands",["require","exports","module","ace/keyboard/hash_handler"],function(e,t,n){t.defaultCommands=[{name:"addCursorAbove",exec:function(e){e.selectMoreLines(-1)},bindKey:{win:"Ctrl-Alt-Up",mac:"Ctrl-Alt-Up"},scrollIntoView:"cursor",readOnly:!0},{name:"addCursorBelow",exec:function(e){e.selectMoreLines(1)},bindKey:{win:"Ctrl-Alt-Down",mac:"Ctrl-Alt-Down"},scrollIntoView:"cursor",readOnly:!0},{name:"addCursorAboveSkipCurrent",exec:function(e){e.selectMoreLines(-1,!0)},bindKey:{win:"Ctrl-Alt-Shift-Up",mac:"Ctrl-Alt-Shift-Up"},scrollIntoView:"cursor",readOnly:!0},{name:"addCursorBelowSkipCurrent",exec:function(e){e.selectMoreLines(1,!0)},bindKey:{win:"Ctrl-Alt-Shift-Down",mac:"Ctrl-Alt-Shift-Down"},scrollIntoView:"cursor",readOnly:!0},{name:"selectMoreBefore",exec:function(e){e.selectMore(-1)},bindKey:{win:"Ctrl-Alt-Left",mac:"Ctrl-Alt-Left"},scrollIntoView:"cursor",readOnly:!0},{name:"selectMoreAfter",exec:function(e){e.selectMore(1)},bindKey:{win:"Ctrl-Alt-Right",mac:"Ctrl-Alt-Right"},scrollIntoView:"cursor",readOnly:!0},{name:"selectNextBefore",exec:function(e){e.selectMore(-1,!0)},bindKey:{win:"Ctrl-Alt-Shift-Left",mac:"Ctrl-Alt-Shift-Left"},scrollIntoView:"cursor",readOnly:!0},{name:"selectNextAfter",exec:function(e){e.selectMore(1,!0)},bindKey:{win:"Ctrl-Alt-Shift-Right",mac:"Ctrl-Alt-Shift-Right"},scrollIntoView:"cursor",readOnly:!0},{name:"splitIntoLines",exec:function(e){e.multiSelect.splitIntoLines()},bindKey:{win:"Ctrl-Alt-L",mac:"Ctrl-Alt-L"},readOnly:!0},{name:"alignCursors",exec:function(e){e.alignCursors()},bindKey:{win:"Ctrl-Alt-A",mac:"Ctrl-Alt-A"},scrollIntoView:"cursor"},{name:"findAll",exec:function(e){e.findAll()},bindKey:{win:"Ctrl-Alt-K",mac:"Ctrl-Alt-G"},scrollIntoView:"cursor",readOnly:!0}],t.multiSelectCommands=[{name:"singleSelection",bindKey:"esc",exec:function(e){e.exitMultiSelectMode()},scrollIntoView:"cursor",readOnly:!0,isAvailable:function(e){return e&&e.inMultiSelectMode}}];var r=e("../keyboard/hash_handler").HashHandler;t.keyboardHandler=new r(t.multiSelectCommands)}),ace.define("ace/multi_select",["require","exports","module","ace/range_list","ace/range","ace/selection","ace/mouse/multi_select_handler","ace/lib/event","ace/lib/lang","ace/commands/multi_select_commands","ace/search","ace/edit_session","ace/editor","ace/config"],function(e,t,n){function h(e,t,n){return c.$options.wrap=!0,c.$options.needle=t,c.$options.backwards=n==-1,c.find(e)}function v(e,t){return e.row==t.row&&e.column==t.column}function m(e){if(e.$multiselectOnSessionChange)return;e.$onAddRange=e.$onAddRange.bind(e),e.$onRemoveRange=e.$onRemoveRange.bind(e),e.$onMultiSelect=e.$onMultiSelect.bind(e),e.$onSingleSelect=e.$onSingleSelect.bind(e),e.$multiselectOnSessionChange=t.onSessionChange.bind(e),e.$checkMultiselectChange=e.$checkMultiselectChange.bind(e),e.$multiselectOnSessionChange(e),e.on("changeSession",e.$multiselectOnSessionChange),e.on("mousedown",o),e.commands.addCommands(f.defaultCommands),g(e)}function g(e){function r(t){n&&(e.renderer.setMouseCursor(""),n=!1)}var t=e.textInput.getElement(),n=!1;u.addListener(t,"keydown",function(t){var i=t.keyCode==18&&!(t.ctrlKey||t.shiftKey||t.metaKey);e.$blockSelectEnabled&&i?n||(e.renderer.setMouseCursor("crosshair"),n=!0):n&&r()}),u.addListener(t,"keyup",r),u.addListener(t,"blur",r)}var r=e("./range_list").RangeList,i=e("./range").Range,s=e("./selection").Selection,o=e("./mouse/multi_select_handler").onMouseDown,u=e("./lib/event"),a=e("./lib/lang"),f=e("./commands/multi_select_commands");t.commands=f.defaultCommands.concat(f.multiSelectCommands);var l=e("./search").Search,c=new l,p=e("./edit_session").EditSession;(function(){this.getSelectionMarkers=function(){return this.$selectionMarkers}}).call(p.prototype),function(){this.ranges=null,this.rangeList=null,this.addRange=function(e,t){if(!e)return;if(!this.inMultiSelectMode&&this.rangeCount===0){var n=this.toOrientedRange();this.rangeList.add(n),this.rangeList.add(e);if(this.rangeList.ranges.length!=2)return this.rangeList.removeAll(),t||this.fromOrientedRange(e);this.rangeList.removeAll(),this.rangeList.add(n),this.$onAddRange(n)}e.cursor||(e.cursor=e.end);var r=this.rangeList.add(e);return this.$onAddRange(e),r.length&&this.$onRemoveRange(r),this.rangeCount>1&&!this.inMultiSelectMode&&(this._signal("multiSelect"),this.inMultiSelectMode=!0,this.session.$undoSelect=!1,this.rangeList.attach(this.session)),t||this.fromOrientedRange(e)},this.toSingleRange=function(e){e=e||this.ranges[0];var t=this.rangeList.removeAll();t.length&&this.$onRemoveRange(t),e&&this.fromOrientedRange(e)},this.substractPoint=function(e){var t=this.rangeList.substractPoint(e);if(t)return this.$onRemoveRange(t),t[0]},this.mergeOverlappingRanges=function(){var e=this.rangeList.merge();e.length?this.$onRemoveRange(e):this.ranges[0]&&this.fromOrientedRange(this.ranges[0])},this.$onAddRange=function(e){this.rangeCount=this.rangeList.ranges.length,this.ranges.unshift(e),this._signal("addRange",{range:e})},this.$onRemoveRange=function(e){this.rangeCount=this.rangeList.ranges.length;if(this.rangeCount==1&&this.inMultiSelectMode){var t=this.rangeList.ranges.pop();e.push(t),this.rangeCount=0}for(var n=e.length;n--;){var r=this.ranges.indexOf(e[n]);this.ranges.splice(r,1)}this._signal("removeRange",{ranges:e}),this.rangeCount===0&&this.inMultiSelectMode&&(this.inMultiSelectMode=!1,this._signal("singleSelect"),this.session.$undoSelect=!0,this.rangeList.detach(this.session)),t=t||this.ranges[0],t&&!t.isEqual(this.getRange())&&this.fromOrientedRange(t)},this.$initRangeList=function(){if(this.rangeList)return;this.rangeList=new r,this.ranges=[],this.rangeCount=0},this.getAllRanges=function(){return this.rangeCount?this.rangeList.ranges.concat():[this.getRange()]},this.splitIntoLines=function(){if(this.rangeCount>1){var e=this.rangeList.ranges,t=e[e.length-1],n=i.fromPoints(e[0].start,t.end);this.toSingleRange(),this.setSelectionRange(n,t.cursor==t.start)}else{var n=this.getRange(),r=this.isBackwards(),s=n.start.row,o=n.end.row;if(s==o){if(r)var u=n.end,a=n.start;else var u=n.start,a=n.end;this.addRange(i.fromPoints(a,a)),this.addRange(i.fromPoints(u,u));return}var f=[],l=this.getLineRange(s,!0);l.start.column=n.start.column,f.push(l);for(var c=s+1;c<o;c++)f.push(this.getLineRange(c,!0));l=this.getLineRange(o,!0),l.end.column=n.end.column,f.push(l),f.forEach(this.addRange,this)}},this.toggleBlockSelection=function(){if(this.rangeCount>1){var e=this.rangeList.ranges,t=e[e.length-1],n=i.fromPoints(e[0].start,t.end);this.toSingleRange(),this.setSelectionRange(n,t.cursor==t.start)}else{var r=this.session.documentToScreenPosition(this.selectionLead),s=this.session.documentToScreenPosition(this.selectionAnchor),o=this.rectangularRangeBlock(r,s);o.forEach(this.addRange,this)}},this.rectangularRangeBlock=function(e,t,n){var r=[],s=e.column<t.column;if(s)var o=e.column,u=t.column;else var o=t.column,u=e.column;var a=e.row<t.row;if(a)var f=e.row,l=t.row;else var f=t.row,l=e.row;o<0&&(o=0),f<0&&(f=0),f==l&&(n=!0);for(var c=f;c<=l;c++){var h=i.fromPoints(this.session.screenToDocumentPosition(c,o),this.session.screenToDocumentPosition(c,u));if(h.isEmpty()){if(p&&v(h.end,p))break;var p=h.end}h.cursor=s?h.start:h.end,r.push(h)}a&&r.reverse();if(!n){var d=r.length-1;while(r[d].isEmpty()&&d>0)d--;if(d>0){var m=0;while(r[m].isEmpty())m++}for(var g=d;g>=m;g--)r[g].isEmpty()&&r.splice(g,1)}return r}}.call(s.prototype);var d=e("./editor").Editor;(function(){this.updateSelectionMarkers=function(){this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.addSelectionMarker=function(e){e.cursor||(e.cursor=e.end);var t=this.getSelectionStyle();return e.marker=this.session.addMarker(e,"ace_selection",t),this.session.$selectionMarkers.push(e),this.session.selectionMarkerCount=this.session.$selectionMarkers.length,e},this.removeSelectionMarker=function(e){if(!e.marker)return;this.session.removeMarker(e.marker);var t=this.session.$selectionMarkers.indexOf(e);t!=-1&&this.session.$selectionMarkers.splice(t,1),this.session.selectionMarkerCount=this.session.$selectionMarkers.length},this.removeSelectionMarkers=function(e){var t=this.session.$selectionMarkers;for(var n=e.length;n--;){var r=e[n];if(!r.marker)continue;this.session.removeMarker(r.marker);var i=t.indexOf(r);i!=-1&&t.splice(i,1)}this.session.selectionMarkerCount=t.length},this.$onAddRange=function(e){this.addSelectionMarker(e.range),this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.$onRemoveRange=function(e){this.removeSelectionMarkers(e.ranges),this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.$onMultiSelect=function(e){if(this.inMultiSelectMode)return;this.inMultiSelectMode=!0,this.setStyle("ace_multiselect"),this.keyBinding.addKeyboardHandler(f.keyboardHandler),this.commands.setDefaultHandler("exec",this.$onMultiSelectExec),this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.$onSingleSelect=function(e){if(this.session.multiSelect.inVirtualMode)return;this.inMultiSelectMode=!1,this.unsetStyle("ace_multiselect"),this.keyBinding.removeKeyboardHandler(f.keyboardHandler),this.commands.removeDefaultHandler("exec",this.$onMultiSelectExec),this.renderer.updateCursor(),this.renderer.updateBackMarkers(),this._emit("changeSelection")},this.$onMultiSelectExec=function(e){var t=e.command,n=e.editor;if(!n.multiSelect)return;if(!t.multiSelectAction){var r=t.exec(n,e.args||{});n.multiSelect.addRange(n.multiSelect.toOrientedRange()),n.multiSelect.mergeOverlappingRanges()}else t.multiSelectAction=="forEach"?r=n.forEachSelection(t,e.args):t.multiSelectAction=="forEachLine"?r=n.forEachSelection(t,e.args,!0):t.multiSelectAction=="single"?(n.exitMultiSelectMode(),r=t.exec(n,e.args||{})):r=t.multiSelectAction(n,e.args||{});return r},this.forEachSelection=function(e,t,n){if(this.inVirtualSelectionMode)return;var r=n&&n.keepOrder,i=n==1||n&&n.$byLines,o=this.session,u=this.selection,a=u.rangeList,f=(r?u:a).ranges,l;if(!f.length)return e.exec?e.exec(this,t||{}):e(this,t||{});var c=u._eventRegistry;u._eventRegistry={};var h=new s(o);this.inVirtualSelectionMode=!0;for(var p=f.length;p--;){if(i)while(p>0&&f[p].start.row==f[p-1].end.row)p--;h.fromOrientedRange(f[p]),h.index=p,this.selection=o.selection=h;var d=e.exec?e.exec(this,t||{}):e(this,t||{});!l&&d!==undefined&&(l=d),h.toOrientedRange(f[p])}h.detach(),this.selection=o.selection=u,this.inVirtualSelectionMode=!1,u._eventRegistry=c,u.mergeOverlappingRanges();var v=this.renderer.$scrollAnimation;return this.onCursorChange(),this.onSelectionChange(),v&&v.from==v.to&&this.renderer.animateScrolling(v.from),l},this.exitMultiSelectMode=function(){if(!this.inMultiSelectMode||this.inVirtualSelectionMode)return;this.multiSelect.toSingleRange()},this.getSelectedText=function(){var e="";if(this.inMultiSelectMode&&!this.inVirtualSelectionMode){var t=this.multiSelect.rangeList.ranges,n=[];for(var r=0;r<t.length;r++)n.push(this.session.getTextRange(t[r]));var i=this.session.getDocument().getNewLineCharacter();e=n.join(i),e.length==(n.length-1)*i.length&&(e="")}else this.selection.isEmpty()||(e=this.session.getTextRange(this.getSelectionRange()));return e},this.$checkMultiselectChange=function(e,t){if(this.inMultiSelectMode&&!this.inVirtualSelectionMode){var n=this.multiSelect.ranges[0];if(this.multiSelect.isEmpty()&&t==this.multiSelect.anchor)return;var r=t==this.multiSelect.anchor?n.cursor==n.start?n.end:n.start:n.cursor;(r.row!=t.row||this.session.$clipPositionToDocument(r.row,r.column).column!=t.column)&&this.multiSelect.toSingleRange(this.multiSelect.toOrientedRange())}},this.findAll=function(e,t,n){t=t||{},t.needle=e||t.needle;if(t.needle==undefined){var r=this.selection.isEmpty()?this.selection.getWordRange():this.selection.getRange();t.needle=this.session.getTextRange(r)}this.$search.set(t);var i=this.$search.findAll(this.session);if(!i.length)return 0;this.$blockScrolling+=1;var s=this.multiSelect;n||s.toSingleRange(i[0]);for(var o=i.length;o--;)s.addRange(i[o],!0);return r&&s.rangeList.rangeAtPoint(r.start)&&s.addRange(r,!0),this.$blockScrolling-=1,i.length},this.selectMoreLines=function(e,t){var n=this.selection.toOrientedRange(),r=n.cursor==n.end,s=this.session.documentToScreenPosition(n.cursor);this.selection.$desiredColumn&&(s.column=this.selection.$desiredColumn);var o=this.session.screenToDocumentPosition(s.row+e,s.column);if(!n.isEmpty())var u=this.session.documentToScreenPosition(r?n.end:n.start),a=this.session.screenToDocumentPosition(u.row+e,u.column);else var a=o;if(r){var f=i.fromPoints(o,a);f.cursor=f.start}else{var f=i.fromPoints(a,o);f.cursor=f.end}f.desiredColumn=s.column;if(!this.selection.inMultiSelectMode)this.selection.addRange(n);else if(t)var l=n.cursor;this.selection.addRange(f),l&&this.selection.substractPoint(l)},this.transposeSelections=function(e){var t=this.session,n=t.multiSelect,r=n.ranges;for(var i=r.length;i--;){var s=r[i];if(s.isEmpty()){var o=t.getWordRange(s.start.row,s.start.column);s.start.row=o.start.row,s.start.column=o.start.column,s.end.row=o.end.row,s.end.column=o.end.column}}n.mergeOverlappingRanges();var u=[];for(var i=r.length;i--;){var s=r[i];u.unshift(t.getTextRange(s))}e<0?u.unshift(u.pop()):u.push(u.shift());for(var i=r.length;i--;){var s=r[i],o=s.clone();t.replace(s,u[i]),s.start.row=o.start.row,s.start.column=o.start.column}},this.selectMore=function(e,t,n){var r=this.session,i=r.multiSelect,s=i.toOrientedRange();if(s.isEmpty()){s=r.getWordRange(s.start.row,s.start.column),s.cursor=e==-1?s.start:s.end,this.multiSelect.addRange(s);if(n)return}var o=r.getTextRange(s),u=h(r,o,e);u&&(u.cursor=e==-1?u.start:u.end,this.$blockScrolling+=1,this.session.unfold(u),this.multiSelect.addRange(u),this.$blockScrolling-=1,this.renderer.scrollCursorIntoView(null,.5)),t&&this.multiSelect.substractPoint(s.cursor)},this.alignCursors=function(){var e=this.session,t=e.multiSelect,n=t.ranges,r=-1,s=n.filter(function(e){if(e.cursor.row==r)return!0;r=e.cursor.row});if(!n.length||s.length==n.length-1){var o=this.selection.getRange(),u=o.start.row,f=o.end.row,l=u==f;if(l){var c=this.session.getLength(),h;do h=this.session.getLine(f);while(/[=:]/.test(h)&&++f<c);do h=this.session.getLine(u);while(/[=:]/.test(h)&&--u>0);u<0&&(u=0),f>=c&&(f=c-1)}var p=this.session.removeFullLines(u,f);p=this.$reAlignText(p,l),this.session.insert({row:u,column:0},p.join("\n")+"\n"),l||(o.start.column=0,o.end.column=p[p.length-1].length),this.selection.setRange(o)}else{s.forEach(function(e){t.substractPoint(e.cursor)});var d=0,v=Infinity,m=n.map(function(t){var n=t.cursor,r=e.getLine(n.row),i=r.substr(n.column).search(/\S/g);return i==-1&&(i=0),n.column>d&&(d=n.column),i<v&&(v=i),i});n.forEach(function(t,n){var r=t.cursor,s=d-r.column,o=m[n]-v;s>o?e.insert(r,a.stringRepeat(" ",s-o)):e.remove(new i(r.row,r.column,r.row,r.column-s+o)),t.start.column=t.end.column=d,t.start.row=t.end.row=r.row,t.cursor=t.end}),t.fromOrientedRange(n[0]),this.renderer.updateCursor(),this.renderer.updateBackMarkers()}},this.$reAlignText=function(e,t){function u(e){return a.stringRepeat(" ",e)}function f(e){return e[2]?u(i)+e[2]+u(s-e[2].length+o)+e[4].replace(/^([=:])\s+/,"$1 "):e[0]}function l(e){return e[2]?u(i+s-e[2].length)+e[2]+u(o," ")+e[4].replace(/^([=:])\s+/,"$1 "):e[0]}function c(e){return e[2]?u(i)+e[2]+u(o)+e[4].replace(/^([=:])\s+/,"$1 "):e[0]}var n=!0,r=!0,i,s,o;return e.map(function(e){var t=e.match(/(\s*)(.*?)(\s*)([=:].*)/);return t?i==null?(i=t[1].length,s=t[2].length,o=t[3].length,t):(i+s+o!=t[1].length+t[2].length+t[3].length&&(r=!1),i!=t[1].length&&(n=!1),i>t[1].length&&(i=t[1].length),s<t[2].length&&(s=t[2].length),o>t[3].length&&(o=t[3].length),t):[e]}).map(t?f:n?r?l:f:c)}}).call(d.prototype),t.onSessionChange=function(e){var t=e.session;t&&!t.multiSelect&&(t.$selectionMarkers=[],t.selection.$initRangeList(),t.multiSelect=t.selection),this.multiSelect=t&&t.multiSelect;var n=e.oldSession;n&&(n.multiSelect.off("addRange",this.$onAddRange),n.multiSelect.off("removeRange",this.$onRemoveRange),n.multiSelect.off("multiSelect",this.$onMultiSelect),n.multiSelect.off("singleSelect",this.$onSingleSelect),n.multiSelect.lead.off("change",this.$checkMultiselectChange),n.multiSelect.anchor.off("change",this.$checkMultiselectChange)),t&&(t.multiSelect.on("addRange",this.$onAddRange),t.multiSelect.on("removeRange",this.$onRemoveRange),t.multiSelect.on("multiSelect",this.$onMultiSelect),t.multiSelect.on("singleSelect",this.$onSingleSelect),t.multiSelect.lead.on("change",this.$checkMultiselectChange),t.multiSelect.anchor.on("change",this.$checkMultiselectChange)),t&&this.inMultiSelectMode!=t.selection.inMultiSelectMode&&(t.selection.inMultiSelectMode?this.$onMultiSelect():this.$onSingleSelect())},t.MultiSelect=m,e("./config").defineOptions(d.prototype,"editor",{enableMultiselect:{set:function(e){m(this),e?(this.on("changeSession",this.$multiselectOnSessionChange),this.on("mousedown",o)):(this.off("changeSession",this.$multiselectOnSessionChange),this.off("mousedown",o))},value:!0},enableBlockSelect:{set:function(e){this.$blockSelectEnabled=e},value:!0}})}),ace.define("ace/mode/folding/fold_mode",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("../../range").Range,i=t.FoldMode=function(){};(function(){this.foldingStartMarker=null,this.foldingStopMarker=null,this.getFoldWidget=function(e,t,n){var r=e.getLine(n);return this.foldingStartMarker.test(r)?"start":t=="markbeginend"&&this.foldingStopMarker&&this.foldingStopMarker.test(r)?"end":""},this.getFoldWidgetRange=function(e,t,n){return null},this.indentationBlock=function(e,t,n){var i=/\S/,s=e.getLine(t),o=s.search(i);if(o==-1)return;var u=n||s.length,a=e.getLength(),f=t,l=t;while(++t<a){var c=e.getLine(t).search(i);if(c==-1)continue;if(c<=o)break;l=t}if(l>f){var h=e.getLine(l).length;return new r(f,u,l,h)}},this.openingBracketBlock=function(e,t,n,i,s){var o={row:n,column:i+1},u=e.$findClosingBracket(t,o,s);if(!u)return;var a=e.foldWidgets[u.row];return a==null&&(a=e.getFoldWidget(u.row)),a=="start"&&u.row>o.row&&(u.row--,u.column=e.getLine(u.row).length),r.fromPoints(o,u)},this.closingBracketBlock=function(e,t,n,i,s){var o={row:n,column:i},u=e.$findOpeningBracket(t,o);if(!u)return;return u.column++,o.column--,r.fromPoints(u,o)}}).call(i.prototype)}),ace.define("ace/theme/textmate",["require","exports","module","ace/lib/dom"],function(e,t,n){"use strict";t.isDark=!1,t.cssClass="ace-tm",t.cssText='.ace-tm .ace_gutter {background: #f0f0f0;color: #333;}.ace-tm .ace_print-margin {width: 1px;background: #e8e8e8;}.ace-tm .ace_fold {background-color: #6B72E6;}.ace-tm {background-color: #FFFFFF;color: black;}.ace-tm .ace_cursor {color: black;}.ace-tm .ace_invisible {color: rgb(191, 191, 191);}.ace-tm .ace_storage,.ace-tm .ace_keyword {color: blue;}.ace-tm .ace_constant {color: rgb(197, 6, 11);}.ace-tm .ace_constant.ace_buildin {color: rgb(88, 72, 246);}.ace-tm .ace_constant.ace_language {color: rgb(88, 92, 246);}.ace-tm .ace_constant.ace_library {color: rgb(6, 150, 14);}.ace-tm .ace_invalid {background-color: rgba(255, 0, 0, 0.1);color: red;}.ace-tm .ace_support.ace_function {color: rgb(60, 76, 114);}.ace-tm .ace_support.ace_constant {color: rgb(6, 150, 14);}.ace-tm .ace_support.ace_type,.ace-tm .ace_support.ace_class {color: rgb(109, 121, 222);}.ace-tm .ace_keyword.ace_operator {color: rgb(104, 118, 135);}.ace-tm .ace_string {color: rgb(3, 106, 7);}.ace-tm .ace_comment {color: rgb(76, 136, 107);}.ace-tm .ace_comment.ace_doc {color: rgb(0, 102, 255);}.ace-tm .ace_comment.ace_doc.ace_tag {color: rgb(128, 159, 191);}.ace-tm .ace_constant.ace_numeric {color: rgb(0, 0, 205);}.ace-tm .ace_variable {color: rgb(49, 132, 149);}.ace-tm .ace_xml-pe {color: rgb(104, 104, 91);}.ace-tm .ace_entity.ace_name.ace_function {color: #0000A2;}.ace-tm .ace_heading {color: rgb(12, 7, 255);}.ace-tm .ace_list {color:rgb(185, 6, 144);}.ace-tm .ace_meta.ace_tag {color:rgb(0, 22, 142);}.ace-tm .ace_string.ace_regex {color: rgb(255, 0, 0)}.ace-tm .ace_marker-layer .ace_selection {background: rgb(181, 213, 255);}.ace-tm.ace_multiselect .ace_selection.ace_start {box-shadow: 0 0 3px 0px white;}.ace-tm .ace_marker-layer .ace_step {background: rgb(252, 255, 0);}.ace-tm .ace_marker-layer .ace_stack {background: rgb(164, 229, 101);}.ace-tm .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid rgb(192, 192, 192);}.ace-tm .ace_marker-layer .ace_active-line {background: rgba(0, 0, 0, 0.07);}.ace-tm .ace_gutter-active-line {background-color : #dcdcdc;}.ace-tm .ace_marker-layer .ace_selected-word {background: rgb(250, 250, 255);border: 1px solid rgb(200, 200, 250);}.ace-tm .ace_indent-guide {background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==") right repeat-y;}';var r=e("../lib/dom");r.importCssString(t.cssText,t.cssClass)}),ace.define("ace/line_widgets",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/range"],function(e,t,n){"use strict";function o(e){this.session=e,this.session.widgetManager=this,this.session.getRowLength=this.getRowLength,this.session.$getWidgetScreenLength=this.$getWidgetScreenLength,this.updateOnChange=this.updateOnChange.bind(this),this.renderWidgets=this.renderWidgets.bind(this),this.measureWidgets=this.measureWidgets.bind(this),this.session._changedWidgets=[],this.$onChangeEditor=this.$onChangeEditor.bind(this),this.session.on("change",this.updateOnChange),this.session.on("changeFold",this.updateOnFold),this.session.on("changeEditor",this.$onChangeEditor)}var r=e("./lib/oop"),i=e("./lib/dom"),s=e("./range").Range;(function(){this.getRowLength=function(e){var t;return this.lineWidgets?t=this.lineWidgets[e]&&this.lineWidgets[e].rowCount||0:t=0,!this.$useWrapMode||!this.$wrapData[e]?1+t:this.$wrapData[e].length+1+t},this.$getWidgetScreenLength=function(){var e=0;return this.lineWidgets.forEach(function(t){t&&t.rowCount&&!t.hidden&&(e+=t.rowCount)}),e},this.$onChangeEditor=function(e){this.attach(e.editor)},this.attach=function(e){e&&e.widgetManager&&e.widgetManager!=this&&e.widgetManager.detach();if(this.editor==e)return;this.detach(),this.editor=e,e&&(e.widgetManager=this,e.renderer.on("beforeRender",this.measureWidgets),e.renderer.on("afterRender",this.renderWidgets))},this.detach=function(e){var t=this.editor;if(!t)return;this.editor=null,t.widgetManager=null,t.renderer.off("beforeRender",this.measureWidgets),t.renderer.off("afterRender",this.renderWidgets);var n=this.session.lineWidgets;n&&n.forEach(function(e){e&&e.el&&e.el.parentNode&&(e._inDocument=!1,e.el.parentNode.removeChild(e.el))})},this.updateOnFold=function(e,t){var n=t.lineWidgets;if(!n||!e.action)return;var r=e.data,i=r.start.row,s=r.end.row,o=e.action=="add";for(var u=i+1;u<s;u++)n[u]&&(n[u].hidden=o);n[s]&&(o?n[i]?n[s].hidden=o:n[i]=n[s]:(n[i]==n[s]&&(n[i]=undefined),n[s].hidden=o))},this.updateOnChange=function(e){var t=this.session.lineWidgets;if(!t)return;var n=e.start.row,r=e.end.row-n;if(r!==0)if(e.action=="remove"){var i=t.splice(n+1,r);i.forEach(function(e){e&&this.removeLineWidget(e)},this),this.$updateRows()}else{var s=new Array(r);s.unshift(n,0),t.splice.apply(t,s),this.$updateRows()}},this.$updateRows=function(){var e=this.session.lineWidgets;if(!e)return;var t=!0;e.forEach(function(e,n){if(e){t=!1,e.row=n;while(e.$oldWidget)e.$oldWidget.row=n,e=e.$oldWidget}}),t&&(this.session.lineWidgets=null)},this.addLineWidget=function(e){this.session.lineWidgets||(this.session.lineWidgets=new Array(this.session.getLength()));var t=this.session.lineWidgets[e.row];t&&(e.$oldWidget=t,t.el&&t.el.parentNode&&(t.el.parentNode.removeChild(t.el),t._inDocument=!1)),this.session.lineWidgets[e.row]=e,e.session=this.session;var n=this.editor.renderer;e.html&&!e.el&&(e.el=i.createElement("div"),e.el.innerHTML=e.html),e.el&&(i.addCssClass(e.el,"ace_lineWidgetContainer"),e.el.style.position="absolute",e.el.style.zIndex=5,n.container.appendChild(e.el),e._inDocument=!0),e.coverGutter||(e.el.style.zIndex=3),e.pixelHeight==null&&(e.pixelHeight=e.el.offsetHeight),e.rowCount==null&&(e.rowCount=e.pixelHeight/n.layerConfig.lineHeight);var r=this.session.getFoldAt(e.row,0);e.$fold=r;if(r){var s=this.session.lineWidgets;e.row==r.end.row&&!s[r.start.row]?s[r.start.row]=e:e.hidden=!0}return this.session._emit("changeFold",{data:{start:{row:e.row}}}),this.$updateRows(),this.renderWidgets(null,n),this.onWidgetChanged(e),e},this.removeLineWidget=function(e){e._inDocument=!1,e.session=null,e.el&&e.el.parentNode&&e.el.parentNode.removeChild(e.el);if(e.editor&&e.editor.destroy)try{e.editor.destroy()}catch(t){}if(this.session.lineWidgets){var n=this.session.lineWidgets[e.row];if(n==e)this.session.lineWidgets[e.row]=e.$oldWidget,e.$oldWidget&&this.onWidgetChanged(e.$oldWidget);else while(n){if(n.$oldWidget==e){n.$oldWidget=e.$oldWidget;break}n=n.$oldWidget}}this.session._emit("changeFold",{data:{start:{row:e.row}}}),this.$updateRows()},this.getWidgetsAtRow=function(e){var t=this.session.lineWidgets,n=t&&t[e],r=[];while(n)r.push(n),n=n.$oldWidget;return r},this.onWidgetChanged=function(e){this.session._changedWidgets.push(e),this.editor&&this.editor.renderer.updateFull()},this.measureWidgets=function(e,t){var n=this.session._changedWidgets,r=t.layerConfig;if(!n||!n.length)return;var i=Infinity;for(var s=0;s<n.length;s++){var o=n[s];if(!o||!o.el)continue;if(o.session!=this.session)continue;if(!o._inDocument){if(this.session.lineWidgets[o.row]!=o)continue;o._inDocument=!0,t.container.appendChild(o.el)}o.h=o.el.offsetHeight,o.fixedWidth||(o.w=o.el.offsetWidth,o.screenWidth=Math.ceil(o.w/r.characterWidth));var u=o.h/r.lineHeight;o.coverLine&&(u-=this.session.getRowLineCount(o.row),u<0&&(u=0)),o.rowCount!=u&&(o.rowCount=u,o.row<i&&(i=o.row))}i!=Infinity&&(this.session._emit("changeFold",{data:{start:{row:i}}}),this.session.lineWidgetWidth=null),this.session._changedWidgets=[]},this.renderWidgets=function(e,t){var n=t.layerConfig,r=this.session.lineWidgets;if(!r)return;var i=Math.min(this.firstRow,n.firstRow),s=Math.max(this.lastRow,n.lastRow,r.length);while(i>0&&!r[i])i--;this.firstRow=n.firstRow,this.lastRow=n.lastRow,t.$cursorLayer.config=n;for(var o=i;o<=s;o++){var u=r[o];if(!u||!u.el)continue;if(u.hidden){u.el.style.top=-100-(u.pixelHeight||0)+"px";continue}u._inDocument||(u._inDocument=!0,t.container.appendChild(u.el));var a=t.$cursorLayer.getPixelPosition({row:o,column:0},!0).top;u.coverLine||(a+=n.lineHeight*this.session.getRowLineCount(u.row)),u.el.style.top=a-n.offset+"px";var f=u.coverGutter?0:t.gutterWidth;u.fixedWidth||(f-=t.scrollLeft),u.el.style.left=f+"px",u.fullWidth&&u.screenWidth&&(u.el.style.minWidth=n.width+2*n.padding+"px"),u.fixedWidth?u.el.style.right=t.scrollBar.getWidth()+"px":u.el.style.right=""}}}).call(o.prototype),t.LineWidgets=o}),ace.define("ace/ext/error_marker",["require","exports","module","ace/line_widgets","ace/lib/dom","ace/range"],function(e,t,n){"use strict";function o(e,t,n){var r=0,i=e.length-1;while(r<=i){var s=r+i>>1,o=n(t,e[s]);if(o>0)r=s+1;else{if(!(o<0))return s;i=s-1}}return-(r+1)}function u(e,t,n){var r=e.getAnnotations().sort(s.comparePoints);if(!r.length)return;var i=o(r,{row:t,column:-1},s.comparePoints);i<0&&(i=-i-1),i>=r.length?i=n>0?0:r.length-1:i===0&&n<0&&(i=r.length-1);var u=r[i];if(!u||!n)return;if(u.row===t){do u=r[i+=n];while(u&&u.row===t);if(!u)return r.slice()}var a=[];t=u.row;do a[n<0?"unshift":"push"](u),u=r[i+=n];while(u&&u.row==t);return a.length&&a}var r=e("../line_widgets").LineWidgets,i=e("../lib/dom"),s=e("../range").Range;t.showErrorMarker=function(e,t){var n=e.session;n.widgetManager||(n.widgetManager=new r(n),n.widgetManager.attach(e));var s=e.getCursorPosition(),o=s.row,a=n.widgetManager.getWidgetsAtRow(o).filter(function(e){return e.type=="errorMarker"})[0];a?a.destroy():o-=t;var f=u(n,o,t),l;if(f){var c=f[0];s.column=(c.pos&&typeof c.column!="number"?c.pos.sc:c.column)||0,s.row=c.row,l=e.renderer.$gutterLayer.$annotations[s.row]}else{if(a)return;l={text:["Looks good!"],className:"ace_ok"}}e.session.unfold(s.row),e.selection.moveToPosition(s);var h={row:s.row,fixedWidth:!0,coverGutter:!0,el:i.createElement("div"),type:"errorMarker"},p=h.el.appendChild(i.createElement("div")),d=h.el.appendChild(i.createElement("div"));d.className="error_widget_arrow "+l.className;var v=e.renderer.$cursorLayer.getPixelPosition(s).left;d.style.left=v+e.renderer.gutterWidth-5+"px",h.el.className="error_widget_wrapper",p.className="error_widget "+l.className,p.innerHTML=l.text.join("<br>"),p.appendChild(i.createElement("div"));var m=function(e,t,n){if(t===0&&(n==="esc"||n==="return"))return h.destroy(),{command:"null"}};h.destroy=function(){if(e.$mouseHandler.isMousePressed)return;e.keyBinding.removeKeyboardHandler(m),n.widgetManager.removeLineWidget(h),e.off("changeSelection",h.destroy),e.off("changeSession",h.destroy),e.off("mouseup",h.destroy),e.off("change",h.destroy)},e.keyBinding.addKeyboardHandler(m),e.on("changeSelection",h.destroy),e.on("changeSession",h.destroy),e.on("mouseup",h.destroy),e.on("change",h.destroy),e.session.widgetManager.addLineWidget(h),h.el.onmousedown=e.focus.bind(e),e.renderer.scrollCursorIntoView(null,.5,{bottom:h.el.offsetHeight})},i.importCssString(" .error_widget_wrapper { background: inherit; color: inherit; border:none } .error_widget { border-top: solid 2px; border-bottom: solid 2px; margin: 5px 0; padding: 10px 40px; white-space: pre-wrap; } .error_widget.ace_error, .error_widget_arrow.ace_error{ border-color: #ff5a5a } .error_widget.ace_warning, .error_widget_arrow.ace_warning{ border-color: #F1D817 } .error_widget.ace_info, .error_widget_arrow.ace_info{ border-color: #5a5a5a } .error_widget.ace_ok, .error_widget_arrow.ace_ok{ border-color: #5aaa5a } .error_widget_arrow { position: absolute; border: solid 5px; border-top-color: transparent!important; border-right-color: transparent!important; border-left-color: transparent!important; top: -5px; }","")}),ace.define("ace/ace",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/dom","ace/lib/event","ace/editor","ace/edit_session","ace/undomanager","ace/virtual_renderer","ace/worker/worker_client","ace/keyboard/hash_handler","ace/placeholder","ace/multi_select","ace/mode/folding/fold_mode","ace/theme/textmate","ace/ext/error_marker","ace/config"],function(e,t,n){"use strict";e("./lib/fixoldbrowsers");var r=e("./lib/dom"),i=e("./lib/event"),s=e("./editor").Editor,o=e("./edit_session").EditSession,u=e("./undomanager").UndoManager,a=e("./virtual_renderer").VirtualRenderer;e("./worker/worker_client"),e("./keyboard/hash_handler"),e("./placeholder"),e("./multi_select"),e("./mode/folding/fold_mode"),e("./theme/textmate"),e("./ext/error_marker"),t.config=e("./config"),t.require=e,"function"=="function"&&(t.define=__webpack_require__(171)),t.edit=function(e){if(typeof e=="string"){var n=e;e=document.getElementById(n);if(!e)throw new Error("ace.edit can't find div #"+n)}if(e&&e.env&&e.env.editor instanceof s)return e.env.editor;var o="";if(e&&/input|textarea/i.test(e.tagName)){var u=e;o=u.value,e=r.createElement("pre"),u.parentNode.replaceChild(e,u)}else e&&(o=r.getInnerText(e),e.innerHTML="");var f=t.createEditSession(o),l=new s(new a(e));l.setSession(f);var c={document:f,editor:l,onResize:l.resize.bind(l,null)};return u&&(c.textarea=u),i.addListener(window,"resize",c.onResize),l.on("destroy",function(){i.removeListener(window,"resize",c.onResize),c.editor.container.env=null}),l.container.env=l.env=c,l},t.createEditSession=function(e,t){var n=new o(e,t);return n.setUndoManager(new u),n},t.EditSession=o,t.UndoManager=u,t.version="1.2.5"}); 36296 (function() { 36297 ace.require(["ace/ace"], function(a) { 36298 if (a) { 36299 a.config.init(true); 36300 a.define = ace.define; 36301 } 36302 if (!window.ace) 36303 window.ace = a; 36304 for (var key in a) if (a.hasOwnProperty(key)) 36305 window.ace[key] = a[key]; 36306 }); 36307 })(); 36308 36309 36310 /***/ }, 36311 /* 171 */ 36312 /***/ function(module, exports) { 36313 36314 module.exports = function() { throw new Error("define cannot be used indirect"); }; 36315 36316 36317 /***/ }, 36318 /* 172 */ 36319 /***/ function(module, exports) { 36320 36321 ace.define("ace/theme/monokai",["require","exports","module","ace/lib/dom"],function(e,t,n){t.isDark=!0,t.cssClass="ace-monokai",t.cssText=".ace-monokai .ace_gutter {background: #2F3129;color: #8F908A}.ace-monokai .ace_print-margin {width: 1px;background: #555651}.ace-monokai {background-color: #272822;color: #F8F8F2}.ace-monokai .ace_cursor {color: #F8F8F0}.ace-monokai .ace_marker-layer .ace_selection {background: #49483E}.ace-monokai.ace_multiselect .ace_selection.ace_start {box-shadow: 0 0 3px 0px #272822;}.ace-monokai .ace_marker-layer .ace_step {background: rgb(102, 82, 0)}.ace-monokai .ace_marker-layer .ace_bracket {margin: -1px 0 0 -1px;border: 1px solid #49483E}.ace-monokai .ace_marker-layer .ace_active-line {background: #202020}.ace-monokai .ace_gutter-active-line {background-color: #272727}.ace-monokai .ace_marker-layer .ace_selected-word {border: 1px solid #49483E}.ace-monokai .ace_invisible {color: #52524d}.ace-monokai .ace_entity.ace_name.ace_tag,.ace-monokai .ace_keyword,.ace-monokai .ace_meta.ace_tag,.ace-monokai .ace_storage {color: #F92672}.ace-monokai .ace_punctuation,.ace-monokai .ace_punctuation.ace_tag {color: #fff}.ace-monokai .ace_constant.ace_character,.ace-monokai .ace_constant.ace_language,.ace-monokai .ace_constant.ace_numeric,.ace-monokai .ace_constant.ace_other {color: #AE81FF}.ace-monokai .ace_invalid {color: #F8F8F0;background-color: #F92672}.ace-monokai .ace_invalid.ace_deprecated {color: #F8F8F0;background-color: #AE81FF}.ace-monokai .ace_support.ace_constant,.ace-monokai .ace_support.ace_function {color: #66D9EF}.ace-monokai .ace_fold {background-color: #A6E22E;border-color: #F8F8F2}.ace-monokai .ace_storage.ace_type,.ace-monokai .ace_support.ace_class,.ace-monokai .ace_support.ace_type {font-style: italic;color: #66D9EF}.ace-monokai .ace_entity.ace_name.ace_function,.ace-monokai .ace_entity.ace_other,.ace-monokai .ace_entity.ace_other.ace_attribute-name,.ace-monokai .ace_variable {color: #A6E22E}.ace-monokai .ace_variable.ace_parameter {font-style: italic;color: #FD971F}.ace-monokai .ace_string {color: #E6DB74}.ace-monokai .ace_comment {color: #75715E}.ace-monokai .ace_indent-guide {background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAEklEQVQImWPQ0FD0ZXBzd/wPAAjVAoxeSgNeAAAAAElFTkSuQmCC) right repeat-y}";var r=e("../lib/dom");r.importCssString(t.cssText,t.cssClass)}) 36322 36323 /***/ }, 36324 /* 173 */ 36325 /***/ function(module, exports) { 36326 36327 ace.define("ace/mode/yaml_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text_highlight_rules").TextHighlightRules,s=function(){this.$rules={start:[{token:"comment",regex:"#.*$"},{token:"list.markup",regex:/^(?:-{3}|\.{3})\s*(?=#|$)/},{token:"list.markup",regex:/^\s*[\-?](?:$|\s)/},{token:"constant",regex:"!![\\w//]+"},{token:"constant.language",regex:"[&\\*][a-zA-Z0-9-_]+"},{token:["meta.tag","keyword"],regex:/^(\s*\w.*?)(:(?:\s+|$))/},{token:["meta.tag","keyword"],regex:/(\w+?)(\s*:(?:\s+|$))/},{token:"keyword.operator",regex:"<<\\w*:\\w*"},{token:"keyword.operator",regex:"-\\s*(?=[{])"},{token:"string",regex:'["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'},{token:"string",regex:"[|>][-+\\d\\s]*$",next:"qqstring"},{token:"string",regex:"['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"},{token:"constant.numeric",regex:/(\b|[+\-\.])[\d_]+(?:(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)/},{token:"constant.numeric",regex:/[+\-]?\.inf\b|NaN\b|0x[\dA-Fa-f_]+|0b[10_]+/},{token:"constant.language.boolean",regex:"\\b(?:true|false|TRUE|FALSE|True|False|yes|no)\\b"},{token:"paren.lparen",regex:"[[({]"},{token:"paren.rparen",regex:"[\\])}]"}],qqstring:[{token:"string",regex:"(?=(?:(?:\\\\.)|(?:[^:]))*?:)",next:"start"},{token:"string",regex:".+"}]}};r.inherits(s,i),t.YamlHighlightRules=s}),ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("../range").Range,i=function(){};(function(){this.checkOutdent=function(e,t){return/^\s+$/.test(e)?/^\s*\}/.test(t):!1},this.autoOutdent=function(e,t){var n=e.getLine(t),i=n.match(/^(\s*\})/);if(!i)return 0;var s=i[1].length,o=e.findMatchingBracket({row:t,column:s});if(!o||o.row==t)return 0;var u=this.$getIndent(e.getLine(o.row));e.replace(new r(t,0,t,s-1),u)},this.$getIndent=function(e){return e.match(/^\s*/)[0]}}).call(i.prototype),t.MatchingBraceOutdent=i}),ace.define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"],function(e,t,n){"use strict";var r=e("../../lib/oop"),i=e("./fold_mode").FoldMode,s=e("../../range").Range,o=t.FoldMode=function(){};r.inherits(o,i),function(){this.getFoldWidgetRange=function(e,t,n){var r=this.indentationBlock(e,n);if(r)return r;var i=/\S/,o=e.getLine(n),u=o.search(i);if(u==-1||o[u]!="#")return;var a=o.length,f=e.getLength(),l=n,c=n;while(++n<f){o=e.getLine(n);var h=o.search(i);if(h==-1)continue;if(o[h]!="#")break;c=n}if(c>l){var p=e.getLine(c).length;return new s(l,a,c,p)}},this.getFoldWidget=function(e,t,n){var r=e.getLine(n),i=r.search(/\S/),s=e.getLine(n+1),o=e.getLine(n-1),u=o.search(/\S/),a=s.search(/\S/);if(i==-1)return e.foldWidgets[n-1]=u!=-1&&u<a?"start":"","";if(u==-1){if(i==a&&r[i]=="#"&&s[i]=="#")return e.foldWidgets[n-1]="",e.foldWidgets[n+1]="","start"}else if(u==i&&r[i]=="#"&&o[i]=="#"&&e.getLine(n-2).search(/\S/)==-1)return e.foldWidgets[n-1]="start",e.foldWidgets[n+1]="","";return u!=-1&&u<i?e.foldWidgets[n-1]="start":e.foldWidgets[n-1]="",i<a?"start":""}}.call(o.prototype)}),ace.define("ace/mode/yaml",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/yaml_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/coffee"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text").Mode,s=e("./yaml_highlight_rules").YamlHighlightRules,o=e("./matching_brace_outdent").MatchingBraceOutdent,u=e("./folding/coffee").FoldMode,a=function(){this.HighlightRules=s,this.$outdent=new o,this.foldingRules=new u};r.inherits(a,i),function(){this.lineCommentStart="#",this.getNextLineIndent=function(e,t,n){var r=this.$getIndent(t);if(e=="start"){var i=t.match(/^.*[\{\(\[]\s*$/);i&&(r+=n)}return r},this.checkOutdent=function(e,t,n){return this.$outdent.checkOutdent(t,n)},this.autoOutdent=function(e,t,n){this.$outdent.autoOutdent(t,n)},this.$id="ace/mode/yaml"}.call(a.prototype),t.Mode=a}) 36328 36329 /***/ }, 36330 /* 174 */ 36331 /***/ function(module, exports) { 36332 36333 ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text_highlight_rules").TextHighlightRules,s=function(){this.$rules={start:[{token:"comment.doc.tag",regex:"@[\\w\\d_]+"},s.getTagRule(),{defaultToken:"comment.doc",caseInsensitive:!0}]}};r.inherits(s,i),s.getTagRule=function(e){return{token:"comment.doc.tag.storage.type",regex:"\\b(?:TODO|FIXME|XXX|HACK)\\b"}},s.getStartRule=function(e){return{token:"comment.doc",regex:"\\/\\*(?=\\*)",next:e}},s.getEndRule=function(e){return{token:"comment.doc",regex:"\\*\\/",next:e}},t.DocCommentHighlightRules=s}),ace.define("ace/mode/javascript_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";function a(){var e=o.replace("\\d","\\d\\-"),t={onMatch:function(e,t,n){var r=e.charAt(1)=="/"?2:1;if(r==1)t!=this.nextState?n.unshift(this.next,this.nextState,0):n.unshift(this.next),n[2]++;else if(r==2&&t==this.nextState){n[1]--;if(!n[1]||n[1]<0)n.shift(),n.shift()}return[{type:"meta.tag.punctuation."+(r==1?"":"end-")+"tag-open.xml",value:e.slice(0,r)},{type:"meta.tag.tag-name.xml",value:e.substr(r)}]},regex:"</?"+e+"",next:"jsxAttributes",nextState:"jsx"};this.$rules.start.unshift(t);var n={regex:"{",token:"paren.quasi.start",push:"start"};this.$rules.jsx=[n,t,{include:"reference"},{defaultToken:"string"}],this.$rules.jsxAttributes=[{token:"meta.tag.punctuation.tag-close.xml",regex:"/?>",onMatch:function(e,t,n){return t==n[0]&&n.shift(),e.length==2&&(n[0]==this.nextState&&n[1]--,(!n[1]||n[1]<0)&&n.splice(0,2)),this.next=n[0]||"start",[{type:this.token,value:e}]},nextState:"jsx"},n,f("jsxAttributes"),{token:"entity.other.attribute-name.xml",regex:e},{token:"keyword.operator.attribute-equals.xml",regex:"="},{token:"text.tag-whitespace.xml",regex:"\\s+"},{token:"string.attribute-value.xml",regex:"'",stateName:"jsx_attr_q",push:[{token:"string.attribute-value.xml",regex:"'",next:"pop"},{include:"reference"},{defaultToken:"string.attribute-value.xml"}]},{token:"string.attribute-value.xml",regex:'"',stateName:"jsx_attr_qq",push:[{token:"string.attribute-value.xml",regex:'"',next:"pop"},{include:"reference"},{defaultToken:"string.attribute-value.xml"}]},t],this.$rules.reference=[{token:"constant.language.escape.reference.xml",regex:"(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"}]}function f(e){return[{token:"comment",regex:/\/\*/,next:[i.getTagRule(),{token:"comment",regex:"\\*\\/",next:e||"pop"},{defaultToken:"comment",caseInsensitive:!0}]},{token:"comment",regex:"\\/\\/",next:[i.getTagRule(),{token:"comment",regex:"$|^",next:e||"pop"},{defaultToken:"comment",caseInsensitive:!0}]}]}var r=e("../lib/oop"),i=e("./doc_comment_highlight_rules").DocCommentHighlightRules,s=e("./text_highlight_rules").TextHighlightRules,o="[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*",u=function(e){var t=this.createKeywordMapper({"variable.language":"Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|Namespace|QName|XML|XMLList|ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|SyntaxError|TypeError|URIError|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|isNaN|parseFloat|parseInt|JSON|Math|this|arguments|prototype|window|document",keyword:"const|yield|import|get|set|async|await|break|case|catch|continue|default|delete|do|else|finally|for|function|if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|__parent__|__count__|escape|unescape|with|__proto__|class|enum|extends|super|export|implements|private|public|interface|package|protected|static","storage.type":"const|let|var|function","constant.language":"null|Infinity|NaN|undefined","support.function":"alert","constant.language.boolean":"true|false"},"identifier"),n="case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void",r="\\\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|u{[0-9a-fA-F]{1,6}}|[0-2][0-7]{0,2}|3[0-7][0-7]?|[4-7][0-7]?|.)";this.$rules={no_regex:[i.getStartRule("doc-start"),f("no_regex"),{token:"string",regex:"'(?=.)",next:"qstring"},{token:"string",regex:'"(?=.)',next:"qqstring"},{token:"constant.numeric",regex:/0(?:[xX][0-9a-fA-F]+|[bB][01]+)\b/},{token:"constant.numeric",regex:/[+-]?\d[\d_]*(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/},{token:["storage.type","punctuation.operator","support.function","punctuation.operator","entity.name.function","text","keyword.operator"],regex:"("+o+")(\\.)(prototype)(\\.)("+o+")(\\s*)(=)",next:"function_arguments"},{token:["storage.type","punctuation.operator","entity.name.function","text","keyword.operator","text","storage.type","text","paren.lparen"],regex:"("+o+")(\\.)("+o+")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",next:"function_arguments"},{token:["entity.name.function","text","keyword.operator","text","storage.type","text","paren.lparen"],regex:"("+o+")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",next:"function_arguments"},{token:["storage.type","punctuation.operator","entity.name.function","text","keyword.operator","text","storage.type","text","entity.name.function","text","paren.lparen"],regex:"("+o+")(\\.)("+o+")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",next:"function_arguments"},{token:["storage.type","text","entity.name.function","text","paren.lparen"],regex:"(function)(\\s+)("+o+")(\\s*)(\\()",next:"function_arguments"},{token:["entity.name.function","text","punctuation.operator","text","storage.type","text","paren.lparen"],regex:"("+o+")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",next:"function_arguments"},{token:["text","text","storage.type","text","paren.lparen"],regex:"(:)(\\s*)(function)(\\s*)(\\()",next:"function_arguments"},{token:"keyword",regex:"(?:"+n+")\\b",next:"start"},{token:["support.constant"],regex:/that\b/},{token:["storage.type","punctuation.operator","support.function.firebug"],regex:/(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/},{token:t,regex:o},{token:"punctuation.operator",regex:/[.](?![.])/,next:"property"},{token:"keyword.operator",regex:/--|\+\+|\.{3}|===|==|=|!=|!==|<+=?|>+=?|!|&&|\|\||\?:|[!$%&*+\-~\/^]=?/,next:"start"},{token:"punctuation.operator",regex:/[?:,;.]/,next:"start"},{token:"paren.lparen",regex:/[\[({]/,next:"start"},{token:"paren.rparen",regex:/[\])}]/},{token:"comment",regex:/^#!.*$/}],property:[{token:"text",regex:"\\s+"},{token:["storage.type","punctuation.operator","entity.name.function","text","keyword.operator","text","storage.type","text","entity.name.function","text","paren.lparen"],regex:"("+o+")(\\.)("+o+")(\\s*)(=)(\\s*)(function)(?:(\\s+)(\\w+))?(\\s*)(\\()",next:"function_arguments"},{token:"punctuation.operator",regex:/[.](?![.])/},{token:"support.function",regex:/(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/},{token:"support.function.dom",regex:/(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName|ClassName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/},{token:"support.constant",regex:/(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/},{token:"identifier",regex:o},{regex:"",token:"empty",next:"no_regex"}],start:[i.getStartRule("doc-start"),f("start"),{token:"string.regexp",regex:"\\/",next:"regex"},{token:"text",regex:"\\s+|^$",next:"start"},{token:"empty",regex:"",next:"no_regex"}],regex:[{token:"regexp.keyword.operator",regex:"\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"},{token:"string.regexp",regex:"/[sxngimy]*",next:"no_regex"},{token:"invalid",regex:/\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/},{token:"constant.language.escape",regex:/\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/},{token:"constant.language.delimiter",regex:/\|/},{token:"constant.language.escape",regex:/\[\^?/,next:"regex_character_class"},{token:"empty",regex:"$",next:"no_regex"},{defaultToken:"string.regexp"}],regex_character_class:[{token:"regexp.charclass.keyword.operator",regex:"\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"},{token:"constant.language.escape",regex:"]",next:"regex"},{token:"constant.language.escape",regex:"-"},{token:"empty",regex:"$",next:"no_regex"},{defaultToken:"string.regexp.charachterclass"}],function_arguments:[{token:"variable.parameter",regex:o},{token:"punctuation.operator",regex:"[, ]+"},{token:"punctuation.operator",regex:"$"},{token:"empty",regex:"",next:"no_regex"}],qqstring:[{token:"constant.language.escape",regex:r},{token:"string",regex:"\\\\$",next:"qqstring"},{token:"string",regex:'"|$',next:"no_regex"},{defaultToken:"string"}],qstring:[{token:"constant.language.escape",regex:r},{token:"string",regex:"\\\\$",next:"qstring"},{token:"string",regex:"'|$",next:"no_regex"},{defaultToken:"string"}]};if(!e||!e.noES6)this.$rules.no_regex.unshift({regex:"[{}]",onMatch:function(e,t,n){this.next=e=="{"?this.nextState:"";if(e=="{"&&n.length)n.unshift("start",t);else if(e=="}"&&n.length){n.shift(),this.next=n.shift();if(this.next.indexOf("string")!=-1||this.next.indexOf("jsx")!=-1)return"paren.quasi.end"}return e=="{"?"paren.lparen":"paren.rparen"},nextState:"start"},{token:"string.quasi.start",regex:/`/,push:[{token:"constant.language.escape",regex:r},{token:"paren.quasi.start",regex:/\${/,push:"start"},{token:"string.quasi.end",regex:/`/,next:"pop"},{defaultToken:"string.quasi"}]}),(!e||e.jsx!=0)&&a.call(this);this.embedRules(i,"doc-",[i.getEndRule("no_regex")]),this.normalizeRules()};r.inherits(u,s),t.JavaScriptHighlightRules=u}),ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("../range").Range,i=function(){};(function(){this.checkOutdent=function(e,t){return/^\s+$/.test(e)?/^\s*\}/.test(t):!1},this.autoOutdent=function(e,t){var n=e.getLine(t),i=n.match(/^(\s*\})/);if(!i)return 0;var s=i[1].length,o=e.findMatchingBracket({row:t,column:s});if(!o||o.row==t)return 0;var u=this.$getIndent(e.getLine(o.row));e.replace(new r(t,0,t,s-1),u)},this.$getIndent=function(e){return e.match(/^\s*/)[0]}}).call(i.prototype),t.MatchingBraceOutdent=i}),ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"],function(e,t,n){"use strict";var r=e("../../lib/oop"),i=e("../../range").Range,s=e("./fold_mode").FoldMode,o=t.FoldMode=function(e){e&&(this.foldingStartMarker=new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/,"|"+e.start)),this.foldingStopMarker=new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/,"|"+e.end)))};r.inherits(o,s),function(){this.foldingStartMarker=/(\{|\[)[^\}\]]*$|^\s*(\/\*)/,this.foldingStopMarker=/^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/,this.singleLineBlockCommentRe=/^\s*(\/\*).*\*\/\s*$/,this.tripleStarBlockCommentRe=/^\s*(\/\*\*\*).*\*\/\s*$/,this.startRegionRe=/^\s*(\/\*|\/\/)#?region\b/,this._getFoldWidgetBase=this.getFoldWidget,this.getFoldWidget=function(e,t,n){var r=e.getLine(n);if(this.singleLineBlockCommentRe.test(r)&&!this.startRegionRe.test(r)&&!this.tripleStarBlockCommentRe.test(r))return"";var i=this._getFoldWidgetBase(e,t,n);return!i&&this.startRegionRe.test(r)?"start":i},this.getFoldWidgetRange=function(e,t,n,r){var i=e.getLine(n);if(this.startRegionRe.test(i))return this.getCommentRegionBlock(e,i,n);var s=i.match(this.foldingStartMarker);if(s){var o=s.index;if(s[1])return this.openingBracketBlock(e,s[1],n,o);var u=e.getCommentFoldRange(n,o+s[0].length,1);return u&&!u.isMultiLine()&&(r?u=this.getSectionRange(e,n):t!="all"&&(u=null)),u}if(t==="markbegin")return;var s=i.match(this.foldingStopMarker);if(s){var o=s.index+s[0].length;return s[1]?this.closingBracketBlock(e,s[1],n,o):e.getCommentFoldRange(n,o,-1)}},this.getSectionRange=function(e,t){var n=e.getLine(t),r=n.search(/\S/),s=t,o=n.length;t+=1;var u=t,a=e.getLength();while(++t<a){n=e.getLine(t);var f=n.search(/\S/);if(f===-1)continue;if(r>f)break;var l=this.getFoldWidgetRange(e,"all",t);if(l){if(l.start.row<=s)break;if(l.isMultiLine())t=l.end.row;else if(r==f)break}u=t}return new i(s,o,u,e.getLine(u).length)},this.getCommentRegionBlock=function(e,t,n){var r=t.search(/\s*$/),s=e.getLength(),o=n,u=/^\s*(?:\/\*|\/\/|--)#?(end)?region\b/,a=1;while(++n<s){t=e.getLine(n);var f=u.exec(t);if(!f)continue;f[1]?a--:a++;if(!a)break}var l=n;if(l>o)return new i(o,r,l,t.length)}}.call(o.prototype)}),ace.define("ace/mode/javascript",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/javascript_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text").Mode,s=e("./javascript_highlight_rules").JavaScriptHighlightRules,o=e("./matching_brace_outdent").MatchingBraceOutdent,u=e("../range").Range,a=e("../worker/worker_client").WorkerClient,f=e("./behaviour/cstyle").CstyleBehaviour,l=e("./folding/cstyle").FoldMode,c=function(){this.HighlightRules=s,this.$outdent=new o,this.$behaviour=new f,this.foldingRules=new l};r.inherits(c,i),function(){this.lineCommentStart="//",this.blockComment={start:"/*",end:"*/"},this.getNextLineIndent=function(e,t,n){var r=this.$getIndent(t),i=this.getTokenizer().getLineTokens(t,e),s=i.tokens,o=i.state;if(s.length&&s[s.length-1].type=="comment")return r;if(e=="start"||e=="no_regex"){var u=t.match(/^.*(?:\bcase\b.*:|[\{\(\[])\s*$/);u&&(r+=n)}else if(e=="doc-start"){if(o=="start"||o=="no_regex")return"";var u=t.match(/^\s*(\/?)\*/);u&&(u[1]&&(r+=" "),r+="* ")}return r},this.checkOutdent=function(e,t,n){return this.$outdent.checkOutdent(t,n)},this.autoOutdent=function(e,t,n){this.$outdent.autoOutdent(t,n)},this.createWorker=function(e){var t=new a(["ace"],"ace/mode/javascript_worker","JavaScriptWorker");return t.attachToDocument(e.getDocument()),t.on("annotate",function(t){e.setAnnotations(t.data)}),t.on("terminate",function(){e.clearAnnotations()}),t},this.$id="ace/mode/javascript"}.call(c.prototype),t.Mode=c}) 36334 36335 /***/ }, 36336 /* 175 */ 36337 /***/ function(module, exports, __webpack_require__) { 36338 36339 'use strict';var _backbone=__webpack_require__(113),_backbone2=_interopRequireDefault(_backbone),_underscore=__webpack_require__(114),_underscore2=_interopRequireDefault(_underscore);__webpack_require__(164);__webpack_require__(166);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}const Form=_backbone2.default.Form;Form.template=_underscore2.default.template('<form class="gohan-form" role="form"> <div class="required-description"><span class="form-asterisk">*</span> Indicates required field</div> <div data-fieldsets></div></form>'),Form.Fieldset.template=_underscore2.default.template('<fieldset data-fields> <% if (legend) { %> <legend><%= legend %></legend> <% } %></fieldset>'),Form.Field.template=_underscore2.default.template('<div class="nested-form-group field-<%= key %>"> <label class="control-label" for="<%= editorId %>"><%= title %></label> <% if (help) { %> <span class="help-description"> <%= help %></span> <% } %> <div class="controls"> <span data-editor></span> <div class="help-block"><span class="error" data-error></span></div> </div></div>'),Form.NestedField=Form.Field.extend({template:_underscore2.default.template('<div class="nested-form-group field-<%= key %>"> <label class="control-label" for="<%= editorId %>"><%= title %></label> <% if (help) { %> <span class="help-description"> <%= help %></span> <% } %> <div class="controls"> <span data-editor></span> <div class="help-block"><span class="error" data-error></span></div> </div></div>',null,Form.templateSettings)}),Form.editors.Base.prototype.className='form-control',Form.Field.errorClassName='has-error',Form.editors.List&&(Form.editors.List.template=_underscore2.default.template('<div class="list-container"> <ul class="list-sortable" data-items></ul> <a class="add-item" data-action="add"><span class="fa fa-plus-circle"></span> Add Item</a></div>'),Form.editors.List.Item.template=_underscore2.default.template('<li class="list-item-container"> <div class="list-action"> <span class="fa fa-minus-circle" data-action="remove" title="Remove Item"></span> </div> <div class="list-counter"></div> <div class="list-body"> <span data-editor></span> <div class="help-block"><span class="error" data-error></span></div> </div> <div class="list-sort up"> <a class="" data-action="move-left"><span class="fa fa-chevron-circle-up"></span>Up</a> </div> <div class="list-sort down"> <a class="" data-action="move-right"><span class="fa fa-chevron-circle-down"></span>Down</a> </div></li>')); 36340 36341 /***/ }, 36342 /* 176 */ 36343 /***/ function(module, exports, __webpack_require__) { 36344 36345 'use strict';var _backbone=__webpack_require__(113),_backbone2=_interopRequireDefault(_backbone);__webpack_require__(164);var _jsYaml=__webpack_require__(121),_jsYaml2=_interopRequireDefault(_jsYaml);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}_backbone2.default.Form.validators.errMessages.ipv4='The specified IP address has an invalid format.',_backbone2.default.Form.validators.errMessages.ipv6='The specified IP address has an invalid format.',_backbone2.default.Form.validators.errMessages.ipv4mask='The specified IP mask has an invalid format.',_backbone2.default.Form.validators.errMessages.cidr='The specified CIDR has an invalid format.',_backbone2.default.Form.validators.errMessages.mac='The specified MAC address has an invalid format.',_backbone2.default.Form.validators.errMessages.uuid='The specified UUID has an invalid format.',_backbone2.default.Form.validators.errMessages.port='The specified port has an invalid format.',_backbone2.default.Form.validators.errMessages.hostname='The specified hostname has an invalid format.',_backbone2.default.Form.validators.errMessages.uri='The specified uri has an invalid format.',_backbone2.default.Form.validators.errMessages['cidr-or-ipv4']='The specified CIDR or IP has an invalid format.',_backbone2.default.Form.validators.errMessages.yaml='The specified yaml has an invalid format.',_backbone2.default.Form.validators.ipv4=function(b){return b=Object.assign({type:'ipv4',message:this.errMessages.ipv4},b),c=>{const d=/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(c);if(b.value=c,!d&&c)return{type:b.type,message:b.message}}},_backbone2.default.Form.validators.ipv6=function(b){return b=Object.assign({type:'ipv6',message:this.errMessages.ipv6},b),c=>{const d=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/.test(c);if(b.value=c,!d&&c){const e={type:b.type,message:b.message};return e}}},_backbone2.default.Form.validators.ipv4mask=function(b){return b=Object.assign({type:'ipv4mask',message:this.errMessages.ipv4mask},b),c=>{const d=/^\d+$/.test(c)&&1<=c&&32>=c;if(b.value=c,!d&&c){const e={type:b.type,message:b.message};return e}}},_backbone2.default.Form.validators.cidr=function(b){const c=_backbone2.default.Form.validators.ipv4(b),d=_backbone2.default.Form.validators.ipv4mask(b);return b=Object.assign({},{type:'cidr',message:this.errMessages.cidr},b),e=>{const f=e.split('/'),g=f[0],h=f[1],i=c(g),j=d(h);if(b.value=e,i||j){const k={type:b.type,message:b.message};return k}}},_backbone2.default.Form.validators.mac=function(b){return b=Object.assign({type:'mac',message:this.errMessages.mac},b),c=>{const d=/^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$/.test(c);if(b.value=c,!d&&c){const e={type:b.type,message:b.message};return e}}},_backbone2.default.Form.validators.uuid=function(b){return b=Object.assign({type:'uuid',message:this.errMessages.uuid},b),c=>{const d=[/^[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[1-5][A-Fa-f0-9]{3}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}$/,/^[A-Fa-f0-9]{8}[A-Fa-f0-9]{4}[1-5][A-Fa-f0-9]{3}[A-Fa-f0-9]{4}[A-Fa-f0-9]{12}$/],e=d.some(f=>{return f.test(c)});if(b.value=c,!e&&c){const f={type:b.type,message:b.message};return f}}},_backbone2.default.Form.validators.port=function(b){return b=Object.assign({type:'port',message:this.errMessages.port},b),c=>{const d=/^\d+$/.test(c)&&1<=c&&65535>=c;if(b.value=c,!d&&c){const e={type:b.type,message:b.message};return e}}},_backbone2.default.Form.validators.hostname=function(b){return b=Object.assign({type:'hostname',message:this.errMessages.hostname},b),c=>{const d=/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$/.test(c);if(b.value=c,!d&&c){const e={type:b.type,message:b.message};return e}}},_backbone2.default.Form.validators.uri=function(b){return b=Object.assign({type:'uri',message:this.errMessages.uri},b),c=>{const d=/([A-Za-z][A-Za-z0-9+\-.]*):(?:(\/\/)(?:((?:[A-Za-z0-9\-._~!$&'()*+,;=:]|%[0-9A-Fa-f]{2})*)@)?((?:\[(?:(?:(?:(?:[0-9A-Fa-f]{1,4}:){6}|::(?:[0-9A-Fa-f]{1,4}:){5}|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){4}|(?:(?:[0-9A-Fa-f]{1,4}:){0,1}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){3}|(?:(?:[0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,4}:){2}|(?:(?:[0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}:|(?:(?:[0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})?::)(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))|(?:(?:[0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})?::)|[Vv][0-9A-Fa-f]+\.[A-Za-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|(?:[A-Za-z0-9\-._~!$&'()*+,;=]|%[0-9A-Fa-f]{2})*))(?::([0-9]*))?((?:\/(?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f]{2})*)*)|\/((?:(?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f]{2})+(?:\/(?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f]{2})*)*)?)|((?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f]{2})+(?:\/(?:[A-Za-z0-9\-._~!$&'()*+,;=:@]|%[0-9A-Fa-f]{2})*)*)|)(?:\?((?:[A-Za-z0-9\-._~!$&'()*+,;=:@\/?]|%[0-9A-Fa-f]{2})*))?(?:\#((?:[A-Za-z0-9\-._~!$&'()*+,;=:@\/?]|%[0-9A-Fa-f]{2})*))?/.test(c);if(b.value=c,!d&&c){const e={type:b.type,message:b.message};return e}}},_backbone2.default.Form.validators['cidr-or-ipv4']=function(b){const c=_backbone2.default.Form.validators.ipv4(b),d=_backbone2.default.Form.validators.ipv4mask(b);return b=Object.assign({},{type:'cidr-or-ipv4',message:this.errMessages['cidr-or-ipv4']},b),e=>{const f=e.split('/'),g=f[0],h=f[1],i=c(g),j=d(h);if((b.value=e,i||1!==f.length)&&(i||j||2!==f.length)){const k={type:b.type,message:b.message};return k}}},_backbone2.default.Form.validators.yaml=function(b){return b=Object.assign({type:'yaml',message:this.errMessages.yaml},b),c=>{let d;try{let e=_jsYaml2.default.load(c);if('object'===(typeof e).toLowerCase())throw Error()}catch(e){d=e}if(b.value=c,!d&&c){const e={type:b.type,message:b.message};return e}}}; 36346 36347 /***/ }, 36348 /* 177 */ 36349 /***/ function(module, exports, __webpack_require__) { 36350 36351 'use strict';var _backbone=__webpack_require__(113),_backbone2=_interopRequireDefault(_backbone),_underscore=__webpack_require__(114),_underscore2=_interopRequireDefault(_underscore);__webpack_require__(164);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}class SelectEditor extends _backbone2.default.Form.editors.Select{setValue(c){c&&super.setValue(c)}_arrayToHtml(c){return c.reduce((d,e)=>{if(!(e instanceof Object&&!Array.isArray(e))){if(null===e)return d.push('<option value="">Not selected</option>'),d;d.push(`<option>${_underscore2.default.escape(e)}</option>`)}else if(e.group)d.push(`<optgroup label="${_underscore2.default.escape(e.group)}">`),d.push(this._getOptionsHtml(e.options)),d.push('</optgroup>');else{const f=e.val||0===e.val?e.val:'';d.push(`<option value="${f}">${_underscore2.default.escape(e.label)}</option>`)}return d},[]).join('')}render(){const c={container:'body',width:'100%'},d=Object.keys(this.schema.options).length;if(this.schema.options instanceof Array)this.setOptions(this.schema.options);else{const e=Object.keys(this.schema.options).sort((f,g)=>this.schema.options[f].localeCompare(this.schema.options[g])).reduce((f,g)=>{return f[g]=this.schema.options[g],f},(()=>{return this.schema.nullable&&!this.schema.validators.includes('required')?{'':'Not selected'}:{}})());this.setOptions(e)}return 6<=d&&(c.liveSearch=!0),this.$el.addClass('selectpicker'),setTimeout(()=>{this.$el.selectpicker(c)},0),this}}_backbone2.default.Form.editors.Select=SelectEditor; 36352 36353 /***/ }, 36354 /* 178 */ 36355 /***/ function(module, exports, __webpack_require__) { 36356 36357 'use strict';var _backbone=__webpack_require__(113),_backbone2=_interopRequireDefault(_backbone);__webpack_require__(164);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}class NumberEditor extends _backbone2.default.Form.editors.Number{get defaultValue(){return''}getValue(){const a=this.$el.val();return''===a?'':parseFloat(a,10)}}_backbone2.default.Form.editors.Number=NumberEditor; 36358 36359 /***/ }, 36360 /* 179 */ 36361 /***/ function(module, exports) { 36362 36363 module.exports = function(obj){ 36364 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 36365 with(obj||{}){ 36366 __p+='<div class="sk-three-bounce">\n <div class="sk-child sk-bounce1"></div>\n <div class="sk-child sk-bounce2"></div>\n <div class="sk-child sk-bounce3"></div>\n</div>\n'; 36367 } 36368 return __p; 36369 }; 36370 36371 36372 /***/ }, 36373 /* 180 */ 36374 /***/ function(module, exports) { 36375 36376 module.exports = function(obj){ 36377 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 36378 with(obj||{}){ 36379 __p+='<a class=\'btn btn-default btn-sm\'\n tabindex="0"\n role="button"\n data-placement=\'auto\'\n data-trigger=\'click\'\n data-toggle=\'popover\'\n data-html=\'true\'\n data-content=\''+ 36380 ((__t=( content ))==null?'':__t)+ 36381 '\'>view</a>\n'; 36382 } 36383 return __p; 36384 }; 36385 36386 36387 /***/ }, 36388 /* 181 */ 36389 /***/ function(module, exports, __webpack_require__) { 36390 36391 /* WEBPACK VAR INJECTION */(function(_) {module.exports = function(obj){ 36392 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 36393 with(obj||{}){ 36394 __p+=''; 36395 36396 const totalResource = data.length; 36397 const selectedResource = 36398 uiState.map(function(elm) { 36399 if (elm.isSelected) { 36400 return 1; 36401 } else { 36402 return 0; 36403 } 36404 }).reduce(function(a, b) { 36405 return a + b; 36406 }, 0); 36407 36408 __p+='\n\n<div class="container-fluid gohan-table-header">\n <div class="row">\n <div class="col-sm-4 resource-name">\n <h2>'+ 36409 ((__t=( schema.title ))==null?'':_.escape(__t))+ 36410 '</h2>\n </div>\n <div class="col-sm-8 actions">\n <form class="form-inline">\n <div class="form-group" data-gohan="search">\n <span class="filterby">Filter by</span>\n <select class="form-control" placeholder="Filter By">\n'; 36411 36412 schema.schema.propertiesOrder.forEach(function(key) { 36413 const property = schema.schema.properties[key]; 36414 const view = property['view'] 36415 if(view && !view.includes('list') || key === parentProperty) { 36416 return; 36417 } 36418 36419 __p+='\n <option value="'+ 36420 ((__t=( key ))==null?'':__t)+ 36421 '" '+ 36422 ((__t=( key === searchQuery.property ? 'selected' : ''))==null?'':__t)+ 36423 '>'+ 36424 ((__t=( property.title ))==null?'':__t)+ 36425 '</option>\n'; 36426 36427 }); 36428 36429 __p+='\n </select>\n <input type="text" class="form-control" placeholder="Search" value="'+ 36430 ((__t=( searchQuery.value ))==null?'':__t)+ 36431 '">\n'; 36432 36433 if (selectedResource > 0) { 36434 36435 __p+='\n <a class="btn btn-danger" data-gohan="delete-all">Delete Selected</a>\n'; 36436 36437 }; 36438 36439 __p+='\n <a class="btn btn-primary gohan_create" data-gohan="create"><strong>+</strong> New</a>\n </div>\n </form>\n </div>\n </div>\n</div>\n<div data-gohan="error"></div>\n<div class="card">\n <table class="table gohan-table">\n <thead>\n <tr>\n <th class="checkbox-col">\n'; 36440 36441 const allAriaCheckState = 36442 (selectedResource === 0) ? 'false' : 36443 (totalResource === selectedResource) ? 'true' : 'mixed'; 36444 36445 const allCheckboxState = 36446 (selectedResource === 0) ? 'fa-square-o' : 36447 (totalResource === selectedResource) ? 'fa-check-square' : 'fa-minus-square-o'; 36448 36449 __p+='\n <span class="gohan-checkbox" role="checkbox" aria-checked="'+ 36450 ((__t=( allAriaCheckState ))==null?'':__t)+ 36451 '" tabindex="0" aria-label="checkbox">\n <span data-gohan="toggle-all-row" class="fa '+ 36452 ((__t=( allCheckboxState ))==null?'':__t)+ 36453 '"></span>\n </span>\n </th>\n'; 36454 36455 let columns = 2; 36456 schema.schema.propertiesOrder.forEach(function(key) { 36457 const property = schema.schema.properties[key]; 36458 const view = property['view']; 36459 36460 if(view && !view.includes('list') || key === parentProperty) { 36461 return; 36462 } 36463 columns ++; 36464 36465 __p+='\n <th>\n <a href="#/'+ 36466 ((__t=( schema.url.substring(1) ))==null?'':__t)+ 36467 '" data-id="'+ 36468 ((__t=( key ))==null?'':__t)+ 36469 '" class="title" data-gohan="sort-title">'+ 36470 ((__t=( property.title ))==null?'':__t)+ 36471 '\n '; 36472 if(sort.by === key) { 36473 if(sort.reverse) { 36474 __p+='\n <div class="glyphicon glyphicon-sort-by-alphabet-alt"></div>\n '; 36475 } else { 36476 __p+='\n <div class="glyphicon glyphicon-sort-by-alphabet"></div>\n '; 36477 } 36478 } 36479 __p+='\n </a>\n </th>\n'; 36480 36481 }); 36482 36483 __p+='\n <th></th>\n </tr>\n </thead>\n <tbody id="page'+ 36484 ((__t=( key + 1 ))==null?'':__t)+ 36485 '" >\n'; 36486 36487 if (data.length === 0) { 36488 36489 __p+='\n <tr><td colspan="'+ 36490 ((__t=( columns ))==null?'':__t)+ 36491 '" class="no-data">No Data</td></tr>\n'; 36492 36493 } else { 36494 data.forEach(function(d, i) { 36495 const isSelected = uiState[i].isSelected; 36496 const isDeleting = uiState[i].isDeleting; 36497 const checkboxState = (isSelected)? 'fa-check-square' : 'fa-square-o'; 36498 const checkboxDisable = (isDeleting)? 'disabled' : ''; 36499 const trState = (isDeleting) ? 'active' : (isSelected) ? 'info' : ''; 36500 36501 __p+='\n <tr class="'+ 36502 ((__t=( trState ))==null?'':__t)+ 36503 '">\n <td class="checkbox-col">\n <span class="gohan-checkbox" role="checkbox" aria-disabled="'+ 36504 ((__t=( String(isDeleting) ))==null?'':__t)+ 36505 '" aria-checked="'+ 36506 ((__t=( String(isSelected) ))==null?'':__t)+ 36507 '" tabindex="0" aria-label="checkbox">\n <span data-gohan="toggle-row" class="'+ 36508 ((__t=( checkboxDisable ))==null?'':__t)+ 36509 ' fa '+ 36510 ((__t=( checkboxState ))==null?'':__t)+ 36511 '" data-id='+ 36512 ((__t=( d.id ))==null?'':__t)+ 36513 '></span>\n </span>\n </td>\n'; 36514 36515 schema.schema.propertiesOrder.forEach(function(key) { 36516 const property = schema.schema.properties[key]; 36517 const view = property['view'] 36518 36519 if(view && !view.includes('list') || key === parentProperty) { 36520 return; 36521 } 36522 36523 const title = property.title.toLowerCase(); 36524 const urlPattern = /^((http|https):\/\/)/; 36525 36526 if (property['format'] === 'uri' && urlPattern.test(d[key])) { 36527 36528 __p+='\n <td><a href="'+ 36529 ((__t=( d[key] ))==null?'':_.escape(__t))+ 36530 '"> link </a></td>\n'; 36531 36532 } else if (title === 'name' || title === 'title') { 36533 36534 __p+='\n <td><a data-id="'+ 36535 ((__t=( d[key] ))==null?'':__t)+ 36536 '" href="#/'+ 36537 ((__t=( fragment ))==null?'':__t)+ 36538 '/'+ 36539 ((__t=( d.id ))==null?'':__t)+ 36540 '">'+ 36541 ((__t=( d[key] ))==null?'':__t)+ 36542 '</a></td>\n'; 36543 36544 } else { 36545 36546 __p+='\n <td>'+ 36547 ((__t=( d[key] ))==null?'':__t)+ 36548 '</td>\n'; 36549 36550 } 36551 36552 __p+='\n'; 36553 36554 }); 36555 36556 __p+='\n <td class="action_column">\n'; 36557 36558 if (isDeleting) { 36559 36560 __p+='\n <span class="deleting">Deleting...</span>\n'; 36561 36562 } else { 36563 36564 __p+='\n <a class="action-icon" data-id="'+ 36565 ((__t=( d['id']))==null?'':_.escape(__t))+ 36566 '" data-gohan="update" data-toggle="tooltip" data-placement="top" title="Edit"><span class="glyphicon glyphicon-pencil" aria-label="Edit"></span></a><a class="action-icon" data-id="'+ 36567 ((__t=( d['id']))==null?'':_.escape(__t))+ 36568 '" data-gohan="delete" data-toggle="tooltip" data-placement="top" title="Delete"><span class="glyphicon glyphicon-trash" aria-label="Delete"></span></a>\n'; 36569 36570 } 36571 36572 __p+='\n </td>\n </tr>\n'; 36573 36574 }); 36575 36576 __p+='\n'; 36577 36578 } 36579 36580 __p+='\n </tbody>\n </table>\n</div>\n\n'; 36581 if (pageCount > 1) { 36582 __p+='\n<nav data-gohan="pagination">\n <ul class="pagination pagination-sm">\n <li '; 36583 if (activePage === 1) { 36584 __p+=' class="disabled" '; 36585 } 36586 __p+='>\n <a data-id="prev" aria-label="Previous">\n <span aria-hidden="true">«</span>\n </a>\n </li>\n '; 36587 if(pagination.start !== 1) { 36588 __p+='\n <li><a data-id="'+ 36589 ((__t=( pagination.start - 1 ))==null?'':__t)+ 36590 '" data-more="'+ 36591 ((__t=( 'left' ))==null?'':__t)+ 36592 '">'+ 36593 ((__t=((pagination.start - pagination.limit + 1) +'...' + (pagination.start - 1) ))==null?'':__t)+ 36594 '</a></li>\n '; 36595 } 36596 __p+='\n '; 36597 for (var key = pagination.start; key <= pagination.start + pagination.limit - 1 && key <= pageCount; key++) { 36598 if(key === pagination.start + pagination.limit - 1) { 36599 36600 __p+='\n <li ><a data-id="'+ 36601 ((__t=( key ))==null?'':__t)+ 36602 '" data-more="right">'+ 36603 ((__t=( key + '...' + pageCount ))==null?'':__t)+ 36604 '</a></li>\n '; 36605 } else { 36606 36607 __p+='\n <li '; 36608 if (key === activePage) { 36609 __p+=' class="active" '; 36610 } 36611 __p+='><a data-id="'+ 36612 ((__t=( key ))==null?'':__t)+ 36613 '">'+ 36614 ((__t=( key ))==null?'':__t)+ 36615 '</a></li>\n '; 36616 36617 } 36618 } 36619 __p+='\n <li '; 36620 if (activePage === pageCount) { 36621 __p+=' class="disabled" '; 36622 } 36623 __p+='>\n <a data-id="next" aria-label="Next">\n <span aria-hidden="true">»</span>\n </a>\n </li>\n </ul>\n</nav>\n'; 36624 } 36625 __p+='\n'; 36626 } 36627 return __p; 36628 }; 36629 36630 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(114))) 36631 36632 /***/ }, 36633 /* 182 */ 36634 /***/ function(module, exports, __webpack_require__) { 36635 36636 /* WEBPACK VAR INJECTION */(function($) {'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _backbone=__webpack_require__(113),_underscore=__webpack_require__(114),_underscore2=_interopRequireDefault(_underscore),_jsYaml=__webpack_require__(121),_jsYaml2=_interopRequireDefault(_jsYaml),_bootstrapDialog=__webpack_require__(85),_bootstrapDialog2=_interopRequireDefault(_bootstrapDialog),_dialogView=__webpack_require__(161),_dialogView2=_interopRequireDefault(_dialogView),_errorView=__webpack_require__(162),_errorView2=_interopRequireDefault(_errorView),_tableView=__webpack_require__(160),_tableView2=_interopRequireDefault(_tableView),_loader=__webpack_require__(179),_loader2=_interopRequireDefault(_loader),_detail=__webpack_require__(183),_detail2=_interopRequireDefault(_detail);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}class DetailView extends _backbone.View{get tagName(){return'div'}get className(){return'detailview'}get events(){return{'click [data-gohan="update"]':'update','click [data-gohan="delete"]':'delete'}}constructor(a){super(a),this.app=a.app,this.errorView=this.app.ErrorClass?new this.app.ErrorClass:new _errorView2.default,this.template=a.template||_detail2.default,this.loaderTemplate=a.loaderTemplate||_loader2.default,this.TableViewClass=a.TableViewClass||_tableView2.default,this.schema=a.schema,this.childview=a.childview,this.model=a.model,this.fragment=a.fragment,this.$el.html(this.loaderTemplate()),this.model.fetch().then(()=>this.render(),b=>this.errorView.render(...b))}dialogForm(a,b,c,d,e){this.schema.filterByAction(a,this.parentProperty).then(f=>{this.dialog=new _dialogView2.default({app:this.app,formTitle:b,data:c,onsubmit:d,onhide:e,unformattedSchema:this.schema,schema:this.schema.toFormJSON(f),fields:f.propertiesOrder}),this.dialog.render()})}toLocal(a){return this.schema.toLocal(a)}toServer(a){return this.schema.toServer(a)}delete(a){a.preventDefault(),_bootstrapDialog2.default.confirm({title:'Delete',message:'Are you sure to delete?',closable:!0,btnOKLabel:'Delete',callback:b=>{b&&this.model.destroy().then(()=>{history.back()},c=>{this.errorView.render(...c)})}})}update(a){a.preventDefault(),a.currentTarget.disabled=!0;const b=this.model,c=this.toLocal(b.toJSON()),d='<h4>Update '+this.schema.get('title')+'</h4>';this.dialogForm('update',d,c,e=>{e=this.toServer(e),b.save(e).then(()=>{this.dialog.close(),this.render()},f=>{this.dialog.errorView.render(...f),this.dialog.stopSpin()})},()=>{a.currentTarget.disabled=!1})}renderProperty(a,b){let c;const d=this.schema.get('schema').properties[b],e=a[b];if(void 0===e)return'';if(void 0===d)return'';const f=a[d.relation_property];// jscs:ignore requireCamelCaseOrUpperCaseIdentifiers 36637 return void 0!==f&&void 0!==f.name?f.name:d.type.includes('object')||d.originalType&&d.originalType.includes('object')?(c=$('<pre style="width:500px;"></pre>').text(_jsYaml2.default.safeDump(e)).html(),'<pre>'+_underscore2.default.escape(c)+'</pre>'):'array'===d.type?'<pre>'+_jsYaml2.default.safeDump(e)+'</pre>':'string'===d.type&&'yaml'===d.format?'<pre>'+_underscore2.default.escape(e)+'</pre>':_underscore2.default.escape(e)}render(){const a=this.model.toJSON(),b=Object.assign({},a);for(let d in a)b[d]=this.renderProperty(a,d);const c=this.schema.children().map(d=>{const e=this.fragment+'/'+d.get('plural');return{id:d.id,title:d.get('title'),href:e}});return this.$el.html(this.template({data:b,schema:this.schema.toJSON(),children:c})),$('[data-gohan="error"]',this.el).append(this.errorView.el),this.app.router.changeTitle(this.model.get('name')||this.model.get('id')),this.model.getAncestors(d=>{d.unshift(this.model);const e=d.reduce((f,g)=>{const h=g.schema.get('url');let i,j;return g.schema.hasParent()?(i=g.schema.parent().get('url')+'/'+g.parentId()+'/'+g.schema.get('plural')+'/'+g.get('id'),j=g.schema.parent().get('url')+'/'+g.parentId()+'/'+g.schema.get('plural')):(i=g.schema.get('url')+'/'+g.get('id'),j=h),f.push({title:g.get('name'),url:i},{title:g.schema.get('title'),url:j}),f},[]);e.reverse(),this.app.breadCrumb.update(e)}),this.schema.children().forEach(d=>{const e=this.fragment+'/'+d.get('plural'),f=this.schema.apiEndpointBase()+'/'+e,g=d.makeCollection(f),h=new this.TableViewClass({schema:d,collection:g,childview:!0,fragment:this.fragment+'/'+d.get('plural'),app:this.app});return $('div#'+d.id+'_table',this.$el).html(h.render().el),{title:d.get('title'),href:e,element:h.render().el}}),this.$('button[data-toggle=hover]').popover(),this}}exports.default=DetailView;/* global $, history */ 36638 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71))) 36639 36640 /***/ }, 36641 /* 183 */ 36642 /***/ function(module, exports, __webpack_require__) { 36643 36644 /* WEBPACK VAR INJECTION */(function(_) {module.exports = function(obj){ 36645 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 36646 with(obj||{}){ 36647 __p+='<div data-gohan="error"></div>\n<div class="card gohan-detail-container">\n <div class="container-fluid">\n <div class="row gohan-detail-header">\n <div class="col-sm-8 resource-name"><h2>'+ 36648 ((__t=( schema.title ))==null?'':_.escape(__t))+ 36649 '</h2></div>\n <div class="col-sm-4 actions">\n <a class="edit" data-gohan="update" href="#"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>Edit</a><a class="edit" data-gohan="delete" href="#"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span>Delete</a>\n </div>\n </div>\n'; 36650 36651 schema.schema.propertiesOrder.forEach(function(key) { 36652 const property = schema.schema.properties[key]; 36653 const view = property['view']; 36654 if (view && !view.includes('detail')) { 36655 return; 36656 } 36657 36658 __p+='\n <div class="row gohan-detail-property">\n <div class="col-sm-3 property-title">'+ 36659 ((__t=( property.title ))==null?'':_.escape(__t))+ 36660 '</div>\n <div class="col-sm-9 property-detail">'+ 36661 ((__t=( data[key] ))==null?'':__t)+ 36662 '</div>\n </div>\n'; 36663 36664 }); 36665 36666 __p+='\n </div>\n</div>\n\n'; 36667 36668 if (children.length > 0) { 36669 36670 __p+='\n<div class="container-fluid">\n <div class="row">\n'; 36671 36672 children.forEach(function(child) { 36673 36674 __p+='\n <div class="child-resource">\n <div id="'+ 36675 ((__t=( child.id ))==null?'':_.escape(__t))+ 36676 '_table"></div>\n </div>\n'; 36677 36678 }); 36679 36680 __p+='\n </div>\n</div>\n'; 36681 36682 } 36683 36684 __p+='\n'; 36685 } 36686 return __p; 36687 }; 36688 36689 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(114))) 36690 36691 /***/ }, 36692 /* 184 */ 36693 /***/ function(module, exports, __webpack_require__) { 36694 36695 /* WEBPACK VAR INJECTION */(function($) {'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _backbone=__webpack_require__(113),_errorView=__webpack_require__(162),_errorView2=_interopRequireDefault(_errorView),_login=__webpack_require__(185),_login2=_interopRequireDefault(_login);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}class LoginView extends _backbone.View{get tagName(){return'div'}get events(){return{'click [data-gohan="login"]':'login'}}/** 36696 * Constructs the object. 36697 * @constructor 36698 * @extends View.constructor 36699 * @param {Object} options 36700 */constructor(a){super(a),this.template=a.template||_login2.default,this.model=a.model,this.errorView=new _errorView2.default,this.listenTo(this.model,'change:authData',this.reload)}/** 36701 * Reloads window on current history fragment. 36702 */reload(){_backbone.history.loadUrl(_backbone.history.fragment)}/** 36703 * Renders template to html element. 36704 * @returns {LoginView} 36705 */render(){return this.el.innerHTML=this.template({}),$('[data-gohan="error"]',this.el).append(this.errorView.el),this}/** 36706 * Handles of click event on login button. 36707 * @param {Event} event 36708 */login(a){a.preventDefault(),a.currentTarget.disabled=!0;const b=this.$('#id').val(),c=this.$('#password').val();$('#alerts').empty(),this.model.login(b,c).then(d=>{const e=d[0].name;this.model.loginTenant(e).catch(f=>{this.errorView.render(...f)})}).catch(d=>{this.errorView.render(...d),a.currentTarget.disabled=!1})}}exports.default=LoginView;/* global $ */ 36709 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71))) 36710 36711 /***/ }, 36712 /* 185 */ 36713 /***/ function(module, exports) { 36714 36715 module.exports = function(obj){ 36716 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 36717 with(obj||{}){ 36718 __p+='<div class="login-container" id="main">\n <div class="login-panel">\n <h1>Gohan WebUI</h1>\n <div class="panel panel-default card">\n \n <div class="panel-heading">\n <h2 class="panel-title">Login</h2>\n </div>\n <div class="panel-body">\n <div id="alerts"></div>\n <div data-gohan="error"></div>\n <form accept-charset="UTF-8" method="" action="" role="form" id="login">\n <fieldset>\n <div class="form-group">\n <input class="form-control" placeholder="ID" name="id" type="text" id="id"></div>\n <div class="form-group">\n <input class="form-control" placeholder="Password" name="password" id="password" type="password" value=""></div>\n <input class="btn btn-primary btn-block" data-gohan="login" type="submit" value="Login"></fieldset>\n </form>\n </div>\n </div>\n </div>\n</div>\n'; 36719 } 36720 return __p; 36721 }; 36722 36723 36724 /***/ }, 36725 /* 186 */ 36726 /***/ function(module, exports, __webpack_require__) { 36727 36728 /* WEBPACK VAR INJECTION */(function($) {'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _backbone=__webpack_require__(113),_top=__webpack_require__(187),_top2=_interopRequireDefault(_top),_bootstrapDialog=__webpack_require__(85),_bootstrapDialog2=_interopRequireDefault(_bootstrapDialog);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}/** 36729 * Class contains logic of sample page view in application. 36730 * @class SampleView 36731 * @extends View 36732 */class TopView extends _backbone.View{get tagName(){return'div'}get className(){return'top-view'}get events(){return{'click button.api-request':'apiRequest','click .api-list > li> a':'setURL'}}/** 36733 * Constructs the object. 36734 * @constructor 36735 * @override View.constructor 36736 * @param {Object} options 36737 */constructor(a){super(a),this.app=a.app,this.errorView=new this.app.ErrorClass,this.app&&this.app.breadCrumb.update([{url:'/',title:'Home'}]),this.render()}apiRequest(a){a.preventDefault();const b=this.$('#HTTPmethod').val(),c=this.app.config.get('gohan').url+this.$('#api-url').val(),d=this.$('#request-data').val();(0,_backbone.ajax)({dataType:'json',url:c,data:d,method:b,timeout:5e3,headers:{'X-Auth-Token':this.app.userModel.authToken(),'Content-Type':'application/json'},success:(...e)=>{_bootstrapDialog2.default.show({type:_bootstrapDialog2.default.TYPE_DEFAULT,title:'Success',message:'see dettail in console'}),console.log(e)},error:(...e)=>{_bootstrapDialog2.default.show({type:_bootstrapDialog2.default.TYPE_DEFAULT,title:'Error',message:'see dettail in console'}),console.log(e)}})}setURL(a){a.preventDefault(),$('#api-url',this.$el).val(a.target.innerText)}/** 36738 * Renders component content. 36739 * @override View.render 36740 * @returns {SampleView} 36741 */render(){this.app.router.changeTitle('Home');const a=[];return this.app.schemas.each(b=>{const c=b.get('metadata');c&&void 0!==c.type||a.push(b.get('url'))}),this.$el.html((0,_top2.default)({gohanURL:this.app.config.get('gohan').url,schemaURL:a})),$('[data-gohan="error"]',this.el).append(this.errorView.el),this}/** 36742 * Removes page content. 36743 */close(){this.remove()}}exports.default=TopView;/* global $ */ 36744 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71))) 36745 36746 /***/ }, 36747 /* 187 */ 36748 /***/ function(module, exports, __webpack_require__) { 36749 36750 /* WEBPACK VAR INJECTION */(function(_) {module.exports = function(obj){ 36751 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 36752 with(obj||{}){ 36753 __p+='<div data-gohan="error"></div>\n<div class="top-container">\n <h2>Resources</h2>\n <div class="card">\n <ul>\n <li><a href="https://github.com/cloudwan/gohan" target="_blank">Gohan (Github Repo)</a></li>\n <li><a href="https://github.com/cloudwan/gohan_webui" target="_blank">Gohan WebUI (Github Repo)</a></li>\n </ul>\n </div>\n\n <h2>API Request</h2>\n <div class="card">\n <p>You can see the result in the browser console, X-Auth-Token wll be added to every API call</p>\n <form class="form-horizontal">\n <div class="form-group">\n <label for="api-url" class="col-sm-2 control-label">URL</label>\n <div class="col-sm-3 pre-url" id="pre-url">'+ 36754 ((__t=( gohanURL ))==null?'':_.escape(__t))+ 36755 ' + </div>\n\n <div class="col-sm-7">\n <div class="input-group">\n <input type="text" class="form-control" aria-label="API URL" id="api-url" placeholder="'+ 36756 ((__t=( schemaURL[0] ))==null?'':__t)+ 36757 '">\n <div class="input-group-btn">\n <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <span class="caret"></span></button>\n <ul class="dropdown-menu dropdown-menu-right api-list">\n '; 36758 schemaURL.forEach( function(url){ 36759 __p+='\n <li><a href="#">'+ 36760 ((__t=( url ))==null?'':__t)+ 36761 '</a></li>\n '; 36762 }); 36763 __p+='\n </ul>\n </div><!-- /btn-group -->\n </div><!-- /input-group -->\n </div>\n </div>\n <div class="form-group">\n <label class="col-sm-2 control-label" for="HTTPmethod">HTTP Method</label>\n <div class="col-sm-10">\n <select class="form-control" id="HTTPmethod">\n <option>GET</option>\n <option>POST</option>\n <option>PUT</option>\n </select>\n </div>\n </div>\n <div class="form-group">\n <label for="requestData" class="col-sm-2 control-label">Data</label>\n <div class="col-sm-10">\n <textarea class="form-control" rows="3" id="request-data"></textarea>\n <span class="help-block">Put Stringified JSON here</span>\n </div>\n </div>\n <div class="form-group">\n <div class="col-sm-offset-2 col-sm-10">\n <button type="button" class="btn btn-primary api-request">Submit</button>\n </div>\n </div>\n </form>\n </div>\n</div>\n'; 36764 } 36765 return __p; 36766 }; 36767 36768 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(114))) 36769 36770 /***/ }, 36771 /* 188 */ 36772 /***/ function(module, exports, __webpack_require__) { 36773 36774 'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _backbone=__webpack_require__(113),_underscore=__webpack_require__(114),_underscore2=_interopRequireDefault(_underscore),_breadcrumb=__webpack_require__(189),_breadcrumb2=_interopRequireDefault(_breadcrumb);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}/** 36775 * Class contains logic of bread crumb view in application. 36776 * @class BreadCrumbView 36777 * @extends View 36778 */class BreadCrumbView extends _backbone.View{get className(){return'bread-crumb'}get template(){return _breadcrumb2.default}/** 36779 * Updates bread crumb. 36780 * @param {Array} ancestors 36781 * @param {Object} childView 36782 */update(a){const b=a.map(c=>{return{title:_underscore2.default.escape(c.title),url:_underscore2.default.escape(c.url)}});this.$el.html(this.template({parents:b}))}/** 36783 * Renders component content. 36784 * @override View.render 36785 * @returns {BreadCrumbView} 36786 */render(){return this.$el.html(),this}}exports.default=BreadCrumbView; 36787 36788 /***/ }, 36789 /* 189 */ 36790 /***/ function(module, exports) { 36791 36792 module.exports = function(obj){ 36793 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 36794 with(obj||{}){ 36795 __p+='<ol>\n'; 36796 36797 parents.forEach(parent => { 36798 36799 __p+='\n <li><a href="#'+ 36800 ((__t=( parent.url ))==null?'':__t)+ 36801 '">'+ 36802 ((__t=( parent.title ))==null?'':__t)+ 36803 '</a></li>\n'; 36804 36805 }); 36806 36807 __p+='\n</ol>\n'; 36808 } 36809 return __p; 36810 }; 36811 36812 36813 /***/ }, 36814 /* 190 */ 36815 /***/ function(module, exports) { 36816 36817 module.exports = function(obj){ 36818 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 36819 with(obj||{}){ 36820 __p+='<div class="container-fluid">\n <div class="row">\n <div class="sidebar" id="sidebar">\n </div>\n <div class="main">\n <nav class="navbar navbar-inverse navbar-fixed-top gohan-header">\n <div class="container-fluid">\n <div class="navbar-header">\n <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#gohan-header-navbar-collapse" aria-expanded="false">\n <span class="sr-only">Toggle navigation</span>\n <span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span>\n <span class="glyphicon glyphicon-triangle-top" aria-hidden="true"></span>\n </button>\n <div id="bread-crumb"></div>\n </div>\n <div class="collapse navbar-collapse" id="gohan-header-navbar-collapse">\n <div id="header"></div>\n </div>\n </div>\n </nav>\n <div id="main_body">\n </div>\n </div>\n </div>\n</div>\n'; 36821 } 36822 return __p; 36823 }; 36824 36825 36826 /***/ }, 36827 /* 191 */ 36828 /***/ function(module, exports, __webpack_require__) { 36829 36830 /* WEBPACK VAR INJECTION */(function($) {'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _bootstrapDialog=__webpack_require__(85),_bootstrapDialog2=_interopRequireDefault(_bootstrapDialog),_dialogView=__webpack_require__(161),_dialogView2=_interopRequireDefault(_dialogView),_underscore=__webpack_require__(114),_underscore2=_interopRequireDefault(_underscore),_jsYaml=__webpack_require__(121),_jsYaml2=_interopRequireDefault(_jsYaml);__webpack_require__(192);__webpack_require__(193);__webpack_require__(195);__webpack_require__(197);__webpack_require__(170);__webpack_require__(172);__webpack_require__(173);__webpack_require__(174);var _tableView=__webpack_require__(160),_tableView2=_interopRequireDefault(_tableView),_schemaForm=__webpack_require__(200),_schemaForm2=_interopRequireDefault(_schemaForm),_propertyForm=__webpack_require__(201),_propertyForm2=_interopRequireDefault(_propertyForm);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}class SchemaView extends _tableView2.default{toLocal(a){return a}toServer(a){return a}dialogForm(a,b,c,d){this.schema.filterByAction(a,this.parentProperty).then(e=>{e.additionalForm=['*'],e.propertiesOrder=['id','singular','plural','title','description','parent','namespace','prefix'],e.required=[];const f=[{id:'title',type:'string'},{id:'type',type:'string',enum:['string','boolean','integer','number','array','object']},{id:'description',type:'string'},{id:'required',type:'checkbox'}],g=[];void 0===c.schema&&(c.schema={properties:{id:{title:'ID',type:'string',description:'ID',permission:['create'],view:['detail']},name:{title:'Name',type:'string',description:'Name',permission:['create','update']},description:{title:'Description',type:'string',description:'Description',permission:['create','update']},tenant_id:{// eslint-disable-line camelcase 36831 title:'Tenant ID',type:'string',description:'Tenant ID',permission:['create'],view:['detail']}},propertiesOrder:['id','name','description','tenant_id']}),this.dialog=new _dialogView2.default({action:a,formTitle:b,data:c,fields:e.propertiesOrder,onsubmit:l=>{const m=[],n=[],o={};$('#properties_table tbody tr').each(function(){const q=$(this).data('property'),r=q.id;void 0===r||o[r]||(m.push(q.id),q.required&&n.push(r),delete q.id,delete q.required,o[r]=q)}),l.schema={type:'object',propertiesOrder:m,required:n,properties:o},d(l)},unformattedSchema:this.schema,schema:this.schema.toFormJSON(e)}),this.dialog.render(),this.dialog.form.$el.append($((0,_schemaForm2.default)({propertyColumns:f}))),$('#properties_table tbody',this.dialog.form.$el).sortable();const h=c.schema||{};for(let l of h.propertiesOrder){const m=_underscore2.default.extend({},h.properties[l]);if(void 0===m)return;let n=!1;h.required&&0<=h.required.indexOf(l)&&(n=!0),m.id=l,m.required=n,g.push(m)}const i={type:'string'};g.push(_underscore2.default.extend({},i));const j=l=>{const m=$((0,_propertyForm2.default)({propertyColumns:f,property:l}));$('.delete',m).on('click',function(){window.confirm('Are you sure to delete?')&&($(this).off('click'),$(this).parent().parent().remove())}),$('.id_form',m).change(k),$('#properties_table tbody',this.dialog.form.$el).append(m),$('#id',m).change(function(){l.id=$(this).val()}),m.data('property',l);for(let n of f)$('#'+n.id,m).change(function(){l[n.id]='checkbox'===n.type?$(this).is(':checked'):$(this).val()});$('button#detail',m).click(()=>{const n=$('<div style="width:500px;height:200px;"></div>'),o=window.ace,p=o.edit(n.get(0));p.getSession().setNewLineMode('unix'),p.setTheme('ace/theme/monokai'),p.getSession().setMode('ace/mode/yaml'),p.getSession().setTabSize(2),p.$blockScrolling='Infinity';const q=_jsYaml2.default.safeDump(l);p.getSession().setValue(q),_bootstrapDialog2.default.show({type:_bootstrapDialog2.default.TYPE_DEFAULT,title:'Property Detail',closeByKeyboard:!1,message:n,spinicon:'glyphicon glyphicon-refresh',onshown:()=>{$('.modal-body').css({'max-height':$(window).height()-200+'px'})},buttons:[{id:'submit',label:'Submit',cssClass:'btn-primary btn-raised btn-material-blue-600',action:function(s){const t=p.getSession().getValue(),u=_jsYaml2.default.safeLoad(t),v=$($('#properties_table tbody tr').get(g.indexOf(l)));for(let w in l)delete l[w];for(let w in u)l[w]=u[w];for(let w in l){let x=l[w];'boolean'==typeof x?v.find('#'+w).prop('checked',x):v.find('#'+w).val(x)}s.close()}}]})})},k=()=>{let l=!0;$('.id_form',this.dialog.form.$el).each(function(){'\'\''===$(this).val()&&(l=!1)}),l&&j(Object.assign({},i))};for(let l of g)j(l)})}}exports.default=SchemaView;/* global window, $ */ 36832 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71))) 36833 36834 /***/ }, 36835 /* 192 */ 36836 /***/ function(module, exports, __webpack_require__) { 36837 36838 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;// This file is deprecated in 1.12.0 to be removed in 1.13 36839 ( function() { 36840 !(__WEBPACK_AMD_DEFINE_FACTORY__ = ([ 36841 "jquery", 36842 "./data", 36843 "./disable-selection", 36844 "./focusable", 36845 "./form", 36846 "./ie", 36847 "./keycode", 36848 "./labels", 36849 "./jquery-1-7", 36850 "./plugin", 36851 "./safe-active-element", 36852 "./safe-blur", 36853 "./scroll-parent", 36854 "./tabbable", 36855 "./unique-id", 36856 "./version" 36857 ]), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 36858 } )(); 36859 36860 36861 /***/ }, 36862 /* 193 */ 36863 /***/ function(module, exports, __webpack_require__) { 36864 36865 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 36866 * jQuery UI Widget 1.12.1 36867 * http://jqueryui.com 36868 * 36869 * Copyright jQuery Foundation and other contributors 36870 * Released under the MIT license. 36871 * http://jquery.org/license 36872 */ 36873 36874 //>>label: Widget 36875 //>>group: Core 36876 //>>description: Provides a factory for creating stateful widgets with a common API. 36877 //>>docs: http://api.jqueryui.com/jQuery.widget/ 36878 //>>demos: http://jqueryui.com/widget/ 36879 36880 ( function( factory ) { 36881 if ( true ) { 36882 36883 // AMD. Register as an anonymous module. 36884 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(71), __webpack_require__(194) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 36885 } else { 36886 36887 // Browser globals 36888 factory( jQuery ); 36889 } 36890 }( function( $ ) { 36891 36892 var widgetUuid = 0; 36893 var widgetSlice = Array.prototype.slice; 36894 36895 $.cleanData = ( function( orig ) { 36896 return function( elems ) { 36897 var events, elem, i; 36898 for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) { 36899 try { 36900 36901 // Only trigger remove when necessary to save time 36902 events = $._data( elem, "events" ); 36903 if ( events && events.remove ) { 36904 $( elem ).triggerHandler( "remove" ); 36905 } 36906 36907 // Http://bugs.jquery.com/ticket/8235 36908 } catch ( e ) {} 36909 } 36910 orig( elems ); 36911 }; 36912 } )( $.cleanData ); 36913 36914 $.widget = function( name, base, prototype ) { 36915 var existingConstructor, constructor, basePrototype; 36916 36917 // ProxiedPrototype allows the provided prototype to remain unmodified 36918 // so that it can be used as a mixin for multiple widgets (#8876) 36919 var proxiedPrototype = {}; 36920 36921 var namespace = name.split( "." )[ 0 ]; 36922 name = name.split( "." )[ 1 ]; 36923 var fullName = namespace + "-" + name; 36924 36925 if ( !prototype ) { 36926 prototype = base; 36927 base = $.Widget; 36928 } 36929 36930 if ( $.isArray( prototype ) ) { 36931 prototype = $.extend.apply( null, [ {} ].concat( prototype ) ); 36932 } 36933 36934 // Create selector for plugin 36935 $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) { 36936 return !!$.data( elem, fullName ); 36937 }; 36938 36939 $[ namespace ] = $[ namespace ] || {}; 36940 existingConstructor = $[ namespace ][ name ]; 36941 constructor = $[ namespace ][ name ] = function( options, element ) { 36942 36943 // Allow instantiation without "new" keyword 36944 if ( !this._createWidget ) { 36945 return new constructor( options, element ); 36946 } 36947 36948 // Allow instantiation without initializing for simple inheritance 36949 // must use "new" keyword (the code above always passes args) 36950 if ( arguments.length ) { 36951 this._createWidget( options, element ); 36952 } 36953 }; 36954 36955 // Extend with the existing constructor to carry over any static properties 36956 $.extend( constructor, existingConstructor, { 36957 version: prototype.version, 36958 36959 // Copy the object used to create the prototype in case we need to 36960 // redefine the widget later 36961 _proto: $.extend( {}, prototype ), 36962 36963 // Track widgets that inherit from this widget in case this widget is 36964 // redefined after a widget inherits from it 36965 _childConstructors: [] 36966 } ); 36967 36968 basePrototype = new base(); 36969 36970 // We need to make the options hash a property directly on the new instance 36971 // otherwise we'll modify the options hash on the prototype that we're 36972 // inheriting from 36973 basePrototype.options = $.widget.extend( {}, basePrototype.options ); 36974 $.each( prototype, function( prop, value ) { 36975 if ( !$.isFunction( value ) ) { 36976 proxiedPrototype[ prop ] = value; 36977 return; 36978 } 36979 proxiedPrototype[ prop ] = ( function() { 36980 function _super() { 36981 return base.prototype[ prop ].apply( this, arguments ); 36982 } 36983 36984 function _superApply( args ) { 36985 return base.prototype[ prop ].apply( this, args ); 36986 } 36987 36988 return function() { 36989 var __super = this._super; 36990 var __superApply = this._superApply; 36991 var returnValue; 36992 36993 this._super = _super; 36994 this._superApply = _superApply; 36995 36996 returnValue = value.apply( this, arguments ); 36997 36998 this._super = __super; 36999 this._superApply = __superApply; 37000 37001 return returnValue; 37002 }; 37003 } )(); 37004 } ); 37005 constructor.prototype = $.widget.extend( basePrototype, { 37006 37007 // TODO: remove support for widgetEventPrefix 37008 // always use the name + a colon as the prefix, e.g., draggable:start 37009 // don't prefix for widgets that aren't DOM-based 37010 widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name ) : name 37011 }, proxiedPrototype, { 37012 constructor: constructor, 37013 namespace: namespace, 37014 widgetName: name, 37015 widgetFullName: fullName 37016 } ); 37017 37018 // If this widget is being redefined then we need to find all widgets that 37019 // are inheriting from it and redefine all of them so that they inherit from 37020 // the new version of this widget. We're essentially trying to replace one 37021 // level in the prototype chain. 37022 if ( existingConstructor ) { 37023 $.each( existingConstructor._childConstructors, function( i, child ) { 37024 var childPrototype = child.prototype; 37025 37026 // Redefine the child widget using the same prototype that was 37027 // originally used, but inherit from the new version of the base 37028 $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, 37029 child._proto ); 37030 } ); 37031 37032 // Remove the list of existing child constructors from the old constructor 37033 // so the old child constructors can be garbage collected 37034 delete existingConstructor._childConstructors; 37035 } else { 37036 base._childConstructors.push( constructor ); 37037 } 37038 37039 $.widget.bridge( name, constructor ); 37040 37041 return constructor; 37042 }; 37043 37044 $.widget.extend = function( target ) { 37045 var input = widgetSlice.call( arguments, 1 ); 37046 var inputIndex = 0; 37047 var inputLength = input.length; 37048 var key; 37049 var value; 37050 37051 for ( ; inputIndex < inputLength; inputIndex++ ) { 37052 for ( key in input[ inputIndex ] ) { 37053 value = input[ inputIndex ][ key ]; 37054 if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) { 37055 37056 // Clone objects 37057 if ( $.isPlainObject( value ) ) { 37058 target[ key ] = $.isPlainObject( target[ key ] ) ? 37059 $.widget.extend( {}, target[ key ], value ) : 37060 37061 // Don't extend strings, arrays, etc. with objects 37062 $.widget.extend( {}, value ); 37063 37064 // Copy everything else by reference 37065 } else { 37066 target[ key ] = value; 37067 } 37068 } 37069 } 37070 } 37071 return target; 37072 }; 37073 37074 $.widget.bridge = function( name, object ) { 37075 var fullName = object.prototype.widgetFullName || name; 37076 $.fn[ name ] = function( options ) { 37077 var isMethodCall = typeof options === "string"; 37078 var args = widgetSlice.call( arguments, 1 ); 37079 var returnValue = this; 37080 37081 if ( isMethodCall ) { 37082 37083 // If this is an empty collection, we need to have the instance method 37084 // return undefined instead of the jQuery instance 37085 if ( !this.length && options === "instance" ) { 37086 returnValue = undefined; 37087 } else { 37088 this.each( function() { 37089 var methodValue; 37090 var instance = $.data( this, fullName ); 37091 37092 if ( options === "instance" ) { 37093 returnValue = instance; 37094 return false; 37095 } 37096 37097 if ( !instance ) { 37098 return $.error( "cannot call methods on " + name + 37099 " prior to initialization; " + 37100 "attempted to call method '" + options + "'" ); 37101 } 37102 37103 if ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) { 37104 return $.error( "no such method '" + options + "' for " + name + 37105 " widget instance" ); 37106 } 37107 37108 methodValue = instance[ options ].apply( instance, args ); 37109 37110 if ( methodValue !== instance && methodValue !== undefined ) { 37111 returnValue = methodValue && methodValue.jquery ? 37112 returnValue.pushStack( methodValue.get() ) : 37113 methodValue; 37114 return false; 37115 } 37116 } ); 37117 } 37118 } else { 37119 37120 // Allow multiple hashes to be passed on init 37121 if ( args.length ) { 37122 options = $.widget.extend.apply( null, [ options ].concat( args ) ); 37123 } 37124 37125 this.each( function() { 37126 var instance = $.data( this, fullName ); 37127 if ( instance ) { 37128 instance.option( options || {} ); 37129 if ( instance._init ) { 37130 instance._init(); 37131 } 37132 } else { 37133 $.data( this, fullName, new object( options, this ) ); 37134 } 37135 } ); 37136 } 37137 37138 return returnValue; 37139 }; 37140 }; 37141 37142 $.Widget = function( /* options, element */ ) {}; 37143 $.Widget._childConstructors = []; 37144 37145 $.Widget.prototype = { 37146 widgetName: "widget", 37147 widgetEventPrefix: "", 37148 defaultElement: "<div>", 37149 37150 options: { 37151 classes: {}, 37152 disabled: false, 37153 37154 // Callbacks 37155 create: null 37156 }, 37157 37158 _createWidget: function( options, element ) { 37159 element = $( element || this.defaultElement || this )[ 0 ]; 37160 this.element = $( element ); 37161 this.uuid = widgetUuid++; 37162 this.eventNamespace = "." + this.widgetName + this.uuid; 37163 37164 this.bindings = $(); 37165 this.hoverable = $(); 37166 this.focusable = $(); 37167 this.classesElementLookup = {}; 37168 37169 if ( element !== this ) { 37170 $.data( element, this.widgetFullName, this ); 37171 this._on( true, this.element, { 37172 remove: function( event ) { 37173 if ( event.target === element ) { 37174 this.destroy(); 37175 } 37176 } 37177 } ); 37178 this.document = $( element.style ? 37179 37180 // Element within the document 37181 element.ownerDocument : 37182 37183 // Element is window or document 37184 element.document || element ); 37185 this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow ); 37186 } 37187 37188 this.options = $.widget.extend( {}, 37189 this.options, 37190 this._getCreateOptions(), 37191 options ); 37192 37193 this._create(); 37194 37195 if ( this.options.disabled ) { 37196 this._setOptionDisabled( this.options.disabled ); 37197 } 37198 37199 this._trigger( "create", null, this._getCreateEventData() ); 37200 this._init(); 37201 }, 37202 37203 _getCreateOptions: function() { 37204 return {}; 37205 }, 37206 37207 _getCreateEventData: $.noop, 37208 37209 _create: $.noop, 37210 37211 _init: $.noop, 37212 37213 destroy: function() { 37214 var that = this; 37215 37216 this._destroy(); 37217 $.each( this.classesElementLookup, function( key, value ) { 37218 that._removeClass( value, key ); 37219 } ); 37220 37221 // We can probably remove the unbind calls in 2.0 37222 // all event bindings should go through this._on() 37223 this.element 37224 .off( this.eventNamespace ) 37225 .removeData( this.widgetFullName ); 37226 this.widget() 37227 .off( this.eventNamespace ) 37228 .removeAttr( "aria-disabled" ); 37229 37230 // Clean up events and states 37231 this.bindings.off( this.eventNamespace ); 37232 }, 37233 37234 _destroy: $.noop, 37235 37236 widget: function() { 37237 return this.element; 37238 }, 37239 37240 option: function( key, value ) { 37241 var options = key; 37242 var parts; 37243 var curOption; 37244 var i; 37245 37246 if ( arguments.length === 0 ) { 37247 37248 // Don't return a reference to the internal hash 37249 return $.widget.extend( {}, this.options ); 37250 } 37251 37252 if ( typeof key === "string" ) { 37253 37254 // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } 37255 options = {}; 37256 parts = key.split( "." ); 37257 key = parts.shift(); 37258 if ( parts.length ) { 37259 curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] ); 37260 for ( i = 0; i < parts.length - 1; i++ ) { 37261 curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {}; 37262 curOption = curOption[ parts[ i ] ]; 37263 } 37264 key = parts.pop(); 37265 if ( arguments.length === 1 ) { 37266 return curOption[ key ] === undefined ? null : curOption[ key ]; 37267 } 37268 curOption[ key ] = value; 37269 } else { 37270 if ( arguments.length === 1 ) { 37271 return this.options[ key ] === undefined ? null : this.options[ key ]; 37272 } 37273 options[ key ] = value; 37274 } 37275 } 37276 37277 this._setOptions( options ); 37278 37279 return this; 37280 }, 37281 37282 _setOptions: function( options ) { 37283 var key; 37284 37285 for ( key in options ) { 37286 this._setOption( key, options[ key ] ); 37287 } 37288 37289 return this; 37290 }, 37291 37292 _setOption: function( key, value ) { 37293 if ( key === "classes" ) { 37294 this._setOptionClasses( value ); 37295 } 37296 37297 this.options[ key ] = value; 37298 37299 if ( key === "disabled" ) { 37300 this._setOptionDisabled( value ); 37301 } 37302 37303 return this; 37304 }, 37305 37306 _setOptionClasses: function( value ) { 37307 var classKey, elements, currentElements; 37308 37309 for ( classKey in value ) { 37310 currentElements = this.classesElementLookup[ classKey ]; 37311 if ( value[ classKey ] === this.options.classes[ classKey ] || 37312 !currentElements || 37313 !currentElements.length ) { 37314 continue; 37315 } 37316 37317 // We are doing this to create a new jQuery object because the _removeClass() call 37318 // on the next line is going to destroy the reference to the current elements being 37319 // tracked. We need to save a copy of this collection so that we can add the new classes 37320 // below. 37321 elements = $( currentElements.get() ); 37322 this._removeClass( currentElements, classKey ); 37323 37324 // We don't use _addClass() here, because that uses this.options.classes 37325 // for generating the string of classes. We want to use the value passed in from 37326 // _setOption(), this is the new value of the classes option which was passed to 37327 // _setOption(). We pass this value directly to _classes(). 37328 elements.addClass( this._classes( { 37329 element: elements, 37330 keys: classKey, 37331 classes: value, 37332 add: true 37333 } ) ); 37334 } 37335 }, 37336 37337 _setOptionDisabled: function( value ) { 37338 this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value ); 37339 37340 // If the widget is becoming disabled, then nothing is interactive 37341 if ( value ) { 37342 this._removeClass( this.hoverable, null, "ui-state-hover" ); 37343 this._removeClass( this.focusable, null, "ui-state-focus" ); 37344 } 37345 }, 37346 37347 enable: function() { 37348 return this._setOptions( { disabled: false } ); 37349 }, 37350 37351 disable: function() { 37352 return this._setOptions( { disabled: true } ); 37353 }, 37354 37355 _classes: function( options ) { 37356 var full = []; 37357 var that = this; 37358 37359 options = $.extend( { 37360 element: this.element, 37361 classes: this.options.classes || {} 37362 }, options ); 37363 37364 function processClassString( classes, checkOption ) { 37365 var current, i; 37366 for ( i = 0; i < classes.length; i++ ) { 37367 current = that.classesElementLookup[ classes[ i ] ] || $(); 37368 if ( options.add ) { 37369 current = $( $.unique( current.get().concat( options.element.get() ) ) ); 37370 } else { 37371 current = $( current.not( options.element ).get() ); 37372 } 37373 that.classesElementLookup[ classes[ i ] ] = current; 37374 full.push( classes[ i ] ); 37375 if ( checkOption && options.classes[ classes[ i ] ] ) { 37376 full.push( options.classes[ classes[ i ] ] ); 37377 } 37378 } 37379 } 37380 37381 this._on( options.element, { 37382 "remove": "_untrackClassesElement" 37383 } ); 37384 37385 if ( options.keys ) { 37386 processClassString( options.keys.match( /\S+/g ) || [], true ); 37387 } 37388 if ( options.extra ) { 37389 processClassString( options.extra.match( /\S+/g ) || [] ); 37390 } 37391 37392 return full.join( " " ); 37393 }, 37394 37395 _untrackClassesElement: function( event ) { 37396 var that = this; 37397 $.each( that.classesElementLookup, function( key, value ) { 37398 if ( $.inArray( event.target, value ) !== -1 ) { 37399 that.classesElementLookup[ key ] = $( value.not( event.target ).get() ); 37400 } 37401 } ); 37402 }, 37403 37404 _removeClass: function( element, keys, extra ) { 37405 return this._toggleClass( element, keys, extra, false ); 37406 }, 37407 37408 _addClass: function( element, keys, extra ) { 37409 return this._toggleClass( element, keys, extra, true ); 37410 }, 37411 37412 _toggleClass: function( element, keys, extra, add ) { 37413 add = ( typeof add === "boolean" ) ? add : extra; 37414 var shift = ( typeof element === "string" || element === null ), 37415 options = { 37416 extra: shift ? keys : extra, 37417 keys: shift ? element : keys, 37418 element: shift ? this.element : element, 37419 add: add 37420 }; 37421 options.element.toggleClass( this._classes( options ), add ); 37422 return this; 37423 }, 37424 37425 _on: function( suppressDisabledCheck, element, handlers ) { 37426 var delegateElement; 37427 var instance = this; 37428 37429 // No suppressDisabledCheck flag, shuffle arguments 37430 if ( typeof suppressDisabledCheck !== "boolean" ) { 37431 handlers = element; 37432 element = suppressDisabledCheck; 37433 suppressDisabledCheck = false; 37434 } 37435 37436 // No element argument, shuffle and use this.element 37437 if ( !handlers ) { 37438 handlers = element; 37439 element = this.element; 37440 delegateElement = this.widget(); 37441 } else { 37442 element = delegateElement = $( element ); 37443 this.bindings = this.bindings.add( element ); 37444 } 37445 37446 $.each( handlers, function( event, handler ) { 37447 function handlerProxy() { 37448 37449 // Allow widgets to customize the disabled handling 37450 // - disabled as an array instead of boolean 37451 // - disabled class as method for disabling individual parts 37452 if ( !suppressDisabledCheck && 37453 ( instance.options.disabled === true || 37454 $( this ).hasClass( "ui-state-disabled" ) ) ) { 37455 return; 37456 } 37457 return ( typeof handler === "string" ? instance[ handler ] : handler ) 37458 .apply( instance, arguments ); 37459 } 37460 37461 // Copy the guid so direct unbinding works 37462 if ( typeof handler !== "string" ) { 37463 handlerProxy.guid = handler.guid = 37464 handler.guid || handlerProxy.guid || $.guid++; 37465 } 37466 37467 var match = event.match( /^([\w:-]*)\s*(.*)$/ ); 37468 var eventName = match[ 1 ] + instance.eventNamespace; 37469 var selector = match[ 2 ]; 37470 37471 if ( selector ) { 37472 delegateElement.on( eventName, selector, handlerProxy ); 37473 } else { 37474 element.on( eventName, handlerProxy ); 37475 } 37476 } ); 37477 }, 37478 37479 _off: function( element, eventName ) { 37480 eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) + 37481 this.eventNamespace; 37482 element.off( eventName ).off( eventName ); 37483 37484 // Clear the stack to avoid memory leaks (#10056) 37485 this.bindings = $( this.bindings.not( element ).get() ); 37486 this.focusable = $( this.focusable.not( element ).get() ); 37487 this.hoverable = $( this.hoverable.not( element ).get() ); 37488 }, 37489 37490 _delay: function( handler, delay ) { 37491 function handlerProxy() { 37492 return ( typeof handler === "string" ? instance[ handler ] : handler ) 37493 .apply( instance, arguments ); 37494 } 37495 var instance = this; 37496 return setTimeout( handlerProxy, delay || 0 ); 37497 }, 37498 37499 _hoverable: function( element ) { 37500 this.hoverable = this.hoverable.add( element ); 37501 this._on( element, { 37502 mouseenter: function( event ) { 37503 this._addClass( $( event.currentTarget ), null, "ui-state-hover" ); 37504 }, 37505 mouseleave: function( event ) { 37506 this._removeClass( $( event.currentTarget ), null, "ui-state-hover" ); 37507 } 37508 } ); 37509 }, 37510 37511 _focusable: function( element ) { 37512 this.focusable = this.focusable.add( element ); 37513 this._on( element, { 37514 focusin: function( event ) { 37515 this._addClass( $( event.currentTarget ), null, "ui-state-focus" ); 37516 }, 37517 focusout: function( event ) { 37518 this._removeClass( $( event.currentTarget ), null, "ui-state-focus" ); 37519 } 37520 } ); 37521 }, 37522 37523 _trigger: function( type, event, data ) { 37524 var prop, orig; 37525 var callback = this.options[ type ]; 37526 37527 data = data || {}; 37528 event = $.Event( event ); 37529 event.type = ( type === this.widgetEventPrefix ? 37530 type : 37531 this.widgetEventPrefix + type ).toLowerCase(); 37532 37533 // The original event may come from any element 37534 // so we need to reset the target on the new event 37535 event.target = this.element[ 0 ]; 37536 37537 // Copy original event properties over to the new event 37538 orig = event.originalEvent; 37539 if ( orig ) { 37540 for ( prop in orig ) { 37541 if ( !( prop in event ) ) { 37542 event[ prop ] = orig[ prop ]; 37543 } 37544 } 37545 } 37546 37547 this.element.trigger( event, data ); 37548 return !( $.isFunction( callback ) && 37549 callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false || 37550 event.isDefaultPrevented() ); 37551 } 37552 }; 37553 37554 $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { 37555 $.Widget.prototype[ "_" + method ] = function( element, options, callback ) { 37556 if ( typeof options === "string" ) { 37557 options = { effect: options }; 37558 } 37559 37560 var hasOptions; 37561 var effectName = !options ? 37562 method : 37563 options === true || typeof options === "number" ? 37564 defaultEffect : 37565 options.effect || defaultEffect; 37566 37567 options = options || {}; 37568 if ( typeof options === "number" ) { 37569 options = { duration: options }; 37570 } 37571 37572 hasOptions = !$.isEmptyObject( options ); 37573 options.complete = callback; 37574 37575 if ( options.delay ) { 37576 element.delay( options.delay ); 37577 } 37578 37579 if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) { 37580 element[ method ]( options ); 37581 } else if ( effectName !== method && element[ effectName ] ) { 37582 element[ effectName ]( options.duration, options.easing, callback ); 37583 } else { 37584 element.queue( function( next ) { 37585 $( this )[ method ](); 37586 if ( callback ) { 37587 callback.call( element[ 0 ] ); 37588 } 37589 next(); 37590 } ); 37591 } 37592 }; 37593 } ); 37594 37595 return $.widget; 37596 37597 } ) ); 37598 37599 37600 /***/ }, 37601 /* 194 */ 37602 /***/ function(module, exports, __webpack_require__) { 37603 37604 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;( function( factory ) { 37605 if ( true ) { 37606 37607 // AMD. Register as an anonymous module. 37608 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(71) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 37609 } else { 37610 37611 // Browser globals 37612 factory( jQuery ); 37613 } 37614 } ( function( $ ) { 37615 37616 $.ui = $.ui || {}; 37617 37618 return $.ui.version = "1.12.1"; 37619 37620 } ) ); 37621 37622 37623 /***/ }, 37624 /* 195 */ 37625 /***/ function(module, exports, __webpack_require__) { 37626 37627 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 37628 * jQuery UI Mouse 1.12.1 37629 * http://jqueryui.com 37630 * 37631 * Copyright jQuery Foundation and other contributors 37632 * Released under the MIT license. 37633 * http://jquery.org/license 37634 */ 37635 37636 //>>label: Mouse 37637 //>>group: Widgets 37638 //>>description: Abstracts mouse-based interactions to assist in creating certain widgets. 37639 //>>docs: http://api.jqueryui.com/mouse/ 37640 37641 ( function( factory ) { 37642 if ( true ) { 37643 37644 // AMD. Register as an anonymous module. 37645 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ 37646 __webpack_require__(71), 37647 __webpack_require__(196), 37648 __webpack_require__(194), 37649 __webpack_require__(193) 37650 ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 37651 } else { 37652 37653 // Browser globals 37654 factory( jQuery ); 37655 } 37656 }( function( $ ) { 37657 37658 var mouseHandled = false; 37659 $( document ).on( "mouseup", function() { 37660 mouseHandled = false; 37661 } ); 37662 37663 return $.widget( "ui.mouse", { 37664 version: "1.12.1", 37665 options: { 37666 cancel: "input, textarea, button, select, option", 37667 distance: 1, 37668 delay: 0 37669 }, 37670 _mouseInit: function() { 37671 var that = this; 37672 37673 this.element 37674 .on( "mousedown." + this.widgetName, function( event ) { 37675 return that._mouseDown( event ); 37676 } ) 37677 .on( "click." + this.widgetName, function( event ) { 37678 if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) { 37679 $.removeData( event.target, that.widgetName + ".preventClickEvent" ); 37680 event.stopImmediatePropagation(); 37681 return false; 37682 } 37683 } ); 37684 37685 this.started = false; 37686 }, 37687 37688 // TODO: make sure destroying one instance of mouse doesn't mess with 37689 // other instances of mouse 37690 _mouseDestroy: function() { 37691 this.element.off( "." + this.widgetName ); 37692 if ( this._mouseMoveDelegate ) { 37693 this.document 37694 .off( "mousemove." + this.widgetName, this._mouseMoveDelegate ) 37695 .off( "mouseup." + this.widgetName, this._mouseUpDelegate ); 37696 } 37697 }, 37698 37699 _mouseDown: function( event ) { 37700 37701 // don't let more than one widget handle mouseStart 37702 if ( mouseHandled ) { 37703 return; 37704 } 37705 37706 this._mouseMoved = false; 37707 37708 // We may have missed mouseup (out of window) 37709 ( this._mouseStarted && this._mouseUp( event ) ); 37710 37711 this._mouseDownEvent = event; 37712 37713 var that = this, 37714 btnIsLeft = ( event.which === 1 ), 37715 37716 // event.target.nodeName works around a bug in IE 8 with 37717 // disabled inputs (#7620) 37718 elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ? 37719 $( event.target ).closest( this.options.cancel ).length : false ); 37720 if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) { 37721 return true; 37722 } 37723 37724 this.mouseDelayMet = !this.options.delay; 37725 if ( !this.mouseDelayMet ) { 37726 this._mouseDelayTimer = setTimeout( function() { 37727 that.mouseDelayMet = true; 37728 }, this.options.delay ); 37729 } 37730 37731 if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) { 37732 this._mouseStarted = ( this._mouseStart( event ) !== false ); 37733 if ( !this._mouseStarted ) { 37734 event.preventDefault(); 37735 return true; 37736 } 37737 } 37738 37739 // Click event may never have fired (Gecko & Opera) 37740 if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) { 37741 $.removeData( event.target, this.widgetName + ".preventClickEvent" ); 37742 } 37743 37744 // These delegates are required to keep context 37745 this._mouseMoveDelegate = function( event ) { 37746 return that._mouseMove( event ); 37747 }; 37748 this._mouseUpDelegate = function( event ) { 37749 return that._mouseUp( event ); 37750 }; 37751 37752 this.document 37753 .on( "mousemove." + this.widgetName, this._mouseMoveDelegate ) 37754 .on( "mouseup." + this.widgetName, this._mouseUpDelegate ); 37755 37756 event.preventDefault(); 37757 37758 mouseHandled = true; 37759 return true; 37760 }, 37761 37762 _mouseMove: function( event ) { 37763 37764 // Only check for mouseups outside the document if you've moved inside the document 37765 // at least once. This prevents the firing of mouseup in the case of IE<9, which will 37766 // fire a mousemove event if content is placed under the cursor. See #7778 37767 // Support: IE <9 37768 if ( this._mouseMoved ) { 37769 37770 // IE mouseup check - mouseup happened when mouse was out of window 37771 if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && 37772 !event.button ) { 37773 return this._mouseUp( event ); 37774 37775 // Iframe mouseup check - mouseup occurred in another document 37776 } else if ( !event.which ) { 37777 37778 // Support: Safari <=8 - 9 37779 // Safari sets which to 0 if you press any of the following keys 37780 // during a drag (#14461) 37781 if ( event.originalEvent.altKey || event.originalEvent.ctrlKey || 37782 event.originalEvent.metaKey || event.originalEvent.shiftKey ) { 37783 this.ignoreMissingWhich = true; 37784 } else if ( !this.ignoreMissingWhich ) { 37785 return this._mouseUp( event ); 37786 } 37787 } 37788 } 37789 37790 if ( event.which || event.button ) { 37791 this._mouseMoved = true; 37792 } 37793 37794 if ( this._mouseStarted ) { 37795 this._mouseDrag( event ); 37796 return event.preventDefault(); 37797 } 37798 37799 if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) { 37800 this._mouseStarted = 37801 ( this._mouseStart( this._mouseDownEvent, event ) !== false ); 37802 ( this._mouseStarted ? this._mouseDrag( event ) : this._mouseUp( event ) ); 37803 } 37804 37805 return !this._mouseStarted; 37806 }, 37807 37808 _mouseUp: function( event ) { 37809 this.document 37810 .off( "mousemove." + this.widgetName, this._mouseMoveDelegate ) 37811 .off( "mouseup." + this.widgetName, this._mouseUpDelegate ); 37812 37813 if ( this._mouseStarted ) { 37814 this._mouseStarted = false; 37815 37816 if ( event.target === this._mouseDownEvent.target ) { 37817 $.data( event.target, this.widgetName + ".preventClickEvent", true ); 37818 } 37819 37820 this._mouseStop( event ); 37821 } 37822 37823 if ( this._mouseDelayTimer ) { 37824 clearTimeout( this._mouseDelayTimer ); 37825 delete this._mouseDelayTimer; 37826 } 37827 37828 this.ignoreMissingWhich = false; 37829 mouseHandled = false; 37830 event.preventDefault(); 37831 }, 37832 37833 _mouseDistanceMet: function( event ) { 37834 return ( Math.max( 37835 Math.abs( this._mouseDownEvent.pageX - event.pageX ), 37836 Math.abs( this._mouseDownEvent.pageY - event.pageY ) 37837 ) >= this.options.distance 37838 ); 37839 }, 37840 37841 _mouseDelayMet: function( /* event */ ) { 37842 return this.mouseDelayMet; 37843 }, 37844 37845 // These are placeholder methods, to be overriden by extending plugin 37846 _mouseStart: function( /* event */ ) {}, 37847 _mouseDrag: function( /* event */ ) {}, 37848 _mouseStop: function( /* event */ ) {}, 37849 _mouseCapture: function( /* event */ ) { return true; } 37850 } ); 37851 37852 } ) ); 37853 37854 37855 /***/ }, 37856 /* 196 */ 37857 /***/ function(module, exports, __webpack_require__) { 37858 37859 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;( function( factory ) { 37860 if ( true ) { 37861 37862 // AMD. Register as an anonymous module. 37863 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(71), __webpack_require__(194) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 37864 } else { 37865 37866 // Browser globals 37867 factory( jQuery ); 37868 } 37869 } ( function( $ ) { 37870 37871 // This file is deprecated 37872 return $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() ); 37873 } ) ); 37874 37875 37876 /***/ }, 37877 /* 197 */ 37878 /***/ function(module, exports, __webpack_require__) { 37879 37880 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 37881 * jQuery UI Sortable 1.12.1 37882 * http://jqueryui.com 37883 * 37884 * Copyright jQuery Foundation and other contributors 37885 * Released under the MIT license. 37886 * http://jquery.org/license 37887 */ 37888 37889 //>>label: Sortable 37890 //>>group: Interactions 37891 //>>description: Enables items in a list to be sorted using the mouse. 37892 //>>docs: http://api.jqueryui.com/sortable/ 37893 //>>demos: http://jqueryui.com/sortable/ 37894 //>>css.structure: ../../themes/base/sortable.css 37895 37896 ( function( factory ) { 37897 if ( true ) { 37898 37899 // AMD. Register as an anonymous module. 37900 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ 37901 __webpack_require__(71), 37902 __webpack_require__(195), 37903 __webpack_require__(198), 37904 __webpack_require__(196), 37905 __webpack_require__(199), 37906 __webpack_require__(194), 37907 __webpack_require__(193) 37908 ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 37909 } else { 37910 37911 // Browser globals 37912 factory( jQuery ); 37913 } 37914 }( function( $ ) { 37915 37916 return $.widget( "ui.sortable", $.ui.mouse, { 37917 version: "1.12.1", 37918 widgetEventPrefix: "sort", 37919 ready: false, 37920 options: { 37921 appendTo: "parent", 37922 axis: false, 37923 connectWith: false, 37924 containment: false, 37925 cursor: "auto", 37926 cursorAt: false, 37927 dropOnEmpty: true, 37928 forcePlaceholderSize: false, 37929 forceHelperSize: false, 37930 grid: false, 37931 handle: false, 37932 helper: "original", 37933 items: "> *", 37934 opacity: false, 37935 placeholder: false, 37936 revert: false, 37937 scroll: true, 37938 scrollSensitivity: 20, 37939 scrollSpeed: 20, 37940 scope: "default", 37941 tolerance: "intersect", 37942 zIndex: 1000, 37943 37944 // Callbacks 37945 activate: null, 37946 beforeStop: null, 37947 change: null, 37948 deactivate: null, 37949 out: null, 37950 over: null, 37951 receive: null, 37952 remove: null, 37953 sort: null, 37954 start: null, 37955 stop: null, 37956 update: null 37957 }, 37958 37959 _isOverAxis: function( x, reference, size ) { 37960 return ( x >= reference ) && ( x < ( reference + size ) ); 37961 }, 37962 37963 _isFloating: function( item ) { 37964 return ( /left|right/ ).test( item.css( "float" ) ) || 37965 ( /inline|table-cell/ ).test( item.css( "display" ) ); 37966 }, 37967 37968 _create: function() { 37969 this.containerCache = {}; 37970 this._addClass( "ui-sortable" ); 37971 37972 //Get the items 37973 this.refresh(); 37974 37975 //Let's determine the parent's offset 37976 this.offset = this.element.offset(); 37977 37978 //Initialize mouse events for interaction 37979 this._mouseInit(); 37980 37981 this._setHandleClassName(); 37982 37983 //We're ready to go 37984 this.ready = true; 37985 37986 }, 37987 37988 _setOption: function( key, value ) { 37989 this._super( key, value ); 37990 37991 if ( key === "handle" ) { 37992 this._setHandleClassName(); 37993 } 37994 }, 37995 37996 _setHandleClassName: function() { 37997 var that = this; 37998 this._removeClass( this.element.find( ".ui-sortable-handle" ), "ui-sortable-handle" ); 37999 $.each( this.items, function() { 38000 that._addClass( 38001 this.instance.options.handle ? 38002 this.item.find( this.instance.options.handle ) : 38003 this.item, 38004 "ui-sortable-handle" 38005 ); 38006 } ); 38007 }, 38008 38009 _destroy: function() { 38010 this._mouseDestroy(); 38011 38012 for ( var i = this.items.length - 1; i >= 0; i-- ) { 38013 this.items[ i ].item.removeData( this.widgetName + "-item" ); 38014 } 38015 38016 return this; 38017 }, 38018 38019 _mouseCapture: function( event, overrideHandle ) { 38020 var currentItem = null, 38021 validHandle = false, 38022 that = this; 38023 38024 if ( this.reverting ) { 38025 return false; 38026 } 38027 38028 if ( this.options.disabled || this.options.type === "static" ) { 38029 return false; 38030 } 38031 38032 //We have to refresh the items data once first 38033 this._refreshItems( event ); 38034 38035 //Find out if the clicked node (or one of its parents) is a actual item in this.items 38036 $( event.target ).parents().each( function() { 38037 if ( $.data( this, that.widgetName + "-item" ) === that ) { 38038 currentItem = $( this ); 38039 return false; 38040 } 38041 } ); 38042 if ( $.data( event.target, that.widgetName + "-item" ) === that ) { 38043 currentItem = $( event.target ); 38044 } 38045 38046 if ( !currentItem ) { 38047 return false; 38048 } 38049 if ( this.options.handle && !overrideHandle ) { 38050 $( this.options.handle, currentItem ).find( "*" ).addBack().each( function() { 38051 if ( this === event.target ) { 38052 validHandle = true; 38053 } 38054 } ); 38055 if ( !validHandle ) { 38056 return false; 38057 } 38058 } 38059 38060 this.currentItem = currentItem; 38061 this._removeCurrentsFromItems(); 38062 return true; 38063 38064 }, 38065 38066 _mouseStart: function( event, overrideHandle, noActivation ) { 38067 38068 var i, body, 38069 o = this.options; 38070 38071 this.currentContainer = this; 38072 38073 //We only need to call refreshPositions, because the refreshItems call has been moved to 38074 // mouseCapture 38075 this.refreshPositions(); 38076 38077 //Create and append the visible helper 38078 this.helper = this._createHelper( event ); 38079 38080 //Cache the helper size 38081 this._cacheHelperProportions(); 38082 38083 /* 38084 * - Position generation - 38085 * This block generates everything position related - it's the core of draggables. 38086 */ 38087 38088 //Cache the margins of the original element 38089 this._cacheMargins(); 38090 38091 //Get the next scrolling parent 38092 this.scrollParent = this.helper.scrollParent(); 38093 38094 //The element's absolute position on the page minus margins 38095 this.offset = this.currentItem.offset(); 38096 this.offset = { 38097 top: this.offset.top - this.margins.top, 38098 left: this.offset.left - this.margins.left 38099 }; 38100 38101 $.extend( this.offset, { 38102 click: { //Where the click happened, relative to the element 38103 left: event.pageX - this.offset.left, 38104 top: event.pageY - this.offset.top 38105 }, 38106 parent: this._getParentOffset(), 38107 38108 // This is a relative to absolute position minus the actual position calculation - 38109 // only used for relative positioned helper 38110 relative: this._getRelativeOffset() 38111 } ); 38112 38113 // Only after we got the offset, we can change the helper's position to absolute 38114 // TODO: Still need to figure out a way to make relative sorting possible 38115 this.helper.css( "position", "absolute" ); 38116 this.cssPosition = this.helper.css( "position" ); 38117 38118 //Generate the original position 38119 this.originalPosition = this._generatePosition( event ); 38120 this.originalPageX = event.pageX; 38121 this.originalPageY = event.pageY; 38122 38123 //Adjust the mouse offset relative to the helper if "cursorAt" is supplied 38124 ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) ); 38125 38126 //Cache the former DOM position 38127 this.domPosition = { 38128 prev: this.currentItem.prev()[ 0 ], 38129 parent: this.currentItem.parent()[ 0 ] 38130 }; 38131 38132 // If the helper is not the original, hide the original so it's not playing any role during 38133 // the drag, won't cause anything bad this way 38134 if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) { 38135 this.currentItem.hide(); 38136 } 38137 38138 //Create the placeholder 38139 this._createPlaceholder(); 38140 38141 //Set a containment if given in the options 38142 if ( o.containment ) { 38143 this._setContainment(); 38144 } 38145 38146 if ( o.cursor && o.cursor !== "auto" ) { // cursor option 38147 body = this.document.find( "body" ); 38148 38149 // Support: IE 38150 this.storedCursor = body.css( "cursor" ); 38151 body.css( "cursor", o.cursor ); 38152 38153 this.storedStylesheet = 38154 $( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body ); 38155 } 38156 38157 if ( o.opacity ) { // opacity option 38158 if ( this.helper.css( "opacity" ) ) { 38159 this._storedOpacity = this.helper.css( "opacity" ); 38160 } 38161 this.helper.css( "opacity", o.opacity ); 38162 } 38163 38164 if ( o.zIndex ) { // zIndex option 38165 if ( this.helper.css( "zIndex" ) ) { 38166 this._storedZIndex = this.helper.css( "zIndex" ); 38167 } 38168 this.helper.css( "zIndex", o.zIndex ); 38169 } 38170 38171 //Prepare scrolling 38172 if ( this.scrollParent[ 0 ] !== this.document[ 0 ] && 38173 this.scrollParent[ 0 ].tagName !== "HTML" ) { 38174 this.overflowOffset = this.scrollParent.offset(); 38175 } 38176 38177 //Call callbacks 38178 this._trigger( "start", event, this._uiHash() ); 38179 38180 //Recache the helper size 38181 if ( !this._preserveHelperProportions ) { 38182 this._cacheHelperProportions(); 38183 } 38184 38185 //Post "activate" events to possible containers 38186 if ( !noActivation ) { 38187 for ( i = this.containers.length - 1; i >= 0; i-- ) { 38188 this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) ); 38189 } 38190 } 38191 38192 //Prepare possible droppables 38193 if ( $.ui.ddmanager ) { 38194 $.ui.ddmanager.current = this; 38195 } 38196 38197 if ( $.ui.ddmanager && !o.dropBehaviour ) { 38198 $.ui.ddmanager.prepareOffsets( this, event ); 38199 } 38200 38201 this.dragging = true; 38202 38203 this._addClass( this.helper, "ui-sortable-helper" ); 38204 38205 // Execute the drag once - this causes the helper not to be visiblebefore getting its 38206 // correct position 38207 this._mouseDrag( event ); 38208 return true; 38209 38210 }, 38211 38212 _mouseDrag: function( event ) { 38213 var i, item, itemElement, intersection, 38214 o = this.options, 38215 scrolled = false; 38216 38217 //Compute the helpers position 38218 this.position = this._generatePosition( event ); 38219 this.positionAbs = this._convertPositionTo( "absolute" ); 38220 38221 if ( !this.lastPositionAbs ) { 38222 this.lastPositionAbs = this.positionAbs; 38223 } 38224 38225 //Do scrolling 38226 if ( this.options.scroll ) { 38227 if ( this.scrollParent[ 0 ] !== this.document[ 0 ] && 38228 this.scrollParent[ 0 ].tagName !== "HTML" ) { 38229 38230 if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) - 38231 event.pageY < o.scrollSensitivity ) { 38232 this.scrollParent[ 0 ].scrollTop = 38233 scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed; 38234 } else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) { 38235 this.scrollParent[ 0 ].scrollTop = 38236 scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed; 38237 } 38238 38239 if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) - 38240 event.pageX < o.scrollSensitivity ) { 38241 this.scrollParent[ 0 ].scrollLeft = scrolled = 38242 this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed; 38243 } else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) { 38244 this.scrollParent[ 0 ].scrollLeft = scrolled = 38245 this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed; 38246 } 38247 38248 } else { 38249 38250 if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) { 38251 scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed ); 38252 } else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) < 38253 o.scrollSensitivity ) { 38254 scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed ); 38255 } 38256 38257 if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) { 38258 scrolled = this.document.scrollLeft( 38259 this.document.scrollLeft() - o.scrollSpeed 38260 ); 38261 } else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) < 38262 o.scrollSensitivity ) { 38263 scrolled = this.document.scrollLeft( 38264 this.document.scrollLeft() + o.scrollSpeed 38265 ); 38266 } 38267 38268 } 38269 38270 if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) { 38271 $.ui.ddmanager.prepareOffsets( this, event ); 38272 } 38273 } 38274 38275 //Regenerate the absolute position used for position checks 38276 this.positionAbs = this._convertPositionTo( "absolute" ); 38277 38278 //Set the helper position 38279 if ( !this.options.axis || this.options.axis !== "y" ) { 38280 this.helper[ 0 ].style.left = this.position.left + "px"; 38281 } 38282 if ( !this.options.axis || this.options.axis !== "x" ) { 38283 this.helper[ 0 ].style.top = this.position.top + "px"; 38284 } 38285 38286 //Rearrange 38287 for ( i = this.items.length - 1; i >= 0; i-- ) { 38288 38289 //Cache variables and intersection, continue if no intersection 38290 item = this.items[ i ]; 38291 itemElement = item.item[ 0 ]; 38292 intersection = this._intersectsWithPointer( item ); 38293 if ( !intersection ) { 38294 continue; 38295 } 38296 38297 // Only put the placeholder inside the current Container, skip all 38298 // items from other containers. This works because when moving 38299 // an item from one container to another the 38300 // currentContainer is switched before the placeholder is moved. 38301 // 38302 // Without this, moving items in "sub-sortables" can cause 38303 // the placeholder to jitter between the outer and inner container. 38304 if ( item.instance !== this.currentContainer ) { 38305 continue; 38306 } 38307 38308 // Cannot intersect with itself 38309 // no useless actions that have been done before 38310 // no action if the item moved is the parent of the item checked 38311 if ( itemElement !== this.currentItem[ 0 ] && 38312 this.placeholder[ intersection === 1 ? "next" : "prev" ]()[ 0 ] !== itemElement && 38313 !$.contains( this.placeholder[ 0 ], itemElement ) && 38314 ( this.options.type === "semi-dynamic" ? 38315 !$.contains( this.element[ 0 ], itemElement ) : 38316 true 38317 ) 38318 ) { 38319 38320 this.direction = intersection === 1 ? "down" : "up"; 38321 38322 if ( this.options.tolerance === "pointer" || this._intersectsWithSides( item ) ) { 38323 this._rearrange( event, item ); 38324 } else { 38325 break; 38326 } 38327 38328 this._trigger( "change", event, this._uiHash() ); 38329 break; 38330 } 38331 } 38332 38333 //Post events to containers 38334 this._contactContainers( event ); 38335 38336 //Interconnect with droppables 38337 if ( $.ui.ddmanager ) { 38338 $.ui.ddmanager.drag( this, event ); 38339 } 38340 38341 //Call callbacks 38342 this._trigger( "sort", event, this._uiHash() ); 38343 38344 this.lastPositionAbs = this.positionAbs; 38345 return false; 38346 38347 }, 38348 38349 _mouseStop: function( event, noPropagation ) { 38350 38351 if ( !event ) { 38352 return; 38353 } 38354 38355 //If we are using droppables, inform the manager about the drop 38356 if ( $.ui.ddmanager && !this.options.dropBehaviour ) { 38357 $.ui.ddmanager.drop( this, event ); 38358 } 38359 38360 if ( this.options.revert ) { 38361 var that = this, 38362 cur = this.placeholder.offset(), 38363 axis = this.options.axis, 38364 animation = {}; 38365 38366 if ( !axis || axis === "x" ) { 38367 animation.left = cur.left - this.offset.parent.left - this.margins.left + 38368 ( this.offsetParent[ 0 ] === this.document[ 0 ].body ? 38369 0 : 38370 this.offsetParent[ 0 ].scrollLeft 38371 ); 38372 } 38373 if ( !axis || axis === "y" ) { 38374 animation.top = cur.top - this.offset.parent.top - this.margins.top + 38375 ( this.offsetParent[ 0 ] === this.document[ 0 ].body ? 38376 0 : 38377 this.offsetParent[ 0 ].scrollTop 38378 ); 38379 } 38380 this.reverting = true; 38381 $( this.helper ).animate( 38382 animation, 38383 parseInt( this.options.revert, 10 ) || 500, 38384 function() { 38385 that._clear( event ); 38386 } 38387 ); 38388 } else { 38389 this._clear( event, noPropagation ); 38390 } 38391 38392 return false; 38393 38394 }, 38395 38396 cancel: function() { 38397 38398 if ( this.dragging ) { 38399 38400 this._mouseUp( new $.Event( "mouseup", { target: null } ) ); 38401 38402 if ( this.options.helper === "original" ) { 38403 this.currentItem.css( this._storedCSS ); 38404 this._removeClass( this.currentItem, "ui-sortable-helper" ); 38405 } else { 38406 this.currentItem.show(); 38407 } 38408 38409 //Post deactivating events to containers 38410 for ( var i = this.containers.length - 1; i >= 0; i-- ) { 38411 this.containers[ i ]._trigger( "deactivate", null, this._uiHash( this ) ); 38412 if ( this.containers[ i ].containerCache.over ) { 38413 this.containers[ i ]._trigger( "out", null, this._uiHash( this ) ); 38414 this.containers[ i ].containerCache.over = 0; 38415 } 38416 } 38417 38418 } 38419 38420 if ( this.placeholder ) { 38421 38422 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, 38423 // it unbinds ALL events from the original node! 38424 if ( this.placeholder[ 0 ].parentNode ) { 38425 this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] ); 38426 } 38427 if ( this.options.helper !== "original" && this.helper && 38428 this.helper[ 0 ].parentNode ) { 38429 this.helper.remove(); 38430 } 38431 38432 $.extend( this, { 38433 helper: null, 38434 dragging: false, 38435 reverting: false, 38436 _noFinalSort: null 38437 } ); 38438 38439 if ( this.domPosition.prev ) { 38440 $( this.domPosition.prev ).after( this.currentItem ); 38441 } else { 38442 $( this.domPosition.parent ).prepend( this.currentItem ); 38443 } 38444 } 38445 38446 return this; 38447 38448 }, 38449 38450 serialize: function( o ) { 38451 38452 var items = this._getItemsAsjQuery( o && o.connected ), 38453 str = []; 38454 o = o || {}; 38455 38456 $( items ).each( function() { 38457 var res = ( $( o.item || this ).attr( o.attribute || "id" ) || "" ) 38458 .match( o.expression || ( /(.+)[\-=_](.+)/ ) ); 38459 if ( res ) { 38460 str.push( 38461 ( o.key || res[ 1 ] + "[]" ) + 38462 "=" + ( o.key && o.expression ? res[ 1 ] : res[ 2 ] ) ); 38463 } 38464 } ); 38465 38466 if ( !str.length && o.key ) { 38467 str.push( o.key + "=" ); 38468 } 38469 38470 return str.join( "&" ); 38471 38472 }, 38473 38474 toArray: function( o ) { 38475 38476 var items = this._getItemsAsjQuery( o && o.connected ), 38477 ret = []; 38478 38479 o = o || {}; 38480 38481 items.each( function() { 38482 ret.push( $( o.item || this ).attr( o.attribute || "id" ) || "" ); 38483 } ); 38484 return ret; 38485 38486 }, 38487 38488 /* Be careful with the following core functions */ 38489 _intersectsWith: function( item ) { 38490 38491 var x1 = this.positionAbs.left, 38492 x2 = x1 + this.helperProportions.width, 38493 y1 = this.positionAbs.top, 38494 y2 = y1 + this.helperProportions.height, 38495 l = item.left, 38496 r = l + item.width, 38497 t = item.top, 38498 b = t + item.height, 38499 dyClick = this.offset.click.top, 38500 dxClick = this.offset.click.left, 38501 isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && 38502 ( y1 + dyClick ) < b ), 38503 isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && 38504 ( x1 + dxClick ) < r ), 38505 isOverElement = isOverElementHeight && isOverElementWidth; 38506 38507 if ( this.options.tolerance === "pointer" || 38508 this.options.forcePointerForContainers || 38509 ( this.options.tolerance !== "pointer" && 38510 this.helperProportions[ this.floating ? "width" : "height" ] > 38511 item[ this.floating ? "width" : "height" ] ) 38512 ) { 38513 return isOverElement; 38514 } else { 38515 38516 return ( l < x1 + ( this.helperProportions.width / 2 ) && // Right Half 38517 x2 - ( this.helperProportions.width / 2 ) < r && // Left Half 38518 t < y1 + ( this.helperProportions.height / 2 ) && // Bottom Half 38519 y2 - ( this.helperProportions.height / 2 ) < b ); // Top Half 38520 38521 } 38522 }, 38523 38524 _intersectsWithPointer: function( item ) { 38525 var verticalDirection, horizontalDirection, 38526 isOverElementHeight = ( this.options.axis === "x" ) || 38527 this._isOverAxis( 38528 this.positionAbs.top + this.offset.click.top, item.top, item.height ), 38529 isOverElementWidth = ( this.options.axis === "y" ) || 38530 this._isOverAxis( 38531 this.positionAbs.left + this.offset.click.left, item.left, item.width ), 38532 isOverElement = isOverElementHeight && isOverElementWidth; 38533 38534 if ( !isOverElement ) { 38535 return false; 38536 } 38537 38538 verticalDirection = this._getDragVerticalDirection(); 38539 horizontalDirection = this._getDragHorizontalDirection(); 38540 38541 return this.floating ? 38542 ( ( horizontalDirection === "right" || verticalDirection === "down" ) ? 2 : 1 ) 38543 : ( verticalDirection && ( verticalDirection === "down" ? 2 : 1 ) ); 38544 38545 }, 38546 38547 _intersectsWithSides: function( item ) { 38548 38549 var isOverBottomHalf = this._isOverAxis( this.positionAbs.top + 38550 this.offset.click.top, item.top + ( item.height / 2 ), item.height ), 38551 isOverRightHalf = this._isOverAxis( this.positionAbs.left + 38552 this.offset.click.left, item.left + ( item.width / 2 ), item.width ), 38553 verticalDirection = this._getDragVerticalDirection(), 38554 horizontalDirection = this._getDragHorizontalDirection(); 38555 38556 if ( this.floating && horizontalDirection ) { 38557 return ( ( horizontalDirection === "right" && isOverRightHalf ) || 38558 ( horizontalDirection === "left" && !isOverRightHalf ) ); 38559 } else { 38560 return verticalDirection && ( ( verticalDirection === "down" && isOverBottomHalf ) || 38561 ( verticalDirection === "up" && !isOverBottomHalf ) ); 38562 } 38563 38564 }, 38565 38566 _getDragVerticalDirection: function() { 38567 var delta = this.positionAbs.top - this.lastPositionAbs.top; 38568 return delta !== 0 && ( delta > 0 ? "down" : "up" ); 38569 }, 38570 38571 _getDragHorizontalDirection: function() { 38572 var delta = this.positionAbs.left - this.lastPositionAbs.left; 38573 return delta !== 0 && ( delta > 0 ? "right" : "left" ); 38574 }, 38575 38576 refresh: function( event ) { 38577 this._refreshItems( event ); 38578 this._setHandleClassName(); 38579 this.refreshPositions(); 38580 return this; 38581 }, 38582 38583 _connectWith: function() { 38584 var options = this.options; 38585 return options.connectWith.constructor === String ? 38586 [ options.connectWith ] : 38587 options.connectWith; 38588 }, 38589 38590 _getItemsAsjQuery: function( connected ) { 38591 38592 var i, j, cur, inst, 38593 items = [], 38594 queries = [], 38595 connectWith = this._connectWith(); 38596 38597 if ( connectWith && connected ) { 38598 for ( i = connectWith.length - 1; i >= 0; i-- ) { 38599 cur = $( connectWith[ i ], this.document[ 0 ] ); 38600 for ( j = cur.length - 1; j >= 0; j-- ) { 38601 inst = $.data( cur[ j ], this.widgetFullName ); 38602 if ( inst && inst !== this && !inst.options.disabled ) { 38603 queries.push( [ $.isFunction( inst.options.items ) ? 38604 inst.options.items.call( inst.element ) : 38605 $( inst.options.items, inst.element ) 38606 .not( ".ui-sortable-helper" ) 38607 .not( ".ui-sortable-placeholder" ), inst ] ); 38608 } 38609 } 38610 } 38611 } 38612 38613 queries.push( [ $.isFunction( this.options.items ) ? 38614 this.options.items 38615 .call( this.element, null, { options: this.options, item: this.currentItem } ) : 38616 $( this.options.items, this.element ) 38617 .not( ".ui-sortable-helper" ) 38618 .not( ".ui-sortable-placeholder" ), this ] ); 38619 38620 function addItems() { 38621 items.push( this ); 38622 } 38623 for ( i = queries.length - 1; i >= 0; i-- ) { 38624 queries[ i ][ 0 ].each( addItems ); 38625 } 38626 38627 return $( items ); 38628 38629 }, 38630 38631 _removeCurrentsFromItems: function() { 38632 38633 var list = this.currentItem.find( ":data(" + this.widgetName + "-item)" ); 38634 38635 this.items = $.grep( this.items, function( item ) { 38636 for ( var j = 0; j < list.length; j++ ) { 38637 if ( list[ j ] === item.item[ 0 ] ) { 38638 return false; 38639 } 38640 } 38641 return true; 38642 } ); 38643 38644 }, 38645 38646 _refreshItems: function( event ) { 38647 38648 this.items = []; 38649 this.containers = [ this ]; 38650 38651 var i, j, cur, inst, targetData, _queries, item, queriesLength, 38652 items = this.items, 38653 queries = [ [ $.isFunction( this.options.items ) ? 38654 this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) : 38655 $( this.options.items, this.element ), this ] ], 38656 connectWith = this._connectWith(); 38657 38658 //Shouldn't be run the first time through due to massive slow-down 38659 if ( connectWith && this.ready ) { 38660 for ( i = connectWith.length - 1; i >= 0; i-- ) { 38661 cur = $( connectWith[ i ], this.document[ 0 ] ); 38662 for ( j = cur.length - 1; j >= 0; j-- ) { 38663 inst = $.data( cur[ j ], this.widgetFullName ); 38664 if ( inst && inst !== this && !inst.options.disabled ) { 38665 queries.push( [ $.isFunction( inst.options.items ) ? 38666 inst.options.items 38667 .call( inst.element[ 0 ], event, { item: this.currentItem } ) : 38668 $( inst.options.items, inst.element ), inst ] ); 38669 this.containers.push( inst ); 38670 } 38671 } 38672 } 38673 } 38674 38675 for ( i = queries.length - 1; i >= 0; i-- ) { 38676 targetData = queries[ i ][ 1 ]; 38677 _queries = queries[ i ][ 0 ]; 38678 38679 for ( j = 0, queriesLength = _queries.length; j < queriesLength; j++ ) { 38680 item = $( _queries[ j ] ); 38681 38682 // Data for target checking (mouse manager) 38683 item.data( this.widgetName + "-item", targetData ); 38684 38685 items.push( { 38686 item: item, 38687 instance: targetData, 38688 width: 0, height: 0, 38689 left: 0, top: 0 38690 } ); 38691 } 38692 } 38693 38694 }, 38695 38696 refreshPositions: function( fast ) { 38697 38698 // Determine whether items are being displayed horizontally 38699 this.floating = this.items.length ? 38700 this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) : 38701 false; 38702 38703 //This has to be redone because due to the item being moved out/into the offsetParent, 38704 // the offsetParent's position will change 38705 if ( this.offsetParent && this.helper ) { 38706 this.offset.parent = this._getParentOffset(); 38707 } 38708 38709 var i, item, t, p; 38710 38711 for ( i = this.items.length - 1; i >= 0; i-- ) { 38712 item = this.items[ i ]; 38713 38714 //We ignore calculating positions of all connected containers when we're not over them 38715 if ( item.instance !== this.currentContainer && this.currentContainer && 38716 item.item[ 0 ] !== this.currentItem[ 0 ] ) { 38717 continue; 38718 } 38719 38720 t = this.options.toleranceElement ? 38721 $( this.options.toleranceElement, item.item ) : 38722 item.item; 38723 38724 if ( !fast ) { 38725 item.width = t.outerWidth(); 38726 item.height = t.outerHeight(); 38727 } 38728 38729 p = t.offset(); 38730 item.left = p.left; 38731 item.top = p.top; 38732 } 38733 38734 if ( this.options.custom && this.options.custom.refreshContainers ) { 38735 this.options.custom.refreshContainers.call( this ); 38736 } else { 38737 for ( i = this.containers.length - 1; i >= 0; i-- ) { 38738 p = this.containers[ i ].element.offset(); 38739 this.containers[ i ].containerCache.left = p.left; 38740 this.containers[ i ].containerCache.top = p.top; 38741 this.containers[ i ].containerCache.width = 38742 this.containers[ i ].element.outerWidth(); 38743 this.containers[ i ].containerCache.height = 38744 this.containers[ i ].element.outerHeight(); 38745 } 38746 } 38747 38748 return this; 38749 }, 38750 38751 _createPlaceholder: function( that ) { 38752 that = that || this; 38753 var className, 38754 o = that.options; 38755 38756 if ( !o.placeholder || o.placeholder.constructor === String ) { 38757 className = o.placeholder; 38758 o.placeholder = { 38759 element: function() { 38760 38761 var nodeName = that.currentItem[ 0 ].nodeName.toLowerCase(), 38762 element = $( "<" + nodeName + ">", that.document[ 0 ] ); 38763 38764 that._addClass( element, "ui-sortable-placeholder", 38765 className || that.currentItem[ 0 ].className ) 38766 ._removeClass( element, "ui-sortable-helper" ); 38767 38768 if ( nodeName === "tbody" ) { 38769 that._createTrPlaceholder( 38770 that.currentItem.find( "tr" ).eq( 0 ), 38771 $( "<tr>", that.document[ 0 ] ).appendTo( element ) 38772 ); 38773 } else if ( nodeName === "tr" ) { 38774 that._createTrPlaceholder( that.currentItem, element ); 38775 } else if ( nodeName === "img" ) { 38776 element.attr( "src", that.currentItem.attr( "src" ) ); 38777 } 38778 38779 if ( !className ) { 38780 element.css( "visibility", "hidden" ); 38781 } 38782 38783 return element; 38784 }, 38785 update: function( container, p ) { 38786 38787 // 1. If a className is set as 'placeholder option, we don't force sizes - 38788 // the class is responsible for that 38789 // 2. The option 'forcePlaceholderSize can be enabled to force it even if a 38790 // class name is specified 38791 if ( className && !o.forcePlaceholderSize ) { 38792 return; 38793 } 38794 38795 //If the element doesn't have a actual height by itself (without styles coming 38796 // from a stylesheet), it receives the inline height from the dragged item 38797 if ( !p.height() ) { 38798 p.height( 38799 that.currentItem.innerHeight() - 38800 parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) - 38801 parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) ); 38802 } 38803 if ( !p.width() ) { 38804 p.width( 38805 that.currentItem.innerWidth() - 38806 parseInt( that.currentItem.css( "paddingLeft" ) || 0, 10 ) - 38807 parseInt( that.currentItem.css( "paddingRight" ) || 0, 10 ) ); 38808 } 38809 } 38810 }; 38811 } 38812 38813 //Create the placeholder 38814 that.placeholder = $( o.placeholder.element.call( that.element, that.currentItem ) ); 38815 38816 //Append it after the actual current item 38817 that.currentItem.after( that.placeholder ); 38818 38819 //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317) 38820 o.placeholder.update( that, that.placeholder ); 38821 38822 }, 38823 38824 _createTrPlaceholder: function( sourceTr, targetTr ) { 38825 var that = this; 38826 38827 sourceTr.children().each( function() { 38828 $( "<td> </td>", that.document[ 0 ] ) 38829 .attr( "colspan", $( this ).attr( "colspan" ) || 1 ) 38830 .appendTo( targetTr ); 38831 } ); 38832 }, 38833 38834 _contactContainers: function( event ) { 38835 var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom, 38836 floating, axis, 38837 innermostContainer = null, 38838 innermostIndex = null; 38839 38840 // Get innermost container that intersects with item 38841 for ( i = this.containers.length - 1; i >= 0; i-- ) { 38842 38843 // Never consider a container that's located within the item itself 38844 if ( $.contains( this.currentItem[ 0 ], this.containers[ i ].element[ 0 ] ) ) { 38845 continue; 38846 } 38847 38848 if ( this._intersectsWith( this.containers[ i ].containerCache ) ) { 38849 38850 // If we've already found a container and it's more "inner" than this, then continue 38851 if ( innermostContainer && 38852 $.contains( 38853 this.containers[ i ].element[ 0 ], 38854 innermostContainer.element[ 0 ] ) ) { 38855 continue; 38856 } 38857 38858 innermostContainer = this.containers[ i ]; 38859 innermostIndex = i; 38860 38861 } else { 38862 38863 // container doesn't intersect. trigger "out" event if necessary 38864 if ( this.containers[ i ].containerCache.over ) { 38865 this.containers[ i ]._trigger( "out", event, this._uiHash( this ) ); 38866 this.containers[ i ].containerCache.over = 0; 38867 } 38868 } 38869 38870 } 38871 38872 // If no intersecting containers found, return 38873 if ( !innermostContainer ) { 38874 return; 38875 } 38876 38877 // Move the item into the container if it's not there already 38878 if ( this.containers.length === 1 ) { 38879 if ( !this.containers[ innermostIndex ].containerCache.over ) { 38880 this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) ); 38881 this.containers[ innermostIndex ].containerCache.over = 1; 38882 } 38883 } else { 38884 38885 // When entering a new container, we will find the item with the least distance and 38886 // append our item near it 38887 dist = 10000; 38888 itemWithLeastDistance = null; 38889 floating = innermostContainer.floating || this._isFloating( this.currentItem ); 38890 posProperty = floating ? "left" : "top"; 38891 sizeProperty = floating ? "width" : "height"; 38892 axis = floating ? "pageX" : "pageY"; 38893 38894 for ( j = this.items.length - 1; j >= 0; j-- ) { 38895 if ( !$.contains( 38896 this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] ) 38897 ) { 38898 continue; 38899 } 38900 if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) { 38901 continue; 38902 } 38903 38904 cur = this.items[ j ].item.offset()[ posProperty ]; 38905 nearBottom = false; 38906 if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) { 38907 nearBottom = true; 38908 } 38909 38910 if ( Math.abs( event[ axis ] - cur ) < dist ) { 38911 dist = Math.abs( event[ axis ] - cur ); 38912 itemWithLeastDistance = this.items[ j ]; 38913 this.direction = nearBottom ? "up" : "down"; 38914 } 38915 } 38916 38917 //Check if dropOnEmpty is enabled 38918 if ( !itemWithLeastDistance && !this.options.dropOnEmpty ) { 38919 return; 38920 } 38921 38922 if ( this.currentContainer === this.containers[ innermostIndex ] ) { 38923 if ( !this.currentContainer.containerCache.over ) { 38924 this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() ); 38925 this.currentContainer.containerCache.over = 1; 38926 } 38927 return; 38928 } 38929 38930 itemWithLeastDistance ? 38931 this._rearrange( event, itemWithLeastDistance, null, true ) : 38932 this._rearrange( event, null, this.containers[ innermostIndex ].element, true ); 38933 this._trigger( "change", event, this._uiHash() ); 38934 this.containers[ innermostIndex ]._trigger( "change", event, this._uiHash( this ) ); 38935 this.currentContainer = this.containers[ innermostIndex ]; 38936 38937 //Update the placeholder 38938 this.options.placeholder.update( this.currentContainer, this.placeholder ); 38939 38940 this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) ); 38941 this.containers[ innermostIndex ].containerCache.over = 1; 38942 } 38943 38944 }, 38945 38946 _createHelper: function( event ) { 38947 38948 var o = this.options, 38949 helper = $.isFunction( o.helper ) ? 38950 $( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) : 38951 ( o.helper === "clone" ? this.currentItem.clone() : this.currentItem ); 38952 38953 //Add the helper to the DOM if that didn't happen already 38954 if ( !helper.parents( "body" ).length ) { 38955 $( o.appendTo !== "parent" ? 38956 o.appendTo : 38957 this.currentItem[ 0 ].parentNode )[ 0 ].appendChild( helper[ 0 ] ); 38958 } 38959 38960 if ( helper[ 0 ] === this.currentItem[ 0 ] ) { 38961 this._storedCSS = { 38962 width: this.currentItem[ 0 ].style.width, 38963 height: this.currentItem[ 0 ].style.height, 38964 position: this.currentItem.css( "position" ), 38965 top: this.currentItem.css( "top" ), 38966 left: this.currentItem.css( "left" ) 38967 }; 38968 } 38969 38970 if ( !helper[ 0 ].style.width || o.forceHelperSize ) { 38971 helper.width( this.currentItem.width() ); 38972 } 38973 if ( !helper[ 0 ].style.height || o.forceHelperSize ) { 38974 helper.height( this.currentItem.height() ); 38975 } 38976 38977 return helper; 38978 38979 }, 38980 38981 _adjustOffsetFromHelper: function( obj ) { 38982 if ( typeof obj === "string" ) { 38983 obj = obj.split( " " ); 38984 } 38985 if ( $.isArray( obj ) ) { 38986 obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 }; 38987 } 38988 if ( "left" in obj ) { 38989 this.offset.click.left = obj.left + this.margins.left; 38990 } 38991 if ( "right" in obj ) { 38992 this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; 38993 } 38994 if ( "top" in obj ) { 38995 this.offset.click.top = obj.top + this.margins.top; 38996 } 38997 if ( "bottom" in obj ) { 38998 this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; 38999 } 39000 }, 39001 39002 _getParentOffset: function() { 39003 39004 //Get the offsetParent and cache its position 39005 this.offsetParent = this.helper.offsetParent(); 39006 var po = this.offsetParent.offset(); 39007 39008 // This is a special case where we need to modify a offset calculated on start, since the 39009 // following happened: 39010 // 1. The position of the helper is absolute, so it's position is calculated based on the 39011 // next positioned parent 39012 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't 39013 // the document, which means that the scroll is included in the initial calculation of the 39014 // offset of the parent, and never recalculated upon drag 39015 if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] && 39016 $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) { 39017 po.left += this.scrollParent.scrollLeft(); 39018 po.top += this.scrollParent.scrollTop(); 39019 } 39020 39021 // This needs to be actually done for all browsers, since pageX/pageY includes this 39022 // information with an ugly IE fix 39023 if ( this.offsetParent[ 0 ] === this.document[ 0 ].body || 39024 ( this.offsetParent[ 0 ].tagName && 39025 this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) { 39026 po = { top: 0, left: 0 }; 39027 } 39028 39029 return { 39030 top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ), 39031 left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 ) 39032 }; 39033 39034 }, 39035 39036 _getRelativeOffset: function() { 39037 39038 if ( this.cssPosition === "relative" ) { 39039 var p = this.currentItem.position(); 39040 return { 39041 top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) + 39042 this.scrollParent.scrollTop(), 39043 left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) + 39044 this.scrollParent.scrollLeft() 39045 }; 39046 } else { 39047 return { top: 0, left: 0 }; 39048 } 39049 39050 }, 39051 39052 _cacheMargins: function() { 39053 this.margins = { 39054 left: ( parseInt( this.currentItem.css( "marginLeft" ), 10 ) || 0 ), 39055 top: ( parseInt( this.currentItem.css( "marginTop" ), 10 ) || 0 ) 39056 }; 39057 }, 39058 39059 _cacheHelperProportions: function() { 39060 this.helperProportions = { 39061 width: this.helper.outerWidth(), 39062 height: this.helper.outerHeight() 39063 }; 39064 }, 39065 39066 _setContainment: function() { 39067 39068 var ce, co, over, 39069 o = this.options; 39070 if ( o.containment === "parent" ) { 39071 o.containment = this.helper[ 0 ].parentNode; 39072 } 39073 if ( o.containment === "document" || o.containment === "window" ) { 39074 this.containment = [ 39075 0 - this.offset.relative.left - this.offset.parent.left, 39076 0 - this.offset.relative.top - this.offset.parent.top, 39077 o.containment === "document" ? 39078 this.document.width() : 39079 this.window.width() - this.helperProportions.width - this.margins.left, 39080 ( o.containment === "document" ? 39081 ( this.document.height() || document.body.parentNode.scrollHeight ) : 39082 this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight 39083 ) - this.helperProportions.height - this.margins.top 39084 ]; 39085 } 39086 39087 if ( !( /^(document|window|parent)$/ ).test( o.containment ) ) { 39088 ce = $( o.containment )[ 0 ]; 39089 co = $( o.containment ).offset(); 39090 over = ( $( ce ).css( "overflow" ) !== "hidden" ); 39091 39092 this.containment = [ 39093 co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) + 39094 ( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left, 39095 co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) + 39096 ( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top, 39097 co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - 39098 ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) - 39099 ( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) - 39100 this.helperProportions.width - this.margins.left, 39101 co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - 39102 ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) - 39103 ( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) - 39104 this.helperProportions.height - this.margins.top 39105 ]; 39106 } 39107 39108 }, 39109 39110 _convertPositionTo: function( d, pos ) { 39111 39112 if ( !pos ) { 39113 pos = this.position; 39114 } 39115 var mod = d === "absolute" ? 1 : -1, 39116 scroll = this.cssPosition === "absolute" && 39117 !( this.scrollParent[ 0 ] !== this.document[ 0 ] && 39118 $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? 39119 this.offsetParent : 39120 this.scrollParent, 39121 scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName ); 39122 39123 return { 39124 top: ( 39125 39126 // The absolute mouse position 39127 pos.top + 39128 39129 // Only for relative positioned nodes: Relative offset from element to offset parent 39130 this.offset.relative.top * mod + 39131 39132 // The offsetParent's offset without borders (offset + border) 39133 this.offset.parent.top * mod - 39134 ( ( this.cssPosition === "fixed" ? 39135 -this.scrollParent.scrollTop() : 39136 ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod ) 39137 ), 39138 left: ( 39139 39140 // The absolute mouse position 39141 pos.left + 39142 39143 // Only for relative positioned nodes: Relative offset from element to offset parent 39144 this.offset.relative.left * mod + 39145 39146 // The offsetParent's offset without borders (offset + border) 39147 this.offset.parent.left * mod - 39148 ( ( this.cssPosition === "fixed" ? 39149 -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : 39150 scroll.scrollLeft() ) * mod ) 39151 ) 39152 }; 39153 39154 }, 39155 39156 _generatePosition: function( event ) { 39157 39158 var top, left, 39159 o = this.options, 39160 pageX = event.pageX, 39161 pageY = event.pageY, 39162 scroll = this.cssPosition === "absolute" && 39163 !( this.scrollParent[ 0 ] !== this.document[ 0 ] && 39164 $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? 39165 this.offsetParent : 39166 this.scrollParent, 39167 scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName ); 39168 39169 // This is another very weird special case that only happens for relative elements: 39170 // 1. If the css position is relative 39171 // 2. and the scroll parent is the document or similar to the offset parent 39172 // we have to refresh the relative offset during the scroll so there are no jumps 39173 if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] && 39174 this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) { 39175 this.offset.relative = this._getRelativeOffset(); 39176 } 39177 39178 /* 39179 * - Position constraining - 39180 * Constrain the position to a mix of grid, containment. 39181 */ 39182 39183 if ( this.originalPosition ) { //If we are not dragging yet, we won't check for options 39184 39185 if ( this.containment ) { 39186 if ( event.pageX - this.offset.click.left < this.containment[ 0 ] ) { 39187 pageX = this.containment[ 0 ] + this.offset.click.left; 39188 } 39189 if ( event.pageY - this.offset.click.top < this.containment[ 1 ] ) { 39190 pageY = this.containment[ 1 ] + this.offset.click.top; 39191 } 39192 if ( event.pageX - this.offset.click.left > this.containment[ 2 ] ) { 39193 pageX = this.containment[ 2 ] + this.offset.click.left; 39194 } 39195 if ( event.pageY - this.offset.click.top > this.containment[ 3 ] ) { 39196 pageY = this.containment[ 3 ] + this.offset.click.top; 39197 } 39198 } 39199 39200 if ( o.grid ) { 39201 top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) / 39202 o.grid[ 1 ] ) * o.grid[ 1 ]; 39203 pageY = this.containment ? 39204 ( ( top - this.offset.click.top >= this.containment[ 1 ] && 39205 top - this.offset.click.top <= this.containment[ 3 ] ) ? 39206 top : 39207 ( ( top - this.offset.click.top >= this.containment[ 1 ] ) ? 39208 top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : 39209 top; 39210 39211 left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) / 39212 o.grid[ 0 ] ) * o.grid[ 0 ]; 39213 pageX = this.containment ? 39214 ( ( left - this.offset.click.left >= this.containment[ 0 ] && 39215 left - this.offset.click.left <= this.containment[ 2 ] ) ? 39216 left : 39217 ( ( left - this.offset.click.left >= this.containment[ 0 ] ) ? 39218 left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : 39219 left; 39220 } 39221 39222 } 39223 39224 return { 39225 top: ( 39226 39227 // The absolute mouse position 39228 pageY - 39229 39230 // Click offset (relative to the element) 39231 this.offset.click.top - 39232 39233 // Only for relative positioned nodes: Relative offset from element to offset parent 39234 this.offset.relative.top - 39235 39236 // The offsetParent's offset without borders (offset + border) 39237 this.offset.parent.top + 39238 ( ( this.cssPosition === "fixed" ? 39239 -this.scrollParent.scrollTop() : 39240 ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) ) 39241 ), 39242 left: ( 39243 39244 // The absolute mouse position 39245 pageX - 39246 39247 // Click offset (relative to the element) 39248 this.offset.click.left - 39249 39250 // Only for relative positioned nodes: Relative offset from element to offset parent 39251 this.offset.relative.left - 39252 39253 // The offsetParent's offset without borders (offset + border) 39254 this.offset.parent.left + 39255 ( ( this.cssPosition === "fixed" ? 39256 -this.scrollParent.scrollLeft() : 39257 scrollIsRootNode ? 0 : scroll.scrollLeft() ) ) 39258 ) 39259 }; 39260 39261 }, 39262 39263 _rearrange: function( event, i, a, hardRefresh ) { 39264 39265 a ? a[ 0 ].appendChild( this.placeholder[ 0 ] ) : 39266 i.item[ 0 ].parentNode.insertBefore( this.placeholder[ 0 ], 39267 ( this.direction === "down" ? i.item[ 0 ] : i.item[ 0 ].nextSibling ) ); 39268 39269 //Various things done here to improve the performance: 39270 // 1. we create a setTimeout, that calls refreshPositions 39271 // 2. on the instance, we have a counter variable, that get's higher after every append 39272 // 3. on the local scope, we copy the counter variable, and check in the timeout, 39273 // if it's still the same 39274 // 4. this lets only the last addition to the timeout stack through 39275 this.counter = this.counter ? ++this.counter : 1; 39276 var counter = this.counter; 39277 39278 this._delay( function() { 39279 if ( counter === this.counter ) { 39280 39281 //Precompute after each DOM insertion, NOT on mousemove 39282 this.refreshPositions( !hardRefresh ); 39283 } 39284 } ); 39285 39286 }, 39287 39288 _clear: function( event, noPropagation ) { 39289 39290 this.reverting = false; 39291 39292 // We delay all events that have to be triggered to after the point where the placeholder 39293 // has been removed and everything else normalized again 39294 var i, 39295 delayedTriggers = []; 39296 39297 // We first have to update the dom position of the actual currentItem 39298 // Note: don't do it if the current item is already removed (by a user), or it gets 39299 // reappended (see #4088) 39300 if ( !this._noFinalSort && this.currentItem.parent().length ) { 39301 this.placeholder.before( this.currentItem ); 39302 } 39303 this._noFinalSort = null; 39304 39305 if ( this.helper[ 0 ] === this.currentItem[ 0 ] ) { 39306 for ( i in this._storedCSS ) { 39307 if ( this._storedCSS[ i ] === "auto" || this._storedCSS[ i ] === "static" ) { 39308 this._storedCSS[ i ] = ""; 39309 } 39310 } 39311 this.currentItem.css( this._storedCSS ); 39312 this._removeClass( this.currentItem, "ui-sortable-helper" ); 39313 } else { 39314 this.currentItem.show(); 39315 } 39316 39317 if ( this.fromOutside && !noPropagation ) { 39318 delayedTriggers.push( function( event ) { 39319 this._trigger( "receive", event, this._uiHash( this.fromOutside ) ); 39320 } ); 39321 } 39322 if ( ( this.fromOutside || 39323 this.domPosition.prev !== 39324 this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] || 39325 this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) { 39326 39327 // Trigger update callback if the DOM position has changed 39328 delayedTriggers.push( function( event ) { 39329 this._trigger( "update", event, this._uiHash() ); 39330 } ); 39331 } 39332 39333 // Check if the items Container has Changed and trigger appropriate 39334 // events. 39335 if ( this !== this.currentContainer ) { 39336 if ( !noPropagation ) { 39337 delayedTriggers.push( function( event ) { 39338 this._trigger( "remove", event, this._uiHash() ); 39339 } ); 39340 delayedTriggers.push( ( function( c ) { 39341 return function( event ) { 39342 c._trigger( "receive", event, this._uiHash( this ) ); 39343 }; 39344 } ).call( this, this.currentContainer ) ); 39345 delayedTriggers.push( ( function( c ) { 39346 return function( event ) { 39347 c._trigger( "update", event, this._uiHash( this ) ); 39348 }; 39349 } ).call( this, this.currentContainer ) ); 39350 } 39351 } 39352 39353 //Post events to containers 39354 function delayEvent( type, instance, container ) { 39355 return function( event ) { 39356 container._trigger( type, event, instance._uiHash( instance ) ); 39357 }; 39358 } 39359 for ( i = this.containers.length - 1; i >= 0; i-- ) { 39360 if ( !noPropagation ) { 39361 delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) ); 39362 } 39363 if ( this.containers[ i ].containerCache.over ) { 39364 delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) ); 39365 this.containers[ i ].containerCache.over = 0; 39366 } 39367 } 39368 39369 //Do what was originally in plugins 39370 if ( this.storedCursor ) { 39371 this.document.find( "body" ).css( "cursor", this.storedCursor ); 39372 this.storedStylesheet.remove(); 39373 } 39374 if ( this._storedOpacity ) { 39375 this.helper.css( "opacity", this._storedOpacity ); 39376 } 39377 if ( this._storedZIndex ) { 39378 this.helper.css( "zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex ); 39379 } 39380 39381 this.dragging = false; 39382 39383 if ( !noPropagation ) { 39384 this._trigger( "beforeStop", event, this._uiHash() ); 39385 } 39386 39387 //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, 39388 // it unbinds ALL events from the original node! 39389 this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] ); 39390 39391 if ( !this.cancelHelperRemoval ) { 39392 if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) { 39393 this.helper.remove(); 39394 } 39395 this.helper = null; 39396 } 39397 39398 if ( !noPropagation ) { 39399 for ( i = 0; i < delayedTriggers.length; i++ ) { 39400 39401 // Trigger all delayed events 39402 delayedTriggers[ i ].call( this, event ); 39403 } 39404 this._trigger( "stop", event, this._uiHash() ); 39405 } 39406 39407 this.fromOutside = false; 39408 return !this.cancelHelperRemoval; 39409 39410 }, 39411 39412 _trigger: function() { 39413 if ( $.Widget.prototype._trigger.apply( this, arguments ) === false ) { 39414 this.cancel(); 39415 } 39416 }, 39417 39418 _uiHash: function( _inst ) { 39419 var inst = _inst || this; 39420 return { 39421 helper: inst.helper, 39422 placeholder: inst.placeholder || $( [] ), 39423 position: inst.position, 39424 originalPosition: inst.originalPosition, 39425 offset: inst.positionAbs, 39426 item: inst.currentItem, 39427 sender: _inst ? _inst.element : null 39428 }; 39429 } 39430 39431 } ); 39432 39433 } ) ); 39434 39435 39436 /***/ }, 39437 /* 198 */ 39438 /***/ function(module, exports, __webpack_require__) { 39439 39440 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 39441 * jQuery UI :data 1.12.1 39442 * http://jqueryui.com 39443 * 39444 * Copyright jQuery Foundation and other contributors 39445 * Released under the MIT license. 39446 * http://jquery.org/license 39447 */ 39448 39449 //>>label: :data Selector 39450 //>>group: Core 39451 //>>description: Selects elements which have data stored under the specified key. 39452 //>>docs: http://api.jqueryui.com/data-selector/ 39453 39454 ( function( factory ) { 39455 if ( true ) { 39456 39457 // AMD. Register as an anonymous module. 39458 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(71), __webpack_require__(194) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 39459 } else { 39460 39461 // Browser globals 39462 factory( jQuery ); 39463 } 39464 } ( function( $ ) { 39465 return $.extend( $.expr[ ":" ], { 39466 data: $.expr.createPseudo ? 39467 $.expr.createPseudo( function( dataName ) { 39468 return function( elem ) { 39469 return !!$.data( elem, dataName ); 39470 }; 39471 } ) : 39472 39473 // Support: jQuery <1.8 39474 function( elem, i, match ) { 39475 return !!$.data( elem, match[ 3 ] ); 39476 } 39477 } ); 39478 } ) ); 39479 39480 39481 /***/ }, 39482 /* 199 */ 39483 /***/ function(module, exports, __webpack_require__) { 39484 39485 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 39486 * jQuery UI Scroll Parent 1.12.1 39487 * http://jqueryui.com 39488 * 39489 * Copyright jQuery Foundation and other contributors 39490 * Released under the MIT license. 39491 * http://jquery.org/license 39492 */ 39493 39494 //>>label: scrollParent 39495 //>>group: Core 39496 //>>description: Get the closest ancestor element that is scrollable. 39497 //>>docs: http://api.jqueryui.com/scrollParent/ 39498 39499 ( function( factory ) { 39500 if ( true ) { 39501 39502 // AMD. Register as an anonymous module. 39503 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(71), __webpack_require__(194) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 39504 } else { 39505 39506 // Browser globals 39507 factory( jQuery ); 39508 } 39509 } ( function( $ ) { 39510 39511 return $.fn.scrollParent = function( includeHidden ) { 39512 var position = this.css( "position" ), 39513 excludeStaticParent = position === "absolute", 39514 overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/, 39515 scrollParent = this.parents().filter( function() { 39516 var parent = $( this ); 39517 if ( excludeStaticParent && parent.css( "position" ) === "static" ) { 39518 return false; 39519 } 39520 return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + 39521 parent.css( "overflow-x" ) ); 39522 } ).eq( 0 ); 39523 39524 return position === "fixed" || !scrollParent.length ? 39525 $( this[ 0 ].ownerDocument || document ) : 39526 scrollParent; 39527 }; 39528 39529 } ) ); 39530 39531 39532 /***/ }, 39533 /* 200 */ 39534 /***/ function(module, exports, __webpack_require__) { 39535 39536 /* WEBPACK VAR INJECTION */(function(_) {module.exports = function(obj){ 39537 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 39538 with(obj||{}){ 39539 __p+='<table class="table table-striped" id="properties_table">\n<thead>\n<tr><th></th><th>ID</th>'; 39540 39541 _.each(propertyColumns, function(column){ 39542 __p+='\n <th>'+ 39543 ((__t=( column.id ))==null?'':__t)+ 39544 '</th>\n'; 39545 39546 }); 39547 39548 __p+='\n<th></th></tr></thead>\n<tbody></tbody></table>\n\n'; 39549 } 39550 return __p; 39551 }; 39552 39553 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(114))) 39554 39555 /***/ }, 39556 /* 201 */ 39557 /***/ function(module, exports, __webpack_require__) { 39558 39559 /* WEBPACK VAR INJECTION */(function(_) {module.exports = function(obj){ 39560 var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; 39561 with(obj||{}){ 39562 __p+='<tr>\n<td class="handle">\n <span class="fa fa-reorder" aria-hidden="true"></span>\n</td>\n<td>\n <input id="id" value="'+ 39563 ((__t=( property["id"] ))==null?'':_.escape(__t))+ 39564 '" class="form-control id_form"/>\n</td>\n'; 39565 _.each(propertyColumns, function(column){ 39566 var id = column.id; 39567 __p+='\n <td>\n '; 39568 if (column.enum){ 39569 __p+='\n <select class="form-control" id="\''+ 39570 ((__t=( id ))==null?'':_.escape(__t))+ 39571 '">\n '; 39572 _.each(column.enum, function(key){ 39573 __p+='\n <option value="'+ 39574 ((__t=( key ))==null?'':_.escape(__t))+ 39575 '"\n '; 39576 if(key == property[column.id] ){ 39577 __p+=' selected '; 39578 } 39579 __p+='> '+ 39580 ((__t=( key ))==null?'':_.escape(__t))+ 39581 '\n </option>\n '; 39582 }); 39583 __p+='\n </select>\n '; 39584 } else if (column.type == "string"){ 39585 __p+='\n <input id="'+ 39586 ((__t=( id ))==null?'':_.escape(__t))+ 39587 '" value="'+ 39588 ((__t=( property[column.id] ))==null?'':_.escape(__t))+ 39589 '" class="form-control"/>\n '; 39590 }else if(column.type == "checkbox") { 39591 __p+='\n <input type="checkbox" class="form-control" id="'+ 39592 ((__t=( id ))==null?'':_.escape(__t))+ 39593 '"\n '; 39594 if(property[column.id]){; 39595 __p+=' checked '; 39596 } 39597 __p+=' />\n '; 39598 } 39599 __p+='\n </td>\n'; 39600 }); 39601 __p+='\n<td class="action">\n <button type="button" class="btn btn-default" aria-label="Detail" id="detail" > Detail </button>\n <a class="delete" aria-label="Delete"><span class="fa fa-remove"></span></a>\n</td>\n</tr>\n'; 39602 } 39603 return __p; 39604 }; 39605 39606 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(114))) 39607 39608 /***/ }, 39609 /* 202 */ 39610 /***/ function(module, exports, __webpack_require__) { 39611 39612 'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _backbone=__webpack_require__(113);/** 39613 * Class contains logic of router in application. 39614 * @class AppRouter 39615 * @extends Router 39616 */class AppRouter extends _backbone.Router{/** 39617 * Constructs the object. 39618 * @constructor 39619 * @override 39620 * @param {Object} options={} 39621 */constructor(a={}){super(a),this.pageBaseTitle=a.title||'',this.routes=[],window.addEventListener('popstate',()=>{this.navigate(window.location.hash,{trigger:!0,replace:!0})})}/** 39622 * Adds route to router. 39623 * @override 39624 * @param {string} route 39625 * @param {string} name 39626 * @param {!*} rest 39627 */route(a,b,...c){this.routes.push({path:a,name:b}),super.route(a,b,...c)}/** 39628 * Changes title to specified value. 39629 * @param {string} name='' 39630 */changeTitle(a=''){return''===a?void(document.title=this.pageBaseTitle):void(document.title=a+' | '+this.pageBaseTitle)}setQueryParams(a){let b='';for(let c in a)a.hasOwnProperty(c)&&(b+=''==b?'?':'&',b+=c+'='+a[c]);window.history.replaceState({},'','/'+b+window.location.hash)}getQueryParams(){const a={},b=_backbone.history.location.search.substr(1);return''===b?a:(b.split('&').map(c=>{const d=c.split('=');a[d[0].toString()]=d[1].toString()}),a)}/** 39631 * Returns status of path in router, 39632 * if is registered returns true, otherwise false. 39633 * @param param 39634 * @returns {boolean} 39635 */pathIsRegistered(a){return this.routes.map(({path:b})=>b).includes(a)}}exports.default=AppRouter;/* global document, window */ 39636 39637 /***/ }, 39638 /* 203 */ 39639 /***/ function(module, exports, __webpack_require__) { 39640 39641 'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _backbone=__webpack_require__(113);/** 39642 * Class contains logic of config in application. 39643 * @class ConfigModel 39644 * @extends Model 39645 */class ConfigModel extends _backbone.Model{/** 39646 * Constructs the object. 39647 * @constructor 39648 * @extends Model.constructor 39649 * @param options 39650 */constructor(a){super(a),this.url=a.url}/** 39651 * Fetches data from server. 39652 * @extends Collection.fetch 39653 * @param {Object} [options] 39654 * @returns {Promise} 39655 */fetch(a){return new Promise((b,c)=>{super.fetch(Object.assign({success:(...d)=>{b(d)},error:(...d)=>{c(d)}},a))})}/** 39656 * Parses data. 39657 * @override Model.parse 39658 * @param {Object} resp 39659 * @returns {Object} 39660 */parse(a){return-1!==a.authUrl.indexOf('__HOST__')&&(a.authUrl=a.authUrl.replace('__HOST__',location.hostname)),-1!==a.gohan.url.indexOf('__HOST__')&&(a.gohan.url=a.gohan.url.replace('__HOST__',location.hostname)),a}}exports.default=ConfigModel;/* global location */ 39661 39662 /***/ } 39663 /******/ ]);