]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/blob - bip39-standalone.html
fixed spacing, added missing tag
[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 <div>
6423 <table class="table table-striped">
6424 <thead>
6425 <th>
6426 <div class="input-group">
6427 Index&nbsp;&nbsp;
6428 <button class="index-toggle">Toggle</button>
6429 </div>
6430 </th>
6431 <th>
6432 <div class="input-group">
6433 Address&nbsp;&nbsp;
6434 <button class="address-toggle">Toggle</button>
6435 </div>
6436 </th>
6437 <th>
6438 <div class="input-group">
6439 Private Key&nbsp;&nbsp;
6440 <button class="private-key-toggle">Toggle</button>
6441 </div>
6442 </th>
6443 </thead>
6444 <tbody class="addresses">
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 <tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
6450 </tbody>
6451 </table>
6452 </div>
6453 </div>
6454 <span>Show next </button>
6455 <input type="number" class="rows-to-add" value="20">
6456 <button class="more">Show</button>
6457
6458 <hr>
6459
6460 <div class="row">
6461 <div class="col-md-12">
6462 <h2>More info</h2>
6463 <h3>BIP39 <span class="small">Mnemonic code for generating deterministic keys</span></h3>
6464 <p>
6465 Read more at the
6466 <a href="https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki">official BIP39 spec</a>
6467 </p>
6468 <h3>BIP32 <span class="small">Hierarchical Deterministic Wallets</span></h3>
6469 <p>
6470 Read more at the
6471 <a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" target="_blank">official BIP32 spec</a>
6472 and see the demo at
6473 <a href="http://bip32.org/" target="_blank">bip32.org</a>
6474 </p>
6475 <h3>BIP44 <span class="small">Multi-Account Hierarchy for Deterministic Wallets</span></h3>
6476 <p>
6477 Read more at the
6478 <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki" target="_blank">official BIP44 spec</a>
6479 </p>
6480 <h3>Private Keys</h3>
6481 <p>
6482 Use private keys at
6483 <a href="https://brainwallet.github.io/" target="_blank">brainwallet.org</a>,
6484 but be careful - it can be easy to make mistakes if you
6485 don't know what you're doing
6486 </p>
6487 </div>
6488 </div>
6489
6490 <hr>
6491
6492 <div class="row">
6493 <div class="col-md-12">
6494
6495 <h2>Offline Usage</h2>
6496
6497 <p>
6498 You can use this tool without having to be online.
6499 </p>
6500 <p>
6501 In your browser, select file save-as, and save this page
6502 as a file.
6503 </p>
6504 <p>
6505 Double-click that file to open it in a browser
6506 on any offline computer.
6507 </p>
6508 <p>
6509 Alternatively, download it from
6510 <a href="https://github.com/dcpos/bip39">
6511 https://github.com/dcpos/bip39
6512 </a>
6513
6514 </div>
6515 </div>
6516
6517 <hr>
6518
6519 <div class="row">
6520 <div class="col-md-12">
6521
6522 <h2>This project is 100% open-source code</h2>
6523
6524 <p>
6525 <span>Get the source code at - </span>
6526 <a href="https://github.com/dcpos/bip39" target="_blank">
6527 https://github.com/dcpos/bip39
6528 </a>
6529 </p>
6530
6531 <h3>Libraries</h3>
6532
6533 <p>
6534 <span>BitcoinJS - </span>
6535 <a href="https://github.com/bitcoinjs/bitcoinjs-lib" target="_blank">
6536 https://github.com/bitcoinjs/bitcoinjs-lib
6537 </a>
6538 </p>
6539
6540 <p>
6541 <span>jsBIP39 - </span>
6542 <a href="https://github.com/iancoleman/jsbip39" target="_blank">
6543 https://github.com/iancoleman/jsbip39
6544 </a>
6545 </p>
6546
6547 <p>
6548 <span>sjcl - </span>
6549 <a href="https://github.com/bitwiseshiftleft/sjcl" target="_blank">
6550 https://github.com/bitwiseshiftleft/sjcl
6551 </a>
6552 </p>
6553
6554 <p>
6555 <span>jQuery - </span>
6556 <a href="https://jquery.com/" target="_blank">
6557 https://jquery.com/
6558 </a>
6559 </p>
6560
6561 <p>
6562 <span>Twitter Bootstrap - </span>
6563 <a href="http://getbootstrap.com/" target="_blank">
6564 http://getbootstrap.com/
6565 </a>
6566 </p>
6567
6568 </div>
6569 </div>
6570
6571 </div>
6572
6573 <div class="feedback-container">
6574 <div class="feedback">Loading...</div>
6575 </div>
6576
6577 <script type="text/template" id="address-row-template">
6578 <tr>
6579 <td class="index"><span></span></td>
6580 <td class="address"><span></span></td>
6581 <td class="privkey"><span></span></td>
6582 </tr>
6583 </script>
6584 <script>
6585 /*!
6586 * jQuery JavaScript Library v2.1.1
6587 * http://jquery.com/
6588 *
6589 * Includes Sizzle.js
6590 * http://sizzlejs.com/
6591 *
6592 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
6593 * Released under the MIT license
6594 * http://jquery.org/license
6595 *
6596 * Date: 2014-05-01T17:11Z
6597 */
6598
6599 (function( global, factory ) {
6600
6601 if ( typeof module === "object" && typeof module.exports === "object" ) {
6602 // For CommonJS and CommonJS-like environments where a proper window is present,
6603 // execute the factory and get jQuery
6604 // For environments that do not inherently posses a window with a document
6605 // (such as Node.js), expose a jQuery-making factory as module.exports
6606 // This accentuates the need for the creation of a real window
6607 // e.g. var jQuery = require("jquery")(window);
6608 // See ticket #14549 for more info
6609 module.exports = global.document ?
6610 factory( global, true ) :
6611 function( w ) {
6612 if ( !w.document ) {
6613 throw new Error( "jQuery requires a window with a document" );
6614 }
6615 return factory( w );
6616 };
6617 } else {
6618 factory( global );
6619 }
6620
6621 // Pass this if window is not defined yet
6622 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
6623
6624 // Can't do this because several apps including ASP.NET trace
6625 // the stack via arguments.caller.callee and Firefox dies if
6626 // you try to trace through "use strict" call chains. (#13335)
6627 // Support: Firefox 18+
6628 //
6629
6630 var arr = [];
6631
6632 var slice = arr.slice;
6633
6634 var concat = arr.concat;
6635
6636 var push = arr.push;
6637
6638 var indexOf = arr.indexOf;
6639
6640 var class2type = {};
6641
6642 var toString = class2type.toString;
6643
6644 var hasOwn = class2type.hasOwnProperty;
6645
6646 var support = {};
6647
6648
6649
6650 var
6651 // Use the correct document accordingly with window argument (sandbox)
6652 document = window.document,
6653
6654 version = "2.1.1",
6655
6656 // Define a local copy of jQuery
6657 jQuery = function( selector, context ) {
6658 // The jQuery object is actually just the init constructor 'enhanced'
6659 // Need init if jQuery is called (just allow error to be thrown if not included)
6660 return new jQuery.fn.init( selector, context );
6661 },
6662
6663 // Support: Android<4.1
6664 // Make sure we trim BOM and NBSP
6665 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
6666
6667 // Matches dashed string for camelizing
6668 rmsPrefix = /^-ms-/,
6669 rdashAlpha = /-([\da-z])/gi,
6670
6671 // Used by jQuery.camelCase as callback to replace()
6672 fcamelCase = function( all, letter ) {
6673 return letter.toUpperCase();
6674 };
6675
6676 jQuery.fn = jQuery.prototype = {
6677 // The current version of jQuery being used
6678 jquery: version,
6679
6680 constructor: jQuery,
6681
6682 // Start with an empty selector
6683 selector: "",
6684
6685 // The default length of a jQuery object is 0
6686 length: 0,
6687
6688 toArray: function() {
6689 return slice.call( this );
6690 },
6691
6692 // Get the Nth element in the matched element set OR
6693 // Get the whole matched element set as a clean array
6694 get: function( num ) {
6695 return num != null ?
6696
6697 // Return just the one element from the set
6698 ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
6699
6700 // Return all the elements in a clean array
6701 slice.call( this );
6702 },
6703
6704 // Take an array of elements and push it onto the stack
6705 // (returning the new matched element set)
6706 pushStack: function( elems ) {
6707
6708 // Build a new jQuery matched element set
6709 var ret = jQuery.merge( this.constructor(), elems );
6710
6711 // Add the old object onto the stack (as a reference)
6712 ret.prevObject = this;
6713 ret.context = this.context;
6714
6715 // Return the newly-formed element set
6716 return ret;
6717 },
6718
6719 // Execute a callback for every element in the matched set.
6720 // (You can seed the arguments with an array of args, but this is
6721 // only used internally.)
6722 each: function( callback, args ) {
6723 return jQuery.each( this, callback, args );
6724 },
6725
6726 map: function( callback ) {
6727 return this.pushStack( jQuery.map(this, function( elem, i ) {
6728 return callback.call( elem, i, elem );
6729 }));
6730 },
6731
6732 slice: function() {
6733 return this.pushStack( slice.apply( this, arguments ) );
6734 },
6735
6736 first: function() {
6737 return this.eq( 0 );
6738 },
6739
6740 last: function() {
6741 return this.eq( -1 );
6742 },
6743
6744 eq: function( i ) {
6745 var len = this.length,
6746 j = +i + ( i < 0 ? len : 0 );
6747 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
6748 },
6749
6750 end: function() {
6751 return this.prevObject || this.constructor(null);
6752 },
6753
6754 // For internal use only.
6755 // Behaves like an Array's method, not like a jQuery method.
6756 push: push,
6757 sort: arr.sort,
6758 splice: arr.splice
6759 };
6760
6761 jQuery.extend = jQuery.fn.extend = function() {
6762 var options, name, src, copy, copyIsArray, clone,
6763 target = arguments[0] || {},
6764 i = 1,
6765 length = arguments.length,
6766 deep = false;
6767
6768 // Handle a deep copy situation
6769 if ( typeof target === "boolean" ) {
6770 deep = target;
6771
6772 // skip the boolean and the target
6773 target = arguments[ i ] || {};
6774 i++;
6775 }
6776
6777 // Handle case when target is a string or something (possible in deep copy)
6778 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
6779 target = {};
6780 }
6781
6782 // extend jQuery itself if only one argument is passed
6783 if ( i === length ) {
6784 target = this;
6785 i--;
6786 }
6787
6788 for ( ; i < length; i++ ) {
6789 // Only deal with non-null/undefined values
6790 if ( (options = arguments[ i ]) != null ) {
6791 // Extend the base object
6792 for ( name in options ) {
6793 src = target[ name ];
6794 copy = options[ name ];
6795
6796 // Prevent never-ending loop
6797 if ( target === copy ) {
6798 continue;
6799 }
6800
6801 // Recurse if we're merging plain objects or arrays
6802 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
6803 if ( copyIsArray ) {
6804 copyIsArray = false;
6805 clone = src && jQuery.isArray(src) ? src : [];
6806
6807 } else {
6808 clone = src && jQuery.isPlainObject(src) ? src : {};
6809 }
6810
6811 // Never move original objects, clone them
6812 target[ name ] = jQuery.extend( deep, clone, copy );
6813
6814 // Don't bring in undefined values
6815 } else if ( copy !== undefined ) {
6816 target[ name ] = copy;
6817 }
6818 }
6819 }
6820 }
6821
6822 // Return the modified object
6823 return target;
6824 };
6825
6826 jQuery.extend({
6827 // Unique for each copy of jQuery on the page
6828 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
6829
6830 // Assume jQuery is ready without the ready module
6831 isReady: true,
6832
6833 error: function( msg ) {
6834 throw new Error( msg );
6835 },
6836
6837 noop: function() {},
6838
6839 // See test/unit/core.js for details concerning isFunction.
6840 // Since version 1.3, DOM methods and functions like alert
6841 // aren't supported. They return false on IE (#2968).
6842 isFunction: function( obj ) {
6843 return jQuery.type(obj) === "function";
6844 },
6845
6846 isArray: Array.isArray,
6847
6848 isWindow: function( obj ) {
6849 return obj != null && obj === obj.window;
6850 },
6851
6852 isNumeric: function( obj ) {
6853 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
6854 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
6855 // subtraction forces infinities to NaN
6856 return !jQuery.isArray( obj ) && obj - parseFloat( obj ) >= 0;
6857 },
6858
6859 isPlainObject: function( obj ) {
6860 // Not plain objects:
6861 // - Any object or value whose internal [[Class]] property is not "[object Object]"
6862 // - DOM nodes
6863 // - window
6864 if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
6865 return false;
6866 }
6867
6868 if ( obj.constructor &&
6869 !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
6870 return false;
6871 }
6872
6873 // If the function hasn't returned already, we're confident that
6874 // |obj| is a plain object, created by {} or constructed with new Object
6875 return true;
6876 },
6877
6878 isEmptyObject: function( obj ) {
6879 var name;
6880 for ( name in obj ) {
6881 return false;
6882 }
6883 return true;
6884 },
6885
6886 type: function( obj ) {
6887 if ( obj == null ) {
6888 return obj + "";
6889 }
6890 // Support: Android < 4.0, iOS < 6 (functionish RegExp)
6891 return typeof obj === "object" || typeof obj === "function" ?
6892 class2type[ toString.call(obj) ] || "object" :
6893 typeof obj;
6894 },
6895
6896 // Evaluates a script in a global context
6897 globalEval: function( code ) {
6898 var script,
6899 indirect = eval;
6900
6901 code = jQuery.trim( code );
6902
6903 if ( code ) {
6904 // If the code includes a valid, prologue position
6905 // strict mode pragma, execute code by injecting a
6906 // script tag into the document.
6907 if ( code.indexOf("use strict") === 1 ) {
6908 script = document.createElement("script");
6909 script.text = code;
6910 document.head.appendChild( script ).parentNode.removeChild( script );
6911 } else {
6912 // Otherwise, avoid the DOM node creation, insertion
6913 // and removal by using an indirect global eval
6914 indirect( code );
6915 }
6916 }
6917 },
6918
6919 // Convert dashed to camelCase; used by the css and data modules
6920 // Microsoft forgot to hump their vendor prefix (#9572)
6921 camelCase: function( string ) {
6922 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
6923 },
6924
6925 nodeName: function( elem, name ) {
6926 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
6927 },
6928
6929 // args is for internal usage only
6930 each: function( obj, callback, args ) {
6931 var value,
6932 i = 0,
6933 length = obj.length,
6934 isArray = isArraylike( obj );
6935
6936 if ( args ) {
6937 if ( isArray ) {
6938 for ( ; i < length; i++ ) {
6939 value = callback.apply( obj[ i ], args );
6940
6941 if ( value === false ) {
6942 break;
6943 }
6944 }
6945 } else {
6946 for ( i in obj ) {
6947 value = callback.apply( obj[ i ], args );
6948
6949 if ( value === false ) {
6950 break;
6951 }
6952 }
6953 }
6954
6955 // A special, fast, case for the most common use of each
6956 } else {
6957 if ( isArray ) {
6958 for ( ; i < length; i++ ) {
6959 value = callback.call( obj[ i ], i, obj[ i ] );
6960
6961 if ( value === false ) {
6962 break;
6963 }
6964 }
6965 } else {
6966 for ( i in obj ) {
6967 value = callback.call( obj[ i ], i, obj[ i ] );
6968
6969 if ( value === false ) {
6970 break;
6971 }
6972 }
6973 }
6974 }
6975
6976 return obj;
6977 },
6978
6979 // Support: Android<4.1
6980 trim: function( text ) {
6981 return text == null ?
6982 "" :
6983 ( text + "" ).replace( rtrim, "" );
6984 },
6985
6986 // results is for internal usage only
6987 makeArray: function( arr, results ) {
6988 var ret = results || [];
6989
6990 if ( arr != null ) {
6991 if ( isArraylike( Object(arr) ) ) {
6992 jQuery.merge( ret,
6993 typeof arr === "string" ?
6994 [ arr ] : arr
6995 );
6996 } else {
6997 push.call( ret, arr );
6998 }
6999 }
7000
7001 return ret;
7002 },
7003
7004 inArray: function( elem, arr, i ) {
7005 return arr == null ? -1 : indexOf.call( arr, elem, i );
7006 },
7007
7008 merge: function( first, second ) {
7009 var len = +second.length,
7010 j = 0,
7011 i = first.length;
7012
7013 for ( ; j < len; j++ ) {
7014 first[ i++ ] = second[ j ];
7015 }
7016
7017 first.length = i;
7018
7019 return first;
7020 },
7021
7022 grep: function( elems, callback, invert ) {
7023 var callbackInverse,
7024 matches = [],
7025 i = 0,
7026 length = elems.length,
7027 callbackExpect = !invert;
7028
7029 // Go through the array, only saving the items
7030 // that pass the validator function
7031 for ( ; i < length; i++ ) {
7032 callbackInverse = !callback( elems[ i ], i );
7033 if ( callbackInverse !== callbackExpect ) {
7034 matches.push( elems[ i ] );
7035 }
7036 }
7037
7038 return matches;
7039 },
7040
7041 // arg is for internal usage only
7042 map: function( elems, callback, arg ) {
7043 var value,
7044 i = 0,
7045 length = elems.length,
7046 isArray = isArraylike( elems ),
7047 ret = [];
7048
7049 // Go through the array, translating each of the items to their new values
7050 if ( isArray ) {
7051 for ( ; i < length; i++ ) {
7052 value = callback( elems[ i ], i, arg );
7053
7054 if ( value != null ) {
7055 ret.push( value );
7056 }
7057 }
7058
7059 // Go through every key on the object,
7060 } else {
7061 for ( i in elems ) {
7062 value = callback( elems[ i ], i, arg );
7063
7064 if ( value != null ) {
7065 ret.push( value );
7066 }
7067 }
7068 }
7069
7070 // Flatten any nested arrays
7071 return concat.apply( [], ret );
7072 },
7073
7074 // A global GUID counter for objects
7075 guid: 1,
7076
7077 // Bind a function to a context, optionally partially applying any
7078 // arguments.
7079 proxy: function( fn, context ) {
7080 var tmp, args, proxy;
7081
7082 if ( typeof context === "string" ) {
7083 tmp = fn[ context ];
7084 context = fn;
7085 fn = tmp;
7086 }
7087
7088 // Quick check to determine if target is callable, in the spec
7089 // this throws a TypeError, but we will just return undefined.
7090 if ( !jQuery.isFunction( fn ) ) {
7091 return undefined;
7092 }
7093
7094 // Simulated bind
7095 args = slice.call( arguments, 2 );
7096 proxy = function() {
7097 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
7098 };
7099
7100 // Set the guid of unique handler to the same of original handler, so it can be removed
7101 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
7102
7103 return proxy;
7104 },
7105
7106 now: Date.now,
7107
7108 // jQuery.support is not used in Core but other projects attach their
7109 // properties to it so it needs to exist.
7110 support: support
7111 });
7112
7113 // Populate the class2type map
7114 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
7115 class2type[ "[object " + name + "]" ] = name.toLowerCase();
7116 });
7117
7118 function isArraylike( obj ) {
7119 var length = obj.length,
7120 type = jQuery.type( obj );
7121
7122 if ( type === "function" || jQuery.isWindow( obj ) ) {
7123 return false;
7124 }
7125
7126 if ( obj.nodeType === 1 && length ) {
7127 return true;
7128 }
7129
7130 return type === "array" || length === 0 ||
7131 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
7132 }
7133 var Sizzle =
7134 /*!
7135 * Sizzle CSS Selector Engine v1.10.19
7136 * http://sizzlejs.com/
7137 *
7138 * Copyright 2013 jQuery Foundation, Inc. and other contributors
7139 * Released under the MIT license
7140 * http://jquery.org/license
7141 *
7142 * Date: 2014-04-18
7143 */
7144 (function( window ) {
7145
7146 var i,
7147 support,
7148 Expr,
7149 getText,
7150 isXML,
7151 tokenize,
7152 compile,
7153 select,
7154 outermostContext,
7155 sortInput,
7156 hasDuplicate,
7157
7158 // Local document vars
7159 setDocument,
7160 document,
7161 docElem,
7162 documentIsHTML,
7163 rbuggyQSA,
7164 rbuggyMatches,
7165 matches,
7166 contains,
7167
7168 // Instance-specific data
7169 expando = "sizzle" + -(new Date()),
7170 preferredDoc = window.document,
7171 dirruns = 0,
7172 done = 0,
7173 classCache = createCache(),
7174 tokenCache = createCache(),
7175 compilerCache = createCache(),
7176 sortOrder = function( a, b ) {
7177 if ( a === b ) {
7178 hasDuplicate = true;
7179 }
7180 return 0;
7181 },
7182
7183 // General-purpose constants
7184 strundefined = typeof undefined,
7185 MAX_NEGATIVE = 1 << 31,
7186
7187 // Instance methods
7188 hasOwn = ({}).hasOwnProperty,
7189 arr = [],
7190 pop = arr.pop,
7191 push_native = arr.push,
7192 push = arr.push,
7193 slice = arr.slice,
7194 // Use a stripped-down indexOf if we can't use a native one
7195 indexOf = arr.indexOf || function( elem ) {
7196 var i = 0,
7197 len = this.length;
7198 for ( ; i < len; i++ ) {
7199 if ( this[i] === elem ) {
7200 return i;
7201 }
7202 }
7203 return -1;
7204 },
7205
7206 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
7207
7208 // Regular expressions
7209
7210 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
7211 whitespace = "[\\x20\\t\\r\\n\\f]",
7212 // http://www.w3.org/TR/css3-syntax/#characters
7213 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
7214
7215 // Loosely modeled on CSS identifier characters
7216 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
7217 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
7218 identifier = characterEncoding.replace( "w", "w#" ),
7219
7220 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
7221 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace +
7222 // Operator (capture 2)
7223 "*([*^$|!~]?=)" + whitespace +
7224 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
7225 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
7226 "*\\]",
7227
7228 pseudos = ":(" + characterEncoding + ")(?:\\((" +
7229 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
7230 // 1. quoted (capture 3; capture 4 or capture 5)
7231 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
7232 // 2. simple (capture 6)
7233 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
7234 // 3. anything else (capture 2)
7235 ".*" +
7236 ")\\)|)",
7237
7238 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
7239 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
7240
7241 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
7242 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
7243
7244 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
7245
7246 rpseudo = new RegExp( pseudos ),
7247 ridentifier = new RegExp( "^" + identifier + "$" ),
7248
7249 matchExpr = {
7250 "ID": new RegExp( "^#(" + characterEncoding + ")" ),
7251 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
7252 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
7253 "ATTR": new RegExp( "^" + attributes ),
7254 "PSEUDO": new RegExp( "^" + pseudos ),
7255 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
7256 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
7257 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
7258 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
7259 // For use in libraries implementing .is()
7260 // We use this for POS matching in `select`
7261 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
7262 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
7263 },
7264
7265 rinputs = /^(?:input|select|textarea|button)$/i,
7266 rheader = /^h\d$/i,
7267
7268 rnative = /^[^{]+\{\s*\[native \w/,
7269
7270 // Easily-parseable/retrievable ID or TAG or CLASS selectors
7271 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
7272
7273 rsibling = /[+~]/,
7274 rescape = /'|\\/g,
7275
7276 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
7277 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
7278 funescape = function( _, escaped, escapedWhitespace ) {
7279 var high = "0x" + escaped - 0x10000;
7280 // NaN means non-codepoint
7281 // Support: Firefox<24
7282 // Workaround erroneous numeric interpretation of +"0x"
7283 return high !== high || escapedWhitespace ?
7284 escaped :
7285 high < 0 ?
7286 // BMP codepoint
7287 String.fromCharCode( high + 0x10000 ) :
7288 // Supplemental Plane codepoint (surrogate pair)
7289 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
7290 };
7291
7292 // Optimize for push.apply( _, NodeList )
7293 try {
7294 push.apply(
7295 (arr = slice.call( preferredDoc.childNodes )),
7296 preferredDoc.childNodes
7297 );
7298 // Support: Android<4.0
7299 // Detect silently failing push.apply
7300 arr[ preferredDoc.childNodes.length ].nodeType;
7301 } catch ( e ) {
7302 push = { apply: arr.length ?
7303
7304 // Leverage slice if possible
7305 function( target, els ) {
7306 push_native.apply( target, slice.call(els) );
7307 } :
7308
7309 // Support: IE<9
7310 // Otherwise append directly
7311 function( target, els ) {
7312 var j = target.length,
7313 i = 0;
7314 // Can't trust NodeList.length
7315 while ( (target[j++] = els[i++]) ) {}
7316 target.length = j - 1;
7317 }
7318 };
7319 }
7320
7321 function Sizzle( selector, context, results, seed ) {
7322 var match, elem, m, nodeType,
7323 // QSA vars
7324 i, groups, old, nid, newContext, newSelector;
7325
7326 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
7327 setDocument( context );
7328 }
7329
7330 context = context || document;
7331 results = results || [];
7332
7333 if ( !selector || typeof selector !== "string" ) {
7334 return results;
7335 }
7336
7337 if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
7338 return [];
7339 }
7340
7341 if ( documentIsHTML && !seed ) {
7342
7343 // Shortcuts
7344 if ( (match = rquickExpr.exec( selector )) ) {
7345 // Speed-up: Sizzle("#ID")
7346 if ( (m = match[1]) ) {
7347 if ( nodeType === 9 ) {
7348 elem = context.getElementById( m );
7349 // Check parentNode to catch when Blackberry 4.6 returns
7350 // nodes that are no longer in the document (jQuery #6963)
7351 if ( elem && elem.parentNode ) {
7352 // Handle the case where IE, Opera, and Webkit return items
7353 // by name instead of ID
7354 if ( elem.id === m ) {
7355 results.push( elem );
7356 return results;
7357 }
7358 } else {
7359 return results;
7360 }
7361 } else {
7362 // Context is not a document
7363 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
7364 contains( context, elem ) && elem.id === m ) {
7365 results.push( elem );
7366 return results;
7367 }
7368 }
7369
7370 // Speed-up: Sizzle("TAG")
7371 } else if ( match[2] ) {
7372 push.apply( results, context.getElementsByTagName( selector ) );
7373 return results;
7374
7375 // Speed-up: Sizzle(".CLASS")
7376 } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
7377 push.apply( results, context.getElementsByClassName( m ) );
7378 return results;
7379 }
7380 }
7381
7382 // QSA path
7383 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
7384 nid = old = expando;
7385 newContext = context;
7386 newSelector = nodeType === 9 && selector;
7387
7388 // qSA works strangely on Element-rooted queries
7389 // We can work around this by specifying an extra ID on the root
7390 // and working up from there (Thanks to Andrew Dupont for the technique)
7391 // IE 8 doesn't work on object elements
7392 if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
7393 groups = tokenize( selector );
7394
7395 if ( (old = context.getAttribute("id")) ) {
7396 nid = old.replace( rescape, "\\$&" );
7397 } else {
7398 context.setAttribute( "id", nid );
7399 }
7400 nid = "[id='" + nid + "'] ";
7401
7402 i = groups.length;
7403 while ( i-- ) {
7404 groups[i] = nid + toSelector( groups[i] );
7405 }
7406 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
7407 newSelector = groups.join(",");
7408 }
7409
7410 if ( newSelector ) {
7411 try {
7412 push.apply( results,
7413 newContext.querySelectorAll( newSelector )
7414 );
7415 return results;
7416 } catch(qsaError) {
7417 } finally {
7418 if ( !old ) {
7419 context.removeAttribute("id");
7420 }
7421 }
7422 }
7423 }
7424 }
7425
7426 // All others
7427 return select( selector.replace( rtrim, "$1" ), context, results, seed );
7428 }
7429
7430 /**
7431 * Create key-value caches of limited size
7432 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
7433 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
7434 * deleting the oldest entry
7435 */
7436 function createCache() {
7437 var keys = [];
7438
7439 function cache( key, value ) {
7440 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
7441 if ( keys.push( key + " " ) > Expr.cacheLength ) {
7442 // Only keep the most recent entries
7443 delete cache[ keys.shift() ];
7444 }
7445 return (cache[ key + " " ] = value);
7446 }
7447 return cache;
7448 }
7449
7450 /**
7451 * Mark a function for special use by Sizzle
7452 * @param {Function} fn The function to mark
7453 */
7454 function markFunction( fn ) {
7455 fn[ expando ] = true;
7456 return fn;
7457 }
7458
7459 /**
7460 * Support testing using an element
7461 * @param {Function} fn Passed the created div and expects a boolean result
7462 */
7463 function assert( fn ) {
7464 var div = document.createElement("div");
7465
7466 try {
7467 return !!fn( div );
7468 } catch (e) {
7469 return false;
7470 } finally {
7471 // Remove from its parent by default
7472 if ( div.parentNode ) {
7473 div.parentNode.removeChild( div );
7474 }
7475 // release memory in IE
7476 div = null;
7477 }
7478 }
7479
7480 /**
7481 * Adds the same handler for all of the specified attrs
7482 * @param {String} attrs Pipe-separated list of attributes
7483 * @param {Function} handler The method that will be applied
7484 */
7485 function addHandle( attrs, handler ) {
7486 var arr = attrs.split("|"),
7487 i = attrs.length;
7488
7489 while ( i-- ) {
7490 Expr.attrHandle[ arr[i] ] = handler;
7491 }
7492 }
7493
7494 /**
7495 * Checks document order of two siblings
7496 * @param {Element} a
7497 * @param {Element} b
7498 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
7499 */
7500 function siblingCheck( a, b ) {
7501 var cur = b && a,
7502 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
7503 ( ~b.sourceIndex || MAX_NEGATIVE ) -
7504 ( ~a.sourceIndex || MAX_NEGATIVE );
7505
7506 // Use IE sourceIndex if available on both nodes
7507 if ( diff ) {
7508 return diff;
7509 }
7510
7511 // Check if b follows a
7512 if ( cur ) {
7513 while ( (cur = cur.nextSibling) ) {
7514 if ( cur === b ) {
7515 return -1;
7516 }
7517 }
7518 }
7519
7520 return a ? 1 : -1;
7521 }
7522
7523 /**
7524 * Returns a function to use in pseudos for input types
7525 * @param {String} type
7526 */
7527 function createInputPseudo( type ) {
7528 return function( elem ) {
7529 var name = elem.nodeName.toLowerCase();
7530 return name === "input" && elem.type === type;
7531 };
7532 }
7533
7534 /**
7535 * Returns a function to use in pseudos for buttons
7536 * @param {String} type
7537 */
7538 function createButtonPseudo( type ) {
7539 return function( elem ) {
7540 var name = elem.nodeName.toLowerCase();
7541 return (name === "input" || name === "button") && elem.type === type;
7542 };
7543 }
7544
7545 /**
7546 * Returns a function to use in pseudos for positionals
7547 * @param {Function} fn
7548 */
7549 function createPositionalPseudo( fn ) {
7550 return markFunction(function( argument ) {
7551 argument = +argument;
7552 return markFunction(function( seed, matches ) {
7553 var j,
7554 matchIndexes = fn( [], seed.length, argument ),
7555 i = matchIndexes.length;
7556
7557 // Match elements found at the specified indexes
7558 while ( i-- ) {
7559 if ( seed[ (j = matchIndexes[i]) ] ) {
7560 seed[j] = !(matches[j] = seed[j]);
7561 }
7562 }
7563 });
7564 });
7565 }
7566
7567 /**
7568 * Checks a node for validity as a Sizzle context
7569 * @param {Element|Object=} context
7570 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
7571 */
7572 function testContext( context ) {
7573 return context && typeof context.getElementsByTagName !== strundefined && context;
7574 }
7575
7576 // Expose support vars for convenience
7577 support = Sizzle.support = {};
7578
7579 /**
7580 * Detects XML nodes
7581 * @param {Element|Object} elem An element or a document
7582 * @returns {Boolean} True iff elem is a non-HTML XML node
7583 */
7584 isXML = Sizzle.isXML = function( elem ) {
7585 // documentElement is verified for cases where it doesn't yet exist
7586 // (such as loading iframes in IE - #4833)
7587 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
7588 return documentElement ? documentElement.nodeName !== "HTML" : false;
7589 };
7590
7591 /**
7592 * Sets document-related variables once based on the current document
7593 * @param {Element|Object} [doc] An element or document object to use to set the document
7594 * @returns {Object} Returns the current document
7595 */
7596 setDocument = Sizzle.setDocument = function( node ) {
7597 var hasCompare,
7598 doc = node ? node.ownerDocument || node : preferredDoc,
7599 parent = doc.defaultView;
7600
7601 // If no document and documentElement is available, return
7602 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
7603 return document;
7604 }
7605
7606 // Set our document
7607 document = doc;
7608 docElem = doc.documentElement;
7609
7610 // Support tests
7611 documentIsHTML = !isXML( doc );
7612
7613 // Support: IE>8
7614 // If iframe document is assigned to "document" variable and if iframe has been reloaded,
7615 // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
7616 // IE6-8 do not support the defaultView property so parent will be undefined
7617 if ( parent && parent !== parent.top ) {
7618 // IE11 does not have attachEvent, so all must suffer
7619 if ( parent.addEventListener ) {
7620 parent.addEventListener( "unload", function() {
7621 setDocument();
7622 }, false );
7623 } else if ( parent.attachEvent ) {
7624 parent.attachEvent( "onunload", function() {
7625 setDocument();
7626 });
7627 }
7628 }
7629
7630 /* Attributes
7631 ---------------------------------------------------------------------- */
7632
7633 // Support: IE<8
7634 // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
7635 support.attributes = assert(function( div ) {
7636 div.className = "i";
7637 return !div.getAttribute("className");
7638 });
7639
7640 /* getElement(s)By*
7641 ---------------------------------------------------------------------- */
7642
7643 // Check if getElementsByTagName("*") returns only elements
7644 support.getElementsByTagName = assert(function( div ) {
7645 div.appendChild( doc.createComment("") );
7646 return !div.getElementsByTagName("*").length;
7647 });
7648
7649 // Check if getElementsByClassName can be trusted
7650 support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
7651 div.innerHTML = "<div class='a'></div><div class='a i'></div>";
7652
7653 // Support: Safari<4
7654 // Catch class over-caching
7655 div.firstChild.className = "i";
7656 // Support: Opera<10
7657 // Catch gEBCN failure to find non-leading classes
7658 return div.getElementsByClassName("i").length === 2;
7659 });
7660
7661 // Support: IE<10
7662 // Check if getElementById returns elements by name
7663 // The broken getElementById methods don't pick up programatically-set names,
7664 // so use a roundabout getElementsByName test
7665 support.getById = assert(function( div ) {
7666 docElem.appendChild( div ).id = expando;
7667 return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
7668 });
7669
7670 // ID find and filter
7671 if ( support.getById ) {
7672 Expr.find["ID"] = function( id, context ) {
7673 if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
7674 var m = context.getElementById( id );
7675 // Check parentNode to catch when Blackberry 4.6 returns
7676 // nodes that are no longer in the document #6963
7677 return m && m.parentNode ? [ m ] : [];
7678 }
7679 };
7680 Expr.filter["ID"] = function( id ) {
7681 var attrId = id.replace( runescape, funescape );
7682 return function( elem ) {
7683 return elem.getAttribute("id") === attrId;
7684 };
7685 };
7686 } else {
7687 // Support: IE6/7
7688 // getElementById is not reliable as a find shortcut
7689 delete Expr.find["ID"];
7690
7691 Expr.filter["ID"] = function( id ) {
7692 var attrId = id.replace( runescape, funescape );
7693 return function( elem ) {
7694 var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
7695 return node && node.value === attrId;
7696 };
7697 };
7698 }
7699
7700 // Tag
7701 Expr.find["TAG"] = support.getElementsByTagName ?
7702 function( tag, context ) {
7703 if ( typeof context.getElementsByTagName !== strundefined ) {
7704 return context.getElementsByTagName( tag );
7705 }
7706 } :
7707 function( tag, context ) {
7708 var elem,
7709 tmp = [],
7710 i = 0,
7711 results = context.getElementsByTagName( tag );
7712
7713 // Filter out possible comments
7714 if ( tag === "*" ) {
7715 while ( (elem = results[i++]) ) {
7716 if ( elem.nodeType === 1 ) {
7717 tmp.push( elem );
7718 }
7719 }
7720
7721 return tmp;
7722 }
7723 return results;
7724 };
7725
7726 // Class
7727 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
7728 if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
7729 return context.getElementsByClassName( className );
7730 }
7731 };
7732
7733 /* QSA/matchesSelector
7734 ---------------------------------------------------------------------- */
7735
7736 // QSA and matchesSelector support
7737
7738 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
7739 rbuggyMatches = [];
7740
7741 // qSa(:focus) reports false when true (Chrome 21)
7742 // We allow this because of a bug in IE8/9 that throws an error
7743 // whenever `document.activeElement` is accessed on an iframe
7744 // So, we allow :focus to pass through QSA all the time to avoid the IE error
7745 // See http://bugs.jquery.com/ticket/13378
7746 rbuggyQSA = [];
7747
7748 if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
7749 // Build QSA regex
7750 // Regex strategy adopted from Diego Perini
7751 assert(function( div ) {
7752 // Select is set to empty string on purpose
7753 // This is to test IE's treatment of not explicitly
7754 // setting a boolean content attribute,
7755 // since its presence should be enough
7756 // http://bugs.jquery.com/ticket/12359
7757 div.innerHTML = "<select msallowclip=''><option selected=''></option></select>";
7758
7759 // Support: IE8, Opera 11-12.16
7760 // Nothing should be selected when empty strings follow ^= or $= or *=
7761 // The test attribute must be unknown in Opera but "safe" for WinRT
7762 // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
7763 if ( div.querySelectorAll("[msallowclip^='']").length ) {
7764 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
7765 }
7766
7767 // Support: IE8
7768 // Boolean attributes and "value" are not treated correctly
7769 if ( !div.querySelectorAll("[selected]").length ) {
7770 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
7771 }
7772
7773 // Webkit/Opera - :checked should return selected option elements
7774 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
7775 // IE8 throws error here and will not see later tests
7776 if ( !div.querySelectorAll(":checked").length ) {
7777 rbuggyQSA.push(":checked");
7778 }
7779 });
7780
7781 assert(function( div ) {
7782 // Support: Windows 8 Native Apps
7783 // The type and name attributes are restricted during .innerHTML assignment
7784 var input = doc.createElement("input");
7785 input.setAttribute( "type", "hidden" );
7786 div.appendChild( input ).setAttribute( "name", "D" );
7787
7788 // Support: IE8
7789 // Enforce case-sensitivity of name attribute
7790 if ( div.querySelectorAll("[name=d]").length ) {
7791 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
7792 }
7793
7794 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
7795 // IE8 throws error here and will not see later tests
7796 if ( !div.querySelectorAll(":enabled").length ) {
7797 rbuggyQSA.push( ":enabled", ":disabled" );
7798 }
7799
7800 // Opera 10-11 does not throw on post-comma invalid pseudos
7801 div.querySelectorAll("*,:x");
7802 rbuggyQSA.push(",.*:");
7803 });
7804 }
7805
7806 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
7807 docElem.webkitMatchesSelector ||
7808 docElem.mozMatchesSelector ||
7809 docElem.oMatchesSelector ||
7810 docElem.msMatchesSelector) )) ) {
7811
7812 assert(function( div ) {
7813 // Check to see if it's possible to do matchesSelector
7814 // on a disconnected node (IE 9)
7815 support.disconnectedMatch = matches.call( div, "div" );
7816
7817 // This should fail with an exception
7818 // Gecko does not error, returns false instead
7819 matches.call( div, "[s!='']:x" );
7820 rbuggyMatches.push( "!=", pseudos );
7821 });
7822 }
7823
7824 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
7825 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
7826
7827 /* Contains
7828 ---------------------------------------------------------------------- */
7829 hasCompare = rnative.test( docElem.compareDocumentPosition );
7830
7831 // Element contains another
7832 // Purposefully does not implement inclusive descendent
7833 // As in, an element does not contain itself
7834 contains = hasCompare || rnative.test( docElem.contains ) ?
7835 function( a, b ) {
7836 var adown = a.nodeType === 9 ? a.documentElement : a,
7837 bup = b && b.parentNode;
7838 return a === bup || !!( bup && bup.nodeType === 1 && (
7839 adown.contains ?
7840 adown.contains( bup ) :
7841 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
7842 ));
7843 } :
7844 function( a, b ) {
7845 if ( b ) {
7846 while ( (b = b.parentNode) ) {
7847 if ( b === a ) {
7848 return true;
7849 }
7850 }
7851 }
7852 return false;
7853 };
7854
7855 /* Sorting
7856 ---------------------------------------------------------------------- */
7857
7858 // Document order sorting
7859 sortOrder = hasCompare ?
7860 function( a, b ) {
7861
7862 // Flag for duplicate removal
7863 if ( a === b ) {
7864 hasDuplicate = true;
7865 return 0;
7866 }
7867
7868 // Sort on method existence if only one input has compareDocumentPosition
7869 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
7870 if ( compare ) {
7871 return compare;
7872 }
7873
7874 // Calculate position if both inputs belong to the same document
7875 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
7876 a.compareDocumentPosition( b ) :
7877
7878 // Otherwise we know they are disconnected
7879 1;
7880
7881 // Disconnected nodes
7882 if ( compare & 1 ||
7883 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
7884
7885 // Choose the first element that is related to our preferred document
7886 if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
7887 return -1;
7888 }
7889 if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
7890 return 1;
7891 }
7892
7893 // Maintain original order
7894 return sortInput ?
7895 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
7896 0;
7897 }
7898
7899 return compare & 4 ? -1 : 1;
7900 } :
7901 function( a, b ) {
7902 // Exit early if the nodes are identical
7903 if ( a === b ) {
7904 hasDuplicate = true;
7905 return 0;
7906 }
7907
7908 var cur,
7909 i = 0,
7910 aup = a.parentNode,
7911 bup = b.parentNode,
7912 ap = [ a ],
7913 bp = [ b ];
7914
7915 // Parentless nodes are either documents or disconnected
7916 if ( !aup || !bup ) {
7917 return a === doc ? -1 :
7918 b === doc ? 1 :
7919 aup ? -1 :
7920 bup ? 1 :
7921 sortInput ?
7922 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
7923 0;
7924
7925 // If the nodes are siblings, we can do a quick check
7926 } else if ( aup === bup ) {
7927 return siblingCheck( a, b );
7928 }
7929
7930 // Otherwise we need full lists of their ancestors for comparison
7931 cur = a;
7932 while ( (cur = cur.parentNode) ) {
7933 ap.unshift( cur );
7934 }
7935 cur = b;
7936 while ( (cur = cur.parentNode) ) {
7937 bp.unshift( cur );
7938 }
7939
7940 // Walk down the tree looking for a discrepancy
7941 while ( ap[i] === bp[i] ) {
7942 i++;
7943 }
7944
7945 return i ?
7946 // Do a sibling check if the nodes have a common ancestor
7947 siblingCheck( ap[i], bp[i] ) :
7948
7949 // Otherwise nodes in our document sort first
7950 ap[i] === preferredDoc ? -1 :
7951 bp[i] === preferredDoc ? 1 :
7952 0;
7953 };
7954
7955 return doc;
7956 };
7957
7958 Sizzle.matches = function( expr, elements ) {
7959 return Sizzle( expr, null, null, elements );
7960 };
7961
7962 Sizzle.matchesSelector = function( elem, expr ) {
7963 // Set document vars if needed
7964 if ( ( elem.ownerDocument || elem ) !== document ) {
7965 setDocument( elem );
7966 }
7967
7968 // Make sure that attribute selectors are quoted
7969 expr = expr.replace( rattributeQuotes, "='$1']" );
7970
7971 if ( support.matchesSelector && documentIsHTML &&
7972 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
7973 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
7974
7975 try {
7976 var ret = matches.call( elem, expr );
7977
7978 // IE 9's matchesSelector returns false on disconnected nodes
7979 if ( ret || support.disconnectedMatch ||
7980 // As well, disconnected nodes are said to be in a document
7981 // fragment in IE 9
7982 elem.document && elem.document.nodeType !== 11 ) {
7983 return ret;
7984 }
7985 } catch(e) {}
7986 }
7987
7988 return Sizzle( expr, document, null, [ elem ] ).length > 0;
7989 };
7990
7991 Sizzle.contains = function( context, elem ) {
7992 // Set document vars if needed
7993 if ( ( context.ownerDocument || context ) !== document ) {
7994 setDocument( context );
7995 }
7996 return contains( context, elem );
7997 };
7998
7999 Sizzle.attr = function( elem, name ) {
8000 // Set document vars if needed
8001 if ( ( elem.ownerDocument || elem ) !== document ) {
8002 setDocument( elem );
8003 }
8004
8005 var fn = Expr.attrHandle[ name.toLowerCase() ],
8006 // Don't get fooled by Object.prototype properties (jQuery #13807)
8007 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
8008 fn( elem, name, !documentIsHTML ) :
8009 undefined;
8010
8011 return val !== undefined ?
8012 val :
8013 support.attributes || !documentIsHTML ?
8014 elem.getAttribute( name ) :
8015 (val = elem.getAttributeNode(name)) && val.specified ?
8016 val.value :
8017 null;
8018 };
8019
8020 Sizzle.error = function( msg ) {
8021 throw new Error( "Syntax error, unrecognized expression: " + msg );
8022 };
8023
8024 /**
8025 * Document sorting and removing duplicates
8026 * @param {ArrayLike} results
8027 */
8028 Sizzle.uniqueSort = function( results ) {
8029 var elem,
8030 duplicates = [],
8031 j = 0,
8032 i = 0;
8033
8034 // Unless we *know* we can detect duplicates, assume their presence
8035 hasDuplicate = !support.detectDuplicates;
8036 sortInput = !support.sortStable && results.slice( 0 );
8037 results.sort( sortOrder );
8038
8039 if ( hasDuplicate ) {
8040 while ( (elem = results[i++]) ) {
8041 if ( elem === results[ i ] ) {
8042 j = duplicates.push( i );
8043 }
8044 }
8045 while ( j-- ) {
8046 results.splice( duplicates[ j ], 1 );
8047 }
8048 }
8049
8050 // Clear input after sorting to release objects
8051 // See https://github.com/jquery/sizzle/pull/225
8052 sortInput = null;
8053
8054 return results;
8055 };
8056
8057 /**
8058 * Utility function for retrieving the text value of an array of DOM nodes
8059 * @param {Array|Element} elem
8060 */
8061 getText = Sizzle.getText = function( elem ) {
8062 var node,
8063 ret = "",
8064 i = 0,
8065 nodeType = elem.nodeType;
8066
8067 if ( !nodeType ) {
8068 // If no nodeType, this is expected to be an array
8069 while ( (node = elem[i++]) ) {
8070 // Do not traverse comment nodes
8071 ret += getText( node );
8072 }
8073 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
8074 // Use textContent for elements
8075 // innerText usage removed for consistency of new lines (jQuery #11153)
8076 if ( typeof elem.textContent === "string" ) {
8077 return elem.textContent;
8078 } else {
8079 // Traverse its children
8080 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
8081 ret += getText( elem );
8082 }
8083 }
8084 } else if ( nodeType === 3 || nodeType === 4 ) {
8085 return elem.nodeValue;
8086 }
8087 // Do not include comment or processing instruction nodes
8088
8089 return ret;
8090 };
8091
8092 Expr = Sizzle.selectors = {
8093
8094 // Can be adjusted by the user
8095 cacheLength: 50,
8096
8097 createPseudo: markFunction,
8098
8099 match: matchExpr,
8100
8101 attrHandle: {},
8102
8103 find: {},
8104
8105 relative: {
8106 ">": { dir: "parentNode", first: true },
8107 " ": { dir: "parentNode" },
8108 "+": { dir: "previousSibling", first: true },
8109 "~": { dir: "previousSibling" }
8110 },
8111
8112 preFilter: {
8113 "ATTR": function( match ) {
8114 match[1] = match[1].replace( runescape, funescape );
8115
8116 // Move the given value to match[3] whether quoted or unquoted
8117 match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
8118
8119 if ( match[2] === "~=" ) {
8120 match[3] = " " + match[3] + " ";
8121 }
8122
8123 return match.slice( 0, 4 );
8124 },
8125
8126 "CHILD": function( match ) {
8127 /* matches from matchExpr["CHILD"]
8128 1 type (only|nth|...)
8129 2 what (child|of-type)
8130 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
8131 4 xn-component of xn+y argument ([+-]?\d*n|)
8132 5 sign of xn-component
8133 6 x of xn-component
8134 7 sign of y-component
8135 8 y of y-component
8136 */
8137 match[1] = match[1].toLowerCase();
8138
8139 if ( match[1].slice( 0, 3 ) === "nth" ) {
8140 // nth-* requires argument
8141 if ( !match[3] ) {
8142 Sizzle.error( match[0] );
8143 }
8144
8145 // numeric x and y parameters for Expr.filter.CHILD
8146 // remember that false/true cast respectively to 0/1
8147 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
8148 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
8149
8150 // other types prohibit arguments
8151 } else if ( match[3] ) {
8152 Sizzle.error( match[0] );
8153 }
8154
8155 return match;
8156 },
8157
8158 "PSEUDO": function( match ) {
8159 var excess,
8160 unquoted = !match[6] && match[2];
8161
8162 if ( matchExpr["CHILD"].test( match[0] ) ) {
8163 return null;
8164 }
8165
8166 // Accept quoted arguments as-is
8167 if ( match[3] ) {
8168 match[2] = match[4] || match[5] || "";
8169
8170 // Strip excess characters from unquoted arguments
8171 } else if ( unquoted && rpseudo.test( unquoted ) &&
8172 // Get excess from tokenize (recursively)
8173 (excess = tokenize( unquoted, true )) &&
8174 // advance to the next closing parenthesis
8175 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
8176
8177 // excess is a negative index
8178 match[0] = match[0].slice( 0, excess );
8179 match[2] = unquoted.slice( 0, excess );
8180 }
8181
8182 // Return only captures needed by the pseudo filter method (type and argument)
8183 return match.slice( 0, 3 );
8184 }
8185 },
8186
8187 filter: {
8188
8189 "TAG": function( nodeNameSelector ) {
8190 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
8191 return nodeNameSelector === "*" ?
8192 function() { return true; } :
8193 function( elem ) {
8194 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
8195 };
8196 },
8197
8198 "CLASS": function( className ) {
8199 var pattern = classCache[ className + " " ];
8200
8201 return pattern ||
8202 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
8203 classCache( className, function( elem ) {
8204 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
8205 });
8206 },
8207
8208 "ATTR": function( name, operator, check ) {
8209 return function( elem ) {
8210 var result = Sizzle.attr( elem, name );
8211
8212 if ( result == null ) {
8213 return operator === "!=";
8214 }
8215 if ( !operator ) {
8216 return true;
8217 }
8218
8219 result += "";
8220
8221 return operator === "=" ? result === check :
8222 operator === "!=" ? result !== check :
8223 operator === "^=" ? check && result.indexOf( check ) === 0 :
8224 operator === "*=" ? check && result.indexOf( check ) > -1 :
8225 operator === "$=" ? check && result.slice( -check.length ) === check :
8226 operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
8227 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
8228 false;
8229 };
8230 },
8231
8232 "CHILD": function( type, what, argument, first, last ) {
8233 var simple = type.slice( 0, 3 ) !== "nth",
8234 forward = type.slice( -4 ) !== "last",
8235 ofType = what === "of-type";
8236
8237 return first === 1 && last === 0 ?
8238
8239 // Shortcut for :nth-*(n)
8240 function( elem ) {
8241 return !!elem.parentNode;
8242 } :
8243
8244 function( elem, context, xml ) {
8245 var cache, outerCache, node, diff, nodeIndex, start,
8246 dir = simple !== forward ? "nextSibling" : "previousSibling",
8247 parent = elem.parentNode,
8248 name = ofType && elem.nodeName.toLowerCase(),
8249 useCache = !xml && !ofType;
8250
8251 if ( parent ) {
8252
8253 // :(first|last|only)-(child|of-type)
8254 if ( simple ) {
8255 while ( dir ) {
8256 node = elem;
8257 while ( (node = node[ dir ]) ) {
8258 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
8259 return false;
8260 }
8261 }
8262 // Reverse direction for :only-* (if we haven't yet done so)
8263 start = dir = type === "only" && !start && "nextSibling";
8264 }
8265 return true;
8266 }
8267
8268 start = [ forward ? parent.firstChild : parent.lastChild ];
8269
8270 // non-xml :nth-child(...) stores cache data on `parent`
8271 if ( forward && useCache ) {
8272 // Seek `elem` from a previously-cached index
8273 outerCache = parent[ expando ] || (parent[ expando ] = {});
8274 cache = outerCache[ type ] || [];
8275 nodeIndex = cache[0] === dirruns && cache[1];
8276 diff = cache[0] === dirruns && cache[2];
8277 node = nodeIndex && parent.childNodes[ nodeIndex ];
8278
8279 while ( (node = ++nodeIndex && node && node[ dir ] ||
8280
8281 // Fallback to seeking `elem` from the start
8282 (diff = nodeIndex = 0) || start.pop()) ) {
8283
8284 // When found, cache indexes on `parent` and break
8285 if ( node.nodeType === 1 && ++diff && node === elem ) {
8286 outerCache[ type ] = [ dirruns, nodeIndex, diff ];
8287 break;
8288 }
8289 }
8290
8291 // Use previously-cached element index if available
8292 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
8293 diff = cache[1];
8294
8295 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
8296 } else {
8297 // Use the same loop as above to seek `elem` from the start
8298 while ( (node = ++nodeIndex && node && node[ dir ] ||
8299 (diff = nodeIndex = 0) || start.pop()) ) {
8300
8301 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
8302 // Cache the index of each encountered element
8303 if ( useCache ) {
8304 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
8305 }
8306
8307 if ( node === elem ) {
8308 break;
8309 }
8310 }
8311 }
8312 }
8313
8314 // Incorporate the offset, then check against cycle size
8315 diff -= last;
8316 return diff === first || ( diff % first === 0 && diff / first >= 0 );
8317 }
8318 };
8319 },
8320
8321 "PSEUDO": function( pseudo, argument ) {
8322 // pseudo-class names are case-insensitive
8323 // http://www.w3.org/TR/selectors/#pseudo-classes
8324 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
8325 // Remember that setFilters inherits from pseudos
8326 var args,
8327 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
8328 Sizzle.error( "unsupported pseudo: " + pseudo );
8329
8330 // The user may use createPseudo to indicate that
8331 // arguments are needed to create the filter function
8332 // just as Sizzle does
8333 if ( fn[ expando ] ) {
8334 return fn( argument );
8335 }
8336
8337 // But maintain support for old signatures
8338 if ( fn.length > 1 ) {
8339 args = [ pseudo, pseudo, "", argument ];
8340 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
8341 markFunction(function( seed, matches ) {
8342 var idx,
8343 matched = fn( seed, argument ),
8344 i = matched.length;
8345 while ( i-- ) {
8346 idx = indexOf.call( seed, matched[i] );
8347 seed[ idx ] = !( matches[ idx ] = matched[i] );
8348 }
8349 }) :
8350 function( elem ) {
8351 return fn( elem, 0, args );
8352 };
8353 }
8354
8355 return fn;
8356 }
8357 },
8358
8359 pseudos: {
8360 // Potentially complex pseudos
8361 "not": markFunction(function( selector ) {
8362 // Trim the selector passed to compile
8363 // to avoid treating leading and trailing
8364 // spaces as combinators
8365 var input = [],
8366 results = [],
8367 matcher = compile( selector.replace( rtrim, "$1" ) );
8368
8369 return matcher[ expando ] ?
8370 markFunction(function( seed, matches, context, xml ) {
8371 var elem,
8372 unmatched = matcher( seed, null, xml, [] ),
8373 i = seed.length;
8374
8375 // Match elements unmatched by `matcher`
8376 while ( i-- ) {
8377 if ( (elem = unmatched[i]) ) {
8378 seed[i] = !(matches[i] = elem);
8379 }
8380 }
8381 }) :
8382 function( elem, context, xml ) {
8383 input[0] = elem;
8384 matcher( input, null, xml, results );
8385 return !results.pop();
8386 };
8387 }),
8388
8389 "has": markFunction(function( selector ) {
8390 return function( elem ) {
8391 return Sizzle( selector, elem ).length > 0;
8392 };
8393 }),
8394
8395 "contains": markFunction(function( text ) {
8396 return function( elem ) {
8397 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
8398 };
8399 }),
8400
8401 // "Whether an element is represented by a :lang() selector
8402 // is based solely on the element's language value
8403 // being equal to the identifier C,
8404 // or beginning with the identifier C immediately followed by "-".
8405 // The matching of C against the element's language value is performed case-insensitively.
8406 // The identifier C does not have to be a valid language name."
8407 // http://www.w3.org/TR/selectors/#lang-pseudo
8408 "lang": markFunction( function( lang ) {
8409 // lang value must be a valid identifier
8410 if ( !ridentifier.test(lang || "") ) {
8411 Sizzle.error( "unsupported lang: " + lang );
8412 }
8413 lang = lang.replace( runescape, funescape ).toLowerCase();
8414 return function( elem ) {
8415 var elemLang;
8416 do {
8417 if ( (elemLang = documentIsHTML ?
8418 elem.lang :
8419 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
8420
8421 elemLang = elemLang.toLowerCase();
8422 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
8423 }
8424 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
8425 return false;
8426 };
8427 }),
8428
8429 // Miscellaneous
8430 "target": function( elem ) {
8431 var hash = window.location && window.location.hash;
8432 return hash && hash.slice( 1 ) === elem.id;
8433 },
8434
8435 "root": function( elem ) {
8436 return elem === docElem;
8437 },
8438
8439 "focus": function( elem ) {
8440 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
8441 },
8442
8443 // Boolean properties
8444 "enabled": function( elem ) {
8445 return elem.disabled === false;
8446 },
8447
8448 "disabled": function( elem ) {
8449 return elem.disabled === true;
8450 },
8451
8452 "checked": function( elem ) {
8453 // In CSS3, :checked should return both checked and selected elements
8454 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
8455 var nodeName = elem.nodeName.toLowerCase();
8456 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
8457 },
8458
8459 "selected": function( elem ) {
8460 // Accessing this property makes selected-by-default
8461 // options in Safari work properly
8462 if ( elem.parentNode ) {
8463 elem.parentNode.selectedIndex;
8464 }
8465
8466 return elem.selected === true;
8467 },
8468
8469 // Contents
8470 "empty": function( elem ) {
8471 // http://www.w3.org/TR/selectors/#empty-pseudo
8472 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
8473 // but not by others (comment: 8; processing instruction: 7; etc.)
8474 // nodeType < 6 works because attributes (2) do not appear as children
8475 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
8476 if ( elem.nodeType < 6 ) {
8477 return false;
8478 }
8479 }
8480 return true;
8481 },
8482
8483 "parent": function( elem ) {
8484 return !Expr.pseudos["empty"]( elem );
8485 },
8486
8487 // Element/input types
8488 "header": function( elem ) {
8489 return rheader.test( elem.nodeName );
8490 },
8491
8492 "input": function( elem ) {
8493 return rinputs.test( elem.nodeName );
8494 },
8495
8496 "button": function( elem ) {
8497 var name = elem.nodeName.toLowerCase();
8498 return name === "input" && elem.type === "button" || name === "button";
8499 },
8500
8501 "text": function( elem ) {
8502 var attr;
8503 return elem.nodeName.toLowerCase() === "input" &&
8504 elem.type === "text" &&
8505
8506 // Support: IE<8
8507 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
8508 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
8509 },
8510
8511 // Position-in-collection
8512 "first": createPositionalPseudo(function() {
8513 return [ 0 ];
8514 }),
8515
8516 "last": createPositionalPseudo(function( matchIndexes, length ) {
8517 return [ length - 1 ];
8518 }),
8519
8520 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
8521 return [ argument < 0 ? argument + length : argument ];
8522 }),
8523
8524 "even": createPositionalPseudo(function( matchIndexes, length ) {
8525 var i = 0;
8526 for ( ; i < length; i += 2 ) {
8527 matchIndexes.push( i );
8528 }
8529 return matchIndexes;
8530 }),
8531
8532 "odd": createPositionalPseudo(function( matchIndexes, length ) {
8533 var i = 1;
8534 for ( ; i < length; i += 2 ) {
8535 matchIndexes.push( i );
8536 }
8537 return matchIndexes;
8538 }),
8539
8540 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
8541 var i = argument < 0 ? argument + length : argument;
8542 for ( ; --i >= 0; ) {
8543 matchIndexes.push( i );
8544 }
8545 return matchIndexes;
8546 }),
8547
8548 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
8549 var i = argument < 0 ? argument + length : argument;
8550 for ( ; ++i < length; ) {
8551 matchIndexes.push( i );
8552 }
8553 return matchIndexes;
8554 })
8555 }
8556 };
8557
8558 Expr.pseudos["nth"] = Expr.pseudos["eq"];
8559
8560 // Add button/input type pseudos
8561 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
8562 Expr.pseudos[ i ] = createInputPseudo( i );
8563 }
8564 for ( i in { submit: true, reset: true } ) {
8565 Expr.pseudos[ i ] = createButtonPseudo( i );
8566 }
8567
8568 // Easy API for creating new setFilters
8569 function setFilters() {}
8570 setFilters.prototype = Expr.filters = Expr.pseudos;
8571 Expr.setFilters = new setFilters();
8572
8573 tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
8574 var matched, match, tokens, type,
8575 soFar, groups, preFilters,
8576 cached = tokenCache[ selector + " " ];
8577
8578 if ( cached ) {
8579 return parseOnly ? 0 : cached.slice( 0 );
8580 }
8581
8582 soFar = selector;
8583 groups = [];
8584 preFilters = Expr.preFilter;
8585
8586 while ( soFar ) {
8587
8588 // Comma and first run
8589 if ( !matched || (match = rcomma.exec( soFar )) ) {
8590 if ( match ) {
8591 // Don't consume trailing commas as valid
8592 soFar = soFar.slice( match[0].length ) || soFar;
8593 }
8594 groups.push( (tokens = []) );
8595 }
8596
8597 matched = false;
8598
8599 // Combinators
8600 if ( (match = rcombinators.exec( soFar )) ) {
8601 matched = match.shift();
8602 tokens.push({
8603 value: matched,
8604 // Cast descendant combinators to space
8605 type: match[0].replace( rtrim, " " )
8606 });
8607 soFar = soFar.slice( matched.length );
8608 }
8609
8610 // Filters
8611 for ( type in Expr.filter ) {
8612 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
8613 (match = preFilters[ type ]( match ))) ) {
8614 matched = match.shift();
8615 tokens.push({
8616 value: matched,
8617 type: type,
8618 matches: match
8619 });
8620 soFar = soFar.slice( matched.length );
8621 }
8622 }
8623
8624 if ( !matched ) {
8625 break;
8626 }
8627 }
8628
8629 // Return the length of the invalid excess
8630 // if we're just parsing
8631 // Otherwise, throw an error or return tokens
8632 return parseOnly ?
8633 soFar.length :
8634 soFar ?
8635 Sizzle.error( selector ) :
8636 // Cache the tokens
8637 tokenCache( selector, groups ).slice( 0 );
8638 };
8639
8640 function toSelector( tokens ) {
8641 var i = 0,
8642 len = tokens.length,
8643 selector = "";
8644 for ( ; i < len; i++ ) {
8645 selector += tokens[i].value;
8646 }
8647 return selector;
8648 }
8649
8650 function addCombinator( matcher, combinator, base ) {
8651 var dir = combinator.dir,
8652 checkNonElements = base && dir === "parentNode",
8653 doneName = done++;
8654
8655 return combinator.first ?
8656 // Check against closest ancestor/preceding element
8657 function( elem, context, xml ) {
8658 while ( (elem = elem[ dir ]) ) {
8659 if ( elem.nodeType === 1 || checkNonElements ) {
8660 return matcher( elem, context, xml );
8661 }
8662 }
8663 } :
8664
8665 // Check against all ancestor/preceding elements
8666 function( elem, context, xml ) {
8667 var oldCache, outerCache,
8668 newCache = [ dirruns, doneName ];
8669
8670 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
8671 if ( xml ) {
8672 while ( (elem = elem[ dir ]) ) {
8673 if ( elem.nodeType === 1 || checkNonElements ) {
8674 if ( matcher( elem, context, xml ) ) {
8675 return true;
8676 }
8677 }
8678 }
8679 } else {
8680 while ( (elem = elem[ dir ]) ) {
8681 if ( elem.nodeType === 1 || checkNonElements ) {
8682 outerCache = elem[ expando ] || (elem[ expando ] = {});
8683 if ( (oldCache = outerCache[ dir ]) &&
8684 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
8685
8686 // Assign to newCache so results back-propagate to previous elements
8687 return (newCache[ 2 ] = oldCache[ 2 ]);
8688 } else {
8689 // Reuse newcache so results back-propagate to previous elements
8690 outerCache[ dir ] = newCache;
8691
8692 // A match means we're done; a fail means we have to keep checking
8693 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
8694 return true;
8695 }
8696 }
8697 }
8698 }
8699 }
8700 };
8701 }
8702
8703 function elementMatcher( matchers ) {
8704 return matchers.length > 1 ?
8705 function( elem, context, xml ) {
8706 var i = matchers.length;
8707 while ( i-- ) {
8708 if ( !matchers[i]( elem, context, xml ) ) {
8709 return false;
8710 }
8711 }
8712 return true;
8713 } :
8714 matchers[0];
8715 }
8716
8717 function multipleContexts( selector, contexts, results ) {
8718 var i = 0,
8719 len = contexts.length;
8720 for ( ; i < len; i++ ) {
8721 Sizzle( selector, contexts[i], results );
8722 }
8723 return results;
8724 }
8725
8726 function condense( unmatched, map, filter, context, xml ) {
8727 var elem,
8728 newUnmatched = [],
8729 i = 0,
8730 len = unmatched.length,
8731 mapped = map != null;
8732
8733 for ( ; i < len; i++ ) {
8734 if ( (elem = unmatched[i]) ) {
8735 if ( !filter || filter( elem, context, xml ) ) {
8736 newUnmatched.push( elem );
8737 if ( mapped ) {
8738 map.push( i );
8739 }
8740 }
8741 }
8742 }
8743
8744 return newUnmatched;
8745 }
8746
8747 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
8748 if ( postFilter && !postFilter[ expando ] ) {
8749 postFilter = setMatcher( postFilter );
8750 }
8751 if ( postFinder && !postFinder[ expando ] ) {
8752 postFinder = setMatcher( postFinder, postSelector );
8753 }
8754 return markFunction(function( seed, results, context, xml ) {
8755 var temp, i, elem,
8756 preMap = [],
8757 postMap = [],
8758 preexisting = results.length,
8759
8760 // Get initial elements from seed or context
8761 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
8762
8763 // Prefilter to get matcher input, preserving a map for seed-results synchronization
8764 matcherIn = preFilter && ( seed || !selector ) ?
8765 condense( elems, preMap, preFilter, context, xml ) :
8766 elems,
8767
8768 matcherOut = matcher ?
8769 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
8770 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
8771
8772 // ...intermediate processing is necessary
8773 [] :
8774
8775 // ...otherwise use results directly
8776 results :
8777 matcherIn;
8778
8779 // Find primary matches
8780 if ( matcher ) {
8781 matcher( matcherIn, matcherOut, context, xml );
8782 }
8783
8784 // Apply postFilter
8785 if ( postFilter ) {
8786 temp = condense( matcherOut, postMap );
8787 postFilter( temp, [], context, xml );
8788
8789 // Un-match failing elements by moving them back to matcherIn
8790 i = temp.length;
8791 while ( i-- ) {
8792 if ( (elem = temp[i]) ) {
8793 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
8794 }
8795 }
8796 }
8797
8798 if ( seed ) {
8799 if ( postFinder || preFilter ) {
8800 if ( postFinder ) {
8801 // Get the final matcherOut by condensing this intermediate into postFinder contexts
8802 temp = [];
8803 i = matcherOut.length;
8804 while ( i-- ) {
8805 if ( (elem = matcherOut[i]) ) {
8806 // Restore matcherIn since elem is not yet a final match
8807 temp.push( (matcherIn[i] = elem) );
8808 }
8809 }
8810 postFinder( null, (matcherOut = []), temp, xml );
8811 }
8812
8813 // Move matched elements from seed to results to keep them synchronized
8814 i = matcherOut.length;
8815 while ( i-- ) {
8816 if ( (elem = matcherOut[i]) &&
8817 (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
8818
8819 seed[temp] = !(results[temp] = elem);
8820 }
8821 }
8822 }
8823
8824 // Add elements to results, through postFinder if defined
8825 } else {
8826 matcherOut = condense(
8827 matcherOut === results ?
8828 matcherOut.splice( preexisting, matcherOut.length ) :
8829 matcherOut
8830 );
8831 if ( postFinder ) {
8832 postFinder( null, results, matcherOut, xml );
8833 } else {
8834 push.apply( results, matcherOut );
8835 }
8836 }
8837 });
8838 }
8839
8840 function matcherFromTokens( tokens ) {
8841 var checkContext, matcher, j,
8842 len = tokens.length,
8843 leadingRelative = Expr.relative[ tokens[0].type ],
8844 implicitRelative = leadingRelative || Expr.relative[" "],
8845 i = leadingRelative ? 1 : 0,
8846
8847 // The foundational matcher ensures that elements are reachable from top-level context(s)
8848 matchContext = addCombinator( function( elem ) {
8849 return elem === checkContext;
8850 }, implicitRelative, true ),
8851 matchAnyContext = addCombinator( function( elem ) {
8852 return indexOf.call( checkContext, elem ) > -1;
8853 }, implicitRelative, true ),
8854 matchers = [ function( elem, context, xml ) {
8855 return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
8856 (checkContext = context).nodeType ?
8857 matchContext( elem, context, xml ) :
8858 matchAnyContext( elem, context, xml ) );
8859 } ];
8860
8861 for ( ; i < len; i++ ) {
8862 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
8863 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
8864 } else {
8865 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
8866
8867 // Return special upon seeing a positional matcher
8868 if ( matcher[ expando ] ) {
8869 // Find the next relative operator (if any) for proper handling
8870 j = ++i;
8871 for ( ; j < len; j++ ) {
8872 if ( Expr.relative[ tokens[j].type ] ) {
8873 break;
8874 }
8875 }
8876 return setMatcher(
8877 i > 1 && elementMatcher( matchers ),
8878 i > 1 && toSelector(
8879 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
8880 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
8881 ).replace( rtrim, "$1" ),
8882 matcher,
8883 i < j && matcherFromTokens( tokens.slice( i, j ) ),
8884 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
8885 j < len && toSelector( tokens )
8886 );
8887 }
8888 matchers.push( matcher );
8889 }
8890 }
8891
8892 return elementMatcher( matchers );
8893 }
8894
8895 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
8896 var bySet = setMatchers.length > 0,
8897 byElement = elementMatchers.length > 0,
8898 superMatcher = function( seed, context, xml, results, outermost ) {
8899 var elem, j, matcher,
8900 matchedCount = 0,
8901 i = "0",
8902 unmatched = seed && [],
8903 setMatched = [],
8904 contextBackup = outermostContext,
8905 // We must always have either seed elements or outermost context
8906 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
8907 // Use integer dirruns iff this is the outermost matcher
8908 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
8909 len = elems.length;
8910
8911 if ( outermost ) {
8912 outermostContext = context !== document && context;
8913 }
8914
8915 // Add elements passing elementMatchers directly to results
8916 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
8917 // Support: IE<9, Safari
8918 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
8919 for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
8920 if ( byElement && elem ) {
8921 j = 0;
8922 while ( (matcher = elementMatchers[j++]) ) {
8923 if ( matcher( elem, context, xml ) ) {
8924 results.push( elem );
8925 break;
8926 }
8927 }
8928 if ( outermost ) {
8929 dirruns = dirrunsUnique;
8930 }
8931 }
8932
8933 // Track unmatched elements for set filters
8934 if ( bySet ) {
8935 // They will have gone through all possible matchers
8936 if ( (elem = !matcher && elem) ) {
8937 matchedCount--;
8938 }
8939
8940 // Lengthen the array for every element, matched or not
8941 if ( seed ) {
8942 unmatched.push( elem );
8943 }
8944 }
8945 }
8946
8947 // Apply set filters to unmatched elements
8948 matchedCount += i;
8949 if ( bySet && i !== matchedCount ) {
8950 j = 0;
8951 while ( (matcher = setMatchers[j++]) ) {
8952 matcher( unmatched, setMatched, context, xml );
8953 }
8954
8955 if ( seed ) {
8956 // Reintegrate element matches to eliminate the need for sorting
8957 if ( matchedCount > 0 ) {
8958 while ( i-- ) {
8959 if ( !(unmatched[i] || setMatched[i]) ) {
8960 setMatched[i] = pop.call( results );
8961 }
8962 }
8963 }
8964
8965 // Discard index placeholder values to get only actual matches
8966 setMatched = condense( setMatched );
8967 }
8968
8969 // Add matches to results
8970 push.apply( results, setMatched );
8971
8972 // Seedless set matches succeeding multiple successful matchers stipulate sorting
8973 if ( outermost && !seed && setMatched.length > 0 &&
8974 ( matchedCount + setMatchers.length ) > 1 ) {
8975
8976 Sizzle.uniqueSort( results );
8977 }
8978 }
8979
8980 // Override manipulation of globals by nested matchers
8981 if ( outermost ) {
8982 dirruns = dirrunsUnique;
8983 outermostContext = contextBackup;
8984 }
8985
8986 return unmatched;
8987 };
8988
8989 return bySet ?
8990 markFunction( superMatcher ) :
8991 superMatcher;
8992 }
8993
8994 compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
8995 var i,
8996 setMatchers = [],
8997 elementMatchers = [],
8998 cached = compilerCache[ selector + " " ];
8999
9000 if ( !cached ) {
9001 // Generate a function of recursive functions that can be used to check each element
9002 if ( !match ) {
9003 match = tokenize( selector );
9004 }
9005 i = match.length;
9006 while ( i-- ) {
9007 cached = matcherFromTokens( match[i] );
9008 if ( cached[ expando ] ) {
9009 setMatchers.push( cached );
9010 } else {
9011 elementMatchers.push( cached );
9012 }
9013 }
9014
9015 // Cache the compiled function
9016 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
9017
9018 // Save selector and tokenization
9019 cached.selector = selector;
9020 }
9021 return cached;
9022 };
9023
9024 /**
9025 * A low-level selection function that works with Sizzle's compiled
9026 * selector functions
9027 * @param {String|Function} selector A selector or a pre-compiled
9028 * selector function built with Sizzle.compile
9029 * @param {Element} context
9030 * @param {Array} [results]
9031 * @param {Array} [seed] A set of elements to match against
9032 */
9033 select = Sizzle.select = function( selector, context, results, seed ) {
9034 var i, tokens, token, type, find,
9035 compiled = typeof selector === "function" && selector,
9036 match = !seed && tokenize( (selector = compiled.selector || selector) );
9037
9038 results = results || [];
9039
9040 // Try to minimize operations if there is no seed and only one group
9041 if ( match.length === 1 ) {
9042
9043 // Take a shortcut and set the context if the root selector is an ID
9044 tokens = match[0] = match[0].slice( 0 );
9045 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
9046 support.getById && context.nodeType === 9 && documentIsHTML &&
9047 Expr.relative[ tokens[1].type ] ) {
9048
9049 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
9050 if ( !context ) {
9051 return results;
9052
9053 // Precompiled matchers will still verify ancestry, so step up a level
9054 } else if ( compiled ) {
9055 context = context.parentNode;
9056 }
9057
9058 selector = selector.slice( tokens.shift().value.length );
9059 }
9060
9061 // Fetch a seed set for right-to-left matching
9062 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
9063 while ( i-- ) {
9064 token = tokens[i];
9065
9066 // Abort if we hit a combinator
9067 if ( Expr.relative[ (type = token.type) ] ) {
9068 break;
9069 }
9070 if ( (find = Expr.find[ type ]) ) {
9071 // Search, expanding context for leading sibling combinators
9072 if ( (seed = find(
9073 token.matches[0].replace( runescape, funescape ),
9074 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
9075 )) ) {
9076
9077 // If seed is empty or no tokens remain, we can return early
9078 tokens.splice( i, 1 );
9079 selector = seed.length && toSelector( tokens );
9080 if ( !selector ) {
9081 push.apply( results, seed );
9082 return results;
9083 }
9084
9085 break;
9086 }
9087 }
9088 }
9089 }
9090
9091 // Compile and execute a filtering function if one is not provided
9092 // Provide `match` to avoid retokenization if we modified the selector above
9093 ( compiled || compile( selector, match ) )(
9094 seed,
9095 context,
9096 !documentIsHTML,
9097 results,
9098 rsibling.test( selector ) && testContext( context.parentNode ) || context
9099 );
9100 return results;
9101 };
9102
9103 // One-time assignments
9104
9105 // Sort stability
9106 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
9107
9108 // Support: Chrome<14
9109 // Always assume duplicates if they aren't passed to the comparison function
9110 support.detectDuplicates = !!hasDuplicate;
9111
9112 // Initialize against the default document
9113 setDocument();
9114
9115 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
9116 // Detached nodes confoundingly follow *each other*
9117 support.sortDetached = assert(function( div1 ) {
9118 // Should return 1, but returns 4 (following)
9119 return div1.compareDocumentPosition( document.createElement("div") ) & 1;
9120 });
9121
9122 // Support: IE<8
9123 // Prevent attribute/property "interpolation"
9124 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
9125 if ( !assert(function( div ) {
9126 div.innerHTML = "<a href='#'></a>";
9127 return div.firstChild.getAttribute("href") === "#" ;
9128 }) ) {
9129 addHandle( "type|href|height|width", function( elem, name, isXML ) {
9130 if ( !isXML ) {
9131 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
9132 }
9133 });
9134 }
9135
9136 // Support: IE<9
9137 // Use defaultValue in place of getAttribute("value")
9138 if ( !support.attributes || !assert(function( div ) {
9139 div.innerHTML = "<input/>";
9140 div.firstChild.setAttribute( "value", "" );
9141 return div.firstChild.getAttribute( "value" ) === "";
9142 }) ) {
9143 addHandle( "value", function( elem, name, isXML ) {
9144 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
9145 return elem.defaultValue;
9146 }
9147 });
9148 }
9149
9150 // Support: IE<9
9151 // Use getAttributeNode to fetch booleans when getAttribute lies
9152 if ( !assert(function( div ) {
9153 return div.getAttribute("disabled") == null;
9154 }) ) {
9155 addHandle( booleans, function( elem, name, isXML ) {
9156 var val;
9157 if ( !isXML ) {
9158 return elem[ name ] === true ? name.toLowerCase() :
9159 (val = elem.getAttributeNode( name )) && val.specified ?
9160 val.value :
9161 null;
9162 }
9163 });
9164 }
9165
9166 return Sizzle;
9167
9168 })( window );
9169
9170
9171
9172 jQuery.find = Sizzle;
9173 jQuery.expr = Sizzle.selectors;
9174 jQuery.expr[":"] = jQuery.expr.pseudos;
9175 jQuery.unique = Sizzle.uniqueSort;
9176 jQuery.text = Sizzle.getText;
9177 jQuery.isXMLDoc = Sizzle.isXML;
9178 jQuery.contains = Sizzle.contains;
9179
9180
9181
9182 var rneedsContext = jQuery.expr.match.needsContext;
9183
9184 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
9185
9186
9187
9188 var risSimple = /^.[^:#\[\.,]*$/;
9189
9190 // Implement the identical functionality for filter and not
9191 function winnow( elements, qualifier, not ) {
9192 if ( jQuery.isFunction( qualifier ) ) {
9193 return jQuery.grep( elements, function( elem, i ) {
9194 /* jshint -W018 */
9195 return !!qualifier.call( elem, i, elem ) !== not;
9196 });
9197
9198 }
9199
9200 if ( qualifier.nodeType ) {
9201 return jQuery.grep( elements, function( elem ) {
9202 return ( elem === qualifier ) !== not;
9203 });
9204
9205 }
9206
9207 if ( typeof qualifier === "string" ) {
9208 if ( risSimple.test( qualifier ) ) {
9209 return jQuery.filter( qualifier, elements, not );
9210 }
9211
9212 qualifier = jQuery.filter( qualifier, elements );
9213 }
9214
9215 return jQuery.grep( elements, function( elem ) {
9216 return ( indexOf.call( qualifier, elem ) >= 0 ) !== not;
9217 });
9218 }
9219
9220 jQuery.filter = function( expr, elems, not ) {
9221 var elem = elems[ 0 ];
9222
9223 if ( not ) {
9224 expr = ":not(" + expr + ")";
9225 }
9226
9227 return elems.length === 1 && elem.nodeType === 1 ?
9228 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
9229 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
9230 return elem.nodeType === 1;
9231 }));
9232 };
9233
9234 jQuery.fn.extend({
9235 find: function( selector ) {
9236 var i,
9237 len = this.length,
9238 ret = [],
9239 self = this;
9240
9241 if ( typeof selector !== "string" ) {
9242 return this.pushStack( jQuery( selector ).filter(function() {
9243 for ( i = 0; i < len; i++ ) {
9244 if ( jQuery.contains( self[ i ], this ) ) {
9245 return true;
9246 }
9247 }
9248 }) );
9249 }
9250
9251 for ( i = 0; i < len; i++ ) {
9252 jQuery.find( selector, self[ i ], ret );
9253 }
9254
9255 // Needed because $( selector, context ) becomes $( context ).find( selector )
9256 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
9257 ret.selector = this.selector ? this.selector + " " + selector : selector;
9258 return ret;
9259 },
9260 filter: function( selector ) {
9261 return this.pushStack( winnow(this, selector || [], false) );
9262 },
9263 not: function( selector ) {
9264 return this.pushStack( winnow(this, selector || [], true) );
9265 },
9266 is: function( selector ) {
9267 return !!winnow(
9268 this,
9269
9270 // If this is a positional/relative selector, check membership in the returned set
9271 // so $("p:first").is("p:last") won't return true for a doc with two "p".
9272 typeof selector === "string" && rneedsContext.test( selector ) ?
9273 jQuery( selector ) :
9274 selector || [],
9275 false
9276 ).length;
9277 }
9278 });
9279
9280
9281 // Initialize a jQuery object
9282
9283
9284 // A central reference to the root jQuery(document)
9285 var rootjQuery,
9286
9287 // A simple way to check for HTML strings
9288 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
9289 // Strict HTML recognition (#11290: must start with <)
9290 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
9291
9292 init = jQuery.fn.init = function( selector, context ) {
9293 var match, elem;
9294
9295 // HANDLE: $(""), $(null), $(undefined), $(false)
9296 if ( !selector ) {
9297 return this;
9298 }
9299
9300 // Handle HTML strings
9301 if ( typeof selector === "string" ) {
9302 if ( selector[0] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) {
9303 // Assume that strings that start and end with <> are HTML and skip the regex check
9304 match = [ null, selector, null ];
9305
9306 } else {
9307 match = rquickExpr.exec( selector );
9308 }
9309
9310 // Match html or make sure no context is specified for #id
9311 if ( match && (match[1] || !context) ) {
9312
9313 // HANDLE: $(html) -> $(array)
9314 if ( match[1] ) {
9315 context = context instanceof jQuery ? context[0] : context;
9316
9317 // scripts is true for back-compat
9318 // Intentionally let the error be thrown if parseHTML is not present
9319 jQuery.merge( this, jQuery.parseHTML(
9320 match[1],
9321 context && context.nodeType ? context.ownerDocument || context : document,
9322 true
9323 ) );
9324
9325 // HANDLE: $(html, props)
9326 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
9327 for ( match in context ) {
9328 // Properties of context are called as methods if possible
9329 if ( jQuery.isFunction( this[ match ] ) ) {
9330 this[ match ]( context[ match ] );
9331
9332 // ...and otherwise set as attributes
9333 } else {
9334 this.attr( match, context[ match ] );
9335 }
9336 }
9337 }
9338
9339 return this;
9340
9341 // HANDLE: $(#id)
9342 } else {
9343 elem = document.getElementById( match[2] );
9344
9345 // Check parentNode to catch when Blackberry 4.6 returns
9346 // nodes that are no longer in the document #6963
9347 if ( elem && elem.parentNode ) {
9348 // Inject the element directly into the jQuery object
9349 this.length = 1;
9350 this[0] = elem;
9351 }
9352
9353 this.context = document;
9354 this.selector = selector;
9355 return this;
9356 }
9357
9358 // HANDLE: $(expr, $(...))
9359 } else if ( !context || context.jquery ) {
9360 return ( context || rootjQuery ).find( selector );
9361
9362 // HANDLE: $(expr, context)
9363 // (which is just equivalent to: $(context).find(expr)
9364 } else {
9365 return this.constructor( context ).find( selector );
9366 }
9367
9368 // HANDLE: $(DOMElement)
9369 } else if ( selector.nodeType ) {
9370 this.context = this[0] = selector;
9371 this.length = 1;
9372 return this;
9373
9374 // HANDLE: $(function)
9375 // Shortcut for document ready
9376 } else if ( jQuery.isFunction( selector ) ) {
9377 return typeof rootjQuery.ready !== "undefined" ?
9378 rootjQuery.ready( selector ) :
9379 // Execute immediately if ready is not present
9380 selector( jQuery );
9381 }
9382
9383 if ( selector.selector !== undefined ) {
9384 this.selector = selector.selector;
9385 this.context = selector.context;
9386 }
9387
9388 return jQuery.makeArray( selector, this );
9389 };
9390
9391 // Give the init function the jQuery prototype for later instantiation
9392 init.prototype = jQuery.fn;
9393
9394 // Initialize central reference
9395 rootjQuery = jQuery( document );
9396
9397
9398 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
9399 // methods guaranteed to produce a unique set when starting from a unique set
9400 guaranteedUnique = {
9401 children: true,
9402 contents: true,
9403 next: true,
9404 prev: true
9405 };
9406
9407 jQuery.extend({
9408 dir: function( elem, dir, until ) {
9409 var matched = [],
9410 truncate = until !== undefined;
9411
9412 while ( (elem = elem[ dir ]) && elem.nodeType !== 9 ) {
9413 if ( elem.nodeType === 1 ) {
9414 if ( truncate && jQuery( elem ).is( until ) ) {
9415 break;
9416 }
9417 matched.push( elem );
9418 }
9419 }
9420 return matched;
9421 },
9422
9423 sibling: function( n, elem ) {
9424 var matched = [];
9425
9426 for ( ; n; n = n.nextSibling ) {
9427 if ( n.nodeType === 1 && n !== elem ) {
9428 matched.push( n );
9429 }
9430 }
9431
9432 return matched;
9433 }
9434 });
9435
9436 jQuery.fn.extend({
9437 has: function( target ) {
9438 var targets = jQuery( target, this ),
9439 l = targets.length;
9440
9441 return this.filter(function() {
9442 var i = 0;
9443 for ( ; i < l; i++ ) {
9444 if ( jQuery.contains( this, targets[i] ) ) {
9445 return true;
9446 }
9447 }
9448 });
9449 },
9450
9451 closest: function( selectors, context ) {
9452 var cur,
9453 i = 0,
9454 l = this.length,
9455 matched = [],
9456 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
9457 jQuery( selectors, context || this.context ) :
9458 0;
9459
9460 for ( ; i < l; i++ ) {
9461 for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
9462 // Always skip document fragments
9463 if ( cur.nodeType < 11 && (pos ?
9464 pos.index(cur) > -1 :
9465
9466 // Don't pass non-elements to Sizzle
9467 cur.nodeType === 1 &&
9468 jQuery.find.matchesSelector(cur, selectors)) ) {
9469
9470 matched.push( cur );
9471 break;
9472 }
9473 }
9474 }
9475
9476 return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
9477 },
9478
9479 // Determine the position of an element within
9480 // the matched set of elements
9481 index: function( elem ) {
9482
9483 // No argument, return index in parent
9484 if ( !elem ) {
9485 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
9486 }
9487
9488 // index in selector
9489 if ( typeof elem === "string" ) {
9490 return indexOf.call( jQuery( elem ), this[ 0 ] );
9491 }
9492
9493 // Locate the position of the desired element
9494 return indexOf.call( this,
9495
9496 // If it receives a jQuery object, the first element is used
9497 elem.jquery ? elem[ 0 ] : elem
9498 );
9499 },
9500
9501 add: function( selector, context ) {
9502 return this.pushStack(
9503 jQuery.unique(
9504 jQuery.merge( this.get(), jQuery( selector, context ) )
9505 )
9506 );
9507 },
9508
9509 addBack: function( selector ) {
9510 return this.add( selector == null ?
9511 this.prevObject : this.prevObject.filter(selector)
9512 );
9513 }
9514 });
9515
9516 function sibling( cur, dir ) {
9517 while ( (cur = cur[dir]) && cur.nodeType !== 1 ) {}
9518 return cur;
9519 }
9520
9521 jQuery.each({
9522 parent: function( elem ) {
9523 var parent = elem.parentNode;
9524 return parent && parent.nodeType !== 11 ? parent : null;
9525 },
9526 parents: function( elem ) {
9527 return jQuery.dir( elem, "parentNode" );
9528 },
9529 parentsUntil: function( elem, i, until ) {
9530 return jQuery.dir( elem, "parentNode", until );
9531 },
9532 next: function( elem ) {
9533 return sibling( elem, "nextSibling" );
9534 },
9535 prev: function( elem ) {
9536 return sibling( elem, "previousSibling" );
9537 },
9538 nextAll: function( elem ) {
9539 return jQuery.dir( elem, "nextSibling" );
9540 },
9541 prevAll: function( elem ) {
9542 return jQuery.dir( elem, "previousSibling" );
9543 },
9544 nextUntil: function( elem, i, until ) {
9545 return jQuery.dir( elem, "nextSibling", until );
9546 },
9547 prevUntil: function( elem, i, until ) {
9548 return jQuery.dir( elem, "previousSibling", until );
9549 },
9550 siblings: function( elem ) {
9551 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
9552 },
9553 children: function( elem ) {
9554 return jQuery.sibling( elem.firstChild );
9555 },
9556 contents: function( elem ) {
9557 return elem.contentDocument || jQuery.merge( [], elem.childNodes );
9558 }
9559 }, function( name, fn ) {
9560 jQuery.fn[ name ] = function( until, selector ) {
9561 var matched = jQuery.map( this, fn, until );
9562
9563 if ( name.slice( -5 ) !== "Until" ) {
9564 selector = until;
9565 }
9566
9567 if ( selector && typeof selector === "string" ) {
9568 matched = jQuery.filter( selector, matched );
9569 }
9570
9571 if ( this.length > 1 ) {
9572 // Remove duplicates
9573 if ( !guaranteedUnique[ name ] ) {
9574 jQuery.unique( matched );
9575 }
9576
9577 // Reverse order for parents* and prev-derivatives
9578 if ( rparentsprev.test( name ) ) {
9579 matched.reverse();
9580 }
9581 }
9582
9583 return this.pushStack( matched );
9584 };
9585 });
9586 var rnotwhite = (/\S+/g);
9587
9588
9589
9590 // String to Object options format cache
9591 var optionsCache = {};
9592
9593 // Convert String-formatted options into Object-formatted ones and store in cache
9594 function createOptions( options ) {
9595 var object = optionsCache[ options ] = {};
9596 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
9597 object[ flag ] = true;
9598 });
9599 return object;
9600 }
9601
9602 /*
9603 * Create a callback list using the following parameters:
9604 *
9605 * options: an optional list of space-separated options that will change how
9606 * the callback list behaves or a more traditional option object
9607 *
9608 * By default a callback list will act like an event callback list and can be
9609 * "fired" multiple times.
9610 *
9611 * Possible options:
9612 *
9613 * once: will ensure the callback list can only be fired once (like a Deferred)
9614 *
9615 * memory: will keep track of previous values and will call any callback added
9616 * after the list has been fired right away with the latest "memorized"
9617 * values (like a Deferred)
9618 *
9619 * unique: will ensure a callback can only be added once (no duplicate in the list)
9620 *
9621 * stopOnFalse: interrupt callings when a callback returns false
9622 *
9623 */
9624 jQuery.Callbacks = function( options ) {
9625
9626 // Convert options from String-formatted to Object-formatted if needed
9627 // (we check in cache first)
9628 options = typeof options === "string" ?
9629 ( optionsCache[ options ] || createOptions( options ) ) :
9630 jQuery.extend( {}, options );
9631
9632 var // Last fire value (for non-forgettable lists)
9633 memory,
9634 // Flag to know if list was already fired
9635 fired,
9636 // Flag to know if list is currently firing
9637 firing,
9638 // First callback to fire (used internally by add and fireWith)
9639 firingStart,
9640 // End of the loop when firing
9641 firingLength,
9642 // Index of currently firing callback (modified by remove if needed)
9643 firingIndex,
9644 // Actual callback list
9645 list = [],
9646 // Stack of fire calls for repeatable lists
9647 stack = !options.once && [],
9648 // Fire callbacks
9649 fire = function( data ) {
9650 memory = options.memory && data;
9651 fired = true;
9652 firingIndex = firingStart || 0;
9653 firingStart = 0;
9654 firingLength = list.length;
9655 firing = true;
9656 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
9657 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
9658 memory = false; // To prevent further calls using add
9659 break;
9660 }
9661 }
9662 firing = false;
9663 if ( list ) {
9664 if ( stack ) {
9665 if ( stack.length ) {
9666 fire( stack.shift() );
9667 }
9668 } else if ( memory ) {
9669 list = [];
9670 } else {
9671 self.disable();
9672 }
9673 }
9674 },
9675 // Actual Callbacks object
9676 self = {
9677 // Add a callback or a collection of callbacks to the list
9678 add: function() {
9679 if ( list ) {
9680 // First, we save the current length
9681 var start = list.length;
9682 (function add( args ) {
9683 jQuery.each( args, function( _, arg ) {
9684 var type = jQuery.type( arg );
9685 if ( type === "function" ) {
9686 if ( !options.unique || !self.has( arg ) ) {
9687 list.push( arg );
9688 }
9689 } else if ( arg && arg.length && type !== "string" ) {
9690 // Inspect recursively
9691 add( arg );
9692 }
9693 });
9694 })( arguments );
9695 // Do we need to add the callbacks to the
9696 // current firing batch?
9697 if ( firing ) {
9698 firingLength = list.length;
9699 // With memory, if we're not firing then
9700 // we should call right away
9701 } else if ( memory ) {
9702 firingStart = start;
9703 fire( memory );
9704 }
9705 }
9706 return this;
9707 },
9708 // Remove a callback from the list
9709 remove: function() {
9710 if ( list ) {
9711 jQuery.each( arguments, function( _, arg ) {
9712 var index;
9713 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
9714 list.splice( index, 1 );
9715 // Handle firing indexes
9716 if ( firing ) {
9717 if ( index <= firingLength ) {
9718 firingLength--;
9719 }
9720 if ( index <= firingIndex ) {
9721 firingIndex--;
9722 }
9723 }
9724 }
9725 });
9726 }
9727 return this;
9728 },
9729 // Check if a given callback is in the list.
9730 // If no argument is given, return whether or not list has callbacks attached.
9731 has: function( fn ) {
9732 return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
9733 },
9734 // Remove all callbacks from the list
9735 empty: function() {
9736 list = [];
9737 firingLength = 0;
9738 return this;
9739 },
9740 // Have the list do nothing anymore
9741 disable: function() {
9742 list = stack = memory = undefined;
9743 return this;
9744 },
9745 // Is it disabled?
9746 disabled: function() {
9747 return !list;
9748 },
9749 // Lock the list in its current state
9750 lock: function() {
9751 stack = undefined;
9752 if ( !memory ) {
9753 self.disable();
9754 }
9755 return this;
9756 },
9757 // Is it locked?
9758 locked: function() {
9759 return !stack;
9760 },
9761 // Call all callbacks with the given context and arguments
9762 fireWith: function( context, args ) {
9763 if ( list && ( !fired || stack ) ) {
9764 args = args || [];
9765 args = [ context, args.slice ? args.slice() : args ];
9766 if ( firing ) {
9767 stack.push( args );
9768 } else {
9769 fire( args );
9770 }
9771 }
9772 return this;
9773 },
9774 // Call all the callbacks with the given arguments
9775 fire: function() {
9776 self.fireWith( this, arguments );
9777 return this;
9778 },
9779 // To know if the callbacks have already been called at least once
9780 fired: function() {
9781 return !!fired;
9782 }
9783 };
9784
9785 return self;
9786 };
9787
9788
9789 jQuery.extend({
9790
9791 Deferred: function( func ) {
9792 var tuples = [
9793 // action, add listener, listener list, final state
9794 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
9795 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
9796 [ "notify", "progress", jQuery.Callbacks("memory") ]
9797 ],
9798 state = "pending",
9799 promise = {
9800 state: function() {
9801 return state;
9802 },
9803 always: function() {
9804 deferred.done( arguments ).fail( arguments );
9805 return this;
9806 },
9807 then: function( /* fnDone, fnFail, fnProgress */ ) {
9808 var fns = arguments;
9809 return jQuery.Deferred(function( newDefer ) {
9810 jQuery.each( tuples, function( i, tuple ) {
9811 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
9812 // deferred[ done | fail | progress ] for forwarding actions to newDefer
9813 deferred[ tuple[1] ](function() {
9814 var returned = fn && fn.apply( this, arguments );
9815 if ( returned && jQuery.isFunction( returned.promise ) ) {
9816 returned.promise()
9817 .done( newDefer.resolve )
9818 .fail( newDefer.reject )
9819 .progress( newDefer.notify );
9820 } else {
9821 newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
9822 }
9823 });
9824 });
9825 fns = null;
9826 }).promise();
9827 },
9828 // Get a promise for this deferred
9829 // If obj is provided, the promise aspect is added to the object
9830 promise: function( obj ) {
9831 return obj != null ? jQuery.extend( obj, promise ) : promise;
9832 }
9833 },
9834 deferred = {};
9835
9836 // Keep pipe for back-compat
9837 promise.pipe = promise.then;
9838
9839 // Add list-specific methods
9840 jQuery.each( tuples, function( i, tuple ) {
9841 var list = tuple[ 2 ],
9842 stateString = tuple[ 3 ];
9843
9844 // promise[ done | fail | progress ] = list.add
9845 promise[ tuple[1] ] = list.add;
9846
9847 // Handle state
9848 if ( stateString ) {
9849 list.add(function() {
9850 // state = [ resolved | rejected ]
9851 state = stateString;
9852
9853 // [ reject_list | resolve_list ].disable; progress_list.lock
9854 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
9855 }
9856
9857 // deferred[ resolve | reject | notify ]
9858 deferred[ tuple[0] ] = function() {
9859 deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
9860 return this;
9861 };
9862 deferred[ tuple[0] + "With" ] = list.fireWith;
9863 });
9864
9865 // Make the deferred a promise
9866 promise.promise( deferred );
9867
9868 // Call given func if any
9869 if ( func ) {
9870 func.call( deferred, deferred );
9871 }
9872
9873 // All done!
9874 return deferred;
9875 },
9876
9877 // Deferred helper
9878 when: function( subordinate /* , ..., subordinateN */ ) {
9879 var i = 0,
9880 resolveValues = slice.call( arguments ),
9881 length = resolveValues.length,
9882
9883 // the count of uncompleted subordinates
9884 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
9885
9886 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
9887 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
9888
9889 // Update function for both resolve and progress values
9890 updateFunc = function( i, contexts, values ) {
9891 return function( value ) {
9892 contexts[ i ] = this;
9893 values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
9894 if ( values === progressValues ) {
9895 deferred.notifyWith( contexts, values );
9896 } else if ( !( --remaining ) ) {
9897 deferred.resolveWith( contexts, values );
9898 }
9899 };
9900 },
9901
9902 progressValues, progressContexts, resolveContexts;
9903
9904 // add listeners to Deferred subordinates; treat others as resolved
9905 if ( length > 1 ) {
9906 progressValues = new Array( length );
9907 progressContexts = new Array( length );
9908 resolveContexts = new Array( length );
9909 for ( ; i < length; i++ ) {
9910 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
9911 resolveValues[ i ].promise()
9912 .done( updateFunc( i, resolveContexts, resolveValues ) )
9913 .fail( deferred.reject )
9914 .progress( updateFunc( i, progressContexts, progressValues ) );
9915 } else {
9916 --remaining;
9917 }
9918 }
9919 }
9920
9921 // if we're not waiting on anything, resolve the master
9922 if ( !remaining ) {
9923 deferred.resolveWith( resolveContexts, resolveValues );
9924 }
9925
9926 return deferred.promise();
9927 }
9928 });
9929
9930
9931 // The deferred used on DOM ready
9932 var readyList;
9933
9934 jQuery.fn.ready = function( fn ) {
9935 // Add the callback
9936 jQuery.ready.promise().done( fn );
9937
9938 return this;
9939 };
9940
9941 jQuery.extend({
9942 // Is the DOM ready to be used? Set to true once it occurs.
9943 isReady: false,
9944
9945 // A counter to track how many items to wait for before
9946 // the ready event fires. See #6781
9947 readyWait: 1,
9948
9949 // Hold (or release) the ready event
9950 holdReady: function( hold ) {
9951 if ( hold ) {
9952 jQuery.readyWait++;
9953 } else {
9954 jQuery.ready( true );
9955 }
9956 },
9957
9958 // Handle when the DOM is ready
9959 ready: function( wait ) {
9960
9961 // Abort if there are pending holds or we're already ready
9962 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
9963 return;
9964 }
9965
9966 // Remember that the DOM is ready
9967 jQuery.isReady = true;
9968
9969 // If a normal DOM Ready event fired, decrement, and wait if need be
9970 if ( wait !== true && --jQuery.readyWait > 0 ) {
9971 return;
9972 }
9973
9974 // If there are functions bound, to execute
9975 readyList.resolveWith( document, [ jQuery ] );
9976
9977 // Trigger any bound ready events
9978 if ( jQuery.fn.triggerHandler ) {
9979 jQuery( document ).triggerHandler( "ready" );
9980 jQuery( document ).off( "ready" );
9981 }
9982 }
9983 });
9984
9985 /**
9986 * The ready event handler and self cleanup method
9987 */
9988 function completed() {
9989 document.removeEventListener( "DOMContentLoaded", completed, false );
9990 window.removeEventListener( "load", completed, false );
9991 jQuery.ready();
9992 }
9993
9994 jQuery.ready.promise = function( obj ) {
9995 if ( !readyList ) {
9996
9997 readyList = jQuery.Deferred();
9998
9999 // Catch cases where $(document).ready() is called after the browser event has already occurred.
10000 // we once tried to use readyState "interactive" here, but it caused issues like the one
10001 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
10002 if ( document.readyState === "complete" ) {
10003 // Handle it asynchronously to allow scripts the opportunity to delay ready
10004 setTimeout( jQuery.ready );
10005
10006 } else {
10007
10008 // Use the handy event callback
10009 document.addEventListener( "DOMContentLoaded", completed, false );
10010
10011 // A fallback to window.onload, that will always work
10012 window.addEventListener( "load", completed, false );
10013 }
10014 }
10015 return readyList.promise( obj );
10016 };
10017
10018 // Kick off the DOM ready check even if the user does not
10019 jQuery.ready.promise();
10020
10021
10022
10023
10024 // Multifunctional method to get and set values of a collection
10025 // The value/s can optionally be executed if it's a function
10026 var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
10027 var i = 0,
10028 len = elems.length,
10029 bulk = key == null;
10030
10031 // Sets many values
10032 if ( jQuery.type( key ) === "object" ) {
10033 chainable = true;
10034 for ( i in key ) {
10035 jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
10036 }
10037
10038 // Sets one value
10039 } else if ( value !== undefined ) {
10040 chainable = true;
10041
10042 if ( !jQuery.isFunction( value ) ) {
10043 raw = true;
10044 }
10045
10046 if ( bulk ) {
10047 // Bulk operations run against the entire set
10048 if ( raw ) {
10049 fn.call( elems, value );
10050 fn = null;
10051
10052 // ...except when executing function values
10053 } else {
10054 bulk = fn;
10055 fn = function( elem, key, value ) {
10056 return bulk.call( jQuery( elem ), value );
10057 };
10058 }
10059 }
10060
10061 if ( fn ) {
10062 for ( ; i < len; i++ ) {
10063 fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
10064 }
10065 }
10066 }
10067
10068 return chainable ?
10069 elems :
10070
10071 // Gets
10072 bulk ?
10073 fn.call( elems ) :
10074 len ? fn( elems[0], key ) : emptyGet;
10075 };
10076
10077
10078 /**
10079 * Determines whether an object can have data
10080 */
10081 jQuery.acceptData = function( owner ) {
10082 // Accepts only:
10083 // - Node
10084 // - Node.ELEMENT_NODE
10085 // - Node.DOCUMENT_NODE
10086 // - Object
10087 // - Any
10088 /* jshint -W018 */
10089 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
10090 };
10091
10092
10093 function Data() {
10094 // Support: Android < 4,
10095 // Old WebKit does not have Object.preventExtensions/freeze method,
10096 // return new empty object instead with no [[set]] accessor
10097 Object.defineProperty( this.cache = {}, 0, {
10098 get: function() {
10099 return {};
10100 }
10101 });
10102
10103 this.expando = jQuery.expando + Math.random();
10104 }
10105
10106 Data.uid = 1;
10107 Data.accepts = jQuery.acceptData;
10108
10109 Data.prototype = {
10110 key: function( owner ) {
10111 // We can accept data for non-element nodes in modern browsers,
10112 // but we should not, see #8335.
10113 // Always return the key for a frozen object.
10114 if ( !Data.accepts( owner ) ) {
10115 return 0;
10116 }
10117
10118 var descriptor = {},
10119 // Check if the owner object already has a cache key
10120 unlock = owner[ this.expando ];
10121
10122 // If not, create one
10123 if ( !unlock ) {
10124 unlock = Data.uid++;
10125
10126 // Secure it in a non-enumerable, non-writable property
10127 try {
10128 descriptor[ this.expando ] = { value: unlock };
10129 Object.defineProperties( owner, descriptor );
10130
10131 // Support: Android < 4
10132 // Fallback to a less secure definition
10133 } catch ( e ) {
10134 descriptor[ this.expando ] = unlock;
10135 jQuery.extend( owner, descriptor );
10136 }
10137 }
10138
10139 // Ensure the cache object
10140 if ( !this.cache[ unlock ] ) {
10141 this.cache[ unlock ] = {};
10142 }
10143
10144 return unlock;
10145 },
10146 set: function( owner, data, value ) {
10147 var prop,
10148 // There may be an unlock assigned to this node,
10149 // if there is no entry for this "owner", create one inline
10150 // and set the unlock as though an owner entry had always existed
10151 unlock = this.key( owner ),
10152 cache = this.cache[ unlock ];
10153
10154 // Handle: [ owner, key, value ] args
10155 if ( typeof data === "string" ) {
10156 cache[ data ] = value;
10157
10158 // Handle: [ owner, { properties } ] args
10159 } else {
10160 // Fresh assignments by object are shallow copied
10161 if ( jQuery.isEmptyObject( cache ) ) {
10162 jQuery.extend( this.cache[ unlock ], data );
10163 // Otherwise, copy the properties one-by-one to the cache object
10164 } else {
10165 for ( prop in data ) {
10166 cache[ prop ] = data[ prop ];
10167 }
10168 }
10169 }
10170 return cache;
10171 },
10172 get: function( owner, key ) {
10173 // Either a valid cache is found, or will be created.
10174 // New caches will be created and the unlock returned,
10175 // allowing direct access to the newly created
10176 // empty data object. A valid owner object must be provided.
10177 var cache = this.cache[ this.key( owner ) ];
10178
10179 return key === undefined ?
10180 cache : cache[ key ];
10181 },
10182 access: function( owner, key, value ) {
10183 var stored;
10184 // In cases where either:
10185 //
10186 // 1. No key was specified
10187 // 2. A string key was specified, but no value provided
10188 //
10189 // Take the "read" path and allow the get method to determine
10190 // which value to return, respectively either:
10191 //
10192 // 1. The entire cache object
10193 // 2. The data stored at the key
10194 //
10195 if ( key === undefined ||
10196 ((key && typeof key === "string") && value === undefined) ) {
10197
10198 stored = this.get( owner, key );
10199
10200 return stored !== undefined ?
10201 stored : this.get( owner, jQuery.camelCase(key) );
10202 }
10203
10204 // [*]When the key is not a string, or both a key and value
10205 // are specified, set or extend (existing objects) with either:
10206 //
10207 // 1. An object of properties
10208 // 2. A key and value
10209 //
10210 this.set( owner, key, value );
10211
10212 // Since the "set" path can have two possible entry points
10213 // return the expected data based on which path was taken[*]
10214 return value !== undefined ? value : key;
10215 },
10216 remove: function( owner, key ) {
10217 var i, name, camel,
10218 unlock = this.key( owner ),
10219 cache = this.cache[ unlock ];
10220
10221 if ( key === undefined ) {
10222 this.cache[ unlock ] = {};
10223
10224 } else {
10225 // Support array or space separated string of keys
10226 if ( jQuery.isArray( key ) ) {
10227 // If "name" is an array of keys...
10228 // When data is initially created, via ("key", "val") signature,
10229 // keys will be converted to camelCase.
10230 // Since there is no way to tell _how_ a key was added, remove
10231 // both plain key and camelCase key. #12786
10232 // This will only penalize the array argument path.
10233 name = key.concat( key.map( jQuery.camelCase ) );
10234 } else {
10235 camel = jQuery.camelCase( key );
10236 // Try the string as a key before any manipulation
10237 if ( key in cache ) {
10238 name = [ key, camel ];
10239 } else {
10240 // If a key with the spaces exists, use it.
10241 // Otherwise, create an array by matching non-whitespace
10242 name = camel;
10243 name = name in cache ?
10244 [ name ] : ( name.match( rnotwhite ) || [] );
10245 }
10246 }
10247
10248 i = name.length;
10249 while ( i-- ) {
10250 delete cache[ name[ i ] ];
10251 }
10252 }
10253 },
10254 hasData: function( owner ) {
10255 return !jQuery.isEmptyObject(
10256 this.cache[ owner[ this.expando ] ] || {}
10257 );
10258 },
10259 discard: function( owner ) {
10260 if ( owner[ this.expando ] ) {
10261 delete this.cache[ owner[ this.expando ] ];
10262 }
10263 }
10264 };
10265 var data_priv = new Data();
10266
10267 var data_user = new Data();
10268
10269
10270
10271 /*
10272 Implementation Summary
10273
10274 1. Enforce API surface and semantic compatibility with 1.9.x branch
10275 2. Improve the module's maintainability by reducing the storage
10276 paths to a single mechanism.
10277 3. Use the same single mechanism to support "private" and "user" data.
10278 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
10279 5. Avoid exposing implementation details on user objects (eg. expando properties)
10280 6. Provide a clear path for implementation upgrade to WeakMap in 2014
10281 */
10282 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
10283 rmultiDash = /([A-Z])/g;
10284
10285 function dataAttr( elem, key, data ) {
10286 var name;
10287
10288 // If nothing was found internally, try to fetch any
10289 // data from the HTML5 data-* attribute
10290 if ( data === undefined && elem.nodeType === 1 ) {
10291 name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
10292 data = elem.getAttribute( name );
10293
10294 if ( typeof data === "string" ) {
10295 try {
10296 data = data === "true" ? true :
10297 data === "false" ? false :
10298 data === "null" ? null :
10299 // Only convert to a number if it doesn't change the string
10300 +data + "" === data ? +data :
10301 rbrace.test( data ) ? jQuery.parseJSON( data ) :
10302 data;
10303 } catch( e ) {}
10304
10305 // Make sure we set the data so it isn't changed later
10306 data_user.set( elem, key, data );
10307 } else {
10308 data = undefined;
10309 }
10310 }
10311 return data;
10312 }
10313
10314 jQuery.extend({
10315 hasData: function( elem ) {
10316 return data_user.hasData( elem ) || data_priv.hasData( elem );
10317 },
10318
10319 data: function( elem, name, data ) {
10320 return data_user.access( elem, name, data );
10321 },
10322
10323 removeData: function( elem, name ) {
10324 data_user.remove( elem, name );
10325 },
10326
10327 // TODO: Now that all calls to _data and _removeData have been replaced
10328 // with direct calls to data_priv methods, these can be deprecated.
10329 _data: function( elem, name, data ) {
10330 return data_priv.access( elem, name, data );
10331 },
10332
10333 _removeData: function( elem, name ) {
10334 data_priv.remove( elem, name );
10335 }
10336 });
10337
10338 jQuery.fn.extend({
10339 data: function( key, value ) {
10340 var i, name, data,
10341 elem = this[ 0 ],
10342 attrs = elem && elem.attributes;
10343
10344 // Gets all values
10345 if ( key === undefined ) {
10346 if ( this.length ) {
10347 data = data_user.get( elem );
10348
10349 if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) {
10350 i = attrs.length;
10351 while ( i-- ) {
10352
10353 // Support: IE11+
10354 // The attrs elements can be null (#14894)
10355 if ( attrs[ i ] ) {
10356 name = attrs[ i ].name;
10357 if ( name.indexOf( "data-" ) === 0 ) {
10358 name = jQuery.camelCase( name.slice(5) );
10359 dataAttr( elem, name, data[ name ] );
10360 }
10361 }
10362 }
10363 data_priv.set( elem, "hasDataAttrs", true );
10364 }
10365 }
10366
10367 return data;
10368 }
10369
10370 // Sets multiple values
10371 if ( typeof key === "object" ) {
10372 return this.each(function() {
10373 data_user.set( this, key );
10374 });
10375 }
10376
10377 return access( this, function( value ) {
10378 var data,
10379 camelKey = jQuery.camelCase( key );
10380
10381 // The calling jQuery object (element matches) is not empty
10382 // (and therefore has an element appears at this[ 0 ]) and the
10383 // `value` parameter was not undefined. An empty jQuery object
10384 // will result in `undefined` for elem = this[ 0 ] which will
10385 // throw an exception if an attempt to read a data cache is made.
10386 if ( elem && value === undefined ) {
10387 // Attempt to get data from the cache
10388 // with the key as-is
10389 data = data_user.get( elem, key );
10390 if ( data !== undefined ) {
10391 return data;
10392 }
10393
10394 // Attempt to get data from the cache
10395 // with the key camelized
10396 data = data_user.get( elem, camelKey );
10397 if ( data !== undefined ) {
10398 return data;
10399 }
10400
10401 // Attempt to "discover" the data in
10402 // HTML5 custom data-* attrs
10403 data = dataAttr( elem, camelKey, undefined );
10404 if ( data !== undefined ) {
10405 return data;
10406 }
10407
10408 // We tried really hard, but the data doesn't exist.
10409 return;
10410 }
10411
10412 // Set the data...
10413 this.each(function() {
10414 // First, attempt to store a copy or reference of any
10415 // data that might've been store with a camelCased key.
10416 var data = data_user.get( this, camelKey );
10417
10418 // For HTML5 data-* attribute interop, we have to
10419 // store property names with dashes in a camelCase form.
10420 // This might not apply to all properties...*
10421 data_user.set( this, camelKey, value );
10422
10423 // *... In the case of properties that might _actually_
10424 // have dashes, we need to also store a copy of that
10425 // unchanged property.
10426 if ( key.indexOf("-") !== -1 && data !== undefined ) {
10427 data_user.set( this, key, value );
10428 }
10429 });
10430 }, null, value, arguments.length > 1, null, true );
10431 },
10432
10433 removeData: function( key ) {
10434 return this.each(function() {
10435 data_user.remove( this, key );
10436 });
10437 }
10438 });
10439
10440
10441 jQuery.extend({
10442 queue: function( elem, type, data ) {
10443 var queue;
10444
10445 if ( elem ) {
10446 type = ( type || "fx" ) + "queue";
10447 queue = data_priv.get( elem, type );
10448
10449 // Speed up dequeue by getting out quickly if this is just a lookup
10450 if ( data ) {
10451 if ( !queue || jQuery.isArray( data ) ) {
10452 queue = data_priv.access( elem, type, jQuery.makeArray(data) );
10453 } else {
10454 queue.push( data );
10455 }
10456 }
10457 return queue || [];
10458 }
10459 },
10460
10461 dequeue: function( elem, type ) {
10462 type = type || "fx";
10463
10464 var queue = jQuery.queue( elem, type ),
10465 startLength = queue.length,
10466 fn = queue.shift(),
10467 hooks = jQuery._queueHooks( elem, type ),
10468 next = function() {
10469 jQuery.dequeue( elem, type );
10470 };
10471
10472 // If the fx queue is dequeued, always remove the progress sentinel
10473 if ( fn === "inprogress" ) {
10474 fn = queue.shift();
10475 startLength--;
10476 }
10477
10478 if ( fn ) {
10479
10480 // Add a progress sentinel to prevent the fx queue from being
10481 // automatically dequeued
10482 if ( type === "fx" ) {
10483 queue.unshift( "inprogress" );
10484 }
10485
10486 // clear up the last queue stop function
10487 delete hooks.stop;
10488 fn.call( elem, next, hooks );
10489 }
10490
10491 if ( !startLength && hooks ) {
10492 hooks.empty.fire();
10493 }
10494 },
10495
10496 // not intended for public consumption - generates a queueHooks object, or returns the current one
10497 _queueHooks: function( elem, type ) {
10498 var key = type + "queueHooks";
10499 return data_priv.get( elem, key ) || data_priv.access( elem, key, {
10500 empty: jQuery.Callbacks("once memory").add(function() {
10501 data_priv.remove( elem, [ type + "queue", key ] );
10502 })
10503 });
10504 }
10505 });
10506
10507 jQuery.fn.extend({
10508 queue: function( type, data ) {
10509 var setter = 2;
10510
10511 if ( typeof type !== "string" ) {
10512 data = type;
10513 type = "fx";
10514 setter--;
10515 }
10516
10517 if ( arguments.length < setter ) {
10518 return jQuery.queue( this[0], type );
10519 }
10520
10521 return data === undefined ?
10522 this :
10523 this.each(function() {
10524 var queue = jQuery.queue( this, type, data );
10525
10526 // ensure a hooks for this queue
10527 jQuery._queueHooks( this, type );
10528
10529 if ( type === "fx" && queue[0] !== "inprogress" ) {
10530 jQuery.dequeue( this, type );
10531 }
10532 });
10533 },
10534 dequeue: function( type ) {
10535 return this.each(function() {
10536 jQuery.dequeue( this, type );
10537 });
10538 },
10539 clearQueue: function( type ) {
10540 return this.queue( type || "fx", [] );
10541 },
10542 // Get a promise resolved when queues of a certain type
10543 // are emptied (fx is the type by default)
10544 promise: function( type, obj ) {
10545 var tmp,
10546 count = 1,
10547 defer = jQuery.Deferred(),
10548 elements = this,
10549 i = this.length,
10550 resolve = function() {
10551 if ( !( --count ) ) {
10552 defer.resolveWith( elements, [ elements ] );
10553 }
10554 };
10555
10556 if ( typeof type !== "string" ) {
10557 obj = type;
10558 type = undefined;
10559 }
10560 type = type || "fx";
10561
10562 while ( i-- ) {
10563 tmp = data_priv.get( elements[ i ], type + "queueHooks" );
10564 if ( tmp && tmp.empty ) {
10565 count++;
10566 tmp.empty.add( resolve );
10567 }
10568 }
10569 resolve();
10570 return defer.promise( obj );
10571 }
10572 });
10573 var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
10574
10575 var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
10576
10577 var isHidden = function( elem, el ) {
10578 // isHidden might be called from jQuery#filter function;
10579 // in that case, element will be second argument
10580 elem = el || elem;
10581 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
10582 };
10583
10584 var rcheckableType = (/^(?:checkbox|radio)$/i);
10585
10586
10587
10588 (function() {
10589 var fragment = document.createDocumentFragment(),
10590 div = fragment.appendChild( document.createElement( "div" ) ),
10591 input = document.createElement( "input" );
10592
10593 // #11217 - WebKit loses check when the name is after the checked attribute
10594 // Support: Windows Web Apps (WWA)
10595 // `name` and `type` need .setAttribute for WWA
10596 input.setAttribute( "type", "radio" );
10597 input.setAttribute( "checked", "checked" );
10598 input.setAttribute( "name", "t" );
10599
10600 div.appendChild( input );
10601
10602 // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
10603 // old WebKit doesn't clone checked state correctly in fragments
10604 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
10605
10606 // Make sure textarea (and checkbox) defaultValue is properly cloned
10607 // Support: IE9-IE11+
10608 div.innerHTML = "<textarea>x</textarea>";
10609 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
10610 })();
10611 var strundefined = typeof undefined;
10612
10613
10614
10615 support.focusinBubbles = "onfocusin" in window;
10616
10617
10618 var
10619 rkeyEvent = /^key/,
10620 rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
10621 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
10622 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
10623
10624 function returnTrue() {
10625 return true;
10626 }
10627
10628 function returnFalse() {
10629 return false;
10630 }
10631
10632 function safeActiveElement() {
10633 try {
10634 return document.activeElement;
10635 } catch ( err ) { }
10636 }
10637
10638 /*
10639 * Helper functions for managing events -- not part of the public interface.
10640 * Props to Dean Edwards' addEvent library for many of the ideas.
10641 */
10642 jQuery.event = {
10643
10644 global: {},
10645
10646 add: function( elem, types, handler, data, selector ) {
10647
10648 var handleObjIn, eventHandle, tmp,
10649 events, t, handleObj,
10650 special, handlers, type, namespaces, origType,
10651 elemData = data_priv.get( elem );
10652
10653 // Don't attach events to noData or text/comment nodes (but allow plain objects)
10654 if ( !elemData ) {
10655 return;
10656 }
10657
10658 // Caller can pass in an object of custom data in lieu of the handler
10659 if ( handler.handler ) {
10660 handleObjIn = handler;
10661 handler = handleObjIn.handler;
10662 selector = handleObjIn.selector;
10663 }
10664
10665 // Make sure that the handler has a unique ID, used to find/remove it later
10666 if ( !handler.guid ) {
10667 handler.guid = jQuery.guid++;
10668 }
10669
10670 // Init the element's event structure and main handler, if this is the first
10671 if ( !(events = elemData.events) ) {
10672 events = elemData.events = {};
10673 }
10674 if ( !(eventHandle = elemData.handle) ) {
10675 eventHandle = elemData.handle = function( e ) {
10676 // Discard the second event of a jQuery.event.trigger() and
10677 // when an event is called after a page has unloaded
10678 return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ?
10679 jQuery.event.dispatch.apply( elem, arguments ) : undefined;
10680 };
10681 }
10682
10683 // Handle multiple events separated by a space
10684 types = ( types || "" ).match( rnotwhite ) || [ "" ];
10685 t = types.length;
10686 while ( t-- ) {
10687 tmp = rtypenamespace.exec( types[t] ) || [];
10688 type = origType = tmp[1];
10689 namespaces = ( tmp[2] || "" ).split( "." ).sort();
10690
10691 // There *must* be a type, no attaching namespace-only handlers
10692 if ( !type ) {
10693 continue;
10694 }
10695
10696 // If event changes its type, use the special event handlers for the changed type
10697 special = jQuery.event.special[ type ] || {};
10698
10699 // If selector defined, determine special event api type, otherwise given type
10700 type = ( selector ? special.delegateType : special.bindType ) || type;
10701
10702 // Update special based on newly reset type
10703 special = jQuery.event.special[ type ] || {};
10704
10705 // handleObj is passed to all event handlers
10706 handleObj = jQuery.extend({
10707 type: type,
10708 origType: origType,
10709 data: data,
10710 handler: handler,
10711 guid: handler.guid,
10712 selector: selector,
10713 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
10714 namespace: namespaces.join(".")
10715 }, handleObjIn );
10716
10717 // Init the event handler queue if we're the first
10718 if ( !(handlers = events[ type ]) ) {
10719 handlers = events[ type ] = [];
10720 handlers.delegateCount = 0;
10721
10722 // Only use addEventListener if the special events handler returns false
10723 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
10724 if ( elem.addEventListener ) {
10725 elem.addEventListener( type, eventHandle, false );
10726 }
10727 }
10728 }
10729
10730 if ( special.add ) {
10731 special.add.call( elem, handleObj );
10732
10733 if ( !handleObj.handler.guid ) {
10734 handleObj.handler.guid = handler.guid;
10735 }
10736 }
10737
10738 // Add to the element's handler list, delegates in front
10739 if ( selector ) {
10740 handlers.splice( handlers.delegateCount++, 0, handleObj );
10741 } else {
10742 handlers.push( handleObj );
10743 }
10744
10745 // Keep track of which events have ever been used, for event optimization
10746 jQuery.event.global[ type ] = true;
10747 }
10748
10749 },
10750
10751 // Detach an event or set of events from an element
10752 remove: function( elem, types, handler, selector, mappedTypes ) {
10753
10754 var j, origCount, tmp,
10755 events, t, handleObj,
10756 special, handlers, type, namespaces, origType,
10757 elemData = data_priv.hasData( elem ) && data_priv.get( elem );
10758
10759 if ( !elemData || !(events = elemData.events) ) {
10760 return;
10761 }
10762
10763 // Once for each type.namespace in types; type may be omitted
10764 types = ( types || "" ).match( rnotwhite ) || [ "" ];
10765 t = types.length;
10766 while ( t-- ) {
10767 tmp = rtypenamespace.exec( types[t] ) || [];
10768 type = origType = tmp[1];
10769 namespaces = ( tmp[2] || "" ).split( "." ).sort();
10770
10771 // Unbind all events (on this namespace, if provided) for the element
10772 if ( !type ) {
10773 for ( type in events ) {
10774 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
10775 }
10776 continue;
10777 }
10778
10779 special = jQuery.event.special[ type ] || {};
10780 type = ( selector ? special.delegateType : special.bindType ) || type;
10781 handlers = events[ type ] || [];
10782 tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
10783
10784 // Remove matching events
10785 origCount = j = handlers.length;
10786 while ( j-- ) {
10787 handleObj = handlers[ j ];
10788
10789 if ( ( mappedTypes || origType === handleObj.origType ) &&
10790 ( !handler || handler.guid === handleObj.guid ) &&
10791 ( !tmp || tmp.test( handleObj.namespace ) ) &&
10792 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
10793 handlers.splice( j, 1 );
10794
10795 if ( handleObj.selector ) {
10796 handlers.delegateCount--;
10797 }
10798 if ( special.remove ) {
10799 special.remove.call( elem, handleObj );
10800 }
10801 }
10802 }
10803
10804 // Remove generic event handler if we removed something and no more handlers exist
10805 // (avoids potential for endless recursion during removal of special event handlers)
10806 if ( origCount && !handlers.length ) {
10807 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
10808 jQuery.removeEvent( elem, type, elemData.handle );
10809 }
10810
10811 delete events[ type ];
10812 }
10813 }
10814
10815 // Remove the expando if it's no longer used
10816 if ( jQuery.isEmptyObject( events ) ) {
10817 delete elemData.handle;
10818 data_priv.remove( elem, "events" );
10819 }
10820 },
10821
10822 trigger: function( event, data, elem, onlyHandlers ) {
10823
10824 var i, cur, tmp, bubbleType, ontype, handle, special,
10825 eventPath = [ elem || document ],
10826 type = hasOwn.call( event, "type" ) ? event.type : event,
10827 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
10828
10829 cur = tmp = elem = elem || document;
10830
10831 // Don't do events on text and comment nodes
10832 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
10833 return;
10834 }
10835
10836 // focus/blur morphs to focusin/out; ensure we're not firing them right now
10837 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
10838 return;
10839 }
10840
10841 if ( type.indexOf(".") >= 0 ) {
10842 // Namespaced trigger; create a regexp to match event type in handle()
10843 namespaces = type.split(".");
10844 type = namespaces.shift();
10845 namespaces.sort();
10846 }
10847 ontype = type.indexOf(":") < 0 && "on" + type;
10848
10849 // Caller can pass in a jQuery.Event object, Object, or just an event type string
10850 event = event[ jQuery.expando ] ?
10851 event :
10852 new jQuery.Event( type, typeof event === "object" && event );
10853
10854 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
10855 event.isTrigger = onlyHandlers ? 2 : 3;
10856 event.namespace = namespaces.join(".");
10857 event.namespace_re = event.namespace ?
10858 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
10859 null;
10860
10861 // Clean up the event in case it is being reused
10862 event.result = undefined;
10863 if ( !event.target ) {
10864 event.target = elem;
10865 }
10866
10867 // Clone any incoming data and prepend the event, creating the handler arg list
10868 data = data == null ?
10869 [ event ] :
10870 jQuery.makeArray( data, [ event ] );
10871
10872 // Allow special events to draw outside the lines
10873 special = jQuery.event.special[ type ] || {};
10874 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
10875 return;
10876 }
10877
10878 // Determine event propagation path in advance, per W3C events spec (#9951)
10879 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
10880 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
10881
10882 bubbleType = special.delegateType || type;
10883 if ( !rfocusMorph.test( bubbleType + type ) ) {
10884 cur = cur.parentNode;
10885 }
10886 for ( ; cur; cur = cur.parentNode ) {
10887 eventPath.push( cur );
10888 tmp = cur;
10889 }
10890
10891 // Only add window if we got to document (e.g., not plain obj or detached DOM)
10892 if ( tmp === (elem.ownerDocument || document) ) {
10893 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
10894 }
10895 }
10896
10897 // Fire handlers on the event path
10898 i = 0;
10899 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
10900
10901 event.type = i > 1 ?
10902 bubbleType :
10903 special.bindType || type;
10904
10905 // jQuery handler
10906 handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" );
10907 if ( handle ) {
10908 handle.apply( cur, data );
10909 }
10910
10911 // Native handler
10912 handle = ontype && cur[ ontype ];
10913 if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
10914 event.result = handle.apply( cur, data );
10915 if ( event.result === false ) {
10916 event.preventDefault();
10917 }
10918 }
10919 }
10920 event.type = type;
10921
10922 // If nobody prevented the default action, do it now
10923 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
10924
10925 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
10926 jQuery.acceptData( elem ) ) {
10927
10928 // Call a native DOM method on the target with the same name name as the event.
10929 // Don't do default actions on window, that's where global variables be (#6170)
10930 if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
10931
10932 // Don't re-trigger an onFOO event when we call its FOO() method
10933 tmp = elem[ ontype ];
10934
10935 if ( tmp ) {
10936 elem[ ontype ] = null;
10937 }
10938
10939 // Prevent re-triggering of the same event, since we already bubbled it above
10940 jQuery.event.triggered = type;
10941 elem[ type ]();
10942 jQuery.event.triggered = undefined;
10943
10944 if ( tmp ) {
10945 elem[ ontype ] = tmp;
10946 }
10947 }
10948 }
10949 }
10950
10951 return event.result;
10952 },
10953
10954 dispatch: function( event ) {
10955
10956 // Make a writable jQuery.Event from the native event object
10957 event = jQuery.event.fix( event );
10958
10959 var i, j, ret, matched, handleObj,
10960 handlerQueue = [],
10961 args = slice.call( arguments ),
10962 handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [],
10963 special = jQuery.event.special[ event.type ] || {};
10964
10965 // Use the fix-ed jQuery.Event rather than the (read-only) native event
10966 args[0] = event;
10967 event.delegateTarget = this;
10968
10969 // Call the preDispatch hook for the mapped type, and let it bail if desired
10970 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
10971 return;
10972 }
10973
10974 // Determine handlers
10975 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
10976
10977 // Run delegates first; they may want to stop propagation beneath us
10978 i = 0;
10979 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
10980 event.currentTarget = matched.elem;
10981
10982 j = 0;
10983 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
10984
10985 // Triggered event must either 1) have no namespace, or
10986 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
10987 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
10988
10989 event.handleObj = handleObj;
10990 event.data = handleObj.data;
10991
10992 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
10993 .apply( matched.elem, args );
10994
10995 if ( ret !== undefined ) {
10996 if ( (event.result = ret) === false ) {
10997 event.preventDefault();
10998 event.stopPropagation();
10999 }
11000 }
11001 }
11002 }
11003 }
11004
11005 // Call the postDispatch hook for the mapped type
11006 if ( special.postDispatch ) {
11007 special.postDispatch.call( this, event );
11008 }
11009
11010 return event.result;
11011 },
11012
11013 handlers: function( event, handlers ) {
11014 var i, matches, sel, handleObj,
11015 handlerQueue = [],
11016 delegateCount = handlers.delegateCount,
11017 cur = event.target;
11018
11019 // Find delegate handlers
11020 // Black-hole SVG <use> instance trees (#13180)
11021 // Avoid non-left-click bubbling in Firefox (#3861)
11022 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
11023
11024 for ( ; cur !== this; cur = cur.parentNode || this ) {
11025
11026 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
11027 if ( cur.disabled !== true || event.type !== "click" ) {
11028 matches = [];
11029 for ( i = 0; i < delegateCount; i++ ) {
11030 handleObj = handlers[ i ];
11031
11032 // Don't conflict with Object.prototype properties (#13203)
11033 sel = handleObj.selector + " ";
11034
11035 if ( matches[ sel ] === undefined ) {
11036 matches[ sel ] = handleObj.needsContext ?
11037 jQuery( sel, this ).index( cur ) >= 0 :
11038 jQuery.find( sel, this, null, [ cur ] ).length;
11039 }
11040 if ( matches[ sel ] ) {
11041 matches.push( handleObj );
11042 }
11043 }
11044 if ( matches.length ) {
11045 handlerQueue.push({ elem: cur, handlers: matches });
11046 }
11047 }
11048 }
11049 }
11050
11051 // Add the remaining (directly-bound) handlers
11052 if ( delegateCount < handlers.length ) {
11053 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
11054 }
11055
11056 return handlerQueue;
11057 },
11058
11059 // Includes some event props shared by KeyEvent and MouseEvent
11060 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
11061
11062 fixHooks: {},
11063
11064 keyHooks: {
11065 props: "char charCode key keyCode".split(" "),
11066 filter: function( event, original ) {
11067
11068 // Add which for key events
11069 if ( event.which == null ) {
11070 event.which = original.charCode != null ? original.charCode : original.keyCode;
11071 }
11072
11073 return event;
11074 }
11075 },
11076
11077 mouseHooks: {
11078 props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
11079 filter: function( event, original ) {
11080 var eventDoc, doc, body,
11081 button = original.button;
11082
11083 // Calculate pageX/Y if missing and clientX/Y available
11084 if ( event.pageX == null && original.clientX != null ) {
11085 eventDoc = event.target.ownerDocument || document;
11086 doc = eventDoc.documentElement;
11087 body = eventDoc.body;
11088
11089 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
11090 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
11091 }
11092
11093 // Add which for click: 1 === left; 2 === middle; 3 === right
11094 // Note: button is not normalized, so don't use it
11095 if ( !event.which && button !== undefined ) {
11096 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
11097 }
11098
11099 return event;
11100 }
11101 },
11102
11103 fix: function( event ) {
11104 if ( event[ jQuery.expando ] ) {
11105 return event;
11106 }
11107
11108 // Create a writable copy of the event object and normalize some properties
11109 var i, prop, copy,
11110 type = event.type,
11111 originalEvent = event,
11112 fixHook = this.fixHooks[ type ];
11113
11114 if ( !fixHook ) {
11115 this.fixHooks[ type ] = fixHook =
11116 rmouseEvent.test( type ) ? this.mouseHooks :
11117 rkeyEvent.test( type ) ? this.keyHooks :
11118 {};
11119 }
11120 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
11121
11122 event = new jQuery.Event( originalEvent );
11123
11124 i = copy.length;
11125 while ( i-- ) {
11126 prop = copy[ i ];
11127 event[ prop ] = originalEvent[ prop ];
11128 }
11129
11130 // Support: Cordova 2.5 (WebKit) (#13255)
11131 // All events should have a target; Cordova deviceready doesn't
11132 if ( !event.target ) {
11133 event.target = document;
11134 }
11135
11136 // Support: Safari 6.0+, Chrome < 28
11137 // Target should not be a text node (#504, #13143)
11138 if ( event.target.nodeType === 3 ) {
11139 event.target = event.target.parentNode;
11140 }
11141
11142 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
11143 },
11144
11145 special: {
11146 load: {
11147 // Prevent triggered image.load events from bubbling to window.load
11148 noBubble: true
11149 },
11150 focus: {
11151 // Fire native event if possible so blur/focus sequence is correct
11152 trigger: function() {
11153 if ( this !== safeActiveElement() && this.focus ) {
11154 this.focus();
11155 return false;
11156 }
11157 },
11158 delegateType: "focusin"
11159 },
11160 blur: {
11161 trigger: function() {
11162 if ( this === safeActiveElement() && this.blur ) {
11163 this.blur();
11164 return false;
11165 }
11166 },
11167 delegateType: "focusout"
11168 },
11169 click: {
11170 // For checkbox, fire native event so checked state will be right
11171 trigger: function() {
11172 if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) {
11173 this.click();
11174 return false;
11175 }
11176 },
11177
11178 // For cross-browser consistency, don't fire native .click() on links
11179 _default: function( event ) {
11180 return jQuery.nodeName( event.target, "a" );
11181 }
11182 },
11183
11184 beforeunload: {
11185 postDispatch: function( event ) {
11186
11187 // Support: Firefox 20+
11188 // Firefox doesn't alert if the returnValue field is not set.
11189 if ( event.result !== undefined && event.originalEvent ) {
11190 event.originalEvent.returnValue = event.result;
11191 }
11192 }
11193 }
11194 },
11195
11196 simulate: function( type, elem, event, bubble ) {
11197 // Piggyback on a donor event to simulate a different one.
11198 // Fake originalEvent to avoid donor's stopPropagation, but if the
11199 // simulated event prevents default then we do the same on the donor.
11200 var e = jQuery.extend(
11201 new jQuery.Event(),
11202 event,
11203 {
11204 type: type,
11205 isSimulated: true,
11206 originalEvent: {}
11207 }
11208 );
11209 if ( bubble ) {
11210 jQuery.event.trigger( e, null, elem );
11211 } else {
11212 jQuery.event.dispatch.call( elem, e );
11213 }
11214 if ( e.isDefaultPrevented() ) {
11215 event.preventDefault();
11216 }
11217 }
11218 };
11219
11220 jQuery.removeEvent = function( elem, type, handle ) {
11221 if ( elem.removeEventListener ) {
11222 elem.removeEventListener( type, handle, false );
11223 }
11224 };
11225
11226 jQuery.Event = function( src, props ) {
11227 // Allow instantiation without the 'new' keyword
11228 if ( !(this instanceof jQuery.Event) ) {
11229 return new jQuery.Event( src, props );
11230 }
11231
11232 // Event object
11233 if ( src && src.type ) {
11234 this.originalEvent = src;
11235 this.type = src.type;
11236
11237 // Events bubbling up the document may have been marked as prevented
11238 // by a handler lower down the tree; reflect the correct value.
11239 this.isDefaultPrevented = src.defaultPrevented ||
11240 src.defaultPrevented === undefined &&
11241 // Support: Android < 4.0
11242 src.returnValue === false ?
11243 returnTrue :
11244 returnFalse;
11245
11246 // Event type
11247 } else {
11248 this.type = src;
11249 }
11250
11251 // Put explicitly provided properties onto the event object
11252 if ( props ) {
11253 jQuery.extend( this, props );
11254 }
11255
11256 // Create a timestamp if incoming event doesn't have one
11257 this.timeStamp = src && src.timeStamp || jQuery.now();
11258
11259 // Mark it as fixed
11260 this[ jQuery.expando ] = true;
11261 };
11262
11263 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
11264 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
11265 jQuery.Event.prototype = {
11266 isDefaultPrevented: returnFalse,
11267 isPropagationStopped: returnFalse,
11268 isImmediatePropagationStopped: returnFalse,
11269
11270 preventDefault: function() {
11271 var e = this.originalEvent;
11272
11273 this.isDefaultPrevented = returnTrue;
11274
11275 if ( e && e.preventDefault ) {
11276 e.preventDefault();
11277 }
11278 },
11279 stopPropagation: function() {
11280 var e = this.originalEvent;
11281
11282 this.isPropagationStopped = returnTrue;
11283
11284 if ( e && e.stopPropagation ) {
11285 e.stopPropagation();
11286 }
11287 },
11288 stopImmediatePropagation: function() {
11289 var e = this.originalEvent;
11290
11291 this.isImmediatePropagationStopped = returnTrue;
11292
11293 if ( e && e.stopImmediatePropagation ) {
11294 e.stopImmediatePropagation();
11295 }
11296
11297 this.stopPropagation();
11298 }
11299 };
11300
11301 // Create mouseenter/leave events using mouseover/out and event-time checks
11302 // Support: Chrome 15+
11303 jQuery.each({
11304 mouseenter: "mouseover",
11305 mouseleave: "mouseout",
11306 pointerenter: "pointerover",
11307 pointerleave: "pointerout"
11308 }, function( orig, fix ) {
11309 jQuery.event.special[ orig ] = {
11310 delegateType: fix,
11311 bindType: fix,
11312
11313 handle: function( event ) {
11314 var ret,
11315 target = this,
11316 related = event.relatedTarget,
11317 handleObj = event.handleObj;
11318
11319 // For mousenter/leave call the handler if related is outside the target.
11320 // NB: No relatedTarget if the mouse left/entered the browser window
11321 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
11322 event.type = handleObj.origType;
11323 ret = handleObj.handler.apply( this, arguments );
11324 event.type = fix;
11325 }
11326 return ret;
11327 }
11328 };
11329 });
11330
11331 // Create "bubbling" focus and blur events
11332 // Support: Firefox, Chrome, Safari
11333 if ( !support.focusinBubbles ) {
11334 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
11335
11336 // Attach a single capturing handler on the document while someone wants focusin/focusout
11337 var handler = function( event ) {
11338 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
11339 };
11340
11341 jQuery.event.special[ fix ] = {
11342 setup: function() {
11343 var doc = this.ownerDocument || this,
11344 attaches = data_priv.access( doc, fix );
11345
11346 if ( !attaches ) {
11347 doc.addEventListener( orig, handler, true );
11348 }
11349 data_priv.access( doc, fix, ( attaches || 0 ) + 1 );
11350 },
11351 teardown: function() {
11352 var doc = this.ownerDocument || this,
11353 attaches = data_priv.access( doc, fix ) - 1;
11354
11355 if ( !attaches ) {
11356 doc.removeEventListener( orig, handler, true );
11357 data_priv.remove( doc, fix );
11358
11359 } else {
11360 data_priv.access( doc, fix, attaches );
11361 }
11362 }
11363 };
11364 });
11365 }
11366
11367 jQuery.fn.extend({
11368
11369 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
11370 var origFn, type;
11371
11372 // Types can be a map of types/handlers
11373 if ( typeof types === "object" ) {
11374 // ( types-Object, selector, data )
11375 if ( typeof selector !== "string" ) {
11376 // ( types-Object, data )
11377 data = data || selector;
11378 selector = undefined;
11379 }
11380 for ( type in types ) {
11381 this.on( type, selector, data, types[ type ], one );
11382 }
11383 return this;
11384 }
11385
11386 if ( data == null && fn == null ) {
11387 // ( types, fn )
11388 fn = selector;
11389 data = selector = undefined;
11390 } else if ( fn == null ) {
11391 if ( typeof selector === "string" ) {
11392 // ( types, selector, fn )
11393 fn = data;
11394 data = undefined;
11395 } else {
11396 // ( types, data, fn )
11397 fn = data;
11398 data = selector;
11399 selector = undefined;
11400 }
11401 }
11402 if ( fn === false ) {
11403 fn = returnFalse;
11404 } else if ( !fn ) {
11405 return this;
11406 }
11407
11408 if ( one === 1 ) {
11409 origFn = fn;
11410 fn = function( event ) {
11411 // Can use an empty set, since event contains the info
11412 jQuery().off( event );
11413 return origFn.apply( this, arguments );
11414 };
11415 // Use same guid so caller can remove using origFn
11416 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
11417 }
11418 return this.each( function() {
11419 jQuery.event.add( this, types, fn, data, selector );
11420 });
11421 },
11422 one: function( types, selector, data, fn ) {
11423 return this.on( types, selector, data, fn, 1 );
11424 },
11425 off: function( types, selector, fn ) {
11426 var handleObj, type;
11427 if ( types && types.preventDefault && types.handleObj ) {
11428 // ( event ) dispatched jQuery.Event
11429 handleObj = types.handleObj;
11430 jQuery( types.delegateTarget ).off(
11431 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
11432 handleObj.selector,
11433 handleObj.handler
11434 );
11435 return this;
11436 }
11437 if ( typeof types === "object" ) {
11438 // ( types-object [, selector] )
11439 for ( type in types ) {
11440 this.off( type, selector, types[ type ] );
11441 }
11442 return this;
11443 }
11444 if ( selector === false || typeof selector === "function" ) {
11445 // ( types [, fn] )
11446 fn = selector;
11447 selector = undefined;
11448 }
11449 if ( fn === false ) {
11450 fn = returnFalse;
11451 }
11452 return this.each(function() {
11453 jQuery.event.remove( this, types, fn, selector );
11454 });
11455 },
11456
11457 trigger: function( type, data ) {
11458 return this.each(function() {
11459 jQuery.event.trigger( type, data, this );
11460 });
11461 },
11462 triggerHandler: function( type, data ) {
11463 var elem = this[0];
11464 if ( elem ) {
11465 return jQuery.event.trigger( type, data, elem, true );
11466 }
11467 }
11468 });
11469
11470
11471 var
11472 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
11473 rtagName = /<([\w:]+)/,
11474 rhtml = /<|&#?\w+;/,
11475 rnoInnerhtml = /<(?:script|style|link)/i,
11476 // checked="checked" or checked
11477 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
11478 rscriptType = /^$|\/(?:java|ecma)script/i,
11479 rscriptTypeMasked = /^true\/(.*)/,
11480 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
11481
11482 // We have to close these tags to support XHTML (#13200)
11483 wrapMap = {
11484
11485 // Support: IE 9
11486 option: [ 1, "<select multiple='multiple'>", "</select>" ],
11487
11488 thead: [ 1, "<table>", "</table>" ],
11489 col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
11490 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
11491 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
11492
11493 _default: [ 0, "", "" ]
11494 };
11495
11496 // Support: IE 9
11497 wrapMap.optgroup = wrapMap.option;
11498
11499 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
11500 wrapMap.th = wrapMap.td;
11501
11502 // Support: 1.x compatibility
11503 // Manipulating tables requires a tbody
11504 function manipulationTarget( elem, content ) {
11505 return jQuery.nodeName( elem, "table" ) &&
11506 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
11507
11508 elem.getElementsByTagName("tbody")[0] ||
11509 elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
11510 elem;
11511 }
11512
11513 // Replace/restore the type attribute of script elements for safe DOM manipulation
11514 function disableScript( elem ) {
11515 elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type;
11516 return elem;
11517 }
11518 function restoreScript( elem ) {
11519 var match = rscriptTypeMasked.exec( elem.type );
11520
11521 if ( match ) {
11522 elem.type = match[ 1 ];
11523 } else {
11524 elem.removeAttribute("type");
11525 }
11526
11527 return elem;
11528 }
11529
11530 // Mark scripts as having already been evaluated
11531 function setGlobalEval( elems, refElements ) {
11532 var i = 0,
11533 l = elems.length;
11534
11535 for ( ; i < l; i++ ) {
11536 data_priv.set(
11537 elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" )
11538 );
11539 }
11540 }
11541
11542 function cloneCopyEvent( src, dest ) {
11543 var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
11544
11545 if ( dest.nodeType !== 1 ) {
11546 return;
11547 }
11548
11549 // 1. Copy private data: events, handlers, etc.
11550 if ( data_priv.hasData( src ) ) {
11551 pdataOld = data_priv.access( src );
11552 pdataCur = data_priv.set( dest, pdataOld );
11553 events = pdataOld.events;
11554
11555 if ( events ) {
11556 delete pdataCur.handle;
11557 pdataCur.events = {};
11558
11559 for ( type in events ) {
11560 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
11561 jQuery.event.add( dest, type, events[ type ][ i ] );
11562 }
11563 }
11564 }
11565 }
11566
11567 // 2. Copy user data
11568 if ( data_user.hasData( src ) ) {
11569 udataOld = data_user.access( src );
11570 udataCur = jQuery.extend( {}, udataOld );
11571
11572 data_user.set( dest, udataCur );
11573 }
11574 }
11575
11576 function getAll( context, tag ) {
11577 var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) :
11578 context.querySelectorAll ? context.querySelectorAll( tag || "*" ) :
11579 [];
11580
11581 return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
11582 jQuery.merge( [ context ], ret ) :
11583 ret;
11584 }
11585
11586 // Support: IE >= 9
11587 function fixInput( src, dest ) {
11588 var nodeName = dest.nodeName.toLowerCase();
11589
11590 // Fails to persist the checked state of a cloned checkbox or radio button.
11591 if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
11592 dest.checked = src.checked;
11593
11594 // Fails to return the selected option to the default selected state when cloning options
11595 } else if ( nodeName === "input" || nodeName === "textarea" ) {
11596 dest.defaultValue = src.defaultValue;
11597 }
11598 }
11599
11600 jQuery.extend({
11601 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
11602 var i, l, srcElements, destElements,
11603 clone = elem.cloneNode( true ),
11604 inPage = jQuery.contains( elem.ownerDocument, elem );
11605
11606 // Support: IE >= 9
11607 // Fix Cloning issues
11608 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
11609 !jQuery.isXMLDoc( elem ) ) {
11610
11611 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
11612 destElements = getAll( clone );
11613 srcElements = getAll( elem );
11614
11615 for ( i = 0, l = srcElements.length; i < l; i++ ) {
11616 fixInput( srcElements[ i ], destElements[ i ] );
11617 }
11618 }
11619
11620 // Copy the events from the original to the clone
11621 if ( dataAndEvents ) {
11622 if ( deepDataAndEvents ) {
11623 srcElements = srcElements || getAll( elem );
11624 destElements = destElements || getAll( clone );
11625
11626 for ( i = 0, l = srcElements.length; i < l; i++ ) {
11627 cloneCopyEvent( srcElements[ i ], destElements[ i ] );
11628 }
11629 } else {
11630 cloneCopyEvent( elem, clone );
11631 }
11632 }
11633
11634 // Preserve script evaluation history
11635 destElements = getAll( clone, "script" );
11636 if ( destElements.length > 0 ) {
11637 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
11638 }
11639
11640 // Return the cloned set
11641 return clone;
11642 },
11643
11644 buildFragment: function( elems, context, scripts, selection ) {
11645 var elem, tmp, tag, wrap, contains, j,
11646 fragment = context.createDocumentFragment(),
11647 nodes = [],
11648 i = 0,
11649 l = elems.length;
11650
11651 for ( ; i < l; i++ ) {
11652 elem = elems[ i ];
11653
11654 if ( elem || elem === 0 ) {
11655
11656 // Add nodes directly
11657 if ( jQuery.type( elem ) === "object" ) {
11658 // Support: QtWebKit
11659 // jQuery.merge because push.apply(_, arraylike) throws
11660 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
11661
11662 // Convert non-html into a text node
11663 } else if ( !rhtml.test( elem ) ) {
11664 nodes.push( context.createTextNode( elem ) );
11665
11666 // Convert html into DOM nodes
11667 } else {
11668 tmp = tmp || fragment.appendChild( context.createElement("div") );
11669
11670 // Deserialize a standard representation
11671 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
11672 wrap = wrapMap[ tag ] || wrapMap._default;
11673 tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[ 2 ];
11674
11675 // Descend through wrappers to the right content
11676 j = wrap[ 0 ];
11677 while ( j-- ) {
11678 tmp = tmp.lastChild;
11679 }
11680
11681 // Support: QtWebKit
11682 // jQuery.merge because push.apply(_, arraylike) throws
11683 jQuery.merge( nodes, tmp.childNodes );
11684
11685 // Remember the top-level container
11686 tmp = fragment.firstChild;
11687
11688 // Fixes #12346
11689 // Support: Webkit, IE
11690 tmp.textContent = "";
11691 }
11692 }
11693 }
11694
11695 // Remove wrapper from fragment
11696 fragment.textContent = "";
11697
11698 i = 0;
11699 while ( (elem = nodes[ i++ ]) ) {
11700
11701 // #4087 - If origin and destination elements are the same, and this is
11702 // that element, do not do anything
11703 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
11704 continue;
11705 }
11706
11707 contains = jQuery.contains( elem.ownerDocument, elem );
11708
11709 // Append to fragment
11710 tmp = getAll( fragment.appendChild( elem ), "script" );
11711
11712 // Preserve script evaluation history
11713 if ( contains ) {
11714 setGlobalEval( tmp );
11715 }
11716
11717 // Capture executables
11718 if ( scripts ) {
11719 j = 0;
11720 while ( (elem = tmp[ j++ ]) ) {
11721 if ( rscriptType.test( elem.type || "" ) ) {
11722 scripts.push( elem );
11723 }
11724 }
11725 }
11726 }
11727
11728 return fragment;
11729 },
11730
11731 cleanData: function( elems ) {
11732 var data, elem, type, key,
11733 special = jQuery.event.special,
11734 i = 0;
11735
11736 for ( ; (elem = elems[ i ]) !== undefined; i++ ) {
11737 if ( jQuery.acceptData( elem ) ) {
11738 key = elem[ data_priv.expando ];
11739
11740 if ( key && (data = data_priv.cache[ key ]) ) {
11741 if ( data.events ) {
11742 for ( type in data.events ) {
11743 if ( special[ type ] ) {
11744 jQuery.event.remove( elem, type );
11745
11746 // This is a shortcut to avoid jQuery.event.remove's overhead
11747 } else {
11748 jQuery.removeEvent( elem, type, data.handle );
11749 }
11750 }
11751 }
11752 if ( data_priv.cache[ key ] ) {
11753 // Discard any remaining `private` data
11754 delete data_priv.cache[ key ];
11755 }
11756 }
11757 }
11758 // Discard any remaining `user` data
11759 delete data_user.cache[ elem[ data_user.expando ] ];
11760 }
11761 }
11762 });
11763
11764 jQuery.fn.extend({
11765 text: function( value ) {
11766 return access( this, function( value ) {
11767 return value === undefined ?
11768 jQuery.text( this ) :
11769 this.empty().each(function() {
11770 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
11771 this.textContent = value;
11772 }
11773 });
11774 }, null, value, arguments.length );
11775 },
11776
11777 append: function() {
11778 return this.domManip( arguments, function( elem ) {
11779 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
11780 var target = manipulationTarget( this, elem );
11781 target.appendChild( elem );
11782 }
11783 });
11784 },
11785
11786 prepend: function() {
11787 return this.domManip( arguments, function( elem ) {
11788 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
11789 var target = manipulationTarget( this, elem );
11790 target.insertBefore( elem, target.firstChild );
11791 }
11792 });
11793 },
11794
11795 before: function() {
11796 return this.domManip( arguments, function( elem ) {
11797 if ( this.parentNode ) {
11798 this.parentNode.insertBefore( elem, this );
11799 }
11800 });
11801 },
11802
11803 after: function() {
11804 return this.domManip( arguments, function( elem ) {
11805 if ( this.parentNode ) {
11806 this.parentNode.insertBefore( elem, this.nextSibling );
11807 }
11808 });
11809 },
11810
11811 remove: function( selector, keepData /* Internal Use Only */ ) {
11812 var elem,
11813 elems = selector ? jQuery.filter( selector, this ) : this,
11814 i = 0;
11815
11816 for ( ; (elem = elems[i]) != null; i++ ) {
11817 if ( !keepData && elem.nodeType === 1 ) {
11818 jQuery.cleanData( getAll( elem ) );
11819 }
11820
11821 if ( elem.parentNode ) {
11822 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
11823 setGlobalEval( getAll( elem, "script" ) );
11824 }
11825 elem.parentNode.removeChild( elem );
11826 }
11827 }
11828
11829 return this;
11830 },
11831
11832 empty: function() {
11833 var elem,
11834 i = 0;
11835
11836 for ( ; (elem = this[i]) != null; i++ ) {
11837 if ( elem.nodeType === 1 ) {
11838
11839 // Prevent memory leaks
11840 jQuery.cleanData( getAll( elem, false ) );
11841
11842 // Remove any remaining nodes
11843 elem.textContent = "";
11844 }
11845 }
11846
11847 return this;
11848 },
11849
11850 clone: function( dataAndEvents, deepDataAndEvents ) {
11851 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
11852 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
11853
11854 return this.map(function() {
11855 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
11856 });
11857 },
11858
11859 html: function( value ) {
11860 return access( this, function( value ) {
11861 var elem = this[ 0 ] || {},
11862 i = 0,
11863 l = this.length;
11864
11865 if ( value === undefined && elem.nodeType === 1 ) {
11866 return elem.innerHTML;
11867 }
11868
11869 // See if we can take a shortcut and just use innerHTML
11870 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
11871 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
11872
11873 value = value.replace( rxhtmlTag, "<$1></$2>" );
11874
11875 try {
11876 for ( ; i < l; i++ ) {
11877 elem = this[ i ] || {};
11878
11879 // Remove element nodes and prevent memory leaks
11880 if ( elem.nodeType === 1 ) {
11881 jQuery.cleanData( getAll( elem, false ) );
11882 elem.innerHTML = value;
11883 }
11884 }
11885
11886 elem = 0;
11887
11888 // If using innerHTML throws an exception, use the fallback method
11889 } catch( e ) {}
11890 }
11891
11892 if ( elem ) {
11893 this.empty().append( value );
11894 }
11895 }, null, value, arguments.length );
11896 },
11897
11898 replaceWith: function() {
11899 var arg = arguments[ 0 ];
11900
11901 // Make the changes, replacing each context element with the new content
11902 this.domManip( arguments, function( elem ) {
11903 arg = this.parentNode;
11904
11905 jQuery.cleanData( getAll( this ) );
11906
11907 if ( arg ) {
11908 arg.replaceChild( elem, this );
11909 }
11910 });
11911
11912 // Force removal if there was no new content (e.g., from empty arguments)
11913 return arg && (arg.length || arg.nodeType) ? this : this.remove();
11914 },
11915
11916 detach: function( selector ) {
11917 return this.remove( selector, true );
11918 },
11919
11920 domManip: function( args, callback ) {
11921
11922 // Flatten any nested arrays
11923 args = concat.apply( [], args );
11924
11925 var fragment, first, scripts, hasScripts, node, doc,
11926 i = 0,
11927 l = this.length,
11928 set = this,
11929 iNoClone = l - 1,
11930 value = args[ 0 ],
11931 isFunction = jQuery.isFunction( value );
11932
11933 // We can't cloneNode fragments that contain checked, in WebKit
11934 if ( isFunction ||
11935 ( l > 1 && typeof value === "string" &&
11936 !support.checkClone && rchecked.test( value ) ) ) {
11937 return this.each(function( index ) {
11938 var self = set.eq( index );
11939 if ( isFunction ) {
11940 args[ 0 ] = value.call( this, index, self.html() );
11941 }
11942 self.domManip( args, callback );
11943 });
11944 }
11945
11946 if ( l ) {
11947 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
11948 first = fragment.firstChild;
11949
11950 if ( fragment.childNodes.length === 1 ) {
11951 fragment = first;
11952 }
11953
11954 if ( first ) {
11955 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
11956 hasScripts = scripts.length;
11957
11958 // Use the original fragment for the last item instead of the first because it can end up
11959 // being emptied incorrectly in certain situations (#8070).
11960 for ( ; i < l; i++ ) {
11961 node = fragment;
11962
11963 if ( i !== iNoClone ) {
11964 node = jQuery.clone( node, true, true );
11965
11966 // Keep references to cloned scripts for later restoration
11967 if ( hasScripts ) {
11968 // Support: QtWebKit
11969 // jQuery.merge because push.apply(_, arraylike) throws
11970 jQuery.merge( scripts, getAll( node, "script" ) );
11971 }
11972 }
11973
11974 callback.call( this[ i ], node, i );
11975 }
11976
11977 if ( hasScripts ) {
11978 doc = scripts[ scripts.length - 1 ].ownerDocument;
11979
11980 // Reenable scripts
11981 jQuery.map( scripts, restoreScript );
11982
11983 // Evaluate executable scripts on first document insertion
11984 for ( i = 0; i < hasScripts; i++ ) {
11985 node = scripts[ i ];
11986 if ( rscriptType.test( node.type || "" ) &&
11987 !data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
11988
11989 if ( node.src ) {
11990 // Optional AJAX dependency, but won't run scripts if not present
11991 if ( jQuery._evalUrl ) {
11992 jQuery._evalUrl( node.src );
11993 }
11994 } else {
11995 jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) );
11996 }
11997 }
11998 }
11999 }
12000 }
12001 }
12002
12003 return this;
12004 }
12005 });
12006
12007 jQuery.each({
12008 appendTo: "append",
12009 prependTo: "prepend",
12010 insertBefore: "before",
12011 insertAfter: "after",
12012 replaceAll: "replaceWith"
12013 }, function( name, original ) {
12014 jQuery.fn[ name ] = function( selector ) {
12015 var elems,
12016 ret = [],
12017 insert = jQuery( selector ),
12018 last = insert.length - 1,
12019 i = 0;
12020
12021 for ( ; i <= last; i++ ) {
12022 elems = i === last ? this : this.clone( true );
12023 jQuery( insert[ i ] )[ original ]( elems );
12024
12025 // Support: QtWebKit
12026 // .get() because push.apply(_, arraylike) throws
12027 push.apply( ret, elems.get() );
12028 }
12029
12030 return this.pushStack( ret );
12031 };
12032 });
12033
12034
12035 var iframe,
12036 elemdisplay = {};
12037
12038 /**
12039 * Retrieve the actual display of a element
12040 * @param {String} name nodeName of the element
12041 * @param {Object} doc Document object
12042 */
12043 // Called only from within defaultDisplay
12044 function actualDisplay( name, doc ) {
12045 var style,
12046 elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
12047
12048 // getDefaultComputedStyle might be reliably used only on attached element
12049 display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
12050
12051 // Use of this method is a temporary fix (more like optmization) until something better comes along,
12052 // since it was removed from specification and supported only in FF
12053 style.display : jQuery.css( elem[ 0 ], "display" );
12054
12055 // We don't have any data stored on the element,
12056 // so use "detach" method as fast way to get rid of the element
12057 elem.detach();
12058
12059 return display;
12060 }
12061
12062 /**
12063 * Try to determine the default display value of an element
12064 * @param {String} nodeName
12065 */
12066 function defaultDisplay( nodeName ) {
12067 var doc = document,
12068 display = elemdisplay[ nodeName ];
12069
12070 if ( !display ) {
12071 display = actualDisplay( nodeName, doc );
12072
12073 // If the simple way fails, read from inside an iframe
12074 if ( display === "none" || !display ) {
12075
12076 // Use the already-created iframe if possible
12077 iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
12078
12079 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
12080 doc = iframe[ 0 ].contentDocument;
12081
12082 // Support: IE
12083 doc.write();
12084 doc.close();
12085
12086 display = actualDisplay( nodeName, doc );
12087 iframe.detach();
12088 }
12089
12090 // Store the correct default display
12091 elemdisplay[ nodeName ] = display;
12092 }
12093
12094 return display;
12095 }
12096 var rmargin = (/^margin/);
12097
12098 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
12099
12100 var getStyles = function( elem ) {
12101 return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
12102 };
12103
12104
12105
12106 function curCSS( elem, name, computed ) {
12107 var width, minWidth, maxWidth, ret,
12108 style = elem.style;
12109
12110 computed = computed || getStyles( elem );
12111
12112 // Support: IE9
12113 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
12114 if ( computed ) {
12115 ret = computed.getPropertyValue( name ) || computed[ name ];
12116 }
12117
12118 if ( computed ) {
12119
12120 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
12121 ret = jQuery.style( elem, name );
12122 }
12123
12124 // Support: iOS < 6
12125 // A tribute to the "awesome hack by Dean Edwards"
12126 // iOS < 6 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
12127 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
12128 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
12129
12130 // Remember the original values
12131 width = style.width;
12132 minWidth = style.minWidth;
12133 maxWidth = style.maxWidth;
12134
12135 // Put in the new values to get a computed value out
12136 style.minWidth = style.maxWidth = style.width = ret;
12137 ret = computed.width;
12138
12139 // Revert the changed values
12140 style.width = width;
12141 style.minWidth = minWidth;
12142 style.maxWidth = maxWidth;
12143 }
12144 }
12145
12146 return ret !== undefined ?
12147 // Support: IE
12148 // IE returns zIndex value as an integer.
12149 ret + "" :
12150 ret;
12151 }
12152
12153
12154 function addGetHookIf( conditionFn, hookFn ) {
12155 // Define the hook, we'll check on the first run if it's really needed.
12156 return {
12157 get: function() {
12158 if ( conditionFn() ) {
12159 // Hook not needed (or it's not possible to use it due to missing dependency),
12160 // remove it.
12161 // Since there are no other hooks for marginRight, remove the whole object.
12162 delete this.get;
12163 return;
12164 }
12165
12166 // Hook needed; redefine it so that the support test is not executed again.
12167
12168 return (this.get = hookFn).apply( this, arguments );
12169 }
12170 };
12171 }
12172
12173
12174 (function() {
12175 var pixelPositionVal, boxSizingReliableVal,
12176 docElem = document.documentElement,
12177 container = document.createElement( "div" ),
12178 div = document.createElement( "div" );
12179
12180 if ( !div.style ) {
12181 return;
12182 }
12183
12184 div.style.backgroundClip = "content-box";
12185 div.cloneNode( true ).style.backgroundClip = "";
12186 support.clearCloneStyle = div.style.backgroundClip === "content-box";
12187
12188 container.style.cssText = "border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;" +
12189 "position:absolute";
12190 container.appendChild( div );
12191
12192 // Executing both pixelPosition & boxSizingReliable tests require only one layout
12193 // so they're executed at the same time to save the second computation.
12194 function computePixelPositionAndBoxSizingReliable() {
12195 div.style.cssText =
12196 // Support: Firefox<29, Android 2.3
12197 // Vendor-prefix box-sizing
12198 "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
12199 "box-sizing:border-box;display:block;margin-top:1%;top:1%;" +
12200 "border:1px;padding:1px;width:4px;position:absolute";
12201 div.innerHTML = "";
12202 docElem.appendChild( container );
12203
12204 var divStyle = window.getComputedStyle( div, null );
12205 pixelPositionVal = divStyle.top !== "1%";
12206 boxSizingReliableVal = divStyle.width === "4px";
12207
12208 docElem.removeChild( container );
12209 }
12210
12211 // Support: node.js jsdom
12212 // Don't assume that getComputedStyle is a property of the global object
12213 if ( window.getComputedStyle ) {
12214 jQuery.extend( support, {
12215 pixelPosition: function() {
12216 // This test is executed only once but we still do memoizing
12217 // since we can use the boxSizingReliable pre-computing.
12218 // No need to check if the test was already performed, though.
12219 computePixelPositionAndBoxSizingReliable();
12220 return pixelPositionVal;
12221 },
12222 boxSizingReliable: function() {
12223 if ( boxSizingReliableVal == null ) {
12224 computePixelPositionAndBoxSizingReliable();
12225 }
12226 return boxSizingReliableVal;
12227 },
12228 reliableMarginRight: function() {
12229 // Support: Android 2.3
12230 // Check if div with explicit width and no margin-right incorrectly
12231 // gets computed margin-right based on width of container. (#3333)
12232 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
12233 // This support function is only executed once so no memoizing is needed.
12234 var ret,
12235 marginDiv = div.appendChild( document.createElement( "div" ) );
12236
12237 // Reset CSS: box-sizing; display; margin; border; padding
12238 marginDiv.style.cssText = div.style.cssText =
12239 // Support: Firefox<29, Android 2.3
12240 // Vendor-prefix box-sizing
12241 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
12242 "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
12243 marginDiv.style.marginRight = marginDiv.style.width = "0";
12244 div.style.width = "1px";
12245 docElem.appendChild( container );
12246
12247 ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );
12248
12249 docElem.removeChild( container );
12250
12251 return ret;
12252 }
12253 });
12254 }
12255 })();
12256
12257
12258 // A method for quickly swapping in/out CSS properties to get correct calculations.
12259 jQuery.swap = function( elem, options, callback, args ) {
12260 var ret, name,
12261 old = {};
12262
12263 // Remember the old values, and insert the new ones
12264 for ( name in options ) {
12265 old[ name ] = elem.style[ name ];
12266 elem.style[ name ] = options[ name ];
12267 }
12268
12269 ret = callback.apply( elem, args || [] );
12270
12271 // Revert the old values
12272 for ( name in options ) {
12273 elem.style[ name ] = old[ name ];
12274 }
12275
12276 return ret;
12277 };
12278
12279
12280 var
12281 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
12282 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
12283 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
12284 rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
12285 rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
12286
12287 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
12288 cssNormalTransform = {
12289 letterSpacing: "0",
12290 fontWeight: "400"
12291 },
12292
12293 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
12294
12295 // return a css property mapped to a potentially vendor prefixed property
12296 function vendorPropName( style, name ) {
12297
12298 // shortcut for names that are not vendor prefixed
12299 if ( name in style ) {
12300 return name;
12301 }
12302
12303 // check for vendor prefixed names
12304 var capName = name[0].toUpperCase() + name.slice(1),
12305 origName = name,
12306 i = cssPrefixes.length;
12307
12308 while ( i-- ) {
12309 name = cssPrefixes[ i ] + capName;
12310 if ( name in style ) {
12311 return name;
12312 }
12313 }
12314
12315 return origName;
12316 }
12317
12318 function setPositiveNumber( elem, value, subtract ) {
12319 var matches = rnumsplit.exec( value );
12320 return matches ?
12321 // Guard against undefined "subtract", e.g., when used as in cssHooks
12322 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
12323 value;
12324 }
12325
12326 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
12327 var i = extra === ( isBorderBox ? "border" : "content" ) ?
12328 // If we already have the right measurement, avoid augmentation
12329 4 :
12330 // Otherwise initialize for horizontal or vertical properties
12331 name === "width" ? 1 : 0,
12332
12333 val = 0;
12334
12335 for ( ; i < 4; i += 2 ) {
12336 // both box models exclude margin, so add it if we want it
12337 if ( extra === "margin" ) {
12338 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
12339 }
12340
12341 if ( isBorderBox ) {
12342 // border-box includes padding, so remove it if we want content
12343 if ( extra === "content" ) {
12344 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
12345 }
12346
12347 // at this point, extra isn't border nor margin, so remove border
12348 if ( extra !== "margin" ) {
12349 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
12350 }
12351 } else {
12352 // at this point, extra isn't content, so add padding
12353 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
12354
12355 // at this point, extra isn't content nor padding, so add border
12356 if ( extra !== "padding" ) {
12357 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
12358 }
12359 }
12360 }
12361
12362 return val;
12363 }
12364
12365 function getWidthOrHeight( elem, name, extra ) {
12366
12367 // Start with offset property, which is equivalent to the border-box value
12368 var valueIsBorderBox = true,
12369 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
12370 styles = getStyles( elem ),
12371 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
12372
12373 // some non-html elements return undefined for offsetWidth, so check for null/undefined
12374 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
12375 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
12376 if ( val <= 0 || val == null ) {
12377 // Fall back to computed then uncomputed css if necessary
12378 val = curCSS( elem, name, styles );
12379 if ( val < 0 || val == null ) {
12380 val = elem.style[ name ];
12381 }
12382
12383 // Computed unit is not pixels. Stop here and return.
12384 if ( rnumnonpx.test(val) ) {
12385 return val;
12386 }
12387
12388 // we need the check for style in case a browser which returns unreliable values
12389 // for getComputedStyle silently falls back to the reliable elem.style
12390 valueIsBorderBox = isBorderBox &&
12391 ( support.boxSizingReliable() || val === elem.style[ name ] );
12392
12393 // Normalize "", auto, and prepare for extra
12394 val = parseFloat( val ) || 0;
12395 }
12396
12397 // use the active box-sizing model to add/subtract irrelevant styles
12398 return ( val +
12399 augmentWidthOrHeight(
12400 elem,
12401 name,
12402 extra || ( isBorderBox ? "border" : "content" ),
12403 valueIsBorderBox,
12404 styles
12405 )
12406 ) + "px";
12407 }
12408
12409 function showHide( elements, show ) {
12410 var display, elem, hidden,
12411 values = [],
12412 index = 0,
12413 length = elements.length;
12414
12415 for ( ; index < length; index++ ) {
12416 elem = elements[ index ];
12417 if ( !elem.style ) {
12418 continue;
12419 }
12420
12421 values[ index ] = data_priv.get( elem, "olddisplay" );
12422 display = elem.style.display;
12423 if ( show ) {
12424 // Reset the inline display of this element to learn if it is
12425 // being hidden by cascaded rules or not
12426 if ( !values[ index ] && display === "none" ) {
12427 elem.style.display = "";
12428 }
12429
12430 // Set elements which have been overridden with display: none
12431 // in a stylesheet to whatever the default browser style is
12432 // for such an element
12433 if ( elem.style.display === "" && isHidden( elem ) ) {
12434 values[ index ] = data_priv.access( elem, "olddisplay", defaultDisplay(elem.nodeName) );
12435 }
12436 } else {
12437 hidden = isHidden( elem );
12438
12439 if ( display !== "none" || !hidden ) {
12440 data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
12441 }
12442 }
12443 }
12444
12445 // Set the display of most of the elements in a second loop
12446 // to avoid the constant reflow
12447 for ( index = 0; index < length; index++ ) {
12448 elem = elements[ index ];
12449 if ( !elem.style ) {
12450 continue;
12451 }
12452 if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
12453 elem.style.display = show ? values[ index ] || "" : "none";
12454 }
12455 }
12456
12457 return elements;
12458 }
12459
12460 jQuery.extend({
12461 // Add in style property hooks for overriding the default
12462 // behavior of getting and setting a style property
12463 cssHooks: {
12464 opacity: {
12465 get: function( elem, computed ) {
12466 if ( computed ) {
12467 // We should always get a number back from opacity
12468 var ret = curCSS( elem, "opacity" );
12469 return ret === "" ? "1" : ret;
12470 }
12471 }
12472 }
12473 },
12474
12475 // Don't automatically add "px" to these possibly-unitless properties
12476 cssNumber: {
12477 "columnCount": true,
12478 "fillOpacity": true,
12479 "flexGrow": true,
12480 "flexShrink": true,
12481 "fontWeight": true,
12482 "lineHeight": true,
12483 "opacity": true,
12484 "order": true,
12485 "orphans": true,
12486 "widows": true,
12487 "zIndex": true,
12488 "zoom": true
12489 },
12490
12491 // Add in properties whose names you wish to fix before
12492 // setting or getting the value
12493 cssProps: {
12494 // normalize float css property
12495 "float": "cssFloat"
12496 },
12497
12498 // Get and set the style property on a DOM Node
12499 style: function( elem, name, value, extra ) {
12500 // Don't set styles on text and comment nodes
12501 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
12502 return;
12503 }
12504
12505 // Make sure that we're working with the right name
12506 var ret, type, hooks,
12507 origName = jQuery.camelCase( name ),
12508 style = elem.style;
12509
12510 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
12511
12512 // gets hook for the prefixed version
12513 // followed by the unprefixed version
12514 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
12515
12516 // Check if we're setting a value
12517 if ( value !== undefined ) {
12518 type = typeof value;
12519
12520 // convert relative number strings (+= or -=) to relative numbers. #7345
12521 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
12522 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
12523 // Fixes bug #9237
12524 type = "number";
12525 }
12526
12527 // Make sure that null and NaN values aren't set. See: #7116
12528 if ( value == null || value !== value ) {
12529 return;
12530 }
12531
12532 // If a number was passed in, add 'px' to the (except for certain CSS properties)
12533 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
12534 value += "px";
12535 }
12536
12537 // Fixes #8908, it can be done more correctly by specifying setters in cssHooks,
12538 // but it would mean to define eight (for every problematic property) identical functions
12539 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
12540 style[ name ] = "inherit";
12541 }
12542
12543 // If a hook was provided, use that value, otherwise just set the specified value
12544 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
12545 style[ name ] = value;
12546 }
12547
12548 } else {
12549 // If a hook was provided get the non-computed value from there
12550 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
12551 return ret;
12552 }
12553
12554 // Otherwise just get the value from the style object
12555 return style[ name ];
12556 }
12557 },
12558
12559 css: function( elem, name, extra, styles ) {
12560 var val, num, hooks,
12561 origName = jQuery.camelCase( name );
12562
12563 // Make sure that we're working with the right name
12564 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
12565
12566 // gets hook for the prefixed version
12567 // followed by the unprefixed version
12568 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
12569
12570 // If a hook was provided get the computed value from there
12571 if ( hooks && "get" in hooks ) {
12572 val = hooks.get( elem, true, extra );
12573 }
12574
12575 // Otherwise, if a way to get the computed value exists, use that
12576 if ( val === undefined ) {
12577 val = curCSS( elem, name, styles );
12578 }
12579
12580 //convert "normal" to computed value
12581 if ( val === "normal" && name in cssNormalTransform ) {
12582 val = cssNormalTransform[ name ];
12583 }
12584
12585 // Return, converting to number if forced or a qualifier was provided and val looks numeric
12586 if ( extra === "" || extra ) {
12587 num = parseFloat( val );
12588 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
12589 }
12590 return val;
12591 }
12592 });
12593
12594 jQuery.each([ "height", "width" ], function( i, name ) {
12595 jQuery.cssHooks[ name ] = {
12596 get: function( elem, computed, extra ) {
12597 if ( computed ) {
12598 // certain elements can have dimension info if we invisibly show them
12599 // however, it must have a current display style that would benefit from this
12600 return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ?
12601 jQuery.swap( elem, cssShow, function() {
12602 return getWidthOrHeight( elem, name, extra );
12603 }) :
12604 getWidthOrHeight( elem, name, extra );
12605 }
12606 },
12607
12608 set: function( elem, value, extra ) {
12609 var styles = extra && getStyles( elem );
12610 return setPositiveNumber( elem, value, extra ?
12611 augmentWidthOrHeight(
12612 elem,
12613 name,
12614 extra,
12615 jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
12616 styles
12617 ) : 0
12618 );
12619 }
12620 };
12621 });
12622
12623 // Support: Android 2.3
12624 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
12625 function( elem, computed ) {
12626 if ( computed ) {
12627 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
12628 // Work around by temporarily setting element display to inline-block
12629 return jQuery.swap( elem, { "display": "inline-block" },
12630 curCSS, [ elem, "marginRight" ] );
12631 }
12632 }
12633 );
12634
12635 // These hooks are used by animate to expand properties
12636 jQuery.each({
12637 margin: "",
12638 padding: "",
12639 border: "Width"
12640 }, function( prefix, suffix ) {
12641 jQuery.cssHooks[ prefix + suffix ] = {
12642 expand: function( value ) {
12643 var i = 0,
12644 expanded = {},
12645
12646 // assumes a single number if not a string
12647 parts = typeof value === "string" ? value.split(" ") : [ value ];
12648
12649 for ( ; i < 4; i++ ) {
12650 expanded[ prefix + cssExpand[ i ] + suffix ] =
12651 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
12652 }
12653
12654 return expanded;
12655 }
12656 };
12657
12658 if ( !rmargin.test( prefix ) ) {
12659 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
12660 }
12661 });
12662
12663 jQuery.fn.extend({
12664 css: function( name, value ) {
12665 return access( this, function( elem, name, value ) {
12666 var styles, len,
12667 map = {},
12668 i = 0;
12669
12670 if ( jQuery.isArray( name ) ) {
12671 styles = getStyles( elem );
12672 len = name.length;
12673
12674 for ( ; i < len; i++ ) {
12675 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
12676 }
12677
12678 return map;
12679 }
12680
12681 return value !== undefined ?
12682 jQuery.style( elem, name, value ) :
12683 jQuery.css( elem, name );
12684 }, name, value, arguments.length > 1 );
12685 },
12686 show: function() {
12687 return showHide( this, true );
12688 },
12689 hide: function() {
12690 return showHide( this );
12691 },
12692 toggle: function( state ) {
12693 if ( typeof state === "boolean" ) {
12694 return state ? this.show() : this.hide();
12695 }
12696
12697 return this.each(function() {
12698 if ( isHidden( this ) ) {
12699 jQuery( this ).show();
12700 } else {
12701 jQuery( this ).hide();
12702 }
12703 });
12704 }
12705 });
12706
12707
12708 function Tween( elem, options, prop, end, easing ) {
12709 return new Tween.prototype.init( elem, options, prop, end, easing );
12710 }
12711 jQuery.Tween = Tween;
12712
12713 Tween.prototype = {
12714 constructor: Tween,
12715 init: function( elem, options, prop, end, easing, unit ) {
12716 this.elem = elem;
12717 this.prop = prop;
12718 this.easing = easing || "swing";
12719 this.options = options;
12720 this.start = this.now = this.cur();
12721 this.end = end;
12722 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
12723 },
12724 cur: function() {
12725 var hooks = Tween.propHooks[ this.prop ];
12726
12727 return hooks && hooks.get ?
12728 hooks.get( this ) :
12729 Tween.propHooks._default.get( this );
12730 },
12731 run: function( percent ) {
12732 var eased,
12733 hooks = Tween.propHooks[ this.prop ];
12734
12735 if ( this.options.duration ) {
12736 this.pos = eased = jQuery.easing[ this.easing ](
12737 percent, this.options.duration * percent, 0, 1, this.options.duration
12738 );
12739 } else {
12740 this.pos = eased = percent;
12741 }
12742 this.now = ( this.end - this.start ) * eased + this.start;
12743
12744 if ( this.options.step ) {
12745 this.options.step.call( this.elem, this.now, this );
12746 }
12747
12748 if ( hooks && hooks.set ) {
12749 hooks.set( this );
12750 } else {
12751 Tween.propHooks._default.set( this );
12752 }
12753 return this;
12754 }
12755 };
12756
12757 Tween.prototype.init.prototype = Tween.prototype;
12758
12759 Tween.propHooks = {
12760 _default: {
12761 get: function( tween ) {
12762 var result;
12763
12764 if ( tween.elem[ tween.prop ] != null &&
12765 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
12766 return tween.elem[ tween.prop ];
12767 }
12768
12769 // passing an empty string as a 3rd parameter to .css will automatically
12770 // attempt a parseFloat and fallback to a string if the parse fails
12771 // so, simple values such as "10px" are parsed to Float.
12772 // complex values such as "rotate(1rad)" are returned as is.
12773 result = jQuery.css( tween.elem, tween.prop, "" );
12774 // Empty strings, null, undefined and "auto" are converted to 0.
12775 return !result || result === "auto" ? 0 : result;
12776 },
12777 set: function( tween ) {
12778 // use step hook for back compat - use cssHook if its there - use .style if its
12779 // available and use plain properties where available
12780 if ( jQuery.fx.step[ tween.prop ] ) {
12781 jQuery.fx.step[ tween.prop ]( tween );
12782 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
12783 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
12784 } else {
12785 tween.elem[ tween.prop ] = tween.now;
12786 }
12787 }
12788 }
12789 };
12790
12791 // Support: IE9
12792 // Panic based approach to setting things on disconnected nodes
12793
12794 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
12795 set: function( tween ) {
12796 if ( tween.elem.nodeType && tween.elem.parentNode ) {
12797 tween.elem[ tween.prop ] = tween.now;
12798 }
12799 }
12800 };
12801
12802 jQuery.easing = {
12803 linear: function( p ) {
12804 return p;
12805 },
12806 swing: function( p ) {
12807 return 0.5 - Math.cos( p * Math.PI ) / 2;
12808 }
12809 };
12810
12811 jQuery.fx = Tween.prototype.init;
12812
12813 // Back Compat <1.8 extension point
12814 jQuery.fx.step = {};
12815
12816
12817
12818
12819 var
12820 fxNow, timerId,
12821 rfxtypes = /^(?:toggle|show|hide)$/,
12822 rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
12823 rrun = /queueHooks$/,
12824 animationPrefilters = [ defaultPrefilter ],
12825 tweeners = {
12826 "*": [ function( prop, value ) {
12827 var tween = this.createTween( prop, value ),
12828 target = tween.cur(),
12829 parts = rfxnum.exec( value ),
12830 unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
12831
12832 // Starting value computation is required for potential unit mismatches
12833 start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
12834 rfxnum.exec( jQuery.css( tween.elem, prop ) ),
12835 scale = 1,
12836 maxIterations = 20;
12837
12838 if ( start && start[ 3 ] !== unit ) {
12839 // Trust units reported by jQuery.css
12840 unit = unit || start[ 3 ];
12841
12842 // Make sure we update the tween properties later on
12843 parts = parts || [];
12844
12845 // Iteratively approximate from a nonzero starting point
12846 start = +target || 1;
12847
12848 do {
12849 // If previous iteration zeroed out, double until we get *something*
12850 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
12851 scale = scale || ".5";
12852
12853 // Adjust and apply
12854 start = start / scale;
12855 jQuery.style( tween.elem, prop, start + unit );
12856
12857 // Update scale, tolerating zero or NaN from tween.cur()
12858 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
12859 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
12860 }
12861
12862 // Update tween properties
12863 if ( parts ) {
12864 start = tween.start = +start || +target || 0;
12865 tween.unit = unit;
12866 // If a +=/-= token was provided, we're doing a relative animation
12867 tween.end = parts[ 1 ] ?
12868 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
12869 +parts[ 2 ];
12870 }
12871
12872 return tween;
12873 } ]
12874 };
12875
12876 // Animations created synchronously will run synchronously
12877 function createFxNow() {
12878 setTimeout(function() {
12879 fxNow = undefined;
12880 });
12881 return ( fxNow = jQuery.now() );
12882 }
12883
12884 // Generate parameters to create a standard animation
12885 function genFx( type, includeWidth ) {
12886 var which,
12887 i = 0,
12888 attrs = { height: type };
12889
12890 // if we include width, step value is 1 to do all cssExpand values,
12891 // if we don't include width, step value is 2 to skip over Left and Right
12892 includeWidth = includeWidth ? 1 : 0;
12893 for ( ; i < 4 ; i += 2 - includeWidth ) {
12894 which = cssExpand[ i ];
12895 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
12896 }
12897
12898 if ( includeWidth ) {
12899 attrs.opacity = attrs.width = type;
12900 }
12901
12902 return attrs;
12903 }
12904
12905 function createTween( value, prop, animation ) {
12906 var tween,
12907 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
12908 index = 0,
12909 length = collection.length;
12910 for ( ; index < length; index++ ) {
12911 if ( (tween = collection[ index ].call( animation, prop, value )) ) {
12912
12913 // we're done with this property
12914 return tween;
12915 }
12916 }
12917 }
12918
12919 function defaultPrefilter( elem, props, opts ) {
12920 /* jshint validthis: true */
12921 var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
12922 anim = this,
12923 orig = {},
12924 style = elem.style,
12925 hidden = elem.nodeType && isHidden( elem ),
12926 dataShow = data_priv.get( elem, "fxshow" );
12927
12928 // handle queue: false promises
12929 if ( !opts.queue ) {
12930 hooks = jQuery._queueHooks( elem, "fx" );
12931 if ( hooks.unqueued == null ) {
12932 hooks.unqueued = 0;
12933 oldfire = hooks.empty.fire;
12934 hooks.empty.fire = function() {
12935 if ( !hooks.unqueued ) {
12936 oldfire();
12937 }
12938 };
12939 }
12940 hooks.unqueued++;
12941
12942 anim.always(function() {
12943 // doing this makes sure that the complete handler will be called
12944 // before this completes
12945 anim.always(function() {
12946 hooks.unqueued--;
12947 if ( !jQuery.queue( elem, "fx" ).length ) {
12948 hooks.empty.fire();
12949 }
12950 });
12951 });
12952 }
12953
12954 // height/width overflow pass
12955 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
12956 // Make sure that nothing sneaks out
12957 // Record all 3 overflow attributes because IE9-10 do not
12958 // change the overflow attribute when overflowX and
12959 // overflowY are set to the same value
12960 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
12961
12962 // Set display property to inline-block for height/width
12963 // animations on inline elements that are having width/height animated
12964 display = jQuery.css( elem, "display" );
12965
12966 // Test default display if display is currently "none"
12967 checkDisplay = display === "none" ?
12968 data_priv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
12969
12970 if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
12971 style.display = "inline-block";
12972 }
12973 }
12974
12975 if ( opts.overflow ) {
12976 style.overflow = "hidden";
12977 anim.always(function() {
12978 style.overflow = opts.overflow[ 0 ];
12979 style.overflowX = opts.overflow[ 1 ];
12980 style.overflowY = opts.overflow[ 2 ];
12981 });
12982 }
12983
12984 // show/hide pass
12985 for ( prop in props ) {
12986 value = props[ prop ];
12987 if ( rfxtypes.exec( value ) ) {
12988 delete props[ prop ];
12989 toggle = toggle || value === "toggle";
12990 if ( value === ( hidden ? "hide" : "show" ) ) {
12991
12992 // 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
12993 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
12994 hidden = true;
12995 } else {
12996 continue;
12997 }
12998 }
12999 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
13000
13001 // Any non-fx value stops us from restoring the original display value
13002 } else {
13003 display = undefined;
13004 }
13005 }
13006
13007 if ( !jQuery.isEmptyObject( orig ) ) {
13008 if ( dataShow ) {
13009 if ( "hidden" in dataShow ) {
13010 hidden = dataShow.hidden;
13011 }
13012 } else {
13013 dataShow = data_priv.access( elem, "fxshow", {} );
13014 }
13015
13016 // store state if its toggle - enables .stop().toggle() to "reverse"
13017 if ( toggle ) {
13018 dataShow.hidden = !hidden;
13019 }
13020 if ( hidden ) {
13021 jQuery( elem ).show();
13022 } else {
13023 anim.done(function() {
13024 jQuery( elem ).hide();
13025 });
13026 }
13027 anim.done(function() {
13028 var prop;
13029
13030 data_priv.remove( elem, "fxshow" );
13031 for ( prop in orig ) {
13032 jQuery.style( elem, prop, orig[ prop ] );
13033 }
13034 });
13035 for ( prop in orig ) {
13036 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
13037
13038 if ( !( prop in dataShow ) ) {
13039 dataShow[ prop ] = tween.start;
13040 if ( hidden ) {
13041 tween.end = tween.start;
13042 tween.start = prop === "width" || prop === "height" ? 1 : 0;
13043 }
13044 }
13045 }
13046
13047 // If this is a noop like .hide().hide(), restore an overwritten display value
13048 } else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) {
13049 style.display = display;
13050 }
13051 }
13052
13053 function propFilter( props, specialEasing ) {
13054 var index, name, easing, value, hooks;
13055
13056 // camelCase, specialEasing and expand cssHook pass
13057 for ( index in props ) {
13058 name = jQuery.camelCase( index );
13059 easing = specialEasing[ name ];
13060 value = props[ index ];
13061 if ( jQuery.isArray( value ) ) {
13062 easing = value[ 1 ];
13063 value = props[ index ] = value[ 0 ];
13064 }
13065
13066 if ( index !== name ) {
13067 props[ name ] = value;
13068 delete props[ index ];
13069 }
13070
13071 hooks = jQuery.cssHooks[ name ];
13072 if ( hooks && "expand" in hooks ) {
13073 value = hooks.expand( value );
13074 delete props[ name ];
13075
13076 // not quite $.extend, this wont overwrite keys already present.
13077 // also - reusing 'index' from above because we have the correct "name"
13078 for ( index in value ) {
13079 if ( !( index in props ) ) {
13080 props[ index ] = value[ index ];
13081 specialEasing[ index ] = easing;
13082 }
13083 }
13084 } else {
13085 specialEasing[ name ] = easing;
13086 }
13087 }
13088 }
13089
13090 function Animation( elem, properties, options ) {
13091 var result,
13092 stopped,
13093 index = 0,
13094 length = animationPrefilters.length,
13095 deferred = jQuery.Deferred().always( function() {
13096 // don't match elem in the :animated selector
13097 delete tick.elem;
13098 }),
13099 tick = function() {
13100 if ( stopped ) {
13101 return false;
13102 }
13103 var currentTime = fxNow || createFxNow(),
13104 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
13105 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
13106 temp = remaining / animation.duration || 0,
13107 percent = 1 - temp,
13108 index = 0,
13109 length = animation.tweens.length;
13110
13111 for ( ; index < length ; index++ ) {
13112 animation.tweens[ index ].run( percent );
13113 }
13114
13115 deferred.notifyWith( elem, [ animation, percent, remaining ]);
13116
13117 if ( percent < 1 && length ) {
13118 return remaining;
13119 } else {
13120 deferred.resolveWith( elem, [ animation ] );
13121 return false;
13122 }
13123 },
13124 animation = deferred.promise({
13125 elem: elem,
13126 props: jQuery.extend( {}, properties ),
13127 opts: jQuery.extend( true, { specialEasing: {} }, options ),
13128 originalProperties: properties,
13129 originalOptions: options,
13130 startTime: fxNow || createFxNow(),
13131 duration: options.duration,
13132 tweens: [],
13133 createTween: function( prop, end ) {
13134 var tween = jQuery.Tween( elem, animation.opts, prop, end,
13135 animation.opts.specialEasing[ prop ] || animation.opts.easing );
13136 animation.tweens.push( tween );
13137 return tween;
13138 },
13139 stop: function( gotoEnd ) {
13140 var index = 0,
13141 // if we are going to the end, we want to run all the tweens
13142 // otherwise we skip this part
13143 length = gotoEnd ? animation.tweens.length : 0;
13144 if ( stopped ) {
13145 return this;
13146 }
13147 stopped = true;
13148 for ( ; index < length ; index++ ) {
13149 animation.tweens[ index ].run( 1 );
13150 }
13151
13152 // resolve when we played the last frame
13153 // otherwise, reject
13154 if ( gotoEnd ) {
13155 deferred.resolveWith( elem, [ animation, gotoEnd ] );
13156 } else {
13157 deferred.rejectWith( elem, [ animation, gotoEnd ] );
13158 }
13159 return this;
13160 }
13161 }),
13162 props = animation.props;
13163
13164 propFilter( props, animation.opts.specialEasing );
13165
13166 for ( ; index < length ; index++ ) {
13167 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
13168 if ( result ) {
13169 return result;
13170 }
13171 }
13172
13173 jQuery.map( props, createTween, animation );
13174
13175 if ( jQuery.isFunction( animation.opts.start ) ) {
13176 animation.opts.start.call( elem, animation );
13177 }
13178
13179 jQuery.fx.timer(
13180 jQuery.extend( tick, {
13181 elem: elem,
13182 anim: animation,
13183 queue: animation.opts.queue
13184 })
13185 );
13186
13187 // attach callbacks from options
13188 return animation.progress( animation.opts.progress )
13189 .done( animation.opts.done, animation.opts.complete )
13190 .fail( animation.opts.fail )
13191 .always( animation.opts.always );
13192 }
13193
13194 jQuery.Animation = jQuery.extend( Animation, {
13195
13196 tweener: function( props, callback ) {
13197 if ( jQuery.isFunction( props ) ) {
13198 callback = props;
13199 props = [ "*" ];
13200 } else {
13201 props = props.split(" ");
13202 }
13203
13204 var prop,
13205 index = 0,
13206 length = props.length;
13207
13208 for ( ; index < length ; index++ ) {
13209 prop = props[ index ];
13210 tweeners[ prop ] = tweeners[ prop ] || [];
13211 tweeners[ prop ].unshift( callback );
13212 }
13213 },
13214
13215 prefilter: function( callback, prepend ) {
13216 if ( prepend ) {
13217 animationPrefilters.unshift( callback );
13218 } else {
13219 animationPrefilters.push( callback );
13220 }
13221 }
13222 });
13223
13224 jQuery.speed = function( speed, easing, fn ) {
13225 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
13226 complete: fn || !fn && easing ||
13227 jQuery.isFunction( speed ) && speed,
13228 duration: speed,
13229 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
13230 };
13231
13232 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
13233 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
13234
13235 // normalize opt.queue - true/undefined/null -> "fx"
13236 if ( opt.queue == null || opt.queue === true ) {
13237 opt.queue = "fx";
13238 }
13239
13240 // Queueing
13241 opt.old = opt.complete;
13242
13243 opt.complete = function() {
13244 if ( jQuery.isFunction( opt.old ) ) {
13245 opt.old.call( this );
13246 }
13247
13248 if ( opt.queue ) {
13249 jQuery.dequeue( this, opt.queue );
13250 }
13251 };
13252
13253 return opt;
13254 };
13255
13256 jQuery.fn.extend({
13257 fadeTo: function( speed, to, easing, callback ) {
13258
13259 // show any hidden elements after setting opacity to 0
13260 return this.filter( isHidden ).css( "opacity", 0 ).show()
13261
13262 // animate to the value specified
13263 .end().animate({ opacity: to }, speed, easing, callback );
13264 },
13265 animate: function( prop, speed, easing, callback ) {
13266 var empty = jQuery.isEmptyObject( prop ),
13267 optall = jQuery.speed( speed, easing, callback ),
13268 doAnimation = function() {
13269 // Operate on a copy of prop so per-property easing won't be lost
13270 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
13271
13272 // Empty animations, or finishing resolves immediately
13273 if ( empty || data_priv.get( this, "finish" ) ) {
13274 anim.stop( true );
13275 }
13276 };
13277 doAnimation.finish = doAnimation;
13278
13279 return empty || optall.queue === false ?
13280 this.each( doAnimation ) :
13281 this.queue( optall.queue, doAnimation );
13282 },
13283 stop: function( type, clearQueue, gotoEnd ) {
13284 var stopQueue = function( hooks ) {
13285 var stop = hooks.stop;
13286 delete hooks.stop;
13287 stop( gotoEnd );
13288 };
13289
13290 if ( typeof type !== "string" ) {
13291 gotoEnd = clearQueue;
13292 clearQueue = type;
13293 type = undefined;
13294 }
13295 if ( clearQueue && type !== false ) {
13296 this.queue( type || "fx", [] );
13297 }
13298
13299 return this.each(function() {
13300 var dequeue = true,
13301 index = type != null && type + "queueHooks",
13302 timers = jQuery.timers,
13303 data = data_priv.get( this );
13304
13305 if ( index ) {
13306 if ( data[ index ] && data[ index ].stop ) {
13307 stopQueue( data[ index ] );
13308 }
13309 } else {
13310 for ( index in data ) {
13311 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
13312 stopQueue( data[ index ] );
13313 }
13314 }
13315 }
13316
13317 for ( index = timers.length; index--; ) {
13318 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
13319 timers[ index ].anim.stop( gotoEnd );
13320 dequeue = false;
13321 timers.splice( index, 1 );
13322 }
13323 }
13324
13325 // start the next in the queue if the last step wasn't forced
13326 // timers currently will call their complete callbacks, which will dequeue
13327 // but only if they were gotoEnd
13328 if ( dequeue || !gotoEnd ) {
13329 jQuery.dequeue( this, type );
13330 }
13331 });
13332 },
13333 finish: function( type ) {
13334 if ( type !== false ) {
13335 type = type || "fx";
13336 }
13337 return this.each(function() {
13338 var index,
13339 data = data_priv.get( this ),
13340 queue = data[ type + "queue" ],
13341 hooks = data[ type + "queueHooks" ],
13342 timers = jQuery.timers,
13343 length = queue ? queue.length : 0;
13344
13345 // enable finishing flag on private data
13346 data.finish = true;
13347
13348 // empty the queue first
13349 jQuery.queue( this, type, [] );
13350
13351 if ( hooks && hooks.stop ) {
13352 hooks.stop.call( this, true );
13353 }
13354
13355 // look for any active animations, and finish them
13356 for ( index = timers.length; index--; ) {
13357 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
13358 timers[ index ].anim.stop( true );
13359 timers.splice( index, 1 );
13360 }
13361 }
13362
13363 // look for any animations in the old queue and finish them
13364 for ( index = 0; index < length; index++ ) {
13365 if ( queue[ index ] && queue[ index ].finish ) {
13366 queue[ index ].finish.call( this );
13367 }
13368 }
13369
13370 // turn off finishing flag
13371 delete data.finish;
13372 });
13373 }
13374 });
13375
13376 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
13377 var cssFn = jQuery.fn[ name ];
13378 jQuery.fn[ name ] = function( speed, easing, callback ) {
13379 return speed == null || typeof speed === "boolean" ?
13380 cssFn.apply( this, arguments ) :
13381 this.animate( genFx( name, true ), speed, easing, callback );
13382 };
13383 });
13384
13385 // Generate shortcuts for custom animations
13386 jQuery.each({
13387 slideDown: genFx("show"),
13388 slideUp: genFx("hide"),
13389 slideToggle: genFx("toggle"),
13390 fadeIn: { opacity: "show" },
13391 fadeOut: { opacity: "hide" },
13392 fadeToggle: { opacity: "toggle" }
13393 }, function( name, props ) {
13394 jQuery.fn[ name ] = function( speed, easing, callback ) {
13395 return this.animate( props, speed, easing, callback );
13396 };
13397 });
13398
13399 jQuery.timers = [];
13400 jQuery.fx.tick = function() {
13401 var timer,
13402 i = 0,
13403 timers = jQuery.timers;
13404
13405 fxNow = jQuery.now();
13406
13407 for ( ; i < timers.length; i++ ) {
13408 timer = timers[ i ];
13409 // Checks the timer has not already been removed
13410 if ( !timer() && timers[ i ] === timer ) {
13411 timers.splice( i--, 1 );
13412 }
13413 }
13414
13415 if ( !timers.length ) {
13416 jQuery.fx.stop();
13417 }
13418 fxNow = undefined;
13419 };
13420
13421 jQuery.fx.timer = function( timer ) {
13422 jQuery.timers.push( timer );
13423 if ( timer() ) {
13424 jQuery.fx.start();
13425 } else {
13426 jQuery.timers.pop();
13427 }
13428 };
13429
13430 jQuery.fx.interval = 13;
13431
13432 jQuery.fx.start = function() {
13433 if ( !timerId ) {
13434 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
13435 }
13436 };
13437
13438 jQuery.fx.stop = function() {
13439 clearInterval( timerId );
13440 timerId = null;
13441 };
13442
13443 jQuery.fx.speeds = {
13444 slow: 600,
13445 fast: 200,
13446 // Default speed
13447 _default: 400
13448 };
13449
13450
13451 // Based off of the plugin by Clint Helfers, with permission.
13452 // http://blindsignals.com/index.php/2009/07/jquery-delay/
13453 jQuery.fn.delay = function( time, type ) {
13454 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
13455 type = type || "fx";
13456
13457 return this.queue( type, function( next, hooks ) {
13458 var timeout = setTimeout( next, time );
13459 hooks.stop = function() {
13460 clearTimeout( timeout );
13461 };
13462 });
13463 };
13464
13465
13466 (function() {
13467 var input = document.createElement( "input" ),
13468 select = document.createElement( "select" ),
13469 opt = select.appendChild( document.createElement( "option" ) );
13470
13471 input.type = "checkbox";
13472
13473 // Support: iOS 5.1, Android 4.x, Android 2.3
13474 // Check the default checkbox/radio value ("" on old WebKit; "on" elsewhere)
13475 support.checkOn = input.value !== "";
13476
13477 // Must access the parent to make an option select properly
13478 // Support: IE9, IE10
13479 support.optSelected = opt.selected;
13480
13481 // Make sure that the options inside disabled selects aren't marked as disabled
13482 // (WebKit marks them as disabled)
13483 select.disabled = true;
13484 support.optDisabled = !opt.disabled;
13485
13486 // Check if an input maintains its value after becoming a radio
13487 // Support: IE9, IE10
13488 input = document.createElement( "input" );
13489 input.value = "t";
13490 input.type = "radio";
13491 support.radioValue = input.value === "t";
13492 })();
13493
13494
13495 var nodeHook, boolHook,
13496 attrHandle = jQuery.expr.attrHandle;
13497
13498 jQuery.fn.extend({
13499 attr: function( name, value ) {
13500 return access( this, jQuery.attr, name, value, arguments.length > 1 );
13501 },
13502
13503 removeAttr: function( name ) {
13504 return this.each(function() {
13505 jQuery.removeAttr( this, name );
13506 });
13507 }
13508 });
13509
13510 jQuery.extend({
13511 attr: function( elem, name, value ) {
13512 var hooks, ret,
13513 nType = elem.nodeType;
13514
13515 // don't get/set attributes on text, comment and attribute nodes
13516 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
13517 return;
13518 }
13519
13520 // Fallback to prop when attributes are not supported
13521 if ( typeof elem.getAttribute === strundefined ) {
13522 return jQuery.prop( elem, name, value );
13523 }
13524
13525 // All attributes are lowercase
13526 // Grab necessary hook if one is defined
13527 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
13528 name = name.toLowerCase();
13529 hooks = jQuery.attrHooks[ name ] ||
13530 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
13531 }
13532
13533 if ( value !== undefined ) {
13534
13535 if ( value === null ) {
13536 jQuery.removeAttr( elem, name );
13537
13538 } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
13539 return ret;
13540
13541 } else {
13542 elem.setAttribute( name, value + "" );
13543 return value;
13544 }
13545
13546 } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
13547 return ret;
13548
13549 } else {
13550 ret = jQuery.find.attr( elem, name );
13551
13552 // Non-existent attributes return null, we normalize to undefined
13553 return ret == null ?
13554 undefined :
13555 ret;
13556 }
13557 },
13558
13559 removeAttr: function( elem, value ) {
13560 var name, propName,
13561 i = 0,
13562 attrNames = value && value.match( rnotwhite );
13563
13564 if ( attrNames && elem.nodeType === 1 ) {
13565 while ( (name = attrNames[i++]) ) {
13566 propName = jQuery.propFix[ name ] || name;
13567
13568 // Boolean attributes get special treatment (#10870)
13569 if ( jQuery.expr.match.bool.test( name ) ) {
13570 // Set corresponding property to false
13571 elem[ propName ] = false;
13572 }
13573
13574 elem.removeAttribute( name );
13575 }
13576 }
13577 },
13578
13579 attrHooks: {
13580 type: {
13581 set: function( elem, value ) {
13582 if ( !support.radioValue && value === "radio" &&
13583 jQuery.nodeName( elem, "input" ) ) {
13584 // Setting the type on a radio button after the value resets the value in IE6-9
13585 // Reset value to default in case type is set after value during creation
13586 var val = elem.value;
13587 elem.setAttribute( "type", value );
13588 if ( val ) {
13589 elem.value = val;
13590 }
13591 return value;
13592 }
13593 }
13594 }
13595 }
13596 });
13597
13598 // Hooks for boolean attributes
13599 boolHook = {
13600 set: function( elem, value, name ) {
13601 if ( value === false ) {
13602 // Remove boolean attributes when set to false
13603 jQuery.removeAttr( elem, name );
13604 } else {
13605 elem.setAttribute( name, name );
13606 }
13607 return name;
13608 }
13609 };
13610 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
13611 var getter = attrHandle[ name ] || jQuery.find.attr;
13612
13613 attrHandle[ name ] = function( elem, name, isXML ) {
13614 var ret, handle;
13615 if ( !isXML ) {
13616 // Avoid an infinite loop by temporarily removing this function from the getter
13617 handle = attrHandle[ name ];
13618 attrHandle[ name ] = ret;
13619 ret = getter( elem, name, isXML ) != null ?
13620 name.toLowerCase() :
13621 null;
13622 attrHandle[ name ] = handle;
13623 }
13624 return ret;
13625 };
13626 });
13627
13628
13629
13630
13631 var rfocusable = /^(?:input|select|textarea|button)$/i;
13632
13633 jQuery.fn.extend({
13634 prop: function( name, value ) {
13635 return access( this, jQuery.prop, name, value, arguments.length > 1 );
13636 },
13637
13638 removeProp: function( name ) {
13639 return this.each(function() {
13640 delete this[ jQuery.propFix[ name ] || name ];
13641 });
13642 }
13643 });
13644
13645 jQuery.extend({
13646 propFix: {
13647 "for": "htmlFor",
13648 "class": "className"
13649 },
13650
13651 prop: function( elem, name, value ) {
13652 var ret, hooks, notxml,
13653 nType = elem.nodeType;
13654
13655 // don't get/set properties on text, comment and attribute nodes
13656 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
13657 return;
13658 }
13659
13660 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
13661
13662 if ( notxml ) {
13663 // Fix name and attach hooks
13664 name = jQuery.propFix[ name ] || name;
13665 hooks = jQuery.propHooks[ name ];
13666 }
13667
13668 if ( value !== undefined ) {
13669 return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
13670 ret :
13671 ( elem[ name ] = value );
13672
13673 } else {
13674 return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
13675 ret :
13676 elem[ name ];
13677 }
13678 },
13679
13680 propHooks: {
13681 tabIndex: {
13682 get: function( elem ) {
13683 return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ?
13684 elem.tabIndex :
13685 -1;
13686 }
13687 }
13688 }
13689 });
13690
13691 // Support: IE9+
13692 // Selectedness for an option in an optgroup can be inaccurate
13693 if ( !support.optSelected ) {
13694 jQuery.propHooks.selected = {
13695 get: function( elem ) {
13696 var parent = elem.parentNode;
13697 if ( parent && parent.parentNode ) {
13698 parent.parentNode.selectedIndex;
13699 }
13700 return null;
13701 }
13702 };
13703 }
13704
13705 jQuery.each([
13706 "tabIndex",
13707 "readOnly",
13708 "maxLength",
13709 "cellSpacing",
13710 "cellPadding",
13711 "rowSpan",
13712 "colSpan",
13713 "useMap",
13714 "frameBorder",
13715 "contentEditable"
13716 ], function() {
13717 jQuery.propFix[ this.toLowerCase() ] = this;
13718 });
13719
13720
13721
13722
13723 var rclass = /[\t\r\n\f]/g;
13724
13725 jQuery.fn.extend({
13726 addClass: function( value ) {
13727 var classes, elem, cur, clazz, j, finalValue,
13728 proceed = typeof value === "string" && value,
13729 i = 0,
13730 len = this.length;
13731
13732 if ( jQuery.isFunction( value ) ) {
13733 return this.each(function( j ) {
13734 jQuery( this ).addClass( value.call( this, j, this.className ) );
13735 });
13736 }
13737
13738 if ( proceed ) {
13739 // The disjunction here is for better compressibility (see removeClass)
13740 classes = ( value || "" ).match( rnotwhite ) || [];
13741
13742 for ( ; i < len; i++ ) {
13743 elem = this[ i ];
13744 cur = elem.nodeType === 1 && ( elem.className ?
13745 ( " " + elem.className + " " ).replace( rclass, " " ) :
13746 " "
13747 );
13748
13749 if ( cur ) {
13750 j = 0;
13751 while ( (clazz = classes[j++]) ) {
13752 if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
13753 cur += clazz + " ";
13754 }
13755 }
13756
13757 // only assign if different to avoid unneeded rendering.
13758 finalValue = jQuery.trim( cur );
13759 if ( elem.className !== finalValue ) {
13760 elem.className = finalValue;
13761 }
13762 }
13763 }
13764 }
13765
13766 return this;
13767 },
13768
13769 removeClass: function( value ) {
13770 var classes, elem, cur, clazz, j, finalValue,
13771 proceed = arguments.length === 0 || typeof value === "string" && value,
13772 i = 0,
13773 len = this.length;
13774
13775 if ( jQuery.isFunction( value ) ) {
13776 return this.each(function( j ) {
13777 jQuery( this ).removeClass( value.call( this, j, this.className ) );
13778 });
13779 }
13780 if ( proceed ) {
13781 classes = ( value || "" ).match( rnotwhite ) || [];
13782
13783 for ( ; i < len; i++ ) {
13784 elem = this[ i ];
13785 // This expression is here for better compressibility (see addClass)
13786 cur = elem.nodeType === 1 && ( elem.className ?
13787 ( " " + elem.className + " " ).replace( rclass, " " ) :
13788 ""
13789 );
13790
13791 if ( cur ) {
13792 j = 0;
13793 while ( (clazz = classes[j++]) ) {
13794 // Remove *all* instances
13795 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
13796 cur = cur.replace( " " + clazz + " ", " " );
13797 }
13798 }
13799
13800 // only assign if different to avoid unneeded rendering.
13801 finalValue = value ? jQuery.trim( cur ) : "";
13802 if ( elem.className !== finalValue ) {
13803 elem.className = finalValue;
13804 }
13805 }
13806 }
13807 }
13808
13809 return this;
13810 },
13811
13812 toggleClass: function( value, stateVal ) {
13813 var type = typeof value;
13814
13815 if ( typeof stateVal === "boolean" && type === "string" ) {
13816 return stateVal ? this.addClass( value ) : this.removeClass( value );
13817 }
13818
13819 if ( jQuery.isFunction( value ) ) {
13820 return this.each(function( i ) {
13821 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
13822 });
13823 }
13824
13825 return this.each(function() {
13826 if ( type === "string" ) {
13827 // toggle individual class names
13828 var className,
13829 i = 0,
13830 self = jQuery( this ),
13831 classNames = value.match( rnotwhite ) || [];
13832
13833 while ( (className = classNames[ i++ ]) ) {
13834 // check each className given, space separated list
13835 if ( self.hasClass( className ) ) {
13836 self.removeClass( className );
13837 } else {
13838 self.addClass( className );
13839 }
13840 }
13841
13842 // Toggle whole class name
13843 } else if ( type === strundefined || type === "boolean" ) {
13844 if ( this.className ) {
13845 // store className if set
13846 data_priv.set( this, "__className__", this.className );
13847 }
13848
13849 // If the element has a class name or if we're passed "false",
13850 // then remove the whole classname (if there was one, the above saved it).
13851 // Otherwise bring back whatever was previously saved (if anything),
13852 // falling back to the empty string if nothing was stored.
13853 this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || "";
13854 }
13855 });
13856 },
13857
13858 hasClass: function( selector ) {
13859 var className = " " + selector + " ",
13860 i = 0,
13861 l = this.length;
13862 for ( ; i < l; i++ ) {
13863 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
13864 return true;
13865 }
13866 }
13867
13868 return false;
13869 }
13870 });
13871
13872
13873
13874
13875 var rreturn = /\r/g;
13876
13877 jQuery.fn.extend({
13878 val: function( value ) {
13879 var hooks, ret, isFunction,
13880 elem = this[0];
13881
13882 if ( !arguments.length ) {
13883 if ( elem ) {
13884 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
13885
13886 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
13887 return ret;
13888 }
13889
13890 ret = elem.value;
13891
13892 return typeof ret === "string" ?
13893 // handle most common string cases
13894 ret.replace(rreturn, "") :
13895 // handle cases where value is null/undef or number
13896 ret == null ? "" : ret;
13897 }
13898
13899 return;
13900 }
13901
13902 isFunction = jQuery.isFunction( value );
13903
13904 return this.each(function( i ) {
13905 var val;
13906
13907 if ( this.nodeType !== 1 ) {
13908 return;
13909 }
13910
13911 if ( isFunction ) {
13912 val = value.call( this, i, jQuery( this ).val() );
13913 } else {
13914 val = value;
13915 }
13916
13917 // Treat null/undefined as ""; convert numbers to string
13918 if ( val == null ) {
13919 val = "";
13920
13921 } else if ( typeof val === "number" ) {
13922 val += "";
13923
13924 } else if ( jQuery.isArray( val ) ) {
13925 val = jQuery.map( val, function( value ) {
13926 return value == null ? "" : value + "";
13927 });
13928 }
13929
13930 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
13931
13932 // If set returns undefined, fall back to normal setting
13933 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
13934 this.value = val;
13935 }
13936 });
13937 }
13938 });
13939
13940 jQuery.extend({
13941 valHooks: {
13942 option: {
13943 get: function( elem ) {
13944 var val = jQuery.find.attr( elem, "value" );
13945 return val != null ?
13946 val :
13947 // Support: IE10-11+
13948 // option.text throws exceptions (#14686, #14858)
13949 jQuery.trim( jQuery.text( elem ) );
13950 }
13951 },
13952 select: {
13953 get: function( elem ) {
13954 var value, option,
13955 options = elem.options,
13956 index = elem.selectedIndex,
13957 one = elem.type === "select-one" || index < 0,
13958 values = one ? null : [],
13959 max = one ? index + 1 : options.length,
13960 i = index < 0 ?
13961 max :
13962 one ? index : 0;
13963
13964 // Loop through all the selected options
13965 for ( ; i < max; i++ ) {
13966 option = options[ i ];
13967
13968 // IE6-9 doesn't update selected after form reset (#2551)
13969 if ( ( option.selected || i === index ) &&
13970 // Don't return options that are disabled or in a disabled optgroup
13971 ( support.optDisabled ? !option.disabled : option.getAttribute( "disabled" ) === null ) &&
13972 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
13973
13974 // Get the specific value for the option
13975 value = jQuery( option ).val();
13976
13977 // We don't need an array for one selects
13978 if ( one ) {
13979 return value;
13980 }
13981
13982 // Multi-Selects return an array
13983 values.push( value );
13984 }
13985 }
13986
13987 return values;
13988 },
13989
13990 set: function( elem, value ) {
13991 var optionSet, option,
13992 options = elem.options,
13993 values = jQuery.makeArray( value ),
13994 i = options.length;
13995
13996 while ( i-- ) {
13997 option = options[ i ];
13998 if ( (option.selected = jQuery.inArray( option.value, values ) >= 0) ) {
13999 optionSet = true;
14000 }
14001 }
14002
14003 // force browsers to behave consistently when non-matching value is set
14004 if ( !optionSet ) {
14005 elem.selectedIndex = -1;
14006 }
14007 return values;
14008 }
14009 }
14010 }
14011 });
14012
14013 // Radios and checkboxes getter/setter
14014 jQuery.each([ "radio", "checkbox" ], function() {
14015 jQuery.valHooks[ this ] = {
14016 set: function( elem, value ) {
14017 if ( jQuery.isArray( value ) ) {
14018 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
14019 }
14020 }
14021 };
14022 if ( !support.checkOn ) {
14023 jQuery.valHooks[ this ].get = function( elem ) {
14024 // Support: Webkit
14025 // "" is returned instead of "on" if a value isn't specified
14026 return elem.getAttribute("value") === null ? "on" : elem.value;
14027 };
14028 }
14029 });
14030
14031
14032
14033
14034 // Return jQuery for attributes-only inclusion
14035
14036
14037 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
14038 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
14039 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
14040
14041 // Handle event binding
14042 jQuery.fn[ name ] = function( data, fn ) {
14043 return arguments.length > 0 ?
14044 this.on( name, null, data, fn ) :
14045 this.trigger( name );
14046 };
14047 });
14048
14049 jQuery.fn.extend({
14050 hover: function( fnOver, fnOut ) {
14051 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
14052 },
14053
14054 bind: function( types, data, fn ) {
14055 return this.on( types, null, data, fn );
14056 },
14057 unbind: function( types, fn ) {
14058 return this.off( types, null, fn );
14059 },
14060
14061 delegate: function( selector, types, data, fn ) {
14062 return this.on( types, selector, data, fn );
14063 },
14064 undelegate: function( selector, types, fn ) {
14065 // ( namespace ) or ( selector, types [, fn] )
14066 return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
14067 }
14068 });
14069
14070
14071 var nonce = jQuery.now();
14072
14073 var rquery = (/\?/);
14074
14075
14076
14077 // Support: Android 2.3
14078 // Workaround failure to string-cast null input
14079 jQuery.parseJSON = function( data ) {
14080 return JSON.parse( data + "" );
14081 };
14082
14083
14084 // Cross-browser xml parsing
14085 jQuery.parseXML = function( data ) {
14086 var xml, tmp;
14087 if ( !data || typeof data !== "string" ) {
14088 return null;
14089 }
14090
14091 // Support: IE9
14092 try {
14093 tmp = new DOMParser();
14094 xml = tmp.parseFromString( data, "text/xml" );
14095 } catch ( e ) {
14096 xml = undefined;
14097 }
14098
14099 if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
14100 jQuery.error( "Invalid XML: " + data );
14101 }
14102 return xml;
14103 };
14104
14105
14106 var
14107 // Document location
14108 ajaxLocParts,
14109 ajaxLocation,
14110
14111 rhash = /#.*$/,
14112 rts = /([?&])_=[^&]*/,
14113 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
14114 // #7653, #8125, #8152: local protocol detection
14115 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
14116 rnoContent = /^(?:GET|HEAD)$/,
14117 rprotocol = /^\/\//,
14118 rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
14119
14120 /* Prefilters
14121 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
14122 * 2) These are called:
14123 * - BEFORE asking for a transport
14124 * - AFTER param serialization (s.data is a string if s.processData is true)
14125 * 3) key is the dataType
14126 * 4) the catchall symbol "*" can be used
14127 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
14128 */
14129 prefilters = {},
14130
14131 /* Transports bindings
14132 * 1) key is the dataType
14133 * 2) the catchall symbol "*" can be used
14134 * 3) selection will start with transport dataType and THEN go to "*" if needed
14135 */
14136 transports = {},
14137
14138 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
14139 allTypes = "*/".concat("*");
14140
14141 // #8138, IE may throw an exception when accessing
14142 // a field from window.location if document.domain has been set
14143 try {
14144 ajaxLocation = location.href;
14145 } catch( e ) {
14146 // Use the href attribute of an A element
14147 // since IE will modify it given document.location
14148 ajaxLocation = document.createElement( "a" );
14149 ajaxLocation.href = "";
14150 ajaxLocation = ajaxLocation.href;
14151 }
14152
14153 // Segment location into parts
14154 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
14155
14156 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
14157 function addToPrefiltersOrTransports( structure ) {
14158
14159 // dataTypeExpression is optional and defaults to "*"
14160 return function( dataTypeExpression, func ) {
14161
14162 if ( typeof dataTypeExpression !== "string" ) {
14163 func = dataTypeExpression;
14164 dataTypeExpression = "*";
14165 }
14166
14167 var dataType,
14168 i = 0,
14169 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
14170
14171 if ( jQuery.isFunction( func ) ) {
14172 // For each dataType in the dataTypeExpression
14173 while ( (dataType = dataTypes[i++]) ) {
14174 // Prepend if requested
14175 if ( dataType[0] === "+" ) {
14176 dataType = dataType.slice( 1 ) || "*";
14177 (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
14178
14179 // Otherwise append
14180 } else {
14181 (structure[ dataType ] = structure[ dataType ] || []).push( func );
14182 }
14183 }
14184 }
14185 };
14186 }
14187
14188 // Base inspection function for prefilters and transports
14189 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
14190
14191 var inspected = {},
14192 seekingTransport = ( structure === transports );
14193
14194 function inspect( dataType ) {
14195 var selected;
14196 inspected[ dataType ] = true;
14197 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
14198 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
14199 if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
14200 options.dataTypes.unshift( dataTypeOrTransport );
14201 inspect( dataTypeOrTransport );
14202 return false;
14203 } else if ( seekingTransport ) {
14204 return !( selected = dataTypeOrTransport );
14205 }
14206 });
14207 return selected;
14208 }
14209
14210 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
14211 }
14212
14213 // A special extend for ajax options
14214 // that takes "flat" options (not to be deep extended)
14215 // Fixes #9887
14216 function ajaxExtend( target, src ) {
14217 var key, deep,
14218 flatOptions = jQuery.ajaxSettings.flatOptions || {};
14219
14220 for ( key in src ) {
14221 if ( src[ key ] !== undefined ) {
14222 ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
14223 }
14224 }
14225 if ( deep ) {
14226 jQuery.extend( true, target, deep );
14227 }
14228
14229 return target;
14230 }
14231
14232 /* Handles responses to an ajax request:
14233 * - finds the right dataType (mediates between content-type and expected dataType)
14234 * - returns the corresponding response
14235 */
14236 function ajaxHandleResponses( s, jqXHR, responses ) {
14237
14238 var ct, type, finalDataType, firstDataType,
14239 contents = s.contents,
14240 dataTypes = s.dataTypes;
14241
14242 // Remove auto dataType and get content-type in the process
14243 while ( dataTypes[ 0 ] === "*" ) {
14244 dataTypes.shift();
14245 if ( ct === undefined ) {
14246 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
14247 }
14248 }
14249
14250 // Check if we're dealing with a known content-type
14251 if ( ct ) {
14252 for ( type in contents ) {
14253 if ( contents[ type ] && contents[ type ].test( ct ) ) {
14254 dataTypes.unshift( type );
14255 break;
14256 }
14257 }
14258 }
14259
14260 // Check to see if we have a response for the expected dataType
14261 if ( dataTypes[ 0 ] in responses ) {
14262 finalDataType = dataTypes[ 0 ];
14263 } else {
14264 // Try convertible dataTypes
14265 for ( type in responses ) {
14266 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
14267 finalDataType = type;
14268 break;
14269 }
14270 if ( !firstDataType ) {
14271 firstDataType = type;
14272 }
14273 }
14274 // Or just use first one
14275 finalDataType = finalDataType || firstDataType;
14276 }
14277
14278 // If we found a dataType
14279 // We add the dataType to the list if needed
14280 // and return the corresponding response
14281 if ( finalDataType ) {
14282 if ( finalDataType !== dataTypes[ 0 ] ) {
14283 dataTypes.unshift( finalDataType );
14284 }
14285 return responses[ finalDataType ];
14286 }
14287 }
14288
14289 /* Chain conversions given the request and the original response
14290 * Also sets the responseXXX fields on the jqXHR instance
14291 */
14292 function ajaxConvert( s, response, jqXHR, isSuccess ) {
14293 var conv2, current, conv, tmp, prev,
14294 converters = {},
14295 // Work with a copy of dataTypes in case we need to modify it for conversion
14296 dataTypes = s.dataTypes.slice();
14297
14298 // Create converters map with lowercased keys
14299 if ( dataTypes[ 1 ] ) {
14300 for ( conv in s.converters ) {
14301 converters[ conv.toLowerCase() ] = s.converters[ conv ];
14302 }
14303 }
14304
14305 current = dataTypes.shift();
14306
14307 // Convert to each sequential dataType
14308 while ( current ) {
14309
14310 if ( s.responseFields[ current ] ) {
14311 jqXHR[ s.responseFields[ current ] ] = response;
14312 }
14313
14314 // Apply the dataFilter if provided
14315 if ( !prev && isSuccess && s.dataFilter ) {
14316 response = s.dataFilter( response, s.dataType );
14317 }
14318
14319 prev = current;
14320 current = dataTypes.shift();
14321
14322 if ( current ) {
14323
14324 // There's only work to do if current dataType is non-auto
14325 if ( current === "*" ) {
14326
14327 current = prev;
14328
14329 // Convert response if prev dataType is non-auto and differs from current
14330 } else if ( prev !== "*" && prev !== current ) {
14331
14332 // Seek a direct converter
14333 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
14334
14335 // If none found, seek a pair
14336 if ( !conv ) {
14337 for ( conv2 in converters ) {
14338
14339 // If conv2 outputs current
14340 tmp = conv2.split( " " );
14341 if ( tmp[ 1 ] === current ) {
14342
14343 // If prev can be converted to accepted input
14344 conv = converters[ prev + " " + tmp[ 0 ] ] ||
14345 converters[ "* " + tmp[ 0 ] ];
14346 if ( conv ) {
14347 // Condense equivalence converters
14348 if ( conv === true ) {
14349 conv = converters[ conv2 ];
14350
14351 // Otherwise, insert the intermediate dataType
14352 } else if ( converters[ conv2 ] !== true ) {
14353 current = tmp[ 0 ];
14354 dataTypes.unshift( tmp[ 1 ] );
14355 }
14356 break;
14357 }
14358 }
14359 }
14360 }
14361
14362 // Apply converter (if not an equivalence)
14363 if ( conv !== true ) {
14364
14365 // Unless errors are allowed to bubble, catch and return them
14366 if ( conv && s[ "throws" ] ) {
14367 response = conv( response );
14368 } else {
14369 try {
14370 response = conv( response );
14371 } catch ( e ) {
14372 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
14373 }
14374 }
14375 }
14376 }
14377 }
14378 }
14379
14380 return { state: "success", data: response };
14381 }
14382
14383 jQuery.extend({
14384
14385 // Counter for holding the number of active queries
14386 active: 0,
14387
14388 // Last-Modified header cache for next request
14389 lastModified: {},
14390 etag: {},
14391
14392 ajaxSettings: {
14393 url: ajaxLocation,
14394 type: "GET",
14395 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
14396 global: true,
14397 processData: true,
14398 async: true,
14399 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
14400 /*
14401 timeout: 0,
14402 data: null,
14403 dataType: null,
14404 username: null,
14405 password: null,
14406 cache: null,
14407 throws: false,
14408 traditional: false,
14409 headers: {},
14410 */
14411
14412 accepts: {
14413 "*": allTypes,
14414 text: "text/plain",
14415 html: "text/html",
14416 xml: "application/xml, text/xml",
14417 json: "application/json, text/javascript"
14418 },
14419
14420 contents: {
14421 xml: /xml/,
14422 html: /html/,
14423 json: /json/
14424 },
14425
14426 responseFields: {
14427 xml: "responseXML",
14428 text: "responseText",
14429 json: "responseJSON"
14430 },
14431
14432 // Data converters
14433 // Keys separate source (or catchall "*") and destination types with a single space
14434 converters: {
14435
14436 // Convert anything to text
14437 "* text": String,
14438
14439 // Text to html (true = no transformation)
14440 "text html": true,
14441
14442 // Evaluate text as a json expression
14443 "text json": jQuery.parseJSON,
14444
14445 // Parse text as xml
14446 "text xml": jQuery.parseXML
14447 },
14448
14449 // For options that shouldn't be deep extended:
14450 // you can add your own custom options here if
14451 // and when you create one that shouldn't be
14452 // deep extended (see ajaxExtend)
14453 flatOptions: {
14454 url: true,
14455 context: true
14456 }
14457 },
14458
14459 // Creates a full fledged settings object into target
14460 // with both ajaxSettings and settings fields.
14461 // If target is omitted, writes into ajaxSettings.
14462 ajaxSetup: function( target, settings ) {
14463 return settings ?
14464
14465 // Building a settings object
14466 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
14467
14468 // Extending ajaxSettings
14469 ajaxExtend( jQuery.ajaxSettings, target );
14470 },
14471
14472 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
14473 ajaxTransport: addToPrefiltersOrTransports( transports ),
14474
14475 // Main method
14476 ajax: function( url, options ) {
14477
14478 // If url is an object, simulate pre-1.5 signature
14479 if ( typeof url === "object" ) {
14480 options = url;
14481 url = undefined;
14482 }
14483
14484 // Force options to be an object
14485 options = options || {};
14486
14487 var transport,
14488 // URL without anti-cache param
14489 cacheURL,
14490 // Response headers
14491 responseHeadersString,
14492 responseHeaders,
14493 // timeout handle
14494 timeoutTimer,
14495 // Cross-domain detection vars
14496 parts,
14497 // To know if global events are to be dispatched
14498 fireGlobals,
14499 // Loop variable
14500 i,
14501 // Create the final options object
14502 s = jQuery.ajaxSetup( {}, options ),
14503 // Callbacks context
14504 callbackContext = s.context || s,
14505 // Context for global events is callbackContext if it is a DOM node or jQuery collection
14506 globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
14507 jQuery( callbackContext ) :
14508 jQuery.event,
14509 // Deferreds
14510 deferred = jQuery.Deferred(),
14511 completeDeferred = jQuery.Callbacks("once memory"),
14512 // Status-dependent callbacks
14513 statusCode = s.statusCode || {},
14514 // Headers (they are sent all at once)
14515 requestHeaders = {},
14516 requestHeadersNames = {},
14517 // The jqXHR state
14518 state = 0,
14519 // Default abort message
14520 strAbort = "canceled",
14521 // Fake xhr
14522 jqXHR = {
14523 readyState: 0,
14524
14525 // Builds headers hashtable if needed
14526 getResponseHeader: function( key ) {
14527 var match;
14528 if ( state === 2 ) {
14529 if ( !responseHeaders ) {
14530 responseHeaders = {};
14531 while ( (match = rheaders.exec( responseHeadersString )) ) {
14532 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
14533 }
14534 }
14535 match = responseHeaders[ key.toLowerCase() ];
14536 }
14537 return match == null ? null : match;
14538 },
14539
14540 // Raw string
14541 getAllResponseHeaders: function() {
14542 return state === 2 ? responseHeadersString : null;
14543 },
14544
14545 // Caches the header
14546 setRequestHeader: function( name, value ) {
14547 var lname = name.toLowerCase();
14548 if ( !state ) {
14549 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
14550 requestHeaders[ name ] = value;
14551 }
14552 return this;
14553 },
14554
14555 // Overrides response content-type header
14556 overrideMimeType: function( type ) {
14557 if ( !state ) {
14558 s.mimeType = type;
14559 }
14560 return this;
14561 },
14562
14563 // Status-dependent callbacks
14564 statusCode: function( map ) {
14565 var code;
14566 if ( map ) {
14567 if ( state < 2 ) {
14568 for ( code in map ) {
14569 // Lazy-add the new callback in a way that preserves old ones
14570 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
14571 }
14572 } else {
14573 // Execute the appropriate callbacks
14574 jqXHR.always( map[ jqXHR.status ] );
14575 }
14576 }
14577 return this;
14578 },
14579
14580 // Cancel the request
14581 abort: function( statusText ) {
14582 var finalText = statusText || strAbort;
14583 if ( transport ) {
14584 transport.abort( finalText );
14585 }
14586 done( 0, finalText );
14587 return this;
14588 }
14589 };
14590
14591 // Attach deferreds
14592 deferred.promise( jqXHR ).complete = completeDeferred.add;
14593 jqXHR.success = jqXHR.done;
14594 jqXHR.error = jqXHR.fail;
14595
14596 // Remove hash character (#7531: and string promotion)
14597 // Add protocol if not provided (prefilters might expect it)
14598 // Handle falsy url in the settings object (#10093: consistency with old signature)
14599 // We also use the url parameter if available
14600 s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" )
14601 .replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
14602
14603 // Alias method option to type as per ticket #12004
14604 s.type = options.method || options.type || s.method || s.type;
14605
14606 // Extract dataTypes list
14607 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
14608
14609 // A cross-domain request is in order when we have a protocol:host:port mismatch
14610 if ( s.crossDomain == null ) {
14611 parts = rurl.exec( s.url.toLowerCase() );
14612 s.crossDomain = !!( parts &&
14613 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
14614 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
14615 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
14616 );
14617 }
14618
14619 // Convert data if not already a string
14620 if ( s.data && s.processData && typeof s.data !== "string" ) {
14621 s.data = jQuery.param( s.data, s.traditional );
14622 }
14623
14624 // Apply prefilters
14625 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
14626
14627 // If request was aborted inside a prefilter, stop there
14628 if ( state === 2 ) {
14629 return jqXHR;
14630 }
14631
14632 // We can fire global events as of now if asked to
14633 fireGlobals = s.global;
14634
14635 // Watch for a new set of requests
14636 if ( fireGlobals && jQuery.active++ === 0 ) {
14637 jQuery.event.trigger("ajaxStart");
14638 }
14639
14640 // Uppercase the type
14641 s.type = s.type.toUpperCase();
14642
14643 // Determine if request has content
14644 s.hasContent = !rnoContent.test( s.type );
14645
14646 // Save the URL in case we're toying with the If-Modified-Since
14647 // and/or If-None-Match header later on
14648 cacheURL = s.url;
14649
14650 // More options handling for requests with no content
14651 if ( !s.hasContent ) {
14652
14653 // If data is available, append data to url
14654 if ( s.data ) {
14655 cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
14656 // #9682: remove data so that it's not used in an eventual retry
14657 delete s.data;
14658 }
14659
14660 // Add anti-cache in url if needed
14661 if ( s.cache === false ) {
14662 s.url = rts.test( cacheURL ) ?
14663
14664 // If there is already a '_' parameter, set its value
14665 cacheURL.replace( rts, "$1_=" + nonce++ ) :
14666
14667 // Otherwise add one to the end
14668 cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
14669 }
14670 }
14671
14672 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
14673 if ( s.ifModified ) {
14674 if ( jQuery.lastModified[ cacheURL ] ) {
14675 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
14676 }
14677 if ( jQuery.etag[ cacheURL ] ) {
14678 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
14679 }
14680 }
14681
14682 // Set the correct header, if data is being sent
14683 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
14684 jqXHR.setRequestHeader( "Content-Type", s.contentType );
14685 }
14686
14687 // Set the Accepts header for the server, depending on the dataType
14688 jqXHR.setRequestHeader(
14689 "Accept",
14690 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
14691 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
14692 s.accepts[ "*" ]
14693 );
14694
14695 // Check for headers option
14696 for ( i in s.headers ) {
14697 jqXHR.setRequestHeader( i, s.headers[ i ] );
14698 }
14699
14700 // Allow custom headers/mimetypes and early abort
14701 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
14702 // Abort if not done already and return
14703 return jqXHR.abort();
14704 }
14705
14706 // aborting is no longer a cancellation
14707 strAbort = "abort";
14708
14709 // Install callbacks on deferreds
14710 for ( i in { success: 1, error: 1, complete: 1 } ) {
14711 jqXHR[ i ]( s[ i ] );
14712 }
14713
14714 // Get transport
14715 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
14716
14717 // If no transport, we auto-abort
14718 if ( !transport ) {
14719 done( -1, "No Transport" );
14720 } else {
14721 jqXHR.readyState = 1;
14722
14723 // Send global event
14724 if ( fireGlobals ) {
14725 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
14726 }
14727 // Timeout
14728 if ( s.async && s.timeout > 0 ) {
14729 timeoutTimer = setTimeout(function() {
14730 jqXHR.abort("timeout");
14731 }, s.timeout );
14732 }
14733
14734 try {
14735 state = 1;
14736 transport.send( requestHeaders, done );
14737 } catch ( e ) {
14738 // Propagate exception as error if not done
14739 if ( state < 2 ) {
14740 done( -1, e );
14741 // Simply rethrow otherwise
14742 } else {
14743 throw e;
14744 }
14745 }
14746 }
14747
14748 // Callback for when everything is done
14749 function done( status, nativeStatusText, responses, headers ) {
14750 var isSuccess, success, error, response, modified,
14751 statusText = nativeStatusText;
14752
14753 // Called once
14754 if ( state === 2 ) {
14755 return;
14756 }
14757
14758 // State is "done" now
14759 state = 2;
14760
14761 // Clear timeout if it exists
14762 if ( timeoutTimer ) {
14763 clearTimeout( timeoutTimer );
14764 }
14765
14766 // Dereference transport for early garbage collection
14767 // (no matter how long the jqXHR object will be used)
14768 transport = undefined;
14769
14770 // Cache response headers
14771 responseHeadersString = headers || "";
14772
14773 // Set readyState
14774 jqXHR.readyState = status > 0 ? 4 : 0;
14775
14776 // Determine if successful
14777 isSuccess = status >= 200 && status < 300 || status === 304;
14778
14779 // Get response data
14780 if ( responses ) {
14781 response = ajaxHandleResponses( s, jqXHR, responses );
14782 }
14783
14784 // Convert no matter what (that way responseXXX fields are always set)
14785 response = ajaxConvert( s, response, jqXHR, isSuccess );
14786
14787 // If successful, handle type chaining
14788 if ( isSuccess ) {
14789
14790 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
14791 if ( s.ifModified ) {
14792 modified = jqXHR.getResponseHeader("Last-Modified");
14793 if ( modified ) {
14794 jQuery.lastModified[ cacheURL ] = modified;
14795 }
14796 modified = jqXHR.getResponseHeader("etag");
14797 if ( modified ) {
14798 jQuery.etag[ cacheURL ] = modified;
14799 }
14800 }
14801
14802 // if no content
14803 if ( status === 204 || s.type === "HEAD" ) {
14804 statusText = "nocontent";
14805
14806 // if not modified
14807 } else if ( status === 304 ) {
14808 statusText = "notmodified";
14809
14810 // If we have data, let's convert it
14811 } else {
14812 statusText = response.state;
14813 success = response.data;
14814 error = response.error;
14815 isSuccess = !error;
14816 }
14817 } else {
14818 // We extract error from statusText
14819 // then normalize statusText and status for non-aborts
14820 error = statusText;
14821 if ( status || !statusText ) {
14822 statusText = "error";
14823 if ( status < 0 ) {
14824 status = 0;
14825 }
14826 }
14827 }
14828
14829 // Set data for the fake xhr object
14830 jqXHR.status = status;
14831 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
14832
14833 // Success/Error
14834 if ( isSuccess ) {
14835 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
14836 } else {
14837 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
14838 }
14839
14840 // Status-dependent callbacks
14841 jqXHR.statusCode( statusCode );
14842 statusCode = undefined;
14843
14844 if ( fireGlobals ) {
14845 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
14846 [ jqXHR, s, isSuccess ? success : error ] );
14847 }
14848
14849 // Complete
14850 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
14851
14852 if ( fireGlobals ) {
14853 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
14854 // Handle the global AJAX counter
14855 if ( !( --jQuery.active ) ) {
14856 jQuery.event.trigger("ajaxStop");
14857 }
14858 }
14859 }
14860
14861 return jqXHR;
14862 },
14863
14864 getJSON: function( url, data, callback ) {
14865 return jQuery.get( url, data, callback, "json" );
14866 },
14867
14868 getScript: function( url, callback ) {
14869 return jQuery.get( url, undefined, callback, "script" );
14870 }
14871 });
14872
14873 jQuery.each( [ "get", "post" ], function( i, method ) {
14874 jQuery[ method ] = function( url, data, callback, type ) {
14875 // shift arguments if data argument was omitted
14876 if ( jQuery.isFunction( data ) ) {
14877 type = type || callback;
14878 callback = data;
14879 data = undefined;
14880 }
14881
14882 return jQuery.ajax({
14883 url: url,
14884 type: method,
14885 dataType: type,
14886 data: data,
14887 success: callback
14888 });
14889 };
14890 });
14891
14892 // Attach a bunch of functions for handling common AJAX events
14893 jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
14894 jQuery.fn[ type ] = function( fn ) {
14895 return this.on( type, fn );
14896 };
14897 });
14898
14899
14900 jQuery._evalUrl = function( url ) {
14901 return jQuery.ajax({
14902 url: url,
14903 type: "GET",
14904 dataType: "script",
14905 async: false,
14906 global: false,
14907 "throws": true
14908 });
14909 };
14910
14911
14912 jQuery.fn.extend({
14913 wrapAll: function( html ) {
14914 var wrap;
14915
14916 if ( jQuery.isFunction( html ) ) {
14917 return this.each(function( i ) {
14918 jQuery( this ).wrapAll( html.call(this, i) );
14919 });
14920 }
14921
14922 if ( this[ 0 ] ) {
14923
14924 // The elements to wrap the target around
14925 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
14926
14927 if ( this[ 0 ].parentNode ) {
14928 wrap.insertBefore( this[ 0 ] );
14929 }
14930
14931 wrap.map(function() {
14932 var elem = this;
14933
14934 while ( elem.firstElementChild ) {
14935 elem = elem.firstElementChild;
14936 }
14937
14938 return elem;
14939 }).append( this );
14940 }
14941
14942 return this;
14943 },
14944
14945 wrapInner: function( html ) {
14946 if ( jQuery.isFunction( html ) ) {
14947 return this.each(function( i ) {
14948 jQuery( this ).wrapInner( html.call(this, i) );
14949 });
14950 }
14951
14952 return this.each(function() {
14953 var self = jQuery( this ),
14954 contents = self.contents();
14955
14956 if ( contents.length ) {
14957 contents.wrapAll( html );
14958
14959 } else {
14960 self.append( html );
14961 }
14962 });
14963 },
14964
14965 wrap: function( html ) {
14966 var isFunction = jQuery.isFunction( html );
14967
14968 return this.each(function( i ) {
14969 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
14970 });
14971 },
14972
14973 unwrap: function() {
14974 return this.parent().each(function() {
14975 if ( !jQuery.nodeName( this, "body" ) ) {
14976 jQuery( this ).replaceWith( this.childNodes );
14977 }
14978 }).end();
14979 }
14980 });
14981
14982
14983 jQuery.expr.filters.hidden = function( elem ) {
14984 // Support: Opera <= 12.12
14985 // Opera reports offsetWidths and offsetHeights less than zero on some elements
14986 return elem.offsetWidth <= 0 && elem.offsetHeight <= 0;
14987 };
14988 jQuery.expr.filters.visible = function( elem ) {
14989 return !jQuery.expr.filters.hidden( elem );
14990 };
14991
14992
14993
14994
14995 var r20 = /%20/g,
14996 rbracket = /\[\]$/,
14997 rCRLF = /\r?\n/g,
14998 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
14999 rsubmittable = /^(?:input|select|textarea|keygen)/i;
15000
15001 function buildParams( prefix, obj, traditional, add ) {
15002 var name;
15003
15004 if ( jQuery.isArray( obj ) ) {
15005 // Serialize array item.
15006 jQuery.each( obj, function( i, v ) {
15007 if ( traditional || rbracket.test( prefix ) ) {
15008 // Treat each array item as a scalar.
15009 add( prefix, v );
15010
15011 } else {
15012 // Item is non-scalar (array or object), encode its numeric index.
15013 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
15014 }
15015 });
15016
15017 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
15018 // Serialize object item.
15019 for ( name in obj ) {
15020 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
15021 }
15022
15023 } else {
15024 // Serialize scalar item.
15025 add( prefix, obj );
15026 }
15027 }
15028
15029 // Serialize an array of form elements or a set of
15030 // key/values into a query string
15031 jQuery.param = function( a, traditional ) {
15032 var prefix,
15033 s = [],
15034 add = function( key, value ) {
15035 // If value is a function, invoke it and return its value
15036 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
15037 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
15038 };
15039
15040 // Set traditional to true for jQuery <= 1.3.2 behavior.
15041 if ( traditional === undefined ) {
15042 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
15043 }
15044
15045 // If an array was passed in, assume that it is an array of form elements.
15046 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
15047 // Serialize the form elements
15048 jQuery.each( a, function() {
15049 add( this.name, this.value );
15050 });
15051
15052 } else {
15053 // If traditional, encode the "old" way (the way 1.3.2 or older
15054 // did it), otherwise encode params recursively.
15055 for ( prefix in a ) {
15056 buildParams( prefix, a[ prefix ], traditional, add );
15057 }
15058 }
15059
15060 // Return the resulting serialization
15061 return s.join( "&" ).replace( r20, "+" );
15062 };
15063
15064 jQuery.fn.extend({
15065 serialize: function() {
15066 return jQuery.param( this.serializeArray() );
15067 },
15068 serializeArray: function() {
15069 return this.map(function() {
15070 // Can add propHook for "elements" to filter or add form elements
15071 var elements = jQuery.prop( this, "elements" );
15072 return elements ? jQuery.makeArray( elements ) : this;
15073 })
15074 .filter(function() {
15075 var type = this.type;
15076
15077 // Use .is( ":disabled" ) so that fieldset[disabled] works
15078 return this.name && !jQuery( this ).is( ":disabled" ) &&
15079 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
15080 ( this.checked || !rcheckableType.test( type ) );
15081 })
15082 .map(function( i, elem ) {
15083 var val = jQuery( this ).val();
15084
15085 return val == null ?
15086 null :
15087 jQuery.isArray( val ) ?
15088 jQuery.map( val, function( val ) {
15089 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
15090 }) :
15091 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
15092 }).get();
15093 }
15094 });
15095
15096
15097 jQuery.ajaxSettings.xhr = function() {
15098 try {
15099 return new XMLHttpRequest();
15100 } catch( e ) {}
15101 };
15102
15103 var xhrId = 0,
15104 xhrCallbacks = {},
15105 xhrSuccessStatus = {
15106 // file protocol always yields status code 0, assume 200
15107 0: 200,
15108 // Support: IE9
15109 // #1450: sometimes IE returns 1223 when it should be 204
15110 1223: 204
15111 },
15112 xhrSupported = jQuery.ajaxSettings.xhr();
15113
15114 // Support: IE9
15115 // Open requests must be manually aborted on unload (#5280)
15116 if ( window.ActiveXObject ) {
15117 jQuery( window ).on( "unload", function() {
15118 for ( var key in xhrCallbacks ) {
15119 xhrCallbacks[ key ]();
15120 }
15121 });
15122 }
15123
15124 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
15125 support.ajax = xhrSupported = !!xhrSupported;
15126
15127 jQuery.ajaxTransport(function( options ) {
15128 var callback;
15129
15130 // Cross domain only allowed if supported through XMLHttpRequest
15131 if ( support.cors || xhrSupported && !options.crossDomain ) {
15132 return {
15133 send: function( headers, complete ) {
15134 var i,
15135 xhr = options.xhr(),
15136 id = ++xhrId;
15137
15138 xhr.open( options.type, options.url, options.async, options.username, options.password );
15139
15140 // Apply custom fields if provided
15141 if ( options.xhrFields ) {
15142 for ( i in options.xhrFields ) {
15143 xhr[ i ] = options.xhrFields[ i ];
15144 }
15145 }
15146
15147 // Override mime type if needed
15148 if ( options.mimeType && xhr.overrideMimeType ) {
15149 xhr.overrideMimeType( options.mimeType );
15150 }
15151
15152 // X-Requested-With header
15153 // For cross-domain requests, seeing as conditions for a preflight are
15154 // akin to a jigsaw puzzle, we simply never set it to be sure.
15155 // (it can always be set on a per-request basis or even using ajaxSetup)
15156 // For same-domain requests, won't change header if already provided.
15157 if ( !options.crossDomain && !headers["X-Requested-With"] ) {
15158 headers["X-Requested-With"] = "XMLHttpRequest";
15159 }
15160
15161 // Set headers
15162 for ( i in headers ) {
15163 xhr.setRequestHeader( i, headers[ i ] );
15164 }
15165
15166 // Callback
15167 callback = function( type ) {
15168 return function() {
15169 if ( callback ) {
15170 delete xhrCallbacks[ id ];
15171 callback = xhr.onload = xhr.onerror = null;
15172
15173 if ( type === "abort" ) {
15174 xhr.abort();
15175 } else if ( type === "error" ) {
15176 complete(
15177 // file: protocol always yields status 0; see #8605, #14207
15178 xhr.status,
15179 xhr.statusText
15180 );
15181 } else {
15182 complete(
15183 xhrSuccessStatus[ xhr.status ] || xhr.status,
15184 xhr.statusText,
15185 // Support: IE9
15186 // Accessing binary-data responseText throws an exception
15187 // (#11426)
15188 typeof xhr.responseText === "string" ? {
15189 text: xhr.responseText
15190 } : undefined,
15191 xhr.getAllResponseHeaders()
15192 );
15193 }
15194 }
15195 };
15196 };
15197
15198 // Listen to events
15199 xhr.onload = callback();
15200 xhr.onerror = callback("error");
15201
15202 // Create the abort callback
15203 callback = xhrCallbacks[ id ] = callback("abort");
15204
15205 try {
15206 // Do send the request (this may raise an exception)
15207 xhr.send( options.hasContent && options.data || null );
15208 } catch ( e ) {
15209 // #14683: Only rethrow if this hasn't been notified as an error yet
15210 if ( callback ) {
15211 throw e;
15212 }
15213 }
15214 },
15215
15216 abort: function() {
15217 if ( callback ) {
15218 callback();
15219 }
15220 }
15221 };
15222 }
15223 });
15224
15225
15226
15227
15228 // Install script dataType
15229 jQuery.ajaxSetup({
15230 accepts: {
15231 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
15232 },
15233 contents: {
15234 script: /(?:java|ecma)script/
15235 },
15236 converters: {
15237 "text script": function( text ) {
15238 jQuery.globalEval( text );
15239 return text;
15240 }
15241 }
15242 });
15243
15244 // Handle cache's special case and crossDomain
15245 jQuery.ajaxPrefilter( "script", function( s ) {
15246 if ( s.cache === undefined ) {
15247 s.cache = false;
15248 }
15249 if ( s.crossDomain ) {
15250 s.type = "GET";
15251 }
15252 });
15253
15254 // Bind script tag hack transport
15255 jQuery.ajaxTransport( "script", function( s ) {
15256 // This transport only deals with cross domain requests
15257 if ( s.crossDomain ) {
15258 var script, callback;
15259 return {
15260 send: function( _, complete ) {
15261 script = jQuery("<script>").prop({
15262 async: true,
15263 charset: s.scriptCharset,
15264 src: s.url
15265 }).on(
15266 "load error",
15267 callback = function( evt ) {
15268 script.remove();
15269 callback = null;
15270 if ( evt ) {
15271 complete( evt.type === "error" ? 404 : 200, evt.type );
15272 }
15273 }
15274 );
15275 document.head.appendChild( script[ 0 ] );
15276 },
15277 abort: function() {
15278 if ( callback ) {
15279 callback();
15280 }
15281 }
15282 };
15283 }
15284 });
15285
15286
15287
15288
15289 var oldCallbacks = [],
15290 rjsonp = /(=)\?(?=&|$)|\?\?/;
15291
15292 // Default jsonp settings
15293 jQuery.ajaxSetup({
15294 jsonp: "callback",
15295 jsonpCallback: function() {
15296 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
15297 this[ callback ] = true;
15298 return callback;
15299 }
15300 });
15301
15302 // Detect, normalize options and install callbacks for jsonp requests
15303 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
15304
15305 var callbackName, overwritten, responseContainer,
15306 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
15307 "url" :
15308 typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
15309 );
15310
15311 // Handle iff the expected data type is "jsonp" or we have a parameter to set
15312 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
15313
15314 // Get callback name, remembering preexisting value associated with it
15315 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
15316 s.jsonpCallback() :
15317 s.jsonpCallback;
15318
15319 // Insert callback into url or form data
15320 if ( jsonProp ) {
15321 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
15322 } else if ( s.jsonp !== false ) {
15323 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
15324 }
15325
15326 // Use data converter to retrieve json after script execution
15327 s.converters["script json"] = function() {
15328 if ( !responseContainer ) {
15329 jQuery.error( callbackName + " was not called" );
15330 }
15331 return responseContainer[ 0 ];
15332 };
15333
15334 // force json dataType
15335 s.dataTypes[ 0 ] = "json";
15336
15337 // Install callback
15338 overwritten = window[ callbackName ];
15339 window[ callbackName ] = function() {
15340 responseContainer = arguments;
15341 };
15342
15343 // Clean-up function (fires after converters)
15344 jqXHR.always(function() {
15345 // Restore preexisting value
15346 window[ callbackName ] = overwritten;
15347
15348 // Save back as free
15349 if ( s[ callbackName ] ) {
15350 // make sure that re-using the options doesn't screw things around
15351 s.jsonpCallback = originalSettings.jsonpCallback;
15352
15353 // save the callback name for future use
15354 oldCallbacks.push( callbackName );
15355 }
15356
15357 // Call if it was a function and we have a response
15358 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
15359 overwritten( responseContainer[ 0 ] );
15360 }
15361
15362 responseContainer = overwritten = undefined;
15363 });
15364
15365 // Delegate to script
15366 return "script";
15367 }
15368 });
15369
15370
15371
15372
15373 // data: string of html
15374 // context (optional): If specified, the fragment will be created in this context, defaults to document
15375 // keepScripts (optional): If true, will include scripts passed in the html string
15376 jQuery.parseHTML = function( data, context, keepScripts ) {
15377 if ( !data || typeof data !== "string" ) {
15378 return null;
15379 }
15380 if ( typeof context === "boolean" ) {
15381 keepScripts = context;
15382 context = false;
15383 }
15384 context = context || document;
15385
15386 var parsed = rsingleTag.exec( data ),
15387 scripts = !keepScripts && [];
15388
15389 // Single tag
15390 if ( parsed ) {
15391 return [ context.createElement( parsed[1] ) ];
15392 }
15393
15394 parsed = jQuery.buildFragment( [ data ], context, scripts );
15395
15396 if ( scripts && scripts.length ) {
15397 jQuery( scripts ).remove();
15398 }
15399
15400 return jQuery.merge( [], parsed.childNodes );
15401 };
15402
15403
15404 // Keep a copy of the old load method
15405 var _load = jQuery.fn.load;
15406
15407 /**
15408 * Load a url into a page
15409 */
15410 jQuery.fn.load = function( url, params, callback ) {
15411 if ( typeof url !== "string" && _load ) {
15412 return _load.apply( this, arguments );
15413 }
15414
15415 var selector, type, response,
15416 self = this,
15417 off = url.indexOf(" ");
15418
15419 if ( off >= 0 ) {
15420 selector = jQuery.trim( url.slice( off ) );
15421 url = url.slice( 0, off );
15422 }
15423
15424 // If it's a function
15425 if ( jQuery.isFunction( params ) ) {
15426
15427 // We assume that it's the callback
15428 callback = params;
15429 params = undefined;
15430
15431 // Otherwise, build a param string
15432 } else if ( params && typeof params === "object" ) {
15433 type = "POST";
15434 }
15435
15436 // If we have elements to modify, make the request
15437 if ( self.length > 0 ) {
15438 jQuery.ajax({
15439 url: url,
15440
15441 // if "type" variable is undefined, then "GET" method will be used
15442 type: type,
15443 dataType: "html",
15444 data: params
15445 }).done(function( responseText ) {
15446
15447 // Save response for use in complete callback
15448 response = arguments;
15449
15450 self.html( selector ?
15451
15452 // If a selector was specified, locate the right elements in a dummy div
15453 // Exclude scripts to avoid IE 'Permission Denied' errors
15454 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
15455
15456 // Otherwise use the full result
15457 responseText );
15458
15459 }).complete( callback && function( jqXHR, status ) {
15460 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
15461 });
15462 }
15463
15464 return this;
15465 };
15466
15467
15468
15469
15470 jQuery.expr.filters.animated = function( elem ) {
15471 return jQuery.grep(jQuery.timers, function( fn ) {
15472 return elem === fn.elem;
15473 }).length;
15474 };
15475
15476
15477
15478
15479 var docElem = window.document.documentElement;
15480
15481 /**
15482 * Gets a window from an element
15483 */
15484 function getWindow( elem ) {
15485 return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView;
15486 }
15487
15488 jQuery.offset = {
15489 setOffset: function( elem, options, i ) {
15490 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
15491 position = jQuery.css( elem, "position" ),
15492 curElem = jQuery( elem ),
15493 props = {};
15494
15495 // Set position first, in-case top/left are set even on static elem
15496 if ( position === "static" ) {
15497 elem.style.position = "relative";
15498 }
15499
15500 curOffset = curElem.offset();
15501 curCSSTop = jQuery.css( elem, "top" );
15502 curCSSLeft = jQuery.css( elem, "left" );
15503 calculatePosition = ( position === "absolute" || position === "fixed" ) &&
15504 ( curCSSTop + curCSSLeft ).indexOf("auto") > -1;
15505
15506 // Need to be able to calculate position if either top or left is auto and position is either absolute or fixed
15507 if ( calculatePosition ) {
15508 curPosition = curElem.position();
15509 curTop = curPosition.top;
15510 curLeft = curPosition.left;
15511
15512 } else {
15513 curTop = parseFloat( curCSSTop ) || 0;
15514 curLeft = parseFloat( curCSSLeft ) || 0;
15515 }
15516
15517 if ( jQuery.isFunction( options ) ) {
15518 options = options.call( elem, i, curOffset );
15519 }
15520
15521 if ( options.top != null ) {
15522 props.top = ( options.top - curOffset.top ) + curTop;
15523 }
15524 if ( options.left != null ) {
15525 props.left = ( options.left - curOffset.left ) + curLeft;
15526 }
15527
15528 if ( "using" in options ) {
15529 options.using.call( elem, props );
15530
15531 } else {
15532 curElem.css( props );
15533 }
15534 }
15535 };
15536
15537 jQuery.fn.extend({
15538 offset: function( options ) {
15539 if ( arguments.length ) {
15540 return options === undefined ?
15541 this :
15542 this.each(function( i ) {
15543 jQuery.offset.setOffset( this, options, i );
15544 });
15545 }
15546
15547 var docElem, win,
15548 elem = this[ 0 ],
15549 box = { top: 0, left: 0 },
15550 doc = elem && elem.ownerDocument;
15551
15552 if ( !doc ) {
15553 return;
15554 }
15555
15556 docElem = doc.documentElement;
15557
15558 // Make sure it's not a disconnected DOM node
15559 if ( !jQuery.contains( docElem, elem ) ) {
15560 return box;
15561 }
15562
15563 // If we don't have gBCR, just use 0,0 rather than error
15564 // BlackBerry 5, iOS 3 (original iPhone)
15565 if ( typeof elem.getBoundingClientRect !== strundefined ) {
15566 box = elem.getBoundingClientRect();
15567 }
15568 win = getWindow( doc );
15569 return {
15570 top: box.top + win.pageYOffset - docElem.clientTop,
15571 left: box.left + win.pageXOffset - docElem.clientLeft
15572 };
15573 },
15574
15575 position: function() {
15576 if ( !this[ 0 ] ) {
15577 return;
15578 }
15579
15580 var offsetParent, offset,
15581 elem = this[ 0 ],
15582 parentOffset = { top: 0, left: 0 };
15583
15584 // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
15585 if ( jQuery.css( elem, "position" ) === "fixed" ) {
15586 // We assume that getBoundingClientRect is available when computed position is fixed
15587 offset = elem.getBoundingClientRect();
15588
15589 } else {
15590 // Get *real* offsetParent
15591 offsetParent = this.offsetParent();
15592
15593 // Get correct offsets
15594 offset = this.offset();
15595 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
15596 parentOffset = offsetParent.offset();
15597 }
15598
15599 // Add offsetParent borders
15600 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
15601 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
15602 }
15603
15604 // Subtract parent offsets and element margins
15605 return {
15606 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
15607 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
15608 };
15609 },
15610
15611 offsetParent: function() {
15612 return this.map(function() {
15613 var offsetParent = this.offsetParent || docElem;
15614
15615 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) {
15616 offsetParent = offsetParent.offsetParent;
15617 }
15618
15619 return offsetParent || docElem;
15620 });
15621 }
15622 });
15623
15624 // Create scrollLeft and scrollTop methods
15625 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
15626 var top = "pageYOffset" === prop;
15627
15628 jQuery.fn[ method ] = function( val ) {
15629 return access( this, function( elem, method, val ) {
15630 var win = getWindow( elem );
15631
15632 if ( val === undefined ) {
15633 return win ? win[ prop ] : elem[ method ];
15634 }
15635
15636 if ( win ) {
15637 win.scrollTo(
15638 !top ? val : window.pageXOffset,
15639 top ? val : window.pageYOffset
15640 );
15641
15642 } else {
15643 elem[ method ] = val;
15644 }
15645 }, method, val, arguments.length, null );
15646 };
15647 });
15648
15649 // Add the top/left cssHooks using jQuery.fn.position
15650 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
15651 // getComputedStyle returns percent when specified for top/left/bottom/right
15652 // rather than make the css module depend on the offset module, we just check for it here
15653 jQuery.each( [ "top", "left" ], function( i, prop ) {
15654 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
15655 function( elem, computed ) {
15656 if ( computed ) {
15657 computed = curCSS( elem, prop );
15658 // if curCSS returns percentage, fallback to offset
15659 return rnumnonpx.test( computed ) ?
15660 jQuery( elem ).position()[ prop ] + "px" :
15661 computed;
15662 }
15663 }
15664 );
15665 });
15666
15667
15668 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
15669 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
15670 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
15671 // margin is only for outerHeight, outerWidth
15672 jQuery.fn[ funcName ] = function( margin, value ) {
15673 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
15674 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
15675
15676 return access( this, function( elem, type, value ) {
15677 var doc;
15678
15679 if ( jQuery.isWindow( elem ) ) {
15680 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
15681 // isn't a whole lot we can do. See pull request at this URL for discussion:
15682 // https://github.com/jquery/jquery/pull/764
15683 return elem.document.documentElement[ "client" + name ];
15684 }
15685
15686 // Get document width or height
15687 if ( elem.nodeType === 9 ) {
15688 doc = elem.documentElement;
15689
15690 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
15691 // whichever is greatest
15692 return Math.max(
15693 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
15694 elem.body[ "offset" + name ], doc[ "offset" + name ],
15695 doc[ "client" + name ]
15696 );
15697 }
15698
15699 return value === undefined ?
15700 // Get width or height on the element, requesting but not forcing parseFloat
15701 jQuery.css( elem, type, extra ) :
15702
15703 // Set width or height on the element
15704 jQuery.style( elem, type, value, extra );
15705 }, type, chainable ? margin : undefined, chainable, null );
15706 };
15707 });
15708 });
15709
15710
15711 // The number of elements contained in the matched element set
15712 jQuery.fn.size = function() {
15713 return this.length;
15714 };
15715
15716 jQuery.fn.andSelf = jQuery.fn.addBack;
15717
15718
15719
15720
15721 // Register as a named AMD module, since jQuery can be concatenated with other
15722 // files that may use define, but not via a proper concatenation script that
15723 // understands anonymous AMD modules. A named AMD is safest and most robust
15724 // way to register. Lowercase jquery is used because AMD module names are
15725 // derived from file names, and jQuery is normally delivered in a lowercase
15726 // file name. Do this after creating the global so that if an AMD module wants
15727 // to call noConflict to hide this version of jQuery, it will work.
15728
15729 // Note that for maximum portability, libraries that are not jQuery should
15730 // declare themselves as anonymous modules, and avoid setting a global if an
15731 // AMD loader is present. jQuery is a special case. For more information, see
15732 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
15733
15734 if ( typeof define === "function" && define.amd ) {
15735 define( "jquery", [], function() {
15736 return jQuery;
15737 });
15738 }
15739
15740
15741
15742
15743 var
15744 // Map over jQuery in case of overwrite
15745 _jQuery = window.jQuery,
15746
15747 // Map over the $ in case of overwrite
15748 _$ = window.$;
15749
15750 jQuery.noConflict = function( deep ) {
15751 if ( window.$ === jQuery ) {
15752 window.$ = _$;
15753 }
15754
15755 if ( deep && window.jQuery === jQuery ) {
15756 window.jQuery = _jQuery;
15757 }
15758
15759 return jQuery;
15760 };
15761
15762 // Expose jQuery and $ identifiers, even in
15763 // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
15764 // and CommonJS for browser emulators (#13566)
15765 if ( typeof noGlobal === strundefined ) {
15766 window.jQuery = window.$ = jQuery;
15767 }
15768
15769
15770
15771
15772 return jQuery;
15773
15774 }));
15775 </script>
15776 <script>
15777 /*!
15778 * Bootstrap v3.2.0 (http://getbootstrap.com)
15779 * Copyright 2011-2014 Twitter, Inc.
15780 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15781 */
15782
15783 if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript requires jQuery') }
15784
15785 /* ========================================================================
15786 * Bootstrap: transition.js v3.2.0
15787 * http://getbootstrap.com/javascript/#transitions
15788 * ========================================================================
15789 * Copyright 2011-2014 Twitter, Inc.
15790 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15791 * ======================================================================== */
15792
15793
15794 +function ($) {
15795 'use strict';
15796
15797 // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
15798 // ============================================================
15799
15800 function transitionEnd() {
15801 var el = document.createElement('bootstrap')
15802
15803 var transEndEventNames = {
15804 WebkitTransition : 'webkitTransitionEnd',
15805 MozTransition : 'transitionend',
15806 OTransition : 'oTransitionEnd otransitionend',
15807 transition : 'transitionend'
15808 }
15809
15810 for (var name in transEndEventNames) {
15811 if (el.style[name] !== undefined) {
15812 return { end: transEndEventNames[name] }
15813 }
15814 }
15815
15816 return false // explicit for ie8 ( ._.)
15817 }
15818
15819 // http://blog.alexmaccaw.com/css-transitions
15820 $.fn.emulateTransitionEnd = function (duration) {
15821 var called = false
15822 var $el = this
15823 $(this).one('bsTransitionEnd', function () { called = true })
15824 var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
15825 setTimeout(callback, duration)
15826 return this
15827 }
15828
15829 $(function () {
15830 $.support.transition = transitionEnd()
15831
15832 if (!$.support.transition) return
15833
15834 $.event.special.bsTransitionEnd = {
15835 bindType: $.support.transition.end,
15836 delegateType: $.support.transition.end,
15837 handle: function (e) {
15838 if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
15839 }
15840 }
15841 })
15842
15843 }(jQuery);
15844
15845 /* ========================================================================
15846 * Bootstrap: alert.js v3.2.0
15847 * http://getbootstrap.com/javascript/#alerts
15848 * ========================================================================
15849 * Copyright 2011-2014 Twitter, Inc.
15850 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15851 * ======================================================================== */
15852
15853
15854 +function ($) {
15855 'use strict';
15856
15857 // ALERT CLASS DEFINITION
15858 // ======================
15859
15860 var dismiss = '[data-dismiss="alert"]'
15861 var Alert = function (el) {
15862 $(el).on('click', dismiss, this.close)
15863 }
15864
15865 Alert.VERSION = '3.2.0'
15866
15867 Alert.prototype.close = function (e) {
15868 var $this = $(this)
15869 var selector = $this.attr('data-target')
15870
15871 if (!selector) {
15872 selector = $this.attr('href')
15873 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
15874 }
15875
15876 var $parent = $(selector)
15877
15878 if (e) e.preventDefault()
15879
15880 if (!$parent.length) {
15881 $parent = $this.hasClass('alert') ? $this : $this.parent()
15882 }
15883
15884 $parent.trigger(e = $.Event('close.bs.alert'))
15885
15886 if (e.isDefaultPrevented()) return
15887
15888 $parent.removeClass('in')
15889
15890 function removeElement() {
15891 // detach from parent, fire event then clean up data
15892 $parent.detach().trigger('closed.bs.alert').remove()
15893 }
15894
15895 $.support.transition && $parent.hasClass('fade') ?
15896 $parent
15897 .one('bsTransitionEnd', removeElement)
15898 .emulateTransitionEnd(150) :
15899 removeElement()
15900 }
15901
15902
15903 // ALERT PLUGIN DEFINITION
15904 // =======================
15905
15906 function Plugin(option) {
15907 return this.each(function () {
15908 var $this = $(this)
15909 var data = $this.data('bs.alert')
15910
15911 if (!data) $this.data('bs.alert', (data = new Alert(this)))
15912 if (typeof option == 'string') data[option].call($this)
15913 })
15914 }
15915
15916 var old = $.fn.alert
15917
15918 $.fn.alert = Plugin
15919 $.fn.alert.Constructor = Alert
15920
15921
15922 // ALERT NO CONFLICT
15923 // =================
15924
15925 $.fn.alert.noConflict = function () {
15926 $.fn.alert = old
15927 return this
15928 }
15929
15930
15931 // ALERT DATA-API
15932 // ==============
15933
15934 $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
15935
15936 }(jQuery);
15937
15938 /* ========================================================================
15939 * Bootstrap: button.js v3.2.0
15940 * http://getbootstrap.com/javascript/#buttons
15941 * ========================================================================
15942 * Copyright 2011-2014 Twitter, Inc.
15943 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15944 * ======================================================================== */
15945
15946
15947 +function ($) {
15948 'use strict';
15949
15950 // BUTTON PUBLIC CLASS DEFINITION
15951 // ==============================
15952
15953 var Button = function (element, options) {
15954 this.$element = $(element)
15955 this.options = $.extend({}, Button.DEFAULTS, options)
15956 this.isLoading = false
15957 }
15958
15959 Button.VERSION = '3.2.0'
15960
15961 Button.DEFAULTS = {
15962 loadingText: 'loading...'
15963 }
15964
15965 Button.prototype.setState = function (state) {
15966 var d = 'disabled'
15967 var $el = this.$element
15968 var val = $el.is('input') ? 'val' : 'html'
15969 var data = $el.data()
15970
15971 state = state + 'Text'
15972
15973 if (data.resetText == null) $el.data('resetText', $el[val]())
15974
15975 $el[val](data[state] == null ? this.options[state] : data[state])
15976
15977 // push to event loop to allow forms to submit
15978 setTimeout($.proxy(function () {
15979 if (state == 'loadingText') {
15980 this.isLoading = true
15981 $el.addClass(d).attr(d, d)
15982 } else if (this.isLoading) {
15983 this.isLoading = false
15984 $el.removeClass(d).removeAttr(d)
15985 }
15986 }, this), 0)
15987 }
15988
15989 Button.prototype.toggle = function () {
15990 var changed = true
15991 var $parent = this.$element.closest('[data-toggle="buttons"]')
15992
15993 if ($parent.length) {
15994 var $input = this.$element.find('input')
15995 if ($input.prop('type') == 'radio') {
15996 if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
15997 else $parent.find('.active').removeClass('active')
15998 }
15999 if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
16000 }
16001
16002 if (changed) this.$element.toggleClass('active')
16003 }
16004
16005
16006 // BUTTON PLUGIN DEFINITION
16007 // ========================
16008
16009 function Plugin(option) {
16010 return this.each(function () {
16011 var $this = $(this)
16012 var data = $this.data('bs.button')
16013 var options = typeof option == 'object' && option
16014
16015 if (!data) $this.data('bs.button', (data = new Button(this, options)))
16016
16017 if (option == 'toggle') data.toggle()
16018 else if (option) data.setState(option)
16019 })
16020 }
16021
16022 var old = $.fn.button
16023
16024 $.fn.button = Plugin
16025 $.fn.button.Constructor = Button
16026
16027
16028 // BUTTON NO CONFLICT
16029 // ==================
16030
16031 $.fn.button.noConflict = function () {
16032 $.fn.button = old
16033 return this
16034 }
16035
16036
16037 // BUTTON DATA-API
16038 // ===============
16039
16040 $(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
16041 var $btn = $(e.target)
16042 if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
16043 Plugin.call($btn, 'toggle')
16044 e.preventDefault()
16045 })
16046
16047 }(jQuery);
16048
16049 /* ========================================================================
16050 * Bootstrap: carousel.js v3.2.0
16051 * http://getbootstrap.com/javascript/#carousel
16052 * ========================================================================
16053 * Copyright 2011-2014 Twitter, Inc.
16054 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16055 * ======================================================================== */
16056
16057
16058 +function ($) {
16059 'use strict';
16060
16061 // CAROUSEL CLASS DEFINITION
16062 // =========================
16063
16064 var Carousel = function (element, options) {
16065 this.$element = $(element).on('keydown.bs.carousel', $.proxy(this.keydown, this))
16066 this.$indicators = this.$element.find('.carousel-indicators')
16067 this.options = options
16068 this.paused =
16069 this.sliding =
16070 this.interval =
16071 this.$active =
16072 this.$items = null
16073
16074 this.options.pause == 'hover' && this.$element
16075 .on('mouseenter.bs.carousel', $.proxy(this.pause, this))
16076 .on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
16077 }
16078
16079 Carousel.VERSION = '3.2.0'
16080
16081 Carousel.DEFAULTS = {
16082 interval: 5000,
16083 pause: 'hover',
16084 wrap: true
16085 }
16086
16087 Carousel.prototype.keydown = function (e) {
16088 switch (e.which) {
16089 case 37: this.prev(); break
16090 case 39: this.next(); break
16091 default: return
16092 }
16093
16094 e.preventDefault()
16095 }
16096
16097 Carousel.prototype.cycle = function (e) {
16098 e || (this.paused = false)
16099
16100 this.interval && clearInterval(this.interval)
16101
16102 this.options.interval
16103 && !this.paused
16104 && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
16105
16106 return this
16107 }
16108
16109 Carousel.prototype.getItemIndex = function (item) {
16110 this.$items = item.parent().children('.item')
16111 return this.$items.index(item || this.$active)
16112 }
16113
16114 Carousel.prototype.to = function (pos) {
16115 var that = this
16116 var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active'))
16117
16118 if (pos > (this.$items.length - 1) || pos < 0) return
16119
16120 if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid"
16121 if (activeIndex == pos) return this.pause().cycle()
16122
16123 return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
16124 }
16125
16126 Carousel.prototype.pause = function (e) {
16127 e || (this.paused = true)
16128
16129 if (this.$element.find('.next, .prev').length && $.support.transition) {
16130 this.$element.trigger($.support.transition.end)
16131 this.cycle(true)
16132 }
16133
16134 this.interval = clearInterval(this.interval)
16135
16136 return this
16137 }
16138
16139 Carousel.prototype.next = function () {
16140 if (this.sliding) return
16141 return this.slide('next')
16142 }
16143
16144 Carousel.prototype.prev = function () {
16145 if (this.sliding) return
16146 return this.slide('prev')
16147 }
16148
16149 Carousel.prototype.slide = function (type, next) {
16150 var $active = this.$element.find('.item.active')
16151 var $next = next || $active[type]()
16152 var isCycling = this.interval
16153 var direction = type == 'next' ? 'left' : 'right'
16154 var fallback = type == 'next' ? 'first' : 'last'
16155 var that = this
16156
16157 if (!$next.length) {
16158 if (!this.options.wrap) return
16159 $next = this.$element.find('.item')[fallback]()
16160 }
16161
16162 if ($next.hasClass('active')) return (this.sliding = false)
16163
16164 var relatedTarget = $next[0]
16165 var slideEvent = $.Event('slide.bs.carousel', {
16166 relatedTarget: relatedTarget,
16167 direction: direction
16168 })
16169 this.$element.trigger(slideEvent)
16170 if (slideEvent.isDefaultPrevented()) return
16171
16172 this.sliding = true
16173
16174 isCycling && this.pause()
16175
16176 if (this.$indicators.length) {
16177 this.$indicators.find('.active').removeClass('active')
16178 var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)])
16179 $nextIndicator && $nextIndicator.addClass('active')
16180 }
16181
16182 var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid"
16183 if ($.support.transition && this.$element.hasClass('slide')) {
16184 $next.addClass(type)
16185 $next[0].offsetWidth // force reflow
16186 $active.addClass(direction)
16187 $next.addClass(direction)
16188 $active
16189 .one('bsTransitionEnd', function () {
16190 $next.removeClass([type, direction].join(' ')).addClass('active')
16191 $active.removeClass(['active', direction].join(' '))
16192 that.sliding = false
16193 setTimeout(function () {
16194 that.$element.trigger(slidEvent)
16195 }, 0)
16196 })
16197 .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000)
16198 } else {
16199 $active.removeClass('active')
16200 $next.addClass('active')
16201 this.sliding = false
16202 this.$element.trigger(slidEvent)
16203 }
16204
16205 isCycling && this.cycle()
16206
16207 return this
16208 }
16209
16210
16211 // CAROUSEL PLUGIN DEFINITION
16212 // ==========================
16213
16214 function Plugin(option) {
16215 return this.each(function () {
16216 var $this = $(this)
16217 var data = $this.data('bs.carousel')
16218 var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
16219 var action = typeof option == 'string' ? option : options.slide
16220
16221 if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
16222 if (typeof option == 'number') data.to(option)
16223 else if (action) data[action]()
16224 else if (options.interval) data.pause().cycle()
16225 })
16226 }
16227
16228 var old = $.fn.carousel
16229
16230 $.fn.carousel = Plugin
16231 $.fn.carousel.Constructor = Carousel
16232
16233
16234 // CAROUSEL NO CONFLICT
16235 // ====================
16236
16237 $.fn.carousel.noConflict = function () {
16238 $.fn.carousel = old
16239 return this
16240 }
16241
16242
16243 // CAROUSEL DATA-API
16244 // =================
16245
16246 $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
16247 var href
16248 var $this = $(this)
16249 var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7
16250 if (!$target.hasClass('carousel')) return
16251 var options = $.extend({}, $target.data(), $this.data())
16252 var slideIndex = $this.attr('data-slide-to')
16253 if (slideIndex) options.interval = false
16254
16255 Plugin.call($target, options)
16256
16257 if (slideIndex) {
16258 $target.data('bs.carousel').to(slideIndex)
16259 }
16260
16261 e.preventDefault()
16262 })
16263
16264 $(window).on('load', function () {
16265 $('[data-ride="carousel"]').each(function () {
16266 var $carousel = $(this)
16267 Plugin.call($carousel, $carousel.data())
16268 })
16269 })
16270
16271 }(jQuery);
16272
16273 /* ========================================================================
16274 * Bootstrap: collapse.js v3.2.0
16275 * http://getbootstrap.com/javascript/#collapse
16276 * ========================================================================
16277 * Copyright 2011-2014 Twitter, Inc.
16278 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16279 * ======================================================================== */
16280
16281
16282 +function ($) {
16283 'use strict';
16284
16285 // COLLAPSE PUBLIC CLASS DEFINITION
16286 // ================================
16287
16288 var Collapse = function (element, options) {
16289 this.$element = $(element)
16290 this.options = $.extend({}, Collapse.DEFAULTS, options)
16291 this.transitioning = null
16292
16293 if (this.options.parent) this.$parent = $(this.options.parent)
16294 if (this.options.toggle) this.toggle()
16295 }
16296
16297 Collapse.VERSION = '3.2.0'
16298
16299 Collapse.DEFAULTS = {
16300 toggle: true
16301 }
16302
16303 Collapse.prototype.dimension = function () {
16304 var hasWidth = this.$element.hasClass('width')
16305 return hasWidth ? 'width' : 'height'
16306 }
16307
16308 Collapse.prototype.show = function () {
16309 if (this.transitioning || this.$element.hasClass('in')) return
16310
16311 var startEvent = $.Event('show.bs.collapse')
16312 this.$element.trigger(startEvent)
16313 if (startEvent.isDefaultPrevented()) return
16314
16315 var actives = this.$parent && this.$parent.find('> .panel > .in')
16316
16317 if (actives && actives.length) {
16318 var hasData = actives.data('bs.collapse')
16319 if (hasData && hasData.transitioning) return
16320 Plugin.call(actives, 'hide')
16321 hasData || actives.data('bs.collapse', null)
16322 }
16323
16324 var dimension = this.dimension()
16325
16326 this.$element
16327 .removeClass('collapse')
16328 .addClass('collapsing')[dimension](0)
16329
16330 this.transitioning = 1
16331
16332 var complete = function () {
16333 this.$element
16334 .removeClass('collapsing')
16335 .addClass('collapse in')[dimension]('')
16336 this.transitioning = 0
16337 this.$element
16338 .trigger('shown.bs.collapse')
16339 }
16340
16341 if (!$.support.transition) return complete.call(this)
16342
16343 var scrollSize = $.camelCase(['scroll', dimension].join('-'))
16344
16345 this.$element
16346 .one('bsTransitionEnd', $.proxy(complete, this))
16347 .emulateTransitionEnd(350)[dimension](this.$element[0][scrollSize])
16348 }
16349
16350 Collapse.prototype.hide = function () {
16351 if (this.transitioning || !this.$element.hasClass('in')) return
16352
16353 var startEvent = $.Event('hide.bs.collapse')
16354 this.$element.trigger(startEvent)
16355 if (startEvent.isDefaultPrevented()) return
16356
16357 var dimension = this.dimension()
16358
16359 this.$element[dimension](this.$element[dimension]())[0].offsetHeight
16360
16361 this.$element
16362 .addClass('collapsing')
16363 .removeClass('collapse')
16364 .removeClass('in')
16365
16366 this.transitioning = 1
16367
16368 var complete = function () {
16369 this.transitioning = 0
16370 this.$element
16371 .trigger('hidden.bs.collapse')
16372 .removeClass('collapsing')
16373 .addClass('collapse')
16374 }
16375
16376 if (!$.support.transition) return complete.call(this)
16377
16378 this.$element
16379 [dimension](0)
16380 .one('bsTransitionEnd', $.proxy(complete, this))
16381 .emulateTransitionEnd(350)
16382 }
16383
16384 Collapse.prototype.toggle = function () {
16385 this[this.$element.hasClass('in') ? 'hide' : 'show']()
16386 }
16387
16388
16389 // COLLAPSE PLUGIN DEFINITION
16390 // ==========================
16391
16392 function Plugin(option) {
16393 return this.each(function () {
16394 var $this = $(this)
16395 var data = $this.data('bs.collapse')
16396 var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
16397
16398 if (!data && options.toggle && option == 'show') option = !option
16399 if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
16400 if (typeof option == 'string') data[option]()
16401 })
16402 }
16403
16404 var old = $.fn.collapse
16405
16406 $.fn.collapse = Plugin
16407 $.fn.collapse.Constructor = Collapse
16408
16409
16410 // COLLAPSE NO CONFLICT
16411 // ====================
16412
16413 $.fn.collapse.noConflict = function () {
16414 $.fn.collapse = old
16415 return this
16416 }
16417
16418
16419 // COLLAPSE DATA-API
16420 // =================
16421
16422 $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
16423 var href
16424 var $this = $(this)
16425 var target = $this.attr('data-target')
16426 || e.preventDefault()
16427 || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7
16428 var $target = $(target)
16429 var data = $target.data('bs.collapse')
16430 var option = data ? 'toggle' : $this.data()
16431 var parent = $this.attr('data-parent')
16432 var $parent = parent && $(parent)
16433
16434 if (!data || !data.transitioning) {
16435 if ($parent) $parent.find('[data-toggle="collapse"][data-parent="' + parent + '"]').not($this).addClass('collapsed')
16436 $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
16437 }
16438
16439 Plugin.call($target, option)
16440 })
16441
16442 }(jQuery);
16443
16444 /* ========================================================================
16445 * Bootstrap: dropdown.js v3.2.0
16446 * http://getbootstrap.com/javascript/#dropdowns
16447 * ========================================================================
16448 * Copyright 2011-2014 Twitter, Inc.
16449 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16450 * ======================================================================== */
16451
16452
16453 +function ($) {
16454 'use strict';
16455
16456 // DROPDOWN CLASS DEFINITION
16457 // =========================
16458
16459 var backdrop = '.dropdown-backdrop'
16460 var toggle = '[data-toggle="dropdown"]'
16461 var Dropdown = function (element) {
16462 $(element).on('click.bs.dropdown', this.toggle)
16463 }
16464
16465 Dropdown.VERSION = '3.2.0'
16466
16467 Dropdown.prototype.toggle = function (e) {
16468 var $this = $(this)
16469
16470 if ($this.is('.disabled, :disabled')) return
16471
16472 var $parent = getParent($this)
16473 var isActive = $parent.hasClass('open')
16474
16475 clearMenus()
16476
16477 if (!isActive) {
16478 if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
16479 // if mobile we use a backdrop because click events don't delegate
16480 $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
16481 }
16482
16483 var relatedTarget = { relatedTarget: this }
16484 $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
16485
16486 if (e.isDefaultPrevented()) return
16487
16488 $this.trigger('focus')
16489
16490 $parent
16491 .toggleClass('open')
16492 .trigger('shown.bs.dropdown', relatedTarget)
16493 }
16494
16495 return false
16496 }
16497
16498 Dropdown.prototype.keydown = function (e) {
16499 if (!/(38|40|27)/.test(e.keyCode)) return
16500
16501 var $this = $(this)
16502
16503 e.preventDefault()
16504 e.stopPropagation()
16505
16506 if ($this.is('.disabled, :disabled')) return
16507
16508 var $parent = getParent($this)
16509 var isActive = $parent.hasClass('open')
16510
16511 if (!isActive || (isActive && e.keyCode == 27)) {
16512 if (e.which == 27) $parent.find(toggle).trigger('focus')
16513 return $this.trigger('click')
16514 }
16515
16516 var desc = ' li:not(.divider):visible a'
16517 var $items = $parent.find('[role="menu"]' + desc + ', [role="listbox"]' + desc)
16518
16519 if (!$items.length) return
16520
16521 var index = $items.index($items.filter(':focus'))
16522
16523 if (e.keyCode == 38 && index > 0) index-- // up
16524 if (e.keyCode == 40 && index < $items.length - 1) index++ // down
16525 if (!~index) index = 0
16526
16527 $items.eq(index).trigger('focus')
16528 }
16529
16530 function clearMenus(e) {
16531 if (e && e.which === 3) return
16532 $(backdrop).remove()
16533 $(toggle).each(function () {
16534 var $parent = getParent($(this))
16535 var relatedTarget = { relatedTarget: this }
16536 if (!$parent.hasClass('open')) return
16537 $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
16538 if (e.isDefaultPrevented()) return
16539 $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
16540 })
16541 }
16542
16543 function getParent($this) {
16544 var selector = $this.attr('data-target')
16545
16546 if (!selector) {
16547 selector = $this.attr('href')
16548 selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
16549 }
16550
16551 var $parent = selector && $(selector)
16552
16553 return $parent && $parent.length ? $parent : $this.parent()
16554 }
16555
16556
16557 // DROPDOWN PLUGIN DEFINITION
16558 // ==========================
16559
16560 function Plugin(option) {
16561 return this.each(function () {
16562 var $this = $(this)
16563 var data = $this.data('bs.dropdown')
16564
16565 if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))
16566 if (typeof option == 'string') data[option].call($this)
16567 })
16568 }
16569
16570 var old = $.fn.dropdown
16571
16572 $.fn.dropdown = Plugin
16573 $.fn.dropdown.Constructor = Dropdown
16574
16575
16576 // DROPDOWN NO CONFLICT
16577 // ====================
16578
16579 $.fn.dropdown.noConflict = function () {
16580 $.fn.dropdown = old
16581 return this
16582 }
16583
16584
16585 // APPLY TO STANDARD DROPDOWN ELEMENTS
16586 // ===================================
16587
16588 $(document)
16589 .on('click.bs.dropdown.data-api', clearMenus)
16590 .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
16591 .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
16592 .on('keydown.bs.dropdown.data-api', toggle + ', [role="menu"], [role="listbox"]', Dropdown.prototype.keydown)
16593
16594 }(jQuery);
16595
16596 /* ========================================================================
16597 * Bootstrap: modal.js v3.2.0
16598 * http://getbootstrap.com/javascript/#modals
16599 * ========================================================================
16600 * Copyright 2011-2014 Twitter, Inc.
16601 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16602 * ======================================================================== */
16603
16604
16605 +function ($) {
16606 'use strict';
16607
16608 // MODAL CLASS DEFINITION
16609 // ======================
16610
16611 var Modal = function (element, options) {
16612 this.options = options
16613 this.$body = $(document.body)
16614 this.$element = $(element)
16615 this.$backdrop =
16616 this.isShown = null
16617 this.scrollbarWidth = 0
16618
16619 if (this.options.remote) {
16620 this.$element
16621 .find('.modal-content')
16622 .load(this.options.remote, $.proxy(function () {
16623 this.$element.trigger('loaded.bs.modal')
16624 }, this))
16625 }
16626 }
16627
16628 Modal.VERSION = '3.2.0'
16629
16630 Modal.DEFAULTS = {
16631 backdrop: true,
16632 keyboard: true,
16633 show: true
16634 }
16635
16636 Modal.prototype.toggle = function (_relatedTarget) {
16637 return this.isShown ? this.hide() : this.show(_relatedTarget)
16638 }
16639
16640 Modal.prototype.show = function (_relatedTarget) {
16641 var that = this
16642 var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
16643
16644 this.$element.trigger(e)
16645
16646 if (this.isShown || e.isDefaultPrevented()) return
16647
16648 this.isShown = true
16649
16650 this.checkScrollbar()
16651 this.$body.addClass('modal-open')
16652
16653 this.setScrollbar()
16654 this.escape()
16655
16656 this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
16657
16658 this.backdrop(function () {
16659 var transition = $.support.transition && that.$element.hasClass('fade')
16660
16661 if (!that.$element.parent().length) {
16662 that.$element.appendTo(that.$body) // don't move modals dom position
16663 }
16664
16665 that.$element
16666 .show()
16667 .scrollTop(0)
16668
16669 if (transition) {
16670 that.$element[0].offsetWidth // force reflow
16671 }
16672
16673 that.$element
16674 .addClass('in')
16675 .attr('aria-hidden', false)
16676
16677 that.enforceFocus()
16678
16679 var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
16680
16681 transition ?
16682 that.$element.find('.modal-dialog') // wait for modal to slide in
16683 .one('bsTransitionEnd', function () {
16684 that.$element.trigger('focus').trigger(e)
16685 })
16686 .emulateTransitionEnd(300) :
16687 that.$element.trigger('focus').trigger(e)
16688 })
16689 }
16690
16691 Modal.prototype.hide = function (e) {
16692 if (e) e.preventDefault()
16693
16694 e = $.Event('hide.bs.modal')
16695
16696 this.$element.trigger(e)
16697
16698 if (!this.isShown || e.isDefaultPrevented()) return
16699
16700 this.isShown = false
16701
16702 this.$body.removeClass('modal-open')
16703
16704 this.resetScrollbar()
16705 this.escape()
16706
16707 $(document).off('focusin.bs.modal')
16708
16709 this.$element
16710 .removeClass('in')
16711 .attr('aria-hidden', true)
16712 .off('click.dismiss.bs.modal')
16713
16714 $.support.transition && this.$element.hasClass('fade') ?
16715 this.$element
16716 .one('bsTransitionEnd', $.proxy(this.hideModal, this))
16717 .emulateTransitionEnd(300) :
16718 this.hideModal()
16719 }
16720
16721 Modal.prototype.enforceFocus = function () {
16722 $(document)
16723 .off('focusin.bs.modal') // guard against infinite focus loop
16724 .on('focusin.bs.modal', $.proxy(function (e) {
16725 if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
16726 this.$element.trigger('focus')
16727 }
16728 }, this))
16729 }
16730
16731 Modal.prototype.escape = function () {
16732 if (this.isShown && this.options.keyboard) {
16733 this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {
16734 e.which == 27 && this.hide()
16735 }, this))
16736 } else if (!this.isShown) {
16737 this.$element.off('keyup.dismiss.bs.modal')
16738 }
16739 }
16740
16741 Modal.prototype.hideModal = function () {
16742 var that = this
16743 this.$element.hide()
16744 this.backdrop(function () {
16745 that.$element.trigger('hidden.bs.modal')
16746 })
16747 }
16748
16749 Modal.prototype.removeBackdrop = function () {
16750 this.$backdrop && this.$backdrop.remove()
16751 this.$backdrop = null
16752 }
16753
16754 Modal.prototype.backdrop = function (callback) {
16755 var that = this
16756 var animate = this.$element.hasClass('fade') ? 'fade' : ''
16757
16758 if (this.isShown && this.options.backdrop) {
16759 var doAnimate = $.support.transition && animate
16760
16761 this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
16762 .appendTo(this.$body)
16763
16764 this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
16765 if (e.target !== e.currentTarget) return
16766 this.options.backdrop == 'static'
16767 ? this.$element[0].focus.call(this.$element[0])
16768 : this.hide.call(this)
16769 }, this))
16770
16771 if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
16772
16773 this.$backdrop.addClass('in')
16774
16775 if (!callback) return
16776
16777 doAnimate ?
16778 this.$backdrop
16779 .one('bsTransitionEnd', callback)
16780 .emulateTransitionEnd(150) :
16781 callback()
16782
16783 } else if (!this.isShown && this.$backdrop) {
16784 this.$backdrop.removeClass('in')
16785
16786 var callbackRemove = function () {
16787 that.removeBackdrop()
16788 callback && callback()
16789 }
16790 $.support.transition && this.$element.hasClass('fade') ?
16791 this.$backdrop
16792 .one('bsTransitionEnd', callbackRemove)
16793 .emulateTransitionEnd(150) :
16794 callbackRemove()
16795
16796 } else if (callback) {
16797 callback()
16798 }
16799 }
16800
16801 Modal.prototype.checkScrollbar = function () {
16802 if (document.body.clientWidth >= window.innerWidth) return
16803 this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar()
16804 }
16805
16806 Modal.prototype.setScrollbar = function () {
16807 var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
16808 if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
16809 }
16810
16811 Modal.prototype.resetScrollbar = function () {
16812 this.$body.css('padding-right', '')
16813 }
16814
16815 Modal.prototype.measureScrollbar = function () { // thx walsh
16816 var scrollDiv = document.createElement('div')
16817 scrollDiv.className = 'modal-scrollbar-measure'
16818 this.$body.append(scrollDiv)
16819 var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
16820 this.$body[0].removeChild(scrollDiv)
16821 return scrollbarWidth
16822 }
16823
16824
16825 // MODAL PLUGIN DEFINITION
16826 // =======================
16827
16828 function Plugin(option, _relatedTarget) {
16829 return this.each(function () {
16830 var $this = $(this)
16831 var data = $this.data('bs.modal')
16832 var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
16833
16834 if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
16835 if (typeof option == 'string') data[option](_relatedTarget)
16836 else if (options.show) data.show(_relatedTarget)
16837 })
16838 }
16839
16840 var old = $.fn.modal
16841
16842 $.fn.modal = Plugin
16843 $.fn.modal.Constructor = Modal
16844
16845
16846 // MODAL NO CONFLICT
16847 // =================
16848
16849 $.fn.modal.noConflict = function () {
16850 $.fn.modal = old
16851 return this
16852 }
16853
16854
16855 // MODAL DATA-API
16856 // ==============
16857
16858 $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
16859 var $this = $(this)
16860 var href = $this.attr('href')
16861 var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7
16862 var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
16863
16864 if ($this.is('a')) e.preventDefault()
16865
16866 $target.one('show.bs.modal', function (showEvent) {
16867 if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
16868 $target.one('hidden.bs.modal', function () {
16869 $this.is(':visible') && $this.trigger('focus')
16870 })
16871 })
16872 Plugin.call($target, option, this)
16873 })
16874
16875 }(jQuery);
16876
16877 /* ========================================================================
16878 * Bootstrap: tooltip.js v3.2.0
16879 * http://getbootstrap.com/javascript/#tooltip
16880 * Inspired by the original jQuery.tipsy by Jason Frame
16881 * ========================================================================
16882 * Copyright 2011-2014 Twitter, Inc.
16883 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
16884 * ======================================================================== */
16885
16886
16887 +function ($) {
16888 'use strict';
16889
16890 // TOOLTIP PUBLIC CLASS DEFINITION
16891 // ===============================
16892
16893 var Tooltip = function (element, options) {
16894 this.type =
16895 this.options =
16896 this.enabled =
16897 this.timeout =
16898 this.hoverState =
16899 this.$element = null
16900
16901 this.init('tooltip', element, options)
16902 }
16903
16904 Tooltip.VERSION = '3.2.0'
16905
16906 Tooltip.DEFAULTS = {
16907 animation: true,
16908 placement: 'top',
16909 selector: false,
16910 template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
16911 trigger: 'hover focus',
16912 title: '',
16913 delay: 0,
16914 html: false,
16915 container: false,
16916 viewport: {
16917 selector: 'body',
16918 padding: 0
16919 }
16920 }
16921
16922 Tooltip.prototype.init = function (type, element, options) {
16923 this.enabled = true
16924 this.type = type
16925 this.$element = $(element)
16926 this.options = this.getOptions(options)
16927 this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport)
16928
16929 var triggers = this.options.trigger.split(' ')
16930
16931 for (var i = triggers.length; i--;) {
16932 var trigger = triggers[i]
16933
16934 if (trigger == 'click') {
16935 this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
16936 } else if (trigger != 'manual') {
16937 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
16938 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
16939
16940 this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
16941 this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
16942 }
16943 }
16944
16945 this.options.selector ?
16946 (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
16947 this.fixTitle()
16948 }
16949
16950 Tooltip.prototype.getDefaults = function () {
16951 return Tooltip.DEFAULTS
16952 }
16953
16954 Tooltip.prototype.getOptions = function (options) {
16955 options = $.extend({}, this.getDefaults(), this.$element.data(), options)
16956
16957 if (options.delay && typeof options.delay == 'number') {
16958 options.delay = {
16959 show: options.delay,
16960 hide: options.delay
16961 }
16962 }
16963
16964 return options
16965 }
16966
16967 Tooltip.prototype.getDelegateOptions = function () {
16968 var options = {}
16969 var defaults = this.getDefaults()
16970
16971 this._options && $.each(this._options, function (key, value) {
16972 if (defaults[key] != value) options[key] = value
16973 })
16974
16975 return options
16976 }
16977
16978 Tooltip.prototype.enter = function (obj) {
16979 var self = obj instanceof this.constructor ?
16980 obj : $(obj.currentTarget).data('bs.' + this.type)
16981
16982 if (!self) {
16983 self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
16984 $(obj.currentTarget).data('bs.' + this.type, self)
16985 }
16986
16987 clearTimeout(self.timeout)
16988
16989 self.hoverState = 'in'
16990
16991 if (!self.options.delay || !self.options.delay.show) return self.show()
16992
16993 self.timeout = setTimeout(function () {
16994 if (self.hoverState == 'in') self.show()
16995 }, self.options.delay.show)
16996 }
16997
16998 Tooltip.prototype.leave = function (obj) {
16999 var self = obj instanceof this.constructor ?
17000 obj : $(obj.currentTarget).data('bs.' + this.type)
17001
17002 if (!self) {
17003 self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
17004 $(obj.currentTarget).data('bs.' + this.type, self)
17005 }
17006
17007 clearTimeout(self.timeout)
17008
17009 self.hoverState = 'out'
17010
17011 if (!self.options.delay || !self.options.delay.hide) return self.hide()
17012
17013 self.timeout = setTimeout(function () {
17014 if (self.hoverState == 'out') self.hide()
17015 }, self.options.delay.hide)
17016 }
17017
17018 Tooltip.prototype.show = function () {
17019 var e = $.Event('show.bs.' + this.type)
17020
17021 if (this.hasContent() && this.enabled) {
17022 this.$element.trigger(e)
17023
17024 var inDom = $.contains(document.documentElement, this.$element[0])
17025 if (e.isDefaultPrevented() || !inDom) return
17026 var that = this
17027
17028 var $tip = this.tip()
17029
17030 var tipId = this.getUID(this.type)
17031
17032 this.setContent()
17033 $tip.attr('id', tipId)
17034 this.$element.attr('aria-describedby', tipId)
17035
17036 if (this.options.animation) $tip.addClass('fade')
17037
17038 var placement = typeof this.options.placement == 'function' ?
17039 this.options.placement.call(this, $tip[0], this.$element[0]) :
17040 this.options.placement
17041
17042 var autoToken = /\s?auto?\s?/i
17043 var autoPlace = autoToken.test(placement)
17044 if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
17045
17046 $tip
17047 .detach()
17048 .css({ top: 0, left: 0, display: 'block' })
17049 .addClass(placement)
17050 .data('bs.' + this.type, this)
17051
17052 this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
17053
17054 var pos = this.getPosition()
17055 var actualWidth = $tip[0].offsetWidth
17056 var actualHeight = $tip[0].offsetHeight
17057
17058 if (autoPlace) {
17059 var orgPlacement = placement
17060 var $parent = this.$element.parent()
17061 var parentDim = this.getPosition($parent)
17062
17063 placement = placement == 'bottom' && pos.top + pos.height + actualHeight - parentDim.scroll > parentDim.height ? 'top' :
17064 placement == 'top' && pos.top - parentDim.scroll - actualHeight < 0 ? 'bottom' :
17065 placement == 'right' && pos.right + actualWidth > parentDim.width ? 'left' :
17066 placement == 'left' && pos.left - actualWidth < parentDim.left ? 'right' :
17067 placement
17068
17069 $tip
17070 .removeClass(orgPlacement)
17071 .addClass(placement)
17072 }
17073
17074 var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
17075
17076 this.applyPlacement(calculatedOffset, placement)
17077
17078 var complete = function () {
17079 that.$element.trigger('shown.bs.' + that.type)
17080 that.hoverState = null
17081 }
17082
17083 $.support.transition && this.$tip.hasClass('fade') ?
17084 $tip
17085 .one('bsTransitionEnd', complete)
17086 .emulateTransitionEnd(150) :
17087 complete()
17088 }
17089 }
17090
17091 Tooltip.prototype.applyPlacement = function (offset, placement) {
17092 var $tip = this.tip()
17093 var width = $tip[0].offsetWidth
17094 var height = $tip[0].offsetHeight
17095
17096 // manually read margins because getBoundingClientRect includes difference
17097 var marginTop = parseInt($tip.css('margin-top'), 10)
17098 var marginLeft = parseInt($tip.css('margin-left'), 10)
17099
17100 // we must check for NaN for ie 8/9
17101 if (isNaN(marginTop)) marginTop = 0
17102 if (isNaN(marginLeft)) marginLeft = 0
17103
17104 offset.top = offset.top + marginTop
17105 offset.left = offset.left + marginLeft
17106
17107 // $.fn.offset doesn't round pixel values
17108 // so we use setOffset directly with our own function B-0
17109 $.offset.setOffset($tip[0], $.extend({
17110 using: function (props) {
17111 $tip.css({
17112 top: Math.round(props.top),
17113 left: Math.round(props.left)
17114 })
17115 }
17116 }, offset), 0)
17117
17118 $tip.addClass('in')
17119
17120 // check to see if placing tip in new offset caused the tip to resize itself
17121 var actualWidth = $tip[0].offsetWidth
17122 var actualHeight = $tip[0].offsetHeight
17123
17124 if (placement == 'top' && actualHeight != height) {
17125 offset.top = offset.top + height - actualHeight
17126 }
17127
17128 var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
17129
17130 if (delta.left) offset.left += delta.left
17131 else offset.top += delta.top
17132
17133 var arrowDelta = delta.left ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight
17134 var arrowPosition = delta.left ? 'left' : 'top'
17135 var arrowOffsetPosition = delta.left ? 'offsetWidth' : 'offsetHeight'
17136
17137 $tip.offset(offset)
17138 this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], arrowPosition)
17139 }
17140
17141 Tooltip.prototype.replaceArrow = function (delta, dimension, position) {
17142 this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + '%') : '')
17143 }
17144
17145 Tooltip.prototype.setContent = function () {
17146 var $tip = this.tip()
17147 var title = this.getTitle()
17148
17149 $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
17150 $tip.removeClass('fade in top bottom left right')
17151 }
17152
17153 Tooltip.prototype.hide = function () {
17154 var that = this
17155 var $tip = this.tip()
17156 var e = $.Event('hide.bs.' + this.type)
17157
17158 this.$element.removeAttr('aria-describedby')
17159
17160 function complete() {
17161 if (that.hoverState != 'in') $tip.detach()
17162 that.$element.trigger('hidden.bs.' + that.type)
17163 }
17164
17165 this.$element.trigger(e)
17166
17167 if (e.isDefaultPrevented()) return
17168
17169 $tip.removeClass('in')
17170
17171 $.support.transition && this.$tip.hasClass('fade') ?
17172 $tip
17173 .one('bsTransitionEnd', complete)
17174 .emulateTransitionEnd(150) :
17175 complete()
17176
17177 this.hoverState = null
17178
17179 return this
17180 }
17181
17182 Tooltip.prototype.fixTitle = function () {
17183 var $e = this.$element
17184 if ($e.attr('title') || typeof ($e.attr('data-original-title')) != 'string') {
17185 $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
17186 }
17187 }
17188
17189 Tooltip.prototype.hasContent = function () {
17190 return this.getTitle()
17191 }
17192
17193 Tooltip.prototype.getPosition = function ($element) {
17194 $element = $element || this.$element
17195 var el = $element[0]
17196 var isBody = el.tagName == 'BODY'
17197 return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : null, {
17198 scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop(),
17199 width: isBody ? $(window).width() : $element.outerWidth(),
17200 height: isBody ? $(window).height() : $element.outerHeight()
17201 }, isBody ? { top: 0, left: 0 } : $element.offset())
17202 }
17203
17204 Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
17205 return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
17206 placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
17207 placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
17208 /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
17209
17210 }
17211
17212 Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
17213 var delta = { top: 0, left: 0 }
17214 if (!this.$viewport) return delta
17215
17216 var viewportPadding = this.options.viewport && this.options.viewport.padding || 0
17217 var viewportDimensions = this.getPosition(this.$viewport)
17218
17219 if (/right|left/.test(placement)) {
17220 var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll
17221 var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
17222 if (topEdgeOffset < viewportDimensions.top) { // top overflow
17223 delta.top = viewportDimensions.top - topEdgeOffset
17224 } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
17225 delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
17226 }
17227 } else {
17228 var leftEdgeOffset = pos.left - viewportPadding
17229 var rightEdgeOffset = pos.left + viewportPadding + actualWidth
17230 if (leftEdgeOffset < viewportDimensions.left) { // left overflow
17231 delta.left = viewportDimensions.left - leftEdgeOffset
17232 } else if (rightEdgeOffset > viewportDimensions.width) { // right overflow
17233 delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
17234 }
17235 }
17236
17237 return delta
17238 }
17239
17240 Tooltip.prototype.getTitle = function () {
17241 var title
17242 var $e = this.$element
17243 var o = this.options
17244
17245 title = $e.attr('data-original-title')
17246 || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
17247
17248 return title
17249 }
17250
17251 Tooltip.prototype.getUID = function (prefix) {
17252 do prefix += ~~(Math.random() * 1000000)
17253 while (document.getElementById(prefix))
17254 return prefix
17255 }
17256
17257 Tooltip.prototype.tip = function () {
17258 return (this.$tip = this.$tip || $(this.options.template))
17259 }
17260
17261 Tooltip.prototype.arrow = function () {
17262 return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))
17263 }
17264
17265 Tooltip.prototype.validate = function () {
17266 if (!this.$element[0].parentNode) {
17267 this.hide()
17268 this.$element = null
17269 this.options = null
17270 }
17271 }
17272
17273 Tooltip.prototype.enable = function () {
17274 this.enabled = true
17275 }
17276
17277 Tooltip.prototype.disable = function () {
17278 this.enabled = false
17279 }
17280
17281 Tooltip.prototype.toggleEnabled = function () {
17282 this.enabled = !this.enabled
17283 }
17284
17285 Tooltip.prototype.toggle = function (e) {
17286 var self = this
17287 if (e) {
17288 self = $(e.currentTarget).data('bs.' + this.type)
17289 if (!self) {
17290 self = new this.constructor(e.currentTarget, this.getDelegateOptions())
17291 $(e.currentTarget).data('bs.' + this.type, self)
17292 }
17293 }
17294
17295 self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
17296 }
17297
17298 Tooltip.prototype.destroy = function () {
17299 clearTimeout(this.timeout)
17300 this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
17301 }
17302
17303
17304 // TOOLTIP PLUGIN DEFINITION
17305 // =========================
17306
17307 function Plugin(option) {
17308 return this.each(function () {
17309 var $this = $(this)
17310 var data = $this.data('bs.tooltip')
17311 var options = typeof option == 'object' && option
17312
17313 if (!data && option == 'destroy') return
17314 if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
17315 if (typeof option == 'string') data[option]()
17316 })
17317 }
17318
17319 var old = $.fn.tooltip
17320
17321 $.fn.tooltip = Plugin
17322 $.fn.tooltip.Constructor = Tooltip
17323
17324
17325 // TOOLTIP NO CONFLICT
17326 // ===================
17327
17328 $.fn.tooltip.noConflict = function () {
17329 $.fn.tooltip = old
17330 return this
17331 }
17332
17333 }(jQuery);
17334
17335 /* ========================================================================
17336 * Bootstrap: popover.js v3.2.0
17337 * http://getbootstrap.com/javascript/#popovers
17338 * ========================================================================
17339 * Copyright 2011-2014 Twitter, Inc.
17340 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17341 * ======================================================================== */
17342
17343
17344 +function ($) {
17345 'use strict';
17346
17347 // POPOVER PUBLIC CLASS DEFINITION
17348 // ===============================
17349
17350 var Popover = function (element, options) {
17351 this.init('popover', element, options)
17352 }
17353
17354 if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
17355
17356 Popover.VERSION = '3.2.0'
17357
17358 Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
17359 placement: 'right',
17360 trigger: 'click',
17361 content: '',
17362 template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
17363 })
17364
17365
17366 // NOTE: POPOVER EXTENDS tooltip.js
17367 // ================================
17368
17369 Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
17370
17371 Popover.prototype.constructor = Popover
17372
17373 Popover.prototype.getDefaults = function () {
17374 return Popover.DEFAULTS
17375 }
17376
17377 Popover.prototype.setContent = function () {
17378 var $tip = this.tip()
17379 var title = this.getTitle()
17380 var content = this.getContent()
17381
17382 $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
17383 $tip.find('.popover-content').empty()[ // we use append for html objects to maintain js events
17384 this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
17385 ](content)
17386
17387 $tip.removeClass('fade top bottom left right in')
17388
17389 // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
17390 // this manually by checking the contents.
17391 if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
17392 }
17393
17394 Popover.prototype.hasContent = function () {
17395 return this.getTitle() || this.getContent()
17396 }
17397
17398 Popover.prototype.getContent = function () {
17399 var $e = this.$element
17400 var o = this.options
17401
17402 return $e.attr('data-content')
17403 || (typeof o.content == 'function' ?
17404 o.content.call($e[0]) :
17405 o.content)
17406 }
17407
17408 Popover.prototype.arrow = function () {
17409 return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
17410 }
17411
17412 Popover.prototype.tip = function () {
17413 if (!this.$tip) this.$tip = $(this.options.template)
17414 return this.$tip
17415 }
17416
17417
17418 // POPOVER PLUGIN DEFINITION
17419 // =========================
17420
17421 function Plugin(option) {
17422 return this.each(function () {
17423 var $this = $(this)
17424 var data = $this.data('bs.popover')
17425 var options = typeof option == 'object' && option
17426
17427 if (!data && option == 'destroy') return
17428 if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
17429 if (typeof option == 'string') data[option]()
17430 })
17431 }
17432
17433 var old = $.fn.popover
17434
17435 $.fn.popover = Plugin
17436 $.fn.popover.Constructor = Popover
17437
17438
17439 // POPOVER NO CONFLICT
17440 // ===================
17441
17442 $.fn.popover.noConflict = function () {
17443 $.fn.popover = old
17444 return this
17445 }
17446
17447 }(jQuery);
17448
17449 /* ========================================================================
17450 * Bootstrap: scrollspy.js v3.2.0
17451 * http://getbootstrap.com/javascript/#scrollspy
17452 * ========================================================================
17453 * Copyright 2011-2014 Twitter, Inc.
17454 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17455 * ======================================================================== */
17456
17457
17458 +function ($) {
17459 'use strict';
17460
17461 // SCROLLSPY CLASS DEFINITION
17462 // ==========================
17463
17464 function ScrollSpy(element, options) {
17465 var process = $.proxy(this.process, this)
17466
17467 this.$body = $('body')
17468 this.$scrollElement = $(element).is('body') ? $(window) : $(element)
17469 this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
17470 this.selector = (this.options.target || '') + ' .nav li > a'
17471 this.offsets = []
17472 this.targets = []
17473 this.activeTarget = null
17474 this.scrollHeight = 0
17475
17476 this.$scrollElement.on('scroll.bs.scrollspy', process)
17477 this.refresh()
17478 this.process()
17479 }
17480
17481 ScrollSpy.VERSION = '3.2.0'
17482
17483 ScrollSpy.DEFAULTS = {
17484 offset: 10
17485 }
17486
17487 ScrollSpy.prototype.getScrollHeight = function () {
17488 return this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight)
17489 }
17490
17491 ScrollSpy.prototype.refresh = function () {
17492 var offsetMethod = 'offset'
17493 var offsetBase = 0
17494
17495 if (!$.isWindow(this.$scrollElement[0])) {
17496 offsetMethod = 'position'
17497 offsetBase = this.$scrollElement.scrollTop()
17498 }
17499
17500 this.offsets = []
17501 this.targets = []
17502 this.scrollHeight = this.getScrollHeight()
17503
17504 var self = this
17505
17506 this.$body
17507 .find(this.selector)
17508 .map(function () {
17509 var $el = $(this)
17510 var href = $el.data('target') || $el.attr('href')
17511 var $href = /^#./.test(href) && $(href)
17512
17513 return ($href
17514 && $href.length
17515 && $href.is(':visible')
17516 && [[$href[offsetMethod]().top + offsetBase, href]]) || null
17517 })
17518 .sort(function (a, b) { return a[0] - b[0] })
17519 .each(function () {
17520 self.offsets.push(this[0])
17521 self.targets.push(this[1])
17522 })
17523 }
17524
17525 ScrollSpy.prototype.process = function () {
17526 var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
17527 var scrollHeight = this.getScrollHeight()
17528 var maxScroll = this.options.offset + scrollHeight - this.$scrollElement.height()
17529 var offsets = this.offsets
17530 var targets = this.targets
17531 var activeTarget = this.activeTarget
17532 var i
17533
17534 if (this.scrollHeight != scrollHeight) {
17535 this.refresh()
17536 }
17537
17538 if (scrollTop >= maxScroll) {
17539 return activeTarget != (i = targets[targets.length - 1]) && this.activate(i)
17540 }
17541
17542 if (activeTarget && scrollTop <= offsets[0]) {
17543 return activeTarget != (i = targets[0]) && this.activate(i)
17544 }
17545
17546 for (i = offsets.length; i--;) {
17547 activeTarget != targets[i]
17548 && scrollTop >= offsets[i]
17549 && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
17550 && this.activate(targets[i])
17551 }
17552 }
17553
17554 ScrollSpy.prototype.activate = function (target) {
17555 this.activeTarget = target
17556
17557 $(this.selector)
17558 .parentsUntil(this.options.target, '.active')
17559 .removeClass('active')
17560
17561 var selector = this.selector +
17562 '[data-target="' + target + '"],' +
17563 this.selector + '[href="' + target + '"]'
17564
17565 var active = $(selector)
17566 .parents('li')
17567 .addClass('active')
17568
17569 if (active.parent('.dropdown-menu').length) {
17570 active = active
17571 .closest('li.dropdown')
17572 .addClass('active')
17573 }
17574
17575 active.trigger('activate.bs.scrollspy')
17576 }
17577
17578
17579 // SCROLLSPY PLUGIN DEFINITION
17580 // ===========================
17581
17582 function Plugin(option) {
17583 return this.each(function () {
17584 var $this = $(this)
17585 var data = $this.data('bs.scrollspy')
17586 var options = typeof option == 'object' && option
17587
17588 if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
17589 if (typeof option == 'string') data[option]()
17590 })
17591 }
17592
17593 var old = $.fn.scrollspy
17594
17595 $.fn.scrollspy = Plugin
17596 $.fn.scrollspy.Constructor = ScrollSpy
17597
17598
17599 // SCROLLSPY NO CONFLICT
17600 // =====================
17601
17602 $.fn.scrollspy.noConflict = function () {
17603 $.fn.scrollspy = old
17604 return this
17605 }
17606
17607
17608 // SCROLLSPY DATA-API
17609 // ==================
17610
17611 $(window).on('load.bs.scrollspy.data-api', function () {
17612 $('[data-spy="scroll"]').each(function () {
17613 var $spy = $(this)
17614 Plugin.call($spy, $spy.data())
17615 })
17616 })
17617
17618 }(jQuery);
17619
17620 /* ========================================================================
17621 * Bootstrap: tab.js v3.2.0
17622 * http://getbootstrap.com/javascript/#tabs
17623 * ========================================================================
17624 * Copyright 2011-2014 Twitter, Inc.
17625 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17626 * ======================================================================== */
17627
17628
17629 +function ($) {
17630 'use strict';
17631
17632 // TAB CLASS DEFINITION
17633 // ====================
17634
17635 var Tab = function (element) {
17636 this.element = $(element)
17637 }
17638
17639 Tab.VERSION = '3.2.0'
17640
17641 Tab.prototype.show = function () {
17642 var $this = this.element
17643 var $ul = $this.closest('ul:not(.dropdown-menu)')
17644 var selector = $this.data('target')
17645
17646 if (!selector) {
17647 selector = $this.attr('href')
17648 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
17649 }
17650
17651 if ($this.parent('li').hasClass('active')) return
17652
17653 var previous = $ul.find('.active:last a')[0]
17654 var e = $.Event('show.bs.tab', {
17655 relatedTarget: previous
17656 })
17657
17658 $this.trigger(e)
17659
17660 if (e.isDefaultPrevented()) return
17661
17662 var $target = $(selector)
17663
17664 this.activate($this.closest('li'), $ul)
17665 this.activate($target, $target.parent(), function () {
17666 $this.trigger({
17667 type: 'shown.bs.tab',
17668 relatedTarget: previous
17669 })
17670 })
17671 }
17672
17673 Tab.prototype.activate = function (element, container, callback) {
17674 var $active = container.find('> .active')
17675 var transition = callback
17676 && $.support.transition
17677 && $active.hasClass('fade')
17678
17679 function next() {
17680 $active
17681 .removeClass('active')
17682 .find('> .dropdown-menu > .active')
17683 .removeClass('active')
17684
17685 element.addClass('active')
17686
17687 if (transition) {
17688 element[0].offsetWidth // reflow for transition
17689 element.addClass('in')
17690 } else {
17691 element.removeClass('fade')
17692 }
17693
17694 if (element.parent('.dropdown-menu')) {
17695 element.closest('li.dropdown').addClass('active')
17696 }
17697
17698 callback && callback()
17699 }
17700
17701 transition ?
17702 $active
17703 .one('bsTransitionEnd', next)
17704 .emulateTransitionEnd(150) :
17705 next()
17706
17707 $active.removeClass('in')
17708 }
17709
17710
17711 // TAB PLUGIN DEFINITION
17712 // =====================
17713
17714 function Plugin(option) {
17715 return this.each(function () {
17716 var $this = $(this)
17717 var data = $this.data('bs.tab')
17718
17719 if (!data) $this.data('bs.tab', (data = new Tab(this)))
17720 if (typeof option == 'string') data[option]()
17721 })
17722 }
17723
17724 var old = $.fn.tab
17725
17726 $.fn.tab = Plugin
17727 $.fn.tab.Constructor = Tab
17728
17729
17730 // TAB NO CONFLICT
17731 // ===============
17732
17733 $.fn.tab.noConflict = function () {
17734 $.fn.tab = old
17735 return this
17736 }
17737
17738
17739 // TAB DATA-API
17740 // ============
17741
17742 $(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
17743 e.preventDefault()
17744 Plugin.call($(this), 'show')
17745 })
17746
17747 }(jQuery);
17748
17749 /* ========================================================================
17750 * Bootstrap: affix.js v3.2.0
17751 * http://getbootstrap.com/javascript/#affix
17752 * ========================================================================
17753 * Copyright 2011-2014 Twitter, Inc.
17754 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
17755 * ======================================================================== */
17756
17757
17758 +function ($) {
17759 'use strict';
17760
17761 // AFFIX CLASS DEFINITION
17762 // ======================
17763
17764 var Affix = function (element, options) {
17765 this.options = $.extend({}, Affix.DEFAULTS, options)
17766
17767 this.$target = $(this.options.target)
17768 .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
17769 .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))
17770
17771 this.$element = $(element)
17772 this.affixed =
17773 this.unpin =
17774 this.pinnedOffset = null
17775
17776 this.checkPosition()
17777 }
17778
17779 Affix.VERSION = '3.2.0'
17780
17781 Affix.RESET = 'affix affix-top affix-bottom'
17782
17783 Affix.DEFAULTS = {
17784 offset: 0,
17785 target: window
17786 }
17787
17788 Affix.prototype.getPinnedOffset = function () {
17789 if (this.pinnedOffset) return this.pinnedOffset
17790 this.$element.removeClass(Affix.RESET).addClass('affix')
17791 var scrollTop = this.$target.scrollTop()
17792 var position = this.$element.offset()
17793 return (this.pinnedOffset = position.top - scrollTop)
17794 }
17795
17796 Affix.prototype.checkPositionWithEventLoop = function () {
17797 setTimeout($.proxy(this.checkPosition, this), 1)
17798 }
17799
17800 Affix.prototype.checkPosition = function () {
17801 if (!this.$element.is(':visible')) return
17802
17803 var scrollHeight = $(document).height()
17804 var scrollTop = this.$target.scrollTop()
17805 var position = this.$element.offset()
17806 var offset = this.options.offset
17807 var offsetTop = offset.top
17808 var offsetBottom = offset.bottom
17809
17810 if (typeof offset != 'object') offsetBottom = offsetTop = offset
17811 if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element)
17812 if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element)
17813
17814 var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false :
17815 offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' :
17816 offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false
17817
17818 if (this.affixed === affix) return
17819 if (this.unpin != null) this.$element.css('top', '')
17820
17821 var affixType = 'affix' + (affix ? '-' + affix : '')
17822 var e = $.Event(affixType + '.bs.affix')
17823
17824 this.$element.trigger(e)
17825
17826 if (e.isDefaultPrevented()) return
17827
17828 this.affixed = affix
17829 this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null
17830
17831 this.$element
17832 .removeClass(Affix.RESET)
17833 .addClass(affixType)
17834 .trigger($.Event(affixType.replace('affix', 'affixed')))
17835
17836 if (affix == 'bottom') {
17837 this.$element.offset({
17838 top: scrollHeight - this.$element.height() - offsetBottom
17839 })
17840 }
17841 }
17842
17843
17844 // AFFIX PLUGIN DEFINITION
17845 // =======================
17846
17847 function Plugin(option) {
17848 return this.each(function () {
17849 var $this = $(this)
17850 var data = $this.data('bs.affix')
17851 var options = typeof option == 'object' && option
17852
17853 if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
17854 if (typeof option == 'string') data[option]()
17855 })
17856 }
17857
17858 var old = $.fn.affix
17859
17860 $.fn.affix = Plugin
17861 $.fn.affix.Constructor = Affix
17862
17863
17864 // AFFIX NO CONFLICT
17865 // =================
17866
17867 $.fn.affix.noConflict = function () {
17868 $.fn.affix = old
17869 return this
17870 }
17871
17872
17873 // AFFIX DATA-API
17874 // ==============
17875
17876 $(window).on('load', function () {
17877 $('[data-spy="affix"]').each(function () {
17878 var $spy = $(this)
17879 var data = $spy.data()
17880
17881 data.offset = data.offset || {}
17882
17883 if (data.offsetBottom) data.offset.bottom = data.offsetBottom
17884 if (data.offsetTop) data.offset.top = data.offsetTop
17885
17886 Plugin.call($spy, data)
17887 })
17888 })
17889
17890 }(jQuery);
17891 </script>
17892 <script>
17893 (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){
17894 var assert = _dereq_('assert')
17895
17896 module.exports = BigInteger
17897
17898 // JavaScript engine analysis
17899 var canary = 0xdeadbeefcafe;
17900 var j_lm = ((canary&0xffffff)==0xefcafe);
17901
17902 // (public) Constructor
17903 function BigInteger(a,b,c) {
17904 if (!(this instanceof BigInteger)) {
17905 return new BigInteger(a, b, c);
17906 }
17907
17908 if(a != null) {
17909 if("number" == typeof a) this.fromNumber(a,b,c);
17910 else if(b == null && "string" != typeof a) this.fromString(a,256);
17911 else this.fromString(a,b);
17912 }
17913 }
17914
17915 var proto = BigInteger.prototype;
17916
17917 // return new, unset BigInteger
17918 function nbi() { return new BigInteger(null); }
17919
17920 // Bits per digit
17921 var dbits;
17922
17923 // am: Compute w_j += (x*this_i), propagate carries,
17924 // c is initial carry, returns final carry.
17925 // c < 3*dvalue, x < 2*dvalue, this_i < dvalue
17926 // We need to select the fastest one that works in this environment.
17927
17928 // am1: use a single mult and divide to get the high bits,
17929 // max digit bits should be 26 because
17930 // max internal value = 2*dvalue^2-2*dvalue (< 2^53)
17931 function am1(i,x,w,j,c,n) {
17932 while(--n >= 0) {
17933 var v = x*this[i++]+w[j]+c;
17934 c = Math.floor(v/0x4000000);
17935 w[j++] = v&0x3ffffff;
17936 }
17937 return c;
17938 }
17939 // am2 avoids a big mult-and-extract completely.
17940 // Max digit bits should be <= 30 because we do bitwise ops
17941 // on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
17942 function am2(i,x,w,j,c,n) {
17943 var xl = x&0x7fff, xh = x>>15;
17944 while(--n >= 0) {
17945 var l = this[i]&0x7fff;
17946 var h = this[i++]>>15;
17947 var m = xh*l+h*xl;
17948 l = xl*l+((m&0x7fff)<<15)+w[j]+(c&0x3fffffff);
17949 c = (l>>>30)+(m>>>15)+xh*h+(c>>>30);
17950 w[j++] = l&0x3fffffff;
17951 }
17952 return c;
17953 }
17954 // Alternately, set max digit bits to 28 since some
17955 // browsers slow down when dealing with 32-bit numbers.
17956 function am3(i,x,w,j,c,n) {
17957 var xl = x&0x3fff, xh = x>>14;
17958 while(--n >= 0) {
17959 var l = this[i]&0x3fff;
17960 var h = this[i++]>>14;
17961 var m = xh*l+h*xl;
17962 l = xl*l+((m&0x3fff)<<14)+w[j]+c;
17963 c = (l>>28)+(m>>14)+xh*h;
17964 w[j++] = l&0xfffffff;
17965 }
17966 return c;
17967 }
17968
17969 // wtf?
17970 BigInteger.prototype.am = am1;
17971 dbits = 26;
17972
17973 /*
17974 if(j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
17975 BigInteger.prototype.am = am2;
17976 dbits = 30;
17977 }
17978 else if(j_lm && (navigator.appName != "Netscape")) {
17979 BigInteger.prototype.am = am1;
17980 dbits = 26;
17981 }
17982 else { // Mozilla/Netscape seems to prefer am3
17983 BigInteger.prototype.am = am3;
17984 dbits = 28;
17985 }
17986 */
17987
17988 BigInteger.prototype.DB = dbits;
17989 BigInteger.prototype.DM = ((1<<dbits)-1);
17990 var DV = BigInteger.prototype.DV = (1<<dbits);
17991
17992 var BI_FP = 52;
17993 BigInteger.prototype.FV = Math.pow(2,BI_FP);
17994 BigInteger.prototype.F1 = BI_FP-dbits;
17995 BigInteger.prototype.F2 = 2*dbits-BI_FP;
17996
17997 // Digit conversions
17998 var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
17999 var BI_RC = new Array();
18000 var rr,vv;
18001 rr = "0".charCodeAt(0);
18002 for(vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
18003 rr = "a".charCodeAt(0);
18004 for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
18005 rr = "A".charCodeAt(0);
18006 for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
18007
18008 function int2char(n) { return BI_RM.charAt(n); }
18009 function intAt(s,i) {
18010 var c = BI_RC[s.charCodeAt(i)];
18011 return (c==null)?-1:c;
18012 }
18013
18014 // (protected) copy this to r
18015 function bnpCopyTo(r) {
18016 for(var i = this.t-1; i >= 0; --i) r[i] = this[i];
18017 r.t = this.t;
18018 r.s = this.s;
18019 }
18020
18021 // (protected) set from integer value x, -DV <= x < DV
18022 function bnpFromInt(x) {
18023 this.t = 1;
18024 this.s = (x<0)?-1:0;
18025 if(x > 0) this[0] = x;
18026 else if(x < -1) this[0] = x+DV;
18027 else this.t = 0;
18028 }
18029
18030 // return bigint initialized to value
18031 function nbv(i) { var r = nbi(); r.fromInt(i); return r; }
18032
18033 // (protected) set from string and radix
18034 function bnpFromString(s,b) {
18035 var self = this;
18036
18037 var k;
18038 if(b == 16) k = 4;
18039 else if(b == 8) k = 3;
18040 else if(b == 256) k = 8; // byte array
18041 else if(b == 2) k = 1;
18042 else if(b == 32) k = 5;
18043 else if(b == 4) k = 2;
18044 else { self.fromRadix(s,b); return; }
18045 self.t = 0;
18046 self.s = 0;
18047 var i = s.length, mi = false, sh = 0;
18048 while(--i >= 0) {
18049 var x = (k==8)?s[i]&0xff:intAt(s,i);
18050 if(x < 0) {
18051 if(s.charAt(i) == "-") mi = true;
18052 continue;
18053 }
18054 mi = false;
18055 if(sh == 0)
18056 self[self.t++] = x;
18057 else if(sh+k > self.DB) {
18058 self[self.t-1] |= (x&((1<<(self.DB-sh))-1))<<sh;
18059 self[self.t++] = (x>>(self.DB-sh));
18060 }
18061 else
18062 self[self.t-1] |= x<<sh;
18063 sh += k;
18064 if(sh >= self.DB) sh -= self.DB;
18065 }
18066 if(k == 8 && (s[0]&0x80) != 0) {
18067 self.s = -1;
18068 if(sh > 0) self[self.t-1] |= ((1<<(self.DB-sh))-1)<<sh;
18069 }
18070 self.clamp();
18071 if(mi) BigInteger.ZERO.subTo(self,self);
18072 }
18073
18074 // (protected) clamp off excess high words
18075 function bnpClamp() {
18076 var c = this.s&this.DM;
18077 while(this.t > 0 && this[this.t-1] == c) --this.t;
18078 }
18079
18080 // (public) return string representation in given radix
18081 function bnToString(b) {
18082 var self = this;
18083 if(self.s < 0) return "-"+self.negate().toString(b);
18084 var k;
18085 if(b == 16) k = 4;
18086 else if(b == 8) k = 3;
18087 else if(b == 2) k = 1;
18088 else if(b == 32) k = 5;
18089 else if(b == 4) k = 2;
18090 else return self.toRadix(b);
18091 var km = (1<<k)-1, d, m = false, r = "", i = self.t;
18092 var p = self.DB-(i*self.DB)%k;
18093 if(i-- > 0) {
18094 if(p < self.DB && (d = self[i]>>p) > 0) { m = true; r = int2char(d); }
18095 while(i >= 0) {
18096 if(p < k) {
18097 d = (self[i]&((1<<p)-1))<<(k-p);
18098 d |= self[--i]>>(p+=self.DB-k);
18099 }
18100 else {
18101 d = (self[i]>>(p-=k))&km;
18102 if(p <= 0) { p += self.DB; --i; }
18103 }
18104 if(d > 0) m = true;
18105 if(m) r += int2char(d);
18106 }
18107 }
18108 return m?r:"0";
18109 }
18110
18111 // (public) -this
18112 function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; }
18113
18114 // (public) |this|
18115 function bnAbs() { return (this.s<0)?this.negate():this; }
18116
18117 // (public) return + if this > a, - if this < a, 0 if equal
18118 function bnCompareTo(a) {
18119 var r = this.s-a.s;
18120 if(r != 0) return r;
18121 var i = this.t;
18122 r = i-a.t;
18123 if(r != 0) return (this.s<0)?-r:r;
18124 while(--i >= 0) if((r=this[i]-a[i]) != 0) return r;
18125 return 0;
18126 }
18127
18128 // returns bit length of the integer x
18129 function nbits(x) {
18130 var r = 1, t;
18131 if((t=x>>>16) != 0) { x = t; r += 16; }
18132 if((t=x>>8) != 0) { x = t; r += 8; }
18133 if((t=x>>4) != 0) { x = t; r += 4; }
18134 if((t=x>>2) != 0) { x = t; r += 2; }
18135 if((t=x>>1) != 0) { x = t; r += 1; }
18136 return r;
18137 }
18138
18139 // (public) return the number of bits in "this"
18140 function bnBitLength() {
18141 if(this.t <= 0) return 0;
18142 return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM));
18143 }
18144
18145 // (protected) r = this << n*DB
18146 function bnpDLShiftTo(n,r) {
18147 var i;
18148 for(i = this.t-1; i >= 0; --i) r[i+n] = this[i];
18149 for(i = n-1; i >= 0; --i) r[i] = 0;
18150 r.t = this.t+n;
18151 r.s = this.s;
18152 }
18153
18154 // (protected) r = this >> n*DB
18155 function bnpDRShiftTo(n,r) {
18156 for(var i = n; i < this.t; ++i) r[i-n] = this[i];
18157 r.t = Math.max(this.t-n,0);
18158 r.s = this.s;
18159 }
18160
18161 // (protected) r = this << n
18162 function bnpLShiftTo(n,r) {
18163 var self = this;
18164 var bs = n%self.DB;
18165 var cbs = self.DB-bs;
18166 var bm = (1<<cbs)-1;
18167 var ds = Math.floor(n/self.DB), c = (self.s<<bs)&self.DM, i;
18168 for(i = self.t-1; i >= 0; --i) {
18169 r[i+ds+1] = (self[i]>>cbs)|c;
18170 c = (self[i]&bm)<<bs;
18171 }
18172 for(i = ds-1; i >= 0; --i) r[i] = 0;
18173 r[ds] = c;
18174 r.t = self.t+ds+1;
18175 r.s = self.s;
18176 r.clamp();
18177 }
18178
18179 // (protected) r = this >> n
18180 function bnpRShiftTo(n,r) {
18181 var self = this;
18182 r.s = self.s;
18183 var ds = Math.floor(n/self.DB);
18184 if(ds >= self.t) { r.t = 0; return; }
18185 var bs = n%self.DB;
18186 var cbs = self.DB-bs;
18187 var bm = (1<<bs)-1;
18188 r[0] = self[ds]>>bs;
18189 for(var i = ds+1; i < self.t; ++i) {
18190 r[i-ds-1] |= (self[i]&bm)<<cbs;
18191 r[i-ds] = self[i]>>bs;
18192 }
18193 if(bs > 0) r[self.t-ds-1] |= (self.s&bm)<<cbs;
18194 r.t = self.t-ds;
18195 r.clamp();
18196 }
18197
18198 // (protected) r = this - a
18199 function bnpSubTo(a,r) {
18200 var self = this;
18201 var i = 0, c = 0, m = Math.min(a.t,self.t);
18202 while(i < m) {
18203 c += self[i]-a[i];
18204 r[i++] = c&self.DM;
18205 c >>= self.DB;
18206 }
18207 if(a.t < self.t) {
18208 c -= a.s;
18209 while(i < self.t) {
18210 c += self[i];
18211 r[i++] = c&self.DM;
18212 c >>= self.DB;
18213 }
18214 c += self.s;
18215 }
18216 else {
18217 c += self.s;
18218 while(i < a.t) {
18219 c -= a[i];
18220 r[i++] = c&self.DM;
18221 c >>= self.DB;
18222 }
18223 c -= a.s;
18224 }
18225 r.s = (c<0)?-1:0;
18226 if(c < -1) r[i++] = self.DV+c;
18227 else if(c > 0) r[i++] = c;
18228 r.t = i;
18229 r.clamp();
18230 }
18231
18232 // (protected) r = this * a, r != this,a (HAC 14.12)
18233 // "this" should be the larger one if appropriate.
18234 function bnpMultiplyTo(a,r) {
18235 var x = this.abs(), y = a.abs();
18236 var i = x.t;
18237 r.t = i+y.t;
18238 while(--i >= 0) r[i] = 0;
18239 for(i = 0; i < y.t; ++i) r[i+x.t] = x.am(0,y[i],r,i,0,x.t);
18240 r.s = 0;
18241 r.clamp();
18242 if(this.s != a.s) BigInteger.ZERO.subTo(r,r);
18243 }
18244
18245 // (protected) r = this^2, r != this (HAC 14.16)
18246 function bnpSquareTo(r) {
18247 var x = this.abs();
18248 var i = r.t = 2*x.t;
18249 while(--i >= 0) r[i] = 0;
18250 for(i = 0; i < x.t-1; ++i) {
18251 var c = x.am(i,x[i],r,2*i,0,1);
18252 if((r[i+x.t]+=x.am(i+1,2*x[i],r,2*i+1,c,x.t-i-1)) >= x.DV) {
18253 r[i+x.t] -= x.DV;
18254 r[i+x.t+1] = 1;
18255 }
18256 }
18257 if(r.t > 0) r[r.t-1] += x.am(i,x[i],r,2*i,0,1);
18258 r.s = 0;
18259 r.clamp();
18260 }
18261
18262 // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
18263 // r != q, this != m. q or r may be null.
18264 function bnpDivRemTo(m,q,r) {
18265 var self = this;
18266 var pm = m.abs();
18267 if(pm.t <= 0) return;
18268 var pt = self.abs();
18269 if(pt.t < pm.t) {
18270 if(q != null) q.fromInt(0);
18271 if(r != null) self.copyTo(r);
18272 return;
18273 }
18274 if(r == null) r = nbi();
18275 var y = nbi(), ts = self.s, ms = m.s;
18276 var nsh = self.DB-nbits(pm[pm.t-1]); // normalize modulus
18277 if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); }
18278 else { pm.copyTo(y); pt.copyTo(r); }
18279 var ys = y.t;
18280 var y0 = y[ys-1];
18281 if(y0 == 0) return;
18282 var yt = y0*(1<<self.F1)+((ys>1)?y[ys-2]>>self.F2:0);
18283 var d1 = self.FV/yt, d2 = (1<<self.F1)/yt, e = 1<<self.F2;
18284 var i = r.t, j = i-ys, t = (q==null)?nbi():q;
18285 y.dlShiftTo(j,t);
18286 if(r.compareTo(t) >= 0) {
18287 r[r.t++] = 1;
18288 r.subTo(t,r);
18289 }
18290 BigInteger.ONE.dlShiftTo(ys,t);
18291 t.subTo(y,y); // "negative" y so we can replace sub with am later
18292 while(y.t < ys) y[y.t++] = 0;
18293 while(--j >= 0) {
18294 // Estimate quotient digit
18295 var qd = (r[--i]==y0)?self.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2);
18296 if((r[i]+=y.am(0,qd,r,j,0,ys)) < qd) { // Try it out
18297 y.dlShiftTo(j,t);
18298 r.subTo(t,r);
18299 while(r[i] < --qd) r.subTo(t,r);
18300 }
18301 }
18302 if(q != null) {
18303 r.drShiftTo(ys,q);
18304 if(ts != ms) BigInteger.ZERO.subTo(q,q);
18305 }
18306 r.t = ys;
18307 r.clamp();
18308 if(nsh > 0) r.rShiftTo(nsh,r); // Denormalize remainder
18309 if(ts < 0) BigInteger.ZERO.subTo(r,r);
18310 }
18311
18312 // (public) this mod a
18313 function bnMod(a) {
18314 var r = nbi();
18315 this.abs().divRemTo(a,null,r);
18316 if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r);
18317 return r;
18318 }
18319
18320 // Modular reduction using "classic" algorithm
18321 function Classic(m) { this.m = m; }
18322 function cConvert(x) {
18323 if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);
18324 else return x;
18325 }
18326 function cRevert(x) { return x; }
18327 function cReduce(x) { x.divRemTo(this.m,null,x); }
18328 function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
18329 function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
18330
18331 Classic.prototype.convert = cConvert;
18332 Classic.prototype.revert = cRevert;
18333 Classic.prototype.reduce = cReduce;
18334 Classic.prototype.mulTo = cMulTo;
18335 Classic.prototype.sqrTo = cSqrTo;
18336
18337 // (protected) return "-1/this % 2^DB"; useful for Mont. reduction
18338 // justification:
18339 // xy == 1 (mod m)
18340 // xy = 1+km
18341 // xy(2-xy) = (1+km)(1-km)
18342 // x[y(2-xy)] = 1-k^2m^2
18343 // x[y(2-xy)] == 1 (mod m^2)
18344 // if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
18345 // should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
18346 // JS multiply "overflows" differently from C/C++, so care is needed here.
18347 function bnpInvDigit() {
18348 if(this.t < 1) return 0;
18349 var x = this[0];
18350 if((x&1) == 0) return 0;
18351 var y = x&3; // y == 1/x mod 2^2
18352 y = (y*(2-(x&0xf)*y))&0xf; // y == 1/x mod 2^4
18353 y = (y*(2-(x&0xff)*y))&0xff; // y == 1/x mod 2^8
18354 y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff; // y == 1/x mod 2^16
18355 // last step - calculate inverse mod DV directly;
18356 // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
18357 y = (y*(2-x*y%this.DV))%this.DV; // y == 1/x mod 2^dbits
18358 // we really want the negative inverse, and -DV < y < DV
18359 return (y>0)?this.DV-y:-y;
18360 }
18361
18362 // Montgomery reduction
18363 function Montgomery(m) {
18364 this.m = m;
18365 this.mp = m.invDigit();
18366 this.mpl = this.mp&0x7fff;
18367 this.mph = this.mp>>15;
18368 this.um = (1<<(m.DB-15))-1;
18369 this.mt2 = 2*m.t;
18370 }
18371
18372 // xR mod m
18373 function montConvert(x) {
18374 var r = nbi();
18375 x.abs().dlShiftTo(this.m.t,r);
18376 r.divRemTo(this.m,null,r);
18377 if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r);
18378 return r;
18379 }
18380
18381 // x/R mod m
18382 function montRevert(x) {
18383 var r = nbi();
18384 x.copyTo(r);
18385 this.reduce(r);
18386 return r;
18387 }
18388
18389 // x = x/R mod m (HAC 14.32)
18390 function montReduce(x) {
18391 while(x.t <= this.mt2) // pad x so am has enough room later
18392 x[x.t++] = 0;
18393 for(var i = 0; i < this.m.t; ++i) {
18394 // faster way of calculating u0 = x[i]*mp mod DV
18395 var j = x[i]&0x7fff;
18396 var u0 = (j*this.mpl+(((j*this.mph+(x[i]>>15)*this.mpl)&this.um)<<15))&x.DM;
18397 // use am to combine the multiply-shift-add into one call
18398 j = i+this.m.t;
18399 x[j] += this.m.am(0,u0,x,i,0,this.m.t);
18400 // propagate carry
18401 while(x[j] >= x.DV) { x[j] -= x.DV; x[++j]++; }
18402 }
18403 x.clamp();
18404 x.drShiftTo(this.m.t,x);
18405 if(x.compareTo(this.m) >= 0) x.subTo(this.m,x);
18406 }
18407
18408 // r = "x^2/R mod m"; x != r
18409 function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
18410
18411 // r = "xy/R mod m"; x,y != r
18412 function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
18413
18414 Montgomery.prototype.convert = montConvert;
18415 Montgomery.prototype.revert = montRevert;
18416 Montgomery.prototype.reduce = montReduce;
18417 Montgomery.prototype.mulTo = montMulTo;
18418 Montgomery.prototype.sqrTo = montSqrTo;
18419
18420 // (protected) true iff this is even
18421 function bnpIsEven() { return ((this.t>0)?(this[0]&1):this.s) == 0; }
18422
18423 // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
18424 function bnpExp(e,z) {
18425 if(e > 0xffffffff || e < 1) return BigInteger.ONE;
18426 var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1;
18427 g.copyTo(r);
18428 while(--i >= 0) {
18429 z.sqrTo(r,r2);
18430 if((e&(1<<i)) > 0) z.mulTo(r2,g,r);
18431 else { var t = r; r = r2; r2 = t; }
18432 }
18433 return z.revert(r);
18434 }
18435
18436 // (public) this^e % m, 0 <= e < 2^32
18437 function bnModPowInt(e,m) {
18438 var z;
18439 if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
18440 return this.exp(e,z);
18441 }
18442
18443 // protected
18444 proto.copyTo = bnpCopyTo;
18445 proto.fromInt = bnpFromInt;
18446 proto.fromString = bnpFromString;
18447 proto.clamp = bnpClamp;
18448 proto.dlShiftTo = bnpDLShiftTo;
18449 proto.drShiftTo = bnpDRShiftTo;
18450 proto.lShiftTo = bnpLShiftTo;
18451 proto.rShiftTo = bnpRShiftTo;
18452 proto.subTo = bnpSubTo;
18453 proto.multiplyTo = bnpMultiplyTo;
18454 proto.squareTo = bnpSquareTo;
18455 proto.divRemTo = bnpDivRemTo;
18456 proto.invDigit = bnpInvDigit;
18457 proto.isEven = bnpIsEven;
18458 proto.exp = bnpExp;
18459
18460 // public
18461 proto.toString = bnToString;
18462 proto.negate = bnNegate;
18463 proto.abs = bnAbs;
18464 proto.compareTo = bnCompareTo;
18465 proto.bitLength = bnBitLength;
18466 proto.mod = bnMod;
18467 proto.modPowInt = bnModPowInt;
18468
18469 //// jsbn2
18470
18471 function nbi() { return new BigInteger(null); }
18472
18473 // (public)
18474 function bnClone() { var r = nbi(); this.copyTo(r); return r; }
18475
18476 // (public) return value as integer
18477 function bnIntValue() {
18478 if(this.s < 0) {
18479 if(this.t == 1) return this[0]-this.DV;
18480 else if(this.t == 0) return -1;
18481 }
18482 else if(this.t == 1) return this[0];
18483 else if(this.t == 0) return 0;
18484 // assumes 16 < DB < 32
18485 return ((this[1]&((1<<(32-this.DB))-1))<<this.DB)|this[0];
18486 }
18487
18488 // (public) return value as byte
18489 function bnByteValue() { return (this.t==0)?this.s:(this[0]<<24)>>24; }
18490
18491 // (public) return value as short (assumes DB>=16)
18492 function bnShortValue() { return (this.t==0)?this.s:(this[0]<<16)>>16; }
18493
18494 // (protected) return x s.t. r^x < DV
18495 function bnpChunkSize(r) { return Math.floor(Math.LN2*this.DB/Math.log(r)); }
18496
18497 // (public) 0 if this == 0, 1 if this > 0
18498 function bnSigNum() {
18499 if(this.s < 0) return -1;
18500 else if(this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0;
18501 else return 1;
18502 }
18503
18504 // (protected) convert to radix string
18505 function bnpToRadix(b) {
18506 if(b == null) b = 10;
18507 if(this.signum() == 0 || b < 2 || b > 36) return "0";
18508 var cs = this.chunkSize(b);
18509 var a = Math.pow(b,cs);
18510 var d = nbv(a), y = nbi(), z = nbi(), r = "";
18511 this.divRemTo(d,y,z);
18512 while(y.signum() > 0) {
18513 r = (a+z.intValue()).toString(b).substr(1) + r;
18514 y.divRemTo(d,y,z);
18515 }
18516 return z.intValue().toString(b) + r;
18517 }
18518
18519 // (protected) convert from radix string
18520 function bnpFromRadix(s,b) {
18521 var self = this;
18522 self.fromInt(0);
18523 if(b == null) b = 10;
18524 var cs = self.chunkSize(b);
18525 var d = Math.pow(b,cs), mi = false, j = 0, w = 0;
18526 for(var i = 0; i < s.length; ++i) {
18527 var x = intAt(s,i);
18528 if(x < 0) {
18529 if(s.charAt(i) == "-" && self.signum() == 0) mi = true;
18530 continue;
18531 }
18532 w = b*w+x;
18533 if(++j >= cs) {
18534 self.dMultiply(d);
18535 self.dAddOffset(w,0);
18536 j = 0;
18537 w = 0;
18538 }
18539 }
18540 if(j > 0) {
18541 self.dMultiply(Math.pow(b,j));
18542 self.dAddOffset(w,0);
18543 }
18544 if(mi) BigInteger.ZERO.subTo(self,self);
18545 }
18546
18547 // (protected) alternate constructor
18548 function bnpFromNumber(a,b,c) {
18549 var self = this;
18550 if("number" == typeof b) {
18551 // new BigInteger(int,int,RNG)
18552 if(a < 2) self.fromInt(1);
18553 else {
18554 self.fromNumber(a,c);
18555 if(!self.testBit(a-1)) // force MSB set
18556 self.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,self);
18557 if(self.isEven()) self.dAddOffset(1,0); // force odd
18558 while(!self.isProbablePrime(b)) {
18559 self.dAddOffset(2,0);
18560 if(self.bitLength() > a) self.subTo(BigInteger.ONE.shiftLeft(a-1),self);
18561 }
18562 }
18563 }
18564 else {
18565 // new BigInteger(int,RNG)
18566 var x = new Array(), t = a&7;
18567 x.length = (a>>3)+1;
18568 b.nextBytes(x);
18569 if(t > 0) x[0] &= ((1<<t)-1); else x[0] = 0;
18570 self.fromString(x,256);
18571 }
18572 }
18573
18574 // (public) convert to bigendian byte array
18575 function bnToByteArray() {
18576 var self = this;
18577 var i = self.t, r = new Array();
18578 r[0] = self.s;
18579 var p = self.DB-(i*self.DB)%8, d, k = 0;
18580 if(i-- > 0) {
18581 if(p < self.DB && (d = self[i]>>p) != (self.s&self.DM)>>p)
18582 r[k++] = d|(self.s<<(self.DB-p));
18583 while(i >= 0) {
18584 if(p < 8) {
18585 d = (self[i]&((1<<p)-1))<<(8-p);
18586 d |= self[--i]>>(p+=self.DB-8);
18587 }
18588 else {
18589 d = (self[i]>>(p-=8))&0xff;
18590 if(p <= 0) { p += self.DB; --i; }
18591 }
18592 if((d&0x80) != 0) d |= -256;
18593 if(k === 0 && (self.s&0x80) != (d&0x80)) ++k;
18594 if(k > 0 || d != self.s) r[k++] = d;
18595 }
18596 }
18597 return r;
18598 }
18599
18600 function bnEquals(a) { return(this.compareTo(a)==0); }
18601 function bnMin(a) { return(this.compareTo(a)<0)?this:a; }
18602 function bnMax(a) { return(this.compareTo(a)>0)?this:a; }
18603
18604 // (protected) r = this op a (bitwise)
18605 function bnpBitwiseTo(a,op,r) {
18606 var self = this;
18607 var i, f, m = Math.min(a.t,self.t);
18608 for(i = 0; i < m; ++i) r[i] = op(self[i],a[i]);
18609 if(a.t < self.t) {
18610 f = a.s&self.DM;
18611 for(i = m; i < self.t; ++i) r[i] = op(self[i],f);
18612 r.t = self.t;
18613 }
18614 else {
18615 f = self.s&self.DM;
18616 for(i = m; i < a.t; ++i) r[i] = op(f,a[i]);
18617 r.t = a.t;
18618 }
18619 r.s = op(self.s,a.s);
18620 r.clamp();
18621 }
18622
18623 // (public) this & a
18624 function op_and(x,y) { return x&y; }
18625 function bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; }
18626
18627 // (public) this | a
18628 function op_or(x,y) { return x|y; }
18629 function bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; }
18630
18631 // (public) this ^ a
18632 function op_xor(x,y) { return x^y; }
18633 function bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; }
18634
18635 // (public) this & ~a
18636 function op_andnot(x,y) { return x&~y; }
18637 function bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; }
18638
18639 // (public) ~this
18640 function bnNot() {
18641 var r = nbi();
18642 for(var i = 0; i < this.t; ++i) r[i] = this.DM&~this[i];
18643 r.t = this.t;
18644 r.s = ~this.s;
18645 return r;
18646 }
18647
18648 // (public) this << n
18649 function bnShiftLeft(n) {
18650 var r = nbi();
18651 if(n < 0) this.rShiftTo(-n,r); else this.lShiftTo(n,r);
18652 return r;
18653 }
18654
18655 // (public) this >> n
18656 function bnShiftRight(n) {
18657 var r = nbi();
18658 if(n < 0) this.lShiftTo(-n,r); else this.rShiftTo(n,r);
18659 return r;
18660 }
18661
18662 // return index of lowest 1-bit in x, x < 2^31
18663 function lbit(x) {
18664 if(x == 0) return -1;
18665 var r = 0;
18666 if((x&0xffff) == 0) { x >>= 16; r += 16; }
18667 if((x&0xff) == 0) { x >>= 8; r += 8; }
18668 if((x&0xf) == 0) { x >>= 4; r += 4; }
18669 if((x&3) == 0) { x >>= 2; r += 2; }
18670 if((x&1) == 0) ++r;
18671 return r;
18672 }
18673
18674 // (public) returns index of lowest 1-bit (or -1 if none)
18675 function bnGetLowestSetBit() {
18676 for(var i = 0; i < this.t; ++i)
18677 if(this[i] != 0) return i*this.DB+lbit(this[i]);
18678 if(this.s < 0) return this.t*this.DB;
18679 return -1;
18680 }
18681
18682 // return number of 1 bits in x
18683 function cbit(x) {
18684 var r = 0;
18685 while(x != 0) { x &= x-1; ++r; }
18686 return r;
18687 }
18688
18689 // (public) return number of set bits
18690 function bnBitCount() {
18691 var r = 0, x = this.s&this.DM;
18692 for(var i = 0; i < this.t; ++i) r += cbit(this[i]^x);
18693 return r;
18694 }
18695
18696 // (public) true iff nth bit is set
18697 function bnTestBit(n) {
18698 var j = Math.floor(n/this.DB);
18699 if(j >= this.t) return(this.s!=0);
18700 return((this[j]&(1<<(n%this.DB)))!=0);
18701 }
18702
18703 // (protected) this op (1<<n)
18704 function bnpChangeBit(n,op) {
18705 var r = BigInteger.ONE.shiftLeft(n);
18706 this.bitwiseTo(r,op,r);
18707 return r;
18708 }
18709
18710 // (public) this | (1<<n)
18711 function bnSetBit(n) { return this.changeBit(n,op_or); }
18712
18713 // (public) this & ~(1<<n)
18714 function bnClearBit(n) { return this.changeBit(n,op_andnot); }
18715
18716 // (public) this ^ (1<<n)
18717 function bnFlipBit(n) { return this.changeBit(n,op_xor); }
18718
18719 // (protected) r = this + a
18720 function bnpAddTo(a,r) {
18721 var self = this;
18722
18723 var i = 0, c = 0, m = Math.min(a.t,self.t);
18724 while(i < m) {
18725 c += self[i]+a[i];
18726 r[i++] = c&self.DM;
18727 c >>= self.DB;
18728 }
18729 if(a.t < self.t) {
18730 c += a.s;
18731 while(i < self.t) {
18732 c += self[i];
18733 r[i++] = c&self.DM;
18734 c >>= self.DB;
18735 }
18736 c += self.s;
18737 }
18738 else {
18739 c += self.s;
18740 while(i < a.t) {
18741 c += a[i];
18742 r[i++] = c&self.DM;
18743 c >>= self.DB;
18744 }
18745 c += a.s;
18746 }
18747 r.s = (c<0)?-1:0;
18748 if(c > 0) r[i++] = c;
18749 else if(c < -1) r[i++] = self.DV+c;
18750 r.t = i;
18751 r.clamp();
18752 }
18753
18754 // (public) this + a
18755 function bnAdd(a) { var r = nbi(); this.addTo(a,r); return r; }
18756
18757 // (public) this - a
18758 function bnSubtract(a) { var r = nbi(); this.subTo(a,r); return r; }
18759
18760 // (public) this * a
18761 function bnMultiply(a) { var r = nbi(); this.multiplyTo(a,r); return r; }
18762
18763 // (public) this^2
18764 function bnSquare() { var r = nbi(); this.squareTo(r); return r; }
18765
18766 // (public) this / a
18767 function bnDivide(a) { var r = nbi(); this.divRemTo(a,r,null); return r; }
18768
18769 // (public) this % a
18770 function bnRemainder(a) { var r = nbi(); this.divRemTo(a,null,r); return r; }
18771
18772 // (public) [this/a,this%a]
18773 function bnDivideAndRemainder(a) {
18774 var q = nbi(), r = nbi();
18775 this.divRemTo(a,q,r);
18776 return new Array(q,r);
18777 }
18778
18779 // (protected) this *= n, this >= 0, 1 < n < DV
18780 function bnpDMultiply(n) {
18781 this[this.t] = this.am(0,n-1,this,0,0,this.t);
18782 ++this.t;
18783 this.clamp();
18784 }
18785
18786 // (protected) this += n << w words, this >= 0
18787 function bnpDAddOffset(n,w) {
18788 if(n == 0) return;
18789 while(this.t <= w) this[this.t++] = 0;
18790 this[w] += n;
18791 while(this[w] >= this.DV) {
18792 this[w] -= this.DV;
18793 if(++w >= this.t) this[this.t++] = 0;
18794 ++this[w];
18795 }
18796 }
18797
18798 // A "null" reducer
18799 function NullExp() {}
18800 function nNop(x) { return x; }
18801 function nMulTo(x,y,r) { x.multiplyTo(y,r); }
18802 function nSqrTo(x,r) { x.squareTo(r); }
18803
18804 NullExp.prototype.convert = nNop;
18805 NullExp.prototype.revert = nNop;
18806 NullExp.prototype.mulTo = nMulTo;
18807 NullExp.prototype.sqrTo = nSqrTo;
18808
18809 // (public) this^e
18810 function bnPow(e) { return this.exp(e,new NullExp()); }
18811
18812 // (protected) r = lower n words of "this * a", a.t <= n
18813 // "this" should be the larger one if appropriate.
18814 function bnpMultiplyLowerTo(a,n,r) {
18815 var i = Math.min(this.t+a.t,n);
18816 r.s = 0; // assumes a,this >= 0
18817 r.t = i;
18818 while(i > 0) r[--i] = 0;
18819 var j;
18820 for(j = r.t-this.t; i < j; ++i) r[i+this.t] = this.am(0,a[i],r,i,0,this.t);
18821 for(j = Math.min(a.t,n); i < j; ++i) this.am(0,a[i],r,i,0,n-i);
18822 r.clamp();
18823 }
18824
18825 // (protected) r = "this * a" without lower n words, n > 0
18826 // "this" should be the larger one if appropriate.
18827 function bnpMultiplyUpperTo(a,n,r) {
18828 --n;
18829 var i = r.t = this.t+a.t-n;
18830 r.s = 0; // assumes a,this >= 0
18831 while(--i >= 0) r[i] = 0;
18832 for(i = Math.max(n-this.t,0); i < a.t; ++i)
18833 r[this.t+i-n] = this.am(n-i,a[i],r,0,0,this.t+i-n);
18834 r.clamp();
18835 r.drShiftTo(1,r);
18836 }
18837
18838 // Barrett modular reduction
18839 function Barrett(m) {
18840 // setup Barrett
18841 this.r2 = nbi();
18842 this.q3 = nbi();
18843 BigInteger.ONE.dlShiftTo(2*m.t,this.r2);
18844 this.mu = this.r2.divide(m);
18845 this.m = m;
18846 }
18847
18848 function barrettConvert(x) {
18849 if(x.s < 0 || x.t > 2*this.m.t) return x.mod(this.m);
18850 else if(x.compareTo(this.m) < 0) return x;
18851 else { var r = nbi(); x.copyTo(r); this.reduce(r); return r; }
18852 }
18853
18854 function barrettRevert(x) { return x; }
18855
18856 // x = x mod m (HAC 14.42)
18857 function barrettReduce(x) {
18858 var self = this;
18859 x.drShiftTo(self.m.t-1,self.r2);
18860 if(x.t > self.m.t+1) { x.t = self.m.t+1; x.clamp(); }
18861 self.mu.multiplyUpperTo(self.r2,self.m.t+1,self.q3);
18862 self.m.multiplyLowerTo(self.q3,self.m.t+1,self.r2);
18863 while(x.compareTo(self.r2) < 0) x.dAddOffset(1,self.m.t+1);
18864 x.subTo(self.r2,x);
18865 while(x.compareTo(self.m) >= 0) x.subTo(self.m,x);
18866 }
18867
18868 // r = x^2 mod m; x != r
18869 function barrettSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
18870
18871 // r = x*y mod m; x,y != r
18872 function barrettMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
18873
18874 Barrett.prototype.convert = barrettConvert;
18875 Barrett.prototype.revert = barrettRevert;
18876 Barrett.prototype.reduce = barrettReduce;
18877 Barrett.prototype.mulTo = barrettMulTo;
18878 Barrett.prototype.sqrTo = barrettSqrTo;
18879
18880 // (public) this^e % m (HAC 14.85)
18881 function bnModPow(e,m) {
18882 var i = e.bitLength(), k, r = nbv(1), z;
18883 if(i <= 0) return r;
18884 else if(i < 18) k = 1;
18885 else if(i < 48) k = 3;
18886 else if(i < 144) k = 4;
18887 else if(i < 768) k = 5;
18888 else k = 6;
18889 if(i < 8)
18890 z = new Classic(m);
18891 else if(m.isEven())
18892 z = new Barrett(m);
18893 else
18894 z = new Montgomery(m);
18895
18896 // precomputation
18897 var g = new Array(), n = 3, k1 = k-1, km = (1<<k)-1;
18898 g[1] = z.convert(this);
18899 if(k > 1) {
18900 var g2 = nbi();
18901 z.sqrTo(g[1],g2);
18902 while(n <= km) {
18903 g[n] = nbi();
18904 z.mulTo(g2,g[n-2],g[n]);
18905 n += 2;
18906 }
18907 }
18908
18909 var j = e.t-1, w, is1 = true, r2 = nbi(), t;
18910 i = nbits(e[j])-1;
18911 while(j >= 0) {
18912 if(i >= k1) w = (e[j]>>(i-k1))&km;
18913 else {
18914 w = (e[j]&((1<<(i+1))-1))<<(k1-i);
18915 if(j > 0) w |= e[j-1]>>(this.DB+i-k1);
18916 }
18917
18918 n = k;
18919 while((w&1) == 0) { w >>= 1; --n; }
18920 if((i -= n) < 0) { i += this.DB; --j; }
18921 if(is1) { // ret == 1, don't bother squaring or multiplying it
18922 g[w].copyTo(r);
18923 is1 = false;
18924 }
18925 else {
18926 while(n > 1) { z.sqrTo(r,r2); z.sqrTo(r2,r); n -= 2; }
18927 if(n > 0) z.sqrTo(r,r2); else { t = r; r = r2; r2 = t; }
18928 z.mulTo(r2,g[w],r);
18929 }
18930
18931 while(j >= 0 && (e[j]&(1<<i)) == 0) {
18932 z.sqrTo(r,r2); t = r; r = r2; r2 = t;
18933 if(--i < 0) { i = this.DB-1; --j; }
18934 }
18935 }
18936 return z.revert(r);
18937 }
18938
18939 // (public) gcd(this,a) (HAC 14.54)
18940 function bnGCD(a) {
18941 var x = (this.s<0)?this.negate():this.clone();
18942 var y = (a.s<0)?a.negate():a.clone();
18943 if(x.compareTo(y) < 0) { var t = x; x = y; y = t; }
18944 var i = x.getLowestSetBit(), g = y.getLowestSetBit();
18945 if(g < 0) return x;
18946 if(i < g) g = i;
18947 if(g > 0) {
18948 x.rShiftTo(g,x);
18949 y.rShiftTo(g,y);
18950 }
18951 while(x.signum() > 0) {
18952 if((i = x.getLowestSetBit()) > 0) x.rShiftTo(i,x);
18953 if((i = y.getLowestSetBit()) > 0) y.rShiftTo(i,y);
18954 if(x.compareTo(y) >= 0) {
18955 x.subTo(y,x);
18956 x.rShiftTo(1,x);
18957 }
18958 else {
18959 y.subTo(x,y);
18960 y.rShiftTo(1,y);
18961 }
18962 }
18963 if(g > 0) y.lShiftTo(g,y);
18964 return y;
18965 }
18966
18967 // (protected) this % n, n < 2^26
18968 function bnpModInt(n) {
18969 if(n <= 0) return 0;
18970 var d = this.DV%n, r = (this.s<0)?n-1:0;
18971 if(this.t > 0)
18972 if(d == 0) r = this[0]%n;
18973 else for(var i = this.t-1; i >= 0; --i) r = (d*r+this[i])%n;
18974 return r;
18975 }
18976
18977 // (public) 1/this % m (HAC 14.61)
18978 function bnModInverse(m) {
18979 var ac = m.isEven();
18980 if((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO;
18981 var u = m.clone(), v = this.clone();
18982 var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1);
18983 while(u.signum() != 0) {
18984 while(u.isEven()) {
18985 u.rShiftTo(1,u);
18986 if(ac) {
18987 if(!a.isEven() || !b.isEven()) { a.addTo(this,a); b.subTo(m,b); }
18988 a.rShiftTo(1,a);
18989 }
18990 else if(!b.isEven()) b.subTo(m,b);
18991 b.rShiftTo(1,b);
18992 }
18993 while(v.isEven()) {
18994 v.rShiftTo(1,v);
18995 if(ac) {
18996 if(!c.isEven() || !d.isEven()) { c.addTo(this,c); d.subTo(m,d); }
18997 c.rShiftTo(1,c);
18998 }
18999 else if(!d.isEven()) d.subTo(m,d);
19000 d.rShiftTo(1,d);
19001 }
19002 if(u.compareTo(v) >= 0) {
19003 u.subTo(v,u);
19004 if(ac) a.subTo(c,a);
19005 b.subTo(d,b);
19006 }
19007 else {
19008 v.subTo(u,v);
19009 if(ac) c.subTo(a,c);
19010 d.subTo(b,d);
19011 }
19012 }
19013 if(v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;
19014 if(d.compareTo(m) >= 0) return d.subtract(m);
19015 if(d.signum() < 0) d.addTo(m,d); else return d;
19016 if(d.signum() < 0) return d.add(m); else return d;
19017 }
19018
19019 // protected
19020 proto.chunkSize = bnpChunkSize;
19021 proto.toRadix = bnpToRadix;
19022 proto.fromRadix = bnpFromRadix;
19023 proto.fromNumber = bnpFromNumber;
19024 proto.bitwiseTo = bnpBitwiseTo;
19025 proto.changeBit = bnpChangeBit;
19026 proto.addTo = bnpAddTo;
19027 proto.dMultiply = bnpDMultiply;
19028 proto.dAddOffset = bnpDAddOffset;
19029 proto.multiplyLowerTo = bnpMultiplyLowerTo;
19030 proto.multiplyUpperTo = bnpMultiplyUpperTo;
19031 proto.modInt = bnpModInt;
19032
19033 // public
19034 proto.clone = bnClone;
19035 proto.intValue = bnIntValue;
19036 proto.byteValue = bnByteValue;
19037 proto.shortValue = bnShortValue;
19038 proto.signum = bnSigNum;
19039 proto.toByteArray = bnToByteArray;
19040 proto.equals = bnEquals;
19041 proto.min = bnMin;
19042 proto.max = bnMax;
19043 proto.and = bnAnd;
19044 proto.or = bnOr;
19045 proto.xor = bnXor;
19046 proto.andNot = bnAndNot;
19047 proto.not = bnNot;
19048 proto.shiftLeft = bnShiftLeft;
19049 proto.shiftRight = bnShiftRight;
19050 proto.getLowestSetBit = bnGetLowestSetBit;
19051 proto.bitCount = bnBitCount;
19052 proto.testBit = bnTestBit;
19053 proto.setBit = bnSetBit;
19054 proto.clearBit = bnClearBit;
19055 proto.flipBit = bnFlipBit;
19056 proto.add = bnAdd;
19057 proto.subtract = bnSubtract;
19058 proto.multiply = bnMultiply;
19059 proto.divide = bnDivide;
19060 proto.remainder = bnRemainder;
19061 proto.divideAndRemainder = bnDivideAndRemainder;
19062 proto.modPow = bnModPow;
19063 proto.modInverse = bnModInverse;
19064 proto.pow = bnPow;
19065 proto.gcd = bnGCD;
19066
19067 // JSBN-specific extension
19068 proto.square = bnSquare;
19069
19070 // BigInteger interfaces not implemented in jsbn:
19071
19072 // BigInteger(int signum, byte[] magnitude)
19073 // double doubleValue()
19074 // float floatValue()
19075 // int hashCode()
19076 // long longValue()
19077 // static BigInteger valueOf(long val)
19078
19079 // "constants"
19080 BigInteger.ZERO = nbv(0);
19081 BigInteger.ONE = nbv(1);
19082 BigInteger.valueOf = nbv;
19083
19084 },{"assert":4}],2:[function(_dereq_,module,exports){
19085 (function (Buffer){
19086 // FIXME: Kind of a weird way to throw exceptions, consider removing
19087 var assert = _dereq_('assert')
19088 var BigInteger = _dereq_('./bigi')
19089
19090 /**
19091 * Turns a byte array into a big integer.
19092 *
19093 * This function will interpret a byte array as a big integer in big
19094 * endian notation.
19095 */
19096 BigInteger.fromByteArrayUnsigned = function(byteArray) {
19097 // BigInteger expects a DER integer conformant byte array
19098 if (byteArray[0] & 0x80) {
19099 return new BigInteger([0].concat(byteArray))
19100 }
19101
19102 return new BigInteger(byteArray)
19103 }
19104
19105 /**
19106 * Returns a byte array representation of the big integer.
19107 *
19108 * This returns the absolute of the contained value in big endian
19109 * form. A value of zero results in an empty array.
19110 */
19111 BigInteger.prototype.toByteArrayUnsigned = function() {
19112 var byteArray = this.toByteArray()
19113 return byteArray[0] === 0 ? byteArray.slice(1) : byteArray
19114 }
19115
19116 BigInteger.fromDERInteger = function(byteArray) {
19117 return new BigInteger(byteArray)
19118 }
19119
19120 /*
19121 * Converts BigInteger to a DER integer representation.
19122 *
19123 * The format for this value uses the most significant bit as a sign
19124 * bit. If the most significant bit is already set and the integer is
19125 * positive, a 0x00 is prepended.
19126 *
19127 * Examples:
19128 *
19129 * 0 => 0x00
19130 * 1 => 0x01
19131 * -1 => 0x81
19132 * 127 => 0x7f
19133 * -127 => 0xff
19134 * 128 => 0x0080
19135 * -128 => 0x80
19136 * 255 => 0x00ff
19137 * -255 => 0xff
19138 * 16300 => 0x3fac
19139 * -16300 => 0xbfac
19140 * 62300 => 0x00f35c
19141 * -62300 => 0xf35c
19142 */
19143 BigInteger.prototype.toDERInteger = BigInteger.prototype.toByteArray
19144
19145 BigInteger.fromBuffer = function(buffer) {
19146 // BigInteger expects a DER integer conformant byte array
19147 if (buffer[0] & 0x80) {
19148 var byteArray = Array.prototype.slice.call(buffer)
19149
19150 return new BigInteger([0].concat(byteArray))
19151 }
19152
19153 return new BigInteger(buffer)
19154 }
19155
19156 BigInteger.fromHex = function(hex) {
19157 if (hex === '') return BigInteger.ZERO
19158
19159 assert.equal(hex, hex.match(/^[A-Fa-f0-9]+/), 'Invalid hex string')
19160 assert.equal(hex.length % 2, 0, 'Incomplete hex')
19161 return new BigInteger(hex, 16)
19162 }
19163
19164 BigInteger.prototype.toBuffer = function(size) {
19165 var byteArray = this.toByteArrayUnsigned()
19166 var zeros = []
19167
19168 var padding = size - byteArray.length
19169 while (zeros.length < padding) zeros.push(0)
19170
19171 return new Buffer(zeros.concat(byteArray))
19172 }
19173
19174 BigInteger.prototype.toHex = function(size) {
19175 return this.toBuffer(size).toString('hex')
19176 }
19177
19178 }).call(this,_dereq_("buffer").Buffer)
19179 },{"./bigi":1,"assert":4,"buffer":8}],3:[function(_dereq_,module,exports){
19180 var BigInteger = _dereq_('./bigi')
19181
19182 //addons
19183 _dereq_('./convert')
19184
19185 module.exports = BigInteger
19186 },{"./bigi":1,"./convert":2}],4:[function(_dereq_,module,exports){
19187 // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
19188 //
19189 // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
19190 //
19191 // Originally from narwhal.js (http://narwhaljs.org)
19192 // Copyright (c) 2009 Thomas Robinson <280north.com>
19193 //
19194 // Permission is hereby granted, free of charge, to any person obtaining a copy
19195 // of this software and associated documentation files (the 'Software'), to
19196 // deal in the Software without restriction, including without limitation the
19197 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
19198 // sell copies of the Software, and to permit persons to whom the Software is
19199 // furnished to do so, subject to the following conditions:
19200 //
19201 // The above copyright notice and this permission notice shall be included in
19202 // all copies or substantial portions of the Software.
19203 //
19204 // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19205 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19206 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19207 // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19208 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19209 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19210
19211 // when used in node, this will actually load the util module we depend on
19212 // versus loading the builtin util module as happens otherwise
19213 // this is a bug in node module loading as far as I am concerned
19214 var util = _dereq_('util/');
19215
19216 var pSlice = Array.prototype.slice;
19217 var hasOwn = Object.prototype.hasOwnProperty;
19218
19219 // 1. The assert module provides functions that throw
19220 // AssertionError's when particular conditions are not met. The
19221 // assert module must conform to the following interface.
19222
19223 var assert = module.exports = ok;
19224
19225 // 2. The AssertionError is defined in assert.
19226 // new assert.AssertionError({ message: message,
19227 // actual: actual,
19228 // expected: expected })
19229
19230 assert.AssertionError = function AssertionError(options) {
19231 this.name = 'AssertionError';
19232 this.actual = options.actual;
19233 this.expected = options.expected;
19234 this.operator = options.operator;
19235 if (options.message) {
19236 this.message = options.message;
19237 this.generatedMessage = false;
19238 } else {
19239 this.message = getMessage(this);
19240 this.generatedMessage = true;
19241 }
19242 var stackStartFunction = options.stackStartFunction || fail;
19243
19244 if (Error.captureStackTrace) {
19245 Error.captureStackTrace(this, stackStartFunction);
19246 }
19247 else {
19248 // non v8 browsers so we can have a stacktrace
19249 var err = new Error();
19250 if (err.stack) {
19251 var out = err.stack;
19252
19253 // try to strip useless frames
19254 var fn_name = stackStartFunction.name;
19255 var idx = out.indexOf('\n' + fn_name);
19256 if (idx >= 0) {
19257 // once we have located the function frame
19258 // we need to strip out everything before it (and its line)
19259 var next_line = out.indexOf('\n', idx + 1);
19260 out = out.substring(next_line + 1);
19261 }
19262
19263 this.stack = out;
19264 }
19265 }
19266 };
19267
19268 // assert.AssertionError instanceof Error
19269 util.inherits(assert.AssertionError, Error);
19270
19271 function replacer(key, value) {
19272 if (util.isUndefined(value)) {
19273 return '' + value;
19274 }
19275 if (util.isNumber(value) && (isNaN(value) || !isFinite(value))) {
19276 return value.toString();
19277 }
19278 if (util.isFunction(value) || util.isRegExp(value)) {
19279 return value.toString();
19280 }
19281 return value;
19282 }
19283
19284 function truncate(s, n) {
19285 if (util.isString(s)) {
19286 return s.length < n ? s : s.slice(0, n);
19287 } else {
19288 return s;
19289 }
19290 }
19291
19292 function getMessage(self) {
19293 return truncate(JSON.stringify(self.actual, replacer), 128) + ' ' +
19294 self.operator + ' ' +
19295 truncate(JSON.stringify(self.expected, replacer), 128);
19296 }
19297
19298 // At present only the three keys mentioned above are used and
19299 // understood by the spec. Implementations or sub modules can pass
19300 // other keys to the AssertionError's constructor - they will be
19301 // ignored.
19302
19303 // 3. All of the following functions must throw an AssertionError
19304 // when a corresponding condition is not met, with a message that
19305 // may be undefined if not provided. All assertion methods provide
19306 // both the actual and expected values to the assertion error for
19307 // display purposes.
19308
19309 function fail(actual, expected, message, operator, stackStartFunction) {
19310 throw new assert.AssertionError({
19311 message: message,
19312 actual: actual,
19313 expected: expected,
19314 operator: operator,
19315 stackStartFunction: stackStartFunction
19316 });
19317 }
19318
19319 // EXTENSION! allows for well behaved errors defined elsewhere.
19320 assert.fail = fail;
19321
19322 // 4. Pure assertion tests whether a value is truthy, as determined
19323 // by !!guard.
19324 // assert.ok(guard, message_opt);
19325 // This statement is equivalent to assert.equal(true, !!guard,
19326 // message_opt);. To test strictly for the value true, use
19327 // assert.strictEqual(true, guard, message_opt);.
19328
19329 function ok(value, message) {
19330 if (!value) fail(value, true, message, '==', assert.ok);
19331 }
19332 assert.ok = ok;
19333
19334 // 5. The equality assertion tests shallow, coercive equality with
19335 // ==.
19336 // assert.equal(actual, expected, message_opt);
19337
19338 assert.equal = function equal(actual, expected, message) {
19339 if (actual != expected) fail(actual, expected, message, '==', assert.equal);
19340 };
19341
19342 // 6. The non-equality assertion tests for whether two objects are not equal
19343 // with != assert.notEqual(actual, expected, message_opt);
19344
19345 assert.notEqual = function notEqual(actual, expected, message) {
19346 if (actual == expected) {
19347 fail(actual, expected, message, '!=', assert.notEqual);
19348 }
19349 };
19350
19351 // 7. The equivalence assertion tests a deep equality relation.
19352 // assert.deepEqual(actual, expected, message_opt);
19353
19354 assert.deepEqual = function deepEqual(actual, expected, message) {
19355 if (!_deepEqual(actual, expected)) {
19356 fail(actual, expected, message, 'deepEqual', assert.deepEqual);
19357 }
19358 };
19359
19360 function _deepEqual(actual, expected) {
19361 // 7.1. All identical values are equivalent, as determined by ===.
19362 if (actual === expected) {
19363 return true;
19364
19365 } else if (util.isBuffer(actual) && util.isBuffer(expected)) {
19366 if (actual.length != expected.length) return false;
19367
19368 for (var i = 0; i < actual.length; i++) {
19369 if (actual[i] !== expected[i]) return false;
19370 }
19371
19372 return true;
19373
19374 // 7.2. If the expected value is a Date object, the actual value is
19375 // equivalent if it is also a Date object that refers to the same time.
19376 } else if (util.isDate(actual) && util.isDate(expected)) {
19377 return actual.getTime() === expected.getTime();
19378
19379 // 7.3 If the expected value is a RegExp object, the actual value is
19380 // equivalent if it is also a RegExp object with the same source and
19381 // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
19382 } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
19383 return actual.source === expected.source &&
19384 actual.global === expected.global &&
19385 actual.multiline === expected.multiline &&
19386 actual.lastIndex === expected.lastIndex &&
19387 actual.ignoreCase === expected.ignoreCase;
19388
19389 // 7.4. Other pairs that do not both pass typeof value == 'object',
19390 // equivalence is determined by ==.
19391 } else if (!util.isObject(actual) && !util.isObject(expected)) {
19392 return actual == expected;
19393
19394 // 7.5 For all other Object pairs, including Array objects, equivalence is
19395 // determined by having the same number of owned properties (as verified
19396 // with Object.prototype.hasOwnProperty.call), the same set of keys
19397 // (although not necessarily the same order), equivalent values for every
19398 // corresponding key, and an identical 'prototype' property. Note: this
19399 // accounts for both named and indexed properties on Arrays.
19400 } else {
19401 return objEquiv(actual, expected);
19402 }
19403 }
19404
19405 function isArguments(object) {
19406 return Object.prototype.toString.call(object) == '[object Arguments]';
19407 }
19408
19409 function objEquiv(a, b) {
19410 if (util.isNullOrUndefined(a) || util.isNullOrUndefined(b))
19411 return false;
19412 // an identical 'prototype' property.
19413 if (a.prototype !== b.prototype) return false;
19414 //~~~I've managed to break Object.keys through screwy arguments passing.
19415 // Converting to array solves the problem.
19416 if (isArguments(a)) {
19417 if (!isArguments(b)) {
19418 return false;
19419 }
19420 a = pSlice.call(a);
19421 b = pSlice.call(b);
19422 return _deepEqual(a, b);
19423 }
19424 try {
19425 var ka = objectKeys(a),
19426 kb = objectKeys(b),
19427 key, i;
19428 } catch (e) {//happens when one is a string literal and the other isn't
19429 return false;
19430 }
19431 // having the same number of owned properties (keys incorporates
19432 // hasOwnProperty)
19433 if (ka.length != kb.length)
19434 return false;
19435 //the same set of keys (although not necessarily the same order),
19436 ka.sort();
19437 kb.sort();
19438 //~~~cheap key test
19439 for (i = ka.length - 1; i >= 0; i--) {
19440 if (ka[i] != kb[i])
19441 return false;
19442 }
19443 //equivalent values for every corresponding key, and
19444 //~~~possibly expensive deep test
19445 for (i = ka.length - 1; i >= 0; i--) {
19446 key = ka[i];
19447 if (!_deepEqual(a[key], b[key])) return false;
19448 }
19449 return true;
19450 }
19451
19452 // 8. The non-equivalence assertion tests for any deep inequality.
19453 // assert.notDeepEqual(actual, expected, message_opt);
19454
19455 assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
19456 if (_deepEqual(actual, expected)) {
19457 fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
19458 }
19459 };
19460
19461 // 9. The strict equality assertion tests strict equality, as determined by ===.
19462 // assert.strictEqual(actual, expected, message_opt);
19463
19464 assert.strictEqual = function strictEqual(actual, expected, message) {
19465 if (actual !== expected) {
19466 fail(actual, expected, message, '===', assert.strictEqual);
19467 }
19468 };
19469
19470 // 10. The strict non-equality assertion tests for strict inequality, as
19471 // determined by !==. assert.notStrictEqual(actual, expected, message_opt);
19472
19473 assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
19474 if (actual === expected) {
19475 fail(actual, expected, message, '!==', assert.notStrictEqual);
19476 }
19477 };
19478
19479 function expectedException(actual, expected) {
19480 if (!actual || !expected) {
19481 return false;
19482 }
19483
19484 if (Object.prototype.toString.call(expected) == '[object RegExp]') {
19485 return expected.test(actual);
19486 } else if (actual instanceof expected) {
19487 return true;
19488 } else if (expected.call({}, actual) === true) {
19489 return true;
19490 }
19491
19492 return false;
19493 }
19494
19495 function _throws(shouldThrow, block, expected, message) {
19496 var actual;
19497
19498 if (util.isString(expected)) {
19499 message = expected;
19500 expected = null;
19501 }
19502
19503 try {
19504 block();
19505 } catch (e) {
19506 actual = e;
19507 }
19508
19509 message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
19510 (message ? ' ' + message : '.');
19511
19512 if (shouldThrow && !actual) {
19513 fail(actual, expected, 'Missing expected exception' + message);
19514 }
19515
19516 if (!shouldThrow && expectedException(actual, expected)) {
19517 fail(actual, expected, 'Got unwanted exception' + message);
19518 }
19519
19520 if ((shouldThrow && actual && expected &&
19521 !expectedException(actual, expected)) || (!shouldThrow && actual)) {
19522 throw actual;
19523 }
19524 }
19525
19526 // 11. Expected to throw an error:
19527 // assert.throws(block, Error_opt, message_opt);
19528
19529 assert.throws = function(block, /*optional*/error, /*optional*/message) {
19530 _throws.apply(this, [true].concat(pSlice.call(arguments)));
19531 };
19532
19533 // EXTENSION! This is annoying to write outside this module.
19534 assert.doesNotThrow = function(block, /*optional*/message) {
19535 _throws.apply(this, [false].concat(pSlice.call(arguments)));
19536 };
19537
19538 assert.ifError = function(err) { if (err) {throw err;}};
19539
19540 var objectKeys = Object.keys || function (obj) {
19541 var keys = [];
19542 for (var key in obj) {
19543 if (hasOwn.call(obj, key)) keys.push(key);
19544 }
19545 return keys;
19546 };
19547
19548 },{"util/":6}],5:[function(_dereq_,module,exports){
19549 module.exports = function isBuffer(arg) {
19550 return arg && typeof arg === 'object'
19551 && typeof arg.copy === 'function'
19552 && typeof arg.fill === 'function'
19553 && typeof arg.readUInt8 === 'function';
19554 }
19555 },{}],6:[function(_dereq_,module,exports){
19556 (function (process,global){
19557 // Copyright Joyent, Inc. and other Node contributors.
19558 //
19559 // Permission is hereby granted, free of charge, to any person obtaining a
19560 // copy of this software and associated documentation files (the
19561 // "Software"), to deal in the Software without restriction, including
19562 // without limitation the rights to use, copy, modify, merge, publish,
19563 // distribute, sublicense, and/or sell copies of the Software, and to permit
19564 // persons to whom the Software is furnished to do so, subject to the
19565 // following conditions:
19566 //
19567 // The above copyright notice and this permission notice shall be included
19568 // in all copies or substantial portions of the Software.
19569 //
19570 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19571 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19572 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
19573 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19574 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19575 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
19576 // USE OR OTHER DEALINGS IN THE SOFTWARE.
19577
19578 var formatRegExp = /%[sdj%]/g;
19579 exports.format = function(f) {
19580 if (!isString(f)) {
19581 var objects = [];
19582 for (var i = 0; i < arguments.length; i++) {
19583 objects.push(inspect(arguments[i]));
19584 }
19585 return objects.join(' ');
19586 }
19587
19588 var i = 1;
19589 var args = arguments;
19590 var len = args.length;
19591 var str = String(f).replace(formatRegExp, function(x) {
19592 if (x === '%%') return '%';
19593 if (i >= len) return x;
19594 switch (x) {
19595 case '%s': return String(args[i++]);
19596 case '%d': return Number(args[i++]);
19597 case '%j':
19598 try {
19599 return JSON.stringify(args[i++]);
19600 } catch (_) {
19601 return '[Circular]';
19602 }
19603 default:
19604 return x;
19605 }
19606 });
19607 for (var x = args[i]; i < len; x = args[++i]) {
19608 if (isNull(x) || !isObject(x)) {
19609 str += ' ' + x;
19610 } else {
19611 str += ' ' + inspect(x);
19612 }
19613 }
19614 return str;
19615 };
19616
19617
19618 // Mark that a method should not be used.
19619 // Returns a modified function which warns once by default.
19620 // If --no-deprecation is set, then it is a no-op.
19621 exports.deprecate = function(fn, msg) {
19622 // Allow for deprecating things in the process of starting up.
19623 if (isUndefined(global.process)) {
19624 return function() {
19625 return exports.deprecate(fn, msg).apply(this, arguments);
19626 };
19627 }
19628
19629 if (process.noDeprecation === true) {
19630 return fn;
19631 }
19632
19633 var warned = false;
19634 function deprecated() {
19635 if (!warned) {
19636 if (process.throwDeprecation) {
19637 throw new Error(msg);
19638 } else if (process.traceDeprecation) {
19639 console.trace(msg);
19640 } else {
19641 console.error(msg);
19642 }
19643 warned = true;
19644 }
19645 return fn.apply(this, arguments);
19646 }
19647
19648 return deprecated;
19649 };
19650
19651
19652 var debugs = {};
19653 var debugEnviron;
19654 exports.debuglog = function(set) {
19655 if (isUndefined(debugEnviron))
19656 debugEnviron = process.env.NODE_DEBUG || '';
19657 set = set.toUpperCase();
19658 if (!debugs[set]) {
19659 if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
19660 var pid = process.pid;
19661 debugs[set] = function() {
19662 var msg = exports.format.apply(exports, arguments);
19663 console.error('%s %d: %s', set, pid, msg);
19664 };
19665 } else {
19666 debugs[set] = function() {};
19667 }
19668 }
19669 return debugs[set];
19670 };
19671
19672
19673 /**
19674 * Echos the value of a value. Trys to print the value out
19675 * in the best way possible given the different types.
19676 *
19677 * @param {Object} obj The object to print out.
19678 * @param {Object} opts Optional options object that alters the output.
19679 */
19680 /* legacy: obj, showHidden, depth, colors*/
19681 function inspect(obj, opts) {
19682 // default options
19683 var ctx = {
19684 seen: [],
19685 stylize: stylizeNoColor
19686 };
19687 // legacy...
19688 if (arguments.length >= 3) ctx.depth = arguments[2];
19689 if (arguments.length >= 4) ctx.colors = arguments[3];
19690 if (isBoolean(opts)) {
19691 // legacy...
19692 ctx.showHidden = opts;
19693 } else if (opts) {
19694 // got an "options" object
19695 exports._extend(ctx, opts);
19696 }
19697 // set default options
19698 if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
19699 if (isUndefined(ctx.depth)) ctx.depth = 2;
19700 if (isUndefined(ctx.colors)) ctx.colors = false;
19701 if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
19702 if (ctx.colors) ctx.stylize = stylizeWithColor;
19703 return formatValue(ctx, obj, ctx.depth);
19704 }
19705 exports.inspect = inspect;
19706
19707
19708 // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
19709 inspect.colors = {
19710 'bold' : [1, 22],
19711 'italic' : [3, 23],
19712 'underline' : [4, 24],
19713 'inverse' : [7, 27],
19714 'white' : [37, 39],
19715 'grey' : [90, 39],
19716 'black' : [30, 39],
19717 'blue' : [34, 39],
19718 'cyan' : [36, 39],
19719 'green' : [32, 39],
19720 'magenta' : [35, 39],
19721 'red' : [31, 39],
19722 'yellow' : [33, 39]
19723 };
19724
19725 // Don't use 'blue' not visible on cmd.exe
19726 inspect.styles = {
19727 'special': 'cyan',
19728 'number': 'yellow',
19729 'boolean': 'yellow',
19730 'undefined': 'grey',
19731 'null': 'bold',
19732 'string': 'green',
19733 'date': 'magenta',
19734 // "name": intentionally not styling
19735 'regexp': 'red'
19736 };
19737
19738
19739 function stylizeWithColor(str, styleType) {
19740 var style = inspect.styles[styleType];
19741
19742 if (style) {
19743 return '\u001b[' + inspect.colors[style][0] + 'm' + str +
19744 '\u001b[' + inspect.colors[style][1] + 'm';
19745 } else {
19746 return str;
19747 }
19748 }
19749
19750
19751 function stylizeNoColor(str, styleType) {
19752 return str;
19753 }
19754
19755
19756 function arrayToHash(array) {
19757 var hash = {};
19758
19759 array.forEach(function(val, idx) {
19760 hash[val] = true;
19761 });
19762
19763 return hash;
19764 }
19765
19766
19767 function formatValue(ctx, value, recurseTimes) {
19768 // Provide a hook for user-specified inspect functions.
19769 // Check that value is an object with an inspect function on it
19770 if (ctx.customInspect &&
19771 value &&
19772 isFunction(value.inspect) &&
19773 // Filter out the util module, it's inspect function is special
19774 value.inspect !== exports.inspect &&
19775 // Also filter out any prototype objects using the circular check.
19776 !(value.constructor && value.constructor.prototype === value)) {
19777 var ret = value.inspect(recurseTimes, ctx);
19778 if (!isString(ret)) {
19779 ret = formatValue(ctx, ret, recurseTimes);
19780 }
19781 return ret;
19782 }
19783
19784 // Primitive types cannot have properties
19785 var primitive = formatPrimitive(ctx, value);
19786 if (primitive) {
19787 return primitive;
19788 }
19789
19790 // Look up the keys of the object.
19791 var keys = Object.keys(value);
19792 var visibleKeys = arrayToHash(keys);
19793
19794 if (ctx.showHidden) {
19795 keys = Object.getOwnPropertyNames(value);
19796 }
19797
19798 // IE doesn't make error fields non-enumerable
19799 // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
19800 if (isError(value)
19801 && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
19802 return formatError(value);
19803 }
19804
19805 // Some type of object without properties can be shortcutted.
19806 if (keys.length === 0) {
19807 if (isFunction(value)) {
19808 var name = value.name ? ': ' + value.name : '';
19809 return ctx.stylize('[Function' + name + ']', 'special');
19810 }
19811 if (isRegExp(value)) {
19812 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
19813 }
19814 if (isDate(value)) {
19815 return ctx.stylize(Date.prototype.toString.call(value), 'date');
19816 }
19817 if (isError(value)) {
19818 return formatError(value);
19819 }
19820 }
19821
19822 var base = '', array = false, braces = ['{', '}'];
19823
19824 // Make Array say that they are Array
19825 if (isArray(value)) {
19826 array = true;
19827 braces = ['[', ']'];
19828 }
19829
19830 // Make functions say that they are functions
19831 if (isFunction(value)) {
19832 var n = value.name ? ': ' + value.name : '';
19833 base = ' [Function' + n + ']';
19834 }
19835
19836 // Make RegExps say that they are RegExps
19837 if (isRegExp(value)) {
19838 base = ' ' + RegExp.prototype.toString.call(value);
19839 }
19840
19841 // Make dates with properties first say the date
19842 if (isDate(value)) {
19843 base = ' ' + Date.prototype.toUTCString.call(value);
19844 }
19845
19846 // Make error with message first say the error
19847 if (isError(value)) {
19848 base = ' ' + formatError(value);
19849 }
19850
19851 if (keys.length === 0 && (!array || value.length == 0)) {
19852 return braces[0] + base + braces[1];
19853 }
19854
19855 if (recurseTimes < 0) {
19856 if (isRegExp(value)) {
19857 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
19858 } else {
19859 return ctx.stylize('[Object]', 'special');
19860 }
19861 }
19862
19863 ctx.seen.push(value);
19864
19865 var output;
19866 if (array) {
19867 output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
19868 } else {
19869 output = keys.map(function(key) {
19870 return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
19871 });
19872 }
19873
19874 ctx.seen.pop();
19875
19876 return reduceToSingleString(output, base, braces);
19877 }
19878
19879
19880 function formatPrimitive(ctx, value) {
19881 if (isUndefined(value))
19882 return ctx.stylize('undefined', 'undefined');
19883 if (isString(value)) {
19884 var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
19885 .replace(/'/g, "\\'")
19886 .replace(/\\"/g, '"') + '\'';
19887 return ctx.stylize(simple, 'string');
19888 }
19889 if (isNumber(value))
19890 return ctx.stylize('' + value, 'number');
19891 if (isBoolean(value))
19892 return ctx.stylize('' + value, 'boolean');
19893 // For some reason typeof null is "object", so special case here.
19894 if (isNull(value))
19895 return ctx.stylize('null', 'null');
19896 }
19897
19898
19899 function formatError(value) {
19900 return '[' + Error.prototype.toString.call(value) + ']';
19901 }
19902
19903
19904 function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
19905 var output = [];
19906 for (var i = 0, l = value.length; i < l; ++i) {
19907 if (hasOwnProperty(value, String(i))) {
19908 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
19909 String(i), true));
19910 } else {
19911 output.push('');
19912 }
19913 }
19914 keys.forEach(function(key) {
19915 if (!key.match(/^\d+$/)) {
19916 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
19917 key, true));
19918 }
19919 });
19920 return output;
19921 }
19922
19923
19924 function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
19925 var name, str, desc;
19926 desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
19927 if (desc.get) {
19928 if (desc.set) {
19929 str = ctx.stylize('[Getter/Setter]', 'special');
19930 } else {
19931 str = ctx.stylize('[Getter]', 'special');
19932 }
19933 } else {
19934 if (desc.set) {
19935 str = ctx.stylize('[Setter]', 'special');
19936 }
19937 }
19938 if (!hasOwnProperty(visibleKeys, key)) {
19939 name = '[' + key + ']';
19940 }
19941 if (!str) {
19942 if (ctx.seen.indexOf(desc.value) < 0) {
19943 if (isNull(recurseTimes)) {
19944 str = formatValue(ctx, desc.value, null);
19945 } else {
19946 str = formatValue(ctx, desc.value, recurseTimes - 1);
19947 }
19948 if (str.indexOf('\n') > -1) {
19949 if (array) {
19950 str = str.split('\n').map(function(line) {
19951 return ' ' + line;
19952 }).join('\n').substr(2);
19953 } else {
19954 str = '\n' + str.split('\n').map(function(line) {
19955 return ' ' + line;
19956 }).join('\n');
19957 }
19958 }
19959 } else {
19960 str = ctx.stylize('[Circular]', 'special');
19961 }
19962 }
19963 if (isUndefined(name)) {
19964 if (array && key.match(/^\d+$/)) {
19965 return str;
19966 }
19967 name = JSON.stringify('' + key);
19968 if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
19969 name = name.substr(1, name.length - 2);
19970 name = ctx.stylize(name, 'name');
19971 } else {
19972 name = name.replace(/'/g, "\\'")
19973 .replace(/\\"/g, '"')
19974 .replace(/(^"|"$)/g, "'");
19975 name = ctx.stylize(name, 'string');
19976 }
19977 }
19978
19979 return name + ': ' + str;
19980 }
19981
19982
19983 function reduceToSingleString(output, base, braces) {
19984 var numLinesEst = 0;
19985 var length = output.reduce(function(prev, cur) {
19986 numLinesEst++;
19987 if (cur.indexOf('\n') >= 0) numLinesEst++;
19988 return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
19989 }, 0);
19990
19991 if (length > 60) {
19992 return braces[0] +
19993 (base === '' ? '' : base + '\n ') +
19994 ' ' +
19995 output.join(',\n ') +
19996 ' ' +
19997 braces[1];
19998 }
19999
20000 return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
20001 }
20002
20003
20004 // NOTE: These type checking functions intentionally don't use `instanceof`
20005 // because it is fragile and can be easily faked with `Object.create()`.
20006 function isArray(ar) {
20007 return Array.isArray(ar);
20008 }
20009 exports.isArray = isArray;
20010
20011 function isBoolean(arg) {
20012 return typeof arg === 'boolean';
20013 }
20014 exports.isBoolean = isBoolean;
20015
20016 function isNull(arg) {
20017 return arg === null;
20018 }
20019 exports.isNull = isNull;
20020
20021 function isNullOrUndefined(arg) {
20022 return arg == null;
20023 }
20024 exports.isNullOrUndefined = isNullOrUndefined;
20025
20026 function isNumber(arg) {
20027 return typeof arg === 'number';
20028 }
20029 exports.isNumber = isNumber;
20030
20031 function isString(arg) {
20032 return typeof arg === 'string';
20033 }
20034 exports.isString = isString;
20035
20036 function isSymbol(arg) {
20037 return typeof arg === 'symbol';
20038 }
20039 exports.isSymbol = isSymbol;
20040
20041 function isUndefined(arg) {
20042 return arg === void 0;
20043 }
20044 exports.isUndefined = isUndefined;
20045
20046 function isRegExp(re) {
20047 return isObject(re) && objectToString(re) === '[object RegExp]';
20048 }
20049 exports.isRegExp = isRegExp;
20050
20051 function isObject(arg) {
20052 return typeof arg === 'object' && arg !== null;
20053 }
20054 exports.isObject = isObject;
20055
20056 function isDate(d) {
20057 return isObject(d) && objectToString(d) === '[object Date]';
20058 }
20059 exports.isDate = isDate;
20060
20061 function isError(e) {
20062 return isObject(e) &&
20063 (objectToString(e) === '[object Error]' || e instanceof Error);
20064 }
20065 exports.isError = isError;
20066
20067 function isFunction(arg) {
20068 return typeof arg === 'function';
20069 }
20070 exports.isFunction = isFunction;
20071
20072 function isPrimitive(arg) {
20073 return arg === null ||
20074 typeof arg === 'boolean' ||
20075 typeof arg === 'number' ||
20076 typeof arg === 'string' ||
20077 typeof arg === 'symbol' || // ES6 symbol
20078 typeof arg === 'undefined';
20079 }
20080 exports.isPrimitive = isPrimitive;
20081
20082 exports.isBuffer = _dereq_('./support/isBuffer');
20083
20084 function objectToString(o) {
20085 return Object.prototype.toString.call(o);
20086 }
20087
20088
20089 function pad(n) {
20090 return n < 10 ? '0' + n.toString(10) : n.toString(10);
20091 }
20092
20093
20094 var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
20095 'Oct', 'Nov', 'Dec'];
20096
20097 // 26 Feb 16:19:34
20098 function timestamp() {
20099 var d = new Date();
20100 var time = [pad(d.getHours()),
20101 pad(d.getMinutes()),
20102 pad(d.getSeconds())].join(':');
20103 return [d.getDate(), months[d.getMonth()], time].join(' ');
20104 }
20105
20106
20107 // log is just a thin wrapper to console.log that prepends a timestamp
20108 exports.log = function() {
20109 console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
20110 };
20111
20112
20113 /**
20114 * Inherit the prototype methods from one constructor into another.
20115 *
20116 * The Function.prototype.inherits from lang.js rewritten as a standalone
20117 * function (not on Function.prototype). NOTE: If this file is to be loaded
20118 * during bootstrapping this function needs to be rewritten using some native
20119 * functions as prototype setup using normal JavaScript does not work as
20120 * expected during bootstrapping (see mirror.js in r114903).
20121 *
20122 * @param {function} ctor Constructor function which needs to inherit the
20123 * prototype.
20124 * @param {function} superCtor Constructor function to inherit prototype from.
20125 */
20126 exports.inherits = _dereq_('inherits');
20127
20128 exports._extend = function(origin, add) {
20129 // Don't do anything if add isn't an object
20130 if (!add || !isObject(add)) return origin;
20131
20132 var keys = Object.keys(add);
20133 var i = keys.length;
20134 while (i--) {
20135 origin[keys[i]] = add[keys[i]];
20136 }
20137 return origin;
20138 };
20139
20140 function hasOwnProperty(obj, prop) {
20141 return Object.prototype.hasOwnProperty.call(obj, prop);
20142 }
20143
20144 }).call(this,_dereq_("FWaASH"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
20145 },{"./support/isBuffer":5,"FWaASH":12,"inherits":11}],7:[function(_dereq_,module,exports){
20146
20147 },{}],8:[function(_dereq_,module,exports){
20148 /*!
20149 * The buffer module from node.js, for the browser.
20150 *
20151 * at author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
20152 * at license MIT
20153 */
20154
20155 var base64 = _dereq_('base64-js')
20156 var ieee754 = _dereq_('ieee754')
20157
20158 exports.Buffer = Buffer
20159 exports.SlowBuffer = Buffer
20160 exports.INSPECT_MAX_BYTES = 50
20161 Buffer.poolSize = 8192
20162
20163 /**
20164 * If `Buffer._useTypedArrays`:
20165 * === true Use Uint8Array implementation (fastest)
20166 * === false Use Object implementation (compatible down to IE6)
20167 */
20168 Buffer._useTypedArrays = (function () {
20169 // Detect if browser supports Typed Arrays. Supported browsers are IE 10+, Firefox 4+,
20170 // Chrome 7+, Safari 5.1+, Opera 11.6+, iOS 4.2+. If the browser does not support adding
20171 // properties to `Uint8Array` instances, then that's the same as no `Uint8Array` support
20172 // because we need to be able to add all the node Buffer API methods. This is an issue
20173 // in Firefox 4-29. Now fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=695438
20174 try {
20175 var buf = new ArrayBuffer(0)
20176 var arr = new Uint8Array(buf)
20177 arr.foo = function () { return 42 }
20178 return 42 === arr.foo() &&
20179 typeof arr.subarray === 'function' // Chrome 9-10 lack `subarray`
20180 } catch (e) {
20181 return false
20182 }
20183 })()
20184
20185 /**
20186 * Class: Buffer
20187 * =============
20188 *
20189 * The Buffer constructor returns instances of `Uint8Array` that are augmented
20190 * with function properties for all the node `Buffer` API functions. We use
20191 * `Uint8Array` so that square bracket notation works as expected -- it returns
20192 * a single octet.
20193 *
20194 * By augmenting the instances, we can avoid modifying the `Uint8Array`
20195 * prototype.
20196 */
20197 function Buffer (subject, encoding, noZero) {
20198 if (!(this instanceof Buffer))
20199 return new Buffer(subject, encoding, noZero)
20200
20201 var type = typeof subject
20202
20203 if (encoding === 'base64' && type === 'string') {
20204 subject = base64clean(subject)
20205 }
20206
20207 // Find the length
20208 var length
20209 if (type === 'number')
20210 length = coerce(subject)
20211 else if (type === 'string')
20212 length = Buffer.byteLength(subject, encoding)
20213 else if (type === 'object')
20214 length = coerce(subject.length) // assume that object is array-like
20215 else
20216 throw new Error('First argument needs to be a number, array or string.')
20217
20218 var buf
20219 if (Buffer._useTypedArrays) {
20220 // Preferred: Return an augmented `Uint8Array` instance for best performance
20221 buf = Buffer._augment(new Uint8Array(length))
20222 } else {
20223 // Fallback: Return THIS instance of Buffer (created by `new`)
20224 buf = this
20225 buf.length = length
20226 buf._isBuffer = true
20227 }
20228
20229 var i
20230 if (Buffer._useTypedArrays && typeof subject.byteLength === 'number') {
20231 // Speed optimization -- use set if we're copying from a typed array
20232 buf._set(subject)
20233 } else if (isArrayish(subject)) {
20234 // Treat array-ish objects as a byte array
20235 if (Buffer.isBuffer(subject)) {
20236 for (i = 0; i < length; i++)
20237 buf[i] = subject.readUInt8(i)
20238 } else {
20239 for (i = 0; i < length; i++)
20240 buf[i] = ((subject[i] % 256) + 256) % 256
20241 }
20242 } else if (type === 'string') {
20243 buf.write(subject, 0, encoding)
20244 } else if (type === 'number' && !Buffer._useTypedArrays && !noZero) {
20245 for (i = 0; i < length; i++) {
20246 buf[i] = 0
20247 }
20248 }
20249
20250 return buf
20251 }
20252
20253 // STATIC METHODS
20254 // ==============
20255
20256 Buffer.isEncoding = function (encoding) {
20257 switch (String(encoding).toLowerCase()) {
20258 case 'hex':
20259 case 'utf8':
20260 case 'utf-8':
20261 case 'ascii':
20262 case 'binary':
20263 case 'base64':
20264 case 'raw':
20265 case 'ucs2':
20266 case 'ucs-2':
20267 case 'utf16le':
20268 case 'utf-16le':
20269 return true
20270 default:
20271 return false
20272 }
20273 }
20274
20275 Buffer.isBuffer = function (b) {
20276 return !!(b !== null && b !== undefined && b._isBuffer)
20277 }
20278
20279 Buffer.byteLength = function (str, encoding) {
20280 var ret
20281 str = str.toString()
20282 switch (encoding || 'utf8') {
20283 case 'hex':
20284 ret = str.length / 2
20285 break
20286 case 'utf8':
20287 case 'utf-8':
20288 ret = utf8ToBytes(str).length
20289 break
20290 case 'ascii':
20291 case 'binary':
20292 case 'raw':
20293 ret = str.length
20294 break
20295 case 'base64':
20296 ret = base64ToBytes(str).length
20297 break
20298 case 'ucs2':
20299 case 'ucs-2':
20300 case 'utf16le':
20301 case 'utf-16le':
20302 ret = str.length * 2
20303 break
20304 default:
20305 throw new Error('Unknown encoding')
20306 }
20307 return ret
20308 }
20309
20310 Buffer.concat = function (list, totalLength) {
20311 assert(isArray(list), 'Usage: Buffer.concat(list[, length])')
20312
20313 if (list.length === 0) {
20314 return new Buffer(0)
20315 } else if (list.length === 1) {
20316 return list[0]
20317 }
20318
20319 var i
20320 if (totalLength === undefined) {
20321 totalLength = 0
20322 for (i = 0; i < list.length; i++) {
20323 totalLength += list[i].length
20324 }
20325 }
20326
20327 var buf = new Buffer(totalLength)
20328 var pos = 0
20329 for (i = 0; i < list.length; i++) {
20330 var item = list[i]
20331 item.copy(buf, pos)
20332 pos += item.length
20333 }
20334 return buf
20335 }
20336
20337 Buffer.compare = function (a, b) {
20338 assert(Buffer.isBuffer(a) && Buffer.isBuffer(b), 'Arguments must be Buffers')
20339 var x = a.length
20340 var y = b.length
20341 for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {}
20342 if (i !== len) {
20343 x = a[i]
20344 y = b[i]
20345 }
20346 if (x < y) {
20347 return -1
20348 }
20349 if (y < x) {
20350 return 1
20351 }
20352 return 0
20353 }
20354
20355 // BUFFER INSTANCE METHODS
20356 // =======================
20357
20358 function hexWrite (buf, string, offset, length) {
20359 offset = Number(offset) || 0
20360 var remaining = buf.length - offset
20361 if (!length) {
20362 length = remaining
20363 } else {
20364 length = Number(length)
20365 if (length > remaining) {
20366 length = remaining
20367 }
20368 }
20369
20370 // must be an even number of digits
20371 var strLen = string.length
20372 assert(strLen % 2 === 0, 'Invalid hex string')
20373
20374 if (length > strLen / 2) {
20375 length = strLen / 2
20376 }
20377 for (var i = 0; i < length; i++) {
20378 var byte = parseInt(string.substr(i * 2, 2), 16)
20379 assert(!isNaN(byte), 'Invalid hex string')
20380 buf[offset + i] = byte
20381 }
20382 return i
20383 }
20384
20385 function utf8Write (buf, string, offset, length) {
20386 var charsWritten = blitBuffer(utf8ToBytes(string), buf, offset, length)
20387 return charsWritten
20388 }
20389
20390 function asciiWrite (buf, string, offset, length) {
20391 var charsWritten = blitBuffer(asciiToBytes(string), buf, offset, length)
20392 return charsWritten
20393 }
20394
20395 function binaryWrite (buf, string, offset, length) {
20396 return asciiWrite(buf, string, offset, length)
20397 }
20398
20399 function base64Write (buf, string, offset, length) {
20400 var charsWritten = blitBuffer(base64ToBytes(string), buf, offset, length)
20401 return charsWritten
20402 }
20403
20404 function utf16leWrite (buf, string, offset, length) {
20405 var charsWritten = blitBuffer(utf16leToBytes(string), buf, offset, length)
20406 return charsWritten
20407 }
20408
20409 Buffer.prototype.write = function (string, offset, length, encoding) {
20410 // Support both (string, offset, length, encoding)
20411 // and the legacy (string, encoding, offset, length)
20412 if (isFinite(offset)) {
20413 if (!isFinite(length)) {
20414 encoding = length
20415 length = undefined
20416 }
20417 } else { // legacy
20418 var swap = encoding
20419 encoding = offset
20420 offset = length
20421 length = swap
20422 }
20423
20424 offset = Number(offset) || 0
20425 var remaining = this.length - offset
20426 if (!length) {
20427 length = remaining
20428 } else {
20429 length = Number(length)
20430 if (length > remaining) {
20431 length = remaining
20432 }
20433 }
20434 encoding = String(encoding || 'utf8').toLowerCase()
20435
20436 var ret
20437 switch (encoding) {
20438 case 'hex':
20439 ret = hexWrite(this, string, offset, length)
20440 break
20441 case 'utf8':
20442 case 'utf-8':
20443 ret = utf8Write(this, string, offset, length)
20444 break
20445 case 'ascii':
20446 ret = asciiWrite(this, string, offset, length)
20447 break
20448 case 'binary':
20449 ret = binaryWrite(this, string, offset, length)
20450 break
20451 case 'base64':
20452 ret = base64Write(this, string, offset, length)
20453 break
20454 case 'ucs2':
20455 case 'ucs-2':
20456 case 'utf16le':
20457 case 'utf-16le':
20458 ret = utf16leWrite(this, string, offset, length)
20459 break
20460 default:
20461 throw new Error('Unknown encoding')
20462 }
20463 return ret
20464 }
20465
20466 Buffer.prototype.toString = function (encoding, start, end) {
20467 var self = this
20468
20469 encoding = String(encoding || 'utf8').toLowerCase()
20470 start = Number(start) || 0
20471 end = (end === undefined) ? self.length : Number(end)
20472
20473 // Fastpath empty strings
20474 if (end === start)
20475 return ''
20476
20477 var ret
20478 switch (encoding) {
20479 case 'hex':
20480 ret = hexSlice(self, start, end)
20481 break
20482 case 'utf8':
20483 case 'utf-8':
20484 ret = utf8Slice(self, start, end)
20485 break
20486 case 'ascii':
20487 ret = asciiSlice(self, start, end)
20488 break
20489 case 'binary':
20490 ret = binarySlice(self, start, end)
20491 break
20492 case 'base64':
20493 ret = base64Slice(self, start, end)
20494 break
20495 case 'ucs2':
20496 case 'ucs-2':
20497 case 'utf16le':
20498 case 'utf-16le':
20499 ret = utf16leSlice(self, start, end)
20500 break
20501 default:
20502 throw new Error('Unknown encoding')
20503 }
20504 return ret
20505 }
20506
20507 Buffer.prototype.toJSON = function () {
20508 return {
20509 type: 'Buffer',
20510 data: Array.prototype.slice.call(this._arr || this, 0)
20511 }
20512 }
20513
20514 Buffer.prototype.equals = function (b) {
20515 assert(Buffer.isBuffer(b), 'Argument must be a Buffer')
20516 return Buffer.compare(this, b) === 0
20517 }
20518
20519 Buffer.prototype.compare = function (b) {
20520 assert(Buffer.isBuffer(b), 'Argument must be a Buffer')
20521 return Buffer.compare(this, b)
20522 }
20523
20524 // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
20525 Buffer.prototype.copy = function (target, target_start, start, end) {
20526 var source = this
20527
20528 if (!start) start = 0
20529 if (!end && end !== 0) end = this.length
20530 if (!target_start) target_start = 0
20531
20532 // Copy 0 bytes; we're done
20533 if (end === start) return
20534 if (target.length === 0 || source.length === 0) return
20535
20536 // Fatal error conditions
20537 assert(end >= start, 'sourceEnd < sourceStart')
20538 assert(target_start >= 0 && target_start < target.length,
20539 'targetStart out of bounds')
20540 assert(start >= 0 && start < source.length, 'sourceStart out of bounds')
20541 assert(end >= 0 && end <= source.length, 'sourceEnd out of bounds')
20542
20543 // Are we oob?
20544 if (end > this.length)
20545 end = this.length
20546 if (target.length - target_start < end - start)
20547 end = target.length - target_start + start
20548
20549 var len = end - start
20550
20551 if (len < 100 || !Buffer._useTypedArrays) {
20552 for (var i = 0; i < len; i++) {
20553 target[i + target_start] = this[i + start]
20554 }
20555 } else {
20556 target._set(this.subarray(start, start + len), target_start)
20557 }
20558 }
20559
20560 function base64Slice (buf, start, end) {
20561 if (start === 0 && end === buf.length) {
20562 return base64.fromByteArray(buf)
20563 } else {
20564 return base64.fromByteArray(buf.slice(start, end))
20565 }
20566 }
20567
20568 function utf8Slice (buf, start, end) {
20569 var res = ''
20570 var tmp = ''
20571 end = Math.min(buf.length, end)
20572
20573 for (var i = start; i < end; i++) {
20574 if (buf[i] <= 0x7F) {
20575 res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i])
20576 tmp = ''
20577 } else {
20578 tmp += '%' + buf[i].toString(16)
20579 }
20580 }
20581
20582 return res + decodeUtf8Char(tmp)
20583 }
20584
20585 function asciiSlice (buf, start, end) {
20586 var ret = ''
20587 end = Math.min(buf.length, end)
20588
20589 for (var i = start; i < end; i++) {
20590 ret += String.fromCharCode(buf[i])
20591 }
20592 return ret
20593 }
20594
20595 function binarySlice (buf, start, end) {
20596 return asciiSlice(buf, start, end)
20597 }
20598
20599 function hexSlice (buf, start, end) {
20600 var len = buf.length
20601
20602 if (!start || start < 0) start = 0
20603 if (!end || end < 0 || end > len) end = len
20604
20605 var out = ''
20606 for (var i = start; i < end; i++) {
20607 out += toHex(buf[i])
20608 }
20609 return out
20610 }
20611
20612 function utf16leSlice (buf, start, end) {
20613 var bytes = buf.slice(start, end)
20614 var res = ''
20615 for (var i = 0; i < bytes.length; i += 2) {
20616 res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
20617 }
20618 return res
20619 }
20620
20621 Buffer.prototype.slice = function (start, end) {
20622 var len = this.length
20623 start = clamp(start, len, 0)
20624 end = clamp(end, len, len)
20625
20626 if (Buffer._useTypedArrays) {
20627 return Buffer._augment(this.subarray(start, end))
20628 } else {
20629 var sliceLen = end - start
20630 var newBuf = new Buffer(sliceLen, undefined, true)
20631 for (var i = 0; i < sliceLen; i++) {
20632 newBuf[i] = this[i + start]
20633 }
20634 return newBuf
20635 }
20636 }
20637
20638 // `get` will be removed in Node 0.13+
20639 Buffer.prototype.get = function (offset) {
20640 console.log('.get() is deprecated. Access using array indexes instead.')
20641 return this.readUInt8(offset)
20642 }
20643
20644 // `set` will be removed in Node 0.13+
20645 Buffer.prototype.set = function (v, offset) {
20646 console.log('.set() is deprecated. Access using array indexes instead.')
20647 return this.writeUInt8(v, offset)
20648 }
20649
20650 Buffer.prototype.readUInt8 = function (offset, noAssert) {
20651 if (!noAssert) {
20652 assert(offset !== undefined && offset !== null, 'missing offset')
20653 assert(offset < this.length, 'Trying to read beyond buffer length')
20654 }
20655
20656 if (offset >= this.length)
20657 return
20658
20659 return this[offset]
20660 }
20661
20662 function readUInt16 (buf, offset, littleEndian, noAssert) {
20663 if (!noAssert) {
20664 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20665 assert(offset !== undefined && offset !== null, 'missing offset')
20666 assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
20667 }
20668
20669 var len = buf.length
20670 if (offset >= len)
20671 return
20672
20673 var val
20674 if (littleEndian) {
20675 val = buf[offset]
20676 if (offset + 1 < len)
20677 val |= buf[offset + 1] << 8
20678 } else {
20679 val = buf[offset] << 8
20680 if (offset + 1 < len)
20681 val |= buf[offset + 1]
20682 }
20683 return val
20684 }
20685
20686 Buffer.prototype.readUInt16LE = function (offset, noAssert) {
20687 return readUInt16(this, offset, true, noAssert)
20688 }
20689
20690 Buffer.prototype.readUInt16BE = function (offset, noAssert) {
20691 return readUInt16(this, offset, false, noAssert)
20692 }
20693
20694 function readUInt32 (buf, offset, littleEndian, noAssert) {
20695 if (!noAssert) {
20696 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20697 assert(offset !== undefined && offset !== null, 'missing offset')
20698 assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
20699 }
20700
20701 var len = buf.length
20702 if (offset >= len)
20703 return
20704
20705 var val
20706 if (littleEndian) {
20707 if (offset + 2 < len)
20708 val = buf[offset + 2] << 16
20709 if (offset + 1 < len)
20710 val |= buf[offset + 1] << 8
20711 val |= buf[offset]
20712 if (offset + 3 < len)
20713 val = val + (buf[offset + 3] << 24 >>> 0)
20714 } else {
20715 if (offset + 1 < len)
20716 val = buf[offset + 1] << 16
20717 if (offset + 2 < len)
20718 val |= buf[offset + 2] << 8
20719 if (offset + 3 < len)
20720 val |= buf[offset + 3]
20721 val = val + (buf[offset] << 24 >>> 0)
20722 }
20723 return val
20724 }
20725
20726 Buffer.prototype.readUInt32LE = function (offset, noAssert) {
20727 return readUInt32(this, offset, true, noAssert)
20728 }
20729
20730 Buffer.prototype.readUInt32BE = function (offset, noAssert) {
20731 return readUInt32(this, offset, false, noAssert)
20732 }
20733
20734 Buffer.prototype.readInt8 = function (offset, noAssert) {
20735 if (!noAssert) {
20736 assert(offset !== undefined && offset !== null,
20737 'missing offset')
20738 assert(offset < this.length, 'Trying to read beyond buffer length')
20739 }
20740
20741 if (offset >= this.length)
20742 return
20743
20744 var neg = this[offset] & 0x80
20745 if (neg)
20746 return (0xff - this[offset] + 1) * -1
20747 else
20748 return this[offset]
20749 }
20750
20751 function readInt16 (buf, offset, littleEndian, noAssert) {
20752 if (!noAssert) {
20753 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20754 assert(offset !== undefined && offset !== null, 'missing offset')
20755 assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
20756 }
20757
20758 var len = buf.length
20759 if (offset >= len)
20760 return
20761
20762 var val = readUInt16(buf, offset, littleEndian, true)
20763 var neg = val & 0x8000
20764 if (neg)
20765 return (0xffff - val + 1) * -1
20766 else
20767 return val
20768 }
20769
20770 Buffer.prototype.readInt16LE = function (offset, noAssert) {
20771 return readInt16(this, offset, true, noAssert)
20772 }
20773
20774 Buffer.prototype.readInt16BE = function (offset, noAssert) {
20775 return readInt16(this, offset, false, noAssert)
20776 }
20777
20778 function readInt32 (buf, offset, littleEndian, noAssert) {
20779 if (!noAssert) {
20780 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20781 assert(offset !== undefined && offset !== null, 'missing offset')
20782 assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
20783 }
20784
20785 var len = buf.length
20786 if (offset >= len)
20787 return
20788
20789 var val = readUInt32(buf, offset, littleEndian, true)
20790 var neg = val & 0x80000000
20791 if (neg)
20792 return (0xffffffff - val + 1) * -1
20793 else
20794 return val
20795 }
20796
20797 Buffer.prototype.readInt32LE = function (offset, noAssert) {
20798 return readInt32(this, offset, true, noAssert)
20799 }
20800
20801 Buffer.prototype.readInt32BE = function (offset, noAssert) {
20802 return readInt32(this, offset, false, noAssert)
20803 }
20804
20805 function readFloat (buf, offset, littleEndian, noAssert) {
20806 if (!noAssert) {
20807 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20808 assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
20809 }
20810
20811 return ieee754.read(buf, offset, littleEndian, 23, 4)
20812 }
20813
20814 Buffer.prototype.readFloatLE = function (offset, noAssert) {
20815 return readFloat(this, offset, true, noAssert)
20816 }
20817
20818 Buffer.prototype.readFloatBE = function (offset, noAssert) {
20819 return readFloat(this, offset, false, noAssert)
20820 }
20821
20822 function readDouble (buf, offset, littleEndian, noAssert) {
20823 if (!noAssert) {
20824 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20825 assert(offset + 7 < buf.length, 'Trying to read beyond buffer length')
20826 }
20827
20828 return ieee754.read(buf, offset, littleEndian, 52, 8)
20829 }
20830
20831 Buffer.prototype.readDoubleLE = function (offset, noAssert) {
20832 return readDouble(this, offset, true, noAssert)
20833 }
20834
20835 Buffer.prototype.readDoubleBE = function (offset, noAssert) {
20836 return readDouble(this, offset, false, noAssert)
20837 }
20838
20839 Buffer.prototype.writeUInt8 = function (value, offset, noAssert) {
20840 if (!noAssert) {
20841 assert(value !== undefined && value !== null, 'missing value')
20842 assert(offset !== undefined && offset !== null, 'missing offset')
20843 assert(offset < this.length, 'trying to write beyond buffer length')
20844 verifuint(value, 0xff)
20845 }
20846
20847 if (offset >= this.length) return
20848
20849 this[offset] = value
20850 return offset + 1
20851 }
20852
20853 function writeUInt16 (buf, value, offset, littleEndian, noAssert) {
20854 if (!noAssert) {
20855 assert(value !== undefined && value !== null, 'missing value')
20856 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20857 assert(offset !== undefined && offset !== null, 'missing offset')
20858 assert(offset + 1 < buf.length, 'trying to write beyond buffer length')
20859 verifuint(value, 0xffff)
20860 }
20861
20862 var len = buf.length
20863 if (offset >= len)
20864 return
20865
20866 for (var i = 0, j = Math.min(len - offset, 2); i < j; i++) {
20867 buf[offset + i] =
20868 (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
20869 (littleEndian ? i : 1 - i) * 8
20870 }
20871 return offset + 2
20872 }
20873
20874 Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) {
20875 return writeUInt16(this, value, offset, true, noAssert)
20876 }
20877
20878 Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) {
20879 return writeUInt16(this, value, offset, false, noAssert)
20880 }
20881
20882 function writeUInt32 (buf, value, offset, littleEndian, noAssert) {
20883 if (!noAssert) {
20884 assert(value !== undefined && value !== null, 'missing value')
20885 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20886 assert(offset !== undefined && offset !== null, 'missing offset')
20887 assert(offset + 3 < buf.length, 'trying to write beyond buffer length')
20888 verifuint(value, 0xffffffff)
20889 }
20890
20891 var len = buf.length
20892 if (offset >= len)
20893 return
20894
20895 for (var i = 0, j = Math.min(len - offset, 4); i < j; i++) {
20896 buf[offset + i] =
20897 (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
20898 }
20899 return offset + 4
20900 }
20901
20902 Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) {
20903 return writeUInt32(this, value, offset, true, noAssert)
20904 }
20905
20906 Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) {
20907 return writeUInt32(this, value, offset, false, noAssert)
20908 }
20909
20910 Buffer.prototype.writeInt8 = function (value, offset, noAssert) {
20911 if (!noAssert) {
20912 assert(value !== undefined && value !== null, 'missing value')
20913 assert(offset !== undefined && offset !== null, 'missing offset')
20914 assert(offset < this.length, 'Trying to write beyond buffer length')
20915 verifsint(value, 0x7f, -0x80)
20916 }
20917
20918 if (offset >= this.length)
20919 return
20920
20921 if (value >= 0)
20922 this.writeUInt8(value, offset, noAssert)
20923 else
20924 this.writeUInt8(0xff + value + 1, offset, noAssert)
20925 return offset + 1
20926 }
20927
20928 function writeInt16 (buf, value, offset, littleEndian, noAssert) {
20929 if (!noAssert) {
20930 assert(value !== undefined && value !== null, 'missing value')
20931 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20932 assert(offset !== undefined && offset !== null, 'missing offset')
20933 assert(offset + 1 < buf.length, 'Trying to write beyond buffer length')
20934 verifsint(value, 0x7fff, -0x8000)
20935 }
20936
20937 var len = buf.length
20938 if (offset >= len)
20939 return
20940
20941 if (value >= 0)
20942 writeUInt16(buf, value, offset, littleEndian, noAssert)
20943 else
20944 writeUInt16(buf, 0xffff + value + 1, offset, littleEndian, noAssert)
20945 return offset + 2
20946 }
20947
20948 Buffer.prototype.writeInt16LE = function (value, offset, noAssert) {
20949 return writeInt16(this, value, offset, true, noAssert)
20950 }
20951
20952 Buffer.prototype.writeInt16BE = function (value, offset, noAssert) {
20953 return writeInt16(this, value, offset, false, noAssert)
20954 }
20955
20956 function writeInt32 (buf, value, offset, littleEndian, noAssert) {
20957 if (!noAssert) {
20958 assert(value !== undefined && value !== null, 'missing value')
20959 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20960 assert(offset !== undefined && offset !== null, 'missing offset')
20961 assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
20962 verifsint(value, 0x7fffffff, -0x80000000)
20963 }
20964
20965 var len = buf.length
20966 if (offset >= len)
20967 return
20968
20969 if (value >= 0)
20970 writeUInt32(buf, value, offset, littleEndian, noAssert)
20971 else
20972 writeUInt32(buf, 0xffffffff + value + 1, offset, littleEndian, noAssert)
20973 return offset + 4
20974 }
20975
20976 Buffer.prototype.writeInt32LE = function (value, offset, noAssert) {
20977 return writeInt32(this, value, offset, true, noAssert)
20978 }
20979
20980 Buffer.prototype.writeInt32BE = function (value, offset, noAssert) {
20981 return writeInt32(this, value, offset, false, noAssert)
20982 }
20983
20984 function writeFloat (buf, value, offset, littleEndian, noAssert) {
20985 if (!noAssert) {
20986 assert(value !== undefined && value !== null, 'missing value')
20987 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
20988 assert(offset !== undefined && offset !== null, 'missing offset')
20989 assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
20990 verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38)
20991 }
20992
20993 var len = buf.length
20994 if (offset >= len)
20995 return
20996
20997 ieee754.write(buf, value, offset, littleEndian, 23, 4)
20998 return offset + 4
20999 }
21000
21001 Buffer.prototype.writeFloatLE = function (value, offset, noAssert) {
21002 return writeFloat(this, value, offset, true, noAssert)
21003 }
21004
21005 Buffer.prototype.writeFloatBE = function (value, offset, noAssert) {
21006 return writeFloat(this, value, offset, false, noAssert)
21007 }
21008
21009 function writeDouble (buf, value, offset, littleEndian, noAssert) {
21010 if (!noAssert) {
21011 assert(value !== undefined && value !== null, 'missing value')
21012 assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
21013 assert(offset !== undefined && offset !== null, 'missing offset')
21014 assert(offset + 7 < buf.length,
21015 'Trying to write beyond buffer length')
21016 verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308)
21017 }
21018
21019 var len = buf.length
21020 if (offset >= len)
21021 return
21022
21023 ieee754.write(buf, value, offset, littleEndian, 52, 8)
21024 return offset + 8
21025 }
21026
21027 Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) {
21028 return writeDouble(this, value, offset, true, noAssert)
21029 }
21030
21031 Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) {
21032 return writeDouble(this, value, offset, false, noAssert)
21033 }
21034
21035 // fill(value, start=0, end=buffer.length)
21036 Buffer.prototype.fill = function (value, start, end) {
21037 if (!value) value = 0
21038 if (!start) start = 0
21039 if (!end) end = this.length
21040
21041 assert(end >= start, 'end < start')
21042
21043 // Fill 0 bytes; we're done
21044 if (end === start) return
21045 if (this.length === 0) return
21046
21047 assert(start >= 0 && start < this.length, 'start out of bounds')
21048 assert(end >= 0 && end <= this.length, 'end out of bounds')
21049
21050 var i
21051 if (typeof value === 'number') {
21052 for (i = start; i < end; i++) {
21053 this[i] = value
21054 }
21055 } else {
21056 var bytes = utf8ToBytes(value.toString())
21057 var len = bytes.length
21058 for (i = start; i < end; i++) {
21059 this[i] = bytes[i % len]
21060 }
21061 }
21062
21063 return this
21064 }
21065
21066 Buffer.prototype.inspect = function () {
21067 var out = []
21068 var len = this.length
21069 for (var i = 0; i < len; i++) {
21070 out[i] = toHex(this[i])
21071 if (i === exports.INSPECT_MAX_BYTES) {
21072 out[i + 1] = '...'
21073 break
21074 }
21075 }
21076 return '<Buffer ' + out.join(' ') + '>'
21077 }
21078
21079 /**
21080 * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
21081 * Added in Node 0.12. Only available in browsers that support ArrayBuffer.
21082 */
21083 Buffer.prototype.toArrayBuffer = function () {
21084 if (typeof Uint8Array !== 'undefined') {
21085 if (Buffer._useTypedArrays) {
21086 return (new Buffer(this)).buffer
21087 } else {
21088 var buf = new Uint8Array(this.length)
21089 for (var i = 0, len = buf.length; i < len; i += 1) {
21090 buf[i] = this[i]
21091 }
21092 return buf.buffer
21093 }
21094 } else {
21095 throw new Error('Buffer.toArrayBuffer not supported in this browser')
21096 }
21097 }
21098
21099 // HELPER FUNCTIONS
21100 // ================
21101
21102 var BP = Buffer.prototype
21103
21104 /**
21105 * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
21106 */
21107 Buffer._augment = function (arr) {
21108 arr._isBuffer = true
21109
21110 // save reference to original Uint8Array get/set methods before overwriting
21111 arr._get = arr.get
21112 arr._set = arr.set
21113
21114 // deprecated, will be removed in node 0.13+
21115 arr.get = BP.get
21116 arr.set = BP.set
21117
21118 arr.write = BP.write
21119 arr.toString = BP.toString
21120 arr.toLocaleString = BP.toString
21121 arr.toJSON = BP.toJSON
21122 arr.equals = BP.equals
21123 arr.compare = BP.compare
21124 arr.copy = BP.copy
21125 arr.slice = BP.slice
21126 arr.readUInt8 = BP.readUInt8
21127 arr.readUInt16LE = BP.readUInt16LE
21128 arr.readUInt16BE = BP.readUInt16BE
21129 arr.readUInt32LE = BP.readUInt32LE
21130 arr.readUInt32BE = BP.readUInt32BE
21131 arr.readInt8 = BP.readInt8
21132 arr.readInt16LE = BP.readInt16LE
21133 arr.readInt16BE = BP.readInt16BE
21134 arr.readInt32LE = BP.readInt32LE
21135 arr.readInt32BE = BP.readInt32BE
21136 arr.readFloatLE = BP.readFloatLE
21137 arr.readFloatBE = BP.readFloatBE
21138 arr.readDoubleLE = BP.readDoubleLE
21139 arr.readDoubleBE = BP.readDoubleBE
21140 arr.writeUInt8 = BP.writeUInt8
21141 arr.writeUInt16LE = BP.writeUInt16LE
21142 arr.writeUInt16BE = BP.writeUInt16BE
21143 arr.writeUInt32LE = BP.writeUInt32LE
21144 arr.writeUInt32BE = BP.writeUInt32BE
21145 arr.writeInt8 = BP.writeInt8
21146 arr.writeInt16LE = BP.writeInt16LE
21147 arr.writeInt16BE = BP.writeInt16BE
21148 arr.writeInt32LE = BP.writeInt32LE
21149 arr.writeInt32BE = BP.writeInt32BE
21150 arr.writeFloatLE = BP.writeFloatLE
21151 arr.writeFloatBE = BP.writeFloatBE
21152 arr.writeDoubleLE = BP.writeDoubleLE
21153 arr.writeDoubleBE = BP.writeDoubleBE
21154 arr.fill = BP.fill
21155 arr.inspect = BP.inspect
21156 arr.toArrayBuffer = BP.toArrayBuffer
21157
21158 return arr
21159 }
21160
21161 var INVALID_BASE64_RE = /[^+\/0-9A-z]/g
21162
21163 function base64clean (str) {
21164 // Node strips out invalid characters like \n and \t from the string, base64-js does not
21165 str = stringtrim(str).replace(INVALID_BASE64_RE, '')
21166 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
21167 while (str.length % 4 !== 0) {
21168 str = str + '='
21169 }
21170 return str
21171 }
21172
21173 function stringtrim (str) {
21174 if (str.trim) return str.trim()
21175 return str.replace(/^\s+|\s+$/g, '')
21176 }
21177
21178 // slice(start, end)
21179 function clamp (index, len, defaultValue) {
21180 if (typeof index !== 'number') return defaultValue
21181 index = ~~index; // Coerce to integer.
21182 if (index >= len) return len
21183 if (index >= 0) return index
21184 index += len
21185 if (index >= 0) return index
21186 return 0
21187 }
21188
21189 function coerce (length) {
21190 // Coerce length to a number (possibly NaN), round up
21191 // in case it's fractional (e.g. 123.456) then do a
21192 // double negate to coerce a NaN to 0. Easy, right?
21193 length = ~~Math.ceil(+length)
21194 return length < 0 ? 0 : length
21195 }
21196
21197 function isArray (subject) {
21198 return (Array.isArray || function (subject) {
21199 return Object.prototype.toString.call(subject) === '[object Array]'
21200 })(subject)
21201 }
21202
21203 function isArrayish (subject) {
21204 return isArray(subject) || Buffer.isBuffer(subject) ||
21205 subject && typeof subject === 'object' &&
21206 typeof subject.length === 'number'
21207 }
21208
21209 function toHex (n) {
21210 if (n < 16) return '0' + n.toString(16)
21211 return n.toString(16)
21212 }
21213
21214 function utf8ToBytes (str) {
21215 var byteArray = []
21216 for (var i = 0; i < str.length; i++) {
21217 var b = str.charCodeAt(i)
21218 if (b <= 0x7F) {
21219 byteArray.push(b)
21220 } else {
21221 var start = i
21222 if (b >= 0xD800 && b <= 0xDFFF) i++
21223 var h = encodeURIComponent(str.slice(start, i+1)).substr(1).split('%')
21224 for (var j = 0; j < h.length; j++) {
21225 byteArray.push(parseInt(h[j], 16))
21226 }
21227 }
21228 }
21229 return byteArray
21230 }
21231
21232 function asciiToBytes (str) {
21233 var byteArray = []
21234 for (var i = 0; i < str.length; i++) {
21235 // Node's code seems to be doing this and not & 0x7F..
21236 byteArray.push(str.charCodeAt(i) & 0xFF)
21237 }
21238 return byteArray
21239 }
21240
21241 function utf16leToBytes (str) {
21242 var c, hi, lo
21243 var byteArray = []
21244 for (var i = 0; i < str.length; i++) {
21245 c = str.charCodeAt(i)
21246 hi = c >> 8
21247 lo = c % 256
21248 byteArray.push(lo)
21249 byteArray.push(hi)
21250 }
21251
21252 return byteArray
21253 }
21254
21255 function base64ToBytes (str) {
21256 return base64.toByteArray(str)
21257 }
21258
21259 function blitBuffer (src, dst, offset, length) {
21260 for (var i = 0; i < length; i++) {
21261 if ((i + offset >= dst.length) || (i >= src.length))
21262 break
21263 dst[i + offset] = src[i]
21264 }
21265 return i
21266 }
21267
21268 function decodeUtf8Char (str) {
21269 try {
21270 return decodeURIComponent(str)
21271 } catch (err) {
21272 return String.fromCharCode(0xFFFD) // UTF 8 invalid char
21273 }
21274 }
21275
21276 /*
21277 * We have to make sure that the value is a valid integer. This means that it
21278 * is non-negative. It has no fractional component and that it does not
21279 * exceed the maximum allowed value.
21280 */
21281 function verifuint (value, max) {
21282 assert(typeof value === 'number', 'cannot write a non-number as a number')
21283 assert(value >= 0, 'specified a negative value for writing an unsigned value')
21284 assert(value <= max, 'value is larger than maximum value for type')
21285 assert(Math.floor(value) === value, 'value has a fractional component')
21286 }
21287
21288 function verifsint (value, max, min) {
21289 assert(typeof value === 'number', 'cannot write a non-number as a number')
21290 assert(value <= max, 'value larger than maximum allowed value')
21291 assert(value >= min, 'value smaller than minimum allowed value')
21292 assert(Math.floor(value) === value, 'value has a fractional component')
21293 }
21294
21295 function verifIEEE754 (value, max, min) {
21296 assert(typeof value === 'number', 'cannot write a non-number as a number')
21297 assert(value <= max, 'value larger than maximum allowed value')
21298 assert(value >= min, 'value smaller than minimum allowed value')
21299 }
21300
21301 function assert (test, message) {
21302 if (!test) throw new Error(message || 'Failed assertion')
21303 }
21304
21305 },{"base64-js":9,"ieee754":10}],9:[function(_dereq_,module,exports){
21306 var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
21307
21308 ;(function (exports) {
21309 'use strict';
21310
21311 var Arr = (typeof Uint8Array !== 'undefined')
21312 ? Uint8Array
21313 : Array
21314
21315 var PLUS = '+'.charCodeAt(0)
21316 var SLASH = '/'.charCodeAt(0)
21317 var NUMBER = '0'.charCodeAt(0)
21318 var LOWER = 'a'.charCodeAt(0)
21319 var UPPER = 'A'.charCodeAt(0)
21320
21321 function decode (elt) {
21322 var code = elt.charCodeAt(0)
21323 if (code === PLUS)
21324 return 62 // '+'
21325 if (code === SLASH)
21326 return 63 // '/'
21327 if (code < NUMBER)
21328 return -1 //no match
21329 if (code < NUMBER + 10)
21330 return code - NUMBER + 26 + 26
21331 if (code < UPPER + 26)
21332 return code - UPPER
21333 if (code < LOWER + 26)
21334 return code - LOWER + 26
21335 }
21336
21337 function b64ToByteArray (b64) {
21338 var i, j, l, tmp, placeHolders, arr
21339
21340 if (b64.length % 4 > 0) {
21341 throw new Error('Invalid string. Length must be a multiple of 4')
21342 }
21343
21344 // the number of equal signs (place holders)
21345 // if there are two placeholders, than the two characters before it
21346 // represent one byte
21347 // if there is only one, then the three characters before it represent 2 bytes
21348 // this is just a cheap hack to not do indexOf twice
21349 var len = b64.length
21350 placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
21351
21352 // base64 is 4/3 + up to two characters of the original data
21353 arr = new Arr(b64.length * 3 / 4 - placeHolders)
21354
21355 // if there are placeholders, only get up to the last complete 4 chars
21356 l = placeHolders > 0 ? b64.length - 4 : b64.length
21357
21358 var L = 0
21359
21360 function push (v) {
21361 arr[L++] = v
21362 }
21363
21364 for (i = 0, j = 0; i < l; i += 4, j += 3) {
21365 tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
21366 push((tmp & 0xFF0000) >> 16)
21367 push((tmp & 0xFF00) >> 8)
21368 push(tmp & 0xFF)
21369 }
21370
21371 if (placeHolders === 2) {
21372 tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
21373 push(tmp & 0xFF)
21374 } else if (placeHolders === 1) {
21375 tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
21376 push((tmp >> 8) & 0xFF)
21377 push(tmp & 0xFF)
21378 }
21379
21380 return arr
21381 }
21382
21383 function uint8ToBase64 (uint8) {
21384 var i,
21385 extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
21386 output = "",
21387 temp, length
21388
21389 function encode (num) {
21390 return lookup.charAt(num)
21391 }
21392
21393 function tripletToBase64 (num) {
21394 return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
21395 }
21396
21397 // go through the array every three bytes, we'll deal with trailing stuff later
21398 for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
21399 temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
21400 output += tripletToBase64(temp)
21401 }
21402
21403 // pad the end with zeros, but make sure to not forget the extra bytes
21404 switch (extraBytes) {
21405 case 1:
21406 temp = uint8[uint8.length - 1]
21407 output += encode(temp >> 2)
21408 output += encode((temp << 4) & 0x3F)
21409 output += '=='
21410 break
21411 case 2:
21412 temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
21413 output += encode(temp >> 10)
21414 output += encode((temp >> 4) & 0x3F)
21415 output += encode((temp << 2) & 0x3F)
21416 output += '='
21417 break
21418 }
21419
21420 return output
21421 }
21422
21423 exports.toByteArray = b64ToByteArray
21424 exports.fromByteArray = uint8ToBase64
21425 }(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
21426
21427 },{}],10:[function(_dereq_,module,exports){
21428 exports.read = function(buffer, offset, isLE, mLen, nBytes) {
21429 var e, m,
21430 eLen = nBytes * 8 - mLen - 1,
21431 eMax = (1 << eLen) - 1,
21432 eBias = eMax >> 1,
21433 nBits = -7,
21434 i = isLE ? (nBytes - 1) : 0,
21435 d = isLE ? -1 : 1,
21436 s = buffer[offset + i];
21437
21438 i += d;
21439
21440 e = s & ((1 << (-nBits)) - 1);
21441 s >>= (-nBits);
21442 nBits += eLen;
21443 for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8){};
21444
21445 m = e & ((1 << (-nBits)) - 1);
21446 e >>= (-nBits);
21447 nBits += mLen;
21448 for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8){};
21449
21450 if (e === 0) {
21451 e = 1 - eBias;
21452 } else if (e === eMax) {
21453 return m ? NaN : ((s ? -1 : 1) * Infinity);
21454 } else {
21455 m = m + Math.pow(2, mLen);
21456 e = e - eBias;
21457 }
21458 return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
21459 };
21460
21461 exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
21462 var e, m, c,
21463 eLen = nBytes * 8 - mLen - 1,
21464 eMax = (1 << eLen) - 1,
21465 eBias = eMax >> 1,
21466 rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0),
21467 i = isLE ? 0 : (nBytes - 1),
21468 d = isLE ? 1 : -1,
21469 s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
21470
21471 value = Math.abs(value);
21472
21473 if (isNaN(value) || value === Infinity) {
21474 m = isNaN(value) ? 1 : 0;
21475 e = eMax;
21476 } else {
21477 e = Math.floor(Math.log(value) / Math.LN2);
21478 if (value * (c = Math.pow(2, -e)) < 1) {
21479 e--;
21480 c *= 2;
21481 }
21482 if (e + eBias >= 1) {
21483 value += rt / c;
21484 } else {
21485 value += rt * Math.pow(2, 1 - eBias);
21486 }
21487 if (value * c >= 2) {
21488 e++;
21489 c /= 2;
21490 }
21491
21492 if (e + eBias >= eMax) {
21493 m = 0;
21494 e = eMax;
21495 } else if (e + eBias >= 1) {
21496 m = (value * c - 1) * Math.pow(2, mLen);
21497 e = e + eBias;
21498 } else {
21499 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
21500 e = 0;
21501 }
21502 }
21503
21504 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8){};
21505
21506 e = (e << mLen) | m;
21507 eLen += mLen;
21508 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8){};
21509
21510 buffer[offset + i - d] |= s * 128;
21511 };
21512
21513 },{}],11:[function(_dereq_,module,exports){
21514 if (typeof Object.create === 'function') {
21515 // implementation from standard node.js 'util' module
21516 module.exports = function inherits(ctor, superCtor) {
21517 ctor.super_ = superCtor
21518 ctor.prototype = Object.create(superCtor.prototype, {
21519 constructor: {
21520 value: ctor,
21521 enumerable: false,
21522 writable: true,
21523 configurable: true
21524 }
21525 });
21526 };
21527 } else {
21528 // old school shim for old browsers
21529 module.exports = function inherits(ctor, superCtor) {
21530 ctor.super_ = superCtor
21531 var TempCtor = function () {}
21532 TempCtor.prototype = superCtor.prototype
21533 ctor.prototype = new TempCtor()
21534 ctor.prototype.constructor = ctor
21535 }
21536 }
21537
21538 },{}],12:[function(_dereq_,module,exports){
21539 // shim for using process in browser
21540
21541 var process = module.exports = {};
21542
21543 process.nextTick = (function () {
21544 var canSetImmediate = typeof window !== 'undefined'
21545 && window.setImmediate;
21546 var canPost = typeof window !== 'undefined'
21547 && window.postMessage && window.addEventListener
21548 ;
21549
21550 if (canSetImmediate) {
21551 return function (f) { return window.setImmediate(f) };
21552 }
21553
21554 if (canPost) {
21555 var queue = [];
21556 window.addEventListener('message', function (ev) {
21557 var source = ev.source;
21558 if ((source === window || source === null) && ev.data === 'process-tick') {
21559 ev.stopPropagation();
21560 if (queue.length > 0) {
21561 var fn = queue.shift();
21562 fn();
21563 }
21564 }
21565 }, true);
21566
21567 return function nextTick(fn) {
21568 queue.push(fn);
21569 window.postMessage('process-tick', '*');
21570 };
21571 }
21572
21573 return function nextTick(fn) {
21574 setTimeout(fn, 0);
21575 };
21576 })();
21577
21578 process.title = 'browser';
21579 process.browser = true;
21580 process.env = {};
21581 process.argv = [];
21582
21583 function noop() {}
21584
21585 process.on = noop;
21586 process.addListener = noop;
21587 process.once = noop;
21588 process.off = noop;
21589 process.removeListener = noop;
21590 process.removeAllListeners = noop;
21591 process.emit = noop;
21592
21593 process.binding = function (name) {
21594 throw new Error('process.binding is not supported');
21595 }
21596
21597 // TODO(shtylman)
21598 process.cwd = function () { return '/' };
21599 process.chdir = function (dir) {
21600 throw new Error('process.chdir is not supported');
21601 };
21602
21603 },{}],13:[function(_dereq_,module,exports){
21604 module.exports=_dereq_(5)
21605 },{}],14:[function(_dereq_,module,exports){
21606 module.exports=_dereq_(6)
21607 },{"./support/isBuffer":13,"FWaASH":12,"inherits":11}],15:[function(_dereq_,module,exports){
21608 (function (Buffer){
21609 // Base58 encoding/decoding
21610 // Originally written by Mike Hearn for BitcoinJ
21611 // Copyright (c) 2011 Google Inc
21612 // Ported to JavaScript by Stefan Thomas
21613 // Merged Buffer refactorings from base58-native by Stephen Pair
21614 // Copyright (c) 2013 BitPay Inc
21615
21616 var assert = _dereq_('assert')
21617 var BigInteger = _dereq_('bigi')
21618
21619 var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
21620 var ALPHABET_BUF = new Buffer(ALPHABET, 'ascii')
21621 var ALPHABET_MAP = {}
21622 for(var i = 0; i < ALPHABET.length; i++) {
21623 ALPHABET_MAP[ALPHABET.charAt(i)] = BigInteger.valueOf(i)
21624 }
21625 var BASE = new BigInteger('58')
21626
21627 function encode(buffer) {
21628 var bi = BigInteger.fromBuffer(buffer)
21629 var result = new Buffer(buffer.length << 1)
21630
21631 var i = result.length - 1
21632 while (bi.signum() > 0) {
21633 var remainder = bi.mod(BASE)
21634 bi = bi.divide(BASE)
21635
21636 result[i] = ALPHABET_BUF[remainder.intValue()]
21637 i--
21638 }
21639
21640 // deal with leading zeros
21641 var j = 0
21642 while (buffer[j] === 0) {
21643 result[i] = ALPHABET_BUF[0]
21644 j++
21645 i--
21646 }
21647
21648 return result.slice(i + 1, result.length).toString('ascii')
21649 }
21650
21651 function decode(string) {
21652 if (string.length === 0) return new Buffer(0)
21653
21654 var num = BigInteger.ZERO
21655
21656 for (var i = 0; i < string.length; i++) {
21657 num = num.multiply(BASE)
21658
21659 var figure = ALPHABET_MAP[string.charAt(i)]
21660 assert.notEqual(figure, undefined, 'Non-base58 character')
21661
21662 num = num.add(figure)
21663 }
21664
21665 // deal with leading zeros
21666 var j = 0
21667 while ((j < string.length) && (string[j] === ALPHABET[0])) {
21668 j++
21669 }
21670
21671 var buffer = num.toBuffer()
21672 var leadingZeros = new Buffer(j)
21673 leadingZeros.fill(0)
21674
21675 return Buffer.concat([leadingZeros, buffer])
21676 }
21677
21678 module.exports = {
21679 encode: encode,
21680 decode: decode
21681 }
21682
21683 }).call(this,_dereq_("buffer").Buffer)
21684 },{"assert":4,"bigi":3,"buffer":8}],16:[function(_dereq_,module,exports){
21685 (function (Buffer){
21686 var createHash = _dereq_('sha.js')
21687
21688 var md5 = toConstructor(_dereq_('./md5'))
21689 var rmd160 = toConstructor(_dereq_('ripemd160'))
21690
21691 function toConstructor (fn) {
21692 return function () {
21693 var buffers = []
21694 var m= {
21695 update: function (data, enc) {
21696 if(!Buffer.isBuffer(data)) data = new Buffer(data, enc)
21697 buffers.push(data)
21698 return this
21699 },
21700 digest: function (enc) {
21701 var buf = Buffer.concat(buffers)
21702 var r = fn(buf)
21703 buffers = null
21704 return enc ? r.toString(enc) : r
21705 }
21706 }
21707 return m
21708 }
21709 }
21710
21711 module.exports = function (alg) {
21712 if('md5' === alg) return new md5()
21713 if('rmd160' === alg) return new rmd160()
21714 return createHash(alg)
21715 }
21716
21717 }).call(this,_dereq_("buffer").Buffer)
21718 },{"./md5":20,"buffer":8,"ripemd160":21,"sha.js":23}],17:[function(_dereq_,module,exports){
21719 (function (Buffer){
21720 var createHash = _dereq_('./create-hash')
21721
21722 var blocksize = 64
21723 var zeroBuffer = new Buffer(blocksize); zeroBuffer.fill(0)
21724
21725 module.exports = Hmac
21726
21727 function Hmac (alg, key) {
21728 if(!(this instanceof Hmac)) return new Hmac(alg, key)
21729 this._opad = opad
21730 this._alg = alg
21731
21732 key = this._key = !Buffer.isBuffer(key) ? new Buffer(key) : key
21733
21734 if(key.length > blocksize) {
21735 key = createHash(alg).update(key).digest()
21736 } else if(key.length < blocksize) {
21737 key = Buffer.concat([key, zeroBuffer], blocksize)
21738 }
21739
21740 var ipad = this._ipad = new Buffer(blocksize)
21741 var opad = this._opad = new Buffer(blocksize)
21742
21743 for(var i = 0; i < blocksize; i++) {
21744 ipad[i] = key[i] ^ 0x36
21745 opad[i] = key[i] ^ 0x5C
21746 }
21747
21748 this._hash = createHash(alg).update(ipad)
21749 }
21750
21751 Hmac.prototype.update = function (data, enc) {
21752 this._hash.update(data, enc)
21753 return this
21754 }
21755
21756 Hmac.prototype.digest = function (enc) {
21757 var h = this._hash.digest()
21758 return createHash(this._alg).update(this._opad).update(h).digest(enc)
21759 }
21760
21761
21762 }).call(this,_dereq_("buffer").Buffer)
21763 },{"./create-hash":16,"buffer":8}],18:[function(_dereq_,module,exports){
21764 (function (Buffer){
21765 var intSize = 4;
21766 var zeroBuffer = new Buffer(intSize); zeroBuffer.fill(0);
21767 var chrsz = 8;
21768
21769 function toArray(buf, bigEndian) {
21770 if ((buf.length % intSize) !== 0) {
21771 var len = buf.length + (intSize - (buf.length % intSize));
21772 buf = Buffer.concat([buf, zeroBuffer], len);
21773 }
21774
21775 var arr = [];
21776 var fn = bigEndian ? buf.readInt32BE : buf.readInt32LE;
21777 for (var i = 0; i < buf.length; i += intSize) {
21778 arr.push(fn.call(buf, i));
21779 }
21780 return arr;
21781 }
21782
21783 function toBuffer(arr, size, bigEndian) {
21784 var buf = new Buffer(size);
21785 var fn = bigEndian ? buf.writeInt32BE : buf.writeInt32LE;
21786 for (var i = 0; i < arr.length; i++) {
21787 fn.call(buf, arr[i], i * 4, true);
21788 }
21789 return buf;
21790 }
21791
21792 function hash(buf, fn, hashSize, bigEndian) {
21793 if (!Buffer.isBuffer(buf)) buf = new Buffer(buf);
21794 var arr = fn(toArray(buf, bigEndian), buf.length * chrsz);
21795 return toBuffer(arr, hashSize, bigEndian);
21796 }
21797
21798 module.exports = { hash: hash };
21799
21800 }).call(this,_dereq_("buffer").Buffer)
21801 },{"buffer":8}],19:[function(_dereq_,module,exports){
21802 (function (Buffer){
21803 var rng = _dereq_('./rng')
21804
21805 function error () {
21806 var m = [].slice.call(arguments).join(' ')
21807 throw new Error([
21808 m,
21809 'we accept pull requests',
21810 'http://github.com/dominictarr/crypto-browserify'
21811 ].join('\n'))
21812 }
21813
21814 exports.createHash = _dereq_('./create-hash')
21815
21816 exports.createHmac = _dereq_('./create-hmac')
21817
21818 exports.randomBytes = function(size, callback) {
21819 if (callback && callback.call) {
21820 try {
21821 callback.call(this, undefined, new Buffer(rng(size)))
21822 } catch (err) { callback(err) }
21823 } else {
21824 return new Buffer(rng(size))
21825 }
21826 }
21827
21828 function each(a, f) {
21829 for(var i in a)
21830 f(a[i], i)
21831 }
21832
21833 exports.getHashes = function () {
21834 return ['sha1', 'sha256', 'md5', 'rmd160']
21835
21836 }
21837
21838 var p = _dereq_('./pbkdf2')(exports.createHmac)
21839 exports.pbkdf2 = p.pbkdf2
21840 exports.pbkdf2Sync = p.pbkdf2Sync
21841
21842
21843 // the least I can do is make error messages for the rest of the node.js/crypto api.
21844 each(['createCredentials'
21845 , 'createCipher'
21846 , 'createCipheriv'
21847 , 'createDecipher'
21848 , 'createDecipheriv'
21849 , 'createSign'
21850 , 'createVerify'
21851 , 'createDiffieHellman'
21852 ], function (name) {
21853 exports[name] = function () {
21854 error('sorry,', name, 'is not implemented yet')
21855 }
21856 })
21857
21858 }).call(this,_dereq_("buffer").Buffer)
21859 },{"./create-hash":16,"./create-hmac":17,"./pbkdf2":27,"./rng":28,"buffer":8}],20:[function(_dereq_,module,exports){
21860 /*
21861 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
21862 * Digest Algorithm, as defined in RFC 1321.
21863 * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
21864 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
21865 * Distributed under the BSD License
21866 * See http://pajhome.org.uk/crypt/md5 for more info.
21867 */
21868
21869 var helpers = _dereq_('./helpers');
21870
21871 /*
21872 * Calculate the MD5 of an array of little-endian words, and a bit length
21873 */
21874 function core_md5(x, len)
21875 {
21876 /* append padding */
21877 x[len >> 5] |= 0x80 << ((len) % 32);
21878 x[(((len + 64) >>> 9) << 4) + 14] = len;
21879
21880 var a = 1732584193;
21881 var b = -271733879;
21882 var c = -1732584194;
21883 var d = 271733878;
21884
21885 for(var i = 0; i < x.length; i += 16)
21886 {
21887 var olda = a;
21888 var oldb = b;
21889 var oldc = c;
21890 var oldd = d;
21891
21892 a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
21893 d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
21894 c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
21895 b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
21896 a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
21897 d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
21898 c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
21899 b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
21900 a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
21901 d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
21902 c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
21903 b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
21904 a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
21905 d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
21906 c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
21907 b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
21908
21909 a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
21910 d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
21911 c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
21912 b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
21913 a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
21914 d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
21915 c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
21916 b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
21917 a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
21918 d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
21919 c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
21920 b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
21921 a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
21922 d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
21923 c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
21924 b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
21925
21926 a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
21927 d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
21928 c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
21929 b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
21930 a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
21931 d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
21932 c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
21933 b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
21934 a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
21935 d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
21936 c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
21937 b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
21938 a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
21939 d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
21940 c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
21941 b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
21942
21943 a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
21944 d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
21945 c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
21946 b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
21947 a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
21948 d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
21949 c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
21950 b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
21951 a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
21952 d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
21953 c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
21954 b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
21955 a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
21956 d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
21957 c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
21958 b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
21959
21960 a = safe_add(a, olda);
21961 b = safe_add(b, oldb);
21962 c = safe_add(c, oldc);
21963 d = safe_add(d, oldd);
21964 }
21965 return Array(a, b, c, d);
21966
21967 }
21968
21969 /*
21970 * These functions implement the four basic operations the algorithm uses.
21971 */
21972 function md5_cmn(q, a, b, x, s, t)
21973 {
21974 return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
21975 }
21976 function md5_ff(a, b, c, d, x, s, t)
21977 {
21978 return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
21979 }
21980 function md5_gg(a, b, c, d, x, s, t)
21981 {
21982 return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
21983 }
21984 function md5_hh(a, b, c, d, x, s, t)
21985 {
21986 return md5_cmn(b ^ c ^ d, a, b, x, s, t);
21987 }
21988 function md5_ii(a, b, c, d, x, s, t)
21989 {
21990 return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
21991 }
21992
21993 /*
21994 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
21995 * to work around bugs in some JS interpreters.
21996 */
21997 function safe_add(x, y)
21998 {
21999 var lsw = (x & 0xFFFF) + (y & 0xFFFF);
22000 var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
22001 return (msw << 16) | (lsw & 0xFFFF);
22002 }
22003
22004 /*
22005 * Bitwise rotate a 32-bit number to the left.
22006 */
22007 function bit_rol(num, cnt)
22008 {
22009 return (num << cnt) | (num >>> (32 - cnt));
22010 }
22011
22012 module.exports = function md5(buf) {
22013 return helpers.hash(buf, core_md5, 16);
22014 };
22015
22016 },{"./helpers":18}],21:[function(_dereq_,module,exports){
22017 (function (Buffer){
22018
22019 module.exports = ripemd160
22020
22021
22022
22023 /*
22024 CryptoJS v3.1.2
22025 code.google.com/p/crypto-js
22026 (c) 2009-2013 by Jeff Mott. All rights reserved.
22027 code.google.com/p/crypto-js/wiki/License
22028 */
22029 /** @preserve
22030 (c) 2012 by Cédric Mesnil. All rights reserved.
22031
22032 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
22033
22034 - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
22035 - 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.
22036
22037 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.
22038 */
22039
22040 // Constants table
22041 var zl = [
22042 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
22043 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
22044 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
22045 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
22046 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13];
22047 var zr = [
22048 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
22049 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
22050 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
22051 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
22052 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11];
22053 var sl = [
22054 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
22055 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
22056 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
22057 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
22058 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ];
22059 var sr = [
22060 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
22061 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
22062 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
22063 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
22064 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ];
22065
22066 var hl = [ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E];
22067 var hr = [ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000];
22068
22069 var bytesToWords = function (bytes) {
22070 var words = [];
22071 for (var i = 0, b = 0; i < bytes.length; i++, b += 8) {
22072 words[b >>> 5] |= bytes[i] << (24 - b % 32);
22073 }
22074 return words;
22075 };
22076
22077 var wordsToBytes = function (words) {
22078 var bytes = [];
22079 for (var b = 0; b < words.length * 32; b += 8) {
22080 bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF);
22081 }
22082 return bytes;
22083 };
22084
22085 var processBlock = function (H, M, offset) {
22086
22087 // Swap endian
22088 for (var i = 0; i < 16; i++) {
22089 var offset_i = offset + i;
22090 var M_offset_i = M[offset_i];
22091
22092 // Swap
22093 M[offset_i] = (
22094 (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
22095 (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
22096 );
22097 }
22098
22099 // Working variables
22100 var al, bl, cl, dl, el;
22101 var ar, br, cr, dr, er;
22102
22103 ar = al = H[0];
22104 br = bl = H[1];
22105 cr = cl = H[2];
22106 dr = dl = H[3];
22107 er = el = H[4];
22108 // Computation
22109 var t;
22110 for (var i = 0; i < 80; i += 1) {
22111 t = (al + M[offset+zl[i]])|0;
22112 if (i<16){
22113 t += f1(bl,cl,dl) + hl[0];
22114 } else if (i<32) {
22115 t += f2(bl,cl,dl) + hl[1];
22116 } else if (i<48) {
22117 t += f3(bl,cl,dl) + hl[2];
22118 } else if (i<64) {
22119 t += f4(bl,cl,dl) + hl[3];
22120 } else {// if (i<80) {
22121 t += f5(bl,cl,dl) + hl[4];
22122 }
22123 t = t|0;
22124 t = rotl(t,sl[i]);
22125 t = (t+el)|0;
22126 al = el;
22127 el = dl;
22128 dl = rotl(cl, 10);
22129 cl = bl;
22130 bl = t;
22131
22132 t = (ar + M[offset+zr[i]])|0;
22133 if (i<16){
22134 t += f5(br,cr,dr) + hr[0];
22135 } else if (i<32) {
22136 t += f4(br,cr,dr) + hr[1];
22137 } else if (i<48) {
22138 t += f3(br,cr,dr) + hr[2];
22139 } else if (i<64) {
22140 t += f2(br,cr,dr) + hr[3];
22141 } else {// if (i<80) {
22142 t += f1(br,cr,dr) + hr[4];
22143 }
22144 t = t|0;
22145 t = rotl(t,sr[i]) ;
22146 t = (t+er)|0;
22147 ar = er;
22148 er = dr;
22149 dr = rotl(cr, 10);
22150 cr = br;
22151 br = t;
22152 }
22153 // Intermediate hash value
22154 t = (H[1] + cl + dr)|0;
22155 H[1] = (H[2] + dl + er)|0;
22156 H[2] = (H[3] + el + ar)|0;
22157 H[3] = (H[4] + al + br)|0;
22158 H[4] = (H[0] + bl + cr)|0;
22159 H[0] = t;
22160 };
22161
22162 function f1(x, y, z) {
22163 return ((x) ^ (y) ^ (z));
22164 }
22165
22166 function f2(x, y, z) {
22167 return (((x)&(y)) | ((~x)&(z)));
22168 }
22169
22170 function f3(x, y, z) {
22171 return (((x) | (~(y))) ^ (z));
22172 }
22173
22174 function f4(x, y, z) {
22175 return (((x) & (z)) | ((y)&(~(z))));
22176 }
22177
22178 function f5(x, y, z) {
22179 return ((x) ^ ((y) |(~(z))));
22180 }
22181
22182 function rotl(x,n) {
22183 return (x<<n) | (x>>>(32-n));
22184 }
22185
22186 function ripemd160(message) {
22187 var H = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0];
22188
22189 if (typeof message == 'string')
22190 message = new Buffer(message, 'utf8');
22191
22192 var m = bytesToWords(message);
22193
22194 var nBitsLeft = message.length * 8;
22195 var nBitsTotal = message.length * 8;
22196
22197 // Add padding
22198 m[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
22199 m[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
22200 (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
22201 (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)
22202 );
22203
22204 for (var i=0 ; i<m.length; i += 16) {
22205 processBlock(H, m, i);
22206 }
22207
22208 // Swap endian
22209 for (var i = 0; i < 5; i++) {
22210 // Shortcut
22211 var H_i = H[i];
22212
22213 // Swap
22214 H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
22215 (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
22216 }
22217
22218 var digestbytes = wordsToBytes(H);
22219 return new Buffer(digestbytes);
22220 }
22221
22222
22223
22224 }).call(this,_dereq_("buffer").Buffer)
22225 },{"buffer":8}],22:[function(_dereq_,module,exports){
22226 var u = _dereq_('./util')
22227 var write = u.write
22228 var fill = u.zeroFill
22229
22230 module.exports = function (Buffer) {
22231
22232 //prototype class for hash functions
22233 function Hash (blockSize, finalSize) {
22234 this._block = new Buffer(blockSize) //new Uint32Array(blockSize/4)
22235 this._finalSize = finalSize
22236 this._blockSize = blockSize
22237 this._len = 0
22238 this._s = 0
22239 }
22240
22241 Hash.prototype.init = function () {
22242 this._s = 0
22243 this._len = 0
22244 }
22245
22246 function lengthOf(data, enc) {
22247 if(enc == null) return data.byteLength || data.length
22248 if(enc == 'ascii' || enc == 'binary') return data.length
22249 if(enc == 'hex') return data.length/2
22250 if(enc == 'base64') return data.length/3
22251 }
22252
22253 Hash.prototype.update = function (data, enc) {
22254 var bl = this._blockSize
22255
22256 //I'd rather do this with a streaming encoder, like the opposite of
22257 //http://nodejs.org/api/string_decoder.html
22258 var length
22259 if(!enc && 'string' === typeof data)
22260 enc = 'utf8'
22261
22262 if(enc) {
22263 if(enc === 'utf-8')
22264 enc = 'utf8'
22265
22266 if(enc === 'base64' || enc === 'utf8')
22267 data = new Buffer(data, enc), enc = null
22268
22269 length = lengthOf(data, enc)
22270 } else
22271 length = data.byteLength || data.length
22272
22273 var l = this._len += length
22274 var s = this._s = (this._s || 0)
22275 var f = 0
22276 var buffer = this._block
22277 while(s < l) {
22278 var t = Math.min(length, f + bl)
22279 write(buffer, data, enc, s%bl, f, t)
22280 var ch = (t - f);
22281 s += ch; f += ch
22282
22283 if(!(s%bl))
22284 this._update(buffer)
22285 }
22286 this._s = s
22287
22288 return this
22289
22290 }
22291
22292 Hash.prototype.digest = function (enc) {
22293 var bl = this._blockSize
22294 var fl = this._finalSize
22295 var len = this._len*8
22296
22297 var x = this._block
22298
22299 var bits = len % (bl*8)
22300
22301 //add end marker, so that appending 0's creats a different hash.
22302 x[this._len % bl] = 0x80
22303 fill(this._block, this._len % bl + 1)
22304
22305 if(bits >= fl*8) {
22306 this._update(this._block)
22307 u.zeroFill(this._block, 0)
22308 }
22309
22310 //TODO: handle case where the bit length is > Math.pow(2, 29)
22311 x.writeInt32BE(len, fl + 4) //big endian
22312
22313 var hash = this._update(this._block) || this._hash()
22314 if(enc == null) return hash
22315 return hash.toString(enc)
22316 }
22317
22318 Hash.prototype._update = function () {
22319 throw new Error('_update must be implemented by subclass')
22320 }
22321
22322 return Hash
22323 }
22324
22325 },{"./util":26}],23:[function(_dereq_,module,exports){
22326 var exports = module.exports = function (alg) {
22327 var Alg = exports[alg]
22328 if(!Alg) throw new Error(alg + ' is not supported (we accept pull requests)')
22329 return new Alg()
22330 }
22331
22332 var Buffer = _dereq_('buffer').Buffer
22333 var Hash = _dereq_('./hash')(Buffer)
22334
22335 exports.sha =
22336 exports.sha1 = _dereq_('./sha1')(Buffer, Hash)
22337 exports.sha256 = _dereq_('./sha256')(Buffer, Hash)
22338
22339 },{"./hash":22,"./sha1":24,"./sha256":25,"buffer":8}],24:[function(_dereq_,module,exports){
22340 /*
22341 * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
22342 * in FIPS PUB 180-1
22343 * Version 2.1a Copyright Paul Johnston 2000 - 2002.
22344 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
22345 * Distributed under the BSD License
22346 * See http://pajhome.org.uk/crypt/md5 for details.
22347 */
22348 module.exports = function (Buffer, Hash) {
22349
22350 var inherits = _dereq_('util').inherits
22351
22352 inherits(Sha1, Hash)
22353
22354 var A = 0|0
22355 var B = 4|0
22356 var C = 8|0
22357 var D = 12|0
22358 var E = 16|0
22359
22360 var BE = false
22361 var LE = true
22362
22363 var W = new Int32Array(80)
22364
22365 var POOL = []
22366
22367 function Sha1 () {
22368 if(POOL.length)
22369 return POOL.pop().init()
22370
22371 if(!(this instanceof Sha1)) return new Sha1()
22372 this._w = W
22373 Hash.call(this, 16*4, 14*4)
22374
22375 this._h = null
22376 this.init()
22377 }
22378
22379 Sha1.prototype.init = function () {
22380 this._a = 0x67452301
22381 this._b = 0xefcdab89
22382 this._c = 0x98badcfe
22383 this._d = 0x10325476
22384 this._e = 0xc3d2e1f0
22385
22386 Hash.prototype.init.call(this)
22387 return this
22388 }
22389
22390 Sha1.prototype._POOL = POOL
22391
22392 // assume that array is a Uint32Array with length=16,
22393 // and that if it is the last block, it already has the length and the 1 bit appended.
22394
22395
22396 var isDV = new Buffer(1) instanceof DataView
22397 function readInt32BE (X, i) {
22398 return isDV
22399 ? X.getInt32(i, false)
22400 : X.readInt32BE(i)
22401 }
22402
22403 Sha1.prototype._update = function (array) {
22404
22405 var X = this._block
22406 var h = this._h
22407 var a, b, c, d, e, _a, _b, _c, _d, _e
22408
22409 a = _a = this._a
22410 b = _b = this._b
22411 c = _c = this._c
22412 d = _d = this._d
22413 e = _e = this._e
22414
22415 var w = this._w
22416
22417 for(var j = 0; j < 80; j++) {
22418 var W = w[j]
22419 = j < 16
22420 //? X.getInt32(j*4, false)
22421 //? readInt32BE(X, j*4) //*/ X.readInt32BE(j*4) //*/
22422 ? X.readInt32BE(j*4)
22423 : rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1)
22424
22425 var t =
22426 add(
22427 add(rol(a, 5), sha1_ft(j, b, c, d)),
22428 add(add(e, W), sha1_kt(j))
22429 );
22430
22431 e = d
22432 d = c
22433 c = rol(b, 30)
22434 b = a
22435 a = t
22436 }
22437
22438 this._a = add(a, _a)
22439 this._b = add(b, _b)
22440 this._c = add(c, _c)
22441 this._d = add(d, _d)
22442 this._e = add(e, _e)
22443 }
22444
22445 Sha1.prototype._hash = function () {
22446 if(POOL.length < 100) POOL.push(this)
22447 var H = new Buffer(20)
22448 //console.log(this._a|0, this._b|0, this._c|0, this._d|0, this._e|0)
22449 H.writeInt32BE(this._a|0, A)
22450 H.writeInt32BE(this._b|0, B)
22451 H.writeInt32BE(this._c|0, C)
22452 H.writeInt32BE(this._d|0, D)
22453 H.writeInt32BE(this._e|0, E)
22454 return H
22455 }
22456
22457 /*
22458 * Perform the appropriate triplet combination function for the current
22459 * iteration
22460 */
22461 function sha1_ft(t, b, c, d) {
22462 if(t < 20) return (b & c) | ((~b) & d);
22463 if(t < 40) return b ^ c ^ d;
22464 if(t < 60) return (b & c) | (b & d) | (c & d);
22465 return b ^ c ^ d;
22466 }
22467
22468 /*
22469 * Determine the appropriate additive constant for the current iteration
22470 */
22471 function sha1_kt(t) {
22472 return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :
22473 (t < 60) ? -1894007588 : -899497514;
22474 }
22475
22476 /*
22477 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
22478 * to work around bugs in some JS interpreters.
22479 * //dominictarr: this is 10 years old, so maybe this can be dropped?)
22480 *
22481 */
22482 function add(x, y) {
22483 return (x + y ) | 0
22484 //lets see how this goes on testling.
22485 // var lsw = (x & 0xFFFF) + (y & 0xFFFF);
22486 // var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
22487 // return (msw << 16) | (lsw & 0xFFFF);
22488 }
22489
22490 /*
22491 * Bitwise rotate a 32-bit number to the left.
22492 */
22493 function rol(num, cnt) {
22494 return (num << cnt) | (num >>> (32 - cnt));
22495 }
22496
22497 return Sha1
22498 }
22499
22500 },{"util":14}],25:[function(_dereq_,module,exports){
22501
22502 /**
22503 * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
22504 * in FIPS 180-2
22505 * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
22506 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
22507 *
22508 */
22509
22510 var inherits = _dereq_('util').inherits
22511 var BE = false
22512 var LE = true
22513 var u = _dereq_('./util')
22514
22515 module.exports = function (Buffer, Hash) {
22516
22517 var K = [
22518 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
22519 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
22520 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
22521 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
22522 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
22523 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
22524 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
22525 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
22526 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
22527 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
22528 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
22529 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
22530 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
22531 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
22532 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
22533 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
22534 ]
22535
22536 inherits(Sha256, Hash)
22537 var W = new Array(64)
22538 var POOL = []
22539 function Sha256() {
22540 // Closure compiler warning - this code lacks side effects - thus commented out
22541 // if(POOL.length) {
22542 // return POOL.shift().init()
22543 // }
22544 //this._data = new Buffer(32)
22545
22546 this.init()
22547
22548 this._w = W //new Array(64)
22549
22550 Hash.call(this, 16*4, 14*4)
22551 };
22552
22553 Sha256.prototype.init = function () {
22554
22555 this._a = 0x6a09e667|0
22556 this._b = 0xbb67ae85|0
22557 this._c = 0x3c6ef372|0
22558 this._d = 0xa54ff53a|0
22559 this._e = 0x510e527f|0
22560 this._f = 0x9b05688c|0
22561 this._g = 0x1f83d9ab|0
22562 this._h = 0x5be0cd19|0
22563
22564 this._len = this._s = 0
22565
22566 return this
22567 }
22568
22569 var safe_add = function(x, y) {
22570 var lsw = (x & 0xFFFF) + (y & 0xFFFF);
22571 var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
22572 return (msw << 16) | (lsw & 0xFFFF);
22573 }
22574
22575 function S (X, n) {
22576 return (X >>> n) | (X << (32 - n));
22577 }
22578
22579 function R (X, n) {
22580 return (X >>> n);
22581 }
22582
22583 function Ch (x, y, z) {
22584 return ((x & y) ^ ((~x) & z));
22585 }
22586
22587 function Maj (x, y, z) {
22588 return ((x & y) ^ (x & z) ^ (y & z));
22589 }
22590
22591 function Sigma0256 (x) {
22592 return (S(x, 2) ^ S(x, 13) ^ S(x, 22));
22593 }
22594
22595 function Sigma1256 (x) {
22596 return (S(x, 6) ^ S(x, 11) ^ S(x, 25));
22597 }
22598
22599 function Gamma0256 (x) {
22600 return (S(x, 7) ^ S(x, 18) ^ R(x, 3));
22601 }
22602
22603 function Gamma1256 (x) {
22604 return (S(x, 17) ^ S(x, 19) ^ R(x, 10));
22605 }
22606
22607 Sha256.prototype._update = function(m) {
22608 var M = this._block
22609 var W = this._w
22610 var a, b, c, d, e, f, g, h
22611 var T1, T2
22612
22613 a = this._a | 0
22614 b = this._b | 0
22615 c = this._c | 0
22616 d = this._d | 0
22617 e = this._e | 0
22618 f = this._f | 0
22619 g = this._g | 0
22620 h = this._h | 0
22621
22622 for (var j = 0; j < 64; j++) {
22623 var w = W[j] = j < 16
22624 ? M.readInt32BE(j * 4)
22625 : Gamma1256(W[j - 2]) + W[j - 7] + Gamma0256(W[j - 15]) + W[j - 16]
22626
22627 T1 = h + Sigma1256(e) + Ch(e, f, g) + K[j] + w
22628
22629 T2 = Sigma0256(a) + Maj(a, b, c);
22630 h = g; g = f; f = e; e = d + T1; d = c; c = b; b = a; a = T1 + T2;
22631 }
22632
22633 this._a = (a + this._a) | 0
22634 this._b = (b + this._b) | 0
22635 this._c = (c + this._c) | 0
22636 this._d = (d + this._d) | 0
22637 this._e = (e + this._e) | 0
22638 this._f = (f + this._f) | 0
22639 this._g = (g + this._g) | 0
22640 this._h = (h + this._h) | 0
22641
22642 };
22643
22644 Sha256.prototype._hash = function () {
22645 if(POOL.length < 10)
22646 POOL.push(this)
22647
22648 var H = new Buffer(32)
22649
22650 H.writeInt32BE(this._a, 0)
22651 H.writeInt32BE(this._b, 4)
22652 H.writeInt32BE(this._c, 8)
22653 H.writeInt32BE(this._d, 12)
22654 H.writeInt32BE(this._e, 16)
22655 H.writeInt32BE(this._f, 20)
22656 H.writeInt32BE(this._g, 24)
22657 H.writeInt32BE(this._h, 28)
22658
22659 return H
22660 }
22661
22662 return Sha256
22663
22664 }
22665
22666 },{"./util":26,"util":14}],26:[function(_dereq_,module,exports){
22667 exports.write = write
22668 exports.zeroFill = zeroFill
22669
22670 exports.toString = toString
22671
22672 function write (buffer, string, enc, start, from, to, LE) {
22673 var l = (to - from)
22674 if(enc === 'ascii' || enc === 'binary') {
22675 for( var i = 0; i < l; i++) {
22676 buffer[start + i] = string.charCodeAt(i + from)
22677 }
22678 }
22679 else if(enc == null) {
22680 for( var i = 0; i < l; i++) {
22681 buffer[start + i] = string[i + from]
22682 }
22683 }
22684 else if(enc === 'hex') {
22685 for(var i = 0; i < l; i++) {
22686 var j = from + i
22687 buffer[start + i] = parseInt(string[j*2] + string[(j*2)+1], 16)
22688 }
22689 }
22690 else if(enc === 'base64') {
22691 throw new Error('base64 encoding not yet supported')
22692 }
22693 else
22694 throw new Error(enc +' encoding not yet supported')
22695 }
22696
22697 //always fill to the end!
22698 function zeroFill(buf, from) {
22699 for(var i = from; i < buf.length; i++)
22700 buf[i] = 0
22701 }
22702
22703
22704 },{}],27:[function(_dereq_,module,exports){
22705 (function (Buffer){
22706 // JavaScript PBKDF2 Implementation
22707 // Based on http://git.io/qsv2zw
22708 // Licensed under LGPL v3
22709 // Copyright (c) 2013 jduncanator
22710
22711 var blocksize = 64
22712 var zeroBuffer = new Buffer(blocksize); zeroBuffer.fill(0)
22713
22714 module.exports = function (createHmac, exports) {
22715 exports = exports || {}
22716
22717 exports.pbkdf2 = function(password, salt, iterations, keylen, cb) {
22718 if('function' !== typeof cb)
22719 throw new Error('No callback provided to pbkdf2');
22720 setTimeout(function () {
22721 cb(null, exports.pbkdf2Sync(password, salt, iterations, keylen))
22722 })
22723 }
22724
22725 exports.pbkdf2Sync = function(key, salt, iterations, keylen) {
22726 if('number' !== typeof iterations)
22727 throw new TypeError('Iterations not a number')
22728 if(iterations < 0)
22729 throw new TypeError('Bad iterations')
22730 if('number' !== typeof keylen)
22731 throw new TypeError('Key length not a number')
22732 if(keylen < 0)
22733 throw new TypeError('Bad key length')
22734
22735 //stretch key to the correct length that hmac wants it,
22736 //otherwise this will happen every time hmac is called
22737 //twice per iteration.
22738 var key = !Buffer.isBuffer(key) ? new Buffer(key) : key
22739
22740 if(key.length > blocksize) {
22741 key = createHash(alg).update(key).digest()
22742 } else if(key.length < blocksize) {
22743 key = Buffer.concat([key, zeroBuffer], blocksize)
22744 }
22745
22746 var HMAC;
22747 var cplen, p = 0, i = 1, itmp = new Buffer(4), digtmp;
22748 var out = new Buffer(keylen);
22749 out.fill(0);
22750 while(keylen) {
22751 if(keylen > 20)
22752 cplen = 20;
22753 else
22754 cplen = keylen;
22755
22756 /* We are unlikely to ever use more than 256 blocks (5120 bits!)
22757 * but just in case...
22758 */
22759 itmp[0] = (i >> 24) & 0xff;
22760 itmp[1] = (i >> 16) & 0xff;
22761 itmp[2] = (i >> 8) & 0xff;
22762 itmp[3] = i & 0xff;
22763
22764 HMAC = createHmac('sha1', key);
22765 HMAC.update(salt)
22766 HMAC.update(itmp);
22767 digtmp = HMAC.digest();
22768 digtmp.copy(out, p, 0, cplen);
22769
22770 for(var j = 1; j < iterations; j++) {
22771 HMAC = createHmac('sha1', key);
22772 HMAC.update(digtmp);
22773 digtmp = HMAC.digest();
22774 for(var k = 0; k < cplen; k++) {
22775 out[k] ^= digtmp[k];
22776 }
22777 }
22778 keylen -= cplen;
22779 i++;
22780 p += cplen;
22781 }
22782
22783 return out;
22784 }
22785
22786 return exports
22787 }
22788
22789 }).call(this,_dereq_("buffer").Buffer)
22790 },{"buffer":8}],28:[function(_dereq_,module,exports){
22791 (function (Buffer){
22792 // Original code adapted from Robert Kieffer.
22793 // details at https://github.com/broofa/node-uuid
22794
22795
22796 (function() {
22797 var _global = this;
22798
22799 var mathRNG, whatwgRNG;
22800
22801 // NOTE: Math.random() does not guarantee "cryptographic quality"
22802 mathRNG = function(size) {
22803 var bytes = new Buffer(size);
22804 var r;
22805
22806 for (var i = 0, r; i < size; i++) {
22807 if ((i & 0x03) == 0) r = Math.random() * 0x100000000;
22808 bytes[i] = r >>> ((i & 0x03) << 3) & 0xff;
22809 }
22810
22811 return bytes;
22812 }
22813
22814 if (_global.crypto && crypto.getRandomValues) {
22815 whatwgRNG = function(size) {
22816 var bytes = new Buffer(size); //in browserify, this is an extended Uint8Array
22817 crypto.getRandomValues(bytes);
22818 return bytes;
22819 }
22820 }
22821
22822 module.exports = whatwgRNG || mathRNG;
22823
22824 }())
22825
22826 }).call(this,_dereq_("buffer").Buffer)
22827 },{"buffer":8}],29:[function(_dereq_,module,exports){
22828 ;(function (root, factory, undef) {
22829 if (typeof exports === "object") {
22830 // CommonJS
22831 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
22832 }
22833 else if (typeof define === "function" && define.amd) {
22834 // AMD
22835 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
22836 }
22837 else {
22838 // Global (browser)
22839 factory(root.CryptoJS);
22840 }
22841 }(this, function (CryptoJS) {
22842
22843 (function () {
22844 // Shortcuts
22845 var C = CryptoJS;
22846 var C_lib = C.lib;
22847 var BlockCipher = C_lib.BlockCipher;
22848 var C_algo = C.algo;
22849
22850 // Lookup tables
22851 var SBOX = [];
22852 var INV_SBOX = [];
22853 var SUB_MIX_0 = [];
22854 var SUB_MIX_1 = [];
22855 var SUB_MIX_2 = [];
22856 var SUB_MIX_3 = [];
22857 var INV_SUB_MIX_0 = [];
22858 var INV_SUB_MIX_1 = [];
22859 var INV_SUB_MIX_2 = [];
22860 var INV_SUB_MIX_3 = [];
22861
22862 // Compute lookup tables
22863 (function () {
22864 // Compute double table
22865 var d = [];
22866 for (var i = 0; i < 256; i++) {
22867 if (i < 128) {
22868 d[i] = i << 1;
22869 } else {
22870 d[i] = (i << 1) ^ 0x11b;
22871 }
22872 }
22873
22874 // Walk GF(2^8)
22875 var x = 0;
22876 var xi = 0;
22877 for (var i = 0; i < 256; i++) {
22878 // Compute sbox
22879 var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
22880 sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
22881 SBOX[x] = sx;
22882 INV_SBOX[sx] = x;
22883
22884 // Compute multiplication
22885 var x2 = d[x];
22886 var x4 = d[x2];
22887 var x8 = d[x4];
22888
22889 // Compute sub bytes, mix columns tables
22890 var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
22891 SUB_MIX_0[x] = (t << 24) | (t >>> 8);
22892 SUB_MIX_1[x] = (t << 16) | (t >>> 16);
22893 SUB_MIX_2[x] = (t << 8) | (t >>> 24);
22894 SUB_MIX_3[x] = t;
22895
22896 // Compute inv sub bytes, inv mix columns tables
22897 var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
22898 INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
22899 INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
22900 INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
22901 INV_SUB_MIX_3[sx] = t;
22902
22903 // Compute next counter
22904 if (!x) {
22905 x = xi = 1;
22906 } else {
22907 x = x2 ^ d[d[d[x8 ^ x2]]];
22908 xi ^= d[d[xi]];
22909 }
22910 }
22911 }());
22912
22913 // Precomputed Rcon lookup
22914 var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
22915
22916 /**
22917 * AES block cipher algorithm.
22918 */
22919 var AES = C_algo.AES = BlockCipher.extend({
22920 _doReset: function () {
22921 // Shortcuts
22922 var key = this._key;
22923 var keyWords = key.words;
22924 var keySize = key.sigBytes / 4;
22925
22926 // Compute number of rounds
22927 var nRounds = this._nRounds = keySize + 6
22928
22929 // Compute number of key schedule rows
22930 var ksRows = (nRounds + 1) * 4;
22931
22932 // Compute key schedule
22933 var keySchedule = this._keySchedule = [];
22934 for (var ksRow = 0; ksRow < ksRows; ksRow++) {
22935 if (ksRow < keySize) {
22936 keySchedule[ksRow] = keyWords[ksRow];
22937 } else {
22938 var t = keySchedule[ksRow - 1];
22939
22940 if (!(ksRow % keySize)) {
22941 // Rot word
22942 t = (t << 8) | (t >>> 24);
22943
22944 // Sub word
22945 t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
22946
22947 // Mix Rcon
22948 t ^= RCON[(ksRow / keySize) | 0] << 24;
22949 } else if (keySize > 6 && ksRow % keySize == 4) {
22950 // Sub word
22951 t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
22952 }
22953
22954 keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
22955 }
22956 }
22957
22958 // Compute inv key schedule
22959 var invKeySchedule = this._invKeySchedule = [];
22960 for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
22961 var ksRow = ksRows - invKsRow;
22962
22963 if (invKsRow % 4) {
22964 var t = keySchedule[ksRow];
22965 } else {
22966 var t = keySchedule[ksRow - 4];
22967 }
22968
22969 if (invKsRow < 4 || ksRow <= 4) {
22970 invKeySchedule[invKsRow] = t;
22971 } else {
22972 invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
22973 INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
22974 }
22975 }
22976 },
22977
22978 encryptBlock: function (M, offset) {
22979 this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
22980 },
22981
22982 decryptBlock: function (M, offset) {
22983 // Swap 2nd and 4th rows
22984 var t = M[offset + 1];
22985 M[offset + 1] = M[offset + 3];
22986 M[offset + 3] = t;
22987
22988 this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
22989
22990 // Inv swap 2nd and 4th rows
22991 var t = M[offset + 1];
22992 M[offset + 1] = M[offset + 3];
22993 M[offset + 3] = t;
22994 },
22995
22996 _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
22997 // Shortcut
22998 var nRounds = this._nRounds;
22999
23000 // Get input, add round key
23001 var s0 = M[offset] ^ keySchedule[0];
23002 var s1 = M[offset + 1] ^ keySchedule[1];
23003 var s2 = M[offset + 2] ^ keySchedule[2];
23004 var s3 = M[offset + 3] ^ keySchedule[3];
23005
23006 // Key schedule row counter
23007 var ksRow = 4;
23008
23009 // Rounds
23010 for (var round = 1; round < nRounds; round++) {
23011 // Shift rows, sub bytes, mix columns, add round key
23012 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++];
23013 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++];
23014 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++];
23015 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++];
23016
23017 // Update state
23018 s0 = t0;
23019 s1 = t1;
23020 s2 = t2;
23021 s3 = t3;
23022 }
23023
23024 // Shift rows, sub bytes, add round key
23025 var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
23026 var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
23027 var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
23028 var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
23029
23030 // Set output
23031 M[offset] = t0;
23032 M[offset + 1] = t1;
23033 M[offset + 2] = t2;
23034 M[offset + 3] = t3;
23035 },
23036
23037 keySize: 256/32
23038 });
23039
23040 /**
23041 * Shortcut functions to the cipher's object interface.
23042 *
23043 * @example
23044 *
23045 * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
23046 * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
23047 */
23048 C.AES = BlockCipher._createHelper(AES);
23049 }());
23050
23051
23052 return CryptoJS.AES;
23053
23054 }));
23055 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],30:[function(_dereq_,module,exports){
23056 ;(function (root, factory) {
23057 if (typeof exports === "object") {
23058 // CommonJS
23059 module.exports = exports = factory(_dereq_("./core"));
23060 }
23061 else if (typeof define === "function" && define.amd) {
23062 // AMD
23063 define(["./core"], factory);
23064 }
23065 else {
23066 // Global (browser)
23067 factory(root.CryptoJS);
23068 }
23069 }(this, function (CryptoJS) {
23070
23071 /**
23072 * Cipher core components.
23073 */
23074 CryptoJS.lib.Cipher || (function (undefined) {
23075 // Shortcuts
23076 var C = CryptoJS;
23077 var C_lib = C.lib;
23078 var Base = C_lib.Base;
23079 var WordArray = C_lib.WordArray;
23080 var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
23081 var C_enc = C.enc;
23082 var Utf8 = C_enc.Utf8;
23083 var Base64 = C_enc.Base64;
23084 var C_algo = C.algo;
23085 var EvpKDF = C_algo.EvpKDF;
23086
23087 /**
23088 * Abstract base cipher template.
23089 *
23090 * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
23091 * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
23092 * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
23093 * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
23094 */
23095 var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
23096 /**
23097 * Configuration options.
23098 *
23099 * @property {WordArray} iv The IV to use for this operation.
23100 */
23101 cfg: Base.extend(),
23102
23103 /**
23104 * Creates this cipher in encryption mode.
23105 *
23106 * @param {WordArray} key The key.
23107 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23108 *
23109 * @return {Cipher} A cipher instance.
23110 *
23111 * @static
23112 *
23113 * @example
23114 *
23115 * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
23116 */
23117 createEncryptor: function (key, cfg) {
23118 return this.create(this._ENC_XFORM_MODE, key, cfg);
23119 },
23120
23121 /**
23122 * Creates this cipher in decryption mode.
23123 *
23124 * @param {WordArray} key The key.
23125 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23126 *
23127 * @return {Cipher} A cipher instance.
23128 *
23129 * @static
23130 *
23131 * @example
23132 *
23133 * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
23134 */
23135 createDecryptor: function (key, cfg) {
23136 return this.create(this._DEC_XFORM_MODE, key, cfg);
23137 },
23138
23139 /**
23140 * Initializes a newly created cipher.
23141 *
23142 * @param {number} xformMode Either the encryption or decryption transormation mode constant.
23143 * @param {WordArray} key The key.
23144 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23145 *
23146 * @example
23147 *
23148 * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
23149 */
23150 init: function (xformMode, key, cfg) {
23151 // Apply config defaults
23152 this.cfg = this.cfg.extend(cfg);
23153
23154 // Store transform mode and key
23155 this._xformMode = xformMode;
23156 this._key = key;
23157
23158 // Set initial values
23159 this.reset();
23160 },
23161
23162 /**
23163 * Resets this cipher to its initial state.
23164 *
23165 * @example
23166 *
23167 * cipher.reset();
23168 */
23169 reset: function () {
23170 // Reset data buffer
23171 BufferedBlockAlgorithm.reset.call(this);
23172
23173 // Perform concrete-cipher logic
23174 this._doReset();
23175 },
23176
23177 /**
23178 * Adds data to be encrypted or decrypted.
23179 *
23180 * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
23181 *
23182 * @return {WordArray} The data after processing.
23183 *
23184 * @example
23185 *
23186 * var encrypted = cipher.process('data');
23187 * var encrypted = cipher.process(wordArray);
23188 */
23189 process: function (dataUpdate) {
23190 // Append
23191 this._append(dataUpdate);
23192
23193 // Process available blocks
23194 return this._process();
23195 },
23196
23197 /**
23198 * Finalizes the encryption or decryption process.
23199 * Note that the finalize operation is effectively a destructive, read-once operation.
23200 *
23201 * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
23202 *
23203 * @return {WordArray} The data after final processing.
23204 *
23205 * @example
23206 *
23207 * var encrypted = cipher.finalize();
23208 * var encrypted = cipher.finalize('data');
23209 * var encrypted = cipher.finalize(wordArray);
23210 */
23211 finalize: function (dataUpdate) {
23212 // Final data update
23213 if (dataUpdate) {
23214 this._append(dataUpdate);
23215 }
23216
23217 // Perform concrete-cipher logic
23218 var finalProcessedData = this._doFinalize();
23219
23220 return finalProcessedData;
23221 },
23222
23223 keySize: 128/32,
23224
23225 ivSize: 128/32,
23226
23227 _ENC_XFORM_MODE: 1,
23228
23229 _DEC_XFORM_MODE: 2,
23230
23231 /**
23232 * Creates shortcut functions to a cipher's object interface.
23233 *
23234 * @param {Cipher} cipher The cipher to create a helper for.
23235 *
23236 * @return {Object} An object with encrypt and decrypt shortcut functions.
23237 *
23238 * @static
23239 *
23240 * @example
23241 *
23242 * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
23243 */
23244 _createHelper: (function () {
23245 function selectCipherStrategy(key) {
23246 if (typeof key == 'string') {
23247 return PasswordBasedCipher;
23248 } else {
23249 return SerializableCipher;
23250 }
23251 }
23252
23253 return function (cipher) {
23254 return {
23255 encrypt: function (message, key, cfg) {
23256 return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
23257 },
23258
23259 decrypt: function (ciphertext, key, cfg) {
23260 return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
23261 }
23262 };
23263 };
23264 }())
23265 });
23266
23267 /**
23268 * Abstract base stream cipher template.
23269 *
23270 * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
23271 */
23272 var StreamCipher = C_lib.StreamCipher = Cipher.extend({
23273 _doFinalize: function () {
23274 // Process partial blocks
23275 var finalProcessedBlocks = this._process(!!'flush');
23276
23277 return finalProcessedBlocks;
23278 },
23279
23280 blockSize: 1
23281 });
23282
23283 /**
23284 * Mode namespace.
23285 */
23286 var C_mode = C.mode = {};
23287
23288 /**
23289 * Abstract base block cipher mode template.
23290 */
23291 var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
23292 /**
23293 * Creates this mode for encryption.
23294 *
23295 * @param {Cipher} cipher A block cipher instance.
23296 * @param {Array} iv The IV words.
23297 *
23298 * @static
23299 *
23300 * @example
23301 *
23302 * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
23303 */
23304 createEncryptor: function (cipher, iv) {
23305 return this.Encryptor.create(cipher, iv);
23306 },
23307
23308 /**
23309 * Creates this mode for decryption.
23310 *
23311 * @param {Cipher} cipher A block cipher instance.
23312 * @param {Array} iv The IV words.
23313 *
23314 * @static
23315 *
23316 * @example
23317 *
23318 * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
23319 */
23320 createDecryptor: function (cipher, iv) {
23321 return this.Decryptor.create(cipher, iv);
23322 },
23323
23324 /**
23325 * Initializes a newly created mode.
23326 *
23327 * @param {Cipher} cipher A block cipher instance.
23328 * @param {Array} iv The IV words.
23329 *
23330 * @example
23331 *
23332 * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
23333 */
23334 init: function (cipher, iv) {
23335 this._cipher = cipher;
23336 this._iv = iv;
23337 }
23338 });
23339
23340 /**
23341 * Cipher Block Chaining mode.
23342 */
23343 var CBC = C_mode.CBC = (function () {
23344 /**
23345 * Abstract base CBC mode.
23346 */
23347 var CBC = BlockCipherMode.extend();
23348
23349 /**
23350 * CBC encryptor.
23351 */
23352 CBC.Encryptor = CBC.extend({
23353 /**
23354 * Processes the data block at offset.
23355 *
23356 * @param {Array} words The data words to operate on.
23357 * @param {number} offset The offset where the block starts.
23358 *
23359 * @example
23360 *
23361 * mode.processBlock(data.words, offset);
23362 */
23363 processBlock: function (words, offset) {
23364 // Shortcuts
23365 var cipher = this._cipher;
23366 var blockSize = cipher.blockSize;
23367
23368 // XOR and encrypt
23369 xorBlock.call(this, words, offset, blockSize);
23370 cipher.encryptBlock(words, offset);
23371
23372 // Remember this block to use with next block
23373 this._prevBlock = words.slice(offset, offset + blockSize);
23374 }
23375 });
23376
23377 /**
23378 * CBC decryptor.
23379 */
23380 CBC.Decryptor = CBC.extend({
23381 /**
23382 * Processes the data block at offset.
23383 *
23384 * @param {Array} words The data words to operate on.
23385 * @param {number} offset The offset where the block starts.
23386 *
23387 * @example
23388 *
23389 * mode.processBlock(data.words, offset);
23390 */
23391 processBlock: function (words, offset) {
23392 // Shortcuts
23393 var cipher = this._cipher;
23394 var blockSize = cipher.blockSize;
23395
23396 // Remember this block to use with next block
23397 var thisBlock = words.slice(offset, offset + blockSize);
23398
23399 // Decrypt and XOR
23400 cipher.decryptBlock(words, offset);
23401 xorBlock.call(this, words, offset, blockSize);
23402
23403 // This block becomes the previous block
23404 this._prevBlock = thisBlock;
23405 }
23406 });
23407
23408 function xorBlock(words, offset, blockSize) {
23409 // Shortcut
23410 var iv = this._iv;
23411
23412 // Choose mixing block
23413 if (iv) {
23414 var block = iv;
23415
23416 // Remove IV for subsequent blocks
23417 this._iv = undefined;
23418 } else {
23419 var block = this._prevBlock;
23420 }
23421
23422 // XOR blocks
23423 for (var i = 0; i < blockSize; i++) {
23424 words[offset + i] ^= block[i];
23425 }
23426 }
23427
23428 return CBC;
23429 }());
23430
23431 /**
23432 * Padding namespace.
23433 */
23434 var C_pad = C.pad = {};
23435
23436 /**
23437 * PKCS #5/7 padding strategy.
23438 */
23439 var Pkcs7 = C_pad.Pkcs7 = {
23440 /**
23441 * Pads data using the algorithm defined in PKCS #5/7.
23442 *
23443 * @param {WordArray} data The data to pad.
23444 * @param {number} blockSize The multiple that the data should be padded to.
23445 *
23446 * @static
23447 *
23448 * @example
23449 *
23450 * CryptoJS.pad.Pkcs7.pad(wordArray, 4);
23451 */
23452 pad: function (data, blockSize) {
23453 // Shortcut
23454 var blockSizeBytes = blockSize * 4;
23455
23456 // Count padding bytes
23457 var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
23458
23459 // Create padding word
23460 var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
23461
23462 // Create padding
23463 var paddingWords = [];
23464 for (var i = 0; i < nPaddingBytes; i += 4) {
23465 paddingWords.push(paddingWord);
23466 }
23467 var padding = WordArray.create(paddingWords, nPaddingBytes);
23468
23469 // Add padding
23470 data.concat(padding);
23471 },
23472
23473 /**
23474 * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
23475 *
23476 * @param {WordArray} data The data to unpad.
23477 *
23478 * @static
23479 *
23480 * @example
23481 *
23482 * CryptoJS.pad.Pkcs7.unpad(wordArray);
23483 */
23484 unpad: function (data) {
23485 // Get number of padding bytes from last byte
23486 var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
23487
23488 // Remove padding
23489 data.sigBytes -= nPaddingBytes;
23490 }
23491 };
23492
23493 /**
23494 * Abstract base block cipher template.
23495 *
23496 * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
23497 */
23498 var BlockCipher = C_lib.BlockCipher = Cipher.extend({
23499 /**
23500 * Configuration options.
23501 *
23502 * @property {Mode} mode The block mode to use. Default: CBC
23503 * @property {Padding} padding The padding strategy to use. Default: Pkcs7
23504 */
23505 cfg: Cipher.cfg.extend({
23506 mode: CBC,
23507 padding: Pkcs7
23508 }),
23509
23510 reset: function () {
23511 // Reset cipher
23512 Cipher.reset.call(this);
23513
23514 // Shortcuts
23515 var cfg = this.cfg;
23516 var iv = cfg.iv;
23517 var mode = cfg.mode;
23518
23519 // Reset block mode
23520 if (this._xformMode == this._ENC_XFORM_MODE) {
23521 var modeCreator = mode.createEncryptor;
23522 } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
23523 var modeCreator = mode.createDecryptor;
23524
23525 // Keep at least one block in the buffer for unpadding
23526 this._minBufferSize = 1;
23527 }
23528 this._mode = modeCreator.call(mode, this, iv && iv.words);
23529 },
23530
23531 _doProcessBlock: function (words, offset) {
23532 this._mode.processBlock(words, offset);
23533 },
23534
23535 _doFinalize: function () {
23536 // Shortcut
23537 var padding = this.cfg.padding;
23538
23539 // Finalize
23540 if (this._xformMode == this._ENC_XFORM_MODE) {
23541 // Pad data
23542 padding.pad(this._data, this.blockSize);
23543
23544 // Process final blocks
23545 var finalProcessedBlocks = this._process(!!'flush');
23546 } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
23547 // Process final blocks
23548 var finalProcessedBlocks = this._process(!!'flush');
23549
23550 // Unpad data
23551 padding.unpad(finalProcessedBlocks);
23552 }
23553
23554 return finalProcessedBlocks;
23555 },
23556
23557 blockSize: 128/32
23558 });
23559
23560 /**
23561 * A collection of cipher parameters.
23562 *
23563 * @property {WordArray} ciphertext The raw ciphertext.
23564 * @property {WordArray} key The key to this ciphertext.
23565 * @property {WordArray} iv The IV used in the ciphering operation.
23566 * @property {WordArray} salt The salt used with a key derivation function.
23567 * @property {Cipher} algorithm The cipher algorithm.
23568 * @property {Mode} mode The block mode used in the ciphering operation.
23569 * @property {Padding} padding The padding scheme used in the ciphering operation.
23570 * @property {number} blockSize The block size of the cipher.
23571 * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
23572 */
23573 var CipherParams = C_lib.CipherParams = Base.extend({
23574 /**
23575 * Initializes a newly created cipher params object.
23576 *
23577 * @param {Object} cipherParams An object with any of the possible cipher parameters.
23578 *
23579 * @example
23580 *
23581 * var cipherParams = CryptoJS.lib.CipherParams.create({
23582 * ciphertext: ciphertextWordArray,
23583 * key: keyWordArray,
23584 * iv: ivWordArray,
23585 * salt: saltWordArray,
23586 * algorithm: CryptoJS.algo.AES,
23587 * mode: CryptoJS.mode.CBC,
23588 * padding: CryptoJS.pad.PKCS7,
23589 * blockSize: 4,
23590 * formatter: CryptoJS.format.OpenSSL
23591 * });
23592 */
23593 init: function (cipherParams) {
23594 this.mixIn(cipherParams);
23595 },
23596
23597 /**
23598 * Converts this cipher params object to a string.
23599 *
23600 * @param {Format} formatter (Optional) The formatting strategy to use.
23601 *
23602 * @return {string} The stringified cipher params.
23603 *
23604 * @throws Error If neither the formatter nor the default formatter is set.
23605 *
23606 * @example
23607 *
23608 * var string = cipherParams + '';
23609 * var string = cipherParams.toString();
23610 * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
23611 */
23612 toString: function (formatter) {
23613 return (formatter || this.formatter).stringify(this);
23614 }
23615 });
23616
23617 /**
23618 * Format namespace.
23619 */
23620 var C_format = C.format = {};
23621
23622 /**
23623 * OpenSSL formatting strategy.
23624 */
23625 var OpenSSLFormatter = C_format.OpenSSL = {
23626 /**
23627 * Converts a cipher params object to an OpenSSL-compatible string.
23628 *
23629 * @param {CipherParams} cipherParams The cipher params object.
23630 *
23631 * @return {string} The OpenSSL-compatible string.
23632 *
23633 * @static
23634 *
23635 * @example
23636 *
23637 * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
23638 */
23639 stringify: function (cipherParams) {
23640 // Shortcuts
23641 var ciphertext = cipherParams.ciphertext;
23642 var salt = cipherParams.salt;
23643
23644 // Format
23645 if (salt) {
23646 var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
23647 } else {
23648 var wordArray = ciphertext;
23649 }
23650
23651 return wordArray.toString(Base64);
23652 },
23653
23654 /**
23655 * Converts an OpenSSL-compatible string to a cipher params object.
23656 *
23657 * @param {string} openSSLStr The OpenSSL-compatible string.
23658 *
23659 * @return {CipherParams} The cipher params object.
23660 *
23661 * @static
23662 *
23663 * @example
23664 *
23665 * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
23666 */
23667 parse: function (openSSLStr) {
23668 // Parse base64
23669 var ciphertext = Base64.parse(openSSLStr);
23670
23671 // Shortcut
23672 var ciphertextWords = ciphertext.words;
23673
23674 // Test for salt
23675 if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
23676 // Extract salt
23677 var salt = WordArray.create(ciphertextWords.slice(2, 4));
23678
23679 // Remove salt from ciphertext
23680 ciphertextWords.splice(0, 4);
23681 ciphertext.sigBytes -= 16;
23682 }
23683
23684 return CipherParams.create({ ciphertext: ciphertext, salt: salt });
23685 }
23686 };
23687
23688 /**
23689 * A cipher wrapper that returns ciphertext as a serializable cipher params object.
23690 */
23691 var SerializableCipher = C_lib.SerializableCipher = Base.extend({
23692 /**
23693 * Configuration options.
23694 *
23695 * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
23696 */
23697 cfg: Base.extend({
23698 format: OpenSSLFormatter
23699 }),
23700
23701 /**
23702 * Encrypts a message.
23703 *
23704 * @param {Cipher} cipher The cipher algorithm to use.
23705 * @param {WordArray|string} message The message to encrypt.
23706 * @param {WordArray} key The key.
23707 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23708 *
23709 * @return {CipherParams} A cipher params object.
23710 *
23711 * @static
23712 *
23713 * @example
23714 *
23715 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
23716 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
23717 * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
23718 */
23719 encrypt: function (cipher, message, key, cfg) {
23720 // Apply config defaults
23721 cfg = this.cfg.extend(cfg);
23722
23723 // Encrypt
23724 var encryptor = cipher.createEncryptor(key, cfg);
23725 var ciphertext = encryptor.finalize(message);
23726
23727 // Shortcut
23728 var cipherCfg = encryptor.cfg;
23729
23730 // Create and return serializable cipher params
23731 return CipherParams.create({
23732 ciphertext: ciphertext,
23733 key: key,
23734 iv: cipherCfg.iv,
23735 algorithm: cipher,
23736 mode: cipherCfg.mode,
23737 padding: cipherCfg.padding,
23738 blockSize: cipher.blockSize,
23739 formatter: cfg.format
23740 });
23741 },
23742
23743 /**
23744 * Decrypts serialized ciphertext.
23745 *
23746 * @param {Cipher} cipher The cipher algorithm to use.
23747 * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
23748 * @param {WordArray} key The key.
23749 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23750 *
23751 * @return {WordArray} The plaintext.
23752 *
23753 * @static
23754 *
23755 * @example
23756 *
23757 * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
23758 * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
23759 */
23760 decrypt: function (cipher, ciphertext, key, cfg) {
23761 // Apply config defaults
23762 cfg = this.cfg.extend(cfg);
23763
23764 // Convert string to CipherParams
23765 ciphertext = this._parse(ciphertext, cfg.format);
23766
23767 // Decrypt
23768 var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
23769
23770 return plaintext;
23771 },
23772
23773 /**
23774 * Converts serialized ciphertext to CipherParams,
23775 * else assumed CipherParams already and returns ciphertext unchanged.
23776 *
23777 * @param {CipherParams|string} ciphertext The ciphertext.
23778 * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
23779 *
23780 * @return {CipherParams} The unserialized ciphertext.
23781 *
23782 * @static
23783 *
23784 * @example
23785 *
23786 * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
23787 */
23788 _parse: function (ciphertext, format) {
23789 if (typeof ciphertext == 'string') {
23790 return format.parse(ciphertext, this);
23791 } else {
23792 return ciphertext;
23793 }
23794 }
23795 });
23796
23797 /**
23798 * Key derivation function namespace.
23799 */
23800 var C_kdf = C.kdf = {};
23801
23802 /**
23803 * OpenSSL key derivation function.
23804 */
23805 var OpenSSLKdf = C_kdf.OpenSSL = {
23806 /**
23807 * Derives a key and IV from a password.
23808 *
23809 * @param {string} password The password to derive from.
23810 * @param {number} keySize The size in words of the key to generate.
23811 * @param {number} ivSize The size in words of the IV to generate.
23812 * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
23813 *
23814 * @return {CipherParams} A cipher params object with the key, IV, and salt.
23815 *
23816 * @static
23817 *
23818 * @example
23819 *
23820 * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
23821 * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
23822 */
23823 execute: function (password, keySize, ivSize, salt) {
23824 // Generate random salt
23825 if (!salt) {
23826 salt = WordArray.random(64/8);
23827 }
23828
23829 // Derive key and IV
23830 var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
23831
23832 // Separate key and IV
23833 var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
23834 key.sigBytes = keySize * 4;
23835
23836 // Return params
23837 return CipherParams.create({ key: key, iv: iv, salt: salt });
23838 }
23839 };
23840
23841 /**
23842 * A serializable cipher wrapper that derives the key from a password,
23843 * and returns ciphertext as a serializable cipher params object.
23844 */
23845 var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
23846 /**
23847 * Configuration options.
23848 *
23849 * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
23850 */
23851 cfg: SerializableCipher.cfg.extend({
23852 kdf: OpenSSLKdf
23853 }),
23854
23855 /**
23856 * Encrypts a message using a password.
23857 *
23858 * @param {Cipher} cipher The cipher algorithm to use.
23859 * @param {WordArray|string} message The message to encrypt.
23860 * @param {string} password The password.
23861 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23862 *
23863 * @return {CipherParams} A cipher params object.
23864 *
23865 * @static
23866 *
23867 * @example
23868 *
23869 * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
23870 * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
23871 */
23872 encrypt: function (cipher, message, password, cfg) {
23873 // Apply config defaults
23874 cfg = this.cfg.extend(cfg);
23875
23876 // Derive key and other params
23877 var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
23878
23879 // Add IV to config
23880 cfg.iv = derivedParams.iv;
23881
23882 // Encrypt
23883 var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
23884
23885 // Mix in derived params
23886 ciphertext.mixIn(derivedParams);
23887
23888 return ciphertext;
23889 },
23890
23891 /**
23892 * Decrypts serialized ciphertext using a password.
23893 *
23894 * @param {Cipher} cipher The cipher algorithm to use.
23895 * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
23896 * @param {string} password The password.
23897 * @param {Object} cfg (Optional) The configuration options to use for this operation.
23898 *
23899 * @return {WordArray} The plaintext.
23900 *
23901 * @static
23902 *
23903 * @example
23904 *
23905 * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
23906 * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
23907 */
23908 decrypt: function (cipher, ciphertext, password, cfg) {
23909 // Apply config defaults
23910 cfg = this.cfg.extend(cfg);
23911
23912 // Convert string to CipherParams
23913 ciphertext = this._parse(ciphertext, cfg.format);
23914
23915 // Derive key and other params
23916 var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
23917
23918 // Add IV to config
23919 cfg.iv = derivedParams.iv;
23920
23921 // Decrypt
23922 var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
23923
23924 return plaintext;
23925 }
23926 });
23927 }());
23928
23929
23930 }));
23931 },{"./core":31}],31:[function(_dereq_,module,exports){
23932 ;(function (root, factory) {
23933 if (typeof exports === "object") {
23934 // CommonJS
23935 module.exports = exports = factory();
23936 }
23937 else if (typeof define === "function" && define.amd) {
23938 // AMD
23939 define([], factory);
23940 }
23941 else {
23942 // Global (browser)
23943 root.CryptoJS = factory();
23944 }
23945 }(this, function () {
23946
23947 /**
23948 * CryptoJS core components.
23949 */
23950 var CryptoJS = CryptoJS || (function (Math, undefined) {
23951 /**
23952 * CryptoJS namespace.
23953 */
23954 var C = {};
23955
23956 /**
23957 * Library namespace.
23958 */
23959 var C_lib = C.lib = {};
23960
23961 /**
23962 * Base object for prototypal inheritance.
23963 */
23964 var Base = C_lib.Base = (function () {
23965 function F() {}
23966
23967 return {
23968 /**
23969 * Creates a new object that inherits from this object.
23970 *
23971 * @param {Object} overrides Properties to copy into the new object.
23972 *
23973 * @return {Object} The new object.
23974 *
23975 * @static
23976 *
23977 * @example
23978 *
23979 * var MyType = CryptoJS.lib.Base.extend({
23980 * field: 'value',
23981 *
23982 * method: function () {
23983 * }
23984 * });
23985 */
23986 extend: function (overrides) {
23987 // Spawn
23988 F.prototype = this;
23989 var subtype = new F();
23990
23991 // Augment
23992 if (overrides) {
23993 subtype.mixIn(overrides);
23994 }
23995
23996 // Create default initializer
23997 if (!subtype.hasOwnProperty('init')) {
23998 subtype.init = function () {
23999 subtype.$super.init.apply(this, arguments);
24000 };
24001 }
24002
24003 // Initializer's prototype is the subtype object
24004 subtype.init.prototype = subtype;
24005
24006 // Reference supertype
24007 subtype.$super = this;
24008
24009 return subtype;
24010 },
24011
24012 /**
24013 * Extends this object and runs the init method.
24014 * Arguments to create() will be passed to init().
24015 *
24016 * @return {Object} The new object.
24017 *
24018 * @static
24019 *
24020 * @example
24021 *
24022 * var instance = MyType.create();
24023 */
24024 create: function () {
24025 var instance = this.extend();
24026 instance.init.apply(instance, arguments);
24027
24028 return instance;
24029 },
24030
24031 /**
24032 * Initializes a newly created object.
24033 * Override this method to add some logic when your objects are created.
24034 *
24035 * @example
24036 *
24037 * var MyType = CryptoJS.lib.Base.extend({
24038 * init: function () {
24039 * // ...
24040 * }
24041 * });
24042 */
24043 init: function () {
24044 },
24045
24046 /**
24047 * Copies properties into this object.
24048 *
24049 * @param {Object} properties The properties to mix in.
24050 *
24051 * @example
24052 *
24053 * MyType.mixIn({
24054 * field: 'value'
24055 * });
24056 */
24057 mixIn: function (properties) {
24058 for (var propertyName in properties) {
24059 if (properties.hasOwnProperty(propertyName)) {
24060 this[propertyName] = properties[propertyName];
24061 }
24062 }
24063
24064 // IE won't copy toString using the loop above
24065 if (properties.hasOwnProperty('toString')) {
24066 this.toString = properties.toString;
24067 }
24068 },
24069
24070 /**
24071 * Creates a copy of this object.
24072 *
24073 * @return {Object} The clone.
24074 *
24075 * @example
24076 *
24077 * var clone = instance.clone();
24078 */
24079 clone: function () {
24080 return this.init.prototype.extend(this);
24081 }
24082 };
24083 }());
24084
24085 /**
24086 * An array of 32-bit words.
24087 *
24088 * @property {Array} words The array of 32-bit words.
24089 * @property {number} sigBytes The number of significant bytes in this word array.
24090 */
24091 var WordArray = C_lib.WordArray = Base.extend({
24092 /**
24093 * Initializes a newly created word array.
24094 *
24095 * @param {Array} words (Optional) An array of 32-bit words.
24096 * @param {number} sigBytes (Optional) The number of significant bytes in the words.
24097 *
24098 * @example
24099 *
24100 * var wordArray = CryptoJS.lib.WordArray.create();
24101 * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
24102 * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
24103 */
24104 init: function (words, sigBytes) {
24105 words = this.words = words || [];
24106
24107 if (sigBytes != undefined) {
24108 this.sigBytes = sigBytes;
24109 } else {
24110 this.sigBytes = words.length * 4;
24111 }
24112 },
24113
24114 /**
24115 * Converts this word array to a string.
24116 *
24117 * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
24118 *
24119 * @return {string} The stringified word array.
24120 *
24121 * @example
24122 *
24123 * var string = wordArray + '';
24124 * var string = wordArray.toString();
24125 * var string = wordArray.toString(CryptoJS.enc.Utf8);
24126 */
24127 toString: function (encoder) {
24128 return (encoder || Hex).stringify(this);
24129 },
24130
24131 /**
24132 * Concatenates a word array to this word array.
24133 *
24134 * @param {WordArray} wordArray The word array to append.
24135 *
24136 * @return {WordArray} This word array.
24137 *
24138 * @example
24139 *
24140 * wordArray1.concat(wordArray2);
24141 */
24142 concat: function (wordArray) {
24143 // Shortcuts
24144 var thisWords = this.words;
24145 var thatWords = wordArray.words;
24146 var thisSigBytes = this.sigBytes;
24147 var thatSigBytes = wordArray.sigBytes;
24148
24149 // Clamp excess bits
24150 this.clamp();
24151
24152 // Concat
24153 if (thisSigBytes % 4) {
24154 // Copy one byte at a time
24155 for (var i = 0; i < thatSigBytes; i++) {
24156 var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
24157 thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
24158 }
24159 } else if (thatWords.length > 0xffff) {
24160 // Copy one word at a time
24161 for (var i = 0; i < thatSigBytes; i += 4) {
24162 thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
24163 }
24164 } else {
24165 // Copy all words at once
24166 thisWords.push.apply(thisWords, thatWords);
24167 }
24168 this.sigBytes += thatSigBytes;
24169
24170 // Chainable
24171 return this;
24172 },
24173
24174 /**
24175 * Removes insignificant bits.
24176 *
24177 * @example
24178 *
24179 * wordArray.clamp();
24180 */
24181 clamp: function () {
24182 // Shortcuts
24183 var words = this.words;
24184 var sigBytes = this.sigBytes;
24185
24186 // Clamp
24187 words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
24188 words.length = Math.ceil(sigBytes / 4);
24189 },
24190
24191 /**
24192 * Creates a copy of this word array.
24193 *
24194 * @return {WordArray} The clone.
24195 *
24196 * @example
24197 *
24198 * var clone = wordArray.clone();
24199 */
24200 clone: function () {
24201 var clone = Base.clone.call(this);
24202 clone.words = this.words.slice(0);
24203
24204 return clone;
24205 },
24206
24207 /**
24208 * Creates a word array filled with random bytes.
24209 *
24210 * @param {number} nBytes The number of random bytes to generate.
24211 *
24212 * @return {WordArray} The random word array.
24213 *
24214 * @static
24215 *
24216 * @example
24217 *
24218 * var wordArray = CryptoJS.lib.WordArray.random(16);
24219 */
24220 random: function (nBytes) {
24221 var words = [];
24222 for (var i = 0; i < nBytes; i += 4) {
24223 words.push((Math.random() * 0x100000000) | 0);
24224 }
24225
24226 return new WordArray.init(words, nBytes);
24227 }
24228 });
24229
24230 /**
24231 * Encoder namespace.
24232 */
24233 var C_enc = C.enc = {};
24234
24235 /**
24236 * Hex encoding strategy.
24237 */
24238 var Hex = C_enc.Hex = {
24239 /**
24240 * Converts a word array to a hex string.
24241 *
24242 * @param {WordArray} wordArray The word array.
24243 *
24244 * @return {string} The hex string.
24245 *
24246 * @static
24247 *
24248 * @example
24249 *
24250 * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
24251 */
24252 stringify: function (wordArray) {
24253 // Shortcuts
24254 var words = wordArray.words;
24255 var sigBytes = wordArray.sigBytes;
24256
24257 // Convert
24258 var hexChars = [];
24259 for (var i = 0; i < sigBytes; i++) {
24260 var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
24261 hexChars.push((bite >>> 4).toString(16));
24262 hexChars.push((bite & 0x0f).toString(16));
24263 }
24264
24265 return hexChars.join('');
24266 },
24267
24268 /**
24269 * Converts a hex string to a word array.
24270 *
24271 * @param {string} hexStr The hex string.
24272 *
24273 * @return {WordArray} The word array.
24274 *
24275 * @static
24276 *
24277 * @example
24278 *
24279 * var wordArray = CryptoJS.enc.Hex.parse(hexString);
24280 */
24281 parse: function (hexStr) {
24282 // Shortcut
24283 var hexStrLength = hexStr.length;
24284
24285 // Convert
24286 var words = [];
24287 for (var i = 0; i < hexStrLength; i += 2) {
24288 words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
24289 }
24290
24291 return new WordArray.init(words, hexStrLength / 2);
24292 }
24293 };
24294
24295 /**
24296 * Latin1 encoding strategy.
24297 */
24298 var Latin1 = C_enc.Latin1 = {
24299 /**
24300 * Converts a word array to a Latin1 string.
24301 *
24302 * @param {WordArray} wordArray The word array.
24303 *
24304 * @return {string} The Latin1 string.
24305 *
24306 * @static
24307 *
24308 * @example
24309 *
24310 * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
24311 */
24312 stringify: function (wordArray) {
24313 // Shortcuts
24314 var words = wordArray.words;
24315 var sigBytes = wordArray.sigBytes;
24316
24317 // Convert
24318 var latin1Chars = [];
24319 for (var i = 0; i < sigBytes; i++) {
24320 var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
24321 latin1Chars.push(String.fromCharCode(bite));
24322 }
24323
24324 return latin1Chars.join('');
24325 },
24326
24327 /**
24328 * Converts a Latin1 string to a word array.
24329 *
24330 * @param {string} latin1Str The Latin1 string.
24331 *
24332 * @return {WordArray} The word array.
24333 *
24334 * @static
24335 *
24336 * @example
24337 *
24338 * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
24339 */
24340 parse: function (latin1Str) {
24341 // Shortcut
24342 var latin1StrLength = latin1Str.length;
24343
24344 // Convert
24345 var words = [];
24346 for (var i = 0; i < latin1StrLength; i++) {
24347 words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
24348 }
24349
24350 return new WordArray.init(words, latin1StrLength);
24351 }
24352 };
24353
24354 /**
24355 * UTF-8 encoding strategy.
24356 */
24357 var Utf8 = C_enc.Utf8 = {
24358 /**
24359 * Converts a word array to a UTF-8 string.
24360 *
24361 * @param {WordArray} wordArray The word array.
24362 *
24363 * @return {string} The UTF-8 string.
24364 *
24365 * @static
24366 *
24367 * @example
24368 *
24369 * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
24370 */
24371 stringify: function (wordArray) {
24372 try {
24373 return decodeURIComponent(escape(Latin1.stringify(wordArray)));
24374 } catch (e) {
24375 throw new Error('Malformed UTF-8 data');
24376 }
24377 },
24378
24379 /**
24380 * Converts a UTF-8 string to a word array.
24381 *
24382 * @param {string} utf8Str The UTF-8 string.
24383 *
24384 * @return {WordArray} The word array.
24385 *
24386 * @static
24387 *
24388 * @example
24389 *
24390 * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
24391 */
24392 parse: function (utf8Str) {
24393 return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
24394 }
24395 };
24396
24397 /**
24398 * Abstract buffered block algorithm template.
24399 *
24400 * The property blockSize must be implemented in a concrete subtype.
24401 *
24402 * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
24403 */
24404 var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
24405 /**
24406 * Resets this block algorithm's data buffer to its initial state.
24407 *
24408 * @example
24409 *
24410 * bufferedBlockAlgorithm.reset();
24411 */
24412 reset: function () {
24413 // Initial values
24414 this._data = new WordArray.init();
24415 this._nDataBytes = 0;
24416 },
24417
24418 /**
24419 * Adds new data to this block algorithm's buffer.
24420 *
24421 * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
24422 *
24423 * @example
24424 *
24425 * bufferedBlockAlgorithm._append('data');
24426 * bufferedBlockAlgorithm._append(wordArray);
24427 */
24428 _append: function (data) {
24429 // Convert string to WordArray, else assume WordArray already
24430 if (typeof data == 'string') {
24431 data = Utf8.parse(data);
24432 }
24433
24434 // Append
24435 this._data.concat(data);
24436 this._nDataBytes += data.sigBytes;
24437 },
24438
24439 /**
24440 * Processes available data blocks.
24441 *
24442 * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
24443 *
24444 * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
24445 *
24446 * @return {WordArray} The processed data.
24447 *
24448 * @example
24449 *
24450 * var processedData = bufferedBlockAlgorithm._process();
24451 * var processedData = bufferedBlockAlgorithm._process(!!'flush');
24452 */
24453 _process: function (doFlush) {
24454 // Shortcuts
24455 var data = this._data;
24456 var dataWords = data.words;
24457 var dataSigBytes = data.sigBytes;
24458 var blockSize = this.blockSize;
24459 var blockSizeBytes = blockSize * 4;
24460
24461 // Count blocks ready
24462 var nBlocksReady = dataSigBytes / blockSizeBytes;
24463 if (doFlush) {
24464 // Round up to include partial blocks
24465 nBlocksReady = Math.ceil(nBlocksReady);
24466 } else {
24467 // Round down to include only full blocks,
24468 // less the number of blocks that must remain in the buffer
24469 nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
24470 }
24471
24472 // Count words ready
24473 var nWordsReady = nBlocksReady * blockSize;
24474
24475 // Count bytes ready
24476 var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
24477
24478 // Process blocks
24479 if (nWordsReady) {
24480 for (var offset = 0; offset < nWordsReady; offset += blockSize) {
24481 // Perform concrete-algorithm logic
24482 this._doProcessBlock(dataWords, offset);
24483 }
24484
24485 // Remove processed words
24486 var processedWords = dataWords.splice(0, nWordsReady);
24487 data.sigBytes -= nBytesReady;
24488 }
24489
24490 // Return processed words
24491 return new WordArray.init(processedWords, nBytesReady);
24492 },
24493
24494 /**
24495 * Creates a copy of this object.
24496 *
24497 * @return {Object} The clone.
24498 *
24499 * @example
24500 *
24501 * var clone = bufferedBlockAlgorithm.clone();
24502 */
24503 clone: function () {
24504 var clone = Base.clone.call(this);
24505 clone._data = this._data.clone();
24506
24507 return clone;
24508 },
24509
24510 _minBufferSize: 0
24511 });
24512
24513 /**
24514 * Abstract hasher template.
24515 *
24516 * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
24517 */
24518 var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
24519 /**
24520 * Configuration options.
24521 */
24522 cfg: Base.extend(),
24523
24524 /**
24525 * Initializes a newly created hasher.
24526 *
24527 * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
24528 *
24529 * @example
24530 *
24531 * var hasher = CryptoJS.algo.SHA256.create();
24532 */
24533 init: function (cfg) {
24534 // Apply config defaults
24535 this.cfg = this.cfg.extend(cfg);
24536
24537 // Set initial values
24538 this.reset();
24539 },
24540
24541 /**
24542 * Resets this hasher to its initial state.
24543 *
24544 * @example
24545 *
24546 * hasher.reset();
24547 */
24548 reset: function () {
24549 // Reset data buffer
24550 BufferedBlockAlgorithm.reset.call(this);
24551
24552 // Perform concrete-hasher logic
24553 this._doReset();
24554 },
24555
24556 /**
24557 * Updates this hasher with a message.
24558 *
24559 * @param {WordArray|string} messageUpdate The message to append.
24560 *
24561 * @return {Hasher} This hasher.
24562 *
24563 * @example
24564 *
24565 * hasher.update('message');
24566 * hasher.update(wordArray);
24567 */
24568 update: function (messageUpdate) {
24569 // Append
24570 this._append(messageUpdate);
24571
24572 // Update the hash
24573 this._process();
24574
24575 // Chainable
24576 return this;
24577 },
24578
24579 /**
24580 * Finalizes the hash computation.
24581 * Note that the finalize operation is effectively a destructive, read-once operation.
24582 *
24583 * @param {WordArray|string} messageUpdate (Optional) A final message update.
24584 *
24585 * @return {WordArray} The hash.
24586 *
24587 * @example
24588 *
24589 * var hash = hasher.finalize();
24590 * var hash = hasher.finalize('message');
24591 * var hash = hasher.finalize(wordArray);
24592 */
24593 finalize: function (messageUpdate) {
24594 // Final message update
24595 if (messageUpdate) {
24596 this._append(messageUpdate);
24597 }
24598
24599 // Perform concrete-hasher logic
24600 var hash = this._doFinalize();
24601
24602 return hash;
24603 },
24604
24605 blockSize: 512/32,
24606
24607 /**
24608 * Creates a shortcut function to a hasher's object interface.
24609 *
24610 * @param {Hasher} hasher The hasher to create a helper for.
24611 *
24612 * @return {Function} The shortcut function.
24613 *
24614 * @static
24615 *
24616 * @example
24617 *
24618 * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
24619 */
24620 _createHelper: function (hasher) {
24621 return function (message, cfg) {
24622 return new hasher.init(cfg).finalize(message);
24623 };
24624 },
24625
24626 /**
24627 * Creates a shortcut function to the HMAC's object interface.
24628 *
24629 * @param {Hasher} hasher The hasher to use in this HMAC helper.
24630 *
24631 * @return {Function} The shortcut function.
24632 *
24633 * @static
24634 *
24635 * @example
24636 *
24637 * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
24638 */
24639 _createHmacHelper: function (hasher) {
24640 return function (message, key) {
24641 return new C_algo.HMAC.init(hasher, key).finalize(message);
24642 };
24643 }
24644 });
24645
24646 /**
24647 * Algorithm namespace.
24648 */
24649 var C_algo = C.algo = {};
24650
24651 return C;
24652 }(Math));
24653
24654
24655 return CryptoJS;
24656
24657 }));
24658 },{}],32:[function(_dereq_,module,exports){
24659 ;(function (root, factory) {
24660 if (typeof exports === "object") {
24661 // CommonJS
24662 module.exports = exports = factory(_dereq_("./core"));
24663 }
24664 else if (typeof define === "function" && define.amd) {
24665 // AMD
24666 define(["./core"], factory);
24667 }
24668 else {
24669 // Global (browser)
24670 factory(root.CryptoJS);
24671 }
24672 }(this, function (CryptoJS) {
24673
24674 (function () {
24675 // Shortcuts
24676 var C = CryptoJS;
24677 var C_lib = C.lib;
24678 var WordArray = C_lib.WordArray;
24679 var C_enc = C.enc;
24680
24681 /**
24682 * Base64 encoding strategy.
24683 */
24684 var Base64 = C_enc.Base64 = {
24685 /**
24686 * Converts a word array to a Base64 string.
24687 *
24688 * @param {WordArray} wordArray The word array.
24689 *
24690 * @return {string} The Base64 string.
24691 *
24692 * @static
24693 *
24694 * @example
24695 *
24696 * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
24697 */
24698 stringify: function (wordArray) {
24699 // Shortcuts
24700 var words = wordArray.words;
24701 var sigBytes = wordArray.sigBytes;
24702 var map = this._map;
24703
24704 // Clamp excess bits
24705 wordArray.clamp();
24706
24707 // Convert
24708 var base64Chars = [];
24709 for (var i = 0; i < sigBytes; i += 3) {
24710 var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
24711 var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
24712 var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
24713
24714 var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
24715
24716 for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
24717 base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
24718 }
24719 }
24720
24721 // Add padding
24722 var paddingChar = map.charAt(64);
24723 if (paddingChar) {
24724 while (base64Chars.length % 4) {
24725 base64Chars.push(paddingChar);
24726 }
24727 }
24728
24729 return base64Chars.join('');
24730 },
24731
24732 /**
24733 * Converts a Base64 string to a word array.
24734 *
24735 * @param {string} base64Str The Base64 string.
24736 *
24737 * @return {WordArray} The word array.
24738 *
24739 * @static
24740 *
24741 * @example
24742 *
24743 * var wordArray = CryptoJS.enc.Base64.parse(base64String);
24744 */
24745 parse: function (base64Str) {
24746 // Shortcuts
24747 var base64StrLength = base64Str.length;
24748 var map = this._map;
24749
24750 // Ignore padding
24751 var paddingChar = map.charAt(64);
24752 if (paddingChar) {
24753 var paddingIndex = base64Str.indexOf(paddingChar);
24754 if (paddingIndex != -1) {
24755 base64StrLength = paddingIndex;
24756 }
24757 }
24758
24759 // Convert
24760 var words = [];
24761 var nBytes = 0;
24762 for (var i = 0; i < base64StrLength; i++) {
24763 if (i % 4) {
24764 var bits1 = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2);
24765 var bits2 = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2);
24766 words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
24767 nBytes++;
24768 }
24769 }
24770
24771 return WordArray.create(words, nBytes);
24772 },
24773
24774 _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
24775 };
24776 }());
24777
24778
24779 return CryptoJS.enc.Base64;
24780
24781 }));
24782 },{"./core":31}],33:[function(_dereq_,module,exports){
24783 ;(function (root, factory) {
24784 if (typeof exports === "object") {
24785 // CommonJS
24786 module.exports = exports = factory(_dereq_("./core"));
24787 }
24788 else if (typeof define === "function" && define.amd) {
24789 // AMD
24790 define(["./core"], factory);
24791 }
24792 else {
24793 // Global (browser)
24794 factory(root.CryptoJS);
24795 }
24796 }(this, function (CryptoJS) {
24797
24798 (function () {
24799 // Shortcuts
24800 var C = CryptoJS;
24801 var C_lib = C.lib;
24802 var WordArray = C_lib.WordArray;
24803 var C_enc = C.enc;
24804
24805 /**
24806 * UTF-16 BE encoding strategy.
24807 */
24808 var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
24809 /**
24810 * Converts a word array to a UTF-16 BE string.
24811 *
24812 * @param {WordArray} wordArray The word array.
24813 *
24814 * @return {string} The UTF-16 BE string.
24815 *
24816 * @static
24817 *
24818 * @example
24819 *
24820 * var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
24821 */
24822 stringify: function (wordArray) {
24823 // Shortcuts
24824 var words = wordArray.words;
24825 var sigBytes = wordArray.sigBytes;
24826
24827 // Convert
24828 var utf16Chars = [];
24829 for (var i = 0; i < sigBytes; i += 2) {
24830 var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff;
24831 utf16Chars.push(String.fromCharCode(codePoint));
24832 }
24833
24834 return utf16Chars.join('');
24835 },
24836
24837 /**
24838 * Converts a UTF-16 BE string to a word array.
24839 *
24840 * @param {string} utf16Str The UTF-16 BE string.
24841 *
24842 * @return {WordArray} The word array.
24843 *
24844 * @static
24845 *
24846 * @example
24847 *
24848 * var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
24849 */
24850 parse: function (utf16Str) {
24851 // Shortcut
24852 var utf16StrLength = utf16Str.length;
24853
24854 // Convert
24855 var words = [];
24856 for (var i = 0; i < utf16StrLength; i++) {
24857 words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16);
24858 }
24859
24860 return WordArray.create(words, utf16StrLength * 2);
24861 }
24862 };
24863
24864 /**
24865 * UTF-16 LE encoding strategy.
24866 */
24867 C_enc.Utf16LE = {
24868 /**
24869 * Converts a word array to a UTF-16 LE string.
24870 *
24871 * @param {WordArray} wordArray The word array.
24872 *
24873 * @return {string} The UTF-16 LE string.
24874 *
24875 * @static
24876 *
24877 * @example
24878 *
24879 * var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
24880 */
24881 stringify: function (wordArray) {
24882 // Shortcuts
24883 var words = wordArray.words;
24884 var sigBytes = wordArray.sigBytes;
24885
24886 // Convert
24887 var utf16Chars = [];
24888 for (var i = 0; i < sigBytes; i += 2) {
24889 var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff);
24890 utf16Chars.push(String.fromCharCode(codePoint));
24891 }
24892
24893 return utf16Chars.join('');
24894 },
24895
24896 /**
24897 * Converts a UTF-16 LE string to a word array.
24898 *
24899 * @param {string} utf16Str The UTF-16 LE string.
24900 *
24901 * @return {WordArray} The word array.
24902 *
24903 * @static
24904 *
24905 * @example
24906 *
24907 * var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
24908 */
24909 parse: function (utf16Str) {
24910 // Shortcut
24911 var utf16StrLength = utf16Str.length;
24912
24913 // Convert
24914 var words = [];
24915 for (var i = 0; i < utf16StrLength; i++) {
24916 words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16));
24917 }
24918
24919 return WordArray.create(words, utf16StrLength * 2);
24920 }
24921 };
24922
24923 function swapEndian(word) {
24924 return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff);
24925 }
24926 }());
24927
24928
24929 return CryptoJS.enc.Utf16;
24930
24931 }));
24932 },{"./core":31}],34:[function(_dereq_,module,exports){
24933 ;(function (root, factory, undef) {
24934 if (typeof exports === "object") {
24935 // CommonJS
24936 module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha1"), _dereq_("./hmac"));
24937 }
24938 else if (typeof define === "function" && define.amd) {
24939 // AMD
24940 define(["./core", "./sha1", "./hmac"], factory);
24941 }
24942 else {
24943 // Global (browser)
24944 factory(root.CryptoJS);
24945 }
24946 }(this, function (CryptoJS) {
24947
24948 (function () {
24949 // Shortcuts
24950 var C = CryptoJS;
24951 var C_lib = C.lib;
24952 var Base = C_lib.Base;
24953 var WordArray = C_lib.WordArray;
24954 var C_algo = C.algo;
24955 var MD5 = C_algo.MD5;
24956
24957 /**
24958 * This key derivation function is meant to conform with EVP_BytesToKey.
24959 * www.openssl.org/docs/crypto/EVP_BytesToKey.html
24960 */
24961 var EvpKDF = C_algo.EvpKDF = Base.extend({
24962 /**
24963 * Configuration options.
24964 *
24965 * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
24966 * @property {Hasher} hasher The hash algorithm to use. Default: MD5
24967 * @property {number} iterations The number of iterations to perform. Default: 1
24968 */
24969 cfg: Base.extend({
24970 keySize: 128/32,
24971 hasher: MD5,
24972 iterations: 1
24973 }),
24974
24975 /**
24976 * Initializes a newly created key derivation function.
24977 *
24978 * @param {Object} cfg (Optional) The configuration options to use for the derivation.
24979 *
24980 * @example
24981 *
24982 * var kdf = CryptoJS.algo.EvpKDF.create();
24983 * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
24984 * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
24985 */
24986 init: function (cfg) {
24987 this.cfg = this.cfg.extend(cfg);
24988 },
24989
24990 /**
24991 * Derives a key from a password.
24992 *
24993 * @param {WordArray|string} password The password.
24994 * @param {WordArray|string} salt A salt.
24995 *
24996 * @return {WordArray} The derived key.
24997 *
24998 * @example
24999 *
25000 * var key = kdf.compute(password, salt);
25001 */
25002 compute: function (password, salt) {
25003 // Shortcut
25004 var cfg = this.cfg;
25005
25006 // Init hasher
25007 var hasher = cfg.hasher.create();
25008
25009 // Initial values
25010 var derivedKey = WordArray.create();
25011
25012 // Shortcuts
25013 var derivedKeyWords = derivedKey.words;
25014 var keySize = cfg.keySize;
25015 var iterations = cfg.iterations;
25016
25017 // Generate key
25018 while (derivedKeyWords.length < keySize) {
25019 if (block) {
25020 hasher.update(block);
25021 }
25022 var block = hasher.update(password).finalize(salt);
25023 hasher.reset();
25024
25025 // Iterations
25026 for (var i = 1; i < iterations; i++) {
25027 block = hasher.finalize(block);
25028 hasher.reset();
25029 }
25030
25031 derivedKey.concat(block);
25032 }
25033 derivedKey.sigBytes = keySize * 4;
25034
25035 return derivedKey;
25036 }
25037 });
25038
25039 /**
25040 * Derives a key from a password.
25041 *
25042 * @param {WordArray|string} password The password.
25043 * @param {WordArray|string} salt A salt.
25044 * @param {Object} cfg (Optional) The configuration options to use for this computation.
25045 *
25046 * @return {WordArray} The derived key.
25047 *
25048 * @static
25049 *
25050 * @example
25051 *
25052 * var key = CryptoJS.EvpKDF(password, salt);
25053 * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
25054 * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
25055 */
25056 C.EvpKDF = function (password, salt, cfg) {
25057 return EvpKDF.create(cfg).compute(password, salt);
25058 };
25059 }());
25060
25061
25062 return CryptoJS.EvpKDF;
25063
25064 }));
25065 },{"./core":31,"./hmac":36,"./sha1":55}],35:[function(_dereq_,module,exports){
25066 ;(function (root, factory, undef) {
25067 if (typeof exports === "object") {
25068 // CommonJS
25069 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25070 }
25071 else if (typeof define === "function" && define.amd) {
25072 // AMD
25073 define(["./core", "./cipher-core"], factory);
25074 }
25075 else {
25076 // Global (browser)
25077 factory(root.CryptoJS);
25078 }
25079 }(this, function (CryptoJS) {
25080
25081 (function (undefined) {
25082 // Shortcuts
25083 var C = CryptoJS;
25084 var C_lib = C.lib;
25085 var CipherParams = C_lib.CipherParams;
25086 var C_enc = C.enc;
25087 var Hex = C_enc.Hex;
25088 var C_format = C.format;
25089
25090 var HexFormatter = C_format.Hex = {
25091 /**
25092 * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
25093 *
25094 * @param {CipherParams} cipherParams The cipher params object.
25095 *
25096 * @return {string} The hexadecimally encoded string.
25097 *
25098 * @static
25099 *
25100 * @example
25101 *
25102 * var hexString = CryptoJS.format.Hex.stringify(cipherParams);
25103 */
25104 stringify: function (cipherParams) {
25105 return cipherParams.ciphertext.toString(Hex);
25106 },
25107
25108 /**
25109 * Converts a hexadecimally encoded ciphertext string to a cipher params object.
25110 *
25111 * @param {string} input The hexadecimally encoded string.
25112 *
25113 * @return {CipherParams} The cipher params object.
25114 *
25115 * @static
25116 *
25117 * @example
25118 *
25119 * var cipherParams = CryptoJS.format.Hex.parse(hexString);
25120 */
25121 parse: function (input) {
25122 var ciphertext = Hex.parse(input);
25123 return CipherParams.create({ ciphertext: ciphertext });
25124 }
25125 };
25126 }());
25127
25128
25129 return CryptoJS.format.Hex;
25130
25131 }));
25132 },{"./cipher-core":30,"./core":31}],36:[function(_dereq_,module,exports){
25133 ;(function (root, factory) {
25134 if (typeof exports === "object") {
25135 // CommonJS
25136 module.exports = exports = factory(_dereq_("./core"));
25137 }
25138 else if (typeof define === "function" && define.amd) {
25139 // AMD
25140 define(["./core"], factory);
25141 }
25142 else {
25143 // Global (browser)
25144 factory(root.CryptoJS);
25145 }
25146 }(this, function (CryptoJS) {
25147
25148 (function () {
25149 // Shortcuts
25150 var C = CryptoJS;
25151 var C_lib = C.lib;
25152 var Base = C_lib.Base;
25153 var C_enc = C.enc;
25154 var Utf8 = C_enc.Utf8;
25155 var C_algo = C.algo;
25156
25157 /**
25158 * HMAC algorithm.
25159 */
25160 var HMAC = C_algo.HMAC = Base.extend({
25161 /**
25162 * Initializes a newly created HMAC.
25163 *
25164 * @param {Hasher} hasher The hash algorithm to use.
25165 * @param {WordArray|string} key The secret key.
25166 *
25167 * @example
25168 *
25169 * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
25170 */
25171 init: function (hasher, key) {
25172 // Init hasher
25173 hasher = this._hasher = new hasher.init();
25174
25175 // Convert string to WordArray, else assume WordArray already
25176 if (typeof key == 'string') {
25177 key = Utf8.parse(key);
25178 }
25179
25180 // Shortcuts
25181 var hasherBlockSize = hasher.blockSize;
25182 var hasherBlockSizeBytes = hasherBlockSize * 4;
25183
25184 // Allow arbitrary length keys
25185 if (key.sigBytes > hasherBlockSizeBytes) {
25186 key = hasher.finalize(key);
25187 }
25188
25189 // Clamp excess bits
25190 key.clamp();
25191
25192 // Clone key for inner and outer pads
25193 var oKey = this._oKey = key.clone();
25194 var iKey = this._iKey = key.clone();
25195
25196 // Shortcuts
25197 var oKeyWords = oKey.words;
25198 var iKeyWords = iKey.words;
25199
25200 // XOR keys with pad constants
25201 for (var i = 0; i < hasherBlockSize; i++) {
25202 oKeyWords[i] ^= 0x5c5c5c5c;
25203 iKeyWords[i] ^= 0x36363636;
25204 }
25205 oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
25206
25207 // Set initial values
25208 this.reset();
25209 },
25210
25211 /**
25212 * Resets this HMAC to its initial state.
25213 *
25214 * @example
25215 *
25216 * hmacHasher.reset();
25217 */
25218 reset: function () {
25219 // Shortcut
25220 var hasher = this._hasher;
25221
25222 // Reset
25223 hasher.reset();
25224 hasher.update(this._iKey);
25225 },
25226
25227 /**
25228 * Updates this HMAC with a message.
25229 *
25230 * @param {WordArray|string} messageUpdate The message to append.
25231 *
25232 * @return {HMAC} This HMAC instance.
25233 *
25234 * @example
25235 *
25236 * hmacHasher.update('message');
25237 * hmacHasher.update(wordArray);
25238 */
25239 update: function (messageUpdate) {
25240 this._hasher.update(messageUpdate);
25241
25242 // Chainable
25243 return this;
25244 },
25245
25246 /**
25247 * Finalizes the HMAC computation.
25248 * Note that the finalize operation is effectively a destructive, read-once operation.
25249 *
25250 * @param {WordArray|string} messageUpdate (Optional) A final message update.
25251 *
25252 * @return {WordArray} The HMAC.
25253 *
25254 * @example
25255 *
25256 * var hmac = hmacHasher.finalize();
25257 * var hmac = hmacHasher.finalize('message');
25258 * var hmac = hmacHasher.finalize(wordArray);
25259 */
25260 finalize: function (messageUpdate) {
25261 // Shortcut
25262 var hasher = this._hasher;
25263
25264 // Compute HMAC
25265 var innerHash = hasher.finalize(messageUpdate);
25266 hasher.reset();
25267 var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
25268
25269 return hmac;
25270 }
25271 });
25272 }());
25273
25274
25275 }));
25276 },{"./core":31}],37:[function(_dereq_,module,exports){
25277 ;(function (root, factory, undef) {
25278 if (typeof exports === "object") {
25279 // CommonJS
25280 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"));
25281 }
25282 else if (typeof define === "function" && define.amd) {
25283 // AMD
25284 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);
25285 }
25286 else {
25287 // Global (browser)
25288 factory(root.CryptoJS);
25289 }
25290 }(this, function (CryptoJS) {
25291
25292 return CryptoJS;
25293
25294 }));
25295 },{"./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){
25296 ;(function (root, factory) {
25297 if (typeof exports === "object") {
25298 // CommonJS
25299 module.exports = exports = factory(_dereq_("./core"));
25300 }
25301 else if (typeof define === "function" && define.amd) {
25302 // AMD
25303 define(["./core"], factory);
25304 }
25305 else {
25306 // Global (browser)
25307 factory(root.CryptoJS);
25308 }
25309 }(this, function (CryptoJS) {
25310
25311 (function () {
25312 // Check if typed arrays are supported
25313 if (typeof ArrayBuffer != 'function') {
25314 return;
25315 }
25316
25317 // Shortcuts
25318 var C = CryptoJS;
25319 var C_lib = C.lib;
25320 var WordArray = C_lib.WordArray;
25321
25322 // Reference original init
25323 var superInit = WordArray.init;
25324
25325 // Augment WordArray.init to handle typed arrays
25326 var subInit = WordArray.init = function (typedArray) {
25327 // Convert buffers to uint8
25328 if (typedArray instanceof ArrayBuffer) {
25329 typedArray = new Uint8Array(typedArray);
25330 }
25331
25332 // Convert other array views to uint8
25333 if (
25334 typedArray instanceof Int8Array ||
25335 typedArray instanceof Uint8ClampedArray ||
25336 typedArray instanceof Int16Array ||
25337 typedArray instanceof Uint16Array ||
25338 typedArray instanceof Int32Array ||
25339 typedArray instanceof Uint32Array ||
25340 typedArray instanceof Float32Array ||
25341 typedArray instanceof Float64Array
25342 ) {
25343 typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
25344 }
25345
25346 // Handle Uint8Array
25347 if (typedArray instanceof Uint8Array) {
25348 // Shortcut
25349 var typedArrayByteLength = typedArray.byteLength;
25350
25351 // Extract bytes
25352 var words = [];
25353 for (var i = 0; i < typedArrayByteLength; i++) {
25354 words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8);
25355 }
25356
25357 // Initialize this word array
25358 superInit.call(this, words, typedArrayByteLength);
25359 } else {
25360 // Else call normal init
25361 superInit.apply(this, arguments);
25362 }
25363 };
25364
25365 subInit.prototype = WordArray;
25366 }());
25367
25368
25369 return CryptoJS.lib.WordArray;
25370
25371 }));
25372 },{"./core":31}],39:[function(_dereq_,module,exports){
25373 ;(function (root, factory) {
25374 if (typeof exports === "object") {
25375 // CommonJS
25376 module.exports = exports = factory(_dereq_("./core"));
25377 }
25378 else if (typeof define === "function" && define.amd) {
25379 // AMD
25380 define(["./core"], factory);
25381 }
25382 else {
25383 // Global (browser)
25384 factory(root.CryptoJS);
25385 }
25386 }(this, function (CryptoJS) {
25387
25388 (function (Math) {
25389 // Shortcuts
25390 var C = CryptoJS;
25391 var C_lib = C.lib;
25392 var WordArray = C_lib.WordArray;
25393 var Hasher = C_lib.Hasher;
25394 var C_algo = C.algo;
25395
25396 // Constants table
25397 var T = [];
25398
25399 // Compute constants
25400 (function () {
25401 for (var i = 0; i < 64; i++) {
25402 T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
25403 }
25404 }());
25405
25406 /**
25407 * MD5 hash algorithm.
25408 */
25409 var MD5 = C_algo.MD5 = Hasher.extend({
25410 _doReset: function () {
25411 this._hash = new WordArray.init([
25412 0x67452301, 0xefcdab89,
25413 0x98badcfe, 0x10325476
25414 ]);
25415 },
25416
25417 _doProcessBlock: function (M, offset) {
25418 // Swap endian
25419 for (var i = 0; i < 16; i++) {
25420 // Shortcuts
25421 var offset_i = offset + i;
25422 var M_offset_i = M[offset_i];
25423
25424 M[offset_i] = (
25425 (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
25426 (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
25427 );
25428 }
25429
25430 // Shortcuts
25431 var H = this._hash.words;
25432
25433 var M_offset_0 = M[offset + 0];
25434 var M_offset_1 = M[offset + 1];
25435 var M_offset_2 = M[offset + 2];
25436 var M_offset_3 = M[offset + 3];
25437 var M_offset_4 = M[offset + 4];
25438 var M_offset_5 = M[offset + 5];
25439 var M_offset_6 = M[offset + 6];
25440 var M_offset_7 = M[offset + 7];
25441 var M_offset_8 = M[offset + 8];
25442 var M_offset_9 = M[offset + 9];
25443 var M_offset_10 = M[offset + 10];
25444 var M_offset_11 = M[offset + 11];
25445 var M_offset_12 = M[offset + 12];
25446 var M_offset_13 = M[offset + 13];
25447 var M_offset_14 = M[offset + 14];
25448 var M_offset_15 = M[offset + 15];
25449
25450 // Working varialbes
25451 var a = H[0];
25452 var b = H[1];
25453 var c = H[2];
25454 var d = H[3];
25455
25456 // Computation
25457 a = FF(a, b, c, d, M_offset_0, 7, T[0]);
25458 d = FF(d, a, b, c, M_offset_1, 12, T[1]);
25459 c = FF(c, d, a, b, M_offset_2, 17, T[2]);
25460 b = FF(b, c, d, a, M_offset_3, 22, T[3]);
25461 a = FF(a, b, c, d, M_offset_4, 7, T[4]);
25462 d = FF(d, a, b, c, M_offset_5, 12, T[5]);
25463 c = FF(c, d, a, b, M_offset_6, 17, T[6]);
25464 b = FF(b, c, d, a, M_offset_7, 22, T[7]);
25465 a = FF(a, b, c, d, M_offset_8, 7, T[8]);
25466 d = FF(d, a, b, c, M_offset_9, 12, T[9]);
25467 c = FF(c, d, a, b, M_offset_10, 17, T[10]);
25468 b = FF(b, c, d, a, M_offset_11, 22, T[11]);
25469 a = FF(a, b, c, d, M_offset_12, 7, T[12]);
25470 d = FF(d, a, b, c, M_offset_13, 12, T[13]);
25471 c = FF(c, d, a, b, M_offset_14, 17, T[14]);
25472 b = FF(b, c, d, a, M_offset_15, 22, T[15]);
25473
25474 a = GG(a, b, c, d, M_offset_1, 5, T[16]);
25475 d = GG(d, a, b, c, M_offset_6, 9, T[17]);
25476 c = GG(c, d, a, b, M_offset_11, 14, T[18]);
25477 b = GG(b, c, d, a, M_offset_0, 20, T[19]);
25478 a = GG(a, b, c, d, M_offset_5, 5, T[20]);
25479 d = GG(d, a, b, c, M_offset_10, 9, T[21]);
25480 c = GG(c, d, a, b, M_offset_15, 14, T[22]);
25481 b = GG(b, c, d, a, M_offset_4, 20, T[23]);
25482 a = GG(a, b, c, d, M_offset_9, 5, T[24]);
25483 d = GG(d, a, b, c, M_offset_14, 9, T[25]);
25484 c = GG(c, d, a, b, M_offset_3, 14, T[26]);
25485 b = GG(b, c, d, a, M_offset_8, 20, T[27]);
25486 a = GG(a, b, c, d, M_offset_13, 5, T[28]);
25487 d = GG(d, a, b, c, M_offset_2, 9, T[29]);
25488 c = GG(c, d, a, b, M_offset_7, 14, T[30]);
25489 b = GG(b, c, d, a, M_offset_12, 20, T[31]);
25490
25491 a = HH(a, b, c, d, M_offset_5, 4, T[32]);
25492 d = HH(d, a, b, c, M_offset_8, 11, T[33]);
25493 c = HH(c, d, a, b, M_offset_11, 16, T[34]);
25494 b = HH(b, c, d, a, M_offset_14, 23, T[35]);
25495 a = HH(a, b, c, d, M_offset_1, 4, T[36]);
25496 d = HH(d, a, b, c, M_offset_4, 11, T[37]);
25497 c = HH(c, d, a, b, M_offset_7, 16, T[38]);
25498 b = HH(b, c, d, a, M_offset_10, 23, T[39]);
25499 a = HH(a, b, c, d, M_offset_13, 4, T[40]);
25500 d = HH(d, a, b, c, M_offset_0, 11, T[41]);
25501 c = HH(c, d, a, b, M_offset_3, 16, T[42]);
25502 b = HH(b, c, d, a, M_offset_6, 23, T[43]);
25503 a = HH(a, b, c, d, M_offset_9, 4, T[44]);
25504 d = HH(d, a, b, c, M_offset_12, 11, T[45]);
25505 c = HH(c, d, a, b, M_offset_15, 16, T[46]);
25506 b = HH(b, c, d, a, M_offset_2, 23, T[47]);
25507
25508 a = II(a, b, c, d, M_offset_0, 6, T[48]);
25509 d = II(d, a, b, c, M_offset_7, 10, T[49]);
25510 c = II(c, d, a, b, M_offset_14, 15, T[50]);
25511 b = II(b, c, d, a, M_offset_5, 21, T[51]);
25512 a = II(a, b, c, d, M_offset_12, 6, T[52]);
25513 d = II(d, a, b, c, M_offset_3, 10, T[53]);
25514 c = II(c, d, a, b, M_offset_10, 15, T[54]);
25515 b = II(b, c, d, a, M_offset_1, 21, T[55]);
25516 a = II(a, b, c, d, M_offset_8, 6, T[56]);
25517 d = II(d, a, b, c, M_offset_15, 10, T[57]);
25518 c = II(c, d, a, b, M_offset_6, 15, T[58]);
25519 b = II(b, c, d, a, M_offset_13, 21, T[59]);
25520 a = II(a, b, c, d, M_offset_4, 6, T[60]);
25521 d = II(d, a, b, c, M_offset_11, 10, T[61]);
25522 c = II(c, d, a, b, M_offset_2, 15, T[62]);
25523 b = II(b, c, d, a, M_offset_9, 21, T[63]);
25524
25525 // Intermediate hash value
25526 H[0] = (H[0] + a) | 0;
25527 H[1] = (H[1] + b) | 0;
25528 H[2] = (H[2] + c) | 0;
25529 H[3] = (H[3] + d) | 0;
25530 },
25531
25532 _doFinalize: function () {
25533 // Shortcuts
25534 var data = this._data;
25535 var dataWords = data.words;
25536
25537 var nBitsTotal = this._nDataBytes * 8;
25538 var nBitsLeft = data.sigBytes * 8;
25539
25540 // Add padding
25541 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
25542
25543 var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
25544 var nBitsTotalL = nBitsTotal;
25545 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
25546 (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
25547 (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
25548 );
25549 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
25550 (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
25551 (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
25552 );
25553
25554 data.sigBytes = (dataWords.length + 1) * 4;
25555
25556 // Hash final blocks
25557 this._process();
25558
25559 // Shortcuts
25560 var hash = this._hash;
25561 var H = hash.words;
25562
25563 // Swap endian
25564 for (var i = 0; i < 4; i++) {
25565 // Shortcut
25566 var H_i = H[i];
25567
25568 H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
25569 (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
25570 }
25571
25572 // Return final computed hash
25573 return hash;
25574 },
25575
25576 clone: function () {
25577 var clone = Hasher.clone.call(this);
25578 clone._hash = this._hash.clone();
25579
25580 return clone;
25581 }
25582 });
25583
25584 function FF(a, b, c, d, x, s, t) {
25585 var n = a + ((b & c) | (~b & d)) + x + t;
25586 return ((n << s) | (n >>> (32 - s))) + b;
25587 }
25588
25589 function GG(a, b, c, d, x, s, t) {
25590 var n = a + ((b & d) | (c & ~d)) + x + t;
25591 return ((n << s) | (n >>> (32 - s))) + b;
25592 }
25593
25594 function HH(a, b, c, d, x, s, t) {
25595 var n = a + (b ^ c ^ d) + x + t;
25596 return ((n << s) | (n >>> (32 - s))) + b;
25597 }
25598
25599 function II(a, b, c, d, x, s, t) {
25600 var n = a + (c ^ (b | ~d)) + x + t;
25601 return ((n << s) | (n >>> (32 - s))) + b;
25602 }
25603
25604 /**
25605 * Shortcut function to the hasher's object interface.
25606 *
25607 * @param {WordArray|string} message The message to hash.
25608 *
25609 * @return {WordArray} The hash.
25610 *
25611 * @static
25612 *
25613 * @example
25614 *
25615 * var hash = CryptoJS.MD5('message');
25616 * var hash = CryptoJS.MD5(wordArray);
25617 */
25618 C.MD5 = Hasher._createHelper(MD5);
25619
25620 /**
25621 * Shortcut function to the HMAC's object interface.
25622 *
25623 * @param {WordArray|string} message The message to hash.
25624 * @param {WordArray|string} key The secret key.
25625 *
25626 * @return {WordArray} The HMAC.
25627 *
25628 * @static
25629 *
25630 * @example
25631 *
25632 * var hmac = CryptoJS.HmacMD5(message, key);
25633 */
25634 C.HmacMD5 = Hasher._createHmacHelper(MD5);
25635 }(Math));
25636
25637
25638 return CryptoJS.MD5;
25639
25640 }));
25641 },{"./core":31}],40:[function(_dereq_,module,exports){
25642 ;(function (root, factory, undef) {
25643 if (typeof exports === "object") {
25644 // CommonJS
25645 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25646 }
25647 else if (typeof define === "function" && define.amd) {
25648 // AMD
25649 define(["./core", "./cipher-core"], factory);
25650 }
25651 else {
25652 // Global (browser)
25653 factory(root.CryptoJS);
25654 }
25655 }(this, function (CryptoJS) {
25656
25657 /**
25658 * Cipher Feedback block mode.
25659 */
25660 CryptoJS.mode.CFB = (function () {
25661 var CFB = CryptoJS.lib.BlockCipherMode.extend();
25662
25663 CFB.Encryptor = CFB.extend({
25664 processBlock: function (words, offset) {
25665 // Shortcuts
25666 var cipher = this._cipher;
25667 var blockSize = cipher.blockSize;
25668
25669 generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
25670
25671 // Remember this block to use with next block
25672 this._prevBlock = words.slice(offset, offset + blockSize);
25673 }
25674 });
25675
25676 CFB.Decryptor = CFB.extend({
25677 processBlock: function (words, offset) {
25678 // Shortcuts
25679 var cipher = this._cipher;
25680 var blockSize = cipher.blockSize;
25681
25682 // Remember this block to use with next block
25683 var thisBlock = words.slice(offset, offset + blockSize);
25684
25685 generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
25686
25687 // This block becomes the previous block
25688 this._prevBlock = thisBlock;
25689 }
25690 });
25691
25692 function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
25693 // Shortcut
25694 var iv = this._iv;
25695
25696 // Generate keystream
25697 if (iv) {
25698 var keystream = iv.slice(0);
25699
25700 // Remove IV for subsequent blocks
25701 this._iv = undefined;
25702 } else {
25703 var keystream = this._prevBlock;
25704 }
25705 cipher.encryptBlock(keystream, 0);
25706
25707 // Encrypt
25708 for (var i = 0; i < blockSize; i++) {
25709 words[offset + i] ^= keystream[i];
25710 }
25711 }
25712
25713 return CFB;
25714 }());
25715
25716
25717 return CryptoJS.mode.CFB;
25718
25719 }));
25720 },{"./cipher-core":30,"./core":31}],41:[function(_dereq_,module,exports){
25721 ;(function (root, factory, undef) {
25722 if (typeof exports === "object") {
25723 // CommonJS
25724 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25725 }
25726 else if (typeof define === "function" && define.amd) {
25727 // AMD
25728 define(["./core", "./cipher-core"], factory);
25729 }
25730 else {
25731 // Global (browser)
25732 factory(root.CryptoJS);
25733 }
25734 }(this, function (CryptoJS) {
25735
25736 /** @preserve
25737 * Counter block mode compatible with Dr Brian Gladman fileenc.c
25738 * derived from CryptoJS.mode.CTR
25739 * Jan Hruby jhruby.web@gmail.com
25740 */
25741 CryptoJS.mode.CTRGladman = (function () {
25742 var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();
25743
25744 function incWord(word)
25745 {
25746 if (((word >> 24) & 0xff) === 0xff) { //overflow
25747 var b1 = (word >> 16)&0xff;
25748 var b2 = (word >> 8)&0xff;
25749 var b3 = word & 0xff;
25750
25751 if (b1 === 0xff) // overflow b1
25752 {
25753 b1 = 0;
25754 if (b2 === 0xff)
25755 {
25756 b2 = 0;
25757 if (b3 === 0xff)
25758 {
25759 b3 = 0;
25760 }
25761 else
25762 {
25763 ++b3;
25764 }
25765 }
25766 else
25767 {
25768 ++b2;
25769 }
25770 }
25771 else
25772 {
25773 ++b1;
25774 }
25775
25776 word = 0;
25777 word += (b1 << 16);
25778 word += (b2 << 8);
25779 word += b3;
25780 }
25781 else
25782 {
25783 word += (0x01 << 24);
25784 }
25785 return word;
25786 }
25787
25788 function incCounter(counter)
25789 {
25790 if ((counter[0] = incWord(counter[0])) === 0)
25791 {
25792 // encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8
25793 counter[1] = incWord(counter[1]);
25794 }
25795 return counter;
25796 }
25797
25798 var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
25799 processBlock: function (words, offset) {
25800 // Shortcuts
25801 var cipher = this._cipher
25802 var blockSize = cipher.blockSize;
25803 var iv = this._iv;
25804 var counter = this._counter;
25805
25806 // Generate keystream
25807 if (iv) {
25808 counter = this._counter = iv.slice(0);
25809
25810 // Remove IV for subsequent blocks
25811 this._iv = undefined;
25812 }
25813
25814 incCounter(counter);
25815
25816 var keystream = counter.slice(0);
25817 cipher.encryptBlock(keystream, 0);
25818
25819 // Encrypt
25820 for (var i = 0; i < blockSize; i++) {
25821 words[offset + i] ^= keystream[i];
25822 }
25823 }
25824 });
25825
25826 CTRGladman.Decryptor = Encryptor;
25827
25828 return CTRGladman;
25829 }());
25830
25831
25832
25833
25834 return CryptoJS.mode.CTRGladman;
25835
25836 }));
25837 },{"./cipher-core":30,"./core":31}],42:[function(_dereq_,module,exports){
25838 ;(function (root, factory, undef) {
25839 if (typeof exports === "object") {
25840 // CommonJS
25841 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25842 }
25843 else if (typeof define === "function" && define.amd) {
25844 // AMD
25845 define(["./core", "./cipher-core"], factory);
25846 }
25847 else {
25848 // Global (browser)
25849 factory(root.CryptoJS);
25850 }
25851 }(this, function (CryptoJS) {
25852
25853 /**
25854 * Counter block mode.
25855 */
25856 CryptoJS.mode.CTR = (function () {
25857 var CTR = CryptoJS.lib.BlockCipherMode.extend();
25858
25859 var Encryptor = CTR.Encryptor = CTR.extend({
25860 processBlock: function (words, offset) {
25861 // Shortcuts
25862 var cipher = this._cipher
25863 var blockSize = cipher.blockSize;
25864 var iv = this._iv;
25865 var counter = this._counter;
25866
25867 // Generate keystream
25868 if (iv) {
25869 counter = this._counter = iv.slice(0);
25870
25871 // Remove IV for subsequent blocks
25872 this._iv = undefined;
25873 }
25874 var keystream = counter.slice(0);
25875 cipher.encryptBlock(keystream, 0);
25876
25877 // Increment counter
25878 counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0
25879
25880 // Encrypt
25881 for (var i = 0; i < blockSize; i++) {
25882 words[offset + i] ^= keystream[i];
25883 }
25884 }
25885 });
25886
25887 CTR.Decryptor = Encryptor;
25888
25889 return CTR;
25890 }());
25891
25892
25893 return CryptoJS.mode.CTR;
25894
25895 }));
25896 },{"./cipher-core":30,"./core":31}],43:[function(_dereq_,module,exports){
25897 ;(function (root, factory, undef) {
25898 if (typeof exports === "object") {
25899 // CommonJS
25900 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25901 }
25902 else if (typeof define === "function" && define.amd) {
25903 // AMD
25904 define(["./core", "./cipher-core"], factory);
25905 }
25906 else {
25907 // Global (browser)
25908 factory(root.CryptoJS);
25909 }
25910 }(this, function (CryptoJS) {
25911
25912 /**
25913 * Electronic Codebook block mode.
25914 */
25915 CryptoJS.mode.ECB = (function () {
25916 var ECB = CryptoJS.lib.BlockCipherMode.extend();
25917
25918 ECB.Encryptor = ECB.extend({
25919 processBlock: function (words, offset) {
25920 this._cipher.encryptBlock(words, offset);
25921 }
25922 });
25923
25924 ECB.Decryptor = ECB.extend({
25925 processBlock: function (words, offset) {
25926 this._cipher.decryptBlock(words, offset);
25927 }
25928 });
25929
25930 return ECB;
25931 }());
25932
25933
25934 return CryptoJS.mode.ECB;
25935
25936 }));
25937 },{"./cipher-core":30,"./core":31}],44:[function(_dereq_,module,exports){
25938 ;(function (root, factory, undef) {
25939 if (typeof exports === "object") {
25940 // CommonJS
25941 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25942 }
25943 else if (typeof define === "function" && define.amd) {
25944 // AMD
25945 define(["./core", "./cipher-core"], factory);
25946 }
25947 else {
25948 // Global (browser)
25949 factory(root.CryptoJS);
25950 }
25951 }(this, function (CryptoJS) {
25952
25953 /**
25954 * Output Feedback block mode.
25955 */
25956 CryptoJS.mode.OFB = (function () {
25957 var OFB = CryptoJS.lib.BlockCipherMode.extend();
25958
25959 var Encryptor = OFB.Encryptor = OFB.extend({
25960 processBlock: function (words, offset) {
25961 // Shortcuts
25962 var cipher = this._cipher
25963 var blockSize = cipher.blockSize;
25964 var iv = this._iv;
25965 var keystream = this._keystream;
25966
25967 // Generate keystream
25968 if (iv) {
25969 keystream = this._keystream = iv.slice(0);
25970
25971 // Remove IV for subsequent blocks
25972 this._iv = undefined;
25973 }
25974 cipher.encryptBlock(keystream, 0);
25975
25976 // Encrypt
25977 for (var i = 0; i < blockSize; i++) {
25978 words[offset + i] ^= keystream[i];
25979 }
25980 }
25981 });
25982
25983 OFB.Decryptor = Encryptor;
25984
25985 return OFB;
25986 }());
25987
25988
25989 return CryptoJS.mode.OFB;
25990
25991 }));
25992 },{"./cipher-core":30,"./core":31}],45:[function(_dereq_,module,exports){
25993 ;(function (root, factory, undef) {
25994 if (typeof exports === "object") {
25995 // CommonJS
25996 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
25997 }
25998 else if (typeof define === "function" && define.amd) {
25999 // AMD
26000 define(["./core", "./cipher-core"], factory);
26001 }
26002 else {
26003 // Global (browser)
26004 factory(root.CryptoJS);
26005 }
26006 }(this, function (CryptoJS) {
26007
26008 /**
26009 * ANSI X.923 padding strategy.
26010 */
26011 CryptoJS.pad.AnsiX923 = {
26012 pad: function (data, blockSize) {
26013 // Shortcuts
26014 var dataSigBytes = data.sigBytes;
26015 var blockSizeBytes = blockSize * 4;
26016
26017 // Count padding bytes
26018 var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
26019
26020 // Compute last byte position
26021 var lastBytePos = dataSigBytes + nPaddingBytes - 1;
26022
26023 // Pad
26024 data.clamp();
26025 data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8);
26026 data.sigBytes += nPaddingBytes;
26027 },
26028
26029 unpad: function (data) {
26030 // Get number of padding bytes from last byte
26031 var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
26032
26033 // Remove padding
26034 data.sigBytes -= nPaddingBytes;
26035 }
26036 };
26037
26038
26039 return CryptoJS.pad.Ansix923;
26040
26041 }));
26042 },{"./cipher-core":30,"./core":31}],46:[function(_dereq_,module,exports){
26043 ;(function (root, factory, undef) {
26044 if (typeof exports === "object") {
26045 // CommonJS
26046 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
26047 }
26048 else if (typeof define === "function" && define.amd) {
26049 // AMD
26050 define(["./core", "./cipher-core"], factory);
26051 }
26052 else {
26053 // Global (browser)
26054 factory(root.CryptoJS);
26055 }
26056 }(this, function (CryptoJS) {
26057
26058 /**
26059 * ISO 10126 padding strategy.
26060 */
26061 CryptoJS.pad.Iso10126 = {
26062 pad: function (data, blockSize) {
26063 // Shortcut
26064 var blockSizeBytes = blockSize * 4;
26065
26066 // Count padding bytes
26067 var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
26068
26069 // Pad
26070 data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).
26071 concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1));
26072 },
26073
26074 unpad: function (data) {
26075 // Get number of padding bytes from last byte
26076 var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
26077
26078 // Remove padding
26079 data.sigBytes -= nPaddingBytes;
26080 }
26081 };
26082
26083
26084 return CryptoJS.pad.Iso10126;
26085
26086 }));
26087 },{"./cipher-core":30,"./core":31}],47:[function(_dereq_,module,exports){
26088 ;(function (root, factory, undef) {
26089 if (typeof exports === "object") {
26090 // CommonJS
26091 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
26092 }
26093 else if (typeof define === "function" && define.amd) {
26094 // AMD
26095 define(["./core", "./cipher-core"], factory);
26096 }
26097 else {
26098 // Global (browser)
26099 factory(root.CryptoJS);
26100 }
26101 }(this, function (CryptoJS) {
26102
26103 /**
26104 * ISO/IEC 9797-1 Padding Method 2.
26105 */
26106 CryptoJS.pad.Iso97971 = {
26107 pad: function (data, blockSize) {
26108 // Add 0x80 byte
26109 data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
26110
26111 // Zero pad the rest
26112 CryptoJS.pad.ZeroPadding.pad(data, blockSize);
26113 },
26114
26115 unpad: function (data) {
26116 // Remove zero padding
26117 CryptoJS.pad.ZeroPadding.unpad(data);
26118
26119 // Remove one more byte -- the 0x80 byte
26120 data.sigBytes--;
26121 }
26122 };
26123
26124
26125 return CryptoJS.pad.Iso97971;
26126
26127 }));
26128 },{"./cipher-core":30,"./core":31}],48:[function(_dereq_,module,exports){
26129 ;(function (root, factory, undef) {
26130 if (typeof exports === "object") {
26131 // CommonJS
26132 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
26133 }
26134 else if (typeof define === "function" && define.amd) {
26135 // AMD
26136 define(["./core", "./cipher-core"], factory);
26137 }
26138 else {
26139 // Global (browser)
26140 factory(root.CryptoJS);
26141 }
26142 }(this, function (CryptoJS) {
26143
26144 /**
26145 * A noop padding strategy.
26146 */
26147 CryptoJS.pad.NoPadding = {
26148 pad: function () {
26149 },
26150
26151 unpad: function () {
26152 }
26153 };
26154
26155
26156 return CryptoJS.pad.NoPadding;
26157
26158 }));
26159 },{"./cipher-core":30,"./core":31}],49:[function(_dereq_,module,exports){
26160 ;(function (root, factory, undef) {
26161 if (typeof exports === "object") {
26162 // CommonJS
26163 module.exports = exports = factory(_dereq_("./core"), _dereq_("./cipher-core"));
26164 }
26165 else if (typeof define === "function" && define.amd) {
26166 // AMD
26167 define(["./core", "./cipher-core"], factory);
26168 }
26169 else {
26170 // Global (browser)
26171 factory(root.CryptoJS);
26172 }
26173 }(this, function (CryptoJS) {
26174
26175 /**
26176 * Zero padding strategy.
26177 */
26178 CryptoJS.pad.ZeroPadding = {
26179 pad: function (data, blockSize) {
26180 // Shortcut
26181 var blockSizeBytes = blockSize * 4;
26182
26183 // Pad
26184 data.clamp();
26185 data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
26186 },
26187
26188 unpad: function (data) {
26189 // Shortcut
26190 var dataWords = data.words;
26191
26192 // Unpad
26193 var i = data.sigBytes - 1;
26194 while (!((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
26195 i--;
26196 }
26197 data.sigBytes = i + 1;
26198 }
26199 };
26200
26201
26202 return CryptoJS.pad.ZeroPadding;
26203
26204 }));
26205 },{"./cipher-core":30,"./core":31}],50:[function(_dereq_,module,exports){
26206 ;(function (root, factory, undef) {
26207 if (typeof exports === "object") {
26208 // CommonJS
26209 module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha1"), _dereq_("./hmac"));
26210 }
26211 else if (typeof define === "function" && define.amd) {
26212 // AMD
26213 define(["./core", "./sha1", "./hmac"], factory);
26214 }
26215 else {
26216 // Global (browser)
26217 factory(root.CryptoJS);
26218 }
26219 }(this, function (CryptoJS) {
26220
26221 (function () {
26222 // Shortcuts
26223 var C = CryptoJS;
26224 var C_lib = C.lib;
26225 var Base = C_lib.Base;
26226 var WordArray = C_lib.WordArray;
26227 var C_algo = C.algo;
26228 var SHA1 = C_algo.SHA1;
26229 var HMAC = C_algo.HMAC;
26230
26231 /**
26232 * Password-Based Key Derivation Function 2 algorithm.
26233 */
26234 var PBKDF2 = C_algo.PBKDF2 = Base.extend({
26235 /**
26236 * Configuration options.
26237 *
26238 * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
26239 * @property {Hasher} hasher The hasher to use. Default: SHA1
26240 * @property {number} iterations The number of iterations to perform. Default: 1
26241 */
26242 cfg: Base.extend({
26243 keySize: 128/32,
26244 hasher: SHA1,
26245 iterations: 1
26246 }),
26247
26248 /**
26249 * Initializes a newly created key derivation function.
26250 *
26251 * @param {Object} cfg (Optional) The configuration options to use for the derivation.
26252 *
26253 * @example
26254 *
26255 * var kdf = CryptoJS.algo.PBKDF2.create();
26256 * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
26257 * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
26258 */
26259 init: function (cfg) {
26260 this.cfg = this.cfg.extend(cfg);
26261 },
26262
26263 /**
26264 * Computes the Password-Based Key Derivation Function 2.
26265 *
26266 * @param {WordArray|string} password The password.
26267 * @param {WordArray|string} salt A salt.
26268 *
26269 * @return {WordArray} The derived key.
26270 *
26271 * @example
26272 *
26273 * var key = kdf.compute(password, salt);
26274 */
26275 compute: function (password, salt) {
26276 // Shortcut
26277 var cfg = this.cfg;
26278
26279 // Init HMAC
26280 var hmac = HMAC.create(cfg.hasher, password);
26281
26282 // Initial values
26283 var derivedKey = WordArray.create();
26284 var blockIndex = WordArray.create([0x00000001]);
26285
26286 // Shortcuts
26287 var derivedKeyWords = derivedKey.words;
26288 var blockIndexWords = blockIndex.words;
26289 var keySize = cfg.keySize;
26290 var iterations = cfg.iterations;
26291
26292 // Generate key
26293 while (derivedKeyWords.length < keySize) {
26294 var block = hmac.update(salt).finalize(blockIndex);
26295 hmac.reset();
26296
26297 // Shortcuts
26298 var blockWords = block.words;
26299 var blockWordsLength = blockWords.length;
26300
26301 // Iterations
26302 var intermediate = block;
26303 for (var i = 1; i < iterations; i++) {
26304 intermediate = hmac.finalize(intermediate);
26305 hmac.reset();
26306
26307 // Shortcut
26308 var intermediateWords = intermediate.words;
26309
26310 // XOR intermediate with block
26311 for (var j = 0; j < blockWordsLength; j++) {
26312 blockWords[j] ^= intermediateWords[j];
26313 }
26314 }
26315
26316 derivedKey.concat(block);
26317 blockIndexWords[0]++;
26318 }
26319 derivedKey.sigBytes = keySize * 4;
26320
26321 return derivedKey;
26322 }
26323 });
26324
26325 /**
26326 * Computes the Password-Based Key Derivation Function 2.
26327 *
26328 * @param {WordArray|string} password The password.
26329 * @param {WordArray|string} salt A salt.
26330 * @param {Object} cfg (Optional) The configuration options to use for this computation.
26331 *
26332 * @return {WordArray} The derived key.
26333 *
26334 * @static
26335 *
26336 * @example
26337 *
26338 * var key = CryptoJS.PBKDF2(password, salt);
26339 * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 });
26340 * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 });
26341 */
26342 C.PBKDF2 = function (password, salt, cfg) {
26343 return PBKDF2.create(cfg).compute(password, salt);
26344 };
26345 }());
26346
26347
26348 return CryptoJS.PBKDF2;
26349
26350 }));
26351 },{"./core":31,"./hmac":36,"./sha1":55}],51:[function(_dereq_,module,exports){
26352 ;(function (root, factory, undef) {
26353 if (typeof exports === "object") {
26354 // CommonJS
26355 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
26356 }
26357 else if (typeof define === "function" && define.amd) {
26358 // AMD
26359 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
26360 }
26361 else {
26362 // Global (browser)
26363 factory(root.CryptoJS);
26364 }
26365 }(this, function (CryptoJS) {
26366
26367 (function () {
26368 // Shortcuts
26369 var C = CryptoJS;
26370 var C_lib = C.lib;
26371 var StreamCipher = C_lib.StreamCipher;
26372 var C_algo = C.algo;
26373
26374 // Reusable objects
26375 var S = [];
26376 var C_ = [];
26377 var G = [];
26378
26379 /**
26380 * Rabbit stream cipher algorithm.
26381 *
26382 * This is a legacy version that neglected to convert the key to little-endian.
26383 * This error doesn't affect the cipher's security,
26384 * but it does affect its compatibility with other implementations.
26385 */
26386 var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
26387 _doReset: function () {
26388 // Shortcuts
26389 var K = this._key.words;
26390 var iv = this.cfg.iv;
26391
26392 // Generate initial state values
26393 var X = this._X = [
26394 K[0], (K[3] << 16) | (K[2] >>> 16),
26395 K[1], (K[0] << 16) | (K[3] >>> 16),
26396 K[2], (K[1] << 16) | (K[0] >>> 16),
26397 K[3], (K[2] << 16) | (K[1] >>> 16)
26398 ];
26399
26400 // Generate initial counter values
26401 var C = this._C = [
26402 (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
26403 (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
26404 (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
26405 (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
26406 ];
26407
26408 // Carry bit
26409 this._b = 0;
26410
26411 // Iterate the system four times
26412 for (var i = 0; i < 4; i++) {
26413 nextState.call(this);
26414 }
26415
26416 // Modify the counters
26417 for (var i = 0; i < 8; i++) {
26418 C[i] ^= X[(i + 4) & 7];
26419 }
26420
26421 // IV setup
26422 if (iv) {
26423 // Shortcuts
26424 var IV = iv.words;
26425 var IV_0 = IV[0];
26426 var IV_1 = IV[1];
26427
26428 // Generate four subvectors
26429 var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
26430 var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
26431 var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
26432 var i3 = (i2 << 16) | (i0 & 0x0000ffff);
26433
26434 // Modify counter values
26435 C[0] ^= i0;
26436 C[1] ^= i1;
26437 C[2] ^= i2;
26438 C[3] ^= i3;
26439 C[4] ^= i0;
26440 C[5] ^= i1;
26441 C[6] ^= i2;
26442 C[7] ^= i3;
26443
26444 // Iterate the system four times
26445 for (var i = 0; i < 4; i++) {
26446 nextState.call(this);
26447 }
26448 }
26449 },
26450
26451 _doProcessBlock: function (M, offset) {
26452 // Shortcut
26453 var X = this._X;
26454
26455 // Iterate the system
26456 nextState.call(this);
26457
26458 // Generate four keystream words
26459 S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
26460 S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
26461 S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
26462 S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
26463
26464 for (var i = 0; i < 4; i++) {
26465 // Swap endian
26466 S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
26467 (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
26468
26469 // Encrypt
26470 M[offset + i] ^= S[i];
26471 }
26472 },
26473
26474 blockSize: 128/32,
26475
26476 ivSize: 64/32
26477 });
26478
26479 function nextState() {
26480 // Shortcuts
26481 var X = this._X;
26482 var C = this._C;
26483
26484 // Save old counter values
26485 for (var i = 0; i < 8; i++) {
26486 C_[i] = C[i];
26487 }
26488
26489 // Calculate new counter values
26490 C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
26491 C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
26492 C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
26493 C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
26494 C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
26495 C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
26496 C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
26497 C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
26498 this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
26499
26500 // Calculate the g-values
26501 for (var i = 0; i < 8; i++) {
26502 var gx = X[i] + C[i];
26503
26504 // Construct high and low argument for squaring
26505 var ga = gx & 0xffff;
26506 var gb = gx >>> 16;
26507
26508 // Calculate high and low result of squaring
26509 var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
26510 var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
26511
26512 // High XOR low
26513 G[i] = gh ^ gl;
26514 }
26515
26516 // Calculate new state values
26517 X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
26518 X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
26519 X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
26520 X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
26521 X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
26522 X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
26523 X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
26524 X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
26525 }
26526
26527 /**
26528 * Shortcut functions to the cipher's object interface.
26529 *
26530 * @example
26531 *
26532 * var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
26533 * var plaintext = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
26534 */
26535 C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
26536 }());
26537
26538
26539 return CryptoJS.RabbitLegacy;
26540
26541 }));
26542 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],52:[function(_dereq_,module,exports){
26543 ;(function (root, factory, undef) {
26544 if (typeof exports === "object") {
26545 // CommonJS
26546 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
26547 }
26548 else if (typeof define === "function" && define.amd) {
26549 // AMD
26550 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
26551 }
26552 else {
26553 // Global (browser)
26554 factory(root.CryptoJS);
26555 }
26556 }(this, function (CryptoJS) {
26557
26558 (function () {
26559 // Shortcuts
26560 var C = CryptoJS;
26561 var C_lib = C.lib;
26562 var StreamCipher = C_lib.StreamCipher;
26563 var C_algo = C.algo;
26564
26565 // Reusable objects
26566 var S = [];
26567 var C_ = [];
26568 var G = [];
26569
26570 /**
26571 * Rabbit stream cipher algorithm
26572 */
26573 var Rabbit = C_algo.Rabbit = StreamCipher.extend({
26574 _doReset: function () {
26575 // Shortcuts
26576 var K = this._key.words;
26577 var iv = this.cfg.iv;
26578
26579 // Swap endian
26580 for (var i = 0; i < 4; i++) {
26581 K[i] = (((K[i] << 8) | (K[i] >>> 24)) & 0x00ff00ff) |
26582 (((K[i] << 24) | (K[i] >>> 8)) & 0xff00ff00);
26583 }
26584
26585 // Generate initial state values
26586 var X = this._X = [
26587 K[0], (K[3] << 16) | (K[2] >>> 16),
26588 K[1], (K[0] << 16) | (K[3] >>> 16),
26589 K[2], (K[1] << 16) | (K[0] >>> 16),
26590 K[3], (K[2] << 16) | (K[1] >>> 16)
26591 ];
26592
26593 // Generate initial counter values
26594 var C = this._C = [
26595 (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
26596 (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
26597 (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
26598 (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
26599 ];
26600
26601 // Carry bit
26602 this._b = 0;
26603
26604 // Iterate the system four times
26605 for (var i = 0; i < 4; i++) {
26606 nextState.call(this);
26607 }
26608
26609 // Modify the counters
26610 for (var i = 0; i < 8; i++) {
26611 C[i] ^= X[(i + 4) & 7];
26612 }
26613
26614 // IV setup
26615 if (iv) {
26616 // Shortcuts
26617 var IV = iv.words;
26618 var IV_0 = IV[0];
26619 var IV_1 = IV[1];
26620
26621 // Generate four subvectors
26622 var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
26623 var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
26624 var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
26625 var i3 = (i2 << 16) | (i0 & 0x0000ffff);
26626
26627 // Modify counter values
26628 C[0] ^= i0;
26629 C[1] ^= i1;
26630 C[2] ^= i2;
26631 C[3] ^= i3;
26632 C[4] ^= i0;
26633 C[5] ^= i1;
26634 C[6] ^= i2;
26635 C[7] ^= i3;
26636
26637 // Iterate the system four times
26638 for (var i = 0; i < 4; i++) {
26639 nextState.call(this);
26640 }
26641 }
26642 },
26643
26644 _doProcessBlock: function (M, offset) {
26645 // Shortcut
26646 var X = this._X;
26647
26648 // Iterate the system
26649 nextState.call(this);
26650
26651 // Generate four keystream words
26652 S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
26653 S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
26654 S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
26655 S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
26656
26657 for (var i = 0; i < 4; i++) {
26658 // Swap endian
26659 S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
26660 (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
26661
26662 // Encrypt
26663 M[offset + i] ^= S[i];
26664 }
26665 },
26666
26667 blockSize: 128/32,
26668
26669 ivSize: 64/32
26670 });
26671
26672 function nextState() {
26673 // Shortcuts
26674 var X = this._X;
26675 var C = this._C;
26676
26677 // Save old counter values
26678 for (var i = 0; i < 8; i++) {
26679 C_[i] = C[i];
26680 }
26681
26682 // Calculate new counter values
26683 C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
26684 C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
26685 C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
26686 C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
26687 C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
26688 C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
26689 C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
26690 C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
26691 this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
26692
26693 // Calculate the g-values
26694 for (var i = 0; i < 8; i++) {
26695 var gx = X[i] + C[i];
26696
26697 // Construct high and low argument for squaring
26698 var ga = gx & 0xffff;
26699 var gb = gx >>> 16;
26700
26701 // Calculate high and low result of squaring
26702 var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
26703 var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
26704
26705 // High XOR low
26706 G[i] = gh ^ gl;
26707 }
26708
26709 // Calculate new state values
26710 X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
26711 X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
26712 X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
26713 X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
26714 X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
26715 X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
26716 X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
26717 X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
26718 }
26719
26720 /**
26721 * Shortcut functions to the cipher's object interface.
26722 *
26723 * @example
26724 *
26725 * var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
26726 * var plaintext = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
26727 */
26728 C.Rabbit = StreamCipher._createHelper(Rabbit);
26729 }());
26730
26731
26732 return CryptoJS.Rabbit;
26733
26734 }));
26735 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],53:[function(_dereq_,module,exports){
26736 ;(function (root, factory, undef) {
26737 if (typeof exports === "object") {
26738 // CommonJS
26739 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
26740 }
26741 else if (typeof define === "function" && define.amd) {
26742 // AMD
26743 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
26744 }
26745 else {
26746 // Global (browser)
26747 factory(root.CryptoJS);
26748 }
26749 }(this, function (CryptoJS) {
26750
26751 (function () {
26752 // Shortcuts
26753 var C = CryptoJS;
26754 var C_lib = C.lib;
26755 var StreamCipher = C_lib.StreamCipher;
26756 var C_algo = C.algo;
26757
26758 /**
26759 * RC4 stream cipher algorithm.
26760 */
26761 var RC4 = C_algo.RC4 = StreamCipher.extend({
26762 _doReset: function () {
26763 // Shortcuts
26764 var key = this._key;
26765 var keyWords = key.words;
26766 var keySigBytes = key.sigBytes;
26767
26768 // Init sbox
26769 var S = this._S = [];
26770 for (var i = 0; i < 256; i++) {
26771 S[i] = i;
26772 }
26773
26774 // Key setup
26775 for (var i = 0, j = 0; i < 256; i++) {
26776 var keyByteIndex = i % keySigBytes;
26777 var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff;
26778
26779 j = (j + S[i] + keyByte) % 256;
26780
26781 // Swap
26782 var t = S[i];
26783 S[i] = S[j];
26784 S[j] = t;
26785 }
26786
26787 // Counters
26788 this._i = this._j = 0;
26789 },
26790
26791 _doProcessBlock: function (M, offset) {
26792 M[offset] ^= generateKeystreamWord.call(this);
26793 },
26794
26795 keySize: 256/32,
26796
26797 ivSize: 0
26798 });
26799
26800 function generateKeystreamWord() {
26801 // Shortcuts
26802 var S = this._S;
26803 var i = this._i;
26804 var j = this._j;
26805
26806 // Generate keystream word
26807 var keystreamWord = 0;
26808 for (var n = 0; n < 4; n++) {
26809 i = (i + 1) % 256;
26810 j = (j + S[i]) % 256;
26811
26812 // Swap
26813 var t = S[i];
26814 S[i] = S[j];
26815 S[j] = t;
26816
26817 keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8);
26818 }
26819
26820 // Update counters
26821 this._i = i;
26822 this._j = j;
26823
26824 return keystreamWord;
26825 }
26826
26827 /**
26828 * Shortcut functions to the cipher's object interface.
26829 *
26830 * @example
26831 *
26832 * var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
26833 * var plaintext = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
26834 */
26835 C.RC4 = StreamCipher._createHelper(RC4);
26836
26837 /**
26838 * Modified RC4 stream cipher algorithm.
26839 */
26840 var RC4Drop = C_algo.RC4Drop = RC4.extend({
26841 /**
26842 * Configuration options.
26843 *
26844 * @property {number} drop The number of keystream words to drop. Default 192
26845 */
26846 cfg: RC4.cfg.extend({
26847 drop: 192
26848 }),
26849
26850 _doReset: function () {
26851 RC4._doReset.call(this);
26852
26853 // Drop
26854 for (var i = this.cfg.drop; i > 0; i--) {
26855 generateKeystreamWord.call(this);
26856 }
26857 }
26858 });
26859
26860 /**
26861 * Shortcut functions to the cipher's object interface.
26862 *
26863 * @example
26864 *
26865 * var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
26866 * var plaintext = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
26867 */
26868 C.RC4Drop = StreamCipher._createHelper(RC4Drop);
26869 }());
26870
26871
26872 return CryptoJS.RC4;
26873
26874 }));
26875 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],54:[function(_dereq_,module,exports){
26876 ;(function (root, factory) {
26877 if (typeof exports === "object") {
26878 // CommonJS
26879 module.exports = exports = factory(_dereq_("./core"));
26880 }
26881 else if (typeof define === "function" && define.amd) {
26882 // AMD
26883 define(["./core"], factory);
26884 }
26885 else {
26886 // Global (browser)
26887 factory(root.CryptoJS);
26888 }
26889 }(this, function (CryptoJS) {
26890
26891 /** @preserve
26892 (c) 2012 by Cédric Mesnil. All rights reserved.
26893
26894 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
26895
26896 - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
26897 - 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.
26898
26899 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.
26900 */
26901
26902 (function (Math) {
26903 // Shortcuts
26904 var C = CryptoJS;
26905 var C_lib = C.lib;
26906 var WordArray = C_lib.WordArray;
26907 var Hasher = C_lib.Hasher;
26908 var C_algo = C.algo;
26909
26910 // Constants table
26911 var _zl = WordArray.create([
26912 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
26913 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
26914 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
26915 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
26916 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]);
26917 var _zr = WordArray.create([
26918 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
26919 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
26920 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
26921 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
26922 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]);
26923 var _sl = WordArray.create([
26924 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
26925 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
26926 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
26927 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
26928 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ]);
26929 var _sr = WordArray.create([
26930 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
26931 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
26932 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
26933 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
26934 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]);
26935
26936 var _hl = WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]);
26937 var _hr = WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]);
26938
26939 /**
26940 * RIPEMD160 hash algorithm.
26941 */
26942 var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
26943 _doReset: function () {
26944 this._hash = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]);
26945 },
26946
26947 _doProcessBlock: function (M, offset) {
26948
26949 // Swap endian
26950 for (var i = 0; i < 16; i++) {
26951 // Shortcuts
26952 var offset_i = offset + i;
26953 var M_offset_i = M[offset_i];
26954
26955 // Swap
26956 M[offset_i] = (
26957 (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
26958 (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
26959 );
26960 }
26961 // Shortcut
26962 var H = this._hash.words;
26963 var hl = _hl.words;
26964 var hr = _hr.words;
26965 var zl = _zl.words;
26966 var zr = _zr.words;
26967 var sl = _sl.words;
26968 var sr = _sr.words;
26969
26970 // Working variables
26971 var al, bl, cl, dl, el;
26972 var ar, br, cr, dr, er;
26973
26974 ar = al = H[0];
26975 br = bl = H[1];
26976 cr = cl = H[2];
26977 dr = dl = H[3];
26978 er = el = H[4];
26979 // Computation
26980 var t;
26981 for (var i = 0; i < 80; i += 1) {
26982 t = (al + M[offset+zl[i]])|0;
26983 if (i<16){
26984 t += f1(bl,cl,dl) + hl[0];
26985 } else if (i<32) {
26986 t += f2(bl,cl,dl) + hl[1];
26987 } else if (i<48) {
26988 t += f3(bl,cl,dl) + hl[2];
26989 } else if (i<64) {
26990 t += f4(bl,cl,dl) + hl[3];
26991 } else {// if (i<80) {
26992 t += f5(bl,cl,dl) + hl[4];
26993 }
26994 t = t|0;
26995 t = rotl(t,sl[i]);
26996 t = (t+el)|0;
26997 al = el;
26998 el = dl;
26999 dl = rotl(cl, 10);
27000 cl = bl;
27001 bl = t;
27002
27003 t = (ar + M[offset+zr[i]])|0;
27004 if (i<16){
27005 t += f5(br,cr,dr) + hr[0];
27006 } else if (i<32) {
27007 t += f4(br,cr,dr) + hr[1];
27008 } else if (i<48) {
27009 t += f3(br,cr,dr) + hr[2];
27010 } else if (i<64) {
27011 t += f2(br,cr,dr) + hr[3];
27012 } else {// if (i<80) {
27013 t += f1(br,cr,dr) + hr[4];
27014 }
27015 t = t|0;
27016 t = rotl(t,sr[i]) ;
27017 t = (t+er)|0;
27018 ar = er;
27019 er = dr;
27020 dr = rotl(cr, 10);
27021 cr = br;
27022 br = t;
27023 }
27024 // Intermediate hash value
27025 t = (H[1] + cl + dr)|0;
27026 H[1] = (H[2] + dl + er)|0;
27027 H[2] = (H[3] + el + ar)|0;
27028 H[3] = (H[4] + al + br)|0;
27029 H[4] = (H[0] + bl + cr)|0;
27030 H[0] = t;
27031 },
27032
27033 _doFinalize: function () {
27034 // Shortcuts
27035 var data = this._data;
27036 var dataWords = data.words;
27037
27038 var nBitsTotal = this._nDataBytes * 8;
27039 var nBitsLeft = data.sigBytes * 8;
27040
27041 // Add padding
27042 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
27043 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
27044 (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
27045 (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)
27046 );
27047 data.sigBytes = (dataWords.length + 1) * 4;
27048
27049 // Hash final blocks
27050 this._process();
27051
27052 // Shortcuts
27053 var hash = this._hash;
27054 var H = hash.words;
27055
27056 // Swap endian
27057 for (var i = 0; i < 5; i++) {
27058 // Shortcut
27059 var H_i = H[i];
27060
27061 // Swap
27062 H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
27063 (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
27064 }
27065
27066 // Return final computed hash
27067 return hash;
27068 },
27069
27070 clone: function () {
27071 var clone = Hasher.clone.call(this);
27072 clone._hash = this._hash.clone();
27073
27074 return clone;
27075 }
27076 });
27077
27078
27079 function f1(x, y, z) {
27080 return ((x) ^ (y) ^ (z));
27081
27082 }
27083
27084 function f2(x, y, z) {
27085 return (((x)&(y)) | ((~x)&(z)));
27086 }
27087
27088 function f3(x, y, z) {
27089 return (((x) | (~(y))) ^ (z));
27090 }
27091
27092 function f4(x, y, z) {
27093 return (((x) & (z)) | ((y)&(~(z))));
27094 }
27095
27096 function f5(x, y, z) {
27097 return ((x) ^ ((y) |(~(z))));
27098
27099 }
27100
27101 function rotl(x,n) {
27102 return (x<<n) | (x>>>(32-n));
27103 }
27104
27105
27106 /**
27107 * Shortcut function to the hasher's object interface.
27108 *
27109 * @param {WordArray|string} message The message to hash.
27110 *
27111 * @return {WordArray} The hash.
27112 *
27113 * @static
27114 *
27115 * @example
27116 *
27117 * var hash = CryptoJS.RIPEMD160('message');
27118 * var hash = CryptoJS.RIPEMD160(wordArray);
27119 */
27120 C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
27121
27122 /**
27123 * Shortcut function to the HMAC's object interface.
27124 *
27125 * @param {WordArray|string} message The message to hash.
27126 * @param {WordArray|string} key The secret key.
27127 *
27128 * @return {WordArray} The HMAC.
27129 *
27130 * @static
27131 *
27132 * @example
27133 *
27134 * var hmac = CryptoJS.HmacRIPEMD160(message, key);
27135 */
27136 C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
27137 }(Math));
27138
27139
27140 return CryptoJS.RIPEMD160;
27141
27142 }));
27143 },{"./core":31}],55:[function(_dereq_,module,exports){
27144 ;(function (root, factory) {
27145 if (typeof exports === "object") {
27146 // CommonJS
27147 module.exports = exports = factory(_dereq_("./core"));
27148 }
27149 else if (typeof define === "function" && define.amd) {
27150 // AMD
27151 define(["./core"], factory);
27152 }
27153 else {
27154 // Global (browser)
27155 factory(root.CryptoJS);
27156 }
27157 }(this, function (CryptoJS) {
27158
27159 (function () {
27160 // Shortcuts
27161 var C = CryptoJS;
27162 var C_lib = C.lib;
27163 var WordArray = C_lib.WordArray;
27164 var Hasher = C_lib.Hasher;
27165 var C_algo = C.algo;
27166
27167 // Reusable object
27168 var W = [];
27169
27170 /**
27171 * SHA-1 hash algorithm.
27172 */
27173 var SHA1 = C_algo.SHA1 = Hasher.extend({
27174 _doReset: function () {
27175 this._hash = new WordArray.init([
27176 0x67452301, 0xefcdab89,
27177 0x98badcfe, 0x10325476,
27178 0xc3d2e1f0
27179 ]);
27180 },
27181
27182 _doProcessBlock: function (M, offset) {
27183 // Shortcut
27184 var H = this._hash.words;
27185
27186 // Working variables
27187 var a = H[0];
27188 var b = H[1];
27189 var c = H[2];
27190 var d = H[3];
27191 var e = H[4];
27192
27193 // Computation
27194 for (var i = 0; i < 80; i++) {
27195 if (i < 16) {
27196 W[i] = M[offset + i] | 0;
27197 } else {
27198 var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
27199 W[i] = (n << 1) | (n >>> 31);
27200 }
27201
27202 var t = ((a << 5) | (a >>> 27)) + e + W[i];
27203 if (i < 20) {
27204 t += ((b & c) | (~b & d)) + 0x5a827999;
27205 } else if (i < 40) {
27206 t += (b ^ c ^ d) + 0x6ed9eba1;
27207 } else if (i < 60) {
27208 t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
27209 } else /* if (i < 80) */ {
27210 t += (b ^ c ^ d) - 0x359d3e2a;
27211 }
27212
27213 e = d;
27214 d = c;
27215 c = (b << 30) | (b >>> 2);
27216 b = a;
27217 a = t;
27218 }
27219
27220 // Intermediate hash value
27221 H[0] = (H[0] + a) | 0;
27222 H[1] = (H[1] + b) | 0;
27223 H[2] = (H[2] + c) | 0;
27224 H[3] = (H[3] + d) | 0;
27225 H[4] = (H[4] + e) | 0;
27226 },
27227
27228 _doFinalize: function () {
27229 // Shortcuts
27230 var data = this._data;
27231 var dataWords = data.words;
27232
27233 var nBitsTotal = this._nDataBytes * 8;
27234 var nBitsLeft = data.sigBytes * 8;
27235
27236 // Add padding
27237 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
27238 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
27239 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
27240 data.sigBytes = dataWords.length * 4;
27241
27242 // Hash final blocks
27243 this._process();
27244
27245 // Return final computed hash
27246 return this._hash;
27247 },
27248
27249 clone: function () {
27250 var clone = Hasher.clone.call(this);
27251 clone._hash = this._hash.clone();
27252
27253 return clone;
27254 }
27255 });
27256
27257 /**
27258 * Shortcut function to the hasher's object interface.
27259 *
27260 * @param {WordArray|string} message The message to hash.
27261 *
27262 * @return {WordArray} The hash.
27263 *
27264 * @static
27265 *
27266 * @example
27267 *
27268 * var hash = CryptoJS.SHA1('message');
27269 * var hash = CryptoJS.SHA1(wordArray);
27270 */
27271 C.SHA1 = Hasher._createHelper(SHA1);
27272
27273 /**
27274 * Shortcut function to the HMAC's object interface.
27275 *
27276 * @param {WordArray|string} message The message to hash.
27277 * @param {WordArray|string} key The secret key.
27278 *
27279 * @return {WordArray} The HMAC.
27280 *
27281 * @static
27282 *
27283 * @example
27284 *
27285 * var hmac = CryptoJS.HmacSHA1(message, key);
27286 */
27287 C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
27288 }());
27289
27290
27291 return CryptoJS.SHA1;
27292
27293 }));
27294 },{"./core":31}],56:[function(_dereq_,module,exports){
27295 ;(function (root, factory, undef) {
27296 if (typeof exports === "object") {
27297 // CommonJS
27298 module.exports = exports = factory(_dereq_("./core"), _dereq_("./sha256"));
27299 }
27300 else if (typeof define === "function" && define.amd) {
27301 // AMD
27302 define(["./core", "./sha256"], factory);
27303 }
27304 else {
27305 // Global (browser)
27306 factory(root.CryptoJS);
27307 }
27308 }(this, function (CryptoJS) {
27309
27310 (function () {
27311 // Shortcuts
27312 var C = CryptoJS;
27313 var C_lib = C.lib;
27314 var WordArray = C_lib.WordArray;
27315 var C_algo = C.algo;
27316 var SHA256 = C_algo.SHA256;
27317
27318 /**
27319 * SHA-224 hash algorithm.
27320 */
27321 var SHA224 = C_algo.SHA224 = SHA256.extend({
27322 _doReset: function () {
27323 this._hash = new WordArray.init([
27324 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
27325 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
27326 ]);
27327 },
27328
27329 _doFinalize: function () {
27330 var hash = SHA256._doFinalize.call(this);
27331
27332 hash.sigBytes -= 4;
27333
27334 return hash;
27335 }
27336 });
27337
27338 /**
27339 * Shortcut function to the hasher's object interface.
27340 *
27341 * @param {WordArray|string} message The message to hash.
27342 *
27343 * @return {WordArray} The hash.
27344 *
27345 * @static
27346 *
27347 * @example
27348 *
27349 * var hash = CryptoJS.SHA224('message');
27350 * var hash = CryptoJS.SHA224(wordArray);
27351 */
27352 C.SHA224 = SHA256._createHelper(SHA224);
27353
27354 /**
27355 * Shortcut function to the HMAC's object interface.
27356 *
27357 * @param {WordArray|string} message The message to hash.
27358 * @param {WordArray|string} key The secret key.
27359 *
27360 * @return {WordArray} The HMAC.
27361 *
27362 * @static
27363 *
27364 * @example
27365 *
27366 * var hmac = CryptoJS.HmacSHA224(message, key);
27367 */
27368 C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
27369 }());
27370
27371
27372 return CryptoJS.SHA224;
27373
27374 }));
27375 },{"./core":31,"./sha256":57}],57:[function(_dereq_,module,exports){
27376 ;(function (root, factory) {
27377 if (typeof exports === "object") {
27378 // CommonJS
27379 module.exports = exports = factory(_dereq_("./core"));
27380 }
27381 else if (typeof define === "function" && define.amd) {
27382 // AMD
27383 define(["./core"], factory);
27384 }
27385 else {
27386 // Global (browser)
27387 factory(root.CryptoJS);
27388 }
27389 }(this, function (CryptoJS) {
27390
27391 (function (Math) {
27392 // Shortcuts
27393 var C = CryptoJS;
27394 var C_lib = C.lib;
27395 var WordArray = C_lib.WordArray;
27396 var Hasher = C_lib.Hasher;
27397 var C_algo = C.algo;
27398
27399 // Initialization and round constants tables
27400 var H = [];
27401 var K = [];
27402
27403 // Compute constants
27404 (function () {
27405 function isPrime(n) {
27406 var sqrtN = Math.sqrt(n);
27407 for (var factor = 2; factor <= sqrtN; factor++) {
27408 if (!(n % factor)) {
27409 return false;
27410 }
27411 }
27412
27413 return true;
27414 }
27415
27416 function getFractionalBits(n) {
27417 return ((n - (n | 0)) * 0x100000000) | 0;
27418 }
27419
27420 var n = 2;
27421 var nPrime = 0;
27422 while (nPrime < 64) {
27423 if (isPrime(n)) {
27424 if (nPrime < 8) {
27425 H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
27426 }
27427 K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
27428
27429 nPrime++;
27430 }
27431
27432 n++;
27433 }
27434 }());
27435
27436 // Reusable object
27437 var W = [];
27438
27439 /**
27440 * SHA-256 hash algorithm.
27441 */
27442 var SHA256 = C_algo.SHA256 = Hasher.extend({
27443 _doReset: function () {
27444 this._hash = new WordArray.init(H.slice(0));
27445 },
27446
27447 _doProcessBlock: function (M, offset) {
27448 // Shortcut
27449 var H = this._hash.words;
27450
27451 // Working variables
27452 var a = H[0];
27453 var b = H[1];
27454 var c = H[2];
27455 var d = H[3];
27456 var e = H[4];
27457 var f = H[5];
27458 var g = H[6];
27459 var h = H[7];
27460
27461 // Computation
27462 for (var i = 0; i < 64; i++) {
27463 if (i < 16) {
27464 W[i] = M[offset + i] | 0;
27465 } else {
27466 var gamma0x = W[i - 15];
27467 var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
27468 ((gamma0x << 14) | (gamma0x >>> 18)) ^
27469 (gamma0x >>> 3);
27470
27471 var gamma1x = W[i - 2];
27472 var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
27473 ((gamma1x << 13) | (gamma1x >>> 19)) ^
27474 (gamma1x >>> 10);
27475
27476 W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
27477 }
27478
27479 var ch = (e & f) ^ (~e & g);
27480 var maj = (a & b) ^ (a & c) ^ (b & c);
27481
27482 var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
27483 var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
27484
27485 var t1 = h + sigma1 + ch + K[i] + W[i];
27486 var t2 = sigma0 + maj;
27487
27488 h = g;
27489 g = f;
27490 f = e;
27491 e = (d + t1) | 0;
27492 d = c;
27493 c = b;
27494 b = a;
27495 a = (t1 + t2) | 0;
27496 }
27497
27498 // Intermediate hash value
27499 H[0] = (H[0] + a) | 0;
27500 H[1] = (H[1] + b) | 0;
27501 H[2] = (H[2] + c) | 0;
27502 H[3] = (H[3] + d) | 0;
27503 H[4] = (H[4] + e) | 0;
27504 H[5] = (H[5] + f) | 0;
27505 H[6] = (H[6] + g) | 0;
27506 H[7] = (H[7] + h) | 0;
27507 },
27508
27509 _doFinalize: function () {
27510 // Shortcuts
27511 var data = this._data;
27512 var dataWords = data.words;
27513
27514 var nBitsTotal = this._nDataBytes * 8;
27515 var nBitsLeft = data.sigBytes * 8;
27516
27517 // Add padding
27518 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
27519 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
27520 dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
27521 data.sigBytes = dataWords.length * 4;
27522
27523 // Hash final blocks
27524 this._process();
27525
27526 // Return final computed hash
27527 return this._hash;
27528 },
27529
27530 clone: function () {
27531 var clone = Hasher.clone.call(this);
27532 clone._hash = this._hash.clone();
27533
27534 return clone;
27535 }
27536 });
27537
27538 /**
27539 * Shortcut function to the hasher's object interface.
27540 *
27541 * @param {WordArray|string} message The message to hash.
27542 *
27543 * @return {WordArray} The hash.
27544 *
27545 * @static
27546 *
27547 * @example
27548 *
27549 * var hash = CryptoJS.SHA256('message');
27550 * var hash = CryptoJS.SHA256(wordArray);
27551 */
27552 C.SHA256 = Hasher._createHelper(SHA256);
27553
27554 /**
27555 * Shortcut function to the HMAC's object interface.
27556 *
27557 * @param {WordArray|string} message The message to hash.
27558 * @param {WordArray|string} key The secret key.
27559 *
27560 * @return {WordArray} The HMAC.
27561 *
27562 * @static
27563 *
27564 * @example
27565 *
27566 * var hmac = CryptoJS.HmacSHA256(message, key);
27567 */
27568 C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
27569 }(Math));
27570
27571
27572 return CryptoJS.SHA256;
27573
27574 }));
27575 },{"./core":31}],58:[function(_dereq_,module,exports){
27576 ;(function (root, factory, undef) {
27577 if (typeof exports === "object") {
27578 // CommonJS
27579 module.exports = exports = factory(_dereq_("./core"), _dereq_("./x64-core"));
27580 }
27581 else if (typeof define === "function" && define.amd) {
27582 // AMD
27583 define(["./core", "./x64-core"], factory);
27584 }
27585 else {
27586 // Global (browser)
27587 factory(root.CryptoJS);
27588 }
27589 }(this, function (CryptoJS) {
27590
27591 (function (Math) {
27592 // Shortcuts
27593 var C = CryptoJS;
27594 var C_lib = C.lib;
27595 var WordArray = C_lib.WordArray;
27596 var Hasher = C_lib.Hasher;
27597 var C_x64 = C.x64;
27598 var X64Word = C_x64.Word;
27599 var C_algo = C.algo;
27600
27601 // Constants tables
27602 var RHO_OFFSETS = [];
27603 var PI_INDEXES = [];
27604 var ROUND_CONSTANTS = [];
27605
27606 // Compute Constants
27607 (function () {
27608 // Compute rho offset constants
27609 var x = 1, y = 0;
27610 for (var t = 0; t < 24; t++) {
27611 RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;
27612
27613 var newX = y % 5;
27614 var newY = (2 * x + 3 * y) % 5;
27615 x = newX;
27616 y = newY;
27617 }
27618
27619 // Compute pi index constants
27620 for (var x = 0; x < 5; x++) {
27621 for (var y = 0; y < 5; y++) {
27622 PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;
27623 }
27624 }
27625
27626 // Compute round constants
27627 var LFSR = 0x01;
27628 for (var i = 0; i < 24; i++) {
27629 var roundConstantMsw = 0;
27630 var roundConstantLsw = 0;
27631
27632 for (var j = 0; j < 7; j++) {
27633 if (LFSR & 0x01) {
27634 var bitPosition = (1 << j) - 1;
27635 if (bitPosition < 32) {
27636 roundConstantLsw ^= 1 << bitPosition;
27637 } else /* if (bitPosition >= 32) */ {
27638 roundConstantMsw ^= 1 << (bitPosition - 32);
27639 }
27640 }
27641
27642 // Compute next LFSR
27643 if (LFSR & 0x80) {
27644 // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1
27645 LFSR = (LFSR << 1) ^ 0x71;
27646 } else {
27647 LFSR <<= 1;
27648 }
27649 }
27650
27651 ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
27652 }
27653 }());
27654
27655 // Reusable objects for temporary values
27656 var T = [];
27657 (function () {
27658 for (var i = 0; i < 25; i++) {
27659 T[i] = X64Word.create();
27660 }
27661 }());
27662
27663 /**
27664 * SHA-3 hash algorithm.
27665 */
27666 var SHA3 = C_algo.SHA3 = Hasher.extend({
27667 /**
27668 * Configuration options.
27669 *
27670 * @property {number} outputLength
27671 * The desired number of bits in the output hash.
27672 * Only values permitted are: 224, 256, 384, 512.
27673 * Default: 512
27674 */
27675 cfg: Hasher.cfg.extend({
27676 outputLength: 512
27677 }),
27678
27679 _doReset: function () {
27680 var state = this._state = []
27681 for (var i = 0; i < 25; i++) {
27682 state[i] = new X64Word.init();
27683 }
27684
27685 this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;
27686 },
27687
27688 _doProcessBlock: function (M, offset) {
27689 // Shortcuts
27690 var state = this._state;
27691 var nBlockSizeLanes = this.blockSize / 2;
27692
27693 // Absorb
27694 for (var i = 0; i < nBlockSizeLanes; i++) {
27695 // Shortcuts
27696 var M2i = M[offset + 2 * i];
27697 var M2i1 = M[offset + 2 * i + 1];
27698
27699 // Swap endian
27700 M2i = (
27701 (((M2i << 8) | (M2i >>> 24)) & 0x00ff00ff) |
27702 (((M2i << 24) | (M2i >>> 8)) & 0xff00ff00)
27703 );
27704 M2i1 = (
27705 (((M2i1 << 8) | (M2i1 >>> 24)) & 0x00ff00ff) |
27706 (((M2i1 << 24) | (M2i1 >>> 8)) & 0xff00ff00)
27707 );
27708
27709 // Absorb message into state
27710 var lane = state[i];
27711 lane.high ^= M2i1;
27712 lane.low ^= M2i;
27713 }
27714
27715 // Rounds
27716 for (var round = 0; round < 24; round++) {
27717 // Theta
27718 for (var x = 0; x < 5; x++) {
27719 // Mix column lanes
27720 var tMsw = 0, tLsw = 0;
27721 for (var y = 0; y < 5; y++) {
27722 var lane = state[x + 5 * y];
27723 tMsw ^= lane.high;
27724 tLsw ^= lane.low;
27725 }
27726
27727 // Temporary values
27728 var Tx = T[x];
27729 Tx.high = tMsw;
27730 Tx.low = tLsw;
27731 }
27732 for (var x = 0; x < 5; x++) {
27733 // Shortcuts
27734 var Tx4 = T[(x + 4) % 5];
27735 var Tx1 = T[(x + 1) % 5];
27736 var Tx1Msw = Tx1.high;
27737 var Tx1Lsw = Tx1.low;
27738
27739 // Mix surrounding columns
27740 var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));
27741 var tLsw = Tx4.low ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));
27742 for (var y = 0; y < 5; y++) {
27743 var lane = state[x + 5 * y];
27744 lane.high ^= tMsw;
27745 lane.low ^= tLsw;
27746 }
27747 }
27748
27749 // Rho Pi
27750 for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
27751 // Shortcuts
27752 var lane = state[laneIndex];
27753 var laneMsw = lane.high;
27754 var laneLsw = lane.low;
27755 var rhoOffset = RHO_OFFSETS[laneIndex];
27756
27757 // Rotate lanes
27758 if (rhoOffset < 32) {
27759 var tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
27760 var tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
27761 } else /* if (rhoOffset >= 32) */ {
27762 var tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
27763 var tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
27764 }
27765
27766 // Transpose lanes
27767 var TPiLane = T[PI_INDEXES[laneIndex]];
27768 TPiLane.high = tMsw;
27769 TPiLane.low = tLsw;
27770 }
27771
27772 // Rho pi at x = y = 0
27773 var T0 = T[0];
27774 var state0 = state[0];
27775 T0.high = state0.high;
27776 T0.low = state0.low;
27777
27778 // Chi
27779 for (var x = 0; x < 5; x++) {
27780 for (var y = 0; y < 5; y++) {
27781 // Shortcuts
27782 var laneIndex = x + 5 * y;
27783 var lane = state[laneIndex];
27784 var TLane = T[laneIndex];
27785 var Tx1Lane = T[((x + 1) % 5) + 5 * y];
27786 var Tx2Lane = T[((x + 2) % 5) + 5 * y];
27787
27788 // Mix rows
27789 lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
27790 lane.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low);
27791 }
27792 }
27793
27794 // Iota
27795 var lane = state[0];
27796 var roundConstant = ROUND_CONSTANTS[round];
27797 lane.high ^= roundConstant.high;
27798 lane.low ^= roundConstant.low;;
27799 }
27800 },
27801
27802 _doFinalize: function () {
27803 // Shortcuts
27804 var data = this._data;
27805 var dataWords = data.words;
27806 var nBitsTotal = this._nDataBytes * 8;
27807 var nBitsLeft = data.sigBytes * 8;
27808 var blockSizeBits = this.blockSize * 32;
27809
27810 // Add padding
27811 dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);
27812 dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;
27813 data.sigBytes = dataWords.length * 4;
27814
27815 // Hash final blocks
27816 this._process();
27817
27818 // Shortcuts
27819 var state = this._state;
27820 var outputLengthBytes = this.cfg.outputLength / 8;
27821 var outputLengthLanes = outputLengthBytes / 8;
27822
27823 // Squeeze
27824 var hashWords = [];
27825 for (var i = 0; i < outputLengthLanes; i++) {
27826 // Shortcuts
27827 var lane = state[i];
27828 var laneMsw = lane.high;
27829 var laneLsw = lane.low;
27830
27831 // Swap endian
27832 laneMsw = (
27833 (((laneMsw << 8) | (laneMsw >>> 24)) & 0x00ff00ff) |
27834 (((laneMsw << 24) | (laneMsw >>> 8)) & 0xff00ff00)
27835 );
27836 laneLsw = (
27837 (((laneLsw << 8) | (laneLsw >>> 24)) & 0x00ff00ff) |
27838 (((laneLsw << 24) | (laneLsw >>> 8)) & 0xff00ff00)
27839 );
27840
27841 // Squeeze state to retrieve hash
27842 hashWords.push(laneLsw);
27843 hashWords.push(laneMsw);
27844 }
27845
27846 // Return final computed hash
27847 return new WordArray.init(hashWords, outputLengthBytes);
27848 },
27849
27850 clone: function () {
27851 var clone = Hasher.clone.call(this);
27852
27853 var state = clone._state = this._state.slice(0);
27854 for (var i = 0; i < 25; i++) {
27855 state[i] = state[i].clone();
27856 }
27857
27858 return clone;
27859 }
27860 });
27861
27862 /**
27863 * Shortcut function to the hasher's object interface.
27864 *
27865 * @param {WordArray|string} message The message to hash.
27866 *
27867 * @return {WordArray} The hash.
27868 *
27869 * @static
27870 *
27871 * @example
27872 *
27873 * var hash = CryptoJS.SHA3('message');
27874 * var hash = CryptoJS.SHA3(wordArray);
27875 */
27876 C.SHA3 = Hasher._createHelper(SHA3);
27877
27878 /**
27879 * Shortcut function to the HMAC's object interface.
27880 *
27881 * @param {WordArray|string} message The message to hash.
27882 * @param {WordArray|string} key The secret key.
27883 *
27884 * @return {WordArray} The HMAC.
27885 *
27886 * @static
27887 *
27888 * @example
27889 *
27890 * var hmac = CryptoJS.HmacSHA3(message, key);
27891 */
27892 C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
27893 }(Math));
27894
27895
27896 return CryptoJS.SHA3;
27897
27898 }));
27899 },{"./core":31,"./x64-core":62}],59:[function(_dereq_,module,exports){
27900 ;(function (root, factory, undef) {
27901 if (typeof exports === "object") {
27902 // CommonJS
27903 module.exports = exports = factory(_dereq_("./core"), _dereq_("./x64-core"), _dereq_("./sha512"));
27904 }
27905 else if (typeof define === "function" && define.amd) {
27906 // AMD
27907 define(["./core", "./x64-core", "./sha512"], factory);
27908 }
27909 else {
27910 // Global (browser)
27911 factory(root.CryptoJS);
27912 }
27913 }(this, function (CryptoJS) {
27914
27915 (function () {
27916 // Shortcuts
27917 var C = CryptoJS;
27918 var C_x64 = C.x64;
27919 var X64Word = C_x64.Word;
27920 var X64WordArray = C_x64.WordArray;
27921 var C_algo = C.algo;
27922 var SHA512 = C_algo.SHA512;
27923
27924 /**
27925 * SHA-384 hash algorithm.
27926 */
27927 var SHA384 = C_algo.SHA384 = SHA512.extend({
27928 _doReset: function () {
27929 this._hash = new X64WordArray.init([
27930 new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
27931 new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
27932 new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
27933 new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
27934 ]);
27935 },
27936
27937 _doFinalize: function () {
27938 var hash = SHA512._doFinalize.call(this);
27939
27940 hash.sigBytes -= 16;
27941
27942 return hash;
27943 }
27944 });
27945
27946 /**
27947 * Shortcut function to the hasher's object interface.
27948 *
27949 * @param {WordArray|string} message The message to hash.
27950 *
27951 * @return {WordArray} The hash.
27952 *
27953 * @static
27954 *
27955 * @example
27956 *
27957 * var hash = CryptoJS.SHA384('message');
27958 * var hash = CryptoJS.SHA384(wordArray);
27959 */
27960 C.SHA384 = SHA512._createHelper(SHA384);
27961
27962 /**
27963 * Shortcut function to the HMAC's object interface.
27964 *
27965 * @param {WordArray|string} message The message to hash.
27966 * @param {WordArray|string} key The secret key.
27967 *
27968 * @return {WordArray} The HMAC.
27969 *
27970 * @static
27971 *
27972 * @example
27973 *
27974 * var hmac = CryptoJS.HmacSHA384(message, key);
27975 */
27976 C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
27977 }());
27978
27979
27980 return CryptoJS.SHA384;
27981
27982 }));
27983 },{"./core":31,"./sha512":60,"./x64-core":62}],60:[function(_dereq_,module,exports){
27984 ;(function (root, factory, undef) {
27985 if (typeof exports === "object") {
27986 // CommonJS
27987 module.exports = exports = factory(_dereq_("./core"), _dereq_("./x64-core"));
27988 }
27989 else if (typeof define === "function" && define.amd) {
27990 // AMD
27991 define(["./core", "./x64-core"], factory);
27992 }
27993 else {
27994 // Global (browser)
27995 factory(root.CryptoJS);
27996 }
27997 }(this, function (CryptoJS) {
27998
27999 (function () {
28000 // Shortcuts
28001 var C = CryptoJS;
28002 var C_lib = C.lib;
28003 var Hasher = C_lib.Hasher;
28004 var C_x64 = C.x64;
28005 var X64Word = C_x64.Word;
28006 var X64WordArray = C_x64.WordArray;
28007 var C_algo = C.algo;
28008
28009 function X64Word_create() {
28010 return X64Word.create.apply(X64Word, arguments);
28011 }
28012
28013 // Constants
28014 var K = [
28015 X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd),
28016 X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc),
28017 X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019),
28018 X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118),
28019 X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe),
28020 X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2),
28021 X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1),
28022 X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694),
28023 X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3),
28024 X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65),
28025 X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483),
28026 X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5),
28027 X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210),
28028 X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4),
28029 X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725),
28030 X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70),
28031 X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926),
28032 X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df),
28033 X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8),
28034 X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b),
28035 X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001),
28036 X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30),
28037 X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910),
28038 X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8),
28039 X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53),
28040 X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8),
28041 X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb),
28042 X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3),
28043 X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60),
28044 X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec),
28045 X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9),
28046 X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b),
28047 X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207),
28048 X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178),
28049 X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6),
28050 X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b),
28051 X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493),
28052 X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c),
28053 X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a),
28054 X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817)
28055 ];
28056
28057 // Reusable objects
28058 var W = [];
28059 (function () {
28060 for (var i = 0; i < 80; i++) {
28061 W[i] = X64Word_create();
28062 }
28063 }());
28064
28065 /**
28066 * SHA-512 hash algorithm.
28067 */
28068 var SHA512 = C_algo.SHA512 = Hasher.extend({
28069 _doReset: function () {
28070 this._hash = new X64WordArray.init([
28071 new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b),
28072 new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1),
28073 new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f),
28074 new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179)
28075 ]);
28076 },
28077
28078 _doProcessBlock: function (M, offset) {
28079 // Shortcuts
28080 var H = this._hash.words;
28081
28082 var H0 = H[0];
28083 var H1 = H[1];
28084 var H2 = H[2];
28085 var H3 = H[3];
28086 var H4 = H[4];
28087 var H5 = H[5];
28088 var H6 = H[6];
28089 var H7 = H[7];
28090
28091 var H0h = H0.high;
28092 var H0l = H0.low;
28093 var H1h = H1.high;
28094 var H1l = H1.low;
28095 var H2h = H2.high;
28096 var H2l = H2.low;
28097 var H3h = H3.high;
28098 var H3l = H3.low;
28099 var H4h = H4.high;
28100 var H4l = H4.low;
28101 var H5h = H5.high;
28102 var H5l = H5.low;
28103 var H6h = H6.high;
28104 var H6l = H6.low;
28105 var H7h = H7.high;
28106 var H7l = H7.low;
28107
28108 // Working variables
28109 var ah = H0h;
28110 var al = H0l;
28111 var bh = H1h;
28112 var bl = H1l;
28113 var ch = H2h;
28114 var cl = H2l;
28115 var dh = H3h;
28116 var dl = H3l;
28117 var eh = H4h;
28118 var el = H4l;
28119 var fh = H5h;
28120 var fl = H5l;
28121 var gh = H6h;
28122 var gl = H6l;
28123 var hh = H7h;
28124 var hl = H7l;
28125
28126 // Rounds
28127 for (var i = 0; i < 80; i++) {
28128 // Shortcut
28129 var Wi = W[i];
28130
28131 // Extend message
28132 if (i < 16) {
28133 var Wih = Wi.high = M[offset + i * 2] | 0;
28134 var Wil = Wi.low = M[offset + i * 2 + 1] | 0;
28135 } else {
28136 // Gamma0
28137 var gamma0x = W[i - 15];
28138 var gamma0xh = gamma0x.high;
28139 var gamma0xl = gamma0x.low;
28140 var gamma0h = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7);
28141 var gamma0l = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25));
28142
28143 // Gamma1
28144 var gamma1x = W[i - 2];
28145 var gamma1xh = gamma1x.high;
28146 var gamma1xl = gamma1x.low;
28147 var gamma1h = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6);
28148 var gamma1l = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26));
28149
28150 // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
28151 var Wi7 = W[i - 7];
28152 var Wi7h = Wi7.high;
28153 var Wi7l = Wi7.low;
28154
28155 var Wi16 = W[i - 16];
28156 var Wi16h = Wi16.high;
28157 var Wi16l = Wi16.low;
28158
28159 var Wil = gamma0l + Wi7l;
28160 var Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
28161 var Wil = Wil + gamma1l;
28162 var Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
28163 var Wil = Wil + Wi16l;
28164 var Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
28165
28166 Wi.high = Wih;
28167 Wi.low = Wil;
28168 }
28169
28170 var chh = (eh & fh) ^ (~eh & gh);
28171 var chl = (el & fl) ^ (~el & gl);
28172 var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
28173 var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
28174
28175 var sigma0h = ((ah >>> 28) | (al << 4)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
28176 var sigma0l = ((al >>> 28) | (ah << 4)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
28177 var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9));
28178 var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9));
28179
28180 // t1 = h + sigma1 + ch + K[i] + W[i]
28181 var Ki = K[i];
28182 var Kih = Ki.high;
28183 var Kil = Ki.low;
28184
28185 var t1l = hl + sigma1l;
28186 var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
28187 var t1l = t1l + chl;
28188 var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
28189 var t1l = t1l + Kil;
28190 var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0);
28191 var t1l = t1l + Wil;
28192 var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0);
28193
28194 // t2 = sigma0 + maj
28195 var t2l = sigma0l + majl;
28196 var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
28197
28198 // Update working variables
28199 hh = gh;
28200 hl = gl;
28201 gh = fh;
28202 gl = fl;
28203 fh = eh;
28204 fl = el;
28205 el = (dl + t1l) | 0;
28206 eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
28207 dh = ch;
28208 dl = cl;
28209 ch = bh;
28210 cl = bl;
28211 bh = ah;
28212 bl = al;
28213 al = (t1l + t2l) | 0;
28214 ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
28215 }
28216
28217 // Intermediate hash value
28218 H0l = H0.low = (H0l + al);
28219 H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0));
28220 H1l = H1.low = (H1l + bl);
28221 H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0));
28222 H2l = H2.low = (H2l + cl);
28223 H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0));
28224 H3l = H3.low = (H3l + dl);
28225 H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0));
28226 H4l = H4.low = (H4l + el);
28227 H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0));
28228 H5l = H5.low = (H5l + fl);
28229 H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0));
28230 H6l = H6.low = (H6l + gl);
28231 H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0));
28232 H7l = H7.low = (H7l + hl);
28233 H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0));
28234 },
28235
28236 _doFinalize: function () {
28237 // Shortcuts
28238 var data = this._data;
28239 var dataWords = data.words;
28240
28241 var nBitsTotal = this._nDataBytes * 8;
28242 var nBitsLeft = data.sigBytes * 8;
28243
28244 // Add padding
28245 dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
28246 dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000);
28247 dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal;
28248 data.sigBytes = dataWords.length * 4;
28249
28250 // Hash final blocks
28251 this._process();
28252
28253 // Convert hash to 32-bit word array before returning
28254 var hash = this._hash.toX32();
28255
28256 // Return final computed hash
28257 return hash;
28258 },
28259
28260 clone: function () {
28261 var clone = Hasher.clone.call(this);
28262 clone._hash = this._hash.clone();
28263
28264 return clone;
28265 },
28266
28267 blockSize: 1024/32
28268 });
28269
28270 /**
28271 * Shortcut function to the hasher's object interface.
28272 *
28273 * @param {WordArray|string} message The message to hash.
28274 *
28275 * @return {WordArray} The hash.
28276 *
28277 * @static
28278 *
28279 * @example
28280 *
28281 * var hash = CryptoJS.SHA512('message');
28282 * var hash = CryptoJS.SHA512(wordArray);
28283 */
28284 C.SHA512 = Hasher._createHelper(SHA512);
28285
28286 /**
28287 * Shortcut function to the HMAC's object interface.
28288 *
28289 * @param {WordArray|string} message The message to hash.
28290 * @param {WordArray|string} key The secret key.
28291 *
28292 * @return {WordArray} The HMAC.
28293 *
28294 * @static
28295 *
28296 * @example
28297 *
28298 * var hmac = CryptoJS.HmacSHA512(message, key);
28299 */
28300 C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
28301 }());
28302
28303
28304 return CryptoJS.SHA512;
28305
28306 }));
28307 },{"./core":31,"./x64-core":62}],61:[function(_dereq_,module,exports){
28308 ;(function (root, factory, undef) {
28309 if (typeof exports === "object") {
28310 // CommonJS
28311 module.exports = exports = factory(_dereq_("./core"), _dereq_("./enc-base64"), _dereq_("./md5"), _dereq_("./evpkdf"), _dereq_("./cipher-core"));
28312 }
28313 else if (typeof define === "function" && define.amd) {
28314 // AMD
28315 define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory);
28316 }
28317 else {
28318 // Global (browser)
28319 factory(root.CryptoJS);
28320 }
28321 }(this, function (CryptoJS) {
28322
28323 (function () {
28324 // Shortcuts
28325 var C = CryptoJS;
28326 var C_lib = C.lib;
28327 var WordArray = C_lib.WordArray;
28328 var BlockCipher = C_lib.BlockCipher;
28329 var C_algo = C.algo;
28330
28331 // Permuted Choice 1 constants
28332 var PC1 = [
28333 57, 49, 41, 33, 25, 17, 9, 1,
28334 58, 50, 42, 34, 26, 18, 10, 2,
28335 59, 51, 43, 35, 27, 19, 11, 3,
28336 60, 52, 44, 36, 63, 55, 47, 39,
28337 31, 23, 15, 7, 62, 54, 46, 38,
28338 30, 22, 14, 6, 61, 53, 45, 37,
28339 29, 21, 13, 5, 28, 20, 12, 4
28340 ];
28341
28342 // Permuted Choice 2 constants
28343 var PC2 = [
28344 14, 17, 11, 24, 1, 5,
28345 3, 28, 15, 6, 21, 10,
28346 23, 19, 12, 4, 26, 8,
28347 16, 7, 27, 20, 13, 2,
28348 41, 52, 31, 37, 47, 55,
28349 30, 40, 51, 45, 33, 48,
28350 44, 49, 39, 56, 34, 53,
28351 46, 42, 50, 36, 29, 32
28352 ];
28353
28354 // Cumulative bit shift constants
28355 var BIT_SHIFTS = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
28356
28357 // SBOXes and round permutation constants
28358 var SBOX_P = [
28359 {
28360 0x0: 0x808200,
28361 0x10000000: 0x8000,
28362 0x20000000: 0x808002,
28363 0x30000000: 0x2,
28364 0x40000000: 0x200,
28365 0x50000000: 0x808202,
28366 0x60000000: 0x800202,
28367 0x70000000: 0x800000,
28368 0x80000000: 0x202,
28369 0x90000000: 0x800200,
28370 0xa0000000: 0x8200,
28371 0xb0000000: 0x808000,
28372 0xc0000000: 0x8002,
28373 0xd0000000: 0x800002,
28374 0xe0000000: 0x0,
28375 0xf0000000: 0x8202,
28376 0x8000000: 0x0,
28377 0x18000000: 0x808202,
28378 0x28000000: 0x8202,
28379 0x38000000: 0x8000,
28380 0x48000000: 0x808200,
28381 0x58000000: 0x200,
28382 0x68000000: 0x808002,
28383 0x78000000: 0x2,
28384 0x88000000: 0x800200,
28385 0x98000000: 0x8200,
28386 0xa8000000: 0x808000,
28387 0xb8000000: 0x800202,
28388 0xc8000000: 0x800002,
28389 0xd8000000: 0x8002,
28390 0xe8000000: 0x202,
28391 0xf8000000: 0x800000,
28392 0x1: 0x8000,
28393 0x10000001: 0x2,
28394 0x20000001: 0x808200,
28395 0x30000001: 0x800000,
28396 0x40000001: 0x808002,
28397 0x50000001: 0x8200,
28398 0x60000001: 0x200,
28399 0x70000001: 0x800202,
28400 0x80000001: 0x808202,
28401 0x90000001: 0x808000,
28402 0xa0000001: 0x800002,
28403 0xb0000001: 0x8202,
28404 0xc0000001: 0x202,
28405 0xd0000001: 0x800200,
28406 0xe0000001: 0x8002,
28407 0xf0000001: 0x0,
28408 0x8000001: 0x808202,
28409 0x18000001: 0x808000,
28410 0x28000001: 0x800000,
28411 0x38000001: 0x200,
28412 0x48000001: 0x8000,
28413 0x58000001: 0x800002,
28414 0x68000001: 0x2,
28415 0x78000001: 0x8202,
28416 0x88000001: 0x8002,
28417 0x98000001: 0x800202,
28418 0xa8000001: 0x202,
28419 0xb8000001: 0x808200,
28420 0xc8000001: 0x800200,
28421 0xd8000001: 0x0,
28422 0xe8000001: 0x8200,
28423 0xf8000001: 0x808002
28424 },
28425 {
28426 0x0: 0x40084010,
28427 0x1000000: 0x4000,
28428 0x2000000: 0x80000,
28429 0x3000000: 0x40080010,
28430 0x4000000: 0x40000010,
28431 0x5000000: 0x40084000,
28432 0x6000000: 0x40004000,
28433 0x7000000: 0x10,
28434 0x8000000: 0x84000,
28435 0x9000000: 0x40004010,
28436 0xa000000: 0x40000000,
28437 0xb000000: 0x84010,
28438 0xc000000: 0x80010,
28439 0xd000000: 0x0,
28440 0xe000000: 0x4010,
28441 0xf000000: 0x40080000,
28442 0x800000: 0x40004000,
28443 0x1800000: 0x84010,
28444 0x2800000: 0x10,
28445 0x3800000: 0x40004010,
28446 0x4800000: 0x40084010,
28447 0x5800000: 0x40000000,
28448 0x6800000: 0x80000,
28449 0x7800000: 0x40080010,
28450 0x8800000: 0x80010,
28451 0x9800000: 0x0,
28452 0xa800000: 0x4000,
28453 0xb800000: 0x40080000,
28454 0xc800000: 0x40000010,
28455 0xd800000: 0x84000,
28456 0xe800000: 0x40084000,
28457 0xf800000: 0x4010,
28458 0x10000000: 0x0,
28459 0x11000000: 0x40080010,
28460 0x12000000: 0x40004010,
28461 0x13000000: 0x40084000,
28462 0x14000000: 0x40080000,
28463 0x15000000: 0x10,
28464 0x16000000: 0x84010,
28465 0x17000000: 0x4000,
28466 0x18000000: 0x4010,
28467 0x19000000: 0x80000,
28468 0x1a000000: 0x80010,
28469 0x1b000000: 0x40000010,
28470 0x1c000000: 0x84000,
28471 0x1d000000: 0x40004000,
28472 0x1e000000: 0x40000000,
28473 0x1f000000: 0x40084010,
28474 0x10800000: 0x84010,
28475 0x11800000: 0x80000,
28476 0x12800000: 0x40080000,
28477 0x13800000: 0x4000,
28478 0x14800000: 0x40004000,
28479 0x15800000: 0x40084010,
28480 0x16800000: 0x10,
28481 0x17800000: 0x40000000,
28482 0x18800000: 0x40084000,
28483 0x19800000: 0x40000010,
28484 0x1a800000: 0x40004010,
28485 0x1b800000: 0x80010,
28486 0x1c800000: 0x0,
28487 0x1d800000: 0x4010,
28488 0x1e800000: 0x40080010,
28489 0x1f800000: 0x84000
28490 },
28491 {
28492 0x0: 0x104,
28493 0x100000: 0x0,
28494 0x200000: 0x4000100,
28495 0x300000: 0x10104,
28496 0x400000: 0x10004,
28497 0x500000: 0x4000004,
28498 0x600000: 0x4010104,
28499 0x700000: 0x4010000,
28500 0x800000: 0x4000000,
28501 0x900000: 0x4010100,
28502 0xa00000: 0x10100,
28503 0xb00000: 0x4010004,
28504 0xc00000: 0x4000104,
28505 0xd00000: 0x10000,
28506 0xe00000: 0x4,
28507 0xf00000: 0x100,
28508 0x80000: 0x4010100,
28509 0x180000: 0x4010004,
28510 0x280000: 0x0,
28511 0x380000: 0x4000100,
28512 0x480000: 0x4000004,
28513 0x580000: 0x10000,
28514 0x680000: 0x10004,
28515 0x780000: 0x104,
28516 0x880000: 0x4,
28517 0x980000: 0x100,
28518 0xa80000: 0x4010000,
28519 0xb80000: 0x10104,
28520 0xc80000: 0x10100,
28521 0xd80000: 0x4000104,
28522 0xe80000: 0x4010104,
28523 0xf80000: 0x4000000,
28524 0x1000000: 0x4010100,
28525 0x1100000: 0x10004,
28526 0x1200000: 0x10000,
28527 0x1300000: 0x4000100,
28528 0x1400000: 0x100,
28529 0x1500000: 0x4010104,
28530 0x1600000: 0x4000004,
28531 0x1700000: 0x0,
28532 0x1800000: 0x4000104,
28533 0x1900000: 0x4000000,
28534 0x1a00000: 0x4,
28535 0x1b00000: 0x10100,
28536 0x1c00000: 0x4010000,
28537 0x1d00000: 0x104,
28538 0x1e00000: 0x10104,
28539 0x1f00000: 0x4010004,
28540 0x1080000: 0x4000000,
28541 0x1180000: 0x104,
28542 0x1280000: 0x4010100,
28543 0x1380000: 0x0,
28544 0x1480000: 0x10004,
28545 0x1580000: 0x4000100,
28546 0x1680000: 0x100,
28547 0x1780000: 0x4010004,
28548 0x1880000: 0x10000,
28549 0x1980000: 0x4010104,
28550 0x1a80000: 0x10104,
28551 0x1b80000: 0x4000004,
28552 0x1c80000: 0x4000104,
28553 0x1d80000: 0x4010000,
28554 0x1e80000: 0x4,
28555 0x1f80000: 0x10100
28556 },
28557 {
28558 0x0: 0x80401000,
28559 0x10000: 0x80001040,
28560 0x20000: 0x401040,
28561 0x30000: 0x80400000,
28562 0x40000: 0x0,
28563 0x50000: 0x401000,
28564 0x60000: 0x80000040,
28565 0x70000: 0x400040,
28566 0x80000: 0x80000000,
28567 0x90000: 0x400000,
28568 0xa0000: 0x40,
28569 0xb0000: 0x80001000,
28570 0xc0000: 0x80400040,
28571 0xd0000: 0x1040,
28572 0xe0000: 0x1000,
28573 0xf0000: 0x80401040,
28574 0x8000: 0x80001040,
28575 0x18000: 0x40,
28576 0x28000: 0x80400040,
28577 0x38000: 0x80001000,
28578 0x48000: 0x401000,
28579 0x58000: 0x80401040,
28580 0x68000: 0x0,
28581 0x78000: 0x80400000,
28582 0x88000: 0x1000,
28583 0x98000: 0x80401000,
28584 0xa8000: 0x400000,
28585 0xb8000: 0x1040,
28586 0xc8000: 0x80000000,
28587 0xd8000: 0x400040,
28588 0xe8000: 0x401040,
28589 0xf8000: 0x80000040,
28590 0x100000: 0x400040,
28591 0x110000: 0x401000,
28592 0x120000: 0x80000040,
28593 0x130000: 0x0,
28594 0x140000: 0x1040,
28595 0x150000: 0x80400040,
28596 0x160000: 0x80401000,
28597 0x170000: 0x80001040,
28598 0x180000: 0x80401040,
28599 0x190000: 0x80000000,
28600 0x1a0000: 0x80400000,
28601 0x1b0000: 0x401040,
28602 0x1c0000: 0x80001000,
28603 0x1d0000: 0x400000,
28604 0x1e0000: 0x40,
28605 0x1f0000: 0x1000,
28606 0x108000: 0x80400000,
28607 0x118000: 0x80401040,
28608 0x128000: 0x0,
28609 0x138000: 0x401000,
28610 0x148000: 0x400040,
28611 0x158000: 0x80000000,
28612 0x168000: 0x80001040,
28613 0x178000: 0x40,
28614 0x188000: 0x80000040,
28615 0x198000: 0x1000,
28616 0x1a8000: 0x80001000,
28617 0x1b8000: 0x80400040,
28618 0x1c8000: 0x1040,
28619 0x1d8000: 0x80401000,
28620 0x1e8000: 0x400000,
28621 0x1f8000: 0x401040
28622 },
28623 {
28624 0x0: 0x80,
28625 0x1000: 0x1040000,
28626 0x2000: 0x40000,
28627 0x3000: 0x20000000,
28628 0x4000: 0x20040080,
28629 0x5000: 0x1000080,
28630 0x6000: 0x21000080,
28631 0x7000: 0x40080,
28632 0x8000: 0x1000000,
28633 0x9000: 0x20040000,
28634 0xa000: 0x20000080,
28635 0xb000: 0x21040080,
28636 0xc000: 0x21040000,
28637 0xd000: 0x0,
28638 0xe000: 0x1040080,
28639 0xf000: 0x21000000,
28640 0x800: 0x1040080,
28641 0x1800: 0x21000080,
28642 0x2800: 0x80,
28643 0x3800: 0x1040000,
28644 0x4800: 0x40000,
28645 0x5800: 0x20040080,
28646 0x6800: 0x21040000,
28647 0x7800: 0x20000000,
28648 0x8800: 0x20040000,
28649 0x9800: 0x0,
28650 0xa800: 0x21040080,
28651 0xb800: 0x1000080,
28652 0xc800: 0x20000080,
28653 0xd800: 0x21000000,
28654 0xe800: 0x1000000,
28655 0xf800: 0x40080,
28656 0x10000: 0x40000,
28657 0x11000: 0x80,
28658 0x12000: 0x20000000,
28659 0x13000: 0x21000080,
28660 0x14000: 0x1000080,
28661 0x15000: 0x21040000,
28662 0x16000: 0x20040080,
28663 0x17000: 0x1000000,
28664 0x18000: 0x21040080,
28665 0x19000: 0x21000000,
28666 0x1a000: 0x1040000,
28667 0x1b000: 0x20040000,
28668 0x1c000: 0x40080,
28669 0x1d000: 0x20000080,
28670 0x1e000: 0x0,
28671 0x1f000: 0x1040080,
28672 0x10800: 0x21000080,
28673 0x11800: 0x1000000,
28674 0x12800: 0x1040000,
28675 0x13800: 0x20040080,
28676 0x14800: 0x20000000,
28677 0x15800: 0x1040080,
28678 0x16800: 0x80,
28679 0x17800: 0x21040000,
28680 0x18800: 0x40080,
28681 0x19800: 0x21040080,
28682 0x1a800: 0x0,
28683 0x1b800: 0x21000000,
28684 0x1c800: 0x1000080,
28685 0x1d800: 0x40000,
28686 0x1e800: 0x20040000,
28687 0x1f800: 0x20000080
28688 },
28689 {
28690 0x0: 0x10000008,
28691 0x100: 0x2000,
28692 0x200: 0x10200000,
28693 0x300: 0x10202008,
28694 0x400: 0x10002000,
28695 0x500: 0x200000,
28696 0x600: 0x200008,
28697 0x700: 0x10000000,
28698 0x800: 0x0,
28699 0x900: 0x10002008,
28700 0xa00: 0x202000,
28701 0xb00: 0x8,
28702 0xc00: 0x10200008,
28703 0xd00: 0x202008,
28704 0xe00: 0x2008,
28705 0xf00: 0x10202000,
28706 0x80: 0x10200000,
28707 0x180: 0x10202008,
28708 0x280: 0x8,
28709 0x380: 0x200000,
28710 0x480: 0x202008,
28711 0x580: 0x10000008,
28712 0x680: 0x10002000,
28713 0x780: 0x2008,
28714 0x880: 0x200008,
28715 0x980: 0x2000,
28716 0xa80: 0x10002008,
28717 0xb80: 0x10200008,
28718 0xc80: 0x0,
28719 0xd80: 0x10202000,
28720 0xe80: 0x202000,
28721 0xf80: 0x10000000,
28722 0x1000: 0x10002000,
28723 0x1100: 0x10200008,
28724 0x1200: 0x10202008,
28725 0x1300: 0x2008,
28726 0x1400: 0x200000,
28727 0x1500: 0x10000000,
28728 0x1600: 0x10000008,
28729 0x1700: 0x202000,
28730 0x1800: 0x202008,
28731 0x1900: 0x0,
28732 0x1a00: 0x8,
28733 0x1b00: 0x10200000,
28734 0x1c00: 0x2000,
28735 0x1d00: 0x10002008,
28736 0x1e00: 0x10202000,
28737 0x1f00: 0x200008,
28738 0x1080: 0x8,
28739 0x1180: 0x202000,
28740 0x1280: 0x200000,
28741 0x1380: 0x10000008,
28742 0x1480: 0x10002000,
28743 0x1580: 0x2008,
28744 0x1680: 0x10202008,
28745 0x1780: 0x10200000,
28746 0x1880: 0x10202000,
28747 0x1980: 0x10200008,
28748 0x1a80: 0x2000,
28749 0x1b80: 0x202008,
28750 0x1c80: 0x200008,
28751 0x1d80: 0x0,
28752 0x1e80: 0x10000000,
28753 0x1f80: 0x10002008
28754 },
28755 {
28756 0x0: 0x100000,
28757 0x10: 0x2000401,
28758 0x20: 0x400,
28759 0x30: 0x100401,
28760 0x40: 0x2100401,
28761 0x50: 0x0,
28762 0x60: 0x1,
28763 0x70: 0x2100001,
28764 0x80: 0x2000400,
28765 0x90: 0x100001,
28766 0xa0: 0x2000001,
28767 0xb0: 0x2100400,
28768 0xc0: 0x2100000,
28769 0xd0: 0x401,
28770 0xe0: 0x100400,
28771 0xf0: 0x2000000,
28772 0x8: 0x2100001,
28773 0x18: 0x0,
28774 0x28: 0x2000401,
28775 0x38: 0x2100400,
28776 0x48: 0x100000,
28777 0x58: 0x2000001,
28778 0x68: 0x2000000,
28779 0x78: 0x401,
28780 0x88: 0x100401,
28781 0x98: 0x2000400,
28782 0xa8: 0x2100000,
28783 0xb8: 0x100001,
28784 0xc8: 0x400,
28785 0xd8: 0x2100401,
28786 0xe8: 0x1,
28787 0xf8: 0x100400,
28788 0x100: 0x2000000,
28789 0x110: 0x100000,
28790 0x120: 0x2000401,
28791 0x130: 0x2100001,
28792 0x140: 0x100001,
28793 0x150: 0x2000400,
28794 0x160: 0x2100400,
28795 0x170: 0x100401,
28796 0x180: 0x401,
28797 0x190: 0x2100401,
28798 0x1a0: 0x100400,
28799 0x1b0: 0x1,
28800 0x1c0: 0x0,
28801 0x1d0: 0x2100000,
28802 0x1e0: 0x2000001,
28803 0x1f0: 0x400,
28804 0x108: 0x100400,
28805 0x118: 0x2000401,
28806 0x128: 0x2100001,
28807 0x138: 0x1,
28808 0x148: 0x2000000,
28809 0x158: 0x100000,
28810 0x168: 0x401,
28811 0x178: 0x2100400,
28812 0x188: 0x2000001,
28813 0x198: 0x2100000,
28814 0x1a8: 0x0,
28815 0x1b8: 0x2100401,
28816 0x1c8: 0x100401,
28817 0x1d8: 0x400,
28818 0x1e8: 0x2000400,
28819 0x1f8: 0x100001
28820 },
28821 {
28822 0x0: 0x8000820,
28823 0x1: 0x20000,
28824 0x2: 0x8000000,
28825 0x3: 0x20,
28826 0x4: 0x20020,
28827 0x5: 0x8020820,
28828 0x6: 0x8020800,
28829 0x7: 0x800,
28830 0x8: 0x8020000,
28831 0x9: 0x8000800,
28832 0xa: 0x20800,
28833 0xb: 0x8020020,
28834 0xc: 0x820,
28835 0xd: 0x0,
28836 0xe: 0x8000020,
28837 0xf: 0x20820,
28838 0x80000000: 0x800,
28839 0x80000001: 0x8020820,
28840 0x80000002: 0x8000820,
28841 0x80000003: 0x8000000,
28842 0x80000004: 0x8020000,
28843 0x80000005: 0x20800,
28844 0x80000006: 0x20820,
28845 0x80000007: 0x20,
28846 0x80000008: 0x8000020,
28847 0x80000009: 0x820,
28848 0x8000000a: 0x20020,
28849 0x8000000b: 0x8020800,
28850 0x8000000c: 0x0,
28851 0x8000000d: 0x8020020,
28852 0x8000000e: 0x8000800,
28853 0x8000000f: 0x20000,
28854 0x10: 0x20820,
28855 0x11: 0x8020800,
28856 0x12: 0x20,
28857 0x13: 0x800,
28858 0x14: 0x8000800,
28859 0x15: 0x8000020,
28860 0x16: 0x8020020,
28861 0x17: 0x20000,
28862 0x18: 0x0,
28863 0x19: 0x20020,
28864 0x1a: 0x8020000,
28865 0x1b: 0x8000820,
28866 0x1c: 0x8020820,
28867 0x1d: 0x20800,
28868 0x1e: 0x820,
28869 0x1f: 0x8000000,
28870 0x80000010: 0x20000,
28871 0x80000011: 0x800,
28872 0x80000012: 0x8020020,
28873 0x80000013: 0x20820,
28874 0x80000014: 0x20,
28875 0x80000015: 0x8020000,
28876 0x80000016: 0x8000000,
28877 0x80000017: 0x8000820,
28878 0x80000018: 0x8020820,
28879 0x80000019: 0x8000020,
28880 0x8000001a: 0x8000800,
28881 0x8000001b: 0x0,
28882 0x8000001c: 0x20800,
28883 0x8000001d: 0x820,
28884 0x8000001e: 0x20020,
28885 0x8000001f: 0x8020800
28886 }
28887 ];
28888
28889 // Masks that select the SBOX input
28890 var SBOX_MASK = [
28891 0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
28892 0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
28893 ];
28894
28895 /**
28896 * DES block cipher algorithm.
28897 */
28898 var DES = C_algo.DES = BlockCipher.extend({
28899 _doReset: function () {
28900 // Shortcuts
28901 var key = this._key;
28902 var keyWords = key.words;
28903
28904 // Select 56 bits according to PC1
28905 var keyBits = [];
28906 for (var i = 0; i < 56; i++) {
28907 var keyBitPos = PC1[i] - 1;
28908 keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
28909 }
28910
28911 // Assemble 16 subkeys
28912 var subKeys = this._subKeys = [];
28913 for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
28914 // Create subkey
28915 var subKey = subKeys[nSubKey] = [];
28916
28917 // Shortcut
28918 var bitShift = BIT_SHIFTS[nSubKey];
28919
28920 // Select 48 bits according to PC2
28921 for (var i = 0; i < 24; i++) {
28922 // Select from the left 28 key bits
28923 subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);
28924
28925 // Select from the right 28 key bits
28926 subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
28927 }
28928
28929 // Since each subkey is applied to an expanded 32-bit input,
28930 // the subkey can be broken into 8 values scaled to 32-bits,
28931 // which allows the key to be used without expansion
28932 subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
28933 for (var i = 1; i < 7; i++) {
28934 subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
28935 }
28936 subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
28937 }
28938
28939 // Compute inverse subkeys
28940 var invSubKeys = this._invSubKeys = [];
28941 for (var i = 0; i < 16; i++) {
28942 invSubKeys[i] = subKeys[15 - i];
28943 }
28944 },
28945
28946 encryptBlock: function (M, offset) {
28947 this._doCryptBlock(M, offset, this._subKeys);
28948 },
28949
28950 decryptBlock: function (M, offset) {
28951 this._doCryptBlock(M, offset, this._invSubKeys);
28952 },
28953
28954 _doCryptBlock: function (M, offset, subKeys) {
28955 // Get input
28956 this._lBlock = M[offset];
28957 this._rBlock = M[offset + 1];
28958
28959 // Initial permutation
28960 exchangeLR.call(this, 4, 0x0f0f0f0f);
28961 exchangeLR.call(this, 16, 0x0000ffff);
28962 exchangeRL.call(this, 2, 0x33333333);
28963 exchangeRL.call(this, 8, 0x00ff00ff);
28964 exchangeLR.call(this, 1, 0x55555555);
28965
28966 // Rounds
28967 for (var round = 0; round < 16; round++) {
28968 // Shortcuts
28969 var subKey = subKeys[round];
28970 var lBlock = this._lBlock;
28971 var rBlock = this._rBlock;
28972
28973 // Feistel function
28974 var f = 0;
28975 for (var i = 0; i < 8; i++) {
28976 f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
28977 }
28978 this._lBlock = rBlock;
28979 this._rBlock = lBlock ^ f;
28980 }
28981
28982 // Undo swap from last round
28983 var t = this._lBlock;
28984 this._lBlock = this._rBlock;
28985 this._rBlock = t;
28986
28987 // Final permutation
28988 exchangeLR.call(this, 1, 0x55555555);
28989 exchangeRL.call(this, 8, 0x00ff00ff);
28990 exchangeRL.call(this, 2, 0x33333333);
28991 exchangeLR.call(this, 16, 0x0000ffff);
28992 exchangeLR.call(this, 4, 0x0f0f0f0f);
28993
28994 // Set output
28995 M[offset] = this._lBlock;
28996 M[offset + 1] = this._rBlock;
28997 },
28998
28999 keySize: 64/32,
29000
29001 ivSize: 64/32,
29002
29003 blockSize: 64/32
29004 });
29005
29006 // Swap bits across the left and right words
29007 function exchangeLR(offset, mask) {
29008 var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
29009 this._rBlock ^= t;
29010 this._lBlock ^= t << offset;
29011 }
29012
29013 function exchangeRL(offset, mask) {
29014 var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
29015 this._lBlock ^= t;
29016 this._rBlock ^= t << offset;
29017 }
29018
29019 /**
29020 * Shortcut functions to the cipher's object interface.
29021 *
29022 * @example
29023 *
29024 * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
29025 * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg);
29026 */
29027 C.DES = BlockCipher._createHelper(DES);
29028
29029 /**
29030 * Triple-DES block cipher algorithm.
29031 */
29032 var TripleDES = C_algo.TripleDES = BlockCipher.extend({
29033 _doReset: function () {
29034 // Shortcuts
29035 var key = this._key;
29036 var keyWords = key.words;
29037
29038 // Create DES instances
29039 this._des1 = DES.createEncryptor(WordArray.create(keyWords.slice(0, 2)));
29040 this._des2 = DES.createEncryptor(WordArray.create(keyWords.slice(2, 4)));
29041 this._des3 = DES.createEncryptor(WordArray.create(keyWords.slice(4, 6)));
29042 },
29043
29044 encryptBlock: function (M, offset) {
29045 this._des1.encryptBlock(M, offset);
29046 this._des2.decryptBlock(M, offset);
29047 this._des3.encryptBlock(M, offset);
29048 },
29049
29050 decryptBlock: function (M, offset) {
29051 this._des3.decryptBlock(M, offset);
29052 this._des2.encryptBlock(M, offset);
29053 this._des1.decryptBlock(M, offset);
29054 },
29055
29056 keySize: 192/32,
29057
29058 ivSize: 64/32,
29059
29060 blockSize: 64/32
29061 });
29062
29063 /**
29064 * Shortcut functions to the cipher's object interface.
29065 *
29066 * @example
29067 *
29068 * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
29069 * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
29070 */
29071 C.TripleDES = BlockCipher._createHelper(TripleDES);
29072 }());
29073
29074
29075 return CryptoJS.TripleDES;
29076
29077 }));
29078 },{"./cipher-core":30,"./core":31,"./enc-base64":32,"./evpkdf":34,"./md5":39}],62:[function(_dereq_,module,exports){
29079 ;(function (root, factory) {
29080 if (typeof exports === "object") {
29081 // CommonJS
29082 module.exports = exports = factory(_dereq_("./core"));
29083 }
29084 else if (typeof define === "function" && define.amd) {
29085 // AMD
29086 define(["./core"], factory);
29087 }
29088 else {
29089 // Global (browser)
29090 factory(root.CryptoJS);
29091 }
29092 }(this, function (CryptoJS) {
29093
29094 (function (undefined) {
29095 // Shortcuts
29096 var C = CryptoJS;
29097 var C_lib = C.lib;
29098 var Base = C_lib.Base;
29099 var X32WordArray = C_lib.WordArray;
29100
29101 /**
29102 * x64 namespace.
29103 */
29104 var C_x64 = C.x64 = {};
29105
29106 /**
29107 * A 64-bit word.
29108 */
29109 var X64Word = C_x64.Word = Base.extend({
29110 /**
29111 * Initializes a newly created 64-bit word.
29112 *
29113 * @param {number} high The high 32 bits.
29114 * @param {number} low The low 32 bits.
29115 *
29116 * @example
29117 *
29118 * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
29119 */
29120 init: function (high, low) {
29121 this.high = high;
29122 this.low = low;
29123 }
29124
29125 /**
29126 * Bitwise NOTs this word.
29127 *
29128 * @return {X64Word} A new x64-Word object after negating.
29129 *
29130 * @example
29131 *
29132 * var negated = x64Word.not();
29133 */
29134 // not: function () {
29135 // var high = ~this.high;
29136 // var low = ~this.low;
29137
29138 // return X64Word.create(high, low);
29139 // },
29140
29141 /**
29142 * Bitwise ANDs this word with the passed word.
29143 *
29144 * @param {X64Word} word The x64-Word to AND with this word.
29145 *
29146 * @return {X64Word} A new x64-Word object after ANDing.
29147 *
29148 * @example
29149 *
29150 * var anded = x64Word.and(anotherX64Word);
29151 */
29152 // and: function (word) {
29153 // var high = this.high & word.high;
29154 // var low = this.low & word.low;
29155
29156 // return X64Word.create(high, low);
29157 // },
29158
29159 /**
29160 * Bitwise ORs this word with the passed word.
29161 *
29162 * @param {X64Word} word The x64-Word to OR with this word.
29163 *
29164 * @return {X64Word} A new x64-Word object after ORing.
29165 *
29166 * @example
29167 *
29168 * var ored = x64Word.or(anotherX64Word);
29169 */
29170 // or: function (word) {
29171 // var high = this.high | word.high;
29172 // var low = this.low | word.low;
29173
29174 // return X64Word.create(high, low);
29175 // },
29176
29177 /**
29178 * Bitwise XORs this word with the passed word.
29179 *
29180 * @param {X64Word} word The x64-Word to XOR with this word.
29181 *
29182 * @return {X64Word} A new x64-Word object after XORing.
29183 *
29184 * @example
29185 *
29186 * var xored = x64Word.xor(anotherX64Word);
29187 */
29188 // xor: function (word) {
29189 // var high = this.high ^ word.high;
29190 // var low = this.low ^ word.low;
29191
29192 // return X64Word.create(high, low);
29193 // },
29194
29195 /**
29196 * Shifts this word n bits to the left.
29197 *
29198 * @param {number} n The number of bits to shift.
29199 *
29200 * @return {X64Word} A new x64-Word object after shifting.
29201 *
29202 * @example
29203 *
29204 * var shifted = x64Word.shiftL(25);
29205 */
29206 // shiftL: function (n) {
29207 // if (n < 32) {
29208 // var high = (this.high << n) | (this.low >>> (32 - n));
29209 // var low = this.low << n;
29210 // } else {
29211 // var high = this.low << (n - 32);
29212 // var low = 0;
29213 // }
29214
29215 // return X64Word.create(high, low);
29216 // },
29217
29218 /**
29219 * Shifts this word n bits to the right.
29220 *
29221 * @param {number} n The number of bits to shift.
29222 *
29223 * @return {X64Word} A new x64-Word object after shifting.
29224 *
29225 * @example
29226 *
29227 * var shifted = x64Word.shiftR(7);
29228 */
29229 // shiftR: function (n) {
29230 // if (n < 32) {
29231 // var low = (this.low >>> n) | (this.high << (32 - n));
29232 // var high = this.high >>> n;
29233 // } else {
29234 // var low = this.high >>> (n - 32);
29235 // var high = 0;
29236 // }
29237
29238 // return X64Word.create(high, low);
29239 // },
29240
29241 /**
29242 * Rotates this word n bits to the left.
29243 *
29244 * @param {number} n The number of bits to rotate.
29245 *
29246 * @return {X64Word} A new x64-Word object after rotating.
29247 *
29248 * @example
29249 *
29250 * var rotated = x64Word.rotL(25);
29251 */
29252 // rotL: function (n) {
29253 // return this.shiftL(n).or(this.shiftR(64 - n));
29254 // },
29255
29256 /**
29257 * Rotates this word n bits to the right.
29258 *
29259 * @param {number} n The number of bits to rotate.
29260 *
29261 * @return {X64Word} A new x64-Word object after rotating.
29262 *
29263 * @example
29264 *
29265 * var rotated = x64Word.rotR(7);
29266 */
29267 // rotR: function (n) {
29268 // return this.shiftR(n).or(this.shiftL(64 - n));
29269 // },
29270
29271 /**
29272 * Adds this word with the passed word.
29273 *
29274 * @param {X64Word} word The x64-Word to add with this word.
29275 *
29276 * @return {X64Word} A new x64-Word object after adding.
29277 *
29278 * @example
29279 *
29280 * var added = x64Word.add(anotherX64Word);
29281 */
29282 // add: function (word) {
29283 // var low = (this.low + word.low) | 0;
29284 // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;
29285 // var high = (this.high + word.high + carry) | 0;
29286
29287 // return X64Word.create(high, low);
29288 // }
29289 });
29290
29291 /**
29292 * An array of 64-bit words.
29293 *
29294 * @property {Array} words The array of CryptoJS.x64.Word objects.
29295 * @property {number} sigBytes The number of significant bytes in this word array.
29296 */
29297 var X64WordArray = C_x64.WordArray = Base.extend({
29298 /**
29299 * Initializes a newly created word array.
29300 *
29301 * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
29302 * @param {number} sigBytes (Optional) The number of significant bytes in the words.
29303 *
29304 * @example
29305 *
29306 * var wordArray = CryptoJS.x64.WordArray.create();
29307 *
29308 * var wordArray = CryptoJS.x64.WordArray.create([
29309 * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
29310 * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
29311 * ]);
29312 *
29313 * var wordArray = CryptoJS.x64.WordArray.create([
29314 * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
29315 * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
29316 * ], 10);
29317 */
29318 init: function (words, sigBytes) {
29319 words = this.words = words || [];
29320
29321 if (sigBytes != undefined) {
29322 this.sigBytes = sigBytes;
29323 } else {
29324 this.sigBytes = words.length * 8;
29325 }
29326 },
29327
29328 /**
29329 * Converts this 64-bit word array to a 32-bit word array.
29330 *
29331 * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.
29332 *
29333 * @example
29334 *
29335 * var x32WordArray = x64WordArray.toX32();
29336 */
29337 toX32: function () {
29338 // Shortcuts
29339 var x64Words = this.words;
29340 var x64WordsLength = x64Words.length;
29341
29342 // Convert
29343 var x32Words = [];
29344 for (var i = 0; i < x64WordsLength; i++) {
29345 var x64Word = x64Words[i];
29346 x32Words.push(x64Word.high);
29347 x32Words.push(x64Word.low);
29348 }
29349
29350 return X32WordArray.create(x32Words, this.sigBytes);
29351 },
29352
29353 /**
29354 * Creates a copy of this word array.
29355 *
29356 * @return {X64WordArray} The clone.
29357 *
29358 * @example
29359 *
29360 * var clone = x64WordArray.clone();
29361 */
29362 clone: function () {
29363 var clone = Base.clone.call(this);
29364
29365 // Clone "words" array
29366 var words = clone.words = this.words.slice(0);
29367
29368 // Clone each X64Word object
29369 var wordsLength = words.length;
29370 for (var i = 0; i < wordsLength; i++) {
29371 words[i] = words[i].clone();
29372 }
29373
29374 return clone;
29375 }
29376 });
29377 }());
29378
29379
29380 return CryptoJS;
29381
29382 }));
29383 },{"./core":31}],63:[function(_dereq_,module,exports){
29384 var assert = _dereq_('assert')
29385 var BigInteger = _dereq_('bigi')
29386
29387 var Point = _dereq_('./point')
29388
29389 function Curve(p, a, b, Gx, Gy, n, h) {
29390 this.p = p
29391 this.a = a
29392 this.b = b
29393 this.G = Point.fromAffine(this, Gx, Gy)
29394 this.n = n
29395 this.h = h
29396
29397 this.infinity = new Point(this, null, null, BigInteger.ZERO)
29398
29399 // result caching
29400 this.pOverFour = p.add(BigInteger.ONE).shiftRight(2)
29401 }
29402
29403 Curve.prototype.pointFromX = function(isOdd, x) {
29404 var alpha = x.pow(3).add(this.a.multiply(x)).add(this.b).mod(this.p)
29405 var beta = alpha.modPow(this.pOverFour, this.p)
29406
29407 var y = beta
29408 if (beta.isEven() ^ !isOdd) {
29409 y = this.p.subtract(y) // -y % p
29410 }
29411
29412 return Point.fromAffine(this, x, y)
29413 }
29414
29415 Curve.prototype.isInfinity = function(Q) {
29416 if (Q === this.infinity) return true
29417
29418 return Q.z.signum() === 0 && Q.y.signum() !== 0
29419 }
29420
29421 Curve.prototype.isOnCurve = function(Q) {
29422 if (this.isInfinity(Q)) return true
29423
29424 var x = Q.affineX
29425 var y = Q.affineY
29426 var a = this.a
29427 var b = this.b
29428 var p = this.p
29429
29430 // Check that xQ and yQ are integers in the interval [0, p - 1]
29431 if (x.signum() < 0 || x.compareTo(p) >= 0) return false
29432 if (y.signum() < 0 || y.compareTo(p) >= 0) return false
29433
29434 // and check that y^2 = x^3 + ax + b (mod p)
29435 var lhs = y.square().mod(p)
29436 var rhs = x.pow(3).add(a.multiply(x)).add(b).mod(p)
29437 return lhs.equals(rhs)
29438 }
29439
29440 /**
29441 * Validate an elliptic curve point.
29442 *
29443 * See SEC 1, section 3.2.2.1: Elliptic Curve Public Key Validation Primitive
29444 */
29445 Curve.prototype.validate = function(Q) {
29446 // Check Q != O
29447 assert(!this.isInfinity(Q), 'Point is at infinity')
29448 assert(this.isOnCurve(Q), 'Point is not on the curve')
29449
29450 // Check nQ = O (where Q is a scalar multiple of G)
29451 var nQ = Q.multiply(this.n)
29452 assert(this.isInfinity(nQ), 'Point is not a scalar multiple of G')
29453
29454 return true
29455 }
29456
29457 module.exports = Curve
29458
29459 },{"./point":67,"assert":4,"bigi":3}],64:[function(_dereq_,module,exports){
29460 module.exports={
29461 "secp128r1": {
29462 "p": "fffffffdffffffffffffffffffffffff",
29463 "a": "fffffffdfffffffffffffffffffffffc",
29464 "b": "e87579c11079f43dd824993c2cee5ed3",
29465 "n": "fffffffe0000000075a30d1b9038a115",
29466 "h": "01",
29467 "Gx": "161ff7528b899b2d0c28607ca52c5b86",
29468 "Gy": "cf5ac8395bafeb13c02da292dded7a83"
29469 },
29470 "secp160k1": {
29471 "p": "fffffffffffffffffffffffffffffffeffffac73",
29472 "a": "00",
29473 "b": "07",
29474 "n": "0100000000000000000001b8fa16dfab9aca16b6b3",
29475 "h": "01",
29476 "Gx": "3b4c382ce37aa192a4019e763036f4f5dd4d7ebb",
29477 "Gy": "938cf935318fdced6bc28286531733c3f03c4fee"
29478 },
29479 "secp160r1": {
29480 "p": "ffffffffffffffffffffffffffffffff7fffffff",
29481 "a": "ffffffffffffffffffffffffffffffff7ffffffc",
29482 "b": "1c97befc54bd7a8b65acf89f81d4d4adc565fa45",
29483 "n": "0100000000000000000001f4c8f927aed3ca752257",
29484 "h": "01",
29485 "Gx": "4a96b5688ef573284664698968c38bb913cbfc82",
29486 "Gy": "23a628553168947d59dcc912042351377ac5fb32"
29487 },
29488 "secp192k1": {
29489 "p": "fffffffffffffffffffffffffffffffffffffffeffffee37",
29490 "a": "00",
29491 "b": "03",
29492 "n": "fffffffffffffffffffffffe26f2fc170f69466a74defd8d",
29493 "h": "01",
29494 "Gx": "db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d",
29495 "Gy": "9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"
29496 },
29497 "secp192r1": {
29498 "p": "fffffffffffffffffffffffffffffffeffffffffffffffff",
29499 "a": "fffffffffffffffffffffffffffffffefffffffffffffffc",
29500 "b": "64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1",
29501 "n": "ffffffffffffffffffffffff99def836146bc9b1b4d22831",
29502 "h": "01",
29503 "Gx": "188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012",
29504 "Gy": "07192b95ffc8da78631011ed6b24cdd573f977a11e794811"
29505 },
29506 "secp224r1": {
29507 "p": "ffffffffffffffffffffffffffffffff000000000000000000000001",
29508 "a": "fffffffffffffffffffffffffffffffefffffffffffffffffffffffe",
29509 "b": "b4050a850c04b3abf54132565044b0b7d7bfd8ba270b39432355ffb4",
29510 "n": "ffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d",
29511 "h": "01",
29512 "Gx": "b70e0cbd6bb4bf7f321390b94a03c1d356c21122343280d6115c1d21",
29513 "Gy": "bd376388b5f723fb4c22dfe6cd4375a05a07476444d5819985007e34"
29514 },
29515 "secp256k1": {
29516 "p": "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f",
29517 "a": "00",
29518 "b": "07",
29519 "n": "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",
29520 "h": "01",
29521 "Gx": "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
29522 "Gy": "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"
29523 },
29524 "secp256r1": {
29525 "p": "ffffffff00000001000000000000000000000000ffffffffffffffffffffffff",
29526 "a": "ffffffff00000001000000000000000000000000fffffffffffffffffffffffc",
29527 "b": "5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b",
29528 "n": "ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551",
29529 "h": "01",
29530 "Gx": "6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296",
29531 "Gy": "4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"
29532 }
29533 }
29534
29535 },{}],65:[function(_dereq_,module,exports){
29536 var Point = _dereq_('./point')
29537 var Curve = _dereq_('./curve')
29538
29539 var getCurveByName = _dereq_('./names')
29540
29541 module.exports = {
29542 Curve: Curve,
29543 Point: Point,
29544 getCurveByName: getCurveByName
29545 }
29546
29547 },{"./curve":63,"./names":66,"./point":67}],66:[function(_dereq_,module,exports){
29548 var BigInteger = _dereq_('bigi')
29549
29550 var curves = _dereq_('./curves')
29551 var Curve = _dereq_('./curve')
29552
29553 function getCurveByName(name) {
29554 var curve = curves[name]
29555 if (!curve) return null
29556
29557 var p = new BigInteger(curve.p, 16)
29558 var a = new BigInteger(curve.a, 16)
29559 var b = new BigInteger(curve.b, 16)
29560 var n = new BigInteger(curve.n, 16)
29561 var h = new BigInteger(curve.h, 16)
29562 var Gx = new BigInteger(curve.Gx, 16)
29563 var Gy = new BigInteger(curve.Gy, 16)
29564
29565 return new Curve(p, a, b, Gx, Gy, n, h)
29566 }
29567
29568 module.exports = getCurveByName
29569
29570 },{"./curve":63,"./curves":64,"bigi":3}],67:[function(_dereq_,module,exports){
29571 (function (Buffer){
29572 var assert = _dereq_('assert')
29573 var BigInteger = _dereq_('bigi')
29574
29575 var THREE = BigInteger.valueOf(3)
29576
29577 function Point(curve, x, y, z) {
29578 assert.notStrictEqual(z, undefined, 'Missing Z coordinate')
29579
29580 this.curve = curve
29581 this.x = x
29582 this.y = y
29583 this.z = z
29584 this._zInv = null
29585
29586 this.compressed = true
29587 }
29588
29589 Object.defineProperty(Point.prototype, 'zInv', {
29590 get: function() {
29591 if (this._zInv === null) {
29592 this._zInv = this.z.modInverse(this.curve.p)
29593 }
29594
29595 return this._zInv
29596 }
29597 })
29598
29599 Object.defineProperty(Point.prototype, 'affineX', {
29600 get: function() {
29601 return this.x.multiply(this.zInv).mod(this.curve.p)
29602 }
29603 })
29604
29605 Object.defineProperty(Point.prototype, 'affineY', {
29606 get: function() {
29607 return this.y.multiply(this.zInv).mod(this.curve.p)
29608 }
29609 })
29610
29611 Point.fromAffine = function(curve, x, y) {
29612 return new Point(curve, x, y, BigInteger.ONE)
29613 }
29614
29615 Point.prototype.equals = function(other) {
29616 if (other === this) return true
29617 if (this.curve.isInfinity(this)) return this.curve.isInfinity(other)
29618 if (this.curve.isInfinity(other)) return this.curve.isInfinity(this)
29619
29620 // u = Y2 * Z1 - Y1 * Z2
29621 var u = other.y.multiply(this.z).subtract(this.y.multiply(other.z)).mod(this.curve.p)
29622
29623 if (u.signum() !== 0) return false
29624
29625 // v = X2 * Z1 - X1 * Z2
29626 var v = other.x.multiply(this.z).subtract(this.x.multiply(other.z)).mod(this.curve.p)
29627
29628 return v.signum() === 0
29629 }
29630
29631 Point.prototype.negate = function() {
29632 var y = this.curve.p.subtract(this.y)
29633
29634 return new Point(this.curve, this.x, y, this.z)
29635 }
29636
29637 Point.prototype.add = function(b) {
29638 if (this.curve.isInfinity(this)) return b
29639 if (this.curve.isInfinity(b)) return this
29640
29641 var x1 = this.x
29642 var y1 = this.y
29643 var x2 = b.x
29644 var y2 = b.y
29645
29646 // u = Y2 * Z1 - Y1 * Z2
29647 var u = y2.multiply(this.z).subtract(y1.multiply(b.z)).mod(this.curve.p)
29648 // v = X2 * Z1 - X1 * Z2
29649 var v = x2.multiply(this.z).subtract(x1.multiply(b.z)).mod(this.curve.p)
29650
29651 if (v.signum() === 0) {
29652 if (u.signum() === 0) {
29653 return this.twice() // this == b, so double
29654 }
29655
29656 return this.curve.infinity // this = -b, so infinity
29657 }
29658
29659 var v2 = v.square()
29660 var v3 = v2.multiply(v)
29661 var x1v2 = x1.multiply(v2)
29662 var zu2 = u.square().multiply(this.z)
29663
29664 // x3 = v * (z2 * (z1 * u^2 - 2 * x1 * v^2) - v^3)
29665 var x3 = zu2.subtract(x1v2.shiftLeft(1)).multiply(b.z).subtract(v3).multiply(v).mod(this.curve.p)
29666 // y3 = z2 * (3 * x1 * u * v^2 - y1 * v^3 - z1 * u^3) + u * v^3
29667 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)
29668 // z3 = v^3 * z1 * z2
29669 var z3 = v3.multiply(this.z).multiply(b.z).mod(this.curve.p)
29670
29671 return new Point(this.curve, x3, y3, z3)
29672 }
29673
29674 Point.prototype.twice = function() {
29675 if (this.curve.isInfinity(this)) return this
29676 if (this.y.signum() === 0) return this.curve.infinity
29677
29678 var x1 = this.x
29679 var y1 = this.y
29680
29681 var y1z1 = y1.multiply(this.z)
29682 var y1sqz1 = y1z1.multiply(y1).mod(this.curve.p)
29683 var a = this.curve.a
29684
29685 // w = 3 * x1^2 + a * z1^2
29686 var w = x1.square().multiply(THREE)
29687
29688 if (a.signum() !== 0) {
29689 w = w.add(this.z.square().multiply(a))
29690 }
29691
29692 w = w.mod(this.curve.p)
29693 // x3 = 2 * y1 * z1 * (w^2 - 8 * x1 * y1^2 * z1)
29694 var x3 = w.square().subtract(x1.shiftLeft(3).multiply(y1sqz1)).shiftLeft(1).multiply(y1z1).mod(this.curve.p)
29695 // y3 = 4 * y1^2 * z1 * (3 * w * x1 - 2 * y1^2 * z1) - w^3
29696 var y3 = w.multiply(THREE).multiply(x1).subtract(y1sqz1.shiftLeft(1)).shiftLeft(2).multiply(y1sqz1).subtract(w.pow(3)).mod(this.curve.p)
29697 // z3 = 8 * (y1 * z1)^3
29698 var z3 = y1z1.pow(3).shiftLeft(3).mod(this.curve.p)
29699
29700 return new Point(this.curve, x3, y3, z3)
29701 }
29702
29703 // Simple NAF (Non-Adjacent Form) multiplication algorithm
29704 // TODO: modularize the multiplication algorithm
29705 Point.prototype.multiply = function(k) {
29706 if (this.curve.isInfinity(this)) return this
29707 if (k.signum() === 0) return this.curve.infinity
29708
29709 var e = k
29710 var h = e.multiply(THREE)
29711
29712 var neg = this.negate()
29713 var R = this
29714
29715 for (var i = h.bitLength() - 2; i > 0; --i) {
29716 R = R.twice()
29717
29718 var hBit = h.testBit(i)
29719 var eBit = e.testBit(i)
29720
29721 if (hBit != eBit) {
29722 R = R.add(hBit ? this : neg)
29723 }
29724 }
29725
29726 return R
29727 }
29728
29729 // Compute this*j + x*k (simultaneous multiplication)
29730 Point.prototype.multiplyTwo = function(j, x, k) {
29731 var i
29732
29733 if (j.bitLength() > k.bitLength())
29734 i = j.bitLength() - 1
29735 else
29736 i = k.bitLength() - 1
29737
29738 var R = this.curve.infinity
29739 var both = this.add(x)
29740
29741 while (i >= 0) {
29742 R = R.twice()
29743
29744 var jBit = j.testBit(i)
29745 var kBit = k.testBit(i)
29746
29747 if (jBit) {
29748 if (kBit) {
29749 R = R.add(both)
29750
29751 } else {
29752 R = R.add(this)
29753 }
29754
29755 } else {
29756 if (kBit) {
29757 R = R.add(x)
29758 }
29759 }
29760 --i
29761 }
29762
29763 return R
29764 }
29765
29766 Point.prototype.getEncoded = function(compressed) {
29767 if (compressed == undefined) compressed = this.compressed
29768 if (this.curve.isInfinity(this)) return new Buffer('00', 'hex') // Infinity point encoded is simply '00'
29769
29770 var x = this.affineX
29771 var y = this.affineY
29772
29773 var buffer
29774
29775 // Determine size of q in bytes
29776 var byteLength = Math.floor((this.curve.p.bitLength() + 7) / 8)
29777
29778 // 0x02/0x03 | X
29779 if (compressed) {
29780 buffer = new Buffer(1 + byteLength)
29781 buffer.writeUInt8(y.isEven() ? 0x02 : 0x03, 0)
29782
29783 // 0x04 | X | Y
29784 } else {
29785 buffer = new Buffer(1 + byteLength + byteLength)
29786 buffer.writeUInt8(0x04, 0)
29787
29788 y.toBuffer(byteLength).copy(buffer, 1 + byteLength)
29789 }
29790
29791 x.toBuffer(byteLength).copy(buffer, 1)
29792
29793 return buffer
29794 }
29795
29796 Point.decodeFrom = function(curve, buffer) {
29797 var type = buffer.readUInt8(0)
29798 var compressed = (type !== 4)
29799
29800 var x = BigInteger.fromBuffer(buffer.slice(1, 33))
29801 var byteLength = Math.floor((curve.p.bitLength() + 7) / 8)
29802
29803 var Q
29804 if (compressed) {
29805 assert.equal(buffer.length, byteLength + 1, 'Invalid sequence length')
29806 assert(type === 0x02 || type === 0x03, 'Invalid sequence tag')
29807
29808 var isOdd = (type === 0x03)
29809 Q = curve.pointFromX(isOdd, x)
29810
29811 } else {
29812 assert.equal(buffer.length, 1 + byteLength + byteLength, 'Invalid sequence length')
29813
29814 var y = BigInteger.fromBuffer(buffer.slice(1 + byteLength))
29815 Q = Point.fromAffine(curve, x, y)
29816 }
29817
29818 Q.compressed = compressed
29819 return Q
29820 }
29821
29822 Point.prototype.toString = function () {
29823 if (this.curve.isInfinity(this)) return '(INFINITY)'
29824
29825 return '(' + this.affineX.toString() + ',' + this.affineY.toString() + ')'
29826 }
29827
29828 module.exports = Point
29829
29830 }).call(this,_dereq_("buffer").Buffer)
29831 },{"assert":4,"bigi":3,"buffer":8}],68:[function(_dereq_,module,exports){
29832 (function (process,Buffer){
29833 // Closure compiler error - result of 'not' operator not being used
29834 //!function(globals){
29835 (function(globals){
29836 'use strict'
29837
29838 //*** UMD BEGIN
29839 if (typeof define !== 'undefined' && define.amd) { //require.js / AMD
29840 define([], function() {
29841 return secureRandom
29842 })
29843 } else if (typeof module !== 'undefined' && module.exports) { //CommonJS
29844 module.exports = secureRandom
29845 } else { //script / browser
29846 globals.secureRandom = secureRandom
29847 }
29848 //*** UMD END
29849
29850 //options.type is the only valid option
29851 function secureRandom(count, options) {
29852 options = options || {type: 'Array'}
29853 //we check for process.pid to prevent browserify from tricking us
29854 if (typeof process != 'undefined' && typeof process.pid == 'number') {
29855 return nodeRandom(count, options)
29856 } else {
29857 var crypto = window.crypto || window.msCrypto
29858 if (!crypto) throw new Error("Your browser does not support window.crypto.")
29859 return browserRandom(count, options)
29860 }
29861 }
29862
29863 function nodeRandom(count, options) {
29864 var crypto = _dereq_('crypto')
29865 var buf = crypto.randomBytes(count)
29866
29867 switch (options.type) {
29868 case 'Array':
29869 return [].slice.call(buf)
29870 case 'Buffer':
29871 return buf
29872 case 'Uint8Array':
29873 var arr = new Uint8Array(count)
29874 for (var i = 0; i < count; ++i) { arr[i] = buf.readUInt8(i) }
29875 return arr
29876 default:
29877 throw new Error(options.type + " is unsupported.")
29878 }
29879 }
29880
29881 function browserRandom(count, options) {
29882 var nativeArr = new Uint8Array(count)
29883 var crypto = window.crypto || window.msCrypto
29884 crypto.getRandomValues(nativeArr)
29885
29886 switch (options.type) {
29887 case 'Array':
29888 return [].slice.call(nativeArr)
29889 case 'Buffer':
29890 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.')}
29891 return new Buffer(nativeArr)
29892 case 'Uint8Array':
29893 return nativeArr
29894 default:
29895 throw new Error(options.type + " is unsupported.")
29896 }
29897 }
29898
29899 secureRandom.randomArray = function(byteCount) {
29900 return secureRandom(byteCount, {type: 'Array'})
29901 }
29902
29903 secureRandom.randomUint8Array = function(byteCount) {
29904 return secureRandom(byteCount, {type: 'Uint8Array'})
29905 }
29906
29907 secureRandom.randomBuffer = function(byteCount) {
29908 return secureRandom(byteCount, {type: 'Buffer'})
29909 }
29910
29911
29912 })(this);
29913
29914 }).call(this,_dereq_("FWaASH"),_dereq_("buffer").Buffer)
29915 },{"FWaASH":12,"buffer":8,"crypto":7}],69:[function(_dereq_,module,exports){
29916 (function (Buffer){
29917 var assert = _dereq_('assert')
29918 var base58check = _dereq_('./base58check')
29919 var networks = _dereq_('./networks')
29920 var scripts = _dereq_('./scripts')
29921
29922 function findScriptTypeByVersion(version) {
29923 for (var networkName in networks) {
29924 var network = networks[networkName]
29925
29926 if (version === network.pubKeyHash) return 'pubkeyhash'
29927 if (version === network.scriptHash) return 'scripthash'
29928 }
29929 }
29930
29931 function Address(hash, version) {
29932 assert(Buffer.isBuffer(hash), 'Expected Buffer, got ' + hash)
29933 assert.strictEqual(hash.length, 20, 'Invalid hash length')
29934 assert.strictEqual(version & 0xff, version, 'Invalid version byte')
29935
29936 this.hash = hash
29937 this.version = version
29938 }
29939
29940 // Import functions
29941 Address.fromBase58Check = function(string) {
29942 var payload = base58check.decode(string)
29943 var version = payload.readUInt8(0)
29944 var hash = payload.slice(1)
29945
29946 return new Address(hash, version)
29947 }
29948
29949 Address.fromOutputScript = function(script, network) {
29950 network = network || networks.bitcoin
29951
29952 var type = scripts.classifyOutput(script)
29953
29954 if (type === 'pubkeyhash') return new Address(script.chunks[2], network.pubKeyHash)
29955 if (type === 'scripthash') return new Address(script.chunks[1], network.scriptHash)
29956
29957 assert(false, type + ' has no matching Address')
29958 }
29959
29960 // Export functions
29961 Address.prototype.toBase58Check = function () {
29962 var payload = new Buffer(21)
29963 payload.writeUInt8(this.version, 0)
29964 this.hash.copy(payload, 1)
29965
29966 return base58check.encode(payload)
29967 }
29968
29969 Address.prototype.toOutputScript = function() {
29970 var scriptType = findScriptTypeByVersion(this.version)
29971
29972 if (scriptType === 'pubkeyhash') return scripts.pubKeyHashOutput(this.hash)
29973 if (scriptType === 'scripthash') return scripts.scriptHashOutput(this.hash)
29974
29975 assert(false, this.toString() + ' has no matching Script')
29976 }
29977
29978 Address.prototype.toString = Address.prototype.toBase58Check
29979
29980 module.exports = Address
29981
29982 }).call(this,_dereq_("buffer").Buffer)
29983 },{"./base58check":70,"./networks":81,"./scripts":84,"assert":4,"buffer":8}],70:[function(_dereq_,module,exports){
29984 (function (Buffer){
29985 // https://en.bitcoin.it/wiki/Base58Check_encoding
29986 var assert = _dereq_('assert')
29987 var base58 = _dereq_('bs58')
29988 var crypto = _dereq_('./crypto')
29989
29990 // Encode a buffer as a base58-check-encoded string
29991 function encode(payload) {
29992 var checksum = crypto.hash256(payload).slice(0, 4)
29993
29994 return base58.encode(Buffer.concat([
29995 payload,
29996 checksum
29997 ]))
29998 }
29999
30000 // Decode a base58-check-encoded string to a buffer
30001 function decode(string) {
30002 var buffer = base58.decode(string)
30003
30004 var payload = buffer.slice(0, -4)
30005 var checksum = buffer.slice(-4)
30006 var newChecksum = crypto.hash256(payload).slice(0, 4)
30007
30008 assert.deepEqual(newChecksum, checksum, 'Invalid checksum')
30009
30010 return payload
30011 }
30012
30013 module.exports = {
30014 encode: encode,
30015 decode: decode
30016 }
30017
30018 }).call(this,_dereq_("buffer").Buffer)
30019 },{"./crypto":73,"assert":4,"bs58":15,"buffer":8}],71:[function(_dereq_,module,exports){
30020 var assert = _dereq_('assert')
30021 var opcodes = _dereq_('./opcodes')
30022
30023 // https://github.com/feross/buffer/blob/master/index.js#L1127
30024 function verifuint(value, max) {
30025 assert(typeof value === 'number', 'cannot write a non-number as a number')
30026 assert(value >= 0, 'specified a negative value for writing an unsigned value')
30027 assert(value <= max, 'value is larger than maximum value for type')
30028 assert(Math.floor(value) === value, 'value has a fractional component')
30029 }
30030
30031 function pushDataSize(i) {
30032 return i < opcodes.OP_PUSHDATA1 ? 1
30033 : i < 0xff ? 2
30034 : i < 0xffff ? 3
30035 : 5
30036 }
30037
30038 function readPushDataInt(buffer, offset) {
30039 var opcode = buffer.readUInt8(offset)
30040 var number, size
30041
30042 // ~6 bit
30043 if (opcode < opcodes.OP_PUSHDATA1) {
30044 number = opcode
30045 size = 1
30046
30047 // 8 bit
30048 } else if (opcode === opcodes.OP_PUSHDATA1) {
30049 number = buffer.readUInt8(offset + 1)
30050 size = 2
30051
30052 // 16 bit
30053 } else if (opcode === opcodes.OP_PUSHDATA2) {
30054 number = buffer.readUInt16LE(offset + 1)
30055 size = 3
30056
30057 // 32 bit
30058 } else {
30059 assert.equal(opcode, opcodes.OP_PUSHDATA4, 'Unexpected opcode')
30060
30061 number = buffer.readUInt32LE(offset + 1)
30062 size = 5
30063
30064 }
30065
30066 return {
30067 opcode: opcode,
30068 number: number,
30069 size: size
30070 }
30071 }
30072
30073 function readUInt64LE(buffer, offset) {
30074 var a = buffer.readUInt32LE(offset)
30075 var b = buffer.readUInt32LE(offset + 4)
30076 b *= 0x100000000
30077
30078 verifuint(b + a, 0x001fffffffffffff)
30079
30080 return b + a
30081 }
30082
30083 function readVarInt(buffer, offset) {
30084 var t = buffer.readUInt8(offset)
30085 var number, size
30086
30087 // 8 bit
30088 if (t < 253) {
30089 number = t
30090 size = 1
30091
30092 // 16 bit
30093 } else if (t < 254) {
30094 number = buffer.readUInt16LE(offset + 1)
30095 size = 3
30096
30097 // 32 bit
30098 } else if (t < 255) {
30099 number = buffer.readUInt32LE(offset + 1)
30100 size = 5
30101
30102 // 64 bit
30103 } else {
30104 number = readUInt64LE(buffer, offset + 1)
30105 size = 9
30106 }
30107
30108 return {
30109 number: number,
30110 size: size
30111 }
30112 }
30113
30114 function writePushDataInt(buffer, number, offset) {
30115 var size = pushDataSize(number)
30116
30117 // ~6 bit
30118 if (size === 1) {
30119 buffer.writeUInt8(number, offset)
30120
30121 // 8 bit
30122 } else if (size === 2) {
30123 buffer.writeUInt8(opcodes.OP_PUSHDATA1, offset)
30124 buffer.writeUInt8(number, offset + 1)
30125
30126 // 16 bit
30127 } else if (size === 3) {
30128 buffer.writeUInt8(opcodes.OP_PUSHDATA2, offset)
30129 buffer.writeUInt16LE(number, offset + 1)
30130
30131 // 32 bit
30132 } else {
30133 buffer.writeUInt8(opcodes.OP_PUSHDATA4, offset)
30134 buffer.writeUInt32LE(number, offset + 1)
30135
30136 }
30137
30138 return size
30139 }
30140
30141 function writeUInt64LE(buffer, value, offset) {
30142 verifuint(value, 0x001fffffffffffff)
30143
30144 buffer.writeInt32LE(value & -1, offset)
30145 buffer.writeUInt32LE(Math.floor(value / 0x100000000), offset + 4)
30146 }
30147
30148 function varIntSize(i) {
30149 return i < 253 ? 1
30150 : i < 0x10000 ? 3
30151 : i < 0x100000000 ? 5
30152 : 9
30153 }
30154
30155 function writeVarInt(buffer, number, offset) {
30156 var size = varIntSize(number)
30157
30158 // 8 bit
30159 if (size === 1) {
30160 buffer.writeUInt8(number, offset)
30161
30162 // 16 bit
30163 } else if (size === 3) {
30164 buffer.writeUInt8(253, offset)
30165 buffer.writeUInt16LE(number, offset + 1)
30166
30167 // 32 bit
30168 } else if (size === 5) {
30169 buffer.writeUInt8(254, offset)
30170 buffer.writeUInt32LE(number, offset + 1)
30171
30172 // 64 bit
30173 } else {
30174 buffer.writeUInt8(255, offset)
30175 writeUInt64LE(buffer, number, offset + 1)
30176 }
30177
30178 return size
30179 }
30180
30181 module.exports = {
30182 pushDataSize: pushDataSize,
30183 readPushDataInt: readPushDataInt,
30184 readUInt64LE: readUInt64LE,
30185 readVarInt: readVarInt,
30186 varIntSize: varIntSize,
30187 writePushDataInt: writePushDataInt,
30188 writeUInt64LE: writeUInt64LE,
30189 writeVarInt: writeVarInt
30190 }
30191
30192 },{"./opcodes":82,"assert":4}],72:[function(_dereq_,module,exports){
30193 (function (Buffer){
30194 var assert = _dereq_('assert')
30195 var Crypto = _dereq_('crypto-js')
30196 var WordArray = Crypto.lib.WordArray
30197
30198 function bufferToWordArray(buffer) {
30199 assert(Buffer.isBuffer(buffer), 'Expected Buffer, got', buffer)
30200
30201 var words = []
30202 for (var i = 0, b = 0; i < buffer.length; i++, b += 8) {
30203 words[b >>> 5] |= buffer[i] << (24 - b % 32)
30204 }
30205
30206 return new WordArray.init(words, buffer.length)
30207 }
30208
30209 function wordArrayToBuffer(wordArray) {
30210 assert(Array.isArray(wordArray.words), 'Expected WordArray, got' + wordArray)
30211
30212 var words = wordArray.words
30213 var buffer = new Buffer(words.length * 4)
30214
30215 words.forEach(function(value, i) {
30216 buffer.writeInt32BE(value & -1, i * 4)
30217 })
30218
30219 return buffer
30220 }
30221
30222 module.exports = {
30223 bufferToWordArray: bufferToWordArray,
30224 wordArrayToBuffer: wordArrayToBuffer
30225 }
30226
30227 }).call(this,_dereq_("buffer").Buffer)
30228 },{"assert":4,"buffer":8,"crypto-js":37}],73:[function(_dereq_,module,exports){
30229 (function (Buffer){
30230 // Crypto, crypto, where art thou crypto
30231 var assert = _dereq_('assert')
30232 var CryptoJS = _dereq_('crypto-js')
30233 var crypto = _dereq_('crypto')
30234 var convert = _dereq_('./convert')
30235
30236 function hash160(buffer) {
30237 return ripemd160(sha256(buffer))
30238 }
30239
30240 function hash256(buffer) {
30241 return sha256(sha256(buffer))
30242 }
30243
30244 function ripemd160(buffer) {
30245 return crypto.createHash('rmd160').update(buffer).digest()
30246 }
30247
30248 function sha1(buffer) {
30249 return crypto.createHash('sha1').update(buffer).digest()
30250 }
30251
30252 function sha256(buffer) {
30253 return crypto.createHash('sha256').update(buffer).digest()
30254 }
30255
30256 // FIXME: Name not consistent with others
30257 function HmacSHA256(buffer, secret) {
30258 return crypto.createHmac('sha256', secret).update(buffer).digest()
30259 }
30260
30261 function HmacSHA512(data, secret) {
30262 assert(Buffer.isBuffer(data), 'Expected Buffer for data, got ' + data)
30263 assert(Buffer.isBuffer(secret), 'Expected Buffer for secret, got ' + secret)
30264
30265 var dataWords = convert.bufferToWordArray(data)
30266 var secretWords = convert.bufferToWordArray(secret)
30267
30268 var hash = CryptoJS.HmacSHA512(dataWords, secretWords)
30269
30270 return convert.wordArrayToBuffer(hash)
30271 }
30272
30273 module.exports = {
30274 ripemd160: ripemd160,
30275 sha1: sha1,
30276 sha256: sha256,
30277 hash160: hash160,
30278 hash256: hash256,
30279 HmacSHA256: HmacSHA256,
30280 HmacSHA512: HmacSHA512
30281 }
30282
30283 }).call(this,_dereq_("buffer").Buffer)
30284 },{"./convert":72,"assert":4,"buffer":8,"crypto":19,"crypto-js":37}],74:[function(_dereq_,module,exports){
30285 (function (Buffer){
30286 var assert = _dereq_('assert')
30287 var crypto = _dereq_('./crypto')
30288
30289 var BigInteger = _dereq_('bigi')
30290 var ECSignature = _dereq_('./ecsignature')
30291 var Point = _dereq_('ecurve').Point
30292
30293 // https://tools.ietf.org/html/rfc6979#section-3.2
30294 function deterministicGenerateK(curve, hash, d) {
30295 assert(Buffer.isBuffer(hash), 'Hash must be a Buffer, not ' + hash)
30296 assert.equal(hash.length, 32, 'Hash must be 256 bit')
30297 assert(d instanceof BigInteger, 'Private key must be a BigInteger')
30298
30299 var x = d.toBuffer(32)
30300 var k = new Buffer(32)
30301 var v = new Buffer(32)
30302
30303 // Step B
30304 v.fill(1)
30305
30306 // Step C
30307 k.fill(0)
30308
30309 // Step D
30310 k = crypto.HmacSHA256(Buffer.concat([v, new Buffer([0]), x, hash]), k)
30311
30312 // Step E
30313 v = crypto.HmacSHA256(v, k)
30314
30315 // Step F
30316 k = crypto.HmacSHA256(Buffer.concat([v, new Buffer([1]), x, hash]), k)
30317
30318 // Step G
30319 v = crypto.HmacSHA256(v, k)
30320
30321 // Step H1/H2a, ignored as tlen === qlen (256 bit)
30322 // Step H2b
30323 v = crypto.HmacSHA256(v, k)
30324
30325 var T = BigInteger.fromBuffer(v)
30326
30327 // Step H3, repeat until T is within the interval [1, n - 1]
30328 while ((T.signum() <= 0) || (T.compareTo(curve.n) >= 0)) {
30329 k = crypto.HmacSHA256(Buffer.concat([v, new Buffer([0])]), k)
30330 v = crypto.HmacSHA256(v, k)
30331
30332 T = BigInteger.fromBuffer(v)
30333 }
30334
30335 return T
30336 }
30337
30338 function sign(curve, hash, d) {
30339 var k = deterministicGenerateK(curve, hash, d)
30340
30341 var n = curve.n
30342 var G = curve.G
30343 var Q = G.multiply(k)
30344 var e = BigInteger.fromBuffer(hash)
30345
30346 var r = Q.affineX.mod(n)
30347 assert.notEqual(r.signum(), 0, 'Invalid R value')
30348
30349 var s = k.modInverse(n).multiply(e.add(d.multiply(r))).mod(n)
30350 assert.notEqual(s.signum(), 0, 'Invalid S value')
30351
30352 var N_OVER_TWO = n.shiftRight(1)
30353
30354 // enforce low S values, see bip62: 'low s values in signatures'
30355 if (s.compareTo(N_OVER_TWO) > 0) {
30356 s = n.subtract(s)
30357 }
30358
30359 return new ECSignature(r, s)
30360 }
30361
30362 function verify(curve, hash, signature, Q) {
30363 var e = BigInteger.fromBuffer(hash)
30364
30365 return verifyRaw(curve, e, signature, Q)
30366 }
30367
30368 function verifyRaw(curve, e, signature, Q) {
30369 var n = curve.n
30370 var G = curve.G
30371
30372 var r = signature.r
30373 var s = signature.s
30374
30375 if (r.signum() === 0 || r.compareTo(n) >= 0) return false
30376 if (s.signum() === 0 || s.compareTo(n) >= 0) return false
30377
30378 var c = s.modInverse(n)
30379
30380 var u1 = e.multiply(c).mod(n)
30381 var u2 = r.multiply(c).mod(n)
30382
30383 var point = G.multiplyTwo(u1, Q, u2)
30384 var v = point.affineX.mod(n)
30385
30386 return v.equals(r)
30387 }
30388
30389 /**
30390 * Recover a public key from a signature.
30391 *
30392 * See SEC 1: Elliptic Curve Cryptography, section 4.1.6, "Public
30393 * Key Recovery Operation".
30394 *
30395 * http://www.secg.org/download/aid-780/sec1-v2.pdf
30396 */
30397 function recoverPubKey(curve, e, signature, i) {
30398 assert.strictEqual(i & 3, i, 'Recovery param is more than two bits')
30399
30400 var r = signature.r
30401 var s = signature.s
30402
30403 // A set LSB signifies that the y-coordinate is odd
30404 var isYOdd = i & 1
30405
30406 // The more significant bit specifies whether we should use the
30407 // first or second candidate key.
30408 var isSecondKey = i >> 1
30409
30410 var n = curve.n
30411 var G = curve.G
30412
30413 // 1.1 Let x = r + jn
30414 var x = isSecondKey ? r.add(n) : r
30415 var R = curve.pointFromX(isYOdd, x)
30416
30417 // 1.4 Check that nR is at infinity
30418 var nR = R.multiply(n)
30419 assert(curve.isInfinity(nR), 'nR is not a valid curve point')
30420
30421 // Compute -e from e
30422 var eNeg = e.negate().mod(n)
30423
30424 // 1.6.1 Compute Q = r^-1 (sR - eG)
30425 // Q = r^-1 (sR + -eG)
30426 var rInv = r.modInverse(n)
30427
30428 var Q = R.multiplyTwo(s, G, eNeg).multiply(rInv)
30429 curve.validate(Q)
30430
30431 return Q
30432 }
30433
30434 /**
30435 * Calculate pubkey extraction parameter.
30436 *
30437 * When extracting a pubkey from a signature, we have to
30438 * distinguish four different cases. Rather than putting this
30439 * burden on the verifier, Bitcoin includes a 2-bit value with the
30440 * signature.
30441 *
30442 * This function simply tries all four cases and returns the value
30443 * that resulted in a successful pubkey recovery.
30444 */
30445 function calcPubKeyRecoveryParam(curve, e, signature, Q) {
30446 for (var i = 0; i < 4; i++) {
30447 var Qprime = recoverPubKey(curve, e, signature, i)
30448
30449 // 1.6.2 Verify Q
30450 if (Qprime.equals(Q)) {
30451 return i
30452 }
30453 }
30454
30455 throw new Error('Unable to find valid recovery factor')
30456 }
30457
30458 module.exports = {
30459 calcPubKeyRecoveryParam: calcPubKeyRecoveryParam,
30460 deterministicGenerateK: deterministicGenerateK,
30461 recoverPubKey: recoverPubKey,
30462 sign: sign,
30463 verify: verify,
30464 verifyRaw: verifyRaw
30465 }
30466
30467 }).call(this,_dereq_("buffer").Buffer)
30468 },{"./crypto":73,"./ecsignature":77,"assert":4,"bigi":3,"buffer":8,"ecurve":65}],75:[function(_dereq_,module,exports){
30469 (function (Buffer){
30470 var assert = _dereq_('assert')
30471 var base58check = _dereq_('./base58check')
30472 var ecdsa = _dereq_('./ecdsa')
30473 var networks = _dereq_('./networks')
30474 var secureRandom = _dereq_('secure-random')
30475
30476 var BigInteger = _dereq_('bigi')
30477 var ECPubKey = _dereq_('./ecpubkey')
30478
30479 var ecurve = _dereq_('ecurve')
30480 var curve = ecurve.getCurveByName('secp256k1')
30481
30482 function ECKey(d, compressed) {
30483 assert(d.signum() > 0, 'Private key must be greater than 0')
30484 assert(d.compareTo(curve.n) < 0, 'Private key must be less than the curve order')
30485
30486 var Q = curve.G.multiply(d)
30487
30488 this.d = d
30489 this.pub = new ECPubKey(Q, compressed)
30490 }
30491
30492 // Static constructors
30493 ECKey.fromWIF = function(string) {
30494 var payload = base58check.decode(string)
30495 var compressed = false
30496
30497 // Ignore the version byte
30498 payload = payload.slice(1)
30499
30500 if (payload.length === 33) {
30501 assert.strictEqual(payload[32], 0x01, 'Invalid compression flag')
30502
30503 // Truncate the compression flag
30504 payload = payload.slice(0, -1)
30505 compressed = true
30506 }
30507
30508 assert.equal(payload.length, 32, 'Invalid WIF payload length')
30509
30510 var d = BigInteger.fromBuffer(payload)
30511 return new ECKey(d, compressed)
30512 }
30513
30514 ECKey.makeRandom = function(compressed, rng) {
30515 rng = rng || secureRandom.randomBuffer
30516
30517 var buffer = rng(32)
30518 assert(Buffer.isBuffer(buffer), 'Expected Buffer, got ' + buffer)
30519
30520 var d = BigInteger.fromBuffer(buffer)
30521 d = d.mod(curve.n)
30522
30523 return new ECKey(d, compressed)
30524 }
30525
30526 // Export functions
30527 ECKey.prototype.toWIF = function(network) {
30528 network = network || networks.bitcoin
30529
30530 var bufferLen = this.pub.compressed ? 34 : 33
30531 var buffer = new Buffer(bufferLen)
30532
30533 buffer.writeUInt8(network.wif, 0)
30534 this.d.toBuffer(32).copy(buffer, 1)
30535
30536 if (this.pub.compressed) {
30537 buffer.writeUInt8(0x01, 33)
30538 }
30539
30540 return base58check.encode(buffer)
30541 }
30542
30543 // Operations
30544 ECKey.prototype.sign = function(hash) {
30545 return ecdsa.sign(curve, hash, this.d)
30546 }
30547
30548 module.exports = ECKey
30549
30550 }).call(this,_dereq_("buffer").Buffer)
30551 },{"./base58check":70,"./ecdsa":74,"./ecpubkey":76,"./networks":81,"assert":4,"bigi":3,"buffer":8,"ecurve":65,"secure-random":68}],76:[function(_dereq_,module,exports){
30552 (function (Buffer){
30553 var assert = _dereq_('assert')
30554 var crypto = _dereq_('./crypto')
30555 var ecdsa = _dereq_('./ecdsa')
30556 var networks = _dereq_('./networks')
30557
30558 var Address = _dereq_('./address')
30559
30560 var ecurve = _dereq_('ecurve')
30561 var curve = ecurve.getCurveByName('secp256k1')
30562
30563 function ECPubKey(Q, compressed) {
30564 assert(Q instanceof ecurve.Point, 'Expected Point, got ' + Q)
30565
30566 if (compressed == undefined) compressed = true
30567 assert.strictEqual(typeof compressed, 'boolean', 'Expected boolean, got ' + compressed)
30568
30569 this.compressed = compressed
30570 this.Q = Q
30571 }
30572
30573 // Static constructors
30574 ECPubKey.fromBuffer = function(buffer) {
30575 var Q = ecurve.Point.decodeFrom(curve, buffer)
30576 return new ECPubKey(Q, Q.compressed)
30577 }
30578
30579 ECPubKey.fromHex = function(hex) {
30580 return ECPubKey.fromBuffer(new Buffer(hex, 'hex'))
30581 }
30582
30583 // Operations
30584 ECPubKey.prototype.getAddress = function(network) {
30585 network = network || networks.bitcoin
30586
30587 return new Address(crypto.hash160(this.toBuffer()), network.pubKeyHash)
30588 }
30589
30590 ECPubKey.prototype.verify = function(hash, signature) {
30591 return ecdsa.verify(curve, hash, signature, this.Q)
30592 }
30593
30594 // Export functions
30595 ECPubKey.prototype.toBuffer = function() {
30596 return this.Q.getEncoded(this.compressed)
30597 }
30598
30599 ECPubKey.prototype.toHex = function() {
30600 return this.toBuffer().toString('hex')
30601 }
30602
30603 module.exports = ECPubKey
30604
30605 }).call(this,_dereq_("buffer").Buffer)
30606 },{"./address":69,"./crypto":73,"./ecdsa":74,"./networks":81,"assert":4,"buffer":8,"ecurve":65}],77:[function(_dereq_,module,exports){
30607 (function (Buffer){
30608 var assert = _dereq_('assert')
30609 var BigInteger = _dereq_('bigi')
30610
30611 function ECSignature(r, s) {
30612 assert(r instanceof BigInteger, 'Expected BigInteger, got ' + r)
30613 assert(s instanceof BigInteger, 'Expected BigInteger, got ' + s)
30614 this.r = r
30615 this.s = s
30616 }
30617
30618 // Import operations
30619 ECSignature.parseCompact = function(buffer) {
30620 assert.equal(buffer.length, 65, 'Invalid signature length')
30621 var i = buffer.readUInt8(0) - 27
30622
30623 // At most 3 bits
30624 assert.equal(i, i & 7, 'Invalid signature parameter')
30625 var compressed = !!(i & 4)
30626
30627 // Recovery param only
30628 i = i & 3
30629
30630 var r = BigInteger.fromBuffer(buffer.slice(1, 33))
30631 var s = BigInteger.fromBuffer(buffer.slice(33))
30632
30633 return {
30634 compressed: compressed,
30635 i: i,
30636 signature: new ECSignature(r, s)
30637 }
30638 }
30639
30640 ECSignature.fromDER = function(buffer) {
30641 assert.equal(buffer.readUInt8(0), 0x30, 'Not a DER sequence')
30642 assert.equal(buffer.readUInt8(1), buffer.length - 2, 'Invalid sequence length')
30643 assert.equal(buffer.readUInt8(2), 0x02, 'Expected a DER integer')
30644
30645 var rLen = buffer.readUInt8(3)
30646 assert(rLen > 0, 'R length is zero')
30647
30648 var offset = 4 + rLen
30649 assert.equal(buffer.readUInt8(offset), 0x02, 'Expected a DER integer (2)')
30650
30651 var sLen = buffer.readUInt8(offset + 1)
30652 assert(sLen > 0, 'S length is zero')
30653
30654 var rB = buffer.slice(4, offset)
30655 var sB = buffer.slice(offset + 2)
30656 offset += 2 + sLen
30657
30658 if (rLen > 1 && rB.readUInt8(0) === 0x00) {
30659 assert(rB.readUInt8(1) & 0x80, 'R value excessively padded')
30660 }
30661
30662 if (sLen > 1 && sB.readUInt8(0) === 0x00) {
30663 assert(sB.readUInt8(1) & 0x80, 'S value excessively padded')
30664 }
30665
30666 assert.equal(offset, buffer.length, 'Invalid DER encoding')
30667 var r = BigInteger.fromDERInteger(rB)
30668 var s = BigInteger.fromDERInteger(sB)
30669
30670 assert(r.signum() >= 0, 'R value is negative')
30671 assert(s.signum() >= 0, 'S value is negative')
30672
30673 return new ECSignature(r, s)
30674 }
30675
30676 // FIXME: 0x00, 0x04, 0x80 are SIGHASH_* boundary constants, importing Transaction causes a circular dependency
30677 ECSignature.parseScriptSignature = function(buffer) {
30678 var hashType = buffer.readUInt8(buffer.length - 1)
30679 var hashTypeMod = hashType & ~0x80
30680
30681 assert(hashTypeMod > 0x00 && hashTypeMod < 0x04, 'Invalid hashType')
30682
30683 return {
30684 signature: ECSignature.fromDER(buffer.slice(0, -1)),
30685 hashType: hashType
30686 }
30687 }
30688
30689 // Export operations
30690 ECSignature.prototype.toCompact = function(i, compressed) {
30691 if (compressed) i += 4
30692 i += 27
30693
30694 var buffer = new Buffer(65)
30695 buffer.writeUInt8(i, 0)
30696
30697 this.r.toBuffer(32).copy(buffer, 1)
30698 this.s.toBuffer(32).copy(buffer, 33)
30699
30700 return buffer
30701 }
30702
30703 ECSignature.prototype.toDER = function() {
30704 var rBa = this.r.toDERInteger()
30705 var sBa = this.s.toDERInteger()
30706
30707 var sequence = []
30708 sequence.push(0x02) // INTEGER
30709 sequence.push(rBa.length)
30710 sequence = sequence.concat(rBa)
30711
30712 sequence.push(0x02) // INTEGER
30713 sequence.push(sBa.length)
30714 sequence = sequence.concat(sBa)
30715
30716 sequence.unshift(sequence.length)
30717 sequence.unshift(0x30) // SEQUENCE
30718
30719 return new Buffer(sequence)
30720 }
30721
30722 ECSignature.prototype.toScriptSignature = function(hashType) {
30723 var hashTypeBuffer = new Buffer(1)
30724 hashTypeBuffer.writeUInt8(hashType, 0)
30725
30726 return Buffer.concat([this.toDER(), hashTypeBuffer])
30727 }
30728
30729 module.exports = ECSignature
30730
30731 }).call(this,_dereq_("buffer").Buffer)
30732 },{"assert":4,"bigi":3,"buffer":8}],78:[function(_dereq_,module,exports){
30733 (function (Buffer){
30734 var assert = _dereq_('assert')
30735 var base58check = _dereq_('./base58check')
30736 var crypto = _dereq_('./crypto')
30737 var networks = _dereq_('./networks')
30738
30739 var BigInteger = _dereq_('bigi')
30740 var ECKey = _dereq_('./eckey')
30741 var ECPubKey = _dereq_('./ecpubkey')
30742
30743 var ecurve = _dereq_('ecurve')
30744 var curve = ecurve.getCurveByName('secp256k1')
30745
30746 function findBIP32ParamsByVersion(version) {
30747 for (var name in networks) {
30748 var network = networks[name]
30749
30750 for (var type in network.bip32) {
30751 if (version != network.bip32[type]) continue
30752
30753 return {
30754 isPrivate: (type === 'private'),
30755 network: network
30756 }
30757 }
30758 }
30759
30760 assert(false, 'Could not find version ' + version.toString(16))
30761 }
30762
30763 function HDNode(K, chainCode, network) {
30764 network = network || networks.bitcoin
30765
30766 assert(Buffer.isBuffer(chainCode), 'Expected Buffer, got ' + chainCode)
30767 assert(network.bip32, 'Unknown BIP32 constants for network')
30768
30769 this.chainCode = chainCode
30770 this.depth = 0
30771 this.index = 0
30772 this.network = network
30773
30774 if (K instanceof BigInteger) {
30775 this.privKey = new ECKey(K, true)
30776 this.pubKey = this.privKey.pub
30777 } else {
30778 this.pubKey = new ECPubKey(K, true)
30779 }
30780 }
30781
30782 HDNode.MASTER_SECRET = new Buffer('Bitcoin seed')
30783 HDNode.HIGHEST_BIT = 0x80000000
30784 HDNode.LENGTH = 78
30785
30786 HDNode.fromSeedBuffer = function(seed, network) {
30787 var I = crypto.HmacSHA512(seed, HDNode.MASTER_SECRET)
30788 var IL = I.slice(0, 32)
30789 var IR = I.slice(32)
30790
30791 // In case IL is 0 or >= n, the master key is invalid
30792 // This is handled by `new ECKey` in the HDNode constructor
30793 var pIL = BigInteger.fromBuffer(IL)
30794
30795 return new HDNode(pIL, IR, network)
30796 }
30797
30798 HDNode.fromSeedHex = function(hex, network) {
30799 return HDNode.fromSeedBuffer(new Buffer(hex, 'hex'), network)
30800 }
30801
30802 HDNode.fromBase58 = function(string) {
30803 return HDNode.fromBuffer(base58check.decode(string))
30804 }
30805
30806 HDNode.fromBuffer = function(buffer) {
30807 assert.strictEqual(buffer.length, HDNode.LENGTH, 'Invalid buffer length')
30808
30809 // 4 byte: version bytes
30810 var version = buffer.readUInt32BE(0)
30811 var params = findBIP32ParamsByVersion(version)
30812
30813 // 1 byte: depth: 0x00 for master nodes, 0x01 for level-1 descendants, ...
30814 var depth = buffer.readUInt8(4)
30815
30816 // 4 bytes: the fingerprint of the parent's key (0x00000000 if master key)
30817 var parentFingerprint = buffer.readUInt32BE(5)
30818 if (depth === 0) {
30819 assert.strictEqual(parentFingerprint, 0x00000000, 'Invalid parent fingerprint')
30820 }
30821
30822 // 4 bytes: child number. This is the number i in xi = xpar/i, with xi the key being serialized.
30823 // This is encoded in MSB order. (0x00000000 if master key)
30824 var index = buffer.readUInt32BE(9)
30825 assert(depth > 0 || index === 0, 'Invalid index')
30826
30827 // 32 bytes: the chain code
30828 var chainCode = buffer.slice(13, 45)
30829 var hd
30830
30831 // 33 bytes: private key data (0x00 + k)
30832 if (params.isPrivate) {
30833 assert.strictEqual(buffer.readUInt8(45), 0x00, 'Invalid private key')
30834 var data = buffer.slice(46, 78)
30835 var d = BigInteger.fromBuffer(data)
30836 hd = new HDNode(d, chainCode, params.network)
30837
30838 // 33 bytes: public key data (0x02 + X or 0x03 + X)
30839 } else {
30840 var data = buffer.slice(45, 78)
30841 var Q = ecurve.Point.decodeFrom(curve, data)
30842 assert.equal(Q.compressed, true, 'Invalid public key')
30843
30844 // Verify that the X coordinate in the public point corresponds to a point on the curve.
30845 // If not, the extended public key is invalid.
30846 curve.validate(Q)
30847
30848 hd = new HDNode(Q, chainCode, params.network)
30849 }
30850
30851 hd.depth = depth
30852 hd.index = index
30853 hd.parentFingerprint = parentFingerprint
30854
30855 return hd
30856 }
30857
30858 HDNode.fromHex = function(hex) {
30859 return HDNode.fromBuffer(new Buffer(hex, 'hex'))
30860 }
30861
30862 HDNode.prototype.getIdentifier = function() {
30863 return crypto.hash160(this.pubKey.toBuffer())
30864 }
30865
30866 HDNode.prototype.getFingerprint = function() {
30867 return this.getIdentifier().slice(0, 4)
30868 }
30869
30870 HDNode.prototype.getAddress = function() {
30871 return this.pubKey.getAddress(this.network)
30872 }
30873
30874 HDNode.prototype.toBase58 = function(isPrivate) {
30875 return base58check.encode(this.toBuffer(isPrivate))
30876 }
30877
30878 HDNode.prototype.toBuffer = function(isPrivate) {
30879 if (isPrivate == undefined) isPrivate = !!this.privKey
30880
30881 // Version
30882 var version = isPrivate ? this.network.bip32.private : this.network.bip32.public
30883 var buffer = new Buffer(HDNode.LENGTH)
30884
30885 // 4 bytes: version bytes
30886 buffer.writeUInt32BE(version, 0)
30887
30888 // Depth
30889 // 1 byte: depth: 0x00 for master nodes, 0x01 for level-1 descendants, ....
30890 buffer.writeUInt8(this.depth, 4)
30891
30892 // 4 bytes: the fingerprint of the parent's key (0x00000000 if master key)
30893 var fingerprint = (this.depth === 0) ? 0x00000000 : this.parentFingerprint
30894 buffer.writeUInt32BE(fingerprint, 5)
30895
30896 // 4 bytes: child number. This is the number i in xi = xpar/i, with xi the key being serialized.
30897 // This is encoded in Big endian. (0x00000000 if master key)
30898 buffer.writeUInt32BE(this.index, 9)
30899
30900 // 32 bytes: the chain code
30901 this.chainCode.copy(buffer, 13)
30902
30903 // 33 bytes: the public key or private key data
30904 if (isPrivate) {
30905 assert(this.privKey, 'Missing private key')
30906
30907 // 0x00 + k for private keys
30908 buffer.writeUInt8(0, 45)
30909 this.privKey.d.toBuffer(32).copy(buffer, 46)
30910 } else {
30911
30912 // X9.62 encoding for public keys
30913 this.pubKey.toBuffer().copy(buffer, 45)
30914 }
30915
30916 return buffer
30917 }
30918
30919 HDNode.prototype.toHex = function(isPrivate) {
30920 return this.toBuffer(isPrivate).toString('hex')
30921 }
30922
30923 // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#child-key-derivation-ckd-functions
30924 HDNode.prototype.derive = function(index) {
30925 var isHardened = index >= HDNode.HIGHEST_BIT
30926 var indexBuffer = new Buffer(4)
30927 indexBuffer.writeUInt32BE(index, 0)
30928
30929 var data
30930
30931 // Hardened child
30932 if (isHardened) {
30933 assert(this.privKey, 'Could not derive hardened child key')
30934
30935 // data = 0x00 || ser256(kpar) || ser32(index)
30936 data = Buffer.concat([
30937 this.privKey.d.toBuffer(33),
30938 indexBuffer
30939 ])
30940
30941 // Normal child
30942 } else {
30943 // data = serP(point(kpar)) || ser32(index)
30944 // = serP(Kpar) || ser32(index)
30945 data = Buffer.concat([
30946 this.pubKey.toBuffer(),
30947 indexBuffer
30948 ])
30949 }
30950
30951 var I = crypto.HmacSHA512(data, this.chainCode)
30952 var IL = I.slice(0, 32)
30953 var IR = I.slice(32)
30954
30955 var pIL = BigInteger.fromBuffer(IL)
30956
30957 // In case parse256(IL) >= n, proceed with the next value for i
30958 if (pIL.compareTo(curve.n) >= 0) {
30959 return this.derive(index + 1)
30960 }
30961
30962 // Private parent key -> private child key
30963 var hd
30964 if (this.privKey) {
30965 // ki = parse256(IL) + kpar (mod n)
30966 var ki = pIL.add(this.privKey.d).mod(curve.n)
30967
30968 // In case ki == 0, proceed with the next value for i
30969 if (ki.signum() === 0) {
30970 return this.derive(index + 1)
30971 }
30972
30973 hd = new HDNode(ki, IR, this.network)
30974
30975 // Public parent key -> public child key
30976 } else {
30977 // Ki = point(parse256(IL)) + Kpar
30978 // = G*IL + Kpar
30979 var Ki = curve.G.multiply(pIL).add(this.pubKey.Q)
30980
30981 // In case Ki is the point at infinity, proceed with the next value for i
30982 if (curve.isInfinity(Ki)) {
30983 return this.derive(index + 1)
30984 }
30985
30986 hd = new HDNode(Ki, IR, this.network)
30987 }
30988
30989 hd.depth = this.depth + 1
30990 hd.index = index
30991 hd.parentFingerprint = this.getFingerprint().readUInt32BE(0)
30992
30993 return hd
30994 }
30995
30996 HDNode.prototype.deriveHardened = function(index) {
30997 // Only derives hardened private keys by default
30998 return this.derive(index + HDNode.HIGHEST_BIT)
30999 }
31000
31001 HDNode.prototype.toString = HDNode.prototype.toBase58
31002
31003 module.exports = HDNode
31004
31005 }).call(this,_dereq_("buffer").Buffer)
31006 },{"./base58check":70,"./crypto":73,"./eckey":75,"./ecpubkey":76,"./networks":81,"assert":4,"bigi":3,"buffer":8,"ecurve":65}],79:[function(_dereq_,module,exports){
31007 module.exports = {
31008 Address: _dereq_('./address'),
31009 base58check: _dereq_('./base58check'),
31010 bufferutils: _dereq_('./bufferutils'),
31011 convert: _dereq_('./convert'),
31012 crypto: _dereq_('./crypto'),
31013 ecdsa: _dereq_('./ecdsa'),
31014 ECKey: _dereq_('./eckey'),
31015 ECPubKey: _dereq_('./ecpubkey'),
31016 ECSignature: _dereq_('./ecsignature'),
31017 Message: _dereq_('./message'),
31018 opcodes: _dereq_('./opcodes'),
31019 HDNode: _dereq_('./hdnode'),
31020 Script: _dereq_('./script'),
31021 scripts: _dereq_('./scripts'),
31022 Transaction: _dereq_('./transaction'),
31023 networks: _dereq_('./networks'),
31024 Wallet: _dereq_('./wallet')
31025 }
31026
31027 },{"./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){
31028 (function (Buffer){
31029 /// Implements Bitcoin's feature for signing arbitrary messages.
31030 var Address = _dereq_('./address')
31031 var BigInteger = _dereq_('bigi')
31032 var bufferutils = _dereq_('./bufferutils')
31033 var crypto = _dereq_('./crypto')
31034 var ecdsa = _dereq_('./ecdsa')
31035 var networks = _dereq_('./networks')
31036
31037 var Address = _dereq_('./address')
31038 var ECPubKey = _dereq_('./ecpubkey')
31039 var ECSignature = _dereq_('./ecsignature')
31040
31041 var ecurve = _dereq_('ecurve')
31042 var ecparams = ecurve.getCurveByName('secp256k1')
31043
31044 function magicHash(message, network) {
31045 var magicPrefix = new Buffer(network.magicPrefix)
31046 var messageBuffer = new Buffer(message)
31047 var lengthBuffer = new Buffer(bufferutils.varIntSize(messageBuffer.length))
31048 bufferutils.writeVarInt(lengthBuffer, messageBuffer.length, 0)
31049
31050 var buffer = Buffer.concat([magicPrefix, lengthBuffer, messageBuffer])
31051 return crypto.hash256(buffer)
31052 }
31053
31054 function sign(privKey, message, network) {
31055 network = network || networks.bitcoin
31056
31057 var hash = magicHash(message, network)
31058 var signature = privKey.sign(hash)
31059 var e = BigInteger.fromBuffer(hash)
31060 var i = ecdsa.calcPubKeyRecoveryParam(ecparams, e, signature, privKey.pub.Q)
31061
31062 return signature.toCompact(i, privKey.pub.compressed)
31063 }
31064
31065 // TODO: network could be implied from address
31066 function verify(address, signatureBuffer, message, network) {
31067 if (address instanceof Address) {
31068 address = address.toString()
31069 }
31070 network = network || networks.bitcoin
31071
31072 var hash = magicHash(message, network)
31073 var parsed = ECSignature.parseCompact(signatureBuffer)
31074 var e = BigInteger.fromBuffer(hash)
31075 var Q = ecdsa.recoverPubKey(ecparams, e, parsed.signature, parsed.i)
31076
31077 var pubKey = new ECPubKey(Q, parsed.compressed)
31078 return pubKey.getAddress(network).toString() === address
31079 }
31080
31081 module.exports = {
31082 magicHash: magicHash,
31083 sign: sign,
31084 verify: verify
31085 }
31086
31087 }).call(this,_dereq_("buffer").Buffer)
31088 },{"./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){
31089 // https://en.bitcoin.it/wiki/List_of_address_prefixes
31090 // Dogecoin BIP32 is a proposed standard: https://bitcointalk.org/index.php?topic=409731
31091
31092 var networks = {
31093 bitcoin: {
31094 magicPrefix: '\x18Bitcoin Signed Message:\n',
31095 bip32: {
31096 public: 0x0488b21e,
31097 private: 0x0488ade4
31098 },
31099 pubKeyHash: 0x00,
31100 scriptHash: 0x05,
31101 wif: 0x80,
31102 dustThreshold: 546, // https://github.com/bitcoin/bitcoin/blob/v0.9.2/src/core.h#L151-L162
31103 feePerKb: 10000, // https://github.com/bitcoin/bitcoin/blob/v0.9.2/src/main.cpp#L53
31104 estimateFee: estimateFee('bitcoin')
31105 },
31106 dogecoin: {
31107 magicPrefix: '\x19Dogecoin Signed Message:\n',
31108 bip32: {
31109 public: 0x02facafd,
31110 private: 0x02fac398
31111 },
31112 pubKeyHash: 0x1e,
31113 scriptHash: 0x16,
31114 wif: 0x9e,
31115 dustThreshold: 0, // https://github.com/dogecoin/dogecoin/blob/v1.7.1/src/core.h#L155-L160
31116 dustSoftThreshold: 100000000, // https://github.com/dogecoin/dogecoin/blob/v1.7.1/src/main.h#L62
31117 feePerKb: 100000000, // https://github.com/dogecoin/dogecoin/blob/v1.7.1/src/main.cpp#L58
31118 estimateFee: estimateFee('dogecoin')
31119 },
31120 litecoin: {
31121 magicPrefix: '\x19Litecoin Signed Message:\n',
31122 bip32: {
31123 public: 0x019da462,
31124 private: 0x019d9cfe
31125 },
31126 pubKeyHash: 0x30,
31127 scriptHash: 0x05,
31128 wif: 0xb0,
31129 dustThreshold: 0, // https://github.com/litecoin-project/litecoin/blob/v0.8.7.2/src/main.cpp#L360-L365
31130 dustSoftThreshold: 100000, // https://github.com/litecoin-project/litecoin/blob/v0.8.7.2/src/main.h#L53
31131 feePerKb: 100000, // https://github.com/litecoin-project/litecoin/blob/v0.8.7.2/src/main.cpp#L56
31132 estimateFee: estimateFee('litecoin')
31133 },
31134 testnet: {
31135 magicPrefix: '\x18Bitcoin Signed Message:\n',
31136 bip32: {
31137 public: 0x043587cf,
31138 private: 0x04358394
31139 },
31140 pubKeyHash: 0x6f,
31141 scriptHash: 0xc4,
31142 wif: 0xef,
31143 dustThreshold: 546,
31144 feePerKb: 10000,
31145 estimateFee: estimateFee('testnet')
31146 }
31147 }
31148
31149 function estimateFee(type) {
31150 return function(tx) {
31151 var network = networks[type]
31152 var baseFee = network.feePerKb
31153 var byteSize = tx.toBuffer().length
31154
31155 var fee = baseFee * Math.ceil(byteSize / 1000)
31156 if (network.dustSoftThreshold == undefined) return fee
31157
31158 tx.outs.forEach(function(e){
31159 if (e.value < network.dustSoftThreshold) {
31160 fee += baseFee
31161 }
31162 })
31163
31164 return fee
31165 }
31166 }
31167
31168 module.exports = networks
31169
31170 },{}],82:[function(_dereq_,module,exports){
31171 module.exports = {
31172 // push value
31173 OP_FALSE : 0,
31174 OP_0 : 0,
31175 OP_PUSHDATA1 : 76,
31176 OP_PUSHDATA2 : 77,
31177 OP_PUSHDATA4 : 78,
31178 OP_1NEGATE : 79,
31179 OP_RESERVED : 80,
31180 OP_1 : 81,
31181 OP_TRUE : 81,
31182 OP_2 : 82,
31183 OP_3 : 83,
31184 OP_4 : 84,
31185 OP_5 : 85,
31186 OP_6 : 86,
31187 OP_7 : 87,
31188 OP_8 : 88,
31189 OP_9 : 89,
31190 OP_10 : 90,
31191 OP_11 : 91,
31192 OP_12 : 92,
31193 OP_13 : 93,
31194 OP_14 : 94,
31195 OP_15 : 95,
31196 OP_16 : 96,
31197
31198 // control
31199 OP_NOP : 97,
31200 OP_VER : 98,
31201 OP_IF : 99,
31202 OP_NOTIF : 100,
31203 OP_VERIF : 101,
31204 OP_VERNOTIF : 102,
31205 OP_ELSE : 103,
31206 OP_ENDIF : 104,
31207 OP_VERIFY : 105,
31208 OP_RETURN : 106,
31209
31210 // stack ops
31211 OP_TOALTSTACK : 107,
31212 OP_FROMALTSTACK : 108,
31213 OP_2DROP : 109,
31214 OP_2DUP : 110,
31215 OP_3DUP : 111,
31216 OP_2OVER : 112,
31217 OP_2ROT : 113,
31218 OP_2SWAP : 114,
31219 OP_IFDUP : 115,
31220 OP_DEPTH : 116,
31221 OP_DROP : 117,
31222 OP_DUP : 118,
31223 OP_NIP : 119,
31224 OP_OVER : 120,
31225 OP_PICK : 121,
31226 OP_ROLL : 122,
31227 OP_ROT : 123,
31228 OP_SWAP : 124,
31229 OP_TUCK : 125,
31230
31231 // splice ops
31232 OP_CAT : 126,
31233 OP_SUBSTR : 127,
31234 OP_LEFT : 128,
31235 OP_RIGHT : 129,
31236 OP_SIZE : 130,
31237
31238 // bit logic
31239 OP_INVERT : 131,
31240 OP_AND : 132,
31241 OP_OR : 133,
31242 OP_XOR : 134,
31243 OP_EQUAL : 135,
31244 OP_EQUALVERIFY : 136,
31245 OP_RESERVED1 : 137,
31246 OP_RESERVED2 : 138,
31247
31248 // numeric
31249 OP_1ADD : 139,
31250 OP_1SUB : 140,
31251 OP_2MUL : 141,
31252 OP_2DIV : 142,
31253 OP_NEGATE : 143,
31254 OP_ABS : 144,
31255 OP_NOT : 145,
31256 OP_0NOTEQUAL : 146,
31257
31258 OP_ADD : 147,
31259 OP_SUB : 148,
31260 OP_MUL : 149,
31261 OP_DIV : 150,
31262 OP_MOD : 151,
31263 OP_LSHIFT : 152,
31264 OP_RSHIFT : 153,
31265
31266 OP_BOOLAND : 154,
31267 OP_BOOLOR : 155,
31268 OP_NUMEQUAL : 156,
31269 OP_NUMEQUALVERIFY : 157,
31270 OP_NUMNOTEQUAL : 158,
31271 OP_LESSTHAN : 159,
31272 OP_GREATERTHAN : 160,
31273 OP_LESSTHANOREQUAL : 161,
31274 OP_GREATERTHANOREQUAL : 162,
31275 OP_MIN : 163,
31276 OP_MAX : 164,
31277
31278 OP_WITHIN : 165,
31279
31280 // crypto
31281 OP_RIPEMD160 : 166,
31282 OP_SHA1 : 167,
31283 OP_SHA256 : 168,
31284 OP_HASH160 : 169,
31285 OP_HASH256 : 170,
31286 OP_CODESEPARATOR : 171,
31287 OP_CHECKSIG : 172,
31288 OP_CHECKSIGVERIFY : 173,
31289 OP_CHECKMULTISIG : 174,
31290 OP_CHECKMULTISIGVERIFY : 175,
31291
31292 // expansion
31293 OP_NOP1 : 176,
31294 OP_NOP2 : 177,
31295 OP_NOP3 : 178,
31296 OP_NOP4 : 179,
31297 OP_NOP5 : 180,
31298 OP_NOP6 : 181,
31299 OP_NOP7 : 182,
31300 OP_NOP8 : 183,
31301 OP_NOP9 : 184,
31302 OP_NOP10 : 185,
31303
31304 // template matching params
31305 OP_PUBKEYHASH : 253,
31306 OP_PUBKEY : 254,
31307 OP_INVALIDOPCODE : 255
31308 }
31309
31310 },{}],83:[function(_dereq_,module,exports){
31311 (function (Buffer){
31312 var assert = _dereq_('assert')
31313 var bufferutils = _dereq_('./bufferutils')
31314 var crypto = _dereq_('./crypto')
31315 var opcodes = _dereq_('./opcodes')
31316
31317 function Script(buffer, chunks) {
31318 assert(Buffer.isBuffer(buffer), 'Expected Buffer, got ' + buffer)
31319 assert(Array.isArray(chunks), 'Expected Array, got ' + chunks)
31320
31321 this.buffer = buffer
31322 this.chunks = chunks
31323 }
31324
31325 // Import operations
31326 Script.fromASM = function(asm) {
31327 var strChunks = asm.split(' ')
31328
31329 var chunks = strChunks.map(function(strChunk) {
31330 if (strChunk in opcodes) {
31331 return opcodes[strChunk]
31332
31333 } else {
31334 return new Buffer(strChunk, 'hex')
31335 }
31336 })
31337
31338 return Script.fromChunks(chunks)
31339 }
31340
31341 Script.fromBuffer = function(buffer) {
31342 var chunks = []
31343
31344 var i = 0
31345
31346 while (i < buffer.length) {
31347 var opcode = buffer.readUInt8(i)
31348
31349 if ((opcode > opcodes.OP_0) && (opcode <= opcodes.OP_PUSHDATA4)) {
31350 var d = bufferutils.readPushDataInt(buffer, i)
31351 i += d.size
31352
31353 var data = buffer.slice(i, i + d.number)
31354 i += d.number
31355
31356 chunks.push(data)
31357
31358 } else {
31359 chunks.push(opcode)
31360
31361 i += 1
31362 }
31363 }
31364
31365 return new Script(buffer, chunks)
31366 }
31367
31368 Script.fromChunks = function(chunks) {
31369 assert(Array.isArray(chunks), 'Expected Array, got ' + chunks)
31370
31371 var bufferSize = chunks.reduce(function(accum, chunk) {
31372 if (Buffer.isBuffer(chunk)) {
31373 return accum + bufferutils.pushDataSize(chunk.length) + chunk.length
31374 }
31375
31376 return accum + 1
31377 }, 0.0)
31378
31379 var buffer = new Buffer(bufferSize)
31380 var offset = 0
31381
31382 chunks.forEach(function(chunk) {
31383 if (Buffer.isBuffer(chunk)) {
31384 offset += bufferutils.writePushDataInt(buffer, chunk.length, offset)
31385
31386 chunk.copy(buffer, offset)
31387 offset += chunk.length
31388
31389 } else {
31390 buffer.writeUInt8(chunk, offset)
31391 offset += 1
31392 }
31393 })
31394
31395 assert.equal(offset, buffer.length, 'Could not decode chunks')
31396 return new Script(buffer, chunks)
31397 }
31398
31399 Script.fromHex = function(hex) {
31400 return Script.fromBuffer(new Buffer(hex, 'hex'))
31401 }
31402
31403 // Constants
31404 Script.EMPTY = Script.fromChunks([])
31405
31406 // Operations
31407 Script.prototype.getHash = function() {
31408 return crypto.hash160(this.buffer)
31409 }
31410
31411 // FIXME: doesn't work for data chunks, maybe time to use buffertools.compare...
31412 Script.prototype.without = function(needle) {
31413 return Script.fromChunks(this.chunks.filter(function(op) {
31414 return op !== needle
31415 }))
31416 }
31417
31418 // Export operations
31419 var reverseOps = []
31420 for (var op in opcodes) {
31421 var code = opcodes[op]
31422 reverseOps[code] = op
31423 }
31424
31425 Script.prototype.toASM = function() {
31426 return this.chunks.map(function(chunk) {
31427 if (Buffer.isBuffer(chunk)) {
31428 return chunk.toString('hex')
31429
31430 } else {
31431 return reverseOps[chunk]
31432 }
31433 }).join(' ')
31434 }
31435
31436 Script.prototype.toBuffer = function() {
31437 return this.buffer
31438 }
31439
31440 Script.prototype.toHex = function() {
31441 return this.toBuffer().toString('hex')
31442 }
31443
31444 module.exports = Script
31445
31446 }).call(this,_dereq_("buffer").Buffer)
31447 },{"./bufferutils":71,"./crypto":73,"./opcodes":82,"assert":4,"buffer":8}],84:[function(_dereq_,module,exports){
31448 (function (Buffer){
31449 var assert = _dereq_('assert')
31450 var opcodes = _dereq_('./opcodes')
31451
31452 // FIXME: use ECPubKey, currently the circular dependency breaks everything.
31453 //
31454 // Solutions:
31455 // * Remove ECPubKey.getAddress
31456 // - Minimal change, but likely unpopular
31457 // * Move all script related functionality out of Address
31458 // - Means a lot of changes to Transaction/Wallet
31459 // * Ignore it (existing solution)
31460 // * Some form of hackery with commonjs
31461 //
31462 var ecurve = _dereq_('ecurve')
31463 var curve = ecurve.getCurveByName('secp256k1')
31464
31465 var ECSignature = _dereq_('./ecsignature')
31466 var Script = _dereq_('./script')
31467
31468 function classifyOutput(script) {
31469 assert(script instanceof Script, 'Expected Script, got ', script)
31470
31471 if (isPubKeyHashOutput.call(script)) {
31472 return 'pubkeyhash'
31473 } else if (isScriptHashOutput.call(script)) {
31474 return 'scripthash'
31475 } else if (isMultisigOutput.call(script)) {
31476 return 'multisig'
31477 } else if (isPubKeyOutput.call(script)) {
31478 return 'pubkey'
31479 } else if (isNulldataOutput.call(script)) {
31480 return 'nulldata'
31481 } else {
31482 return 'nonstandard'
31483 }
31484 }
31485
31486 function classifyInput(script) {
31487 assert(script instanceof Script, 'Expected Script, got ', script)
31488
31489 if (isPubKeyHashInput.call(script)) {
31490 return 'pubkeyhash'
31491 } else if (isScriptHashInput.call(script)) {
31492 return 'scripthash'
31493 } else if (isMultisigInput.call(script)) {
31494 return 'multisig'
31495 } else if (isPubKeyInput.call(script)) {
31496 return 'pubkey'
31497 } else {
31498 return 'nonstandard'
31499 }
31500 }
31501
31502 function isCanonicalPubKey(buffer) {
31503 if (!Buffer.isBuffer(buffer)) return false
31504
31505 try {
31506 // FIXME: boo
31507 ecurve.Point.decodeFrom(curve, buffer)
31508 } catch (e) {
31509 if (!(e.message.match(/Invalid sequence (length|tag)/))) throw e
31510
31511 return false
31512 }
31513
31514 return true
31515 }
31516
31517 function isCanonicalSignature(buffer) {
31518 if (!Buffer.isBuffer(buffer)) return false
31519
31520 try {
31521 ECSignature.parseScriptSignature(buffer)
31522 } catch(e) {
31523 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
31524
31525 return false
31526 }
31527
31528 return true
31529 }
31530
31531 function isPubKeyHashInput() {
31532 return this.chunks.length === 2 &&
31533 isCanonicalSignature(this.chunks[0]) &&
31534 isCanonicalPubKey(this.chunks[1])
31535 }
31536
31537 function isPubKeyHashOutput() {
31538 return this.chunks.length === 5 &&
31539 this.chunks[0] === opcodes.OP_DUP &&
31540 this.chunks[1] === opcodes.OP_HASH160 &&
31541 Buffer.isBuffer(this.chunks[2]) &&
31542 this.chunks[2].length === 20 &&
31543 this.chunks[3] === opcodes.OP_EQUALVERIFY &&
31544 this.chunks[4] === opcodes.OP_CHECKSIG
31545 }
31546
31547 function isPubKeyInput() {
31548 return this.chunks.length === 1 &&
31549 isCanonicalSignature(this.chunks[0])
31550 }
31551
31552 function isPubKeyOutput() {
31553 return this.chunks.length === 2 &&
31554 isCanonicalPubKey(this.chunks[0]) &&
31555 this.chunks[1] === opcodes.OP_CHECKSIG
31556 }
31557
31558 function isScriptHashInput() {
31559 if (this.chunks.length < 2) return false
31560 var lastChunk = this.chunks[this.chunks.length - 1]
31561
31562 if (!Buffer.isBuffer(lastChunk)) return false
31563
31564 var scriptSig = Script.fromChunks(this.chunks.slice(0, -1))
31565 var scriptPubKey = Script.fromBuffer(lastChunk)
31566
31567 return classifyInput(scriptSig) === classifyOutput(scriptPubKey)
31568 }
31569
31570 function isScriptHashOutput() {
31571 return this.chunks.length === 3 &&
31572 this.chunks[0] === opcodes.OP_HASH160 &&
31573 Buffer.isBuffer(this.chunks[1]) &&
31574 this.chunks[1].length === 20 &&
31575 this.chunks[2] === opcodes.OP_EQUAL
31576 }
31577
31578 function isMultisigInput() {
31579 return this.chunks[0] === opcodes.OP_0 &&
31580 this.chunks.slice(1).every(isCanonicalSignature)
31581 }
31582
31583 function isMultisigOutput() {
31584 if (this.chunks < 4) return false
31585 if (this.chunks[this.chunks.length - 1] !== opcodes.OP_CHECKMULTISIG) return false
31586
31587 var mOp = this.chunks[0]
31588 if (mOp === opcodes.OP_0) return false
31589 if (mOp < opcodes.OP_1) return false
31590 if (mOp > opcodes.OP_16) return false
31591
31592 var nOp = this.chunks[this.chunks.length - 2]
31593 if (nOp === opcodes.OP_0) return false
31594 if (nOp < opcodes.OP_1) return false
31595 if (nOp > opcodes.OP_16) return false
31596
31597 var m = mOp - (opcodes.OP_1 - 1)
31598 var n = nOp - (opcodes.OP_1 - 1)
31599 if (n < m) return false
31600
31601 var pubKeys = this.chunks.slice(1, -2)
31602 if (n < pubKeys.length) return false
31603
31604 return pubKeys.every(isCanonicalPubKey)
31605 }
31606
31607 function isNulldataOutput() {
31608 return this.chunks[0] === opcodes.OP_RETURN
31609 }
31610
31611 // Standard Script Templates
31612 // {pubKey} OP_CHECKSIG
31613 function pubKeyOutput(pubKey) {
31614 return Script.fromChunks([
31615 pubKey.toBuffer(),
31616 opcodes.OP_CHECKSIG
31617 ])
31618 }
31619
31620 // OP_DUP OP_HASH160 {pubKeyHash} OP_EQUALVERIFY OP_CHECKSIG
31621 function pubKeyHashOutput(hash) {
31622 assert(Buffer.isBuffer(hash), 'Expected Buffer, got ' + hash)
31623
31624 return Script.fromChunks([
31625 opcodes.OP_DUP,
31626 opcodes.OP_HASH160,
31627 hash,
31628 opcodes.OP_EQUALVERIFY,
31629 opcodes.OP_CHECKSIG
31630 ])
31631 }
31632
31633 // OP_HASH160 {scriptHash} OP_EQUAL
31634 function scriptHashOutput(hash) {
31635 assert(Buffer.isBuffer(hash), 'Expected Buffer, got ' + hash)
31636
31637 return Script.fromChunks([
31638 opcodes.OP_HASH160,
31639 hash,
31640 opcodes.OP_EQUAL
31641 ])
31642 }
31643
31644 // m [pubKeys ...] n OP_CHECKMULTISIG
31645 function multisigOutput(m, pubKeys) {
31646 assert(Array.isArray(pubKeys), 'Expected Array, got ' + pubKeys)
31647 assert(pubKeys.length >= m, 'Not enough pubKeys provided')
31648
31649 var pubKeyBuffers = pubKeys.map(function(pubKey) {
31650 return pubKey.toBuffer()
31651 })
31652 var n = pubKeys.length
31653
31654 return Script.fromChunks([].concat(
31655 (opcodes.OP_1 - 1) + m,
31656 pubKeyBuffers,
31657 (opcodes.OP_1 - 1) + n,
31658 opcodes.OP_CHECKMULTISIG
31659 ))
31660 }
31661
31662 // {signature}
31663 function pubKeyInput(signature) {
31664 assert(Buffer.isBuffer(signature), 'Expected Buffer, got ' + signature)
31665
31666 return Script.fromChunks([signature])
31667 }
31668
31669 // {signature} {pubKey}
31670 function pubKeyHashInput(signature, pubKey) {
31671 assert(Buffer.isBuffer(signature), 'Expected Buffer, got ' + signature)
31672
31673 return Script.fromChunks([signature, pubKey.toBuffer()])
31674 }
31675
31676 // <scriptSig> {serialized scriptPubKey script}
31677 function scriptHashInput(scriptSig, scriptPubKey) {
31678 return Script.fromChunks([].concat(
31679 scriptSig.chunks,
31680 scriptPubKey.toBuffer()
31681 ))
31682 }
31683
31684 // OP_0 [signatures ...]
31685 function multisigInput(signatures, scriptPubKey) {
31686 if (scriptPubKey) {
31687 assert(isMultisigOutput.call(scriptPubKey))
31688
31689 var m = scriptPubKey.chunks[0]
31690 var k = m - (opcodes.OP_1 - 1)
31691 assert(k <= signatures.length, 'Not enough signatures provided')
31692 }
31693
31694 return Script.fromChunks([].concat(opcodes.OP_0, signatures))
31695 }
31696
31697 module.exports = {
31698 classifyInput: classifyInput,
31699 classifyOutput: classifyOutput,
31700 multisigInput: multisigInput,
31701 multisigOutput: multisigOutput,
31702 pubKeyHashInput: pubKeyHashInput,
31703 pubKeyHashOutput: pubKeyHashOutput,
31704 pubKeyInput: pubKeyInput,
31705 pubKeyOutput: pubKeyOutput,
31706 scriptHashInput: scriptHashInput,
31707 scriptHashOutput: scriptHashOutput
31708 }
31709
31710 }).call(this,_dereq_("buffer").Buffer)
31711 },{"./ecsignature":77,"./opcodes":82,"./script":83,"assert":4,"buffer":8,"ecurve":65}],85:[function(_dereq_,module,exports){
31712 (function (Buffer){
31713 var assert = _dereq_('assert')
31714 var bufferutils = _dereq_('./bufferutils')
31715 var crypto = _dereq_('./crypto')
31716 var opcodes = _dereq_('./opcodes')
31717 var scripts = _dereq_('./scripts')
31718
31719 var Address = _dereq_('./address')
31720 var ECKey = _dereq_('./eckey')
31721 var ECSignature = _dereq_('./ecsignature')
31722 var Script = _dereq_('./script')
31723
31724 Transaction.DEFAULT_SEQUENCE = 0xffffffff
31725 Transaction.SIGHASH_ALL = 0x01
31726 Transaction.SIGHASH_NONE = 0x02
31727 Transaction.SIGHASH_SINGLE = 0x03
31728 Transaction.SIGHASH_ANYONECANPAY = 0x80
31729
31730 function Transaction() {
31731 this.version = 1
31732 this.locktime = 0
31733 this.ins = []
31734 this.outs = []
31735 }
31736
31737 /**
31738 * Create a new txin.
31739 *
31740 * Can be called with any of:
31741 *
31742 * - A transaction and an index
31743 * - A transaction hash and an index
31744 *
31745 * Note that this method does not sign the created input.
31746 */
31747 Transaction.prototype.addInput = function(tx, index, sequence) {
31748 if (sequence == undefined) sequence = Transaction.DEFAULT_SEQUENCE
31749
31750 var hash
31751
31752 if (typeof tx === 'string') {
31753 hash = new Buffer(tx, 'hex')
31754
31755 // TxId hex is big-endian, we need little-endian
31756 Array.prototype.reverse.call(hash)
31757
31758 } else if (tx instanceof Transaction) {
31759 hash = tx.getHash()
31760
31761 } else {
31762 hash = tx
31763 }
31764
31765 assert(Buffer.isBuffer(hash), 'Expected Transaction, txId or txHash, got ' + tx)
31766 assert.equal(hash.length, 32, 'Expected hash length of 32, got ' + hash.length)
31767 assert.equal(typeof index, 'number', 'Expected number index, got ' + index)
31768
31769 return (this.ins.push({
31770 hash: hash,
31771 index: index,
31772 script: Script.EMPTY,
31773 sequence: sequence
31774 }) - 1)
31775 }
31776
31777 /**
31778 * Create a new txout.
31779 *
31780 * Can be called with:
31781 *
31782 * - A base58 address string and a value
31783 * - An Address object and a value
31784 * - A scriptPubKey Script and a value
31785 */
31786 Transaction.prototype.addOutput = function(scriptPubKey, value) {
31787 // Attempt to get a valid address if it's a base58 address string
31788 if (typeof scriptPubKey === 'string') {
31789 scriptPubKey = Address.fromBase58Check(scriptPubKey)
31790 }
31791
31792 // Attempt to get a valid script if it's an Address object
31793 if (scriptPubKey instanceof Address) {
31794 var address = scriptPubKey
31795
31796 scriptPubKey = address.toOutputScript()
31797 }
31798
31799 return (this.outs.push({
31800 script: scriptPubKey,
31801 value: value,
31802 }) - 1)
31803 }
31804
31805 Transaction.prototype.toBuffer = function () {
31806 var txInSize = this.ins.reduce(function(a, x) {
31807 return a + (40 + bufferutils.varIntSize(x.script.buffer.length) + x.script.buffer.length)
31808 }, 0)
31809
31810 var txOutSize = this.outs.reduce(function(a, x) {
31811 return a + (8 + bufferutils.varIntSize(x.script.buffer.length) + x.script.buffer.length)
31812 }, 0)
31813
31814 var buffer = new Buffer(
31815 8 +
31816 bufferutils.varIntSize(this.ins.length) +
31817 bufferutils.varIntSize(this.outs.length) +
31818 txInSize +
31819 txOutSize
31820 )
31821
31822 var offset = 0
31823 function writeSlice(slice) {
31824 slice.copy(buffer, offset)
31825 offset += slice.length
31826 }
31827 function writeUInt32(i) {
31828 buffer.writeUInt32LE(i, offset)
31829 offset += 4
31830 }
31831 function writeUInt64(i) {
31832 bufferutils.writeUInt64LE(buffer, i, offset)
31833 offset += 8
31834 }
31835 function writeVarInt(i) {
31836 var n = bufferutils.writeVarInt(buffer, i, offset)
31837 offset += n
31838 }
31839
31840 writeUInt32(this.version)
31841 writeVarInt(this.ins.length)
31842
31843 this.ins.forEach(function(txin) {
31844 writeSlice(txin.hash)
31845 writeUInt32(txin.index)
31846 writeVarInt(txin.script.buffer.length)
31847 writeSlice(txin.script.buffer)
31848 writeUInt32(txin.sequence)
31849 })
31850
31851 writeVarInt(this.outs.length)
31852 this.outs.forEach(function(txout) {
31853 writeUInt64(txout.value)
31854 writeVarInt(txout.script.buffer.length)
31855 writeSlice(txout.script.buffer)
31856 })
31857
31858 writeUInt32(this.locktime)
31859
31860 return buffer
31861 }
31862
31863 Transaction.prototype.toHex = function() {
31864 return this.toBuffer().toString('hex')
31865 }
31866
31867 /**
31868 * Hash transaction for signing a specific input.
31869 *
31870 * Bitcoin uses a different hash for each signed transaction input. This
31871 * method copies the transaction, makes the necessary changes based on the
31872 * hashType, serializes and finally hashes the result. This hash can then be
31873 * used to sign the transaction input in question.
31874 */
31875 Transaction.prototype.hashForSignature = function(prevOutScript, inIndex, hashType) {
31876 assert(inIndex >= 0, 'Invalid vin index')
31877 assert(inIndex < this.ins.length, 'Invalid vin index')
31878 assert(prevOutScript instanceof Script, 'Invalid Script object')
31879
31880 var txTmp = this.clone()
31881 var hashScript = prevOutScript.without(opcodes.OP_CODESEPARATOR)
31882
31883 // Blank out other inputs' signatures
31884 txTmp.ins.forEach(function(txin) {
31885 txin.script = Script.EMPTY
31886 })
31887 txTmp.ins[inIndex].script = hashScript
31888
31889 var hashTypeModifier = hashType & 0x1f
31890 if (hashTypeModifier === Transaction.SIGHASH_NONE) {
31891 assert(false, 'SIGHASH_NONE not yet supported')
31892
31893 } else if (hashTypeModifier === Transaction.SIGHASH_SINGLE) {
31894 assert(false, 'SIGHASH_SINGLE not yet supported')
31895
31896 }
31897
31898 if (hashType & Transaction.SIGHASH_ANYONECANPAY) {
31899 assert(false, 'SIGHASH_ANYONECANPAY not yet supported')
31900 }
31901
31902 var hashTypeBuffer = new Buffer(4)
31903 hashTypeBuffer.writeInt32LE(hashType, 0)
31904
31905 var buffer = Buffer.concat([txTmp.toBuffer(), hashTypeBuffer])
31906 return crypto.hash256(buffer)
31907 }
31908
31909 Transaction.prototype.getHash = function () {
31910 return crypto.hash256(this.toBuffer())
31911 }
31912
31913 Transaction.prototype.getId = function () {
31914 var buffer = this.getHash()
31915
31916 // Big-endian is used for TxHash
31917 Array.prototype.reverse.call(buffer)
31918
31919 return buffer.toString('hex')
31920 }
31921
31922 Transaction.prototype.clone = function () {
31923 var newTx = new Transaction()
31924 newTx.version = this.version
31925 newTx.locktime = this.locktime
31926
31927 newTx.ins = this.ins.map(function(txin) {
31928 return {
31929 hash: txin.hash,
31930 index: txin.index,
31931 script: txin.script,
31932 sequence: txin.sequence
31933 }
31934 })
31935
31936 newTx.outs = this.outs.map(function(txout) {
31937 return {
31938 script: txout.script,
31939 value: txout.value
31940 }
31941 })
31942
31943 return newTx
31944 }
31945
31946 Transaction.fromBuffer = function(buffer) {
31947 var offset = 0
31948 function readSlice(n) {
31949 offset += n
31950 return buffer.slice(offset - n, offset)
31951 }
31952 function readUInt32() {
31953 var i = buffer.readUInt32LE(offset)
31954 offset += 4
31955 return i
31956 }
31957 function readUInt64() {
31958 var i = bufferutils.readUInt64LE(buffer, offset)
31959 offset += 8
31960 return i
31961 }
31962 function readVarInt() {
31963 var vi = bufferutils.readVarInt(buffer, offset)
31964 offset += vi.size
31965 return vi.number
31966 }
31967
31968 var tx = new Transaction()
31969 tx.version = readUInt32()
31970
31971 var vinLen = readVarInt()
31972 for (var i = 0; i < vinLen; ++i) {
31973 var hash = readSlice(32)
31974 var vout = readUInt32()
31975 var scriptLen = readVarInt()
31976 var script = readSlice(scriptLen)
31977 var sequence = readUInt32()
31978
31979 tx.ins.push({
31980 hash: hash,
31981 index: vout,
31982 script: Script.fromBuffer(script),
31983 sequence: sequence
31984 })
31985 }
31986
31987 var voutLen = readVarInt()
31988 for (i = 0; i < voutLen; ++i) {
31989 var value = readUInt64()
31990 var scriptLen = readVarInt()
31991 var script = readSlice(scriptLen)
31992
31993 tx.outs.push({
31994 value: value,
31995 script: Script.fromBuffer(script)
31996 })
31997 }
31998
31999 tx.locktime = readUInt32()
32000 assert.equal(offset, buffer.length, 'Transaction has unexpected data')
32001
32002 return tx
32003 }
32004
32005 Transaction.fromHex = function(hex) {
32006 return Transaction.fromBuffer(new Buffer(hex, 'hex'))
32007 }
32008
32009 /**
32010 * Signs a pubKeyHash output at some index with the given key
32011 */
32012 Transaction.prototype.sign = function(index, privKey, hashType) {
32013 var prevOutScript = privKey.pub.getAddress().toOutputScript()
32014 var signature = this.signInput(index, prevOutScript, privKey, hashType)
32015
32016 // FIXME: Assumed prior TX was pay-to-pubkey-hash
32017 var scriptSig = scripts.pubKeyHashInput(signature, privKey.pub)
32018 this.setInputScript(index, scriptSig)
32019 }
32020
32021 Transaction.prototype.signInput = function(index, prevOutScript, privKey, hashType) {
32022 hashType = hashType || Transaction.SIGHASH_ALL
32023
32024 var hash = this.hashForSignature(prevOutScript, index, hashType)
32025 var signature = privKey.sign(hash)
32026
32027 return signature.toScriptSignature(hashType)
32028 }
32029
32030 Transaction.prototype.setInputScript = function(index, script) {
32031 this.ins[index].script = script
32032 }
32033
32034 // FIXME: could be validateInput(index, prevTxOut, pub)
32035 Transaction.prototype.validateInput = function(index, prevOutScript, pubKey, buffer) {
32036 var parsed = ECSignature.parseScriptSignature(buffer)
32037 var hash = this.hashForSignature(prevOutScript, index, parsed.hashType)
32038
32039 return pubKey.verify(hash, parsed.signature)
32040 }
32041
32042 module.exports = Transaction
32043
32044 }).call(this,_dereq_("buffer").Buffer)
32045 },{"./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){
32046 (function (Buffer){
32047 var assert = _dereq_('assert')
32048 var networks = _dereq_('./networks')
32049 var rng = _dereq_('secure-random')
32050
32051 var Address = _dereq_('./address')
32052 var HDNode = _dereq_('./hdnode')
32053 var Transaction = _dereq_('./transaction')
32054
32055 function Wallet(seed, network) {
32056 network = network || networks.bitcoin
32057
32058 // Stored in a closure to make accidental serialization less likely
32059 var masterkey = null
32060 var me = this
32061 var accountZero = null
32062 var internalAccount = null
32063 var externalAccount = null
32064
32065 // Addresses
32066 this.addresses = []
32067 this.changeAddresses = []
32068
32069 // Transaction output data
32070 this.outputs = {}
32071
32072 // Make a new master key
32073 this.newMasterKey = function(seed) {
32074 seed = seed || new Buffer(rng(32))
32075 masterkey = HDNode.fromSeedBuffer(seed, network)
32076
32077 // HD first-level child derivation method should be hardened
32078 // See https://bitcointalk.org/index.php?topic=405179.msg4415254#msg4415254
32079 accountZero = masterkey.deriveHardened(0)
32080 externalAccount = accountZero.derive(0)
32081 internalAccount = accountZero.derive(1)
32082
32083 me.addresses = []
32084 me.changeAddresses = []
32085
32086 me.outputs = {}
32087 }
32088
32089 this.newMasterKey(seed)
32090
32091 this.generateAddress = function() {
32092 var key = externalAccount.derive(this.addresses.length)
32093 this.addresses.push(key.getAddress().toString())
32094 return this.addresses[this.addresses.length - 1]
32095 }
32096
32097 this.generateChangeAddress = function() {
32098 var key = internalAccount.derive(this.changeAddresses.length)
32099 this.changeAddresses.push(key.getAddress().toString())
32100 return this.changeAddresses[this.changeAddresses.length - 1]
32101 }
32102
32103 this.getBalance = function() {
32104 return this.getUnspentOutputs().reduce(function(memo, output){
32105 return memo + output.value
32106 }, 0)
32107 }
32108
32109 this.getUnspentOutputs = function() {
32110 var utxo = []
32111
32112 for(var key in this.outputs){
32113 var output = this.outputs[key]
32114 if(!output.to) utxo.push(outputToUnspentOutput(output))
32115 }
32116
32117 return utxo
32118 }
32119
32120 this.setUnspentOutputs = function(utxo) {
32121 var outputs = {}
32122
32123 utxo.forEach(function(uo){
32124 validateUnspentOutput(uo)
32125 var o = unspentOutputToOutput(uo)
32126 outputs[o.from] = o
32127 })
32128
32129 this.outputs = outputs
32130 }
32131
32132 function outputToUnspentOutput(output){
32133 var hashAndIndex = output.from.split(":")
32134
32135 return {
32136 hash: hashAndIndex[0],
32137 outputIndex: parseInt(hashAndIndex[1]),
32138 address: output.address,
32139 value: output.value,
32140 pending: output.pending
32141 }
32142 }
32143
32144 function unspentOutputToOutput(o) {
32145 var hash = o.hash
32146 var key = hash + ":" + o.outputIndex
32147 return {
32148 from: key,
32149 address: o.address,
32150 value: o.value,
32151 pending: o.pending
32152 }
32153 }
32154
32155 function validateUnspentOutput(uo) {
32156 var missingField
32157
32158 if (isNullOrUndefined(uo.hash)) {
32159 missingField = "hash"
32160 }
32161
32162 var requiredKeys = ['outputIndex', 'address', 'value']
32163 requiredKeys.forEach(function (key) {
32164 if (isNullOrUndefined(uo[key])){
32165 missingField = key
32166 }
32167 })
32168
32169 if (missingField) {
32170 var message = [
32171 'Invalid unspent output: key', missingField, 'is missing.',
32172 'A valid unspent output must contain'
32173 ]
32174 message.push(requiredKeys.join(', '))
32175 message.push("and hash")
32176 throw new Error(message.join(' '))
32177 }
32178 }
32179
32180 function isNullOrUndefined(value) {
32181 return value == undefined
32182 }
32183
32184 this.processPendingTx = function(tx){
32185 processTx(tx, true)
32186 }
32187
32188 this.processConfirmedTx = function(tx){
32189 processTx(tx, false)
32190 }
32191
32192 function processTx(tx, isPending) {
32193 var txid = tx.getId()
32194
32195 tx.outs.forEach(function(txOut, i) {
32196 var address
32197
32198 try {
32199 address = Address.fromOutputScript(txOut.script, network).toString()
32200 } catch(e) {
32201 if (!(e.message.match(/has no matching Address/))) throw e
32202 }
32203
32204 if (isMyAddress(address)) {
32205 var output = txid + ':' + i
32206
32207 me.outputs[output] = {
32208 from: output,
32209 value: txOut.value,
32210 address: address,
32211 pending: isPending
32212 }
32213 }
32214 })
32215
32216 tx.ins.forEach(function(txIn, i) {
32217 // copy and convert to big-endian hex
32218 var txinId = new Buffer(txIn.hash)
32219 Array.prototype.reverse.call(txinId)
32220 txinId = txinId.toString('hex')
32221
32222 var output = txinId + ':' + txIn.index
32223
32224 if (!(output in me.outputs)) return
32225
32226 if (isPending) {
32227 me.outputs[output].to = txid + ':' + i
32228 me.outputs[output].pending = true
32229 } else {
32230 delete me.outputs[output]
32231 }
32232 })
32233 }
32234
32235 this.createTx = function(to, value, fixedFee, changeAddress) {
32236 assert(value > network.dustThreshold, value + ' must be above dust threshold (' + network.dustThreshold + ' Satoshis)')
32237
32238 var utxos = getCandidateOutputs(value)
32239 var accum = 0
32240 var subTotal = value
32241 var addresses = []
32242
32243 var tx = new Transaction()
32244 tx.addOutput(to, value)
32245
32246 for (var i = 0; i < utxos.length; ++i) {
32247 var utxo = utxos[i]
32248 addresses.push(utxo.address)
32249
32250 var outpoint = utxo.from.split(':')
32251 tx.addInput(outpoint[0], parseInt(outpoint[1]))
32252
32253 var fee = fixedFee == undefined ? estimateFeePadChangeOutput(tx) : fixedFee
32254
32255 accum += utxo.value
32256 subTotal = value + fee
32257 if (accum >= subTotal) {
32258 var change = accum - subTotal
32259
32260 if (change > network.dustThreshold) {
32261 tx.addOutput(changeAddress || getChangeAddress(), change)
32262 }
32263
32264 break
32265 }
32266 }
32267
32268 assert(accum >= subTotal, 'Not enough funds (incl. fee): ' + accum + ' < ' + subTotal)
32269
32270 this.signWith(tx, addresses)
32271 return tx
32272 }
32273
32274 function getCandidateOutputs() {
32275 var unspent = []
32276
32277 for (var key in me.outputs) {
32278 var output = me.outputs[key]
32279 if (!output.pending) unspent.push(output)
32280 }
32281
32282 var sortByValueDesc = unspent.sort(function(o1, o2){
32283 return o2.value - o1.value
32284 })
32285
32286 return sortByValueDesc
32287 }
32288
32289 function estimateFeePadChangeOutput(tx) {
32290 var tmpTx = tx.clone()
32291 tmpTx.addOutput(getChangeAddress(), network.dustSoftThreshold || 0)
32292
32293 return network.estimateFee(tmpTx)
32294 }
32295
32296 function getChangeAddress() {
32297 if(me.changeAddresses.length === 0) me.generateChangeAddress();
32298 return me.changeAddresses[me.changeAddresses.length - 1]
32299 }
32300
32301 this.signWith = function(tx, addresses) {
32302 assert.equal(tx.ins.length, addresses.length, 'Number of addresses must match number of transaction inputs')
32303
32304 addresses.forEach(function(address, i) {
32305 var key = me.getPrivateKeyForAddress(address)
32306
32307 tx.sign(i, key)
32308 })
32309
32310 return tx
32311 }
32312
32313 this.getMasterKey = function() { return masterkey }
32314 this.getAccountZero = function() { return accountZero }
32315 this.getInternalAccount = function() { return internalAccount }
32316 this.getExternalAccount = function() { return externalAccount }
32317
32318 this.getPrivateKey = function(index) {
32319 return externalAccount.derive(index).privKey
32320 }
32321
32322 this.getInternalPrivateKey = function(index) {
32323 return internalAccount.derive(index).privKey
32324 }
32325
32326 this.getPrivateKeyForAddress = function(address) {
32327 var index
32328 if((index = this.addresses.indexOf(address)) > -1) {
32329 return this.getPrivateKey(index)
32330 } else if((index = this.changeAddresses.indexOf(address)) > -1) {
32331 return this.getInternalPrivateKey(index)
32332 } else {
32333 throw new Error('Unknown address. Make sure the address is from the keychain and has been generated.')
32334 }
32335 }
32336
32337 function isReceiveAddress(address){
32338 return me.addresses.indexOf(address) > -1
32339 }
32340
32341 function isChangeAddress(address){
32342 return me.changeAddresses.indexOf(address) > -1
32343 }
32344
32345 function isMyAddress(address) {
32346 return isReceiveAddress(address) || isChangeAddress(address)
32347 }
32348 }
32349
32350 module.exports = Wallet
32351
32352 }).call(this,_dereq_("buffer").Buffer)
32353 },{"./address":69,"./hdnode":78,"./networks":81,"./transaction":85,"assert":4,"buffer":8,"secure-random":68}]},{},[79])
32354 (79)
32355 });
32356 </script>
32357 <script>
32358 // Select components from sjcl to suit the crypto operations bip39 requires.
32359
32360 //// base.js
32361
32362 /** @fileOverview Javascript cryptography implementation.
32363 *
32364 * Crush to remove comments, shorten variable names and
32365 * generally reduce transmission size.
32366 *
32367 * @author Emily Stark
32368 * @author Mike Hamburg
32369 * @author Dan Boneh
32370 */
32371
32372 "use strict";
32373 /*jslint indent: 2, bitwise: false, nomen: false, plusplus: false, white: false, regexp: false */
32374 /*global document, window, escape, unescape, module, require, Uint32Array */
32375
32376 /** @namespace The Stanford Javascript Crypto Library, top-level namespace. */
32377 var sjcl = {
32378 /** @namespace Symmetric ciphers. */
32379 cipher: {},
32380
32381 /** @namespace Hash functions. Right now only SHA256 is implemented. */
32382 hash: {},
32383
32384 /** @namespace Key exchange functions. Right now only SRP is implemented. */
32385 keyexchange: {},
32386
32387 /** @namespace Block cipher modes of operation. */
32388 mode: {},
32389
32390 /** @namespace Miscellaneous. HMAC and PBKDF2. */
32391 misc: {},
32392
32393 /**
32394 * @namespace Bit array encoders and decoders.
32395 *
32396 * @description
32397 * The members of this namespace are functions which translate between
32398 * SJCL's bitArrays and other objects (usually strings). Because it
32399 * isn't always clear which direction is encoding and which is decoding,
32400 * the method names are "fromBits" and "toBits".
32401 */
32402 codec: {},
32403
32404 /** @namespace Exceptions. */
32405 exception: {
32406 /** @constructor Ciphertext is corrupt. */
32407 corrupt: function(message) {
32408 this.toString = function() { return "CORRUPT: "+this.message; };
32409 this.message = message;
32410 },
32411
32412 /** @constructor Invalid parameter. */
32413 invalid: function(message) {
32414 this.toString = function() { return "INVALID: "+this.message; };
32415 this.message = message;
32416 },
32417
32418 /** @constructor Bug or missing feature in SJCL. @constructor */
32419 bug: function(message) {
32420 this.toString = function() { return "BUG: "+this.message; };
32421 this.message = message;
32422 },
32423
32424 /** @constructor Something isn't ready. */
32425 notReady: function(message) {
32426 this.toString = function() { return "NOT READY: "+this.message; };
32427 this.message = message;
32428 }
32429 }
32430 };
32431
32432 if(typeof module !== 'undefined' && module.exports){
32433 module.exports = sjcl;
32434 }
32435 if (typeof define === "function") {
32436 define([], function () {
32437 return sjcl;
32438 });
32439 }
32440
32441
32442 //// bitArray.js
32443
32444 /** @fileOverview Arrays of bits, encoded as arrays of Numbers.
32445 *
32446 * @author Emily Stark
32447 * @author Mike Hamburg
32448 * @author Dan Boneh
32449 */
32450
32451 /** @namespace Arrays of bits, encoded as arrays of Numbers.
32452 *
32453 * @description
32454 * <p>
32455 * These objects are the currency accepted by SJCL's crypto functions.
32456 * </p>
32457 *
32458 * <p>
32459 * Most of our crypto primitives operate on arrays of 4-byte words internally,
32460 * but many of them can take arguments that are not a multiple of 4 bytes.
32461 * This library encodes arrays of bits (whose size need not be a multiple of 8
32462 * bits) as arrays of 32-bit words. The bits are packed, big-endian, into an
32463 * array of words, 32 bits at a time. Since the words are double-precision
32464 * floating point numbers, they fit some extra data. We use this (in a private,
32465 * possibly-changing manner) to encode the number of bits actually present
32466 * in the last word of the array.
32467 * </p>
32468 *
32469 * <p>
32470 * Because bitwise ops clear this out-of-band data, these arrays can be passed
32471 * to ciphers like AES which want arrays of words.
32472 * </p>
32473 */
32474 sjcl.bitArray = {
32475 /**
32476 * Array slices in units of bits.
32477 * @param {bitArray} a The array to slice.
32478 * @param {Number} bstart The offset to the start of the slice, in bits.
32479 * @param {Number} bend The offset to the end of the slice, in bits. If this is undefined,
32480 * slice until the end of the array.
32481 * @return {bitArray} The requested slice.
32482 */
32483 bitSlice: function (a, bstart, bend) {
32484 a = sjcl.bitArray._shiftRight(a.slice(bstart/32), 32 - (bstart & 31)).slice(1);
32485 return (bend === undefined) ? a : sjcl.bitArray.clamp(a, bend-bstart);
32486 },
32487
32488 /**
32489 * Extract a number packed into a bit array.
32490 * @param {bitArray} a The array to slice.
32491 * @param {Number} bstart The offset to the start of the slice, in bits.
32492 * @param {Number} length The length of the number to extract.
32493 * @return {Number} The requested slice.
32494 */
32495 extract: function(a, bstart, blength) {
32496 // FIXME: this Math.floor is not necessary at all, but for some reason
32497 // seems to suppress a bug in the Chromium JIT.
32498 var x, sh = Math.floor((-bstart-blength) & 31);
32499 if ((bstart + blength - 1 ^ bstart) & -32) {
32500 // it crosses a boundary
32501 x = (a[bstart/32|0] << (32 - sh)) ^ (a[bstart/32+1|0] >>> sh);
32502 } else {
32503 // within a single word
32504 x = a[bstart/32|0] >>> sh;
32505 }
32506 return x & ((1<<blength) - 1);
32507 },
32508
32509 /**
32510 * Concatenate two bit arrays.
32511 * @param {bitArray} a1 The first array.
32512 * @param {bitArray} a2 The second array.
32513 * @return {bitArray} The concatenation of a1 and a2.
32514 */
32515 concat: function (a1, a2) {
32516 if (a1.length === 0 || a2.length === 0) {
32517 return a1.concat(a2);
32518 }
32519
32520 var last = a1[a1.length-1], shift = sjcl.bitArray.getPartial(last);
32521 if (shift === 32) {
32522 return a1.concat(a2);
32523 } else {
32524 return sjcl.bitArray._shiftRight(a2, shift, last|0, a1.slice(0,a1.length-1));
32525 }
32526 },
32527
32528 /**
32529 * Find the length of an array of bits.
32530 * @param {bitArray} a The array.
32531 * @return {Number} The length of a, in bits.
32532 */
32533 bitLength: function (a) {
32534 var l = a.length, x;
32535 if (l === 0) { return 0; }
32536 x = a[l - 1];
32537 return (l-1) * 32 + sjcl.bitArray.getPartial(x);
32538 },
32539
32540 /**
32541 * Truncate an array.
32542 * @param {bitArray} a The array.
32543 * @param {Number} len The length to truncate to, in bits.
32544 * @return {bitArray} A new array, truncated to len bits.
32545 */
32546 clamp: function (a, len) {
32547 if (a.length * 32 < len) { return a; }
32548 a = a.slice(0, Math.ceil(len / 32));
32549 var l = a.length;
32550 len = len & 31;
32551 if (l > 0 && len) {
32552 a[l-1] = sjcl.bitArray.partial(len, a[l-1] & 0x80000000 >> (len-1), 1);
32553 }
32554 return a;
32555 },
32556
32557 /**
32558 * Make a partial word for a bit array.
32559 * @param {Number} len The number of bits in the word.
32560 * @param {Number} x The bits.
32561 * @param {Number} [0] _end Pass 1 if x has already been shifted to the high side.
32562 * @return {Number} The partial word.
32563 */
32564 partial: function (len, x, _end) {
32565 if (len === 32) { return x; }
32566 return (_end ? x|0 : x << (32-len)) + len * 0x10000000000;
32567 },
32568
32569 /**
32570 * Get the number of bits used by a partial word.
32571 * @param {Number} x The partial word.
32572 * @return {Number} The number of bits used by the partial word.
32573 */
32574 getPartial: function (x) {
32575 return Math.round(x/0x10000000000) || 32;
32576 },
32577
32578 /**
32579 * Compare two arrays for equality in a predictable amount of time.
32580 * @param {bitArray} a The first array.
32581 * @param {bitArray} b The second array.
32582 * @return {boolean} true if a == b; false otherwise.
32583 */
32584 equal: function (a, b) {
32585 if (sjcl.bitArray.bitLength(a) !== sjcl.bitArray.bitLength(b)) {
32586 return false;
32587 }
32588 var x = 0, i;
32589 for (i=0; i<a.length; i++) {
32590 x |= a[i]^b[i];
32591 }
32592 return (x === 0);
32593 },
32594
32595 /** Shift an array right.
32596 * @param {bitArray} a The array to shift.
32597 * @param {Number} shift The number of bits to shift.
32598 * @param {Number} [carry=0] A byte to carry in
32599 * @param {bitArray} [out=[]] An array to prepend to the output.
32600 * @private
32601 */
32602 _shiftRight: function (a, shift, carry, out) {
32603 var i, last2=0, shift2;
32604 if (out === undefined) { out = []; }
32605
32606 for (; shift >= 32; shift -= 32) {
32607 out.push(carry);
32608 carry = 0;
32609 }
32610 if (shift === 0) {
32611 return out.concat(a);
32612 }
32613
32614 for (i=0; i<a.length; i++) {
32615 out.push(carry | a[i]>>>shift);
32616 carry = a[i] << (32-shift);
32617 }
32618 last2 = a.length ? a[a.length-1] : 0;
32619 shift2 = sjcl.bitArray.getPartial(last2);
32620 out.push(sjcl.bitArray.partial(shift+shift2 & 31, (shift + shift2 > 32) ? carry : out.pop(),1));
32621 return out;
32622 },
32623
32624 /** xor a block of 4 words together.
32625 * @private
32626 */
32627 _xor4: function(x,y) {
32628 return [x[0]^y[0],x[1]^y[1],x[2]^y[2],x[3]^y[3]];
32629 },
32630
32631 /** byteswap a word array inplace.
32632 * (does not handle partial words)
32633 * @param {sjcl.bitArray} a word array
32634 * @return {sjcl.bitArray} byteswapped array
32635 */
32636 byteswapM: function(a) {
32637 var i, v, m = 0xff00;
32638 for (i = 0; i < a.length; ++i) {
32639 v = a[i];
32640 a[i] = (v >>> 24) | ((v >>> 8) & m) | ((v & m) << 8) | (v << 24);
32641 }
32642 return a;
32643 }
32644 };
32645
32646
32647 //// codecString.js
32648
32649 /** @fileOverview Bit array codec implementations.
32650 *
32651 * @author Emily Stark
32652 * @author Mike Hamburg
32653 * @author Dan Boneh
32654 */
32655
32656 /** @namespace UTF-8 strings */
32657 sjcl.codec.utf8String = {
32658 /** Convert from a bitArray to a UTF-8 string. */
32659 fromBits: function (arr) {
32660 var out = "", bl = sjcl.bitArray.bitLength(arr), i, tmp;
32661 for (i=0; i<bl/8; i++) {
32662 if ((i&3) === 0) {
32663 tmp = arr[i/4];
32664 }
32665 out += String.fromCharCode(tmp >>> 24);
32666 tmp <<= 8;
32667 }
32668 return decodeURIComponent(escape(out));
32669 },
32670
32671 /** Convert from a UTF-8 string to a bitArray. */
32672 toBits: function (str) {
32673 str = unescape(encodeURIComponent(str));
32674 var out = [], i, tmp=0;
32675 for (i=0; i<str.length; i++) {
32676 tmp = tmp << 8 | str.charCodeAt(i);
32677 if ((i&3) === 3) {
32678 out.push(tmp);
32679 tmp = 0;
32680 }
32681 }
32682 if (i&3) {
32683 out.push(sjcl.bitArray.partial(8*(i&3), tmp));
32684 }
32685 return out;
32686 }
32687 };
32688
32689
32690 //// codecHex.js
32691
32692 /** @fileOverview Bit array codec implementations.
32693 *
32694 * @author Emily Stark
32695 * @author Mike Hamburg
32696 * @author Dan Boneh
32697 */
32698
32699 /** @namespace Hexadecimal */
32700 sjcl.codec.hex = {
32701 /** Convert from a bitArray to a hex string. */
32702 fromBits: function (arr) {
32703 var out = "", i;
32704 for (i=0; i<arr.length; i++) {
32705 out += ((arr[i]|0)+0xF00000000000).toString(16).substr(4);
32706 }
32707 return out.substr(0, sjcl.bitArray.bitLength(arr)/4);//.replace(/(.{8})/g, "$1 ");
32708 },
32709 /** Convert from a hex string to a bitArray. */
32710 toBits: function (str) {
32711 var i, out=[], len;
32712 str = str.replace(/\s|0x/g, "");
32713 len = str.length;
32714 str = str + "00000000";
32715 for (i=0; i<str.length; i+=8) {
32716 out.push(parseInt(str.substr(i,8),16)^0);
32717 }
32718 return sjcl.bitArray.clamp(out, len*4);
32719 }
32720 };
32721
32722
32723 //// sha512.js
32724
32725 /** @fileOverview Javascript SHA-512 implementation.
32726 *
32727 * This implementation was written for CryptoJS by Jeff Mott and adapted for
32728 * SJCL by Stefan Thomas.
32729 *
32730 * CryptoJS (c) 2009–2012 by Jeff Mott. All rights reserved.
32731 * Released with New BSD License
32732 *
32733 * @author Emily Stark
32734 * @author Mike Hamburg
32735 * @author Dan Boneh
32736 * @author Jeff Mott
32737 * @author Stefan Thomas
32738 */
32739
32740 /**
32741 * Context for a SHA-512 operation in progress.
32742 * @constructor
32743 * @class Secure Hash Algorithm, 512 bits.
32744 */
32745 sjcl.hash.sha512 = function (hash) {
32746 if (!this._key[0]) { this._precompute(); }
32747 if (hash) {
32748 this._h = hash._h.slice(0);
32749 this._buffer = hash._buffer.slice(0);
32750 this._length = hash._length;
32751 } else {
32752 this.reset();
32753 }
32754 };
32755
32756 /**
32757 * Hash a string or an array of words.
32758 * @static
32759 * @param {bitArray|String} data the data to hash.
32760 * @return {bitArray} The hash value, an array of 16 big-endian words.
32761 */
32762 sjcl.hash.sha512.hash = function (data) {
32763 return (new sjcl.hash.sha512()).update(data).finalize();
32764 };
32765
32766 sjcl.hash.sha512.prototype = {
32767 /**
32768 * The hash's block size, in bits.
32769 * @constant
32770 */
32771 blockSize: 1024,
32772
32773 /**
32774 * Reset the hash state.
32775 * @return this
32776 */
32777 reset:function () {
32778 this._h = this._init.slice(0);
32779 this._buffer = [];
32780 this._length = 0;
32781 return this;
32782 },
32783
32784 /**
32785 * Input several words to the hash.
32786 * @param {bitArray|String} data the data to hash.
32787 * @return this
32788 */
32789 update: function (data) {
32790 if (typeof data === "string") {
32791 data = sjcl.codec.utf8String.toBits(data);
32792 }
32793 var i, b = this._buffer = sjcl.bitArray.concat(this._buffer, data),
32794 ol = this._length,
32795 nl = this._length = ol + sjcl.bitArray.bitLength(data);
32796 for (i = 1024+ol & -1024; i <= nl; i+= 1024) {
32797 this._block(b.splice(0,32));
32798 }
32799 return this;
32800 },
32801
32802 /**
32803 * Complete hashing and output the hash value.
32804 * @return {bitArray} The hash value, an array of 16 big-endian words.
32805 */
32806 finalize:function () {
32807 var i, b = this._buffer, h = this._h;
32808
32809 // Round out and push the buffer
32810 b = sjcl.bitArray.concat(b, [sjcl.bitArray.partial(1,1)]);
32811
32812 // Round out the buffer to a multiple of 32 words, less the 4 length words.
32813 for (i = b.length + 4; i & 31; i++) {
32814 b.push(0);
32815 }
32816
32817 // append the length
32818 b.push(0);
32819 b.push(0);
32820 b.push(Math.floor(this._length / 0x100000000));
32821 b.push(this._length | 0);
32822
32823 while (b.length) {
32824 this._block(b.splice(0,32));
32825 }
32826
32827 this.reset();
32828 return h;
32829 },
32830
32831 /**
32832 * The SHA-512 initialization vector, to be precomputed.
32833 * @private
32834 */
32835 _init:[],
32836
32837 /**
32838 * Least significant 24 bits of SHA512 initialization values.
32839 *
32840 * Javascript only has 53 bits of precision, so we compute the 40 most
32841 * significant bits and add the remaining 24 bits as constants.
32842 *
32843 * @private
32844 */
32845 _initr: [ 0xbcc908, 0xcaa73b, 0x94f82b, 0x1d36f1, 0xe682d1, 0x3e6c1f, 0x41bd6b, 0x7e2179 ],
32846
32847 /*
32848 _init:
32849 [0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1,
32850 0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179],
32851 */
32852
32853 /**
32854 * The SHA-512 hash key, to be precomputed.
32855 * @private
32856 */
32857 _key:[],
32858
32859 /**
32860 * Least significant 24 bits of SHA512 key values.
32861 * @private
32862 */
32863 _keyr:
32864 [0x28ae22, 0xef65cd, 0x4d3b2f, 0x89dbbc, 0x48b538, 0x05d019, 0x194f9b, 0x6d8118,
32865 0x030242, 0x706fbe, 0xe4b28c, 0xffb4e2, 0x7b896f, 0x1696b1, 0xc71235, 0x692694,
32866 0xf14ad2, 0x4f25e3, 0x8cd5b5, 0xac9c65, 0x2b0275, 0xa6e483, 0x41fbd4, 0x1153b5,
32867 0x66dfab, 0xb43210, 0xfb213f, 0xef0ee4, 0xa88fc2, 0x0aa725, 0x03826f, 0x0e6e70,
32868 0xd22ffc, 0x26c926, 0xc42aed, 0x95b3df, 0xaf63de, 0x77b2a8, 0xedaee6, 0x82353b,
32869 0xf10364, 0x423001, 0xf89791, 0x54be30, 0xef5218, 0x65a910, 0x71202a, 0xbbd1b8,
32870 0xd2d0c8, 0x41ab53, 0x8eeb99, 0x9b48a8, 0xc95a63, 0x418acb, 0x63e373, 0xb2b8a3,
32871 0xefb2fc, 0x172f60, 0xf0ab72, 0x6439ec, 0x631e28, 0x82bde9, 0xc67915, 0x72532b,
32872 0x26619c, 0xc0c207, 0xe0eb1e, 0x6ed178, 0x176fba, 0xc898a6, 0xf90dae, 0x1c471b,
32873 0x047d84, 0xc72493, 0xc9bebc, 0x100d4c, 0x3e42b6, 0x657e2a, 0xd6faec, 0x475817],
32874
32875 /*
32876 _key:
32877 [0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
32878 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
32879 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
32880 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
32881 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
32882 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
32883 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
32884 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
32885 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
32886 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
32887 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
32888 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
32889 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
32890 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
32891 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
32892 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
32893 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
32894 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
32895 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
32896 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817],
32897 */
32898
32899 /**
32900 * Function to precompute _init and _key.
32901 * @private
32902 */
32903 _precompute: function () {
32904 // XXX: This code is for precomputing the SHA256 constants, change for
32905 // SHA512 and re-enable.
32906 var i = 0, prime = 2, factor;
32907
32908 function frac(x) { return (x-Math.floor(x)) * 0x100000000 | 0; }
32909 function frac2(x) { return (x-Math.floor(x)) * 0x10000000000 & 0xff; }
32910
32911 outer: for (; i<80; prime++) {
32912 for (factor=2; factor*factor <= prime; factor++) {
32913 if (prime % factor === 0) {
32914 // not a prime
32915 continue outer;
32916 }
32917 }
32918
32919 if (i<8) {
32920 this._init[i*2] = frac(Math.pow(prime, 1/2));
32921 this._init[i*2+1] = (frac2(Math.pow(prime, 1/2)) << 24) | this._initr[i];
32922 }
32923 this._key[i*2] = frac(Math.pow(prime, 1/3));
32924 this._key[i*2+1] = (frac2(Math.pow(prime, 1/3)) << 24) | this._keyr[i];
32925 i++;
32926 }
32927 },
32928
32929 /**
32930 * Perform one cycle of SHA-512.
32931 * @param {bitArray} words one block of words.
32932 * @private
32933 */
32934 _block:function (words) {
32935 var i, wrh, wrl,
32936 w = words.slice(0),
32937 h = this._h,
32938 k = this._key,
32939 h0h = h[ 0], h0l = h[ 1], h1h = h[ 2], h1l = h[ 3],
32940 h2h = h[ 4], h2l = h[ 5], h3h = h[ 6], h3l = h[ 7],
32941 h4h = h[ 8], h4l = h[ 9], h5h = h[10], h5l = h[11],
32942 h6h = h[12], h6l = h[13], h7h = h[14], h7l = h[15];
32943
32944 // Working variables
32945 var ah = h0h, al = h0l, bh = h1h, bl = h1l,
32946 ch = h2h, cl = h2l, dh = h3h, dl = h3l,
32947 eh = h4h, el = h4l, fh = h5h, fl = h5l,
32948 gh = h6h, gl = h6l, hh = h7h, hl = h7l;
32949
32950 for (i=0; i<80; i++) {
32951 // load up the input word for this round
32952 if (i<16) {
32953 wrh = w[i * 2];
32954 wrl = w[i * 2 + 1];
32955 } else {
32956 // Gamma0
32957 var gamma0xh = w[(i-15) * 2];
32958 var gamma0xl = w[(i-15) * 2 + 1];
32959 var gamma0h =
32960 ((gamma0xl << 31) | (gamma0xh >>> 1)) ^
32961 ((gamma0xl << 24) | (gamma0xh >>> 8)) ^
32962 (gamma0xh >>> 7);
32963 var gamma0l =
32964 ((gamma0xh << 31) | (gamma0xl >>> 1)) ^
32965 ((gamma0xh << 24) | (gamma0xl >>> 8)) ^
32966 ((gamma0xh << 25) | (gamma0xl >>> 7));
32967
32968 // Gamma1
32969 var gamma1xh = w[(i-2) * 2];
32970 var gamma1xl = w[(i-2) * 2 + 1];
32971 var gamma1h =
32972 ((gamma1xl << 13) | (gamma1xh >>> 19)) ^
32973 ((gamma1xh << 3) | (gamma1xl >>> 29)) ^
32974 (gamma1xh >>> 6);
32975 var gamma1l =
32976 ((gamma1xh << 13) | (gamma1xl >>> 19)) ^
32977 ((gamma1xl << 3) | (gamma1xh >>> 29)) ^
32978 ((gamma1xh << 26) | (gamma1xl >>> 6));
32979
32980 // Shortcuts
32981 var wr7h = w[(i-7) * 2];
32982 var wr7l = w[(i-7) * 2 + 1];
32983
32984 var wr16h = w[(i-16) * 2];
32985 var wr16l = w[(i-16) * 2 + 1];
32986
32987 // W(round) = gamma0 + W(round - 7) + gamma1 + W(round - 16)
32988 wrl = gamma0l + wr7l;
32989 wrh = gamma0h + wr7h + ((wrl >>> 0) < (gamma0l >>> 0) ? 1 : 0);
32990 wrl += gamma1l;
32991 wrh += gamma1h + ((wrl >>> 0) < (gamma1l >>> 0) ? 1 : 0);
32992 wrl += wr16l;
32993 wrh += wr16h + ((wrl >>> 0) < (wr16l >>> 0) ? 1 : 0);
32994 }
32995
32996 w[i*2] = wrh |= 0;
32997 w[i*2 + 1] = wrl |= 0;
32998
32999 // Ch
33000 var chh = (eh & fh) ^ (~eh & gh);
33001 var chl = (el & fl) ^ (~el & gl);
33002
33003 // Maj
33004 var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
33005 var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
33006
33007 // Sigma0
33008 var sigma0h = ((al << 4) | (ah >>> 28)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
33009 var sigma0l = ((ah << 4) | (al >>> 28)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
33010
33011 // Sigma1
33012 var sigma1h = ((el << 18) | (eh >>> 14)) ^ ((el << 14) | (eh >>> 18)) ^ ((eh << 23) | (el >>> 9));
33013 var sigma1l = ((eh << 18) | (el >>> 14)) ^ ((eh << 14) | (el >>> 18)) ^ ((el << 23) | (eh >>> 9));
33014
33015 // K(round)
33016 var krh = k[i*2];
33017 var krl = k[i*2+1];
33018
33019 // t1 = h + sigma1 + ch + K(round) + W(round)
33020 var t1l = hl + sigma1l;
33021 var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
33022 t1l += chl;
33023 t1h += chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
33024 t1l += krl;
33025 t1h += krh + ((t1l >>> 0) < (krl >>> 0) ? 1 : 0);
33026 t1l = t1l + wrl|0; // FF32..FF34 perf issue https://bugzilla.mozilla.org/show_bug.cgi?id=1054972
33027 t1h += wrh + ((t1l >>> 0) < (wrl >>> 0) ? 1 : 0);
33028
33029 // t2 = sigma0 + maj
33030 var t2l = sigma0l + majl;
33031 var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
33032
33033 // Update working variables
33034 hh = gh;
33035 hl = gl;
33036 gh = fh;
33037 gl = fl;
33038 fh = eh;
33039 fl = el;
33040 el = (dl + t1l) | 0;
33041 eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
33042 dh = ch;
33043 dl = cl;
33044 ch = bh;
33045 cl = bl;
33046 bh = ah;
33047 bl = al;
33048 al = (t1l + t2l) | 0;
33049 ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
33050 }
33051
33052 // Intermediate hash
33053 h0l = h[1] = (h0l + al) | 0;
33054 h[0] = (h0h + ah + ((h0l >>> 0) < (al >>> 0) ? 1 : 0)) | 0;
33055 h1l = h[3] = (h1l + bl) | 0;
33056 h[2] = (h1h + bh + ((h1l >>> 0) < (bl >>> 0) ? 1 : 0)) | 0;
33057 h2l = h[5] = (h2l + cl) | 0;
33058 h[4] = (h2h + ch + ((h2l >>> 0) < (cl >>> 0) ? 1 : 0)) | 0;
33059 h3l = h[7] = (h3l + dl) | 0;
33060 h[6] = (h3h + dh + ((h3l >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
33061 h4l = h[9] = (h4l + el) | 0;
33062 h[8] = (h4h + eh + ((h4l >>> 0) < (el >>> 0) ? 1 : 0)) | 0;
33063 h5l = h[11] = (h5l + fl) | 0;
33064 h[10] = (h5h + fh + ((h5l >>> 0) < (fl >>> 0) ? 1 : 0)) | 0;
33065 h6l = h[13] = (h6l + gl) | 0;
33066 h[12] = (h6h + gh + ((h6l >>> 0) < (gl >>> 0) ? 1 : 0)) | 0;
33067 h7l = h[15] = (h7l + hl) | 0;
33068 h[14] = (h7h + hh + ((h7l >>> 0) < (hl >>> 0) ? 1 : 0)) | 0;
33069 }
33070 };
33071
33072
33073 //// hmac.js
33074
33075 /** @fileOverview HMAC implementation.
33076 *
33077 * @author Emily Stark
33078 * @author Mike Hamburg
33079 * @author Dan Boneh
33080 */
33081
33082 /** HMAC with the specified hash function.
33083 * @constructor
33084 * @param {bitArray} key the key for HMAC.
33085 * @param {Object} [hash=sjcl.hash.sha256] The hash function to use.
33086 */
33087 sjcl.misc.hmac = function (key, Hash) {
33088 this._hash = Hash = Hash || sjcl.hash.sha256;
33089 var exKey = [[],[]], i,
33090 bs = Hash.prototype.blockSize / 32;
33091 this._baseHash = [new Hash(), new Hash()];
33092
33093 if (key.length > bs) {
33094 key = Hash.hash(key);
33095 }
33096
33097 for (i=0; i<bs; i++) {
33098 exKey[0][i] = key[i]^0x36363636;
33099 exKey[1][i] = key[i]^0x5C5C5C5C;
33100 }
33101
33102 this._baseHash[0].update(exKey[0]);
33103 this._baseHash[1].update(exKey[1]);
33104 this._resultHash = new Hash(this._baseHash[0]);
33105 };
33106
33107 /** HMAC with the specified hash function. Also called encrypt since it's a prf.
33108 * @param {bitArray|String} data The data to mac.
33109 */
33110 sjcl.misc.hmac.prototype.encrypt = sjcl.misc.hmac.prototype.mac = function (data) {
33111 if (!this._updated) {
33112 this.update(data);
33113 return this.digest(data);
33114 } else {
33115 throw new sjcl.exception.invalid("encrypt on already updated hmac called!");
33116 }
33117 };
33118
33119 sjcl.misc.hmac.prototype.reset = function () {
33120 this._resultHash = new this._hash(this._baseHash[0]);
33121 this._updated = false;
33122 };
33123
33124 sjcl.misc.hmac.prototype.update = function (data) {
33125 this._updated = true;
33126 this._resultHash.update(data);
33127 };
33128
33129 sjcl.misc.hmac.prototype.digest = function () {
33130 var w = this._resultHash.finalize(), result = new (this._hash)(this._baseHash[1]).update(w).finalize();
33131
33132 this.reset();
33133
33134 return result;
33135 };
33136
33137
33138 //// pbkdf2.js
33139
33140
33141 /** @fileOverview Password-based key-derivation function, version 2.0.
33142 *
33143 * @author Emily Stark
33144 * @author Mike Hamburg
33145 * @author Dan Boneh
33146 */
33147
33148 /** Password-Based Key-Derivation Function, version 2.0.
33149 *
33150 * Generate keys from passwords using PBKDF2-HMAC-SHA256.
33151 *
33152 * This is the method specified by RSA's PKCS #5 standard.
33153 *
33154 * @param {bitArray|String} password The password.
33155 * @param {bitArray|String} salt The salt. Should have lots of entropy.
33156 * @param {Number} [count=1000] The number of iterations. Higher numbers make the function slower but more secure.
33157 * @param {Number} [length] The length of the derived key. Defaults to the
33158 output size of the hash function.
33159 * @param {Object} [Prff=sjcl.misc.hmac] The pseudorandom function family.
33160 * @return {bitArray} the derived key.
33161 */
33162 sjcl.misc.pbkdf2 = function (password, salt, count, length, Prff) {
33163 count = count || 1000;
33164
33165 if (length < 0 || count < 0) {
33166 throw sjcl.exception.invalid("invalid params to pbkdf2");
33167 }
33168
33169 if (typeof password === "string") {
33170 password = sjcl.codec.utf8String.toBits(password);
33171 }
33172
33173 if (typeof salt === "string") {
33174 salt = sjcl.codec.utf8String.toBits(salt);
33175 }
33176
33177 Prff = Prff || sjcl.misc.hmac;
33178
33179 var prf = new Prff(password),
33180 u, ui, i, j, k, out = [], b = sjcl.bitArray;
33181
33182 for (k = 1; 32 * out.length < (length || 1); k++) {
33183 u = ui = prf.encrypt(b.concat(salt,[k]));
33184
33185 for (i=1; i<count; i++) {
33186 ui = prf.encrypt(ui);
33187 for (j=0; j<ui.length; j++) {
33188 u[j] ^= ui[j];
33189 }
33190 }
33191
33192 out = out.concat(u);
33193 }
33194
33195 if (length) { out = b.clamp(out, length); }
33196
33197 return out;
33198 };
33199
33200
33201 //// sha256.js
33202
33203 /** @fileOverview Javascript SHA-256 implementation.
33204 *
33205 * An older version of this implementation is available in the public
33206 * domain, but this one is (c) Emily Stark, Mike Hamburg, Dan Boneh,
33207 * Stanford University 2008-2010 and BSD-licensed for liability
33208 * reasons.
33209 *
33210 * Special thanks to Aldo Cortesi for pointing out several bugs in
33211 * this code.
33212 *
33213 * @author Emily Stark
33214 * @author Mike Hamburg
33215 * @author Dan Boneh
33216 */
33217
33218 /**
33219 * Context for a SHA-256 operation in progress.
33220 * @constructor
33221 * @class Secure Hash Algorithm, 256 bits.
33222 */
33223 sjcl.hash.sha256 = function (hash) {
33224 if (!this._key[0]) { this._precompute(); }
33225 if (hash) {
33226 this._h = hash._h.slice(0);
33227 this._buffer = hash._buffer.slice(0);
33228 this._length = hash._length;
33229 } else {
33230 this.reset();
33231 }
33232 };
33233
33234 /**
33235 * Hash a string or an array of words.
33236 * @static
33237 * @param {bitArray|String} data the data to hash.
33238 * @return {bitArray} The hash value, an array of 16 big-endian words.
33239 */
33240 sjcl.hash.sha256.hash = function (data) {
33241 return (new sjcl.hash.sha256()).update(data).finalize();
33242 };
33243
33244 sjcl.hash.sha256.prototype = {
33245 /**
33246 * The hash's block size, in bits.
33247 * @constant
33248 */
33249 blockSize: 512,
33250
33251 /**
33252 * Reset the hash state.
33253 * @return this
33254 */
33255 reset:function () {
33256 this._h = this._init.slice(0);
33257 this._buffer = [];
33258 this._length = 0;
33259 return this;
33260 },
33261
33262 /**
33263 * Input several words to the hash.
33264 * @param {bitArray|String} data the data to hash.
33265 * @return this
33266 */
33267 update: function (data) {
33268 if (typeof data === "string") {
33269 data = sjcl.codec.utf8String.toBits(data);
33270 }
33271 var i, b = this._buffer = sjcl.bitArray.concat(this._buffer, data),
33272 ol = this._length,
33273 nl = this._length = ol + sjcl.bitArray.bitLength(data);
33274 for (i = 512+ol & -512; i <= nl; i+= 512) {
33275 this._block(b.splice(0,16));
33276 }
33277 return this;
33278 },
33279
33280 /**
33281 * Complete hashing and output the hash value.
33282 * @return {bitArray} The hash value, an array of 8 big-endian words.
33283 */
33284 finalize:function () {
33285 var i, b = this._buffer, h = this._h;
33286
33287 // Round out and push the buffer
33288 b = sjcl.bitArray.concat(b, [sjcl.bitArray.partial(1,1)]);
33289
33290 // Round out the buffer to a multiple of 16 words, less the 2 length words.
33291 for (i = b.length + 2; i & 15; i++) {
33292 b.push(0);
33293 }
33294
33295 // append the length
33296 b.push(Math.floor(this._length / 0x100000000));
33297 b.push(this._length | 0);
33298
33299 while (b.length) {
33300 this._block(b.splice(0,16));
33301 }
33302
33303 this.reset();
33304 return h;
33305 },
33306
33307 /**
33308 * The SHA-256 initialization vector, to be precomputed.
33309 * @private
33310 */
33311 _init:[],
33312 /*
33313 _init:[0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19],
33314 */
33315
33316 /**
33317 * The SHA-256 hash key, to be precomputed.
33318 * @private
33319 */
33320 _key:[],
33321 /*
33322 _key:
33323 [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
33324 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
33325 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
33326 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
33327 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
33328 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
33329 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
33330 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2],
33331 */
33332
33333
33334 /**
33335 * Function to precompute _init and _key.
33336 * @private
33337 */
33338 _precompute: function () {
33339 var i = 0, prime = 2, factor;
33340
33341 function frac(x) { return (x-Math.floor(x)) * 0x100000000 | 0; }
33342
33343 outer: for (; i<64; prime++) {
33344 for (factor=2; factor*factor <= prime; factor++) {
33345 if (prime % factor === 0) {
33346 // not a prime
33347 continue outer;
33348 }
33349 }
33350
33351 if (i<8) {
33352 this._init[i] = frac(Math.pow(prime, 1/2));
33353 }
33354 this._key[i] = frac(Math.pow(prime, 1/3));
33355 i++;
33356 }
33357 },
33358
33359 /**
33360 * Perform one cycle of SHA-256.
33361 * @param {bitArray} words one block of words.
33362 * @private
33363 */
33364 _block:function (words) {
33365 var i, tmp, a, b,
33366 w = words.slice(0),
33367 h = this._h,
33368 k = this._key,
33369 h0 = h[0], h1 = h[1], h2 = h[2], h3 = h[3],
33370 h4 = h[4], h5 = h[5], h6 = h[6], h7 = h[7];
33371
33372 /* Rationale for placement of |0 :
33373 * If a value can overflow is original 32 bits by a factor of more than a few
33374 * million (2^23 ish), there is a possibility that it might overflow the
33375 * 53-bit mantissa and lose precision.
33376 *
33377 * To avoid this, we clamp back to 32 bits by |'ing with 0 on any value that
33378 * propagates around the loop, and on the hash state h[]. I don't believe
33379 * that the clamps on h4 and on h0 are strictly necessary, but it's close
33380 * (for h4 anyway), and better safe than sorry.
33381 *
33382 * The clamps on h[] are necessary for the output to be correct even in the
33383 * common case and for short inputs.
33384 */
33385 for (i=0; i<64; i++) {
33386 // load up the input word for this round
33387 if (i<16) {
33388 tmp = w[i];
33389 } else {
33390 a = w[(i+1 ) & 15];
33391 b = w[(i+14) & 15];
33392 tmp = w[i&15] = ((a>>>7 ^ a>>>18 ^ a>>>3 ^ a<<25 ^ a<<14) +
33393 (b>>>17 ^ b>>>19 ^ b>>>10 ^ b<<15 ^ b<<13) +
33394 w[i&15] + w[(i+9) & 15]) | 0;
33395 }
33396
33397 tmp = (tmp + h7 + (h4>>>6 ^ h4>>>11 ^ h4>>>25 ^ h4<<26 ^ h4<<21 ^ h4<<7) + (h6 ^ h4&(h5^h6)) + k[i]); // | 0;
33398
33399 // shift register
33400 h7 = h6; h6 = h5; h5 = h4;
33401 h4 = h3 + tmp | 0;
33402 h3 = h2; h2 = h1; h1 = h0;
33403
33404 h0 = (tmp + ((h1&h2) ^ (h3&(h1^h2))) + (h1>>>2 ^ h1>>>13 ^ h1>>>22 ^ h1<<30 ^ h1<<19 ^ h1<<10)) | 0;
33405 }
33406
33407 h[0] = h[0]+h0 | 0;
33408 h[1] = h[1]+h1 | 0;
33409 h[2] = h[2]+h2 | 0;
33410 h[3] = h[3]+h3 | 0;
33411 h[4] = h[4]+h4 | 0;
33412 h[5] = h[5]+h5 | 0;
33413 h[6] = h[6]+h6 | 0;
33414 h[7] = h[7]+h7 | 0;
33415 }
33416 };
33417 </script>
33418 <script>
33419 WORDLISTS = {};
33420 </script>
33421 <script>
33422 WORDLISTS["english"] = [
33423 "abandon","ability","able","about","above","absent","absorb","abstract","absurd","abuse",
33424 "access","accident","account","accuse","achieve","acid","acoustic","acquire","across","act",
33425 "action","actor","actress","actual","adapt","add","addict","address","adjust","admit",
33426 "adult","advance","advice","aerobic","affair","afford","afraid","again","age","agent",
33427 "agree","ahead","aim","air","airport","aisle","alarm","album","alcohol","alert",
33428 "alien","all","alley","allow","almost","alone","alpha","already","also","alter",
33429 "always","amateur","amazing","among","amount","amused","analyst","anchor","ancient","anger",
33430 "angle","angry","animal","ankle","announce","annual","another","answer","antenna","antique",
33431 "anxiety","any","apart","apology","appear","apple","approve","april","arch","arctic",
33432 "area","arena","argue","arm","armed","armor","army","around","arrange","arrest",
33433 "arrive","arrow","art","artefact","artist","artwork","ask","aspect","assault","asset",
33434 "assist","assume","asthma","athlete","atom","attack","attend","attitude","attract","auction",
33435 "audit","august","aunt","author","auto","autumn","average","avocado","avoid","awake",
33436 "aware","away","awesome","awful","awkward","axis","baby","bachelor","bacon","badge",
33437 "bag","balance","balcony","ball","bamboo","banana","banner","bar","barely","bargain",
33438 "barrel","base","basic","basket","battle","beach","bean","beauty","because","become",
33439 "beef","before","begin","behave","behind","believe","below","belt","bench","benefit",
33440 "best","betray","better","between","beyond","bicycle","bid","bike","bind","biology",
33441 "bird","birth","bitter","black","blade","blame","blanket","blast","bleak","bless",
33442 "blind","blood","blossom","blouse","blue","blur","blush","board","boat","body",
33443 "boil","bomb","bone","bonus","book","boost","border","boring","borrow","boss",
33444 "bottom","bounce","box","boy","bracket","brain","brand","brass","brave","bread",
33445 "breeze","brick","bridge","brief","bright","bring","brisk","broccoli","broken","bronze",
33446 "broom","brother","brown","brush","bubble","buddy","budget","buffalo","build","bulb",
33447 "bulk","bullet","bundle","bunker","burden","burger","burst","bus","business","busy",
33448 "butter","buyer","buzz","cabbage","cabin","cable","cactus","cage","cake","call",
33449 "calm","camera","camp","can","canal","cancel","candy","cannon","canoe","canvas",
33450 "canyon","capable","capital","captain","car","carbon","card","cargo","carpet","carry",
33451 "cart","case","cash","casino","castle","casual","cat","catalog","catch","category",
33452 "cattle","caught","cause","caution","cave","ceiling","celery","cement","census","century",
33453 "cereal","certain","chair","chalk","champion","change","chaos","chapter","charge","chase",
33454 "chat","cheap","check","cheese","chef","cherry","chest","chicken","chief","child",
33455 "chimney","choice","choose","chronic","chuckle","chunk","churn","cigar","cinnamon","circle",
33456 "citizen","city","civil","claim","clap","clarify","claw","clay","clean","clerk",
33457 "clever","click","client","cliff","climb","clinic","clip","clock","clog","close",
33458 "cloth","cloud","clown","club","clump","cluster","clutch","coach","coast","coconut",
33459 "code","coffee","coil","coin","collect","color","column","combine","come","comfort",
33460 "comic","common","company","concert","conduct","confirm","congress","connect","consider","control",
33461 "convince","cook","cool","copper","copy","coral","core","corn","correct","cost",
33462 "cotton","couch","country","couple","course","cousin","cover","coyote","crack","cradle",
33463 "craft","cram","crane","crash","crater","crawl","crazy","cream","credit","creek",
33464 "crew","cricket","crime","crisp","critic","crop","cross","crouch","crowd","crucial",
33465 "cruel","cruise","crumble","crunch","crush","cry","crystal","cube","culture","cup",
33466 "cupboard","curious","current","curtain","curve","cushion","custom","cute","cycle","dad",
33467 "damage","damp","dance","danger","daring","dash","daughter","dawn","day","deal",
33468 "debate","debris","decade","december","decide","decline","decorate","decrease","deer","defense",
33469 "define","defy","degree","delay","deliver","demand","demise","denial","dentist","deny",
33470 "depart","depend","deposit","depth","deputy","derive","describe","desert","design","desk",
33471 "despair","destroy","detail","detect","develop","device","devote","diagram","dial","diamond",
33472 "diary","dice","diesel","diet","differ","digital","dignity","dilemma","dinner","dinosaur",
33473 "direct","dirt","disagree","discover","disease","dish","dismiss","disorder","display","distance",
33474 "divert","divide","divorce","dizzy","doctor","document","dog","doll","dolphin","domain",
33475 "donate","donkey","donor","door","dose","double","dove","draft","dragon","drama",
33476 "drastic","draw","dream","dress","drift","drill","drink","drip","drive","drop",
33477 "drum","dry","duck","dumb","dune","during","dust","dutch","duty","dwarf",
33478 "dynamic","eager","eagle","early","earn","earth","easily","east","easy","echo",
33479 "ecology","economy","edge","edit","educate","effort","egg","eight","either","elbow",
33480 "elder","electric","elegant","element","elephant","elevator","elite","else","embark","embody",
33481 "embrace","emerge","emotion","employ","empower","empty","enable","enact","end","endless",
33482 "endorse","enemy","energy","enforce","engage","engine","enhance","enjoy","enlist","enough",
33483 "enrich","enroll","ensure","enter","entire","entry","envelope","episode","equal","equip",
33484 "era","erase","erode","erosion","error","erupt","escape","essay","essence","estate",
33485 "eternal","ethics","evidence","evil","evoke","evolve","exact","example","excess","exchange",
33486 "excite","exclude","excuse","execute","exercise","exhaust","exhibit","exile","exist","exit",
33487 "exotic","expand","expect","expire","explain","expose","express","extend","extra","eye",
33488 "eyebrow","fabric","face","faculty","fade","faint","faith","fall","false","fame",
33489 "family","famous","fan","fancy","fantasy","farm","fashion","fat","fatal","father",
33490 "fatigue","fault","favorite","feature","february","federal","fee","feed","feel","female",
33491 "fence","festival","fetch","fever","few","fiber","fiction","field","figure","file",
33492 "film","filter","final","find","fine","finger","finish","fire","firm","first",
33493 "fiscal","fish","fit","fitness","fix","flag","flame","flash","flat","flavor",
33494 "flee","flight","flip","float","flock","floor","flower","fluid","flush","fly",
33495 "foam","focus","fog","foil","fold","follow","food","foot","force","forest",
33496 "forget","fork","fortune","forum","forward","fossil","foster","found","fox","fragile",
33497 "frame","frequent","fresh","friend","fringe","frog","front","frost","frown","frozen",
33498 "fruit","fuel","fun","funny","furnace","fury","future","gadget","gain","galaxy",
33499 "gallery","game","gap","garage","garbage","garden","garlic","garment","gas","gasp",
33500 "gate","gather","gauge","gaze","general","genius","genre","gentle","genuine","gesture",
33501 "ghost","giant","gift","giggle","ginger","giraffe","girl","give","glad","glance",
33502 "glare","glass","glide","glimpse","globe","gloom","glory","glove","glow","glue",
33503 "goat","goddess","gold","good","goose","gorilla","gospel","gossip","govern","gown",
33504 "grab","grace","grain","grant","grape","grass","gravity","great","green","grid",
33505 "grief","grit","grocery","group","grow","grunt","guard","guess","guide","guilt",
33506 "guitar","gun","gym","habit","hair","half","hammer","hamster","hand","happy",
33507 "harbor","hard","harsh","harvest","hat","have","hawk","hazard","head","health",
33508 "heart","heavy","hedgehog","height","hello","helmet","help","hen","hero","hidden",
33509 "high","hill","hint","hip","hire","history","hobby","hockey","hold","hole",
33510 "holiday","hollow","home","honey","hood","hope","horn","horror","horse","hospital",
33511 "host","hotel","hour","hover","hub","huge","human","humble","humor","hundred",
33512 "hungry","hunt","hurdle","hurry","hurt","husband","hybrid","ice","icon","idea",
33513 "identify","idle","ignore","ill","illegal","illness","image","imitate","immense","immune",
33514 "impact","impose","improve","impulse","inch","include","income","increase","index","indicate",
33515 "indoor","industry","infant","inflict","inform","inhale","inherit","initial","inject","injury",
33516 "inmate","inner","innocent","input","inquiry","insane","insect","inside","inspire","install",
33517 "intact","interest","into","invest","invite","involve","iron","island","isolate","issue",
33518 "item","ivory","jacket","jaguar","jar","jazz","jealous","jeans","jelly","jewel",
33519 "job","join","joke","journey","joy","judge","juice","jump","jungle","junior",
33520 "junk","just","kangaroo","keen","keep","ketchup","key","kick","kid","kidney",
33521 "kind","kingdom","kiss","kit","kitchen","kite","kitten","kiwi","knee","knife",
33522 "knock","know","lab","label","labor","ladder","lady","lake","lamp","language",
33523 "laptop","large","later","latin","laugh","laundry","lava","law","lawn","lawsuit",
33524 "layer","lazy","leader","leaf","learn","leave","lecture","left","leg","legal",
33525 "legend","leisure","lemon","lend","length","lens","leopard","lesson","letter","level",
33526 "liar","liberty","library","license","life","lift","light","like","limb","limit",
33527 "link","lion","liquid","list","little","live","lizard","load","loan","lobster",
33528 "local","lock","logic","lonely","long","loop","lottery","loud","lounge","love",
33529 "loyal","lucky","luggage","lumber","lunar","lunch","luxury","lyrics","machine","mad",
33530 "magic","magnet","maid","mail","main","major","make","mammal","man","manage",
33531 "mandate","mango","mansion","manual","maple","marble","march","margin","marine","market",
33532 "marriage","mask","mass","master","match","material","math","matrix","matter","maximum",
33533 "maze","meadow","mean","measure","meat","mechanic","medal","media","melody","melt",
33534 "member","memory","mention","menu","mercy","merge","merit","merry","mesh","message",
33535 "metal","method","middle","midnight","milk","million","mimic","mind","minimum","minor",
33536 "minute","miracle","mirror","misery","miss","mistake","mix","mixed","mixture","mobile",
33537 "model","modify","mom","moment","monitor","monkey","monster","month","moon","moral",
33538 "more","morning","mosquito","mother","motion","motor","mountain","mouse","move","movie",
33539 "much","muffin","mule","multiply","muscle","museum","mushroom","music","must","mutual",
33540 "myself","mystery","myth","naive","name","napkin","narrow","nasty","nation","nature",
33541 "near","neck","need","negative","neglect","neither","nephew","nerve","nest","net",
33542 "network","neutral","never","news","next","nice","night","noble","noise","nominee",
33543 "noodle","normal","north","nose","notable","note","nothing","notice","novel","now",
33544 "nuclear","number","nurse","nut","oak","obey","object","oblige","obscure","observe",
33545 "obtain","obvious","occur","ocean","october","odor","off","offer","office","often",
33546 "oil","okay","old","olive","olympic","omit","once","one","onion","online",
33547 "only","open","opera","opinion","oppose","option","orange","orbit","orchard","order",
33548 "ordinary","organ","orient","original","orphan","ostrich","other","outdoor","outer","output",
33549 "outside","oval","oven","over","own","owner","oxygen","oyster","ozone","pact",
33550 "paddle","page","pair","palace","palm","panda","panel","panic","panther","paper",
33551 "parade","parent","park","parrot","party","pass","patch","path","patient","patrol",
33552 "pattern","pause","pave","payment","peace","peanut","pear","peasant","pelican","pen",
33553 "penalty","pencil","people","pepper","perfect","permit","person","pet","phone","photo",
33554 "phrase","physical","piano","picnic","picture","piece","pig","pigeon","pill","pilot",
33555 "pink","pioneer","pipe","pistol","pitch","pizza","place","planet","plastic","plate",
33556 "play","please","pledge","pluck","plug","plunge","poem","poet","point","polar",
33557 "pole","police","pond","pony","pool","popular","portion","position","possible","post",
33558 "potato","pottery","poverty","powder","power","practice","praise","predict","prefer","prepare",
33559 "present","pretty","prevent","price","pride","primary","print","priority","prison","private",
33560 "prize","problem","process","produce","profit","program","project","promote","proof","property",
33561 "prosper","protect","proud","provide","public","pudding","pull","pulp","pulse","pumpkin",
33562 "punch","pupil","puppy","purchase","purity","purpose","purse","push","put","puzzle",
33563 "pyramid","quality","quantum","quarter","question","quick","quit","quiz","quote","rabbit",
33564 "raccoon","race","rack","radar","radio","rail","rain","raise","rally","ramp",
33565 "ranch","random","range","rapid","rare","rate","rather","raven","raw","razor",
33566 "ready","real","reason","rebel","rebuild","recall","receive","recipe","record","recycle",
33567 "reduce","reflect","reform","refuse","region","regret","regular","reject","relax","release",
33568 "relief","rely","remain","remember","remind","remove","render","renew","rent","reopen",
33569 "repair","repeat","replace","report","require","rescue","resemble","resist","resource","response",
33570 "result","retire","retreat","return","reunion","reveal","review","reward","rhythm","rib",
33571 "ribbon","rice","rich","ride","ridge","rifle","right","rigid","ring","riot",
33572 "ripple","risk","ritual","rival","river","road","roast","robot","robust","rocket",
33573 "romance","roof","rookie","room","rose","rotate","rough","round","route","royal",
33574 "rubber","rude","rug","rule","run","runway","rural","sad","saddle","sadness",
33575 "safe","sail","salad","salmon","salon","salt","salute","same","sample","sand",
33576 "satisfy","satoshi","sauce","sausage","save","say","scale","scan","scare","scatter",
33577 "scene","scheme","school","science","scissors","scorpion","scout","scrap","screen","script",
33578 "scrub","sea","search","season","seat","second","secret","section","security","seed",
33579 "seek","segment","select","sell","seminar","senior","sense","sentence","series","service",
33580 "session","settle","setup","seven","shadow","shaft","shallow","share","shed","shell",
33581 "sheriff","shield","shift","shine","ship","shiver","shock","shoe","shoot","shop",
33582 "short","shoulder","shove","shrimp","shrug","shuffle","shy","sibling","sick","side",
33583 "siege","sight","sign","silent","silk","silly","silver","similar","simple","since",
33584 "sing","siren","sister","situate","six","size","skate","sketch","ski","skill",
33585 "skin","skirt","skull","slab","slam","sleep","slender","slice","slide","slight",
33586 "slim","slogan","slot","slow","slush","small","smart","smile","smoke","smooth",
33587 "snack","snake","snap","sniff","snow","soap","soccer","social","sock","soda",
33588 "soft","solar","soldier","solid","solution","solve","someone","song","soon","sorry",
33589 "sort","soul","sound","soup","source","south","space","spare","spatial","spawn",
33590 "speak","special","speed","spell","spend","sphere","spice","spider","spike","spin",
33591 "spirit","split","spoil","sponsor","spoon","sport","spot","spray","spread","spring",
33592 "spy","square","squeeze","squirrel","stable","stadium","staff","stage","stairs","stamp",
33593 "stand","start","state","stay","steak","steel","stem","step","stereo","stick",
33594 "still","sting","stock","stomach","stone","stool","story","stove","strategy","street",
33595 "strike","strong","struggle","student","stuff","stumble","style","subject","submit","subway",
33596 "success","such","sudden","suffer","sugar","suggest","suit","summer","sun","sunny",
33597 "sunset","super","supply","supreme","sure","surface","surge","surprise","surround","survey",
33598 "suspect","sustain","swallow","swamp","swap","swarm","swear","sweet","swift","swim",
33599 "swing","switch","sword","symbol","symptom","syrup","system","table","tackle","tag",
33600 "tail","talent","talk","tank","tape","target","task","taste","tattoo","taxi",
33601 "teach","team","tell","ten","tenant","tennis","tent","term","test","text",
33602 "thank","that","theme","then","theory","there","they","thing","this","thought",
33603 "three","thrive","throw","thumb","thunder","ticket","tide","tiger","tilt","timber",
33604 "time","tiny","tip","tired","tissue","title","toast","tobacco","today","toddler",
33605 "toe","together","toilet","token","tomato","tomorrow","tone","tongue","tonight","tool",
33606 "tooth","top","topic","topple","torch","tornado","tortoise","toss","total","tourist",
33607 "toward","tower","town","toy","track","trade","traffic","tragic","train","transfer",
33608 "trap","trash","travel","tray","treat","tree","trend","trial","tribe","trick",
33609 "trigger","trim","trip","trophy","trouble","truck","true","truly","trumpet","trust",
33610 "truth","try","tube","tuition","tumble","tuna","tunnel","turkey","turn","turtle",
33611 "twelve","twenty","twice","twin","twist","two","type","typical","ugly","umbrella",
33612 "unable","unaware","uncle","uncover","under","undo","unfair","unfold","unhappy","uniform",
33613 "unique","unit","universe","unknown","unlock","until","unusual","unveil","update","upgrade",
33614 "uphold","upon","upper","upset","urban","urge","usage","use","used","useful",
33615 "useless","usual","utility","vacant","vacuum","vague","valid","valley","valve","van",
33616 "vanish","vapor","various","vast","vault","vehicle","velvet","vendor","venture","venue",
33617 "verb","verify","version","very","vessel","veteran","viable","vibrant","vicious","victory",
33618 "video","view","village","vintage","violin","virtual","virus","visa","visit","visual",
33619 "vital","vivid","vocal","voice","void","volcano","volume","vote","voyage","wage",
33620 "wagon","wait","walk","wall","walnut","want","warfare","warm","warrior","wash",
33621 "wasp","waste","water","wave","way","wealth","weapon","wear","weasel","weather",
33622 "web","wedding","weekend","weird","welcome","west","wet","whale","what","wheat",
33623 "wheel","when","where","whip","whisper","wide","width","wife","wild","will",
33624 "win","window","wine","wing","wink","winner","winter","wire","wisdom","wise",
33625 "wish","witness","wolf","woman","wonder","wood","wool","word","work","world",
33626 "worry","worth","wrap","wreck","wrestle","wrist","write","wrong","yard","year",
33627 "yellow","you","young","youth","zebra","zero","zone","zoo"]
33628 </script>
33629 <script>
33630 /*
33631 * Copyright (c) 2013 Pavol Rusnak
33632 *
33633 * Permission is hereby granted, free of charge, to any person obtaining a copy of
33634 * this software and associated documentation files (the "Software"), to deal in
33635 * the Software without restriction, including without limitation the rights to
33636 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
33637 * of the Software, and to permit persons to whom the Software is furnished to do
33638 * so, subject to the following conditions:
33639 *
33640 * The above copyright notice and this permission notice shall be included in all
33641 * copies or substantial portions of the Software.
33642 *
33643 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33644 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33645 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33646 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
33647 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33648 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33649 */
33650
33651 /*
33652 * Javascript port from python by Ian Coleman
33653 *
33654 * Requires code from sjcl
33655 * https://github.com/bitwiseshiftleft/sjcl
33656 */
33657
33658 var Mnemonic = function(language) {
33659
33660 var PBKDF2_ROUNDS = 2048;
33661 var RADIX = 2048;
33662
33663 var self = this;
33664 var wordlist = [];
33665
33666 var hmacSHA512 = function(key) {
33667 var hasher = new sjcl.misc.hmac(key, sjcl.hash.sha512);
33668 this.encrypt = function() {
33669 return hasher.encrypt.apply(hasher, arguments);
33670 };
33671 };
33672
33673 function init() {
33674 wordlist = WORDLISTS[language];
33675 if (wordlist.length != RADIX) {
33676 err = 'Wordlist should contain ' + RADIX + ' words, but it contains ' + wordlist.length + ' words.';
33677 throw err;
33678 }
33679 }
33680
33681 self.generate = function(strength) {
33682 strength = strength || 128;
33683 var r = strength % 32;
33684 if (r > 0) {
33685 throw 'Strength should be divisible by 32, but it is not (' + r + ').';
33686 }
33687 var hasStrongCrypto = 'crypto' in window && window['crypto'] !== null;
33688 if (!hasStrongCrypto) {
33689 throw 'Mnemonic should be generated with strong randomness, but crypto.getRandomValues is unavailable';
33690 }
33691 var buffer = new Uint8Array(strength / 8);
33692 var data = crypto.getRandomValues(buffer);
33693 return self.toMnemonic(data);
33694 }
33695
33696 self.toMnemonic = function(byteArray) {
33697 if (byteArray.length % 4 > 0) {
33698 throw 'Data length in bits should be divisible by 32, but it is not (' + byteArray.length + ' bytes = ' + byteArray.length*8 + ' bits).'
33699 }
33700
33701 //h = hashlib.sha256(data).hexdigest()
33702 var data = byteArrayToWordArray(byteArray);
33703 var hash = sjcl.hash.sha256.hash(data);
33704 var h = sjcl.codec.hex.fromBits(hash);
33705
33706 // b is a binary string, eg '00111010101100...'
33707 //b = bin(int(binascii.hexlify(data), 16))[2:].zfill(len(data) * 8) + \
33708 // bin(int(h, 16))[2:].zfill(256)[:len(data) * 8 / 32]
33709 //
33710 // a = bin(int(binascii.hexlify(data), 16))[2:].zfill(len(data) * 8)
33711 // c = bin(int(h, 16))[2:].zfill(256)
33712 // d = c[:len(data) * 8 / 32]
33713 var a = byteArrayToBinaryString(byteArray);
33714 var c = zfill(hexStringToBinaryString(h), 256);
33715 var d = c.substring(0, byteArray.length * 8 / 32);
33716 // b = line1 + line2
33717 var b = a + d;
33718
33719 var result = [];
33720 var blen = b.length / 11;
33721 for (var i=0; i<blen; i++) {
33722 var idx = parseInt(b.substring(i * 11, (i + 1) * 11), 2);
33723 result.push(wordlist[idx]);
33724 }
33725 return result.join(' ');
33726 }
33727
33728 self.check = function(mnemonic) {
33729 var mnemonic = mnemonic.split(' ')
33730 if (mnemonic.length % 3 > 0) {
33731 return false
33732 }
33733 // idx = map(lambda x: bin(self.wordlist.index(x))[2:].zfill(11), mnemonic)
33734 var idx = [];
33735 for (var i=0; i<mnemonic.length; i++) {
33736 var word = mnemonic[i];
33737 var wordIndex = wordlist.indexOf(word);
33738 if (wordIndex == -1) {
33739 return false;
33740 }
33741 var binaryIndex = zfill(wordIndex.toString(2), 11);
33742 idx.push(binaryIndex);
33743 }
33744 var b = idx.join('');
33745 var l = b.length;
33746 //d = b[:l / 33 * 32]
33747 //h = b[-l / 33:]
33748 var d = b.substring(0, l / 33 * 32);
33749 var h = b.substring(l - l / 33, l);
33750 //nd = binascii.unhexlify(hex(int(d, 2))[2:].rstrip('L').zfill(l / 33 * 8))
33751 var nd = binaryStringToWordArray(d);
33752 //nh = bin(int(hashlib.sha256(nd).hexdigest(), 16))[2:].zfill(256)[:l / 33]
33753 var ndHash = sjcl.hash.sha256.hash(nd);
33754 var ndHex = sjcl.codec.hex.fromBits(ndHash);
33755 var ndBstr = zfill(hexStringToBinaryString(ndHex), 256);
33756 var nh = ndBstr.substring(0,l/33);
33757 return h == nh;
33758 }
33759
33760 self.toSeed = function(mnemonic, passphrase) {
33761 passphrase = passphrase || '';
33762 mnemonic = self.normalizeString(mnemonic)
33763 passphrase = self.normalizeString(passphrase)
33764 passphrase = "mnemonic" + passphrase;
33765 var mnemonicBits = sjcl.codec.utf8String.toBits(mnemonic);
33766 var passphraseBits = sjcl.codec.utf8String.toBits(passphrase);
33767 var result = sjcl.misc.pbkdf2(mnemonicBits, passphraseBits, PBKDF2_ROUNDS, 512, hmacSHA512);
33768 var hashHex = sjcl.codec.hex.fromBits(result);
33769 return hashHex;
33770 }
33771
33772 self.normalizeString = function(str) {
33773 if (typeof str.normalize == "function") {
33774 return str.normalize("NFKD");
33775 }
33776 else {
33777 // TODO decide how to handle this in the future.
33778 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
33779 return str;
33780 }
33781 }
33782
33783 function byteArrayToWordArray(data) {
33784 var a = [];
33785 for (var i=0; i<data.length/4; i++) {
33786 v = 0;
33787 v += data[i*4 + 0] << 8 * 3;
33788 v += data[i*4 + 1] << 8 * 2;
33789 v += data[i*4 + 2] << 8 * 1;
33790 v += data[i*4 + 3] << 8 * 0;
33791 a.push(v);
33792 }
33793 return a;
33794 }
33795
33796 function byteArrayToBinaryString(data) {
33797 var bin = "";
33798 for (var i=0; i<data.length; i++) {
33799 bin += zfill(data[i].toString(2), 8);
33800 }
33801 return bin;
33802 }
33803
33804 function hexStringToBinaryString(hexString) {
33805 binaryString = "";
33806 for (var i=0; i<hexString.length; i++) {
33807 binaryString += zfill(parseInt(hexString[i], 16).toString(2),4);
33808 }
33809 return binaryString;
33810 }
33811
33812 function binaryStringToWordArray(binary) {
33813 var aLen = binary.length / 32;
33814 var a = [];
33815 for (var i=0; i<aLen; i++) {
33816 var valueStr = binary.substring(0,32);
33817 var value = parseInt(valueStr, 2);
33818 a.push(value);
33819 binary = binary.slice(32);
33820 }
33821 return a;
33822 }
33823
33824 // Pad a numeric string on the left with zero digits until the given width
33825 // is reached.
33826 // Note this differs to the python implementation because it does not
33827 // handle numbers starting with a sign.
33828 function zfill(source, length) {
33829 source = source.toString();
33830 while (source.length < length) {
33831 source = '0' + source;
33832 }
33833 return source;
33834 }
33835
33836 init();
33837
33838 }
33839 </script>
33840 <script>
33841 (function() {
33842
33843 var mnemonic = new Mnemonic("english");
33844 var bip32RootKey = null;
33845 var bip32ExtendedKey = null;
33846 var network = Bitcoin.networks.bitcoin;
33847 var addressRowTemplate = $("#address-row-template");
33848
33849 var showIndex = true;
33850 var showAddress = true;
33851 var showPrivKey = true;
33852
33853 var phraseChangeTimeoutEvent = null;
33854
33855 var DOM = {};
33856 DOM.network = $(".network");
33857 DOM.phraseNetwork = $("#network-phrase");
33858 DOM.bip44Network = $("#network-bip44");
33859 DOM.addressNetwork = $("#network-address-type");
33860 DOM.phrase = $(".phrase");
33861 DOM.passphrase = $(".passphrase");
33862 DOM.generate = $(".generate");
33863 DOM.rootKey = $(".root-key");
33864 DOM.extendedPrivKey = $(".extended-priv-key");
33865 DOM.extendedPubKey = $(".extended-pub-key");
33866 DOM.bip32tab = $("#bip32-tab");
33867 DOM.bip44tab = $("#bip44-tab");
33868 DOM.bip32panel = $("#bip32");
33869 DOM.bip44panel = $("#bip44");
33870 DOM.bip32path = $("#bip32-path");
33871 DOM.bip44path = $("#bip44-path");
33872 DOM.bip44purpose = $("#bip44 .purpose");
33873 DOM.bip44coin = $("#bip44 .coin");
33874 DOM.bip44account = $("#bip44 .account");
33875 DOM.bip44change = $("#bip44 .change");
33876 DOM.strength = $(".strength");
33877 DOM.addresses = $(".addresses");
33878 DOM.rowsToAdd = $(".rows-to-add");
33879 DOM.more = $(".more");
33880 DOM.feedback = $(".feedback");
33881 DOM.tab = $(".derivation-type a");
33882 DOM.indexToggle = $(".index-toggle");
33883 DOM.addressToggle = $(".address-toggle");
33884 DOM.privateKeyToggle = $(".private-key-toggle");
33885
33886 var derivationPath = DOM.bip44path.val();
33887
33888 function init() {
33889 // Events
33890 DOM.network.on("change", networkChanged);
33891 DOM.phrase.on("input", delayedPhraseChanged);
33892 DOM.passphrase.on("input", delayedPhraseChanged);
33893 DOM.generate.on("click", generateClicked);
33894 DOM.more.on("click", showMore);
33895 DOM.bip32path.on("input", bip32Changed);
33896 DOM.bip44purpose.on("input", bip44Changed);
33897 DOM.bip44coin.on("input", bip44Changed);
33898 DOM.bip44account.on("input", bip44Changed);
33899 DOM.bip44change.on("input", bip44Changed);
33900 DOM.tab.on("click", tabClicked);
33901 DOM.indexToggle.on("click", toggleIndexes);
33902 DOM.addressToggle.on("click", toggleAddresses);
33903 DOM.privateKeyToggle.on("click", togglePrivateKeys);
33904 disableForms();
33905 hidePending();
33906 hideValidationError();
33907 }
33908
33909 // Event handlers
33910
33911 function networkChanged(e) {
33912 var n = e.target.value;
33913 if (n == "bitcoin") {
33914 network = Bitcoin.networks.bitcoin;
33915 DOM.bip44coin.val(0);
33916 setBip44DerivationPath();
33917 enableBip44Tab();
33918 }
33919 else if (n == "bitcoin-testnet") {
33920 network = Bitcoin.networks.testnet;
33921 DOM.bip44coin.val(1);
33922 setBip44DerivationPath();
33923 enableBip44Tab();
33924 }
33925 else if (n == "litecoin") {
33926 network = Bitcoin.networks.litecoin;
33927 DOM.bip44coin.val(2);
33928 setBip44DerivationPath();
33929 enableBip44Tab();
33930 }
33931 else if (n == "dogecoin") {
33932 network = Bitcoin.networks.dogecoin;
33933 //disableBip44Tab();
33934 }
33935 DOM.phraseNetwork.val(n);
33936 DOM.bip44Network.val(n);
33937 if(e.target != DOM.addressNetwork.dom){
33938 DOM.addressNetwork.val(n);
33939 }
33940 delayedPhraseChanged();
33941 }
33942
33943 function delayedPhraseChanged() {
33944 hideValidationError();
33945 showPending();
33946 if (phraseChangeTimeoutEvent != null) {
33947 clearTimeout(phraseChangeTimeoutEvent);
33948 }
33949 phraseChangeTimeoutEvent = setTimeout(phraseChanged, 400);
33950 }
33951
33952 function phraseChanged() {
33953 showPending();
33954 hideValidationError();
33955 // Get the mnemonic phrase
33956 var phrase = DOM.phrase.val();
33957 var passphrase = DOM.passphrase.val();
33958 var errorText = findPhraseErrors(phrase);
33959 if (errorText) {
33960 showValidationError(errorText);
33961 return;
33962 }
33963 // Get the derivation path
33964 var errorText = findDerivationPathErrors();
33965 if (errorText) {
33966 showValidationError(errorText);
33967 return;
33968 }
33969 // Calculate and display
33970 calcBip32Seed(phrase, passphrase, derivationPath);
33971 displayBip32Info();
33972 hidePending();
33973 }
33974
33975 function generateClicked() {
33976 clearDisplay();
33977 showPending();
33978 setTimeout(function() {
33979 var phrase = generateRandomPhrase();
33980 if (!phrase) {
33981 return;
33982 }
33983 phraseChanged();
33984 }, 50);
33985 }
33986
33987 function tabClicked(e) {
33988 var activePath = $(e.target.getAttribute("href") + " .path");
33989 derivationPath = activePath.val();
33990 derivationChanged();
33991 }
33992
33993 function derivationChanged() {
33994 delayedPhraseChanged();
33995 }
33996
33997 function bip32Changed() {
33998 derivationPath = DOM.bip32path.val();
33999 derivationChanged();
34000 }
34001
34002 function bip44Changed() {
34003 setBip44DerivationPath();
34004 derivationPath = DOM.bip44path.val();
34005 derivationChanged();
34006 }
34007
34008 function toggleIndexes() {
34009 showIndex = !showIndex;
34010 $("td.index span").toggleClass("invisible");
34011 }
34012
34013 function toggleAddresses() {
34014 showAddress = !showAddress;
34015 $("td.address span").toggleClass("invisible");
34016 }
34017
34018 function togglePrivateKeys() {
34019 showPrivKey = !showPrivKey;
34020 $("td.privkey span").toggleClass("invisible");
34021 }
34022
34023 // Private methods
34024
34025 function generateRandomPhrase() {
34026 if (!hasStrongRandom()) {
34027 var errorText = "This browser does not support strong randomness";
34028 showValidationError(errorText);
34029 return;
34030 }
34031 var numWords = parseInt(DOM.strength.val());
34032 // Check strength is an integer
34033 if (isNaN(numWords)) {
34034 DOM.strength.val("12");
34035 numWords = 12;
34036 }
34037 // Check strength is a multiple of 32, if not round it down
34038 if (numWords % 3 != 0) {
34039 numWords = Math.floor(numWords / 3) * 3;
34040 DOM.strength.val(numWords);
34041 }
34042 // Check strength is at least 32
34043 if (numWords == 0) {
34044 numWords = 3;
34045 DOM.strength.val(numWords);
34046 }
34047 var strength = numWords / 3 * 32;
34048 var words = mnemonic.generate(strength);
34049 DOM.phrase.val(words);
34050 return words;
34051 }
34052
34053 function calcBip32Seed(phrase, passphrase, path) {
34054 var seed = mnemonic.toSeed(phrase, passphrase);
34055 bip32RootKey = Bitcoin.HDNode.fromSeedHex(seed, network);
34056 bip32ExtendedKey = bip32RootKey;
34057 // Derive the key from the path
34058 var pathBits = path.split("/");
34059 for (var i=0; i<pathBits.length; i++) {
34060 var bit = pathBits[i];
34061 var index = parseInt(bit);
34062 if (isNaN(index)) {
34063 continue;
34064 }
34065 var hardened = bit[bit.length-1] == "'";
34066 if (hardened) {
34067 bip32ExtendedKey = bip32ExtendedKey.deriveHardened(index);
34068 }
34069 else {
34070 bip32ExtendedKey = bip32ExtendedKey.derive(index);
34071 }
34072 }
34073 }
34074
34075 function showValidationError(errorText) {
34076 DOM.feedback
34077 .text(errorText)
34078 .show();
34079 }
34080
34081 function hideValidationError() {
34082 DOM.feedback
34083 .text("")
34084 .hide();
34085 }
34086
34087 function findPhraseErrors(phrase) {
34088 // TODO make this right
34089 // Preprocess the words
34090 phrase = mnemonic.normalizeString(phrase);
34091 var parts = phrase.split(" ");
34092 var proper = [];
34093 for (var i=0; i<parts.length; i++) {
34094 var part = parts[i];
34095 if (part.length > 0) {
34096 // TODO check that lowercasing is always valid to do
34097 proper.push(part.toLowerCase());
34098 }
34099 }
34100 // TODO some levenstein on the words
34101 var properPhrase = proper.join(' ');
34102 // Check the words are valid
34103 var isValid = mnemonic.check(properPhrase);
34104 if (!isValid) {
34105 return "Invalid mnemonic";
34106 }
34107 return false;
34108 }
34109
34110 function findDerivationPathErrors(path) {
34111 // TODO
34112 return false;
34113 }
34114
34115 function displayBip32Info() {
34116 // Display the key
34117 var rootKey = bip32RootKey.toBase58();
34118 DOM.rootKey.val(rootKey);
34119 var extendedPrivKey = bip32ExtendedKey.toBase58();
34120 DOM.extendedPrivKey.val(extendedPrivKey);
34121 var extendedPubKey = bip32ExtendedKey.toBase58(false);
34122 DOM.extendedPubKey.val(extendedPubKey);
34123 // Display the addresses and privkeys
34124 clearAddressesList();
34125 displayAddresses(0, 20);
34126 }
34127
34128 function displayAddresses(start, total) {
34129 for (var i=0; i<total; i++) {
34130 var index = i + start;
34131 new TableRow(index);
34132 }
34133 }
34134
34135 function TableRow(index) {
34136
34137 function init() {
34138 calculateValues();
34139 }
34140
34141 function calculateValues() {
34142 setTimeout(function() {
34143 var key = bip32ExtendedKey.derive(index);
34144 var address = key.getAddress().toString();
34145 var privkey = key.privKey.toWIF(network);
34146 addAddressToList(index, address, privkey);
34147 }, 50)
34148 }
34149
34150 init();
34151
34152 }
34153
34154 function showMore() {
34155 var start = DOM.addresses.children().length;
34156 var rowsToAdd = parseInt(DOM.rowsToAdd.val());
34157 if (isNaN(rowsToAdd)) {
34158 rowsToAdd = 20;
34159 DOM.rowsToAdd.val("20");
34160 }
34161 if (rowsToAdd > 200) {
34162 var msg = "Generating " + rowsToAdd + " rows could take a while. ";
34163 msg += "Do you want to continue?";
34164 if (!confirm(msg)) {
34165 return;
34166 }
34167 }
34168 displayAddresses(start, rowsToAdd);
34169 }
34170
34171 function clearDisplay() {
34172 clearAddressesList();
34173 clearKey();
34174 hideValidationError();
34175 }
34176
34177 function clearAddressesList() {
34178 DOM.addresses.empty();
34179 }
34180
34181 function clearKey() {
34182 DOM.rootKey.val("");
34183 DOM.extendedPrivKey.val("");
34184 DOM.extendedPubKey.val("");
34185 }
34186
34187 function addAddressToList(index, address, privkey) {
34188 var row = $(addressRowTemplate.html());
34189 // Elements
34190 var indexCell = row.find(".index span");
34191 var addressCell = row.find(".address span");
34192 var privkeyCell = row.find(".privkey span");
34193 // Content
34194 indexCell.text(index);
34195 addressCell.text(address);
34196 privkeyCell.text(privkey);
34197 // Visibility
34198 if (!showIndex) {
34199 indexCell.addClass("invisible");
34200 }
34201 if (!showAddress) {
34202 addressCell.addClass("invisible");
34203 }
34204 if (!showPrivKey) {
34205 privkeCell.addClass("invisible");
34206 }
34207 DOM.addresses.append(row);
34208 }
34209
34210 function hasStrongRandom() {
34211 return 'crypto' in window && window['crypto'] !== null;
34212 }
34213
34214 function disableForms() {
34215 $("form").on("submit", function(e) {
34216 e.preventDefault();
34217 });
34218 }
34219
34220 function setBip44DerivationPath() {
34221 var purpose = parseIntNoNaN(DOM.bip44purpose.val(), 44);
34222 var coin = parseIntNoNaN(DOM.bip44coin.val(), 0);
34223 var account = parseIntNoNaN(DOM.bip44account.val(), 0);
34224 var change = parseIntNoNaN(DOM.bip44change.val(), 0);
34225 var path = "m/";
34226 path += purpose + "'/";
34227 path += coin + "'/";
34228 path += account + "'/";
34229 path += change;
34230 DOM.bip44path.val(path);
34231 }
34232
34233 function parseIntNoNaN(val, defaultVal) {
34234 var v = parseInt(val);
34235 if (isNaN(v)) {
34236 return defaultVal;
34237 }
34238 return v;
34239 }
34240
34241 function showPending() {
34242 DOM.feedback
34243 .text("Calculating...")
34244 .show();
34245 }
34246
34247 function hidePending() {
34248 DOM.feedback
34249 .text("")
34250 .hide();
34251 }
34252
34253 function enableBip44Tab() {
34254 // show bip44 tab (but don't select it)
34255 DOM.bip44tab.removeClass("hidden");
34256 DOM.bip44panel.removeClass("hidden");
34257 }
34258
34259 function disableBip44Tab() {
34260 // hide bip44 tab
34261 DOM.bip44tab.addClass("hidden");
34262 DOM.bip44tab.removeClass("active");
34263 // hide bip44 panel
34264 DOM.bip44panel.addClass("hidden");
34265 DOM.bip44panel.removeClass("active");
34266 // show bip32 tab
34267 DOM.bip32tab.addClass("active");
34268 // show bip32 panel
34269 DOM.bip32panel.addClass("active");
34270 // set the derivation path
34271 var activePath = $("#bip32 .path");
34272 derivationPath = activePath.val();
34273 }
34274
34275 init();
34276
34277 })();
34278 </script>
34279 </body>
34280 </html>