]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blob - bip39-standalone.html
updated standalone
[perso/Immae/Projets/Cryptomonnaies/BIP39.git] / bip39-standalone.html
1 <!DOCTYPE html>
2 <html>
3 <head lang="en">
4 <meta charset="utf-8" />
5 <title>BIP39 - Mnemonic Code</title>
6 <style>
7 /*!
8 * Bootstrap v3.2.0 (http://getbootstrap.com)
9 * Copyright 2011-2014 Twitter, Inc.
10 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
11 */
12
13 /*! normalize.css v3.0.1 | MIT License | git.io/normalize */
14 html {
15 font-family: sans-serif;
16 -webkit-text-size-adjust: 100%;
17 -ms-text-size-adjust: 100%;
18 }
19 body {
20 margin: 0;
21 }
22 article,
23 aside,
24 details,
25 figcaption,
26 figure,
27 footer,
28 header,
29 hgroup,
30 main,
31 nav,
32 section,
33 summary {
34 display: block;
35 }
36 audio,
37 canvas,
38 progress,
39 video {
40 display: inline-block;
41 vertical-align: baseline;
42 }
43 audio:not([controls]) {
44 display: none;
45 height: 0;
46 }
47 [hidden],
48 template {
49 display: none;
50 }
51 a {
52 background: transparent;
53 }
54 a:active,
55 a:hover {
56 outline: 0;
57 }
58 abbr[title] {
59 border-bottom: 1px dotted;
60 }
61 b,
62 strong {
63 font-weight: bold;
64 }
65 dfn {
66 font-style: italic;
67 }
68 h1 {
69 margin: .67em 0;
70 font-size: 2em;
71 }
72 mark {
73 color: #000;
74 background: #ff0;
75 }
76 small {
77 font-size: 80%;
78 }
79 sub,
80 sup {
81 position: relative;
82 font-size: 75%;
83 line-height: 0;
84 vertical-align: baseline;
85 }
86 sup {
87 top: -.5em;
88 }
89 sub {
90 bottom: -.25em;
91 }
92 img {
93 border: 0;
94 }
95 svg:not(:root) {
96 overflow: hidden;
97 }
98 figure {
99 margin: 1em 40px;
100 }
101 hr {
102 height: 0;
103 -webkit-box-sizing: content-box;
104 -moz-box-sizing: content-box;
105 box-sizing: content-box;
106 }
107 pre {
108 overflow: auto;
109 }
110 code,
111 kbd,
112 pre,
113 samp {
114 font-family: monospace, monospace;
115 font-size: 1em;
116 }
117 button,
118 input,
119 optgroup,
120 select,
121 textarea {
122 margin: 0;
123 font: inherit;
124 color: inherit;
125 }
126 button {
127 overflow: visible;
128 }
129 button,
130 select {
131 text-transform: none;
132 }
133 button,
134 html input[type="button"],
135 input[type="reset"],
136 input[type="submit"] {
137 -webkit-appearance: button;
138 cursor: pointer;
139 }
140 button[disabled],
141 html input[disabled] {
142 cursor: default;
143 }
144 button::-moz-focus-inner,
145 input::-moz-focus-inner {
146 padding: 0;
147 border: 0;
148 }
149 input {
150 line-height: normal;
151 }
152 input[type="checkbox"],
153 input[type="radio"] {
154 -webkit-box-sizing: border-box;
155 -moz-box-sizing: border-box;
156 box-sizing: border-box;
157 padding: 0;
158 }
159 input[type="number"]::-webkit-inner-spin-button,
160 input[type="number"]::-webkit-outer-spin-button {
161 height: auto;
162 }
163 input[type="search"] {
164 -webkit-box-sizing: content-box;
165 -moz-box-sizing: content-box;
166 box-sizing: content-box;
167 -webkit-appearance: textfield;
168 }
169 input[type="search"]::-webkit-search-cancel-button,
170 input[type="search"]::-webkit-search-decoration {
171 -webkit-appearance: none;
172 }
173 fieldset {
174 padding: .35em .625em .75em;
175 margin: 0 2px;
176 border: 1px solid #c0c0c0;
177 }
178 legend {
179 padding: 0;
180 border: 0;
181 }
182 textarea {
183 overflow: auto;
184 }
185 optgroup {
186 font-weight: bold;
187 }
188 table {
189 border-spacing: 0;
190 border-collapse: collapse;
191 }
192 td,
193 th {
194 padding: 0;
195 }
196 @media print {
197 * {
198 color: #000 !important;
199 text-shadow: none !important;
200 background: transparent !important;
201 -webkit-box-shadow: none !important;
202 box-shadow: none !important;
203 }
204 a,
205 a:visited {
206 text-decoration: underline;
207 }
208 a[href]:after {
209 content: " (" attr(href) ")";
210 }
211 abbr[title]:after {
212 content: " (" attr(title) ")";
213 }
214 a[href^="javascript:"]:after,
215 a[href^="#"]:after {
216 content: "";
217 }
218 pre,
219 blockquote {
220 border: 1px solid #999;
221
222 page-break-inside: avoid;
223 }
224 thead {
225 display: table-header-group;
226 }
227 tr,
228 img {
229 page-break-inside: avoid;
230 }
231 img {
232 max-width: 100% !important;
233 }
234 p,
235 h2,
236 h3 {
237 orphans: 3;
238 widows: 3;
239 }
240 h2,
241 h3 {
242 page-break-after: avoid;
243 }
244 select {
245 background: #fff !important;
246 }
247 .navbar {
248 display: none;
249 }
250 .table td,
251 .table th {
252 background-color: #fff !important;
253 }
254 .btn > .caret,
255 .dropup > .btn > .caret {
256 border-top-color: #000 !important;
257 }
258 .label {
259 border: 1px solid #000;
260 }
261 .table {
262 border-collapse: collapse !important;
263 }
264 .table-bordered th,
265 .table-bordered td {
266 border: 1px solid #ddd !important;
267 }
268 }
269 @font-face {
270 font-family: 'Glyphicons Halflings';
271
272 src: url('../fonts/glyphicons-halflings-regular.eot');
273 src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
274 }
275 .glyphicon {
276 position: relative;
277 top: 1px;
278 display: inline-block;
279 font-family: 'Glyphicons Halflings';
280 font-style: normal;
281 font-weight: normal;
282 line-height: 1;
283
284 -webkit-font-smoothing: antialiased;
285 -moz-osx-font-smoothing: grayscale;
286 }
287 .glyphicon-asterisk:before {
288 content: "\2a";
289 }
290 .glyphicon-plus:before {
291 content: "\2b";
292 }
293 .glyphicon-euro:before {
294 content: "\20ac";
295 }
296 .glyphicon-minus:before {
297 content: "\2212";
298 }
299 .glyphicon-cloud:before {
300 content: "\2601";
301 }
302 .glyphicon-envelope:before {
303 content: "\2709";
304 }
305 .glyphicon-pencil:before {
306 content: "\270f";
307 }
308 .glyphicon-glass:before {
309 content: "\e001";
310 }
311 .glyphicon-music:before {
312 content: "\e002";
313 }
314 .glyphicon-search:before {
315 content: "\e003";
316 }
317 .glyphicon-heart:before {
318 content: "\e005";
319 }
320 .glyphicon-star:before {
321 content: "\e006";
322 }
323 .glyphicon-star-empty:before {
324 content: "\e007";
325 }
326 .glyphicon-user:before {
327 content: "\e008";
328 }
329 .glyphicon-film:before {
330 content: "\e009";
331 }
332 .glyphicon-th-large:before {
333 content: "\e010";
334 }
335 .glyphicon-th:before {
336 content: "\e011";
337 }
338 .glyphicon-th-list:before {
339 content: "\e012";
340 }
341 .glyphicon-ok:before {
342 content: "\e013";
343 }
344 .glyphicon-remove:before {
345 content: "\e014";
346 }
347 .glyphicon-zoom-in:before {
348 content: "\e015";
349 }
350 .glyphicon-zoom-out:before {
351 content: "\e016";
352 }
353 .glyphicon-off:before {
354 content: "\e017";
355 }
356 .glyphicon-signal:before {
357 content: "\e018";
358 }
359 .glyphicon-cog:before {
360 content: "\e019";
361 }
362 .glyphicon-trash:before {
363 content: "\e020";
364 }
365 .glyphicon-home:before {
366 content: "\e021";
367 }
368 .glyphicon-file:before {
369 content: "\e022";
370 }
371 .glyphicon-time:before {
372 content: "\e023";
373 }
374 .glyphicon-road:before {
375 content: "\e024";
376 }
377 .glyphicon-download-alt:before {
378 content: "\e025";
379 }
380 .glyphicon-download:before {
381 content: "\e026";
382 }
383 .glyphicon-upload:before {
384 content: "\e027";
385 }
386 .glyphicon-inbox:before {
387 content: "\e028";
388 }
389 .glyphicon-play-circle:before {
390 content: "\e029";
391 }
392 .glyphicon-repeat:before {
393 content: "\e030";
394 }
395 .glyphicon-refresh:before {
396 content: "\e031";
397 }
398 .glyphicon-list-alt:before {
399 content: "\e032";
400 }
401 .glyphicon-lock:before {
402 content: "\e033";
403 }
404 .glyphicon-flag:before {
405 content: "\e034";
406 }
407 .glyphicon-headphones:before {
408 content: "\e035";
409 }
410 .glyphicon-volume-off:before {
411 content: "\e036";
412 }
413 .glyphicon-volume-down:before {
414 content: "\e037";
415 }
416 .glyphicon-volume-up:before {
417 content: "\e038";
418 }
419 .glyphicon-qrcode:before {
420 content: "\e039";
421 }
422 .glyphicon-barcode:before {
423 content: "\e040";
424 }
425 .glyphicon-tag:before {
426 content: "\e041";
427 }
428 .glyphicon-tags:before {
429 content: "\e042";
430 }
431 .glyphicon-book:before {
432 content: "\e043";
433 }
434 .glyphicon-bookmark:before {
435 content: "\e044";
436 }
437 .glyphicon-print:before {
438 content: "\e045";
439 }
440 .glyphicon-camera:before {
441 content: "\e046";
442 }
443 .glyphicon-font:before {
444 content: "\e047";
445 }
446 .glyphicon-bold:before {
447 content: "\e048";
448 }
449 .glyphicon-italic:before {
450 content: "\e049";
451 }
452 .glyphicon-text-height:before {
453 content: "\e050";
454 }
455 .glyphicon-text-width:before {
456 content: "\e051";
457 }
458 .glyphicon-align-left:before {
459 content: "\e052";
460 }
461 .glyphicon-align-center:before {
462 content: "\e053";
463 }
464 .glyphicon-align-right:before {
465 content: "\e054";
466 }
467 .glyphicon-align-justify:before {
468 content: "\e055";
469 }
470 .glyphicon-list:before {
471 content: "\e056";
472 }
473 .glyphicon-indent-left:before {
474 content: "\e057";
475 }
476 .glyphicon-indent-right:before {
477 content: "\e058";
478 }
479 .glyphicon-facetime-video:before {
480 content: "\e059";
481 }
482 .glyphicon-picture:before {
483 content: "\e060";
484 }
485 .glyphicon-map-marker:before {
486 content: "\e062";
487 }
488 .glyphicon-adjust:before {
489 content: "\e063";
490 }
491 .glyphicon-tint:before {
492 content: "\e064";
493 }
494 .glyphicon-edit:before {
495 content: "\e065";
496 }
497 .glyphicon-share:before {
498 content: "\e066";
499 }
500 .glyphicon-check:before {
501 content: "\e067";
502 }
503 .glyphicon-move:before {
504 content: "\e068";
505 }
506 .glyphicon-step-backward:before {
507 content: "\e069";
508 }
509 .glyphicon-fast-backward:before {
510 content: "\e070";
511 }
512 .glyphicon-backward:before {
513 content: "\e071";
514 }
515 .glyphicon-play:before {
516 content: "\e072";
517 }
518 .glyphicon-pause:before {
519 content: "\e073";
520 }
521 .glyphicon-stop:before {
522 content: "\e074";
523 }
524 .glyphicon-forward:before {
525 content: "\e075";
526 }
527 .glyphicon-fast-forward:before {
528 content: "\e076";
529 }
530 .glyphicon-step-forward:before {
531 content: "\e077";
532 }
533 .glyphicon-eject:before {
534 content: "\e078";
535 }
536 .glyphicon-chevron-left:before {
537 content: "\e079";
538 }
539 .glyphicon-chevron-right:before {
540 content: "\e080";
541 }
542 .glyphicon-plus-sign:before {
543 content: "\e081";
544 }
545 .glyphicon-minus-sign:before {
546 content: "\e082";
547 }
548 .glyphicon-remove-sign:before {
549 content: "\e083";
550 }
551 .glyphicon-ok-sign:before {
552 content: "\e084";
553 }
554 .glyphicon-question-sign:before {
555 content: "\e085";
556 }
557 .glyphicon-info-sign:before {
558 content: "\e086";
559 }
560 .glyphicon-screenshot:before {
561 content: "\e087";
562 }
563 .glyphicon-remove-circle:before {
564 content: "\e088";
565 }
566 .glyphicon-ok-circle:before {
567 content: "\e089";
568 }
569 .glyphicon-ban-circle:before {
570 content: "\e090";
571 }
572 .glyphicon-arrow-left:before {
573 content: "\e091";
574 }
575 .glyphicon-arrow-right:before {
576 content: "\e092";
577 }
578 .glyphicon-arrow-up:before {
579 content: "\e093";
580 }
581 .glyphicon-arrow-down:before {
582 content: "\e094";
583 }
584 .glyphicon-share-alt:before {
585 content: "\e095";
586 }
587 .glyphicon-resize-full:before {
588 content: "\e096";
589 }
590 .glyphicon-resize-small:before {
591 content: "\e097";
592 }
593 .glyphicon-exclamation-sign:before {
594 content: "\e101";
595 }
596 .glyphicon-gift:before {
597 content: "\e102";
598 }
599 .glyphicon-leaf:before {
600 content: "\e103";
601 }
602 .glyphicon-fire:before {
603 content: "\e104";
604 }
605 .glyphicon-eye-open:before {
606 content: "\e105";
607 }
608 .glyphicon-eye-close:before {
609 content: "\e106";
610 }
611 .glyphicon-warning-sign:before {
612 content: "\e107";
613 }
614 .glyphicon-plane:before {
615 content: "\e108";
616 }
617 .glyphicon-calendar:before {
618 content: "\e109";
619 }
620 .glyphicon-random:before {
621 content: "\e110";
622 }
623 .glyphicon-comment:before {
624 content: "\e111";
625 }
626 .glyphicon-magnet:before {
627 content: "\e112";
628 }
629 .glyphicon-chevron-up:before {
630 content: "\e113";
631 }
632 .glyphicon-chevron-down:before {
633 content: "\e114";
634 }
635 .glyphicon-retweet:before {
636 content: "\e115";
637 }
638 .glyphicon-shopping-cart:before {
639 content: "\e116";
640 }
641 .glyphicon-folder-close:before {
642 content: "\e117";
643 }
644 .glyphicon-folder-open:before {
645 content: "\e118";
646 }
647 .glyphicon-resize-vertical:before {
648 content: "\e119";
649 }
650 .glyphicon-resize-horizontal:before {
651 content: "\e120";
652 }
653 .glyphicon-hdd:before {
654 content: "\e121";
655 }
656 .glyphicon-bullhorn:before {
657 content: "\e122";
658 }
659 .glyphicon-bell:before {
660 content: "\e123";
661 }
662 .glyphicon-certificate:before {
663 content: "\e124";
664 }
665 .glyphicon-thumbs-up:before {
666 content: "\e125";
667 }
668 .glyphicon-thumbs-down:before {
669 content: "\e126";
670 }
671 .glyphicon-hand-right:before {
672 content: "\e127";
673 }
674 .glyphicon-hand-left:before {
675 content: "\e128";
676 }
677 .glyphicon-hand-up:before {
678 content: "\e129";
679 }
680 .glyphicon-hand-down:before {
681 content: "\e130";
682 }
683 .glyphicon-circle-arrow-right:before {
684 content: "\e131";
685 }
686 .glyphicon-circle-arrow-left:before {
687 content: "\e132";
688 }
689 .glyphicon-circle-arrow-up:before {
690 content: "\e133";
691 }
692 .glyphicon-circle-arrow-down:before {
693 content: "\e134";
694 }
695 .glyphicon-globe:before {
696 content: "\e135";
697 }
698 .glyphicon-wrench:before {
699 content: "\e136";
700 }
701 .glyphicon-tasks:before {
702 content: "\e137";
703 }
704 .glyphicon-filter:before {
705 content: "\e138";
706 }
707 .glyphicon-briefcase:before {
708 content: "\e139";
709 }
710 .glyphicon-fullscreen:before {
711 content: "\e140";
712 }
713 .glyphicon-dashboard:before {
714 content: "\e141";
715 }
716 .glyphicon-paperclip:before {
717 content: "\e142";
718 }
719 .glyphicon-heart-empty:before {
720 content: "\e143";
721 }
722 .glyphicon-link:before {
723 content: "\e144";
724 }
725 .glyphicon-phone:before {
726 content: "\e145";
727 }
728 .glyphicon-pushpin:before {
729 content: "\e146";
730 }
731 .glyphicon-usd:before {
732 content: "\e148";
733 }
734 .glyphicon-gbp:before {
735 content: "\e149";
736 }
737 .glyphicon-sort:before {
738 content: "\e150";
739 }
740 .glyphicon-sort-by-alphabet:before {
741 content: "\e151";
742 }
743 .glyphicon-sort-by-alphabet-alt:before {
744 content: "\e152";
745 }
746 .glyphicon-sort-by-order:before {
747 content: "\e153";
748 }
749 .glyphicon-sort-by-order-alt:before {
750 content: "\e154";
751 }
752 .glyphicon-sort-by-attributes:before {
753 content: "\e155";
754 }
755 .glyphicon-sort-by-attributes-alt:before {
756 content: "\e156";
757 }
758 .glyphicon-unchecked:before {
759 content: "\e157";
760 }
761 .glyphicon-expand:before {
762 content: "\e158";
763 }
764 .glyphicon-collapse-down:before {
765 content: "\e159";
766 }
767 .glyphicon-collapse-up:before {
768 content: "\e160";
769 }
770 .glyphicon-log-in:before {
771 content: "\e161";
772 }
773 .glyphicon-flash:before {
774 content: "\e162";
775 }
776 .glyphicon-log-out:before {
777 content: "\e163";
778 }
779 .glyphicon-new-window:before {
780 content: "\e164";
781 }
782 .glyphicon-record:before {
783 content: "\e165";
784 }
785 .glyphicon-save:before {
786 content: "\e166";
787 }
788 .glyphicon-open:before {
789 content: "\e167";
790 }
791 .glyphicon-saved:before {
792 content: "\e168";
793 }
794 .glyphicon-import:before {
795 content: "\e169";
796 }
797 .glyphicon-export:before {
798 content: "\e170";
799 }
800 .glyphicon-send:before {
801 content: "\e171";
802 }
803 .glyphicon-floppy-disk:before {
804 content: "\e172";
805 }
806 .glyphicon-floppy-saved:before {
807 content: "\e173";
808 }
809 .glyphicon-floppy-remove:before {
810 content: "\e174";
811 }
812 .glyphicon-floppy-save:before {
813 content: "\e175";
814 }
815 .glyphicon-floppy-open:before {
816 content: "\e176";
817 }
818 .glyphicon-credit-card:before {
819 content: "\e177";
820 }
821 .glyphicon-transfer:before {
822 content: "\e178";
823 }
824 .glyphicon-cutlery:before {
825 content: "\e179";
826 }
827 .glyphicon-header:before {
828 content: "\e180";
829 }
830 .glyphicon-compressed:before {
831 content: "\e181";
832 }
833 .glyphicon-earphone:before {
834 content: "\e182";
835 }
836 .glyphicon-phone-alt:before {
837 content: "\e183";
838 }
839 .glyphicon-tower:before {
840 content: "\e184";
841 }
842 .glyphicon-stats:before {
843 content: "\e185";
844 }
845 .glyphicon-sd-video:before {
846 content: "\e186";
847 }
848 .glyphicon-hd-video:before {
849 content: "\e187";
850 }
851 .glyphicon-subtitles:before {
852 content: "\e188";
853 }
854 .glyphicon-sound-stereo:before {
855 content: "\e189";
856 }
857 .glyphicon-sound-dolby:before {
858 content: "\e190";
859 }
860 .glyphicon-sound-5-1:before {
861 content: "\e191";
862 }
863 .glyphicon-sound-6-1:before {
864 content: "\e192";
865 }
866 .glyphicon-sound-7-1:before {
867 content: "\e193";
868 }
869 .glyphicon-copyright-mark:before {
870 content: "\e194";
871 }
872 .glyphicon-registration-mark:before {
873 content: "\e195";
874 }
875 .glyphicon-cloud-download:before {
876 content: "\e197";
877 }
878 .glyphicon-cloud-upload:before {
879 content: "\e198";
880 }
881 .glyphicon-tree-conifer:before {
882 content: "\e199";
883 }
884 .glyphicon-tree-deciduous:before {
885 content: "\e200";
886 }
887 * {
888 -webkit-box-sizing: border-box;
889 -moz-box-sizing: border-box;
890 box-sizing: border-box;
891 }
892 *:before,
893 *:after {
894 -webkit-box-sizing: border-box;
895 -moz-box-sizing: border-box;
896 box-sizing: border-box;
897 }
898 html {
899 font-size: 10px;
900
901 -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
902 }
903 body {
904 font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
905 font-size: 14px;
906 line-height: 1.42857143;
907 color: #333;
908 background-color: #fff;
909 }
910 input,
911 button,
912 select,
913 textarea {
914 font-family: inherit;
915 font-size: inherit;
916 line-height: inherit;
917 }
918 a {
919 color: #428bca;
920 text-decoration: none;
921 }
922 a:hover,
923 a:focus {
924 color: #2a6496;
925 text-decoration: underline;
926 }
927 a:focus {
928 outline: thin dotted;
929 outline: 5px auto -webkit-focus-ring-color;
930 outline-offset: -2px;
931 }
932 figure {
933 margin: 0;
934 }
935 img {
936 vertical-align: middle;
937 }
938 .img-responsive,
939 .thumbnail > img,
940 .thumbnail a > img,
941 .carousel-inner > .item > img,
942 .carousel-inner > .item > a > img {
943 display: block;
944 width: 100% \9;
945 max-width: 100%;
946 height: auto;
947 }
948 .img-rounded {
949 border-radius: 6px;
950 }
951 .img-thumbnail {
952 display: inline-block;
953 width: 100% \9;
954 max-width: 100%;
955 height: auto;
956 padding: 4px;
957 line-height: 1.42857143;
958 background-color: #fff;
959 border: 1px solid #ddd;
960 border-radius: 4px;
961 -webkit-transition: all .2s ease-in-out;
962 -o-transition: all .2s ease-in-out;
963 transition: all .2s ease-in-out;
964 }
965 .img-circle {
966 border-radius: 50%;
967 }
968 hr {
969 margin-top: 20px;
970 margin-bottom: 20px;
971 border: 0;
972 border-top: 1px solid #eee;
973 }
974 .sr-only {
975 position: absolute;
976 width: 1px;
977 height: 1px;
978 padding: 0;
979 margin: -1px;
980 overflow: hidden;
981 clip: rect(0, 0, 0, 0);
982 border: 0;
983 }
984 .sr-only-focusable:active,
985 .sr-only-focusable:focus {
986 position: static;
987 width: auto;
988 height: auto;
989 margin: 0;
990 overflow: visible;
991 clip: auto;
992 }
993 h1,
994 h2,
995 h3,
996 h4,
997 h5,
998 h6,
999 .h1,
1000 .h2,
1001 .h3,
1002 .h4,
1003 .h5,
1004 .h6 {
1005 font-family: inherit;
1006 font-weight: 500;
1007 line-height: 1.1;
1008 color: inherit;
1009 }
1010 h1 small,
1011 h2 small,
1012 h3 small,
1013 h4 small,
1014 h5 small,
1015 h6 small,
1016 .h1 small,
1017 .h2 small,
1018 .h3 small,
1019 .h4 small,
1020 .h5 small,
1021 .h6 small,
1022 h1 .small,
1023 h2 .small,
1024 h3 .small,
1025 h4 .small,
1026 h5 .small,
1027 h6 .small,
1028 .h1 .small,
1029 .h2 .small,
1030 .h3 .small,
1031 .h4 .small,
1032 .h5 .small,
1033 .h6 .small {
1034 font-weight: normal;
1035 line-height: 1;
1036 color: #777;
1037 }
1038 h1,
1039 .h1,
1040 h2,
1041 .h2,
1042 h3,
1043 .h3 {
1044 margin-top: 20px;
1045 margin-bottom: 10px;
1046 }
1047 h1 small,
1048 .h1 small,
1049 h2 small,
1050 .h2 small,
1051 h3 small,
1052 .h3 small,
1053 h1 .small,
1054 .h1 .small,
1055 h2 .small,
1056 .h2 .small,
1057 h3 .small,
1058 .h3 .small {
1059 font-size: 65%;
1060 }
1061 h4,
1062 .h4,
1063 h5,
1064 .h5,
1065 h6,
1066 .h6 {
1067 margin-top: 10px;
1068 margin-bottom: 10px;
1069 }
1070 h4 small,
1071 .h4 small,
1072 h5 small,
1073 .h5 small,
1074 h6 small,
1075 .h6 small,
1076 h4 .small,
1077 .h4 .small,
1078 h5 .small,
1079 .h5 .small,
1080 h6 .small,
1081 .h6 .small {
1082 font-size: 75%;
1083 }
1084 h1,
1085 .h1 {
1086 font-size: 36px;
1087 }
1088 h2,
1089 .h2 {
1090 font-size: 30px;
1091 }
1092 h3,
1093 .h3 {
1094 font-size: 24px;
1095 }
1096 h4,
1097 .h4 {
1098 font-size: 18px;
1099 }
1100 h5,
1101 .h5 {
1102 font-size: 14px;
1103 }
1104 h6,
1105 .h6 {
1106 font-size: 12px;
1107 }
1108 p {
1109 margin: 0 0 10px;
1110 }
1111 .lead {
1112 margin-bottom: 20px;
1113 font-size: 16px;
1114 font-weight: 300;
1115 line-height: 1.4;
1116 }
1117 @media (min-width: 768px) {
1118 .lead {
1119 font-size: 21px;
1120 }
1121 }
1122 small,
1123 .small {
1124 font-size: 85%;
1125 }
1126 cite {
1127 font-style: normal;
1128 }
1129 mark,
1130 .mark {
1131 padding: .2em;
1132 background-color: #fcf8e3;
1133 }
1134 .text-left {
1135 text-align: left;
1136 }
1137 .text-right {
1138 text-align: right;
1139 }
1140 .text-center {
1141 text-align: center;
1142 }
1143 .text-justify {
1144 text-align: justify;
1145 }
1146 .text-nowrap {
1147 white-space: nowrap;
1148 }
1149 .text-lowercase {
1150 text-transform: lowercase;
1151 }
1152 .text-uppercase {
1153 text-transform: uppercase;
1154 }
1155 .text-capitalize {
1156 text-transform: capitalize;
1157 }
1158 .text-muted {
1159 color: #777;
1160 }
1161 .text-primary {
1162 color: #428bca;
1163 }
1164 a.text-primary:hover {
1165 color: #3071a9;
1166 }
1167 .text-success {
1168 color: #3c763d;
1169 }
1170 a.text-success:hover {
1171 color: #2b542c;
1172 }
1173 .text-info {
1174 color: #31708f;
1175 }
1176 a.text-info:hover {
1177 color: #245269;
1178 }
1179 .text-warning {
1180 color: #8a6d3b;
1181 }
1182 a.text-warning:hover {
1183 color: #66512c;
1184 }
1185 .text-danger {
1186 color: #a94442;
1187 }
1188 a.text-danger:hover {
1189 color: #843534;
1190 }
1191 .bg-primary {
1192 color: #fff;
1193 background-color: #428bca;
1194 }
1195 a.bg-primary:hover {
1196 background-color: #3071a9;
1197 }
1198 .bg-success {
1199 background-color: #dff0d8;
1200 }
1201 a.bg-success:hover {
1202 background-color: #c1e2b3;
1203 }
1204 .bg-info {
1205 background-color: #d9edf7;
1206 }
1207 a.bg-info:hover {
1208 background-color: #afd9ee;
1209 }
1210 .bg-warning {
1211 background-color: #fcf8e3;
1212 }
1213 a.bg-warning:hover {
1214 background-color: #f7ecb5;
1215 }
1216 .bg-danger {
1217 background-color: #f2dede;
1218 }
1219 a.bg-danger:hover {
1220 background-color: #e4b9b9;
1221 }
1222 .page-header {
1223 padding-bottom: 9px;
1224 margin: 40px 0 20px;
1225 border-bottom: 1px solid #eee;
1226 }
1227 ul,
1228 ol {
1229 margin-top: 0;
1230 margin-bottom: 10px;
1231 }
1232 ul ul,
1233 ol ul,
1234 ul ol,
1235 ol ol {
1236 margin-bottom: 0;
1237 }
1238 .list-unstyled {
1239 padding-left: 0;
1240 list-style: none;
1241 }
1242 .list-inline {
1243 padding-left: 0;
1244 margin-left: -5px;
1245 list-style: none;
1246 }
1247 .list-inline > li {
1248 display: inline-block;
1249 padding-right: 5px;
1250 padding-left: 5px;
1251 }
1252 dl {
1253 margin-top: 0;
1254 margin-bottom: 20px;
1255 }
1256 dt,
1257 dd {
1258 line-height: 1.42857143;
1259 }
1260 dt {
1261 font-weight: bold;
1262 }
1263 dd {
1264 margin-left: 0;
1265 }
1266 @media (min-width: 768px) {
1267 .dl-horizontal dt {
1268 float: left;
1269 width: 160px;
1270 overflow: hidden;
1271 clear: left;
1272 text-align: right;
1273 text-overflow: ellipsis;
1274 white-space: nowrap;
1275 }
1276 .dl-horizontal dd {
1277 margin-left: 180px;
1278 }
1279 }
1280 abbr[title],
1281 abbr[data-original-title] {
1282 cursor: help;
1283 border-bottom: 1px dotted #777;
1284 }
1285 .initialism {
1286 font-size: 90%;
1287 text-transform: uppercase;
1288 }
1289 blockquote {
1290 padding: 10px 20px;
1291 margin: 0 0 20px;
1292 font-size: 17.5px;
1293 border-left: 5px solid #eee;
1294 }
1295 blockquote p:last-child,
1296 blockquote ul:last-child,
1297 blockquote ol:last-child {
1298 margin-bottom: 0;
1299 }
1300 blockquote footer,
1301 blockquote small,
1302 blockquote .small {
1303 display: block;
1304 font-size: 80%;
1305 line-height: 1.42857143;
1306 color: #777;
1307 }
1308 blockquote footer:before,
1309 blockquote small:before,
1310 blockquote .small:before {
1311 content: '\2014 \00A0';
1312 }
1313 .blockquote-reverse,
1314 blockquote.pull-right {
1315 padding-right: 15px;
1316 padding-left: 0;
1317 text-align: right;
1318 border-right: 5px solid #eee;
1319 border-left: 0;
1320 }
1321 .blockquote-reverse footer:before,
1322 blockquote.pull-right footer:before,
1323 .blockquote-reverse small:before,
1324 blockquote.pull-right small:before,
1325 .blockquote-reverse .small:before,
1326 blockquote.pull-right .small:before {
1327 content: '';
1328 }
1329 .blockquote-reverse footer:after,
1330 blockquote.pull-right footer:after,
1331 .blockquote-reverse small:after,
1332 blockquote.pull-right small:after,
1333 .blockquote-reverse .small:after,
1334 blockquote.pull-right .small:after {
1335 content: '\00A0 \2014';
1336 }
1337 blockquote:before,
1338 blockquote:after {
1339 content: "";
1340 }
1341 address {
1342 margin-bottom: 20px;
1343 font-style: normal;
1344 line-height: 1.42857143;
1345 }
1346 code,
1347 kbd,
1348 pre,
1349 samp {
1350 font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
1351 }
1352 code {
1353 padding: 2px 4px;
1354 font-size: 90%;
1355 color: #c7254e;
1356 background-color: #f9f2f4;
1357 border-radius: 4px;
1358 }
1359 kbd {
1360 padding: 2px 4px;
1361 font-size: 90%;
1362 color: #fff;
1363 background-color: #333;
1364 border-radius: 3px;
1365 -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .25);
1366 box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .25);
1367 }
1368 kbd kbd {
1369 padding: 0;
1370 font-size: 100%;
1371 -webkit-box-shadow: none;
1372 box-shadow: none;
1373 }
1374 pre {
1375 display: block;
1376 padding: 9.5px;
1377 margin: 0 0 10px;
1378 font-size: 13px;
1379 line-height: 1.42857143;
1380 color: #333;
1381 word-break: break-all;
1382 word-wrap: break-word;
1383 background-color: #f5f5f5;
1384 border: 1px solid #ccc;
1385 border-radius: 4px;
1386 }
1387 pre code {
1388 padding: 0;
1389 font-size: inherit;
1390 color: inherit;
1391 white-space: pre-wrap;
1392 background-color: transparent;
1393 border-radius: 0;
1394 }
1395 .pre-scrollable {
1396 max-height: 340px;
1397 overflow-y: scroll;
1398 }
1399 .container {
1400 padding-right: 15px;
1401 padding-left: 15px;
1402 margin-right: auto;
1403 margin-left: auto;
1404 }
1405 @media (min-width: 768px) {
1406 .container {
1407 width: 750px;
1408 }
1409 }
1410 @media (min-width: 992px) {
1411 .container {
1412 width: 970px;
1413 }
1414 }
1415 @media (min-width: 1200px) {
1416 .container {
1417 width: 1170px;
1418 }
1419 }
1420 .container-fluid {
1421 padding-right: 15px;
1422 padding-left: 15px;
1423 margin-right: auto;
1424 margin-left: auto;
1425 }
1426 .row {
1427 margin-right: -15px;
1428 margin-left: -15px;
1429 }
1430 .col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12 {
1431 position: relative;
1432 min-height: 1px;
1433 padding-right: 15px;
1434 padding-left: 15px;
1435 }
1436 .col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12 {
1437 float: left;
1438 }
1439 .col-xs-12 {
1440 width: 100%;
1441 }
1442 .col-xs-11 {
1443 width: 91.66666667%;
1444 }
1445 .col-xs-10 {
1446 width: 83.33333333%;
1447 }
1448 .col-xs-9 {
1449 width: 75%;
1450 }
1451 .col-xs-8 {
1452 width: 66.66666667%;
1453 }
1454 .col-xs-7 {
1455 width: 58.33333333%;
1456 }
1457 .col-xs-6 {
1458 width: 50%;
1459 }
1460 .col-xs-5 {
1461 width: 41.66666667%;
1462 }
1463 .col-xs-4 {
1464 width: 33.33333333%;
1465 }
1466 .col-xs-3 {
1467 width: 25%;
1468 }
1469 .col-xs-2 {
1470 width: 16.66666667%;
1471 }
1472 .col-xs-1 {
1473 width: 8.33333333%;
1474 }
1475 .col-xs-pull-12 {
1476 right: 100%;
1477 }
1478 .col-xs-pull-11 {
1479 right: 91.66666667%;
1480 }
1481 .col-xs-pull-10 {
1482 right: 83.33333333%;
1483 }
1484 .col-xs-pull-9 {
1485 right: 75%;
1486 }
1487 .col-xs-pull-8 {
1488 right: 66.66666667%;
1489 }
1490 .col-xs-pull-7 {
1491 right: 58.33333333%;
1492 }
1493 .col-xs-pull-6 {
1494 right: 50%;
1495 }
1496 .col-xs-pull-5 {
1497 right: 41.66666667%;
1498 }
1499 .col-xs-pull-4 {
1500 right: 33.33333333%;
1501 }
1502 .col-xs-pull-3 {
1503 right: 25%;
1504 }
1505 .col-xs-pull-2 {
1506 right: 16.66666667%;
1507 }
1508 .col-xs-pull-1 {
1509 right: 8.33333333%;
1510 }
1511 .col-xs-pull-0 {
1512 right: auto;
1513 }
1514 .col-xs-push-12 {
1515 left: 100%;
1516 }
1517 .col-xs-push-11 {
1518 left: 91.66666667%;
1519 }
1520 .col-xs-push-10 {
1521 left: 83.33333333%;
1522 }
1523 .col-xs-push-9 {
1524 left: 75%;
1525 }
1526 .col-xs-push-8 {
1527 left: 66.66666667%;
1528 }
1529 .col-xs-push-7 {
1530 left: 58.33333333%;
1531 }
1532 .col-xs-push-6 {
1533 left: 50%;
1534 }
1535 .col-xs-push-5 {
1536 left: 41.66666667%;
1537 }
1538 .col-xs-push-4 {
1539 left: 33.33333333%;
1540 }
1541 .col-xs-push-3 {
1542 left: 25%;
1543 }
1544 .col-xs-push-2 {
1545 left: 16.66666667%;
1546 }
1547 .col-xs-push-1 {
1548 left: 8.33333333%;
1549 }
1550 .col-xs-push-0 {
1551 left: auto;
1552 }
1553 .col-xs-offset-12 {
1554 margin-left: 100%;
1555 }
1556 .col-xs-offset-11 {
1557 margin-left: 91.66666667%;
1558 }
1559 .col-xs-offset-10 {
1560 margin-left: 83.33333333%;
1561 }
1562 .col-xs-offset-9 {
1563 margin-left: 75%;
1564 }
1565 .col-xs-offset-8 {
1566 margin-left: 66.66666667%;
1567 }
1568 .col-xs-offset-7 {
1569 margin-left: 58.33333333%;
1570 }
1571 .col-xs-offset-6 {
1572 margin-left: 50%;
1573 }
1574 .col-xs-offset-5 {
1575 margin-left: 41.66666667%;
1576 }
1577 .col-xs-offset-4 {
1578 margin-left: 33.33333333%;
1579 }
1580 .col-xs-offset-3 {
1581 margin-left: 25%;
1582 }
1583 .col-xs-offset-2 {
1584 margin-left: 16.66666667%;
1585 }
1586 .col-xs-offset-1 {
1587 margin-left: 8.33333333%;
1588 }
1589 .col-xs-offset-0 {
1590 margin-left: 0;
1591 }
1592 @media (min-width: 768px) {
1593 .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12 {
1594 float: left;
1595 }
1596 .col-sm-12 {
1597 width: 100%;
1598 }
1599 .col-sm-11 {
1600 width: 91.66666667%;
1601 }
1602 .col-sm-10 {
1603 width: 83.33333333%;
1604 }
1605 .col-sm-9 {
1606 width: 75%;
1607 }
1608 .col-sm-8 {
1609 width: 66.66666667%;
1610 }
1611 .col-sm-7 {
1612 width: 58.33333333%;
1613 }
1614 .col-sm-6 {
1615 width: 50%;
1616 }
1617 .col-sm-5 {
1618 width: 41.66666667%;
1619 }
1620 .col-sm-4 {
1621 width: 33.33333333%;
1622 }
1623 .col-sm-3 {
1624 width: 25%;
1625 }
1626 .col-sm-2 {
1627 width: 16.66666667%;
1628 }
1629 .col-sm-1 {
1630 width: 8.33333333%;
1631 }
1632 .col-sm-pull-12 {
1633 right: 100%;
1634 }
1635 .col-sm-pull-11 {
1636 right: 91.66666667%;
1637 }
1638 .col-sm-pull-10 {
1639 right: 83.33333333%;
1640 }
1641 .col-sm-pull-9 {
1642 right: 75%;
1643 }
1644 .col-sm-pull-8 {
1645 right: 66.66666667%;
1646 }
1647 .col-sm-pull-7 {
1648 right: 58.33333333%;
1649 }
1650 .col-sm-pull-6 {
1651 right: 50%;
1652 }
1653 .col-sm-pull-5 {
1654 right: 41.66666667%;
1655 }
1656 .col-sm-pull-4 {
1657 right: 33.33333333%;
1658 }
1659 .col-sm-pull-3 {
1660 right: 25%;
1661 }
1662 .col-sm-pull-2 {
1663 right: 16.66666667%;
1664 }
1665 .col-sm-pull-1 {
1666 right: 8.33333333%;
1667 }
1668 .col-sm-pull-0 {
1669 right: auto;
1670 }
1671 .col-sm-push-12 {
1672 left: 100%;
1673 }
1674 .col-sm-push-11 {
1675 left: 91.66666667%;
1676 }
1677 .col-sm-push-10 {
1678 left: 83.33333333%;
1679 }
1680 .col-sm-push-9 {
1681 left: 75%;
1682 }
1683 .col-sm-push-8 {
1684 left: 66.66666667%;
1685 }
1686 .col-sm-push-7 {
1687 left: 58.33333333%;
1688 }
1689 .col-sm-push-6 {
1690 left: 50%;
1691 }
1692 .col-sm-push-5 {
1693 left: 41.66666667%;
1694 }
1695 .col-sm-push-4 {
1696 left: 33.33333333%;
1697 }
1698 .col-sm-push-3 {
1699 left: 25%;
1700 }
1701 .col-sm-push-2 {
1702 left: 16.66666667%;
1703 }
1704 .col-sm-push-1 {
1705 left: 8.33333333%;
1706 }
1707 .col-sm-push-0 {
1708 left: auto;
1709 }
1710 .col-sm-offset-12 {
1711 margin-left: 100%;
1712 }
1713 .col-sm-offset-11 {
1714 margin-left: 91.66666667%;
1715 }
1716 .col-sm-offset-10 {
1717 margin-left: 83.33333333%;
1718 }
1719 .col-sm-offset-9 {
1720 margin-left: 75%;
1721 }
1722 .col-sm-offset-8 {
1723 margin-left: 66.66666667%;
1724 }
1725 .col-sm-offset-7 {
1726 margin-left: 58.33333333%;
1727 }
1728 .col-sm-offset-6 {
1729 margin-left: 50%;
1730 }
1731 .col-sm-offset-5 {
1732 margin-left: 41.66666667%;
1733 }
1734 .col-sm-offset-4 {
1735 margin-left: 33.33333333%;
1736 }
1737 .col-sm-offset-3 {
1738 margin-left: 25%;
1739 }
1740 .col-sm-offset-2 {
1741 margin-left: 16.66666667%;
1742 }
1743 .col-sm-offset-1 {
1744 margin-left: 8.33333333%;
1745 }
1746 .col-sm-offset-0 {
1747 margin-left: 0;
1748 }
1749 }
1750 @media (min-width: 992px) {
1751 .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12 {
1752 float: left;
1753 }
1754 .col-md-12 {
1755 width: 100%;
1756 }
1757 .col-md-11 {
1758 width: 91.66666667%;
1759 }
1760 .col-md-10 {
1761 width: 83.33333333%;
1762 }
1763 .col-md-9 {
1764 width: 75%;
1765 }
1766 .col-md-8 {
1767 width: 66.66666667%;
1768 }
1769 .col-md-7 {
1770 width: 58.33333333%;
1771 }
1772 .col-md-6 {
1773 width: 50%;
1774 }
1775 .col-md-5 {
1776 width: 41.66666667%;
1777 }
1778 .col-md-4 {
1779 width: 33.33333333%;
1780 }
1781 .col-md-3 {
1782 width: 25%;
1783 }
1784 .col-md-2 {
1785 width: 16.66666667%;
1786 }
1787 .col-md-1 {
1788 width: 8.33333333%;
1789 }
1790 .col-md-pull-12 {
1791 right: 100%;
1792 }
1793 .col-md-pull-11 {
1794 right: 91.66666667%;
1795 }
1796 .col-md-pull-10 {
1797 right: 83.33333333%;
1798 }
1799 .col-md-pull-9 {
1800 right: 75%;
1801 }
1802 .col-md-pull-8 {
1803 right: 66.66666667%;
1804 }
1805 .col-md-pull-7 {
1806 right: 58.33333333%;
1807 }
1808 .col-md-pull-6 {
1809 right: 50%;
1810 }
1811 .col-md-pull-5 {
1812 right: 41.66666667%;
1813 }
1814 .col-md-pull-4 {
1815 right: 33.33333333%;
1816 }
1817 .col-md-pull-3 {
1818 right: 25%;
1819 }
1820 .col-md-pull-2 {
1821 right: 16.66666667%;
1822 }
1823 .col-md-pull-1 {
1824 right: 8.33333333%;
1825 }
1826 .col-md-pull-0 {
1827 right: auto;
1828 }
1829 .col-md-push-12 {
1830 left: 100%;
1831 }
1832 .col-md-push-11 {
1833 left: 91.66666667%;
1834 }
1835 .col-md-push-10 {
1836 left: 83.33333333%;
1837 }
1838 .col-md-push-9 {
1839 left: 75%;
1840 }
1841 .col-md-push-8 {
1842 left: 66.66666667%;
1843 }
1844 .col-md-push-7 {
1845 left: 58.33333333%;
1846 }
1847 .col-md-push-6 {
1848 left: 50%;
1849 }
1850 .col-md-push-5 {
1851 left: 41.66666667%;
1852 }
1853 .col-md-push-4 {
1854 left: 33.33333333%;
1855 }
1856 .col-md-push-3 {
1857 left: 25%;
1858 }
1859 .col-md-push-2 {
1860 left: 16.66666667%;
1861 }
1862 .col-md-push-1 {
1863 left: 8.33333333%;
1864 }
1865 .col-md-push-0 {
1866 left: auto;
1867 }
1868 .col-md-offset-12 {
1869 margin-left: 100%;
1870 }
1871 .col-md-offset-11 {
1872 margin-left: 91.66666667%;
1873 }
1874 .col-md-offset-10 {
1875 margin-left: 83.33333333%;
1876 }
1877 .col-md-offset-9 {
1878 margin-left: 75%;
1879 }
1880 .col-md-offset-8 {
1881 margin-left: 66.66666667%;
1882 }
1883 .col-md-offset-7 {
1884 margin-left: 58.33333333%;
1885 }
1886 .col-md-offset-6 {
1887 margin-left: 50%;
1888 }
1889 .col-md-offset-5 {
1890 margin-left: 41.66666667%;
1891 }
1892 .col-md-offset-4 {
1893 margin-left: 33.33333333%;
1894 }
1895 .col-md-offset-3 {
1896 margin-left: 25%;
1897 }
1898 .col-md-offset-2 {
1899 margin-left: 16.66666667%;
1900 }
1901 .col-md-offset-1 {
1902 margin-left: 8.33333333%;
1903 }
1904 .col-md-offset-0 {
1905 margin-left: 0;
1906 }
1907 }
1908 @media (min-width: 1200px) {
1909 .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12 {
1910 float: left;
1911 }
1912 .col-lg-12 {
1913 width: 100%;
1914 }
1915 .col-lg-11 {
1916 width: 91.66666667%;
1917 }
1918 .col-lg-10 {
1919 width: 83.33333333%;
1920 }
1921 .col-lg-9 {
1922 width: 75%;
1923 }
1924 .col-lg-8 {
1925 width: 66.66666667%;
1926 }
1927 .col-lg-7 {
1928 width: 58.33333333%;
1929 }
1930 .col-lg-6 {
1931 width: 50%;
1932 }
1933 .col-lg-5 {
1934 width: 41.66666667%;
1935 }
1936 .col-lg-4 {
1937 width: 33.33333333%;
1938 }
1939 .col-lg-3 {
1940 width: 25%;
1941 }
1942 .col-lg-2 {
1943 width: 16.66666667%;
1944 }
1945 .col-lg-1 {
1946 width: 8.33333333%;
1947 }
1948 .col-lg-pull-12 {
1949 right: 100%;
1950 }
1951 .col-lg-pull-11 {
1952 right: 91.66666667%;
1953 }
1954 .col-lg-pull-10 {
1955 right: 83.33333333%;
1956 }
1957 .col-lg-pull-9 {
1958 right: 75%;
1959 }
1960 .col-lg-pull-8 {
1961 right: 66.66666667%;
1962 }
1963 .col-lg-pull-7 {
1964 right: 58.33333333%;
1965 }
1966 .col-lg-pull-6 {
1967 right: 50%;
1968 }
1969 .col-lg-pull-5 {
1970 right: 41.66666667%;
1971 }
1972 .col-lg-pull-4 {
1973 right: 33.33333333%;
1974 }
1975 .col-lg-pull-3 {
1976 right: 25%;
1977 }
1978 .col-lg-pull-2 {
1979 right: 16.66666667%;
1980 }
1981 .col-lg-pull-1 {
1982 right: 8.33333333%;
1983 }
1984 .col-lg-pull-0 {
1985 right: auto;
1986 }
1987 .col-lg-push-12 {
1988 left: 100%;
1989 }
1990 .col-lg-push-11 {
1991 left: 91.66666667%;
1992 }
1993 .col-lg-push-10 {
1994 left: 83.33333333%;
1995 }
1996 .col-lg-push-9 {
1997 left: 75%;
1998 }
1999 .col-lg-push-8 {
2000 left: 66.66666667%;
2001 }
2002 .col-lg-push-7 {
2003 left: 58.33333333%;
2004 }
2005 .col-lg-push-6 {
2006 left: 50%;
2007 }
2008 .col-lg-push-5 {
2009 left: 41.66666667%;
2010 }
2011 .col-lg-push-4 {
2012 left: 33.33333333%;
2013 }
2014 .col-lg-push-3 {
2015 left: 25%;
2016 }
2017 .col-lg-push-2 {
2018 left: 16.66666667%;
2019 }
2020 .col-lg-push-1 {
2021 left: 8.33333333%;
2022 }
2023 .col-lg-push-0 {
2024 left: auto;
2025 }
2026 .col-lg-offset-12 {
2027 margin-left: 100%;
2028 }
2029 .col-lg-offset-11 {
2030 margin-left: 91.66666667%;
2031 }
2032 .col-lg-offset-10 {
2033 margin-left: 83.33333333%;
2034 }
2035 .col-lg-offset-9 {
2036 margin-left: 75%;
2037 }
2038 .col-lg-offset-8 {
2039 margin-left: 66.66666667%;
2040 }
2041 .col-lg-offset-7 {
2042 margin-left: 58.33333333%;
2043 }
2044 .col-lg-offset-6 {
2045 margin-left: 50%;
2046 }
2047 .col-lg-offset-5 {
2048 margin-left: 41.66666667%;
2049 }
2050 .col-lg-offset-4 {
2051 margin-left: 33.33333333%;
2052 }
2053 .col-lg-offset-3 {
2054 margin-left: 25%;
2055 }
2056 .col-lg-offset-2 {
2057 margin-left: 16.66666667%;
2058 }
2059 .col-lg-offset-1 {
2060 margin-left: 8.33333333%;
2061 }
2062 .col-lg-offset-0 {
2063 margin-left: 0;
2064 }
2065 }
2066 table {
2067 background-color: transparent;
2068 }
2069 th {
2070 text-align: left;
2071 }
2072 .table {
2073 width: 100%;
2074 max-width: 100%;
2075 margin-bottom: 20px;
2076 }
2077 .table > thead > tr > th,
2078 .table > tbody > tr > th,
2079 .table > tfoot > tr > th,
2080 .table > thead > tr > td,
2081 .table > tbody > tr > td,
2082 .table > tfoot > tr > td {
2083 padding: 8px;
2084 line-height: 1.42857143;
2085 vertical-align: top;
2086 border-top: 1px solid #ddd;
2087 }
2088 .table > thead > tr > th {
2089 vertical-align: bottom;
2090 border-bottom: 2px solid #ddd;
2091 }
2092 .table > caption + thead > tr:first-child > th,
2093 .table > colgroup + thead > tr:first-child > th,
2094 .table > thead:first-child > tr:first-child > th,
2095 .table > caption + thead > tr:first-child > td,
2096 .table > colgroup + thead > tr:first-child > td,
2097 .table > thead:first-child > tr:first-child > td {
2098 border-top: 0;
2099 }
2100 .table > tbody + tbody {
2101 border-top: 2px solid #ddd;
2102 }
2103 .table .table {
2104 background-color: #fff;
2105 }
2106 .table-condensed > thead > tr > th,
2107 .table-condensed > tbody > tr > th,
2108 .table-condensed > tfoot > tr > th,
2109 .table-condensed > thead > tr > td,
2110 .table-condensed > tbody > tr > td,
2111 .table-condensed > tfoot > tr > td {
2112 padding: 5px;
2113 }
2114 .table-bordered {
2115 border: 1px solid #ddd;
2116 }
2117 .table-bordered > thead > tr > th,
2118 .table-bordered > tbody > tr > th,
2119 .table-bordered > tfoot > tr > th,
2120 .table-bordered > thead > tr > td,
2121 .table-bordered > tbody > tr > td,
2122 .table-bordered > tfoot > tr > td {
2123 border: 1px solid #ddd;
2124 }
2125 .table-bordered > thead > tr > th,
2126 .table-bordered > thead > tr > td {
2127 border-bottom-width: 2px;
2128 }
2129 .table-striped > tbody > tr:nth-child(odd) > td,
2130 .table-striped > tbody > tr:nth-child(odd) > th {
2131 background-color: #f9f9f9;
2132 }
2133 .table-hover > tbody > tr:hover > td,
2134 .table-hover > tbody > tr:hover > th {
2135 background-color: #f5f5f5;
2136 }
2137 table col[class*="col-"] {
2138 position: static;
2139 display: table-column;
2140 float: none;
2141 }
2142 table td[class*="col-"],
2143 table th[class*="col-"] {
2144 position: static;
2145 display: table-cell;
2146 float: none;
2147 }
2148 .table > thead > tr > td.active,
2149 .table > tbody > tr > td.active,
2150 .table > tfoot > tr > td.active,
2151 .table > thead > tr > th.active,
2152 .table > tbody > tr > th.active,
2153 .table > tfoot > tr > th.active,
2154 .table > thead > tr.active > td,
2155 .table > tbody > tr.active > td,
2156 .table > tfoot > tr.active > td,
2157 .table > thead > tr.active > th,
2158 .table > tbody > tr.active > th,
2159 .table > tfoot > tr.active > th {
2160 background-color: #f5f5f5;
2161 }
2162 .table-hover > tbody > tr > td.active:hover,
2163 .table-hover > tbody > tr > th.active:hover,
2164 .table-hover > tbody > tr.active:hover > td,
2165 .table-hover > tbody > tr:hover > .active,
2166 .table-hover > tbody > tr.active:hover > th {
2167 background-color: #e8e8e8;
2168 }
2169 .table > thead > tr > td.success,
2170 .table > tbody > tr > td.success,
2171 .table > tfoot > tr > td.success,
2172 .table > thead > tr > th.success,
2173 .table > tbody > tr > th.success,
2174 .table > tfoot > tr > th.success,
2175 .table > thead > tr.success > td,
2176 .table > tbody > tr.success > td,
2177 .table > tfoot > tr.success > td,
2178 .table > thead > tr.success > th,
2179 .table > tbody > tr.success > th,
2180 .table > tfoot > tr.success > th {
2181 background-color: #dff0d8;
2182 }
2183 .table-hover > tbody > tr > td.success:hover,
2184 .table-hover > tbody > tr > th.success:hover,
2185 .table-hover > tbody > tr.success:hover > td,
2186 .table-hover > tbody > tr:hover > .success,
2187 .table-hover > tbody > tr.success:hover > th {
2188 background-color: #d0e9c6;
2189 }
2190 .table > thead > tr > td.info,
2191 .table > tbody > tr > td.info,
2192 .table > tfoot > tr > td.info,
2193 .table > thead > tr > th.info,
2194 .table > tbody > tr > th.info,
2195 .table > tfoot > tr > th.info,
2196 .table > thead > tr.info > td,
2197 .table > tbody > tr.info > td,
2198 .table > tfoot > tr.info > td,
2199 .table > thead > tr.info > th,
2200 .table > tbody > tr.info > th,
2201 .table > tfoot > tr.info > th {
2202 background-color: #d9edf7;
2203 }
2204 .table-hover > tbody > tr > td.info:hover,
2205 .table-hover > tbody > tr > th.info:hover,
2206 .table-hover > tbody > tr.info:hover > td,
2207 .table-hover > tbody > tr:hover > .info,
2208 .table-hover > tbody > tr.info:hover > th {
2209 background-color: #c4e3f3;
2210 }
2211 .table > thead > tr > td.warning,
2212 .table > tbody > tr > td.warning,
2213 .table > tfoot > tr > td.warning,
2214 .table > thead > tr > th.warning,
2215 .table > tbody > tr > th.warning,
2216 .table > tfoot > tr > th.warning,
2217 .table > thead > tr.warning > td,
2218 .table > tbody > tr.warning > td,
2219 .table > tfoot > tr.warning > td,
2220 .table > thead > tr.warning > th,
2221 .table > tbody > tr.warning > th,
2222 .table > tfoot > tr.warning > th {
2223 background-color: #fcf8e3;
2224 }
2225 .table-hover > tbody > tr > td.warning:hover,
2226 .table-hover > tbody > tr > th.warning:hover,
2227 .table-hover > tbody > tr.warning:hover > td,
2228 .table-hover > tbody > tr:hover > .warning,
2229 .table-hover > tbody > tr.warning:hover > th {
2230 background-color: #faf2cc;
2231 }
2232 .table > thead > tr > td.danger,
2233 .table > tbody > tr > td.danger,
2234 .table > tfoot > tr > td.danger,
2235 .table > thead > tr > th.danger,
2236 .table > tbody > tr > th.danger,
2237 .table > tfoot > tr > th.danger,
2238 .table > thead > tr.danger > td,
2239 .table > tbody > tr.danger > td,
2240 .table > tfoot > tr.danger > td,
2241 .table > thead > tr.danger > th,
2242 .table > tbody > tr.danger > th,
2243 .table > tfoot > tr.danger > th {
2244 background-color: #f2dede;
2245 }
2246 .table-hover > tbody > tr > td.danger:hover,
2247 .table-hover > tbody > tr > th.danger:hover,
2248 .table-hover > tbody > tr.danger:hover > td,
2249 .table-hover > tbody > tr:hover > .danger,
2250 .table-hover > tbody > tr.danger:hover > th {
2251 background-color: #ebcccc;
2252 }
2253 @media screen and (max-width: 767px) {
2254 .table-responsive {
2255 width: 100%;
2256 margin-bottom: 15px;
2257 overflow-x: auto;
2258 overflow-y: hidden;
2259 -webkit-overflow-scrolling: touch;
2260 -ms-overflow-style: -ms-autohiding-scrollbar;
2261 border: 1px solid #ddd;
2262 }
2263 .table-responsive > .table {
2264 margin-bottom: 0;
2265 }
2266 .table-responsive > .table > thead > tr > th,
2267 .table-responsive > .table > tbody > tr > th,
2268 .table-responsive > .table > tfoot > tr > th,
2269 .table-responsive > .table > thead > tr > td,
2270 .table-responsive > .table > tbody > tr > td,
2271 .table-responsive > .table > tfoot > tr > td {
2272 white-space: nowrap;
2273 }
2274 .table-responsive > .table-bordered {
2275 border: 0;
2276 }
2277 .table-responsive > .table-bordered > thead > tr > th:first-child,
2278 .table-responsive > .table-bordered > tbody > tr > th:first-child,
2279 .table-responsive > .table-bordered > tfoot > tr > th:first-child,
2280 .table-responsive > .table-bordered > thead > tr > td:first-child,
2281 .table-responsive > .table-bordered > tbody > tr > td:first-child,
2282 .table-responsive > .table-bordered > tfoot > tr > td:first-child {
2283 border-left: 0;
2284 }
2285 .table-responsive > .table-bordered > thead > tr > th:last-child,
2286 .table-responsive > .table-bordered > tbody > tr > th:last-child,
2287 .table-responsive > .table-bordered > tfoot > tr > th:last-child,
2288 .table-responsive > .table-bordered > thead > tr > td:last-child,
2289 .table-responsive > .table-bordered > tbody > tr > td:last-child,
2290 .table-responsive > .table-bordered > tfoot > tr > td:last-child {
2291 border-right: 0;
2292 }
2293 .table-responsive > .table-bordered > tbody > tr:last-child > th,
2294 .table-responsive > .table-bordered > tfoot > tr:last-child > th,
2295 .table-responsive > .table-bordered > tbody > tr:last-child > td,
2296 .table-responsive > .table-bordered > tfoot > tr:last-child > td {
2297 border-bottom: 0;
2298 }
2299 }
2300 fieldset {
2301 min-width: 0;
2302 padding: 0;
2303 margin: 0;
2304 border: 0;
2305 }
2306 legend {
2307 display: block;
2308 width: 100%;
2309 padding: 0;
2310 margin-bottom: 20px;
2311 font-size: 21px;
2312 line-height: inherit;
2313 color: #333;
2314 border: 0;
2315 border-bottom: 1px solid #e5e5e5;
2316 }
2317 label {
2318 display: inline-block;
2319 max-width: 100%;
2320 margin-bottom: 5px;
2321 font-weight: bold;
2322 }
2323 input[type="search"] {
2324 -webkit-box-sizing: border-box;
2325 -moz-box-sizing: border-box;
2326 box-sizing: border-box;
2327 }
2328 input[type="radio"],
2329 input[type="checkbox"] {
2330 margin: 4px 0 0;
2331 margin-top: 1px \9;
2332 line-height: normal;
2333 }
2334 input[type="file"] {
2335 display: block;
2336 }
2337 input[type="range"] {
2338 display: block;
2339 width: 100%;
2340 }
2341 select[multiple],
2342 select[size] {
2343 height: auto;
2344 }
2345 input[type="file"]:focus,
2346 input[type="radio"]:focus,
2347 input[type="checkbox"]:focus {
2348 outline: thin dotted;
2349 outline: 5px auto -webkit-focus-ring-color;
2350 outline-offset: -2px;
2351 }
2352 output {
2353 display: block;
2354 padding-top: 7px;
2355 font-size: 14px;
2356 line-height: 1.42857143;
2357 color: #555;
2358 }
2359 .form-control {
2360 display: block;
2361 width: 100%;
2362 height: 34px;
2363 padding: 6px 12px;
2364 font-size: 14px;
2365 line-height: 1.42857143;
2366 color: #555;
2367 background-color: #fff;
2368 background-image: none;
2369 border: 1px solid #ccc;
2370 border-radius: 4px;
2371 -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
2372 box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
2373 -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
2374 -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
2375 transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
2376 }
2377 .form-control:focus {
2378 border-color: #66afe9;
2379 outline: 0;
2380 -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);
2381 box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);
2382 }
2383 .form-control::-moz-placeholder {
2384 color: #777;
2385 opacity: 1;
2386 }
2387 .form-control:-ms-input-placeholder {
2388 color: #777;
2389 }
2390 .form-control::-webkit-input-placeholder {
2391 color: #777;
2392 }
2393 .form-control[disabled],
2394 .form-control[readonly],
2395 fieldset[disabled] .form-control {
2396 cursor: not-allowed;
2397 background-color: #eee;
2398 opacity: 1;
2399 }
2400 textarea.form-control {
2401 height: auto;
2402 }
2403 input[type="search"] {
2404 -webkit-appearance: none;
2405 }
2406 input[type="date"],
2407 input[type="time"],
2408 input[type="datetime-local"],
2409 input[type="month"] {
2410 line-height: 34px;
2411 line-height: 1.42857143 \0;
2412 }
2413 input[type="date"].input-sm,
2414 input[type="time"].input-sm,
2415 input[type="datetime-local"].input-sm,
2416 input[type="month"].input-sm {
2417 line-height: 30px;
2418 }
2419 input[type="date"].input-lg,
2420 input[type="time"].input-lg,
2421 input[type="datetime-local"].input-lg,
2422 input[type="month"].input-lg {
2423 line-height: 46px;
2424 }
2425 .form-group {
2426 margin-bottom: 15px;
2427 }
2428 .radio,
2429 .checkbox {
2430 position: relative;
2431 display: block;
2432 min-height: 20px;
2433 margin-top: 10px;
2434 margin-bottom: 10px;
2435 }
2436 .radio label,
2437 .checkbox label {
2438 padding-left: 20px;
2439 margin-bottom: 0;
2440 font-weight: normal;
2441 cursor: pointer;
2442 }
2443 .radio input[type="radio"],
2444 .radio-inline input[type="radio"],
2445 .checkbox input[type="checkbox"],
2446 .checkbox-inline input[type="checkbox"] {
2447 position: absolute;
2448 margin-top: 4px \9;
2449 margin-left: -20px;
2450 }
2451 .radio + .radio,
2452 .checkbox + .checkbox {
2453 margin-top: -5px;
2454 }
2455 .radio-inline,
2456 .checkbox-inline {
2457 display: inline-block;
2458 padding-left: 20px;
2459 margin-bottom: 0;
2460 font-weight: normal;
2461 vertical-align: middle;
2462 cursor: pointer;
2463 }
2464 .radio-inline + .radio-inline,
2465 .checkbox-inline + .checkbox-inline {
2466 margin-top: 0;
2467 margin-left: 10px;
2468 }
2469 input[type="radio"][disabled],
2470 input[type="checkbox"][disabled],
2471 input[type="radio"].disabled,
2472 input[type="checkbox"].disabled,
2473 fieldset[disabled] input[type="radio"],
2474 fieldset[disabled] input[type="checkbox"] {
2475 cursor: not-allowed;
2476 }
2477 .radio-inline.disabled,
2478 .checkbox-inline.disabled,
2479 fieldset[disabled] .radio-inline,
2480 fieldset[disabled] .checkbox-inline {
2481 cursor: not-allowed;
2482 }
2483 .radio.disabled label,
2484 .checkbox.disabled label,
2485 fieldset[disabled] .radio label,
2486 fieldset[disabled] .checkbox label {
2487 cursor: not-allowed;
2488 }
2489 .form-control-static {
2490 padding-top: 7px;
2491 padding-bottom: 7px;
2492 margin-bottom: 0;
2493 }
2494 .form-control-static.input-lg,
2495 .form-control-static.input-sm {
2496 padding-right: 0;
2497 padding-left: 0;
2498 }
2499 .input-sm,
2500 .form-horizontal .form-group-sm .form-control {
2501 height: 30px;
2502 padding: 5px 10px;
2503 font-size: 12px;
2504 line-height: 1.5;
2505 border-radius: 3px;
2506 }
2507 select.input-sm {
2508 height: 30px;
2509 line-height: 30px;
2510 }
2511 textarea.input-sm,
2512 select[multiple].input-sm {
2513 height: auto;
2514 }
2515 .input-lg,
2516 .form-horizontal .form-group-lg .form-control {
2517 height: 46px;
2518 padding: 10px 16px;
2519 font-size: 18px;
2520 line-height: 1.33;
2521 border-radius: 6px;
2522 }
2523 select.input-lg {
2524 height: 46px;
2525 line-height: 46px;
2526 }
2527 textarea.input-lg,
2528 select[multiple].input-lg {
2529 height: auto;
2530 }
2531 .has-feedback {
2532 position: relative;
2533 }
2534 .has-feedback .form-control {
2535 padding-right: 42.5px;
2536 }
2537 .form-control-feedback {
2538 position: absolute;
2539 top: 25px;
2540 right: 0;
2541 z-index: 2;
2542 display: block;
2543 width: 34px;
2544 height: 34px;
2545 line-height: 34px;
2546 text-align: center;
2547 }
2548 .input-lg + .form-control-feedback {
2549 width: 46px;
2550 height: 46px;
2551 line-height: 46px;
2552 }
2553 .input-sm + .form-control-feedback {
2554 width: 30px;
2555 height: 30px;
2556 line-height: 30px;
2557 }
2558 .has-success .help-block,
2559 .has-success .control-label,
2560 .has-success .radio,
2561 .has-success .checkbox,
2562 .has-success .radio-inline,
2563 .has-success .checkbox-inline {
2564 color: #3c763d;
2565 }
2566 .has-success .form-control {
2567 border-color: #3c763d;
2568 -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
2569 box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
2570 }
2571 .has-success .form-control:focus {
2572 border-color: #2b542c;
2573 -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #67b168;
2574 box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #67b168;
2575 }
2576 .has-success .input-group-addon {
2577 color: #3c763d;
2578 background-color: #dff0d8;
2579 border-color: #3c763d;
2580 }
2581 .has-success .form-control-feedback {
2582 color: #3c763d;
2583 }
2584 .has-warning .help-block,
2585 .has-warning .control-label,
2586 .has-warning .radio,
2587 .has-warning .checkbox,
2588 .has-warning .radio-inline,
2589 .has-warning .checkbox-inline {
2590 color: #8a6d3b;
2591 }
2592 .has-warning .form-control {
2593 border-color: #8a6d3b;
2594 -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
2595 box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
2596 }
2597 .has-warning .form-control:focus {
2598 border-color: #66512c;
2599 -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #c0a16b;
2600 box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #c0a16b;
2601 }
2602 .has-warning .input-group-addon {
2603 color: #8a6d3b;
2604 background-color: #fcf8e3;
2605 border-color: #8a6d3b;
2606 }
2607 .has-warning .form-control-feedback {
2608 color: #8a6d3b;
2609 }
2610 .has-error .help-block,
2611 .has-error .control-label,
2612 .has-error .radio,
2613 .has-error .checkbox,
2614 .has-error .radio-inline,
2615 .has-error .checkbox-inline {
2616 color: #a94442;
2617 }
2618 .has-error .form-control {
2619 border-color: #a94442;
2620 -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
2621 box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
2622 }
2623 .has-error .form-control:focus {
2624 border-color: #843534;
2625 -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #ce8483;
2626 box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 6px #ce8483;
2627 }
2628 .has-error .input-group-addon {
2629 color: #a94442;
2630 background-color: #f2dede;
2631 border-color: #a94442;
2632 }
2633 .has-error .form-control-feedback {
2634 color: #a94442;
2635 }
2636 .has-feedback label.sr-only ~ .form-control-feedback {
2637 top: 0;
2638 }
2639 .help-block {
2640 display: block;
2641 margin-top: 5px;
2642 margin-bottom: 10px;
2643 color: #737373;
2644 }
2645 @media (min-width: 768px) {
2646 .form-inline .form-group {
2647 display: inline-block;
2648 margin-bottom: 0;
2649 vertical-align: middle;
2650 }
2651 .form-inline .form-control {
2652 display: inline-block;
2653 width: auto;
2654 vertical-align: middle;
2655 }
2656 .form-inline .input-group {
2657 display: inline-table;
2658 vertical-align: middle;
2659 }
2660 .form-inline .input-group .input-group-addon,
2661 .form-inline .input-group .input-group-btn,
2662 .form-inline .input-group .form-control {
2663 width: auto;
2664 }
2665 .form-inline .input-group > .form-control {
2666 width: 100%;
2667 }
2668 .form-inline .control-label {
2669 margin-bottom: 0;
2670 vertical-align: middle;
2671 }
2672 .form-inline .radio,
2673 .form-inline .checkbox {
2674 display: inline-block;
2675 margin-top: 0;
2676 margin-bottom: 0;
2677 vertical-align: middle;
2678 }
2679 .form-inline .radio label,
2680 .form-inline .checkbox label {
2681 padding-left: 0;
2682 }
2683 .form-inline .radio input[type="radio"],
2684 .form-inline .checkbox input[type="checkbox"] {
2685 position: relative;
2686 margin-left: 0;
2687 }
2688 .form-inline .has-feedback .form-control-feedback {
2689 top: 0;
2690 }
2691 }
2692 .form-horizontal .radio,
2693 .form-horizontal .checkbox,
2694 .form-horizontal .radio-inline,
2695 .form-horizontal .checkbox-inline {
2696 padding-top: 7px;
2697 margin-top: 0;
2698 margin-bottom: 0;
2699 }
2700 .form-horizontal .radio,
2701 .form-horizontal .checkbox {
2702 min-height: 27px;
2703 }
2704 .form-horizontal .form-group {
2705 margin-right: -15px;
2706 margin-left: -15px;
2707 }
2708 @media (min-width: 768px) {
2709 .form-horizontal .control-label {
2710 padding-top: 7px;
2711 margin-bottom: 0;
2712 text-align: right;
2713 }
2714 }
2715 .form-horizontal .has-feedback .form-control-feedback {
2716 top: 0;
2717 right: 15px;
2718 }
2719 @media (min-width: 768px) {
2720 .form-horizontal .form-group-lg .control-label {
2721 padding-top: 14.3px;
2722 }
2723 }
2724 @media (min-width: 768px) {
2725 .form-horizontal .form-group-sm .control-label {
2726 padding-top: 6px;
2727 }
2728 }
2729 .btn {
2730 display: inline-block;
2731 padding: 6px 12px;
2732 margin-bottom: 0;
2733 font-size: 14px;
2734 font-weight: normal;
2735 line-height: 1.42857143;
2736 text-align: center;
2737 white-space: nowrap;
2738 vertical-align: middle;
2739 cursor: pointer;
2740 -webkit-user-select: none;
2741 -moz-user-select: none;
2742 -ms-user-select: none;
2743 user-select: none;
2744 background-image: none;
2745 border: 1px solid transparent;
2746 border-radius: 4px;
2747 }
2748 .btn:focus,
2749 .btn:active:focus,
2750 .btn.active:focus {
2751 outline: thin dotted;
2752 outline: 5px auto -webkit-focus-ring-color;
2753 outline-offset: -2px;
2754 }
2755 .btn:hover,
2756 .btn:focus {
2757 color: #333;
2758 text-decoration: none;
2759 }
2760 .btn:active,
2761 .btn.active {
2762 background-image: none;
2763 outline: 0;
2764 -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
2765 box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
2766 }
2767 .btn.disabled,
2768 .btn[disabled],
2769 fieldset[disabled] .btn {
2770 pointer-events: none;
2771 cursor: not-allowed;
2772 filter: alpha(opacity=65);
2773 -webkit-box-shadow: none;
2774 box-shadow: none;
2775 opacity: .65;
2776 }
2777 .btn-default {
2778 color: #333;
2779 background-color: #fff;
2780 border-color: #ccc;
2781 }
2782 .btn-default:hover,
2783 .btn-default:focus,
2784 .btn-default:active,
2785 .btn-default.active,
2786 .open > .dropdown-toggle.btn-default {
2787 color: #333;
2788 background-color: #e6e6e6;
2789 border-color: #adadad;
2790 }
2791 .btn-default:active,
2792 .btn-default.active,
2793 .open > .dropdown-toggle.btn-default {
2794 background-image: none;
2795 }
2796 .btn-default.disabled,
2797 .btn-default[disabled],
2798 fieldset[disabled] .btn-default,
2799 .btn-default.disabled:hover,
2800 .btn-default[disabled]:hover,
2801 fieldset[disabled] .btn-default:hover,
2802 .btn-default.disabled:focus,
2803 .btn-default[disabled]:focus,
2804 fieldset[disabled] .btn-default:focus,
2805 .btn-default.disabled:active,
2806 .btn-default[disabled]:active,
2807 fieldset[disabled] .btn-default:active,
2808 .btn-default.disabled.active,
2809 .btn-default[disabled].active,
2810 fieldset[disabled] .btn-default.active {
2811 background-color: #fff;
2812 border-color: #ccc;
2813 }
2814 .btn-default .badge {
2815 color: #fff;
2816 background-color: #333;
2817 }
2818 .btn-primary {
2819 color: #fff;
2820 background-color: #428bca;
2821 border-color: #357ebd;
2822 }
2823 .btn-primary:hover,
2824 .btn-primary:focus,
2825 .btn-primary:active,
2826 .btn-primary.active,
2827 .open > .dropdown-toggle.btn-primary {
2828 color: #fff;
2829 background-color: #3071a9;
2830 border-color: #285e8e;
2831 }
2832 .btn-primary:active,
2833 .btn-primary.active,
2834 .open > .dropdown-toggle.btn-primary {
2835 background-image: none;
2836 }
2837 .btn-primary.disabled,
2838 .btn-primary[disabled],
2839 fieldset[disabled] .btn-primary,
2840 .btn-primary.disabled:hover,
2841 .btn-primary[disabled]:hover,
2842 fieldset[disabled] .btn-primary:hover,
2843 .btn-primary.disabled:focus,
2844 .btn-primary[disabled]:focus,
2845 fieldset[disabled] .btn-primary:focus,
2846 .btn-primary.disabled:active,
2847 .btn-primary[disabled]:active,
2848 fieldset[disabled] .btn-primary:active,
2849 .btn-primary.disabled.active,
2850 .btn-primary[disabled].active,
2851 fieldset[disabled] .btn-primary.active {
2852 background-color: #428bca;
2853 border-color: #357ebd;
2854 }
2855 .btn-primary .badge {
2856 color: #428bca;
2857 background-color: #fff;
2858 }
2859 .btn-success {
2860 color: #fff;
2861 background-color: #5cb85c;
2862 border-color: #4cae4c;
2863 }
2864 .btn-success:hover,
2865 .btn-success:focus,
2866 .btn-success:active,
2867 .btn-success.active,
2868 .open > .dropdown-toggle.btn-success {
2869 color: #fff;
2870 background-color: #449d44;
2871 border-color: #398439;
2872 }
2873 .btn-success:active,
2874 .btn-success.active,
2875 .open > .dropdown-toggle.btn-success {
2876 background-image: none;
2877 }
2878 .btn-success.disabled,
2879 .btn-success[disabled],
2880 fieldset[disabled] .btn-success,
2881 .btn-success.disabled:hover,
2882 .btn-success[disabled]:hover,
2883 fieldset[disabled] .btn-success:hover,
2884 .btn-success.disabled:focus,
2885 .btn-success[disabled]:focus,
2886 fieldset[disabled] .btn-success:focus,
2887 .btn-success.disabled:active,
2888 .btn-success[disabled]:active,
2889 fieldset[disabled] .btn-success:active,
2890 .btn-success.disabled.active,
2891 .btn-success[disabled].active,
2892 fieldset[disabled] .btn-success.active {
2893 background-color: #5cb85c;
2894 border-color: #4cae4c;
2895 }
2896 .btn-success .badge {
2897 color: #5cb85c;
2898 background-color: #fff;
2899 }
2900 .btn-info {
2901 color: #fff;
2902 background-color: #5bc0de;
2903 border-color: #46b8da;
2904 }
2905 .btn-info:hover,
2906 .btn-info:focus,
2907 .btn-info:active,
2908 .btn-info.active,
2909 .open > .dropdown-toggle.btn-info {
2910 color: #fff;
2911 background-color: #31b0d5;
2912 border-color: #269abc;
2913 }
2914 .btn-info:active,
2915 .btn-info.active,
2916 .open > .dropdown-toggle.btn-info {
2917 background-image: none;
2918 }
2919 .btn-info.disabled,
2920 .btn-info[disabled],
2921 fieldset[disabled] .btn-info,
2922 .btn-info.disabled:hover,
2923 .btn-info[disabled]:hover,
2924 fieldset[disabled] .btn-info:hover,
2925 .btn-info.disabled:focus,
2926 .btn-info[disabled]:focus,
2927 fieldset[disabled] .btn-info:focus,
2928 .btn-info.disabled:active,
2929 .btn-info[disabled]:active,
2930 fieldset[disabled] .btn-info:active,
2931 .btn-info.disabled.active,
2932 .btn-info[disabled].active,
2933 fieldset[disabled] .btn-info.active {
2934 background-color: #5bc0de;
2935 border-color: #46b8da;
2936 }
2937 .btn-info .badge {
2938 color: #5bc0de;
2939 background-color: #fff;
2940 }
2941 .btn-warning {
2942 color: #fff;
2943 background-color: #f0ad4e;
2944 border-color: #eea236;
2945 }
2946 .btn-warning:hover,
2947 .btn-warning:focus,
2948 .btn-warning:active,
2949 .btn-warning.active,
2950 .open > .dropdown-toggle.btn-warning {
2951 color: #fff;
2952 background-color: #ec971f;
2953 border-color: #d58512;
2954 }
2955 .btn-warning:active,
2956 .btn-warning.active,
2957 .open > .dropdown-toggle.btn-warning {
2958 background-image: none;
2959 }
2960 .btn-warning.disabled,
2961 .btn-warning[disabled],
2962 fieldset[disabled] .btn-warning,
2963 .btn-warning.disabled:hover,
2964 .btn-warning[disabled]:hover,
2965 fieldset[disabled] .btn-warning:hover,
2966 .btn-warning.disabled:focus,
2967 .btn-warning[disabled]:focus,
2968 fieldset[disabled] .btn-warning:focus,
2969 .btn-warning.disabled:active,
2970 .btn-warning[disabled]:active,
2971 fieldset[disabled] .btn-warning:active,
2972 .btn-warning.disabled.active,
2973 .btn-warning[disabled].active,
2974 fieldset[disabled] .btn-warning.active {
2975 background-color: #f0ad4e;
2976 border-color: #eea236;
2977 }
2978 .btn-warning .badge {
2979 color: #f0ad4e;
2980 background-color: #fff;
2981 }
2982 .btn-danger {
2983 color: #fff;
2984 background-color: #d9534f;
2985 border-color: #d43f3a;
2986 }
2987 .btn-danger:hover,
2988 .btn-danger:focus,
2989 .btn-danger:active,
2990 .btn-danger.active,
2991 .open > .dropdown-toggle.btn-danger {
2992 color: #fff;
2993 background-color: #c9302c;
2994 border-color: #ac2925;
2995 }
2996 .btn-danger:active,
2997 .btn-danger.active,
2998 .open > .dropdown-toggle.btn-danger {
2999 background-image: none;
3000 }
3001 .btn-danger.disabled,
3002 .btn-danger[disabled],
3003 fieldset[disabled] .btn-danger,
3004 .btn-danger.disabled:hover,
3005 .btn-danger[disabled]:hover,
3006 fieldset[disabled] .btn-danger:hover,
3007 .btn-danger.disabled:focus,
3008 .btn-danger[disabled]:focus,
3009 fieldset[disabled] .btn-danger:focus,
3010 .btn-danger.disabled:active,
3011 .btn-danger[disabled]:active,
3012 fieldset[disabled] .btn-danger:active,
3013 .btn-danger.disabled.active,
3014 .btn-danger[disabled].active,
3015 fieldset[disabled] .btn-danger.active {
3016 background-color: #d9534f;
3017 border-color: #d43f3a;
3018 }
3019 .btn-danger .badge {
3020 color: #d9534f;
3021 background-color: #fff;
3022 }
3023 .btn-link {
3024 font-weight: normal;
3025 color: #428bca;
3026 cursor: pointer;
3027 border-radius: 0;
3028 }
3029 .btn-link,
3030 .btn-link:active,
3031 .btn-link[disabled],
3032 fieldset[disabled] .btn-link {
3033 background-color: transparent;
3034 -webkit-box-shadow: none;
3035 box-shadow: none;
3036 }
3037 .btn-link,
3038 .btn-link:hover,
3039 .btn-link:focus,
3040 .btn-link:active {
3041 border-color: transparent;
3042 }
3043 .btn-link:hover,
3044 .btn-link:focus {
3045 color: #2a6496;
3046 text-decoration: underline;
3047 background-color: transparent;
3048 }
3049 .btn-link[disabled]:hover,
3050 fieldset[disabled] .btn-link:hover,
3051 .btn-link[disabled]:focus,
3052 fieldset[disabled] .btn-link:focus {
3053 color: #777;
3054 text-decoration: none;
3055 }
3056 .btn-lg,
3057 .btn-group-lg > .btn {
3058 padding: 10px 16px;
3059 font-size: 18px;
3060 line-height: 1.33;
3061 border-radius: 6px;
3062 }
3063 .btn-sm,
3064 .btn-group-sm > .btn {
3065 padding: 5px 10px;
3066 font-size: 12px;
3067 line-height: 1.5;
3068 border-radius: 3px;
3069 }
3070 .btn-xs,
3071 .btn-group-xs > .btn {
3072 padding: 1px 5px;
3073 font-size: 12px;
3074 line-height: 1.5;
3075 border-radius: 3px;
3076 }
3077 .btn-block {
3078 display: block;
3079 width: 100%;
3080 }
3081 .btn-block + .btn-block {
3082 margin-top: 5px;
3083 }
3084 input[type="submit"].btn-block,
3085 input[type="reset"].btn-block,
3086 input[type="button"].btn-block {
3087 width: 100%;
3088 }
3089 .fade {
3090 opacity: 0;
3091 -webkit-transition: opacity .15s linear;
3092 -o-transition: opacity .15s linear;
3093 transition: opacity .15s linear;
3094 }
3095 .fade.in {
3096 opacity: 1;
3097 }
3098 .collapse {
3099 display: none;
3100 }
3101 .collapse.in {
3102 display: block;
3103 }
3104 tr.collapse.in {
3105 display: table-row;
3106 }
3107 tbody.collapse.in {
3108 display: table-row-group;
3109 }
3110 .collapsing {
3111 position: relative;
3112 height: 0;
3113 overflow: hidden;
3114 -webkit-transition: height .35s ease;
3115 -o-transition: height .35s ease;
3116 transition: height .35s ease;
3117 }
3118 .caret {
3119 display: inline-block;
3120 width: 0;
3121 height: 0;
3122 margin-left: 2px;
3123 vertical-align: middle;
3124 border-top: 4px solid;
3125 border-right: 4px solid transparent;
3126 border-left: 4px solid transparent;
3127 }
3128 .dropdown {
3129 position: relative;
3130 }
3131 .dropdown-toggle:focus {
3132 outline: 0;
3133 }
3134 .dropdown-menu {
3135 position: absolute;
3136 top: 100%;
3137 left: 0;
3138 z-index: 1000;
3139 display: none;
3140 float: left;
3141 min-width: 160px;
3142 padding: 5px 0;
3143 margin: 2px 0 0;
3144 font-size: 14px;
3145 text-align: left;
3146 list-style: none;
3147 background-color: #fff;
3148 -webkit-background-clip: padding-box;
3149 background-clip: padding-box;
3150 border: 1px solid #ccc;
3151 border: 1px solid rgba(0, 0, 0, .15);
3152 border-radius: 4px;
3153 -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, .175);
3154 box-shadow: 0 6px 12px rgba(0, 0, 0, .175);
3155 }
3156 .dropdown-menu.pull-right {
3157 right: 0;
3158 left: auto;
3159 }
3160 .dropdown-menu .divider {
3161 height: 1px;
3162 margin: 9px 0;
3163 overflow: hidden;
3164 background-color: #e5e5e5;
3165 }
3166 .dropdown-menu > li > a {
3167 display: block;
3168 padding: 3px 20px;
3169 clear: both;
3170 font-weight: normal;
3171 line-height: 1.42857143;
3172 color: #333;
3173 white-space: nowrap;
3174 }
3175 .dropdown-menu > li > a:hover,
3176 .dropdown-menu > li > a:focus {
3177 color: #262626;
3178 text-decoration: none;
3179 background-color: #f5f5f5;
3180 }
3181 .dropdown-menu > .active > a,
3182 .dropdown-menu > .active > a:hover,
3183 .dropdown-menu > .active > a:focus {
3184 color: #fff;
3185 text-decoration: none;
3186 background-color: #428bca;
3187 outline: 0;
3188 }
3189 .dropdown-menu > .disabled > a,
3190 .dropdown-menu > .disabled > a:hover,
3191 .dropdown-menu > .disabled > a:focus {
3192 color: #777;
3193 }
3194 .dropdown-menu > .disabled > a:hover,
3195 .dropdown-menu > .disabled > a:focus {
3196 text-decoration: none;
3197 cursor: not-allowed;
3198 background-color: transparent;
3199 background-image: none;
3200 filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
3201 }
3202 .open > .dropdown-menu {
3203 display: block;
3204 }
3205 .open > a {
3206 outline: 0;
3207 }
3208 .dropdown-menu-right {
3209 right: 0;
3210 left: auto;
3211 }
3212 .dropdown-menu-left {
3213 right: auto;
3214 left: 0;
3215 }
3216 .dropdown-header {
3217 display: block;
3218 padding: 3px 20px;
3219 font-size: 12px;
3220 line-height: 1.42857143;
3221 color: #777;
3222 white-space: nowrap;
3223 }
3224 .dropdown-backdrop {
3225 position: fixed;
3226 top: 0;
3227 right: 0;
3228 bottom: 0;
3229 left: 0;
3230 z-index: 990;
3231 }
3232 .pull-right > .dropdown-menu {
3233 right: 0;
3234 left: auto;
3235 }
3236 .dropup .caret,
3237 .navbar-fixed-bottom .dropdown .caret {
3238 content: "";
3239 border-top: 0;
3240 border-bottom: 4px solid;
3241 }
3242 .dropup .dropdown-menu,
3243 .navbar-fixed-bottom .dropdown .dropdown-menu {
3244 top: auto;
3245 bottom: 100%;
3246 margin-bottom: 1px;
3247 }
3248 @media (min-width: 768px) {
3249 .navbar-right .dropdown-menu {
3250 right: 0;
3251 left: auto;
3252 }
3253 .navbar-right .dropdown-menu-left {
3254 right: auto;
3255 left: 0;
3256 }
3257 }
3258 .btn-group,
3259 .btn-group-vertical {
3260 position: relative;
3261 display: inline-block;
3262 vertical-align: middle;
3263 }
3264 .btn-group > .btn,
3265 .btn-group-vertical > .btn {
3266 position: relative;
3267 float: left;
3268 }
3269 .btn-group > .btn:hover,
3270 .btn-group-vertical > .btn:hover,
3271 .btn-group > .btn:focus,
3272 .btn-group-vertical > .btn:focus,
3273 .btn-group > .btn:active,
3274 .btn-group-vertical > .btn:active,
3275 .btn-group > .btn.active,
3276 .btn-group-vertical > .btn.active {
3277 z-index: 2;
3278 }
3279 .btn-group > .btn:focus,
3280 .btn-group-vertical > .btn:focus {
3281 outline: 0;
3282 }
3283 .btn-group .btn + .btn,
3284 .btn-group .btn + .btn-group,
3285 .btn-group .btn-group + .btn,
3286 .btn-group .btn-group + .btn-group {
3287 margin-left: -1px;
3288 }
3289 .btn-toolbar {
3290 margin-left: -5px;
3291 }
3292 .btn-toolbar .btn-group,
3293 .btn-toolbar .input-group {
3294 float: left;
3295 }
3296 .btn-toolbar > .btn,
3297 .btn-toolbar > .btn-group,
3298 .btn-toolbar > .input-group {
3299 margin-left: 5px;
3300 }
3301 .btn-group > .btn:not(:first-child):not(:last-child):not(.dropdown-toggle) {
3302 border-radius: 0;
3303 }
3304 .btn-group > .btn:first-child {
3305 margin-left: 0;
3306 }
3307 .btn-group > .btn:first-child:not(:last-child):not(.dropdown-toggle) {
3308 border-top-right-radius: 0;
3309 border-bottom-right-radius: 0;
3310 }
3311 .btn-group > .btn:last-child:not(:first-child),
3312 .btn-group > .dropdown-toggle:not(:first-child) {
3313 border-top-left-radius: 0;
3314 border-bottom-left-radius: 0;
3315 }
3316 .btn-group > .btn-group {
3317 float: left;
3318 }
3319 .btn-group > .btn-group:not(:first-child):not(:last-child) > .btn {
3320 border-radius: 0;
3321 }
3322 .btn-group > .btn-group:first-child > .btn:last-child,
3323 .btn-group > .btn-group:first-child > .dropdown-toggle {
3324 border-top-right-radius: 0;
3325 border-bottom-right-radius: 0;
3326 }
3327 .btn-group > .btn-group:last-child > .btn:first-child {
3328 border-top-left-radius: 0;
3329 border-bottom-left-radius: 0;
3330 }
3331 .btn-group .dropdown-toggle:active,
3332 .btn-group.open .dropdown-toggle {
3333 outline: 0;
3334 }
3335 .btn-group > .btn + .dropdown-toggle {
3336 padding-right: 8px;
3337 padding-left: 8px;
3338 }
3339 .btn-group > .btn-lg + .dropdown-toggle {
3340 padding-right: 12px;
3341 padding-left: 12px;
3342 }
3343 .btn-group.open .dropdown-toggle {
3344 -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
3345 box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
3346 }
3347 .btn-group.open .dropdown-toggle.btn-link {
3348 -webkit-box-shadow: none;
3349 box-shadow: none;
3350 }
3351 .btn .caret {
3352 margin-left: 0;
3353 }
3354 .btn-lg .caret {
3355 border-width: 5px 5px 0;
3356 border-bottom-width: 0;
3357 }
3358 .dropup .btn-lg .caret {
3359 border-width: 0 5px 5px;
3360 }
3361 .btn-group-vertical > .btn,
3362 .btn-group-vertical > .btn-group,
3363 .btn-group-vertical > .btn-group > .btn {
3364 display: block;
3365 float: none;
3366 width: 100%;
3367 max-width: 100%;
3368 }
3369 .btn-group-vertical > .btn-group > .btn {
3370 float: none;
3371 }
3372 .btn-group-vertical > .btn + .btn,
3373 .btn-group-vertical > .btn + .btn-group,
3374 .btn-group-vertical > .btn-group + .btn,
3375 .btn-group-vertical > .btn-group + .btn-group {
3376 margin-top: -1px;
3377 margin-left: 0;
3378 }
3379 .btn-group-vertical > .btn:not(:first-child):not(:last-child) {
3380 border-radius: 0;
3381 }
3382 .btn-group-vertical > .btn:first-child:not(:last-child) {
3383 border-top-right-radius: 4px;
3384 border-bottom-right-radius: 0;
3385 border-bottom-left-radius: 0;
3386 }
3387 .btn-group-vertical > .btn:last-child:not(:first-child) {
3388 border-top-left-radius: 0;
3389 border-top-right-radius: 0;
3390 border-bottom-left-radius: 4px;
3391 }
3392 .btn-group-vertical > .btn-group:not(:first-child):not(:last-child) > .btn {
3393 border-radius: 0;
3394 }
3395 .btn-group-vertical > .btn-group:first-child:not(:last-child) > .btn:last-child,
3396 .btn-group-vertical > .btn-group:first-child:not(:last-child) > .dropdown-toggle {
3397 border-bottom-right-radius: 0;
3398 border-bottom-left-radius: 0;
3399 }
3400 .btn-group-vertical > .btn-group:last-child:not(:first-child) > .btn:first-child {
3401 border-top-left-radius: 0;
3402 border-top-right-radius: 0;
3403 }
3404 .btn-group-justified {
3405 display: table;
3406 width: 100%;
3407 table-layout: fixed;
3408 border-collapse: separate;
3409 }
3410 .btn-group-justified > .btn,
3411 .btn-group-justified > .btn-group {
3412 display: table-cell;
3413 float: none;
3414 width: 1%;
3415 }
3416 .btn-group-justified > .btn-group .btn {
3417 width: 100%;
3418 }
3419 .btn-group-justified > .btn-group .dropdown-menu {
3420 left: auto;
3421 }
3422 [data-toggle="buttons"] > .btn > input[type="radio"],
3423 [data-toggle="buttons"] > .btn > input[type="checkbox"] {
3424 position: absolute;
3425 z-index: -1;
3426 filter: alpha(opacity=0);
3427 opacity: 0;
3428 }
3429 .input-group {
3430 position: relative;
3431 display: table;
3432 border-collapse: separate;
3433 }
3434 .input-group[class*="col-"] {
3435 float: none;
3436 padding-right: 0;
3437 padding-left: 0;
3438 }
3439 .input-group .form-control {
3440 position: relative;
3441 z-index: 2;
3442 float: left;
3443 width: 100%;
3444 margin-bottom: 0;
3445 }
3446 .input-group-lg > .form-control,
3447 .input-group-lg > .input-group-addon,
3448 .input-group-lg > .input-group-btn > .btn {
3449 height: 46px;
3450 padding: 10px 16px;
3451 font-size: 18px;
3452 line-height: 1.33;
3453 border-radius: 6px;
3454 }
3455 select.input-group-lg > .form-control,
3456 select.input-group-lg > .input-group-addon,
3457 select.input-group-lg > .input-group-btn > .btn {
3458 height: 46px;
3459 line-height: 46px;
3460 }
3461 textarea.input-group-lg > .form-control,
3462 textarea.input-group-lg > .input-group-addon,
3463 textarea.input-group-lg > .input-group-btn > .btn,
3464 select[multiple].input-group-lg > .form-control,
3465 select[multiple].input-group-lg > .input-group-addon,
3466 select[multiple].input-group-lg > .input-group-btn > .btn {
3467 height: auto;
3468 }
3469 .input-group-sm > .form-control,
3470 .input-group-sm > .input-group-addon,
3471 .input-group-sm > .input-group-btn > .btn {
3472 height: 30px;
3473 padding: 5px 10px;
3474 font-size: 12px;
3475 line-height: 1.5;
3476 border-radius: 3px;
3477 }
3478 select.input-group-sm > .form-control,
3479 select.input-group-sm > .input-group-addon,
3480 select.input-group-sm > .input-group-btn > .btn {
3481 height: 30px;
3482 line-height: 30px;
3483 }
3484 textarea.input-group-sm > .form-control,
3485 textarea.input-group-sm > .input-group-addon,
3486 textarea.input-group-sm > .input-group-btn > .btn,
3487 select[multiple].input-group-sm > .form-control,
3488 select[multiple].input-group-sm > .input-group-addon,
3489 select[multiple].input-group-sm > .input-group-btn > .btn {
3490 height: auto;
3491 }
3492 .input-group-addon,
3493 .input-group-btn,
3494 .input-group .form-control {
3495 display: table-cell;
3496 }
3497 .input-group-addon:not(:first-child):not(:last-child),
3498 .input-group-btn:not(:first-child):not(:last-child),
3499 .input-group .form-control:not(:first-child):not(:last-child) {
3500 border-radius: 0;
3501 }
3502 .input-group-addon,
3503 .input-group-btn {
3504 width: 1%;
3505 white-space: nowrap;
3506 vertical-align: middle;
3507 }
3508 .input-group-addon {
3509 padding: 6px 12px;
3510 font-size: 14px;
3511 font-weight: normal;
3512 line-height: 1;
3513 color: #555;
3514 text-align: center;
3515 background-color: #eee;
3516 border: 1px solid #ccc;
3517 border-radius: 4px;
3518 }
3519 .input-group-addon.input-sm {
3520 padding: 5px 10px;
3521 font-size: 12px;
3522 border-radius: 3px;
3523 }
3524 .input-group-addon.input-lg {
3525 padding: 10px 16px;
3526 font-size: 18px;
3527 border-radius: 6px;
3528 }
3529 .input-group-addon input[type="radio"],
3530 .input-group-addon input[type="checkbox"] {
3531 margin-top: 0;
3532 }
3533 .input-group .form-control:first-child,
3534 .input-group-addon:first-child,
3535 .input-group-btn:first-child > .btn,
3536 .input-group-btn:first-child > .btn-group > .btn,
3537 .input-group-btn:first-child > .dropdown-toggle,
3538 .input-group-btn:last-child > .btn:not(:last-child):not(.dropdown-toggle),
3539 .input-group-btn:last-child > .btn-group:not(:last-child) > .btn {
3540 border-top-right-radius: 0;
3541 border-bottom-right-radius: 0;
3542 }
3543 .input-group-addon:first-child {
3544 border-right: 0;
3545 }
3546 .input-group .form-control:last-child,
3547 .input-group-addon:last-child,
3548 .input-group-btn:last-child > .btn,
3549 .input-group-btn:last-child > .btn-group > .btn,
3550 .input-group-btn:last-child > .dropdown-toggle,
3551 .input-group-btn:first-child > .btn:not(:first-child),
3552 .input-group-btn:first-child > .btn-group:not(:first-child) > .btn {
3553 border-top-left-radius: 0;
3554 border-bottom-left-radius: 0;
3555 }
3556 .input-group-addon:last-child {
3557 border-left: 0;
3558 }
3559 .input-group-btn {
3560 position: relative;
3561 font-size: 0;
3562 white-space: nowrap;
3563 }
3564 .input-group-btn > .btn {
3565 position: relative;
3566 }
3567 .input-group-btn > .btn + .btn {
3568 margin-left: -1px;
3569 }
3570 .input-group-btn > .btn:hover,
3571 .input-group-btn > .btn:focus,
3572 .input-group-btn > .btn:active {
3573 z-index: 2;
3574 }
3575 .input-group-btn:first-child > .btn,
3576 .input-group-btn:first-child > .btn-group {
3577 margin-right: -1px;
3578 }
3579 .input-group-btn:last-child > .btn,
3580 .input-group-btn:last-child > .btn-group {
3581 margin-left: -1px;
3582 }
3583 .nav {
3584 padding-left: 0;
3585 margin-bottom: 0;
3586 list-style: none;
3587 }
3588 .nav > li {
3589 position: relative;
3590 display: block;
3591 }
3592 .nav > li > a {
3593 position: relative;
3594 display: block;
3595 padding: 10px 15px;
3596 }
3597 .nav > li > a:hover,
3598 .nav > li > a:focus {
3599 text-decoration: none;
3600 background-color: #eee;
3601 }
3602 .nav > li.disabled > a {
3603 color: #777;
3604 }
3605 .nav > li.disabled > a:hover,
3606 .nav > li.disabled > a:focus {
3607 color: #777;
3608 text-decoration: none;
3609 cursor: not-allowed;
3610 background-color: transparent;
3611 }
3612 .nav .open > a,
3613 .nav .open > a:hover,
3614 .nav .open > a:focus {
3615 background-color: #eee;
3616 border-color: #428bca;
3617 }
3618 .nav .nav-divider {
3619 height: 1px;
3620 margin: 9px 0;
3621 overflow: hidden;
3622 background-color: #e5e5e5;
3623 }
3624 .nav > li > a > img {
3625 max-width: none;
3626 }
3627 .nav-tabs {
3628 border-bottom: 1px solid #ddd;
3629 }
3630 .nav-tabs > li {
3631 float: left;
3632 margin-bottom: -1px;
3633 }
3634 .nav-tabs > li > a {
3635 margin-right: 2px;
3636 line-height: 1.42857143;
3637 border: 1px solid transparent;
3638 border-radius: 4px 4px 0 0;
3639 }
3640 .nav-tabs > li > a:hover {
3641 border-color: #eee #eee #ddd;
3642 }
3643 .nav-tabs > li.active > a,
3644 .nav-tabs > li.active > a:hover,
3645 .nav-tabs > li.active > a:focus {
3646 color: #555;
3647 cursor: default;
3648 background-color: #fff;
3649 border: 1px solid #ddd;
3650 border-bottom-color: transparent;
3651 }
3652 .nav-tabs.nav-justified {
3653 width: 100%;
3654 border-bottom: 0;
3655 }
3656 .nav-tabs.nav-justified > li {
3657 float: none;
3658 }
3659 .nav-tabs.nav-justified > li > a {
3660 margin-bottom: 5px;
3661 text-align: center;
3662 }
3663 .nav-tabs.nav-justified > .dropdown .dropdown-menu {
3664 top: auto;
3665 left: auto;
3666 }
3667 @media (min-width: 768px) {
3668 .nav-tabs.nav-justified > li {
3669 display: table-cell;
3670 width: 1%;
3671 }
3672 .nav-tabs.nav-justified > li > a {
3673 margin-bottom: 0;
3674 }
3675 }
3676 .nav-tabs.nav-justified > li > a {
3677 margin-right: 0;
3678 border-radius: 4px;
3679 }
3680 .nav-tabs.nav-justified > .active > a,
3681 .nav-tabs.nav-justified > .active > a:hover,
3682 .nav-tabs.nav-justified > .active > a:focus {
3683 border: 1px solid #ddd;
3684 }
3685 @media (min-width: 768px) {
3686 .nav-tabs.nav-justified > li > a {
3687 border-bottom: 1px solid #ddd;
3688 border-radius: 4px 4px 0 0;
3689 }
3690 .nav-tabs.nav-justified > .active > a,
3691 .nav-tabs.nav-justified > .active > a:hover,
3692 .nav-tabs.nav-justified > .active > a:focus {
3693 border-bottom-color: #fff;
3694 }
3695 }
3696 .nav-pills > li {
3697 float: left;
3698 }
3699 .nav-pills > li > a {
3700 border-radius: 4px;
3701 }
3702 .nav-pills > li + li {
3703 margin-left: 2px;
3704 }
3705 .nav-pills > li.active > a,
3706 .nav-pills > li.active > a:hover,
3707 .nav-pills > li.active > a:focus {
3708 color: #fff;
3709 background-color: #428bca;
3710 }
3711 .nav-stacked > li {
3712 float: none;
3713 }
3714 .nav-stacked > li + li {
3715 margin-top: 2px;
3716 margin-left: 0;
3717 }
3718 .nav-justified {
3719 width: 100%;
3720 }
3721 .nav-justified > li {
3722 float: none;
3723 }
3724 .nav-justified > li > a {
3725 margin-bottom: 5px;
3726 text-align: center;
3727 }
3728 .nav-justified > .dropdown .dropdown-menu {
3729 top: auto;
3730 left: auto;
3731 }
3732 @media (min-width: 768px) {
3733 .nav-justified > li {
3734 display: table-cell;
3735 width: 1%;
3736 }
3737 .nav-justified > li > a {
3738 margin-bottom: 0;
3739 }
3740 }
3741 .nav-tabs-justified {
3742 border-bottom: 0;
3743 }
3744 .nav-tabs-justified > li > a {
3745 margin-right: 0;
3746 border-radius: 4px;
3747 }
3748 .nav-tabs-justified > .active > a,
3749 .nav-tabs-justified > .active > a:hover,
3750 .nav-tabs-justified > .active > a:focus {
3751 border: 1px solid #ddd;
3752 }
3753 @media (min-width: 768px) {
3754 .nav-tabs-justified > li > a {
3755 border-bottom: 1px solid #ddd;
3756 border-radius: 4px 4px 0 0;
3757 }
3758 .nav-tabs-justified > .active > a,
3759 .nav-tabs-justified > .active > a:hover,
3760 .nav-tabs-justified > .active > a:focus {
3761 border-bottom-color: #fff;
3762 }
3763 }
3764 .tab-content > .tab-pane {
3765 display: none;
3766 }
3767 .tab-content > .active {
3768 display: block;
3769 }
3770 .nav-tabs .dropdown-menu {
3771 margin-top: -1px;
3772 border-top-left-radius: 0;
3773 border-top-right-radius: 0;
3774 }
3775 .navbar {
3776 position: relative;
3777 min-height: 50px;
3778 margin-bottom: 20px;
3779 border: 1px solid transparent;
3780 }
3781 @media (min-width: 768px) {
3782 .navbar {
3783 border-radius: 4px;
3784 }
3785 }
3786 @media (min-width: 768px) {
3787 .navbar-header {
3788 float: left;
3789 }
3790 }
3791 .navbar-collapse {
3792 padding-right: 15px;
3793 padding-left: 15px;
3794 overflow-x: visible;
3795 -webkit-overflow-scrolling: touch;
3796 border-top: 1px solid transparent;
3797 -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1);
3798 box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1);
3799 }
3800 .navbar-collapse.in {
3801 overflow-y: auto;
3802 }
3803 @media (min-width: 768px) {
3804 .navbar-collapse {
3805 width: auto;
3806 border-top: 0;
3807 -webkit-box-shadow: none;
3808 box-shadow: none;
3809 }
3810 .navbar-collapse.collapse {
3811 display: block !important;
3812 height: auto !important;
3813 padding-bottom: 0;
3814 overflow: visible !important;
3815 }
3816 .navbar-collapse.in {
3817 overflow-y: visible;
3818 }
3819 .navbar-fixed-top .navbar-collapse,
3820 .navbar-static-top .navbar-collapse,
3821 .navbar-fixed-bottom .navbar-collapse {
3822 padding-right: 0;
3823 padding-left: 0;
3824 }
3825 }
3826 .navbar-fixed-top .navbar-collapse,
3827 .navbar-fixed-bottom .navbar-collapse {
3828 max-height: 340px;
3829 }
3830 @media (max-width: 480px) and (orientation: landscape) {
3831 .navbar-fixed-top .navbar-collapse,
3832 .navbar-fixed-bottom .navbar-collapse {
3833 max-height: 200px;
3834 }
3835 }
3836 .container > .navbar-header,
3837 .container-fluid > .navbar-header,
3838 .container > .navbar-collapse,
3839 .container-fluid > .navbar-collapse {
3840 margin-right: -15px;
3841 margin-left: -15px;
3842 }
3843 @media (min-width: 768px) {
3844 .container > .navbar-header,
3845 .container-fluid > .navbar-header,
3846 .container > .navbar-collapse,
3847 .container-fluid > .navbar-collapse {
3848 margin-right: 0;
3849 margin-left: 0;
3850 }
3851 }
3852 .navbar-static-top {
3853 z-index: 1000;
3854 border-width: 0 0 1px;
3855 }
3856 @media (min-width: 768px) {
3857 .navbar-static-top {
3858 border-radius: 0;
3859 }
3860 }
3861 .navbar-fixed-top,
3862 .navbar-fixed-bottom {
3863 position: fixed;
3864 right: 0;
3865 left: 0;
3866 z-index: 1030;
3867 -webkit-transform: translate3d(0, 0, 0);
3868 -o-transform: translate3d(0, 0, 0);
3869 transform: translate3d(0, 0, 0);
3870 }
3871 @media (min-width: 768px) {
3872 .navbar-fixed-top,
3873 .navbar-fixed-bottom {
3874 border-radius: 0;
3875 }
3876 }
3877 .navbar-fixed-top {
3878 top: 0;
3879 border-width: 0 0 1px;
3880 }
3881 .navbar-fixed-bottom {
3882 bottom: 0;
3883 margin-bottom: 0;
3884 border-width: 1px 0 0;
3885 }
3886 .navbar-brand {
3887 float: left;
3888 height: 50px;
3889 padding: 15px 15px;
3890 font-size: 18px;
3891 line-height: 20px;
3892 }
3893 .navbar-brand:hover,
3894 .navbar-brand:focus {
3895 text-decoration: none;
3896 }
3897 @media (min-width: 768px) {
3898 .navbar > .container .navbar-brand,
3899 .navbar > .container-fluid .navbar-brand {
3900 margin-left: -15px;
3901 }
3902 }
3903 .navbar-toggle {
3904 position: relative;
3905 float: right;
3906 padding: 9px 10px;
3907 margin-top: 8px;
3908 margin-right: 15px;
3909 margin-bottom: 8px;
3910 background-color: transparent;
3911 background-image: none;
3912 border: 1px solid transparent;
3913 border-radius: 4px;
3914 }
3915 .navbar-toggle:focus {
3916 outline: 0;
3917 }
3918 .navbar-toggle .icon-bar {
3919 display: block;
3920 width: 22px;
3921 height: 2px;
3922 border-radius: 1px;
3923 }
3924 .navbar-toggle .icon-bar + .icon-bar {
3925 margin-top: 4px;
3926 }
3927 @media (min-width: 768px) {
3928 .navbar-toggle {
3929 display: none;
3930 }
3931 }
3932 .navbar-nav {
3933 margin: 7.5px -15px;
3934 }
3935 .navbar-nav > li > a {
3936 padding-top: 10px;
3937 padding-bottom: 10px;
3938 line-height: 20px;
3939 }
3940 @media (max-width: 767px) {
3941 .navbar-nav .open .dropdown-menu {
3942 position: static;
3943 float: none;
3944 width: auto;
3945 margin-top: 0;
3946 background-color: transparent;
3947 border: 0;
3948 -webkit-box-shadow: none;
3949 box-shadow: none;
3950 }
3951 .navbar-nav .open .dropdown-menu > li > a,
3952 .navbar-nav .open .dropdown-menu .dropdown-header {
3953 padding: 5px 15px 5px 25px;
3954 }
3955 .navbar-nav .open .dropdown-menu > li > a {
3956 line-height: 20px;
3957 }
3958 .navbar-nav .open .dropdown-menu > li > a:hover,
3959 .navbar-nav .open .dropdown-menu > li > a:focus {
3960 background-image: none;
3961 }
3962 }
3963 @media (min-width: 768px) {
3964 .navbar-nav {
3965 float: left;
3966 margin: 0;
3967 }
3968 .navbar-nav > li {
3969 float: left;
3970 }
3971 .navbar-nav > li > a {
3972 padding-top: 15px;
3973 padding-bottom: 15px;
3974 }
3975 .navbar-nav.navbar-right:last-child {
3976 margin-right: -15px;
3977 }
3978 }
3979 @media (min-width: 768px) {
3980 .navbar-left {
3981 float: left !important;
3982 }
3983 .navbar-right {
3984 float: right !important;
3985 }
3986 }
3987 .navbar-form {
3988 padding: 10px 15px;
3989 margin-top: 8px;
3990 margin-right: -15px;
3991 margin-bottom: 8px;
3992 margin-left: -15px;
3993 border-top: 1px solid transparent;
3994 border-bottom: 1px solid transparent;
3995 -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 1px 0 rgba(255, 255, 255, .1);
3996 box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 1px 0 rgba(255, 255, 255, .1);
3997 }
3998 @media (min-width: 768px) {
3999 .navbar-form .form-group {
4000 display: inline-block;
4001 margin-bottom: 0;
4002 vertical-align: middle;
4003 }
4004 .navbar-form .form-control {
4005 display: inline-block;
4006 width: auto;
4007 vertical-align: middle;
4008 }
4009 .navbar-form .input-group {
4010 display: inline-table;
4011 vertical-align: middle;
4012 }
4013 .navbar-form .input-group .input-group-addon,
4014 .navbar-form .input-group .input-group-btn,
4015 .navbar-form .input-group .form-control {
4016 width: auto;
4017 }
4018 .navbar-form .input-group > .form-control {
4019 width: 100%;
4020 }
4021 .navbar-form .control-label {
4022 margin-bottom: 0;
4023 vertical-align: middle;
4024 }
4025 .navbar-form .radio,
4026 .navbar-form .checkbox {
4027 display: inline-block;
4028 margin-top: 0;
4029 margin-bottom: 0;
4030 vertical-align: middle;
4031 }
4032 .navbar-form .radio label,
4033 .navbar-form .checkbox label {
4034 padding-left: 0;
4035 }
4036 .navbar-form .radio input[type="radio"],
4037 .navbar-form .checkbox input[type="checkbox"] {
4038 position: relative;
4039 margin-left: 0;
4040 }
4041 .navbar-form .has-feedback .form-control-feedback {
4042 top: 0;
4043 }
4044 }
4045 @media (max-width: 767px) {
4046 .navbar-form .form-group {
4047 margin-bottom: 5px;
4048 }
4049 }
4050 @media (min-width: 768px) {
4051 .navbar-form {
4052 width: auto;
4053 padding-top: 0;
4054 padding-bottom: 0;
4055 margin-right: 0;
4056 margin-left: 0;
4057 border: 0;
4058 -webkit-box-shadow: none;
4059 box-shadow: none;
4060 }
4061 .navbar-form.navbar-right:last-child {
4062 margin-right: -15px;
4063 }
4064 }
4065 .navbar-nav > li > .dropdown-menu {
4066 margin-top: 0;
4067 border-top-left-radius: 0;
4068 border-top-right-radius: 0;
4069 }
4070 .navbar-fixed-bottom .navbar-nav > li > .dropdown-menu {
4071 border-bottom-right-radius: 0;
4072 border-bottom-left-radius: 0;
4073 }
4074 .navbar-btn {
4075 margin-top: 8px;
4076 margin-bottom: 8px;
4077 }
4078 .navbar-btn.btn-sm {
4079 margin-top: 10px;
4080 margin-bottom: 10px;
4081 }
4082 .navbar-btn.btn-xs {
4083 margin-top: 14px;
4084 margin-bottom: 14px;
4085 }
4086 .navbar-text {
4087 margin-top: 15px;
4088 margin-bottom: 15px;
4089 }
4090 @media (min-width: 768px) {
4091 .navbar-text {
4092 float: left;
4093 margin-right: 15px;
4094 margin-left: 15px;
4095 }
4096 .navbar-text.navbar-right:last-child {
4097 margin-right: 0;
4098 }
4099 }
4100 .navbar-default {
4101 background-color: #f8f8f8;
4102 border-color: #e7e7e7;
4103 }
4104 .navbar-default .navbar-brand {
4105 color: #777;
4106 }
4107 .navbar-default .navbar-brand:hover,
4108 .navbar-default .navbar-brand:focus {
4109 color: #5e5e5e;
4110 background-color: transparent;
4111 }
4112 .navbar-default .navbar-text {
4113 color: #777;
4114 }
4115 .navbar-default .navbar-nav > li > a {
4116 color: #777;
4117 }
4118 .navbar-default .navbar-nav > li > a:hover,
4119 .navbar-default .navbar-nav > li > a:focus {
4120 color: #333;
4121 background-color: transparent;
4122 }
4123 .navbar-default .navbar-nav > .active > a,
4124 .navbar-default .navbar-nav > .active > a:hover,
4125 .navbar-default .navbar-nav > .active > a:focus {
4126 color: #555;
4127 background-color: #e7e7e7;
4128 }
4129 .navbar-default .navbar-nav > .disabled > a,
4130 .navbar-default .navbar-nav > .disabled > a:hover,
4131 .navbar-default .navbar-nav > .disabled > a:focus {
4132 color: #ccc;
4133 background-color: transparent;
4134 }
4135 .navbar-default .navbar-toggle {
4136 border-color: #ddd;
4137 }
4138 .navbar-default .navbar-toggle:hover,
4139 .navbar-default .navbar-toggle:focus {
4140 background-color: #ddd;
4141 }
4142 .navbar-default .navbar-toggle .icon-bar {
4143 background-color: #888;
4144 }
4145 .navbar-default .navbar-collapse,
4146 .navbar-default .navbar-form {
4147 border-color: #e7e7e7;
4148 }
4149 .navbar-default .navbar-nav > .open > a,
4150 .navbar-default .navbar-nav > .open > a:hover,
4151 .navbar-default .navbar-nav > .open > a:focus {
4152 color: #555;
4153 background-color: #e7e7e7;
4154 }
4155 @media (max-width: 767px) {
4156 .navbar-default .navbar-nav .open .dropdown-menu > li > a {
4157 color: #777;
4158 }
4159 .navbar-default .navbar-nav .open .dropdown-menu > li > a:hover,
4160 .navbar-default .navbar-nav .open .dropdown-menu > li > a:focus {
4161 color: #333;
4162 background-color: transparent;
4163 }
4164 .navbar-default .navbar-nav .open .dropdown-menu > .active > a,
4165 .navbar-default .navbar-nav .open .dropdown-menu > .active > a:hover,
4166 .navbar-default .navbar-nav .open .dropdown-menu > .active > a:focus {
4167 color: #555;
4168 background-color: #e7e7e7;
4169 }
4170 .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a,
4171 .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:hover,
4172 .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:focus {
4173 color: #ccc;
4174 background-color: transparent;
4175 }
4176 }
4177 .navbar-default .navbar-link {
4178 color: #777;
4179 }
4180 .navbar-default .navbar-link:hover {
4181 color: #333;
4182 }
4183 .navbar-default .btn-link {
4184 color: #777;
4185 }
4186 .navbar-default .btn-link:hover,
4187 .navbar-default .btn-link:focus {
4188 color: #333;
4189 }
4190 .navbar-default .btn-link[disabled]:hover,
4191 fieldset[disabled] .navbar-default .btn-link:hover,
4192 .navbar-default .btn-link[disabled]:focus,
4193 fieldset[disabled] .navbar-default .btn-link:focus {
4194 color: #ccc;
4195 }
4196 .navbar-inverse {
4197 background-color: #222;
4198 border-color: #080808;
4199 }
4200 .navbar-inverse .navbar-brand {
4201 color: #777;
4202 }
4203 .navbar-inverse .navbar-brand:hover,
4204 .navbar-inverse .navbar-brand:focus {
4205 color: #fff;
4206 background-color: transparent;
4207 }
4208 .navbar-inverse .navbar-text {
4209 color: #777;
4210 }
4211 .navbar-inverse .navbar-nav > li > a {
4212 color: #777;
4213 }
4214 .navbar-inverse .navbar-nav > li > a:hover,
4215 .navbar-inverse .navbar-nav > li > a:focus {
4216 color: #fff;
4217 background-color: transparent;
4218 }
4219 .navbar-inverse .navbar-nav > .active > a,
4220 .navbar-inverse .navbar-nav > .active > a:hover,
4221 .navbar-inverse .navbar-nav > .active > a:focus {
4222 color: #fff;
4223 background-color: #080808;
4224 }
4225 .navbar-inverse .navbar-nav > .disabled > a,
4226 .navbar-inverse .navbar-nav > .disabled > a:hover,
4227 .navbar-inverse .navbar-nav > .disabled > a:focus {
4228 color: #444;
4229 background-color: transparent;
4230 }
4231 .navbar-inverse .navbar-toggle {
4232 border-color: #333;
4233 }
4234 .navbar-inverse .navbar-toggle:hover,
4235 .navbar-inverse .navbar-toggle:focus {
4236 background-color: #333;
4237 }
4238 .navbar-inverse .navbar-toggle .icon-bar {
4239 background-color: #fff;
4240 }
4241 .navbar-inverse .navbar-collapse,
4242 .navbar-inverse .navbar-form {
4243 border-color: #101010;
4244 }
4245 .navbar-inverse .navbar-nav > .open > a,
4246 .navbar-inverse .navbar-nav > .open > a:hover,
4247 .navbar-inverse .navbar-nav > .open > a:focus {
4248 color: #fff;
4249 background-color: #080808;
4250 }
4251 @media (max-width: 767px) {
4252 .navbar-inverse .navbar-nav .open .dropdown-menu > .dropdown-header {
4253 border-color: #080808;
4254 }
4255 .navbar-inverse .navbar-nav .open .dropdown-menu .divider {
4256 background-color: #080808;
4257 }
4258 .navbar-inverse .navbar-nav .open .dropdown-menu > li > a {
4259 color: #777;
4260 }
4261 .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:hover,
4262 .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:focus {
4263 color: #fff;
4264 background-color: transparent;
4265 }
4266 .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a,
4267 .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:hover,
4268 .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:focus {
4269 color: #fff;
4270 background-color: #080808;
4271 }
4272 .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a,
4273 .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:hover,
4274 .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:focus {
4275 color: #444;
4276 background-color: transparent;
4277 }
4278 }
4279 .navbar-inverse .navbar-link {
4280 color: #777;
4281 }
4282 .navbar-inverse .navbar-link:hover {
4283 color: #fff;
4284 }
4285 .navbar-inverse .btn-link {
4286 color: #777;
4287 }
4288 .navbar-inverse .btn-link:hover,
4289 .navbar-inverse .btn-link:focus {
4290 color: #fff;
4291 }
4292 .navbar-inverse .btn-link[disabled]:hover,
4293 fieldset[disabled] .navbar-inverse .btn-link:hover,
4294 .navbar-inverse .btn-link[disabled]:focus,
4295 fieldset[disabled] .navbar-inverse .btn-link:focus {
4296 color: #444;
4297 }
4298 .breadcrumb {
4299 padding: 8px 15px;
4300 margin-bottom: 20px;
4301 list-style: none;
4302 background-color: #f5f5f5;
4303 border-radius: 4px;
4304 }
4305 .breadcrumb > li {
4306 display: inline-block;
4307 }
4308 .breadcrumb > li + li:before {
4309 padding: 0 5px;
4310 color: #ccc;
4311 content: "/\00a0";
4312 }
4313 .breadcrumb > .active {
4314 color: #777;
4315 }
4316 .pagination {
4317 display: inline-block;
4318 padding-left: 0;
4319 margin: 20px 0;
4320 border-radius: 4px;
4321 }
4322 .pagination > li {
4323 display: inline;
4324 }
4325 .pagination > li > a,
4326 .pagination > li > span {
4327 position: relative;
4328 float: left;
4329 padding: 6px 12px;
4330 margin-left: -1px;
4331 line-height: 1.42857143;
4332 color: #428bca;
4333 text-decoration: none;
4334 background-color: #fff;
4335 border: 1px solid #ddd;
4336 }
4337 .pagination > li:first-child > a,
4338 .pagination > li:first-child > span {
4339 margin-left: 0;
4340 border-top-left-radius: 4px;
4341 border-bottom-left-radius: 4px;
4342 }
4343 .pagination > li:last-child > a,
4344 .pagination > li:last-child > span {
4345 border-top-right-radius: 4px;
4346 border-bottom-right-radius: 4px;
4347 }
4348 .pagination > li > a:hover,
4349 .pagination > li > span:hover,
4350 .pagination > li > a:focus,
4351 .pagination > li > span:focus {
4352 color: #2a6496;
4353 background-color: #eee;
4354 border-color: #ddd;
4355 }
4356 .pagination > .active > a,
4357 .pagination > .active > span,
4358 .pagination > .active > a:hover,
4359 .pagination > .active > span:hover,
4360 .pagination > .active > a:focus,
4361 .pagination > .active > span:focus {
4362 z-index: 2;
4363 color: #fff;
4364 cursor: default;
4365 background-color: #428bca;
4366 border-color: #428bca;
4367 }
4368 .pagination > .disabled > span,
4369 .pagination > .disabled > span:hover,
4370 .pagination > .disabled > span:focus,
4371 .pagination > .disabled > a,
4372 .pagination > .disabled > a:hover,
4373 .pagination > .disabled > a:focus {
4374 color: #777;
4375 cursor: not-allowed;
4376 background-color: #fff;
4377 border-color: #ddd;
4378 }
4379 .pagination-lg > li > a,
4380 .pagination-lg > li > span {
4381 padding: 10px 16px;
4382 font-size: 18px;
4383 }
4384 .pagination-lg > li:first-child > a,
4385 .pagination-lg > li:first-child > span {
4386 border-top-left-radius: 6px;
4387 border-bottom-left-radius: 6px;
4388 }
4389 .pagination-lg > li:last-child > a,
4390 .pagination-lg > li:last-child > span {
4391 border-top-right-radius: 6px;
4392 border-bottom-right-radius: 6px;
4393 }
4394 .pagination-sm > li > a,
4395 .pagination-sm > li > span {
4396 padding: 5px 10px;
4397 font-size: 12px;
4398 }
4399 .pagination-sm > li:first-child > a,
4400 .pagination-sm > li:first-child > span {
4401 border-top-left-radius: 3px;
4402 border-bottom-left-radius: 3px;
4403 }
4404 .pagination-sm > li:last-child > a,
4405 .pagination-sm > li:last-child > span {
4406 border-top-right-radius: 3px;
4407 border-bottom-right-radius: 3px;
4408 }
4409 .pager {
4410 padding-left: 0;
4411 margin: 20px 0;
4412 text-align: center;
4413 list-style: none;
4414 }
4415 .pager li {
4416 display: inline;
4417 }
4418 .pager li > a,
4419 .pager li > span {
4420 display: inline-block;
4421 padding: 5px 14px;
4422 background-color: #fff;
4423 border: 1px solid #ddd;
4424 border-radius: 15px;
4425 }
4426 .pager li > a:hover,
4427 .pager li > a:focus {
4428 text-decoration: none;
4429 background-color: #eee;
4430 }
4431 .pager .next > a,
4432 .pager .next > span {
4433 float: right;
4434 }
4435 .pager .previous > a,
4436 .pager .previous > span {
4437 float: left;
4438 }
4439 .pager .disabled > a,
4440 .pager .disabled > a:hover,
4441 .pager .disabled > a:focus,
4442 .pager .disabled > span {
4443 color: #777;
4444 cursor: not-allowed;
4445 background-color: #fff;
4446 }
4447 .label {
4448 display: inline;
4449 padding: .2em .6em .3em;
4450 font-size: 75%;
4451 font-weight: bold;
4452 line-height: 1;
4453 color: #fff;
4454 text-align: center;
4455 white-space: nowrap;
4456 vertical-align: baseline;
4457 border-radius: .25em;
4458 }
4459 a.label:hover,
4460 a.label:focus {
4461 color: #fff;
4462 text-decoration: none;
4463 cursor: pointer;
4464 }
4465 .label:empty {
4466 display: none;
4467 }
4468 .btn .label {
4469 position: relative;
4470 top: -1px;
4471 }
4472 .label-default {
4473 background-color: #777;
4474 }
4475 .label-default[href]:hover,
4476 .label-default[href]:focus {
4477 background-color: #5e5e5e;
4478 }
4479 .label-primary {
4480 background-color: #428bca;
4481 }
4482 .label-primary[href]:hover,
4483 .label-primary[href]:focus {
4484 background-color: #3071a9;
4485 }
4486 .label-success {
4487 background-color: #5cb85c;
4488 }
4489 .label-success[href]:hover,
4490 .label-success[href]:focus {
4491 background-color: #449d44;
4492 }
4493 .label-info {
4494 background-color: #5bc0de;
4495 }
4496 .label-info[href]:hover,
4497 .label-info[href]:focus {
4498 background-color: #31b0d5;
4499 }
4500 .label-warning {
4501 background-color: #f0ad4e;
4502 }
4503 .label-warning[href]:hover,
4504 .label-warning[href]:focus {
4505 background-color: #ec971f;
4506 }
4507 .label-danger {
4508 background-color: #d9534f;
4509 }
4510 .label-danger[href]:hover,
4511 .label-danger[href]:focus {
4512 background-color: #c9302c;
4513 }
4514 .badge {
4515 display: inline-block;
4516 min-width: 10px;
4517 padding: 3px 7px;
4518 font-size: 12px;
4519 font-weight: bold;
4520 line-height: 1;
4521 color: #fff;
4522 text-align: center;
4523 white-space: nowrap;
4524 vertical-align: baseline;
4525 background-color: #777;
4526 border-radius: 10px;
4527 }
4528 .badge:empty {
4529 display: none;
4530 }
4531 .btn .badge {
4532 position: relative;
4533 top: -1px;
4534 }
4535 .btn-xs .badge {
4536 top: 0;
4537 padding: 1px 5px;
4538 }
4539 a.badge:hover,
4540 a.badge:focus {
4541 color: #fff;
4542 text-decoration: none;
4543 cursor: pointer;
4544 }
4545 a.list-group-item.active > .badge,
4546 .nav-pills > .active > a > .badge {
4547 color: #428bca;
4548 background-color: #fff;
4549 }
4550 .nav-pills > li > a > .badge {
4551 margin-left: 3px;
4552 }
4553 .jumbotron {
4554 padding: 30px;
4555 margin-bottom: 30px;
4556 color: inherit;
4557 background-color: #eee;
4558 }
4559 .jumbotron h1,
4560 .jumbotron .h1 {
4561 color: inherit;
4562 }
4563 .jumbotron p {
4564 margin-bottom: 15px;
4565 font-size: 21px;
4566 font-weight: 200;
4567 }
4568 .jumbotron > hr {
4569 border-top-color: #d5d5d5;
4570 }
4571 .container .jumbotron {
4572 border-radius: 6px;
4573 }
4574 .jumbotron .container {
4575 max-width: 100%;
4576 }
4577 @media screen and (min-width: 768px) {
4578 .jumbotron {
4579 padding-top: 48px;
4580 padding-bottom: 48px;
4581 }
4582 .container .jumbotron {
4583 padding-right: 60px;
4584 padding-left: 60px;
4585 }
4586 .jumbotron h1,
4587 .jumbotron .h1 {
4588 font-size: 63px;
4589 }
4590 }
4591 .thumbnail {
4592 display: block;
4593 padding: 4px;
4594 margin-bottom: 20px;
4595 line-height: 1.42857143;
4596 background-color: #fff;
4597 border: 1px solid #ddd;
4598 border-radius: 4px;
4599 -webkit-transition: all .2s ease-in-out;
4600 -o-transition: all .2s ease-in-out;
4601 transition: all .2s ease-in-out;
4602 }
4603 .thumbnail > img,
4604 .thumbnail a > img {
4605 margin-right: auto;
4606 margin-left: auto;
4607 }
4608 a.thumbnail:hover,
4609 a.thumbnail:focus,
4610 a.thumbnail.active {
4611 border-color: #428bca;
4612 }
4613 .thumbnail .caption {
4614 padding: 9px;
4615 color: #333;
4616 }
4617 .alert {
4618 padding: 15px;
4619 margin-bottom: 20px;
4620 border: 1px solid transparent;
4621 border-radius: 4px;
4622 }
4623 .alert h4 {
4624 margin-top: 0;
4625 color: inherit;
4626 }
4627 .alert .alert-link {
4628 font-weight: bold;
4629 }
4630 .alert > p,
4631 .alert > ul {
4632 margin-bottom: 0;
4633 }
4634 .alert > p + p {
4635 margin-top: 5px;
4636 }
4637 .alert-dismissable,
4638 .alert-dismissible {
4639 padding-right: 35px;
4640 }
4641 .alert-dismissable .close,
4642 .alert-dismissible .close {
4643 position: relative;
4644 top: -2px;
4645 right: -21px;
4646 color: inherit;
4647 }
4648 .alert-success {
4649 color: #3c763d;
4650 background-color: #dff0d8;
4651 border-color: #d6e9c6;
4652 }
4653 .alert-success hr {
4654 border-top-color: #c9e2b3;
4655 }
4656 .alert-success .alert-link {
4657 color: #2b542c;
4658 }
4659 .alert-info {
4660 color: #31708f;
4661 background-color: #d9edf7;
4662 border-color: #bce8f1;
4663 }
4664 .alert-info hr {
4665 border-top-color: #a6e1ec;
4666 }
4667 .alert-info .alert-link {
4668 color: #245269;
4669 }
4670 .alert-warning {
4671 color: #8a6d3b;
4672 background-color: #fcf8e3;
4673 border-color: #faebcc;
4674 }
4675 .alert-warning hr {
4676 border-top-color: #f7e1b5;
4677 }
4678 .alert-warning .alert-link {
4679 color: #66512c;
4680 }
4681 .alert-danger {
4682 color: #a94442;
4683 background-color: #f2dede;
4684 border-color: #ebccd1;
4685 }
4686 .alert-danger hr {
4687 border-top-color: #e4b9c0;
4688 }
4689 .alert-danger .alert-link {
4690 color: #843534;
4691 }
4692 @-webkit-keyframes progress-bar-stripes {
4693 from {
4694 background-position: 40px 0;
4695 }
4696 to {
4697 background-position: 0 0;
4698 }
4699 }
4700 @-o-keyframes progress-bar-stripes {
4701 from {
4702 background-position: 40px 0;
4703 }
4704 to {
4705 background-position: 0 0;
4706 }
4707 }
4708 @keyframes progress-bar-stripes {
4709 from {
4710 background-position: 40px 0;
4711 }
4712 to {
4713 background-position: 0 0;
4714 }
4715 }
4716 .progress {
4717 height: 20px;
4718 margin-bottom: 20px;
4719 overflow: hidden;
4720 background-color: #f5f5f5;
4721 border-radius: 4px;
4722 -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1);
4723 box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1);
4724 }
4725 .progress-bar {
4726 float: left;
4727 width: 0;
4728 height: 100%;
4729 font-size: 12px;
4730 line-height: 20px;
4731 color: #fff;
4732 text-align: center;
4733 background-color: #428bca;
4734 -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15);
4735 box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .15);
4736 -webkit-transition: width .6s ease;
4737 -o-transition: width .6s ease;
4738 transition: width .6s ease;
4739 }
4740 .progress-striped .progress-bar,
4741 .progress-bar-striped {
4742 background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4743 background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4744 background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4745 -webkit-background-size: 40px 40px;
4746 background-size: 40px 40px;
4747 }
4748 .progress.active .progress-bar,
4749 .progress-bar.active {
4750 -webkit-animation: progress-bar-stripes 2s linear infinite;
4751 -o-animation: progress-bar-stripes 2s linear infinite;
4752 animation: progress-bar-stripes 2s linear infinite;
4753 }
4754 .progress-bar[aria-valuenow="1"],
4755 .progress-bar[aria-valuenow="2"] {
4756 min-width: 30px;
4757 }
4758 .progress-bar[aria-valuenow="0"] {
4759 min-width: 30px;
4760 color: #777;
4761 background-color: transparent;
4762 background-image: none;
4763 -webkit-box-shadow: none;
4764 box-shadow: none;
4765 }
4766 .progress-bar-success {
4767 background-color: #5cb85c;
4768 }
4769 .progress-striped .progress-bar-success {
4770 background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4771 background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4772 background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4773 }
4774 .progress-bar-info {
4775 background-color: #5bc0de;
4776 }
4777 .progress-striped .progress-bar-info {
4778 background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4779 background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4780 background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4781 }
4782 .progress-bar-warning {
4783 background-color: #f0ad4e;
4784 }
4785 .progress-striped .progress-bar-warning {
4786 background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4787 background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4788 background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4789 }
4790 .progress-bar-danger {
4791 background-color: #d9534f;
4792 }
4793 .progress-striped .progress-bar-danger {
4794 background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4795 background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4796 background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
4797 }
4798 .media,
4799 .media-body {
4800 overflow: hidden;
4801 zoom: 1;
4802 }
4803 .media,
4804 .media .media {
4805 margin-top: 15px;
4806 }
4807 .media:first-child {
4808 margin-top: 0;
4809 }
4810 .media-object {
4811 display: block;
4812 }
4813 .media-heading {
4814 margin: 0 0 5px;
4815 }
4816 .media > .pull-left {
4817 margin-right: 10px;
4818 }
4819 .media > .pull-right {
4820 margin-left: 10px;
4821 }
4822 .media-list {
4823 padding-left: 0;
4824 list-style: none;
4825 }
4826 .list-group {
4827 padding-left: 0;
4828 margin-bottom: 20px;
4829 }
4830 .list-group-item {
4831 position: relative;
4832 display: block;
4833 padding: 10px 15px;
4834 margin-bottom: -1px;
4835 background-color: #fff;
4836 border: 1px solid #ddd;
4837 }
4838 .list-group-item:first-child {
4839 border-top-left-radius: 4px;
4840 border-top-right-radius: 4px;
4841 }
4842 .list-group-item:last-child {
4843 margin-bottom: 0;
4844 border-bottom-right-radius: 4px;
4845 border-bottom-left-radius: 4px;
4846 }
4847 .list-group-item > .badge {
4848 float: right;
4849 }
4850 .list-group-item > .badge + .badge {
4851 margin-right: 5px;
4852 }
4853 a.list-group-item {
4854 color: #555;
4855 }
4856 a.list-group-item .list-group-item-heading {
4857 color: #333;
4858 }
4859 a.list-group-item:hover,
4860 a.list-group-item:focus {
4861 color: #555;
4862 text-decoration: none;
4863 background-color: #f5f5f5;
4864 }
4865 .list-group-item.disabled,
4866 .list-group-item.disabled:hover,
4867 .list-group-item.disabled:focus {
4868 color: #777;
4869 background-color: #eee;
4870 }
4871 .list-group-item.disabled .list-group-item-heading,
4872 .list-group-item.disabled:hover .list-group-item-heading,
4873 .list-group-item.disabled:focus .list-group-item-heading {
4874 color: inherit;
4875 }
4876 .list-group-item.disabled .list-group-item-text,
4877 .list-group-item.disabled:hover .list-group-item-text,
4878 .list-group-item.disabled:focus .list-group-item-text {
4879 color: #777;
4880 }
4881 .list-group-item.active,
4882 .list-group-item.active:hover,
4883 .list-group-item.active:focus {
4884 z-index: 2;
4885 color: #fff;
4886 background-color: #428bca;
4887 border-color: #428bca;
4888 }
4889 .list-group-item.active .list-group-item-heading,
4890 .list-group-item.active:hover .list-group-item-heading,
4891 .list-group-item.active:focus .list-group-item-heading,
4892 .list-group-item.active .list-group-item-heading > small,
4893 .list-group-item.active:hover .list-group-item-heading > small,
4894 .list-group-item.active:focus .list-group-item-heading > small,
4895 .list-group-item.active .list-group-item-heading > .small,
4896 .list-group-item.active:hover .list-group-item-heading > .small,
4897 .list-group-item.active:focus .list-group-item-heading > .small {
4898 color: inherit;
4899 }
4900 .list-group-item.active .list-group-item-text,
4901 .list-group-item.active:hover .list-group-item-text,
4902 .list-group-item.active:focus .list-group-item-text {
4903 color: #e1edf7;
4904 }
4905 .list-group-item-success {
4906 color: #3c763d;
4907 background-color: #dff0d8;
4908 }
4909 a.list-group-item-success {
4910 color: #3c763d;
4911 }
4912 a.list-group-item-success .list-group-item-heading {
4913 color: inherit;
4914 }
4915 a.list-group-item-success:hover,
4916 a.list-group-item-success:focus {
4917 color: #3c763d;
4918 background-color: #d0e9c6;
4919 }
4920 a.list-group-item-success.active,
4921 a.list-group-item-success.active:hover,
4922 a.list-group-item-success.active:focus {
4923 color: #fff;
4924 background-color: #3c763d;
4925 border-color: #3c763d;
4926 }
4927 .list-group-item-info {
4928 color: #31708f;
4929 background-color: #d9edf7;
4930 }
4931 a.list-group-item-info {
4932 color: #31708f;
4933 }
4934 a.list-group-item-info .list-group-item-heading {
4935 color: inherit;
4936 }
4937 a.list-group-item-info:hover,
4938 a.list-group-item-info:focus {
4939 color: #31708f;
4940 background-color: #c4e3f3;
4941 }
4942 a.list-group-item-info.active,
4943 a.list-group-item-info.active:hover,
4944 a.list-group-item-info.active:focus {
4945 color: #fff;
4946 background-color: #31708f;
4947 border-color: #31708f;
4948 }
4949 .list-group-item-warning {
4950 color: #8a6d3b;
4951 background-color: #fcf8e3;
4952 }
4953 a.list-group-item-warning {
4954 color: #8a6d3b;
4955 }
4956 a.list-group-item-warning .list-group-item-heading {
4957 color: inherit;
4958 }
4959 a.list-group-item-warning:hover,
4960 a.list-group-item-warning:focus {
4961 color: #8a6d3b;
4962 background-color: #faf2cc;
4963 }
4964 a.list-group-item-warning.active,
4965 a.list-group-item-warning.active:hover,
4966 a.list-group-item-warning.active:focus {
4967 color: #fff;
4968 background-color: #8a6d3b;
4969 border-color: #8a6d3b;
4970 }
4971 .list-group-item-danger {
4972 color: #a94442;
4973 background-color: #f2dede;
4974 }
4975 a.list-group-item-danger {
4976 color: #a94442;
4977 }
4978 a.list-group-item-danger .list-group-item-heading {
4979 color: inherit;
4980 }
4981 a.list-group-item-danger:hover,
4982 a.list-group-item-danger:focus {
4983 color: #a94442;
4984 background-color: #ebcccc;
4985 }
4986 a.list-group-item-danger.active,
4987 a.list-group-item-danger.active:hover,
4988 a.list-group-item-danger.active:focus {
4989 color: #fff;
4990 background-color: #a94442;
4991 border-color: #a94442;
4992 }
4993 .list-group-item-heading {
4994 margin-top: 0;
4995 margin-bottom: 5px;
4996 }
4997 .list-group-item-text {
4998 margin-bottom: 0;
4999 line-height: 1.3;
5000 }
5001 .panel {
5002 margin-bottom: 20px;
5003 background-color: #fff;
5004 border: 1px solid transparent;
5005 border-radius: 4px;
5006 -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
5007 box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
5008 }
5009 .panel-body {
5010 padding: 15px;
5011 }
5012 .panel-heading {
5013 padding: 10px 15px;
5014 border-bottom: 1px solid transparent;
5015 border-top-left-radius: 3px;
5016 border-top-right-radius: 3px;
5017 }
5018 .panel-heading > .dropdown .dropdown-toggle {
5019 color: inherit;
5020 }
5021 .panel-title {
5022 margin-top: 0;
5023 margin-bottom: 0;
5024 font-size: 16px;
5025 color: inherit;
5026 }
5027 .panel-title > a {
5028 color: inherit;
5029 }
5030 .panel-footer {
5031 padding: 10px 15px;
5032 background-color: #f5f5f5;
5033 border-top: 1px solid #ddd;
5034 border-bottom-right-radius: 3px;
5035 border-bottom-left-radius: 3px;
5036 }
5037 .panel > .list-group {
5038 margin-bottom: 0;
5039 }
5040 .panel > .list-group .list-group-item {
5041 border-width: 1px 0;
5042 border-radius: 0;
5043 }
5044 .panel > .list-group:first-child .list-group-item:first-child {
5045 border-top: 0;
5046 border-top-left-radius: 3px;
5047 border-top-right-radius: 3px;
5048 }
5049 .panel > .list-group:last-child .list-group-item:last-child {
5050 border-bottom: 0;
5051 border-bottom-right-radius: 3px;
5052 border-bottom-left-radius: 3px;
5053 }
5054 .panel-heading + .list-group .list-group-item:first-child {
5055 border-top-width: 0;
5056 }
5057 .list-group + .panel-footer {
5058 border-top-width: 0;
5059 }
5060 .panel > .table,
5061 .panel > .table-responsive > .table,
5062 .panel > .panel-collapse > .table {
5063 margin-bottom: 0;
5064 }
5065 .panel > .table:first-child,
5066 .panel > .table-responsive:first-child > .table:first-child {
5067 border-top-left-radius: 3px;
5068 border-top-right-radius: 3px;
5069 }
5070 .panel > .table:first-child > thead:first-child > tr:first-child td:first-child,
5071 .panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child td:first-child,
5072 .panel > .table:first-child > tbody:first-child > tr:first-child td:first-child,
5073 .panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child td:first-child,
5074 .panel > .table:first-child > thead:first-child > tr:first-child th:first-child,
5075 .panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child th:first-child,
5076 .panel > .table:first-child > tbody:first-child > tr:first-child th:first-child,
5077 .panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child th:first-child {
5078 border-top-left-radius: 3px;
5079 }
5080 .panel > .table:first-child > thead:first-child > tr:first-child td:last-child,
5081 .panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child td:last-child,
5082 .panel > .table:first-child > tbody:first-child > tr:first-child td:last-child,
5083 .panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child td:last-child,
5084 .panel > .table:first-child > thead:first-child > tr:first-child th:last-child,
5085 .panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child th:last-child,
5086 .panel > .table:first-child > tbody:first-child > tr:first-child th:last-child,
5087 .panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child th:last-child {
5088 border-top-right-radius: 3px;
5089 }
5090 .panel > .table:last-child,
5091 .panel > .table-responsive:last-child > .table:last-child {
5092 border-bottom-right-radius: 3px;
5093 border-bottom-left-radius: 3px;
5094 }
5095 .panel > .table:last-child > tbody:last-child > tr:last-child td:first-child,
5096 .panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child td:first-child,
5097 .panel > .table:last-child > tfoot:last-child > tr:last-child td:first-child,
5098 .panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child td:first-child,
5099 .panel > .table:last-child > tbody:last-child > tr:last-child th:first-child,
5100 .panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child th:first-child,
5101 .panel > .table:last-child > tfoot:last-child > tr:last-child th:first-child,
5102 .panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child th:first-child {
5103 border-bottom-left-radius: 3px;
5104 }
5105 .panel > .table:last-child > tbody:last-child > tr:last-child td:last-child,
5106 .panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child td:last-child,
5107 .panel > .table:last-child > tfoot:last-child > tr:last-child td:last-child,
5108 .panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child td:last-child,
5109 .panel > .table:last-child > tbody:last-child > tr:last-child th:last-child,
5110 .panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child th:last-child,
5111 .panel > .table:last-child > tfoot:last-child > tr:last-child th:last-child,
5112 .panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child th:last-child {
5113 border-bottom-right-radius: 3px;
5114 }
5115 .panel > .panel-body + .table,
5116 .panel > .panel-body + .table-responsive {
5117 border-top: 1px solid #ddd;
5118 }
5119 .panel > .table > tbody:first-child > tr:first-child th,
5120 .panel > .table > tbody:first-child > tr:first-child td {
5121 border-top: 0;
5122 }
5123 .panel > .table-bordered,
5124 .panel > .table-responsive > .table-bordered {
5125 border: 0;
5126 }
5127 .panel > .table-bordered > thead > tr > th:first-child,
5128 .panel > .table-responsive > .table-bordered > thead > tr > th:first-child,
5129 .panel > .table-bordered > tbody > tr > th:first-child,
5130 .panel > .table-responsive > .table-bordered > tbody > tr > th:first-child,
5131 .panel > .table-bordered > tfoot > tr > th:first-child,
5132 .panel > .table-responsive > .table-bordered > tfoot > tr > th:first-child,
5133 .panel > .table-bordered > thead > tr > td:first-child,
5134 .panel > .table-responsive > .table-bordered > thead > tr > td:first-child,
5135 .panel > .table-bordered > tbody > tr > td:first-child,
5136 .panel > .table-responsive > .table-bordered > tbody > tr > td:first-child,
5137 .panel > .table-bordered > tfoot > tr > td:first-child,
5138 .panel > .table-responsive > .table-bordered > tfoot > tr > td:first-child {
5139 border-left: 0;
5140 }
5141 .panel > .table-bordered > thead > tr > th:last-child,
5142 .panel > .table-responsive > .table-bordered > thead > tr > th:last-child,
5143 .panel > .table-bordered > tbody > tr > th:last-child,
5144 .panel > .table-responsive > .table-bordered > tbody > tr > th:last-child,
5145 .panel > .table-bordered > tfoot > tr > th:last-child,
5146 .panel > .table-responsive > .table-bordered > tfoot > tr > th:last-child,
5147 .panel > .table-bordered > thead > tr > td:last-child,
5148 .panel > .table-responsive > .table-bordered > thead > tr > td:last-child,
5149 .panel > .table-bordered > tbody > tr > td:last-child,
5150 .panel > .table-responsive > .table-bordered > tbody > tr > td:last-child,
5151 .panel > .table-bordered > tfoot > tr > td:last-child,
5152 .panel > .table-responsive > .table-bordered > tfoot > tr > td:last-child {
5153 border-right: 0;
5154 }
5155 .panel > .table-bordered > thead > tr:first-child > td,
5156 .panel > .table-responsive > .table-bordered > thead > tr:first-child > td,
5157 .panel > .table-bordered > tbody > tr:first-child > td,
5158 .panel > .table-responsive > .table-bordered > tbody > tr:first-child > td,
5159 .panel > .table-bordered > thead > tr:first-child > th,
5160 .panel > .table-responsive > .table-bordered > thead > tr:first-child > th,
5161 .panel > .table-bordered > tbody > tr:first-child > th,
5162 .panel > .table-responsive > .table-bordered > tbody > tr:first-child > th {
5163 border-bottom: 0;
5164 }
5165 .panel > .table-bordered > tbody > tr:last-child > td,
5166 .panel > .table-responsive > .table-bordered > tbody > tr:last-child > td,
5167 .panel > .table-bordered > tfoot > tr:last-child > td,
5168 .panel > .table-responsive > .table-bordered > tfoot > tr:last-child > td,
5169 .panel > .table-bordered > tbody > tr:last-child > th,
5170 .panel > .table-responsive > .table-bordered > tbody > tr:last-child > th,
5171 .panel > .table-bordered > tfoot > tr:last-child > th,
5172 .panel > .table-responsive > .table-bordered > tfoot > tr:last-child > th {
5173 border-bottom: 0;
5174 }
5175 .panel > .table-responsive {
5176 margin-bottom: 0;
5177 border: 0;
5178 }
5179 .panel-group {
5180 margin-bottom: 20px;
5181 }
5182 .panel-group .panel {
5183 margin-bottom: 0;
5184 border-radius: 4px;
5185 }
5186 .panel-group .panel + .panel {
5187 margin-top: 5px;
5188 }
5189 .panel-group .panel-heading {
5190 border-bottom: 0;
5191 }
5192 .panel-group .panel-heading + .panel-collapse > .panel-body {
5193 border-top: 1px solid #ddd;
5194 }
5195 .panel-group .panel-footer {
5196 border-top: 0;
5197 }
5198 .panel-group .panel-footer + .panel-collapse .panel-body {
5199 border-bottom: 1px solid #ddd;
5200 }
5201 .panel-default {
5202 border-color: #ddd;
5203 }
5204 .panel-default > .panel-heading {
5205 color: #333;
5206 background-color: #f5f5f5;
5207 border-color: #ddd;
5208 }
5209 .panel-default > .panel-heading + .panel-collapse > .panel-body {
5210 border-top-color: #ddd;
5211 }
5212 .panel-default > .panel-heading .badge {
5213 color: #f5f5f5;
5214 background-color: #333;
5215 }
5216 .panel-default > .panel-footer + .panel-collapse > .panel-body {
5217 border-bottom-color: #ddd;
5218 }
5219 .panel-primary {
5220 border-color: #428bca;
5221 }
5222 .panel-primary > .panel-heading {
5223 color: #fff;
5224 background-color: #428bca;
5225 border-color: #428bca;
5226 }
5227 .panel-primary > .panel-heading + .panel-collapse > .panel-body {
5228 border-top-color: #428bca;
5229 }
5230 .panel-primary > .panel-heading .badge {
5231 color: #428bca;
5232 background-color: #fff;
5233 }
5234 .panel-primary > .panel-footer + .panel-collapse > .panel-body {
5235 border-bottom-color: #428bca;
5236 }
5237 .panel-success {
5238 border-color: #d6e9c6;
5239 }
5240 .panel-success > .panel-heading {
5241 color: #3c763d;
5242 background-color: #dff0d8;
5243 border-color: #d6e9c6;
5244 }
5245 .panel-success > .panel-heading + .panel-collapse > .panel-body {
5246 border-top-color: #d6e9c6;
5247 }
5248 .panel-success > .panel-heading .badge {
5249 color: #dff0d8;
5250 background-color: #3c763d;
5251 }
5252 .panel-success > .panel-footer + .panel-collapse > .panel-body {
5253 border-bottom-color: #d6e9c6;
5254 }
5255 .panel-info {
5256 border-color: #bce8f1;
5257 }
5258 .panel-info > .panel-heading {
5259 color: #31708f;
5260 background-color: #d9edf7;
5261 border-color: #bce8f1;
5262 }
5263 .panel-info > .panel-heading + .panel-collapse > .panel-body {
5264 border-top-color: #bce8f1;
5265 }
5266 .panel-info > .panel-heading .badge {
5267 color: #d9edf7;
5268 background-color: #31708f;
5269 }
5270 .panel-info > .panel-footer + .panel-collapse > .panel-body {
5271 border-bottom-color: #bce8f1;
5272 }
5273 .panel-warning {
5274 border-color: #faebcc;
5275 }
5276 .panel-warning > .panel-heading {
5277 color: #8a6d3b;
5278 background-color: #fcf8e3;
5279 border-color: #faebcc;
5280 }
5281 .panel-warning > .panel-heading + .panel-collapse > .panel-body {
5282 border-top-color: #faebcc;
5283 }
5284 .panel-warning > .panel-heading .badge {
5285 color: #fcf8e3;
5286 background-color: #8a6d3b;
5287 }
5288 .panel-warning > .panel-footer + .panel-collapse > .panel-body {
5289 border-bottom-color: #faebcc;
5290 }
5291 .panel-danger {
5292 border-color: #ebccd1;
5293 }
5294 .panel-danger > .panel-heading {
5295 color: #a94442;
5296 background-color: #f2dede;
5297 border-color: #ebccd1;
5298 }
5299 .panel-danger > .panel-heading + .panel-collapse > .panel-body {
5300 border-top-color: #ebccd1;
5301 }
5302 .panel-danger > .panel-heading .badge {
5303 color: #f2dede;
5304 background-color: #a94442;
5305 }
5306 .panel-danger > .panel-footer + .panel-collapse > .panel-body {
5307 border-bottom-color: #ebccd1;
5308 }
5309 .embed-responsive {
5310 position: relative;
5311 display: block;
5312 height: 0;
5313 padding: 0;
5314 overflow: hidden;
5315 }
5316 .embed-responsive .embed-responsive-item,
5317 .embed-responsive iframe,
5318 .embed-responsive embed,
5319 .embed-responsive object {
5320 position: absolute;
5321 top: 0;
5322 bottom: 0;
5323 left: 0;
5324 width: 100%;
5325 height: 100%;
5326 border: 0;
5327 }
5328 .embed-responsive.embed-responsive-16by9 {
5329 padding-bottom: 56.25%;
5330 }
5331 .embed-responsive.embed-responsive-4by3 {
5332 padding-bottom: 75%;
5333 }
5334 .well {
5335 min-height: 20px;
5336 padding: 19px;
5337 margin-bottom: 20px;
5338 background-color: #f5f5f5;
5339 border: 1px solid #e3e3e3;
5340 border-radius: 4px;
5341 -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .05);
5342 box-shadow: inset 0 1px 1px rgba(0, 0, 0, .05);
5343 }
5344 .well blockquote {
5345 border-color: #ddd;
5346 border-color: rgba(0, 0, 0, .15);
5347 }
5348 .well-lg {
5349 padding: 24px;
5350 border-radius: 6px;
5351 }
5352 .well-sm {
5353 padding: 9px;
5354 border-radius: 3px;
5355 }
5356 .close {
5357 float: right;
5358 font-size: 21px;
5359 font-weight: bold;
5360 line-height: 1;
5361 color: #000;
5362 text-shadow: 0 1px 0 #fff;
5363 filter: alpha(opacity=20);
5364 opacity: .2;
5365 }
5366 .close:hover,
5367 .close:focus {
5368 color: #000;
5369 text-decoration: none;
5370 cursor: pointer;
5371 filter: alpha(opacity=50);
5372 opacity: .5;
5373 }
5374 button.close {
5375 -webkit-appearance: none;
5376 padding: 0;
5377 cursor: pointer;
5378 background: transparent;
5379 border: 0;
5380 }
5381 .modal-open {
5382 overflow: hidden;
5383 }
5384 .modal {
5385 position: fixed;
5386 top: 0;
5387 right: 0;
5388 bottom: 0;
5389 left: 0;
5390 z-index: 1050;
5391 display: none;
5392 overflow: hidden;
5393 -webkit-overflow-scrolling: touch;
5394 outline: 0;
5395 }
5396 .modal.fade .modal-dialog {
5397 -webkit-transition: -webkit-transform .3s ease-out;
5398 -o-transition: -o-transform .3s ease-out;
5399 transition: transform .3s ease-out;
5400 -webkit-transform: translate3d(0, -25%, 0);
5401 -o-transform: translate3d(0, -25%, 0);
5402 transform: translate3d(0, -25%, 0);
5403 }
5404 .modal.in .modal-dialog {
5405 -webkit-transform: translate3d(0, 0, 0);
5406 -o-transform: translate3d(0, 0, 0);
5407 transform: translate3d(0, 0, 0);
5408 }
5409 .modal-open .modal {
5410 overflow-x: hidden;
5411 overflow-y: auto;
5412 }
5413 .modal-dialog {
5414 position: relative;
5415 width: auto;
5416 margin: 10px;
5417 }
5418 .modal-content {
5419 position: relative;
5420 background-color: #fff;
5421 -webkit-background-clip: padding-box;
5422 background-clip: padding-box;
5423 border: 1px solid #999;
5424 border: 1px solid rgba(0, 0, 0, .2);
5425 border-radius: 6px;
5426 outline: 0;
5427 -webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
5428 box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
5429 }
5430 .modal-backdrop {
5431 position: fixed;
5432 top: 0;
5433 right: 0;
5434 bottom: 0;
5435 left: 0;
5436 z-index: 1040;
5437 background-color: #000;
5438 }
5439 .modal-backdrop.fade {
5440 filter: alpha(opacity=0);
5441 opacity: 0;
5442 }
5443 .modal-backdrop.in {
5444 filter: alpha(opacity=50);
5445 opacity: .5;
5446 }
5447 .modal-header {
5448 min-height: 16.42857143px;
5449 padding: 15px;
5450 border-bottom: 1px solid #e5e5e5;
5451 }
5452 .modal-header .close {
5453 margin-top: -2px;
5454 }
5455 .modal-title {
5456 margin: 0;
5457 line-height: 1.42857143;
5458 }
5459 .modal-body {
5460 position: relative;
5461 padding: 15px;
5462 }
5463 .modal-footer {
5464 padding: 15px;
5465 text-align: right;
5466 border-top: 1px solid #e5e5e5;
5467 }
5468 .modal-footer .btn + .btn {
5469 margin-bottom: 0;
5470 margin-left: 5px;
5471 }
5472 .modal-footer .btn-group .btn + .btn {
5473 margin-left: -1px;
5474 }
5475 .modal-footer .btn-block + .btn-block {
5476 margin-left: 0;
5477 }
5478 .modal-scrollbar-measure {
5479 position: absolute;
5480 top: -9999px;
5481 width: 50px;
5482 height: 50px;
5483 overflow: scroll;
5484 }
5485 @media (min-width: 768px) {
5486 .modal-dialog {
5487 width: 600px;
5488 margin: 30px auto;
5489 }
5490 .modal-content {
5491 -webkit-box-shadow: 0 5px 15px rgba(0, 0, 0, .5);
5492 box-shadow: 0 5px 15px rgba(0, 0, 0, .5);
5493 }
5494 .modal-sm {
5495 width: 300px;
5496 }
5497 }
5498 @media (min-width: 992px) {
5499 .modal-lg {
5500 width: 900px;
5501 }
5502 }
5503 .tooltip {
5504 position: absolute;
5505 z-index: 1070;
5506 display: block;
5507 font-size: 12px;
5508 line-height: 1.4;
5509 visibility: visible;
5510 filter: alpha(opacity=0);
5511 opacity: 0;
5512 }
5513 .tooltip.in {
5514 filter: alpha(opacity=90);
5515 opacity: .9;
5516 }
5517 .tooltip.top {
5518 padding: 5px 0;
5519 margin-top: -3px;
5520 }
5521 .tooltip.right {
5522 padding: 0 5px;
5523 margin-left: 3px;
5524 }
5525 .tooltip.bottom {
5526 padding: 5px 0;
5527 margin-top: 3px;
5528 }
5529 .tooltip.left {
5530 padding: 0 5px;
5531 margin-left: -3px;
5532 }
5533 .tooltip-inner {
5534 max-width: 200px;
5535 padding: 3px 8px;
5536 color: #fff;
5537 text-align: center;
5538 text-decoration: none;
5539 background-color: #000;
5540 border-radius: 4px;
5541 }
5542 .tooltip-arrow {
5543 position: absolute;
5544 width: 0;
5545 height: 0;
5546 border-color: transparent;
5547 border-style: solid;
5548 }
5549 .tooltip.top .tooltip-arrow {
5550 bottom: 0;
5551 left: 50%;
5552 margin-left: -5px;
5553 border-width: 5px 5px 0;
5554 border-top-color: #000;
5555 }
5556 .tooltip.top-left .tooltip-arrow {
5557 bottom: 0;
5558 left: 5px;
5559 border-width: 5px 5px 0;
5560 border-top-color: #000;
5561 }
5562 .tooltip.top-right .tooltip-arrow {
5563 right: 5px;
5564 bottom: 0;
5565 border-width: 5px 5px 0;
5566 border-top-color: #000;
5567 }
5568 .tooltip.right .tooltip-arrow {
5569 top: 50%;
5570 left: 0;
5571 margin-top: -5px;
5572 border-width: 5px 5px 5px 0;
5573 border-right-color: #000;
5574 }
5575 .tooltip.left .tooltip-arrow {
5576 top: 50%;
5577 right: 0;
5578 margin-top: -5px;
5579 border-width: 5px 0 5px 5px;
5580 border-left-color: #000;
5581 }
5582 .tooltip.bottom .tooltip-arrow {
5583 top: 0;
5584 left: 50%;
5585 margin-left: -5px;
5586 border-width: 0 5px 5px;
5587 border-bottom-color: #000;
5588 }
5589 .tooltip.bottom-left .tooltip-arrow {
5590 top: 0;
5591 left: 5px;
5592 border-width: 0 5px 5px;
5593 border-bottom-color: #000;
5594 }
5595 .tooltip.bottom-right .tooltip-arrow {
5596 top: 0;
5597 right: 5px;
5598 border-width: 0 5px 5px;
5599 border-bottom-color: #000;
5600 }
5601 .popover {
5602 position: absolute;
5603 top: 0;
5604 left: 0;
5605 z-index: 1060;
5606 display: none;
5607 max-width: 276px;
5608 padding: 1px;
5609 text-align: left;
5610 white-space: normal;
5611 background-color: #fff;
5612 -webkit-background-clip: padding-box;
5613 background-clip: padding-box;
5614 border: 1px solid #ccc;
5615 border: 1px solid rgba(0, 0, 0, .2);
5616 border-radius: 6px;
5617 -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
5618 box-shadow: 0 5px 10px rgba(0, 0, 0, .2);
5619 }
5620 .popover.top {
5621 margin-top: -10px;
5622 }
5623 .popover.right {
5624 margin-left: 10px;
5625 }
5626 .popover.bottom {
5627 margin-top: 10px;
5628 }
5629 .popover.left {
5630 margin-left: -10px;
5631 }
5632 .popover-title {
5633 padding: 8px 14px;
5634 margin: 0;
5635 font-size: 14px;
5636 font-weight: normal;
5637 line-height: 18px;
5638 background-color: #f7f7f7;
5639 border-bottom: 1px solid #ebebeb;
5640 border-radius: 5px 5px 0 0;
5641 }
5642 .popover-content {
5643 padding: 9px 14px;
5644 }
5645 .popover > .arrow,
5646 .popover > .arrow:after {
5647 position: absolute;
5648 display: block;
5649 width: 0;
5650 height: 0;
5651 border-color: transparent;
5652 border-style: solid;
5653 }
5654 .popover > .arrow {
5655 border-width: 11px;
5656 }
5657 .popover > .arrow:after {
5658 content: "";
5659 border-width: 10px;
5660 }
5661 .popover.top > .arrow {
5662 bottom: -11px;
5663 left: 50%;
5664 margin-left: -11px;
5665 border-top-color: #999;
5666 border-top-color: rgba(0, 0, 0, .25);
5667 border-bottom-width: 0;
5668 }
5669 .popover.top > .arrow:after {
5670 bottom: 1px;
5671 margin-left: -10px;
5672 content: " ";
5673 border-top-color: #fff;
5674 border-bottom-width: 0;
5675 }
5676 .popover.right > .arrow {
5677 top: 50%;
5678 left: -11px;
5679 margin-top: -11px;
5680 border-right-color: #999;
5681 border-right-color: rgba(0, 0, 0, .25);
5682 border-left-width: 0;
5683 }
5684 .popover.right > .arrow:after {
5685 bottom: -10px;
5686 left: 1px;
5687 content: " ";
5688 border-right-color: #fff;
5689 border-left-width: 0;
5690 }
5691 .popover.bottom > .arrow {
5692 top: -11px;
5693 left: 50%;
5694 margin-left: -11px;
5695 border-top-width: 0;
5696 border-bottom-color: #999;
5697 border-bottom-color: rgba(0, 0, 0, .25);
5698 }
5699 .popover.bottom > .arrow:after {
5700 top: 1px;
5701 margin-left: -10px;
5702 content: " ";
5703 border-top-width: 0;
5704 border-bottom-color: #fff;
5705 }
5706 .popover.left > .arrow {
5707 top: 50%;
5708 right: -11px;
5709 margin-top: -11px;
5710 border-right-width: 0;
5711 border-left-color: #999;
5712 border-left-color: rgba(0, 0, 0, .25);
5713 }
5714 .popover.left > .arrow:after {
5715 right: 1px;
5716 bottom: -10px;
5717 content: " ";
5718 border-right-width: 0;
5719 border-left-color: #fff;
5720 }
5721 .carousel {
5722 position: relative;
5723 }
5724 .carousel-inner {
5725 position: relative;
5726 width: 100%;
5727 overflow: hidden;
5728 }
5729 .carousel-inner > .item {
5730 position: relative;
5731 display: none;
5732 -webkit-transition: .6s ease-in-out left;
5733 -o-transition: .6s ease-in-out left;
5734 transition: .6s ease-in-out left;
5735 }
5736 .carousel-inner > .item > img,
5737 .carousel-inner > .item > a > img {
5738 line-height: 1;
5739 }
5740 .carousel-inner > .active,
5741 .carousel-inner > .next,
5742 .carousel-inner > .prev {
5743 display: block;
5744 }
5745 .carousel-inner > .active {
5746 left: 0;
5747 }
5748 .carousel-inner > .next,
5749 .carousel-inner > .prev {
5750 position: absolute;
5751 top: 0;
5752 width: 100%;
5753 }
5754 .carousel-inner > .next {
5755 left: 100%;
5756 }
5757 .carousel-inner > .prev {
5758 left: -100%;
5759 }
5760 .carousel-inner > .next.left,
5761 .carousel-inner > .prev.right {
5762 left: 0;
5763 }
5764 .carousel-inner > .active.left {
5765 left: -100%;
5766 }
5767 .carousel-inner > .active.right {
5768 left: 100%;
5769 }
5770 .carousel-control {
5771 position: absolute;
5772 top: 0;
5773 bottom: 0;
5774 left: 0;
5775 width: 15%;
5776 font-size: 20px;
5777 color: #fff;
5778 text-align: center;
5779 text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
5780 filter: alpha(opacity=50);
5781 opacity: .5;
5782 }
5783 .carousel-control.left {
5784 background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, .0001) 100%);
5785 background-image: -o-linear-gradient(left, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, .0001) 100%);
5786 background-image: -webkit-gradient(linear, left top, right top, from(rgba(0, 0, 0, .5)), to(rgba(0, 0, 0, .0001)));
5787 background-image: linear-gradient(to right, rgba(0, 0, 0, .5) 0%, rgba(0, 0, 0, .0001) 100%);
5788 filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#80000000', endColorstr='#00000000', GradientType=1);
5789 background-repeat: repeat-x;
5790 }
5791 .carousel-control.right {
5792 right: 0;
5793 left: auto;
5794 background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, .0001) 0%, rgba(0, 0, 0, .5) 100%);
5795 background-image: -o-linear-gradient(left, rgba(0, 0, 0, .0001) 0%, rgba(0, 0, 0, .5) 100%);
5796 background-image: -webkit-gradient(linear, left top, right top, from(rgba(0, 0, 0, .0001)), to(rgba(0, 0, 0, .5)));
5797 background-image: linear-gradient(to right, rgba(0, 0, 0, .0001) 0%, rgba(0, 0, 0, .5) 100%);
5798 filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#80000000', GradientType=1);
5799 background-repeat: repeat-x;
5800 }
5801 .carousel-control:hover,
5802 .carousel-control:focus {
5803 color: #fff;
5804 text-decoration: none;
5805 filter: alpha(opacity=90);
5806 outline: 0;
5807 opacity: .9;
5808 }
5809 .carousel-control .icon-prev,
5810 .carousel-control .icon-next,
5811 .carousel-control .glyphicon-chevron-left,
5812 .carousel-control .glyphicon-chevron-right {
5813 position: absolute;
5814 top: 50%;
5815 z-index: 5;
5816 display: inline-block;
5817 }
5818 .carousel-control .icon-prev,
5819 .carousel-control .glyphicon-chevron-left {
5820 left: 50%;
5821 margin-left: -10px;
5822 }
5823 .carousel-control .icon-next,
5824 .carousel-control .glyphicon-chevron-right {
5825 right: 50%;
5826 margin-right: -10px;
5827 }
5828 .carousel-control .icon-prev,
5829 .carousel-control .icon-next {
5830 width: 20px;
5831 height: 20px;
5832 margin-top: -10px;
5833 font-family: serif;
5834 }
5835 .carousel-control .icon-prev:before {
5836 content: '\2039';
5837 }
5838 .carousel-control .icon-next:before {
5839 content: '\203a';
5840 }
5841 .carousel-indicators {
5842 position: absolute;
5843 bottom: 10px;
5844 left: 50%;
5845 z-index: 15;
5846 width: 60%;
5847 padding-left: 0;
5848 margin-left: -30%;
5849 text-align: center;
5850 list-style: none;
5851 }
5852 .carousel-indicators li {
5853 display: inline-block;
5854 width: 10px;
5855 height: 10px;
5856 margin: 1px;
5857 text-indent: -999px;
5858 cursor: pointer;
5859 background-color: #000 \9;
5860 background-color: rgba(0, 0, 0, 0);
5861 border: 1px solid #fff;
5862 border-radius: 10px;
5863 }
5864 .carousel-indicators .active {
5865 width: 12px;
5866 height: 12px;
5867 margin: 0;
5868 background-color: #fff;
5869 }
5870 .carousel-caption {
5871 position: absolute;
5872 right: 15%;
5873 bottom: 20px;
5874 left: 15%;
5875 z-index: 10;
5876 padding-top: 20px;
5877 padding-bottom: 20px;
5878 color: #fff;
5879 text-align: center;
5880 text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
5881 }
5882 .carousel-caption .btn {
5883 text-shadow: none;
5884 }
5885 @media screen and (min-width: 768px) {
5886 .carousel-control .glyphicon-chevron-left,
5887 .carousel-control .glyphicon-chevron-right,
5888 .carousel-control .icon-prev,
5889 .carousel-control .icon-next {
5890 width: 30px;
5891 height: 30px;
5892 margin-top: -15px;
5893 font-size: 30px;
5894 }
5895 .carousel-control .glyphicon-chevron-left,
5896 .carousel-control .icon-prev {
5897 margin-left: -15px;
5898 }
5899 .carousel-control .glyphicon-chevron-right,
5900 .carousel-control .icon-next {
5901 margin-right: -15px;
5902 }
5903 .carousel-caption {
5904 right: 20%;
5905 left: 20%;
5906 padding-bottom: 30px;
5907 }
5908 .carousel-indicators {
5909 bottom: 20px;
5910 }
5911 }
5912 .clearfix:before,
5913 .clearfix:after,
5914 .dl-horizontal dd:before,
5915 .dl-horizontal dd:after,
5916 .container:before,
5917 .container:after,
5918 .container-fluid:before,
5919 .container-fluid:after,
5920 .row:before,
5921 .row:after,
5922 .form-horizontal .form-group:before,
5923 .form-horizontal .form-group:after,
5924 .btn-toolbar:before,
5925 .btn-toolbar:after,
5926 .btn-group-vertical > .btn-group:before,
5927 .btn-group-vertical > .btn-group:after,
5928 .nav:before,
5929 .nav:after,
5930 .navbar:before,
5931 .navbar:after,
5932 .navbar-header:before,
5933 .navbar-header:after,
5934 .navbar-collapse:before,
5935 .navbar-collapse:after,
5936 .pager:before,
5937 .pager:after,
5938 .panel-body:before,
5939 .panel-body:after,
5940 .modal-footer:before,
5941 .modal-footer:after {
5942 display: table;
5943 content: " ";
5944 }
5945 .clearfix:after,
5946 .dl-horizontal dd:after,
5947 .container:after,
5948 .container-fluid:after,
5949 .row:after,
5950 .form-horizontal .form-group:after,
5951 .btn-toolbar:after,
5952 .btn-group-vertical > .btn-group:after,
5953 .nav:after,
5954 .navbar:after,
5955 .navbar-header:after,
5956 .navbar-collapse:after,
5957 .pager:after,
5958 .panel-body:after,
5959 .modal-footer:after {
5960 clear: both;
5961 }
5962 .center-block {
5963 display: block;
5964 margin-right: auto;
5965 margin-left: auto;
5966 }
5967 .pull-right {
5968 float: right !important;
5969 }
5970 .pull-left {
5971 float: left !important;
5972 }
5973 .hide {
5974 display: none !important;
5975 }
5976 .show {
5977 display: block !important;
5978 }
5979 .invisible {
5980 visibility: hidden;
5981 }
5982 .text-hide {
5983 font: 0/0 a;
5984 color: transparent;
5985 text-shadow: none;
5986 background-color: transparent;
5987 border: 0;
5988 }
5989 .hidden {
5990 display: none !important;
5991 visibility: hidden !important;
5992 }
5993 .affix {
5994 position: fixed;
5995 -webkit-transform: translate3d(0, 0, 0);
5996 -o-transform: translate3d(0, 0, 0);
5997 transform: translate3d(0, 0, 0);
5998 }
5999 @-ms-viewport {
6000 width: device-width;
6001 }
6002 .visible-xs,
6003 .visible-sm,
6004 .visible-md,
6005 .visible-lg {
6006 display: none !important;
6007 }
6008 .visible-xs-block,
6009 .visible-xs-inline,
6010 .visible-xs-inline-block,
6011 .visible-sm-block,
6012 .visible-sm-inline,
6013 .visible-sm-inline-block,
6014 .visible-md-block,
6015 .visible-md-inline,
6016 .visible-md-inline-block,
6017 .visible-lg-block,
6018 .visible-lg-inline,
6019 .visible-lg-inline-block {
6020 display: none !important;
6021 }
6022 @media (max-width: 767px) {
6023 .visible-xs {
6024 display: block !important;
6025 }
6026 table.visible-xs {
6027 display: table;
6028 }
6029 tr.visible-xs {
6030 display: table-row !important;
6031 }
6032 th.visible-xs,
6033 td.visible-xs {
6034 display: table-cell !important;
6035 }
6036 }
6037 @media (max-width: 767px) {
6038 .visible-xs-block {
6039 display: block !important;
6040 }
6041 }
6042 @media (max-width: 767px) {
6043 .visible-xs-inline {
6044 display: inline !important;
6045 }
6046 }
6047 @media (max-width: 767px) {
6048 .visible-xs-inline-block {
6049 display: inline-block !important;
6050 }
6051 }
6052 @media (min-width: 768px) and (max-width: 991px) {
6053 .visible-sm {
6054 display: block !important;
6055 }
6056 table.visible-sm {
6057 display: table;
6058 }
6059 tr.visible-sm {
6060 display: table-row !important;
6061 }
6062 th.visible-sm,
6063 td.visible-sm {
6064 display: table-cell !important;
6065 }
6066 }
6067 @media (min-width: 768px) and (max-width: 991px) {
6068 .visible-sm-block {
6069 display: block !important;
6070 }
6071 }
6072 @media (min-width: 768px) and (max-width: 991px) {
6073 .visible-sm-inline {
6074 display: inline !important;
6075 }
6076 }
6077 @media (min-width: 768px) and (max-width: 991px) {
6078 .visible-sm-inline-block {
6079 display: inline-block !important;
6080 }
6081 }
6082 @media (min-width: 992px) and (max-width: 1199px) {
6083 .visible-md {
6084 display: block !important;
6085 }
6086 table.visible-md {
6087 display: table;
6088 }
6089 tr.visible-md {
6090 display: table-row !important;
6091 }
6092 th.visible-md,
6093 td.visible-md {
6094 display: table-cell !important;
6095 }
6096 }
6097 @media (min-width: 992px) and (max-width: 1199px) {
6098 .visible-md-block {
6099 display: block !important;
6100 }
6101 }
6102 @media (min-width: 992px) and (max-width: 1199px) {
6103 .visible-md-inline {
6104 display: inline !important;
6105 }
6106 }
6107 @media (min-width: 992px) and (max-width: 1199px) {
6108 .visible-md-inline-block {
6109 display: inline-block !important;
6110 }
6111 }
6112 @media (min-width: 1200px) {
6113 .visible-lg {
6114 display: block !important;
6115 }
6116 table.visible-lg {
6117 display: table;
6118 }
6119 tr.visible-lg {
6120 display: table-row !important;
6121 }
6122 th.visible-lg,
6123 td.visible-lg {
6124 display: table-cell !important;
6125 }
6126 }
6127 @media (min-width: 1200px) {
6128 .visible-lg-block {
6129 display: block !important;
6130 }
6131 }
6132 @media (min-width: 1200px) {
6133 .visible-lg-inline {
6134 display: inline !important;
6135 }
6136 }
6137 @media (min-width: 1200px) {
6138 .visible-lg-inline-block {
6139 display: inline-block !important;
6140 }
6141 }
6142 @media (max-width: 767px) {
6143 .hidden-xs {
6144 display: none !important;
6145 }
6146 }
6147 @media (min-width: 768px) and (max-width: 991px) {
6148 .hidden-sm {
6149 display: none !important;
6150 }
6151 }
6152 @media (min-width: 992px) and (max-width: 1199px) {
6153 .hidden-md {
6154 display: none !important;
6155 }
6156 }
6157 @media (min-width: 1200px) {
6158 .hidden-lg {
6159 display: none !important;
6160 }
6161 }
6162 .visible-print {
6163 display: none !important;
6164 }
6165 @media print {
6166 .visible-print {
6167 display: block !important;
6168 }
6169 table.visible-print {
6170 display: table;
6171 }
6172 tr.visible-print {
6173 display: table-row !important;
6174 }
6175 th.visible-print,
6176 td.visible-print {
6177 display: table-cell !important;
6178 }
6179 }
6180 .visible-print-block {
6181 display: none !important;
6182 }
6183 @media print {
6184 .visible-print-block {
6185 display: block !important;
6186 }
6187 }
6188 .visible-print-inline {
6189 display: none !important;
6190 }
6191 @media print {
6192 .visible-print-inline {
6193 display: inline !important;
6194 }
6195 }
6196 .visible-print-inline-block {
6197 display: none !important;
6198 }
6199 @media print {
6200 .visible-print-inline-block {
6201 display: inline-block !important;
6202 }
6203 }
6204 @media print {
6205 .hidden-print {
6206 display: none !important;
6207 }
6208 }
6209 /*# sourceMappingURL=bootstrap.css.map */
6210 </style>
6211 <meta content="Mnemonic code for generating deterministic keys" name="description"/>
6212 <meta content="width=device-width, initial-scale=1.0" name="viewport" />
6213 <meta content="bitcoin mnemonic converter" name="description" />
6214 <meta content="DC POS" name="author" />
6215
6216 <style>
6217 body {
6218 padding-bottom: 32px;
6219 }
6220 .form-control[readonly] {
6221 cursor: text;
6222 }
6223 .feedback-container {
6224 position: fixed;
6225 top: 0;
6226 width: 100%;
6227 text-align: center;
6228 z-index: 4;
6229 }
6230 .feedback {
6231 display: table;
6232 padding: 0.5em 1em;
6233 background-color: orange;
6234 margin: 0 auto;
6235 font-size: 2em;
6236 color: #444;
6237 border: 2px solid #555;
6238 border-top: 0;
6239 border-bottom-left-radius: 20px 20px;
6240 border-bottom-right-radius: 20px 20px;
6241 }
6242 </style>
6243 </head>
6244 <body>
6245 <div class="container">
6246
6247 <h1 class="text-center">Mnemonic Code Converter</h1>
6248 <hr>
6249 <div class="row">
6250 <div class="col-md-12">
6251 <h2>Mnemonic</h2>
6252 <form class="form-horizontal" role="form">
6253 <div class="col-sm-2"></div>
6254 <div class="col-sm-10">
6255 <p>You can enter an existing BIP39 mnemonic, or generate a new random one. Typing your own twelve words will probably not work how you expect, since the words require a particular structure (the last word is a checksum)</p>
6256 <p>For more info see the <a href="https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki" target="_blank">BIP39 spec</a></p>
6257 </div>
6258 <div class="form-group">
6259 <label for="network-phrase" class="col-sm-2 control-label">Coin</label>
6260 <div class="col-sm-10">
6261 <select id="network-phrase" class="network form-control">
6262 <option value="bitcoin">Bitcoin</option>
6263 <option value="bitcoin-testnet">Bitcoin Testnet</option>
6264 <option value="litecoin">Litecoin</option>
6265 <option value="dogecoin">Dogecoin</option>
6266 </select>
6267 </div>
6268 </div>
6269 <div class="form-group">
6270 <label for="phrase" class="col-sm-2 control-label">BIP39 Mnemonic</label>
6271 <div class="col-sm-10">
6272 <textarea id="phrase" class="phrase form-control"></textarea>
6273 </div>
6274 </div>
6275 <div class="form-group">
6276 <label for="strength" class="col-sm-2 control-label">Number of words</label>
6277 <div class="col-sm-10">
6278 <div class="input-group">
6279 <input type="number" class="strength form-control" id="strength" value="12">
6280 <span class="input-group-btn">
6281 <button class="btn generate">Generate Random Mnemonic</button>
6282 </span>
6283 </div>
6284 </div>
6285 </div>
6286 <div class="form-group">
6287 <label for="passphrase" class="col-sm-2 control-label">BIP39 Passphrase (optional)</label>
6288 <div class="col-sm-10">
6289 <textarea id="passphrase" class="passphrase form-control"></textarea>
6290 </div>
6291 </div>
6292 <div class="form-group">
6293 <label for="root-key" class="col-sm-2 control-label">BIP32 Root Key</label>
6294 <div class="col-sm-10">
6295 <textarea id="root-key" class="root-key form-control" readonly="readonly"></textarea>
6296 </div>
6297 </div>
6298 </form>
6299 </div>
6300 </div>
6301
6302 <hr>
6303
6304 <div class="row">
6305 <div class="col-md-12">
6306 <h2>Derivation Path</h2>
6307 <ul class="derivation-type nav nav-tabs" role="tablist">
6308 <li id="bip44-tab" class="active">
6309 <a href="#bip44" role="tab" data-toggle="tab">BIP44</a>
6310 </li>
6311 <li id="bip32-tab">
6312 <a href="#bip32" role="tab" data-toggle="tab">BIP32</a>
6313 </li>
6314 </ul>
6315 <div class="derivation-type tab-content">
6316 <div id="bip44" class="tab-pane active">
6317 <form class="form-horizontal" role="form">
6318 <br>
6319 <div class="col-sm-2"></div>
6320 <div class="col-sm-10">
6321 <p>For more info see the <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki" target="_blank">BIP44 spec</a></p>
6322 </div>
6323 <div class="form-group">
6324 <label for="network-bip44" class="col-sm-2 control-label">Coin</label>
6325 <div class="col-sm-10">
6326 <select id="network-bip44" class="network form-control">
6327 <option value="bitcoin">Bitcoin</option>
6328 <option value="bitcoin-testnet">Bitcoin Testnet</option>
6329 <option value="litecoin">Litecoin</option>
6330 </select>
6331 </div>
6332 </div>
6333 <div class="form-group">
6334 <label for="purpose" class="col-sm-2 control-label">
6335 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#purpose" target="_blank">Purpose</a>
6336 </label>
6337 <div class="col-sm-10">
6338 <input id="purpose" type="text" class="purpose form-control" value="44">
6339 </div>
6340 </div>
6341 <div class="form-group">
6342 <label for="coin" class="col-sm-2 control-label">
6343 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#registered-coin-types" target="_blank">Coin</a>
6344 </label>
6345 <div class="col-sm-10">
6346 <input id="coin" type="text" class="coin form-control" value="0">
6347 </div>
6348 </div>
6349 <div class="form-group">
6350 <label for="account" class="col-sm-2 control-label">
6351 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#account" target="_blank">Account</a>
6352 </label>
6353 <div class="col-sm-10">
6354 <input id="account" type="text" class="account form-control" value="0">
6355 </div>
6356 </div>
6357 <div class="form-group">
6358 <label for="change" class="col-sm-2 control-label">
6359 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#change" target="_blank">External / Internal</a>
6360 </label>
6361 <div class="col-sm-10">
6362 <input id="change" type="text" class="change form-control" value="0">
6363 </div>
6364 </div>
6365 <div class="form-group">
6366 <label for="bip44-path" class="col-sm-2 control-label">BIP32 Derivation Path</label>
6367 <div class="col-sm-10">
6368 <input id="bip44-path" type="text" class="path form-control" value="m/44'/0'/0'/0" readonly="readonly">
6369 </div>
6370 </div>
6371 </form>
6372 </div>
6373 <div id="bip32" class="tab-pane">
6374 <form class="form-horizontal" role="form">
6375 <br>
6376 <div class="col-sm-2"></div>
6377 <div class="col-sm-10">
6378 <p>For more info see the <a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" target="_blank">BIP32 spec</a></p>
6379 </div>
6380 <div class="form-group">
6381 <label for="bip32-path" class="col-sm-2 control-label">BIP32 Derivation Path</label>
6382 <div class="col-sm-10">
6383 <input id="bip32-path" type="text" class="path form-control" value="m/0">
6384 </div>
6385 </div>
6386 </form>
6387 </div>
6388 </div>
6389 <form class="form-horizontal" role="form">
6390 <div class="form-group">
6391 <label for="extended-priv-key" class="col-sm-2 control-label">BIP32 Extended Key</label>
6392 <div class="col-sm-10">
6393 <textarea id="extended-priv-key" class="extended-priv-key form-control" readonly="readonly"></textarea>
6394 </div>
6395 </div>
6396 <div class="form-group">
6397 <label for="extended-pub-key" class="col-sm-2 control-label">BIP32 Extended Key (addresses only)</label>
6398 <div class="col-sm-10">
6399 <textarea id="extended-pub-key" class="extended-pub-key form-control" readonly="readonly"></textarea>
6400 </div>
6401 </div>
6402 </form>
6403 </div>
6404 </div>
6405
6406 <hr>
6407
6408 <div class="row">
6409 <div class="col-md-12">
6410 <h2>Derived Addresses</h2>
6411 <p>Note these addreses are derived from the <strong>BIP32 Extended Key</strong></p>
6412 <div class="form-group">
6413 <label for="network-address-type" class="col-sm-2 control-label">Coin</label>
6414 <div class="col-sm-10">
6415 <select id="network-address-type" class="network form-control">
6416 <option value="bitcoin">Bitcoin</option>
6417 <option value="bitcoin-testnet">Bitcoin Testnet</option>
6418 <option value="litecoin">Litecoin</option>
6419 <option value="dogecoin">Dogecoin</option>
6420 </select>
6421 </div>
6422 <table class="table table-striped">
6423 <thead>
6424 <th>
6425 <div class="input-group">
6426 Index&nbsp;&nbsp;
6427 <button class="index-toggle">Toggle</button>
6428 </div>
6429 </th>
6430 <th>
6431 <div class="input-group">
6432 Address&nbsp;&nbsp;
6433 <button class="address-toggle">Toggle</button>
6434 </div>
6435 </th>
6436 <th>
6437 <div class="input-group">
6438 Private Key&nbsp;&nbsp;
6439 <button class="private-key-toggle">Toggle</button>
6440 </div>
6441 </th>
6442 </thead>
6443 <tbody class="addresses">
6444 <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
6445 <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
6446 <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
6447 <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
6448 <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
6449 </tbody>
6450 </table>
6451 </div>
6452 </div>
6453 <span>Show next </button>
6454 <input type="number" class="rows-to-add" value="20">
6455 <button class="more">Show</button>
6456
6457 <hr>
6458
6459 <div class="row">
6460 <div class="col-md-12">
6461 <h2>More info</h2>
6462 <h3>BIP39 <span class="small">Mnemonic code for generating deterministic keys</span></h3>
6463 <p>
6464 Read more at the
6465 <a href="https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki">official BIP39 spec</a>
6466 </p>
6467 <h3>BIP32 <span class="small">Hierarchical Deterministic Wallets</span></h3>
6468 <p>
6469 Read more at the
6470 <a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" target="_blank">official BIP32 spec</a>
6471 and see the demo at
6472 <a href="http://bip32.org/" target="_blank">bip32.org</a>
6473 </p>
6474 <h3>BIP44 <span class="small">Multi-Account Hierarchy for Deterministic Wallets</span></h3>
6475 <p>
6476 Read more at the
6477 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki" target="_blank">official BIP44 spec</a>
6478 </p>
6479 <h3>Private Keys</h3>
6480 <p>
6481 Use private keys at
6482 <a href="https://brainwallet.github.io/" target="_blank">brainwallet.org</a>,
6483 but be careful - it can be easy to make mistakes if you
6484 don't know what you're doing
6485 </p>
6486 </div>
6487 </div>
6488
6489 <hr>
6490
6491 <div class="row">
6492 <div class="col-md-12">
6493
6494 <h2>Offline Usage</h2>
6495
6496 <p>
6497 You can use this tool without having to be online.
6498 </p>
6499 <p>
6500 In your browser, select file save-as, and save this page
6501 as a file.
6502 </p>
6503 <p>
6504 Double-click that file to open it in a browser
6505 on any offline computer.
6506 </p>
6507 <p>
6508 Alternatively, download it from
6509 <a href="https://github.com/dcpos/bip39">
6510 https://github.com/dcpos/bip39
6511 </a>
6512
6513 </div>
6514 </div>
6515
6516 <hr>
6517
6518 <div class="row">
6519 <div class="col-md-12">
6520
6521 <h2>This project is 100% open-source code</h2>
6522
6523 <p>
6524 <span>Get the source code at - </span>
6525 <a href="https://github.com/dcpos/bip39" target="_blank">
6526 https://github.com/dcpos/bip39
6527 </a>
6528 </p>
6529
6530 <h3>Libraries</h3>
6531
6532 <p>
6533 <span>BitcoinJS - </span>
6534 <a href="https://github.com/bitcoinjs/bitcoinjs-lib" target="_blank">
6535 https://github.com/bitcoinjs/bitcoinjs-lib
6536 </a>
6537 </p>
6538
6539 <p>
6540 <span>jsBIP39 - </span>
6541 <a href="https://github.com/iancoleman/jsbip39" target="_blank">
6542 https://github.com/iancoleman/jsbip39
6543 </a>
6544 </p>
6545
6546 <p>
6547 <span>sjcl - </span>
6548 <a href="https://github.com/bitwiseshiftleft/sjcl" target="_blank">
6549 https://github.com/bitwiseshiftleft/sjcl
6550 </a>
6551 </p>
6552
6553 <p>
6554 <span>jQuery - </span>
6555 <a href="https://jquery.com/" target="_blank">
6556 https://jquery.com/
6557 </a>
6558 </p>
6559
6560 <p>
6561 <span>Twitter Bootstrap - </span>
6562 <a href="http://getbootstrap.com/" target="_blank">
6563 http://getbootstrap.com/
6564 </a>
6565 </p>
6566
6567 </div>
6568 </div>
6569
6570 </div>
6571
6572 <div class="feedback-container">
6573 <div class="feedback">Loading...</div>
6574 </div>
6575
6576 <script type="text/template" id="address-row-template">
6577 <tr>
6578 <td class="index"><span></span></td>
6579 <td class="address"><span></span></td>
6580 <td class="privkey"><span></span></td>
6581 </tr>
6582 </script>
6583 <script>
6584 /*!
6585 * jQuery JavaScript Library v2.1.1
6586 * http://jquery.com/
6587 *
6588 * Includes Sizzle.js
6589 * http://sizzlejs.com/
6590 *
6591 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
6592 * Released under the MIT license
6593 * http://jquery.org/license
6594 *
6595 * Date: 2014-05-01T17:11Z
6596 */
6597
6598 (function( global, factory ) {
6599
6600 if ( typeof module === "object" && typeof module.exports === "object" ) {
6601 // For CommonJS and CommonJS-like environments where a proper window is present,
6602 // execute the factory and get jQuery
6603 // For environments that do not inherently posses a window with a document
6604 // (such as Node.js), expose a jQuery-making factory as module.exports
6605 // This accentuates the need for the creation of a real window
6606 // e.g. var jQuery = require("jquery")(window);
6607 // See ticket #14549 for more info
6608 module.exports = global.document ?
6609 factory( global, true ) :
6610 function( w ) {
6611 if ( !w.document ) {
6612 throw new Error( "jQuery requires a window with a document" );
6613 }
6614 return factory( w );
6615 };
6616 } else {
6617 factory( global );
6618 }
6619
6620 // Pass this if window is not defined yet
6621 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
6622
6623 // Can't do this because several apps including ASP.NET trace
6624 // the stack via arguments.caller.callee and Firefox dies if
6625 // you try to trace through "use strict" call chains. (#13335)
6626 // Support: Firefox 18+
6627 //
6628
6629 var arr = [];
6630
6631 var slice = arr.slice;
6632
6633 var concat = arr.concat;
6634
6635 var push = arr.push;
6636
6637 var indexOf = arr.indexOf;
6638
6639 var class2type = {};
6640
6641 var toString = class2type.toString;
6642
6643 var hasOwn = class2type.hasOwnProperty;
6644
6645 var support = {};
6646
6647
6648
6649 var
6650 // Use the correct document accordingly with window argument (sandbox)
6651 document = window.document,
6652
6653 version = "2.1.1",
6654
6655 // Define a local copy of jQuery
6656 jQuery = function( selector, context ) {
6657 // The jQuery object is actually just the init constructor 'enhanced'
6658 // Need init if jQuery is called (just allow error to be thrown if not included)
6659 return new jQuery.fn.init( selector, context );
6660 },
6661
6662 // Support: Android<4.1
6663 // Make sure we trim BOM and NBSP
6664 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
6665
6666 // Matches dashed string for camelizing
6667 rmsPrefix = /^-ms-/,
6668 rdashAlpha = /-([\da-z])/gi,
6669
6670 // Used by jQuery.camelCase as callback to replace()
6671 fcamelCase = function( all, letter ) {
6672 return letter.toUpperCase();
6673 };
6674
6675 jQuery.fn = jQuery.prototype = {
6676 // The current version of jQuery being used
6677 jquery: version,
6678
6679 constructor: jQuery,
6680
6681 // Start with an empty selector
6682 selector: "",
6683
6684 // The default length of a jQuery object is 0
6685 length: 0,
6686
6687 toArray: function() {
6688 return slice.call( this );
6689 },
6690
6691 // Get the Nth element in the matched element set OR
6692 // Get the whole matched element set as a clean array
6693 get: function( num ) {
6694 return num != null ?
6695
6696 // Return just the one element from the set
6697 ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
6698
6699 // Return all the elements in a clean array
6700 slice.call( this );
6701 },
6702
6703 // Take an array of elements and push it onto the stack
6704 // (returning the new matched element set)
6705 pushStack: function( elems ) {
6706
6707 // Build a new jQuery matched element set
6708 var ret = jQuery.merge( this.constructor(), elems );
6709
6710 // Add the old object onto the stack (as a reference)
6711 ret.prevObject = this;
6712 ret.context = this.context;
6713
6714 // Return the newly-formed element set
6715 return ret;
6716 },
6717
6718 // Execute a callback for every element in the matched set.
6719 // (You can seed the arguments with an array of args, but this is
6720 // only used internally.)
6721 each: function( callback, args ) {
6722 return jQuery.each( this, callback, args );
6723 },
6724
6725 map: function( callback ) {
6726 return this.pushStack( jQuery.map(this, function( elem, i ) {
6727 return callback.call( elem, i, elem );
6728 }));
6729 },
6730
6731 slice: function() {
6732 return this.pushStack( slice.apply( this, arguments ) );
6733 },
6734
6735 first: function() {
6736 return this.eq( 0 );
6737 },
6738
6739 last: function() {
6740 return this.eq( -1 );
6741 },
6742
6743 eq: function( i ) {
6744 var len = this.length,
6745 j = +i + ( i < 0 ? len : 0 );
6746 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
6747 },
6748
6749 end: function() {
6750 return this.prevObject || this.constructor(null);
6751 },
6752
6753 // For internal use only.
6754 // Behaves like an Array's method, not like a jQuery method.
6755 push: push,
6756 sort: arr.sort,
6757 splice: arr.splice
6758 };
6759
6760 jQuery.extend = jQuery.fn.extend = function() {
6761 var options, name, src, copy, copyIsArray, clone,
6762 target = arguments[0] || {},
6763 i = 1,
6764 length = arguments.length,
6765 deep = false;
6766
6767 // Handle a deep copy situation
6768 if ( typeof target === "boolean" ) {
6769 deep = target;
6770
6771 // skip the boolean and the target
6772 target = arguments[ i ] || {};
6773 i++;
6774 }
6775
6776 // Handle case when target is a string or something (possible in deep copy)
6777 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
6778 target = {};
6779 }
6780
6781 // extend jQuery itself if only one argument is passed
6782 if ( i === length ) {
6783 target = this;
6784 i--;
6785 }
6786
6787 for ( ; i < length; i++ ) {
6788 // Only deal with non-null/undefined values
6789 if ( (options = arguments[ i ]) != null ) {
6790 // Extend the base object
6791 for ( name in options ) {
6792 src = target[ name ];
6793 copy = options[ name ];
6794
6795 // Prevent never-ending loop
6796 if ( target === copy ) {
6797 continue;
6798 }
6799
6800 // Recurse if we're merging plain objects or arrays
6801 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
6802 if ( copyIsArray ) {
6803 copyIsArray = false;
6804 clone = src && jQuery.isArray(src) ? src : [];
6805
6806 } else {
6807 clone = src && jQuery.isPlainObject(src) ? src : {};
6808 }
6809
6810 // Never move original objects, clone them
6811 target[ name ] = jQuery.extend( deep, clone, copy );
6812
6813 // Don't bring in undefined values
6814 } else if ( copy !== undefined ) {
6815 target[ name ] = copy;
6816 }
6817 }
6818 }
6819 }
6820
6821 // Return the modified object
6822 return target;
6823 };
6824
6825 jQuery.extend({
6826 // Unique for each copy of jQuery on the page
6827 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
6828
6829 // Assume jQuery is ready without the ready module
6830 isReady: true,
6831
6832 error: function( msg ) {
6833 throw new Error( msg );
6834 },
6835
6836 noop: function() {},
6837
6838 // See test/unit/core.js for details concerning isFunction.
6839 // Since version 1.3, DOM methods and functions like alert
6840 // aren't supported. They return false on IE (#2968).
6841 isFunction: function( obj ) {
6842 return jQuery.type(obj) === "function";
6843 },
6844
6845 isArray: Array.isArray,
6846
6847 isWindow: function( obj ) {
6848 return obj != null && obj === obj.window;
6849 },
6850
6851 isNumeric: function( obj ) {
6852 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
6853 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
6854 // subtraction forces infinities to NaN
6855 return !jQuery.isArray( obj ) && obj - parseFloat( obj ) >= 0;
6856 },
6857
6858 isPlainObject: function( obj ) {
6859 // Not plain objects:
6860 // - Any object or value whose internal [[Class]] property is not "[object Object]"
6861 // - DOM nodes
6862 // - window
6863 if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
6864 return false;
6865 }
6866
6867 if ( obj.constructor &&
6868 !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
6869 return false;
6870 }
6871
6872 // If the function hasn't returned already, we're confident that
6873 // |obj| is a plain object, created by {} or constructed with new Object
6874 return true;
6875 },
6876
6877 isEmptyObject: function( obj ) {
6878 var name;
6879 for ( name in obj ) {
6880 return false;
6881 }
6882 return true;
6883 },
6884
6885 type: function( obj ) {
6886 if ( obj == null ) {
6887 return obj + "";
6888 }
6889 // Support: Android < 4.0, iOS < 6 (functionish RegExp)
6890 return typeof obj === "object" || typeof obj === "function" ?
6891 class2type[ toString.call(obj) ] || "object" :
6892 typeof obj;
6893 },
6894
6895 // Evaluates a script in a global context
6896 globalEval: function( code ) {
6897 var script,
6898 indirect = eval;
6899
6900 code = jQuery.trim( code );
6901
6902 if ( code ) {
6903 // If the code includes a valid, prologue position
6904 // strict mode pragma, execute code by injecting a
6905 // script tag into the document.
6906 if ( code.indexOf("use strict") === 1 ) {
6907 script = document.createElement("script");
6908 script.text = code;
6909 document.head.appendChild( script ).parentNode.removeChild( script );
6910 } else {
6911 // Otherwise, avoid the DOM node creation, insertion
6912 // and removal by using an indirect global eval
6913 indirect( code );
6914 }
6915 }
6916 },
6917
6918 // Convert dashed to camelCase; used by the css and data modules
6919 // Microsoft forgot to hump their vendor prefix (#9572)
6920 camelCase: function( string ) {
6921 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
6922 },
6923
6924 nodeName: function( elem, name ) {
6925 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
6926 },
6927
6928 // args is for internal usage only
6929 each: function( obj, callback, args ) {
6930 var value,
6931 i = 0,
6932 length = obj.length,
6933 isArray = isArraylike( obj );
6934
6935 if ( args ) {
6936 if ( isArray ) {
6937 for ( ; i < length; i++ ) {
6938 value = callback.apply( obj[ i ], args );
6939
6940 if ( value === false ) {
6941 break;
6942 }
6943 }
6944 } else {
6945 for ( i in obj ) {
6946 value = callback.apply( obj[ i ], args );
6947
6948 if ( value === false ) {
6949 break;
6950 }
6951 }
6952 }
6953
6954 // A special, fast, case for the most common use of each
6955 } else {
6956 if ( isArray ) {
6957 for ( ; i < length; i++ ) {
6958 value = callback.call( obj[ i ], i, obj[ i ] );
6959
6960 if ( value === false ) {
6961 break;
6962 }
6963 }
6964 } else {
6965 for ( i in obj ) {
6966 value = callback.call( obj[ i ], i, obj[ i ] );
6967
6968 if ( value === false ) {
6969 break;
6970 }
6971 }
6972 }
6973 }
6974
6975 return obj;
6976 },
6977
6978 // Support: Android<4.1
6979 trim: function( text ) {
6980 return text == null ?
6981 "" :
6982 ( text + "" ).replace( rtrim, "" );
6983 },
6984
6985 // results is for internal usage only
6986 makeArray: function( arr, results ) {
6987 var ret = results || [];
6988
6989 if ( arr != null ) {
6990 if ( isArraylike( Object(arr) ) ) {
6991 jQuery.merge( ret,
6992 typeof arr === "string" ?
6993 [ arr ] : arr
6994 );
6995 } else {
6996 push.call( ret, arr );
6997 }
6998 }
6999
7000 return ret;
7001 },
7002
7003 inArray: function( elem, arr, i ) {
7004 return arr == null ? -1 : indexOf.call( arr, elem, i );
7005 },
7006
7007 merge: function( first, second ) {
7008 var len = +second.length,
7009 j = 0,
7010 i = first.length;
7011
7012 for ( ; j < len; j++ ) {
7013 first[ i++ ] = second[ j ];
7014 }
7015
7016 first.length = i;
7017
7018 return first;
7019 },
7020
7021 grep: function( elems, callback, invert ) {
7022 var callbackInverse,
7023 matches = [],
7024 i = 0,
7025 length = elems.length,
7026 callbackExpect = !invert;
7027
7028 // Go through the array, only saving the items
7029 // that pass the validator function
7030 for ( ; i < length; i++ ) {
7031 callbackInverse = !callback( elems[ i ], i );
7032 if ( callbackInverse !== callbackExpect ) {
7033 matches.push( elems[ i ] );
7034 }
7035 }
7036
7037 return matches;
7038 },
7039
7040 // arg is for internal usage only
7041 map: function( elems, callback, arg ) {
7042 var value,
7043 i = 0,
7044 length = elems.length,
7045 isArray = isArraylike( elems ),
7046 ret = [];
7047
7048 // Go through the array, translating each of the items to their new values
7049 if ( isArray ) {
7050 for ( ; i < length; i++ ) {
7051 value = callback( elems[ i ], i, arg );
7052
7053 if ( value != null ) {
7054 ret.push( value );
7055 }
7056 }
7057
7058 // Go through every key on the object,
7059 } else {
7060 for ( i in elems ) {
7061 value = callback( elems[ i ], i, arg );
7062
7063 if ( value != null ) {
7064 ret.push( value );
7065 }
7066 }
7067 }
7068
7069 // Flatten any nested arrays
7070 return concat.apply( [], ret );
7071 },
7072
7073 // A global GUID counter for objects
7074 guid: 1,
7075
7076 // Bind a function to a context, optionally partially applying any
7077 // arguments.
7078 proxy: function( fn, context ) {
7079 var tmp, args, proxy;
7080
7081 if ( typeof context === "string" ) {
7082 tmp = fn[ context ];
7083 context = fn;
7084 fn = tmp;
7085 }
7086
7087 // Quick check to determine if target is callable, in the spec
7088 // this throws a TypeError, but we will just return undefined.
7089 if ( !jQuery.isFunction( fn ) ) {
7090 return undefined;
7091 }
7092
7093 // Simulated bind
7094 args = slice.call( arguments, 2 );
7095 proxy = function() {
7096 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
7097 };
7098
7099 // Set the guid of unique handler to the same of original handler, so it can be removed
7100 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
7101
7102 return proxy;
7103 },
7104
7105 now: Date.now,
7106
7107 // jQuery.support is not used in Core but other projects attach their
7108 // properties to it so it needs to exist.
7109 support: support
7110 });
7111
7112 // Populate the class2type map
7113 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
7114 class2type[ "[object " + name + "]" ] = name.toLowerCase();
7115 });
7116
7117 function isArraylike( obj ) {
7118 var length = obj.length,
7119 type = jQuery.type( obj );
7120
7121 if ( type === "function" || jQuery.isWindow( obj ) ) {
7122 return false;
7123 }
7124
7125 if ( obj.nodeType === 1 && length ) {
7126 return true;
7127 }
7128
7129 return type === "array" || length === 0 ||
7130 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
7131 }
7132 var Sizzle =
7133 /*!
7134 * Sizzle CSS Selector Engine v1.10.19
7135 * http://sizzlejs.com/
7136 *
7137 * Copyright 2013 jQuery Foundation, Inc. and other contributors
7138 * Released under the MIT license
7139 * http://jquery.org/license
7140 *
7141 * Date: 2014-04-18
7142 */
7143 (function( window ) {
7144
7145 var i,
7146 support,
7147 Expr,
7148 getText,
7149 isXML,
7150 tokenize,
7151 compile,
7152 select,
7153 outermostContext,
7154 sortInput,
7155 hasDuplicate,
7156
7157 // Local document vars
7158 setDocument,
7159 document,
7160 docElem,
7161 documentIsHTML,
7162 rbuggyQSA,
7163 rbuggyMatches,
7164 matches,
7165 contains,
7166
7167 // Instance-specific data
7168 expando = "sizzle" + -(new Date()),
7169 preferredDoc = window.document,
7170 dirruns = 0,
7171 done = 0,
7172 classCache = createCache(),
7173 tokenCache = createCache(),
7174 compilerCache = createCache(),
7175 sortOrder = function( a, b ) {
7176 if ( a === b ) {
7177 hasDuplicate = true;
7178 }
7179 return 0;
7180 },
7181
7182 // General-purpose constants
7183 strundefined = typeof undefined,
7184 MAX_NEGATIVE = 1 << 31,
7185
7186 // Instance methods
7187 hasOwn = ({}).hasOwnProperty,
7188 arr = [],
7189 pop = arr.pop,
7190 push_native = arr.push,
7191 push = arr.push,
7192 slice = arr.slice,
7193 // Use a stripped-down indexOf if we can't use a native one
7194 indexOf = arr.indexOf || function( elem ) {
7195 var i = 0,
7196 len = this.length;
7197 for ( ; i < len; i++ ) {
7198 if ( this[i] === elem ) {
7199 return i;
7200 }
7201 }
7202 return -1;
7203 },
7204
7205 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
7206
7207 // Regular expressions
7208
7209 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
7210 whitespace = "[\\x20\\t\\r\\n\\f]",
7211 // http://www.w3.org/TR/css3-syntax/#characters
7212 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
7213
7214 // Loosely modeled on CSS identifier characters
7215 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
7216 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
7217 identifier = characterEncoding.replace( "w", "w#" ),
7218
7219 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
7220 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace +
7221 // Operator (capture 2)
7222 "*([*^$|!~]?=)" + whitespace +
7223 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
7224 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
7225 "*\\]",
7226
7227 pseudos = ":(" + characterEncoding + ")(?:\\((" +
7228 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
7229 // 1. quoted (capture 3; capture 4 or capture 5)
7230 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
7231 // 2. simple (capture 6)
7232 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
7233 // 3. anything else (capture 2)
7234 ".*" +
7235 ")\\)|)",
7236
7237 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
7238 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
7239
7240 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
7241 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
7242
7243 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
7244
7245 rpseudo = new RegExp( pseudos ),
7246 ridentifier = new RegExp( "^" + identifier + "$" ),
7247
7248 matchExpr = {
7249 "ID": new RegExp( "^#(" + characterEncoding + ")" ),
7250 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
7251 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
7252 "ATTR": new RegExp( "^" + attributes ),
7253 "PSEUDO": new RegExp( "^" + pseudos ),
7254 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
7255 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
7256 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
7257 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
7258 // For use in libraries implementing .is()
7259 // We use this for POS matching in `select`
7260 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
7261 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
7262 },
7263
7264 rinputs = /^(?:input|select|textarea|button)$/i,
7265 rheader = /^h\d$/i,
7266
7267 rnative = /^[^{]+\{\s*\[native \w/,
7268
7269 // Easily-parseable/retrievable ID or TAG or CLASS selectors
7270 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
7271
7272 rsibling = /[+~]/,
7273 rescape = /'|\\/g,
7274
7275 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
7276 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
7277 funescape = function( _, escaped, escapedWhitespace ) {
7278 var high = "0x" + escaped - 0x10000;
7279 // NaN means non-codepoint
7280 // Support: Firefox<24
7281 // Workaround erroneous numeric interpretation of +"0x"
7282 return high !== high || escapedWhitespace ?
7283 escaped :
7284 high < 0 ?
7285 // BMP codepoint
7286 String.fromCharCode( high + 0x10000 ) :
7287 // Supplemental Plane codepoint (surrogate pair)
7288 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
7289 };
7290
7291 // Optimize for push.apply( _, NodeList )
7292 try {
7293 push.apply(
7294 (arr = slice.call( preferredDoc.childNodes )),
7295 preferredDoc.childNodes
7296 );
7297 // Support: Android<4.0
7298 // Detect silently failing push.apply
7299 arr[ preferredDoc.childNodes.length ].nodeType;
7300 } catch ( e ) {
7301 push = { apply: arr.length ?
7302
7303 // Leverage slice if possible
7304 function( target, els ) {
7305 push_native.apply( target, slice.call(els) );
7306 } :
7307
7308 // Support: IE<9
7309 // Otherwise append directly
7310 function( target, els ) {
7311 var j = target.length,
7312 i = 0;
7313 // Can't trust NodeList.length
7314 while ( (target[j++] = els[i++]) ) {}
7315 target.length = j - 1;
7316 }
7317 };
7318 }
7319
7320 function Sizzle( selector, context, results, seed ) {
7321 var match, elem, m, nodeType,
7322 // QSA vars
7323 i, groups, old, nid, newContext, newSelector;
7324
7325 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
7326 setDocument( context );
7327 }
7328
7329 context = context || document;
7330 results = results || [];
7331
7332 if ( !selector || typeof selector !== "string" ) {
7333 return results;
7334 }
7335
7336 if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
7337 return [];
7338 }
7339
7340 if ( documentIsHTML && !seed ) {
7341
7342 // Shortcuts
7343 if ( (match = rquickExpr.exec( selector )) ) {
7344 // Speed-up: Sizzle("#ID")
7345 if ( (m = match[1]) ) {
7346 if ( nodeType === 9 ) {
7347 elem = context.getElementById( m );
7348 // Check parentNode to catch when Blackberry 4.6 returns
7349 // nodes that are no longer in the document (jQuery #6963)
7350 if ( elem && elem.parentNode ) {
7351 // Handle the case where IE, Opera, and Webkit return items
7352 // by name instead of ID
7353 if ( elem.id === m ) {
7354 results.push( elem );
7355 return results;
7356 }
7357 } else {
7358 return results;
7359 }
7360 } else {
7361 // Context is not a document
7362 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
7363 contains( context, elem ) && elem.id === m ) {
7364 results.push( elem );
7365 return results;
7366 }
7367 }
7368
7369 // Speed-up: Sizzle("TAG")
7370 } else if ( match[2] ) {
7371 push.apply( results, context.getElementsByTagName( selector ) );
7372 return results;
7373
7374 // Speed-up: Sizzle(".CLASS")
7375 } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
7376 push.apply( results, context.getElementsByClassName( m ) );
7377 return results;
7378 }
7379 }
7380
7381 // QSA path
7382 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
7383 nid = old = expando;
7384 newContext = context;
7385 newSelector = nodeType === 9 && selector;
7386
7387 // qSA works strangely on Element-rooted queries
7388 // We can work around this by specifying an extra ID on the root
7389 // and working up from there (Thanks to Andrew Dupont for the technique)
7390 // IE 8 doesn't work on object elements
7391 if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
7392 groups = tokenize( selector );
7393
7394 if ( (old = context.getAttribute("id")) ) {
7395 nid = old.replace( rescape, "\\$&" );
7396 } else {
7397 context.setAttribute( "id", nid );
7398 }
7399 nid = "[id='" + nid + "'] ";
7400
7401 i = groups.length;
7402 while ( i-- ) {
7403 groups[i] = nid + toSelector( groups[i] );
7404 }
7405 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
7406 newSelector = groups.join(",");
7407 }
7408
7409 if ( newSelector ) {
7410 try {
7411 push.apply( results,
7412 newContext.querySelectorAll( newSelector )
7413 );
7414 return results;
7415 } catch(qsaError) {
7416 } finally {
7417 if ( !old ) {
7418 context.removeAttribute("id");
7419 }
7420 }
7421 }
7422 }
7423 }
7424
7425 // All others
7426 return select( selector.replace( rtrim, "$1" ), context, results, seed );
7427 }
7428
7429 /**
7430 * Create key-value caches of limited size
7431 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
7432 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
7433 * deleting the oldest entry
7434 */
7435 function createCache() {
7436 var keys = [];
7437
7438 function cache( key, value ) {
7439 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
7440 if ( keys.push( key + " " ) > Expr.cacheLength ) {
7441 // Only keep the most recent entries
7442 delete cache[ keys.shift() ];
7443 }
7444 return (cache[ key + " " ] = value);
7445 }
7446 return cache;
7447 }
7448
7449 /**
7450 * Mark a function for special use by Sizzle
7451 * @param {Function} fn The function to mark
7452 */
7453 function markFunction( fn ) {
7454 fn[ expando ] = true;
7455 return fn;
7456 }
7457
7458 /**
7459 * Support testing using an element
7460 * @param {Function} fn Passed the created div and expects a boolean result
7461 */
7462 function assert( fn ) {
7463 var div = document.createElement("div");
7464
7465 try {
7466 return !!fn( div );
7467 } catch (e) {
7468 return false;
7469 } finally {
7470 // Remove from its parent by default
7471 if ( div.parentNode ) {
7472 div.parentNode.removeChild( div );
7473 }
7474 // release memory in IE
7475 div = null;
7476 }
7477 }
7478
7479 /**
7480 * Adds the same handler for all of the specified attrs
7481 * @param {String} attrs Pipe-separated list of attributes
7482 * @param {Function} handler The method that will be applied
7483 */
7484 function addHandle( attrs, handler ) {
7485 var arr = attrs.split("|"),
7486 i = attrs.length;
7487
7488 while ( i-- ) {
7489 Expr.attrHandle[ arr[i] ] = handler;
7490 }
7491 }
7492
7493 /**
7494 * Checks document order of two siblings
7495 * @param {Element} a
7496 * @param {Element} b
7497 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
7498 */
7499 function siblingCheck( a, b ) {
7500 var cur = b && a,
7501 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
7502 ( ~b.sourceIndex || MAX_NEGATIVE ) -
7503 ( ~a.sourceIndex || MAX_NEGATIVE );
7504
7505 // Use IE sourceIndex if available on both nodes
7506 if ( diff ) {
7507 return diff;
7508 }
7509
7510 // Check if b follows a
7511 if ( cur ) {
7512 while ( (cur = cur.nextSibling) ) {
7513 if ( cur === b ) {
7514 return -1;
7515 }
7516 }
7517 }
7518
7519 return a ? 1 : -1;
7520 }
7521
7522 /**
7523 * Returns a function to use in pseudos for input types
7524 * @param {String} type
7525 */
7526 function createInputPseudo( type ) {
7527 return function( elem ) {
7528 var name = elem.nodeName.toLowerCase();
7529 return name === "input" && elem.type === type;
7530 };
7531 }
7532
7533 /**
7534 * Returns a function to use in pseudos for buttons
7535 * @param {String} type
7536 */
7537 function createButtonPseudo( type ) {
7538 return function( elem ) {
7539 var name = elem.nodeName.toLowerCase();
7540 return (name === "input" || name === "button") && elem.type === type;
7541 };
7542 }
7543
7544 /**
7545 * Returns a function to use in pseudos for positionals
7546 * @param {Function} fn
7547 */
7548 function createPositionalPseudo( fn ) {
7549 return markFunction(function( argument ) {
7550 argument = +argument;
7551 return markFunction(function( seed, matches ) {
7552 var j,
7553 matchIndexes = fn( [], seed.length, argument ),
7554 i = matchIndexes.length;
7555
7556 // Match elements found at the specified indexes
7557 while ( i-- ) {
7558 if ( seed[ (j = matchIndexes[i]) ] ) {
7559 seed[j] = !(matches[j] = seed[j]);
7560 }
7561 }
7562 });
7563 });
7564 }
7565
7566 /**
7567 * Checks a node for validity as a Sizzle context
7568 * @param {Element|Object=} context
7569 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
7570 */
7571 function testContext( context ) {
7572 return context && typeof context.getElementsByTagName !== strundefined && context;
7573 }
7574
7575 // Expose support vars for convenience
7576 support = Sizzle.support = {};
7577
7578 /**
7579 * Detects XML nodes
7580 * @param {Element|Object} elem An element or a document
7581 * @returns {Boolean} True iff elem is a non-HTML XML node
7582 */
7583 isXML = Sizzle.isXML = function( elem ) {
7584 // documentElement is verified for cases where it doesn't yet exist
7585 // (such as loading iframes in IE - #4833)
7586 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
7587 return documentElement ? documentElement.nodeName !== "HTML" : false;
7588 };
7589
7590 /**
7591 * Sets document-related variables once based on the current document
7592 * @param {Element|Object} [doc] An element or document object to use to set the document
7593 * @returns {Object} Returns the current document
7594 */
7595 setDocument = Sizzle.setDocument = function( node ) {
7596 var hasCompare,
7597 doc = node ? node.ownerDocument || node : preferredDoc,
7598 parent = doc.defaultView;
7599
7600 // If no document and documentElement is available, return
7601 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
7602 return document;
7603 }
7604
7605 // Set our document
7606 document = doc;
7607 docElem = doc.documentElement;
7608
7609 // Support tests
7610 documentIsHTML = !isXML( doc );
7611
7612 // Support: IE>8
7613 // If iframe document is assigned to "document" variable and if iframe has been reloaded,
7614 // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
7615 // IE6-8 do not support the defaultView property so parent will be undefined
7616 if ( parent && parent !== parent.top ) {
7617 // IE11 does not have attachEvent, so all must suffer
7618 if ( parent.addEventListener ) {
7619 parent.addEventListener( "unload", function() {
7620 setDocument();
7621 }, false );
7622 } else if ( parent.attachEvent ) {
7623 parent.attachEvent( "onunload", function() {
7624 setDocument();
7625 });
7626 }
7627 }
7628
7629 /* Attributes
7630 ---------------------------------------------------------------------- */
7631
7632 // Support: IE<8
7633 // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
7634 support.attributes = assert(function( div ) {
7635 div.className = "i";
7636 return !div.getAttribute("className");
7637 });
7638
7639 /* getElement(s)By*
7640 ---------------------------------------------------------------------- */
7641
7642 // Check if getElementsByTagName("*") returns only elements
7643 support.getElementsByTagName = assert(function( div ) {
7644 div.appendChild( doc.createComment("") );
7645 return !div.getElementsByTagName("*").length;
7646 });
7647
7648 // Check if getElementsByClassName can be trusted
7649 support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
7650 div.innerHTML = "<div class='a'></div><div class='a i'></div>";
7651
7652 // Support: Safari<4
7653 // Catch class over-caching
7654 div.firstChild.className = "i";
7655 // Support: Opera<10
7656 // Catch gEBCN failure to find non-leading classes
7657 return div.getElementsByClassName("i").length === 2;
7658 });
7659
7660 // Support: IE<10
7661 // Check if getElementById returns elements by name
7662 // The broken getElementById methods don't pick up programatically-set names,
7663 // so use a roundabout getElementsByName test
7664 support.getById = assert(function( div ) {
7665 docElem.appendChild( div ).id = expando;
7666 return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
7667 });
7668
7669 // ID find and filter
7670 if ( support.getById ) {
7671 Expr.find["ID"] = function( id, context ) {
7672 if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
7673 var m = context.getElementById( id );
7674 // Check parentNode to catch when Blackberry 4.6 returns
7675 // nodes that are no longer in the document #6963
7676 return m && m.parentNode ? [ m ] : [];
7677 }
7678 };
7679 Expr.filter["ID"] = function( id ) {
7680 var attrId = id.replace( runescape, funescape );
7681 return function( elem ) {
7682 return elem.getAttribute("id") === attrId;
7683 };
7684 };
7685 } else {
7686 // Support: IE6/7
7687 // getElementById is not reliable as a find shortcut
7688 delete Expr.find["ID"];
7689
7690 Expr.filter["ID"] = function( id ) {
7691 var attrId = id.replace( runescape, funescape );
7692 return function( elem ) {
7693 var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
7694 return node && node.value === attrId;
7695 };
7696 };
7697 }
7698
7699 // Tag
7700 Expr.find["TAG"] = support.getElementsByTagName ?
7701 function( tag, context ) {
7702 if ( typeof context.getElementsByTagName !== strundefined ) {
7703 return context.getElementsByTagName( tag );
7704 }
7705 } :
7706 function( tag, context ) {
7707 var elem,
7708 tmp = [],
7709 i = 0,
7710 results = context.getElementsByTagName( tag );
7711
7712 // Filter out possible comments
7713 if ( tag === "*" ) {
7714 while ( (elem = results[i++]) ) {
7715 if ( elem.nodeType === 1 ) {
7716 tmp.push( elem );
7717 }
7718 }
7719
7720 return tmp;
7721 }
7722 return results;
7723 };
7724
7725 // Class
7726 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
7727 if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
7728 return context.getElementsByClassName( className );
7729 }
7730 };
7731
7732 /* QSA/matchesSelector
7733 ---------------------------------------------------------------------- */
7734
7735 // QSA and matchesSelector support
7736
7737 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
7738 rbuggyMatches = [];
7739
7740 // qSa(:focus) reports false when true (Chrome 21)
7741 // We allow this because of a bug in IE8/9 that throws an error
7742 // whenever `document.activeElement` is accessed on an iframe
7743 // So, we allow :focus to pass through QSA all the time to avoid the IE error
7744 // See http://bugs.jquery.com/ticket/13378
7745 rbuggyQSA = [];
7746
7747 if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
7748 // Build QSA regex
7749 // Regex strategy adopted from Diego Perini
7750 assert(function( div ) {
7751 // Select is set to empty string on purpose
7752 // This is to test IE's treatment of not explicitly
7753 // setting a boolean content attribute,
7754 // since its presence should be enough
7755 // http://bugs.jquery.com/ticket/12359
7756 div.innerHTML = "<select msallowclip=''><option selected=''></option></select>";
7757
7758 // Support: IE8, Opera 11-12.16
7759 // Nothing should be selected when empty strings follow ^= or $= or *=
7760 // The test attribute must be unknown in Opera but "safe" for WinRT
7761 // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
7762 if ( div.querySelectorAll("[msallowclip^='']").length ) {
7763 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
7764 }
7765
7766 // Support: IE8
7767 // Boolean attributes and "value" are not treated correctly
7768 if ( !div.querySelectorAll("[selected]").length ) {
7769 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
7770 }
7771
7772 // Webkit/Opera - :checked should return selected option elements
7773 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
7774 // IE8 throws error here and will not see later tests
7775 if ( !div.querySelectorAll(":checked").length ) {
7776 rbuggyQSA.push(":checked");
7777 }
7778 });
7779
7780 assert(function( div ) {
7781 // Support: Windows 8 Native Apps
7782 // The type and name attributes are restricted during .innerHTML assignment
7783 var input = doc.createElement("input");
7784 input.setAttribute( "type", "hidden" );
7785 div.appendChild( input ).setAttribute( "name", "D" );
7786
7787 // Support: IE8
7788 // Enforce case-sensitivity of name attribute
7789 if ( div.querySelectorAll("[name=d]").length ) {
7790 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
7791 }
7792
7793 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
7794 // IE8 throws error here and will not see later tests
7795 if ( !div.querySelectorAll(":enabled").length ) {
7796 rbuggyQSA.push( ":enabled", ":disabled" );
7797 }
7798
7799 // Opera 10-11 does not throw on post-comma invalid pseudos
7800 div.querySelectorAll("*,:x");
7801 rbuggyQSA.push(",.*:");
7802 });
7803 }
7804
7805 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
7806 docElem.webkitMatchesSelector ||
7807 docElem.mozMatchesSelector ||
7808 docElem.oMatchesSelector ||
7809 docElem.msMatchesSelector) )) ) {
7810
7811 assert(function( div ) {
7812 // Check to see if it's possible to do matchesSelector
7813 // on a disconnected node (IE 9)
7814 support.disconnectedMatch = matches.call( div, "div" );
7815
7816 // This should fail with an exception
7817 // Gecko does not error, returns false instead
7818 matches.call( div, "[s!='']:x" );
7819 rbuggyMatches.push( "!=", pseudos );
7820 });
7821 }
7822
7823 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
7824 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
7825
7826 /* Contains
7827 ---------------------------------------------------------------------- */
7828 hasCompare = rnative.test( docElem.compareDocumentPosition );
7829
7830 // Element contains another
7831 // Purposefully does not implement inclusive descendent
7832 // As in, an element does not contain itself
7833 contains = hasCompare || rnative.test( docElem.contains ) ?
7834 function( a, b ) {
7835 var adown = a.nodeType === 9 ? a.documentElement : a,
7836 bup = b && b.parentNode;
7837 return a === bup || !!( bup && bup.nodeType === 1 && (
7838 adown.contains ?
7839 adown.contains( bup ) :
7840 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
7841 ));
7842 } :
7843 function( a, b ) {
7844 if ( b ) {
7845 while ( (b = b.parentNode) ) {
7846 if ( b === a ) {
7847 return true;
7848 }
7849 }
7850 }
7851 return false;
7852 };
7853
7854 /* Sorting
7855 ---------------------------------------------------------------------- */
7856
7857 // Document order sorting
7858 sortOrder = hasCompare ?
7859 function( a, b ) {
7860
7861 // Flag for duplicate removal
7862 if ( a === b ) {
7863 hasDuplicate = true;
7864 return 0;
7865 }
7866
7867 // Sort on method existence if only one input has compareDocumentPosition
7868 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
7869 if ( compare ) {
7870 return compare;
7871 }
7872
7873 // Calculate position if both inputs belong to the same document
7874 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
7875 a.compareDocumentPosition( b ) :
7876
7877 // Otherwise we know they are disconnected
7878 1;
7879
7880 // Disconnected nodes
7881 if ( compare & 1 ||
7882 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
7883
7884 // Choose the first element that is related to our preferred document
7885 if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
7886 return -1;
7887 }
7888 if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
7889 return 1;
7890 }
7891
7892 // Maintain original order
7893 return sortInput ?
7894 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
7895 0;
7896 }
7897
7898 return compare & 4 ? -1 : 1;
7899 } :
7900 function( a, b ) {
7901 // Exit early if the nodes are identical
7902 if ( a === b ) {
7903 hasDuplicate = true;
7904 return 0;
7905 }
7906
7907 var cur,
7908 i = 0,
7909 aup = a.parentNode,
7910 bup = b.parentNode,
7911 ap = [ a ],
7912 bp = [ b ];
7913
7914 // Parentless nodes are either documents or disconnected
7915 if ( !aup || !bup ) {
7916 return a === doc ? -1 :
7917 b === doc ? 1 :
7918 aup ? -1 :
7919 bup ? 1 :
7920 sortInput ?
7921 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
7922 0;
7923
7924 // If the nodes are siblings, we can do a quick check
7925 } else if ( aup === bup ) {
7926 return siblingCheck( a, b );
7927 }
7928
7929 // Otherwise we need full lists of their ancestors for comparison
7930 cur = a;
7931 while ( (cur = cur.parentNode) ) {
7932 ap.unshift( cur );
7933 }
7934 cur = b;
7935 while ( (cur = cur.parentNode) ) {
7936 bp.unshift( cur );
7937 }
7938
7939 // Walk down the tree looking for a discrepancy
7940 while ( ap[i] === bp[i] ) {
7941 i++;
7942 }
7943
7944 return i ?
7945 // Do a sibling check if the nodes have a common ancestor
7946 siblingCheck( ap[i], bp[i] ) :
7947
7948 // Otherwise nodes in our document sort first
7949 ap[i] === preferredDoc ? -1 :
7950 bp[i] === preferredDoc ? 1 :
7951 0;
7952 };
7953
7954 return doc;
7955 };
7956
7957 Sizzle.matches = function( expr, elements ) {
7958 return Sizzle( expr, null, null, elements );
7959 };
7960
7961 Sizzle.matchesSelector = function( elem, expr ) {
7962 // Set document vars if needed
7963 if ( ( elem.ownerDocument || elem ) !== document ) {
7964 setDocument( elem );
7965 }
7966
7967 // Make sure that attribute selectors are quoted
7968 expr = expr.replace( rattributeQuotes, "='$1']" );
7969
7970 if ( support.matchesSelector && documentIsHTML &&
7971 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
7972 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
7973
7974 try {
7975 var ret = matches.call( elem, expr );
7976
7977 // IE 9's matchesSelector returns false on disconnected nodes
7978 if ( ret || support.disconnectedMatch ||
7979 // As well, disconnected nodes are said to be in a document
7980 // fragment in IE 9
7981 elem.document && elem.document.nodeType !== 11 ) {
7982 return ret;
7983 }
7984 } catch(e) {}
7985 }
7986
7987 return Sizzle( expr, document, null, [ elem ] ).length > 0;
7988 };
7989
7990 Sizzle.contains = function( context, elem ) {
7991 // Set document vars if needed
7992 if ( ( context.ownerDocument || context ) !== document ) {
7993 setDocument( context );
7994 }
7995 return contains( context, elem );
7996 };
7997
7998 Sizzle.attr = function( elem, name ) {
7999 // Set document vars if needed
8000 if ( ( elem.ownerDocument || elem ) !== document ) {
8001 setDocument( elem );
8002 }
8003
8004 var fn = Expr.attrHandle[ name.toLowerCase() ],
8005 // Don't get fooled by Object.prototype properties (jQuery #13807)
8006 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
8007 fn( elem, name, !documentIsHTML ) :
8008 undefined;
8009
8010 return val !== undefined ?
8011 val :
8012 support.attributes || !documentIsHTML ?
8013 elem.getAttribute( name ) :
8014 (val = elem.getAttributeNode(name)) && val.specified ?
8015 val.value :
8016 null;
8017 };
8018
8019 Sizzle.error = function( msg ) {
8020 throw new Error( "Syntax error, unrecognized expression: " + msg );
8021 };
8022
8023 /**
8024 * Document sorting and removing duplicates
8025 * @param {ArrayLike} results
8026 */
8027 Sizzle.uniqueSort = function( results ) {
8028 var elem,
8029 duplicates = [],
8030 j = 0,
8031 i = 0;
8032
8033 // Unless we *know* we can detect duplicates, assume their presence
8034 hasDuplicate = !support.detectDuplicates;
8035 sortInput = !support.sortStable && results.slice( 0 );
8036 results.sort( sortOrder );
8037
8038 if ( hasDuplicate ) {
8039 while ( (elem = results[i++]) ) {
8040 if ( elem === results[ i ] ) {
8041 j = duplicates.push( i );
8042 }
8043 }
8044 while ( j-- ) {
8045 results.splice( duplicates[ j ], 1 );
8046 }
8047 }
8048
8049 // Clear input after sorting to release objects
8050 // See https://github.com/jquery/sizzle/pull/225
8051 sortInput = null;
8052
8053 return results;
8054 };
8055
8056 /**
8057 * Utility function for retrieving the text value of an array of DOM nodes
8058 * @param {Array|Element} elem
8059 */
8060 getText = Sizzle.getText = function( elem ) {
8061 var node,
8062 ret = "",
8063 i = 0,
8064 nodeType = elem.nodeType;
8065
8066 if ( !nodeType ) {
8067 // If no nodeType, this is expected to be an array
8068 while ( (node = elem[i++]) ) {
8069 // Do not traverse comment nodes
8070 ret += getText( node );
8071 }
8072 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
8073 // Use textContent for elements
8074 // innerText usage removed for consistency of new lines (jQuery #11153)
8075 if ( typeof elem.textContent === "string" ) {
8076 return elem.textContent;
8077 } else {
8078 // Traverse its children
8079 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
8080 ret += getText( elem );
8081 }
8082 }
8083 } else if ( nodeType === 3 || nodeType === 4 ) {
8084 return elem.nodeValue;
8085 }
8086 // Do not include comment or processing instruction nodes
8087
8088 return ret;
8089 };
8090
8091 Expr = Sizzle.selectors = {
8092
8093 // Can be adjusted by the user
8094 cacheLength: 50,
8095
8096 createPseudo: markFunction,
8097
8098 match: matchExpr,
8099
8100 attrHandle: {},
8101
8102 find: {},
8103
8104 relative: {
8105 ">": { dir: "parentNode", first: true },
8106 " ": { dir: "parentNode" },
8107 "+": { dir: "previousSibling", first: true },
8108 "~": { dir: "previousSibling" }
8109 },
8110
8111 preFilter: {
8112 "ATTR": function( match ) {
8113 match[1] = match[1].replace( runescape, funescape );
8114
8115 // Move the given value to match[3] whether quoted or unquoted
8116 match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
8117
8118 if ( match[2] === "~=" ) {
8119 match[3] = " " + match[3] + " ";
8120 }
8121
8122 return match.slice( 0, 4 );
8123 },
8124
8125 "CHILD": function( match ) {
8126 /* matches from matchExpr["CHILD"]
8127 1 type (only|nth|...)
8128 2 what (child|of-type)
8129 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
8130 4 xn-component of xn+y argument ([+-]?\d*n|)
8131 5 sign of xn-component
8132 6 x of xn-component
8133 7 sign of y-component
8134 8 y of y-component
8135 */
8136 match[1] = match[1].toLowerCase();
8137
8138 if ( match[1].slice( 0, 3 ) === "nth" ) {
8139 // nth-* requires argument
8140 if ( !match[3] ) {
8141 Sizzle.error( match[0] );
8142 }
8143
8144 // numeric x and y parameters for Expr.filter.CHILD
8145 // remember that false/true cast respectively to 0/1
8146 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
8147 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
8148
8149 // other types prohibit arguments
8150 } else if ( match[3] ) {
8151 Sizzle.error( match[0] );
8152 }
8153
8154 return match;
8155 },
8156
8157 "PSEUDO": function( match ) {
8158 var excess,
8159 unquoted = !match[6] && match[2];
8160
8161 if ( matchExpr["CHILD"].test( match[0] ) ) {
8162 return null;
8163 }
8164
8165 // Accept quoted arguments as-is
8166 if ( match[3] ) {
8167 match[2] = match[4] || match[5] || "";
8168
8169 // Strip excess characters from unquoted arguments
8170 } else if ( unquoted && rpseudo.test( unquoted ) &&
8171 // Get excess from tokenize (recursively)
8172 (excess = tokenize( unquoted, true )) &&
8173 // advance to the next closing parenthesis
8174 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
8175
8176 // excess is a negative index
8177 match[0] = match[0].slice( 0, excess );
8178 match[2] = unquoted.slice( 0, excess );
8179 }
8180
8181 // Return only captures needed by the pseudo filter method (type and argument)
8182 return match.slice( 0, 3 );
8183 }
8184 },
8185
8186 filter: {
8187
8188 "TAG": function( nodeNameSelector ) {
8189 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
8190 return nodeNameSelector === "*" ?
8191 function() { return true; } :
8192 function( elem ) {
8193 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
8194 };
8195 },
8196
8197 "CLASS": function( className ) {
8198 var pattern = classCache[ className + " " ];
8199
8200 return pattern ||
8201 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
8202 classCache( className, function( elem ) {
8203 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
8204 });
8205 },
8206
8207 "ATTR": function( name, operator, check ) {
8208 return function( elem ) {
8209 var result = Sizzle.attr( elem, name );
8210
8211 if ( result == null ) {
8212 return operator === "!=";
8213 }
8214 if ( !operator ) {
8215 return true;
8216 }
8217
8218 result += "";
8219
8220 return operator === "=" ? result === check :
8221 operator === "!=" ? result !== check :
8222 operator === "^=" ? check && result.indexOf( check ) === 0 :
8223 operator === "*=" ? check && result.indexOf( check ) > -1 :
8224 operator === "$=" ? check && result.slice( -check.length ) === check :
8225 operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
8226 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
8227 false;
8228 };
8229 },
8230
8231 "CHILD": function( type, what, argument, first, last ) {
8232 var simple = type.slice( 0, 3 ) !== "nth",
8233 forward = type.slice( -4 ) !== "last",
8234 ofType = what === "of-type";
8235
8236 return first === 1 && last === 0 ?
8237
8238 // Shortcut for :nth-*(n)
8239 function( elem ) {
8240 return !!elem.parentNode;
8241 } :
8242
8243 function( elem, context, xml ) {
8244 var cache, outerCache, node, diff, nodeIndex, start,
8245 dir = simple !== forward ? "nextSibling" : "previousSibling",
8246 parent = elem.parentNode,
8247 name = ofType && elem.nodeName.toLowerCase(),
8248 useCache = !xml && !ofType;
8249
8250 if ( parent ) {
8251
8252 // :(first|last|only)-(child|of-type)
8253 if ( simple ) {
8254 while ( dir ) {
8255 node = elem;
8256 while ( (node = node[ dir ]) ) {
8257 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
8258 return false;
8259 }
8260 }
8261 // Reverse direction for :only-* (if we haven't yet done so)
8262 start = dir = type === "only" && !start && "nextSibling";
8263 }
8264 return true;
8265 }
8266
8267 start = [ forward ? parent.firstChild : parent.lastChild ];
8268
8269 // non-xml :nth-child(...) stores cache data on `parent`
8270 if ( forward && useCache ) {
8271 // Seek `elem` from a previously-cached index
8272 outerCache = parent[ expando ] || (parent[ expando ] = {});
8273 cache = outerCache[ type ] || [];
8274 nodeIndex = cache[0] === dirruns && cache[1];
8275 diff = cache[0] === dirruns && cache[2];
8276 node = nodeIndex && parent.childNodes[ nodeIndex ];
8277
8278 while ( (node = ++nodeIndex && node && node[ dir ] ||
8279
8280 // Fallback to seeking `elem` from the start
8281 (diff = nodeIndex = 0) || start.pop()) ) {
8282
8283 // When found, cache indexes on `parent` and break
8284 if ( node.nodeType === 1 && ++diff && node === elem ) {
8285 outerCache[ type ] = [ dirruns, nodeIndex, diff ];
8286 break;
8287 }
8288 }
8289
8290 // Use previously-cached element index if available
8291 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
8292 diff = cache[1];
8293
8294 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
8295 } else {
8296 // Use the same loop as above to seek `elem` from the start
8297 while ( (node = ++nodeIndex && node && node[ dir ] ||
8298 (diff = nodeIndex = 0) || start.pop()) ) {
8299
8300 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
8301 // Cache the index of each encountered element
8302 if ( useCache ) {
8303 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
8304 }
8305
8306 if ( node === elem ) {
8307 break;
8308 }
8309 }
8310 }
8311 }
8312
8313 // Incorporate the offset, then check against cycle size
8314 diff -= last;
8315 return diff === first || ( diff % first === 0 && diff / first >= 0 );
8316 }
8317 };
8318 },
8319
8320 "PSEUDO": function( pseudo, argument ) {
8321 // pseudo-class names are case-insensitive
8322 // http://www.w3.org/TR/selectors/#pseudo-classes
8323 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
8324 // Remember that setFilters inherits from pseudos
8325 var args,
8326 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
8327 Sizzle.error( "unsupported pseudo: " + pseudo );
8328
8329 // The user may use createPseudo to indicate that
8330 // arguments are needed to create the filter function
8331 // just as Sizzle does
8332 if ( fn[ expando ] ) {
8333 return fn( argument );
8334 }
8335
8336 // But maintain support for old signatures
8337 if ( fn.length > 1 ) {
8338 args = [ pseudo, pseudo, "", argument ];
8339 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
8340 markFunction(function( seed, matches ) {
8341 var idx,
8342 matched = fn( seed, argument ),
8343 i = matched.length;
8344 while ( i-- ) {
8345 idx = indexOf.call( seed, matched[i] );
8346 seed[ idx ] = !( matches[ idx ] = matched[i] );
8347 }
8348 }) :
8349 function( elem ) {
8350 return fn( elem, 0, args );
8351 };
8352 }
8353
8354 return fn;
8355 }
8356 },
8357
8358 pseudos: {
8359 // Potentially complex pseudos
8360 "not": markFunction(function( selector ) {
8361 // Trim the selector passed to compile
8362 // to avoid treating leading and trailing
8363 // spaces as combinators
8364 var input = [],
8365 results = [],
8366 matcher = compile( selector.replace( rtrim, "$1" ) );
8367
8368 return matcher[ expando ] ?
8369 markFunction(function( seed, matches, context, xml ) {
8370 var elem,
8371 unmatched = matcher( seed, null, xml, [] ),
8372 i = seed.length;
8373
8374 // Match elements unmatched by `matcher`
8375 while ( i-- ) {
8376 if ( (elem = unmatched[i]) ) {
8377 seed[i] = !(matches[i] = elem);
8378 }
8379 }
8380 }) :
8381 function( elem, context, xml ) {
8382 input[0] = elem;
8383 matcher( input, null, xml, results );
8384 return !results.pop();
8385 };
8386 }),
8387
8388 "has": markFunction(function( selector ) {
8389 return function( elem ) {
8390 return Sizzle( selector, elem ).length > 0;
8391 };
8392 }),
8393
8394 "contains": markFunction(function( text ) {
8395 return function( elem ) {
8396 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
8397 };
8398 }),
8399
8400 // "Whether an element is represented by a :lang() selector
8401 // is based solely on the element's language value
8402 // being equal to the identifier C,
8403 // or beginning with the identifier C immediately followed by "-".
8404 // The matching of C against the element's language value is performed case-insensitively.
8405 // The identifier C does not have to be a valid language name."
8406 // http://www.w3.org/TR/selectors/#lang-pseudo
8407 "lang": markFunction( function( lang ) {
8408 // lang value must be a valid identifier
8409 if ( !ridentifier.test(lang || "") ) {
8410 Sizzle.error( "unsupported lang: " + lang );
8411 }
8412 lang = lang.replace( runescape, funescape ).toLowerCase();
8413 return function( elem ) {
8414 var elemLang;
8415 do {
8416 if ( (elemLang = documentIsHTML ?
8417 elem.lang :
8418 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
8419
8420 elemLang = elemLang.toLowerCase();
8421 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
8422 }
8423 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
8424 return false;
8425 };
8426 }),
8427
8428 // Miscellaneous
8429 "target": function( elem ) {
8430 var hash = window.location && window.location.hash;
8431 return hash && hash.slice( 1 ) === elem.id;
8432 },
8433
8434 "root": function( elem ) {
8435 return elem === docElem;
8436 },
8437
8438 "focus": function( elem ) {
8439 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
8440 },
8441
8442 // Boolean properties
8443 "enabled": function( elem ) {
8444 return elem.disabled === false;
8445 },
8446
8447 "disabled": function( elem ) {
8448 return elem.disabled === true;
8449 },
8450
8451 "checked": function( elem ) {
8452 // In CSS3, :checked should return both checked and selected elements
8453 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
8454 var nodeName = elem.nodeName.toLowerCase();
8455 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
8456 },
8457
8458 "selected": function( elem ) {
8459 // Accessing this property makes selected-by-default
8460 // options in Safari work properly
8461 if ( elem.parentNode ) {
8462 elem.parentNode.selectedIndex;
8463 }
8464
8465 return elem.selected === true;
8466 },
8467
8468 // Contents
8469 "empty": function( elem ) {
8470 // http://www.w3.org/TR/selectors/#empty-pseudo
8471 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
8472 // but not by others (comment: 8; processing instruction: 7; etc.)
8473 // nodeType < 6 works because attributes (2) do not appear as children
8474 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
8475 if ( elem.nodeType < 6 ) {
8476 return false;
8477 }
8478 }
8479 return true;
8480 },
8481
8482 "parent": function( elem ) {
8483 return !Expr.pseudos["empty"]( elem );
8484 },
8485
8486 // Element/input types
8487 "header": function( elem ) {
8488 return rheader.test( elem.nodeName );
8489 },
8490
8491 "input": function( elem ) {
8492 return rinputs.test( elem.nodeName );
8493 },
8494
8495 "button": function( elem ) {
8496 var name = elem.nodeName.toLowerCase();
8497 return name === "input" && elem.type === "button" || name === "button";
8498 },
8499
8500 "text": function( elem ) {
8501 var attr;
8502 return elem.nodeName.toLowerCase() === "input" &&
8503 elem.type === "text" &&
8504
8505 // Support: IE<8
8506 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
8507 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
8508 },
8509
8510 // Position-in-collection
8511 "first": createPositionalPseudo(function() {
8512 return [ 0 ];
8513 }),
8514
8515 "last": createPositionalPseudo(function( matchIndexes, length ) {
8516 return [ length - 1 ];
8517 }),
8518
8519 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
8520 return [ argument < 0 ? argument + length : argument ];
8521 }),
8522
8523 "even": createPositionalPseudo(function( matchIndexes, length ) {
8524 var i = 0;
8525 for ( ; i < length; i += 2 ) {
8526 matchIndexes.push( i );
8527 }
8528 return matchIndexes;
8529 }),
8530
8531 "odd": createPositionalPseudo(function( matchIndexes, length ) {
8532 var i = 1;
8533 for ( ; i < length; i += 2 ) {
8534 matchIndexes.push( i );
8535 }
8536 return matchIndexes;
8537 }),
8538
8539 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
8540 var i = argument < 0 ? argument + length : argument;
8541 for ( ; --i >= 0; ) {
8542 matchIndexes.push( i );
8543 }
8544 return matchIndexes;
8545 }),
8546
8547 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
8548 var i = argument < 0 ? argument + length : argument;
8549 for ( ; ++i < length; ) {
8550 matchIndexes.push( i );
8551 }
8552 return matchIndexes;
8553 })
8554 }
8555 };
8556
8557 Expr.pseudos["nth"] = Expr.pseudos["eq"];
8558
8559 // Add button/input type pseudos
8560 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
8561 Expr.pseudos[ i ] = createInputPseudo( i );
8562 }
8563 for ( i in { submit: true, reset: true } ) {
8564 Expr.pseudos[ i ] = createButtonPseudo( i );
8565 }
8566
8567 // Easy API for creating new setFilters
8568 function setFilters() {}
8569 setFilters.prototype = Expr.filters = Expr.pseudos;
8570 Expr.setFilters = new setFilters();
8571
8572 tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
8573 var matched, match, tokens, type,
8574 soFar, groups, preFilters,
8575 cached = tokenCache[ selector + " " ];
8576
8577 if ( cached ) {
8578 return parseOnly ? 0 : cached.slice( 0 );
8579 }
8580
8581 soFar = selector;
8582 groups = [];
8583 preFilters = Expr.preFilter;
8584
8585 while ( soFar ) {
8586
8587 // Comma and first run
8588 if ( !matched || (match = rcomma.exec( soFar )) ) {
8589 if ( match ) {
8590 // Don't consume trailing commas as valid
8591 soFar = soFar.slice( match[0].length ) || soFar;
8592 }
8593 groups.push( (tokens = []) );
8594 }
8595
8596 matched = false;
8597
8598 // Combinators
8599 if ( (match = rcombinators.exec( soFar )) ) {
8600 matched = match.shift();
8601 tokens.push({
8602 value: matched,
8603 // Cast descendant combinators to space
8604 type: match[0].replace( rtrim, " " )
8605 });
8606 soFar = soFar.slice( matched.length );
8607 }
8608
8609 // Filters
8610 for ( type in Expr.filter ) {
8611 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
8612 (match = preFilters[ type ]( match ))) ) {
8613 matched = match.shift();
8614 tokens.push({
8615 value: matched,
8616 type: type,
8617 matches: match
8618 });
8619 soFar = soFar.slice( matched.length );
8620 }
8621 }
8622
8623 if ( !matched ) {
8624 break;
8625 }
8626 }
8627
8628 // Return the length of the invalid excess
8629 // if we're just parsing
8630 // Otherwise, throw an error or return tokens
8631 return parseOnly ?
8632 soFar.length :
8633 soFar ?
8634 Sizzle.error( selector ) :
8635 // Cache the tokens
8636 tokenCache( selector, groups ).slice( 0 );
8637 };
8638
8639 function toSelector( tokens ) {
8640 var i = 0,
8641 len = tokens.length,
8642 selector = "";
8643 for ( ; i < len; i++ ) {
8644 selector += tokens[i].value;
8645 }
8646 return selector;
8647 }
8648
8649 function addCombinator( matcher, combinator, base ) {
8650 var dir = combinator.dir,
8651 checkNonElements = base && dir === "parentNode",
8652 doneName = done++;
8653
8654 return combinator.first ?
8655 // Check against closest ancestor/preceding element
8656 function( elem, context, xml ) {
8657 while ( (elem = elem[ dir ]) ) {
8658 if ( elem.nodeType === 1 || checkNonElements ) {
8659 return matcher( elem, context, xml );
8660 }
8661 }
8662 } :
8663
8664 // Check against all ancestor/preceding elements
8665 function( elem, context, xml ) {
8666 var oldCache, outerCache,
8667 newCache = [ dirruns, doneName ];
8668
8669 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
8670 if ( xml ) {
8671 while ( (elem = elem[ dir ]) ) {
8672 if ( elem.nodeType === 1 || checkNonElements ) {
8673 if ( matcher( elem, context, xml ) ) {
8674 return true;
8675 }
8676 }
8677 }
8678 } else {
8679 while ( (elem = elem[ dir ]) ) {
8680 if ( elem.nodeType === 1 || checkNonElements ) {
8681 outerCache = elem[ expando ] || (elem[ expando ] = {});
8682 if ( (oldCache = outerCache[ dir ]) &&
8683 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
8684
8685 // Assign to newCache so results back-propagate to previous elements
8686 return (newCache[ 2 ] = oldCache[ 2 ]);
8687 } else {
8688 // Reuse newcache so results back-propagate to previous elements
8689 outerCache[ dir ] = newCache;
8690
8691 // A match means we're done; a fail means we have to keep checking
8692 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
8693 return true;
8694 }
8695 }
8696 }
8697 }
8698 }
8699 };
8700 }
8701
8702 function elementMatcher( matchers ) {
8703 return matchers.length > 1 ?
8704 function( elem, context, xml ) {
8705 var i = matchers.length;
8706 while ( i-- ) {
8707 if ( !matchers[i]( elem, context, xml ) ) {
8708 return false;
8709 }
8710 }
8711 return true;
8712 } :
8713 matchers[0];
8714 }
8715
8716 function multipleContexts( selector, contexts, results ) {
8717 var i = 0,
8718 len = contexts.length;
8719 for ( ; i < len; i++ ) {
8720 Sizzle( selector, contexts[i], results );
8721 }
8722 return results;
8723 }
8724
8725 function condense( unmatched, map, filter, context, xml ) {
8726 var elem,
8727 newUnmatched = [],
8728 i = 0,
8729 len = unmatched.length,
8730 mapped = map != null;
8731
8732 for ( ; i < len; i++ ) {
8733 if ( (elem = unmatched[i]) ) {
8734 if ( !filter || filter( elem, context, xml ) ) {
8735 newUnmatched.push( elem );
8736 if ( mapped ) {
8737 map.push( i );
8738 }
8739 }
8740 }
8741 }
8742
8743 return newUnmatched;
8744 }
8745
8746 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
8747 if ( postFilter && !postFilter[ expando ] ) {
8748 postFilter = setMatcher( postFilter );
8749 }
8750 if ( postFinder && !postFinder[ expando ] ) {
8751 postFinder = setMatcher( postFinder, postSelector );
8752 }
8753 return markFunction(function( seed, results, context, xml ) {
8754 var temp, i, elem,
8755 preMap = [],
8756 postMap = [],
8757 preexisting = results.length,
8758
8759 // Get initial elements from seed or context
8760 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
8761
8762 // Prefilter to get matcher input, preserving a map for seed-results synchronization
8763 matcherIn = preFilter && ( seed || !selector ) ?
8764 condense( elems, preMap, preFilter, context, xml ) :
8765 elems,
8766
8767 matcherOut = matcher ?
8768 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
8769 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
8770
8771 // ...intermediate processing is necessary
8772 [] :
8773
8774 // ...otherwise use results directly
8775 results :
8776 matcherIn;
8777
8778 // Find primary matches
8779 if ( matcher ) {
8780 matcher( matcherIn, matcherOut, context, xml );
8781 }
8782
8783 // Apply postFilter
8784 if ( postFilter ) {
8785 temp = condense( matcherOut, postMap );
8786 postFilter( temp, [], context, xml );
8787
8788 // Un-match failing elements by moving them back to matcherIn
8789 i = temp.length;
8790 while ( i-- ) {
8791 if ( (elem = temp[i]) ) {
8792 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
8793 }
8794 }
8795 }
8796
8797 if ( seed ) {
8798 if ( postFinder || preFilter ) {
8799 if ( postFinder ) {
8800 // Get the final matcherOut by condensing this intermediate into postFinder contexts
8801 temp = [];
8802 i = matcherOut.length;
8803 while ( i-- ) {
8804 if ( (elem = matcherOut[i]) ) {
8805 // Restore matcherIn since elem is not yet a final match
8806 temp.push( (matcherIn[i] = elem) );
8807 }
8808 }
8809 postFinder( null, (matcherOut = []), temp, xml );
8810 }
8811
8812 // Move matched elements from seed to results to keep them synchronized
8813 i = matcherOut.length;
8814 while ( i-- ) {
8815 if ( (elem = matcherOut[i]) &&
8816 (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
8817
8818 seed[temp] = !(results[temp] = elem);
8819 }
8820 }
8821 }
8822
8823 // Add elements to results, through postFinder if defined
8824 } else {
8825 matcherOut = condense(
8826 matcherOut === results ?
8827 matcherOut.splice( preexisting, matcherOut.length ) :
8828 matcherOut
8829 );
8830 if ( postFinder ) {
8831 postFinder( null, results, matcherOut, xml );
8832 } else {
8833 push.apply( results, matcherOut );
8834 }
8835 }
8836 });
8837 }
8838
8839 function matcherFromTokens( tokens ) {
8840 var checkContext, matcher, j,
8841 len = tokens.length,
8842 leadingRelative = Expr.relative[ tokens[0].type ],
8843 implicitRelative = leadingRelative || Expr.relative[" "],
8844 i = leadingRelative ? 1 : 0,
8845
8846 // The foundational matcher ensures that elements are reachable from top-level context(s)
8847 matchContext = addCombinator( function( elem ) {
8848 return elem === checkContext;
8849 }, implicitRelative, true ),
8850 matchAnyContext = addCombinator( function( elem ) {
8851 return indexOf.call( checkContext, elem ) > -1;
8852 }, implicitRelative, true ),
8853 matchers = [ function( elem, context, xml ) {
8854 return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
8855 (checkContext = context).nodeType ?
8856 matchContext( elem, context, xml ) :
8857 matchAnyContext( elem, context, xml ) );
8858 } ];
8859
8860 for ( ; i < len; i++ ) {
8861 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
8862 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
8863 } else {
8864 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
8865
8866 // Return special upon seeing a positional matcher
8867 if ( matcher[ expando ] ) {
8868 // Find the next relative operator (if any) for proper handling
8869 j = ++i;
8870 for ( ; j < len; j++ ) {
8871 if ( Expr.relative[ tokens[j].type ] ) {
8872 break;
8873 }
8874 }
8875 return setMatcher(
8876 i > 1 && elementMatcher( matchers ),
8877 i > 1 && toSelector(
8878 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
8879 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
8880 ).replace( rtrim, "$1" ),
8881 matcher,
8882 i < j && matcherFromTokens( tokens.slice( i, j ) ),
8883 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
8884 j < len && toSelector( tokens )
8885 );
8886 }
8887 matchers.push( matcher );
8888 }
8889 }
8890
8891 return elementMatcher( matchers );
8892 }
8893
8894 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
8895 var bySet = setMatchers.length > 0,
8896 byElement = elementMatchers.length > 0,
8897 superMatcher = function( seed, context, xml, results, outermost ) {
8898 var elem, j, matcher,
8899 matchedCount = 0,
8900 i = "0",
8901 unmatched = seed && [],
8902 setMatched = [],
8903 contextBackup = outermostContext,
8904 // We must always have either seed elements or outermost context
8905 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
8906 // Use integer dirruns iff this is the outermost matcher
8907 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
8908 len = elems.length;
8909
8910 if ( outermost ) {
8911 outermostContext = context !== document && context;
8912 }
8913
8914 // Add elements passing elementMatchers directly to results
8915 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
8916 // Support: IE<9, Safari
8917 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
8918 for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
8919 if ( byElement && elem ) {
8920 j = 0;
8921 while ( (matcher = elementMatchers[j++]) ) {
8922 if ( matcher( elem, context, xml ) ) {
8923 results.push( elem );
8924 break;
8925 }
8926 }
8927 if ( outermost ) {
8928 dirruns = dirrunsUnique;
8929 }
8930 }
8931
8932 // Track unmatched elements for set filters
8933 if ( bySet ) {
8934 // They will have gone through all possible matchers
8935 if ( (elem = !matcher && elem) ) {
8936 matchedCount--;
8937 }
8938
8939 // Lengthen the array for every element, matched or not
8940 if ( seed ) {
8941 unmatched.push( elem );
8942 }
8943 }
8944 }
8945
8946 // Apply set filters to unmatched elements
8947 matchedCount += i;
8948 if ( bySet && i !== matchedCount ) {
8949 j = 0;
8950 while ( (matcher = setMatchers[j++]) ) {
8951 matcher( unmatched, setMatched, context, xml );
8952 }
8953
8954 if ( seed ) {
8955 // Reintegrate element matches to eliminate the need for sorting
8956 if ( matchedCount > 0 ) {
8957 while ( i-- ) {
8958 if ( !(unmatched[i] || setMatched[i]) ) {
8959 setMatched[i] = pop.call( results );
8960 }
8961 }
8962 }
8963
8964 // Discard index placeholder values to get only actual matches
8965 setMatched = condense( setMatched );
8966 }
8967
8968 // Add matches to results
8969 push.apply( results, setMatched );
8970
8971 // Seedless set matches succeeding multiple successful matchers stipulate sorting
8972 if ( outermost && !seed && setMatched.length > 0 &&
8973 ( matchedCount + setMatchers.length ) > 1 ) {
8974
8975 Sizzle.uniqueSort( results );
8976 }
8977 }
8978
8979 // Override manipulation of globals by nested matchers
8980 if ( outermost ) {
8981 dirruns = dirrunsUnique;
8982 outermostContext = contextBackup;
8983 }
8984
8985 return unmatched;
8986 };
8987
8988 return bySet ?
8989 markFunction( superMatcher ) :
8990 superMatcher;
8991 }
8992
8993 compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
8994 var i,
8995 setMatchers = [],
8996 elementMatchers = [],
8997 cached = compilerCache[ selector + " " ];
8998
8999 if ( !cached ) {
9000 // Generate a function of recursive functions that can be used to check each element
9001 if ( !match ) {
9002 match = tokenize( selector );
9003 }
9004 i = match.length;
9005 while ( i-- ) {
9006 cached = matcherFromTokens( match[i] );
9007 if ( cached[ expando ] ) {
9008 setMatchers.push( cached );
9009 } else {
9010 elementMatchers.push( cached );
9011 }
9012 }
9013
9014 // Cache the compiled function
9015 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
9016
9017 // Save selector and tokenization
9018 cached.selector = selector;
9019 }
9020 return cached;
9021 };
9022
9023 /**
9024 * A low-level selection function that works with Sizzle's compiled
9025 * selector functions
9026 * @param {String|Function} selector A selector or a pre-compiled
9027 * selector function built with Sizzle.compile
9028 * @param {Element} context
9029 * @param {Array} [results]
9030 * @param {Array} [seed] A set of elements to match against
9031 */
9032 select = Sizzle.select = function( selector, context, results, seed ) {
9033 var i, tokens, token, type, find,
9034 compiled = typeof selector === "function" && selector,
9035 match = !seed && tokenize( (selector = compiled.selector || selector) );
9036
9037 results = results || [];
9038
9039 // Try to minimize operations if there is no seed and only one group
9040 if ( match.length === 1 ) {
9041
9042 // Take a shortcut and set the context if the root selector is an ID
9043 tokens = match[0] = match[0].slice( 0 );
9044 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
9045 support.getById && context.nodeType === 9 && documentIsHTML &&
9046 Expr.relative[ tokens[1].type ] ) {
9047
9048 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
9049 if ( !context ) {
9050 return results;
9051
9052 // Precompiled matchers will still verify ancestry, so step up a level
9053 } else if ( compiled ) {
9054 context = context.parentNode;
9055 }
9056
9057 selector = selector.slice( tokens.shift().value.length );
9058 }
9059
9060 // Fetch a seed set for right-to-left matching
9061 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
9062 while ( i-- ) {
9063 token = tokens[i];
9064
9065 // Abort if we hit a combinator
9066 if ( Expr.relative[ (type = token.type) ] ) {
9067 break;
9068 }
9069 if ( (find = Expr.find[ type ]) ) {
9070 // Search, expanding context for leading sibling combinators
9071 if ( (seed = find(
9072 token.matches[0].replace( runescape, funescape ),
9073 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
9074 )) ) {
9075
9076 // If seed is empty or no tokens remain, we can return early
9077 tokens.splice( i, 1 );
9078 selector = seed.length && toSelector( tokens );
9079 if ( !selector ) {
9080 push.apply( results, seed );
9081 return results;
9082 }
9083
9084 break;
9085 }
9086 }
9087 }
9088 }
9089
9090 // Compile and execute a filtering function if one is not provided
9091 // Provide `match` to avoid retokenization if we modified the selector above
9092 ( compiled || compile( selector, match ) )(
9093 seed,
9094 context,
9095 !documentIsHTML,
9096 results,
9097 rsibling.test( selector ) && testContext( context.parentNode ) || context
9098 );
9099 return results;
9100 };
9101
9102 // One-time assignments
9103
9104 // Sort stability
9105 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
9106
9107 // Support: Chrome<14
9108 // Always assume duplicates if they aren't passed to the comparison function
9109 support.detectDuplicates = !!hasDuplicate;
9110
9111 // Initialize against the default document
9112 setDocument();
9113
9114 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
9115 // Detached nodes confoundingly follow *each other*
9116 support.sortDetached = assert(function( div1 ) {
9117 // Should return 1, but returns 4 (following)
9118 return div1.compareDocumentPosition( document.createElement("div") ) & 1;
9119 });
9120
9121 // Support: IE<8
9122 // Prevent attribute/property "interpolation"
9123 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
9124 if ( !assert(function( div ) {
9125 div.innerHTML = "<a href='#'></a>";
9126 return div.firstChild.getAttribute("href") === "#" ;
9127 }) ) {
9128 addHandle( "type|href|height|width", function( elem, name, isXML ) {
9129 if ( !isXML ) {
9130 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
9131 }
9132 });
9133 }
9134
9135 // Support: IE<9
9136 // Use defaultValue in place of getAttribute("value")
9137 if ( !support.attributes || !assert(function( div ) {
9138 div.innerHTML = "<input/>";
9139 div.firstChild.setAttribute( "value", "" );
9140 return div.firstChild.getAttribute( "value" ) === "";
9141 }) ) {
9142 addHandle( "value", function( elem, name, isXML ) {
9143 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
9144 return elem.defaultValue;
9145 }
9146 });
9147 }
9148
9149 // Support: IE<9
9150 // Use getAttributeNode to fetch booleans when getAttribute lies
9151 if ( !assert(function( div ) {
9152 return div.getAttribute("disabled") == null;
9153 }) ) {
9154 addHandle( booleans, function( elem, name, isXML ) {
9155 var val;
9156 if ( !isXML ) {
9157 return elem[ name ] === true ? name.toLowerCase() :
9158 (val = elem.getAttributeNode( name )) && val.specified ?
9159 val.value :
9160 null;
9161 }
9162 });
9163 }
9164
9165 return Sizzle;
9166
9167 })( window );
9168
9169
9170
9171 jQuery.find = Sizzle;
9172 jQuery.expr = Sizzle.selectors;
9173 jQuery.expr[":"] = jQuery.expr.pseudos;
9174 jQuery.unique = Sizzle.uniqueSort;
9175 jQuery.text = Sizzle.getText;
9176 jQuery.isXMLDoc = Sizzle.isXML;
9177 jQuery.contains = Sizzle.contains;
9178
9179
9180
9181 var rneedsContext = jQuery.expr.match.needsContext;
9182
9183 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
9184
9185
9186
9187 var risSimple = /^.[^:#\[\.,]*$/;
9188
9189 // Implement the identical functionality for filter and not
9190 function winnow( elements, qualifier, not ) {
9191 if ( jQuery.isFunction( qualifier ) ) {
9192 return jQuery.grep( elements, function( elem, i ) {
9193 /* jshint -W018 */
9194 return !!qualifier.call( elem, i, elem ) !== not;
9195 });
9196
9197 }
9198
9199 if ( qualifier.nodeType ) {
9200 return jQuery.grep( elements, function( elem ) {
9201 return ( elem === qualifier ) !== not;
9202 });
9203
9204 }
9205
9206 if ( typeof qualifier === "string" ) {
9207 if ( risSimple.test( qualifier ) ) {
9208 return jQuery.filter( qualifier, elements, not );
9209 }
9210
9211 qualifier = jQuery.filter( qualifier, elements );
9212 }
9213
9214 return jQuery.grep( elements, function( elem ) {
9215 return ( indexOf.call( qualifier, elem ) >= 0 ) !== not;
9216 });
9217 }
9218
9219 jQuery.filter = function( expr, elems, not ) {
9220 var elem = elems[ 0 ];
9221
9222 if ( not ) {
9223 expr = ":not(" + expr + ")";
9224 }
9225
9226 return elems.length === 1 && elem.nodeType === 1 ?
9227 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
9228 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
9229 return elem.nodeType === 1;
9230 }));
9231 };
9232
9233 jQuery.fn.extend({
9234 find: function( selector ) {
9235 var i,
9236 len = this.length,
9237 ret = [],
9238 self = this;
9239
9240 if ( typeof selector !== "string" ) {
9241 return this.pushStack( jQuery( selector ).filter(function() {
9242 for ( i = 0; i < len; i++ ) {
9243 if ( jQuery.contains( self[ i ], this ) ) {
9244 return true;
9245 }
9246 }
9247 }) );
9248 }
9249
9250 for ( i = 0; i < len; i++ ) {
9251 jQuery.find( selector, self[ i ], ret );
9252 }
9253
9254 // Needed because $( selector, context ) becomes $( context ).find( selector )
9255 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
9256 ret.selector = this.selector ? this.selector + " " + selector : selector;
9257 return ret;
9258 },
9259 filter: function( selector ) {
9260 return this.pushStack( winnow(this, selector || [], false) );
9261 },
9262 not: function( selector ) {
9263 return this.pushStack( winnow(this, selector || [], true) );
9264 },
9265 is: function( selector ) {
9266 return !!winnow(
9267 this,
9268
9269 // If this is a positional/relative selector, check membership in the returned set
9270 // so $("p:first").is("p:last") won't return true for a doc with two "p".
9271 typeof selector === "string" && rneedsContext.test( selector ) ?
9272 jQuery( selector ) :
9273 selector || [],
9274 false
9275 ).length;
9276 }
9277 });
9278
9279
9280 // Initialize a jQuery object
9281
9282
9283 // A central reference to the root jQuery(document)
9284 var rootjQuery,
9285
9286 // A simple way to check for HTML strings
9287 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
9288 // Strict HTML recognition (#11290: must start with <)
9289 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
9290
9291 init = jQuery.fn.init = function( selector, context ) {
9292 var match, elem;
9293
9294 // HANDLE: $(""), $(null), $(undefined), $(false)
9295 if ( !selector ) {
9296 return this;
9297 }
9298
9299 // Handle HTML strings
9300 if ( typeof selector === "string" ) {
9301 if ( selector[0] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) {
9302 // Assume that strings that start and end with <> are HTML and skip the regex check
9303 match = [ null, selector, null ];
9304
9305 } else {
9306 match = rquickExpr.exec( selector );
9307 }
9308
9309 // Match html or make sure no context is specified for #id
9310 if ( match && (match[1] || !context) ) {
9311
9312 // HANDLE: $(html) -> $(array)
9313 if ( match[1] ) {
9314 context = context instanceof jQuery ? context[0] : context;
9315
9316 // scripts is true for back-compat
9317 // Intentionally let the error be thrown if parseHTML is not present
9318 jQuery.merge( this, jQuery.parseHTML(
9319 match[1],
9320 context && context.nodeType ? context.ownerDocument || context : document,
9321 true
9322 ) );
9323
9324 // HANDLE: $(html, props)
9325 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
9326 for ( match in context ) {
9327 // Properties of context are called as methods if possible
9328 if ( jQuery.isFunction( this[ match ] ) ) {
9329 this[ match ]( context[ match ] );
9330
9331 // ...and otherwise set as attributes
9332 } else {
9333 this.attr( match, context[ match ] );
9334 }
9335 }
9336 }
9337
9338 return this;
9339
9340 // HANDLE: $(#id)
9341 } else {
9342 elem = document.getElementById( match[2] );
9343
9344 // Check parentNode to catch when Blackberry 4.6 returns
9345 // nodes that are no longer in the document #6963
9346 if ( elem && elem.parentNode ) {
9347 // Inject the element directly into the jQuery object
9348 this.length = 1;
9349 this[0] = elem;
9350 }
9351
9352 this.context = document;
9353 this.selector = selector;
9354 return this;
9355 }
9356
9357 // HANDLE: $(expr, $(...))
9358 } else if ( !context || context.jquery ) {
9359 return ( context || rootjQuery ).find( selector );
9360
9361 // HANDLE: $(expr, context)
9362 // (which is just equivalent to: $(context).find(expr)
9363 } else {
9364 return this.constructor( context ).find( selector );
9365 }
9366
9367 // HANDLE: $(DOMElement)
9368 } else if ( selector.nodeType ) {
9369 this.context = this[0] = selector;
9370 this.length = 1;
9371 return this;
9372
9373 // HANDLE: $(function)
9374 // Shortcut for document ready
9375 } else if ( jQuery.isFunction( selector ) ) {
9376 return typeof rootjQuery.ready !== "undefined" ?
9377 rootjQuery.ready( selector ) :
9378 // Execute immediately if ready is not present
9379 selector( jQuery );
9380 }
9381
9382 if ( selector.selector !== undefined ) {
9383 this.selector = selector.selector;
9384 this.context = selector.context;
9385 }
9386
9387 return jQuery.makeArray( selector, this );
9388 };
9389
9390 // Give the init function the jQuery prototype for later instantiation
9391 init.prototype = jQuery.fn;
9392
9393 // Initialize central reference
9394 rootjQuery = jQuery( document );
9395
9396
9397 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
9398 // methods guaranteed to produce a unique set when starting from a unique set
9399 guaranteedUnique = {
9400 children: true,
9401 contents: true,
9402 next: true,
9403 prev: true
9404 };
9405
9406 jQuery.extend({
9407 dir: function( elem, dir, until ) {
9408 var matched = [],
9409 truncate = until !== undefined;
9410
9411 while ( (elem = elem[ dir ]) && elem.nodeType !== 9 ) {
9412 if ( elem.nodeType === 1 ) {
9413 if ( truncate && jQuery( elem ).is( until ) ) {
9414 break;
9415 }
9416 matched.push( elem );
9417 }
9418 }
9419 return matched;
9420 },
9421
9422 sibling: function( n, elem ) {
9423 var matched = [];
9424
9425 for ( ; n; n = n.nextSibling ) {
9426 if ( n.nodeType === 1 && n !== elem ) {
9427 matched.push( n );
9428 }
9429 }
9430
9431 return matched;
9432 }
9433 });
9434
9435 jQuery.fn.extend({
9436 has: function( target ) {
9437 var targets = jQuery( target, this ),
9438 l = targets.length;
9439
9440 return this.filter(function() {
9441 var i = 0;
9442 for ( ; i < l; i++ ) {
9443 if ( jQuery.contains( this, targets[i] ) ) {
9444 return true;
9445 }
9446 }
9447 });
9448 },
9449
9450 closest: function( selectors, context ) {
9451 var cur,
9452 i = 0,
9453 l = this.length,
9454 matched = [],
9455 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
9456 jQuery( selectors, context || this.context ) :
9457 0;
9458
9459 for ( ; i < l; i++ ) {
9460 for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
9461 // Always skip document fragments
9462 if ( cur.nodeType < 11 && (pos ?
9463 pos.index(cur) > -1 :
9464
9465 // Don't pass non-elements to Sizzle
9466 cur.nodeType === 1 &&
9467 jQuery.find.matchesSelector(cur, selectors)) ) {
9468
9469 matched.push( cur );
9470 break;
9471 }
9472 }
9473 }
9474
9475 return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
9476 },
9477
9478 // Determine the position of an element within
9479 // the matched set of elements
9480 index: function( elem ) {
9481
9482 // No argument, return index in parent
9483 if ( !elem ) {
9484 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
9485 }
9486
9487 // index in selector
9488 if ( typeof elem === "string" ) {
9489 return indexOf.call( jQuery( elem ), this[ 0 ] );
9490 }
9491
9492 // Locate the position of the desired element
9493 return indexOf.call( this,
9494
9495 // If it receives a jQuery object, the first element is used
9496 elem.jquery ? elem[ 0 ] : elem
9497 );
9498 },
9499
9500 add: function( selector, context ) {
9501 return this.pushStack(
9502 jQuery.unique(
9503 jQuery.merge( this.get(), jQuery( selector, context ) )
9504 )
9505 );
9506 },
9507
9508 addBack: function( selector ) {
9509 return this.add( selector == null ?
9510 this.prevObject : this.prevObject.filter(selector)
9511 );
9512 }
9513 });
9514
9515 function sibling( cur, dir ) {
9516 while ( (cur = cur[dir]) && cur.nodeType !== 1 ) {}
9517 return cur;
9518 }
9519
9520 jQuery.each({
9521 parent: function( elem ) {
9522 var parent = elem.parentNode;
9523 return parent && parent.nodeType !== 11 ? parent : null;
9524 },
9525 parents: function( elem ) {
9526 return jQuery.dir( elem, "parentNode" );
9527 },
9528 parentsUntil: function( elem, i, until ) {
9529 return jQuery.dir( elem, "parentNode", until );
9530 },
9531 next: function( elem ) {
9532 return sibling( elem, "nextSibling" );
9533 },
9534 prev: function( elem ) {
9535 return sibling( elem, "previousSibling" );
9536 },
9537 nextAll: function( elem ) {
9538 return jQuery.dir( elem, "nextSibling" );
9539 },
9540 prevAll: function( elem ) {
9541 return jQuery.dir( elem, "previousSibling" );
9542 },
9543 nextUntil: function( elem, i, until ) {
9544 return jQuery.dir( elem, "nextSibling", until );
9545 },
9546 prevUntil: function( elem, i, until ) {
9547 return jQuery.dir( elem, "previousSibling", until );
9548 },
9549 siblings: function( elem ) {
9550 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
9551 },
9552 children: function( elem ) {
9553 return jQuery.sibling( elem.firstChild );
9554 },
9555 contents: function( elem ) {
9556 return elem.contentDocument || jQuery.merge( [], elem.childNodes );
9557 }
9558 }, function( name, fn ) {
9559 jQuery.fn[ name ] = function( until, selector ) {
9560 var matched = jQuery.map( this, fn, until );
9561
9562 if ( name.slice( -5 ) !== "Until" ) {
9563 selector = until;
9564 }
9565
9566 if ( selector && typeof selector === "string" ) {
9567 matched = jQuery.filter( selector, matched );
9568 }
9569
9570 if ( this.length > 1 ) {
9571 // Remove duplicates
9572 if ( !guaranteedUnique[ name ] ) {
9573 jQuery.unique( matched );
9574 }
9575
9576 // Reverse order for parents* and prev-derivatives
9577 if ( rparentsprev.test( name ) ) {
9578 matched.reverse();
9579 }
9580 }
9581
9582 return this.pushStack( matched );
9583 };
9584 });
9585 var rnotwhite = (/\S+/g);
9586
9587
9588
9589 // String to Object options format cache
9590 var optionsCache = {};
9591
9592 // Convert String-formatted options into Object-formatted ones and store in cache
9593 function createOptions( options ) {
9594 var object = optionsCache[ options ] = {};
9595 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
9596 object[ flag ] = true;
9597 });
9598 return object;
9599 }
9600
9601 /*
9602 * Create a callback list using the following parameters:
9603 *
9604 * options: an optional list of space-separated options that will change how
9605 * the callback list behaves or a more traditional option object
9606 *
9607 * By default a callback list will act like an event callback list and can be
9608 * "fired" multiple times.
9609 *
9610 * Possible options:
9611 *
9612 * once: will ensure the callback list can only be fired once (like a Deferred)
9613 *
9614 * memory: will keep track of previous values and will call any callback added
9615 * after the list has been fired right away with the latest "memorized"
9616 * values (like a Deferred)
9617 *
9618 * unique: will ensure a callback can only be added once (no duplicate in the list)
9619 *
9620 * stopOnFalse: interrupt callings when a callback returns false
9621 *
9622 */
9623 jQuery.Callbacks = function( options ) {
9624
9625 // Convert options from String-formatted to Object-formatted if needed
9626 // (we check in cache first)
9627 options = typeof options === "string" ?
9628 ( optionsCache[ options ] || createOptions( options ) ) :
9629 jQuery.extend( {}, options );
9630
9631 var // Last fire value (for non-forgettable lists)
9632 memory,
9633 // Flag to know if list was already fired
9634 fired,
9635 // Flag to know if list is currently firing
9636 firing,
9637 // First callback to fire (used internally by add and fireWith)
9638 firingStart,
9639 // End of the loop when firing
9640 firingLength,
9641 // Index of currently firing callback (modified by remove if needed)
9642 firingIndex,
9643 // Actual callback list
9644 list = [],
9645 // Stack of fire calls for repeatable lists
9646 stack = !options.once && [],
9647 // Fire callbacks
9648 fire = function( data ) {
9649 memory = options.memory && data;
9650 fired = true;
9651 firingIndex = firingStart || 0;
9652 firingStart = 0;
9653 firingLength = list.length;
9654 firing = true;
9655 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
9656 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
9657 memory = false; // To prevent further calls using add
9658 break;
9659 }
9660 }
9661 firing = false;
9662 if ( list ) {
9663 if ( stack ) {
9664 if ( stack.length ) {
9665 fire( stack.shift() );
9666 }
9667 } else if ( memory ) {
9668 list = [];
9669 } else {
9670 self.disable();
9671 }
9672 }
9673 },
9674 // Actual Callbacks object
9675 self = {
9676 // Add a callback or a collection of callbacks to the list
9677 add: function() {
9678 if ( list ) {
9679 // First, we save the current length
9680 var start = list.length;
9681 (function add( args ) {
9682 jQuery.each( args, function( _, arg ) {
9683 var type = jQuery.type( arg );
9684 if ( type === "function" ) {
9685 if ( !options.unique || !self.has( arg ) ) {
9686 list.push( arg );
9687 }
9688 } else if ( arg && arg.length && type !== "string" ) {
9689 // Inspect recursively
9690 add( arg );
9691 }
9692 });
9693 })( arguments );
9694 // Do we need to add the callbacks to the
9695 // current firing batch?
9696 if ( firing ) {
9697 firingLength = list.length;
9698 // With memory, if we're not firing then
9699 // we should call right away
9700 } else if ( memory ) {
9701 firingStart = start;
9702 fire( memory );
9703 }
9704 }
9705 return this;
9706 },
9707 // Remove a callback from the list
9708 remove: function() {
9709 if ( list ) {
9710 jQuery.each( arguments, function( _, arg ) {
9711 var index;
9712 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
9713 list.splice( index, 1 );
9714 // Handle firing indexes
9715 if ( firing ) {
9716 if ( index <= firingLength ) {
9717 firingLength--;
9718 }
9719 if ( index <= firingIndex ) {
9720 firingIndex--;
9721 }
9722 }
9723 }
9724 });
9725 }
9726 return this;
9727 },
9728 // Check if a given callback is in the list.
9729 // If no argument is given, return whether or not list has callbacks attached.
9730 has: function( fn ) {
9731 return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
9732 },
9733 // Remove all callbacks from the list
9734 empty: function() {
9735 list = [];
9736 firingLength = 0;
9737 return this;
9738 },
9739 // Have the list do nothing anymore
9740 disable: function() {
9741 list = stack = memory = undefined;
9742 return this;
9743 },
9744 // Is it disabled?
9745 disabled: function() {
9746 return !list;
9747 },
9748 // Lock the list in its current state
9749 lock: function() {
9750 stack = undefined;
9751 if ( !memory ) {
9752 self.disable();
9753 }
9754 return this;
9755 },
9756 // Is it locked?
9757 locked: function() {
9758 return !stack;
9759 },
9760 // Call all callbacks with the given context and arguments
9761 fireWith: function( context, args ) {
9762 if ( list && ( !fired || stack ) ) {
9763 args = args || [];
9764 args = [ context, args.slice ? args.slice() : args ];
9765 if ( firing ) {
9766 stack.push( args );
9767 } else {
9768 fire( args );
9769 }
9770 }
9771 return this;
9772 },
9773 // Call all the callbacks with the given arguments
9774 fire: function() {
9775 self.fireWith( this, arguments );
9776 return this;
9777 },
9778 // To know if the callbacks have already been called at least once
9779 fired: function() {
9780 return !!fired;
9781 }
9782 };
9783
9784 return self;
9785 };
9786
9787
9788 jQuery.extend({
9789
9790 Deferred: function( func ) {
9791 var tuples = [
9792 // action, add listener, listener list, final state
9793 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
9794 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
9795 [ "notify", "progress", jQuery.Callbacks("memory") ]
9796 ],
9797 state = "pending",
9798 promise = {
9799 state: function() {
9800 return state;
9801 },
9802 always: function() {
9803 deferred.done( arguments ).fail( arguments );
9804 return this;
9805 },
9806 then: function( /* fnDone, fnFail, fnProgress */ ) {
9807 var fns = arguments;
9808 return jQuery.Deferred(function( newDefer ) {
9809 jQuery.each( tuples, function( i, tuple ) {
9810 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
9811 // deferred[ done | fail | progress ] for forwarding actions to newDefer
9812 deferred[ tuple[1] ](function() {
9813 var returned = fn && fn.apply( this, arguments );
9814 if ( returned && jQuery.isFunction( returned.promise ) ) {
9815 returned.promise()
9816 .done( newDefer.resolve )
9817 .fail( newDefer.reject )
9818 .progress( newDefer.notify );
9819 } else {
9820 newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
9821 }
9822 });
9823 });
9824 fns = null;
9825 }).promise();
9826 },
9827 // Get a promise for this deferred
9828 // If obj is provided, the promise aspect is added to the object
9829 promise: function( obj ) {
9830 return obj != null ? jQuery.extend( obj, promise ) : promise;
9831 }
9832 },
9833 deferred = {};
9834
9835 // Keep pipe for back-compat
9836 promise.pipe = promise.then;
9837
9838 // Add list-specific methods
9839 jQuery.each( tuples, function( i, tuple ) {
9840 var list = tuple[ 2 ],
9841 stateString = tuple[ 3 ];
9842
9843 // promise[ done | fail | progress ] = list.add
9844 promise[ tuple[1] ] = list.add;
9845
9846 // Handle state
9847 if ( stateString ) {
9848 list.add(function() {
9849 // state = [ resolved | rejected ]
9850 state = stateString;
9851
9852 // [ reject_list | resolve_list ].disable; progress_list.lock
9853 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
9854 }
9855
9856 // deferred[ resolve | reject | notify ]
9857 deferred[ tuple[0] ] = function() {
9858 deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
9859 return this;
9860 };
9861 deferred[ tuple[0] + "With" ] = list.fireWith;
9862 });
9863
9864 // Make the deferred a promise
9865 promise.promise( deferred );
9866
9867 // Call given func if any
9868 if ( func ) {
9869 func.call( deferred, deferred );
9870 }
9871
9872 // All done!
9873 return deferred;
9874 },
9875
9876 // Deferred helper
9877 when: function( subordinate /* , ..., subordinateN */ ) {
9878 var i = 0,
9879 resolveValues = slice.call( arguments ),
9880 length = resolveValues.length,
9881
9882 // the count of uncompleted subordinates
9883 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
9884
9885 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
9886 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
9887
9888 // Update function for both resolve and progress values
9889 updateFunc = function( i, contexts, values ) {
9890 return function( value ) {
9891 contexts[ i ] = this;
9892 values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
9893 if ( values === progressValues ) {
9894 deferred.notifyWith( contexts, values );
9895 } else if ( !( --remaining ) ) {
9896 deferred.resolveWith( contexts, values );
9897 }
9898 };
9899 },
9900
9901 progressValues, progressContexts, resolveContexts;
9902
9903 // add listeners to Deferred subordinates; treat others as resolved
9904 if ( length > 1 ) {
9905 progressValues = new Array( length );
9906 progressContexts = new Array( length );
9907 resolveContexts = new Array( length );
9908 for ( ; i < length; i++ ) {
9909 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
9910 resolveValues[ i ].promise()
9911 .done( updateFunc( i, resolveContexts, resolveValues ) )
9912 .fail( deferred.reject )
9913 .progress( updateFunc( i, progressContexts, progressValues ) );
9914 } else {
9915 --remaining;
9916 }
9917 }
9918 }
9919
9920 // if we're not waiting on anything, resolve the master
9921 if ( !remaining ) {
9922 deferred.resolveWith( resolveContexts, resolveValues );
9923 }
9924
9925 return deferred.promise();
9926 }
9927 });
9928
9929
9930 // The deferred used on DOM ready
9931 var readyList;
9932
9933 jQuery.fn.ready = function( fn ) {
9934 // Add the callback
9935 jQuery.ready.promise().done( fn );
9936
9937 return this;
9938 };
9939
9940 jQuery.extend({
9941 // Is the DOM ready to be used? Set to true once it occurs.
9942 isReady: false,
9943
9944 // A counter to track how many items to wait for before
9945 // the ready event fires. See #6781
9946 readyWait: 1,
9947
9948 // Hold (or release) the ready event
9949 holdReady: function( hold ) {
9950 if ( hold ) {
9951 jQuery.readyWait++;
9952 } else {
9953 jQuery.ready( true );
9954 }
9955 },
9956
9957 // Handle when the DOM is ready
9958 ready: function( wait ) {
9959
9960 // Abort if there are pending holds or we're already ready
9961 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
9962 return;
9963 }
9964
9965 // Remember that the DOM is ready
9966 jQuery.isReady = true;
9967
9968 // If a normal DOM Ready event fired, decrement, and wait if need be
9969 if ( wait !== true && --jQuery.readyWait > 0 ) {
9970 return;
9971 }
9972
9973 // If there are functions bound, to execute
9974 readyList.resolveWith( document, [ jQuery ] );
9975
9976 // Trigger any bound ready events
9977 if ( jQuery.fn.triggerHandler ) {
9978 jQuery( document ).triggerHandler( "ready" );
9979 jQuery( document ).off( "ready" );
9980 }
9981 }
9982 });
9983
9984 /**
9985 * The ready event handler and self cleanup method
9986 */
9987 function completed() {
9988 document.removeEventListener( "DOMContentLoaded", completed, false );
9989 window.removeEventListener( "load", completed, false );
9990 jQuery.ready();
9991 }
9992
9993 jQuery.ready.promise = function( obj ) {
9994 if ( !readyList ) {
9995
9996 readyList = jQuery.Deferred();
9997
9998 // Catch cases where $(document).ready() is called after the browser event has already occurred.
9999 // we once tried to use readyState "interactive" here, but it caused issues like the one
10000 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
10001 if ( document.readyState === "complete" ) {
10002 // Handle it asynchronously to allow scripts the opportunity to delay ready
10003 setTimeout( jQuery.ready );
10004
10005 } else {
10006
10007 // Use the handy event callback
10008 document.addEventListener( "DOMContentLoaded", completed, false );
10009
10010 // A fallback to window.onload, that will always work
10011 window.addEventListener( "load", completed, false );
10012 }
10013 }
10014 return readyList.promise( obj );
10015 };
10016
10017 // Kick off the DOM ready check even if the user does not
10018 jQuery.ready.promise();
10019
10020
10021
10022
10023 // Multifunctional method to get and set values of a collection
10024 // The value/s can optionally be executed if it's a function
10025 var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
10026 var i = 0,
10027 len = elems.length,
10028 bulk = key == null;
10029
10030 // Sets many values
10031 if ( jQuery.type( key ) === "object" ) {
10032 chainable = true;
10033 for ( i in key ) {
10034 jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
10035 }
10036
10037 // Sets one value
10038 } else if ( value !== undefined ) {
10039 chainable = true;
10040
10041 if ( !jQuery.isFunction( value ) ) {
10042 raw = true;
10043 }
10044
10045 if ( bulk ) {
10046 // Bulk operations run against the entire set
10047 if ( raw ) {
10048 fn.call( elems, value );
10049 fn = null;
10050
10051 // ...except when executing function values
10052 } else {
10053 bulk = fn;
10054 fn = function( elem, key, value ) {
10055 return bulk.call( jQuery( elem ), value );
10056 };
10057 }
10058 }
10059
10060 if ( fn ) {
10061 for ( ; i < len; i++ ) {
10062 fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
10063 }
10064 }
10065 }
10066
10067 return chainable ?
10068 elems :
10069
10070 // Gets
10071 bulk ?
10072 fn.call( elems ) :
10073 len ? fn( elems[0], key ) : emptyGet;
10074 };
10075
10076
10077 /**
10078 * Determines whether an object can have data
10079 */
10080 jQuery.acceptData = function( owner ) {
10081 // Accepts only:
10082 // - Node
10083 // - Node.ELEMENT_NODE
10084 // - Node.DOCUMENT_NODE
10085 // - Object
10086 // - Any
10087 /* jshint -W018 */
10088 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
10089 };
10090
10091
10092 function Data() {
10093 // Support: Android < 4,
10094 // Old WebKit does not have Object.preventExtensions/freeze method,
10095 // return new empty object instead with no [[set]] accessor
10096 Object.defineProperty( this.cache = {}, 0, {
10097 get: function() {
10098 return {};
10099 }
10100 });
10101
10102 this.expando = jQuery.expando + Math.random();
10103 }
10104
10105 Data.uid = 1;
10106 Data.accepts = jQuery.acceptData;
10107
10108 Data.prototype = {
10109 key: function( owner ) {
10110 // We can accept data for non-element nodes in modern browsers,
10111 // but we should not, see #8335.
10112 // Always return the key for a frozen object.
10113 if ( !Data.accepts( owner ) ) {
10114 return 0;
10115 }
10116
10117 var descriptor = {},
10118 // Check if the owner object already has a cache key
10119 unlock = owner[ this.expando ];
10120
10121 // If not, create one
10122 if ( !unlock ) {
10123 unlock = Data.uid++;
10124
10125 // Secure it in a non-enumerable, non-writable property
10126 try {
10127 descriptor[ this.expando ] = { value: unlock };
10128 Object.defineProperties( owner, descriptor );
10129
10130 // Support: Android < 4
10131 // Fallback to a less secure definition
10132 } catch ( e ) {
10133 descriptor[ this.expando ] = unlock;
10134 jQuery.extend( owner, descriptor );
10135 }
10136 }
10137
10138 // Ensure the cache object
10139 if ( !this.cache[ unlock ] ) {
10140 this.cache[ unlock ] = {};
10141 }
10142
10143 return unlock;
10144 },
10145 set: function( owner, data, value ) {
10146 var prop,
10147 // There may be an unlock assigned to this node,
10148 // if there is no entry for this "owner", create one inline
10149 // and set the unlock as though an owner entry had always existed
10150 unlock = this.key( owner ),
10151 cache = this.cache[ unlock ];
10152
10153 // Handle: [ owner, key, value ] args
10154 if ( typeof data === "string" ) {
10155 cache[ data ] = value;
10156
10157 // Handle: [ owner, { properties } ] args
10158 } else {
10159 // Fresh assignments by object are shallow copied
10160 if ( jQuery.isEmptyObject( cache ) ) {
10161 jQuery.extend( this.cache[ unlock ], data );
10162 // Otherwise, copy the properties one-by-one to the cache object
10163 } else {
10164 for ( prop in data ) {
10165 cache[ prop ] = data[ prop ];
10166 }
10167 }
10168 }
10169 return cache;
10170 },
10171 get: function( owner, key ) {
10172 // Either a valid cache is found, or will be created.
10173 // New caches will be created and the unlock returned,
10174 // allowing direct access to the newly created
10175 // empty data object. A valid owner object must be provided.
10176 var cache = this.cache[ this.key( owner ) ];
10177
10178 return key === undefined ?
10179 cache : cache[ key ];
10180 },
10181 access: function( owner, key, value ) {
10182 var stored;
10183 // In cases where either:
10184 //
10185 // 1. No key was specified
10186 // 2. A string key was specified, but no value provided
10187 //
10188 // Take the "read" path and allow the get method to determine
10189 // which value to return, respectively either:
10190 //
10191 // 1. The entire cache object
10192 // 2. The data stored at the key
10193 //
10194 if ( key === undefined ||
10195 ((key && typeof key === "string") && value === undefined) ) {
10196
10197 stored = this.get( owner, key );
10198
10199 return stored !== undefined ?
10200 stored : this.get( owner, jQuery.camelCase(key) );
10201 }
10202
10203 // [*]When the key is not a string, or both a key and value
10204 // are specified, set or extend (existing objects) with either:
10205 //
10206 // 1. An object of properties
10207 // 2. A key and value
10208 //
10209 this.set( owner, key, value );
10210
10211 // Since the "set" path can have two possible entry points
10212 // return the expected data based on which path was taken[*]
10213 return value !== undefined ? value : key;
10214 },
10215 remove: function( owner, key ) {
10216 var i, name, camel,
10217 unlock = this.key( owner ),
10218 cache = this.cache[ unlock ];
10219
10220 if ( key === undefined ) {
10221 this.cache[ unlock ] = {};
10222
10223 } else {
10224 // Support array or space separated string of keys
10225 if ( jQuery.isArray( key ) ) {
10226 // If "name" is an array of keys...
10227 // When data is initially created, via ("key", "val") signature,
10228 // keys will be converted to camelCase.
10229 // Since there is no way to tell _how_ a key was added, remove
10230 // both plain key and camelCase key. #12786
10231 // This will only penalize the array argument path.
10232 name = key.concat( key.map( jQuery.camelCase ) );
10233 } else {
10234 camel = jQuery.camelCase( key );
10235 // Try the string as a key before any manipulation
10236 if ( key in cache ) {
10237 name = [ key, camel ];
10238 } else {
10239 // If a key with the spaces exists, use it.
10240 // Otherwise, create an array by matching non-whitespace
10241 name = camel;
10242 name = name in cache ?
10243 [ name ] : ( name.match( rnotwhite ) || [] );
10244 }
10245 }
10246
10247 i = name.length;
10248 while ( i-- ) {
10249 delete cache[ name[ i ] ];
10250 }
10251 }
10252 },
10253 hasData: function( owner ) {
10254 return !jQuery.isEmptyObject(
10255 this.cache[ owner[ this.expando ] ] || {}
10256 );
10257 },
10258 discard: function( owner ) {
10259 if ( owner[ this.expando ] ) {
10260 delete this.cache[ owner[ this.expando ] ];
10261 }
10262 }
10263 };
10264 var data_priv = new Data();
10265
10266 var data_user = new Data();
10267
10268
10269
10270 /*
10271 Implementation Summary
10272
10273 1. Enforce API surface and semantic compatibility with 1.9.x branch
10274 2. Improve the module's maintainability by reducing the storage
10275 paths to a single mechanism.
10276 3. Use the same single mechanism to support "private" and "user" data.
10277 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
10278 5. Avoid exposing implementation details on user objects (eg. expando properties)
10279 6. Provide a clear path for implementation upgrade to WeakMap in 2014
10280 */
10281 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
10282 rmultiDash = /([A-Z])/g;
10283
10284 function dataAttr( elem, key, data ) {
10285 var name;
10286
10287 // If nothing was found internally, try to fetch any
10288 // data from the HTML5 data-* attribute
10289 if ( data === undefined && elem.nodeType === 1 ) {
10290 name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
10291 data = elem.getAttribute( name );
10292
10293 if ( typeof data === "string" ) {
10294 try {
10295 data = data === "true" ? true :
10296 data === "false" ? false :
10297 data === "null" ? null :
10298 // Only convert to a number if it doesn't change the string
10299 +data + "" === data ? +data :
10300 rbrace.test( data ) ? jQuery.parseJSON( data ) :
10301 data;
10302 } catch( e ) {}
10303
10304 // Make sure we set the data so it isn't changed later
10305 data_user.set( elem, key, data );
10306 } else {
10307 data = undefined;
10308 }
10309 }
10310 return data;
10311 }
10312
10313 jQuery.extend({
10314 hasData: function( elem ) {
10315 return data_user.hasData( elem ) || data_priv.hasData( elem );
10316 },
10317
10318 data: function( elem, name, data ) {
10319 return data_user.access( elem, name, data );
10320 },
10321
10322 removeData: function( elem, name ) {
10323 data_user.remove( elem, name );
10324 },
10325
10326 // TODO: Now that all calls to _data and _removeData have been replaced
10327 // with direct calls to data_priv methods, these can be deprecated.
10328 _data: function( elem, name, data ) {
10329 return data_priv.access( elem, name, data );
10330 },
10331
10332 _removeData: function( elem, name ) {
10333 data_priv.remove( elem, name );
10334 }
10335 });
10336
10337 jQuery.fn.extend({
10338 data: function( key, value ) {
10339 var i, name, data,
10340 elem = this[ 0 ],
10341 attrs = elem && elem.attributes;
10342
10343 // Gets all values
10344 if ( key === undefined ) {
10345 if ( this.length ) {
10346 data = data_user.get( elem );
10347
10348 if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) {
10349 i = attrs.length;
10350 while ( i-- ) {
10351
10352 // Support: IE11+
10353 // The attrs elements can be null (#14894)
10354 if ( attrs[ i ] ) {
10355 name = attrs[ i ].name;
10356 if ( name.indexOf( "data-" ) === 0 ) {
10357 name = jQuery.camelCase( name.slice(5) );
10358 dataAttr( elem, name, data[ name ] );
10359 }
10360 }
10361 }
10362 data_priv.set( elem, "hasDataAttrs", true );
10363 }
10364 }
10365
10366 return data;
10367 }
10368
10369 // Sets multiple values
10370 if ( typeof key === "object" ) {
10371 return this.each(function() {
10372 data_user.set( this, key );
10373 });
10374 }
10375
10376 return access( this, function( value ) {
10377 var data,
10378 camelKey = jQuery.camelCase( key );
10379
10380 // The calling jQuery object (element matches) is not empty
10381 // (and therefore has an element appears at this[ 0 ]) and the
10382 // `value` parameter was not undefined. An empty jQuery object
10383 // will result in `undefined` for elem = this[ 0 ] which will
10384 // throw an exception if an attempt to read a data cache is made.
10385 if ( elem && value === undefined ) {
10386 // Attempt to get data from the cache
10387 // with the key as-is
10388 data = data_user.get( elem, key );
10389 if ( data !== undefined ) {
10390 return data;
10391 }
10392
10393 // Attempt to get data from the cache
10394 // with the key camelized
10395 data = data_user.get( elem, camelKey );
10396 if ( data !== undefined ) {
10397 return data;
10398 }
10399
10400 // Attempt to "discover" the data in
10401 // HTML5 custom data-* attrs
10402 data = dataAttr( elem, camelKey, undefined );
10403 if ( data !== undefined ) {
10404 return data;
10405 }
10406
10407 // We tried really hard, but the data doesn't exist.
10408 return;
10409 }
10410
10411 // Set the data...
10412 this.each(function() {
10413 // First, attempt to store a copy or reference of any
10414 // data that might've been store with a camelCased key.
10415 var data = data_user.get( this, camelKey );
10416
10417 // For HTML5 data-* attribute interop, we have to
10418 // store property names with dashes in a camelCase form.
10419 // This might not apply to all properties...*
10420 data_user.set( this, camelKey, value );
10421
10422 // *... In the case of properties that might _actually_
10423 // have dashes, we need to also store a copy of that
10424 // unchanged property.
10425 if ( key.indexOf("-") !== -1 && data !== undefined ) {
10426 data_user.set( this, key, value );
10427 }
10428 });
10429 }, null, value, arguments.length > 1, null, true );
10430 },
10431
10432 removeData: function( key ) {
10433 return this.each(function() {
10434 data_user.remove( this, key );
10435 });
10436 }
10437 });
10438
10439
10440 jQuery.extend({
10441 queue: function( elem, type, data ) {
10442 var queue;
10443
10444 if ( elem ) {
10445 type = ( type || "fx" ) + "queue";
10446 queue = data_priv.get( elem, type );
10447
10448 // Speed up dequeue by getting out quickly if this is just a lookup
10449 if ( data ) {
10450 if ( !queue || jQuery.isArray( data ) ) {
10451 queue = data_priv.access( elem, type, jQuery.makeArray(data) );
10452 } else {
10453 queue.push( data );
10454 }
10455 }
10456 return queue || [];
10457 }
10458 },
10459
10460 dequeue: function( elem, type ) {
10461 type = type || "fx";
10462
10463 var queue = jQuery.queue( elem, type ),
10464 startLength = queue.length,
10465 fn = queue.shift(),
10466 hooks = jQuery._queueHooks( elem, type ),
10467 next = function() {
10468 jQuery.dequeue( elem, type );
10469 };
10470
10471 // If the fx queue is dequeued, always remove the progress sentinel
10472 if ( fn === "inprogress" ) {
10473 fn = queue.shift();
10474 startLength--;
10475 }
10476
10477 if ( fn ) {
10478
10479 // Add a progress sentinel to prevent the fx queue from being
10480 // automatically dequeued
10481 if ( type === "fx" ) {
10482 queue.unshift( "inprogress" );
10483 }
10484
10485 // clear up the last queue stop function
10486 delete hooks.stop;
10487 fn.call( elem, next, hooks );
10488 }
10489
10490 if ( !startLength && hooks ) {
10491 hooks.empty.fire();
10492 }
10493 },
10494
10495 // not intended for public consumption - generates a queueHooks object, or returns the current one
10496 _queueHooks: function( elem, type ) {
10497 var key = type + "queueHooks";
10498 return data_priv.get( elem, key ) || data_priv.access( elem, key, {
10499 empty: jQuery.Callbacks("once memory").add(function() {
10500 data_priv.remove( elem, [ type + "queue", key ] );
10501 })
10502 });
10503 }
10504 });
10505
10506 jQuery.fn.extend({
10507 queue: function( type, data ) {
10508 var setter = 2;
10509
10510 if ( typeof type !== "string" ) {
10511 data = type;
10512 type = "fx";
10513 setter--;
10514 }
10515
10516 if ( arguments.length < setter ) {
10517 return jQuery.queue( this[0], type );
10518 }
10519
10520 return data === undefined ?
10521 this :
10522 this.each(function() {
10523 var queue = jQuery.queue( this, type, data );
10524
10525 // ensure a hooks for this queue
10526 jQuery._queueHooks( this, type );
10527
10528 if ( type === "fx" && queue[0] !== "inprogress" ) {
10529 jQuery.dequeue( this, type );
10530 }
10531 });
10532 },
10533 dequeue: function( type ) {
10534 return this.each(function() {
10535 jQuery.dequeue( this, type );
10536 });
10537 },
10538 clearQueue: function( type ) {
10539 return this.queue( type || "fx", [] );
10540 },
10541 // Get a promise resolved when queues of a certain type
10542 // are emptied (fx is the type by default)
10543 promise: function( type, obj ) {
10544 var tmp,
10545 count = 1,
10546 defer = jQuery.Deferred(),
10547 elements = this,
10548 i = this.length,
10549 resolve = function() {
10550 if ( !( --count ) ) {
10551 defer.resolveWith( elements, [ elements ] );
10552 }
10553 };
10554
10555 if ( typeof type !== "string" ) {
10556 obj = type;
10557 type = undefined;
10558 }
10559 type = type || "fx";
10560
10561 while ( i-- ) {
10562 tmp = data_priv.get( elements[ i ], type + "queueHooks" );
10563 if ( tmp && tmp.empty ) {
10564 count++;
10565 tmp.empty.add( resolve );
10566 }
10567 }
10568 resolve();
10569 return defer.promise( obj );
10570 }
10571 });
10572 var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
10573
10574 var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
10575
10576 var isHidden = function( elem, el ) {
10577 // isHidden might be called from jQuery#filter function;
10578 // in that case, element will be second argument
10579 elem = el || elem;
10580 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
10581 };
10582
10583 var rcheckableType = (/^(?:checkbox|radio)$/i);
10584
10585
10586
10587 (function() {
10588 var fragment = document.createDocumentFragment(),
10589 div = fragment.appendChild( document.createElement( "div" ) ),
10590 input = document.createElement( "input" );
10591
10592 // #11217 - WebKit loses check when the name is after the checked attribute
10593 // Support: Windows Web Apps (WWA)
10594 // `name` and `type` need .setAttribute for WWA
10595 input.setAttribute( "type", "radio" );
10596 input.setAttribute( "checked", "checked" );
10597 input.setAttribute( "name", "t" );
10598
10599 div.appendChild( input );
10600
10601 // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
10602 // old WebKit doesn't clone checked state correctly in fragments
10603 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
10604
10605 // Make sure textarea (and checkbox) defaultValue is properly cloned
10606 // Support: IE9-IE11+
10607 div.innerHTML = "<textarea>x</textarea>";
10608 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
10609 })();
10610 var strundefined = typeof undefined;
10611
10612
10613
10614 support.focusinBubbles = "onfocusin" in window;
10615
10616
10617 var
10618 rkeyEvent = /^key/,
10619 rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
10620 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
10621 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
10622
10623 function returnTrue() {
10624 return true;
10625 }
10626
10627 function returnFalse() {
10628 return false;
10629 }
10630
10631 function safeActiveElement() {
10632 try {
10633 return document.activeElement;
10634 } catch ( err ) { }
10635 }
10636
10637 /*
10638 * Helper functions for managing events -- not part of the public interface.
10639 * Props to Dean Edwards' addEvent library for many of the ideas.
10640 */
10641 jQuery.event = {
10642
10643 global: {},
10644
10645 add: function( elem, types, handler, data, selector ) {
10646
10647 var handleObjIn, eventHandle, tmp,
10648 events, t, handleObj,
10649 special, handlers, type, namespaces, origType,
10650 elemData = data_priv.get( elem );
10651
10652 // Don't attach events to noData or text/comment nodes (but allow plain objects)
10653 if ( !elemData ) {
10654 return;
10655 }
10656
10657 // Caller can pass in an object of custom data in lieu of the handler
10658 if ( handler.handler ) {
10659 handleObjIn = handler;
10660 handler = handleObjIn.handler;
10661 selector = handleObjIn.selector;
10662 }
10663
10664 // Make sure that the handler has a unique ID, used to find/remove it later
10665 if ( !handler.guid ) {
10666 handler.guid = jQuery.guid++;
10667 }
10668
10669 // Init the element's event structure and main handler, if this is the first
10670 if ( !(events = elemData.events) ) {
10671 events = elemData.events = {};
10672 }
10673 if ( !(eventHandle = elemData.handle) ) {
10674 eventHandle = elemData.handle = function( e ) {
10675 // Discard the second event of a jQuery.event.trigger() and
10676 // when an event is called after a page has unloaded
10677 return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ?
10678 jQuery.event.dispatch.apply( elem, arguments ) : undefined;
10679 };
10680 }
10681
10682 // Handle multiple events separated by a space
10683 types = ( types || "" ).match( rnotwhite ) || [ "" ];
10684 t = types.length;
10685 while ( t-- ) {
10686 tmp = rtypenamespace.exec( types[t] ) || [];
10687 type = origType = tmp[1];
10688 namespaces = ( tmp[2] || "" ).split( "." ).sort();
10689
10690 // There *must* be a type, no attaching namespace-only handlers
10691 if ( !type ) {
10692 continue;
10693 }
10694
10695 // If event changes its type, use the special event handlers for the changed type
10696 special = jQuery.event.special[ type ] || {};
10697
10698 // If selector defined, determine special event api type, otherwise given type
10699 type = ( selector ? special.delegateType : special.bindType ) || type;
10700
10701 // Update special based on newly reset type
10702 special = jQuery.event.special[ type ] || {};
10703
10704 // handleObj is passed to all event handlers
10705 handleObj = jQuery.extend({
10706 type: type,
10707 origType: origType,
10708 data: data,
10709 handler: handler,
10710 guid: handler.guid,
10711 selector: selector,
10712 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
10713 namespace: namespaces.join(".")
10714 }, handleObjIn );
10715
10716 // Init the event handler queue if we're the first
10717 if ( !(handlers = events[ type ]) ) {
10718 handlers = events[ type ] = [];
10719 handlers.delegateCount = 0;
10720
10721 // Only use addEventListener if the special events handler returns false
10722 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
10723 if ( elem.addEventListener ) {
10724 elem.addEventListener( type, eventHandle, false );
10725 }
10726 }
10727 }
10728
10729 if ( special.add ) {
10730 special.add.call( elem, handleObj );
10731
10732 if ( !handleObj.handler.guid ) {
10733 handleObj.handler.guid = handler.guid;
10734 }
10735 }
10736
10737 // Add to the element's handler list, delegates in front
10738 if ( selector ) {
10739 handlers.splice( handlers.delegateCount++, 0, handleObj );
10740 } else {
10741 handlers.push( handleObj );
10742 }
10743
10744 // Keep track of which events have ever been used, for event optimization
10745 jQuery.event.global[ type ] = true;
10746 }
10747
10748 },
10749
10750 // Detach an event or set of events from an element
10751 remove: function( elem, types, handler, selector, mappedTypes ) {
10752
10753 var j, origCount, tmp,
10754 events, t, handleObj,
10755 special, handlers, type, namespaces, origType,
10756 elemData = data_priv.hasData( elem ) && data_priv.get( elem );
10757
10758 if ( !elemData || !(events = elemData.events) ) {
10759 return;
10760 }
10761
10762 // Once for each type.namespace in types; type may be omitted
10763 types = ( types || "" ).match( rnotwhite ) || [ "" ];
10764 t = types.length;
10765 while ( t-- ) {
10766 tmp = rtypenamespace.exec( types[t] ) || [];
10767 type = origType = tmp[1];
10768 namespaces = ( tmp[2] || "" ).split( "." ).sort();
10769
10770 // Unbind all events (on this namespace, if provided) for the element
10771 if ( !type ) {
10772 for ( type in events ) {
10773 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
10774 }
10775 continue;
10776 }
10777
10778 special = jQuery.event.special[ type ] || {};
10779 type = ( selector ? special.delegateType : special.bindType ) || type;
10780 handlers = events[ type ] || [];
10781 tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
10782
10783 // Remove matching events
10784 origCount = j = handlers.length;
10785 while ( j-- ) {
10786 handleObj = handlers[ j ];
10787
10788 if ( ( mappedTypes || origType === handleObj.origType ) &&
10789 ( !handler || handler.guid === handleObj.guid ) &&
10790 ( !tmp || tmp.test( handleObj.namespace ) ) &&
10791 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
10792 handlers.splice( j, 1 );
10793
10794 if ( handleObj.selector ) {
10795 handlers.delegateCount--;
10796 }
10797 if ( special.remove ) {
10798 special.remove.call( elem, handleObj );
10799 }
10800 }
10801 }
10802
10803 // Remove generic event handler if we removed something and no more handlers exist
10804 // (avoids potential for endless recursion during removal of special event handlers)
10805 if ( origCount && !handlers.length ) {
10806 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
10807 jQuery.removeEvent( elem, type, elemData.handle );
10808 }
10809
10810 delete events[ type ];
10811 }
10812 }
10813
10814 // Remove the expando if it's no longer used
10815 if ( jQuery.isEmptyObject( events ) ) {
10816 delete elemData.handle;
10817 data_priv.remove( elem, "events" );
10818 }
10819 },
10820
10821 trigger: function( event, data, elem, onlyHandlers ) {
10822
10823 var i, cur, tmp, bubbleType, ontype, handle, special,
10824 eventPath = [ elem || document ],
10825 type = hasOwn.call( event, "type" ) ? event.type : event,
10826 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
10827
10828 cur = tmp = elem = elem || document;
10829
10830 // Don't do events on text and comment nodes
10831 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
10832 return;
10833 }
10834
10835 // focus/blur morphs to focusin/out; ensure we're not firing them right now
10836 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
10837 return;
10838 }
10839
10840 if ( type.indexOf(".") >= 0 ) {
10841 // Namespaced trigger; create a regexp to match event type in handle()
10842 namespaces = type.split(".");
10843 type = namespaces.shift();
10844 namespaces.sort();
10845 }
10846 ontype = type.indexOf(":") < 0 && "on" + type;
10847
10848 // Caller can pass in a jQuery.Event object, Object, or just an event type string
10849 event = event[ jQuery.expando ] ?
10850 event :
10851 new jQuery.Event( type, typeof event === "object" && event );
10852
10853 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
10854 event.isTrigger = onlyHandlers ? 2 : 3;
10855 event.namespace = namespaces.join(".");
10856 event.namespace_re = event.namespace ?
10857 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
10858 null;
10859
10860 // Clean up the event in case it is being reused
10861 event.result = undefined;
10862 if ( !event.target ) {
10863 event.target = elem;
10864 }
10865
10866 // Clone any incoming data and prepend the event, creating the handler arg list
10867 data = data == null ?
10868 [ event ] :
10869 jQuery.makeArray( data, [ event ] );
10870
10871 // Allow special events to draw outside the lines
10872 special = jQuery.event.special[ type ] || {};
10873 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
10874 return;
10875 }
10876
10877 // Determine event propagation path in advance, per W3C events spec (#9951)
10878 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
10879 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
10880
10881 bubbleType = special.delegateType || type;
10882 if ( !rfocusMorph.test( bubbleType + type ) ) {
10883 cur = cur.parentNode;
10884 }
10885 for ( ; cur; cur = cur.parentNode ) {
10886 eventPath.push( cur );
10887 tmp = cur;
10888 }
10889
10890 // Only add window if we got to document (e.g., not plain obj or detached DOM)
10891 if ( tmp === (elem.ownerDocument || document) ) {
10892 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
10893 }
10894 }
10895
10896 // Fire handlers on the event path
10897 i = 0;
10898 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
10899
10900 event.type = i > 1 ?
10901 bubbleType :
10902 special.bindType || type;
10903
10904 // jQuery handler
10905 handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" );
10906 if ( handle ) {
10907 handle.apply( cur, data );
10908 }
10909
10910 // Native handler
10911 handle = ontype && cur[ ontype ];
10912 if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
10913 event.result = handle.apply( cur, data );
10914 if ( event.result === false ) {
10915 event.preventDefault();
10916 }
10917 }
10918 }
10919 event.type = type;
10920
10921 // If nobody prevented the default action, do it now
10922 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
10923
10924 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
10925 jQuery.acceptData( elem ) ) {
10926
10927 // Call a native DOM method on the target with the same name name as the event.
10928 // Don't do default actions on window, that's where global variables be (#6170)
10929 if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
10930
10931 // Don't re-trigger an onFOO event when we call its FOO() method
10932 tmp = elem[ ontype ];
10933
10934 if ( tmp ) {
10935 elem[ ontype ] = null;
10936 }
10937
10938 // Prevent re-triggering of the same event, since we already bubbled it above
10939 jQuery.event.triggered = type;
10940 elem[ type ]();
10941 jQuery.event.triggered = undefined;
10942
10943 if ( tmp ) {
10944 elem[ ontype ] = tmp;
10945 }
10946 }
10947 }
10948 }
10949
10950 return event.result;
10951 },
10952
10953 dispatch: function( event ) {
10954
10955 // Make a writable jQuery.Event from the native event object
10956 event = jQuery.event.fix( event );
10957
10958 var i, j, ret, matched, handleObj,
10959 handlerQueue = [],
10960 args = slice.call( arguments ),
10961 handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [],
10962 special = jQuery.event.special[ event.type ] || {};
10963
10964 // Use the fix-ed jQuery.Event rather than the (read-only) native event
10965 args[0] = event;
10966 event.delegateTarget = this;
10967
10968 // Call the preDispatch hook for the mapped type, and let it bail if desired
10969 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
10970 return;
10971 }
10972
10973 // Determine handlers
10974 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
10975
10976 // Run delegates first; they may want to stop propagation beneath us
10977 i = 0;
10978 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
10979 event.currentTarget = matched.elem;
10980
10981 j = 0;
10982 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
10983
10984 // Triggered event must either 1) have no namespace, or
10985 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
10986 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
10987
10988 event.handleObj = handleObj;
10989 event.data = handleObj.data;
10990
10991 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
10992 .apply( matched.elem, args );
10993
10994 if ( ret !== undefined ) {
10995 if ( (event.result = ret) === false ) {
10996 event.preventDefault();
10997 event.stopPropagation();
10998 }
10999 }
11000 }
11001 }
11002 }
11003
11004 // Call the postDispatch hook for the mapped type
11005 if ( special.postDispatch ) {
11006 special.postDispatch.call( this, event );
11007 }
11008
11009 return event.result;
11010 },
11011
11012 handlers: function( event, handlers ) {
11013 var i, matches, sel, handleObj,
11014 handlerQueue = [],
11015 delegateCount = handlers.delegateCount,
11016 cur = event.target;
11017
11018 // Find delegate handlers
11019 // Black-hole SVG <use> instance trees (#13180)
11020 // Avoid non-left-click bubbling in Firefox (#3861)
11021 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
11022
11023 for ( ; cur !== this; cur = cur.parentNode || this ) {
11024
11025 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
11026 if ( cur.disabled !== true || event.type !== "click" ) {
11027 matches = [];
11028 for ( i = 0; i < delegateCount; i++ ) {
11029 handleObj = handlers[ i ];
11030
11031 // Don't conflict with Object.prototype properties (#13203)
11032 sel = handleObj.selector + " ";
11033
11034 if ( matches[ sel ] === undefined ) {
11035 matches[ sel ] = handleObj.needsContext ?
11036 jQuery( sel, this ).index( cur ) >= 0 :
11037 jQuery.find( sel, this, null, [ cur ] ).length;
11038 }
11039 if ( matches[ sel ] ) {
11040 matches.push( handleObj );
11041 }
11042 }
11043 if ( matches.length ) {
11044 handlerQueue.push({ elem: cur, handlers: matches });
11045 }
11046 }
11047 }
11048 }
11049
11050 // Add the remaining (directly-bound) handlers
11051 if ( delegateCount < handlers.length ) {
11052 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
11053 }
11054
11055 return handlerQueue;
11056 },
11057
11058 // Includes some event props shared by KeyEvent and MouseEvent
11059 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
11060
11061 fixHooks: {},
11062
11063 keyHooks: {
11064 props: "char charCode key keyCode".split(" "),
11065 filter: function( event, original ) {
11066
11067 // Add which for key events
11068 if ( event.which == null ) {
11069 event.which = original.charCode != null ? original.charCode : original.keyCode;
11070 }
11071
11072 return event;
11073 }
11074 },
11075
11076 mouseHooks: {
11077 props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
11078 filter: function( event, original ) {
11079 var eventDoc, doc, body,
11080 button = original.button;
11081
11082 // Calculate pageX/Y if missing and clientX/Y available
11083 if ( event.pageX == null && original.clientX != null ) {
11084 eventDoc = event.target.ownerDocument || document;
11085 doc = eventDoc.documentElement;
11086 body = eventDoc.body;
11087
11088 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
11089 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
11090 }
11091
11092 // Add which for click: 1 === left; 2 === middle; 3 === right
11093 // Note: button is not normalized, so don't use it
11094 if ( !event.which && button !== undefined ) {
11095 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
11096 }
11097
11098 return event;
11099 }
11100 },
11101
11102 fix: function( event ) {
11103 if ( event[ jQuery.expando ] ) {
11104 return event;
11105 }
11106
11107 // Create a writable copy of the event object and normalize some properties
11108 var i, prop, copy,
11109 type = event.type,
11110 originalEvent = event,
11111 fixHook = this.fixHooks[ type ];
11112
11113 if ( !fixHook ) {
11114 this.fixHooks[ type ] = fixHook =
11115 rmouseEvent.test( type ) ? this.mouseHooks :
11116 rkeyEvent.test( type ) ? this.keyHooks :
11117 {};
11118 }
11119 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
11120
11121 event = new jQuery.Event( originalEvent );
11122
11123 i = copy.length;
11124 while ( i-- ) {
11125 prop = copy[ i ];
11126 event[ prop ] = originalEvent[ prop ];
11127 }
11128
11129 // Support: Cordova 2.5 (WebKit) (#13255)
11130 // All events should have a target; Cordova deviceready doesn't
11131 if ( !event.target ) {
11132 event.target = document;
11133 }
11134
11135 // Support: Safari 6.0+, Chrome < 28
11136 // Target should not be a text node (#504, #13143)
11137 if ( event.target.nodeType === 3 ) {
11138 event.target = event.target.parentNode;
11139 }
11140
11141 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
11142 },
11143
11144 special: {
11145 load: {
11146 // Prevent triggered image.load events from bubbling to window.load
11147 noBubble: true
11148 },
11149 focus: {
11150 // Fire native event if possible so blur/focus sequence is correct
11151 trigger: function() {
11152 if ( this !== safeActiveElement() && this.focus ) {
11153 this.focus();
11154 return false;
11155 }
11156 },
11157 delegateType: "focusin"
11158 },
11159 blur: {
11160 trigger: function() {
11161 if ( this === safeActiveElement() && this.blur ) {
11162 this.blur();
11163 return false;
11164 }
11165 },
11166 delegateType: "focusout"
11167 },
11168 click: {
11169 // For checkbox, fire native event so checked state will be right
11170 trigger: function() {
11171 if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) {
11172 this.click();
11173 return false;
11174 }
11175 },
11176
11177 // For cross-browser consistency, don't fire native .click() on links
11178 _default: function( event ) {
11179 return jQuery.nodeName( event.target, "a" );
11180 }
11181 },
11182
11183 beforeunload: {
11184 postDispatch: function( event ) {
11185
11186 // Support: Firefox 20+
11187 // Firefox doesn't alert if the returnValue field is not set.
11188 if ( event.result !== undefined && event.originalEvent ) {
11189 event.originalEvent.returnValue = event.result;
11190 }
11191 }
11192 }
11193 },
11194
11195 simulate: function( type, elem, event, bubble ) {
11196 // Piggyback on a donor event to simulate a different one.
11197 // Fake originalEvent to avoid donor's stopPropagation, but if the
11198 // simulated event prevents default then we do the same on the donor.
11199 var e = jQuery.extend(
11200 new jQuery.Event(),
11201 event,
11202 {
11203 type: type,
11204 isSimulated: true,
11205 originalEvent: {}
11206 }
11207 );
11208 if ( bubble ) {
11209 jQuery.event.trigger( e, null, elem );
11210 } else {
11211 jQuery.event.dispatch.call( elem, e );
11212 }
11213 if ( e.isDefaultPrevented() ) {
11214 event.preventDefault();
11215 }
11216 }
11217 };
11218
11219 jQuery.removeEvent = function( elem, type, handle ) {
11220 if ( elem.removeEventListener ) {
11221 elem.removeEventListener( type, handle, false );
11222 }
11223 };
11224
11225 jQuery.Event = function( src, props ) {
11226 // Allow instantiation without the 'new' keyword
11227 if ( !(this instanceof jQuery.Event) ) {
11228 return new jQuery.Event( src, props );
11229 }
11230
11231 // Event object
11232 if ( src && src.type ) {
11233 this.originalEvent = src;
11234 this.type = src.type;
11235
11236 // Events bubbling up the document may have been marked as prevented
11237 // by a handler lower down the tree; reflect the correct value.
11238 this.isDefaultPrevented = src.defaultPrevented ||
11239 src.defaultPrevented === undefined &&
11240 // Support: Android < 4.0
11241 src.returnValue === false ?
11242 returnTrue :
11243 returnFalse;
11244
11245 // Event type
11246 } else {
11247 this.type = src;
11248 }
11249
11250 // Put explicitly provided properties onto the event object
11251 if ( props ) {
11252 jQuery.extend( this, props );
11253 }
11254
11255 // Create a timestamp if incoming event doesn't have one
11256 this.timeStamp = src && src.timeStamp || jQuery.now();
11257
11258 // Mark it as fixed
11259 this[ jQuery.expando ] = true;
11260 };
11261
11262 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
11263 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
11264 jQuery.Event.prototype = {
11265 isDefaultPrevented: returnFalse,
11266 isPropagationStopped: returnFalse,
11267 isImmediatePropagationStopped: returnFalse,
11268
11269 preventDefault: function() {
11270 var e = this.originalEvent;
11271
11272 this.isDefaultPrevented = returnTrue;
11273
11274 if ( e && e.preventDefault ) {
11275 e.preventDefault();
11276 }
11277 },
11278 stopPropagation: function() {
11279 var e = this.originalEvent;
11280
11281 this.isPropagationStopped = returnTrue;
11282
11283 if ( e && e.stopPropagation ) {
11284 e.stopPropagation();
11285 }
11286 },
11287 stopImmediatePropagation: function() {
11288 var e = this.originalEvent;
11289
11290 this.isImmediatePropagationStopped = returnTrue;
11291
11292 if ( e && e.stopImmediatePropagation ) {
11293 e.stopImmediatePropagation();
11294 }
11295
11296 this.stopPropagation();
11297 }
11298 };
11299
11300 // Create mouseenter/leave events using mouseover/out and event-time checks
11301 // Support: Chrome 15+
11302 jQuery.each({
11303 mouseenter: "mouseover",
11304 mouseleave: "mouseout",
11305 pointerenter: "pointerover",
11306 pointerleave: "pointerout"
11307 }, function( orig, fix ) {
11308 jQuery.event.special[ orig ] = {
11309 delegateType: fix,
11310 bindType: fix,
11311
11312 handle: function( event ) {
11313 var ret,
11314 target = this,
11315 related = event.relatedTarget,
11316 handleObj = event.handleObj;
11317
11318 // For mousenter/leave call the handler if related is outside the target.
11319 // NB: No relatedTarget if the mouse left/entered the browser window
11320 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
11321 event.type = handleObj.origType;
11322 ret = handleObj.handler.apply( this, arguments );
11323 event.type = fix;
11324 }
11325 return ret;
11326 }
11327 };
11328 });
11329
11330 // Create "bubbling" focus and blur events
11331 // Support: Firefox, Chrome, Safari
11332 if ( !support.focusinBubbles ) {
11333 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
11334
11335 // Attach a single capturing handler on the document while someone wants focusin/focusout
11336 var handler = function( event ) {
11337 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
11338 };
11339
11340 jQuery.event.special[ fix ] = {
11341 setup: function() {
11342 var doc = this.ownerDocument || this,
11343 attaches = data_priv.access( doc, fix );
11344
11345 if ( !attaches ) {
11346 doc.addEventListener( orig, handler, true );
11347 }
11348 data_priv.access( doc, fix, ( attaches || 0 ) + 1 );
11349 },
11350 teardown: function() {
11351 var doc = this.ownerDocument || this,
11352 attaches = data_priv.access( doc, fix ) - 1;
11353
11354 if ( !attaches ) {
11355 doc.removeEventListener( orig, handler, true );
11356 data_priv.remove( doc, fix );
11357
11358 } else {
11359 data_priv.access( doc, fix, attaches );
11360 }
11361 }
11362 };
11363 });
11364 }
11365
11366 jQuery.fn.extend({
11367
11368 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
11369 var origFn, type;
11370
11371 // Types can be a map of types/handlers
11372 if ( typeof types === "object" ) {
11373 // ( types-Object, selector, data )
11374 if ( typeof selector !== "string" ) {
11375 // ( types-Object, data )
11376 data = data || selector;
11377 selector = undefined;
11378 }
11379 for ( type in types ) {
11380 this.on( type, selector, data, types[ type ], one );
11381 }
11382 return this;
11383 }
11384
11385 if ( data == null && fn == null ) {
11386 // ( types, fn )
11387 fn = selector;
11388 data = selector = undefined;
11389 } else if ( fn == null ) {
11390 if ( typeof selector === "string" ) {
11391 // ( types, selector, fn )
11392 fn = data;
11393 data = undefined;
11394 } else {
11395 // ( types, data, fn )
11396 fn = data;
11397 data = selector;
11398 selector = undefined;
11399 }
11400 }
11401 if ( fn === false ) {
11402 fn = returnFalse;
11403 } else if ( !fn ) {
11404 return this;
11405 }
11406
11407 if ( one === 1 ) {
11408 origFn = fn;
11409 fn = function( event ) {
11410 // Can use an empty set, since event contains the info
11411 jQuery().off( event );
11412 return origFn.apply( this, arguments );
11413 };
11414 // Use same guid so caller can remove using origFn
11415 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
11416 }
11417 return this.each( function() {
11418 jQuery.event.add( this, types, fn, data, selector );
11419 });
11420 },
11421 one: function( types, selector, data, fn ) {
11422 return this.on( types, selector, data, fn, 1 );
11423 },
11424 off: function( types, selector, fn ) {
11425 var handleObj, type;
11426 if ( types && types.preventDefault && types.handleObj ) {
11427 // ( event ) dispatched jQuery.Event
11428 handleObj = types.handleObj;
11429 jQuery( types.delegateTarget ).off(
11430 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
11431 handleObj.selector,
11432 handleObj.handler
11433 );
11434 return this;
11435 }
11436 if ( typeof types === "object" ) {
11437 // ( types-object [, selector] )
11438 for ( type in types ) {
11439 this.off( type, selector, types[ type ] );
11440 }
11441 return this;
11442 }
11443 if ( selector === false || typeof selector === "function" ) {
11444 // ( types [, fn] )
11445 fn = selector;
11446 selector = undefined;
11447 }
11448 if ( fn === false ) {
11449 fn = returnFalse;
11450 }
11451 return this.each(function() {
11452 jQuery.event.remove( this, types, fn, selector );
11453 });
11454 },
11455
11456 trigger: function( type, data ) {
11457 return this.each(function() {
11458 jQuery.event.trigger( type, data, this );
11459 });
11460 },
11461 triggerHandler: function( type, data ) {
11462 var elem = this[0];
11463 if ( elem ) {
11464 return jQuery.event.trigger( type, data, elem, true );
11465 }
11466 }
11467 });
11468
11469
11470 var
11471 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
11472 rtagName = /<([\w:]+)/,
11473 rhtml = /<|&#?\w+;/,
11474 rnoInnerhtml = /<(?:script|style|link)/i,
11475 // checked="checked" or checked
11476 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
11477 rscriptType = /^$|\/(?:java|ecma)script/i,
11478 rscriptTypeMasked = /^true\/(.*)/,
11479 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
11480
11481 // We have to close these tags to support XHTML (#13200)
11482 wrapMap = {
11483
11484 // Support: IE 9
11485 option: [ 1, "<select multiple='multiple'>", "</select>" ],
11486
11487 thead: [ 1, "<table>", "</table>" ],
11488 col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
11489 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
11490 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
11491
11492 _default: [ 0, "", "" ]
11493 };
11494
11495 // Support: IE 9
11496 wrapMap.optgroup = wrapMap.option;
11497
11498 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
11499 wrapMap.th = wrapMap.td;
11500
11501 // Support: 1.x compatibility
11502 // Manipulating tables requires a tbody
11503 function manipulationTarget( elem, content ) {
11504 return jQuery.nodeName( elem, "table" ) &&
11505 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
11506
11507 elem.getElementsByTagName("tbody")[0] ||
11508 elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
11509 elem;
11510 }
11511
11512 // Replace/restore the type attribute of script elements for safe DOM manipulation
11513 function disableScript( elem ) {
11514 elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type;
11515 return elem;
11516 }
11517 function restoreScript( elem ) {
11518 var match = rscriptTypeMasked.exec( elem.type );
11519
11520 if ( match ) {
11521 elem.type = match[ 1 ];
11522 } else {
11523 elem.removeAttribute("type");
11524 }
11525
11526 return elem;
11527 }
11528
11529 // Mark scripts as having already been evaluated
11530 function setGlobalEval( elems, refElements ) {
11531 var i = 0,
11532 l = elems.length;
11533
11534 for ( ; i < l; i++ ) {
11535 data_priv.set(
11536 elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" )
11537 );
11538 }
11539 }
11540
11541 function cloneCopyEvent( src, dest ) {
11542 var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
11543
11544 if ( dest.nodeType !== 1 ) {
11545 return;
11546 }
11547
11548 // 1. Copy private data: events, handlers, etc.
11549 if ( data_priv.hasData( src ) ) {
11550 pdataOld = data_priv.access( src );
11551 pdataCur = data_priv.set( dest, pdataOld );
11552 events = pdataOld.events;
11553
11554 if ( events ) {
11555 delete pdataCur.handle;
11556 pdataCur.events = {};
11557
11558 for ( type in events ) {
11559 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
11560 jQuery.event.add( dest, type, events[ type ][ i ] );
11561 }
11562 }
11563 }
11564 }
11565
11566 // 2. Copy user data
11567 if ( data_user.hasData( src ) ) {
11568 udataOld = data_user.access( src );
11569 udataCur = jQuery.extend( {}, udataOld );
11570
11571 data_user.set( dest, udataCur );
11572 }
11573 }
11574
11575 function getAll( context, tag ) {
11576 var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) :
11577 context.querySelectorAll ? context.querySelectorAll( tag || "*" ) :
11578 [];
11579
11580 return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
11581 jQuery.merge( [ context ], ret ) :
11582 ret;
11583 }
11584
11585 // Support: IE >= 9
11586 function fixInput( src, dest ) {
11587 var nodeName = dest.nodeName.toLowerCase();
11588
11589 // Fails to persist the checked state of a cloned checkbox or radio button.
11590 if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
11591 dest.checked = src.checked;
11592
11593 // Fails to return the selected option to the default selected state when cloning options
11594 } else if ( nodeName === "input" || nodeName === "textarea" ) {
11595 dest.defaultValue = src.defaultValue;
11596 }
11597 }
11598
11599 jQuery.extend({
11600 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
11601 var i, l, srcElements, destElements,
11602 clone = elem.cloneNode( true ),
11603 inPage = jQuery.contains( elem.ownerDocument, elem );
11604
11605 // Support: IE >= 9
11606 // Fix Cloning issues
11607 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
11608 !jQuery.isXMLDoc( elem ) ) {
11609
11610 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
11611 destElements = getAll( clone );
11612 srcElements = getAll( elem );
11613
11614 for ( i = 0, l = srcElements.length; i < l; i++ ) {
11615 fixInput( srcElements[ i ], destElements[ i ] );
11616 }
11617 }
11618
11619 // Copy the events from the original to the clone
11620 if ( dataAndEvents ) {
11621 if ( deepDataAndEvents ) {
11622 srcElements = srcElements || getAll( elem );
11623 destElements = destElements || getAll( clone );
11624
11625 for ( i = 0, l = srcElements.length; i < l; i++ ) {
11626 cloneCopyEvent( srcElements[ i ], destElements[ i ] );
11627 }
11628 } else {
11629 cloneCopyEvent( elem, clone );
11630 }
11631 }
11632
11633 // Preserve script evaluation history
11634 destElements = getAll( clone, "script" );
11635 if ( destElements.length > 0 ) {
11636 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
11637 }
11638
11639 // Return the cloned set
11640 return clone;
11641 },
11642
11643 buildFragment: function( elems, context, scripts, selection ) {
11644 var elem, tmp, tag, wrap, contains, j,
11645 fragment = context.createDocumentFragment(),
11646 nodes = [],
11647 i = 0,
11648 l = elems.length;
11649
11650 for ( ; i < l; i++ ) {
11651 elem = elems[ i ];
11652
11653 if ( elem || elem === 0 ) {
11654
11655 // Add nodes directly
11656 if ( jQuery.type( elem ) === "object" ) {
11657 // Support: QtWebKit
11658 // jQuery.merge because push.apply(_, arraylike) throws
11659 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
11660
11661 // Convert non-html into a text node
11662 } else if ( !rhtml.test( elem ) ) {
11663 nodes.push( context.createTextNode( elem ) );
11664
11665 // Convert html into DOM nodes
11666 } else {
11667 tmp = tmp || fragment.appendChild( context.createElement("div") );
11668
11669 // Deserialize a standard representation
11670 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
11671 wrap = wrapMap[ tag ] || wrapMap._default;
11672 tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[ 2 ];
11673
11674 // Descend through wrappers to the right content
11675 j = wrap[ 0 ];
11676 while ( j-- ) {
11677 tmp = tmp.lastChild;
11678 }
11679
11680 // Support: QtWebKit
11681 // jQuery.merge because push.apply(_, arraylike) throws
11682 jQuery.merge( nodes, tmp.childNodes );
11683
11684 // Remember the top-level container
11685 tmp = fragment.firstChild;
11686
11687 // Fixes #12346
11688 // Support: Webkit, IE
11689 tmp.textContent = "";
11690 }
11691 }
11692 }
11693
11694 // Remove wrapper from fragment
11695 fragment.textContent = "";
11696
11697 i = 0;
11698 while ( (elem = nodes[ i++ ]) ) {
11699
11700 // #4087 - If origin and destination elements are the same, and this is
11701 // that element, do not do anything
11702 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
11703 continue;
11704 }
11705
11706 contains = jQuery.contains( elem.ownerDocument, elem );
11707
11708 // Append to fragment
11709 tmp = getAll( fragment.appendChild( elem ), "script" );
11710
11711 // Preserve script evaluation history
11712 if ( contains ) {
11713 setGlobalEval( tmp );
11714 }
11715
11716 // Capture executables
11717 if ( scripts ) {
11718 j = 0;
11719 while ( (elem = tmp[ j++ ]) ) {
11720 if ( rscriptType.test( elem.type || "" ) ) {
11721 scripts.push( elem );
11722 }
11723 }
11724 }
11725 }
11726
11727 return fragment;
11728 },
11729
11730 cleanData: function( elems ) {
11731 var data, elem, type, key,
11732 special = jQuery.event.special,
11733 i = 0;
11734
11735 for ( ; (elem = elems[ i ]) !== undefined; i++ ) {
11736 if ( jQuery.acceptData( elem ) ) {
11737 key = elem[ data_priv.expando ];
11738
11739 if ( key && (data = data_priv.cache[ key ]) ) {
11740 if ( data.events ) {
11741 for ( type in data.events ) {
11742 if ( special[ type ] ) {
11743 jQuery.event.remove( elem, type );
11744
11745 // This is a shortcut to avoid jQuery.event.remove's overhead
11746 } else {
11747 jQuery.removeEvent( elem, type, data.handle );
11748 }
11749 }
11750 }
11751 if ( data_priv.cache[ key ] ) {
11752 // Discard any remaining `private` data
11753 delete data_priv.cache[ key ];
11754 }
11755 }
11756 }
11757 // Discard any remaining `user` data
11758 delete data_user.cache[ elem[ data_user.expando ] ];
11759 }
11760 }
11761 });
11762
11763 jQuery.fn.extend({
11764 text: function( value ) {
11765 return access( this, function( value ) {
11766 return value === undefined ?
11767 jQuery.text( this ) :
11768 this.empty().each(function() {
11769 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
11770 this.textContent = value;
11771 }
11772 });
11773 }, null, value, arguments.length );
11774 },
11775
11776 append: function() {
11777 return this.domManip( arguments, function( elem ) {
11778 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
11779 var target = manipulationTarget( this, elem );
11780 target.appendChild( elem );
11781 }
11782 });
11783 },
11784
11785 prepend: function() {
11786 return this.domManip( arguments, function( elem ) {
11787 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
11788 var target = manipulationTarget( this, elem );
11789 target.insertBefore( elem, target.firstChild );
11790 }
11791 });
11792 },
11793
11794 before: function() {
11795 return this.domManip( arguments, function( elem ) {
11796 if ( this.parentNode ) {
11797 this.parentNode.insertBefore( elem, this );
11798 }
11799 });
11800 },
11801
11802 after: function() {
11803 return this.domManip( arguments, function( elem ) {
11804 if ( this.parentNode ) {
11805 this.parentNode.insertBefore( elem, this.nextSibling );
11806 }
11807 });
11808 },
11809
11810 remove: function( selector, keepData /* Internal Use Only */ ) {
11811 var elem,
11812 elems = selector ? jQuery.filter( selector, this ) : this,
11813 i = 0;
11814
11815 for ( ; (elem = elems[i]) != null; i++ ) {
11816 if ( !keepData && elem.nodeType === 1 ) {
11817 jQuery.cleanData( getAll( elem ) );
11818 }
11819
11820 if ( elem.parentNode ) {
11821 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
11822 setGlobalEval( getAll( elem, "script" ) );
11823 }
11824 elem.parentNode.removeChild( elem );
11825 }
11826 }
11827
11828 return this;
11829 },
11830
11831 empty: function() {
11832 var elem,
11833 i = 0;
11834
11835 for ( ; (elem = this[i]) != null; i++ ) {
11836 if ( elem.nodeType === 1 ) {
11837
11838 // Prevent memory leaks
11839 jQuery.cleanData( getAll( elem, false ) );
11840
11841 // Remove any remaining nodes
11842 elem.textContent = "";
11843 }
11844 }
11845
11846 return this;
11847 },
11848
11849 clone: function( dataAndEvents, deepDataAndEvents ) {
11850 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
11851 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
11852
11853 return this.map(function() {
11854 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
11855 });
11856 },
11857
11858 html: function( value ) {
11859 return access( this, function( value ) {
11860 var elem = this[ 0 ] || {},
11861 i = 0,
11862 l = this.length;
11863
11864 if ( value === undefined && elem.nodeType === 1 ) {
11865 return elem.innerHTML;
11866 }
11867
11868 // See if we can take a shortcut and just use innerHTML
11869 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
11870 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
11871
11872 value = value.replace( rxhtmlTag, "<$1></$2>" );
11873
11874 try {
11875 for ( ; i < l; i++ ) {
11876 elem = this[ i ] || {};
11877
11878 // Remove element nodes and prevent memory leaks
11879 if ( elem.nodeType === 1 ) {
11880 jQuery.cleanData( getAll( elem, false ) );
11881 elem.innerHTML = value;
11882 }
11883 }
11884
11885 elem = 0;
11886
11887 // If using innerHTML throws an exception, use the fallback method
11888 } catch( e ) {}
11889 }
11890
11891 if ( elem ) {
11892 this.empty().append( value );
11893 }
11894 }, null, value, arguments.length );
11895 },
11896
11897 replaceWith: function() {
11898 var arg = arguments[ 0 ];
11899
11900 // Make the changes, replacing each context element with the new content
11901 this.domManip( arguments, function( elem ) {
11902 arg = this.parentNode;
11903
11904 jQuery.cleanData( getAll( this ) );
11905
11906 if ( arg ) {
11907 arg.replaceChild( elem, this );
11908 }
11909 });
11910
11911 // Force removal if there was no new content (e.g., from empty arguments)
11912 return arg && (arg.length || arg.nodeType) ? this : this.remove();
11913 },
11914
11915 detach: function( selector ) {
11916 return this.remove( selector, true );
11917 },
11918
11919 domManip: function( args, callback ) {
11920
11921 // Flatten any nested arrays
11922 args = concat.apply( [], args );
11923
11924 var fragment, first, scripts, hasScripts, node, doc,
11925 i = 0,
11926 l = this.length,
11927 set = this,
11928 iNoClone = l - 1,
11929 value = args[ 0 ],
11930 isFunction = jQuery.isFunction( value );
11931
11932 // We can't cloneNode fragments that contain checked, in WebKit
11933 if ( isFunction ||
11934 ( l > 1 && typeof value === "string" &&
11935 !support.checkClone && rchecked.test( value ) ) ) {
11936 return this.each(function( index ) {
11937 var self = set.eq( index );
11938 if ( isFunction ) {
11939 args[ 0 ] = value.call( this, index, self.html() );
11940 }
11941 self.domManip( args, callback );
11942 });
11943 }
11944
11945 if ( l ) {
11946 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
11947 first = fragment.firstChild;
11948
11949 if ( fragment.childNodes.length === 1 ) {
11950 fragment = first;
11951 }
11952
11953 if ( first ) {
11954 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
11955 hasScripts = scripts.length;
11956
11957 // Use the original fragment for the last item instead of the first because it can end up
11958 // being emptied incorrectly in certain situations (#8070).
11959 for ( ; i < l; i++ ) {
11960 node = fragment;
11961
11962 if ( i !== iNoClone ) {
11963 node = jQuery.clone( node, true, true );
11964
11965 // Keep references to cloned scripts for later restoration
11966 if ( hasScripts ) {
11967 // Support: QtWebKit
11968 // jQuery.merge because push.apply(_, arraylike) throws
11969 jQuery.merge( scripts, getAll( node, "script" ) );
11970 }
11971 }
11972
11973 callback.call( this[ i ], node, i );
11974 }
11975
11976 if ( hasScripts ) {
11977 doc = scripts[ scripts.length - 1 ].ownerDocument;
11978
11979 // Reenable scripts
11980 jQuery.map( scripts, restoreScript );
11981
11982 // Evaluate executable scripts on first document insertion
11983 for ( i = 0; i < hasScripts; i++ ) {
11984 node = scripts[ i ];
11985 if ( rscriptType.test( node.type || "" ) &&
11986 !data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
11987
11988 if ( node.src ) {
11989 // Optional AJAX dependency, but won't run scripts if not present
11990 if ( jQuery._evalUrl ) {
11991 jQuery._evalUrl( node.src );
11992 }
11993 } else {
11994 jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) );
11995 }
11996 }
11997 }
11998 }
11999 }
12000 }
12001
12002 return this;
12003 }
12004 });
12005
12006 jQuery.each({
12007 appendTo: "append",
12008 prependTo: "prepend",
12009 insertBefore: "before",
12010 insertAfter: "after",
12011 replaceAll: "replaceWith"
12012 }, function( name, original ) {
12013 jQuery.fn[ name ] = function( selector ) {
12014 var elems,
12015 ret = [],
12016 insert = jQuery( selector ),
12017 last = insert.length - 1,
12018 i = 0;
12019
12020 for ( ; i <= last; i++ ) {
12021 elems = i === last ? this : this.clone( true );
12022 jQuery( insert[ i ] )[ original ]( elems );
12023
12024 // Support: QtWebKit
12025 // .get() because push.apply(_, arraylike) throws
12026 push.apply( ret, elems.get() );
12027 }
12028
12029 return this.pushStack( ret );
12030 };
12031 });
12032
12033
12034 var iframe,
12035 elemdisplay = {};
12036
12037 /**
12038 * Retrieve the actual display of a element
12039 * @param {String} name nodeName of the element
12040 * @param {Object} doc Document object
12041 */
12042 // Called only from within defaultDisplay
12043 function actualDisplay( name, doc ) {
12044 var style,
12045 elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
12046
12047 // getDefaultComputedStyle might be reliably used only on attached element
12048 display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
12049
12050 // Use of this method is a temporary fix (more like optmization) until something better comes along,
12051 // since it was removed from specification and supported only in FF
12052 style.display : jQuery.css( elem[ 0 ], "display" );
12053
12054 // We don't have any data stored on the element,
12055 // so use "detach" method as fast way to get rid of the element
12056 elem.detach();
12057
12058 return display;
12059 }
12060
12061 /**
12062 * Try to determine the default display value of an element
12063 * @param {String} nodeName
12064 */
12065 function defaultDisplay( nodeName ) {
12066 var doc = document,
12067 display = elemdisplay[ nodeName ];
12068
12069 if ( !display ) {
12070 display = actualDisplay( nodeName, doc );
12071
12072 // If the simple way fails, read from inside an iframe
12073 if ( display === "none" || !display ) {
12074
12075 // Use the already-created iframe if possible
12076 iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
12077
12078 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
12079 doc = iframe[ 0 ].contentDocument;
12080
12081 // Support: IE
12082 doc.write();
12083 doc.close();
12084
12085 display = actualDisplay( nodeName, doc );
12086 iframe.detach();
12087 }
12088
12089 // Store the correct default display
12090 elemdisplay[ nodeName ] = display;
12091 }
12092
12093 return display;
12094 }
12095 var rmargin = (/^margin/);
12096
12097 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
12098
12099 var getStyles = function( elem ) {
12100 return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
12101 };
12102
12103
12104
12105 function curCSS( elem, name, computed ) {
12106 var width, minWidth, maxWidth, ret,
12107 style = elem.style;
12108
12109 computed = computed || getStyles( elem );
12110
12111 // Support: IE9
12112 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
12113 if ( computed ) {
12114 ret = computed.getPropertyValue( name ) || computed[ name ];
12115 }
12116
12117 if ( computed ) {
12118
12119 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
12120 ret = jQuery.style( elem, name );
12121 }
12122
12123 // Support: iOS < 6
12124 // A tribute to the "awesome hack by Dean Edwards"
12125 // iOS < 6 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
12126 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
12127 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
12128
12129 // Remember the original values
12130 width = style.width;
12131 minWidth = style.minWidth;
12132 maxWidth = style.maxWidth;
12133
12134 // Put in the new values to get a computed value out
12135 style.minWidth = style.maxWidth = style.width = ret;
12136 ret = computed.width;
12137
12138 // Revert the changed values
12139 style.width = width;
12140 style.minWidth = minWidth;
12141 style.maxWidth = maxWidth;
12142 }
12143 }
12144
12145 return ret !== undefined ?
12146 // Support: IE
12147 // IE returns zIndex value as an integer.
12148 ret + "" :
12149 ret;
12150 }
12151
12152
12153 function addGetHookIf( conditionFn, hookFn ) {
12154 // Define the hook, we'll check on the first run if it's really needed.
12155 return {
12156 get: function() {
12157 if ( conditionFn() ) {
12158 // Hook not needed (or it's not possible to use it due to missing dependency),
12159 // remove it.
12160 // Since there are no other hooks for marginRight, remove the whole object.
12161 delete this.get;
12162 return;
12163 }
12164
12165 // Hook needed; redefine it so that the support test is not executed again.
12166
12167 return (this.get = hookFn).apply( this, arguments );
12168 }
12169 };
12170 }
12171
12172
12173 (function() {
12174 var pixelPositionVal, boxSizingReliableVal,
12175 docElem = document.documentElement,
12176 container = document.createElement( "div" ),
12177 div = document.createElement( "div" );
12178
12179 if ( !div.style ) {
12180 return;
12181 }
12182
12183 div.style.backgroundClip = "content-box";
12184 div.cloneNode( true ).style.backgroundClip = "";
12185 support.clearCloneStyle = div.style.backgroundClip === "content-box";
12186
12187 container.style.cssText = "border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;" +
12188 "position:absolute";
12189 container.appendChild( div );
12190
12191 // Executing both pixelPosition & boxSizingReliable tests require only one layout
12192 // so they're executed at the same time to save the second computation.
12193 function computePixelPositionAndBoxSizingReliable() {
12194 div.style.cssText =
12195 // Support: Firefox<29, Android 2.3
12196 // Vendor-prefix box-sizing
12197 "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
12198 "box-sizing:border-box;display:block;margin-top:1%;top:1%;" +
12199 "border:1px;padding:1px;width:4px;position:absolute";
12200 div.innerHTML = "";
12201 docElem.appendChild( container );
12202
12203 var divStyle = window.getComputedStyle( div, null );
12204 pixelPositionVal = divStyle.top !== "1%";
12205 boxSizingReliableVal = divStyle.width === "4px";
12206
12207 docElem.removeChild( container );
12208 }
12209
12210 // Support: node.js jsdom
12211 // Don't assume that getComputedStyle is a property of the global object
12212 if ( window.getComputedStyle ) {
12213 jQuery.extend( support, {
12214 pixelPosition: function() {
12215 // This test is executed only once but we still do memoizing
12216 // since we can use the boxSizingReliable pre-computing.
12217 // No need to check if the test was already performed, though.
12218 computePixelPositionAndBoxSizingReliable();
12219 return pixelPositionVal;
12220 },
12221 boxSizingReliable: function() {
12222 if ( boxSizingReliableVal == null ) {
12223 computePixelPositionAndBoxSizingReliable();
12224 }
12225 return boxSizingReliableVal;
12226 },
12227 reliableMarginRight: function() {
12228 // Support: Android 2.3
12229 // Check if div with explicit width and no margin-right incorrectly
12230 // gets computed margin-right based on width of container. (#3333)
12231 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
12232 // This support function is only executed once so no memoizing is needed.
12233 var ret,
12234 marginDiv = div.appendChild( document.createElement( "div" ) );
12235
12236 // Reset CSS: box-sizing; display; margin; border; padding
12237 marginDiv.style.cssText = div.style.cssText =
12238 // Support: Firefox<29, Android 2.3
12239 // Vendor-prefix box-sizing
12240 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
12241 "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
12242 marginDiv.style.marginRight = marginDiv.style.width = "0";
12243 div.style.width = "1px";
12244 docElem.appendChild( container );
12245
12246 ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );
12247
12248 docElem.removeChild( container );
12249
12250 return ret;
12251 }
12252 });
12253 }
12254 })();
12255
12256
12257 // A method for quickly swapping in/out CSS properties to get correct calculations.
12258 jQuery.swap = function( elem, options, callback, args ) {
12259 var ret, name,
12260 old = {};
12261
12262 // Remember the old values, and insert the new ones
12263 for ( name in options ) {
12264 old[ name ] = elem.style[ name ];
12265 elem.style[ name ] = options[ name ];
12266 }
12267
12268 ret = callback.apply( elem, args || [] );
12269
12270 // Revert the old values
12271 for ( name in options ) {
12272 elem.style[ name ] = old[ name ];
12273 }
12274
12275 return ret;
12276 };
12277
12278
12279 var
12280 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
12281 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
12282 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
12283 rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
12284 rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
12285
12286 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
12287 cssNormalTransform = {
12288 letterSpacing: "0",
12289 fontWeight: "400"
12290 },
12291
12292 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
12293
12294 // return a css property mapped to a potentially vendor prefixed property
12295 function vendorPropName( style, name ) {
12296
12297 // shortcut for names that are not vendor prefixed
12298 if ( name in style ) {
12299 return name;
12300 }
12301
12302 // check for vendor prefixed names
12303 var capName = name[0].toUpperCase() + name.slice(1),
12304 origName = name,
12305 i = cssPrefixes.length;
12306
12307 while ( i-- ) {
12308 name = cssPrefixes[ i ] + capName;
12309 if ( name in style ) {
12310 return name;
12311 }
12312 }
12313
12314 return origName;
12315 }
12316
12317 function setPositiveNumber( elem, value, subtract ) {
12318 var matches = rnumsplit.exec( value );
12319 return matches ?
12320 // Guard against undefined "subtract", e.g., when used as in cssHooks
12321 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
12322 value;
12323 }
12324
12325 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
12326 var i = extra === ( isBorderBox ? "border" : "content" ) ?
12327 // If we already have the right measurement, avoid augmentation
12328 4 :
12329 // Otherwise initialize for horizontal or vertical properties
12330 name === "width" ? 1 : 0,
12331
12332 val = 0;
12333
12334 for ( ; i < 4; i += 2 ) {
12335 // both box models exclude margin, so add it if we want it
12336 if ( extra === "margin" ) {
12337 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
12338 }
12339
12340 if ( isBorderBox ) {
12341 // border-box includes padding, so remove it if we want content
12342 if ( extra === "content" ) {
12343 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
12344 }
12345
12346 // at this point, extra isn't border nor margin, so remove border
12347 if ( extra !== "margin" ) {
12348 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
12349 }
12350 } else {
12351 // at this point, extra isn't content, so add padding
12352 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
12353
12354 // at this point, extra isn't content nor padding, so add border
12355 if ( extra !== "padding" ) {
12356 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
12357 }
12358 }
12359 }
12360
12361 return val;
12362 }
12363
12364 function getWidthOrHeight( elem, name, extra ) {
12365
12366 // Start with offset property, which is equivalent to the border-box value
12367 var valueIsBorderBox = true,
12368 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
12369 styles = getStyles( elem ),
12370 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
12371
12372 // some non-html elements return undefined for offsetWidth, so check for null/undefined
12373 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
12374 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
12375 if ( val <= 0 || val == null ) {
12376 // Fall back to computed then uncomputed css if necessary
12377 val = curCSS( elem, name, styles );
12378 if ( val < 0 || val == null ) {
12379 val = elem.style[ name ];
12380 }
12381
12382 // Computed unit is not pixels. Stop here and return.
12383 if ( rnumnonpx.test(val) ) {
12384 return val;
12385 }
12386
12387 // we need the check for style in case a browser which returns unreliable values
12388 // for getComputedStyle silently falls back to the reliable elem.style
12389 valueIsBorderBox = isBorderBox &&
12390 ( support.boxSizingReliable() || val === elem.style[ name ] );
12391
12392 // Normalize "", auto, and prepare for extra
12393 val = parseFloat( val ) || 0;
12394 }
12395
12396 // use the active box-sizing model to add/subtract irrelevant styles
12397 return ( val +
12398 augmentWidthOrHeight(
12399 elem,
12400 name,
12401 extra || ( isBorderBox ? "border" : "content" ),
12402 valueIsBorderBox,
12403 styles
12404 )
12405 ) + "px";
12406 }
12407
12408 function showHide( elements, show ) {
12409 var display, elem, hidden,
12410 values = [],
12411 index = 0,
12412 length = elements.length;
12413
12414 for ( ; index < length; index++ ) {
12415 elem = elements[ index ];
12416 if ( !elem.style ) {
12417 continue;
12418 }
12419
12420 values[ index ] = data_priv.get( elem, "olddisplay" );
12421 display = elem.style.display;
12422 if ( show ) {
12423 // Reset the inline display of this element to learn if it is
12424 // being hidden by cascaded rules or not
12425 if ( !values[ index ] && display === "none" ) {
12426 elem.style.display = "";
12427 }
12428
12429 // Set elements which have been overridden with display: none
12430 // in a stylesheet to whatever the default browser style is
12431 // for such an element
12432 if ( elem.style.display === "" && isHidden( elem ) ) {
12433 values[ index ] = data_priv.access( elem, "olddisplay", defaultDisplay(elem.nodeName) );
12434 }
12435 } else {
12436 hidden = isHidden( elem );
12437
12438 if ( display !== "none" || !hidden ) {
12439 data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
12440 }
12441 }
12442 }
12443
12444 // Set the display of most of the elements in a second loop
12445 // to avoid the constant reflow
12446 for ( index = 0; index < length; index++ ) {
12447 elem = elements[ index ];
12448 if ( !elem.style ) {
12449 continue;
12450 }
12451 if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
12452 elem.style.display = show ? values[ index ] || "" : "none";
12453 }
12454 }
12455
12456 return elements;
12457 }
12458
12459 jQuery.extend({
12460 // Add in style property hooks for overriding the default
12461 // behavior of getting and setting a style property
12462 cssHooks: {
12463 opacity: {
12464 get: function( elem, computed ) {
12465 if ( computed ) {
12466 // We should always get a number back from opacity
12467 var ret = curCSS( elem, "opacity" );
12468 return ret === "" ? "1" : ret;
12469 }
12470 }
12471 }
12472 },
12473
12474 // Don't automatically add "px" to these possibly-unitless properties
12475 cssNumber: {
12476 "columnCount": true,
12477 "fillOpacity": true,
12478 "flexGrow": true,
12479 "flexShrink": true,
12480 "fontWeight": true,
12481 "lineHeight": true,
12482 "opacity": true,
12483 "order": true,
12484 "orphans": true,
12485 "widows": true,
12486 "zIndex": true,
12487 "zoom": true
12488 },
12489
12490 // Add in properties whose names you wish to fix before
12491 // setting or getting the value
12492 cssProps: {
12493 // normalize float css property
12494 "float": "cssFloat"
12495 },
12496
12497 // Get and set the style property on a DOM Node
12498 style: function( elem, name, value, extra ) {
12499 // Don't set styles on text and comment nodes
12500 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
12501 return;
12502 }
12503
12504 // Make sure that we're working with the right name
12505 var ret, type, hooks,
12506 origName = jQuery.camelCase( name ),
12507 style = elem.style;
12508
12509 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
12510
12511 // gets hook for the prefixed version
12512 // followed by the unprefixed version
12513 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
12514
12515 // Check if we're setting a value
12516 if ( value !== undefined ) {
12517 type = typeof value;
12518
12519 // convert relative number strings (+= or -=) to relative numbers. #7345
12520 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
12521 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
12522 // Fixes bug #9237
12523 type = "number";
12524 }
12525
12526 // Make sure that null and NaN values aren't set. See: #7116
12527 if ( value == null || value !== value ) {
12528 return;
12529 }
12530
12531 // If a number was passed in, add 'px' to the (except for certain CSS properties)
12532 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
12533 value += "px";
12534 }
12535
12536 // Fixes #8908, it can be done more correctly by specifying setters in cssHooks,
12537 // but it would mean to define eight (for every problematic property) identical functions
12538 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
12539 style[ name ] = "inherit";
12540 }
12541
12542 // If a hook was provided, use that value, otherwise just set the specified value
12543 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
12544 style[ name ] = value;
12545 }
12546
12547 } else {
12548 // If a hook was provided get the non-computed value from there
12549 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
12550 return ret;
12551 }
12552
12553 // Otherwise just get the value from the style object
12554 return style[ name ];
12555 }
12556 },
12557
12558 css: function( elem, name, extra, styles ) {
12559 var val, num, hooks,
12560 origName = jQuery.camelCase( name );
12561
12562 // Make sure that we're working with the right name
12563 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
12564
12565 // gets hook for the prefixed version
12566 // followed by the unprefixed version
12567 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
12568
12569 // If a hook was provided get the computed value from there
12570 if ( hooks && "get" in hooks ) {
12571 val = hooks.get( elem, true, extra );
12572 }
12573
12574 // Otherwise, if a way to get the computed value exists, use that
12575 if ( val === undefined ) {
12576 val = curCSS( elem, name, styles );
12577 }
12578
12579 //convert "normal" to computed value
12580 if ( val === "normal" && name in cssNormalTransform ) {
12581 val = cssNormalTransform[ name ];
12582 }
12583
12584 // Return, converting to number if forced or a qualifier was provided and val looks numeric
12585 if ( extra === "" || extra ) {
12586 num = parseFloat( val );
12587 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
12588 }
12589 return val;
12590 }
12591 });
12592
12593 jQuery.each([ "height", "width" ], function( i, name ) {
12594 jQuery.cssHooks[ name ] = {
12595 get: function( elem, computed, extra ) {
12596 if ( computed ) {
12597 // certain elements can have dimension info if we invisibly show them
12598 // however, it must have a current display style that would benefit from this
12599 return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ?
12600 jQuery.swap( elem, cssShow, function() {
12601 return getWidthOrHeight( elem, name, extra );
12602 }) :
12603 getWidthOrHeight( elem, name, extra );
12604 }
12605 },
12606
12607 set: function( elem, value, extra ) {
12608 var styles = extra && getStyles( elem );
12609 return setPositiveNumber( elem, value, extra ?
12610 augmentWidthOrHeight(
12611 elem,
12612 name,
12613 extra,
12614 jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
12615 styles
12616 ) : 0
12617 );
12618 }
12619 };
12620 });
12621
12622 // Support: Android 2.3
12623 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
12624 function( elem, computed ) {
12625 if ( computed ) {
12626 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
12627 // Work around by temporarily setting element display to inline-block
12628 return jQuery.swap( elem, { "display": "inline-block" },
12629 curCSS, [ elem, "marginRight" ] );
12630 }
12631 }
12632 );
12633
12634 // These hooks are used by animate to expand properties
12635 jQuery.each({
12636 margin: "",
12637 padding: "",
12638 border: "Width"
12639 }, function( prefix, suffix ) {
12640 jQuery.cssHooks[ prefix + suffix ] = {
12641 expand: function( value ) {
12642 var i = 0,
12643 expanded = {},
12644
12645 // assumes a single number if not a string
12646 parts = typeof value === "string" ? value.split(" ") : [ value ];
12647
12648 for ( ; i < 4; i++ ) {
12649 expanded[ prefix + cssExpand[ i ] + suffix ] =
12650 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
12651 }
12652
12653 return expanded;
12654 }
12655 };
12656
12657 if ( !rmargin.test( prefix ) ) {
12658 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
12659 }
12660 });
12661
12662 jQuery.fn.extend({
12663 css: function( name, value ) {
12664 return access( this, function( elem, name, value ) {
12665 var styles, len,
12666 map = {},
12667 i = 0;
12668
12669 if ( jQuery.isArray( name ) ) {
12670 styles = getStyles( elem );
12671 len = name.length;
12672
12673 for ( ; i < len; i++ ) {
12674 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
12675 }
12676
12677 return map;
12678 }
12679
12680 return value !== undefined ?
12681 jQuery.style( elem, name, value ) :
12682 jQuery.css( elem, name );
12683 }, name, value, arguments.length > 1 );
12684 },
12685 show: function() {
12686 return showHide( this, true );
12687 },
12688 hide: function() {
12689 return showHide( this );
12690 },
12691 toggle: function( state ) {
12692 if ( typeof state === "boolean" ) {
12693 return state ? this.show() : this.hide();
12694 }
12695
12696 return this.each(function() {
12697 if ( isHidden( this ) ) {
12698 jQuery( this ).show();
12699 } else {
12700 jQuery( this ).hide();
12701 }
12702 });
12703 }
12704 });
12705
12706
12707 function Tween( elem, options, prop, end, easing ) {
12708 return new Tween.prototype.init( elem, options, prop, end, easing );
12709 }
12710 jQuery.Tween = Tween;
12711
12712 Tween.prototype = {
12713 constructor: Tween,
12714 init: function( elem, options, prop, end, easing, unit ) {
12715 this.elem = elem;
12716 this.prop = prop;
12717 this.easing = easing || "swing";
12718 this.options = options;
12719 this.start = this.now = this.cur();
12720 this.end = end;
12721 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
12722 },
12723 cur: function() {
12724 var hooks = Tween.propHooks[ this.prop ];
12725
12726 return hooks && hooks.get ?
12727 hooks.get( this ) :
12728 Tween.propHooks._default.get( this );
12729 },
12730 run: function( percent ) {
12731 var eased,
12732 hooks = Tween.propHooks[ this.prop ];
12733
12734 if ( this.options.duration ) {
12735 this.pos = eased = jQuery.easing[ this.easing ](
12736 percent, this.options.duration * percent, 0, 1, this.options.duration
12737 );
12738 } else {
12739 this.pos = eased = percent;
12740 }
12741 this.now = ( this.end - this.start ) * eased + this.start;
12742
12743 if ( this.options.step ) {
12744 this.options.step.call( this.elem, this.now, this );
12745 }
12746
12747 if ( hooks && hooks.set ) {
12748 hooks.set( this );
12749 } else {
12750 Tween.propHooks._default.set( this );
12751 }
12752 return this;
12753 }
12754 };
12755
12756 Tween.prototype.init.prototype = Tween.prototype;
12757
12758 Tween.propHooks = {
12759 _default: {
12760 get: function( tween ) {
12761 var result;
12762
12763 if ( tween.elem[ tween.prop ] != null &&
12764 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
12765 return tween.elem[ tween.prop ];
12766 }
12767
12768 // passing an empty string as a 3rd parameter to .css will automatically
12769 // attempt a parseFloat and fallback to a string if the parse fails
12770 // so, simple values such as "10px" are parsed to Float.
12771 // complex values such as "rotate(1rad)" are returned as is.
12772 result = jQuery.css( tween.elem, tween.prop, "" );
12773 // Empty strings, null, undefined and "auto" are converted to 0.
12774 return !result || result === "auto" ? 0 : result;
12775 },
12776 set: function( tween ) {
12777 // use step hook for back compat - use cssHook if its there - use .style if its
12778 // available and use plain properties where available
12779 if ( jQuery.fx.step[ tween.prop ] ) {
12780 jQuery.fx.step[ tween.prop ]( tween );
12781 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
12782 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
12783 } else {
12784 tween.elem[ tween.prop ] = tween.now;
12785 }
12786 }
12787 }
12788 };
12789
12790 // Support: IE9
12791 // Panic based approach to setting things on disconnected nodes
12792
12793 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
12794 set: function( tween ) {
12795 if ( tween.elem.nodeType && tween.elem.parentNode ) {
12796 tween.elem[ tween.prop ] = tween.now;
12797 }
12798 }
12799 };
12800
12801 jQuery.easing = {
12802 linear: function( p ) {
12803 return p;
12804 },
12805 swing: function( p ) {
12806 return 0.5 - Math.cos( p * Math.PI ) / 2;
12807 }
12808 };
12809
12810 jQuery.fx = Tween.prototype.init;
12811
12812 // Back Compat <1.8 extension point
12813 jQuery.fx.step = {};
12814
12815
12816
12817
12818 var
12819 fxNow, timerId,
12820 rfxtypes = /^(?:toggle|show|hide)$/,
12821 rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
12822 rrun = /queueHooks$/,
12823 animationPrefilters = [ defaultPrefilter ],
12824 tweeners = {
12825 "*": [ function( prop, value ) {
12826 var tween = this.createTween( prop, value ),
12827 target = tween.cur(),
12828 parts = rfxnum.exec( value ),
12829 unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
12830
12831 // Starting value computation is required for potential unit mismatches
12832 start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
12833 rfxnum.exec( jQuery.css( tween.elem, prop ) ),
12834 scale = 1,
12835 maxIterations = 20;
12836
12837 if ( start && start[ 3 ] !== unit ) {
12838 // Trust units reported by jQuery.css
12839 unit = unit || start[ 3 ];
12840
12841 // Make sure we update the tween properties later on
12842 parts = parts || [];
12843
12844 // Iteratively approximate from a nonzero starting point
12845 start = +target || 1;
12846
12847 do {
12848 // If previous iteration zeroed out, double until we get *something*
12849 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
12850 scale = scale || ".5";
12851
12852 // Adjust and apply
12853 start = start / scale;
12854 jQuery.style( tween.elem, prop, start + unit );
12855
12856 // Update scale, tolerating zero or NaN from tween.cur()
12857 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
12858 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
12859 }
12860
12861 // Update tween properties
12862 if ( parts ) {
12863 start = tween.start = +start || +target || 0;
12864 tween.unit = unit;
12865 // If a +=/-= token was provided, we're doing a relative animation
12866 tween.end = parts[ 1 ] ?
12867 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
12868 +parts[ 2 ];
12869 }
12870
12871 return tween;
12872 } ]
12873 };
12874
12875 // Animations created synchronously will run synchronously
12876 function createFxNow() {
12877 setTimeout(function() {
12878 fxNow = undefined;
12879 });
12880 return ( fxNow = jQuery.now() );
12881 }
12882
12883 // Generate parameters to create a standard animation
12884 function genFx( type, includeWidth ) {
12885 var which,
12886 i = 0,
12887 attrs = { height: type };
12888
12889 // if we include width, step value is 1 to do all cssExpand values,
12890 // if we don't include width, step value is 2 to skip over Left and Right
12891 includeWidth = includeWidth ? 1 : 0;
12892 for ( ; i < 4 ; i += 2 - includeWidth ) {
12893 which = cssExpand[ i ];
12894 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
12895 }
12896
12897 if ( includeWidth ) {
12898 attrs.opacity = attrs.width = type;
12899 }
12900
12901 return attrs;
12902 }
12903
12904 function createTween( value, prop, animation ) {
12905 var tween,
12906 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
12907 index = 0,
12908 length = collection.length;
12909 for ( ; index < length; index++ ) {
12910 if ( (tween = collection[ index ].call( animation, prop, value )) ) {
12911
12912 // we're done with this property
12913 return tween;
12914 }
12915 }
12916 }
12917
12918 function defaultPrefilter( elem, props, opts ) {
12919 /* jshint validthis: true */
12920 var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
12921 anim = this,
12922 orig = {},
12923 style = elem.style,
12924 hidden = elem.nodeType && isHidden( elem ),
12925 dataShow = data_priv.get( elem, "fxshow" );
12926
12927 // handle queue: false promises
12928 if ( !opts.queue ) {
12929 hooks = jQuery._queueHooks( elem, "fx" );
12930 if ( hooks.unqueued == null ) {
12931 hooks.unqueued = 0;
12932 oldfire = hooks.empty.fire;
12933 hooks.empty.fire = function() {
12934 if ( !hooks.unqueued ) {
12935 oldfire();
12936 }
12937 };
12938 }
12939 hooks.unqueued++;
12940
12941 anim.always(function() {
12942 // doing this makes sure that the complete handler will be called
12943 // before this completes
12944 anim.always(function() {
12945 hooks.unqueued--;
12946 if ( !jQuery.queue( elem, "fx" ).length ) {
12947 hooks.empty.fire();
12948 }
12949 });
12950 });
12951 }
12952
12953 // height/width overflow pass
12954 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
12955 // Make sure that nothing sneaks out
12956 // Record all 3 overflow attributes because IE9-10 do not
12957 // change the overflow attribute when overflowX and
12958 // overflowY are set to the same value
12959 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
12960
12961 // Set display property to inline-block for height/width
12962 // animations on inline elements that are having width/height animated
12963 display = jQuery.css( elem, "display" );
12964
12965 // Test default display if display is currently "none"
12966 checkDisplay = display === "none" ?
12967 data_priv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
12968
12969 if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
12970 style.display = "inline-block";
12971 }
12972 }
12973
12974 if ( opts.overflow ) {
12975 style.overflow = "hidden";
12976 anim.always(function() {
12977 style.overflow = opts.overflow[ 0 ];
12978 style.overflowX = opts.overflow[ 1 ];
12979 style.overflowY = opts.overflow[ 2 ];
12980 });
12981 }
12982
12983 // show/hide pass
12984 for ( prop in props ) {
12985 value = props[ prop ];
12986 if ( rfxtypes.exec( value ) ) {
12987 delete props[ prop ];
12988 toggle = toggle || value === "toggle";
12989 if ( value === ( hidden ? "hide" : "show" ) ) {
12990
12991 // If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden
12992 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
12993 hidden = true;
12994 } else {
12995 continue;
12996 }
12997 }
12998 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
12999
13000 // Any non-fx value stops us from restoring the original display value
13001 } else {
13002 display = undefined;
13003 }
13004 }
13005
13006 if ( !jQuery.isEmptyObject( orig ) ) {
13007 if ( dataShow ) {
13008 if ( "hidden" in dataShow ) {
13009 hidden = dataShow.hidden;
13010 }
13011 } else {
13012 dataShow = data_priv.access( elem, "fxshow", {} );
13013 }
13014
13015 // store state if its toggle - enables .stop().toggle() to "reverse"
13016 if ( toggle ) {
13017 dataShow.hidden = !hidden;
13018 }
13019 if ( hidden ) {
13020 jQuery( elem ).show();
13021 } else {
13022 anim.done(function() {
13023 jQuery( elem ).hide();
13024 });
13025 }
13026 anim.done(function() {
13027 var prop;
13028
13029 data_priv.remove( elem, "fxshow" );
13030 for ( prop in orig ) {
13031 jQuery.style( elem, prop, orig[ prop ] );
13032 }
13033 });
13034 for ( prop in orig ) {
13035 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
13036
13037 if ( !( prop in dataShow ) ) {
13038 dataShow[ prop ] = tween.start;
13039 if ( hidden ) {
13040 tween.end = tween.start;
13041 tween.start = prop === "width" || prop === "height" ? 1 : 0;
13042 }
13043 }
13044 }
13045
13046 // If this is a noop like .hide().hide(), restore an overwritten display value
13047 } else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) {
13048 style.display = display;
13049 }
13050 }
13051
13052 function propFilter( props, specialEasing ) {
13053 var index, name, easing, value, hooks;
13054
13055 // camelCase, specialEasing and expand cssHook pass
13056 for ( index in props ) {
13057 name = jQuery.camelCase( index );
13058 easing = specialEasing[ name ];
13059 value = props[ index ];
13060 if ( jQuery.isArray( value ) ) {
13061 easing = value[ 1 ];
13062 value = props[ index ] = value[ 0 ];
13063 }
13064
13065 if ( index !== name ) {
13066 props[ name ] = value;
13067 delete props[ index ];
13068 }
13069
13070 hooks = jQuery.cssHooks[ name ];
13071 if ( hooks && "expand" in hooks ) {
13072 value = hooks.expand( value );
13073 delete props[ name ];
13074
13075 // not quite $.extend, this wont overwrite keys already present.
13076 // also - reusing 'index' from above because we have the correct "name"
13077 for ( index in value ) {
13078 if ( !( index in props ) ) {
13079 props[ index ] = value[ index ];
13080 specialEasing[ index ] = easing;
13081 }
13082 }
13083 } else {
13084 specialEasing[ name ] = easing;
13085 }
13086 }
13087 }
13088
13089 function Animation( elem, properties, options ) {
13090 var result,
13091 stopped,
13092 index = 0,
13093 length = animationPrefilters.length,
13094 deferred = jQuery.Deferred().always( function() {
13095 // don't match elem in the :animated selector
13096 delete tick.elem;
13097 }),
13098 tick = function() {
13099 if ( stopped ) {
13100 return false;
13101 }
13102 var currentTime = fxNow || createFxNow(),
13103 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
13104 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
13105 temp = remaining / animation.duration || 0,
13106 percent = 1 - temp,
13107 index = 0,
13108 length = animation.tweens.length;
13109
13110 for ( ; index < length ; index++ ) {
13111 animation.tweens[ index ].run( percent );
13112 }
13113
13114 deferred.notifyWith( elem, [ animation, percent, remaining ]);
13115
13116 if ( percent < 1 && length ) {
13117 return remaining;
13118 } else {
13119 deferred.resolveWith( elem, [ animation ] );
13120 return false;
13121 }
13122 },
13123 animation = deferred.promise({
13124 elem: elem,
13125 props: jQuery.extend( {}, properties ),
13126 opts: jQuery.extend( true, { specialEasing: {} }, options ),
13127 originalProperties: properties,
13128 originalOptions: options,
13129 startTime: fxNow || createFxNow(),
13130 duration: options.duration,
13131 tweens: [],
13132 createTween: function( prop, end ) {
13133 var tween = jQuery.Tween( elem, animation.opts, prop, end,
13134 animation.opts.specialEasing[ prop ] || animation.opts.easing );
13135 animation.tweens.push( tween );
13136 return tween;
13137 },
13138 stop: function( gotoEnd ) {
13139 var index = 0,
13140 // if we are going to the end, we want to run all the tweens
13141 // otherwise we skip this part
13142 length = gotoEnd ? animation.tweens.length : 0;
13143 if ( stopped ) {
13144 return this;
13145 }
13146 stopped = true;
13147 for ( ; index < length ; index++ ) {
13148 animation.tweens[ index ].run( 1 );
13149 }
13150
13151 // resolve when we played the last frame
13152 // otherwise, reject
13153 if ( gotoEnd ) {
13154 deferred.resolveWith( elem, [ animation, gotoEnd ] );
13155 } else {
13156 deferred.rejectWith( elem, [ animation, gotoEnd ] );
13157 }
13158 return this;
13159 }
13160 }),
13161 props = animation.props;
13162
13163 propFilter( props, animation.opts.specialEasing );
13164
13165 for ( ; index < length ; index++ ) {
13166 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
13167 if ( result ) {
13168 return result;
13169 }
13170 }
13171
13172 jQuery.map( props, createTween, animation );
13173
13174 if ( jQuery.isFunction( animation.opts.start ) ) {
13175 animation.opts.start.call( elem, animation );
13176 }
13177
13178 jQuery.fx.timer(
13179 jQuery.extend( tick, {
13180 elem: elem,
13181 anim: animation,
13182 queue: animation.opts.queue
13183 })
13184 );
13185
13186 // attach callbacks from options
13187 return animation.progress( animation.opts.progress )
13188 .done( animation.opts.done, animation.opts.complete )
13189 .fail( animation.opts.fail )
13190 .always( animation.opts.always );
13191 }
13192
13193 jQuery.Animation = jQuery.extend( Animation, {
13194
13195 tweener: function( props, callback ) {
13196 if ( jQuery.isFunction( props ) ) {
13197 callback = props;
13198 props = [ "*" ];
13199 } else {
13200 props = props.split(" ");
13201 }
13202
13203 var prop,
13204 index = 0,
13205 length = props.length;
13206
13207 for ( ; index < length ; index++ ) {
13208 prop = props[ index ];
13209 tweeners[ prop ] = tweeners[ prop ] || [];
13210 tweeners[ prop ].unshift( callback );
13211 }
13212 },
13213
13214 prefilter: function( callback, prepend ) {
13215 if ( prepend ) {
13216 animationPrefilters.unshift( callback );
13217 } else {
13218 animationPrefilters.push( callback );
13219 }
13220 }
13221 });
13222
13223 jQuery.speed = function( speed, easing, fn ) {
13224 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
13225 complete: fn || !fn && easing ||
13226 jQuery.isFunction( speed ) && speed,
13227 duration: speed,
13228 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
13229 };
13230
13231 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
13232 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
13233
13234 // normalize opt.queue - true/undefined/null -> "fx"
13235 if ( opt.queue == null || opt.queue === true ) {
13236 opt.queue = "fx";
13237 }
13238
13239 // Queueing
13240 opt.old = opt.complete;
13241
13242 opt.complete = function() {
13243 if ( jQuery.isFunction( opt.old ) ) {
13244 opt.old.call( this );
13245 }
13246
13247 if ( opt.queue ) {
13248 jQuery.dequeue( this, opt.queue );
13249 }
13250 };
13251
13252 return opt;
13253 };
13254
13255 jQuery.fn.extend({
13256 fadeTo: function( speed, to, easing, callback ) {
13257
13258 // show any hidden elements after setting opacity to 0
13259 return this.filter( isHidden ).css( "opacity", 0 ).show()
13260
13261 // animate to the value specified
13262 .end().animate({ opacity: to }, speed, easing, callback );
13263 },
13264 animate: function( prop, speed, easing, callback ) {
13265 var empty = jQuery.isEmptyObject( prop ),
13266 optall = jQuery.speed( speed, easing, callback ),
13267 doAnimation = function() {
13268 // Operate on a copy of prop so per-property easing won't be lost
13269 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
13270
13271 // Empty animations, or finishing resolves immediately
13272 if ( empty || data_priv.get( this, "finish" ) ) {
13273 anim.stop( true );
13274 }
13275 };
13276 doAnimation.finish = doAnimation;
13277
13278 return empty || optall.queue === false ?
13279 this.each( doAnimation ) :
13280 this.queue( optall.queue, doAnimation );
13281 },
13282 stop: function( type, clearQueue, gotoEnd ) {
13283 var stopQueue = function( hooks ) {
13284 var stop = hooks.stop;
13285 delete hooks.stop;
13286 stop( gotoEnd );
13287 };
13288
13289 if ( typeof type !== "string" ) {
13290 gotoEnd = clearQueue;
13291 clearQueue = type;
13292 type = undefined;
13293 }
13294 if ( clearQueue && type !== false ) {
13295 this.queue( type || "fx", [] );
13296 }
13297
13298 return this.each(function() {
13299 var dequeue = true,
13300 index = type != null && type + "queueHooks",
13301 timers = jQuery.timers,
13302 data = data_priv.get( this );
13303
13304 if ( index ) {
13305 if ( data[ index ] && data[ index ].stop ) {
13306 stopQueue( data[ index ] );
13307 }
13308 } else {
13309 for ( index in data ) {
13310 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
13311 stopQueue( data[ index ] );
13312 }
13313 }
13314 }
13315
13316 for ( index = timers.length; index--; ) {
13317 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
13318 timers[ index ].anim.stop( gotoEnd );
13319 dequeue = false;
13320 timers.splice( index, 1 );
13321 }
13322 }
13323
13324 // start the next in the queue if the last step wasn't forced
13325 // timers currently will call their complete callbacks, which will dequeue
13326 // but only if they were gotoEnd
13327 if ( dequeue || !gotoEnd ) {
13328 jQuery.dequeue( this, type );
13329 }
13330 });
13331 },
13332 finish: function( type ) {
13333 if ( type !== false ) {
13334 type = type || "fx";
13335 }
13336 return this.each(function() {
13337 var index,
13338 data = data_priv.get( this ),
13339 queue = data[ type + "queue" ],
13340 hooks = data[ type + "queueHooks" ],
13341 timers = jQuery.timers,
13342 length = queue ? queue.length : 0;
13343
13344 // enable finishing flag on private data
13345 data.finish = true;
13346
13347 // empty the queue first
13348 jQuery.queue( this, type, [] );
13349
13350 if ( hooks && hooks.stop ) {
13351 hooks.stop.call( this, true );
13352 }
13353
13354 // look for any active animations, and finish them
13355 for ( index = timers.length; index--; ) {
13356 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
13357 timers[ index ].anim.stop( true );
13358 timers.splice( index, 1 );
13359 }
13360 }
13361
13362 // look for any animations in the old queue and finish them
13363 for ( index = 0; index < length; index++ ) {
13364 if ( queue[ index ] && queue[ index ].finish ) {
13365 queue[ index ].finish.call( this );
13366 }
13367 }
13368
13369 // turn off finishing flag
13370 delete data.finish;
13371 });
13372 }
13373 });
13374
13375 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
13376 var cssFn = jQuery.fn[ name ];
13377 jQuery.fn[ name ] = function( speed, easing, callback ) {
13378 return speed == null || typeof speed === "boolean" ?
13379 cssFn.apply( this, arguments ) :
13380 this.animate( genFx( name, true ), speed, easing, callback );
13381 };
13382 });
13383
13384 // Generate shortcuts for custom animations
13385 jQuery.each({
13386 slideDown: genFx("show"),
13387 slideUp: genFx("hide"),
13388 slideToggle: genFx("toggle"),
13389 fadeIn: { opacity: "show" },
13390 fadeOut: { opacity: "hide" },
13391 fadeToggle: { opacity: "toggle" }
13392 }, function( name, props ) {
13393 jQuery.fn[ name ] = function( speed, easing, callback ) {
13394 return this.animate( props, speed, easing, callback );
13395 };
13396 });
13397
13398 jQuery.timers = [];
13399 jQuery.fx.tick = function() {
13400 var timer,
13401 i = 0,
13402 timers = jQuery.timers;
13403
13404 fxNow = jQuery.now();
13405
13406 for ( ; i < timers.length; i++ ) {
13407 timer = timers[ i ];
13408 // Checks the timer has not already been removed
13409 if ( !timer() && timers[ i ] === timer ) {
13410 timers.splice( i--, 1 );
13411 }
13412 }
13413
13414 if ( !timers.length ) {
13415 jQuery.fx.stop();
13416 }
13417 fxNow = undefined;
13418 };
13419
13420 jQuery.fx.timer = function( timer ) {
13421 jQuery.timers.push( timer );
13422 if ( timer() ) {
13423 jQuery.fx.start();
13424 } else {
13425 jQuery.timers.pop();
13426 }
13427 };
13428
13429 jQuery.fx.interval = 13;
13430
13431 jQuery.fx.start = function() {
13432 if ( !timerId ) {
13433 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
13434 }
13435 };
13436
13437 jQuery.fx.stop = function() {
13438 clearInterval( timerId );
13439 timerId = null;
13440 };
13441
13442 jQuery.fx.speeds = {
13443 slow: 600,
13444 fast: 200,
13445 // Default speed
13446 _default: 400
13447 };
13448
13449
13450 // Based off of the plugin by Clint Helfers, with permission.
13451 // http://blindsignals.com/index.php/2009/07/jquery-delay/
13452 jQuery.fn.delay = function( time, type ) {
13453 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
13454 type = type || "fx";
13455
13456 return this.queue( type, function( next, hooks ) {
13457 var timeout = setTimeout( next, time );
13458 hooks.stop = function() {
13459 clearTimeout( timeout );
13460 };
13461 });
13462 };
13463
13464
13465 (function() {
13466 var input = document.createElement( "input" ),
13467 select = document.createElement( "select" ),
13468 opt = select.appendChild( document.createElement( "option" ) );
13469
13470 input.type = "checkbox";
13471
13472 // Support: iOS 5.1, Android 4.x, Android 2.3
13473 // Check the default checkbox/radio value ("" on old WebKit; "on" elsewhere)
13474 support.checkOn = input.value !== "";
13475
13476 // Must access the parent to make an option select properly
13477 // Support: IE9, IE10
13478 support.optSelected = opt.selected;
13479
13480 // Make sure that the options inside disabled selects aren't marked as disabled
13481 // (WebKit marks them as disabled)
13482 select.disabled = true;
13483 support.optDisabled = !opt.disabled;
13484
13485 // Check if an input maintains its value after becoming a radio
13486 // Support: IE9, IE10
13487 input = document.createElement( "input" );
13488 input.value = "t";
13489 input.type = "radio";
13490 support.radioValue = input.value === "t";
13491 })();
13492
13493
13494 var nodeHook, boolHook,
13495 attrHandle = jQuery.expr.attrHandle;
13496
13497 jQuery.fn.extend({
13498 attr: function( name, value ) {
13499 return access( this, jQuery.attr, name, value, arguments.length > 1 );
13500 },
13501
13502 removeAttr: function( name ) {
13503 return this.each(function() {
13504 jQuery.removeAttr( this, name );
13505 });
13506 }
13507 });
13508
13509 jQuery.extend({
13510 attr: function( elem, name, value ) {
13511 var hooks, ret,
13512 nType = elem.nodeType;
13513
13514 // don't get/set attributes on text, comment and attribute nodes
13515 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
13516 return;
13517 }
13518
13519 // Fallback to prop when attributes are not supported
13520 if ( typeof elem.getAttribute === strundefined ) {
13521 return jQuery.prop( elem, name, value );
13522 }
13523
13524 // All attributes are lowercase
13525 // Grab necessary hook if one is defined
13526 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
13527 name = name.toLowerCase();
13528 hooks = jQuery.attrHooks[ name ] ||
13529 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
13530 }
13531
13532 if ( value !== undefined ) {
13533
13534 if ( value === null ) {
13535 jQuery.removeAttr( elem, name );
13536
13537 } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
13538 return ret;
13539
13540 } else {
13541 elem.setAttribute( name, value + "" );
13542 return value;
13543 }
13544
13545 } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
13546 return ret;
13547
13548 } else {
13549 ret = jQuery.find.attr( elem, name );
13550
13551 // Non-existent attributes return null, we normalize to undefined
13552 return ret == null ?
13553 undefined :
13554 ret;
13555 }
13556 },
13557
13558 removeAttr: function( elem, value ) {
13559 var name, propName,
13560 i = 0,
13561 attrNames = value && value.match( rnotwhite );
13562
13563 if ( attrNames && elem.nodeType === 1 ) {
13564 while ( (name = attrNames[i++]) ) {
13565 propName = jQuery.propFix[ name ] || name;
13566
13567 // Boolean attributes get special treatment (#10870)
13568 if ( jQuery.expr.match.bool.test( name ) ) {
13569 // Set corresponding property to false
13570 elem[ propName ] = false;
13571 }
13572
13573 elem.removeAttribute( name );
13574 }
13575 }
13576 },
13577
13578 attrHooks: {
13579 type: {
13580 set: function( elem, value ) {
13581 if ( !support.radioValue && value === "radio" &&
13582 jQuery.nodeName( elem, "input" ) ) {
13583 // Setting the type on a radio button after the value resets the value in IE6-9
13584 // Reset value to default in case type is set after value during creation
13585 var val = elem.value;
13586 elem.setAttribute( "type", value );
13587 if ( val ) {
13588 elem.value = val;
13589 }
13590 return value;
13591 }
13592 }
13593 }
13594 }
13595 });
13596
13597 // Hooks for boolean attributes
13598 boolHook = {
13599 set: function( elem, value, name ) {
13600 if ( value === false ) {
13601 // Remove boolean attributes when set to false
13602 jQuery.removeAttr( elem, name );
13603 } else {
13604 elem.setAttribute( name, name );
13605 }
13606 return name;
13607 }
13608 };
13609 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
13610 var getter = attrHandle[ name ] || jQuery.find.attr;
13611
13612 attrHandle[ name ] = function( elem, name, isXML ) {
13613 var ret, handle;
13614 if ( !isXML ) {
13615 // Avoid an infinite loop by temporarily removing this function from the getter
13616 handle = attrHandle[ name ];
13617 attrHandle[ name ] = ret;
13618 ret = getter( elem, name, isXML ) != null ?
13619 name.toLowerCase() :
13620 null;
13621 attrHandle[ name ] = handle;
13622 }
13623 return ret;
13624 };
13625 });
13626
13627
13628
13629
13630 var rfocusable = /^(?:input|select|textarea|button)$/i;
13631
13632 jQuery.fn.extend({
13633 prop: function( name, value ) {
13634 return access( this, jQuery.prop, name, value, arguments.length > 1 );
13635 },
13636
13637 removeProp: function( name ) {
13638 return this.each(function() {
13639 delete this[ jQuery.propFix[ name ] || name ];
13640 });
13641 }
13642 });
13643
13644 jQuery.extend({
13645 propFix: {
13646 "for": "htmlFor",
13647 "class": "className"
13648 },
13649
13650 prop: function( elem, name, value ) {
13651 var ret, hooks, notxml,
13652 nType = elem.nodeType;
13653
13654 // don't get/set properties on text, comment and attribute nodes
13655 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
13656 return;
13657 }
13658
13659 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
13660
13661 if ( notxml ) {
13662 // Fix name and attach hooks
13663 name = jQuery.propFix[ name ] || name;
13664 hooks = jQuery.propHooks[ name ];
13665 }
13666
13667 if ( value !== undefined ) {
13668 return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
13669 ret :
13670 ( elem[ name ] = value );
13671
13672 } else {
13673 return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
13674 ret :
13675 elem[ name ];
13676 }
13677 },
13678
13679 propHooks: {
13680 tabIndex: {
13681 get: function( elem ) {
13682 return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ?
13683 elem.tabIndex :
13684 -1;
13685 }
13686 }
13687 }
13688 });
13689
13690 // Support: IE9+
13691 // Selectedness for an option in an optgroup can be inaccurate
13692 if ( !support.optSelected ) {
13693 jQuery.propHooks.selected = {
13694 get: function( elem ) {
13695 var parent = elem.parentNode;
13696 if ( parent && parent.parentNode ) {
13697 parent.parentNode.selectedIndex;
13698 }
13699 return null;
13700 }
13701 };
13702 }
13703
13704 jQuery.each([
13705 "tabIndex",
13706 "readOnly",
13707 "maxLength",
13708 "cellSpacing",
13709 "cellPadding",
13710 "rowSpan",
13711 "colSpan",
13712 "useMap",
13713 "frameBorder",
13714 "contentEditable"
13715 ], function() {
13716 jQuery.propFix[ this.toLowerCase() ] = this;
13717 });
13718
13719
13720
13721
13722 var rclass = /[\t\r\n\f]/g;
13723
13724 jQuery.fn.extend({
13725 addClass: function( value ) {
13726 var classes, elem, cur, clazz, j, finalValue,
13727 proceed = typeof value === "string" && value,
13728 i = 0,
13729 len = this.length;
13730
13731 if ( jQuery.isFunction( value ) ) {
13732 return this.each(function( j ) {
13733 jQuery( this ).addClass( value.call( this, j, this.className ) );
13734 });
13735 }
13736
13737 if ( proceed ) {
13738 // The disjunction here is for better compressibility (see removeClass)
13739 classes = ( value || "" ).match( rnotwhite ) || [];
13740
13741 for ( ; i < len; i++ ) {
13742 elem = this[ i ];
13743 cur = elem.nodeType === 1 && ( elem.className ?
13744 ( " " + elem.className + " " ).replace( rclass, " " ) :
13745 " "
13746 );
13747
13748 if ( cur ) {
13749 j = 0;
13750 while ( (clazz = classes[j++]) ) {
13751 if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
13752 cur += clazz + " ";
13753 }
13754 }
13755
13756 // only assign if different to avoid unneeded rendering.
13757 finalValue = jQuery.trim( cur );
13758 if ( elem.className !== finalValue ) {
13759 elem.className = finalValue;
13760 }
13761 }
13762 }
13763 }
13764
13765 return this;
13766 },
13767
13768 removeClass: function( value ) {
13769 var classes, elem, cur, clazz, j, finalValue,
13770 proceed = arguments.length === 0 || typeof value === "string" && value,
13771 i = 0,
13772 len = this.length;
13773
13774 if ( jQuery.isFunction( value ) ) {
13775 return this.each(function( j ) {
13776 jQuery( this ).removeClass( value.call( this, j, this.className ) );
13777 });
13778 }
13779 if ( proceed ) {
13780 classes = ( value || "" ).match( rnotwhite ) || [];
13781
13782 for ( ; i < len; i++ ) {
13783 elem = this[ i ];
13784 // This expression is here for better compressibility (see addClass)
13785 cur = elem.nodeType === 1 && ( elem.className ?
13786 ( " " + elem.className + " " ).replace( rclass, " " ) :
13787 ""
13788 );
13789
13790 if ( cur ) {
13791 j = 0;
13792 while ( (clazz = classes[j++]) ) {
13793 // Remove *all* instances
13794 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
13795 cur = cur.replace( " " + clazz + " ", " " );
13796 }
13797 }
13798
13799 // only assign if different to avoid unneeded rendering.
13800 finalValue = value ? jQuery.trim( cur ) : "";
13801 if ( elem.className !== finalValue ) {
13802 elem.className = finalValue;
13803 }
13804 }
13805 }
13806 }
13807
13808 return this;
13809 },
13810
13811 toggleClass: function( value, stateVal ) {
13812 var type = typeof value;
13813
13814 if ( typeof stateVal === "boolean" && type === "string" ) {
13815 return stateVal ? this.addClass( value ) : this.removeClass( value );
13816 }
13817
13818 if ( jQuery.isFunction( value ) ) {
13819 return this.each(function( i ) {
13820 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
13821 });
13822 }
13823
13824 return this.each(function() {
13825 if ( type === "string" ) {
13826 // toggle individual class names
13827 var className,
13828 i = 0,
13829 self = jQuery( this ),
13830 classNames = value.match( rnotwhite ) || [];
13831
13832 while ( (className = classNames[ i++ ]) ) {
13833 // check each className given, space separated list
13834 if ( self.hasClass( className ) ) {
13835 self.removeClass( className );
13836 } else {
13837 self.addClass( className );
13838 }
13839 }
13840
13841 // Toggle whole class name
13842 } else if ( type === strundefined || type === "boolean" ) {
13843 if ( this.className ) {
13844 // store className if set
13845 data_priv.set( this, "__className__", this.className );
13846 }
13847
13848 // If the element has a class name or if we're passed "false",
13849 // then remove the whole classname (if there was one, the above saved it).
13850 // Otherwise bring back whatever was previously saved (if anything),
13851 // falling back to the empty string if nothing was stored.
13852 this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || "";
13853 }
13854 });
13855 },
13856
13857 hasClass: function( selector ) {
13858 var className = " " + selector + " ",
13859 i = 0,
13860 l = this.length;
13861 for ( ; i < l; i++ ) {
13862 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
13863 return true;
13864 }
13865 }
13866
13867 return false;
13868 }
13869 });
13870
13871
13872
13873
13874 var rreturn = /\r/g;
13875
13876 jQuery.fn.extend({
13877 val: function( value ) {
13878 var hooks, ret, isFunction,
13879 elem = this[0];
13880
13881 if ( !arguments.length ) {
13882 if ( elem ) {
13883 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
13884
13885 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
13886 return ret;
13887 }
13888
13889 ret = elem.value;
13890
13891 return typeof ret === "string" ?
13892 // handle most common string cases
13893 ret.replace(rreturn, "") :
13894 // handle cases where value is null/undef or number
13895 ret == null ? "" : ret;
13896 }
13897
13898 return;
13899 }
13900
13901 isFunction = jQuery.isFunction( value );
13902
13903 return this.each(function( i ) {
13904 var val;
13905
13906 if ( this.nodeType !== 1 ) {
13907 return;
13908 }
13909
13910 if ( isFunction ) {
13911 val = value.call( this, i, jQuery( this ).val() );
13912 } else {
13913 val = value;
13914 }
13915
13916 // Treat null/undefined as ""; convert numbers to string
13917 if ( val == null ) {
13918 val = "";
13919
13920 } else if ( typeof val === "number" ) {
13921 val += "";
13922
13923 } else if ( jQuery.isArray( val ) ) {
13924 val = jQuery.map( val, function( value ) {
13925 return value == null ? "" : value + "";
13926 });
13927 }
13928
13929 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
13930
13931 // If set returns undefined, fall back to normal setting
13932 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
13933 this.value = val;
13934 }
13935 });
13936 }
13937 });
13938
13939 jQuery.extend({
13940 valHooks: {
13941 option: {
13942 get: function( elem ) {
13943 var val = jQuery.find.attr( elem, "value" );
13944 return val != null ?
13945 val :
13946 // Support: IE10-11+
13947 // option.text throws exceptions (#14686, #14858)
13948 jQuery.trim( jQuery.text( elem ) );
13949 }
13950 },
13951 select: {
13952 get: function( elem ) {
13953 var value, option,
13954 options = elem.options,
13955 index = elem.selectedIndex,
13956 one = elem.type === "select-one" || index < 0,
13957 values = one ? null : [],
13958 max = one ? index + 1 : options.length,
13959 i = index < 0 ?
13960 max :
13961 one ? index : 0;
13962
13963 // Loop through all the selected options
13964 for ( ; i < max; i++ ) {
13965 option = options[ i ];
13966
13967 // IE6-9 doesn't update selected after form reset (#2551)
13968 if ( ( option.selected || i === index ) &&
13969 // Don't return options that are disabled or in a disabled optgroup
13970 ( support.optDisabled ? !option.disabled : option.getAttribute( "disabled" ) === null ) &&
13971 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
13972
13973 // Get the specific value for the option
13974 value = jQuery( option ).val();
13975
13976 // We don't need an array for one selects
13977 if ( one ) {
13978 return value;
13979 }
13980
13981 // Multi-Selects return an array
13982 values.push( value );
13983 }
13984 }
13985
13986 return values;
13987 },
13988
13989 set: function( elem, value ) {
13990 var optionSet, option,
13991 options = elem.options,
13992 values = jQuery.makeArray( value ),
13993 i = options.length;
13994
13995 while ( i-- ) {
13996 option = options[ i ];
13997 if ( (option.selected = jQuery.inArray( option.value, values ) >= 0) ) {
13998 optionSet = true;
13999 }
14000 }
14001
14002 // force browsers to behave consistently when non-matching value is set
14003 if ( !optionSet ) {
14004 elem.selectedIndex = -1;
14005 }
14006 return values;
14007 }
14008 }
14009 }
14010 });
14011
14012 // Radios and checkboxes getter/setter
14013 jQuery.each([ "radio", "checkbox" ], function() {
14014 jQuery.valHooks[ this ] = {
14015 set: function( elem, value ) {
14016 if ( jQuery.isArray( value ) ) {
14017 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
14018 }
14019 }
14020 };
14021 if ( !support.checkOn ) {
14022 jQuery.valHooks[ this ].get = function( elem ) {
14023 // Support: Webkit
14024 // "" is returned instead of "on" if a value isn't specified
14025 return elem.getAttribute("value") === null ? "on" : elem.value;
14026 };
14027 }
14028 });
14029
14030
14031
14032
14033 // Return jQuery for attributes-only inclusion
14034
14035
14036 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
14037 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
14038 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
14039
14040 // Handle event binding
14041 jQuery.fn[ name ] = function( data, fn ) {
14042 return arguments.length > 0 ?
14043 this.on( name, null, data, fn ) :
14044 this.trigger( name );
14045 };
14046 });
14047
14048 jQuery.fn.extend({
14049 hover: function( fnOver, fnOut ) {
14050 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
14051 },
14052
14053 bind: function( types, data, fn ) {
14054 return this.on( types, null, data, fn );
14055 },
14056 unbind: function( types, fn ) {
14057 return this.off( types, null, fn );
14058 },
14059
14060 delegate: function( selector, types, data, fn ) {
14061 return this.on( types, selector, data, fn );
14062 },
14063 undelegate: function( selector, types, fn ) {
14064 // ( namespace ) or ( selector, types [, fn] )
14065 return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
14066 }
14067 });
14068
14069
14070 var nonce = jQuery.now();
14071
14072 var rquery = (/\?/);
14073
14074
14075
14076 // Support: Android 2.3
14077 // Workaround failure to string-cast null input
14078 jQuery.parseJSON = function( data ) {
14079 return JSON.parse( data + "" );
14080 };
14081
14082
14083 // Cross-browser xml parsing
14084 jQuery.parseXML = function( data ) {
14085 var xml, tmp;
14086 if ( !data || typeof data !== "string" ) {
14087 return null;
14088 }
14089
14090 // Support: IE9
14091 try {
14092 tmp = new DOMParser();
14093 xml = tmp.parseFromString( data, "text/xml" );
14094 } catch ( e ) {
14095 xml = undefined;
14096 }
14097
14098 if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
14099 jQuery.error( "Invalid XML: " + data );
14100 }
14101 return xml;
14102 };
14103
14104
14105 var
14106 // Document location
14107 ajaxLocParts,
14108 ajaxLocation,
14109
14110 rhash = /#.*$/,
14111 rts = /([?&])_=[^&]*/,
14112 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
14113 // #7653, #8125, #8152: local protocol detection
14114 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
14115 rnoContent = /^(?:GET|HEAD)$/,
14116 rprotocol = /^\/\//,
14117 rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
14118
14119 /* Prefilters
14120 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
14121 * 2) These are called:
14122 * - BEFORE asking for a transport
14123 * - AFTER param serialization (s.data is a string if s.processData is true)
14124 * 3) key is the dataType
14125 * 4) the catchall symbol "*" can be used
14126 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
14127 */
14128 prefilters = {},
14129
14130 /* Transports bindings
14131 * 1) key is the dataType
14132 * 2) the catchall symbol "*" can be used
14133 * 3) selection will start with transport dataType and THEN go to "*" if needed
14134 */
14135 transports = {},
14136
14137 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
14138 allTypes = "*/".concat("*");
14139
14140 // #8138, IE may throw an exception when accessing
14141 // a field from window.location if document.domain has been set
14142 try {
14143 ajaxLocation = location.href;
14144 } catch( e ) {
14145 // Use the href attribute of an A element
14146 // since IE will modify it given document.location
14147 ajaxLocation = document.createElement( "a" );
14148 ajaxLocation.href = "";
14149 ajaxLocation = ajaxLocation.href;
14150 }
14151
14152 // Segment location into parts
14153 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
14154
14155 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
14156 function addToPrefiltersOrTransports( structure ) {
14157
14158 // dataTypeExpression is optional and defaults to "*"
14159 return function( dataTypeExpression, func ) {
14160
14161 if ( typeof dataTypeExpression !== "string" ) {
14162 func = dataTypeExpression;
14163 dataTypeExpression = "*";
14164 }
14165
14166 var dataType,
14167 i = 0,
14168 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
14169
14170 if ( jQuery.isFunction( func ) ) {
14171 // For each dataType in the dataTypeExpression
14172 while ( (dataType = dataTypes[i++]) ) {
14173 // Prepend if requested
14174 if ( dataType[0] === "+" ) {
14175 dataType = dataType.slice( 1 ) || "*";
14176 (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
14177
14178 // Otherwise append
14179 } else {
14180 (structure[ dataType ] = structure[ dataType ] || []).push( func );
14181 }
14182 }
14183 }
14184 };
14185 }
14186
14187 // Base inspection function for prefilters and transports
14188 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
14189
14190 var inspected = {},
14191 seekingTransport = ( structure === transports );
14192
14193 function inspect( dataType ) {
14194 var selected;
14195 inspected[ dataType ] = true;
14196 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
14197 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
14198 if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
14199 options.dataTypes.unshift( dataTypeOrTransport );
14200 inspect( dataTypeOrTransport );
14201 return false;
14202 } else if ( seekingTransport ) {
14203 return !( selected = dataTypeOrTransport );
14204 }
14205 });
14206 return selected;
14207 }
14208
14209 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
14210 }
14211
14212 // A special extend for ajax options
14213 // that takes "flat" options (not to be deep extended)
14214 // Fixes #9887
14215 function ajaxExtend( target, src ) {
14216 var key, deep,
14217 flatOptions = jQuery.ajaxSettings.flatOptions || {};
14218
14219 for ( key in src ) {
14220 if ( src[ key ] !== undefined ) {
14221 ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
14222 }
14223 }
14224 if ( deep ) {
14225 jQuery.extend( true, target, deep );
14226 }
14227
14228 return target;
14229 }
14230
14231 /* Handles responses to an ajax request:
14232 * - finds the right dataType (mediates between content-type and expected dataType)
14233 * - returns the corresponding response
14234 */
14235 function ajaxHandleResponses( s, jqXHR, responses ) {
14236
14237 var ct, type, finalDataType, firstDataType,
14238 contents = s.contents,
14239 dataTypes = s.dataTypes;
14240
14241 // Remove auto dataType and get content-type in the process
14242 while ( dataTypes[ 0 ] === "*" ) {
14243 dataTypes.shift();
14244 if ( ct === undefined ) {
14245 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
14246 }
14247 }
14248
14249 // Check if we're dealing with a known content-type
14250 if ( ct ) {
14251 for ( type in contents ) {
14252 if ( contents[ type ] && contents[ type ].test( ct ) ) {
14253 dataTypes.unshift( type );
14254 break;
14255 }
14256 }
14257 }
14258
14259 // Check to see if we have a response for the expected dataType
14260 if ( dataTypes[ 0 ] in responses ) {
14261 finalDataType = dataTypes[ 0 ];
14262 } else {
14263 // Try convertible dataTypes
14264 for ( type in responses ) {
14265 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
14266 finalDataType = type;
14267 break;
14268 }
14269 if ( !firstDataType ) {
14270 firstDataType = type;
14271 }
14272 }
14273 // Or just use first one
14274 finalDataType = finalDataType || firstDataType;
14275 }
14276
14277 // If we found a dataType
14278 // We add the dataType to the list if needed
14279 // and return the corresponding response
14280 if ( finalDataType ) {
14281 if ( finalDataType !== dataTypes[ 0 ] ) {
14282 dataTypes.unshift( finalDataType );
14283 }
14284 return responses[ finalDataType ];
14285 }
14286 }
14287
14288 /* Chain conversions given the request and the original response
14289 * Also sets the responseXXX fields on the jqXHR instance
14290 */
14291 function ajaxConvert( s, response, jqXHR, isSuccess ) {
14292 var conv2, current, conv, tmp, prev,
14293 converters = {},
14294 // Work with a copy of dataTypes in case we need to modify it for conversion
14295 dataTypes = s.dataTypes.slice();
14296
14297 // Create converters map with lowercased keys
14298 if ( dataTypes[ 1 ] ) {
14299 for ( conv in s.converters ) {
14300 converters[ conv.toLowerCase() ] = s.converters[ conv ];
14301 }
14302 }
14303
14304 current = dataTypes.shift();
14305
14306 // Convert to each sequential dataType
14307 while ( current ) {
14308
14309 if ( s.responseFields[ current ] ) {
14310 jqXHR[ s.responseFields[ current ] ] = response;
14311 }
14312
14313 // Apply the dataFilter if provided
14314 if ( !prev && isSuccess && s.dataFilter ) {
14315 response = s.dataFilter( response, s.dataType );
14316 }
14317
14318 prev = current;
14319 current = dataTypes.shift();
14320
14321 if ( current ) {
14322
14323 // There's only work to do if current dataType is non-auto
14324 if ( current === "*" ) {
14325
14326 current = prev;
14327
14328 // Convert response if prev dataType is non-auto and differs from current
14329 } else if ( prev !== "*" && prev !== current ) {
14330
14331 // Seek a direct converter
14332 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
14333
14334 // If none found, seek a pair
14335 if ( !conv ) {
14336 for ( conv2 in converters ) {
14337
14338 // If conv2 outputs current
14339 tmp = conv2.split( " " );
14340 if ( tmp[ 1 ] === current ) {
14341
14342 // If prev can be converted to accepted input
14343 conv = converters[ prev + " " + tmp[ 0 ] ] ||
14344 converters[ "* " + tmp[ 0 ] ];
14345 if ( conv ) {
14346 // Condense equivalence converters
14347 if ( conv === true ) {
14348 conv = converters[ conv2 ];
14349
14350 // Otherwise, insert the intermediate dataType
14351 } else if ( converters[ conv2 ] !== true ) {
14352 current = tmp[ 0 ];
14353 dataTypes.unshift( tmp[ 1 ] );
14354 }
14355 break;
14356 }
14357 }
14358 }
14359 }
14360
14361 // Apply converter (if not an equivalence)
14362 if ( conv !== true ) {
14363
14364 // Unless errors are allowed to bubble, catch and return them
14365 if ( conv && s[ "throws" ] ) {
14366 response = conv( response );
14367 } else {
14368 try {
14369 response = conv( response );
14370 } catch ( e ) {
14371 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
14372 }
14373 }
14374 }
14375 }
14376 }
14377 }
14378
14379 return { state: "success", data: response };
14380 }
14381
14382 jQuery.extend({
14383
14384 // Counter for holding the number of active queries
14385 active: 0,
14386
14387 // Last-Modified header cache for next request
14388 lastModified: {},
14389 etag: {},
14390
14391 ajaxSettings: {
14392 url: ajaxLocation,
14393 type: "GET",
14394 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
14395 global: true,
14396 processData: true,
14397 async: true,
14398 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
14399 /*
14400 timeout: 0,
14401 data: null,
14402 dataType: null,
14403 username: null,
14404 password: null,
14405 cache: null,
14406 throws: false,
14407 traditional: false,
14408 headers: {},
14409 */
14410
14411 accepts: {
14412 "*": allTypes,
14413 text: "text/plain",
14414 html: "text/html",
14415 xml: "application/xml, text/xml",
14416 json: "application/json, text/javascript"
14417 },
14418
14419 contents: {
14420 xml: /xml/,
14421 html: /html/,
14422 json: /json/
14423 },
14424
14425 responseFields: {
14426 xml: "responseXML",
14427 text: "responseText",
14428 json: "responseJSON"
14429 },
14430
14431 // Data converters
14432 // Keys separate source (or catchall "*") and destination types with a single space
14433 converters: {
14434
14435 // Convert anything to text
14436 "* text": String,
14437
14438 // Text to html (true = no transformation)
14439 "text html": true,
14440
14441 // Evaluate text as a json expression
14442 "text json": jQuery.parseJSON,
14443
14444 // Parse text as xml
14445 "text xml": jQuery.parseXML
14446 },
14447
14448 // For options that shouldn't be deep extended:
14449 // you can add your own custom options here if
14450 // and when you create one that shouldn't be
14451 // deep extended (see ajaxExtend)
14452 flatOptions: {
14453 url: true,
14454 context: true
14455 }
14456 },
14457
14458 // Creates a full fledged settings object into target
14459 // with both ajaxSettings and settings fields.
14460 // If target is omitted, writes into ajaxSettings.
14461 ajaxSetup: function( target, settings ) {
14462 return settings ?
14463
14464 // Building a settings object
14465 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
14466
14467 // Extending ajaxSettings
14468 ajaxExtend( jQuery.ajaxSettings, target );
14469 },
14470
14471 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
14472 ajaxTransport: addToPrefiltersOrTransports( transports ),
14473
14474 // Main method
14475 ajax: function( url, options ) {
14476
14477 // If url is an object, simulate pre-1.5 signature
14478 if ( typeof url === "object" ) {
14479 options = url;
14480 url = undefined;
14481 }
14482
14483 // Force options to be an object
14484 options = options || {};
14485
14486 var transport,
14487 // URL without anti-cache param
14488 cacheURL,
14489 // Response headers
14490 responseHeadersString,
14491 responseHeaders,
14492 // timeout handle
14493 timeoutTimer,
14494 // Cross-domain detection vars
14495 parts,
14496 // To know if global events are to be dispatched
14497 fireGlobals,
14498 // Loop variable
14499 i,
14500 // Create the final options object
14501 s = jQuery.ajaxSetup( {}, options ),
14502 // Callbacks context
14503 callbackContext = s.context || s,
14504 // Context for global events is callbackContext if it is a DOM node or jQuery collection
14505 globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
14506 jQuery( callbackContext ) :
14507 jQuery.event,
14508 // Deferreds
14509 deferred = jQuery.Deferred(),
14510 completeDeferred = jQuery.Callbacks("once memory"),
14511 // Status-dependent callbacks
14512 statusCode = s.statusCode || {},
14513 // Headers (they are sent all at once)
14514 requestHeaders = {},
14515 requestHeadersNames = {},
14516 // The jqXHR state
14517 state = 0,
14518 // Default abort message
14519 strAbort = "canceled",
14520 // Fake xhr
14521 jqXHR = {
14522 readyState: 0,
14523
14524 // Builds headers hashtable if needed
14525 getResponseHeader: function( key ) {
14526 var match;
14527 if ( state === 2 ) {
14528 if ( !responseHeaders ) {
14529 responseHeaders = {};
14530 while ( (match = rheaders.exec( responseHeadersString )) ) {
14531 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
14532 }
14533 }
14534 match = responseHeaders[ key.toLowerCase() ];
14535 }
14536 return match == null ? null : match;
14537 },
14538
14539 // Raw string
14540 getAllResponseHeaders: function() {
14541 return state === 2 ? responseHeadersString : null;
14542 },
14543
14544 // Caches the header
14545 setRequestHeader: function( name, value ) {
14546 var lname = name.toLowerCase();
14547 if ( !state ) {
14548 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
14549 requestHeaders[ name ] = value;
14550 }
14551 return this;
14552 },
14553
14554 // Overrides response content-type header
14555 overrideMimeType: function( type ) {
14556 if ( !state ) {
14557 s.mimeType = type;
14558 }
14559 return this;
14560 },
14561
14562 // Status-dependent callbacks
14563 statusCode: function( map ) {
14564 var code;
14565 if ( map ) {
14566 if ( state < 2 ) {
14567 for ( code in map ) {
14568 // Lazy-add the new callback in a way that preserves old ones
14569 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
14570 }
14571 } else {
14572 // Execute the appropriate callbacks
14573 jqXHR.always( map[ jqXHR.status ] );
14574 }
14575 }
14576 return this;
14577 },
14578
14579 // Cancel the request
14580 abort: function( statusText ) {
14581 var finalText = statusText || strAbort;
14582 if ( transport ) {
14583 transport.abort( finalText );
14584 }
14585 done( 0, finalText );
14586 return this;
14587 }
14588 };
14589
14590 // Attach deferreds
14591 deferred.promise( jqXHR ).complete = completeDeferred.add;
14592 jqXHR.success = jqXHR.done;
14593 jqXHR.error = jqXHR.fail;
14594
14595 // Remove hash character (#7531: and string promotion)
14596 // Add protocol if not provided (prefilters might expect it)
14597 // Handle falsy url in the settings object (#10093: consistency with old signature)
14598 // We also use the url parameter if available
14599 s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" )
14600 .replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
14601
14602 // Alias method option to type as per ticket #12004
14603 s.type = options.method || options.type || s.method || s.type;
14604
14605 // Extract dataTypes list
14606 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
14607
14608 // A cross-domain request is in order when we have a protocol:host:port mismatch
14609 if ( s.crossDomain == null ) {
14610 parts = rurl.exec( s.url.toLowerCase() );
14611 s.crossDomain = !!( parts &&
14612 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
14613 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
14614 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
14615 );
14616 }
14617
14618 // Convert data if not already a string
14619 if ( s.data && s.processData && typeof s.data !== "string" ) {
14620 s.data = jQuery.param( s.data, s.traditional );
14621 }
14622
14623 // Apply prefilters
14624 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
14625
14626 // If request was aborted inside a prefilter, stop there
14627 if ( state === 2 ) {
14628 return jqXHR;
14629 }
14630
14631 // We can fire global events as of now if asked to
14632 fireGlobals = s.global;
14633
14634 // Watch for a new set of requests
14635 if ( fireGlobals && jQuery.active++ === 0 ) {
14636 jQuery.event.trigger("ajaxStart");
14637 }
14638
14639 // Uppercase the type
14640 s.type = s.type.toUpperCase();
14641
14642 // Determine if request has content
14643 s.hasContent = !rnoContent.test( s.type );
14644
14645 // Save the URL in case we're toying with the If-Modified-Since
14646 // and/or If-None-Match header later on
14647 cacheURL = s.url;
14648
14649 // More options handling for requests with no content
14650 if ( !s.hasContent ) {
14651
14652 // If data is available, append data to url
14653 if ( s.data ) {
14654 cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
14655 // #9682: remove data so that it's not used in an eventual retry
14656 delete s.data;
14657 }
14658
14659 // Add anti-cache in url if needed
14660 if ( s.cache === false ) {
14661 s.url = rts.test( cacheURL ) ?
14662
14663 // If there is already a '_' parameter, set its value
14664 cacheURL.replace( rts, "$1_=" + nonce++ ) :
14665
14666 // Otherwise add one to the end
14667 cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
14668 }
14669 }
14670
14671 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
14672 if ( s.ifModified ) {
14673 if ( jQuery.lastModified[ cacheURL ] ) {
14674 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
14675 }
14676 if ( jQuery.etag[ cacheURL ] ) {
14677 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
14678 }
14679 }
14680
14681 // Set the correct header, if data is being sent
14682 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
14683 jqXHR.setRequestHeader( "Content-Type", s.contentType );
14684 }
14685
14686 // Set the Accepts header for the server, depending on the dataType
14687 jqXHR.setRequestHeader(
14688 "Accept",
14689 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
14690 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
14691 s.accepts[ "*" ]
14692 );
14693
14694 // Check for headers option
14695 for ( i in s.headers ) {
14696 jqXHR.setRequestHeader( i, s.headers[ i ] );
14697 }
14698
14699 // Allow custom headers/mimetypes and early abort
14700 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
14701 // Abort if not done already and return
14702 return jqXHR.abort();
14703 }
14704
14705 // aborting is no longer a cancellation
14706 strAbort = "abort";
14707
14708 // Install callbacks on deferreds
14709 for ( i in { success: 1, error: 1, complete: 1 } ) {
14710 jqXHR[ i ]( s[ i ] );
14711 }
14712
14713 // Get transport
14714 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
14715
14716 // If no transport, we auto-abort
14717 if ( !transport ) {
14718 done( -1, "No Transport" );
14719 } else {
14720 jqXHR.readyState = 1;
14721
14722 // Send global event
14723 if ( fireGlobals ) {
14724 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
14725 }
14726 // Timeout
14727 if ( s.async && s.timeout > 0 ) {
14728 timeoutTimer = setTimeout(function() {
14729 jqXHR.abort("timeout");
14730 }, s.timeout );
14731 }
14732
14733 try {
14734 state = 1;
14735 transport.send( requestHeaders, done );
14736 } catch ( e ) {
14737 // Propagate exception as error if not done
14738 if ( state < 2 ) {
14739 done( -1, e );
14740 // Simply rethrow otherwise
14741 } else {
14742 throw e;
14743 }
14744 }
14745 }
14746
14747 // Callback for when everything is done
14748 function done( status, nativeStatusText, responses, headers ) {
14749 var isSuccess, success, error, response, modified,
14750 statusText = nativeStatusText;
14751
14752 // Called once
14753 if ( state === 2 ) {
14754 return;
14755 }
14756
14757 // State is "done" now
14758 state = 2;
14759
14760 // Clear timeout if it exists
14761 if ( timeoutTimer ) {
14762 clearTimeout( timeoutTimer );
14763 }
14764
14765 // Dereference transport for early garbage collection
14766 // (no matter how long the jqXHR object will be used)
14767 transport = undefined;
14768
14769 // Cache response headers
14770 responseHeadersString = headers || "";
14771
14772 // Set readyState
14773 jqXHR.readyState = status > 0 ? 4 : 0;
14774
14775 // Determine if successful
14776 isSuccess = status >= 200 && status < 300 || status === 304;
14777
14778 // Get response data
14779 if ( responses ) {
14780 response = ajaxHandleResponses( s, jqXHR, responses );
14781 }
14782
14783 // Convert no matter what (that way responseXXX fields are always set)
14784 response = ajaxConvert( s, response, jqXHR, isSuccess );
14785
14786 // If successful, handle type chaining
14787 if ( isSuccess ) {
14788
14789 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
14790 if ( s.ifModified ) {
14791 modified = jqXHR.getResponseHeader("Last-Modified");
14792 if ( modified ) {
14793 jQuery.lastModified[ cacheURL ] = modified;
14794 }
14795 modified = jqXHR.getResponseHeader("etag");
14796 if ( modified ) {
14797 jQuery.etag[ cacheURL ] = modified;
14798 }
14799 }
14800
14801 // if no content
14802 if ( status === 204 || s.type === "HEAD" ) {
14803 statusText = "nocontent";
14804
14805 // if not modified
14806 } else if ( status === 304 ) {
14807 statusText = "notmodified";
14808
14809 // If we have data, let's convert it
14810 } else {
14811 statusText = response.state;
14812 success = response.data;
14813 error = response.error;
14814 isSuccess = !error;
14815 }
14816 } else {
14817 // We extract error from statusText
14818 // then normalize statusText and status for non-aborts
14819 error = statusText;
14820 if ( status || !statusText ) {
14821 statusText = "error";
14822 if ( status < 0 ) {
14823 status = 0;
14824 }
14825 }
14826 }
14827
14828 // Set data for the fake xhr object
14829 jqXHR.status = status;
14830 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
14831
14832 // Success/Error
14833 if ( isSuccess ) {
14834 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
14835 } else {
14836 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
14837 }
14838
14839 // Status-dependent callbacks
14840 jqXHR.statusCode( statusCode );
14841 statusCode = undefined;
14842
14843 if ( fireGlobals ) {
14844 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
14845 [ jqXHR, s, isSuccess ? success : error ] );
14846 }
14847
14848 // Complete
14849 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
14850
14851 if ( fireGlobals ) {
14852 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
14853 // Handle the global AJAX counter
14854 if ( !( --jQuery.active ) ) {
14855 jQuery.event.trigger("ajaxStop");
14856 }
14857 }
14858 }
14859
14860 return jqXHR;
14861 },
14862
14863 getJSON: function( url, data, callback ) {
14864 return jQuery.get( url, data, callback, "json" );
14865 },
14866
14867 getScript: function( url, callback ) {
14868 return jQuery.get( url, undefined, callback, "script" );
14869 }
14870 });
14871
14872 jQuery.each( [ "get", "post" ], function( i, method ) {
14873 jQuery[ method ] = function( url, data, callback, type ) {
14874 // shift arguments if data argument was omitted
14875 if ( jQuery.isFunction( data ) ) {
14876 type = type || callback;
14877 callback = data;
14878 data = undefined;
14879 }
14880
14881 return jQuery.ajax({
14882 url: url,
14883 type: method,
14884 dataType: type,
14885 data: data,
14886 success: callback
14887 });
14888 };
14889 });
14890
14891 // Attach a bunch of functions for handling common AJAX events
14892 jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
14893 jQuery.fn[ type ] = function( fn ) {
14894 return this.on( type, fn );
14895 };
14896 });
14897
14898
14899 jQuery._evalUrl = function( url ) {
14900 return jQuery.ajax({
14901 url: url,
14902 type: "GET",
14903 dataType: "script",
14904 async: false,
14905 global: false,
14906 "throws": true
14907 });
14908 };
14909
14910
14911 jQuery.fn.extend({
14912 wrapAll: function( html ) {
14913 var wrap;
14914
14915 if ( jQuery.isFunction( html ) ) {
14916 return this.each(function( i ) {
14917 jQuery( this ).wrapAll( html.call(this, i) );
14918 });
14919 }
14920
14921 if ( this[ 0 ] ) {
14922
14923 // The elements to wrap the target around
14924 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
14925
14926 if ( this[ 0 ].parentNode ) {
14927 wrap.insertBefore( this[ 0 ] );
14928 }
14929
14930 wrap.map(function() {
14931 var elem = this;
14932
14933 while ( elem.firstElementChild ) {
14934 elem = elem.firstElementChild;
14935 }
14936
14937 return elem;
14938 }).append( this );
14939 }
14940
14941 return this;
14942 },
14943
14944 wrapInner: function( html ) {
14945 if ( jQuery.isFunction( html ) ) {
14946 return this.each(function( i ) {
14947 jQuery( this ).wrapInner( html.call(this, i) );
14948 });
14949 }
14950
14951 return this.each(function() {
14952 var self = jQuery( this ),
14953 contents = self.contents();
14954
14955 if ( contents.length ) {
14956 contents.wrapAll( html );
14957
14958 } else {
14959 self.append( html );
14960 }
14961 });
14962 },
14963
14964 wrap: function( html ) {
14965 var isFunction = jQuery.isFunction( html );
14966
14967 return this.each(function( i ) {
14968 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
14969 });
14970 },
14971
14972 unwrap: function() {
14973 return this.parent().each(function() {
14974 if ( !jQuery.nodeName( this, "body" ) ) {
14975 jQuery( this ).replaceWith( this.childNodes );
14976 }
14977 }).end();
14978 }
14979 });
14980
14981
14982 jQuery.expr.filters.hidden = function( elem ) {
14983 // Support: Opera <= 12.12
14984 // Opera reports offsetWidths and offsetHeights less than zero on some elements
14985 return elem.offsetWidth <= 0 && elem.offsetHeight <= 0;
14986 };
14987 jQuery.expr.filters.visible = function( elem ) {
14988 return !jQuery.expr.filters.hidden( elem );
14989 };
14990
14991
14992
14993
14994 var r20 = /%20/g,
14995 rbracket = /\[\]$/,
14996 rCRLF = /\r?\n/g,
14997 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
14998 rsubmittable = /^(?:input|select|textarea|keygen)/i;
14999
15000 function buildParams( prefix, obj, traditional, add ) {
15001 var name;
15002
15003 if ( jQuery.isArray( obj ) ) {
15004 // Serialize array item.
15005 jQuery.each( obj, function( i, v ) {
15006 if ( traditional || rbracket.test( prefix ) ) {
15007 // Treat each array item as a scalar.
15008 add( prefix, v );
15009
15010 } else {
15011 // Item is non-scalar (array or object), encode its numeric index.
15012 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
15013 }
15014 });
15015
15016 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
15017 // Serialize object item.
15018 for ( name in obj ) {
15019 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
15020 }
15021
15022 } else {
15023 // Serialize scalar item.
15024 add( prefix, obj );
15025 }
15026 }
15027
15028 // Serialize an array of form elements or a set of
15029 // key/values into a query string
15030 jQuery.param = function( a, traditional ) {
15031 var prefix,
15032 s = [],
15033 add = function( key, value ) {
15034 // If value is a function, invoke it and return its value
15035 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
15036 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
15037 };
15038
15039 // Set traditional to true for jQuery <= 1.3.2 behavior.
15040 if ( traditional === undefined ) {
15041 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
15042 }
15043
15044 // If an array was passed in, assume that it is an array of form elements.
15045 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
15046 // Serialize the form elements
15047 jQuery.each( a, function() {
15048 add( this.name, this.value );
15049 });
15050
15051 } else {
15052 // If traditional, encode the "old" way (the way 1.3.2 or older
15053 // did it), otherwise encode params recursively.
15054 for ( prefix in a ) {
15055 buildParams( prefix, a[ prefix ], traditional, add );
15056 }
15057 }
15058
15059 // Return the resulting serialization
15060 return s.join( "&" ).replace( r20, "+" );
15061 };
15062
15063 jQuery.fn.extend({
15064 serialize: function() {
15065 return jQuery.param( this.serializeArray() );
15066 },
15067 serializeArray: function() {
15068 return this.map(function() {
15069 // Can add propHook for "elements" to filter or add form elements
15070 var elements = jQuery.prop( this, "elements" );
15071 return elements ? jQuery.makeArray( elements ) : this;
15072 })
15073 .filter(function() {
15074 var type = this.type;
15075
15076 // Use .is( ":disabled" ) so that fieldset[disabled] works
15077 return this.name && !jQuery( this ).is( ":disabled" ) &&
15078 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
15079 ( this.checked || !rcheckableType.test( type ) );
15080 })
15081 .map(function( i, elem ) {
15082 var val = jQuery( this ).val();
15083
15084 return val == null ?
15085 null :
15086 jQuery.isArray( val ) ?
15087 jQuery.map( val, function( val ) {
15088 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
15089 }) :
15090 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
15091 }).get();
15092 }
15093 });
15094
15095
15096 jQuery.ajaxSettings.xhr = function() {
15097 try {
15098 return new XMLHttpRequest();
15099 } catch( e ) {}
15100 };
15101
15102 var xhrId = 0,
15103 xhrCallbacks = {},
15104 xhrSuccessStatus = {
15105 // file protocol always yields status code 0, assume 200
15106 0: 200,
15107 // Support: IE9
15108 // #1450: sometimes IE returns 1223 when it should be 204
15109 1223: 204
15110 },
15111 xhrSupported = jQuery.ajaxSettings.xhr();
15112
15113 // Support: IE9
15114 // Open requests must be manually aborted on unload (#5280)
15115 if ( window.ActiveXObject ) {
15116 jQuery( window ).on( "unload", function() {
15117 for ( var key in xhrCallbacks ) {
15118 xhrCallbacks[ key ]();
15119 }
15120 });
15121 }
15122
15123 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
15124 support.ajax = xhrSupported = !!xhrSupported;
15125
15126 jQuery.ajaxTransport(function( options ) {
15127 var callback;
15128
15129 // Cross domain only allowed if supported through XMLHttpRequest
15130 if ( support.cors || xhrSupported && !options.crossDomain ) {
15131 return {
15132 send: function( headers, complete ) {
15133 var i,
15134 xhr = options.xhr(),
15135 id = ++xhrId;
15136
15137 xhr.open( options.type, options.url, options.async, options.username, options.password );
15138
15139 // Apply custom fields if provided
15140 if ( options.xhrFields ) {
15141 for ( i in options.xhrFields ) {
15142 xhr[ i ] = options.xhrFields[ i ];
15143 }
15144 }
15145
15146 // Override mime type if needed
15147 if ( options.mimeType && xhr.overrideMimeType ) {
15148 xhr.overrideMimeType( options.mimeType );
15149 }
15150
15151 // X-Requested-With header
15152 // For cross-domain requests, seeing as conditions for a preflight are
15153 // akin to a jigsaw puzzle, we simply never set it to be sure.
15154 // (it can always be set on a per-request basis or even using ajaxSetup)
15155 // For same-domain requests, won't change header if already provided.
15156 if ( !options.crossDomain && !headers["X-Requested-With"] ) {
15157 headers["X-Requested-With"] = "XMLHttpRequest";
15158 }
15159
15160 // Set headers
15161 for ( i in headers ) {
15162 xhr.setRequestHeader( i, headers[ i ] );
15163 }
15164
15165 // Callback
15166 callback = function( type ) {
15167 return function() {
15168 if ( callback ) {
15169 delete xhrCallbacks[ id ];
15170 callback = xhr.onload = xhr.onerror = null;
15171
15172 if ( type === "abort" ) {
15173 xhr.abort();
15174 } else if ( type === "error" ) {
15175 complete(
15176 // file: protocol always yields status 0; see #8605, #14207
15177 xhr.status,
15178 xhr.statusText
15179 );
15180 } else {
15181 complete(
15182 xhrSuccessStatus[ xhr.status ] || xhr.status,
15183 xhr.statusText,
15184 // Support: IE9
15185 // Accessing binary-data responseText throws an exception
15186 // (#11426)
15187 typeof xhr.responseText === "string" ? {
15188 text: xhr.responseText
15189 } : undefined,
15190 xhr.getAllResponseHeaders()
15191 );
15192 }
15193 }
15194 };
15195 };
15196
15197 // Listen to events
15198 xhr.onload = callback();
15199 xhr.onerror = callback("error");
15200
15201 // Create the abort callback
15202 callback = xhrCallbacks[ id ] = callback("abort");
15203
15204 try {
15205 // Do send the request (this may raise an exception)
15206 xhr.send( options.hasContent && options.data || null );
15207 } catch ( e ) {
15208 // #14683: Only rethrow if this hasn't been notified as an error yet
15209 if ( callback ) {
15210 throw e;
15211 }
15212 }
15213 },
15214
15215 abort: function() {
15216 if ( callback ) {
15217 callback();
15218 }
15219 }
15220 };
15221 }
15222 });
15223
15224
15225
15226
15227 // Install script dataType
15228 jQuery.ajaxSetup({
15229 accepts: {
15230 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
15231 },
15232 contents: {
15233 script: /(?:java|ecma)script/
15234 },
15235 converters: {
15236 "text script": function( text ) {
15237 jQuery.globalEval( text );
15238 return text;
15239 }
15240 }
15241 });
15242
15243 // Handle cache's special case and crossDomain
15244 jQuery.ajaxPrefilter( "script", function( s ) {
15245 if ( s.cache === undefined ) {
15246 s.cache = false;
15247 }
15248 if ( s.crossDomain ) {
15249 s.type = "GET";
15250 }
15251 });
15252
15253 // Bind script tag hack transport
15254 jQuery.ajaxTransport( "script", function( s ) {
15255 // This transport only deals with cross domain requests
15256 if ( s.crossDomain ) {
15257 var script, callback;
15258 return {
15259 send: function( _, complete ) {
15260 script = jQuery("<script>").prop({
15261 async: true,
15262 charset: s.scriptCharset,
15263 src: s.url
15264 }).on(
15265 "load error",
15266 callback = function( evt ) {
15267 script.remove();
15268 callback = null;
15269 if ( evt ) {
15270 complete( evt.type === "error" ? 404 : 200, evt.type );
15271 }
15272 }
15273 );
15274 document.head.appendChild( script[ 0 ] );
15275 },
15276 abort: function() {
15277 if ( callback ) {
15278 callback();
15279 }
15280 }
15281 };
15282 }
15283 });
15284
15285
15286
15287
15288 var oldCallbacks = [],
15289 rjsonp = /(=)\?(?=&|$)|\?\?/;
15290
15291 // Default jsonp settings
15292 jQuery.ajaxSetup({
15293 jsonp: "callback",
15294 jsonpCallback: function() {
15295 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
15296 this[ callback ] = true;
15297 return callback;
15298 }
15299 });
15300
15301 // Detect, normalize options and install callbacks for jsonp requests
15302 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
15303
15304 var callbackName, overwritten, responseContainer,
15305 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
15306 "url" :
15307 typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
15308 );
15309
15310 // Handle iff the expected data type is "jsonp" or we have a parameter to set
15311 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
15312
15313 // Get callback name, remembering preexisting value associated with it
15314 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
15315 s.jsonpCallback() :
15316 s.jsonpCallback;
15317
15318 // Insert callback into url or form data
15319 if ( jsonProp ) {
15320 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
15321 } else if ( s.jsonp !== false ) {
15322 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
15323 }
15324
15325 // Use data converter to retrieve json after script execution
15326 s.converters["script json"] = function() {
15327 if ( !responseContainer ) {
15328 jQuery.error( callbackName + " was not called" );
15329 }
15330 return responseContainer[ 0 ];
15331 };
15332
15333 // force json dataType
15334 s.dataTypes[ 0 ] = "json";
15335
15336 // Install callback
15337 overwritten = window[ callbackName ];
15338 window[ callbackName ] = function() {
15339 responseContainer = arguments;
15340 };
15341
15342 // Clean-up function (fires after converters)
15343 jqXHR.always(function() {
15344 // Restore preexisting value
15345 window[ callbackName ] = overwritten;
15346
15347 // Save back as free
15348 if ( s[ callbackName ] ) {
15349 // make sure that re-using the options doesn't screw things around
15350 s.jsonpCallback = originalSettings.jsonpCallback;
15351
15352 // save the callback name for future use
15353 oldCallbacks.push( callbackName );
15354 }
15355
15356 // Call if it was a function and we have a response
15357 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
15358 overwritten( responseContainer[ 0 ] );
15359 }
15360
15361 responseContainer = overwritten = undefined;
15362 });
15363
15364 // Delegate to script
15365 return "script";
15366 }
15367 });
15368
15369
15370
15371
15372 // data: string of html
15373 // context (optional): If specified, the fragment will be created in this context, defaults to document
15374 // keepScripts (optional): If true, will include scripts passed in the html string
15375 jQuery.parseHTML = function( data, context, keepScripts ) {
15376 if ( !data || typeof data !== "string" ) {
15377 return null;
15378 }
15379 if ( typeof context === "boolean" ) {
15380 keepScripts = context;
15381 context = false;
15382 }
15383 context = context || document;
15384
15385 var parsed = rsingleTag.exec( data ),
15386 scripts = !keepScripts && [];
15387
15388 // Single tag
15389 if ( parsed ) {
15390 return [ context.createElement( parsed[1] ) ];
15391 }
15392
15393 parsed = jQuery.buildFragment( [ data ], context, scripts );
15394
15395 if ( scripts && scripts.length ) {
15396 jQuery( scripts ).remove();
15397 }
15398
15399 return jQuery.merge( [], parsed.childNodes );
15400 };
15401
15402
15403 // Keep a copy of the old load method
15404 var _load = jQuery.fn.load;
15405
15406 /**
15407 * Load a url into a page
15408 */
15409 jQuery.fn.load = function( url, params, callback ) {
15410 if ( typeof url !== "string" && _load ) {
15411 return _load.apply( this, arguments );
15412 }
15413
15414 var selector, type, response,
15415 self = this,
15416 off = url.indexOf(" ");
15417
15418 if ( off >= 0 ) {
15419 selector = jQuery.trim( url.slice( off ) );
15420 url = url.slice( 0, off );
15421 }
15422
15423 // If it's a function
15424 if ( jQuery.isFunction( params ) ) {
15425
15426 // We assume that it's the callback
15427 callback = params;
15428 params = undefined;
15429
15430 // Otherwise, build a param string
15431 } else if ( params && typeof params === "object" ) {
15432 type = "POST";
15433 }
15434
15435 // If we have elements to modify, make the request
15436 if ( self.length > 0 ) {
15437 jQuery.ajax({
15438 url: url,
15439
15440 // if "type" variable is undefined, then "GET" method will be used
15441 type: type,
15442 dataType: "html",
15443 data: params
15444 }).done(function( responseText ) {
15445
15446 // Save response for use in complete callback
15447 response = arguments;
15448
15449 self.html( selector ?
15450
15451 // If a selector was specified, locate the right elements in a dummy div
15452 // Exclude scripts to avoid IE 'Permission Denied' errors
15453 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
15454
15455 // Otherwise use the full result
15456 responseText );
15457
15458 }).complete( callback && function( jqXHR, status ) {
15459 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
15460 });
15461 }
15462
15463 return this;
15464 };
15465
15466
15467
15468
15469 jQuery.expr.filters.animated = function( elem ) {
15470 return jQuery.grep(jQuery.timers, function( fn ) {
15471 return elem === fn.elem;
15472 }).length;
15473 };
15474
15475
15476
15477
15478 var docElem = window.document.documentElement;
15479
15480 /**
15481 * Gets a window from an element
15482 */
15483 function getWindow( elem ) {
15484 return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView;
15485 }
15486
15487 jQuery.offset = {
15488 setOffset: function( elem, options, i ) {
15489 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
15490 position = jQuery.css( elem, "position" ),
15491 curElem = jQuery( elem ),
15492 props = {};
15493
15494 // Set position first, in-case top/left are set even on static elem
15495 if ( position === "static" ) {
15496 elem.style.position = "relative";
15497 }
15498
15499 curOffset = curElem.offset();
15500 curCSSTop = jQuery.css( elem, "top" );
15501 curCSSLeft = jQuery.css( elem, "left" );
15502 calculatePosition = ( position === "absolute" || position === "fixed" ) &&
15503 ( curCSSTop + curCSSLeft ).indexOf("auto") > -1;
15504
15505 // Need to be able to calculate position if either top or left is auto and position is either absolute or fixed
15506 if ( calculatePosition ) {
15507 curPosition = curElem.position();
15508 curTop = curPosition.top;
15509 curLeft = curPosition.left;
15510
15511 } else {
15512 curTop = parseFloat( curCSSTop ) || 0;
15513 curLeft = parseFloat( curCSSLeft ) || 0;
15514 }
15515
15516 if ( jQuery.isFunction( options ) ) {
15517 options = options.call( elem, i, curOffset );
15518 }
15519
15520 if ( options.top != null ) {
15521 props.top = ( options.top - curOffset.top ) + curTop;
15522 }
15523 if ( options.left != null ) {
15524 props.left = ( options.left - curOffset.left ) + curLeft;
15525 }
15526
15527 if ( "using" in options ) {
15528 options.using.call( elem, props );
15529
15530 } else {
15531 curElem.css( props );
15532 }
15533 }
15534 };
15535
15536 jQuery.fn.extend({
15537 offset: function( options ) {
15538 if ( arguments.length ) {
15539 return options === undefined ?
15540 this :
15541 this.each(function( i ) {
15542 jQuery.offset.setOffset( this, options, i );
15543 });
15544 }
15545
15546 var docElem, win,
15547 elem = this[ 0 ],
15548 box = { top: 0, left: 0 },
15549 doc = elem && elem.ownerDocument;
15550
15551 if ( !doc ) {
15552 return;
15553 }
15554
15555 docElem = doc.documentElement;
15556
15557 // Make sure it's not a disconnected DOM node
15558 if ( !jQuery.contains( docElem, elem ) ) {
15559 return box;
15560 }
15561
15562 // If we don't have gBCR, just use 0,0 rather than error
15563 // BlackBerry 5, iOS 3 (original iPhone)
15564 if ( typeof elem.getBoundingClientRect !== strundefined ) {
15565 box = elem.getBoundingClientRect();
15566 }
15567 win = getWindow( doc );
15568 return {
15569 top: box.top + win.pageYOffset - docElem.clientTop,
15570 left: box.left + win.pageXOffset - docElem.clientLeft
15571 };
15572 },
15573
15574 position: function() {
15575 if ( !this[ 0 ] ) {
15576 return;
15577 }
15578
15579 var offsetParent, offset,
15580 elem = this[ 0 ],
15581 parentOffset = { top: 0, left: 0 };
15582
15583 // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
15584 if ( jQuery.css( elem, "position" ) === "fixed" ) {
15585 // We assume that getBoundingClientRect is available when computed position is fixed
15586 offset = elem.getBoundingClientRect();
15587
15588 } else {
15589 // Get *real* offsetParent
15590 offsetParent = this.offsetParent();
15591
15592 // Get correct offsets
15593 offset = this.offset();
15594 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
15595 parentOffset = offsetParent.offset();
15596 }
15597
15598 // Add offsetParent borders
15599 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
15600 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
15601 }
15602
15603 // Subtract parent offsets and element margins
15604 return {
15605 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
15606 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
15607 };
15608 },
15609
15610 offsetParent: function() {
15611 return this.map(function() {
15612 var offsetParent = this.offsetParent || docElem;
15613
15614 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) {
15615 offsetParent = offsetParent.offsetParent;
15616 }
15617
15618 return offsetParent || docElem;
15619 });
15620 }
15621 });
15622
15623 // Create scrollLeft and scrollTop methods
15624 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
15625 var top = "pageYOffset" === prop;
15626
15627 jQuery.fn[ method ] = function( val ) {
15628 return access( this, function( elem, method, val ) {
15629 var win = getWindow( elem );
15630
15631 if ( val === undefined ) {
15632 return win ? win[ prop ] : elem[ method ];
15633 }
15634
15635 if ( win ) {
15636 win.scrollTo(
15637 !top ? val : window.pageXOffset,
15638 top ? val : window.pageYOffset
15639 );
15640
15641 } else {
15642 elem[ method ] = val;
15643 }
15644 }, method, val, arguments.length, null );
15645 };
15646 });
15647
15648 // Add the top/left cssHooks using jQuery.fn.position
15649 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
15650 // getComputedStyle returns percent when specified for top/left/bottom/right
15651 // rather than make the css module depend on the offset module, we just check for it here
15652 jQuery.each( [ "top", "left" ], function( i, prop ) {
15653 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
15654 function( elem, computed ) {
15655 if ( computed ) {
15656 computed = curCSS( elem, prop );
15657 // if curCSS returns percentage, fallback to offset
15658 return rnumnonpx.test( computed ) ?
15659 jQuery( elem ).position()[ prop ] + "px" :
15660 computed;
15661 }
15662 }
15663 );
15664 });
15665
15666
15667 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
15668 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
15669 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
15670 // margin is only for outerHeight, outerWidth
15671 jQuery.fn[ funcName ] = function( margin, value ) {
15672 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
15673 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
15674
15675 return access( this, function( elem, type, value ) {
15676 var doc;
15677
15678 if ( jQuery.isWindow( elem ) ) {
15679 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
15680 // isn't a whole lot we can do. See pull request at this URL for discussion:
15681 // https://github.com/jquery/jquery/pull/764
15682 return elem.document.documentElement[ "client" + name ];
15683 }
15684
15685 // Get document width or height
15686 if ( elem.nodeType === 9 ) {
15687 doc = elem.documentElement;
15688
15689 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
15690 // whichever is greatest
15691 return Math.max(
15692 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
15693 elem.body[ "offset" + name ], doc[ "offset" + name ],
15694 doc[ "client" + name ]
15695 );
15696 }
15697
15698 return value === undefined ?
15699 // Get width or height on the element, requesting but not forcing parseFloat
15700 jQuery.css( elem, type, extra ) :
15701
15702 // Set width or height on the element
15703 jQuery.style( elem, type, value, extra );
15704 }, type, chainable ? margin : undefined, chainable, null );
15705 };
15706 });
15707 });
15708
15709
15710 // The number of elements contained in the matched element set
15711 jQuery.fn.size = function() {
15712 return this.length;
15713 };
15714
15715 jQuery.fn.andSelf = jQuery.fn.addBack;
15716
15717
15718
15719
15720 // Register as a named AMD module, since jQuery can be concatenated with other
15721 // files that may use define, but not via a proper concatenation script that
15722 // understands anonymous AMD modules. A named AMD is safest and most robust
15723 // way to register. Lowercase jquery is used because AMD module names are
15724 // derived from file names, and jQuery is normally delivered in a lowercase
15725 // file name. Do this after creating the global so that if an AMD module wants
15726 // to call noConflict to hide this version of jQuery, it will work.
15727
15728 // Note that for maximum portability, libraries that are not jQuery should
15729 // declare themselves as anonymous modules, and avoid setting a global if an
15730 // AMD loader is present. jQuery is a special case. For more information, see
15731 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
15732
15733 if ( typeof define === "function" && define.amd ) {
15734 define( "jquery", [], function() {
15735 return jQuery;
15736 });
15737 }
15738
15739
15740
15741
15742 var
15743 // Map over jQuery in case of overwrite
15744 _jQuery = window.jQuery,
15745
15746 // Map over the $ in case of overwrite
15747 _$ = window.$;
15748
15749 jQuery.noConflict = function( deep ) {
15750 if ( window.$ === jQuery ) {
15751 window.$ = _$;
15752 }
15753
15754 if ( deep && window.jQuery === jQuery ) {
15755 window.jQuery = _jQuery;
15756 }
15757
15758 return jQuery;
15759 };
15760
15761 // Expose jQuery and $ identifiers, even in
15762 // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
15763 // and CommonJS for browser emulators (#13566)
15764 if ( typeof noGlobal === strundefined ) {
15765 window.jQuery = window.$ = jQuery;
15766 }
15767
15768
15769
15770
15771 return jQuery;
15772
15773 }));
15774 </script>
15775 <script>
15776 /*!
15777 * Bootstrap v3.2.0 (http://getbootstrap.com)
15778 * Copyright 2011-2014 Twitter, Inc.
15779 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15780 */
15781
15782 if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript requires jQuery') }
15783
15784 /* ========================================================================
15785 * Bootstrap: transition.js v3.2.0
15786 * http://getbootstrap.com/javascript/#transitions
15787 * ========================================================================
15788 * Copyright 2011-2014 Twitter, Inc.
15789 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15790 * ======================================================================== */
15791
15792
15793 +function ($) {
15794 'use strict';
15795
15796 // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
15797 // ============================================================
15798
15799 function transitionEnd() {
15800 var el = document.createElement('bootstrap')
15801
15802 var transEndEventNames = {
15803 WebkitTransition : 'webkitTransitionEnd',
15804 MozTransition : 'transitionend',
15805 OTransition : 'oTransitionEnd otransitionend',
15806 transition : 'transitionend'
15807 }
15808
15809 for (var name in transEndEventNames) {
15810 if (el.style[name] !== undefined) {
15811 return { end: transEndEventNames[name] }
15812 }
15813 }
15814
15815 return false // explicit for ie8 ( ._.)
15816 }
15817
15818 // http://blog.alexmaccaw.com/css-transitions
15819 $.fn.emulateTransitionEnd = function (duration) {
15820 var called = false
15821 var $el = this
15822 $(this).one('bsTransitionEnd', function () { called = true })
15823 var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
15824 setTimeout(callback, duration)
15825 return this
15826 }
15827
15828 $(function () {
15829 $.support.transition = transitionEnd()
15830
15831 if (!$.support.transition) return
15832
15833 $.event.special.bsTransitionEnd = {
15834 bindType: $.support.transition.end,
15835 delegateType: $.support.transition.end,
15836 handle: function (e) {
15837 if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
15838 }
15839 }
15840 })
15841
15842 }(jQuery);
15843
15844 /* ========================================================================
15845 * Bootstrap: alert.js v3.2.0
15846 * http://getbootstrap.com/javascript/#alerts
15847 * ========================================================================
15848 * Copyright 2011-2014 Twitter, Inc.
15849 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15850 * ======================================================================== */
15851
15852
15853 +function ($) {
15854 'use strict';
15855
15856 // ALERT CLASS DEFINITION
15857 // ======================
15858
15859 var dismiss = '[data-dismiss="alert"]'
15860 var Alert = function (el) {
15861 $(el).on('click', dismiss, this.close)
15862 }
15863
15864 Alert.VERSION = '3.2.0'
15865
15866 Alert.prototype.close = function (e) {
15867 var $this = $(this)
15868 var selector = $this.attr('data-target')
15869
15870 if (!selector) {
15871 selector = $this.attr('href')
15872 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
15873 }
15874
15875 var $parent = $(selector)
15876
15877 if (e) e.preventDefault()
15878
15879 if (!$parent.length) {
15880 $parent = $this.hasClass('alert') ? $this : $this.parent()
15881 }
15882
15883 $parent.trigger(e = $.Event('close.bs.alert'))
15884
15885 if (e.isDefaultPrevented()) return
15886
15887 $parent.removeClass('in')
15888
15889 function removeElement() {
15890 // detach from parent, fire event then clean up data
15891 $parent.detach().trigger('closed.bs.alert').remove()
15892 }
15893
15894 $.support.transition && $parent.hasClass('fade') ?
15895 $parent
15896 .one('bsTransitionEnd', removeElement)
15897 .emulateTransitionEnd(150) :
15898 removeElement()
15899 }
15900
15901
15902 // ALERT PLUGIN DEFINITION
15903 // =======================
15904
15905 function Plugin(option) {
15906 return this.each(function () {
15907 var $this = $(this)
15908 var data = $this.data('bs.alert')
15909
15910 if (!data) $this.data('bs.alert', (data = new Alert(this)))
15911 if (typeof option == 'string') data[option].call($this)
15912 })
15913 }
15914
15915 var old = $.fn.alert
15916
15917 $.fn.alert = Plugin
15918 $.fn.alert.Constructor = Alert
15919
15920
15921 // ALERT NO CONFLICT
15922 // =================
15923
15924 $.fn.alert.noConflict = function () {
15925 $.fn.alert = old
15926 return this
15927 }
15928
15929
15930 // ALERT DATA-API
15931 // ==============
15932
15933 $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
15934
15935 }(jQuery);
15936
15937 /* ========================================================================
15938 * Bootstrap: button.js v3.2.0
15939 * http://getbootstrap.com/javascript/#buttons
15940 * ========================================================================
15941 * Copyright 2011-2014 Twitter, Inc.
15942 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15943 * ======================================================================== */
15944
15945
15946 +function ($) {
15947 'use strict';
15948
15949 // BUTTON PUBLIC CLASS DEFINITION
15950 // ==============================
15951
15952 var Button = function (element, options) {
15953 this.$element = $(element)
15954 this.options = $.extend({}, Button.DEFAULTS, options)
15955 this.isLoading = false
15956 }
15957
15958 Button.VERSION = '3.2.0'
15959
15960 Button.DEFAULTS = {
15961 loadingText: 'loading...'
15962 }
15963
15964 Button.prototype.setState = function (state) {
15965 var d = 'disabled'
15966 var $el = this.$element
15967 var val = $el.is('input') ? 'val' : 'html'
15968 var data = $el.data()
15969
15970 state = state + 'Text'
15971
15972 if (data.resetText == null) $el.data('resetText', $el[val]())
15973
15974 $el[val](data[state] == null ? this.options[state] : data[state])
15975
15976 // push to event loop to allow forms to submit
15977 setTimeout($.proxy(function () {
15978 if (state == 'loadingText') {
15979 this.isLoading = true
15980 $el.addClass(d).attr(d, d)
15981 } else if (this.isLoading) {
15982 this.isLoading = false
15983 $el.removeClass(d).removeAttr(d)
15984 }
15985 }, this), 0)
15986 }
15987
15988 Button.prototype.toggle = function () {
15989 var changed = true
15990 var $parent = this.$element.closest('[data-toggle="buttons"]')
15991
15992 if ($parent.length) {
15993 var $input = this.$element.find('input')
15994 if ($input.prop('type') == 'radio') {
15995 if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
15996 else $parent.find('.active').removeClass('active')
15997 }
15998 if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
15999 }
16000
16001 if (changed) this.$element.toggleClass('active')
16002 }
16003
16004
16005 // BUTTON PLUGIN DEFINITION
16006 // ========================
16007
16008 function Plugin(option) {
16009 return this.each(function () {
16010 var $this = $(this)
16011 var data = $this.data('bs.button')
16012 var options = typeof option == 'object' && option
16013
16014 if (!data) $this.data('bs.button', (data = new Button(this, options)))
16015
16016 if (option == 'toggle') data.toggle()
16017 else if (option) data.setState(option)
16018 })
16019 }
16020
16021 var old = $.fn.button
16022
16023 $.fn.button = Plugin
16024 $.fn.button.Constructor = Button
16025
16026
16027 // BUTTON NO CONFLICT
16028 // ==================
16029
16030 $.fn.button.noConflict = function () {
16031 $.fn.button = old
16032 return this
16033 }
16034
16035
16036 // BUTTON DATA-API
16037 // ===============
16038
16039 $(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
16040 var $btn = $(e.target)
16041 if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
16042 Plugin.call($btn, 'toggle')
16043 e.preventDefault()
16044 })
16045
16046 }(jQuery);
16047
16048 /* ========================================================================
16049 * Bootstrap: carousel.js v3.2.0
16050 * http://getbootstrap.com/javascript/#carousel
16051 * ========================================================================
16052 * Copyright 2011-2014 Twitter, Inc.
16053 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16054 * ======================================================================== */
16055
16056
16057 +function ($) {
16058 'use strict';
16059
16060 // CAROUSEL CLASS DEFINITION
16061 // =========================
16062
16063 var Carousel = function (element, options) {
16064 this.$element = $(element).on('keydown.bs.carousel', $.proxy(this.keydown, this))
16065 this.$indicators = this.$element.find('.carousel-indicators')
16066 this.options = options
16067 this.paused =
16068 this.sliding =
16069 this.interval =
16070 this.$active =
16071 this.$items = null
16072
16073 this.options.pause == 'hover' && this.$element
16074 .on('mouseenter.bs.carousel', $.proxy(this.pause, this))
16075 .on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
16076 }
16077
16078 Carousel.VERSION = '3.2.0'
16079
16080 Carousel.DEFAULTS = {
16081 interval: 5000,
16082 pause: 'hover',
16083 wrap: true
16084 }
16085
16086 Carousel.prototype.keydown = function (e) {
16087 switch (e.which) {
16088 case 37: this.prev(); break
16089 case 39: this.next(); break
16090 default: return
16091 }
16092
16093 e.preventDefault()
16094 }
16095
16096 Carousel.prototype.cycle = function (e) {
16097 e || (this.paused = false)
16098
16099 this.interval && clearInterval(this.interval)
16100
16101 this.options.interval
16102 && !this.paused
16103 && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
16104
16105 return this
16106 }
16107
16108 Carousel.prototype.getItemIndex = function (item) {
16109 this.$items = item.parent().children('.item')
16110 return this.$items.index(item || this.$active)
16111 }
16112
16113 Carousel.prototype.to = function (pos) {
16114 var that = this
16115 var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active'))
16116
16117 if (pos > (this.$items.length - 1) || pos < 0) return
16118
16119 if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid"
16120 if (activeIndex == pos) return this.pause().cycle()
16121
16122 return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
16123 }
16124
16125 Carousel.prototype.pause = function (e) {
16126 e || (this.paused = true)
16127
16128 if (this.$element.find('.next, .prev').length && $.support.transition) {
16129 this.$element.trigger($.support.transition.end)
16130 this.cycle(true)
16131 }
16132
16133 this.interval = clearInterval(this.interval)
16134
16135 return this
16136 }
16137
16138 Carousel.prototype.next = function () {
16139 if (this.sliding) return
16140 return this.slide('next')
16141 }
16142
16143 Carousel.prototype.prev = function () {
16144 if (this.sliding) return
16145 return this.slide('prev')
16146 }
16147
16148 Carousel.prototype.slide = function (type, next) {
16149 var $active = this.$element.find('.item.active')
16150 var $next = next || $active[type]()
16151 var isCycling = this.interval
16152 var direction = type == 'next' ? 'left' : 'right'
16153 var fallback = type == 'next' ? 'first' : 'last'
16154 var that = this
16155
16156 if (!$next.length) {
16157 if (!this.options.wrap) return
16158 $next = this.$element.find('.item')[fallback]()
16159 }
16160
16161 if ($next.hasClass('active')) return (this.sliding = false)
16162
16163 var relatedTarget = $next[0]
16164 var slideEvent = $.Event('slide.bs.carousel', {
16165 relatedTarget: relatedTarget,
16166 direction: direction
16167 })
16168 this.$element.trigger(slideEvent)
16169 if (slideEvent.isDefaultPrevented()) return
16170
16171 this.sliding = true
16172
16173 isCycling && this.pause()
16174
16175 if (this.$indicators.length) {
16176 this.$indicators.find('.active').removeClass('active')
16177 var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)])
16178 $nextIndicator && $nextIndicator.addClass('active')
16179 }
16180
16181 var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid"
16182 if ($.support.transition && this.$element.hasClass('slide')) {
16183 $next.addClass(type)
16184 $next[0].offsetWidth // force reflow
16185 $active.addClass(direction)
16186 $next.addClass(direction)
16187 $active
16188 .one('bsTransitionEnd', function () {
16189 $next.removeClass([type, direction].join(' ')).addClass('active')
16190 $active.removeClass(['active', direction].join(' '))
16191 that.sliding = false
16192 setTimeout(function () {
16193 that.$element.trigger(slidEvent)
16194 }, 0)
16195 })
16196 .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000)
16197 } else {
16198 $active.removeClass('active')
16199 $next.addClass('active')
16200 this.sliding = false
16201 this.$element.trigger(slidEvent)
16202 }
16203
16204 isCycling && this.cycle()
16205
16206 return this
16207 }
16208
16209
16210 // CAROUSEL PLUGIN DEFINITION
16211 // ==========================
16212
16213 function Plugin(option) {
16214 return this.each(function () {
16215 var $this = $(this)
16216 var data = $this.data('bs.carousel')
16217 var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
16218 var action = typeof option == 'string' ? option : options.slide
16219
16220 if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
16221 if (typeof option == 'number') data.to(option)
16222 else if (action) data[action]()
16223 else if (options.interval) data.pause().cycle()
16224 })
16225 }
16226
16227 var old = $.fn.carousel
16228
16229 $.fn.carousel = Plugin
16230 $.fn.carousel.Constructor = Carousel
16231
16232
16233 // CAROUSEL NO CONFLICT
16234 // ====================
16235
16236 $.fn.carousel.noConflict = function () {
16237 $.fn.carousel = old
16238 return this
16239 }
16240
16241
16242 // CAROUSEL DATA-API
16243 // =================
16244
16245 $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
16246 var href
16247 var $this = $(this)
16248 var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7
16249 if (!$target.hasClass('carousel')) return
16250 var options = $.extend({}, $target.data(), $this.data())
16251 var slideIndex = $this.attr('data-slide-to')
16252 if (slideIndex) options.interval = false
16253
16254 Plugin.call($target, options)
16255
16256 if (slideIndex) {
16257 $target.data('bs.carousel').to(slideIndex)
16258 }
16259
16260 e.preventDefault()
16261 })
16262
16263 $(window).on('load', function () {
16264 $('[data-ride="carousel"]').each(function () {
16265 var $carousel = $(this)
16266 Plugin.call($carousel, $carousel.data())
16267 })
16268 })
16269
16270 }(jQuery);
16271
16272 /* ========================================================================
16273 * Bootstrap: collapse.js v3.2.0
16274 * http://getbootstrap.com/javascript/#collapse
16275 * ========================================================================
16276 * Copyright 2011-2014 Twitter, Inc.
16277 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16278 * ======================================================================== */
16279
16280
16281 +function ($) {
16282 'use strict';
16283
16284 // COLLAPSE PUBLIC CLASS DEFINITION
16285 // ================================
16286
16287 var Collapse = function (element, options) {
16288 this.$element = $(element)
16289 this.options = $.extend({}, Collapse.DEFAULTS, options)
16290 this.transitioning = null
16291
16292 if (this.options.parent) this.$parent = $(this.options.parent)
16293 if (this.options.toggle) this.toggle()
16294 }
16295
16296 Collapse.VERSION = '3.2.0'
16297
16298 Collapse.DEFAULTS = {
16299 toggle: true
16300 }
16301
16302 Collapse.prototype.dimension = function () {
16303 var hasWidth = this.$element.hasClass('width')
16304 return hasWidth ? 'width' : 'height'
16305 }
16306
16307 Collapse.prototype.show = function () {
16308 if (this.transitioning || this.$element.hasClass('in')) return
16309
16310 var startEvent = $.Event('show.bs.collapse')
16311 this.$element.trigger(startEvent)
16312 if (startEvent.isDefaultPrevented()) return
16313
16314 var actives = this.$parent && this.$parent.find('> .panel > .in')
16315
16316 if (actives && actives.length) {
16317 var hasData = actives.data('bs.collapse')
16318 if (hasData && hasData.transitioning) return
16319 Plugin.call(actives, 'hide')
16320 hasData || actives.data('bs.collapse', null)
16321 }
16322
16323 var dimension = this.dimension()
16324
16325 this.$element
16326 .removeClass('collapse')
16327 .addClass('collapsing')[dimension](0)
16328
16329 this.transitioning = 1
16330
16331 var complete = function () {
16332 this.$element
16333 .removeClass('collapsing')
16334 .addClass('collapse in')[dimension]('')
16335 this.transitioning = 0
16336 this.$element
16337 .trigger('shown.bs.collapse')
16338 }
16339
16340 if (!$.support.transition) return complete.call(this)
16341
16342 var scrollSize = $.camelCase(['scroll', dimension].join('-'))
16343
16344 this.$element
16345 .one('bsTransitionEnd', $.proxy(complete, this))
16346 .emulateTransitionEnd(350)[dimension](this.$element[0][scrollSize])
16347 }
16348
16349 Collapse.prototype.hide = function () {
16350 if (this.transitioning || !this.$element.hasClass('in')) return
16351
16352 var startEvent = $.Event('hide.bs.collapse')
16353 this.$element.trigger(startEvent)
16354 if (startEvent.isDefaultPrevented()) return
16355
16356 var dimension = this.dimension()
16357
16358 this.$element[dimension](this.$element[dimension]())[0].offsetHeight
16359
16360 this.$element
16361 .addClass('collapsing')
16362 .removeClass('collapse')
16363 .removeClass('in')
16364
16365 this.transitioning = 1
16366
16367 var complete = function () {
16368 this.transitioning = 0
16369 this.$element
16370 .trigger('hidden.bs.collapse')
16371 .removeClass('collapsing')
16372 .addClass('collapse')
16373 }
16374
16375 if (!$.support.transition) return complete.call(this)
16376
16377 this.$element
16378 [dimension](0)
16379 .one('bsTransitionEnd', $.proxy(complete, this))
16380 .emulateTransitionEnd(350)
16381 }
16382
16383 Collapse.prototype.toggle = function () {
16384 this[this.$element.hasClass('in') ? 'hide' : 'show']()
16385 }
16386
16387
16388 // COLLAPSE PLUGIN DEFINITION
16389 // ==========================
16390
16391 function Plugin(option) {
16392 return this.each(function () {
16393 var $this = $(this)
16394 var data = $this.data('bs.collapse')
16395 var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
16396
16397 if (!data && options.toggle && option == 'show') option = !option
16398 if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
16399 if (typeof option == 'string') data[option]()
16400 })
16401 }
16402
16403 var old = $.fn.collapse
16404
16405 $.fn.collapse = Plugin
16406 $.fn.collapse.Constructor = Collapse
16407
16408
16409 // COLLAPSE NO CONFLICT
16410 // ====================
16411
16412 $.fn.collapse.noConflict = function () {
16413 $.fn.collapse = old
16414 return this
16415 }
16416
16417
16418 // COLLAPSE DATA-API
16419 // =================
16420
16421 $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
16422 var href
16423 var $this = $(this)
16424 var target = $this.attr('data-target')
16425 || e.preventDefault()
16426 || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7
16427 var $target = $(target)
16428 var data = $target.data('bs.collapse')
16429 var option = data ? 'toggle' : $this.data()
16430 var parent = $this.attr('data-parent')
16431 var $parent = parent && $(parent)
16432
16433 if (!data || !data.transitioning) {
16434 if ($parent) $parent.find('[data-toggle="collapse"][data-parent="' + parent + '"]').not($this).addClass('collapsed')
16435 $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
16436 }
16437
16438 Plugin.call($target, option)
16439 })
16440
16441 }(jQuery);
16442
16443 /* ========================================================================
16444 * Bootstrap: dropdown.js v3.2.0
16445 * http://getbootstrap.com/javascript/#dropdowns
16446 * ========================================================================
16447 * Copyright 2011-2014 Twitter, Inc.
16448 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16449 * ======================================================================== */
16450
16451
16452 +function ($) {
16453 'use strict';
16454
16455 // DROPDOWN CLASS DEFINITION
16456 // =========================
16457
16458 var backdrop = '.dropdown-backdrop'
16459 var toggle = '[data-toggle="dropdown"]'
16460 var Dropdown = function (element) {
16461 $(element).on('click.bs.dropdown', this.toggle)
16462 }
16463
16464 Dropdown.VERSION = '3.2.0'
16465
16466 Dropdown.prototype.toggle = function (e) {
16467 var $this = $(this)
16468
16469 if ($this.is('.disabled, :disabled')) return
16470
16471 var $parent = getParent($this)
16472 var isActive = $parent.hasClass('open')
16473
16474 clearMenus()
16475
16476 if (!isActive) {
16477 if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
16478 // if mobile we use a backdrop because click events don't delegate
16479 $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
16480 }
16481
16482 var relatedTarget = { relatedTarget: this }
16483 $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
16484
16485 if (e.isDefaultPrevented()) return
16486
16487 $this.trigger('focus')
16488
16489 $parent
16490 .toggleClass('open')
16491 .trigger('shown.bs.dropdown', relatedTarget)
16492 }
16493
16494 return false
16495 }
16496
16497 Dropdown.prototype.keydown = function (e) {
16498 if (!/(38|40|27)/.test(e.keyCode)) return
16499
16500 var $this = $(this)
16501
16502 e.preventDefault()
16503 e.stopPropagation()
16504
16505 if ($this.is('.disabled, :disabled')) return
16506
16507 var $parent = getParent($this)
16508 var isActive = $parent.hasClass('open')
16509
16510 if (!isActive || (isActive && e.keyCode == 27)) {
16511 if (e.which == 27) $parent.find(toggle).trigger('focus')
16512 return $this.trigger('click')
16513 }
16514
16515 var desc = ' li:not(.divider):visible a'
16516 var $items = $parent.find('[role="menu"]' + desc + ', [role="listbox"]' + desc)
16517
16518 if (!$items.length) return
16519
16520 var index = $items.index($items.filter(':focus'))
16521
16522 if (e.keyCode == 38 && index > 0) index-- // up
16523 if (e.keyCode == 40 && index < $items.length - 1) index++ // down
16524 if (!~index) index = 0
16525
16526 $items.eq(index).trigger('focus')
16527 }
16528
16529 function clearMenus(e) {
16530 if (e && e.which === 3) return
16531 $(backdrop).remove()
16532 $(toggle).each(function () {
16533 var $parent = getParent($(this))
16534 var relatedTarget = { relatedTarget: this }
16535 if (!$parent.hasClass('open')) return
16536 $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
16537 if (e.isDefaultPrevented()) return
16538 $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
16539 })
16540 }
16541
16542 function getParent($this) {
16543 var selector = $this.attr('data-target')
16544
16545 if (!selector) {
16546 selector = $this.attr('href')
16547 selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
16548 }
16549
16550 var $parent = selector && $(selector)
16551
16552 return $parent && $parent.length ? $parent : $this.parent()
16553 }
16554
16555
16556 // DROPDOWN PLUGIN DEFINITION
16557 // ==========================
16558
16559 function Plugin(option) {
16560 return this.each(function () {
16561 var $this = $(this)
16562 var data = $this.data('bs.dropdown')
16563
16564 if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))
16565 if (typeof option == 'string') data[option].call($this)
16566 })
16567 }
16568
16569 var old = $.fn.dropdown
16570
16571 $.fn.dropdown = Plugin
16572 $.fn.dropdown.Constructor = Dropdown
16573
16574
16575 // DROPDOWN NO CONFLICT
16576 // ====================
16577
16578 $.fn.dropdown.noConflict = function () {
16579 $.fn.dropdown = old
16580 return this
16581 }
16582
16583
16584 // APPLY TO STANDARD DROPDOWN ELEMENTS
16585 // ===================================
16586
16587 $(document)
16588 .on('click.bs.dropdown.data-api', clearMenus)
16589 .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
16590 .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
16591 .on('keydown.bs.dropdown.data-api', toggle + ', [role="menu"], [role="listbox"]', Dropdown.prototype.keydown)
16592
16593 }(jQuery);
16594
16595 /* ========================================================================
16596 * Bootstrap: modal.js v3.2.0
16597 * http://getbootstrap.com/javascript/#modals
16598 * ========================================================================
16599 * Copyright 2011-2014 Twitter, Inc.
16600 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16601 * ======================================================================== */
16602
16603
16604 +function ($) {
16605 'use strict';
16606
16607 // MODAL CLASS DEFINITION
16608 // ======================
16609
16610 var Modal = function (element, options) {
16611 this.options = options
16612 this.$body = $(document.body)
16613 this.$element = $(element)
16614 this.$backdrop =
16615 this.isShown = null
16616 this.scrollbarWidth = 0
16617
16618 if (this.options.remote) {
16619 this.$element
16620 .find('.modal-content')
16621 .load(this.options.remote, $.proxy(function () {
16622 this.$element.trigger('loaded.bs.modal')
16623 }, this))
16624 }
16625 }
16626
16627 Modal.VERSION = '3.2.0'
16628
16629 Modal.DEFAULTS = {
16630 backdrop: true,
16631 keyboard: true,
16632 show: true
16633 }
16634
16635 Modal.prototype.toggle = function (_relatedTarget) {
16636 return this.isShown ? this.hide() : this.show(_relatedTarget)
16637 }
16638
16639 Modal.prototype.show = function (_relatedTarget) {
16640 var that = this
16641 var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
16642
16643 this.$element.trigger(e)
16644
16645 if (this.isShown || e.isDefaultPrevented()) return
16646
16647 this.isShown = true
16648
16649 this.checkScrollbar()
16650 this.$body.addClass('modal-open')
16651
16652 this.setScrollbar()
16653 this.escape()
16654
16655 this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
16656
16657 this.backdrop(function () {
16658 var transition = $.support.transition && that.$element.hasClass('fade')
16659
16660 if (!that.$element.parent().length) {
16661 that.$element.appendTo(that.$body) // don't move modals dom position
16662 }
16663
16664 that.$element
16665 .show()
16666 .scrollTop(0)
16667
16668 if (transition) {
16669 that.$element[0].offsetWidth // force reflow
16670 }
16671
16672 that.$element
16673 .addClass('in')
16674 .attr('aria-hidden', false)
16675
16676 that.enforceFocus()
16677
16678 var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
16679
16680 transition ?
16681 that.$element.find('.modal-dialog') // wait for modal to slide in
16682 .one('bsTransitionEnd', function () {
16683 that.$element.trigger('focus').trigger(e)
16684 })
16685 .emulateTransitionEnd(300) :
16686 that.$element.trigger('focus').trigger(e)
16687 })
16688 }
16689
16690 Modal.prototype.hide = function (e) {
16691 if (e) e.preventDefault()
16692
16693 e = $.Event('hide.bs.modal')
16694
16695 this.$element.trigger(e)
16696
16697 if (!this.isShown || e.isDefaultPrevented()) return
16698
16699 this.isShown = false
16700
16701 this.$body.removeClass('modal-open')
16702
16703 this.resetScrollbar()
16704 this.escape()
16705
16706 $(document).off('focusin.bs.modal')
16707
16708 this.$element
16709 .removeClass('in')
16710 .attr('aria-hidden', true)
16711 .off('click.dismiss.bs.modal')
16712
16713 $.support.transition && this.$element.hasClass('fade') ?
16714 this.$element
16715 .one('bsTransitionEnd', $.proxy(this.hideModal, this))
16716 .emulateTransitionEnd(300) :
16717 this.hideModal()
16718 }
16719
16720 Modal.prototype.enforceFocus = function () {
16721 $(document)
16722 .off('focusin.bs.modal') // guard against infinite focus loop
16723 .on('focusin.bs.modal', $.proxy(function (e) {
16724 if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
16725 this.$element.trigger('focus')
16726 }
16727 }, this))
16728 }
16729
16730 Modal.prototype.escape = function () {
16731 if (this.isShown && this.options.keyboard) {
16732 this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {
16733 e.which == 27 && this.hide()
16734 }, this))
16735 } else if (!this.isShown) {
16736 this.$element.off('keyup.dismiss.bs.modal')
16737 }
16738 }
16739
16740 Modal.prototype.hideModal = function () {
16741 var that = this
16742 this.$element.hide()
16743 this.backdrop(function () {
16744 that.$element.trigger('hidden.bs.modal')
16745 })
16746 }
16747
16748 Modal.prototype.removeBackdrop = function () {
16749 this.$backdrop && this.$backdrop.remove()
16750 this.$backdrop = null
16751 }
16752
16753 Modal.prototype.backdrop = function (callback) {
16754 var that = this
16755 var animate = this.$element.hasClass('fade') ? 'fade' : ''
16756
16757 if (this.isShown && this.options.backdrop) {
16758 var doAnimate = $.support.transition && animate
16759
16760 this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
16761 .appendTo(this.$body)
16762
16763 this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
16764 if (e.target !== e.currentTarget) return
16765 this.options.backdrop == 'static'
16766 ? this.$element[0].focus.call(this.$element[0])
16767 : this.hide.call(this)
16768 }, this))
16769
16770 if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
16771
16772 this.$backdrop.addClass('in')
16773
16774 if (!callback) return
16775
16776 doAnimate ?
16777 this.$backdrop
16778 .one('bsTransitionEnd', callback)
16779 .emulateTransitionEnd(150) :
16780 callback()
16781
16782 } else if (!this.isShown && this.$backdrop) {
16783 this.$backdrop.removeClass('in')
16784
16785 var callbackRemove = function () {
16786 that.removeBackdrop()
16787 callback && callback()
16788 }
16789 $.support.transition && this.$element.hasClass('fade') ?
16790 this.$backdrop
16791 .one('bsTransitionEnd', callbackRemove)
16792 .emulateTransitionEnd(150) :
16793 callbackRemove()
16794
16795 } else if (callback) {
16796 callback()
16797 }
16798 }
16799
16800 Modal.prototype.checkScrollbar = function () {
16801 if (document.body.clientWidth >= window.innerWidth) return
16802 this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar()
16803 }
16804
16805 Modal.prototype.setScrollbar = function () {
16806 var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
16807 if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
16808 }
16809
16810 Modal.prototype.resetScrollbar = function () {
16811 this.$body.css('padding-right', '')
16812 }
16813
16814 Modal.prototype.measureScrollbar = function () { // thx walsh
16815 var scrollDiv = document.createElement('div')
16816 scrollDiv.className = 'modal-scrollbar-measure'
16817 this.$body.append(scrollDiv)
16818 var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
16819 this.$body[0].removeChild(scrollDiv)
16820 return scrollbarWidth
16821 }
16822
16823
16824 // MODAL PLUGIN DEFINITION
16825 // =======================
16826
16827 function Plugin(option, _relatedTarget) {
16828 return this.each(function () {
16829 var $this = $(this)
16830 var data = $this.data('bs.modal')
16831 var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
16832
16833 if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
16834 if (typeof option == 'string') data[option](_relatedTarget)
16835 else if (options.show) data.show(_relatedTarget)
16836 })
16837 }
16838
16839 var old = $.fn.modal
16840
16841 $.fn.modal = Plugin
16842 $.fn.modal.Constructor = Modal
16843
16844
16845 // MODAL NO CONFLICT
16846 // =================
16847
16848 $.fn.modal.noConflict = function () {
16849 $.fn.modal = old
16850 return this
16851 }
16852
16853
16854 // MODAL DATA-API
16855 // ==============
16856
16857 $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
16858 var $this = $(this)
16859 var href = $this.attr('href')
16860 var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7
16861 var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
16862
16863 if ($this.is('a')) e.preventDefault()
16864
16865 $target.one('show.bs.modal', function (showEvent) {
16866 if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
16867 $target.one('hidden.bs.modal', function () {
16868 $this.is(':visible') && $this.trigger('focus')
16869 })
16870 })
16871 Plugin.call($target, option, this)
16872 })
16873
16874 }(jQuery);
16875
16876 /* ========================================================================
16877 * Bootstrap: tooltip.js v3.2.0
16878 * http://getbootstrap.com/javascript/#tooltip
16879 * Inspired by the original jQuery.tipsy by Jason Frame
16880 * ========================================================================
16881 * Copyright 2011-2014 Twitter, Inc.
16882 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16883 * ======================================================================== */
16884
16885
16886 +function ($) {
16887 'use strict';
16888
16889 // TOOLTIP PUBLIC CLASS DEFINITION
16890 // ===============================
16891
16892 var Tooltip = function (element, options) {
16893 this.type =
16894 this.options =
16895 this.enabled =
16896 this.timeout =
16897 this.hoverState =
16898 this.$element = null
16899
16900 this.init('tooltip', element, options)
16901 }
16902
16903 Tooltip.VERSION = '3.2.0'
16904
16905 Tooltip.DEFAULTS = {
16906 animation: true,
16907 placement: 'top',
16908 selector: false,
16909 template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
16910 trigger: 'hover focus',
16911 title: '',
16912 delay: 0,
16913 html: false,
16914 container: false,
16915 viewport: {
16916 selector: 'body',
16917 padding: 0
16918 }
16919 }
16920
16921 Tooltip.prototype.init = function (type, element, options) {
16922 this.enabled = true
16923 this.type = type
16924 this.$element = $(element)
16925 this.options = this.getOptions(options)
16926 this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport)
16927
16928 var triggers = this.options.trigger.split(' ')
16929
16930 for (var i = triggers.length; i--;) {
16931 var trigger = triggers[i]
16932
16933 if (trigger == 'click') {
16934 this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
16935 } else if (trigger != 'manual') {
16936 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
16937 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
16938
16939 this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
16940 this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
16941 }
16942 }
16943
16944 this.options.selector ?
16945 (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
16946 this.fixTitle()
16947 }
16948
16949 Tooltip.prototype.getDefaults = function () {
16950 return Tooltip.DEFAULTS
16951 }
16952
16953 Tooltip.prototype.getOptions = function (options) {
16954 options = $.extend({}, this.getDefaults(), this.$element.data(), options)
16955
16956 if (options.delay && typeof options.delay == 'number') {
16957 options.delay = {
16958 show: options.delay,
16959 hide: options.delay
16960 }
16961 }
16962
16963 return options
16964 }
16965
16966 Tooltip.prototype.getDelegateOptions = function () {
16967 var options = {}
16968 var defaults = this.getDefaults()
16969
16970 this._options && $.each(this._options, function (key, value) {
16971 if (defaults[key] != value) options[key] = value
16972 })
16973
16974 return options
16975 }
16976
16977 Tooltip.prototype.enter = function (obj) {
16978 var self = obj instanceof this.constructor ?
16979 obj : $(obj.currentTarget).data('bs.' + this.type)
16980
16981 if (!self) {
16982 self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
16983 $(obj.currentTarget).data('bs.' + this.type, self)
16984 }
16985
16986 clearTimeout(self.timeout)
16987
16988 self.hoverState = 'in'
16989
16990 if (!self.options.delay || !self.options.delay.show) return self.show()
16991
16992 self.timeout = setTimeout(function () {
16993 if (self.hoverState == 'in') self.show()
16994 }, self.options.delay.show)
16995 }
16996
16997 Tooltip.prototype.leave = function (obj) {
16998 var self = obj instanceof this.constructor ?
16999 obj : $(obj.currentTarget).data('bs.' + this.type)
17000
17001 if (!self) {
17002 self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
17003 $(obj.currentTarget).data('bs.' + this.type, self)
17004 }
17005
17006 clearTimeout(self.timeout)
17007
17008 self.hoverState = 'out'
17009
17010 if (!self.options.delay || !self.options.delay.hide) return self.hide()
17011
17012 self.timeout = setTimeout(function () {
17013 if (self.hoverState == 'out') self.hide()
17014 }, self.options.delay.hide)
17015 }
17016
17017 Tooltip.prototype.show = function () {
17018 var e = $.Event('show.bs.' + this.type)
17019
17020 if (this.hasContent() && this.enabled) {
17021 this.$element.trigger(e)
17022
17023 var inDom = $.contains(document.documentElement, this.$element[0])
17024 if (e.isDefaultPrevented() || !inDom) return
17025 var that = this
17026
17027 var $tip = this.tip()
17028
17029 var tipId = this.getUID(this.type)
17030
17031 this.setContent()
17032 $tip.attr('id', tipId)
17033 this.$element.attr('aria-describedby', tipId)
17034
17035 if (this.options.animation) $tip.addClass('fade')
17036
17037 var placement = typeof this.options.placement == 'function' ?
17038 this.options.placement.call(this, $tip[0], this.$element[0]) :
17039 this.options.placement
17040
17041 var autoToken = /\s?auto?\s?/i
17042 var autoPlace = autoToken.test(placement)
17043 if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
17044
17045 $tip
17046 .detach()
17047 .css({ top: 0, left: 0, display: 'block' })
17048 .addClass(placement)
17049 .data('bs.' + this.type, this)
17050
17051 this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
17052
17053 var pos = this.getPosition()
17054 var actualWidth = $tip[0].offsetWidth
17055 var actualHeight = $tip[0].offsetHeight
17056
17057 if (autoPlace) {
17058 var orgPlacement = placement
17059 var $parent = this.$element.parent()
17060 var parentDim = this.getPosition($parent)
17061
17062 placement = placement == 'bottom' && pos.top + pos.height + actualHeight - parentDim.scroll > parentDim.height ? 'top' :
17063 placement == 'top' && pos.top - parentDim.scroll - actualHeight < 0 ? 'bottom' :
17064 placement == 'right' && pos.right + actualWidth > parentDim.width ? 'left' :
17065 placement == 'left' && pos.left - actualWidth < parentDim.left ? 'right' :
17066 placement
17067
17068 $tip
17069 .removeClass(orgPlacement)
17070 .addClass(placement)
17071 }
17072
17073 var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
17074
17075 this.applyPlacement(calculatedOffset, placement)
17076
17077 var complete = function () {
17078 that.$element.trigger('shown.bs.' + that.type)
17079 that.hoverState = null
17080 }
17081
17082 $.support.transition && this.$tip.hasClass('fade') ?
17083 $tip
17084 .one('bsTransitionEnd', complete)
17085 .emulateTransitionEnd(150) :
17086 complete()
17087 }
17088 }
17089
17090 Tooltip.prototype.applyPlacement = function (offset, placement) {
17091 var $tip = this.tip()
17092 var width = $tip[0].offsetWidth
17093 var height = $tip[0].offsetHeight
17094
17095 // manually read margins because getBoundingClientRect includes difference
17096 var marginTop = parseInt($tip.css('margin-top'), 10)
17097 var marginLeft = parseInt($tip.css('margin-left'), 10)
17098
17099 // we must check for NaN for ie 8/9
17100 if (isNaN(marginTop)) marginTop = 0
17101 if (isNaN(marginLeft)) marginLeft = 0
17102
17103 offset.top = offset.top + marginTop
17104 offset.left = offset.left + marginLeft
17105
17106 // $.fn.offset doesn't round pixel values
17107 // so we use setOffset directly with our own function B-0
17108 $.offset.setOffset($tip[0], $.extend({
17109 using: function (props) {
17110 $tip.css({
17111 top: Math.round(props.top),
17112 left: Math.round(props.left)
17113 })
17114 }
17115 }, offset), 0)
17116
17117 $tip.addClass('in')
17118
17119 // check to see if placing tip in new offset caused the tip to resize itself
17120 var actualWidth = $tip[0].offsetWidth
17121 var actualHeight = $tip[0].offsetHeight
17122
17123 if (placement == 'top' && actualHeight != height) {
17124 offset.top = offset.top + height - actualHeight
17125 }
17126
17127 var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
17128
17129 if (delta.left) offset.left += delta.left
17130 else offset.top += delta.top
17131
17132 var arrowDelta = delta.left ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight
17133 var arrowPosition = delta.left ? 'left' : 'top'
17134 var arrowOffsetPosition = delta.left ? 'offsetWidth' : 'offsetHeight'
17135
17136 $tip.offset(offset)
17137 this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], arrowPosition)
17138 }
17139
17140 Tooltip.prototype.replaceArrow = function (delta, dimension, position) {
17141 this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + '%') : '')
17142 }
17143
17144 Tooltip.prototype.setContent = function () {
17145 var $tip = this.tip()
17146 var title = this.getTitle()
17147
17148 $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
17149 $tip.removeClass('fade in top bottom left right')
17150 }
17151
17152 Tooltip.prototype.hide = function () {
17153 var that = this
17154 var $tip = this.tip()
17155 var e = $.Event('hide.bs.' + this.type)
17156
17157 this.$element.removeAttr('aria-describedby')
17158
17159 function complete() {
17160 if (that.hoverState != 'in') $tip.detach()
17161 that.$element.trigger('hidden.bs.' + that.type)
17162 }
17163
17164 this.$element.trigger(e)
17165
17166 if (e.isDefaultPrevented()) return
17167
17168 $tip.removeClass('in')
17169
17170 $.support.transition && this.$tip.hasClass('fade') ?
17171 $tip
17172 .one('bsTransitionEnd', complete)
17173 .emulateTransitionEnd(150) :
17174 complete()
17175
17176 this.hoverState = null
17177
17178 return this
17179 }
17180
17181 Tooltip.prototype.fixTitle = function () {
17182 var $e = this.$element
17183 if ($e.attr('title') || typeof ($e.attr('data-original-title')) != 'string') {
17184 $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
17185 }
17186 }
17187
17188 Tooltip.prototype.hasContent = function () {
17189 return this.getTitle()
17190 }
17191
17192 Tooltip.prototype.getPosition = function ($element) {
17193 $element = $element || this.$element
17194 var el = $element[0]
17195 var isBody = el.tagName == 'BODY'
17196 return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : null, {
17197 scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop(),
17198 width: isBody ? $(window).width() : $element.outerWidth(),
17199 height: isBody ? $(window).height() : $element.outerHeight()
17200 }, isBody ? { top: 0, left: 0 } : $element.offset())
17201 }
17202
17203 Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
17204 return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
17205 placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
17206 placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
17207 /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
17208
17209 }
17210
17211 Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
17212 var delta = { top: 0, left: 0 }
17213 if (!this.$viewport) return delta
17214
17215 var viewportPadding = this.options.viewport && this.options.viewport.padding || 0
17216 var viewportDimensions = this.getPosition(this.$viewport)
17217
17218 if (/right|left/.test(placement)) {
17219 var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll
17220 var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
17221 if (topEdgeOffset < viewportDimensions.top) { // top overflow
17222 delta.top = viewportDimensions.top - topEdgeOffset
17223 } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
17224 delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
17225 }
17226 } else {
17227 var leftEdgeOffset = pos.left - viewportPadding
17228 var rightEdgeOffset = pos.left + viewportPadding + actualWidth
17229 if (leftEdgeOffset < viewportDimensions.left) { // left overflow
17230 delta.left = viewportDimensions.left - leftEdgeOffset
17231 } else if (rightEdgeOffset > viewportDimensions.width) { // right overflow
17232 delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
17233 }
17234 }
17235
17236 return delta
17237 }
17238
17239 Tooltip.prototype.getTitle = function () {
17240 var title
17241 var $e = this.$element
17242 var o = this.options
17243
17244 title = $e.attr('data-original-title')
17245 || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
17246
17247 return title
17248 }
17249
17250 Tooltip.prototype.getUID = function (prefix) {
17251 do prefix += ~~(Math.random() * 1000000)
17252 while (document.getElementById(prefix))
17253 return prefix
17254 }
17255
17256 Tooltip.prototype.tip = function () {
17257 return (this.$tip = this.$tip || $(this.options.template))
17258 }
17259
17260 Tooltip.prototype.arrow = function () {
17261 return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))
17262 }
17263
17264 Tooltip.prototype.validate = function () {
17265 if (!this.$element[0].parentNode) {
17266 this.hide()
17267 this.$element = null
17268 this.options = null
17269 }
17270 }
17271
17272 Tooltip.prototype.enable = function () {
17273 this.enabled = true
17274 }
17275
17276 Tooltip.prototype.disable = function () {
17277 this.enabled = false
17278 }
17279
17280 Tooltip.prototype.toggleEnabled = function () {
17281 this.enabled = !this.enabled
17282 }
17283
17284 Tooltip.prototype.toggle = function (e) {
17285 var self = this
17286 if (e) {
17287 self = $(e.currentTarget).data('bs.' + this.type)
17288 if (!self) {
17289 self = new this.constructor(e.currentTarget, this.getDelegateOptions())
17290 $(e.currentTarget).data('bs.' + this.type, self)
17291 }
17292 }
17293
17294 self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
17295 }
17296
17297 Tooltip.prototype.destroy = function () {
17298 clearTimeout(this.timeout)
17299 this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
17300 }
17301
17302
17303 // TOOLTIP PLUGIN DEFINITION
17304 // =========================
17305
17306 function Plugin(option) {
17307 return this.each(function () {
17308 var $this = $(this)
17309 var data = $this.data('bs.tooltip')
17310 var options = typeof option == 'object' && option
17311
17312 if (!data && option == 'destroy') return
17313 if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
17314 if (typeof option == 'string') data[option]()
17315 })
17316 }
17317
17318 var old = $.fn.tooltip
17319
17320 $.fn.tooltip = Plugin
17321 $.fn.tooltip.Constructor = Tooltip
17322
17323
17324 // TOOLTIP NO CONFLICT
17325 // ===================
17326
17327 $.fn.tooltip.noConflict = function () {
17328 $.fn.tooltip = old
17329 return this
17330 }
17331
17332 }(jQuery);
17333
17334 /* ========================================================================
17335 * Bootstrap: popover.js v3.2.0
17336 * http://getbootstrap.com/javascript/#popovers
17337 * ========================================================================
17338 * Copyright 2011-2014 Twitter, Inc.
17339 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17340 * ======================================================================== */
17341
17342
17343 +function ($) {
17344 'use strict';
17345
17346 // POPOVER PUBLIC CLASS DEFINITION
17347 // ===============================
17348
17349 var Popover = function (element, options) {
17350 this.init('popover', element, options)
17351 }
17352
17353 if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
17354
17355 Popover.VERSION = '3.2.0'
17356
17357 Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
17358 placement: 'right',
17359 trigger: 'click',
17360 content: '',
17361 template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
17362 })
17363
17364
17365 // NOTE: POPOVER EXTENDS tooltip.js
17366 // ================================
17367
17368 Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
17369
17370 Popover.prototype.constructor = Popover
17371
17372 Popover.prototype.getDefaults = function () {
17373 return Popover.DEFAULTS
17374 }
17375
17376 Popover.prototype.setContent = function () {
17377 var $tip = this.tip()
17378 var title = this.getTitle()
17379 var content = this.getContent()
17380
17381 $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
17382 $tip.find('.popover-content').empty()[ // we use append for html objects to maintain js events
17383 this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
17384 ](content)
17385
17386 $tip.removeClass('fade top bottom left right in')
17387
17388 // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
17389 // this manually by checking the contents.
17390 if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
17391 }
17392
17393 Popover.prototype.hasContent = function () {
17394 return this.getTitle() || this.getContent()
17395 }
17396
17397 Popover.prototype.getContent = function () {
17398 var $e = this.$element
17399 var o = this.options
17400
17401 return $e.attr('data-content')
17402 || (typeof o.content == 'function' ?
17403 o.content.call($e[0]) :
17404 o.content)
17405 }
17406
17407 Popover.prototype.arrow = function () {
17408 return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
17409 }
17410
17411 Popover.prototype.tip = function () {
17412 if (!this.$tip) this.$tip = $(this.options.template)
17413 return this.$tip
17414 }
17415
17416
17417 // POPOVER PLUGIN DEFINITION
17418 // =========================
17419
17420 function Plugin(option) {
17421 return this.each(function () {
17422 var $this = $(this)
17423 var data = $this.data('bs.popover')
17424 var options = typeof option == 'object' && option
17425
17426 if (!data && option == 'destroy') return
17427 if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
17428 if (typeof option == 'string') data[option]()
17429 })
17430 }
17431
17432 var old = $.fn.popover
17433
17434 $.fn.popover = Plugin
17435 $.fn.popover.Constructor = Popover
17436
17437
17438 // POPOVER NO CONFLICT
17439 // ===================
17440
17441 $.fn.popover.noConflict = function () {
17442 $.fn.popover = old
17443 return this
17444 }
17445
17446 }(jQuery);
17447
17448 /* ========================================================================
17449 * Bootstrap: scrollspy.js v3.2.0
17450 * http://getbootstrap.com/javascript/#scrollspy
17451 * ========================================================================
17452 * Copyright 2011-2014 Twitter, Inc.
17453 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17454 * ======================================================================== */
17455
17456
17457 +function ($) {
17458 'use strict';
17459
17460 // SCROLLSPY CLASS DEFINITION
17461 // ==========================
17462
17463 function ScrollSpy(element, options) {
17464 var process = $.proxy(this.process, this)
17465
17466 this.$body = $('body')
17467 this.$scrollElement = $(element).is('body') ? $(window) : $(element)
17468 this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
17469 this.selector = (this.options.target || '') + ' .nav li > a'
17470 this.offsets = []
17471 this.targets = []
17472 this.activeTarget = null
17473 this.scrollHeight = 0
17474
17475 this.$scrollElement.on('scroll.bs.scrollspy', process)
17476 this.refresh()
17477 this.process()
17478 }
17479
17480 ScrollSpy.VERSION = '3.2.0'
17481
17482 ScrollSpy.DEFAULTS = {
17483 offset: 10
17484 }
17485
17486 ScrollSpy.prototype.getScrollHeight = function () {
17487 return this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight)
17488 }
17489
17490 ScrollSpy.prototype.refresh = function () {
17491 var offsetMethod = 'offset'
17492 var offsetBase = 0
17493
17494 if (!$.isWindow(this.$scrollElement[0])) {
17495 offsetMethod = 'position'
17496 offsetBase = this.$scrollElement.scrollTop()
17497 }
17498
17499 this.offsets = []
17500 this.targets = []
17501 this.scrollHeight = this.getScrollHeight()
17502
17503 var self = this
17504
17505 this.$body
17506 .find(this.selector)
17507 .map(function () {
17508 var $el = $(this)
17509 var href = $el.data('target') || $el.attr('href')
17510 var $href = /^#./.test(href) && $(href)
17511
17512 return ($href
17513 && $href.length
17514 && $href.is(':visible')
17515 && [[$href[offsetMethod]().top + offsetBase, href]]) || null
17516 })
17517 .sort(function (a, b) { return a[0] - b[0] })
17518 .each(function () {
17519 self.offsets.push(this[0])
17520 self.targets.push(this[1])
17521 })
17522 }
17523
17524 ScrollSpy.prototype.process = function () {
17525 var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
17526 var scrollHeight = this.getScrollHeight()
17527 var maxScroll = this.options.offset + scrollHeight - this.$scrollElement.height()
17528 var offsets = this.offsets
17529 var targets = this.targets
17530 var activeTarget = this.activeTarget
17531 var i
17532
17533 if (this.scrollHeight != scrollHeight) {
17534 this.refresh()
17535 }
17536
17537 if (scrollTop >= maxScroll) {
17538 return activeTarget != (i = targets[targets.length - 1]) && this.activate(i)
17539 }
17540
17541 if (activeTarget && scrollTop <= offsets[0]) {
17542 return activeTarget != (i = targets[0]) && this.activate(i)
17543 }
17544
17545 for (i = offsets.length; i--;) {
17546 activeTarget != targets[i]
17547 && scrollTop >= offsets[i]
17548 && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
17549 && this.activate(targets[i])
17550 }
17551 }
17552
17553 ScrollSpy.prototype.activate = function (target) {
17554 this.activeTarget = target
17555
17556 $(this.selector)
17557 .parentsUntil(this.options.target, '.active')
17558 .removeClass('active')
17559
17560 var selector = this.selector +
17561 '[data-target="' + target + '"],' +
17562 this.selector + '[href="' + target + '"]'
17563
17564 var active = $(selector)
17565 .parents('li')
17566 .addClass('active')
17567
17568 if (active.parent('.dropdown-menu').length) {
17569 active = active
17570 .closest('li.dropdown')
17571 .addClass('active')
17572 }
17573
17574 active.trigger('activate.bs.scrollspy')
17575 }
17576
17577
17578 // SCROLLSPY PLUGIN DEFINITION
17579 // ===========================
17580
17581 function Plugin(option) {
17582 return this.each(function () {
17583 var $this = $(this)
17584 var data = $this.data('bs.scrollspy')
17585 var options = typeof option == 'object' && option
17586
17587 if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
17588 if (typeof option == 'string') data[option]()
17589 })
17590 }
17591
17592 var old = $.fn.scrollspy
17593
17594 $.fn.scrollspy = Plugin
17595 $.fn.scrollspy.Constructor = ScrollSpy
17596
17597
17598 // SCROLLSPY NO CONFLICT
17599 // =====================
17600
17601 $.fn.scrollspy.noConflict = function () {
17602 $.fn.scrollspy = old
17603 return this
17604 }
17605
17606
17607 // SCROLLSPY DATA-API
17608 // ==================
17609
17610 $(window).on('load.bs.scrollspy.data-api', function () {
17611 $('[data-spy="scroll"]').each(function () {
17612 var $spy = $(this)
17613 Plugin.call($spy, $spy.data())
17614 })
17615 })
17616
17617 }(jQuery);
17618
17619 /* ========================================================================
17620 * Bootstrap: tab.js v3.2.0
17621 * http://getbootstrap.com/javascript/#tabs
17622 * ========================================================================
17623 * Copyright 2011-2014 Twitter, Inc.
17624 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17625 * ======================================================================== */
17626
17627
17628 +function ($) {
17629 'use strict';
17630
17631 // TAB CLASS DEFINITION
17632 // ====================
17633
17634 var Tab = function (element) {
17635 this.element = $(element)
17636 }
17637
17638 Tab.VERSION = '3.2.0'
17639
17640 Tab.prototype.show = function () {
17641 var $this = this.element
17642 var $ul = $this.closest('ul:not(.dropdown-menu)')
17643 var selector = $this.data('target')
17644
17645 if (!selector) {
17646 selector = $this.attr('href')
17647 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
17648 }
17649
17650 if ($this.parent('li').hasClass('active')) return
17651
17652 var previous = $ul.find('.active:last a')[0]
17653 var e = $.Event('show.bs.tab', {
17654 relatedTarget: previous
17655 })
17656
17657 $this.trigger(e)
17658
17659 if (e.isDefaultPrevented()) return
17660
17661 var $target = $(selector)
17662
17663 this.activate($this.closest('li'), $ul)
17664 this.activate($target, $target.parent(), function () {
17665 $this.trigger({
17666 type: 'shown.bs.tab',
17667 relatedTarget: previous
17668 })
17669 })
17670 }
17671
17672 Tab.prototype.activate = function (element, container, callback) {
17673 var $active = container.find('> .active')
17674 var transition = callback
17675 && $.support.transition
17676 && $active.hasClass('fade')
17677
17678 function next() {
17679 $active
17680 .removeClass('active')
17681 .find('> .dropdown-menu > .active')
17682 .removeClass('active')
17683
17684 element.addClass('active')
17685
17686 if (transition) {
17687 element[0].offsetWidth // reflow for transition
17688 element.addClass('in')
17689 } else {
17690 element.removeClass('fade')
17691 }
17692
17693 if (element.parent('.dropdown-menu')) {
17694 element.closest('li.dropdown').addClass('active')
17695 }
17696
17697 callback && callback()
17698 }
17699
17700 transition ?
17701 $active
17702 .one('bsTransitionEnd', next)
17703 .emulateTransitionEnd(150) :
17704 next()
17705
17706 $active.removeClass('in')
17707 }
17708
17709
17710 // TAB PLUGIN DEFINITION
17711 // =====================
17712
17713 function Plugin(option) {
17714 return this.each(function () {
17715 var $this = $(this)
17716 var data = $this.data('bs.tab')
17717
17718 if (!data) $this.data('bs.tab', (data = new Tab(this)))
17719 if (typeof option == 'string') data[option]()
17720 })
17721 }
17722
17723 var old = $.fn.tab
17724
17725 $.fn.tab = Plugin
17726 $.fn.tab.Constructor = Tab
17727
17728
17729 // TAB NO CONFLICT
17730 // ===============
17731
17732 $.fn.tab.noConflict = function () {
17733 $.fn.tab = old
17734 return this
17735 }
17736
17737
17738 // TAB DATA-API
17739 // ============
17740
17741 $(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
17742 e.preventDefault()
17743 Plugin.call($(this), 'show')
17744 })
17745
17746 }(jQuery);
17747
17748 /* ========================================================================
17749 * Bootstrap: affix.js v3.2.0
17750 * http://getbootstrap.com/javascript/#affix
17751 * ========================================================================
17752 * Copyright 2011-2014 Twitter, Inc.
17753 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17754 * ======================================================================== */
17755
17756
17757 +function ($) {
17758 'use strict';
17759
17760 // AFFIX CLASS DEFINITION
17761 // ======================
17762
17763 var Affix = function (element, options) {
17764 this.options = $.extend({}, Affix.DEFAULTS, options)
17765
17766 this.$target = $(this.options.target)
17767 .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
17768 .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))
17769
17770 this.$element = $(element)
17771 this.affixed =
17772 this.unpin =
17773 this.pinnedOffset = null
17774
17775 this.checkPosition()
17776 }
17777
17778 Affix.VERSION = '3.2.0'
17779
17780 Affix.RESET = 'affix affix-top affix-bottom'
17781
17782 Affix.DEFAULTS = {
17783 offset: 0,
17784 target: window
17785 }
17786
17787 Affix.prototype.getPinnedOffset = function () {
17788 if (this.pinnedOffset) return this.pinnedOffset
17789 this.$element.removeClass(Affix.RESET).addClass('affix')
17790 var scrollTop = this.$target.scrollTop()
17791 var position = this.$element.offset()
17792 return (this.pinnedOffset = position.top - scrollTop)
17793 }
17794
17795 Affix.prototype.checkPositionWithEventLoop = function () {
17796 setTimeout($.proxy(this.checkPosition, this), 1)
17797 }
17798
17799 Affix.prototype.checkPosition = function () {
17800 if (!this.$element.is(':visible')) return
17801
17802 var scrollHeight = $(document).height()
17803 var scrollTop = this.$target.scrollTop()
17804 var position = this.$element.offset()
17805 var offset = this.options.offset
17806 var offsetTop = offset.top
17807 var offsetBottom = offset.bottom
17808
17809 if (typeof offset != 'object') offsetBottom = offsetTop = offset
17810 if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element)
17811 if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element)
17812
17813 var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false :
17814 offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' :
17815 offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false
17816
17817 if (this.affixed === affix) return
17818 if (this.unpin != null) this.$element.css('top', '')
17819
17820 var affixType = 'affix' + (affix ? '-' + affix : '')
17821 var e = $.Event(affixType + '.bs.affix')
17822
17823 this.$element.trigger(e)
17824
17825 if (e.isDefaultPrevented()) return
17826
17827 this.affixed = affix
17828 this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null
17829
17830 this.$element
17831 .removeClass(Affix.RESET)
17832 .addClass(affixType)
17833 .trigger($.Event(affixType.replace('affix', 'affixed')))
17834
17835 if (affix == 'bottom') {
17836 this.$element.offset({
17837 top: scrollHeight - this.$element.height() - offsetBottom
17838 })
17839 }
17840 }
17841
17842
17843 // AFFIX PLUGIN DEFINITION
17844 // =======================
17845
17846 function Plugin(option) {
17847 return this.each(function () {
17848 var $this = $(this)
17849 var data = $this.data('bs.affix')
17850 var options = typeof option == 'object' && option
17851
17852 if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
17853 if (typeof option == 'string') data[option]()
17854 })
17855 }
17856
17857 var old = $.fn.affix
17858
17859 $.fn.affix = Plugin
17860 $.fn.affix.Constructor = Affix
17861
17862
17863 // AFFIX NO CONFLICT
17864 // =================
17865
17866 $.fn.affix.noConflict = function () {
17867 $.fn.affix = old
17868 return this
17869 }
17870
17871
17872 // AFFIX DATA-API
17873 // ==============
17874
17875 $(window).on('load', function () {
17876 $('[data-spy="affix"]').each(function () {
17877 var $spy = $(this)
17878 var data = $spy.data()
17879
17880 data.offset = data.offset || {}
17881
17882 if (data.offsetBottom) data.offset.bottom = data.offsetBottom
17883 if (data.offsetTop) data.offset.top = data.offsetTop
17884
17885 Plugin.call($spy, data)
17886 })
17887 })
17888
17889 }(jQuery);
17890 </script>
17891 <script>
17892 (function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Bitcoin=e()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
17893 var assert = _dereq_('assert')
17894
17895 module.exports = BigInteger
17896
17897 // JavaScript engine analysis
17898 var canary = 0xdeadbeefcafe;
17899 var j_lm = ((canary&0xffffff)==0xefcafe);
17900
17901 // (public) Constructor
17902 function BigInteger(a,b,c) {
17903 if (!(this instanceof BigInteger)) {
17904 return new BigInteger(a, b, c);
17905 }
17906
17907 if(a != null) {
17908 if("number" == typeof a) this.fromNumber(a,b,c);
17909 else if(b == null && "string" != typeof a) this.fromString(a,256);
17910 else this.fromString(a,b);
17911 }
17912 }
17913
17914 var proto = BigInteger.prototype;
17915
17916 // return new, unset BigInteger
17917 function nbi() { return new BigInteger(null); }
17918
17919 // Bits per digit
17920 var dbits;
17921
17922 // am: Compute w_j += (x*this_i), propagate carries,
17923 // c is initial carry, returns final carry.
17924 // c < 3*dvalue, x < 2*dvalue, this_i < dvalue
17925 // We need to select the fastest one that works in this environment.
17926
17927 // am1: use a single mult and divide to get the high bits,
17928 // max digit bits should be 26 because
17929 // max internal value = 2*dvalue^2-2*dvalue (< 2^53)
17930 function am1(i,x,w,j,c,n) {
17931 while(--n >= 0) {
17932 var v = x*this[i++]+w[j]+c;
17933 c = Math.floor(v/0x4000000);
17934 w[j++] = v&0x3ffffff;
17935 }
17936 return c;
17937 }
17938 // am2 avoids a big mult-and-extract completely.
17939 // Max digit bits should be <= 30 because we do bitwise ops
17940 // on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
17941 function am2(i,x,w,j,c,n) {
17942 var xl = x&0x7fff, xh = x>>15;
17943 while(--n >= 0) {
17944 var l = this[i]&0x7fff;
17945 var h = this[i++]>>15;
17946 var m = xh*l+h*xl;
17947 l = xl*l+((m&0x7fff)<<15)+w[j]+(c&0x3fffffff);
17948 c = (l>>>30)+(m>>>15)+xh*h+(c>>>30);
17949 w[j++] = l&0x3fffffff;
17950 }
17951 return c;
17952 }
17953 // Alternately, set max digit bits to 28 since some
17954 // browsers slow down when dealing with 32-bit numbers.
17955 function am3(i,x,w,j,c,n) {
17956 var xl = x&0x3fff, xh = x>>14;
17957 while(--n >= 0) {
17958 var l = this[i]&0x3fff;
17959 var h = this[i++]>>14;
17960 var m = xh*l+h*xl;
17961 l = xl*l+((m&0x3fff)<<14)+w[j]+c;
17962 c = (l>>28)+(m>>14)+xh*h;
17963 w[j++] = l&0xfffffff;
17964 }
17965 return c;
17966 }
17967
17968 // wtf?
17969 BigInteger.prototype.am = am1;
17970 dbits = 26;
17971
17972 /*
17973 if(j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
17974 BigInteger.prototype.am = am2;
17975 dbits = 30;
17976 }
17977 else if(j_lm && (navigator.appName != "Netscape")) {
17978 BigInteger.prototype.am = am1;
17979 dbits = 26;
17980 }
17981 else { // Mozilla/Netscape seems to prefer am3
17982 BigInteger.prototype.am = am3;
17983 dbits = 28;
17984 }
17985 */
17986
17987 BigInteger.prototype.DB = dbits;
17988 BigInteger.prototype.DM = ((1<<dbits)-1);
17989 var DV = BigInteger.prototype.DV = (1<<dbits);
17990
17991 var BI_FP = 52;
17992 BigInteger.prototype.FV = Math.pow(2,BI_FP);
17993 BigInteger.prototype.F1 = BI_FP-dbits;
17994 BigInteger.prototype.F2 = 2*dbits-BI_FP;
17995
17996 // Digit conversions
17997 var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
17998 var BI_RC = new Array();
17999 var rr,vv;
18000 rr = "0".charCodeAt(0);
18001 for(vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
18002 rr = "a".charCodeAt(0);
18003 for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
18004 rr = "A".charCodeAt(0);
18005 for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
18006
18007 function int2char(n) { return BI_RM.charAt(n); }
18008 function intAt(s,i) {
18009 var c = BI_RC[s.charCodeAt(i)];
18010 return (c==null)?-1:c;
18011 }
18012
18013 // (protected) copy this to r
18014 function bnpCopyTo(r) {
18015 for(var i = this.t-1; i >= 0; --i) r[i] = this[i];
18016 r.t = this.t;
18017 r.s = this.s;
18018 }
18019
18020 // (protected) set from integer value x, -DV <= x < DV
18021 function bnpFromInt(x) {
18022 this.t = 1;
18023 this.s = (x<0)?-1:0;
18024 if(x > 0) this[0] = x;
18025 else if(x < -1) this[0] = x+DV;
18026 else this.t = 0;
18027 }
18028
18029 // return bigint initialized to value
18030 function nbv(i) { var r = nbi(); r.fromInt(i); return r; }
18031
18032 // (protected) set from string and radix
18033 function bnpFromString(s,b) {
18034 var self = this;
18035
18036 var k;
18037 if(b == 16) k = 4;
18038 else if(b == 8) k = 3;
18039 else if(b == 256) k = 8; // byte array
18040 else if(b == 2) k = 1;
18041 else if(b == 32) k = 5;
18042 else if(b == 4) k = 2;
18043 else { self.fromRadix(s,b); return; }
18044 self.t = 0;
18045 self.s = 0;
18046 var i = s.length, mi = false, sh = 0;
18047 while(--i >= 0) {
18048 var x = (k==8)?s[i]&0xff:intAt(s,i);
18049 if(x < 0) {
18050 if(s.charAt(i) == "-") mi = true;
18051 continue;
18052 }
18053 mi = false;
18054 if(sh == 0)
18055 self[self.t++] = x;
18056 else if(sh+k > self.DB) {
18057 self[self.t-1] |= (x&((1<<(self.DB-sh))-1))<<sh;
18058 self[self.t++] = (x>>(self.DB-sh));
18059 }
18060 else
18061 self[self.t-1] |= x<<sh;
18062 sh += k;
18063 if(sh >= self.DB) sh -= self.DB;
18064 }
18065 if(k == 8 && (s[0]&0x80) != 0) {
18066 self.s = -1;
18067 if(sh > 0) self[self.t-1] |= ((1<<(self.DB-sh))-1)<<sh;
18068 }
18069 self.clamp();
18070 if(mi) BigInteger.ZERO.subTo(self,self);
18071 }
18072
18073 // (protected) clamp off excess high words
18074 function bnpClamp() {
18075 var c = this.s&this.DM;
18076 while(this.t > 0 && this[this.t-1] == c) --this.t;
18077 }
18078
18079 // (public) return string representation in given radix
18080 function bnToString(b) {
18081 var self = this;
18082 if(self.s < 0) return "-"+self.negate().toString(b);
18083 var k;
18084 if(b == 16) k = 4;
18085 else if(b == 8) k = 3;
18086 else if(b == 2) k = 1;
18087 else if(b == 32) k = 5;
18088 else if(b == 4) k = 2;
18089 else return self.toRadix(b);
18090 var km = (1<<k)-1, d, m = false, r = "", i = self.t;
18091 var p = self.DB-(i*self.DB)%k;
18092 if(i-- > 0) {
18093 if(p < self.DB && (d = self[i]>>p) > 0) { m = true; r = int2char(d); }
18094 while(i >= 0) {
18095 if(p < k) {
18096 d = (self[i]&((1<<p)-1))<<(k-p);
18097 d |= self[--i]>>(p+=self.DB-k);
18098 }
18099 else {
18100 d = (self[i]>>(p-=k))&km;
18101 if(p <= 0) { p += self.DB; --i; }
18102 }
18103 if(d > 0) m = true;
18104 if(m) r += int2char(d);
18105 }
18106 }
18107 return m?r:"0";
18108 }
18109
18110 // (public) -this
18111 function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; }
18112
18113 // (public) |this|
18114 function bnAbs() { return (this.s<0)?this.negate():this; }
18115
18116 // (public) return + if this > a, - if this < a, 0 if equal
18117 function bnCompareTo(a) {
18118 var r = this.s-a.s;
18119 if(r != 0) return r;
18120 var i = this.t;
18121 r = i-a.t;
18122 if(r != 0) return (this.s<0)?-r:r;
18123 while(--i >= 0) if((r=this[i]-a[i]) != 0) return r;
18124 return 0;
18125 }
18126
18127 // returns bit length of the integer x
18128 function nbits(x) {
18129 var r = 1, t;
18130 if((t=x>>>16) != 0) { x = t; r += 16; }
18131 if((t=x>>8) != 0) { x = t; r += 8; }
18132 if((t=x>>4) != 0) { x = t; r += 4; }
18133 if((t=x>>2) != 0) { x = t; r += 2; }
18134 if((t=x>>1) != 0) { x = t; r += 1; }
18135 return r;
18136 }
18137
18138 // (public) return the number of bits in "this"
18139 function bnBitLength() {
18140 if(this.t <= 0) return 0;
18141 return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM));
18142 }
18143
18144 // (protected) r = this << n*DB
18145 function bnpDLShiftTo(n,r) {
18146 var i;
18147 for(i = this.t-1; i >= 0; --i) r[i+n] = this[i];
18148 for(i = n-1; i >= 0; --i) r[i] = 0;
18149 r.t = this.t+n;
18150 r.s = this.s;
18151 }
18152
18153 // (protected) r = this >> n*DB
18154 function bnpDRShiftTo(n,r) {
18155 for(var i = n; i < this.t; ++i) r[i-n] = this[i];
18156 r.t = Math.max(this.t-n,0);
18157 r.s = this.s;
18158 }
18159
18160 // (protected) r = this << n
18161 function bnpLShiftTo(n,r) {
18162 var self = this;
18163 var bs = n%self.DB;
18164 var cbs = self.DB-bs;
18165 var bm = (1<<cbs)-1;
18166 var ds = Math.floor(n/self.DB), c = (self.s<<bs)&self.DM, i;
18167 for(i = self.t-1; i >= 0; --i) {
18168 r[i+ds+1] = (self[i]>>cbs)|c;
18169 c = (self[i]&bm)<<bs;
18170 }
18171 for(i = ds-1; i >= 0; --i) r[i] = 0;
18172 r[ds] = c;
18173 r.t = self.t+ds+1;
18174 r.s = self.s;
18175 r.clamp();
18176 }
18177
18178 // (protected) r = this >> n
18179 function bnpRShiftTo(n,r) {
18180 var self = this;
18181 r.s = self.s;
18182 var ds = Math.floor(n/self.DB);
18183 if(ds >= self.t) { r.t = 0; return; }
18184 var bs = n%self.DB;
18185 var cbs = self.DB-bs;
18186 var bm = (1<<bs)-1;
18187 r[0] = self[ds]>>bs;
18188 for(var i = ds+1; i < self.t; ++i) {
18189 r[i-ds-1] |= (self[i]&bm)<<cbs;
18190 r[i-ds] = self[i]>>bs;
18191 }
18192 if(bs > 0) r[self.t-ds-1] |= (self.s&bm)<<cbs;
18193 r.t = self.t-ds;
18194 r.clamp();
18195 }
18196
18197 // (protected) r = this - a
18198 function bnpSubTo(a,r) {
18199 var self = this;
18200 var i = 0, c = 0, m = Math.min(a.t,self.t);
18201 while(i < m) {
18202 c += self[i]-a[i];
18203 r[i++] = c&self.DM;
18204 c >>= self.DB;
18205 }
18206 if(a.t < self.t) {
18207 c -= a.s;
18208 while(i < self.t) {
18209 c += self[i];
18210 r[i++] = c&self.DM;
18211 c >>= self.DB;
18212 }
18213 c += self.s;
18214 }
18215 else {
18216 c += self.s;
18217 while(i < a.t) {
18218 c -= a[i];
18219 r[i++] = c&self.DM;
18220 c >>= self.DB;
18221 }
18222 c -= a.s;
18223 }
18224 r.s = (c<0)?-1:0;
18225 if(c < -1) r[i++] = self.DV+c;
18226 else if(c > 0) r[i++] = c;
18227 r.t = i;
18228 r.clamp();
18229 }
18230
18231 // (protected) r = this * a, r != this,a (HAC 14.12)
18232 // "this" should be the larger one if appropriate.
18233 function bnpMultiplyTo(a,r) {
18234 var x = this.abs(), y = a.abs();
18235 var i = x.t;
18236 r.t = i+y.t;
18237 while(--i >= 0) r[i] = 0;
18238 for(i = 0; i < y.t; ++i) r[i+x.t] = x.am(0,y[i],r,i,0,x.t);
18239 r.s = 0;
18240 r.clamp();
18241 if(this.s != a.s) BigInteger.ZERO.subTo(r,r);
18242 }
18243
18244 // (protected) r = this^2, r != this (HAC 14.16)
18245 function bnpSquareTo(r) {
18246 var x = this.abs();
18247 var i = r.t = 2*x.t;
18248 while(--i >= 0) r[i] = 0;
18249 for(i = 0; i < x.t-1; ++i) {
18250 var c = x.am(i,x[i],r,2*i,0,1);
18251 if((r[i+x.t]+=x.am(i+1,2*x[i],r,2*i+1,c,x.t-i-1)) >= x.DV) {
18252 r[i+x.t] -= x.DV;
18253 r[i+x.t+1] = 1;
18254 }
18255 }
18256 if(r.t > 0) r[r.t-1] += x.am(i,x[i],r,2*i,0,1);
18257 r.s = 0;
18258 r.clamp();
18259 }
18260
18261 // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
18262 // r != q, this != m. q or r may be null.
18263 function bnpDivRemTo(m,q,r) {
18264 var self = this;
18265 var pm = m.abs();
18266 if(pm.t <= 0) return;
18267 var pt = self.abs();
18268 if(pt.t < pm.t) {
18269 if(q != null) q.fromInt(0);
18270 if(r != null) self.copyTo(r);
18271 return;
18272 }
18273 if(r == null) r = nbi();
18274 var y = nbi(), ts = self.s, ms = m.s;
18275 var nsh = self.DB-nbits(pm[pm.t-1]); // normalize modulus
18276 if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); }
18277 else { pm.copyTo(y); pt.copyTo(r); }
18278 var ys = y.t;
18279 var y0 = y[ys-1];
18280 if(y0 == 0) return;
18281 var yt = y0*(1<<self.F1)+((ys>1)?y[ys-2]>>self.F2:0);
18282 var d1 = self.FV/yt, d2 = (1<<self.F1)/yt, e = 1<<self.F2;
18283 var i = r.t, j = i-ys, t = (q==null)?nbi():q;
18284 y.dlShiftTo(j,t);
18285 if(r.compareTo(t) >= 0) {
18286 r[r.t++] = 1;
18287 r.subTo(t,r);
18288 }
18289 BigInteger.ONE.dlShiftTo(ys,t);
18290 t.subTo(y,y); // "negative" y so we can replace sub with am later
18291 while(y.t < ys) y[y.t++] = 0;
18292 while(--j >= 0) {
18293 // Estimate quotient digit
18294 var qd = (r[--i]==y0)?self.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2);
18295 if((r[i]+=y.am(0,qd,r,j,0,ys)) < qd) { // Try it out
18296 y.dlShiftTo(j,t);
18297 r.subTo(t,r);
18298 while(r[i] < --qd) r.subTo(t,r);
18299 }
18300 }
18301 if(q != null) {
18302 r.drShiftTo(ys,q);
18303 if(ts != ms) BigInteger.ZERO.subTo(q,q);
18304 }
18305 r.t = ys;
18306 r.clamp();
18307 if(nsh > 0) r.rShiftTo(nsh,r); // Denormalize remainder
18308 if(ts < 0) BigInteger.ZERO.subTo(r,r);
18309 }
18310
18311 // (public) this mod a
18312 function bnMod(a) {
18313 var r = nbi();
18314 this.abs().divRemTo(a,null,r);
18315 if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r);
18316 return r;
18317 }
18318
18319 // Modular reduction using "classic" algorithm
18320 function Classic(m) { this.m = m; }
18321 function cConvert(x) {
18322 if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);
18323 else return x;
18324 }
18325 function cRevert(x) { return x; }
18326 function cReduce(x) { x.divRemTo(this.m,null,x); }
18327 function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
18328 function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
18329
18330 Classic.prototype.convert = cConvert;
18331 Classic.prototype.revert = cRevert;
18332 Classic.prototype.reduce = cReduce;
18333 Classic.prototype.mulTo = cMulTo;
18334 Classic.prototype.sqrTo = cSqrTo;
18335
18336 // (protected) return "-1/this % 2^DB"; useful for Mont. reduction
18337 // justification:
18338 // xy == 1 (mod m)
18339 // xy = 1+km
18340 // xy(2-xy) = (1+km)(1-km)
18341 // x[y(2-xy)] = 1-k^2m^2
18342 // x[y(2-xy)] == 1 (mod m^2)
18343 // if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
18344 // should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
18345 // JS multiply "overflows" differently from C/C++, so care is needed here.
18346 function bnpInvDigit() {
18347 if(this.t < 1) return 0;
18348 var x = this[0];
18349 if((x&1) == 0) return 0;
18350 var y = x&3; // y == 1/x mod 2^2
18351 y = (y*(2-(x&0xf)*y))&0xf; // y == 1/x mod 2^4
18352 y = (y*(2-(x&0xff)*y))&0xff; // y == 1/x mod 2^8
18353 y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff; // y == 1/x mod 2^16
18354 // last step - calculate inverse mod DV directly;
18355 // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
18356 y = (y*(2-x*y%this.DV))%this.DV; // y == 1/x mod 2^dbits
18357 // we really want the negative inverse, and -DV < y < DV
18358 return (y>0)?this.DV-y:-y;
18359 }
18360
18361 // Montgomery reduction
18362 function Montgomery(m) {
18363 this.m = m;
18364 this.mp = m.invDigit();
18365 this.mpl = this.mp&0x7fff;
18366 this.mph = this.mp>>15;
18367 this.um = (1<<(m.DB-15))-1;
18368 this.mt2 = 2*m.t;
18369 }
18370
18371 // xR mod m
18372 function montConvert(x) {
18373 var r = nbi();
18374 x.abs().dlShiftTo(this.m.t,r);
18375 r.divRemTo(this.m,null,r);
18376 if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r);
18377 return r;
18378 }
18379
18380 // x/R mod m
18381 function montRevert(x) {
18382 var r = nbi();
18383 x.copyTo(r);
18384 this.reduce(r);
18385 return r;
18386 }
18387
18388 // x = x/R mod m (HAC 14.32)
18389 function montReduce(x) {
18390 while(x.t <= this.mt2) // pad x so am has enough room later
18391 x[x.t++] = 0;
18392 for(var i = 0; i < this.m.t; ++i) {
18393 // faster way of calculating u0 = x[i]*mp mod DV
18394 var j = x[i]&0x7fff;
18395 var u0 = (j*this.mpl+(((j*this.mph+(x[i]>>15)*this.mpl)&this.um)<<15))&x.DM;
18396 // use am to combine the multiply-shift-add into one call
18397 j = i+this.m.t;
18398 x[j] += this.m.am(0,u0,x,i,0,this.m.t);
18399 // propagate carry
18400 while(x[j] >= x.DV) { x[j] -= x.DV; x[++j]++; }
18401 }
18402 x.clamp();
18403 x.drShiftTo(this.m.t,x);
18404 if(x.compareTo(this.m) >= 0) x.subTo(this.m,x);
18405 }
18406
18407 // r = "x^2/R mod m"; x != r
18408 function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
18409
18410 // r = "xy/R mod m"; x,y != r
18411 function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
18412
18413 Montgomery.prototype.convert = montConvert;
18414 Montgomery.prototype.revert = montRevert;
18415 Montgomery.prototype.reduce = montReduce;
18416 Montgomery.prototype.mulTo = montMulTo;
18417 Montgomery.prototype.sqrTo = montSqrTo;
18418
18419 // (protected) true iff this is even
18420 function bnpIsEven() { return ((this.t>0)?(this[0]&1):this.s) == 0; }
18421
18422 // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
18423 function bnpExp(e,z) {
18424 if(e > 0xffffffff || e < 1) return BigInteger.ONE;
18425 var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1;
18426 g.copyTo(r);
18427 while(--i >= 0) {
18428 z.sqrTo(r,r2);
18429 if((e&(1<<i)) > 0) z.mulTo(r2,g,r);
18430 else { var t = r; r = r2; r2 = t; }
18431 }
18432 return z.revert(r);
18433 }
18434
18435 // (public) this^e % m, 0 <= e < 2^32
18436 function bnModPowInt(e,m) {
18437 var z;
18438 if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
18439 return this.exp(e,z);
18440 }
18441
18442 // protected
18443 proto.copyTo = bnpCopyTo;
18444 proto.fromInt = bnpFromInt;
18445 proto.fromString = bnpFromString;
18446 proto.clamp = bnpClamp;
18447 proto.dlShiftTo = bnpDLShiftTo;
18448 proto.drShiftTo = bnpDRShiftTo;
18449 proto.lShiftTo = bnpLShiftTo;
18450 proto.rShiftTo = bnpRShiftTo;
18451 proto.subTo = bnpSubTo;
18452 proto.multiplyTo = bnpMultiplyTo;
18453 proto.squareTo = bnpSquareTo;
18454 proto.divRemTo = bnpDivRemTo;
18455 proto.invDigit = bnpInvDigit;
18456 proto.isEven = bnpIsEven;
18457 proto.exp = bnpExp;
18458
18459 // public
18460 proto.toString = bnToString;
18461 proto.negate = bnNegate;
18462 proto.abs = bnAbs;
18463 proto.compareTo = bnCompareTo;
18464 proto.bitLength = bnBitLength;
18465 proto.mod = bnMod;
18466 proto.modPowInt = bnModPowInt;
18467
18468 //// jsbn2
18469
18470 function nbi() { return new BigInteger(null); }
18471
18472 // (public)
18473 function bnClone() { var r = nbi(); this.copyTo(r); return r; }
18474
18475 // (public) return value as integer
18476 function bnIntValue() {
18477 if(this.s < 0) {
18478 if(this.t == 1) return this[0]-this.DV;
18479 else if(this.t == 0) return -1;
18480 }
18481 else if(this.t == 1) return this[0];
18482 else if(this.t == 0) return 0;
18483 // assumes 16 < DB < 32
18484 return ((this[1]&((1<<(32-this.DB))-1))<<this.DB)|this[0];
18485 }
18486
18487 // (public) return value as byte
18488 function bnByteValue() { return (this.t==0)?this.s:(this[0]<<24)>>24; }
18489
18490 // (public) return value as short (assumes DB>=16)
18491 function bnShortValue() { return (this.t==0)?this.s:(this[0]<<16)>>16; }
18492
18493 // (protected) return x s.t. r^x < DV
18494 function bnpChunkSize(r) { return Math.floor(Math.LN2*this.DB/Math.log(r)); }
18495
18496 // (public) 0 if this == 0, 1 if this > 0
18497 function bnSigNum() {
18498 if(this.s < 0) return -1;
18499 else if(this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0;
18500 else return 1;
18501 }
18502
18503 // (protected) convert to radix string
18504 function bnpToRadix(b) {
18505 if(b == null) b = 10;
18506 if(this.signum() == 0 || b < 2 || b > 36) return "0";
18507 var cs = this.chunkSize(b);
18508 var a = Math.pow(b,cs);
18509 var d = nbv(a), y = nbi(), z = nbi(), r = "";
18510 this.divRemTo(d,y,z);
18511 while(y.signum() > 0) {
18512 r = (a+z.intValue()).toString(b).substr(1) + r;
18513 y.divRemTo(d,y,z);
18514 }
18515 return z.intValue().toString(b) + r;
18516 }
18517
18518 // (protected) convert from radix string
18519 function bnpFromRadix(s,b) {
18520 var self = this;
18521 self.fromInt(0);
18522 if(b == null) b = 10;
18523 var cs = self.chunkSize(b);
18524 var d = Math.pow(b,cs), mi = false, j = 0, w = 0;
18525 for(var i = 0; i < s.length; ++i) {
18526 var x = intAt(s,i);
18527 if(x < 0) {
18528 if(s.charAt(i) == "-" && self.signum() == 0) mi = true;
18529 continue;
18530 }
18531 w = b*w+x;
18532 if(++j >= cs) {
18533 self.dMultiply(d);
18534 self.dAddOffset(w,0);
18535 j = 0;
18536 w = 0;
18537 }
18538 }
18539 if(j > 0) {
18540 self.dMultiply(Math.pow(b,j));
18541 self.dAddOffset(w,0);
18542 }
18543 if(mi) BigInteger.ZERO.subTo(self,self);
18544 }
18545
18546 // (protected) alternate constructor
18547 function bnpFromNumber(a,b,c) {
18548 var self = this;
18549 if("number" == typeof b) {
18550 // new BigInteger(int,int,RNG)
18551 if(a < 2) self.fromInt(1);
18552 else {
18553 self.fromNumber(a,c);
18554 if(!self.testBit(a-1)) // force MSB set
18555 self.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,self);
18556 if(self.isEven()) self.dAddOffset(1,0); // force odd
18557 while(!self.isProbablePrime(b)) {
18558 self.dAddOffset(2,0);
18559 if(self.bitLength() > a) self.subTo(BigInteger.ONE.shiftLeft(a-1),self);
18560 }
18561 }
18562 }
18563 else {
18564 // new BigInteger(int,RNG)
18565 var x = new Array(), t = a&7;
18566 x.length = (a>>3)+1;
18567 b.nextBytes(x);
18568 if(t > 0) x[0] &= ((1<<t)-1); else x[0] = 0;
18569 self.fromString(x,256);
18570 }
18571 }
18572
18573 // (public) convert to bigendian byte array
18574 function bnToByteArray() {
18575 var self = this;
18576 var i = self.t, r = new Array();
18577 r[0] = self.s;
18578 var p = self.DB-(i*self.DB)%8, d, k = 0;
18579 if(i-- > 0) {
18580 if(p < self.DB && (d = self[i]>>p) != (self.s&self.DM)>>p)
18581 r[k++] = d|(self.s<<(self.DB-p));
18582 while(i >= 0) {
18583 if(p < 8) {
18584 d = (self[i]&((1<<p)-1))<<(8-p);
18585 d |= self[--i]>>(p+=self.DB-8);
18586 }
18587 else {
18588 d = (self[i]>>(p-=8))&0xff;
18589 if(p <= 0) { p += self.DB; --i; }
18590 }
18591 if((d&0x80) != 0) d |= -256;
18592 if(k === 0 && (self.s&0x80) != (d&0x80)) ++k;
18593 if(k > 0 || d != self.s) r[k++] = d;
18594 }
18595 }
18596 return r;
18597 }
18598
18599 function bnEquals(a) { return(this.compareTo(a)==0); }
18600 function bnMin(a) { return(this.compareTo(a)<0)?this:a; }
18601 function bnMax(a) { return(this.compareTo(a)>0)?this:a; }
18602
18603 // (protected) r = this op a (bitwise)
18604 function bnpBitwiseTo(a,op,r) {
18605 var self = this;
18606 var i, f, m = Math.min(a.t,self.t);
18607 for(i = 0; i < m; ++i) r[i] = op(self[i],a[i]);
18608 if(a.t < self.t) {
18609 f = a.s&self.DM;
18610 for(i = m; i < self.t; ++i) r[i] = op(self[i],f);
18611 r.t = self.t;
18612 }
18613 else {
18614 f = self.s&self.DM;
18615 for(i = m; i < a.t; ++i) r[i] = op(f,a[i]);
18616 r.t = a.t;
18617 }
18618 r.s = op(self.s,a.s);
18619 r.clamp();
18620 }
18621
18622 // (public) this & a
18623 function op_and(x,y) { return x&y; }
18624 function bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; }
18625
18626 // (public) this | a
18627 function op_or(x,y) { return x|y; }
18628 function bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; }
18629
18630 // (public) this ^ a
18631 function op_xor(x,y) { return x^y; }
18632 function bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; }
18633
18634 // (public) this & ~a
18635 function op_andnot(x,y) { return x&~y; }
18636 function bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; }
18637
18638 // (public) ~this
18639 function bnNot() {
18640 var r = nbi();
18641 for(var i = 0; i < this.t; ++i) r[i] = this.DM&~this[i];
18642 r.t = this.t;
18643 r.s = ~this.s;
18644 return r;
18645 }
18646
18647 // (public) this << n
18648 function bnShiftLeft(n) {
18649 var r = nbi();
18650 if(n < 0) this.rShiftTo(-n,r); else this.lShiftTo(n,r);
18651 return r;
18652 }
18653
18654 // (public) this >> n
18655 function bnShiftRight(n) {
18656 var r = nbi();
18657 if(n < 0) this.lShiftTo(-n,r); else this.rShiftTo(n,r);
18658 return r;
18659 }
18660
18661 // return index of lowest 1-bit in x, x < 2^31
18662 function lbit(x) {
18663 if(x == 0) return -1;
18664 var r = 0;
18665 if((x&0xffff) == 0) { x >>= 16; r += 16; }
18666 if((x&0xff) == 0) { x >>= 8; r += 8; }
18667 if((x&0xf) == 0) { x >>= 4; r += 4; }
18668 if((x&3) == 0) { x >>= 2; r += 2; }
18669 if((x&1) == 0) ++r;
18670 return r;
18671 }
18672
18673 // (public) returns index of lowest 1-bit (or -1 if none)
18674 function bnGetLowestSetBit() {
18675 for(var i = 0; i < this.t; ++i)
18676 if(this[i] != 0) return i*this.DB+lbit(this[i]);
18677 if(this.s < 0) return this.t*this.DB;
18678 return -1;
18679 }
18680
18681 // return number of 1 bits in x
18682 function cbit(x) {
18683 var r = 0;
18684 while(x != 0) { x &= x-1; ++r; }
18685 return r;
18686 }
18687
18688 // (public) return number of set bits
18689 function bnBitCount() {
18690 var r = 0, x = this.s&this.DM;
18691 for(var i = 0; i < this.t; ++i) r += cbit(this[i]^x);
18692 return r;
18693 }
18694
18695 // (public) true iff nth bit is set
18696 function bnTestBit(n) {
18697 var j = Math.floor(n/this.DB);
18698 if(j >= this.t) return(this.s!=0);
18699 return((this[j]&(1<<(n%this.DB)))!=0);
18700 }
18701
18702 // (protected) this op (1<<n)
18703 function bnpChangeBit(n,op) {
18704 var r = BigInteger.ONE.shiftLeft(n);
18705 this.bitwiseTo(r,op,r);
18706 return r;
18707 }
18708
18709 // (public) this | (1<<n)
18710 function bnSetBit(n) { return this.changeBit(n,op_or); }
18711
18712 // (public) this & ~(1<<n)
18713 function bnClearBit(n) { return this.changeBit(n,op_andnot); }
18714
18715 // (public) this ^ (1<<n)
18716 function bnFlipBit(n) { return this.changeBit(n,op_xor); }
18717
18718 // (protected) r = this + a
18719 function bnpAddTo(a,r) {
18720 var self = this;
18721
18722 var i = 0, c = 0, m = Math.min(a.t,self.t);
18723 while(i < m) {
18724 c += self[i]+a[i];
18725 r[i++] = c&self.DM;
18726 c >>= self.DB;
18727 }
18728 if(a.t < self.t) {
18729 c += a.s;
18730 while(i < self.t) {
18731 c += self[i];
18732 r[i++] = c&self.DM;
18733 c >>= self.DB;
18734 }
18735 c += self.s;
18736 }
18737 else {
18738 c += self.s;
18739 while(i < a.t) {
18740 c += a[i];
18741 r[i++] = c&self.DM;
18742 c >>= self.DB;
18743 }
18744 c += a.s;
18745 }
18746 r.s = (c<0)?-1:0;
18747 if(c > 0) r[i++] = c;
18748 else if(c < -1) r[i++] = self.DV+c;
18749 r.t = i;
18750 r.clamp();
18751 }
18752
18753 // (public) this + a
18754 function bnAdd(a) { var r = nbi(); this.addTo(a,r); return r; }
18755
18756 // (public) this - a
18757 function bnSubtract(a) { var r = nbi(); this.subTo(a,r); return r; }
18758
18759 // (public) this * a
18760 function bnMultiply(a) { var r = nbi(); this.multiplyTo(a,r); return r; }
18761
18762 // (public) this^2
18763 function bnSquare() { var r = nbi(); this.squareTo(r); return r; }
18764
18765 // (public) this / a
18766 function bnDivide(a) { var r = nbi(); this.divRemTo(a,r,null); return r; }
18767
18768 // (public) this % a
18769 function bnRemainder(a) { var r = nbi(); this.divRemTo(a,null,r); return r; }
18770
18771 // (public) [this/a,this%a]
18772 function bnDivideAndRemainder(a) {
18773 var q = nbi(), r = nbi();
18774 this.divRemTo(a,q,r);
18775 return new Array(q,r);
18776 }
18777
18778 // (protected) this *= n, this >= 0, 1 < n < DV
18779 function bnpDMultiply(n) {
18780 this[this.t] = this.am(0,n-1,this,0,0,this.t);
18781 ++this.t;
18782 this.clamp();
18783 }
18784
18785 // (protected) this += n << w words, this >= 0
18786 function bnpDAddOffset(n,w) {
18787 if(n == 0) return;
18788 while(this.t <= w) this[this.t++] = 0;
18789 this[w] += n;
18790 while(this[w] >= this.DV) {
18791 this[w] -= this.DV;
18792 if(++w >= this.t) this[this.t++] = 0;
18793 ++this[w];
18794 }
18795 }
18796
18797 // A "null" reducer
18798 function NullExp() {}
18799 function nNop(x) { return x; }
18800 function nMulTo(x,y,r) { x.multiplyTo(y,r); }
18801 function nSqrTo(x,r) { x.squareTo(r); }
18802
18803 NullExp.prototype.convert = nNop;
18804 NullExp.prototype.revert = nNop;
18805 NullExp.prototype.mulTo = nMulTo;
18806 NullExp.prototype.sqrTo = nSqrTo;
18807
18808 // (public) this^e
18809 function bnPow(e) { return this.exp(e,new NullExp()); }
18810
18811 // (protected) r = lower n words of "this * a", a.t <= n
18812 // "this" should be the larger one if appropriate.
18813 function bnpMultiplyLowerTo(a,n,r) {
18814 var i = Math.min(this.t+a.t,n);
18815 r.s = 0; // assumes a,this >= 0
18816 r.t = i;
18817 while(i > 0) r[--i] = 0;
18818 var j;
18819 for(j = r.t-this.t; i < j; ++i) r[i+this.t] = this.am(0,a[i],r,i,0,this.t);
18820 for(j = Math.min(a.t,n); i < j; ++i) this.am(0,a[i],r,i,0,n-i);
18821 r.clamp();
18822 }
18823
18824 // (protected) r = "this * a" without lower n words, n > 0
18825 // "this" should be the larger one if appropriate.
18826 function bnpMultiplyUpperTo(a,n,r) {
18827 --n;
18828 var i = r.t = this.t+a.t-n;
18829 r.s = 0; // assumes a,this >= 0
18830 while(--i >= 0) r[i] = 0;
18831 for(i = Math.max(n-this.t,0); i < a.t; ++i)
18832 r[this.t+i-n] = this.am(n-i,a[i],r,0,0,this.t+i-n);
18833 r.clamp();
18834 r.drShiftTo(1,r);
18835 }
18836
18837 // Barrett modular reduction
18838 function Barrett(m) {
18839 // setup Barrett
18840 this.r2 = nbi();
18841 this.q3 = nbi();
18842 BigInteger.ONE.dlShiftTo(2*m.t,this.r2);
18843 this.mu = this.r2.divide(m);
18844 this.m = m;
18845 }
18846
18847 function barrettConvert(x) {
18848 if(x.s < 0 || x.t > 2*this.m.t) return x.mod(this.m);
18849 else if(x.compareTo(this.m) < 0) return x;
18850 else { var r = nbi(); x.copyTo(r); this.reduce(r); return r; }
18851 }
18852
18853 function barrettRevert(x) { return x; }
18854
18855 // x = x mod m (HAC 14.42)
18856 function barrettReduce(x) {
18857 var self = this;
18858 x.drShiftTo(self.m.t-1,self.r2);
18859 if(x.t > self.m.t+1) { x.t = self.m.t+1; x.clamp(); }
18860 self.mu.multiplyUpperTo(self.r2,self.m.t+1,self.q3);
18861 self.m.multiplyLowerTo(self.q3,self.m.t+1,self.r2);
18862 while(x.compareTo(self.r2) < 0) x.dAddOffset(1,self.m.t+1);
18863 x.subTo(self.r2,x);
18864 while(x.compareTo(self.m) >= 0) x.subTo(self.m,x);
18865 }
18866
18867 // r = x^2 mod m; x != r
18868 function barrettSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
18869
18870 // r = x*y mod m; x,y != r
18871 function barrettMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
18872
18873 Barrett.prototype.convert = barrettConvert;
18874 Barrett.prototype.revert = barrettRevert;
18875 Barrett.prototype.reduce = barrettReduce;
18876 Barrett.prototype.mulTo = barrettMulTo;
18877 Barrett.prototype.sqrTo = barrettSqrTo;
18878
18879 // (public) this^e % m (HAC 14.85)
18880 function bnModPow(e,m) {
18881 var i = e.bitLength(), k, r = nbv(1), z;
18882 if(i <= 0) return r;
18883 else if(i < 18) k = 1;
18884 else if(i < 48) k = 3;
18885 else if(i < 144) k = 4;
18886 else if(i < 768) k = 5;
18887 else k = 6;
18888 if(i < 8)
18889 z = new Classic(m);
18890 else if(m.isEven())
18891 z = new Barrett(m);
18892 else
18893 z = new Montgomery(m);
18894
18895 // precomputation
18896 var g = new Array(), n = 3, k1 = k-1, km = (1<<k)-1;
18897 g[1] = z.convert(this);
18898 if(k > 1) {
18899 var g2 = nbi();
18900 z.sqrTo(g[1],g2);
18901 while(n <= km) {
18902 g[n] = nbi();
18903 z.mulTo(g2,g[n-2],g[n]);
18904 n += 2;
18905 }
18906 }
18907
18908 var j = e.t-1, w, is1 = true, r2 = nbi(), t;
18909 i = nbits(e[j])-1;
18910 while(j >= 0) {
18911 if(i >= k1) w = (e[j]>>(i-k1))&km;
18912 else {
18913 w = (e[j]&((1<<(i+1))-1))<<(k1-i);
18914 if(j > 0) w |= e[j-1]>>(this.DB+i-k1);
18915 }
18916
18917 n = k;
18918 while((w&1) == 0) { w >>= 1; --n; }
18919 if((i -= n) < 0) { i += this.DB; --j; }
18920 if(is1) { // ret == 1, don't bother squaring or multiplying it
18921 g[w].copyTo(r);
18922 is1 = false;
18923 }
18924 else {
18925 while(n > 1) { z.sqrTo(r,r2); z.sqrTo(r2,r); n -= 2; }
18926 if(n > 0) z.sqrTo(r,r2); else { t = r; r = r2; r2 = t; }
18927 z.mulTo(r2,g[w],r);
18928 }
18929
18930 while(j >= 0 && (e[j]&(1<<i)) == 0) {
18931 z.sqrTo(r,r2); t = r; r = r2; r2 = t;
18932 if(--i < 0) { i = this.DB-1; --j; }
18933 }
18934 }
18935 return z.revert(r);
18936 }
18937
18938 // (public) gcd(this,a) (HAC 14.54)
18939 function bnGCD(a) {
18940 var x = (this.s<0)?this.negate():this.clone();
18941 var y = (a.s<0)?a.negate():a.clone();
18942 if(x.compareTo(y) < 0) { var t = x; x = y; y = t; }
18943 var i = x.getLowestSetBit(), g = y.getLowestSetBit();
18944 if(g < 0) return x;
18945 if(i < g) g = i;
18946 if(g > 0) {
18947 x.rShiftTo(g,x);
18948 y.rShiftTo(g,y);
18949 }
18950 while(x.signum() > 0) {
18951 if((i = x.getLowestSetBit()) > 0) x.rShiftTo(i,x);
18952 if((i = y.getLowestSetBit()) > 0) y.rShiftTo(i,y);
18953 if(x.compareTo(y) >= 0) {
18954 x.subTo(y,x);
18955 x.rShiftTo(1,x);
18956 }
18957 else {
18958 y.subTo(x,y);
18959 y.rShiftTo(1,y);
18960 }
18961 }
18962 if(g > 0) y.lShiftTo(g,y);
18963 return y;
18964 }
18965
18966 // (protected) this % n, n < 2^26
18967 function bnpModInt(n) {
18968 if(n <= 0) return 0;
18969 var d = this.DV%n, r = (this.s<0)?n-1:0;
18970 if(this.t > 0)
18971 if(d == 0) r = this[0]%n;
18972 else for(var i = this.t-1; i >= 0; --i) r = (d*r+this[i])%n;
18973 return r;
18974 }
18975
18976 // (public) 1/this % m (HAC 14.61)
18977 function bnModInverse(m) {
18978 var ac = m.isEven();
18979 if((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO;
18980 var u = m.clone(), v = this.clone();
18981 var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1);
18982 while(u.signum() != 0) {
18983 while(u.isEven()) {
18984 u.rShiftTo(1,u);
18985 if(ac) {
18986 if(!a.isEven() || !b.isEven()) { a.addTo(this,a); b.subTo(m,b); }
18987 a.rShiftTo(1,a);
18988 }
18989 else if(!b.isEven()) b.subTo(m,b);
18990 b.rShiftTo(1,b);
18991 }
18992 while(v.isEven()) {
18993 v.rShiftTo(1,v);
18994 if(ac) {
18995 if(!c.isEven() || !d.isEven()) { c.addTo(this,c); d.subTo(m,d); }
18996 c.rShiftTo(1,c);
18997 }
18998 else if(!d.isEven()) d.subTo(m,d);
18999 d.rShiftTo(1,d);
19000 }
19001 if(u.compareTo(v) >= 0) {
19002 u.subTo(v,u);
19003 if(ac) a.subTo(c,a);
19004 b.subTo(d,b);
19005 }
19006 else {
19007 v.subTo(u,v);
19008 if(ac) c.subTo(a,c);
19009 d.subTo(b,d);
19010 }
19011 }
19012 if(v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;
19013 if(d.compareTo(m) >= 0) return d.subtract(m);
19014 if(d.signum() < 0) d.addTo(m,d); else return d;
19015 if(d.signum() < 0) return d.add(m); else return d;
19016 }
19017
19018 // protected
19019 proto.chunkSize = bnpChunkSize;
19020 proto.toRadix = bnpToRadix;
19021 proto.fromRadix = bnpFromRadix;
19022 proto.fromNumber = bnpFromNumber;
19023 proto.bitwiseTo = bnpBitwiseTo;
19024 proto.changeBit = bnpChangeBit;
19025 proto.addTo = bnpAddTo;
19026 proto.dMultiply = bnpDMultiply;
19027 proto.dAddOffset = bnpDAddOffset;
19028 proto.multiplyLowerTo = bnpMultiplyLowerTo;
19029 proto.multiplyUpperTo = bnpMultiplyUpperTo;
19030 proto.modInt = bnpModInt;
19031
19032 // public
19033 proto.clone = bnClone;
19034 proto.intValue = bnIntValue;
19035 proto.byteValue = bnByteValue;
19036 proto.shortValue = bnShortValue;
19037 proto.signum = bnSigNum;
19038 proto.toByteArray = bnToByteArray;
19039 proto.equals = bnEquals;
19040 proto.min = bnMin;
19041 proto.max = bnMax;
19042 proto.and = bnAnd;
19043 proto.or = bnOr;
19044 proto.xor = bnXor;
19045 proto.andNot = bnAndNot;
19046 proto.not = bnNot;
19047 proto.shiftLeft = bnShiftLeft;
19048 proto.shiftRight = bnShiftRight;
19049 proto.getLowestSetBit = bnGetLowestSetBit;
19050 proto.bitCount = bnBitCount;
19051 proto.testBit = bnTestBit;
19052 proto.setBit = bnSetBit;
19053 proto.clearBit = bnClearBit;
19054 proto.flipBit = bnFlipBit;
19055 proto.add = bnAdd;
19056 proto.subtract = bnSubtract;
19057 proto.multiply = bnMultiply;
19058 proto.divide = bnDivide;
19059 proto.remainder = bnRemainder;
19060 proto.divideAndRemainder = bnDivideAndRemainder;
19061 proto.modPow = bnModPow;
19062 proto.modInverse = bnModInverse;
19063 proto.pow = bnPow;
19064 proto.gcd = bnGCD;
19065
19066 // JSBN-specific extension
19067 proto.square = bnSquare;
19068
19069 // BigInteger interfaces not implemented in jsbn:
19070
19071 // BigInteger(int signum, byte[] magnitude)
19072 // double doubleValue()
19073 // float floatValue()
19074 // int hashCode()
19075 // long longValue()
19076 // static BigInteger valueOf(long val)
19077
19078 // "constants"
19079 BigInteger.ZERO = nbv(0);
19080 BigInteger.ONE = nbv(1);
19081 BigInteger.valueOf = nbv;
19082
19083 },{"assert":4}],2:[function(_dereq_,module,exports){
19084 (function (Buffer){
19085 // FIXME: Kind of a weird way to throw exceptions, consider removing
19086 var assert = _dereq_('assert')
19087 var BigInteger = _dereq_('./bigi')
19088
19089 /**
19090 * Turns a byte array into a big integer.
19091 *
19092 * This function will interpret a byte array as a big integer in big
19093 * endian notation.
19094 */
19095 BigInteger.fromByteArrayUnsigned = function(byteArray) {
19096 // BigInteger expects a DER integer conformant byte array
19097 if (byteArray[0] & 0x80) {
19098 return new BigInteger([0].concat(byteArray))
19099 }
19100
19101 return new BigInteger(byteArray)
19102 }
19103
19104 /**
19105 * Returns a byte array representation of the big integer.
19106 *
19107 * This returns the absolute of the contained value in big endian
19108 * form. A value of zero results in an empty array.
19109 */
19110 BigInteger.prototype.toByteArrayUnsigned = function() {
19111 var byteArray = this.toByteArray()
19112 return byteArray[0] === 0 ? byteArray.slice(1) : byteArray
19113 }
19114
19115 BigInteger.fromDERInteger = function(byteArray) {
19116 return new BigInteger(byteArray)
19117 }
19118
19119 /*
19120 * Converts BigInteger to a DER integer representation.
19121 *
19122 * The format for this value uses the most significant bit as a sign
19123 * bit. If the most significant bit is already set and the integer is
19124 * positive, a 0x00 is prepended.
19125 *
19126 * Examples:
19127 *
19128 * 0 => 0x00
19129 * 1 => 0x01
19130 * -1 => 0x81
19131 * 127 => 0x7f
19132 * -127 => 0xff
19133 * 128 => 0x0080
19134 * -128 => 0x80
19135 * 255 => 0x00ff
19136 * -255 => 0xff
19137 * 16300 => 0x3fac
19138 * -16300 => 0xbfac
19139 * 62300 => 0x00f35c
19140 * -62300 => 0xf35c
19141 */
19142 BigInteger.prototype.toDERInteger = BigInteger.prototype.toByteArray
19143
19144 BigInteger.fromBuffer = function(buffer) {
19145 // BigInteger expects a DER integer conformant byte array
19146 if (buffer[0] & 0x80) {
19147 var byteArray = Array.prototype.slice.call(buffer)
19148
19149 return new BigInteger([0].concat(byteArray))
19150 }
19151
19152 return new BigInteger(buffer)
19153 }
19154
19155 BigInteger.fromHex = function(hex) {
19156 if (hex === '') return BigInteger.ZERO
19157
19158 assert.equal(hex, hex.match(/^[A-Fa-f0-9]+/), 'Invalid hex string')
19159 assert.equal(hex.length % 2, 0, 'Incomplete hex')
19160 return new BigInteger(hex, 16)
19161 }
19162
19163 BigInteger.prototype.toBuffer = function(size) {
19164 var byteArray = this.toByteArrayUnsigned()
19165 var zeros = []
19166
19167 var padding = size - byteArray.length
19168 while (zeros.length < padding) zeros.push(0)
19169
19170 return new Buffer(zeros.concat(byteArray))
19171 }
19172
19173 BigInteger.prototype.toHex = function(size) {
19174 return this.toBuffer(size).toString('hex')
19175 }
19176
19177 }).call(this,_dereq_("buffer").Buffer)
19178 },{"./bigi":1,"assert":4,"buffer":8}],3:[function(_dereq_,module,exports){
19179 var BigInteger = _dereq_('./bigi')
19180
19181 //addons
19182 _dereq_('./convert')
19183
19184 module.exports = BigInteger
19185 },{"./bigi":1,"./convert":2}],4:[function(_dereq_,module,exports){
19186 // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
19187 //
19188 // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
19189 //
19190 // Originally from narwhal.js (http://narwhaljs.org)
19191 // Copyright (c) 2009 Thomas Robinson <280north.com>
19192 //
19193 // Permission is hereby granted, free of charge, to any person obtaining a copy
19194 // of this software and associated documentation files (the 'Software'), to
19195 // deal in the Software without restriction, including without limitation the
19196 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
19197 // sell copies of the Software, and to permit persons to whom the Software is
19198 // furnished to do so, subject to the following conditions:
19199 //
19200 // The above copyright notice and this permission notice shall be included in
19201 // all copies or substantial portions of the Software.
19202 //
19203 // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19204 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19205 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19206 // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19207 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19208 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19209
19210 // when used in node, this will actually load the util module we depend on
19211 // versus loading the builtin util module as happens otherwise
19212 // this is a bug in node module loading as far as I am concerned
19213 var util = _dereq_('util/');
19214
19215 var pSlice = Array.prototype.slice;
19216 var hasOwn = Object.prototype.hasOwnProperty;
19217
19218 // 1. The assert module provides functions that throw
19219 // AssertionError's when particular conditions are not met. The
19220 // assert module must conform to the following interface.
19221
19222 var assert = module.exports = ok;
19223
19224 // 2. The AssertionError is defined in assert.
19225 // new assert.AssertionError({ message: message,
19226 // actual: actual,
19227 // expected: expected })
19228
19229 assert.AssertionError = function AssertionError(options) {
19230 this.name = 'AssertionError';
19231 this.actual = options.actual;
19232 this.expected = options.expected;
19233 this.operator = options.operator;
19234 if (options.message) {
19235 this.message = options.message;
19236 this.generatedMessage = false;
19237 } else {
19238 this.message = getMessage(this);
19239 this.generatedMessage = true;
19240 }
19241 var stackStartFunction = options.stackStartFunction || fail;
19242
19243 if (Error.captureStackTrace) {
19244 Error.captureStackTrace(this, stackStartFunction);
19245 }
19246 else {
19247 // non v8 browsers so we can have a stacktrace
19248 var err = new Error();
19249 if (err.stack) {
19250 var out = err.stack;
19251
19252 // try to strip useless frames
19253 var fn_name = stackStartFunction.name;
19254 var idx = out.indexOf('\n' + fn_name);
19255 if (idx >= 0) {
19256 // once we have located the function frame
19257 // we need to strip out everything before it (and its line)
19258 var next_line = out.indexOf('\n', idx + 1);
19259 out = out.substring(next_line + 1);
19260 }
19261
19262 this.stack = out;
19263 }
19264 }
19265 };
19266
19267 // assert.AssertionError instanceof Error
19268 util.inherits(assert.AssertionError, Error);
19269
19270 function replacer(key, value) {
19271 if (util.isUndefined(value)) {
19272 return '' + value;
19273 }
19274 if (util.isNumber(value) && (isNaN(value) || !isFinite(value))) {
19275 return value.toString();
19276 }
19277 if (util.isFunction(value) || util.isRegExp(value)) {
19278 return value.toString();
19279 }
19280 return value;
19281 }
19282
19283 function truncate(s, n) {
19284 if (util.isString(s)) {
19285 return s.length < n ? s : s.slice(0, n);
19286 } else {
19287 return s;
19288 }
19289 }
19290
19291 function getMessage(self) {
19292 return truncate(JSON.stringify(self.actual, replacer), 128) + ' ' +
19293 self.operator + ' ' +
19294 truncate(JSON.stringify(self.expected, replacer), 128);
19295 }
19296
19297 // At present only the three keys mentioned above are used and
19298 // understood by the spec. Implementations or sub modules can pass
19299 // other keys to the AssertionError's constructor - they will be
19300 // ignored.
19301
19302 // 3. All of the following functions must throw an AssertionError
19303 // when a corresponding condition is not met, with a message that
19304 // may be undefined if not provided. All assertion methods provide
19305 // both the actual and expected values to the assertion error for
19306 // display purposes.
19307
19308 function fail(actual, expected, message, operator, stackStartFunction) {
19309 throw new assert.AssertionError({
19310 message: message,
19311 actual: actual,
19312 expected: expected,
19313 operator: operator,
19314 stackStartFunction: stackStartFunction
19315 });
19316 }
19317
19318 // EXTENSION! allows for well behaved errors defined elsewhere.
19319 assert.fail = fail;
19320
19321 // 4. Pure assertion tests whether a value is truthy, as determined
19322 // by !!guard.
19323 // assert.ok(guard, message_opt);
19324 // This statement is equivalent to assert.equal(true, !!guard,
19325 // message_opt);. To test strictly for the value true, use
19326 // assert.strictEqual(true, guard, message_opt);.
19327
19328 function ok(value, message) {
19329 if (!value) fail(value, true, message, '==', assert.ok);
19330 }
19331 assert.ok = ok;
19332
19333 // 5. The equality assertion tests shallow, coercive equality with
19334 // ==.
19335 // assert.equal(actual, expected, message_opt);
19336
19337 assert.equal = function equal(actual, expected, message) {
19338 if (actual != expected) fail(actual, expected, message, '==', assert.equal);
19339 };
19340
19341 // 6. The non-equality assertion tests for whether two objects are not equal
19342 // with != assert.notEqual(actual, expected, message_opt);
19343
19344 assert.notEqual = function notEqual(actual, expected, message) {
19345 if (actual == expected) {
19346 fail(actual, expected, message, '!=', assert.notEqual);
19347 }
19348 };
19349
19350 // 7. The equivalence assertion tests a deep equality relation.
19351 // assert.deepEqual(actual, expected, message_opt);
19352
19353 assert.deepEqual = function deepEqual(actual, expected, message) {
19354 if (!_deepEqual(actual, expected)) {
19355 fail(actual, expected, message, 'deepEqual', assert.deepEqual);
19356 }
19357 };
19358
19359 function _deepEqual(actual, expected) {
19360 // 7.1. All identical values are equivalent, as determined by ===.
19361 if (actual === expected) {
19362 return true;
19363
19364 } else if (util.isBuffer(actual) && util.isBuffer(expected)) {
19365 if (actual.length != expected.length) return false;
19366
19367 for (var i = 0; i < actual.length; i++) {
19368 if (actual[i] !== expected[i]) return false;
19369 }
19370
19371 return true;
19372
19373 // 7.2. If the expected value is a Date object, the actual value is
19374 // equivalent if it is also a Date object that refers to the same time.
19375 } else if (util.isDate(actual) && util.isDate(expected)) {
19376 return actual.getTime() === expected.getTime();
19377
19378 // 7.3 If the expected value is a RegExp object, the actual value is
19379 // equivalent if it is also a RegExp object with the same source and
19380 // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
19381 } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
19382 return actual.source === expected.source &&
19383 actual.global === expected.global &&
19384 actual.multiline === expected.multiline &&
19385 actual.lastIndex === expected.lastIndex &&
19386 actual.ignoreCase === expected.ignoreCase;
19387
19388 // 7.4. Other pairs that do not both pass typeof value == 'object',
19389 // equivalence is determined by ==.
19390 } else if (!util.isObject(actual) && !util.isObject(expected)) {
19391 return actual == expected;
19392
19393 // 7.5 For all other Object pairs, including Array objects, equivalence is
19394 // determined by having the same number of owned properties (as verified
19395 // with Object.prototype.hasOwnProperty.call), the same set of keys
19396 // (although not necessarily the same order), equivalent values for every
19397 // corresponding key, and an identical 'prototype' property. Note: this
19398 // accounts for both named and indexed properties on Arrays.
19399 } else {
19400 return objEquiv(actual, expected);
19401 }
19402 }
19403
19404 function isArguments(object) {
19405 return Object.prototype.toString.call(object) == '[object Arguments]';
19406 }
19407
19408 function objEquiv(a, b) {
19409 if (util.isNullOrUndefined(a) || util.isNullOrUndefined(b))
19410 return false;
19411 // an identical 'prototype' property.
19412 if (a.prototype !== b.prototype) return false;
19413 //~~~I've managed to break Object.keys through screwy arguments passing.
19414 // Converting to array solves the problem.
19415 if (isArguments(a)) {
19416 if (!isArguments(b)) {
19417 return false;
19418 }
19419 a = pSlice.call(a);
19420 b = pSlice.call(b);
19421 return _deepEqual(a, b);
19422 }
19423 try {
19424 var ka = objectKeys(a),
19425 kb = objectKeys(b),
19426 key, i;
19427 } catch (e) {//happens when one is a string literal and the other isn't
19428 return false;
19429 }
19430 // having the same number of owned properties (keys incorporates
19431 // hasOwnProperty)
19432 if (ka.length != kb.length)
19433 return false;
19434 //the same set of keys (although not necessarily the same order),
19435 ka.sort();
19436 kb.sort();
19437 //~~~cheap key test
19438 for (i = ka.length - 1; i >= 0; i--) {
19439 if (ka[i] != kb[i])
19440 return false;
19441 }
19442 //equivalent values for every corresponding key, and
19443 //~~~possibly expensive deep test
19444 for (i = ka.length - 1; i >= 0; i--) {
19445 key = ka[i];
19446 if (!_deepEqual(a[key], b[key])) return false;
19447 }
19448 return true;
19449 }
19450
19451 // 8. The non-equivalence assertion tests for any deep inequality.
19452 // assert.notDeepEqual(actual, expected, message_opt);
19453
19454 assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
19455 if (_deepEqual(actual, expected)) {
19456 fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
19457 }
19458 };
19459
19460 // 9. The strict equality assertion tests strict equality, as determined by ===.
19461 // assert.strictEqual(actual, expected, message_opt);
19462
19463 assert.strictEqual = function strictEqual(actual, expected, message) {
19464 if (actual !== expected) {
19465 fail(actual, expected, message, '===', assert.strictEqual);
19466 }
19467 };
19468
19469 // 10. The strict non-equality assertion tests for strict inequality, as
19470 // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
19471
19472 assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
19473 if (actual === expected) {
19474 fail(actual, expected, message, '!==', assert.notStrictEqual);
19475 }
19476 };
19477
19478 function expectedException(actual, expected) {
19479 if (!actual || !expected) {
19480 return false;
19481 }
19482
19483 if (Object.prototype.toString.call(expected) == '[object RegExp]') {
19484 return expected.test(actual);
19485 } else if (actual instanceof expected) {
19486 return true;
19487 } else if (expected.call({}, actual) === true) {
19488 return true;
19489 }
19490
19491 return false;
19492 }
19493
19494 function _throws(shouldThrow, block, expected, message) {
19495 var actual;
19496
19497 if (util.isString(expected)) {
19498 message = expected;
19499 expected = null;
19500 }
19501
19502 try {
19503 block();
19504 } catch (e) {
19505 actual = e;
19506 }
19507
19508 message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
19509 (message ? ' ' + message : '.');
19510
19511 if (shouldThrow && !actual) {
19512 fail(actual, expected, 'Missing expected exception' + message);
19513 }
19514
19515 if (!shouldThrow && expectedException(actual, expected)) {
19516 fail(actual, expected, 'Got unwanted exception' + message);
19517 }
19518
19519 if ((shouldThrow && actual && expected &&
19520 !expectedException(actual, expected)) || (!shouldThrow && actual)) {
19521 throw actual;
19522 }
19523 }
19524
19525 // 11. Expected to throw an error:
19526 // assert.throws(block, Error_opt, message_opt);
19527
19528 assert.throws = function(block, /*optional*/error, /*optional*/message) {
19529 _throws.apply(this, [true].concat(pSlice.call(arguments)));
19530 };
19531
19532 // EXTENSION! This is annoying to write outside this module.
19533 assert.doesNotThrow = function(block, /*optional*/message) {
19534 _throws.apply(this, [false].concat(pSlice.call(arguments)));
19535 };
19536
19537 assert.ifError = function(err) { if (err) {throw err;}};
19538
19539 var objectKeys = Object.keys || function (obj) {
19540 var keys = [];
19541 for (var key in obj) {
19542 if (hasOwn.call(obj, key)) keys.push(key);
19543 }
19544 return keys;
19545 };
19546
19547 },{"util/":6}],5:[function(_dereq_,module,exports){
19548 module.exports = function isBuffer(arg) {
19549 return arg && typeof arg === 'object'
19550 && typeof arg.copy === 'function'
19551 && typeof arg.fill === 'function'
19552 && typeof arg.readUInt8 === 'function';
19553 }
19554 },{}],6:[function(_dereq_,module,exports){
19555 (function (process,global){
19556 // Copyright Joyent, Inc. and other Node contributors.
19557 //
19558 // Permission is hereby granted, free of charge, to any person obtaining a
19559 // copy of this software and associated documentation files (the
19560 // "Software"), to deal in the Software without restriction, including
19561 // without limitation the rights to use, copy, modify, merge, publish,
19562 // distribute, sublicense, and/or sell copies of the Software, and to permit
19563 // persons to whom the Software is furnished to do so, subject to the
19564 // following conditions:
19565 //
19566 // The above copyright notice and this permission notice shall be included
19567 // in all copies or substantial portions of the Software.
19568 //
19569 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19570 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19571 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
19572 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19573 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19574 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
19575 // USE OR OTHER DEALINGS IN THE SOFTWARE.
19576
19577 var formatRegExp = /%[sdj%]/g;
19578 exports.format = function(f) {
19579 if (!isString(f)) {
19580 var objects = [];
19581 for (var i = 0; i < arguments.length; i++) {
19582 objects.push(inspect(arguments[i]));
19583 }
19584 return objects.join(' ');
19585 }
19586
19587 var i = 1;
19588 var args = arguments;
19589 var len = args.length;
19590 var str = String(f).replace(formatRegExp, function(x) {
19591 if (x === '%%') return '%';
19592 if (i >= len) return x;
19593 switch (x) {
19594 case '%s': return String(args[i++]);
19595 case '%d': return Number(args[i++]);
19596 case '%j':
19597 try {
19598 return JSON.stringify(args[i++]);
19599 } catch (_) {
19600 return '[Circular]';
19601 }
19602 default:
19603 return x;
19604 }
19605 });
19606 for (var x = args[i]; i < len; x = args[++i]) {
19607 if (isNull(x) || !isObject(x)) {
19608 str += ' ' + x;
19609 } else {
19610 str += ' ' + inspect(x);
19611 }
19612 }
19613 return str;
19614 };
19615
19616
19617 // Mark that a method should not be used.
19618 // Returns a modified function which warns once by default.
19619 // If --no-deprecation is set, then it is a no-op.
19620 exports.deprecate = function(fn, msg) {
19621 // Allow for deprecating things in the process of starting up.
19622 if (isUndefined(global.process)) {
19623 return function() {
19624 return exports.deprecate(fn, msg).apply(this, arguments);
19625 };
19626 }
19627
19628 if (process.noDeprecation === true) {
19629 return fn;
19630 }
19631
19632 var warned = false;
19633 function deprecated() {
19634 if (!warned) {
19635 if (process.throwDeprecation) {
19636 throw new Error(msg);
19637 } else if (process.traceDeprecation) {
19638 console.trace(msg);
19639 } else {
19640 console.error(msg);
19641 }
19642 warned = true;
19643 }
19644 return fn.apply(this, arguments);
19645 }
19646
19647 return deprecated;
19648 };
19649
19650
19651 var debugs = {};
19652 var debugEnviron;
19653 exports.debuglog = function(set) {
19654 if (isUndefined(debugEnviron))
19655 debugEnviron = process.env.NODE_DEBUG || '';
19656 set = set.toUpperCase();
19657 if (!debugs[set]) {
19658 if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
19659 var pid = process.pid;
19660 debugs[set] = function() {
19661 var msg = exports.format.apply(exports, arguments);
19662 console.error('%s %d: %s', set, pid, msg);
19663 };
19664 } else {
19665 debugs[set] = function() {};
19666 }
19667 }
19668 return debugs[set];
19669 };
19670
19671
19672 /**
19673 * Echos the value of a value. Trys to print the value out
19674 * in the best way possible given the different types.
19675 *
19676 * @param {Object} obj The object to print out.
19677 * @param {Object} opts Optional options object that alters the output.
19678 */
19679 /* legacy: obj, showHidden, depth, colors*/
19680 function inspect(obj, opts) {
19681 // default options
19682 var ctx = {
19683 seen: [],
19684 stylize: stylizeNoColor
19685 };
19686 // legacy...
19687 if (arguments.length >= 3) ctx.depth = arguments[2];
19688 if (arguments.length >= 4) ctx.colors = arguments[3];
19689 if (isBoolean(opts)) {
19690 // legacy...
19691 ctx.showHidden = opts;
19692 } else if (opts) {
19693 // got an "options" object
19694 exports._extend(ctx, opts);
19695 }
19696 // set default options
19697 if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
19698 if (isUndefined(ctx.depth)) ctx.depth = 2;
19699 if (isUndefined(ctx.colors)) ctx.colors = false;
19700 if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
19701 if (ctx.colors) ctx.stylize = stylizeWithColor;
19702 return formatValue(ctx, obj, ctx.depth);
19703 }
19704 exports.inspect = inspect;
19705
19706
19707 // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
19708 inspect.colors = {
19709 'bold' : [1, 22],
19710 'italic' : [3, 23],
19711 'underline' : [4, 24],
19712 'inverse' : [7, 27],
19713 'white' : [37, 39],
19714 'grey' : [90, 39],
19715 'black' : [30, 39],
19716 'blue' : [34, 39],
19717 'cyan' : [36, 39],
19718 'green' : [32, 39],
19719 'magenta' : [35, 39],
19720 'red' : [31, 39],
19721 'yellow' : [33, 39]
19722 };
19723
19724 // Don't use 'blue' not visible on cmd.exe
19725 inspect.styles = {
19726 'special': 'cyan',
19727 'number': 'yellow',
19728 'boolean': 'yellow',
19729 'undefined': 'grey',
19730 'null': 'bold',
19731 'string': 'green',
19732 'date': 'magenta',
19733 // "name": intentionally not styling
19734 'regexp': 'red'
19735 };
19736
19737
19738 function stylizeWithColor(str, styleType) {
19739 var style = inspect.styles[styleType];
19740
19741 if (style) {
19742 return '\u001b[' + inspect.colors[style][0] + 'm' + str +
19743 '\u001b[' + inspect.colors[style][1] + 'm';
19744 } else {
19745 return str;
19746 }
19747 }
19748
19749
19750 function stylizeNoColor(str, styleType) {
19751 return str;
19752 }
19753
19754
19755 function arrayToHash(array) {
19756 var hash = {};
19757
19758 array.forEach(function(val, idx) {
19759 hash[val] = true;
19760 });
19761
19762 return hash;
19763 }
19764
19765
19766 function formatValue(ctx, value, recurseTimes) {
19767 // Provide a hook for user-specified inspect functions.
19768 // Check that value is an object with an inspect function on it
19769 if (ctx.customInspect &&
19770 value &&
19771 isFunction(value.inspect) &&
19772 // Filter out the util module, it's inspect function is special
19773 value.inspect !== exports.inspect &&
19774 // Also filter out any prototype objects using the circular check.
19775 !(value.constructor && value.constructor.prototype === value)) {
19776 var ret = value.inspect(recurseTimes, ctx);
19777 if (!isString(ret)) {
19778 ret = formatValue(ctx, ret, recurseTimes);
19779 }
19780 return ret;
19781 }
19782
19783 // Primitive types cannot have properties
19784 var primitive = formatPrimitive(ctx, value);
19785 if (primitive) {
19786 return primitive;
19787 }
19788
19789 // Look up the keys of the object.
19790 var keys = Object.keys(value);
19791 var visibleKeys = arrayToHash(keys);
19792
19793 if (ctx.showHidden) {
19794 keys = Object.getOwnPropertyNames(value);
19795 }
19796
19797 // IE doesn't make error fields non-enumerable
19798 // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
19799 if (isError(value)
19800 && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
19801 return formatError(value);
19802 }
19803
19804 // Some type of object without properties can be shortcutted.
19805 if (keys.length === 0) {
19806 if (isFunction(value)) {
19807 var name = value.name ? ': ' + value.name : '';
19808 return ctx.stylize('[Function' + name + ']', 'special');
19809 }
19810 if (isRegExp(value)) {
19811 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
19812 }
19813 if (isDate(value)) {
19814 return ctx.stylize(Date.prototype.toString.call(value), 'date');
19815 }
19816 if (isError(value)) {
19817 return formatError(value);
19818 }
19819 }
19820
19821 var base = '', array = false, braces = ['{', '}'];
19822
19823 // Make Array say that they are Array
19824 if (isArray(value)) {
19825 array = true;
19826 braces = ['[', ']'];
19827 }
19828
19829 // Make functions say that they are functions
19830 if (isFunction(value)) {
19831 var n = value.name ? ': ' + value.name : '';
19832 base = ' [Function' + n + ']';
19833 }
19834
19835 // Make RegExps say that they are RegExps
19836 if (isRegExp(value)) {
19837 base = ' ' + RegExp.prototype.toString.call(value);
19838 }
19839
19840 // Make dates with properties first say the date
19841 if (isDate(value)) {
19842 base = ' ' + Date.prototype.toUTCString.call(value);
19843 }
19844
19845 // Make error with message first say the error
19846 if (isError(value)) {
19847 base = ' ' + formatError(value);
19848 }
19849
19850 if (keys.length === 0 && (!array || value.length == 0)) {
19851 return braces[0] + base + braces[1];
19852 }
19853
19854 if (recurseTimes < 0) {
19855 if (isRegExp(value)) {
19856 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
19857 } else {
19858 return ctx.stylize('[Object]', 'special');
19859 }
19860 }
19861
19862 ctx.seen.push(value);
19863
19864 var output;
19865 if (array) {
19866 output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
19867 } else {
19868 output = keys.map(function(key) {
19869 return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
19870 });
19871 }
19872
19873 ctx.seen.pop();
19874
19875 return reduceToSingleString(output, base, braces);
19876 }
19877
19878
19879 function formatPrimitive(ctx, value) {
19880 if (isUndefined(value))
19881 return ctx.stylize('undefined', 'undefined');
19882 if (isString(value)) {
19883 var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
19884 .replace(/'/g, "\\'")
19885 .replace(/\\"/g, '"') + '\'';
19886 return ctx.stylize(simple, 'string');
19887 }
19888 if (isNumber(value))
19889 return ctx.stylize('' + value, 'number');
19890 if (isBoolean(value))
19891 return ctx.stylize('' + value, 'boolean');
19892 // For some reason typeof null is "object", so special case here.
19893 if (isNull(value))
19894 return ctx.stylize('null', 'null');
19895 }
19896
19897
19898 function formatError(value) {
19899 return '[' + Error.prototype.toString.call(value) + ']';
19900 }
19901
19902
19903 function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
19904 var output = [];
19905 for (var i = 0, l = value.length; i < l; ++i) {
19906 if (hasOwnProperty(value, String(i))) {
19907 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
19908 String(i), true));
19909 } else {
19910 output.push('');
19911 }
19912 }
19913 keys.forEach(function(key) {
19914 if (!key.match(/^\d+$/)) {
19915 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
19916 key, true));
19917 }
19918 });
19919 return output;
19920 }
19921
19922
19923 function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
19924 var name, str, desc;
19925 desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
19926 if (desc.get) {
19927 if (desc.set) {
19928 str = ctx.stylize('[Getter/Setter]', 'special');
19929 } else {
19930 str = ctx.stylize('[Getter]', 'special');
19931 }
19932 } else {
19933 if (desc.set) {
19934 str = ctx.stylize('[Setter]', 'special');
19935 }
19936 }
19937 if (!hasOwnProperty(visibleKeys, key)) {
19938 name = '[' + key + ']';
19939 }
19940 if (!str) {
19941 if (ctx.seen.indexOf(desc.value) < 0) {
19942 if (isNull(recurseTimes)) {
19943 str = formatValue(ctx, desc.value, null);
19944 } else {
19945 str = formatValue(ctx, desc.value, recurseTimes - 1);
19946 }
19947 if (str.indexOf('\n') > -1) {
19948 if (array) {
19949 str = str.split('\n').map(function(line) {
19950 return ' ' + line;
19951 }).join('\n').substr(2);
19952 } else {
19953 str = '\n' + str.split('\n').map(function(line) {
19954 return ' ' + line;
19955 }).join('\n');
19956 }
19957 }
19958 } else {
19959 str = ctx.stylize('[Circular]', 'special');
19960 }
19961 }
19962 if (isUndefined(name)) {
19963 if (array && key.match(/^\d+$/)) {
19964 return str;
19965 }
19966 name = JSON.stringify('' + key);
19967 if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
19968 name = name.substr(1, name.length - 2);
19969 name = ctx.stylize(name, 'name');
19970 } else {
19971 name = name.replace(/'/g, "\\'")
19972 .replace(/\\"/g, '"')
19973 .replace(/(^"|"$)/g, "'");
19974 name = ctx.stylize(name, 'string');
19975 }
19976 }
19977
19978 return name + ': ' + str;
19979 }
19980
19981
19982 function reduceToSingleString(output, base, braces) {
19983 var numLinesEst = 0;
19984 var length = output.reduce(function(prev, cur) {
19985 numLinesEst++;
19986 if (cur.indexOf('\n') >= 0) numLinesEst++;
19987 return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
19988 }, 0);
19989
19990 if (length > 60) {
19991 return braces[0] +
19992 (base === '' ? '' : base + '\n ') +
19993 ' ' +
19994 output.join(',\n ') +
19995 ' ' +
19996 braces[1];
19997 }
19998
19999 return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
20000 }
20001
20002
20003 // NOTE: These type checking functions intentionally don't use `instanceof`
20004 // because it is fragile and can be easily faked with `Object.create()`.
20005 function isArray(ar) {
20006 return Array.isArray(ar);
20007 }
20008 exports.isArray = isArray;
20009
20010 function isBoolean(arg) {
20011 return typeof arg === 'boolean';
20012 }
20013 exports.isBoolean = isBoolean;
20014
20015 function isNull(arg) {
20016 return arg === null;
20017 }
20018 exports.isNull = isNull;
20019
20020 function isNullOrUndefined(arg) {
20021 return arg == null;
20022 }
20023 exports.isNullOrUndefined = isNullOrUndefined;
20024
20025 function isNumber(arg) {
20026 return typeof arg === 'number';
20027 }
20028 exports.isNumber = isNumber;
20029
20030 function isString(arg) {
20031 return typeof arg === 'string';
20032 }
20033 exports.isString = isString;
20034
20035 function isSymbol(arg) {
20036 return typeof arg === 'symbol';
20037 }
20038 exports.isSymbol = isSymbol;
20039
20040 function isUndefined(arg) {
20041 return arg === void 0;
20042 }
20043 exports.isUndefined = isUndefined;
20044
20045 function isRegExp(re) {
20046 return isObject(re) && objectToString(re) === '[object RegExp]';
20047 }
20048 exports.isRegExp = isRegExp;
20049
20050 function isObject(arg) {
20051 return typeof arg === 'object' && arg !== null;
20052 }
20053 exports.isObject = isObject;
20054
20055 function isDate(d) {
20056 return isObject(d) && objectToString(d) === '[object Date]';
20057 }
20058 exports.isDate = isDate;
20059
20060 function isError(e) {
20061 return isObject(e) &&
20062 (objectToString(e) === '[object Error]' || e instanceof Error);
20063 }
20064 exports.isError = isError;
20065
20066 function isFunction(arg) {
20067 return typeof arg === 'function';
20068 }
20069 exports.isFunction = isFunction;
20070
20071 function isPrimitive(arg) {
20072 return arg === null ||
20073 typeof arg === 'boolean' ||
20074 typeof arg === 'number' ||
20075 typeof arg === 'string' ||
20076 typeof arg === 'symbol' || // ES6 symbol
20077 typeof arg === 'undefined';
20078 }
20079 exports.isPrimitive = isPrimitive;
20080
20081 exports.isBuffer = _dereq_('./support/isBuffer');
20082
20083 function objectToString(o) {
20084 return Object.prototype.toString.call(o);
20085 }
20086
20087
20088 function pad(n) {
20089 return n < 10 ? '0' + n.toString(10) : n.toString(10);
20090 }
20091
20092
20093 var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
20094 'Oct', 'Nov', 'Dec'];
20095
20096 // 26 Feb 16:19:34
20097 function timestamp() {
20098 var d = new Date();
20099 var time = [pad(d.getHours()),
20100 pad(d.getMinutes()),
20101 pad(d.getSeconds())].join(':');
20102 return [d.getDate(), months[d.getMonth()], time].join(' ');
20103 }
20104
20105
20106 // log is just a thin wrapper to console.log that prepends a timestamp
20107 exports.log = function() {
20108 console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
20109 };
20110
20111
20112 /**
20113 * Inherit the prototype methods from one constructor into another.
20114 *
20115 * The Function.prototype.inherits from lang.js rewritten as a standalone
20116 * function (not on Function.prototype). NOTE: If this file is to be loaded
20117 * during bootstrapping this function needs to be rewritten using some native
20118 * functions as prototype setup using normal JavaScript does not work as
20119 * expected during bootstrapping (see mirror.js in r114903).
20120 *
20121 * @param {function} ctor Constructor function which needs to inherit the
20122 * prototype.
20123 * @param {function} superCtor Constructor function to inherit prototype from.
20124 */
20125 exports.inherits = _dereq_('inherits');
20126
20127 exports._extend = function(origin, add) {
20128 // Don't do anything if add isn't an object
20129 if (!add || !isObject(add)) return origin;
20130
20131 var keys = Object.keys(add);
20132 var i = keys.length;
20133 while (i--) {
20134 origin[keys[i]] = add[keys[i]];
20135 }
20136 return origin;
20137 };
20138
20139 function hasOwnProperty(obj, prop) {
20140 return Object.prototype.hasOwnProperty.call(obj, prop);
20141 }
20142
20143 }).call(this,_dereq_("FWaASH"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
20144 },{"./support/isBuffer":5,"FWaASH":12,"inherits":11}],7:[function(_dereq_,module,exports){
20145
20146 },{}],8:[function(_dereq_,module,exports){
20147 /*!
20148 * The buffer module from node.js, for the browser.
20149 *
20150 * at author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
20151 * at license MIT
20152 */
20153
20154 var base64 = _dereq_('base64-js')
20155 var ieee754 = _dereq_('ieee754')
20156
20157 exports.Buffer = Buffer
20158 exports.SlowBuffer = Buffer
20159 exports.INSPECT_MAX_BYTES = 50
20160 Buffer.poolSize = 8192
20161
20162 /**
20163 * If `Buffer._useTypedArrays`:
20164 * === true Use Uint8Array implementation (fastest)
20165 * === false Use Object implementation (compatible down to IE6)
20166 */
20167 Buffer._useTypedArrays = (function () {
20168 // Detect if browser supports Typed Arrays. Supported browsers are IE 10+, Firefox 4+,
20169 // Chrome 7+, Safari 5.1+, Opera 11.6+, iOS 4.2+. If the browser does not support adding
20170 // properties to `Uint8Array` instances, then that's the same as no `Uint8Array` support
20171 // because we need to be able to add all the node Buffer API methods. This is an issue
20172 // in Firefox 4-29. Now fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=695438
20173 try {
20174 var buf = new ArrayBuffer(0)
20175 var arr = new Uint8Array(buf)
20176 arr.foo = function () { return 42 }
20177 return 42 === arr.foo() &&
20178 typeof arr.subarray === 'function' // Chrome 9-10 lack `subarray`
20179 } catch (e) {
20180 return false
20181 }
20182 })()
20183
20184 /**
20185 * Class: Buffer
20186 * =============
20187 *
20188 * The Buffer constructor returns instances of `Uint8Array` that are augmented
20189 * with function properties for all the node `Buffer` API functions. We use
20190 * `Uint8Array` so that square bracket notation works as expected -- it returns
20191 * a single octet.
20192 *
20193 * By augmenting the instances, we can avoid modifying the `Uint8Array`
20194 * prototype.
20195 */
20196 function Buffer (subject, encoding, noZero) {
20197 if (!(this instanceof Buffer))
20198 return new Buffer(subject, encoding, noZero)
20199
20200 var type = typeof subject
20201
20202 if (encoding === 'base64' && type === 'string') {
20203 subject = base64clean(subject)
20204 }
20205
20206 // Find the length
20207 var length
20208 if (type === 'number')
20209 length = coerce(subject)
20210 else if (type === 'string')
20211 length = Buffer.byteLength(subject, encoding)
20212 else if (type === 'object')
20213 length = coerce(subject.length) // assume that object is array-like
20214 else
20215 throw new Error('First argument needs to be a number, array or string.')
20216
20217 var buf
20218 if (Buffer._useTypedArrays) {
20219 // Preferred: Return an augmented `Uint8Array` instance for best performance
20220 buf = Buffer._augment(new Uint8Array(length))
20221 } else {
20222 // Fallback: Return THIS instance of Buffer (created by `new`)
20223 buf = this
20224 buf.length = length
20225 buf._isBuffer = true
20226 }
20227
20228 var i
20229 if (Buffer._useTypedArrays && typeof subject.byteLength === 'number') {
20230 // Speed optimization -- use set if we're copying from a typed array
20231 buf._set(subject)
20232 } else if (isArrayish(subject)) {
20233 // Treat array-ish objects as a byte array
20234 if (Buffer.isBuffer(subject)) {
20235 for (i = 0; i < length; i++)
20236 buf[i] = subject.readUInt8(i)
20237 } else {
20238 for (i = 0; i < length; i++)
20239 buf[i] = ((subject[i] % 256) + 256) % 256
20240 }
20241 } else if (type === 'string') {
20242 buf.write(subject, 0, encoding)
20243 } else if (type === 'number' && !Buffer._useTypedArrays && !noZero) {
20244 for (i = 0; i < length; i++) {
20245 buf[i] = 0
20246 }
20247 }
20248
20249 return buf
20250 }
20251
20252 // STATIC METHODS
20253 // ==============
20254
20255 Buffer.isEncoding = function (encoding) {
20256 switch (String(encoding).toLowerCase()) {
20257 case 'hex':
20258 case 'utf8':
20259 case 'utf-8':
20260 case 'ascii':
20261 case 'binary':
20262 case 'base64':
20263 case 'raw':
20264 case 'ucs2':
20265 case 'ucs-2':
20266 case 'utf16le':
20267 case 'utf-16le':
20268 return true
20269 default:
20270 return false
20271 }
20272 }
20273
20274 Buffer.isBuffer = function (b) {
20275 return !!(b !== null && b !== undefined && b._isBuffer)
20276 }
20277
20278 Buffer.byteLength = function (str, encoding) {
20279 var ret
20280 str = str.toString()
20281 switch (encoding || 'utf8') {
20282 case 'hex':
20283 ret = str.length / 2
20284 break
20285 case 'utf8':
20286 case 'utf-8':
20287 ret = utf8ToBytes(str).length
20288 break
20289 case 'ascii':
20290 case 'binary':
20291 case 'raw':
20292 ret = str.length
20293 break
20294 case 'base64':
20295 ret = base64ToBytes(str).length
20296 break
20297 case 'ucs2':
20298 case 'ucs-2':
20299 case 'utf16le':
20300 case 'utf-16le':
20301 ret = str.length * 2
20302 break
20303 default:
20304 throw new Error('Unknown encoding')
20305 }
20306 return ret
20307 }
20308
20309 Buffer.concat = function (list, totalLength) {
20310 assert(isArray(list), 'Usage: Buffer.concat(list[, length])')
20311
20312 if (list.length === 0) {
20313 return new Buffer(0)
20314 } else if (list.length === 1) {
20315 return list[0]
20316 }
20317
20318 var i
20319 if (totalLength === undefined) {
20320 totalLength = 0
20321 for (i = 0; i < list.length; i++) {
20322 totalLength += list[i].length
20323 }
20324 }
20325
20326 var buf = new Buffer(totalLength)
20327 var pos = 0
20328 for (i = 0; i < list.length; i++) {
20329 var item = list[i]
20330 item.copy(buf, pos)
20331 pos += item.length
20332 }
20333 return buf
20334 }
20335
20336 Buffer.compare = function (a, b) {
20337 assert(Buffer.isBuffer(a) && Buffer.isBuffer(b), 'Arguments must be Buffers')
20338 var x = a.length
20339 var y = b.length
20340 for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {}
20341 if (i !== len) {
20342 x = a[i]
20343 y = b[i]
20344 }
20345 if (x < y) {
20346 return -1
20347 }
20348 if (y < x) {
20349 return 1
20350 }
20351 return 0
20352 }
20353
20354 // BUFFER INSTANCE METHODS
20355 // =======================
20356
20357 function hexWrite (buf, string, offset, length) {
20358 offset = Number(offset) || 0
20359 var remaining = buf.length - offset
20360 if (!length) {
20361 length = remaining
20362 } else {
20363 length = Number(length)
20364 if (length > remaining) {
20365 length = remaining
20366 }
20367 }
20368
20369 // must be an even number of digits
20370 var strLen = string.length
20371 assert(strLen % 2 === 0, 'Invalid hex string')
20372
20373 if (length > strLen / 2) {
20374 length = strLen / 2
20375 }
20376 for (var i = 0; i < length; i++) {
20377 var byte = parseInt(string.substr(i * 2, 2), 16)
20378 assert(!isNaN(byte), 'Invalid hex string')
20379 buf[offset + i] = byte
20380 }
20381 return i
20382 }
20383
20384 function utf8Write (buf, string, offset, length) {
20385 var charsWritten = blitBuffer(utf8ToBytes(string), buf, offset, length)
20386 return charsWritten
20387 }
20388
20389 function asciiWrite (buf, string, offset, length) {
20390 var charsWritten = blitBuffer(asciiToBytes(string), buf, offset, length)
20391 return charsWritten
20392 }
20393
20394 function binaryWrite (buf, string, offset, length) {
20395 return asciiWrite(buf, string, offset, length)
20396 }
20397
20398 function base64Write (buf, string, offset, length) {
20399 var charsWritten = blitBuffer(base64ToBytes(string), buf, offset, length)
20400 return charsWritten
20401 }
20402
20403 function utf16leWrite (buf, string, offset, length) {
20404 var charsWritten = blitBuffer(utf16leToBytes(string), buf, offset, length)
20405 return charsWritten
20406 }
20407
20408 Buffer.prototype.write = function (string, offset, length, encoding) {
20409 // Support both (string, offset, length, encoding)
20410 // and the legacy (string, encoding, offset, length)
20411 if (isFinite(offset)) {
20412 if (!isFinite(length)) {
20413 encoding = length
20414 length = undefined
20415 }
20416 } else { // legacy
20417 var swap = encoding
20418 encoding = offset
20419 offset = length
20420 length = swap
20421 }
20422
20423 offset = Number(offset) || 0
20424 var remaining = this.length - offset
20425 if (!length) {
20426 length = remaining
20427 } else {
20428 length = Number(length)
20429 if (length > remaining) {
20430 length = remaining
20431 }
20432 }
20433 encoding = String(encoding || 'utf8').toLowerCase()
20434
20435 var ret
20436 switch (encoding) {
20437 case 'hex':
20438 ret = hexWrite(this, string, offset, length)
20439 break
20440 case 'utf8':
20441 case 'utf-8':
20442 ret = utf8Write(this, string, offset, length)
20443 break
20444 case 'ascii':
20445 ret = asciiWrite(this, string, offset, length)
20446 break
20447 case 'binary':
20448 ret = binaryWrite(this, string, offset, length)
20449 break
20450 case 'base64':
20451 ret = base64Write(this, string, offset, length)
20452 break
20453 case 'ucs2':
20454 case 'ucs-2':
20455 case 'utf16le':
20456 case 'utf-16le':
20457 ret = utf16leWrite(this, string, offset, length)
20458 break
20459 default:
20460 throw new Error('Unknown encoding')
20461 }
20462 return ret
20463 }
20464
20465 Buffer.prototype.toString = function (encoding, start, end) {
20466 var self = this
20467
20468 encoding = String(encoding || 'utf8').toLowerCase()
20469 start = Number(start) || 0
20470 end = (end === undefined) ? self.length : Number(end)
20471
20472 // Fastpath empty strings
20473 if (end === start)
20474 return ''
20475
20476 var ret
20477 switch (encoding) {
20478 case 'hex':
20479 ret = hexSlice(self, start, end)
20480 break
20481 case 'utf8':
20482 case 'utf-8':
20483 ret = utf8Slice(self, start, end)
20484 break
20485 case 'ascii':
20486 ret = asciiSlice(self, start, end)
20487 break
20488 case 'binary':
20489 ret = binarySlice(self, start, end)
20490 break
20491 case 'base64':
20492 ret = base64Slice(self, start, end)
20493 break
20494 case 'ucs2':
20495 case 'ucs-2':
20496 case 'utf16le':
20497 case 'utf-16le':
20498 ret = utf16leSlice(self, start, end)
20499 break
20500 default:
20501 throw new Error('Unknown encoding')
20502 }
20503 return ret
20504 }
20505
20506 Buffer.prototype.toJSON = function () {
20507 return {
20508 type: 'Buffer',
20509 data: Array.prototype.slice.call(this._arr || this, 0)
20510 }
20511 }
20512
20513 Buffer.prototype.equals = function (b) {
20514 assert(Buffer.isBuffer(b), 'Argument must be a Buffer')
20515 return Buffer.compare(this, b) === 0
20516 }
20517
20518 Buffer.prototype.compare = function (b) {
20519 assert(Buffer.isBuffer(b), 'Argument must be a Buffer')
20520 return Buffer.compare(this, b)
20521 }
20522
20523 // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
20524 Buffer.prototype.copy = function (target, target_start, start, end) {
20525 var source = this
20526
20527 if (!start) start = 0
20528 if (!end && end !== 0) end = this.length
20529 if (!target_start) target_start = 0
20530
20531 // Copy 0 bytes; we're done
20532 if (end === start) return
20533 if (target.length === 0 || source.length === 0) return
20534
20535 // Fatal error conditions
20536 assert(end >= start, 'sourceEnd < sourceStart')
20537 assert(target_start >= 0 && target_start < target.length,
20538 'targetStart out of bounds')
20539 assert(start >= 0 && start < source.length, 'sourceStart out of bounds')
20540 assert(end >= 0 && end <= source.length, 'sourceEnd out of bounds')
20541
20542 // Are we oob?
20543 if (end > this.length)
20544 end = this.length
20545 if (target.length - target_start < end - start)
20546 end = target.length - target_start + start
20547
20548 var len = end - start
20549
20550 if (len < 100 || !Buffer._useTypedArrays) {
20551 for (var i = 0; i < len; i++) {
20552 target[i + target_start] = this[i + start]
20553 }
20554 } else {
20555 target._set(this.subarray(start, start + len), target_start)
20556 }
20557 }
20558
20559 function base64Slice (buf, start, end) {
20560 if (start === 0 && end === buf.length) {
20561 return base64.fromByteArray(buf)
20562 } else {
20563 return base64.fromByteArray(buf.slice(start, end))
20564 }
20565 }
20566
20567 function utf8Slice (buf, start, end) {
20568 var res = ''
20569 var tmp = ''
20570 end = Math.min(buf.length, end)
20571
20572 for (var i = start; i < end; i++) {
20573 if (buf[i] <= 0x7F) {
20574 res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i])
20575 tmp = ''
20576 } else {
20577 tmp += '%' + buf[i].toString(16)
20578 }
20579 }
20580
20581 return res + decodeUtf8Char(tmp)
20582 }
20583
20584 function asciiSlice (buf, start, end) {
20585 var ret = ''
20586 end = Math.min(buf.length, end)
20587
20588 for (var i = start; i < end; i++) {
20589 ret += String.fromCharCode(buf[i])
20590 }
20591 return ret
20592 }
20593
20594 function binarySlice (buf, start, end) {
20595 return asciiSlice(buf, start, end)
20596 }
20597
20598 function hexSlice (buf, start, end) {
20599 var len = buf.length
20600
20601 if (!start || start < 0) start = 0
20602 if (!end || end < 0 || end > len) end = len
20603
20604 var out = ''
20605 for (var i = start; i < end; i++) {
20606 out += toHex(buf[i])
20607 }
20608 return out
20609 }
20610
20611 function utf16leSlice (buf, start, end) {
20612 var bytes = buf.slice(start, end)
20613 var res = ''
20614 for (var i = 0; i < bytes.length; i += 2) {
20615 res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
20616 }
20617 return res
20618 }
20619
20620 Buffer.prototype.slice = function (start, end) {
20621 var len = this.length
20622 start = clamp(start, len, 0)
20623 end = clamp(end, len, len)
20624
20625 if (Buffer._useTypedArrays) {
20626 return Buffer._augment(this.subarray(start, end))
20627 } else {
20628 var sliceLen = end - start
20629 var newBuf = new Buffer(sliceLen, undefined, true)
20630 for (var i = 0; i < sliceLen; i++) {
20631 newBuf[i] = this[i + start]
20632 }
20633 return newBuf
20634 }
20635 }
20636
20637 // `get` will be removed in Node 0.13+
20638 Buffer.prototype.get = function (offset) {
20639 console.log('.get() is deprecated. Access using array indexes instead.')
20640 return this.readUInt8(offset)
20641 }
20642
20643 // `set` will be removed in Node 0.13+
20644 Buffer.prototype.set = function (v, offset) {
20645 console.log('.set() is deprecated. Access using array indexes instead.')
20646 return this.writeUInt8(v, offset)
20647 }
20648
20649 Buffer.prototype.readUInt8 = function (offset, noAssert) {
20650 if (!noAssert) {
20651 assert(offset !== undefined && offset !== null, 'missing offset')
20652 assert(offset < this.length, 'Trying to read beyond buffer length')
20653 }
20654
20655 if (offset >= this.length)
20656 return
20657
20658 return this[offset]
20659 }
20660
20661 function readUInt16 (buf, offset, littleEndian, noAssert) {
20662 if (!noAssert) {
20663 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20664 assert(offset !== undefined && offset !== null, 'missing offset')
20665 assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
20666 }
20667
20668 var len = buf.length
20669 if (offset >= len)
20670 return
20671
20672 var val
20673 if (littleEndian) {
20674 val = buf[offset]
20675 if (offset + 1 < len)
20676 val |= buf[offset + 1] << 8
20677 } else {
20678 val = buf[offset] << 8
20679 if (offset + 1 < len)
20680 val |= buf[offset + 1]
20681 }
20682 return val
20683 }
20684
20685 Buffer.prototype.readUInt16LE = function (offset, noAssert) {
20686 return readUInt16(this, offset, true, noAssert)
20687 }
20688
20689 Buffer.prototype.readUInt16BE = function (offset, noAssert) {
20690 return readUInt16(this, offset, false, noAssert)
20691 }
20692
20693 function readUInt32 (buf, offset, littleEndian, noAssert) {
20694 if (!noAssert) {
20695 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20696 assert(offset !== undefined && offset !== null, 'missing offset')
20697 assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
20698 }
20699
20700 var len = buf.length
20701 if (offset >= len)
20702 return
20703
20704 var val
20705 if (littleEndian) {
20706 if (offset + 2 < len)
20707 val = buf[offset + 2] << 16
20708 if (offset + 1 < len)
20709 val |= buf[offset + 1] << 8
20710 val |= buf[offset]
20711 if (offset + 3 < len)
20712 val = val + (buf[offset + 3] << 24 >>> 0)
20713 } else {
20714 if (offset + 1 < len)
20715 val = buf[offset + 1] << 16
20716 if (offset + 2 < len)
20717 val |= buf[offset + 2] << 8
20718 if (offset + 3 < len)
20719 val |= buf[offset + 3]
20720 val = val + (buf[offset] << 24 >>> 0)
20721 }
20722 return val
20723 }
20724
20725 Buffer.prototype.readUInt32LE = function (offset, noAssert) {
20726 return readUInt32(this, offset, true, noAssert)
20727 }
20728
20729 Buffer.prototype.readUInt32BE = function (offset, noAssert) {
20730 return readUInt32(this, offset, false, noAssert)
20731 }
20732
20733 Buffer.prototype.readInt8 = function (offset, noAssert) {
20734 if (!noAssert) {
20735 assert(offset !== undefined && offset !== null,
20736 'missing offset')
20737 assert(offset < this.length, 'Trying to read beyond buffer length')
20738 }
20739
20740 if (offset >= this.length)
20741 return
20742
20743 var neg = this[offset] & 0x80
20744 if (neg)
20745 return (0xff - this[offset] + 1) * -1
20746 else
20747 return this[offset]
20748 }
20749
20750 function readInt16 (buf, offset, littleEndian, noAssert) {
20751 if (!noAssert) {
20752 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20753 assert(offset !== undefined && offset !== null, 'missing offset')
20754 assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
20755 }
20756
20757 var len = buf.length
20758 if (offset >= len)
20759 return
20760
20761 var val = readUInt16(buf, offset, littleEndian, true)
20762 var neg = val & 0x8000
20763 if (neg)
20764 return (0xffff - val + 1) * -1
20765 else
20766 return val
20767 }
20768
20769 Buffer.prototype.readInt16LE = function (offset, noAssert) {
20770 return readInt16(this, offset, true, noAssert)
20771 }
20772
20773 Buffer.prototype.readInt16BE = function (offset, noAssert) {
20774 return readInt16(this, offset, false, noAssert)
20775 }
20776
20777 function readInt32 (buf, offset, littleEndian, noAssert) {
20778 if (!noAssert) {
20779 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20780 assert(offset !== undefined && offset !== null, 'missing offset')
20781 assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
20782 }
20783
20784 var len = buf.length
20785 if (offset >= len)
20786 return
20787
20788 var val = readUInt32(buf, offset, littleEndian, true)
20789 var neg = val & 0x80000000
20790 if (neg)
20791 return (0xffffffff - val + 1) * -1
20792 else
20793 return val
20794 }
20795
20796 Buffer.prototype.readInt32LE = function (offset, noAssert) {
20797 return readInt32(this, offset, true, noAssert)
20798 }
20799
20800 Buffer.prototype.readInt32BE = function (offset, noAssert) {
20801 return readInt32(this, offset, false, noAssert)
20802 }
20803
20804 function readFloat (buf, offset, littleEndian, noAssert) {
20805 if (!noAssert) {
20806 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20807 assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
20808 }
20809
20810 return ieee754.read(buf, offset, littleEndian, 23, 4)
20811 }
20812
20813 Buffer.prototype.readFloatLE = function (offset, noAssert) {
20814 return readFloat(this, offset, true, noAssert)
20815 }
20816
20817 Buffer.prototype.readFloatBE = function (offset, noAssert) {
20818 return readFloat(this, offset, false, noAssert)
20819 }
20820
20821 function readDouble (buf, offset, littleEndian, noAssert) {
20822 if (!noAssert) {
20823 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20824 assert(offset + 7 < buf.length, 'Trying to read beyond buffer length')
20825 }
20826
20827 return ieee754.read(buf, offset, littleEndian, 52, 8)
20828 }
20829
20830 Buffer.prototype.readDoubleLE = function (offset, noAssert) {
20831 return readDouble(this, offset, true, noAssert)
20832 }
20833
20834 Buffer.prototype.readDoubleBE = function (offset, noAssert) {
20835 return readDouble(this, offset, false, noAssert)
20836 }
20837
20838 Buffer.prototype.writeUInt8 = function (value, offset, noAssert) {
20839 if (!noAssert) {
20840 assert(value !== undefined && value !== null, 'missing value')
20841 assert(offset !== undefined && offset !== null, 'missing offset')
20842 assert(offset < this.length, 'trying to write beyond buffer length')
20843 verifuint(value, 0xff)
20844 }
20845
20846 if (offset >= this.length) return
20847
20848 this[offset] = value
20849 return offset + 1
20850 }
20851
20852 function writeUInt16 (buf, value, offset, littleEndian, noAssert) {
20853 if (!noAssert) {
20854 assert(value !== undefined && value !== null, 'missing value')
20855 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20856 assert(offset !== undefined && offset !== null, 'missing offset')
20857 assert(offset + 1 < buf.length, 'trying to write beyond buffer length')
20858 verifuint(value, 0xffff)
20859 }
20860
20861 var len = buf.length
20862 if (offset >= len)
20863 return
20864
20865 for (var i = 0, j = Math.min(len - offset, 2); i < j; i++) {
20866 buf[offset + i] =
20867 (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
20868 (littleEndian ? i : 1 - i) * 8
20869 }
20870 return offset + 2
20871 }
20872
20873 Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) {
20874 return writeUInt16(this, value, offset, true, noAssert)
20875 }
20876
20877 Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) {
20878 return writeUInt16(this, value, offset, false, noAssert)
20879 }
20880
20881 function writeUInt32 (buf, value, offset, littleEndian, noAssert) {
20882 if (!noAssert) {
20883 assert(value !== undefined && value !== null, 'missing value')
20884 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20885 assert(offset !== undefined && offset !== null, 'missing offset')
20886 assert(offset + 3 < buf.length, 'trying to write beyond buffer length')
20887 verifuint(value, 0xffffffff)
20888 }
20889
20890 var len = buf.length
20891 if (offset >= len)
20892 return
20893
20894 for (var i = 0, j = Math.min(len - offset, 4); i < j; i++) {
20895 buf[offset + i] =
20896 (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
20897 }
20898 return offset + 4
20899 }
20900
20901 Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) {
20902 return writeUInt32(this, value, offset, true, noAssert)
20903 }
20904
20905 Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) {
20906 return writeUInt32(this, value, offset, false, noAssert)
20907 }
20908
20909 Buffer.prototype.writeInt8 = function (value, offset, noAssert) {
20910 if (!noAssert) {
20911 assert(value !== undefined && value !== null, 'missing value')
20912 assert(offset !== undefined && offset !== null, 'missing offset')
20913 assert(offset < this.length, 'Trying to write beyond buffer length')
20914 verifsint(value, 0x7f, -0x80)
20915 }
20916
20917 if (offset >= this.length)
20918 return
20919
20920 if (value >= 0)
20921 this.writeUInt8(value, offset, noAssert)
20922 else
20923 this.writeUInt8(0xff + value + 1, offset, noAssert)
20924 return offset + 1
20925 }
20926
20927 function writeInt16 (buf, value, offset, littleEndian, noAssert) {
20928 if (!noAssert) {
20929 assert(value !== undefined && value !== null, 'missing value')
20930 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20931 assert(offset !== undefined && offset !== null, 'missing offset')
20932 assert(offset + 1 < buf.length, 'Trying to write beyond buffer length')
20933 verifsint(value, 0x7fff, -0x8000)
20934 }
20935
20936 var len = buf.length
20937 if (offset >= len)
20938 return
20939
20940 if (value >= 0)
20941 writeUInt16(buf, value, offset, littleEndian, noAssert)
20942 else
20943 writeUInt16(buf, 0xffff + value + 1, offset, littleEndian, noAssert)
20944 return offset + 2
20945 }
20946
20947 Buffer.prototype.writeInt16LE = function (value, offset, noAssert) {
20948 return writeInt16(this, value, offset, true, noAssert)
20949 }
20950
20951 Buffer.prototype.writeInt16BE = function (value, offset, noAssert) {
20952 return writeInt16(this, value, offset, false, noAssert)
20953 }
20954
20955 function writeInt32 (buf, value, offset, littleEndian, noAssert) {
20956 if (!noAssert) {
20957 assert(value !== undefined && value !== null, 'missing value')
20958 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20959 assert(offset !== undefined && offset !== null, 'missing offset')
20960 assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
20961 verifsint(value, 0x7fffffff, -0x80000000)
20962 }
20963
20964 var len = buf.length
20965 if (offset >= len)
20966 return
20967
20968 if (value >= 0)
20969 writeUInt32(buf, value, offset, littleEndian, noAssert)
20970 else
20971 writeUInt32(buf, 0xffffffff + value + 1, offset, littleEndian, noAssert)
20972 return offset + 4
20973 }
20974
20975 Buffer.prototype.writeInt32LE = function (value, offset, noAssert) {
20976 return writeInt32(this, value, offset, true, noAssert)
20977 }
20978
20979 Buffer.prototype.writeInt32BE = function (value, offset, noAssert) {
20980 return writeInt32(this, value, offset, false, noAssert)
20981 }
20982
20983 function writeFloat (buf, value, offset, littleEndian, noAssert) {
20984 if (!noAssert) {
20985 assert(value !== undefined && value !== null, 'missing value')
20986 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20987 assert(offset !== undefined && offset !== null, 'missing offset')
20988 assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
20989 verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38)
20990 }
20991
20992 var len = buf.length
20993 if (offset >= len)
20994 return
20995
20996 ieee754.write(buf, value, offset, littleEndian, 23, 4)
20997 return offset + 4
20998 }
20999
21000 Buffer.prototype.writeFloatLE = function (value, offset, noAssert) {
21001 return writeFloat(this, value, offset, true, noAssert)
21002 }
21003
21004 Buffer.prototype.writeFloatBE = function (value, offset, noAssert) {
21005 return writeFloat(this, value, offset, false, noAssert)
21006 }
21007
21008 function writeDouble (buf, value, offset, littleEndian, noAssert) {
21009 if (!noAssert) {
21010 assert(value !== undefined && value !== null, 'missing value')
21011 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
21012 assert(offset !== undefined && offset !== null, 'missing offset')
21013 assert(offset + 7 < buf.length,
21014 'Trying to write beyond buffer length')
21015 verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308)
21016 }
21017
21018 var len = buf.length
21019 if (offset >= len)
21020 return
21021
21022 ieee754.write(buf, value, offset, littleEndian, 52, 8)
21023 return offset + 8
21024 }
21025
21026 Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) {
21027 return writeDouble(this, value, offset, true, noAssert)
21028 }
21029
21030 Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) {
21031 return writeDouble(this, value, offset, false, noAssert)
21032 }
21033
21034 // fill(value, start=0, end=buffer.length)
21035 Buffer.prototype.fill = function (value, start, end) {
21036 if (!value) value = 0
21037 if (!start) start = 0
21038 if (!end) end = this.length
21039
21040 assert(end >= start, 'end < start')
21041
21042 // Fill 0 bytes; we're done
21043 if (end === start) return
21044 if (this.length === 0) return
21045
21046 assert(start >= 0 && start < this.length, 'start out of bounds')
21047 assert(end >= 0 && end <= this.length, 'end out of bounds')
21048
21049 var i
21050 if (typeof value === 'number') {
21051 for (i = start; i < end; i++) {
21052 this[i] = value
21053 }
21054 } else {
21055 var bytes = utf8ToBytes(value.toString())
21056 var len = bytes.length
21057 for (i = start; i < end; i++) {
21058 this[i] = bytes[i % len]
21059 }
21060 }
21061
21062 return this
21063 }
21064
21065 Buffer.prototype.inspect = function () {
21066 var out = []
21067 var len = this.length
21068 for (var i = 0; i < len; i++) {
21069 out[i] = toHex(this[i])
21070 if (i === exports.INSPECT_MAX_BYTES) {
21071 out[i + 1] = '...'
21072 break
21073 }
21074 }
21075 return '<Buffer ' + out.join(' ') + '>'
21076 }
21077
21078 /**
21079 * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
21080 * Added in Node 0.12. Only available in browsers that support ArrayBuffer.
21081 */
21082 Buffer.prototype.toArrayBuffer = function () {
21083 if (typeof Uint8Array !== 'undefined') {
21084 if (Buffer._useTypedArrays) {
21085 return (new Buffer(this)).buffer
21086 } else {
21087 var buf = new Uint8Array(this.length)
21088 for (var i = 0, len = buf.length; i < len; i += 1) {
21089 buf[i] = this[i]
21090 }
21091 return buf.buffer
21092 }
21093 } else {
21094 throw new Error('Buffer.toArrayBuffer not supported in this browser')
21095 }
21096 }
21097
21098 // HELPER FUNCTIONS
21099 // ================
21100
21101 var BP = Buffer.prototype
21102
21103 /**
21104 * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
21105 */
21106 Buffer._augment = function (arr) {
21107 arr._isBuffer = true
21108
21109 // save reference to original Uint8Array get/set methods before overwriting
21110 arr._get = arr.get
21111 arr._set = arr.set
21112
21113 // deprecated, will be removed in node 0.13+
21114 arr.get = BP.get
21115 arr.set = BP.set
21116
21117 arr.write = BP.write
21118 arr.toString = BP.toString
21119 arr.toLocaleString = BP.toString
21120 arr.toJSON = BP.toJSON
21121 arr.equals = BP.equals
21122 arr.compare = BP.compare
21123 arr.copy = BP.copy
21124 arr.slice = BP.slice
21125 arr.readUInt8 = BP.readUInt8
21126 arr.readUInt16LE = BP.readUInt16LE
21127 arr.readUInt16BE = BP.readUInt16BE
21128 arr.readUInt32LE = BP.readUInt32LE
21129 arr.readUInt32BE = BP.readUInt32BE
21130 arr.readInt8 = BP.readInt8
21131 arr.readInt16LE = BP.readInt16LE
21132 arr.readInt16BE = BP.readInt16BE
21133 arr.readInt32LE = BP.readInt32LE
21134 arr.readInt32BE = BP.readInt32BE
21135 arr.readFloatLE = BP.readFloatLE
21136 arr.readFloatBE = BP.readFloatBE
21137 arr.readDoubleLE = BP.readDoubleLE
21138 arr.readDoubleBE = BP.readDoubleBE
21139 arr.writeUInt8 = BP.writeUInt8
21140 arr.writeUInt16LE = BP.writeUInt16LE
21141 arr.writeUInt16BE = BP.writeUInt16BE
21142 arr.writeUInt32LE = BP.writeUInt32LE
21143 arr.writeUInt32BE = BP.writeUInt32BE
21144 arr.writeInt8 = BP.writeInt8
21145 arr.writeInt16LE = BP.writeInt16LE
21146 arr.writeInt16BE = BP.writeInt16BE
21147 arr.writeInt32LE = BP.writeInt32LE
21148 arr.writeInt32BE = BP.writeInt32BE
21149 arr.writeFloatLE = BP.writeFloatLE
21150 arr.writeFloatBE = BP.writeFloatBE
21151 arr.writeDoubleLE = BP.writeDoubleLE
21152 arr.writeDoubleBE = BP.writeDoubleBE
21153 arr.fill = BP.fill
21154 arr.inspect = BP.inspect
21155 arr.toArrayBuffer = BP.toArrayBuffer
21156
21157 return arr
21158 }
21159
21160 var INVALID_BASE64_RE = /[^+\/0-9A-z]/g
21161
21162 function base64clean (str) {
21163 // Node strips out invalid characters like \n and \t from the string, base64-js does not
21164 str = stringtrim(str).replace(INVALID_BASE64_RE, '')
21165 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
21166 while (str.length % 4 !== 0) {
21167 str = str + '='
21168 }
21169 return str
21170 }
21171
21172 function stringtrim (str) {
21173 if (str.trim) return str.trim()
21174 return str.replace(/^\s+|\s+$/g, '')
21175 }
21176
21177 // slice(start, end)
21178 function clamp (index, len, defaultValue) {
21179 if (typeof index !== 'number') return defaultValue
21180 index = ~~index; // Coerce to integer.
21181 if (index >= len) return len
21182 if (index >= 0) return index
21183 index += len
21184 if (index >= 0) return index
21185 return 0
21186 }
21187
21188 function coerce (length) {
21189 // Coerce length to a number (possibly NaN), round up
21190 // in case it's fractional (e.g. 123.456) then do a
21191 // double negate to coerce a NaN to 0. Easy, right?
21192 length = ~~Math.ceil(+length)
21193 return length < 0 ? 0 : length
21194 }
21195
21196 function isArray (subject) {
21197 return (Array.isArray || function (subject) {
21198 return Object.prototype.toString.call(subject) === '[object Array]'
21199 })(subject)
21200 }
21201
21202 function isArrayish (subject) {
21203 return isArray(subject) || Buffer.isBuffer(subject) ||
21204 subject && typeof subject === 'object' &&
21205 typeof subject.length === 'number'
21206 }
21207
21208 function toHex (n) {
21209 if (n < 16) return '0' + n.toString(16)
21210 return n.toString(16)
21211 }
21212
21213 function utf8ToBytes (str) {
21214 var byteArray = []
21215 for (var i = 0; i < str.length; i++) {
21216 var b = str.charCodeAt(i)
21217 if (b <= 0x7F) {
21218 byteArray.push(b)
21219 } else {
21220 var start = i
21221 if (b >= 0xD800 && b <= 0xDFFF) i++
21222 var h = encodeURIComponent(str.slice(start, i+1)).substr(1).split('%')
21223 for (var j = 0; j < h.length; j++) {
21224 byteArray.push(parseInt(h[j], 16))
21225 }
21226 }
21227 }
21228 return byteArray
21229 }
21230
21231 function asciiToBytes (str) {
21232 var byteArray = []
21233 for (var i = 0; i < str.length; i++) {
21234 // Node's code seems to be doing this and not & 0x7F..
21235 byteArray.push(str.charCodeAt(i) & 0xFF)
21236 }
21237 return byteArray
21238 }
21239
21240 function utf16leToBytes (str) {
21241 var c, hi, lo
21242 var byteArray = []
21243 for (var i = 0; i < str.length; i++) {
21244 c = str.charCodeAt(i)
21245 hi = c >> 8
21246 lo = c % 256
21247 byteArray.push(lo)
21248 byteArray.push(hi)
21249 }
21250
21251 return byteArray
21252 }
21253
21254 function base64ToBytes (str) {
21255 return base64.toByteArray(str)
21256 }
21257
21258 function blitBuffer (src, dst, offset, length) {
21259 for (var i = 0; i < length; i++) {
21260 if ((i + offset >= dst.length) || (i >= src.length))
21261 break
21262 dst[i + offset] = src[i]
21263 }
21264 return i
21265 }
21266
21267 function decodeUtf8Char (str) {
21268 try {
21269 return decodeURIComponent(str)
21270 } catch (err) {
21271 return String.fromCharCode(0xFFFD) // UTF 8 invalid char
21272 }
21273 }
21274
21275 /*
21276 * We have to make sure that the value is a valid integer. This means that it
21277 * is non-negative. It has no fractional component and that it does not
21278 * exceed the maximum allowed value.
21279 */
21280 function verifuint (value, max) {
21281 assert(typeof value === 'number', 'cannot write a non-number as a number')
21282 assert(value >= 0, 'specified a negative value for writing an unsigned value')
21283 assert(value <= max, 'value is larger than maximum value for type')
21284 assert(Math.floor(value) === value, 'value has a fractional component')
21285 }
21286
21287 function verifsint (value, max, min) {
21288 assert(typeof value === 'number', 'cannot write a non-number as a number')
21289 assert(value <= max, 'value larger than maximum allowed value')
21290 assert(value >= min, 'value smaller than minimum allowed value')
21291 assert(Math.floor(value) === value, 'value has a fractional component')
21292 }
21293
21294 function verifIEEE754 (value, max, min) {
21295 assert(typeof value === 'number', 'cannot write a non-number as a number')
21296 assert(value <= max, 'value larger than maximum allowed value')
21297 assert(value >= min, 'value smaller than minimum allowed value')
21298 }
21299
21300 function assert (test, message) {
21301 if (!test) throw new Error(message || 'Failed assertion')
21302 }
21303
21304 },{"base64-js":9,"ieee754":10}],9:[function(_dereq_,module,exports){
21305 var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
21306
21307 ;(function (exports) {
21308 'use strict';
21309
21310 var Arr = (typeof Uint8Array !== 'undefined')
21311 ? Uint8Array
21312 : Array
21313
21314 var PLUS = '+'.charCodeAt(0)
21315 var SLASH = '/'.charCodeAt(0)
21316 var NUMBER = '0'.charCodeAt(0)
21317 var LOWER = 'a'.charCodeAt(0)
21318 var UPPER = 'A'.charCodeAt(0)
21319
21320 function decode (elt) {
21321 var code = elt.charCodeAt(0)
21322 if (code === PLUS)
21323 return 62 // '+'
21324 if (code === SLASH)
21325 return 63 // '/'
21326 if (code < NUMBER)
21327 return -1 //no match
21328 if (code < NUMBER + 10)
21329 return code - NUMBER + 26 + 26
21330 if (code < UPPER + 26)
21331 return code - UPPER
21332 if (code < LOWER + 26)
21333 return code - LOWER + 26
21334 }
21335
21336 function b64ToByteArray (b64) {
21337 var i, j, l, tmp, placeHolders, arr
21338
21339 if (b64.length % 4 > 0) {
21340 throw new Error('Invalid string. Length must be a multiple of 4')
21341 }
21342
21343 // the number of equal signs (place holders)
21344 // if there are two placeholders, than the two characters before it
21345 // represent one byte
21346 // if there is only one, then the three characters before it represent 2 bytes
21347 // this is just a cheap hack to not do indexOf twice
21348 var len = b64.length
21349 placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
21350
21351 // base64 is 4/3 + up to two characters of the original data
21352 arr = new Arr(b64.length * 3 / 4 - placeHolders)
21353
21354 // if there are placeholders, only get up to the last complete 4 chars
21355 l = placeHolders > 0 ? b64.length - 4 : b64.length
21356
21357 var L = 0
21358
21359 function push (v) {
21360 arr[L++] = v
21361 }
21362
21363 for (i = 0, j = 0; i < l; i += 4, j += 3) {
21364 tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
21365 push((tmp & 0xFF0000) >> 16)
21366 push((tmp & 0xFF00) >> 8)
21367 push(tmp & 0xFF)
21368 }
21369
21370 if (placeHolders === 2) {
21371 tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
21372 push(tmp & 0xFF)
21373 } else if (placeHolders === 1) {
21374 tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
21375 push((tmp >> 8) & 0xFF)
21376 push(tmp & 0xFF)
21377 }
21378
21379 return arr
21380 }
21381
21382 function uint8ToBase64 (uint8) {
21383 var i,
21384 extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
21385 output = "",
21386 temp, length
21387
21388 function encode (num) {
21389 return lookup.charAt(num)
21390 }
21391
21392 function tripletToBase64 (num) {
21393 return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
21394 }
21395
21396 // go through the array every three bytes, we'll deal with trailing stuff later
21397 for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
21398 temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
21399 output += tripletToBase64(temp)
21400 }
21401
21402 // pad the end with zeros, but make sure to not forget the extra bytes
21403 switch (extraBytes) {
21404 case 1:
21405 temp = uint8[uint8.length - 1]
21406 output += encode(temp >> 2)
21407 output += encode((temp << 4) & 0x3F)
21408 output += '=='
21409 break
21410 case 2:
21411 temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
21412 output += encode(temp >> 10)
21413 output += encode((temp >> 4) & 0x3F)
21414 output += encode((temp << 2) & 0x3F)
21415 output += '='
21416 break
21417 }
21418
21419 return output
21420 }
21421
21422 exports.toByteArray = b64ToByteArray
21423 exports.fromByteArray = uint8ToBase64
21424 }(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
21425
21426 },{}],10:[function(_dereq_,module,exports){
21427 exports.read = function(buffer, offset, isLE, mLen, nBytes) {
21428 var e, m,
21429 eLen = nBytes * 8 - mLen - 1,
21430 eMax = (1 << eLen) - 1,
21431 eBias = eMax >> 1,
21432 nBits = -7,
21433 i = isLE ? (nBytes - 1) : 0,
21434 d = isLE ? -1 : 1,
21435 s = buffer[offset + i];
21436
21437 i += d;
21438
21439 e = s & ((1 << (-nBits)) - 1);
21440 s >>= (-nBits);
21441 nBits += eLen;
21442 for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8){};
21443
21444 m = e & ((1 << (-nBits)) - 1);
21445 e >>= (-nBits);
21446 nBits += mLen;
21447 for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8){};
21448
21449 if (e === 0) {
21450 e = 1 - eBias;
21451 } else if (e === eMax) {
21452 return m ? NaN : ((s ? -1 : 1) * Infinity);
21453 } else {
21454 m = m + Math.pow(2, mLen);
21455 e = e - eBias;
21456 }
21457 return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
21458 };
21459
21460 exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
21461 var e, m, c,
21462 eLen = nBytes * 8 - mLen - 1,
21463 eMax = (1 << eLen) - 1,
21464 eBias = eMax >> 1,
21465 rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0),
21466 i = isLE ? 0 : (nBytes - 1),
21467 d = isLE ? 1 : -1,
21468 s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
21469
21470 value = Math.abs(value);
21471
21472 if (isNaN(value) || value === Infinity) {
21473 m = isNaN(value) ? 1 : 0;
21474 e = eMax;
21475 } else {
21476 e = Math.floor(Math.log(value) / Math.LN2);
21477 if (value * (c = Math.pow(2, -e)) < 1) {
21478 e--;
21479 c *= 2;
21480 }
21481 if (e + eBias >= 1) {
21482 value += rt / c;
21483 } else {
21484 value += rt * Math.pow(2, 1 - eBias);
21485 }
21486 if (value * c >= 2) {
21487 e++;
21488 c /= 2;
21489 }
21490
21491 if (e + eBias >= eMax) {
21492 m = 0;
21493 e = eMax;
21494 } else if (e + eBias >= 1) {
21495 m = (value * c - 1) * Math.pow(2, mLen);
21496 e = e + eBias;
21497 } else {
21498 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
21499 e = 0;
21500 }
21501 }
21502
21503 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8){};
21504
21505 e = (e << mLen) | m;
21506 eLen += mLen;
21507 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8){};
21508
21509 buffer[offset + i - d] |= s * 128;
21510 };
21511
21512 },{}],11:[function(_dereq_,module,exports){
21513 if (typeof Object.create === 'function') {
21514 // implementation from standard node.js 'util' module
21515 module.exports = function inherits(ctor, superCtor) {
21516 ctor.super_ = superCtor
21517 ctor.prototype = Object.create(superCtor.prototype, {
21518 constructor: {
21519 value: ctor,
21520 enumerable: false,
21521 writable: true,
21522 configurable: true
21523 }
21524 });
21525 };
21526 } else {
21527 // old school shim for old browsers
21528 module.exports = function inherits(ctor, superCtor) {
21529 ctor.super_ = superCtor
21530 var TempCtor = function () {}
21531 TempCtor.prototype = superCtor.prototype
21532 ctor.prototype = new TempCtor()
21533 ctor.prototype.constructor = ctor
21534 }
21535 }
21536
21537 },{}],12:[function(_dereq_,module,exports){
21538 // shim for using process in browser
21539
21540 var process = module.exports = {};
21541
21542 process.nextTick = (function () {
21543 var canSetImmediate = typeof window !== 'undefined'
21544 && window.setImmediate;
21545 var canPost = typeof window !== 'undefined'
21546 && window.postMessage && window.addEventListener
21547 ;
21548
21549 if (canSetImmediate) {
21550 return function (f) { return window.setImmediate(f) };
21551 }
21552
21553 if (canPost) {
21554 var queue = [];
21555 window.addEventListener('message', function (ev) {
21556 var source = ev.source;
21557 if ((source === window || source === null) && ev.data === 'process-tick') {
21558 ev.stopPropagation();
21559 if (queue.length > 0) {
21560 var fn = queue.shift();
21561 fn();
21562 }
21563 }
21564 }, true);
21565
21566 return function nextTick(fn) {
21567 queue.push(fn);
21568 window.postMessage('process-tick', '*');
21569 };
21570 }
21571
21572 return function nextTick(fn) {
21573 setTimeout(fn, 0);
21574 };
21575 })();
21576
21577 process.title = 'browser';
21578 process.browser = true;
21579 process.env = {};
21580 process.argv = [];
21581
21582 function noop() {}
21583
21584 process.on = noop;
21585 process.addListener = noop;
21586 process.once = noop;
21587 process.off = noop;
21588 process.removeListener = noop;
21589 process.removeAllListeners = noop;
21590 process.emit = noop;
21591
21592 process.binding = function (name) {
21593 throw new Error('process.binding is not supported');
21594 }
21595
21596 // TODO(shtylman)
21597 process.cwd = function () { return '/' };
21598 process.chdir = function (dir) {
21599 throw new Error('process.chdir is not supported');
21600 };
21601
21602 },{}],13:[function(_dereq_,module,exports){
21603 module.exports=_dereq_(5)
21604 },{}],14:[function(_dereq_,module,exports){
21605 module.exports=_dereq_(6)
21606 },{"./support/isBuffer":13,"FWaASH":12,"inherits":11}],15:[function(_dereq_,module,exports){
21607 (function (Buffer){
21608 // Base58 encoding/decoding
21609 // Originally written by Mike Hearn for BitcoinJ
21610 // Copyright (c) 2011 Google Inc
21611 // Ported to JavaScript by Stefan Thomas
21612 // Merged Buffer refactorings from base58-native by Stephen Pair
21613 // Copyright (c) 2013 BitPay Inc
21614
21615 var assert = _dereq_('assert')
21616 var BigInteger = _dereq_('bigi')
21617
21618 var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
21619 var ALPHABET_BUF = new Buffer(ALPHABET, 'ascii')
21620 var ALPHABET_MAP = {}
21621 for(var i = 0; i < ALPHABET.length; i++) {
21622 ALPHABET_MAP[ALPHABET.charAt(i)] = BigInteger.valueOf(i)
21623 }
21624 var BASE = new BigInteger('58')
21625
21626 function encode(buffer) {
21627 var bi = BigInteger.fromBuffer(buffer)
21628 var result = new Buffer(buffer.length << 1)
21629
21630 var i = result.length - 1
21631 while (bi.signum() > 0) {
21632 var remainder = bi.mod(BASE)
21633 bi = bi.divide(BASE)
21634
21635 result[i] = ALPHABET_BUF[remainder.intValue()]
21636 i--
21637 }
21638
21639 // deal with leading zeros
21640 var j = 0
21641 while (buffer[j] === 0) {
21642 result[i] = ALPHABET_BUF[0]
21643 j++
21644 i--
21645 }
21646
21647 return result.slice(i + 1, result.length).toString('ascii')
21648 }
21649
21650 function decode(string) {
21651 if (string.length === 0) return new Buffer(0)
21652
21653 var num = BigInteger.ZERO
21654
21655 for (var i = 0; i < string.length; i++) {
21656 num = num.multiply(BASE)
21657
21658 var figure = ALPHABET_MAP[string.charAt(i)]
21659 assert.notEqual(figure, undefined, 'Non-base58 character')
21660
21661 num = num.add(figure)
21662 }
21663
21664 // deal with leading zeros
21665 var j = 0
21666 while ((j < string.length) && (string[j] === ALPHABET[0])) {
21667 j++
21668 }
21669
21670 var buffer = num.toBuffer()
21671 var leadingZeros = new Buffer(j)
21672 leadingZeros.fill(0)
21673
21674 return Buffer.concat([leadingZeros, buffer])
21675 }
21676
21677 module.exports = {
21678 encode: encode,
21679 decode: decode
21680 }
21681
21682 }).call(this,_dereq_("buffer").Buffer)
21683 },{"assert":4,"bigi":3,"buffer":8}],16:[function(_dereq_,module,exports){
21684 (function (Buffer){
21685 var createHash = _dereq_('sha.js')
21686
21687 var md5 = toConstructor(_dereq_('./md5'))
21688 var rmd160 = toConstructor(_dereq_('ripemd160'))
21689
21690 function toConstructor (fn) {
21691 return function () {
21692 var buffers = []
21693 var m= {
21694 update: function (data, enc) {
21695 if(!Buffer.isBuffer(data)) data = new Buffer(data, enc)
21696 buffers.push(data)
21697 return this
21698 },
21699 digest: function (enc) {
21700 var buf = Buffer.concat(buffers)
21701 var r = fn(buf)
21702 buffers = null
21703 return enc ? r.toString(enc) : r
21704 }
21705 }
21706 return m
21707 }
21708 }
21709
21710 module.exports = function (alg) {
21711 if('md5' === alg) return new md5()
21712 if('rmd160' === alg) return new rmd160()
21713 return createHash(alg)
21714 }
21715
21716 }).call(this,_dereq_("buffer").Buffer)
21717 },{"./md5":20,"buffer":8,"ripemd160":21,"sha.js":23}],17:[function(_dereq_,module,exports){
21718 (function (Buffer){
21719 var createHash = _dereq_('./create-hash')
21720
21721 var blocksize = 64
21722 var zeroBuffer = new Buffer(blocksize); zeroBuffer.fill(0)
21723
21724 module.exports = Hmac
21725
21726 function Hmac (alg, key) {
21727 if(!(this instanceof Hmac)) return new Hmac(alg, key)
21728 this._opad = opad
21729 this._alg = alg
21730
21731 key = this._key = !Buffer.isBuffer(key) ? new Buffer(key) : key
21732
21733 if(key.length > blocksize) {
21734 key = createHash(alg).update(key).digest()
21735 } else if(key.length < blocksize) {
21736 key = Buffer.concat([key, zeroBuffer], blocksize)
21737 }
21738
21739 var ipad = this._ipad = new Buffer(blocksize)
21740 var opad = this._opad = new Buffer(blocksize)
21741
21742 for(var i = 0; i < blocksize; i++) {
21743 ipad[i] = key[i] ^ 0x36
21744 opad[i] = key[i] ^ 0x5C
21745 }
21746
21747 this._hash = createHash(alg).update(ipad)
21748 }
21749
21750 Hmac.prototype.update = function (data, enc) {
21751 this._hash.update(data, enc)
21752 return this
21753 }
21754
21755 Hmac.prototype.digest = function (enc) {
21756 var h = this._hash.digest()
21757 return createHash(this._alg).update(this._opad).update(h).digest(enc)
21758 }
21759
21760
21761 }).call(this,_dereq_("buffer").Buffer)
21762 },{"./create-hash":16,"buffer":8}],18:[function(_dereq_,module,exports){
21763 (function (Buffer){
21764 var intSize = 4;
21765 var zeroBuffer = new Buffer(intSize); zeroBuffer.fill(0);
21766 var chrsz = 8;
21767
21768 function toArray(buf, bigEndian) {
21769 if ((buf.length % intSize) !== 0) {
21770 var len = buf.length + (intSize - (buf.length % intSize));
21771 buf = Buffer.concat([buf, zeroBuffer], len);
21772 }
21773
21774 var arr = [];
21775 var fn = bigEndian ? buf.readInt32BE : buf.readInt32LE;
21776 for (var i = 0; i < buf.length; i += intSize) {
21777 arr.push(fn.call(buf, i));
21778 }
21779 return arr;
21780 }
21781
21782 function toBuffer(arr, size, bigEndian) {
21783 var buf = new Buffer(size);
21784 var fn = bigEndian ? buf.writeInt32BE : buf.writeInt32LE;
21785 for (var i = 0; i < arr.length; i++) {
21786 fn.call(buf, arr[i], i * 4, true);
21787 }
21788 return buf;
21789 }
21790
21791 function hash(buf, fn, hashSize, bigEndian) {
21792 if (!Buffer.isBuffer(buf)) buf = new Buffer(buf);
21793 var arr = fn(toArray(buf, bigEndian), buf.length * chrsz);
21794 return toBuffer(arr, hashSize, bigEndian);
21795 }
21796
21797 module.exports = { hash: hash };
21798
21799 }).call(this,_dereq_("buffer").Buffer)
21800 },{"buffer":8}],19:[function(_dereq_,module,exports){
21801 (function (Buffer){
21802 var rng = _dereq_('./rng')
21803
21804 function error () {
21805 var m = [].slice.call(arguments).join(' ')
21806 throw new Error([
21807 m,
21808 'we accept pull requests',
21809 'http://github.com/dominictarr/crypto-browserify'
21810 ].join('\n'))
21811 }
21812
21813 exports.createHash = _dereq_('./create-hash')
21814
21815 exports.createHmac = _dereq_('./create-hmac')
21816
21817 exports.randomBytes = function(size, callback) {
21818 if (callback && callback.call) {
21819 try {
21820 callback.call(this, undefined, new Buffer(rng(size)))
21821 } catch (err) { callback(err) }
21822 } else {
21823 return new Buffer(rng(size))
21824 }
21825 }
21826
21827 function each(a, f) {
21828 for(var i in a)
21829 f(a[i], i)
21830 }
21831
21832 exports.getHashes = function () {
21833 return ['sha1', 'sha256', 'md5', 'rmd160']
21834
21835 }
21836
21837 var p = _dereq_('./pbkdf2')(exports.createHmac)
21838 exports.pbkdf2 = p.pbkdf2
21839 exports.pbkdf2Sync = p.pbkdf2Sync
21840
21841
21842 // the least I can do is make error messages for the rest of the node.js/crypto api.
21843 each(['createCredentials'
21844 , 'createCipher'
21845 , 'createCipheriv'
21846 , 'createDecipher'
21847 , 'createDecipheriv'
21848 , 'createSign'
21849 , 'createVerify'
21850 , 'createDiffieHellman'
21851 ], function (name) {
21852 exports[name] = function () {
21853 error('sorry,', name, 'is not implemented yet')
21854 }
21855 })
21856
21857 }).call(this,_dereq_("buffer").Buffer)
21858 },{"./create-hash":16,"./create-hmac":17,"./pbkdf2":27,"./rng":28,"buffer":8}],20:[function(_dereq_,module,exports){
21859 /*
21860 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
21861 * Digest Algorithm, as defined in RFC 1321.
21862 * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
21863 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
21864 * Distributed under the BSD License
21865 * See http://pajhome.org.uk/crypt/md5 for more info.
21866 */
21867
21868 var helpers = _dereq_('./helpers');
21869
21870 /*
21871 * Calculate the MD5 of an array of little-endian words, and a bit length
21872 */
21873 function core_md5(x, len)
21874 {
21875 /* append padding */
21876 x[len >> 5] |= 0x80 << ((len) % 32);
21877 x[(((len + 64) >>> 9) << 4) + 14] = len;
21878
21879 var a = 1732584193;
21880 var b = -271733879;
21881 var c = -1732584194;
21882 var d = 271733878;
21883
21884 for(var i = 0; i < x.length; i += 16)
21885 {
21886 var olda = a;
21887 var oldb = b;
21888 var oldc = c;
21889 var oldd = d;
21890
21891 a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
21892 d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
21893 c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
21894 b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
21895 a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
21896 d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
21897 c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
21898 b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
21899 a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
21900 d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
21901 c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
21902 b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
21903 a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
21904 d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
21905 c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
21906 b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
21907
21908 a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
21909 d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
21910 c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
21911 b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
21912 a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
21913 d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
21914 c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
21915 b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
21916 a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
21917 d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
21918 c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
21919 b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
21920 a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
21921 d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
21922 c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
21923 b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
21924
21925 a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
21926 d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
21927 c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
21928 b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
21929 a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
21930 d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
21931 c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
21932 b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
21933 a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
21934 d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
21935 c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
21936 b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
21937 a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
21938 d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
21939 c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
21940 b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
21941
21942 a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
21943 d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
21944 c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
21945 b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
21946 a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
21947 d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
21948 c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
21949 b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
21950 a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
21951 d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
21952 c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
21953 b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
21954 a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
21955 d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
21956 c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
21957 b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
21958
21959 a = safe_add(a, olda);
21960 b = safe_add(b, oldb);
21961 c = safe_add(c, oldc);
21962 d = safe_add(d, oldd);
21963 }
21964 return Array(a, b, c, d);
21965
21966 }
21967
21968 /*
21969 * These functions implement the four basic operations the algorithm uses.
21970 */
21971 function md5_cmn(q, a, b, x, s, t)
21972 {
21973 return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
21974 }
21975 function md5_ff(a, b, c, d, x, s, t)
21976 {
21977 return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
21978 }
21979 function md5_gg(a, b, c, d, x, s, t)
21980 {
21981 return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
21982 }
21983 function md5_hh(a, b, c, d, x, s, t)
21984 {
21985 return md5_cmn(b ^ c ^ d, a, b, x, s, t);
21986 }
21987 function md5_ii(a, b, c, d, x, s, t)
21988 {
21989 return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
21990 }
21991
21992 /*
21993 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
21994 * to work around bugs in some JS interpreters.
21995 */
21996 function safe_add(x, y)
21997 {
21998 var lsw = (x & 0xFFFF) + (y & 0xFFFF);
21999 var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
22000 return (msw << 16) | (lsw & 0xFFFF);
22001 }
22002
22003 /*
22004 * Bitwise rotate a 32-bit number to the left.
22005 */
22006 function bit_rol(num, cnt)
22007 {
22008 return (num << cnt) | (num >>> (32 - cnt));
22009 }
22010
22011 module.exports = function md5(buf) {
22012 return helpers.hash(buf, core_md5, 16);
22013 };
22014
22015 },{"./helpers":18}],21:[function(_dereq_,module,exports){
22016 (function (Buffer){
22017
22018 module.exports = ripemd160
22019
22020
22021
22022 /*
22023 CryptoJS v3.1.2
22024 code.google.com/p/crypto-js
22025 (c) 2009-2013 by Jeff Mott. All rights reserved.
22026 code.google.com/p/crypto-js/wiki/License
22027 */
22028 /** @preserve
22029 (c) 2012 by Cédric Mesnil. All rights reserved.
22030
22031 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
22032
22033 - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
22034 - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
22035
22036 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22037 */
22038
22039 // Constants table
22040 var zl = [
22041 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
22042 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
22043 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
22044 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
22045 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13];
22046 var zr = [
22047 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
22048 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
22049 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
22050 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
22051 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11];
22052 var sl = [
22053 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
22054 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
22055 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
22056 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
22057 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ];
22058 var sr = [
22059 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
22060 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
22061 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
22062 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
22063 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ];
22064
22065 var hl = [ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E];
22066 var hr = [ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000];
22067
22068 var bytesToWords = function (bytes) {
22069 var words = [];
22070 for (var i = 0, b = 0; i < bytes.length; i++, b += 8) {
22071 words[b >>> 5] |= bytes[i] << (24 - b % 32);
22072 }
22073 return words;
22074 };
22075
22076 var wordsToBytes = function (words) {
22077 var bytes = [];
22078 for (var b = 0; b < words.length * 32; b += 8) {
22079 bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF);
22080 }
22081 return bytes;
22082 };
22083
22084 var processBlock = function (H, M, offset) {
22085
22086 // Swap endian
22087 for (var i = 0; i < 16; i++) {
22088 var offset_i = offset + i;
22089 var M_offset_i = M[offset_i];
22090
22091 // Swap
22092 M[offset_i] = (
22093 (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
22094 (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
22095 );
22096 }
22097
22098 // Working variables
22099 var al, bl, cl, dl, el;
22100 var ar, br, cr, dr, er;
22101
22102 ar = al = H[0];
22103 br = bl = H[1];
22104 cr = cl = H[2];
22105 dr = dl = H[3];
22106 er = el = H[4];
22107 // Computation
22108 var t;
22109 for (var i = 0; i < 80; i += 1) {
22110 t = (al + M[offset+zl[i]])|0;
22111 if (i<16){
22112 t += f1(bl,cl,dl) + hl[0];
22113 } else if (i<32) {
22114 t += f2(bl,cl,dl) + hl[1];
22115 } else if (i<48) {
22116 t += f3(bl,cl,dl) + hl[2];
22117 } else if (i<64) {
22118 t += f4(bl,cl,dl) + hl[3];
22119 } else {// if (i<80) {
22120 t += f5(bl,cl,dl) + hl[4];
22121 }
22122 t = t|0;
22123 t = rotl(t,sl[i]);
22124 t = (t+el)|0;
22125 al = el;
22126 el = dl;
22127 dl = rotl(cl, 10);
22128 cl = bl;
22129 bl = t;
22130
22131 t = (ar + M[offset+zr[i]])|0;
22132 if (i<16){
22133 t += f5(br,cr,dr) + hr[0];
22134 } else if (i<32) {
22135 t += f4(br,cr,dr) + hr[1];
22136 } else if (i<48) {
22137 t += f3(br,cr,dr) + hr[2];
22138 } else if (i<64) {
22139 t += f2(br,cr,dr) + hr[3];
22140 } else {// if (i<80) {
22141 t += f1(br,cr,dr) + hr[4];
22142 }
22143 t = t|0;
22144 t = rotl(t,sr[i]) ;
22145 t = (t+er)|0;
22146 ar = er;
22147 er = dr;
22148 dr = rotl(cr, 10);
22149 cr = br;
22150 br = t;
22151 }
22152 // Intermediate hash value
22153 t = (H[1] + cl + dr)|0;
22154 H[1] = (H[2] + dl + er)|0;
22155 H[2] = (H[3] + el + ar)|0;
22156 H[3] = (H[4] + al + br)|0;
22157 H[4] = (H[0] + bl + cr)|0;
22158 H[0] = t;
22159 };
22160
22161 function f1(x, y, z) {
22162 return ((x) ^ (y) ^ (z));
22163 }
22164
22165 function f2(x, y, z) {
22166 return (((x)&(y)) | ((~x)&(z)));
22167 }
22168
22169 function f3(x, y, z) {
22170 return (((x) | (~(y))) ^ (z));
22171 }
22172
22173 function f4(x, y, z) {
22174 return (((x) & (z)) | ((y)&(~(z))));
22175 }
22176
22177 function f5(x, y, z) {
22178 return ((x) ^ ((y) |(~(z))));
22179 }
22180
22181 function rotl(x,n) {
22182 return (x<<n) | (x>>>(32-n));
22183 }
22184
22185 function ripemd160(message) {
22186 var H = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0];
22187
22188 if (typeof message == 'string')
22189 message = new Buffer(message, 'utf8');
22190
22191 var m = bytesToWords(message);
22192
22193 var nBitsLeft = message.length * 8;
22194 var nBitsTotal = message.length * 8;
22195
22196 // Add padding
22197 m[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
22198 m[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
22199 (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
22200 (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)
22201 );
22202
22203 for (var i=0 ; i<m.length; i += 16) {
22204 processBlock(H, m, i);
22205 }
22206
22207 // Swap endian
22208 for (var i = 0; i < 5; i++) {
22209 // Shortcut
22210 var H_i = H[i];
22211
22212 // Swap
22213 H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
22214 (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
22215 }
22216
22217 var digestbytes = wordsToBytes(H);
22218 return new Buffer(digestbytes);
22219 }
22220
22221
22222
22223 }).call(this,_dereq_("buffer").Buffer)
22224 },{"buffer":8}],22:[function(_dereq_,module,exports){
22225 var u = _dereq_('./util')
22226 var write = u.write
22227 var fill = u.zeroFill
22228
22229 module.exports = function (Buffer) {
22230
22231 //prototype class for hash functions
22232 function Hash (blockSize, finalSize) {
22233 this._block = new Buffer(blockSize) //new Uint32Array(blockSize/4)
22234 this._finalSize = finalSize
22235 this._blockSize = blockSize
22236 this._len = 0
22237 this._s = 0
22238 }
22239
22240 Hash.prototype.init = function () {
22241 this._s = 0
22242 this._len = 0
22243 }
22244
22245 function lengthOf(data, enc) {
22246 if(enc == null) return data.byteLength || data.length
22247 if(enc == 'ascii' || enc == 'binary') return data.length
22248 if(enc == 'hex') return data.length/2
22249 if(enc == 'base64') return data.length/3
22250 }
22251
22252 Hash.prototype.update = function (data, enc) {
22253 var bl = this._blockSize
22254
22255 //I'd rather do this with a streaming encoder, like the opposite of
22256 //http://nodejs.org/api/string_decoder.html
22257 var length
22258 if(!enc && 'string' === typeof data)
22259 enc = 'utf8'
22260
22261 if(enc) {
22262 if(enc === 'utf-8')
22263 enc = 'utf8'
22264
22265 if(enc === 'base64' || enc === 'utf8')
22266 data = new Buffer(data, enc), enc = null
22267
22268 length = lengthOf(data, enc)
22269 } else
22270 length = data.byteLength || data.length
22271
22272 var l = this._len += length
22273 var s = this._s = (this._s || 0)
22274 var f = 0
22275 var buffer = this._block
22276 while(s < l) {
22277 var t = Math.min(length, f + bl)
22278 write(buffer, data, enc, s%bl, f, t)
22279 var ch = (t - f);
22280 s += ch; f += ch
22281
22282 if(!(s%bl))
22283 this._update(buffer)
22284 }
22285 this._s = s
22286
22287 return this
22288
22289 }
22290
22291 Hash.prototype.digest = function (enc) {
22292 var bl = this._blockSize
22293 var fl = this._finalSize
22294 var len = this._len*8
22295
22296 var x = this._block
22297
22298 var bits = len % (bl*8)
22299
22300 //add end marker, so that appending 0's creats a different hash.
22301 x[this._len % bl] = 0x80
22302 fill(this._block, this._len % bl + 1)
22303
22304 if(bits >= fl*8) {
22305 this._update(this._block)
22306 u.zeroFill(this._block, 0)
22307 }
22308
22309 //TODO: handle case where the bit length is > Math.pow(2, 29)
22310 x.writeInt32BE(len, fl + 4) //big endian
22311
22312 var hash = this._update(this._block) || this._hash()
22313 if(enc == null) return hash
22314 return hash.toString(enc)
22315 }
22316
22317 Hash.prototype._update = function () {
22318 throw new Error('_update must be implemented by subclass')
22319 }
22320
22321 return Hash
22322 }
22323
22324 },{"./util":26}],23:[function(_dereq_,module,exports){
22325 var exports = module.exports = function (alg) {
22326 var Alg = exports[alg]
22327 if(!Alg) throw new Error(alg + ' is not supported (we accept pull requests)')
22328 return new Alg()
22329 }
22330
22331 var Buffer = _dereq_('buffer').Buffer
22332 var Hash = _dereq_('./hash')(Buffer)
22333
22334 exports.sha =
22335 exports.sha1 = _dereq_('./sha1')(Buffer, Hash)
22336 exports.sha256 = _dereq_('./sha256')(Buffer, Hash)
22337
22338 },{"./hash":22,"./sha1":24,"./sha256":25,"buffer":8}],24:[function(_dereq_,module,exports){
22339 /*
22340 * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
22341 * in FIPS PUB 180-1
22342 * Version 2.1a Copyright Paul Johnston 2000 - 2002.
22343 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
22344 * Distributed under the BSD License
22345 * See http://pajhome.org.uk/crypt/md5 for details.
22346 */
22347 module.exports = function (Buffer, Hash) {
22348
22349 var inherits = _dereq_('util').inherits
22350
22351 inherits(Sha1, Hash)
22352
22353 var A = 0|0
22354 var B = 4|0
22355 var C = 8|0
22356 var D = 12|0
22357 var E = 16|0
22358
22359 var BE = false
22360 var LE = true
22361
22362 var W = new Int32Array(80)
22363
22364 var POOL = []
22365
22366 function Sha1 () {
22367 if(POOL.length)
22368 return POOL.pop().init()
22369
22370 if(!(this instanceof Sha1)) return new Sha1()
22371 this._w = W
22372 Hash.call(this, 16*4, 14*4)
22373
22374 this._h = null
22375 this.init()
22376 }
22377
22378 Sha1.prototype.init = function () {
22379 this._a = 0x67452301
22380 this._b = 0xefcdab89
22381 this._c = 0x98badcfe
22382 this._d = 0x10325476
22383 this._e = 0xc3d2e1f0
22384
22385 Hash.prototype.init.call(this)
22386 return this
22387 }
22388
22389 Sha1.prototype._POOL = POOL
22390
22391 // assume that array is a Uint32Array with length=16,
22392 // and that if it is the last block, it already has the length and the 1 bit appended.
22393
22394
22395 var isDV = new Buffer(1) instanceof DataView
22396 function readInt32BE (X, i) {
22397 return isDV
22398 ? X.getInt32(i, false)
22399 : X.readInt32BE(i)
22400 }
22401
22402 Sha1.prototype._update = function (array) {
22403
22404 var X = this._block
22405 var h = this._h
22406 var a, b, c, d, e, _a, _b, _c, _d, _e
22407
22408 a = _a = this._a
22409 b = _b = this._b
22410 c = _c = this._c
22411 d = _d = this._d
22412 e = _e = this._e
22413
22414 var w = this._w
22415
22416 for(var j = 0; j < 80; j++) {
22417 var W = w[j]
22418 = j < 16
22419 //? X.getInt32(j*4, false)
22420 //? readInt32BE(X, j*4) //*/ X.readInt32BE(j*4) //*/
22421 ? X.readInt32BE(j*4)
22422 : rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1)
22423
22424 var t =
22425 add(
22426 add(rol(a, 5), sha1_ft(j, b, c, d)),
22427 add(add(e, W), sha1_kt(j))
22428 );
22429
22430 e = d
22431 d = c
22432 c = rol(b, 30)
22433 b = a
22434 a = t
22435 }
22436
22437 this._a = add(a, _a)
22438 this._b = add(b, _b)
22439 this._c = add(c, _c)
22440 this._d = add(d, _d)
22441 this._e = add(e, _e)
22442 }
22443
22444 Sha1.prototype._hash = function () {
22445 if(POOL.length < 100) POOL.push(this)
22446 var H = new Buffer(20)
22447 //console.log(this._a|0, this._b|0, this._c|0, this._d|0, this._e|0)
22448 H.writeInt32BE(this._a|0, A)
22449 H.writeInt32BE(this._b|0, B)
22450 H.writeInt32BE(this._c|0, C)
22451 H.writeInt32BE(this._d|0, D)
22452 H.writeInt32BE(this._e|0, E)
22453 return H
22454 }
22455
22456 /*
22457 * Perform the appropriate triplet combination function for the current
22458 * iteration
22459 */
22460 function sha1_ft(t, b, c, d) {
22461 if(t < 20) return (b & c) | ((~b) & d);
22462 if(t < 40) return b ^ c ^ d;
22463 if(t < 60) return (b & c) | (b & d) | (c & d);
22464 return b ^ c ^ d;
22465 }
22466
22467 /*
22468 * Determine the appropriate additive constant for the current iteration
22469 */
22470 function sha1_kt(t) {
22471 return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :
22472 (t < 60) ? -1894007588 : -899497514;
22473 }
22474
22475 /*
22476 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
22477 * to work around bugs in some JS interpreters.
22478 * //dominictarr: this is 10 years old, so maybe this can be dropped?)
22479 *
22480 */
22481 function add(x, y) {
22482 return (x + y ) | 0
22483 //lets see how this goes on testling.
22484 // var lsw = (x & 0xFFFF) + (y & 0xFFFF);
22485 // var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
22486 // return (msw << 16) | (lsw & 0xFFFF);
22487 }
22488
22489 /*
22490 * Bitwise rotate a 32-bit number to the left.
22491 */
22492 function rol(num, cnt) {
22493 return (num << cnt) | (num >>> (32 - cnt));
22494 }
22495
22496 return Sha1
22497 }
22498
22499 },{"util":14}],25:[function(_dereq_,module,exports){
22500
22501 /**
22502 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
22503 * in FIPS 180-2
22504 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
22505 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
22506 *
22507 */
22508
22509 var inherits = _dereq_('util').inherits
22510 var BE = false
22511 var LE = true
22512 var u = _dereq_('./util')
22513
22514 module.exports = function (Buffer, Hash) {
22515
22516 var K = [
22517 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
22518 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
22519 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
22520 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
22521 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
22522 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
22523 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
22524 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
22525 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
22526 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
22527 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
22528 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
22529 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
22530 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
22531 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
22532 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
22533 ]
22534
22535 inherits(Sha256, Hash)
22536 var W = new Array(64)
22537 var POOL = []
22538 function Sha256() {
22539 // Closure compiler warning - this code lacks side effects - thus commented out
22540 // if(POOL.length) {
22541 // return POOL.shift().init()
22542 // }
22543 //this._data = new Buffer(32)
22544
22545 this.init()
22546
22547 this._w = W //new Array(64)
22548
22549 Hash.call(this, 16*4, 14*4)
22550 };
22551
22552 Sha256.prototype.init = function () {
22553
22554 this._a = 0x6a09e667|0
22555 this._b = 0xbb67ae85|0
22556 this._c = 0x3c6ef372|0
22557 this._d = 0xa54ff53a|0
22558 this._e = 0x510e527f|0
22559 this._f = 0x9b05688c|0
22560 this._g = 0x1f83d9ab|0
22561 this._h = 0x5be0cd19|0
22562
22563 this._len = this._s = 0
22564
22565 return this
22566 }
22567
22568 var safe_add = function(x, y) {
22569 var lsw = (x & 0xFFFF) + (y & 0xFFFF);
22570 var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
22571 return (msw << 16) | (lsw & 0xFFFF);
22572 }
22573
22574 function S (X, n) {
22575 return (X >>> n) | (X << (32 - n));
22576 }
22577
22578 function R (X, n) {
22579 return (X >>> n);
22580 }
22581
22582 function Ch (x, y, z) {
22583 return ((x & y) ^ ((~x) & z));
22584 }
22585
22586 function Maj (x, y, z) {
22587 return ((x & y) ^ (x & z) ^ (y & z));
22588 }
22589
22590 function Sigma0256 (x) {
22591 return (S(x, 2) ^ S(x, 13) ^ S(x, 22));
22592 }
22593
22594 function Sigma1256 (x) {
22595 return (S(x, 6) ^ S(x, 11) ^ S(x, 25));
22596 }
22597
22598 function Gamma0256 (x) {
22599 return (S(x, 7) ^ S(x, 18) ^ R(x, 3));
22600 }
22601
22602 function Gamma1256 (x) {
22603 return (S(x, 17) ^ S(x, 19) ^ R(x, 10));
22604 }
22605
22606 Sha256.prototype._update = function(m) {
22607 var M = this._block
22608 var W = this._w
22609 var a, b, c, d, e, f, g, h
22610 var T1, T2
22611
22612 a = this._a | 0
22613 b = this._b | 0
22614 c = this._c | 0
22615 d = this._d | 0
22616 e = this._e | 0
22617 f = this._f | 0
22618 g = this._g | 0
22619 h = this._h | 0
22620
22621 for (var j = 0; j < 64; j++) {
22622 var w = W[j] = j < 16
22623 ? M.readInt32BE(j * 4)
22624 : Gamma1256(W[j - 2]) + W[j - 7] + Gamma0256(W[j - 15]) + W[j - 16]
22625
22626 T1 = h + Sigma1256(e) + Ch(e, f, g) + K[j] + w
22627
22628 T2 = Sigma0256(a) + Maj(a, b, c);
22629 h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2;
22630 }
22631
22632 this._a = (a + this._a) | 0
22633 this._b = (b + this._b) | 0
22634 this._c = (c + this._c) | 0
22635 this._d = (d + this._d) | 0
22636 this._e = (e + this._e) | 0
22637 this._f = (f + this._f) | 0
22638 this._g = (g + this._g) | 0
22639 this._h = (h + this._h) | 0
22640
22641 };
22642
22643 Sha256.prototype._hash = function () {
22644 if(POOL.length < 10)
22645 POOL.push(this)
22646
22647 var H = new Buffer(32)
22648
22649 H.writeInt32BE(this._a, 0)
22650 H.writeInt32BE(this._b, 4)
22651 H.writeInt32BE(this._c, 8)
22652 H.writeInt32BE(this._d, 12)
22653 H.writeInt32BE(this._e, 16)
22654 H.writeInt32BE(this._f, 20)
22655 H.writeInt32BE(this._g, 24)
22656 H.writeInt32BE(this._h, 28)
22657
22658 return H
22659 }
22660
22661 return Sha256
22662
22663 }
22664
22665 },{"./util":26,"util":14}],26:[function(_dereq_,module,exports){
22666 exports.write = write
22667 exports.zeroFill = zeroFill
22668
22669 exports.toString = toString
22670
22671 function write (buffer, string, enc, start, from, to, LE) {
22672 var l = (to - from)
22673 if(enc === 'ascii' || enc === 'binary') {
22674 for( var i = 0; i < l; i++) {
22675 buffer[start + i] = string.charCodeAt(i + from)
22676 }
22677 }
22678 else if(enc == null) {
22679 for( var i = 0; i < l; i++) {
22680 buffer[start + i] = string[i + from]
22681 }
22682 }
22683 else if(enc === 'hex') {
22684 for(var i = 0; i < l; i++) {
22685 var j = from + i
22686 buffer[start + i] = parseInt(string[j*2] + string[(j*2)+1], 16)
22687 }
22688 }
22689 else if(enc === 'base64') {
22690 throw new Error('base64 encoding not yet supported')
22691 }
22692 else
22693 throw new Error(enc +' encoding not yet supported')
22694 }
22695
22696 //always fill to the end!
22697 function zeroFill(buf, from) {
22698 for(var i = from; i < buf.length; i++)
22699 buf[i] = 0
22700 }
22701
22702
22703 },{}],27:[function(_dereq_,module,exports){
22704 (function (Buffer){
22705 // JavaScript PBKDF2 Implementation
22706 // Based on http://git.io/qsv2zw
22707 // Licensed under LGPL v3
22708 // Copyright (c) 2013 jduncanator
22709
22710 var blocksize = 64
22711 var zeroBuffer = new Buffer(blocksize); zeroBuffer.fill(0)
22712
22713 module.exports = function (createHmac, exports) {
22714 exports = exports || {}
22715
22716 exports.pbkdf2 = function(password, salt, iterations, keylen, cb) {
22717 if('function' !== typeof cb)
22718 throw new Error('No callback provided to pbkdf2');
22719 setTimeout(function () {
22720 cb(null, exports.pbkdf2Sync(password, salt, iterations, keylen))
22721 })
22722 }
22723
22724 exports.pbkdf2Sync = function(key, salt, iterations, keylen) {
22725 if('number' !== typeof iterations)
22726 throw new TypeError('Iterations not a number')
22727 if(iterations < 0)
22728 throw new TypeError('Bad iterations')
22729 if('number' !== typeof keylen)
22730 throw new TypeError('Key length not a number')
22731 if(keylen < 0)
22732 throw new TypeError('Bad key length')
22733
22734 //stretch key to the correct length that hmac wants it,
22735 //otherwise this will happen every time hmac is called
22736 //twice per iteration.
22737 var key = !Buffer.isBuffer(key) ? new Buffer(key) : key
22738
22739 if(key.length > blocksize) {
22740 key = createHash(alg).update(key).digest()
22741 } else if(key.length < blocksize) {
22742 key = Buffer.concat([key, zeroBuffer], blocksize)
22743 }
22744
22745 var HMAC;
22746 var cplen, p = 0, i = 1, itmp = new Buffer(4), digtmp;
22747 var out = new Buffer(keylen);
22748 out.fill(0);
22749 while(keylen) {
22750 if(keylen > 20)
22751 cplen = 20;
22752 else
22753 cplen = keylen;
22754
22755 /* We are unlikely to ever use more than 256 blocks (5120 bits!)
22756 * but just in case...
22757 */
22758 itmp[0] = (i >> 24) & 0xff;
22759 itmp[1] = (i >> 16) & 0xff;
22760 itmp[2] = (i >> 8) & 0xff;
22761 itmp[3] = i & 0xff;
22762
22763 HMAC = createHmac('sha1', key);
22764 HMAC.update(salt)
22765 HMAC.update(itmp);
22766 digtmp = HMAC.digest();
22767 digtmp.copy(out, p, 0, cplen);
22768
22769 for(var j = 1; j < iterations; j++) {
22770 HMAC = createHmac('sha1', key);
22771 HMAC.update(digtmp);
22772 digtmp = HMAC.digest();
22773 for(var k = 0; k < cplen; k++) {
22774 out[k] ^= digtmp[k];
22775 }
22776 }
22777 keylen -= cplen;
22778 i++;
22779 p += cplen;
22780 }
22781
22782 return out;
22783 }
22784
22785 return exports
22786 }
22787
22788 }).call(this,_dereq_("buffer").Buffer)
22789 },{"buffer":8}],28:[function(_dereq_,module,exports){
22790 (function (Buffer){
22791 // Original code adapted from Robert Kieffer.
22792 // details at https://github.com/broofa/node-uuid
22793
22794
22795 (function() {
22796 var _global = this;
22797
22798 var mathRNG, whatwgRNG;
22799
22800 // NOTE: Math.random() does not guarantee "cryptographic quality"
22801 mathRNG = function(size) {
22802 var bytes = new Buffer(size);
22803 var r;
22804
22805 for (var i = 0, r; i < size; i++) {
22806 if ((i & 0x03) == 0) r = Math.random() * 0x100000000;
22807 bytes[i] = r >>> ((i & 0x03) << 3) & 0xff;
22808 }
22809
22810 return bytes;
22811 }
22812
22813 if (_global.crypto && crypto.getRandomValues) {
22814 whatwgRNG = function(size) {
22815 var bytes = new Buffer(size); //in browserify, this is an extended Uint8Array
22816 crypto.getRandomValues(bytes);
22817 return bytes;
22818 }
22819 }
22820
22821 module.exports = whatwgRNG || mathRNG;
22822
22823 }())
22824
22825 }).call(this,_dereq_("buffer").Buffer)
22826 },{"buffer":8}],29:[function(_dereq_,module,exports){
22827 ;(function (root, factory, undef) {
22828 if (typeof exports === "object") {
22829 // CommonJS
22830 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
22831 }
22832 else if (typeof define === "function" && define.amd) {
22833 // AMD
22834 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
22835 }
22836 else {
22837 // Global (browser)
22838 factory(root.CryptoJS);
22839 }
22840 }(this, function (CryptoJS) {
22841
22842 (function () {
22843 // Shortcuts
22844 var C = CryptoJS;
22845 var C_lib = C.lib;
22846 var BlockCipher = C_lib.BlockCipher;
22847 var C_algo = C.algo;
22848
22849 // Lookup tables
22850 var SBOX = [];
22851 var INV_SBOX = [];
22852 var SUB_MIX_0 = [];
22853 var SUB_MIX_1 = [];
22854 var SUB_MIX_2 = [];
22855 var SUB_MIX_3 = [];
22856 var INV_SUB_MIX_0 = [];
22857 var INV_SUB_MIX_1 = [];
22858 var INV_SUB_MIX_2 = [];
22859 var INV_SUB_MIX_3 = [];
22860
22861 // Compute lookup tables
22862 (function () {
22863 // Compute double table
22864 var d = [];
22865 for (var i = 0; i < 256; i++) {
22866 if (i < 128) {
22867 d[i] = i << 1;
22868 } else {
22869 d[i] = (i << 1) ^ 0x11b;
22870 }
22871 }
22872
22873 // Walk GF(2^8)
22874 var x = 0;
22875 var xi = 0;
22876 for (var i = 0; i < 256; i++) {
22877 // Compute sbox
22878 var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
22879 sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
22880 SBOX[x] = sx;
22881 INV_SBOX[sx] = x;
22882
22883 // Compute multiplication
22884 var x2 = d[x];
22885 var x4 = d[x2];
22886 var x8 = d[x4];
22887
22888 // Compute sub bytes, mix columns tables
22889 var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
22890 SUB_MIX_0[x] = (t << 24) | (t >>> 8);
22891 SUB_MIX_1[x] = (t << 16) | (t >>> 16);
22892 SUB_MIX_2[x] = (t << 8) | (t >>> 24);
22893 SUB_MIX_3[x] = t;
22894
22895 // Compute inv sub bytes, inv mix columns tables
22896 var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
22897 INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
22898 INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
22899 INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
22900 INV_SUB_MIX_3[sx] = t;
22901
22902 // Compute next counter
22903 if (!x) {
22904 x = xi = 1;
22905 } else {
22906 x = x2 ^ d[d[d[x8 ^ x2]]];
22907 xi ^= d[d[xi]];
22908 }
22909 }
22910 }());
22911
22912 // Precomputed Rcon lookup
22913 var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
22914
22915 /**
22916 * AES block cipher algorithm.
22917 */
22918 var AES = C_algo.AES = BlockCipher.extend({
22919 _doReset: function () {
22920 // Shortcuts
22921 var key = this._key;
22922 var keyWords = key.words;
22923 var keySize = key.sigBytes / 4;
22924
22925 // Compute number of rounds
22926 var nRounds = this._nRounds = keySize + 6
22927
22928 // Compute number of key schedule rows
22929 var ksRows = (nRounds + 1) * 4;
22930
22931 // Compute key schedule
22932 var keySchedule = this._keySchedule = [];
22933 for (var ksRow = 0; ksRow < ksRows; ksRow++) {
22934 if (ksRow < keySize) {
22935 keySchedule[ksRow] = keyWords[ksRow];
22936 } else {
22937 var t = keySchedule[ksRow - 1];
22938
22939 if (!(ksRow % keySize)) {
22940 // Rot word
22941 t = (t << 8) | (t >>> 24);
22942
22943 // Sub word
22944 t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
22945
22946 // Mix Rcon
22947 t ^= RCON[(ksRow / keySize) | 0] << 24;
22948 } else if (keySize > 6 && ksRow % keySize == 4) {
22949 // Sub word
22950 t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
22951 }
22952
22953 keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
22954 }
22955 }
22956
22957 // Compute inv key schedule
22958 var invKeySchedule = this._invKeySchedule = [];
22959 for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
22960 var ksRow = ksRows - invKsRow;
22961
22962 if (invKsRow % 4) {
22963 var t = keySchedule[ksRow];
22964 } else {
22965 var t = keySchedule[ksRow - 4];
22966 }
22967
22968 if (invKsRow < 4 || ksRow <= 4) {
22969 invKeySchedule[invKsRow] = t;
22970 } else {
22971 invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
22972 INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
22973 }
22974 }
22975 },
22976
22977 encryptBlock: function (M, offset) {
22978 this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
22979 },
22980
22981 decryptBlock: function (M, offset) {
22982 // Swap 2nd and 4th rows
22983 var t = M[offset + 1];
22984 M[offset + 1] = M[offset + 3];
22985 M[offset + 3] = t;
22986
22987 this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
22988
22989 // Inv swap 2nd and 4th rows
22990 var t = M[offset + 1];
22991 M[offset + 1] = M[offset + 3];
22992 M[offset + 3] = t;
22993 },
22994
22995 _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
22996 // Shortcut
22997 var nRounds = this._nRounds;
22998
22999 // Get input, add round key
23000 var s0 = M[offset] ^ keySchedule[0];
23001 var s1 = M[offset + 1] ^ keySchedule[1];
23002 var s2 = M[offset + 2] ^ keySchedule[2];
23003 var s3 = M[offset + 3] ^ keySchedule[3];
23004
23005 // Key schedule row counter
23006 var ksRow = 4;
23007
23008 // Rounds
23009 for (var round = 1; round < nRounds; round++) {
23010 // Shift rows, sub bytes, mix columns, add round key
23011 var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++];
23012 var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++];
23013 var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++];
23014 var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++];
23015
23016 // Update state
23017 s0 = t0;
23018 s1 = t1;
23019 s2 = t2;
23020 s3 = t3;
23021 }
23022
23023 // Shift rows, sub bytes, add round key
23024 var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
23025 var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
23026 var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
23027 var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
23028
23029 // Set output
23030 M[offset] = t0;
23031 M[offset + 1] = t1;
23032 M[offset + 2] = t2;
23033 M[offset + 3] = t3;
23034 },
23035
23036 keySize: 256/32
23037 });
23038
23039 /**
23040 * Shortcut functions to the cipher's object interface.
23041 *
23042 * @example
23043 *
23044 * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
23045 * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
23046 */
23047 C.AES = BlockCipher._createHelper(AES);
23048 }());
23049
23050
23051 return CryptoJS.AES;
23052
23053 }));
23054 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],30:[function(_dereq_,module,exports){
23055 ;(function (root, factory) {
23056 if (typeof exports === "object") {
23057 // CommonJS
23058 module.exports = exports = factory(_dereq_("./core"));
23059 }
23060 else if (typeof define === "function" && define.amd) {
23061 // AMD
23062 define(["./core"], factory);
23063 }
23064 else {
23065 // Global (browser)
23066 factory(root.CryptoJS);
23067 }
23068 }(this, function (CryptoJS) {
23069
23070 /**
23071 * Cipher core components.
23072 */
23073 CryptoJS.lib.Cipher || (function (undefined) {
23074 // Shortcuts
23075 var C = CryptoJS;
23076 var C_lib = C.lib;
23077 var Base = C_lib.Base;
23078 var WordArray = C_lib.WordArray;
23079 var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
23080 var C_enc = C.enc;
23081 var Utf8 = C_enc.Utf8;
23082 var Base64 = C_enc.Base64;
23083 var C_algo = C.algo;
23084 var EvpKDF = C_algo.EvpKDF;
23085
23086 /**
23087 * Abstract base cipher template.
23088 *
23089 * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
23090 * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
23091 * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
23092 * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
23093 */
23094 var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
23095 /**
23096 * Configuration options.
23097 *
23098 * @property {WordArray} iv The IV to use for this operation.
23099 */
23100 cfg: Base.extend(),
23101
23102 /**
23103 * Creates this cipher in encryption mode.
23104 *
23105 * @param {WordArray} key The key.
23106 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23107 *
23108 * @return {Cipher} A cipher instance.
23109 *
23110 * @static
23111 *
23112 * @example
23113 *
23114 * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
23115 */
23116 createEncryptor: function (key, cfg) {
23117 return this.create(this._ENC_XFORM_MODE, key, cfg);
23118 },
23119
23120 /**
23121 * Creates this cipher in decryption mode.
23122 *
23123 * @param {WordArray} key The key.
23124 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23125 *
23126 * @return {Cipher} A cipher instance.
23127 *
23128 * @static
23129 *
23130 * @example
23131 *
23132 * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
23133 */
23134 createDecryptor: function (key, cfg) {
23135 return this.create(this._DEC_XFORM_MODE, key, cfg);
23136 },
23137
23138 /**
23139 * Initializes a newly created cipher.
23140 *
23141 * @param {number} xformMode Either the encryption or decryption transormation mode constant.
23142 * @param {WordArray} key The key.
23143 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23144 *
23145 * @example
23146 *
23147 * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
23148 */
23149 init: function (xformMode, key, cfg) {
23150 // Apply config defaults
23151 this.cfg = this.cfg.extend(cfg);
23152
23153 // Store transform mode and key
23154 this._xformMode = xformMode;
23155 this._key = key;
23156
23157 // Set initial values
23158 this.reset();
23159 },
23160
23161 /**
23162 * Resets this cipher to its initial state.
23163 *
23164 * @example
23165 *
23166 * cipher.reset();
23167 */
23168 reset: function () {
23169 // Reset data buffer
23170 BufferedBlockAlgorithm.reset.call(this);
23171
23172 // Perform concrete-cipher logic
23173 this._doReset();
23174 },
23175
23176 /**
23177 * Adds data to be encrypted or decrypted.
23178 *
23179 * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
23180 *
23181 * @return {WordArray} The data after processing.
23182 *
23183 * @example
23184 *
23185 * var encrypted = cipher.process('data');
23186 * var encrypted = cipher.process(wordArray);
23187 */
23188 process: function (dataUpdate) {
23189 // Append
23190 this._append(dataUpdate);
23191
23192 // Process available blocks
23193 return this._process();
23194 },
23195
23196 /**
23197 * Finalizes the encryption or decryption process.
23198 * Note that the finalize operation is effectively a destructive, read-once operation.
23199 *
23200 * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
23201 *
23202 * @return {WordArray} The data after final processing.
23203 *
23204 * @example
23205 *
23206 * var encrypted = cipher.finalize();
23207 * var encrypted = cipher.finalize('data');
23208 * var encrypted = cipher.finalize(wordArray);
23209 */
23210 finalize: function (dataUpdate) {
23211 // Final data update
23212 if (dataUpdate) {
23213 this._append(dataUpdate);
23214 }
23215
23216 // Perform concrete-cipher logic
23217 var finalProcessedData = this._doFinalize();
23218
23219 return finalProcessedData;
23220 },
23221
23222 keySize: 128/32,
23223
23224 ivSize: 128/32,
23225
23226 _ENC_XFORM_MODE: 1,
23227
23228 _DEC_XFORM_MODE: 2,
23229
23230 /**
23231 * Creates shortcut functions to a cipher's object interface.
23232 *
23233 * @param {Cipher} cipher The cipher to create a helper for.
23234 *
23235 * @return {Object} An object with encrypt and decrypt shortcut functions.
23236 *
23237 * @static
23238 *
23239 * @example
23240 *
23241 * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
23242 */
23243 _createHelper: (function () {
23244 function selectCipherStrategy(key) {
23245 if (typeof key == 'string') {
23246 return PasswordBasedCipher;
23247 } else {
23248 return SerializableCipher;
23249 }
23250 }
23251
23252 return function (cipher) {
23253 return {
23254 encrypt: function (message, key, cfg) {
23255 return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
23256 },
23257
23258 decrypt: function (ciphertext, key, cfg) {
23259 return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
23260 }
23261 };
23262 };
23263 }())
23264 });
23265
23266 /**
23267 * Abstract base stream cipher template.
23268 *
23269 * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
23270 */
23271 var StreamCipher = C_lib.StreamCipher = Cipher.extend({
23272 _doFinalize: function () {
23273 // Process partial blocks
23274 var finalProcessedBlocks = this._process(!!'flush');
23275
23276 return finalProcessedBlocks;
23277 },
23278
23279 blockSize: 1
23280 });
23281
23282 /**
23283 * Mode namespace.
23284 */
23285 var C_mode = C.mode = {};
23286
23287 /**
23288 * Abstract base block cipher mode template.
23289 */
23290 var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
23291 /**
23292 * Creates this mode for encryption.
23293 *
23294 * @param {Cipher} cipher A block cipher instance.
23295 * @param {Array} iv The IV words.
23296 *
23297 * @static
23298 *
23299 * @example
23300 *
23301 * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
23302 */
23303 createEncryptor: function (cipher, iv) {
23304 return this.Encryptor.create(cipher, iv);
23305 },
23306
23307 /**
23308 * Creates this mode for decryption.
23309 *
23310 * @param {Cipher} cipher A block cipher instance.
23311 * @param {Array} iv The IV words.
23312 *
23313 * @static
23314 *
23315 * @example
23316 *
23317 * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
23318 */
23319 createDecryptor: function (cipher, iv) {
23320 return this.Decryptor.create(cipher, iv);
23321 },
23322
23323 /**
23324 * Initializes a newly created mode.
23325 *
23326 * @param {Cipher} cipher A block cipher instance.
23327 * @param {Array} iv The IV words.
23328 *
23329 * @example
23330 *
23331 * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
23332 */
23333 init: function (cipher, iv) {
23334 this._cipher = cipher;
23335 this._iv = iv;
23336 }
23337 });
23338
23339 /**
23340 * Cipher Block Chaining mode.
23341 */
23342 var CBC = C_mode.CBC = (function () {
23343 /**
23344 * Abstract base CBC mode.
23345 */
23346 var CBC = BlockCipherMode.extend();
23347
23348 /**
23349 * CBC encryptor.
23350 */
23351 CBC.Encryptor = CBC.extend({
23352 /**
23353 * Processes the data block at offset.
23354 *
23355 * @param {Array} words The data words to operate on.
23356 * @param {number} offset The offset where the block starts.
23357 *
23358 * @example
23359 *
23360 * mode.processBlock(data.words, offset);
23361 */
23362 processBlock: function (words, offset) {
23363 // Shortcuts
23364 var cipher = this._cipher;
23365 var blockSize = cipher.blockSize;
23366
23367 // XOR and encrypt
23368 xorBlock.call(this, words, offset, blockSize);
23369 cipher.encryptBlock(words, offset);
23370
23371 // Remember this block to use with next block
23372 this._prevBlock = words.slice(offset, offset + blockSize);
23373 }
23374 });
23375
23376 /**
23377 * CBC decryptor.
23378 */
23379 CBC.Decryptor = CBC.extend({
23380 /**
23381 * Processes the data block at offset.
23382 *
23383 * @param {Array} words The data words to operate on.
23384 * @param {number} offset The offset where the block starts.
23385 *
23386 * @example
23387 *
23388 * mode.processBlock(data.words, offset);
23389 */
23390 processBlock: function (words, offset) {
23391 // Shortcuts
23392 var cipher = this._cipher;
23393 var blockSize = cipher.blockSize;
23394
23395 // Remember this block to use with next block
23396 var thisBlock = words.slice(offset, offset + blockSize);
23397
23398 // Decrypt and XOR
23399 cipher.decryptBlock(words, offset);
23400 xorBlock.call(this, words, offset, blockSize);
23401
23402 // This block becomes the previous block
23403 this._prevBlock = thisBlock;
23404 }
23405 });
23406
23407 function xorBlock(words, offset, blockSize) {
23408 // Shortcut
23409 var iv = this._iv;
23410
23411 // Choose mixing block
23412 if (iv) {
23413 var block = iv;
23414
23415 // Remove IV for subsequent blocks
23416 this._iv = undefined;
23417 } else {
23418 var block = this._prevBlock;
23419 }
23420
23421 // XOR blocks
23422 for (var i = 0; i < blockSize; i++) {
23423 words[offset + i] ^= block[i];
23424 }
23425 }
23426
23427 return CBC;
23428 }());
23429
23430 /**
23431 * Padding namespace.
23432 */
23433 var C_pad = C.pad = {};
23434
23435 /**
23436 * PKCS #5/7 padding strategy.
23437 */
23438 var Pkcs7 = C_pad.Pkcs7 = {
23439 /**
23440 * Pads data using the algorithm defined in PKCS #5/7.
23441 *
23442 * @param {WordArray} data The data to pad.
23443 * @param {number} blockSize The multiple that the data should be padded to.
23444 *
23445 * @static
23446 *
23447 * @example
23448 *
23449 * CryptoJS.pad.Pkcs7.pad(wordArray, 4);
23450 */
23451 pad: function (data, blockSize) {
23452 // Shortcut
23453 var blockSizeBytes = blockSize * 4;
23454
23455 // Count padding bytes
23456 var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
23457
23458 // Create padding word
23459 var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
23460
23461 // Create padding
23462 var paddingWords = [];
23463 for (var i = 0; i < nPaddingBytes; i += 4) {
23464 paddingWords.push(paddingWord);
23465 }
23466 var padding = WordArray.create(paddingWords, nPaddingBytes);
23467
23468 // Add padding
23469 data.concat(padding);
23470 },
23471
23472 /**
23473 * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
23474 *
23475 * @param {WordArray} data The data to unpad.
23476 *
23477 * @static
23478 *
23479 * @example
23480 *
23481 * CryptoJS.pad.Pkcs7.unpad(wordArray);
23482 */
23483 unpad: function (data) {
23484 // Get number of padding bytes from last byte
23485 var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
23486
23487 // Remove padding
23488 data.sigBytes -= nPaddingBytes;
23489 }
23490 };
23491
23492 /**
23493 * Abstract base block cipher template.
23494 *
23495 * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
23496 */
23497 var BlockCipher = C_lib.BlockCipher = Cipher.extend({
23498 /**
23499 * Configuration options.
23500 *
23501 * @property {Mode} mode The block mode to use. Default: CBC
23502 * @property {Padding} padding The padding strategy to use. Default: Pkcs7
23503 */
23504 cfg: Cipher.cfg.extend({
23505 mode: CBC,
23506 padding: Pkcs7
23507 }),
23508
23509 reset: function () {
23510 // Reset cipher
23511 Cipher.reset.call(this);
23512
23513 // Shortcuts
23514 var cfg = this.cfg;
23515 var iv = cfg.iv;
23516 var mode = cfg.mode;
23517
23518 // Reset block mode
23519 if (this._xformMode == this._ENC_XFORM_MODE) {
23520 var modeCreator = mode.createEncryptor;
23521 } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
23522 var modeCreator = mode.createDecryptor;
23523
23524 // Keep at least one block in the buffer for unpadding
23525 this._minBufferSize = 1;
23526 }
23527 this._mode = modeCreator.call(mode, this, iv && iv.words);
23528 },
23529
23530 _doProcessBlock: function (words, offset) {
23531 this._mode.processBlock(words, offset);
23532 },
23533
23534 _doFinalize: function () {
23535 // Shortcut
23536 var padding = this.cfg.padding;
23537
23538 // Finalize
23539 if (this._xformMode == this._ENC_XFORM_MODE) {
23540 // Pad data
23541 padding.pad(this._data, this.blockSize);
23542
23543 // Process final blocks
23544 var finalProcessedBlocks = this._process(!!'flush');
23545 } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
23546 // Process final blocks
23547 var finalProcessedBlocks = this._process(!!'flush');
23548
23549 // Unpad data
23550 padding.unpad(finalProcessedBlocks);
23551 }
23552
23553 return finalProcessedBlocks;
23554 },
23555
23556 blockSize: 128/32
23557 });
23558
23559 /**
23560 * A collection of cipher parameters.
23561 *
23562 * @property {WordArray} ciphertext The raw ciphertext.
23563 * @property {WordArray} key The key to this ciphertext.
23564 * @property {WordArray} iv The IV used in the ciphering operation.
23565 * @property {WordArray} salt The salt used with a key derivation function.
23566 * @property {Cipher} algorithm The cipher algorithm.
23567 * @property {Mode} mode The block mode used in the ciphering operation.
23568 * @property {Padding} padding The padding scheme used in the ciphering operation.
23569 * @property {number} blockSize The block size of the cipher.
23570 * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
23571 */
23572 var CipherParams = C_lib.CipherParams = Base.extend({
23573 /**
23574 * Initializes a newly created cipher params object.
23575 *
23576 * @param {Object} cipherParams An object with any of the possible cipher parameters.
23577 *
23578 * @example
23579 *
23580 * var cipherParams = CryptoJS.lib.CipherParams.create({
23581 * ciphertext: ciphertextWordArray,
23582 * key: keyWordArray,
23583 * iv: ivWordArray,
23584 * salt: saltWordArray,
23585 * algorithm: CryptoJS.algo.AES,
23586 * mode: CryptoJS.mode.CBC,
23587 * padding: CryptoJS.pad.PKCS7,
23588 * blockSize: 4,
23589 * formatter: CryptoJS.format.OpenSSL
23590 * });
23591 */
23592 init: function (cipherParams) {
23593 this.mixIn(cipherParams);
23594 },
23595
23596 /**
23597 * Converts this cipher params object to a string.
23598 *
23599 * @param {Format} formatter (Optional) The formatting strategy to use.
23600 *
23601 * @return {string} The stringified cipher params.
23602 *
23603 * @throws Error If neither the formatter nor the default formatter is set.
23604 *
23605 * @example
23606 *
23607 * var string = cipherParams + '';
23608 * var string = cipherParams.toString();
23609 * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
23610 */
23611 toString: function (formatter) {
23612 return (formatter || this.formatter).stringify(this);
23613 }
23614 });
23615
23616 /**
23617 * Format namespace.
23618 */
23619 var C_format = C.format = {};
23620
23621 /**
23622 * OpenSSL formatting strategy.
23623 */
23624 var OpenSSLFormatter = C_format.OpenSSL = {
23625 /**
23626 * Converts a cipher params object to an OpenSSL-compatible string.
23627 *
23628 * @param {CipherParams} cipherParams The cipher params object.
23629 *
23630 * @return {string} The OpenSSL-compatible string.
23631 *
23632 * @static
23633 *
23634 * @example
23635 *
23636 * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
23637 */
23638 stringify: function (cipherParams) {
23639 // Shortcuts
23640 var ciphertext = cipherParams.ciphertext;
23641 var salt = cipherParams.salt;
23642
23643 // Format
23644 if (salt) {
23645 var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
23646 } else {
23647 var wordArray = ciphertext;
23648 }
23649
23650 return wordArray.toString(Base64);
23651 },
23652
23653 /**
23654 * Converts an OpenSSL-compatible string to a cipher params object.
23655 *
23656 * @param {string} openSSLStr The OpenSSL-compatible string.
23657 *
23658 * @return {CipherParams} The cipher params object.
23659 *
23660 * @static
23661 *
23662 * @example
23663 *
23664 * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
23665 */
23666 parse: function (openSSLStr) {
23667 // Parse base64
23668 var ciphertext = Base64.parse(openSSLStr);
23669
23670 // Shortcut
23671 var ciphertextWords = ciphertext.words;
23672
23673 // Test for salt
23674 if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
23675 // Extract salt
23676 var salt = WordArray.create(ciphertextWords.slice(2, 4));
23677
23678 // Remove salt from ciphertext
23679 ciphertextWords.splice(0, 4);
23680 ciphertext.sigBytes -= 16;
23681 }
23682
23683 return CipherParams.create({ ciphertext: ciphertext, salt: salt });
23684 }
23685 };
23686
23687 /**
23688 * A cipher wrapper that returns ciphertext as a serializable cipher params object.
23689 */
23690 var SerializableCipher = C_lib.SerializableCipher = Base.extend({
23691 /**
23692 * Configuration options.
23693 *
23694 * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
23695 */
23696 cfg: Base.extend({
23697 format: OpenSSLFormatter
23698 }),
23699
23700 /**
23701 * Encrypts a message.
23702 *
23703 * @param {Cipher} cipher The cipher algorithm to use.
23704 * @param {WordArray|string} message The message to encrypt.
23705 * @param {WordArray} key The key.
23706 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23707 *
23708 * @return {CipherParams} A cipher params object.
23709 *
23710 * @static
23711 *
23712 * @example
23713 *
23714 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
23715 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
23716 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
23717 */
23718 encrypt: function (cipher, message, key, cfg) {
23719 // Apply config defaults
23720 cfg = this.cfg.extend(cfg);
23721
23722 // Encrypt
23723 var encryptor = cipher.createEncryptor(key, cfg);
23724 var ciphertext = encryptor.finalize(message);
23725
23726 // Shortcut
23727 var cipherCfg = encryptor.cfg;
23728
23729 // Create and return serializable cipher params
23730 return CipherParams.create({
23731 ciphertext: ciphertext,
23732 key: key,
23733 iv: cipherCfg.iv,
23734 algorithm: cipher,
23735 mode: cipherCfg.mode,
23736 padding: cipherCfg.padding,
23737 blockSize: cipher.blockSize,
23738 formatter: cfg.format
23739 });
23740 },
23741
23742 /**
23743 * Decrypts serialized ciphertext.
23744 *
23745 * @param {Cipher} cipher The cipher algorithm to use.
23746 * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
23747 * @param {WordArray} key The key.
23748 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23749 *
23750 * @return {WordArray} The plaintext.
23751 *
23752 * @static
23753 *
23754 * @example
23755 *
23756 * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
23757 * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
23758 */
23759 decrypt: function (cipher, ciphertext, key, cfg) {
23760 // Apply config defaults
23761 cfg = this.cfg.extend(cfg);
23762
23763 // Convert string to CipherParams
23764 ciphertext = this._parse(ciphertext, cfg.format);
23765
23766 // Decrypt
23767 var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
23768
23769 return plaintext;
23770 },
23771
23772 /**
23773 * Converts serialized ciphertext to CipherParams,
23774 * else assumed CipherParams already and returns ciphertext unchanged.
23775 *
23776 * @param {CipherParams|string} ciphertext The ciphertext.
23777 * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
23778 *
23779 * @return {CipherParams} The unserialized ciphertext.
23780 *
23781 * @static
23782 *
23783 * @example
23784 *
23785 * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
23786 */
23787 _parse: function (ciphertext, format) {
23788 if (typeof ciphertext == 'string') {
23789 return format.parse(ciphertext, this);
23790 } else {
23791 return ciphertext;
23792 }
23793 }
23794 });
23795
23796 /**
23797 * Key derivation function namespace.
23798 */
23799 var C_kdf = C.kdf = {};
23800
23801 /**
23802 * OpenSSL key derivation function.
23803 */
23804 var OpenSSLKdf = C_kdf.OpenSSL = {
23805 /**
23806 * Derives a key and IV from a password.
23807 *
23808 * @param {string} password The password to derive from.
23809 * @param {number} keySize The size in words of the key to generate.
23810 * @param {number} ivSize The size in words of the IV to generate.
23811 * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
23812 *
23813 * @return {CipherParams} A cipher params object with the key, IV, and salt.
23814 *
23815 * @static
23816 *
23817 * @example
23818 *
23819 * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
23820 * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
23821 */
23822 execute: function (password, keySize, ivSize, salt) {
23823 // Generate random salt
23824 if (!salt) {
23825 salt = WordArray.random(64/8);
23826 }
23827
23828 // Derive key and IV
23829 var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
23830
23831 // Separate key and IV
23832 var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
23833 key.sigBytes = keySize * 4;
23834
23835 // Return params
23836 return CipherParams.create({ key: key, iv: iv, salt: salt });
23837 }
23838 };
23839
23840 /**
23841 * A serializable cipher wrapper that derives the key from a password,
23842 * and returns ciphertext as a serializable cipher params object.
23843 */
23844 var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
23845 /**
23846 * Configuration options.
23847 *
23848 * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
23849 */
23850 cfg: SerializableCipher.cfg.extend({
23851 kdf: OpenSSLKdf
23852 }),
23853
23854 /**
23855 * Encrypts a message using a password.
23856 *
23857 * @param {Cipher} cipher The cipher algorithm to use.
23858 * @param {WordArray|string} message The message to encrypt.
23859 * @param {string} password The password.
23860 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23861 *
23862 * @return {CipherParams} A cipher params object.
23863 *
23864 * @static
23865 *
23866 * @example
23867 *
23868 * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
23869 * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
23870 */
23871 encrypt: function (cipher, message, password, cfg) {
23872 // Apply config defaults
23873 cfg = this.cfg.extend(cfg);
23874
23875 // Derive key and other params
23876 var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
23877
23878 // Add IV to config
23879 cfg.iv = derivedParams.iv;
23880
23881 // Encrypt
23882 var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
23883
23884 // Mix in derived params
23885 ciphertext.mixIn(derivedParams);
23886
23887 return ciphertext;
23888 },
23889
23890 /**
23891 * Decrypts serialized ciphertext using a password.
23892 *
23893 * @param {Cipher} cipher The cipher algorithm to use.
23894 * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
23895 * @param {string} password The password.
23896 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23897 *
23898 * @return {WordArray} The plaintext.
23899 *
23900 * @static
23901 *
23902 * @example
23903 *
23904 * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
23905 * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
23906 */
23907 decrypt: function (cipher, ciphertext, password, cfg) {
23908 // Apply config defaults
23909 cfg = this.cfg.extend(cfg);
23910
23911 // Convert string to CipherParams
23912 ciphertext = this._parse(ciphertext, cfg.format);
23913
23914 // Derive key and other params
23915 var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
23916
23917 // Add IV to config
23918 cfg.iv = derivedParams.iv;
23919
23920 // Decrypt
23921 var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
23922
23923 return plaintext;
23924 }
23925 });
23926 }());
23927
23928
23929 }));
23930 },{"./core":31}],31:[function(_dereq_,module,exports){
23931 ;(function (root, factory) {
23932 if (typeof exports === "object") {
23933 // CommonJS
23934 module.exports = exports = factory();
23935 }
23936 else if (typeof define === "function" && define.amd) {
23937 // AMD
23938 define([], factory);
23939 }
23940 else {
23941 // Global (browser)
23942 root.CryptoJS = factory();
23943 }
23944 }(this, function () {
23945
23946 /**
23947 * CryptoJS core components.
23948 */
23949 var CryptoJS = CryptoJS || (function (Math, undefined) {
23950 /**
23951 * CryptoJS namespace.
23952 */
23953 var C = {};
23954
23955 /**
23956 * Library namespace.
23957 */
23958 var C_lib = C.lib = {};
23959
23960 /**
23961 * Base object for prototypal inheritance.
23962 */
23963 var Base = C_lib.Base = (function () {
23964 function F() {}
23965
23966 return {
23967 /**
23968 * Creates a new object that inherits from this object.
23969 *
23970 * @param {Object} overrides Properties to copy into the new object.
23971 *
23972 * @return {Object} The new object.
23973 *
23974 * @static
23975 *
23976 * @example
23977 *
23978 * var MyType = CryptoJS.lib.Base.extend({
23979 * field: 'value',
23980 *
23981 * method: function () {
23982 * }
23983 * });
23984 */
23985 extend: function (overrides) {
23986 // Spawn
23987 F.prototype = this;
23988 var subtype = new F();
23989
23990 // Augment
23991 if (overrides) {
23992 subtype.mixIn(overrides);
23993 }
23994
23995 // Create default initializer
23996 if (!subtype.hasOwnProperty('init')) {
23997 subtype.init = function () {
23998 subtype.$super.init.apply(this, arguments);
23999 };
24000 }
24001
24002 // Initializer's prototype is the subtype object
24003 subtype.init.prototype = subtype;
24004
24005 // Reference supertype
24006 subtype.$super = this;
24007
24008 return subtype;
24009 },
24010
24011 /**
24012 * Extends this object and runs the init method.
24013 * Arguments to create() will be passed to init().
24014 *
24015 * @return {Object} The new object.
24016 *
24017 * @static
24018 *
24019 * @example
24020 *
24021 * var instance = MyType.create();
24022 */
24023 create: function () {
24024 var instance = this.extend();
24025 instance.init.apply(instance, arguments);
24026
24027 return instance;
24028 },
24029
24030 /**
24031 * Initializes a newly created object.
24032 * Override this method to add some logic when your objects are created.
24033 *
24034 * @example
24035 *
24036 * var MyType = CryptoJS.lib.Base.extend({
24037 * init: function () {
24038 * // ...
24039 * }
24040 * });
24041 */
24042 init: function () {
24043 },
24044
24045 /**
24046 * Copies properties into this object.
24047 *
24048 * @param {Object} properties The properties to mix in.
24049 *
24050 * @example
24051 *
24052 * MyType.mixIn({
24053 * field: 'value'
24054 * });
24055 */
24056 mixIn: function (properties) {
24057 for (var propertyName in properties) {
24058 if (properties.hasOwnProperty(propertyName)) {
24059 this[propertyName] = properties[propertyName];
24060 }
24061 }
24062
24063 // IE won't copy toString using the loop above
24064 if (properties.hasOwnProperty('toString')) {
24065 this.toString = properties.toString;
24066 }
24067 },
24068
24069 /**
24070 * Creates a copy of this object.
24071 *
24072 * @return {Object} The clone.
24073 *
24074 * @example
24075 *
24076 * var clone = instance.clone();
24077 */
24078 clone: function () {
24079 return this.init.prototype.extend(this);
24080 }
24081 };
24082 }());
24083
24084 /**
24085 * An array of 32-bit words.
24086 *
24087 * @property {Array} words The array of 32-bit words.
24088 * @property {number} sigBytes The number of significant bytes in this word array.
24089 */
24090 var WordArray = C_lib.WordArray = Base.extend({
24091 /**
24092 * Initializes a newly created word array.
24093 *
24094 * @param {Array} words (Optional) An array of 32-bit words.
24095 * @param {number} sigBytes (Optional) The number of significant bytes in the words.
24096 *
24097 * @example
24098 *
24099 * var wordArray = CryptoJS.lib.WordArray.create();
24100 * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
24101 * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
24102 */
24103 init: function (words, sigBytes) {
24104 words = this.words = words || [];
24105
24106 if (sigBytes != undefined) {
24107 this.sigBytes = sigBytes;
24108 } else {
24109 this.sigBytes = words.length * 4;
24110 }
24111 },
24112
24113 /**
24114 * Converts this word array to a string.
24115 *
24116 * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
24117 *
24118 * @return {string} The stringified word array.
24119 *
24120 * @example
24121 *
24122 * var string = wordArray + '';
24123 * var string = wordArray.toString();
24124 * var string = wordArray.toString(CryptoJS.enc.Utf8);
24125 */
24126 toString: function (encoder) {
24127 return (encoder || Hex).stringify(this);
24128 },
24129
24130 /**
24131 * Concatenates a word array to this word array.
24132 *
24133 * @param {WordArray} wordArray The word array to append.
24134 *
24135 * @return {WordArray} This word array.
24136 *
24137 * @example
24138 *
24139 * wordArray1.concat(wordArray2);
24140 */
24141 concat: function (wordArray) {
24142 // Shortcuts
24143 var thisWords = this.words;
24144 var thatWords = wordArray.words;
24145 var thisSigBytes = this.sigBytes;
24146 var thatSigBytes = wordArray.sigBytes;
24147
24148 // Clamp excess bits
24149 this.clamp();
24150
24151 // Concat
24152 if (thisSigBytes % 4) {
24153 // Copy one byte at a time
24154 for (var i = 0; i < thatSigBytes; i++) {
24155 var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
24156 thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
24157 }
24158 } else if (thatWords.length > 0xffff) {
24159 // Copy one word at a time
24160 for (var i = 0; i < thatSigBytes; i += 4) {
24161 thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
24162 }
24163 } else {
24164 // Copy all words at once
24165 thisWords.push.apply(thisWords, thatWords);
24166 }
24167 this.sigBytes += thatSigBytes;
24168
24169 // Chainable
24170 return this;
24171 },
24172
24173 /**
24174 * Removes insignificant bits.
24175 *
24176 * @example
24177 *
24178 * wordArray.clamp();
24179 */
24180 clamp: function () {
24181 // Shortcuts
24182 var words = this.words;
24183 var sigBytes = this.sigBytes;
24184
24185 // Clamp
24186 words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
24187 words.length = Math.ceil(sigBytes / 4);
24188 },
24189
24190 /**
24191 * Creates a copy of this word array.
24192 *
24193 * @return {WordArray} The clone.
24194 *
24195 * @example
24196 *
24197 * var clone = wordArray.clone();
24198 */
24199 clone: function () {
24200 var clone = Base.clone.call(this);
24201 clone.words = this.words.slice(0);
24202
24203 return clone;
24204 },
24205
24206 /**
24207 * Creates a word array filled with random bytes.
24208 *
24209 * @param {number} nBytes The number of random bytes to generate.
24210 *
24211 * @return {WordArray} The random word array.
24212 *
24213 * @static
24214 *
24215 * @example
24216 *
24217 * var wordArray = CryptoJS.lib.WordArray.random(16);
24218 */
24219 random: function (nBytes) {
24220 var words = [];
24221 for (var i = 0; i < nBytes; i += 4) {
24222 words.push((Math.random() * 0x100000000) | 0);
24223 }
24224
24225 return new WordArray.init(words, nBytes);
24226 }
24227 });
24228
24229 /**
24230 * Encoder namespace.
24231 */
24232 var C_enc = C.enc = {};
24233
24234 /**
24235 * Hex encoding strategy.
24236 */
24237 var Hex = C_enc.Hex = {
24238 /**
24239 * Converts a word array to a hex string.
24240 *
24241 * @param {WordArray} wordArray The word array.
24242 *
24243 * @return {string} The hex string.
24244 *
24245 * @static
24246 *
24247 * @example
24248 *
24249 * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
24250 */
24251 stringify: function (wordArray) {
24252 // Shortcuts
24253 var words = wordArray.words;
24254 var sigBytes = wordArray.sigBytes;
24255
24256 // Convert
24257 var hexChars = [];
24258 for (var i = 0; i < sigBytes; i++) {
24259 var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
24260 hexChars.push((bite >>> 4).toString(16));
24261 hexChars.push((bite & 0x0f).toString(16));
24262 }
24263
24264 return hexChars.join('');
24265 },
24266
24267 /**
24268 * Converts a hex string to a word array.
24269 *
24270 * @param {string} hexStr The hex string.
24271 *
24272 * @return {WordArray} The word array.
24273 *
24274 * @static
24275 *
24276 * @example
24277 *
24278 * var wordArray = CryptoJS.enc.Hex.parse(hexString);
24279 */
24280 parse: function (hexStr) {
24281 // Shortcut
24282 var hexStrLength = hexStr.length;
24283
24284 // Convert
24285 var words = [];
24286 for (var i = 0; i < hexStrLength; i += 2) {
24287 words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
24288 }
24289
24290 return new WordArray.init(words, hexStrLength / 2);
24291 }
24292 };
24293
24294 /**
24295 * Latin1 encoding strategy.
24296 */
24297 var Latin1 = C_enc.Latin1 = {
24298 /**
24299 * Converts a word array to a Latin1 string.
24300 *
24301 * @param {WordArray} wordArray The word array.
24302 *
24303 * @return {string} The Latin1 string.
24304 *
24305 * @static
24306 *
24307 * @example
24308 *
24309 * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
24310 */
24311 stringify: function (wordArray) {
24312 // Shortcuts
24313 var words = wordArray.words;
24314 var sigBytes = wordArray.sigBytes;
24315
24316 // Convert
24317 var latin1Chars = [];
24318 for (var i = 0; i < sigBytes; i++) {
24319 var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
24320 latin1Chars.push(String.fromCharCode(bite));
24321 }
24322
24323 return latin1Chars.join('');
24324 },
24325
24326 /**
24327 * Converts a Latin1 string to a word array.
24328 *
24329 * @param {string} latin1Str The Latin1 string.
24330 *
24331 * @return {WordArray} The word array.
24332 *
24333 * @static
24334 *
24335 * @example
24336 *
24337 * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
24338 */
24339 parse: function (latin1Str) {
24340 // Shortcut
24341 var latin1StrLength = latin1Str.length;
24342
24343 // Convert
24344 var words = [];
24345 for (var i = 0; i < latin1StrLength; i++) {
24346 words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
24347 }
24348
24349 return new WordArray.init(words, latin1StrLength);
24350 }
24351 };
24352
24353 /**
24354 * UTF-8 encoding strategy.
24355 */
24356 var Utf8 = C_enc.Utf8 = {
24357 /**
24358 * Converts a word array to a UTF-8 string.
24359 *
24360 * @param {WordArray} wordArray The word array.
24361 *
24362 * @return {string} The UTF-8 string.
24363 *
24364 * @static
24365 *
24366 * @example
24367 *
24368 * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
24369 */
24370 stringify: function (wordArray) {
24371 try {
24372 return decodeURIComponent(escape(Latin1.stringify(wordArray)));
24373 } catch (e) {
24374 throw new Error('Malformed UTF-8 data');
24375 }
24376 },
24377
24378 /**
24379 * Converts a UTF-8 string to a word array.
24380 *
24381 * @param {string} utf8Str The UTF-8 string.
24382 *
24383 * @return {WordArray} The word array.
24384 *
24385 * @static
24386 *
24387 * @example
24388 *
24389 * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
24390 */
24391 parse: function (utf8Str) {
24392 return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
24393 }
24394 };
24395
24396 /**
24397 * Abstract buffered block algorithm template.
24398 *
24399 * The property blockSize must be implemented in a concrete subtype.
24400 *
24401 * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
24402 */
24403 var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
24404 /**
24405 * Resets this block algorithm's data buffer to its initial state.
24406 *
24407 * @example
24408 *
24409 * bufferedBlockAlgorithm.reset();
24410 */
24411 reset: function () {
24412 // Initial values
24413 this._data = new WordArray.init();
24414 this._nDataBytes = 0;
24415 },
24416
24417 /**
24418 * Adds new data to this block algorithm's buffer.
24419 *
24420 * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
24421 *
24422 * @example
24423 *
24424 * bufferedBlockAlgorithm._append('data');
24425 * bufferedBlockAlgorithm._append(wordArray);
24426 */
24427 _append: function (data) {
24428 // Convert string to WordArray, else assume WordArray already
24429 if (typeof data == 'string') {
24430 data = Utf8.parse(data);
24431 }
24432
24433 // Append
24434 this._data.concat(data);
24435 this._nDataBytes += data.sigBytes;
24436 },
24437
24438 /**
24439 * Processes available data blocks.
24440 *
24441 * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
24442 *
24443 * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
24444 *
24445 * @return {WordArray} The processed data.
24446 *
24447 * @example
24448 *
24449 * var processedData = bufferedBlockAlgorithm._process();
24450 * var processedData = bufferedBlockAlgorithm._process(!!'flush');
24451 */
24452 _process: function (doFlush) {
24453 // Shortcuts
24454 var data = this._data;
24455 var dataWords = data.words;
24456 var dataSigBytes = data.sigBytes;
24457 var blockSize = this.blockSize;
24458 var blockSizeBytes = blockSize * 4;
24459
24460 // Count blocks ready
24461 var nBlocksReady = dataSigBytes / blockSizeBytes;
24462 if (doFlush) {
24463 // Round up to include partial blocks
24464 nBlocksReady = Math.ceil(nBlocksReady);
24465 } else {
24466 // Round down to include only full blocks,
24467 // less the number of blocks that must remain in the buffer
24468 nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
24469 }
24470
24471 // Count words ready
24472 var nWordsReady = nBlocksReady * blockSize;
24473
24474 // Count bytes ready
24475 var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
24476
24477 // Process blocks
24478 if (nWordsReady) {
24479 for (var offset = 0; offset < nWordsReady; offset += blockSize) {
24480 // Perform concrete-algorithm logic
24481 this._doProcessBlock(dataWords, offset);
24482 }
24483
24484 // Remove processed words
24485 var processedWords = dataWords.splice(0, nWordsReady);
24486 data.sigBytes -= nBytesReady;
24487 }
24488
24489 // Return processed words
24490 return new WordArray.init(processedWords, nBytesReady);
24491 },
24492
24493 /**
24494 * Creates a copy of this object.
24495 *
24496 * @return {Object} The clone.
24497 *
24498 * @example
24499 *
24500 * var clone = bufferedBlockAlgorithm.clone();
24501 */
24502 clone: function () {
24503 var clone = Base.clone.call(this);
24504 clone._data = this._data.clone();
24505
24506 return clone;
24507 },
24508
24509 _minBufferSize: 0
24510 });
24511
24512 /**
24513 * Abstract hasher template.
24514 *
24515 * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
24516 */
24517 var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
24518 /**
24519 * Configuration options.
24520 */
24521 cfg: Base.extend(),
24522
24523 /**
24524 * Initializes a newly created hasher.
24525 *
24526 * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
24527 *
24528 * @example
24529 *
24530 * var hasher = CryptoJS.algo.SHA256.create();
24531 */
24532 init: function (cfg) {
24533 // Apply config defaults
24534 this.cfg = this.cfg.extend(cfg);
24535
24536 // Set initial values
24537 this.reset();
24538 },
24539
24540 /**
24541 * Resets this hasher to its initial state.
24542 *
24543 * @example
24544 *
24545 * hasher.reset();
24546 */
24547 reset: function () {
24548 // Reset data buffer
24549 BufferedBlockAlgorithm.reset.call(this);
24550
24551 // Perform concrete-hasher logic
24552 this._doReset();
24553 },
24554
24555 /**
24556 * Updates this hasher with a message.
24557 *
24558 * @param {WordArray|string} messageUpdate The message to append.
24559 *
24560 * @return {Hasher} This hasher.
24561 *
24562 * @example
24563 *
24564 * hasher.update('message');
24565 * hasher.update(wordArray);
24566 */
24567 update: function (messageUpdate) {
24568 // Append
24569 this._append(messageUpdate);
24570
24571 // Update the hash
24572 this._process();
24573
24574 // Chainable
24575 return this;
24576 },
24577
24578 /**
24579 * Finalizes the hash computation.
24580 * Note that the finalize operation is effectively a destructive, read-once operation.
24581 *
24582 * @param {WordArray|string} messageUpdate (Optional) A final message update.
24583 *
24584 * @return {WordArray} The hash.
24585 *
24586 * @example
24587 *
24588 * var hash = hasher.finalize();
24589 * var hash = hasher.finalize('message');
24590 * var hash = hasher.finalize(wordArray);
24591 */
24592 finalize: function (messageUpdate) {
24593 // Final message update
24594 if (messageUpdate) {
24595 this._append(messageUpdate);
24596 }
24597
24598 // Perform concrete-hasher logic
24599 var hash = this._doFinalize();
24600
24601 return hash;
24602 },
24603
24604 blockSize: 512/32,
24605
24606 /**
24607 * Creates a shortcut function to a hasher's object interface.
24608 *
24609 * @param {Hasher} hasher The hasher to create a helper for.
24610 *
24611 * @return {Function} The shortcut function.
24612 *
24613 * @static
24614 *
24615 * @example
24616 *
24617 * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
24618 */
24619 _createHelper: function (hasher) {
24620 return function (message, cfg) {
24621 return new hasher.init(cfg).finalize(message);
24622 };
24623 },
24624
24625 /**
24626 * Creates a shortcut function to the HMAC's object interface.
24627 *
24628 * @param {Hasher} hasher The hasher to use in this HMAC helper.
24629 *
24630 * @return {Function} The shortcut function.
24631 *
24632 * @static
24633 *
24634 * @example
24635 *
24636 * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
24637 */
24638 _createHmacHelper: function (hasher) {
24639 return function (message, key) {
24640 return new C_algo.HMAC.init(hasher, key).finalize(message);
24641 };
24642 }
24643 });
24644
24645 /**
24646 * Algorithm namespace.
24647 */
24648 var C_algo = C.algo = {};
24649
24650 return C;
24651 }(Math));
24652
24653
24654 return CryptoJS;
24655
24656 }));
24657 },{}],32:[function(_dereq_,module,exports){
24658 ;(function (root, factory) {
24659 if (typeof exports === "object") {
24660 // CommonJS
24661 module.exports = exports = factory(_dereq_("./core"));
24662 }
24663 else if (typeof define === "function" && define.amd) {
24664 // AMD
24665 define(["./core"], factory);
24666 }
24667 else {
24668 // Global (browser)
24669 factory(root.CryptoJS);
24670 }
24671 }(this, function (CryptoJS) {
24672
24673 (function () {
24674 // Shortcuts
24675 var C = CryptoJS;
24676 var C_lib = C.lib;
24677 var WordArray = C_lib.WordArray;
24678 var C_enc = C.enc;
24679
24680 /**
24681 * Base64 encoding strategy.
24682 */
24683 var Base64 = C_enc.Base64 = {
24684 /**
24685 * Converts a word array to a Base64 string.
24686 *
24687 * @param {WordArray} wordArray The word array.
24688 *
24689 * @return {string} The Base64 string.
24690 *
24691 * @static
24692 *
24693 * @example
24694 *
24695 * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
24696 */
24697 stringify: function (wordArray) {
24698 // Shortcuts
24699 var words = wordArray.words;
24700 var sigBytes = wordArray.sigBytes;
24701 var map = this._map;
24702
24703 // Clamp excess bits
24704 wordArray.clamp();
24705
24706 // Convert
24707 var base64Chars = [];
24708 for (var i = 0; i < sigBytes; i += 3) {
24709 var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
24710 var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
24711 var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
24712
24713 var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
24714
24715 for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
24716 base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
24717 }
24718 }
24719
24720 // Add padding
24721 var paddingChar = map.charAt(64);
24722 if (paddingChar) {
24723 while (base64Chars.length % 4) {
24724 base64Chars.push(paddingChar);
24725 }
24726 }
24727
24728 return base64Chars.join('');
24729 },
24730
24731 /**
24732 * Converts a Base64 string to a word array.
24733 *
24734 * @param {string} base64Str The Base64 string.
24735 *
24736 * @return {WordArray} The word array.
24737 *
24738 * @static
24739 *
24740 * @example
24741 *
24742 * var wordArray = CryptoJS.enc.Base64.parse(base64String);
24743 */
24744 parse: function (base64Str) {
24745 // Shortcuts
24746 var base64StrLength = base64Str.length;
24747 var map = this._map;
24748
24749 // Ignore padding
24750 var paddingChar = map.charAt(64);
24751 if (paddingChar) {
24752 var paddingIndex = base64Str.indexOf(paddingChar);
24753 if (paddingIndex != -1) {
24754 base64StrLength = paddingIndex;
24755 }
24756 }
24757
24758 // Convert
24759 var words = [];
24760 var nBytes = 0;
24761 for (var i = 0; i < base64StrLength; i++) {
24762 if (i % 4) {
24763 var bits1 = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2);
24764 var bits2 = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2);
24765 words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
24766 nBytes++;
24767 }
24768 }
24769
24770 return WordArray.create(words, nBytes);
24771 },
24772
24773 _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
24774 };
24775 }());
24776
24777
24778 return CryptoJS.enc.Base64;
24779
24780 }));
24781 },{"./core":31}],33:[function(_dereq_,module,exports){
24782 ;(function (root, factory) {
24783 if (typeof exports === "object") {
24784 // CommonJS
24785 module.exports = exports = factory(_dereq_("./core"));
24786 }
24787 else if (typeof define === "function" && define.amd) {
24788 // AMD
24789 define(["./core"], factory);
24790 }
24791 else {
24792 // Global (browser)
24793 factory(root.CryptoJS);
24794 }
24795 }(this, function (CryptoJS) {
24796
24797 (function () {
24798 // Shortcuts
24799 var C = CryptoJS;
24800 var C_lib = C.lib;
24801 var WordArray = C_lib.WordArray;
24802 var C_enc = C.enc;
24803
24804 /**
24805 * UTF-16 BE encoding strategy.
24806 */
24807 var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
24808 /**
24809 * Converts a word array to a UTF-16 BE string.
24810 *
24811 * @param {WordArray} wordArray The word array.
24812 *
24813 * @return {string} The UTF-16 BE string.
24814 *
24815 * @static
24816 *
24817 * @example
24818 *
24819 * var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
24820 */
24821 stringify: function (wordArray) {
24822 // Shortcuts
24823 var words = wordArray.words;
24824 var sigBytes = wordArray.sigBytes;
24825
24826 // Convert
24827 var utf16Chars = [];
24828 for (var i = 0; i < sigBytes; i += 2) {
24829 var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff;
24830 utf16Chars.push(String.fromCharCode(codePoint));
24831 }
24832
24833 return utf16Chars.join('');
24834 },
24835
24836 /**
24837 * Converts a UTF-16 BE string to a word array.
24838 *
24839 * @param {string} utf16Str The UTF-16 BE string.
24840 *
24841 * @return {WordArray} The word array.
24842 *
24843 * @static
24844 *
24845 * @example
24846 *
24847 * var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
24848 */
24849 parse: function (utf16Str) {
24850 // Shortcut
24851 var utf16StrLength = utf16Str.length;
24852
24853 // Convert
24854 var words = [];
24855 for (var i = 0; i < utf16StrLength; i++) {
24856 words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16);
24857 }
24858
24859 return WordArray.create(words, utf16StrLength * 2);
24860 }
24861 };
24862
24863 /**
24864 * UTF-16 LE encoding strategy.
24865 */
24866 C_enc.Utf16LE = {
24867 /**
24868 * Converts a word array to a UTF-16 LE string.
24869 *
24870 * @param {WordArray} wordArray The word array.
24871 *
24872 * @return {string} The UTF-16 LE string.
24873 *
24874 * @static
24875 *
24876 * @example
24877 *
24878 * var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
24879 */
24880 stringify: function (wordArray) {
24881 // Shortcuts
24882 var words = wordArray.words;
24883 var sigBytes = wordArray.sigBytes;
24884
24885 // Convert
24886 var utf16Chars = [];
24887 for (var i = 0; i < sigBytes; i += 2) {
24888 var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff);
24889 utf16Chars.push(String.fromCharCode(codePoint));
24890 }
24891
24892 return utf16Chars.join('');
24893 },
24894
24895 /**
24896 * Converts a UTF-16 LE string to a word array.
24897 *
24898 * @param {string} utf16Str The UTF-16 LE string.
24899 *
24900 * @return {WordArray} The word array.
24901 *
24902 * @static
24903 *
24904 * @example
24905 *
24906 * var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
24907 */
24908 parse: function (utf16Str) {
24909 // Shortcut
24910 var utf16StrLength = utf16Str.length;
24911
24912 // Convert
24913 var words = [];
24914 for (var i = 0; i < utf16StrLength; i++) {
24915 words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16));
24916 }
24917
24918 return WordArray.create(words, utf16StrLength * 2);
24919 }
24920 };
24921
24922 function swapEndian(word) {
24923 return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff);
24924 }
24925 }());
24926
24927
24928 return CryptoJS.enc.Utf16;
24929
24930 }));
24931 },{"./core":31}],34:[function(_dereq_,module,exports){
24932 ;(function (root, factory, undef) {
24933 if (typeof exports === "object") {
24934 // CommonJS
24935 module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha1"), _dereq_("./hmac"));
24936 }
24937 else if (typeof define === "function" && define.amd) {
24938 // AMD
24939 define(["./core", "./sha1", "./hmac"], factory);
24940 }
24941 else {
24942 // Global (browser)
24943 factory(root.CryptoJS);
24944 }
24945 }(this, function (CryptoJS) {
24946
24947 (function () {
24948 // Shortcuts
24949 var C = CryptoJS;
24950 var C_lib = C.lib;
24951 var Base = C_lib.Base;
24952 var WordArray = C_lib.WordArray;
24953 var C_algo = C.algo;
24954 var MD5 = C_algo.MD5;
24955
24956 /**
24957 * This key derivation function is meant to conform with EVP_BytesToKey.
24958 * www.openssl.org/docs/crypto/EVP_BytesToKey.html
24959 */
24960 var EvpKDF = C_algo.EvpKDF = Base.extend({
24961 /**
24962 * Configuration options.
24963 *
24964 * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
24965 * @property {Hasher} hasher The hash algorithm to use. Default: MD5
24966 * @property {number} iterations The number of iterations to perform. Default: 1
24967 */
24968 cfg: Base.extend({
24969 keySize: 128/32,
24970 hasher: MD5,
24971 iterations: 1
24972 }),
24973
24974 /**
24975 * Initializes a newly created key derivation function.
24976 *
24977 * @param {Object} cfg (Optional) The configuration options to use for the derivation.
24978 *
24979 * @example
24980 *
24981 * var kdf = CryptoJS.algo.EvpKDF.create();
24982 * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
24983 * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
24984 */
24985 init: function (cfg) {
24986 this.cfg = this.cfg.extend(cfg);
24987 },
24988
24989 /**
24990 * Derives a key from a password.
24991 *
24992 * @param {WordArray|string} password The password.
24993 * @param {WordArray|string} salt A salt.
24994 *
24995 * @return {WordArray} The derived key.
24996 *
24997 * @example
24998 *
24999 * var key = kdf.compute(password, salt);
25000 */
25001 compute: function (password, salt) {
25002 // Shortcut
25003 var cfg = this.cfg;
25004
25005 // Init hasher
25006 var hasher = cfg.hasher.create();
25007
25008 // Initial values
25009 var derivedKey = WordArray.create();
25010
25011 // Shortcuts
25012 var derivedKeyWords = derivedKey.words;
25013 var keySize = cfg.keySize;
25014 var iterations = cfg.iterations;
25015
25016 // Generate key
25017 while (derivedKeyWords.length < keySize) {
25018 if (block) {
25019 hasher.update(block);
25020 }
25021 var block = hasher.update(password).finalize(salt);
25022 hasher.reset();
25023
25024 // Iterations
25025 for (var i = 1; i < iterations; i++) {
25026 block = hasher.finalize(block);
25027 hasher.reset();
25028 }
25029
25030 derivedKey.concat(block);
25031 }
25032 derivedKey.sigBytes = keySize * 4;
25033
25034 return derivedKey;
25035 }
25036 });
25037
25038 /**
25039 * Derives a key from a password.
25040 *
25041 * @param {WordArray|string} password The password.
25042 * @param {WordArray|string} salt A salt.
25043 * @param {Object} cfg (Optional) The configuration options to use for this computation.
25044 *
25045 * @return {WordArray} The derived key.
25046 *
25047 * @static
25048 *
25049 * @example
25050 *
25051 * var key = CryptoJS.EvpKDF(password, salt);
25052 * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
25053 * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
25054 */
25055 C.EvpKDF = function (password, salt, cfg) {
25056 return EvpKDF.create(cfg).compute(password, salt);
25057 };
25058 }());
25059
25060
25061 return CryptoJS.EvpKDF;
25062
25063 }));
25064 },{"./core":31,"./hmac":36,"./sha1":55}],35:[function(_dereq_,module,exports){
25065 ;(function (root, factory, undef) {
25066 if (typeof exports === "object") {
25067 // CommonJS
25068 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25069 }
25070 else if (typeof define === "function" && define.amd) {
25071 // AMD
25072 define(["./core", "./cipher-core"], factory);
25073 }
25074 else {
25075 // Global (browser)
25076 factory(root.CryptoJS);
25077 }
25078 }(this, function (CryptoJS) {
25079
25080 (function (undefined) {
25081 // Shortcuts
25082 var C = CryptoJS;
25083 var C_lib = C.lib;
25084 var CipherParams = C_lib.CipherParams;
25085 var C_enc = C.enc;
25086 var Hex = C_enc.Hex;
25087 var C_format = C.format;
25088
25089 var HexFormatter = C_format.Hex = {
25090 /**
25091 * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
25092 *
25093 * @param {CipherParams} cipherParams The cipher params object.
25094 *
25095 * @return {string} The hexadecimally encoded string.
25096 *
25097 * @static
25098 *
25099 * @example
25100 *
25101 * var hexString = CryptoJS.format.Hex.stringify(cipherParams);
25102 */
25103 stringify: function (cipherParams) {
25104 return cipherParams.ciphertext.toString(Hex);
25105 },
25106
25107 /**
25108 * Converts a hexadecimally encoded ciphertext string to a cipher params object.
25109 *
25110 * @param {string} input The hexadecimally encoded string.
25111 *
25112 * @return {CipherParams} The cipher params object.
25113 *
25114 * @static
25115 *
25116 * @example
25117 *
25118 * var cipherParams = CryptoJS.format.Hex.parse(hexString);
25119 */
25120 parse: function (input) {
25121 var ciphertext = Hex.parse(input);
25122 return CipherParams.create({ ciphertext: ciphertext });
25123 }
25124 };
25125 }());
25126
25127
25128 return CryptoJS.format.Hex;
25129
25130 }));
25131 },{"./cipher-core":30,"./core":31}],36:[function(_dereq_,module,exports){
25132 ;(function (root, factory) {
25133 if (typeof exports === "object") {
25134 // CommonJS
25135 module.exports = exports = factory(_dereq_("./core"));
25136 }
25137 else if (typeof define === "function" && define.amd) {
25138 // AMD
25139 define(["./core"], factory);
25140 }
25141 else {
25142 // Global (browser)
25143 factory(root.CryptoJS);
25144 }
25145 }(this, function (CryptoJS) {
25146
25147 (function () {
25148 // Shortcuts
25149 var C = CryptoJS;
25150 var C_lib = C.lib;
25151 var Base = C_lib.Base;
25152 var C_enc = C.enc;
25153 var Utf8 = C_enc.Utf8;
25154 var C_algo = C.algo;
25155
25156 /**
25157 * HMAC algorithm.
25158 */
25159 var HMAC = C_algo.HMAC = Base.extend({
25160 /**
25161 * Initializes a newly created HMAC.
25162 *
25163 * @param {Hasher} hasher The hash algorithm to use.
25164 * @param {WordArray|string} key The secret key.
25165 *
25166 * @example
25167 *
25168 * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
25169 */
25170 init: function (hasher, key) {
25171 // Init hasher
25172 hasher = this._hasher = new hasher.init();
25173
25174 // Convert string to WordArray, else assume WordArray already
25175 if (typeof key == 'string') {
25176 key = Utf8.parse(key);
25177 }
25178
25179 // Shortcuts
25180 var hasherBlockSize = hasher.blockSize;
25181 var hasherBlockSizeBytes = hasherBlockSize * 4;
25182
25183 // Allow arbitrary length keys
25184 if (key.sigBytes > hasherBlockSizeBytes) {
25185 key = hasher.finalize(key);
25186 }
25187
25188 // Clamp excess bits
25189 key.clamp();
25190
25191 // Clone key for inner and outer pads
25192 var oKey = this._oKey = key.clone();
25193 var iKey = this._iKey = key.clone();
25194
25195 // Shortcuts
25196 var oKeyWords = oKey.words;
25197 var iKeyWords = iKey.words;
25198
25199 // XOR keys with pad constants
25200 for (var i = 0; i < hasherBlockSize; i++) {
25201 oKeyWords[i] ^= 0x5c5c5c5c;
25202 iKeyWords[i] ^= 0x36363636;
25203 }
25204 oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
25205
25206 // Set initial values
25207 this.reset();
25208 },
25209
25210 /**
25211 * Resets this HMAC to its initial state.
25212 *
25213 * @example
25214 *
25215 * hmacHasher.reset();
25216 */
25217 reset: function () {
25218 // Shortcut
25219 var hasher = this._hasher;
25220
25221 // Reset
25222 hasher.reset();
25223 hasher.update(this._iKey);
25224 },
25225
25226 /**
25227 * Updates this HMAC with a message.
25228 *
25229 * @param {WordArray|string} messageUpdate The message to append.
25230 *
25231 * @return {HMAC} This HMAC instance.
25232 *
25233 * @example
25234 *
25235 * hmacHasher.update('message');
25236 * hmacHasher.update(wordArray);
25237 */
25238 update: function (messageUpdate) {
25239 this._hasher.update(messageUpdate);
25240
25241 // Chainable
25242 return this;
25243 },
25244
25245 /**
25246 * Finalizes the HMAC computation.
25247 * Note that the finalize operation is effectively a destructive, read-once operation.
25248 *
25249 * @param {WordArray|string} messageUpdate (Optional) A final message update.
25250 *
25251 * @return {WordArray} The HMAC.
25252 *
25253 * @example
25254 *
25255 * var hmac = hmacHasher.finalize();
25256 * var hmac = hmacHasher.finalize('message');
25257 * var hmac = hmacHasher.finalize(wordArray);
25258 */
25259 finalize: function (messageUpdate) {
25260 // Shortcut
25261 var hasher = this._hasher;
25262
25263 // Compute HMAC
25264 var innerHash = hasher.finalize(messageUpdate);
25265 hasher.reset();
25266 var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
25267
25268 return hmac;
25269 }
25270 });
25271 }());
25272
25273
25274 }));
25275 },{"./core":31}],37:[function(_dereq_,module,exports){
25276 ;(function (root, factory, undef) {
25277 if (typeof exports === "object") {
25278 // CommonJS
25279 module.exports = exports = factory(_dereq_("./core"), _dereq_("./x64-core"), _dereq_("./lib-typedarrays"), _dereq_("./enc-utf16"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./sha1"), _dereq_("./sha256"), _dereq_("./sha224"), _dereq_("./sha512"), _dereq_("./sha384"), _dereq_("./sha3"), _dereq_("./ripemd160"), _dereq_("./hmac"), _dereq_("./pbkdf2"), _dereq_("./evpkdf"), _dereq_("./cipher-core"), _dereq_("./mode-cfb"), _dereq_("./mode-ctr"), _dereq_("./mode-ctr-gladman"), _dereq_("./mode-ofb"), _dereq_("./mode-ecb"), _dereq_("./pad-ansix923"), _dereq_("./pad-iso10126"), _dereq_("./pad-iso97971"), _dereq_("./pad-zeropadding"), _dereq_("./pad-nopadding"), _dereq_("./format-hex"), _dereq_("./aes"), _dereq_("./tripledes"), _dereq_("./rc4"), _dereq_("./rabbit"), _dereq_("./rabbit-legacy"));
25280 }
25281 else if (typeof define === "function" && define.amd) {
25282 // AMD
25283 define(["./core", "./x64-core", "./lib-typedarrays", "./enc-utf16", "./enc-base64", "./md5", "./sha1", "./sha256", "./sha224", "./sha512", "./sha384", "./sha3", "./ripemd160", "./hmac", "./pbkdf2", "./evpkdf", "./cipher-core", "./mode-cfb", "./mode-ctr", "./mode-ctr-gladman", "./mode-ofb", "./mode-ecb", "./pad-ansix923", "./pad-iso10126", "./pad-iso97971", "./pad-zeropadding", "./pad-nopadding", "./format-hex", "./aes", "./tripledes", "./rc4", "./rabbit", "./rabbit-legacy"], factory);
25284 }
25285 else {
25286 // Global (browser)
25287 factory(root.CryptoJS);
25288 }
25289 }(this, function (CryptoJS) {
25290
25291 return CryptoJS;
25292
25293 }));
25294 },{"./aes":29,"./cipher-core":30,"./core":31,"./enc-base64":32,"./enc-utf16":33,"./evpkdf":34,"./format-hex":35,"./hmac":36,"./lib-typedarrays":38,"./md5":39,"./mode-cfb":40,"./mode-ctr":42,"./mode-ctr-gladman":41,"./mode-ecb":43,"./mode-ofb":44,"./pad-ansix923":45,"./pad-iso10126":46,"./pad-iso97971":47,"./pad-nopadding":48,"./pad-zeropadding":49,"./pbkdf2":50,"./rabbit":52,"./rabbit-legacy":51,"./rc4":53,"./ripemd160":54,"./sha1":55,"./sha224":56,"./sha256":57,"./sha3":58,"./sha384":59,"./sha512":60,"./tripledes":61,"./x64-core":62}],38:[function(_dereq_,module,exports){
25295 ;(function (root, factory) {
25296 if (typeof exports === "object") {
25297 // CommonJS
25298 module.exports = exports = factory(_dereq_("./core"));
25299 }
25300 else if (typeof define === "function" && define.amd) {
25301 // AMD
25302 define(["./core"], factory);
25303 }
25304 else {
25305 // Global (browser)
25306 factory(root.CryptoJS);
25307 }
25308 }(this, function (CryptoJS) {
25309
25310 (function () {
25311 // Check if typed arrays are supported
25312 if (typeof ArrayBuffer != 'function') {
25313 return;
25314 }
25315
25316 // Shortcuts
25317 var C = CryptoJS;
25318 var C_lib = C.lib;
25319 var WordArray = C_lib.WordArray;
25320
25321 // Reference original init
25322 var superInit = WordArray.init;
25323
25324 // Augment WordArray.init to handle typed arrays
25325 var subInit = WordArray.init = function (typedArray) {
25326 // Convert buffers to uint8
25327 if (typedArray instanceof ArrayBuffer) {
25328 typedArray = new Uint8Array(typedArray);
25329 }
25330
25331 // Convert other array views to uint8
25332 if (
25333 typedArray instanceof Int8Array ||
25334 typedArray instanceof Uint8ClampedArray ||
25335 typedArray instanceof Int16Array ||
25336 typedArray instanceof Uint16Array ||
25337 typedArray instanceof Int32Array ||
25338 typedArray instanceof Uint32Array ||
25339 typedArray instanceof Float32Array ||
25340 typedArray instanceof Float64Array
25341 ) {
25342 typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
25343 }
25344
25345 // Handle Uint8Array
25346 if (typedArray instanceof Uint8Array) {
25347 // Shortcut
25348 var typedArrayByteLength = typedArray.byteLength;
25349
25350 // Extract bytes
25351 var words = [];
25352 for (var i = 0; i < typedArrayByteLength; i++) {
25353 words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8);
25354 }
25355
25356 // Initialize this word array
25357 superInit.call(this, words, typedArrayByteLength);
25358 } else {
25359 // Else call normal init
25360 superInit.apply(this, arguments);
25361 }
25362 };
25363
25364 subInit.prototype = WordArray;
25365 }());
25366
25367
25368 return CryptoJS.lib.WordArray;
25369
25370 }));
25371 },{"./core":31}],39:[function(_dereq_,module,exports){
25372 ;(function (root, factory) {
25373 if (typeof exports === "object") {
25374 // CommonJS
25375 module.exports = exports = factory(_dereq_("./core"));
25376 }
25377 else if (typeof define === "function" && define.amd) {
25378 // AMD
25379 define(["./core"], factory);
25380 }
25381 else {
25382 // Global (browser)
25383 factory(root.CryptoJS);
25384 }
25385 }(this, function (CryptoJS) {
25386
25387 (function (Math) {
25388 // Shortcuts
25389 var C = CryptoJS;
25390 var C_lib = C.lib;
25391 var WordArray = C_lib.WordArray;
25392 var Hasher = C_lib.Hasher;
25393 var C_algo = C.algo;
25394
25395 // Constants table
25396 var T = [];
25397
25398 // Compute constants
25399 (function () {
25400 for (var i = 0; i < 64; i++) {
25401 T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
25402 }
25403 }());
25404
25405 /**
25406 * MD5 hash algorithm.
25407 */
25408 var MD5 = C_algo.MD5 = Hasher.extend({
25409 _doReset: function () {
25410 this._hash = new WordArray.init([
25411 0x67452301, 0xefcdab89,
25412 0x98badcfe, 0x10325476
25413 ]);
25414 },
25415
25416 _doProcessBlock: function (M, offset) {
25417 // Swap endian
25418 for (var i = 0; i < 16; i++) {
25419 // Shortcuts
25420 var offset_i = offset + i;
25421 var M_offset_i = M[offset_i];
25422
25423 M[offset_i] = (
25424 (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
25425 (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
25426 );
25427 }
25428
25429 // Shortcuts
25430 var H = this._hash.words;
25431
25432 var M_offset_0 = M[offset + 0];
25433 var M_offset_1 = M[offset + 1];
25434 var M_offset_2 = M[offset + 2];
25435 var M_offset_3 = M[offset + 3];
25436 var M_offset_4 = M[offset + 4];
25437 var M_offset_5 = M[offset + 5];
25438 var M_offset_6 = M[offset + 6];
25439 var M_offset_7 = M[offset + 7];
25440 var M_offset_8 = M[offset + 8];
25441 var M_offset_9 = M[offset + 9];
25442 var M_offset_10 = M[offset + 10];
25443 var M_offset_11 = M[offset + 11];
25444 var M_offset_12 = M[offset + 12];
25445 var M_offset_13 = M[offset + 13];
25446 var M_offset_14 = M[offset + 14];
25447 var M_offset_15 = M[offset + 15];
25448
25449 // Working varialbes
25450 var a = H[0];
25451 var b = H[1];
25452 var c = H[2];
25453 var d = H[3];
25454
25455 // Computation
25456 a = FF(a, b, c, d, M_offset_0, 7, T[0]);
25457 d = FF(d, a, b, c, M_offset_1, 12, T[1]);
25458 c = FF(c, d, a, b, M_offset_2, 17, T[2]);
25459 b = FF(b, c, d, a, M_offset_3, 22, T[3]);
25460 a = FF(a, b, c, d, M_offset_4, 7, T[4]);
25461 d = FF(d, a, b, c, M_offset_5, 12, T[5]);
25462 c = FF(c, d, a, b, M_offset_6, 17, T[6]);
25463 b = FF(b, c, d, a, M_offset_7, 22, T[7]);
25464 a = FF(a, b, c, d, M_offset_8, 7, T[8]);
25465 d = FF(d, a, b, c, M_offset_9, 12, T[9]);
25466 c = FF(c, d, a, b, M_offset_10, 17, T[10]);
25467 b = FF(b, c, d, a, M_offset_11, 22, T[11]);
25468 a = FF(a, b, c, d, M_offset_12, 7, T[12]);
25469 d = FF(d, a, b, c, M_offset_13, 12, T[13]);
25470 c = FF(c, d, a, b, M_offset_14, 17, T[14]);
25471 b = FF(b, c, d, a, M_offset_15, 22, T[15]);
25472
25473 a = GG(a, b, c, d, M_offset_1, 5, T[16]);
25474 d = GG(d, a, b, c, M_offset_6, 9, T[17]);
25475 c = GG(c, d, a, b, M_offset_11, 14, T[18]);
25476 b = GG(b, c, d, a, M_offset_0, 20, T[19]);
25477 a = GG(a, b, c, d, M_offset_5, 5, T[20]);
25478 d = GG(d, a, b, c, M_offset_10, 9, T[21]);
25479 c = GG(c, d, a, b, M_offset_15, 14, T[22]);
25480 b = GG(b, c, d, a, M_offset_4, 20, T[23]);
25481 a = GG(a, b, c, d, M_offset_9, 5, T[24]);
25482 d = GG(d, a, b, c, M_offset_14, 9, T[25]);
25483 c = GG(c, d, a, b, M_offset_3, 14, T[26]);
25484 b = GG(b, c, d, a, M_offset_8, 20, T[27]);
25485 a = GG(a, b, c, d, M_offset_13, 5, T[28]);
25486 d = GG(d, a, b, c, M_offset_2, 9, T[29]);
25487 c = GG(c, d, a, b, M_offset_7, 14, T[30]);
25488 b = GG(b, c, d, a, M_offset_12, 20, T[31]);
25489
25490 a = HH(a, b, c, d, M_offset_5, 4, T[32]);
25491 d = HH(d, a, b, c, M_offset_8, 11, T[33]);
25492 c = HH(c, d, a, b, M_offset_11, 16, T[34]);
25493 b = HH(b, c, d, a, M_offset_14, 23, T[35]);
25494 a = HH(a, b, c, d, M_offset_1, 4, T[36]);
25495 d = HH(d, a, b, c, M_offset_4, 11, T[37]);
25496 c = HH(c, d, a, b, M_offset_7, 16, T[38]);
25497 b = HH(b, c, d, a, M_offset_10, 23, T[39]);
25498 a = HH(a, b, c, d, M_offset_13, 4, T[40]);
25499 d = HH(d, a, b, c, M_offset_0, 11, T[41]);
25500 c = HH(c, d, a, b, M_offset_3, 16, T[42]);
25501 b = HH(b, c, d, a, M_offset_6, 23, T[43]);
25502 a = HH(a, b, c, d, M_offset_9, 4, T[44]);
25503 d = HH(d, a, b, c, M_offset_12, 11, T[45]);
25504 c = HH(c, d, a, b, M_offset_15, 16, T[46]);
25505 b = HH(b, c, d, a, M_offset_2, 23, T[47]);
25506
25507 a = II(a, b, c, d, M_offset_0, 6, T[48]);
25508 d = II(d, a, b, c, M_offset_7, 10, T[49]);
25509 c = II(c, d, a, b, M_offset_14, 15, T[50]);
25510 b = II(b, c, d, a, M_offset_5, 21, T[51]);
25511 a = II(a, b, c, d, M_offset_12, 6, T[52]);
25512 d = II(d, a, b, c, M_offset_3, 10, T[53]);
25513 c = II(c, d, a, b, M_offset_10, 15, T[54]);
25514 b = II(b, c, d, a, M_offset_1, 21, T[55]);
25515 a = II(a, b, c, d, M_offset_8, 6, T[56]);
25516 d = II(d, a, b, c, M_offset_15, 10, T[57]);
25517 c = II(c, d, a, b, M_offset_6, 15, T[58]);
25518 b = II(b, c, d, a, M_offset_13, 21, T[59]);
25519 a = II(a, b, c, d, M_offset_4, 6, T[60]);
25520 d = II(d, a, b, c, M_offset_11, 10, T[61]);
25521 c = II(c, d, a, b, M_offset_2, 15, T[62]);
25522 b = II(b, c, d, a, M_offset_9, 21, T[63]);
25523
25524 // Intermediate hash value
25525 H[0] = (H[0] + a) | 0;
25526 H[1] = (H[1] + b) | 0;
25527 H[2] = (H[2] + c) | 0;
25528 H[3] = (H[3] + d) | 0;
25529 },
25530
25531 _doFinalize: function () {
25532 // Shortcuts
25533 var data = this._data;
25534 var dataWords = data.words;
25535
25536 var nBitsTotal = this._nDataBytes * 8;
25537 var nBitsLeft = data.sigBytes * 8;
25538
25539 // Add padding
25540 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
25541
25542 var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
25543 var nBitsTotalL = nBitsTotal;
25544 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
25545 (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
25546 (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
25547 );
25548 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
25549 (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
25550 (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
25551 );
25552
25553 data.sigBytes = (dataWords.length + 1) * 4;
25554
25555 // Hash final blocks
25556 this._process();
25557
25558 // Shortcuts
25559 var hash = this._hash;
25560 var H = hash.words;
25561
25562 // Swap endian
25563 for (var i = 0; i < 4; i++) {
25564 // Shortcut
25565 var H_i = H[i];
25566
25567 H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
25568 (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
25569 }
25570
25571 // Return final computed hash
25572 return hash;
25573 },
25574
25575 clone: function () {
25576 var clone = Hasher.clone.call(this);
25577 clone._hash = this._hash.clone();
25578
25579 return clone;
25580 }
25581 });
25582
25583 function FF(a, b, c, d, x, s, t) {
25584 var n = a + ((b & c) | (~b & d)) + x + t;
25585 return ((n << s) | (n >>> (32 - s))) + b;
25586 }
25587
25588 function GG(a, b, c, d, x, s, t) {
25589 var n = a + ((b & d) | (c & ~d)) + x + t;
25590 return ((n << s) | (n >>> (32 - s))) + b;
25591 }
25592
25593 function HH(a, b, c, d, x, s, t) {
25594 var n = a + (b ^ c ^ d) + x + t;
25595 return ((n << s) | (n >>> (32 - s))) + b;
25596 }
25597
25598 function II(a, b, c, d, x, s, t) {
25599 var n = a + (c ^ (b | ~d)) + x + t;
25600 return ((n << s) | (n >>> (32 - s))) + b;
25601 }
25602
25603 /**
25604 * Shortcut function to the hasher's object interface.
25605 *
25606 * @param {WordArray|string} message The message to hash.
25607 *
25608 * @return {WordArray} The hash.
25609 *
25610 * @static
25611 *
25612 * @example
25613 *
25614 * var hash = CryptoJS.MD5('message');
25615 * var hash = CryptoJS.MD5(wordArray);
25616 */
25617 C.MD5 = Hasher._createHelper(MD5);
25618
25619 /**
25620 * Shortcut function to the HMAC's object interface.
25621 *
25622 * @param {WordArray|string} message The message to hash.
25623 * @param {WordArray|string} key The secret key.
25624 *
25625 * @return {WordArray} The HMAC.
25626 *
25627 * @static
25628 *
25629 * @example
25630 *
25631 * var hmac = CryptoJS.HmacMD5(message, key);
25632 */
25633 C.HmacMD5 = Hasher._createHmacHelper(MD5);
25634 }(Math));
25635
25636
25637 return CryptoJS.MD5;
25638
25639 }));
25640 },{"./core":31}],40:[function(_dereq_,module,exports){
25641 ;(function (root, factory, undef) {
25642 if (typeof exports === "object") {
25643 // CommonJS
25644 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25645 }
25646 else if (typeof define === "function" && define.amd) {
25647 // AMD
25648 define(["./core", "./cipher-core"], factory);
25649 }
25650 else {
25651 // Global (browser)
25652 factory(root.CryptoJS);
25653 }
25654 }(this, function (CryptoJS) {
25655
25656 /**
25657 * Cipher Feedback block mode.
25658 */
25659 CryptoJS.mode.CFB = (function () {
25660 var CFB = CryptoJS.lib.BlockCipherMode.extend();
25661
25662 CFB.Encryptor = CFB.extend({
25663 processBlock: function (words, offset) {
25664 // Shortcuts
25665 var cipher = this._cipher;
25666 var blockSize = cipher.blockSize;
25667
25668 generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
25669
25670 // Remember this block to use with next block
25671 this._prevBlock = words.slice(offset, offset + blockSize);
25672 }
25673 });
25674
25675 CFB.Decryptor = CFB.extend({
25676 processBlock: function (words, offset) {
25677 // Shortcuts
25678 var cipher = this._cipher;
25679 var blockSize = cipher.blockSize;
25680
25681 // Remember this block to use with next block
25682 var thisBlock = words.slice(offset, offset + blockSize);
25683
25684 generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
25685
25686 // This block becomes the previous block
25687 this._prevBlock = thisBlock;
25688 }
25689 });
25690
25691 function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
25692 // Shortcut
25693 var iv = this._iv;
25694
25695 // Generate keystream
25696 if (iv) {
25697 var keystream = iv.slice(0);
25698
25699 // Remove IV for subsequent blocks
25700 this._iv = undefined;
25701 } else {
25702 var keystream = this._prevBlock;
25703 }
25704 cipher.encryptBlock(keystream, 0);
25705
25706 // Encrypt
25707 for (var i = 0; i < blockSize; i++) {
25708 words[offset + i] ^= keystream[i];
25709 }
25710 }
25711
25712 return CFB;
25713 }());
25714
25715
25716 return CryptoJS.mode.CFB;
25717
25718 }));
25719 },{"./cipher-core":30,"./core":31}],41:[function(_dereq_,module,exports){
25720 ;(function (root, factory, undef) {
25721 if (typeof exports === "object") {
25722 // CommonJS
25723 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25724 }
25725 else if (typeof define === "function" && define.amd) {
25726 // AMD
25727 define(["./core", "./cipher-core"], factory);
25728 }
25729 else {
25730 // Global (browser)
25731 factory(root.CryptoJS);
25732 }
25733 }(this, function (CryptoJS) {
25734
25735 /** @preserve
25736 * Counter block mode compatible with Dr Brian Gladman fileenc.c
25737 * derived from CryptoJS.mode.CTR
25738 * Jan Hruby jhruby.web@gmail.com
25739 */
25740 CryptoJS.mode.CTRGladman = (function () {
25741 var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();
25742
25743 function incWord(word)
25744 {
25745 if (((word >> 24) & 0xff) === 0xff) { //overflow
25746 var b1 = (word >> 16)&0xff;
25747 var b2 = (word >> 8)&0xff;
25748 var b3 = word & 0xff;
25749
25750 if (b1 === 0xff) // overflow b1
25751 {
25752 b1 = 0;
25753 if (b2 === 0xff)
25754 {
25755 b2 = 0;
25756 if (b3 === 0xff)
25757 {
25758 b3 = 0;
25759 }
25760 else
25761 {
25762 ++b3;
25763 }
25764 }
25765 else
25766 {
25767 ++b2;
25768 }
25769 }
25770 else
25771 {
25772 ++b1;
25773 }
25774
25775 word = 0;
25776 word += (b1 << 16);
25777 word += (b2 << 8);
25778 word += b3;
25779 }
25780 else
25781 {
25782 word += (0x01 << 24);
25783 }
25784 return word;
25785 }
25786
25787 function incCounter(counter)
25788 {
25789 if ((counter[0] = incWord(counter[0])) === 0)
25790 {
25791 // encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8
25792 counter[1] = incWord(counter[1]);
25793 }
25794 return counter;
25795 }
25796
25797 var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
25798 processBlock: function (words, offset) {
25799 // Shortcuts
25800 var cipher = this._cipher
25801 var blockSize = cipher.blockSize;
25802 var iv = this._iv;
25803 var counter = this._counter;
25804
25805 // Generate keystream
25806 if (iv) {
25807 counter = this._counter = iv.slice(0);
25808
25809 // Remove IV for subsequent blocks
25810 this._iv = undefined;
25811 }
25812
25813 incCounter(counter);
25814
25815 var keystream = counter.slice(0);
25816 cipher.encryptBlock(keystream, 0);
25817
25818 // Encrypt
25819 for (var i = 0; i < blockSize; i++) {
25820 words[offset + i] ^= keystream[i];
25821 }
25822 }
25823 });
25824
25825 CTRGladman.Decryptor = Encryptor;
25826
25827 return CTRGladman;
25828 }());
25829
25830
25831
25832
25833 return CryptoJS.mode.CTRGladman;
25834
25835 }));
25836 },{"./cipher-core":30,"./core":31}],42:[function(_dereq_,module,exports){
25837 ;(function (root, factory, undef) {
25838 if (typeof exports === "object") {
25839 // CommonJS
25840 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25841 }
25842 else if (typeof define === "function" && define.amd) {
25843 // AMD
25844 define(["./core", "./cipher-core"], factory);
25845 }
25846 else {
25847 // Global (browser)
25848 factory(root.CryptoJS);
25849 }
25850 }(this, function (CryptoJS) {
25851
25852 /**
25853 * Counter block mode.
25854 */
25855 CryptoJS.mode.CTR = (function () {
25856 var CTR = CryptoJS.lib.BlockCipherMode.extend();
25857
25858 var Encryptor = CTR.Encryptor = CTR.extend({
25859 processBlock: function (words, offset) {
25860 // Shortcuts
25861 var cipher = this._cipher
25862 var blockSize = cipher.blockSize;
25863 var iv = this._iv;
25864 var counter = this._counter;
25865
25866 // Generate keystream
25867 if (iv) {
25868 counter = this._counter = iv.slice(0);
25869
25870 // Remove IV for subsequent blocks
25871 this._iv = undefined;
25872 }
25873 var keystream = counter.slice(0);
25874 cipher.encryptBlock(keystream, 0);
25875
25876 // Increment counter
25877 counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0
25878
25879 // Encrypt
25880 for (var i = 0; i < blockSize; i++) {
25881 words[offset + i] ^= keystream[i];
25882 }
25883 }
25884 });
25885
25886 CTR.Decryptor = Encryptor;
25887
25888 return CTR;
25889 }());
25890
25891
25892 return CryptoJS.mode.CTR;
25893
25894 }));
25895 },{"./cipher-core":30,"./core":31}],43:[function(_dereq_,module,exports){
25896 ;(function (root, factory, undef) {
25897 if (typeof exports === "object") {
25898 // CommonJS
25899 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25900 }
25901 else if (typeof define === "function" && define.amd) {
25902 // AMD
25903 define(["./core", "./cipher-core"], factory);
25904 }
25905 else {
25906 // Global (browser)
25907 factory(root.CryptoJS);
25908 }
25909 }(this, function (CryptoJS) {
25910
25911 /**
25912 * Electronic Codebook block mode.
25913 */
25914 CryptoJS.mode.ECB = (function () {
25915 var ECB = CryptoJS.lib.BlockCipherMode.extend();
25916
25917 ECB.Encryptor = ECB.extend({
25918 processBlock: function (words, offset) {
25919 this._cipher.encryptBlock(words, offset);
25920 }
25921 });
25922
25923 ECB.Decryptor = ECB.extend({
25924 processBlock: function (words, offset) {
25925 this._cipher.decryptBlock(words, offset);
25926 }
25927 });
25928
25929 return ECB;
25930 }());
25931
25932
25933 return CryptoJS.mode.ECB;
25934
25935 }));
25936 },{"./cipher-core":30,"./core":31}],44:[function(_dereq_,module,exports){
25937 ;(function (root, factory, undef) {
25938 if (typeof exports === "object") {
25939 // CommonJS
25940 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25941 }
25942 else if (typeof define === "function" && define.amd) {
25943 // AMD
25944 define(["./core", "./cipher-core"], factory);
25945 }
25946 else {
25947 // Global (browser)
25948 factory(root.CryptoJS);
25949 }
25950 }(this, function (CryptoJS) {
25951
25952 /**
25953 * Output Feedback block mode.
25954 */
25955 CryptoJS.mode.OFB = (function () {
25956 var OFB = CryptoJS.lib.BlockCipherMode.extend();
25957
25958 var Encryptor = OFB.Encryptor = OFB.extend({
25959 processBlock: function (words, offset) {
25960 // Shortcuts
25961 var cipher = this._cipher
25962 var blockSize = cipher.blockSize;
25963 var iv = this._iv;
25964 var keystream = this._keystream;
25965
25966 // Generate keystream
25967 if (iv) {
25968 keystream = this._keystream = iv.slice(0);
25969
25970 // Remove IV for subsequent blocks
25971 this._iv = undefined;
25972 }
25973 cipher.encryptBlock(keystream, 0);
25974
25975 // Encrypt
25976 for (var i = 0; i < blockSize; i++) {
25977 words[offset + i] ^= keystream[i];
25978 }
25979 }
25980 });
25981
25982 OFB.Decryptor = Encryptor;
25983
25984 return OFB;
25985 }());
25986
25987
25988 return CryptoJS.mode.OFB;
25989
25990 }));
25991 },{"./cipher-core":30,"./core":31}],45:[function(_dereq_,module,exports){
25992 ;(function (root, factory, undef) {
25993 if (typeof exports === "object") {
25994 // CommonJS
25995 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25996 }
25997 else if (typeof define === "function" && define.amd) {
25998 // AMD
25999 define(["./core", "./cipher-core"], factory);
26000 }
26001 else {
26002 // Global (browser)
26003 factory(root.CryptoJS);
26004 }
26005 }(this, function (CryptoJS) {
26006
26007 /**
26008 * ANSI X.923 padding strategy.
26009 */
26010 CryptoJS.pad.AnsiX923 = {
26011 pad: function (data, blockSize) {
26012 // Shortcuts
26013 var dataSigBytes = data.sigBytes;
26014 var blockSizeBytes = blockSize * 4;
26015
26016 // Count padding bytes
26017 var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
26018
26019 // Compute last byte position
26020 var lastBytePos = dataSigBytes + nPaddingBytes - 1;
26021
26022 // Pad
26023 data.clamp();
26024 data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8);
26025 data.sigBytes += nPaddingBytes;
26026 },
26027
26028 unpad: function (data) {
26029 // Get number of padding bytes from last byte
26030 var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
26031
26032 // Remove padding
26033 data.sigBytes -= nPaddingBytes;
26034 }
26035 };
26036
26037
26038 return CryptoJS.pad.Ansix923;
26039
26040 }));
26041 },{"./cipher-core":30,"./core":31}],46:[function(_dereq_,module,exports){
26042 ;(function (root, factory, undef) {
26043 if (typeof exports === "object") {
26044 // CommonJS
26045 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
26046 }
26047 else if (typeof define === "function" && define.amd) {
26048 // AMD
26049 define(["./core", "./cipher-core"], factory);
26050 }
26051 else {
26052 // Global (browser)
26053 factory(root.CryptoJS);
26054 }
26055 }(this, function (CryptoJS) {
26056
26057 /**
26058 * ISO 10126 padding strategy.
26059 */
26060 CryptoJS.pad.Iso10126 = {
26061 pad: function (data, blockSize) {
26062 // Shortcut
26063 var blockSizeBytes = blockSize * 4;
26064
26065 // Count padding bytes
26066 var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
26067
26068 // Pad
26069 data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).
26070 concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1));
26071 },
26072
26073 unpad: function (data) {
26074 // Get number of padding bytes from last byte
26075 var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
26076
26077 // Remove padding
26078 data.sigBytes -= nPaddingBytes;
26079 }
26080 };
26081
26082
26083 return CryptoJS.pad.Iso10126;
26084
26085 }));
26086 },{"./cipher-core":30,"./core":31}],47:[function(_dereq_,module,exports){
26087 ;(function (root, factory, undef) {
26088 if (typeof exports === "object") {
26089 // CommonJS
26090 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
26091 }
26092 else if (typeof define === "function" && define.amd) {
26093 // AMD
26094 define(["./core", "./cipher-core"], factory);
26095 }
26096 else {
26097 // Global (browser)
26098 factory(root.CryptoJS);
26099 }
26100 }(this, function (CryptoJS) {
26101
26102 /**
26103 * ISO/IEC 9797-1 Padding Method 2.
26104 */
26105 CryptoJS.pad.Iso97971 = {
26106 pad: function (data, blockSize) {
26107 // Add 0x80 byte
26108 data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
26109
26110 // Zero pad the rest
26111 CryptoJS.pad.ZeroPadding.pad(data, blockSize);
26112 },
26113
26114 unpad: function (data) {
26115 // Remove zero padding
26116 CryptoJS.pad.ZeroPadding.unpad(data);
26117
26118 // Remove one more byte -- the 0x80 byte
26119 data.sigBytes--;
26120 }
26121 };
26122
26123
26124 return CryptoJS.pad.Iso97971;
26125
26126 }));
26127 },{"./cipher-core":30,"./core":31}],48:[function(_dereq_,module,exports){
26128 ;(function (root, factory, undef) {
26129 if (typeof exports === "object") {
26130 // CommonJS
26131 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
26132 }
26133 else if (typeof define === "function" && define.amd) {
26134 // AMD
26135 define(["./core", "./cipher-core"], factory);
26136 }
26137 else {
26138 // Global (browser)
26139 factory(root.CryptoJS);
26140 }
26141 }(this, function (CryptoJS) {
26142
26143 /**
26144 * A noop padding strategy.
26145 */
26146 CryptoJS.pad.NoPadding = {
26147 pad: function () {
26148 },
26149
26150 unpad: function () {
26151 }
26152 };
26153
26154
26155 return CryptoJS.pad.NoPadding;
26156
26157 }));
26158 },{"./cipher-core":30,"./core":31}],49:[function(_dereq_,module,exports){
26159 ;(function (root, factory, undef) {
26160 if (typeof exports === "object") {
26161 // CommonJS
26162 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
26163 }
26164 else if (typeof define === "function" && define.amd) {
26165 // AMD
26166 define(["./core", "./cipher-core"], factory);
26167 }
26168 else {
26169 // Global (browser)
26170 factory(root.CryptoJS);
26171 }
26172 }(this, function (CryptoJS) {
26173
26174 /**
26175 * Zero padding strategy.
26176 */
26177 CryptoJS.pad.ZeroPadding = {
26178 pad: function (data, blockSize) {
26179 // Shortcut
26180 var blockSizeBytes = blockSize * 4;
26181
26182 // Pad
26183 data.clamp();
26184 data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
26185 },
26186
26187 unpad: function (data) {
26188 // Shortcut
26189 var dataWords = data.words;
26190
26191 // Unpad
26192 var i = data.sigBytes - 1;
26193 while (!((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
26194 i--;
26195 }
26196 data.sigBytes = i + 1;
26197 }
26198 };
26199
26200
26201 return CryptoJS.pad.ZeroPadding;
26202
26203 }));
26204 },{"./cipher-core":30,"./core":31}],50:[function(_dereq_,module,exports){
26205 ;(function (root, factory, undef) {
26206 if (typeof exports === "object") {
26207 // CommonJS
26208 module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha1"), _dereq_("./hmac"));
26209 }
26210 else if (typeof define === "function" && define.amd) {
26211 // AMD
26212 define(["./core", "./sha1", "./hmac"], factory);
26213 }
26214 else {
26215 // Global (browser)
26216 factory(root.CryptoJS);
26217 }
26218 }(this, function (CryptoJS) {
26219
26220 (function () {
26221 // Shortcuts
26222 var C = CryptoJS;
26223 var C_lib = C.lib;
26224 var Base = C_lib.Base;
26225 var WordArray = C_lib.WordArray;
26226 var C_algo = C.algo;
26227 var SHA1 = C_algo.SHA1;
26228 var HMAC = C_algo.HMAC;
26229
26230 /**
26231 * Password-Based Key Derivation Function 2 algorithm.
26232 */
26233 var PBKDF2 = C_algo.PBKDF2 = Base.extend({
26234 /**
26235 * Configuration options.
26236 *
26237 * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
26238 * @property {Hasher} hasher The hasher to use. Default: SHA1
26239 * @property {number} iterations The number of iterations to perform. Default: 1
26240 */
26241 cfg: Base.extend({
26242 keySize: 128/32,
26243 hasher: SHA1,
26244 iterations: 1
26245 }),
26246
26247 /**
26248 * Initializes a newly created key derivation function.
26249 *
26250 * @param {Object} cfg (Optional) The configuration options to use for the derivation.
26251 *
26252 * @example
26253 *
26254 * var kdf = CryptoJS.algo.PBKDF2.create();
26255 * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
26256 * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
26257 */
26258 init: function (cfg) {
26259 this.cfg = this.cfg.extend(cfg);
26260 },
26261
26262 /**
26263 * Computes the Password-Based Key Derivation Function 2.
26264 *
26265 * @param {WordArray|string} password The password.
26266 * @param {WordArray|string} salt A salt.
26267 *
26268 * @return {WordArray} The derived key.
26269 *
26270 * @example
26271 *
26272 * var key = kdf.compute(password, salt);
26273 */
26274 compute: function (password, salt) {
26275 // Shortcut
26276 var cfg = this.cfg;
26277
26278 // Init HMAC
26279 var hmac = HMAC.create(cfg.hasher, password);
26280
26281 // Initial values
26282 var derivedKey = WordArray.create();
26283 var blockIndex = WordArray.create([0x00000001]);
26284
26285 // Shortcuts
26286 var derivedKeyWords = derivedKey.words;
26287 var blockIndexWords = blockIndex.words;
26288 var keySize = cfg.keySize;
26289 var iterations = cfg.iterations;
26290
26291 // Generate key
26292 while (derivedKeyWords.length < keySize) {
26293 var block = hmac.update(salt).finalize(blockIndex);
26294 hmac.reset();
26295
26296 // Shortcuts
26297 var blockWords = block.words;
26298 var blockWordsLength = blockWords.length;
26299
26300 // Iterations
26301 var intermediate = block;
26302 for (var i = 1; i < iterations; i++) {
26303 intermediate = hmac.finalize(intermediate);
26304 hmac.reset();
26305
26306 // Shortcut
26307 var intermediateWords = intermediate.words;
26308
26309 // XOR intermediate with block
26310 for (var j = 0; j < blockWordsLength; j++) {
26311 blockWords[j] ^= intermediateWords[j];
26312 }
26313 }
26314
26315 derivedKey.concat(block);
26316 blockIndexWords[0]++;
26317 }
26318 derivedKey.sigBytes = keySize * 4;
26319
26320 return derivedKey;
26321 }
26322 });
26323
26324 /**
26325 * Computes the Password-Based Key Derivation Function 2.
26326 *
26327 * @param {WordArray|string} password The password.
26328 * @param {WordArray|string} salt A salt.
26329 * @param {Object} cfg (Optional) The configuration options to use for this computation.
26330 *
26331 * @return {WordArray} The derived key.
26332 *
26333 * @static
26334 *
26335 * @example
26336 *
26337 * var key = CryptoJS.PBKDF2(password, salt);
26338 * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 });
26339 * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 });
26340 */
26341 C.PBKDF2 = function (password, salt, cfg) {
26342 return PBKDF2.create(cfg).compute(password, salt);
26343 };
26344 }());
26345
26346
26347 return CryptoJS.PBKDF2;
26348
26349 }));
26350 },{"./core":31,"./hmac":36,"./sha1":55}],51:[function(_dereq_,module,exports){
26351 ;(function (root, factory, undef) {
26352 if (typeof exports === "object") {
26353 // CommonJS
26354 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
26355 }
26356 else if (typeof define === "function" && define.amd) {
26357 // AMD
26358 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
26359 }
26360 else {
26361 // Global (browser)
26362 factory(root.CryptoJS);
26363 }
26364 }(this, function (CryptoJS) {
26365
26366 (function () {
26367 // Shortcuts
26368 var C = CryptoJS;
26369 var C_lib = C.lib;
26370 var StreamCipher = C_lib.StreamCipher;
26371 var C_algo = C.algo;
26372
26373 // Reusable objects
26374 var S = [];
26375 var C_ = [];
26376 var G = [];
26377
26378 /**
26379 * Rabbit stream cipher algorithm.
26380 *
26381 * This is a legacy version that neglected to convert the key to little-endian.
26382 * This error doesn't affect the cipher's security,
26383 * but it does affect its compatibility with other implementations.
26384 */
26385 var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
26386 _doReset: function () {
26387 // Shortcuts
26388 var K = this._key.words;
26389 var iv = this.cfg.iv;
26390
26391 // Generate initial state values
26392 var X = this._X = [
26393 K[0], (K[3] << 16) | (K[2] >>> 16),
26394 K[1], (K[0] << 16) | (K[3] >>> 16),
26395 K[2], (K[1] << 16) | (K[0] >>> 16),
26396 K[3], (K[2] << 16) | (K[1] >>> 16)
26397 ];
26398
26399 // Generate initial counter values
26400 var C = this._C = [
26401 (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
26402 (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
26403 (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
26404 (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
26405 ];
26406
26407 // Carry bit
26408 this._b = 0;
26409
26410 // Iterate the system four times
26411 for (var i = 0; i < 4; i++) {
26412 nextState.call(this);
26413 }
26414
26415 // Modify the counters
26416 for (var i = 0; i < 8; i++) {
26417 C[i] ^= X[(i + 4) & 7];
26418 }
26419
26420 // IV setup
26421 if (iv) {
26422 // Shortcuts
26423 var IV = iv.words;
26424 var IV_0 = IV[0];
26425 var IV_1 = IV[1];
26426
26427 // Generate four subvectors
26428 var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
26429 var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
26430 var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
26431 var i3 = (i2 << 16) | (i0 & 0x0000ffff);
26432
26433 // Modify counter values
26434 C[0] ^= i0;
26435 C[1] ^= i1;
26436 C[2] ^= i2;
26437 C[3] ^= i3;
26438 C[4] ^= i0;
26439 C[5] ^= i1;
26440 C[6] ^= i2;
26441 C[7] ^= i3;
26442
26443 // Iterate the system four times
26444 for (var i = 0; i < 4; i++) {
26445 nextState.call(this);
26446 }
26447 }
26448 },
26449
26450 _doProcessBlock: function (M, offset) {
26451 // Shortcut
26452 var X = this._X;
26453
26454 // Iterate the system
26455 nextState.call(this);
26456
26457 // Generate four keystream words
26458 S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
26459 S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
26460 S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
26461 S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
26462
26463 for (var i = 0; i < 4; i++) {
26464 // Swap endian
26465 S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
26466 (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
26467
26468 // Encrypt
26469 M[offset + i] ^= S[i];
26470 }
26471 },
26472
26473 blockSize: 128/32,
26474
26475 ivSize: 64/32
26476 });
26477
26478 function nextState() {
26479 // Shortcuts
26480 var X = this._X;
26481 var C = this._C;
26482
26483 // Save old counter values
26484 for (var i = 0; i < 8; i++) {
26485 C_[i] = C[i];
26486 }
26487
26488 // Calculate new counter values
26489 C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
26490 C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
26491 C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
26492 C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
26493 C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
26494 C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
26495 C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
26496 C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
26497 this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
26498
26499 // Calculate the g-values
26500 for (var i = 0; i < 8; i++) {
26501 var gx = X[i] + C[i];
26502
26503 // Construct high and low argument for squaring
26504 var ga = gx & 0xffff;
26505 var gb = gx >>> 16;
26506
26507 // Calculate high and low result of squaring
26508 var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
26509 var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
26510
26511 // High XOR low
26512 G[i] = gh ^ gl;
26513 }
26514
26515 // Calculate new state values
26516 X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
26517 X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
26518 X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
26519 X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
26520 X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
26521 X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
26522 X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
26523 X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
26524 }
26525
26526 /**
26527 * Shortcut functions to the cipher's object interface.
26528 *
26529 * @example
26530 *
26531 * var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
26532 * var plaintext = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
26533 */
26534 C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
26535 }());
26536
26537
26538 return CryptoJS.RabbitLegacy;
26539
26540 }));
26541 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],52:[function(_dereq_,module,exports){
26542 ;(function (root, factory, undef) {
26543 if (typeof exports === "object") {
26544 // CommonJS
26545 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
26546 }
26547 else if (typeof define === "function" && define.amd) {
26548 // AMD
26549 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
26550 }
26551 else {
26552 // Global (browser)
26553 factory(root.CryptoJS);
26554 }
26555 }(this, function (CryptoJS) {
26556
26557 (function () {
26558 // Shortcuts
26559 var C = CryptoJS;
26560 var C_lib = C.lib;
26561 var StreamCipher = C_lib.StreamCipher;
26562 var C_algo = C.algo;
26563
26564 // Reusable objects
26565 var S = [];
26566 var C_ = [];
26567 var G = [];
26568
26569 /**
26570 * Rabbit stream cipher algorithm
26571 */
26572 var Rabbit = C_algo.Rabbit = StreamCipher.extend({
26573 _doReset: function () {
26574 // Shortcuts
26575 var K = this._key.words;
26576 var iv = this.cfg.iv;
26577
26578 // Swap endian
26579 for (var i = 0; i < 4; i++) {
26580 K[i] = (((K[i] << 8) | (K[i] >>> 24)) & 0x00ff00ff) |
26581 (((K[i] << 24) | (K[i] >>> 8)) & 0xff00ff00);
26582 }
26583
26584 // Generate initial state values
26585 var X = this._X = [
26586 K[0], (K[3] << 16) | (K[2] >>> 16),
26587 K[1], (K[0] << 16) | (K[3] >>> 16),
26588 K[2], (K[1] << 16) | (K[0] >>> 16),
26589 K[3], (K[2] << 16) | (K[1] >>> 16)
26590 ];
26591
26592 // Generate initial counter values
26593 var C = this._C = [
26594 (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
26595 (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
26596 (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
26597 (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
26598 ];
26599
26600 // Carry bit
26601 this._b = 0;
26602
26603 // Iterate the system four times
26604 for (var i = 0; i < 4; i++) {
26605 nextState.call(this);
26606 }
26607
26608 // Modify the counters
26609 for (var i = 0; i < 8; i++) {
26610 C[i] ^= X[(i + 4) & 7];
26611 }
26612
26613 // IV setup
26614 if (iv) {
26615 // Shortcuts
26616 var IV = iv.words;
26617 var IV_0 = IV[0];
26618 var IV_1 = IV[1];
26619
26620 // Generate four subvectors
26621 var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
26622 var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
26623 var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
26624 var i3 = (i2 << 16) | (i0 & 0x0000ffff);
26625
26626 // Modify counter values
26627 C[0] ^= i0;
26628 C[1] ^= i1;
26629 C[2] ^= i2;
26630 C[3] ^= i3;
26631 C[4] ^= i0;
26632 C[5] ^= i1;
26633 C[6] ^= i2;
26634 C[7] ^= i3;
26635
26636 // Iterate the system four times
26637 for (var i = 0; i < 4; i++) {
26638 nextState.call(this);
26639 }
26640 }
26641 },
26642
26643 _doProcessBlock: function (M, offset) {
26644 // Shortcut
26645 var X = this._X;
26646
26647 // Iterate the system
26648 nextState.call(this);
26649
26650 // Generate four keystream words
26651 S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
26652 S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
26653 S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
26654 S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
26655
26656 for (var i = 0; i < 4; i++) {
26657 // Swap endian
26658 S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
26659 (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
26660
26661 // Encrypt
26662 M[offset + i] ^= S[i];
26663 }
26664 },
26665
26666 blockSize: 128/32,
26667
26668 ivSize: 64/32
26669 });
26670
26671 function nextState() {
26672 // Shortcuts
26673 var X = this._X;
26674 var C = this._C;
26675
26676 // Save old counter values
26677 for (var i = 0; i < 8; i++) {
26678 C_[i] = C[i];
26679 }
26680
26681 // Calculate new counter values
26682 C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
26683 C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
26684 C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
26685 C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
26686 C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
26687 C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
26688 C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
26689 C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
26690 this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
26691
26692 // Calculate the g-values
26693 for (var i = 0; i < 8; i++) {
26694 var gx = X[i] + C[i];
26695
26696 // Construct high and low argument for squaring
26697 var ga = gx & 0xffff;
26698 var gb = gx >>> 16;
26699
26700 // Calculate high and low result of squaring
26701 var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
26702 var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
26703
26704 // High XOR low
26705 G[i] = gh ^ gl;
26706 }
26707
26708 // Calculate new state values
26709 X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
26710 X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
26711 X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
26712 X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
26713 X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
26714 X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
26715 X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
26716 X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
26717 }
26718
26719 /**
26720 * Shortcut functions to the cipher's object interface.
26721 *
26722 * @example
26723 *
26724 * var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
26725 * var plaintext = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
26726 */
26727 C.Rabbit = StreamCipher._createHelper(Rabbit);
26728 }());
26729
26730
26731 return CryptoJS.Rabbit;
26732
26733 }));
26734 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],53:[function(_dereq_,module,exports){
26735 ;(function (root, factory, undef) {
26736 if (typeof exports === "object") {
26737 // CommonJS
26738 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
26739 }
26740 else if (typeof define === "function" && define.amd) {
26741 // AMD
26742 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
26743 }
26744 else {
26745 // Global (browser)
26746 factory(root.CryptoJS);
26747 }
26748 }(this, function (CryptoJS) {
26749
26750 (function () {
26751 // Shortcuts
26752 var C = CryptoJS;
26753 var C_lib = C.lib;
26754 var StreamCipher = C_lib.StreamCipher;
26755 var C_algo = C.algo;
26756
26757 /**
26758 * RC4 stream cipher algorithm.
26759 */
26760 var RC4 = C_algo.RC4 = StreamCipher.extend({
26761 _doReset: function () {
26762 // Shortcuts
26763 var key = this._key;
26764 var keyWords = key.words;
26765 var keySigBytes = key.sigBytes;
26766
26767 // Init sbox
26768 var S = this._S = [];
26769 for (var i = 0; i < 256; i++) {
26770 S[i] = i;
26771 }
26772
26773 // Key setup
26774 for (var i = 0, j = 0; i < 256; i++) {
26775 var keyByteIndex = i % keySigBytes;
26776 var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff;
26777
26778 j = (j + S[i] + keyByte) % 256;
26779
26780 // Swap
26781 var t = S[i];
26782 S[i] = S[j];
26783 S[j] = t;
26784 }
26785
26786 // Counters
26787 this._i = this._j = 0;
26788 },
26789
26790 _doProcessBlock: function (M, offset) {
26791 M[offset] ^= generateKeystreamWord.call(this);
26792 },
26793
26794 keySize: 256/32,
26795
26796 ivSize: 0
26797 });
26798
26799 function generateKeystreamWord() {
26800 // Shortcuts
26801 var S = this._S;
26802 var i = this._i;
26803 var j = this._j;
26804
26805 // Generate keystream word
26806 var keystreamWord = 0;
26807 for (var n = 0; n < 4; n++) {
26808 i = (i + 1) % 256;
26809 j = (j + S[i]) % 256;
26810
26811 // Swap
26812 var t = S[i];
26813 S[i] = S[j];
26814 S[j] = t;
26815
26816 keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8);
26817 }
26818
26819 // Update counters
26820 this._i = i;
26821 this._j = j;
26822
26823 return keystreamWord;
26824 }
26825
26826 /**
26827 * Shortcut functions to the cipher's object interface.
26828 *
26829 * @example
26830 *
26831 * var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
26832 * var plaintext = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
26833 */
26834 C.RC4 = StreamCipher._createHelper(RC4);
26835
26836 /**
26837 * Modified RC4 stream cipher algorithm.
26838 */
26839 var RC4Drop = C_algo.RC4Drop = RC4.extend({
26840 /**
26841 * Configuration options.
26842 *
26843 * @property {number} drop The number of keystream words to drop. Default 192
26844 */
26845 cfg: RC4.cfg.extend({
26846 drop: 192
26847 }),
26848
26849 _doReset: function () {
26850 RC4._doReset.call(this);
26851
26852 // Drop
26853 for (var i = this.cfg.drop; i > 0; i--) {
26854 generateKeystreamWord.call(this);
26855 }
26856 }
26857 });
26858
26859 /**
26860 * Shortcut functions to the cipher's object interface.
26861 *
26862 * @example
26863 *
26864 * var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
26865 * var plaintext = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
26866 */
26867 C.RC4Drop = StreamCipher._createHelper(RC4Drop);
26868 }());
26869
26870
26871 return CryptoJS.RC4;
26872
26873 }));
26874 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],54:[function(_dereq_,module,exports){
26875 ;(function (root, factory) {
26876 if (typeof exports === "object") {
26877 // CommonJS
26878 module.exports = exports = factory(_dereq_("./core"));
26879 }
26880 else if (typeof define === "function" && define.amd) {
26881 // AMD
26882 define(["./core"], factory);
26883 }
26884 else {
26885 // Global (browser)
26886 factory(root.CryptoJS);
26887 }
26888 }(this, function (CryptoJS) {
26889
26890 /** @preserve
26891 (c) 2012 by Cédric Mesnil. All rights reserved.
26892
26893 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
26894
26895 - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
26896 - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
26897
26898 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26899 */
26900
26901 (function (Math) {
26902 // Shortcuts
26903 var C = CryptoJS;
26904 var C_lib = C.lib;
26905 var WordArray = C_lib.WordArray;
26906 var Hasher = C_lib.Hasher;
26907 var C_algo = C.algo;
26908
26909 // Constants table
26910 var _zl = WordArray.create([
26911 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
26912 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
26913 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
26914 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
26915 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]);
26916 var _zr = WordArray.create([
26917 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
26918 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
26919 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
26920 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
26921 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]);
26922 var _sl = WordArray.create([
26923 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
26924 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
26925 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
26926 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
26927 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ]);
26928 var _sr = WordArray.create([
26929 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
26930 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
26931 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
26932 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
26933 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]);
26934
26935 var _hl = WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]);
26936 var _hr = WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]);
26937
26938 /**
26939 * RIPEMD160 hash algorithm.
26940 */
26941 var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
26942 _doReset: function () {
26943 this._hash = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]);
26944 },
26945
26946 _doProcessBlock: function (M, offset) {
26947
26948 // Swap endian
26949 for (var i = 0; i < 16; i++) {
26950 // Shortcuts
26951 var offset_i = offset + i;
26952 var M_offset_i = M[offset_i];
26953
26954 // Swap
26955 M[offset_i] = (
26956 (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
26957 (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
26958 );
26959 }
26960 // Shortcut
26961 var H = this._hash.words;
26962 var hl = _hl.words;
26963 var hr = _hr.words;
26964 var zl = _zl.words;
26965 var zr = _zr.words;
26966 var sl = _sl.words;
26967 var sr = _sr.words;
26968
26969 // Working variables
26970 var al, bl, cl, dl, el;
26971 var ar, br, cr, dr, er;
26972
26973 ar = al = H[0];
26974 br = bl = H[1];
26975 cr = cl = H[2];
26976 dr = dl = H[3];
26977 er = el = H[4];
26978 // Computation
26979 var t;
26980 for (var i = 0; i < 80; i += 1) {
26981 t = (al + M[offset+zl[i]])|0;
26982 if (i<16){
26983 t += f1(bl,cl,dl) + hl[0];
26984 } else if (i<32) {
26985 t += f2(bl,cl,dl) + hl[1];
26986 } else if (i<48) {
26987 t += f3(bl,cl,dl) + hl[2];
26988 } else if (i<64) {
26989 t += f4(bl,cl,dl) + hl[3];
26990 } else {// if (i<80) {
26991 t += f5(bl,cl,dl) + hl[4];
26992 }
26993 t = t|0;
26994 t = rotl(t,sl[i]);
26995 t = (t+el)|0;
26996 al = el;
26997 el = dl;
26998 dl = rotl(cl, 10);
26999 cl = bl;
27000 bl = t;
27001
27002 t = (ar + M[offset+zr[i]])|0;
27003 if (i<16){
27004 t += f5(br,cr,dr) + hr[0];
27005 } else if (i<32) {
27006 t += f4(br,cr,dr) + hr[1];
27007 } else if (i<48) {
27008 t += f3(br,cr,dr) + hr[2];
27009 } else if (i<64) {
27010 t += f2(br,cr,dr) + hr[3];
27011 } else {// if (i<80) {
27012 t += f1(br,cr,dr) + hr[4];
27013 }
27014 t = t|0;
27015 t = rotl(t,sr[i]) ;
27016 t = (t+er)|0;
27017 ar = er;
27018 er = dr;
27019 dr = rotl(cr, 10);
27020 cr = br;
27021 br = t;
27022 }
27023 // Intermediate hash value
27024 t = (H[1] + cl + dr)|0;
27025 H[1] = (H[2] + dl + er)|0;
27026 H[2] = (H[3] + el + ar)|0;
27027 H[3] = (H[4] + al + br)|0;
27028 H[4] = (H[0] + bl + cr)|0;
27029 H[0] = t;
27030 },
27031
27032 _doFinalize: function () {
27033 // Shortcuts
27034 var data = this._data;
27035 var dataWords = data.words;
27036
27037 var nBitsTotal = this._nDataBytes * 8;
27038 var nBitsLeft = data.sigBytes * 8;
27039
27040 // Add padding
27041 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
27042 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
27043 (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
27044 (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)
27045 );
27046 data.sigBytes = (dataWords.length + 1) * 4;
27047
27048 // Hash final blocks
27049 this._process();
27050
27051 // Shortcuts
27052 var hash = this._hash;
27053 var H = hash.words;
27054
27055 // Swap endian
27056 for (var i = 0; i < 5; i++) {
27057 // Shortcut
27058 var H_i = H[i];
27059
27060 // Swap
27061 H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
27062 (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
27063 }
27064
27065 // Return final computed hash
27066 return hash;
27067 },
27068
27069 clone: function () {
27070 var clone = Hasher.clone.call(this);
27071 clone._hash = this._hash.clone();
27072
27073 return clone;
27074 }
27075 });
27076
27077
27078 function f1(x, y, z) {
27079 return ((x) ^ (y) ^ (z));
27080
27081 }
27082
27083 function f2(x, y, z) {
27084 return (((x)&(y)) | ((~x)&(z)));
27085 }
27086
27087 function f3(x, y, z) {
27088 return (((x) | (~(y))) ^ (z));
27089 }
27090
27091 function f4(x, y, z) {
27092 return (((x) & (z)) | ((y)&(~(z))));
27093 }
27094
27095 function f5(x, y, z) {
27096 return ((x) ^ ((y) |(~(z))));
27097
27098 }
27099
27100 function rotl(x,n) {
27101 return (x<<n) | (x>>>(32-n));
27102 }
27103
27104
27105 /**
27106 * Shortcut function to the hasher's object interface.
27107 *
27108 * @param {WordArray|string} message The message to hash.
27109 *
27110 * @return {WordArray} The hash.
27111 *
27112 * @static
27113 *
27114 * @example
27115 *
27116 * var hash = CryptoJS.RIPEMD160('message');
27117 * var hash = CryptoJS.RIPEMD160(wordArray);
27118 */
27119 C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
27120
27121 /**
27122 * Shortcut function to the HMAC's object interface.
27123 *
27124 * @param {WordArray|string} message The message to hash.
27125 * @param {WordArray|string} key The secret key.
27126 *
27127 * @return {WordArray} The HMAC.
27128 *
27129 * @static
27130 *
27131 * @example
27132 *
27133 * var hmac = CryptoJS.HmacRIPEMD160(message, key);
27134 */
27135 C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
27136 }(Math));
27137
27138
27139 return CryptoJS.RIPEMD160;
27140
27141 }));
27142 },{"./core":31}],55:[function(_dereq_,module,exports){
27143 ;(function (root, factory) {
27144 if (typeof exports === "object") {
27145 // CommonJS
27146 module.exports = exports = factory(_dereq_("./core"));
27147 }
27148 else if (typeof define === "function" && define.amd) {
27149 // AMD
27150 define(["./core"], factory);
27151 }
27152 else {
27153 // Global (browser)
27154 factory(root.CryptoJS);
27155 }
27156 }(this, function (CryptoJS) {
27157
27158 (function () {
27159 // Shortcuts
27160 var C = CryptoJS;
27161 var C_lib = C.lib;
27162 var WordArray = C_lib.WordArray;
27163 var Hasher = C_lib.Hasher;
27164 var C_algo = C.algo;
27165
27166 // Reusable object
27167 var W = [];
27168
27169 /**
27170 * SHA-1 hash algorithm.
27171 */
27172 var SHA1 = C_algo.SHA1 = Hasher.extend({
27173 _doReset: function () {
27174 this._hash = new WordArray.init([
27175 0x67452301, 0xefcdab89,
27176 0x98badcfe, 0x10325476,
27177 0xc3d2e1f0
27178 ]);
27179 },
27180
27181 _doProcessBlock: function (M, offset) {
27182 // Shortcut
27183 var H = this._hash.words;
27184
27185 // Working variables
27186 var a = H[0];
27187 var b = H[1];
27188 var c = H[2];
27189 var d = H[3];
27190 var e = H[4];
27191
27192 // Computation
27193 for (var i = 0; i < 80; i++) {
27194 if (i < 16) {
27195 W[i] = M[offset + i] | 0;
27196 } else {
27197 var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
27198 W[i] = (n << 1) | (n >>> 31);
27199 }
27200
27201 var t = ((a << 5) | (a >>> 27)) + e + W[i];
27202 if (i < 20) {
27203 t += ((b & c) | (~b & d)) + 0x5a827999;
27204 } else if (i < 40) {
27205 t += (b ^ c ^ d) + 0x6ed9eba1;
27206 } else if (i < 60) {
27207 t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
27208 } else /* if (i < 80) */ {
27209 t += (b ^ c ^ d) - 0x359d3e2a;
27210 }
27211
27212 e = d;
27213 d = c;
27214 c = (b << 30) | (b >>> 2);
27215 b = a;
27216 a = t;
27217 }
27218
27219 // Intermediate hash value
27220 H[0] = (H[0] + a) | 0;
27221 H[1] = (H[1] + b) | 0;
27222 H[2] = (H[2] + c) | 0;
27223 H[3] = (H[3] + d) | 0;
27224 H[4] = (H[4] + e) | 0;
27225 },
27226
27227 _doFinalize: function () {
27228 // Shortcuts
27229 var data = this._data;
27230 var dataWords = data.words;
27231
27232 var nBitsTotal = this._nDataBytes * 8;
27233 var nBitsLeft = data.sigBytes * 8;
27234
27235 // Add padding
27236 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
27237 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
27238 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
27239 data.sigBytes = dataWords.length * 4;
27240
27241 // Hash final blocks
27242 this._process();
27243
27244 // Return final computed hash
27245 return this._hash;
27246 },
27247
27248 clone: function () {
27249 var clone = Hasher.clone.call(this);
27250 clone._hash = this._hash.clone();
27251
27252 return clone;
27253 }
27254 });
27255
27256 /**
27257 * Shortcut function to the hasher's object interface.
27258 *
27259 * @param {WordArray|string} message The message to hash.
27260 *
27261 * @return {WordArray} The hash.
27262 *
27263 * @static
27264 *
27265 * @example
27266 *
27267 * var hash = CryptoJS.SHA1('message');
27268 * var hash = CryptoJS.SHA1(wordArray);
27269 */
27270 C.SHA1 = Hasher._createHelper(SHA1);
27271
27272 /**
27273 * Shortcut function to the HMAC's object interface.
27274 *
27275 * @param {WordArray|string} message The message to hash.
27276 * @param {WordArray|string} key The secret key.
27277 *
27278 * @return {WordArray} The HMAC.
27279 *
27280 * @static
27281 *
27282 * @example
27283 *
27284 * var hmac = CryptoJS.HmacSHA1(message, key);
27285 */
27286 C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
27287 }());
27288
27289
27290 return CryptoJS.SHA1;
27291
27292 }));
27293 },{"./core":31}],56:[function(_dereq_,module,exports){
27294 ;(function (root, factory, undef) {
27295 if (typeof exports === "object") {
27296 // CommonJS
27297 module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha256"));
27298 }
27299 else if (typeof define === "function" && define.amd) {
27300 // AMD
27301 define(["./core", "./sha256"], factory);
27302 }
27303 else {
27304 // Global (browser)
27305 factory(root.CryptoJS);
27306 }
27307 }(this, function (CryptoJS) {
27308
27309 (function () {
27310 // Shortcuts
27311 var C = CryptoJS;
27312 var C_lib = C.lib;
27313 var WordArray = C_lib.WordArray;
27314 var C_algo = C.algo;
27315 var SHA256 = C_algo.SHA256;
27316
27317 /**
27318 * SHA-224 hash algorithm.
27319 */
27320 var SHA224 = C_algo.SHA224 = SHA256.extend({
27321 _doReset: function () {
27322 this._hash = new WordArray.init([
27323 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
27324 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
27325 ]);
27326 },
27327
27328 _doFinalize: function () {
27329 var hash = SHA256._doFinalize.call(this);
27330
27331 hash.sigBytes -= 4;
27332
27333 return hash;
27334 }
27335 });
27336
27337 /**
27338 * Shortcut function to the hasher's object interface.
27339 *
27340 * @param {WordArray|string} message The message to hash.
27341 *
27342 * @return {WordArray} The hash.
27343 *
27344 * @static
27345 *
27346 * @example
27347 *
27348 * var hash = CryptoJS.SHA224('message');
27349 * var hash = CryptoJS.SHA224(wordArray);
27350 */
27351 C.SHA224 = SHA256._createHelper(SHA224);
27352
27353 /**
27354 * Shortcut function to the HMAC's object interface.
27355 *
27356 * @param {WordArray|string} message The message to hash.
27357 * @param {WordArray|string} key The secret key.
27358 *
27359 * @return {WordArray} The HMAC.
27360 *
27361 * @static
27362 *
27363 * @example
27364 *
27365 * var hmac = CryptoJS.HmacSHA224(message, key);
27366 */
27367 C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
27368 }());
27369
27370
27371 return CryptoJS.SHA224;
27372
27373 }));
27374 },{"./core":31,"./sha256":57}],57:[function(_dereq_,module,exports){
27375 ;(function (root, factory) {
27376 if (typeof exports === "object") {
27377 // CommonJS
27378 module.exports = exports = factory(_dereq_("./core"));
27379 }
27380 else if (typeof define === "function" && define.amd) {
27381 // AMD
27382 define(["./core"], factory);
27383 }
27384 else {
27385 // Global (browser)
27386 factory(root.CryptoJS);
27387 }
27388 }(this, function (CryptoJS) {
27389
27390 (function (Math) {
27391 // Shortcuts
27392 var C = CryptoJS;
27393 var C_lib = C.lib;
27394 var WordArray = C_lib.WordArray;
27395 var Hasher = C_lib.Hasher;
27396 var C_algo = C.algo;
27397
27398 // Initialization and round constants tables
27399 var H = [];
27400 var K = [];
27401
27402 // Compute constants
27403 (function () {
27404 function isPrime(n) {
27405 var sqrtN = Math.sqrt(n);
27406 for (var factor = 2; factor <= sqrtN; factor++) {
27407 if (!(n % factor)) {
27408 return false;
27409 }
27410 }
27411
27412 return true;
27413 }
27414
27415 function getFractionalBits(n) {
27416 return ((n - (n | 0)) * 0x100000000) | 0;
27417 }
27418
27419 var n = 2;
27420 var nPrime = 0;
27421 while (nPrime < 64) {
27422 if (isPrime(n)) {
27423 if (nPrime < 8) {
27424 H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
27425 }
27426 K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
27427
27428 nPrime++;
27429 }
27430
27431 n++;
27432 }
27433 }());
27434
27435 // Reusable object
27436 var W = [];
27437
27438 /**
27439 * SHA-256 hash algorithm.
27440 */
27441 var SHA256 = C_algo.SHA256 = Hasher.extend({
27442 _doReset: function () {
27443 this._hash = new WordArray.init(H.slice(0));
27444 },
27445
27446 _doProcessBlock: function (M, offset) {
27447 // Shortcut
27448 var H = this._hash.words;
27449
27450 // Working variables
27451 var a = H[0];
27452 var b = H[1];
27453 var c = H[2];
27454 var d = H[3];
27455 var e = H[4];
27456 var f = H[5];
27457 var g = H[6];
27458 var h = H[7];
27459
27460 // Computation
27461 for (var i = 0; i < 64; i++) {
27462 if (i < 16) {
27463 W[i] = M[offset + i] | 0;
27464 } else {
27465 var gamma0x = W[i - 15];
27466 var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
27467 ((gamma0x << 14) | (gamma0x >>> 18)) ^
27468 (gamma0x >>> 3);
27469
27470 var gamma1x = W[i - 2];
27471 var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
27472 ((gamma1x << 13) | (gamma1x >>> 19)) ^
27473 (gamma1x >>> 10);
27474
27475 W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
27476 }
27477
27478 var ch = (e & f) ^ (~e & g);
27479 var maj = (a & b) ^ (a & c) ^ (b & c);
27480
27481 var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
27482 var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
27483
27484 var t1 = h + sigma1 + ch + K[i] + W[i];
27485 var t2 = sigma0 + maj;
27486
27487 h = g;
27488 g = f;
27489 f = e;
27490 e = (d + t1) | 0;
27491 d = c;
27492 c = b;
27493 b = a;
27494 a = (t1 + t2) | 0;
27495 }
27496
27497 // Intermediate hash value
27498 H[0] = (H[0] + a) | 0;
27499 H[1] = (H[1] + b) | 0;
27500 H[2] = (H[2] + c) | 0;
27501 H[3] = (H[3] + d) | 0;
27502 H[4] = (H[4] + e) | 0;
27503 H[5] = (H[5] + f) | 0;
27504 H[6] = (H[6] + g) | 0;
27505 H[7] = (H[7] + h) | 0;
27506 },
27507
27508 _doFinalize: function () {
27509 // Shortcuts
27510 var data = this._data;
27511 var dataWords = data.words;
27512
27513 var nBitsTotal = this._nDataBytes * 8;
27514 var nBitsLeft = data.sigBytes * 8;
27515
27516 // Add padding
27517 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
27518 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
27519 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
27520 data.sigBytes = dataWords.length * 4;
27521
27522 // Hash final blocks
27523 this._process();
27524
27525 // Return final computed hash
27526 return this._hash;
27527 },
27528
27529 clone: function () {
27530 var clone = Hasher.clone.call(this);
27531 clone._hash = this._hash.clone();
27532
27533 return clone;
27534 }
27535 });
27536
27537 /**
27538 * Shortcut function to the hasher's object interface.
27539 *
27540 * @param {WordArray|string} message The message to hash.
27541 *
27542 * @return {WordArray} The hash.
27543 *
27544 * @static
27545 *
27546 * @example
27547 *
27548 * var hash = CryptoJS.SHA256('message');
27549 * var hash = CryptoJS.SHA256(wordArray);
27550 */
27551 C.SHA256 = Hasher._createHelper(SHA256);
27552
27553 /**
27554 * Shortcut function to the HMAC's object interface.
27555 *
27556 * @param {WordArray|string} message The message to hash.
27557 * @param {WordArray|string} key The secret key.
27558 *
27559 * @return {WordArray} The HMAC.
27560 *
27561 * @static
27562 *
27563 * @example
27564 *
27565 * var hmac = CryptoJS.HmacSHA256(message, key);
27566 */
27567 C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
27568 }(Math));
27569
27570
27571 return CryptoJS.SHA256;
27572
27573 }));
27574 },{"./core":31}],58:[function(_dereq_,module,exports){
27575 ;(function (root, factory, undef) {
27576 if (typeof exports === "object") {
27577 // CommonJS
27578 module.exports = exports = factory(_dereq_("./core"), _dereq_("./x64-core"));
27579 }
27580 else if (typeof define === "function" && define.amd) {
27581 // AMD
27582 define(["./core", "./x64-core"], factory);
27583 }
27584 else {
27585 // Global (browser)
27586 factory(root.CryptoJS);
27587 }
27588 }(this, function (CryptoJS) {
27589
27590 (function (Math) {
27591 // Shortcuts
27592 var C = CryptoJS;
27593 var C_lib = C.lib;
27594 var WordArray = C_lib.WordArray;
27595 var Hasher = C_lib.Hasher;
27596 var C_x64 = C.x64;
27597 var X64Word = C_x64.Word;
27598 var C_algo = C.algo;
27599
27600 // Constants tables
27601 var RHO_OFFSETS = [];
27602 var PI_INDEXES = [];
27603 var ROUND_CONSTANTS = [];
27604
27605 // Compute Constants
27606 (function () {
27607 // Compute rho offset constants
27608 var x = 1, y = 0;
27609 for (var t = 0; t < 24; t++) {
27610 RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;
27611
27612 var newX = y % 5;
27613 var newY = (2 * x + 3 * y) % 5;
27614 x = newX;
27615 y = newY;
27616 }
27617
27618 // Compute pi index constants
27619 for (var x = 0; x < 5; x++) {
27620 for (var y = 0; y < 5; y++) {
27621 PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;
27622 }
27623 }
27624
27625 // Compute round constants
27626 var LFSR = 0x01;
27627 for (var i = 0; i < 24; i++) {
27628 var roundConstantMsw = 0;
27629 var roundConstantLsw = 0;
27630
27631 for (var j = 0; j < 7; j++) {
27632 if (LFSR & 0x01) {
27633 var bitPosition = (1 << j) - 1;
27634 if (bitPosition < 32) {
27635 roundConstantLsw ^= 1 << bitPosition;
27636 } else /* if (bitPosition >= 32) */ {
27637 roundConstantMsw ^= 1 << (bitPosition - 32);
27638 }
27639 }
27640
27641 // Compute next LFSR
27642 if (LFSR & 0x80) {
27643 // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1
27644 LFSR = (LFSR << 1) ^ 0x71;
27645 } else {
27646 LFSR <<= 1;
27647 }
27648 }
27649
27650 ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
27651 }
27652 }());
27653
27654 // Reusable objects for temporary values
27655 var T = [];
27656 (function () {
27657 for (var i = 0; i < 25; i++) {
27658 T[i] = X64Word.create();
27659 }
27660 }());
27661
27662 /**
27663 * SHA-3 hash algorithm.
27664 */
27665 var SHA3 = C_algo.SHA3 = Hasher.extend({
27666 /**
27667 * Configuration options.
27668 *
27669 * @property {number} outputLength
27670 * The desired number of bits in the output hash.
27671 * Only values permitted are: 224, 256, 384, 512.
27672 * Default: 512
27673 */
27674 cfg: Hasher.cfg.extend({
27675 outputLength: 512
27676 }),
27677
27678 _doReset: function () {
27679 var state = this._state = []
27680 for (var i = 0; i < 25; i++) {
27681 state[i] = new X64Word.init();
27682 }
27683
27684 this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;
27685 },
27686
27687 _doProcessBlock: function (M, offset) {
27688 // Shortcuts
27689 var state = this._state;
27690 var nBlockSizeLanes = this.blockSize / 2;
27691
27692 // Absorb
27693 for (var i = 0; i < nBlockSizeLanes; i++) {
27694 // Shortcuts
27695 var M2i = M[offset + 2 * i];
27696 var M2i1 = M[offset + 2 * i + 1];
27697
27698 // Swap endian
27699 M2i = (
27700 (((M2i << 8) | (M2i >>> 24)) & 0x00ff00ff) |
27701 (((M2i << 24) | (M2i >>> 8)) & 0xff00ff00)
27702 );
27703 M2i1 = (
27704 (((M2i1 << 8) | (M2i1 >>> 24)) & 0x00ff00ff) |
27705 (((M2i1 << 24) | (M2i1 >>> 8)) & 0xff00ff00)
27706 );
27707
27708 // Absorb message into state
27709 var lane = state[i];
27710 lane.high ^= M2i1;
27711 lane.low ^= M2i;
27712 }
27713
27714 // Rounds
27715 for (var round = 0; round < 24; round++) {
27716 // Theta
27717 for (var x = 0; x < 5; x++) {
27718 // Mix column lanes
27719 var tMsw = 0, tLsw = 0;
27720 for (var y = 0; y < 5; y++) {
27721 var lane = state[x + 5 * y];
27722 tMsw ^= lane.high;
27723 tLsw ^= lane.low;
27724 }
27725
27726 // Temporary values
27727 var Tx = T[x];
27728 Tx.high = tMsw;
27729 Tx.low = tLsw;
27730 }
27731 for (var x = 0; x < 5; x++) {
27732 // Shortcuts
27733 var Tx4 = T[(x + 4) % 5];
27734 var Tx1 = T[(x + 1) % 5];
27735 var Tx1Msw = Tx1.high;
27736 var Tx1Lsw = Tx1.low;
27737
27738 // Mix surrounding columns
27739 var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));
27740 var tLsw = Tx4.low ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));
27741 for (var y = 0; y < 5; y++) {
27742 var lane = state[x + 5 * y];
27743 lane.high ^= tMsw;
27744 lane.low ^= tLsw;
27745 }
27746 }
27747
27748 // Rho Pi
27749 for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
27750 // Shortcuts
27751 var lane = state[laneIndex];
27752 var laneMsw = lane.high;
27753 var laneLsw = lane.low;
27754 var rhoOffset = RHO_OFFSETS[laneIndex];
27755
27756 // Rotate lanes
27757 if (rhoOffset < 32) {
27758 var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
27759 var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
27760 } else /* if (rhoOffset >= 32) */ {
27761 var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
27762 var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
27763 }
27764
27765 // Transpose lanes
27766 var TPiLane = T[PI_INDEXES[laneIndex]];
27767 TPiLane.high = tMsw;
27768 TPiLane.low = tLsw;
27769 }
27770
27771 // Rho pi at x = y = 0
27772 var T0 = T[0];
27773 var state0 = state[0];
27774 T0.high = state0.high;
27775 T0.low = state0.low;
27776
27777 // Chi
27778 for (var x = 0; x < 5; x++) {
27779 for (var y = 0; y < 5; y++) {
27780 // Shortcuts
27781 var laneIndex = x + 5 * y;
27782 var lane = state[laneIndex];
27783 var TLane = T[laneIndex];
27784 var Tx1Lane = T[((x + 1) % 5) + 5 * y];
27785 var Tx2Lane = T[((x + 2) % 5) + 5 * y];
27786
27787 // Mix rows
27788 lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
27789 lane.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low);
27790 }
27791 }
27792
27793 // Iota
27794 var lane = state[0];
27795 var roundConstant = ROUND_CONSTANTS[round];
27796 lane.high ^= roundConstant.high;
27797 lane.low ^= roundConstant.low;;
27798 }
27799 },
27800
27801 _doFinalize: function () {
27802 // Shortcuts
27803 var data = this._data;
27804 var dataWords = data.words;
27805 var nBitsTotal = this._nDataBytes * 8;
27806 var nBitsLeft = data.sigBytes * 8;
27807 var blockSizeBits = this.blockSize * 32;
27808
27809 // Add padding
27810 dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);
27811 dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;
27812 data.sigBytes = dataWords.length * 4;
27813
27814 // Hash final blocks
27815 this._process();
27816
27817 // Shortcuts
27818 var state = this._state;
27819 var outputLengthBytes = this.cfg.outputLength / 8;
27820 var outputLengthLanes = outputLengthBytes / 8;
27821
27822 // Squeeze
27823 var hashWords = [];
27824 for (var i = 0; i < outputLengthLanes; i++) {
27825 // Shortcuts
27826 var lane = state[i];
27827 var laneMsw = lane.high;
27828 var laneLsw = lane.low;
27829
27830 // Swap endian
27831 laneMsw = (
27832 (((laneMsw << 8) | (laneMsw >>> 24)) & 0x00ff00ff) |
27833 (((laneMsw << 24) | (laneMsw >>> 8)) & 0xff00ff00)
27834 );
27835 laneLsw = (
27836 (((laneLsw << 8) | (laneLsw >>> 24)) & 0x00ff00ff) |
27837 (((laneLsw << 24) | (laneLsw >>> 8)) & 0xff00ff00)
27838 );
27839
27840 // Squeeze state to retrieve hash
27841 hashWords.push(laneLsw);
27842 hashWords.push(laneMsw);
27843 }
27844
27845 // Return final computed hash
27846 return new WordArray.init(hashWords, outputLengthBytes);
27847 },
27848
27849 clone: function () {
27850 var clone = Hasher.clone.call(this);
27851
27852 var state = clone._state = this._state.slice(0);
27853 for (var i = 0; i < 25; i++) {
27854 state[i] = state[i].clone();
27855 }
27856
27857 return clone;
27858 }
27859 });
27860
27861 /**
27862 * Shortcut function to the hasher's object interface.
27863 *
27864 * @param {WordArray|string} message The message to hash.
27865 *
27866 * @return {WordArray} The hash.
27867 *
27868 * @static
27869 *
27870 * @example
27871 *
27872 * var hash = CryptoJS.SHA3('message');
27873 * var hash = CryptoJS.SHA3(wordArray);
27874 */
27875 C.SHA3 = Hasher._createHelper(SHA3);
27876
27877 /**
27878 * Shortcut function to the HMAC's object interface.
27879 *
27880 * @param {WordArray|string} message The message to hash.
27881 * @param {WordArray|string} key The secret key.
27882 *
27883 * @return {WordArray} The HMAC.
27884 *
27885 * @static
27886 *
27887 * @example
27888 *
27889 * var hmac = CryptoJS.HmacSHA3(message, key);
27890 */
27891 C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
27892 }(Math));
27893
27894
27895 return CryptoJS.SHA3;
27896
27897 }));
27898 },{"./core":31,"./x64-core":62}],59:[function(_dereq_,module,exports){
27899 ;(function (root, factory, undef) {
27900 if (typeof exports === "object") {
27901 // CommonJS
27902 module.exports = exports = factory(_dereq_("./core"), _dereq_("./x64-core"), _dereq_("./sha512"));
27903 }
27904 else if (typeof define === "function" && define.amd) {
27905 // AMD
27906 define(["./core", "./x64-core", "./sha512"], factory);
27907 }
27908 else {
27909 // Global (browser)
27910 factory(root.CryptoJS);
27911 }
27912 }(this, function (CryptoJS) {
27913
27914 (function () {
27915 // Shortcuts
27916 var C = CryptoJS;
27917 var C_x64 = C.x64;
27918 var X64Word = C_x64.Word;
27919 var X64WordArray = C_x64.WordArray;
27920 var C_algo = C.algo;
27921 var SHA512 = C_algo.SHA512;
27922
27923 /**
27924 * SHA-384 hash algorithm.
27925 */
27926 var SHA384 = C_algo.SHA384 = SHA512.extend({
27927 _doReset: function () {
27928 this._hash = new X64WordArray.init([
27929 new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
27930 new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
27931 new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
27932 new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
27933 ]);
27934 },
27935
27936 _doFinalize: function () {
27937 var hash = SHA512._doFinalize.call(this);
27938
27939 hash.sigBytes -= 16;
27940
27941 return hash;
27942 }
27943 });
27944
27945 /**
27946 * Shortcut function to the hasher's object interface.
27947 *
27948 * @param {WordArray|string} message The message to hash.
27949 *
27950 * @return {WordArray} The hash.
27951 *
27952 * @static
27953 *
27954 * @example
27955 *
27956 * var hash = CryptoJS.SHA384('message');
27957 * var hash = CryptoJS.SHA384(wordArray);
27958 */
27959 C.SHA384 = SHA512._createHelper(SHA384);
27960
27961 /**
27962 * Shortcut function to the HMAC's object interface.
27963 *
27964 * @param {WordArray|string} message The message to hash.
27965 * @param {WordArray|string} key The secret key.
27966 *
27967 * @return {WordArray} The HMAC.
27968 *
27969 * @static
27970 *
27971 * @example
27972 *
27973 * var hmac = CryptoJS.HmacSHA384(message, key);
27974 */
27975 C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
27976 }());
27977
27978
27979 return CryptoJS.SHA384;
27980
27981 }));
27982 },{"./core":31,"./sha512":60,"./x64-core":62}],60:[function(_dereq_,module,exports){
27983 ;(function (root, factory, undef) {
27984 if (typeof exports === "object") {
27985 // CommonJS
27986 module.exports = exports = factory(_dereq_("./core"), _dereq_("./x64-core"));
27987 }
27988 else if (typeof define === "function" && define.amd) {
27989 // AMD
27990 define(["./core", "./x64-core"], factory);
27991 }
27992 else {
27993 // Global (browser)
27994 factory(root.CryptoJS);
27995 }
27996 }(this, function (CryptoJS) {
27997
27998 (function () {
27999 // Shortcuts
28000 var C = CryptoJS;
28001 var C_lib = C.lib;
28002 var Hasher = C_lib.Hasher;
28003 var C_x64 = C.x64;
28004 var X64Word = C_x64.Word;
28005 var X64WordArray = C_x64.WordArray;
28006 var C_algo = C.algo;
28007
28008 function X64Word_create() {
28009 return X64Word.create.apply(X64Word, arguments);
28010 }
28011
28012 // Constants
28013 var K = [
28014 X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd),
28015 X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc),
28016 X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019),
28017 X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118),
28018 X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe),
28019 X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2),
28020 X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1),
28021 X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694),
28022 X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3),
28023 X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65),
28024 X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483),
28025 X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5),
28026 X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210),
28027 X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4),
28028 X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725),
28029 X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70),
28030 X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926),
28031 X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df),
28032 X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8),
28033 X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b),
28034 X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001),
28035 X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30),
28036 X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910),
28037 X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8),
28038 X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53),
28039 X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8),
28040 X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb),
28041 X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3),
28042 X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60),
28043 X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec),
28044 X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9),
28045 X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b),
28046 X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207),
28047 X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178),
28048 X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6),
28049 X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b),
28050 X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493),
28051 X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c),
28052 X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a),
28053 X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817)
28054 ];
28055
28056 // Reusable objects
28057 var W = [];
28058 (function () {
28059 for (var i = 0; i < 80; i++) {
28060 W[i] = X64Word_create();
28061 }
28062 }());
28063
28064 /**
28065 * SHA-512 hash algorithm.
28066 */
28067 var SHA512 = C_algo.SHA512 = Hasher.extend({
28068 _doReset: function () {
28069 this._hash = new X64WordArray.init([
28070 new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b),
28071 new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1),
28072 new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f),
28073 new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179)
28074 ]);
28075 },
28076
28077 _doProcessBlock: function (M, offset) {
28078 // Shortcuts
28079 var H = this._hash.words;
28080
28081 var H0 = H[0];
28082 var H1 = H[1];
28083 var H2 = H[2];
28084 var H3 = H[3];
28085 var H4 = H[4];
28086 var H5 = H[5];
28087 var H6 = H[6];
28088 var H7 = H[7];
28089
28090 var H0h = H0.high;
28091 var H0l = H0.low;
28092 var H1h = H1.high;
28093 var H1l = H1.low;
28094 var H2h = H2.high;
28095 var H2l = H2.low;
28096 var H3h = H3.high;
28097 var H3l = H3.low;
28098 var H4h = H4.high;
28099 var H4l = H4.low;
28100 var H5h = H5.high;
28101 var H5l = H5.low;
28102 var H6h = H6.high;
28103 var H6l = H6.low;
28104 var H7h = H7.high;
28105 var H7l = H7.low;
28106
28107 // Working variables
28108 var ah = H0h;
28109 var al = H0l;
28110 var bh = H1h;
28111 var bl = H1l;
28112 var ch = H2h;
28113 var cl = H2l;
28114 var dh = H3h;
28115 var dl = H3l;
28116 var eh = H4h;
28117 var el = H4l;
28118 var fh = H5h;
28119 var fl = H5l;
28120 var gh = H6h;
28121 var gl = H6l;
28122 var hh = H7h;
28123 var hl = H7l;
28124
28125 // Rounds
28126 for (var i = 0; i < 80; i++) {
28127 // Shortcut
28128 var Wi = W[i];
28129
28130 // Extend message
28131 if (i < 16) {
28132 var Wih = Wi.high = M[offset + i * 2] | 0;
28133 var Wil = Wi.low = M[offset + i * 2 + 1] | 0;
28134 } else {
28135 // Gamma0
28136 var gamma0x = W[i - 15];
28137 var gamma0xh = gamma0x.high;
28138 var gamma0xl = gamma0x.low;
28139 var gamma0h = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7);
28140 var gamma0l = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25));
28141
28142 // Gamma1
28143 var gamma1x = W[i - 2];
28144 var gamma1xh = gamma1x.high;
28145 var gamma1xl = gamma1x.low;
28146 var gamma1h = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6);
28147 var gamma1l = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26));
28148
28149 // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
28150 var Wi7 = W[i - 7];
28151 var Wi7h = Wi7.high;
28152 var Wi7l = Wi7.low;
28153
28154 var Wi16 = W[i - 16];
28155 var Wi16h = Wi16.high;
28156 var Wi16l = Wi16.low;
28157
28158 var Wil = gamma0l + Wi7l;
28159 var Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
28160 var Wil = Wil + gamma1l;
28161 var Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
28162 var Wil = Wil + Wi16l;
28163 var Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
28164
28165 Wi.high = Wih;
28166 Wi.low = Wil;
28167 }
28168
28169 var chh = (eh & fh) ^ (~eh & gh);
28170 var chl = (el & fl) ^ (~el & gl);
28171 var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
28172 var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
28173
28174 var sigma0h = ((ah >>> 28) | (al << 4)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
28175 var sigma0l = ((al >>> 28) | (ah << 4)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
28176 var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9));
28177 var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9));
28178
28179 // t1 = h + sigma1 + ch + K[i] + W[i]
28180 var Ki = K[i];
28181 var Kih = Ki.high;
28182 var Kil = Ki.low;
28183
28184 var t1l = hl + sigma1l;
28185 var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
28186 var t1l = t1l + chl;
28187 var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
28188 var t1l = t1l + Kil;
28189 var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0);
28190 var t1l = t1l + Wil;
28191 var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0);
28192
28193 // t2 = sigma0 + maj
28194 var t2l = sigma0l + majl;
28195 var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
28196
28197 // Update working variables
28198 hh = gh;
28199 hl = gl;
28200 gh = fh;
28201 gl = fl;
28202 fh = eh;
28203 fl = el;
28204 el = (dl + t1l) | 0;
28205 eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
28206 dh = ch;
28207 dl = cl;
28208 ch = bh;
28209 cl = bl;
28210 bh = ah;
28211 bl = al;
28212 al = (t1l + t2l) | 0;
28213 ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
28214 }
28215
28216 // Intermediate hash value
28217 H0l = H0.low = (H0l + al);
28218 H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0));
28219 H1l = H1.low = (H1l + bl);
28220 H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0));
28221 H2l = H2.low = (H2l + cl);
28222 H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0));
28223 H3l = H3.low = (H3l + dl);
28224 H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0));
28225 H4l = H4.low = (H4l + el);
28226 H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0));
28227 H5l = H5.low = (H5l + fl);
28228 H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0));
28229 H6l = H6.low = (H6l + gl);
28230 H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0));
28231 H7l = H7.low = (H7l + hl);
28232 H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0));
28233 },
28234
28235 _doFinalize: function () {
28236 // Shortcuts
28237 var data = this._data;
28238 var dataWords = data.words;
28239
28240 var nBitsTotal = this._nDataBytes * 8;
28241 var nBitsLeft = data.sigBytes * 8;
28242
28243 // Add padding
28244 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
28245 dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000);
28246 dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal;
28247 data.sigBytes = dataWords.length * 4;
28248
28249 // Hash final blocks
28250 this._process();
28251
28252 // Convert hash to 32-bit word array before returning
28253 var hash = this._hash.toX32();
28254
28255 // Return final computed hash
28256 return hash;
28257 },
28258
28259 clone: function () {
28260 var clone = Hasher.clone.call(this);
28261 clone._hash = this._hash.clone();
28262
28263 return clone;
28264 },
28265
28266 blockSize: 1024/32
28267 });
28268
28269 /**
28270 * Shortcut function to the hasher's object interface.
28271 *
28272 * @param {WordArray|string} message The message to hash.
28273 *
28274 * @return {WordArray} The hash.
28275 *
28276 * @static
28277 *
28278 * @example
28279 *
28280 * var hash = CryptoJS.SHA512('message');
28281 * var hash = CryptoJS.SHA512(wordArray);
28282 */
28283 C.SHA512 = Hasher._createHelper(SHA512);
28284
28285 /**
28286 * Shortcut function to the HMAC's object interface.
28287 *
28288 * @param {WordArray|string} message The message to hash.
28289 * @param {WordArray|string} key The secret key.
28290 *
28291 * @return {WordArray} The HMAC.
28292 *
28293 * @static
28294 *
28295 * @example
28296 *
28297 * var hmac = CryptoJS.HmacSHA512(message, key);
28298 */
28299 C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
28300 }());
28301
28302
28303 return CryptoJS.SHA512;
28304
28305 }));
28306 },{"./core":31,"./x64-core":62}],61:[function(_dereq_,module,exports){
28307 ;(function (root, factory, undef) {
28308 if (typeof exports === "object") {
28309 // CommonJS
28310 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
28311 }
28312 else if (typeof define === "function" && define.amd) {
28313 // AMD
28314 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
28315 }
28316 else {
28317 // Global (browser)
28318 factory(root.CryptoJS);
28319 }
28320 }(this, function (CryptoJS) {
28321
28322 (function () {
28323 // Shortcuts
28324 var C = CryptoJS;
28325 var C_lib = C.lib;
28326 var WordArray = C_lib.WordArray;
28327 var BlockCipher = C_lib.BlockCipher;
28328 var C_algo = C.algo;
28329
28330 // Permuted Choice 1 constants
28331 var PC1 = [
28332 57, 49, 41, 33, 25, 17, 9, 1,
28333 58, 50, 42, 34, 26, 18, 10, 2,
28334 59, 51, 43, 35, 27, 19, 11, 3,
28335 60, 52, 44, 36, 63, 55, 47, 39,
28336 31, 23, 15, 7, 62, 54, 46, 38,
28337 30, 22, 14, 6, 61, 53, 45, 37,
28338 29, 21, 13, 5, 28, 20, 12, 4
28339 ];
28340
28341 // Permuted Choice 2 constants
28342 var PC2 = [
28343 14, 17, 11, 24, 1, 5,
28344 3, 28, 15, 6, 21, 10,
28345 23, 19, 12, 4, 26, 8,
28346 16, 7, 27, 20, 13, 2,
28347 41, 52, 31, 37, 47, 55,
28348 30, 40, 51, 45, 33, 48,
28349 44, 49, 39, 56, 34, 53,
28350 46, 42, 50, 36, 29, 32
28351 ];
28352
28353 // Cumulative bit shift constants
28354 var BIT_SHIFTS = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
28355
28356 // SBOXes and round permutation constants
28357 var SBOX_P = [
28358 {
28359 0x0: 0x808200,
28360 0x10000000: 0x8000,
28361 0x20000000: 0x808002,
28362 0x30000000: 0x2,
28363 0x40000000: 0x200,
28364 0x50000000: 0x808202,
28365 0x60000000: 0x800202,
28366 0x70000000: 0x800000,
28367 0x80000000: 0x202,
28368 0x90000000: 0x800200,
28369 0xa0000000: 0x8200,
28370 0xb0000000: 0x808000,
28371 0xc0000000: 0x8002,
28372 0xd0000000: 0x800002,
28373 0xe0000000: 0x0,
28374 0xf0000000: 0x8202,
28375 0x8000000: 0x0,
28376 0x18000000: 0x808202,
28377 0x28000000: 0x8202,
28378 0x38000000: 0x8000,
28379 0x48000000: 0x808200,
28380 0x58000000: 0x200,
28381 0x68000000: 0x808002,
28382 0x78000000: 0x2,
28383 0x88000000: 0x800200,
28384 0x98000000: 0x8200,
28385 0xa8000000: 0x808000,
28386 0xb8000000: 0x800202,
28387 0xc8000000: 0x800002,
28388 0xd8000000: 0x8002,
28389 0xe8000000: 0x202,
28390 0xf8000000: 0x800000,
28391 0x1: 0x8000,
28392 0x10000001: 0x2,
28393 0x20000001: 0x808200,
28394 0x30000001: 0x800000,
28395 0x40000001: 0x808002,
28396 0x50000001: 0x8200,
28397 0x60000001: 0x200,
28398 0x70000001: 0x800202,
28399 0x80000001: 0x808202,
28400 0x90000001: 0x808000,
28401 0xa0000001: 0x800002,
28402 0xb0000001: 0x8202,
28403 0xc0000001: 0x202,
28404 0xd0000001: 0x800200,
28405 0xe0000001: 0x8002,
28406 0xf0000001: 0x0,
28407 0x8000001: 0x808202,
28408 0x18000001: 0x808000,
28409 0x28000001: 0x800000,
28410 0x38000001: 0x200,
28411 0x48000001: 0x8000,
28412 0x58000001: 0x800002,
28413 0x68000001: 0x2,
28414 0x78000001: 0x8202,
28415 0x88000001: 0x8002,
28416 0x98000001: 0x800202,
28417 0xa8000001: 0x202,
28418 0xb8000001: 0x808200,
28419 0xc8000001: 0x800200,
28420 0xd8000001: 0x0,
28421 0xe8000001: 0x8200,
28422 0xf8000001: 0x808002
28423 },
28424 {
28425 0x0: 0x40084010,
28426 0x1000000: 0x4000,
28427 0x2000000: 0x80000,
28428 0x3000000: 0x40080010,
28429 0x4000000: 0x40000010,
28430 0x5000000: 0x40084000,
28431 0x6000000: 0x40004000,
28432 0x7000000: 0x10,
28433 0x8000000: 0x84000,
28434 0x9000000: 0x40004010,
28435 0xa000000: 0x40000000,
28436 0xb000000: 0x84010,
28437 0xc000000: 0x80010,
28438 0xd000000: 0x0,
28439 0xe000000: 0x4010,
28440 0xf000000: 0x40080000,
28441 0x800000: 0x40004000,
28442 0x1800000: 0x84010,
28443 0x2800000: 0x10,
28444 0x3800000: 0x40004010,
28445 0x4800000: 0x40084010,
28446 0x5800000: 0x40000000,
28447 0x6800000: 0x80000,
28448 0x7800000: 0x40080010,
28449 0x8800000: 0x80010,
28450 0x9800000: 0x0,
28451 0xa800000: 0x4000,
28452 0xb800000: 0x40080000,
28453 0xc800000: 0x40000010,
28454 0xd800000: 0x84000,
28455 0xe800000: 0x40084000,
28456 0xf800000: 0x4010,
28457 0x10000000: 0x0,
28458 0x11000000: 0x40080010,
28459 0x12000000: 0x40004010,
28460 0x13000000: 0x40084000,
28461 0x14000000: 0x40080000,
28462 0x15000000: 0x10,
28463 0x16000000: 0x84010,
28464 0x17000000: 0x4000,
28465 0x18000000: 0x4010,
28466 0x19000000: 0x80000,
28467 0x1a000000: 0x80010,
28468 0x1b000000: 0x40000010,
28469 0x1c000000: 0x84000,
28470 0x1d000000: 0x40004000,
28471 0x1e000000: 0x40000000,
28472 0x1f000000: 0x40084010,
28473 0x10800000: 0x84010,
28474 0x11800000: 0x80000,
28475 0x12800000: 0x40080000,
28476 0x13800000: 0x4000,
28477 0x14800000: 0x40004000,
28478 0x15800000: 0x40084010,
28479 0x16800000: 0x10,
28480 0x17800000: 0x40000000,
28481 0x18800000: 0x40084000,
28482 0x19800000: 0x40000010,
28483 0x1a800000: 0x40004010,
28484 0x1b800000: 0x80010,
28485 0x1c800000: 0x0,
28486 0x1d800000: 0x4010,
28487 0x1e800000: 0x40080010,
28488 0x1f800000: 0x84000
28489 },
28490 {
28491 0x0: 0x104,
28492 0x100000: 0x0,
28493 0x200000: 0x4000100,
28494 0x300000: 0x10104,
28495 0x400000: 0x10004,
28496 0x500000: 0x4000004,
28497 0x600000: 0x4010104,
28498 0x700000: 0x4010000,
28499 0x800000: 0x4000000,
28500 0x900000: 0x4010100,
28501 0xa00000: 0x10100,
28502 0xb00000: 0x4010004,
28503 0xc00000: 0x4000104,
28504 0xd00000: 0x10000,
28505 0xe00000: 0x4,
28506 0xf00000: 0x100,
28507 0x80000: 0x4010100,
28508 0x180000: 0x4010004,
28509 0x280000: 0x0,
28510 0x380000: 0x4000100,
28511 0x480000: 0x4000004,
28512 0x580000: 0x10000,
28513 0x680000: 0x10004,
28514 0x780000: 0x104,
28515 0x880000: 0x4,
28516 0x980000: 0x100,
28517 0xa80000: 0x4010000,
28518 0xb80000: 0x10104,
28519 0xc80000: 0x10100,
28520 0xd80000: 0x4000104,
28521 0xe80000: 0x4010104,
28522 0xf80000: 0x4000000,
28523 0x1000000: 0x4010100,
28524 0x1100000: 0x10004,
28525 0x1200000: 0x10000,
28526 0x1300000: 0x4000100,
28527 0x1400000: 0x100,
28528 0x1500000: 0x4010104,
28529 0x1600000: 0x4000004,
28530 0x1700000: 0x0,
28531 0x1800000: 0x4000104,
28532 0x1900000: 0x4000000,
28533 0x1a00000: 0x4,
28534 0x1b00000: 0x10100,
28535 0x1c00000: 0x4010000,
28536 0x1d00000: 0x104,
28537 0x1e00000: 0x10104,
28538 0x1f00000: 0x4010004,
28539 0x1080000: 0x4000000,
28540 0x1180000: 0x104,
28541 0x1280000: 0x4010100,
28542 0x1380000: 0x0,
28543 0x1480000: 0x10004,
28544 0x1580000: 0x4000100,
28545 0x1680000: 0x100,
28546 0x1780000: 0x4010004,
28547 0x1880000: 0x10000,
28548 0x1980000: 0x4010104,
28549 0x1a80000: 0x10104,
28550 0x1b80000: 0x4000004,
28551 0x1c80000: 0x4000104,
28552 0x1d80000: 0x4010000,
28553 0x1e80000: 0x4,
28554 0x1f80000: 0x10100
28555 },
28556 {
28557 0x0: 0x80401000,
28558 0x10000: 0x80001040,
28559 0x20000: 0x401040,
28560 0x30000: 0x80400000,
28561 0x40000: 0x0,
28562 0x50000: 0x401000,
28563 0x60000: 0x80000040,
28564 0x70000: 0x400040,
28565 0x80000: 0x80000000,
28566 0x90000: 0x400000,
28567 0xa0000: 0x40,
28568 0xb0000: 0x80001000,
28569 0xc0000: 0x80400040,
28570 0xd0000: 0x1040,
28571 0xe0000: 0x1000,
28572 0xf0000: 0x80401040,
28573 0x8000: 0x80001040,
28574 0x18000: 0x40,
28575 0x28000: 0x80400040,
28576 0x38000: 0x80001000,
28577 0x48000: 0x401000,
28578 0x58000: 0x80401040,
28579 0x68000: 0x0,
28580 0x78000: 0x80400000,
28581 0x88000: 0x1000,
28582 0x98000: 0x80401000,
28583 0xa8000: 0x400000,
28584 0xb8000: 0x1040,
28585 0xc8000: 0x80000000,
28586 0xd8000: 0x400040,
28587 0xe8000: 0x401040,
28588 0xf8000: 0x80000040,
28589 0x100000: 0x400040,
28590 0x110000: 0x401000,
28591 0x120000: 0x80000040,
28592 0x130000: 0x0,
28593 0x140000: 0x1040,
28594 0x150000: 0x80400040,
28595 0x160000: 0x80401000,
28596 0x170000: 0x80001040,
28597 0x180000: 0x80401040,
28598 0x190000: 0x80000000,
28599 0x1a0000: 0x80400000,
28600 0x1b0000: 0x401040,
28601 0x1c0000: 0x80001000,
28602 0x1d0000: 0x400000,
28603 0x1e0000: 0x40,
28604 0x1f0000: 0x1000,
28605 0x108000: 0x80400000,
28606 0x118000: 0x80401040,
28607 0x128000: 0x0,
28608 0x138000: 0x401000,
28609 0x148000: 0x400040,
28610 0x158000: 0x80000000,
28611 0x168000: 0x80001040,
28612 0x178000: 0x40,
28613 0x188000: 0x80000040,
28614 0x198000: 0x1000,
28615 0x1a8000: 0x80001000,
28616 0x1b8000: 0x80400040,
28617 0x1c8000: 0x1040,
28618 0x1d8000: 0x80401000,
28619 0x1e8000: 0x400000,
28620 0x1f8000: 0x401040
28621 },
28622 {
28623 0x0: 0x80,
28624 0x1000: 0x1040000,
28625 0x2000: 0x40000,
28626 0x3000: 0x20000000,
28627 0x4000: 0x20040080,
28628 0x5000: 0x1000080,
28629 0x6000: 0x21000080,
28630 0x7000: 0x40080,
28631 0x8000: 0x1000000,
28632 0x9000: 0x20040000,
28633 0xa000: 0x20000080,
28634 0xb000: 0x21040080,
28635 0xc000: 0x21040000,
28636 0xd000: 0x0,
28637 0xe000: 0x1040080,
28638 0xf000: 0x21000000,
28639 0x800: 0x1040080,
28640 0x1800: 0x21000080,
28641 0x2800: 0x80,
28642 0x3800: 0x1040000,
28643 0x4800: 0x40000,
28644 0x5800: 0x20040080,
28645 0x6800: 0x21040000,
28646 0x7800: 0x20000000,
28647 0x8800: 0x20040000,
28648 0x9800: 0x0,
28649 0xa800: 0x21040080,
28650 0xb800: 0x1000080,
28651 0xc800: 0x20000080,
28652 0xd800: 0x21000000,
28653 0xe800: 0x1000000,
28654 0xf800: 0x40080,
28655 0x10000: 0x40000,
28656 0x11000: 0x80,
28657 0x12000: 0x20000000,
28658 0x13000: 0x21000080,
28659 0x14000: 0x1000080,
28660 0x15000: 0x21040000,
28661 0x16000: 0x20040080,
28662 0x17000: 0x1000000,
28663 0x18000: 0x21040080,
28664 0x19000: 0x21000000,
28665 0x1a000: 0x1040000,
28666 0x1b000: 0x20040000,
28667 0x1c000: 0x40080,
28668 0x1d000: 0x20000080,
28669 0x1e000: 0x0,
28670 0x1f000: 0x1040080,
28671 0x10800: 0x21000080,
28672 0x11800: 0x1000000,
28673 0x12800: 0x1040000,
28674 0x13800: 0x20040080,
28675 0x14800: 0x20000000,
28676 0x15800: 0x1040080,
28677 0x16800: 0x80,
28678 0x17800: 0x21040000,
28679 0x18800: 0x40080,
28680 0x19800: 0x21040080,
28681 0x1a800: 0x0,
28682 0x1b800: 0x21000000,
28683 0x1c800: 0x1000080,
28684 0x1d800: 0x40000,
28685 0x1e800: 0x20040000,
28686 0x1f800: 0x20000080
28687 },
28688 {
28689 0x0: 0x10000008,
28690 0x100: 0x2000,
28691 0x200: 0x10200000,
28692 0x300: 0x10202008,
28693 0x400: 0x10002000,
28694 0x500: 0x200000,
28695 0x600: 0x200008,
28696 0x700: 0x10000000,
28697 0x800: 0x0,
28698 0x900: 0x10002008,
28699 0xa00: 0x202000,
28700 0xb00: 0x8,
28701 0xc00: 0x10200008,
28702 0xd00: 0x202008,
28703 0xe00: 0x2008,
28704 0xf00: 0x10202000,
28705 0x80: 0x10200000,
28706 0x180: 0x10202008,
28707 0x280: 0x8,
28708 0x380: 0x200000,
28709 0x480: 0x202008,
28710 0x580: 0x10000008,
28711 0x680: 0x10002000,
28712 0x780: 0x2008,
28713 0x880: 0x200008,
28714 0x980: 0x2000,
28715 0xa80: 0x10002008,
28716 0xb80: 0x10200008,
28717 0xc80: 0x0,
28718 0xd80: 0x10202000,
28719 0xe80: 0x202000,
28720 0xf80: 0x10000000,
28721 0x1000: 0x10002000,
28722 0x1100: 0x10200008,
28723 0x1200: 0x10202008,
28724 0x1300: 0x2008,
28725 0x1400: 0x200000,
28726 0x1500: 0x10000000,
28727 0x1600: 0x10000008,
28728 0x1700: 0x202000,
28729 0x1800: 0x202008,
28730 0x1900: 0x0,
28731 0x1a00: 0x8,
28732 0x1b00: 0x10200000,
28733 0x1c00: 0x2000,
28734 0x1d00: 0x10002008,
28735 0x1e00: 0x10202000,
28736 0x1f00: 0x200008,
28737 0x1080: 0x8,
28738 0x1180: 0x202000,
28739 0x1280: 0x200000,
28740 0x1380: 0x10000008,
28741 0x1480: 0x10002000,
28742 0x1580: 0x2008,
28743 0x1680: 0x10202008,
28744 0x1780: 0x10200000,
28745 0x1880: 0x10202000,
28746 0x1980: 0x10200008,
28747 0x1a80: 0x2000,
28748 0x1b80: 0x202008,
28749 0x1c80: 0x200008,
28750 0x1d80: 0x0,
28751 0x1e80: 0x10000000,
28752 0x1f80: 0x10002008
28753 },
28754 {
28755 0x0: 0x100000,
28756 0x10: 0x2000401,
28757 0x20: 0x400,
28758 0x30: 0x100401,
28759 0x40: 0x2100401,
28760 0x50: 0x0,
28761 0x60: 0x1,
28762 0x70: 0x2100001,
28763 0x80: 0x2000400,
28764 0x90: 0x100001,
28765 0xa0: 0x2000001,
28766 0xb0: 0x2100400,
28767 0xc0: 0x2100000,
28768 0xd0: 0x401,
28769 0xe0: 0x100400,
28770 0xf0: 0x2000000,
28771 0x8: 0x2100001,
28772 0x18: 0x0,
28773 0x28: 0x2000401,
28774 0x38: 0x2100400,
28775 0x48: 0x100000,
28776 0x58: 0x2000001,
28777 0x68: 0x2000000,
28778 0x78: 0x401,
28779 0x88: 0x100401,
28780 0x98: 0x2000400,
28781 0xa8: 0x2100000,
28782 0xb8: 0x100001,
28783 0xc8: 0x400,
28784 0xd8: 0x2100401,
28785 0xe8: 0x1,
28786 0xf8: 0x100400,
28787 0x100: 0x2000000,
28788 0x110: 0x100000,
28789 0x120: 0x2000401,
28790 0x130: 0x2100001,
28791 0x140: 0x100001,
28792 0x150: 0x2000400,
28793 0x160: 0x2100400,
28794 0x170: 0x100401,
28795 0x180: 0x401,
28796 0x190: 0x2100401,
28797 0x1a0: 0x100400,
28798 0x1b0: 0x1,
28799 0x1c0: 0x0,
28800 0x1d0: 0x2100000,
28801 0x1e0: 0x2000001,
28802 0x1f0: 0x400,
28803 0x108: 0x100400,
28804 0x118: 0x2000401,
28805 0x128: 0x2100001,
28806 0x138: 0x1,
28807 0x148: 0x2000000,
28808 0x158: 0x100000,
28809 0x168: 0x401,
28810 0x178: 0x2100400,
28811 0x188: 0x2000001,
28812 0x198: 0x2100000,
28813 0x1a8: 0x0,
28814 0x1b8: 0x2100401,
28815 0x1c8: 0x100401,
28816 0x1d8: 0x400,
28817 0x1e8: 0x2000400,
28818 0x1f8: 0x100001
28819 },
28820 {
28821 0x0: 0x8000820,
28822 0x1: 0x20000,
28823 0x2: 0x8000000,
28824 0x3: 0x20,
28825 0x4: 0x20020,
28826 0x5: 0x8020820,
28827 0x6: 0x8020800,
28828 0x7: 0x800,
28829 0x8: 0x8020000,
28830 0x9: 0x8000800,
28831 0xa: 0x20800,
28832 0xb: 0x8020020,
28833 0xc: 0x820,
28834 0xd: 0x0,
28835 0xe: 0x8000020,
28836 0xf: 0x20820,
28837 0x80000000: 0x800,
28838 0x80000001: 0x8020820,
28839 0x80000002: 0x8000820,
28840 0x80000003: 0x8000000,
28841 0x80000004: 0x8020000,
28842 0x80000005: 0x20800,
28843 0x80000006: 0x20820,
28844 0x80000007: 0x20,
28845 0x80000008: 0x8000020,
28846 0x80000009: 0x820,
28847 0x8000000a: 0x20020,
28848 0x8000000b: 0x8020800,
28849 0x8000000c: 0x0,
28850 0x8000000d: 0x8020020,
28851 0x8000000e: 0x8000800,
28852 0x8000000f: 0x20000,
28853 0x10: 0x20820,
28854 0x11: 0x8020800,
28855 0x12: 0x20,
28856 0x13: 0x800,
28857 0x14: 0x8000800,
28858 0x15: 0x8000020,
28859 0x16: 0x8020020,
28860 0x17: 0x20000,
28861 0x18: 0x0,
28862 0x19: 0x20020,
28863 0x1a: 0x8020000,
28864 0x1b: 0x8000820,
28865 0x1c: 0x8020820,
28866 0x1d: 0x20800,
28867 0x1e: 0x820,
28868 0x1f: 0x8000000,
28869 0x80000010: 0x20000,
28870 0x80000011: 0x800,
28871 0x80000012: 0x8020020,
28872 0x80000013: 0x20820,
28873 0x80000014: 0x20,
28874 0x80000015: 0x8020000,
28875 0x80000016: 0x8000000,
28876 0x80000017: 0x8000820,
28877 0x80000018: 0x8020820,
28878 0x80000019: 0x8000020,
28879 0x8000001a: 0x8000800,
28880 0x8000001b: 0x0,
28881 0x8000001c: 0x20800,
28882 0x8000001d: 0x820,
28883 0x8000001e: 0x20020,
28884 0x8000001f: 0x8020800
28885 }
28886 ];
28887
28888 // Masks that select the SBOX input
28889 var SBOX_MASK = [
28890 0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
28891 0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
28892 ];
28893
28894 /**
28895 * DES block cipher algorithm.
28896 */
28897 var DES = C_algo.DES = BlockCipher.extend({
28898 _doReset: function () {
28899 // Shortcuts
28900 var key = this._key;
28901 var keyWords = key.words;
28902
28903 // Select 56 bits according to PC1
28904 var keyBits = [];
28905 for (var i = 0; i < 56; i++) {
28906 var keyBitPos = PC1[i] - 1;
28907 keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
28908 }
28909
28910 // Assemble 16 subkeys
28911 var subKeys = this._subKeys = [];
28912 for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
28913 // Create subkey
28914 var subKey = subKeys[nSubKey] = [];
28915
28916 // Shortcut
28917 var bitShift = BIT_SHIFTS[nSubKey];
28918
28919 // Select 48 bits according to PC2
28920 for (var i = 0; i < 24; i++) {
28921 // Select from the left 28 key bits
28922 subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);
28923
28924 // Select from the right 28 key bits
28925 subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
28926 }
28927
28928 // Since each subkey is applied to an expanded 32-bit input,
28929 // the subkey can be broken into 8 values scaled to 32-bits,
28930 // which allows the key to be used without expansion
28931 subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
28932 for (var i = 1; i < 7; i++) {
28933 subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
28934 }
28935 subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
28936 }
28937
28938 // Compute inverse subkeys
28939 var invSubKeys = this._invSubKeys = [];
28940 for (var i = 0; i < 16; i++) {
28941 invSubKeys[i] = subKeys[15 - i];
28942 }
28943 },
28944
28945 encryptBlock: function (M, offset) {
28946 this._doCryptBlock(M, offset, this._subKeys);
28947 },
28948
28949 decryptBlock: function (M, offset) {
28950 this._doCryptBlock(M, offset, this._invSubKeys);
28951 },
28952
28953 _doCryptBlock: function (M, offset, subKeys) {
28954 // Get input
28955 this._lBlock = M[offset];
28956 this._rBlock = M[offset + 1];
28957
28958 // Initial permutation
28959 exchangeLR.call(this, 4, 0x0f0f0f0f);
28960 exchangeLR.call(this, 16, 0x0000ffff);
28961 exchangeRL.call(this, 2, 0x33333333);
28962 exchangeRL.call(this, 8, 0x00ff00ff);
28963 exchangeLR.call(this, 1, 0x55555555);
28964
28965 // Rounds
28966 for (var round = 0; round < 16; round++) {
28967 // Shortcuts
28968 var subKey = subKeys[round];
28969 var lBlock = this._lBlock;
28970 var rBlock = this._rBlock;
28971
28972 // Feistel function
28973 var f = 0;
28974 for (var i = 0; i < 8; i++) {
28975 f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
28976 }
28977 this._lBlock = rBlock;
28978 this._rBlock = lBlock ^ f;
28979 }
28980
28981 // Undo swap from last round
28982 var t = this._lBlock;
28983 this._lBlock = this._rBlock;
28984 this._rBlock = t;
28985
28986 // Final permutation
28987 exchangeLR.call(this, 1, 0x55555555);
28988 exchangeRL.call(this, 8, 0x00ff00ff);
28989 exchangeRL.call(this, 2, 0x33333333);
28990 exchangeLR.call(this, 16, 0x0000ffff);
28991 exchangeLR.call(this, 4, 0x0f0f0f0f);
28992
28993 // Set output
28994 M[offset] = this._lBlock;
28995 M[offset + 1] = this._rBlock;
28996 },
28997
28998 keySize: 64/32,
28999
29000 ivSize: 64/32,
29001
29002 blockSize: 64/32
29003 });
29004
29005 // Swap bits across the left and right words
29006 function exchangeLR(offset, mask) {
29007 var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
29008 this._rBlock ^= t;
29009 this._lBlock ^= t << offset;
29010 }
29011
29012 function exchangeRL(offset, mask) {
29013 var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
29014 this._lBlock ^= t;
29015 this._rBlock ^= t << offset;
29016 }
29017
29018 /**
29019 * Shortcut functions to the cipher's object interface.
29020 *
29021 * @example
29022 *
29023 * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
29024 * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg);
29025 */
29026 C.DES = BlockCipher._createHelper(DES);
29027
29028 /**
29029 * Triple-DES block cipher algorithm.
29030 */
29031 var TripleDES = C_algo.TripleDES = BlockCipher.extend({
29032 _doReset: function () {
29033 // Shortcuts
29034 var key = this._key;
29035 var keyWords = key.words;
29036
29037 // Create DES instances
29038 this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2)));
29039 this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4)));
29040 this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6)));
29041 },
29042
29043 encryptBlock: function (M, offset) {
29044 this._des1.encryptBlock(M, offset);
29045 this._des2.decryptBlock(M, offset);
29046 this._des3.encryptBlock(M, offset);
29047 },
29048
29049 decryptBlock: function (M, offset) {
29050 this._des3.decryptBlock(M, offset);
29051 this._des2.encryptBlock(M, offset);
29052 this._des1.decryptBlock(M, offset);
29053 },
29054
29055 keySize: 192/32,
29056
29057 ivSize: 64/32,
29058
29059 blockSize: 64/32
29060 });
29061
29062 /**
29063 * Shortcut functions to the cipher's object interface.
29064 *
29065 * @example
29066 *
29067 * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
29068 * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
29069 */
29070 C.TripleDES = BlockCipher._createHelper(TripleDES);
29071 }());
29072
29073
29074 return CryptoJS.TripleDES;
29075
29076 }));
29077 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],62:[function(_dereq_,module,exports){
29078 ;(function (root, factory) {
29079 if (typeof exports === "object") {
29080 // CommonJS
29081 module.exports = exports = factory(_dereq_("./core"));
29082 }
29083 else if (typeof define === "function" && define.amd) {
29084 // AMD
29085 define(["./core"], factory);
29086 }
29087 else {
29088 // Global (browser)
29089 factory(root.CryptoJS);
29090 }
29091 }(this, function (CryptoJS) {
29092
29093 (function (undefined) {
29094 // Shortcuts
29095 var C = CryptoJS;
29096 var C_lib = C.lib;
29097 var Base = C_lib.Base;
29098 var X32WordArray = C_lib.WordArray;
29099
29100 /**
29101 * x64 namespace.
29102 */
29103 var C_x64 = C.x64 = {};
29104
29105 /**
29106 * A 64-bit word.
29107 */
29108 var X64Word = C_x64.Word = Base.extend({
29109 /**
29110 * Initializes a newly created 64-bit word.
29111 *
29112 * @param {number} high The high 32 bits.
29113 * @param {number} low The low 32 bits.
29114 *
29115 * @example
29116 *
29117 * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
29118 */
29119 init: function (high, low) {
29120 this.high = high;
29121 this.low = low;
29122 }
29123
29124 /**
29125 * Bitwise NOTs this word.
29126 *
29127 * @return {X64Word} A new x64-Word object after negating.
29128 *
29129 * @example
29130 *
29131 * var negated = x64Word.not();
29132 */
29133 // not: function () {
29134 // var high = ~this.high;
29135 // var low = ~this.low;
29136
29137 // return X64Word.create(high, low);
29138 // },
29139
29140 /**
29141 * Bitwise ANDs this word with the passed word.
29142 *
29143 * @param {X64Word} word The x64-Word to AND with this word.
29144 *
29145 * @return {X64Word} A new x64-Word object after ANDing.
29146 *
29147 * @example
29148 *
29149 * var anded = x64Word.and(anotherX64Word);
29150 */
29151 // and: function (word) {
29152 // var high = this.high & word.high;
29153 // var low = this.low & word.low;
29154
29155 // return X64Word.create(high, low);
29156 // },
29157
29158 /**
29159 * Bitwise ORs this word with the passed word.
29160 *
29161 * @param {X64Word} word The x64-Word to OR with this word.
29162 *
29163 * @return {X64Word} A new x64-Word object after ORing.
29164 *
29165 * @example
29166 *
29167 * var ored = x64Word.or(anotherX64Word);
29168 */
29169 // or: function (word) {
29170 // var high = this.high | word.high;
29171 // var low = this.low | word.low;
29172
29173 // return X64Word.create(high, low);
29174 // },
29175
29176 /**
29177 * Bitwise XORs this word with the passed word.
29178 *
29179 * @param {X64Word} word The x64-Word to XOR with this word.
29180 *
29181 * @return {X64Word} A new x64-Word object after XORing.
29182 *
29183 * @example
29184 *
29185 * var xored = x64Word.xor(anotherX64Word);
29186 */
29187 // xor: function (word) {
29188 // var high = this.high ^ word.high;
29189 // var low = this.low ^ word.low;
29190
29191 // return X64Word.create(high, low);
29192 // },
29193
29194 /**
29195 * Shifts this word n bits to the left.
29196 *
29197 * @param {number} n The number of bits to shift.
29198 *
29199 * @return {X64Word} A new x64-Word object after shifting.
29200 *
29201 * @example
29202 *
29203 * var shifted = x64Word.shiftL(25);
29204 */
29205 // shiftL: function (n) {
29206 // if (n < 32) {
29207 // var high = (this.high << n) | (this.low >>> (32 - n));
29208 // var low = this.low << n;
29209 // } else {
29210 // var high = this.low << (n - 32);
29211 // var low = 0;
29212 // }
29213
29214 // return X64Word.create(high, low);
29215 // },
29216
29217 /**
29218 * Shifts this word n bits to the right.
29219 *
29220 * @param {number} n The number of bits to shift.
29221 *
29222 * @return {X64Word} A new x64-Word object after shifting.
29223 *
29224 * @example
29225 *
29226 * var shifted = x64Word.shiftR(7);
29227 */
29228 // shiftR: function (n) {
29229 // if (n < 32) {
29230 // var low = (this.low >>> n) | (this.high << (32 - n));
29231 // var high = this.high >>> n;
29232 // } else {
29233 // var low = this.high >>> (n - 32);
29234 // var high = 0;
29235 // }
29236
29237 // return X64Word.create(high, low);
29238 // },
29239
29240 /**
29241 * Rotates this word n bits to the left.
29242 *
29243 * @param {number} n The number of bits to rotate.
29244 *
29245 * @return {X64Word} A new x64-Word object after rotating.
29246 *
29247 * @example
29248 *
29249 * var rotated = x64Word.rotL(25);
29250 */
29251 // rotL: function (n) {
29252 // return this.shiftL(n).or(this.shiftR(64 - n));
29253 // },
29254
29255 /**
29256 * Rotates this word n bits to the right.
29257 *
29258 * @param {number} n The number of bits to rotate.
29259 *
29260 * @return {X64Word} A new x64-Word object after rotating.
29261 *
29262 * @example
29263 *
29264 * var rotated = x64Word.rotR(7);
29265 */
29266 // rotR: function (n) {
29267 // return this.shiftR(n).or(this.shiftL(64 - n));
29268 // },
29269
29270 /**
29271 * Adds this word with the passed word.
29272 *
29273 * @param {X64Word} word The x64-Word to add with this word.
29274 *
29275 * @return {X64Word} A new x64-Word object after adding.
29276 *
29277 * @example
29278 *
29279 * var added = x64Word.add(anotherX64Word);
29280 */
29281 // add: function (word) {
29282 // var low = (this.low + word.low) | 0;
29283 // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;
29284 // var high = (this.high + word.high + carry) | 0;
29285
29286 // return X64Word.create(high, low);
29287 // }
29288 });
29289
29290 /**
29291 * An array of 64-bit words.
29292 *
29293 * @property {Array} words The array of CryptoJS.x64.Word objects.
29294 * @property {number} sigBytes The number of significant bytes in this word array.
29295 */
29296 var X64WordArray = C_x64.WordArray = Base.extend({
29297 /**
29298 * Initializes a newly created word array.
29299 *
29300 * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
29301 * @param {number} sigBytes (Optional) The number of significant bytes in the words.
29302 *
29303 * @example
29304 *
29305 * var wordArray = CryptoJS.x64.WordArray.create();
29306 *
29307 * var wordArray = CryptoJS.x64.WordArray.create([
29308 * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
29309 * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
29310 * ]);
29311 *
29312 * var wordArray = CryptoJS.x64.WordArray.create([
29313 * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
29314 * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
29315 * ], 10);
29316 */
29317 init: function (words, sigBytes) {
29318 words = this.words = words || [];
29319
29320 if (sigBytes != undefined) {
29321 this.sigBytes = sigBytes;
29322 } else {
29323 this.sigBytes = words.length * 8;
29324 }
29325 },
29326
29327 /**
29328 * Converts this 64-bit word array to a 32-bit word array.
29329 *
29330 * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.
29331 *
29332 * @example
29333 *
29334 * var x32WordArray = x64WordArray.toX32();
29335 */
29336 toX32: function () {
29337 // Shortcuts
29338 var x64Words = this.words;
29339 var x64WordsLength = x64Words.length;
29340
29341 // Convert
29342 var x32Words = [];
29343 for (var i = 0; i < x64WordsLength; i++) {
29344 var x64Word = x64Words[i];
29345 x32Words.push(x64Word.high);
29346 x32Words.push(x64Word.low);
29347 }
29348
29349 return X32WordArray.create(x32Words, this.sigBytes);
29350 },
29351
29352 /**
29353 * Creates a copy of this word array.
29354 *
29355 * @return {X64WordArray} The clone.
29356 *
29357 * @example
29358 *
29359 * var clone = x64WordArray.clone();
29360 */
29361 clone: function () {
29362 var clone = Base.clone.call(this);
29363
29364 // Clone "words" array
29365 var words = clone.words = this.words.slice(0);
29366
29367 // Clone each X64Word object
29368 var wordsLength = words.length;
29369 for (var i = 0; i < wordsLength; i++) {
29370 words[i] = words[i].clone();
29371 }
29372
29373 return clone;
29374 }
29375 });
29376 }());
29377
29378
29379 return CryptoJS;
29380
29381 }));
29382 },{"./core":31}],63:[function(_dereq_,module,exports){
29383 var assert = _dereq_('assert')
29384 var BigInteger = _dereq_('bigi')
29385
29386 var Point = _dereq_('./point')
29387
29388 function Curve(p, a, b, Gx, Gy, n, h) {
29389 this.p = p
29390 this.a = a
29391 this.b = b
29392 this.G = Point.fromAffine(this, Gx, Gy)
29393 this.n = n
29394 this.h = h
29395
29396 this.infinity = new Point(this, null, null, BigInteger.ZERO)
29397
29398 // result caching
29399 this.pOverFour = p.add(BigInteger.ONE).shiftRight(2)
29400 }
29401
29402 Curve.prototype.pointFromX = function(isOdd, x) {
29403 var alpha = x.pow(3).add(this.a.multiply(x)).add(this.b).mod(this.p)
29404 var beta = alpha.modPow(this.pOverFour, this.p)
29405
29406 var y = beta
29407 if (beta.isEven() ^ !isOdd) {
29408 y = this.p.subtract(y) // -y % p
29409 }
29410
29411 return Point.fromAffine(this, x, y)
29412 }
29413
29414 Curve.prototype.isInfinity = function(Q) {
29415 if (Q === this.infinity) return true
29416
29417 return Q.z.signum() === 0 && Q.y.signum() !== 0
29418 }
29419
29420 Curve.prototype.isOnCurve = function(Q) {
29421 if (this.isInfinity(Q)) return true
29422
29423 var x = Q.affineX
29424 var y = Q.affineY
29425 var a = this.a
29426 var b = this.b
29427 var p = this.p
29428
29429 // Check that xQ and yQ are integers in the interval [0, p - 1]
29430 if (x.signum() < 0 || x.compareTo(p) >= 0) return false
29431 if (y.signum() < 0 || y.compareTo(p) >= 0) return false
29432
29433 // and check that y^2 = x^3 + ax + b (mod p)
29434 var lhs = y.square().mod(p)
29435 var rhs = x.pow(3).add(a.multiply(x)).add(b).mod(p)
29436 return lhs.equals(rhs)
29437 }
29438
29439 /**
29440 * Validate an elliptic curve point.
29441 *
29442 * See SEC 1, section 3.2.2.1: Elliptic Curve Public Key Validation Primitive
29443 */
29444 Curve.prototype.validate = function(Q) {
29445 // Check Q != O
29446 assert(!this.isInfinity(Q), 'Point is at infinity')
29447 assert(this.isOnCurve(Q), 'Point is not on the curve')
29448
29449 // Check nQ = O (where Q is a scalar multiple of G)
29450 var nQ = Q.multiply(this.n)
29451 assert(this.isInfinity(nQ), 'Point is not a scalar multiple of G')
29452
29453 return true
29454 }
29455
29456 module.exports = Curve
29457
29458 },{"./point":67,"assert":4,"bigi":3}],64:[function(_dereq_,module,exports){
29459 module.exports={
29460 "secp128r1": {
29461 "p": "fffffffdffffffffffffffffffffffff",
29462 "a": "fffffffdfffffffffffffffffffffffc",
29463 "b": "e87579c11079f43dd824993c2cee5ed3",
29464 "n": "fffffffe0000000075a30d1b9038a115",
29465 "h": "01",
29466 "Gx": "161ff7528b899b2d0c28607ca52c5b86",
29467 "Gy": "cf5ac8395bafeb13c02da292dded7a83"
29468 },
29469 "secp160k1": {
29470 "p": "fffffffffffffffffffffffffffffffeffffac73",
29471 "a": "00",
29472 "b": "07",
29473 "n": "0100000000000000000001b8fa16dfab9aca16b6b3",
29474 "h": "01",
29475 "Gx": "3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",
29476 "Gy": "938cf935318fdced6bc28286531733c3f03c4fee"
29477 },
29478 "secp160r1": {
29479 "p": "ffffffffffffffffffffffffffffffff7fffffff",
29480 "a": "ffffffffffffffffffffffffffffffff7ffffffc",
29481 "b": "1c97befc54bd7a8b65acf89f81d4d4adc565fa45",
29482 "n": "0100000000000000000001f4c8f927aed3ca752257",
29483 "h": "01",
29484 "Gx": "4a96b5688ef573284664698968c38bb913cbfc82",
29485 "Gy": "23a628553168947d59dcc912042351377ac5fb32"
29486 },
29487 "secp192k1": {
29488 "p": "fffffffffffffffffffffffffffffffffffffffeffffee37",
29489 "a": "00",
29490 "b": "03",
29491 "n": "fffffffffffffffffffffffe26f2fc170f69466a74defd8d",
29492 "h": "01",
29493 "Gx": "db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",
29494 "Gy": "9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"
29495 },
29496 "secp192r1": {
29497 "p": "fffffffffffffffffffffffffffffffeffffffffffffffff",
29498 "a": "fffffffffffffffffffffffffffffffefffffffffffffffc",
29499 "b": "64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",
29500 "n": "ffffffffffffffffffffffff99def836146bc9b1b4d22831",
29501 "h": "01",
29502 "Gx": "188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",
29503 "Gy": "07192b95ffc8da78631011ed6b24cdd573f977a11e794811"
29504 },
29505 "secp224r1": {
29506 "p": "ffffffffffffffffffffffffffffffff000000000000000000000001",
29507 "a": "fffffffffffffffffffffffffffffffefffffffffffffffffffffffe",
29508 "b": "b4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4",
29509 "n": "ffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d",
29510 "h": "01",
29511 "Gx": "b70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21",
29512 "Gy": "bd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34"
29513 },
29514 "secp256k1": {
29515 "p": "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
29516 "a": "00",
29517 "b": "07",
29518 "n": "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",
29519 "h": "01",
29520 "Gx": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
29521 "Gy": "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"
29522 },
29523 "secp256r1": {
29524 "p": "ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
29525 "a": "ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",
29526 "b": "5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",
29527 "n": "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
29528 "h": "01",
29529 "Gx": "6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",
29530 "Gy": "4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"
29531 }
29532 }
29533
29534 },{}],65:[function(_dereq_,module,exports){
29535 var Point = _dereq_('./point')
29536 var Curve = _dereq_('./curve')
29537
29538 var getCurveByName = _dereq_('./names')
29539
29540 module.exports = {
29541 Curve: Curve,
29542 Point: Point,
29543 getCurveByName: getCurveByName
29544 }
29545
29546 },{"./curve":63,"./names":66,"./point":67}],66:[function(_dereq_,module,exports){
29547 var BigInteger = _dereq_('bigi')
29548
29549 var curves = _dereq_('./curves')
29550 var Curve = _dereq_('./curve')
29551
29552 function getCurveByName(name) {
29553 var curve = curves[name]
29554 if (!curve) return null
29555
29556 var p = new BigInteger(curve.p, 16)
29557 var a = new BigInteger(curve.a, 16)
29558 var b = new BigInteger(curve.b, 16)
29559 var n = new BigInteger(curve.n, 16)
29560 var h = new BigInteger(curve.h, 16)
29561 var Gx = new BigInteger(curve.Gx, 16)
29562 var Gy = new BigInteger(curve.Gy, 16)
29563
29564 return new Curve(p, a, b, Gx, Gy, n, h)
29565 }
29566
29567 module.exports = getCurveByName
29568
29569 },{"./curve":63,"./curves":64,"bigi":3}],67:[function(_dereq_,module,exports){
29570 (function (Buffer){
29571 var assert = _dereq_('assert')
29572 var BigInteger = _dereq_('bigi')
29573
29574 var THREE = BigInteger.valueOf(3)
29575
29576 function Point(curve, x, y, z) {
29577 assert.notStrictEqual(z, undefined, 'Missing Z coordinate')
29578
29579 this.curve = curve
29580 this.x = x
29581 this.y = y
29582 this.z = z
29583 this._zInv = null
29584
29585 this.compressed = true
29586 }
29587
29588 Object.defineProperty(Point.prototype, 'zInv', {
29589 get: function() {
29590 if (this._zInv === null) {
29591 this._zInv = this.z.modInverse(this.curve.p)
29592 }
29593
29594 return this._zInv
29595 }
29596 })
29597
29598 Object.defineProperty(Point.prototype, 'affineX', {
29599 get: function() {
29600 return this.x.multiply(this.zInv).mod(this.curve.p)
29601 }
29602 })
29603
29604 Object.defineProperty(Point.prototype, 'affineY', {
29605 get: function() {
29606 return this.y.multiply(this.zInv).mod(this.curve.p)
29607 }
29608 })
29609
29610 Point.fromAffine = function(curve, x, y) {
29611 return new Point(curve, x, y, BigInteger.ONE)
29612 }
29613
29614 Point.prototype.equals = function(other) {
29615 if (other === this) return true
29616 if (this.curve.isInfinity(this)) return this.curve.isInfinity(other)
29617 if (this.curve.isInfinity(other)) return this.curve.isInfinity(this)
29618
29619 // u = Y2 * Z1 - Y1 * Z2
29620 var u = other.y.multiply(this.z).subtract(this.y.multiply(other.z)).mod(this.curve.p)
29621
29622 if (u.signum() !== 0) return false
29623
29624 // v = X2 * Z1 - X1 * Z2
29625 var v = other.x.multiply(this.z).subtract(this.x.multiply(other.z)).mod(this.curve.p)
29626
29627 return v.signum() === 0
29628 }
29629
29630 Point.prototype.negate = function() {
29631 var y = this.curve.p.subtract(this.y)
29632
29633 return new Point(this.curve, this.x, y, this.z)
29634 }
29635
29636 Point.prototype.add = function(b) {
29637 if (this.curve.isInfinity(this)) return b
29638 if (this.curve.isInfinity(b)) return this
29639
29640 var x1 = this.x
29641 var y1 = this.y
29642 var x2 = b.x
29643 var y2 = b.y
29644
29645 // u = Y2 * Z1 - Y1 * Z2
29646 var u = y2.multiply(this.z).subtract(y1.multiply(b.z)).mod(this.curve.p)
29647 // v = X2 * Z1 - X1 * Z2
29648 var v = x2.multiply(this.z).subtract(x1.multiply(b.z)).mod(this.curve.p)
29649
29650 if (v.signum() === 0) {
29651 if (u.signum() === 0) {
29652 return this.twice() // this == b, so double
29653 }
29654
29655 return this.curve.infinity // this = -b, so infinity
29656 }
29657
29658 var v2 = v.square()
29659 var v3 = v2.multiply(v)
29660 var x1v2 = x1.multiply(v2)
29661 var zu2 = u.square().multiply(this.z)
29662
29663 // x3 = v * (z2 * (z1 * u^2 - 2 * x1 * v^2) - v^3)
29664 var x3 = zu2.subtract(x1v2.shiftLeft(1)).multiply(b.z).subtract(v3).multiply(v).mod(this.curve.p)
29665 // y3 = z2 * (3 * x1 * u * v^2 - y1 * v^3 - z1 * u^3) + u * v^3
29666 var y3 = x1v2.multiply(THREE).multiply(u).subtract(y1.multiply(v3)).subtract(zu2.multiply(u)).multiply(b.z).add(u.multiply(v3)).mod(this.curve.p)
29667 // z3 = v^3 * z1 * z2
29668 var z3 = v3.multiply(this.z).multiply(b.z).mod(this.curve.p)
29669
29670 return new Point(this.curve, x3, y3, z3)
29671 }
29672
29673 Point.prototype.twice = function() {
29674 if (this.curve.isInfinity(this)) return this
29675 if (this.y.signum() === 0) return this.curve.infinity
29676
29677 var x1 = this.x
29678 var y1 = this.y
29679
29680 var y1z1 = y1.multiply(this.z)
29681 var y1sqz1 = y1z1.multiply(y1).mod(this.curve.p)
29682 var a = this.curve.a
29683
29684 // w = 3 * x1^2 + a * z1^2
29685 var w = x1.square().multiply(THREE)
29686
29687 if (a.signum() !== 0) {
29688 w = w.add(this.z.square().multiply(a))
29689 }
29690
29691 w = w.mod(this.curve.p)
29692 // x3 = 2 * y1 * z1 * (w^2 - 8 * x1 * y1^2 * z1)
29693 var x3 = w.square().subtract(x1.shiftLeft(3).multiply(y1sqz1)).shiftLeft(1).multiply(y1z1).mod(this.curve.p)
29694 // y3 = 4 * y1^2 * z1 * (3 * w * x1 - 2 * y1^2 * z1) - w^3
29695 var y3 = w.multiply(THREE).multiply(x1).subtract(y1sqz1.shiftLeft(1)).shiftLeft(2).multiply(y1sqz1).subtract(w.pow(3)).mod(this.curve.p)
29696 // z3 = 8 * (y1 * z1)^3
29697 var z3 = y1z1.pow(3).shiftLeft(3).mod(this.curve.p)
29698
29699 return new Point(this.curve, x3, y3, z3)
29700 }
29701
29702 // Simple NAF (Non-Adjacent Form) multiplication algorithm
29703 // TODO: modularize the multiplication algorithm
29704 Point.prototype.multiply = function(k) {
29705 if (this.curve.isInfinity(this)) return this
29706 if (k.signum() === 0) return this.curve.infinity
29707
29708 var e = k
29709 var h = e.multiply(THREE)
29710
29711 var neg = this.negate()
29712 var R = this
29713
29714 for (var i = h.bitLength() - 2; i > 0; --i) {
29715 R = R.twice()
29716
29717 var hBit = h.testBit(i)
29718 var eBit = e.testBit(i)
29719
29720 if (hBit != eBit) {
29721 R = R.add(hBit ? this : neg)
29722 }
29723 }
29724
29725 return R
29726 }
29727
29728 // Compute this*j + x*k (simultaneous multiplication)
29729 Point.prototype.multiplyTwo = function(j, x, k) {
29730 var i
29731
29732 if (j.bitLength() > k.bitLength())
29733 i = j.bitLength() - 1
29734 else
29735 i = k.bitLength() - 1
29736
29737 var R = this.curve.infinity
29738 var both = this.add(x)
29739
29740 while (i >= 0) {
29741 R = R.twice()
29742
29743 var jBit = j.testBit(i)
29744 var kBit = k.testBit(i)
29745
29746 if (jBit) {
29747 if (kBit) {
29748 R = R.add(both)
29749
29750 } else {
29751 R = R.add(this)
29752 }
29753
29754 } else {
29755 if (kBit) {
29756 R = R.add(x)
29757 }
29758 }
29759 --i
29760 }
29761
29762 return R
29763 }
29764
29765 Point.prototype.getEncoded = function(compressed) {
29766 if (compressed == undefined) compressed = this.compressed
29767 if (this.curve.isInfinity(this)) return new Buffer('00', 'hex') // Infinity point encoded is simply '00'
29768
29769 var x = this.affineX
29770 var y = this.affineY
29771
29772 var buffer
29773
29774 // Determine size of q in bytes
29775 var byteLength = Math.floor((this.curve.p.bitLength() + 7) / 8)
29776
29777 // 0x02/0x03 | X
29778 if (compressed) {
29779 buffer = new Buffer(1 + byteLength)
29780 buffer.writeUInt8(y.isEven() ? 0x02 : 0x03, 0)
29781
29782 // 0x04 | X | Y
29783 } else {
29784 buffer = new Buffer(1 + byteLength + byteLength)
29785 buffer.writeUInt8(0x04, 0)
29786
29787 y.toBuffer(byteLength).copy(buffer, 1 + byteLength)
29788 }
29789
29790 x.toBuffer(byteLength).copy(buffer, 1)
29791
29792 return buffer
29793 }
29794
29795 Point.decodeFrom = function(curve, buffer) {
29796 var type = buffer.readUInt8(0)
29797 var compressed = (type !== 4)
29798
29799 var x = BigInteger.fromBuffer(buffer.slice(1, 33))
29800 var byteLength = Math.floor((curve.p.bitLength() + 7) / 8)
29801
29802 var Q
29803 if (compressed) {
29804 assert.equal(buffer.length, byteLength + 1, 'Invalid sequence length')
29805 assert(type === 0x02 || type === 0x03, 'Invalid sequence tag')
29806
29807 var isOdd = (type === 0x03)
29808 Q = curve.pointFromX(isOdd, x)
29809
29810 } else {
29811 assert.equal(buffer.length, 1 + byteLength + byteLength, 'Invalid sequence length')
29812
29813 var y = BigInteger.fromBuffer(buffer.slice(1 + byteLength))
29814 Q = Point.fromAffine(curve, x, y)
29815 }
29816
29817 Q.compressed = compressed
29818 return Q
29819 }
29820
29821 Point.prototype.toString = function () {
29822 if (this.curve.isInfinity(this)) return '(INFINITY)'
29823
29824 return '(' + this.affineX.toString() + ',' + this.affineY.toString() + ')'
29825 }
29826
29827 module.exports = Point
29828
29829 }).call(this,_dereq_("buffer").Buffer)
29830 },{"assert":4,"bigi":3,"buffer":8}],68:[function(_dereq_,module,exports){
29831 (function (process,Buffer){
29832 // Closure compiler error - result of 'not' operator not being used
29833 //!function(globals){
29834 (function(globals){
29835 'use strict'
29836
29837 //*** UMD BEGIN
29838 if (typeof define !== 'undefined' && define.amd) { //require.js / AMD
29839 define([], function() {
29840 return secureRandom
29841 })
29842 } else if (typeof module !== 'undefined' && module.exports) { //CommonJS
29843 module.exports = secureRandom
29844 } else { //script / browser
29845 globals.secureRandom = secureRandom
29846 }
29847 //*** UMD END
29848
29849 //options.type is the only valid option
29850 function secureRandom(count, options) {
29851 options = options || {type: 'Array'}
29852 //we check for process.pid to prevent browserify from tricking us
29853 if (typeof process != 'undefined' && typeof process.pid == 'number') {
29854 return nodeRandom(count, options)
29855 } else {
29856 var crypto = window.crypto || window.msCrypto
29857 if (!crypto) throw new Error("Your browser does not support window.crypto.")
29858 return browserRandom(count, options)
29859 }
29860 }
29861
29862 function nodeRandom(count, options) {
29863 var crypto = _dereq_('crypto')
29864 var buf = crypto.randomBytes(count)
29865
29866 switch (options.type) {
29867 case 'Array':
29868 return [].slice.call(buf)
29869 case 'Buffer':
29870 return buf
29871 case 'Uint8Array':
29872 var arr = new Uint8Array(count)
29873 for (var i = 0; i < count; ++i) { arr[i] = buf.readUInt8(i) }
29874 return arr
29875 default:
29876 throw new Error(options.type + " is unsupported.")
29877 }
29878 }
29879
29880 function browserRandom(count, options) {
29881 var nativeArr = new Uint8Array(count)
29882 var crypto = window.crypto || window.msCrypto
29883 crypto.getRandomValues(nativeArr)
29884
29885 switch (options.type) {
29886 case 'Array':
29887 return [].slice.call(nativeArr)
29888 case 'Buffer':
29889 try { var b = new Buffer(1) } catch(e) { throw new Error('Buffer not supported in this environment. Use Node.js or Browserify for browser support.')}
29890 return new Buffer(nativeArr)
29891 case 'Uint8Array':
29892 return nativeArr
29893 default:
29894 throw new Error(options.type + " is unsupported.")
29895 }
29896 }
29897
29898 secureRandom.randomArray = function(byteCount) {
29899 return secureRandom(byteCount, {type: 'Array'})
29900 }
29901
29902 secureRandom.randomUint8Array = function(byteCount) {
29903 return secureRandom(byteCount, {type: 'Uint8Array'})
29904 }
29905
29906 secureRandom.randomBuffer = function(byteCount) {
29907 return secureRandom(byteCount, {type: 'Buffer'})
29908 }
29909
29910
29911 })(this);
29912
29913 }).call(this,_dereq_("FWaASH"),_dereq_("buffer").Buffer)
29914 },{"FWaASH":12,"buffer":8,"crypto":7}],69:[function(_dereq_,module,exports){
29915 (function (Buffer){
29916 var assert = _dereq_('assert')
29917 var base58check = _dereq_('./base58check')
29918 var networks = _dereq_('./networks')
29919 var scripts = _dereq_('./scripts')
29920
29921 function findScriptTypeByVersion(version) {
29922 for (var networkName in networks) {
29923 var network = networks[networkName]
29924
29925 if (version === network.pubKeyHash) return 'pubkeyhash'
29926 if (version === network.scriptHash) return 'scripthash'
29927 }
29928 }
29929
29930 function Address(hash, version) {
29931 assert(Buffer.isBuffer(hash), 'Expected Buffer, got ' + hash)
29932 assert.strictEqual(hash.length, 20, 'Invalid hash length')
29933 assert.strictEqual(version & 0xff, version, 'Invalid version byte')
29934
29935 this.hash = hash
29936 this.version = version
29937 }
29938
29939 // Import functions
29940 Address.fromBase58Check = function(string) {
29941 var payload = base58check.decode(string)
29942 var version = payload.readUInt8(0)
29943 var hash = payload.slice(1)
29944
29945 return new Address(hash, version)
29946 }
29947
29948 Address.fromOutputScript = function(script, network) {
29949 network = network || networks.bitcoin
29950
29951 var type = scripts.classifyOutput(script)
29952
29953 if (type === 'pubkeyhash') return new Address(script.chunks[2], network.pubKeyHash)
29954 if (type === 'scripthash') return new Address(script.chunks[1], network.scriptHash)
29955
29956 assert(false, type + ' has no matching Address')
29957 }
29958
29959 // Export functions
29960 Address.prototype.toBase58Check = function () {
29961 var payload = new Buffer(21)
29962 payload.writeUInt8(this.version, 0)
29963 this.hash.copy(payload, 1)
29964
29965 return base58check.encode(payload)
29966 }
29967
29968 Address.prototype.toOutputScript = function() {
29969 var scriptType = findScriptTypeByVersion(this.version)
29970
29971 if (scriptType === 'pubkeyhash') return scripts.pubKeyHashOutput(this.hash)
29972 if (scriptType === 'scripthash') return scripts.scriptHashOutput(this.hash)
29973
29974 assert(false, this.toString() + ' has no matching Script')
29975 }
29976
29977 Address.prototype.toString = Address.prototype.toBase58Check
29978
29979 module.exports = Address
29980
29981 }).call(this,_dereq_("buffer").Buffer)
29982 },{"./base58check":70,"./networks":81,"./scripts":84,"assert":4,"buffer":8}],70:[function(_dereq_,module,exports){
29983 (function (Buffer){
29984 // https://en.bitcoin.it/wiki/Base58Check_encoding
29985 var assert = _dereq_('assert')
29986 var base58 = _dereq_('bs58')
29987 var crypto = _dereq_('./crypto')
29988
29989 // Encode a buffer as a base58-check-encoded string
29990 function encode(payload) {
29991 var checksum = crypto.hash256(payload).slice(0, 4)
29992
29993 return base58.encode(Buffer.concat([
29994 payload,
29995 checksum
29996 ]))
29997 }
29998
29999 // Decode a base58-check-encoded string to a buffer
30000 function decode(string) {
30001 var buffer = base58.decode(string)
30002
30003 var payload = buffer.slice(0, -4)
30004 var checksum = buffer.slice(-4)
30005 var newChecksum = crypto.hash256(payload).slice(0, 4)
30006
30007 assert.deepEqual(newChecksum, checksum, 'Invalid checksum')
30008
30009 return payload
30010 }
30011
30012 module.exports = {
30013 encode: encode,
30014 decode: decode
30015 }
30016
30017 }).call(this,_dereq_("buffer").Buffer)
30018 },{"./crypto":73,"assert":4,"bs58":15,"buffer":8}],71:[function(_dereq_,module,exports){
30019 var assert = _dereq_('assert')
30020 var opcodes = _dereq_('./opcodes')
30021
30022 // https://github.com/feross/buffer/blob/master/index.js#L1127
30023 function verifuint(value, max) {
30024 assert(typeof value === 'number', 'cannot write a non-number as a number')
30025 assert(value >= 0, 'specified a negative value for writing an unsigned value')
30026 assert(value <= max, 'value is larger than maximum value for type')
30027 assert(Math.floor(value) === value, 'value has a fractional component')
30028 }
30029
30030 function pushDataSize(i) {
30031 return i < opcodes.OP_PUSHDATA1 ? 1
30032 : i < 0xff ? 2
30033 : i < 0xffff ? 3
30034 : 5
30035 }
30036
30037 function readPushDataInt(buffer, offset) {
30038 var opcode = buffer.readUInt8(offset)
30039 var number, size
30040
30041 // ~6 bit
30042 if (opcode < opcodes.OP_PUSHDATA1) {
30043 number = opcode
30044 size = 1
30045
30046 // 8 bit
30047 } else if (opcode === opcodes.OP_PUSHDATA1) {
30048 number = buffer.readUInt8(offset + 1)
30049 size = 2
30050
30051 // 16 bit
30052 } else if (opcode === opcodes.OP_PUSHDATA2) {
30053 number = buffer.readUInt16LE(offset + 1)
30054 size = 3
30055
30056 // 32 bit
30057 } else {
30058 assert.equal(opcode, opcodes.OP_PUSHDATA4, 'Unexpected opcode')
30059
30060 number = buffer.readUInt32LE(offset + 1)
30061 size = 5
30062
30063 }
30064
30065 return {
30066 opcode: opcode,
30067 number: number,
30068 size: size
30069 }
30070 }
30071
30072 function readUInt64LE(buffer, offset) {
30073 var a = buffer.readUInt32LE(offset)
30074 var b = buffer.readUInt32LE(offset + 4)
30075 b *= 0x100000000
30076
30077 verifuint(b + a, 0x001fffffffffffff)
30078
30079 return b + a
30080 }
30081
30082 function readVarInt(buffer, offset) {
30083 var t = buffer.readUInt8(offset)
30084 var number, size
30085
30086 // 8 bit
30087 if (t < 253) {
30088 number = t
30089 size = 1
30090
30091 // 16 bit
30092 } else if (t < 254) {
30093 number = buffer.readUInt16LE(offset + 1)
30094 size = 3
30095
30096 // 32 bit
30097 } else if (t < 255) {
30098 number = buffer.readUInt32LE(offset + 1)
30099 size = 5
30100
30101 // 64 bit
30102 } else {
30103 number = readUInt64LE(buffer, offset + 1)
30104 size = 9
30105 }
30106
30107 return {
30108 number: number,
30109 size: size
30110 }
30111 }
30112
30113 function writePushDataInt(buffer, number, offset) {
30114 var size = pushDataSize(number)
30115
30116 // ~6 bit
30117 if (size === 1) {
30118 buffer.writeUInt8(number, offset)
30119
30120 // 8 bit
30121 } else if (size === 2) {
30122 buffer.writeUInt8(opcodes.OP_PUSHDATA1, offset)
30123 buffer.writeUInt8(number, offset + 1)
30124
30125 // 16 bit
30126 } else if (size === 3) {
30127 buffer.writeUInt8(opcodes.OP_PUSHDATA2, offset)
30128 buffer.writeUInt16LE(number, offset + 1)
30129
30130 // 32 bit
30131 } else {
30132 buffer.writeUInt8(opcodes.OP_PUSHDATA4, offset)
30133 buffer.writeUInt32LE(number, offset + 1)
30134
30135 }
30136
30137 return size
30138 }
30139
30140 function writeUInt64LE(buffer, value, offset) {
30141 verifuint(value, 0x001fffffffffffff)
30142
30143 buffer.writeInt32LE(value & -1, offset)
30144 buffer.writeUInt32LE(Math.floor(value / 0x100000000), offset + 4)
30145 }
30146
30147 function varIntSize(i) {
30148 return i < 253 ? 1
30149 : i < 0x10000 ? 3
30150 : i < 0x100000000 ? 5
30151 : 9
30152 }
30153
30154 function writeVarInt(buffer, number, offset) {
30155 var size = varIntSize(number)
30156
30157 // 8 bit
30158 if (size === 1) {
30159 buffer.writeUInt8(number, offset)
30160
30161 // 16 bit
30162 } else if (size === 3) {
30163 buffer.writeUInt8(253, offset)
30164 buffer.writeUInt16LE(number, offset + 1)
30165
30166 // 32 bit
30167 } else if (size === 5) {
30168 buffer.writeUInt8(254, offset)
30169 buffer.writeUInt32LE(number, offset + 1)
30170
30171 // 64 bit
30172 } else {
30173 buffer.writeUInt8(255, offset)
30174 writeUInt64LE(buffer, number, offset + 1)
30175 }
30176
30177 return size
30178 }
30179
30180 module.exports = {
30181 pushDataSize: pushDataSize,
30182 readPushDataInt: readPushDataInt,
30183 readUInt64LE: readUInt64LE,
30184 readVarInt: readVarInt,
30185 varIntSize: varIntSize,
30186 writePushDataInt: writePushDataInt,
30187 writeUInt64LE: writeUInt64LE,
30188 writeVarInt: writeVarInt
30189 }
30190
30191 },{"./opcodes":82,"assert":4}],72:[function(_dereq_,module,exports){
30192 (function (Buffer){
30193 var assert = _dereq_('assert')
30194 var Crypto = _dereq_('crypto-js')
30195 var WordArray = Crypto.lib.WordArray
30196
30197 function bufferToWordArray(buffer) {
30198 assert(Buffer.isBuffer(buffer), 'Expected Buffer, got', buffer)
30199
30200 var words = []
30201 for (var i = 0, b = 0; i < buffer.length; i++, b += 8) {
30202 words[b >>> 5] |= buffer[i] << (24 - b % 32)
30203 }
30204
30205 return new WordArray.init(words, buffer.length)
30206 }
30207
30208 function wordArrayToBuffer(wordArray) {
30209 assert(Array.isArray(wordArray.words), 'Expected WordArray, got' + wordArray)
30210
30211 var words = wordArray.words
30212 var buffer = new Buffer(words.length * 4)
30213
30214 words.forEach(function(value, i) {
30215 buffer.writeInt32BE(value & -1, i * 4)
30216 })
30217
30218 return buffer
30219 }
30220
30221 module.exports = {
30222 bufferToWordArray: bufferToWordArray,
30223 wordArrayToBuffer: wordArrayToBuffer
30224 }
30225
30226 }).call(this,_dereq_("buffer").Buffer)
30227 },{"assert":4,"buffer":8,"crypto-js":37}],73:[function(_dereq_,module,exports){
30228 (function (Buffer){
30229 // Crypto, crypto, where art thou crypto
30230 var assert = _dereq_('assert')
30231 var CryptoJS = _dereq_('crypto-js')
30232 var crypto = _dereq_('crypto')
30233 var convert = _dereq_('./convert')
30234
30235 function hash160(buffer) {
30236 return ripemd160(sha256(buffer))
30237 }
30238
30239 function hash256(buffer) {
30240 return sha256(sha256(buffer))
30241 }
30242
30243 function ripemd160(buffer) {
30244 return crypto.createHash('rmd160').update(buffer).digest()
30245 }
30246
30247 function sha1(buffer) {
30248 return crypto.createHash('sha1').update(buffer).digest()
30249 }
30250
30251 function sha256(buffer) {
30252 return crypto.createHash('sha256').update(buffer).digest()
30253 }
30254
30255 // FIXME: Name not consistent with others
30256 function HmacSHA256(buffer, secret) {
30257 return crypto.createHmac('sha256', secret).update(buffer).digest()
30258 }
30259
30260 function HmacSHA512(data, secret) {
30261 assert(Buffer.isBuffer(data), 'Expected Buffer for data, got ' + data)
30262 assert(Buffer.isBuffer(secret), 'Expected Buffer for secret, got ' + secret)
30263
30264 var dataWords = convert.bufferToWordArray(data)
30265 var secretWords = convert.bufferToWordArray(secret)
30266
30267 var hash = CryptoJS.HmacSHA512(dataWords, secretWords)
30268
30269 return convert.wordArrayToBuffer(hash)
30270 }
30271
30272 module.exports = {
30273 ripemd160: ripemd160,
30274 sha1: sha1,
30275 sha256: sha256,
30276 hash160: hash160,
30277 hash256: hash256,
30278 HmacSHA256: HmacSHA256,
30279 HmacSHA512: HmacSHA512
30280 }
30281
30282 }).call(this,_dereq_("buffer").Buffer)
30283 },{"./convert":72,"assert":4,"buffer":8,"crypto":19,"crypto-js":37}],74:[function(_dereq_,module,exports){
30284 (function (Buffer){
30285 var assert = _dereq_('assert')
30286 var crypto = _dereq_('./crypto')
30287
30288 var BigInteger = _dereq_('bigi')
30289 var ECSignature = _dereq_('./ecsignature')
30290 var Point = _dereq_('ecurve').Point
30291
30292 // https://tools.ietf.org/html/rfc6979#section-3.2
30293 function deterministicGenerateK(curve, hash, d) {
30294 assert(Buffer.isBuffer(hash), 'Hash must be a Buffer, not ' + hash)
30295 assert.equal(hash.length, 32, 'Hash must be 256 bit')
30296 assert(d instanceof BigInteger, 'Private key must be a BigInteger')
30297
30298 var x = d.toBuffer(32)
30299 var k = new Buffer(32)
30300 var v = new Buffer(32)
30301
30302 // Step B
30303 v.fill(1)
30304
30305 // Step C
30306 k.fill(0)
30307
30308 // Step D
30309 k = crypto.HmacSHA256(Buffer.concat([v, new Buffer([0]), x, hash]), k)
30310
30311 // Step E
30312 v = crypto.HmacSHA256(v, k)
30313
30314 // Step F
30315 k = crypto.HmacSHA256(Buffer.concat([v, new Buffer([1]), x, hash]), k)
30316
30317 // Step G
30318 v = crypto.HmacSHA256(v, k)
30319
30320 // Step H1/H2a, ignored as tlen === qlen (256 bit)
30321 // Step H2b
30322 v = crypto.HmacSHA256(v, k)
30323
30324 var T = BigInteger.fromBuffer(v)
30325
30326 // Step H3, repeat until T is within the interval [1, n - 1]
30327 while ((T.signum() <= 0) || (T.compareTo(curve.n) >= 0)) {
30328 k = crypto.HmacSHA256(Buffer.concat([v, new Buffer([0])]), k)
30329 v = crypto.HmacSHA256(v, k)
30330
30331 T = BigInteger.fromBuffer(v)
30332 }
30333
30334 return T
30335 }
30336
30337 function sign(curve, hash, d) {
30338 var k = deterministicGenerateK(curve, hash, d)
30339
30340 var n = curve.n
30341 var G = curve.G
30342 var Q = G.multiply(k)
30343 var e = BigInteger.fromBuffer(hash)
30344
30345 var r = Q.affineX.mod(n)
30346 assert.notEqual(r.signum(), 0, 'Invalid R value')
30347
30348 var s = k.modInverse(n).multiply(e.add(d.multiply(r))).mod(n)
30349 assert.notEqual(s.signum(), 0, 'Invalid S value')
30350
30351 var N_OVER_TWO = n.shiftRight(1)
30352
30353 // enforce low S values, see bip62: 'low s values in signatures'
30354 if (s.compareTo(N_OVER_TWO) > 0) {
30355 s = n.subtract(s)
30356 }
30357
30358 return new ECSignature(r, s)
30359 }
30360
30361 function verify(curve, hash, signature, Q) {
30362 var e = BigInteger.fromBuffer(hash)
30363
30364 return verifyRaw(curve, e, signature, Q)
30365 }
30366
30367 function verifyRaw(curve, e, signature, Q) {
30368 var n = curve.n
30369 var G = curve.G
30370
30371 var r = signature.r
30372 var s = signature.s
30373
30374 if (r.signum() === 0 || r.compareTo(n) >= 0) return false
30375 if (s.signum() === 0 || s.compareTo(n) >= 0) return false
30376
30377 var c = s.modInverse(n)
30378
30379 var u1 = e.multiply(c).mod(n)
30380 var u2 = r.multiply(c).mod(n)
30381
30382 var point = G.multiplyTwo(u1, Q, u2)
30383 var v = point.affineX.mod(n)
30384
30385 return v.equals(r)
30386 }
30387
30388 /**
30389 * Recover a public key from a signature.
30390 *
30391 * See SEC 1: Elliptic Curve Cryptography, section 4.1.6, "Public
30392 * Key Recovery Operation".
30393 *
30394 * http://www.secg.org/download/aid-780/sec1-v2.pdf
30395 */
30396 function recoverPubKey(curve, e, signature, i) {
30397 assert.strictEqual(i & 3, i, 'Recovery param is more than two bits')
30398
30399 var r = signature.r
30400 var s = signature.s
30401
30402 // A set LSB signifies that the y-coordinate is odd
30403 var isYOdd = i & 1
30404
30405 // The more significant bit specifies whether we should use the
30406 // first or second candidate key.
30407 var isSecondKey = i >> 1
30408
30409 var n = curve.n
30410 var G = curve.G
30411
30412 // 1.1 Let x = r + jn
30413 var x = isSecondKey ? r.add(n) : r
30414 var R = curve.pointFromX(isYOdd, x)
30415
30416 // 1.4 Check that nR is at infinity
30417 var nR = R.multiply(n)
30418 assert(curve.isInfinity(nR), 'nR is not a valid curve point')
30419
30420 // Compute -e from e
30421 var eNeg = e.negate().mod(n)
30422
30423 // 1.6.1 Compute Q = r^-1 (sR - eG)
30424 // Q = r^-1 (sR + -eG)
30425 var rInv = r.modInverse(n)
30426
30427 var Q = R.multiplyTwo(s, G, eNeg).multiply(rInv)
30428 curve.validate(Q)
30429
30430 return Q
30431 }
30432
30433 /**
30434 * Calculate pubkey extraction parameter.
30435 *
30436 * When extracting a pubkey from a signature, we have to
30437 * distinguish four different cases. Rather than putting this
30438 * burden on the verifier, Bitcoin includes a 2-bit value with the
30439 * signature.
30440 *
30441 * This function simply tries all four cases and returns the value
30442 * that resulted in a successful pubkey recovery.
30443 */
30444 function calcPubKeyRecoveryParam(curve, e, signature, Q) {
30445 for (var i = 0; i < 4; i++) {
30446 var Qprime = recoverPubKey(curve, e, signature, i)
30447
30448 // 1.6.2 Verify Q
30449 if (Qprime.equals(Q)) {
30450 return i
30451 }
30452 }
30453
30454 throw new Error('Unable to find valid recovery factor')
30455 }
30456
30457 module.exports = {
30458 calcPubKeyRecoveryParam: calcPubKeyRecoveryParam,
30459 deterministicGenerateK: deterministicGenerateK,
30460 recoverPubKey: recoverPubKey,
30461 sign: sign,
30462 verify: verify,
30463 verifyRaw: verifyRaw
30464 }
30465
30466 }).call(this,_dereq_("buffer").Buffer)
30467 },{"./crypto":73,"./ecsignature":77,"assert":4,"bigi":3,"buffer":8,"ecurve":65}],75:[function(_dereq_,module,exports){
30468 (function (Buffer){
30469 var assert = _dereq_('assert')
30470 var base58check = _dereq_('./base58check')
30471 var ecdsa = _dereq_('./ecdsa')
30472 var networks = _dereq_('./networks')
30473 var secureRandom = _dereq_('secure-random')
30474
30475 var BigInteger = _dereq_('bigi')
30476 var ECPubKey = _dereq_('./ecpubkey')
30477
30478 var ecurve = _dereq_('ecurve')
30479 var curve = ecurve.getCurveByName('secp256k1')
30480
30481 function ECKey(d, compressed) {
30482 assert(d.signum() > 0, 'Private key must be greater than 0')
30483 assert(d.compareTo(curve.n) < 0, 'Private key must be less than the curve order')
30484
30485 var Q = curve.G.multiply(d)
30486
30487 this.d = d
30488 this.pub = new ECPubKey(Q, compressed)
30489 }
30490
30491 // Static constructors
30492 ECKey.fromWIF = function(string) {
30493 var payload = base58check.decode(string)
30494 var compressed = false
30495
30496 // Ignore the version byte
30497 payload = payload.slice(1)
30498
30499 if (payload.length === 33) {
30500 assert.strictEqual(payload[32], 0x01, 'Invalid compression flag')
30501
30502 // Truncate the compression flag
30503 payload = payload.slice(0, -1)
30504 compressed = true
30505 }
30506
30507 assert.equal(payload.length, 32, 'Invalid WIF payload length')
30508
30509 var d = BigInteger.fromBuffer(payload)
30510 return new ECKey(d, compressed)
30511 }
30512
30513 ECKey.makeRandom = function(compressed, rng) {
30514 rng = rng || secureRandom.randomBuffer
30515
30516 var buffer = rng(32)
30517 assert(Buffer.isBuffer(buffer), 'Expected Buffer, got ' + buffer)
30518
30519 var d = BigInteger.fromBuffer(buffer)
30520 d = d.mod(curve.n)
30521
30522 return new ECKey(d, compressed)
30523 }
30524
30525 // Export functions
30526 ECKey.prototype.toWIF = function(network) {
30527 network = network || networks.bitcoin
30528
30529 var bufferLen = this.pub.compressed ? 34 : 33
30530 var buffer = new Buffer(bufferLen)
30531
30532 buffer.writeUInt8(network.wif, 0)
30533 this.d.toBuffer(32).copy(buffer, 1)
30534
30535 if (this.pub.compressed) {
30536 buffer.writeUInt8(0x01, 33)
30537 }
30538
30539 return base58check.encode(buffer)
30540 }
30541
30542 // Operations
30543 ECKey.prototype.sign = function(hash) {
30544 return ecdsa.sign(curve, hash, this.d)
30545 }
30546
30547 module.exports = ECKey
30548
30549 }).call(this,_dereq_("buffer").Buffer)
30550 },{"./base58check":70,"./ecdsa":74,"./ecpubkey":76,"./networks":81,"assert":4,"bigi":3,"buffer":8,"ecurve":65,"secure-random":68}],76:[function(_dereq_,module,exports){
30551 (function (Buffer){
30552 var assert = _dereq_('assert')
30553 var crypto = _dereq_('./crypto')
30554 var ecdsa = _dereq_('./ecdsa')
30555 var networks = _dereq_('./networks')
30556
30557 var Address = _dereq_('./address')
30558
30559 var ecurve = _dereq_('ecurve')
30560 var curve = ecurve.getCurveByName('secp256k1')
30561
30562 function ECPubKey(Q, compressed) {
30563 assert(Q instanceof ecurve.Point, 'Expected Point, got ' + Q)
30564
30565 if (compressed == undefined) compressed = true
30566 assert.strictEqual(typeof compressed, 'boolean', 'Expected boolean, got ' + compressed)
30567
30568 this.compressed = compressed
30569 this.Q = Q
30570 }
30571
30572 // Static constructors
30573 ECPubKey.fromBuffer = function(buffer) {
30574 var Q = ecurve.Point.decodeFrom(curve, buffer)
30575 return new ECPubKey(Q, Q.compressed)
30576 }
30577
30578 ECPubKey.fromHex = function(hex) {
30579 return ECPubKey.fromBuffer(new Buffer(hex, 'hex'))
30580 }
30581
30582 // Operations
30583 ECPubKey.prototype.getAddress = function(network) {
30584 network = network || networks.bitcoin
30585
30586 return new Address(crypto.hash160(this.toBuffer()), network.pubKeyHash)
30587 }
30588
30589 ECPubKey.prototype.verify = function(hash, signature) {
30590 return ecdsa.verify(curve, hash, signature, this.Q)
30591 }
30592
30593 // Export functions
30594 ECPubKey.prototype.toBuffer = function() {
30595 return this.Q.getEncoded(this.compressed)
30596 }
30597
30598 ECPubKey.prototype.toHex = function() {
30599 return this.toBuffer().toString('hex')
30600 }
30601
30602 module.exports = ECPubKey
30603
30604 }).call(this,_dereq_("buffer").Buffer)
30605 },{"./address":69,"./crypto":73,"./ecdsa":74,"./networks":81,"assert":4,"buffer":8,"ecurve":65}],77:[function(_dereq_,module,exports){
30606 (function (Buffer){
30607 var assert = _dereq_('assert')
30608 var BigInteger = _dereq_('bigi')
30609
30610 function ECSignature(r, s) {
30611 assert(r instanceof BigInteger, 'Expected BigInteger, got ' + r)
30612 assert(s instanceof BigInteger, 'Expected BigInteger, got ' + s)
30613 this.r = r
30614 this.s = s
30615 }
30616
30617 // Import operations
30618 ECSignature.parseCompact = function(buffer) {
30619 assert.equal(buffer.length, 65, 'Invalid signature length')
30620 var i = buffer.readUInt8(0) - 27
30621
30622 // At most 3 bits
30623 assert.equal(i, i & 7, 'Invalid signature parameter')
30624 var compressed = !!(i & 4)
30625
30626 // Recovery param only
30627 i = i & 3
30628
30629 var r = BigInteger.fromBuffer(buffer.slice(1, 33))
30630 var s = BigInteger.fromBuffer(buffer.slice(33))
30631
30632 return {
30633 compressed: compressed,
30634 i: i,
30635 signature: new ECSignature(r, s)
30636 }
30637 }
30638
30639 ECSignature.fromDER = function(buffer) {
30640 assert.equal(buffer.readUInt8(0), 0x30, 'Not a DER sequence')
30641 assert.equal(buffer.readUInt8(1), buffer.length - 2, 'Invalid sequence length')
30642 assert.equal(buffer.readUInt8(2), 0x02, 'Expected a DER integer')
30643
30644 var rLen = buffer.readUInt8(3)
30645 assert(rLen > 0, 'R length is zero')
30646
30647 var offset = 4 + rLen
30648 assert.equal(buffer.readUInt8(offset), 0x02, 'Expected a DER integer (2)')
30649
30650 var sLen = buffer.readUInt8(offset + 1)
30651 assert(sLen > 0, 'S length is zero')
30652
30653 var rB = buffer.slice(4, offset)
30654 var sB = buffer.slice(offset + 2)
30655 offset += 2 + sLen
30656
30657 if (rLen > 1 && rB.readUInt8(0) === 0x00) {
30658 assert(rB.readUInt8(1) & 0x80, 'R value excessively padded')
30659 }
30660
30661 if (sLen > 1 && sB.readUInt8(0) === 0x00) {
30662 assert(sB.readUInt8(1) & 0x80, 'S value excessively padded')
30663 }
30664
30665 assert.equal(offset, buffer.length, 'Invalid DER encoding')
30666 var r = BigInteger.fromDERInteger(rB)
30667 var s = BigInteger.fromDERInteger(sB)
30668
30669 assert(r.signum() >= 0, 'R value is negative')
30670 assert(s.signum() >= 0, 'S value is negative')
30671
30672 return new ECSignature(r, s)
30673 }
30674
30675 // FIXME: 0x00, 0x04, 0x80 are SIGHASH_* boundary constants, importing Transaction causes a circular dependency
30676 ECSignature.parseScriptSignature = function(buffer) {
30677 var hashType = buffer.readUInt8(buffer.length - 1)
30678 var hashTypeMod = hashType & ~0x80
30679
30680 assert(hashTypeMod > 0x00 && hashTypeMod < 0x04, 'Invalid hashType')
30681
30682 return {
30683 signature: ECSignature.fromDER(buffer.slice(0, -1)),
30684 hashType: hashType
30685 }
30686 }
30687
30688 // Export operations
30689 ECSignature.prototype.toCompact = function(i, compressed) {
30690 if (compressed) i += 4
30691 i += 27
30692
30693 var buffer = new Buffer(65)
30694 buffer.writeUInt8(i, 0)
30695
30696 this.r.toBuffer(32).copy(buffer, 1)
30697 this.s.toBuffer(32).copy(buffer, 33)
30698
30699 return buffer
30700 }
30701
30702 ECSignature.prototype.toDER = function() {
30703 var rBa = this.r.toDERInteger()
30704 var sBa = this.s.toDERInteger()
30705
30706 var sequence = []
30707 sequence.push(0x02) // INTEGER
30708 sequence.push(rBa.length)
30709 sequence = sequence.concat(rBa)
30710
30711 sequence.push(0x02) // INTEGER
30712 sequence.push(sBa.length)
30713 sequence = sequence.concat(sBa)
30714
30715 sequence.unshift(sequence.length)
30716 sequence.unshift(0x30) // SEQUENCE
30717
30718 return new Buffer(sequence)
30719 }
30720
30721 ECSignature.prototype.toScriptSignature = function(hashType) {
30722 var hashTypeBuffer = new Buffer(1)
30723 hashTypeBuffer.writeUInt8(hashType, 0)
30724
30725 return Buffer.concat([this.toDER(), hashTypeBuffer])
30726 }
30727
30728 module.exports = ECSignature
30729
30730 }).call(this,_dereq_("buffer").Buffer)
30731 },{"assert":4,"bigi":3,"buffer":8}],78:[function(_dereq_,module,exports){
30732 (function (Buffer){
30733 var assert = _dereq_('assert')
30734 var base58check = _dereq_('./base58check')
30735 var crypto = _dereq_('./crypto')
30736 var networks = _dereq_('./networks')
30737
30738 var BigInteger = _dereq_('bigi')
30739 var ECKey = _dereq_('./eckey')
30740 var ECPubKey = _dereq_('./ecpubkey')
30741
30742 var ecurve = _dereq_('ecurve')
30743 var curve = ecurve.getCurveByName('secp256k1')
30744
30745 function findBIP32ParamsByVersion(version) {
30746 for (var name in networks) {
30747 var network = networks[name]
30748
30749 for (var type in network.bip32) {
30750 if (version != network.bip32[type]) continue
30751
30752 return {
30753 isPrivate: (type === 'private'),
30754 network: network
30755 }
30756 }
30757 }
30758
30759 assert(false, 'Could not find version ' + version.toString(16))
30760 }
30761
30762 function HDNode(K, chainCode, network) {
30763 network = network || networks.bitcoin
30764
30765 assert(Buffer.isBuffer(chainCode), 'Expected Buffer, got ' + chainCode)
30766 assert(network.bip32, 'Unknown BIP32 constants for network')
30767
30768 this.chainCode = chainCode
30769 this.depth = 0
30770 this.index = 0
30771 this.network = network
30772
30773 if (K instanceof BigInteger) {
30774 this.privKey = new ECKey(K, true)
30775 this.pubKey = this.privKey.pub
30776 } else {
30777 this.pubKey = new ECPubKey(K, true)
30778 }
30779 }
30780
30781 HDNode.MASTER_SECRET = new Buffer('Bitcoin seed')
30782 HDNode.HIGHEST_BIT = 0x80000000
30783 HDNode.LENGTH = 78
30784
30785 HDNode.fromSeedBuffer = function(seed, network) {
30786 var I = crypto.HmacSHA512(seed, HDNode.MASTER_SECRET)
30787 var IL = I.slice(0, 32)
30788 var IR = I.slice(32)
30789
30790 // In case IL is 0 or >= n, the master key is invalid
30791 // This is handled by `new ECKey` in the HDNode constructor
30792 var pIL = BigInteger.fromBuffer(IL)
30793
30794 return new HDNode(pIL, IR, network)
30795 }
30796
30797 HDNode.fromSeedHex = function(hex, network) {
30798 return HDNode.fromSeedBuffer(new Buffer(hex, 'hex'), network)
30799 }
30800
30801 HDNode.fromBase58 = function(string) {
30802 return HDNode.fromBuffer(base58check.decode(string))
30803 }
30804
30805 HDNode.fromBuffer = function(buffer) {
30806 assert.strictEqual(buffer.length, HDNode.LENGTH, 'Invalid buffer length')
30807
30808 // 4 byte: version bytes
30809 var version = buffer.readUInt32BE(0)
30810 var params = findBIP32ParamsByVersion(version)
30811
30812 // 1 byte: depth: 0x00 for master nodes, 0x01 for level-1 descendants, ...
30813 var depth = buffer.readUInt8(4)
30814
30815 // 4 bytes: the fingerprint of the parent's key (0x00000000 if master key)
30816 var parentFingerprint = buffer.readUInt32BE(5)
30817 if (depth === 0) {
30818 assert.strictEqual(parentFingerprint, 0x00000000, 'Invalid parent fingerprint')
30819 }
30820
30821 // 4 bytes: child number. This is the number i in xi = xpar/i, with xi the key being serialized.
30822 // This is encoded in MSB order. (0x00000000 if master key)
30823 var index = buffer.readUInt32BE(9)
30824 assert(depth > 0 || index === 0, 'Invalid index')
30825
30826 // 32 bytes: the chain code
30827 var chainCode = buffer.slice(13, 45)
30828 var hd
30829
30830 // 33 bytes: private key data (0x00 + k)
30831 if (params.isPrivate) {
30832 assert.strictEqual(buffer.readUInt8(45), 0x00, 'Invalid private key')
30833 var data = buffer.slice(46, 78)
30834 var d = BigInteger.fromBuffer(data)
30835 hd = new HDNode(d, chainCode, params.network)
30836
30837 // 33 bytes: public key data (0x02 + X or 0x03 + X)
30838 } else {
30839 var data = buffer.slice(45, 78)
30840 var Q = ecurve.Point.decodeFrom(curve, data)
30841 assert.equal(Q.compressed, true, 'Invalid public key')
30842
30843 // Verify that the X coordinate in the public point corresponds to a point on the curve.
30844 // If not, the extended public key is invalid.
30845 curve.validate(Q)
30846
30847 hd = new HDNode(Q, chainCode, params.network)
30848 }
30849
30850 hd.depth = depth
30851 hd.index = index
30852 hd.parentFingerprint = parentFingerprint
30853
30854 return hd
30855 }
30856
30857 HDNode.fromHex = function(hex) {
30858 return HDNode.fromBuffer(new Buffer(hex, 'hex'))
30859 }
30860
30861 HDNode.prototype.getIdentifier = function() {
30862 return crypto.hash160(this.pubKey.toBuffer())
30863 }
30864
30865 HDNode.prototype.getFingerprint = function() {
30866 return this.getIdentifier().slice(0, 4)
30867 }
30868
30869 HDNode.prototype.getAddress = function() {
30870 return this.pubKey.getAddress(this.network)
30871 }
30872
30873 HDNode.prototype.toBase58 = function(isPrivate) {
30874 return base58check.encode(this.toBuffer(isPrivate))
30875 }
30876
30877 HDNode.prototype.toBuffer = function(isPrivate) {
30878 if (isPrivate == undefined) isPrivate = !!this.privKey
30879
30880 // Version
30881 var version = isPrivate ? this.network.bip32.private : this.network.bip32.public
30882 var buffer = new Buffer(HDNode.LENGTH)
30883
30884 // 4 bytes: version bytes
30885 buffer.writeUInt32BE(version, 0)
30886
30887 // Depth
30888 // 1 byte: depth: 0x00 for master nodes, 0x01 for level-1 descendants, ....
30889 buffer.writeUInt8(this.depth, 4)
30890
30891 // 4 bytes: the fingerprint of the parent's key (0x00000000 if master key)
30892 var fingerprint = (this.depth === 0) ? 0x00000000 : this.parentFingerprint
30893 buffer.writeUInt32BE(fingerprint, 5)
30894
30895 // 4 bytes: child number. This is the number i in xi = xpar/i, with xi the key being serialized.
30896 // This is encoded in Big endian. (0x00000000 if master key)
30897 buffer.writeUInt32BE(this.index, 9)
30898
30899 // 32 bytes: the chain code
30900 this.chainCode.copy(buffer, 13)
30901
30902 // 33 bytes: the public key or private key data
30903 if (isPrivate) {
30904 assert(this.privKey, 'Missing private key')
30905
30906 // 0x00 + k for private keys
30907 buffer.writeUInt8(0, 45)
30908 this.privKey.d.toBuffer(32).copy(buffer, 46)
30909 } else {
30910
30911 // X9.62 encoding for public keys
30912 this.pubKey.toBuffer().copy(buffer, 45)
30913 }
30914
30915 return buffer
30916 }
30917
30918 HDNode.prototype.toHex = function(isPrivate) {
30919 return this.toBuffer(isPrivate).toString('hex')
30920 }
30921
30922 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#child-key-derivation-ckd-functions
30923 HDNode.prototype.derive = function(index) {
30924 var isHardened = index >= HDNode.HIGHEST_BIT
30925 var indexBuffer = new Buffer(4)
30926 indexBuffer.writeUInt32BE(index, 0)
30927
30928 var data
30929
30930 // Hardened child
30931 if (isHardened) {
30932 assert(this.privKey, 'Could not derive hardened child key')
30933
30934 // data = 0x00 || ser256(kpar) || ser32(index)
30935 data = Buffer.concat([
30936 this.privKey.d.toBuffer(33),
30937 indexBuffer
30938 ])
30939
30940 // Normal child
30941 } else {
30942 // data = serP(point(kpar)) || ser32(index)
30943 // = serP(Kpar) || ser32(index)
30944 data = Buffer.concat([
30945 this.pubKey.toBuffer(),
30946 indexBuffer
30947 ])
30948 }
30949
30950 var I = crypto.HmacSHA512(data, this.chainCode)
30951 var IL = I.slice(0, 32)
30952 var IR = I.slice(32)
30953
30954 var pIL = BigInteger.fromBuffer(IL)
30955
30956 // In case parse256(IL) >= n, proceed with the next value for i
30957 if (pIL.compareTo(curve.n) >= 0) {
30958 return this.derive(index + 1)
30959 }
30960
30961 // Private parent key -> private child key
30962 var hd
30963 if (this.privKey) {
30964 // ki = parse256(IL) + kpar (mod n)
30965 var ki = pIL.add(this.privKey.d).mod(curve.n)
30966
30967 // In case ki == 0, proceed with the next value for i
30968 if (ki.signum() === 0) {
30969 return this.derive(index + 1)
30970 }
30971
30972 hd = new HDNode(ki, IR, this.network)
30973
30974 // Public parent key -> public child key
30975 } else {
30976 // Ki = point(parse256(IL)) + Kpar
30977 // = G*IL + Kpar
30978 var Ki = curve.G.multiply(pIL).add(this.pubKey.Q)
30979
30980 // In case Ki is the point at infinity, proceed with the next value for i
30981 if (curve.isInfinity(Ki)) {
30982 return this.derive(index + 1)
30983 }
30984
30985 hd = new HDNode(Ki, IR, this.network)
30986 }
30987
30988 hd.depth = this.depth + 1
30989 hd.index = index
30990 hd.parentFingerprint = this.getFingerprint().readUInt32BE(0)
30991
30992 return hd
30993 }
30994
30995 HDNode.prototype.deriveHardened = function(index) {
30996 // Only derives hardened private keys by default
30997 return this.derive(index + HDNode.HIGHEST_BIT)
30998 }
30999
31000 HDNode.prototype.toString = HDNode.prototype.toBase58
31001
31002 module.exports = HDNode
31003
31004 }).call(this,_dereq_("buffer").Buffer)
31005 },{"./base58check":70,"./crypto":73,"./eckey":75,"./ecpubkey":76,"./networks":81,"assert":4,"bigi":3,"buffer":8,"ecurve":65}],79:[function(_dereq_,module,exports){
31006 module.exports = {
31007 Address: _dereq_('./address'),
31008 base58check: _dereq_('./base58check'),
31009 bufferutils: _dereq_('./bufferutils'),
31010 convert: _dereq_('./convert'),
31011 crypto: _dereq_('./crypto'),
31012 ecdsa: _dereq_('./ecdsa'),
31013 ECKey: _dereq_('./eckey'),
31014 ECPubKey: _dereq_('./ecpubkey'),
31015 ECSignature: _dereq_('./ecsignature'),
31016 Message: _dereq_('./message'),
31017 opcodes: _dereq_('./opcodes'),
31018 HDNode: _dereq_('./hdnode'),
31019 Script: _dereq_('./script'),
31020 scripts: _dereq_('./scripts'),
31021 Transaction: _dereq_('./transaction'),
31022 networks: _dereq_('./networks'),
31023 Wallet: _dereq_('./wallet')
31024 }
31025
31026 },{"./address":69,"./base58check":70,"./bufferutils":71,"./convert":72,"./crypto":73,"./ecdsa":74,"./eckey":75,"./ecpubkey":76,"./ecsignature":77,"./hdnode":78,"./message":80,"./networks":81,"./opcodes":82,"./script":83,"./scripts":84,"./transaction":85,"./wallet":86}],80:[function(_dereq_,module,exports){
31027 (function (Buffer){
31028 /// Implements Bitcoin's feature for signing arbitrary messages.
31029 var Address = _dereq_('./address')
31030 var BigInteger = _dereq_('bigi')
31031 var bufferutils = _dereq_('./bufferutils')
31032 var crypto = _dereq_('./crypto')
31033 var ecdsa = _dereq_('./ecdsa')
31034 var networks = _dereq_('./networks')
31035
31036 var Address = _dereq_('./address')
31037 var ECPubKey = _dereq_('./ecpubkey')
31038 var ECSignature = _dereq_('./ecsignature')
31039
31040 var ecurve = _dereq_('ecurve')
31041 var ecparams = ecurve.getCurveByName('secp256k1')
31042
31043 function magicHash(message, network) {
31044 var magicPrefix = new Buffer(network.magicPrefix)
31045 var messageBuffer = new Buffer(message)
31046 var lengthBuffer = new Buffer(bufferutils.varIntSize(messageBuffer.length))
31047 bufferutils.writeVarInt(lengthBuffer, messageBuffer.length, 0)
31048
31049 var buffer = Buffer.concat([magicPrefix, lengthBuffer, messageBuffer])
31050 return crypto.hash256(buffer)
31051 }
31052
31053 function sign(privKey, message, network) {
31054 network = network || networks.bitcoin
31055
31056 var hash = magicHash(message, network)
31057 var signature = privKey.sign(hash)
31058 var e = BigInteger.fromBuffer(hash)
31059 var i = ecdsa.calcPubKeyRecoveryParam(ecparams, e, signature, privKey.pub.Q)
31060
31061 return signature.toCompact(i, privKey.pub.compressed)
31062 }
31063
31064 // TODO: network could be implied from address
31065 function verify(address, signatureBuffer, message, network) {
31066 if (address instanceof Address) {
31067 address = address.toString()
31068 }
31069 network = network || networks.bitcoin
31070
31071 var hash = magicHash(message, network)
31072 var parsed = ECSignature.parseCompact(signatureBuffer)
31073 var e = BigInteger.fromBuffer(hash)
31074 var Q = ecdsa.recoverPubKey(ecparams, e, parsed.signature, parsed.i)
31075
31076 var pubKey = new ECPubKey(Q, parsed.compressed)
31077 return pubKey.getAddress(network).toString() === address
31078 }
31079
31080 module.exports = {
31081 magicHash: magicHash,
31082 sign: sign,
31083 verify: verify
31084 }
31085
31086 }).call(this,_dereq_("buffer").Buffer)
31087 },{"./address":69,"./bufferutils":71,"./crypto":73,"./ecdsa":74,"./ecpubkey":76,"./ecsignature":77,"./networks":81,"bigi":3,"buffer":8,"ecurve":65}],81:[function(_dereq_,module,exports){
31088 // https://en.bitcoin.it/wiki/List_of_address_prefixes
31089 // Dogecoin BIP32 is a proposed standard: https://bitcointalk.org/index.php?topic=409731
31090
31091 var networks = {
31092 bitcoin: {
31093 magicPrefix: '\x18Bitcoin Signed Message:\n',
31094 bip32: {
31095 public: 0x0488b21e,
31096 private: 0x0488ade4
31097 },
31098 pubKeyHash: 0x00,
31099 scriptHash: 0x05,
31100 wif: 0x80,
31101 dustThreshold: 546, // https://github.com/bitcoin/bitcoin/blob/v0.9.2/src/core.h#L151-L162
31102 feePerKb: 10000, // https://github.com/bitcoin/bitcoin/blob/v0.9.2/src/main.cpp#L53
31103 estimateFee: estimateFee('bitcoin')
31104 },
31105 dogecoin: {
31106 magicPrefix: '\x19Dogecoin Signed Message:\n',
31107 bip32: {
31108 public: 0x02facafd,
31109 private: 0x02fac398
31110 },
31111 pubKeyHash: 0x1e,
31112 scriptHash: 0x16,
31113 wif: 0x9e,
31114 dustThreshold: 0, // https://github.com/dogecoin/dogecoin/blob/v1.7.1/src/core.h#L155-L160
31115 dustSoftThreshold: 100000000, // https://github.com/dogecoin/dogecoin/blob/v1.7.1/src/main.h#L62
31116 feePerKb: 100000000, // https://github.com/dogecoin/dogecoin/blob/v1.7.1/src/main.cpp#L58
31117 estimateFee: estimateFee('dogecoin')
31118 },
31119 litecoin: {
31120 magicPrefix: '\x19Litecoin Signed Message:\n',
31121 bip32: {
31122 public: 0x019da462,
31123 private: 0x019d9cfe
31124 },
31125 pubKeyHash: 0x30,
31126 scriptHash: 0x05,
31127 wif: 0xb0,
31128 dustThreshold: 0, // https://github.com/litecoin-project/litecoin/blob/v0.8.7.2/src/main.cpp#L360-L365
31129 dustSoftThreshold: 100000, // https://github.com/litecoin-project/litecoin/blob/v0.8.7.2/src/main.h#L53
31130 feePerKb: 100000, // https://github.com/litecoin-project/litecoin/blob/v0.8.7.2/src/main.cpp#L56
31131 estimateFee: estimateFee('litecoin')
31132 },
31133 testnet: {
31134 magicPrefix: '\x18Bitcoin Signed Message:\n',
31135 bip32: {
31136 public: 0x043587cf,
31137 private: 0x04358394
31138 },
31139 pubKeyHash: 0x6f,
31140 scriptHash: 0xc4,
31141 wif: 0xef,
31142 dustThreshold: 546,
31143 feePerKb: 10000,
31144 estimateFee: estimateFee('testnet')
31145 }
31146 }
31147
31148 function estimateFee(type) {
31149 return function(tx) {
31150 var network = networks[type]
31151 var baseFee = network.feePerKb
31152 var byteSize = tx.toBuffer().length
31153
31154 var fee = baseFee * Math.ceil(byteSize / 1000)
31155 if (network.dustSoftThreshold == undefined) return fee
31156
31157 tx.outs.forEach(function(e){
31158 if (e.value < network.dustSoftThreshold) {
31159 fee += baseFee
31160 }
31161 })
31162
31163 return fee
31164 }
31165 }
31166
31167 module.exports = networks
31168
31169 },{}],82:[function(_dereq_,module,exports){
31170 module.exports = {
31171 // push value
31172 OP_FALSE : 0,
31173 OP_0 : 0,
31174 OP_PUSHDATA1 : 76,
31175 OP_PUSHDATA2 : 77,
31176 OP_PUSHDATA4 : 78,
31177 OP_1NEGATE : 79,
31178 OP_RESERVED : 80,
31179 OP_1 : 81,
31180 OP_TRUE : 81,
31181 OP_2 : 82,
31182 OP_3 : 83,
31183 OP_4 : 84,
31184 OP_5 : 85,
31185 OP_6 : 86,
31186 OP_7 : 87,
31187 OP_8 : 88,
31188 OP_9 : 89,
31189 OP_10 : 90,
31190 OP_11 : 91,
31191 OP_12 : 92,
31192 OP_13 : 93,
31193 OP_14 : 94,
31194 OP_15 : 95,
31195 OP_16 : 96,
31196
31197 // control
31198 OP_NOP : 97,
31199 OP_VER : 98,
31200 OP_IF : 99,
31201 OP_NOTIF : 100,
31202 OP_VERIF : 101,
31203 OP_VERNOTIF : 102,
31204 OP_ELSE : 103,
31205 OP_ENDIF : 104,
31206 OP_VERIFY : 105,
31207 OP_RETURN : 106,
31208
31209 // stack ops
31210 OP_TOALTSTACK : 107,
31211 OP_FROMALTSTACK : 108,
31212 OP_2DROP : 109,
31213 OP_2DUP : 110,
31214 OP_3DUP : 111,
31215 OP_2OVER : 112,
31216 OP_2ROT : 113,
31217 OP_2SWAP : 114,
31218 OP_IFDUP : 115,
31219 OP_DEPTH : 116,
31220 OP_DROP : 117,
31221 OP_DUP : 118,
31222 OP_NIP : 119,
31223 OP_OVER : 120,
31224 OP_PICK : 121,
31225 OP_ROLL : 122,
31226 OP_ROT : 123,
31227 OP_SWAP : 124,
31228 OP_TUCK : 125,
31229
31230 // splice ops
31231 OP_CAT : 126,
31232 OP_SUBSTR : 127,
31233 OP_LEFT : 128,
31234 OP_RIGHT : 129,
31235 OP_SIZE : 130,
31236
31237 // bit logic
31238 OP_INVERT : 131,
31239 OP_AND : 132,
31240 OP_OR : 133,
31241 OP_XOR : 134,
31242 OP_EQUAL : 135,
31243 OP_EQUALVERIFY : 136,
31244 OP_RESERVED1 : 137,
31245 OP_RESERVED2 : 138,
31246
31247 // numeric
31248 OP_1ADD : 139,
31249 OP_1SUB : 140,
31250 OP_2MUL : 141,
31251 OP_2DIV : 142,
31252 OP_NEGATE : 143,
31253 OP_ABS : 144,
31254 OP_NOT : 145,
31255 OP_0NOTEQUAL : 146,
31256
31257 OP_ADD : 147,
31258 OP_SUB : 148,
31259 OP_MUL : 149,
31260 OP_DIV : 150,
31261 OP_MOD : 151,
31262 OP_LSHIFT : 152,
31263 OP_RSHIFT : 153,
31264
31265 OP_BOOLAND : 154,
31266 OP_BOOLOR : 155,
31267 OP_NUMEQUAL : 156,
31268 OP_NUMEQUALVERIFY : 157,
31269 OP_NUMNOTEQUAL : 158,
31270 OP_LESSTHAN : 159,
31271 OP_GREATERTHAN : 160,
31272 OP_LESSTHANOREQUAL : 161,
31273 OP_GREATERTHANOREQUAL : 162,
31274 OP_MIN : 163,
31275 OP_MAX : 164,
31276
31277 OP_WITHIN : 165,
31278
31279 // crypto
31280 OP_RIPEMD160 : 166,
31281 OP_SHA1 : 167,
31282 OP_SHA256 : 168,
31283 OP_HASH160 : 169,
31284 OP_HASH256 : 170,
31285 OP_CODESEPARATOR : 171,
31286 OP_CHECKSIG : 172,
31287 OP_CHECKSIGVERIFY : 173,
31288 OP_CHECKMULTISIG : 174,
31289 OP_CHECKMULTISIGVERIFY : 175,
31290
31291 // expansion
31292 OP_NOP1 : 176,
31293 OP_NOP2 : 177,
31294 OP_NOP3 : 178,
31295 OP_NOP4 : 179,
31296 OP_NOP5 : 180,
31297 OP_NOP6 : 181,
31298 OP_NOP7 : 182,
31299 OP_NOP8 : 183,
31300 OP_NOP9 : 184,
31301 OP_NOP10 : 185,
31302
31303 // template matching params
31304 OP_PUBKEYHASH : 253,
31305 OP_PUBKEY : 254,
31306 OP_INVALIDOPCODE : 255
31307 }
31308
31309 },{}],83:[function(_dereq_,module,exports){
31310 (function (Buffer){
31311 var assert = _dereq_('assert')
31312 var bufferutils = _dereq_('./bufferutils')
31313 var crypto = _dereq_('./crypto')
31314 var opcodes = _dereq_('./opcodes')
31315
31316 function Script(buffer, chunks) {
31317 assert(Buffer.isBuffer(buffer), 'Expected Buffer, got ' + buffer)
31318 assert(Array.isArray(chunks), 'Expected Array, got ' + chunks)
31319
31320 this.buffer = buffer
31321 this.chunks = chunks
31322 }
31323
31324 // Import operations
31325 Script.fromASM = function(asm) {
31326 var strChunks = asm.split(' ')
31327
31328 var chunks = strChunks.map(function(strChunk) {
31329 if (strChunk in opcodes) {
31330 return opcodes[strChunk]
31331
31332 } else {
31333 return new Buffer(strChunk, 'hex')
31334 }
31335 })
31336
31337 return Script.fromChunks(chunks)
31338 }
31339
31340 Script.fromBuffer = function(buffer) {
31341 var chunks = []
31342
31343 var i = 0
31344
31345 while (i < buffer.length) {
31346 var opcode = buffer.readUInt8(i)
31347
31348 if ((opcode > opcodes.OP_0) && (opcode <= opcodes.OP_PUSHDATA4)) {
31349 var d = bufferutils.readPushDataInt(buffer, i)
31350 i += d.size
31351
31352 var data = buffer.slice(i, i + d.number)
31353 i += d.number
31354
31355 chunks.push(data)
31356
31357 } else {
31358 chunks.push(opcode)
31359
31360 i += 1
31361 }
31362 }
31363
31364 return new Script(buffer, chunks)
31365 }
31366
31367 Script.fromChunks = function(chunks) {
31368 assert(Array.isArray(chunks), 'Expected Array, got ' + chunks)
31369
31370 var bufferSize = chunks.reduce(function(accum, chunk) {
31371 if (Buffer.isBuffer(chunk)) {
31372 return accum + bufferutils.pushDataSize(chunk.length) + chunk.length
31373 }
31374
31375 return accum + 1
31376 }, 0.0)
31377
31378 var buffer = new Buffer(bufferSize)
31379 var offset = 0
31380
31381 chunks.forEach(function(chunk) {
31382 if (Buffer.isBuffer(chunk)) {
31383 offset += bufferutils.writePushDataInt(buffer, chunk.length, offset)
31384
31385 chunk.copy(buffer, offset)
31386 offset += chunk.length
31387
31388 } else {
31389 buffer.writeUInt8(chunk, offset)
31390 offset += 1
31391 }
31392 })
31393
31394 assert.equal(offset, buffer.length, 'Could not decode chunks')
31395 return new Script(buffer, chunks)
31396 }
31397
31398 Script.fromHex = function(hex) {
31399 return Script.fromBuffer(new Buffer(hex, 'hex'))
31400 }
31401
31402 // Constants
31403 Script.EMPTY = Script.fromChunks([])
31404
31405 // Operations
31406 Script.prototype.getHash = function() {
31407 return crypto.hash160(this.buffer)
31408 }
31409
31410 // FIXME: doesn't work for data chunks, maybe time to use buffertools.compare...
31411 Script.prototype.without = function(needle) {
31412 return Script.fromChunks(this.chunks.filter(function(op) {
31413 return op !== needle
31414 }))
31415 }
31416
31417 // Export operations
31418 var reverseOps = []
31419 for (var op in opcodes) {
31420 var code = opcodes[op]
31421 reverseOps[code] = op
31422 }
31423
31424 Script.prototype.toASM = function() {
31425 return this.chunks.map(function(chunk) {
31426 if (Buffer.isBuffer(chunk)) {
31427 return chunk.toString('hex')
31428
31429 } else {
31430 return reverseOps[chunk]
31431 }
31432 }).join(' ')
31433 }
31434
31435 Script.prototype.toBuffer = function() {
31436 return this.buffer
31437 }
31438
31439 Script.prototype.toHex = function() {
31440 return this.toBuffer().toString('hex')
31441 }
31442
31443 module.exports = Script
31444
31445 }).call(this,_dereq_("buffer").Buffer)
31446 },{"./bufferutils":71,"./crypto":73,"./opcodes":82,"assert":4,"buffer":8}],84:[function(_dereq_,module,exports){
31447 (function (Buffer){
31448 var assert = _dereq_('assert')
31449 var opcodes = _dereq_('./opcodes')
31450
31451 // FIXME: use ECPubKey, currently the circular dependency breaks everything.
31452 //
31453 // Solutions:
31454 // * Remove ECPubKey.getAddress
31455 // - Minimal change, but likely unpopular
31456 // * Move all script related functionality out of Address
31457 // - Means a lot of changes to Transaction/Wallet
31458 // * Ignore it (existing solution)
31459 // * Some form of hackery with commonjs
31460 //
31461 var ecurve = _dereq_('ecurve')
31462 var curve = ecurve.getCurveByName('secp256k1')
31463
31464 var ECSignature = _dereq_('./ecsignature')
31465 var Script = _dereq_('./script')
31466
31467 function classifyOutput(script) {
31468 assert(script instanceof Script, 'Expected Script, got ', script)
31469
31470 if (isPubKeyHashOutput.call(script)) {
31471 return 'pubkeyhash'
31472 } else if (isScriptHashOutput.call(script)) {
31473 return 'scripthash'
31474 } else if (isMultisigOutput.call(script)) {
31475 return 'multisig'
31476 } else if (isPubKeyOutput.call(script)) {
31477 return 'pubkey'
31478 } else if (isNulldataOutput.call(script)) {
31479 return 'nulldata'
31480 } else {
31481 return 'nonstandard'
31482 }
31483 }
31484
31485 function classifyInput(script) {
31486 assert(script instanceof Script, 'Expected Script, got ', script)
31487
31488 if (isPubKeyHashInput.call(script)) {
31489 return 'pubkeyhash'
31490 } else if (isScriptHashInput.call(script)) {
31491 return 'scripthash'
31492 } else if (isMultisigInput.call(script)) {
31493 return 'multisig'
31494 } else if (isPubKeyInput.call(script)) {
31495 return 'pubkey'
31496 } else {
31497 return 'nonstandard'
31498 }
31499 }
31500
31501 function isCanonicalPubKey(buffer) {
31502 if (!Buffer.isBuffer(buffer)) return false
31503
31504 try {
31505 // FIXME: boo
31506 ecurve.Point.decodeFrom(curve, buffer)
31507 } catch (e) {
31508 if (!(e.message.match(/Invalid sequence (length|tag)/))) throw e
31509
31510 return false
31511 }
31512
31513 return true
31514 }
31515
31516 function isCanonicalSignature(buffer) {
31517 if (!Buffer.isBuffer(buffer)) return false
31518
31519 try {
31520 ECSignature.parseScriptSignature(buffer)
31521 } catch(e) {
31522 if (!(e.message.match(/Not a DER sequence|Invalid sequence length|Expected a DER integer|R length is zero|S length is zero|R value excessively padded|S value excessively padded|R value is negative|S value is negative|Invalid hashType/))) throw e
31523
31524 return false
31525 }
31526
31527 return true
31528 }
31529
31530 function isPubKeyHashInput() {
31531 return this.chunks.length === 2 &&
31532 isCanonicalSignature(this.chunks[0]) &&
31533 isCanonicalPubKey(this.chunks[1])
31534 }
31535
31536 function isPubKeyHashOutput() {
31537 return this.chunks.length === 5 &&
31538 this.chunks[0] === opcodes.OP_DUP &&
31539 this.chunks[1] === opcodes.OP_HASH160 &&
31540 Buffer.isBuffer(this.chunks[2]) &&
31541 this.chunks[2].length === 20 &&
31542 this.chunks[3] === opcodes.OP_EQUALVERIFY &&
31543 this.chunks[4] === opcodes.OP_CHECKSIG
31544 }
31545
31546 function isPubKeyInput() {
31547 return this.chunks.length === 1 &&
31548 isCanonicalSignature(this.chunks[0])
31549 }
31550
31551 function isPubKeyOutput() {
31552 return this.chunks.length === 2 &&
31553 isCanonicalPubKey(this.chunks[0]) &&
31554 this.chunks[1] === opcodes.OP_CHECKSIG
31555 }
31556
31557 function isScriptHashInput() {
31558 if (this.chunks.length < 2) return false
31559 var lastChunk = this.chunks[this.chunks.length - 1]
31560
31561 if (!Buffer.isBuffer(lastChunk)) return false
31562
31563 var scriptSig = Script.fromChunks(this.chunks.slice(0, -1))
31564 var scriptPubKey = Script.fromBuffer(lastChunk)
31565
31566 return classifyInput(scriptSig) === classifyOutput(scriptPubKey)
31567 }
31568
31569 function isScriptHashOutput() {
31570 return this.chunks.length === 3 &&
31571 this.chunks[0] === opcodes.OP_HASH160 &&
31572 Buffer.isBuffer(this.chunks[1]) &&
31573 this.chunks[1].length === 20 &&
31574 this.chunks[2] === opcodes.OP_EQUAL
31575 }
31576
31577 function isMultisigInput() {
31578 return this.chunks[0] === opcodes.OP_0 &&
31579 this.chunks.slice(1).every(isCanonicalSignature)
31580 }
31581
31582 function isMultisigOutput() {
31583 if (this.chunks < 4) return false
31584 if (this.chunks[this.chunks.length - 1] !== opcodes.OP_CHECKMULTISIG) return false
31585
31586 var mOp = this.chunks[0]
31587 if (mOp === opcodes.OP_0) return false
31588 if (mOp < opcodes.OP_1) return false
31589 if (mOp > opcodes.OP_16) return false
31590
31591 var nOp = this.chunks[this.chunks.length - 2]
31592 if (nOp === opcodes.OP_0) return false
31593 if (nOp < opcodes.OP_1) return false
31594 if (nOp > opcodes.OP_16) return false
31595
31596 var m = mOp - (opcodes.OP_1 - 1)
31597 var n = nOp - (opcodes.OP_1 - 1)
31598 if (n < m) return false
31599
31600 var pubKeys = this.chunks.slice(1, -2)
31601 if (n < pubKeys.length) return false
31602
31603 return pubKeys.every(isCanonicalPubKey)
31604 }
31605
31606 function isNulldataOutput() {
31607 return this.chunks[0] === opcodes.OP_RETURN
31608 }
31609
31610 // Standard Script Templates
31611 // {pubKey} OP_CHECKSIG
31612 function pubKeyOutput(pubKey) {
31613 return Script.fromChunks([
31614 pubKey.toBuffer(),
31615 opcodes.OP_CHECKSIG
31616 ])
31617 }
31618
31619 // OP_DUP OP_HASH160 {pubKeyHash} OP_EQUALVERIFY OP_CHECKSIG
31620 function pubKeyHashOutput(hash) {
31621 assert(Buffer.isBuffer(hash), 'Expected Buffer, got ' + hash)
31622
31623 return Script.fromChunks([
31624 opcodes.OP_DUP,
31625 opcodes.OP_HASH160,
31626 hash,
31627 opcodes.OP_EQUALVERIFY,
31628 opcodes.OP_CHECKSIG
31629 ])
31630 }
31631
31632 // OP_HASH160 {scriptHash} OP_EQUAL
31633 function scriptHashOutput(hash) {
31634 assert(Buffer.isBuffer(hash), 'Expected Buffer, got ' + hash)
31635
31636 return Script.fromChunks([
31637 opcodes.OP_HASH160,
31638 hash,
31639 opcodes.OP_EQUAL
31640 ])
31641 }
31642
31643 // m [pubKeys ...] n OP_CHECKMULTISIG
31644 function multisigOutput(m, pubKeys) {
31645 assert(Array.isArray(pubKeys), 'Expected Array, got ' + pubKeys)
31646 assert(pubKeys.length >= m, 'Not enough pubKeys provided')
31647
31648 var pubKeyBuffers = pubKeys.map(function(pubKey) {
31649 return pubKey.toBuffer()
31650 })
31651 var n = pubKeys.length
31652
31653 return Script.fromChunks([].concat(
31654 (opcodes.OP_1 - 1) + m,
31655 pubKeyBuffers,
31656 (opcodes.OP_1 - 1) + n,
31657 opcodes.OP_CHECKMULTISIG
31658 ))
31659 }
31660
31661 // {signature}
31662 function pubKeyInput(signature) {
31663 assert(Buffer.isBuffer(signature), 'Expected Buffer, got ' + signature)
31664
31665 return Script.fromChunks([signature])
31666 }
31667
31668 // {signature} {pubKey}
31669 function pubKeyHashInput(signature, pubKey) {
31670 assert(Buffer.isBuffer(signature), 'Expected Buffer, got ' + signature)
31671
31672 return Script.fromChunks([signature, pubKey.toBuffer()])
31673 }
31674
31675 // <scriptSig> {serialized scriptPubKey script}
31676 function scriptHashInput(scriptSig, scriptPubKey) {
31677 return Script.fromChunks([].concat(
31678 scriptSig.chunks,
31679 scriptPubKey.toBuffer()
31680 ))
31681 }
31682
31683 // OP_0 [signatures ...]
31684 function multisigInput(signatures, scriptPubKey) {
31685 if (scriptPubKey) {
31686 assert(isMultisigOutput.call(scriptPubKey))
31687
31688 var m = scriptPubKey.chunks[0]
31689 var k = m - (opcodes.OP_1 - 1)
31690 assert(k <= signatures.length, 'Not enough signatures provided')
31691 }
31692
31693 return Script.fromChunks([].concat(opcodes.OP_0, signatures))
31694 }
31695
31696 module.exports = {
31697 classifyInput: classifyInput,
31698 classifyOutput: classifyOutput,
31699 multisigInput: multisigInput,
31700 multisigOutput: multisigOutput,
31701 pubKeyHashInput: pubKeyHashInput,
31702 pubKeyHashOutput: pubKeyHashOutput,
31703 pubKeyInput: pubKeyInput,
31704 pubKeyOutput: pubKeyOutput,
31705 scriptHashInput: scriptHashInput,
31706 scriptHashOutput: scriptHashOutput
31707 }
31708
31709 }).call(this,_dereq_("buffer").Buffer)
31710 },{"./ecsignature":77,"./opcodes":82,"./script":83,"assert":4,"buffer":8,"ecurve":65}],85:[function(_dereq_,module,exports){
31711 (function (Buffer){
31712 var assert = _dereq_('assert')
31713 var bufferutils = _dereq_('./bufferutils')
31714 var crypto = _dereq_('./crypto')
31715 var opcodes = _dereq_('./opcodes')
31716 var scripts = _dereq_('./scripts')
31717
31718 var Address = _dereq_('./address')
31719 var ECKey = _dereq_('./eckey')
31720 var ECSignature = _dereq_('./ecsignature')
31721 var Script = _dereq_('./script')
31722
31723 Transaction.DEFAULT_SEQUENCE = 0xffffffff
31724 Transaction.SIGHASH_ALL = 0x01
31725 Transaction.SIGHASH_NONE = 0x02
31726 Transaction.SIGHASH_SINGLE = 0x03
31727 Transaction.SIGHASH_ANYONECANPAY = 0x80
31728
31729 function Transaction() {
31730 this.version = 1
31731 this.locktime = 0
31732 this.ins = []
31733 this.outs = []
31734 }
31735
31736 /**
31737 * Create a new txin.
31738 *
31739 * Can be called with any of:
31740 *
31741 * - A transaction and an index
31742 * - A transaction hash and an index
31743 *
31744 * Note that this method does not sign the created input.
31745 */
31746 Transaction.prototype.addInput = function(tx, index, sequence) {
31747 if (sequence == undefined) sequence = Transaction.DEFAULT_SEQUENCE
31748
31749 var hash
31750
31751 if (typeof tx === 'string') {
31752 hash = new Buffer(tx, 'hex')
31753
31754 // TxId hex is big-endian, we need little-endian
31755 Array.prototype.reverse.call(hash)
31756
31757 } else if (tx instanceof Transaction) {
31758 hash = tx.getHash()
31759
31760 } else {
31761 hash = tx
31762 }
31763
31764 assert(Buffer.isBuffer(hash), 'Expected Transaction, txId or txHash, got ' + tx)
31765 assert.equal(hash.length, 32, 'Expected hash length of 32, got ' + hash.length)
31766 assert.equal(typeof index, 'number', 'Expected number index, got ' + index)
31767
31768 return (this.ins.push({
31769 hash: hash,
31770 index: index,
31771 script: Script.EMPTY,
31772 sequence: sequence
31773 }) - 1)
31774 }
31775
31776 /**
31777 * Create a new txout.
31778 *
31779 * Can be called with:
31780 *
31781 * - A base58 address string and a value
31782 * - An Address object and a value
31783 * - A scriptPubKey Script and a value
31784 */
31785 Transaction.prototype.addOutput = function(scriptPubKey, value) {
31786 // Attempt to get a valid address if it's a base58 address string
31787 if (typeof scriptPubKey === 'string') {
31788 scriptPubKey = Address.fromBase58Check(scriptPubKey)
31789 }
31790
31791 // Attempt to get a valid script if it's an Address object
31792 if (scriptPubKey instanceof Address) {
31793 var address = scriptPubKey
31794
31795 scriptPubKey = address.toOutputScript()
31796 }
31797
31798 return (this.outs.push({
31799 script: scriptPubKey,
31800 value: value,
31801 }) - 1)
31802 }
31803
31804 Transaction.prototype.toBuffer = function () {
31805 var txInSize = this.ins.reduce(function(a, x) {
31806 return a + (40 + bufferutils.varIntSize(x.script.buffer.length) + x.script.buffer.length)
31807 }, 0)
31808
31809 var txOutSize = this.outs.reduce(function(a, x) {
31810 return a + (8 + bufferutils.varIntSize(x.script.buffer.length) + x.script.buffer.length)
31811 }, 0)
31812
31813 var buffer = new Buffer(
31814 8 +
31815 bufferutils.varIntSize(this.ins.length) +
31816 bufferutils.varIntSize(this.outs.length) +
31817 txInSize +
31818 txOutSize
31819 )
31820
31821 var offset = 0
31822 function writeSlice(slice) {
31823 slice.copy(buffer, offset)
31824 offset += slice.length
31825 }
31826 function writeUInt32(i) {
31827 buffer.writeUInt32LE(i, offset)
31828 offset += 4
31829 }
31830 function writeUInt64(i) {
31831 bufferutils.writeUInt64LE(buffer, i, offset)
31832 offset += 8
31833 }
31834 function writeVarInt(i) {
31835 var n = bufferutils.writeVarInt(buffer, i, offset)
31836 offset += n
31837 }
31838
31839 writeUInt32(this.version)
31840 writeVarInt(this.ins.length)
31841
31842 this.ins.forEach(function(txin) {
31843 writeSlice(txin.hash)
31844 writeUInt32(txin.index)
31845 writeVarInt(txin.script.buffer.length)
31846 writeSlice(txin.script.buffer)
31847 writeUInt32(txin.sequence)
31848 })
31849
31850 writeVarInt(this.outs.length)
31851 this.outs.forEach(function(txout) {
31852 writeUInt64(txout.value)
31853 writeVarInt(txout.script.buffer.length)
31854 writeSlice(txout.script.buffer)
31855 })
31856
31857 writeUInt32(this.locktime)
31858
31859 return buffer
31860 }
31861
31862 Transaction.prototype.toHex = function() {
31863 return this.toBuffer().toString('hex')
31864 }
31865
31866 /**
31867 * Hash transaction for signing a specific input.
31868 *
31869 * Bitcoin uses a different hash for each signed transaction input. This
31870 * method copies the transaction, makes the necessary changes based on the
31871 * hashType, serializes and finally hashes the result. This hash can then be
31872 * used to sign the transaction input in question.
31873 */
31874 Transaction.prototype.hashForSignature = function(prevOutScript, inIndex, hashType) {
31875 assert(inIndex >= 0, 'Invalid vin index')
31876 assert(inIndex < this.ins.length, 'Invalid vin index')
31877 assert(prevOutScript instanceof Script, 'Invalid Script object')
31878
31879 var txTmp = this.clone()
31880 var hashScript = prevOutScript.without(opcodes.OP_CODESEPARATOR)
31881
31882 // Blank out other inputs' signatures
31883 txTmp.ins.forEach(function(txin) {
31884 txin.script = Script.EMPTY
31885 })
31886 txTmp.ins[inIndex].script = hashScript
31887
31888 var hashTypeModifier = hashType & 0x1f
31889 if (hashTypeModifier === Transaction.SIGHASH_NONE) {
31890 assert(false, 'SIGHASH_NONE not yet supported')
31891
31892 } else if (hashTypeModifier === Transaction.SIGHASH_SINGLE) {
31893 assert(false, 'SIGHASH_SINGLE not yet supported')
31894
31895 }
31896
31897 if (hashType & Transaction.SIGHASH_ANYONECANPAY) {
31898 assert(false, 'SIGHASH_ANYONECANPAY not yet supported')
31899 }
31900
31901 var hashTypeBuffer = new Buffer(4)
31902 hashTypeBuffer.writeInt32LE(hashType, 0)
31903
31904 var buffer = Buffer.concat([txTmp.toBuffer(), hashTypeBuffer])
31905 return crypto.hash256(buffer)
31906 }
31907
31908 Transaction.prototype.getHash = function () {
31909 return crypto.hash256(this.toBuffer())
31910 }
31911
31912 Transaction.prototype.getId = function () {
31913 var buffer = this.getHash()
31914
31915 // Big-endian is used for TxHash
31916 Array.prototype.reverse.call(buffer)
31917
31918 return buffer.toString('hex')
31919 }
31920
31921 Transaction.prototype.clone = function () {
31922 var newTx = new Transaction()
31923 newTx.version = this.version
31924 newTx.locktime = this.locktime
31925
31926 newTx.ins = this.ins.map(function(txin) {
31927 return {
31928 hash: txin.hash,
31929 index: txin.index,
31930 script: txin.script,
31931 sequence: txin.sequence
31932 }
31933 })
31934
31935 newTx.outs = this.outs.map(function(txout) {
31936 return {
31937 script: txout.script,
31938 value: txout.value
31939 }
31940 })
31941
31942 return newTx
31943 }
31944
31945 Transaction.fromBuffer = function(buffer) {
31946 var offset = 0
31947 function readSlice(n) {
31948 offset += n
31949 return buffer.slice(offset - n, offset)
31950 }
31951 function readUInt32() {
31952 var i = buffer.readUInt32LE(offset)
31953 offset += 4
31954 return i
31955 }
31956 function readUInt64() {
31957 var i = bufferutils.readUInt64LE(buffer, offset)
31958 offset += 8
31959 return i
31960 }
31961 function readVarInt() {
31962 var vi = bufferutils.readVarInt(buffer, offset)
31963 offset += vi.size
31964 return vi.number
31965 }
31966
31967 var tx = new Transaction()
31968 tx.version = readUInt32()
31969
31970 var vinLen = readVarInt()
31971 for (var i = 0; i < vinLen; ++i) {
31972 var hash = readSlice(32)
31973 var vout = readUInt32()
31974 var scriptLen = readVarInt()
31975 var script = readSlice(scriptLen)
31976 var sequence = readUInt32()
31977
31978 tx.ins.push({
31979 hash: hash,
31980 index: vout,
31981 script: Script.fromBuffer(script),
31982 sequence: sequence
31983 })
31984 }
31985
31986 var voutLen = readVarInt()
31987 for (i = 0; i < voutLen; ++i) {
31988 var value = readUInt64()
31989 var scriptLen = readVarInt()
31990 var script = readSlice(scriptLen)
31991
31992 tx.outs.push({
31993 value: value,
31994 script: Script.fromBuffer(script)
31995 })
31996 }
31997
31998 tx.locktime = readUInt32()
31999 assert.equal(offset, buffer.length, 'Transaction has unexpected data')
32000
32001 return tx
32002 }
32003
32004 Transaction.fromHex = function(hex) {
32005 return Transaction.fromBuffer(new Buffer(hex, 'hex'))
32006 }
32007
32008 /**
32009 * Signs a pubKeyHash output at some index with the given key
32010 */
32011 Transaction.prototype.sign = function(index, privKey, hashType) {
32012 var prevOutScript = privKey.pub.getAddress().toOutputScript()
32013 var signature = this.signInput(index, prevOutScript, privKey, hashType)
32014
32015 // FIXME: Assumed prior TX was pay-to-pubkey-hash
32016 var scriptSig = scripts.pubKeyHashInput(signature, privKey.pub)
32017 this.setInputScript(index, scriptSig)
32018 }
32019
32020 Transaction.prototype.signInput = function(index, prevOutScript, privKey, hashType) {
32021 hashType = hashType || Transaction.SIGHASH_ALL
32022
32023 var hash = this.hashForSignature(prevOutScript, index, hashType)
32024 var signature = privKey.sign(hash)
32025
32026 return signature.toScriptSignature(hashType)
32027 }
32028
32029 Transaction.prototype.setInputScript = function(index, script) {
32030 this.ins[index].script = script
32031 }
32032
32033 // FIXME: could be validateInput(index, prevTxOut, pub)
32034 Transaction.prototype.validateInput = function(index, prevOutScript, pubKey, buffer) {
32035 var parsed = ECSignature.parseScriptSignature(buffer)
32036 var hash = this.hashForSignature(prevOutScript, index, parsed.hashType)
32037
32038 return pubKey.verify(hash, parsed.signature)
32039 }
32040
32041 module.exports = Transaction
32042
32043 }).call(this,_dereq_("buffer").Buffer)
32044 },{"./address":69,"./bufferutils":71,"./crypto":73,"./eckey":75,"./ecsignature":77,"./opcodes":82,"./script":83,"./scripts":84,"assert":4,"buffer":8}],86:[function(_dereq_,module,exports){
32045 (function (Buffer){
32046 var assert = _dereq_('assert')
32047 var networks = _dereq_('./networks')
32048 var rng = _dereq_('secure-random')
32049
32050 var Address = _dereq_('./address')
32051 var HDNode = _dereq_('./hdnode')
32052 var Transaction = _dereq_('./transaction')
32053
32054 function Wallet(seed, network) {
32055 network = network || networks.bitcoin
32056
32057 // Stored in a closure to make accidental serialization less likely
32058 var masterkey = null
32059 var me = this
32060 var accountZero = null
32061 var internalAccount = null
32062 var externalAccount = null
32063
32064 // Addresses
32065 this.addresses = []
32066 this.changeAddresses = []
32067
32068 // Transaction output data
32069 this.outputs = {}
32070
32071 // Make a new master key
32072 this.newMasterKey = function(seed) {
32073 seed = seed || new Buffer(rng(32))
32074 masterkey = HDNode.fromSeedBuffer(seed, network)
32075
32076 // HD first-level child derivation method should be hardened
32077 // See https://bitcointalk.org/index.php?topic=405179.msg4415254#msg4415254
32078 accountZero = masterkey.deriveHardened(0)
32079 externalAccount = accountZero.derive(0)
32080 internalAccount = accountZero.derive(1)
32081
32082 me.addresses = []
32083 me.changeAddresses = []
32084
32085 me.outputs = {}
32086 }
32087
32088 this.newMasterKey(seed)
32089
32090 this.generateAddress = function() {
32091 var key = externalAccount.derive(this.addresses.length)
32092 this.addresses.push(key.getAddress().toString())
32093 return this.addresses[this.addresses.length - 1]
32094 }
32095
32096 this.generateChangeAddress = function() {
32097 var key = internalAccount.derive(this.changeAddresses.length)
32098 this.changeAddresses.push(key.getAddress().toString())
32099 return this.changeAddresses[this.changeAddresses.length - 1]
32100 }
32101
32102 this.getBalance = function() {
32103 return this.getUnspentOutputs().reduce(function(memo, output){
32104 return memo + output.value
32105 }, 0)
32106 }
32107
32108 this.getUnspentOutputs = function() {
32109 var utxo = []
32110
32111 for(var key in this.outputs){
32112 var output = this.outputs[key]
32113 if(!output.to) utxo.push(outputToUnspentOutput(output))
32114 }
32115
32116 return utxo
32117 }
32118
32119 this.setUnspentOutputs = function(utxo) {
32120 var outputs = {}
32121
32122 utxo.forEach(function(uo){
32123 validateUnspentOutput(uo)
32124 var o = unspentOutputToOutput(uo)
32125 outputs[o.from] = o
32126 })
32127
32128 this.outputs = outputs
32129 }
32130
32131 function outputToUnspentOutput(output){
32132 var hashAndIndex = output.from.split(":")
32133
32134 return {
32135 hash: hashAndIndex[0],
32136 outputIndex: parseInt(hashAndIndex[1]),
32137 address: output.address,
32138 value: output.value,
32139 pending: output.pending
32140 }
32141 }
32142
32143 function unspentOutputToOutput(o) {
32144 var hash = o.hash
32145 var key = hash + ":" + o.outputIndex
32146 return {
32147 from: key,
32148 address: o.address,
32149 value: o.value,
32150 pending: o.pending
32151 }
32152 }
32153
32154 function validateUnspentOutput(uo) {
32155 var missingField
32156
32157 if (isNullOrUndefined(uo.hash)) {
32158 missingField = "hash"
32159 }
32160
32161 var requiredKeys = ['outputIndex', 'address', 'value']
32162 requiredKeys.forEach(function (key) {
32163 if (isNullOrUndefined(uo[key])){
32164 missingField = key
32165 }
32166 })
32167
32168 if (missingField) {
32169 var message = [
32170 'Invalid unspent output: key', missingField, 'is missing.',
32171 'A valid unspent output must contain'
32172 ]
32173 message.push(requiredKeys.join(', '))
32174 message.push("and hash")
32175 throw new Error(message.join(' '))
32176 }
32177 }
32178
32179 function isNullOrUndefined(value) {
32180 return value == undefined
32181 }
32182
32183 this.processPendingTx = function(tx){
32184 processTx(tx, true)
32185 }
32186
32187 this.processConfirmedTx = function(tx){
32188 processTx(tx, false)
32189 }
32190
32191 function processTx(tx, isPending) {
32192 var txid = tx.getId()
32193
32194 tx.outs.forEach(function(txOut, i) {
32195 var address
32196
32197 try {
32198 address = Address.fromOutputScript(txOut.script, network).toString()
32199 } catch(e) {
32200 if (!(e.message.match(/has no matching Address/))) throw e
32201 }
32202
32203 if (isMyAddress(address)) {
32204 var output = txid + ':' + i
32205
32206 me.outputs[output] = {
32207 from: output,
32208 value: txOut.value,
32209 address: address,
32210 pending: isPending
32211 }
32212 }
32213 })
32214
32215 tx.ins.forEach(function(txIn, i) {
32216 // copy and convert to big-endian hex
32217 var txinId = new Buffer(txIn.hash)
32218 Array.prototype.reverse.call(txinId)
32219 txinId = txinId.toString('hex')
32220
32221 var output = txinId + ':' + txIn.index
32222
32223 if (!(output in me.outputs)) return
32224
32225 if (isPending) {
32226 me.outputs[output].to = txid + ':' + i
32227 me.outputs[output].pending = true
32228 } else {
32229 delete me.outputs[output]
32230 }
32231 })
32232 }
32233
32234 this.createTx = function(to, value, fixedFee, changeAddress) {
32235 assert(value > network.dustThreshold, value + ' must be above dust threshold (' + network.dustThreshold + ' Satoshis)')
32236
32237 var utxos = getCandidateOutputs(value)
32238 var accum = 0
32239 var subTotal = value
32240 var addresses = []
32241
32242 var tx = new Transaction()
32243 tx.addOutput(to, value)
32244
32245 for (var i = 0; i < utxos.length; ++i) {
32246 var utxo = utxos[i]
32247 addresses.push(utxo.address)
32248
32249 var outpoint = utxo.from.split(':')
32250 tx.addInput(outpoint[0], parseInt(outpoint[1]))
32251
32252 var fee = fixedFee == undefined ? estimateFeePadChangeOutput(tx) : fixedFee
32253
32254 accum += utxo.value
32255 subTotal = value + fee
32256 if (accum >= subTotal) {
32257 var change = accum - subTotal
32258
32259 if (change > network.dustThreshold) {
32260 tx.addOutput(changeAddress || getChangeAddress(), change)
32261 }
32262
32263 break
32264 }
32265 }
32266
32267 assert(accum >= subTotal, 'Not enough funds (incl. fee): ' + accum + ' < ' + subTotal)
32268
32269 this.signWith(tx, addresses)
32270 return tx
32271 }
32272
32273 function getCandidateOutputs() {
32274 var unspent = []
32275
32276 for (var key in me.outputs) {
32277 var output = me.outputs[key]
32278 if (!output.pending) unspent.push(output)
32279 }
32280
32281 var sortByValueDesc = unspent.sort(function(o1, o2){
32282 return o2.value - o1.value
32283 })
32284
32285 return sortByValueDesc
32286 }
32287
32288 function estimateFeePadChangeOutput(tx) {
32289 var tmpTx = tx.clone()
32290 tmpTx.addOutput(getChangeAddress(), network.dustSoftThreshold || 0)
32291
32292 return network.estimateFee(tmpTx)
32293 }
32294
32295 function getChangeAddress() {
32296 if(me.changeAddresses.length === 0) me.generateChangeAddress();
32297 return me.changeAddresses[me.changeAddresses.length - 1]
32298 }
32299
32300 this.signWith = function(tx, addresses) {
32301 assert.equal(tx.ins.length, addresses.length, 'Number of addresses must match number of transaction inputs')
32302
32303 addresses.forEach(function(address, i) {
32304 var key = me.getPrivateKeyForAddress(address)
32305
32306 tx.sign(i, key)
32307 })
32308
32309 return tx
32310 }
32311
32312 this.getMasterKey = function() { return masterkey }
32313 this.getAccountZero = function() { return accountZero }
32314 this.getInternalAccount = function() { return internalAccount }
32315 this.getExternalAccount = function() { return externalAccount }
32316
32317 this.getPrivateKey = function(index) {
32318 return externalAccount.derive(index).privKey
32319 }
32320
32321 this.getInternalPrivateKey = function(index) {
32322 return internalAccount.derive(index).privKey
32323 }
32324
32325 this.getPrivateKeyForAddress = function(address) {
32326 var index
32327 if((index = this.addresses.indexOf(address)) > -1) {
32328 return this.getPrivateKey(index)
32329 } else if((index = this.changeAddresses.indexOf(address)) > -1) {
32330 return this.getInternalPrivateKey(index)
32331 } else {
32332 throw new Error('Unknown address. Make sure the address is from the keychain and has been generated.')
32333 }
32334 }
32335
32336 function isReceiveAddress(address){
32337 return me.addresses.indexOf(address) > -1
32338 }
32339
32340 function isChangeAddress(address){
32341 return me.changeAddresses.indexOf(address) > -1
32342 }
32343
32344 function isMyAddress(address) {
32345 return isReceiveAddress(address) || isChangeAddress(address)
32346 }
32347 }
32348
32349 module.exports = Wallet
32350
32351 }).call(this,_dereq_("buffer").Buffer)
32352 },{"./address":69,"./hdnode":78,"./networks":81,"./transaction":85,"assert":4,"buffer":8,"secure-random":68}]},{},[79])
32353 (79)
32354 });
32355 </script>
32356 <script>
32357 // Select components from sjcl to suit the crypto operations bip39 requires.
32358
32359 //// base.js
32360
32361 /** @fileOverview Javascript cryptography implementation.
32362 *
32363 * Crush to remove comments, shorten variable names and
32364 * generally reduce transmission size.
32365 *
32366 * @author Emily Stark
32367 * @author Mike Hamburg
32368 * @author Dan Boneh
32369 */
32370
32371 "use strict";
32372 /*jslint indent: 2, bitwise: false, nomen: false, plusplus: false, white: false, regexp: false */
32373 /*global document, window, escape, unescape, module, require, Uint32Array */
32374
32375 /** @namespace The Stanford Javascript Crypto Library, top-level namespace. */
32376 var sjcl = {
32377 /** @namespace Symmetric ciphers. */
32378 cipher: {},
32379
32380 /** @namespace Hash functions. Right now only SHA256 is implemented. */
32381 hash: {},
32382
32383 /** @namespace Key exchange functions. Right now only SRP is implemented. */
32384 keyexchange: {},
32385
32386 /** @namespace Block cipher modes of operation. */
32387 mode: {},
32388
32389 /** @namespace Miscellaneous. HMAC and PBKDF2. */
32390 misc: {},
32391
32392 /**
32393 * @namespace Bit array encoders and decoders.
32394 *
32395 * @description
32396 * The members of this namespace are functions which translate between
32397 * SJCL's bitArrays and other objects (usually strings). Because it
32398 * isn't always clear which direction is encoding and which is decoding,
32399 * the method names are "fromBits" and "toBits".
32400 */
32401 codec: {},
32402
32403 /** @namespace Exceptions. */
32404 exception: {
32405 /** @constructor Ciphertext is corrupt. */
32406 corrupt: function(message) {
32407 this.toString = function() { return "CORRUPT: "+this.message; };
32408 this.message = message;
32409 },
32410
32411 /** @constructor Invalid parameter. */
32412 invalid: function(message) {
32413 this.toString = function() { return "INVALID: "+this.message; };
32414 this.message = message;
32415 },
32416
32417 /** @constructor Bug or missing feature in SJCL. @constructor */
32418 bug: function(message) {
32419 this.toString = function() { return "BUG: "+this.message; };
32420 this.message = message;
32421 },
32422
32423 /** @constructor Something isn't ready. */
32424 notReady: function(message) {
32425 this.toString = function() { return "NOT READY: "+this.message; };
32426 this.message = message;
32427 }
32428 }
32429 };
32430
32431 if(typeof module !== 'undefined' && module.exports){
32432 module.exports = sjcl;
32433 }
32434 if (typeof define === "function") {
32435 define([], function () {
32436 return sjcl;
32437 });
32438 }
32439
32440
32441 //// bitArray.js
32442
32443 /** @fileOverview Arrays of bits, encoded as arrays of Numbers.
32444 *
32445 * @author Emily Stark
32446 * @author Mike Hamburg
32447 * @author Dan Boneh
32448 */
32449
32450 /** @namespace Arrays of bits, encoded as arrays of Numbers.
32451 *
32452 * @description
32453 * <p>
32454 * These objects are the currency accepted by SJCL's crypto functions.
32455 * </p>
32456 *
32457 * <p>
32458 * Most of our crypto primitives operate on arrays of 4-byte words internally,
32459 * but many of them can take arguments that are not a multiple of 4 bytes.
32460 * This library encodes arrays of bits (whose size need not be a multiple of 8
32461 * bits) as arrays of 32-bit words. The bits are packed, big-endian, into an
32462 * array of words, 32 bits at a time. Since the words are double-precision
32463 * floating point numbers, they fit some extra data. We use this (in a private,
32464 * possibly-changing manner) to encode the number of bits actually present
32465 * in the last word of the array.
32466 * </p>
32467 *
32468 * <p>
32469 * Because bitwise ops clear this out-of-band data, these arrays can be passed
32470 * to ciphers like AES which want arrays of words.
32471 * </p>
32472 */
32473 sjcl.bitArray = {
32474 /**
32475 * Array slices in units of bits.
32476 * @param {bitArray} a The array to slice.
32477 * @param {Number} bstart The offset to the start of the slice, in bits.
32478 * @param {Number} bend The offset to the end of the slice, in bits. If this is undefined,
32479 * slice until the end of the array.
32480 * @return {bitArray} The requested slice.
32481 */
32482 bitSlice: function (a, bstart, bend) {
32483 a = sjcl.bitArray._shiftRight(a.slice(bstart/32), 32 - (bstart & 31)).slice(1);
32484 return (bend === undefined) ? a : sjcl.bitArray.clamp(a, bend-bstart);
32485 },
32486
32487 /**
32488 * Extract a number packed into a bit array.
32489 * @param {bitArray} a The array to slice.
32490 * @param {Number} bstart The offset to the start of the slice, in bits.
32491 * @param {Number} length The length of the number to extract.
32492 * @return {Number} The requested slice.
32493 */
32494 extract: function(a, bstart, blength) {
32495 // FIXME: this Math.floor is not necessary at all, but for some reason
32496 // seems to suppress a bug in the Chromium JIT.
32497 var x, sh = Math.floor((-bstart-blength) & 31);
32498 if ((bstart + blength - 1 ^ bstart) & -32) {
32499 // it crosses a boundary
32500 x = (a[bstart/32|0] << (32 - sh)) ^ (a[bstart/32+1|0] >>> sh);
32501 } else {
32502 // within a single word
32503 x = a[bstart/32|0] >>> sh;
32504 }
32505 return x & ((1<<blength) - 1);
32506 },
32507
32508 /**
32509 * Concatenate two bit arrays.
32510 * @param {bitArray} a1 The first array.
32511 * @param {bitArray} a2 The second array.
32512 * @return {bitArray} The concatenation of a1 and a2.
32513 */
32514 concat: function (a1, a2) {
32515 if (a1.length === 0 || a2.length === 0) {
32516 return a1.concat(a2);
32517 }
32518
32519 var last = a1[a1.length-1], shift = sjcl.bitArray.getPartial(last);
32520 if (shift === 32) {
32521 return a1.concat(a2);
32522 } else {
32523 return sjcl.bitArray._shiftRight(a2, shift, last|0, a1.slice(0,a1.length-1));
32524 }
32525 },
32526
32527 /**
32528 * Find the length of an array of bits.
32529 * @param {bitArray} a The array.
32530 * @return {Number} The length of a, in bits.
32531 */
32532 bitLength: function (a) {
32533 var l = a.length, x;
32534 if (l === 0) { return 0; }
32535 x = a[l - 1];
32536 return (l-1) * 32 + sjcl.bitArray.getPartial(x);
32537 },
32538
32539 /**
32540 * Truncate an array.
32541 * @param {bitArray} a The array.
32542 * @param {Number} len The length to truncate to, in bits.
32543 * @return {bitArray} A new array, truncated to len bits.
32544 */
32545 clamp: function (a, len) {
32546 if (a.length * 32 < len) { return a; }
32547 a = a.slice(0, Math.ceil(len / 32));
32548 var l = a.length;
32549 len = len & 31;
32550 if (l > 0 && len) {
32551 a[l-1] = sjcl.bitArray.partial(len, a[l-1] & 0x80000000 >> (len-1), 1);
32552 }
32553 return a;
32554 },
32555
32556 /**
32557 * Make a partial word for a bit array.
32558 * @param {Number} len The number of bits in the word.
32559 * @param {Number} x The bits.
32560 * @param {Number} [0] _end Pass 1 if x has already been shifted to the high side.
32561 * @return {Number} The partial word.
32562 */
32563 partial: function (len, x, _end) {
32564 if (len === 32) { return x; }
32565 return (_end ? x|0 : x << (32-len)) + len * 0x10000000000;
32566 },
32567
32568 /**
32569 * Get the number of bits used by a partial word.
32570 * @param {Number} x The partial word.
32571 * @return {Number} The number of bits used by the partial word.
32572 */
32573 getPartial: function (x) {
32574 return Math.round(x/0x10000000000) || 32;
32575 },
32576
32577 /**
32578 * Compare two arrays for equality in a predictable amount of time.
32579 * @param {bitArray} a The first array.
32580 * @param {bitArray} b The second array.
32581 * @return {boolean} true if a == b; false otherwise.
32582 */
32583 equal: function (a, b) {
32584 if (sjcl.bitArray.bitLength(a) !== sjcl.bitArray.bitLength(b)) {
32585 return false;
32586 }
32587 var x = 0, i;
32588 for (i=0; i<a.length; i++) {
32589 x |= a[i]^b[i];
32590 }
32591 return (x === 0);
32592 },
32593
32594 /** Shift an array right.
32595 * @param {bitArray} a The array to shift.
32596 * @param {Number} shift The number of bits to shift.
32597 * @param {Number} [carry=0] A byte to carry in
32598 * @param {bitArray} [out=[]] An array to prepend to the output.
32599 * @private
32600 */
32601 _shiftRight: function (a, shift, carry, out) {
32602 var i, last2=0, shift2;
32603 if (out === undefined) { out = []; }
32604
32605 for (; shift >= 32; shift -= 32) {
32606 out.push(carry);
32607 carry = 0;
32608 }
32609 if (shift === 0) {
32610 return out.concat(a);
32611 }
32612
32613 for (i=0; i<a.length; i++) {
32614 out.push(carry | a[i]>>>shift);
32615 carry = a[i] << (32-shift);
32616 }
32617 last2 = a.length ? a[a.length-1] : 0;
32618 shift2 = sjcl.bitArray.getPartial(last2);
32619 out.push(sjcl.bitArray.partial(shift+shift2 & 31, (shift + shift2 > 32) ? carry : out.pop(),1));
32620 return out;
32621 },
32622
32623 /** xor a block of 4 words together.
32624 * @private
32625 */
32626 _xor4: function(x,y) {
32627 return [x[0]^y[0],x[1]^y[1],x[2]^y[2],x[3]^y[3]];
32628 },
32629
32630 /** byteswap a word array inplace.
32631 * (does not handle partial words)
32632 * @param {sjcl.bitArray} a word array
32633 * @return {sjcl.bitArray} byteswapped array
32634 */
32635 byteswapM: function(a) {
32636 var i, v, m = 0xff00;
32637 for (i = 0; i < a.length; ++i) {
32638 v = a[i];
32639 a[i] = (v >>> 24) | ((v >>> 8) & m) | ((v & m) << 8) | (v << 24);
32640 }
32641 return a;
32642 }
32643 };
32644
32645
32646 //// codecString.js
32647
32648 /** @fileOverview Bit array codec implementations.
32649 *
32650 * @author Emily Stark
32651 * @author Mike Hamburg
32652 * @author Dan Boneh
32653 */
32654
32655 /** @namespace UTF-8 strings */
32656 sjcl.codec.utf8String = {
32657 /** Convert from a bitArray to a UTF-8 string. */
32658 fromBits: function (arr) {
32659 var out = "", bl = sjcl.bitArray.bitLength(arr), i, tmp;
32660 for (i=0; i<bl/8; i++) {
32661 if ((i&3) === 0) {
32662 tmp = arr[i/4];
32663 }
32664 out += String.fromCharCode(tmp >>> 24);
32665 tmp <<= 8;
32666 }
32667 return decodeURIComponent(escape(out));
32668 },
32669
32670 /** Convert from a UTF-8 string to a bitArray. */
32671 toBits: function (str) {
32672 str = unescape(encodeURIComponent(str));
32673 var out = [], i, tmp=0;
32674 for (i=0; i<str.length; i++) {
32675 tmp = tmp << 8 | str.charCodeAt(i);
32676 if ((i&3) === 3) {
32677 out.push(tmp);
32678 tmp = 0;
32679 }
32680 }
32681 if (i&3) {
32682 out.push(sjcl.bitArray.partial(8*(i&3), tmp));
32683 }
32684 return out;
32685 }
32686 };
32687
32688
32689 //// codecHex.js
32690
32691 /** @fileOverview Bit array codec implementations.
32692 *
32693 * @author Emily Stark
32694 * @author Mike Hamburg
32695 * @author Dan Boneh
32696 */
32697
32698 /** @namespace Hexadecimal */
32699 sjcl.codec.hex = {
32700 /** Convert from a bitArray to a hex string. */
32701 fromBits: function (arr) {
32702 var out = "", i;
32703 for (i=0; i<arr.length; i++) {
32704 out += ((arr[i]|0)+0xF00000000000).toString(16).substr(4);
32705 }
32706 return out.substr(0, sjcl.bitArray.bitLength(arr)/4);//.replace(/(.{8})/g, "$1 ");
32707 },
32708 /** Convert from a hex string to a bitArray. */
32709 toBits: function (str) {
32710 var i, out=[], len;
32711 str = str.replace(/\s|0x/g, "");
32712 len = str.length;
32713 str = str + "00000000";
32714 for (i=0; i<str.length; i+=8) {
32715 out.push(parseInt(str.substr(i,8),16)^0);
32716 }
32717 return sjcl.bitArray.clamp(out, len*4);
32718 }
32719 };
32720
32721
32722 //// sha512.js
32723
32724 /** @fileOverview Javascript SHA-512 implementation.
32725 *
32726 * This implementation was written for CryptoJS by Jeff Mott and adapted for
32727 * SJCL by Stefan Thomas.
32728 *
32729 * CryptoJS (c) 2009–2012 by Jeff Mott. All rights reserved.
32730 * Released with New BSD License
32731 *
32732 * @author Emily Stark
32733 * @author Mike Hamburg
32734 * @author Dan Boneh
32735 * @author Jeff Mott
32736 * @author Stefan Thomas
32737 */
32738
32739 /**
32740 * Context for a SHA-512 operation in progress.
32741 * @constructor
32742 * @class Secure Hash Algorithm, 512 bits.
32743 */
32744 sjcl.hash.sha512 = function (hash) {
32745 if (!this._key[0]) { this._precompute(); }
32746 if (hash) {
32747 this._h = hash._h.slice(0);
32748 this._buffer = hash._buffer.slice(0);
32749 this._length = hash._length;
32750 } else {
32751 this.reset();
32752 }
32753 };
32754
32755 /**
32756 * Hash a string or an array of words.
32757 * @static
32758 * @param {bitArray|String} data the data to hash.
32759 * @return {bitArray} The hash value, an array of 16 big-endian words.
32760 */
32761 sjcl.hash.sha512.hash = function (data) {
32762 return (new sjcl.hash.sha512()).update(data).finalize();
32763 };
32764
32765 sjcl.hash.sha512.prototype = {
32766 /**
32767 * The hash's block size, in bits.
32768 * @constant
32769 */
32770 blockSize: 1024,
32771
32772 /**
32773 * Reset the hash state.
32774 * @return this
32775 */
32776 reset:function () {
32777 this._h = this._init.slice(0);
32778 this._buffer = [];
32779 this._length = 0;
32780 return this;
32781 },
32782
32783 /**
32784 * Input several words to the hash.
32785 * @param {bitArray|String} data the data to hash.
32786 * @return this
32787 */
32788 update: function (data) {
32789 if (typeof data === "string") {
32790 data = sjcl.codec.utf8String.toBits(data);
32791 }
32792 var i, b = this._buffer = sjcl.bitArray.concat(this._buffer, data),
32793 ol = this._length,
32794 nl = this._length = ol + sjcl.bitArray.bitLength(data);
32795 for (i = 1024+ol & -1024; i <= nl; i+= 1024) {
32796 this._block(b.splice(0,32));
32797 }
32798 return this;
32799 },
32800
32801 /**
32802 * Complete hashing and output the hash value.
32803 * @return {bitArray} The hash value, an array of 16 big-endian words.
32804 */
32805 finalize:function () {
32806 var i, b = this._buffer, h = this._h;
32807
32808 // Round out and push the buffer
32809 b = sjcl.bitArray.concat(b, [sjcl.bitArray.partial(1,1)]);
32810
32811 // Round out the buffer to a multiple of 32 words, less the 4 length words.
32812 for (i = b.length + 4; i & 31; i++) {
32813 b.push(0);
32814 }
32815
32816 // append the length
32817 b.push(0);
32818 b.push(0);
32819 b.push(Math.floor(this._length / 0x100000000));
32820 b.push(this._length | 0);
32821
32822 while (b.length) {
32823 this._block(b.splice(0,32));
32824 }
32825
32826 this.reset();
32827 return h;
32828 },
32829
32830 /**
32831 * The SHA-512 initialization vector, to be precomputed.
32832 * @private
32833 */
32834 _init:[],
32835
32836 /**
32837 * Least significant 24 bits of SHA512 initialization values.
32838 *
32839 * Javascript only has 53 bits of precision, so we compute the 40 most
32840 * significant bits and add the remaining 24 bits as constants.
32841 *
32842 * @private
32843 */
32844 _initr: [ 0xbcc908, 0xcaa73b, 0x94f82b, 0x1d36f1, 0xe682d1, 0x3e6c1f, 0x41bd6b, 0x7e2179 ],
32845
32846 /*
32847 _init:
32848 [0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1,
32849 0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179],
32850 */
32851
32852 /**
32853 * The SHA-512 hash key, to be precomputed.
32854 * @private
32855 */
32856 _key:[],
32857
32858 /**
32859 * Least significant 24 bits of SHA512 key values.
32860 * @private
32861 */
32862 _keyr:
32863 [0x28ae22, 0xef65cd, 0x4d3b2f, 0x89dbbc, 0x48b538, 0x05d019, 0x194f9b, 0x6d8118,
32864 0x030242, 0x706fbe, 0xe4b28c, 0xffb4e2, 0x7b896f, 0x1696b1, 0xc71235, 0x692694,
32865 0xf14ad2, 0x4f25e3, 0x8cd5b5, 0xac9c65, 0x2b0275, 0xa6e483, 0x41fbd4, 0x1153b5,
32866 0x66dfab, 0xb43210, 0xfb213f, 0xef0ee4, 0xa88fc2, 0x0aa725, 0x03826f, 0x0e6e70,
32867 0xd22ffc, 0x26c926, 0xc42aed, 0x95b3df, 0xaf63de, 0x77b2a8, 0xedaee6, 0x82353b,
32868 0xf10364, 0x423001, 0xf89791, 0x54be30, 0xef5218, 0x65a910, 0x71202a, 0xbbd1b8,
32869 0xd2d0c8, 0x41ab53, 0x8eeb99, 0x9b48a8, 0xc95a63, 0x418acb, 0x63e373, 0xb2b8a3,
32870 0xefb2fc, 0x172f60, 0xf0ab72, 0x6439ec, 0x631e28, 0x82bde9, 0xc67915, 0x72532b,
32871 0x26619c, 0xc0c207, 0xe0eb1e, 0x6ed178, 0x176fba, 0xc898a6, 0xf90dae, 0x1c471b,
32872 0x047d84, 0xc72493, 0xc9bebc, 0x100d4c, 0x3e42b6, 0x657e2a, 0xd6faec, 0x475817],
32873
32874 /*
32875 _key:
32876 [0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
32877 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
32878 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
32879 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
32880 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
32881 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
32882 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
32883 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
32884 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
32885 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
32886 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
32887 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
32888 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
32889 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
32890 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
32891 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
32892 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
32893 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
32894 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
32895 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817],
32896 */
32897
32898 /**
32899 * Function to precompute _init and _key.
32900 * @private
32901 */
32902 _precompute: function () {
32903 // XXX: This code is for precomputing the SHA256 constants, change for
32904 // SHA512 and re-enable.
32905 var i = 0, prime = 2, factor;
32906
32907 function frac(x) { return (x-Math.floor(x)) * 0x100000000 | 0; }
32908 function frac2(x) { return (x-Math.floor(x)) * 0x10000000000 & 0xff; }
32909
32910 outer: for (; i<80; prime++) {
32911 for (factor=2; factor*factor <= prime; factor++) {
32912 if (prime % factor === 0) {
32913 // not a prime
32914 continue outer;
32915 }
32916 }
32917
32918 if (i<8) {
32919 this._init[i*2] = frac(Math.pow(prime, 1/2));
32920 this._init[i*2+1] = (frac2(Math.pow(prime, 1/2)) << 24) | this._initr[i];
32921 }
32922 this._key[i*2] = frac(Math.pow(prime, 1/3));
32923 this._key[i*2+1] = (frac2(Math.pow(prime, 1/3)) << 24) | this._keyr[i];
32924 i++;
32925 }
32926 },
32927
32928 /**
32929 * Perform one cycle of SHA-512.
32930 * @param {bitArray} words one block of words.
32931 * @private
32932 */
32933 _block:function (words) {
32934 var i, wrh, wrl,
32935 w = words.slice(0),
32936 h = this._h,
32937 k = this._key,
32938 h0h = h[ 0], h0l = h[ 1], h1h = h[ 2], h1l = h[ 3],
32939 h2h = h[ 4], h2l = h[ 5], h3h = h[ 6], h3l = h[ 7],
32940 h4h = h[ 8], h4l = h[ 9], h5h = h[10], h5l = h[11],
32941 h6h = h[12], h6l = h[13], h7h = h[14], h7l = h[15];
32942
32943 // Working variables
32944 var ah = h0h, al = h0l, bh = h1h, bl = h1l,
32945 ch = h2h, cl = h2l, dh = h3h, dl = h3l,
32946 eh = h4h, el = h4l, fh = h5h, fl = h5l,
32947 gh = h6h, gl = h6l, hh = h7h, hl = h7l;
32948
32949 for (i=0; i<80; i++) {
32950 // load up the input word for this round
32951 if (i<16) {
32952 wrh = w[i * 2];
32953 wrl = w[i * 2 + 1];
32954 } else {
32955 // Gamma0
32956 var gamma0xh = w[(i-15) * 2];
32957 var gamma0xl = w[(i-15) * 2 + 1];
32958 var gamma0h =
32959 ((gamma0xl << 31) | (gamma0xh >>> 1)) ^
32960 ((gamma0xl << 24) | (gamma0xh >>> 8)) ^
32961 (gamma0xh >>> 7);
32962 var gamma0l =
32963 ((gamma0xh << 31) | (gamma0xl >>> 1)) ^
32964 ((gamma0xh << 24) | (gamma0xl >>> 8)) ^
32965 ((gamma0xh << 25) | (gamma0xl >>> 7));
32966
32967 // Gamma1
32968 var gamma1xh = w[(i-2) * 2];
32969 var gamma1xl = w[(i-2) * 2 + 1];
32970 var gamma1h =
32971 ((gamma1xl << 13) | (gamma1xh >>> 19)) ^
32972 ((gamma1xh << 3) | (gamma1xl >>> 29)) ^
32973 (gamma1xh >>> 6);
32974 var gamma1l =
32975 ((gamma1xh << 13) | (gamma1xl >>> 19)) ^
32976 ((gamma1xl << 3) | (gamma1xh >>> 29)) ^
32977 ((gamma1xh << 26) | (gamma1xl >>> 6));
32978
32979 // Shortcuts
32980 var wr7h = w[(i-7) * 2];
32981 var wr7l = w[(i-7) * 2 + 1];
32982
32983 var wr16h = w[(i-16) * 2];
32984 var wr16l = w[(i-16) * 2 + 1];
32985
32986 // W(round) = gamma0 + W(round - 7) + gamma1 + W(round - 16)
32987 wrl = gamma0l + wr7l;
32988 wrh = gamma0h + wr7h + ((wrl >>> 0) < (gamma0l >>> 0) ? 1 : 0);
32989 wrl += gamma1l;
32990 wrh += gamma1h + ((wrl >>> 0) < (gamma1l >>> 0) ? 1 : 0);
32991 wrl += wr16l;
32992 wrh += wr16h + ((wrl >>> 0) < (wr16l >>> 0) ? 1 : 0);
32993 }
32994
32995 w[i*2] = wrh |= 0;
32996 w[i*2 + 1] = wrl |= 0;
32997
32998 // Ch
32999 var chh = (eh & fh) ^ (~eh & gh);
33000 var chl = (el & fl) ^ (~el & gl);
33001
33002 // Maj
33003 var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
33004 var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
33005
33006 // Sigma0
33007 var sigma0h = ((al << 4) | (ah >>> 28)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
33008 var sigma0l = ((ah << 4) | (al >>> 28)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
33009
33010 // Sigma1
33011 var sigma1h = ((el << 18) | (eh >>> 14)) ^ ((el << 14) | (eh >>> 18)) ^ ((eh << 23) | (el >>> 9));
33012 var sigma1l = ((eh << 18) | (el >>> 14)) ^ ((eh << 14) | (el >>> 18)) ^ ((el << 23) | (eh >>> 9));
33013
33014 // K(round)
33015 var krh = k[i*2];
33016 var krl = k[i*2+1];
33017
33018 // t1 = h + sigma1 + ch + K(round) + W(round)
33019 var t1l = hl + sigma1l;
33020 var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
33021 t1l += chl;
33022 t1h += chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
33023 t1l += krl;
33024 t1h += krh + ((t1l >>> 0) < (krl >>> 0) ? 1 : 0);
33025 t1l = t1l + wrl|0; // FF32..FF34 perf issue https://bugzilla.mozilla.org/show_bug.cgi?id=1054972
33026 t1h += wrh + ((t1l >>> 0) < (wrl >>> 0) ? 1 : 0);
33027
33028 // t2 = sigma0 + maj
33029 var t2l = sigma0l + majl;
33030 var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
33031
33032 // Update working variables
33033 hh = gh;
33034 hl = gl;
33035 gh = fh;
33036 gl = fl;
33037 fh = eh;
33038 fl = el;
33039 el = (dl + t1l) | 0;
33040 eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
33041 dh = ch;
33042 dl = cl;
33043 ch = bh;
33044 cl = bl;
33045 bh = ah;
33046 bl = al;
33047 al = (t1l + t2l) | 0;
33048 ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
33049 }
33050
33051 // Intermediate hash
33052 h0l = h[1] = (h0l + al) | 0;
33053 h[0] = (h0h + ah + ((h0l >>> 0) < (al >>> 0) ? 1 : 0)) | 0;
33054 h1l = h[3] = (h1l + bl) | 0;
33055 h[2] = (h1h + bh + ((h1l >>> 0) < (bl >>> 0) ? 1 : 0)) | 0;
33056 h2l = h[5] = (h2l + cl) | 0;
33057 h[4] = (h2h + ch + ((h2l >>> 0) < (cl >>> 0) ? 1 : 0)) | 0;
33058 h3l = h[7] = (h3l + dl) | 0;
33059 h[6] = (h3h + dh + ((h3l >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
33060 h4l = h[9] = (h4l + el) | 0;
33061 h[8] = (h4h + eh + ((h4l >>> 0) < (el >>> 0) ? 1 : 0)) | 0;
33062 h5l = h[11] = (h5l + fl) | 0;
33063 h[10] = (h5h + fh + ((h5l >>> 0) < (fl >>> 0) ? 1 : 0)) | 0;
33064 h6l = h[13] = (h6l + gl) | 0;
33065 h[12] = (h6h + gh + ((h6l >>> 0) < (gl >>> 0) ? 1 : 0)) | 0;
33066 h7l = h[15] = (h7l + hl) | 0;
33067 h[14] = (h7h + hh + ((h7l >>> 0) < (hl >>> 0) ? 1 : 0)) | 0;
33068 }
33069 };
33070
33071
33072 //// hmac.js
33073
33074 /** @fileOverview HMAC implementation.
33075 *
33076 * @author Emily Stark
33077 * @author Mike Hamburg
33078 * @author Dan Boneh
33079 */
33080
33081 /** HMAC with the specified hash function.
33082 * @constructor
33083 * @param {bitArray} key the key for HMAC.
33084 * @param {Object} [hash=sjcl.hash.sha256] The hash function to use.
33085 */
33086 sjcl.misc.hmac = function (key, Hash) {
33087 this._hash = Hash = Hash || sjcl.hash.sha256;
33088 var exKey = [[],[]], i,
33089 bs = Hash.prototype.blockSize / 32;
33090 this._baseHash = [new Hash(), new Hash()];
33091
33092 if (key.length > bs) {
33093 key = Hash.hash(key);
33094 }
33095
33096 for (i=0; i<bs; i++) {
33097 exKey[0][i] = key[i]^0x36363636;
33098 exKey[1][i] = key[i]^0x5C5C5C5C;
33099 }
33100
33101 this._baseHash[0].update(exKey[0]);
33102 this._baseHash[1].update(exKey[1]);
33103 this._resultHash = new Hash(this._baseHash[0]);
33104 };
33105
33106 /** HMAC with the specified hash function. Also called encrypt since it's a prf.
33107 * @param {bitArray|String} data The data to mac.
33108 */
33109 sjcl.misc.hmac.prototype.encrypt = sjcl.misc.hmac.prototype.mac = function (data) {
33110 if (!this._updated) {
33111 this.update(data);
33112 return this.digest(data);
33113 } else {
33114 throw new sjcl.exception.invalid("encrypt on already updated hmac called!");
33115 }
33116 };
33117
33118 sjcl.misc.hmac.prototype.reset = function () {
33119 this._resultHash = new this._hash(this._baseHash[0]);
33120 this._updated = false;
33121 };
33122
33123 sjcl.misc.hmac.prototype.update = function (data) {
33124 this._updated = true;
33125 this._resultHash.update(data);
33126 };
33127
33128 sjcl.misc.hmac.prototype.digest = function () {
33129 var w = this._resultHash.finalize(), result = new (this._hash)(this._baseHash[1]).update(w).finalize();
33130
33131 this.reset();
33132
33133 return result;
33134 };
33135
33136
33137 //// pbkdf2.js
33138
33139
33140 /** @fileOverview Password-based key-derivation function, version 2.0.
33141 *
33142 * @author Emily Stark
33143 * @author Mike Hamburg
33144 * @author Dan Boneh
33145 */
33146
33147 /** Password-Based Key-Derivation Function, version 2.0.
33148 *
33149 * Generate keys from passwords using PBKDF2-HMAC-SHA256.
33150 *
33151 * This is the method specified by RSA's PKCS #5 standard.
33152 *
33153 * @param {bitArray|String} password The password.
33154 * @param {bitArray|String} salt The salt. Should have lots of entropy.
33155 * @param {Number} [count=1000] The number of iterations. Higher numbers make the function slower but more secure.
33156 * @param {Number} [length] The length of the derived key. Defaults to the
33157 output size of the hash function.
33158 * @param {Object} [Prff=sjcl.misc.hmac] The pseudorandom function family.
33159 * @return {bitArray} the derived key.
33160 */
33161 sjcl.misc.pbkdf2 = function (password, salt, count, length, Prff) {
33162 count = count || 1000;
33163
33164 if (length < 0 || count < 0) {
33165 throw sjcl.exception.invalid("invalid params to pbkdf2");
33166 }
33167
33168 if (typeof password === "string") {
33169 password = sjcl.codec.utf8String.toBits(password);
33170 }
33171
33172 if (typeof salt === "string") {
33173 salt = sjcl.codec.utf8String.toBits(salt);
33174 }
33175
33176 Prff = Prff || sjcl.misc.hmac;
33177
33178 var prf = new Prff(password),
33179 u, ui, i, j, k, out = [], b = sjcl.bitArray;
33180
33181 for (k = 1; 32 * out.length < (length || 1); k++) {
33182 u = ui = prf.encrypt(b.concat(salt,[k]));
33183
33184 for (i=1; i<count; i++) {
33185 ui = prf.encrypt(ui);
33186 for (j=0; j<ui.length; j++) {
33187 u[j] ^= ui[j];
33188 }
33189 }
33190
33191 out = out.concat(u);
33192 }
33193
33194 if (length) { out = b.clamp(out, length); }
33195
33196 return out;
33197 };
33198
33199
33200 //// sha256.js
33201
33202 /** @fileOverview Javascript SHA-256 implementation.
33203 *
33204 * An older version of this implementation is available in the public
33205 * domain, but this one is (c) Emily Stark, Mike Hamburg, Dan Boneh,
33206 * Stanford University 2008-2010 and BSD-licensed for liability
33207 * reasons.
33208 *
33209 * Special thanks to Aldo Cortesi for pointing out several bugs in
33210 * this code.
33211 *
33212 * @author Emily Stark
33213 * @author Mike Hamburg
33214 * @author Dan Boneh
33215 */
33216
33217 /**
33218 * Context for a SHA-256 operation in progress.
33219 * @constructor
33220 * @class Secure Hash Algorithm, 256 bits.
33221 */
33222 sjcl.hash.sha256 = function (hash) {
33223 if (!this._key[0]) { this._precompute(); }
33224 if (hash) {
33225 this._h = hash._h.slice(0);
33226 this._buffer = hash._buffer.slice(0);
33227 this._length = hash._length;
33228 } else {
33229 this.reset();
33230 }
33231 };
33232
33233 /**
33234 * Hash a string or an array of words.
33235 * @static
33236 * @param {bitArray|String} data the data to hash.
33237 * @return {bitArray} The hash value, an array of 16 big-endian words.
33238 */
33239 sjcl.hash.sha256.hash = function (data) {
33240 return (new sjcl.hash.sha256()).update(data).finalize();
33241 };
33242
33243 sjcl.hash.sha256.prototype = {
33244 /**
33245 * The hash's block size, in bits.
33246 * @constant
33247 */
33248 blockSize: 512,
33249
33250 /**
33251 * Reset the hash state.
33252 * @return this
33253 */
33254 reset:function () {
33255 this._h = this._init.slice(0);
33256 this._buffer = [];
33257 this._length = 0;
33258 return this;
33259 },
33260
33261 /**
33262 * Input several words to the hash.
33263 * @param {bitArray|String} data the data to hash.
33264 * @return this
33265 */
33266 update: function (data) {
33267 if (typeof data === "string") {
33268 data = sjcl.codec.utf8String.toBits(data);
33269 }
33270 var i, b = this._buffer = sjcl.bitArray.concat(this._buffer, data),
33271 ol = this._length,
33272 nl = this._length = ol + sjcl.bitArray.bitLength(data);
33273 for (i = 512+ol & -512; i <= nl; i+= 512) {
33274 this._block(b.splice(0,16));
33275 }
33276 return this;
33277 },
33278
33279 /**
33280 * Complete hashing and output the hash value.
33281 * @return {bitArray} The hash value, an array of 8 big-endian words.
33282 */
33283 finalize:function () {
33284 var i, b = this._buffer, h = this._h;
33285
33286 // Round out and push the buffer
33287 b = sjcl.bitArray.concat(b, [sjcl.bitArray.partial(1,1)]);
33288
33289 // Round out the buffer to a multiple of 16 words, less the 2 length words.
33290 for (i = b.length + 2; i & 15; i++) {
33291 b.push(0);
33292 }
33293
33294 // append the length
33295 b.push(Math.floor(this._length / 0x100000000));
33296 b.push(this._length | 0);
33297
33298 while (b.length) {
33299 this._block(b.splice(0,16));
33300 }
33301
33302 this.reset();
33303 return h;
33304 },
33305
33306 /**
33307 * The SHA-256 initialization vector, to be precomputed.
33308 * @private
33309 */
33310 _init:[],
33311 /*
33312 _init:[0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19],
33313 */
33314
33315 /**
33316 * The SHA-256 hash key, to be precomputed.
33317 * @private
33318 */
33319 _key:[],
33320 /*
33321 _key:
33322 [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
33323 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
33324 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
33325 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
33326 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
33327 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
33328 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
33329 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2],
33330 */
33331
33332
33333 /**
33334 * Function to precompute _init and _key.
33335 * @private
33336 */
33337 _precompute: function () {
33338 var i = 0, prime = 2, factor;
33339
33340 function frac(x) { return (x-Math.floor(x)) * 0x100000000 | 0; }
33341
33342 outer: for (; i<64; prime++) {
33343 for (factor=2; factor*factor <= prime; factor++) {
33344 if (prime % factor === 0) {
33345 // not a prime
33346 continue outer;
33347 }
33348 }
33349
33350 if (i<8) {
33351 this._init[i] = frac(Math.pow(prime, 1/2));
33352 }
33353 this._key[i] = frac(Math.pow(prime, 1/3));
33354 i++;
33355 }
33356 },
33357
33358 /**
33359 * Perform one cycle of SHA-256.
33360 * @param {bitArray} words one block of words.
33361 * @private
33362 */
33363 _block:function (words) {
33364 var i, tmp, a, b,
33365 w = words.slice(0),
33366 h = this._h,
33367 k = this._key,
33368 h0 = h[0], h1 = h[1], h2 = h[2], h3 = h[3],
33369 h4 = h[4], h5 = h[5], h6 = h[6], h7 = h[7];
33370
33371 /* Rationale for placement of |0 :
33372 * If a value can overflow is original 32 bits by a factor of more than a few
33373 * million (2^23 ish), there is a possibility that it might overflow the
33374 * 53-bit mantissa and lose precision.
33375 *
33376 * To avoid this, we clamp back to 32 bits by |'ing with 0 on any value that
33377 * propagates around the loop, and on the hash state h[]. I don't believe
33378 * that the clamps on h4 and on h0 are strictly necessary, but it's close
33379 * (for h4 anyway), and better safe than sorry.
33380 *
33381 * The clamps on h[] are necessary for the output to be correct even in the
33382 * common case and for short inputs.
33383 */
33384 for (i=0; i<64; i++) {
33385 // load up the input word for this round
33386 if (i<16) {
33387 tmp = w[i];
33388 } else {
33389 a = w[(i+1 ) & 15];
33390 b = w[(i+14) & 15];
33391 tmp = w[i&15] = ((a>>>7 ^ a>>>18 ^ a>>>3 ^ a<<25 ^ a<<14) +
33392 (b>>>17 ^ b>>>19 ^ b>>>10 ^ b<<15 ^ b<<13) +
33393 w[i&15] + w[(i+9) & 15]) | 0;
33394 }
33395
33396 tmp = (tmp + h7 + (h4>>>6 ^ h4>>>11 ^ h4>>>25 ^ h4<<26 ^ h4<<21 ^ h4<<7) + (h6 ^ h4&(h5^h6)) + k[i]); // | 0;
33397
33398 // shift register
33399 h7 = h6; h6 = h5; h5 = h4;
33400 h4 = h3 + tmp | 0;
33401 h3 = h2; h2 = h1; h1 = h0;
33402
33403 h0 = (tmp + ((h1&h2) ^ (h3&(h1^h2))) + (h1>>>2 ^ h1>>>13 ^ h1>>>22 ^ h1<<30 ^ h1<<19 ^ h1<<10)) | 0;
33404 }
33405
33406 h[0] = h[0]+h0 | 0;
33407 h[1] = h[1]+h1 | 0;
33408 h[2] = h[2]+h2 | 0;
33409 h[3] = h[3]+h3 | 0;
33410 h[4] = h[4]+h4 | 0;
33411 h[5] = h[5]+h5 | 0;
33412 h[6] = h[6]+h6 | 0;
33413 h[7] = h[7]+h7 | 0;
33414 }
33415 };
33416 </script>
33417 <script>
33418 WORDLISTS = {};
33419 </script>
33420 <script>
33421 WORDLISTS["english"] = [
33422 "abandon","ability","able","about","above","absent","absorb","abstract","absurd","abuse",
33423 "access","accident","account","accuse","achieve","acid","acoustic","acquire","across","act",
33424 "action","actor","actress","actual","adapt","add","addict","address","adjust","admit",
33425 "adult","advance","advice","aerobic","affair","afford","afraid","again","age","agent",
33426 "agree","ahead","aim","air","airport","aisle","alarm","album","alcohol","alert",
33427 "alien","all","alley","allow","almost","alone","alpha","already","also","alter",
33428 "always","amateur","amazing","among","amount","amused","analyst","anchor","ancient","anger",
33429 "angle","angry","animal","ankle","announce","annual","another","answer","antenna","antique",
33430 "anxiety","any","apart","apology","appear","apple","approve","april","arch","arctic",
33431 "area","arena","argue","arm","armed","armor","army","around","arrange","arrest",
33432 "arrive","arrow","art","artefact","artist","artwork","ask","aspect","assault","asset",
33433 "assist","assume","asthma","athlete","atom","attack","attend","attitude","attract","auction",
33434 "audit","august","aunt","author","auto","autumn","average","avocado","avoid","awake",
33435 "aware","away","awesome","awful","awkward","axis","baby","bachelor","bacon","badge",
33436 "bag","balance","balcony","ball","bamboo","banana","banner","bar","barely","bargain",
33437 "barrel","base","basic","basket","battle","beach","bean","beauty","because","become",
33438 "beef","before","begin","behave","behind","believe","below","belt","bench","benefit",
33439 "best","betray","better","between","beyond","bicycle","bid","bike","bind","biology",
33440 "bird","birth","bitter","black","blade","blame","blanket","blast","bleak","bless",
33441 "blind","blood","blossom","blouse","blue","blur","blush","board","boat","body",
33442 "boil","bomb","bone","bonus","book","boost","border","boring","borrow","boss",
33443 "bottom","bounce","box","boy","bracket","brain","brand","brass","brave","bread",
33444 "breeze","brick","bridge","brief","bright","bring","brisk","broccoli","broken","bronze",
33445 "broom","brother","brown","brush","bubble","buddy","budget","buffalo","build","bulb",
33446 "bulk","bullet","bundle","bunker","burden","burger","burst","bus","business","busy",
33447 "butter","buyer","buzz","cabbage","cabin","cable","cactus","cage","cake","call",
33448 "calm","camera","camp","can","canal","cancel","candy","cannon","canoe","canvas",
33449 "canyon","capable","capital","captain","car","carbon","card","cargo","carpet","carry",
33450 "cart","case","cash","casino","castle","casual","cat","catalog","catch","category",
33451 "cattle","caught","cause","caution","cave","ceiling","celery","cement","census","century",
33452 "cereal","certain","chair","chalk","champion","change","chaos","chapter","charge","chase",
33453 "chat","cheap","check","cheese","chef","cherry","chest","chicken","chief","child",
33454 "chimney","choice","choose","chronic","chuckle","chunk","churn","cigar","cinnamon","circle",
33455 "citizen","city","civil","claim","clap","clarify","claw","clay","clean","clerk",
33456 "clever","click","client","cliff","climb","clinic","clip","clock","clog","close",
33457 "cloth","cloud","clown","club","clump","cluster","clutch","coach","coast","coconut",
33458 "code","coffee","coil","coin","collect","color","column","combine","come","comfort",
33459 "comic","common","company","concert","conduct","confirm","congress","connect","consider","control",
33460 "convince","cook","cool","copper","copy","coral","core","corn","correct","cost",
33461 "cotton","couch","country","couple","course","cousin","cover","coyote","crack","cradle",
33462 "craft","cram","crane","crash","crater","crawl","crazy","cream","credit","creek",
33463 "crew","cricket","crime","crisp","critic","crop","cross","crouch","crowd","crucial",
33464 "cruel","cruise","crumble","crunch","crush","cry","crystal","cube","culture","cup",
33465 "cupboard","curious","current","curtain","curve","cushion","custom","cute","cycle","dad",
33466 "damage","damp","dance","danger","daring","dash","daughter","dawn","day","deal",
33467 "debate","debris","decade","december","decide","decline","decorate","decrease","deer","defense",
33468 "define","defy","degree","delay","deliver","demand","demise","denial","dentist","deny",
33469 "depart","depend","deposit","depth","deputy","derive","describe","desert","design","desk",
33470 "despair","destroy","detail","detect","develop","device","devote","diagram","dial","diamond",
33471 "diary","dice","diesel","diet","differ","digital","dignity","dilemma","dinner","dinosaur",
33472 "direct","dirt","disagree","discover","disease","dish","dismiss","disorder","display","distance",
33473 "divert","divide","divorce","dizzy","doctor","document","dog","doll","dolphin","domain",
33474 "donate","donkey","donor","door","dose","double","dove","draft","dragon","drama",
33475 "drastic","draw","dream","dress","drift","drill","drink","drip","drive","drop",
33476 "drum","dry","duck","dumb","dune","during","dust","dutch","duty","dwarf",
33477 "dynamic","eager","eagle","early","earn","earth","easily","east","easy","echo",
33478 "ecology","economy","edge","edit","educate","effort","egg","eight","either","elbow",
33479 "elder","electric","elegant","element","elephant","elevator","elite","else","embark","embody",
33480 "embrace","emerge","emotion","employ","empower","empty","enable","enact","end","endless",
33481 "endorse","enemy","energy","enforce","engage","engine","enhance","enjoy","enlist","enough",
33482 "enrich","enroll","ensure","enter","entire","entry","envelope","episode","equal","equip",
33483 "era","erase","erode","erosion","error","erupt","escape","essay","essence","estate",
33484 "eternal","ethics","evidence","evil","evoke","evolve","exact","example","excess","exchange",
33485 "excite","exclude","excuse","execute","exercise","exhaust","exhibit","exile","exist","exit",
33486 "exotic","expand","expect","expire","explain","expose","express","extend","extra","eye",
33487 "eyebrow","fabric","face","faculty","fade","faint","faith","fall","false","fame",
33488 "family","famous","fan","fancy","fantasy","farm","fashion","fat","fatal","father",
33489 "fatigue","fault","favorite","feature","february","federal","fee","feed","feel","female",
33490 "fence","festival","fetch","fever","few","fiber","fiction","field","figure","file",
33491 "film","filter","final","find","fine","finger","finish","fire","firm","first",
33492 "fiscal","fish","fit","fitness","fix","flag","flame","flash","flat","flavor",
33493 "flee","flight","flip","float","flock","floor","flower","fluid","flush","fly",
33494 "foam","focus","fog","foil","fold","follow","food","foot","force","forest",
33495 "forget","fork","fortune","forum","forward","fossil","foster","found","fox","fragile",
33496 "frame","frequent","fresh","friend","fringe","frog","front","frost","frown","frozen",
33497 "fruit","fuel","fun","funny","furnace","fury","future","gadget","gain","galaxy",
33498 "gallery","game","gap","garage","garbage","garden","garlic","garment","gas","gasp",
33499 "gate","gather","gauge","gaze","general","genius","genre","gentle","genuine","gesture",
33500 "ghost","giant","gift","giggle","ginger","giraffe","girl","give","glad","glance",
33501 "glare","glass","glide","glimpse","globe","gloom","glory","glove","glow","glue",
33502 "goat","goddess","gold","good","goose","gorilla","gospel","gossip","govern","gown",
33503 "grab","grace","grain","grant","grape","grass","gravity","great","green","grid",
33504 "grief","grit","grocery","group","grow","grunt","guard","guess","guide","guilt",
33505 "guitar","gun","gym","habit","hair","half","hammer","hamster","hand","happy",
33506 "harbor","hard","harsh","harvest","hat","have","hawk","hazard","head","health",
33507 "heart","heavy","hedgehog","height","hello","helmet","help","hen","hero","hidden",
33508 "high","hill","hint","hip","hire","history","hobby","hockey","hold","hole",
33509 "holiday","hollow","home","honey","hood","hope","horn","horror","horse","hospital",
33510 "host","hotel","hour","hover","hub","huge","human","humble","humor","hundred",
33511 "hungry","hunt","hurdle","hurry","hurt","husband","hybrid","ice","icon","idea",
33512 "identify","idle","ignore","ill","illegal","illness","image","imitate","immense","immune",
33513 "impact","impose","improve","impulse","inch","include","income","increase","index","indicate",
33514 "indoor","industry","infant","inflict","inform","inhale","inherit","initial","inject","injury",
33515 "inmate","inner","innocent","input","inquiry","insane","insect","inside","inspire","install",
33516 "intact","interest","into","invest","invite","involve","iron","island","isolate","issue",
33517 "item","ivory","jacket","jaguar","jar","jazz","jealous","jeans","jelly","jewel",
33518 "job","join","joke","journey","joy","judge","juice","jump","jungle","junior",
33519 "junk","just","kangaroo","keen","keep","ketchup","key","kick","kid","kidney",
33520 "kind","kingdom","kiss","kit","kitchen","kite","kitten","kiwi","knee","knife",
33521 "knock","know","lab","label","labor","ladder","lady","lake","lamp","language",
33522 "laptop","large","later","latin","laugh","laundry","lava","law","lawn","lawsuit",
33523 "layer","lazy","leader","leaf","learn","leave","lecture","left","leg","legal",
33524 "legend","leisure","lemon","lend","length","lens","leopard","lesson","letter","level",
33525 "liar","liberty","library","license","life","lift","light","like","limb","limit",
33526 "link","lion","liquid","list","little","live","lizard","load","loan","lobster",
33527 "local","lock","logic","lonely","long","loop","lottery","loud","lounge","love",
33528 "loyal","lucky","luggage","lumber","lunar","lunch","luxury","lyrics","machine","mad",
33529 "magic","magnet","maid","mail","main","major","make","mammal","man","manage",
33530 "mandate","mango","mansion","manual","maple","marble","march","margin","marine","market",
33531 "marriage","mask","mass","master","match","material","math","matrix","matter","maximum",
33532 "maze","meadow","mean","measure","meat","mechanic","medal","media","melody","melt",
33533 "member","memory","mention","menu","mercy","merge","merit","merry","mesh","message",
33534 "metal","method","middle","midnight","milk","million","mimic","mind","minimum","minor",
33535 "minute","miracle","mirror","misery","miss","mistake","mix","mixed","mixture","mobile",
33536 "model","modify","mom","moment","monitor","monkey","monster","month","moon","moral",
33537 "more","morning","mosquito","mother","motion","motor","mountain","mouse","move","movie",
33538 "much","muffin","mule","multiply","muscle","museum","mushroom","music","must","mutual",
33539 "myself","mystery","myth","naive","name","napkin","narrow","nasty","nation","nature",
33540 "near","neck","need","negative","neglect","neither","nephew","nerve","nest","net",
33541 "network","neutral","never","news","next","nice","night","noble","noise","nominee",
33542 "noodle","normal","north","nose","notable","note","nothing","notice","novel","now",
33543 "nuclear","number","nurse","nut","oak","obey","object","oblige","obscure","observe",
33544 "obtain","obvious","occur","ocean","october","odor","off","offer","office","often",
33545 "oil","okay","old","olive","olympic","omit","once","one","onion","online",
33546 "only","open","opera","opinion","oppose","option","orange","orbit","orchard","order",
33547 "ordinary","organ","orient","original","orphan","ostrich","other","outdoor","outer","output",
33548 "outside","oval","oven","over","own","owner","oxygen","oyster","ozone","pact",
33549 "paddle","page","pair","palace","palm","panda","panel","panic","panther","paper",
33550 "parade","parent","park","parrot","party","pass","patch","path","patient","patrol",
33551 "pattern","pause","pave","payment","peace","peanut","pear","peasant","pelican","pen",
33552 "penalty","pencil","people","pepper","perfect","permit","person","pet","phone","photo",
33553 "phrase","physical","piano","picnic","picture","piece","pig","pigeon","pill","pilot",
33554 "pink","pioneer","pipe","pistol","pitch","pizza","place","planet","plastic","plate",
33555 "play","please","pledge","pluck","plug","plunge","poem","poet","point","polar",
33556 "pole","police","pond","pony","pool","popular","portion","position","possible","post",
33557 "potato","pottery","poverty","powder","power","practice","praise","predict","prefer","prepare",
33558 "present","pretty","prevent","price","pride","primary","print","priority","prison","private",
33559 "prize","problem","process","produce","profit","program","project","promote","proof","property",
33560 "prosper","protect","proud","provide","public","pudding","pull","pulp","pulse","pumpkin",
33561 "punch","pupil","puppy","purchase","purity","purpose","purse","push","put","puzzle",
33562 "pyramid","quality","quantum","quarter","question","quick","quit","quiz","quote","rabbit",
33563 "raccoon","race","rack","radar","radio","rail","rain","raise","rally","ramp",
33564 "ranch","random","range","rapid","rare","rate","rather","raven","raw","razor",
33565 "ready","real","reason","rebel","rebuild","recall","receive","recipe","record","recycle",
33566 "reduce","reflect","reform","refuse","region","regret","regular","reject","relax","release",
33567 "relief","rely","remain","remember","remind","remove","render","renew","rent","reopen",
33568 "repair","repeat","replace","report","require","rescue","resemble","resist","resource","response",
33569 "result","retire","retreat","return","reunion","reveal","review","reward","rhythm","rib",
33570 "ribbon","rice","rich","ride","ridge","rifle","right","rigid","ring","riot",
33571 "ripple","risk","ritual","rival","river","road","roast","robot","robust","rocket",
33572 "romance","roof","rookie","room","rose","rotate","rough","round","route","royal",
33573 "rubber","rude","rug","rule","run","runway","rural","sad","saddle","sadness",
33574 "safe","sail","salad","salmon","salon","salt","salute","same","sample","sand",
33575 "satisfy","satoshi","sauce","sausage","save","say","scale","scan","scare","scatter",
33576 "scene","scheme","school","science","scissors","scorpion","scout","scrap","screen","script",
33577 "scrub","sea","search","season","seat","second","secret","section","security","seed",
33578 "seek","segment","select","sell","seminar","senior","sense","sentence","series","service",
33579 "session","settle","setup","seven","shadow","shaft","shallow","share","shed","shell",
33580 "sheriff","shield","shift","shine","ship","shiver","shock","shoe","shoot","shop",
33581 "short","shoulder","shove","shrimp","shrug","shuffle","shy","sibling","sick","side",
33582 "siege","sight","sign","silent","silk","silly","silver","similar","simple","since",
33583 "sing","siren","sister","situate","six","size","skate","sketch","ski","skill",
33584 "skin","skirt","skull","slab","slam","sleep","slender","slice","slide","slight",
33585 "slim","slogan","slot","slow","slush","small","smart","smile","smoke","smooth",
33586 "snack","snake","snap","sniff","snow","soap","soccer","social","sock","soda",
33587 "soft","solar","soldier","solid","solution","solve","someone","song","soon","sorry",
33588 "sort","soul","sound","soup","source","south","space","spare","spatial","spawn",
33589 "speak","special","speed","spell","spend","sphere","spice","spider","spike","spin",
33590 "spirit","split","spoil","sponsor","spoon","sport","spot","spray","spread","spring",
33591 "spy","square","squeeze","squirrel","stable","stadium","staff","stage","stairs","stamp",
33592 "stand","start","state","stay","steak","steel","stem","step","stereo","stick",
33593 "still","sting","stock","stomach","stone","stool","story","stove","strategy","street",
33594 "strike","strong","struggle","student","stuff","stumble","style","subject","submit","subway",
33595 "success","such","sudden","suffer","sugar","suggest","suit","summer","sun","sunny",
33596 "sunset","super","supply","supreme","sure","surface","surge","surprise","surround","survey",
33597 "suspect","sustain","swallow","swamp","swap","swarm","swear","sweet","swift","swim",
33598 "swing","switch","sword","symbol","symptom","syrup","system","table","tackle","tag",
33599 "tail","talent","talk","tank","tape","target","task","taste","tattoo","taxi",
33600 "teach","team","tell","ten","tenant","tennis","tent","term","test","text",
33601 "thank","that","theme","then","theory","there","they","thing","this","thought",
33602 "three","thrive","throw","thumb","thunder","ticket","tide","tiger","tilt","timber",
33603 "time","tiny","tip","tired","tissue","title","toast","tobacco","today","toddler",
33604 "toe","together","toilet","token","tomato","tomorrow","tone","tongue","tonight","tool",
33605 "tooth","top","topic","topple","torch","tornado","tortoise","toss","total","tourist",
33606 "toward","tower","town","toy","track","trade","traffic","tragic","train","transfer",
33607 "trap","trash","travel","tray","treat","tree","trend","trial","tribe","trick",
33608 "trigger","trim","trip","trophy","trouble","truck","true","truly","trumpet","trust",
33609 "truth","try","tube","tuition","tumble","tuna","tunnel","turkey","turn","turtle",
33610 "twelve","twenty","twice","twin","twist","two","type","typical","ugly","umbrella",
33611 "unable","unaware","uncle","uncover","under","undo","unfair","unfold","unhappy","uniform",
33612 "unique","unit","universe","unknown","unlock","until","unusual","unveil","update","upgrade",
33613 "uphold","upon","upper","upset","urban","urge","usage","use","used","useful",
33614 "useless","usual","utility","vacant","vacuum","vague","valid","valley","valve","van",
33615 "vanish","vapor","various","vast","vault","vehicle","velvet","vendor","venture","venue",
33616 "verb","verify","version","very","vessel","veteran","viable","vibrant","vicious","victory",
33617 "video","view","village","vintage","violin","virtual","virus","visa","visit","visual",
33618 "vital","vivid","vocal","voice","void","volcano","volume","vote","voyage","wage",
33619 "wagon","wait","walk","wall","walnut","want","warfare","warm","warrior","wash",
33620 "wasp","waste","water","wave","way","wealth","weapon","wear","weasel","weather",
33621 "web","wedding","weekend","weird","welcome","west","wet","whale","what","wheat",
33622 "wheel","when","where","whip","whisper","wide","width","wife","wild","will",
33623 "win","window","wine","wing","wink","winner","winter","wire","wisdom","wise",
33624 "wish","witness","wolf","woman","wonder","wood","wool","word","work","world",
33625 "worry","worth","wrap","wreck","wrestle","wrist","write","wrong","yard","year",
33626 "yellow","you","young","youth","zebra","zero","zone","zoo"]
33627 </script>
33628 <script>
33629 /*
33630 * Copyright (c) 2013 Pavol Rusnak
33631 *
33632 * Permission is hereby granted, free of charge, to any person obtaining a copy of
33633 * this software and associated documentation files (the "Software"), to deal in
33634 * the Software without restriction, including without limitation the rights to
33635 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
33636 * of the Software, and to permit persons to whom the Software is furnished to do
33637 * so, subject to the following conditions:
33638 *
33639 * The above copyright notice and this permission notice shall be included in all
33640 * copies or substantial portions of the Software.
33641 *
33642 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33643 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33644 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33645 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
33646 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33647 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33648 */
33649
33650 /*
33651 * Javascript port from python by Ian Coleman
33652 *
33653 * Requires code from sjcl
33654 * https://github.com/bitwiseshiftleft/sjcl
33655 */
33656
33657 var Mnemonic = function(language) {
33658
33659 var PBKDF2_ROUNDS = 2048;
33660 var RADIX = 2048;
33661
33662 var self = this;
33663 var wordlist = [];
33664
33665 var hmacSHA512 = function(key) {
33666 var hasher = new sjcl.misc.hmac(key, sjcl.hash.sha512);
33667 this.encrypt = function() {
33668 return hasher.encrypt.apply(hasher, arguments);
33669 };
33670 };
33671
33672 function init() {
33673 wordlist = WORDLISTS[language];
33674 if (wordlist.length != RADIX) {
33675 err = 'Wordlist should contain ' + RADIX + ' words, but it contains ' + wordlist.length + ' words.';
33676 throw err;
33677 }
33678 }
33679
33680 self.generate = function(strength) {
33681 strength = strength || 128;
33682 var r = strength % 32;
33683 if (r > 0) {
33684 throw 'Strength should be divisible by 32, but it is not (' + r + ').';
33685 }
33686 var hasStrongCrypto = 'crypto' in window && window['crypto'] !== null;
33687 if (!hasStrongCrypto) {
33688 throw 'Mnemonic should be generated with strong randomness, but crypto.getRandomValues is unavailable';
33689 }
33690 var buffer = new Uint8Array(strength / 8);
33691 var data = crypto.getRandomValues(buffer);
33692 return self.toMnemonic(data);
33693 }
33694
33695 self.toMnemonic = function(byteArray) {
33696 if (byteArray.length % 4 > 0) {
33697 throw 'Data length in bits should be divisible by 32, but it is not (' + byteArray.length + ' bytes = ' + byteArray.length*8 + ' bits).'
33698 }
33699
33700 //h = hashlib.sha256(data).hexdigest()
33701 var data = byteArrayToWordArray(byteArray);
33702 var hash = sjcl.hash.sha256.hash(data);
33703 var h = sjcl.codec.hex.fromBits(hash);
33704
33705 // b is a binary string, eg '00111010101100...'
33706 //b = bin(int(binascii.hexlify(data), 16))[2:].zfill(len(data) * 8) + \
33707 // bin(int(h, 16))[2:].zfill(256)[:len(data) * 8 / 32]
33708 //
33709 // a = bin(int(binascii.hexlify(data), 16))[2:].zfill(len(data) * 8)
33710 // c = bin(int(h, 16))[2:].zfill(256)
33711 // d = c[:len(data) * 8 / 32]
33712 var a = byteArrayToBinaryString(byteArray);
33713 var c = zfill(hexStringToBinaryString(h), 256);
33714 var d = c.substring(0, byteArray.length * 8 / 32);
33715 // b = line1 + line2
33716 var b = a + d;
33717
33718 var result = [];
33719 var blen = b.length / 11;
33720 for (var i=0; i<blen; i++) {
33721 var idx = parseInt(b.substring(i * 11, (i + 1) * 11), 2);
33722 result.push(wordlist[idx]);
33723 }
33724 return result.join(' ');
33725 }
33726
33727 self.check = function(mnemonic) {
33728 var mnemonic = mnemonic.split(' ')
33729 if (mnemonic.length % 3 > 0) {
33730 return false
33731 }
33732 // idx = map(lambda x: bin(self.wordlist.index(x))[2:].zfill(11), mnemonic)
33733 var idx = [];
33734 for (var i=0; i<mnemonic.length; i++) {
33735 var word = mnemonic[i];
33736 var wordIndex = wordlist.indexOf(word);
33737 if (wordIndex == -1) {
33738 return false;
33739 }
33740 var binaryIndex = zfill(wordIndex.toString(2), 11);
33741 idx.push(binaryIndex);
33742 }
33743 var b = idx.join('');
33744 var l = b.length;
33745 //d = b[:l / 33 * 32]
33746 //h = b[-l / 33:]
33747 var d = b.substring(0, l / 33 * 32);
33748 var h = b.substring(l - l / 33, l);
33749 //nd = binascii.unhexlify(hex(int(d, 2))[2:].rstrip('L').zfill(l / 33 * 8))
33750 var nd = binaryStringToWordArray(d);
33751 //nh = bin(int(hashlib.sha256(nd).hexdigest(), 16))[2:].zfill(256)[:l / 33]
33752 var ndHash = sjcl.hash.sha256.hash(nd);
33753 var ndHex = sjcl.codec.hex.fromBits(ndHash);
33754 var ndBstr = zfill(hexStringToBinaryString(ndHex), 256);
33755 var nh = ndBstr.substring(0,l/33);
33756 return h == nh;
33757 }
33758
33759 self.toSeed = function(mnemonic, passphrase) {
33760 passphrase = passphrase || '';
33761 mnemonic = self.normalizeString(mnemonic)
33762 passphrase = self.normalizeString(passphrase)
33763 passphrase = "mnemonic" + passphrase;
33764 var mnemonicBits = sjcl.codec.utf8String.toBits(mnemonic);
33765 var passphraseBits = sjcl.codec.utf8String.toBits(passphrase);
33766 var result = sjcl.misc.pbkdf2(mnemonicBits, passphraseBits, PBKDF2_ROUNDS, 512, hmacSHA512);
33767 var hashHex = sjcl.codec.hex.fromBits(result);
33768 return hashHex;
33769 }
33770
33771 self.normalizeString = function(str) {
33772 if (typeof str.normalize == "function") {
33773 return str.normalize("NFKD");
33774 }
33775 else {
33776 // TODO decide how to handle this in the future.
33777 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
33778 return str;
33779 }
33780 }
33781
33782 function byteArrayToWordArray(data) {
33783 var a = [];
33784 for (var i=0; i<data.length/4; i++) {
33785 v = 0;
33786 v += data[i*4 + 0] << 8 * 3;
33787 v += data[i*4 + 1] << 8 * 2;
33788 v += data[i*4 + 2] << 8 * 1;
33789 v += data[i*4 + 3] << 8 * 0;
33790 a.push(v);
33791 }
33792 return a;
33793 }
33794
33795 function byteArrayToBinaryString(data) {
33796 var bin = "";
33797 for (var i=0; i<data.length; i++) {
33798 bin += zfill(data[i].toString(2), 8);
33799 }
33800 return bin;
33801 }
33802
33803 function hexStringToBinaryString(hexString) {
33804 binaryString = "";
33805 for (var i=0; i<hexString.length; i++) {
33806 binaryString += zfill(parseInt(hexString[i], 16).toString(2),4);
33807 }
33808 return binaryString;
33809 }
33810
33811 function binaryStringToWordArray(binary) {
33812 var aLen = binary.length / 32;
33813 var a = [];
33814 for (var i=0; i<aLen; i++) {
33815 var valueStr = binary.substring(0,32);
33816 var value = parseInt(valueStr, 2);
33817 a.push(value);
33818 binary = binary.slice(32);
33819 }
33820 return a;
33821 }
33822
33823 // Pad a numeric string on the left with zero digits until the given width
33824 // is reached.
33825 // Note this differs to the python implementation because it does not
33826 // handle numbers starting with a sign.
33827 function zfill(source, length) {
33828 source = source.toString();
33829 while (source.length < length) {
33830 source = '0' + source;
33831 }
33832 return source;
33833 }
33834
33835 init();
33836
33837 }
33838 </script>
33839 <script>
33840 (function() {
33841
33842 var mnemonic = new Mnemonic("english");
33843 var bip32RootKey = null;
33844 var bip32ExtendedKey = null;
33845 var network = Bitcoin.networks.bitcoin;
33846 var addressRowTemplate = $("#address-row-template");
33847
33848 var showIndex = true;
33849 var showAddress = true;
33850 var showPrivKey = true;
33851
33852 var phraseChangeTimeoutEvent = null;
33853
33854 var DOM = {};
33855 DOM.network = $(".network");
33856 DOM.phraseNetwork = $("#network-phrase");
33857 DOM.bip44Network = $("#network-bip44");
33858 DOM.addressNetwork = $("#network-address-type");
33859 DOM.phrase = $(".phrase");
33860 DOM.passphrase = $(".passphrase");
33861 DOM.generate = $(".generate");
33862 DOM.rootKey = $(".root-key");
33863 DOM.extendedPrivKey = $(".extended-priv-key");
33864 DOM.extendedPubKey = $(".extended-pub-key");
33865 DOM.bip32tab = $("#bip32-tab");
33866 DOM.bip44tab = $("#bip44-tab");
33867 DOM.bip32panel = $("#bip32");
33868 DOM.bip44panel = $("#bip44");
33869 DOM.bip32path = $("#bip32-path");
33870 DOM.bip44path = $("#bip44-path");
33871 DOM.bip44purpose = $("#bip44 .purpose");
33872 DOM.bip44coin = $("#bip44 .coin");
33873 DOM.bip44account = $("#bip44 .account");
33874 DOM.bip44change = $("#bip44 .change");
33875 DOM.strength = $(".strength");
33876 DOM.addresses = $(".addresses");
33877 DOM.rowsToAdd = $(".rows-to-add");
33878 DOM.more = $(".more");
33879 DOM.feedback = $(".feedback");
33880 DOM.tab = $(".derivation-type a");
33881 DOM.indexToggle = $(".index-toggle");
33882 DOM.addressToggle = $(".address-toggle");
33883 DOM.privateKeyToggle = $(".private-key-toggle");
33884
33885 var derivationPath = DOM.bip44path.val();
33886
33887 function init() {
33888 // Events
33889 DOM.network.on("change", networkChanged);
33890 DOM.phrase.on("input", delayedPhraseChanged);
33891 DOM.passphrase.on("input", delayedPhraseChanged);
33892 DOM.generate.on("click", generateClicked);
33893 DOM.more.on("click", showMore);
33894 DOM.bip32path.on("input", bip32Changed);
33895 DOM.bip44purpose.on("input", bip44Changed);
33896 DOM.bip44coin.on("input", bip44Changed);
33897 DOM.bip44account.on("input", bip44Changed);
33898 DOM.bip44change.on("input", bip44Changed);
33899 DOM.tab.on("click", tabClicked);
33900 DOM.indexToggle.on("click", toggleIndexes);
33901 DOM.addressToggle.on("click", toggleAddresses);
33902 DOM.privateKeyToggle.on("click", togglePrivateKeys);
33903 disableForms();
33904 hidePending();
33905 hideValidationError();
33906 }
33907
33908 // Event handlers
33909
33910 function networkChanged(e) {
33911 var n = e.target.value;
33912 if (n == "bitcoin") {
33913 network = Bitcoin.networks.bitcoin;
33914 DOM.bip44coin.val(0);
33915 setBip44DerivationPath();
33916 enableBip44Tab();
33917 }
33918 else if (n == "bitcoin-testnet") {
33919 network = Bitcoin.networks.testnet;
33920 DOM.bip44coin.val(1);
33921 setBip44DerivationPath();
33922 enableBip44Tab();
33923 }
33924 else if (n == "litecoin") {
33925 network = Bitcoin.networks.litecoin;
33926 DOM.bip44coin.val(2);
33927 setBip44DerivationPath();
33928 enableBip44Tab();
33929 }
33930 else if (n == "dogecoin") {
33931 network = Bitcoin.networks.dogecoin;
33932 //disableBip44Tab();
33933 }
33934 DOM.phraseNetwork.val(n);
33935 DOM.bip44Network.val(n);
33936 if(e.target != DOM.addressNetwork.dom){
33937 DOM.addressNetwork.val(n);
33938 }
33939 delayedPhraseChanged();
33940 }
33941
33942 function delayedPhraseChanged() {
33943 hideValidationError();
33944 showPending();
33945 if (phraseChangeTimeoutEvent != null) {
33946 clearTimeout(phraseChangeTimeoutEvent);
33947 }
33948 phraseChangeTimeoutEvent = setTimeout(phraseChanged, 400);
33949 }
33950
33951 function phraseChanged() {
33952 showPending();
33953 hideValidationError();
33954 // Get the mnemonic phrase
33955 var phrase = DOM.phrase.val();
33956 var passphrase = DOM.passphrase.val();
33957 var errorText = findPhraseErrors(phrase);
33958 if (errorText) {
33959 showValidationError(errorText);
33960 return;
33961 }
33962 // Get the derivation path
33963 var errorText = findDerivationPathErrors();
33964 if (errorText) {
33965 showValidationError(errorText);
33966 return;
33967 }
33968 // Calculate and display
33969 calcBip32Seed(phrase, passphrase, derivationPath);
33970 displayBip32Info();
33971 hidePending();
33972 }
33973
33974 function generateClicked() {
33975 clearDisplay();
33976 showPending();
33977 setTimeout(function() {
33978 var phrase = generateRandomPhrase();
33979 if (!phrase) {
33980 return;
33981 }
33982 phraseChanged();
33983 }, 50);
33984 }
33985
33986 function tabClicked(e) {
33987 var activePath = $(e.target.getAttribute("href") + " .path");
33988 derivationPath = activePath.val();
33989 derivationChanged();
33990 }
33991
33992 function derivationChanged() {
33993 delayedPhraseChanged();
33994 }
33995
33996 function bip32Changed() {
33997 derivationPath = DOM.bip32path.val();
33998 derivationChanged();
33999 }
34000
34001 function bip44Changed() {
34002 setBip44DerivationPath();
34003 derivationPath = DOM.bip44path.val();
34004 derivationChanged();
34005 }
34006
34007 function toggleIndexes() {
34008 showIndex = !showIndex;
34009 $("td.index span").toggleClass("invisible");
34010 }
34011
34012 function toggleAddresses() {
34013 showAddress = !showAddress;
34014 $("td.address span").toggleClass("invisible");
34015 }
34016
34017 function togglePrivateKeys() {
34018 showPrivKey = !showPrivKey;
34019 $("td.privkey span").toggleClass("invisible");
34020 }
34021
34022 // Private methods
34023
34024 function generateRandomPhrase() {
34025 if (!hasStrongRandom()) {
34026 var errorText = "This browser does not support strong randomness";
34027 showValidationError(errorText);
34028 return;
34029 }
34030 var numWords = parseInt(DOM.strength.val());
34031 // Check strength is an integer
34032 if (isNaN(numWords)) {
34033 DOM.strength.val("12");
34034 numWords = 12;
34035 }
34036 // Check strength is a multiple of 32, if not round it down
34037 if (numWords % 3 != 0) {
34038 numWords = Math.floor(numWords / 3) * 3;
34039 DOM.strength.val(numWords);
34040 }
34041 // Check strength is at least 32
34042 if (numWords == 0) {
34043 numWords = 3;
34044 DOM.strength.val(numWords);
34045 }
34046 var strength = numWords / 3 * 32;
34047 var words = mnemonic.generate(strength);
34048 DOM.phrase.val(words);
34049 return words;
34050 }
34051
34052 function calcBip32Seed(phrase, passphrase, path) {
34053 var seed = mnemonic.toSeed(phrase, passphrase);
34054 bip32RootKey = Bitcoin.HDNode.fromSeedHex(seed, network);
34055 bip32ExtendedKey = bip32RootKey;
34056 // Derive the key from the path
34057 var pathBits = path.split("/");
34058 for (var i=0; i<pathBits.length; i++) {
34059 var bit = pathBits[i];
34060 var index = parseInt(bit);
34061 if (isNaN(index)) {
34062 continue;
34063 }
34064 var hardened = bit[bit.length-1] == "'";
34065 if (hardened) {
34066 bip32ExtendedKey = bip32ExtendedKey.deriveHardened(index);
34067 }
34068 else {
34069 bip32ExtendedKey = bip32ExtendedKey.derive(index);
34070 }
34071 }
34072 }
34073
34074 function showValidationError(errorText) {
34075 DOM.feedback
34076 .text(errorText)
34077 .show();
34078 }
34079
34080 function hideValidationError() {
34081 DOM.feedback
34082 .text("")
34083 .hide();
34084 }
34085
34086 function findPhraseErrors(phrase) {
34087 // TODO make this right
34088 // Preprocess the words
34089 phrase = mnemonic.normalizeString(phrase);
34090 var parts = phrase.split(" ");
34091 var proper = [];
34092 for (var i=0; i<parts.length; i++) {
34093 var part = parts[i];
34094 if (part.length > 0) {
34095 // TODO check that lowercasing is always valid to do
34096 proper.push(part.toLowerCase());
34097 }
34098 }
34099 // TODO some levenstein on the words
34100 var properPhrase = proper.join(' ');
34101 // Check the words are valid
34102 var isValid = mnemonic.check(properPhrase);
34103 if (!isValid) {
34104 return "Invalid mnemonic";
34105 }
34106 return false;
34107 }
34108
34109 function findDerivationPathErrors(path) {
34110 // TODO
34111 return false;
34112 }
34113
34114 function displayBip32Info() {
34115 // Display the key
34116 var rootKey = bip32RootKey.toBase58();
34117 DOM.rootKey.val(rootKey);
34118 var extendedPrivKey = bip32ExtendedKey.toBase58();
34119 DOM.extendedPrivKey.val(extendedPrivKey);
34120 var extendedPubKey = bip32ExtendedKey.toBase58(false);
34121 DOM.extendedPubKey.val(extendedPubKey);
34122 // Display the addresses and privkeys
34123 clearAddressesList();
34124 displayAddresses(0, 20);
34125 }
34126
34127 function displayAddresses(start, total) {
34128 for (var i=0; i<total; i++) {
34129 var index = i + start;
34130 new TableRow(index);
34131 }
34132 }
34133
34134 function TableRow(index) {
34135
34136 function init() {
34137 calculateValues();
34138 }
34139
34140 function calculateValues() {
34141 setTimeout(function() {
34142 var key = bip32ExtendedKey.derive(index);
34143 var address = key.getAddress().toString();
34144 var privkey = key.privKey.toWIF(network);
34145 addAddressToList(index, address, privkey);
34146 }, 50)
34147 }
34148
34149 init();
34150
34151 }
34152
34153 function showMore() {
34154 var start = DOM.addresses.children().length;
34155 var rowsToAdd = parseInt(DOM.rowsToAdd.val());
34156 if (isNaN(rowsToAdd)) {
34157 rowsToAdd = 20;
34158 DOM.rowsToAdd.val("20");
34159 }
34160 if (rowsToAdd > 200) {
34161 var msg = "Generating " + rowsToAdd + " rows could take a while. ";
34162 msg += "Do you want to continue?";
34163 if (!confirm(msg)) {
34164 return;
34165 }
34166 }
34167 displayAddresses(start, rowsToAdd);
34168 }
34169
34170 function clearDisplay() {
34171 clearAddressesList();
34172 clearKey();
34173 hideValidationError();
34174 }
34175
34176 function clearAddressesList() {
34177 DOM.addresses.empty();
34178 }
34179
34180 function clearKey() {
34181 DOM.rootKey.val("");
34182 DOM.extendedPrivKey.val("");
34183 DOM.extendedPubKey.val("");
34184 }
34185
34186 function addAddressToList(index, address, privkey) {
34187 var row = $(addressRowTemplate.html());
34188 // Elements
34189 var indexCell = row.find(".index span");
34190 var addressCell = row.find(".address span");
34191 var privkeyCell = row.find(".privkey span");
34192 // Content
34193 indexCell.text(index);
34194 addressCell.text(address);
34195 privkeyCell.text(privkey);
34196 // Visibility
34197 if (!showIndex) {
34198 indexCell.addClass("invisible");
34199 }
34200 if (!showAddress) {
34201 addressCell.addClass("invisible");
34202 }
34203 if (!showPrivKey) {
34204 privkeCell.addClass("invisible");
34205 }
34206 DOM.addresses.append(row);
34207 }
34208
34209 function hasStrongRandom() {
34210 return 'crypto' in window && window['crypto'] !== null;
34211 }
34212
34213 function disableForms() {
34214 $("form").on("submit", function(e) {
34215 e.preventDefault();
34216 });
34217 }
34218
34219 function setBip44DerivationPath() {
34220 var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
34221 var coin = parseIntNoNaN(DOM.bip44coin.val(), 0);
34222 var account = parseIntNoNaN(DOM.bip44account.val(), 0);
34223 var change = parseIntNoNaN(DOM.bip44change.val(), 0);
34224 var path = "m/";
34225 path += purpose + "'/";
34226 path += coin + "'/";
34227 path += account + "'/";
34228 path += change;
34229 DOM.bip44path.val(path);
34230 }
34231
34232 function parseIntNoNaN(val, defaultVal) {
34233 var v = parseInt(val);
34234 if (isNaN(v)) {
34235 return defaultVal;
34236 }
34237 return v;
34238 }
34239
34240 function showPending() {
34241 DOM.feedback
34242 .text("Calculating...")
34243 .show();
34244 }
34245
34246 function hidePending() {
34247 DOM.feedback
34248 .text("")
34249 .hide();
34250 }
34251
34252 function enableBip44Tab() {
34253 // show bip44 tab (but don't select it)
34254 DOM.bip44tab.removeClass("hidden");
34255 DOM.bip44panel.removeClass("hidden");
34256 }
34257
34258 function disableBip44Tab() {
34259 // hide bip44 tab
34260 DOM.bip44tab.addClass("hidden");
34261 DOM.bip44tab.removeClass("active");
34262 // hide bip44 panel
34263 DOM.bip44panel.addClass("hidden");
34264 DOM.bip44panel.removeClass("active");
34265 // show bip32 tab
34266 DOM.bip32tab.addClass("active");
34267 // show bip32 panel
34268 DOM.bip32panel.addClass("active");
34269 // set the derivation path
34270 var activePath = $("#bip32 .path");
34271 derivationPath = activePath.val();
34272 }
34273
34274 init();
34275
34276 })();
34277 </script>
34278 </body>
34279 </html>