Skip to content

Instantly share code, notes, and snippets.

@t2psyto
Last active December 28, 2017 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t2psyto/e3e3eeb114f8260c404d35cd6f9544e5 to your computer and use it in GitHub Desktop.
Save t2psyto/e3e3eeb114f8260c404d35cd6f9544e5 to your computer and use it in GitHub Desktop.
This file has been truncated, but you can view the full file.
// brython.js brython.info
// version [3, 3, 0, 'alpha', 0]
// implementation [3, 3, 5, 'dev', 0]
// version compiled from commented, indented source files at
// github.com/brython-dev/brython
!function(r,n){"use strict";function t(r,n,t,e){for(t=void 0!==t?t:0,e=void 0!==e?e:r.length;e>t;){var c=e+t>>1;r[c]>n?e=c:t=c+1}return t}function e(r){if(35>r)return r;var n=t(K,r);return L[n]}function c(r){var n=t(M,r);return N[n]}function u(r){switch(r.charCodeAt(0)){case 9:case 10:case 11:case 12:case 13:case 28:case 29:case 30:case 31:case 32:case 133:case 160:case 5760:case 8192:case 8193:case 8194:case 8195:case 8196:case 8197:case 8198:case 8199:case 8200:case 8201:case 8202:case 8232:case 8233:case 8239:case 8287:case 12288:return!0}return!1}function a(r){var n;return r>=1114112?n=0:(n=e(r>>J),n=c((n<<J)+(r&(1<<J)-1))),y[n]}function i(r,n){for(var t="",e=0;n>e;e++)t+=String.fromCharCode(I[r+e]);return t}function o(r){var n=r.charCodeAt(0),t=a(n);return 0!=(t[H]&T)}function f(r){var n=r.charCodeAt(0),t=a(n);return 0!=(t[H]&V)}function h(r){var n=r.charCodeAt(0),t=a(n);return 0!=(t[H]&W)}function v(r){var n=r.charCodeAt(0),t=a(n);return t[H]&P?t[F]:-1}function s(r){return v(r)<0?0:1}function d(r){var n=r.charCodeAt(0),t=a(n);return t[H]&Q?t[G]:-1}function A(r){return d(r)<0?0:1}function l(r){var n=r.charCodeAt(0),t=a(n);return 0!=(t[H]&Y)}function C(r){var n=r.charCodeAt(0),t=a(n);return 0!=(t[H]&X)}function g(r){var n=r.charCodeAt(0),t=a(n);return 0!=(t[H]&R)}function p(r){var n=r.charCodeAt(0),t=a(n);return 0!=(t[H]&U)}function m(r){var n=r.charCodeAt(0),t=a(n);return t[H]&rn?i(65535&t[D],t[D]>>24):String.fromCharCode(n+t[D])}function S(r){var n=r.charCodeAt(0),t=a(n);return t[H]&rn?i(65535&t[E],t[E]>>24):String.fromCharCode(n+t[E])}function w(r){var n=r.charCodeAt(0),t=a(n);return t[H]&rn?i(65535&t[B],t[B]>>24):String.fromCharCode(n+t[B])}function b(r){var n=r.charCodeAt(0),t=a(n);if(t[H]&rn&&t[D]>>20&7){var e=(65535&t[D])+(t[D]>>24),c=t[D]>>20&7;return i(e,c)}return m(r)}function z(r){var n=r.charCodeAt(0),t=a(n);return 0!=(t[H]&$)}function _(r){var n=r.charCodeAt(0),t=a(n);return 0!=(t[H]&Z)}function j(r){var n=r.charCodeAt(0),t=a(n);return 0!=(t[H]&O)}function k(r){return j(r)||s(r)||A(r)||l(r)}function q(r,n){var t,e;for(t=n-1;t>=0&&(e=r.charAt(t),_(e));t--);var c=t>=0&&z(e);if(c){for(t=n+1;r.length>t&&(e=r.charAt(t),_(e));t++);c=t==r.length||!z(e)}return String.fromCharCode(c?962:963)}function x(r,n,t){return 931==r.charCodeAt(0)?q(n,t):m(r)}n.unicode=r;var y=[[0,0,0,0,0,0],[0,0,0,0,0,0],[0,0,0,0,0,32],[0,0,0,0,0,48],[0,0,0,0,0,1056],[0,0,0,0,0,1024],[0,0,0,0,0,5120],[0,0,0,0,0,3590],[0,0,0,1,1,3590],[0,0,0,2,2,3590],[0,0,0,3,3,3590],[0,0,0,4,4,3590],[0,0,0,5,5,3590],[0,0,0,6,6,3590],[0,0,0,7,7,3590],[0,0,0,8,8,3590],[0,0,0,9,9,3590],[0,32,0,0,0,10113],[0,0,0,0,0,1536],[-32,0,-32,0,0,9993],[0,0,0,0,0,9993],[0,0,0,0,0,4096],[0,0,0,0,2,3076],[0,0,0,0,3,3076],[16777218,17825792,16777218,0,0,26377],[0,0,0,0,0,5632],[0,0,0,0,1,3076],[0,0,0,0,0,3072],[33554438,18874371,33554440,0,0,26377],[121,0,121,0,0,9993],[0,1,0,0,0,10113],[-1,0,-1,0,0,9993],[16777228,33554442,16777228,0,0,26497],[-232,0,-232,0,0,9993],[33554448,18874381,33554448,0,0,26377],[0,-121,0,0,0,10113],[16777236,17825810,16777236,0,0,26377],[195,0,195,0,0,9993],[0,210,0,0,0,10113],[0,206,0,0,0,10113],[0,205,0,0,0,10113],[0,79,0,0,0,10113],[0,202,0,0,0,10113],[0,203,0,0,0,10113],[0,207,0,0,0,10113],[97,0,97,0,0,9993],[0,211,0,0,0,10113],[0,209,0,0,0,10113],[163,0,163,0,0,9993],[0,213,0,0,0,10113],[130,0,130,0,0,9993],[0,214,0,0,0,10113],[0,218,0,0,0,10113],[0,217,0,0,0,10113],[0,219,0,0,0,10113],[0,0,0,0,0,1793],[56,0,56,0,0,9993],[0,2,1,0,0,10113],[-1,1,0,0,0,10049],[-2,0,-1,0,0,9993],[-79,0,-79,0,0,9993],[33554456,18874389,33554456,0,0,26377],[0,-97,0,0,0,10113],[0,-56,0,0,0,10113],[0,-130,0,0,0,10113],[0,10795,0,0,0,10113],[0,-163,0,0,0,10113],[0,10792,0,0,0,10113],[10815,0,10815,0,0,9993],[0,-195,0,0,0,10113],[0,69,0,0,0,10113],[0,71,0,0,0,10113],[10783,0,10783,0,0,9993],[10780,0,10780,0,0,9993],[10782,0,10782,0,0,9993],[-210,0,-210,0,0,9993],[-206,0,-206,0,0,9993],[-205,0,-205,0,0,9993],[-202,0,-202,0,0,9993],[-203,0,-203,0,0,9993],[42319,0,42319,0,0,9993],[42315,0,42315,0,0,9993],[-207,0,-207,0,0,9993],[42280,0,42280,0,0,9993],[42308,0,42308,0,0,9993],[-209,0,-209,0,0,9993],[-211,0,-211,0,0,9993],[10743,0,10743,0,0,9993],[42305,0,42305,0,0,9993],[10749,0,10749,0,0,9993],[-213,0,-213,0,0,9993],[-214,0,-214,0,0,9993],[10727,0,10727,0,0,9993],[-218,0,-218,0,0,9993],[42282,0,42282,0,0,9993],[-69,0,-69,0,0,9993],[-217,0,-217,0,0,9993],[-71,0,-71,0,0,9993],[-219,0,-219,0,0,9993],[42261,0,42261,0,0,9993],[42258,0,42258,0,0,9993],[0,0,0,0,0,14089],[0,0,0,0,0,5889],[16777244,17825818,16777244,0,0,30216],[0,0,0,0,0,13321],[0,116,0,0,0,10113],[0,38,0,0,0,10113],[0,37,0,0,0,10113],[0,64,0,0,0,10113],[0,63,0,0,0,10113],[50331681,19922973,50331681,0,0,26377],[-38,0,-38,0,0,9993],[-37,0,-37,0,0,9993],[50331688,19922980,50331688,0,0,26377],[16777261,17825835,16777261,0,0,26377],[-64,0,-64,0,0,9993],[-63,0,-63,0,0,9993],[0,8,0,0,0,10113],[16777264,17825838,16777264,0,0,26377],[16777267,17825841,16777267,0,0,26377],[0,0,0,0,0,10113],[16777270,17825844,16777270,0,0,26377],[16777273,17825847,16777273,0,0,26377],[-8,0,-8,0,0,9993],[16777276,17825850,16777276,0,0,26377],[16777279,17825853,16777279,0,0,26377],[7,0,7,0,0,9993],[-116,0,-116,0,0,9993],[0,-60,0,0,0,10113],[16777282,17825856,16777282,0,0,26377],[0,-7,0,0,0,10113],[0,80,0,0,0,10113],[-80,0,-80,0,0,9993],[0,15,0,0,0,10113],[-15,0,-15,0,0,9993],[0,48,0,0,0,10113],[-48,0,-48,0,0,9993],[33554502,18874435,33554504,0,0,26377],[0,0,0,0,0,1537],[0,7264,0,0,0,10113],[0,0,0,0,1,3588],[0,0,0,0,2,3588],[0,0,0,0,3,3588],[0,0,0,0,4,3588],[0,0,0,0,5,3588],[0,0,0,0,6,3588],[0,0,0,0,7,3588],[0,0,0,0,8,3588],[0,0,0,0,9,3588],[16777292,17825866,16777292,0,0,26497],[16777295,17825869,16777295,0,0,26497],[16777298,17825872,16777298,0,0,26497],[16777301,17825875,16777301,0,0,26497],[16777304,17825878,16777304,0,0,26497],[16777307,17825881,16777307,0,0,26497],[16777310,17825884,16777310,0,0,26497],[16777313,17825887,16777313,0,0,26497],[16777316,17825890,16777316,0,0,26497],[16777319,17825893,16777319,0,0,26497],[16777322,17825896,16777322,0,0,26497],[16777325,17825899,16777325,0,0,26497],[16777328,17825902,16777328,0,0,26497],[16777331,17825905,16777331,0,0,26497],[16777334,17825908,16777334,0,0,26497],[16777337,17825911,16777337,0,0,26497],[16777340,17825914,16777340,0,0,26497],[16777343,17825917,16777343,0,0,26497],[16777346,17825920,16777346,0,0,26497],[16777349,17825923,16777349,0,0,26497],[16777352,17825926,16777352,0,0,26497],[16777355,17825929,16777355,0,0,26497],[16777358,17825932,16777358,0,0,26497],[16777361,17825935,16777361,0,0,26497],[16777364,17825938,16777364,0,0,26497],[16777367,17825941,16777367,0,0,26497],[16777370,17825944,16777370,0,0,26497],[16777373,17825947,16777373,0,0,26497],[16777376,17825950,16777376,0,0,26497],[16777379,17825953,16777379,0,0,26497],[16777382,17825956,16777382,0,0,26497],[16777385,17825959,16777385,0,0,26497],[16777388,17825962,16777388,0,0,26497],[16777391,17825965,16777391,0,0,26497],[16777394,17825968,16777394,0,0,26497],[16777397,17825971,16777397,0,0,26497],[16777400,17825974,16777400,0,0,26497],[16777403,17825977,16777403,0,0,26497],[16777406,17825980,16777406,0,0,26497],[16777409,17825983,16777409,0,0,26497],[16777412,17825986,16777412,0,0,26497],[16777415,17825989,16777415,0,0,26497],[16777418,17825992,16777418,0,0,26497],[16777421,17825995,16777421,0,0,26497],[16777424,17825998,16777424,0,0,26497],[16777427,17826001,16777427,0,0,26497],[16777430,17826004,16777430,0,0,26497],[16777433,17826007,16777433,0,0,26497],[16777436,17826010,16777436,0,0,26497],[16777439,17826013,16777439,0,0,26497],[16777442,17826016,16777442,0,0,26497],[16777445,17826019,16777445,0,0,26497],[16777448,17826022,16777448,0,0,26497],[16777451,17826025,16777451,0,0,26497],[16777454,17826028,16777454,0,0,26497],[16777457,17826031,16777457,0,0,26497],[16777460,17826034,16777460,0,0,26497],[16777463,17826037,16777463,0,0,26497],[16777466,17826040,16777466,0,0,26497],[16777469,17826043,16777469,0,0,26497],[16777472,17826046,16777472,0,0,26497],[16777475,17826049,16777475,0,0,26497],[16777478,17826052,16777478,0,0,26497],[16777481,17826055,16777481,0,0,26497],[16777484,17826058,16777484,0,0,26497],[16777487,17826061,16777487,0,0,26497],[16777490,17826064,16777490,0,0,26497],[16777493,17826067,16777493,0,0,26497],[16777496,17826070,16777496,0,0,26497],[16777499,17826073,16777499,0,0,26497],[16777502,17826076,16777502,0,0,26497],[16777505,17826079,16777505,0,0,26497],[16777508,17826082,16777508,0,0,26497],[16777511,17826085,16777511,0,0,26497],[16777514,17826088,16777514,0,0,26497],[16777517,17826091,16777517,0,0,26497],[16777520,17826094,16777520,0,0,26497],[16777523,17826097,16777523,0,0,26497],[16777526,17826100,16777526,0,0,26497],[16777529,17826103,16777529,0,0,26497],[16777532,17826106,16777532,0,0,26497],[16777535,17826109,16777535,0,0,26497],[16777538,17826112,16777538,0,0,26497],[16777541,17826115,16777541,0,0,26497],[16777544,17826118,16777544,0,0,26497],[16777547,17826121,16777547,0,0,26497],[16777550,17826124,16777550,0,0,26377],[16777553,17826127,16777553,0,0,26377],[16777556,17826130,16777556,0,0,26377],[16777559,17826133,16777559,0,0,26377],[16777562,17826136,16777562,0,0,26377],[16777565,17826139,16777565,0,0,26377],[0,0,0,0,0,3840],[35332,0,35332,0,0,9993],[3814,0,3814,0,0,9993],[33554785,18874718,33554785,0,0,26377],[33554790,18874723,33554790,0,0,26377],[33554795,18874728,33554795,0,0,26377],[33554800,18874733,33554800,0,0,26377],[33554805,18874738,33554805,0,0,26377],[16777593,17826167,16777593,0,0,26377],[16777597,18874746,16777597,0,0,26497],[8,0,8,0,0,9993],[0,-8,0,0,0,10113],[33554817,18874750,33554817,0,0,26377],[50332039,19923331,50332039,0,0,26377],[50332046,19923338,50332046,0,0,26377],[50332053,19923345,50332053,0,0,26377],[74,0,74,0,0,9993],[86,0,86,0,0,9993],[100,0,100,0,0,9993],[128,0,128,0,0,9993],[112,0,112,0,0,9993],[126,0,126,0,0,9993],[33554843,18874776,16777629,0,0,26377],[33554849,18874782,16777635,0,0,26377],[33554855,18874788,16777641,0,0,26377],[33554861,18874794,16777647,0,0,26377],[33554867,18874800,16777653,0,0,26377],[33554873,18874806,16777659,0,0,26377],[33554879,18874812,16777665,0,0,26377],[33554885,18874818,16777671,0,0,26377],[33554891,18874824,16777677,0,0,26433],[33554897,18874830,16777683,0,0,26433],[33554903,18874836,16777689,0,0,26433],[33554909,18874842,16777695,0,0,26433],[33554915,18874848,16777701,0,0,26433],[33554921,18874854,16777707,0,0,26433],[33554927,18874860,16777713,0,0,26433],[33554933,18874866,16777719,0,0,26433],[33554939,18874872,16777725,0,0,26377],[33554945,18874878,16777731,0,0,26377],[33554951,18874884,16777737,0,0,26377],[33554957,18874890,16777743,0,0,26377],[33554963,18874896,16777749,0,0,26377],[33554969,18874902,16777755,0,0,26377],[33554975,18874908,16777761,0,0,26377],[33554981,18874914,16777767,0,0,26377],[33554987,18874920,16777773,0,0,26433],[33554993,18874926,16777779,0,0,26433],[33554999,18874932,16777785,0,0,26433],[33555005,18874938,16777791,0,0,26433],[33555011,18874944,16777797,0,0,26433],[33555017,18874950,16777803,0,0,26433],[33555023,18874956,16777809,0,0,26433],[33555029,18874962,16777815,0,0,26433],[33555035,18874968,16777821,0,0,26377],[33555041,18874974,16777827,0,0,26377],[33555047,18874980,16777833,0,0,26377],[33555053,18874986,16777839,0,0,26377],[33555059,18874992,16777845,0,0,26377],[33555065,18874998,16777851,0,0,26377],[33555071,18875004,16777857,0,0,26377],[33555077,18875010,16777863,0,0,26377],[33555083,18875016,16777869,0,0,26433],[33555089,18875022,16777875,0,0,26433],[33555095,18875028,16777881,0,0,26433],[33555101,18875034,16777887,0,0,26433],[33555107,18875040,16777893,0,0,26433],[33555113,18875046,16777899,0,0,26433],[33555119,18875052,16777905,0,0,26433],[33555125,18875058,16777911,0,0,26433],[33555131,18875064,33555133,0,0,26377],[33555138,18875071,16777924,0,0,26377],[33555144,18875077,33555146,0,0,26377],[33555151,18875084,33555151,0,0,26377],[50332373,19923665,50332376,0,0,26377],[0,-74,0,0,0,10113],[33555166,18875099,16777952,0,0,26433],[16777955,17826529,16777955,0,0,26377],[33555175,18875108,33555177,0,0,26377],[33555182,18875115,16777968,0,0,26377],[33555188,18875121,33555190,0,0,26377],[33555195,18875128,33555195,0,0,26377],[50332417,19923709,50332420,0,0,26377],[0,-86,0,0,0,10113],[33555210,18875143,16777996,0,0,26433],[50332433,19923725,50332433,0,0,26377],[50332440,19923732,50332440,0,0,26377],[33555230,18875163,33555230,0,0,26377],[50332452,19923744,50332452,0,0,26377],[0,-100,0,0,0,10113],[50332459,19923751,50332459,0,0,26377],[50332466,19923758,50332466,0,0,26377],[33555256,18875189,33555256,0,0,26377],[33555261,18875194,33555261,0,0,26377],[50332483,19923775,50332483,0,0,26377],[0,-112,0,0,0,10113],[33555273,18875206,33555275,0,0,26377],[33555280,18875213,16778066,0,0,26377],[33555286,18875219,33555288,0,0,26377],[33555293,18875226,33555293,0,0,26377],[50332515,19923807,50332518,0,0,26377],[0,-128,0,0,0,10113],[0,-126,0,0,0,10113],[33555308,18875241,16778094,0,0,26433],[0,0,0,0,0,3076],[0,0,0,0,4,3076],[0,0,0,0,5,3076],[0,0,0,0,6,3076],[0,0,0,0,7,3076],[0,0,0,0,8,3076],[0,0,0,0,9,3076],[0,0,0,0,0,1792],[0,-7517,0,0,0,10113],[0,-8383,0,0,0,10113],[0,-8262,0,0,0,10113],[0,28,0,0,0,10113],[-28,0,-28,0,0,9993],[0,16,0,0,0,12160],[-16,0,-16,0,0,12040],[0,26,0,0,0,9344],[-26,0,-26,0,0,9224],[0,-10743,0,0,0,10113],[0,-3814,0,0,0,10113],[0,-10727,0,0,0,10113],[-10795,0,-10795,0,0,9993],[-10792,0,-10792,0,0,9993],[0,-10780,0,0,0,10113],[0,-10749,0,0,0,10113],[0,-10783,0,0,0,10113],[0,-10782,0,0,0,10113],[0,-10815,0,0,0,10113],[-7264,0,-7264,0,0,9993],[0,0,0,0,0,5121],[0,0,0,0,0,3841],[0,-35332,0,0,0,10113],[0,-42280,0,0,0,10113],[0,-42308,0,0,0,10113],[0,-42319,0,0,0,10113],[0,-42315,0,0,0,10113],[0,-42305,0,0,0,10113],[0,-42258,0,0,0,10113],[0,-42282,0,0,0,10113],[0,-42261,0,0,0,10113],[0,928,0,0,0,10113],[-928,0,-928,0,0,9993],[16778097,17826671,16778097,0,0,26377],[16778100,17826674,16778100,0,0,26377],[16778103,17826677,16778103,0,0,26377],[16778106,17826680,16778106,0,0,26377],[16778109,17826683,16778109,0,0,26377],[16778112,17826686,16778112,0,0,26377],[16778115,17826689,16778115,0,0,26377],[16778118,17826692,16778118,0,0,26377],[16778121,17826695,16778121,0,0,26377],[16778124,17826698,16778124,0,0,26377],[16778127,17826701,16778127,0,0,26377],[16778130,17826704,16778130,0,0,26377],[16778133,17826707,16778133,0,0,26377],[16778136,17826710,16778136,0,0,26377],[16778139,17826713,16778139,0,0,26377],[16778142,17826716,16778142,0,0,26377],[16778145,17826719,16778145,0,0,26377],[16778148,17826722,16778148,0,0,26377],[16778151,17826725,16778151,0,0,26377],[16778154,17826728,16778154,0,0,26377],[16778157,17826731,16778157,0,0,26377],[16778160,17826734,16778160,0,0,26377],[16778163,17826737,16778163,0,0,26377],[16778166,17826740,16778166,0,0,26377],[16778169,17826743,16778169,0,0,26377],[16778172,17826746,16778172,0,0,26377],[16778175,17826749,16778175,0,0,26377],[16778178,17826752,16778178,0,0,26377],[16778181,17826755,16778181,0,0,26377],[16778184,17826758,16778184,0,0,26377],[16778187,17826761,16778187,0,0,26377],[16778190,17826764,16778190,0,0,26377],[16778193,17826767,16778193,0,0,26377],[16778196,17826770,16778196,0,0,26377],[16778199,17826773,16778199,0,0,26377],[16778202,17826776,16778202,0,0,26377],[16778205,17826779,16778205,0,0,26377],[16778208,17826782,16778208,0,0,26377],[16778211,17826785,16778211,0,0,26377],[16778214,17826788,16778214,0,0,26377],[16778217,17826791,16778217,0,0,26377],[16778220,17826794,16778220,0,0,26377],[16778223,17826797,16778223,0,0,26377],[16778226,17826800,16778226,0,0,26377],[16778229,17826803,16778229,0,0,26377],[16778232,17826806,16778232,0,0,26377],[16778235,17826809,16778235,0,0,26377],[16778238,17826812,16778238,0,0,26377],[16778241,17826815,16778241,0,0,26377],[16778244,17826818,16778244,0,0,26377],[16778247,17826821,16778247,0,0,26377],[16778250,17826824,16778250,0,0,26377],[16778253,17826827,16778253,0,0,26377],[16778256,17826830,16778256,0,0,26377],[16778259,17826833,16778259,0,0,26377],[16778262,17826836,16778262,0,0,26377],[16778265,17826839,16778265,0,0,26377],[16778268,17826842,16778268,0,0,26377],[16778271,17826845,16778271,0,0,26377],[16778274,17826848,16778274,0,0,26377],[16778277,17826851,16778277,0,0,26377],[16778280,17826854,16778280,0,0,26377],[16778283,17826857,16778283,0,0,26377],[16778286,17826860,16778286,0,0,26377],[16778289,17826863,16778289,0,0,26377],[16778292,17826866,16778292,0,0,26377],[16778295,17826869,16778295,0,0,26377],[16778298,17826872,16778298,0,0,26377],[16778301,17826875,16778301,0,0,26377],[16778304,17826878,16778304,0,0,26377],[16778307,17826881,16778307,0,0,26377],[16778310,17826884,16778310,0,0,26377],[16778313,17826887,16778313,0,0,26377],[16778316,17826890,16778316,0,0,26377],[16778319,17826893,16778319,0,0,26377],[16778322,17826896,16778322,0,0,26377],[16778325,17826899,16778325,0,0,26377],[16778328,17826902,16778328,0,0,26377],[16778331,17826905,16778331,0,0,26377],[16778334,17826908,16778334,0,0,26377],[33555554,18875487,33555556,0,0,26377],[33555561,18875494,33555563,0,0,26377],[33555568,18875501,33555570,0,0,26377],[50332792,19924084,50332795,0,0,26377],[50332802,19924094,50332805,0,0,26377],[33555595,18875528,33555597,0,0,26377],[33555602,18875535,33555604,0,0,26377],[33555609,18875542,33555611,0,0,26377],[33555616,18875549,33555618,0,0,26377],[33555623,18875556,33555625,0,0,26377],[33555630,18875563,33555632,0,0,26377],[33555637,18875570,33555639,0,0,26377],[0,0,0,0,0,1025],[0,0,0,0,0,5633],[0,40,0,0,0,10113],[-40,0,-40,0,0,9993],[0,0,0,0,0,9344]],B=0,D=1,E=2,F=3,G=4,H=5,I=[181,956,924,223,115,115,83,83,83,115,105,775,304,329,700,110,700,78,383,115,83,496,106,780,74,780,837,953,921,912,953,776,769,921,776,769,944,965,776,769,933,776,769,962,963,931,976,946,914,977,952,920,981,966,934,982,960,928,1008,954,922,1009,961,929,1013,949,917,1415,1381,1410,1333,1362,1333,1410,43888,5024,5024,43889,5025,5025,43890,5026,5026,43891,5027,5027,43892,5028,5028,43893,5029,5029,43894,5030,5030,43895,5031,5031,43896,5032,5032,43897,5033,5033,43898,5034,5034,43899,5035,5035,43900,5036,5036,43901,5037,5037,43902,5038,5038,43903,5039,5039,43904,5040,5040,43905,5041,5041,43906,5042,5042,43907,5043,5043,43908,5044,5044,43909,5045,5045,43910,5046,5046,43911,5047,5047,43912,5048,5048,43913,5049,5049,43914,5050,5050,43915,5051,5051,43916,5052,5052,43917,5053,5053,43918,5054,5054,43919,5055,5055,43920,5056,5056,43921,5057,5057,43922,5058,5058,43923,5059,5059,43924,5060,5060,43925,5061,5061,43926,5062,5062,43927,5063,5063,43928,5064,5064,43929,5065,5065,43930,5066,5066,43931,5067,5067,43932,5068,5068,43933,5069,5069,43934,5070,5070,43935,5071,5071,43936,5072,5072,43937,5073,5073,43938,5074,5074,43939,5075,5075,43940,5076,5076,43941,5077,5077,43942,5078,5078,43943,5079,5079,43944,5080,5080,43945,5081,5081,43946,5082,5082,43947,5083,5083,43948,5084,5084,43949,5085,5085,43950,5086,5086,43951,5087,5087,43952,5088,5088,43953,5089,5089,43954,5090,5090,43955,5091,5091,43956,5092,5092,43957,5093,5093,43958,5094,5094,43959,5095,5095,43960,5096,5096,43961,5097,5097,43962,5098,5098,43963,5099,5099,43964,5100,5100,43965,5101,5101,43966,5102,5102,43967,5103,5103,5112,5104,5104,5113,5105,5105,5114,5106,5106,5115,5107,5107,5116,5108,5108,5117,5109,5109,5112,5104,5104,5113,5105,5105,5114,5106,5106,5115,5107,5107,5116,5108,5108,5117,5109,5109,7830,104,817,72,817,7831,116,776,84,776,7832,119,778,87,778,7833,121,778,89,778,7834,97,702,65,702,7835,7777,7776,223,115,115,7838,8016,965,787,933,787,8018,965,787,768,933,787,768,8020,965,787,769,933,787,769,8022,965,787,834,933,787,834,8064,7936,953,7944,921,8072,8065,7937,953,7945,921,8073,8066,7938,953,7946,921,8074,8067,7939,953,7947,921,8075,8068,7940,953,7948,921,8076,8069,7941,953,7949,921,8077,8070,7942,953,7950,921,8078,8071,7943,953,7951,921,8079,8064,7936,953,7944,921,8072,8065,7937,953,7945,921,8073,8066,7938,953,7946,921,8074,8067,7939,953,7947,921,8075,8068,7940,953,7948,921,8076,8069,7941,953,7949,921,8077,8070,7942,953,7950,921,8078,8071,7943,953,7951,921,8079,8080,7968,953,7976,921,8088,8081,7969,953,7977,921,8089,8082,7970,953,7978,921,8090,8083,7971,953,7979,921,8091,8084,7972,953,7980,921,8092,8085,7973,953,7981,921,8093,8086,7974,953,7982,921,8094,8087,7975,953,7983,921,8095,8080,7968,953,7976,921,8088,8081,7969,953,7977,921,8089,8082,7970,953,7978,921,8090,8083,7971,953,7979,921,8091,8084,7972,953,7980,921,8092,8085,7973,953,7981,921,8093,8086,7974,953,7982,921,8094,8087,7975,953,7983,921,8095,8096,8032,953,8040,921,8104,8097,8033,953,8041,921,8105,8098,8034,953,8042,921,8106,8099,8035,953,8043,921,8107,8100,8036,953,8044,921,8108,8101,8037,953,8045,921,8109,8102,8038,953,8046,921,8110,8103,8039,953,8047,921,8111,8096,8032,953,8040,921,8104,8097,8033,953,8041,921,8105,8098,8034,953,8042,921,8106,8099,8035,953,8043,921,8107,8100,8036,953,8044,921,8108,8101,8037,953,8045,921,8109,8102,8038,953,8046,921,8110,8103,8039,953,8047,921,8111,8114,8048,953,8122,921,8122,837,8115,945,953,913,921,8124,8116,940,953,902,921,902,837,8118,945,834,913,834,8119,945,834,953,913,834,921,913,834,837,8115,945,953,913,921,8124,8126,953,921,8130,8052,953,8138,921,8138,837,8131,951,953,919,921,8140,8132,942,953,905,921,905,837,8134,951,834,919,834,8135,951,834,953,919,834,921,919,834,837,8131,951,953,919,921,8140,8146,953,776,768,921,776,768,8147,953,776,769,921,776,769,8150,953,834,921,834,8151,953,776,834,921,776,834,8162,965,776,768,933,776,768,8163,965,776,769,933,776,769,8164,961,787,929,787,8166,965,834,933,834,8167,965,776,834,933,776,834,8178,8060,953,8186,921,8186,837,8179,969,953,937,921,8188,8180,974,953,911,921,911,837,8182,969,834,937,834,8183,969,834,953,937,834,921,937,834,837,8179,969,953,937,921,8188,43888,5024,5024,43889,5025,5025,43890,5026,5026,43891,5027,5027,43892,5028,5028,43893,5029,5029,43894,5030,5030,43895,5031,5031,43896,5032,5032,43897,5033,5033,43898,5034,5034,43899,5035,5035,43900,5036,5036,43901,5037,5037,43902,5038,5038,43903,5039,5039,43904,5040,5040,43905,5041,5041,43906,5042,5042,43907,5043,5043,43908,5044,5044,43909,5045,5045,43910,5046,5046,43911,5047,5047,43912,5048,5048,43913,5049,5049,43914,5050,5050,43915,5051,5051,43916,5052,5052,43917,5053,5053,43918,5054,5054,43919,5055,5055,43920,5056,5056,43921,5057,5057,43922,5058,5058,43923,5059,5059,43924,5060,5060,43925,5061,5061,43926,5062,5062,43927,5063,5063,43928,5064,5064,43929,5065,5065,43930,5066,5066,43931,5067,5067,43932,5068,5068,43933,5069,5069,43934,5070,5070,43935,5071,5071,43936,5072,5072,43937,5073,5073,43938,5074,5074,43939,5075,5075,43940,5076,5076,43941,5077,5077,43942,5078,5078,43943,5079,5079,43944,5080,5080,43945,5081,5081,43946,5082,5082,43947,5083,5083,43948,5084,5084,43949,5085,5085,43950,5086,5086,43951,5087,5087,43952,5088,5088,43953,5089,5089,43954,5090,5090,43955,5091,5091,43956,5092,5092,43957,5093,5093,43958,5094,5094,43959,5095,5095,43960,5096,5096,43961,5097,5097,43962,5098,5098,43963,5099,5099,43964,5100,5100,43965,5101,5101,43966,5102,5102,43967,5103,5103,64256,102,102,70,70,70,102,64257,102,105,70,73,70,105,64258,102,108,70,76,70,108,64259,102,102,105,70,70,73,70,102,105,64260,102,102,108,70,70,76,70,102,108,64261,115,116,83,84,83,116,64262,115,116,83,84,83,116,64275,1396,1398,1348,1350,1348,1398,64276,1396,1381,1348,1333,1348,1381,64277,1396,1387,1348,1339,1348,1387,64278,1406,1398,1358,1350,1358,1398,64279,1396,1389,1348,1341,1348,1389],J=7,K=[36,37,38,39,40,41,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,71,72,73,74,78,79,80,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,104,105,106,112,113,118,119,155,156,157,158,159,162,163,166,167,168,173,174,177,178,188,189,190,191,197,198,199,207,208,222,223,231,232,236,237,257,258,264,265,281,282,283,300,301,302,319,320,321,329,330,332,333,334,335,336,337,338,339,340,341,342,343,344,431,432,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523,524,526,527,528,529,530,531,532,533,534,535,536,537,538,540,541,544,545,546,547,548,549,550,551,553,554,555,556,557,558,559,561,562,565,566,576,583,584,585,586,587,608,616,617,648,652,653,720,724,725,726,727,728,734,735,736,864,865,888,889,890,928,929,930,931,932,933,934,935,936,937,938,939,940,941,942,943,944,948,949,950,976,977,978,988,989,990,992,993,994,995,996,997,998,999,1e3,1002,1003,1004,1005,1006,1007,1008,1009,1010,1011,1012,1024,1025,1026,1027,1042,1043,1044,1045,1046,1047,1095,1096,1107,1108,1142,1143,1220,1221,1357,1358,1390,1391,1392,1393,1437,1438,1520,1521,1522,1524,1525,7168,7169,7170,7171,7172,7680,8191,8192,8703,8704],L=[34,35,36,37,38,39,34,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,64,68,69,64,70,71,72,73,74,75,76,77,64,78,79,80,81,82,83,84,64,85,86,34,87,34,88,34,89,90,91,92,34,93,34,94,95,34,96,34,97,34,98,99,100,34,101,102,34,103,34,104,34,105,34,101,34,104,34,106,34,107,108,34,109,110,34,111,112,34,113,34,114,115,116,117,118,119,120,121,122,123,124,125,34,126,127,128,129,130,131,132,133,134,34,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,145,34,152,145,153,154,155,156,157,158,159,160,161,162,145,163,145,164,165,166,167,168,169,170,145,171,145,172,173,174,175,145,176,145,177,145,34,178,179,34,180,145,34,181,145,34,182,145,34,183,184,185,186,145,187,188,145,189,145,190,191,145,64,192,193,194,195,145,196,145,197,198,199,200,201,202,203,204,64,205,206,145,34,207,145,208,209,145,210,211,212,213,214,145,64,215,64,216,217,64,218,219,220,221,222,223,224,145,225,226,227,34,87,228,34,229,230,34,231,34,232,34,233,34,234,34,235,34,236,34,237,34,238,145,34,231,34,239,145,240,145,241,242,145,127,243,127,243],M=[9,10,14,28,31,32,33,39,40,46,47,48,49,50,51,52,53,54,55,56,57,58,59,65,91,94,95,96,97,123,127,133,134,160,161,168,169,170,171,173,174,175,176,178,179,180,181,182,183,184,185,186,187,188,191,192,215,216,223,224,247,248,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,428,429,430,431,432,433,435,436,437,438,439,440,441,442,443,444,445,446,447,448,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,559,560,561,562,563,564,570,571,572,573,574,575,577,578,579,580,581,582,583,584,585,586,587,588,589,590,591,592,593,594,595,596,597,598,600,601,602,603,604,605,608,609,610,611,612,613,614,615,616,617,618,619,620,621,623,624,625,626,627,629,630,637,638,640,641,643,644,647,648,649,650,652,653,658,659,660,661,669,670,671,688,697,704,706,710,722,736,741,748,749,750,751,768,837,838,880,881,882,883,884,885,886,887,888,890,891,894,895,896,900,902,903,904,907,908,909,910,912,913,930,931,940,941,944,945,962,963,972,973,975,976,977,978,981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1e3,1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,1011,1012,1013,1014,1015,1016,1017,1018,1019,1020,1021,1024,1040,1072,1104,1120,1121,1122,1123,1124,1125,1126,1127,1128,1129,1130,1131,1132,1133,1134,1135,1136,1137,1138,1139,1140,1141,1142,1143,1144,1145,1146,1147,1148,1149,1150,1151,1152,1153,1154,1155,1160,1162,1163,1164,1165,1166,1167,1168,1169,1170,1171,1172,1173,1174,1175,1176,1177,1178,1179,1180,1181,1182,1183,1184,1185,1186,1187,1188,1189,1190,1191,1192,1193,1194,1195,1196,1197,1198,1199,1200,1201,1202,1203,1204,1205,1206,1207,1208,1209,1210,1211,1212,1213,1214,1215,1216,1217,1218,1219,1220,1221,1222,1223,1224,1225,1226,1227,1228,1229,1230,1231,1232,1233,1234,1235,1236,1237,1238,1239,1240,1241,1242,1243,1244,1245,1246,1247,1248,1249,1250,1251,1252,1253,1254,1255,1256,1257,1258,1259,1260,1261,1262,1263,1264,1265,1266,1267,1268,1269,1270,1271,1272,1273,1274,1275,1276,1277,1278,1279,1280,1281,1282,1283,1284,1285,1286,1287,1288,1289,1290,1291,1292,1293,1294,1295,1296,1297,1298,1299,1300,1301,1302,1303,1304,1305,1306,1307,1308,1309,1310,1311,1312,1313,1314,1315,1316,1317,1318,1319,1320,1321,1322,1323,1324,1325,1326,1327,1328,1329,1367,1369,1370,1376,1377,1415,1416,1417,1419,1421,1424,1425,1470,1471,1472,1473,1475,1476,1478,1479,1480,1488,1515,1520,1523,1524,1525,1536,1542,1552,1563,1564,1565,1566,1568,1600,1601,1611,1632,1633,1634,1635,1636,1637,1638,1639,1640,1641,1642,1646,1648,1649,1748,1749,1750,1757,1758,1759,1765,1767,1769,1770,1774,1776,1777,1778,1779,1780,1781,1782,1783,1784,1785,1786,1789,1791,1792,1806,1807,1808,1809,1810,1840,1867,1869,1958,1969,1970,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,2027,2036,2038,2042,2043,2048,2070,2074,2075,2084,2085,2088,2089,2094,2096,2111,2112,2137,2140,2142,2143,2208,2229,2275,2307,2308,2362,2363,2364,2365,2366,2369,2377,2381,2382,2384,2385,2392,2402,2404,2406,2407,2408,2409,2410,2411,2412,2413,2414,2415,2416,2417,2418,2433,2434,2436,2437,2445,2447,2449,2451,2473,2474,2481,2482,2483,2486,2490,2492,2493,2494,2497,2501,2503,2505,2507,2509,2510,2511,2519,2520,2524,2526,2527,2530,2532,2534,2535,2536,2537,2538,2539,2540,2541,2542,2543,2544,2546,2548,2554,2556,2561,2563,2564,2565,2571,2575,2577,2579,2601,2602,2609,2610,2612,2613,2615,2616,2618,2620,2621,2622,2625,2627,2631,2633,2635,2638,2641,2642,2649,2653,2654,2655,2662,2663,2664,2665,2666,2667,2668,2669,2670,2671,2672,2674,2677,2678,2689,2691,2692,2693,2702,2703,2706,2707,2729,2730,2737,2738,2740,2741,2746,2748,2749,2750,2753,2758,2759,2761,2762,2763,2765,2766,2768,2769,2784,2786,2788,2790,2791,2792,2793,2794,2795,2796,2797,2798,2799,2800,2802,2809,2810,2817,2818,2820,2821,2829,2831,2833,2835,2857,2858,2865,2866,2868,2869,2874,2876,2877,2878,2879,2880,2881,2885,2887,2889,2891,2893,2894,2902,2903,2904,2908,2910,2911,2914,2916,2918,2919,2920,2921,2922,2923,2924,2925,2926,2927,2928,2929,2930,2936,2946,2947,2948,2949,2955,2958,2961,2962,2966,2969,2971,2972,2973,2974,2976,2979,2981,2984,2987,2990,3002,3006,3008,3009,3011,3014,3017,3018,3021,3022,3024,3025,3031,3032,3046,3047,3048,3049,3050,3051,3052,3053,3054,3055,3056,3059,3067,3072,3073,3076,3077,3085,3086,3089,3090,3113,3114,3130,3133,3134,3137,3141,3142,3145,3146,3150,3157,3159,3160,3163,3168,3170,3172,3174,3175,3176,3177,3178,3179,3180,3181,3182,3183,3184,3192,3199,3200,3201,3202,3204,3205,3213,3214,3217,3218,3241,3242,3252,3253,3258,3260,3261,3262,3263,3264,3269,3270,3271,3273,3274,3276,3278,3285,3287,3294,3295,3296,3298,3300,3302,3303,3304,3305,3306,3307,3308,3309,3310,3311,3312,3313,3315,3329,3330,3332,3333,3341,3342,3345,3346,3387,3389,3390,3393,3397,3398,3401,3402,3405,3406,3407,3415,3416,3423,3426,3428,3430,3431,3432,3433,3434,3435,3436,3437,3438,3439,3440,3446,3449,3450,3456,3458,3460,3461,3479,3482,3506,3507,3516,3517,3518,3520,3527,3530,3531,3535,3538,3541,3542,3543,3544,3552,3558,3559,3560,3561,3562,3563,3564,3565,3566,3567,3568,3570,3572,3573,3585,3633,3634,3635,3636,3643,3647,3648,3654,3655,3663,3664,3665,3666,3667,3668,3669,3670,3671,3672,3673,3674,3676,3713,3715,3716,3717,3719,3721,3722,3723,3725,3726,3732,3736,3737,3744,3745,3748,3749,3750,3751,3752,3754,3756,3757,3761,3762,3763,3764,3770,3771,3773,3774,3776,3781,3782,3783,3784,3790,3792,3793,3794,3795,3796,3797,3798,3799,3800,3801,3802,3804,3808,3840,3841,3864,3866,3872,3873,3874,3875,3876,3877,3878,3879,3880,3881,3882,3892,3893,3894,3895,3896,3897,3898,3902,3904,3912,3913,3949,3953,3967,3968,3973,3974,3976,3981,3992,3993,4029,4030,4038,4039,4045,4046,4059,4096,4139,4141,4145,4146,4152,4153,4155,4157,4159,4160,4161,4162,4163,4164,4165,4166,4167,4168,4169,4170,4176,4182,4184,4186,4190,4193,4194,4197,4199,4206,4209,4213,4226,4227,4229,4231,4237,4238,4239,4240,4241,4242,4243,4244,4245,4246,4247,4248,4249,4250,4253,4254,4256,4294,4295,4296,4301,4302,4304,4347,4348,4349,4553,4554,4558,4560,4567,4568,4569,4570,4574,4576,4617,4618,4622,4624,4657,4658,4662,4664,4671,4672,4673,4674,4678,4680,4695,4696,4753,4754,4758,4760,4827,4829,4832,4841,4842,4843,4844,4845,4846,4847,4848,4849,4850,4861,4864,4880,4890,4896,4897,4898,4899,4900,4901,4902,4903,4904,4905,4906,4907,4908,4909,4910,4911,4912,4913,4914,4915,4916,4917,4918,4919,4920,4921,4922,4923,4924,4925,4926,4927,4928,4929,4930,4931,4932,4933,4934,4935,4936,4937,4938,4939,4940,4941,4942,4943,4944,4945,4946,4947,4948,4949,4950,4951,4952,4953,4954,4955,4956,4957,4958,4959,4960,4961,4962,4963,4964,4965,4966,4967,4968,4969,4970,4971,4972,4973,4974,4975,4976,4977,4978,4979,4980,4981,4982,4984,4985,4986,4987,4988,4989,4990,4992,4993,5229,5231,5248,5249,5275,5277,5280,5355,5358,5361,5369,5376,5389,5390,5394,5397,5408,5426,5429,5431,5440,5458,5460,5472,5485,5486,5489,5490,5492,5504,5556,5558,5559,5566,5574,5575,5577,5588,5591,5592,5596,5597,5598,5600,5601,5602,5603,5604,5605,5606,5607,5608,5609,5610,5616,5626,5632,5643,5646,5647,5648,5649,5650,5651,5652,5653,5654,5655,5656,5657,5658,5664,5699,5700,5752,5760,5801,5802,5803,5808,5878,5888,5919,5920,5923,5927,5929,5932,5936,5938,5939,5945,5948,5952,5953,5956,5958,5959,5960,5961,5962,5963,5964,5965,5966,5967,5968,5998,6e3,6005,6016,6060,6064,6090,6096,6097,6098,6099,6100,6101,6102,6103,6104,6105,6106,6107,6110,6144,6167,6169,6171,6172,6174,6176,6229,6230,6231,6232,6239,6240,6241,6242,6243,6245,6253,6259,6269,6271,6272,6273,6274,6275,6276,6277,6278,6279,6280,6281,6282,6288,6289,6290,6291,6292,6293,6294,6295,6296,6297,6298,6304,6311,6312,6318,6320,6334,6335,6400,6404,6405,6452,6453,6454,6459,6460,6461,6466,6467,6469,6476,6480,6481,6482,6483,6484,6485,6486,6487,6488,6489,6490,6507,6516,6525,6528,6530,6531,6561,6562,6566,6568,6570,6571,6574,6576,6577,6578,6579,6580,6581,6582,6583,6584,6585,6586,6630,6631,6632,6634,6637,6638,6639,6642,6644,6652,6656,6692,6700,6708,6710,6712,6715,6720,6721,6722,6723,6724,6725,6726,6727,6728,6729,6730,6733,6736,6737,6738,6739,6740,6741,6742,6743,6744,6745,6746,6776,6782,6784,6848,6856,6864,6867,6868,6881,6882,6889,6893,6894,6898,6900,6901,6903,6904,6906,6912,6956,7019,7032,7033,7034,7037,7038,7067,7104,7158,7164,7168,7169,7170,7171,7172,7173,7174,7175,7176,7177,7178,7179,7180,7181,7182,7183,7184,7185,7186,7187,7188,7189,7190,7191,7192,7193,7194,7195,7196,7197,7198,7199,7200,7201,7202,7203,7204,7205,7206,7207,7208,7209,7210,7211,7212,7213,7214,7215,7216,7217,7218,7219,7220,7221,7222,7223,7224,7225,7226,7227,7228,7229,7230,7231,7232,7233,7234,7235,7236,7237,7238,7239,7240,7241,7242,7243,7244,7245,7246,7247,7248,7249,7250,7251,7252,7253,7254,7255,7256,7257,7258,7259,7260,7261,7262,7263,7264,7265,7266,7267,7268,7269,7270,7271,7272,7273,7274,7275,7276,7277,7278,7279,7280,7281,7282,7283,7284,7285,7286,7287,7288,7289,7290,7291,7292,7293,7294,7295,7296,7297,7298,7299,7300,7301,7302,7303,7304,7305,7306,7307,7308,7309,7310,7311,7312,7313,7314,7315,7316,7317,7318,7319,7320,7321,7322,7323,7324,7326,7327,7328,7329,7330,7331,7332,7333,7334,7335,7336,7337,7338,7339,7340,7341,7342,7343,7344,7345,7346,7347,7348,7349,7350,7351,7352,7353,7354,7355,7356,7357,7358,7359,7360,7361,7362,7363,7364,7365,7366,7367,7368,7369,7370,7371,7372,7373,7374,7375,7376,7377,7378,7379,7380,7381,7382,7383,7384,7385,7386,7387,7388,7389,7390,7391,7392,7393,7394,7395,7396,7397,7398,7399,7400,7401,7402,7403,7404,7405,7406,7407,7408,7409,7410,7411,7412,7413,7414,7415,7416,7417,7418,7419,7420,7421,7422,7423,7424,7432,7440,7446,7448,7454,7456,7464,7472,7480,7488,7494,7496,7502,7504,7505,7506,7507,7508,7509,7510,7511,7512,7513,7514,7515,7516,7517,7518,7519,7520,7528,7536,7538,7542,7544,7546,7548,7550,7552,7553,7554,7555,7556,7557,7558,7559,7560,7561,7562,7563,7564,7565,7566,7567,7568,7569,7570,7571,7572,7573,7574,7575,7576,7577,7578,7579,7580,7581,7582,7583,7584,7585,7586,7587,7588,7589,7590,7591,7592,7593,7594,7595,7596,7597,7598,7599,7600,7602,7603,7604,7605,7606,7607,7608,7610,7612,7613,7614,7615,7618,7619,7620,7621,7622,7623,7624,7628,7629,7632,7634,7635,7636,7638,7639,7640,7642,7644,7645,7648,7650,7651,7652,7653,7654,7655,7656,7658,7660,7661,7664,7666,7667,7668,7669,7670,7671,7672,7674,7676,7677,7679,7680,7691,7696,7704,7706,7716,7717,7719,7720,7722,7727,7728,7743,7745,7764,7765,7775,7776,7781,7782,7792,7793,7794,7796,7797,7798,7799,7800,7801,7802,7807,7808,7809,7810,7811,7812,7813,7814,7815,7816,7817,7818,7823,7824,7837,7840,7871,7888,7901,7905,7906,7909,7921,7936,7938,7939,7943,7944,7946,7947,7950,7952,7955,7956,7957,7958,7960,7961,7966,7972,7973,7974,7975,7976,7977,7978,7979,7980,7982,7983,7984,7986,7987,7988,7989,7993,7994,7996,7998,8e3,8005,8006,8010,8014,8015,8016,8032,8048,8064,8067,8068,8069,8073,8074,8076,8080,8443,8448,8487,8512,8523,8544,8545,8546,8547,8548,8549,8550,8551,8552,8553,8564,8565,8566,8567,8568,8569,8570,8571,8572,8573,8584,8585,8586,8587,8588,8589,8590,8591,8592,8593,8604,8630,8656,8682,8683,8693,8694,8695,8696,8697,8698,8699,8700,8701,8702,8703,8704,8822,8823,8824,8825,8826,8827,8828,8829,8830,8831,8832,8833,8834,8835,8836,8837,8838,8839,8840,8841,8842,8843,8844,8845,8846,8847,8848,8849,8850,8851,8852,9076,9078,9110,9112,9146,9149,9161,9162,9170,9196,9200,9216,9263,9264,9311,9312,9313,9314,9315,9316,9317,9318,9319,9320,9321,9322,9323,9324,9325,9326,9327,9328,9329,9330,9331,9332,9333,9334,9335,9340,9342,9344,9345,9346,9347,9348,9349,9350,9351,9352,9353,9354,9355,9356,9357,9358,9359,9360,9361,9362,9363,9364,9365,9366,9367,9368,9369,9370,9371,9372,9373,9374,9375,9376,9377,9378,9379,9380,9381,9382,9383,9384,9385,9386,9387,9388,9389,9390,9391,9392,9393,9394,9395,9396,9397,9398,9399,9400,9401,9402,9403,9404,9405,9406,9407,9408,9409,9410,9411,9412,9413,9414,9415,9416,9417,9418,9419,9420,9421,9422,9423,9424,9425,9426,9427,9428,9429,9430,9431,9432,9433,9434,9435,9436,9437,9438,9439,9440,9441,9442,9443,9444,9445,9451,9452,9453,9454,9455,9458,9459,9460,9465,9469,9470,9472,9510,9511,9512,9517,9518,9520,9576,9583,9584,9585,9599,9600,9623,9632,9639,9640,9647,9648,9655,9656,9663,9664,9671,9672,9679,9680,9687,9688,9695,9696,9728,9775,9776,9795,9856,9882,9883,9972,9984,10070,10096,10108,10112,10113,10117,10118,10119,10120,10145,10154,10158,10160,10161,10166,10168,10171,10172,10173,10176,10177,10263,10265,10267,10269,10271,10272,10273,10363,10364,10367,10368,10373,10414,10417,10511,10512,10514,10518,10528,10555,10560,10596,10608,10624,10655,10656,10666,10696,10704,10705,10720,10752,10762,10801,10816,10879,10880,10885,10886,11011,11012,11178,11179,11341,11342,11446,11456,11520,11521,11523,11524,11527,11528,11529,11530,11613,11614,11660,11661,11668,11669,11670,11671,11711,11713,11743,11744,11752,11753,11789,11790,11888,11889,11908,11909,11974,11975,12009,12010,12011,12012,12013,12014,12097,12098,12099,12102,12108,12109,12225,12229,12379,12380,12529,12530,12537,12538,12666,12667,12798,12800,12812,12815,12816,12817,13054,13055,13132,13133,13266,13267,13318,13319,13462,13463,13612,13613,13742,13743,13747,13748,13872,13873,13985,13986,14022,14023,14028,14029,14072,14073,14198,14199,14294,14336,14357,14358,14477,14480,14535,14544,14584,14590,14592,14604,14605,14608,14624,14625,14626,14627,14628,14629,14630,14631,14632,14633,14634,14636,14656,14657,14658,14659,14660,14661,14662,14663,14664,14665,14666,14667,14668,14669,14670,14671,14672,14673,14674,14675,14676,14677,14678,14679,14680,14681,14682,14683,14684,14685,14686,14687,14688,14689,14690,14691,14692,14693,14694,14695,14696,14697,14698,14699,14700,14701,14702,14703,14704,14707,14708,14718,14719,14720,14721,14722,14723,14724,14725,14726,14727,14728,14729,14730,14731,14732,14733,14734,14735,14736,14737,14738,14739,14740,14741,14742,14743,14744,14745,14746,14747,14748,14750,14752,14822,14832,14834,14840,14848,14871,14880,14882,14883,14884,14885,14886,14887,14888,14889,14890,14891,14892,14893,14894,14895,14896,14898,14899,14900,14901,14902,14903,14904,14905,14906,14907,14908,14909,14910,14911,14912,14913,14914,14915,14916,14917,14918,14919,14920,14921,14922,14923,14924,14925,14926,14927,14928,14929,14930,14931,14932,14933,14934,14935,14936,14937,14938,14939,14940,14941,14942,14943,14944,14945,14946,14947,14948,14949,14950,14951,14952,14953,14954,14955,14956,14957,14958,14959,14960,14961,14969,14970,14971,14972,14973,14974,14975,14976,14977,14978,14979,14980,14981,14982,14983,14984,14985,14987,14988,14989,14990,14991,14992,14993,14994,14995,14996,14998,14999,15e3,15001,15002,15003,15004,15005,15006,15007,15008,15009,15010,15011,15012,15013,15014,15015,15016,15017,15018,15019,15020,15021,15022,15024,15025,15026,15027,15028,15029,15030,15031,15032,15095,15096,15098,15099,15106,15107,15110,15111,15115,15116,15139,15141,15143,15144,15148,15152,15158,15162,15168,15220,15224,15232,15234,15284,15300,15301,15310,15312,15313,15314,15315,15316,15317,15318,15319,15320,15321,15322,15328,15346,15352,15355,15356,15357,15358,15360,15361,15362,15363,15364,15365,15366,15367,15368,15369,15370,15398,15406,15408,15431,15442,15444,15455,15456,15485,15488,15491,15492,15539,15540,15542,15546,15548,15549,15553,15566,15567,15568,15569,15570,15571,15572,15573,15574,15575,15576,15577,15578,15582,15584,15589,15590,15591,15600,15601,15602,15603,15604,15605,15606,15607,15608,15609,15610,15615,15616,15657,15663,15665,15667,15669,15671,15680,15683,15684,15692,15693,15694,15696,15697,15698,15699,15700,15701,15702,15703,15704,15705,15706,15708,15712,15728,15729,15735,15738,15739,15740,15741,15742,15792,15793,15794,15797,15799,15801,15806,15808,15809,15810,15811,15835,15837,15838,15840,15851,15852,15854,15856,15858,15859,15861,15862,15863,15873,15879,15881,15887,15889,15895,15904,15911,15912,15919,15920,15955,15956,15963,15964,15968,15974,15984,15985,15986,15987,15988,15989,15990,15991,15992,15993,15994,15995,15996,15997,15998,15999,16e3,16001,16002,16003,16004,16005,16006,16007,16008,16009,16010,16011,16012,16013,16014,16015,16016,16017,16018,16019,16020,16021,16022,16023,16024,16025,16026,16027,16028,16029,16030,16031,16032,16033,16034,16035,16036,16037,16038,16039,16040,16041,16042,16043,16044,16045,16046,16047,16048,16049,16050,16051,16052,16053,16054,16055,16056,16057,16058,16059,16060,16061,16062,16063,16064,16099,16101,16102,16104,16105,16107,16108,16109,16110,16112,16113,16114,16115,16116,16117,16118,16119,16120,16121,16122,16128,16164,16176,16199,16203,16252,16256,16384,16491,16492,16499,16500,16504,16505,16562,16563,16593,16594,16595,16596,16637,16638,16750,16752,16858,16896,16897,16898,16899,16900,16901,16902,16903,16915,16916,16917,16918,16919,16920,16925,16926,16927,16937,16938,16951,16952,16957,16958,16959,16960,16962,16963,16965,16966,17074,17090,17107,17246,17252,17342,17344,17360,17424,17426,17480,17520,17530,17532,17534,17536,17552,17555,17556,17562,17568,17584,17587,17589,17613,17616,17618,17619,17620,17621,17622,17639,17640,17644,17648,17649,17650,17651,17652,17653,17654,17655,17656,17657,17658,17659,17660,17661,17662,17663,17789,17791,17792,17793,17799,17800,17806,17807,17808,17809,17810,17811,17812,17813,17814,17815,17816,17817,17818,17819,17825,17851,17854,17855,17856,17857,17883,17894,17904,17905,17950,17952,17983,17986,17992,17994,18e3,18002,18008,18010,18013,18016,18019,18020,18023,18024,18031,18041,18044,18046,18048,18060,18061,18087,18088,18107,18108,18110,18111,18126,18128,18142,18176,18299,18304,18307,18311,18356,18359,18368,18421,18425,18442,18444,18445,18448,18460,18464,18465,18512,18557,18558,18688,18717,18720,18769,18784,18785,18812,18816,18848,18852,18864,18881,18882,18890,18891,18896,18934,18939,18944,18974,18975,18976,19012,19016,19024,19025,19030,19072,19112,19152,19230,19232,19233,19234,19235,19236,19237,19238,19239,19240,19241,19242,19328,19368,19376,19428,19439,19440,19456,19511,19520,19542,19552,19560,19584,19590,19592,19593,19594,19638,19639,19641,19644,19645,19647,19670,19671,19672,19680,19703,19705,19712,19743,19751,19760,19808,19827,19828,19830,19835,19840,19862,19868,19871,19872,19898,19903,19904,19968,20024,20028,20030,20032,20048,20050,20096,20097,20100,20101,20103,20108,20112,20116,20117,20120,20121,20148,20152,20155,20159,20160,20161,20162,20163,20164,20168,20176,20185,20192,20221,20223,20224,20253,20256,20288,20296,20297,20325,20327,20331,20336,20343,20352,20406,20409,20416,20438,20440,20448,20467,20472,20480,20498,20505,20509,20521,20528,20608,20681,20736,20787,20800,20851,20858,20864,20960,20961,20962,20963,20964,20965,20966,20967,20968,20969,20991,20992,20993,20994,20995,21048,21063,21070,21074,21075,21076,21077,21078,21079,21080,21081,21082,21083,21094,21095,21096,21097,21098,21099,21100,21101,21102,21103,21104,21119,21122,21123,21168,21171,21175,21177,21179,21181,21182,21186,21200,21225,21232,21233,21234,21235,21236,21237,21238,21239,21240,21241,21242,21248,21251,21287,21292,21293,21301,21302,21303,21304,21305,21306,21307,21308,21309,21310,21311,21312,21316,21328,21363,21364,21366,21367,21376,21378,21379,21427,21430,21439,21441,21445,21450,21453,21454,21456,21457,21458,21459,21460,21461,21462,21463,21464,21465,21466,21467,21468,21469,21472,21473,21493,21504,21522,21523,21548,21551,21554,21556,21557,21558,21560,21566,21632,21639,21640,21641,21642,21646,21647,21662,21663,21673,21674,21680,21727,21728,21731,21739,21744,21745,21746,21747,21748,21749,21750,21751,21752,21753,21754,21760,21762,21764,21765,21773,21775,21777,21779,21801,21802,21809,21810,21812,21813,21818,21820,21821,21822,21824,21825,21829,21831,21833,21835,21838,21840,21841,21847,21848,21853,21858,21860,21862,21869,21872,21877,21888,21936,21939,21945,21946,21947,21951,21953,21954,21956,21958,21959,21960,21968,21969,21970,21971,21972,21973,21974,21975,21976,21977,21978,22016,22063,22066,22070,22072,22076,22078,22079,22081,22104,22108,22110,22144,22192,22195,22203,22205,22206,22207,22209,22212,22213,22224,22225,22226,22227,22228,22229,22230,22231,22232,22233,22234,22272,22315,22316,22317,22318,22320,22326,22327,22328,22336,22337,22338,22339,22340,22341,22342,22343,22344,22345,22346,22400,22426,22429,22432,22434,22438,22439,22444,22448,22449,22450,22451,22452,22453,22454,22455,22456,22457,22458,22460,22464,22560,22592,22624,22625,22626,22627,22628,22629,22630,22631,22632,22633,22634,22643,22655,22656,22720,22777,22784,22810,22912,23023,23024,23029,23040,23108,23168,23215,23296,23367,23424,23481,23488,23519,23520,23521,23522,23523,23524,23525,23526,23527,23528,23529,23530,23534,23536,23632,23662,23664,23669,23670,23680,23728,23735,23744,23748,23750,23760,23761,23762,23763,23764,23765,23766,23767,23768,23769,23770,23771,23778,23779,23800,23805,23824,23936,24005,24016,24017,24063,24079,24083,24096,24192,24194,24320,24427,24432,24445,24448,24457,24464,24474,24476,24477,24479,24480,24484,24576,24694,24704,24743,24745,24805,24807,24810,24813,24819,24827,24835,24837,24844,24874,24878,24937,24960,25026,25029,25030,25088,25175,25184,25202,25216,25242,25268,25294,25301,25302,25320,25346,25372,25373,25374,25376,25378,25379,25381,25383,25385,25389,25390,25398,25402,25403,25404,25405,25412,25413,25424,25450,25476,25478,25479,25483,25485,25493,25494,25501,25502,25528,25530,25531,25535,25536,25541,25542,25543,25546,25553,25554,25580,25606,25632,25658,25684,25710,25736,25762,25788,25814,25840,25866,25894,25896,25921,25922,25947,25948,25954,25979,25980,26005,26006,26012,26037,26038,26063,26064,26070,26095,26096,26121,26122,26128,26153,26154,26179,26180,26186,26187,26188,26190,26191,26192,26193,26194,26195,26196,26197,26198,26199,26200,26201,26202,26203,26204,26205,26206,26207,26208,26209,26210,26211,26212,26213,26214,26215,26216,26217,26218,26219,26220,26221,26222,26223,26224,26225,26226,26227,26228,26229,26230,26231,26232,26233,26234,26235,26236,26237,26238,26239,26240,26295,26299,26349,26357,26358,26372,26373,26380,26395,26400,26401,26416,26496,26565,26567,26576,26583,26624,26628,26629,26656,26657,26659,26660,26661,26663,26664,26665,26675,26676,26680,26681,26682,26683,26684,26690,26691,26695,26696,26697,26698,26699,26700,26701,26704,26705,26707,26708,26709,26711,26712,26713,26714,26715,26716,26717,26718,26719,26720,26721,26723,26724,26725,26727,26731,26732,26739,26740,26744,26745,26749,26750,26751,26752,26762,26763,26780,26785,26788,26789,26794,26795,26812,26864,26866,26880,26924,26928,27028,27040,27055,27057,27072,27073,27088,27089,27126,27136,27138,27139,27140,27141,27142,27143,27144,27145,27146,27147,27149,27152,27183,27184,27210,27216,27242,27244,27248,27274,27291,27366,27395,27408,27451,27456,27465,27472,27474,27520,27643,27648,27770,27771,27812,27813,27985,28e3,28013,28016,28020,28032,28148,28160,28245,28288,28300,28304,28360,28368,28378,28384,28424,28432,28462,28560,28569,28672,28677,28736,28737,28800,28801,28802,28900,28901,29026,29027,29089,29090,29187,29188,29196,29197,29212,29213,29418,29419,29437,29438,29465,29466,29584,29585,29720,29721,29851,29852,30061,30062,30167,30208,30261,30272,30366,30368,30498,30592,30622,30721,30722,30752,30848,31088,31104,31230,31232],N=[1,2,3,1,3,2,4,5,6,5,6,5,7,8,9,10,11,12,13,14,15,16,6,5,17,5,6,18,6,19,5,1,3,1,2,5,6,5,20,5,21,5,6,5,22,23,6,24,5,25,6,26,20,5,27,5,17,5,17,28,19,5,19,29,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,32,33,30,31,30,31,30,31,20,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,34,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,35,30,31,30,31,30,31,36,37,38,30,31,30,31,39,30,31,40,30,31,20,41,42,43,30,31,40,44,45,46,47,30,31,48,20,46,49,50,51,30,31,30,31,30,31,52,30,31,52,20,30,31,52,30,31,53,30,31,30,31,54,30,31,20,55,30,31,20,56,55,57,58,59,57,58,59,57,58,59,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,60,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,61,57,58,59,30,31,62,63,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,64,20,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,20,65,30,31,66,67,68,30,31,69,70,71,30,31,30,31,30,31,30,31,30,31,72,73,74,75,76,20,77,20,78,20,79,80,20,77,81,20,82,20,83,84,20,85,86,20,87,88,20,86,20,89,90,20,91,20,92,20,93,20,93,20,94,93,95,96,97,20,98,20,55,20,99,100,20,101,102,101,6,102,6,101,6,102,6,102,6,25,103,25,30,31,30,31,102,6,30,31,0,104,50,5,105,0,6,106,25,107,0,108,0,109,110,17,0,17,111,112,113,19,114,19,115,116,117,118,119,120,121,122,123,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,124,125,126,127,128,129,5,30,31,130,30,31,20,64,131,17,19,132,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,5,25,6,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,133,30,31,30,31,30,31,30,31,30,31,30,31,30,31,134,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,0,135,0,102,5,0,136,137,0,5,0,5,0,25,5,25,5,25,5,25,5,25,0,55,0,55,5,6,0,21,5,25,5,21,0,5,55,102,55,25,7,8,9,10,11,12,13,14,15,16,5,55,25,55,5,55,25,21,5,25,102,25,5,25,55,7,8,9,10,11,12,13,14,15,16,55,5,55,5,0,21,55,25,55,25,0,55,25,55,0,7,8,9,10,11,12,13,14,15,16,55,25,102,5,102,0,55,25,102,25,102,25,102,25,0,5,0,55,25,0,5,0,55,0,25,18,55,25,18,25,55,18,25,18,25,18,55,25,55,25,5,7,8,9,10,11,12,13,14,15,16,5,102,55,25,18,0,55,0,55,0,55,0,55,0,55,0,55,0,25,55,18,25,0,18,0,18,25,55,0,18,0,55,0,55,25,0,7,8,9,10,11,12,13,14,15,16,55,5,27,5,0,25,18,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,25,0,18,25,0,25,0,25,0,25,0,55,0,55,0,7,8,9,10,11,12,13,14,15,16,25,55,25,0,25,18,0,55,0,55,0,55,0,55,0,55,0,55,0,25,55,18,25,0,25,18,0,18,25,0,55,0,55,25,0,7,8,9,10,11,12,13,14,15,16,5,0,55,0,25,18,0,55,0,55,0,55,0,55,0,55,0,55,0,25,55,18,25,18,25,0,18,0,18,25,0,25,18,0,55,0,55,25,0,7,8,9,10,11,12,13,14,15,16,5,55,27,0,25,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,18,25,18,0,18,0,18,25,0,55,0,18,0,7,8,9,10,11,12,13,14,15,16,27,5,0,25,18,0,55,0,55,0,55,0,55,0,55,25,18,0,25,0,25,0,25,0,55,0,55,25,0,7,8,9,10,11,12,13,14,15,16,0,27,5,0,25,18,0,55,0,55,0,55,0,55,0,55,0,25,55,18,25,18,0,25,18,0,18,25,0,18,0,55,0,55,25,0,7,8,9,10,11,12,13,14,15,16,0,55,0,25,18,0,55,0,55,0,55,0,55,18,25,0,18,0,18,25,55,0,18,0,55,25,0,7,8,9,10,11,12,13,14,15,16,27,0,5,55,0,18,0,55,0,55,0,55,0,55,0,55,0,25,0,18,25,0,25,0,18,0,7,8,9,10,11,12,13,14,15,16,0,18,5,0,55,25,55,138,25,0,5,55,102,25,5,7,8,9,10,11,12,13,14,15,16,5,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,25,55,138,25,0,25,55,0,55,0,102,0,25,0,7,8,9,10,11,12,13,14,15,16,0,55,0,55,5,25,5,7,8,9,10,11,12,13,14,15,16,27,5,25,5,25,5,25,5,18,55,0,55,0,25,18,25,5,25,55,25,0,25,0,5,25,5,0,5,0,55,18,25,18,25,18,25,18,25,55,7,8,9,10,11,12,13,14,15,16,5,55,18,25,55,25,55,18,55,18,55,25,55,25,18,25,18,25,55,18,7,8,9,10,11,12,13,14,15,16,18,25,5,139,0,139,0,139,0,55,5,102,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,25,5,140,141,142,143,144,145,146,147,148,27,0,55,5,0,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,0,235,236,237,238,239,240,0,5,55,5,55,2,55,5,0,55,5,241,55,0,55,0,55,25,0,55,25,5,0,55,25,0,55,0,55,0,25,0,55,25,18,25,18,25,18,25,5,102,5,55,25,0,7,8,9,10,11,12,13,14,15,16,0,27,0,5,25,21,0,7,8,9,10,11,12,13,14,15,16,0,55,102,55,0,55,25,55,0,55,0,55,0,25,18,25,18,0,18,25,18,25,0,5,0,5,7,8,9,10,11,12,13,14,15,16,55,0,55,0,55,0,55,0,7,8,9,10,11,12,13,14,15,16,140,0,5,55,25,18,25,0,5,55,18,25,18,25,0,25,18,25,18,25,18,25,0,25,7,8,9,10,11,12,13,14,15,16,0,7,8,9,10,11,12,13,14,15,16,0,5,102,5,0,25,6,0,25,18,55,25,18,25,18,25,18,25,18,55,0,7,8,9,10,11,12,13,14,15,16,5,25,5,0,25,18,55,18,25,18,25,18,25,55,7,8,9,10,11,12,13,14,15,16,55,25,18,25,18,25,18,25,18,0,5,55,18,25,18,25,0,5,7,8,9,10,11,12,13,14,15,16,0,55,7,8,9,10,11,12,13,14,15,16,55,102,5,0,5,0,25,5,25,18,25,55,25,55,18,25,55,0,25,0,20,101,20,101,242,20,243,20,101,25,0,25,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,244,245,246,247,248,249,20,250,20,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,251,252,251,0,252,0,251,252,251,252,251,0,252,0,253,251,254,251,255,251,256,251,0,252,0,252,0,252,0,252,251,252,257,258,259,260,261,262,0,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,251,311,312,313,0,314,315,252,316,317,6,318,6,319,320,321,0,322,323,324,325,6,251,326,327,0,328,329,252,330,0,6,251,331,332,333,126,334,335,252,336,130,6,0,337,338,339,0,340,341,342,343,344,6,0,2,21,5,6,5,6,5,6,3,21,2,5,18,5,18,5,2,21,0,21,345,101,0,346,347,348,349,350,351,5,101,345,26,22,23,346,347,348,349,350,351,5,0,101,0,5,0,25,6,25,6,25,0,5,120,5,120,5,20,120,20,120,20,5,120,5,352,120,5,120,5,353,5,120,5,354,355,120,352,20,120,356,120,20,55,20,5,20,120,5,120,20,5,357,5,27,358,359,241,30,31,241,27,5,0,5,0,5,0,5,0,26,22,23,346,347,348,349,350,351,27,26,22,23,346,347,348,349,350,351,27,26,22,23,346,347,348,349,350,351,27,5,360,361,345,27,26,22,23,346,347,348,349,350,351,27,345,5,26,22,23,346,347,348,349,350,351,27,26,22,23,346,347,348,349,350,351,27,26,22,23,346,347,348,349,350,351,27,5,0,5,0,5,0,5,0,5,0,5,0,135,0,136,0,30,31,362,363,364,365,366,30,31,30,31,30,31,367,368,369,370,20,30,31,20,30,31,20,101,371,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,20,5,30,31,30,31,25,30,31,0,5,27,5,372,0,372,0,372,0,55,0,102,5,0,25,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,25,5,373,5,0,5,0,5,0,5,0,5,0,2,5,102,55,241,5,241,25,18,5,102,5,241,102,55,5,0,55,0,25,6,102,55,5,55,5,102,55,0,55,0,55,0,5,27,5,55,0,5,0,55,5,0,27,5,27,5,27,5,27,5,27,5,0,55,374,55,374,55,374,55,374,55,0,5,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,0,55,102,55,0,5,0,55,102,5,55,102,5,55,7,8,9,10,11,12,13,14,15,16,55,0,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,55,25,6,5,25,5,102,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,101,25,55,241,25,5,0,6,102,6,30,31,30,31,30,31,30,31,30,31,30,31,30,31,20,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,101,20,30,31,30,31,375,30,31,30,31,30,31,30,31,30,31,102,6,30,31,376,20,55,30,31,30,31,20,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,30,31,377,378,379,380,0,381,382,383,384,30,31,30,31,0,55,101,20,55,25,55,25,55,25,55,18,25,18,5,0,27,5,0,55,5,0,18,55,18,25,0,5,7,8,9,10,11,12,13,14,15,16,0,25,55,5,55,5,55,0,7,8,9,10,11,12,13,14,15,16,55,25,5,55,25,18,0,5,55,0,25,18,55,25,18,25,18,25,18,5,0,102,7,8,9,10,11,12,13,14,15,16,0,5,55,25,102,55,7,8,9,10,11,12,13,14,15,16,55,0,55,25,18,25,18,25,0,55,25,55,25,18,0,7,8,9,10,11,12,13,14,15,16,0,5,55,102,55,5,55,18,25,18,55,25,55,25,55,25,55,25,55,25,55,0,55,102,5,55,18,25,18,5,55,102,18,25,0,55,0,55,0,55,0,55,0,55,0,20,385,20,6,101,20,0,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,55,18,25,18,25,18,5,18,25,0,7,8,9,10,11,12,13,14,15,16,0,55,0,55,0,55,0,1,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,0,55,0,466,467,468,469,470,471,472,0,473,474,475,476,477,0,55,25,55,5,55,0,55,0,55,0,55,0,55,0,55,6,0,55,478,55,5,0,55,0,55,0,55,478,5,0,25,5,6,5,0,25,5,18,5,18,5,6,0,5,6,5,0,5,0,478,55,478,55,478,0,478,55,478,55,478,55,478,55,478,55,0,21,0,5,6,5,6,5,7,8,9,10,11,12,13,14,15,16,6,5,17,5,6,18,6,19,5,55,102,55,479,55,0,55,0,55,0,55,0,55,0,5,6,5,0,5,0,21,5,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,5,0,27,0,5,241,27,5,27,5,0,5,0,5,0,5,25,0,55,0,55,0,25,27,0,55,27,0,55,241,55,241,0,55,25,0,55,0,5,55,0,55,5,241,0,480,481,55,0,7,8,9,10,11,12,13,14,15,16,0,55,0,55,0,5,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,5,27,55,5,27,55,0,27,0,55,0,55,0,27,55,27,0,5,55,0,5,0,55,0,27,55,27,0,27,55,25,0,25,0,25,55,0,55,0,55,0,25,0,25,26,22,23,346,27,0,5,0,55,27,5,55,27,0,55,5,55,25,0,27,5,0,55,0,5,55,0,27,55,0,27,55,0,5,0,27,0,55,0,108,0,115,0,27,0,26,22,23,346,347,348,349,350,351,27,0,18,25,18,55,25,5,0,26,22,23,346,347,348,349,350,351,27,7,8,9,10,11,12,13,14,15,16,0,25,18,55,18,25,18,25,5,21,5,0,55,0,7,8,9,10,11,12,13,14,15,16,0,25,55,25,18,25,0,7,8,9,10,11,12,13,14,15,16,5,0,55,25,5,55,0,25,18,55,18,25,18,55,5,25,5,0,7,8,9,10,11,12,13,14,15,16,55,5,55,5,0,27,0,55,0,55,18,25,18,25,18,25,5,0,55,0,55,0,55,0,55,0,55,5,0,55,25,18,25,0,7,8,9,10,11,12,13,14,15,16,0,25,18,0,55,0,55,0,55,0,55,0,55,0,55,0,25,55,18,25,18,0,18,0,18,0,55,0,18,0,55,18,0,25,0,25,0,55,18,25,18,25,18,25,18,25,55,5,55,0,7,8,9,10,11,12,13,14,15,16,0,55,18,25,0,18,25,18,25,5,55,25,0,55,18,25,18,25,18,25,5,55,0,7,8,9,10,11,12,13,14,15,16,0,55,25,18,25,18,25,18,25,0,7,8,9,10,11,12,13,14,15,16,0,55,0,25,18,25,18,25,0,7,8,9,10,11,12,13,14,15,16,27,5,0,17,19,7,8,9,10,11,12,13,14,15,16,27,0,55,0,55,0,55,0,241,0,5,0,55,0,55,0,55,0,55,0,55,0,7,8,9,10,11,12,13,14,15,16,0,5,0,55,0,25,5,0,55,25,5,102,5,0,7,8,9,10,11,12,13,14,15,16,0,27,0,55,0,55,0,55,0,55,18,0,25,102,0,55,0,55,0,55,0,55,0,55,0,5,25,5,21,0,5,0,5,0,5,18,25,5,18,21,25,5,25,5,25,5,0,5,25,5,0,5,0,27,0,120,20,120,20,0,20,120,20,120,0,120,0,120,0,120,0,120,0,120,20,0,20,0,20,0,20,120,20,120,0,120,0,120,0,120,0,20,120,0,120,0,120,0,120,0,120,0,20,120,20,120,20,120,20,120,20,120,20,120,20,0,120,5,20,5,20,120,5,20,5,20,120,5,20,5,20,120,5,20,5,20,120,5,20,5,20,120,20,0,7,8,9,10,11,12,13,14,15,16,7,8,9,10,11,12,13,14,15,16,7,8,9,10,11,12,13,14,15,16,7,8,9,10,11,12,13,14,15,16,7,8,9,10,11,12,13,14,15,16,25,5,25,5,25,5,25,5,0,25,0,25,0,55,0,27,25,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,55,0,5,0,5,0,5,0,5,0,5,0,5,0,5,0,345,26,22,23,346,347,348,349,350,351,27,0,5,0,482,5,482,5,0,482,5,0,5,0,5,0,5,0,5,0,5,6,5,0,5,0,5,0,5,0,5,0,5,0,5,0,5,0,5,0,5,0,5,0,5,0,5,0,5,0,5,0,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,374,55,0,55,0,55,0,55,0,55,0,21,0,21,25,0,1,0],O=1,P=2,Q=4,R=8,T=64,U=128,V=256,W=512,X=1024,Y=2048,Z=4096,$=8192,rn=16384;
unicode=unicode||{},unicode.title=function(r){for(var n="",t=!1,e=0;r.length>e;e++){var c=r.charAt(e);n+=t?x(c,r,e):S(c),t=z(c)}return n},unicode.capitalize=function(r){var n="";n+=w(r.charAt(0));for(var t=1;r.length>t;t++)n+=x(r.charAt(t),r,t);return n},unicode.casefold=function(r){for(var n="",t=0;r.length>t;t++)n+=b(r.charAt(t));return n},unicode.islower=function(r){if(""==r)return!1;for(var n=!1,t=0;r.length>t;t++){var e=r.charAt(t);if(p(e)||o(e))return!1;n||(n=g(e))}return n},unicode.isupper=function(r){if(""==r)return!1;for(var n=!1,t=0;r.length>t;t++){var e=r.charAt(t);if(g(e)||o(e))return!1;n||(n=p(e))}return n},unicode.istitle=function(r){if(""==r)return!1;for(var n=!1,t=!1,e=0;r.length>e;e++){var c=r.charAt(e);if(p(c)||o(c)){if(t)return!1;t=!0,n=!0}else if(g(c)){if(!t)return!1;t=!0,n=!0}else t=!1}return n},unicode.isspace=function(r){if(""==r)return!1;for(var n=0;r.length>n;n++){var t=r.charAt(n);if(!u(t))return!1}return!0},unicode.isalpha=function(r){if(""==r)return!1;for(var n=0;r.length>n;n++){var t=r.charAt(n);if(!j(t))return!1}return!0},unicode.isalnum=function(r){if(""==r)return!1;for(var n=0;r.length>n;n++){var t=r.charAt(n);if(!k(t))return!1}return!0},unicode.isdecimal=function(r){if(""==r)return!1;for(var n=0;r.length>n;n++){var t=r.charAt(n);if(!s(t))return!1}return!0},unicode.isdigit=function(r){if(""==r)return!1;for(var n=0;r.length>n;n++){var t=r.charAt(n);if(!A(t))return!1}return!0},unicode.isnumeric=function(r){if(""==r)return!1;for(var n=0;r.length>n;n++){var t=r.charAt(n);if(!l(t))return!1}return!0},unicode.isidentifier=function(r){if(""==r)return!1;if("_"!=r.charAt(0)&&!f(r.charAt(0)))return!1;for(var n=1;r.length>n;n++)if(!h(r.charAt(n)))return!1;return!0},unicode.isprintable=function(r){for(var n=0;r.length>n;n++)if(!C(r.charAt(n)))return!1;return!0},unicode.lower=function(r){for(var n="",t=0;r.length>t;t++){var e=r.charAt(t);n+=x(e,r,t)}return n},unicode.swapcase=function(r){for(var n="",t=0;r.length>t;t++){var e=r.charAt(t);n+=p(e)?x(e,r,t):g(e)?w(e):e}return n},unicode.upper=function(r){for(var n="",t=0;r.length>t;t++){var e=r.charAt(t);n+=w(e)}return n}}({},function(){return this}());
var __BRYTHON__=__BRYTHON__ ||{}
;(function($B){
var isWebWorker=('undefined' !==typeof WorkerGlobalScope)&&("function"===typeof importScripts)&&(navigator instanceof WorkerNavigator)
var _window=self;
var $path
if($B.brython_path===undefined){
var this_url;
if(isWebWorker){this_url=_window.location.href;}else{
var scripts=document.getElementsByTagName('script')
this_url=scripts[scripts.length-1].src}
var elts=this_url.split('/')
elts.pop()
$path=$B.brython_path=elts.join('/')+'/'}else{
$path=$B.brython_path}
var $href=$B.script_path=_window.location.href
var $href_elts=$href.split('/')
$href_elts.pop()
var $script_dir=$B.script_dir=$href_elts.join('/')
$B.__ARGV=[]
$B.$py_module_path={}
$B.$py_src={}
$B.path=[$path+'Lib',$path+'libs',$script_dir,$path+'Lib/site-packages']
$B.bound={}
$B.async_enabled=false
if($B.async_enabled)$B.block={}
$B.modules={}
$B.imported={}
$B.vars={}
$B._globals={}
$B.frames_stack=[]
$B.builtins={__repr__:function(){return "<module 'builtins>'"},__str__:function(){return "<module 'builtins'>"},}
$B.builtins_block={id:'__builtins__',module:'__builtins__'}
$B.modules['__builtins__']=$B.builtins_block
$B.bound['__builtins__']={'__BRYTHON__':true,'$eval':true,'$open': true}
$B.bound['__builtins__']['BaseException']=true
$B.builtin_funcs={}
$B.__getattr__=function(attr){return this[attr]}
$B.__setattr__=function(attr,value){
if(['debug','stdout','stderr'].indexOf(attr)>-1){$B[attr]=value}
else{throw $B.builtins.AttributeError('__BRYTHON__ object has no attribute '+attr)}}
$B.language=_window.navigator.userLanguage ||_window.navigator.language
if(isWebWorker){$B.charset="utf-8"}else{
$B.charset=document.characterSet ||document.inputEncoding ||"utf-8"}
$B.max_int=Math.pow(2,53)-1
$B.min_int=-$B.max_int
$B.$py_next_hash=Math.pow(2,53)-1
$B.$py_UUID=0
$B.lambda_magic=Math.random().toString(36).substr(2,8)
$B.callbacks={}
$B.set_func_names=function(klass){var name=klass.__name__
for(var attr in klass){if(typeof klass[attr]=='function'){klass[attr].$infos={__qualname__ : name+'.'+attr,__name__:attr}}}}
var has_storage=typeof(Storage)!=="undefined"
if(has_storage){$B.has_local_storage=false
try{
if(localStorage){$B.local_storage=localStorage
$B.has_local_storage=true}}catch(err){}
$B.has_session_storage=false
try{
if(sessionStorage){$B.session_storage=sessionStorage
$B.has_session_storage=true}}catch(err){}}else{
$B.has_local_storage=false
$B.has_session_storage=false}
$B.globals=function(){
return $B.frames_stack[$B.frames_stack.length-1][3]}
$B.regexIdentifier=/^(?:[\$A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D])(?:[\$0-9A-Z_a-z\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF])*$/})(__BRYTHON__)
__BRYTHON__.implementation=[3,3,5,'dev',0]
__BRYTHON__.__MAGIC__="3.3.5"
__BRYTHON__.version_info=[3,3,0,'alpha',0]
__BRYTHON__.compiled_date="2017-12-12 15:51:09.124854"
__BRYTHON__.builtin_module_names=["posix","sys","errno","time","_ajax","_base64","_jsre","_multiprocessing","_posixsubprocess","_profile","_svg","_sys","builtins","dis","hashlib","json","long_int","math","modulefinder","random","_abcoll","_codecs","_collections","_csv","_functools","_imp","_io","_random","_socket","_sre","_string","_struct","_sysconfigdata","_testcapi","_thread","_warnings","_weakref"]
;(function($B){var js,$pos,res,$op
var _b_=$B.builtins
var _window=self;
var isWebWorker=$B.isa_web_worker=('undefined' !==typeof WorkerGlobalScope)&&("function"===typeof importScripts)&&(navigator instanceof WorkerNavigator);
var keys=$B.keys=function(obj){var res=[],pos=0
for(var attr in obj){res[pos++]=attr}
res.sort()
return res}
var clone=$B.clone=function(obj){var res={}
for(var attr in obj){res[attr]=obj[attr]}
return res}
$B.last=function(table){return table[table.length-1]}
$B.list2obj=function(list,value){var res={},i=list.length
if(value===undefined){value=true}
while(i-->0){res[list[i]]=value}
return res}
var $operators={"//=":"ifloordiv",">>=":"irshift","<<=":"ilshift","**=":"ipow","**":"pow","//":"floordiv","<<":"lshift",">>":"rshift","+=":"iadd","-=":"isub","*=":"imul","/=":"itruediv","%=":"imod","&=":"iand","|=":"ior","^=":"ixor","+":"add","-":"sub","*":"mul","/":"truediv","%":"mod","&":"and","|":"or","~":"invert","^":"xor","<":"lt",">":"gt","<=":"le",">=":"ge","==":"eq","!=":"ne","or":"or","and":"and","in":"in","not": "not","is":"is","not_in":"not_in","is_not":"is_not" }
var $augmented_assigns=$B.augmented_assigns={"//=":"ifloordiv",">>=":"irshift","<<=":"ilshift","**=":"ipow","+=":"iadd","-=":"isub","*=":"imul","/=":"itruediv","%=":"imod","&=":"iand","|=":"ior","^=":"ixor"}
var noassign=$B.list2obj(['True','False','None','__debug__'])
var $op_order=[['or'],['and'],['not'],['in','not_in'],['<','<=','>','>=','!=','==','is','is_not'],['|'],['^'],['&'],['>>','<<'],['+'],['-'],['*','/','//','%'],['unary_neg','unary_inv','unary_pos'],['**']
]
var $op_weight={}
var $weight=1
for(var $i=0;$i<$op_order.length;$i++){var _tmp=$op_order[$i]
for(var $j=0;$j<_tmp.length;$j++){$op_weight[_tmp[$j]]=$weight}
$weight++}
var $loop_num=0
var chained_comp_num=0
function $_SyntaxError(C,msg,indent){
var ctx_node=C
while(ctx_node.type!=='node'){ctx_node=ctx_node.parent}
var tree_node=ctx_node.node,root=tree_node
while(root.parent!==undefined){root=root.parent}
var module=tree_node.module
var line_num=tree_node.line_num
if(root.line_info){line_num=root.line_info}
if(indent!==undefined){line_num++}
if(indent===undefined){if(Array.isArray(msg)){$B.$SyntaxError(module,msg[0],$pos)}
if(msg==="Triple string end not found"){
$B.$SyntaxError(module,'invalid syntax : triple string end not found',$pos,line_num,root)}
$B.$SyntaxError(module,'invalid syntax',$pos,line_num,root)}else{throw $B.$IndentationError(module,msg,$pos)}}
function $Node(type){this.type=type
this.children=[]
this.yield_atoms=[]
this.add=function(child){
this.children[this.children.length]=child
child.parent=this
child.module=this.module}
this.insert=function(pos,child){
this.children.splice(pos,0,child)
child.parent=this
child.module=this.module}
this.toString=function(){return "<object 'Node'>"}
this.show=function(indent){
var res=''
if(this.type==='module'){for(var i=0;i<this.children.length;i++){res +=this.children[i].show(indent)}
return res}
indent=indent ||0
res +=' '.repeat(indent)
res +=this.C
if(this.children.length>0)res +='{'
res +='\n'
for(var i=0;i<this.children.length;i++){res +='['+i+'] '+this.children[i].show(indent+4)}
if(this.children.length>0){res +=' '.repeat(indent)
res+='}\n'}
return res}
this.to_js=function(indent){
if(this.js!==undefined)return this.js
this.res=[]
var pos=0
this.unbound=[]
if(this.type==='module'){for(var i=0;i<this.children.length;i++){this.res[pos++]=this.children[i].to_js()
this.children[i].js_index=pos }
this.js=this.res.join('')
return this.js}
indent=indent ||0
var ctx_js=this.C.to_js()
if(ctx_js){
this.res[pos++]=' '.repeat(indent)
this.res[pos++]=ctx_js
this.js_index=pos
if(this.children.length>0)this.res[pos++]='{'
this.res[pos++]='\n'
for(var i=0;i<this.children.length;i++){this.res[pos++]=this.children[i].to_js(indent+4)
this.children[i].js_index=pos }
if(this.children.length>0){this.res[pos++]=' '.repeat(indent)
this.res[pos++]='}\n'}}
this.js=this.res.join('')
return this.js}
this.transform=function(rank){
if(this.yield_atoms.length>0){
this.parent.children.splice(rank,1)
var offset=0
for(var i=0;i<this.yield_atoms.length;i++){var atom=this.yield_atoms[i]
if(atom.from){
atom.transform(this,rank)
continue}else{
var temp_node=new $Node()
var js='var $yield_value'+$loop_num
js +='='+(this.yield_atoms[i].to_js()||'None')
new $NodeJSCtx(temp_node,js)
this.parent.insert(rank+offset,temp_node)
var yield_node=new $Node()
this.parent.insert(rank+offset+1,yield_node)
var yield_expr=new $YieldCtx(new $NodeCtx(yield_node))
new $StringCtx(yield_expr,'$yield_value'+$loop_num)
var set_yield=new $Node()
set_yield.is_set_yield_value=true
js=$loop_num
new $NodeJSCtx(set_yield,js)
this.parent.insert(rank+offset+2,set_yield)
this.yield_atoms[i].to_js=(function(x){return function(){return '$yield_value'+x}})($loop_num)
$loop_num++
offset +=3}}
this.parent.insert(rank+offset,this)
this.yield_atoms=[]
return offset+1}
if(this.type==='module'){
this.doc_string=$get_docstring(this)
var i=0
while(i<this.children.length){var offset=this.children[i].transform(i)
if(offset===undefined){offset=1}
i +=offset}}else{var elt=this.C.tree[0],ctx_offset
if(elt.transform !==undefined){ctx_offset=elt.transform(this,rank)}
var i=0
while(i<this.children.length){var offset=this.children[i].transform(i)
if(offset===undefined){offset=1}
i +=offset}
if(ctx_offset===undefined){ctx_offset=1}
if(this.C && this.C.tree!==undefined &&
this.C.tree[0].type=="generator"){var def_node=this,def_ctx=def_node.C.tree[0]
var blocks=[],node=def_node.parent_block,is_comp=node.is_comp
while(true){var node_id=node.id.replace(/\./g,'_'),block='"$locals_'+node_id+'": '
if(is_comp){block +='$B.clone($locals_'+node_id+')'}else{block +='$locals_'+node_id}
blocks.push(block)
node=node.parent_block
if(node===undefined ||node.id=='__builtins__'){break}}
blocks='{'+blocks+'}'
var parent=this.parent
while(parent!==undefined && parent.id===undefined){parent=parent.parent}
var g=$B.$BRgenerator(def_ctx.name,blocks,def_ctx.id,def_node),block_id=parent.id.replace(/\./g,'_'),name=def_ctx.decorated ? def_ctx.alias :
def_ctx.name+def_ctx.num,res='var '+def_ctx.name+def_ctx.num + ' = '+
'$locals_'+block_id+'["'+def_ctx.name+
'"] = $B.genfunc("'+
def_ctx.name+'", '+blocks+',['+g+'],'+
def_ctx.default_str+')'
this.parent.children.splice(rank,1)
this.parent.insert(rank+offset-1,$NodeJS(res))}
return ctx_offset}}
this.clone=function(){var res=new $Node(this.type)
for(var attr in this){res[attr]=this[attr]}
return res}}
function $AbstractExprCtx(C,with_commas){this.type='abstract_expr'
this.with_commas=with_commas
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
this.toString=function(){return '(abstract_expr '+with_commas+') '+this.tree}
this.to_js=function(){this.js_processed=true
if(this.type==='list')return '['+$to_js(this.tree)+']'
return $to_js(this.tree)}}
function $AliasCtx(C){
this.type='ctx_manager_alias'
this.parent=C
this.tree=[]
C.tree[C.tree.length-1].alias=this}
function $AnnotationCtx(C){
this.type='annotation'
this.parent=C
this.tree=[]
C.annotation=this
this.toString=function(){return '(annotation) '+this.tree}
this.to_js=function(){return $to_js(this.tree)}}
function $AssertCtx(C){
this.type='assert'
this.toString=function(){return '(assert) '+this.tree}
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
this.transform=function(node,rank){if(this.tree[0].type==='list_or_tuple'){
var condition=this.tree[0].tree[0]
var message=this.tree[0].tree[1]}else{var condition=this.tree[0]
var message=null}
var new_ctx=new $ConditionCtx(node.C,'if')
var not_ctx=new $NotCtx(new_ctx)
not_ctx.tree=[condition]
node.C=new_ctx
var new_node=new $Node()
var js='throw AssertionError("AssertionError")'
if(message !==null){js='throw AssertionError(str('+message.to_js()+'))'}
new $NodeJSCtx(new_node,js)
node.add(new_node)}}
function $AssignCtx(C){
var ctx=C
while(ctx){if(ctx.type=='assert'){$_SyntaxError(C,'invalid syntax - assign')}
ctx=ctx.parent}
this.type='assign'
C.parent.tree.pop()
C.parent.tree[C.parent.tree.length]=this
this.parent=C.parent
this.tree=[C]
var scope=$get_scope(this),level=$get_level(this)
if(C.type=='expr' && C.tree[0].type=='call'){$_SyntaxError(C,["can't assign to function call "])}else if(C.type=='list_or_tuple' ||
(C.type=='expr' && C.tree[0].type=='list_or_tuple')){if(C.type=='expr'){C=C.tree[0]}
C.bind_ids(scope.id,level)}else if(C.type=='assign'){for(var i=0;i<C.tree.length;i++){var assigned=C.tree[i].tree[0]
if(assigned.type=='id'){$bind(assigned.value,scope.id,level)}}}else{var assigned=C.tree[0]
if(assigned && assigned.type=='id'){if(noassign[assigned.value]===true){$_SyntaxError(C,["can't assign to keyword"])}
assigned.bound=true
if(!$B._globals[scope.id]||
$B._globals[scope.id][assigned.value]===undefined){
var node=$get_node(this)
node.bound_before=$B.keys($B.bound[scope.id])
$bind(assigned.value,scope.id,level)}else{
var module=$get_module(C)
$bind(assigned.value,module.id,level)}}else if(["str","int","float","complex"].indexOf(assigned.type)>-1){$_SyntaxError(C,["can't assign to literal"])}}
this.guess_type=function(){return}
this.toString=function(){return '(assign) '+this.tree[0]+'='+this.tree[1]}
this.transform=function(node,rank){
var scope=$get_scope(this)
var left=this.tree[0],right=this.tree[1],assigned=[]
while(left.type=='assign'){assigned.push(left.tree[1])
left=left.tree[0]}
if(assigned.length>0){assigned.push(left)
var ctx=node.C
ctx.tree=[]
var nleft=new $RawJSCtx(ctx,'var $temp'+$loop_num)
nleft.tree=ctx.tree
nassign=new $AssignCtx(nleft)
nassign.tree[1]=right
for(var i=0;i<assigned.length;i++){var new_node=new $Node(),node_ctx=new $NodeCtx(new_node)
new_node.locals=node.locals
node.parent.insert(rank+1,new_node)
assigned[i].parent=node_ctx
var assign=new $AssignCtx(assigned[i])
new $RawJSCtx(assign,'$temp'+$loop_num)}
$loop_num++
return assigned.length-1}
var left_items=null
switch(left.type){case 'expr':
if(left.tree.length>1){left_items=left.tree}else if(left.tree[0].type==='list_or_tuple'||left.tree[0].type==='target_list'){left_items=left.tree[0].tree}else if(left.tree[0].type=='id'){
var name=left.tree[0].value
if($B._globals && $B._globals[scope.id]
&& $B._globals[scope.id][name]){}else{left.tree[0].bound=true}}
break
case 'target_list':
case 'list_or_tuple':
left_items=left.tree}
if(left_items===null){return}
var right=this.tree[1]
var right_items=null
if(right.type==='list'||right.type==='tuple'||
(right.type==='expr' && right.tree.length>1)){right_items=right.tree}
if(right_items!==null){
if(right_items.length>left_items.length){throw Error('ValueError : too many values to unpack (expected '+left_items.length+')')}else if(right_items.length<left_items.length){throw Error('ValueError : need more than '+right_items.length+' to unpack')}
var new_nodes=[],pos=0
var new_node=new $Node()
new $NodeJSCtx(new_node,'void(0)')
new_nodes[pos++]=new_node
var $var='$temp'+$loop_num
var new_node=new $Node()
new $NodeJSCtx(new_node,'var '+$var+'=[], $pos=0')
new_nodes[pos++]=new_node
for(var i=0;i<right_items.length;i++){var js=$var+'[$pos++]='+right_items[i].to_js()
var new_node=new $Node()
new $NodeJSCtx(new_node,js)
new_nodes[pos++]=new_node}
for(var i=0;i<left_items.length;i++){var new_node=new $Node(),this_node=$get_node(this)
new_node.id=this_node.module
new_node.locals=this.node.locals
var C=new $NodeCtx(new_node)
left_items[i].parent=C
var assign=new $AssignCtx(left_items[i],false)
assign.tree[1]=new $JSCode($var+'['+i+']')
new_nodes[pos++]=new_node}
node.parent.children.splice(rank,1)
for(var i=new_nodes.length-1;i>=0;i--){node.parent.insert(rank,new_nodes[i])}
$loop_num++}else{
var new_node=new $Node()
new_node.line_num=node.line_num
var rname='$right'+$loop_num
var js='var '+rname+' = getattr'
js +='($B.$iter('+right.to_js()+'),"__next__");'
new $NodeJSCtx(new_node,js)
var new_nodes=[new_node],pos=1
var rlist_node=new $Node()
var rlname='$rlist'+$loop_num
js='var '+rlname+'=[], $pos=0;'+'while(1){try{'+rlname+
'[$pos++] = '+rname+'()}catch(err){break}};'
new $NodeJSCtx(rlist_node,js)
new_nodes[pos++]=rlist_node
var packed=null
for(var i=0;i<left_items.length;i++){var expr=left_items[i]
if(expr.type=='packed' ||
(expr.type=='expr' && expr.tree[0].type=='packed')){packed=i
break}}
var check_node=new $Node()
var min_length=left_items.length
if(packed!==null){min_length--}
js='if('+rlname+'.length<'+min_length+')'+
'{throw ValueError("need more than "+'+rlname+
'.length+" value" + ('+rlname+'.length>1 ?'+
' "s" : "")+" to unpack")}'
new $NodeJSCtx(check_node,js)
new_nodes[pos++]=check_node
if(packed==null){var check_node=new $Node()
var min_length=left_items.length
js='if('+rlname+'.length>'+min_length+')'+
'{throw ValueError("too many values to unpack '+
'(expected '+left_items.length+')")}'
new $NodeJSCtx(check_node,js)
new_nodes[pos++]=check_node}
for(var i=0;i<left_items.length;i++){var new_node=new $Node()
new_node.id=scope.id
var C=new $NodeCtx(new_node)
left_items[i].parent=C
var assign=new $AssignCtx(left_items[i],false)
var js=rlname
if(packed==null ||i<packed){js +='['+i+']'}else if(i==packed){js +='.slice('+i+','+rlname+'.length-'+
(left_items.length-i-1)+')'}else{js +='['+rlname+'.length-'+(left_items.length-i)+']'}
assign.tree[1]=new $JSCode(js)
new_nodes[pos++]=new_node}
node.parent.children.splice(rank,1)
for(var i=new_nodes.length-1;i>=0;i--){node.parent.insert(rank,new_nodes[i])}
$loop_num++}}
this.to_js=function(){this.js_processed=true
if(this.parent.type==='call'){
return '{$nat:"kw",name:'+this.tree[0].to_js()+',value:'+this.tree[1].to_js()+'}'}
var left=this.tree[0]
if(left.type==='expr')left=left.tree[0]
var right=this.tree[1]
if(left.type=='attribute' ||left.type=='sub'){
var right_js=right.to_js()
var res='',rvar='',$var='$temp'+$loop_num
if(right.type=='expr' && right.tree[0]!==undefined &&
right.tree[0].type=='call' &&
('eval'==right.tree[0].func.value ||
'exec'==right.tree[0].func.value)){res +='var '+$var+'='+right_js+';\n'
rvar=$var}else if(right.type=='expr' && right.tree[0]!==undefined &&
right.tree[0].type=='sub'){res +='var '+$var+'='+right_js+';\n'
rvar=$var}else{rvar=right_js}
if(left.type==='attribute'){
$loop_num++
left.func='setattr'
var left_to_js=left.to_js()
left.func='getattr'
if(left.assign_self){return res + left_to_js[0]+ rvar + left_to_js[1]+ rvar + ')'}
res +=left_to_js
res=res.substr(0,res.length-1)
return res + ','+rvar+');None;'}
if(left.type==='sub'){
var seq=left.value.to_js(),temp='$temp'+$loop_num,type
if(left.value.type=='id'){type=$get_node(this).locals[left.value.value]}
$loop_num++
var res='var '+temp+'='+seq+'\n'
if(type!=='list'){res +='if(Array.isArray('+temp+') && !'+temp+'.__class__){'}
if(left.tree.length==1){res +='$B.set_list_key('+temp+','+
(left.tree[0].to_js()+''||'null')+','+
right.to_js()+')'}else if(left.tree.length==2){res +='$B.set_list_slice('+temp+','+
(left.tree[0].to_js()+''||'null')+','+
(left.tree[1].to_js()+''||'null')+','+
right.to_js()+')'}else if(left.tree.length==3){res +='$B.set_list_slice_step('+temp+','+
(left.tree[0].to_js()+''||'null')+','+
(left.tree[1].to_js()+''||'null')+','+
(left.tree[2].to_js()+''||'null')+','+
right.to_js()+')'}
if(type=='list'){return res}
res +='\n}else{'
if(left.tree.length==1){res +='$B.$setitem('+left.value.to_js()
res +=','+left.tree[0].to_js()+','+right_js+')};None;'}else{left.func='setitem'
res +=left.to_js()
res=res.substr(0,res.length-1)
left.func='getitem'
res +=','+right_js+')};None;'}
return res}}
return left.to_js()+'='+right.to_js()}}
function $AsyncCtx(C){
this.type='async'
this.parent=C
C.async=true
this.toString=function(){return '(async)'}}
function $AttrCtx(C){
this.type='attribute'
this.value=C.tree[0]
this.parent=C
C.tree.pop()
C.tree[C.tree.length]=this
this.tree=[]
this.func='getattr'
this.toString=function(){return '(attr) '+this.value+'.'+this.name}
this.to_js=function(){this.js_processed=true
var js=this.value.to_js()
if(this.func=="setattr" && this.value.type=="id"){var scope=$get_scope(this),parent=scope.parent
if(scope.ntype=="def"){if(parent.ntype=="class"){var params=scope.C.tree[0].positional_list
if(this.value.value==params[0]&& parent.C &&
parent.C.tree[0].args===undefined){
this.assign_self=true
return[js+".__class__.__setattr__==="+
"undefined && "+js+'.__class__ !== $B.$factory ? '+
js+"."+this.name+" = "," : $B.$setattr("+js+', "'+
this.name+'", ']}}}}
if(this.func=='setattr'){
return '$B.$setattr('+js+',"'+this.name+'")'}else{
return 'getattr('+js+',"'+this.name+'")'}}}
function $AugmentedAssignCtx(C,op){
this.type='augm_assign'
this.parent=C.parent
C.parent.tree.pop()
C.parent.tree[C.parent.tree.length]=this
this.op=op
this.tree=[C]
var scope=this.scope=$get_scope(this)
if(C.type=='expr'){var assigned=C.tree[0]
if(assigned.type=='id'){var name=assigned.value
if(noassign[name]===true){$_SyntaxError(C,["can't assign to keyword"])}else if((scope.ntype=='def'||scope.ntype=='generator')&&
$B.bound[scope.id][name]===undefined){if(scope.globals===undefined ||scope.globals.indexOf(name)==-1){
assigned.unbound=true}}}else if(['str','int','float','complex'].indexOf(assigned.type)>-1){$_SyntaxError(C,["can't assign to literal"])}}
$get_node(this).bound_before=$B.keys($B.bound[scope.id])
this.module=scope.module
this.toString=function(){return '(augm assign) '+this.tree}
this.transform=function(node,rank){var func='__'+$operators[op]+'__'
var offset=0,parent=node.parent
var line_num=node.line_num,lnum_set=false
parent.children.splice(rank,1)
var left_is_id=(this.tree[0].type=='expr' &&
this.tree[0].tree[0].type=='id')
if(left_is_id){
this.tree[0].tree[0].augm_assign=true
if($B.debug>0){var check_node=$NodeJS('if('+this.tree[0].to_js()+
'===undefined){throw NameError("name \''+
this.tree[0].tree[0].value+'\' is not defined")}')
node.parent.insert(rank,check_node)
offset++}
var left_id=this.tree[0].tree[0].value,was_bound=$B.bound[this.scope.id][left_id]!==undefined,left_id_unbound=this.tree[0].tree[0].unbound}
var right_is_int=(this.tree[1].type=='expr' &&
this.tree[1].tree[0].type=='int')
var right=right_is_int ? this.tree[1].tree[0].to_js(): '$temp'
if(!right_is_int){
var new_node=new $Node()
new_node.line_num=line_num
lnum_set=true
new $NodeJSCtx(new_node,'var $temp,$left;')
parent.insert(rank,new_node)
offset++
var new_node=new $Node()
new_node.id=this.scope.id
var new_ctx=new $NodeCtx(new_node)
var new_expr=new $ExprCtx(new_ctx,'js',false)
var _id=new $RawJSCtx(new_expr,'$temp')
var assign=new $AssignCtx(new_expr)
assign.tree[1]=this.tree[1]
_id.parent=assign
parent.insert(rank+offset,new_node)
offset++}
var prefix='',in_class=false
switch(op){case '+=':
case '-=':
case '*=':
case '/=':
if(left_is_id){var scope=this.scope,global_ns='$local_'+scope.module.replace(/\./g,'_')
switch(scope.ntype){case 'module':
prefix=global_ns
break
case 'def':
case 'generator':
if(scope.globals && scope.globals.indexOf(C.tree[0].value)>-1){prefix=global_ns}else{prefix='$locals'}
break;
case 'class':
var new_node=new $Node()
if(!lnum_set){new_node.line_num=line_num;lnum_set=true}
new $NodeJSCtx(new_node,'var $left='+C.to_js())
parent.insert(rank+offset,new_node)
in_class=true
offset++}}}
var left=C.tree[0].to_js()
prefix=prefix && !C.tree[0].unknown_binding && !left_id_unbound
var op1=op.charAt(0)
if(prefix){var left1=in_class ? '$left' : left
var new_node=new $Node()
if(!lnum_set){new_node.line_num=line_num;lnum_set=true}
js=right_is_int ? 'if(' : 'if(typeof $temp.valueOf()=="number" && '
js +=left1+'.constructor===Number'
js +='&& '+left+op1+right+'>$B.min_int && '+left+op1+right+
'< $B.max_int){'
js +=right_is_int ? '(' : '(typeof $temp=="number" && '
js +='typeof '+left1+'=="number") ? '
js +=left+op+right
js +=' : ('+left1+'.constructor===Number ? '
js +=left+'=float('+left+op1
js +=right_is_int ? right : right+'.valueOf()'
js +=') : '+left + op
js +=right_is_int ? right : right+'.valueOf()'
js +=')}'
new $NodeJSCtx(new_node,js)
parent.insert(rank+offset,new_node)
offset++}
var aaops={'+=':'add','-=':'sub','*=':'mul'}
if(C.tree[0].type=='sub' &&
('+='==op ||'-='==op ||'*='==op)&&
C.tree[0].tree.length==1){var js1='$B.augm_item_'+aaops[op]+'('
js1 +=C.tree[0].value.to_js()
js1 +=','+C.tree[0].tree[0].to_js()+','
js1 +=right+');None;'
var new_node=new $Node()
if(!lnum_set){new_node.line_num=line_num;lnum_set=true}
new $NodeJSCtx(new_node,js1)
parent.insert(rank+offset,new_node)
offset++
return}
var new_node=new $Node()
if(!lnum_set){new_node.line_num=line_num;lnum_set=true}
var js=''
if(prefix){js +='else '}
js +='if(!hasattr('+C.to_js()+',"'+func+'"))'
new $NodeJSCtx(new_node,js)
parent.insert(rank+offset,new_node)
offset ++
var aa1=new $Node()
aa1.id=this.scope.id
var ctx1=new $NodeCtx(aa1)
var expr1=new $ExprCtx(ctx1,'clone',false)
if(left_id_unbound){new $RawJSCtx(expr1,'$locals["'+left_id+'"]')}else{expr1.tree=C.tree
for(var i=0;i<expr1.tree.length;i++){expr1.tree[i].parent=expr1}}
var assign1=new $AssignCtx(expr1)
var new_op=new $OpCtx(expr1,op.substr(0,op.length-1))
new_op.parent=assign1
new $RawJSCtx(new_op,right)
assign1.tree.push(new_op)
expr1.parent.tree.pop()
expr1.parent.tree.push(assign1)
new_node.add(aa1)
var aa2=new $Node()
new $NodeJSCtx(aa2,'else')
parent.insert(rank+offset,aa2)
var aa3=new $Node()
var js3='getattr('+C.to_js()+',"'+func+'")('+right+')'
new $NodeJSCtx(aa3,js3)
aa2.add(aa3)
if(left_is_id && !was_bound && !this.scope.blurred){$B.bound[this.scope.id][left_id]=undefined}
return offset}
this.to_js=function(){return ''}}
function $BodyCtx(C){
var ctx_node=C.parent
while(ctx_node.type!=='node'){ctx_node=ctx_node.parent}
var tree_node=ctx_node.node
var body_node=new $Node()
body_node.line_num=tree_node.line_num
tree_node.insert(0,body_node)
return new $NodeCtx(body_node)}
function set_loop_C(C,kw){
var ctx_node=C
while(ctx_node.type!=='node'){ctx_node=ctx_node.parent}
var tree_node=ctx_node.node
var loop_node=tree_node.parent
var break_flag=false
while(1){if(loop_node.type==='module'){
$_SyntaxError(C,kw+' outside of a loop')}else{var ctx=loop_node.C.tree[0]
if(ctx.type==='condition' && ctx.token==='while'){this.loop_ctx=ctx
ctx['has_'+kw]=true
break}
switch(ctx.type){case 'for':
this.loop_ctx=ctx
ctx['has_'+kw]=true
break_flag=true
break
case 'def':
case 'generator':
case 'class':
$_SyntaxError(C,kw+' outside of a loop')
default:
loop_node=loop_node.parent}
if(break_flag)break}}}
function $BreakCtx(C){
this.type='break'
this.toString=function(){return 'break '}
this.parent=C
C.tree[C.tree.length]=this
set_loop_C.apply(this,[C,'break'])
this.to_js=function(){this.js_processed=true
var scope=$get_scope(this)
var res=';$locals_'+scope.id.replace(/\./g,'_')+
'["$no_break'+this.loop_ctx.loop_num+'"]=false'
if(this.loop_ctx.type!='asyncfor'){res +=';break'}else{res +=';throw StopIteration('+this.loop_ctx.loop_num+')'}
return res}}
function $CallArgCtx(C){
this.type='call_arg'
this.toString=function(){return 'call_arg '+this.tree}
this.parent=C
this.start=$pos
this.tree=[]
C.tree[C.tree.length]=this
this.expect='id'
this.to_js=function(){this.js_processed=true
return $to_js(this.tree)}}
function $CallCtx(C){
this.type='call'
this.func=C.tree[0]
if(this.func!==undefined){
this.func.parent=this}
this.parent=C
if(C.type!='class'){C.tree.pop()
C.tree[C.tree.length]=this}else{
C.args=this}
this.expect='id'
this.tree=[]
this.start=$pos
this.toString=function(){return '(call) '+this.func+'('+this.tree+')'}
if(this.func && this.func.type=="attribute" && this.func.name=="wait"
&& this.func.value.type=="id" && this.func.value.value=="time"){console.log('call',this.func)
$get_node(this).blocking={'type': 'wait','call': this}}
if(this.func && this.func.value=='input'){$get_node(this).blocking={'type': 'input'}}
this.to_js=function(){this.js_processed=true
if(this.tree.length>0){if(this.tree[this.tree.length-1].tree.length==0){
this.tree.pop()}}
var func_js=this.func.to_js()
if(this.func!==undefined){switch(this.func.value){case 'classmethod':
return 'classmethod('+$to_js(this.tree)+')'
case '$$super':
if(this.tree.length==0){
var scope=$get_scope(this)
if(scope.ntype=='def' ||scope.ntype=='generator'){var def_scope=$get_scope(scope.C.tree[0])
if(def_scope.ntype=='class'){new $IdCtx(this,def_scope.C.tree[0].name)}}}
if(this.tree.length==1){
var scope=$get_scope(this)
if(scope.ntype=='def' ||scope.ntype=='generator'){var args=scope.C.tree[0].args
if(args.length>0){new $IdCtx(this,args[0])}}}
break
default:
if(this.func.type=='unary'){
switch(this.func.op){case '+':
return 'getattr('+$to_js(this.tree)+',"__pos__")()'
case '-':
return 'getattr('+$to_js(this.tree)+',"__neg__")()'
case '~':
return 'getattr('+$to_js(this.tree)+',"__invert__")()'}}}
var _block=false
if($B.async_enabled){var scope=$get_scope(this.func)
if($B.block[scope.id]===undefined){}
else if($B.block[scope.id][this.func.value])_block=true}
var positional=[],kw_args=[],star_args=false,dstar_args=[]
for(var i=0;i<this.tree.length;i++){var arg=this.tree[i],type
switch(arg.type){case 'star_arg':
star_args=true
positional.push([arg.tree[0].tree[0].to_js(),'*'])
break
case 'double_star_arg':
dstar_args.push(arg.tree[0].tree[0].to_js())
break
case 'id':
positional.push([arg.to_js(),'s'])
break
default:
if(arg.tree[0]===undefined){console.log('bizarre',arg)}
else{type=arg.tree[0].type}
switch(type){case 'expr':
positional.push([arg.to_js(),'s'])
break
case 'kwarg':
kw_args.push(arg.tree[0].tree[0].value+':'+arg.tree[0].tree[1].to_js())
break
case 'list_or_tuple':
case 'op':
positional.push([arg.to_js(),'s'])
break
case 'star_arg':
star_args=true
positional.push([arg.tree[0].tree[0].to_js(),'*'])
break
case 'double_star_arg':
dstar_args.push(arg.tree[0].tree[0].to_js())
break
default:
positional.push([arg.to_js(),'s'])
break}
break}}
var args_str
if(star_args){
var p=[]
for(var i=0,len=positional.length;i<len;i++){arg=positional[i]
if(arg[1]=='*'){
p.push('_b_.list('+arg[0]+')')}else{var elt=[positional[i][0]]
i++
while(i<len && positional[i][1]=='s'){elt.push(positional[i][0])
i++}
i--
p.push('['+elt.join(',')+']')}}
args_str=p[0]
for(var i=1;i<p.length;i++){args_str +='.concat('+p[i]+')'}}else{for(var i=0,len=positional.length;i<len;i++){positional[i]=positional[i][0]}
args_str=positional.join(', ')}
var kw_args_str='{'+kw_args.join(', ')+'}'
if(dstar_args.length){kw_args_str='{$nat:"kw",kw:$B.extend("'+this.func.value+
'",'+kw_args_str + ',' + dstar_args.join(', ')+')}'}else if(kw_args_str!=='{}'){kw_args_str='{$nat:"kw",kw:'+kw_args_str+'}'}else{kw_args_str=''}
if(star_args && kw_args_str){args_str +='.concat(['+kw_args_str+'])'}else{if(args_str && kw_args_str){args_str +=','+kw_args_str}
else if(!args_str){args_str=kw_args_str}}
if(star_args){
args_str='.apply(null,'+args_str+')'}else{args_str='('+args_str+')'}
if(this.tree.length>-1){if(this.func.type=='id'){if(this.func.is_builtin){
if($B.builtin_funcs[this.func.value]!==undefined){return func_js+args_str}}else{var bound_obj=this.func.found
if(bound_obj &&(bound_obj.type=='class' ||
bound_obj.type=='def')){return func_js+args_str}}
var res='getattr('+func_js+',"__call__")'+args_str}else{var res='getattr('+func_js+',"__call__")'+args_str}
return res}
return 'getattr('+func_js+',"__call__")'+args_str}}}
function $ClassCtx(C){
this.type='class'
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
this.expect='id'
this.toString=function(){return '(class) '+this.name+' '+this.tree+' args '+this.args}
var scope=this.scope=$get_scope(this)
this.parent.node.parent_block=scope
this.parent.node.bound={}
this.set_name=function(name){this.random=$B.UUID()
this.name=name
this.id=C.node.module+'_'+name+'_'+this.random
$B.bound[this.id]={}
if($B.async_enabled)$B.block[this.id]={}
$B.modules[this.id]=this.parent.node
this.parent.node.id=this.id
var parent_block=scope
while(parent_block.C && parent_block.C.tree[0].type=='class'){parent_block=parent_block.parent}
while(parent_block.C &&
'def' !=parent_block.C.tree[0].type &&
'generator' !=parent_block.C.tree[0].type){parent_block=parent_block.parent}
this.parent.node.parent_block=parent_block
this.level=this.scope.level
$B.bound[this.scope.id][name]=this
if(scope.is_function){if(scope.C.tree[0].locals.indexOf(name)==-1){scope.C.tree[0].locals.push(name)}}}
this.transform=function(node,rank){
this.doc_string=$get_docstring(node)
var instance_decl=new $Node()
var local_ns='$locals_'+this.id.replace(/\./g,'_')
var js=';var '+local_ns+'={$type:"class"}, $locals = '+local_ns+
', $local_name="'+local_ns+'";'
new $NodeJSCtx(instance_decl,js)
node.insert(0,instance_decl)
var global_scope=this.scope
while(global_scope.parent_block.id !=='__builtins__'){global_scope=global_scope.parent_block}
var global_ns='$locals_'+global_scope.id.replace(/\./g,'_')
var js=';var $top_frame = [$local_name, $locals,'+
'"'+global_scope.id+'", '+global_ns+
']; $B.frames_stack.push($top_frame);'
node.insert(1,$NodeJS(js))
node.add($NodeJS('$B.leave_frame()'))
var ret_obj=new $Node()
new $NodeJSCtx(ret_obj,'return '+local_ns+';')
node.insert(node.children.length,ret_obj)
var run_func=new $Node()
new $NodeJSCtx(run_func,')();')
node.parent.insert(rank+1,run_func)
var scope=$get_scope(this)
var name_ref=';$locals_'+scope.id.replace(/\./g,'_')
name_ref +='["'+this.name+'"]'
var js=[name_ref +'=$B.$class_constructor("'+this.name],pos=1
js[pos++]='",$'+this.name+'_'+this.random
if(this.args!==undefined){
var arg_tree=this.args.tree,args=[],kw=[]
for(var i=0;i<arg_tree.length;i++){var _tmp=arg_tree[i]
if(_tmp.tree[0].type=='kwarg'){kw.push(_tmp.tree[0])}
else{args.push(_tmp.to_js())}}
js[pos++]=',tuple(['+args.join(',')+']),['
var _re=new RegExp('"','g')
var _r=[],rpos=0
for(var i=0;i<args.length;i++){_r[rpos++]='"'+args[i].replace(_re,'\\"')+'"'}
js[pos++]=_r.join(',')+ ']'
_r=[],rpos=0
for(var i=0;i<kw.length;i++){var _tmp=kw[i]
_r[rpos++]='["'+_tmp.tree[0].value+'",'+_tmp.tree[1].to_js()+']'}
js[pos++]=',[' + _r.join(',')+ ']'}else{
js[pos++]=',tuple([]),[],[]'}
js[pos++]=')'
var cl_cons=new $Node()
new $NodeJSCtx(cl_cons,js.join(''))
rank++
node.parent.insert(rank+1,cl_cons)
rank++
var ds_node=new $Node()
js=name_ref+'.$dict.__doc__='
if(this.name=='classXXX'){
js=name_ref+'.__doc__='}
js +=(this.doc_string ||'None')+';'
new $NodeJSCtx(ds_node,js)
node.parent.insert(rank+1,ds_node)
rank++
js=name_ref+'.$dict.__module__=$locals_'
if(this.name=='classXXX'){
js=name_ref+'.__module__=$locals_'}
js +=$get_module(this).module.replace(/\./g,'_')+'.__name__'
var mod_node=new $Node()
new $NodeJSCtx(mod_node,js)
node.parent.insert(rank+1,mod_node)
if(scope.ntype==='module'){var w_decl=new $Node()
new $NodeJSCtx(w_decl,'$locals["'+ this.name+'"]='+this.name)}
var end_node=new $Node()
new $NodeJSCtx(end_node,'None;')
node.parent.insert(rank+2,end_node)
this.transformed=true}
this.to_js=function(){this.js_processed=true
return 'var $'+this.name+'_'+this.random+'=(function()'}}
function $CompIfCtx(C){
this.type='comp_if'
C.parent.intervals.push($pos)
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
this.toString=function(){return '(comp if) '+this.tree}
this.to_js=function(){this.js_processed=true
return $to_js(this.tree)}}
function $ComprehensionCtx(C){
this.type='comprehension'
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
this.toString=function(){return '(comprehension) '+this.tree}
this.to_js=function(){this.js_processed=true
var _i=[],pos=0
for(var j=0;j<this.tree.length;j++)_i[pos++]=this.tree[j].start
return _i}}
function $CompForCtx(C){
this.type='comp_for'
C.parent.intervals.push($pos)
this.parent=C
this.tree=[]
this.expect='in'
C.tree[C.tree.length]=this
this.toString=function(){return '(comp for) '+this.tree}
this.to_js=function(){this.js_processed=true
return $to_js(this.tree)}}
function $CompIterableCtx(C){
this.type='comp_iterable'
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
this.toString=function(){return '(comp iter) '+this.tree}
this.to_js=function(){this.js_processed=true
return $to_js(this.tree)}}
function $ConditionCtx(C,token){
this.type='condition'
this.token=token
this.parent=C
this.tree=[]
if(token==='while'){this.loop_num=$loop_num++}
C.tree[C.tree.length]=this
this.toString=function(){return this.token+' '+this.tree}
this.transform=function(node,rank){var scope=$get_scope(this)
if(this.token=="while"){if(scope.ntype=='generator'){this.parent.node.loop_start=this.loop_num}
var new_node=new $Node()
var js='$locals["$no_break'+this.loop_num+'"]=true'
new $NodeJSCtx(new_node,js)
node.parent.insert(rank,new_node)
return 2}}
this.to_js=function(){this.js_processed=true
var tok=this.token
if(tok==='elif'){tok='else if'}
var res=[tok+'($B.$bool(']
if(tok=='while'){res.push('$locals["$no_break'+this.loop_num+'"] && ')}else if(tok=='else if'){var line_info=$get_node(this).line_num+','+$get_scope(this).id
res.push('($locals.$line_info="'+line_info+'") && ')}
if(this.tree.length==1){res.push($to_js(this.tree)+'))')}else{
res.push(this.tree[0].to_js()+'))')
if(this.tree[1].tree.length>0){res.push('{'+this.tree[1].to_js()+'}')}}
return res.join('')}}
function $ContinueCtx(C){
this.type='continue'
this.parent=C
$get_node(this).is_continue=true
C.tree[C.tree.length]=this
set_loop_C.apply(this,[C,'continue'])
this.toString=function(){return '(continue)'}
this.to_js=function(){this.js_processed=true
return 'continue'}}
function $DebuggerCtx(C){
this.type='continue'
this.parent=C
C.tree[C.tree.length]=this
this.toString=function(){return '(debugger)'}
this.to_js=function(){this.js_processed=true
return 'debugger'}}
function $DecoratorCtx(C){
this.type='decorator'
this.parent=C
C.tree[C.tree.length]=this
this.tree=[]
this.toString=function(){return '(decorator) '+this.tree}
this.transform=function(node,rank){var func_rank=rank+1,children=node.parent.children
var decorators=[this.tree]
while(1){if(func_rank>=children.length){$_SyntaxError(C,['decorator expects function'])}
else if(children[func_rank].C.type=='node_js'){func_rank++}
else if(children[func_rank].C.tree[0].type==='decorator'){decorators.push(children[func_rank].C.tree[0].tree)
children.splice(func_rank,1)}else{break}}
this.dec_ids=[]
var pos=0
for(var i=0;i<decorators.length;i++){this.dec_ids[pos++]='$id'+ $B.UUID()}
if($B.async_enabled){var _block_async_flag=false;
for(var i=0;i<decorators.length;i++){try{
var name=decorators[i][0].tree[0].value
if(name=="brython_block" ||name=="brython_async")_block_async_flag=true}catch(err){console.log(i);console.log(decorators[i][0])}}}
var obj=children[func_rank].C.tree[0]
if(obj.type=='def'){obj.decorated=true
obj.alias='$dec'+$B.UUID()}
var tail='',scope=$get_scope(this),ref='$locals["'
if($B._globals[scope.id]&& $B._globals[scope.id][obj.name]){var module=$get_module(this)
ref='$locals_'+module.id+'["'}
ref +=obj.name+'"]'
var res=ref+'='
for(var i=0;i<decorators.length;i++){
res +='getattr('+this.dec_ids[i]+',"__call__")('
tail +=')'}
res +=(obj.decorated ? obj.alias : ref)+tail+';'
$B.bound[scope.id][obj.name]=true
var decor_node=new $Node()
new $NodeJSCtx(decor_node,res)
node.parent.insert(func_rank+1,decor_node)
this.decorators=decorators}
this.to_js=function(){if($B.async_enabled){if(this.processing !==undefined)return ""}
this.js_processed=true
var res=[],pos=0
for(var i=0;i<this.decorators.length;i++){res[pos++]='var '+this.dec_ids[i]+'='+$to_js(this.decorators[i])+';'}
return res.join('')}}
function $DefCtx(C){this.type='def'
this.name=null
this.parent=C
this.tree=[]
this.async=C.async
this.locals=[]
this.yields=[]
C.tree[C.tree.length]=this
this.enclosing=[]
var scope=this.scope=$get_scope(this)
if(scope.C && scope.C.tree[0].type=="class"){this.class_name=scope.C.tree[0].name}
var parent_block=scope
while(parent_block.C && parent_block.C.tree[0].type=='class'){parent_block=parent_block.parent}
while(parent_block.C &&
'def' !=parent_block.C.tree[0].type &&
'generator' !=parent_block.C.tree[0].type){parent_block=parent_block.parent}
this.parent.node.parent_block=parent_block
var pb=parent_block
while(pb && pb.C){if(pb.C.tree[0].type=='def'){this.inside_function=true
break}
pb=pb.parent_block}
this.module=scope.module
this.num=$loop_num
$loop_num++
this.positional_list=[]
this.default_list=[]
this.other_args=null
this.other_kw=null
this.after_star=[]
this.set_name=function(name){try{name=$mangle(name,this.parent.tree[0])}catch(err){console.log(err)
console.log('parent',this.parent)
throw err}
var id_ctx=new $IdCtx(this,name)
this.name=name
this.id=this.scope.id+'_'+name
this.id=this.id.replace(/\./g,'_')
this.id +='_'+ $B.UUID()
this.parent.node.id=this.id
this.parent.node.module=this.module
$B.modules[this.id]=this.parent.node
$B.bound[this.id]={}
this.level=this.scope.level
if($B._globals[this.scope.id]!==undefined &&
$B._globals[this.scope.id][name]!==undefined){
$B.bound[this.module][name]=this}else{$B.bound[this.scope.id][name]=this}
id_ctx.bound=true
if(scope.is_function){if(scope.C.tree[0].locals.indexOf(name)==-1){scope.C.tree[0].locals.push(name)}}}
this.toString=function(){return 'def '+this.name+'('+this.tree+')'}
this.transform=function(node,rank){
if(this.transformed!==undefined)return
var scope=this.scope
var pb=this.parent.node
while(pb && pb.C){if(pb.C.tree[0].type=='def'){this.inside_function=true
break}
pb=pb.parent}
this.doc_string=$get_docstring(node)
this.rank=rank
var indent=node.indent+16
if(this.name.substr(0,15)=='lambda_'+$B.lambda_magic){var pblock=$B.modules[scope.id].parent_block
if(pblock.C && pblock.C.tree[0].type=="def"){this.enclosing.push(pblock)}}
var pnode=this.parent.node
while(pnode.parent && pnode.parent.is_def_func){this.enclosing.push(pnode.parent.parent)
pnode=pnode.parent.parent}
var defaults=[],apos=0,dpos=0,defs1=[],dpos1=0
this.argcount=0
this.kwonlyargcount=0
this.varnames={}
this.args=[]
this.__defaults__=[]
this.slots=[]
var slot_list=[]
var annotations=[]
if(this.annotation){annotations.push('"return":'+this.annotation.to_js())}
var func_args=this.tree[1].tree
for(var i=0;i<func_args.length;i++){var arg=func_args[i]
this.args[apos++]=arg.name
this.varnames[arg.name]=true
if(arg.type==='func_arg_id'){if(this.star_arg){this.kwonlyargcount++}
else{this.argcount++}
this.slots.push(arg.name+':null')
slot_list.push('"'+arg.name+'"')
if(arg.tree.length>0){defaults[dpos++]='"'+arg.name+'"'
defs1[dpos1++]=arg.name+':'+$to_js(arg.tree)
this.__defaults__.push($to_js(arg.tree))}}else if(arg.type=='func_star_arg'){if(arg.op=='*'){this.star_arg=arg.name}
else if(arg.op=='**'){this.kw_arg=arg.name}}
if(arg.annotation){annotations.push(arg.name+': '+arg.annotation.to_js())}}
var flags=67
if(this.star_arg){flags |=4}
if(this.kw_arg){flags |=8}
if(this.type=='generator'){flags |=32}
var positional_str=[],positional_obj=[],pos=0
for(var i=0,_len=this.positional_list.length;i<_len;i++){positional_str[pos]='"'+this.positional_list[i]+'"'
positional_obj[pos++]=this.positional_list[i]+':null'}
positional_str=positional_str.join(',')
positional_obj='{'+positional_obj.join(',')+'}'
var dobj=[],pos=0
for(var i=0;i<this.default_list.length;i++){dobj[pos++]=this.default_list[i]+':null'}
dobj='{'+dobj.join(',')+'}'
var nodes=[],js
var global_scope=scope
while(global_scope.parent_block.id !=='__builtins__'){global_scope=global_scope.parent_block}
var global_ns='$locals_'+global_scope.id.replace(/\./g,'_')
var prefix=this.tree[0].to_js()
if(this.decorated){prefix=this.alias}
var name=this.name+this.num
var local_ns='$locals_'+this.id
js='var '+local_ns+'={}, '
js +='$local_name="'+this.id+'",$locals='+local_ns+';'
var new_node=new $Node()
new_node.locals_def=true
new $NodeJSCtx(new_node,js)
nodes.push(new_node)
var enter_frame_node=new $Node(),js=';var $top_frame = [$local_name, $locals,'+
'"'+global_scope.id+'", '+global_ns+
']; $B.frames_stack.push($top_frame); var $stack_length = '+
'$B.frames_stack.length;'
if($B.profile > 1){if(this.scope.ntype=='class'){fname=this.scope.C.tree[0].name+'.'+this.name}
else fname=this.name
if(pnode && pnode.id){fmod=pnode.id.slice(0,pnode.id.indexOf('_'))}
else fmod='';
js=";var _parent_line_info={}; if($B.frames_stack[$B.frames_stack.length-1]){"+
" _parent_line_info=$B.frames_stack[$B.frames_stack.length-1][1].$line_info;"+
"} else {_parent_line_info="+global_ns+".$line_info};"+
";$B.$profile.call('"+fmod+"','"+fname+"',"+
node.line_num+",_parent_line_info)"+js;}
enter_frame_node.enter_frame=true
new $NodeJSCtx(enter_frame_node,js)
nodes.push(enter_frame_node)
this.env=[]
var make_args_nodes=[]
var js=this.type=='def' ? local_ns+' = $locals' : 'var $ns'
js +=' = $B.args("'+this.name+'", '+
this.argcount+', {'+this.slots.join(', ')+'}, '+
'['+slot_list.join(', ')+'], arguments, '
if(defs1.length){js +='$defaults, '}
else{js +='{}, '}
js +=this.other_args+', '+this.other_kw+');'
var new_node=new $Node()
new $NodeJSCtx(new_node,js)
make_args_nodes.push(new_node)
if(this.type=='generator'){
js='for(var $var in $ns){$locals[$var]=$ns[$var]};'
make_args_nodes.push($NodeJS(js))}
var only_positional=false
if(this.other_args===null && this.other_kw===null &&
this.after_star.length==0
&& defaults.length==0){
only_positional=true
if($B.debug>0 ||this.positional_list.length>0){
nodes.push($NodeJS('var $len = arguments.length;'))
var new_node=new $Node()
var js='if($len>0 && arguments[$len-1].$nat!==undefined)'
new $NodeJSCtx(new_node,js)
nodes.push(new_node)
new_node.add(make_args_nodes[0])
if(make_args_nodes.length>1){new_node.add(make_args_nodes[1])}
var else_node=new $Node()
new $NodeJSCtx(else_node,'else')
nodes.push(else_node)}
var pos_len=this.positional_list.length
if($B.debug>0){
js='if($len!='+pos_len+'){$B.wrong_nb_args("'+this.name+
'", $len, '+pos_len
if(positional_str.length>0){js +=', ['+positional_str+']'}
js +=')}'
else_node.add($NodeJS(js))}
if(this.positional_list.length>0){if(this.type=='generator'){for(var i=0;i<this.positional_list.length;i++){var arg=this.positional_list[i]
var new_node=new $Node()
var js='$locals["'+arg+'"]='+arg
new $NodeJSCtx(new_node,js)
else_node.add(new_node)}}else{var pargs=[]
for(var i=0;i<this.positional_list.length;i++){var arg=this.positional_list[i]
pargs.push(arg+':'+arg)}
if($B.debug < 1){js='if($len!='+pos_len+'){$B.wrong_nb_args("'+this.name+
'", $len, '+pos_len
if(positional_str.length>0){js +=', ['+positional_str+']'}
js +=')}'
else_node.add($NodeJS(js))}
else_node.add($NodeJS(local_ns+'=$locals={'+pargs.join(', ')+'}'))}}}else{nodes.push(make_args_nodes[0])
if(make_args_nodes.length>1){nodes.push(make_args_nodes[1])}}
nodes.push($NodeJS('$B.frames_stack[$B.frames_stack.length-1][1] = $locals;'))
nodes.push($NodeJS('$B.js_this = this;'))
for(var i=nodes.length-1;i>=0;i--){node.children.splice(0,0,nodes[i])}
var def_func_node=new $Node()
this.params=''
if(only_positional){this.params=Object.keys(this.varnames).join(', ')
new $NodeJSCtx(def_func_node,'')}else{new $NodeJSCtx(def_func_node,'')}
def_func_node.is_def_func=true
def_func_node.module=this.module
var last_instr=node.children[node.children.length-1].C.tree[0]
if(last_instr.type!=='return' && this.type!='generator'){
var js='$B.leave_frame'
if(this.id.substr(0,5)=='$exec'){js +='_exec'}
node.add($NodeJS(js+'($local_name);return None'))}
node.add(def_func_node)
var offset=1
var indent=node.indent
node.parent.insert(rank+offset++,$NodeJS(name+'.$infos = {'))
var __name__=this.name
if(__name__.substr(0,15)=='lambda_'+$B.lambda_magic){__name__="<lambda>"}
js=' __name__:"' + __name__ + '",'
node.parent.insert(rank+offset++,$NodeJS(js))
var __qualname__=__name__
if(this.class_name){__qualname__=this.class_name + '.' + __name__}
js=' __qualname__:"' + __qualname__ + '",'
node.parent.insert(rank+offset++,$NodeJS(js))
var def_names=[]
for(var i=0;i<this.default_list.length;i++){def_names.push('"'+this.default_list[i]+'"')}
node.parent.insert(rank+offset++,$NodeJS(' __defaults__ : ['+
def_names.join(', ')+'],'))
var module=$get_module(this)
js=' __module__ : "'+module.module+'",'
node.parent.insert(rank+offset++,$NodeJS(js))
js=' __doc__: '+(this.doc_string ||'None')+','
node.parent.insert(rank+offset++,$NodeJS(js))
js=' __annotations__: {'+annotations.join(',')+'},'
node.parent.insert(rank+offset++,$NodeJS(js))
for(var attr in $B.bound[this.id]){this.varnames[attr]=true}
var co_varnames=[]
for(var attr in this.varnames){co_varnames.push('"'+attr+'"')}
var h='\n'+' '.repeat(indent+8)
js=' __code__:{'+h+' __class__:$B.$CodeDict'
var h1=','+h+' '.repeat(4)
js +=h1+'co_argcount:'+this.argcount+
h1+'co_filename:$locals_'+scope.module.replace(/\./g,'_')+'["__file__"]'+
h1+'co_firstlineno:'+node.line_num+
h1+'co_flags:'+flags+
h1+'co_kwonlyargcount:'+this.kwonlyargcount+
h1+'co_name: "'+this.name+'"'+
h1+'co_nlocals: '+co_varnames.length+
h1+'co_varnames: ['+co_varnames.join(', ')+']'+
h+'}\n };'
js +='None;'
new_node=new $Node()
new $NodeJSCtx(new_node,js)
node.parent.insert(rank+offset++,new_node)
this.default_str='{'+defs1.join(', ')+'}'
if(this.type=="def"){node.parent.insert(rank+offset++,$NodeJS('return '+name+'})('+
this.default_str+')'))}
if(this.type=='def'){var parent=node
for(var pos=0;pos<parent.children.length &&
parent.children[pos]!==enter_frame_node;pos++){}
var try_node=$NodeJS('try'),children=parent.children.slice(pos+1)
parent.insert(pos+1,try_node)
for(var i=0;i<children.length;i++){if(children[i].is_def_func){for(var j=0;j<children[i].children.length;j++){try_node.add(children[i].children[j])}}else{try_node.add(children[i])}}
parent.children.splice(pos+2,parent.children.length)
var except_node=$NodeJS('catch(err)')
except_node.add($NodeJS('$B.leave_frame($local_name);throw err'))
parent.add(except_node)}
this.transformed=true
return offset}
this.to_js=function(func_name){this.js_processed=true
func_name=func_name ||this.tree[0].to_js()
if(this.decorated){func_name='var '+this.alias}
func_name=func_name ||this.tree[0].to_js()
if(this.decorated){func_name='var '+this.alias}
return func_name+' = (function ($defaults){function '+
this.name+this.num+'('+this.params+')'}}
function $DelCtx(C){
this.type='del'
this.parent=C
C.tree[C.tree.length]=this
this.tree=[]
this.toString=function(){return 'del '+this.tree}
this.to_js=function(){this.js_processed=true
if(this.tree[0].type=='list_or_tuple'){
var res=[],pos=0
for(var i=0;i<this.tree[0].tree.length;i++){var subdel=new $DelCtx(C)
subdel.tree=[this.tree[0].tree[i]]
res[pos++]=subdel.to_js()
C.tree.pop()}
this.tree=[]
return res.join(';')}else{var expr=this.tree[0].tree[0]
switch(expr.type){case 'id':
return 'delete '+expr.to_js()+';'
case 'list_or_tuple':
var res=[],pos=0
for(var i=0;i<expr.tree.length;i++){res[pos++]='delete '+expr.tree[i].to_js()}
return res.join(';')
case 'sub':
expr.func='delitem'
js=expr.to_js()
expr.func='getitem'
return js
case 'op':
$_SyntaxError(this,["can't delete operator"])
case 'call':
$_SyntaxError(this,["can't delete function call"])
case 'attribute':
return 'delattr('+expr.value.to_js()+',"'+expr.name+'")'
default:
$_SyntaxError(this,["can't delete "+expr.type])}}}}
function $DictOrSetCtx(C){
this.type='dict_or_set'
this.real='dict_or_set'
this.expect='id'
this.closed=false
this.start=$pos
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
this.toString=function(){switch(this.real){case 'dict':
return '(dict) {'+this.items+'}'
case 'set':
return '(set) {'+this.tree+'}'}
return '(dict_or_set) {'+this.tree+'}'}
this.to_js=function(){this.js_processed=true
switch(this.real){case 'dict':
var res=[],pos=0
for(var i=0;i<this.items.length;i+=2){res[pos++]='['+this.items[i].to_js()+','+this.items[i+1].to_js()+']'}
return 'dict(['+res.join(',')+'])'+$to_js(this.tree)
case 'set_comp':
return 'set('+$to_js(this.items)+')'+$to_js(this.tree)
case 'dict_comp':
return 'dict('+$to_js(this.items)+')'+$to_js(this.tree)}
return 'set(['+$to_js(this.items)+'])'+$to_js(this.tree)}}
function $DoubleStarArgCtx(C){
this.type='double_star_arg'
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
this.toString=function(){return '**'+this.tree}
this.to_js=function(){this.js_processed=true
return '{$nat:"pdict",arg:'+$to_js(this.tree)+'}'}}
function $EllipsisCtx(C){
this.type='ellipsis'
this.parent=C
this.nbdots=1
C.tree[C.tree.length]=this
this.toString=function(){return 'ellipsis'}
this.to_js=function(){this.js_processed=true
return '$B.builtins["Ellipsis"]'}}
function $ExceptCtx(C){
this.type='except'
this.parent=C
C.tree[C.tree.length]=this
this.tree=[]
this.expect='id'
this.scope=$get_scope(this)
this.toString=function(){return '(except) '}
this.set_alias=function(alias){this.tree[0].alias=alias
$B.bound[this.scope.id][alias]={level: this.scope.level}}
this.to_js=function(){
this.js_processed=true
switch(this.tree.length){case 0:
return 'else'
case 1:
if(this.tree[0].name==='Exception')return 'else if(1)'}
var res=[],pos=0
for(var i=0;i<this.tree.length;i++){res[pos++]=this.tree[i].to_js()}
var lnum=''
if($B.debug>0){var module=$get_module(this)
lnum='($locals.$line_info="'+$get_node(this).line_num+','+
module.id+'") && '}
return 'else if('+lnum+'$B.is_exc('+this.error_name+',['+res.join(',')+']))'}}
function $ExprCtx(C,name,with_commas){
this.type='expr'
this.name=name
this.with_commas=with_commas
this.expect=','
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
this.toString=function(){return '(expr '+with_commas+') '+this.tree}
this.to_js=function(arg){this.js_processed=true
if(this.type==='list')return '['+$to_js(this.tree)+']'
if(this.tree.length===1)return this.tree[0].to_js(arg)
return 'tuple('+$to_js(this.tree)+')'}}
function $ExprNot(C){
this.type='expr_not'
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
this.toString=function(){return '(expr_not)'}}
function $FloatCtx(C,value){
this.type='float'
this.value=value
this.toString=function(){return 'float '+this.value}
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
this.to_js=function(){this.js_processed=true
if(/^\d+$/.exec(this.value)||
/^\d+\.\d*$/.exec(this.value)){return '(new Number('+this.value+'))'}
return 'float('+this.value+')'}}
function $ForExpr(C){
this.type='for'
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
this.loop_num=$loop_num
this.module=$get_scope(this).module
$loop_num++
this.toString=function(){return '(for) '+this.tree}
this.transform=function(node,rank){var scope=$get_scope(this),target=this.tree[0],target_is_1_tuple=target.tree.length==1 && target.expect=='id',iterable=this.tree[1],num=this.loop_num,local_ns='$locals_'+scope.id.replace(/\./g,'_'),h='\n'+' '.repeat(node.indent+4)
var $range=false
if(target.tree.length==1 &&
target.expct !='id' &&
iterable.type=='expr' &&
iterable.tree[0].type=='expr' &&
iterable.tree[0].tree[0].type=='call'){var call=iterable.tree[0].tree[0]
if(call.func.type=='id'){var func_name=call.func.value
if(func_name=='range' && call.tree.length<3){$range=call}}}
var new_nodes=[],pos=0
var children=node.children
var offset=1
if($range && scope.ntype!='generator'){if(this.has_break){
new_node=new $Node()
new $NodeJSCtx(new_node,local_ns+'["$no_break'+num+'"]=true')
new_nodes[pos++]=new_node}
var range_is_builtin=false
if(!scope.blurred){var _scope=$get_scope(this),found=[],fpos=0
while(1){if($B.bound[_scope.id]['range']){found[fpos++]=_scope.id}
if(_scope.parent_block){_scope=_scope.parent_block}
else{break}}
range_is_builtin=found.length==1 && found[0]=="__builtins__"
if(found==['__builtins__']){range_is_builtin=true}}
var test_range_node=new $Node()
if(range_is_builtin){new $NodeJSCtx(test_range_node,'if(1)')}else{new $NodeJSCtx(test_range_node,'if('+call.func.to_js()+'===$B.builtins.range)')}
new_nodes[pos++]=test_range_node
var idt=target.to_js()
if($range.tree.length==1){var start=0,stop=$range.tree[0].to_js()}else{var start=$range.tree[0].to_js(),stop=$range.tree[1].to_js()}
var js='var $stop_'+num +'=$B.int_or_bool('+
stop+');'+h+idt+'='+start+';'+h+
' var $next'+num+'= '+idt+','+h+
' $safe'+num+'= typeof $next'+num+'=="number" && typeof '+
'$stop_'+num+'=="number";'+h+'while(true)'
var for_node=new $Node()
new $NodeJSCtx(for_node,js)
for_node.add($NodeJS('if($safe'+num+' && $next'+num+'>= $stop_'+
num+'){break}'))
for_node.add($NodeJS('else if(!$safe'+num+
' && $B.ge($next'+num+', $stop_'+num+
')){break}'))
for_node.add($NodeJS(idt+' = $next'+num))
for_node.add($NodeJS('if($safe'+num+'){$next'+num+'+=1'+'}'))
for_node.add($NodeJS('else{$next'+num+'=$B.add($next'+num+',1)}'))
for(var i=0;i<children.length;i++){for_node.add(children[i].clone())}
for_node.add($NodeJS('$locals.$line_info="'+node.line_num+','+
scope.id+'"; None;'))
var in_loop=false
if(scope.ntype=='module'){var pnode=node.parent
while(pnode){if(pnode.for_wrapper){in_loop=true;break}
pnode=pnode.parent}}
if(scope.ntype=='module' && !in_loop){var func_node=new $Node()
func_node.for_wrapper=true
js='function $f'+num+'('
if(this.has_break){js +='$no_break'+num}
js +=')'
new $NodeJSCtx(func_node,js)
test_range_node.add(func_node)
func_node.add(for_node)
if(this.has_break){new_node=new $Node()
new $NodeJSCtx(new_node,'return $no_break'+num)
func_node.add(new_node)}
var end_func_node=new $Node()
new $NodeJSCtx(end_func_node,'var $res'+num+'=$f'+num+'();')
test_range_node.add(end_func_node)
if(this.has_break){var no_break=new $Node()
new $NodeJSCtx(no_break,'var $no_break'+num+'=$res'+num)
test_range_node.add(no_break)}}else{
test_range_node.add(for_node)}
if(range_is_builtin){node.parent.children.splice(rank,1)
var k=0
if(this.has_break){node.parent.insert(rank,new_nodes[0])
k++}
for(var i=new_nodes[k].children.length-1;i>=0;i--){node.parent.insert(rank+k,new_nodes[k].children[i])}
node.parent.children[rank].line_num=node.line_num
node.children=[]
return 0}
var else_node=new $Node()
new $NodeJSCtx(else_node,'else')
new_nodes[pos++]=else_node
for(var i=new_nodes.length-1;i>=0;i--){node.parent.insert(rank+1,new_nodes[i])}
this.test_range=true
new_nodes=[],pos=0}
var new_node=new $Node()
new_node.line_num=$get_node(this).line_num
var it_js=iterable.to_js()
var js='$locals["$next'+num+'"]'+'=getattr($B.$iter('+ it_js +
'),"__next__")'
new $NodeJSCtx(new_node,js)
new_nodes[pos++]=new_node
var js='if(isinstance('+it_js+', dict)){$locals.$len_func'+num+
'=getattr('+it_js+',"__len__"); $locals.$len'+num+
'=$locals.$len_func'+num+'()}else{$locals.$len'+num+'=null}'
new_nodes[pos++]=$NodeJS(js)
if(this.has_break){
new_node=new $Node()
new $NodeJSCtx(new_node,local_ns+'["$no_break'+num+'"]=true;')
new_nodes[pos++]=new_node}
var while_node=new $Node()
if(this.has_break){js='while('+local_ns+'["$no_break'+num+'"])'}
else{js='while(1)'}
new $NodeJSCtx(while_node,js)
while_node.C.loop_num=num
while_node.C.type='for'
while_node.line_num=node.line_num
if(scope.ntype=='generator'){
while_node.loop_start=num}
new_nodes[pos++]=while_node
node.parent.children.splice(rank,1)
if(this.test_range){for(var i=new_nodes.length-1;i>=0;i--){else_node.insert(0,new_nodes[i])}}else{for(var i=new_nodes.length-1;i>=0;i--){node.parent.insert(rank,new_nodes[i])
offset +=new_nodes.length}}
while_node.add($NodeJS('if($locals.$len'+num+'!==null && $locals.$len'+
num+'!=$locals.$len_func'+num+'()){throw RuntimeError("dictionary'+
' changed size during iteration")}'))
var try_node=new $Node()
new $NodeJSCtx(try_node,'try')
while_node.add(try_node)
var iter_node=new $Node()
iter_node.parent=$get_node(this).parent
iter_node.id=this.module
var C=new $NodeCtx(iter_node)
var target_expr=new $ExprCtx(C,'left',true)
if(target_is_1_tuple){
var t=new $ListOrTupleCtx(target_expr)
t.real='tuple'
t.tree=target.tree}else{target_expr.tree=target.tree}
var assign=new $AssignCtx(target_expr)
assign.tree[1]=new $JSCode('$locals["$next'+num+'"]()')
try_node.add(iter_node)
var catch_node=new $Node()
var js='catch($err){if($B.is_exc($err,[StopIteration]))'+
'{$B.clear_exc();break;}'
js +='else{throw($err)}}'
new $NodeJSCtx(catch_node,js)
while_node.add(catch_node)
for(var i=0;i<children.length;i++){while_node.add(children[i].clone())}
node.children=[]
return 0}
this.to_js=function(){this.js_processed=true
var iterable=this.tree.pop()
return 'for '+$to_js(this.tree)+' in '+iterable.to_js()}}
function $FromCtx(C){
this.type='from'
this.parent=C
this.module=''
this.names=[]
this.aliases={}
C.tree[C.tree.length]=this
this.expect='module'
this.scope=$get_scope(this)
this.add_name=function(name){this.names[this.names.length]=name
if(name=='*'){this.scope.blurred=true}}
this.transform=function(node,rank){if(!this.blocking){
var mod_name=this.module.replace(/\$/g,'')
if(this.names[0]=='*'){node.add($NodeJS('for(var $attr in $B.imported["'+mod_name+
'"]){if($attr.charAt(0)!=="_"){$locals[$attr]=$B.imported["'+mod_name+'"][$attr]}};'))}else{for(var i=0;i<this.names.length;i++){var name=this.names[i]
node.add($NodeJS('$locals["'+(this.aliases[name]||name)+
'"]=$B.imported["'+mod_name+'"]["'+name+'"]'))}}
for(var i=rank+1;i<node.parent.children.length;i++){node.add(node.parent.children[i])}
node.parent.children.splice(rank+1,node.parent.children.length)
node.parent.add($NodeJS(')'))}}
this.bind_names=function(){
var scope=$get_scope(this)
for(var i=0;i<this.names.length;i++){var name=this.aliases[this.names[i]]||this.names[i]
$B.bound[scope.id][name]={level: scope.level}}}
this.toString=function(){return '(from) '+this.module+' (import) '+this.names+'(as)'+this.aliases}
this.to_js=function(){this.js_processed=true
var scope=$get_scope(this),mod=$get_module(this).module,res=[],pos=0,indent=$get_node(this).indent,head=' '.repeat(indent);
var _mod=this.module.replace(/\$/g,''),$package,packages=[]
while(_mod.length>0){if(_mod.charAt(0)=='.'){if($package===undefined){if($B.imported[mod]!==undefined){$package=$B.imported[mod].__package__}}else{$package=$B.imported[$package]}
if($package===undefined){return 'throw SystemError("Parent module \'\' not loaded,'+
' cannot perform relative import")'}else if($package=='None'){console.log('package is None !')}else{packages.push($package)}
_mod=_mod.substr(1)}else{break}}
if(_mod){packages.push(_mod)}
this.module=packages.join('.')
var mod_name=this.module.replace(/\$/g,'')
if(this.blocking){res[pos++]='$B.$import("';
res[pos++]=mod_name+'",["';
res[pos++]=this.names.join('","')+'"], {';
var sep='';
for(var attr in this.aliases){res[pos++]=sep + '"'+attr+'": "'+this.aliases[attr]+'"';
sep=',';}
res[pos++]='}, {}, true);';
if(this.names[0]=='*'){res[pos++]='\n'+head+'for(var $attr in $B.imported["'+mod_name+
'"]){if($attr.charAt(0)!=="_"){'+
'$locals[$attr]=$B.imported["'+mod_name+'"][$attr]}};'}else{for(var i=0;i<this.names.length;i++){var name=this.names[i]
res[pos++]='\n'+head+'$locals["'+(this.aliases[name]||name)+
'"]=$B.imported["'+mod_name+'"]["'+name+'"];'}}
res[pos++]='\n'+head+'None;';}else{res[pos++]='$B.$import_non_blocking("'+mod_name+'", function()'}
if(this.names[0]=='*'){
scope.blurred=true}
return res.join('');}}
function $FuncArgs(C){
this.type='func_args'
this.parent=C
this.tree=[]
this.names=[]
C.tree[C.tree.length]=this
this.toString=function(){return 'func args '+this.tree}
this.expect='id'
this.has_default=false
this.has_star_arg=false
this.has_kw_arg=false
this.to_js=function(){this.js_processed=true
return $to_js(this.tree)}}
function $FuncArgIdCtx(C,name){
this.type='func_arg_id'
this.name=name
this.parent=C
if(C.has_star_arg){C.parent.after_star.push(name)}else{C.parent.positional_list.push(name)}
var node=$get_node(this)
if($B.bound[node.id][name]){$_SyntaxError(C,["duplicate argument '"+name+"' in function definition"])}
$B.bound[node.id][name]={level:1}
this.tree=[]
C.tree[C.tree.length]=this
var ctx=C
while(ctx.parent!==undefined){if(ctx.type==='def'){ctx.locals.push(name)
break}
ctx=ctx.parent}
this.expect='='
this.toString=function(){return 'func arg id '+this.name +'='+this.tree}
this.to_js=function(){this.js_processed=true
return this.name+$to_js(this.tree)}}
function $FuncStarArgCtx(C,op){
this.type='func_star_arg'
this.op=op
this.parent=C
this.node=$get_node(this)
C.has_star_arg=op=='*'
C.has_kw_arg=op=='**'
C.tree[C.tree.length]=this
this.toString=function(){return '(func star arg '+this.op+') '+this.name}
this.set_name=function(name){this.name=name
if(name=='$dummy'){return}
if($B.bound[this.node.id][name]){$_SyntaxError(C,["duplicate argument '"+name+"' in function definition"])}
$B.bound[this.node.id][name]={level:1}
var ctx=C
while(ctx.parent!==undefined){if(ctx.type==='def'){ctx.locals.push(name)
break}
ctx=ctx.parent}
if(op=='*'){ctx.other_args='"'+name+'"'}
else{ctx.other_kw='"'+name+'"'}}}
function $GlobalCtx(C){
this.type='global'
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
this.expect='id'
this.toString=function(){return 'global '+this.tree}
this.scope=$get_scope(this)
$B._globals[this.scope.id]=$B._globals[this.scope.id]||{}
this.add=function(name){$B._globals[this.scope.id][name]=true}
this.to_js=function(){this.js_processed=true
return ''}}
function $IdCtx(C,value){
this.type='id'
this.toString=function(){return '(id) '+this.value+':'+(this.tree||'')}
this.value=$mangle(value,C)
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
var scope=this.scope=$get_scope(this)
this.blurred_scope=this.scope.blurred
this.env=clone($B.bound[this.scope.id])
if(C.parent.type==='call_arg'){this.call_arg=true}
this.level=$get_level(this)
var ctx=C
while(ctx.parent!==undefined){switch(ctx.type){case 'ctx_manager_alias':
$B.bound[scope.id][value]={level: $get_level(this)}
break
case 'list_or_tuple':
case 'dict_or_set':
case 'call_arg':
case 'def':
case 'lambda':
if(ctx.vars===undefined){ctx.vars=[value]}
else if(ctx.vars.indexOf(value)===-1){ctx.vars.push(value)}
if(this.call_arg&&ctx.type==='lambda'){if(ctx.locals===undefined){ctx.locals=[value]}
else{ctx.locals.push(value)}}}
ctx=ctx.parent}
if(C.type=='target_list' ||
(C.type=='expr' && C.parent.type=='target_list')){
$B.bound[scope.id][value]={level: $get_level(this)}
this.bound=true}
if(scope.ntype=='def' ||scope.ntype=='generator'){
var _ctx=this.parent
while(_ctx){if(_ctx.type=='list_or_tuple' && _ctx.is_comp()){this.in_comp=true
return}
_ctx=_ctx.parent}
if(C.type=='expr' && C.parent.type=='comp_if'){
return}else if(C.type=='global'){if(scope.globals===undefined){scope.globals=[value]}else if(scope.globals.indexOf(value)==-1){scope.globals.push(value)}}}
this.to_js=function(arg){
if(this.result!==undefined && this.scope.ntype=='generator'){return this.result}
this.js_processed=true
var val=this.value
var is_local=$B.bound[this.scope.id][val]!==undefined,this_node=$get_node(this),bound_before=this_node.bound_before
if(this.scope.nonlocals && this.scope.nonlocals[val]!==undefined){this.nonlocal=true}
this.unbound=this.unbound ||(is_local && !this.bound &&
bound_before && bound_before.indexOf(val)==-1)
if((!this.bound)&& this.scope.C && this.scope.ntype=='class' &&
this.scope.C.tree[0].name==val){
return '$B.$search("'+val+'")'}
if(this.unbound && !this.nonlocal){if(this.scope.ntype=='def' ||this.scope.ntype=='generator'){return '$B.$local_search("'+val+'")'}else{return '$B.$search("'+val+'")'}}
if(val=='__BRYTHON__' ||val=='$B'){return val}
var innermost=$get_scope(this),scope=innermost,found=[]
var gs=innermost
while(gs.parent_block && gs.parent_block.id!=='__builtins__'){gs=gs.parent_block}
var global_ns='$locals_'+gs.id.replace(/\./g,'_')
while(1){if($B.bound[scope.id]===undefined){console.log('name '+val+' undef '+scope.id)}
if($B._globals[scope.id]!==undefined &&
$B._globals[scope.id][val]!==undefined){
if($B.bound[gs.id][val]!==undefined ||this.bound){this.result=global_ns+'["'+val+'"]'
return this.result}else{this.result='$B.$global_search("'+val+'")'
return this.result}}
if(scope===innermost){
var bound_before=this_node.bound_before
if(bound_before && !this.bound){if(bound_before.indexOf(val)>-1){found.push(scope)}
else if(scope.C &&
scope.C.tree[0].type=='def' &&
scope.C.tree[0].env.indexOf(val)>-1){found.push(scope)}}else{if($B.bound[scope.id][val]){
if(!this.bound && this_node.locals[val]===undefined){
if(!scope.is_comp &&
(!scope.parent_block ||
!scope.parent_block.is_comp)){
found.push(scope)}}else{found.push(scope)}}}}else{
if($B.bound[scope.id]===undefined){console.log('no bound',scope.id)}
if($B.bound[scope.id][val]){found.push(scope)}}
if(scope.parent_block){scope=scope.parent_block}
else{break}}
this.found=found
if(this.nonlocal && found[0]===innermost){found.shift()}
if(found.length>0){
if(!this.bound && found[0].C && found[0]===innermost
&& val.charAt(0)!='$'){var locs=$get_node(this).locals ||{},nonlocs=innermost.nonlocals
if(locs[val]===undefined &&
((innermost.type!='def' ||innermost.type!='generator')&&
innermost.C.tree[0].args.indexOf(val)==-1)&&
(nonlocs===undefined ||nonlocs[val]===undefined)){this.result='$B.$local_search("'+val+'")'
return this.result}}
if(found.length>1 && found[0].C){if(found[0].C.tree[0].type=='class' && !this.bound){var ns0='$locals_'+found[0].id.replace(/\./g,'_'),ns1='$locals_'+found[1].id.replace(/\./g,'_'),res
if(bound_before){if(bound_before.indexOf(val)>-1){this.found=$B.bound[found[0].id][val]
res=ns0}else{this.found=$B.bound[found[1].id][val]
res=ns1}
this.result=res+'["'+val+'"]'
return this.result}else{this.found=false
var res=ns0 + '["'+val+'"]!==undefined ? '
res +=ns0 + '["'+val+'"] : '
this.result=res + ns1 + '["'+val+'"]'
return this.result}}}
var scope=found[0]
this.found=$B.bound[scope.id][val]
var scope_ns='$locals_'+scope.id.replace(/\./g,'_')
if(scope.C===undefined){
if(scope.id=='__builtins__'){if(gs.blurred){
val='('+global_ns+'["'+val+'"] || '+val+')'}else{
if(val!=='__builtins__'){val='$B.builtins.'+val}
this.is_builtin=true}}else if(scope.id==scope.module){
if(this.bound ||this.augm_assign){
val=scope_ns+'["'+val+'"]'}else{if(scope===innermost && this.env[val]===undefined){var locs=this_node.locals ||{}
if(locs[val]===undefined){
if(found.length>1 && found[1].id=='__builtins__'){this.is_builtin=true
this.result='$B.builtins.'+val+$to_js(this.tree,'')
return this.result}}
this.result='$B.$search("'+val+'")'
return this.result}else{if(scope.level<=2){
val=scope_ns+'["'+val+'"]'}else{
val='$B.$check_def("'+val+'",'+scope_ns+'["'+val+'"])'}}}}else{val=scope_ns+'["'+val+'"]'}}else if(scope===innermost){if($B._globals[scope.id]&& $B._globals[scope.id][val]){val=global_ns+'["'+val+'"]'}else if(!this.bound && !this.augm_assign){
var bind_level
if(this_node.locals && this_node.locals[val]){bind_level=this_node.locals[val].level}
if(bind_level!==undefined && bind_level<=this.level){val='$locals["'+val+'"]'}else{val='$B.$check_def_local("'+val+'",$locals["'+val+'"])'}}else{val='$locals["'+val+'"]'}}else if(!this.bound && !this.augm_assign){
if(scope.ntype=='generator'){
var up=0,
sc=innermost
while(sc!==scope){up++;sc=sc.parent_block}
var scope_name="$B.frames_stack[$B.frames_stack.length-1-"+up+"][1]"
val='$B.$check_def_free("'+val+'",'+scope_name+'["'+val+'"])'}else{val='$B.$check_def_free("'+val+'",'+scope_ns+'["'+val+'"])'}}else{val=scope_ns+'["'+val+'"]'}
this.result=val+$to_js(this.tree,'')
return this.result}else{
this.unknown_binding=true
this.result='$B.$global_search("'+val+'")'
return this.result}}}
function $ImaginaryCtx(C,value){
this.type='imaginary'
this.value=value
this.toString=function(){return 'imaginary '+this.value}
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
this.to_js=function(){this.js_processed=true
return 'complex(0,'+this.value+')'}}
function $ImportCtx(C){
this.type='import'
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
this.expect='id'
this.toString=function(){return 'import '+this.tree}
this.bind_names=function(){
var scope=$get_scope(this)
for(var i=0;i<this.tree.length;i++){if(this.tree[i].name==this.tree[i].alias){var name=this.tree[i].name,parts=name.split('.'),bound=name
if(parts.length>1){bound=parts[0]}}else{bound=this.tree[i].alias}
$B.bound[scope.id][bound]={level: scope.level}}}
this.to_js=function(){this.js_processed=true
var scope=$get_scope(this),res=[],pos=0
for(var i=0;i<this.tree.length;i++){var mod_name=this.tree[i].name,aliases=(this.tree[i].name==this.tree[i].alias)?
'{}' :('{"' + mod_name + '" : "' +
this.tree[i].alias + '"}'),localns='$locals_'+scope.id.replace(/\./g,'_');
res[pos++]='$B.$import("'+mod_name+'", [],'+aliases+',' +
localns + ', true);'}
return res.join('')+ 'None;'}}
function $ImportedModuleCtx(C,name){this.type='imported module'
this.toString=function(){return ' (imported module) '+this.name}
this.parent=C
this.name=name
this.alias=name
C.tree[C.tree.length]=this
this.to_js=function(){this.js_processed=true
return '"'+this.name+'"'}}
function $IntCtx(C,value){
this.type='int'
this.value=value
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
this.toString=function(){return 'int '+this.value}
this.to_js=function(){this.js_processed=true
var v=parseInt(value[1],value[0])
if(v>$B.min_int && v<$B.max_int){return v}
else{return '$B.LongInt("'+value[1]+'", '+value[0]+')'}}}
function $JSCode(js){this.js=js
this.toString=function(){return this.js}
this.to_js=function(){this.js_processed=true
return this.js}}
function $KwArgCtx(C){
this.type='kwarg'
this.parent=C.parent
this.tree=[C.tree[0]]
C.parent.tree.pop()
C.parent.tree.push(this)
C.parent.parent.has_kw=true
var value=this.tree[0].value
var ctx=C.parent.parent
if(ctx.kwargs===undefined){ctx.kwargs=[value]}
else if(ctx.kwargs.indexOf(value)===-1){ctx.kwargs.push(value)}
else{$_SyntaxError(C,['keyword argument repeated'])}
this.toString=function(){return 'kwarg '+this.tree[0]+'='+this.tree[1]}
this.to_js=function(){this.js_processed=true
var key=this.tree[0].value
if(key.substr(0,2)=='$$'){key=key.substr(2)}
var res='{$nat:"kw",name:"'+key+'",'
return res + 'value:'+$to_js(this.tree.slice(1,this.tree.length))+'}'}}
function $LambdaCtx(C){
this.type='lambda'
this.parent=C
C.tree[C.tree.length]=this
this.tree=[]
this.args_start=$pos+6
this.vars=[]
this.locals=[]
this.toString=function(){return '(lambda) '+this.args_start+' '+this.body_start}
this.to_js=function(){this.js_processed=true
var node=$get_node(this),module=$get_module(this),src=$get_src(C),args=src.substring(this.args_start,this.body_start),body=src.substring(this.body_start+1,this.body_end)
body=body.replace(/\\\n/g,' ')
body=body.replace(/\n/g,' ')
var scope=$get_scope(this)
var rand=$B.UUID(),func_name='lambda_'+$B.lambda_magic+'_'+rand,py='def '+func_name+'('+args+'):\n'
py +=' return '+body
var lambda_name='lambda'+rand,module_name=module.id.replace(/\./g,'_'),scope_id=scope.id.replace(/\./g,'_')
var js=$B.py2js(py,module_name,lambda_name,scope_id,node.line_num).to_js()
js='(function(){\n'+js+'\nreturn $locals.'+func_name+'\n})()'
$B.clear_ns(lambda_name)
$B.$py_src[lambda_name]=null
delete $B.$py_src[lambda_name]
return js}}
function $ListOrTupleCtx(C,real){
this.type='list_or_tuple'
this.start=$pos
this.real=real
this.expect='id'
this.closed=false
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
this.toString=function(){switch(this.real){case 'list':
return '(list) ['+this.tree+']'
case 'list_comp':
case 'gen_expr':
return '('+this.real+') ['+this.intervals+'-'+this.tree+']'
default:
return '(tuple) ('+this.tree+')'}}
this.is_comp=function(){switch(this.real){case 'list_comp':
case 'gen_expr':
case 'dict_or_set_comp':
return true}
return false}
this.get_src=function(){
var scope=$get_scope(this)
var ident=scope.id
while($B.$py_src[ident]===undefined && $B.modules[ident].parent_block){ident=$B.modules[ident].parent_block.id}
var src=$B.$py_src[ident]
if(scope.comments===undefined){return src}
for(var i=0;i<scope.comments.length;i++){var start=scope.comments[i][0],len=scope.comments[i][1]
src=src.substr(0,start)+ ' '.repeat(len + 1)+
src.substr(start + len + 1)}
return src}
this.bind_ids=function(scope_id,level){
for(var i=0;i<this.tree.length;i++){var item=this.tree[i]
if(item.type=='id'){$bind(item.value,scope_id,level)
item.bound=true}else if(item.type=='expr' && item.tree[0].type=="id"){$bind(item.tree[0].value,scope_id,level)
item.tree[0].bound=true}else if(item.type=='expr' && item.tree[0].type=="packed"){if(item.tree[0].tree[0].type=='id'){$bind(item.tree[0].tree[0],scope_id,level)
item.tree[0].tree[0].bound=true}}else if(item.type=='list_or_tuple' ||
(item.type=="expr" && item.tree[0].type=='list_or_tuple')){if(item.type=="expr"){item=item.tree[0]}
item.bind_ids(scope_id,level)}}}
this.to_js=function(){this.js_processed=true
var scope=$get_scope(this),sc=scope,scope_id=scope.id.replace(/\//g, '_'),
pos=0
var module_name = $get_module(this).module
switch(this.real) {
case 'list':
return '$B.$list(['+$to_js(this.tree)+'])'
case 'list_comp':
case 'gen_expr':
case 'dict_or_set_comp':
var src = this.get_src()
var res1 = [], items = []
if(this.comments !== undefined){
console.log('comments in comp', this.comments)
}
var qesc = new RegExp('"',"g") // to escape double quotes in arguments
for(var i=1;i<this.intervals.length;i++){var txt=src.substring(this.intervals[i-1],this.intervals[i])
items.push(txt)
var lines=txt.split('\n')
var res2=[],pos=0
for(var j=0;j<lines.length;j++){var txt=lines[j]
if(txt.replace(/ /g,'').length==0){continue}
txt=txt.replace(/\n/g,' ')
txt=txt.replace(/\\/g,'\\\\')
txt=txt.replace(qesc,'\\"')
res2[pos++]='"'+txt+'"'}
res1.push('['+res2.join(',')+']')}
var line_num=$get_node(this).line_num
switch(this.real){case 'list_comp':
var local_name=scope.id.replace(/\./g,'_')
var lc=$B.$list_comp(items),
py=lc[0],ix=lc[1],listcomp_name='lc'+ix,local_name=scope.id.replace(/\./g,'_')
var save_pos=$pos
var root=$B.py2js({src:py,is_comp:true},module_name,listcomp_name,local_name,line_num)
$pos=save_pos
var js=root.to_js()
root=null
$B.clear_ns(listcomp_name)
delete $B.$py_src[listcomp_name]
js +='return $locals_lc'+ix+'["x'+ix+'"]'
js='(function(){'+js+'})()'
return js
case 'dict_or_set_comp':
if(this.expression.length===1){return $B.$gen_expr(module_name,scope_id,items,line_num)}
return $B.$dict_comp(module_name,scope_id,items,line_num)}
return $B.$gen_expr(module_name,scope_id,items,line_num)
case 'tuple':
if(this.tree.length===1 && this.has_comma===undefined){return this.tree[0].to_js()}
return 'tuple(['+$to_js(this.tree)+'])'}}}
function $NodeCtx(node){
this.node=node
node.C=this
this.tree=[]
this.type='node'
var scope=null
var tree_node=node
while(tree_node.parent && tree_node.parent.type!=='module'){var ntype=tree_node.parent.C.tree[0].type
var _break_flag=false
switch(ntype){case 'def':
case 'class':
case 'generator':
scope=tree_node.parent
_break_flag=true}
if(_break_flag)break
tree_node=tree_node.parent}
if(scope==null){scope=tree_node.parent ||tree_node }
this.node.locals=clone($B.bound[scope.id])
this.toString=function(){return 'node '+this.tree}
this.to_js=function(){if(this.js!==undefined){return this.js}
this.js_processed=true
if(this.tree.length>1){var new_node=new $Node()
var ctx=new $NodeCtx(new_node)
ctx.tree=[this.tree[1]]
new_node.indent=node.indent+4
this.tree.pop()
node.add(new_node)}
if(node.children.length==0){this.js=$to_js(this.tree)+';'}else{this.js=$to_js(this.tree)}
return this.js}}
function $NodeJS(js){var node=new $Node()
new $NodeJSCtx(node,js)
return node}
function $NodeJSCtx(node,js){
this.node=node
node.C=this
this.type='node_js'
this.tree=[js]
this.toString=function(){return 'js '+js}
this.to_js=function(){this.js_processed=true
return js}}
function $NonlocalCtx(C){
this.type='global'
this.parent=C
this.tree=[]
this.names={}
C.tree[C.tree.length]=this
this.expect='id'
this.scope=$get_scope(this)
this.scope.nonlocals=this.scope.nonlocals ||{}
if(this.scope.C===undefined){$_SyntaxError(C,["nonlocal declaration not allowed at module level"])}
this.toString=function(){return 'global '+this.tree}
this.add=function(name){if($B.bound[this.scope.id][name]=='arg'){$_SyntaxError(C,["name '"+name+"' is parameter and nonlocal"])}
this.names[name]=[false,$pos]
this.scope.nonlocals[name]=true}
this.transform=function(node,rank){var pscope=this.scope.parent_block
if(pscope.C===undefined){$_SyntaxError(C,["no binding for nonlocal '"+
$B.last(Object.keys(this.names))+"' found"])}else{while(pscope!==undefined && pscope.C!==undefined){for(var name in this.names){if($B.bound[pscope.id][name]!==undefined){this.names[name]=[true]}}
pscope=pscope.parent_block}
for(var name in this.names){if(!this.names[name][0]){console.log('nonlocal error, C '+C)
$pos=this.names[name][1]
$_SyntaxError(C,["no binding for nonlocal '"+name+"' found"])}}}}
this.to_js=function(){this.js_processed=true
return ''}}
function $NotCtx(C){
this.type='not'
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
this.toString=function(){return 'not ('+this.tree+')'}
this.to_js=function(){this.js_processed=true
return '!$B.$bool('+$to_js(this.tree)+')'}}
function $OpCtx(C,op){
this.type='op'
this.op=op
this.parent=C.parent
this.tree=[C]
this.scope=$get_scope(this)
if(C.type=="expr"){if(['int','float','str'].indexOf(C.tree[0].type)>-1){this.left_type=C.tree[0].type}else if(C.tree[0].type=="id"){var binding=$B.bound[this.scope.id][C.tree[0].value]
if(binding){this.left_type=binding.type}}}
C.parent.tree.pop()
C.parent.tree.push(this)
this.toString=function(){return '(op '+this.op+') ['+this.tree+']'}
this.to_js=function(){this.js_processed=true
var comps={'==':'eq','!=':'ne','>=':'ge','<=':'le','<':'lt','>':'gt'}
if(comps[this.op]!==undefined){var method=comps[this.op]
if(this.tree[0].type=='expr' && this.tree[1].type=='expr'){var t0=this.tree[0].tree[0],t1=this.tree[1].tree[0],js0=t0.to_js(),js1=t1.to_js()
switch(t1.type){case 'int':
switch(t0.type){case 'int':
if(t0.value>$B.min_int && t0.value<$B.max_int &&
t1.value>$B.min_int && t1.value<$B.max_int){return js0+this.op+js1}else{return 'getattr('+this.tree[0].to_js()+',"__'+
method+'__")('+this.tree[1].to_js()+')'}
case 'str':
return '$B.$TypeError("unorderable types: int() < str()")'
case 'id':
var res='typeof ' + js0 + '=="number" ? '+ js0 +
this.op+js1+' : $B.rich_comp("__'+method+'__",'+
this.tree[0].to_js()+','+
this.tree[1].to_js()+')'
return res}
break;
case 'str':
switch(t0.type){case 'str':
return js0+this.op+js1
case 'int':
return '$B.$TypeError("unorderable types: str() < int()")'
case 'id':
var res='typeof ' + js0 + '=="string" ? ' + js0 +
this.op+js1+' : $B.rich_comp("__'+method+'__",'+
this.tree[0].to_js()+','+
this.tree[1].to_js()+')'
return res}
break;
case 'id':
if(t0.type=='id'){var res='typeof '+js0+'!="object" && typeof '+js0+
'!="function" && typeof '+js0+'==typeof '+js1 +
' ? '+js0+this.op+js1+' : $B.rich_comp("__'+
method+'__",' +
this.tree[0].to_js()+','+this.tree[1].to_js()+')'
return res}
break;}}}
switch(this.op){case 'and':
var op0=this.tree[0].to_js(),op1=this.tree[1].to_js()
if(this.wrap!==undefined){
return '(function(){var '+this.wrap.name+'='+this.wrap.js+
';return $B.$test_expr($B.$test_item('+
op0+') && $B.$test_item('+op1+'))})()'}else{return '$B.$test_expr($B.$test_item('+op0+')&&'+
'$B.$test_item('+op1+'))'}
case 'or':
var res='$B.$test_expr($B.$test_item('+this.tree[0].to_js()+')||'
return res + '$B.$test_item('+this.tree[1].to_js()+'))'
case 'in':
return '$B.$is_member('+$to_js(this.tree)+')'
case 'not_in':
return '!$B.$is_member('+$to_js(this.tree)+')'
case 'unary_neg':
case 'unary_pos':
case 'unary_inv':
var op,method
if(this.op=='unary_neg'){op='-';method='__neg__'}
else if(this.op=='unary_pos'){op='+';method='__pos__'}
else{op='~';method='__invert__'}
if(this.tree[1].type=="expr"){var x=this.tree[1].tree[0]
switch(x.type){case 'int':
var v=parseInt(x.value[1],x.value[0])
if(v>$B.min_int && v<$B.max_int){return op+v}
return 'getattr('+x.to_js()+', "'+method+'")()'
case 'float':
return 'float('+op+x.value+')'
case 'imaginary':
return 'complex(0,'+op+x.value+')'}}
return 'getattr('+this.tree[1].to_js()+',"'+method+'")()'
case 'is':
return '$B.$is('+this.tree[0].to_js()+ ', ' +
this.tree[1].to_js()+ ')'
case 'is_not':
return this.tree[0].to_js()+ '!==' + this.tree[1].to_js()
case '*':
case '+':
case '-':
var op=this.op,vars=[],has_float_lit=false,scope=$get_scope(this)
function is_simple(elt){if(elt.type=='expr' && elt.tree[0].type=='int'){return true}
else if(elt.type=='expr' && elt.tree[0].type=='float'){has_float_lit=true
return true}else if(elt.type=='expr' && elt.tree[0].type=='list_or_tuple'
&& elt.tree[0].real=='tuple'
&& elt.tree[0].tree.length==1
&& elt.tree[0].tree[0].type=='expr'){return is_simple(elt.tree[0].tree[0].tree[0])}else if(elt.type=='expr' && elt.tree[0].type=='id'){var _var=elt.tree[0].to_js()
if(vars.indexOf(_var)==-1){vars.push(_var)}
return true}else if(elt.type=='op' &&['*','+','-'].indexOf(elt.op)>-1){for(var i=0;i<elt.tree.length;i++){if(!is_simple(elt.tree[i])){return false}}
return true}
return false}
function get_type(ns,v){var t
if(['int','float','str'].indexOf(v.type)>-1){t=v.type}else if(v.type=='id' && ns[v.value]){t=ns[v.value].type}
return t}
var e0=this.tree[0],e1=this.tree[1]
if(is_simple(this)){var v0=this.tree[0].tree[0]
var v1=this.tree[1].tree[0]
if(vars.length==0 && !has_float_lit){
return this.simple_js()}else if(vars.length==0){
return 'new Number('+this.simple_js()+')'}else{
var ns=$B.bound[scope.id],t0=get_type(ns,v0),t1=get_type(ns,v1)
if((t0=='float' && t1=='float')||
(this.op=='+' && t0=='str' && t1=='str')){this.result_type=t0
return v0.to_js()+this.op+v1.to_js()}else if(['int','float'].indexOf(t0)>-1 &&
['int','float'].indexOf(t1)>-1){if(t0=='int' && t1=='int'){this.result_type='int'}
else{this.result_type='float'}
switch(this.op){case '+':
return '$B.add('+v0.to_js()+','+v1.to_js()+')'
case '-':
return '$B.sub('+v0.to_js()+','+v1.to_js()+')'
case '*':
return '$B.mul('+v0.to_js()+','+v1.to_js()+')'}}
var tests=[],tests1=[],pos=0
for(var i=0;i<vars.length;i++){
tests[pos]='typeof '+vars[i]+'.valueOf() == "number"'
tests1[pos++]='typeof '+vars[i]+' == "number"'}
var res=[tests.join(' && ')+' ? '],pos=1
res[pos++]='('+tests1.join(' && ')+' ? '
res[pos++]=this.simple_js()
res[pos++]=' : new Number('+this.simple_js()+')'
res[pos++]=')'
if(this.op=='+'){res[pos++]=' : (typeof '+this.tree[0].to_js()+'=="string"'
res[pos++]=' && typeof '+this.tree[1].to_js()
res[pos++]='=="string") ? '+this.tree[0].to_js()
res[pos++]='+'+this.tree[1].to_js()}
res[pos++]=': getattr('+this.tree[0].to_js()+',"__'
res[pos++]=$operators[this.op]+'__")'+'('+this.tree[1].to_js()+')'
return '('+res.join('')+')'}}
if(comps[this.op]!==undefined){return '$B.rich_comp("__'+$operators[this.op]+'__",'+e0.to_js()+
','+e1.to_js()+')'}else{return 'getattr('+e0.to_js()+', "__'+$operators[this.op]+
'__")('+e1.to_js()+')'}
default:
if(comps[this.op]!==undefined){return '$B.rich_comp("__'+$operators[this.op]+'__",'+
this.tree[0].to_js()+','+this.tree[1].to_js()+')'}else{return 'getattr('+this.tree[0].to_js()+', "__'+
$operators[this.op]+'__")('+this.tree[1].to_js()+')'}}}
this.simple_js=function(){function sjs(elt){if(elt.type=='op'){return elt.simple_js()}
else if(elt.type=='expr' && elt.tree[0].type=='list_or_tuple'
&& elt.tree[0].real=='tuple'
&& elt.tree[0].tree.length==1
&& elt.tree[0].tree[0].type=='expr'){return '('+elt.tree[0].tree[0].tree[0].simple_js()+')'}else{return elt.tree[0].to_js()}}
if(op=='+'){return '$B.add('+sjs(this.tree[0])+','+sjs(this.tree[1])+')'}
else if(op=='-'){return '$B.sub('+sjs(this.tree[0])+','+sjs(this.tree[1])+')'}
else if(op=='*'){return '$B.mul('+sjs(this.tree[0])+','+sjs(this.tree[1])+')'}
else if(op=='/'){return '$B.div('+sjs(this.tree[0])+','+sjs(this.tree[1])+')'}
else{return sjs(this.tree[0])+op+sjs(this.tree[1])}}}
function $PackedCtx(C){
this.type='packed'
if(C.parent.type=='list_or_tuple'){for(var i=0;i<C.parent.tree.length;i++){var child=C.parent.tree[i]
if(child.type=='expr' && child.tree.length>0
&& child.tree[0].type=='packed'){$_SyntaxError(C,["two starred expressions in assignment"])}}}
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
this.toString=function(){return '(packed) '+this.tree}
this.to_js=function(){this.js_processed=true
return $to_js(this.tree)}}
function $PassCtx(C){
this.type='pass'
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
this.toString=function(){return '(pass)'}
this.to_js=function(){this.js_processed=true
return 'void(0)'}}
function $RaiseCtx(C){
this.type='raise'
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
this.toString=function(){return ' (raise) '+this.tree}
this.to_js=function(){this.js_processed=true
var res=''
if(this.tree.length===0){return '$B.$raise()'}
var exc=this.tree[0],exc_js=exc.to_js()
return '$B.$raise('+exc_js+')'}}
function $RawJSCtx(C,js){this.type="raw_js"
C.tree[C.tree.length]=this
this.parent=C
this.toString=function(){return '(js) '+js}
this.to_js=function(){this.js_processed=true
return js}}
function $ReturnCtx(C){
this.type='return'
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
var node=$get_node(this)
while(node.parent){if(node.parent.C){var elt=node.parent.C.tree[0]
if(elt.type=='for'){elt.has_return=true
break}else if(elt.type=='try'){elt.has_return=true}else if(elt.type=='single_kw' && elt.token=='finally'){elt.has_return=true}}
node=node.parent}
this.toString=function(){return 'return '+this.tree}
this.to_js=function(){this.js_processed=true
if(this.tree.length==1 && this.tree[0].type=='abstract_expr'){
this.tree.pop()
new $IdCtx(new $ExprCtx(this,'rvalue',false),'None')}
var scope=$get_scope(this)
if(scope.ntype=='generator'){return 'return [$B.generator_return(' + $to_js(this.tree)+')]'}
var js='var $res = '+$to_js(this.tree)+';'+'$B.leave_frame'
if(scope.id.substr(0,6)=='$exec_'){js +='_exec'}
return js + '($local_name);return $res'}}
function $SingleKwCtx(C,token){
this.type='single_kw'
this.token=token
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
if(token=="else"){var node=C.node
var pnode=node.parent
for(var rank=0;rank<pnode.children.length;rank++){if(pnode.children[rank]===node)break}
var pctx=pnode.children[rank-1].C
if(pctx.tree.length>0){var elt=pctx.tree[0]
if(elt.type=='for' ||
elt.type=='asyncfor' ||
(elt.type=='condition' && elt.token=='while')){elt.has_break=true
elt.else_node=$get_node(this)
this.loop_num=elt.loop_num}}}
this.toString=function(){return this.token}
this.transform=function(node,rank){
if(this.token=='finally'){var scope=$get_scope(this)
if(scope.ntype!='generator'){var scope_id=scope.id.replace(/\./g,'_'),js='var $exit;if($B.frames_stack.length<$stack_length)'+
'{$exit=true;$B.frames_stack.push($top_frame)}'
node.insert(0,$NodeJS(js))
node.add($NodeJS('if($exit){$B.leave_frame("'+scope_id+'")}'))}}}
this.to_js=function(){this.js_processed=true
if(this.token=='finally')return this.token
if(this.loop_num!==undefined){var scope=$get_scope(this)
var res='if($locals_'+scope.id.replace(/\./g,'_')
return res +'["$no_break'+this.loop_num+'"])'}
return this.token}}
function $StarArgCtx(C){
this.type='star_arg'
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
this.toString=function(){return '(star arg) '+this.tree}
this.to_js=function(){this.js_processed=true
return '{$nat:"ptuple",arg:'+$to_js(this.tree)+'}'}}
function $StringCtx(C,value){
this.type='str'
this.parent=C
this.tree=[value]
this.raw=false
C.tree[C.tree.length]=this
this.toString=function(){return 'string '+(this.tree||'')}
this.to_js=function(){this.js_processed=true
var res='',type=null
function fstring(parsed_fstring){
var elts=[]
for(var i=0;i<parsed_fstring.length;i++){if(parsed_fstring[i].type=='expression'){var expr=parsed_fstring[i].expression,parts=expr.split(':')
expr=parts[0]
expr=expr.replace('\n','\\n')
var expr1="$B.builtins.$$eval('("+expr+")')"
switch(parsed_fstring[i].conversion){case "a":
expr1='$B.builtins.ascii('+expr1+')'
break
case "r":
expr1='$B.builtins.repr('+expr1+')'
break
case "s":
expr1='$B.builtins.str('+expr1+')'
break}
var fmt=parts[1]
if(fmt!==undefined){
var parsed_fmt=$B.parse_fstring(fmt)
if(parsed_fmt.length > 1){fmt=fstring(parsed_fmt)}else{fmt="'" + fmt + "'"}
var res1="$B.builtins.str.$dict.format('{0:' + " +
fmt + " + '}', " + expr1 + ")"
elts.push(res1)}else{elts.push(expr1)}}else{elts.push("'"+parsed_fstring[i]+"'")}}
return elts.join(' + ')}
for(var i=0;i<this.tree.length;i++){if(this.tree[i].type=="call"){
var js='(function(){throw TypeError("'+"'str'"+
' object is not callable")}())'
return js}else{var value=this.tree[i],is_fstring=Array.isArray(value),is_bytes=false
if(!is_fstring){is_bytes=value.charAt(0)=='b'}
if(type==null){type=is_bytes
if(is_bytes){res+='bytes('}}else if(type!=is_bytes){return '$B.$TypeError("can\'t concat bytes to str")'}
if(!is_bytes){if(is_fstring){res +=fstring(value)}else{res +=value.replace(/\n/g,'\\n\\\n')}}else{res +=value.substr(1).replace(/\n/g,'\\n\\\n')}
if(i<this.tree.length-1){res+='+'}}}
if(is_bytes){res +=',"ISO-8859-1")'}
return res}}
function $SubCtx(C){
this.type='sub'
this.func='getitem'
this.value=C.tree[0]
C.tree.pop()
C.tree[C.tree.length]=this
this.parent=C
this.tree=[]
this.toString=function(){return '(sub) (value) '+this.value+' (tree) '+this.tree}
this.to_js=function(){this.js_processed=true
if(this.func=='getitem' && this.value.type=='id'){var type=$get_node(this).locals[this.value.value],val=this.value.to_js()
if(type=='list'||type=='tuple'){if(this.tree.length==1){return '$B.list_key('+val+
', '+this.tree[0].to_js()+')'}else if(this.tree.length==2){return '$B.list_slice('+val+
', '+(this.tree[0].to_js()||"null")+','+
(this.tree[1].to_js()||"null")+')'}else if(this.tree.length==3){return '$B.list_slice_step('+val+
', '+(this.tree[0].to_js()||"null")+','+
(this.tree[1].to_js()||"null")+','+
(this.tree[2].to_js()||"null")+')'}}}
if(this.func=='getitem' && this.tree.length==1){return '$B.$getitem('+this.value.to_js()+',' + this.tree[0].to_js()+')'}
var res='',shortcut=false
if(this.func!=='delitem' && Array.isArray &&
this.tree.length==1 && !this.in_sub){var expr='',x=this
shortcut=true
while(x.value.type=='sub'){expr +='['+x.tree[0].to_js()+']'
x.value.in_sub=true
x=x.value}
var subs=x.value.to_js()+'['+x.tree[0].to_js()+']'
res +='((Array.isArray('+x.value.to_js()+') || '
res +='typeof '+x.value.to_js()+'=="string")'
res +=' && '+subs+'!==undefined ?'
res +=subs+expr+ ' : '}
var val=this.value.to_js()
res +='getattr('+val+',"__'+this.func+'__")('
if(this.tree.length===1){res +=this.tree[0].to_js()+')'}else{var res1=[],pos=0
for(var i=0;i<this.tree.length;i++){if(this.tree[i].type==='abstract_expr'){res1[pos++]='None'}
else{res1[pos++]=this.tree[i].to_js()}}
res +='slice(' + res1.join(',')+ '))'}
return shortcut ? res+')' : res}}
function $TargetListCtx(C){
this.type='target_list'
this.parent=C
this.tree=[]
this.expect='id'
C.tree[C.tree.length]=this
this.toString=function(){return '(target list) '+this.tree}
this.to_js=function(){this.js_processed=true
return $to_js(this.tree)}}
function $TernaryCtx(C){
this.type='ternary'
this.parent=C.parent
C.parent.tree.pop()
C.parent.tree.push(this)
C.parent=this
this.tree=[C]
this.toString=function(){return '(ternary) '+this.tree}
this.to_js=function(){this.js_processed=true
var res='$B.$bool('+this.tree[1].to_js()+') ? '
res +=this.tree[0].to_js()+' : '
return res + this.tree[2].to_js()}}
function $TryCtx(C){
this.type='try'
this.parent=C
C.tree[C.tree.length]=this
this.toString=function(){return '(try) '}
this.transform=function(node,rank){if(node.parent.children.length===rank+1){$_SyntaxError(C,"missing clause after 'try' 1")}else{var next_ctx=node.parent.children[rank+1].C.tree[0]
switch(next_ctx.type){case 'except':
case 'finally':
case 'single_kw':
break
default:
$_SyntaxError(C,"missing clause after 'try' 2")}}
var scope=$get_scope(this)
var $var='var $failed'+$loop_num
var js=$var+'=false;\n'+' '.repeat(node.indent+8)+
'try'
new $NodeJSCtx(node,js)
node.is_try=true
node.has_return=this.has_return
var catch_node=new $Node()
new $NodeJSCtx(catch_node,'catch($err'+$loop_num+')')
catch_node.is_catch=true
node.parent.insert(rank+1,catch_node)
var new_node=new $Node()
new $NodeJSCtx(new_node,$var+'=true;$B.pmframe=$B.last($B.frames_stack);if(0){}')
catch_node.insert(0,new_node)
var pos=rank+2
var has_default=false
var has_else=false
var has_finally=false
while(1){if(pos===node.parent.children.length){break}
var ctx=node.parent.children[pos].C.tree[0]
if(ctx.type==='except'){
if(has_else){$_SyntaxError(C,"'except' or 'finally' after 'else'")}
if(has_finally){$_SyntaxError(C,"'except' after 'finally'")}
ctx.error_name='$err'+$loop_num
if(ctx.tree.length>0 && ctx.tree[0].alias!==null
&& ctx.tree[0].alias!==undefined){
var new_node=new $Node()
var alias=ctx.tree[0].alias
var js='$locals["'+alias+'"]'
js +='=$B.exception($err'+$loop_num+')'
new $NodeJSCtx(new_node,js)
node.parent.children[pos].insert(0,new_node)}
catch_node.insert(catch_node.children.length,node.parent.children[pos])
if(ctx.tree.length===0){if(has_default){$_SyntaxError(C,'more than one except: line')}
has_default=true}
node.parent.children.splice(pos,1)}else if(ctx.type==='single_kw' && ctx.token==='finally'){has_finally=true
var finally_node=node.parent.children[pos]
pos++}else if(ctx.type==='single_kw' && ctx.token==='else'){if(has_else){$_SyntaxError(C,"more than one 'else'")}
if(has_finally){$_SyntaxError(C,"'else' after 'finally'")}
has_else=true
var else_body=node.parent.children[pos]
node.parent.children.splice(pos,1)}else{break}}
if(!has_default){
var new_node=new $Node(),ctx=new $NodeCtx(new_node)
catch_node.insert(catch_node.children.length,new_node)
new $SingleKwCtx(ctx,'else')
new_node.add($NodeJS('throw $err'+$loop_num))}
if(has_else){var else_node=new $Node()
else_node.module=scope.module
new $NodeJSCtx(else_node,'if(!$failed'+$loop_num+')')
for(var i=0;i<else_body.children.length;i++){else_node.add(else_body.children[i])}
if(has_finally){finally_node.insert(0,else_node)}else{node.parent.insert(pos,else_node)}
pos++}
$loop_num++}
this.to_js=function(){this.js_processed=true
return 'try'}}
function $UnaryCtx(C,op){
this.type='unary'
this.op=op
this.parent=C
C.tree[C.tree.length]=this
this.toString=function(){return '(unary) '+this.op}
this.to_js=function(){this.js_processed=true
return this.op}}
function $WithCtx(C){
this.type='with'
this.parent=C
C.tree[C.tree.length]=this
this.tree=[]
this.expect='as'
this.scope=$get_scope(this)
this.toString=function(){return '(with) '+this.tree}
this.set_alias=function(arg){console.log('set with alias',arg)
this.tree[this.tree.length-1].alias=arg
$B.bound[this.scope.id][arg]={level: this.scope.level}
if(this.scope.ntype !=='module'){
this.scope.C.tree[0].locals.push(arg)}}
this.transform=function(node,rank){while(this.tree.length>1){
var suite=node.children,item=this.tree.pop(),new_node=new $Node(),ctx=new $NodeCtx(new_node),with_ctx=new $WithCtx(ctx)
item.parent=with_ctx
with_ctx.tree=[item]
for(var i=0;i<suite.length;i++){new_node.add(suite[i])}
node.children=[new_node]}
node.is_try=true
if(this.transformed)return
if(this.tree.length>1){var nw=new $Node()
var ctx=new $NodeCtx(nw)
nw.parent=node
nw.module=node.module
nw.indent=node.indent+4
var wc=new $WithCtx(ctx)
wc.tree=this.tree.slice(1)
for(var i=0;i<node.children.length;i++){nw.add(node.children[i])}
node.children=[nw]
this.transformed=true
return}
var num=this.num=$loop_num
if(this.tree[0].alias===null){this.tree[0].alias='$temp'}
if(this.tree[0].type=='expr' &&
this.tree[0].tree[0].type=='list_or_tuple'){if(this.tree[1].type!='expr' ||
this.tree[1].tree[0].type!='list_or_tuple'){$_SyntaxError(C)}
if(this.tree[0].tree[0].tree.length!=this.tree[1].tree[0].tree.length){$_SyntaxError(C,['wrong number of alias'])}
var ids=this.tree[0].tree[0].tree
var alias=this.tree[1].tree[0].tree
this.tree.shift()
this.tree.shift()
for(var i=ids.length-1;i>=0;i--){ids[i].alias=alias[i].value
this.tree.splice(0,0,ids[i])}}
var block=node.children
node.children=[]
var try_node=new $Node()
try_node.is_try=true
new $NodeJSCtx(try_node,'try')
node.add(try_node)
if(this.tree[0].alias){var alias=this.tree[0].alias.tree[0].tree[0].value
var js='$locals'+'["'+alias+'"] = $value'+num
var value_node=new $Node()
new $NodeJSCtx(value_node,js)
try_node.add(value_node)}
for(var i=0;i<block.length;i++){try_node.add(block[i])}
var catch_node=new $Node()
catch_node.is_catch=true
new $NodeJSCtx(catch_node,'catch($err'+$loop_num+')')
var fbody=new $Node(),indent=node.indent+4
var js='$exc'+num+' = false;$err'+$loop_num+'=$B.exception($err'+
$loop_num+')\n'+' '.repeat(indent)+
'if(!$B.$bool($ctx_manager_exit'+num+'($err'+$loop_num+
'.__class__.$factory,'+'$err'+$loop_num+
',getattr($err'+$loop_num+',"traceback"))))'
js +='{throw $err'+$loop_num+'}'
new $NodeJSCtx(fbody,js)
catch_node.add(fbody)
node.add(catch_node)
var finally_node=new $Node()
new $NodeJSCtx(finally_node,'finally')
finally_node.C.type='single_kw'
finally_node.C.token='finally'
finally_node.C.in_ctx_manager=true
finally_node.is_except=true
finally_node.in_ctx_manager=true
var fbody=new $Node()
new $NodeJSCtx(fbody,'if($exc'+num+'){$ctx_manager_exit'+num+
'(None,None,None)}')
finally_node.add(fbody)
node.parent.insert(rank+1,finally_node)
$loop_num++
this.transformed=true}
this.to_js=function(){this.js_processed=true
var indent=$get_node(this).indent,h=' '.repeat(indent+4),num=this.num
var res='var $ctx_manager'+num+' = '+this.tree[0].to_js()+
'\n'+h+'var $ctx_manager_exit'+num+
'= getattr($ctx_manager'+num+',"__exit__")\n'+
h+'var $value'+num+' = getattr($ctx_manager'+num+
',"__enter__")()\n'
res +=h+'var $exc'+num+' = true\n'
return res + h+'try'}}
function $YieldCtx(C){
this.type='yield'
this.toString=function(){return '(yield) '+this.tree}
this.parent=C
this.tree=[]
C.tree[C.tree.length]=this
switch(C.type){case 'node':
break;
case 'assign':
case 'tuple':
case 'list_or_tuple':
var ctx=C
while(ctx.parent)ctx=ctx.parent
ctx.node.yield_atoms.push(this)
break;
default:
$_SyntaxError(C,'yield atom must be inside ()')}
var scope=this.scope=$get_scope(this)
if(!scope.is_function){$_SyntaxError(C,["'yield' outside function"])}
var def=scope.C.tree[0]
def.type='generator'
def.yields.push(this)
this.toString=function(){return '(yield) '+(this.from ? '(from) ' : '')+this.tree}
this.transform=function(node,rank){if(this.from===true){
var new_node=new $Node()
new_node.locals=node.locals
node.parent.children.splice(rank,1)
node.parent.insert(rank,new_node)
var for_ctx=new $ForExpr(new $NodeCtx(new_node))
new $IdCtx(new $ExprCtx(for_ctx,'id',false),'$temp'+$loop_num)
$B.bound[this.scope.id]['$temp'+$loop_num]=true
for_ctx.tree[1]=this.tree[0]
this.tree[0].parent=for_ctx
var yield_node=new $Node()
new_node.locals=node.locals
new_node.add(yield_node)
new $IdCtx(new $YieldCtx(new $NodeCtx(yield_node)),'$temp'+$loop_num)
var ph_node=new $Node()
new $NodeJSCtx(ph_node,'// placeholder for generator sent value')
ph_node.set_yield_value=true
new_node.add(ph_node)
for_ctx.transform(new_node,rank)
$loop_num++}else{var new_node=new $Node()
new $NodeJSCtx(new_node,'// placeholder for generator sent value')
new_node.set_yield_value=true
node.parent.insert(rank+1,new_node)}}
this.to_js=function(){this.js_processed=true
if(this.from===undefined)return $to_js(this.tree)||'None'
return $to_js(this.tree)}}
function $add_profile(node,rank){if(node.type==='module'){var i=0
while(i<node.children.length){i +=$add_profile(node.children[i],i)}}else{var elt=node.C.tree[0],offset=1
var flag=true
var pnode=node
while(pnode.parent!==undefined){pnode=pnode.parent}
var mod_id=pnode.id
if(node.line_num===undefined){flag=false}
if(elt.type==='condition' && elt.token==='elif'){flag=false}
else if(elt.type==='except'){flag=false}
else if(elt.type==='single_kw'){flag=false}
if(flag){
var new_node=new $Node()
new $NodeJSCtx(new_node,';$B.$profile.count("'+mod_id+'",'+node.line_num+');')
node.parent.insert(rank,new_node)
offset=2}
var i=0
while(i<node.children.length)i+=$add_profile(node.children[i],i)
return offset}}
function $add_line_num(node,rank){if(node.type==='module'){var i=0
while(i<node.children.length){i +=$add_line_num(node.children[i],i)}}else{var elt=node.C.tree[0],offset=1
var flag=true
var pnode=node
while(pnode.parent!==undefined){pnode=pnode.parent}
var mod_id=pnode.id
if(node.line_num===undefined){flag=false}
if(elt.type==='condition' && elt.token==='elif'){flag=false}
else if(elt.type==='except'){flag=false}
else if(elt.type==='single_kw'){flag=false}
if(flag){
var js=';$locals.$line_info="'+node.line_num+','+mod_id+'";'
var new_node=new $Node()
new $NodeJSCtx(new_node,js)
node.parent.insert(rank,new_node)
offset=2}
var i=0
while(i<node.children.length)i+=$add_line_num(node.children[i],i)
if((elt.type=='condition' && elt.token=="while")
||node.C.type=='for'){node.add($NodeJS('$locals.$line_info="'+node.line_num+','+
mod_id+'";'))}
return offset}}
function $bind(name,scope_id,level){
if($B.bound[scope_id][name]!==undefined){
if(level<$B.bound[scope_id][name].level){$B.bound[scope_id][name].level=level}}else{$B.bound[scope_id][name]={level: level}}}
function $previous(C){var previous=C.node.parent.children[C.node.parent.children.length-2]
if(!previous ||!previous.C){$_SyntaxError(C,'keyword not following correct keyword')}
return previous.C.tree[0]}
function $get_docstring(node){var doc_string=''
if(node.children.length>0){var firstchild=node.children[0]
if(firstchild.C.tree && firstchild.C.tree[0].type=='expr'){var expr=firstchild.C.tree[0].tree[0]
if(expr.type=='str' && !Array.isArray(expr.tree[0])){doc_string=firstchild.C.tree[0].tree[0].to_js()}}}
return doc_string}
function $get_scope(C){
var ctx_node=C.parent
while(ctx_node.type!=='node'){ctx_node=ctx_node.parent}
var tree_node=ctx_node.node,scope=null,level=1
while(tree_node.parent && tree_node.parent.type!=='module'){var ntype=tree_node.parent.C.tree[0].type
switch(ntype){case 'def':
case 'class':
case 'generator':
var scope=tree_node.parent
scope.ntype=ntype
scope.is_function=ntype!='class'
scope.level=level
return scope}
tree_node=tree_node.parent
level++}
var scope=tree_node.parent ||tree_node
scope.ntype="module"
scope.level=level
return scope}
function $get_level(ctx){var nd=$get_node(ctx),level=0
while(nd.parent!==undefined){level++
nd=nd.parent}
return level}
function $get_module(C){
var ctx_node=C.parent
while(ctx_node.type!=='node'){ctx_node=ctx_node.parent}
var tree_node=ctx_node.node
if(tree_node.ntype=="module"){return tree_node}
var scope=null
while(tree_node.parent.type!=='module'){tree_node=tree_node.parent}
var scope=tree_node.parent
scope.ntype="module"
return scope}
function $get_src(C){
var node=$get_node(C)
while(node.parent!==undefined){node=node.parent}
return node.src}
function $get_node(C){var ctx=C
while(ctx.parent){ctx=ctx.parent}
return ctx.node}
function $to_js_map(tree_element){if(tree_element.to_js !==undefined)return tree_element.to_js()
throw Error('no to_js() for '+tree_element)}
function $to_js(tree,sep){if(sep===undefined){sep=','}
return tree.map($to_js_map).join(sep)}
function $arbo(ctx){while(ctx.parent!=undefined){ctx=ctx.parent}
return ctx}
function $mangle(name,C){
if(name.substr(0,2)=="__" && name.substr(name.length-2)!=="__"){var klass=null,scope=$get_scope(C)
while(true){if(scope.ntype=="module"){return name}
else if(scope.ntype=="class"){var class_name=scope.C.tree[0].name
while(class_name.charAt(0)=='_'){class_name=class_name.substr(1)}
return '_' + class_name + name}else{if(scope.parent && scope.parent.C){scope=$get_scope(scope.C.tree[0])}else{return name}}}}else{return name}}
function $transition(C,token){
switch(C.type){case 'abstract_expr':
switch(token){case 'id':
case 'imaginary':
case 'int':
case 'float':
case 'str':
case 'bytes':
case '[':
case '(':
case '{':
case '.':
case 'not':
case 'lambda':
case 'yield':
C.parent.tree.pop()
var commas=C.with_commas
C=C.parent}
switch(token){case 'id':
return new $IdCtx(new $ExprCtx(C,'id',commas),arguments[2])
case 'str':
return new $StringCtx(new $ExprCtx(C,'str',commas),arguments[2])
case 'bytes':
return new $StringCtx(new $ExprCtx(C,'bytes',commas),arguments[2])
case 'int':
return new $IntCtx(new $ExprCtx(C,'int',commas),arguments[2])
case 'float':
return new $FloatCtx(new $ExprCtx(C,'float',commas),arguments[2])
case 'imaginary':
return new $ImaginaryCtx(new $ExprCtx(C,'imaginary',commas),arguments[2])
case '(':
return new $ListOrTupleCtx(new $ExprCtx(C,'tuple',commas),'tuple')
case '[':
return new $ListOrTupleCtx(new $ExprCtx(C,'list',commas),'list')
case '{':
return new $DictOrSetCtx(new $ExprCtx(C,'dict_or_set',commas))
case '.':
return new $EllipsisCtx(new $ExprCtx(C,'ellipsis',commas))
case 'not':
if(C.type==='op'&&C.op==='is'){
C.op='is_not'
return C}
return new $NotCtx(new $ExprCtx(C,'not',commas))
case 'lambda':
return new $LambdaCtx(new $ExprCtx(C,'lambda',commas))
case 'op':
var tg=arguments[2]
switch(tg){case '*':
C.parent.tree.pop()
var commas=C.with_commas
C=C.parent
return new $PackedCtx(new $ExprCtx(C,'expr',commas))
case '-':
case '~':
case '+':
C.parent.tree.pop()
var left=new $UnaryCtx(C.parent,tg)
if(tg=='-'){var op_expr=new $OpCtx(left,'unary_neg')}
else if(tg=='+'){var op_expr=new $OpCtx(left,'unary_pos')}
else{var op_expr=new $OpCtx(left,'unary_inv')}
return new $AbstractExprCtx(op_expr,false)
case 'not':
C.parent.tree.pop()
var commas=C.with_commas
C=C.parent
return new $NotCtx(new $ExprCtx(C,'not',commas))}
$_SyntaxError(C,'token '+token+' after '+C)
case '=':
$_SyntaxError(C,token)
case 'yield':
return new $AbstractExprCtx(new $YieldCtx(C),true)
case ':':
return $transition(C.parent,token,arguments[2])
case ')':
case ',':
switch(C.parent.type){case 'list_or_tuple':
case 'call_arg':
case 'op':
case 'yield':
break
default:
$_SyntaxError(C,token)}}
return $transition(C.parent,token,arguments[2])
case 'annotation':
return $transition(C.parent,token)
case 'assert':
if(token==='eol')return $transition(C.parent,token)
$_SyntaxError(C,token)
case 'assign':
if(token==='eol'){if(C.tree[1].type=='abstract_expr'){$_SyntaxError(C,'token '+token+' after '+C)}
C.guess_type()
return $transition(C.parent,'eol')}
$_SyntaxError(C,'token '+token+' after '+C)
case 'async':
if(token=="def"){return $transition(C.parent,token,arguments[2])}
$_SyntaxError(C,'token '+token+' after '+C)
case 'attribute':
if(token==='id'){var name=arguments[2]
if(noassign[name]===true){$_SyntaxError(C,["cannot assign to "+name])}
name=$mangle(name,C)
C.name=name
return C.parent}
$_SyntaxError(C,token)
case 'augm_assign':
if(token==='eol'){if(C.tree[1].type=='abstract_expr'){$_SyntaxError(C,'token '+token+' after '+C)}
return $transition(C.parent,'eol')}
$_SyntaxError(C,'token '+token+' after '+C)
case 'break':
if(token==='eol')return $transition(C.parent,'eol')
$_SyntaxError(C,token)
case 'call':
switch(token){case ',':
if(C.expect=='id'){$_SyntaxError(C,token)}
return C
case 'id':
case 'imaginary':
case 'int':
case 'float':
case 'str':
case 'bytes':
case '[':
case '(':
case '{':
case '.':
case 'not':
case 'lambda':
if(C.has_dstar)$_SyntaxError(C,token)
C.expect=','
return $transition(new $CallArgCtx(C),token,arguments[2])
case ')':
C.end=$pos
return C.parent
case 'op':
C.expect=','
switch(arguments[2]){case '-':
case '~':
case '+':
C.expect=','
return $transition(new $CallArgCtx(C),token,arguments[2])
case '*':
C.has_star=true;
return new $StarArgCtx(C)
case '**':
C.has_dstar=true
return new $DoubleStarArgCtx(C)}
$_SyntaxError(C,token)}
return $transition(C.parent,token,arguments[2])
case 'call_arg':
switch(token){case 'id':
case 'imaginary':
case 'int':
case 'float':
case 'str':
case 'bytes':
case '[':
case '(':
case '{':
case '.':
case 'not':
case 'lambda':
if(C.expect==='id'){C.expect=','
var expr=new $AbstractExprCtx(C,false)
return $transition(expr,token,arguments[2])}
break
case '=':
if(C.expect===','){return new $ExprCtx(new $KwArgCtx(C),'kw_value',false)}
break
case 'for':
var lst=new $ListOrTupleCtx(C,'gen_expr')
lst.vars=C.vars
lst.locals=C.locals
lst.intervals=[C.start]
C.tree.pop()
lst.expression=C.tree
C.tree=[lst]
lst.tree=[]
var comp=new $ComprehensionCtx(lst)
return new $TargetListCtx(new $CompForCtx(comp))
case 'op':
if(C.expect==='id'){var op=arguments[2]
C.expect=','
switch(op){case '+':
case '-':
case '~':
return $transition(new $AbstractExprCtx(C,false),token,op)
case '*':
return new $StarArgCtx(C)
case '**':
return new $DoubleStarArgCtx(C)}}
$_SyntaxError(C,'token '+token+' after '+C)
case ')':
if(C.parent.kwargs &&
$B.last(C.parent.tree).tree[0]&&
['kwarg','star_arg','double_star_arg'].indexOf($B.last(C.parent.tree).tree[0].type)==-1){$_SyntaxError(C,['non-keyword arg after keyword arg'])}
if(C.tree.length>0){var son=C.tree[C.tree.length-1]
if(son.type==='list_or_tuple'&&son.real==='gen_expr'){son.intervals.push($pos)}}
return $transition(C.parent,token)
case ':':
if(C.expect===',' && C.parent.parent.type==='lambda'){return $transition(C.parent.parent,token)}
break
case ',':
if(C.expect===','){if(C.parent.kwargs &&
['kwarg','star_arg','double_star_arg'].indexOf($B.last(C.parent.tree).tree[0].type)==-1){console.log('err2')
$_SyntaxError(C,['non-keyword arg after keyword arg'])}
return $transition(C.parent,token,arguments[2])}
console.log('C '+C+'token '+token+' expect '+C.expect)}
$_SyntaxError(C,'token '+token+' after '+C)
case 'class':
switch(token){case 'id':
if(C.expect==='id'){C.set_name(arguments[2])
C.expect='(:'
return C}
break
case '(':
return new $CallCtx(C)
case ':':
return $BodyCtx(C)}
$_SyntaxError(C,'token '+token+' after '+C)
case 'comp_if':
return $transition(C.parent,token,arguments[2])
case 'comp_for':
if(token==='in' && C.expect==='in'){C.expect=null
return new $AbstractExprCtx(new $CompIterableCtx(C),true)}
if(C.expect===null){
return $transition(C.parent,token,arguments[2])}
$_SyntaxError(C,'token '+token+' after '+C)
case 'comp_iterable':
return $transition(C.parent,token,arguments[2])
case 'comprehension':
switch(token){case 'if':
return new $AbstractExprCtx(new $CompIfCtx(C),false)
case 'for':
return new $TargetListCtx(new $CompForCtx(C))}
return $transition(C.parent,token,arguments[2])
case 'condition':
if(token===':')return $BodyCtx(C)
$_SyntaxError(C,'token '+token+' after '+C)
case 'continue':
if(token=='eol')return C.parent
$_SyntaxError(C,'token '+token+' after '+C)
case 'ctx_manager_alias':
switch(token){case ',':
case ':':
return $transition(C.parent,token,arguments[2])}
$_SyntaxError(C,'token '+token+' after '+C)
case 'decorator':
if(token==='id' && C.tree.length===0){return $transition(new $AbstractExprCtx(C,false),token,arguments[2])}
if(token==='eol'){return $transition(C.parent,token)}
$_SyntaxError(C,'token '+token+' after '+C)
case 'def':
switch(token){case 'id':
if(C.name){$_SyntaxError(C,'token '+token+' after '+C)}
C.set_name(arguments[2])
return C
case '(':
if(C.name===null){$_SyntaxError(C,'token '+token+' after '+C)}
C.has_args=true;
return new $FuncArgs(C)
case 'annotation':
return new $AbstractExprCtx(new $AnnotationCtx(C),true)
case ':':
if(C.has_args)return $BodyCtx(C)}
$_SyntaxError(C,'token '+token+' after '+C)
case 'del':
if(token==='eol')return $transition(C.parent,token)
$_SyntaxError(C,'token '+token+' after '+C)
case 'dict_or_set':
if(C.closed){switch(token){case '[':
return new $AbstractExprCtx(new $SubCtx(C.parent),false)
case '(':
return new $CallArgCtx(new $CallCtx(C))}
return $transition(C.parent,token,arguments[2])}else{if(C.expect===','){switch(token){case '}':
switch(C.real){case 'dict_or_set':
if(C.tree.length !==1)break
C.real='set'
case 'set':
case 'set_comp':
case 'dict_comp':
C.items=C.tree
C.tree=[]
C.closed=true
return C
case 'dict':
if(C.tree.length%2===0){C.items=C.tree
C.tree=[]
C.closed=true
return C}}
$_SyntaxError(C,'token '+token+' after '+C)
case ',':
if(C.real==='dict_or_set'){C.real='set'}
if(C.real==='dict' && C.tree.length%2){$_SyntaxError(C,'token '+token+' after '+C)}
C.expect='id'
return C
case ':':
if(C.real==='dict_or_set'){C.real='dict'}
if(C.real==='dict'){C.expect=','
return new $AbstractExprCtx(C,false)}else{$_SyntaxError(C,'token '+token+' after '+C)}
case 'for':
if(C.real==='dict_or_set'){C.real='set_comp'}
else{C.real='dict_comp'}
var lst=new $ListOrTupleCtx(C,'dict_or_set_comp')
lst.intervals=[C.start+1]
lst.vars=C.vars
C.tree.pop()
lst.expression=C.tree
C.tree=[lst]
lst.tree=[]
var comp=new $ComprehensionCtx(lst)
return new $TargetListCtx(new $CompForCtx(comp))}
$_SyntaxError(C,'token '+token+' after '+C)}else if(C.expect==='id'){switch(token){case '}':
if(C.tree.length==0){
C.items=[]
C.real='dict'}else{
C.items=C.tree}
C.tree=[]
C.closed=true
return C
case 'id':
case 'imaginary':
case 'int':
case 'float':
case 'str':
case 'bytes':
case '[':
case '(':
case '{':
case '.':
case 'not':
case 'lambda':
C.expect=','
var expr=new $AbstractExprCtx(C,false)
return $transition(expr,token,arguments[2])
case 'op':
switch(arguments[2]){case '+':
return C
case '-':
case '~':
C.expect=','
var left=new $UnaryCtx(C,arguments[2])
if(arguments[2]=='-'){var op_expr=new $OpCtx(left,'unary_neg')}
else if(arguments[2]=='+'){var op_expr=new $OpCtx(left,'unary_pos')}
else{var op_expr=new $OpCtx(left,'unary_inv')}
return new $AbstractExprCtx(op_expr,false)}
$_SyntaxError(C,'token '+token+' after '+C)}
$_SyntaxError(C,'token '+token+' after '+C)}
return $transition(C.parent,token,arguments[2])}
case 'double_star_arg':
switch(token){case 'id':
case 'imaginary':
case 'int':
case 'float':
case 'str':
case 'bytes':
case '[':
case '(':
case '{':
case '.':
case 'not':
case 'lambda':
return $transition(new $AbstractExprCtx(C,false),token,arguments[2])
case ',':
case ')':
return $transition(C.parent,token)
case ':':
if(C.parent.parent.type==='lambda'){return $transition(C.parent.parent,token)}}
$_SyntaxError(C,'token '+token+' after '+C)
case 'ellipsis':
if(token=='.'){C.nbdots++;return C}
else{if(C.nbdots!=3){$pos--;$_SyntaxError(C,'token '+token+' after '+C)}else{return $transition(C.parent,token,arguments[2])}}
case 'except':
switch(token){case 'id':
case 'imaginary':
case 'int':
case 'float':
case 'str':
case 'bytes':
case '[':
case '(':
case '{':
case 'not':
case 'lamdba':
if(C.expect==='id'){C.expect='as'
return $transition(new $AbstractExprCtx(C,false),token,arguments[2])}
case 'as':
if(C.expect==='as' && C.has_alias===undefined){C.expect='alias'
C.has_alias=true
return C}
case 'id':
if(C.expect==='alias'){C.expect=':'
C.set_alias(arguments[2])
return C}
break
case ':':
var _ce=C.expect
if(_ce=='id' ||_ce=='as' ||_ce==':'){return $BodyCtx(C)}
break
case '(':
if(C.expect==='id' && C.tree.length===0){C.parenth=true
return C}
break
case ')':
if(C.expect==',' ||C.expect=='as'){C.expect='as'
return C}
case ',':
if(C.parenth!==undefined && C.has_alias===undefined &&
(C.expect=='as' ||C.expect==',')){C.expect='id'
return C}}
$_SyntaxError(C,'token '+token+' after '+C.expect)
case 'expr':
switch(token){case 'id':
case 'imaginary':
case 'int':
case 'float':
case 'str':
case 'bytes':
case 'lamdba':
$_SyntaxError(C,'token '+token+' after '+C)
break
case '[':
case '(':
case '{':
case '.':
case 'not':
if(C.expect==='expr'){C.expect=','
return $transition(new $AbstractExprCtx(C,false),token,arguments[2])}}
switch(token){case 'not':
if(C.expect===',')return new $ExprNot(C)
break
case 'in':
if(C.parent.type=='target_list'){
return $transition(C.parent,token)}
if(C.expect===',')return $transition(C,'op','in')
break
case ',':
if(C.expect===','){if(C.with_commas){
C.parent.tree.pop()
var tuple=new $ListOrTupleCtx(C.parent,'tuple')
tuple.implicit=true
tuple.has_comma=true
tuple.tree=[C]
C.parent=tuple
return tuple}}
return $transition(C.parent,token)
case '.':
return new $AttrCtx(C)
case '[':
return new $AbstractExprCtx(new $SubCtx(C),true)
case '(':
return new $CallCtx(C)
case 'op':
var op_parent=C.parent,op=arguments[2]
if(op_parent.type=='ternary' && op_parent.in_else){var new_op=new $OpCtx(C,op)
return new $AbstractExprCtx(new_op,false)}
var op1=C.parent,repl=null
while(1){if(op1.type==='expr'){op1=op1.parent}
else if(op1.type==='op'
&&$op_weight[op1.op]>=$op_weight[op]
&& !(op1.op=='**' && op=='**')
){repl=op1;op1=op1.parent}else if(op1.type=="not" && $op_weight['not']>$op_weight[op]){repl=op1;op1=op1.parent}else{break}}
if(repl===null){while(1){if(C.parent!==op1){C=C.parent
op_parent=C.parent}else{break}}
C.parent.tree.pop()
var expr=new $ExprCtx(op_parent,'operand',C.with_commas)
expr.expect=','
C.parent=expr
var new_op=new $OpCtx(C,op)
return new $AbstractExprCtx(new_op,false)}else{
if(op==='and' ||op==='or'){while(repl.parent.type==='not'||
(repl.parent.type==='expr'&&repl.parent.parent.type==='not')){
repl=repl.parent
op_parent=repl.parent}}}
if(repl.type==='op'){var _flag=false
switch(repl.op){case '<':
case '<=':
case '==':
case '!=':
case 'is':
case '>=':
case '>':
_flag=true}
if(_flag){switch(op){case '<':
case '<=':
case '==':
case '!=':
case 'is':
case '>=':
case '>':
var c2=repl.tree[1],
c2js=c2.to_js()
var c2_clone=new Object()
for(var attr in c2){c2_clone[attr]=c2[attr]}
var vname="$c"+chained_comp_num
c2.to_js=function(){return vname}
c2_clone.to_js=function(){return vname}
chained_comp_num++
while(repl.parent && repl.parent.type=='op'){if($op_weight[repl.parent.op]<$op_weight[repl.op]){repl=repl.parent}else{break}}
repl.parent.tree.pop()
var and_expr=new $OpCtx(repl,'and')
and_expr.wrap={'name': vname,'js': c2js}
c2_clone.parent=and_expr
and_expr.tree.push('xxx')
var new_op=new $OpCtx(c2_clone,op)
return new $AbstractExprCtx(new_op,false)}}}
repl.parent.tree.pop()
var expr=new $ExprCtx(repl.parent,'operand',false)
expr.tree=[op1]
repl.parent=expr
var new_op=new $OpCtx(repl,op)
return new $AbstractExprCtx(new_op,false)
case 'augm_assign':
if(C.expect===','){return new $AbstractExprCtx(new $AugmentedAssignCtx(C,arguments[2]),true)}
break
case '=':
if(C.expect===','){if(C.parent.type==="call_arg"){
if(C.tree[0].type !='id'){$_SyntaxError(C,["keyword can't be an expression"])}
return new $AbstractExprCtx(new $KwArgCtx(C),true)}else if(C.parent.type=="annotation"){return $transition(C.parent.parent,token,arguments[2])}
while(C.parent!==undefined){C=C.parent
if(C.type=='condition'){$_SyntaxError(C,'token '+token+' after '+C)}}
C=C.tree[0]
return new $AbstractExprCtx(new $AssignCtx(C),true)}
break
case 'if':
var in_comp=false,ctx=C.parent
while(true){if(ctx.type=='comp_iterable'){in_comp=true;break}
else if(ctx.parent!==undefined){ctx=ctx.parent}
else{break}}
if(in_comp){break}
var ctx=C
while(ctx.parent && ctx.parent.type=='op'){ctx=ctx.parent
if(ctx.type=='expr' && ctx.parent && ctx.parent.type=='op'){ctx=ctx.parent}}
return new $AbstractExprCtx(new $TernaryCtx(ctx),false)}
return $transition(C.parent,token)
case 'expr_not':
if(token=='in'){
C.parent.tree.pop()
return new $AbstractExprCtx(new $OpCtx(C.parent,'not_in'),false)}
$_SyntaxError(C,'token '+token+' after '+C)
case 'for':
switch(token){case 'in':
return new $AbstractExprCtx(new $ExprCtx(C,'target list',true),false)
case ':':
if(C.tree.length<2){
$_SyntaxError(C,'token '+token+' after '+C)}
return $BodyCtx(C)}
$_SyntaxError(C,'token '+token+' after '+C)
case 'from':
switch(token){case 'id':
if(C.expect=='id'){C.add_name(arguments[2])
C.expect=','
return C}
if(C.expect==='alias'){C.aliases[C.names[C.names.length-1]]=arguments[2]
C.expect=','
return C}
case '.':
if(C.expect=='module'){if(token=='id'){C.module +=arguments[2]}
else{C.module +='.'}
return C}
case 'import':
C.blocking=token=='import'
if(C.expect=='module'){C.expect='id'
return C}
case 'op':
if(arguments[2]=='*' && C.expect=='id'
&& C.names.length==0){if($get_scope(C).ntype!=='module'){$_SyntaxError(C,["import * only allowed at module level"])}
C.add_name('*')
C.expect='eol'
return C}
case ',':
if(C.expect==','){C.expect='id'
return C}
case 'eol':
switch(C.expect){case ',':
case 'eol':
C.bind_names()
return $transition(C.parent,token)
case 'id':
$_SyntaxError(C,['trailing comma not allowed without surrounding parentheses'])
default:
$_SyntaxError(C,['invalid syntax'])}
case 'as':
if(C.expect==',' ||C.expect=='eol'){C.expect='alias'
return C}
case '(':
if(C.expect=='id'){C.expect='id'
return C}
case ')':
if(C.expect==',' ||C.expect=='id'){C.expect='eol'
return C}}
$_SyntaxError(C,'token '+token+' after '+C)
case 'func_arg_id':
switch(token){case '=':
if(C.expect==='='){C.parent.has_default=true
var def_ctx=C.parent.parent
if(C.parent.has_star_arg){def_ctx.default_list.push(def_ctx.after_star.pop())}else{def_ctx.default_list.push(def_ctx.positional_list.pop())}
return new $AbstractExprCtx(C,false)}
break
case ',':
case ')':
if(C.parent.has_default && C.tree.length==0 &&
C.parent.has_star_arg===undefined){console.log('parent '+C.parent,C.parent)
$pos -=C.name.length
$_SyntaxError(C,['non-default argument follows default argument'])}else{return $transition(C.parent,token)}
case ':':
if(C.parent.has_default){
$_SyntaxError(C,'token '+token+' after '+C)}
return new $AbstractExprCtx(new $AnnotationCtx(C),false)}
$_SyntaxError(C,'token '+token+' after '+C)
case 'func_args':
switch(token){case 'id':
if(C.expect==='id'){C.expect=','
if(C.names.indexOf(arguments[2])>-1){$_SyntaxError(C,['duplicate argument '+arguments[2]+' in function definition'])}}
return new $FuncArgIdCtx(C,arguments[2])
case ',':
if(C.has_kw_arg)$_SyntaxError(C,'duplicate kw arg')
if(C.expect===','){C.expect='id'
return C}
$_SyntaxError(C,'token '+token+' after '+C)
case ')':
return C.parent
case 'op':
var op=arguments[2]
C.expect=','
if(op=='*'){if(C.has_star_arg){$_SyntaxError(C,'duplicate star arg')}
return new $FuncStarArgCtx(C,'*')}
if(op=='**')return new $FuncStarArgCtx(C,'**')
$_SyntaxError(C,'token '+op+' after '+C)}
$_SyntaxError(C,'token '+token+' after '+C)
case 'func_star_arg':
switch(token){case 'id':
if(C.name===undefined){if(C.parent.names.indexOf(arguments[2])>-1){$_SyntaxError(C,['duplicate argument '+arguments[2]+' in function definition'])}}
C.set_name(arguments[2])
C.parent.names.push(arguments[2])
return C
case ',':
case ')':
if(C.name===undefined){
C.set_name('$dummy')
C.parent.names.push('$dummy')}
return $transition(C.parent,token)
case ':':
if(C.name===undefined){$_SyntaxError(C,'annotation on an unnamed parameter')}
return new $AbstractExprCtx(new $AnnotationCtx(C),false)}
$_SyntaxError(C,'token '+token+' after '+C)
case 'global':
switch(token){case 'id':
if(C.expect==='id'){new $IdCtx(C,arguments[2])
C.add(arguments[2])
C.expect=','
return C}
break
case ',':
if(C.expect===','){C.expect='id'
return C}
break
case 'eol':
if(C.expect===','){return $transition(C.parent,token)}
break}
$_SyntaxError(C,'token '+token+' after '+C)
case 'id':
switch(token){case '=':
if(C.parent.type==='expr' &&
C.parent.parent !==undefined &&
C.parent.parent.type==='call_arg'){return new $AbstractExprCtx(new $KwArgCtx(C.parent),false)}
return $transition(C.parent,token,arguments[2])
case 'op':
return $transition(C.parent,token,arguments[2])
case 'id':
case 'str':
case 'int':
case 'float':
case 'imaginary':
if(C.value=="print"){$_SyntaxError(C,["missing parenthesis in call to 'print'"])}
$_SyntaxError(C,'token '+token+' after '+C)}
if(C.value=="async"){
if(token=='def'){C.parent.parent.tree=[]
var ctx=$transition(C.parent.parent,token,arguments[2])
ctx.async=true
return ctx}}
return $transition(C.parent,token,arguments[2])
case 'import':
switch(token){case 'id':
if(C.expect==='id'){new $ImportedModuleCtx(C,arguments[2])
C.expect=','
return C}
if(C.expect==='qual'){C.expect=','
C.tree[C.tree.length-1].name +='.'+arguments[2]
C.tree[C.tree.length-1].alias +='.'+arguments[2]
return C}
if(C.expect==='alias'){C.expect=','
C.tree[C.tree.length-1].alias=arguments[2]
return C}
break
case '.':
if(C.expect===','){C.expect='qual'
return C}
break
case ',':
if(C.expect===','){C.expect='id'
return C}
break
case 'as':
if(C.expect===','){C.expect='alias'
return C}
break
case 'eol':
if(C.expect===','){C.bind_names()
return $transition(C.parent,token)}
break}
$_SyntaxError(C,'token '+token+' after '+C)
case 'imaginary':
case 'int':
case 'float':
switch(token){case 'id':
case 'imaginary':
case 'int':
case 'float':
case 'str':
case 'bytes':
case '[':
case '(':
case '{':
case 'not':
case 'lamdba':
$_SyntaxError(C,'token '+token+' after '+C)}
return $transition(C.parent,token,arguments[2])
case 'kwarg':
if(token===',')return new $CallArgCtx(C.parent.parent)
return $transition(C.parent,token)
case 'lambda':
if(token===':' && C.args===undefined){C.args=C.tree
C.tree=[]
C.body_start=$pos
return new $AbstractExprCtx(C,false)}
if(C.args!==undefined){
C.body_end=$pos
return $transition(C.parent,token)}
if(C.args===undefined){return $transition(new $CallCtx(C),token,arguments[2])}
$_SyntaxError(C,'token '+token+' after '+C)
case 'list_or_tuple':
if(C.closed){if(token==='[')return new $AbstractExprCtx(new $SubCtx(C.parent),false)
if(token==='(')return new $CallCtx(C)
return $transition(C.parent,token,arguments[2])}else{if(C.expect===','){switch(C.real){case 'tuple':
case 'gen_expr':
if(token===')'){C.closed=true
if(C.real==='gen_expr'){C.intervals.push($pos)}
return C.parent}
break
case 'list':
case 'list_comp':
if(token===']'){C.closed=true
if(C.real==='list_comp'){C.intervals.push($pos)}
return C}
break
case 'dict_or_set_comp':
if(token==='}'){C.intervals.push($pos)
return $transition(C.parent,token)}
break}
switch(token){case ',':
if(C.real==='tuple'){C.has_comma=true}
C.expect='id'
return C
case 'for':
if(C.real==='list'){C.real='list_comp'}
else{C.real='gen_expr'}
C.intervals=[C.start+1]
C.expression=C.tree
C.tree=[]
var comp=new $ComprehensionCtx(C)
return new $TargetListCtx(new $CompForCtx(comp))}
return $transition(C.parent,token,arguments[2])}else if(C.expect==='id'){switch(C.real){case 'tuple':
if(token===')'){C.closed=true
return C.parent}
if(token=='eol' && C.implicit===true){C.closed=true
return $transition(C.parent,token)}
break
case 'gen_expr':
if(token===')'){C.closed=true
return $transition(C.parent,token)}
break
case 'list':
if(token===']'){C.closed=true
return C}
break}
switch(token){case '=':
if(C.real=='tuple' && C.implicit===true){C.closed=true
C.parent.tree.pop()
var expr=new $ExprCtx(C.parent,'tuple',false)
expr.tree=[C]
C.parent=expr
return $transition(C.parent,token)}
break
case ')':
break
case ']':
if(C.real=='tuple' && C.implicit===true){
return $transition(C.parent,token,arguments[2])}else{break}
case ',':
$_SyntaxError(C,'unexpected comma inside list')
default:
C.expect=','
var expr=new $AbstractExprCtx(C,false)
return $transition(expr,token,arguments[2])}}else{return $transition(C.parent,token,arguments[2])}}
case 'list_comp':
switch(token){case ']':
return C.parent
case 'in':
return new $ExprCtx(C,'iterable',true)
case 'if':
return new $ExprCtx(C,'condition',true)}
$_SyntaxError(C,'token '+token+' after '+C)
case 'node':
switch(token){case 'id':
case 'imaginary':
case 'int':
case 'float':
case 'str':
case 'bytes':
case '[':
case '(':
case '{':
case 'not':
case 'lamdba':
case '.':
var expr=new $AbstractExprCtx(C,true)
return $transition(expr,token,arguments[2])
case 'op':
switch(arguments[2]){case '*':
case '+':
case '-':
case '~':
var expr=new $AbstractExprCtx(C,true)
return $transition(expr,token,arguments[2])}
break
case 'class':
return new $ClassCtx(C)
case 'continue':
return new $ContinueCtx(C)
case '__debugger__':
return new $DebuggerCtx(C)
case 'break':
return new $BreakCtx(C)
case 'def':
return new $DefCtx(C)
case 'for':
return new $TargetListCtx(new $ForExpr(C))
case 'if':
case 'while':
return new $AbstractExprCtx(new $ConditionCtx(C,token),false)
case 'elif':
var previous=$previous(C)
if(['condition'].indexOf(previous.type)==-1 ||
previous.token=='while'){$_SyntaxError(C,'elif after '+previous.type)}
return new $AbstractExprCtx(new $ConditionCtx(C,token),false)
case 'else':
var previous=$previous(C)
if(['condition','except','for'].indexOf(previous.type)==-1){$_SyntaxError(C,'else after '+previous.type)}
return new $SingleKwCtx(C,token)
case 'finally':
var previous=$previous(C)
if(['try','except'].indexOf(previous.type)==-1 &&
(previous.type!='single_kw' ||previous.token!='else')){$_SyntaxError(C,'finally after '+previous.type)}
return new $SingleKwCtx(C,token)
case 'try':
return new $TryCtx(C)
case 'except':
var previous=$previous(C)
if(['try','except'].indexOf(previous.type)==-1){$_SyntaxError(C,'except after '+previous.type)}
return new $ExceptCtx(C)
case 'assert':
return new $AbstractExprCtx(new $AssertCtx(C),'assert',true)
case 'from':
return new $FromCtx(C)
case 'import':
return new $ImportCtx(C)
case 'global':
return new $GlobalCtx(C)
case 'nonlocal':
return new $NonlocalCtx(C)
case 'lambda':
return new $LambdaCtx(C)
case 'pass':
return new $PassCtx(C)
case 'raise':
return new $AbstractExprCtx(new $RaiseCtx(C),true)
case 'return':
return new $AbstractExprCtx(new $ReturnCtx(C),true)
case 'with':
return new $AbstractExprCtx(new $WithCtx(C),false)
case 'yield':
return new $AbstractExprCtx(new $YieldCtx(C),true)
case 'del':
return new $AbstractExprCtx(new $DelCtx(C),true)
case '@':
return new $DecoratorCtx(C)
case 'eol':
if(C.tree.length===0){
C.node.parent.children.pop()
return C.node.parent.C}
return C}
$_SyntaxError(C,'token '+token+' after '+C)
case 'not':
switch(token){case 'in':
C.parent.parent.tree.pop()
return new $ExprCtx(new $OpCtx(C.parent,'not_in'),'op',false)
case 'id':
case 'imaginary':
case 'int':
case 'float':
case 'str':
case 'bytes':
case '[':
case '(':
case '{':
case '.':
case 'not':
case 'lamdba':
var expr=new $AbstractExprCtx(C,false)
return $transition(expr,token,arguments[2])
case 'op':
var a=arguments[2]
if('+'==a ||'-'==a ||'~'==a){var expr=new $AbstractExprCtx(C,false)
return $transition(expr,token,arguments[2])}}
return $transition(C.parent,token)
case 'op':
if(C.op===undefined){$_SyntaxError(C,['C op undefined '+C])}
if(C.op.substr(0,5)=='unary' && token !='eol'){if(C.parent.type=='assign' ||C.parent.type=='return'){
C.parent.tree.pop()
var t=new $ListOrTupleCtx(C.parent,'tuple')
t.tree.push(C)
C.parent=t
return t}}
switch(token){case 'id':
case 'imaginary':
case 'int':
case 'float':
case 'str':
case 'bytes':
case '[':
case '(':
case '{':
case '.':
case 'not':
case 'lamdba':
return $transition(new $AbstractExprCtx(C,false),token,arguments[2])
case 'op':
switch(arguments[2]){case '+':
case '-':
case '~':
return new $UnaryCtx(C,arguments[2])}
default:
if(C.tree[C.tree.length-1].type=='abstract_expr'){$_SyntaxError(C,'token '+token+' after '+C)}}
var t0=C.tree[0],t1=C.tree[1]
if(t0.tree && t1.tree){t0=t0.tree[0]
t1=t1.tree[0]}
return $transition(C.parent,token)
case 'packed':
if(token==='id'){new $IdCtx(C,arguments[2])
C.parent.expect=','
return C.parent}
$_SyntaxError(C,'token '+token+' after '+C)
case 'pass':
if(token==='eol')return C.parent
$_SyntaxError(C,'token '+token+' after '+C)
case 'raise':
switch(token){case 'id':
if(C.tree.length===0){return new $IdCtx(new $ExprCtx(C,'exc',false),arguments[2])}
break
case 'from':
if(C.tree.length>0){return new $AbstractExprCtx(C,false)}
break
case 'eol':
return $transition(C.parent,token)}
$_SyntaxError(C,'token '+token+' after '+C)
case 'return':
return $transition(C.parent,token)
case 'single_kw':
if(token===':')return $BodyCtx(C)
$_SyntaxError(C,'token '+token+' after '+C)
case 'star_arg':
switch(token){case 'id':
if(C.parent.type=="target_list"){C.tree.push(arguments[2])
C.parent.expect=','
console.log('return parent',C.parent)
return C.parent}
return $transition(new $AbstractExprCtx(C,false),token,arguments[2])
case 'imaginary':
case 'int':
case 'float':
case 'str':
case 'bytes':
case '[':
case '(':
case '{':
case 'not':
case 'lamdba':
return $transition(new $AbstractExprCtx(C,false),token,arguments[2])
case ',':
return $transition(C.parent,token)
case ')':
return $transition(C.parent,token)
case ':':
if(C.parent.parent.type==='lambda'){return $transition(C.parent.parent,token)}}
$_SyntaxError(C,'token '+token+' after '+C)
case 'str':
switch(token){case '[':
return new $AbstractExprCtx(new $SubCtx(C.parent),false)
case '(':
C.parent.tree[0]=C
return new $CallCtx(C.parent)
case 'str':
C.tree.push(arguments[2])
return C}
return $transition(C.parent,token,arguments[2])
case 'sub':
switch(token){case 'id':
case 'imaginary':
case 'int':
case 'float':
case 'str':
case 'bytes':
case '[':
case '(':
case '{':
case '.':
case 'not':
case 'lamdba':
var expr=new $AbstractExprCtx(C,false)
return $transition(expr,token,arguments[2])
case ']':
return C.parent
case ':':
if(C.tree.length==0){new $AbstractExprCtx(C,false)}
return new $AbstractExprCtx(C,false)}
$_SyntaxError(C,'token '+token+' after '+C)
case 'target_list':
switch(token){case 'id':
if(C.expect==='id'){C.expect=','
return new $IdCtx(new $ExprCtx(C,'target',false),arguments[2])}
case 'op':
if(C.expect=='id' && arguments[2]=='*'){
return new $PackedCtx(C)}
case '(':
case '[':
if(C.expect==='id'){C.expect=','
return new $TargetListCtx(C)}
case ')':
case ']':
if(C.expect===',')return C.parent
case ',':
if(C.expect==','){C.expect='id'
return C}}
if(C.expect===','){return $transition(C.parent,token,arguments[2])}else if(token=='in'){
return $transition(C.parent,token,arguments[2])}
$_SyntaxError(C,'token '+token+' after '+C)
case 'ternary':
if(token==='else'){C.in_else=true
return new $AbstractExprCtx(C,false)}
return $transition(C.parent,token,arguments[2])
case 'try':
if(token===':')return $BodyCtx(C)
$_SyntaxError(C,'token '+token+' after '+C)
case 'unary':
switch(token){case 'int':
case 'float':
case 'imaginary':
console.log(token,arguments[2],'after',C)
var expr=C.parent
C.parent.parent.tree.pop()
var value=arguments[2]
if(C.op==='-'){value="-"+value}
else if(C.op==='~'){value=~value}
return $transition(C.parent.parent,token,value)
case 'id':
C.parent.parent.tree.pop()
var expr=new $ExprCtx(C.parent.parent,'call',false)
var expr1=new $ExprCtx(expr,'id',false)
new $IdCtx(expr1,arguments[2])
var repl=new $AttrCtx(expr)
if(C.op==='+'){repl.name='__pos__'}
else if(C.op==='-'){repl.name='__neg__'}
else{repl.name='__invert__'}
return expr1
case 'op':
if('+'==arguments[2]||'-'==arguments[2]){var op=arguments[2]
if(C.op===op){C.op='+'}else{C.op='-'}
return C}}
return $transition(C.parent,token,arguments[2])
case 'with':
switch(token){case 'id':
if(C.expect==='id'){C.expect='as'
return $transition(new $AbstractExprCtx(C,false),token,arguments[2])}
if(C.expect==='alias'){if(C.parenth!==undefined){C.expect=','}
else{C.expect=':'}
C.set_alias(arguments[2])
return C}
break
case 'as':
return new $AbstractExprCtx(new $AliasCtx(C))
case ':':
switch(C.expect){case 'id':
case 'as':
case ':':
return $BodyCtx(C)}
break
case '(':
if(C.expect==='id' && C.tree.length===0){C.parenth=true
return C}else if(C.expect=='alias'){C.expect=':'
return new $TargetListCtx(C,false)}
break
case ')':
if(C.expect==',' ||C.expect=='as'){C.expect=':'
return C}
break
case ',':
if(C.parenth!==undefined && C.has_alias===undefined &&
(C.expect==',' ||C.expect=='as')){C.expect='id'
return C}else if(C.expect=='as'){C.expect='id'
return C}else if(C.expect==':'){C.expect='id'
return C}
break}
$_SyntaxError(C,'token '+token+' after '+C.expect)
case 'yield':
if(token=='from'){
if(C.tree[0].type!='abstract_expr'){
$_SyntaxError(C,"'from' must follow 'yield'")}
C.from=true
C.tree=[]
return new $AbstractExprCtx(C,true)}
return $transition(C.parent,token)}}
$B.forbidden=['alert','arguments','case','catch','constructor','Date','delete','default','document','enum','eval','extends','Error','history','function','length','location','Math','new','null','Number','RegExp','super','this','throw','var','window','toLocaleString','toString','message']
$B.aliased_names={}
for(var i=0;i<$B.forbidden.length;i++){$B.aliased_names[$B.forbidden[i]]=true}
var s_escaped='abfnrtvxuU"0123456789'+"'"+'\\',is_escaped={}
for(var i=0;i<s_escaped.length;i++){is_escaped[s_escaped.charAt(i)]=true}
function $tokenize(src,module,locals_id,parent_block_id,line_info){var br_close={")":"(","]":"[","}":"{"}
var br_stack=""
var br_pos=[]
var kwdict=["class","return","break","for","lambda","try","finally","raise","def","from","nonlocal","while","del","global","with","as","elif","else","if","yield","assert","import","except","raise","in","pass","with","continue","__debugger__"
]
var unsupported=[]
var $indented=['class','def','for','condition','single_kw','try','except','with']
var int_pattern=new RegExp("^\\d+(j|J)?"),float_pattern1=new RegExp("^\\d+\\.\\d*([eE][+-]?\\d+)?(j|J)?"),float_pattern2=new RegExp("^\\d+([eE][+-]?\\d+)(j|J)?"),hex_pattern=new RegExp("^0[xX]([0-9a-fA-F]+)"),octal_pattern=new RegExp("^0[oO]([0-7]+)"),binary_pattern=new RegExp("^0[bB]([01]+)")
var C=null
var root=new $Node('module')
root.module=module
root.id=locals_id
$B.modules[root.id]=root
if(locals_id==parent_block_id){root.parent_block=$B.modules[parent_block_id].parent_block ||$B.modules['__builtins__']}else{root.parent_block=$B.modules[parent_block_id]||$B.modules['__builtins__']}
root.line_info=line_info
root.indent=-1
root.comments=[]
if(locals_id!==module){$B.bound[locals_id]=$B.bound[locals_id]||{}}
var new_node=new $Node(),current=root,name="",_type=null,pos=0,indent=null,string_modifier=false
if(typeof src=="object"){root.is_comp=src.is_comp
src=src.src}
root.src=src
var lnum=1
while(pos<src.length){var car=src.charAt(pos)
if(indent===null){var indent=0
while(pos<src.length){var _s=src.charAt(pos)
if(_s==" "){indent++;pos++}
else if(_s=="\t"){
indent++;pos++
if(indent%8>0)indent+=8-indent%8}else{break}}
var _s=src.charAt(pos)
if(_s=='\n'){pos++;lnum++;indent=null;continue}
else if(_s==='#'){
var offset=src.substr(pos).search(/\n/)
if(offset===-1){break}
pos+=offset+1;lnum++;indent=null;continue}
new_node.indent=indent
new_node.line_num=lnum
new_node.module=module
if(indent>current.indent){
if(C!==null){if($indented.indexOf(C.tree[0].type)==-1){$pos=pos
$_SyntaxError(C,'unexpected indent',pos)}}
current.add(new_node)}else if(indent<=current.indent &&
$indented.indexOf(C.tree[0].type)>-1 &&
C.tree.length<2){$pos=pos
$_SyntaxError(C,'expected an indented block',pos)}else{
while(indent!==current.indent){current=current.parent
if(current===undefined ||indent>current.indent){$pos=pos
$_SyntaxError(C,'unexpected indent',pos)}}
current.parent.add(new_node)}
current=new_node
C=new $NodeCtx(new_node)
continue}
if(car=="#"){var end=src.substr(pos+1).search('\n')
if(end==-1){end=src.length-1}
root.comments.push([pos,end])
pos +=end+1;continue}
if(car=='"' ||car=="'"){var raw=C.type=='str' && C.raw,bytes=false,fstring=false,end=null;
if(string_modifier){switch(string_modifier){case 'r':
raw=true
break
case 'u':
break
case 'b':
bytes=true
break
case 'rb':
case 'br':
bytes=true;raw=true
break
case 'f':
fstring=true
break
case 'fr','rf':
fstring=true
raw=true
break}
string_modifier=false}
if(src.substr(pos,3)==car+car+car){_type="triple_string";end=pos+3}
else{_type="string";end=pos+1}
var escaped=false
var zone=car
var found=false
while(end<src.length){if(escaped){zone+=src.charAt(end)
if(raw && src.charAt(end)=='\\'){zone+='\\'}
escaped=false;end+=1}else if(src.charAt(end)=="\\"){if(raw){if(end<src.length-1 && src.charAt(end+1)==car){zone +='\\\\'+car
end +=2}else{zone +='\\\\'
end++}
escaped=true}else{
if(src.charAt(end+1)=='\n'){
end +=2
lnum++}else{
if(end < src.length-1 &&
is_escaped[src.charAt(end+1)]==undefined){zone +='\\'}
zone+='\\'
escaped=true;end+=1}}}else if(src.charAt(end)=='\n' && _type!='triple_string'){
$pos=end
$_SyntaxError(C,["EOL while scanning string literal"])}else if(src.charAt(end)==car){if(_type=="triple_string" && src.substr(end,3)!=car+car+car){zone +=src.charAt(end)
end++}else{
found=true
$pos=pos
var $string=zone.substr(1),string=''
for(var i=0;i<$string.length;i++){var $car=$string.charAt(i)
if($car==car &&
(raw ||(i==0 ||$string.charAt(i-1)!=='\\'))){string +='\\'}
string +=$car}
if(fstring){try{var elts=$B.parse_fstring(string)}catch(err){$_SyntaxError(C,[err.toString()])}}
if(bytes){C=$transition(C,'str','b'+car+string+car)}else if(fstring){C=$transition(C,'str',elts)}else{C=$transition(C,'str',car+string+car)}
C.raw=raw;
pos=end+1
if(_type=="triple_string"){pos=end+3}
break}}else{
zone +=src.charAt(end)
if(src.charAt(end)=='\n'){lnum++}
end++}}
if(!found){if(_type==="triple_string"){$_SyntaxError(C,"Triple string end not found")}else{$_SyntaxError(C,"String end not found")}}
continue}
if(name=="" && car!='$'){
if($B.regexIdentifier.exec(car)){name=car
var p0=pos
pos++
while(pos<src.length && $B.regexIdentifier.exec(src.substring(p0,pos+1))){name+=src.charAt(pos)
pos++}}
if(name){
if(kwdict.indexOf(name)>-1){$pos=pos-name.length
if(unsupported.indexOf(name)>-1){$_SyntaxError(C,"Unsupported Python keyword '"+name+"'")}
C=$transition(C,name)}else if(typeof $operators[name]=='string'){
if(name=='is'){
var re=/^\s+not\s+/
var res=re.exec(src.substr(pos))
if(res!==null){pos +=res[0].length
$pos=pos-name.length
C=$transition(C,'op','is_not')}else{$pos=pos-name.length
C=$transition(C,'op',name)}}else if(name=='not'){
var re=/^\s+in\s+/
var res=re.exec(src.substr(pos))
if(res!==null){pos +=res[0].length
$pos=pos-name.length
C=$transition(C,'op','not_in')}else{$pos=pos-name.length
C=$transition(C,name)}}else{$pos=pos-name.length
C=$transition(C,'op',name)}}else if((src.charAt(pos)=='"'||src.charAt(pos)=="'")
&&['r','b','u','rb','br','f','fr','rf'].indexOf(name.toLowerCase())!==-1){string_modifier=name.toLowerCase()
name=""
continue}else{
if($B.forbidden.indexOf(name)>-1){name='$$'+name}
$pos=pos-name.length
C=$transition(C,'id',name)}
name=""
continue}}
switch(car){case ' ':
case '\t':
pos++
break
case '.':
if(pos<src.length-1 && /^\d$/.test(src.charAt(pos+1))){
var j=pos+1
while(j<src.length && src.charAt(j).search(/\d|e|E/)>-1){j++}
C=$transition(C,'float','0'+src.substr(pos,j-pos))
pos=j
break}
$pos=pos
C=$transition(C,'.')
pos++
break
case '0':
var res=hex_pattern.exec(src.substr(pos))
if(res){C=$transition(C,'int',[16,res[1]])
pos +=res[0].length
break}
var res=octal_pattern.exec(src.substr(pos))
if(res){C=$transition(C,'int',[8,res[1]])
pos +=res[0].length
break}
var res=binary_pattern.exec(src.substr(pos))
if(res){C=$transition(C,'int',[2,res[1]])
pos +=res[0].length
break}
if(src.charAt(pos+1).search(/\d/)>-1){
if(parseInt(src.substr(pos))===0){res=int_pattern.exec(src.substr(pos))
$pos=pos
C=$transition(C,'int',[10,res[0]])
pos +=res[0].length
break}else{$_SyntaxError(C,('invalid literal starting with 0'))}}
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
var res=float_pattern1.exec(src.substr(pos))
if(res){$pos=pos
if(res[2]!==undefined){C=$transition(C,'imaginary',res[0].substr(0,res[0].length-1))}else{C=$transition(C,'float',res[0])}}else{res=float_pattern2.exec(src.substr(pos))
if(res){$pos=pos
if(res[2]!==undefined){C=$transition(C,'imaginary',res[0].substr(0,res[0].length-1))}else{C=$transition(C,'float',res[0])}}else{res=int_pattern.exec(src.substr(pos))
$pos=pos
if(res[1]!==undefined){C=$transition(C,'imaginary',res[0].substr(0,res[0].length-1))}else{C=$transition(C,'int',[10,res[0]])}}}
pos +=res[0].length
break
case '\n':
lnum++
if(br_stack.length>0){
pos++;}else{
if(current.C.tree.length>0){$pos=pos
C=$transition(C,'eol')
indent=null
new_node=new $Node()}else{new_node.line_num=lnum}
pos++}
break
case '(':
case '[':
case '{':
br_stack +=car
br_pos[br_stack.length-1]=[C,pos]
$pos=pos
C=$transition(C,car)
pos++
break
case ')':
case ']':
case '}':
if(br_stack==""){$_SyntaxError(C,"Unexpected closing bracket")}else if(br_close[car]!=br_stack.charAt(br_stack.length-1)){$_SyntaxError(C,"Unbalanced bracket")}else{
br_stack=br_stack.substr(0,br_stack.length-1)
$pos=pos
C=$transition(C,car)
pos++}
break
case '=':
if(src.charAt(pos+1)!="="){$pos=pos
C=$transition(C,'=')
pos++;}else{
$pos=pos
C=$transition(C,'op','==')
pos+=2}
break
case ',':
case ':':
$pos=pos
C=$transition(C,car)
pos++
break
case ';':
$transition(C,'eol')
if(current.C.tree.length===0){
$pos=pos
$_SyntaxError(C,'invalid syntax')}
var pos1=pos+1
var ends_line=false
while(pos1<src.length){var _s=src.charAt(pos1)
if(_s=='\n' ||_s=='#'){ends_line=true;break}
else if(_s==' '){pos1++}
else{break}}
if(ends_line){pos++;break}
new_node=new $Node()
new_node.indent=$get_node(C).indent
new_node.line_num=lnum
new_node.module=module
$get_node(C).parent.add(new_node)
current=new_node
C=new $NodeCtx(new_node)
pos++
break
case '/':
case '%':
case '&':
case '>':
case '<':
case '-':
case '+':
case '*':
case '/':
case '^':
case '=':
case '|':
case '~':
case '!':
if(car=='-' && src.charAt(pos+1)=='>'){C=$transition(C,'annotation')
pos +=2
continue}
var op_match=""
for(var op_sign in $operators){if(op_sign==src.substr(pos,op_sign.length)
&& op_sign.length>op_match.length){op_match=op_sign}}
$pos=pos
if(op_match.length>0){if(op_match in $augmented_assigns){C=$transition(C,'augm_assign',op_match)}else{C=$transition(C,'op',op_match)}
pos +=op_match.length}else{$_SyntaxError(C,'invalid character: '+car)}
break
case '\\':
if(src.charAt(pos+1)=='\n'){lnum++
pos+=2
break}
case '@':
$pos=pos
C=$transition(C,car)
pos++
break
default:
$pos=pos;$_SyntaxError(C,'unknown token ['+car+']')}}
if(br_stack.length!=0){var br_err=br_pos[0]
$pos=br_err[1]
$_SyntaxError(br_err[0],["Unbalanced bracket "+br_stack.charAt(br_stack.length-1)])}
if(C!==null && $indented.indexOf(C.tree[0].type)>-1){$pos=pos-1
$_SyntaxError(C,'expected an indented block',pos)}
return root}
$B.py2js=function(src,module,locals_id,parent_block_id,line_info){
var t0=new Date().getTime(),is_comp=false
if(typeof src=='object'){is_comp=src.is_comp
src=src.src}
src=src.replace(/\r\n/gm,'\n')
if(src.charAt(src.length-1)!="\n"){src+='\n'}
var locals_is_module=Array.isArray(locals_id)
if(locals_is_module){locals_id=locals_id[0]}
var internal=locals_id.charAt(0)=='$'
var local_ns='$locals_'+locals_id.replace(/\./g,'_')
var global_ns='$locals_'+module.replace(/\./g,'_')
$B.bound[module]=$B.bound[module]||{}
$B.bound[module]['__doc__']=true
$B.bound[module]['__name__']=true
$B.bound[module]['__file__']=true
$B.$py_src[locals_id]=src
var root=$tokenize({src:src,is_comp:is_comp},module,locals_id,parent_block_id,line_info)
root.is_comp=is_comp
root.transform()
var js=['var $B = __BRYTHON__;\n'],pos=1
js[pos++]='eval(__BRYTHON__.InjectBuiltins());\n\n'
js[pos]='var '
if(locals_is_module){js[pos]+=local_ns+'=$locals_'+module+', '}else if(!internal){js[pos]+=local_ns+'=$B.imported["'+locals_id+'"] || {}, '}
js[pos]+='$locals='+local_ns+';'
var offset=0
root.insert(0,$NodeJS(js.join('')))
offset++
var ds_node=new $Node()
new $NodeJSCtx(ds_node,local_ns+'["__doc__"]='+(root.doc_string||'None')+';')
root.insert(offset++,ds_node)
var name_node=new $Node()
new $NodeJSCtx(name_node,local_ns+'["__name__"]='+local_ns+'["__name__"] || "'+locals_id+'";')
root.insert(offset++,name_node)
var file_node=new $Node()
new $NodeJSCtx(file_node,local_ns+'["__file__"]="'+$B.$py_module_path[module]+'";None;\n')
root.insert(offset++,file_node)
if(line_info !==undefined){var line_node=new $Node()
new $NodeJSCtx(line_node,local_ns+'.$line="'+line_info+'";None;\n')
root.insert(offset++,line_node)}
var enter_frame_pos=offset,js='var $top_frame = ["'+locals_id.replace(/\./g,'_')+'", '+
local_ns+', "'+module.replace(/\./g,'_')+'", '+global_ns+
', "a"]; $B.frames_stack.push($top_frame); var $stack_length = '+
'$B.frames_stack.length;'
root.insert(offset++,$NodeJS(js))
var try_node=new $NodeJS('try'),children=root.children.slice(enter_frame_pos+1,root.children.length)
root.insert(enter_frame_pos+1,try_node)
if(children.length==0){children=[$NodeJS('')]}
for(var i=0;i<children.length;i++){try_node.add(children[i])}
try_node.add($NodeJS('$B.leave_frame("'+locals_id+'")'))
root.children.splice(enter_frame_pos+2,root.children.length)
var catch_node=new $NodeJS('catch(err)')
catch_node.add($NodeJS('$B.leave_frame("'+locals_id+'")'))
catch_node.add($NodeJS('throw err'))
root.add(catch_node)
if($B.profile>0){$add_profile(root,null,module)}
if($B.debug>0){$add_line_num(root,null,module)}
var t1=new Date().getTime()
if($B.debug>=2){if(module==locals_id){console.log('module '+module+' translated in '+(t1 - t0)+' ms')}}
$B.compile_time +=t1-t0
return root}
function load_scripts(scripts,run_script,onerror){
if(run_script===undefined){run_script=$B._run_script;}
function callback(ev,script){var ok=false,skip=false;
if(ev !==null){var req=ev.target
if(req.readyState==4){if(req.status==200){ok=true;
var script={name:req.module_name,url:req.responseURL,src:req.responseText};}}
else{
skip=true;}}
else{
ok=true;}
if(skip){return;}
if(ok){try{
run_script(script)}
catch(e){if(onerror===undefined){throw e;}
else{onerror(e);}}
if(scripts.length>0){load_scripts(scripts)}}else{try{
throw Error("cannot load script "+
req.module_name+' at '+req.responseURL+
': error '+req.status)}
catch(e){if(onerror===undefined){throw e;}
else{onerror(e);}}}}
var noajax=true
while(scripts.length>0 && noajax){var script=scripts.shift()
if(script['src']===undefined){
noajax=false;
var req=new XMLHttpRequest()
req.onreadystatechange=callback
req.module_name=script.name
req.open('GET',script.url,true)
req.send()}else{
callback(null,script)
load_scripts(scripts)}}}
$B._load_scripts=load_scripts;
function run_script(script){
$B.$py_module_path[script.name]=script.url
var root,js
try{
root=$B.py2js(script.src,script.name,script.name,'__builtins__')
js=root.to_js()
if($B.debug>1){console.log(js)}
eval(js)}catch($err){if($B.debug>1){console.log($err)
for(var attr in $err){console.log(attr+' : ',$err[attr])}}
if($err.$py_error===undefined){console.log('Javascript error',$err)
$err=_b_.RuntimeError($err+'')}
var name=$err.__name__
var $trace=_b_.getattr($err,'info')
if(name=='SyntaxError' ||name=='IndentationError'){var offset=$err.args[3]
$trace +='\n ' + ' '.repeat(offset)+ '^' +
'\n' + name+': '+$err.args[0]}else{$trace +='\n'+name+': ' + $err.args}
try{_b_.getattr($B.stderr,'write')($trace)}catch(print_exc_err){console.log($trace)}
throw $err}finally{root=null
js=null
$B.clear_ns(script.name)}}
$B._run_script=run_script;
function brython(options){
if($B.meta_path===undefined){$B.meta_path=[]}
$B.$options={}
if(options===undefined)options={'debug':0}
if(typeof options==='number')options={'debug':options}
if(options.debug===undefined){options.debug=0 }
$B.debug=options.debug
_b_.__debug__=$B.debug>0
$B.compile_time=0
if(options.profile===undefined){options.profile=0}
$B.profile=options.profile
if(options.static_stdlib_import===undefined){options.static_stdlib_import=true}
$B.static_stdlib_import=options.static_stdlib_import
if(options.open !==undefined){_b_.open=options.open;
console.log("DeprecationWarning: \'open\' option of \'brython\' "+
"function will be deprecated in future versions of Brython.");}
$B.$options=options
var meta_path=[]
var path_hooks=[]
if($B.use_VFS){meta_path.push($B.$meta_path[0])
path_hooks.push($B.$path_hooks[0])}
if(options.static_stdlib_import!==false){
meta_path.push($B.$meta_path[1])
if($B.path.length>3){$B.path.shift()
$B.path.shift()}}
meta_path.push($B.$meta_path[2])
$B.meta_path=meta_path
path_hooks.push($B.$path_hooks[1])
$B.path_hooks=path_hooks
var $href=$B.script_path=_window.location.href,$href_elts=$href.split('/')
$href_elts.pop()
if(isWebWorker )$href_elts.pop()
$B.curdir=$href_elts.join('/')
if(options.pythonpath!==undefined){$B.path=options.pythonpath
$B.$options.static_stdlib_import=false}
if(options.python_paths){options.python_paths.forEach(function(path){var lang,prefetch;
if(typeof path !=="string"){lang=path.lang
prefetch=path.prefetch
path=path.path}
$B.path.push(path)
if(path.slice(-7).toLowerCase()=='.vfs.js' &&(prefetch===undefined ||prefetch===true))$B.path_importer_cache[path+'/']=$B.imported['_importlib'].VFSPathFinder(path)
if(lang)_importlib.optimize_import_for_path(path,lang)})}
if(! isWebWorker ){
var path_links=document.querySelectorAll('head link[rel~=pythonpath]'),_importlib=$B.modules['_importlib'];
for(var i=0,e;e=path_links[i];++i){var href=e.href;
if((' ' + e.rel + ' ').indexOf(' prepend ')!=-1){$B.path.unshift(href);}else{
$B.path.push(href);}
if(href.slice(-7).toLowerCase()=='.vfs.js' &&
(' ' + e.rel + ' ').indexOf(' prefetch ')!=-1){
$B.path_importer_cache[href + '/']=
$B.imported['_importlib'].VFSPathFinder(href)}
var filetype=e.hreflang;
if(filetype){if(filetype.slice(0,2)=='x-')filetype=filetype.slice(2);
_importlib.optimize_import_for_path(e.href,filetype);}}}
if(options.re_module !==undefined){if(options.re_module=='pyre' ||options.re_module=='jsre'){$B.$options.re=options.re}
console.log("DeprecationWarning: \'re_module\' option of \'brython\' function will be deprecated in future versions of Brython.")}
$B.scripts=[]
$B.js={}
if($B.$options.args){$B.__ARGV=$B.$options.args}else{
$B.__ARGV=_b_.list([])}
if(!isWebWorker){_run_scripts(options)}}
function _run_scripts(options){
var kk=Object.keys(_window)
if(options.ipy_id!==undefined){var $elts=[];
for(var $i=0;$i<options.ipy_id.length;$i++){$elts.push(document.getElementById(options.ipy_id[$i]));}}else{var scripts=document.getElementsByTagName('script'),$elts=[]
for(var i=0;i<scripts.length;i++){var script=scripts[i]
if(script.type=="text/python" ||script.type=="text/python3"){$elts.push(script)}}}
var first_script=true,module_name;
if(options.ipy_id!==undefined){module_name='__main__';
var $src="",js,root
$B.$py_module_path[module_name]=$B.script_path;
for(var $i=0;$i<$elts.length;$i++){var $elt=$elts[$i];
$src +=($elt.innerHTML ||$elt.textContent);}
try{
root=$B.py2js($src,module_name,module_name,'__builtins__')
js=root.to_js()
if($B.debug>1)console.log(js)
eval(js)
$B.clear_ns(module_name)
root=null
js=null}catch($err){root=null
js=null
console.log($err)
if($B.debug>1){console.log($err)
for(var attr in $err){console.log(attr+' : ',$err[attr])}}
if($err.$py_error===undefined){console.log('Javascript error',$err)
$err=_b_.RuntimeError($err+'')}
var $trace=_b_.getattr($err,'info')+'\n'+$err.__name__+
': ' +$err.args
try{_b_.getattr($B.stderr,'write')($trace)}catch(print_exc_err){console.log($trace)}
throw $err}}else{
var defined_ids={}
for(var i=0;i<$elts.length;i++){var elt=$elts[i]
if(elt.id){if(defined_ids[elt.id]){throw Error("Brython error : Found 2 scripts with the same id '"+
elt.id+"'")}else{defined_ids[elt.id]=true}}}
var scripts=[]
for(var $i=0;$i<$elts.length;$i++){var $elt=$elts[$i]
if($elt.type=="text/python"||$elt.type==="text/python3"){if($elt.id){module_name=$elt.id}
else{if(first_script){module_name='__main__';first_script=false}
else{module_name='__main__'+$B.UUID()}
while(defined_ids[module_name]!==undefined){module_name='__main__'+$B.UUID()}}
$B.scripts.push(module_name)
var $src=null
if($elt.src){
scripts.push({name:module_name,url:$elt.src})}else{
var $src=($elt.innerHTML ||$elt.textContent)
$src=$src.replace(/^\n/,'')
$B.$py_module_path[module_name]=$B.script_path
scripts.push({name: module_name,src: $src,url: $B.script_path})}}}}
if(options.ipy_id===undefined){$B._load_scripts(scripts)}}
$B.$operators=$operators
$B.$Node=$Node
$B.$NodeJSCtx=$NodeJSCtx
$B.brython=brython})(__BRYTHON__)
var brython=__BRYTHON__.brython
__BRYTHON__.$__new__=function(factory){return function(cls){
var res=factory.apply(null,[])
res.__class__=cls.$dict
var init_func=null
try{init_func=__BRYTHON__.builtins.getattr(res,'__init__')}
catch(err){}
if(init_func!==null){var args=[],pos=0
for(var i=1,_len_i=arguments.length;i < _len_i;i++){args[pos++]=arguments[i]}
init_func.apply(null,args)
res.__initialized__=true}
return res}}
__BRYTHON__.builtins.object=(function($B){var _b_=$B.builtins
var $ObjectDict={
__name__:'object',$native:true}
var opnames=['add','sub','mul','truediv','floordiv','mod','pow','lshift','rshift','and','xor','or']
var opsigns=['+','-','*','/','//','%','**','<<','>>','&','^','|']
$ObjectDict.__delattr__=function(self,attr){_b_.getattr(self,attr)
delete self[attr];
return _b_.None}
$ObjectDict.__dir__=function(self){var objects=[self],pos=1,klass=self.__class__ ||$B.get_class(self)
objects[pos++]=klass
var mro=klass.__mro__
for(var i=0,_len_i=mro.length;i < _len_i;i++){objects[pos++]=mro[i]}
var res=[],pos=0
for(var i=0,_len_i=objects.length;i < _len_i;i++){for(var attr in objects[i]){if(attr=='toString'){console.log(attr,objects[i][attr])}
if(attr.charAt(0)=='$'){
continue}
if(!isNaN(parseInt(attr.charAt(0)))){
continue}
if(attr=='__mro__'){continue}
res[pos++]=attr}}
for(var attr in self){if(attr.substr(0,2)=='$$'){res[pos++]=attr.substr(2)}
else if(attr.charAt(0)!='$'){res[pos++]=attr}}
res=_b_.list(_b_.set(res))
_b_.list.$dict.sort(res)
return res}
$ObjectDict.__eq__=function(self,other){
var _class=$B.get_class(self)
if(_class.$native ||_class.__name__=='function'){var _class1=$B.get_class(other)
if(!_class1.$native && _class1.__name__ !='function'){return _b_.getattr(other,'__eq__')(self)}}
return self===other}
$ObjectDict.__format__=function(){var $=$B.args('__format__',2,{self:null,spec:null},['self','spec'],arguments,{},null,null)
if($.spec!==''){throw _b_.TypeError("non-empty format string passed to object.__format__")}
return _b_.getattr($.self,'__repr__')()}
$ObjectDict.__ge__=function(){return _b_.NotImplemented}
$ObjectDict.__getattribute__=function(obj,attr){var klass=obj.__class__ ||$B.get_class(obj)
if(attr==='__class__'){return klass.$factory}
var res=obj[attr]
if(res===undefined){
function check(obj,kl,attr){var v=kl[attr]
if(v!==undefined){return v}else if(attr=='__str__' && kl['__repr__']!==undefined){
return kl['__repr__']}}
res=check(obj,klass,attr)
if(res===undefined){var mro=klass.__mro__
for(var i=0,_len_i=mro.length;i < _len_i;i++){res=check(obj,mro[i],attr)
if(res!==undefined){break}}}}else{if(res.__set__===undefined){
return res}}
if(res!==undefined){if(res.__class__===_b_.property.$dict){return res.__get__(res,obj,klass)}
var get=res.__get__
if(get===undefined && res.__class__){var get=res.__class__.__get__
for(var i=0;i<res.__class__.__mro__.length && get===undefined;i++){get=res.__class__.__mro__[i].__get__}}
var __get__=get===undefined ? null : _b_.getattr(res,'__get__',null)
if(__get__!==null){try{return __get__.apply(null,[obj,klass])}
catch(err){console.log('error in get.apply',err)
console.log(__get__+'')
throw err}}
if(typeof res=='object'){if(__get__ &&(typeof __get__=='function')){get_func=function(x,y){return __get__.apply(x,[y,klass])}}}
if(__get__===null &&(typeof res=='function')){__get__=function(x){return x}}
if(__get__!==null){
res.__name__=attr
if(attr=='__new__'){res.$type='staticmethod'}
var res1=__get__.apply(null,[res,obj,klass])
if(typeof res1=='function'){
if(res1.__class__===$B.$factory)return res
else if(res1.__class__===$B.$MethodDict){return res}
return $B.make_method(attr,klass,res)(obj)}else{
return res1}}
return res}else{
var _ga=obj['__getattr__']
if(_ga===undefined){_ga=klass['__getattr__']
if(_ga===undefined){var mro=klass.__mro__
for(var i=0,len=mro.length;i < len;i++){_ga=mro[i]['__getattr__']
if(_ga!==undefined){break}}}}
if(_ga!==undefined){try{return _ga(obj,attr)}
catch(err){}}
if(attr.substr(0,2)=='__' && attr.substr(attr.length-2)=='__'){var attr1=attr.substr(2,attr.length-4)
var rank=opnames.indexOf(attr1)
if(rank > -1){var rop='__r'+opnames[rank]+'__'
var func=function(){try{
if($B.get_class(arguments[0])===klass){throw Error('')}
return _b_.getattr(arguments[0],rop)(obj)}catch(err){var msg="unsupported operand types for "+
opsigns[rank]+": '"+ klass.__name__+"' and '"+
$B.get_class(arguments[0]).__name__+"'"
throw _b_.TypeError(msg)}}
func.$infos={__name__ : klass.__name__+'.'+attr}
return func}}}}
$ObjectDict.__gt__=function(){return _b_.NotImplemented}
$ObjectDict.__hash__=function(self){var hash=self.__hashvalue__
if(hash!==undefined){return hash}
return self.__hashvalue__=$B.$py_next_hash--;}
$ObjectDict.__init__=function(){if(arguments.length==1){
return _b_.None }else if(arguments.length==2){
kw=arguments[1]
if(kw.$nat !==undefined && kw.kw !==undefined){
if(Object.keys(kw.kw).length==0){
return _b_.None }}}
throw _b_.TypeError("object() takes no parameters")}
$ObjectDict.__le__=function(){return _b_.NotImplemented}
$ObjectDict.__lt__=function(){return _b_.NotImplemented}
$ObjectDict.__mro__=[]
$ObjectDict.__new__=function(cls){if(cls===undefined){throw _b_.TypeError('object.__new__(): not enough arguments')}
return{__class__ : cls.$dict}}
$ObjectDict.__ne__=function(self,other){var eq=_b_.getattr(self,"__eq__")
return !eq(other)}
$ObjectDict.__repr__=function(self){if(self===object)return "<class 'object'>"
if(self.__class__===$B.$factory)return "<class '"+self.$dict.__name__+"'>"
if(self.__class__===$B.$type && self.__name__=='classXXX')return "<class '"+self.__name__+"'>"
if(self.__class__.__module__!==undefined){return "<"+self.__class__.__module__+"."+self.__class__.__name__+" object>"}else{return "<"+self.__class__.__name__+" object>"}}
$ObjectDict.__setattr__=function(self,attr,val){if(val===undefined){
throw _b_.TypeError("can't set attributes of built-in/extension type 'object'")}else if(self.__class__===$ObjectDict){
if($ObjectDict[attr]===undefined){throw _b_.AttributeError("'object' object has no attribute '"+attr+"'")}else{throw _b_.AttributeError("'object' object attribute '"+attr+"' is read-only")}}
if($B.aliased_names[attr]){attr='$$'+attr}
self[attr]=val
return _b_.None}
$ObjectDict.__setattr__.__str__=function(){return 'method object.setattr'}
$ObjectDict.__str__=$ObjectDict.__repr__
$ObjectDict.__subclasshook__=function(){return _b_.NotImplemented}
$B.set_func_names($ObjectDict)
function object(){var res={__class__:$ObjectDict},args=[res].concat(Array.prototype.slice.call(arguments))
$ObjectDict.__init__.apply(null,args)
return res}
object.$dict=$ObjectDict
$ObjectDict.$factory=object
object.__repr__=object.__str__=function(){return "<class 'object'>"}
$B.make_class=function(class_obj){
function A(){var res={__class__:A.$dict}
if(class_obj.init){class_obj.init.apply(null,[res].concat(Array.prototype.slice.call(arguments)))}
return res}
A.__class__=$B.$factory
A.$dict={__class__: $B.$type,__name__: class_obj.name,$factory: A}
A.$dict.__mro__=[object.$dict]
return A}
return object})(__BRYTHON__)
;(function($B){var _b_=$B.builtins
$B.$class_constructor=function(class_name,class_obj,parents,parents_names,kwargs){var metaclass=_b_.type
if(kwargs !==undefined){var cl_dict=_b_.dict(),bases=null
for(var attr in class_obj){if(attr.charAt(0)!='$' ||attr.substr(0,2)=='$$'){cl_dict.$string_dict[attr]=class_obj[attr]}}
if(parents!==undefined){for(var i=0;i<parents.length;i++){if(parents[i]===undefined){
$B.line_info=class_obj.$def_line
throw _b_.NameError("name '"+parents_names[i]+"' is not defined")}}}
bases=parents
for(var i=0;i<kwargs.length;i++){var key=kwargs[i][0],val=kwargs[i][1]
if(key=='metaclass'){metaclass=val}
else{throw _b_.TypeError("type() takes 1 or 3 arguments")}}
var mro0=class_obj}else{
var cl_dict=class_obj
bases=parents
var mro0=cl_dict.$string_dict }
var init_subclass=function init_subclass(){};
for(var i=0;i<bases.length;i++){if(bases[i].$dict.$methods){var __init_subclass__=bases[i].$dict.$methods.__init_subclass__;
if(__init_subclass__){init_subclass=function init_subclass(cls){var kw={$nat:true,kw:{}}
for(var kwidx=0;kwidx<kwargs.length;kwidx++){kw.kw[kwargs[kwidx][0]]=kwargs[kwidx][1];}
__init_subclass__().$infos.__func__.apply(null,[cls,kw]);}
break;}}}
var class_dict={__name__ : class_name.replace('$$',''),__bases__ : bases,__dict__ : cl_dict}
class_dict.__slots__=mro0.__slots__
class_dict.__mro__=make_mro(bases,cl_dict)
var is_instanciable=true,non_abstract_methods={},abstract_methods={},mro=[class_dict].concat(class_dict.__mro__)
for(var i=0;i<mro.length;i++){var kdict=i==0 ? mro0 : mro[i]
for(var attr in kdict){if(non_abstract_methods[attr]){continue}
var v=kdict[attr]
if(typeof v=='function' && v.__class__!==$B.$factory){if(v.__isabstractmethod__===true){is_instanciable=false
abstract_methods[attr]=true}else{non_abstract_methods[attr]=true}}}}
for(var i=0;i<mro.length;i++){var _slots=mro[i].__slots__
if(_slots!==undefined){if(typeof _slots=='string'){_slots=[_slots]}
else{_slots=_b_.list(_slots)}
for(var j=0;j<_slots.length;j++){cl_dict.$slots=cl_dict.$slots ||{}
cl_dict.$slots[_slots[j]]=class_dict.__mro__[i]}}}
if(metaclass===_b_.type){for(var i=1;i<mro.length;i++){if(mro[i].__class__ !==$B.$type){metaclass=mro[i].__class__.$factory
break}}}
class_dict.__class__=metaclass.$dict
var meta_new=$B.$type.__getattribute__(metaclass.$dict,'__new__')
if(meta_new.__func__===$B.$type.__new__){var kls=_b_.type.$dict.__new__(_b_.type,class_name,bases,cl_dict)}else{var kls=meta_new(metaclass,class_name,bases,cl_dict)}
var meta_call=$B.$type.__getattribute__(metaclass.$dict,'__call__',kls)
if(meta_call.__func__===$B.$type.__call__){var factory=$instance_creator(kls)}else{
var factory=function(){
if(kls.$instanciable!==undefined){return function(){throw _b_.TypeError(
"Can't instantiate abstract "+
"class interface with abstract methods")}}
var args=[kls.$factory]
for(var i=0;i < arguments.length;i++){args.push(arguments[i])}
return meta_call.apply(null,args)}
factory.$dfactory=$instance_creator(kls)}
factory.__class__=$B.$factory
factory.$dict=kls
factory.$is_func=true
factory.__eq__=function(other){return other===factory.__class__}
kls.$factory=factory
var meta_init=$B.$type.__getattribute__(metaclass.$dict,'__init__',kls)
if(meta_init.__func__===$B.$type.__init__){_b_.type.$dict.__init__(kls.$factory,class_name,bases,cl_dict)}else{meta_init(class_name,bases,cl_dict)}
class_dict.$factory=factory
for(var i=0;i<parents.length;i++){parents[i].$dict.$subclasses=parents[i].$dict.$subclasses ||[]
parents[i].$dict.$subclasses.push(factory)}
if(metaclass===_b_.type){init_subclass(factory);
return factory}
for(var attr in class_dict){factory.$dict[attr]=class_dict[attr]}
factory.$dict.$factory=factory
for(var member in metaclass.$dict){if(typeof metaclass.$dict[member]=='function' && member !='__new__' && member !="__str__"){metaclass.$dict[member].$type='classmethod'}}
if(!is_instanciable){function nofactory(){throw _b_.TypeError("Can't instantiate abstract class interface"+
" with abstract methods "+Object.keys(abstract_methods).join(', '))}
for(var attr in factory){nofactory[attr]=factory[attr]}
init_subclass(nofactory);
return nofactory}
init_subclass(factory);
return factory}
$B.make_method=function(attr,klass,func){
var method
switch(func.$type){case undefined:
case 'function':
method=function(instance){var instance_method=function(){var local_args=[instance]
for(var i=0,_len_i=arguments.length;i < _len_i;i++){local_args.push(arguments[i])}
return func.apply(instance,local_args)}
instance_method.__class__=$B.$MethodDict
instance_method.$infos={__class__:klass.$factory,__func__:func,__name__:attr,__qualname__:klass.__name__+'.'+attr,__self__:instance}
return instance_method}
break
case 'instancemethod':
return func
case 'classmethod':
method=function(obj){var class_method=function(){var local_args=0;
if(obj !==undefined){local_args=[obj.__class__.$factory]}else{
local_args=[klass.$factory]}
var pos=local_args.length
for(var i=0,_len_i=arguments.length;i < _len_i;i++){local_args[pos++]=arguments[i]}
return func.apply(null,local_args)}
class_method.__class__=$B.$MethodDict
class_method.$infos={__class__:klass.$factory,__func__:func,__name__:attr,__qualname__:klass.__name__+'.'+attr}
return class_method}
break
case 'staticmethod':
method=function(){return func}
break}
return method}
function make_mro(bases,cl_dict){
var seqs=[],pos1=0
for(var i=0;i<bases.length;i++){
if(bases[i]===_b_.str)bases[i]=$B.$StringSubclassFactory
else if(bases[i]===_b_.float)bases[i]=$B.$FloatSubclassFactory
else if(bases[i]===_b_.list)bases[i]=$B.$ListSubclassFactory
var bmro=[],pos=0
if(bases[i].$dict===undefined ||
bases[i].$dict.__mro__===undefined){throw _b_.TypeError('Object passed as base class is not a class')}
bmro[pos++]=bases[i].$dict
var _tmp=bases[i].$dict.__mro__
if(_tmp[0]===bases[i].$dict){console.log('bizarre',bases[i].$dict)
_tmp.splice(0,1)}
for(var k=0;k<_tmp.length;k++){bmro[pos++]=_tmp[k]}
seqs[pos1++]=bmro}
if(bases.indexOf(_b_.object)==-1){bases=bases.concat(_b_.tuple([_b_.object]))}
for(var i=0;i<bases.length;i++)seqs[pos1++]=bases[i].$dict
var mro=[],mpos=0
while(1){var non_empty=[],pos=0
for(var i=0;i<seqs.length;i++){if(seqs[i].length>0)non_empty[pos++]=seqs[i]}
if(non_empty.length==0)break
for(var i=0;i<non_empty.length;i++){var seq=non_empty[i],candidate=seq[0],not_head=[],pos=0
for(var j=0;j<non_empty.length;j++){var s=non_empty[j]
if(s.slice(1).indexOf(candidate)>-1){not_head[pos++]=s}}
if(not_head.length>0){candidate=null}
else{break}}
if(candidate===null){throw _b_.TypeError("inconsistent hierarchy, no C3 MRO is possible")}
mro[mpos++]=candidate
for(var i=0;i<seqs.length;i++){var seq=seqs[i]
if(seq[0]===candidate){
seqs[i].shift()}}}
if(mro[mro.length-1]!==_b_.object.$dict){mro[mpos++]=_b_.object.$dict}
return mro}
_b_.type=function(obj,bases,cl_dict){if(arguments.length==1){if(obj.__class__===$B.$factory){
return obj.$dict.__class__.$factory}
return $B.get_class(obj).$factory}
return $B.$class_constructor(obj,cl_dict,bases,undefined,undefined)}
_b_.type.__class__=$B.$factory
$B.$type={$factory: _b_.type,__name__:'type'}
$B.$type.__class__=$B.$type
$B.$type.__mro__=[_b_.object.$dict]
_b_.type.$dict=$B.$type
$B.$type.__new__=function(meta,name,bases,cl_dict){
var class_dict={__class__ : $B.$type,__name__ : name.replace('$$',''),__bases__ : bases,__dict__ : cl_dict,$methods :{},$slots: cl_dict.$slots}
var items=$B.$dict_items(cl_dict);
for(var i=0;i<items.length;i++){var name=items[i][0],v=items[i][1]
class_dict[name]=v
if(typeof v=='function'
&& v.__class__!==$B.$factory
&& v.__class__!==$B.$MethodDict){class_dict.$methods[name]=$B.make_method(name,class_dict,v,v)}}
class_dict.__mro__=make_mro(bases,cl_dict)
class_dict.__class__=class_dict.__mro__[0].__class__
return class_dict}
$B.$type.__init__=function(cls,name,bases,cl_dict){}
$B.$type.__call__=function(){
$f=arguments[0].$dfactory
args=[]
for(var i=1;i < arguments.length;i++){args.push(arguments[i])}
return $f.apply(null,args)}
$B.$factory={__class__:$B.$type,$factory:_b_.type,is_class:true}
$B.$factory.__mro__=[$B.$type,_b_.object.$dict]
_b_.type.__class__=$B.$factory
_b_.object.$dict.__class__=$B.$type
_b_.object.__class__=$B.$factory
function method_wrapper(attr,klass,method){
method.__str__=method.__repr__=function(self){return "<method '"+attr+"' of '"+klass.__name__+"' objects>"}
return method}
$B.$type.__repr__=$B.$type.__str__=function(self){return "<class '" + self.$dict.__name__ +"'>"}
$B.$type.__getattribute__=function(klass,attr,metaclassed){switch(attr){case '__eq__':
return method_wrapper(attr,klass,function(other){return klass.$factory===other})
case '__ne__':
return method_wrapper(attr,klass,function(other){return klass.$factory!==other})
case '__class__':
return klass.__class__.$factory
case '__doc__':
return klass.__doc__ ||_b_.None
case '__setattr__':
if(klass['__setattr__']!==undefined){var func=klass['__setattr__']}
else{var func=function(key,value){klass[key]=value}}
return method_wrapper(attr,klass,func)
case '__delattr__':
if(klass['__delattr__']!==undefined)return klass['__delattr__']
return method_wrapper(attr,klass,function(key){delete klass[key]})}
var res=klass[attr]
if(res===undefined){
var v=klass[attr]
if(v===undefined){var mro=klass.__mro__
for(var i=0;i<mro.length;i++){var v=mro[i][attr]
if(v!==undefined){res=v
break}}}else{res=v}
if(res===undefined){
var v=klass.__class__[attr]
if(v===undefined){var cl_mro=klass.__class__.__mro__
if(cl_mro!==undefined){for(var i=0;i<cl_mro.length;i++){var v=cl_mro[i][attr]
if(v!==undefined){res=v
break}}}}else{res=v}}
if(res===undefined){
var getattr=null,v=klass.__class__.__getattr__
if(v===undefined){for(var i=0;i<cl_mro.length;i++){if(cl_mro[i].__getattr__!==undefined){getattr=cl_mro[i].__getattr__
break}}}else{getattr=v}
if(getattr!==null){if(getattr.$type=='classmethod'){return getattr(klass.$factory,attr)}
return getattr(attr)}}}
if(res===undefined && klass.$slots && klass.$slots[attr]!==undefined){return member_descriptor(klass.$slots[attr],attr)}
if(res!==undefined){
if(res.__class__===$B.$PropertyDict)return res
var get_func=res.__get__
if(get_func===undefined &&(typeof res=='function')){get_func=function(x){return x}}
if(get_func===undefined)return res
if(attr=='__new__'){res.$type='staticmethod'}
if(metaclassed !==undefined){if(attr=='__init__'){res.$type='classmethod'}else if(attr=='__call__'){res.$type='classmethod'}}
var res1=get_func.apply(null,[res,$B.builtins.None,klass])
if(res1.__class__===$B.$factory){
return res1}
if(typeof res1=='function'){
switch(res.$type){case undefined:
case 'function':
case 'instancemethod':
case 'staticmethod':
return res
case 'classmethod':
var args
if(metaclassed===undefined){args=[klass.$factory]}else{
if(metaclassed.$factory===undefined){
args=[]}else{
args=[metaclassed.$factory]}}
var cl_method=(function(initial_args){return function(){
var local_args=initial_args.slice(),pos=local_args.length
for(var i=0;i < arguments.length;i++){local_args[pos++]=arguments[i]}
var result=res.apply(null,local_args)
return result}})(args)
cl_method.__class__=$B.$MethodDict
cl_method.$infos={__self__: klass.$factory,__func__: res,__name__: attr,__qualname__: klass.__name__ + '.' + attr}
return cl_method}}}}
$B.set_func_names($B.$type)
function $instance_creator(klass){
if(klass.$instanciable!==undefined){return function(){throw _b_.TypeError("Can't instantiate abstract "+
"class interface with abstract methods")}}
var new_func=klass.__new__
for(var i=0;i<klass.__mro__.length && new_func===undefined;i++){new_func=klass.__mro__[i].__new__}
var init_func=klass.__init__
for(var i=0;i<klass.__mro__.length - 1 && init_func===undefined;i++){init_func=klass.__mro__[i].__init__}
if(init_func===undefined && new_func===_b_.object.$dict.__new__){
return function(){if(arguments.length>0){throw _b_.TypeError("object() takes no parameters")}
return{__class__: klass}}}else if(new_func===_b_.object.$dict.__new__ ||
new_func===$B.$type.__new__){
return function(){var obj={__class__:klass}
var args=[obj]
for(var i=0,len=arguments.length;i<len;i++){args.push(arguments[i])}
if(init_func!==undefined){init_func.apply(null,args)}
return obj}}else{
return function(){var args=[klass.$factory]
for(var i=0,len=arguments.length;i<len;i++){args.push(arguments[i])}
var obj=new_func.apply(null,args),args=[obj]
for(var i=0,len=arguments.length;i<len;i++){args.push(arguments[i])}
if(!obj.__initialized__ && init_func!==undefined){init_func.apply(null,args)}
return obj}}}
function member_descriptor(klass,attr){return{__class__:member_descriptor.$dict,klass: klass,attr: attr}}
member_descriptor.__class__=$B.$factory
member_descriptor.$dict={__class__: $B.$type,__name__: 'member_descriptor',$factory: member_descriptor,__str__: function(self){return "<member '"+self.attr+"' of '"+self.klass.__name__+
"' objects>"}}
member_descriptor.$dict.__mro__=[_b_.object.$dict]
function $MethodFactory(){}
$MethodFactory.__class__=$B.$factory
$B.$MethodDict={__class__:$B.$type,__name__:'method',$factory:$MethodFactory}
$B.$MethodDict.__eq__=function(self,other){return self.$infos !==undefined &&
other.$infos !==undefined &&
self.$infos.__func__===other.$infos.__func__ &&
self.$infos.__self__===other.$infos.__self__}
$B.$MethodDict.__ne__=function(self,other){return !$B.$MethodDict.__eq__(self,other)}
$B.$MethodDict.__getattribute__=function(self,attr){
var infos=self.$infos
if(infos && infos[attr]){if(attr=='__code__'){var res={__class__:$B.$CodeDict}
for(var attr in infos.__code__){res[attr]=infos.__code__[attr]}
return res}else{return infos[attr]}}else if(infos && infos.__func__ && infos.__func__.$infos &&
infos.__func__.$infos[attr]){
return infos.__func__.$infos[attr]}else{return _b_.object.$dict.__getattribute__(self,attr)}}
$B.$MethodDict.__mro__=[_b_.object.$dict]
$B.$MethodDict.__repr__=$B.$MethodDict.__str__=function(self){return '<bound method '+self.$infos.__qualname__+'.'+
' of '+ _b_.str(self.$infos.__self__)+'>'}
$MethodFactory.$dict=$B.$MethodDict
$B.set_func_names($B.$MethodDict)
$B.$InstanceMethodDict={__class__:$B.$type,__name__:'instancemethod',__mro__:[_b_.object.$dict],$factory:$MethodFactory}})(__BRYTHON__)
;(function($B){var _b_=$B.builtins
var _window=self;
var isWebWorker=('undefined' !==typeof WorkerGlobalScope)&&("function"===typeof importScripts)&&(navigator instanceof WorkerNavigator);
$B.args=function($fname,argcount,slots,var_names,$args,$dobj,extra_pos_args,extra_kw_args){
var has_kw_args=false,nb_pos=$args.length
if(nb_pos>0 && $args[nb_pos-1]&& $args[nb_pos-1].$nat){has_kw_args=true
nb_pos--
var kw_args=$args[nb_pos].kw}
if(extra_pos_args){slots[extra_pos_args]=[];
slots[extra_pos_args].__class__=_b_.tuple.$dict}
if(extra_kw_args){
slots[extra_kw_args]={__class__:_b_.dict.$dict,$numeric_dict :{},$object_dict :{},$string_dict :{},$str_hash:{},length: 0}}
if(nb_pos>argcount){
if(extra_pos_args===null){
msg=$fname+"() takes "+argcount+' positional argument'+
(argcount> 1 ? '' : 's')+ ' but more were given'
throw _b_.TypeError(msg)}else{
for(var i=argcount;i<nb_pos;i++){slots[extra_pos_args].push($args[i])}
nb_pos=argcount}}
for(var i=0;i<nb_pos;i++){slots[var_names[i]]=$args[i]}
if(has_kw_args){for(var key in kw_args){var value=kw_args[key]
if(slots[key]===undefined){
if(extra_kw_args){
if(key.substr(0,2)=='$$'){key=key.substr(2)}
slots[extra_kw_args].$string_dict[key]=value}else{throw _b_.TypeError($fname+"() got an unexpected keyword argument '"+key+"'")}}else if(slots[key]!==null){
throw _b_.TypeError($fname+"() got multiple values for argument '"+key+"'")}else{
slots[key]=value}}}
var missing=[]
for(var attr in slots){if(slots[attr]===null){if($dobj[attr]!==undefined){slots[attr]=$dobj[attr]}
else{missing.push("'"+attr+"'")}}}
if(missing.length>0){if(missing.length==1){throw _b_.TypeError($fname+" missing 1 positional argument: "+missing[0])}else{var msg=$fname+" missing "+missing.length+" positional arguments: "
msg +=missing.join(' and ')
throw _b_.TypeError(msg)}}
return slots}
$B.wrong_nb_args=function(name,received,expected,positional){if(received<expected){var missing=expected-received
throw _b_.TypeError(name+'() missing '+missing+
' positional argument'+(missing>1 ? 's' : '')+': '+
positional.slice(received))}else{throw _b_.TypeError(name+'() takes '+expected+' positional argument'+
(expected>1 ? 's' : '')+ ' but more were given')}}
$B.get_class=function(obj,from){
if(obj===null){return $B.$NoneDict}
var klass=obj.__class__
if(klass===undefined){switch(typeof obj){case 'number':
if(obj % 1===0){
obj.__class__=_b_.int.$dict
return _b_.int.$dict}
obj.__class__=_b_.float.$dict
return _b_.float.$dict
case 'string':
obj.__class__=_b_.str.$dict
return _b_.str.$dict
case 'boolean':
obj.__class__=$B.$BoolDict
return $B.$BoolDict
case 'function':
obj.__class__=$B.$FunctionDict
return $B.$FunctionDict
case 'object':
if(Array.isArray(obj)){if(Object.getPrototypeOf(obj)===Array.prototype){obj.__class__=_b_.list.$dict
return _b_.list.$dict}}else if(obj.constructor===Number)return _b_.float.$dict
break}}
return klass}
$B.$mkdict=function(glob,loc){var res={}
for(var arg in glob)res[arg]=glob[arg]
for(var arg in loc)res[arg]=loc[arg]
return res}
$B.$list_comp=function(items){
var ix=$B.UUID()
var py="x"+ix+"=[]\n",indent=0
for(var i=1,len=items.length;i < len;i++){var item=items[i].replace(/\s+$/,'').replace(/\n/g,'')
py +=' '.repeat(indent)+ item + ':\n'
indent +=4}
py +=' '.repeat(indent)
py +='x'+ix+'.append('+items[0]+')\n'
return[py,ix]}
$B.$dict_comp=function(module_name,parent_block_id,items,line_num){
var ix=$B.UUID(),res='res'+ix,py=res+"={}\n",
indent=0
for(var i=1,len=items.length;i<len;i++){var item=items[i].replace(/\s+$/,'').replace(/\n/g,'')
py +=' '.repeat(indent)+ item +':\n'
indent++}
py +=' '.repeat(indent)+ res + '.update({'+items[0]+'})'
var dictcomp_name='dc'+ix,root=$B.py2js({src:py,is_comp:true},module_name,dictcomp_name,parent_block_id,line_num),js=root.to_js()
js +='\nreturn $locals["'+res+'"]\n'
js='(function(){'+js+'})()'
$B.clear_ns(dictcomp_name)
delete $B.$py_src[dictcomp_name]
return js}
$B.$gen_expr=function(module_name,parent_block_id,items,line_num){
var $ix=$B.UUID()
var py='def ge'+$ix+'():\n'
var indent=1
for(var i=1,len=items.length;i < len;i++){var item=items[i].replace(/\s+$/,'').replace(/\n/g,'')
py +=' '.repeat(indent)+ item + ':\n'
indent +=4}
py+=' '.repeat(indent)
py +='yield ('+items[0]+')'
var genexpr_name='ge'+$ix,root=$B.py2js({src:py,is_comp:true},module_name,genexpr_name,parent_block_id,line_num),js=root.to_js(),lines=js.split('\n')
js=lines.join('\n')
js +='\nvar $res = $locals_'+genexpr_name+'["'+genexpr_name+'"]();\n'+
'$res.is_gen_expr=true;\nreturn $res\n'
js='(function(){'+js+'})()\n'
$B.clear_ns(genexpr_name)
delete $B.$py_src[genexpr_name]
return js}
$B.clear_ns=function(name){
var len=name.length
for(var key in $B.modules){if(key.substr(0,len)==name){$B.modules[key]=null
$B.bound[key]=null
$B._globals[key]=null
delete $B.modules[key]
delete $B.bound[key]
delete $B._globals[key]}}
for(var key in $B.$py_module_path){if(key.substr(0,len)==name){$B.$py_module_path[key]=null
delete $B.$py_module_path[key]}}
var alt_name=name.replace(/\./g,'_')
if(alt_name!=name){$B.clear_ns(alt_name)}}
$B.from_alias=function(attr){if(attr.substr(0,2)=='$$' && $B.aliased_names[attr.substr(2)]){return attr.substr(2)}
return attr}
$B.$search=function(name,global_ns){
var frame=$B.last($B.frames_stack)
if(frame[1][name]!==undefined){return frame[1][name]}
else if(frame[3][name]!==undefined){return frame[3][name]}
else if(_b_[name]!==undefined){return _b_[name]}
else{if(frame[0]==frame[2]||frame[1].$type=="class"){throw _b_.NameError("name '"+name+"' is not defined")}
else{throw _b_.UnboundLocalError("local variable '"+name+
"' referenced before assignment")}}}
$B.$global_search=function(name){
for(var i=$B.frames_stack.length-1;i>=0;i--){var frame=$B.frames_stack[i]
if(frame[3][name]!==undefined){return frame[3][name]}
if(frame[1][name]!==undefined){return frame[1][name]}}
throw _b_.NameError("name '"+$B.from_alias(name)+"' is not defined")}
$B.$local_search=function(name){
var frame=$B.last($B.frames_stack)
if(frame[1][name]!==undefined){return frame[1][name]}
else{throw _b_.UnboundLocalError("local variable '"+name+
"' referenced before assignment")}}
$B.$check_def=function(name,value){
if(value!==undefined){return value}
throw _b_.NameError("name '"+name+"' is not defined")}
$B.$check_def_local=function(name,value){
if(value!==undefined){return value}
throw _b_.UnboundLocalError("local variable '"+name+
"' referenced before assignment")}
$B.$check_def_free=function(name,value){
if(value!==undefined){return value}
var res
for(var i=$B.frames_stack.length-1;i>=0;i--){res=$B.frames_stack[i][1][name]
if(res!==undefined){return res}
res=$B.frames_stack[i][3][name]
if(res!==undefined){return res}}
throw _b_.NameError("free variable '"+name+
"' referenced before assignment in enclosing scope")}
$B.$JS2Py=function(src){if(typeof src==='number'){if(src%1===0)return src
return _b_.float(src)}
if(src===null||src===undefined)return _b_.None
var klass=$B.get_class(src)
if(klass!==undefined){if(klass===_b_.list.$dict){for(var i=0,_len_i=src.length;i< _len_i;i++)src[i]=$B.$JS2Py(src[i])}else if(klass===$B.JSObject.$dict){src=src.js}else{return src}}
if(typeof src=="object"){if($B.$isNode(src))return $B.DOMNode(src)
if($B.$isEvent(src))return $B.$DOMEvent(src)
if($B.$isNodeList(src))return $B.DOMNode(src)
if(Array.isArray(src)&&Object.getPrototypeOf(src)===Array.prototype){var res=[],pos=0
for(var i=0,_len_i=src.length;i<_len_i;i++)res[pos++]=$B.$JS2Py(src[i])
return res}}
return $B.JSObject(src)}
$B.list_key=function(obj,key){key=$B.$GetInt(key)
if(key<0){key +=obj.length}
var res=obj[key]
if(res===undefined){throw _b_.IndexError("list index out of range")}
return res}
$B.list_slice=function(obj,start,stop){if(start===null){start=0}
else{start=$B.$GetInt(start)
if(start<0){start=Math.max(0,start+obj.length)}}
if(stop===null){return obj.slice(start)}
stop=$B.$GetInt(stop)
if(stop<0){stop=Math.max(0,stop+obj.length)}
return obj.slice(start,stop)}
$B.list_slice_step=function(obj,start,stop,step){if(step===null||step==1){return $B.list_slice(obj,start,stop)}
if(step==0){throw _b_.ValueError("slice step cannot be zero")}
step=$B.$GetInt(step)
if(start===null){start=step >=0 ? 0 : obj.length-1}
else{start=$B.$GetInt(start)
if(start<0){start=Math.min(0,start+obj.length)}}
if(stop===null){stop=step >=0 ? obj.length : -1}
else{stop=$B.$GetInt(stop)
if(stop<0){stop=Math.max(0,stop+obj.length)}}
var res=[]
if(step>0){for(var i=start;i<stop;i+=step){res.push(obj[i])}}else{for(var i=start;i>stop;i+=step){res.push(obj[i])}}
return res}
function index_error(obj){var type=typeof obj=='string' ? 'string' : 'list'
throw _b_.IndexError(type+" index out of range")}
$B.$getitem=function(obj,item){if(typeof item=='number'){if(Array.isArray(obj)||typeof obj=='string'){item=item >=0 ? item : obj.length+item
if(obj[item]!==undefined){return obj[item]}
else{index_error(obj)}}}
var ce=$B.current_exception
try{item=$B.$GetInt(item)}catch(err){$B.current_exception=ce}
if((Array.isArray(obj)||typeof obj=='string')
&& typeof item=='number'){item=item >=0 ? item : obj.length+item
if(obj[item]!==undefined){return obj[item]}
else{index_error(obj)}}
return _b_.getattr(obj,'__getitem__')(item)}
$B.set_list_key=function(obj,key,value){try{key=$B.$GetInt(key)}
catch(err){if(_b_.isinstance(key,_b_.slice)){var s=_b_.slice.$dict.$conv_for_seq(key,obj.length)
return $B.set_list_slice_step(obj,s.start,s.stop,s.step,value)}}
if(key<0){key+=obj.length}
if(obj[key]===undefined){console.log(obj,key)
throw _b_.IndexError('list assignment index out of range')}
obj[key]=value}
$B.set_list_slice=function(obj,start,stop,value){if(start===null){start=0}
else{start=$B.$GetInt(start)
if(start<0){start=Math.max(0,start+obj.length)}}
if(stop===null){stop=obj.length}
stop=$B.$GetInt(stop)
if(stop<0){stop=Math.max(0,stop+obj.length)}
var res=_b_.list(value)
obj.splice.apply(obj,[start,stop-start].concat(res))}
$B.set_list_slice_step=function(obj,start,stop,step,value){if(step===null||step==1){return $B.set_list_slice(obj,start,stop,value)}
if(step==0){throw _b_.ValueError("slice step cannot be zero")}
step=$B.$GetInt(step)
if(start===null){start=step>0 ? 0 : obj.length-1}
else{start=$B.$GetInt(start)
if(start<0){start=Math.min(0,start+obj.length)}}
if(stop===null){stop=step>0 ? obj.length : -1}
else{stop=$B.$GetInt(stop)
if(stop<0){stop=Math.max(0,stop+obj.length)}}
var repl=_b_.list(value),j=0,test,nb=0
if(step>0){test=function(i){return i<stop}}
else{test=function(i){return i>stop}}
for(var i=start;test(i);i+=step){nb++}
if(nb!=repl.length){throw _b_.ValueError('attempt to assign sequence of size '+
repl.length+' to extended slice of size '+nb)}
for(var i=start;test(i);i+=step){obj[i]=repl[j]
j++}}
$B.$setitem=function(obj,item,value){if(Array.isArray(obj)&& typeof item=='number' && !_b_.isinstance(obj,_b_.tuple)){if(item<0){item+=obj.length}
if(obj[item]===undefined){throw _b_.IndexError("list assignment index out of range")}
obj[item]=value
return}else if(obj.__class__===_b_.dict.$dict){obj.__class__.__setitem__(obj,item,value)
return}
_b_.getattr(obj,'__setitem__')(item,value)}
$B.augm_item_add=function(obj,item,incr){if(Array.isArray(obj)&& typeof item=="number" &&
obj[item]!==undefined){if(Array.isArray(obj[item])&& Array.isArray(incr)){for(var i=0,len=incr.length;i<len;i++){obj[item].push(incr[i])}
return}else if(typeof obj[item]=='string' && typeof incr=='string'){obj[item]+=incr
return}}
var ga=_b_.getattr
try{var augm_func=ga(ga(obj,'__getitem__')(item),'__iadd__')}catch(err){ga(obj,'__setitem__')(item,ga(ga(obj,'__getitem__')(item),'__add__')(incr))
return}
augm_func(incr)}
var augm_item_src=''+$B.augm_item_add
var augm_ops=[['-=','sub'],['*=','mul']]
for(var i=0,_len_i=augm_ops.length;i < _len_i;i++){var augm_code=augm_item_src.replace(/add/g,augm_ops[i][1])
augm_code=augm_code.replace(/\+=/g,augm_ops[i][0])
eval('$B.augm_item_'+augm_ops[i][1]+'='+augm_code)}
$B.extend=function(fname,arg){
for(var i=2;i<arguments.length;i++){var mapping=arguments[i]
var it=_b_.iter(mapping),getter=_b_.getattr(mapping,'__getitem__')
while(true){try{var key=_b_.next(it)
if(typeof key!=='string'){throw _b_.TypeError(fname+"() keywords must be strings")}
if(arg[key]!==undefined){throw _b_.TypeError(
fname+"() got multiple values for argument '"+key+"'")}
arg[key]=getter(key)}catch(err){if(_b_.isinstance(err,[_b_.StopIteration])){break}
throw err}}}
return arg}
$B.extend_list=function(){
var res=Array.prototype.slice.call(arguments,0,arguments.length-1),last=$B.last(arguments)
var it=_b_.iter(last)
while(true){try{res.push(_b_.next(it))}catch(err){if(_b_.isinstance(err,[_b_.StopIteration])){break}
throw err}}
return res}
$B.$test_item=function(expr){
$B.$test_result=expr
return _b_.bool(expr)}
$B.$test_expr=function(){
return $B.$test_result}
$B.$is=function(a,b){
if(a instanceof Number && b instanceof Number){return a.valueOf()==b.valueOf()}
return a===b}
$B.$is_member=function(item,_set){
var f,_iter
try{f=_b_.getattr(_set,"__contains__")}
catch(err){}
if(f)return f(item)
try{_iter=_b_.iter(_set)}
catch(err){}
if(_iter){while(1){try{var elt=_b_.next(_iter)
if(_b_.getattr(elt,"__eq__")(item))return true}catch(err){if(err.__name__=="StopIteration")return false
throw err}}}
try{f=_b_.getattr(_set,"__getitem__")}
catch(err){throw _b_.TypeError("'"+$B.get_class(_set).__name__+"' object is not iterable")}
if(f){var i=-1
while(1){i++
try{var elt=f(i)
if(_b_.getattr(elt,"__eq__")(item))return true}catch(err){if(err.__name__=='IndexError')return false
throw err}}}}
var $io={__class__:$B.$type,__name__:'io'}
$io.__mro__=[_b_.object.$dict]
$B.stderr={__class__:$io,write:function(data){console.log(data)},flush:function(){}}
$B.stderr_buff=''
$B.stdout={__class__:$io,write: function(data){console.log(data)},flush:function(){}}
$B.stdin={__class__: $io,__original__:true,closed: false,len:1,pos:0,read: function(){return '';},readline: function(){return '';}}
$B.jsobject2pyobject=function(obj){switch(obj){case null:
return _b_.None
case true:
return _b_.True
case false:
return _b_.False}
if(typeof obj==='object' && !Array.isArray(obj)&&
obj.__class__===undefined){
var res=_b_.dict()
for(var attr in obj){res.$string_dict[attr]=$B.jsobject2pyobject(obj[attr])}
return res}
if(_b_.isinstance(obj,_b_.list)){var res=[],pos=0
for(var i=0,_len_i=obj.length;i < _len_i;i++){res[pos++]=$B.jsobject2pyobject(obj[i])}
return res}
if(obj.__class__!==undefined){if(obj.__class__===_b_.list){for(var i=0,_len_i=obj.length;i < _len_i;i++){obj[i]=$B.jsobject2pyobject(obj[i])}
return obj}
return obj}
if(obj._type_==='iter'){
return _b_.iter(obj.data)}
return $B.JSObject(obj)}
$B.pyobject2jsobject=function(obj){
switch(obj){case _b_.None:
return null
case _b_.True:
return true
case _b_.False:
return false}
if(_b_.isinstance(obj,[_b_.int,_b_.float,_b_.str]))return obj
if(_b_.isinstance(obj,[_b_.list,_b_.tuple])){var res=[],pos=0
for(var i=0,_len_i=obj.length;i < _len_i;i++){res[pos++]=$B.pyobject2jsobject(obj[i])}
return res}
if(_b_.isinstance(obj,_b_.dict)){var res={}
var items=_b_.list(_b_.dict.$dict.items(obj))
for(var i=0,_len_i=items.length;i < _len_i;i++){res[$B.pyobject2jsobject(items[i][0])]=$B.pyobject2jsobject(items[i][1])}
return res}
if(_b_.hasattr(obj,'__iter__')){
var _a=[],pos=0
while(1){try{
_a[pos++]=$B.pyobject2jsobject(_b_.next(obj))}catch(err){if(err.__name__ !=="StopIteration")throw err
break}}
return{'_type_': 'iter',data: _a}}
if(_b_.hasattr(obj,'__getstate__')){return _b_.getattr(obj,'__getstate__')()}
if(_b_.hasattr(obj,'__dict__')){return $B.pyobject2jsobject(_b_.getattr(obj,'__dict__'))}
throw _b_.TypeError(_b_.str(obj)+' is not JSON serializable')}
$B.set_line=function(line_num,module_name){$B.line_info=line_num+','+module_name
return _b_.None}
$B.$iterator=function(items,klass){var res={__class__:klass,__iter__:function(){return res},__len__:function(){return items.length},__next__:function(){res.counter++
if(res.counter<items.length)return items[res.counter]
throw _b_.StopIteration("StopIteration")},__repr__:function(){return "<"+klass.__name__+" object>"},counter:-1}
res.__str__=res.toString=res.__repr__
return res}
$B.$iterator_class=function(name){var res={__class__:$B.$type,__name__:name,}
res.__mro__=[_b_.object.$dict]
function as_array(s){var _a=[],pos=0
var _it=_b_.iter(s)
while(1){try{
_a[pos++]=_b_.next(_it)}catch(err){if(err.__name__=='StopIteration'){break}}}
return _a}
function as_list(s){return _b_.list(as_array(s))}
function as_set(s){return _b_.set(as_array(s))}
res.__eq__=function(self,other){if(_b_.isinstance(other,[_b_.tuple,_b_.set,_b_.list])){return _b_.getattr(as_list(self),'__eq__')(other)}
if(_b_.hasattr(other,'__iter__')){return _b_.getattr(as_list(self),'__eq__')(as_list(other))}
_b_.NotImplementedError("__eq__ not implemented yet for list and " + _b_.type(other))}
var _ops=['eq','ne']
var _f=res.__eq__+''
for(var i=0;i < _ops.length;i++){var _op='__'+_ops[i]+'__'
eval('res.'+_op+'='+_f.replace(new RegExp('__eq__','g'),_op))}
res.__or__=function(self,other){if(_b_.isinstance(other,[_b_.tuple,_b_.set,_b_.list])){return _b_.getattr(as_set(self),'__or__')(other)}
if(_b_.hasattr(other,'__iter__')){return _b_.getattr(as_set(self),'__or__')(as_set(other))}
_b_.NotImplementedError("__or__ not implemented yet for set and " + _b_.type(other))}
var _ops=['sub','and','xor','gt','ge','lt','le']
var _f=res.__or__+''
for(var i=0;i < _ops.length;i++){var _op='__'+_ops[i]+'__'
eval('res.'+_op+'='+_f.replace(new RegExp('__or__','g'),_op))}
res.$factory={__class__:$B.$factory,$dict:res}
return res}
$B.$CodeDict={__class__:$B.$type,__name__:'code'}
$B.$CodeDict.__mro__=[_b_.object.$dict]
function _code(){}
_code.__class__=$B.$factory
_code.$dict=$B.$CodeDict
$B.$CodeDict.$factory=_code
function $err(op,klass,other){var msg="unsupported operand type(s) for "+op
msg +=": '"+klass.__name__+"' and '"+$B.get_class(other).__name__+"'"
throw _b_.TypeError(msg)}
var ropnames=['add','sub','mul','truediv','floordiv','mod','pow','lshift','rshift','and','xor','or']
var ropsigns=['+','-','*','/','//','%','**','<<','>>','&','^','|']
$B.make_rmethods=function(klass){for(var j=0,_len_j=ropnames.length;j < _len_j;j++){if(klass['__'+ropnames[j]+'__']===undefined){
klass['__'+ropnames[j]+'__']=(function(name,sign){return function(self,other){try{return _b_.getattr(other,'__r'+name+'__')(self)}
catch(err){$err(sign,klass,other)}}})(ropnames[j],ropsigns[j])}}}
$B.UUID=function(){return $B.$py_UUID++}
$B.InjectBuiltins=function(){var _str=["var _b_=$B.builtins"],pos=1
for(var $b in $B.builtins)_str[pos++]='var ' + $b +'=_b_["'+$b+'"]'
return _str.join(';')}
$B.$GetInt=function(value){
if(typeof value=="number"||value.constructor===Number){return value}
else if(typeof value==="boolean"){return value ? 1 : 0}
else if(_b_.isinstance(value,_b_.int)){return value}
else if(_b_.isinstance(value,_b_.float)){return value.valueOf()}
if(value.__class__!==$B.$factory){try{var v=_b_.getattr(value,'__int__')();return v}catch(e){}
try{var v=_b_.getattr(value,'__index__')();return v}catch(e){}}
throw _b_.TypeError("'"+$B.get_class(value).__name__+
"' object cannot be interpreted as an integer")}
$B.PyNumber_Index=function(item){switch(typeof item){case "boolean":
return item ? 1 : 0
case "number":
return item
case "object":
if(item.__class__===$B.LongInt.$dict){return item}
var method=_b_.getattr(item,'__index__',null)
if(method!==null){method=typeof method=='function' ?
method :
_b_.getattr(method,'__call__')
return $B.int_or_bool(method)}
default:
throw _b_.TypeError("'"+$B.get_class(item).__name__+
"' object cannot be interpreted as an integer")}}
$B.int_or_bool=function(v){switch(typeof v){case "boolean":
return v ? 1 : 0
case "number":
return v
case "object":
if(v.__class__===$B.LongInt.$dict){return v}
else{throw _b_.TypeError("'"+$B.get_class(v).__name__+
"' object cannot be interpreted as an integer")}
default:
throw _b_.TypeError("'"+$B.get_class(v).__name__+
"' object cannot be interpreted as an integer")}}
$B.int_value=function(v){
try{return $B.int_or_bool(v)}
catch(err){if(_b_.isinstance(v,_b_.complex)&& v.$imag==0){return $B.int_or_bool(v.$real)}else if(isinstance(v,_b_.float)&& v==Math.floor(v)){return Math.floor(v)}else{throw _b_.TypeError("'"+$B.get_class(v).__name__+
"' object cannot be interpreted as an integer")}}}
$B.enter_frame=function(frame){
$B.frames_stack.push(frame)}
$B.leave_frame=function(arg){
if($B.profile > 0)$B.$profile.return();
if($B.frames_stack.length==0){console.log('empty stack');return}
$B.frames_stack.pop()}
$B.leave_frame_exec=function(arg){
if($B.profile > 0)$B.$profile.return();
if($B.frames_stack.length==0){console.log('empty stack');return}
var frame=$B.frames_stack.pop()
for(var i=$B.frames_stack.length-1;i>=0;i--){if($B.frames_stack[i][2]==frame[2]){$B.frames_stack[i][3]=frame[3]}}}
$B.memory=function(){var info=[]
for(var attr in __BRYTHON__){var obj=__BRYTHON__[attr]
if(obj===null){continue}
if(Array.isArray(obj)){info.push([obj.length,attr])}
else if(typeof obj=='object'){info.push([Object.keys(obj).length,attr])}}
info.sort(function(x,y){return x[0]-y[0]})
for(var i=0,len=info.length;i<len;i++){console.log(info[i][0],info[i][1],__BRYTHON__[info[i][1]])}}
$B.$profile_data={}
$B.$profile=(function(profile){var call_times={},
_START=0,
_CALLER=1,_CUMULATED=2,_LAST_RESUMED=3,call_stack=[],
profile_start=null,
active=false,
paused=false,
cumulated=0;
var _fhash=function(module,fname,line){return module+"."+fname+":"+line;}
var _hash=function(module,line){return module+":"+line;}
var _is_recursive=function(h){for(i=0;i<call_stack.length;i++)
if(call_stack[i]==h)return true;
return false;}
var $profile={'call':function(module,fname,line,caller){if($B.profile > 1 && active){var ctime=new Date();
var h=_fhash(module,fname,line)
if(!(h in call_times)){call_times[h]=[];}
if(call_stack.length > 0){in_func=call_stack[call_stack.length-1];
func_stack=call_times[in_func]
inner_most_call=func_stack[func_stack.length-1];
inner_most_call[_CUMULATED]+=(ctime-inner_most_call[_LAST_RESUMED])
caller=caller+":"+in_func;}
call_times[h].push([ctime,caller,0,ctime])
call_stack.push(h)}},'return':function(){if($B.profile > 1 && active){var h=call_stack.pop()
if(h in call_times){var t_end=new Date();
var data=call_times[h].pop();
t_start=data[_START]
caller=data[_CALLER]
t_duration=t_end-t_start;
t_in_func=data[_CUMULATED]+(t_end-data[_LAST_RESUMED]);
if(!(h in profile.call_times)){profile.call_times[h]=0;
profile.call_times_proper[h]=0;
profile.call_counts[h]=0;
profile.call_counts_norec[h]=0;
profile.callers[h]={};}
profile.call_times[h]+=t_duration;
profile.call_times_proper[h]+=t_in_func;
profile.call_counts[h]+=1;
if(!(caller in profile.callers[h])){profile.callers[h][caller]=[0,0,0,0]}
if(! _is_recursive(h)){profile.call_counts_norec[h]+=1;
profile.callers[h][caller][3]++;}
profile.callers[h][caller][0]+=t_duration;
profile.callers[h][caller][1]+=t_in_func;
profile.callers[h][caller][2]++;
if(call_stack.length > 0){
in_func=call_stack[call_stack.length-1];
func_stack=call_times[in_func];
inner_most_call=func_stack[func_stack.length-1];
inner_most_call[_LAST_RESUMED]=new Date();}}}},'count':function(module,line){if(active){var h=_hash(module,line);
if(!(h in profile.line_counts)){profile.line_counts[h]=0;}
profile.line_counts[h]++;}},'pause':function(){if(active){elapsed=(new Date())-profile_start
cumulated +=elapsed
active=false
paused=true}},'start':function(){if($B.profile > 0){if(! paused )$B.$profile.clear();
else{paused=false;}
active=true
profile_start=new Date()}},'elapsed': function(){if(active)return cumulated +(new Date())-profile_start
else return cumulated;},'stop':function(){if(active ||paused){profile.profile_duration=((new Date())-profile_start)+cumulated
active=false
paused=false}},'clear':function(){cumulated=0;
profile.line_counts={};
profile.call_times={};
profile.call_times_proper={};
profile.call_counts={};
profile.call_counts_norec={};
profile.callers={};
active=false;
paused=false;},'status':function(){if($B.profile <=0)return "Disabled";
if(active)return "Collecting data: active";
else if(paused)return "Collecting data: paused";
else return "Stopped";},}
return $profile;})($B.$profile_data)
var min_int=Math.pow(-2,53),max_int=Math.pow(2,53)-1
$B.is_safe_int=function(){for(var i=0;i<arguments.length;i++){var arg=arguments[i]
if(arg<min_int ||arg>max_int){return false}}
return true}
$B.add=function(x,y){var z=(typeof x!='number' ||typeof y!='number')?
new Number(x+y): x+y
if(x>min_int && x<max_int && y>min_int && y<max_int
&& z>min_int && z<max_int){return z}
else if((typeof x=='number' ||x.__class__===$B.LongInt.$dict)
&&(typeof y=='number' ||y.__class__===$B.LongInt.$dict)){if((typeof x=='number' && isNaN(x))||
(typeof y=='number' && isNaN(y))){return _b_.float('nan')}
var res=$B.LongInt.$dict.__add__($B.LongInt(x),$B.LongInt(y))
return res}else{return z}}
$B.div=function(x,y){var z=x/y
if(x>min_int && x<max_int && y>min_int && y<max_int
&& z>min_int && z<max_int){return z}
else{return $B.LongInt.$dict.__truediv__($B.LongInt(x),$B.LongInt(y))}}
$B.eq=function(x,y){if(x>min_int && x<max_int && y>min_int && y<max_int){return x==y}
return $B.LongInt.$dict.__eq__($B.LongInt(x),$B.LongInt(y))}
$B.floordiv=function(x,y){var z=x/y
if(x>min_int && x<max_int && y>min_int && y<max_int
&& z>min_int && z<max_int){return Math.floor(z)}
else{return $B.LongInt.$dict.__floordiv__($B.LongInt(x),$B.LongInt(y))}}
$B.mul=function(x,y){var z=(typeof x!='number' ||typeof y!='number')?
new Number(x*y): x*y
if(x>min_int && x<max_int && y>min_int && y<max_int
&& z>min_int && z<max_int){return z}
else if((typeof x=='number' ||x.__class__===$B.LongInt.$dict)
&&(typeof y=='number' ||y.__class__===$B.LongInt.$dict)){if((typeof x=='number' && isNaN(x))||
(typeof y=='number' && isNaN(y))){return _b_.float('nan')}
return $B.LongInt.$dict.__mul__($B.LongInt(x),$B.LongInt(y))}else{return z}}
$B.sub=function(x,y){var z=(typeof x!='number' ||typeof y!='number')?
new Number(x-y): x-y
if(x>min_int && x<max_int && y>min_int && y<max_int
&& z>min_int && z<max_int){return z}
else if((typeof x=='number' ||x.__class__===$B.LongInt.$dict)
&&(typeof y=='number' ||y.__class__===$B.LongInt.$dict)){if((typeof x=='number' && isNaN(x))||
(typeof y=='number' && isNaN(y))){return _b_.float('nan')}
return $B.LongInt.$dict.__sub__($B.LongInt(x),$B.LongInt(y))}else{return z}}
$B.ge=function(x,y){if(typeof x=='number' && typeof y=='number'){return x>=y}
else if(typeof x=='number' && typeof y!='number'){return !y.pos}
else if(typeof x !='number' && typeof y=='number'){return x.pos===true}
else{return $B.LongInt.$dict.__ge__(x,y)}}
$B.gt=function(x,y){if(typeof x=='number' && typeof y=='number'){return x>y}
else if(typeof x=='number' && typeof y!='number'){return !y.pos}
else if(typeof x !='number' && typeof y=='number'){return x.pos===true}
else{return $B.LongInt.$dict.__gt__(x,y)}}
var reversed_op={'__lt__': '__gt__','__le__':'__ge__','__gt__': '__lt__','__ge__': '__le__'}
var method2comp={'__lt__': '<','__le__': '<=','__gt__': '>','__ge__': '>='}
$B.rich_comp=function(op,x,y){var x1=x.valueOf(),y1=y.valueOf()
if(typeof x1=='number' && typeof y1=='number' &&
x.__class__==undefined && y.__class__===undefined){switch(op){case "__eq__":
return x1==y1
case "__ne__":
return x1 !=y1
case "__le__":
return x1 <=y1
case "__lt__":
return x1 < y1
case "__ge__":
return x1 >=y1
case "__gt__":
return x1 > y1}}
var res,rev_op,compared=false
if(x.__class__ && y.__class__){
if(y.__class__.__mro__.indexOf(x.__class__)>-1){rev_op=reversed_op[op]||op
res=_b_.getattr(y,rev_op)(x)
if(res !==_b_.NotImplemented )return res
compared=true}}
res=_b_.getattr(x,op)(y)
if(res !==_b_.NotImplemented )return res;
if(compared)return false;
rev_op=reversed_op[op]||op
res=_b_.getattr(y,rev_op)(x)
if(res !==_b_.NotImplemented )return res
if(op=='__eq__'){return _b_.False}
else if(op=='__ne__'){return _b_.True}
if(x.__class__===$B.$factory){x=x.__class__}
if(y.__class__===$B.$factory){y=y.__class__}
throw _b_.TypeError("'"+method2comp[op]+"' not supported between " +
"instances of '" + $B.get_class(x).__name__+ "' and '" +
$B.get_class(y).__name__+"'")}
$B.is_none=function(o){return o===undefined ||o===null ||o==_b_.None;}
$B.imports=function(){
var w=_window.open('','','width="50%",height=400,resizeable,scrollbars');
w.document.write("Currently imported modules. Copy and paste in file "+
"<b>.bundle-include</b> in your application folder, then run "+
"<code>python -m brython --modules</code> to generate a new version "+
"of <b>brython_modules.js</b><p>")
w.document.write("<TEXTAREA rows=20 cols=40>")
for(var attr in $B.imported){w.document.write(attr+'\n')}
w.document.write("</TEXTAREA>")
w.document.close();}
$B.compiled_imports=function(){
if(!$B.use_VFS){console.log('only works with VFS')
return}
var res={}
for(var attr in $B.imported){var info=$B.VFS[attr]
if(info!==undefined){var lang=info[0],src=info[1]
if(lang=='.js'){res[attr]=['.js',src]}else{res[attr]=['.js',$B.py2js(src,attr,attr,'__builtins__').to_js()]
if(info[2]!==undefined){res[attr].push(info[2])}}}}
var _code="__BRYTHON__.use_VFS = true;\n__BRYTHON__.VFS = "+JSON.stringify(res)
if(isWebWorker){console.log(_code);}else{
var w=_window.open('','','width="80%",height=400,resizeable,scrollbars')
w.document.write("Currently imported modules. Copy and paste in file "+
"<b>brython_modules.js</b> in your application folder<p>"+
"<TEXTAREA rows=20 cols=40>"+_code+"</TEXTAREA>");
w.document.close();}}})(__BRYTHON__)
if(!Array.indexOf){Array.prototype.indexOf=function(obj){for(var i=0,_len_i=this.length;i < _len_i;i++)if(this[i]==obj)return i
return -1}}
if(!String.prototype.repeat){String.prototype.repeat=function(count){if(count < 1)return '';
var result='',pattern=this.valueOf()
while(count > 1){if(count & 1)result +=pattern
count >>=1,pattern +=pattern}
return result + pattern;}}
;(function($B){eval($B.InjectBuiltins())
_b_.__debug__=false
var $ObjectDict=_b_.object.$dict,odga=$ObjectDict.__getattribute__
$B.$comps={'>':'gt','>=':'ge','<':'lt','<=':'le'}
$B.$inv_comps={'>': 'lt','>=': 'le','<': 'gt','<=': 'ge'}
function check_nb_args(name,expected,got){
if(got !=expected){if(expected==0){throw _b_.TypeError(name+"() takes no argument" +
" ("+got+" given)")}else{throw _b_.TypeError(name+"() takes exactly "+expected+" argument" +
(expected<2 ? '' : 's')+" ("+got+" given)")}}}
function check_no_kw(name,x,y){
if(x.$nat ||(y!==undefined && y.$nat)){throw _b_.TypeError(name+"() takes no keyword arguments")}}
function check_not_kw(arg){
if(arg.$nat){throw _b_.TypeError("'"+Object.keys(arg.kw)[0]+
"' is an invalid keyword argument for this function")}}
var $NoneDict={__class__:$B.$type,__name__:'NoneType'}
$NoneDict.__mro__=[$ObjectDict]
$NoneDict.__setattr__=function(self,attr){return no_set_attr($NoneDict,attr)}
var None={__bool__ : function(){return False},__class__ : $NoneDict,__hash__ : function(){return 0},__repr__ : function(){return 'None'},__str__ : function(){return 'None'},toString : function(){return 'None'}}
$NoneDict.$factory=function(){return None}
$NoneDict.$factory.__class__=$B.$factory
$NoneDict.$factory.$dict=$NoneDict
for(var $op in $B.$comps){
var key=$B.$comps[$op]
switch(key){case 'ge':
case 'gt':
case 'le':
case 'lt':
$NoneDict['__'+key+'__']=(function(op){return function(other){throw _b_.TypeError("unorderable types: NoneType() "+op+" "+
$B.get_class(other).__name__+"()")}})($op)}}
for(var $func in None){if(typeof None[$func]==='function'){None[$func].__str__=(function(f){return function(){return "<method-wrapper "+f+" of NoneType object>"}})($func)}}
function abs(obj){check_nb_args('abs',1,arguments.length)
check_no_kw('abs',obj)
if(isinstance(obj,_b_.int))return _b_.int(Math.abs(obj));
if(isinstance(obj,_b_.float))return _b_.float(Math.abs(obj));
if(hasattr(obj,'__abs__')){return getattr(obj,'__abs__')()};
throw _b_.TypeError("Bad operand type for abs(): '"+$B.get_class(obj)+"'")}
function all(obj){check_nb_args('all',1,arguments.length)
check_no_kw('all',obj)
var iterable=iter(obj)
while(1){try{var elt=next(iterable)
if(!bool(elt))return false}catch(err){return true}}}
function any(obj){check_nb_args('any',1,arguments.length)
check_no_kw('any',obj)
var iterable=iter(obj)
while(1){try{var elt=next(iterable)
if(bool(elt))return true}catch(err){return false}}}
function ascii(obj){check_nb_args('ascii',1,arguments.length)
check_no_kw('ascii',obj)
var res=repr(obj),res1='',cp
for(var i=0;i<res.length;i++){cp=res.charCodeAt(i)
if(cp<128){res1 +=res.charAt(i)}
else if(cp<256){res1 +='\\x'+cp.toString(16)}
else{res1 +='\\u'+cp.toString(16)}}
return res1}
function $builtin_base_convert_helper(obj,base){var prefix="";
switch(base){case 2:
prefix='0b';break;
case 8:
prefix='0o';break;
case 16:
prefix='0x';break;
default:
console.log('invalid base:' + base)}
if(obj.__class__===$B.LongInt.$dict){if(obj.pos)return prefix + $B.LongInt.$dict.to_base(obj,base)
return '-' + prefix + $B.LongInt.$dict.to_base(-obj,base)}
var value=$B.$GetInt(obj)
if(value===undefined){
throw _b_.TypeError('Error, argument must be an integer or contains an __index__ function')}
if(value >=0)return prefix + value.toString(base);
return '-' + prefix +(-value).toString(base);}
function bin(obj){check_nb_args('bin',1,arguments.length)
check_no_kw('bin',obj)
if(isinstance(obj,_b_.int)){return $builtin_base_convert_helper(obj,2)}
return getattr(obj,'__index__')()}
$B.$bool=function(obj){
if(obj===null ||obj===undefined )return false
switch(typeof obj){case 'boolean':
return obj
case 'number':
case 'string':
if(obj)return true
return false
default:
try{return getattr(obj,'__bool__')()}
catch(err){try{return getattr(obj,'__len__')()>0}
catch(err){return true}}}}
function bool(){
var $=$B.args('bool',1,{x:null},['x'],arguments,{x:false},null,null)
return $B.$bool($.x)}
function callable(obj){check_nb_args('callable',1,arguments.length)
check_no_kw('callable',obj)
return hasattr(obj,'__call__')}
function chr(i){check_nb_args('chr',1,arguments.length)
check_no_kw('chr',i)
if(i < 0 ||i > 1114111)_b_.ValueError('Outside valid range')
return String.fromCharCode(i)}
function classmethod(func){check_nb_args('classmethod',1,arguments.length)
check_no_kw('classmethod',func)
func.$type='classmethod'
return func}
classmethod.__class__=$B.$factory
classmethod.$dict={__class__:$B.$type,__name__:'classmethod',$factory: classmethod}
classmethod.$dict.__mro__=[$ObjectDict]
$B.$CodeObjectDict={__class__:$B.$type,__name__:'code',__repr__:function(self){return '<code object '+self.name+', file '+self.filename+'>'},}
$B.$CodeObjectDict.__str__=$B.$CodeObjectDict.__repr__
$B.$CodeObjectDict.__mro__=[$ObjectDict]
function compile(source,filename,mode){var $=$B.args('compile',6,{source:null,filename:null,mode:null,flags:null,dont_inherit:null,optimize:null},['source','filename','mode','flags','dont_inherit','optimize'],arguments,{flags:0,dont_inherit:false,optimize:-1},null,null)
var module_name='$exec_' + $B.UUID()
$B.clear_ns(module_name)
$.__class__=$B.$CodeObjectDict
$.co_flags=$.flags
return $}
compile.__class__=$B.factory
$B.$CodeObjectDict.$factory=compile
compile.$dict=$B.$CodeObjectDict
var __debug__=$B.debug>0
function delattr(obj,attr){
check_no_kw('delattr',obj,attr)
check_nb_args('delattr',2,arguments.length)
if(typeof attr !='string'){throw _b_.TypeError("attribute name must be string, not '"+
$B.get_class(attr).__name__+"'")}
var klass=$B.get_class(obj)
var res=obj[attr]
if(res===undefined){res=klass[attr]
if(res===undefined){var mro=klass.__mro__
for(var i=0;i<mro.length;i++){var res=mro[i][attr]
if(res!==undefined){break}}}}
if(res!==undefined && res.__delete__!==undefined){res.__delete__(res,obj,attr)}else{getattr(obj,'__delattr__')(attr)}
return None}
function dir(obj){if(obj===undefined){
var frame=$B.last($B.frames_stack),globals_obj=frame[3],res=_b_.list(),pos=0
for(var attr in globals_obj){if(attr.charAt(0)=='$' && attr.charAt(1)!='$'){
continue}
res[pos++]=attr}
_b_.list.$dict.sort(res)
return res}
check_nb_args('dir',1,arguments.length)
check_no_kw('dir',obj)
var klass=obj.__class__ ||$B.get_class(obj)
if(klass && klass.is_class){obj=obj.$dict}
else{
try{
var res=getattr(obj,'__dir__')()
res=_b_.list(res)
res.sort()
return res}catch(err){}}
var res=[],pos=0
for(var attr in obj){if(attr.charAt(0)!=='$' && attr!=='__class__'){res[pos++]=attr}}
res.sort()
return res}
function divmod(x,y){check_no_kw('divmod',x,y)
check_nb_args('divmod',2,arguments.length)
var klass=x.__class__ ||$B.get_class(x)
return _b_.tuple([getattr(klass,'__floordiv__')(x,y),getattr(klass,'__mod__')(x,y)])}
var $EnumerateDict={__class__:$B.$type,__name__:'enumerate'}
$EnumerateDict.__mro__=[$ObjectDict]
function enumerate(){var $ns=$B.args("enumerate",2,{iterable:null,start:null},['iterable','start'],arguments,{start:0},null,null)
var _iter=iter($ns["iterable"])
var _start=$ns["start"]
var res={__class__:$EnumerateDict,__getattr__:function(attr){return res[attr]},__iter__:function(){return res},__name__:'enumerate iterator',__next__:function(){res.counter++
return _b_.tuple([res.counter,next(_iter)])},__repr__:function(){return "<enumerate object>"},__str__:function(){return "<enumerate object>"},counter:_start-1}
for(var attr in res){if(typeof res[attr]==='function' && attr!=="__class__"){res[attr].__str__=(function(x){return function(){return "<method wrapper '"+x+"' of enumerate object>"}})(attr)}}
return res}
enumerate.__class__=$B.$factory
enumerate.$dict=$EnumerateDict
$EnumerateDict.$factory=enumerate
function $eval(src,_globals,_locals){function from_alias(attr){if(attr.substr(0,2)=='$$' && $B.aliased_names[attr.substr(2)]){return attr.substr(2)}
return attr}
function to_alias(attr){if($B.aliased_names[attr]){return '$$'+attr}
return attr}
var current_frame=$B.frames_stack[$B.frames_stack.length-1]
if(current_frame!==undefined){var current_locals_id=current_frame[0].replace(/\./,'_'),current_globals_id=current_frame[2].replace(/\./,'_')}
var stack_len=$B.frames_stack.length
var is_exec=arguments[3]=='exec',leave=false
if(src.__class__===$B.$CodeObjectDict){src=src.source}else if(typeof src !=='string'){throw _b_.TypeError("eval() arg 1 must be a string, bytes "+
"or code object")}
var globals_id='$exec_'+$B.UUID(),locals_id,parent_block_id
if(_globals !==undefined){if(_globals.__class__!=_b_.dict.$dict){throw _b_.TypeError("exec() globals must be a dict, not "+
_globals.__class__.__name__)}
_globals.globals_id=_globals.globals_id ||globals_id
globals_id=_globals.globals_id}
$B.$py_module_path[globals_id]=$B.$py_module_path[current_globals_id]
if(_globals===undefined){if(current_locals_id==current_globals_id){locals_id=globals_id}else{locals_id='$exec_' + $B.UUID()}}else{if(_locals===_globals ||_locals===undefined){locals_id=globals_id}else{locals_id='$exec_' + $B.UUID()}}
eval('var $locals_'+globals_id+' = {}\nvar $locals_'+locals_id+' = {}')
if(_globals===undefined){var gobj=current_frame[3],ex=''
parent_block_id=current_globals_id
ex +='var $locals_'+current_globals_id+'=gobj;'
ex +='var $locals_'+globals_id+'=gobj;'
eval(ex)
$B.bound[globals_id]=$B.bound[globals_id]||{}
for(var attr in gobj){$B.bound[globals_id][attr]=true}}else{$B.bound[globals_id]={}
var items=_globals.$string_dict
for(var item in items){item1=to_alias(item)
try{eval('$locals_'+globals_id+'["'+item1+'"] = items[item]')
$B.bound[globals_id][item]=true}catch(err){console.log(err)
console.log('error setting',item)
break}}
parent_block_id='__builtins__'}
$B.bound[locals_id]=$B.bound[locals_id]||{}
if(_locals===undefined){if(_globals!==undefined){eval('var $locals_'+locals_id+' = $locals_'+globals_id)}else{var lobj=current_frame[1],ex=''
for(var attr in current_frame[1]){ex +='$locals_'+locals_id+'["'+attr+
'"] = current_frame[1]["'+attr+'"];'
$B.bound[locals_id][attr]=true}
eval(ex)}}else{var items=_b_.dict.$dict.items(_locals),item
while(1){try{var item=next(items)
item1=to_alias(item)
eval('$locals_'+locals_id+'["'+item[0]+'"] = item[1]')
$B.bound[locals_id][item]=true}catch(err){break}}}
var root=$B.py2js(src,globals_id,locals_id,parent_block_id),js,gns,lns
try{
var try_node=root.children[root.children.length-2],instr=try_node.children[try_node.children.length-2]
var type=instr.C.tree[0].type
switch(type){case 'expr':
case 'list_or_tuple':
case 'op':
case 'ternary':
var children=try_node.children
root.children.splice(root.children.length-2,2)
for(var i=0;i<children.length-1;i++){root.add(children[i])}
break
default:
if(!is_exec){throw _b_.SyntaxError("eval() argument must be an expression",'<string>',1,1,src)}}
js=root.to_js()
var res=eval(js)
gns=eval('$locals_'+globals_id)
if($B.frames_stack[$B.frames_stack.length-1][2]==globals_id){gns=$B.frames_stack[$B.frames_stack.length-1][3]}
if(_locals!==undefined){lns=eval('$locals_'+locals_id)
var setitem=getattr(_locals,'__setitem__')
for(var attr in lns){attr1=from_alias(attr)
if(attr1.charAt(0)!='$'){setitem(attr1,lns[attr])}}}else{for(var attr in lns){current_frame[1][attr]=lns[attr]}}
if(_globals!==undefined){
var setitem=getattr(_globals,'__setitem__')
for(var attr in gns){attr1=from_alias(attr)
if(attr1.charAt(0)!='$'){setitem(attr1,gns[attr])}}}else{for(var attr in gns){current_frame[3][attr]=gns[attr]}}
if(res===undefined)return _b_.None
return res}catch(err){if(err.$py_error===undefined){throw $B.exception(err)}
throw err}finally{
if($B.frames_stack.length==stack_len+1){$B.frames_stack.pop()}
root=null
js=null
gns=null
lns=null
$B.clear_ns(globals_id)
$B.clear_ns(locals_id)}}
$eval.$is_func=true
function exec(src,globals,locals){return $eval(src,globals,locals,'exec')||_b_.None}
exec.$is_func=true
var $FilterDict={__class__:$B.$type,__name__:'filter'}
$FilterDict.__iter__=function(self){return self}
$FilterDict.__repr__=$FilterDict.__str__=function(){return "<filter object>"},$FilterDict.__mro__=[$ObjectDict]
function filter(func,iterable){check_no_kw('filter',func,iterable)
check_nb_args('filter',2,arguments.length)
iterable=iter(iterable)
if(func===_b_.None)func=bool
var __next__=function(){while(true){var _item=next(iterable)
if(func(_item)){return _item}}}
return{
__class__: $FilterDict,__next__: __next__}}
function format(value,format_spec){var args=$B.args("format",2,{value:null,format_spec:null},["value","format_spec"],arguments,{format_spec:''},null,null)
var fmt=getattr(args.value,'__format__',null)
if(fmt !==null){return fmt(args.format_spec)}
throw _b_.NotImplementedError("__format__ is not implemented for object '" + _b_.str(args.value)+ "'")}
function attr_error(attr,cname){var msg="bad operand type for unary #: '"+cname+"'"
switch(attr){case '__neg__':
throw _b_.TypeError(msg.replace('#','-'))
case '__pos__':
throw _b_.TypeError(msg.replace('#','+'))
case '__invert__':
throw _b_.TypeError(msg.replace('#','~'))
case '__call__':
throw _b_.TypeError("'"+cname+"'"+' object is not callable')
default:
while(attr.charAt(0)=='$'){attr=attr.substr(1)}
throw _b_.AttributeError("'"+cname+"' object has no attribute '"+attr+"'")}}
$B.show_getattr=function(){var items=[]
for(var attr in $B.counter){items.push([$B.counter[attr],attr])}
items.sort(function(x,y){return x[0]>y[0]? 1 : x[0]==y[0]? 0 : -1})
items.reverse()
for(var i=0;i<10;i++){console.log(items[i])}}
function getattr(obj,attr,_default){var len=arguments.length
if(len<2){throw _b_.TypeError("getattr expected at least 2 arguments, "
+ "got "+len)}
else if(len>3){throw _b_.TypeError("getattr expected at most 3 arguments, got "
+len)}
var rawname=attr
if($B.aliased_names[attr]){attr='$$'+attr}
var klass=obj.__class__
if(klass===undefined){
if(typeof obj=='string'){klass=_b_.str.$dict}
else if(typeof obj=='number'){klass=obj % 1==0 ? _b_.int.$dict : _b_.float.$dict}else if(obj instanceof Number){klass=_b_.float.$dict}else{klass=$B.get_class(obj)}}
if(klass===undefined){
if(obj.hasOwnProperty(attr)){if(typeof obj[attr]=="function"){return function(){
return obj[attr].apply(obj,arguments)}}else{return $B.$JS2Py(obj[attr])}}
if(_default!==undefined)return _default
throw _b_.AttributeError('object has no attribute '+rawname)}
switch(attr){case '__call__':
if(typeof obj=='function'){return obj}else if(klass===$B.JSObject.$dict && typeof obj.js=='function'){return function(){
var args=[]
for(var i=0;i<arguments.length;i++){args.push($B.pyobj2jsobj(arguments[i]))}
var res=obj.js.apply(null,args)
if(res===undefined){return None}
return $B.JSObject(res)}}
break
case '__class__':
return klass.$factory
case '__dict__':
if(klass.is_class && klass.__dict__){return klass.__dict__}
return $B.obj_dict(obj)
case '__doc__':
for(var i=0;i<builtin_names.length;i++){if(obj===_b_[builtin_names[i]]){_get_builtins_doc()
return $B.builtins_doc[builtin_names[i]]}}
break
case '__mro__':
if(klass===$B.$factory){
var res=[obj],pos=0,mro=obj.$dict.__mro__
for(var i=0;i<mro.length;i++){res.push(mro[i].$factory)}
return _b_.tuple(res)}
break
case '__subclasses__':
if(klass===$B.$factory){var subclasses=obj.$dict.$subclasses ||[]
return function(){return subclasses}}
break
case '$$new':
if(klass===$B.JSObject.$dict && obj.js_func !==undefined){return $B.JSConstructor(obj)}
break}
if(typeof obj=='function'){var value=obj.__class__===$B.$factory ? obj.$dict[attr]: obj[attr]
if(value !==undefined){if(attr=='__module__'){return value}}}
if(klass.$native){if(klass[attr]===undefined){var object_attr=_b_.object.$dict[attr]
if(object_attr!==undefined){klass[attr]=object_attr}
else{if(_default===undefined){attr_error(attr,klass.__name__)}
return _default}}
if(klass.$descriptors && klass.$descriptors[attr]!==undefined){return klass[attr](obj)}
if(typeof klass[attr]=='function'){
if(attr=='__new__')return klass[attr].apply(null,arguments)
if(klass[attr].$type=='classmethod'){var res=function(){var args=[klass.$factory]
for(var i=0;i<arguments.length;i++){args.push(arguments[i])}
return klass[attr].apply(null,args)}
res.$type='classmethod'
res.$infos=klass[attr].$infos
return res}
var method=function(){var args=[obj],pos=1
for(var i=0;i<arguments.length;i++){args[pos++]=arguments[i]}
return klass[attr].apply(null,args)}
method.__class__=$B.$MethodDict
method.$infos={__class__: klass.$factory,__func__ : klass[attr],__name__ : attr,__self__ : obj}
method.__str__=method.__repr__=function(){return '<built-in method '+attr+' of '+klass.__name__+' object>'}
return method}
return klass[attr]}
var is_class=klass.is_class,mro,attr_func
if(is_class){attr_func=$B.$type.__getattribute__
if(obj.$dict===undefined){console.log('obj '+obj+' $dict undefined')}
obj=obj.$dict}else{attr_func=klass.__getattribute__
if(attr_func===undefined){var mro=klass.__mro__
for(var i=0,len=mro.length;i<len;i++){attr_func=mro[i]['__getattribute__']
if(attr_func!==undefined){break}}}}
if(typeof attr_func!=='function'){console.log(attr+' is not a function '+attr_func)}
if(attr_func===odga){var res=obj[attr]
if(res===null){return null}
else if(res===undefined && obj.hasOwnProperty(attr)){return res}else if(res!==undefined && res.__set__===undefined){return obj[attr]}}
try{var res=attr_func(obj,attr)}
catch(err){if(_default!==undefined)return _default
throw err}
if(res!==undefined){return res}
if(_default !==undefined){return _default}
var cname=klass.__name__
if(is_class){cname=obj.__name__}
attr_error(rawname,cname)}
function globals(){
check_nb_args('globals',0,arguments.length)
return $B.obj_dict($B.last($B.frames_stack)[3])}
function hasattr(obj,attr){check_no_kw('hasattr',obj,attr)
check_nb_args('hasattr',2,arguments.length)
var ce=$B.current_exception
try{getattr(obj,attr);return true}
catch(err){$B.current_exception=ce;return false}}
function hash(obj){check_no_kw('hash',obj)
check_nb_args('hash',1,arguments.length)
if(obj.__hashvalue__ !==undefined)return obj.__hashvalue__
if(isinstance(obj,_b_.int))return obj.valueOf()
if(isinstance(obj,bool))return _b_.int(obj)
if(obj.__hash__ !==undefined){return obj.__hashvalue__=obj.__hash__()}
if(obj.__class__===$B.$factory){return obj.__hashvalue__=$B.$py_next_hash--}
var hashfunc=getattr(obj,'__hash__',_b_.None)
if(hashfunc==_b_.None){
throw _b_.TypeError("unhashable type: '"+
$B.get_class(obj).__name__+"'",'hash')}
if(hashfunc.$infos===undefined){return obj.__hashvalue__=hashfunc()}
if(hashfunc.$infos.__func__===_b_.object.$dict.__hash__){if(getattr(obj,'__eq__').$infos.__func__!==_b_.object.$dict.__eq__){throw _b_.TypeError("unhashable type: '"+
$B.get_class(obj).__name__+"'",'hash')}else{return _b_.object.$dict.__hash__(obj)}}else{return obj.__hashvalue__=hashfunc()}}
function _get_builtins_doc(){if($B.builtins_doc===undefined){
var url=$B.brython_path
if(url.charAt(url.length-1)=='/'){url=url.substr(0,url.length-1)}
url +='/builtins_docstrings.js'
var f=_b_.open(url)
eval(f.$content)
$B.builtins_doc=docs}}
function help(obj){if(obj===undefined)obj='help'
if(typeof obj=='string' && _b_[obj]!==undefined){_get_builtins_doc()
var _doc=$B.builtins_doc[obj]
if(_doc !==undefined && _doc !=''){_b_.print(_doc)
return}}
for(var i=0;i<builtin_names.length;i++){if(obj===_b_[builtin_names[i]]){_get_builtins_doc()
_b_.print(_doc=$B.builtins_doc[builtin_names[i]])}}
if(typeof obj=='string'){$B.$import("pydoc");
var pydoc=$B.imported["pydoc"]
getattr(getattr(pydoc,"help"),"__call__")(obj)
return}
try{return getattr(obj,'__doc__')}
catch(err){console.log('help err '+err);return ''}}
function hex(x){check_no_kw('hex',x)
check_nb_args('hex',1,arguments.length)
return $builtin_base_convert_helper(x,16)}
function id(obj){check_no_kw('id',obj)
check_nb_args('id',1,arguments.length)
if(isinstance(obj,[_b_.str,_b_.int,_b_.float])){return getattr(_b_.str(obj),'__hash__')()}else if(obj.$id!==undefined){return obj.$id}
else{return obj.$id=$B.UUID()}}
function __import__(mod_name,globals,locals,fromlist,level){
var $=$B.args('__import__',5,{name:null,globals:null,locals:null,fromlist:null,level:null},['name','globals','locals','fromlist','level'],arguments,{globals:None,locals:None,fromlist:_b_.tuple(),level:0},null,null)
return $B.$__import__($.name,$.globals,$.locals,$.fromlist);}
function input(src){var stdin=($B.imported.sys && $B.imported.sys.stdin ||$B.stdin);
if(stdin.__original__){return prompt(src ||'')||'' }
var val=_b_.getattr(stdin,'readline')();
val=val.split('\n')[0];
if(stdin.len===stdin.pos){_b_.getattr(stdin,'close')();}
return val;}
function isinstance(obj,arg){check_no_kw('isinstance',obj,arg)
check_nb_args('isinstance',2,arguments.length)
if(obj===null)return arg===None
if(obj===undefined)return false
if(arg.constructor===Array){for(var i=0;i<arg.length;i++){if(isinstance(obj,arg[i]))return true}
return false}
if(arg===_b_.int &&(obj===True ||obj===False)){return True}
var klass=obj.__class__
if(klass==undefined){if(typeof obj=='string' && arg==_b_.str){return true}
if(obj.contructor==Number && arg==_b_.float){return true}
if(typeof obj=='number' && arg==_b_.int){return true}
klass=$B.get_class(obj)}
if(klass===undefined){return false }
if(arg.$dict===undefined){return false}
if(klass==$B.$factory){klass=obj.$dict.__class__}
function check(kl,arg){if(kl===arg.$dict){return true}
else if(arg===_b_.str &&
kl===$B.$StringSubclassFactory.$dict){return true}
else if(arg===_b_.float &&
kl===$B.$FloatSubclassFactory.$dict){return true}
else if(arg===_b_.list &&
kl===$B.$ListSubclassFactory.$dict){return true}}
if(check(klass,arg)){return true}
var mro=klass.__mro__
for(var i=0;i<mro.length;i++){if(check(mro[i],arg)){return true}}
var hook=getattr(arg,'__instancecheck__',null)
if(hook!==null){return hook(obj)}
return false}
function issubclass(klass,classinfo){check_no_kw('issubclass',klass,classinfo)
check_nb_args('issubclass',2,arguments.length)
if(!klass.__class__ ||klass.__class__!==$B.$factory){throw _b_.TypeError("issubclass() arg 1 must be a class")}
if(isinstance(classinfo,_b_.tuple)){for(var i=0;i<classinfo.length;i++){if(issubclass(klass,classinfo[i]))return true}
return false}
if(classinfo.__class__.is_class){if(klass.$dict===classinfo.$dict ||
klass.$dict.__mro__.indexOf(classinfo.$dict)>-1){return true}}
var hook=getattr(classinfo,'__subclasscheck__',null)
if(hook!==null){return hook(klass)}
return false}
var iterator_class=$B.make_class({name:'iterator',init:function(self,getitem,len){self.getitem=getitem
self.len=len
self.counter=-1}})
iterator_class.$dict.__next__=function(self){self.counter++
if(self.len!==null && self.counter==self.len){throw _b_.StopIteration('')}
try{return self.getitem(self.counter)}
catch(err){throw _b_.StopIteration('')}}
$B.$iter=function(obj){
try{var _iter=getattr(obj,'__iter__')}
catch(err){var gi=getattr(obj,'__getitem__',null),ln=getattr(obj,'__len__',null)
if(gi!==null){if(ln!==null){var len=getattr(ln,'__call__')()
return iterator_class(gi,len)}else{return iterator_class(gi,null)}}
throw _b_.TypeError("'"+$B.get_class(obj).__name__+"' object is not iterable")}
var res=_iter()
try{getattr(res,'__next__')}
catch(err){if(isinstance(err,_b_.AttributeError)){throw _b_.TypeError(
"iter() returned non-iterator of type '"+
$B.get_class(res).__name__+"'")}}
return res}
function iter(){
var $=$B.args('iter',1,{obj: null},['obj'],arguments,null,'kw')
return $B.$iter($.obj)}
function len(obj){check_no_kw('len',obj)
check_nb_args('len',1,arguments.length)
try{return getattr(obj,'__len__')()}
catch(err){throw _b_.TypeError("object of type '"+$B.get_class(obj).__name__+
"' has no len()")}}
function locals(){
check_nb_args('locals',0,arguments.length)
var locals_obj=$B.last($B.frames_stack)[1]
return $B.obj_dict(locals_obj)}
var $MapDict={__class__:$B.$type,__name__:'map'}
$MapDict.__mro__=[$ObjectDict]
$MapDict.__iter__=function(self){return self}
function map(){var $=$B.args('map',2,{func: null,it1:null},['func','it1'],arguments,{},'args',null),func=getattr($.func,'__call__')
var iter_args=[$B.$iter($.it1)],pos=0
for(var i=0;i<$.args.length;i++){iter_args[pos++]=$B.$iter($.args[i])}
var __next__=function(){var args=[],pos=0
for(var i=0;i<iter_args.length;i++){args[pos++]=next(iter_args[i])}
return func.apply(null,args)}
var obj={__class__:$MapDict,__repr__:function(){return "<map object>"},__str__:function(){return "<map object>"},__next__: __next__}
return obj}
function $extreme(args,op){
var $op_name='min'
if(op==='__gt__')$op_name="max"
if(args.length==0){throw _b_.TypeError($op_name+" expected 1 arguments, got 0")}
var last_arg=args[args.length-1],nb_args=args.length,has_default=false,func=false
if(last_arg.$nat=='kw'){nb_args--
last_arg=last_arg.kw
for(var attr in last_arg){switch(attr){case 'key':
func=last_arg[attr]
break
case '$$default':
var default_value=last_arg[attr]
has_default=true
break
default:
throw _b_.TypeError("'"+attr+"' is an invalid keyword argument for this function")}}}
if(!func){func=function(x){return x}}
if(nb_args==0){throw _b_.TypeError($op_name+" expected 1 argument, got 0")}else if(nb_args==1){
var $iter=iter(args[0]),res=null
while(true){try{var x=next($iter)
if(res===null ||bool(getattr(func(x),op)(func(res)))){res=x}}catch(err){if(err.__name__=="StopIteration"){if(res===null){if(has_default){return default_value}
else{throw _b_.ValueError($op_name+"() arg is an empty sequence")}}else{return res}}
throw err}}}else{if(has_default){throw _b_.TypeError("Cannot specify a default for "+$op_name+"() with multiple positional arguments")}
var res=null
for(var i=0;i<nb_args;i++){var x=args[i]
if(res===null ||bool(getattr(func(x),op)(func(res)))){res=x}}
return res}}
function max(){var args=[],pos=0
for(var i=0;i<arguments.length;i++){args[pos++]=arguments[i]}
return $extreme(args,'__gt__')}
var memoryview=$B.make_class({name:'memoryview',init:function(self,obj){check_no_kw('memoryview',obj)
check_nb_args('memoryview',2,arguments.length)
if($B.get_class(obj).$buffer_protocol){self.obj=obj
self.format='B'
self.itemsize=1
self.ndim=1
self.shape=_b_.tuple([self.obj.source.length])
self.strides=_b_.tuple([1])
self.suboffsets=_b_.tuple([])
self.c_contiguous=true
self.f_contiguous=true
self.contiguous=true}else{throw _b_.TypeError("memoryview: a bytes-like object "+
"is required, not '"+$B.get_class(obj).__name__+"'")}}})
memoryview.$dict.__eq__=function(self,other){if(other.__class__!==memoryview.$dict){return false}
return getattr(self.obj,'__eq__')(other.obj)}
memoryview.$dict.__name__="memory"
memoryview.$dict.__getitem__=function(self,key){var res=self.obj.__class__.__getitem__(self.obj,key)
if(key.__class__===_b_.slice.$dict){return memoryview(res)}
return res}
memoryview.$dict.hex=function(self){var res='',bytes=_b_.bytes(self)
for(var i=0,len=bytes.source.length;i<len;i++){res +=bytes.source[i].toString(16)}
return res}
memoryview.$dict.tobytes=function(self){return _b_.bytes(self.obj)}
memoryview.$dict.tolist=function(self){return _b_.list(_b_.bytes(self.obj))}
function min(){var args=[],pos=0
for(var i=0;i<arguments.length;i++){args[pos++]=arguments[i]}
return $extreme(args,'__lt__')}
function next(obj){check_no_kw('next',obj)
check_nb_args('next',1,arguments.length)
var ga=getattr(obj,'__next__')
if(ga!==undefined)return ga()
throw _b_.TypeError("'"+$B.get_class(obj).__name__+
"' object is not an iterator")}
var $NotImplemented=$B.make_class({__name__:"NotImplementedClass"}),NotImplemented=$NotImplemented()
function $not(obj){return !bool(obj)}
function oct(x){return $builtin_base_convert_helper(x,8)}
function ord(c){check_no_kw('ord',c)
check_nb_args('ord',1,arguments.length)
if(typeof c=='string'){if(c.length==1)return c.charCodeAt(0)
throw _b_.TypeError('ord() expected a character, but string of length ' +
c.length + ' found')}
switch($B.get_class(c)){case _b_.str.$dict:
if(c.length==1)return c.charCodeAt(0)
throw _b_.TypeError('ord() expected a character, but string of length ' +
c.length + ' found')
case _b_.bytes.$dict:
case _b_.bytearray.$dict:
if(c.source.length==1)return c.source[0]
throw _b_.TypeError('ord() expected a character, but string of length ' +
c.source.length + ' found')
default:
throw _b_.TypeError('ord() expected a character, but ' +
$B.get_class(c).__name__ + ' was found')}}
function pow(){var $ns=$B.args('pow',3,{x:null,y:null,z:null},['x','y','z'],arguments,{z:null},null,null)
var x=$ns['x'],y=$ns['y'],z=$ns['z']
var res=getattr(x,'__pow__')(y,z)
if(z===null){return res}
else{if(x!=_b_.int(x)||y !=_b_.int(y)){throw _b_.TypeError("pow() 3rd argument not allowed unless "+
"all arguments are integers")}
return getattr(res,'__mod__')(z)}}
function $print(){var $ns=$B.args('print',0,{},[],arguments,{},'args','kw')
var ks=$ns['kw'].$string_dict
var end=(ks['end']===undefined ||ks['end']===None)? '\n' : ks['end'],sep=(ks['sep']===undefined ||ks['sep']===None)? ' ' : ks['sep'],file=ks['file']===undefined ? $B.stdout : ks['file'],args=$ns['args']
getattr(file,'write')(args.map(_b_.str).join(sep)+end)
return None}
$print.__name__='print'
$print.is_func=true
var $PropertyDict={__class__ : $B.$type,__name__ : 'property',}
$PropertyDict.__mro__=[$ObjectDict]
$B.$PropertyDict=$PropertyDict
function property(fget,fset,fdel,doc){var p={__class__ : $PropertyDict,__doc__ : doc ||"",$type:fget.$type,fget:fget,fset:fset,fdel:fdel,toString:function(){return '<property>'}}
p.__get__=function(self,obj,objtype){if(obj===undefined)return self
if(self.fget===undefined)throw _b_.AttributeError("unreadable attribute")
return getattr(self.fget,'__call__')(obj)}
if(fset!==undefined){p.__set__=function(self,obj,value){if(self.fset===undefined)throw _b_.AttributeError("can't set attribute")
getattr(self.fset,'__call__')(obj,value)}}
p.__delete__=fdel;
p.getter=function(fget){return property(fget,p.fset,p.fdel,p.__doc__)}
p.setter=function(fset){return property(p.fget,fset,p.fdel,p.__doc__)}
p.deleter=function(fdel){return property(p.fget,p.fset,fdel,p.__doc__)}
return p}
property.__class__=$B.$factory
property.$dict=$PropertyDict
$PropertyDict.$factory=property
function repr(obj){check_no_kw('repr',obj)
check_nb_args('repr',1,arguments.length)
if(obj.__class__===$B.$factory){
var func=$B.$type.__getattribute__(obj.$dict.__class__,'__repr__')
return func(obj)}
var func=getattr(obj,'__repr__')
if(func!==undefined){return func()}
throw _b_.AttributeError("object has no attribute __repr__")}
var $ReversedDict={__class__:$B.$type,__name__:'reversed'}
$ReversedDict.__mro__=[$ObjectDict]
$ReversedDict.__iter__=function(self){return self}
$ReversedDict.__next__=function(self){self.$counter--
if(self.$counter<0)throw _b_.StopIteration('')
return self.getter(self.$counter)}
function reversed(seq){
check_no_kw('reversed',seq)
check_nb_args('reversed',1,arguments.length)
try{return getattr(seq,'__reversed__')()}
catch(err){if(err.__name__!='AttributeError'){throw err}}
try{var res={__class__:$ReversedDict,$counter : getattr(seq,'__len__')(),getter:getattr(seq,'__getitem__')}
return res}catch(err){throw _b_.TypeError("argument to reversed() must be a sequence")}}
reversed.__class__=$B.$factory
reversed.$dict=$ReversedDict
$ReversedDict.$factory=reversed
function round(arg,n){var $=$B.args('round',2,{number:null,ndigits:null},['number','ndigits'],arguments,{ndigits: None},null,null),arg=$.number,n=$.ndigits
if(!isinstance(arg,[_b_.int,_b_.float])){if(!hasattr(arg,'__round__'))
throw _b_.TypeError("type "+arg.__class__+" doesn't define __round__ method")
if(n===undefined)return getattr(arg,'__round__')()
else return getattr(arg,'__round__')(n)}
if(isinstance(arg,_b_.float)&&(arg.value===Infinity ||arg.value===-Infinity)){throw _b_.OverflowError("cannot convert float infinity to integer")}
if(n===None){var floor=Math.floor(arg)
var diff=Math.abs(arg-floor)
if(diff==0.5){if(floor % 2){return Math.round(arg)}else{return Math.floor(arg)}}else{return _b_.int(Math.round(arg))}}
if(!isinstance(n,_b_.int)){throw _b_.TypeError(
"'"+n.__class__+"' object cannot be interpreted as an integer")}
var mult=Math.pow(10,n)
if(isinstance(arg,_b_.float)){return _b_.float(_b_.int.$dict.__truediv__(Number(Math.round(arg.valueOf()*mult)),mult))}else{
return _b_.int(_b_.int.$dict.__truediv__(Number(Math.round(arg.valueOf()*mult)),mult))}}
function setattr(){var $=$B.args('setattr',3,{obj:null,attr:null,value:null},['obj','attr','value'],arguments,{},null,null),obj=$.obj,attr=$.attr,value=$.value
if(!(typeof attr=='string')){throw _b_.TypeError("setattr(): attribute name must be string")}
return $B.$setattr(obj,attr,value)}
$B.$setattr=function(obj,attr,value){if($B.aliased_names[attr]){attr='$$' + attr}else if(attr.substr(0,2)=='$$' && $B.aliased_names[attr.substr(2)]){attr=attr.substr(2)}
else if(attr=='__class__'){
obj.__class__=value.$dict;
return None}else if(attr=='__dict__'){
if(!value.__class__===_b_.dict.$dict){throw _b_.TypeError("__dict__ must be set to a dictionary, " +
"not a '"+value.__class__.$dict.__name+"'")}
for(var attr in obj){if(attr !=="__class__"){delete obj[attr]}}
for(var attr in value.$string_dict){obj[attr]=value.$string_dict[attr]}
return None}
if(obj.__class__===$B.$factory){
obj.$dict[attr]=value;return None}
var res=obj[attr],klass=obj.__class__ ||$B.get_class(obj)
if(res===undefined && klass){res=klass[attr]
if(res===undefined){var mro=klass.__mro__,_len=mro.length
for(var i=0;i<_len;i++){res=mro[i][attr]
if(res!==undefined)break}}}
if(res!==undefined){
if(res.__set__!==undefined){res.__set__(res,obj,value);return None}
var rcls=res.__class__,__set1__
if(rcls!==undefined){var __set1__=rcls.__set__
if(__set1__===undefined){var mro=rcls.__mro__
for(var i=0,_len=mro.length;i<_len;i++){__set1__=mro[i].__set__
if(__set1__){break}}}}
if(__set1__!==undefined){var __set__=getattr(res,'__set__',null)
if(__set__ &&(typeof __set__=='function')){__set__.apply(res,[obj,value])
return None}}else if(klass && klass.$descriptors !==undefined &&
klass[attr]!==undefined){var setter=klass[attr].setter
if(typeof setter=='function'){setter(obj,value)
return None}else{throw _b_.AttributeError('readonly attribute')}}}
if(klass && klass.$slots){
var has_slots=true,slots=klass.$slots,parent
for(var i=0;i<klass.__mro__.length - 1;i++){parent=klass.__mro__[i]
if(parent.$slots===undefined){has_slots=false;break}
for(var k in parent.$slots){slots[k]=true}}
if(has_slots && slots[attr]===undefined){throw _b_.AttributeError("'"+klass.__name__+
"' object has no attribute '"+attr+"'")}}
var _setattr=false
if(klass!==undefined){_setattr=klass.__setattr__
if(_setattr===undefined){var mro=klass.__mro__
for(var i=0,_len=mro.length;i<_len;i++){_setattr=mro[i].__setattr__
if(_setattr){break}}}}
if(!_setattr){obj[attr]=value}else{_setattr(obj,attr,value)}
return None}
function sorted(){var $=$B.args('sorted',1,{iterable:null},['iterable'],arguments,{},null,'kw')
var _list=_b_.list(iter($.iterable)),args=[_list]
for(var i=1;i<arguments.length;i++){args.push(arguments[i])}
_b_.list.$dict.sort.apply(null,args)
return _list}
var $StaticmethodDict={__class__:$B.$type,__name__:'staticmethod'}
$StaticmethodDict.__mro__=[$ObjectDict]
function staticmethod(func){func.$type='staticmethod'
return func}
staticmethod.__class__=$B.$factory
staticmethod.$dict=$StaticmethodDict
$StaticmethodDict.$factory=staticmethod
function sum(iterable,start){var $=$B.args('sum',2,{iterable:null,start:null},['iterable','start'],arguments,{start: 0},null,null),iterable=$.iterable,start=$.start
if(start===undefined){start=0}else{
if(typeof start==='str'){throw _b_.TypeError("TypeError: sum() can't sum strings [use ''.join(seq) instead]")}
if(_b_.isinstance(start,_b_.bytes)){throw _b_.TypeError("TypeError: sum() can't sum bytes [use b''.join(seq) instead]")}}
var res=start
var iterable=iter(iterable)
while(1){try{var _item=next(iterable)
res=getattr(res,'__add__')(_item)}catch(err){if(err.__name__==='StopIteration'){break}
else{throw err}}}
return res}
var $SuperDict={__class__:$B.$type,__name__:'super'}
$SuperDict.__getattribute__=function(self,attr){var mro=self.__thisclass__.$dict.__mro__,res
for(var i=0;i<mro.length;i++){
res=mro[i][attr]
if(res!==undefined){
if(res.__class__===$PropertyDict){return res.__get__(res,self.__self_class__)}
if(self.__self_class__!==None){if(mro[i]===_b_.object.$dict){var klass=self.__self_class__.__class__
if(klass!==$B.$type){if(klass.__mro__[0]===klass){console.log('anomalie',klass)}
var start=-1,mro2=[klass].concat(klass.__mro__)
for(var j=0;j<mro2.length;j++){if(mro2[j]===self.__thisclass__.$dict){start=j+1
break}}
if(start>-1){for(var j=start;j<mro2.length;j++){var res1=mro2[j][attr]
if(res1!==undefined){res=res1;break}}}}}
var _args=[self.__self_class__]
if(attr=='__new__'){_args=[]}
var method=(function(initial_args){return function(){
var local_args=initial_args.slice()
var pos=initial_args.length
for(var i=0;i<arguments.length;i++){local_args[pos++]=arguments[i]}
var x=res.apply(null,local_args)
if(x===undefined)return None
return x}})(_args)
method.__class__={__class__:$B.$type,__name__:'method',__mro__:[$ObjectDict]}
method.__func__=res
method.__self__=self
return method}
return res}}
if(attr=="__repr__" ||attr=="__str__"){return function(){return $SuperDict[attr](self)}}
throw _b_.AttributeError("object 'super' has no attribute '"+attr+"'")}
$SuperDict.__mro__=[$ObjectDict]
$SuperDict.__repr__=$SuperDict.__str__=function(self){var res="<super: <class '"+self.__thisclass__.$dict.__name__+"'"
if(self.__self_class__!==undefined){res +=', <'+self.__self_class__.__class__.__name__+' object>'}
return res+'>'}
function $$super(_type1,_type2){return{__class__:$SuperDict,__thisclass__:_type1,__self_class__:(_type2 ||None)}}
$$super.$dict=$SuperDict
$$super.__class__=$B.$factory
$SuperDict.$factory=$$super
$$super.$is_func=true
function vars(){var def={},$=$B.args('vars',1,{obj:null},['obj'],arguments,{obj: def},null,null)
if($.obj===def){return _b_.locals()}else{try{return getattr($.obj,'__dict__')}
catch(err){if(err.__class__===_b_.AttributeError.$dict){throw _b_.TypeError("vars() argument must have __dict__ attribute")}
throw err}}}
var $Reader={__class__:$B.$type,__name__:'reader'}
$Reader.__enter__=function(self){return self}
$Reader.__exit__=function(self){return false}
$Reader.__iter__=function(self){return iter(self.$lines)}
$Reader.__len__=function(self){return self.lines.length}
$Reader.__mro__=[$ObjectDict]
$Reader.close=function(self){self.closed=true}
$Reader.read=function(self,nb){if(self.closed===true)throw _b_.ValueError('I/O operation on closed file')
if(nb===undefined)return self.$content
self.$counter+=nb
if(self.$bin){var res=self.$content.source.slice(self.$counter-nb,self.$counter)
return _b_.bytes(res)}
return self.$content.substr(self.$counter-nb,nb)}
$Reader.readable=function(self){return true}
$Reader.readline=function(self,limit){
self.$lc=self.$lc===undefined ? -1 : self.$lc
if(self.closed===true)throw _b_.ValueError('I/O operation on closed file')
if(self.$lc==self.$lines.length-1){return self.$bin ? _b_.bytes(): ''}
self.$lc++
var res=self.$lines[self.$lc]
self.$counter +=(self.$bin ? res.source.length : res.length)
return res}
$Reader.readlines=function(self,hint){if(self.closed===true)throw _b_.ValueError('I/O operation on closed file')
self.$lc=self.$lc===undefined ? -1 : self.$lc
return self.$lines.slice(self.$lc+1)}
$Reader.seek=function(self,offset,whence){if(self.closed===True)throw _b_.ValueError('I/O operation on closed file')
if(whence===undefined)whence=0
if(whence===0){self.$counter=offset}
else if(whence===1){self.$counter +=offset}
else if(whence===2){self.$counter=self.$content.length+offset}}
$Reader.seekable=function(self){return true}
$Reader.tell=function(self){return self.$counter}
$Reader.writable=function(self){return false}
var $BufferedReader={__class__:$B.$type,__name__:'_io.BufferedReader'}
$BufferedReader.__mro__=[$Reader,$ObjectDict]
var $TextIOWrapper={__class__:$B.$type,__name__:'_io.TextIOWrapper'}
$TextIOWrapper.__mro__=[$Reader,$ObjectDict]
function $url_open(){
var $ns=$B.args('open',3,{file:null,mode:null,encoding:null},['file','mode','encoding'],arguments,{mode:'r',encoding:'utf-8'},'args','kw'),$res
for(var attr in $ns){eval('var '+attr+'=$ns["'+attr+'"]')}
if(args.length>0)var mode=args[0]
if(args.length>1)var encoding=args[1]
var is_binary=mode.search('b')>-1
if(isinstance(file,$B.JSObject))return new $B.$OpenFile(file.js,mode,encoding)
if(isinstance(file,_b_.str)){
var req=new XMLHttpRequest();
req.onreadystatechange=function(){try{
var status=this.status
if(status===404){$res=_b_.IOError('File '+file+' not found')}else if(status!==200){$res=_b_.IOError('Could not open file '+file+' : status '+status)}else{$res=this.responseText
if(is_binary){$res=_b_.str.$dict.encode($res,'utf-8')}}}catch(err){$res=_b_.IOError('Could not open file '+file+' : error '+err)}}
var fake_qs='?foo='+(new Date().getTime())
req.open('GET',file+fake_qs,false)
if(is_binary){req.overrideMimeType('text/plain; charset=utf-8');}
req.send()
if($res.constructor===Error)throw $res
if(is_binary){var lf=_b_.bytes('\n','ascii'),lines=_b_.bytes.$dict.split($res,lf)
for(var i=0;i<lines.length-1;i++){lines[i].source.push(10)}}else{var lines=$res.split('\n')
for(var i=0;i<lines.length-1;i++){lines[i]+='\n'}}
var res={$content:$res,$counter:0,$lines:lines,$bin:is_binary,closed:False,encoding:encoding,mode:mode,name:file}
res.__class__=is_binary ? $BufferedReader : $TextIOWrapper
return res}}
var $ZipDict={__class__:$B.$type,__name__:'zip'}
var $zip_iterator=$B.$iterator_class('zip_iterator')
$ZipDict.__iter__=function(self){
return self.$iterator=self.$iterator ||
$B.$iterator(self.items,$zip_iterator)}
$ZipDict.__mro__=[$ObjectDict]
function zip(){var res={__class__:$ZipDict,items:[]}
if(arguments.length==0)return res
var $ns=$B.args('zip',0,{},[],arguments,{},'args','kw')
var _args=$ns['args']
var args=[],pos=0
for(var i=0;i<_args.length;i++){args[pos++]=iter(_args[i])}
var rank=0,items=[]
while(1){var line=[],flag=true,pos=0
for(var i=0;i<args.length;i++){try{line[pos++]=next(args[i])}catch(err){if(err.__name__==='StopIteration'){flag=false;break}
else{throw err}}}
if(!flag)break
items[rank++]=_b_.tuple(line)}
res.items=items
return res}
zip.__class__=$B.$factory
zip.$dict=$ZipDict
$ZipDict.$factory=zip
function no_set_attr(klass,attr){if(klass[attr]!==undefined){throw _b_.AttributeError("'"+klass.__name__+"' object attribute '"+
attr+"' is read-only")}else{throw _b_.AttributeError("'"+klass.__name__+
"' object has no attribute '"+attr+"'")}}
var $BoolDict=$B.$BoolDict={__class__:$B.$type,__dir__:$ObjectDict.__dir__,__name__:'bool'}
bool.__class__=$B.$factory
bool.$dict=$BoolDict
$BoolDict.$factory=bool
var True=true
var False=false
var $EllipsisDict={__class__:$B.$type,__name__:'ellipsis'}
$EllipsisDict.__mro__=[$ObjectDict]
var Ellipsis={$dict: $EllipsisDict,__bool__ : function(){return True},__class__ : $EllipsisDict}
$EllipsisDict.$factory=Ellipsis
for(var $key in $B.$comps){
switch($B.$comps[$key]){case 'ge':
case 'gt':
case 'le':
case 'lt':
Ellipsis['__'+$B.$comps[$key]+'__']=(function(k){return function(other){throw _b_.TypeError("unorderable types: ellipsis() "+k+" "+
$B.get_class(other).__name__)}})($key)}}
for(var $func in Ellipsis){if(typeof Ellipsis[$func]==='function'){Ellipsis[$func].__str__=(function(f){return function(){return "<method-wrapper "+f+" of Ellipsis object>"}})($func)}}
var $FunctionCodeDict={__class__:$B.$type,__name__:'function code'}
$FunctionCodeDict.__mro__=[$ObjectDict]
$FunctionCodeDict.$factory={__class__:$B.$factory,$dict:$FunctionCodeDict}
var $FunctionGlobalsDict={__class:$B.$type,__name__:'function globals'}
$FunctionGlobalsDict.__mro__=[$ObjectDict]
$FunctionGlobalsDict.$factory={__class__:$B.$factory,$dict:$FunctionGlobalsDict}
var $FunctionDict=$B.$FunctionDict={__class__:$B.$type,__code__:{__class__:$FunctionCodeDict,__name__:'function code'},__globals__:{__class__:$FunctionGlobalsDict,__name__:'function globals'},__name__:'function'}
$FunctionDict.__dir__=function(self){var infos=self.$infos ||{},attrs=self.$attrs ||{}
return Object.keys(infos).concat(Object.keys(attrs))}
$FunctionDict.__eq__=function(self,other){return self===other}
$FunctionDict.__getattribute__=function(self,attr){
if(self.$infos && self.$infos[attr]!==undefined){if(attr=='__code__'){var res={__class__:$B.$CodeDict}
for(var attr in self.$infos.__code__){res[attr]=self.$infos.__code__[attr]}
return res}else if(attr=='__annotations__'){
return $B.obj_dict(self.$infos[attr])}else{return self.$infos[attr]}}else if(self.$attrs && self.$attrs[attr]!==undefined){return self.$attrs[attr]}else{return _b_.object.$dict.__getattribute__(self,attr)}}
$FunctionDict.__repr__=$FunctionDict.__str__=function(self){return '<function '+self.$infos.__qualname__+'>'}
$FunctionDict.__mro__=[$ObjectDict]
$FunctionDict.__setattr__=function(self,attr,value){if(self.$infos[attr]!==undefined){self.$infos[attr]=value}
else{self.$attrs=self.$attrs ||{};self.$attrs[attr]=value}}
var $Function=function(){}
$Function.__class__=$B.$factory
$FunctionDict.$factory=$Function
$Function.$dict=$FunctionDict
_b_.__BRYTHON__=__BRYTHON__
var builtin_funcs=['abs','all','any','ascii','bin','bool','bytearray','bytes','callable','chr','classmethod','compile','complex','delattr','dict','dir','divmod','enumerate','eval','exec','exit','filter','float','format','frozenset','getattr','globals','hasattr','hash','help','hex','id','input','int','isinstance','issubclass','iter','len','list','locals','map','max','memoryview','min','next','object','oct','open','ord','pow','print','property','quit','range','repr','reversed','round','set','setattr','slice','sorted','staticmethod','str','sum','$$super','tuple','type','vars','zip']
for(var i=0;i<builtin_funcs.length;i++){var name=builtin_funcs[i]
if(name=='open'){name1='$url_open'}
if(name=='super'){name='$$super'}
if(name=='eval'){name='$eval'}
$B.builtin_funcs[name]=true}
$B.builtin_funcs['$eval']=true
var other_builtins=['Ellipsis','False','None','True','__debug__','__import__','copyright','credits','license','NotImplemented','type']
var builtin_names=builtin_funcs.concat(other_builtins)
for(var i=0;i<builtin_names.length;i++){var name=builtin_names[i]
var orig_name=name
var name1=name
if(name=='open'){name1='$url_open'}
if(name=='super'){name='$$super'}
if(name=='eval'){name=name1='$$eval'}
if(name=='print'){name1='$print'}
$B.bound['__builtins__'][name]=true
try{_b_[name]=eval(name1)
if($B.builtin_funcs[name]!==undefined){
if(_b_[name].__repr__===undefined){
_b_[name].__repr__=_b_[name].__str__=(function(x){return function(){return '<built-in function '+x+'>'}})(orig_name)}
_b_[name].__module__='builtins'
_b_[name].__name__=name
_b_[name].__defaults__=_b_[name].__defaults__ ||[]
_b_[name].__kwdefaults__=_b_[name].__kwdefaults__ ||{}
_b_[name].__annotations__=_b_[name].__annotations__ ||{}}
_b_[name].__doc__=_b_[name].__doc__ ||''}
catch(err){}}
_b_['$$eval']=$eval
_b_['open']=$url_open
_b_['print']=$print
_b_['$$super']=$$super})(__BRYTHON__)
;(function($B){eval($B.InjectBuiltins())
$B.$raise=function(arg){
if(arg===undefined){var es=$B.current_exception
if(es!==undefined)throw es
throw _b_.RuntimeError('No active exception to reraise')}else if(isinstance(arg,BaseException)){throw arg}else if(arg.__class__===$B.$factory && issubclass(arg,BaseException)){throw arg()}else{throw _b_.TypeError("exceptions must derive from BaseException")}}
$B.$syntax_err_line=function(exc,module,pos,line_num){
var pos2line={},lnum=1,src=$B.$py_src[module],module=module.charAt(0)=='$' ? '<string>' : module
if(src===undefined){console.log('no src for',module)
exc.$line_info=line_num+','+module
exc.args=_b_.tuple([$B.$getitem(exc.args,0),module,line_num,0,0])}else{
var line_pos={1:0}
for(var i=0,_len_i=src.length;i < _len_i;i++){pos2line[i]=lnum
if(src.charAt(i)=='\n'){line_pos[++lnum]=i}}
while(line_num===undefined){line_num=pos2line[pos]
pos--}
exc.$line_info=line_num+','+module
var lines=src.split('\n'),line=lines[line_num-1],lpos=pos-line_pos[line_num],len=line.length
line=line.replace(/^\s*/,'')
lpos-=len-line.length
exc.args=_b_.tuple([$B.$getitem(exc.args,0),module,line_num,lpos,line])}}
$B.$SyntaxError=function(module,msg,pos,line_num,root){if(root!==undefined && root.line_info!==undefined){
line_num=root.line_info}
var exc=_b_.SyntaxError(msg)
$B.$syntax_err_line(exc,module,pos,line_num)
throw exc}
$B.$IndentationError=function(module,msg,pos){var exc=_b_.IndentationError(msg)
$B.$syntax_err_line(exc,module,pos)
throw exc}
var $TracebackDict={__class__:$B.$type,__name__:'traceback'}
$TracebackDict.__getattribute__=function(self,attr){if(self.stack.length==0){alert('no stack',attr)}
var last_frame=$B.last(self.stack)
if(last_frame==undefined){alert('last frame undef ');
console.log(self.stack,Object.keys(self.stack))}
var line_info=last_frame[1].$line_info
switch(attr){case 'tb_frame':
return frame(self.stack)
case 'tb_lineno':
if(line_info===undefined){return -1}
else{return parseInt(line_info.split(',')[0])}
case 'tb_lasti':
if(line_info===undefined){return '<unknown>'}
else{var info=line_info.split(',')
var src=$B.$py_src[info[1]]
if(src!==undefined){return src.split('\n')[parseInt(info[0]-1)].trim()}else{return '<unknown>'}}
case 'tb_next':
if(self.stack.length==1){return None}
else{return traceback(self.stack.slice(0,self.stack.length-1))}
default:
return $TracebackDict[attr]}}
$TracebackDict.__mro__=[_b_.object.$dict]
$TracebackDict.__str__=function(self){return '<traceback object>'}
function traceback(stack){return{__class__ : $TracebackDict,stack : stack}}
traceback.__class__=$B.$factory
traceback.$dict=$TracebackDict
$TracebackDict.$factory=traceback
var $FrameDict={__class__:$B.$type,__name__:'frame'}
$FrameDict.__getattr__=function(self,attr){
if(attr=='f_back'){if(self.$pos>0){return frame(self.$stack,self.$pos-1)}}}
$FrameDict.__mro__=[_b_.object.$dict]
function to_dict(obj){var res=_b_.dict()
var setitem=_b_.dict.$dict.__setitem__
for(var attr in obj){if(attr.charAt(0)=='$'){continue}
setitem(res,attr,obj[attr])}
return res}
function frame(stack,pos){var fs=stack
var res={__class__:$FrameDict,f_builtins :{},
$stack: stack,}
if(pos===undefined){pos=fs.length-1}
res.$pos=pos
if(fs.length){var _frame=fs[pos]
var locals_id=_frame[0]
try{res.f_locals=$B.obj_dict(_frame[1])}catch(err){console.log('err '+err)
throw err}
res.f_globals=$B.obj_dict(_frame[3])
if(_frame[1].$line_info===undefined){res.f_lineno=-1}
else{res.f_lineno=parseInt(_frame[1].$line_info.split(',')[0])}
res.f_code={__class__:$B.$CodeDict,co_code:None,
co_name: locals_id,
co_filename: _frame[3].__name__ }
if(res.f_code.co_filename===undefined){console.log(_frame[0],_frame[1],_frame[2],_frame[3]);
alert('no cofilename')}}
return res}
frame.__class__=$B.$factory
frame.$dict=$FrameDict
$FrameDict.$factory=frame
$B._frame=frame
var $BaseExceptionDict={__class__:$B.$type,__bases__ :[_b_.object],__module__:'builtins',__name__:'BaseException',args:[]}
$BaseExceptionDict.__init__=function(self){var args=arguments[1]===undefined ?[]:[arguments[1]]
self.args=_b_.tuple(args)}
$BaseExceptionDict.__repr__=function(self){return self.__class__.__name__+repr(self.args)}
$BaseExceptionDict.__str__=function(self){return _b_.str(self.args[0])}
$BaseExceptionDict.__mro__=[_b_.object.$dict]
$BaseExceptionDict.__new__=function(cls){var err=_b_.BaseException()
err.__name__=cls.$dict.__name__
err.__class__=cls.$dict
return err}
$BaseExceptionDict.__getattr__=function(self,attr){if(attr=='info'){var name=self.__class__.__name__
if(name=='SyntaxError' ||name=='IndentationError'){return 'File "'+self.args[1]+'", line '+self.args[2]+'\n '+
self.args[4]}
var info='Traceback (most recent call last):'
if(self.$js_exc!==undefined){for(var attr in self.$js_exc){if(attr==='message')continue
try{info +='\n '+attr+' : '+self.$js_exc[attr]}
catch(_err){}}
info+='\n'}
for(var i=0;i<self.$stack.length;i++){var frame=self.$stack[i]
if(!frame[1]||!frame[1].$line_info){continue}
var line_info=frame[1].$line_info.split(',')
if($B.$py_src[line_info[1]]===undefined){continue}
var lines=$B.$py_src[line_info[1]].split('\n'),module=line_info[1]
if(module.charAt(0)=='$'){module='<module>'}
info +='\n module '+module+' line '+line_info[0]
var line=lines[parseInt(line_info[0])-1]
if(line)line=line.replace(/^[ ]+/g,'')
if(line===undefined){console.log('line undef...',line_info,$B.$py_src[line_info[1]])}
info +='\n '+line}
return info}else if(attr=='traceback'){
return traceback(self.$stack)}else{throw AttributeError(self.__class__.__name__+
"has no attribute '"+attr+"'")}}
$BaseExceptionDict.__str__=function(self){return self.args[0]}
$BaseExceptionDict.with_traceback=function(self,tb){self.traceback=tb
return self}
$B.set_func_names($BaseExceptionDict)
var BaseException=function(){var err=Error()
err.__name__='BaseException'
err.args=_b_.tuple(Array.prototype.slice.call(arguments))
err.__class__=$BaseExceptionDict
err.$py_error=true
err.$stack=$B.frames_stack.slice()
$B.current_exception=err
eval('//placeholder//');
return err}
BaseException.__class__=$B.$factory
BaseException.$dict=$BaseExceptionDict
$BaseExceptionDict.$factory=BaseException
_b_.BaseException=BaseException
$B.exception=function(js_exc){
if(!js_exc.$py_error){
if(js_exc.info===undefined){var _frame=$B.last($B.frames_stack)
if(_frame===undefined){_frame=$B.pmframe}
if(_frame && _frame[1].$line_info!==undefined){var line_info=_frame[1].$line_info.split(',')
var mod_name=line_info[1]
var module=$B.modules[mod_name]
if(module){if(module.caller!==undefined){
var mod_name=line_info[1]}
var lib_module=mod_name
var line_num=parseInt(line_info[0])
if($B.$py_src[mod_name]===undefined){console.log('pas de py_src pour '+mod_name)
console.log(js_exc)}
var lines=$B.$py_src[mod_name].split('\n'),msg=js_exc.message.toString()
msg +="\n module '"+lib_module+"' line "+line_num
msg +='\n'+lines[line_num-1]
js_exc.msg=msg
js_exc.info_in_msg=true}}else{console.log('error ',js_exc)}}
var exc=Error()
exc.__name__='Internal Javascript error: '+(js_exc.__name__ ||js_exc.name)
exc.__class__=_b_.Exception.$dict
exc.$js_exc=js_exc
if(js_exc.name=='ReferenceError'){exc.__name__='NameError'
exc.__class__=_b_.NameError.$dict
js_exc.message=js_exc.message.replace('$$','')}else if(js_exc.name=="InternalError"){exc.__name__='RuntimeError'
exc.__class__=_b_.RuntimeError.$dict}
var $message=js_exc.msg ||'<'+js_exc+'>'
exc.args=_b_.tuple([$message])
exc.info=''
exc.$py_error=true
exc.$stack=$B.frames_stack.slice()}else{var exc=js_exc}
$B.current_exception=exc
return exc}
$B.is_exc=function(exc,exc_list){
if(exc.__class__===undefined)exc=$B.exception(exc)
var exc_class=exc.__class__.$factory
for(var i=0;i<exc_list.length;i++){if(issubclass(exc_class,exc_list[i]))return true}
return false}
$B.clear_exc=function(){$B.current_exception=null}
function $make_exc(names,parent){
var _str=[],pos=0
for(var i=0;i<names.length;i++){var name=names[i],code=''
if(Array.isArray(name)){
var code=name[1],name=name[0]}
$B.bound['__builtins__'][name]=true
var $exc=(BaseException+'').replace(/BaseException/g,name)
$exc=$exc.replace('//placeholder//',code)
_str[pos++]='var $'+name+'Dict={__class__:$B.$type,__name__:"'+name+'"}'
_str[pos++]='$'+name+'Dict.__bases__ = [parent]'
_str[pos++]='$'+name+'Dict.__module__ = "builtins"'
_str[pos++]='$'+name+'Dict.__mro__=[_b_.'+parent.$dict.__name__+
'.$dict].concat(parent.$dict.__mro__)'
_str[pos++]='_b_.'+name+'='+$exc
_str[pos++]='_b_.'+name+'.__class__=$B.$factory'
_str[pos++]='$'+name+'Dict.$factory=_b_.'+name
_str[pos++]='_b_.'+name+'.$dict=$'+name+'Dict'}
eval(_str.join(';'))}
$make_exc(['SystemExit','KeyboardInterrupt','GeneratorExit','Exception'],BaseException)
$make_exc([['StopIteration','err.value = arguments[0]'],'ArithmeticError','AssertionError','AttributeError','BufferError','EOFError','ImportError','LookupError','MemoryError','NameError','OSError','ReferenceError','RuntimeError','SyntaxError','SystemError','TypeError','ValueError','Warning'],_b_.Exception)
$make_exc(['FloatingPointError','OverflowError','ZeroDivisionError'],_b_.ArithmeticError)
$make_exc(['IndexError','KeyError'],_b_.LookupError)
$make_exc(['UnboundLocalError'],_b_.NameError)
$make_exc(['BlockingIOError','ChildProcessError','ConnectionError','FileExistsError','FileNotFoundError','InterruptedError','IsADirectoryError','NotADirectoryError','PermissionError','ProcessLookupError','TimeoutError'],_b_.OSError)
$make_exc(['BrokenPipeError','ConnectionAbortedError','ConnectionRefusedError','ConnectionResetError'],_b_.ConnectionError)
$make_exc(['NotImplementedError'],_b_.RuntimeError)
$make_exc(['NotImplemented'],_b_.RuntimeError)
$make_exc(['IndentationError'],_b_.SyntaxError)
$make_exc(['TabError'],_b_.IndentationError)
$make_exc(['UnicodeError'],_b_.ValueError)
$make_exc(['UnicodeDecodeError','UnicodeEncodeError','UnicodeTranslateError'],_b_.UnicodeError)
$make_exc(['DeprecationWarning','PendingDeprecationWarning','RuntimeWarning','SyntaxWarning','UserWarning','FutureWarning','ImportWarning','UnicodeWarning','BytesWarning','ResourceWarning'],_b_.Warning)
$make_exc(['EnvironmentError','IOError','VMSError','WindowsError'],_b_.OSError)
$B.$NameError=function(name){
throw _b_.NameError("name '"+name+"' is not defined")}
$B.$TypeError=function(msg){throw _b_.TypeError(msg)}})(__BRYTHON__)
;(function($B){var _b_=$B.builtins,None=_b_.None,$RangeDict={__class__:$B.$type,__dir__:_b_.object.$dict.__dir__,__name__:'range',$native:true,$descriptors:{start:true,step:true,stop:true}}
$RangeDict.__contains__=function(self,other){if($RangeDict.__len__(self)==0){return false}
try{other=$B.int_or_bool(other)}
catch(err){
try{$RangeDict.index(self,other);return true}
catch(err){return false}}
var sub=$B.sub(other,self.start),fl=$B.floordiv(sub,self.step),res=$B.mul(self.step,fl)
if($B.eq(res,sub)){if($B.gt(self.stop,self.start)){return $B.ge(other,self.start)&& $B.gt(self.stop,other)}else{return $B.ge(self.start,other)&& $B.gt(other,self.stop)}}else{return false}}
$RangeDict.__delattr__=function(self,attr,value){throw _b_.AttributeError('readonly attribute')}
$RangeDict.__eq__=function(self,other){if(_b_.isinstance(other,range)){var len=$RangeDict.__len__(self)
if(!$B.eq(len,$RangeDict.__len__(other))){return false}
if(len==0){return true}
if(!$B.eq(self.start,other.start)){return false}
if(len==1){return true}
return $B.eq(self.step,other.step)}
return false}
function compute_item(r,i){var len=$RangeDict.__len__(r)
if(len==0){return r.start}
else if(i>len){return r.stop}
return $B.add(r.start,$B.mul(r.step,i))}
$RangeDict.__getitem__=function(self,rank){if(_b_.isinstance(rank,_b_.slice)){var norm=_b_.slice.$dict.$conv_for_seq(rank,$RangeDict.__len__(self)),substep=$B.mul(self.step,norm.step),substart=compute_item(self,norm.start),substop=compute_item(self,norm.stop)
return range(substart,substop,substep)}
if(typeof rank !="number"){rank=$B.$GetInt(rank)}
if($B.gt(0,rank)){rank=$B.add(rank,$RangeDict.__len__(self))}
var res=$B.add(self.start,$B.mul(rank,self.step))
if(($B.gt(self.step,0)&&($B.ge(res,self.stop)||$B.gt(self.start,res)))||
($B.gt(0,self.step)&&($B.ge(self.stop,res)||$B.gt(res,self.start)))){throw _b_.IndexError('range object index out of range')}
return res }
$RangeDict.__hash__=function(self){var len=$RangeDict.__len__(self)
if(len==0){return _b_.hash(_b_.tuple([0,None,None]))}
if(len==1){return _b_.hash(_b_.tuple([1,self.start,None]))}
return _b_.hash(_b_.tuple([len,self.start,self.step]))}
var $RangeIterator=function(obj){return{__class__:$RangeIterator.$dict,obj: obj}}
$RangeIterator.__class__=$B.$factory
$RangeIterator.$dict={__class__: $B.$type,__name__: 'range_iterator',$factory: $RangeIterator,__iter__: function(self){return self},__next__: function(self){return _b_.next(self.obj)}}
$RangeIterator.$dict.__mro__=[_b_.object.$dict]
$RangeDict.__iter__=function(self){var res={__class__ : $RangeDict,start:self.start,stop:self.stop,step:self.step}
if(self.$safe){res.$counter=self.start-self.step}else{res.$counter=$B.sub(self.start,self.step)}
return $RangeIterator(res)}
$RangeDict.__len__=function(self){var len
if($B.gt(self.step,0)){if($B.ge(self.start,self.stop)){return 0}
var n=$B.sub(self.stop,$B.add(1,self.start)),q=$B.floordiv(n,self.step)
len=$B.add(1,q)}else{if($B.ge(self.stop,self.start)){return 0}
var n=$B.sub(self.start,$B.add(1,self.stop)),q=$B.floordiv(n,$B.mul(-1,self.step))
len=$B.add(1,q)}
if($B.maxsize===undefined){$B.maxsize=$B.LongInt.$dict.__pow__($B.LongInt(2),63)
$B.maxsize=$B.LongInt.$dict.__sub__($B.maxsize,1)}
return len}
$RangeDict.__next__=function(self){if(self.$safe){self.$counter +=self.step
if((self.step>0 && self.$counter >=self.stop)
||(self.step<0 && self.$counter <=self.stop)){throw _b_.StopIteration('')}}else{self.$counter=$B.add(self.$counter,self.step)
if(($B.gt(self.step,0)&& $B.ge(self.$counter,self.stop))
||($B.gt(0,self.step)&& $B.ge(self.stop,self.$counter))){throw _b_.StopIteration('')}}
return self.$counter}
$RangeDict.__mro__=[_b_.object.$dict]
$RangeDict.__reversed__=function(self){var n=$B.sub($RangeDict.__len__(self),1)
return range($B.add(self.start,$B.mul(n,self.step)),$B.sub(self.start,self.step),$B.mul(-1,self.step))}
$RangeDict.__repr__=$RangeDict.__str__=function(self){var res='range('+_b_.str(self.start)+', '+_b_.str(self.stop)
if(self.step!=1)res +=', '+_b_.str(self.step)
return res+')'}
$RangeDict.__setattr__=function(self,attr,value){throw _b_.AttributeError('readonly attribute')}
$RangeDict.start=function(self){return self.start}
$RangeDict.step=function(self){return self.step},$RangeDict.stop=function(self){return self.stop}
$RangeDict.count=function(self,ob){if(_b_.isinstance(ob,[_b_.int,_b_.float,_b_.bool])){return _b_.int($RangeDict.__contains__(self,ob))}else{var comp=_b_.getattr(ob,'__eq__'),it=$RangeDict.__iter__(self)
_next=$RangeIterator.$dict.__next__,nb=0
while(true){try{if(comp(_next(it))){nb++}}catch(err){if(_b_.isinstance(err,_b_.StopIteration)){return nb}
throw err}}}}
$RangeDict.index=function(self,other){var $=$B.args('index',2,{self:null,other:null},['self','other'],arguments,{},null,null),self=$.self,other=$.other
try{other=$B.int_or_bool(other)}catch(err){var comp=_b_.getattr(other,'__eq__'),it=$RangeDict.__iter__(self),_next=$RangeIterator.$dict.__next__,nb=0
while(true){try{if(comp(_next(it))){return nb}
nb++}catch(err){if(_b_.isinstance(err,_b_.StopIteration)){throw _b_.ValueError(_b_.str(other)+' not in range')}
throw err}}}
var sub=$B.sub(other,self.start),fl=$B.floordiv(sub,self.step),res=$B.mul(self.step,fl)
if($B.eq(res,sub)){if(($B.gt(self.stop,self.start)&& $B.ge(other,self.start)
&& $B.gt(self.stop,other))||
($B.ge(self.start,self.stop)&& $B.ge(self.start,other)
&& $B.gt(other,self.stop))){return fl}else{throw _b_.ValueError(_b_.str(other)+' not in range')}}else{throw _b_.ValueError(_b_.str(other)+' not in range')}}
function range(){var $=$B.args('range',3,{start:null,stop:null,step:null},['start','stop','step'],arguments,{stop:null,step:null},null,null),start=$.start,stop=$.stop,step=$.step,safe
if(stop===null && step===null){stop=$B.PyNumber_Index(start)
safe=typeof stop==="number"
return{__class__:$RangeDict,start: 0,stop: stop,step: 1,$is_range: true,$safe: safe}}
if(step===null){step=1}
start=$B.PyNumber_Index(start)
stop=$B.PyNumber_Index(stop)
step=$B.PyNumber_Index(step)
if(step==0){throw _b_.ValueError("range() arg 3 must not be zero")}
safe=(typeof start=='number' && typeof stop=='number' &&
typeof step=='number')
return{__class__: $RangeDict,start: start,stop: stop,step: step,$is_range: true,$safe: safe}}
range.__class__=$B.$factory
range.$dict=$RangeDict
$RangeDict.$factory=range
range.$is_func=true
var $SliceDict={__class__:$B.$type,__name__:'slice',$native:true,$descriptors:{start:true,step:true,stop:true}}
$SliceDict.__mro__=[_b_.object.$dict]
$SliceDict.__repr__=$SliceDict.__str__=function(self){return 'slice('+_b_.str(self.start)+','+
_b_.str(self.stop)+','+_b_.str(self.step)+')'}
$SliceDict.__setattr__=function(self,attr,value){throw _b_.AttributeError('readonly attribute')}
$SliceDict.$conv=function(self,len){
return{start: self.start===_b_.None ? 0 : self.start,stop: self.stop===_b_.None ? len : self.stop,step: self.step===_b_.None ? 1 : self.step}}
$SliceDict.$conv_for_seq=function(self,len){
var step=self.step===None ? 1 : $B.PyNumber_Index(self.step),step_is_neg=$B.gt(0,step),len_1=$B.sub(len,1)
if(step==0){throw _b_.ValueError('slice step cannot be zero');}
var start
if(self.start===None){start=step_is_neg ? len_1 : 0;}else{
start=$B.PyNumber_Index(self.start);
if($B.gt(0,start))start=$B.add(start,len);
if($B.gt(0,start))start=step<0 ? -1 : 0
if($B.ge(start,len))start=step<0 ? len_1 : len;}
if(self.stop===None){stop=step_is_neg ? -1 : len;}else{
stop=$B.PyNumber_Index(self.stop);
if($B.gt(0,stop))stop +=len
if($B.gt(0,stop))stop=step<0 ? -1 : 0
if($B.ge(stop,len))stop=step_is_neg ? len_1 : len;}
return{start: start,stop: stop,step: step}}
$SliceDict.start=function(self){return self.start}
$SliceDict.step=function(self){return self.step}
$SliceDict.stop=function(self){return self.stop}
$SliceDict.indices=function(self,length){var len=$B.$GetInt(length)
if(len < 0)_b_.ValueError('length should not be negative')
if(self.step > 0){var _len=_b_.min(len,self.stop)
return _b_.tuple([self.start,_len,self.step])}else if(self.step==_b_.None){var _len=_b_.min(len,self.stop)
var _start=self.start
if(_start==_b_.None)_start=0
return _b_.tuple([_start,_len,1])}
_b_.NotImplementedError("Error! negative step indices not implemented yet")}
function slice(){var $=$B.args('slice',3,{start:null,stop:null,step:null},['start','stop','step'],arguments,{stop:null,step:null},null,null),start,stop,step
if($.stop===null && $.step===null){start=_b_.None
stop=$.start
step=_b_.None}else{start=$.start
stop=$.stop
step=$.step===null ? _b_.None : $.step}
var res={__class__ : $SliceDict,start:start,stop:stop,step:step}
return res}
slice.__class__=$B.$factory
slice.$dict=$SliceDict
$SliceDict.$factory=slice
slice.$is_func=true
_b_.range=range
_b_.slice=slice})(__BRYTHON__)
;(function($B){var _b_=$B.builtins
var $ObjectDict=_b_.object.$dict
var isinstance=_b_.isinstance,getattr=_b_.getattr,None=_b_.None
var from_unicode={},to_unicode={}
var $BytearrayDict={__class__:$B.$type,__name__:'bytearray',$buffer_protocol:true}
var mutable_methods=['__delitem__','clear','copy','count','index','pop','remove','reverse','sort']
for(var i=0,_len_i=mutable_methods.length;i < _len_i;i++){var method=mutable_methods[i]
$BytearrayDict[method]=(function(m){return function(self){var args=[self.source],pos=1
for(var i=1,_len_i=arguments.length;i < _len_i;i++)args[pos++]=arguments[i]
return _b_.list.$dict[m].apply(null,args)}})(method)}
var $bytearray_iterator=$B.$iterator_class('bytearray_iterator')
$BytearrayDict.__iter__=function(self){return $B.$iterator(self.source,$bytearray_iterator)}
$BytearrayDict.__mro__=[$ObjectDict]
$BytearrayDict.__repr__=$BytearrayDict.__str__=function(self){return 'bytearray('+$BytesDict.__repr__(self)+")"}
$BytearrayDict.__setitem__=function(self,arg,value){if(isinstance(arg,_b_.int)){if(!isinstance(value,_b_.int)){throw _b_.TypeError('an integer is required')}else if(value>255){throw _b_.ValueError("byte must be in range(0, 256)")}
var pos=arg
if(arg<0)pos=self.source.length+pos
if(pos>=0 && pos<self.source.length){self.source[pos]=value}
else{throw _b_.IndexError('list index out of range')}}else if(isinstance(arg,_b_.slice)){var start=arg.start===None ? 0 : arg.start
var stop=arg.stop===None ? self.source.length : arg.stop
if(start<0)start=self.source.length+start
if(stop<0)stop=self.source.length+stop
self.source.splice(start,stop-start)
if(_b_.hasattr(value,'__iter__')){var $temp=_b_.list(value)
for(var i=$temp.length-1;i>=0;i--){if(!isinstance($temp[i],_b_.int)){throw _b_.TypeError('an integer is required')}else if($temp[i]>255){throw ValueError("byte must be in range(0, 256)")}
self.source.splice(start,0,$temp[i])}}else{throw _b_.TypeError("can only assign an iterable")}}else{
throw _b_.TypeError('list indices must be integer, not '+$B.get_class(arg).__name__)}}
$BytearrayDict.append=function(self,b){if(arguments.length!=2){throw _b_.TypeError(
"append takes exactly one argument ("+(arguments.length-1)+" given)")}
if(!isinstance(b,_b_.int))throw _b_.TypeError("an integer is required")
if(b>255)throw ValueError("byte must be in range(0, 256)")
self.source[self.source.length]=b}
$BytearrayDict.insert=function(self,pos,b){if(arguments.length!=3){throw _b_.TypeError(
"insert takes exactly 2 arguments ("+(arguments.length-1)+" given)")}
if(!isinstance(b,_b_.int))throw _b_.TypeError("an integer is required")
if(b>255)throw ValueError("byte must be in range(0, 256)")
_b_.list.$dict.insert(self.source,pos,b)}
function bytearray(source,encoding,errors){var obj={__class__:$BytearrayDict}
$BytearrayDict.__init__(obj,source,encoding,errors)
return obj}
bytearray.__class__=$B.$factory
bytearray.$dict=$BytearrayDict
$BytearrayDict.$factory=bytearray
bytearray.__code__={}
bytearray.__code__.co_argcount=1
bytearray.__code__.co_consts=[]
bytearray.__code__.co_varnames=['i']
var $BytesDict={__class__ : $B.$type,__name__ : 'bytes',$buffer_protocol:true}
$BytesDict.__add__=function(self,other){if(!isinstance(other,bytes)){throw _b_.TypeError("can't concat bytes to " + _b_.str(other))}
self.source=self.source.concat(other.source)
return self}
var $bytes_iterator=$B.$iterator_class('bytes_iterator')
$BytesDict.__iter__=function(self){return $B.$iterator(self.source,$bytes_iterator)}
$BytesDict.__eq__=function(self,other){return getattr(self.source,'__eq__')(other.source)}
$BytesDict.__ge__=function(self,other){return _b_.list.$dict.__ge__(self.source,other.source)}
$BytesDict.__getitem__=function(self,arg){var i
if(isinstance(arg,_b_.int)){var pos=arg
if(arg<0)pos=self.source.length+pos
if(pos>=0 && pos<self.source.length)return self.source[pos]
throw _b_.IndexError('index out of range')}else if(isinstance(arg,_b_.slice)){var step=arg.step===None ? 1 : arg.step
if(step>0){var start=arg.start===None ? 0 : arg.start
var stop=arg.stop===None ? getattr(self.source,'__len__')(): arg.stop}else{var start=arg.start===None ?
getattr(self.source,'__len__')()-1 : arg.start
var stop=arg.stop===None ? 0 : arg.stop}
if(start<0)start=self.source.length+start
if(stop<0)stop=self.source.length+stop
var res=[],i=null,pos=0
if(step>0){stop=Math.min(stop,self.source.length)
if(stop<=start)return bytes([])
for(i=start;i<stop;i+=step)res[pos++]=self.source[i]}else{
if(stop>=start)return bytes([])
stop=Math.max(0,stop)
for(i=start;i>=stop;i+=step)res[pos++]=self.source[i]}
return bytes(res)}else if(isinstance(arg,bool)){return self.source.__getitem__(_b_.int(arg))}}
$BytesDict.__gt__=function(self,other){return _b_.list.$dict.__gt__(self.source,other.source)}
$BytesDict.__hash__=function(self){if(self===undefined){return $BytesDict.__hashvalue__ ||$B.$py_next_hash-- }
var hash=1;
for(var i=0,_len_i=self.length;i < _len_i;i++){hash=(101*hash + self.source[i])& 0xFFFFFFFF}
return hash}
$BytesDict.__init__=function(self,source,encoding,errors){var int_list=[],pos=0
if(source===undefined){}else if(isinstance(source,_b_.int)){var i=source
while(i--)int_list[pos++]=0}else{if(isinstance(source,_b_.str)){if(encoding===undefined)
throw _b_.TypeError("string argument without an encoding")
int_list=encode(source,encoding)}else{
int_list=_b_.list(source)}}
self.source=int_list
self.encoding=encoding
self.errors=errors}
$BytesDict.__le__=function(self,other){return _b_.list.$dict.__le__(self.source,other.source)}
$BytesDict.__len__=function(self){return self.source.length}
$BytesDict.__lt__=function(self,other){return _b_.list.$dict.__lt__(self.source,other.source)}
$BytesDict.__mro__=[$ObjectDict]
$BytesDict.__mul__=function(){var $=$B.args('__mul__',2,{self:null,other:null},['self','other'],arguments,{},null,null),other=$B.PyNumber_Index($.other),res=bytes()
for(var i=0;i<other;i++){res.source=res.source.concat($.self.source)}
return res}
$BytesDict.__ne__=function(self,other){return !$BytesDict.__eq__(self,other)}
$BytesDict.__repr__=$BytesDict.__str__=function(self){var res="b'"
for(var i=0,_len_i=self.source.length;i < _len_i;i++){var s=self.source[i]
if(s<32 ||s>=128){var hx=s.toString(16)
hx=(hx.length==1 ? '0' : '')+ hx
res +='\\x'+hx}else{res +=String.fromCharCode(s)}}
return res+"'"}
$BytesDict.__reduce_ex__=function(self){return $BytesDict.__repr__(self)}
$BytesDict.decode=function(self,encoding,errors){if(encoding===undefined)encoding='utf-8'
if(errors===undefined)errors='strict'
switch(errors){case 'strict':
case 'ignore':
case 'replace':
case 'surrogateescape':
case 'xmlcharrefreplace':
case 'backslashreplace':
return decode(self.source,encoding,errors)
default:}}
$BytesDict.join=function(){var $ns=$B.args('join',2,{self:null,iterable:null},['self','iterable'],arguments,{}),self=$ns['self'],iterable=$ns['iterable']
var next_func=_b_.getattr(_b_.iter(iterable),'__next__'),res=bytes(),empty=true
while(true){try{var item=next_func()
if(empty){empty=false}
else{res=$BytesDict.__add__(res,self)}
res=$BytesDict.__add__(res,item)}catch(err){if(isinstance(err,_b_.StopIteration)){break}
throw err}}
return res}
$BytesDict.maketrans=function(from,to){var _t=[]
for(var i=0;i < 256;i++)_t[i]=i
for(var i=0,_len_i=from.source.length;i < _len_i;i++){var _ndx=from.source[i]
_t[_ndx]=to.source[i]}
return bytes(_t)}
$BytesDict.find=function(){var $=$B.args('find',4,{self:null,sub:null,start:null,end:null},['self','sub','start','end'],arguments,{start:0,end:-1},null,null),sub=$.sub,start=$.start;
if(! sub.__class__ ){throw _b_.TypeError("first argument must be a bytes-like object not '"+$B.get_class($.sub).__name__+"'")}else if(! sub.__class__.$buffer_protocol ){throw _b_.TypeError("first argument must be a bytes-like object not '"+sub.__class__.__name__+"'")}
var end=$.end==-1 ? $.self.source.length-sub.source.length : Math.min($.self.source.length-sub.source.length,$.end);
for(var i=start;i<=end;i++){if($BytesDict.startswith($.self,sub,i))return i;}
return -1;}
$BytesDict.replace=function(){var $=$B.args('replace',4,{self:null,old:null,new:null,count:null},['self','old','new','count'],arguments,{count:-1},null,null),res=[];
var self=$.self,src=self.source,len=src.length,old=$.old,$new=$.new;
var count=$.count >=0 ? $.count : src.length;
if(! $.old.__class__ ){throw _b_.TypeError("first argument must be a bytes-like object not '"+$B.get_class($.old).__name__+"'")}else if(! $.old.__class__.$buffer_protocol ){throw _b_.TypeError("first argument must be a bytes-like object not '"+$.sep.__class__.__name__+"'")}
if(! $.new.__class__ ){throw _b_.TypeError("second argument must be a bytes-like object not '"+$B.get_class($.old).__name__+"'")}else if(! $.new.__class__.$buffer_protocol ){throw _b_.TypeError("second argument must be a bytes-like object not '"+$.sep.__class__.__name__+"'")}
for(var i=0;i<len;i++){if($BytesDict.startswith(self,old,i)&& count){for(var j=0;j<$new.source.length;j++){res.push($new.source[j]);}
i+=(old.source.length-1);
count--;}else{
res.push(src[i]);}}
return bytes(res);}
$BytesDict.split=function(){var $=$B.args('split',2,{self:null,sep:null},['self','sep'],arguments,{},null,null),res=[],start=0,stop=0
if(! $.sep.__class__ ){throw _b_.TypeError("a bytes-like object is required not '"+$B.get_class($.start).__name__+"'")}else if(! $.sep.__class__.$buffer_protocol ){throw _b_.TypeError("a bytes-like object is required not '"+$.sep.__class__.__name__+"'")}
var seps=$.sep.source,len=seps.length,src=$.self.source,blen=src.length
while(stop<blen){var match=true
for(var i=0;i<len && match;i++){if(src[stop+i]!=seps[i]){match=false}}
if(match){res.push(bytes(src.slice(start,stop)))
start=stop+len
stop=start}else{stop++}}
if(match ||(stop>start)){res.push(bytes(src.slice(start,stop)))}
return res}
function _strip(self,cars,lr){if(cars===undefined){cars=[],pos=0
var ws='\r\n \t'
for(var i=0,_len_i=ws.length;i < _len_i;i++)cars[pos++]=ws.charCodeAt(i)}else if(isinstance(cars,bytes)){cars=cars.source}else{throw _b_.TypeError("Type str doesn't support the buffer API")}
if(lr=='l'){for(var i=0,_len_i=self.source.length;i < _len_i;i++){if(cars.indexOf(self.source[i])==-1)break}
return bytes(self.source.slice(i))}
for(var i=self.source.length-1;i>=0;i--){if(cars.indexOf(self.source[i])==-1)break}
return bytes(self.source.slice(0,i+1))}
$BytesDict.lstrip=function(self,cars){return _strip(self,cars,'l')}
$BytesDict.rstrip=function(self,cars){return _strip(self,cars,'r')}
$BytesDict.startswith=function(){var $=$B.args('startswith',3,{self: null,prefix: null,start:null},['self','prefix','start'],arguments,{start:0},null,null),start=$.start
if(_b_.isinstance($.prefix,bytes)){var res=true
for(var i=0;i<$.prefix.source.length && res;i++){res=$.self.source[start+i]==$.prefix.source[i]}
return res}else if(_b_.isinstance($.prefix,_b_.tuple)){var items=[]
for(var i=0;i<$.prefix.length;i++){if(_b_.isinstance($.prefix[i],bytes)){items=items.concat($.prefix[i].source)}else{throw _b_.TypeError("startswith first arg must be bytes or "+
"a tuple of bytes, not "+$B.get_class($.prefix).__name__)}}
var prefix=bytes(items)
return $BytesDict.startswith($.self,prefix,start)}else{throw _b_.TypeError("startsswith first arg must be bytes or a tuple of bytes, not "+
$B.get_class($.prefix).__name__)}}
$BytesDict.strip=function(self,cars){var res=$BytesDict.lstrip(self,cars)
return $BytesDict.rstrip(res,cars)}
$BytesDict.translate=function(self,table,_delete){if(_delete===undefined){_delete=[]}
else if(isinstance(_delete,bytes)){_delete=_delete.source}
else{throw _b_.TypeError("Type "+$B.get_class(_delete).__name+" doesn't support the buffer API")}
var res=[],pos=0
if(isinstance(table,bytes)&& table.source.length==256){for(var i=0,_len_i=self.source.length;i < _len_i;i++){if(_delete.indexOf(self.source[i])>-1)continue
res[pos++]=table.source[self.source[i]]}}
return bytes(res)}
var _upper=function(char_code){if(char_code >=97 && char_code <=122){return char_code - 32}else{
return char_code}}
var _lower=function(char_code){if(char_code >=65 && char_code <=90){return char_code + 32}else{
return char_code}}
$BytesDict.upper=function(self){var _res=[],pos=0
for(var i=0,_len_i=self.source.length;i < _len_i;i++){if(self.source[i])
_res[pos++]=_upper(self.source[i])}
return bytes(_res)}
$BytesDict.lower=function(self){var _res=[],pos=0
for(var i=0,_len_i=self.source.length;i < _len_i;i++){if(self.source[i])
_res[pos++]=_lower(self.source[i])}
return bytes(_res)}
function $UnicodeEncodeError(encoding,code_point,position){throw _b_.UnicodeEncodeError("'"+encoding+
"' codec can't encode character "+_b_.hex(code_point)+
" in position "+position)}
function $UnicodeDecodeError(encoding,position){throw _b_.UnicodeDecodeError("'"+encoding+
"' codec can't decode bytes in position "+position)}
function _hex(int){return int.toString(16)}
function _int(hex){return parseInt(hex,16)}
function normalise(encoding){var enc=encoding.toLowerCase()
if(enc.substr(0,7)=='windows'){enc='cp'+enc.substr(7)}
enc=enc.replace('-','')
enc=enc.replace('-','_')
return enc}
function load_decoder(enc){
if(to_unicode[enc]===undefined){load_encoder(enc)
to_unicode[enc]={}
for(var attr in from_unicode[enc]){to_unicode[enc][from_unicode[enc][attr]]=attr}}}
function load_encoder(enc){
if(from_unicode[enc]===undefined){var mod=_b_.__import__('encodings.'+enc),table=mod[enc].decoding_table
from_unicode[enc]={}
for(var i=0;i<table.length;i++){from_unicode[enc][table.charCodeAt(i)]=i}}}
function decode(b,encoding,errors){var s='',enc=normalise(encoding)
switch(enc){case 'utf_8':
case 'utf-8':
case 'utf8':
case 'U8':
case 'UTF':
var i=0,cp
var _int_800=_int('800'),_int_c2=_int('c2'),_int_1000=_int('1000')
var _int_e0=_int('e0'),_int_e1=_int('e1'),_int_e3=_int('e3')
var _int_a0=_int('a0'),_int_80=_int('80'),_int_2000=_int('2000')
while(i<b.length){if(b[i]<=127){s +=String.fromCharCode(b[i])
i +=1}else if(b[i]<_int_e0){if(i<b.length-1){cp=b[i+1]+ 64*(b[i]-_int_c2)
s +=String.fromCharCode(cp)
i +=2}else{$UnicodeDecodeError(encoding,i)}}else if(b[i]==_int_e0){if(i<b.length-2){var zone=b[i+1]-_int_a0
cp=b[i+2]-_int_80+_int_800+64*zone
s +=String.fromCharCode(cp)
i +=3}else{$UnicodeDecodeError(encoding,i)}}else if(b[i]<_int_e3){if(i<b.length-2){var zone=b[i+1]-_int_80
cp=b[i+2]-_int_80+_int_1000+64*zone
s +=String.fromCharCode(cp)
i +=3}else{$UnicodeDecodeError(encoding,i)}}else{if(i<b.length-2){var zone1=b[i]-_int_e1-1
var zone=b[i+1]-_int_80+64*zone1
cp=b[i+2]-_int_80+_int_2000+64*zone
s +=String.fromCharCode(cp)
i +=3}else{if(errors=='surrogateescape'){s+='\\udc' + _hex(b[i])
i+=1}else{
$UnicodeDecodeError(encoding,i)}}}}
break;
case 'latin_1':
case 'windows1252':
case 'iso-8859-1':
case 'iso8859-1':
case '8859':
case 'cp819':
case 'latin':
case 'latin1':
case 'L1':
for(var i=0,_len_i=b.length;i < _len_i;i++)s +=String.fromCharCode(b[i])
break;
case 'ascii':
for(var i=0,_len_i=b.length;i < _len_i;i++){var cp=b[i]
if(cp<=127){s +=String.fromCharCode(cp)}
else{var msg="'ascii' codec can't decode byte 0x"+cp.toString(16)
msg +=" in position "+i+": ordinal not in range(128)"
throw _b_.UnicodeDecodeError(msg)}}
break;
default:
try{load_decoder(enc)}
catch(err){throw _b_.LookupError("unknown encoding: "+ enc)}
for(var i=0,_len_i=b.length;i < _len_i;i++){var u=to_unicode[enc][b[i]]
if(u!==undefined){s+=String.fromCharCode(u)}
else{s +=String.fromCharCode(b[i])}}
break;}
return s}
function encode(s,encoding){var $=$B.args('encode',2,{s:null,encoding:null},['s','encoding'],arguments,{},null,null),s=$.s,encoding=$.encoding;
var t=[],pos=0,enc=normalise(encoding)
switch(enc){case 'utf-8':
case 'utf8':
var _int_800=_int('800'),_int_c2=_int('c2'),_int_1000=_int('1000')
var _int_e0=_int('e0'),_int_e1=_int('e1'),_int_a0=_int('a0'),_int_80=_int('80')
var _int_2000=_int('2000'),_int_D000=_int('D000')
for(var i=0,_len_i=s.length;i < _len_i;i++){var cp=s.charCodeAt(i)
if(cp<=127){t[pos++]=cp}else if(cp<_int_800){var zone=Math.floor((cp-128)/64)
t[pos++]=_int_c2+zone
t[pos++]=cp -64*zone}else if(cp<_int_1000){var zone=Math.floor((cp-_int_800)/64)
t[pos++]=_int_e0
t[pos++]=_int_a0+zone
t[pos++]=_int_80 + cp - _int_800 - 64 * zone}else if(cp<_int_2000){var zone=Math.floor((cp-_int_1000)/64)
t[pos++]=_int_e1+Math.floor((cp-_int_1000)/_int_1000)
t[pos++]=_int_80+zone
t[pos++]=_int_80 + cp - _int_1000 -64*zone}else if(cp<_int_D000){var zone=Math.floor((cp-_int_2000)/64)
var zone1=Math.floor((cp-_int_2000)/_int_1000)
t[pos++]=_int_e1+Math.floor((cp-_int_1000)/_int_1000)
t[pos++]=_int_80+zone-zone1*64
t[pos++]=_int_80 + cp - _int_2000 - 64 * zone}}
break;
case 'latin1':
case 'iso8859_1':
case 'windows1252':
for(var i=0,_len_i=s.length;i < _len_i;i++){var cp=s.charCodeAt(i)
if(cp<=255){t[pos++]=cp}
else{$UnicodeEncodeError(encoding,i)}}
break;
case 'ascii':
for(var i=0,_len_i=s.length;i < _len_i;i++){var cp=s.charCodeAt(i)
if(cp<=127){t[pos++]=cp}
else{$UnicodeEncodeError(encoding,i)}}
break;
default:
try{load_encoder(enc)}
catch(err){throw _b_.LookupError("unknown encoding: "+ enc)}
for(var i=0,_len_i=s.length;i < _len_i;i++){var cp=s.charCodeAt(i)
if(from_unicode[enc][cp]===undefined){$UnicodeEncodeError(encoding,cp,i)}
t[pos++]=from_unicode[enc][cp]}
break}
return t}
function bytes(source,encoding,errors){
var obj={__class__:$BytesDict}
$BytesDict.__init__(obj,source,encoding,errors)
return obj}
bytes.__class__=$B.$factory
bytes.$dict=$BytesDict
$BytesDict.$factory=bytes
bytes.__code__={}
bytes.__code__.co_argcount=1
bytes.__code__.co_consts=[]
bytes.__code__.co_varnames=['i']
for(var $attr in $BytesDict){if($BytearrayDict[$attr]===undefined){$BytearrayDict[$attr]=(function(attr){return function(){return $BytesDict[attr].apply(null,arguments)}})($attr)}}
$B.set_func_names($BytesDict)
$B.set_func_names($BytearrayDict)
_b_.bytes=bytes
_b_.bytearray=bytearray})(__BRYTHON__)
;(function($B){eval($B.InjectBuiltins())
var $ObjectDict=_b_.object.$dict
var $LocationDict={__class__:$B.$type,__name__:'Location'}
$LocationDict.__mro__=[$ObjectDict]
var _window=self;
function $Location(){
var obj={}
for(var x in _window.location){if(typeof _window.location[x]==='function'){obj[x]=(function(f){return function(){return f.apply(_window.location,arguments)}})(_window.location[x])}else{obj[x]=_window.location[x]}}
if(obj['replace']===undefined){
obj['replace']=function(url){_window.location=url}}
obj.__class__=$LocationDict
obj.toString=function(){return _window.location.toString()}
obj.__repr__=obj.__str__=obj.toString
return obj}
$LocationDict.$factory=$Location
$Location.$dict=$LocationDict
var $JSConstructorDict={__class__:$B.$type,__name__:'JSConstructor'}
$JSConstructorDict.__call__=function(self){
var args=[null]
for(var i=1,_len_i=arguments.length;i < _len_i;i++){args.push(pyobj2jsobj(arguments[i]))}
var factory=self.func.bind.apply(self.func,args)
var res=new factory()
return $B.$JS2Py(res)}
$JSConstructorDict.__getattr__=function(self,attr){
return $JSObjectDict.__getattribute__(self.obj,attr)}
$JSConstructorDict.__mro__=[$ObjectDict]
function JSConstructor(obj){return{
__class__:$JSConstructorDict,obj: obj,func:obj.js_func}}
JSConstructor.__class__=$B.$factory
JSConstructor.$dict=$JSConstructorDict
$JSConstructorDict.$factory=JSConstructor
var jsobj2pyobj=$B.jsobj2pyobj=function(jsobj){switch(jsobj){case true:
case false:
return jsobj}
if(Array.isArray(jsobj))return _b_.list(jsobj)
if(typeof jsobj==='number'){if(jsobj.toString().indexOf('.')==-1)return _b_.int(jsobj)
return _b_.float(jsobj)}
return $B.JSObject(jsobj)}
var pyobj2jsobj=$B.pyobj2jsobj=function(pyobj){
if(pyobj===true ||pyobj===false)return pyobj
if(pyobj===_b_.None)return null
var klass=$B.get_class(pyobj)
if(klass===undefined){
return pyobj;}
if(klass===$JSObjectDict ||klass===$JSConstructorDict){
if(pyobj.js_func!==undefined){return pyobj.js_func}
return pyobj.js}else if(klass===$B.DOMNodeDict ||
klass.__mro__.indexOf($B.DOMNodeDict)>-1){
return pyobj.elt}else if([_b_.list.$dict,_b_.tuple.$dict].indexOf(klass)>-1){
var res=[]
for(var i=0,_len_i=pyobj.length;i < _len_i;i++){res.push(pyobj2jsobj(pyobj[i]))}
return res}else if(klass===_b_.dict.$dict){
var jsobj={}
var items=_b_.list(_b_.dict.$dict.items(pyobj))
for(var j=0,_len_j=items.length;j < _len_j;j++){if(typeof items[j][1]=='function'){
items[j][1].bind(jsobj)}
jsobj[items[j][0]]=pyobj2jsobj(items[j][1])}
return jsobj}else if(klass===$B.builtins.float.$dict){
return pyobj.valueOf()}else if(klass===$B.$FunctionDict){
return function(){try{var args=[]
for(var i=0;i<arguments.length;i++){if(arguments[i]===undefined){args.push(_b_.None)}
else{args.push(jsobj2pyobj(arguments[i]))}}
return pyobj2jsobj(pyobj.apply(this,args))}catch(err){console.log(err)
console.log(_b_.getattr(err,'info'))
console.log(err.__name__+':',err.args.length > 0 ? err.args[0]: '' )
throw err}}}else{
return pyobj}}
var $JSObjectDict={__class__:$B.$type,__name__:'JSObject',toString:function(){return '(JSObject)'}}
$JSObjectDict.__bool__=function(self){return(new Boolean(self.js)).valueOf()}
$JSObjectDict.__delattr__=function(self,attr){_b_.getattr(self,attr)
delete self.js[attr]
return _b_.None}
$JSObjectDict.__dir__=function(self){return Object.keys(self.js)}
$JSObjectDict.__getattribute__=function(self,attr){if(attr.substr(0,2)=='$$')attr=attr.substr(2)
if(self.js===null)return $ObjectDict.__getattribute__(None,attr)
if(attr==='__class__')return $JSObjectDict
if(self.__class__===$JSObjectDict && attr=="$bind" &&
self.js[attr]===undefined &&
self.js['addEventListener']!==undefined){attr='addEventListener'}
var js_attr=self.js[attr]
if(self.js_func && self.js_func[attr]!==undefined){js_attr=self.js_func[attr]}
if(js_attr !==undefined){if(typeof js_attr=='function'){
var res=function(){
var args=[]
for(var i=0,_len_i=arguments.length;i < _len_i;i++){if(arguments[i]!==null && arguments[i].$nat!=undefined){
throw TypeError("A Javascript function can't "+
"take keyword arguments")}else{args.push(pyobj2jsobj(arguments[i]))}}
if(attr==='replace' && self.js===location){location.replace(args[0])
return}
var new_this=self.js;
if(self.js_func){
new_this=self.js_func;}
if(this !==null && this !==undefined && this !==_window){new_this=this}
var result=js_attr.apply(new_this,args)
if(result===undefined){result=this}
return $B.$JS2Py(result)}
res.__repr__=function(){return '<function '+attr+'>'}
res.__str__=function(){return '<function '+attr+'>'}
res.prototype=js_attr.prototype
return{__class__:$JSObjectDict,js:res,js_func:js_attr}}else{if(Array.isArray(js_attr)){return js_attr}
return $B.$JS2Py(js_attr)}}else if(self.js===_window && attr==='$$location'){
return $Location()}
var res=self.__class__[attr]
if(res===undefined){
var mro=self.__class__.__mro__
for(var i=0,_len_i=mro.length;i < _len_i;i++){var v=mro[i][attr]
if(v!==undefined){res=v
break}}}
if(res!==undefined){if(typeof res==='function'){
return function(){var args=[self]
for(var i=0,_len_i=arguments.length;i < _len_i;i++){arg=arguments[i]
if(arg &&(arg.__class__===$JSObjectDict ||arg.__class__===$JSConstructorDict)){args.push(arg.js)}else{args.push(arg)}}
return res.apply(self,args)}}
return $B.$JS2Py(res)}else{
throw _b_.AttributeError("no attribute "+attr+' for '+self.js)}}
$JSObjectDict.__getitem__=function(self,rank){if(typeof self.js.length=='number'){if((typeof rank=="number" ||typeof rank=="boolean")&&
typeof self.js.item=='function'){var rank_to_int=_b_.int(rank)
if(rank_to_int<0){rank_to_int+=self.js.length}
var res=JSObject(self.js.item(rank_to_int))
if(res===undefined){throw _b_.KeyError(rank)}
return res}else if(typeof rank=="string" &&
typeof self.js.getNamedItem=='function'){var res=JSObject(self.js.getNamedItem(rank))
if(res===undefined){throw _b_.keyError(rank)}
return res}}
try{return getattr(self.js,'__getitem__')(rank)}
catch(err){if(self.js[rank]!==undefined){return JSObject(self.js[rank])}
throw _b_.KeyError(rank)}}
var $JSObject_iterator=$B.$iterator_class('JS object iterator')
$JSObjectDict.__iter__=function(self){var items=[]
if(_window.Symbol && self.js[Symbol.iterator]!==undefined){
if(self.js.length!==undefined && self.js.item!==undefined){for(var i=0;i<self.js.length ;i++){items.push(JSObject(self.js[i]))}}else{for(var item in self.js){if(self.js.hasOwnProperty(item )){items.push(jsobj2pyobj(item))}}}
return $B.$iterator(items,$JSObject_iterator)}else if(self.js.length!==undefined && self.js.item !==undefined){
for(var i=0;i<self.js.length ;i++){items.push(JSObject(self.js[i]))}
return $B.$iterator(items,$JSObject_iterator)}
var _dict=$JSObjectDict.to_dict(self)
return _b_.dict.$dict.__iter__(_dict)}
$JSObjectDict.__len__=function(self){if(typeof self.js.length=='number'){return self.js.length}
try{return getattr(self.js,'__len__')()}
catch(err){throw _b_.AttributeError(self.js+' has no attribute __len__')}}
$JSObjectDict.__mro__=[$ObjectDict]
$JSObjectDict.__repr__=function(self){if(self.js instanceof Date){return self.js.toString()}
var proto=Object.getPrototypeOf(self.js)
if(proto){var name=proto.constructor.name
if(name===undefined){
var proto_str=proto.constructor.toString()
name=proto_str.substring(8,proto_str.length-1)}
return "<"+name+" object>"}
return "<JSObject wraps "+self.js+">"}
$JSObjectDict.__setattr__=function(self,attr,value){if(attr.substr(0,2)=='$$'){
attr=attr.substr(2)}
if(isinstance(value,JSObject)){self.js[attr]=value.js}
else{self.js[attr]=value
if(typeof value=='function'){self.js[attr]=function(){var args=[]
for(var i=0,len=arguments.length;i<len;i++){args.push($B.$JS2Py(arguments[i]))}
try{return value.apply(null,args)}
catch(err){err=$B.exception(err)
var info=_b_.getattr(err,'info')
if(err.args.length > 0){err.toString=function(){return info+'\n'+err.__class__.__name__+
': '+_b_.repr(err.args[0])}}else{
err.toString=function(){return info+'\n'+err.__class__.__name__}}
console.log(err+'')
throw err}}}}}
$JSObjectDict.__setitem__=$JSObjectDict.__setattr__
$JSObjectDict.__str__=$JSObjectDict.__repr__
var no_dict={'string':true,'function':true,'number':true,'boolean':true}
$JSObjectDict.bind=function(self,evt,func){self.js.addEventListener(evt,func)
return _b_.None}
$JSObjectDict.to_dict=function(self){
var res=_b_.dict()
for(var key in self.js){var value=self.js[key]
if(typeof value=='object' && !Array.isArray(value)){_b_.dict.$dict.__setitem__(res,key,$JSObjectDict.to_dict(JSObject(value)))}else{_b_.dict.$dict.__setitem__(res,key,value)}}
return res}
function JSObject(obj){if(obj===null){return _b_.None}
if(typeof obj=='function'){return{__class__:$JSObjectDict,js:obj,js_func:obj}}
var klass=$B.get_class(obj)
if(klass===_b_.float.$dict)return _b_.float(obj)
if(klass!==undefined)return obj
return{__class__:$JSObjectDict,js:obj}}
JSObject.__class__=$B.$factory
JSObject.$dict=$JSObjectDict
$JSObjectDict.$factory=JSObject
$B.JSObject=JSObject
$B.JSConstructor=JSConstructor})(__BRYTHON__)
;(function($B){$B.stdlib={}
var pylist=['VFS_import','__future__','_abcoll','_codecs','_collections','_csv','_dummy_thread','_functools','_imp','_io','_markupbase','_random','_socket','_sre','_string','_strptime','_struct','_sysconfigdata','_testcapi','_thread','_threading_local','_warnings','_weakref','_weakrefset','abc','antigravity','argparse','atexit','base64','bdb','binascii','bisect','calendar','cmath','cmd','code','codecs','codeop','colorsys','configparser','Clib','copy','copyreg','csv','datetime','decimal','difflib','doctest','errno','external_import','fnmatch','formatter','fractions','functools','gc','genericpath','getopt','gettext','glob','heapq','imp','inspect','io','itertools','keyword','linecache','locale','marshal','numbers','opcode','operator','optparse','os','pdb','pickle','platform','posix','posixpath','pprint','profile','pwd','pydoc','queue','re','reprlib','select','shutil','signal','site','site-packages.__future__','site-packages.docs','site-packages.header','site-packages.test_sp','socket','sre_compile','sre_constants','sre_parse','stat','string','struct','subprocess','sys','sysconfig','tarfile','tempfile','test.namespace_pkgs.module_and_namespace_package.a_test','textwrap','this','threading','time','timeit','token','tokenize','traceback','turtle','types','uuid','warnings','weakref','webbrowser','zipfile','zlib']
for(var i=0;i<pylist.length;i++)$B.stdlib[pylist[i]]=['py']
var js=['_ajax','_base64','_jsre','_multiprocessing','_posixsubprocess','_profile','_svg','_sys','aes','builtins','dis','hashlib','hmac-md5','hmac-ripemd160','hmac-sha1','hmac-sha224','hmac-sha256','hmac-sha3','hmac-sha384','hmac-sha512','json','long_int','math','md5','modulefinder','pbkdf2','rabbit','rabbit-legacy','random','rc4','ripemd160','sha1','sha224','sha256','sha3','sha384','sha512','tripledes']
for(var i=0;i<js.length;i++)$B.stdlib[js[i]]=['js']
var pkglist=['asyncio','browser','collections','concurrent','concurrent.futures','encodings','html','http','importlib','jqueryui','logging','multiprocessing','multiprocessing.dummy','pydoc_data','site-packages.simpleaio','site-packages.ui','test','test.encoded_modules','test.leakers','test.namespace_pkgs.not_a_namespace_pkg.foo','test.support','test.test_email','test.test_importlib','test.test_importlib.builtin','test.test_importlib.extension','test.test_importlib.frozen','test.test_importlib.import_','test.test_importlib.source','test.test_json','test.tracedmodules','unittest','unittest.test','unittest.test.testmock','urllib','xml','xml.etree','xml.parsers','xml.sax']
for(var i=0;i<pkglist.length;i++)$B.stdlib[pkglist[i]]=['py',true]})(__BRYTHON__)
;(function($B){var _b_=$B.builtins
var _window=self;
$B.$ModuleDict={__class__ : $B.$type,__name__ : 'module'}
$B.$ModuleDict.__repr__=$B.$ModuleDict.__str__=function(self){return '<module '+self.__name__+'>'}
$B.$ModuleDict.__mro__=[_b_.object.$dict]
$B.$ModuleDict.__setattr__=function(self,attr,value){if(self.__name__=='__builtins__'){
$B.builtins[attr]=value}else{self[attr]=value}}
function module(name,doc,$package){return{__class__:$B.$ModuleDict,__name__:name,__doc__:doc||_b_.None,__package__:$package||_b_.None}}
module.__class__=$B.$factory
module.$dict=$B.$ModuleDict
$B.$ModuleDict.$factory=module
var loader=function(){}
var Loader={__class__:$B.$type,__name__ : 'Loader'}
Loader.__mro__=[_b_.object.$dict]
Loader.$factory=loader
loader.$dict=Loader
loader.__class__=$B.$factory
function parent_package(mod_name){var parts=mod_name.split('.');
parts.pop();
return parts.join('.');}
function $importer(){
var $xmlhttp=new XMLHttpRequest();
var fake_qs;
switch($B.$options.cache){case 'version':
fake_qs="?v="+$B.version_info[2]
break;
case 'browser':
fake_qs=''
break;
default:
fake_qs="?v="+(new Date().getTime())}
var timer=setTimeout(function(){$xmlhttp.abort()
throw _b_.ImportError("No module named '"+module+"'")},5000)
return[$xmlhttp,fake_qs,timer]}
function $download_module(module,url,$package){var imp=$importer(),$xmlhttp=imp[0],fake_qs=imp[1],timer=imp[2],res=null,mod_name=module.__name__,res,t0=new Date()
$B.download_time=$B.download_time ||0
$xmlhttp.open('GET',url+fake_qs,false)
if($B.$CORS){$xmlhttp.onload=function(){if($xmlhttp.status==200 ||$xmlhttp.status==0){res=$xmlhttp.responseText}else{
res=_b_.FileNotFoundError("No module named '"+mod_name+"'")}}
$xmlhttp.onerror=function(){res=_b_.FileNotFoundError("No module named '"+mod_name+"'")}}else{
$xmlhttp.onreadystatechange=function(){if(this.readyState==4){_window.clearTimeout(timer)
if(this.status==200 ||$xmlhttp.status==0){res=this.responseText
module.$last_modified=this.getResponseHeader('Last-Modified')}else{
console.log('Error '+this.status+
' means that Python module '+mod_name+
' was not found at url '+url)
res=_b_.FileNotFoundError("No module named '"+mod_name+"'")}}}}
if('overrideMimeType' in $xmlhttp){$xmlhttp.overrideMimeType("text/plain")}
$xmlhttp.send()
if(res==null)throw _b_.FileNotFoundError("No module named '"+mod_name+"' (res is null)")
if(res.constructor===Error){throw res}
$B.download_time +=(new Date())-t0
return res}
$B.$download_module=$download_module
function import_js(module,path){try{var module_contents=$download_module(module,path,undefined)}catch(err){return null}
run_js(module_contents,path,module)
return true}
function run_js(module_contents,path,module){
try{eval(module_contents);
if($B.$options.store){module.$js=module_contents}}catch(err){console.log(err)
throw err}
try{$module}
catch(err){console.log('no $module')
throw _b_.ImportError("name '$module' is not defined in module")}
if(module !==undefined){
for(var attr in $module){module[attr]=$module[attr];}
$module=module;}
else{
$module.__class__=$B.$ModuleDict
$module.__name__=module.name
$module.__repr__=$module.__str__=function(){if($B.builtin_module_names.indexOf(module.name)> -1){return "<module '"+module.name+"' (built-in)>"}
return "<module '"+module.name+"' from "+path+" >"}
if(module.name !='builtins'){
$module.__file__=path}}
$B.imported[module.__name__]=$module
return true}
function show_ns(){var kk=Object.keys(_window)
for(var i=0,_len_i=kk.length;i < _len_i;i++){console.log(kk[i])
if(kk[i].charAt(0)=='$'){console.log(eval(kk[i]))}}
console.log('---')}
function import_py(module,path,$package){
var mod_name=module.__name__,module_contents=$download_module(module,path,$package)
$B.imported[mod_name].$is_package=module.$is_package
$B.imported[mod_name].$last_modified=module.$last_modified
if(path.substr(path.length-12)=='/__init__.py'){
$B.imported[mod_name].__package__=mod_name
$B.imported[mod_name].__path__=path
$B.imported[mod_name].$is_package=module.$is_package=true}else if($package){$B.imported[mod_name].__package__=$package}else{var mod_elts=mod_name.split('.')
mod_elts.pop()
$B.imported[mod_name].__package__=mod_elts.join('.')}
$B.imported[mod_name].__file__=path
return run_py(module_contents,path,module)}
function run_py(module_contents,path,module,compiled){var root,js
if(!compiled){var $Node=$B.$Node,$NodeJSCtx=$B.$NodeJSCtx
$B.$py_module_path[module.__name__]=path
root=$B.py2js(module_contents,module.__name__,module.__name__,'__builtins__')
var body=root.children
root.children=[]
var mod_node=new $Node('expression')
new $NodeJSCtx(mod_node,'var $module=(function()')
root.insert(0,mod_node)
for(var i=0,_len_i=body.length;i < _len_i;i++){mod_node.add(body[i])}
var ret_node=new $Node('expression')
new $NodeJSCtx(ret_node,'return $locals_'+module.__name__.replace(/\./g,'_'))
mod_node.add(ret_node)
var ex_node=new $Node('expression')
new $NodeJSCtx(ex_node,')(__BRYTHON__)')
root.add(ex_node)}
try{js=(compiled)? module_contents : root.to_js()
if($B.$options.debug==10){console.log('code for module '+module.__name__)
console.log(js)}
eval(js)}catch(err){console.log(err+' for module '+module.__name__)
console.log(err)
for(var attr in err){console.log(attr,err[attr])}
console.log(_b_.getattr(err,'info','[no info]'))
console.log('message: '+err.$message)
console.log('filename: '+err.fileName)
console.log('linenum: '+err.lineNumber)
if($B.debug>0){console.log('line info '+ $B.line_info)}
throw err}finally{root=null
js=null
$B.clear_ns(module.__name__)}
try{
var mod=eval('$module')
for(var attr in mod){module[attr]=mod[attr];}
module.__initializing__=false
$B.imported[module.__name__]=module
return true}catch(err){console.log(''+err+' '+' for module '+module.name)
for(var attr in err)console.log(attr+' '+err[attr])
if($B.debug>0){console.log('line info '+__BRYTHON__.line_info)}
throw err}}
$B.run_py=run_py
function new_spec(fields){
fields.__class__=$B.$ModuleDict
return fields;}
function finder_VFS(){return{__class__:finder_VFS.$dict}}
finder_VFS.__class__=$B.$factory
finder_VFS.$dict={$factory: finder_VFS,__class__: $B.$type,__name__: 'VFSFinder',create_module : function(cls,spec){
return _b_.None;},exec_module : function(cls,module){var stored=module.__spec__.loader_state.stored;
delete module.__spec__['loader_state'];
var ext=stored[0],module_contents=stored[1];
module.$is_package=stored[2]||false;
var path=$B.brython_path+'Lib/'+module.__name__
if(module.$is_package){path +='/__init__.py'}
module.__file__=path
if(ext=='.js'){run_js(module_contents,module.__path__,module)}
else{
run_py(module_contents,module.__path__,module,ext=='.pyc.js')}
if($B.debug>1){console.log('import '+module.__name__+' from VFS')}},find_module: function(cls,name,path){return{__class__:Loader,load_module:function(name,path){var spec=cls.$dict.find_spec(cls,name,path)
var mod=module(name)
$B.imported[name]=mod
mod.__spec__=spec
cls.$dict.exec_module(cls,mod)}}},find_spec : function(cls,fullname,path,prev_module){if(!$B.use_VFS){return _b_.None;}
var stored=$B.VFS[fullname];
if(stored===undefined){return _b_.None;}
var is_package=stored[2],is_builtin=$B.builtin_module_names.indexOf(fullname)> -1;
return new_spec({name : fullname,loader: cls,
origin : is_builtin? 'built-in' : 'brython_stdlib',
submodule_search_locations: is_package?[]: _b_.None,loader_state:{stored: stored},
cached: _b_.None,parent: is_package? fullname : parent_package(fullname),has_location: _b_.False});}}
finder_VFS.$dict.__mro__=[_b_.object.$dict]
finder_VFS.$dict.create_module.$type='classmethod'
finder_VFS.$dict.exec_module.$type='classmethod'
finder_VFS.$dict.find_module.$type='classmethod'
finder_VFS.$dict.find_spec.$type='classmethod'
function finder_stdlib_static(){return{__class__:finder_stdlib_static.$dict}}
finder_stdlib_static.__class__=$B.$factory
finder_stdlib_static.$dict={$factory : finder_stdlib_static,__class__ : $B.$type,__name__ : 'StdlibStatic',create_module : function(cls,spec){
return _b_.None;},exec_module : function(cls,module){var metadata=module.__spec__.loader_state;
module.$is_package=metadata.is_package;
if(metadata.ext=='py'){import_py(module,metadata.path,module.__package__);}
else{
import_js(module,metadata.path);}
delete module.__spec__['loader_state'];},find_module: function(cls,name,path){var spec=cls.$dict.find_spec(cls,name,path)
if(spec===_b_.None){return _b_.None}
return{__class__:Loader,load_module:function(name,path){var mod=module(name)
$B.imported[name]=mod
mod.__spec__=spec
mod.__package__=spec.parent
cls.$dict.exec_module(cls,mod)}}},find_spec: function(cls,fullname,path,prev_module){if($B.stdlib && $B.$options.static_stdlib_import){var address=$B.stdlib[fullname];
if(address===undefined){var elts=fullname.split('.')
if(elts.length>1){elts.pop()
var $package=$B.stdlib[elts.join('.')]
if($package && $package[1]){address=['py']}}}
if(address !==undefined){var ext=address[0],is_pkg=address[1]!==undefined,path=$B.brython_path +((ext=='py')? 'Lib/' : 'libs/')+
fullname.replace(/\./g,'/'),metadata={ext: ext,is_package: is_pkg,path: path +(is_pkg? '/__init__.py' :
((ext=='py')? '.py' : '.js')),address: address}
var res=new_spec(
{name : fullname,loader: cls,
origin : metadata.path,submodule_search_locations: is_pkg?[path]: _b_.None,loader_state: metadata,
cached: _b_.None,parent: is_pkg? fullname :
parent_package(fullname),has_location: _b_.True});
return res}}
return _b_.None;}}
finder_stdlib_static.$dict.__mro__=[_b_.object.$dict]
finder_stdlib_static.$dict.create_module.$type='classmethod'
finder_stdlib_static.$dict.exec_module.$type='classmethod'
finder_stdlib_static.$dict.find_module.$type='classmethod'
finder_stdlib_static.$dict.find_spec.$type='classmethod'
function finder_path(){return{__class__:finder_path.$dict}}
finder_path.__class__=$B.$factory
finder_path.$dict={$factory: finder_path,__class__: $B.$type,__name__: 'ImporterPath',create_module : function(cls,spec){
return _b_.None;},exec_module : function(cls,module){var _spec=_b_.getattr(module,'__spec__'),code=_spec.loader_state.code;
module.$is_package=_spec.loader_state.is_package,delete _spec.loader_state['code'];
var src_type=_spec.loader_state.type
if(src_type=='py' ||src_type=='pyc.js'){run_py(code,_spec.origin,module,src_type=='pyc.js');}
else if(_spec.loader_state.type=='js'){run_js(code,_spec.origin,module)}},find_module: function(cls,name,path){return finder_path.$dict.find_spec(cls,name,path)},find_spec : function(cls,fullname,path,prev_module){if($B.is_none(path)){
path=$B.path}
for(var i=0,li=path.length;i<li;++i){var path_entry=path[i];
if(path_entry[path_entry.length - 1]!='/'){path_entry +='/'}
var finder=$B.path_importer_cache[path_entry];
if(finder===undefined){var finder_notfound=true;
for(var j=0,lj=$B.path_hooks.length;
j < lj && finder_notfound;
++j){var hook=$B.path_hooks[j];
try{
finder=(typeof hook=='function' ? hook : _b_.getattr(hook,'__call__'))(path_entry)
finder_notfound=false;}
catch(e){if(e.__class__ !==_b_.ImportError.$dict){throw e;}}}
if(finder_notfound){$B.path_importer_cache[path_entry]=_b_.None;}}
if($B.is_none(finder))
continue;
var find_spec=_b_.getattr(finder,'find_spec'),fs_func=typeof find_spec=='function' ?
find_spec :
_b_.getattr(find_spec,'__call__')
var spec=fs_func(fullname,prev_module);
if(!$B.is_none(spec)){return spec;}}
return _b_.None;}}
finder_path.$dict.__mro__=[_b_.object.$dict]
finder_path.$dict.create_module.$type='classmethod'
finder_path.$dict.exec_module.$type='classmethod'
finder_path.$dict.find_module.$type='classmethod'
finder_path.$dict.find_spec.$type='classmethod'
function vfs_hook(path){if(path.substr(-1)=='/'){path=path.slice(0,-1);}
var ext=path.substr(-7);
if(ext !='.vfs.js'){throw _b_.ImportError('VFS file URL must end with .vfs.js extension');}
self={__class__: vfs_hook.$dict,path: path};
vfs_hook.$dict.load_vfs(self);
return self;}
vfs_hook.__class__=$B.$factory
vfs_hook.$dict={$factory: vfs_hook,__class__: $B.$type,__name__: 'VfsPathFinder',load_vfs: function(self){try{var code=$download_module({__name__:'<VFS>'},self.path)}
catch(e){self.vfs=undefined;
throw new _b_.ImportError(e.$message ||e.message);}
eval(code);
code=null
try{
self.vfs=$vfs;}
catch(e){throw new _b_.ImportError('Expecting $vfs var in VFS file');}
$B.path_importer_cache[self.path + '/']=self;},find_spec: function(self,fullname,module){if(self.vfs===undefined){try{vfs_hook.$dict.load_vfs(self)}
catch(e){console.log("Could not load VFS while importing '" + fullname + "'");
return _b_.None;}}
var stored=self.vfs[fullname];
if(stored===undefined){return _b_.None;}
var is_package=stored[2];
return new_spec({name : fullname,loader: finder_VFS,
origin : self.path + '#' + fullname,
submodule_search_locations: is_package?[self.path]:
_b_.None,loader_state:{stored: stored},
cached: _b_.None,parent: is_package? fullname : parent_package(fullname),has_location: _b_.True});},invalidate_caches: function(self){self.vfs=undefined;}}
vfs_hook.$dict.__mro__=[_b_.object.$dict]
function url_hook(path_entry,hint){return{__class__: url_hook.$dict,path_entry:path_entry,hint:hint }}
url_hook.__class__=$B.$factory
url_hook.$dict={$factory: url_hook,__class__: $B.$type,__name__ : 'UrlPathFinder',__repr__: function(self){return '<UrlPathFinder' +(self.hint? " for '" + self.hint + "'":
"(unbound)")+ ' at ' + self.path_entry + '>'},find_spec : function(self,fullname,module){var loader_data={},notfound=true,hint=self.hint,base_path=self.path_entry + fullname.match(/[^.]+$/g)[0],modpaths=[];
var tryall=hint===undefined;
if(tryall ||hint=='js'){
modpaths=[[base_path + '.js','js',false]];}
if(tryall ||hint=='pyc.js'){
modpaths=modpaths.concat([[base_path + '.pyc.js','pyc.js',false],[base_path + '/__init__.pyc.js','pyc.js',true]]);}
if(tryall ||hint=='py'){
modpaths=modpaths.concat([[base_path + '.py','py',false],[base_path + '/__init__.py','py',true]]);}
for(var j=0;notfound && j < modpaths.length;++j){try{var file_info=modpaths[j],module={__name__:fullname,$is_package: false}
loader_data.code=$download_module(module,file_info[0],undefined);
notfound=false;
loader_data.type=file_info[1];
loader_data.is_package=file_info[2];
if(hint===undefined){self.hint=file_info[1];
$B.path_importer_cache[self.path_entry]=self;}
if(loader_data.is_package){
$B.path_importer_cache[base_path + '/']=
url_hook(base_path + '/',self.hint);}
loader_data.path=file_info[0];}catch(err){}}
if(!notfound){return new_spec({name : fullname,loader: finder_path,origin : loader_data.path,
submodule_search_locations: loader_data.is_package?[base_path]:
_b_.None,loader_state: loader_data,
cached: _b_.None,parent: loader_data.is_package? fullname :
parent_package(fullname),has_location: _b_.True});}
return _b_.None;},invalidate_caches : function(self){}}
url_hook.$dict.__mro__=[_b_.object.$dict]
$B.path_importer_cache={};
var _sys_paths=[[$B.script_dir + '/','py'],[$B.brython_path + 'Lib/','py'],[$B.brython_path + 'Lib/site-packages/','py'],[$B.brython_path + 'libs/','js']];
for(i=0;i < _sys_paths.length;++i){var _path=_sys_paths[i],_type=_path[1];
_path=_path[0];
$B.path_importer_cache[_path]=url_hook(_path,_type);}
delete _path;
delete _type;
delete _sys_paths;
$B.$__import__=function(mod_name,globals,locals,fromlist,level){
var modobj=$B.imported[mod_name],parsed_name=mod_name.split('.');
if(modobj==_b_.None){
throw _b_.ImportError(mod_name)}
if(modobj===undefined){
if($B.is_none(fromlist)){fromlist=[];}
for(var i=0,modsep='',_mod_name='',len=parsed_name.length - 1,__path__=_b_.None;i <=len;++i){var _parent_name=_mod_name;
_mod_name +=modsep + parsed_name[i];
modsep='.';
var modobj=$B.imported[_mod_name];
if(modobj==_b_.None){
throw _b_.ImportError(_mod_name)}
else if(modobj===undefined){try{
$B.import_hooks(_mod_name,__path__,undefined)}catch(err){delete $B.imported[_mod_name]
$B.imported[_mod_name]=null
throw err}
if($B.is_none($B.imported[_mod_name])){throw _b_.ImportError(_mod_name)}
else{
if(_parent_name){_b_.setattr($B.imported[_parent_name],parsed_name[i],$B.imported[_mod_name]);}}}
if(i < len){try{
__path__=_b_.getattr($B.imported[_mod_name],'__path__')}catch(e){
if(i==len-1 && $B.imported[_mod_name][parsed_name[len]]&&
$B.imported[_mod_name][parsed_name[len]].__class__===$B.$ModuleDict){return $B.imported[_mod_name][parsed_name[len]]}
throw _b_.ImportError(_mod_name)}}}}
if(fromlist.length > 0){
return $B.imported[mod_name]}
else{
return $B.imported[parsed_name[0]]}}
$B.$import=function(mod_name,fromlist,aliases,locals){var parts=mod_name.split('.');
if(mod_name[mod_name.length - 1]=='.'){parts.pop()}
var norm_parts=[],prefix=true;
for(var i=0,_len_i=parts.length;i < _len_i;i++){var p=parts[i];
if(prefix && p==''){
elt=norm_parts.pop();
if(elt===undefined){throw _b_.ImportError("Parent module '' not loaded, "+
"cannot perform relative import");}}
else{
prefix=false;
norm_parts.push(p.substr(0,2)=='$$' ? p.substr(2): p)}}
var mod_name=norm_parts.join('.')
if($B.$options.debug==10){console.log('$import '+mod_name)
console.log('use VFS ? '+$B.use_VFS)
console.log('use static stdlib paths ? '+$B.static_stdlib_import)}
var current_frame=$B.frames_stack[$B.frames_stack.length-1],_globals=current_frame[3],__import__=_globals['__import__'],globals=$B.obj_dict(_globals);
if(__import__===undefined){
__import__=$B.$__import__;}
var importer=typeof __import__=='function' ?
__import__ :
_b_.getattr(__import__,'__call__'),modobj=importer(mod_name,globals,undefined,fromlist,0);
if(!fromlist ||fromlist.length==0){
var alias=aliases[mod_name];
if(alias){locals[alias]=$B.imported[mod_name];}
else{
locals[norm_parts[0]]=modobj;}}
else{
var __all__=fromlist,thunk={};
if(fromlist && fromlist[0]=='*'){__all__=_b_.getattr(modobj,'__all__',thunk);
if(__all__ !==thunk){
aliases={};}}
if(__all__===thunk){
for(var attr in modobj){if(attr[0]!=='_'){locals[attr]=modobj[attr];}}}
else{
for(var i=0,l=__all__.length;i < l;++i){var name=__all__[i];
var alias=aliases[name]||name;
try{
locals[alias]=_b_.getattr(modobj,name);}
catch($err1){
try{_b_.getattr(__import__,'__call__')(mod_name + '.' + name,globals,undefined,[],0);
locals[alias]=_b_.getattr(modobj,name);}
catch($err3){
if(mod_name==="__future__"){
var frame=$B.last($B.frames_stack),line_info=frame[3].$line_info,line_elts=line_info.split(','),line_num=parseInt(line_elts[0])
$B.$SyntaxError(frame[2],"future feature "+name+" is not defined",undefined,line_num)}
if($err3.$py_error){var msg=$err3.__class__.__name__ + '\n' +
_b_.getattr($err3,"info")
throw _b_.ImportError("cannot import name '"+
name+"'\n\n" + msg)}
console.log($err3)
throw _b_.ImportError("cannot import name '"+name+"'")}}}}}}
$B.$path_hooks=[vfs_hook,url_hook];
$B.$meta_path=[finder_VFS,finder_stdlib_static,finder_path];
function optimize_import_for_path(path,filetype){if(path.slice(-1)!='/'){path=path + '/' }
var value=(filetype=='none')? _b_.None : url_hook(path,filetype);
$B.path_importer_cache[path]=value;}
_importlib_module={__class__ : $B.$ModuleDict,__name__ : '_importlib',Loader: Loader,VFSFinder: finder_VFS,StdlibStatic: finder_stdlib_static,ImporterPath: finder_path,VFSPathFinder : vfs_hook,UrlPathFinder: url_hook,optimize_import_for_path : optimize_import_for_path}
_importlib_module.__repr__=_importlib_module.__str__=function(){return "<module '_importlib' (built-in)>"}
$B.imported['_importlib']=$B.modules['_importlib']=_importlib_module})(__BRYTHON__)
;(function($B){eval($B.InjectBuiltins())
var $ObjectDict=_b_.object.$dict
function $err(op,other){var msg="unsupported operand type(s) for "+op
msg +=": 'float' and '"+$B.get_class(other).__name__+"'"
throw _b_.TypeError(msg)}
var $FloatDict={__class__:$B.$type,__dir__:$ObjectDict.__dir__,__name__:'float',$native:true,$descriptors:{'numerator':true,'denominator':true,'imag':true,'real':true}}
$FloatDict.numerator=function(self){return self}
$FloatDict.denominator=function(self){return _b_.int(1)}
$FloatDict.imag=function(self){return _b_.int(0)}
$FloatDict.real=function(self){return self}
$FloatDict.__float__=function(self){return self}
$FloatDict.as_integer_ratio=function(self){if(self.valueOf()==Number.POSITIVE_INFINITY ||
self.valueOf()==Number.NEGATIVE_INFINITY){throw _b_.OverflowError("Cannot pass infinity to float.as_integer_ratio.")}
if(!Number.isFinite(self.valueOf())){throw _b_.ValueError("Cannot pass NaN to float.as_integer_ratio.")}
var tmp=_b_.$frexp(self.valueOf())
var fp=tmp[0]
var exponent=tmp[1]
for(var i=0;i < 300;i++){if(fp==Math.floor(fp)){break}else{
fp *=2
exponent--}}
numerator=float(fp)
py_exponent=abs(exponent)
denominator=1
py_exponent=_b_.getattr(int(denominator),"__lshift__")(py_exponent)
if(exponent > 0){numerator=numerator * py_exponent}else{
denominator=py_exponent}
return _b_.tuple([_b_.int(numerator),_b_.int(denominator)])}
$FloatDict.__bool__=function(self){return _b_.bool(self.valueOf())}
$FloatDict.__class__=$B.$type
$FloatDict.__eq__=function(self,other){if(isNaN(self)&& isNaN(other)){return false}
if(isinstance(other,_b_.int))return self==other
if(isinstance(other,float)){
return self.valueOf()==other.valueOf()}
if(isinstance(other,_b_.complex)){if(other.$imag !=0)return false
return self==other.$real}
if(_b_.hasattr(other,'__eq__')){return _b_.getattr(other,'__eq__')(self.value)}
return self.value===other}
$FloatDict.__floordiv__=function(self,other){if(isinstance(other,[_b_.int,float])){if(other.valueOf()==0)throw ZeroDivisionError('division by zero')
return float(Math.floor(self/other))}
if(hasattr(other,'__rfloordiv__')){return getattr(other,'__rfloordiv__')(self)}
$err('//',other)}
$FloatDict.fromhex=function(arg){
if(!isinstance(arg,_b_.str)){throw _b_.ValueError('argument must be a string')}
var value=arg.trim()
switch(value.toLowerCase()){case '+inf':
case 'inf':
case '+infinity':
case 'infinity':
return $FloatClass(Infinity)
case '-inf':
case '-infinity':
return $FloatClass(-Infinity)
case '+nan':
case 'nan':
return $FloatClass(Number.NaN)
case '-nan':
return $FloatClass(-Number.NaN)
case '':
throw _b_.ValueError('count not convert string to float')}
var _m=/^(\d*\.?\d*)$/.exec(value)
if(_m !==null)return $FloatClass(parseFloat(_m[1]))
var _m=/^(\+|-)?(0x)?([0-9A-F]+\.?)?(\.[0-9A-F]+)?(p(\+|-)?\d+)?$/i.exec(value)
if(_m==null)throw _b_.ValueError('invalid hexadecimal floating-point string')
var _sign=_m[1]
var _int=parseInt(_m[3]||'0',16)
var _fraction=_m[4]||'.0'
var _exponent=_m[5]||'p0'
if(_sign=='-'){_sign=-1}else{_sign=1}
var _sum=_int
for(var i=1,_len_i=_fraction.length;i < _len_i;i++){_sum+=parseInt(_fraction.charAt(i),16)/Math.pow(16,i)}
return new Number(_sign * _sum * Math.pow(2,parseInt(_exponent.substring(1))))}
$FloatDict.__getformat__=function(arg){if(arg=='double' ||arg=='float')return 'IEEE, little-endian'
throw _b_.ValueError("__getformat__() argument 1 must be 'double' or 'float'")}
function preformat(self,fmt){if(fmt.empty){return _b_.str(self)}
if(fmt.type && 'eEfFgGn%'.indexOf(fmt.type)==-1){throw _b_.ValueError("Unknown format code '"+fmt.type+
"' for object of type 'float'")}
if(isNaN(self)){if(fmt.type=='f'||fmt.type=='g'){return 'nan'}
else{return 'NAN'}}
if(self==Number.POSITIVE_INFINITY){if(fmt.type=='f'||fmt.type=='g'){return 'inf'}
else{return 'INF'}}
if(fmt.precision===undefined && fmt.type !==undefined){fmt.precision=6}
if(fmt.type=='%'){self *=100}
if(fmt.type=='e'){var res=self.toExponential(fmt.precision),exp=parseInt(res.substr(res.search('e')+1))
if(Math.abs(exp)<10){res=res.substr(0,res.length-1)+'0'+
res.charAt(res.length-1)}
return res}
if(fmt.precision!==undefined){
var prec=fmt.precision
if(prec==0){return Math.round(self)+''}
var res=self.toFixed(prec),pt_pos=res.indexOf('.')
if(fmt.type!==undefined &&
(fmt.type=='%' ||fmt.type.toLowerCase()=='f')){if(pt_pos==-1){res +='.'+'0'.repeat(fmt.precision)}
else{var missing=fmt.precision-res.length+pt_pos+1
if(missing>0)res +='0'.repeat(missing)}}else{var res1=self.toExponential(fmt.precision-1),exp=parseInt(res1.substr(res1.search('e')+1))
if(exp<-4 ||exp>=fmt.precision-1){res=res1
if(Math.abs(exp)<10){res=res.substr(0,res.length-1)+'0'+
res.charAt(res.length-1)}}}}else{var res=_b_.str(self)}
if(fmt.type===undefined||'gGn'.indexOf(fmt.type)!=-1){
while(res.charAt(res.length-1)=='0'){res=res.substr(0,res.length-1)}
if(res.charAt(res.length-1)=='.'){if(fmt.type===undefined){res +='0'}
else{res=res.substr(0,res.length-1)}}}
if(fmt.sign!==undefined){if((fmt.sign==' ' ||fmt.sign=='+')&& self>0){res=fmt.sign+res}}
if(fmt.type=='%'){res+='%'}
return res}
$FloatDict.__format__=function(self,format_spec){var fmt=new $B.parse_format_spec(format_spec)
fmt.align=fmt.align ||'>'
var raw=preformat(self,fmt).split('.'),_int=raw[0]
if(fmt.comma){var len=_int.length,nb=Math.ceil(_int.length/3),chunks=[]
for(var i=0;i<nb;i++){chunks.push(_int.substring(len-3*i-3,len-3*i))}
chunks.reverse()
raw[0]=chunks.join(',')}
return $B.format_width(raw.join('.'),fmt)}
$FloatDict.__hash__=function(self){if(self===undefined){return $FloatDict.__hashvalue__ ||$B.$py_next_hash-- }
var _v=self.valueOf()
if(_v===Infinity)return 314159
if(_v===-Infinity)return -271828
if(isNaN(_v))return 0
if(_v==Math.round(_v))return Math.round(_v)
var r=_b_.$frexp(_v)
r[0]*=Math.pow(2,31)
var hipart=_b_.int(r[0])
r[0]=(r[0]- hipart)* Math.pow(2,31)
var x=hipart + _b_.int(r[0])+(r[1]<< 15)
return x & 0xFFFFFFFF}
_b_.$isninf=function(x){var x1=x
if(isinstance(x,float))x1=x.valueOf()
return x1==-Infinity ||x1==Number.NEGATIVE_INFINITY}
_b_.$isinf=function(x){var x1=x
if(isinstance(x,float))x1=x.valueOf()
return x1==Infinity ||x1==-Infinity ||x1==Number.POSITIVE_INFINITY ||x1==Number.NEGATIVE_INFINITY}
_b_.$fabs=function(x){return x>0?float(x):float(-x)}
_b_.$frexp=function(x){var x1=x
if(isinstance(x,float))x1=x.valueOf()
if(isNaN(x1)||_b_.$isinf(x1)){return[x1,-1]}
if(x1==0)return[0,0]
var sign=1,ex=0,man=x1
if(man < 0.){sign=-sign
man=-man}
while(man < 0.5){man *=2.0
ex--}
while(man >=1.0){man *=0.5
ex++}
man *=sign
return[man ,ex]}
_b_.$ldexp=function(x,i){if(_b_.$isninf(x))return float('-inf')
if(_b_.$isinf(x))return float('inf')
var y=x
if(isinstance(x,float))y=x.valueOf()
if(y==0)return y
var j=i
if(isinstance(i,float))j=i.valueOf()
return y * Math.pow(2,j)}
$FloatDict.hex=function(self){
var DBL_MANT_DIG=53
var TOHEX_NBITS=DBL_MANT_DIG + 3 -(DBL_MANT_DIG+2)%4;
switch(self.valueOf()){case Infinity:
case -Infinity:
case Number.NaN:
case -Number.NaN:
return self
case -0:
return '-0x0.0p0'
case 0:
return '0x0.0p0'}
var _a=_b_.$frexp(_b_.$fabs(self.valueOf()))
var _m=_a[0],_e=_a[1]
var _shift=1 - Math.max(-1021 - _e,0)
_m=_b_.$ldexp(_m,_shift)
_e -=_shift
var _int2hex='0123456789ABCDEF'.split('')
var _s=_int2hex[Math.floor(_m)]
_s+='.'
_m -=Math.floor(_m)
for(var i=0;i <(TOHEX_NBITS-1)/4;i++){_m*=16.0
_s+=_int2hex[Math.floor(_m)]
_m-=Math.floor(_m)}
var _esign='+'
if(_e < 0){_esign='-'
_e=-_e}
if(self.value < 0)return "-0x" + _s + 'p' + _esign + _e;
return "0x" + _s + 'p' + _esign + _e;}
$FloatDict.__init__=function(self,value){self.valueOf=function(){return value.valueOf()}
self.toString=function(){return value+''}
return _b_.None}
$FloatDict.__int__=function(self){return parseInt(self)}
$FloatDict.is_integer=function(self){return _b_.int(self)==self}
$FloatDict.__mod__=function(self,other){
if(other==0){throw ZeroDivisionError('float modulo')}
if(isinstance(other,_b_.int))return new Number((self%other+other)%other)
if(isinstance(other,float)){
var q=Math.floor(self/other),r=self-other*q
return new Number(r)}
if(isinstance(other,_b_.bool)){var bool_value=0;
if(other.valueOf())bool_value=1;
return new Number((self%bool_value+bool_value)%bool_value)}
if(hasattr(other,'__rmod__'))return getattr(other,'__rmod__')(self)
$err('%',other)}
$FloatDict.__mro__=[$ObjectDict]
$FloatDict.__mul__=function(self,other){if(isinstance(other,_b_.int)){if(other.__class__==$B.LongInt.$dict){return new Number(self*parseFloat(other.value))}
return new Number(self*other)}
if(isinstance(other,float))return new Number(self*other)
if(isinstance(other,_b_.bool)){var bool_value=0;
if(other.valueOf())bool_value=1;
return new Number(self*bool_value)}
if(isinstance(other,_b_.complex)){return _b_.complex(float(self*other.$real),float(self*other.$imag))}
if(hasattr(other,'__rmul__'))return getattr(other,'__rmul__')(self)
$err('*',other)}
$FloatDict.__ne__=function(self,other){return !$FloatDict.__eq__(self,other)}
$FloatDict.__neg__=function(self,other){return float(-self)}
$FloatDict.__pos__=function(self){return self}
$FloatDict.__pow__=function(self,other){var other_int=isinstance(other,_b_.int)
if(other_int ||isinstance(other,float)){if(self==1){return self}
if(other==0){return new Number(1)}
if(self==-1 &&
(!isFinite(other)||other.__class__===$B.LongInt.$dict ||!$B.is_safe_int(other))
&& !isNaN(other)){return new Number(1)}
else if(self==0 && isFinite(other)&& other<0){throw _b_.ZeroDivisionError("0.0 cannot be raised to a negative power")}else if(self==Number.NEGATIVE_INFINITY && !isNaN(other)){if(other<0 && other%2==1){return new Number(-0.0)}else if(other<0){return new Number(0)}
else if(other>0 && other%2==1){return Number.NEGATIVE_INFINITY}else{return Number.POSITIVE_INFINITY}}else if(self==Number.POSITIVE_INFINITY && !isNaN(other)){return other>0 ? self : new Number(0)}
if(other==Number.NEGATIVE_INFINITY && !isNaN(self)){return Math.abs(self)<1 ? Number.POSITIVE_INFINITY : new Number(0)}else if(other==Number.POSITIVE_INFINITY && !isNaN(self)){return Math.abs(self)<1 ? new Number(0): Number.POSITIVE_INFINITY}
if(self<0 && !_b_.getattr(other,'__eq__')(_b_.int(other))){
return _b_.complex.$dict.__pow__(_b_.complex(self,0),other)}
return float(Math.pow(self,other))}else if(isinstance(other,_b_.complex)){var preal=Math.pow(self,other.$real),ln=Math.log(self)
return _b_.complex(preal*Math.cos(ln),preal*Math.sin(ln))}
if(hasattr(other,'__rpow__'))return getattr(other,'__rpow__')(self)
$err("** or pow()",other)}
$FloatDict.__repr__=$FloatDict.__str__=function(self){if(self===float)return "<class 'float'>"
if(self.valueOf()==Infinity)return 'inf'
if(self.valueOf()==-Infinity)return '-inf'
if(isNaN(self.valueOf()))return 'nan'
var res=self.valueOf()+''
if(res.indexOf('.')==-1)res+='.0'
return _b_.str(res)}
$FloatDict.__setattr__=function(self,attr,value){if(self.constructor===Number){if($FloatDict[attr]===undefined){throw _b_.AttributeError("'float' object has no attribute '"+attr+"'")}else{throw _b_.AttributeError("'float' object attribute '"+attr+"' is read-only")}}
self[attr]=value
return $N}
$FloatDict.__truediv__=function(self,other){if(isinstance(other,[_b_.int,float])){if(other.valueOf()==0)throw ZeroDivisionError('division by zero')
return float(self/other)}
if(isinstance(other,_b_.complex)){var cmod=other.$real*other.$real+other.$imag*other.$imag
if(cmod==0)throw ZeroDivisionError('division by zero')
return _b_.complex(float(self*other.$real/cmod),float(-self*other.$imag/cmod))}
if(hasattr(other,'__rtruediv__'))return getattr(other,'__rtruediv__')(self)
$err('/',other)}
var $op_func=function(self,other){if(isinstance(other,_b_.int)){if(typeof other=='boolean'){return other ? self-1 : self}else if(other.__class__===$B.LongInt.$dict){return float(self-parseInt(other.value))}else{return float(self-other)}}
if(isinstance(other,float))return float(self-other)
if(isinstance(other,_b_.bool)){var bool_value=0;
if(other.valueOf())bool_value=1;
return float(self-bool_value)}
if(isinstance(other,_b_.complex)){return _b_.complex(self - other.$real,-other.$imag)}
if(hasattr(other,'__rsub__'))return getattr(other,'__rsub__')(self)
$err('-',other)}
$op_func +=''
var $ops={'+':'add','-':'sub'}
for(var $op in $ops){var $opf=$op_func.replace(/-/gm,$op)
$opf=$opf.replace(/__rsub__/gm,'__r'+$ops[$op]+'__')
eval('$FloatDict.__'+$ops[$op]+'__ = '+$opf)}
var $comp_func=function(self,other){if(isinstance(other,_b_.int)){if(other.__class__===$B.LongInt.$dict){return self > parseInt(other.value)}
return self > other.valueOf()}
if(isinstance(other,float))return self > other
if(isinstance(other,_b_.bool)){return self.valueOf()> _b_.bool.$dict.__hash__(other)}
if(hasattr(other,'__int__')||hasattr(other,'__index__')){return $IntDict.__gt__(self,$B.$GetInt(other))}
var inv_op=getattr(other,'__le__',null)
if(inv_op !==null){return inv_op(self)}
var inv_op=getattr(other,'__le__',null)
if(inv_op !==null){return inv_op(self)}
throw _b_.TypeError(
'unorderable types: float() > '+$B.get_class(other).__name__+"()")}
$comp_func +=''
for(var $op in $B.$comps){eval("$FloatDict.__"+$B.$comps[$op]+'__ = '+
$comp_func.replace(/>/gm,$op).
replace(/__gt__/gm,'__'+$B.$comps[$op]+'__').
replace(/__le__/,'__'+$B.$inv_comps[$op]+'__'))}
$B.make_rmethods($FloatDict)
var $notimplemented=function(self,other){throw _b_.TypeError(
"unsupported operand types for OPERATOR: 'float' and '"+
$B.get_class(other).__name__+"'")}
$notimplemented +=''
for(var $op in $B.$operators){
if($B.augmented_assigns[$op]===undefined){var $opfunc='__'+$B.$operators[$op]+'__'
if($FloatDict[$opfunc]===undefined){eval('$FloatDict.'+$opfunc+"="+$notimplemented.replace(/OPERATOR/gm,$op))}}}
function $FloatClass(value){return new Number(value)}
function to_digits(s){
var arabic_digits='\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669',res=''
for(var i=0;i<s.length;i++){var x=arabic_digits.indexOf(s[i])
if(x>-1){res +=x}
else{res +=s[i]}}
return res}
var float=function(value){switch(value){case undefined:
return $FloatClass(0.0)
case Number.MAX_VALUE:
return $FloatClass(Infinity)
case -Number.MAX_VALUE:
return $FloatClass(-Infinity)
case true:
return new Number(1)
case false:
return new Number(0)}
if(typeof value=="number")return new Number(value)
if(isinstance(value,float)){return value}
if(isinstance(value,_b_.bytes)){var s=getattr(value,'decode')('latin-1')
return float(getattr(value,'decode')('latin-1'))}
if(hasattr(value,'__float__')){return $FloatClass(getattr(value,'__float__')())}
if(typeof value=='string'){value=value.trim()
switch(value.toLowerCase()){case '+inf':
case 'inf':
case '+infinity':
case 'infinity':
return Number.POSITIVE_INFINITY
case '-inf':
case '-infinity':
return Number.NEGATIVE_INFINITY
case '+nan':
case 'nan':
return Number.NaN
case '-nan':
return -Number.NaN
case '':
throw _b_.ValueError('count not convert string to float')
default:
value=to_digits(value)
if(isFinite(value))return $FloatClass(eval(value))
else{
_b_.str.$dict.encode(value,'latin-1')
throw _b_.ValueError("Could not convert to float(): '"+_b_.str(value)+"'")}}}
throw _b_.TypeError("float() argument must be a string or a number, not '"+
$B.get_class(value).__name__+"'")}
float.__class__=$B.$factory
float.$dict=$FloatDict
$FloatDict.$factory=float
$FloatDict.__new__=function(cls){if(cls===undefined){throw _b_.TypeError('float.__new__(): not enough arguments')}
return{__class__:cls.$dict}}
$B.$FloatClass=$FloatClass
var $FloatSubclassDict={__class__:$B.$type,__name__:'float'}
for(var $attr in $FloatDict){if(typeof $FloatDict[$attr]=='function'){$FloatSubclassDict[$attr]=(function(attr){return function(){var args=[],pos=0
if(arguments.length>0){var args=[arguments[0].valueOf()],pos=1
for(var i=1,_len_i=arguments.length;i < _len_i;i++){args[pos++]=arguments[i]}}
return $FloatDict[attr].apply(null,args)}})($attr)}}
$FloatSubclassDict.__mro__=[$ObjectDict]
$B.$FloatSubclassFactory={__class__:$B.$factory,$dict:$FloatSubclassDict}
_b_.float=float})(__BRYTHON__)
;(function($B){eval($B.InjectBuiltins())
var $ObjectDict=_b_.object.$dict,$N=_b_.None
function $err(op,other){var msg="unsupported operand type(s) for "+op
msg +=": 'int' and '"+$B.get_class(other).__name__+"'"
throw _b_.TypeError(msg)}
var $IntDict={__class__:$B.$type,__name__:'int',__dir__:$ObjectDict.__dir__,$native:true,$descriptors:{'numerator':true,'denominator':true,'imag':true,'real':true}}
$IntDict.from_bytes=function(){var $=$B.args("from_bytes",3,{bytes:null,byteorder:null,signed:null},['bytes','byteorder','signed'],arguments,{signed:False},null,null)
var x=$.bytes,byteorder=$.byteorder,signed=$.signed
var _bytes,_len
if(isinstance(x,[_b_.list,_b_.tuple])){_bytes=x
_len=len(x)}else if(isinstance(x,[_b_.bytes,_b_.bytearray])){_bytes=x.source
_len=x.source.length}else{
_b_.TypeError("Error! " + _b_.type(x)+ " is not supported in int.from_bytes. fix me!")}
switch(byteorder){case 'big':
var num=_bytes[_len - 1];
var _mult=256
for(var i=(_len - 2);i >=0;i--){
num=$B.add($B.mul(_mult,_bytes[i]),num)
_mult=$B.mul(_mult,256)}
if(!signed)return num
if(_bytes[0]< 128)return num
return $B.sub(num,_mult)
case 'little':
var num=_bytes[0]
if(num >=128)num=num - 256
var _mult=256
for(var i=1;i < _len;i++){num=$B.add($B.mul(_mult,_bytes[i]),num)
_mult=$B.mul(_mult,256)}
if(!signed)return num
if(_bytes[_len - 1]< 128)return num
return $B.sub(num,_mult)}
throw _b_.ValueError("byteorder must be either 'little' or 'big'");}
$IntDict.to_bytes=function(length,byteorder,star){
throw _b_.NotImplementedError("int.to_bytes is not implemented yet")}
$IntDict.__abs__=function(self){return abs(self)}
$IntDict.__bool__=function(self){return new Boolean(self.valueOf())}
$IntDict.__ceil__=function(self){return Math.ceil(self)}
$IntDict.__class__=$B.$type
$IntDict.__divmod__=function(self,other){return divmod(self,other)}
$IntDict.__eq__=function(self,other){
if(other===undefined)return self===int
if(isinstance(other,int))return self.valueOf()==other.valueOf()
if(isinstance(other,_b_.float))return self.valueOf()==other.valueOf()
if(isinstance(other,_b_.complex)){if(other.$imag !=0)return False
return self.valueOf()==other.$real}
if(hasattr(other,'__eq__'))return getattr(other,'__eq__')(self)
return self.valueOf()===other}
$IntDict.__float__=function(self){return new Number(self)}
function preformat(self,fmt){if(fmt.empty){return _b_.str(self)}
if(fmt.type && 'bcdoxXn'.indexOf(fmt.type)==-1){throw _b_.ValueError("Unknown format code '"+fmt.type+
"' for object of type 'int'")}
switch(fmt.type){case undefined:
case 'd':
return self.toString()
case 'b':
return(fmt.alternate ? '0b' : '')+ self.toString(2)
case 'c':
return _b_.chr(self)
case 'o':
return(fmt.alternate ? '0o' : '')+ self.toString(8)
case 'x':
return(fmt.alternate ? '0x' : '')+ self.toString(16)
case 'X':
return(fmt.alternate ? '0X' : '')+ self.toString(16).toUpperCase()
case 'n':
return self }
return res}
$IntDict.__format__=function(self,format_spec){var fmt=new $B.parse_format_spec(format_spec)
if(fmt.type && 'eEfFgG%'.indexOf(fmt.type)!=-1){
return _b_.float.$dict.__format__(self,format_spec)}
fmt.align=fmt.align ||'>'
var res=preformat(self,fmt)
if(fmt.comma){var sign=res[0]=='-' ? '-' : '',rest=res.substr(sign.length),len=rest.length,nb=Math.ceil(rest.length/3),chunks=[]
for(var i=0;i<nb;i++){chunks.push(rest.substring(len-3*i-3,len-3*i))}
chunks.reverse()
res=sign+chunks.join(',')}
return $B.format_width(res,fmt)}
$IntDict.__floordiv__=function(self,other){if(isinstance(other,int)){if(other==0)throw ZeroDivisionError('division by zero')
return Math.floor(self/other)}
if(isinstance(other,_b_.float)){if(!other.valueOf())throw ZeroDivisionError('division by zero')
return Math.floor(self/other)}
if(hasattr(other,'__rfloordiv__')){return getattr(other,'__rfloordiv__')(self)}
$err("//",other)}
$IntDict.__hash__=function(self){if(self===undefined){return $IntDict.__hashvalue__ ||$B.$py_next_hash-- }
return self.valueOf()}
$IntDict.__index__=function(self){return self}
$IntDict.__init__=function(self,value){if(value===undefined){value=0}
self.toString=function(){return value}
return $N}
$IntDict.__int__=function(self){return self}
$IntDict.__invert__=function(self){return ~self}
$IntDict.__lshift__=function(self,other){if(isinstance(other,int)){return int($B.LongInt.$dict.__lshift__($B.LongInt(self),$B.LongInt(other)))}
var rlshift=getattr(other,'__rlshift__',null)
if(rlshift!==null){return rlshift(self)}
$err('<<',other)}
$IntDict.__mod__=function(self,other){
if(isinstance(other,_b_.tuple)&& other.length==1)other=other[0]
if(isinstance(other,[int,_b_.float,bool])){if(other===false){other=0}else if(other===true){other=1}
if(other==0){throw _b_.ZeroDivisionError(
"integer division or modulo by zero")}
return(self%other+other)%other}
if(hasattr(other,'__rmod__'))return getattr(other,'__rmod__')(self)
$err('%',other)}
$IntDict.__mro__=[$ObjectDict]
$IntDict.__mul__=function(self,other){var val=self.valueOf()
if(typeof other==="string"){return other.repeat(val)}
if(isinstance(other,int)){var res=self*other
if(res>$B.min_int && res<$B.max_int){return res}
else{return int($B.LongInt.$dict.__mul__($B.LongInt(self),$B.LongInt(other)))}}
if(isinstance(other,_b_.float)){return new Number(self*other)}
if(isinstance(other,_b_.bool)){if(other.valueOf())return self
return int(0)}
if(isinstance(other,_b_.complex)){return _b_.complex($IntDict.__mul__(self,other.$real),$IntDict.__mul__(self,other.$imag))}
if(isinstance(other,[_b_.list,_b_.tuple])){var res=[]
var $temp=other.slice(0,other.length)
for(var i=0;i<val;i++)res=res.concat($temp)
if(isinstance(other,_b_.tuple))res=_b_.tuple(res)
return res}
if(hasattr(other,'__rmul__'))return getattr(other,'__rmul__')(self)
$err("*",other)}
$IntDict.__name__='int'
$IntDict.__neg__=function(self){return -self}
$IntDict.__new__=function(cls){if(cls===undefined){throw _b_.TypeError('int.__new__(): not enough arguments')}
return{__class__:cls.$dict}}
$IntDict.__pos__=function(self){return self}
$IntDict.__pow__=function(self,other,z){if(isinstance(other,int)){switch(other.valueOf()){case 0:
return int(1)
case 1:
return int(self.valueOf())}
if(z !==undefined && z !==null){
var res=(self % z + z)% z
for(var i=1;i<other;i++){res *=self
res=(res % z + z)% z}
return res}
var res=Math.pow(self.valueOf(),other.valueOf())
if(res>$B.min_int && res<$B.max_int){return res}
else if(res !==Infinity && !isFinite(res)){return res}
else{return int($B.LongInt.$dict.__pow__($B.LongInt(self),$B.LongInt(other)))}}
if(isinstance(other,_b_.float)){if(self>=0){return new Number(Math.pow(self,other.valueOf()))}
else{
return _b_.complex.$dict.__pow__(_b_.complex(self,0),other)}}else if(isinstance(other,_b_.complex)){var preal=Math.pow(self,other.$real),ln=Math.log(self)
return _b_.complex(preal*Math.cos(ln),preal*Math.sin(ln))}
if(hasattr(other,'__rpow__'))return getattr(other,'__rpow__')(self)
$err("**",other)}
$IntDict.__repr__=function(self){if(self===int)return "<class 'int'>"
return self.toString()}
$IntDict.__rshift__=function(self,other){if(isinstance(other,int)){return int($B.LongInt.$dict.__rshift__($B.LongInt(self),$B.LongInt(other)))}
var rrshift=getattr(other,'__rrshift__',null)
if(rrshift!==null){return rrshift(self)}
$err('>>',other)}
$IntDict.__setattr__=function(self,attr,value){if(typeof self=="number"){if($IntDict[attr]===undefined){throw _b_.AttributeError("'int' object has no attribute '"+attr+"'")}else{throw _b_.AttributeError("'int' object attribute '"+attr+"' is read-only")}}
self[attr]=value
return $N}
$IntDict.__str__=$IntDict.__repr__
$IntDict.__truediv__=function(self,other){if(isinstance(other,int)){if(other==0)throw ZeroDivisionError('division by zero')
if(other.__class__==$B.LongInt.$dict){return new Number(self/parseInt(other.value))}
return new Number(self/other)}
if(isinstance(other,_b_.float)){if(!other.valueOf())throw ZeroDivisionError('division by zero')
return new Number(self/other)}
if(isinstance(other,_b_.complex)){var cmod=other.$real*other.$real+other.$imag*other.$imag
if(cmod==0)throw ZeroDivisionError('division by zero')
return _b_.complex(self*other.$real/cmod,-self*other.$imag/cmod)}
if(hasattr(other,'__rtruediv__'))return getattr(other,'__rtruediv__')(self)
$err("/",other)}
$IntDict.bit_length=function(self){s=bin(self)
s=getattr(s,'lstrip')('-0b')
return s.length }
$IntDict.numerator=function(self){return self}
$IntDict.denominator=function(self){return int(1)}
$IntDict.imag=function(self){return int(0)}
$IntDict.real=function(self){return self}
$B.max_int32=(1<<30)* 2 - 1
$B.min_int32=- $B.max_int32
var $op_func=function(self,other){if(isinstance(other,int)){if(other.__class__===$B.LongInt.$dict){return $B.LongInt.$dict.__sub__($B.LongInt(self),$B.LongInt(other))}
if(self > $B.max_int32 ||self < $B.min_int32 ||
other > $B.max_int32 ||other < $B.min_int32){return $B.LongInt.$dict.__sub__($B.LongInt(self),$B.LongInt(other))}
return self-other}
if(isinstance(other,_b_.bool))return self-other
if(hasattr(other,'__rsub__'))return getattr(other,'__rsub__')(self)
$err("-",other)}
$op_func +=''
var $ops={'&':'and','|':'or','^':'xor'}
for(var $op in $ops){var opf=$op_func.replace(/-/gm,$op)
opf=opf.replace(new RegExp('sub','gm'),$ops[$op])
eval('$IntDict.__'+$ops[$op]+'__ = '+opf)}
var $op_func=function(self,other){if(isinstance(other,int)){if(typeof other=='number'){var res=self.valueOf()-other.valueOf()
if(res>=$B.min_int && res<=$B.max_int){return res}
else{return $B.LongInt.$dict.__sub__($B.LongInt(self),$B.LongInt(other))}}else if(typeof other=="boolean"){return other ? self-1 : self}else{return $B.LongInt.$dict.__sub__($B.LongInt(self),$B.LongInt(other))}}
if(isinstance(other,_b_.float)){return new Number(self-other)}
if(isinstance(other,_b_.complex)){return _b_.complex(self-other.$real,-other.$imag)}
if(isinstance(other,_b_.bool)){var bool_value=0;
if(other.valueOf())bool_value=1;
return self-bool_value}
if(isinstance(other,_b_.complex)){return _b_.complex(self.valueOf()- other.$real,other.$imag)}
if(hasattr(other,'__rsub__'))return getattr(other,'__rsub__')(self)
throw $err('-',other)}
$op_func +=''
var $ops={'+':'add','-':'sub'}
for(var $op in $ops){var opf=$op_func.replace(/-/gm,$op)
opf=opf.replace(new RegExp('sub','gm'),$ops[$op])
eval('$IntDict.__'+$ops[$op]+'__ = '+opf)}
var $comp_func=function(self,other){if(other.__class__===$B.LongInt.$dict){return $B.LongInt.$dict.__lt__(other,$B.LongInt(self))}
if(isinstance(other,int))return self.valueOf()> other.valueOf()
if(isinstance(other,_b_.float))return self.valueOf()> other.valueOf()
if(isinstance(other,_b_.bool)){return self.valueOf()> _b_.bool.$dict.__hash__(other)}
if(hasattr(other,'__int__')||hasattr(other,'__index__')){return $IntDict.__gt__(self,$B.$GetInt(other))}
var inv_op=getattr(other,'__lt__',null)
if(inv_op !==null){return inv_op(self)}
throw _b_.TypeError(
"unorderable types: int() > "+$B.get_class(other).__name__+"()")}
$comp_func +=''
for(var $op in $B.$comps){eval("$IntDict.__"+$B.$comps[$op]+'__ = '+
$comp_func.replace(/>/gm,$op).
replace(/__gt__/gm,'__'+$B.$comps[$op]+'__').
replace(/__lt__/,'__'+$B.$inv_comps[$op]+'__'))}
$B.make_rmethods($IntDict)
var $valid_digits=function(base){var digits=''
if(base===0)return '0'
if(base < 10){for(var i=0;i < base;i++)digits+=String.fromCharCode(i+48)
return digits}
var digits='0123456789'
for(var i=10;i < base;i++)digits+=String.fromCharCode(i+55)
return digits}
var int=function(value,base){
if(value===undefined){return 0}
if(typeof value=='number' &&
(base===undefined ||base==10)){return parseInt(value)}
if(base!==undefined){if(!isinstance(value,[_b_.str,_b_.bytes,_b_.bytearray])){throw TypeError("int() can't convert non-string with explicit base")}}
if(isinstance(value,_b_.complex)){throw TypeError("can't convert complex to int")}
var $ns=$B.args('int',2,{x:null,base:null},['x','base'],arguments,{'base':10},'null','null')
var value=$ns['x']
var base=$ns['base']
if(isinstance(value,_b_.float)&& base===10){if(value<$B.min_int ||value>$B.max_int){return $B.LongInt.$dict.$from_float(value)}
else{return value>0 ? Math.floor(value): Math.ceil(value)}}
if(!(base >=2 && base <=36)){
if(base !=0)throw _b_.ValueError("invalid base")}
if(typeof value=='number'){if(base==10){if(value < $B.min_int ||value > $B.max_int)return $B.LongInt(value)
return value}else if(value.toString().search('e')>-1){
throw _b_.OverflowError("can't convert to base "+base)}else{var res=parseInt(value,base)
if(res < $B.min_int ||res > $B.max_int)return $B.LongInt(value,base)
return res}}
if(value===true)return Number(1)
if(value===false)return Number(0)
if(value.__class__===$B.LongInt.$dict){var z=parseInt(value.value)
if(z>$B.min_int && z<$B.max_int){return z}
else{return value}}
base=$B.$GetInt(base)
if(isinstance(value,_b_.str))value=value.valueOf()
if(typeof value=="string"){var _value=value.trim()
if(_value.length==2 && base==0 &&(_value=='0b' ||_value=='0o' ||_value=='0x')){throw _b_.ValueError('invalid value')}
if(_value.length >2){var _pre=_value.substr(0,2).toUpperCase()
if(base==0){if(_pre=='0B')base=2
if(_pre=='0O')base=8
if(_pre=='0X')base=16}
if(_pre=='0B' ||_pre=='0O' ||_pre=='0X'){_value=_value.substr(2)}}
var _digits=$valid_digits(base)
var _re=new RegExp('^[+-]?['+_digits+']+$','i')
if(!_re.test(_value)){throw _b_.ValueError(
"invalid literal for int() with base "+base +": '"+_b_.str(value)+"'")}
if(base <=10 && !isFinite(value)){throw _b_.ValueError(
"invalid literal for int() with base "+base +": '"+_b_.str(value)+"'")}
var res=parseInt(_value,base)
if(res < $B.min_int ||res > $B.max_int)return $B.LongInt(_value,base)
return res}
if(isinstance(value,[_b_.bytes,_b_.bytearray])){var _digits=$valid_digits(base)
for(var i=0;i<value.source.length;i++){if(_digits.indexOf(String.fromCharCode(value.source[i]))==-1){throw _b_.ValueError("invalid literal for int() with base "+
base +": "+_b_.repr(value))}}
return Number(parseInt(getattr(value,'decode')('latin-1'),base))}
if(hasattr(value,'__int__'))return getattr(value,'__int__')()
if(hasattr(value,'__index__'))return getattr(value,'__index__')()
if(hasattr(value,'__trunc__')){var res=getattr(value,'__trunc__')(),int_func=_b_.getattr(res,'__int__',null)
if(int_func===null){throw TypeError('__trunc__ returned non-Integral (type '+
$B.get_class(res).__name__+')')}
var res=int_func()
if(isinstance(res,int)){return res}
throw TypeError('__trunc__ returned non-Integral (type '+
$B.get_class(res).__name__+')')}
throw _b_.ValueError(
"invalid literal for int() with base "+base +": '"+_b_.str(value)+"'")}
int.$dict=$IntDict
int.__class__=$B.$factory
$IntDict.$factory=int
_b_.int=int
var $BoolDict=_b_.bool.$dict
$BoolDict.__add__=function(self,other){return(other ? 1 : 0)+(self ? 1 : 0)}
$BoolDict.__and__=function(self,other){return bool($IntDict.__and__(self,other))}
$BoolDict.__eq__=function(self,other){return self ? bool(other): !bool(other)}
$BoolDict.__ne__=function(self,other){return self ? !bool(other): bool(other)}
$BoolDict.__ge__=function(self,other){return _b_.int.$dict.__ge__($BoolDict.__hash__(self),other)}
$BoolDict.__gt__=function(self,other){return _b_.int.$dict.__gt__($BoolDict.__hash__(self),other)}
$BoolDict.__hash__=$BoolDict.__index__=$BoolDict.__int__=function(self){if(self.valueOf())return 1
return 0}
$BoolDict.__le__=function(self,other){return !$BoolDict.__gt__(self,other)}
$BoolDict.__lshift__=function(self,other){return self.valueOf()<< other}
$BoolDict.__lt__=function(self,other){return !$BoolDict.__ge__(self,other)}
$BoolDict.__mul__=function(self,other){return self ? other : 0}
$BoolDict.__neg__=function(self){return -$B.int_or_bool(self)}
$BoolDict.__or__=function(self,other){return bool($IntDict.__or__(self,other))}
$BoolDict.__pos__=$B.int_or_bool
$BoolDict.__repr__=$BoolDict.__str__=function(self){return self ? "True" : "False"}
$BoolDict.__setattr__=function(self,attr){return no_set_attr($BoolDict,attr)}
$BoolDict.__sub__=function(self,other){return(self ? 1 : 0)-(other ? 1 : 0)}
$BoolDict.__xor__=function(self,other){return self.valueOf()!=other.valueOf()}
$BoolDict.__mro__=[$IntDict,_b_.object.$dict]})(__BRYTHON__)
;(function($B){
eval($B.InjectBuiltins())
var $LongIntDict={__class__:$B.$type,__name__:'int'}
function add_pos(v1,v2){
var res='',carry=0,iself=v1.length,sv=0,x
for(var i=v2.length-1;i>=0;i--){iself--
if(iself<0){sv=0}else{sv=parseInt(v1.charAt(iself))}
x=(carry+sv+parseInt(v2.charAt(i))).toString()
if(x.length==2){res=x.charAt(1)+res;carry=parseInt(x.charAt(0))}
else{res=x+res;carry=0}}
while(iself>0){iself--
x=(carry+parseInt(v1.charAt(iself))).toString()
if(x.length==2){res=x.charAt(1)+res;carry=parseInt(x.charAt(0))}
else{res=x+res;carry=0}}
if(carry){res=carry+res}
return{__class__:$LongIntDict,value:res,pos:true}}
function check_shift(shift){
if(!isinstance(shift,LongInt)){throw TypeError("shift must be int, not '"+
$B.get_class(shift).__name__+"'")}
if(!shift.pos){throw ValueError("negative shift count")}}
function clone(obj){
var obj1={}
for(var attr in obj){obj1[attr]=obj[attr]}
return obj1}
function comp_pos(v1,v2){
if(v1.length>v2.length){return 1}
else if(v1.length<v2.length){return -1}
else{if(v1>v2){return 1}
else if(v1<v2){return -1}}
return 0}
function divmod_pos(v1,v2){
var quotient,mod
if(comp_pos(v1,v2)==-1){
quotient='0'
mod=LongInt(v1)}else if(v2==v1){
quotient='1';
mod=LongInt('0')}else{var quotient=''
var left=v1.substr(0,v2.length)
if(v1<v2){left=v1.substr(0,v2.length+1)}
var right=v1.substr(left.length)
var mv2={}
while(true){
var candidate=Math.floor(parseInt(left)/parseInt(v2))+''
if(mv2[candidate]===undefined){mv2[candidate]=mul_pos(v2,candidate).value}
if(comp_pos(left,mv2[candidate])==-1){
candidate--
if(mv2[candidate]===undefined){mv2[candidate]=mul_pos(v2,candidate).value}}
quotient +=candidate
left=sub_pos(left,mv2[candidate]).value
if(right.length==0){break}
left +=right.charAt(0)
right=right.substr(1)}
mod=sub_pos(v1,mul_pos(quotient,v2).value)}
return[LongInt(quotient),mod]}
function split_chunks(s,size){var nb=Math.ceil(s.length/size),chunks=[],len=s.length
for(var i=0;i<nb;i++){var pos=len-size*(i+1)
if(pos<0){size +=pos;pos=0}
chunks.push(parseInt(s.substr(pos,size)))}
return chunks}
function mul_pos(x,y){
var chunk_size=6
var cx=split_chunks(x,chunk_size),cy=split_chunks(y,chunk_size)
var products={},len=cx.length+cy.length
for(var i=0;i<len-1;i++){products[i]=0}
for(var i=0;i<cx.length;i++){for(var j=0;j<cy.length;j++){products[i+j]+=cx[i]*cy[j]}}
var nb=len-1,pos
for(var i=0;i<len-1;i++){var chunks=split_chunks(products[i].toString(),chunk_size)
for(var j=1;j<chunks.length;j++){pos=i+j
if(products[pos]===undefined){products[pos]=parseInt(chunks[j]);nb=pos}
else{products[pos]+=parseInt(chunks[j])}}
products[i]=chunks[0]}
var result='',i=0,s
while(products[i]!==undefined){s=products[i].toString()
if(products[i+1]!==undefined){s='0'.repeat(chunk_size-s.length)+s}
result=s+result;
i++}
return LongInt(result)}
function sub_pos(v1,v2){
var res='',carry=0,i1=v1.length,sv=0,x
for(var i=v2.length-1;i>=0;i--){i1--
sv=parseInt(v1.charAt(i1))
x=(sv-carry-parseInt(v2.charAt(i)))
if(x<0){res=(10+x)+res;carry=1}
else{res=x+res;carry=0}}
while(i1>0){i1--
x=(parseInt(v1.charAt(i1))-carry)
if(x<0){res=(10+x)+res;carry=1}
else{res=x+res;carry=0}}
while(res.charAt(0)=='0' && res.length>1){res=res.substr(1)}
return{__class__:$LongIntDict,value:res,pos:true}}
$LongIntDict.$from_float=function(value){var s=Math.abs(value).toString(),v=s
if(s.search('e')>-1){var t=/-?(\d)(\.\d+)?e([+-])(\d*)/.exec(s),n1=t[1],n2=t[2],pos=t[3],exp=t[4]
if(pos=='+'){if(n2===undefined){v=n1+'0'.repeat(exp-1)}else{v=n1+n2+'0'.repeat(exp-1-n2.length)}}}
return{__class__:$LongIntDict,value: v,pos: value >=0}}
$LongIntDict.__abs__=function(self){return{__class__:$LongIntDict,value: self.value,pos:true}}
$LongIntDict.__add__=function(self,other){if(isinstance(other,_b_.float)){return _b_.float(parseInt(self.value)+other.value)}
if(typeof other=='number')other=LongInt(_b_.str(other))
var res
if(self.pos&&other.pos){
return add_pos(self.value,other.value)}else if(!self.pos&&!other.pos){
res=add_pos(self.value,other.value)
res.pos=false
return intOrLong(res)}else if(self.pos && !other.pos){
switch(comp_pos(self.value,other.value)){case 1:
res=sub_pos(self.value,other.value)
break
case 0:
res={__class__:$LongIntDict,value:0,pos:true}
break
case -1:
res=sub_pos(other.value,self.value)
res.pos=false
break}
return intOrLong(res)}else{
switch(comp_pos(self.value,other.value)){case 1:
res=sub_pos(self.value,other.value)
res.pos=false
break
case 0:
res={__class__:$LongIntDict,value:0,pos:true}
break
case -1:
res=sub_pos(other.value,self.value)
break}
return intOrLong(res)}}
$LongIntDict.__and__=function(self,other){if(typeof other=='number')other=LongInt(_b_.str(other))
var v1=$LongIntDict.__index__(self)
var v2=$LongIntDict.__index__(other)
if(v1.length<v2.length){var temp=v2;v2=v1;v1=temp}
if(v2.charAt(0)=='1'){v2='1'.repeat(v1.length-v2.length)+v2}
var start=v1.length-v2.length
var res=''
for(var i=0;i<v2.length;i++){if(v1.charAt(start+i)=='1' && v2.charAt(i)=='1'){res +='1'}
else{res +='0'}}
return intOrLong(LongInt(res,2))}
$LongIntDict.__divmod__=function(self,other){if(typeof other=='number')other=LongInt(_b_.str(other))
var dm=divmod_pos(self.value,other.value)
if(self.pos!==other.pos){if(dm[0].value!='0'){dm[0].pos=false}
if(dm[1].value!='0'){
dm[0]=$LongIntDict.__sub__(dm[0],LongInt('1'))
dm[1]=$LongIntDict.__add__(dm[1],LongInt('1'))}}
return[intOrLong(dm[0]),intOrLong(dm[1])]}
$LongIntDict.__eq__=function(self,other){if(typeof other=='number')other=LongInt(_b_.str(other))
return self.value==other.value && self.pos==other.pos}
$LongIntDict.__float__=function(self){return new Number(parseFloat(self.value))}
$LongIntDict.__floordiv__=function(self,other){if(isinstance(other,_b_.float)){return _b_.float(parseInt(self.value)/other)}
if(typeof other=='number')other=LongInt(_b_.str(other))
return intOrLong($LongIntDict.__divmod__(self,other)[0])}
$LongIntDict.__ge__=function(self,other){if(typeof other=='number')other=LongInt(_b_.str(other))
if(self.pos !=other.pos){return !other.pos}
if(self.value.length>other.value.length){return self.pos}
else if(self.value.length<other.value.length){return !self.pos}
else{return self.pos ? self.value >=other.value : self.value <=other.value}}
$LongIntDict.__gt__=function(self,other){return !$LongIntDict.__le__(self,other)}
$LongIntDict.__index__=function(self){
var res='',temp=self.value,d
while(true){d=divmod_pos(temp,'2')
res=d[1].value + res
temp=d[0].value
if(temp=='0'){break}}
if(!self.pos){
var nres='',flag=false
for(var len=res.length-1,i=len;i>=0 ;i--){var bit=res.charAt(i)
if(bit=='0'){if(flag){nres='1'+nres}else{nres='0'+nres}}
else{if(flag){nres='0'+nres}else{flag=true;nres='1'+nres}}}
nres='1'+nres
res=nres}else{res='0' + res}
return intOrLong(res)}
$LongIntDict.__invert__=function(self){return $LongIntDict.__sub__(LongInt('-1'),self)}
$LongIntDict.__le__=function(self,other){if(typeof other=='number')other=LongInt(_b_.str(other))
if(self.pos !==other.pos){return !self.pos}
if(self.value.length>other.value.length){return !self.pos}
else if(self.value.length<other.value.length){return self.pos}
else{return self.pos ? self.value <=other.value : self.value >=other.value}}
$LongIntDict.__lt__=function(self,other){return !$LongIntDict.__ge__(self,other)}
$LongIntDict.__lshift__=function(self,shift){var is_long=shift.__class__==$LongIntDict
if(is_long){var shift_value=parseInt(shift.value)
if(shift_value<0){throw _b_.ValueError('negative shift count')}
if(shift_value < $B.max_int){shift_safe=true;shift=shift_value}}
if(shift_safe){if(shift_value==0){return self}}else{shift=LongInt(shift)
if(shift.value=='0'){return self}}
var res=self.value
while(true){var x,carry=0,res1=''
for(var i=res.length-1;i>=0;i--){x=(carry+parseInt(res.charAt(i))*2).toString()
if(x.length==2){res1=x.charAt(1)+res1;carry=parseInt(x.charAt(0))}
else{res1=x+res1;carry=0}}
if(carry){res1=carry+res1}
res=res1
if(shift_safe){shift--
if(shift==0){break}}else{shift=sub_pos(shift.value,'1')
if(shift.value=='0'){break}}}
return intOrLong({__class__:$LongIntDict,value:res,pos:self.pos})}
$LongIntDict.__mod__=function(self,other){return intOrLong($LongIntDict.__divmod__(self,other)[1])}
$LongIntDict.__mro__=[_b_.int.$dict,_b_.object.$dict]
$LongIntDict.__mul__=function(self,other){switch(self){case Number.NEGATIVE_INFINITY:
case Number.POSITIVE_INFINITY:
var eq=_b_.getattr(other,'__eq__')
if(eq(0)){return NaN}
else if(_b_.getattr(other,'__gt__')(0)){return self}
else{return -self}}
if(isinstance(other,_b_.float)){return _b_.float(parseInt(self.value)*other)}
if(typeof other=='number')other=LongInt(_b_.str(other))
var res=mul_pos(self.value,other.value)
if(self.pos==other.pos){return intOrLong(res)}
res.pos=false
return intOrLong(res)}
$LongIntDict.__neg__=function(obj){return{__class__:$LongIntDict,value:obj.value,pos:!obj.pos}}
$LongIntDict.__or__=function(self,other){other=LongInt(other)
var v1=$LongIntDict.__index__(self)
var v2=$LongIntDict.__index__(other)
if(v1.length<v2.length){var temp=v2;v2=v1;v1=temp}
var start=v1.length-v2.length
var res=v1.substr(0,start)
for(var i=0;i<v2.length;i++){if(v1.charAt(start+i)=='1' ||v2.charAt(i)=='1'){res +='1'}
else{res +='0'}}
return intOrLong(LongInt(res,2))}
$LongIntDict.__pos__=function(self){return self}
$LongIntDict.__pow__=function(self,power,z){if(typeof power=="number"){power=LongInt(_b_.str(power))}else if(!isinstance(power,LongInt)){var msg="power must be a LongDict, not '"
throw TypeError(msg+$B.get_class(power).__name__+"'")}
if(!power.pos){if(self.value=='1'){return self}
return LongInt('0')}else if(power.value=='0'){return LongInt('1')}
var res={__class__:$LongIntDict,value:self.value,pos:self.pos}
var pow=power.value
while(true){pow=sub_pos(pow,'1').value
if(pow=='0'){break}
res=LongInt($LongIntDict.__mul__(res,self))
if(z !==undefined){res=$LongIntDict.__mod__(res,z)}}
return intOrLong(res)}
$LongIntDict.__rshift__=function(self,shift){shift=LongInt(shift)
if(shift.value=='0'){return self}
var res=self.value
while(true){res=divmod_pos(res,'2')[0].value
if(res.value=='0'){break}
shift=sub_pos(shift.value,'1')
if(shift.value=='0'){break}}
return intOrLong({__class__:$LongIntDict,value:res,pos:self.pos})}
$LongIntDict.__str__=$LongIntDict.__repr__=function(self){var res=""
if(!self.pos){res +='-'}
return res+self.value}
$LongIntDict.__sub__=function(self,other){if(isinstance(other,_b_.float)){return _b_.float(parseInt(self.value)-other.value)}
if(typeof other=='number')other=LongInt(_b_.str(other))
var res
if(self.pos && other.pos){switch(comp_pos(self.value,other.value)){case 1:
res=sub_pos(self.value,other.value)
break
case 0:
res={__class__:$LongIntDict,value:'0',pos:true}
break
case -1:
res=sub_pos(other.value,self.value)
res.pos=false
break}
return intOrLong(res)}else if(!self.pos && !other.pos){switch(comp_pos(self.value,other.value)){case 1:
res=sub_pos(self.value,other.value)
res.pos=false
break
case 0:
res={__class__:$LongIntDict,value:'0',pos:true}
break
case -1:
res=sub_pos(other.value,self.value)
break}
return intOrLong(res)}else if(self.pos && !other.pos){return intOrLong(add_pos(self.value,other.value))}else{res=add_pos(self.value,other.value)
res.pos=false
return intOrLong(res)}}
$LongIntDict.__truediv__=function(self,other){if(isinstance(other,LongInt)){return _b_.float(parseInt(self.value)/parseInt(other.value))}else if(isinstance(other,_b_.int)){return _b_.float(parseInt(self.value)/other)}else if(isinstance(other,_b_.float)){return _b_.float(parseInt(self.value)/other)}else{throw TypeError("unsupported operand type(s) for /: 'int' and '"+
$B.get_class(other).__name__+"'")}}
$LongIntDict.__xor__=function(self,other){other=LongInt(other)
var v1=$LongIntDict.__index__(self)
var v2=$LongIntDict.__index__(other)
if(v1.length<v2.length){var temp=v2;v2=v1;v1=temp}
var start=v1.length-v2.length
var res=v1.substr(0,start)
for(var i=0;i<v2.length;i++){if(v1.charAt(start+i)=='1' && v2.charAt(i)=='0'){res +='1'}
else if(v1.charAt(start+i)=='0' && v2.charAt(i)=='1'){res +='1'}
else{res +='0'}}
return intOrLong(LongInt(res,2))}
$LongIntDict.to_base=function(self,base){
var res='',v=self.value
while(v>0){var dm=divmod_pos(v,base.toString())
res=parseInt(dm[1].value).toString(base)+res
v=dm[0].value
if(v==0){break}}
return res}
function digits(base){
var is_digits={}
for(var i=0;i<base;i++){if(i==10){break}
is_digits[i]=true}
if(base>10){
for(var i=0;i<base-10;i++){is_digits[String.fromCharCode(65+i)]=true
is_digits[String.fromCharCode(97+i)]=true}}
return is_digits}
var MAX_SAFE_INTEGER=Math.pow(2,53)-1;
var MIN_SAFE_INTEGER=-MAX_SAFE_INTEGER;
function isSafeInteger(n){return(typeof n==='number' &&
Math.round(n)===n &&
MIN_SAFE_INTEGER <=n &&
n <=MAX_SAFE_INTEGER);}
function intOrLong(long){
var v=parseInt(long.value)*(long.pos ? 1 : -1)
if(v>MIN_SAFE_INTEGER && v<MAX_SAFE_INTEGER){return v}
return long}
function LongInt(value,base){if(arguments.length>2){throw _b_.TypeError("LongInt takes at most 2 arguments ("+
arguments.length+" given)")}
if(base===undefined){base=10}
else if(!isinstance(base,int)){throw TypeError("'"+$B.get_class(base).__name__+"' object cannot be interpreted as an integer")}
if(base<0 ||base==1 ||base>36){throw ValueError("LongInt() base must be >= 2 and <= 36")}
if(isinstance(value,_b_.float)){if(value===Number.POSITIVE_INFINITY ||value===Number.NEGATIVE_INFINITY){return value}
if(value>=0){value=new Number(Math.round(value.value))}
else{value=new Number(Math.ceil(value.value))}}else if(isinstance(value,_b_.bool)){if(value.valueOf())return int(1)
return int(0)}
if(typeof value=='number'){if(isSafeInteger(value)){value=value.toString()}
else if(value.constructor==Number){console.log('big number',value);value=value.toString()}
else{console.log('wrong value',value);throw ValueError("argument of long_int is not a safe integer")}}else if(value.__class__===$LongIntDict){return value}
else if(isinstance(value,_b_.bool)){value=_b_.bool.$dict.__int__(value)+''}
else if(typeof value!='string'){throw ValueError("argument of long_int must be a string, not "+
$B.get_class(value).__name__)}
var has_prefix=false,pos=true,start=0
while(value.charAt(0)==' ' && value.length){value=value.substr(1)}
while(value.charAt(value.length-1)==' ' && value.length){value=value.substr(0,value.length-1)}
if(value.charAt(0)=='+'){has_prefix=true}
else if(value.charAt(0)=='-'){has_prefix=true;pos=false}
if(has_prefix){
if(value.length==1){
throw ValueError('LongInt argument is not a valid number: "'+value+'"')}else{value=value.substr(1)}}
while(start<value.length-1 && value.charAt(start)=='0'){start++}
value=value.substr(start)
var is_digits=digits(base),point=-1
for(var i=0;i<value.length;i++){if(value.charAt(i)=='.' && point==-1){point=i}
else if(!is_digits[value.charAt(i)]){throw ValueError('LongInt argument is not a valid number: "'+value+'"')}}
if(point!=-1){value=value.substr(0,point)}
if(base!=10){
var coef='1',v10=LongInt(0),pos=value.length
while(pos--){var digit_base10=parseInt(value.charAt(pos),base).toString(),digit_by_coef=mul_pos(coef,digit_base10).value
v10=add_pos(v10.value,digit_by_coef)
coef=mul_pos(coef,base.toString()).value}
return v10}
return{__class__:$LongIntDict,value:value,pos:pos}}
LongInt.__class__=$B.$factory
LongInt.$dict=$LongIntDict
$LongIntDict.$factory=LongInt
$B.LongInt=LongInt})(__BRYTHON__)
;(function($B){eval($B.InjectBuiltins())
var $ObjectDict=_b_.object.$dict
function $UnsupportedOpType(op,class1,class2){throw _b_.TypeError("unsupported operand type(s) for "+op+": '"+class1+"' and '"+class2+"'")}
var $ComplexDict={__class__:$B.$type,__dir__:$ObjectDict.__dir__,__name__:'complex',$native:true,$descriptors:{real:true,imag:true}}
$ComplexDict.__abs__=function(self){var _rf=isFinite(self.$real),_if=isFinite(self.$imag);
if((_rf && isNaN(self.$imag))||(_if && isNaN(self.$real))||(isNaN(self.$imag)&& isNaN(self.$real)))return NaN
if(! _rf ||! _if )return Infinity;
var mag=Math.sqrt(Math.pow(self.$real,2)+Math.pow(self.$imag,2));
if(!isFinite(mag)&& _rf && _if){
throw _b_.OverflowError("absolute value too large");}
return mag;}
$ComplexDict.__bool__=function(self){if(self.$real==0 && self.$imag==0)return false;else return true;}
$ComplexDict.__class__=$B.$type
$ComplexDict.__eq__=function(self,other){if(isinstance(other,complex))return self.$real.valueOf()==other.$real.valueOf()&& self.$imag.valueOf()==other.$imag.valueOf()
if(isinstance(other,_b_.int)){if(self.$imag !=0)return False
return self.$real==other.valueOf()}
if(isinstance(other,_b_.float)){if(self.$imag !=0)return False
return self.$real==other.valueOf()}
$UnsupportedOpType("==","complex",$B.get_class(other))}
$ComplexDict.__floordiv__=function(self,other){$UnsupportedOpType("//","complex",$B.get_class(other))}
$ComplexDict.__hash__=function(self){
if(self===undefined){return $ComplexDict.__hashvalue__ ||$B.$py_next_hash--}
return self.$imag*1000003+self.$real}
$ComplexDict.__init__=function(){var args=[].slice.call(arguments,1)
var c=complex.apply(null,args)
var self=arguments[0];
self.$real=c.$real
self.$imag=c.$imag
self.toString=function(){return '('+self.$real+'+'+self.$imag+'j)'}}
$ComplexDict.__invert__=function(self){return ~self}
$ComplexDict.__mod__=function(self,other){throw _b_.TypeError("TypeError: can't mod complex numbers.")}
$ComplexDict.__mro__=[$ObjectDict]
$ComplexDict.__mul__=function(self,other){if(isinstance(other,complex))
return complex(self.$real*other.$real-self.$imag*other.$imag,self.$imag*other.$real + self.$real*other.$imag)
if(isinstance(other,_b_.int))
return complex(self.$real*other.valueOf(),self.$imag*other.valueOf())
if(isinstance(other,_b_.float))
return complex(self.$real*other,self.$imag*other)
if(isinstance(other,_b_.bool)){if(other.valueOf())return self
return complex(0)}
$UnsupportedOpType("*",complex,other)}
$ComplexDict.__name__='complex'
$ComplexDict.__ne__=function(self,other){return !$ComplexDict.__eq__(self,other)}
$ComplexDict.__neg__=function(self){return complex(-self.$real,-self.$imag)}
$ComplexDict.__new__=function(cls){if(cls===undefined)throw _b_.TypeError('complex.__new__(): not enough arguments')
return{__class__:cls.$dict}}
$ComplexDict.__pos__=function(self){return self}
function complex2expo(cx){var norm=Math.sqrt((cx.$real*cx.$real)+(cx.$imag*cx.$imag)),sin=cx.$imag/norm,cos=cx.$real/norm,angle
if(cos==0){angle=sin==1 ? Math.PI/2 : 3*Math.PI/2}
else if(sin==0){angle=cos==1 ? 0 : Math.PI}
else{angle=Math.atan(sin/cos)}
return{norm: norm,angle: angle}}
$ComplexDict.__pow__=function(self,other){
var exp=complex2expo(self),angle=exp.angle,res=Math.pow(exp.norm,other)
if(_b_.isinstance(other,[_b_.int,_b_.float])){return complex(res*Math.cos(angle*other),res*Math.sin(angle*other))}else if(_b_.isinstance(other,complex)){
var x=other.$real,y=other.$imag
var pw=Math.pow(exp.norm,x)*Math.pow(Math.E,-y*angle),theta=y*Math.log(exp.norm)-x*angle
return complex(pw*Math.cos(theta),pw*Math.sin(theta))}else{throw _b_.TypeError("unsupported operand type(s) for ** or pow(): "+
"'complex' and '"+$B.get_class(other).__name__+"'")}}
$ComplexDict.__str__=$ComplexDict.__repr__=function(self){if(self.$real==0){if(1/self.$real < 0){if(self.$imag < 0){return "(-0"+self.$imag+"j)"}else if(self.$imag==0 && 1/self.$imag < 0){return "(-0-"+self.$imag+"j)"}else return "(-0+"+self.$imag+"j)"}else{
if(self.$imag==0 && 1/self.$imag < 0)return "-"+self.$imag+'j'
else return self.$imag+'j'}}
if(self.$imag>0)return '('+self.$real+'+'+self.$imag+'j)';
if(self.$imag==0){if(1/self.$imag < 0)return '('+self.$real+'-'+self.$imag+'j)';
return '('+self.$real+'+'+self.$imag+'j)';}
return '('+self.$real+'-'+(-self.$imag)+'j)'}
$ComplexDict.__sqrt__=function(self){if(self.$imag==0)return complex(Math.sqrt(self.$real))
var r=self.$real,i=self.$imag,_a=Math.sqrt((r + sqrt)/2),_b=Number.sign(i)* Math.sqrt((-r + sqrt)/2)
return complex(_a,_b)}
$ComplexDict.__truediv__=function(self,other){if(isinstance(other,complex)){if(other.$real==0 && other.$imag==0){throw ZeroDivisionError('division by zero')}
var _num=self.$real*other.$real + self.$imag*other.$imag
var _div=other.$real*other.$real + other.$imag*other.$imag
var _num2=self.$imag*other.$real - self.$real*other.$imag
return complex(_num/_div,_num2/_div)}
if(isinstance(other,_b_.int)){if(!other.valueOf())throw ZeroDivisionError('division by zero')
return $ComplexDict.__truediv__(self,complex(other.valueOf()))}
if(isinstance(other,_b_.float)){if(!other.value)throw ZeroDivisionError('division by zero')
return $ComplexDict.__truediv__(self,complex(other.value))}
$UnsupportedOpType("//","complex",other.__class__)}
$ComplexDict.conjugate=function(self){return complex(self.$real,-self.$imag);}
var $op_func=function(self,other){throw _b_.TypeError("TypeError: unsupported operand type(s) for -: 'complex' and '" +
$B.get_class(other).__name__+"'")}
$op_func +=''
var $ops={'&':'and','|':'ior','<<':'lshift','>>':'rshift','^':'xor'}
for(var $op in $ops){eval('$ComplexDict.__'+$ops[$op]+'__ = '+$op_func.replace(/-/gm,$op))}
$ComplexDict.__ior__=$ComplexDict.__or__
var $op_func=function(self,other){if(isinstance(other,complex))return complex(self.$real-other.$real,self.$imag-other.$imag)
if(isinstance(other,_b_.int))return complex($B.sub(self.$real,other.valueOf()),self.$imag)
if(isinstance(other,_b_.float))return complex(self.$real - other.valueOf(),self.$imag)
if(isinstance(other,_b_.bool)){var bool_value=0;
if(other.valueOf())bool_value=1;
return complex(self.$real - bool_value,self.$imag)}
throw _b_.TypeError("unsupported operand type(s) for -: "+self.__repr__()+
" and '"+$B.get_class(other).__name__+"'")}
$ComplexDict.__sub__=$op_func
$op_func +=''
$op_func=$op_func.replace(/-/gm,'+').replace(/sub/gm,'add')
eval('$ComplexDict.__add__ = '+$op_func)
var $comp_func=function(self,other){if(other===undefined ||other==_b_.None){throw _b_.NotImplemented("");}
throw _b_.TypeError("TypeError: no ordering relation is defined for complex numbers")}
$comp_func +=''
for(var $op in $B.$comps){eval("$ComplexDict.__"+$B.$comps[$op]+'__ = '+$comp_func.replace(/>/gm,$op))}
$B.make_rmethods($ComplexDict)
$ComplexDict.real=function(self){return new Number(self.$real)}
$ComplexDict.real.setter=function(){throw _b_.AttributeError("readonly attribute")}
$ComplexDict.imag=function(self){return new Number(self.$imag)}
$ComplexDict.imag.setter=function(){throw _b_.AttributeError("readonly attribute")}
var complex_re=/^\s*([\+\-]*\d*\.?\d*(e[\+\-]*\d*)?)([\+\-]?)(\d*\.?\d*(e[\+\-]*\d*)?)(j?)\s*$/i
var _real=1,_real_mantissa=2,_sign=3,_imag=4,_imag_mantissa=5,_j=6;
var type_conversions=['__complex__','__float__','__int__'];
var _convert=function(num){for(i=0;i<type_conversions.length;i++){if(hasattr(num,type_conversions[i])){return getattr(num,type_conversions[i])()}}
return num}
var complex=function(){var res;
var args=$B.args("complex",2,{real:null,imag:null},["real","imag"],arguments,{real:0,imag:0},null,null)
var $real=args.real,$imag=args.imag;
if(typeof $real=='string'){if(arguments.length > 1 ||arguments[0].$nat !==undefined){throw _b_.TypeError("complex() can't take second arg if first is a string")}
$real=$real.trim()
if($real.startsWith('(')&& $real.endsWith(')')){$real=$real.substr(1)
$real=$real.substr(0,$real.length-1)}
var parts=complex_re.exec($real)
if(parts===null){throw _b_.ValueError("complex() arg is a malformed string")}else if(parts[_real]=='.' ||parts[_imag]=='.' ||parts[_real]=='.e' ||parts[_imag]=='.e' ||parts[_real]=='e' ||parts[_imag]=='e'){throw _b_.ValueError("complex() arg is a malformed string")}else if(parts[_j]!=''){if(parts[_sign]==''){$real=0;
if(parts[_real]=='+' ||parts[_real]==''){$imag=1}else if(parts[_real]=='-'){$imag=-1}else $imag=parseFloat(parts[_real])}else{$real=parseFloat(parts[_real])
$imag=parts[_imag]=='' ? 1 : parseFloat(parts[_imag])
$imag=parts[_sign]=='-' ? -$imag : $imag}}else{$real=parseFloat(parts[_real])
$imag=0}
res={__class__:$ComplexDict,$real:$real ||0,$imag:$imag ||0}
res.__repr__=res.__str__=function(){if(res.$real==0)return res.$imag + 'j'
return '('+res.$real+'+'+res.$imag+'j)'}
return res}
if(arguments.length==1 && $real.__class__===$ComplexDict && $imag==0){return $real;}
if((isinstance($real,_b_.float)||isinstance($real,_b_.int))&&(isinstance($imag,_b_.float)||isinstance($imag,_b_.int))){res={__class__:$ComplexDict,$real:$real,$imag:$imag}
res.__repr__=res.__str__=function(){if(res.$real==0)return res.$imag + 'j'
return '('+res.$real+'+'+res.$imag+'j)'}
return res;}
for(i=0;i<type_conversions.length;i++){if(hasattr($real,type_conversions[i])){}}
$real=_convert($real)
$imag=_convert($imag)
if(!isinstance($real,_b_.float)&& !isinstance($real,_b_.int)&& !isinstance($real,_b_.complex)){throw _b_.TypeError("complex() argument must be a string or a number")}
if(typeof $imag=='string'){throw _b_.TypeError("complex() second arg can't be a string")}
if(!isinstance($imag,_b_.float)&& !isinstance($imag,_b_.int)&& !isinstance($imag,_b_.complex)&& $imag!==undefined){throw _b_.TypeError("complex() argument must be a string or a number")}
$imag=$ComplexDict.__mul__(complex("1j"),$imag)
return $ComplexDict.__add__($imag,$real);}
complex.$dict=$ComplexDict
complex.__class__=$B.$factory
$ComplexDict.$factory=complex
$B.set_func_names($ComplexDict)
_b_.complex=complex})(__BRYTHON__)
;(function($B){
eval($B.InjectBuiltins())
DEFAULT_MIN_MERGE=32;
DEFAULT_MIN_GALLOPING=7;
DEFAULT_TMP_STORAGE_LENGTH=256;
POWERS_OF_TEN=[1e0,1e1,1e2,1e3,1e4,1e5,1e6,1e7,1e8,1e9]
function log10(x){if(x < 1e5){if(x < 1e2){return x < 1e1 ? 0 : 1;}
if(x < 1e4){return x < 1e3 ? 2 : 3;}
return 4;}
if(x < 1e7){return x < 1e6 ? 5 : 6;}
if(x < 1e9){return x < 1e8 ? 7 : 8;}
return 9;}
function alphabeticalCompare(a,b){if(a===b){return 0;}
if(~~a===a && ~~b===b){if(a===0 ||b===0){return a < b ? -1 : 1;}
if(a < 0 ||b < 0){if(b >=0){return -1;}
if(a >=0){return 1;}
a=-a;
b=-b;}
al=log10(a);
bl=log10(b);
var t=0;
if(al < bl){a *=POWERS_OF_TEN[bl - al - 1];
b /=10;
t=-1;}else if(al > bl){b *=POWERS_OF_TEN[al - bl - 1];
a /=10;
t=1;}
if(a===b){return t;}
return a < b ? -1 : 1;}
var aStr=String(a);
var bStr=String(b);
if(aStr===bStr){return 0;}
return aStr < bStr ? -1 : 1;}
function minRunLength(n){var r=0;
while(n >=DEFAULT_MIN_MERGE){r |=(n & 1);
n >>=1;}
return n + r;}
function makeAscendingRun(array,lo,hi,compare){var runHi=lo + 1;
if(runHi===hi){return 1;}
if(compare(array[runHi++],array[lo])< 0){while(runHi < hi && compare(array[runHi],array[runHi - 1])< 0){runHi++;}
reverseRun(array,lo,runHi);}else{
while(runHi < hi && compare(array[runHi],array[runHi - 1])>=0){runHi++;}}
return runHi - lo;}
function reverseRun(array,lo,hi){hi--;
while(lo < hi){var t=array[lo];
array[lo++]=array[hi];
array[hi--]=t;}}
function binaryInsertionSort(array,lo,hi,start,compare){if(start===lo){start++;}
for(;start < hi;start++){var pivot=array[start];
var left=lo;
var right=start;
while(left < right){var mid=(left + right)>>> 1;
if(compare(pivot,array[mid])< 0){right=mid;}else{
left=mid + 1;}}
var n=start - left;
switch(n){case 3:
array[left + 3]=array[left + 2];
case 2:
array[left + 2]=array[left + 1];
case 1:
array[left + 1]=array[left];
break;
default:
while(n > 0){array[left + n]=array[left + n - 1];
n--;}}
array[left]=pivot;}}
function gallopLeft(value,array,start,length,hint,compare){var lastOffset=0;
var maxOffset=0;
var offset=1;
if(compare(value,array[start + hint])> 0){maxOffset=length - hint;
while(offset < maxOffset && compare(value,array[start + hint + offset])> 0){lastOffset=offset;
offset=(offset << 1)+ 1;
if(offset <=0){offset=maxOffset;}}
if(offset > maxOffset){offset=maxOffset;}
lastOffset +=hint;
offset +=hint;}else{
maxOffset=hint + 1;
while(offset < maxOffset && compare(value,array[start + hint - offset])<=0){lastOffset=offset;
offset=(offset << 1)+ 1;
if(offset <=0){offset=maxOffset;}}
if(offset > maxOffset){offset=maxOffset;}
var tmp=lastOffset;
lastOffset=hint - offset;
offset=hint - tmp;}
lastOffset++;
while(lastOffset < offset){var m=lastOffset +((offset - lastOffset)>>> 1);
if(compare(value,array[start + m])> 0){lastOffset=m + 1;}else{
offset=m;}}
return offset;}
function gallopRight(value,array,start,length,hint,compare){var lastOffset=0;
var maxOffset=0;
var offset=1;
if(compare(value,array[start + hint])< 0){maxOffset=hint + 1;
while(offset < maxOffset && compare(value,array[start + hint - offset])< 0){lastOffset=offset;
offset=(offset << 1)+ 1;
if(offset <=0){offset=maxOffset;}}
if(offset > maxOffset){offset=maxOffset;}
var tmp=lastOffset;
lastOffset=hint - offset;
offset=hint - tmp;}else{
maxOffset=length - hint;
while(offset < maxOffset && compare(value,array[start + hint + offset])>=0){lastOffset=offset;
offset=(offset << 1)+ 1;
if(offset <=0){offset=maxOffset;}}
if(offset > maxOffset){offset=maxOffset;}
lastOffset +=hint;
offset +=hint;}
lastOffset++;
while(lastOffset < offset){var m=lastOffset +((offset - lastOffset)>>> 1);
if(compare(value,array[start + m])< 0){offset=m;}else{
lastOffset=m + 1;}}
return offset;}
TimSort=function(array,compare){self={array:array,compare:compare,minGallop:DEFAULT_MIN_GALLOPING,length : array.length,tmpStorageLength:DEFAULT_TMP_STORAGE_LENGTH,stackLength:0,runStart:null,runLength:null,stackSize:0,
pushRun: function(runStart,runLength){this.runStart[this.stackSize]=runStart;
this.runLength[this.stackSize]=runLength;
this.stackSize +=1;},
mergeRuns: function(){while(this.stackSize > 1){var n=this.stackSize - 2;
if((n >=1 &&
this.runLength[n - 1]<=this.runLength[n]+ this.runLength[n + 1])||
(n >=2 &&
this.runLength[n - 2]<=this.runLength[n]+ this.runLength[n - 1])){if(this.runLength[n - 1]< this.runLength[n + 1]){n--;}}else if(this.runLength[n]> this.runLength[n + 1]){break;}
this.mergeAt(n);}},
forceMergeRuns: function(){while(this.stackSize > 1){var n=this.stackSize - 2;
if(n > 0 && this.runLength[n - 1]< this.runLength[n + 1]){n--;}
this.mergeAt(n);}},
mergeAt: function(i){var compare=this.compare;
var array=this.array;
var start1=this.runStart[i];
var length1=this.runLength[i];
var start2=this.runStart[i + 1];
var length2=this.runLength[i + 1];
this.runLength[i]=length1 + length2;
if(i===this.stackSize - 3){this.runStart[i + 1]=this.runStart[i + 2];
this.runLength[i + 1]=this.runLength[i + 2];}
this.stackSize--;
var k=gallopRight(array[start2],array,start1,length1,0,compare);
start1 +=k;
length1 -=k;
if(length1===0){return;}
length2=gallopLeft(array[start1 + length1 - 1],array,start2,length2,length2 - 1,compare);
if(length2===0){return;}
if(length1 <=length2){this.mergeLow(start1,length1,start2,length2);}else{
this.mergeHigh(start1,length1,start2,length2);}},
mergeLow: function(start1,length1,start2,length2){var compare=this.compare;
var array=this.array;
var tmp=this.tmp;
var i=0;
for(i=0;i < length1;i++){tmp[i]=array[start1 + i];}
var cursor1=0;
var cursor2=start2;
var dest=start1;
array[dest++]=array[cursor2++];
if(--length2===0){for(i=0;i < length1;i++){array[dest + i]=tmp[cursor1 + i];}
return;}
if(length1===1){for(i=0;i < length2;i++){array[dest + i]=array[cursor2 + i];}
array[dest + length2]=tmp[cursor1];
return;}
var minGallop=this.minGallop;
while(true){var count1=0;
var count2=0;
var exit=false;
do{
if(compare(array[cursor2],tmp[cursor1])< 0){array[dest++]=array[cursor2++];
count2++;
count1=0;
if(--length2===0){exit=true;
break;}}else{
array[dest++]=tmp[cursor1++];
count1++;
count2=0;
if(--length1===1){exit=true;
break;}}}while((count1 |count2)< minGallop);
if(exit){break;}
do{
count1=gallopRight(array[cursor2],tmp,cursor1,length1,0,compare);
if(count1 !==0){for(i=0;i < count1;i++){array[dest + i]=tmp[cursor1 + i];}
dest +=count1;
cursor1 +=count1;
length1 -=count1;
if(length1 <=1){exit=true;
break;}}
array[dest++]=array[cursor2++];
if(--length2===0){exit=true;
break;}
count2=gallopLeft(tmp[cursor1],array,cursor2,length2,0,compare);
if(count2 !==0){for(i=0;i < count2;i++){array[dest + i]=array[cursor2 + i];}
dest +=count2;
cursor2 +=count2;
length2 -=count2;
if(length2===0){exit=true;
break;}}
array[dest++]=tmp[cursor1++];
if(--length1===1){exit=true;
break;}
minGallop--;}while(count1 >=DEFAULT_MIN_GALLOPING ||count2 >=DEFAULT_MIN_GALLOPING);
if(exit){break;}
if(minGallop < 0){minGallop=0;}
minGallop +=2;}
this.minGallop=minGallop;
if(minGallop < 1){this.minGallop=1;}
if(length1===1){for(i=0;i < length2;i++){array[dest + i]=array[cursor2 + i];}
array[dest + length2]=tmp[cursor1];}else if(length1===0){throw new Error('mergeLow preconditions were not respected');}else{
for(i=0;i < length1;i++){array[dest + i]=tmp[cursor1 + i];}}},
mergeHigh: function(start1,length1,start2,length2){var compare=this.compare;
var array=this.array;
var tmp=this.tmp;
var i=0;
for(i=0;i < length2;i++){tmp[i]=array[start2 + i];}
var cursor1=start1 + length1 - 1;
var cursor2=length2 - 1;
var dest=start2 + length2 - 1;
var customCursor=0;
var customDest=0;
array[dest--]=array[cursor1--];
if(--length1===0){customCursor=dest -(length2 - 1);
for(i=0;i < length2;i++){array[customCursor + i]=tmp[i];}
return;}
if(length2===1){dest -=length1;
cursor1 -=length1;
customDest=dest + 1;
customCursor=cursor1 + 1;
for(i=length1 - 1;i >=0;i--){array[customDest + i]=array[customCursor + i];}
array[dest]=tmp[cursor2];
return;}
var minGallop=this.minGallop;
while(true){var count1=0;
var count2=0;
var exit=false;
do{
if(compare(tmp[cursor2],array[cursor1])< 0){array[dest--]=array[cursor1--];
count1++;
count2=0;
if(--length1===0){exit=true;
break;}}else{
array[dest--]=tmp[cursor2--];
count2++;
count1=0;
if(--length2===1){exit=true;
break;}}}while((count1 |count2)< minGallop);
if(exit){break;}
do{
count1=length1 - gallopRight(tmp[cursor2],array,start1,length1,length1 - 1,compare);
if(count1 !==0){dest -=count1;
cursor1 -=count1;
length1 -=count1;
customDest=dest + 1;
customCursor=cursor1 + 1;
for(i=count1 - 1;i >=0;i--){array[customDest + i]=array[customCursor + i];}
if(length1===0){exit=true;
break;}}
array[dest--]=tmp[cursor2--];
if(--length2===1){exit=true;
break;}
count2=length2 - gallopLeft(array[cursor1],tmp,0,length2,length2 - 1,compare);
if(count2 !==0){dest -=count2;
cursor2 -=count2;
length2 -=count2;
customDest=dest + 1;
customCursor=cursor2 + 1;
for(i=0;i < count2;i++){array[customDest + i]=tmp[customCursor + i];}
if(length2 <=1){exit=true;
break;}}
array[dest--]=array[cursor1--];
if(--length1===0){exit=true;
break;}
minGallop--;}while(count1 >=DEFAULT_MIN_GALLOPING ||count2 >=DEFAULT_MIN_GALLOPING);
if(exit){break;}
if(minGallop < 0){minGallop=0;}
minGallop +=2;}
this.minGallop=minGallop;
if(minGallop < 1){this.minGallop=1;}
if(length2===1){dest -=length1;
cursor1 -=length1;
customDest=dest + 1;
customCursor=cursor1 + 1;
for(i=length1 - 1;i >=0;i--){array[customDest + i]=array[customCursor + i];}
array[dest]=tmp[cursor2];}else if(length2===0){throw new Error('mergeHigh preconditions were not respected');}else{
customCursor=dest -(length2 - 1);
for(i=0;i < length2;i++){array[customCursor + i]=tmp[i];}}}}
if(self.length < 2 * DEFAULT_TMP_STORAGE_LENGTH){self.tmpStorageLength=self.length >>> 1;}
self.tmp=new Array(self.tmpStorageLength);
self.stackLength=
(self.length < 120 ? 5 :
self.length < 1542 ? 10 :
self.length < 119151 ? 19 : 40);
self.runStart=new Array(self.stackLength);
self.runLength=new Array(self.stackLength);
return self;}
function tim_sort(array,compare,lo,hi){if(!Array.isArray(array)){throw new TypeError('Can only sort arrays');}
if(!compare){compare=alphabeticalCompare;}else if(typeof compare !=='function'){hi=lo;
lo=compare;
compare=alphabeticalCompare;}
if(!lo){lo=0;}
if(!hi){hi=array.length;}
var remaining=hi - lo;
if(remaining < 2){return;}
var runLength=0;
if(remaining < DEFAULT_MIN_MERGE){runLength=makeAscendingRun(array,lo,hi,compare);
binaryInsertionSort(array,lo,hi,lo + runLength,compare);
return;}
var ts=new TimSort(array,compare);
var minRun=minRunLength(remaining);
do{
runLength=makeAscendingRun(array,lo,hi,compare);
if(runLength < minRun){var force=remaining;
if(force > minRun){force=minRun;}
binaryInsertionSort(array,lo,lo + force,lo + runLength,compare);
runLength=force;}
ts.pushRun(lo,runLength);
ts.mergeRuns();
remaining -=runLength;
lo +=runLength;}while(remaining !==0);
ts.forceMergeRuns();}
$B.$TimSort=tim_sort;
$B.$AlphabeticalCompare=alphabeticalCompare;})(__BRYTHON__)
;(function($B){eval($B.InjectBuiltins())
var $ObjectDict=_b_.object.$dict,$N=_b_.None
function $list(){
var args=[],pos=0
for(var i=0,_len_i=arguments.length;i < _len_i;i++){args[pos++]=arguments[i]}
return new $ListDict(args)}
var $ListDict={__class__:$B.$type,__name__:'list',$native:true,__dir__:$ObjectDict.__dir__}
$ListDict.__add__=function(self,other){if($B.get_class(self)!==$B.get_class(other)){throw TypeError('can only concatenate list (not "'+
$B.get_class(other).__name__+'") to list')}
var res=self.valueOf().concat(other.valueOf())
if(isinstance(self,tuple))res=tuple(res)
return res}
$ListDict.__contains__=function(self,item){var $=$B.args('__contains__',2,{self:null,item:null},['self','item'],arguments,{},null,null),self=$.self,item=$.item
var _eq=getattr(item,'__eq__')
var i=0
while(i<self.length){if(_eq(self[i]))return true
i++}
return false}
$ListDict.__delitem__=function(self,arg){if(isinstance(arg,_b_.int)){var pos=arg
if(arg<0)pos=self.length+pos
if(pos>=0 && pos<self.length){self.splice(pos,1)
return $N}
throw _b_.IndexError('list index out of range')}
if(isinstance(arg,_b_.slice)){var step=arg.step;if(step===None){step=1}
var start=arg.start
if(start===None){start=step>0 ? 0 : self.length}
var stop=arg.stop
if(stop===None){stop=step >0 ? self.length : 0}
if(start<0)start=self.length+start
if(stop<0)stop=self.length+stop
var res=[],i=null,pos=0
if(step>0){if(stop>start){for(var i=start;i<stop;i+=step){if(self[i]!==undefined){res[pos++]=i}}}}else{
if(stop<start){for(var i=start;i>stop;i+=step){if(self[i]!==undefined){res[pos++]=i}}
res.reverse()}}
var i=res.length
while(i--){
self.splice(res[i],1)}
return $N}
if(hasattr(arg,'__int__')||hasattr(arg,'__index__')){$ListDict.__delitem__(self,_b_.int(arg))
return $N}
throw _b_.TypeError('list indices must be integer, not '+_b_.str(arg.__class__))}
$ListDict.__eq__=function(self,other){if(isinstance(other,$B.get_class(self).$factory)){if(other.length==self.length){var i=self.length
while(i--){if(!getattr(self[i],'__eq__')(other[i]))return false}
return true}}
return false}
$ListDict.__getitem__=function(self,arg){var $=$B.args('__getitem__',2,{self:null,key:null},['self','key'],arguments,{},null,null),self=$.self,key=$.key
var klass=$B.get_class(self).$factory
if(isinstance(key,_b_.int)){var items=self.valueOf()
var pos=key
if(key<0)pos=items.length+pos
if(pos>=0 && pos<items.length)return items[pos]
throw _b_.IndexError('list index out of range')}
if(isinstance(key,_b_.slice)){
var s=_b_.slice.$dict.$conv_for_seq(key,self.length)
var res=[],i=null,items=self.valueOf(),pos=0,start=s.start,stop=s.stop,step=s.step
if(step > 0){if(stop <=start)return klass(res);
for(var i=start;i<stop;i+=step){res[pos++]=items[i]}
return klass(res);}else{
if(stop > start)return klass(res);
for(var i=start;i>stop;i+=step){res[pos++]=items[i]}
return klass(res);}}
if(hasattr(key,'__int__')||hasattr(key,'__index__')){return $ListDict.__getitem__(self,_b_.int(key))}
throw _b_.TypeError('list indices must be integer, not '+
$B.get_class(key).__name__)}
$ListDict.__ge__=function(self,other){if(!isinstance(other,[list,_b_.tuple])){throw _b_.TypeError("unorderable types: list() >= "+
$B.get_class(other).__name__+'()')}
var i=0
while(i<self.length){if(i>=other.length)return true
if(getattr(self[i],'__eq__')(other[i])){i++}
else return(getattr(self[i],"__ge__")(other[i]))}
return other.length==self.length}
$ListDict.__gt__=function(self,other){if(!isinstance(other,[list,_b_.tuple])){throw _b_.TypeError("unorderable types: list() > "+
$B.get_class(other).__name__+'()')}
var i=0
while(i<self.length){if(i>=other.length)return true
if(getattr(self[i],'__eq__')(other[i])){i++}
else return(getattr(self[i],'__gt__')(other[i]))}
return false}
$ListDict.__hash__=None
$ListDict.__iadd__=function(){var $=$B.args('__iadd__',2,{self:null,x:null},['self','x'],arguments,{},null,null)
var x=list($B.$iter($.x))
for(var i=0;i < x.length;i++){$.self.push(x[i])}
return $.self}
$ListDict.__imul__=function(){var $=$B.args('__imul__',2,{self:null,x:null},['self','x'],arguments,{},null,null)
var x=$B.$GetInt($.x),len=$.self.length,pos=len
if(x==0){$ListDict.clear($.self);return $.self}
for(var i=1;i < x;i++){for(j=0;j<len;j++){$.self[pos++]=$.self[j]}}
return $.self}
$ListDict.__init__=function(self,arg){var len_func=getattr(self,'__len__'),pop_func=getattr(self,'pop')
while(len_func())pop_func()
if(arg===undefined)return $N
var arg=$B.$iter(arg)
var next_func=getattr(arg,'__next__')
var pos=len_func()
while(1){try{self[pos++]=next_func()}
catch(err){if(err.__name__=='StopIteration'){break}
else{throw err}}}
return $N}
var $list_iterator=$B.$iterator_class('list_iterator')
$ListDict.__iter__=function(self){return $B.$iterator(self,$list_iterator)}
$ListDict.__le__=function(self,other){return !$ListDict.__gt__(self,other)}
$ListDict.__len__=function(self){return self.length}
$ListDict.__lt__=function(self,other){return !$ListDict.__ge__(self,other)}
$ListDict.__mro__=[$ObjectDict]
$ListDict.__mul__=function(self,other){if(isinstance(other,_b_.int)){
var res=[],$temp=self.slice(),len=$temp.length
for(var i=0;i<other;i++){for(var j=0;j<len;j++){res.push($temp[j])}}
res.__class__=self.__class__
return res}
if(hasattr(other,'__int__')||hasattr(other,'__index__')){return $ListDict.__mul__(self,_b_.int(other))}
throw _b_.TypeError("can't multiply sequence by non-int of type '"+
$B.get_class(other).__name__+"'")}
$ListDict.__ne__=function(self,other){return !$ListDict.__eq__(self,other)}
$ListDict.__repr__=function(self){if(self===undefined)return "<class 'list'>"
var _r=[]
for(var i=0;i<self.length;i++){if(self[i]===self){_r.push('[...]')}
else{_r.push(_b_.repr(self[i]))}}
if(self.__class__===$TupleDict){if(self.length==1){return '('+_r[0]+',)'}
return '('+_r.join(', ')+')'}
return '['+_r.join(', ')+']'}
$ListDict.__setitem__=function(){var $=$B.args('__setitem__',3,{self:null,key:null,value:null},['self','key','value'],arguments,{},null,null),self=$.self,arg=$.key,value=$.value
if(isinstance(arg,_b_.int)){var pos=arg
if(arg<0)pos=self.length+pos
if(pos>=0 && pos<self.length){self[pos]=value}
else{throw _b_.IndexError('list index out of range')}
return $N}
if(isinstance(arg,_b_.slice)){var s=_b_.slice.$dict.$conv_for_seq(arg,self.length)
if(arg.step===null){$B.set_list_slice(self,s.start,s.stop,value)}
else{$B.set_list_slice_step(self,s.start,s.stop,s.step,value)}
return $N}
if(hasattr(arg,'__int__')||hasattr(arg,'__index__')){$ListDict.__setitem__(self,_b_.int(arg),value)
return $N}
throw _b_.TypeError('list indices must be integer, not '+arg.__class__.__name__)}
$ListDict.__str__=$ListDict.__repr__
$B.make_rmethods($ListDict)
var _ops=['add','sub']
$ListDict.append=function(){var $=$B.args('append',2,{self:null,x:null},['self','x'],arguments,{},null,null)
$.self[$.self.length]=$.x
return $N}
$ListDict.clear=function(){var $=$B.args('clear',1,{self:null},['self'],arguments,{},null,null)
while($.self.length){$.self.pop()}
return $N}
$ListDict.copy=function(){var $=$B.args('copy',1,{self:null},['self'],arguments,{},null,null)
return $.self.slice()}
$ListDict.count=function(){var $=$B.args('count',2,{self:null,x:null},['self','x'],arguments,{},null,null)
var res=0
_eq=getattr($.x,'__eq__')
var i=$.self.length
while(i--)if(_eq($.self[i]))res++
return res}
$ListDict.extend=function(){var $=$B.args('extend',2,{self:null,t:null},['self','t'],arguments,{},null,null)
other=list($B.$iter($.t))
for(var i=0;i<other.length;i++){$.self.push(other[i])}
return $N}
$ListDict.index=function(){var $=$B.args('index',4,{self:null,x:null,start:null,stop:null},['self','x','start','stop'],arguments,{start:null,stop:null},null,null),self=$.self,start=$.start,stop=$.stop
var _eq=getattr($.x,'__eq__')
if(start===null){start=0}
else{if(start.__class__===$B.LongInt.$dict){start=parseInt(start.value)*(start.pos ? 1 : -1)}
if(start<0){start=Math.max(0,start+self.length)}}
if(stop===null){stop=self.length}
else{if(stop.__class__===$B.LongInt.$dict){stop=parseInt(stop.value)*(stop.pos ? 1 : -1)}
if(stop<0){stop=Math.min(self.length,stop+self.length)}}
for(var i=start;i < stop;i++){if(_eq(self[i]))return i}
throw _b_.ValueError(_b_.str($.x)+" is not in list")}
$ListDict.insert=function(){var $=$B.args('insert',3,{self:null,i:null,item:null},['self','i','item'],arguments,{},null,null)
$.self.splice($.i,0,$.item)
return $N}
$ListDict.pop=function(){var $=$B.args('pop',2,{self:null,pos:null},['self','pos'],arguments,{pos:null},null,null),self=$.self,pos=$.pos
if(pos===null){pos=self.length-1}
pos=$B.$GetInt(pos)
if(pos<0){pos+=self.length}
var res=self[pos]
if(res===undefined){throw _b_.IndexError('pop index out of range')}
self.splice(pos,1)
return res}
$ListDict.remove=function(){var $=$B.args('remove',2,{self:null,x:null},['self','x'],arguments,{},null,null)
for(var i=0,_len_i=$.self.length;i < _len_i;i++){if(getattr($.self[i],'__eq__')($.x)){$.self.splice(i,1)
return $N}}
throw _b_.ValueError(_b_.str($.x)+" is not in list")}
$ListDict.reverse=function(self){var $=$B.args('reverse',1,{self:null},['self'],arguments,{},null,null),_len=$.self.length-1,i=parseInt($.self.length/2)
while(i--){var buf=$.self[i]
$.self[i]=$.self[_len-i]
$.self[_len-i]=buf}
return $N}
function $partition(arg,array,begin,end,pivot)
{var piv=array[pivot];
array=swap(array,pivot,end-1);
var store=begin;
if(arg===null){if(array.$cl!==false){
var le_func=_b_.getattr(array.$cl,'__le__')
for(var ix=begin;ix<end-1;++ix){if(le_func(array[ix],piv)){array=swap(array,store,ix);
++store;}}}else{for(var ix=begin;ix<end-1;++ix){if(getattr(array[ix],'__le__')(piv)){array=swap(array,store,ix);
++store;}}}}else{var len=array.length
for(var ix=begin;ix<end-1;++ix){var x=arg(array[ix])
if(array.length!==len){throw ValueError('list modified during sort')}
if(getattr(x,'__le__')(arg(piv))){array=swap(array,store,ix);
++store;}}}
array=swap(array,end-1,store);
return store;}
function swap(_array,a,b){var tmp=_array[a];
_array[a]=_array[b];
_array[b]=tmp;
return _array}
function $qsort(arg,array,begin,end)
{if(end-1>begin){var pivot=begin+Math.floor(Math.random()*(end-begin))
pivot=$partition(arg,array,begin,end,pivot);
$qsort(arg,array,begin,pivot);
$qsort(arg,array,pivot+1,end);}}
function $elts_class(self){
if(self.length==0){return null}
var cl=$B.get_class(self[0]),i=self.length
while(i--){
if($B.get_class(self[i])!==cl)return false}
return cl}
$ListDict.sort=function(self){var $=$B.args('sort',1,{self:null},['self'],arguments,{},null,'kw')
var func=null
var reverse=false
var kw_args=$.kw,keys=_b_.list(_b_.dict.$dict.keys(kw_args))
for(var i=0;i<keys.length;i++){if(keys[i]=="key"){func=getattr(kw_args.$string_dict[keys[i]],'__call__')}
else if(keys[i]=='reverse'){reverse=kw_args.$string_dict[keys[i]]}
else{throw _b_.TypeError("'"+keys[i]+
"' is an invalid keyword argument for this function")}}
if(self.length==0)return
self.$cl=$elts_class(self)
var cmp=null;
if(func===null && self.$cl===_b_.str.$dict){if(reverse)
cmp=function(b,a){return $B.$AlphabeticalCompare(a,b)};
else
cmp=function(a,b){return $B.$AlphabeticalCompare(a,b)};}
else if(func===null && self.$cl===_b_.int.$dict){if(reverse)
cmp=function(b,a){return a-b};
else
cmp=function(a,b){return a-b};}else{
if(func===null){if(reverse){cmp=function(b,a){if(getattr(a,'__le__')(b)){if(a==b){return 0};
return -1;}
return 1;}}else{
cmp=function(a,b){if(getattr(a,'__le__')(b)){if(a==b){return 0};
return -1;}
return 1;}}}else{
if(reverse){cmp=function(b,a){var _a=func(a),_b=func(b);
if(getattr(_a,'__le__')(_b)){if(_a==_b){return 0};
return -1;}
return 1;}}else{
cmp=function(a,b){var _a=func(a),_b=func(b);
if(getattr(_a,'__le__')(_b)){if(_a==_b){return 0};
return -1;}
return 1;}}}}
$B.$TimSort(self,cmp,0,self.length)
return(self.__brython__ ? $N : self)}
$B.set_func_names($ListDict)
$B.$list=function(t){t.__brython__=true;
return t}
function list(){if(arguments.length==0){return[]}
var $=$B.args('list',1,{obj:null},['obj'],arguments,{},null,null),obj=$.obj
if(Array.isArray(obj)){
obj=obj.slice()
obj.__brython__=true;
if(obj.__class__==$TupleDict){var res=obj.slice()
res.__class__=$ListDict
return res}
return obj}
var res=[],pos=0,arg=$B.$iter(obj),next_func=getattr(arg,'__next__'),ce=$B.current_exception
while(1){try{res[pos++]=next_func()}
catch(err){if(!isinstance(err,_b_.StopIteration)){throw err}
$B.current_exception=ce
break}}
res.__brython__=true
return res}
list.__class__=$B.$factory
list.$dict=$ListDict
$ListDict.$factory=list
list.$is_func=true
list.__module__='builtins'
list.__bases__=[]
var $ListSubclassDict={__class__:$B.$type,__name__:'list',__new__: function(cls){return{__class__:cls.$dict,$t:[]}}}
for(var $attr in $ListDict){if(typeof $ListDict[$attr]=='function' &&
$ListDict[$attr].__class__!==$B.$factory){
$ListDict[$attr]=(function(attr){var method=$ListDict[attr],func=function(){var self=arguments[0]
if(self.$t!==undefined){var args=[self.$t]
for(var i=1,len=arguments.length;i<len;i++){args.push(arguments[i])}
return method.apply(null,args)}else{return method.apply(null,arguments)}}
return func})($attr)
$ListSubclassDict[$attr]=(function(attr){return function(){var args=[]
if(arguments.length>0){var args=[arguments[0].$t]
var pos=1
for(var i=1,_len_i=arguments.length;i < _len_i;i++){args[pos++]=arguments[i]}}
return $ListDict[attr].apply(null,args)}})($attr)}}
$ListSubclassDict.__mro__=[$ObjectDict]
$B.$ListSubclassFactory={__class__:$B.$factory,$dict:$ListSubclassDict}
function $tuple(arg){return arg}
var $TupleDict={__class__:$B.$type,__name__:'tuple',$native:true}
$TupleDict.__iter__=function(self){return $B.$iterator(self,$tuple_iterator)}
var $tuple_iterator=$B.$iterator_class('tuple_iterator')
function tuple(){var obj=list.apply(null,arguments)
obj.__class__=$TupleDict
return obj}
tuple.__class__=$B.$factory
tuple.$dict=$TupleDict
tuple.$is_func=true
$TupleDict.$factory=tuple
$TupleDict.__new__=$B.$__new__(tuple)
tuple.__module__='builtins'
for(var attr in $ListDict){switch(attr){case '__delitem__':
case '__iadd__':
case '__imul__':
case '__setitem__':
case 'append':
case 'extend':
case 'insert':
case 'remove':
case 'pop':
case 'reverse':
case 'sort':
break
default:
if($TupleDict[attr]===undefined){if(typeof $ListDict[attr]=='function'){$TupleDict[attr]=(function(x){return function(){return $ListDict[x].apply(null,arguments)}})(attr)}else{$TupleDict[attr]=$ListDict[attr]}}}}
$TupleDict.__delitem__=function(){throw _b_.TypeError("'tuple' object doesn't support item deletion")}
$TupleDict.__setitem__=function(){throw _b_.TypeError("'tuple' object does not support item assignment")}
$TupleDict.__eq__=function(self,other){
if(other===undefined)return self===tuple
return $ListDict.__eq__(self,other)}
function c_mul(a,b){s=((parseInt(a)* b)& 0xFFFFFFFF).toString(16)
return parseInt(s.substr(0,s.length-1),16)}
$TupleDict.__hash__=function(self){
var x=0x3456789
for(var i=0,_len_i=self.length;i < _len_i;i++){var y=_b_.hash(self[i]);
x=c_mul(1000003,x)^ y & 0xFFFFFFFF;}
return x}
$TupleDict.__mro__=[$ObjectDict]
$TupleDict.__name__='tuple'
$B.set_func_names($TupleDict)
_b_.list=list
_b_.tuple=tuple
_b_.object.$dict.__bases__=tuple()})(__BRYTHON__)
;(function($B){eval($B.InjectBuiltins())
if(!String.prototype.trim){
String.prototype.trim=function(){var c;
for(var i=0;i < this.length;i++){c=this.charCodeAt(i);
if(c==32 ||c==10 ||c==13 ||c==9 ||c==12 ||c==11 ||c==160 ||c==5760 ||c==6158 ||c==8192 ||c==8193 ||c==8194 ||c==8195 ||c==8196 ||c==8197 ||c==8198 ||c==8199 ||c==8200 ||c==8201 ||c==8202 ||c==8232 ||c==8233 ||c==8239 ||c==8287 ||c==12288 ||c==65279)
continue;else break;}
for(var j=this.length - 1;j >=i;j--){c=this.charCodeAt(j);
if(c==32 ||c==10 ||c==13 ||c==9 ||c==12 ||c==11 ||c==160 ||c==5760 ||c==6158 ||c==8192 ||c==8193 ||c==8194 ||c==8195 ||c==8196 ||c==8197 ||c==8198 ||c==8199 ||c==8200 ||c==8201 ||c==8202 ||c==8232 ||c==8233 ||c==8239 ||c==8287 ||c==12288 ||c==65279)
continue;else break;}
return this.substring(i,j + 1);}}
if(!String.prototype.trimLeft){
String.prototype.trimLeft=function(){var c;
for(var i=0;i < this.length;i++){c=this.charCodeAt(i);
if(c==32 ||c==10 ||c==13 ||c==9 ||c==12 ||c==11 ||c==160 ||c==5760 ||c==6158 ||c==8192 ||c==8193 ||c==8194 ||c==8195 ||c==8196 ||c==8197 ||c==8198 ||c==8199 ||c==8200 ||c==8201 ||c==8202 ||c==8232 ||c==8233 ||c==8239 ||c==8287 ||c==12288 ||c==65279)
continue;else break;}
return this.substring(i);};}
if(!String.prototype.trimRight){String.prototype.trimRight=function(){
var c;
for(var j=this.length - 1;j >=0;j--){c=this.charCodeAt(j);
if(c==32 ||c==10 ||c==13 ||c==9 ||c==12 ||c==11 ||c==160 ||c==5760 ||c==6158 ||c==8192 ||c==8193 ||c==8194 ||c==8195 ||c==8196 ||c==8197 ||c==8198 ||c==8199 ||c==8200 ||c==8201 ||c==8202 ||c==8232 ||c==8233 ||c==8239 ||c==8287 ||c==12288 ||c==65279)
continue;else break;}
return this.substring(0,j + 1);};}
var $ObjectDict=object.$dict
var $StringDict={__class__:$B.$type,__dir__:$ObjectDict.__dir__,__name__:'str',$native:true}
function normalize_start_end($){if($.start===null||$.start===_b_.None){$.start=0}
else if($.start<0){$.start +=$.self.length;$.start=Math.max(0,$.start)}
if($.end===null||$.end===_b_.None){$.end=$.self.length}
else if($.end<0){$.end +=$.self.length;$.end=Math.max(0,$.end)}
if(!isinstance($.start,_b_.int)||!isinstance($.end,_b_.int)){throw _b_.TypeError(
"slice indices must be integers or None or have an __index__ method")}}
function reverse(s){
return s.split('').reverse().join('')}
function check_str(obj){if(!_b_.isinstance(obj,str)){throw _b_.TypeError("can't convert '"+
$B.get_class(obj).__name__+"' object to str implicitely")}}
$StringDict.__add__=function(self,other){if(!(typeof other==="string")){try{return getattr(other,'__radd__')(self)}
catch(err){throw _b_.TypeError(
"Can't convert "+$B.get_class(other).__name__+" to str implicitely")}}
return self+other}
$StringDict.__contains__=function(self,item){if(!(typeof item==="string")){throw _b_.TypeError(
"'in <string>' requires string as left operand, not "+item.__class__)}
var nbcar=item.length
if(nbcar==0)return true
if(self.length==0)return nbcar==0
for(var i=0,_len_i=self.length;i < _len_i;i++){if(self.substr(i,nbcar)==item)return true}
return false}
$StringDict.__delitem__=function(){throw _b_.TypeError("'str' object doesn't support item deletion")}
$StringDict.__dir__=$ObjectDict.__dir__
$StringDict.__eq__=function(self,other){if(other===undefined){
return self===str}
if(_b_.isinstance(other,_b_.str)){return other.valueOf()==self.valueOf()}
return other===self.valueOf()}
function preformat(self,fmt){if(fmt.empty){return _b_.str(self)}
if(fmt.type && fmt.type!='s'){throw _b_.ValueError("Unknown format code '"+fmt.type+
"' for object of type 'str'")}
return self}
$StringDict.__format__=function(self,format_spec){var fmt=new $B.parse_format_spec(format_spec)
if(fmt.sign!==undefined){throw _b_.ValueError("Sign not allowed in string format specifier")}
fmt.align=fmt.align ||'<'
return $B.format_width(preformat(self,fmt),fmt)}
$StringDict.__getitem__=function(self,arg){if(isinstance(arg,_b_.int)){var pos=arg
if(arg<0)pos+=self.length
if(pos>=0 && pos<self.length)return self.charAt(pos)
throw _b_.IndexError('string index out of range')}
if(isinstance(arg,slice)){var s=_b_.slice.$dict.$conv_for_seq(arg,self.length),start=s.start,stop=s.stop,step=s.step
var res='',i=null
if(step>0){if(stop<=start)return ''
for(var i=start;i<stop;i+=step)res +=self.charAt(i)}else{
if(stop>=start)return ''
for(var i=start;i>stop;i+=step)res +=self.charAt(i)}
return res}
if(isinstance(arg,bool))return self.__getitem__(_b_.int(arg))
throw _b_.TypeError('string indices must be integers')}
$StringDict.__hash__=function(self){if(self===undefined){return $StringDict.__hashvalue__ ||$B.$py_next_hash-- }
var hash=1;
for(var i=0,_len_i=self.length;i < _len_i;i++){hash=(101*hash + self.charCodeAt(i))& 0xFFFFFFFF}
return hash}
$StringDict.__init__=function(self,arg){self.valueOf=function(){return arg}
self.toString=function(){return arg}
return _b_.None}
var $str_iterator=$B.$iterator_class('str_iterator')
$StringDict.__iter__=function(self){var items=self.split('')
return $B.$iterator(items,$str_iterator)}
$StringDict.__len__=function(self){return self.length}
var kwarg_key=new RegExp('([^\\)]*)\\)')
var NotANumber=function(){this.name='NotANumber'}
var number_check=function(s){if(!isinstance(s,[_b_.int,_b_.float])){throw new NotANumber()}}
var get_char_array=function(size,char){if(size <=0)
return ''
return new Array(size + 1).join(char)}
var format_padding=function(s,flags,minus_one){var padding=flags.padding
if(!padding){
return s}
s=s.toString()
padding=parseInt(padding,10)
if(minus_one){
padding -=1}
if(!flags.left){return get_char_array(padding - s.length,flags.pad_char)+ s}else{
return s + get_char_array(padding - s.length,flags.pad_char)}}
var format_int_precision=function(val,flags){var precision=flags.precision
if(!precision){return val.toString()}
precision=parseInt(precision,10)
var s
if(val.__class__===$B.LongInt.$dict){s=$B.LongInt.$dict.to_base(val,10)}else{
s=val.toString()}
if(s[0]==='-'){return '-' + get_char_array(precision - s.length + 1,'0')+ s.slice(1)}
return get_char_array(precision - s.length,'0')+ s}
var format_float_precision=function(val,upper,flags,modifier){var precision=flags.precision
if(isFinite(val)){return modifier(val,precision,flags,upper)}
if(val===Infinity){val='inf'}else if(val===-Infinity){val='-inf'}else{
val='nan'}
if(upper){return val.toUpperCase()}
return val}
var format_sign=function(val,flags){if(flags.sign){if(val >=0){return "+"}}else if(flags.space){if(val >=0){return " "}}
return ""}
var str_format=function(val,flags){
flags.pad_char=" "
return format_padding(str(val),flags)}
var num_format=function(val,flags){number_check(val)
if(val.__class__===$B.LongInt.$dict){val=$B.LongInt.$dict.to_base(val,10)}else{
val=parseInt(val)}
var s=format_int_precision(val,flags)
if(flags.pad_char==='0'){if(val < 0){s=s.substring(1)
return '-' + format_padding(s,flags,true)}
var sign=format_sign(val,flags)
if(sign !==''){return sign + format_padding(s,flags,true)}}
return format_padding(format_sign(val,flags)+ s,flags)}
var repr_format=function(val,flags){flags.pad_char=" "
return format_padding(repr(val),flags)}
var ascii_format=function(val,flags){flags.pad_char=" "
return format_padding(ascii(val),flags)}
var _float_helper=function(val,flags){number_check(val)
if(!flags.precision){if(!flags.decimal_point){flags.precision=6}else{
flags.precision=0}}else{
flags.precision=parseInt(flags.precision,10)
validate_precision(flags.precision)}
return parseFloat(val)}
var trailing_zeros=/(.*?)(0+)([eE].*)/
var leading_zeros=/\.(0*)/
var trailing_dot=/\.$/
var validate_precision=function(precision){
if(precision > 20){precision=20 }}
var floating_point_format=function(val,upper,flags){val=_float_helper(val,flags)
var v=val.toString()
var v_len=v.length
var dot_idx=v.indexOf('.')
if(dot_idx < 0){dot_idx=v_len}
if(val < 1 && val > -1){var zeros=leading_zeros.exec(v)
var numzeros
if(zeros){numzeros=zeros[1].length}else{
numzeros=0}
if(numzeros >=4){val=format_sign(val,flags)+ format_float_precision(val,upper,flags,_floating_g_exp_helper)
if(!flags.alternate){var trl=trailing_zeros.exec(val)
if(trl){val=trl[1].replace(trailing_dot,'')+ trl[3]}}else{
if(flags.precision <=1){val=val[0]+ '.' + val.substring(1)}}
return format_padding(val,flags)}
flags.precision=(flags.precision ||0)+ numzeros
return format_padding(format_sign(val,flags)+ format_float_precision(val,upper,flags,function(val,precision){return val.toFixed(min(precision,v_len - dot_idx)+ numzeros)}),flags)}
if(dot_idx > flags.precision){val=format_sign(val,flags)+ format_float_precision(val,upper,flags,_floating_g_exp_helper)
if(!flags.alternate){var trl=trailing_zeros.exec(val)
if(trl){val=trl[1].replace(trailing_dot,'')+ trl[3]}}else{
if(flags.precision <=1){val=val[0]+ '.' + val.substring(1)}}
return format_padding(val,flags)}
return format_padding(format_sign(val,flags)+ format_float_precision(val,upper,flags,function(val,precision){if(!flags.decimal_point){precision=min(v_len - 1,6)}else if(precision > v_len){if(!flags.alternate){precision=v_len}}
if(precision < dot_idx){precision=dot_idx}
return val.toFixed(precision - dot_idx)}),flags)}
var _floating_g_exp_helper=function(val,precision,flags,upper){if(precision){--precision}
val=val.toExponential(precision)
var e_idx=val.lastIndexOf('e')
if(e_idx > val.length - 4){val=val.substring(0,e_idx + 2)+ '0' + val.substring(e_idx + 2)}
if(upper){return val.toUpperCase()}
return val}
var floating_point_decimal_format=function(val,upper,flags){val=_float_helper(val,flags)
return format_padding(format_sign(val,flags)+ format_float_precision(val,upper,flags,function(val,precision,flags){val=val.toFixed(precision)
if(precision===0 && flags.alternate){val +='.'}
return val}),flags)}
var _floating_exp_helper=function(val,precision,flags,upper){val=val.toExponential(precision)
var e_idx=val.lastIndexOf('e')
if(e_idx > val.length - 4){val=val.substring(0,e_idx + 2)+ '0' + val.substring(e_idx + 2)}
if(upper){return val.toUpperCase()}
return val}
var floating_point_exponential_format=function(val,upper,flags){val=_float_helper(val,flags)
return format_padding(format_sign(val,flags)+ format_float_precision(val,upper,flags,_floating_exp_helper),flags)}
var signed_hex_format=function(val,upper,flags){var ret
number_check(val)
if(val.__class__===$B.LongInt.$dict){ret=$B.LongInt.$dict.to_base(val,16)}else{
ret=parseInt(val)
ret=ret.toString(16)}
ret=format_int_precision(ret,flags)
if(upper){ret=ret.toUpperCase()}
if(flags.pad_char==='0'){if(val < 0){ret=ret.substring(1)
ret='-' + format_padding(ret,flags,true)}
var sign=format_sign(val,flags)
if(sign !==''){ret=sign + format_padding(ret,flags,true)}}
if(flags.alternate){if(ret.charAt(0)==='-'){if(upper){ret="-0X" + ret.slice(1)}else{
ret="-0x" + ret.slice(1)}}else{
if(upper){ret="0X" + ret}else{
ret="0x" + ret}}}
return format_padding(format_sign(val,flags)+ ret,flags)}
var octal_format=function(val,flags){number_check(val)
var ret
if(val.__class__===$B.LongInt.$dict){ret=$B.LongInt.$dict.to_base(8)}else{
ret=parseInt(val)
ret=ret.toString(8)}
ret=format_int_precision(ret,flags)
if(flags.pad_char==='0'){if(val < 0){ret=ret.substring(1)
ret='-' + format_padding(ret,flags,true)}
var sign=format_sign(val,flags)
if(sign !==''){ret=sign + format_padding(ret,flags,true)}}
if(flags.alternate){if(ret.charAt(0)==='-'){ret="-0o" + ret.slice(1)}else{
ret="0o" + ret}}
return format_padding(ret,flags)}
var single_char_format=function(val,flags){if(isinstance(val,str)&& val.length==1)return val
try{
val=_b_.int(val)}catch(err){throw _b_.TypeError('%c requires int or char')}
return format_padding(chr(val),flags)}
var num_flag=function(c,flags){if(c==='0' && !flags.padding && !flags.decimal_point && !flags.left){flags.pad_char='0'
return}
if(!flags.decimal_point){flags.padding=(flags.padding ||"")+ c}else{
flags.precision=(flags.precision ||"")+ c}}
var decimal_point_flag=function(val,flags){if(flags.decimal_point){
throw new UnsupportedChar()}
flags.decimal_point=true}
var neg_flag=function(val,flags){flags.pad_char=' '
flags.left=true}
var space_flag=function(val,flags){flags.space=true}
var sign_flag=function(val,flags){flags.sign=true}
var alternate_flag=function(val,flags){flags.alternate=true}
var char_mapping={'s': str_format,'d': num_format,'i': num_format,'u': num_format,'o': octal_format,'r': repr_format,'a': ascii_format,'g': function(val,flags){return floating_point_format(val,false,flags)},'G': function(val,flags){return floating_point_format(val,true,flags)},'f': function(val,flags){return floating_point_decimal_format(val,false,flags)},'F': function(val,flags){return floating_point_decimal_format(val,true,flags)},'e': function(val,flags){return floating_point_exponential_format(val,false,flags)},'E': function(val,flags){return floating_point_exponential_format(val,true,flags)},'x': function(val,flags){return signed_hex_format(val,false,flags)},'X': function(val,flags){return signed_hex_format(val,true,flags)},'c': single_char_format,'0': function(val,flags){return num_flag('0',flags)},'1': function(val,flags){return num_flag('1',flags)},'2': function(val,flags){return num_flag('2',flags)},'3': function(val,flags){return num_flag('3',flags)},'4': function(val,flags){return num_flag('4',flags)},'5': function(val,flags){return num_flag('5',flags)},'6': function(val,flags){return num_flag('6',flags)},'7': function(val,flags){return num_flag('7',flags)},'8': function(val,flags){return num_flag('8',flags)},'9': function(val,flags){return num_flag('9',flags)},'-': neg_flag,' ': space_flag,'+': sign_flag,'.': decimal_point_flag,'#': alternate_flag}
var UnsupportedChar=function(){this.name="UnsupportedChar"}
$StringDict.__mod__=function(self,args){var length=self.length,pos=0 |0,argpos=null,getitem
if(_b_.isinstance(args,_b_.tuple)){argpos=0 |0}else{getitem=_b_.getattr(args,'__getitem__',null)}
var ret=''
var $get_kwarg_string=function(s){
++pos
var rslt=kwarg_key.exec(s.substring(newpos))
if(!rslt){throw _b_.ValueError("incomplete format key")}
var key=rslt[1]
newpos +=rslt[0].length
try{
var self=getitem(key)}catch(err){if(err.name==="KeyError"){throw err}
throw _b_.TypeError("format requires a mapping")}
return get_string_value(s,self)}
var $get_arg_string=function(s){
var self
if(argpos===null){
self=args}else{
self=args[argpos++]
if(self===undefined){throw _b_.TypeError("not enough arguments for format string")}}
return get_string_value(s,self)}
var get_string_value=function(s,self){
var flags={'pad_char': ' '}
do{
var func=char_mapping[s[newpos]]
try{
if(func===undefined){throw new UnsupportedChar()}else{
var ret=func(self,flags)
if(ret !==undefined){return ret}
++newpos}}catch(err){if(err.name==="UnsupportedChar"){invalid_char=s[newpos]
if(invalid_char===undefined){throw _b_.ValueError("incomplete format")}
throw _b_.ValueError("unsupported format character '" + invalid_char +
"' (0x" + invalid_char.charCodeAt(0).toString(16)+ ") at index " + newpos)}else if(err.name==="NotANumber"){var try_char=s[newpos]
var cls=self.__class__
if(!cls){if(typeof(self)==='string'){cls='str'}else{
cls=typeof(self)}}else{
cls=cls.__name__}
throw _b_.TypeError("%" + try_char + " format: a number is required, not " + cls)}else{
throw err}}}while(true)}
var nbph=0
do{
var newpos=self.indexOf('%',pos)
if(newpos < 0){ret +=self.substring(pos)
break}
ret +=self.substring(pos,newpos)
++newpos
if(newpos < length){if(self[newpos]==='%'){ret +='%'}else{
nbph++
if(self[newpos]==='('){++newpos
ret +=$get_kwarg_string(self)}else{
ret +=$get_arg_string(self)}}}else{
throw _b_.ValueError("incomplete format")}
pos=newpos + 1}while(pos < length)
if(argpos!==null){if(args.length>argpos){throw _b_.TypeError('not enough arguments for format string')}else if(args.length<argpos){throw _b_.TypeError('not all arguments converted during string formatting')}}else if(nbph==0){throw _b_.TypeError('not all arguments converted during string formatting')}
return ret}
$StringDict.__mro__=[$ObjectDict]
$StringDict.__mul__=function(){var $=$B.args('__mul__',2,{self:null,other:null},['self','other'],arguments,{},null,null)
if(!isinstance($.other,_b_.int)){throw _b_.TypeError(
"Can't multiply sequence by non-int of type '"+
$B.get_class($.other).__name__+"'")}
var $res=''
for(var i=0;i<$.other;i++){$res+=$.self.valueOf()}
return $res}
$StringDict.__ne__=function(self,other){return other!==self.valueOf()}
$StringDict.__repr__=function(self){var res=self.replace(/\n/g,'\\\\n')
res=res.replace(/\\/g,'\\\\')
if(res.search('"')==-1 && res.search("'")==-1){return "'"+res+"'"}else if(self.search('"')==-1){return '"'+res+'"'}
var qesc=new RegExp("'","g")
res="'"+res.replace(qesc,"\\'")+"'"
return res}
$StringDict.__setitem__=function(self,attr,value){throw _b_.TypeError("'str' object does not support item assignment")}
$StringDict.__str__=function(self){if(self===undefined)return "<class 'str'>"
return self.toString()}
$StringDict.toString=function(){return 'string!'}
var $comp_func=function(self,other){if(typeof other !=="string"){throw _b_.TypeError(
"unorderable types: 'str' > "+$B.get_class(other).__name__+"()")}
return self > other}
$comp_func +=''
var $comps={'>':'gt','>=':'ge','<':'lt','<=':'le'}
for(var $op in $comps){eval("$StringDict.__"+$comps[$op]+'__ = '+$comp_func.replace(/>/gm,$op))}
$B.make_rmethods($StringDict)
var $notimplemented=function(self,other){throw NotImplementedError("OPERATOR not implemented for class str")}
$StringDict.title=unicode.title;
$StringDict.capitalize=unicode.capitalize;
$StringDict.casefold=unicode.casefold;
$StringDict.islower=unicode.islower;
$StringDict.isupper=unicode.isupper;
$StringDict.istitle=unicode.istitle;
$StringDict.isspace=unicode.isspace;
$StringDict.isalpha=unicode.isalpha;
$StringDict.isalnum=unicode.isalnum;
$StringDict.isdecimal=unicode.isdecimal;
$StringDict.isdigit=unicode.isdigit;
$StringDict.isnumeric=unicode.isnumeric;
$StringDict.isidentifier=unicode.isidentifier;
$StringDict.isprintable=unicode.isprintable;
$StringDict.lower=unicode.lower;
$StringDict.swapcase=unicode.swapcase;
$StringDict.upper=unicode.upper;
$StringDict.center=function(self,width,fillchar){var $=$B.args("center",3,{self:null,width:null,fillchar:null},['self','width','fillchar'],arguments,{fillchar:' '},null,null)
if($.width<=self.length)return self
var pad=parseInt(($.width-self.length)/2)
var res=$.fillchar.repeat(pad)
res +=self + res
if(res.length<$.width){res +=$.fillchar}
return res}
$StringDict.count=function(){var $=$B.args('count',4,{self:null,sub:null,start:null,stop:null},['self','sub','start','stop'],arguments,{start:null,stop:null},null,null)
if(!(typeof $.sub==="string")){throw _b_.TypeError(
"Can't convert '"+$B.get_class($.sub).__name__+"' object to str implicitly")}
var substr=$.self
if($.start!==null){var _slice
if($.stop!==null){_slice=_b_.slice($.start,$.stop)}
else{_slice=_b_.slice($.start,$.self.length)}
substr=$StringDict.__getitem__.apply(null,[$.self].concat(_slice))}else{if($.self.length+$.sub.length==0){return 1}}
if($.sub.length==0){if($.start==$.self.length){return 1}
else if(substr.length==0){return 0}
return substr.length+1}
var n=0,pos=0
while(pos<substr.length){pos=substr.indexOf($.sub,pos)
if(pos>=0){n++;pos+=$.sub.length}else break;}
return n}
$StringDict.encode=function(self,encoding){if(encoding===undefined)encoding='utf-8'
if(encoding=='rot13' ||encoding=='rot_13'){
var res=''
for(var i=0,_len=self.length;i<_len ;i++){var char=self.charAt(i)
if(('a'<=char && char<='m')||('A'<=char && char<='M')){res +=String.fromCharCode(String.charCodeAt(char)+13)}else if(('m'<char && char<='z')||('M'<char && char<='Z')){res +=String.fromCharCode(String.charCodeAt(char)-13)}else{res +=char}}
return res}
return _b_.bytes(self,encoding)}
$StringDict.endswith=function(){
var $=$B.args("endswith",4,{self:null,suffix:null,start:null,end:null},['self','suffix','start','end'],arguments,{start:0,end:null},null,null)
normalize_start_end($)
var suffixes=$.suffix
if(!isinstance(suffixes,_b_.tuple)){suffixes=[suffixes]}
var s=$.self.substring($.start,$.end)
for(var i=0,_len_i=suffixes.length;i < _len_i;i++){var suffix=suffixes[i]
if(!_b_.isinstance(suffix,str)){throw _b_.TypeError(
"endswith first arg must be str or a tuple of str, not int")}
if(suffix.length<=s.length &&
s.substr(s.length-suffix.length)==suffix)return true}
return false}
$StringDict.expandtabs=function(self,tabsize){var $=$B.args('expandtabs',2,{self:null,tabsize:null},['self','tabsize'],arguments,{tabsize:8},null,null)
var s=$B.$GetInt($.tabsize),col=0,pos=0,res=''
if(s==1){return self.replace(/\t/g,' ')}
while(pos<self.length){var car=self.charAt(pos)
switch(car){case '\t':
while(col%s > 0){res +=' ';col++}
break
case '\r':
case '\n':
res +=car
col=0
break
default:
res +=car
col++
break}
pos++}
return res}
$StringDict.find=function(){
var $=$B.args("$StringDict.find",4,{self:null,sub:null,start:null,end:null},['self','sub','start','end'],arguments,{start:0,end:null},null,null)
check_str($.sub)
normalize_start_end($)
if(!isinstance($.start,_b_.int)||!isinstance($.end,_b_.int)){throw _b_.TypeError(
"slice indices must be integers or None or have an __index__ method")}
var s=$.self.substring($.start,$.end)
if($.sub.length==0 && $.start==$.self.length){return $.self.length}
if(s.length+$.sub.length==0){return -1}
var last_search=s.length-$.sub.length
for(var i=0;i<=last_search;i++){if(s.substr(i,$.sub.length)==$.sub){return $.start+i}}
return -1}
function parse_format(fmt_string){
var elts=fmt_string.split(':'),name,conv,spec,name_ext=[]
if(elts.length==1){
name=fmt_string}else{
name=elts[0]
spec=elts.splice(1).join(':')}
var elts=name.split('!')
if(elts.length>1){name=elts[0]
conv=elts[1]
if(conv.length!==1 ||'ras'.search(conv)==-1){throw _b_.ValueError('wrong conversion flag '+conv)}}
if(name!==undefined){
function name_repl(match){name_ext.push(match)
return ''}
var name_ext_re=/\.[_a-zA-Z][_a-zA-Z0-9]*|\[[_a-zA-Z][_a-zA-Z0-9]*\]|\[[0-9]+\]/g
name=name.replace(name_ext_re,name_repl)}
return{name: name,name_ext: name_ext,conv: conv,spec: spec||''}}
$StringDict.format=function(self){var $=$B.args('format',1,{self:null},['self'],arguments,{},'args','kw')
var pos=0,_len=self.length,car,text='',parts=[],rank=0
while(pos<_len){car=self.charAt(pos)
if(car=='{' && self.charAt(pos+1)=='{'){
text +='{'
pos+=2}else if(car=='}' && self.charAt(pos+1)=='}'){
text +='}'
pos+=2}else if(car=='{'){
parts.push(text)
var end=pos+1,nb=1
while(end<_len){if(self.charAt(end)=='{'){nb++;end++}
else if(self.charAt(end)=='}'){nb--;end++
if(nb==0){
var fmt_string=self.substring(pos+1,end-1)
var fmt_obj=parse_format(fmt_string)
if(!fmt_obj.name){fmt_obj.name=rank+''
rank++}
if(fmt_obj.spec!==undefined){
function replace_nested(name,key){if(/\d+/.exec(key)){
return _b_.tuple.$dict.__getitem__($.args,parseInt(key))}else{
return _b_.dict.$dict.__getitem__($.kw,key)}}
fmt_obj.spec=fmt_obj.spec.replace(/\{(.+?)\}/g,replace_nested)}
parts.push(fmt_obj)
text=''
break}}else{end++}}
if(nb>0){throw ValueError("wrong format "+self)}
pos=end}else{text +=car;pos++}}
if(text){parts.push(text)}
var res='',fmt
for(var i=0;i<parts.length;i++){
if(typeof parts[i]=='string'){res +=parts[i];continue}
fmt=parts[i]
if(fmt.name.charAt(0).search(/\d/)>-1){
var pos=parseInt(fmt.name),value=_b_.tuple.$dict.__getitem__($.args,pos)}else{
var value=_b_.dict.$dict.__getitem__($.kw,fmt.name)}
for(var j=0;j<fmt.name_ext.length;j++){var ext=fmt.name_ext[j]
if(ext.charAt(0)=='.'){
value=_b_.getattr(value,ext.substr(1))}else{
var key=ext.substr(1,ext.length-2)
if(key.charAt(0).search(/\d/)>-1){key=parseInt(key)}
value=_b_.getattr(value,'__getitem__')(key)}}
if(fmt.conv=='a'){value=_b_.ascii(value)}
else if(fmt.conv=='r'){value=_b_.repr(value)}
else if(fmt.conv=='s'){value=_b_.str(value)}
res +=_b_.getattr(value,'__format__')(fmt.spec)}
return res}
$StringDict.format_map=function(self){throw NotImplementedError("function format_map not implemented yet");}
$StringDict.index=function(self){
var res=$StringDict.find.apply(null,arguments)
if(res===-1)throw _b_.ValueError("substring not found")
return res}
$StringDict.join=function(){var $=$B.args('join',2,{self:null,iterable:null},['self','iterable'],arguments,{},null,null)
var iterable=_b_.iter($.iterable)
var res=[],count=0
while(1){try{var obj2=_b_.next(iterable)
if(!isinstance(obj2,str)){throw _b_.TypeError(
"sequence item "+count+": expected str instance, "+$B.get_class(obj2).__name__+" found")}
res.push(obj2)}catch(err){if(_b_.isinstance(err,_b_.StopIteration)){break}
else{throw err}}}
return res.join($.self)}
$StringDict.ljust=function(self){var $=$B.args('ljust',3,{self:null,width:null,fillchar:null},['self','width','fillchar'],arguments,{fillchar:' '},null,null)
if($.width <=self.length)return self
return self + $.fillchar.repeat($.width - self.length)}
$StringDict.lstrip=function(self,x){var $=$B.args('lstrip',2,{self:null,chars:null},['self','chars'],arguments,{chars:_b_.None},null,null)
if($.chars===_b_.None){return $.self.trimLeft()}
for(var i=0;i < $.self.length;i++){if($.chars.indexOf($.self.charAt(i))===-1){return $.self.substring(i);}}
return '';}
$StringDict.maketrans=function(){var $=$B.args('maketrans',3,{x:null,y:null,z:null},['x','y','z'],arguments,{y:null,z:null},null,null)
var _t=_b_.dict()
for(var i=0;i < 256;i++)_t.$numeric_dict[i]=i
if($.y===null && $.z===null){
if(!_b_.isinstance($.x,_b_.dict)){throw _b_.TypeError('maketrans only argument must be a dict')}
var items=_b_.list(_b_.dict.$dict.items($.x))
for(var i=0,len=items.length;i<len;i++){var k=items[i][0],v=items[i][1]
if(!_b_.isinstance(k,_b_.int)){if(_b_.isinstance(k,_b_.str)&& k.length==1){k=_b_.ord(k)}
else{throw _b_.TypeError("dictionary key "+k+
" is not int or 1-char string")}}
if(v!==_b_.None && !_b_.isinstance(v,[_b_.int,_b_.str])){throw _b_.TypeError("dictionary value "+v+
" is not None, integer or string")}
_t.$numeric_dict[k]=v}
return _t}else{
if(!(_b_.isinstance($.x,_b_.str)&& _b_.isinstance($.y,_b_.str))){throw _b_.TypeError("maketrans arguments must be strings")}else if($.x.length!==$.y.length){throw _b_.TypeError("maketrans arguments must be strings or same length")}else{var toNone={}
if($.z!==null){
if(!_b_.isinstance($.z,_b_.str)){throw _b_.TypeError('maketrans third argument must be a string')}
for(var i=0,len=$.z.length;i<len;i++){toNone[_b_.ord($.z.charAt(i))]=true}}
for(var i=0,len=$.x.length;i<len;i++){_t.$numeric_dict[_b_.ord($.x.charAt(i))]=_b_.ord($.y.charAt(i))}
for(var k in toNone){_t.$numeric_dict[k]=_b_.None}
return _t}}}
$StringDict.partition=function(){var $=$B.args('partition',2,{self:null,sep:null},['self','sep'],arguments,{},null,null)
if($.sep==''){throw _b_.ValueError('empty separator')}
check_str($.sep)
var i=$.self.indexOf($.sep)
if(i==-1)return _b_.tuple([$.self,'',''])
return _b_.tuple([$.self.substring(0,i),$.sep,$.self.substring(i+$.sep.length)])}
function $re_escape(str)
{var specials="[.*+?|()$^"
for(var i=0,_len_i=specials.length;i < _len_i;i++){var re=new RegExp('\\'+specials.charAt(i),'g')
str=str.replace(re,"\\"+specials.charAt(i))}
return str}
$StringDict.replace=function(self,old,_new,count){
var $=$B.args('replace',4,{self:null,old:null,$$new:null,count:null},['self','old','$$new','count'],arguments,{count:-1},null,null),count=$.count,self=$.self,old=$.old,_new=$.$$new
check_str(old)
check_str(_new)
if(!isinstance(count,[_b_.int,_b_.float])){throw _b_.TypeError("'" + $B.get_class(count).__name__ +
"' object cannot be interpreted as an integer");}else if(isinstance(count,_b_.float)){throw _b_.TypeError("integer argument expected, got float");}
if(count==0){return self}
if(count.__class__==$B.LongInt.$dict){count=parseInt(count.value)}
if(old==''){if(_new==''){return self}
if(self==''){return _new}
var elts=self.split('')
if(count>-1 && elts.length>=count){var rest=elts.slice(count).join('')
return _new+elts.slice(0,count).join(_new)+rest}else{return _new+elts.join(_new)+_new}}else{var elts=$StringDict.split(self,old,count)}
var res=self,pos=-1
if(old.length==0){var res=_new
for(var i=0;i<elts.length;i++){res +=elts[i]+_new}
return res+rest}
if(count < 0)count=res.length;
while(count > 0){pos=res.indexOf(old,pos);
if(pos < 0)
break;
res=res.substr(0,pos)+ _new + res.substr(pos + old.length);
pos=pos + _new.length;
count--;}
return res;}
$StringDict.rfind=function(self){
var $=$B.args("rfind",4,{self:null,sub:null,start:null,end:null},['self','sub','start','end'],arguments,{start:0,end:null},null,null)
normalize_start_end($)
check_str($.sub)
if($.sub.length==0){if($.start>$.self.length){return -1}
else{return $.self.length}}
var sublen=$.sub.length
for(var i=$.end-sublen;i>=$.start;i--){if($.self.substr(i,sublen)==$.sub){return i}}
return -1}
$StringDict.rindex=function(){
var res=$StringDict.rfind.apply(null,arguments)
if(res==-1){throw _b_.ValueError("substring not found")}
return res}
$StringDict.rjust=function(self){var $=$B.args("rjust",3,{self:null,width:null,fillchar:null},['self','width','fillchar'],arguments,{fillchar:' '},null,null)
if($.width <=self.length)return self
return $.fillchar.repeat($.width - self.length)+ self}
$StringDict.rpartition=function(self,sep){var $=$B.args('rpartition',2,{self:null,sep:null},['self','sep'],arguments,{},null,null)
check_str($.sep)
var self=reverse($.self),sep=reverse($.sep)
var items=$StringDict.partition(self,sep).reverse()
for(var i=0;i<items.length;i++){items[i]=items[i].split('').reverse().join('')}
return items}
$StringDict.rsplit=function(self){var $=$B.args("rsplit",3,{self:null,sep:null,maxsplit:null},['self','sep','maxsplit'],arguments,{sep:_b_.None,maxsplit:-1},null,null),sep=$.sep
var rev_str=reverse($.self),rev_sep=sep===_b_.None ? sep : reverse($.sep),rev_res=$StringDict.split(rev_str,rev_sep,$.maxsplit)
rev_res.reverse()
for(var i=0;i<rev_res.length;i++){rev_res[i]=reverse(rev_res[i])}
return rev_res}
$StringDict.rstrip=function(self,x){var $=$B.args('rstrip',2,{self:null,chars:null},['self','chars'],arguments,{chars:_b_.None},null,null)
if($.chars===_b_.None){return $.self.trimRight()}
for(var j=$.self.length-1;j >=0;j--){if($.chars.indexOf($.self.charAt(j))===-1){return $.self.substring(0,j+1);}}
return '';}
$StringDict.split=function(){var pos=0
var $=$B.args("split",3,{self:null,sep:null,maxsplit:null},['self','sep','maxsplit'],arguments,{sep:_b_.None,maxsplit:-1},null,null)
var sep=$.sep,maxsplit=$.maxsplit,self=$.self
if(maxsplit.__class__===$B.LongInt.$dict){maxsplit=parseInt(maxsplit.value)}
if(sep=='')throw _b_.ValueError('empty separator')
if(sep===_b_.None){var res=[]
while(pos<self.length&&self.charAt(pos).search(/\s/)>-1){pos++}
if(pos===self.length-1){return[self]}
var name=''
while(1){if(self.charAt(pos).search(/\s/)===-1){if(name===''){name=self.charAt(pos)}
else{name+=self.charAt(pos)}}else{if(name!==''){res.push(name)
if(maxsplit!==-1&&res.length===maxsplit+1){res.pop()
res.push(name+self.substr(pos))
return res}
name=''}}
pos++
if(pos>self.length-1){if(name){res.push(name)}
break}}
return res}else{var res=[],s='',seplen=sep.length
if(maxsplit==0){return[self]}
while(pos<self.length){if(self.substr(pos,seplen)==sep){res.push(s)
pos +=seplen
if(maxsplit>-1 && res.length>=maxsplit){res.push(self.substr(pos))
return res}
s=''}else{s +=self.charAt(pos)
pos++}}
res.push(s)
return res}}
$StringDict.splitlines=function(self){var $=$B.args('splitlines',2,{self:null,keepends:null},['self','keepends'],arguments,{keepends:false},null,null)
if(!_b_.isinstance($.keepends,[_b_.bool,_b_.int])){throw _b_.TypeError('integer argument expected, got '+
$B.get_class($.keepends).__name)}
var keepends=_b_.int($.keepends)
if(keepends){var res=[],start=pos,pos=0,self=$.self
while(pos<self.length){if(self.substr(pos,2)=='\r\n'){res.push(self.substring(start,pos+2))
start=pos+2
pos=start}else if(self.charAt(pos)=='\r' ||self.charAt(pos)=='\n'){res.push(self.substring(start,pos+1))
start=pos+1
pos=start}else{pos++}}
var rest=self.substr(start)
if(rest){res.push(rest)}
return res}else{var self=$.self.replace(/[\r\n]$/,'')
return self.split(/\n|\r\n|\r/)}}
$StringDict.startswith=function(){
var $=$B.args("startswith",4,{self:null,prefix:null,start:null,end:null},['self','prefix','start','end'],arguments,{start:0,end:null},null,null)
normalize_start_end($)
var prefixes=$.prefix
if(!isinstance(prefixes,_b_.tuple)){prefixes=[prefixes]}
var s=$.self.substring($.start,$.end)
for(var i=0,_len_i=prefixes.length;i < _len_i;i++){prefix=prefixes[i]
if(!_b_.isinstance(prefix,str)){throw _b_.TypeError(
"endswith first arg must be str or a tuple of str, not int")}
if(s.substr(0,prefix.length)==prefix)return true}
return false}
$StringDict.strip=function(){var $=$B.args('strip',2,{self:null,chars:null},['self','chars'],arguments,{chars:_b_.None},null,null)
if($.chars===_b_.None){return $.self.trim()}
for(var i=0;i < $.self.length;i++){if($.chars.indexOf($.self.charAt(i))===-1){break;}}
for(var j=$.self.length-1;j >=i;j--){if($.chars.indexOf($.self.charAt(j))===-1){break;}}
return $.self.substring(i,j+1);}
$StringDict.translate=function(self,table){var res=[],pos=0
if(isinstance(table,_b_.dict)){for(var i=0,_len_i=self.length;i < _len_i;i++){var repl=_b_.dict.$dict.get(table,self.charCodeAt(i),-1)
if(repl==-1){res[pos++]=self.charAt(i)}
else if(repl!==None){res[pos++]=_b_.chr(repl)}}}
return res.join('')}
$StringDict.zfill=function(self,width){var $=$B.args('zfill',2,{self:null,width:null},['self','width'],arguments,{},null,null)
if($.width <=self.length){return self}
switch(self.charAt(0)){case '+':
case '-':
return self.charAt(0)+'0'.repeat($.width-self.length)+self.substr(1)
default:
return '0'.repeat(width - self.length)+self}}
function str(arg){if(arg===undefined)return '<undefined>'
switch(typeof arg){case 'string':
return arg
case 'number':
if(isFinite(arg)){return arg.toString()}}
try{if(arg.__class__===$B.$factory){
var func=$B.$type.__getattribute__(arg.$dict.__class__,'__str__')
if(func.__func__===_b_.object.$dict.__str__){return func(arg)}
return func(arg)}else if(arg.__class__===$B.$type){
var func=$B.$type.__getattribute__(arg.__class__,'__str__')
if(func.__func__===_b_.object.$dict.__str__){return func(arg)}
return func()}
var f=getattr(arg,'__str__')}
catch(err){
try{
var f=getattr(arg,'__repr__')}catch(err){if($B.debug>1){console.log(err)}
console.log('Warning - no method __str__ or __repr__, default to toString',arg)
return arg.toString()}}
return getattr(f,'__call__')()}
str.__class__=$B.$factory
str.$dict=$StringDict
$StringDict.$factory=str
$StringDict.__new__=function(cls){if(cls===undefined){throw _b_.TypeError('str.__new__(): not enough arguments')}
return{__class__:cls.$dict}}
$B.set_func_names($StringDict)
var $StringSubclassDict={__class__:$B.$type,__name__:'str'}
for(var $attr in $StringDict){if(typeof $StringDict[$attr]=='function'){$StringSubclassDict[$attr]=(function(attr){return function(){var args=[],pos=0
if(arguments.length>0){var args=[arguments[0].valueOf()],pos=1
for(var i=1,_len_i=arguments.length;i < _len_i;i++){args[pos++]=arguments[i]}}
return $StringDict[attr].apply(null,args)}})($attr)}}
$StringSubclassDict.__mro__=[$ObjectDict]
$B.$StringSubclassFactory={__class__:$B.$factory,$dict:$StringSubclassDict}
_b_.str=str
$B.parse_format_spec=function(spec){if(spec==''){this.empty=true}
else{var pos=0,aligns='<>=^',digits='0123456789',types='bcdeEfFgGnosxX%',align_pos=aligns.indexOf(spec.charAt(0))
if(align_pos!=-1){if(spec.charAt(1)&& aligns.indexOf(spec.charAt(1))!=-1){
this.fill=spec.charAt(0)
this.align=spec.charAt(1)
pos=2}else{
this.align=aligns[align_pos];
this.fill=' ';
pos++}}else{align_pos=aligns.indexOf(spec.charAt(1))
if(spec.charAt(1)&& align_pos!=-1){
this.align=aligns[align_pos]
this.fill=spec.charAt(0)
pos=2}}
var car=spec.charAt(pos)
if(car=='+'||car=='-'||car==' '){this.sign=car;
pos++;
car=spec.charAt(pos);}
if(car=='#'){this.alternate=true;pos++;car=spec.charAt(pos)}
if(car=='0'){
this.fill='0'
this.align='='
pos++;car=spec.charAt(pos)}
while(car && digits.indexOf(car)>-1){if(this.width===undefined){this.width=car}
else{this.width+=car}
pos++;car=spec.charAt(pos)}
if(this.width!==undefined){this.width=parseInt(this.width)}
if(car==','){this.comma=true;pos++;car=spec.charAt(pos)}
if(car=='.'){if(digits.indexOf(spec.charAt(pos+1))==-1){throw _b_.ValueError("Missing precision in format spec")}
this.precision=spec.charAt(pos+1)
pos+=2;car=spec.charAt(pos)
while(car && digits.indexOf(car)>-1){this.precision+=car;pos++;car=spec.charAt(pos)}
this.precision=parseInt(this.precision)}
if(car && types.indexOf(car)>-1){this.type=car;pos++;car=spec.charAt(pos)}
if(pos!==spec.length){
throw _b_.ValueError("Invalid format specifier")}}
this.toString=function(){return(this.fill===undefined ? '' : _b_.str(this.fill))+
(this.align||'')+
(this.sign||'')+
(this.alternate ? '#' : '')+
(this.sign_aware ? '0' : '')+
(this.width ||'')+
(this.comma ? ',' : '')+
(this.precision ? '.'+this.precision : '')+
(this.type ||'')}}
$B.format_width=function(s,fmt){if(fmt.width && s.length<fmt.width){var fill=fmt.fill ||' ',align=fmt.align ||'<',missing=fmt.width-s.length
switch(align){case '<':
return s+fill.repeat(missing)
case '>':
return fill.repeat(missing)+s
case '=':
if('+-'.indexOf(s.charAt(0))>-1){return s.charAt(0)+fill.repeat(missing)+s.substr(1)}else{return fill.repeat(missing)+s}
case '^':
var left=parseInt(missing/2)
return fill.repeat(left)+s+fill.repeat(missing-left)}}
return s}
function fstring_expression(){this.type='expression'
this.expression=''
this.conversion=null
this.fmt=null}
$B.parse_fstring=function(string){
var elts=[],pos=0,current='',ctype=null,nb_braces=0,car
while(pos<string.length){if(ctype===null){car=string.charAt(pos)
if(car=='{'){if(string.charAt(pos+1)=='{'){ctype='string'
current='{'
pos +=2}else{ctype='expression'
nb_braces=1
pos++}}else if(car=='}'){if(string.charAt(pos+1)==car){ctype='string'
current='}'
pos +=2}else{throw Error(" f-string: single '}' is not allowed")}}else{ctype='string'
current=car
pos++}}else if(ctype=='string'){
var i=pos
while(i<string.length){car=string.charAt(i)
if(car=='{'){if(string.charAt(i+1)=='{'){current +='{'
i+=2}else{elts.push(current)
ctype='expression'
pos=i+1
break}}else if(car=='}'){if(string.charAt(i+1)==car){current +=car
i +=2}else{throw Error(" f-string: single '}' is not allowed")}}else{current +=car
i++}}
pos=i+1}else{
var i=pos,nb_braces=1,nb_paren=0,current=new fstring_expression()
while(i<string.length){car=string.charAt(i)
if(car=='{' && nb_paren==0){nb_braces++
current.expression +=car
i++}else if(car=='}' && nb_paren==0){nb_braces -=1
if(nb_braces==0){
elts.push(current)
ctype=null
current=''
pos=i+1
break}
current.expression +=car
i++}else if(car=='\\'){
throw Error("f-string expression part cannot include a" +
" backslash")}else if(nb_paren==0 && car=='!' && current.fmt===null){if(current.expression.length==0){throw Error("f-string: empty expression not allowed")}
if('ars'.indexOf(string.charAt(i+1))==-1){throw Error("f-string: invalid conversion character:" +
" expected 's', 'r', or 'a'")}else{current.conversion=string.charAt(i+1)
i +=2}}else if(car=='('){nb_paren++
current.expression +=car
i++}else if(car==')'){nb_paren--
current.expression +=car
i++}else if(car=='"'){
if(string.substr(i,3)=='"""'){var end=string.indexOf('"""',i+3)
if(end==-1){throw Error("f-string: unterminated string")}
else{var trs=string.substring(i,end+3)
trs=trs.replace('\n','\\n\\')
current.expression +=trs
i=end+3}}else{var end=string.indexOf('"',i+1)
if(end==-1){throw Error("f-string: unterminated string")}
else{current.expression +=string.substring(i,end+1)
i=end+1}}}else if(nb_paren==0 && car==':'){current.fmt=true
current.expression +=car
i++}else{current.expression +=car
i++}}
if(nb_braces>0){throw Error("f-string: expected '}'")}}}
if(current.length>0){elts.push(current)}
return elts}})(__BRYTHON__)
;(function($B){eval($B.InjectBuiltins())
var $ObjectDict=_b_.object.$dict,str_hash=_b_.str.$dict.__hash__,$N=_b_.None
function $DictClass($keys,$values){this.iter=null
this.__class__=$DictDict
$DictDict.clear(this)
var setitem=$DictDict.__setitem__
var i=$keys.length
while(i--)setitem($keys[i],$values[i])}
var $DictDict={__class__:$B.$type,__name__ : 'dict',$native:true,__dir__:$ObjectDict.__dir__}
var $key_iterator=function(d){this.d=d
this.current=0
this.iter=new $item_generator(d)}
$key_iterator.prototype.length=function(){return this.iter.length }
$key_iterator.prototype.next=function(){return this.iter.next()[0]}
var $value_iterator=function(d){this.d=d
this.current=0
this.iter=new $item_generator(d)}
$value_iterator.prototype.length=function(){return this.iter.length }
$value_iterator.prototype.next=function(){return this.iter.next()[1]}
var $item_generator=function(d){this.i=0
if(d.$jsobj){this.items=[]
for(var attr in d.$jsobj){if(attr.charAt(0)!='$'){val=d.$jsobj[attr];
if(val===undefined ||val===null)this.items.push([attr,$N])
else this.items.push([attr,val])}}
this.length=this.items.length;
return}
var items=[]
var pos=0
for(var k in d.$numeric_dict){items[pos++]=[parseFloat(k),d.$numeric_dict[k]]}
for(var k in d.$string_dict){items[pos++]=[k,d.$string_dict[k]]}
for(var k in d.$object_dict){items[pos++]=d.$object_dict[k]}
this.items=items
this.length=items.length}
$item_generator.prototype.next=function(){if(this.i < this.items.length){return this.items[this.i++]}
throw _b_.StopIteration("StopIteration")}
$item_generator.prototype.as_list=function(){return this.items}
var $item_iterator=function(d){this.d=d
this.current=0
this.iter=new $item_generator(d)}
$item_iterator.prototype.length=function(){return this.iter.items.length }
$item_iterator.prototype.next=function(){return _b_.tuple(this.iter.next())}
var $copy_dict=function(left,right){var _l=new $item_generator(right).as_list()
var si=$DictDict.__setitem__
var i=_l.length
while(i--)si(left,_l[i][0],_l[i][1])}
function toSet(items){
var res=[]
while(true){try{res.push(items.next())}
catch(err){break}}
return _b_.set(res)}
var $iterator_wrapper=function(items,klass){var res={__class__:klass,__eq__:function(other){
return getattr(toSet(items),"__eq__")(other)},__iter__:function(){items.iter.i=0;return res},__len__:function(){return items.length()},__next__:function(){return items.next()},__repr__:function(){var s=[]
for(var i=0,len=items.length();i<len;i++){s.push(_b_.repr(items.next()))}
return klass.__name__+'(['+ s.join(',')+ '])'},}
res.__str__=res.toString=res.__repr__
return res}
$DictDict.__bool__=function(){var $=$B.args('__bool__',1,{self:null},['self'],arguments,{},null,null)
return $DictDict.__len__($.self)> 0}
$DictDict.__contains__=function(){var $=$B.args('__contains__',2,{self:null,item:null},['self','item'],arguments,{},null,null),self=$.self,item=$.item
if(self.$jsobj)return self.$jsobj[item]!==undefined
switch(typeof item){case 'string':
return self.$string_dict[item]!==undefined
case 'number':
return self.$numeric_dict[item]!==undefined}
var _key=hash(item)
if(self.$str_hash[_key]!==undefined &&
_b_.getattr(item,'__eq__')(self.$str_hash[_key])){return true}
if(self.$numeric_dict[_key]!==undefined &&
_b_.getattr(item,'__eq__')(_key)){return true}
if(self.$object_dict[_key]!==undefined){
var _eq=getattr(item,'__eq__')
if(_eq(self.$object_dict[_key][0])){return true}}
return false}
$DictDict.__delitem__=function(){var $=$B.args('__eq__',2,{self:null,arg:null},['self','arg'],arguments,{},null,null),self=$.self,arg=$.arg
if(self.$jsobj){if(self.$jsobj[arg]===undefined){throw KeyError(arg)}
delete self.$jsobj[arg]
return $N}
switch(typeof arg){case 'string':
if(self.$string_dict[arg]===undefined)throw KeyError(_b_.str(arg))
delete self.$string_dict[arg]
delete self.$str_hash[str_hash(arg)]
return $N
case 'number':
if(self.$numeric_dict[arg]===undefined)throw KeyError(_b_.str(arg))
delete self.$numeric_dict[arg]
return $N}
var _key=hash(arg)
if(self.$object_dict[_key]!==undefined){delete self.$object_dict[_key]}
if(self.$jsobj)delete self.$jsobj[arg]
return $N}
$DictDict.__eq__=function(){var $=$B.args('__eq__',2,{self:null,other:null},['self','other'],arguments,{},null,null),self=$.self,other=$.other
if(!isinstance(other,dict))return false
if(self.$jsobj){self=self.$to_dict()}
if(other.$jsobj){other=other.$to_dict()}
if($DictDict.__len__(self)!=$DictDict.__len__(other)){return false}
if((self.$numeric_dict.length!=other.$numeric_dict.length)||
(self.$string_dict.length!=other.$string_dict.length)||
(self.$object_dict.length!=other.$object_dict.length)){return false}
for(var k in self.$numeric_dict){if(!_b_.getattr(other.$numeric_dict[k],'__eq__')(self.$numeric_dict[k])){return false}}
for(var k in self.$string_dict){if(!_b_.getattr(other.$string_dict[k],'__eq__')(self.$string_dict[k])){return false}}
for(var k in self.$object_dict){if(!_b_.getattr(other.$object_dict[k][1],'__eq__')(self.$object_dict[k][1])){return false}}
return true}
$DictDict.__getitem__=function(){var $=$B.args('__getitem__',2,{self:null,arg:null},['self','arg'],arguments,{},null,null),self=$.self,arg=$.arg
if(self.$jsobj){if(self.$jsobj[arg]===undefined ||self.$jsobj[arg]===null){return $N}
return self.$jsobj[arg]}
switch(typeof arg){case 'string':
if(self.$string_dict[arg]!==undefined)return self.$string_dict[arg]
break
case 'number':
if(self.$numeric_dict[arg]!==undefined)return self.$numeric_dict[arg]}
var _key=_b_.hash(arg),_eq=_b_.getattr(arg,'__eq__')
var sk=self.$str_hash[_key]
if(sk!==undefined && _eq(sk)){return self.$string_dict[sk]}
if(self.$numeric_dict[_key]!==undefined && _eq(_key)){return self.$numeric_dict[_key]}
var obj_ref=self.$object_dict[_key]
if(obj_ref!==undefined){
_eq(self.$object_dict[_key][0])
return self.$object_dict[_key][1]}
if(self.__class__!==$DictDict){try{var missing_method=getattr(self.__class__.$factory,'__missing__')
return missing_method(self,arg)}catch(err){}}
throw KeyError(_b_.str(arg))}
$DictDict.__hash__=None
$DictDict.__init__=function(self){var args=[],pos=0
for(var i=1;i<arguments.length;i++){args[pos++]=arguments[i]}
switch(args.length){case 0:
return
case 1:
var obj=args[0]
if(Array.isArray(obj)){var i=obj.length
var si=$DictDict.__setitem__
while(i-->0)si(self,obj[i-1][0],obj[i-1][1])
return $N}else if(obj.$nat===undefined && isinstance(obj,dict)){$copy_dict(self,obj)
return $N}
if(obj.__class__===$B.JSObject.$dict){
self.$jsobj=obj.js
return $N}}
var $ns=$B.args('dict',0,{},[],args,{},'args','kw')
var args=$ns['args']
var kw=$ns['kw']
if(args.length>0){if(isinstance(args[0],dict)){$B.$copy_dict(self,args[0])
return $N}
if(Array.isArray(args[0])){var src=args[0]
var i=src.length -1
var si=$DictDict.__setitem__
while(i-->0)si(self,src[i-1][0],src[i-1][1])}else{var iterable=$B.$iter(args[0])
while(1){try{var elt=next(iterable)
var key=getattr(elt,'__getitem__')(0)
var value=getattr(elt,'__getitem__')(1)
$DictDict.__setitem__(self,key,value)}catch(err){if(err.__name__==='StopIteration'){break}
throw err}}}}
if($DictDict.__len__(kw)> 0)$copy_dict(self,kw)
return $N}
var $dict_iterator=$B.$iterator_class('dict iterator')
$DictDict.__iter__=function(self){return $DictDict.keys(self)}
$DictDict.__len__=function(self){var _count=0
if(self.$jsobj){for(var attr in self.$jsobj){if(attr.charAt(0)!='$'){_count++}}
return _count}
for(var k in self.$numeric_dict)_count++
for(var k in self.$string_dict)_count++
for(var k in self.$object_dict)_count+=self.$object_dict[k].length
return _count}
$DictDict.__mro__=[$ObjectDict]
$DictDict.__ne__=function(self,other){return !$DictDict.__eq__(self,other)}
$DictDict.__next__=function(self){if(self.$iter==null){self.$iter=new $item_generator(self)}
try{
return self.$iter.next()}catch(err){if(err.__name__ !=="StopIteration"){throw err }}}
$DictDict.__repr__=function(self){if(self===undefined)return "<class 'dict'>"
if(self.$jsobj){
return $DictDict.__repr__(self.$to_dict())}
var res=[],pos=0,items=new $item_generator(self).as_list()
for(var i=0;i < items.length;i++){var itm=items[i]
if(itm[1]===self){res[pos++]=repr(itm[0])+': {...}'}
else{res[pos++]=repr(itm[0])+': '+repr(itm[1])}}
return '{'+ res.join(', ')+'}'}
$DictDict.__setitem__=function(self,key,value){var $=$B.args('__setitem__',3,{self:null,key:null,value:null},['self','key','value'],arguments,{},null,null),self=$.self,key=$.key,value=$.value
if(self.$jsobj){if(value===$N)self.$jsobj[key]=undefined;
else self.$jsobj[key]=value;
return}
switch(typeof key){case 'string':
self.$string_dict[key]=value
self.$str_hash[str_hash(key)]=key
return $N
case 'number':
self.$numeric_dict[key]=value
return $N}
var _key=hash(key)
var _eq=getattr(key,'__eq__')
if(self.$numeric_dict[_key]!==undefined && _eq(_key)){self.$numeric_dict[_key]=value
return $N}
var sk=self.$str_hash[_key]
if(sk!==undefined && _eq(sk)){self.$string_dict[sk]=value
return $N}
var obj_ref=self.$object_dict[_key]
if(obj_ref!==undefined){
_eq(self.$object_dict[_key][0])}
self.$object_dict[_key]=[key,value]
return $N}
$DictDict.__str__=$DictDict.__repr__
$B.make_rmethods($DictDict)
$DictDict.clear=function(){
var $=$B.args('clear',1,{self:null},['self'],arguments,{},null,null),self=$.self
self.$numeric_dict={}
self.$string_dict={}
self.$str_hash={}
self.$object_dict={}
if(self.$jsobj){for(var attr in self.$jsobj){if(attr.charAt(0)!=='$' && attr !=="__class__"){delete self.$jsobj[attr]}}}
return $N}
$DictDict.copy=function(self){
var $=$B.args('copy',1,{self:null},['self'],arguments,{},null,null),self=$.self,res=_b_.dict()
$copy_dict(res,self)
return res}
$DictDict.fromkeys=function(){var $=$B.args('fromkeys',3,{cls:null,keys:null,value:null},['cls','keys','value'],arguments,{value:_b_.None},null,null),keys=$.keys,value=$.value
var klass=$.cls,res=klass(),keys_iter=$B.$iter(keys)
while(1){try{var key=_b_.next(keys_iter)
if(klass===dict){$DictDict.__setitem__(res,key,value)}
else{_b_.getattr(res,"__setitem__")(key,value)}}catch(err){if($B.is_exc(err,[_b_.StopIteration])){return res}
throw err}}}
$DictDict.fromkeys.$type='classmethod'
$DictDict.get=function(){var $=$B.args('get',3,{self:null,key:null,_default:null},['self','key','_default'],arguments,{_default:$N},null,null)
try{return $DictDict.__getitem__($.self,$.key)}
catch(err){if(_b_.isinstance(err,_b_.KeyError)){return $._default}
else{throw err}}}
var $dict_itemsDict=$B.$iterator_class('dict_items')
$DictDict.items=function(self){if(arguments.length > 1){var _len=arguments.length - 1
var _msg="items() takes no arguments ("+_len+" given)"
throw _b_.TypeError(_msg)}
return $iterator_wrapper(new $item_iterator(self),$dict_itemsDict)}
var $dict_keysDict=$B.$iterator_class('dict_keys')
$DictDict.keys=function(self){if(arguments.length > 1){var _len=arguments.length - 1
var _msg="keys() takes no arguments ("+_len+" given)"
throw _b_.TypeError(_msg)}
return $iterator_wrapper(new $key_iterator(self),$dict_keysDict)}
$DictDict.pop=function(){var $=$B.args('pop',3,{self:null,key: null,_default:null},['self','key','_default'],arguments,{_default:$N},null,null),self=$.self,key=$.key,_default=$._default
try{var res=$DictDict.__getitem__(self,key)
$DictDict.__delitem__(self,key)
return res}catch(err){if(err.__name__==='KeyError'){if(_default!==undefined)return _default
throw err}
throw err}}
$DictDict.popitem=function(self){try{var itm=new $item_iterator(self).next()
$DictDict.__delitem__(self,itm[0])
return _b_.tuple(itm)}catch(err){if(err.__name__=="StopIteration"){throw KeyError("'popitem(): dictionary is empty'")}}}
$DictDict.setdefault=function(){var $=$B.args('setdefault',3,{self:null,key: null,_default:null},['self','key','_default'],arguments,{_default:$N},null,null),self=$.self,key=$.key,_default=$._default
try{return $DictDict.__getitem__(self,key)}
catch(err){if(_default===undefined)_default=$N
$DictDict.__setitem__(self,key,_default)
return _default}}
$DictDict.update=function(self){var $=$B.args('update',1,{'self':null},['self'],arguments,{},'args','kw'),self=$.self,args=$.args,kw=$.kw
if(args.length>0){var o=args[0]
if(isinstance(o,dict)){$copy_dict(self,o)}else if(hasattr(o,'__getitem__')&& hasattr(o,'keys')){var _keys=_b_.list(getattr(o,'keys')())
var si=$DictDict.__setitem__
var i=_keys.length
while(i--){
var _value=getattr(o,'__getitem__')(_keys[i])
si(self,_keys[i],_value)}}}
$copy_dict(self,kw)
return $N}
var $dict_valuesDict=$B.$iterator_class('dict_values')
$DictDict.values=function(self){if(arguments.length > 1){var _len=arguments.length - 1
var _msg="values() takes no arguments ("+_len+" given)"
throw _b_.TypeError(_msg)}
return $iterator_wrapper(new $value_iterator(self),$dict_valuesDict)}
function dict(args,second){var res={__class__:$DictDict,$numeric_dict :{},$object_dict :{},$string_dict :{},$str_hash:{},length: 0}
if(args===undefined){return res}
if(second===undefined){if(Array.isArray(args)){
var i=-1,stop=args.length-1
var si=$DictDict.__setitem__
while(i++<stop){var item=args[i]
switch(typeof item[0]){case 'string':
res.$string_dict[item[0]]=item[1]
res.$str_hash[str_hash(item[0])]=item[0]
break;
case 'number':
res.$numeric_dict[item[0]]=item[1]
break
default:
si(res,item[0],item[1])
break}}
return res}else if(args.$nat=='kw'){
var kw=args['kw']
for(var attr in kw){switch(typeof attr){case 'string':
res.$string_dict[attr]=kw[attr]
res.$str_hash[str_hash(attr)]=attr
break;
case 'number':
res.$numeric_dict[attr]=kw[attr]
break
default:
si(res,attr,kw[attr])
break}}
return res}}
var _args=[res],pos=1
for(var i=0,_len_i=arguments.length;i < _len_i;i++){_args[pos++]=arguments[i]}
$DictDict.__init__.apply(null,_args)
return res}
dict.__class__=$B.$factory
dict.$dict=$DictDict
$DictDict.$factory=dict
$DictDict.__new__=$B.$__new__(dict)
_b_.dict=dict
$B.set_func_names($DictDict)
$B.$dict_iterator=function(d){return new $item_generator(d)}
$B.$dict_length=$DictDict.__len__
$B.$dict_getitem=$DictDict.__getitem__
$B.$dict_get=$DictDict.get
$B.$dict_set=$DictDict.__setitem__
$B.$dict_contains=$DictDict.__contains__
$B.$dict_items=function(d){return new $item_generator(d).as_list()}
$B.$copy_dict=$copy_dict
$B.$dict_get_copy=$DictDict.copy
var mappingproxyDict={__class__ : $B.$type,__name__ : "mappingproxy"}
mappingproxyDict.__mro__=[_b_.object.$dict]
mappingproxyDict.__setitem__=function(){throw _b_.TypeError("'mappingproxy' object does not support item assignment")}
function mappingproxy(obj){var res=obj_dict(obj)
res.__class__=mappingproxyDict
return res}
mappingproxy.__class__=$B.$factory
mappingproxy.$dict=mappingproxyDict
mappingproxyDict.$factory=mappingproxy
$B.mappingproxy=mappingproxy
$B.obj_dict=function(obj){var klass=$B.get_class(obj)
if(klass !==undefined && klass.$native){throw _b_.AttributeError(klass.__name__+
" has no attribute '__dict__'")}
var res=dict()
res.$jsobj=obj
res.$to_dict=(function(x){return function(){var d=dict()
for(var attr in x){if(attr.charAt(0)!='$' && attr!=='__class__'){d.$string_dict[attr]=x[attr]
d.length++}}
return d}})(obj)
return res}})(__BRYTHON__)
;(function($B){var _b_=$B.builtins
var $N=_b_.None
function create_type(obj){return $B.get_class(obj).$factory()}
function clone(obj){var res=create_type(obj)
res.$items=obj.$items.slice()
return res}
var $SetDict={__class__:$B.$type,__dir__:_b_.object.$dict.__dir__,__name__:'set',$native:true}
$SetDict.__add__=function(self,other){throw _b_.TypeError("unsupported operand type(s) for +: 'set' and " +
typeof other )}
$SetDict.__and__=function(self,other,accept_iter){$test(accept_iter,other)
var res=create_type(self)
for(var i=0,_len_i=self.$items.length;i < _len_i;i++){if(_b_.getattr(other,'__contains__')(self.$items[i])){$SetDict.add(res,self.$items[i])}}
return res}
$SetDict.__contains__=function(self,item){if(self.$num &&(typeof item=='number')){if(isNaN(item)){
for(var i=self.$items.length-1;i>=0;i--){if(isNaN(self.$items[i])){return true}}
return false}else{return self.$items.indexOf(item)>-1}}
if(self.$str &&(typeof item=='string')){return self.$items.indexOf(item)>-1}
if(! _b_.isinstance(item,set)){_b_.hash(item)}
for(var i=0,_len_i=self.$items.length;i < _len_i;i++){if(_b_.getattr(self.$items[i],'__eq__')(item))return true}
return false}
$SetDict.__eq__=function(self,other){
if(other===undefined)return self===set
if(_b_.isinstance(other,_b_.set)){if(other.$items.length==self.$items.length){for(var i=0,_len_i=self.$items.length;i < _len_i;i++){if($SetDict.__contains__(self,other.$items[i])===false)return false}
return true}
return false}
if(_b_.isinstance(other,[_b_.list])){if(_b_.len(other)!=self.$items.length)return false
for(var i=0,_len_i=_b_.len(other);i < _len_i;i++){var _value=_b_.getattr(other,'__getitem__')(i)
if($SetDict.__contains__(self,_value)===false)return false}
return true}
if(_b_.hasattr(other,'__iter__')){
if(_b_.len(other)!=self.$items.length)return false
var _it=$B.$iter(other)
while(1){try{
var e=_b_.next(_it)
if(!$SetDict.__contains__(self,e))return false}catch(err){if(err.__name__=="StopIteration"){break}
throw err}}
return true}
return false}
$SetDict.__format__=function(self,format_string){return $SetDict.__str__(self)}
$SetDict.__ge__=function(self,other){if(_b_.isinstance(other,[set,frozenset])){return !$SetDict.__lt__(self,other)}else{return _b_.object.$dict.__ge__(self,other)}}
$SetDict.__gt__=function(self,other){if(_b_.isinstance(other,[set,frozenset])){return !$SetDict.__le__(self,other)}else{return _b_.object.$dict.__gt__(self,other)}}
$SetDict.__init__=function(self){var $=$B.args('__init__',2,{self:null,iterable:null},['self','iterable'],arguments,{iterable:[]},null,null),self=$.self,iterable=$.iterable
if(_b_.isinstance(iterable,[set,frozenset])){self.$items=iterable.$items.slice()
return $N}
var it=$B.$iter(iterable),obj={$items:[],$str:true,$num:true}
while(1){try{var item=_b_.next(it)
$SetDict.add(obj,item)}catch(err){if(_b_.isinstance(err,_b_.StopIteration)){break}
throw err}}
self.$items=obj.$items
return $N}
var $set_iterator=$B.$iterator_class('set iterator')
$SetDict.__iter__=function(self){var it=$B.$iterator(self.$items,$set_iterator),len=self.$items.length,nxt=it.__next__
it.__next__=function(){if(it.__len__()!=len){throw _b_.RuntimeError("size changed during iteration")}
return nxt()}
return it}
$SetDict.__le__=function(self,other){if(_b_.isinstance(other,[set,frozenset])){var cfunc=_b_.getattr(other,'__contains__')
for(var i=0,_len_i=self.$items.length;i < _len_i;i++){if(!cfunc(self.$items[i]))return false}
return true}else{return _b_.object.$dict.__le__(self,other)}}
$SetDict.__len__=function(self){return self.$items.length}
$SetDict.__lt__=function(self,other){if(_b_.isinstance(other,[set,frozenset])){return($SetDict.__le__(self,other)&&
$SetDict.__len__(self)<_b_.getattr(other,'__len__')())}else{return _b_.object.$dict['__lt__'](self,other)}}
$SetDict.__mro__=[_b_.object.$dict]
$SetDict.__ne__=function(self,other){return !$SetDict.__eq__(self,other)}
$SetDict.__or__=function(self,other,accept_iter){
var res=clone(self)
var func=_b_.getattr($B.$iter(other),'__next__')
while(1){try{$SetDict.add(res,func())}
catch(err){if(_b_.isinstance(err,_b_.StopIteration)){break}
throw err}}
res.__class__=self.__class__
return res}
$SetDict.__str__=$SetDict.__repr__=function(self){var frozen=self.$real==='frozen'
self.$cycle=self.$cycle===undefined ? 0 : self.$cycle+1
if(self.$items.length===0){if(frozen)return 'frozenset()'
return 'set()'}
var klass_name=$B.get_class(self).__name__,head=klass_name+'({',tail='})'
if(head=='set('){head='{';tail='}'}
var res=[]
if(self.$cycle){self.$cycle--
return klass_name+'(...)'}
for(var i=0,_len_i=self.$items.length;i < _len_i;i++){var r=_b_.repr(self.$items[i])
if(r===self||r===self.$items[i]){res.push('{...}')}
else{res.push(r)}}
res=res.join(', ')
self.$cycle--
return head+res+tail}
$SetDict.__sub__=function(self,other,accept_iter){
$test(accept_iter,other,'-')
var res=create_type(self)
var cfunc=_b_.getattr(other,'__contains__')
for(var i=0,_len_i=self.$items.length;i < _len_i;i++){if(!cfunc(self.$items[i])){res.$items.push(self.$items[i])}}
return res}
$SetDict.__xor__=function(self,other,accept_iter){
$test(accept_iter,other,'^')
var res=create_type(self)
var cfunc=_b_.getattr(other,'__contains__')
for(var i=0,_len_i=self.$items.length;i < _len_i;i++){if(!cfunc(self.$items[i])){$SetDict.add(res,self.$items[i])}}
for(var i=0,_len_i=other.$items.length;i < _len_i;i++){if(!$SetDict.__contains__(self,other.$items[i])){$SetDict.add(res,other.$items[i])}}
return res}
function $test(accept_iter,other,op){if(accept_iter===undefined && !_b_.isinstance(other,[set,frozenset])){throw _b_.TypeError("unsupported operand type(s) for "+op+
": 'set' and '"+$B.get_class(other).__name__+"'")}}
$B.make_rmethods($SetDict)
$SetDict.add=function(){var $=$B.args('add',2,{self:null,item:null},['self','item'],arguments,{},null,null),self=$.self,item=$.item
_b_.hash(item)
if(self.$str && !(typeof item=='string')){self.$str=false}
if(self.$num && !(typeof item=='number')){self.$num=false}
if(self.$num||self.$str){var ix=self.$items.indexOf(item)
if(ix==-1){self.$items.push(item)}
else{
if(item!==self.$items[ix]){self.$items.push(item)}}
return $N}
var cfunc=_b_.getattr(item,'__eq__')
for(var i=0,_len_i=self.$items.length;i < _len_i;i++){if(cfunc(self.$items[i]))return}
self.$items.push(item)
return $N}
$SetDict.clear=function(){var $=$B.args('clear',1,{self:null},['self'],arguments,{},null,null)
$.self.$items=[];
return $N}
$SetDict.copy=function(){var $=$B.args('copy',1,{self:null},['self'],arguments,{},null,null)
if(_b_.isinstance($.self,frozenset)){return $.self}
var res=set()
for(var i=0,_len_i=$.self.$items.length;i < _len_i;i++){res.$items[i]=$.self.$items[i]}
return res}
$SetDict.difference_update=function(self){var $=$B.args('difference_update',1,{self:null},['self'],arguments,{},'args',null)
for(var i=0;i<$.args.length;i++){var s=set($.args[i]),_next=_b_.getattr($B.$iter(s),'__next__'),item
while(true){try{item=_next()
var _type=typeof item
if(_type=='string' ||_type=="number"){var _index=self.$items.indexOf(item)
if(_index > -1){self.$items.splice(_index,1)}}else{
for(var j=0;j < self.$items.length;j++){if(_b_.getattr(self.$items[j],'__eq__')(item)){self.$items.splice(j,1)}}}}catch(err){if(_b_.isinstance(err,_b_.StopIteration)){break}
throw err}}}
return $N}
$SetDict.discard=function(){var $=$B.args('discard',2,{self:null,item:null},['self','item'],arguments,{},null,null)
try{$SetDict.remove($.self,$.item)}
catch(err){if(!_b_.isinstance(err,[_b_.KeyError,_b_.LookupError])){throw err}}
return $N}
$SetDict.intersection_update=function(){
var $=$B.args('intersection_update',1,{self:null},['self'],arguments,{},'args',null),self=$.self
for(var i=0;i<$.args.length;i++){var remove=[],s=set($.args[i])
for(var j=0;j<self.$items.length;j++){var _item=self.$items[j],_type=typeof _item
if(_type=='string' ||_type=="number"){if(s.$items.indexOf(_item)==-1){remove.push(j)}}else{var found=false
for(var k=0;!found && k < s.$items.length;k++){if(_b_.getattr(s.$items[k],'__eq__')(_item)){found=true}}
if(!found){remove.push(j)}}}
remove.sort(function(x,y){return x-y}).reverse()
for(var j=0;j<remove.length;j++){self.$items.splice(remove[j],1)}}
return $N}
$SetDict.isdisjoint=function(){var $=$B.args('is_disjoint',2,{self:null,other:null},['self','other'],arguments,{},null,null)
for(var i=0,_len_i=$.self.$items.length;i < _len_i;i++){if(_b_.getattr($.other,'__contains__')($.self.$items[i]))return false}
return true}
$SetDict.pop=function(self){if(self.$items.length===0)throw _b_.KeyError('pop from an empty set')
return self.$items.pop()}
$SetDict.remove=function(self,item){
var $=$B.args('remove',2,{self:null,item:null},['self','item'],arguments,{},null,null),self=$.self,item=$.item
if(!_b_.isinstance(item,set)){_b_.hash(item)}
if(typeof item=='string' ||typeof item=='number'){var _i=self.$items.indexOf(item)
if(_i==-1)throw _b_.KeyError(item)
self.$items.splice(_i,1)
return $N}
for(var i=0,_len_i=self.$items.length;i < _len_i;i++){if(_b_.getattr(self.$items[i],'__eq__')(item)){self.$items.splice(i,1)
return $N}}
throw _b_.KeyError(item)}
$SetDict.symmetric_difference_update=function(self,s){
var $=$B.args('symmetric_difference_update',2,{self:null,s:null},['self','s'],arguments,{},null,null),self=$.self,s=$.s
var _next=_b_.getattr($B.$iter(s),'__next__'),item,remove=[],add=[]
while(true){try{item=_next()
var _type=typeof item
if(_type=='string' ||_type=="number"){var _index=self.$items.indexOf(item)
if(_index > -1){remove.push(_index)}else{add.push(item)}}else{
var found=false
for(var j=0;!found && j < self.$items.length;j++){if(_b_.getattr(self.$items[j],'__eq__')(item)){remove.push(j)
found=true}}
if(!found){add.push(item)}}}catch(err){if(_b_.isinstance(err,_b_.StopIteration)){break}
throw err}}
remove.sort(function(x,y){return x-y}).reverse()
for(var i=0;i<remove.length;i++){if(remove[i]!=remove[i-1]){self.$items.splice(remove[i],1)}}
for(var i=0;i<add.length;i++){$SetDict.add(self,add[i])}
return $N}
$SetDict.update=function(self){
var $=$B.args('update',1,{self:null},['self'],arguments,{},'args',null)
for(var i=0;i<$.args.length;i++){var other=set($.args[i])
for(var j=0,_len=other.$items.length;j < _len;j++){$SetDict.add(self,other.$items[j])}}
return $N}
$SetDict.difference=function(){var $=$B.args('difference',1,{self:null},['self'],arguments,{},'args',null)
if($.args.length==0){return $SetDict.copy($.self)}
var res=clone($.self)
for(var i=0;i<$.args.length;i++){res=$SetDict.__sub__(res,set($.args[i]))}
return res}
var fc=$SetDict.difference+''
eval('$SetDict.intersection = '+
fc.replace(/difference/g,'intersection').replace('__sub__','__and__'))
eval('$SetDict.symmetric_difference = '+
fc.replace(/difference/g,'symmetric_difference').replace('__sub__','__xor__'))
eval('$SetDict.union = '+
fc.replace(/difference/g,'union').replace('__sub__','__or__'))
$SetDict.issubset=function(){var $=$B.args('issubset',2,{self:null,other:null},['self','other'],arguments,{},'args',null),func=_b_.getattr($.other,'__contains__')
for(var i=0,len=$.self.$items.length;i<len;i++){if(!func($.self.$items[i])){return false}}
return true}
$SetDict.issuperset=function(){var $=$B.args('issuperset',2,{self:null,other:null},['self','other'],arguments,{},'args',null)
var func=_b_.getattr($.self,'__contains__'),it=$B.$iter($.other)
while(true){try{var item=_b_.next(it)
if(!func(item)){return false}}catch(err){if(_b_.isinstance(err,_b_.StopIteration)){return true}
throw err}}
return true}
function set(){
var res={__class__:$SetDict,$str:true,$num:true,$items:[]}
var args=[res].concat(Array.prototype.slice.call(arguments))
$SetDict.__init__.apply(null,args)
return res}
set.__class__=$B.$factory
set.$dict=$SetDict
$SetDict.$factory=set
$SetDict.__new__=$B.$__new__(set)
$B.set_func_names($SetDict)
var $FrozensetDict={__class__:$B.$type,__name__:'frozenset'}
$FrozensetDict.__mro__=[_b_.object.$dict]
for(var attr in $SetDict){switch(attr){case 'add':
case 'clear':
case 'discard':
case 'pop':
case 'remove':
case 'update':
break
default:
if($FrozensetDict[attr]==undefined){if(typeof $SetDict[attr]=='function'){$FrozensetDict[attr]=(function(x){return function(){return $SetDict[x].apply(null,arguments)}})(attr)}else{$FrozensetDict[attr]=$SetDict[attr]}}}}
$FrozensetDict.__hash__=function(self){if(self===undefined){return $FrozensetDict.__hashvalue__ ||$B.$py_next_hash-- }
if(self.__hashvalue__ !==undefined)return self.__hashvalue__
var _hash=1927868237
_hash *=self.$items.length
for(var i=0,_len_i=self.$items.length;i < _len_i;i++){var _h=_b_.hash(self.$items[i])
_hash ^=((_h ^ 89869747)^(_h << 16))* 3644798167}
_hash=_hash * 69069 + 907133923
if(_hash==-1)_hash=590923713
return self.__hashvalue__=_hash}
$FrozensetDict.__init__=function(){
return $N}
var singleton_id=Math.floor(Math.random()*Math.pow(2,40))
function empty_frozenset(){return{__class__:$FrozensetDict,$items:[],$id:singleton_id}}
function frozenset(){var $=$B.args('frozenset',1,{iterable:null},['iterable'],arguments,{iterable:null},null,null)
if($.iterable===null){return empty_frozenset()}
else if($.iterable.__class__==$FrozensetDict){return $.iterable}
var res=set($.iterable)
if(res.$items.length==0){return empty_frozenset()}
res.__class__=$FrozensetDict
return res}
frozenset.__class__=$B.$factory
frozenset.$dict=$FrozensetDict
$FrozensetDict.__new__=$B.$__new__(frozenset)
$FrozensetDict.$factory=frozenset
$B.set_func_names($FrozensetDict)
_b_.set=set
_b_.frozenset=frozenset})(__BRYTHON__)
;(function($B){eval($B.InjectBuiltins())
var $ObjectDict=_b_.object.$dict
var JSObject=$B.JSObject
var _window=window
function $getMouseOffset(target,ev){ev=ev ||_window.event;
var docPos=$getPosition(target);
var mousePos=$mouseCoords(ev);
return{x:mousePos.x - docPos.x,y:mousePos.y - docPos.y};}
function $getPosition(e){var left=0;
var top=0;
var width=e.width ||e.offsetWidth;
var height=e.height ||e.offsetHeight;
while(e.offsetParent){left +=e.offsetLeft;
top +=e.offsetTop;
e=e.offsetParent;}
left +=e.offsetLeft;
top +=e.offsetTop;
return{left:left,top:top,width:width,height:height};}
function $mouseCoords(ev){var posx=0;
var posy=0;
if(!ev)var ev=_window.event;
if(ev.pageX ||ev.pageY){posx=ev.pageX;
posy=ev.pageY;}else if(ev.clientX ||ev.clientY){posx=ev.clientX + document.body.scrollLeft
+ document.documentElement.scrollLeft;
posy=ev.clientY + document.body.scrollTop
+ document.documentElement.scrollTop;}
var res={}
res.x=_b_.int(posx)
res.y=_b_.int(posy)
res.__getattr__=function(attr){return this[attr]}
res.__class__="MouseCoords"
return res}
var $DOMNodeAttrs=['nodeName','nodeValue','nodeType','parentNode','childNodes','firstChild','lastChild','previousSibling','nextSibling','attributes','ownerDocument']
$B.$isNode=function(o){
return(
typeof Node==="object" ? o instanceof Node :
o && typeof o==="object" && typeof o.nodeType==="number" &&
typeof o.nodeName==="string"
);}
$B.$isNodeList=function(nodes){
try{var result=Object.prototype.toString.call(nodes);
var re=new RegExp("^\\[object (HTMLCollection|NodeList)\\]$")
return(typeof nodes==='object'
&& re.exec(result)!==null
&& nodes.length!==undefined
&&(nodes.length==0 ||
(typeof nodes[0]==="object" && nodes[0].nodeType > 0))
)}catch(err){return false}}
var $DOMEventAttrs_W3C=['NONE','CAPTURING_PHASE','AT_TARGET','BUBBLING_PHASE','type','target','currentTarget','eventPhase','bubbles','cancelable','timeStamp','stopPropagation','preventDefault','initEvent']
var $DOMEventAttrs_IE=['altKey','altLeft','button','cancelBubble','clientX','clientY','contentOverflow','ctrlKey','ctrlLeft','data','dataFld','dataTransfer','fromElement','keyCode','nextPage','offsetX','offsetY','origin','propertyName','reason','recordset','repeat','screenX','screenY','shiftKey','shiftLeft','source','srcElement','srcFilter','srcUrn','toElement','type','url','wheelDelta','x','y']
$B.$isEvent=function(obj){var flag=true
for(var i=0;i<$DOMEventAttrs_W3C.length;i++){if(obj[$DOMEventAttrs_W3C[i]]===undefined){flag=false;break}}
if(flag)return true
for(var i=0;i<$DOMEventAttrs_IE.length;i++){if(obj[$DOMEventAttrs_IE[i]]===undefined)return false}
return true}
var $NodeTypes={1:"ELEMENT",2:"ATTRIBUTE",3:"TEXT",4:"CDATA_SECTION",5:"ENTITY_REFERENCE",6:"ENTITY",7:"PROCESSING_INSTRUCTION",8:"COMMENT",9:"DOCUMENT",10:"DOCUMENT_TYPE",11:"DOCUMENT_FRAGMENT",12:"NOTATION"}
var $DOMEventDict={__class__:$B.$type,__name__:'DOMEvent'}
$DOMEventDict.__mro__=[$ObjectDict]
$DOMEventDict.__getattribute__=function(self,attr){switch(attr){case 'x':
return $mouseCoords(self).x
case 'y':
return $mouseCoords(self).y
case 'data':
if(self.dataTransfer!==undefined)return $Clipboard(self.dataTransfer)
return self['data']
case 'target':
if(self.target===undefined)return DOMNode(self.target)
return DOMNode(self.target)
case 'char':
return String.fromCharCode(self.which)}
var res=self[attr]
if(res!==undefined){if(typeof res=='function'){var func=function(){return res.apply(self,arguments)}
func.$infos={__name__:res.toString().substr(9,res.toString().search('{'))}
return func}
return $B.$JS2Py(res)}
throw _b_.AttributeError("object DOMEvent has no attribute '"+attr+"'")}
function $DOMEvent(ev){ev.__class__=$DOMEventDict
if(ev.preventDefault===undefined){ev.preventDefault=function(){ev.returnValue=false}}
if(ev.stopPropagation===undefined){ev.stopPropagation=function(){ev.cancelBubble=true}}
ev.__repr__=function(){return '<DOMEvent object>'}
ev.toString=ev.__str__=ev.__repr__
return ev}
$B.$DOMEvent=$DOMEvent
$B.DOMEvent=function(evt_name){
return $DOMEvent(new Event(evt_name))}
$B.DOMEvent.__class__=$B.$factory
$B.DOMEvent.$dict=$DOMEventDict
$DOMEventDict.$factory=$B.DOMEvent
var $ClipboardDict={__class__:$B.$type,__name__:'Clipboard'}
$ClipboardDict.__getitem__=function(self,name){return self.data.getData(name)}
$ClipboardDict.__mro__=[$ObjectDict]
$ClipboardDict.__setitem__=function(self,name,value){self.data.setData(name,value)}
function $Clipboard(data){
return{
data : data,__class__ : $ClipboardDict,}}
function $EventsList(elt,evt,arg){
this.elt=elt
this.evt=evt
if(isintance(arg,list)){this.callbacks=arg}
else{this.callbacks=[arg]}
this.remove=function(callback){var found=false
for(var i=0;i<this.callbacks.length;i++){if(this.callbacks[i]===callback){found=true
this.callback.splice(i,1)
this.elt.removeEventListener(this.evt,callback,false)
break}}
if(!found){throw KeyError("not found")}}}
var $OpenFile=$B.$OpenFile=function(file,mode,encoding){var res={__class__: $OpenFileDict,file: file,reader: new FileReader(),}
if(mode==='r'){res.reader.readAsText(file,encoding)}else if(mode==='rb'){res.reader.readAsBinaryString(file)}
return res}
var $OpenFileDict={__class__: $B.$type,
__name__: '$OpenFile',}
$OpenFile.$dict=$OpenFileDict
$OpenFileDict.$factory=$OpenFile
$OpenFile.__class__=$B.$factory
$OpenFileDict.__mro__=[$ObjectDict]
$OpenFileDict.__getattr__=function(self,attr){if(self['get_' + attr]!==undefined)
return self['get_' + attr]
return self.reader[attr]}
$OpenFileDict.__setattr__=function(self,attr,value){var obj=self.reader
if(attr.substr(0,2)=='on'){
var callback=function(ev){return value($DOMEvent(ev))}
obj.addEventListener(attr.substr(2),callback)}else if('set_' + attr in obj){return obj['set_' + attr](value)}else if(attr in obj){obj[attr]=value}else{
setattr(obj,attr,value)}}
var dom={File : function(){},FileReader : function(){}}
dom.File.__class__=$B.$type
dom.File.__str__=function(){return "<class 'File'>"}
dom.FileReader.__class__=$B.$type
dom.FileReader.__str__=function(){return "<class 'FileReader'>"}
function $Options(parent){return{
__class__:$OptionsDict,parent:parent}}
var $OptionsDict={__class__:$B.$type,__name__:'Options'}
$OptionsDict.__delitem__=function(self,arg){self.parent.options.remove(arg.elt)}
$OptionsDict.__getitem__=function(self,key){return DOMNode(self.parent.options[key])}
$OptionsDict.__len__=function(self){return self.parent.options.length}
$OptionsDict.__mro__=[$ObjectDict]
$OptionsDict.__setattr__=function(self,attr,value){self.parent.options[attr]=value}
$OptionsDict.__setitem__=function(self,attr,value){self.parent.options[attr]=$B.$JS2Py(value)}
$OptionsDict.__str__=function(self){return "<object Options wraps "+self.parent.options+">"}
$OptionsDict.append=function(self,element){self.parent.options.add(element.elt)}
$OptionsDict.insert=function(self,index,element){if(index===undefined){self.parent.options.add(element.elt)}
else{self.parent.options.add(element.elt,index)}}
$OptionsDict.item=function(self,index){return self.parent.options.item(index)}
$OptionsDict.namedItem=function(self,name){return self.parent.options.namedItem(name)}
$OptionsDict.remove=function(self,arg){self.parent.options.remove(arg.elt)}
var $StyleDict={__class__:$B.$type,__name__:'CSSProperty'}
$StyleDict.__mro__=[$ObjectDict]
$StyleDict.__getattr__=function(self,attr){return $ObjectDict.__getattribute__(self.js,attr)}
$StyleDict.__setattr__=function(self,attr,value){if(attr.toLowerCase()==='float'){self.js.cssFloat=value
self.js.styleFloat=value}else{switch(attr){case 'top':
case 'left':
case 'height':
case 'width':
case 'borderWidth':
if(isinstance(value,_b_.int))value=value+'px'}
self.js[attr]=value}}
function $Style(style){
return{__class__:$StyleDict,js:style}}
$Style.__class__=$B.$factory
$Style.$dict=$StyleDict
$StyleDict.$factory=$Style
var DOMNode=$B.DOMNode=function(elt,fromtag){if(elt.__class__===DOMNodeDict){return elt}
if(typeof elt=="number" ||typeof elt=="boolean" ||
typeof elt=="string"){return elt}
if(fromtag===undefined){if(DOMNodeDict.tags !==undefined){
var tdict=DOMNodeDict.tags.$string_dict
if(tdict !==undefined){var factory=tdict[elt.tagName]
if(factory !==undefined){
factory.$dict.$elt_wrap=elt
return factory()}}}}
var res={}
res.$dict={}
res.elt=elt
if(elt['$brython_id']===undefined||elt.nodeType===9){
elt.$brython_id='DOM-'+$B.UUID()}
res.__class__=DOMNodeDict
return res}
DOMNodeDict={__class__ : $B.$type,__name__ : 'DOMNode'}
DOMNode.__class__=$B.$factory
DOMNode.$dict=DOMNodeDict
DOMNodeDict.$factory=DOMNode
DOMNodeDict.__mro__=[_b_.object.$dict]
DOMNodeDict.__add__=function(self,other){
var res=$TagSum()
res.children=[self],pos=1
if(isinstance(other,$TagSum)){res.children=res.children.concat(other.children)}else if(isinstance(other,[_b_.str,_b_.int,_b_.float,_b_.list,_b_.dict,_b_.set,_b_.tuple])){res.children[pos++]=DOMNode(document.createTextNode(_b_.str(other)))}else if(isinstance(other,DOMNode)){res.children[pos++]=other}else{
try{res.children=res.children.concat(_b_.list(other))}
catch(err){throw _b_.TypeError("can't add '"+
$B.get_class(other).__name__+"' object to DOMNode instance")}}
return res}
DOMNodeDict.__bool__=function(self){return true}
DOMNodeDict.__class__=$B.$type
DOMNodeDict.__contains__=function(self,key){
if(self.elt.nodeType==9 && typeof key=="string"){return document.getElementById(key)!==null}
key=key.elt !==undefined ? key.elt : key
if(self.elt.length!==undefined && typeof self.elt.item=="function"){for(var i=0,len=self.elt.length;i<len;i++){if(self.elt.item(i)===key){return true}}}
return false}
DOMNodeDict.__del__=function(self){
if(!self.elt.parentNode){throw _b_.ValueError("can't delete "+str(self.elt))}
self.elt.parentNode.removeChild(self.elt)}
DOMNodeDict.__delitem__=function(self,key){if(self.elt.nodeType===9){
var res=self.elt.getElementById(key)
if(res){res.parentNode.removeChild(res)}
else{throw KeyError(key)}}else{
self.elt.parentNode.removeChild(self.elt)}}
DOMNodeDict.__dir__=function(self){var res=[]
for(var attr in self.elt){if(attr.charAt(0)!='$'){res.push(attr)}}
for(var attr in DOMNodeDict){if(attr.charAt(0)!='$' && res.indexOf(attr)==-1){res.push(attr)}}
return res}
DOMNodeDict.__eq__=function(self,other){return self.elt==other.elt}
DOMNodeDict.__getattribute__=function(self,attr){if(attr.substr(0,2)=='$$'){attr=attr.substr(2)}
switch(attr){case 'class_name':
case 'html':
case 'id':
case 'parent':
case 'query':
case 'text':
return DOMNodeDict[attr](self)
case 'height':
case 'left':
case 'top':
case 'width':
if(self.elt instanceof SVGElement){return self.elt.getAttributeNS(null,attr)}
return DOMNodeDict[attr].__get__(self)
case 'clear':
case 'closest':
return function(){return DOMNodeDict[attr](self,arguments[0])}
case 'headers':
if(self.elt.nodeType==9){
var req=new XMLHttpRequest();
req.open('GET',document.location,false);
req.send(null);
var headers=req.getAllResponseHeaders();
headers=headers.split('\r\n')
var res=_b_.dict()
for(var i=0;i<headers.length;i++){var header=headers[i]
if(header.strip().length==0){continue}
var pos=header.search(':')
res.__setitem__(header.substr(0,pos),header.substr(pos+1).lstrip())}
return res;}
break
case '$$location':
attr='location'
break}
if(self.elt.getAttribute!==undefined){res=self.elt.getAttribute(attr)
if(res!==undefined && res!==null && self.elt[attr]===undefined){
return res}}
if(self.elt.getAttributeNS!==undefined){res=self.elt.getAttributeNS(null,attr)
if(res!==undefined && res!==null && res!="" &&
self.elt[attr]===undefined){
return res}}
var res=self.elt[attr]
if(res!==undefined){if(res===null){return _b_.None}
if(typeof res==="function"){var func=(function(f,elt){return function(){var args=[],pos=0
for(var i=0;i<arguments.length;i++){var arg=arguments[i]
if(typeof arg=="function"){var f1=(function(x){return function(){try{return x.apply(null,arguments)}
catch(err){console.log(x,typeof x,err)
if(err.__class__!==undefined){var msg=_b_.getattr(err,'info')+
'\n'+err.__class__.__name__
if(err.args){msg +=': '+err.args[0]}
try{getattr($B.stderr,"write")(msg)}
catch(err){console.log(msg)}}else{try{getattr($B.stderr,"write")(err)}
catch(err1){console.log(err)}}
throw err}}})(arg)
args[pos++]=f1}
else if(isinstance(arg,JSObject)){args[pos++]=arg.js}else if(isinstance(arg,DOMNode)){args[pos++]=arg.elt}else if(arg===_b_.None){args[pos++]=null}else{args[pos++]=arg}}
var result=f.apply(elt,args)
return $B.$JS2Py(result)}})(res,self.elt)
func.$infos={__name__ : attr}
func.$is_func=true
return func}
if(attr=='options')return $Options(self.elt)
if(attr=='style')return $Style(self.elt[attr])
if(Array.isArray(res)){return res}
return $B.$JS2Py(res)}
return $ObjectDict.__getattribute__(self,attr)}
DOMNodeDict.__getitem__=function(self,key){if(self.elt.nodeType===9){
if(typeof key==="string"){var res=self.elt.getElementById(key)
if(res)return DOMNode(res)
throw KeyError(key)}else{try{var elts=self.elt.getElementsByTagName(key.$dict.__name__),res=[],pos=0
for(var $i=0;$i<elts.length;$i++)res[pos++]=DOMNode(elts[$i])
return res}catch(err){throw KeyError(str(key))}}}else{if(typeof self.elt.length=='number'){if((typeof key=="number" ||typeof key=="boolean")&&
typeof self.elt.item=='function'){var key_to_int=_b_.int(key)
if(key_to_int<0){key_to_int+=self.elt.length}
var res=DOMNode(self.elt.item(key_to_int))
if(res===undefined){throw _b_.KeyError(key)}
return res}else if(typeof key=="string" &&
typeof self.elt.getNamedItem=='function'){var res=DOMNode(self.elt.getNamedItem(key))
if(res===undefined){throw _b_.keyError(key)}
return res}}
throw _b_.TypeError('DOMNode object is not subscriptable')}}
DOMNodeDict.__iter__=function(self){
if(self.elt.length!==undefined && typeof self.elt.item=="function"){var items=[]
for(var i=0,len=self.elt.length;i<len;i++){items.push(DOMNode(self.elt.item(i)))}}else if(self.elt.childNodes!==undefined){var items=[]
for(var i=0,len=self.elt.childNodes.length;i<len;i++){items.push(DOMNode(self.elt.childNodes[i]))}}
return $B.$iter(items)}
DOMNodeDict.__le__=function(self,other){
var elt=self.elt
if(self.elt.nodeType===9){elt=self.elt.body}
if(isinstance(other,$TagSum)){var $i=0
for($i=0;$i<other.children.length;$i++){elt.appendChild(other.children[$i].elt)}}else if(typeof other==="string" ||typeof other==="number"){var $txt=document.createTextNode(other.toString())
elt.appendChild($txt)}else if(isinstance(other,DOMNode)){
elt.appendChild(other.elt)}else{try{
var items=_b_.list(other)
for(var i=0;i<items.length;i++){DOMNodeDict.__le__(self,items[i])}}catch(err){throw _b_.TypeError("can't add '"+
$B.get_class(other).__name__+
"' object to DOMNode instance")}}}
DOMNodeDict.__len__=function(self){return self.elt.length}
DOMNodeDict.__mul__=function(self,other){if(isinstance(other,_b_.int)&& other.valueOf()>0){var res=$TagSum()
var pos=res.children.length
for(var i=0;i<other.valueOf();i++){res.children[pos++]=DOMNodeDict.clone(self)()}
return res}
throw _b_.ValueError("can't multiply "+self.__class__+"by "+other)}
DOMNodeDict.__ne__=function(self,other){return !DOMNodeDict.__eq__(self,other)}
DOMNodeDict.__next__=function(self){self.$counter++
if(self.$counter<self.elt.childNodes.length){return DOMNode(self.elt.childNodes[self.$counter])}
throw _b_.StopIteration('StopIteration')}
DOMNodeDict.__radd__=function(self,other){
var res=$TagSum()
var txt=DOMNode(document.createTextNode(other))
res.children=[txt,self]
return res}
DOMNodeDict.__str__=DOMNodeDict.__repr__=function(self){var proto=Object.getPrototypeOf(self.elt)
if(proto){var name=proto.constructor.name
if(name===undefined){
var proto_str=proto.constructor.toString()
name=proto_str.substring(8,proto_str.length-1)}
return "<"+name+" object>"}
var res="<DOMNode object type '"
return res+$NodeTypes[self.elt.nodeType]+"' name '"+self.elt.nodeName+"'>"}
DOMNodeDict.__setattr__=function(self,attr,value){if(attr.substr(0,2)=='on'){
if(!_b_.bool(value)){
DOMNodeDict.unbind(self,attr.substr(2))}else{
DOMNodeDict.bind(self,attr.substr(2),value)}}else{if(DOMNodeDict['set_'+attr]!==undefined){return DOMNodeDict['set_'+attr](self,value)}
if(self.elt[attr]!==undefined){self.elt[attr]=value;return}
var attr1=attr.replace('_','-').toLowerCase()
if(self.elt instanceof SVGElement &&
self.elt.getAttributeNS(null,attr1)!==null){self.elt.setAttributeNS(null,attr1,value)
return}
if(typeof self.elt.getAttribute=='function' &&
typeof self.elt.setAttribute=='function'){var res=self.elt.getAttribute(attr1)
if(value===false){self.elt.removeAttribute(attr1)}else{try{self.elt.setAttribute(attr1,value)}catch(err){
self.elt[attr]=value
return _b_.None}
if(self.elt.getAttribute(attr1)!==value){
self.elt.removeAttribute(attr1)
self.elt[attr]=value}}
return _b_.None}
self.elt[attr]=value
return _b_.None}}
DOMNodeDict.__setitem__=function(self,key,value){self.elt.childNodes[key]=value}
DOMNodeDict.abs_left={__get__: function(self){return $getPosition(self.elt).left},__set__: function(){throw _b_.AttributeError("'DOMNode' objectattribute 'abs_left' is read-only")}}
DOMNodeDict.abs_top={__get__: function(self){return $getPosition(self.elt).top},__set__: function(){throw _b_.AttributeError("'DOMNode' objectattribute 'abs_top' is read-only")}}
DOMNodeDict.bind=function(self,event){
var _id
if(self.elt.nodeType===9){_id=0}
else{_id=self.elt.$brython_id}
self.$events=self.$events ||{}
var evlist=self.$events[event]=self.$events[event]||[]
if(arguments.length==2){
return(function(obj,evt){function f(callback){DOMNodeDict.bind(obj,evt,callback)
return callback}
return f})(self,event)}
for(var i=2;i<arguments.length;i++){var func=arguments[i]
var callback=(function(f){return function(ev){try{return f($DOMEvent(ev))}catch(err){if(err.__class__!==undefined){var msg=_b_.getattr(err,'info')+
'\n'+err.__class__.__name__
if(err.args){msg +=': '+err.args[0]}
try{getattr($B.stderr,"write")(msg)}
catch(err){console.log(msg)}}else{try{getattr($B.stderr,"write")(err)}
catch(err1){console.log(err)}}}}}
)(func)
callback.$infos=func.$infos
callback.$attrs=func.$attrs ||{}
callback.$func=func
self.elt.addEventListener(event,callback,false)
evlist.push([func,callback])}
return self}
DOMNodeDict.children=function(self){var res=[],pos=0,elt=self.elt
console.log(elt,elt.childNodes)
if(elt.nodeType==9){elt=elt.body}
for(var i=0;i<elt.childNodes.length;i++){res[pos++]=DOMNode(elt.childNodes[i])}
return res}
DOMNodeDict.clear=function(self){
var elt=self.elt
if(elt.nodeType==9){elt=elt.body}
while(elt.firstChild){elt.removeChild(elt.firstChild)}}
DOMNodeDict.Class=function(self){if(self.elt.className !==undefined)return self.elt.className
return None}
DOMNodeDict.class_name=function(self){return DOMNodeDict.Class(self)}
DOMNodeDict.clone=function(self){var res=DOMNode(self.elt.cloneNode(true))
var events=self.$events ||{}
for(var event in events){var evt_list=events[event]
for(var i=0;i<evt_list.length;i++){var func=evt_list[i][0]
DOMNodeDict.bind(res,event,func)}}
return res}
DOMNodeDict.closest=function(self,tagName){
var res=self.elt,tagName=tagName.toLowerCase()
while(res.tagName.toLowerCase()!=tagName){res=res.parentNode
if(res===undefined ||res.tagName===undefined){throw _b_.KeyError('no parent of type '+tagName)}}
return DOMNode(res)}
DOMNodeDict.events=function(self,event){self.$events=self.$events ||{}
var evt_list=self.$events[event]=self.$events[event]||[],callbacks=[]
for(var i=0;i<evt_list.length;i++){callbacks.push(evt_list[i][1])}
return callbacks}
DOMNodeDict.focus=function(self){return(function(obj){return function(){
setTimeout(function(){obj.focus();},10)}})(self.elt)}
DOMNodeDict.get=function(self){
var obj=self.elt
var args=[],pos=0
for(var i=1;i<arguments.length;i++){args[pos++]=arguments[i]}
var $ns=$B.args('get',0,{},[],args,{},null,'kw')
var $dict={}
var items=_b_.list(_b_.dict.$dict.items($ns['kw']))
for(var i=0;i<items.length;i++){$dict[items[i][0]]=items[i][1]}
if($dict['name']!==undefined){if(obj.getElementsByName===undefined){throw _b_.TypeError("DOMNode object doesn't support selection by name")}
var res=[],pos=0
var node_list=obj.getElementsByName($dict['name'])
if(node_list.length===0)return[]
for(var i=0;i<node_list.length;i++)res[pos++]=DOMNode(node_list[i])}
if($dict['tag']!==undefined){if(obj.getElementsByTagName===undefined){throw _b_.TypeError("DOMNode object doesn't support selection by tag name")}
var res=[],pos=0
var node_list=obj.getElementsByTagName($dict['tag'])
if(node_list.length===0)return[]
for(var i=0;i<node_list.length;i++)res[pos++]=DOMNode(node_list[i])}
if($dict['classname']!==undefined){if(obj.getElementsByClassName===undefined){throw _b_.TypeError("DOMNode object doesn't support selection by class name")}
var res=[],pos=0
var node_list=obj.getElementsByClassName($dict['classname'])
if(node_list.length===0)return[]
for(var i=0;i<node_list.length;i++)res[pos++]=DOMNode(node_list[i])}
if($dict['id']!==undefined){if(obj.getElementById===undefined){throw _b_.TypeError("DOMNode object doesn't support selection by id")}
var id_res=document.getElementById($dict['id'])
if(!id_res)return[]
return[DOMNode(id_res)]}
if($dict['selector']!==undefined){if(obj.querySelectorAll===undefined){throw _b_.TypeError("DOMNode object doesn't support selection by selector")}
var node_list=obj.querySelectorAll($dict['selector'])
var sel_res=[],pos=0
if(node_list.length===0)return[]
for(var i=0;i<node_list.length;i++)sel_res[pos++]=DOMNode(node_list[i])
if(res===undefined)return sel_res
var to_delete=[],pos=0
for(var i=0;i<res.length;i++){var elt=res[i],
flag=false
for(var j=0;j<sel_res.length;j++){if(elt.__eq__(sel_res[j])){flag=true;break}}
if(!flag){to_delete[pos++]=i}}
for(var i=to_delete.length-1;i>=0;i--)res.splice(to_delete[i],1)}
return res}
DOMNodeDict.getContext=function(self){
if(!('getContext' in self.elt)){throw _b_.AttributeError("object has no attribute 'getContext'")}
var obj=self.elt
return function(ctx){return JSObject(obj.getContext(ctx))}}
DOMNodeDict.getSelectionRange=function(self){
if(self.elt['getSelectionRange']!==undefined){return self.elt.getSelectionRange.apply(null,arguments)}}
DOMNodeDict.height={'__get__': function(self){
if(self.elt.tagName=='CANVAS'){return self.elt.height}
if(self.elt.style===undefined){return _b_.None}
var res=parseInt(self.elt.style.height)
if(isNaN(res)){return self.elt.offsetHeight}
return res},'__set__': function(obj,self,value){if(self.elt.tagName=='CANVAS'){self.elt.height=value}
self.elt.style.height=value+'px'}}
DOMNodeDict.html=function(self){var res=self.elt.innerHTML
if(res===undefined){if(self.elt.nodeType==9){res=self.elt.body.innerHTML}
else{res=_b_.None}}
return res}
DOMNodeDict.id=function(self){if(self.elt.id !==undefined)return self.elt.id
return None}
DOMNodeDict.index=function(self,selector){if(selector===undefined){
selector=self.elt.tagName}
var items=self.elt.parentElement.querySelectorAll(selector),rank=-1
for(var i=0;i<items.length;i++){if(items[i]===self.elt){rank=i;break}}
return rank}
DOMNodeDict.inside=function(self,other){
other=other.elt
var elt=self.elt
while(true){if(other===elt){return true}
elt=elt.parentElement
if(!elt){return false}}}
DOMNodeDict.left={'__get__': function(self){if(self.elt.style===undefined){return _b_.None}
var res=parseInt(self.elt.style.left)
if(isNaN(res)){throw _b_.AttributeError("node has no attribute 'left'")}
return res},'__set__': function(obj,self,value){self.elt.style.left=value+'px'}}
var EventListener=$B.make_class({name: "EventListener",init: function(self,obj){self.obj=obj}})
EventListener.$dict.__enter__=function(self){
var ns=$B.frames_stack[$B.frames_stack.length-1][1]
self.funcs=[]
for(var attr in ns){if(ns[attr]!==null && ns[attr].$infos!==undefined){self.funcs.push(ns[attr])}}}
EventListener.$dict.__exit__=function(self){var ns=$B.frames_stack[$B.frames_stack.length-1][1]
for(var attr in ns){if(ns[attr]!==null && ns[attr].$infos!==undefined){if(self.funcs.indexOf(ns[attr])==-1){DOMNodeDict.bind(self.obj,attr,ns[attr])}}}}
DOMNodeDict.listener={__get__:function(self){return EventListener(self)}}
DOMNodeDict.on=function(self,event){
return(function(obj,evt){function f(callback){DOMNodeDict.bind(obj,evt,callback)
return callback}
return f})(self,event)}
DOMNodeDict.options=function(self){
return new $OptionsClass(self.elt)}
DOMNodeDict.parent=function(self){if(self.elt.parentElement)return DOMNode(self.elt.parentElement)
return None}
DOMNodeDict.reset=function(self){
return function(){self.elt.reset()}}
DOMNodeDict.select=function(self,selector){
if(self.elt.querySelectorAll===undefined){throw _b_.TypeError("DOMNode object doesn't support selection by selector")}
var node_list=self.elt.querySelectorAll(selector),res=[]
if(node_list.length===0)return[]
for(var i=0,len=node_list.length;i<len;i++){res[i]=DOMNode(node_list[i])}
return res}
DOMNodeDict.select_one=function(self,selector){
if(self.elt.querySelector===undefined){throw _b_.TypeError("DOMNode object doesn't support selection by selector")}
var res=self.elt.querySelector(selector)
if(res===null){return None}
return DOMNode(res)}
DOMNodeDict.style=function(self){
self.elt.style.float=self.elt.style.cssFloat ||self.style.styleFloat
return $B.JSObject(self.elt.style)}
DOMNodeDict.top={'__get__': function(self){if(self.elt.style===undefined){return _b_.None}
var res=parseInt(self.elt.style.top)
if(isNaN(res)){throw _b_.AttributeError("node has no attribute 'top'")}
return res},'__set__': function(obj,self,value){self.elt.style.top=value+'px'}}
DOMNodeDict.setSelectionRange=function(self){
if(this['setSelectionRange']!==undefined){return(function(obj){return function(){return obj.setSelectionRange.apply(obj,arguments)}})(this)}else if(this['createTextRange']!==undefined){return(function(obj){return function(start_pos,end_pos){if(end_pos==undefined){end_pos=start_pos}
var range=obj.createTextRange();
range.collapse(true);
range.moveEnd('character',start_pos);
range.moveStart('character',end_pos);
range.select();}})(this)}}
DOMNodeDict.set_class_name=function(self,arg){self.elt.setAttribute('class',arg)}
DOMNodeDict.set_html=function(self,value){var elt=self.elt
if(elt.nodeType==9){elt=elt.body}
elt.innerHTML=str(value)}
DOMNodeDict.set_style=function(self,style){
if(!_b_.isinstance(style,_b_.dict)){throw TypeError('style must be dict, not '+$B.get_class(style).__name__)}
var items=_b_.list(_b_.dict.$dict.items(style))
for(var i=0;i<items.length;i++){var key=items[i][0],value=items[i][1]
if(key.toLowerCase()==='float'){self.elt.style.cssFloat=value
self.elt.style.styleFloat=value}else{switch(key){case 'top':
case 'left':
case 'width':
case 'borderWidth':
if(isinstance(value,_b_.int)){value=value+'px'}}
self.elt.style[key]=value}}}
DOMNodeDict.set_text=function(self,value){var elt=self.elt
if(elt.nodeType==9){elt=elt.body}
elt.innerText=str(value)
elt.textContent=str(value)}
DOMNodeDict.set_value=function(self,value){self.elt.value=str(value)}
DOMNodeDict.submit=function(self){
return function(){self.elt.submit()}}
DOMNodeDict.text=function(self){var elt=self.elt
if(elt.nodeType==9){elt=elt.body}
var res=elt.innerText ||elt.textContent
if(res===null){res=_b_.None}
return res}
DOMNodeDict.toString=function(self){if(self===undefined)return 'DOMNode'
return self.elt.nodeName}
DOMNodeDict.trigger=function(self,etype){
if(self.elt.fireEvent){self.elt.fireEvent('on' + etype);}else{
var evObj=document.createEvent('Events');
evObj.initEvent(etype,true,false);
self.elt.dispatchEvent(evObj);}}
DOMNodeDict.unbind=function(self,event){
self.$events=self.$events ||{}
if(self.$events==={}){return _b_.None}
if(event===undefined){for(var event in self.$events){DOMNodeDict.unbind(self,event)}
return _b_.None}
if(self.$events[event]===undefined ||self.$events[event].length==0){return _b_.None}
var events=self.$events[event]
if(arguments.length===2){
for(var i=0;i<events.length;i++){var callback=events[i][1]
self.elt.removeEventListener(event,callback,false)}
self.$events[event]=[]
return _b_.None}
for(var i=2;i<arguments.length;i++){var callback=arguments[i],flag=false,func=callback.$func
if(func===undefined){
var found=false
for(var j=0;j<events.length;j++){if(events[j][0]===callback){var func=callback,found=true
break}}
if(!found){throw _b_.TypeError('function is not an event callback')}}
for(var j=0;j<events.length;j++){if(getattr(func,'__eq__')(events[j][0])){var callback=events[j][1]
self.elt.removeEventListener(event,callback,false)
events.splice(j,1)
flag=true
break}}
if(!flag){throw KeyError('missing callback for event '+event)}}}
DOMNodeDict.width={'__get__': function(self){
if(self.elt.tagName=='CANVAS'){return self.elt.width}
if(self.elt.style===undefined){return _b_.None}
var res=parseInt(self.elt.style.width)
if(isNaN(res)){
return self.elt.offsetWidth}
return res},'__set__': function(obj,self,value){if(self.elt.tagName=='CANVAS'){
self.elt.width=value}
self.elt.style.width=value+'px'}}
var $QueryDict={__class__:$B.$type,__name__:'query'}
$QueryDict.__contains__=function(self,key){return self._keys.indexOf(key)>-1}
$QueryDict.__getitem__=function(self,key){
var result=self._values[key]
if(result===undefined)throw KeyError(key)
if(result.length==1)return result[0]
return result}
var $QueryDict_iterator=$B.$iterator_class('query string iterator')
$QueryDict.__iter__=function(self){return $B.$iterator(self._keys,$QueryDict_iterator)}
$QueryDict.__mro__=[$ObjectDict]
$QueryDict.getfirst=function(self,key,_default){
var result=self._values[key]
if(result===undefined){if(_default===undefined)return None
return _default}
return result[0]}
$QueryDict.getlist=function(self,key){
var result=self._values[key]
if(result===undefined)return[]
return result}
$QueryDict.getvalue=function(self,key,_default){try{return $QueryDict.__getitem__(self,key)}
catch(err){if(_default===undefined)return None
return _default}}
$QueryDict.keys=function(self){return self._keys}
DOMNodeDict.query=function(self){var res={__class__:$QueryDict,_keys :[],_values :{}}
var qs=location.search.substr(1).split('&')
for(var i=0;i<qs.length;i++){var pos=qs[i].search('=')
var elts=[qs[i].substr(0,pos),qs[i].substr(pos+1)]
var key=decodeURIComponent(elts[0])
var value=decodeURIComponent(elts[1])
if(res._keys.indexOf(key)>-1){res._values[key].push(value)}
else{res._keys.push(key)
res._values[key]=[value]}}
return res}
var $TagSumDict={__class__ : $B.$type,__name__:'TagSum'}
$TagSumDict.appendChild=function(self,child){self.children.push(child)}
$TagSumDict.__add__=function(self,other){if($B.get_class(other)===$TagSumDict){self.children=self.children.concat(other.children)}else if(isinstance(other,[_b_.str,_b_.int,_b_.float,_b_.dict,_b_.set,_b_.list])){self.children=self.children.concat(DOMNode(document.createTextNode(other)))}else{self.children.push(other)}
return self}
$TagSumDict.__mro__=[$ObjectDict]
$TagSumDict.__radd__=function(self,other){var res=$TagSum()
res.children=self.children.concat(DOMNode(document.createTextNode(other)))
return res}
$TagSumDict.__repr__=function(self){var res='<object TagSum> '
for(var i=0;i<self.children.length;i++){res+=self.children[i]
if(self.children[i].toString()=='[object Text]'){res +=' ['+self.children[i].textContent+']\n'}}
return res}
$TagSumDict.__str__=$TagSumDict.toString=$TagSumDict.__repr__
$TagSumDict.clone=function(self){var res=$TagSum(),$i=0
for($i=0;$i<self.children.length;$i++){res.children.push(self.children[$i].cloneNode(true))}
return res}
function $TagSum(){return{__class__:$TagSumDict,children:[],toString:function(){return '(TagSum)'}}}
$TagSum.__class__=$B.$factory
$TagSum.$dict=$TagSumDict
$B.$TagSum=$TagSum
var win=JSObject(_window)
win.get_postMessage=function(msg,targetOrigin){if(isinstance(msg,dict)){var temp={__class__:'dict'}
var items=_b_.list(_b_.dict.$dict.items(msg))
for(var i=0;i<items.length;i++)temp[items[i][0]]=items[i][1]
msg=temp}
return _window.postMessage(msg,targetOrigin)}
$B.DOMNodeDict=DOMNodeDict
$B.win=win})(__BRYTHON__)
;(function($B){
var _b_=$B.builtins
eval($B.InjectBuiltins())
function make_node(top_node,node){
if(node.C.$genjs){var ctx_js=node.C.$genjs}else{var ctx_js=node.C.$genjs=node.C.to_js()}
var is_cond=false,is_except=false,is_else=false,is_continue
if(node.locals_def){
var iter_name=top_node.iter_id
ctx_js='for(var attr in this.blocks){'+
'eval("var "+attr+"=this.blocks[attr]");};'+
'var $locals_'+iter_name+' = this.env = {}'+
', $local_name = "'+iter_name+
'", $locals = $locals_'+iter_name+';'}
if(node.is_catch){is_except=true;is_cond=true}
if(node.is_except){is_except=true}
if(node.C.type=='node'){var ctx=node.C.tree[0]
var ctype=ctx.type
switch(ctx.type){case 'except':
is_except=true
is_cond=true
break
case 'single_kw':
is_cond=true
if(ctx.token=='else')is_else=true
if(ctx.token=='finally')is_except=true
break
case 'condition':
if(ctx.token=='elif'){is_else=true;is_cond=true}
if(ctx.token=='if')is_cond=true}}
if(ctx_js){
var new_node=new $B.genNode(ctx_js)
if(ctype=='yield'){
var yield_node_id=top_node.yields.length
while(ctx_js.charAt(ctx_js.length-1)==';'){ctx_js=ctx_js.substr(0,ctx_js.length-1)}
var res='return ['+ctx_js+', '+yield_node_id+']'
new_node.data=res
top_node.yields.push(new_node)}else if(node.is_set_yield_value){
var yield_node_id=top_node.yields.length
var js='var sent_value = this.sent_value || None;'
js +='if(sent_value.__class__===$B.$GeneratorSendError)'+
'{throw sent_value.err}'
js +='var $yield_value'+ctx_js+'=sent_value;'
js +='this.sent_value=None'
new_node.data=js}else if(ctype=='break' ||ctype=="continue"){
new_node['is_'+ctype]=true
new_node.loop_num=node.C.tree[0].loop_ctx.loop_num}
new_node.is_yield=(ctype=='yield'||ctype=='return')
new_node.is_cond=is_cond
new_node.is_except=is_except
new_node.is_if=ctype=='condition' && ctx.token=="if"
new_node.is_try=node.is_try
new_node.is_else=is_else
new_node.loop_start=node.loop_start
new_node.is_set_yield_value=node.is_set_yield_value
for(var i=0,_len_i=node.children.length;i < _len_i;i++){var nd=make_node(top_node,node.children[i])
if(nd!==undefined){new_node.addChild(nd)}}}
return new_node}
$B.genNode=function(data,parent){this.data=data
this.parent=parent
this.children=[]
this.has_child=false
if(parent===undefined){this.nodes={}
this.num=0}
this.addChild=function(child){if(child===undefined){console.log('child of '+this+' undefined')}
this.children[this.children.length]=child
this.has_child=true
child.parent=this
child.rank=this.children.length-1}
this.clone=function(){var res=new $B.genNode(this.data)
res.has_child=this.has_child
res.is_cond=this.is_cond
res.is_except=this.is_except
res.is_if=this.is_if
res.is_try=this.is_try
res.is_else=this.is_else
res.loop_num=this.loop_num
res.loop_start=this.loop_start
res.is_yield=this.is_yield
return res}
this.clone_tree=function(exit_node,head){
var res=new $B.genNode(this.data)
if(this.replaced && !in_loop(this)){
res.data='void(0)'}
if(this===exit_node &&(this.parent.is_cond ||!in_loop(this))){
if(!exit_node.replaced){
res=new $B.genNode('void(0)')}else{res=new $B.genNode(exit_node.data)}
exit_node.replaced=true}
if(head && this.is_break){res.data='$locals["$no_break'+this.loop_num+'"]=false;'
res.data +='var err = new Error("break");'
res.data +='err.__class__=$B.GeneratorBreak;throw err;'
res.is_break=true}
res.is_continue=this.is_continue
res.has_child=this.has_child
res.is_cond=this.is_cond
res.is_except=this.is_except
res.is_try=this.is_try
res.is_else=this.is_else
res.loop_num=this.loop_num
res.loop_start=this.loop_start
res.no_break=true
res.is_yield=this.is_yield
for(var i=0,_len_i=this.children.length;i < _len_i;i++){if(this.children[i].is_continue){
res.addChild(new $B.genNode('continue'))
break}
res.addChild(this.children[i].clone_tree(exit_node,head))
if(this.children[i].is_break){res.no_break=false}}
return res}
this.has=function(keyword){
if(this['is_'+keyword]){return true}
else{for(var i=0,_len_i=this.children.length;i < _len_i;i++){if(this.children[i].has(keyword)){return true}}}
return false}
this.indent_src=function(indent){return ' '.repeat(indent*indent)}
this.src=function(indent){
indent=indent ||0
var res=[this.indent_src(indent)+this.data],pos=1
if(this.has_child)res[pos++]='{'
res[pos++]='\n'
for(var i=0,_len_i=this.children.length;i < _len_i;i++){res[pos++]=this.children[i].src(indent+1)
if(this.children[i].is_yield){break}}
if(this.has_child)res[pos++]='\n'+this.indent_src(indent)+'}\n'
return res.join('')}
this.toString=function(){return '<Node '+this.data+'>'}}
$B.GeneratorBreak={}
$B.$GeneratorSendError={}
var $GeneratorReturn={}
$B.generator_return=function(value){return{__class__:$GeneratorReturn,value:value}}
function in_loop(node){
while(node){if(node.loop_start!==undefined)return node
node=node.parent}
return false}
function in_try(node){
var tries=[],pnode=node.parent,pos=0
while(pnode){if(pnode.is_try){tries[pos++]=pnode}
pnode=pnode.parent}
return tries}
var $BRGeneratorDict={__class__:$B.$type,__name__:'generator'}
$B.gen_counter=0
$B.$BRgenerator=function(func_name,blocks,def_id,def_node){
var def_ctx=def_node.C.tree[0]
var module=def_node.module,
iter_id=def_id
var func_root=new $B.genNode(def_ctx.to_js())
func_root.module=module
func_root.yields=[]
func_root.loop_ends={}
func_root.def_id=def_id
func_root.iter_id=iter_id
for(var i=0,_len_i=def_node.children.length;i < _len_i;i++){var nd=make_node(func_root,def_node.children[i])
if(nd===undefined){continue}
func_root.addChild(nd)}
var obj={__class__ : $BRGeneratorDict,blocks: blocks,def_ctx:def_ctx,def_id:def_id,func_name:func_name,func_root:func_root,module:module,gi_running:false,iter_id:iter_id,id:iter_id,num:0}
var src=func_root.src(),
raw_src=src.substr(src.search('function'))
raw_src +='return '+def_ctx.name+def_ctx.num+'}'
var funcs=[raw_src]
obj.parent_block=def_node.parent_block
for(var i=0;i<func_root.yields.length;i++){funcs.push(make_next(obj,i))}
delete $B.modules[iter_id]
delete $B.bound[iter_id]
return funcs}
function make_next(self,yield_node_id){
var exit_node=self.func_root.yields[yield_node_id]
exit_node.replaced=false
var root=new $B.genNode(self.def_ctx.to_js())
var fnode=self.func_root.clone()
root.addChild(fnode)
var js='for(var attr in this.blocks){eval("var "+attr+"='+
'this.blocks[attr]");};var $locals_'+self.iter_id+' = this.env,'+
' $locals = $locals_'+self.iter_id+', $local_name="'+self.iter_id+'";'
fnode.addChild(new $B.genNode(js))
js='var $top_frame = ["'+self.iter_id+'",$locals,"'+self.module+
'",$locals_'+self.module.replace(/\./g,'_')+'];'+
'$B.frames_stack.push($top_frame); var $stack_length = '+
'$B.frames_stack.length;'
fnode.addChild(new $B.genNode(js))
while(1){
var exit_parent=exit_node.parent,rest=[],pos=0,has_break,has_continue
var start=exit_node.rank+1
if(exit_node.loop_start!==undefined){
start=exit_node.rank}else if(exit_node.is_cond){
while(start<exit_parent.children.length &&
(exit_parent.children[start].is_except ||
exit_parent.children[start].is_else)){start++}}else if(exit_node.is_try ||exit_node.is_except){
while(start<exit_parent.children.length &&
(exit_parent.children[start].is_except ||
exit_parent.children[start].is_else)){start++}}
for(var i=start,_len_i=exit_parent.children.length;i < _len_i;i++){var clone=exit_parent.children[i].clone_tree(null,true)
if(clone.has('continue')){has_continue=true;break}
rest[pos++]=clone
if(clone.has('break')){has_break=true}}
if(has_break && rest.length>0){
var rest_try=new $B.genNode('try')
for(var i=0,_len_i=rest.length;i < _len_i;i++){rest_try.addChild(rest[i])}
var catch_test='catch(err)'
catch_test +='{if(err.__class__!==$B.GeneratorBreak)'
catch_test +='{throw err}}'
catch_test=new $B.genNode(catch_test)
rest=[rest_try,catch_test]}
var tries=in_try(exit_node)
if(tries.length==0){
for(var i=0;i<rest.length;i++){fnode.addChild(rest[i])}}else{
var tree=[],pos=0
for(var i=0;i<tries.length;i++){var try_node=tries[i],try_clone=try_node.clone()
if(i==0){for(var j=0;j<rest.length;j++){try_clone.addChild(rest[j])}}
var children=[try_clone],cpos=1
for(var j=try_node.rank+1;j<try_node.parent.children.length;j++){if(try_node.parent.children[j].is_except){children[cpos++]=try_node.parent.children[j].clone_tree(null,true)}else{break}}
tree[pos++]=children}
var parent=fnode
while(tree.length){children=tree.pop()
for(var i=0;i<children.length;i++){parent.addChild(children[i])}
parent=children[0]}}
exit_node=exit_parent
if(exit_node===self.func_root){break}}
var src=root.children[0].src(),next_src=src.substr(src.search('function'))
next_src=next_src.substr(10)
next_src=next_src.substr(next_src.search('function'))
return next_src}
var $gen_it={__class__: $B.$type,__name__: "generator"}
$gen_it.__mro__=[_b_.object.$dict]
$gen_it.__enter__=function(self){console.log("generator.__enter__ called")}
$gen_it.__exit__=function(self){console.log("generator.__exit__ called")}
$gen_it.__iter__=function(self){return self}
$gen_it.__next__=function(self){if(self.$finished){throw _b_.StopIteration()}
if(self.gi_running===true){throw ValueError("generator already executing")}
self.gi_running=true
if(self.next===undefined){self.$finished=true
throw _b_.StopIteration()}
try{var res=self.next.apply(self,self.args)}catch(err){
self.$finished=true
throw err}finally{
self.gi_running=false
$B.leave_frame(self.iter_id)}
if(res===undefined){throw _b_.StopIteration()}
else if(res[0].__class__==$GeneratorReturn){
self.$finished=true
throw StopIteration(res[0].value)}
self.next=self.nexts[res[1]]
self.gi_running=false
return res[0]}
$gen_it.close=function(self,value){self.sent_value=_b_.GeneratorExit()
try{var res=$gen_it.__next__(self)
if(res!==_b_.None){throw _b_.RuntimeError("closed generator returned a value")}}catch(err){if($B.is_exc(err,[_b_.StopIteration,_b_.GeneratorExit])){return _b_.None}
throw err}}
$gen_it.send=function(self,value){self.sent_value=value
return $gen_it.__next__(self)}
$gen_it.$$throw=function(self,value){if(_b_.isinstance(value,_b_.type))value=value()
self.sent_value={__class__:$B.$GeneratorSendError,err:value}
return $gen_it.__next__(self)}
$B.genfunc=function(name,blocks,funcs,$defaults){
return function(){var iter_id='$gen'+$B.gen_counter++,gfuncs=[]
gfuncs.push(funcs[0]($defaults))
for(var i=1;i<funcs.length;i++){gfuncs.push(funcs[i])}
var res={__class__: $gen_it,args: Array.prototype.slice.call(arguments),blocks: blocks,env:{},name: name,nexts: gfuncs.slice(1),next: gfuncs[0],iter_id: iter_id,gi_running: false,$started: false,$defaults: $defaults}
return res}}
$B.genfunc.__class__=$B.$factory
$B.genfunc.$dict=$gen_it
$gen_it.$factory=$B.genfunc})(__BRYTHON__)
;(function($B){var update=function(mod,data){for(attr in data){mod[attr]=data[attr]}}
var _window=self;
var modules={}
var browser={$package: true,$is_package: true,__package__:'browser',__file__:$B.brython_path.replace(/\/*$/g,'')+'/Lib/browser/__init__.py',console:$B.JSObject(self.console),win: $B.win,$$window: $B.win,}
browser.__path__=browser.__file__
if(! $B.isa_web_worker ){update(browser,{$$alert:function(message){window.alert($B.builtins.str(message))},confirm: $B.JSObject(window.confirm),$$document:$B.DOMNode(document),doc: $B.DOMNode(document),
DOMEvent:$B.DOMEvent,DOMNode:$B.DOMNode,load:function(script_url,names){
var file_obj=$B.builtins.open(script_url)
var content=$B.builtins.getattr(file_obj,'read')()
eval(content)
if(names!==undefined){if(!Array.isArray(names)){throw $B.builtins.TypeError("argument 'names' should be a"+
" list, not '"+$B.get_class(names).__name__)}else{for(var i=0;i<names.length;i++){try{_window[names[i]]=eval(names[i])}
catch(err){throw $B.builtins.NameError("name '"+
names[i]+"' not found in script "+script_url)}}}}},mouseCoords: function(ev){return $B.JSObject($mouseCoords(ev))},prompt: function(message,default_value){return $B.JSObject(window.prompt(message,default_value||''))},reload: function(){
var scripts=document.getElementsByTagName('script'),js_scripts=[]
for(var i=0;i<scripts.length;i++){if(scripts[i].type===undefined ||
scripts[i].type=='text/javascript'){js_scripts.push(scripts[i])
if(scripts[i].src){console.log(scripts[i].src)}}}
console.log(js_scripts)
for(var i=0;i<$B.scripts.length;i++){var name=$B.scripts[i]
console.log('script:',name)}
for(var mod in $B.imported){if($B.imported[mod].$last_modified){console.log('check',mod,$B.imported[mod].__file__,$B.imported[mod].$last_modified)}else{console.log('no date for mod',mod)}}},URLParameter:function(name){name=name.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");
var regex=new RegExp("[\\?&]" + name + "=([^&#]*)"),results=regex.exec(location.search);
results=results===null ? "" : decodeURIComponent(results[1].replace(/\+/g," "));
return $B.builtins.str(results);}})
modules['browser.html']=(function($B){var _b_=$B.builtins
var $TagSumDict=$B.$TagSum.$dict
function makeTagDict(tagName){
var dict={__class__:$B.$type,__name__:tagName}
dict.__init__=function(){var $ns=$B.args('pow',1,{self:null},['self'],arguments,{},'args','kw'),self=$ns['self'],args=$ns['args']
if(args.length==1){var first=args[0]
if(_b_.isinstance(first,[_b_.str,_b_.int,_b_.float])){
self.elt.innerHTML=_b_.str(first)}else if(first.__class__===$TagSumDict){for(var i=0,len=first.children.length;i < len;i++){self.elt.appendChild(first.children[i].elt)}}else{
if(_b_.isinstance(first,$B.DOMNode)){self.elt.appendChild(first.elt)}else{try{
var items=_b_.list(first)
for(var i=0;i<items.length;i++){$B.DOMNode.$dict.__le__(self,items[i])}}catch(err){throw _b_.ValueError('wrong element '+first)}}}}
var items=_b_.list(_b_.dict.$dict.items($ns['kw']))
for(var i=0,len=items.length;i < len;i++){
var arg=items[i][0],value=items[i][1]
if(arg.toLowerCase().substr(0,2)==="on"){
var js='$B.DOMNodeDict.bind(self,"'
js +=arg.toLowerCase().substr(2)
eval(js+'",function(){'+value+'})')}else if(arg.toLowerCase()=="style"){$B.DOMNodeDict.set_style(self,value)}else{
if(value!==false){
try{arg=arg.replace('_','-')
$B.DOMNodeDict.__setattr__(self,arg,value)}catch(err){throw _b_.ValueError("can't set attribute "+arg)}}}}}
dict.__mro__=[$B.DOMNodeDict,$B.builtins.object.$dict]
dict.__new__=function(cls){
if(cls.$dict.$elt_wrap !==undefined){
var elt=cls.$dict.$elt_wrap
cls.$dict.$elt_wrap=undefined
var res=$B.DOMNode(elt,true)
res._wrapped=true }else{
var res=$B.DOMNode(document.createElement(tagName),true)
res._wrapped=false }
res.__class__=cls.$dict
return res}
return dict}
function makeFactory(tagName){var factory=function(){if(factory.$dict.$elt_wrap !==undefined){
var elt=factory.$dict.$elt_wrap
factory.$dict.$elt_wrap=undefined
var res=$B.DOMNode(elt,true)
res._wrapped=true }else{
if(tagName=='SVG'){var res=$B.DOMNode(document.createElementNS("http://www.w3.org/2000/svg","svg"),true)}else{var res=$B.DOMNode(document.createElement(tagName),true)}
res._wrapped=false }
res.__class__=dicts[tagName]
var args=[res].concat(Array.prototype.slice.call(arguments))
dicts[tagName].__init__.apply(null,args)
return res}
factory.__class__=$B.$factory
factory.$dict=dicts[tagName]
return factory}
var tags=['A','ABBR','ACRONYM','ADDRESS','APPLET','AREA','B','BASE','BASEFONT','BDO','BIG','BLOCKQUOTE','BODY','BR','BUTTON','CAPTION','CENTER','CITE','CODE','COL','COLGROUP','DD','DEL','DFN','DIR','DIV','DL','DT','EM','FIELDSET','FONT','FORM','FRAME','FRAMESET','H1','H2','H3','H4','H5','H6','HEAD','HR','HTML','I','IFRAME','IMG','INPUT','INS','ISINDEX','KBD','LABEL','LEGEND','LI','LINK','MAP','MENU','META','NOFRAMES','NOSCRIPT','OBJECT','OL','OPTGROUP','OPTION','P','PARAM','PRE','Q','S','SAMP','SCRIPT','SELECT','SMALL','SPAN','STRIKE','STRONG','STYLE','SUB','SUP','SVG','TABLE','TBODY','TD','TEXTAREA','TFOOT','TH','THEAD','TITLE','TR','TT','U','UL','VAR',
'ARTICLE','ASIDE','AUDIO','BDI','CANVAS','COMMAND','DATA','DATALIST','EMBED','FIGCAPTION','FIGURE','FOOTER','HEADER','KEYGEN','MAIN','MARK','MATH','METER','NAV','OUTPUT','PROGRESS','RB','RP','RT','RTC','RUBY','SECTION','SOURCE','TEMPLATE','TIME','TRACK','VIDEO','WBR',
'DETAILS','DIALOG','MENUITEM','PICTURE','SUMMARY']
var obj={tags:_b_.dict()},dicts={}
$B.DOMNodeDict.tags=obj.tags
function maketag(tag){if(!(typeof tag=='string')){throw _b_.TypeError("html.maketag expects a string as argument")}
dicts[tag]=makeTagDict(tag)
var factory=makeFactory(tag)
dicts[tag].$factory=factory
obj.tags.$string_dict[tag]=factory
return factory}
for(var i=0,len=tags.length;i < len;i++){obj[tags[i]]=maketag(tags[i])}
obj.maketag=maketag
return obj})(__BRYTHON__)}
modules['browser']=browser
modules['javascript']={__file__:$B.brython_path+'/libs/javascript.js',$$this: function(){
if($B.js_this===undefined){return $B.builtins.None}
return $B.JSObject($B.js_this)},JSObject: function(){console.log('"javascript.JSObject" is deprecrated. '+
'Please refer to the documentation.')
return $B.JSObject.apply(null,arguments)},JSConstructor: function(){console.log('"javascript.JSConstructor" is deprecrated. '+
'Please refer to the documentation.')
return $B.JSConstructor.apply(null,arguments)},load:function(script_url,names){console.log('"javascript.load" is deprecrated. '+
'Please refer to the documentation.')
var file_obj=$B.builtins.open(script_url)
var content=$B.builtins.getattr(file_obj,'read')()
eval(content)
if(names!==undefined){if(!Array.isArray(names)){throw $B.builtins.TypeError("argument 'names' should be a"+
" list, not '"+$B.get_class(names).__name__)}else{for(var i=0;i<names.length;i++){try{_window[names[i]]=eval(names[i])}
catch(err){throw $B.builtins.NameError("name '"+
names[i]+"' not found in script "+script_url)}}}}},NULL: null,py2js: function(src,module_name){if(module_name===undefined){module_name='__main__'+$B.UUID()}
return $B.py2js(src,module_name,module_name,'__builtins__').to_js()},pyobj2jsobj:function(obj){return $B.pyobj2jsobj(obj)},jsobj2pyobj:function(obj){return $B.jsobj2pyobj(obj)},UNDEFINED: undefined}
var _b_=$B.builtins
modules['_sys']={__file__:$B.brython_path+'/libs/_sys.js',
Getframe : function(depth){return $B._frame($B.frames_stack,depth)},modules:{
__get__: function(){return _b_.dict($B.JSObject($B.imported))},__set__: function(self,obj,value){throw _b_.TypeError("Read only property 'sys.modules'")}},path:{
__get__: function(){return $B.path},__set__: function(self,obj,value){$B.path=value;}},meta_path:{
__get__: function(){return $B.meta_path},__set__: function(self,obj,value){$B.meta_path=value }},path_hooks:{
__get__: function(){return $B.path_hooks},__set__: function(self,obj,value){$B.path_hooks=value }},path_importer_cache:{
__get__: function(){return _b_.dict($B.JSObject($B.path_importer_cache))},__set__: function(self,obj,value){throw _b_.TypeError("Read only property"+
" 'sys.path_importer_cache'")}},stderr:{
__get__: function(){return $B.stderr},__set__: function(self,obj,value){$B.stderr=value},write: function(data){_b_.getattr($B.stderr,"write")(data)}},stdout:{
__get__: function(){return $B.stdout},__set__: function(self,obj,value){$B.stdout=value},write: function(data){_b_.getattr($B.stdout,"write")(data)}},stdin : $B.stdin}
function load(name,module_obj){
module_obj.__class__=$B.$ModuleDict
module_obj.__name__=name
module_obj.__repr__=module_obj.__str__=function(){return "<module '"+name+"' (built-in)>"}
$B.imported[name]=$B.modules[name]=module_obj
for(var attr in module_obj){if(typeof module_obj[attr]=='function'){var name=attr
while(name.charAt(0)=='$'){name=name.substr(1)}
module_obj[attr].$infos={__name__:name}}}}
for(var attr in modules){load(attr,modules[attr])}
if(! $B.isa_web_worker)modules['browser'].html=modules['browser.html'];
var _b_=$B.builtins
_b_.__builtins__=$B.$ModuleDict.$factory('__builtins__','Python builtins')
for(var attr in $B.builtins){_b_.__builtins__[attr]=_b_[attr]}
_b_.__builtins__.__setattr__=function(attr,value){_b_[attr]=value}
$B.bound.__builtins__.__builtins__=_b_.__builtins__})(__BRYTHON__)
;(function($B){var _b_=$B.builtins
function import_hooks(mod_name,_path,module,blocking){
if($B.is_none(module)){module=undefined;}
var _meta_path=$B.meta_path;
var spec=undefined;
for(var i=0,_len_i=_meta_path.length;i < _len_i && $B.is_none(spec);i++){var _finder=_meta_path[i],find_spec=_b_.getattr(_finder,'find_spec',null)
if(find_spec !==null){spec=_b_.getattr(find_spec,'__call__')(mod_name,_path,undefined,blocking);
spec.blocking=blocking}}
if($B.is_none(spec)){
throw _b_.ImportError('No module named '+mod_name);}
var _loader=_b_.getattr(spec,'loader',_b_.None),_sys_modules=$B.imported,_spec_name=_b_.getattr(spec,'name');
if($B.is_none(module)){
if(!$B.is_none(_loader)){var create_module=_b_.getattr(_loader,'create_module',_b_.None);
if(!$B.is_none(create_module)){module=_b_.getattr(create_module,'__call__')(spec);}}
if(module===undefined){throw _b_.ImportError(mod_name)}
if($B.is_none(module)){
module=$B.$ModuleDict.$factory(mod_name);
var mod_desc=_b_.getattr(spec,'origin');
if(_b_.getattr(spec,'has_location')){mod_desc="from '" + mod_desc + "'";}
else{
mod_desc='(' + mod_desc + ')';}}}
module.__name__=_spec_name;
module.__loader__=_loader;
module.__package__=_b_.getattr(spec,'parent','');
module.__spec__=spec;
var locs=_b_.getattr(spec,'submodule_search_locations');
if(module.$is_package=!$B.is_none(locs)){module.__path__=locs;}
if(_b_.getattr(spec,'has_location')){module.__file__=_b_.getattr(spec,'origin')
$B.$py_module_path[module.__name__]=module.__file__;}
var cached=_b_.getattr(spec,'cached');
if(!$B.is_none(cached)){module.__cached__=cached;}
if($B.is_none(_loader)){if(!$B.is_none(locs)){$B.modules[_spec_name]=_sys_modules[_spec_name]=module;}
else{
throw _b_.ImportError(mod_name);}}
else{
var exec_module=_b_.getattr(_loader,'exec_module',_b_.None);
if($B.is_none(exec_module)){
module=_b_.getattr(_b_.getattr(_loader,'load_module'),'__call__')(_spec_name);}
else{
$B.modules[_spec_name]=_sys_modules[_spec_name]=module;
try{_b_.getattr(exec_module,'__call__')(module,blocking)}
catch(e){delete $B.modules[_spec_name];
delete _sys_modules[_spec_name];
throw e;}}}
return _sys_modules[_spec_name];}
$B.import_hooks=import_hooks})(__BRYTHON__)
__BRYTHON__.use_VFS = true;
__BRYTHON__.VFS={"builtins": [".js", "var $module = (function(){\n var obj = {__class__:__BRYTHON__.$ModuleDict,__name__:'builtins'}\n var builtin_names = ['ArithmeticError', 'AssertionError', 'AttributeError', \n 'BaseException', 'BlockingIOError', 'BrokenPipeError', 'BufferError', \n 'BytesWarning', 'ChildProcessError', 'ConnectionAbortedError', \n 'ConnectionError', 'ConnectionRefusedError', 'ConnectionResetError', \n 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', \n 'False', 'FileExistsError', 'FileNotFoundError', 'FloatingPointError', \n 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', \n 'IndentationError', 'IndexError', 'InterruptedError', 'IsADirectoryError',\n 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', \n 'None', 'NotADirectoryError', 'NotImplemented', 'NotImplementedError', \n 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'PermissionError', \n 'ProcessLookupError', 'ReferenceError', 'ResourceWarning', 'RuntimeError', \n 'RuntimeWarning', 'StopIteration', 'SyntaxError', 'SyntaxWarning', \n 'SystemError', 'SystemExit', 'TabError', 'TimeoutError', 'True', 'TypeError', \n 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', \n 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', \n 'ValueError', 'Warning', 'WindowsError', 'ZeroDivisionError', '_', \n '__build_class__', '__debug__', '__doc__', '__import__', '__name__', \n '__package__', 'abs', 'all', 'any', 'ascii', 'bin', 'bool', 'bytearray', \n 'bytes','callable', 'chr', 'classmethod', 'compile', 'complex', 'copyright', \n 'credits','delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'exec', \n 'exit', 'filter', 'float', 'format', 'frozenset', 'getattr', 'globals', \n 'hasattr', 'hash', 'help', 'hex', 'id', 'input', 'int', 'isinstance', \n 'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'map', 'max', \n 'memoryview', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', \n 'property', 'quit', 'range', 'repr', 'reversed', 'round', 'set', 'setattr', \n 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', \n 'vars', 'zip']\n for(var i=0, _len_i = builtin_names.length; i < _len_i;i++){\n try{eval(\"obj['\"+builtin_names[i]+\"']=__BRYTHON__.builtins.\"+builtin_names[i])}\n catch(err){if (__BRYTHON__.$debug) {console.log(err)}}\n }\n return obj\n})()\n"], "dis": [".js", "var $module=(function($B){\n\nvar mod = {\n dis:function(src){\n $B.$py_module_path['__main__'] = $B.brython_path\n return __BRYTHON__.py2js(src,'__main__','__main__','__builtins__').to_js()\n }\n}\nreturn mod\n\n})(__BRYTHON__)"], "hashlib": [".js", "var $module=(function($B){\n\nvar _b_ = $B.builtins\n\nvar $s=[]\nfor(var $b in _b_) $s.push('var ' + $b +'=_b_[\"'+$b+'\"]')\neval($s.join(';'))\n\nvar $mod = {\n\n __getattr__ : function(attr){\n if (attr == 'new') return $hashlib_new;\n return this[attr]\n },\n md5: function(obj) {return $hashlib_new('md5', obj)},\n sha1: function(obj) {return $hashlib_new('sha1', obj)},\n sha224: function(obj) {return $hashlib_new('sha224', obj)},\n sha256: function(obj) {return $hashlib_new('sha256', obj)},\n sha384: function(obj) {return $hashlib_new('sha384', obj)},\n sha512: function(obj) {return $hashlib_new('sha512', obj)},\n\n algorithms_guaranteed: ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512'],\n algorithms_available: ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512']\n}\n\n\n//todo: eventually move this function to a \"utility\" file or use ajax module?\nfunction $get_CryptoJS_lib(alg) {\n var imp=$importer()\n var $xmlhttp=imp[0], fake_qs=imp[1], timer=imp[2], res=null\n\n $xmlhttp.onreadystatechange = function(){\n if($xmlhttp.readyState==4){\n window.clearTimeout(timer)\n if($xmlhttp.status==200 || $xmlhttp.status==0){res=$xmlhttp.responseText}\n else{\n // don't throw an exception here, it will not be caught (issue #30)\n res = Error()\n res.name = 'NotFoundError'\n res.message = \"No CryptoJS lib named '\"+alg+\"'\"\n }\n }\n }\n\n $xmlhttp.open('GET', $B.brython_path+'libs/crypto_js/rollups/'+alg+'.js'+fake_qs,false)\n if('overrideMimeType' in $xmlhttp){$xmlhttp.overrideMimeType(\"text/plain\")}\n $xmlhttp.send()\n if(res.constructor===Error){throw res} // module not found\n\n try{\n eval(res + \"; $B.CryptoJS=CryptoJS;\")\n } catch (err) { \n throw Error(\"JS Eval Error\", \"Cannot eval CryptoJS algorithm '\" + alg + \"' : error:\" + err);\n }\n}\n\nfunction bytes2WordArray(obj){\n // Transform a bytes object into an instance of class WordArray\n // defined in CryptoJS\n if(!_b_.isinstance(obj, _b_.bytes)){\n throw _b_.TypeError(\"expected bytes, got \"+\n $B.get_class(obj).__name__)\n }\n\n var words = []\n for(var i=0;i<obj.source.length;i+=4){\n var word = obj.source.slice(i, i+4)\n while(word.length<4){word.push(0)}\n var w = word[3] +(word[2]<<8)+(word[1]<<16)+(word[0]<<24)\n words.push(w)\n }\n return {words: words, sigBytes:obj.source.length}\n}\n\nvar hashDict = {\n __class__: $B.$type,\n __name__: 'hash'\n}\nhashDict.__mro__ = [_b_.object.$dict]\n\nhashDict.update = function(self, msg){\n self.hash.update(bytes2WordArray(msg))\n}\n\nhashDict.copy = function(self){\n return self.hash.clone()\n}\n \nhashDict.digest = function(self){\n var obj = self.hash.clone().finalize().toString(),\n res = []\n for(var i=0;i<obj.length;i+=2){\n res.push(parseInt(obj.substr(i,2), 16))\n }\n return _b_.bytes(res)\n}\n\nhashDict.hexdigest = function(self) {\n return self.hash.clone().finalize().toString()\n}\n\n\nfunction $hashlib_new(alg, obj) {\n\n var res = {\n __class__: hashDict\n }\n\n switch(alg) {\n case 'md5':\n case 'sha1':\n case 'sha224':\n case 'sha256':\n case 'sha384':\n case 'sha512':\n var ALG=alg.toUpperCase()\n if ($B.Crypto === undefined || \n $B.CryptoJS.algo[ALG] === undefined) $get_CryptoJS_lib(alg)\n\n res.hash = $B.CryptoJS.algo[ALG].create()\n if(obj!==undefined){\n res.hash.update(bytes2WordArray(obj))\n }\n break\n default:\n $raise('AttributeError', 'Invalid hash algorithm:' + alg)\n }\n \n return res\n}\n\n$hashlib_new.$type = $B.$factory\nhashDict.$factory = $hashlib_new\n$hashlib_new.$dict = hashDict\n\nreturn $mod\n\n})(__BRYTHON__)\n"], "json": [".js", "var $module = (function($B){\n\nreturn {\n loads : function(){\n var $ = $B.args('loads', 1, {obj:null}, ['obj'], arguments, {},\n null, null)\n return $B.jsobject2pyobject(JSON.parse($.obj))\n },\n load : function(){\n var $ = $B.args('load', 1, {obj:null}, ['obj'], arguments, {},\n null, null)\n return $module.loads(obj.$content);\n },\n dumps : function(){\n var $ = $B.args('dumps', 1, {obj:null}, ['obj'], arguments, {},\n null, null)\n return JSON.stringify($B.pyobject2jsobject($.obj))\n },\n}\n\n})(__BRYTHON__)\n"], "long_int": [".js", "/*\nModule to manipulate long integers\n*/\n\nvar $module=(function($B){\n\neval($B.InjectBuiltins())\n\nvar $LongIntDict = {__class__:$B.$type,__name__:'LongInt'}\n\nfunction add_pos(v1, v2){\n // Add two positive numbers\n // v1, v2 : strings\n // Return an instance of LongInt\n\n var res = '', carry = 0, iself=v1.length, sv=0\n for(var i=v2.length-1;i>=0;i--){\n iself--\n if(iself<0){sv=0}else{sv=parseInt(v1.charAt(iself))}\n x = (carry+sv+parseInt(v2.charAt(i))).toString()\n if(x.length==2){res=x.charAt(1)+res;carry=parseInt(x.charAt(0))}\n else{res=x+res;carry=0}\n }\n while(iself>0){\n iself--\n x = (carry+parseInt(v1.charAt(iself))).toString()\n if(x.length==2){res=x.charAt(1)+res;carry=parseInt(x.charAt(0))}\n else{res=x+res;carry=0}\n }\n if(carry){res=carry+res} \n return {__class__:$LongIntDict, value:res, pos:true}\n}\n\nfunction check_shift(shift){\n // Check the argument of >> and <<\n if(!isinstance(shift, LongInt)){\n throw TypeError(\"shift must be LongInt, not '\"+\n $B.get_class(shift).__name__+\"'\")\n }\n if(!shift.pos){throw ValueError(\"negative shift count\")}\n}\n\nfunction clone(obj){\n // Used for traces\n var obj1 = {}\n for(var attr in obj){obj1[attr]=obj[attr]}\n return obj1\n}\n\nfunction comp_pos(v1, v2){\n // Compare two positive numbers\n if(v1.length>v2.length){return 1}\n else if(v1.length<v2.length){return -1}\n else{\n if(v1>v2){return 1}\n else if(v1<v2){return -1}\n }\n return 0\n}\n\nfunction divmod_pos(v1, v2){\n // v1, v2 : strings, represent 2 positive integers A and B\n // Return [a, b] where a and b are instances of LongInt\n // a = A // B, b = A % B\n var v1_init = v1, quotient, mod\n if(comp_pos(v1, v2)==-1){ // a < b\n quotient='0'\n mod = LongInt(v1)\n }else if(v2==v1){ // a = b\n quotient = '1';\n mod = LongInt('0')\n }else{\n var quotient = '', v1_init = v1\n var left = v1.substr(0, v2.length)\n if(v1<v2){left = v1.substr(0, v2.length+1)}\n var right = v1.substr(left.length)\n // mv2 maps integers i from 2 to 9 to i*v2, used as a cache to avoid\n // having to compute i*v2 each time\n var mv2 = {}\n // Javascript \"safe integer\" with the 15 first digits in v2,\n // used in the algorithm to test candidate values\n var jsv2 = parseInt(v2.substr(0,15))\n\n // Division algorithm\n // At each step in the division, v1 is split into substrings\n // \"left\" is the left part, with the same length as v2\n // \"rest\" is the rest of v1 after \"left\"\n // The algorithm finds the one-digit integer \"candidate\" such\n // that 0 <= left - candidate*v2 < v2\n // It stops when right is empty\n while(true){\n // Uses JS division to test an approximate result\n var jsleft = parseInt(left.substr(0,15))\n var candidate = Math.floor(jsleft/jsv2).toString()\n\n // Check that candidate is the correct result\n // Start by computing candidate*v2 : for this, use the table\n // mv2, which stores the multiples of v2 already calculated\n if(mv2[candidate]===undefined){\n mv2[candidate] = mul_pos(v2, candidate).value\n }\n if(comp_pos(left, mv2[candidate])==-1){\n // If left < candidate * v2, use candidate-1\n candidate--\n if(mv2[candidate]===undefined){\n mv2[candidate] = mul_pos(v2, candidate).value\n }\n }\n\n // Add candidate to the quotient\n quotient += candidate\n\n // New value for left : left - v2*candidate\n left = sub_pos(left, mv2[candidate]).value\n\n // Stop if all digits in v1 have been used\n if(right.length==0){break}\n\n // Else, add next digit to left and remove it from right\n left += right.charAt(0)\n right = right.substr(1)\n }\n // Modulo is A - (A//B)*B\n mod = sub_pos(v1, mul_pos(quotient, v2).value)\n }\n return [LongInt(quotient), mod]\n}\n\nfunction mul_pos(v1, v2){\n // Multiply positive numbers v1 by v2\n // Make v2 smaller than v1\n if(v1.length<v2.length){var a=v1; v1=v2 ; v2=a}\n if(v2=='0'){return LongInt('0')}\n var cols = {}, i=v2.length, j\n \n // Built the object \"cols\", indexed by integers from 1 to nb1+nb2-2\n // where nb1 and nb2 are the number of digits in v1 and v2.\n // cols[n] is the sum of v1[i]*v2[j] for i+j = n\n \n while(i--){\n var car = v2.charAt(i)\n if(car==\"0\"){\n j = v1.length\n while(j--){\n if(cols[i+j]===undefined){cols[i+j]=0}\n } \n }else if(car==\"1\"){\n j = v1.length\n while(j--){\n var z = parseInt(v1.charAt(j))\n if(cols[i+j]===undefined){cols[i+j]=z}\n else{cols[i+j] += z}\n }\n }else{\n var x = parseInt(car), j = v1.length, y, z\n while(j--){\n y = x * parseInt(v1.charAt(j))\n if(cols[i+j]===undefined){cols[i+j]=y}\n else{cols[i+j] += y}\n }\n }\n }\n\n // Transform cols so that cols[x] is a one-digit integers\n i = v1.length+v2.length-1\n while(i--){\n var col = cols[i].toString()\n if(col.length>1){\n // If the value in cols[i] has more than one digit, only keep the\n // last one and report the others at the right index\n // For instance if cols[i] = 123, keep 3 in cols[i], add 2 to\n // cols[i-1] and 1 to cols[i-2]\n cols[i] = parseInt(col.charAt(col.length-1))\n j = col.length\n while(j-->1){\n var report = parseInt(col.charAt(j-1))\n var pos = i-col.length+j\n if(cols[pos]===undefined){cols[pos]=report}\n else{cols[pos] += report}\n }\n }\n }\n\n // Find minimum index in cols\n // The previous loop may have introduced negative indices\n var imin\n for(var attr in cols){\n i = parseInt(attr)\n if(imin===undefined){imin=i}\n else if(i<imin){imin=i}\n }\n\n // Result is the concatenation of digits in cols\n var res = ''\n for(var i=imin;i<=v1.length+v2.length-2;i++){res+=cols[i].toString()}\n return LongInt(res)\n}\n\nfunction sub_pos(v1, v2){\n // Substraction of positive numbers with v1>=v2\n\n var res = '', carry = 0, i1=v1.length, sv=0\n \n // For all digits in v2, starting by the rightmost, substract it from\n // the matching digit in v1\n // This is the equivalent of the manual operation :\n // 12345678\n // - 98765\n //\n // We begin by the rightmost operation : 8-5 (3, no carry),\n // then 7-6 (1, no carry)\n // then 6-7 (9, carry 1) and so on\n for(var i=v2.length-1;i>=0;i--){\n i1--\n sv = parseInt(v1.charAt(i1))\n x = (sv-carry-parseInt(v2.charAt(i)))\n if(x<0){res=(10+x)+res;carry=1}\n else{res=x+res;carry=0}\n }\n \n // If there are remaining digits in v1, substract the carry, if any\n while(i1>0){\n i1--\n x = (parseInt(v1.charAt(i1))-carry)\n if(x<0){res=(10+x)+res;carry=1}\n else{res=x+res;carry=0}\n }\n\n // Remove leading zeros and return the result\n while(res.charAt(0)=='0' && res.length>1){res=res.substr(1)}\n return {__class__:$LongIntDict, value:res, pos:true}\n}\n\n// Special methods to implement operations on instances of LongInt\n\n$LongIntDict.__abs__ = function(self){\n return {__class__:$LongIntDict, value: self.value, pos:true}\n}\n\n$LongIntDict.__add__ = function(self, other){\n if (typeof other == 'number') other=LongInt(_b_.str(other))\n // Addition of \"self\" and \"other\"\n // If both have the same sign (+ or -) we add their absolute values\n // If they have different sign we use the substraction of their\n // absolute values\n var res\n if(self.pos&&other.pos){ // self > 0, other > 0\n return add_pos(self.value, other.value)\n }else if(!self.pos&&!other.pos){ // self < 0, other < 0\n res = add_pos(self.value, other.value)\n res.pos = false\n return res\n }else if(self.pos && !other.pos){ // self > 0, other < 0\n switch (comp_pos(self.value, other.value)){\n case 1:\n res = sub_pos(self.value, other.value)\n break\n case 0:\n res = {__class__:$LongIntDict, value:0, pos:true}\n break\n case -1:\n res = sub_pos(other.value, self.value)\n res.pos = false\n break\n }\n return res\n }else{ // self < 0, other > 0\n switch(comp_pos(self.value, other.value)){\n case 1:\n res = sub_pos(self.value, other.value)\n res.pos = false\n break\n case 0:\n res = {__class__:$LongIntDict, value:0, pos:true}\n break\n case -1:\n res = sub_pos(other.value, self.value)\n break\n }\n return res\n }\n}\n\n$LongIntDict.__and__ = function(self, other){\n if (typeof other == 'number') other=LongInt(_b_.str(other))\n // Bitwise \"and\" : build the binary representation of self and other\n var v1 = $LongIntDict.__index__(self)\n var v2 = $LongIntDict.__index__(other)\n // apply \"and\" on zeros and ones\n if(v1.length<v2.length){var temp=v2;v2=v1;v1=temp}\n var start = v1.length-v2.length\n var res = ''\n for(var i=0;i<v2.length;i++){\n if(v1.charAt(start+i)=='1' && v2.charAt(i)=='1'){res += '1'}\n else{res += '0'}\n }\n // Return the LongInt instance represented by res in base 2\n return LongInt(res, 2)\n}\n\n$LongIntDict.__divmod__ = function(self, other){\n if (typeof other == 'number') other=LongInt(_b_.str(other))\n\n var dm = divmod_pos(self.value, other.value)\n if(self.pos!==other.pos){\n if(dm[0].value!='0'){dm[0].pos = false}\n if(dm[1].value!='0'){\n // If self and other have different signs and self is not a multiple\n // of other, round to the previous integer\n dm[0] = $LongIntDict.__sub__(dm[0], LongInt('1'))\n dm[1] = $LongIntDict.__add__(dm[1], LongInt('1'))\n }\n }\n return dm \n}\n\n$LongIntDict.__eq__ = function(self, other){\n if (typeof other == 'number') other=LongInt(_b_.str(other))\n return self.value==other.value && self.pos==other.pos\n}\n\n$LongIntDict.__floordiv__ = function(self, other){\n if (typeof other == 'number') other=LongInt(_b_.str(other))\n return $LongIntDict.__divmod__(self, other)[0]\n}\n\n$LongIntDict.__ge__ = function(self, other){\n if (typeof other == 'number') other=LongInt(_b_.str(other))\n if(self.value.length>other.value.length){return true}\n else if(self.value.length<other.value.length){return false}\n else{return self.value >= other.value}\n}\n\n$LongIntDict.__gt__ = function(self, other){\n return !$LongIntDict.__le__(self, other)\n}\n\n$LongIntDict.__index__ = function(self){\n // Used by bin()\n // returns a string with the binary value of self\n // The algorithm computes the result of the floor division of self by 2\n \n // XXX to do : negative integers\n \n var res = '', pos=self.value.length,\n temp = self.value, d\n while(true){\n d = divmod_pos(temp, '2')\n res = d[1].value + res\n temp = d[0].value\n if(temp=='0'){break}\n }\n return res\n}\n\n$LongIntDict.__invert__ = function(self){\n var bin = $LongIntDict.__index__(self)\n var res = ''\n for(var i=0;i<bin.length;i++){\n res += bin.charAt(i)=='0' ? '1' : '0'\n }\n return LongInt(res, 2)\n}\n\n$LongIntDict.__le__ = function(self, other){\n if (typeof other == 'number') other=LongInt(_b_.str(other))\n if(self.value.length>other.value.length){return false}\n else if(self.value.length<other.value.length){return true}\n else{return self.value <= other.value}\n}\n\n$LongIntDict.__lt__ = function(self, other){\n return !$LongIntDict.__ge__(self, other)\n}\n\n$LongIntDict.__lshift__ = function(self, shift){\n check_shift(shift)\n var res = self.value\n while(true){\n var x, carry=0, res1=''\n for(var i=res.length-1;i>=0;i--){\n x = (carry+parseInt(res.charAt(i))*2).toString()\n if(x.length==2){res1=x.charAt(1)+res1;carry=parseInt(x.charAt(0))}\n else{res1=x+res1;carry=0}\n }\n if(carry){res1=carry+res1}\n res=res1\n shift = sub_pos(shift.value, '1')\n if(shift.value=='0'){break}\n }\n return {__class__:$LongIntDict, value:res, pos:self.pos}\n}\n\n$LongIntDict.__mod__ = function(self, other){\n return $LongIntDict.__divmod__(self, other)[1]\n}\n\n$LongIntDict.__mro__ = [_b_.object.$dict]\n\n$LongIntDict.__mul__ = function(self, other){\n if (typeof other == 'number') other=LongInt(_b_.str(other))\n var res = mul_pos(self.value, other.value)\n if(self.pos==other.pos){return res}\n res.pos = false\n return res\n}\n\n$LongIntDict.__neg__ = function(obj){\n return {__class__:$LongIntDict, value:obj.value, pos:!obj.pos}\n}\n\n$LongIntDict.__or__ = function(self, other){\n var v1 = $LongIntDict.__index__(self)\n var v2 = $LongIntDict.__index__(other)\n if(v1.length<v2.length){var temp=v2;v2=v1;v1=temp}\n var start = v1.length-v2.length\n var res = v1.substr(0, start)\n for(var i=0;i<v2.length;i++){\n if(v1.charAt(start+i)=='1' || v2.charAt(i)=='1'){res += '1'}\n else{res += '0'}\n }\n return LongInt(res, 2)\n}\n\n\n$LongIntDict.__pow__ = function(self, power){\n if (typeof power == \"number\") {\n power=LongInt(_b_.str(power))\n }else if(!isinstance(power, LongInt)){\n var msg = \"power must be a LongDict, not '\"\n throw TypeError(msg+$B.get_class(power).__name__+\"'\")\n }\n if(!power.pos){\n if(self.value=='1'){return self}\n // For all other integers, x**-n is 0\n return LongInt('0')\n }else if(power.value=='0'){\n return LongInt('1')\n }\n var res = {__class__:$LongIntDict, value:self.value, pos:self.pos}\n var pow = power.value\n while(true){\n pow = sub_pos(pow, '1').value\n if(pow == '0'){break}\n res = $LongIntDict.__mul__(res, self)\n }\n return res \n}\n\n$LongIntDict.__rshift__ = function(self, shift){\n check_shift(shift)\n var res = self.value\n while(true){\n res = divmod_pos(res, '2')[0].value\n if(res.value=='0'){break}\n shift = sub_pos(shift.value, '1')\n if(shift.value=='0'){break}\n }\n return {__class__:$LongIntDict, value:res, pos:self.pos}\n}\n\n$LongIntDict.__str__ = $LongIntDict.__repr__ = function(self){\n var res = \"LongInt('\"\n if(!self.pos){res += '-'}\n return res+self.value+\"')\"\n}\n\n$LongIntDict.__sub__ = function(self, other){\n if (typeof other == 'number') other=LongInt(_b_.str(other))\n var res\n if(self.pos && other.pos){\n switch(comp_pos(self.value, other.value)){\n case 1:\n res = sub_pos(self.value, other.value)\n break\n case 0:\n res = {__class__:$LongIntDict, value:'0', pos:true}\n break\n case -1:\n res = sub_pos(other.value, self.value)\n res.pos = false\n break\n }\n return res\n }else if(!self.pos && !other.pos){\n switch(comp_pos(self.value, other.value)){\n case 1:\n res = sub_pos(self.value, other.value)\n res.pos = false\n break\n case 0:\n res = {__class__:$LongIntDict, value:'0', pos:true}\n break\n case -1:\n res = sub_pos(other.value, self.value)\n break\n }\n return res\n }else if(self.pos && !other.pos){\n return add_pos(self.value, other.value)\n }else{\n res = add_pos(self.value, other.value)\n res.pos = false\n return res\n }\n}\n\n$LongIntDict.__xor__ = function(self, other){\n var v1 = $LongIntDict.__index__(self)\n var v2 = $LongIntDict.__index__(other)\n if(v1.length<v2.length){var temp=v2;v2=v1;v1=temp}\n var start = v1.length-v2.length\n var res = v1.substr(0, start)\n for(var i=0;i<v2.length;i++){\n if(v1.charAt(start+i)=='1' && v2.charAt(i)=='0'){res += '1'}\n else if(v1.charAt(start+i)=='0' && v2.charAt(i)=='1'){res += '1'}\n else{res += '0'}\n }\n return LongInt(res, 2)\n}\n\n$LongIntDict.to_base = function(self, base){\n // Returns the string representation of self in specified base\n var res='', v=self.value\n while(v>0){\n var dm = divmod_pos(v, base.toString())\n res = parseInt(dm[1].value).toString(base)+res\n v = dm[0].value\n if(v==0){break}\n }\n return res\n}\n\nfunction digits(base){\n // Return an object where keys are all the digits valid in specified base\n // and value is \"true\"\n // Used to test if the string passed as first argument to LongInt is valid\n var is_digits = {}\n // Number from 0 to base, or from 0 to 9 if base > 10\n for(var i=0;i<base;i++){\n if(i==10){break}\n is_digits[i]=true\n }\n if(base>10){\n // Additional letters\n // For instance in base 16, add \"abcdefABCDEF\" as keys\n for(var i=0;i<base-10;i++){\n is_digits[String.fromCharCode(65+i)]=true\n is_digits[String.fromCharCode(97+i)]=true\n }\n }\n return is_digits\n}\n\nvar MAX_SAFE_INTEGER = Math.pow(2, 53)-1;\nvar MIN_SAFE_INTEGER = -Number.MAX_SAFE_INTEGER;\n\nfunction isSafeInteger(n) {\n return (typeof n === 'number' &&\n Math.round(n) === n &&\n Number.MIN_SAFE_INTEGER <= n &&\n n <= Number.MAX_SAFE_INTEGER);\n}\n\nfunction LongInt(value, base){\n if(arguments.length>2){\n throw _b_.TypeError(\"LongInt takes at most 2 arguments (\"+\n arguments.length+\" given)\")\n }\n // base defaults to 10\n if(base===undefined){base = 10}\n else if(!isinstance(base, int)){\n throw TypeError(\"'\"+$B.get_class(base).__name__+\"' object cannot be interpreted as an integer\")\n }\n if(base<0 || base==1 || base>36){\n throw ValueError(\"LongInt() base must be >= 2 and <= 36\")\n }\n if(isinstance(value, float)){\n if(value>=0){value=Math.round(value.value)}\n else{value=Math.ceil(value.value)}\n }\n if(typeof value=='number'){\n if(isSafeInteger(value)){value = value.toString()}\n else{throw ValueError(\"argument of long_int is not a safe integer\")}\n }else if(typeof value!='string'){\n throw ValueError(\"argument of long_int must be a string, not \"+\n $B.get_class(value).__name__)\n }\n var has_prefix = false, pos = true, start = 0\n // Strip leading and trailing whitespaces\n while(value.charAt(0)==' ' && value.length){value = value.substr(1)}\n while(value.charAt(value.length-1)==' ' && value.length){\n value = value.substr(0, value.length-1)\n }\n // Check if string starts with + or -\n if(value.charAt(0)=='+'){has_prefix=true}\n else if(value.charAt(0)=='-'){has_prefix=true;pos=false}\n if(has_prefix){\n // Remove prefix\n if(value.length==1){\n // \"+\" or \"-\" alone are not valid arguments\n throw ValueError('LongInt argument is not a valid number: \"'+value+'\"')\n }else{value=value.substr(1)}\n }\n // Ignore leading zeros\n while(start<value.length-1 && value.charAt(start)=='0'){start++}\n value = value.substr(start)\n\n // Check if all characters in value are valid in the base\n var is_digits = digits(base), point = -1\n for(var i=0;i<value.length;i++){\n if(value.charAt(i)=='.' && point==-1){point=i}\n else if(!is_digits[value.charAt(i)]){\n throw ValueError('LongInt argument is not a valid number: \"'+value+'\"')\n }\n }\n if(point!=-1){value=value.substr(0,point)}\n if(base!=10){\n // Conversion to base 10\n var coef = '1', v10 = LongInt(0),\n pos = value.length, digit_base10\n while(pos--){\n digit_base10 = parseInt(value.charAt(pos), base).toString()\n digit_by_coef = mul_pos(coef, digit_base10).value\n v10 = add_pos(v10.value, digit_by_coef)\n coef = mul_pos(coef, base.toString()).value\n }\n return v10\n }\n return {__class__:$LongIntDict, value:value, pos:pos}\n}\n\nLongInt.__class__ = $B.$factory\nLongInt.$dict = $LongIntDict\n$LongIntDict.$factory = LongInt\n\nreturn {LongInt:LongInt}\n\n})(__BRYTHON__)\n"], "math": [".js", "var $module=(function($B){\n\nvar _b_ = $B.builtins\nvar $s=[]\nfor(var $b in _b_) $s.push('var ' + $b +'=_b_[\"'+$b+'\"]')\neval($s.join(';'))\n\n//for(var $py_builtin in _b_){eval(\"var \"+$py_builtin+\"=_b_[$py_builtin]\")}\n\nvar float_check=function(x) {\n if (x.__class__===$B.LongInt.$dict){return parseInt(x.value)}\n return _b_.float(x)\n}\n\nvar isWholeNumber=function(x){return (x*10) % 10 == 0}\n\nvar isOdd=function(x) {return isWholeNumber(x) && 2*Math.floor(x/2) != x}\n\nvar isLargeNumber=function(x) {return x > Math.pow(2,32)}\n\n// Big number Library from jsfromhell.com\n// This library helps with producing \"correct\" results from \n// mathematic operations\n\n//+ Jonas Raoni Soares Silva\n//@ http://jsfromhell.com/classes/bignumber [rev. #4]\n\n\nvar BigNumber = function(n, p, r){\n var o = this, i;\n if(n instanceof BigNumber){\n for(i in {precision: 0, roundType: 0, _s: 0, _f: 0}) o[i] = n[i];\n o._d = n._d.slice();\n return;\n }\n o.precision = isNaN(p = Math.abs(p)) ? BigNumber.defaultPrecision : p;\n o.roundType = isNaN(r = Math.abs(r)) ? BigNumber.defaultRoundType : r;\n o._s = (n += \"\").charAt(0) == \"-\";\n o._f = ((n = n.replace(/[^\\d.]/g, \"\").split(\".\", 2))[0] = n[0].replace(/^0+/, \"\") || \"0\").length;\n for(i = (n = o._d = (n.join(\"\") || \"0\").split(\"\")).length; i; n[--i] = +n[i]);\n o.round();\n};\nwith({$: BigNumber, o: BigNumber.prototype}){\n $.ROUND_HALF_EVEN = ($.ROUND_HALF_DOWN = ($.ROUND_HALF_UP = ($.ROUND_FLOOR = ($.ROUND_CEIL = ($.ROUND_DOWN = ($.ROUND_UP = 0) + 1) + 1) + 1) + 1) + 1) + 1;\n $.defaultPrecision = 40;\n $.defaultRoundType = $.ROUND_HALF_UP;\n o.add = function(n){\n if(this._s != (n = new BigNumber(n))._s)\n return n._s ^= 1, this.subtract(n);\n var o = new BigNumber(this), a = o._d, b = n._d, la = o._f,\n lb = n._f, n = Math.max(la, lb), i, r;\n la != lb && ((lb = la - lb) > 0 ? o._zeroes(b, lb, 1) : o._zeroes(a, -lb, 1));\n i = (la = a.length) == (lb = b.length) ? a.length : ((lb = la - lb) > 0 ? o._zeroes(b, lb) : o._zeroes(a, -lb)).length;\n for(r = 0; i; r = (a[--i] = a[i] + b[i] + r) / 10 >>> 0, a[i] %= 10);\n return r && ++n && a.unshift(r), o._f = n, o.round();\n };\n o.subtract = function(n){\n if(this._s != (n = new BigNumber(n))._s)\n return n._s ^= 1, this.add(n);\n var o = new BigNumber(this), c = o.abs().compare(n.abs()) + 1, a = c ? o : n, b = c ? n : o, la = a._f, lb = b._f, d = la, i, j;\n a = a._d, b = b._d, la != lb && ((lb = la - lb) > 0 ? o._zeroes(b, lb, 1) : o._zeroes(a, -lb, 1));\n for(i = (la = a.length) == (lb = b.length) ? a.length : ((lb = la - lb) > 0 ? o._zeroes(b, lb) : o._zeroes(a, -lb)).length; i;){\n if(a[--i] < b[i]){\n for(j = i; j && !a[--j]; a[j] = 9);\n --a[j], a[i] += 10;\n }\n b[i] = a[i] - b[i];\n }\n return c || (o._s ^= 1), o._f = d, o._d = b, o.round();\n };\n o.multiply = function(n){\n var o = new BigNumber(this), r = o._d.length >= (n = new BigNumber(n))._d.length, a = (r ? o : n)._d,\n b = (r ? n : o)._d, la = a.length, lb = b.length, x = new BigNumber, i, j, s;\n for(i = lb; i; r && s.unshift(r), x.set(x.add(new BigNumber(s.join(\"\")))))\n for(s = (new Array(lb - --i)).join(\"0\").split(\"\"), r = 0, j = la; j; r += a[--j] * b[i], s.unshift(r % 10), r = (r / 10) >>> 0);\n return o._s = o._s != n._s, o._f = ((r = la + lb - o._f - n._f) >= (j = (o._d = x._d).length) ? this._zeroes(o._d, r - j + 1, 1).length : j) - r, o.round();\n };\n o.divide = function(n){\n if((n = new BigNumber(n)) == \"0\")\n throw new Error(\"Division by 0\");\n else if(this == \"0\")\n return new BigNumber;\n var o = new BigNumber(this), a = o._d, b = n._d, la = a.length - o._f,\n lb = b.length - n._f, r = new BigNumber, i = 0, j, s, l, f = 1, c = 0, e = 0;\n r._s = o._s != n._s, r.precision = Math.max(o.precision, n.precision),\n r._f = +r._d.pop(), la != lb && o._zeroes(la > lb ? b : a, Math.abs(la - lb));\n n._f = b.length, b = n, b._s = false, b = b.round();\n for(n = new BigNumber; a[0] == \"0\"; a.shift());\n out:\n do{\n for(l = c = 0, n == \"0\" && (n._d = [], n._f = 0); i < a.length && n.compare(b) == -1; ++i){\n (l = i + 1 == a.length, (!f && ++c > 1 || (e = l && n == \"0\" && a[i] == \"0\")))\n && (r._f == r._d.length && ++r._f, r._d.push(0));\n (a[i] == \"0\" && n == \"0\") || (n._d.push(a[i]), ++n._f);\n if(e)\n break out;\n if((l && n.compare(b) == -1 && (r._f == r._d.length && ++r._f, 1)) || (l = 0))\n while(r._d.push(0), n._d.push(0), ++n._f, n.compare(b) == -1);\n }\n if(f = 0, n.compare(b) == -1 && !(l = 0))\n while(l ? r._d.push(0) : l = 1, n._d.push(0), ++n._f, n.compare(b) == -1);\n for(s = new BigNumber, j = 0; n.compare(y = s.add(b)) + 1 && ++j; s.set(y));\n n.set(n.subtract(s)), !l && r._f == r._d.length && ++r._f, r._d.push(j);\n }\n while((i < a.length || n != \"0\") && (r._d.length - r._f) <= r.precision);\n return r.round();\n };\n o.mod = function(n){\n return this.subtract(this.divide(n).intPart().multiply(n));\n };\n o.pow = function(n){\n var o = new BigNumber(this), i;\n if((n = (new BigNumber(n)).intPart()) == 0) return o.set(1);\n for(i = Math.abs(n); --i; o.set(o.multiply(this)));\n return n < 0 ? o.set((new BigNumber(1)).divide(o)) : o;\n };\n o.set = function(n){\n return this.constructor(n), this;\n };\n o.compare = function(n){\n var a = this, la = this._f, b = new BigNumber(n), lb = b._f, r = [-1, 1], i, l;\n if(a._s != b._s)\n return a._s ? -1 : 1;\n if(la != lb)\n return r[(la > lb) ^ a._s];\n for(la = (a = a._d).length, lb = (b = b._d).length, i = -1, l = Math.min(la, lb); ++i < l;)\n if(a[i] != b[i])\n return r[(a[i] > b[i]) ^ a._s];\n return la != lb ? r[(la > lb) ^ a._s] : 0;\n };\n o.negate = function(){\n var n = new BigNumber(this); return n._s ^= 1, n;\n };\n o.abs = function(){\n var n = new BigNumber(this); return n._s = 0, n;\n };\n o.intPart = function(){\n return new BigNumber((this._s ? \"-\" : \"\") + (this._d.slice(0, this._f).join(\"\") || \"0\"));\n };\n o.valueOf = o.toString = function(){\n var o = this;\n return (o._s ? \"-\" : \"\") + (o._d.slice(0, o._f).join(\"\") || \"0\") + (o._f != o._d.length ? \".\" + o._d.slice(o._f).join(\"\") : \"\");\n };\n o._zeroes = function(n, l, t){\n var s = [\"push\", \"unshift\"][t || 0];\n for(++l; --l; n[s](0));\n return n;\n };\n o.round = function(){\n if(\"_rounding\" in this) return this;\n var $ = BigNumber, r = this.roundType, b = this._d, d, p, n, x;\n for(this._rounding = true; this._f > 1 && !b[0]; --this._f, b.shift());\n for(d = this._f, p = this.precision + d, n = b[p]; b.length > d && !b[b.length -1]; b.pop());\n x = (this._s ? \"-\" : \"\") + (p - d ? \"0.\" + this._zeroes([], p - d - 1).join(\"\") : \"\") + 1;\n if(b.length > p){\n n && (r == $.DOWN ? false : r == $.UP ? true : r == $.CEIL ? !this._s\n : r == $.FLOOR ? this._s : r == $.HALF_UP ? n >= 5 : r == $.HALF_DOWN ? n > 5\n : r == $.HALF_EVEN ? n >= 5 && b[p - 1] & 1 : false) && this.add(x);\n b.splice(p, b.length - p);\n }\n return delete this._rounding, this;\n };\n}\n\nvar isNegZero=function(x) {return x===0 && Math.atan2(x,x) < 0}\n\nvar _mod = {\n __getattr__ : function(attr){\n var res = this[attr]\n if(res===undefined){$raise('AttributeError','module math has no attribute '+attr)}\n return res\n },\n acos: function(x) {return float(Math.acos(float_check(x)))},\n acosh: function(x) { \n if (_b_.$isinf(x)) return float('inf');\n var y = float_check(x);\n return float(Math.log(y + Math.sqrt(y*y-1)));\n },\n asin: function(x) {return float(Math.asin(float_check(x)))},\n asinh: function(x) {\n if (_b_.$isninf(x)) return float('-inf');\n if (_b_.$isinf(x)) return float('inf');\n var y = float_check(x);\n return float(Math.log(y + Math.sqrt(y*y+1)))\n },\n atan: function(x) {\n if (_b_.$isninf(x)) return float(-Math.PI/2);\n if (_b_.$isinf(x)) return float(Math.PI/2);\n return float(Math.atan(float_check(x)))},\n atan2: function(y,x) {\n return float(Math.atan2(float_check(y),float_check(x)))\n },\n atanh: function(x) { \n var y=float_check(x);\n if (y==0) return 0;\n return float(0.5 * Math.log((1/y+1)/(1/y-1)));\n },\n ceil: function(x) {\n try{return getattr(x,'__ceil__')()}catch(err){}\n\n if (_b_.$isninf(x)) return float('-inf')\n if (_b_.$isinf(x)) return float('inf')\n if (isNaN(x)) return float('nan')\n\n var y=float_check(x);\n if (!isNaN(parseFloat(y)) && isFinite(y)) return int(Math.ceil(y));\n \n $raise('ValueError', 'object is not a number and does not contain __ceil__')\n },\n copysign: function(x,y) {\n var x1=Math.abs(float_check(x))\n var y1=float_check(y)\n var sign=y1?y1<0?-1:1:1\n if (isNegZero(y1)) sign=-1 // probably need to work on adding a check for -0\n return float(x1 * sign)\n },\n cos : function(x){return float(Math.cos(float_check(x)))},\n cosh: function(x){\n if (_b_.$isinf(x)) return float('inf')\n var y = float_check(x)\n if (Math.cosh !== undefined) return float(Math.cosh(y))\n return float((Math.pow(Math.E,y) + Math.pow(Math.E,-y))/2)\n },\n degrees: function(x){return float(float_check(x) * 180/Math.PI)},\n e: float(Math.E),\n erf: function(x) {\n // inspired from \n // http://stackoverflow.com/questions/457408/is-there-an-easily-available-implementation-of-erf-for-python\n var y =float_check(x);\n var t = 1.0 / (1.0 + 0.5 * Math.abs(y))\n var ans = 1 - t * Math.exp( -y*y - 1.26551223 +\n t * ( 1.00002368 +\n t * ( 0.37409196 + \n t * ( 0.09678418 + \n t * (-0.18628806 + \n t * ( 0.27886807 + \n t * (-1.13520398 + \n t * ( 1.48851587 + \n t * (-0.82215223 + \n t * 0.17087277)))))))))\n if (y >= 0.0) return ans\n\n return -ans\n },\n\n erfc: function(x) {\n // inspired from \n // http://stackoverflow.com/questions/457408/is-there-an-easily-available-implementation-of-erf-for-python\n var y = float_check(x);\n var t = 1.0 / (1.0 + 0.5 * Math.abs(y))\n var ans = 1 - t * Math.exp( -y*y - 1.26551223 +\n t * ( 1.00002368 +\n t * ( 0.37409196 + \n t * ( 0.09678418 + \n t * (-0.18628806 + \n t * ( 0.27886807 + \n t * (-1.13520398 + \n t * ( 1.48851587 + \n t * (-0.82215223 + \n t * 0.17087277)))))))))\n if (y >= 0.0) return 1-ans\n return 1+ans\n },\n exp: function(x){\n if (_b_.$isninf(x)) {return float(0)}\n if (_b_.$isinf(x)) {return float('inf')}\n var _r=Math.exp(float_check(x))\n if (_b_.$isinf(_r)) {throw OverflowError(\"math range error\")}\n return float(_r)\n },\n expm1: function(x){return float(Math.exp(float_check(x))-1)},\n //fabs: function(x){ return x>0?float(x):float(-x)},\n fabs: function(x){return _b_.$fabs(x)}, //located in py_float.js\n factorial: function(x) {\n //using code from http://stackoverflow.com/questions/3959211/fast-factorial-function-in-javascript\n var y=float_check(x);\n var r=1\n for (var i=2; i<=y; i++){r*=i}\n return r\n },\n floor:function(x){return Math.floor(float_check(x))},\n fmod:function(x,y){return float(float_check(x)%float_check(y))},\n frexp: function(x){var _l=_b_.$frexp(x);return _b_.tuple([float(_l[0]), _l[1]])}, // located in py_float.js\n fsum:function(x){\n /* Translation into Javascript of the function msum in an Active\n State Cookbook recipe : https://code.activestate.com/recipes/393090/\n by Raymond Hettinger\n */\n var partials = [],\n res = new Number(), \n _it = _b_.iter(x)\n while(true){\n try{\n var x = _b_.next(_it),\n i = 0\n for(var j=0, len=partials.length;j<len;j++){\n var y = partials[j]\n if(Math.abs(x) < Math.abs(y)){\n var z = x\n x = y\n y = z\n }\n var hi = x + y,\n lo = y - (hi - x)\n if(lo){\n partials[i] = lo\n i++\n }\n x = hi\n }\n partials = partials.slice(0, i).concat([x])\n }catch(err){\n if(_b_.isinstance(err, _b_.StopIteration)){break}\n throw err\n }\n }\n var res = new Number(0)\n for(var i=0; i<partials.length;i++){res += new Number(partials[i])}\n return new Number(res)\n },\n gamma: function(x){\n //using code from http://stackoverflow.com/questions/3959211/fast-factorial-function-in-javascript\n // Lanczos Approximation of the Gamma Function\n // As described in Numerical Recipes in C (2nd ed. Cambridge University Press, 1992)\n var y=float_check(x);\n var z = y + 1;\n var d1 = Math.sqrt(2 * Math.PI) / z;\n\n var d2 = 1.000000000190015;\n d2 += 76.18009172947146 / (z+1);\n d2 += -86.50532032941677 / (z+2);\n d2 += 24.01409824083091 / (z+3); \n d2 += -1.231739572450155 / (z+4); \n d2 += 1.208650973866179E-3 / (z+5);\n d2 += -5.395239384953E-6 / (z+6);\n\n return d1 * d2 * Math.pow(z+5.5,z+0.5) * Math.exp(-(z+5.5));\n },\n hypot: function(x,y){\n if (_b_.$isinf(x) || _b_.$isinf(y)) return float('inf')\n var x1=float_check(x);\n var y1=float_check(y);\n return float(Math.sqrt(x1*x1 + y1*y1))},\n inf: float('inf'),\n isclose:function(){\n var $ns = $B.args(\"isclose\",\n 4,\n {a:null,b:null,rel_tol:null,abs_tol:null},\n ['a', 'b', 'rel_tol', 'abs_tol'],\n arguments,\n {rel_tol:1e-09, abs_tol:0.0}, \n null, \n null)\n var a = $ns['a'];\n var b = $ns['b'];\n var rel_tol = $ns['rel_tol'];\n var abs_tol = $ns['abs_tol'];\n if (rel_tol < 0.0 || abs_tol < 0.0) throw ValueError('tolerances must be non-negative')\n if (a == b){return True}\n if (_b_.$isinf(a) || _b_.$isinf(b)){return false}\n var diff = _b_.$fabs(b - a);\n var result = ((diff <= _b_.$fabs(rel_tol * b)) || (diff <= _b_.$fabs(rel_tol * a))) || (diff <= _b_.$fabs(abs_tol));\n return result},\n isfinite:function(x) {return isFinite(float_check(x))},\n isinf:function(x) {return _b_.$isinf(float_check(x))},\n isnan:function(x) {return isNaN(float_check(x))},\n ldexp:function(x,i) {return _b_.$ldexp(x,i)}, //located in py_float.js\n lgamma:function(x) {\n // see gamma function for sources\n var y=float_check(x);\n var z = y + 1;\n var d1 = Math.sqrt(2 * Math.PI) / z;\n\n var d2 = 1.000000000190015;\n d2 += 76.18009172947146 / (z+1);\n d2 += -86.50532032941677 / (z+2);\n d2 += 24.01409824083091 / (z+3); \n d2 += -1.231739572450155 / (z+4); \n d2 += 1.208650973866179E-3 / (z+5);\n d2 += -5.395239384953E-6 / (z+6);\n\n return float(Math.log(Math.abs(d1 * d2 * Math.pow(z+5.5,z+0.5) * Math.exp(-(z+5.5)))));\n },\n log: function(x, base) {\n var x1=float_check(x);\n if (base === undefined) return float(Math.log(x1));\n return float(Math.log(x1)/Math.log(float_check(base)));\n },\n log1p: function(x) {return float(Math.log(1.0 + float_check(x)))},\n log2: function(x) {\n if (isNaN(x)) return float('nan')\n if (_b_.$isninf(x)) throw ValueError('')\n var x1=float_check(x)\n if (x1 < 0.0) throw ValueError('')\n //if (isLargeNumber(x1)) x1=new BigNumber(x1) \n return float(Math.log(x1)/Math.LN2)\n },\n log10: function(x) {return float(Math.log(float_check(x))/Math.LN10)},\n modf:function(x) {\n if (_b_.$isninf(x)) return _b_.tuple([0.0, float('-inf')])\n if (_b_.$isinf(x)) return _b_.tuple([0.0, float('inf')])\n if (isNaN(x)) return _b_.tuple([float('nan'), float('nan')])\n\n var x1=float_check(x);\n if (x1 > 0) {\n var i=float(x1-Math.floor(x1))\n return _b_.tuple([i, float(x1-i)])\n }\n\n var x2=Math.ceil(x1)\n var i=float(x1-x2)\n return _b_.tuple([i, float(x2)])\n },\n nan: float('nan'),\n pi : float(Math.PI),\n pow: function(x,y) {\n var x1=float_check(x)\n var y1=float_check(y)\n if (y1 == 0) return float(1) \n if (x1 == 0 && y1 < 0) throw _b_.ValueError('')\n\n if(isNaN(y1)) {if(x1==1) return float(1) \n return float('nan')\n }\n if (x1 == 0) return float(0)\n\n if(_b_.$isninf(y)) {if(x1==1||x1==-1) {return float(1)}\n if(x1 < 1 && x1 > -1) return float('inf') \n return float(0)\n }\n if(_b_.$isinf(y)) {if(x1==1||x1==-1) {return float(1)} \n if(x1 < 1 && x1 > -1) return float(0) \n return float('inf')}\n\n if(isNaN(x1)) return float('nan')\n if(_b_.$isninf(x)) {\n if (y1 > 0 && isOdd(y1)) return float('-inf')\n if (y1 > 0) return float('inf') // this is even or a float\n if (y1 < 0) return float(0)\n return float(1)\n }\n\n if(_b_.$isinf(x)) { \n if (y1 > 0) return float('inf')\n if (y1 < 0) return float(0)\n return float(1)\n }\n\n var r\n if (isLargeNumber(x1) || isLargeNumber(y1)) {\n var x=new BigNumber(x1)\n var y=new BigNumber(y1)\n r=x.pow(y)\n } else {\n r=Math.pow(x1,y1)\n }\n\n if (isNaN(r)) return float('nan')\n if (_b_.$isninf(r)) return float('-inf')\n if (_b_.$isinf(r)) return float('inf')\n\n return r\n },\n radians: function(x){return float(float_check(x) * Math.PI/180)},\n sin : function(x){return float(Math.sin(float_check(x)))},\n sinh: function(x) { \n //if (_b_.$isinf(x)) return float('inf');\n var y = float_check(x)\n if (Math.sinh !== undefined) { return float(Math.sinh(y))}\n return float((Math.pow(Math.E,y) - Math.pow(Math.E,-y))/2)\n },\n sqrt : function(x){\n var y = float_check(x)\n if (y < 0) { throw ValueError(\"math range error\")}\n if (_b_.$isinf(y)) return float('inf')\n var _r=Math.sqrt(y)\n if (_b_.$isinf(_r)) {throw OverflowError(\"math range error\")}\n return float(_r)\n },\n tan: function(x) {\n var y = float_check(x)\n return float(Math.tan(y))\n },\n tanh: function(x) {\n var y = float_check(x)\n if (Math.tanh !== undefined) return float(Math.tanh(y))\n return float((Math.pow(Math.E,y) - Math.pow(Math.E,-y))/\n (Math.pow(Math.E,y) + Math.pow(Math.E,-y))) \n },\n trunc: function(x) {\n try{return getattr(x,'__trunc__')()}catch(err){}\n var x1=float_check(x);\n if (!isNaN(parseFloat(x1)) && isFinite(x1)) {\n if (Math.trunc !== undefined) { return int(Math.trunc(x1))}\n if (x1 > 0) {return int(Math.floor(x1))}\n return int(Math.ceil(x1)) // x1 < 0\n }\n $raise('ValueError', 'object is not a number and does not contain __trunc__')\n }\n}\n\nfor(var $attr in _mod){\n if(typeof _mod[$attr]==='function'){\n _mod[$attr].__repr__=(function(func){\n return function(){return '<built-in function '+func+'>'}})($attr)\n _mod[$attr].__str__=(function(func){\n return function(){return '<built-in function '+func+'>'}})($attr)\n }\n}\n\nreturn _mod\n\n})(__BRYTHON__)\n"], "modulefinder": [".js", "var $module=(function($B){\n\nvar _b_=$B.builtins\nvar _mod = {}\n\n$ModuleFinderDict = {__class__:$B.$type,__name__:'ModuleFinder'}\n$ModuleFinderDict.__mro__ = [_b_.object.$dict]\n\n$ModuleFinderDict.run_script = function(self, pathname){\n // pathname is the url of a Python script\n var py_src = _b_.$open(pathname).read()\n // transform into internal Brython tree structure\n var root = $B.py2js(py_src)\n // walk the tree to find occurences of imports\n function walk(node){\n var modules = []\n var ctx = node.context\n if(ctx && ctx.type=='node'){ctx = ctx.tree[0]}\n\n if(ctx && ctx.type==\"import\"){\n for(var i=0, _len_i = ctx.tree.length; i < _len_i;i++){\n if(modules.indexOf(ctx.tree[i].name)==-1){\n modules.push(ctx.tree[i].name)\n }\n }\n }else if(ctx && ctx.type==\"from\"){\n if(modules.indexOf(ctx.module)==-1){\n modules.push(ctx.module)\n }\n }\n \n for(var i=0, _len_i = node.children.length; i < _len_i;i++){\n mods = walk(node.children[i])\n for(var j=0, _len_j = mods.length; j < _len_j;j++){\n if(modules.indexOf(mods[j])==-1){modules.push(mods[j])}\n }\n }\n return modules\n }\n self.modules = walk(root)\n}\n\n_mod.ModuleFinder = function(){return {__class__:$ModuleFinderDict}\n}\n_mod.ModuleFinder.$dict = $ModuleFinderDict\n_mod.ModuleFinder.__class__ = $B.$factory\n$ModuleFinderDict.$factory = _mod.ModuleFinder\n\nreturn _mod\n})(__BRYTHON__)\n"], "random": [".js", "// Javascript implementation of the random module\n// Based on Ian Bicking's implementation of the Mersenne twister\n\nvar $module = (function($B){\n\n_b_ = $B.builtins\n\nvar VERSION = 3\n\n// Code copied from https://github.com/ianb/whrandom/blob/master/mersenne.js\n// by Ian Bicking\n\n// this program is a JavaScript version of Mersenne Twister,\n// a straight conversion from the original program, mt19937ar.c,\n// translated by y. okada on july 17, 2006.\n// and modified a little at july 20, 2006, but there are not any substantial differences.\n// modularized by Ian Bicking, March 25, 2013 (found original version at http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/VERSIONS/JAVASCRIPT/java-script.html)\n// in this program, procedure descriptions and comments of original source code were not removed.\n// lines commented with //c// were originally descriptions of c procedure. and a few following lines are appropriate JavaScript descriptions.\n// lines commented with /* and */ are original comments.\n// lines commented with // are additional comments in this JavaScript version.\n/*\n A C-program for MT19937, with initialization improved 2002/1/26.\n Coded by Takuji Nishimura and Makoto Matsumoto.\n\n Before using, initialize the state by using init_genrand(seed)\n or init_by_array(init_key, key_length).\n\n Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,\n All rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions\n are met:\n\n 1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n\n 2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\n 3. The names of its contributors may not be used to endorse or promote\n products derived from this software without specific prior written\n permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n Any feedback is very welcome.\n http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html\n email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)\n*/\n\nfunction RandomStream(seed) {\n\n /*jshint bitwise:false */\n /* Period parameters */\n //c//#define N 624\n //c//#define M 397\n //c//#define MATRIX_A 0x9908b0dfUL /* constant vector a */\n //c//#define UPPER_MASK 0x80000000UL /* most significant w-r bits */\n //c//#define LOWER_MASK 0x7fffffffUL /* least significant r bits */\n var N = 624;\n var M = 397;\n var MATRIX_A = 0x9908b0df; /* constant vector a */\n var UPPER_MASK = 0x80000000; /* most significant w-r bits */\n var LOWER_MASK = 0x7fffffff; /* least significant r bits */\n //c//static unsigned long mt[N]; /* the array for the state vector */\n //c//static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */\n var mt = new Array(N); /* the array for the state vector */\n var mti = N+1; /* mti==N+1 means mt[N] is not initialized */\n\n function unsigned32 (n1) // returns a 32-bits unsiged integer from an operand to which applied a bit operator.\n {\n return n1 < 0 ? (n1 ^ UPPER_MASK) + UPPER_MASK : n1;\n }\n\n function subtraction32 (n1, n2) // emulates lowerflow of a c 32-bits unsiged integer variable, instead of the operator -. these both arguments must be non-negative integers expressible using unsigned 32 bits.\n {\n return n1 < n2 ? unsigned32((0x100000000 - (n2 - n1)) & 0xffffffff) : n1 - n2;\n }\n\n function addition32 (n1, n2) // emulates overflow of a c 32-bits unsiged integer variable, instead of the operator +. these both arguments must be non-negative integers expressible using unsigned 32 bits.\n {\n return unsigned32((n1 + n2) & 0xffffffff);\n }\n\n function multiplication32 (n1, n2) // emulates overflow of a c 32-bits unsiged integer variable, instead of the operator *. these both arguments must be non-negative integers expressible using unsigned 32 bits.\n {\n var sum = 0;\n for (var i = 0; i < 32; ++i){\n if ((n1 >>> i) & 0x1){\n sum = addition32(sum, unsigned32(n2 << i));\n }\n }\n return sum;\n }\n\n /* initializes mt[N] with a seed */\n //c//void init_genrand(unsigned long s)\n function init_genrand(s) {\n //c//mt[0]= s & 0xffffffff;\n mt[0]= unsigned32(s & 0xffffffff);\n for (mti=1; mti<N; mti++) {\n mt[mti] =\n //c//(1812433253 * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);\n addition32(multiplication32(1812433253, unsigned32(mt[mti-1] ^ (mt[mti-1] >>> 30))), mti);\n /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */\n /* In the previous versions, MSBs of the seed affect */\n /* only MSBs of the array mt[]. */\n /* 2002/01/09 modified by Makoto Matsumoto */\n //c//mt[mti] &= 0xffffffff;\n mt[mti] = unsigned32(mt[mti] & 0xffffffff);\n /* for >32 bit machines */\n }\n }\n\n /* initialize by an array with array-length */\n /* init_key is the array for initializing keys */\n /* key_length is its length */\n /* slight change for C++, 2004/2/26 */\n //c//void init_by_array(unsigned long init_key[], int key_length)\n function init_by_array(init_key, key_length) {\n //c//int i, j, k;\n var i, j, k;\n init_genrand(19650218);\n i=1; j=0;\n k = (N>key_length ? N : key_length);\n for (; k; k--) {\n //c//mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525))\n //c// + init_key[j] + j; /* non linear */\n mt[i] = addition32(addition32(unsigned32(mt[i] ^ multiplication32(unsigned32(mt[i-1] ^ (mt[i-1] >>> 30)), 1664525)), init_key[j]), j);\n mt[i] =\n //c//mt[i] &= 0xffffffff; /* for WORDSIZE > 32 machines */\n unsigned32(mt[i] & 0xffffffff);\n i++; j++;\n if (i>=N) { mt[0] = mt[N-1]; i=1; }\n if (j>=key_length) {\n j=0;\n }\n }\n for (k=N-1; k; k--) {\n //c//mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941))\n //c//- i; /* non linear */\n mt[i] = subtraction32(unsigned32((mt[i]) ^ multiplication32(unsigned32(mt[i-1] ^ (mt[i-1] >>> 30)), 1566083941)), i);\n //c//mt[i] &= 0xffffffff; /* for WORDSIZE > 32 machines */\n mt[i] = unsigned32(mt[i] & 0xffffffff);\n i++;\n if (i>=N) { mt[0] = mt[N-1]; i=1; }\n }\n mt[0] = 0x80000000; /* MSB is 1; assuring non-zero initial array */\n }\n\n /* generates a random number on [0,0xffffffff]-interval */\n //c//unsigned long genrand_int32(void)\n function genrand_int32() {\n //c//unsigned long y;\n //c//static unsigned long mag01[2]={0x0UL, MATRIX_A};\n var y;\n var mag01 = [0x0, MATRIX_A];\n /* mag01[x] = x * MATRIX_A for x=0,1 */\n\n if (mti >= N) { /* generate N words at one time */\n //c//int kk;\n var kk;\n\n if (mti == N+1) { /* if init_genrand() has not been called, */\n init_genrand(Date.now()); /* a default initial seed is used */\n }\n\n for (kk=0;kk<N-M;kk++) {\n //c//y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);\n //c//mt[kk] = mt[kk+M] ^ (y >> 1) ^ mag01[y & 0x1];\n y = unsigned32((mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK));\n mt[kk] = unsigned32(mt[kk+M] ^ (y >>> 1) ^ mag01[y & 0x1]);\n }\n for (;kk<N-1;kk++) {\n //c//y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);\n //c//mt[kk] = mt[kk+(M-N)] ^ (y >> 1) ^ mag01[y & 0x1];\n y = unsigned32((mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK));\n mt[kk] = unsigned32(mt[kk+(M-N)] ^ (y >>> 1) ^ mag01[y & 0x1]);\n }\n //c//y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK);\n //c//mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1];\n y = unsigned32((mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK));\n mt[N-1] = unsigned32(mt[M-1] ^ (y >>> 1) ^ mag01[y & 0x1]);\n mti = 0;\n }\n\n y = mt[mti++];\n\n /* Tempering */\n //c//y ^= (y >> 11);\n //c//y ^= (y << 7) & 0x9d2c5680;\n //c//y ^= (y << 15) & 0xefc60000;\n //c//y ^= (y >> 18);\n y = unsigned32(y ^ (y >>> 11));\n y = unsigned32(y ^ ((y << 7) & 0x9d2c5680));\n y = unsigned32(y ^ ((y << 15) & 0xefc60000));\n y = unsigned32(y ^ (y >>> 18));\n\n return y;\n }\n\n /* generates a random number on [0,0x7fffffff]-interval */\n //c//long genrand_int31(void)\n function genrand_int31() {\n //c//return (genrand_int32()>>1);\n return (genrand_int32()>>>1);\n }\n\n /* generates a random number on [0,1]-real-interval */\n //c//double genrand_real1(void)\n function genrand_real1() {\n return genrand_int32()*(1.0/4294967295.0);\n /* divided by 2^32-1 */\n }\n\n /* generates a random number on [0,1)-real-interval */\n //c//double genrand_real2(void)\n function genrand_real2() {\n return genrand_int32()*(1.0/4294967296.0);\n /* divided by 2^32 */\n }\n\n /* generates a random number on (0,1)-real-interval */\n //c//double genrand_real3(void)\n function genrand_real3() {\n return ((genrand_int32()) + 0.5)*(1.0/4294967296.0);\n /* divided by 2^32 */\n }\n\n /* generates a random number on [0,1) with 53-bit resolution*/\n //c//double genrand_res53(void)\n function genrand_res53() {\n //c//unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6;\n var a=genrand_int32()>>>5, b=genrand_int32()>>>6;\n return (a*67108864.0+b)*(1.0/9007199254740992.0);\n }\n /* These real versions are due to Isaku Wada, 2002/01/09 added */\n\n var random = genrand_res53;\n\n random.seed = function (seed) {\n if (! seed) {\n seed = Date.now();\n }\n if (typeof seed != \"number\") {\n seed = parseInt(seed, 10);\n }\n if ((seed !== 0 && ! seed) || isNaN(seed)) {\n throw \"Bad seed\";\n }\n init_genrand(seed);\n };\n\n random.seed(seed);\n\n random.int31 = genrand_int31;\n random.real1 = genrand_real1;\n random.real2 = genrand_real2;\n random.real3 = genrand_real3;\n random.res53 = genrand_res53;\n \n // Added for compatibility with Python\n random.getstate = function(){return [VERSION, mt, mti]}\n \n random.setstate = function(state){\n mt = state[1]\n mti = state[2]\n }\n\n return random;\n\n}\n\nfunction _Random(){\n var _random = RandomStream()\n \n _b_ = $B.builtins\n \n var NV_MAGICCONST = 4 * Math.exp(-0.5)/Math.sqrt(2),\n gauss_next = null\n \n function _randbelow(x){\n return Math.floor(x*_random())\n }\n \n function _urandom(n){\n /*\n urandom(n) -> str\n Return n random bytes suitable for cryptographic use.\n */\n \n var randbytes= []\n for(i=0;i<n;i++){randbytes.push(parseInt(_random()*256))}\n return _b_.bytes(randbytes)\n }\n \n var res = {\n // magic constants\n NV_MAGICCONST: 1.71552776992141,\n TWOPI: 6.28318530718,\n LOG4: 1.38629436111989,\n SG_MAGICCONST: 2.50407739677627,\n\n choice: function(seq){\n var $ = $B.args('choice', 1,\n {seq:null},['seq'],arguments, {}, null, null),\n seq = $.seq\n var len, rank\n if(Array.isArray(seq)){len = seq.length}\n else{len = _b_.getattr(seq,'__len__')()}\n if(len==0){throw _b_.IndexError(\"Cannot choose from an empty sequence\")}\n rank = parseInt(_random()*len)\n if(Array.isArray(seq)){return seq[rank]}\n else{return _b_.getattr(seq,'__getitem__')(rank)}\n },\n \n expovariate: function(lambd){\n /*\n Exponential distribution.\n \n lambd is 1.0 divided by the desired mean. It should be\n nonzero. (The parameter would be called \"lambda\", but that is\n a reserved word in Python.) Returned values range from 0 to\n positive infinity if lambd is positive, and from negative\n infinity to 0 if lambd is negative.\n \n */\n // lambd: rate lambd = 1/mean\n // ('lambda' is a Python reserved word)\n \n // we use 1-random() instead of random() to preclude the\n // possibility of taking the log of zero.\n return -Math.log(1.0 - _random())/lambd\n },\n \n gammavariate: function(alpha, beta){\n /* Gamma distribution. Not the gamma function!\n \n Conditions on the parameters are alpha > 0 and beta > 0.\n \n The probability distribution function is:\n \n x ** (alpha - 1) * math.exp(-x / beta)\n pdf(x) = --------------------------------------\n math.gamma(alpha) * beta ** alpha\n \n */\n \n // alpha > 0, beta > 0, mean is alpha*beta, variance is alpha*beta**2\n \n // Warning: a few older sources define the gamma distribution in terms\n // of alpha > -1.0\n \n var $ = $B.args('gammavariate', 2,\n {alpha:null, beta:null}, ['alpha', 'beta'],\n arguments, {}, null, null),\n alpha = $.alpha,\n beta = $.beta,\n LOG4 = Math.log(4),\n SG_MAGICCONST = 1.0 + Math.log(4.5)\n \n if(alpha <= 0.0 || beta <= 0.0){\n throw _b_.ValueError('gammavariate: alpha and beta must be > 0.0')\n }\n \n if(alpha > 1.0){\n \n // Uses R.C.H. Cheng, \"The generation of Gamma\n // variables with non-integral shape parameters\",\n // Applied Statistics, (1977), 26, No. 1, p71-74\n \n var ainv = Math.sqrt(2.0 * alpha - 1.0),\n bbb = alpha - LOG4,\n ccc = alpha + ainv\n \n while(true){\n var u1 = _random()\n if(!((1e-7 < u1) && (u1 < .9999999))){\n continue\n }\n var u2 = 1.0 - _random(),\n v = Math.log(u1/(1.0-u1))/ainv,\n x = alpha*Math.exp(v),\n z = u1*u1*u2,\n r = bbb+ccc*v-x\n if((r + SG_MAGICCONST - 4.5*z >= 0.0) || r >= Math.log(z)){\n return x * beta\n }\n }\n }else if(alpha == 1.0){\n // expovariate(1)\n var u = _random()\n while(u <= 1e-7){u = _random()}\n return -Math.log(u) * beta\n }else{\n // alpha is between 0 and 1 (exclusive)\n \n // Uses ALGORITHM GS of Statistical Computing - Kennedy & Gentle\n \n while(true){\n var u = _random(),\n b = (Math.E + alpha)/Math.E,\n p = b*u,\n x\n if(p <= 1.0){x = Math.pow(p, (1.0/alpha))}\n else{x = -Math.log((b-p)/alpha)}\n var u1 = _random()\n if(p > 1.0){\n if(u1 <= Math.pow(x, alpha - 1.0)){\n break\n }\n }else if(u1 <= Math.exp(-x)){\n break\n }\n }\n return x * beta\n }\n },\n \n gauss:function(){\n \n /* Gaussian distribution.\n \n mu is the mean, and sigma is the standard deviation. This is\n slightly faster than the normalvariate() function.\n \n Not thread-safe without a lock around calls.\n \n # When x and y are two variables from [0, 1), uniformly\n # distributed, then\n #\n # cos(2*pi*x)*sqrt(-2*log(1-y))\n # sin(2*pi*x)*sqrt(-2*log(1-y))\n #\n # are two *independent* variables with normal distribution\n # (mu = 0, sigma = 1).\n # (Lambert Meertens)\n # (corrected version; bug discovered by Mike Miller, fixed by LM)\n \n # Multithreading note: When two threads call this function\n # simultaneously, it is possible that they will receive the\n # same return value. The window is very small though. To\n # avoid this, you have to use a lock around all calls. (I\n # didn't want to slow this down in the serial case by using a\n # lock here.)\n */\n \n var $ = $B.args('gauss', 2, {mu:null, sigma:null},\n ['mu', 'sigma'], arguments, {}, null, null),\n mu = $.mu,\n sigma = $.sigma\n \n var z = gauss_next\n gauss_next = null\n if(z===null){\n var x2pi = _random() * Math.PI * 2,\n g2rad = Math.sqrt(-2.0 * Math.log(1.0 - _random())),\n z = Math.cos(x2pi) * g2rad\n gauss_next = Math.sin(x2pi) * g2rad\n }\n return mu + z*sigma\n },\n \n getrandbits: function(k){\n var $ = $B.args('getrandbits', 1,\n {k:null},['k'],arguments, {}, null, null),\n k = $B.$GetInt($.k)\n // getrandbits(k) -> x. Generates a long int with k random bits.\n if(k <= 0){\n throw _b_.ValueError('number of bits must be greater than zero')\n }\n if(k != _b_.int(k)){\n throw _b_.TypeError('number of bits should be an integer')\n }\n var numbytes = (k + 7), // bits / 8 and rounded up\n x = _b_.int.$dict.from_bytes(_urandom(numbytes), 'big')\n return _b_.getattr(x, '__rshift__')(\n _b_.getattr(numbytes*8,'__sub__')(k))\n },\n \n getstate: function(){\n // Return internal state; can be passed to setstate() later.\n var $ = $B.args('getstate', 0, {}, [], arguments, {}, null, null)\n return _random.getstate()\n },\n \n normalvariate: function(mu, sigma){\n /*\n Normal distribution.\n \n mu is the mean, and sigma is the standard deviation.\n \n */\n \n // mu = mean, sigma = standard deviation\n \n // Uses Kinderman and Monahan method. Reference: Kinderman,\n // A.J. and Monahan, J.F., \"Computer generation of random\n // variables using the ratio of uniform deviates\", ACM Trans\n // Math Software, 3, (1977), pp257-260.\n \n var $=$B.args('normalvariate', 2,\n {mu:null, sigma:null}, ['mu', 'sigma'],\n arguments, {}, null, null),\n mu = $.mu,\n sigma = $.sigma\n \n while(true){\n var u1 = _random(),\n u2 = 1.0 - _random(),\n z = NV_MAGICCONST*(u1-0.5)/u2,\n zz = z*z/4.0\n if(zz <= -Math.log(u2)){break}\n }\n return mu + z*sigma\n },\n \n paretovariate: function(){\n /* Pareto distribution. alpha is the shape parameter.*/\n // Jain, pg. 495\n \n var $ = $B.args('paretovariate', 1, {alpha:null}, ['alpha'],\n arguments, {}, null, null)\n \n var u = 1 - _random()\n return 1 / Math.pow(u,1/$.alpha)\n },\n \n randint: function(a, b){\n var $ = $B.args('randint', 2,\n {a:null, b:null},\n ['a', 'b'],\n arguments, {}, null, null)\n return parseInt(_random()*($.b-$.a+1)+$.a)\n },\n \n random: _random,\n \n randrange: function(){\n var $ = $B.args('randrange', 3,\n {x:null, stop:null, step:null},\n ['x', 'stop', 'step'],\n arguments, {stop:null, step:null}, null, null)\n if($.stop===null){\n var start = 0, stop = $.x, step = 1\n }else{\n var start = $.x, stop = $.stop, \n step = $.step===null ? 1 : $.step\n if(step==0){throw _b_.ValueError('step cannot be 0')}\n }\n if(typeof start=='number' && typeof stop == 'number' &&\n typeof step=='number'){\n return start+step*Math.floor(_random()*Math.floor((stop-start)/step))\n }else{\n var d = _b_.getattr(stop,'__sub__')(start)\n d = _b_.getattr(d, '__floordiv__')(step)\n // Force d to be a LongInt\n d = $B.LongInt(d)\n // d is a long integer with n digits ; to choose a random number\n // between 0 and d the most simple is to take a random digit\n // at each position, except the first one\n var s = d.value, _len = s.length,\n res = Math.floor(_random()*(parseInt(s.charAt(0))+(_len==1 ? 0 : 1)))+''\n var same_start = res.charAt(0)==s.charAt(0)\n for(var i=1;i<_len;i++){\n if(same_start){\n // If it's the last digit, don't allow stop as valid\n if(i==_len-1){\n res += Math.floor(_random()*parseInt(s.charAt(i)))+''\n }else{\n res += Math.floor(_random()*(parseInt(s.charAt(i))+1))+''\n same_start = res.charAt(i)==s.charAt(i)\n }\n }else{\n res += Math.floor(_random()*10)+''\n }\n }\n var offset = {__class__:$B.LongInt.$dict, value: res, \n pos: true}\n d = _b_.getattr(step, '__mul__')(offset)\n d = _b_.getattr(start, '__add__')(d)\n return _b_.int(d)\n }\n },\n \n sample: function(){\n /*\n Chooses k unique random elements from a population sequence or set.\n \n Returns a new list containing elements from the population while\n leaving the original population unchanged. The resulting list is\n in selection order so that all sub-slices will also be valid random\n samples. This allows raffle winners (the sample) to be partitioned\n into grand prize and second place winners (the subslices).\n \n Members of the population need not be hashable or unique. If the\n population contains repeats, then each occurrence is a possible\n selection in the sample.\n \n To choose a sample in a range of integers, use range as an argument.\n This is especially fast and space efficient for sampling from a\n large population: sample(range(10000000), 60)\n \n # Sampling without replacement entails tracking either potential\n # selections (the pool) in a list or previous selections in a set.\n \n # When the number of selections is small compared to the\n # population, then tracking selections is efficient, requiring\n # only a small set and an occasional reselection. For\n # a larger number of selections, the pool tracking method is\n # preferred since the list takes less space than the\n # set and it doesn't suffer from frequent reselections.'\n \n */\n var $ = $B.args('sample',2,{population:null,k:null},\n ['population','k'], arguments,{},null,null),\n population = $.population,\n k = $.k\n \n if(!_b_.hasattr(population, '__len__')){\n throw _b_.TypeError(\"Population must be a sequence or set. For dicts, use list(d).\")\n }\n var n = _b_.getattr(population, '__len__')()\n \n if(k<0 || k>n){\n throw _b_.ValueError(\"Sample larger than population\")\n }\n var result = [],\n setsize = 21 // size of a small set minus size of an empty list\n if(k > 5){\n setsize += Math.pow(4, Math.ceil(Math.log(k * 3, 4))) // table size for big sets\n }\n if(n <= setsize){\n // An n-length list is smaller than a k-length set\n if(Array.isArray(population)){\n var pool = population.slice()\n }else{var pool = _b_.list(population)}\n for(var i=0;i<k;i++){ //invariant: non-selected at [0,n-i)\n var j = _randbelow(n-i)\n result[i] = pool[j]\n pool[j] = pool[n-i-1] // move non-selected item into vacancy\n }\n }else{\n selected = {}\n for(var i=0;i<k;i++){\n var j = _randbelow(n)\n while(selected[j]!==undefined){\n j = _randbelow(n)\n }\n selected[j] = true\n result[i] = Array.isArray(population) ? population[j] :\n _b_.getattr(population, '__getitem__')(j)\n }\n }\n return result\n },\n \n seed: function(){\n /*\n Initialize internal state from hashable object.\n \n None or no argument seeds from current time or from an operating\n system specific randomness source if available.\n \n If *a* is an int, all bits are used.\n */\n var $=$B.args('seed',2,{a:null, version:null},['a', 'version'],\n arguments,{a:new Date(), version:2},null,null),\n a = $.a,\n version = $.version\n \n if(version==1){a = _b_.hash(a)}\n else if(version==2){\n if(_b_.isinstance(a, _b_.str)){\n a = _b_.int.$dict.from_bytes(_b_.bytes(a, 'utf-8'), 'big')\n }else if(_b_.isinstance(a, [_b_.bytes, _b_.bytearray])){\n a = _b_.int.$dict.from_bytes(a, 'big')\n }else if(!_b_.isinstance(a, _b_.int)){\n throw _b_.TypeError('wrong argument')\n }\n if(a.__class__===$B.LongInt.$dict){\n // In this implementation, seed() only accepts safe integers\n // Generate a random one from the underlying string value,\n // using an arbitrary seed (99) to always return the same\n // integer\n var numbers = a.value, res = '', pos\n _random.seed(99)\n for(var i=0;i<17;i++){\n pos = parseInt(_random()*numbers.length)\n res += numbers.charAt(pos)\n }\n a = parseInt(res)\n }\n }else{\n throw ValueError('version can only be 1 or 2')\n }\n \n _random.seed(a)\n gauss_next = null\n },\n \n setstate: function(state){\n // Restore internal state from object returned by getstate().\n var $ = $B.args('setstate', 1, {state:null}, ['state'], \n arguments, {}, null, null)\n var state = _random.getstate()\n if(!Array.isArray($.state)){\n throw _b_.TypeError('state must be a list, not '+\n $B.get_class($.state).__name__)\n }\n if($.state.length<state.length){\n throw _b_.ValueError(\"need more than \"+$.state.length+\n \" values to unpack\")\n }else if($.state.length>state.length){\n throw _b_.ValueError(\"too many values to unpack (expected \"+\n state.length+\")\")\n }\n if($.state[0]!=3){\n throw _b_.ValueError(\"ValueError: state with version \"+\n $.state[0]+\" passed to Random.setstate() of version 3\")\n }\n var second = _b_.list($.state[1])\n if(second.length!==state[1].length){\n throw _b_.ValueError('state vector is the wrong size')\n }\n for(var i=0;i<second.length;i++){\n if(typeof second[i] != 'number'){\n throw _b_.ValueError('state vector items must be integers')\n }\n }\n _random.setstate($.state)\n },\n \n shuffle: function(x, random){\n /*\n x, random=random.random -> shuffle list x in place; return None.\n \n Optional arg random is a 0-argument function returning a random\n float in [0.0, 1.0); by default, the standard random.random.\n */\n \n var $ = $B.args('shuffle',2,{x:null,random:null},\n ['x','random'],\n arguments,{random:null},null,null),\n x = $.x,\n random = $.random\n \n if(random===null){random=_random}\n \n if(Array.isArray(x)){\n for(var i=x.length-1;i>=0;i--){\n var j = Math.floor(random() * (i+1)),\n temp = x[j]\n x[j] = x[i]\n x[i] = temp\n }\n }else{\n var len = _b_.getattr(x, '__len__')(), temp,\n x_get = _b_.getattr(x, '__getitem__'),\n x_set = _b_.getattr(x, '__setitem__')\n \n for(i=len-1;i>=0;i--){\n var j = Math.floor(random() * (i+1)),\n temp = x_get(j)\n x_set(j, x_get(i))\n x_set(i, temp)\n }\n }\n },\n \n triangular: function(){\n /*\n Triangular distribution.\n \n Continuous distribution bounded by given lower and upper limits,\n and having a given mode value in-between.\n \n http://en.wikipedia.org/wiki/Triangular_distribution\n */\n var $=$B.args('triangular',3,\n {low:null, high:null, mode:null},\n ['low', 'high', 'mode'],\n arguments,{low:0, high:1, mode:null}, null, null),\n low = $.low,\n high = $.high,\n mode = $.mode\n \n var u = _random(),\n c = mode===null ? 0.5 : (mode - low) / (high - low)\n if(u > c){\n u = 1 - u\n c = 1 - c\n var temp = low\n low = high\n high = temp\n }\n return low + (high - low) * Math.pow(u * c, 0.5)\n },\n \n uniform: function(){\n var $ = $B.args('uniform',2,{a:null,b:null},['a','b'],\n arguments,{},null,null),\n a = $B.$GetInt($.a),\n b = $B.$GetInt($.b)\n \n return a + (b-a)*_random()\n },\n \n vonmisesvariate: function(mu, kappa){\n /* Circular data distribution.\n \n mu is the mean angle, expressed in radians between 0 and 2*pi, and\n kappa is the concentration parameter, which must be greater than or\n equal to zero. If kappa is equal to zero, this distribution reduces\n to a uniform random angle over the range 0 to 2*pi.\n \n */\n // mu: mean angle (in radians between 0 and 2*pi)\n // kappa: concentration parameter kappa (>= 0)\n // if kappa = 0 generate uniform random angle\n \n // Based upon an algorithm published in: Fisher, N.I.,\n // \"Statistical Analysis of Circular Data\", Cambridge\n // University Press, 1993.\n \n // Thanks to Magnus Kessler for a correction to the\n // implementation of step 4.\n \n var $=$B.args('vonmisesvariate', 2,\n {mu: null, kappa:null}, ['mu', 'kappa'],\n arguments, {}, null, null),\n mu = $.mu,\n kappa = $.kappa,\n TWOPI = 2*Math.PI\n \n if(kappa <= 1e-6){return TWOPI * _random()}\n \n var s = 0.5 / kappa,\n r = s + Math.sqrt(1.0 + s * s)\n \n while(true){\n var u1 = _random(),\n z = Math.cos(Math.PI * u1),\n d = z / (r + z),\n u2 = _random()\n if((u2 < 1.0 - d * d) || \n (u2 <= (1.0 - d) * Math.exp(d))){\n break\n }\n }\n var q = 1.0 / r,\n f = (q + z) / (1.0 + q * z),\n u3 = _random()\n if(u3 > 0.5){var theta = (mu + Math.acos(f)) % TWOPI}\n else{var theta = (mu - Math.acos(f)) % TWOPI}\n return theta\n },\n \n weibullvariate: function(){\n /*Weibull distribution.\n \n alpha is the scale parameter and beta is the shape parameter.\n \n */\n // Jain, pg. 499; bug fix courtesy Bill Arms\n \n var $ = $B.args('weibullvariate', 2, {alpha:null, beta:null},\n ['alpha', 'beta'], arguments, {}, null, null),\n alpha = $.alpha,\n beta = $.beta\n \n var u = 1 - _random()\n return alpha * Math.pow(-Math.log(u), 1/beta)\n },\n \n VERSION: VERSION\n }\n\n res.lognormvariate = function(){\n /*\n Log normal distribution.\n \n If you take the natural logarithm of this distribution, you'll get a\n normal distribution with mean mu and standard deviation sigma.\n mu can have any value, and sigma must be greater than zero.\n \n */\n \n return Math.exp(res.normalvariate.apply(null, arguments))\n }\n \n res.betavariate = function(){\n /* Beta distribution.\n \n Conditions on the parameters are alpha > 0 and beta > 0.\n Returned values range between 0 and 1.\n \n \n # This version due to Janne Sinkkonen, and matches all the std\n # texts (e.g., Knuth Vol 2 Ed 3 pg 134 \"the beta distribution\").\n */\n \n var $ = $B.args('betavariate', 2, {alpha:null, beta:null},\n ['alpha', 'beta'], arguments, {}, null, null),\n alpha = $.alpha,\n beta = $.beta\n \n var y = res.gammavariate(alpha, 1)\n if(y == 0){return _b_.float(0)}\n else{return y / (y + res.gammavariate(beta, 1))}\n }\n \n return res\n\n}\n\nfunction Random(){\n var obj = {__class__: Random.$dict}\n Random.$dict.__init__(obj)\n return obj\n}\nRandom.__class__ = $B.$factory\nRandom.$dict = {\n __class__: $B.$type,\n __name__: 'Random',\n $factory: Random,\n __init__: function(self){self.$r = _Random()},\n __getattribute__: function(self, attr){return self.$r[attr]}\n}\nRandom.$dict.__mro__ = [$B.builtins.object.$dict]\n\nvar $module = _Random()\n\n$module.Random = Random\n\n$module.SystemRandom = function(){\n var f = function(){return {__class__:f.$dict}}\n f.__class__ = $B.$factory\n f.$dict = {\n __class__: $B.$type,\n __name__: 'SystemRandom',\n $factory: f,\n __getattribute__: function(){\n throw $B.builtins.NotImplementedError()\n }\n }\n f.$dict.__mro__ = [$B.builtins.object.$dict]\n return f()\n}\n\nreturn $module\n\n})(__BRYTHON__)\n\n"], "_ajax": [".js", "// ajax\nvar $module = (function($B){\n\neval($B.InjectBuiltins())\nvar $N = $B.builtins.None\n\n\nfunction ajax1(){\n if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari\n var xmlhttp = new XMLHttpRequest();\n }else{// code for IE6, IE5\n var xmlhttp = new ActiveXObject(\"Microsoft.XMLHTTP\");\n }\n xmlhttp.onreadystatechange = function(){\n // here, \"this\" refers to xmlhttp\n var state = this.readyState\n var timer = this.$requestTimer\n if(state===0 && this.onuninitialized){this.onuninitialized()}\n else if(state===1 && this.onloading){this.onloading()}\n else if(state===2 && this.onloaded){this.onloaded()}\n else if(state===3 && this.oninteractive){this.oninteractive()}\n else if(state===4 && this.oncomplete){\n if(timer !== null){window.clearTimeout(timer)}\n this.oncomplete()\n }\n }\n return {\n __class__: ajax.$dict,\n js: xmlhttp,\n headers: {}\n }\n}\najax1.__class__ = $B.$factory\n\najax.__class__ = $B.$factory\n\nfunction ajax(){\n\n if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari\n var xmlhttp=new XMLHttpRequest();\n }else{// code for IE6, IE5\n var xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\");\n }\n xmlhttp.onreadystatechange = function(){\n // here, \"this\" refers to xmlhttp\n var state = this.readyState\n if(this.responseType == \"\" || this.responseType==\"text\"){\n res.js.text = this.responseText\n }\n var timer = this.$requestTimer\n if(state===0 && this.onuninitialized){this.onuninitialized(res)}\n else if(state===1 && this.onloading){this.onloading(res)}\n else if(state===2 && this.onloaded){this.onloaded(res)}\n else if(state===3 && this.oninteractive){this.oninteractive(res)}\n else if(state===4 && this.oncomplete){\n if(timer !== null){window.clearTimeout(timer)}\n this.oncomplete(res)\n }\n }\n var res = {\n __class__: ajax.$dict,\n js: xmlhttp,\n headers: {}\n }\n return res\n}\n\nvar add_to_res = function(res,key,val) {\n if (isinstance(val,list)) {\n for (j = 0; j < val.length; j++) {\n add_to_res(res,key,val[j])\n }\n } else if (val instanceof File || val instanceof Blob) {\n res.append(key,val)\n } else res.append(key,str(val))\n}\n\najax.$dict = {\n\n __class__:$B.$type,\n __name__:'ajax',\n $factory: ajax,\n\n __getattribute__ : function(self, attr){\n // Special case for send : accept dict as parameters\n if(attr=='send'){\n return function(params){\n return ajax.$dict.send(self, params)\n }\n }\n // Otherwise default to JSObject method\n return $B.JSObject.$dict.__getattribute__(self, attr)\n },\n\n __repr__ : function(self){return '<object Ajax>'},\n __str__ : function(self){return '<object Ajax>'},\n\n bind : function(self, evt, func){\n // req.bind(evt,func) is the same as req.onevt = func\n self.js['on'+evt] = function(){\n try{\n return func.apply(null, arguments)\n }catch(err){\n if(err.__class__!==undefined){\n var msg = _b_.getattr(err, 'info')+\n '\\n'+err.__class__.__name__\n if(err.args){msg += ': '+err.args[0]}\n try{getattr($B.stderr,\"write\")(msg)}\n catch(err){console.log(msg)}\n }else{\n try{getattr($B.stderr,\"write\")(err)}\n catch(err1){console.log(err)}\n }\n }\n }\n return $N\n },\n\n send : function(self,params){\n // params can be Python dictionary or string\n //self.js.onreadystatechange = function(ev){console.log(ev.target)}\n var res = ''\n if(!params){\n self.js.send();\n return $N;\n }else if(isinstance(params,str)){\n res = params\n }else if(isinstance(params,dict)){\n if(self.headers['content-type'] == 'multipart/form-data'){\n // The FormData object serializes the data in the 'multipart/form-data'\n // content-type so we may as well override that header if it was set\n // by the user.\n res = new FormData()\n var items = _b_.list(_b_.dict.$dict.items(params))\n for(var i=0, _len_i = items.length; i < _len_i;i++){\n add_to_res(res,str(items[i][0]),items[i][1])\n }\n }else{\n var items = _b_.list(_b_.dict.$dict.items(params))\n for(var i=0, _len_i = items.length; i < _len_i;i++){\n var key = encodeURIComponent(str(items[i][0]));\n if (isinstance(items[i][1],list)) {\n for (j = 0; j < items[i][1].length; j++) {\n res += key +'=' + encodeURIComponent(str(items[i][1][j])) + '&'\n }\n } else {\n res += key + '=' + encodeURIComponent(str(items[i][1])) + '&'\n }\n }\n res = res.substr(0,res.length-1)\n }\n }else{\n throw _b_.TypeError(\"send() argument must be string or dictionary, not '\"+str(params.__class__)+\"'\")\n }\n self.js.send(res)\n return $N\n },\n\n set_header : function(self,key,value){\n self.js.setRequestHeader(key,value)\n self.headers[key.toLowerCase()] = value.toLowerCase()\n },\n\n set_timeout : function(self,seconds,func){\n self.js.$requestTimer = setTimeout(\n function() {self.js.abort();func()},\n seconds*1000);\n }\n}\n\najax.$dict.__mro__ = [$B.JSObject.$dict, _b_.object.$dict]\n\n$B.set_func_names(ajax.$dict)\n\nreturn {ajax:ajax, ajax1:ajax1}\n\n})(__BRYTHON__)\n"], "_base64": [".js", "var $module=(function($B){\n\nvar _b_ = $B.builtins,\n _keyStr = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\"\n\nfunction make_alphabet(altchars){\n var alphabet = _keyStr\n if(altchars!==undefined && altchars!==_b_.None){\n // altchars is an instance of Python bytes\n var source = altchars.source\n alphabet = alphabet.substr(0,alphabet.length-3)+\n _b_.chr(source[0])+_b_.chr(source[1])+'='\n }\n return alphabet\n}\n\nvar Base64 = {\n error: function() { return 'binascii_error' },\n\n encode: function(bytes, altchars) {\n\n var input = bytes.source\n var output = \"\";\n var chr1, chr2, chr3, enc1, enc2, enc3, enc4;\n var i = 0;\n\n var alphabet = make_alphabet(altchars)\n\n while (i < input.length) {\n\n chr1 = input[i++];\n chr2 = input[i++];\n chr3 = input[i++];\n\n enc1 = chr1 >> 2;\n enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);\n enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);\n enc4 = chr3 & 63;\n\n if (isNaN(chr2)) {\n enc3 = enc4 = 64;\n } else if (isNaN(chr3)) {\n enc4 = 64;\n }\n\n output = output + alphabet.charAt(enc1) + \n alphabet.charAt(enc2) + \n alphabet.charAt(enc3) + \n alphabet.charAt(enc4);\n\n }\n return _b_.bytes(output, 'utf-8', 'strict');\n },\n\n\n decode: function(bytes, altchars, validate) {\n var output = [];\n var chr1, chr2, chr3;\n var enc1, enc2, enc3, enc4;\n \n var alphabet = make_alphabet(altchars)\n \n var input = bytes.source\n\n // If validate is set, check that all characters in input\n // are in the alphabet\n var _input = ''\n var padding = 0;\n for(var i=0, len=input.length;i<len;i++){\n var car = String.fromCharCode(input[i])\n var char_num = alphabet.indexOf(car)\n if(char_num==-1){\n if(validate){throw Base64.error(\"Non-base64 digit found: \"+car)}\n } else if(char_num==64 && i < input.length-2) {\n if(validate){throw Base64.error(\"Non-base64 digit found: \"+car)}\n } else if(char_num==64 && i >= input.length-2) {\n padding++;\n _input +=car;\n } else {\n _input +=car\n }\n }\n input = _input;\n if (_input.length == padding ) return _b_.bytes([]);\n if ( _input.length % 4 > 0) throw Base64.error(\"Incorrect padding\");\n\n var i = 0;\n while (i < input.length) {\n\n enc1 = alphabet.indexOf(input.charAt(i++));\n enc2 = alphabet.indexOf(input.charAt(i++));\n enc3 = alphabet.indexOf(input.charAt(i++));\n enc4 = alphabet.indexOf(input.charAt(i++));\n\n chr1 = (enc1 << 2) | (enc2 >> 4);\n chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);\n chr3 = ((enc3 & 3) << 6) | enc4;\n\n output.push(chr1);\n\n if (enc3 != 64) {\n output.push(chr2);\n }\n if (enc4 != 64) {\n output.push(chr3);\n }\n\n }\n // return Python bytes\n return _b_.bytes(output, 'utf-8', 'strict')\n\n },\n\n _utf8_encode: function(string) {\n string = string.replace(/\\r\\n/g, \"\\n\");\n var utftext = \"\";\n\n for (var n = 0; n < string.length; n++) {\n\n var c = string.charCodeAt(n);\n\n if (c < 128) {\n utftext += String.fromCharCode(c);\n }\n else if ((c > 127) && (c < 2048)) {\n utftext += String.fromCharCode((c >> 6) | 192);\n utftext += String.fromCharCode((c & 63) | 128);\n }\n else {\n utftext += String.fromCharCode((c >> 12) | 224);\n utftext += String.fromCharCode(((c >> 6) & 63) | 128);\n utftext += String.fromCharCode((c & 63) | 128);\n }\n\n }\n\n return utftext;\n },\n\n _utf8_decode: function(utftext) {\n var string = \"\";\n var i = 0;\n var c = c1 = c2 = 0;\n\n while (i < utftext.length) {\n\n c = utftext.charCodeAt(i);\n\n if (c < 128) {\n string += String.fromCharCode(c);\n i++;\n }\n else if ((c > 191) && (c < 224)) {\n c2 = utftext.charCodeAt(i + 1);\n string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));\n i += 2;\n }\n else {\n c2 = utftext.charCodeAt(i + 1);\n c3 = utftext.charCodeAt(i + 2);\n string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));\n i += 3;\n }\n\n }\n\n return string;\n }\n\n}\n\nreturn {Base64:Base64}\n}\n\n)(__BRYTHON__)"], "_jsre": [".js", "var $module=(function($B){\n\n var _b_ = $B.builtins\n var $s=[]\n for(var $b in _b_) $s.push('var ' + $b +'=_b_[\"'+$b+'\"]')\n eval($s.join(';'))\n\n var JSObject = $B.JSObject\n\n var obj = {__class__:$module,\n __str__: function(){return \"<module 're'>\"}\n }\n obj.A = obj.ASCII = 256\n obj.I = obj.IGNORECASE = 2 // 'i'\n obj.L = obj.LOCALE = 4\n obj.M = obj.MULTILINE = 8 // 'm'\n obj.S = obj.DOTALL = 16\n obj.U = obj.UNICODE = 32\n obj.X = obj.VERBOSE = 64\n obj._is_valid = function(pattern) {\n if ($B.$options.re=='pyre') return false //force use of python's re module\n if ($B.$options.re=='jsre') return true //force use of brythons re module\n // FIXME: Improve\n\n if (!isinstance(pattern, str)) {\n // this is probably a SRE_PATTERN, so return false, and let\n // python's re module handle this.\n return false\n }\n var is_valid = false;\n try {\n new RegExp(pattern);\n is_valid = true;\n }\n catch(e) {}\n if (!is_valid) return false //if js won't parse the pattern return false\n\n // using reference http://www.regular-expressions.info/\n // to compare python re and javascript regex libraries\n\n // look for things javascript does not support\n // check for name capturing group\n var mylist=['?P=', '?P<', '(?#', '(?<=', '(?<!', '(?(']\n for(var i=0, _len_i = mylist.length; i < _len_i; i++) {\n if (pattern.indexOf(mylist[i]) > -1) return false\n }\n\n var re_list=['\\{,\\d+\\}']\n for(var i=0, _len_i = re_list.length; i < _len_i; i++) {\n var _re=new RegExp(re_list[i])\n if (_re.test(pattern)) return false\n }\n\n // it looks like the pattern has passed all our tests so lets assume\n // javascript can handle this pattern.\n return true\n }\n var $SRE_PatternDict = {\n __class__:$B.$type,\n __name__:'SRE_Pattern'\n }\n $SRE_PatternDict.__mro__ = [object.$dict]\n $SRE_PatternDict.findall = function(self,string){\n return obj.findall(self.pattern,string,self.flags)\n }\n $SRE_PatternDict.finditer = function(self,string){\n return obj.finditer(self.pattern,string,self.flags)\n }\n $SRE_PatternDict.match = function(self,string){\n return obj.match(self.pattern,string,self.flags)\n }\n $SRE_PatternDict.search = function(self,string){\n return obj.search(self.pattern,string,self.flags)\n }\n function normflags(flags) {\n return ((flags & obj.I)? 'i' : '') + ((flags & obj.M)? 'm' : '');\n }\n obj.compile = function(pattern,flags){\n return {\n __class__:$SRE_PatternDict,\n pattern:pattern,\n flags:normflags(flags)\n }\n }\n obj.escape = function(string){\n // Escape all the characters in pattern except ASCII letters, numbers \n // and '_'. This is useful if you want to match an arbitrary literal \n // string that may have regular expression metacharacters in it.\n var res = ''\n var ok = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'\n for(var i=0, _len_i = string.length; i < _len_i;i++){\n if(ok.search(string.charAt(i))>-1){res += string.charAt(i)}\n }\n return res\n }\n obj.findall = function(pattern,string,flags){\n var $ns=$B.args('re.findall',2,\n {pattern:null, string:null}, ['pattern', 'string'],\n arguments,{},'args','kw') ,\n args = $ns['args'] ,\n _flags = 0;\n if(args.length>0){var flags=args[0]}\n else{var _flags = getattr($ns['kw'], 'get')('flags',0)}\n \n var flags = normflags();\n flags += 'gm'\n var jsp = new RegExp(pattern,flags) ,\n jsmatch = string.match(jsp);\n if(jsmatch===null){return []}\n return jsmatch\n }\n obj.finditer = function(pattern,string,flags){\n var $ns=$B.args('re.finditer',2,\n {pattern:null, sring:null}, ['pattern','string'],\n arguments,{},'args','kw'),\n args = $ns['args'],\n _flags = 0;\n if(args.length>0){var flags=args[0]}\n else{var _flags = getattr($ns['kw'], 'get')('flags',0)}\n \n var flags = normflags();\n flags += 'gm'\n var jsp = new RegExp(pattern,flags),\n jsmatch = string.match(jsp);\n if(jsmatch===null){return []}\n \n var _list=[]\n for (var j=0, _len_j = jsmatch.length; j < _len_j; j++) {\n var mo = {}\n mo._match=jsmatch[j]\n mo.group = function(){\n var res = []\n for(var i=0, _len_i = arguments.length; i < _len_i;i++){\n if(jsmatch[arguments[i]]===undefined){res.push(None)}\n else{res.push(jsmatch[arguments[i]])}\n }\n if(arguments.length===1){return res[0]}\n return tuple(res)\n }\n mo.groups = function(_default){\n if(_default===undefined){_default=None}\n var res = []\n for(var i=1, _len_i = jsmatch.length; i < _len_i;i++){\n if(jsmatch[i]===undefined){res.push(_default)}\n else{res.push(jsmatch[i])}\n }\n return tuple(res)\n }\n mo.start = function(){return mo._match.index}\n mo.end = function(){return mo._match.length-mo._match.index}\n mo.string = string\n _list.push(JSObject(mo))\n }\n return _list\n }\n obj.search = function(pattern,string){\n var $ns=$B.args('re.search', 2,\n {pattern:null, string:null},['pattern','string'],\n arguments,{},'args','kw')\n var args = $ns['args']\n if(args.length>0){var flags=args[0]}\n else{var flags = getattr($ns['kw'],'get')('flags','')}\n flags = normflags(flags);\n var jsp = new RegExp(pattern,flags)\n var jsmatch = string.match(jsp)\n if(jsmatch===null){return None}\n var mo = new Object()\n mo.group = function(){\n var res = []\n for(var i=0, _len_i = arguments.length; i < _len_i;i++){\n if(jsmatch[arguments[i]]===undefined){res.push(None)}\n else{res.push(jsmatch[arguments[i]])}\n }\n if(arguments.length===1){return res[0]}\n return tuple(res)\n }\n mo.groups = function(_default){\n if(_default===undefined){_default=None}\n var res = []\n for(var i=1, _len_i = jsmatch.length; i < _len_i;i++){\n if(jsmatch[i]===undefined){res.push(_default)}\n else{res.push(jsmatch[i])}\n }\n return tuple(res)\n }\n mo.start = function(){return jsmatch.index}\n mo.end = function(){return jsmatch.length-jsmatch.index}\n mo.string = string\n return JSObject(mo)\n }\n obj.sub = function(pattern,repl,string){\n var $ns=$B.args('re.search', 3,\n {pattern:null, repl:null, string:null}, \n ['pattern','repl','string'],\n arguments,{},'args','kw')\n for($var in $ns){eval(\"var \"+$var+\"=$ns[$var]\")}\n var args = $ns['args']\n var count = _b_.dict.$dict.get($ns['kw'],'count',0)\n var flags = _b_.dict.$dict.get($ns['kw'],'flags','')\n if(args.length>0){var count=args[0]}\n if(args.length>1){var flags=args[1]}\n flags = normflags(flags);\n if(typeof repl===\"string\"){\n // backreferences are \\1, \\2... in Python but $1,$2... in Javascript\n repl = repl.replace(/\\\\(\\d+)/g,'$$$1')\n }else if(typeof repl===\"function\"){\n // the argument passed to the Python function is the match object\n // the arguments passed to the Javascript function are :\n // - the matched substring\n // - the matched groups\n // - the offset of the matched substring inside the string\n // - the string being examined\n var $repl1 = function(){\n var mo = Object()\n mo.string = arguments[arguments.length-1]\n var start = arguments[arguments.length-2]\n var end = start + arguments[0].length\n mo.start = function(){return start}\n mo.end = function(){return end}\n groups = []\n for(var i=1, _len_i = arguments.length-2; i < _len_i;i++){groups.push(arguments[i])}\n mo.groups = function(_default){\n if(_default===undefined){_default=None}\n var res = []\n for(var i=0, _len_i = groups.length; i < _len_i;i++){\n if(groups[i]===undefined){res.push(_default)}\n else{res.push(groups[i])}\n }\n return res\n }\n return repl(JSObject(mo))\n }\n }\n if(count==0){flags+='g'}\n var jsp = new RegExp(pattern,flags)\n if(typeof repl==='function'){return string.replace(jsp,$repl1)}\n else{return string.replace(jsp,repl)}\n }\n obj.match = (function(search_func){\n return function(){\n // match is like search but pattern must start with ^\n var pattern = arguments[0]\n if(pattern.charAt(0)!=='^'){pattern = '^'+pattern}\n var args = [pattern]\n for(var i=1, _len_i = arguments.length; i < _len_i;i++){args.push(arguments[i])}\n return search_func.apply(null,args)\n }\n })(obj.search)\n\n return obj\n}\n)(__BRYTHON__)\n"], "_multiprocessing": [".js", "// multiprocessing\nvar $module = (function($B){\n\nvar _b_ = $B.builtins\nvar $s=[]\nfor(var $b in _b_) $s.push('var ' + $b +'=_b_[\"'+$b+'\"]')\neval($s.join(';'))\n\n//for(var $py_builtin in _b_){eval(\"var \"+$py_builtin+\"=_b_[$py_builtin]\")}\n\nvar $ProcessDict = {__class__:$B.$type,__name__:'Process'}\n\nvar $convert_args=function(args) {\n var _list=[]\n for(var i=0, _len_i = args.length; i < _len_i; i++) {\n var _a=args[i]\n if(isinstance(_a, str)){_list.push(\"'\"+_a+\"'\")} else {_list.push(_a)} \n }\n\n return _list.join(',')\n}\n\n$ProcessDict.__mro__ = [_b_.object.$dict]\n\n$ProcessDict.__str__=$ProcessDict.toString=$ProcessDict.__repr__=function(self){\n return '<object Process>'\n}\n\n$ProcessDict.is_alive = function(self){return self.$alive}\n\n$ProcessDict.join = function(self, timeout){\n // need to block until process is complete\n // could probably use a addEventListener to execute all existing code\n // after this join statement\n\n self.$worker.addEventListener('message', function (e) {\n var data=e.data\n if (data.stdout != '') { // output stdout from process\n $B.stdout.write(data.stdout)\n }\n }, false);\n}\n\n$ProcessDict.run = function(self){\n //fix me\n}\n\n$ProcessDict.start = function(self){\n //var _args=[]\n //for(var i=0; i < self.$args.length; i++) {\n // var _a=self.$args[i]\n // if(isinstance(_a, str)){_args.push(\"'\"+_a+\"'\")} else {_args.push(_a)} \n //}\n\n self.$worker.postMessage({target: self.$target, \n args: $convert_args(self.$args),\n // kwargs: self.$kwargs\n })\n self.$worker.addEventListener('error', function(e) { throw e})\n self.$alive=true\n}\n\n$ProcessDict.terminate = function(self){\n self.$worker.terminate()\n self.$alive=false\n}\n\n// variables\n//name\n//daemon\n//pid\n//exitcode\n\nfunction Process(){\n //arguments group=None, target=None, name=None, args=(), kwargs=()\n\n var $ns=$B.args('Process',0,{},[],arguments,{},null,'kw')\n var kw=$ns['kw']\n\n var target=_b_.dict.$dict.get($ns['kw'],'target',None)\n var args=_b_.dict.$dict.get($ns['kw'],'args',tuple())\n\n var worker = new Worker('/src/web_workers/multiprocessing.js')\n\n var res = {\n __class__:$ProcessDict,\n $worker: worker,\n name: $ns['name'] || None,\n $target: target+'',\n $args: args,\n //$kwargs: $ns['kw'],\n $alive: false\n }\n return res\n}\n\nProcess.__class__ = $B.$factory\nProcess.$dict = $ProcessDict\n\n\nvar $PoolDict = {__class__:$B.$type,__name__:'Pool'}\n\n$PoolDict.__mro__ = [_b_.object.$dict]\n\n$PoolDict.__enter__ = function(self){}\n$PoolDict.__exit__ = function(self){}\n\n$PoolDict.__str__ = $PoolDict.toString = $PoolDict.__repr__=function(self){\n return '<object Pool>'\n}\n\n$PoolDict.map = function(){\n\n var $ns=$B.args('Pool.map', 3,\n {self:null, func:null, fargs:null}, ['self', 'func', 'fargs'],\n arguments,{},'args','kw')\n var func=$ns['func']\n var fargs=$ns['fargs']\n\n var _results=[]\n\n fargs=iter(fargs)\n\n var _pos=0\n console.log(self.$processes)\n _workers=[]\n for(var i=0; i < self.$processes; i++) {\n _workers[i] = new Worker('/src/web_workers/multiprocessing.js')\n var arg\n\n try{arg=getattr(fargs, '__next__')()} \n catch(err) {\n if (err.__name__ != 'StopIteration') throw err\n }\n console.log(arg)\n _workers[i].finished=false\n _workers[i].postMessage({target: func+'', pos: _pos,\n args: $convert_args([arg])})\n _pos++\n\n _workers[i].addEventListener('message', function(e) {\n _results[e.data.pos]=e.data.result\n if (_results.length == args.length) return _results\n\n try {\n arg=getattr(fargs, '__next__')()\n e.currentTarget.postMessage({target: func+'', pos: _pos,\n args: $convert_args([arg])})\n _pos++\n } catch(err) {\n if (err.__name__ != 'StopIteration') throw err\n this.finished=true\n }\n }, false);\n }\n}\n\n$PoolDict.apply_async = function(){\n\n var $ns=$B.$MakeArgs('apply_async', 3, \n {self:null, func:null, fargs:null}, ['self', 'func', 'fargs'],\n arguments,{},'args','kw')\n var func=$ns['func']\n var fargs=$ns['fargs']\n\n fargs=iter(fargs)\n\n async_result = {}\n async_result.get=function(timeout){\n console.log(results)\n console.log(fargs)\n return this.results}\n async_result.results=[]\n\n var _pos=0\n\n _workers=[]\n for(var i=0; i < self.$processes; i++) {\n _workers[i] = new Worker('/src/web_workers/multiprocessing.js')\n var arg\n\n try{arg=getattr(fargs, '__next__')()} \n catch(err) {\n if (err.__name__ != 'StopIteration') throw err\n }\n //console.log(arg)\n //_workers[i].finished=false\n _workers[i].postMessage({target: func+'', pos: _pos,\n args: $convert_args([arg])})\n _pos++\n\n _workers[i].addEventListener('message', function(e) {\n async_result.results[e.data.pos]=e.data.result\n //if (_results.length == args.length) return _results\n\n try {\n arg=getattr(fargs, '__next__')()\n e.currentTarget.postMessage({target: func+'', pos: _pos,\n args: $convert_args([arg])})\n _pos++\n } catch(err) {\n if (err.__name__ != 'StopIteration') throw err\n this.finished=true\n }\n }, false);\n }\n\n console.log(\"return\", async_result)\n return async_result\n}\n\nfunction Pool(){\n console.log(\"pool\")\n console.log(arguments)\n var $ns=$B.args('Pool',1,\n {processes:null},['processes'],arguments,{},'args','kw')\n //var kw=$ns['kw']\n\n var processes=$ns['processes']\n\n if (processes == None) {\n // look to see if we have stored cpu_count in local storage\n // maybe we should create a brython config file with settings,etc..??\n\n // if not there use a tool such as Core Estimator to calculate number of cpu's\n // http://eligrey.com/blog/post/cpu-core-estimation-with-javascript\n }\n\n console.log(processes)\n var res = {\n __class__:$PoolDict,\n $processes:processes\n }\n return res\n}\n\nPool.__class__ = $B.$factory\nPool.$dict = $PoolDict\n\nreturn {Process:Process, Pool:Pool}\n\n})(__BRYTHON__)\n"], "_posixsubprocess": [".js", "var $module=(function($B){\n\n return {\n cloexec_pipe: function() {} // fixme\n }\n})(__BRYTHON__)\n"], "_profile": [".js", "// Private interface to the profiling instrumentation implemented in py_utils.js.\n// Uses local a copy of the eval function from py_builtin_functions.js\n\nvar $module=(function($B) {\n eval($B.InjectBuiltins());\n return {\n brython:$B,\n data:$B.$profile_data,\n start:$B.$profile.start,\n stop:$B.$profile.stop,\n pause:$B.$profile.pause,\n status:$B.$profile.status,\n clear:$B.$profile.clear,\n elapsed:$B.$profile.elapsed,\n run:function(src,_globals,_locals,nruns) {\n var current_frame = $B.frames_stack[$B.frames_stack.length-1]\n if(current_frame!==undefined){\n var current_locals_id = current_frame[0].replace(/\\./,'_'),\n current_globals_id = current_frame[2].replace(/\\./,'_')\n }\n\n var is_exec = true, leave = false\n\n if(src.__class__===$B.$CodeObjectDict){\n src = src.source\n }\n\n // code will be run in a specific block\n var globals_id = '$profile_'+$B.UUID(),\n locals_id,\n parent_block_id\n if(_locals===_globals || _locals===undefined){\n locals_id = globals_id\n }else{\n locals_id = '$profile_'+$B.UUID()\n }\n // Initialise the object for block namespaces\n eval('var $locals_'+globals_id+' = {}\\nvar $locals_'+locals_id+' = {}')\n\n // Initialise block globals\n if(_globals===undefined){\n var gobj = current_frame[3],\n ex = ''\n for(var attr in current_frame[3]){\n ex == '$locals_'+globals_id+'[\"'+attr+\n '\"] = gobj[\"'+attr+'\"]';\n }\n parent_block_id = current_globals_id\n ex += 'var $locals_'+current_globals_id+'=gobj;'\n eval(ex)\n }else{\n $B.bound[globals_id] = {}\n var items = _b_.dict.$dict.items(_globals), item\n while(1){\n try{\n var item = _b_.next(items)\n eval('$locals_'+globals_id+'[\"'+item[0]+'\"] = item[1]')\n $B.bound[globals_id][item[0]]=true\n }catch(err){\n break\n }\n }\n parent_block_id = '__builtins__'\n }\n\n // Initialise block locals\n if(_locals===undefined){\n if(_globals!==undefined){\n eval('var $locals_'+locals_id+' = $locals_'+globals_id)\n }else{\n var lobj = current_frame[1],\n ex = ''\n for(var attr in current_frame[1]){\n ex += '$locals_'+locals_id+'[\"'+attr+\n '\"] = current_frame[1][\"'+attr+'\"];'\n }\n eval(ex)\n }\n }else{\n var items = _b_.dict.$dict.items(_locals), item\n while(1){\n try{\n var item = _b_.next(items)\n eval('$locals_'+locals_id+'[\"'+item[0]+'\"] = item[1]')\n }catch(err){\n break\n }\n }\n }\n //var nb_modules = Object.keys(__BRYTHON__.modules).length\n //console.log('before exec', nb_modules)\n\n var root = $B.py2js(src, globals_id, locals_id, parent_block_id),\n leave_frame = true\n\n try{\n\n var js = root.to_js()\n\n if ($B.async_enabled) js=$B.execution_object.source_conversion(js)\n\n var i,res,gns;\n for(i=0;i<nruns;i++) {\n res = eval(js)\n gns = eval('$locals_'+globals_id)\n }\n\n // Update _locals with the namespace after execution\n if(_locals!==undefined){\n var lns = eval('$locals_'+locals_id)\n var setitem = getattr(_locals,'__setitem__')\n for(var attr in lns){\n if(attr.charAt(0)=='$'){continue}\n setitem(attr, lns[attr])\n }\n }else{\n for(var attr in lns){current_frame[1][attr] = lns[attr]}\n }\n\n if(_globals!==undefined){\n // Update _globals with the namespace after execution\n var setitem = getattr(_globals,'__setitem__')\n for(var attr in gns){\n if(attr.charAt(0)=='$'){continue}\n setitem(attr, gns[attr])\n }\n }else{\n for(var attr in gns){\n current_frame[3][attr] = gns[attr]\n }\n }\n\n // fixme: some extra variables are bleeding into locals...\n /* This also causes issues for unittests */\n if(res===undefined) return _b_.None\n return res\n }catch(err){\n if(err.$py_error===undefined){throw $B.exception(err)}\n throw err\n }finally{\n\n delete __BRYTHON__.modules[globals_id]\n delete __BRYTHON__.modules[locals_id]\n $B.clear_ns(globals_id)\n $B.clear_ns(locals_id)\n\n if(!is_exec && leave_frame){\n // For eval(), the finally clause with \"leave_frame\" was removed\n // so we must execute it here\n $B.frames_stack.pop()\n }\n }\n }\n }\n})(__BRYTHON__)\n"], "_svg": [".js", "// creation of an HTML element\nvar $module = (function($B){\n\nvar _b_ = $B.builtins\nvar $TagSumDict = $B.$TagSum.$dict\n\nvar $s=[]\nfor(var $b in _b_) $s.push('var ' + $b +'=_b_[\"'+$b+'\"]')\neval($s.join(';'))\n\nvar $svgNS = \"http://www.w3.org/2000/svg\"\nvar $xlinkNS = \"http://www.w3.org/1999/xlink\"\n\nfunction makeTagDict(tagName){\n // return the dictionary for the class associated with tagName\n var dict = {__class__:$B.$type,\n __name__:tagName\n }\n\n dict.__getattribute__ = function(self, attr){\n if(self.elt.hasAttributeNS(null, attr)){\n return self.elt.getAttributeNS(null,attr)\n }\n if(dict[attr]!==undefined){\n return function(){\n var args = [self].concat(Array.prototype.slice.call(arguments))\n return dict[attr].apply(null, args)\n }\n }\n return $B.DOMNodeDict.__getattribute__(self, attr) \n }\n\n dict.__init__ = function(){\n var $ns=$B.args('__init__',1,{self:null},['self'],\n arguments,{},'args','kw')\n var self = $ns['self']\n var args = $ns['args']\n if(args.length==1){\n var first=args[0]\n if(isinstance(first,[str,int,float])){\n self.elt.appendChild(document.createTextNode(str(first)))\n } else if(first.__class__===$TagSumDict){\n for(var i=0, _len_i = first.children.length; i < _len_i;i++){\n self.elt.appendChild(first.children[i].elt)\n }\n } else { // argument is another DOMNode instance\n try{self.elt.appendChild(first.elt)}\n catch(err){throw ValueError('wrong element '+first)}\n }\n }\n\n // attributes\n var items = _b_.list(_b_.dict.$dict.items($ns['kw']))\n for(var i=0, _len_i = items.length; i < _len_i;i++){\n // keyword arguments\n var arg = items[i][0]\n var value = items[i][1]\n if(arg.toLowerCase().substr(0,2)===\"on\"){ \n // Event binding passed as argument \"onclick\", \"onfocus\"...\n // Better use method bind of DOMNode objects\n var js = '$B.DOMNodeDict.bind(self,\"'\n js += arg.toLowerCase().substr(2)\n eval(js+'\",function(){'+value+'})')\n }else if(arg.toLowerCase()==\"style\"){\n $B.DOMNodeDict.set_style(self,value)\n }else if(arg.toLowerCase().indexOf(\"href\") !== -1){ // xlink:href\n self.elt.setAttributeNS( \"http://www.w3.org/1999/xlink\",\"href\",value)\n } else {\n if(value!==false){\n // option.selected=false sets it to true :-)\n try{\n arg = arg.toLowerCase().replace('_','-')\n self.elt.setAttributeNS(null,arg,value)\n }catch(err){\n throw ValueError(\"can't set attribute \"+arg)\n }\n }\n }\n }\n }\n\n dict.__mro__ = [$B.DOMNodeDict,$B.builtins.object.$dict]\n\n dict.__new__ = function(cls){\n var res = $B.DOMNode(document.createElementNS($svgNS,tagName))\n res.__class__ = cls.$dict\n return res\n }\n \n dict.__setattr__ = function(self, key, value){\n if(self.elt.hasAttributeNS(null, key)){\n self.elt.setAttributeNS(null,key,value)\n }else{\n $B.DOMNodeDict.__setattr__(self, key, value)\n }\n }\n\n return dict\n}\n\n\n// the classes used for tag sums, $TagSum and $TagSumClass \n// are defined in py_dom.js\n\nfunction makeFactory(tagName){\n var factory = function(){\n var res = $B.DOMNode(document.createElementNS($svgNS,tagName))\n res.__class__ = dicts[tagName]\n // apply __init__\n var args = [res]\n for(var i=0, _len_i = arguments.length; i < _len_i;i++){args.push(arguments[i])}\n dicts[tagName].__init__.apply(null,args)\n return res\n }\n factory.__class__=$B.$factory\n factory.$dict = dicts[tagName]\n return factory\n}\n\n// SVG\nvar $svg_tags = ['a',\n'altGlyph',\n'altGlyphDef',\n'altGlyphItem',\n'animate',\n'animateColor',\n'animateMotion',\n'animateTransform',\n'circle',\n'clipPath',\n'color_profile', // instead of color-profile\n'cursor',\n'defs',\n'desc',\n'ellipse',\n'feBlend',\n'foreignObject', //patch to enable foreign objects\n'g',\n'image',\n'line',\n'linearGradient',\n'marker',\n'mask',\n'path',\n'pattern',\n'polygon',\n'polyline',\n'radialGradient',\n'rect',\n'set',\n'stop',\n'svg',\n'text',\n'tref',\n'tspan',\n'use']\n\n// create classes\nvar obj = new Object()\nvar dicts = {}\nfor(var i=0, _len_i = $svg_tags.length; i < _len_i;i++){\n var tag = $svg_tags[i]\n dicts[tag]=makeTagDict(tag)\n obj[tag] = makeFactory(tag)\n dicts[tag].$factory = obj[tag]\n}\nreturn obj\n})(__BRYTHON__)\n"], "_sys": [".js", "var $module=(function($B){\n var _b_=$B.builtins\n return {\n // Called \"Getframe\" because \"_getframe\" wouldn't be imported in \n // sys.py with \"from _sys import *\"\n Getframe : function(depth){\n return $B._frame($B.frames_stack, depth)\n },\n modules :\n {'__get__':function(){return $B.obj_dict($B.imported)},\n '__set__':function(self, obj, value){ throw _b_.TypeError(\"Read only property 'sys.modules'\") }\n },\n path: \n {'__get__':function(){return $B.path},\n '__set__':function(self, obj, value){ $B.path = value }\n },\n meta_path: \n {'__get__':function(){return $B.meta_path},\n '__set__':function(self, obj, value){ $B.meta_path = value }\n },\n path_hooks: \n {'__get__':function(){return $B.path_hooks},\n '__set__':function(self, obj, value){ $B.path_hooks = value }\n },\n path_importer_cache: \n {'__get__':function(){return _b_.dict($B.JSObject($B.path_importer_cache))},\n '__set__':function(self, obj, value){ throw _b_.TypeError(\"Read only property 'sys.path_importer_cache'\") }\n },\n stderr : {\n __get__:function(){return $B.stderr},\n __set__:function(self, obj, value){$B.stderr = value},\n write:function(data){_b_.getattr($B.stderr,\"write\")(data)}\n },\n stdout : {\n __get__:function(){return $B.stdout},\n __set__:function(self, obj, value){$B.stdout = value},\n write:function(data){_b_.getattr($B.stdout,\"write\")(data)}\n },\n stdin : $B.stdin\n }\n})(__BRYTHON__)\n"], "crypto_js.rollups.md5": [".js", "/*\nCryptoJS v3.1.2\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\nvar CryptoJS=CryptoJS||function(s,p){var m={},l=m.lib={},n=function(){},r=l.Base={extend:function(b){n.prototype=this;var h=new n;b&&h.mixIn(b);h.hasOwnProperty(\"init\")||(h.init=function(){h.$super.init.apply(this,arguments)});h.init.prototype=h;h.$super=this;return h},create:function(){var b=this.extend();b.init.apply(b,arguments);return b},init:function(){},mixIn:function(b){for(var h in b)b.hasOwnProperty(h)&&(this[h]=b[h]);b.hasOwnProperty(\"toString\")&&(this.toString=b.toString)},clone:function(){return this.init.prototype.extend(this)}},\nq=l.WordArray=r.extend({init:function(b,h){b=this.words=b||[];this.sigBytes=h!=p?h:4*b.length},toString:function(b){return(b||t).stringify(this)},concat:function(b){var h=this.words,a=b.words,j=this.sigBytes;b=b.sigBytes;this.clamp();if(j%4)for(var g=0;g<b;g++)h[j+g>>>2]|=(a[g>>>2]>>>24-8*(g%4)&255)<<24-8*((j+g)%4);else if(65535<a.length)for(g=0;g<b;g+=4)h[j+g>>>2]=a[g>>>2];else h.push.apply(h,a);this.sigBytes+=b;return this},clamp:function(){var b=this.words,h=this.sigBytes;b[h>>>2]&=4294967295<<\n32-8*(h%4);b.length=s.ceil(h/4)},clone:function(){var b=r.clone.call(this);b.words=this.words.slice(0);return b},random:function(b){for(var h=[],a=0;a<b;a+=4)h.push(4294967296*s.random()|0);return new q.init(h,b)}}),v=m.enc={},t=v.Hex={stringify:function(b){var a=b.words;b=b.sigBytes;for(var g=[],j=0;j<b;j++){var k=a[j>>>2]>>>24-8*(j%4)&255;g.push((k>>>4).toString(16));g.push((k&15).toString(16))}return g.join(\"\")},parse:function(b){for(var a=b.length,g=[],j=0;j<a;j+=2)g[j>>>3]|=parseInt(b.substr(j,\n2),16)<<24-4*(j%8);return new q.init(g,a/2)}},a=v.Latin1={stringify:function(b){var a=b.words;b=b.sigBytes;for(var g=[],j=0;j<b;j++)g.push(String.fromCharCode(a[j>>>2]>>>24-8*(j%4)&255));return g.join(\"\")},parse:function(b){for(var a=b.length,g=[],j=0;j<a;j++)g[j>>>2]|=(b.charCodeAt(j)&255)<<24-8*(j%4);return new q.init(g,a)}},u=v.Utf8={stringify:function(b){try{return decodeURIComponent(escape(a.stringify(b)))}catch(g){throw Error(\"Malformed UTF-8 data\");}},parse:function(b){return a.parse(unescape(encodeURIComponent(b)))}},\ng=l.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=new q.init;this._nDataBytes=0},_append:function(b){\"string\"==typeof b&&(b=u.parse(b));this._data.concat(b);this._nDataBytes+=b.sigBytes},_process:function(b){var a=this._data,g=a.words,j=a.sigBytes,k=this.blockSize,m=j/(4*k),m=b?s.ceil(m):s.max((m|0)-this._minBufferSize,0);b=m*k;j=s.min(4*b,j);if(b){for(var l=0;l<b;l+=k)this._doProcessBlock(g,l);l=g.splice(0,b);a.sigBytes-=j}return new q.init(l,j)},clone:function(){var b=r.clone.call(this);\nb._data=this._data.clone();return b},_minBufferSize:0});l.Hasher=g.extend({cfg:r.extend(),init:function(b){this.cfg=this.cfg.extend(b);this.reset()},reset:function(){g.reset.call(this);this._doReset()},update:function(b){this._append(b);this._process();return this},finalize:function(b){b&&this._append(b);return this._doFinalize()},blockSize:16,_createHelper:function(b){return function(a,g){return(new b.init(g)).finalize(a)}},_createHmacHelper:function(b){return function(a,g){return(new k.HMAC.init(b,\ng)).finalize(a)}}});var k=m.algo={};return m}(Math);\n(function(s){function p(a,k,b,h,l,j,m){a=a+(k&b|~k&h)+l+m;return(a<<j|a>>>32-j)+k}function m(a,k,b,h,l,j,m){a=a+(k&h|b&~h)+l+m;return(a<<j|a>>>32-j)+k}function l(a,k,b,h,l,j,m){a=a+(k^b^h)+l+m;return(a<<j|a>>>32-j)+k}function n(a,k,b,h,l,j,m){a=a+(b^(k|~h))+l+m;return(a<<j|a>>>32-j)+k}for(var r=CryptoJS,q=r.lib,v=q.WordArray,t=q.Hasher,q=r.algo,a=[],u=0;64>u;u++)a[u]=4294967296*s.abs(s.sin(u+1))|0;q=q.MD5=t.extend({_doReset:function(){this._hash=new v.init([1732584193,4023233417,2562383102,271733878])},\n_doProcessBlock:function(g,k){for(var b=0;16>b;b++){var h=k+b,w=g[h];g[h]=(w<<8|w>>>24)&16711935|(w<<24|w>>>8)&4278255360}var b=this._hash.words,h=g[k+0],w=g[k+1],j=g[k+2],q=g[k+3],r=g[k+4],s=g[k+5],t=g[k+6],u=g[k+7],v=g[k+8],x=g[k+9],y=g[k+10],z=g[k+11],A=g[k+12],B=g[k+13],C=g[k+14],D=g[k+15],c=b[0],d=b[1],e=b[2],f=b[3],c=p(c,d,e,f,h,7,a[0]),f=p(f,c,d,e,w,12,a[1]),e=p(e,f,c,d,j,17,a[2]),d=p(d,e,f,c,q,22,a[3]),c=p(c,d,e,f,r,7,a[4]),f=p(f,c,d,e,s,12,a[5]),e=p(e,f,c,d,t,17,a[6]),d=p(d,e,f,c,u,22,a[7]),\nc=p(c,d,e,f,v,7,a[8]),f=p(f,c,d,e,x,12,a[9]),e=p(e,f,c,d,y,17,a[10]),d=p(d,e,f,c,z,22,a[11]),c=p(c,d,e,f,A,7,a[12]),f=p(f,c,d,e,B,12,a[13]),e=p(e,f,c,d,C,17,a[14]),d=p(d,e,f,c,D,22,a[15]),c=m(c,d,e,f,w,5,a[16]),f=m(f,c,d,e,t,9,a[17]),e=m(e,f,c,d,z,14,a[18]),d=m(d,e,f,c,h,20,a[19]),c=m(c,d,e,f,s,5,a[20]),f=m(f,c,d,e,y,9,a[21]),e=m(e,f,c,d,D,14,a[22]),d=m(d,e,f,c,r,20,a[23]),c=m(c,d,e,f,x,5,a[24]),f=m(f,c,d,e,C,9,a[25]),e=m(e,f,c,d,q,14,a[26]),d=m(d,e,f,c,v,20,a[27]),c=m(c,d,e,f,B,5,a[28]),f=m(f,c,\nd,e,j,9,a[29]),e=m(e,f,c,d,u,14,a[30]),d=m(d,e,f,c,A,20,a[31]),c=l(c,d,e,f,s,4,a[32]),f=l(f,c,d,e,v,11,a[33]),e=l(e,f,c,d,z,16,a[34]),d=l(d,e,f,c,C,23,a[35]),c=l(c,d,e,f,w,4,a[36]),f=l(f,c,d,e,r,11,a[37]),e=l(e,f,c,d,u,16,a[38]),d=l(d,e,f,c,y,23,a[39]),c=l(c,d,e,f,B,4,a[40]),f=l(f,c,d,e,h,11,a[41]),e=l(e,f,c,d,q,16,a[42]),d=l(d,e,f,c,t,23,a[43]),c=l(c,d,e,f,x,4,a[44]),f=l(f,c,d,e,A,11,a[45]),e=l(e,f,c,d,D,16,a[46]),d=l(d,e,f,c,j,23,a[47]),c=n(c,d,e,f,h,6,a[48]),f=n(f,c,d,e,u,10,a[49]),e=n(e,f,c,d,\nC,15,a[50]),d=n(d,e,f,c,s,21,a[51]),c=n(c,d,e,f,A,6,a[52]),f=n(f,c,d,e,q,10,a[53]),e=n(e,f,c,d,y,15,a[54]),d=n(d,e,f,c,w,21,a[55]),c=n(c,d,e,f,v,6,a[56]),f=n(f,c,d,e,D,10,a[57]),e=n(e,f,c,d,t,15,a[58]),d=n(d,e,f,c,B,21,a[59]),c=n(c,d,e,f,r,6,a[60]),f=n(f,c,d,e,z,10,a[61]),e=n(e,f,c,d,j,15,a[62]),d=n(d,e,f,c,x,21,a[63]);b[0]=b[0]+c|0;b[1]=b[1]+d|0;b[2]=b[2]+e|0;b[3]=b[3]+f|0},_doFinalize:function(){var a=this._data,k=a.words,b=8*this._nDataBytes,h=8*a.sigBytes;k[h>>>5]|=128<<24-h%32;var l=s.floor(b/\n4294967296);k[(h+64>>>9<<4)+15]=(l<<8|l>>>24)&16711935|(l<<24|l>>>8)&4278255360;k[(h+64>>>9<<4)+14]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360;a.sigBytes=4*(k.length+1);this._process();a=this._hash;k=a.words;for(b=0;4>b;b++)h=k[b],k[b]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360;return a},clone:function(){var a=t.clone.call(this);a._hash=this._hash.clone();return a}});r.MD5=t._createHelper(q);r.HmacMD5=t._createHmacHelper(q)})(Math);\n"], "crypto_js.rollups.sha1": [".js", "/*\nCryptoJS v3.1.2\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\nvar CryptoJS=CryptoJS||function(e,m){var p={},j=p.lib={},l=function(){},f=j.Base={extend:function(a){l.prototype=this;var c=new l;a&&c.mixIn(a);c.hasOwnProperty(\"init\")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty(\"toString\")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},\nn=j.WordArray=f.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=m?c:4*a.length},toString:function(a){return(a||h).stringify(this)},concat:function(a){var c=this.words,q=a.words,d=this.sigBytes;a=a.sigBytes;this.clamp();if(d%4)for(var b=0;b<a;b++)c[d+b>>>2]|=(q[b>>>2]>>>24-8*(b%4)&255)<<24-8*((d+b)%4);else if(65535<q.length)for(b=0;b<a;b+=4)c[d+b>>>2]=q[b>>>2];else c.push.apply(c,q);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<<\n32-8*(c%4);a.length=e.ceil(c/4)},clone:function(){var a=f.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],b=0;b<a;b+=4)c.push(4294967296*e.random()|0);return new n.init(c,a)}}),b=p.enc={},h=b.Hex={stringify:function(a){var c=a.words;a=a.sigBytes;for(var b=[],d=0;d<a;d++){var f=c[d>>>2]>>>24-8*(d%4)&255;b.push((f>>>4).toString(16));b.push((f&15).toString(16))}return b.join(\"\")},parse:function(a){for(var c=a.length,b=[],d=0;d<c;d+=2)b[d>>>3]|=parseInt(a.substr(d,\n2),16)<<24-4*(d%8);return new n.init(b,c/2)}},g=b.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var b=[],d=0;d<a;d++)b.push(String.fromCharCode(c[d>>>2]>>>24-8*(d%4)&255));return b.join(\"\")},parse:function(a){for(var c=a.length,b=[],d=0;d<c;d++)b[d>>>2]|=(a.charCodeAt(d)&255)<<24-8*(d%4);return new n.init(b,c)}},r=b.Utf8={stringify:function(a){try{return decodeURIComponent(escape(g.stringify(a)))}catch(c){throw Error(\"Malformed UTF-8 data\");}},parse:function(a){return g.parse(unescape(encodeURIComponent(a)))}},\nk=j.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new n.init;this._nDataBytes=0},_append:function(a){\"string\"==typeof a&&(a=r.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,b=c.words,d=c.sigBytes,f=this.blockSize,h=d/(4*f),h=a?e.ceil(h):e.max((h|0)-this._minBufferSize,0);a=h*f;d=e.min(4*a,d);if(a){for(var g=0;g<a;g+=f)this._doProcessBlock(b,g);g=b.splice(0,a);c.sigBytes-=d}return new n.init(g,d)},clone:function(){var a=f.clone.call(this);\na._data=this._data.clone();return a},_minBufferSize:0});j.Hasher=k.extend({cfg:f.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){k.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(c,b){return(new a.init(b)).finalize(c)}},_createHmacHelper:function(a){return function(b,f){return(new s.HMAC.init(a,\nf)).finalize(b)}}});var s=p.algo={};return p}(Math);\n(function(){var e=CryptoJS,m=e.lib,p=m.WordArray,j=m.Hasher,l=[],m=e.algo.SHA1=j.extend({_doReset:function(){this._hash=new p.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(f,n){for(var b=this._hash.words,h=b[0],g=b[1],e=b[2],k=b[3],j=b[4],a=0;80>a;a++){if(16>a)l[a]=f[n+a]|0;else{var c=l[a-3]^l[a-8]^l[a-14]^l[a-16];l[a]=c<<1|c>>>31}c=(h<<5|h>>>27)+j+l[a];c=20>a?c+((g&e|~g&k)+1518500249):40>a?c+((g^e^k)+1859775393):60>a?c+((g&e|g&k|e&k)-1894007588):c+((g^e^\nk)-899497514);j=k;k=e;e=g<<30|g>>>2;g=h;h=c}b[0]=b[0]+h|0;b[1]=b[1]+g|0;b[2]=b[2]+e|0;b[3]=b[3]+k|0;b[4]=b[4]+j|0},_doFinalize:function(){var f=this._data,e=f.words,b=8*this._nDataBytes,h=8*f.sigBytes;e[h>>>5]|=128<<24-h%32;e[(h+64>>>9<<4)+14]=Math.floor(b/4294967296);e[(h+64>>>9<<4)+15]=b;f.sigBytes=4*e.length;this._process();return this._hash},clone:function(){var e=j.clone.call(this);e._hash=this._hash.clone();return e}});e.SHA1=j._createHelper(m);e.HmacSHA1=j._createHmacHelper(m)})();\n"], "crypto_js.rollups.sha224": [".js", "/*\nCryptoJS v3.1.2\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\nvar CryptoJS=CryptoJS||function(g,l){var f={},k=f.lib={},h=function(){},m=k.Base={extend:function(a){h.prototype=this;var c=new h;a&&c.mixIn(a);c.hasOwnProperty(\"init\")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty(\"toString\")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},\nq=k.WordArray=m.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=l?c:4*a.length},toString:function(a){return(a||s).stringify(this)},concat:function(a){var c=this.words,d=a.words,b=this.sigBytes;a=a.sigBytes;this.clamp();if(b%4)for(var e=0;e<a;e++)c[b+e>>>2]|=(d[e>>>2]>>>24-8*(e%4)&255)<<24-8*((b+e)%4);else if(65535<d.length)for(e=0;e<a;e+=4)c[b+e>>>2]=d[e>>>2];else c.push.apply(c,d);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<<\n32-8*(c%4);a.length=g.ceil(c/4)},clone:function(){var a=m.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],d=0;d<a;d+=4)c.push(4294967296*g.random()|0);return new q.init(c,a)}}),t=f.enc={},s=t.Hex={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b<a;b++){var e=c[b>>>2]>>>24-8*(b%4)&255;d.push((e>>>4).toString(16));d.push((e&15).toString(16))}return d.join(\"\")},parse:function(a){for(var c=a.length,d=[],b=0;b<c;b+=2)d[b>>>3]|=parseInt(a.substr(b,\n2),16)<<24-4*(b%8);return new q.init(d,c/2)}},n=t.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b<a;b++)d.push(String.fromCharCode(c[b>>>2]>>>24-8*(b%4)&255));return d.join(\"\")},parse:function(a){for(var c=a.length,d=[],b=0;b<c;b++)d[b>>>2]|=(a.charCodeAt(b)&255)<<24-8*(b%4);return new q.init(d,c)}},j=t.Utf8={stringify:function(a){try{return decodeURIComponent(escape(n.stringify(a)))}catch(c){throw Error(\"Malformed UTF-8 data\");}},parse:function(a){return n.parse(unescape(encodeURIComponent(a)))}},\nw=k.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new q.init;this._nDataBytes=0},_append:function(a){\"string\"==typeof a&&(a=j.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,d=c.words,b=c.sigBytes,e=this.blockSize,f=b/(4*e),f=a?g.ceil(f):g.max((f|0)-this._minBufferSize,0);a=f*e;b=g.min(4*a,b);if(a){for(var u=0;u<a;u+=e)this._doProcessBlock(d,u);u=d.splice(0,a);c.sigBytes-=b}return new q.init(u,b)},clone:function(){var a=m.clone.call(this);\na._data=this._data.clone();return a},_minBufferSize:0});k.Hasher=w.extend({cfg:m.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){w.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(c,d){return(new a.init(d)).finalize(c)}},_createHmacHelper:function(a){return function(c,d){return(new v.HMAC.init(a,\nd)).finalize(c)}}});var v=f.algo={};return f}(Math);\n(function(g){for(var l=CryptoJS,f=l.lib,k=f.WordArray,h=f.Hasher,f=l.algo,m=[],q=[],t=function(a){return 4294967296*(a-(a|0))|0},s=2,n=0;64>n;){var j;a:{j=s;for(var w=g.sqrt(j),v=2;v<=w;v++)if(!(j%v)){j=!1;break a}j=!0}j&&(8>n&&(m[n]=t(g.pow(s,0.5))),q[n]=t(g.pow(s,1/3)),n++);s++}var a=[],f=f.SHA256=h.extend({_doReset:function(){this._hash=new k.init(m.slice(0))},_doProcessBlock:function(c,d){for(var b=this._hash.words,e=b[0],f=b[1],g=b[2],k=b[3],h=b[4],l=b[5],m=b[6],n=b[7],p=0;64>p;p++){if(16>p)a[p]=\nc[d+p]|0;else{var j=a[p-15],r=a[p-2];a[p]=((j<<25|j>>>7)^(j<<14|j>>>18)^j>>>3)+a[p-7]+((r<<15|r>>>17)^(r<<13|r>>>19)^r>>>10)+a[p-16]}j=n+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&l^~h&m)+q[p]+a[p];r=((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&f^e&g^f&g);n=m;m=l;l=h;h=k+j|0;k=g;g=f;f=e;e=j+r|0}b[0]=b[0]+e|0;b[1]=b[1]+f|0;b[2]=b[2]+g|0;b[3]=b[3]+k|0;b[4]=b[4]+h|0;b[5]=b[5]+l|0;b[6]=b[6]+m|0;b[7]=b[7]+n|0},_doFinalize:function(){var a=this._data,d=a.words,b=8*this._nDataBytes,e=8*a.sigBytes;\nd[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=g.floor(b/4294967296);d[(e+64>>>9<<4)+15]=b;a.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var a=h.clone.call(this);a._hash=this._hash.clone();return a}});l.SHA256=h._createHelper(f);l.HmacSHA256=h._createHmacHelper(f)})(Math);\n(function(){var g=CryptoJS,l=g.lib.WordArray,f=g.algo,k=f.SHA256,f=f.SHA224=k.extend({_doReset:function(){this._hash=new l.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var f=k._doFinalize.call(this);f.sigBytes-=4;return f}});g.SHA224=k._createHelper(f);g.HmacSHA224=k._createHmacHelper(f)})();\n"], "crypto_js.rollups.sha3": [".js", "/*\nCryptoJS v3.1.2\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\nvar CryptoJS=CryptoJS||function(v,p){var d={},u=d.lib={},r=function(){},f=u.Base={extend:function(a){r.prototype=this;var b=new r;a&&b.mixIn(a);b.hasOwnProperty(\"init\")||(b.init=function(){b.$super.init.apply(this,arguments)});b.init.prototype=b;b.$super=this;return b},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty(\"toString\")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},\ns=u.WordArray=f.extend({init:function(a,b){a=this.words=a||[];this.sigBytes=b!=p?b:4*a.length},toString:function(a){return(a||y).stringify(this)},concat:function(a){var b=this.words,c=a.words,j=this.sigBytes;a=a.sigBytes;this.clamp();if(j%4)for(var n=0;n<a;n++)b[j+n>>>2]|=(c[n>>>2]>>>24-8*(n%4)&255)<<24-8*((j+n)%4);else if(65535<c.length)for(n=0;n<a;n+=4)b[j+n>>>2]=c[n>>>2];else b.push.apply(b,c);this.sigBytes+=a;return this},clamp:function(){var a=this.words,b=this.sigBytes;a[b>>>2]&=4294967295<<\n32-8*(b%4);a.length=v.ceil(b/4)},clone:function(){var a=f.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var b=[],c=0;c<a;c+=4)b.push(4294967296*v.random()|0);return new s.init(b,a)}}),x=d.enc={},y=x.Hex={stringify:function(a){var b=a.words;a=a.sigBytes;for(var c=[],j=0;j<a;j++){var n=b[j>>>2]>>>24-8*(j%4)&255;c.push((n>>>4).toString(16));c.push((n&15).toString(16))}return c.join(\"\")},parse:function(a){for(var b=a.length,c=[],j=0;j<b;j+=2)c[j>>>3]|=parseInt(a.substr(j,\n2),16)<<24-4*(j%8);return new s.init(c,b/2)}},e=x.Latin1={stringify:function(a){var b=a.words;a=a.sigBytes;for(var c=[],j=0;j<a;j++)c.push(String.fromCharCode(b[j>>>2]>>>24-8*(j%4)&255));return c.join(\"\")},parse:function(a){for(var b=a.length,c=[],j=0;j<b;j++)c[j>>>2]|=(a.charCodeAt(j)&255)<<24-8*(j%4);return new s.init(c,b)}},q=x.Utf8={stringify:function(a){try{return decodeURIComponent(escape(e.stringify(a)))}catch(b){throw Error(\"Malformed UTF-8 data\");}},parse:function(a){return e.parse(unescape(encodeURIComponent(a)))}},\nt=u.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new s.init;this._nDataBytes=0},_append:function(a){\"string\"==typeof a&&(a=q.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var b=this._data,c=b.words,j=b.sigBytes,n=this.blockSize,e=j/(4*n),e=a?v.ceil(e):v.max((e|0)-this._minBufferSize,0);a=e*n;j=v.min(4*a,j);if(a){for(var f=0;f<a;f+=n)this._doProcessBlock(c,f);f=c.splice(0,a);b.sigBytes-=j}return new s.init(f,j)},clone:function(){var a=f.clone.call(this);\na._data=this._data.clone();return a},_minBufferSize:0});u.Hasher=t.extend({cfg:f.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){t.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(b,c){return(new a.init(c)).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return(new w.HMAC.init(a,\nc)).finalize(b)}}});var w=d.algo={};return d}(Math);\n(function(v){var p=CryptoJS,d=p.lib,u=d.Base,r=d.WordArray,p=p.x64={};p.Word=u.extend({init:function(f,s){this.high=f;this.low=s}});p.WordArray=u.extend({init:function(f,s){f=this.words=f||[];this.sigBytes=s!=v?s:8*f.length},toX32:function(){for(var f=this.words,s=f.length,d=[],p=0;p<s;p++){var e=f[p];d.push(e.high);d.push(e.low)}return r.create(d,this.sigBytes)},clone:function(){for(var f=u.clone.call(this),d=f.words=this.words.slice(0),p=d.length,r=0;r<p;r++)d[r]=d[r].clone();return f}})})();\n(function(v){for(var p=CryptoJS,d=p.lib,u=d.WordArray,r=d.Hasher,f=p.x64.Word,d=p.algo,s=[],x=[],y=[],e=1,q=0,t=0;24>t;t++){s[e+5*q]=(t+1)*(t+2)/2%64;var w=(2*e+3*q)%5,e=q%5,q=w}for(e=0;5>e;e++)for(q=0;5>q;q++)x[e+5*q]=q+5*((2*e+3*q)%5);e=1;for(q=0;24>q;q++){for(var a=w=t=0;7>a;a++){if(e&1){var b=(1<<a)-1;32>b?w^=1<<b:t^=1<<b-32}e=e&128?e<<1^113:e<<1}y[q]=f.create(t,w)}for(var c=[],e=0;25>e;e++)c[e]=f.create();d=d.SHA3=r.extend({cfg:r.cfg.extend({outputLength:512}),_doReset:function(){for(var a=this._state=\n[],b=0;25>b;b++)a[b]=new f.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(a,b){for(var e=this._state,f=this.blockSize/2,h=0;h<f;h++){var l=a[b+2*h],m=a[b+2*h+1],l=(l<<8|l>>>24)&16711935|(l<<24|l>>>8)&4278255360,m=(m<<8|m>>>24)&16711935|(m<<24|m>>>8)&4278255360,g=e[h];g.high^=m;g.low^=l}for(f=0;24>f;f++){for(h=0;5>h;h++){for(var d=l=0,k=0;5>k;k++)g=e[h+5*k],l^=g.high,d^=g.low;g=c[h];g.high=l;g.low=d}for(h=0;5>h;h++){g=c[(h+4)%5];l=c[(h+1)%5];m=l.high;k=l.low;l=g.high^\n(m<<1|k>>>31);d=g.low^(k<<1|m>>>31);for(k=0;5>k;k++)g=e[h+5*k],g.high^=l,g.low^=d}for(m=1;25>m;m++)g=e[m],h=g.high,g=g.low,k=s[m],32>k?(l=h<<k|g>>>32-k,d=g<<k|h>>>32-k):(l=g<<k-32|h>>>64-k,d=h<<k-32|g>>>64-k),g=c[x[m]],g.high=l,g.low=d;g=c[0];h=e[0];g.high=h.high;g.low=h.low;for(h=0;5>h;h++)for(k=0;5>k;k++)m=h+5*k,g=e[m],l=c[m],m=c[(h+1)%5+5*k],d=c[(h+2)%5+5*k],g.high=l.high^~m.high&d.high,g.low=l.low^~m.low&d.low;g=e[0];h=y[f];g.high^=h.high;g.low^=h.low}},_doFinalize:function(){var a=this._data,\nb=a.words,c=8*a.sigBytes,e=32*this.blockSize;b[c>>>5]|=1<<24-c%32;b[(v.ceil((c+1)/e)*e>>>5)-1]|=128;a.sigBytes=4*b.length;this._process();for(var a=this._state,b=this.cfg.outputLength/8,c=b/8,e=[],h=0;h<c;h++){var d=a[h],f=d.high,d=d.low,f=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360,d=(d<<8|d>>>24)&16711935|(d<<24|d>>>8)&4278255360;e.push(d);e.push(f)}return new u.init(e,b)},clone:function(){for(var a=r.clone.call(this),b=a._state=this._state.slice(0),c=0;25>c;c++)b[c]=b[c].clone();return a}});\np.SHA3=r._createHelper(d);p.HmacSHA3=r._createHmacHelper(d)})(Math);\n"], "crypto_js.rollups.sha384": [".js", "/*\nCryptoJS v3.1.2\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\nvar CryptoJS=CryptoJS||function(a,c){var d={},j=d.lib={},f=function(){},m=j.Base={extend:function(a){f.prototype=this;var b=new f;a&&b.mixIn(a);b.hasOwnProperty(\"init\")||(b.init=function(){b.$super.init.apply(this,arguments)});b.init.prototype=b;b.$super=this;return b},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty(\"toString\")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},\nB=j.WordArray=m.extend({init:function(a,b){a=this.words=a||[];this.sigBytes=b!=c?b:4*a.length},toString:function(a){return(a||y).stringify(this)},concat:function(a){var b=this.words,g=a.words,e=this.sigBytes;a=a.sigBytes;this.clamp();if(e%4)for(var k=0;k<a;k++)b[e+k>>>2]|=(g[k>>>2]>>>24-8*(k%4)&255)<<24-8*((e+k)%4);else if(65535<g.length)for(k=0;k<a;k+=4)b[e+k>>>2]=g[k>>>2];else b.push.apply(b,g);this.sigBytes+=a;return this},clamp:function(){var n=this.words,b=this.sigBytes;n[b>>>2]&=4294967295<<\n32-8*(b%4);n.length=a.ceil(b/4)},clone:function(){var a=m.clone.call(this);a.words=this.words.slice(0);return a},random:function(n){for(var b=[],g=0;g<n;g+=4)b.push(4294967296*a.random()|0);return new B.init(b,n)}}),v=d.enc={},y=v.Hex={stringify:function(a){var b=a.words;a=a.sigBytes;for(var g=[],e=0;e<a;e++){var k=b[e>>>2]>>>24-8*(e%4)&255;g.push((k>>>4).toString(16));g.push((k&15).toString(16))}return g.join(\"\")},parse:function(a){for(var b=a.length,g=[],e=0;e<b;e+=2)g[e>>>3]|=parseInt(a.substr(e,\n2),16)<<24-4*(e%8);return new B.init(g,b/2)}},F=v.Latin1={stringify:function(a){var b=a.words;a=a.sigBytes;for(var g=[],e=0;e<a;e++)g.push(String.fromCharCode(b[e>>>2]>>>24-8*(e%4)&255));return g.join(\"\")},parse:function(a){for(var b=a.length,g=[],e=0;e<b;e++)g[e>>>2]|=(a.charCodeAt(e)&255)<<24-8*(e%4);return new B.init(g,b)}},ha=v.Utf8={stringify:function(a){try{return decodeURIComponent(escape(F.stringify(a)))}catch(b){throw Error(\"Malformed UTF-8 data\");}},parse:function(a){return F.parse(unescape(encodeURIComponent(a)))}},\nZ=j.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new B.init;this._nDataBytes=0},_append:function(a){\"string\"==typeof a&&(a=ha.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(n){var b=this._data,g=b.words,e=b.sigBytes,k=this.blockSize,m=e/(4*k),m=n?a.ceil(m):a.max((m|0)-this._minBufferSize,0);n=m*k;e=a.min(4*n,e);if(n){for(var c=0;c<n;c+=k)this._doProcessBlock(g,c);c=g.splice(0,n);b.sigBytes-=e}return new B.init(c,e)},clone:function(){var a=m.clone.call(this);\na._data=this._data.clone();return a},_minBufferSize:0});j.Hasher=Z.extend({cfg:m.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){Z.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(b,g){return(new a.init(g)).finalize(b)}},_createHmacHelper:function(a){return function(b,g){return(new ia.HMAC.init(a,\ng)).finalize(b)}}});var ia=d.algo={};return d}(Math);\n(function(a){var c=CryptoJS,d=c.lib,j=d.Base,f=d.WordArray,c=c.x64={};c.Word=j.extend({init:function(a,c){this.high=a;this.low=c}});c.WordArray=j.extend({init:function(c,d){c=this.words=c||[];this.sigBytes=d!=a?d:8*c.length},toX32:function(){for(var a=this.words,c=a.length,d=[],j=0;j<c;j++){var F=a[j];d.push(F.high);d.push(F.low)}return f.create(d,this.sigBytes)},clone:function(){for(var a=j.clone.call(this),c=a.words=this.words.slice(0),d=c.length,f=0;f<d;f++)c[f]=c[f].clone();return a}})})();\n(function(){function a(){return f.create.apply(f,arguments)}for(var c=CryptoJS,d=c.lib.Hasher,j=c.x64,f=j.Word,m=j.WordArray,j=c.algo,B=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),\na(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,\n2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),\na(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,\n3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],v=[],y=0;80>y;y++)v[y]=a();j=j.SHA512=d.extend({_doReset:function(){this._hash=new m.init([new f.init(1779033703,4089235720),new f.init(3144134277,2227873595),new f.init(1013904242,4271175723),new f.init(2773480762,1595750129),new f.init(1359893119,2917565137),new f.init(2600822924,725511199),new f.init(528734635,4215389547),new f.init(1541459225,327033209)])},_doProcessBlock:function(a,c){for(var d=this._hash.words,\nf=d[0],j=d[1],b=d[2],g=d[3],e=d[4],k=d[5],m=d[6],d=d[7],y=f.high,M=f.low,$=j.high,N=j.low,aa=b.high,O=b.low,ba=g.high,P=g.low,ca=e.high,Q=e.low,da=k.high,R=k.low,ea=m.high,S=m.low,fa=d.high,T=d.low,s=y,p=M,G=$,D=N,H=aa,E=O,W=ba,I=P,t=ca,q=Q,U=da,J=R,V=ea,K=S,X=fa,L=T,u=0;80>u;u++){var z=v[u];if(16>u)var r=z.high=a[c+2*u]|0,h=z.low=a[c+2*u+1]|0;else{var r=v[u-15],h=r.high,w=r.low,r=(h>>>1|w<<31)^(h>>>8|w<<24)^h>>>7,w=(w>>>1|h<<31)^(w>>>8|h<<24)^(w>>>7|h<<25),C=v[u-2],h=C.high,l=C.low,C=(h>>>19|l<<\n13)^(h<<3|l>>>29)^h>>>6,l=(l>>>19|h<<13)^(l<<3|h>>>29)^(l>>>6|h<<26),h=v[u-7],Y=h.high,A=v[u-16],x=A.high,A=A.low,h=w+h.low,r=r+Y+(h>>>0<w>>>0?1:0),h=h+l,r=r+C+(h>>>0<l>>>0?1:0),h=h+A,r=r+x+(h>>>0<A>>>0?1:0);z.high=r;z.low=h}var Y=t&U^~t&V,A=q&J^~q&K,z=s&G^s&H^G&H,ja=p&D^p&E^D&E,w=(s>>>28|p<<4)^(s<<30|p>>>2)^(s<<25|p>>>7),C=(p>>>28|s<<4)^(p<<30|s>>>2)^(p<<25|s>>>7),l=B[u],ka=l.high,ga=l.low,l=L+((q>>>14|t<<18)^(q>>>18|t<<14)^(q<<23|t>>>9)),x=X+((t>>>14|q<<18)^(t>>>18|q<<14)^(t<<23|q>>>9))+(l>>>0<\nL>>>0?1:0),l=l+A,x=x+Y+(l>>>0<A>>>0?1:0),l=l+ga,x=x+ka+(l>>>0<ga>>>0?1:0),l=l+h,x=x+r+(l>>>0<h>>>0?1:0),h=C+ja,z=w+z+(h>>>0<C>>>0?1:0),X=V,L=K,V=U,K=J,U=t,J=q,q=I+l|0,t=W+x+(q>>>0<I>>>0?1:0)|0,W=H,I=E,H=G,E=D,G=s,D=p,p=l+h|0,s=x+z+(p>>>0<l>>>0?1:0)|0}M=f.low=M+p;f.high=y+s+(M>>>0<p>>>0?1:0);N=j.low=N+D;j.high=$+G+(N>>>0<D>>>0?1:0);O=b.low=O+E;b.high=aa+H+(O>>>0<E>>>0?1:0);P=g.low=P+I;g.high=ba+W+(P>>>0<I>>>0?1:0);Q=e.low=Q+q;e.high=ca+t+(Q>>>0<q>>>0?1:0);R=k.low=R+J;k.high=da+U+(R>>>0<J>>>0?1:0);\nS=m.low=S+K;m.high=ea+V+(S>>>0<K>>>0?1:0);T=d.low=T+L;d.high=fa+X+(T>>>0<L>>>0?1:0)},_doFinalize:function(){var a=this._data,c=a.words,d=8*this._nDataBytes,f=8*a.sigBytes;c[f>>>5]|=128<<24-f%32;c[(f+128>>>10<<5)+30]=Math.floor(d/4294967296);c[(f+128>>>10<<5)+31]=d;a.sigBytes=4*c.length;this._process();return this._hash.toX32()},clone:function(){var a=d.clone.call(this);a._hash=this._hash.clone();return a},blockSize:32});c.SHA512=d._createHelper(j);c.HmacSHA512=d._createHmacHelper(j)})();\n(function(){var a=CryptoJS,c=a.x64,d=c.Word,j=c.WordArray,c=a.algo,f=c.SHA512,c=c.SHA384=f.extend({_doReset:function(){this._hash=new j.init([new d.init(3418070365,3238371032),new d.init(1654270250,914150663),new d.init(2438529370,812702999),new d.init(355462360,4144912697),new d.init(1731405415,4290775857),new d.init(2394180231,1750603025),new d.init(3675008525,1694076839),new d.init(1203062813,3204075428)])},_doFinalize:function(){var a=f._doFinalize.call(this);a.sigBytes-=16;return a}});a.SHA384=\nf._createHelper(c);a.HmacSHA384=f._createHmacHelper(c)})();\n"], "crypto_js.rollups.sha512": [".js", "/*\nCryptoJS v3.1.2\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\nvar CryptoJS=CryptoJS||function(a,m){var r={},f=r.lib={},g=function(){},l=f.Base={extend:function(a){g.prototype=this;var b=new g;a&&b.mixIn(a);b.hasOwnProperty(\"init\")||(b.init=function(){b.$super.init.apply(this,arguments)});b.init.prototype=b;b.$super=this;return b},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty(\"toString\")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},\np=f.WordArray=l.extend({init:function(a,b){a=this.words=a||[];this.sigBytes=b!=m?b:4*a.length},toString:function(a){return(a||q).stringify(this)},concat:function(a){var b=this.words,d=a.words,c=this.sigBytes;a=a.sigBytes;this.clamp();if(c%4)for(var j=0;j<a;j++)b[c+j>>>2]|=(d[j>>>2]>>>24-8*(j%4)&255)<<24-8*((c+j)%4);else if(65535<d.length)for(j=0;j<a;j+=4)b[c+j>>>2]=d[j>>>2];else b.push.apply(b,d);this.sigBytes+=a;return this},clamp:function(){var n=this.words,b=this.sigBytes;n[b>>>2]&=4294967295<<\n32-8*(b%4);n.length=a.ceil(b/4)},clone:function(){var a=l.clone.call(this);a.words=this.words.slice(0);return a},random:function(n){for(var b=[],d=0;d<n;d+=4)b.push(4294967296*a.random()|0);return new p.init(b,n)}}),y=r.enc={},q=y.Hex={stringify:function(a){var b=a.words;a=a.sigBytes;for(var d=[],c=0;c<a;c++){var j=b[c>>>2]>>>24-8*(c%4)&255;d.push((j>>>4).toString(16));d.push((j&15).toString(16))}return d.join(\"\")},parse:function(a){for(var b=a.length,d=[],c=0;c<b;c+=2)d[c>>>3]|=parseInt(a.substr(c,\n2),16)<<24-4*(c%8);return new p.init(d,b/2)}},G=y.Latin1={stringify:function(a){var b=a.words;a=a.sigBytes;for(var d=[],c=0;c<a;c++)d.push(String.fromCharCode(b[c>>>2]>>>24-8*(c%4)&255));return d.join(\"\")},parse:function(a){for(var b=a.length,d=[],c=0;c<b;c++)d[c>>>2]|=(a.charCodeAt(c)&255)<<24-8*(c%4);return new p.init(d,b)}},fa=y.Utf8={stringify:function(a){try{return decodeURIComponent(escape(G.stringify(a)))}catch(b){throw Error(\"Malformed UTF-8 data\");}},parse:function(a){return G.parse(unescape(encodeURIComponent(a)))}},\nh=f.BufferedBlockAlgorithm=l.extend({reset:function(){this._data=new p.init;this._nDataBytes=0},_append:function(a){\"string\"==typeof a&&(a=fa.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(n){var b=this._data,d=b.words,c=b.sigBytes,j=this.blockSize,l=c/(4*j),l=n?a.ceil(l):a.max((l|0)-this._minBufferSize,0);n=l*j;c=a.min(4*n,c);if(n){for(var h=0;h<n;h+=j)this._doProcessBlock(d,h);h=d.splice(0,n);b.sigBytes-=c}return new p.init(h,c)},clone:function(){var a=l.clone.call(this);\na._data=this._data.clone();return a},_minBufferSize:0});f.Hasher=h.extend({cfg:l.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){h.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(b,d){return(new a.init(d)).finalize(b)}},_createHmacHelper:function(a){return function(b,d){return(new ga.HMAC.init(a,\nd)).finalize(b)}}});var ga=r.algo={};return r}(Math);\n(function(a){var m=CryptoJS,r=m.lib,f=r.Base,g=r.WordArray,m=m.x64={};m.Word=f.extend({init:function(a,p){this.high=a;this.low=p}});m.WordArray=f.extend({init:function(l,p){l=this.words=l||[];this.sigBytes=p!=a?p:8*l.length},toX32:function(){for(var a=this.words,p=a.length,f=[],q=0;q<p;q++){var G=a[q];f.push(G.high);f.push(G.low)}return g.create(f,this.sigBytes)},clone:function(){for(var a=f.clone.call(this),p=a.words=this.words.slice(0),g=p.length,q=0;q<g;q++)p[q]=p[q].clone();return a}})})();\n(function(){function a(){return g.create.apply(g,arguments)}for(var m=CryptoJS,r=m.lib.Hasher,f=m.x64,g=f.Word,l=f.WordArray,f=m.algo,p=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),\na(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,\n2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),\na(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,\n3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],y=[],q=0;80>q;q++)y[q]=a();f=f.SHA512=r.extend({_doReset:function(){this._hash=new l.init([new g.init(1779033703,4089235720),new g.init(3144134277,2227873595),new g.init(1013904242,4271175723),new g.init(2773480762,1595750129),new g.init(1359893119,2917565137),new g.init(2600822924,725511199),new g.init(528734635,4215389547),new g.init(1541459225,327033209)])},_doProcessBlock:function(a,f){for(var h=this._hash.words,\ng=h[0],n=h[1],b=h[2],d=h[3],c=h[4],j=h[5],l=h[6],h=h[7],q=g.high,m=g.low,r=n.high,N=n.low,Z=b.high,O=b.low,$=d.high,P=d.low,aa=c.high,Q=c.low,ba=j.high,R=j.low,ca=l.high,S=l.low,da=h.high,T=h.low,v=q,s=m,H=r,E=N,I=Z,F=O,W=$,J=P,w=aa,t=Q,U=ba,K=R,V=ca,L=S,X=da,M=T,x=0;80>x;x++){var B=y[x];if(16>x)var u=B.high=a[f+2*x]|0,e=B.low=a[f+2*x+1]|0;else{var u=y[x-15],e=u.high,z=u.low,u=(e>>>1|z<<31)^(e>>>8|z<<24)^e>>>7,z=(z>>>1|e<<31)^(z>>>8|e<<24)^(z>>>7|e<<25),D=y[x-2],e=D.high,k=D.low,D=(e>>>19|k<<13)^\n(e<<3|k>>>29)^e>>>6,k=(k>>>19|e<<13)^(k<<3|e>>>29)^(k>>>6|e<<26),e=y[x-7],Y=e.high,C=y[x-16],A=C.high,C=C.low,e=z+e.low,u=u+Y+(e>>>0<z>>>0?1:0),e=e+k,u=u+D+(e>>>0<k>>>0?1:0),e=e+C,u=u+A+(e>>>0<C>>>0?1:0);B.high=u;B.low=e}var Y=w&U^~w&V,C=t&K^~t&L,B=v&H^v&I^H&I,ha=s&E^s&F^E&F,z=(v>>>28|s<<4)^(v<<30|s>>>2)^(v<<25|s>>>7),D=(s>>>28|v<<4)^(s<<30|v>>>2)^(s<<25|v>>>7),k=p[x],ia=k.high,ea=k.low,k=M+((t>>>14|w<<18)^(t>>>18|w<<14)^(t<<23|w>>>9)),A=X+((w>>>14|t<<18)^(w>>>18|t<<14)^(w<<23|t>>>9))+(k>>>0<M>>>\n0?1:0),k=k+C,A=A+Y+(k>>>0<C>>>0?1:0),k=k+ea,A=A+ia+(k>>>0<ea>>>0?1:0),k=k+e,A=A+u+(k>>>0<e>>>0?1:0),e=D+ha,B=z+B+(e>>>0<D>>>0?1:0),X=V,M=L,V=U,L=K,U=w,K=t,t=J+k|0,w=W+A+(t>>>0<J>>>0?1:0)|0,W=I,J=F,I=H,F=E,H=v,E=s,s=k+e|0,v=A+B+(s>>>0<k>>>0?1:0)|0}m=g.low=m+s;g.high=q+v+(m>>>0<s>>>0?1:0);N=n.low=N+E;n.high=r+H+(N>>>0<E>>>0?1:0);O=b.low=O+F;b.high=Z+I+(O>>>0<F>>>0?1:0);P=d.low=P+J;d.high=$+W+(P>>>0<J>>>0?1:0);Q=c.low=Q+t;c.high=aa+w+(Q>>>0<t>>>0?1:0);R=j.low=R+K;j.high=ba+U+(R>>>0<K>>>0?1:0);S=l.low=\nS+L;l.high=ca+V+(S>>>0<L>>>0?1:0);T=h.low=T+M;h.high=da+X+(T>>>0<M>>>0?1:0)},_doFinalize:function(){var a=this._data,f=a.words,h=8*this._nDataBytes,g=8*a.sigBytes;f[g>>>5]|=128<<24-g%32;f[(g+128>>>10<<5)+30]=Math.floor(h/4294967296);f[(g+128>>>10<<5)+31]=h;a.sigBytes=4*f.length;this._process();return this._hash.toX32()},clone:function(){var a=r.clone.call(this);a._hash=this._hash.clone();return a},blockSize:32});m.SHA512=r._createHelper(f);m.HmacSHA512=r._createHmacHelper(f)})();\n"], "abc": [".py", "\n\n\n\"\"\"Abstract Base Classes (ABCs) according to PEP 3119.\"\"\"\n\nfrom _weakrefset import WeakSet\n\ndef abstractmethod(funcobj):\n ''\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n funcobj. __isabstractmethod__=True\n return funcobj\n \n \nclass abstractclassmethod(classmethod):\n ''\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n __isabstractmethod__=True\n \n def __init__(self,callable):\n callable. __isabstractmethod__=True\n super(). __init__(callable)\n \n \nclass abstractstaticmethod(staticmethod):\n ''\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n __isabstractmethod__=True\n \n def __init__(self,callable):\n callable. __isabstractmethod__=True\n super(). __init__(callable)\n \n \nclass abstractproperty(property):\n ''\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n __isabstractmethod__=True\n \n \nclass ABCMeta(type):\n\n ''\n\n\n\n\n\n\n\n\n\n\n\n \n \n \n \n \n _abc_invalidation_counter=0\n \n def __new__(mcls,name,bases,namespace):\n cls=super(). __new__(mcls,name,bases,namespace)\n \n abstracts={name\n for name,value in namespace. items()\n if getattr(value,\"__isabstractmethod__\",False )}\n for base in bases:\n for name in getattr(base,\"__abstractmethods__\",set()):\n value=getattr(cls,name,None )\n if getattr(value,\"__isabstractmethod__\",False ):\n abstracts. add(name)\n cls. __abstractmethods__=frozenset(abstracts)\n \n cls. _abc_registry=WeakSet()\n cls. _abc_cache=WeakSet()\n cls. _abc_negative_cache=WeakSet()\n cls. _abc_negative_cache_version=ABCMeta. _abc_invalidation_counter\n return cls\n \n def register(cls,subclass):\n ''\n\n\n \n if not isinstance(subclass,type):\n raise TypeError(\"Can only register classes\")\n if issubclass(subclass,cls):\n return subclass\n \n \n if issubclass(cls,subclass):\n \n raise RuntimeError(\"Refusing to create an inheritance cycle\")\n cls. _abc_registry. add(subclass)\n ABCMeta. _abc_invalidation_counter +=1\n return subclass\n \n def _dump_registry(cls,file=None ):\n ''\n print(\"Class: %s.%s\"%(cls. __module__,cls. __name__),file=file)\n print(\"Inv.counter: %s\"%ABCMeta. _abc_invalidation_counter,file=file)\n for name in sorted(cls. __dict__. keys()):\n if name. startswith(\"_abc_\"):\n value=getattr(cls,name)\n print(\"%s: %r\"%(name,value),file=file)\n \n def __instancecheck__(cls,instance):\n ''\n \n subclass=instance. __class__\n if subclass in cls. _abc_cache:\n return True\n subtype=type(instance)\n if subtype is subclass:\n if (cls. _abc_negative_cache_version ==\n ABCMeta. _abc_invalidation_counter and\n subclass in cls. _abc_negative_cache):\n return False\n \n return cls. __subclasscheck__(subclass)\n return any(cls. __subclasscheck__(c)for c in {subclass,subtype})\n \n def __subclasscheck__(cls,subclass):\n ''\n \n if subclass in cls. _abc_cache:\n return True\n \n if cls. _abc_negative_cache_version <ABCMeta. _abc_invalidation_counter:\n \n cls. _abc_negative_cache=WeakSet()\n cls. _abc_negative_cache_version=ABCMeta. _abc_invalidation_counter\n elif subclass in cls. _abc_negative_cache:\n return False\n \n ok=cls. __subclasshook__(subclass)\n if ok is not NotImplemented:\n assert isinstance(ok,bool)\n if ok:\n cls. _abc_cache. add(subclass)\n else :\n cls. _abc_negative_cache. add(subclass)\n return ok\n \n if cls in getattr(subclass,'__mro__',()):\n cls. _abc_cache. add(subclass)\n return True\n \n for rcls in cls. _abc_registry:\n if issubclass(subclass,rcls):\n cls. _abc_cache. add(subclass)\n return True\n \n for scls in cls. __subclasses__():\n if issubclass(subclass,scls):\n cls. _abc_cache. add(subclass)\n return True\n \n cls. _abc_negative_cache. add(subclass)\n return False\n"], "antigravity": [".py", "\nimport webbrowser\nimport hashlib\n\nwebbrowser. open(\"http://xkcd.com/353/\")\n\ndef geohash(latitude,longitude,datedow):\n ''\n\n\n\n\n \n \n h=hashlib. md5(datedow). hexdigest()\n p,q=[('%f'%float. fromhex('0.'+x))for x in (h[:16],h[16:32])]\n print('%d%s %d%s'%(latitude,p[1:],longitude,q[1:]))\n"], "argparse": [".py", "\n\n\"\"\"Command-line parsing library\n\nThis module is an optparse-inspired command-line parsing library that:\n\n - handles both optional and positional arguments\n - produces highly informative usage messages\n - supports parsers that dispatch to sub-parsers\n\nThe following is a simple usage example that sums integers from the\ncommand-line and writes the result to a file::\n\n parser = argparse.ArgumentParser(\n description='sum the integers at the command line')\n parser.add_argument(\n 'integers', metavar='int', nargs='+', type=int,\n help='an integer to be summed')\n parser.add_argument(\n '--log', default=sys.stdout, type=argparse.FileType('w'),\n help='the file where the sum should be written')\n args = parser.parse_args()\n args.log.write('%s' % sum(args.integers))\n args.log.close()\n\nThe module contains the following public classes:\n\n - ArgumentParser -- The main entry point for command-line parsing. As the\n example above shows, the add_argument() method is used to populate\n the parser with actions for optional and positional arguments. Then\n the parse_args() method is invoked to convert the args at the\n command-line into an object with attributes.\n\n - ArgumentError -- The exception raised by ArgumentParser objects when\n there are errors with the parser's actions. Errors raised while\n parsing the command-line are caught by ArgumentParser and emitted\n as command-line messages.\n\n - FileType -- A factory for defining types of files to be created. As the\n example above shows, instances of FileType are typically passed as\n the type= argument of add_argument() calls.\n\n - Action -- The base class for parser actions. Typically actions are\n selected by passing strings like 'store_true' or 'append_const' to\n the action= argument of add_argument(). However, for greater\n customization of ArgumentParser actions, subclasses of Action may\n be defined and passed as the action= argument.\n\n - HelpFormatter, RawDescriptionHelpFormatter, RawTextHelpFormatter,\n ArgumentDefaultsHelpFormatter -- Formatter classes which\n may be passed as the formatter_class= argument to the\n ArgumentParser constructor. HelpFormatter is the default,\n RawDescriptionHelpFormatter and RawTextHelpFormatter tell the parser\n not to change the formatting for help text, and\n ArgumentDefaultsHelpFormatter adds information about argument defaults\n to the help.\n\nAll other classes in this module are considered implementation details.\n(Also note that HelpFormatter and RawDescriptionHelpFormatter are only\nconsidered public as object names -- the API of the formatter objects is\nstill considered an implementation detail.)\n\"\"\"\n\n__version__='1.1'\n__all__=[\n'ArgumentParser',\n'ArgumentError',\n'ArgumentTypeError',\n'FileType',\n'HelpFormatter',\n'ArgumentDefaultsHelpFormatter',\n'RawDescriptionHelpFormatter',\n'RawTextHelpFormatter',\n'MetavarTypeHelpFormatter',\n'Namespace',\n'Action',\n'ONE_OR_MORE',\n'OPTIONAL',\n'PARSER',\n'REMAINDER',\n'SUPPRESS',\n'ZERO_OR_MORE',\n]\n\n\nimport collections as _collections\nimport copy as _copy\nimport os as _os\nimport re as _re\nimport sys as _sys\nimport textwrap as _textwrap\n\nfrom gettext import gettext as _,ngettext\n\n\nSUPPRESS='==SUPPRESS=='\n\nOPTIONAL='?'\nZERO_OR_MORE='*'\nONE_OR_MORE='+'\nPARSER='A...'\nREMAINDER='...'\n_UNRECOGNIZED_ARGS_ATTR='_unrecognized_args'\n\n\n\n\n\nclass _AttributeHolder(object):\n ''\n\n\n\n\n\n \n \n def __repr__(self):\n type_name=type(self). __name__\n arg_strings=[]\n for arg in self. _get_args():\n arg_strings. append(repr(arg))\n for name,value in self. _get_kwargs():\n arg_strings. append('%s=%r'%(name,value))\n return'%s(%s)'%(type_name,', '. join(arg_strings))\n \n def _get_kwargs(self):\n return sorted(self. __dict__. items())\n \n def _get_args(self):\n return []\n \n \ndef _ensure_value(namespace,name,value):\n if getattr(namespace,name,None )is None :\n setattr(namespace,name,value)\n return getattr(namespace,name)\n \n \n \n \n \n \nclass HelpFormatter(object):\n ''\n\n\n\n \n \n def __init__(self,\n prog,\n indent_increment=2,\n max_help_position=24,\n width=None ):\n \n \n if width is None :\n try :\n width=int(_os. environ['COLUMNS'])\n except (KeyError,ValueError):\n width=80\n width -=2\n \n self. _prog=prog\n self. _indent_increment=indent_increment\n self. _max_help_position=max_help_position\n self. _max_help_position=min(max_help_position,\n max(width -20,indent_increment *2))\n self. _width=width\n \n self. _current_indent=0\n self. _level=0\n self. _action_max_length=0\n \n self. _root_section=self. _Section(self,None )\n self. _current_section=self. _root_section\n \n self. _whitespace_matcher=_re. compile(r'\\s+')\n self. _long_break_matcher=_re. compile(r'\\n\\n\\n+')\n \n \n \n \n def _indent(self):\n self. _current_indent +=self. _indent_increment\n self. _level +=1\n \n def _dedent(self):\n self. _current_indent -=self. _indent_increment\n assert self. _current_indent >=0,'Indent decreased below 0.'\n self. _level -=1\n \n class _Section(object):\n \n def __init__(self,formatter,parent,heading=None ):\n self. formatter=formatter\n self. parent=parent\n self. heading=heading\n self. items=[]\n \n def format_help(self):\n \n if self. parent is not None :\n self. formatter. _indent()\n join=self. formatter. _join_parts\n for func,args in self. items:\n func(*args)\n item_help=join([func(*args)for func,args in self. items])\n if self. parent is not None :\n self. formatter. _dedent()\n \n \n if not item_help:\n return''\n \n \n if self. heading is not SUPPRESS and self. heading is not None :\n current_indent=self. formatter. _current_indent\n heading='%*s%s:\\n'%(current_indent,'',self. heading)\n else :\n heading=''\n \n \n return join(['\\n',heading,item_help,'\\n'])\n \n def _add_item(self,func,args):\n self. _current_section. items. append((func,args))\n \n \n \n \n def start_section(self,heading):\n self. _indent()\n section=self. _Section(self,self. _current_section,heading)\n self. _add_item(section. format_help,[])\n self. _current_section=section\n \n def end_section(self):\n self. _current_section=self. _current_section. parent\n self. _dedent()\n \n def add_text(self,text):\n if text is not SUPPRESS and text is not None :\n self. _add_item(self. _format_text,[text])\n \n def add_usage(self,usage,actions,groups,prefix=None ):\n if usage is not SUPPRESS:\n args=usage,actions,groups,prefix\n self. _add_item(self. _format_usage,args)\n \n def add_argument(self,action):\n if action. help is not SUPPRESS:\n \n \n get_invocation=self. _format_action_invocation\n invocations=[get_invocation(action)]\n for subaction in self. _iter_indented_subactions(action):\n invocations. append(get_invocation(subaction))\n \n \n invocation_length=max([len(s)for s in invocations])\n action_length=invocation_length+self. _current_indent\n self. _action_max_length=max(self. _action_max_length,\n action_length)\n \n \n self. _add_item(self. _format_action,[action])\n \n def add_arguments(self,actions):\n for action in actions:\n self. add_argument(action)\n \n \n \n \n def format_help(self):\n help=self. _root_section. format_help()\n if help:\n help=self. _long_break_matcher. sub('\\n\\n',help)\n help=help. strip('\\n')+'\\n'\n return help\n \n def _join_parts(self,part_strings):\n return''. join([part\n for part in part_strings\n if part and part is not SUPPRESS])\n \n def _format_usage(self,usage,actions,groups,prefix):\n if prefix is None :\n prefix=_('usage: ')\n \n \n if usage is not None :\n usage=usage %dict(prog=self. _prog)\n \n \n elif usage is None and not actions:\n usage='%(prog)s'%dict(prog=self. _prog)\n \n \n elif usage is None :\n prog='%(prog)s'%dict(prog=self. _prog)\n \n \n optionals=[]\n positionals=[]\n for action in actions:\n if action. option_strings:\n optionals. append(action)\n else :\n positionals. append(action)\n \n \n format=self. _format_actions_usage\n action_usage=format(optionals+positionals,groups)\n usage=' '. join([s for s in [prog,action_usage]if s])\n \n \n text_width=self. _width -self. _current_indent\n if len(prefix)+len(usage)>text_width:\n \n \n part_regexp=r'\\(.*?\\)+|\\[.*?\\]+|\\S+'\n opt_usage=format(optionals,groups)\n pos_usage=format(positionals,groups)\n opt_parts=_re. findall(part_regexp,opt_usage)\n pos_parts=_re. findall(part_regexp,pos_usage)\n assert' '. join(opt_parts)==opt_usage\n assert' '. join(pos_parts)==pos_usage\n \n \n def get_lines(parts,indent,prefix=None ):\n lines=[]\n line=[]\n if prefix is not None :\n line_len=len(prefix)-1\n else :\n line_len=len(indent)-1\n for part in parts:\n if line_len+1+len(part)>text_width and line:\n lines. append(indent+' '. join(line))\n line=[]\n line_len=len(indent)-1\n line. append(part)\n line_len +=len(part)+1\n if line:\n lines. append(indent+' '. join(line))\n if prefix is not None :\n lines[0]=lines[0][len(indent):]\n return lines\n \n \n if len(prefix)+len(prog)<=0.75 *text_width:\n indent=' '*(len(prefix)+len(prog)+1)\n if opt_parts:\n lines=get_lines([prog]+opt_parts,indent,prefix)\n lines. extend(get_lines(pos_parts,indent))\n elif pos_parts:\n lines=get_lines([prog]+pos_parts,indent,prefix)\n else :\n lines=[prog]\n \n \n else :\n indent=' '*len(prefix)\n parts=opt_parts+pos_parts\n lines=get_lines(parts,indent)\n if len(lines)>1:\n lines=[]\n lines. extend(get_lines(opt_parts,indent))\n lines. extend(get_lines(pos_parts,indent))\n lines=[prog]+lines\n \n \n usage='\\n'. join(lines)\n \n \n return'%s%s\\n\\n'%(prefix,usage)\n \n def _format_actions_usage(self,actions,groups):\n \n group_actions=set()\n inserts={}\n for group in groups:\n try :\n start=actions. index(group. _group_actions[0])\n except ValueError:\n continue\n else :\n end=start+len(group. _group_actions)\n if actions[start:end]==group. _group_actions:\n for action in group. _group_actions:\n group_actions. add(action)\n if not group. required:\n if start in inserts:\n inserts[start]+=' ['\n else :\n inserts[start]='['\n inserts[end]=']'\n else :\n if start in inserts:\n inserts[start]+=' ('\n else :\n inserts[start]='('\n inserts[end]=')'\n for i in range(start+1,end):\n inserts[i]='|'\n \n \n parts=[]\n for i,action in enumerate(actions):\n \n \n \n if action. help is SUPPRESS:\n parts. append(None )\n if inserts. get(i)=='|':\n inserts. pop(i)\n elif inserts. get(i+1)=='|':\n inserts. pop(i+1)\n \n \n elif not action. option_strings:\n default=self. _get_default_metavar_for_positional(action)\n part=self. _format_args(action,default)\n \n \n if action in group_actions:\n if part[0]=='['and part[-1]==']':\n part=part[1:-1]\n \n \n parts. append(part)\n \n \n else :\n option_string=action. option_strings[0]\n \n \n \n if action. nargs ==0:\n part='%s'%option_string\n \n \n \n else :\n default=self. _get_default_metavar_for_optional(action)\n args_string=self. _format_args(action,default)\n part='%s %s'%(option_string,args_string)\n \n \n if not action. required and action not in group_actions:\n part='[%s]'%part\n \n \n parts. append(part)\n \n \n for i in sorted(inserts,reverse=True ):\n parts[i:i]=[inserts[i]]\n \n \n text=' '. join([item for item in parts if item is not None ])\n \n \n open=r'[\\[(]'\n close=r'[\\])]'\n text=_re. sub(r'(%s) '%open,r'\\1',text)\n text=_re. sub(r' (%s)'%close,r'\\1',text)\n text=_re. sub(r'%s *%s'%(open,close),r'',text)\n text=_re. sub(r'\\(([^|]*)\\)',r'\\1',text)\n text=text. strip()\n \n \n return text\n \n def _format_text(self,text):\n if'%(prog)'in text:\n text=text %dict(prog=self. _prog)\n text_width=max(self. _width -self. _current_indent,11)\n indent=' '*self. _current_indent\n return self. _fill_text(text,text_width,indent)+'\\n\\n'\n \n def _format_action(self,action):\n \n help_position=min(self. _action_max_length+2,\n self. _max_help_position)\n help_width=max(self. _width -help_position,11)\n action_width=help_position -self. _current_indent -2\n action_header=self. _format_action_invocation(action)\n \n \n if not action. help:\n tup=self. _current_indent,'',action_header\n action_header='%*s%s\\n'%tup\n \n \n elif len(action_header)<=action_width:\n tup=self. _current_indent,'',action_width,action_header\n action_header='%*s%-*s '%tup\n indent_first=0\n \n \n else :\n tup=self. _current_indent,'',action_header\n action_header='%*s%s\\n'%tup\n indent_first=help_position\n \n \n parts=[action_header]\n \n \n if action. help:\n help_text=self. _expand_help(action)\n help_lines=self. _split_lines(help_text,help_width)\n parts. append('%*s%s\\n'%(indent_first,'',help_lines[0]))\n for line in help_lines[1:]:\n parts. append('%*s%s\\n'%(help_position,'',line))\n \n \n elif not action_header. endswith('\\n'):\n parts. append('\\n')\n \n \n for subaction in self. _iter_indented_subactions(action):\n parts. append(self. _format_action(subaction))\n \n \n return self. _join_parts(parts)\n \n def _format_action_invocation(self,action):\n if not action. option_strings:\n default=self. _get_default_metavar_for_positional(action)\n metavar,=self. _metavar_formatter(action,default)(1)\n return metavar\n \n else :\n parts=[]\n \n \n \n if action. nargs ==0:\n parts. extend(action. option_strings)\n \n \n \n else :\n default=self. _get_default_metavar_for_optional(action)\n args_string=self. _format_args(action,default)\n for option_string in action. option_strings:\n parts. append('%s %s'%(option_string,args_string))\n \n return', '. join(parts)\n \n def _metavar_formatter(self,action,default_metavar):\n if action. metavar is not None :\n result=action. metavar\n elif action. choices is not None :\n choice_strs=[str(choice)for choice in action. choices]\n result='{%s}'%','. join(choice_strs)\n else :\n result=default_metavar\n \n def format(tuple_size):\n if isinstance(result,tuple):\n return result\n else :\n return (result,)*tuple_size\n return format\n \n def _format_args(self,action,default_metavar):\n get_metavar=self. _metavar_formatter(action,default_metavar)\n if action. nargs is None :\n result='%s'%get_metavar(1)\n elif action. nargs ==OPTIONAL:\n result='[%s]'%get_metavar(1)\n elif action. nargs ==ZERO_OR_MORE:\n result='[%s [%s ...]]'%get_metavar(2)\n elif action. nargs ==ONE_OR_MORE:\n result='%s [%s ...]'%get_metavar(2)\n elif action. nargs ==REMAINDER:\n result='...'\n elif action. nargs ==PARSER:\n result='%s ...'%get_metavar(1)\n else :\n formats=['%s'for _ in range(action. nargs)]\n result=' '. join(formats)%get_metavar(action. nargs)\n return result\n \n def _expand_help(self,action):\n params=dict(vars(action),prog=self. _prog)\n for name in list(params):\n if params[name]is SUPPRESS:\n del params[name]\n for name in list(params):\n if hasattr(params[name],'__name__'):\n params[name]=params[name]. __name__\n if params. get('choices')is not None :\n choices_str=', '. join([str(c)for c in params['choices']])\n params['choices']=choices_str\n return self. _get_help_string(action)%params\n \n def _iter_indented_subactions(self,action):\n try :\n get_subactions=action. _get_subactions\n except AttributeError:\n pass\n else :\n self. _indent()\n yield from get_subactions()\n self. _dedent()\n \n def _split_lines(self,text,width):\n text=self. _whitespace_matcher. sub(' ',text). strip()\n return _textwrap. wrap(text,width)\n \n def _fill_text(self,text,width,indent):\n text=self. _whitespace_matcher. sub(' ',text). strip()\n return _textwrap. fill(text,width,initial_indent=indent,\n subsequent_indent=indent)\n \n def _get_help_string(self,action):\n return action. help\n \n def _get_default_metavar_for_optional(self,action):\n return action. dest. upper()\n \n def _get_default_metavar_for_positional(self,action):\n return action. dest\n \n \nclass RawDescriptionHelpFormatter(HelpFormatter):\n ''\n\n\n\n \n \n def _fill_text(self,text,width,indent):\n return''. join(indent+line for line in text. splitlines(keepends=True ))\n \n \nclass RawTextHelpFormatter(RawDescriptionHelpFormatter):\n ''\n\n\n\n \n \n def _split_lines(self,text,width):\n return text. splitlines()\n \n \nclass ArgumentDefaultsHelpFormatter(HelpFormatter):\n ''\n\n\n\n \n \n def _get_help_string(self,action):\n help=action. help\n if'%(default)'not in action. help:\n if action. default is not SUPPRESS:\n defaulting_nargs=[OPTIONAL,ZERO_OR_MORE]\n if action. option_strings or action. nargs in defaulting_nargs:\n help +=' (default: %(default)s)'\n return help\n \n \nclass MetavarTypeHelpFormatter(HelpFormatter):\n ''\n\n\n\n\n \n \n def _get_default_metavar_for_optional(self,action):\n return action. type. __name__\n \n def _get_default_metavar_for_positional(self,action):\n return action. type. __name__\n \n \n \n \n \n \n \ndef _get_action_name(argument):\n if argument is None :\n return None\n elif argument. option_strings:\n return'/'. join(argument. option_strings)\n elif argument. metavar not in (None ,SUPPRESS):\n return argument. metavar\n elif argument. dest not in (None ,SUPPRESS):\n return argument. dest\n else :\n return None\n \n \nclass ArgumentError(Exception):\n ''\n\n\n\n \n \n def __init__(self,argument,message):\n self. argument_name=_get_action_name(argument)\n self. message=message\n \n def __str__(self):\n if self. argument_name is None :\n format='%(message)s'\n else :\n format='argument %(argument_name)s: %(message)s'\n return format %dict(message=self. message,\n argument_name=self. argument_name)\n \n \nclass ArgumentTypeError(Exception):\n ''\n pass\n \n \n \n \n \n \nclass Action(_AttributeHolder):\n ''\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n def __init__(self,\n option_strings,\n dest,\n nargs=None ,\n const=None ,\n default=None ,\n type=None ,\n choices=None ,\n required=False ,\n help=None ,\n metavar=None ):\n self. option_strings=option_strings\n self. dest=dest\n self. nargs=nargs\n self. const=const\n self. default=default\n self. type=type\n self. choices=choices\n self. required=required\n self. help=help\n self. metavar=metavar\n \n def _get_kwargs(self):\n names=[\n 'option_strings',\n 'dest',\n 'nargs',\n 'const',\n 'default',\n 'type',\n 'choices',\n 'help',\n 'metavar',\n ]\n return [(name,getattr(self,name))for name in names]\n \n def __call__(self,parser,namespace,values,option_string=None ):\n raise NotImplementedError(_('.__call__() not defined'))\n \n \nclass _StoreAction(Action):\n\n def __init__(self,\n option_strings,\n dest,\n nargs=None ,\n const=None ,\n default=None ,\n type=None ,\n choices=None ,\n required=False ,\n help=None ,\n metavar=None ):\n if nargs ==0:\n raise ValueError('nargs for store actions must be > 0; if you '\n 'have nothing to store, actions such as store '\n 'true or store const may be more appropriate')\n if const is not None and nargs !=OPTIONAL:\n raise ValueError('nargs must be %r to supply const'%OPTIONAL)\n super(_StoreAction,self). __init__(\n option_strings=option_strings,\n dest=dest,\n nargs=nargs,\n const=const,\n default=default,\n type=type,\n choices=choices,\n required=required,\n help=help,\n metavar=metavar)\n \n def __call__(self,parser,namespace,values,option_string=None ):\n setattr(namespace,self. dest,values)\n \n \nclass _StoreConstAction(Action):\n\n def __init__(self,\n option_strings,\n dest,\n const,\n default=None ,\n required=False ,\n help=None ,\n metavar=None ):\n super(_StoreConstAction,self). __init__(\n option_strings=option_strings,\n dest=dest,\n nargs=0,\n const=const,\n default=default,\n required=required,\n help=help)\n \n def __call__(self,parser,namespace,values,option_string=None ):\n setattr(namespace,self. dest,self. const)\n \n \nclass _StoreTrueAction(_StoreConstAction):\n\n def __init__(self,\n option_strings,\n dest,\n default=False ,\n required=False ,\n help=None ):\n super(_StoreTrueAction,self). __init__(\n option_strings=option_strings,\n dest=dest,\n const=True ,\n default=default,\n required=required,\n help=help)\n \n \nclass _StoreFalseAction(_StoreConstAction):\n\n def __init__(self,\n option_strings,\n dest,\n default=True ,\n required=False ,\n help=None ):\n super(_StoreFalseAction,self). __init__(\n option_strings=option_strings,\n dest=dest,\n const=False ,\n default=default,\n required=required,\n help=help)\n \n \nclass _AppendAction(Action):\n\n def __init__(self,\n option_strings,\n dest,\n nargs=None ,\n const=None ,\n default=None ,\n type=None ,\n choices=None ,\n required=False ,\n help=None ,\n metavar=None ):\n if nargs ==0:\n raise ValueError('nargs for append actions must be > 0; if arg '\n 'strings are not supplying the value to append, '\n 'the append const action may be more appropriate')\n if const is not None and nargs !=OPTIONAL:\n raise ValueError('nargs must be %r to supply const'%OPTIONAL)\n super(_AppendAction,self). __init__(\n option_strings=option_strings,\n dest=dest,\n nargs=nargs,\n const=const,\n default=default,\n type=type,\n choices=choices,\n required=required,\n help=help,\n metavar=metavar)\n \n def __call__(self,parser,namespace,values,option_string=None ):\n items=_copy. copy(_ensure_value(namespace,self. dest,[]))\n items. append(values)\n setattr(namespace,self. dest,items)\n \n \nclass _AppendConstAction(Action):\n\n def __init__(self,\n option_strings,\n dest,\n const,\n default=None ,\n required=False ,\n help=None ,\n metavar=None ):\n super(_AppendConstAction,self). __init__(\n option_strings=option_strings,\n dest=dest,\n nargs=0,\n const=const,\n default=default,\n required=required,\n help=help,\n metavar=metavar)\n \n def __call__(self,parser,namespace,values,option_string=None ):\n items=_copy. copy(_ensure_value(namespace,self. dest,[]))\n items. append(self. const)\n setattr(namespace,self. dest,items)\n \n \nclass _CountAction(Action):\n\n def __init__(self,\n option_strings,\n dest,\n default=None ,\n required=False ,\n help=None ):\n super(_CountAction,self). __init__(\n option_strings=option_strings,\n dest=dest,\n nargs=0,\n default=default,\n required=required,\n help=help)\n \n def __call__(self,parser,namespace,values,option_string=None ):\n new_count=_ensure_value(namespace,self. dest,0)+1\n setattr(namespace,self. dest,new_count)\n \n \nclass _HelpAction(Action):\n\n def __init__(self,\n option_strings,\n dest=SUPPRESS,\n default=SUPPRESS,\n help=None ):\n super(_HelpAction,self). __init__(\n option_strings=option_strings,\n dest=dest,\n default=default,\n nargs=0,\n help=help)\n \n def __call__(self,parser,namespace,values,option_string=None ):\n parser. print_help()\n parser. exit()\n \n \nclass _VersionAction(Action):\n\n def __init__(self,\n option_strings,\n version=None ,\n dest=SUPPRESS,\n default=SUPPRESS,\n help=\"show program's version number and exit\"):\n super(_VersionAction,self). __init__(\n option_strings=option_strings,\n dest=dest,\n default=default,\n nargs=0,\n help=help)\n self. version=version\n \n def __call__(self,parser,namespace,values,option_string=None ):\n version=self. version\n if version is None :\n version=parser. version\n formatter=parser. _get_formatter()\n formatter. add_text(version)\n parser. _print_message(formatter. format_help(),_sys. stdout)\n parser. exit()\n \n \nclass _SubParsersAction(Action):\n\n class _ChoicesPseudoAction(Action):\n \n def __init__(self,name,aliases,help):\n metavar=dest=name\n if aliases:\n metavar +=' (%s)'%', '. join(aliases)\n sup=super(_SubParsersAction. _ChoicesPseudoAction,self)\n sup. __init__(option_strings=[],dest=dest,help=help,\n metavar=metavar)\n \n def __init__(self,\n option_strings,\n prog,\n parser_class,\n dest=SUPPRESS,\n help=None ,\n metavar=None ):\n \n self. _prog_prefix=prog\n self. _parser_class=parser_class\n self. _name_parser_map=_collections. OrderedDict()\n self. _choices_actions=[]\n \n super(_SubParsersAction,self). __init__(\n option_strings=option_strings,\n dest=dest,\n nargs=PARSER,\n choices=self. _name_parser_map,\n help=help,\n metavar=metavar)\n \n def add_parser(self,name,**kwargs):\n \n if kwargs. get('prog')is None :\n kwargs['prog']='%s %s'%(self. _prog_prefix,name)\n \n aliases=kwargs. pop('aliases',())\n \n \n if'help'in kwargs:\n help=kwargs. pop('help')\n choice_action=self. _ChoicesPseudoAction(name,aliases,help)\n self. _choices_actions. append(choice_action)\n \n \n parser=self. _parser_class(**kwargs)\n self. _name_parser_map[name]=parser\n \n \n for alias in aliases:\n self. _name_parser_map[alias]=parser\n \n return parser\n \n def _get_subactions(self):\n return self. _choices_actions\n \n def __call__(self,parser,namespace,values,option_string=None ):\n parser_name=values[0]\n arg_strings=values[1:]\n \n \n if self. dest is not SUPPRESS:\n setattr(namespace,self. dest,parser_name)\n \n \n try :\n parser=self. _name_parser_map[parser_name]\n except KeyError:\n args={'parser_name':parser_name,\n 'choices':', '. join(self. _name_parser_map)}\n msg=_('unknown parser %(parser_name)r (choices: %(choices)s)')%args\n raise ArgumentError(self,msg)\n \n \n \n \n \n \n \n \n subnamespace,arg_strings=parser. parse_known_args(arg_strings,None )\n for key,value in vars(subnamespace). items():\n setattr(namespace,key,value)\n \n if arg_strings:\n vars(namespace). setdefault(_UNRECOGNIZED_ARGS_ATTR,[])\n getattr(namespace,_UNRECOGNIZED_ARGS_ATTR). extend(arg_strings)\n \n \n \n \n \n \nclass FileType(object):\n ''\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n def __init__(self,mode='r',bufsize=-1,encoding=None ,errors=None ):\n self. _mode=mode\n self. _bufsize=bufsize\n self. _encoding=encoding\n self. _errors=errors\n \n def __call__(self,string):\n \n if string =='-':\n if'r'in self. _mode:\n return _sys. stdin\n elif'w'in self. _mode:\n return _sys. stdout\n else :\n msg=_('argument \"-\" with mode %r')%self. _mode\n raise ValueError(msg)\n \n \n try :\n return open(string,self. _mode,self. _bufsize,self. _encoding,\n self. _errors)\n except OSError as e:\n message=_(\"can't open '%s': %s\")\n raise ArgumentTypeError(message %(string,e))\n \n def __repr__(self):\n args=self. _mode,self. _bufsize\n kwargs=[('encoding',self. _encoding),('errors',self. _errors)]\n args_str=', '. join([repr(arg)for arg in args if arg !=-1]+\n ['%s=%r'%(kw,arg)for kw,arg in kwargs\n if arg is not None ])\n return'%s(%s)'%(type(self). __name__,args_str)\n \n \n \n \n \nclass Namespace(_AttributeHolder):\n ''\n\n\n\n \n \n def __init__(self,**kwargs):\n for name in kwargs:\n setattr(self,name,kwargs[name])\n \n def __eq__(self,other):\n if not isinstance(other,Namespace):\n return NotImplemented\n return vars(self)==vars(other)\n \n def __ne__(self,other):\n if not isinstance(other,Namespace):\n return NotImplemented\n return not (self ==other)\n \n def __contains__(self,key):\n return key in self. __dict__\n \n \nclass _ActionsContainer(object):\n\n def __init__(self,\n description,\n prefix_chars,\n argument_default,\n conflict_handler):\n super(_ActionsContainer,self). __init__()\n \n self. description=description\n self. argument_default=argument_default\n self. prefix_chars=prefix_chars\n self. conflict_handler=conflict_handler\n \n \n self. _registries={}\n \n \n self. register('action',None ,_StoreAction)\n self. register('action','store',_StoreAction)\n self. register('action','store_const',_StoreConstAction)\n self. register('action','store_true',_StoreTrueAction)\n self. register('action','store_false',_StoreFalseAction)\n self. register('action','append',_AppendAction)\n self. register('action','append_const',_AppendConstAction)\n self. register('action','count',_CountAction)\n self. register('action','help',_HelpAction)\n self. register('action','version',_VersionAction)\n self. register('action','parsers',_SubParsersAction)\n \n \n self. _get_handler()\n \n \n self. _actions=[]\n self. _option_string_actions={}\n \n \n self. _action_groups=[]\n self. _mutually_exclusive_groups=[]\n \n \n self. _defaults={}\n \n \n self. _negative_number_matcher=_re. compile(r'^-\\d+$|^-\\d*\\.\\d+$')\n \n \n \n self. _has_negative_number_optionals=[]\n \n \n \n \n def register(self,registry_name,value,object):\n registry=self. _registries. setdefault(registry_name,{})\n registry[value]=object\n \n def _registry_get(self,registry_name,value,default=None ):\n return self. _registries[registry_name]. get(value,default)\n \n \n \n \n def set_defaults(self,**kwargs):\n self. _defaults. update(kwargs)\n \n \n \n for action in self. _actions:\n if action. dest in kwargs:\n action. default=kwargs[action. dest]\n \n def get_default(self,dest):\n for action in self. _actions:\n if action. dest ==dest and action. default is not None :\n return action. default\n return self. _defaults. get(dest,None )\n \n \n \n \n \n def add_argument(self,*args,**kwargs):\n ''\n\n\n \n \n \n \n \n chars=self. prefix_chars\n if not args or len(args)==1 and args[0][0]not in chars:\n if args and'dest'in kwargs:\n raise ValueError('dest supplied twice for positional argument')\n kwargs=self. _get_positional_kwargs(*args,**kwargs)\n \n \n else :\n kwargs=self. _get_optional_kwargs(*args,**kwargs)\n \n \n if'default'not in kwargs:\n dest=kwargs['dest']\n if dest in self. _defaults:\n kwargs['default']=self. _defaults[dest]\n elif self. argument_default is not None :\n kwargs['default']=self. argument_default\n \n \n action_class=self. _pop_action_class(kwargs)\n if not callable(action_class):\n raise ValueError('unknown action \"%s\"'%(action_class,))\n action=action_class(**kwargs)\n \n \n type_func=self. _registry_get('type',action. type,action. type)\n if not callable(type_func):\n raise ValueError('%r is not callable'%(type_func,))\n \n \n if hasattr(self,\"_get_formatter\"):\n try :\n self. _get_formatter(). _format_args(action,None )\n except TypeError:\n raise ValueError(\"length of metavar tuple does not match nargs\")\n \n return self. _add_action(action)\n \n def add_argument_group(self,*args,**kwargs):\n group=_ArgumentGroup(self,*args,**kwargs)\n self. _action_groups. append(group)\n return group\n \n def add_mutually_exclusive_group(self,**kwargs):\n group=_MutuallyExclusiveGroup(self,**kwargs)\n self. _mutually_exclusive_groups. append(group)\n return group\n \n def _add_action(self,action):\n \n self. _check_conflict(action)\n \n \n self. _actions. append(action)\n action. container=self\n \n \n for option_string in action. option_strings:\n self. _option_string_actions[option_string]=action\n \n \n for option_string in action. option_strings:\n if self. _negative_number_matcher. match(option_string):\n if not self. _has_negative_number_optionals:\n self. _has_negative_number_optionals. append(True )\n \n \n return action\n \n def _remove_action(self,action):\n self. _actions. remove(action)\n \n def _add_container_actions(self,container):\n \n title_group_map={}\n for group in self. _action_groups:\n if group. title in title_group_map:\n msg=_('cannot merge actions - two groups are named %r')\n raise ValueError(msg %(group. title))\n title_group_map[group. title]=group\n \n \n group_map={}\n for group in container. _action_groups:\n \n \n \n if group. title not in title_group_map:\n title_group_map[group. title]=self. add_argument_group(\n title=group. title,\n description=group. description,\n conflict_handler=group. conflict_handler)\n \n \n for action in group. _group_actions:\n group_map[action]=title_group_map[group. title]\n \n \n \n \n for group in container. _mutually_exclusive_groups:\n mutex_group=self. add_mutually_exclusive_group(\n required=group. required)\n \n \n for action in group. _group_actions:\n group_map[action]=mutex_group\n \n \n for action in container. _actions:\n group_map. get(action,self). _add_action(action)\n \n def _get_positional_kwargs(self,dest,**kwargs):\n \n if'required'in kwargs:\n msg=_(\"'required' is an invalid argument for positionals\")\n raise TypeError(msg)\n \n \n \n if kwargs. get('nargs')not in [OPTIONAL,ZERO_OR_MORE]:\n kwargs['required']=True\n if kwargs. get('nargs')==ZERO_OR_MORE and'default'not in kwargs:\n kwargs['required']=True\n \n \n return dict(kwargs,dest=dest,option_strings=[])\n \n def _get_optional_kwargs(self,*args,**kwargs):\n \n option_strings=[]\n long_option_strings=[]\n for option_string in args:\n \n if not option_string[0]in self. prefix_chars:\n args={'option':option_string,\n 'prefix_chars':self. prefix_chars}\n msg=_('invalid option string %(option)r: '\n 'must start with a character %(prefix_chars)r')\n raise ValueError(msg %args)\n \n \n option_strings. append(option_string)\n if option_string[0]in self. prefix_chars:\n if len(option_string)>1:\n if option_string[1]in self. prefix_chars:\n long_option_strings. append(option_string)\n \n \n dest=kwargs. pop('dest',None )\n if dest is None :\n if long_option_strings:\n dest_option_string=long_option_strings[0]\n else :\n dest_option_string=option_strings[0]\n dest=dest_option_string. lstrip(self. prefix_chars)\n if not dest:\n msg=_('dest= is required for options like %r')\n raise ValueError(msg %option_string)\n dest=dest. replace('-','_')\n \n \n return dict(kwargs,dest=dest,option_strings=option_strings)\n \n def _pop_action_class(self,kwargs,default=None ):\n action=kwargs. pop('action',default)\n return self. _registry_get('action',action,action)\n \n def _get_handler(self):\n \n handler_func_name='_handle_conflict_%s'%self. conflict_handler\n try :\n return getattr(self,handler_func_name)\n except AttributeError:\n msg=_('invalid conflict_resolution value: %r')\n raise ValueError(msg %self. conflict_handler)\n \n def _check_conflict(self,action):\n \n \n confl_optionals=[]\n for option_string in action. option_strings:\n if option_string in self. _option_string_actions:\n confl_optional=self. _option_string_actions[option_string]\n confl_optionals. append((option_string,confl_optional))\n \n \n if confl_optionals:\n conflict_handler=self. _get_handler()\n conflict_handler(action,confl_optionals)\n \n def _handle_conflict_error(self,action,conflicting_actions):\n message=ngettext('conflicting option string: %s',\n 'conflicting option strings: %s',\n len(conflicting_actions))\n conflict_string=', '. join([option_string\n for option_string,action\n in conflicting_actions])\n raise ArgumentError(action,message %conflict_string)\n \n def _handle_conflict_resolve(self,action,conflicting_actions):\n \n \n for option_string,action in conflicting_actions:\n \n \n action. option_strings. remove(option_string)\n self. _option_string_actions. pop(option_string,None )\n \n \n \n if not action. option_strings:\n action. container. _remove_action(action)\n \n \nclass _ArgumentGroup(_ActionsContainer):\n\n def __init__(self,container,title=None ,description=None ,**kwargs):\n \n update=kwargs. setdefault\n update('conflict_handler',container. conflict_handler)\n update('prefix_chars',container. prefix_chars)\n update('argument_default',container. argument_default)\n super_init=super(_ArgumentGroup,self). __init__\n super_init(description=description,**kwargs)\n \n \n self. title=title\n self. _group_actions=[]\n \n \n self. _registries=container. _registries\n self. _actions=container. _actions\n self. _option_string_actions=container. _option_string_actions\n self. _defaults=container. _defaults\n self. _has_negative_number_optionals= container. _has_negative_number_optionals\n self. _mutually_exclusive_groups=container. _mutually_exclusive_groups\n \n def _add_action(self,action):\n action=super(_ArgumentGroup,self). _add_action(action)\n self. _group_actions. append(action)\n return action\n \n def _remove_action(self,action):\n super(_ArgumentGroup,self). _remove_action(action)\n self. _group_actions. remove(action)\n \n \nclass _MutuallyExclusiveGroup(_ArgumentGroup):\n\n def __init__(self,container,required=False ):\n super(_MutuallyExclusiveGroup,self). __init__(container)\n self. required=required\n self. _container=container\n \n def _add_action(self,action):\n if action. required:\n msg=_('mutually exclusive arguments must be optional')\n raise ValueError(msg)\n action=self. _container. _add_action(action)\n self. _group_actions. append(action)\n return action\n \n def _remove_action(self,action):\n self. _container. _remove_action(action)\n self. _group_actions. remove(action)\n \n \nclass ArgumentParser(_AttributeHolder,_ActionsContainer):\n ''\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n def __init__(self,\n prog=None ,\n usage=None ,\n description=None ,\n epilog=None ,\n parents=[],\n formatter_class=HelpFormatter,\n prefix_chars='-',\n fromfile_prefix_chars=None ,\n argument_default=None ,\n conflict_handler='error',\n add_help=True ):\n \n superinit=super(ArgumentParser,self). __init__\n superinit(description=description,\n prefix_chars=prefix_chars,\n argument_default=argument_default,\n conflict_handler=conflict_handler)\n \n \n if prog is None :\n prog=_os. path. basename(_sys. argv[0])\n \n self. prog=prog\n self. usage=usage\n self. epilog=epilog\n self. formatter_class=formatter_class\n self. fromfile_prefix_chars=fromfile_prefix_chars\n self. add_help=add_help\n \n add_group=self. add_argument_group\n self. _positionals=add_group(_('positional arguments'))\n self. _optionals=add_group(_('optional arguments'))\n self. _subparsers=None\n \n \n def identity(string):\n return string\n self. register('type',None ,identity)\n \n \n \n default_prefix='-'if'-'in prefix_chars else prefix_chars[0]\n if self. add_help:\n self. add_argument(\n default_prefix+'h',default_prefix *2+'help',\n action='help',default=SUPPRESS,\n help=_('show this help message and exit'))\n \n \n for parent in parents:\n self. _add_container_actions(parent)\n try :\n defaults=parent. _defaults\n except AttributeError:\n pass\n else :\n self. _defaults. update(defaults)\n \n \n \n \n def _get_kwargs(self):\n names=[\n 'prog',\n 'usage',\n 'description',\n 'formatter_class',\n 'conflict_handler',\n 'add_help',\n ]\n return [(name,getattr(self,name))for name in names]\n \n \n \n \n def add_subparsers(self,**kwargs):\n if self. _subparsers is not None :\n self. error(_('cannot have multiple subparser arguments'))\n \n \n kwargs. setdefault('parser_class',type(self))\n \n if'title'in kwargs or'description'in kwargs:\n title=_(kwargs. pop('title','subcommands'))\n description=_(kwargs. pop('description',None ))\n self. _subparsers=self. add_argument_group(title,description)\n else :\n self. _subparsers=self. _positionals\n \n \n \n if kwargs. get('prog')is None :\n formatter=self. _get_formatter()\n positionals=self. _get_positional_actions()\n groups=self. _mutually_exclusive_groups\n formatter. add_usage(self. usage,positionals,groups,'')\n kwargs['prog']=formatter. format_help(). strip()\n \n \n parsers_class=self. _pop_action_class(kwargs,'parsers')\n action=parsers_class(option_strings=[],**kwargs)\n self. _subparsers. _add_action(action)\n \n \n return action\n \n def _add_action(self,action):\n if action. option_strings:\n self. _optionals. _add_action(action)\n else :\n self. _positionals. _add_action(action)\n return action\n \n def _get_optional_actions(self):\n return [action\n for action in self. _actions\n if action. option_strings]\n \n def _get_positional_actions(self):\n return [action\n for action in self. _actions\n if not action. option_strings]\n \n \n \n \n def parse_args(self,args=None ,namespace=None ):\n args,argv=self. parse_known_args(args,namespace)\n if argv:\n msg=_('unrecognized arguments: %s')\n self. error(msg %' '. join(argv))\n return args\n \n def parse_known_args(self,args=None ,namespace=None ):\n if args is None :\n \n args=_sys. argv[1:]\n else :\n \n args=list(args)\n \n \n if namespace is None :\n namespace=Namespace()\n \n \n for action in self. _actions:\n if action. dest is not SUPPRESS:\n if not hasattr(namespace,action. dest):\n if action. default is not SUPPRESS:\n setattr(namespace,action. dest,action. default)\n \n \n for dest in self. _defaults:\n if not hasattr(namespace,dest):\n setattr(namespace,dest,self. _defaults[dest])\n \n \n try :\n namespace,args=self. _parse_known_args(args,namespace)\n if hasattr(namespace,_UNRECOGNIZED_ARGS_ATTR):\n args. extend(getattr(namespace,_UNRECOGNIZED_ARGS_ATTR))\n delattr(namespace,_UNRECOGNIZED_ARGS_ATTR)\n return namespace,args\n except ArgumentError:\n err=_sys. exc_info()[1]\n self. error(str(err))\n \n def _parse_known_args(self,arg_strings,namespace):\n \n if self. fromfile_prefix_chars is not None :\n arg_strings=self. _read_args_from_files(arg_strings)\n \n \n \n action_conflicts={}\n for mutex_group in self. _mutually_exclusive_groups:\n group_actions=mutex_group. _group_actions\n for i,mutex_action in enumerate(mutex_group. _group_actions):\n conflicts=action_conflicts. setdefault(mutex_action,[])\n conflicts. extend(group_actions[:i])\n conflicts. extend(group_actions[i+1:])\n \n \n \n \n option_string_indices={}\n arg_string_pattern_parts=[]\n arg_strings_iter=iter(arg_strings)\n for i,arg_string in enumerate(arg_strings_iter):\n \n \n if arg_string =='--':\n arg_string_pattern_parts. append('-')\n for arg_string in arg_strings_iter:\n arg_string_pattern_parts. append('A')\n \n \n \n else :\n option_tuple=self. _parse_optional(arg_string)\n if option_tuple is None :\n pattern='A'\n else :\n option_string_indices[i]=option_tuple\n pattern='O'\n arg_string_pattern_parts. append(pattern)\n \n \n arg_strings_pattern=''. join(arg_string_pattern_parts)\n \n \n seen_actions=set()\n seen_non_default_actions=set()\n \n def take_action(action,argument_strings,option_string=None ):\n seen_actions. add(action)\n argument_values=self. _get_values(action,argument_strings)\n \n \n \n \n if argument_values is not action. default:\n seen_non_default_actions. add(action)\n for conflict_action in action_conflicts. get(action,[]):\n if conflict_action in seen_non_default_actions:\n msg=_('not allowed with argument %s')\n action_name=_get_action_name(conflict_action)\n raise ArgumentError(action,msg %action_name)\n \n \n \n if argument_values is not SUPPRESS:\n action(self,namespace,argument_values,option_string)\n \n \n def consume_optional(start_index):\n \n \n option_tuple=option_string_indices[start_index]\n action,option_string,explicit_arg=option_tuple\n \n \n \n match_argument=self. _match_argument\n action_tuples=[]\n while True :\n \n \n if action is None :\n extras. append(arg_strings[start_index])\n return start_index+1\n \n \n \n if explicit_arg is not None :\n arg_count=match_argument(action,'A')\n \n \n \n \n chars=self. prefix_chars\n if arg_count ==0 and option_string[1]not in chars:\n action_tuples. append((action,[],option_string))\n char=option_string[0]\n option_string=char+explicit_arg[0]\n new_explicit_arg=explicit_arg[1:]or None\n optionals_map=self. _option_string_actions\n if option_string in optionals_map:\n action=optionals_map[option_string]\n explicit_arg=new_explicit_arg\n else :\n msg=_('ignored explicit argument %r')\n raise ArgumentError(action,msg %explicit_arg)\n \n \n \n elif arg_count ==1:\n stop=start_index+1\n args=[explicit_arg]\n action_tuples. append((action,args,option_string))\n break\n \n \n \n else :\n msg=_('ignored explicit argument %r')\n raise ArgumentError(action,msg %explicit_arg)\n \n \n \n \n else :\n start=start_index+1\n selected_patterns=arg_strings_pattern[start:]\n arg_count=match_argument(action,selected_patterns)\n stop=start+arg_count\n args=arg_strings[start:stop]\n action_tuples. append((action,args,option_string))\n break\n \n \n \n assert action_tuples\n for action,args,option_string in action_tuples:\n take_action(action,args,option_string)\n return stop\n \n \n \n positionals=self. _get_positional_actions()\n \n \n def consume_positionals(start_index):\n \n match_partial=self. _match_arguments_partial\n selected_pattern=arg_strings_pattern[start_index:]\n arg_counts=match_partial(positionals,selected_pattern)\n \n \n \n for action,arg_count in zip(positionals,arg_counts):\n args=arg_strings[start_index:start_index+arg_count]\n start_index +=arg_count\n take_action(action,args)\n \n \n \n positionals[:]=positionals[len(arg_counts):]\n return start_index\n \n \n \n extras=[]\n start_index=0\n if option_string_indices:\n max_option_string_index=max(option_string_indices)\n else :\n max_option_string_index=-1\n while start_index <=max_option_string_index:\n \n \n next_option_string_index=min([\n index\n for index in option_string_indices\n if index >=start_index])\n if start_index !=next_option_string_index:\n positionals_end_index=consume_positionals(start_index)\n \n \n \n if positionals_end_index >start_index:\n start_index=positionals_end_index\n continue\n else :\n start_index=positionals_end_index\n \n \n \n if start_index not in option_string_indices:\n strings=arg_strings[start_index:next_option_string_index]\n extras. extend(strings)\n start_index=next_option_string_index\n \n \n start_index=consume_optional(start_index)\n \n \n stop_index=consume_positionals(start_index)\n \n \n extras. extend(arg_strings[stop_index:])\n \n \n \n required_actions=[]\n for action in self. _actions:\n if action not in seen_actions:\n if action. required:\n required_actions. append(_get_action_name(action))\n else :\n \n \n \n \n if (action. default is not None and\n isinstance(action. default,str)and\n hasattr(namespace,action. dest)and\n action. default is getattr(namespace,action. dest)):\n setattr(namespace,action. dest,\n self. _get_value(action,action. default))\n \n if required_actions:\n self. error(_('the following arguments are required: %s')%\n ', '. join(required_actions))\n \n \n for group in self. _mutually_exclusive_groups:\n if group. required:\n for action in group. _group_actions:\n if action in seen_non_default_actions:\n break\n \n \n else :\n names=[_get_action_name(action)\n for action in group. _group_actions\n if action. help is not SUPPRESS]\n msg=_('one of the arguments %s is required')\n self. error(msg %' '. join(names))\n \n \n return namespace,extras\n \n def _read_args_from_files(self,arg_strings):\n \n new_arg_strings=[]\n for arg_string in arg_strings:\n \n \n if not arg_string or arg_string[0]not in self. fromfile_prefix_chars:\n new_arg_strings. append(arg_string)\n \n \n else :\n try :\n with open(arg_string[1:])as args_file:\n arg_strings=[]\n for arg_line in args_file. read(). splitlines():\n for arg in self. convert_arg_line_to_args(arg_line):\n arg_strings. append(arg)\n arg_strings=self. _read_args_from_files(arg_strings)\n new_arg_strings. extend(arg_strings)\n except OSError:\n err=_sys. exc_info()[1]\n self. error(str(err))\n \n \n return new_arg_strings\n \n def convert_arg_line_to_args(self,arg_line):\n return [arg_line]\n \n def _match_argument(self,action,arg_strings_pattern):\n \n nargs_pattern=self. _get_nargs_pattern(action)\n match=_re. match(nargs_pattern,arg_strings_pattern)\n \n \n if match is None :\n nargs_errors={\n None :_('expected one argument'),\n OPTIONAL:_('expected at most one argument'),\n ONE_OR_MORE:_('expected at least one argument'),\n }\n default=ngettext('expected %s argument',\n 'expected %s arguments',\n action. nargs)%action. nargs\n msg=nargs_errors. get(action. nargs,default)\n raise ArgumentError(action,msg)\n \n \n return len(match. group(1))\n \n def _match_arguments_partial(self,actions,arg_strings_pattern):\n \n \n result=[]\n for i in range(len(actions),0,-1):\n actions_slice=actions[:i]\n pattern=''. join([self. _get_nargs_pattern(action)\n for action in actions_slice])\n match=_re. match(pattern,arg_strings_pattern)\n if match is not None :\n result. extend([len(string)for string in match. groups()])\n break\n \n \n return result\n \n def _parse_optional(self,arg_string):\n \n if not arg_string:\n return None\n \n \n if not arg_string[0]in self. prefix_chars:\n return None\n \n \n if arg_string in self. _option_string_actions:\n action=self. _option_string_actions[arg_string]\n return action,arg_string,None\n \n \n if len(arg_string)==1:\n return None\n \n \n if'='in arg_string:\n option_string,explicit_arg=arg_string. split('=',1)\n if option_string in self. _option_string_actions:\n action=self. _option_string_actions[option_string]\n return action,option_string,explicit_arg\n \n \n \n option_tuples=self. _get_option_tuples(arg_string)\n \n \n if len(option_tuples)>1:\n options=', '. join([option_string\n for action,option_string,explicit_arg in option_tuples])\n args={'option':arg_string,'matches':options}\n msg=_('ambiguous option: %(option)s could match %(matches)s')\n self. error(msg %args)\n \n \n \n elif len(option_tuples)==1:\n option_tuple,=option_tuples\n return option_tuple\n \n \n \n \n if self. _negative_number_matcher. match(arg_string):\n if not self. _has_negative_number_optionals:\n return None\n \n \n if' 'in arg_string:\n return None\n \n \n \n return None ,arg_string,None\n \n def _get_option_tuples(self,option_string):\n result=[]\n \n \n \n chars=self. prefix_chars\n if option_string[0]in chars and option_string[1]in chars:\n if'='in option_string:\n option_prefix,explicit_arg=option_string. split('=',1)\n else :\n option_prefix=option_string\n explicit_arg=None\n for option_string in self. _option_string_actions:\n if option_string. startswith(option_prefix):\n action=self. _option_string_actions[option_string]\n tup=action,option_string,explicit_arg\n result. append(tup)\n \n \n \n \n elif option_string[0]in chars and option_string[1]not in chars:\n option_prefix=option_string\n explicit_arg=None\n short_option_prefix=option_string[:2]\n short_explicit_arg=option_string[2:]\n \n for option_string in self. _option_string_actions:\n if option_string ==short_option_prefix:\n action=self. _option_string_actions[option_string]\n tup=action,option_string,short_explicit_arg\n result. append(tup)\n elif option_string. startswith(option_prefix):\n action=self. _option_string_actions[option_string]\n tup=action,option_string,explicit_arg\n result. append(tup)\n \n \n else :\n self. error(_('unexpected option string: %s')%option_string)\n \n \n return result\n \n def _get_nargs_pattern(self,action):\n \n \n nargs=action. nargs\n \n \n if nargs is None :\n nargs_pattern='(-*A-*)'\n \n \n elif nargs ==OPTIONAL:\n nargs_pattern='(-*A?-*)'\n \n \n elif nargs ==ZERO_OR_MORE:\n nargs_pattern='(-*[A-]*)'\n \n \n elif nargs ==ONE_OR_MORE:\n nargs_pattern='(-*A[A-]*)'\n \n \n elif nargs ==REMAINDER:\n nargs_pattern='([-AO]*)'\n \n \n elif nargs ==PARSER:\n nargs_pattern='(-*A[-AO]*)'\n \n \n else :\n nargs_pattern='(-*%s-*)'%'-*'. join('A'*nargs)\n \n \n if action. option_strings:\n nargs_pattern=nargs_pattern. replace('-*','')\n nargs_pattern=nargs_pattern. replace('-','')\n \n \n return nargs_pattern\n \n \n \n \n def _get_values(self,action,arg_strings):\n \n if action. nargs not in [PARSER,REMAINDER]:\n try :\n arg_strings. remove('--')\n except ValueError:\n pass\n \n \n if not arg_strings and action. nargs ==OPTIONAL:\n if action. option_strings:\n value=action. const\n else :\n value=action. default\n if isinstance(value,str):\n value=self. _get_value(action,value)\n self. _check_value(action,value)\n \n \n \n elif (not arg_strings and action. nargs ==ZERO_OR_MORE and\n not action. option_strings):\n if action. default is not None :\n value=action. default\n else :\n value=arg_strings\n self. _check_value(action,value)\n \n \n elif len(arg_strings)==1 and action. nargs in [None ,OPTIONAL]:\n arg_string,=arg_strings\n value=self. _get_value(action,arg_string)\n self. _check_value(action,value)\n \n \n elif action. nargs ==REMAINDER:\n value=[self. _get_value(action,v)for v in arg_strings]\n \n \n elif action. nargs ==PARSER:\n value=[self. _get_value(action,v)for v in arg_strings]\n self. _check_value(action,value[0])\n \n \n else :\n value=[self. _get_value(action,v)for v in arg_strings]\n for v in value:\n self. _check_value(action,v)\n \n \n return value\n \n def _get_value(self,action,arg_string):\n type_func=self. _registry_get('type',action. type,action. type)\n if not callable(type_func):\n msg=_('%r is not callable')\n raise ArgumentError(action,msg %type_func)\n \n \n try :\n result=type_func(arg_string)\n \n \n except ArgumentTypeError:\n name=getattr(action. type,'__name__',repr(action. type))\n msg=str(_sys. exc_info()[1])\n raise ArgumentError(action,msg)\n \n \n except (TypeError,ValueError):\n name=getattr(action. type,'__name__',repr(action. type))\n args={'type':name,'value':arg_string}\n msg=_('invalid %(type)s value: %(value)r')\n raise ArgumentError(action,msg %args)\n \n \n return result\n \n def _check_value(self,action,value):\n \n if action. choices is not None and value not in action. choices:\n args={'value':value,\n 'choices':', '. join(map(repr,action. choices))}\n msg=_('invalid choice: %(value)r (choose from %(choices)s)')\n raise ArgumentError(action,msg %args)\n \n \n \n \n def format_usage(self):\n formatter=self. _get_formatter()\n formatter. add_usage(self. usage,self. _actions,\n self. _mutually_exclusive_groups)\n return formatter. format_help()\n \n def format_help(self):\n formatter=self. _get_formatter()\n \n \n formatter. add_usage(self. usage,self. _actions,\n self. _mutually_exclusive_groups)\n \n \n formatter. add_text(self. description)\n \n \n for action_group in self. _action_groups:\n formatter. start_section(action_group. title)\n formatter. add_text(action_group. description)\n formatter. add_arguments(action_group. _group_actions)\n formatter. end_section()\n \n \n formatter. add_text(self. epilog)\n \n \n return formatter. format_help()\n \n def _get_formatter(self):\n return self. formatter_class(prog=self. prog)\n \n \n \n \n def print_usage(self,file=None ):\n if file is None :\n file=_sys. stdout\n self. _print_message(self. format_usage(),file)\n \n def print_help(self,file=None ):\n if file is None :\n file=_sys. stdout\n self. _print_message(self. format_help(),file)\n \n def _print_message(self,message,file=None ):\n if message:\n if file is None :\n file=_sys. stderr\n file. write(message)\n \n \n \n \n def exit(self,status=0,message=None ):\n if message:\n self. _print_message(message,_sys. stderr)\n _sys. exit(status)\n \n def error(self,message):\n ''\n\n\n\n\n\n\n \n self. print_usage(_sys. stderr)\n args={'prog':self. prog,'message':message}\n self. exit(2,_('%(prog)s: error: %(message)s\\n')%args)\n"], "atexit": [".py", "''\n\n\n\n\n\nclass __loader__(object):\n pass\n \ndef _clear(*args,**kw):\n ''\n \n pass\n \ndef _run_exitfuncs(*args,**kw):\n ''\n \n pass\n \ndef register(*args,**kw):\n ''\n\n\n\n\n\n\n \n pass\n \ndef unregister(*args,**kw):\n ''\n\n\n\n \n pass\n"], "base64": [".py", "#! /usr/bin/env python3\n\n\"\"\"RFC 3548: Base16, Base32, Base64 Data Encodings\"\"\"\n\n\n\n\n\n\n\n\n\nimport _base64\nimport binascii\nimport struct\nimport io\n\nsetattr(_base64. Base64,'error',binascii. Error)\n\n__all__=[\n\n'encode','decode','encodebytes','decodebytes',\n\n'b64encode','b64decode','b32encode','b32decode',\n'b16encode','b16decode',\n\n'standard_b64encode','standard_b64decode',\n\n\n\n\n'urlsafe_b64encode','urlsafe_b64decode',\n]\n\n\nbytes_types=(bytes,bytearray)\n\ndef _bytes_from_decode_data(s):\n if isinstance(s,str):\n try :\n return s. encode('ascii')\n except UnicodeEncodeError:\n raise ValueError('string argument should contain only ASCII characters')\n elif isinstance(s,bytes_types):\n return s\n else :\n raise TypeError(\"argument should be bytes or ASCII string, not %s\"%s. __class__. __name__)\n \n \n \n \n \ndef b64encode(s,altchars=None ):\n ''\n\n\n\n\n\n\n\n \n if not isinstance(s,bytes_types):\n raise TypeError(\"expected bytes, not %s\"%s. __class__. __name__)\n if altchars is not None :\n if not isinstance(altchars,bytes_types):\n print('wrong altchars')\n raise TypeError(\"expected bytes, not %s\"\n %altchars. __class__. __name__)\n assert len(altchars)>=2,repr(altchars)\n return _base64. Base64. encode(s,altchars)\n \n \ndef b64decode(s,altchars=None ,validate=False ):\n ''\n\n\n\n\n\n\n\n\n\n\n\n \n if isinstance(s,str):\n s=bytes(s,encoding='ascii')\n if altchars is not None :\n altchars=_bytes_from_decode_data(altchars)\n return _base64. Base64. decode(s,altchars,validate)\n \n \ndef standard_b64encode(s):\n ''\n\n\n \n return b64encode(s)\n \ndef standard_b64decode(s):\n ''\n\n\n\n\n\n \n return b64decode(s)\n \n \n_urlsafe_encode_translation=bytes. maketrans(b'+/',b'-_')\n_urlsafe_decode_translation=bytes. maketrans(b'-_',b'+/')\n\ndef urlsafe_b64encode(s):\n ''\n\n\n\n\n \n return b64encode(s). translate(_urlsafe_encode_translation)\n \ndef urlsafe_b64decode(s):\n ''\n\n\n\n\n\n\n\n \n s=_bytes_from_decode_data(s)\n s=s. translate(_urlsafe_decode_translation)\n return b64decode(s)\n \n \n \n \n_b32alphabet={\n0:b'A',9:b'J',18:b'S',27:b'3',\n1:b'B',10:b'K',19:b'T',28:b'4',\n2:b'C',11:b'L',20:b'U',29:b'5',\n3:b'D',12:b'M',21:b'V',30:b'6',\n4:b'E',13:b'N',22:b'W',31:b'7',\n5:b'F',14:b'O',23:b'X',\n6:b'G',15:b'P',24:b'Y',\n7:b'H',16:b'Q',25:b'Z',\n8:b'I',17:b'R',26:b'2',\n}\n\n_b32tab=[v[0]for k,v in sorted(_b32alphabet. items())]\n_b32rev=dict([(v[0],k)for k,v in _b32alphabet. items()])\n\n\ndef b32encode(s):\n ''\n\n\n \n if not isinstance(s,bytes_types):\n raise TypeError(\"expected bytes, not %s\"%s. __class__. __name__)\n quanta,leftover=divmod(len(s),5)\n \n if leftover:\n s=s+bytes(5 -leftover)\n quanta +=1\n encoded=bytearray()\n for i in range(quanta):\n \n \n \n \n \n c1,c2,c3=struct. unpack('!HHB',s[i *5:(i+1)*5])\n c2 +=(c1&1)<<16\n c3 +=(c2&3)<<8\n encoded +=bytes([_b32tab[c1 >>11],\n _b32tab[(c1 >>6)&0x1f],\n _b32tab[(c1 >>1)&0x1f],\n _b32tab[c2 >>12],\n _b32tab[(c2 >>7)&0x1f],\n _b32tab[(c2 >>2)&0x1f],\n _b32tab[c3 >>5],\n _b32tab[c3&0x1f],\n ])\n \n if leftover ==1:\n encoded[-6:]=b'======'\n elif leftover ==2:\n encoded[-4:]=b'===='\n elif leftover ==3:\n encoded[-3:]=b'==='\n elif leftover ==4:\n encoded[-1:]=b'='\n return bytes(encoded)\n \n \ndef _strip_padchars(s):\n if isinstance(s,bytes_types):\n padchar=ord('=')\n else :\n padchar='='\n pos=-1\n while s[pos]==padchar:\n pos -=1\n pos=abs(pos+1)\n if pos ==0:\n return s,0\n else :\n return s[:-pos],pos\n \ndef b32decode(s,casefold=False ,map01=None ):\n ''\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n s=_bytes_from_decode_data(s)\n quanta,leftover=divmod(len(s),8)\n if leftover:\n raise binascii. Error('Incorrect padding')\n \n \n \n if map01 is not None :\n map01=_bytes_from_decode_data(map01)\n assert len(map01)==1,repr(map01)\n s=s. translate(bytes. maketrans(b'01',b'O'+map01))\n if casefold:\n s=s. upper()\n \n \n \n s,padchars=_strip_padchars(s)\n \n \n parts=[]\n acc=0\n shift=35\n for c in s:\n val=_b32rev. get(c)\n if val is None :\n raise binascii. Error('Non-base32 digit found')\n acc +=_b32rev[c]<<shift\n shift -=5\n if shift <0:\n parts. append(binascii. unhexlify(bytes('%010x'%acc,\"ascii\")))\n acc=0\n shift=35\n \n last=binascii. unhexlify(bytes('%010x'%acc,\"ascii\"))\n if padchars ==0:\n last=b''\n elif padchars ==1:\n last=last[:-1]\n elif padchars ==3:\n last=last[:-2]\n elif padchars ==4:\n last=last[:-3]\n elif padchars ==6:\n last=last[:-4]\n else :\n raise binascii. Error('Incorrect padding')\n parts. append(last)\n return b''. join(parts)\n \n \n \n \n \n \ndef b16encode(s):\n ''\n\n\n \n if not isinstance(s,bytes_types):\n raise TypeError(\"expected bytes, not %s\"%s. __class__. __name__)\n return binascii. hexlify(s). upper()\n \n \ndef b16decode(s,casefold=False ):\n ''\n\n\n\n\n\n\n\n\n \n s=_bytes_from_decode_data(s)\n if casefold:\n s=s. upper()\n for b in s:\n if b not in b'[0123456789ABCDEF]':\n raise binascii. Error('Non-base16 digit found')\n return binascii. unhexlify(s)\n \n \n \n \n \n \n \nMAXLINESIZE=76\nMAXBINSIZE=(MAXLINESIZE //4)*3\n\ndef encode(input,output):\n ''\n if isinstance(input,io. TextIOBase)or isinstance(output,io. TextIOBase):\n raise TypeError(\"Both input and output must be binary streams.\")\n \n while True :\n s=input. read(MAXBINSIZE)\n if not s:\n break\n while len(s)<MAXBINSIZE:\n ns=input. read(MAXBINSIZE -len(s))\n if not ns:\n break\n s +=ns\n line=binascii. b2a_base64(s)\n output. write(line)\n \n \ndef decode(input,output):\n ''\n while True :\n line=input. readline()\n if not line:\n break\n s=binascii. a2b_base64(line)\n output. write(s)\n \n \ndef encodebytes(s):\n ''\n \n if not isinstance(s,bytes_types):\n raise TypeError(\"expected bytes, not %s\"%s. __class__. __name__)\n pieces=[]\n for i in range(0,len(s),MAXBINSIZE):\n chunk=s[i:i+MAXBINSIZE]\n pieces. append(binascii. b2a_base64(chunk))\n return b\"\". join(pieces)\n \ndef encodestring(s):\n ''\n import warnings\n warnings. warn(\"encodestring() is a deprecated alias, use encodebytes()\",\n DeprecationWarning,2)\n return encodebytes(s)\n \n \ndef decodebytes(s):\n ''\n if not isinstance(s,bytes_types):\n raise TypeError(\"expected bytes, not %s\"%s. __class__. __name__)\n return binascii. a2b_base64(s)\n \ndef decodestring(s):\n ''\n import warnings\n warnings. warn(\"decodestring() is a deprecated alias, use decodebytes()\",\n DeprecationWarning,2)\n return decodebytes(s)\n \n \n \ndef main():\n ''\n import sys,getopt\n try :\n opts,args=getopt. getopt(sys. argv[1:],'deut')\n except getopt. error as msg:\n sys. stdout=sys. stderr\n print(msg)\n print(\"\"\"usage: %s [-d|-e|-u|-t] [file|-]\n -d, -u: decode\n -e: encode (default)\n -t: encode and decode string 'Aladdin:open sesame'\"\"\"%sys. argv[0])\n sys. exit(2)\n func=encode\n for o,a in opts:\n if o =='-e':func=encode\n if o =='-d':func=decode\n if o =='-u':func=decode\n if o =='-t':test();return\n if args and args[0]!='-':\n with open(args[0],'rb')as f:\n func(f,sys. stdout. buffer)\n else :\n func(sys. stdin. buffer,sys. stdout. buffer)\n \n \ndef test():\n s0=b\"Aladdin:open sesame\"\n print(repr(s0))\n s1=encodebytes(s0)\n print(repr(s1))\n s2=decodebytes(s1)\n print(repr(s2))\n assert s0 ==s2\n \n \nif __name__ =='__main__':\n main()\n"], "bdb": [".py", "''\n\nimport fnmatch\nimport sys\nimport os\nfrom inspect import CO_GENERATOR\n\n__all__=[\"BdbQuit\",\"Bdb\",\"Breakpoint\"]\n\nclass BdbQuit(Exception):\n ''\n \n \nclass Bdb:\n ''\n\n\n\n\n \n \n def __init__(self,skip=None ):\n self. skip=set(skip)if skip else None\n self. breaks={}\n self. fncache={}\n self. frame_returning=None\n \n def canonic(self,filename):\n if filename ==\"<\"+filename[1:-1]+\">\":\n return filename\n canonic=self. fncache. get(filename)\n if not canonic:\n canonic=os. path. abspath(filename)\n canonic=os. path. normcase(canonic)\n self. fncache[filename]=canonic\n return canonic\n \n def reset(self):\n import linecache\n linecache. checkcache()\n self. botframe=None\n self. _set_stopinfo(None ,None )\n \n def trace_dispatch(self,frame,event,arg):\n if self. quitting:\n return\n if event =='line':\n return self. dispatch_line(frame)\n if event =='call':\n return self. dispatch_call(frame,arg)\n if event =='return':\n return self. dispatch_return(frame,arg)\n if event =='exception':\n return self. dispatch_exception(frame,arg)\n if event =='c_call':\n return self. trace_dispatch\n if event =='c_exception':\n return self. trace_dispatch\n if event =='c_return':\n return self. trace_dispatch\n print('bdb.Bdb.dispatch: unknown debugging event:',repr(event))\n return self. trace_dispatch\n \n def dispatch_line(self,frame):\n if self. stop_here(frame)or self. break_here(frame):\n self. user_line(frame)\n if self. quitting:raise BdbQuit\n return self. trace_dispatch\n \n def dispatch_call(self,frame,arg):\n \n if self. botframe is None :\n \n self. botframe=frame. f_back\n return self. trace_dispatch\n if not (self. stop_here(frame)or self. break_anywhere(frame)):\n \n return\n \n if self. stopframe and frame. f_code. co_flags&CO_GENERATOR:\n return self. trace_dispatch\n self. user_call(frame,arg)\n if self. quitting:raise BdbQuit\n return self. trace_dispatch\n \n def dispatch_return(self,frame,arg):\n if self. stop_here(frame)or frame ==self. returnframe:\n \n if self. stopframe and frame. f_code. co_flags&CO_GENERATOR:\n return self. trace_dispatch\n try :\n self. frame_returning=frame\n self. user_return(frame,arg)\n finally :\n self. frame_returning=None\n if self. quitting:raise BdbQuit\n \n if self. stopframe is frame and self. stoplineno !=-1:\n self. _set_stopinfo(None ,None )\n return self. trace_dispatch\n \n def dispatch_exception(self,frame,arg):\n if self. stop_here(frame):\n \n \n \n if not (frame. f_code. co_flags&CO_GENERATOR\n and arg[0]is StopIteration and arg[2]is None ):\n self. user_exception(frame,arg)\n if self. quitting:raise BdbQuit\n \n \n \n \n elif (self. stopframe and frame is not self. stopframe\n and self. stopframe. f_code. co_flags&CO_GENERATOR\n and arg[0]in (StopIteration,GeneratorExit)):\n self. user_exception(frame,arg)\n if self. quitting:raise BdbQuit\n \n return self. trace_dispatch\n \n \n \n \n \n def is_skipped_module(self,module_name):\n for pattern in self. skip:\n if fnmatch. fnmatch(module_name,pattern):\n return True\n return False\n \n def stop_here(self,frame):\n \n \n if self. skip and self. is_skipped_module(frame. f_globals. get('__name__')):\n return False\n if frame is self. stopframe:\n if self. stoplineno ==-1:\n return False\n return frame. f_lineno >=self. stoplineno\n if not self. stopframe:\n return True\n return False\n \n def break_here(self,frame):\n filename=self. canonic(frame. f_code. co_filename)\n if filename not in self. breaks:\n return False\n lineno=frame. f_lineno\n if lineno not in self. breaks[filename]:\n \n \n lineno=frame. f_code. co_firstlineno\n if lineno not in self. breaks[filename]:\n return False\n \n \n (bp,flag)=effective(filename,lineno,frame)\n if bp:\n self. currentbp=bp. number\n if (flag and bp. temporary):\n self. do_clear(str(bp. number))\n return True\n else :\n return False\n \n def do_clear(self,arg):\n raise NotImplementedError(\"subclass of bdb must implement do_clear()\")\n \n def break_anywhere(self,frame):\n return self. canonic(frame. f_code. co_filename)in self. breaks\n \n \n \n \n def user_call(self,frame,argument_list):\n ''\n \n pass\n \n def user_line(self,frame):\n ''\n pass\n \n def user_return(self,frame,return_value):\n ''\n pass\n \n def user_exception(self,frame,exc_info):\n ''\n \n pass\n \n def _set_stopinfo(self,stopframe,returnframe,stoplineno=0):\n self. stopframe=stopframe\n self. returnframe=returnframe\n self. quitting=False\n \n \n self. stoplineno=stoplineno\n \n \n \n \n def set_until(self,frame,lineno=None ):\n ''\n \n \n if lineno is None :\n lineno=frame. f_lineno+1\n self. _set_stopinfo(frame,frame,lineno)\n \n def set_step(self):\n ''\n \n \n \n \n if self. frame_returning:\n caller_frame=self. frame_returning. f_back\n if caller_frame and not caller_frame. f_trace:\n caller_frame. f_trace=self. trace_dispatch\n self. _set_stopinfo(None ,None )\n \n def set_next(self,frame):\n ''\n self. _set_stopinfo(frame,None )\n \n def set_return(self,frame):\n ''\n if frame. f_code. co_flags&CO_GENERATOR:\n self. _set_stopinfo(frame,None ,-1)\n else :\n self. _set_stopinfo(frame. f_back,frame)\n \n def set_trace(self,frame=None ):\n ''\n\n\n \n if frame is None :\n frame=sys. _getframe(). f_back\n self. reset()\n while frame:\n frame. f_trace=self. trace_dispatch\n self. botframe=frame\n frame=frame. f_back\n self. set_step()\n sys. settrace(self. trace_dispatch)\n \n def set_continue(self):\n \n self. _set_stopinfo(self. botframe,None ,-1)\n if not self. breaks:\n \n sys. settrace(None )\n frame=sys. _getframe(). f_back\n while frame and frame is not self. botframe:\n del frame. f_trace\n frame=frame. f_back\n \n def set_quit(self):\n self. stopframe=self. botframe\n self. returnframe=None\n self. quitting=True\n sys. settrace(None )\n \n \n \n \n \n \n \n \n def set_break(self,filename,lineno,temporary=False ,cond=None ,\n funcname=None ):\n filename=self. canonic(filename)\n import linecache\n line=linecache. getline(filename,lineno)\n if not line:\n return'Line %s:%d does not exist'%(filename,lineno)\n list=self. breaks. setdefault(filename,[])\n if lineno not in list:\n list. append(lineno)\n bp=Breakpoint(filename,lineno,temporary,cond,funcname)\n \n def _prune_breaks(self,filename,lineno):\n if (filename,lineno)not in Breakpoint. bplist:\n self. breaks[filename]. remove(lineno)\n if not self. breaks[filename]:\n del self. breaks[filename]\n \n def clear_break(self,filename,lineno):\n filename=self. canonic(filename)\n if filename not in self. breaks:\n return'There are no breakpoints in %s'%filename\n if lineno not in self. breaks[filename]:\n return'There is no breakpoint at %s:%d'%(filename,lineno)\n \n \n for bp in Breakpoint. bplist[filename,lineno][:]:\n bp. deleteMe()\n self. _prune_breaks(filename,lineno)\n \n def clear_bpbynumber(self,arg):\n try :\n bp=self. get_bpbynumber(arg)\n except ValueError as err:\n return str(err)\n bp. deleteMe()\n self. _prune_breaks(bp. file,bp. line)\n \n def clear_all_file_breaks(self,filename):\n filename=self. canonic(filename)\n if filename not in self. breaks:\n return'There are no breakpoints in %s'%filename\n for line in self. breaks[filename]:\n blist=Breakpoint. bplist[filename,line]\n for bp in blist:\n bp. deleteMe()\n del self. breaks[filename]\n \n def clear_all_breaks(self):\n if not self. breaks:\n return'There are no breakpoints'\n for bp in Breakpoint. bpbynumber:\n if bp:\n bp. deleteMe()\n self. breaks={}\n \n def get_bpbynumber(self,arg):\n if not arg:\n raise ValueError('Breakpoint number expected')\n try :\n number=int(arg)\n except ValueError:\n raise ValueError('Non-numeric breakpoint number %s'%arg)\n try :\n bp=Breakpoint. bpbynumber[number]\n except IndexError:\n raise ValueError('Breakpoint number %d out of range'%number)\n if bp is None :\n raise ValueError('Breakpoint %d already deleted'%number)\n return bp\n \n def get_break(self,filename,lineno):\n filename=self. canonic(filename)\n return filename in self. breaks and lineno in self. breaks[filename]\n \n def get_breaks(self,filename,lineno):\n filename=self. canonic(filename)\n return filename in self. breaks and lineno in self. breaks[filename]and Breakpoint. bplist[filename,lineno]or []\n \n def get_file_breaks(self,filename):\n filename=self. canonic(filename)\n if filename in self. breaks:\n return self. breaks[filename]\n else :\n return []\n \n def get_all_breaks(self):\n return self. breaks\n \n \n \n \n def get_stack(self,f,t):\n stack=[]\n if t and t. tb_frame is f:\n t=t. tb_next\n while f is not None :\n stack. append((f,f. f_lineno))\n if f is self. botframe:\n break\n f=f. f_back\n stack. reverse()\n i=max(0,len(stack)-1)\n while t is not None :\n stack. append((t. tb_frame,t. tb_lineno))\n t=t. tb_next\n if f is None :\n i=max(0,len(stack)-1)\n return stack,i\n \n def format_stack_entry(self,frame_lineno,lprefix=': '):\n import linecache,reprlib\n frame,lineno=frame_lineno\n filename=self. canonic(frame. f_code. co_filename)\n s='%s(%r)'%(filename,lineno)\n if frame. f_code. co_name:\n s +=frame. f_code. co_name\n else :\n s +=\"<lambda>\"\n if'__args__'in frame. f_locals:\n args=frame. f_locals['__args__']\n else :\n args=None\n if args:\n s +=reprlib. repr(args)\n else :\n s +='()'\n if'__return__'in frame. f_locals:\n rv=frame. f_locals['__return__']\n s +='->'\n s +=reprlib. repr(rv)\n line=linecache. getline(filename,lineno,frame. f_globals)\n if line:\n s +=lprefix+line. strip()\n return s\n \n \n \n \n \n def run(self,cmd,globals=None ,locals=None ):\n if globals is None :\n import __main__\n globals=__main__. __dict__\n if locals is None :\n locals=globals\n self. reset()\n if isinstance(cmd,str):\n cmd=compile(cmd,\"<string>\",\"exec\")\n sys. settrace(self. trace_dispatch)\n try :\n exec(cmd,globals,locals)\n except BdbQuit:\n pass\n finally :\n self. quitting=True\n sys. settrace(None )\n \n def runeval(self,expr,globals=None ,locals=None ):\n if globals is None :\n import __main__\n globals=__main__. __dict__\n if locals is None :\n locals=globals\n self. reset()\n sys. settrace(self. trace_dispatch)\n try :\n return eval(expr,globals,locals)\n except BdbQuit:\n pass\n finally :\n self. quitting=True\n sys. settrace(None )\n \n def runctx(self,cmd,globals,locals):\n \n self. run(cmd,globals,locals)\n \n \n \n def runcall(self,func,*args,**kwds):\n self. reset()\n sys. settrace(self. trace_dispatch)\n res=None\n try :\n res=func(*args,**kwds)\n except BdbQuit:\n pass\n finally :\n self. quitting=True\n sys. settrace(None )\n return res\n \n \ndef set_trace():\n Bdb(). set_trace()\n \n \nclass Breakpoint:\n ''\n\n\n\n\n\n\n\n\n\n\n \n \n \n \n \n next=1\n bplist={}\n bpbynumber=[None ]\n \n \n \n def __init__(self,file,line,temporary=False ,cond=None ,funcname=None ):\n self. funcname=funcname\n \n self. func_first_executable_line=None\n self. file=file\n self. line=line\n self. temporary=temporary\n self. cond=cond\n self. enabled=True\n self. ignore=0\n self. hits=0\n self. number=Breakpoint. next\n Breakpoint. next +=1\n \n self. bpbynumber. append(self)\n if (file,line)in self. bplist:\n self. bplist[file,line]. append(self)\n else :\n self. bplist[file,line]=[self]\n \n def deleteMe(self):\n index=(self. file,self. line)\n self. bpbynumber[self. number]=None\n self. bplist[index]. remove(self)\n if not self. bplist[index]:\n \n del self. bplist[index]\n \n def enable(self):\n self. enabled=True\n \n def disable(self):\n self. enabled=False\n \n def bpprint(self,out=None ):\n if out is None :\n out=sys. stdout\n print(self. bpformat(),file=out)\n \n def bpformat(self):\n if self. temporary:\n disp='del '\n else :\n disp='keep '\n if self. enabled:\n disp=disp+'yes '\n else :\n disp=disp+'no '\n ret='%-4dbreakpoint %s at %s:%d'%(self. number,disp,\n self. file,self. line)\n if self. cond:\n ret +='\\n\\tstop only if %s'%(self. cond,)\n if self. ignore:\n ret +='\\n\\tignore next %d hits'%(self. ignore,)\n if self. hits:\n if self. hits >1:\n ss='s'\n else :\n ss=''\n ret +='\\n\\tbreakpoint already hit %d time%s'%(self. hits,ss)\n return ret\n \n def __str__(self):\n return'breakpoint %s at %s:%s'%(self. number,self. file,self. line)\n \n \n \ndef checkfuncname(b,frame):\n ''\n if not b. funcname:\n \n if b. line !=frame. f_lineno:\n \n \n return False\n return True\n \n \n \n if frame. f_code. co_name !=b. funcname:\n \n return False\n \n \n if not b. func_first_executable_line:\n \n b. func_first_executable_line=frame. f_lineno\n \n if b. func_first_executable_line !=frame. f_lineno:\n \n return False\n return True\n \n \n \ndef effective(file,line,frame):\n ''\n\n\n\n\n\n \n possibles=Breakpoint. bplist[file,line]\n for b in possibles:\n if not b. enabled:\n continue\n if not checkfuncname(b,frame):\n continue\n \n b. hits +=1\n if not b. cond:\n \n if b. ignore >0:\n b. ignore -=1\n continue\n else :\n \n return (b,True )\n else :\n \n \n \n try :\n val=eval(b. cond,frame. f_globals,frame. f_locals)\n if val:\n if b. ignore >0:\n b. ignore -=1\n \n else :\n return (b,True )\n \n \n except :\n \n \n \n return (b,False )\n return (None ,None )\n \n \n \n \nclass Tdb(Bdb):\n def user_call(self,frame,args):\n name=frame. f_code. co_name\n if not name:name='???'\n print('+++ call',name,args)\n def user_line(self,frame):\n import linecache\n name=frame. f_code. co_name\n if not name:name='???'\n fn=self. canonic(frame. f_code. co_filename)\n line=linecache. getline(fn,frame. f_lineno,frame. f_globals)\n print('+++',fn,frame. f_lineno,name,':',line. strip())\n def user_return(self,frame,retval):\n print('+++ return',retval)\n def user_exception(self,frame,exc_stuff):\n print('+++ exception',exc_stuff)\n self. set_continue()\n \ndef foo(n):\n print('foo(',n,')')\n x=bar(n *10)\n print('bar returned',x)\n \ndef bar(a):\n print('bar(',a,')')\n return a /2\n \ndef test():\n t=Tdb()\n t. run('import bdb; bdb.foo(10)')\n"], "binascii": [".py", "''\n\n\n\n\n\n\n\nclass Error(ValueError):\n def __init__(self,msg=''):\n self. _msg=msg\n \n def __str__(self):\n return\" binascii.Error: \"+self. _msg\n \n \nclass Done(Exception):\n pass\n \nclass Incomplete(Error):\n pass\n \ndef a2b_uu(s):\n if not s:\n return''\n \n length=(ord(s[0])-0x20)%64\n \n def quadruplets_gen(s):\n while s:\n try :\n yield ord(s[0]),ord(s[1]),ord(s[2]),ord(s[3])\n except IndexError:\n s +=' '\n yield ord(s[0]),ord(s[1]),ord(s[2]),ord(s[3])\n return\n s=s[4:]\n \n try :\n result=[''. join(\n [chr((A -0x20)<<2 |(((B -0x20)>>4)&0x3)),\n chr(((B -0x20)&0xf)<<4 |(((C -0x20)>>2)&0xf)),\n chr(((C -0x20)&0x3)<<6 |((D -0x20)&0x3f))\n ])for A,B,C,D in quadruplets_gen(s[1:]. rstrip())]\n except ValueError:\n raise Error('Illegal char')\n result=''. join(result)\n trailingdata=result[length:]\n if trailingdata. strip('\\x00'):\n raise Error('Trailing garbage')\n result=result[:length]\n if len(result)<length:\n result +=((length -len(result))*'\\x00')\n return bytes(result,__BRYTHON__. charset)\n \n \ndef b2a_uu(s):\n length=len(s)\n if length >45:\n raise Error('At most 45 bytes at once')\n \n def triples_gen(s):\n while s:\n try :\n yield ord(s[0]),ord(s[1]),ord(s[2])\n except IndexError:\n s +='\\0\\0'\n yield ord(s[0]),ord(s[1]),ord(s[2])\n return\n s=s[3:]\n \n result=[''. join(\n [chr(0x20+((A >>2)&0x3F)),\n chr(0x20+(((A <<4)|((B >>4)&0xF))&0x3F)),\n chr(0x20+(((B <<2)|((C >>6)&0x3))&0x3F)),\n chr(0x20+((C)&0x3F))])\n for A,B,C in triples_gen(s)]\n return chr(ord(' ')+(length&0o77))+''. join(result)+'\\n'\n \n \ntable_a2b_base64={\n'A':0,\n'B':1,\n'C':2,\n'D':3,\n'E':4,\n'F':5,\n'G':6,\n'H':7,\n'I':8,\n'J':9,\n'K':10,\n'L':11,\n'M':12,\n'N':13,\n'O':14,\n'P':15,\n'Q':16,\n'R':17,\n'S':18,\n'T':19,\n'U':20,\n'V':21,\n'W':22,\n'X':23,\n'Y':24,\n'Z':25,\n'a':26,\n'b':27,\n'c':28,\n'd':29,\n'e':30,\n'f':31,\n'g':32,\n'h':33,\n'i':34,\n'j':35,\n'k':36,\n'l':37,\n'm':38,\n'n':39,\n'o':40,\n'p':41,\n'q':42,\n'r':43,\n's':44,\n't':45,\n'u':46,\n'v':47,\n'w':48,\n'x':49,\n'y':50,\n'z':51,\n'0':52,\n'1':53,\n'2':54,\n'3':55,\n'4':56,\n'5':57,\n'6':58,\n'7':59,\n'8':60,\n'9':61,\n'+':62,\n'/':63,\n'=':0,\n}\n\n\ndef a2b_base64(s):\n if not isinstance(s,(str,bytes,bytearray)):\n raise TypeError(\"expected string, bytes or a bytearray, got %r\"%(s,))\n s=s. rstrip()\n \n \n \n def next_valid_char(s,pos):\n for i in range(pos+1,len(s)):\n c=s[i]\n if c <0x7f:\n try :\n table_a2b_base64[chr(c)]\n return chr(c)\n except KeyError:\n pass\n return None\n \n quad_pos=0\n leftbits=0\n leftchar=0\n res=[]\n for i,c in enumerate(s):\n if isinstance(c,int):\n c=chr(c)\n if c >'\\x7f'or c =='\\n'or c =='\\r'or c ==' ':\n continue\n if c =='=':\n if quad_pos <2 or (quad_pos ==2 and next_valid_char(s,i)!='='):\n continue\n else :\n leftbits=0\n break\n try :\n next_c=table_a2b_base64[c]\n except KeyError:\n continue\n quad_pos=(quad_pos+1)&0x03\n leftchar=(leftchar <<6)|next_c\n leftbits +=6\n if leftbits >=8:\n leftbits -=8\n res. append((leftchar >>leftbits&0xff))\n leftchar &=((1 <<leftbits)-1)\n if leftbits !=0:\n raise Error('Incorrect padding')\n \n return bytes(''. join([chr(i)for i in res]),__BRYTHON__. charset)\n \ntable_b2a_base64=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"\"0123456789+/\"\n\ndef b2a_base64(s):\n length=len(s)\n final_length=length %3\n \n def triples_gen(s):\n while s:\n try :\n yield s[0],s[1],s[2]\n except IndexError:\n s +=b'\\0\\0'\n yield s[0],s[1],s[2]\n return\n s=s[3:]\n \n a=triples_gen(s[:length -final_length])\n \n result=[''. join(\n [table_b2a_base64[(A >>2)&0x3F],\n table_b2a_base64[((A <<4)|((B >>4)&0xF))&0x3F],\n table_b2a_base64[((B <<2)|((C >>6)&0x3))&0x3F],\n table_b2a_base64[(C)&0x3F]])\n for A,B,C in a]\n \n final=s[length -final_length:]\n if final_length ==0:\n snippet=''\n elif final_length ==1:\n a=final[0]\n snippet=table_b2a_base64[(a >>2)&0x3F]+ table_b2a_base64[(a <<4)&0x3F]+'=='\n else :\n a=final[0]\n b=final[1]\n snippet=table_b2a_base64[(a >>2)&0x3F]+ table_b2a_base64[((a <<4)|(b >>4)&0xF)&0x3F]+ table_b2a_base64[(b <<2)&0x3F]+'='\n return bytes(''. join(result)+snippet+'\\n',__BRYTHON__. charset)\n \ndef a2b_qp(s,header=False ):\n inp=0\n odata=[]\n while inp <len(s):\n if s[inp]=='=':\n inp +=1\n if inp >=len(s):\n break\n \n if (s[inp]=='\\n')or (s[inp]=='\\r'):\n if s[inp]!='\\n':\n while inp <len(s)and s[inp]!='\\n':\n inp +=1\n if inp <len(s):\n inp +=1\n elif s[inp]=='=':\n \n odata. append('=')\n inp +=1\n elif s[inp]in hex_numbers and s[inp+1]in hex_numbers:\n ch=chr(int(s[inp:inp+2],16))\n inp +=2\n odata. append(ch)\n else :\n odata. append('=')\n elif header and s[inp]=='_':\n odata. append(' ')\n inp +=1\n else :\n odata. append(s[inp])\n inp +=1\n return bytes(''. join(odata),__BRYTHON__. charset)\n \ndef b2a_qp(data,quotetabs=False ,istext=True ,header=False ):\n ''\n\n\n\n\n \n MAXLINESIZE=76\n \n \n lf=data. find('\\n')\n crlf=lf >0 and data[lf -1]=='\\r'\n \n inp=0\n linelen=0\n odata=[]\n while inp <len(data):\n c=data[inp]\n if (c >'~'or\n c =='='or\n (header and c =='_')or\n (c =='.'and linelen ==0 and (inp+1 ==len(data)or\n data[inp+1]=='\\n'or\n data[inp+1]=='\\r'))or\n (not istext and (c =='\\r'or c =='\\n'))or\n ((c =='\\t'or c ==' ')and (inp+1 ==len(data)))or\n (c <=' 'and c !='\\r'and c !='\\n'and\n (quotetabs or (not quotetabs and (c !='\\t'and c !=' '))))):\n linelen +=3\n if linelen >=MAXLINESIZE:\n odata. append('=')\n if crlf:odata. append('\\r')\n odata. append('\\n')\n linelen=3\n odata. append('='+two_hex_digits(ord(c)))\n inp +=1\n else :\n if (istext and\n (c =='\\n'or (inp+1 <len(data)and c =='\\r'and\n data[inp+1]=='\\n'))):\n linelen=0\n \n if (len(odata)>0 and\n (odata[-1]==' 'or odata[-1]=='\\t')):\n ch=ord(odata[-1])\n odata[-1]='='\n odata. append(two_hex_digits(ch))\n \n if crlf:odata. append('\\r')\n odata. append('\\n')\n if c =='\\r':\n inp +=2\n else :\n inp +=1\n else :\n if (inp+1 <len(data)and\n data[inp+1]!='\\n'and\n (linelen+1)>=MAXLINESIZE):\n odata. append('=')\n if crlf:odata. append('\\r')\n odata. append('\\n')\n linelen=0\n \n linelen +=1\n if header and c ==' ':\n c='_'\n odata. append(c)\n inp +=1\n return''. join(odata)\n \nhex_numbers='0123456789ABCDEF'\ndef hex(n):\n if n ==0:\n return'0'\n \n if n <0:\n n=-n\n sign='-'\n else :\n sign=''\n arr=[]\n \n def hex_gen(n):\n ''\n while n:\n yield n %0x10\n n=n /0x10\n \n for nibble in hex_gen(n):\n arr=[hex_numbers[nibble]]+arr\n return sign+''. join(arr)\n \ndef two_hex_digits(n):\n return hex_numbers[n /0x10]+hex_numbers[n %0x10]\n \n \ndef strhex_to_int(s):\n i=0\n for c in s:\n i=i *0x10+hex_numbers. index(c)\n return i\n \nhqx_encoding='!\"#$%&\\'()*+,-012345689@ABCDEFGHIJKLMNPQRSTUVXYZ[`abcdefhijklmpqr'\n\nDONE=0x7f\nSKIP=0x7e\nFAIL=0x7d\n\ntable_a2b_hqx=[\n\nFAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,\n\nFAIL,FAIL,SKIP,FAIL,FAIL,SKIP,FAIL,FAIL,\n\nFAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,\n\nFAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,\n\nFAIL,0x00,0x01,0x02,0x03,0x04,0x05,0x06,\n\n0x07,0x08,0x09,0x0A,0x0B,0x0C,FAIL,FAIL,\n\n0x0D,0x0E,0x0F,0x10,0x11,0x12,0x13,FAIL,\n\n0x14,0x15,DONE,FAIL,FAIL,FAIL,FAIL,FAIL,\n\n0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,\n\n0x1E,0x1F,0x20,0x21,0x22,0x23,0x24,FAIL,\n\n0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,FAIL,\n\n0x2C,0x2D,0x2E,0x2F,FAIL,FAIL,FAIL,FAIL,\n\n0x30,0x31,0x32,0x33,0x34,0x35,0x36,FAIL,\n\n0x37,0x38,0x39,0x3A,0x3B,0x3C,FAIL,FAIL,\n\n0x3D,0x3E,0x3F,FAIL,FAIL,FAIL,FAIL,FAIL,\n\nFAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,\nFAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,\nFAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,\nFAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,\nFAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,\nFAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,\nFAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,\nFAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,\nFAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,\nFAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,\nFAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,\nFAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,\nFAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,\nFAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,\nFAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,\nFAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,\nFAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,FAIL,\n]\n\ndef a2b_hqx(s):\n result=[]\n \n def quadruples_gen(s):\n t=[]\n for c in s:\n res=table_a2b_hqx[ord(c)]\n if res ==SKIP:\n continue\n elif res ==FAIL:\n raise Error('Illegal character')\n elif res ==DONE:\n yield t\n raise Done\n else :\n t. append(res)\n if len(t)==4:\n yield t\n t=[]\n yield t\n \n done=0\n try :\n for snippet in quadruples_gen(s):\n length=len(snippet)\n if length ==4:\n result. append(chr(((snippet[0]&0x3f)<<2)|(snippet[1]>>4)))\n result. append(chr(((snippet[1]&0x0f)<<4)|(snippet[2]>>2)))\n result. append(chr(((snippet[2]&0x03)<<6)|(snippet[3])))\n elif length ==3:\n result. append(chr(((snippet[0]&0x3f)<<2)|(snippet[1]>>4)))\n result. append(chr(((snippet[1]&0x0f)<<4)|(snippet[2]>>2)))\n elif length ==2:\n result. append(chr(((snippet[0]&0x3f)<<2)|(snippet[1]>>4)))\n except Done:\n done=1\n except Error:\n raise\n return (''. join(result),done)\n \n \n \ndef b2a_hqx(s):\n result=[]\n \n def triples_gen(s):\n while s:\n try :\n yield ord(s[0]),ord(s[1]),ord(s[2])\n except IndexError:\n yield tuple([ord(c)for c in s])\n s=s[3:]\n \n for snippet in triples_gen(s):\n length=len(snippet)\n if length ==3:\n result. append(\n hqx_encoding[(snippet[0]&0xfc)>>2])\n result. append(hqx_encoding[\n ((snippet[0]&0x03)<<4)|((snippet[1]&0xf0)>>4)])\n result. append(hqx_encoding[\n (snippet[1]&0x0f)<<2 |((snippet[2]&0xc0)>>6)])\n result. append(hqx_encoding[snippet[2]&0x3f])\n elif length ==2:\n result. append(\n hqx_encoding[(snippet[0]&0xfc)>>2])\n result. append(hqx_encoding[\n ((snippet[0]&0x03)<<4)|((snippet[1]&0xf0)>>4)])\n result. append(hqx_encoding[\n (snippet[1]&0x0f)<<2])\n elif length ==1:\n result. append(\n hqx_encoding[(snippet[0]&0xfc)>>2])\n result. append(hqx_encoding[\n ((snippet[0]&0x03)<<4)])\n return''. join(result)\n \ncrctab_hqx=[\n0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7,\n0x8108,0x9129,0xa14a,0xb16b,0xc18c,0xd1ad,0xe1ce,0xf1ef,\n0x1231,0x0210,0x3273,0x2252,0x52b5,0x4294,0x72f7,0x62d6,\n0x9339,0x8318,0xb37b,0xa35a,0xd3bd,0xc39c,0xf3ff,0xe3de,\n0x2462,0x3443,0x0420,0x1401,0x64e6,0x74c7,0x44a4,0x5485,\n0xa56a,0xb54b,0x8528,0x9509,0xe5ee,0xf5cf,0xc5ac,0xd58d,\n0x3653,0x2672,0x1611,0x0630,0x76d7,0x66f6,0x5695,0x46b4,\n0xb75b,0xa77a,0x9719,0x8738,0xf7df,0xe7fe,0xd79d,0xc7bc,\n0x48c4,0x58e5,0x6886,0x78a7,0x0840,0x1861,0x2802,0x3823,\n0xc9cc,0xd9ed,0xe98e,0xf9af,0x8948,0x9969,0xa90a,0xb92b,\n0x5af5,0x4ad4,0x7ab7,0x6a96,0x1a71,0x0a50,0x3a33,0x2a12,\n0xdbfd,0xcbdc,0xfbbf,0xeb9e,0x9b79,0x8b58,0xbb3b,0xab1a,\n0x6ca6,0x7c87,0x4ce4,0x5cc5,0x2c22,0x3c03,0x0c60,0x1c41,\n0xedae,0xfd8f,0xcdec,0xddcd,0xad2a,0xbd0b,0x8d68,0x9d49,\n0x7e97,0x6eb6,0x5ed5,0x4ef4,0x3e13,0x2e32,0x1e51,0x0e70,\n0xff9f,0xefbe,0xdfdd,0xcffc,0xbf1b,0xaf3a,0x9f59,0x8f78,\n0x9188,0x81a9,0xb1ca,0xa1eb,0xd10c,0xc12d,0xf14e,0xe16f,\n0x1080,0x00a1,0x30c2,0x20e3,0x5004,0x4025,0x7046,0x6067,\n0x83b9,0x9398,0xa3fb,0xb3da,0xc33d,0xd31c,0xe37f,0xf35e,\n0x02b1,0x1290,0x22f3,0x32d2,0x4235,0x5214,0x6277,0x7256,\n0xb5ea,0xa5cb,0x95a8,0x8589,0xf56e,0xe54f,0xd52c,0xc50d,\n0x34e2,0x24c3,0x14a0,0x0481,0x7466,0x6447,0x5424,0x4405,\n0xa7db,0xb7fa,0x8799,0x97b8,0xe75f,0xf77e,0xc71d,0xd73c,\n0x26d3,0x36f2,0x0691,0x16b0,0x6657,0x7676,0x4615,0x5634,\n0xd94c,0xc96d,0xf90e,0xe92f,0x99c8,0x89e9,0xb98a,0xa9ab,\n0x5844,0x4865,0x7806,0x6827,0x18c0,0x08e1,0x3882,0x28a3,\n0xcb7d,0xdb5c,0xeb3f,0xfb1e,0x8bf9,0x9bd8,0xabbb,0xbb9a,\n0x4a75,0x5a54,0x6a37,0x7a16,0x0af1,0x1ad0,0x2ab3,0x3a92,\n0xfd2e,0xed0f,0xdd6c,0xcd4d,0xbdaa,0xad8b,0x9de8,0x8dc9,\n0x7c26,0x6c07,0x5c64,0x4c45,0x3ca2,0x2c83,0x1ce0,0x0cc1,\n0xef1f,0xff3e,0xcf5d,0xdf7c,0xaf9b,0xbfba,0x8fd9,0x9ff8,\n0x6e17,0x7e36,0x4e55,0x5e74,0x2e93,0x3eb2,0x0ed1,0x1ef0,\n]\n\ndef crc_hqx(s,crc):\n for c in s:\n crc=((crc <<8)&0xff00)^crctab_hqx[((crc >>8)&0xff)^ord(c)]\n \n return crc\n \ndef rlecode_hqx(s):\n ''\n\n\n\n \n if not s:\n return''\n result=[]\n prev=s[0]\n count=1\n \n \n \n \n if s[-1]=='!':\n s=s[1:]+'?'\n else :\n s=s[1:]+'!'\n \n for c in s:\n if c ==prev and count <255:\n count +=1\n else :\n if count ==1:\n if prev !='\\x90':\n result. append(prev)\n else :\n result. extend(['\\x90','\\x00'])\n elif count <4:\n if prev !='\\x90':\n result. extend([prev]*count)\n else :\n result. extend(['\\x90','\\x00']*count)\n else :\n if prev !='\\x90':\n result. extend([prev,'\\x90',chr(count)])\n else :\n result. extend(['\\x90','\\x00','\\x90',chr(count)])\n count=1\n prev=c\n \n return''. join(result)\n \ndef rledecode_hqx(s):\n s=s. split('\\x90')\n result=[s[0]]\n prev=s[0]\n for snippet in s[1:]:\n count=ord(snippet[0])\n if count >0:\n result. append(prev[-1]*(count -1))\n prev=snippet\n else :\n result. append('\\x90')\n prev='\\x90'\n result. append(snippet[1:])\n \n return''. join(result)\n \ncrc_32_tab=[\n0x00000000,0x77073096,0xee0e612c,0x990951ba,0x076dc419,\n0x706af48f,0xe963a535,0x9e6495a3,0x0edb8832,0x79dcb8a4,\n0xe0d5e91e,0x97d2d988,0x09b64c2b,0x7eb17cbd,0xe7b82d07,\n0x90bf1d91,0x1db71064,0x6ab020f2,0xf3b97148,0x84be41de,\n0x1adad47d,0x6ddde4eb,0xf4d4b551,0x83d385c7,0x136c9856,\n0x646ba8c0,0xfd62f97a,0x8a65c9ec,0x14015c4f,0x63066cd9,\n0xfa0f3d63,0x8d080df5,0x3b6e20c8,0x4c69105e,0xd56041e4,\n0xa2677172,0x3c03e4d1,0x4b04d447,0xd20d85fd,0xa50ab56b,\n0x35b5a8fa,0x42b2986c,0xdbbbc9d6,0xacbcf940,0x32d86ce3,\n0x45df5c75,0xdcd60dcf,0xabd13d59,0x26d930ac,0x51de003a,\n0xc8d75180,0xbfd06116,0x21b4f4b5,0x56b3c423,0xcfba9599,\n0xb8bda50f,0x2802b89e,0x5f058808,0xc60cd9b2,0xb10be924,\n0x2f6f7c87,0x58684c11,0xc1611dab,0xb6662d3d,0x76dc4190,\n0x01db7106,0x98d220bc,0xefd5102a,0x71b18589,0x06b6b51f,\n0x9fbfe4a5,0xe8b8d433,0x7807c9a2,0x0f00f934,0x9609a88e,\n0xe10e9818,0x7f6a0dbb,0x086d3d2d,0x91646c97,0xe6635c01,\n0x6b6b51f4,0x1c6c6162,0x856530d8,0xf262004e,0x6c0695ed,\n0x1b01a57b,0x8208f4c1,0xf50fc457,0x65b0d9c6,0x12b7e950,\n0x8bbeb8ea,0xfcb9887c,0x62dd1ddf,0x15da2d49,0x8cd37cf3,\n0xfbd44c65,0x4db26158,0x3ab551ce,0xa3bc0074,0xd4bb30e2,\n0x4adfa541,0x3dd895d7,0xa4d1c46d,0xd3d6f4fb,0x4369e96a,\n0x346ed9fc,0xad678846,0xda60b8d0,0x44042d73,0x33031de5,\n0xaa0a4c5f,0xdd0d7cc9,0x5005713c,0x270241aa,0xbe0b1010,\n0xc90c2086,0x5768b525,0x206f85b3,0xb966d409,0xce61e49f,\n0x5edef90e,0x29d9c998,0xb0d09822,0xc7d7a8b4,0x59b33d17,\n0x2eb40d81,0xb7bd5c3b,0xc0ba6cad,0xedb88320,0x9abfb3b6,\n0x03b6e20c,0x74b1d29a,0xead54739,0x9dd277af,0x04db2615,\n0x73dc1683,0xe3630b12,0x94643b84,0x0d6d6a3e,0x7a6a5aa8,\n0xe40ecf0b,0x9309ff9d,0x0a00ae27,0x7d079eb1,0xf00f9344,\n0x8708a3d2,0x1e01f268,0x6906c2fe,0xf762575d,0x806567cb,\n0x196c3671,0x6e6b06e7,0xfed41b76,0x89d32be0,0x10da7a5a,\n0x67dd4acc,0xf9b9df6f,0x8ebeeff9,0x17b7be43,0x60b08ed5,\n0xd6d6a3e8,0xa1d1937e,0x38d8c2c4,0x4fdff252,0xd1bb67f1,\n0xa6bc5767,0x3fb506dd,0x48b2364b,0xd80d2bda,0xaf0a1b4c,\n0x36034af6,0x41047a60,0xdf60efc3,0xa867df55,0x316e8eef,\n0x4669be79,0xcb61b38c,0xbc66831a,0x256fd2a0,0x5268e236,\n0xcc0c7795,0xbb0b4703,0x220216b9,0x5505262f,0xc5ba3bbe,\n0xb2bd0b28,0x2bb45a92,0x5cb36a04,0xc2d7ffa7,0xb5d0cf31,\n0x2cd99e8b,0x5bdeae1d,0x9b64c2b0,0xec63f226,0x756aa39c,\n0x026d930a,0x9c0906a9,0xeb0e363f,0x72076785,0x05005713,\n0x95bf4a82,0xe2b87a14,0x7bb12bae,0x0cb61b38,0x92d28e9b,\n0xe5d5be0d,0x7cdcefb7,0x0bdbdf21,0x86d3d2d4,0xf1d4e242,\n0x68ddb3f8,0x1fda836e,0x81be16cd,0xf6b9265b,0x6fb077e1,\n0x18b74777,0x88085ae6,0xff0f6a70,0x66063bca,0x11010b5c,\n0x8f659eff,0xf862ae69,0x616bffd3,0x166ccf45,0xa00ae278,\n0xd70dd2ee,0x4e048354,0x3903b3c2,0xa7672661,0xd06016f7,\n0x4969474d,0x3e6e77db,0xaed16a4a,0xd9d65adc,0x40df0b66,\n0x37d83bf0,0xa9bcae53,0xdebb9ec5,0x47b2cf7f,0x30b5ffe9,\n0xbdbdf21c,0xcabac28a,0x53b39330,0x24b4a3a6,0xbad03605,\n0xcdd70693,0x54de5729,0x23d967bf,0xb3667a2e,0xc4614ab8,\n0x5d681b02,0x2a6f2b94,0xb40bbe37,0xc30c8ea1,0x5a05df1b,\n0x2d02ef8d\n]\n\ndef crc32(s,crc=0):\n result=0\n crc=~int(crc)&0xffffffff\n \n for c in s:\n crc=crc_32_tab[(crc ^int(ord(c)))&0xff]^(crc >>8)\n \n \n \n result=crc ^0xffffffff\n \n if result >2 **31:\n result=((result+2 **31)%2 **32)-2 **31\n \n return result\n \ndef b2a_hex(s):\n if isinstance(s,bytes)or isinstance(s,bytearray):\n conv=lambda x:x\n unconv=lambda x:x\n else :\n conv=lambda x:ord(x)\n unconv=lambda x:chr(x)\n result=[]\n for char in s:\n c=(conv(char)>>4)&0xf\n if c >9:\n c=c+ord('a')-10\n else :\n c=c+ord('0')\n result. append(unconv(c))\n c=conv(char)&0xf\n if c >9:\n c=c+ord('a')-10\n else :\n c=c+ord('0')\n result. append(unconv(c))\n if isinstance(s,bytes):\n return bytes(result,encoding='ascii')\n if isinstance(s,bytearray):\n return bytearray(result,encoding='ascii')\n return''. join(result)\n \nhexlify=b2a_hex\n\ntable_hex=[\n-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,\n-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,\n-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,\n0,1,2,3,4,5,6,7,8,9,-1,-1,-1,-1,-1,-1,\n-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,\n-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,\n-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,\n-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1\n]\n\n\ndef a2b_hex(t):\n result=[]\n \n def pairs_gen(s):\n if isinstance(s,bytes)or isinstance(s,bytearray):\n conv=lambda x:x\n else :\n conv=lambda x:ord(x)\n while s:\n try :\n yield table_hex[conv(s[0])],table_hex[conv(s[1])]\n except IndexError:\n if len(s):\n raise TypeError('Odd-length string')\n return\n s=s[2:]\n \n for a,b in pairs_gen(t):\n if a <0 or b <0:\n raise TypeError('Non-hexadecimal digit found')\n result. append(chr((a <<4)+b))\n return bytes(''. join(result),__BRYTHON__. charset)\n \n \nunhexlify=a2b_hex\n"], "bisect": [".py", "''\n\ndef insort_right(a,x,lo=0,hi=None ):\n ''\n\n\n\n\n\n \n \n if lo <0:\n raise ValueError('lo must be non-negative')\n if hi is None :\n hi=len(a)\n while lo <hi:\n mid=(lo+hi)//2\n if x <a[mid]:hi=mid\n else :lo=mid+1\n a. insert(lo,x)\n \ninsort=insort_right\n\ndef bisect_right(a,x,lo=0,hi=None ):\n ''\n\n\n\n\n\n\n\n \n \n if lo <0:\n raise ValueError('lo must be non-negative')\n if hi is None :\n hi=len(a)\n while lo <hi:\n mid=(lo+hi)//2\n if x <a[mid]:hi=mid\n else :lo=mid+1\n return lo\n \nbisect=bisect_right\n\ndef insort_left(a,x,lo=0,hi=None ):\n ''\n\n\n\n\n\n \n \n if lo <0:\n raise ValueError('lo must be non-negative')\n if hi is None :\n hi=len(a)\n while lo <hi:\n mid=(lo+hi)//2\n if a[mid]<x:lo=mid+1\n else :hi=mid\n a. insert(lo,x)\n \n \ndef bisect_left(a,x,lo=0,hi=None ):\n ''\n\n\n\n\n\n\n\n \n \n if lo <0:\n raise ValueError('lo must be non-negative')\n if hi is None :\n hi=len(a)\n while lo <hi:\n mid=(lo+hi)//2\n if a[mid]<x:lo=mid+1\n else :hi=mid\n return lo\n \n \ntry :\n from _bisect import *\nexcept ImportError:\n pass\n"], "calendar": [".py", "''\n\n\n\n\n\n\nimport sys\nimport datetime\nimport locale as _locale\n\n__all__=[\"IllegalMonthError\",\"IllegalWeekdayError\",\"setfirstweekday\",\n\"firstweekday\",\"isleap\",\"leapdays\",\"weekday\",\"monthrange\",\n\"monthcalendar\",\"prmonth\",\"month\",\"prcal\",\"calendar\",\n\"timegm\",\"month_name\",\"month_abbr\",\"day_name\",\"day_abbr\"]\n\n\nerror=ValueError\n\n\nclass IllegalMonthError(ValueError):\n def __init__(self,month):\n self. month=month\n def __str__(self):\n return\"bad month number %r; must be 1-12\"%self. month\n \n \nclass IllegalWeekdayError(ValueError):\n def __init__(self,weekday):\n self. weekday=weekday\n def __str__(self):\n return\"bad weekday number %r; must be 0 (Monday) to 6 (Sunday)\"%self. weekday\n \n \n \nJanuary=1\nFebruary=2\n\n\nmdays=[0,31,28,31,30,31,30,31,31,30,31,30,31]\n\n\n\n\n\n\nclass _localized_month:\n\n _months=[datetime. date(2001,i+1,1). strftime for i in range(12)]\n _months. insert(0,lambda x:\"\")\n \n def __init__(self,format):\n self. format=format\n \n def __getitem__(self,i):\n funcs=self. _months[i]\n if isinstance(i,slice):\n return [f(self. format)for f in funcs]\n else :\n return funcs(self. format)\n \n def __len__(self):\n return 13\n \n \nclass _localized_day:\n\n\n _days=[datetime. date(2001,1,i+1). strftime for i in range(7)]\n \n def __init__(self,format):\n self. format=format\n \n def __getitem__(self,i):\n funcs=self. _days[i]\n if isinstance(i,slice):\n return [f(self. format)for f in funcs]\n else :\n return funcs(self. format)\n \n def __len__(self):\n return 7\n \n \n \nday_name=_localized_day('%A')\nday_abbr=_localized_day('%a')\n\n\nmonth_name=_localized_month('%B')\nmonth_abbr=_localized_month('%b')\n\n\n(MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY,SUNDAY)=range(7)\n\n\ndef isleap(year):\n ''\n return year %4 ==0 and (year %100 !=0 or year %400 ==0)\n \n \ndef leapdays(y1,y2):\n ''\n \n y1 -=1\n y2 -=1\n return (y2 //4 -y1 //4)-(y2 //100 -y1 //100)+(y2 //400 -y1 //400)\n \n \ndef weekday(year,month,day):\n ''\n \n return datetime. date(year,month,day). weekday()\n \n \ndef monthrange(year,month):\n ''\n \n if not 1 <=month <=12:\n raise IllegalMonthError(month)\n day1=weekday(year,month,1)\n ndays=mdays[month]+(month ==February and isleap(year))\n return day1,ndays\n \n \nclass Calendar(object):\n ''\n\n\n \n \n def __init__(self,firstweekday=0):\n self. firstweekday=firstweekday\n \n def getfirstweekday(self):\n return self. _firstweekday %7\n \n def setfirstweekday(self,firstweekday):\n self. _firstweekday=firstweekday\n \n firstweekday=property(getfirstweekday,setfirstweekday)\n \n def iterweekdays(self):\n ''\n\n\n \n for i in range(self. firstweekday,self. firstweekday+7):\n yield i %7\n \n def itermonthdates(self,year,month):\n ''\n\n\n\n \n date=datetime. date(year,month,1)\n \n days=(date. weekday()-self. firstweekday)%7\n date -=datetime. timedelta(days=days)\n oneday=datetime. timedelta(days=1)\n while True :\n yield date\n try :\n date +=oneday\n except OverflowError:\n \n break\n if date. month !=month and date. weekday()==self. firstweekday:\n break\n \n def itermonthdays2(self,year,month):\n ''\n\n\n \n for date in self. itermonthdates(year,month):\n if date. month !=month:\n yield (0,date. weekday())\n else :\n yield (date. day,date. weekday())\n \n def itermonthdays(self,year,month):\n ''\n\n\n \n for date in self. itermonthdates(year,month):\n if date. month !=month:\n yield 0\n else :\n yield date. day\n \n def monthdatescalendar(self,year,month):\n ''\n\n\n \n dates=list(self. itermonthdates(year,month))\n return [dates[i:i+7]for i in range(0,len(dates),7)]\n \n def monthdays2calendar(self,year,month):\n ''\n\n\n\n\n \n days=list(self. itermonthdays2(year,month))\n return [days[i:i+7]for i in range(0,len(days),7)]\n \n def monthdayscalendar(self,year,month):\n ''\n\n\n \n days=list(self. itermonthdays(year,month))\n return [days[i:i+7]for i in range(0,len(days),7)]\n \n def yeardatescalendar(self,year,width=3):\n ''\n\n\n\n\n \n months=[\n self. monthdatescalendar(year,i)\n for i in range(January,January+12)\n ]\n return [months[i:i+width]for i in range(0,len(months),width)]\n \n def yeardays2calendar(self,year,width=3):\n ''\n\n\n\n\n \n months=[\n self. monthdays2calendar(year,i)\n for i in range(January,January+12)\n ]\n return [months[i:i+width]for i in range(0,len(months),width)]\n \n def yeardayscalendar(self,year,width=3):\n ''\n\n\n\n \n months=[\n self. monthdayscalendar(year,i)\n for i in range(January,January+12)\n ]\n return [months[i:i+width]for i in range(0,len(months),width)]\n \n \nclass TextCalendar(Calendar):\n ''\n\n\n \n \n def prweek(self,theweek,width):\n ''\n\n \n print(self. formatweek(theweek,width),end=' ')\n \n def formatday(self,day,weekday,width):\n ''\n\n \n if day ==0:\n s=''\n else :\n s='%2i'%day\n return s. center(width)\n \n def formatweek(self,theweek,width):\n ''\n\n \n return' '. join(self. formatday(d,wd,width)for (d,wd)in theweek)\n \n def formatweekday(self,day,width):\n ''\n\n \n if width >=9:\n names=day_name\n else :\n names=day_abbr\n return names[day][:width]. center(width)\n \n def formatweekheader(self,width):\n ''\n\n \n return' '. join(self. formatweekday(i,width)for i in self. iterweekdays())\n \n def formatmonthname(self,theyear,themonth,width,withyear=True ):\n ''\n\n \n s=month_name[themonth]\n if withyear:\n s=\"%s %r\"%(s,theyear)\n return s. center(width)\n \n def prmonth(self,theyear,themonth,w=0,l=0):\n ''\n\n \n print(self. formatmonth(theyear,themonth,w,l),end=' ')\n \n def formatmonth(self,theyear,themonth,w=0,l=0):\n ''\n\n \n w=max(2,w)\n l=max(1,l)\n s=self. formatmonthname(theyear,themonth,7 *(w+1)-1)\n s=s. rstrip()\n s +='\\n'*l\n s +=self. formatweekheader(w). rstrip()\n s +='\\n'*l\n for week in self. monthdays2calendar(theyear,themonth):\n s +=self. formatweek(week,w). rstrip()\n s +='\\n'*l\n return s\n \n def formatyear(self,theyear,w=2,l=1,c=6,m=3):\n ''\n\n \n w=max(2,w)\n l=max(1,l)\n c=max(2,c)\n colwidth=(w+1)*7 -1\n v=[]\n a=v. append\n a(repr(theyear). center(colwidth *m+c *(m -1)). rstrip())\n a('\\n'*l)\n header=self. formatweekheader(w)\n for (i,row)in enumerate(self. yeardays2calendar(theyear,m)):\n \n months=range(m *i+1,min(m *(i+1)+1,13))\n a('\\n'*l)\n names=(self. formatmonthname(theyear,k,colwidth,False )\n for k in months)\n a(formatstring(names,colwidth,c). rstrip())\n a('\\n'*l)\n headers=(header for k in months)\n a(formatstring(headers,colwidth,c). rstrip())\n a('\\n'*l)\n \n height=max(len(cal)for cal in row)\n for j in range(height):\n weeks=[]\n for cal in row:\n if j >=len(cal):\n weeks. append('')\n else :\n weeks. append(self. formatweek(cal[j],w))\n a(formatstring(weeks,colwidth,c). rstrip())\n a('\\n'*l)\n return''. join(v)\n \n def pryear(self,theyear,w=0,l=0,c=6,m=3):\n ''\n print(self. formatyear(theyear,w,l,c,m))\n \n \nclass HTMLCalendar(Calendar):\n ''\n\n \n \n \n cssclasses=[\"mon\",\"tue\",\"wed\",\"thu\",\"fri\",\"sat\",\"sun\"]\n \n def formatday(self,day,weekday):\n ''\n\n \n if day ==0:\n return'<td class=\"noday\">&nbsp;</td>'\n else :\n return'<td class=\"%s\">%d</td>'%(self. cssclasses[weekday],day)\n \n def formatweek(self,theweek):\n ''\n\n \n s=''. join(self. formatday(d,wd)for (d,wd)in theweek)\n return'<tr>%s</tr>'%s\n \n def formatweekday(self,day):\n ''\n\n \n return'<th class=\"%s\">%s</th>'%(self. cssclasses[day],day_abbr[day])\n \n def formatweekheader(self):\n ''\n\n \n s=''. join(self. formatweekday(i)for i in self. iterweekdays())\n return'<tr>%s</tr>'%s\n \n def formatmonthname(self,theyear,themonth,withyear=True ):\n ''\n\n \n if withyear:\n s='%s %s'%(month_name[themonth],theyear)\n else :\n s='%s'%month_name[themonth]\n return'<tr><th colspan=\"7\" class=\"month\">%s</th></tr>'%s\n \n def formatmonth(self,theyear,themonth,withyear=True ):\n ''\n\n \n v=[]\n a=v. append\n a('<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"month\">')\n a('\\n')\n a(self. formatmonthname(theyear,themonth,withyear=withyear))\n a('\\n')\n a(self. formatweekheader())\n a('\\n')\n for week in self. monthdays2calendar(theyear,themonth):\n a(self. formatweek(week))\n a('\\n')\n a('</table>')\n a('\\n')\n return''. join(v)\n \n def formatyear(self,theyear,width=3):\n ''\n\n \n v=[]\n a=v. append\n width=max(width,1)\n a('<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"year\">')\n a('\\n')\n a('<tr><th colspan=\"%d\" class=\"year\">%s</th></tr>'%(width,theyear))\n for i in range(January,January+12,width):\n \n months=range(i,min(i+width,13))\n a('<tr>')\n for m in months:\n a('<td>')\n a(self. formatmonth(theyear,m,withyear=False ))\n a('</td>')\n a('</tr>')\n a('</table>')\n return''. join(v)\n \n def formatyearpage(self,theyear,width=3,css='calendar.css',encoding=None ):\n ''\n\n \n if encoding is None :\n encoding=sys. getdefaultencoding()\n v=[]\n a=v. append\n a('<?xml version=\"1.0\" encoding=\"%s\"?>\\n'%encoding)\n a('<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\\n')\n a('<html>\\n')\n a('<head>\\n')\n a('<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\" />\\n'%encoding)\n if css is not None :\n a('<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\" />\\n'%css)\n a('<title>Calendar for %d</title>\\n'%theyear)\n a('</head>\\n')\n a('<body>\\n')\n a(self. formatyear(theyear,width))\n a('</body>\\n')\n a('</html>\\n')\n return''. join(v). encode(encoding,\"xmlcharrefreplace\")\n \n \nclass different_locale:\n def __init__(self,locale):\n self. locale=locale\n \n def __enter__(self):\n self. oldlocale=_locale. getlocale(_locale. LC_TIME)\n _locale. setlocale(_locale. LC_TIME,self. locale)\n \n def __exit__(self,*args):\n _locale. setlocale(_locale. LC_TIME,self. oldlocale)\n \n \nclass LocaleTextCalendar(TextCalendar):\n ''\n\n\n\n\n \n \n def __init__(self,firstweekday=0,locale=None ):\n TextCalendar. __init__(self,firstweekday)\n if locale is None :\n locale=_locale. getdefaultlocale()\n self. locale=locale\n \n def formatweekday(self,day,width):\n with different_locale(self. locale):\n if width >=9:\n names=day_name\n else :\n names=day_abbr\n name=names[day]\n return name[:width]. center(width)\n \n def formatmonthname(self,theyear,themonth,width,withyear=True ):\n with different_locale(self. locale):\n s=month_name[themonth]\n if withyear:\n s=\"%s %r\"%(s,theyear)\n return s. center(width)\n \n \nclass LocaleHTMLCalendar(HTMLCalendar):\n ''\n\n\n\n\n \n def __init__(self,firstweekday=0,locale=None ):\n HTMLCalendar. __init__(self,firstweekday)\n if locale is None :\n locale=_locale. getdefaultlocale()\n self. locale=locale\n \n def formatweekday(self,day):\n with different_locale(self. locale):\n s=day_abbr[day]\n return'<th class=\"%s\">%s</th>'%(self. cssclasses[day],s)\n \n def formatmonthname(self,theyear,themonth,withyear=True ):\n with different_locale(self. locale):\n s=month_name[themonth]\n if withyear:\n s='%s %s'%(s,theyear)\n return'<tr><th colspan=\"7\" class=\"month\">%s</th></tr>'%s\n \n \n \nc=TextCalendar()\n\nfirstweekday=c. getfirstweekday\n\ndef setfirstweekday(firstweekday):\n if not MONDAY <=firstweekday <=SUNDAY:\n raise IllegalWeekdayError(firstweekday)\n c. firstweekday=firstweekday\n \nmonthcalendar=c. monthdayscalendar\nprweek=c. prweek\nweek=c. formatweek\nweekheader=c. formatweekheader\nprmonth=c. prmonth\nmonth=c. formatmonth\ncalendar=c. formatyear\nprcal=c. pryear\n\n\n\n_colwidth=7 *3 -1\n_spacing=6\n\n\ndef format(cols,colwidth=_colwidth,spacing=_spacing):\n ''\n print(formatstring(cols,colwidth,spacing))\n \n \ndef formatstring(cols,colwidth=_colwidth,spacing=_spacing):\n ''\n spacing *=' '\n return spacing. join(c. center(colwidth)for c in cols)\n \n \nEPOCH=1970\n_EPOCH_ORD=datetime. date(EPOCH,1,1). toordinal()\n\n\ndef timegm(tuple):\n ''\n year,month,day,hour,minute,second=tuple[:6]\n days=datetime. date(year,month,1). toordinal()-_EPOCH_ORD+day -1\n hours=days *24+hour\n minutes=hours *60+minute\n seconds=minutes *60+second\n return seconds\n \n \ndef main(args):\n import optparse\n parser=optparse. OptionParser(usage=\"usage: %prog [options] [year [month]]\")\n parser. add_option(\n \"-w\",\"--width\",\n dest=\"width\",type=\"int\",default=2,\n help=\"width of date column (default 2, text only)\"\n )\n parser. add_option(\n \"-l\",\"--lines\",\n dest=\"lines\",type=\"int\",default=1,\n help=\"number of lines for each week (default 1, text only)\"\n )\n parser. add_option(\n \"-s\",\"--spacing\",\n dest=\"spacing\",type=\"int\",default=6,\n help=\"spacing between months (default 6, text only)\"\n )\n parser. add_option(\n \"-m\",\"--months\",\n dest=\"months\",type=\"int\",default=3,\n help=\"months per row (default 3, text only)\"\n )\n parser. add_option(\n \"-c\",\"--css\",\n dest=\"css\",default=\"calendar.css\",\n help=\"CSS to use for page (html only)\"\n )\n parser. add_option(\n \"-L\",\"--locale\",\n dest=\"locale\",default=None ,\n help=\"locale to be used from month and weekday names\"\n )\n parser. add_option(\n \"-e\",\"--encoding\",\n dest=\"encoding\",default=None ,\n help=\"Encoding to use for output.\"\n )\n parser. add_option(\n \"-t\",\"--type\",\n dest=\"type\",default=\"text\",\n choices=(\"text\",\"html\"),\n help=\"output type (text or html)\"\n )\n \n (options,args)=parser. parse_args(args)\n \n if options. locale and not options. encoding:\n parser. error(\"if --locale is specified --encoding is required\")\n sys. exit(1)\n \n locale=options. locale,options. encoding\n \n if options. type ==\"html\":\n if options. locale:\n cal=LocaleHTMLCalendar(locale=locale)\n else :\n cal=HTMLCalendar()\n encoding=options. encoding\n if encoding is None :\n encoding=sys. getdefaultencoding()\n optdict=dict(encoding=encoding,css=options. css)\n write=sys. stdout. buffer. write\n if len(args)==1:\n write(cal. formatyearpage(datetime. date. today(). year,**optdict))\n elif len(args)==2:\n write(cal. formatyearpage(int(args[1]),**optdict))\n else :\n parser. error(\"incorrect number of arguments\")\n sys. exit(1)\n else :\n if options. locale:\n cal=LocaleTextCalendar(locale=locale)\n else :\n cal=TextCalendar()\n optdict=dict(w=options. width,l=options. lines)\n if len(args)!=3:\n optdict[\"c\"]=options. spacing\n optdict[\"m\"]=options. months\n if len(args)==1:\n result=cal. formatyear(datetime. date. today(). year,**optdict)\n elif len(args)==2:\n result=cal. formatyear(int(args[1]),**optdict)\n elif len(args)==3:\n result=cal. formatmonth(int(args[1]),int(args[2]),**optdict)\n else :\n parser. error(\"incorrect number of arguments\")\n sys. exit(1)\n write=sys. stdout. write\n if options. encoding:\n result=result. encode(options. encoding)\n write=sys. stdout. buffer. write\n write(result)\n \n \nif __name__ ==\"__main__\":\n main(sys. argv)\n"], "cmath": [".py", "\n\n\n\n\n\n\n\n\n\nimport math\nimport sys\n\ndef takes_complex(func):\n def decorated(x):\n if isinstance(x,complex):\n return func(x)\n elif type(x)in [int,float]:\n return func(complex(x))\n elif hasattr(x,'__complex__'):\n c=x. __complex__()\n if not isinstance(c,complex):\n raise TypeError(\"A complex number is required\")\n else :\n return func(c)\n elif hasattr(x,'__float__'):\n try :\n c=complex(x. __float__(),0)\n except :\n raise TypeError(\"A complex number is required\")\n return func(c)\n else :\n raise TypeError(\"A complex number is required\")\n if hasattr(func,'__doc__'):\n decorated. __doc__=func. __doc__\n if hasattr(func,'__name__'):\n decorated. __name__=func. __name__\n return decorated\n \n@takes_complex\ndef isfinite(x):\n return math. isfinite(x. imag)and math. isfinite(x. real)\n \n@takes_complex\ndef phase(x):\n ''\n return math. atan2(x. imag,x. real)\n \n@takes_complex\ndef polar(x):\n ''\n\n\n\n\n \n phi=math. atan2(x. imag,x. real)\n r=math. sqrt(x. real **2+x. imag **2)\n return r,phi\n \ndef rect(r,phi):\n ''\n\n \n if math. isinf(r)or math. isinf(phi):\n \n \n if math. isinf(phi)and r !=.0 and not math. isnan(r):\n raise ValueError(\"math domain error\")\n \n \n \n \n if -_INF <phi <_INF and phi !=.0:\n if r >0:\n _real=math. copysign(_INF,math. cos(phi))\n _imag=math. copysign(_INF,math. sin(phi))\n else :\n _real=-math. copysign(_INF,cos(phi));\n _imag=-math. copysign(_INF,sin(phi));\n return complex(_real,_imag)\n return _SPECIAL_VALUE(complex(r,phi),_rect_special_values)\n \n else :\n if phi ==.0:\n \n \n \n return complex(r,phi *r)\n else :\n return complex(r *math. cos(phi),r *math. sin(phi))\n \n@takes_complex\ndef sqrt(x):\n ''\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n s,d,ax,ay=.0,.0,math. fabs(x. real),math. fabs(x. imag)\n \n ret=_SPECIAL_VALUE(x,_sqrt_special_values)\n if ret is not None :\n return ret\n \n if x. real ==.0 and x. imag ==.0:\n _real=.0\n _imag=x. imag\n return complex(_real,_imag)\n \n if ax <sys. float_info. min and ay <sys. float_info. min and (ax >0. or ay >0.):\n \n ax=math. ldexp(ax,_CM_SCALE_UP);\n s=math. ldexp(math. sqrt(ax+math. hypot(ax,math. ldexp(ay,_CM_SCALE_UP))),_CM_SCALE_DOWN)\n else :\n ax /=8.0 ;\n s=2.0 *math. sqrt(ax+math. hypot(ax,ay /8.0));\n \n d=ay /(2.0 *s)\n \n if x. real >=.0:\n _real=s ;\n _imag=math. copysign(d,x. imag)\n else :\n _real=d ;\n _imag=math. copysign(s,x. imag)\n \n return complex(_real,_imag)\n \n@takes_complex\ndef acos(x):\n ''\n\n\n\n\n \n \n ret=_SPECIAL_VALUE(x,_acos_special_values)\n if ret is not None :\n return ret\n \n if math. fabs(x. real)>_CM_LARGE_DOUBLE or math. fabs(x. imag)>_CM_LARGE_DOUBLE:\n \n \n _real=math. atan2(math. fabs(x. imag),x. real)\n \n \n \n if x. real <0:\n _imag=-math. copysign(math. log(math. hypot(x. real /2.,x. imag /2.))+_M_LN2 *2.,x. imag);\n else :\n _imag=math. copysign(math. log(math. hypot(x. real /2.,x. imag /2.))+_M_LN2 *2.,-x. imag);\n else :\n s1=complex(float(1 -x. real),-x. imag)\n s1=sqrt(s1)\n s2=complex(1.0+x. real,x. imag)\n s2=sqrt(s2)\n _real=2.0 *math. atan2(s1. real,s2. real);\n _imag=math. asinh(s2. real *s1. imag -s2. imag *s1. real)\n \n return complex(_real,_imag)\n \n@takes_complex\ndef acosh(x):\n ''\n\n\n\n \n ret=_SPECIAL_VALUE(x,_acosh_special_values)\n if ret is not None :\n return ret\n \n if math. fabs(x. real)>_CM_LARGE_DOUBLE or math. fabs(x. imag)>_CM_LARGE_DOUBLE:\n \n _real=math. log(math. hypot(x. real /2.0,x. imag /2.0))+_M_LN2 *2.0\n _imag=math. atan2(x. imag,x. real);\n else :\n s1=sqrt(complex(x. real -1.0,x. imag))\n s2=sqrt(complex(x. real+1.0,x. imag))\n _real=math. asinh(s1. real *s2. real+s1. imag *s2. imag)\n _imag=2. *math. atan2(s1. imag,s2. real)\n \n return complex(_real,_imag)\n \n@takes_complex\ndef asin(x):\n ''\n\n\n\n \n \n s=complex(-x. imag,x. real)\n s=asinh(s)\n return complex(s. imag,-s. real)\n \n@takes_complex\ndef asinh(x):\n ''\n\n\n\n\n \n ret=_SPECIAL_VALUE(x,_asinh_special_values)\n if ret is not None :\n return ret\n \n if math. fabs(x. real)>_CM_LARGE_DOUBLE or math. fabs(x. imag)>_CM_LARGE_DOUBLE:\n if x. imag >=.0:\n _real=math. copysign(math. log(math. hypot(x. real /2.,x. imag /2.))+_M_LN2 *2.,x. real)\n else :\n _real=-math. copysign(math. log(math. hypot(x. real /2.,x. imag /2.))+_M_LN2 *2.,-x. real)\n _imag=math. atan2(x. imag,math. fabs(x. real))\n else :\n s1=sqrt(complex(1.0+x. imag,-x. real))\n s2=sqrt(complex(1.0 -x. imag,x. real))\n _real=math. asinh(s1. real *s2. imag -s2. real *s1. imag)\n _imag=math. atan2(x. imag,s1. real *s2. real -s1. imag *s2. imag)\n return complex(_real,_imag)\n \n@takes_complex\ndef atan(x):\n ''\n\n\n\n\n \n s=atanh(complex(-x. imag,x. real))\n return complex(s. imag,-s. real)\n \n@takes_complex\ndef atanh(x):\n ''\n\n\n\n\n \n \n ret=_SPECIAL_VALUE(x,_atanh_special_values)\n if ret is not None :\n return ret\n \n \n if x. real <.0:\n return -(atanh(-x))\n \n ay=math. fabs(x. imag)\n \n if x. real >_CM_SQRT_LARGE_DOUBLE or ay >_CM_SQRT_LARGE_DOUBLE:\n \n \n \n \n \n h=math. hypot(x. real /2.,x. imag /2.)\n _real=x. real /4. /h /h\n \n \n \n \n \n \n _imag=-math. copysign(math. pi /2.,-x. imag)\n \n elif x. real ==1.0 and ay <_CM_SQRT_DBL_MIN:\n \n \n if (ay ==.0):\n raise ValueError(\"math domain error\")\n else :\n _real=-math. log(math. sqrt(ay)/math. sqrt(math. hypot(ay,2.)))\n _imag=math. copysign(math. atan2(2.0,-ay)/2,x. imag)\n \n else :\n \n _real=math. log1p(4. *x. real /((1 -x. real)*(1 -x. real)+ay *ay))/4.\n _imag=-math. atan2(-2. *x. imag,(1 -x. real)*(1+x. real)-ay *ay)/2.\n errno=0\n \n return complex(_real,_imag)\n \n@takes_complex\ndef cos(x):\n ''\n return cosh(complex(-x. imag,x. real))\n \n@takes_complex\ndef cosh(x):\n ''\n \n \n if isinf(x):\n if -_INF <x. imag <_INF and x. imag !=.0:\n if x. real >0:\n _real=math. copysign(_INF,math. cos(x. imag))\n _imag=math. copysign(_INF,math. sin(x. imag))\n else :\n _real=math. copysign(_INF,math. cos(x. imag))\n _imag=-math. copysign(_INF,math. sin(x. imag))\n return complex(_real,_imag)\n else :\n \n if x. imag !=.0 and not math. isnan(x. real):\n raise ValueError(\"math domain error\")\n return _SPECIAL_VALUE(x,_cosh_special_values)\n \n if math. fabs(x. real)>_CM_LOG_LARGE_DOUBLE:\n \n \n x_minus_one=x. real -math. copysign(1.0,x. real)\n _real=cos(x. imag)*math. cosh(x_minus_one)*math. e\n _imag=sin(x. imag)*math. sinh(x_minus_one)*math. e\n else :\n _real=math. cos(x. imag)*math. cosh(x. real)\n _imag=math. sin(x. imag)*math. sinh(x. real)\n \n ret=complex(_real,_imag)\n \n if isinf(ret):\n raise OverflowError()\n return ret\n \n@takes_complex\ndef exp(x):\n ''\n if math. isinf(x. real)or math. isinf(x. imag):\n \n if math. isinf(x. imag)and (-_INF <x. real <_INF or math. isinf(x. real)and x. real >0):\n raise ValueError(\"math domain error\")\n \n if math. isinf(x. real)and -_INF <x. imag <_INF and x. imag !=.0:\n if x. real >0:\n _real=math. copysign(_INF,cos(x. imag))\n _imag=math. copysign(_INF,sin(x. imag))\n else :\n _real=math. copysign(.0,cos(x. imag))\n _imag=math. copysign(.0,sin(x. imag))\n return complex(_real,_imag)\n \n return _SPECIAL_VALUE(x,_exp_special_values)\n \n \n if x. real >_CM_LOG_LARGE_DOUBLE:\n l=math. exp(x. real -1.);\n _real=l *math. cos(x. imag)*math. e\n _imag=l *math. sin(x. imag)*math. e\n else :\n l=math. exp(x. real);\n _real=l *math. cos(x. imag)\n _imag=l *math. sin(x. imag)\n \n if math. isinf(_real)or math. isinf(_imag):\n raise OverflowError()\n \n return complex(_real,_imag)\n \n@takes_complex\ndef isinf(x):\n ''\n return math. isinf(x. real)or math. isinf(x. imag)\n \n@takes_complex\ndef isnan(x):\n ''\n return math. isnan(x. real)or math. isnan(x. imag)\n \n \n@takes_complex\ndef _to_complex(x):\n return x\n \ndef log(x,base=None ):\n ''\n\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n x=_to_complex(x)\n \n \n \n \n \n \n if base is not None :\n x=log(x)\n base=log(base)\n x=x /base\n \n ret=_SPECIAL_VALUE(x,_log_special_values)\n if ret is not None :\n return ret\n \n ax=math. fabs(x. real)\n ay=math. fabs(x. imag)\n \n if ax >_CM_LARGE_DOUBLE or ay >_CM_LARGE_DOUBLE:\n _real=math. log(math. hypot(ax /2.0,ay /2.0))+_M_LN2\n elif ax <sys. float_info. min and ay <sys. float_info. min:\n if ax >.0 or ay >.0:\n \n _real=math. log(math. hypot(math. ldexp(ax,sys. float_info. mant_dig),math. ldexp(ay,sys. float_info. mant_dig)))-sys. float_info. mant_dig *_M_LN2\n else :\n \n raise ValueError(\"math domain error\")\n _real=-_INF\n _imag=math. atan2(x. imag,x. real)\n else :\n h=math. hypot(ax,ay)\n if 0.71 <=h and h <=1.73:\n am=max(ax,ay)\n an=min(ax,ay)\n _real=math. log1p((am -1)*(am+1)+an *an)/2.\n else :\n _real=math. log(h)\n _imag=math. atan2(x. imag,x. real)\n return complex(_real,_imag)\n \n@takes_complex\ndef log10(x):\n ''\n\n\n\n \n ret=log(x);\n _real=ret. real /_M_LN10\n _imag=ret. imag /_M_LN10\n return complex(_real,_imag)\n \n@takes_complex\ndef sin(x):\n ''\n \n s=complex(-x. imag,x. real)\n s=sinh(s)\n return complex(s. imag,-s. real)\n \n@takes_complex\ndef sinh(x):\n ''\n \n if math. isinf(x. real)or math. isinf(x. imag):\n \n \n if math. isinf(x. imag)and not math. isnan(x. real):\n raise ValueError(\"math domain error\")\n \n if math. isinf(x. real)and -_INF <x. imag <_INF and x. imag !=.0:\n if x. real >0:\n _real=math. copysign(_INF,cos(x. imag))\n _imag=math. copysign(_INF,sin(x. imag))\n else :\n _real=-math. copysign(_INF,cos(x. imag))\n _imag=math. copysign(_INF,sin(x. imag))\n return complex(_real,_imag)\n \n return _SPECIAL_VALUE(x,_sinh_special_values)\n \n if math. fabs(x. real)>_CM_LOG_LARGE_DOUBLE:\n x_minus_one=x. real -math. copysign(1.0,x. real)\n _real=math. cos(x. imag)*math. sinh(x. imag)*math. e\n _imag=math. sin(x. imag)*math. cosh(x. imag)*math. e\n else :\n _real=math. cos(x. imag)*math. sinh(x. real)\n _imag=math. sin(x. imag)*math. cosh(x. real)\n \n if math. isinf(_real)or math. isinf(_imag):\n raise OverflowError()\n \n return complex(_real,_imag)\n \n@takes_complex\ndef tan(x):\n ''\n s=atanh(complex(-x. imag,x. real))\n return complex(s. imag,-s. real)\n \n@takes_complex\ndef tanh(x):\n ''\n ''\n\n\n \n \n \n \n \n \n \n \n \n \n \n if isinf(x):\n if math. isinf(x. imag)and -_INF <x. real <_INF:\n raise ValueError(\"math domain error\")\n \n \n if math. isinf(x. real)and -_INF <x. imag <_INF and x. imag !=.0:\n if x. real >0:\n _real=1.0\n _imag=math. copysign(.0,2.0 *math. sin(x. imag)*math. cos(x. imag))\n else :\n _real=-1.0\n _imag=math. copysign(.0,2. *math. sin(x. imag)*math. cos(x. imag))\n return complex(_real,_imag)\n return _SPECIAL_VALUE(x,_tanh_special_values)\n \n \n if math. fabs(x. real)>_CM_LOG_LARGE_DOUBLE:\n _real=math. copysign(1.,x. real)\n _imag=4. *math. sin(x. imag)*math. cos(x. imag)*math. exp(-2. *math. fabs(x. real))\n else :\n tx=math. tanh(x. real)\n ty=math. tan(x. imag)\n cx=1.0 /math. cosh(x. real)\n txty=tx *ty\n denom=1.+txty *txty\n _real=tx *(1.+ty *ty)/denom\n _imag=((ty /denom)*cx)*cx\n return complex(_real,_imag)\n \n \npi=math. pi\ne=math. e\n\n_CM_LARGE_DOUBLE=sys. float_info. max /4\n_CM_SQRT_LARGE_DOUBLE=math. sqrt(_CM_LARGE_DOUBLE)\n_CM_LOG_LARGE_DOUBLE=math. log(_CM_LARGE_DOUBLE)\n_CM_SQRT_DBL_MIN=math. sqrt(sys. float_info. min)\n_M_LN2=0.6931471805599453094\n_M_LN10=2.302585092994045684\n\nif sys. float_info. radix ==2:\n _CM_SCALE_UP=int((2 *(sys. float_info. mant_dig /2)+1))\nelif sys. float_info. radix ==16:\n _CM_SCALE_UP=int((4 *sys. float_info. mant_dig+1))\nelse :\n raise (\"cmath implementation expects the float base to be either 2 or 16, got \"+str(sys. float_info. radix)+\" instead.\")\n_CM_SCALE_DOWN=int((-(_CM_SCALE_UP+1)/2))\n\n_INF=float('inf')\n_NAN=float('nan')\n_PI=math. pi\n_P14=0.25 *math. pi\n_P12=0.5 *math. pi\n_P34=0.75 *math. pi\n_U=-9.5426319407711027e33\n\n\n_ST_NINF=0\n_ST_NEG=1\n_ST_NZERO=2\n_ST_PZERO=3\n_ST_POS=4\n_ST_PINF=5\n_ST_NAN=6\n\n\ndef _SPECIAL_VALUE(z,table):\n if not math. isfinite(z. real)or not math. isfinite(z. imag):\n return table[_special_type(z. real)][_special_type(z. imag)]\n else :\n return None\n \ndef _special_type(x):\n if -_INF <x <_INF:\n if x !=0:\n if math. copysign(1.0,x)==1.0:\n return _ST_POS\n else :\n return _ST_NEG\n else :\n if math. copysign(1.0,x)==1.0:\n return _ST_PZERO\n else :\n return _ST_NZERO\n if math. isnan(x):\n return _ST_NAN\n if math. copysign(1.0,x)==1.0:\n return _ST_PINF\n else :\n return _ST_NINF\n \n_acos_special_values=[\n[complex(_P34,_INF),complex(_PI,_INF),complex(_PI,_INF),complex(_PI,-_INF),complex(_PI,-_INF),complex(_P34,-_INF),complex(_NAN,_INF)],\n[complex(_P12,_INF),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_P12,-_INF),complex(_NAN,_NAN)],\n[complex(_P12,_INF),complex(_U,_U),complex(_P12,0.),complex(_P12,-0.),complex(_U,_U),complex(_P12,-_INF),complex(_P12,_NAN)],\n[complex(_P12,_INF),complex(_U,_U),complex(_P12,0.),complex(_P12,-0.),complex(_U,_U),complex(_P12,-_INF),complex(_P12,_NAN)],\n[complex(_P12,_INF),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_P12,-_INF),complex(_NAN,_NAN)],\n[complex(_P14,_INF),complex(0.,_INF),complex(0.,_INF),complex(0.,-_INF),complex(0.,-_INF),complex(_P14,-_INF),complex(_NAN,_INF)],\n[complex(_NAN,_INF),complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_NAN,-_INF),complex(_NAN,_NAN)],\n]\n\n_acosh_special_values=[\n[complex(_INF,-_P34),complex(_INF,-_PI),complex(_INF,-_PI),complex(_INF,_PI),complex(_INF,_PI),complex(_INF,_P34),complex(_INF,_NAN)],\n[complex(_INF,-_P12),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_INF,_P12),complex(_NAN,_NAN)],\n[complex(_INF,-_P12),complex(_U,_U),complex(0.,-_P12),complex(0.,_P12),complex(_U,_U),complex(_INF,_P12),complex(_NAN,_NAN)],\n[complex(_INF,-_P12),complex(_U,_U),complex(0.,-_P12),complex(0.,_P12),complex(_U,_U),complex(_INF,_P12),complex(_NAN,_NAN)],\n[complex(_INF,-_P12),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_INF,_P12),complex(_NAN,_NAN)],\n[complex(_INF,-_P14),complex(_INF,-0.),complex(_INF,-0.),complex(_INF,0.),complex(_INF,0.),complex(_INF,_P14),complex(_INF,_NAN)],\n[complex(_INF,_NAN),complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_INF,_NAN),complex(_NAN,_NAN)],\n]\n\n_asinh_special_values=[\n[complex(-_INF,-_P14),complex(-_INF,-0.),complex(-_INF,-0.),complex(-_INF,0.),complex(-_INF,0.),complex(-_INF,_P14),complex(-_INF,_NAN)],\n[complex(-_INF,-_P12),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(-_INF,_P12),complex(_NAN,_NAN)],\n[complex(-_INF,-_P12),complex(_U,_U),complex(-0.,-0.),complex(-0.,0.),complex(_U,_U),complex(-_INF,_P12),complex(_NAN,_NAN)],\n[complex(_INF,-_P12),complex(_U,_U),complex(0.,-0.),complex(0.,0.),complex(_U,_U),complex(_INF,_P12),complex(_NAN,_NAN)],\n[complex(_INF,-_P12),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_INF,_P12),complex(_NAN,_NAN)],\n[complex(_INF,-_P14),complex(_INF,-0.),complex(_INF,-0.),complex(_INF,0.),complex(_INF,0.),complex(_INF,_P14),complex(_INF,_NAN)],\n[complex(_INF,_NAN),complex(_NAN,_NAN),complex(_NAN,-0.),complex(_NAN,0.),complex(_NAN,_NAN),complex(_INF,_NAN),complex(_NAN,_NAN)],\n]\n\n_atanh_special_values=[\n[complex(-0.,-_P12),complex(-0.,-_P12),complex(-0.,-_P12),complex(-0.,_P12),complex(-0.,_P12),complex(-0.,_P12),complex(-0.,_NAN)],\n[complex(-0.,-_P12),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(-0.,_P12),complex(_NAN,_NAN)],\n[complex(-0.,-_P12),complex(_U,_U),complex(-0.,-0.),complex(-0.,0.),complex(_U,_U),complex(-0.,_P12),complex(-0.,_NAN)],\n[complex(0.,-_P12),complex(_U,_U),complex(0.,-0.),complex(0.,0.),complex(_U,_U),complex(0.,_P12),complex(0.,_NAN)],\n[complex(0.,-_P12),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(0.,_P12),complex(_NAN,_NAN)],\n[complex(0.,-_P12),complex(0.,-_P12),complex(0.,-_P12),complex(0.,_P12),complex(0.,_P12),complex(0.,_P12),complex(0.,_NAN)],\n[complex(0.,-_P12),complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_NAN,_NAN),complex(0.,_P12),complex(_NAN,_NAN)],\n]\n\n_cosh_special_values=[\n[complex(_INF,_NAN),complex(_U,_U),complex(_INF,0.),complex(_INF,-0.),complex(_U,_U),complex(_INF,_NAN),complex(_INF,_NAN)],\n[complex(_NAN,_NAN),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_NAN,_NAN),complex(_NAN,_NAN)],\n[complex(_NAN,0.),complex(_U,_U),complex(1.,0.),complex(1.,-0.),complex(_U,_U),complex(_NAN,0.),complex(_NAN,0.)],\n[complex(_NAN,0.),complex(_U,_U),complex(1.,-0.),complex(1.,0.),complex(_U,_U),complex(_NAN,0.),complex(_NAN,0.)],\n[complex(_NAN,_NAN),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_NAN,_NAN),complex(_NAN,_NAN)],\n[complex(_INF,_NAN),complex(_U,_U),complex(_INF,-0.),complex(_INF,0.),complex(_U,_U),complex(_INF,_NAN),complex(_INF,_NAN)],\n[complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_NAN,0.),complex(_NAN,0.),complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_NAN,_NAN)],\n]\n\n_exp_special_values=[\n[complex(0.,0.),complex(_U,_U),complex(0.,-0.),complex(0.,0.),complex(_U,_U),complex(0.,0.),complex(0.,0.)],\n[complex(_NAN,_NAN),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_NAN,_NAN),complex(_NAN,_NAN)],\n[complex(_NAN,_NAN),complex(_U,_U),complex(1.,-0.),complex(1.,0.),complex(_U,_U),complex(_NAN,_NAN),complex(_NAN,_NAN)],\n[complex(_NAN,_NAN),complex(_U,_U),complex(1.,-0.),complex(1.,0.),complex(_U,_U),complex(_NAN,_NAN),complex(_NAN,_NAN)],\n[complex(_NAN,_NAN),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_NAN,_NAN),complex(_NAN,_NAN)],\n[complex(_INF,_NAN),complex(_U,_U),complex(_INF,-0.),complex(_INF,0.),complex(_U,_U),complex(_INF,_NAN),complex(_INF,_NAN)],\n[complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_NAN,-0.),complex(_NAN,0.),complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_NAN,_NAN)],\n]\n\n_log_special_values=[\n[complex(_INF,-_P34),complex(_INF,-_PI),complex(_INF,-_PI),complex(_INF,_PI),complex(_INF,_PI),complex(_INF,_P34),complex(_INF,_NAN)],\n[complex(_INF,-_P12),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_INF,_P12),complex(_NAN,_NAN)],\n[complex(_INF,-_P12),complex(_U,_U),complex(-_INF,-_PI),complex(-_INF,_PI),complex(_U,_U),complex(_INF,_P12),complex(_NAN,_NAN)],\n[complex(_INF,-_P12),complex(_U,_U),complex(-_INF,-0.),complex(-_INF,0.),complex(_U,_U),complex(_INF,_P12),complex(_NAN,_NAN)],\n[complex(_INF,-_P12),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_INF,_P12),complex(_NAN,_NAN)],\n[complex(_INF,-_P14),complex(_INF,-0.),complex(_INF,-0.),complex(_INF,0.),complex(_INF,0.),complex(_INF,_P14),complex(_INF,_NAN)],\n[complex(_INF,_NAN),complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_INF,_NAN),complex(_NAN,_NAN)],\n]\n\n_sinh_special_values=[\n[complex(_INF,_NAN),complex(_U,_U),complex(-_INF,-0.),complex(-_INF,0.),complex(_U,_U),complex(_INF,_NAN),complex(_INF,_NAN)],\n[complex(_NAN,_NAN),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_NAN,_NAN),complex(_NAN,_NAN)],\n[complex(0.,_NAN),complex(_U,_U),complex(-0.,-0.),complex(-0.,0.),complex(_U,_U),complex(0.,_NAN),complex(0.,_NAN)],\n[complex(0.,_NAN),complex(_U,_U),complex(0.,-0.),complex(0.,0.),complex(_U,_U),complex(0.,_NAN),complex(0.,_NAN)],\n[complex(_NAN,_NAN),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_NAN,_NAN),complex(_NAN,_NAN)],\n[complex(_INF,_NAN),complex(_U,_U),complex(_INF,-0.),complex(_INF,0.),complex(_U,_U),complex(_INF,_NAN),complex(_INF,_NAN)],\n[complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_NAN,-0.),complex(_NAN,0.),complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_NAN,_NAN)],\n]\n\n_sqrt_special_values=[\n[complex(_INF,-_INF),complex(0.,-_INF),complex(0.,-_INF),complex(0.,_INF),complex(0.,_INF),complex(_INF,_INF),complex(_NAN,_INF)],\n[complex(_INF,-_INF),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_INF,_INF),complex(_NAN,_NAN)],\n[complex(_INF,-_INF),complex(_U,_U),complex(0.,-0.),complex(0.,0.),complex(_U,_U),complex(_INF,_INF),complex(_NAN,_NAN)],\n[complex(_INF,-_INF),complex(_U,_U),complex(0.,-0.),complex(0.,0.),complex(_U,_U),complex(_INF,_INF),complex(_NAN,_NAN)],\n[complex(_INF,-_INF),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_INF,_INF),complex(_NAN,_NAN)],\n[complex(_INF,-_INF),complex(_INF,-0.),complex(_INF,-0.),complex(_INF,0.),complex(_INF,0.),complex(_INF,_INF),complex(_INF,_NAN)],\n[complex(_INF,-_INF),complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_INF,_INF),complex(_NAN,_NAN)],\n]\n\n_tanh_special_values=[\n[complex(-1.,0.),complex(_U,_U),complex(-1.,-0.),complex(-1.,0.),complex(_U,_U),complex(-1.,0.),complex(-1.,0.)],\n[complex(_NAN,_NAN),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_NAN,_NAN),complex(_NAN,_NAN)],\n[complex(_NAN,_NAN),complex(_U,_U),complex(-0.,-0.),complex(-0.,0.),complex(_U,_U),complex(_NAN,_NAN),complex(_NAN,_NAN)],\n[complex(_NAN,_NAN),complex(_U,_U),complex(0.,-0.),complex(0.,0.),complex(_U,_U),complex(_NAN,_NAN),complex(_NAN,_NAN)],\n[complex(_NAN,_NAN),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_NAN,_NAN),complex(_NAN,_NAN)],\n[complex(1.,0.),complex(_U,_U),complex(1.,-0.),complex(1.,0.),complex(_U,_U),complex(1.,0.),complex(1.,0.)],\n[complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_NAN,-0.),complex(_NAN,0.),complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_NAN,_NAN)],\n]\n\n_rect_special_values=[\n[complex(_INF,_NAN),complex(_U,_U),complex(-_INF,0.),complex(-_INF,-0.),complex(_U,_U),complex(_INF,_NAN),complex(_INF,_NAN)],\n[complex(_NAN,_NAN),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_NAN,_NAN),complex(_NAN,_NAN)],\n[complex(0.,0.),complex(_U,_U),complex(-0.,0.),complex(-0.,-0.),complex(_U,_U),complex(0.,0.),complex(0.,0.)],\n[complex(0.,0.),complex(_U,_U),complex(0.,-0.),complex(0.,0.),complex(_U,_U),complex(0.,0.),complex(0.,0.)],\n[complex(_NAN,_NAN),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_U,_U),complex(_NAN,_NAN),complex(_NAN,_NAN)],\n[complex(_INF,_NAN),complex(_U,_U),complex(_INF,-0.),complex(_INF,0.),complex(_U,_U),complex(_INF,_NAN),complex(_INF,_NAN)],\n[complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_NAN,0.),complex(_NAN,0.),complex(_NAN,_NAN),complex(_NAN,_NAN),complex(_NAN,_NAN)],\n]\n"], "cmd": [".py", "''\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nimport string,sys\n\n__all__=[\"Cmd\"]\n\nPROMPT='(Cmd) '\nIDENTCHARS=string. ascii_letters+string. digits+'_'\n\nclass Cmd:\n ''\n\n\n\n\n\n\n\n\n\n \n prompt=PROMPT\n identchars=IDENTCHARS\n ruler='='\n lastcmd=''\n intro=None\n doc_leader=\"\"\n doc_header=\"Documented commands (type help <topic>):\"\n misc_header=\"Miscellaneous help topics:\"\n undoc_header=\"Undocumented commands:\"\n nohelp=\"*** No help on %s\"\n use_rawinput=1\n \n def __init__(self,completekey='tab',stdin=None ,stdout=None ):\n ''\n\n\n\n\n\n\n\n\n \n if stdin is not None :\n self. stdin=stdin\n else :\n self. stdin=sys. stdin\n if stdout is not None :\n self. stdout=stdout\n else :\n self. stdout=sys. stdout\n self. cmdqueue=[]\n self. completekey=completekey\n \n def cmdloop(self,intro=None ):\n ''\n\n\n\n \n \n self. preloop()\n if self. use_rawinput and self. completekey:\n try :\n import readline\n self. old_completer=readline. get_completer()\n readline. set_completer(self. complete)\n readline. parse_and_bind(self. completekey+\": complete\")\n except ImportError:\n pass\n try :\n if intro is not None :\n self. intro=intro\n if self. intro:\n self. stdout. write(str(self. intro)+\"\\n\")\n stop=None\n while not stop:\n if self. cmdqueue:\n line=self. cmdqueue. pop(0)\n else :\n if self. use_rawinput:\n try :\n line=input(self. prompt)\n except EOFError:\n line='EOF'\n else :\n self. stdout. write(self. prompt)\n self. stdout. flush()\n line=self. stdin. readline()\n if not len(line):\n line='EOF'\n else :\n line=line. rstrip('\\r\\n')\n line=self. precmd(line)\n stop=self. onecmd(line)\n stop=self. postcmd(stop,line)\n self. postloop()\n finally :\n if self. use_rawinput and self. completekey:\n try :\n import readline\n readline. set_completer(self. old_completer)\n except ImportError:\n pass\n \n \n def precmd(self,line):\n ''\n\n\n \n return line\n \n def postcmd(self,stop,line):\n ''\n return stop\n \n def preloop(self):\n ''\n pass\n \n def postloop(self):\n ''\n\n\n \n pass\n \n def parseline(self,line):\n ''\n\n\n \n line=line. strip()\n if not line:\n return None ,None ,line\n elif line[0]=='?':\n line='help '+line[1:]\n elif line[0]=='!':\n if hasattr(self,'do_shell'):\n line='shell '+line[1:]\n else :\n return None ,None ,line\n i,n=0,len(line)\n while i <n and line[i]in self. identchars:i=i+1\n cmd,arg=line[:i],line[i:]. strip()\n return cmd,arg,line\n \n def onecmd(self,line):\n ''\n\n\n\n\n\n\n\n \n cmd,arg,line=self. parseline(line)\n if not line:\n return self. emptyline()\n if cmd is None :\n return self. default(line)\n self. lastcmd=line\n if line =='EOF':\n self. lastcmd=''\n if cmd =='':\n return self. default(line)\n else :\n try :\n func=getattr(self,'do_'+cmd)\n except AttributeError:
View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment