/** * Minified by jsDelivr using Terser v5.3.5. * Original file: /npm/brython@3.9.1/brython.js * * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files */ var __BRYTHON__=__BRYTHON__||{};try{eval("async function* f(){}")}catch(e){console.warn("Your browser is not fully supported. If you are using Microsoft Edge, please upgrade to the latest version")}!function(e){var t;e.isWebWorker="undefined"!=typeof WorkerGlobalScope&&"function"==typeof importScripts&&navigator instanceof WorkerNavigator,e.isNode="undefined"!=typeof process&&"node"===process.release.name;var r,n=(t=e.isNode?{location:{href:"",origin:"",pathname:""},navigator:{userLanguage:""}}:self).location.href;if(e.protocol=n.split(":")[0],e.BigInt=t.BigInt,e.indexedDB=t.indexedDB,void 0===e.brython_path){var o;if(e.isWebWorker)(o=t.location.href).startsWith("blob:")&&(o=o.substr(5));else{var a=document.getElementsByTagName("script");o=a[a.length-1].src}var s=o.split("/");s.pop(),r=e.brython_path=s.join("/")+"/"}else e.brython_path.endsWith("/")||(e.brython_path+="/"),r=e.brython_path;var i=(t.location.origin+t.location.pathname).split("/");i.pop();var _=e.script_dir=i.join("/");if(e.__ARGV=[],e.webworkers={},e.$py_module_path={},e.file_cache={},e.$py_src={},e.path=[r+"Lib",r+"libs",_,r+"Lib/site-packages"],e.async_enabled=!1,e.async_enabled&&(e.block={}),e.imported={},e.precompiled={},e.frames_stack=[],e.builtins={},e.builtins_scope={id:"__builtins__",module:"__builtins__",binding:{}},e.builtin_funcs={},e.builtin_classes=[],e.__getattr__=function(e){return this[e]},e.__setattr__=function(t,r){if(!(["debug","stdout","stderr"].indexOf(t)>-1))throw e.builtins.AttributeError.$factory("__BRYTHON__ object has no attribute "+t);e[t]=r},e.language=t.navigator.userLanguage||t.navigator.language,e.locale="C",e.isWebWorker?e.charset="utf-8":e.charset=document.characterSet||document.inputEncoding||"utf-8",e.max_int=Math.pow(2,53)-1,e.min_int=-e.max_int,e.$py_next_hash=Math.pow(2,53)-1,e.$py_UUID=0,e.lambda_magic=Math.random().toString(36).substr(2,8),e.set_func_names=function(t,r){if(t.$infos){var n=t.$infos.__name__;t.$infos.__module__=r,t.$infos.__qualname__=n}else{n=t.__name__;t.$infos={__name__:n,__module__:r,__qualname__:n}}for(var o in t.__module__=r,t)"function"==typeof t[o]&&(t[o].$infos={__doc__:t[o].__doc__||"",__module__:r,__qualname__:n+"."+o,__name__:o},"classmethod"==t[o].$type&&(t[o].__class__=e.method))},"undefined"!=typeof Storage){e.has_local_storage=!1;try{localStorage&&(e.local_storage=localStorage,e.has_local_storage=!0)}catch(e){}e.has_session_storage=!1;try{sessionStorage&&(e.session_storage=sessionStorage,e.has_session_storage=!0)}catch(e){}}else e.has_local_storage=!1,e.has_session_storage=!1;e.globals=function(){return e.frames_stack[e.frames_stack.length-1][3]},e.scripts={},e.$options={},e.update_VFS=function(t){e.VFS=e.VFS||{};var r=t.$timestamp;for(var n in void 0!==r&&delete t.$timestamp,t)e.VFS.hasOwnProperty(n)&&console.warn("Virtual File System: duplicate entry "+n),e.VFS[n]=t[n],e.VFS[n].timestamp=r},e.add_files=function(t){for(var r in e.files=e.files||{},t)e.files[r]=t[r]},e.python_to_js=function(t,r){e.meta_path=e.$meta_path.slice(),e.use_VFS||e.meta_path.shift(),void 0===r&&(r="__main__");var n=__BRYTHON__.py2js(t,r,r).to_js();return n="(function() {\n var $locals_"+r+" = {}\n"+n+"\n}())"},t.py=function(t){var r=e.py2js(t[0],"script","script").to_js();e.set_import_paths(),new Function("$locals_script",r)({})}}(__BRYTHON__),__BRYTHON__.implementation=[3,9,1,"final",0],__BRYTHON__.__MAGIC__="3.9.1",__BRYTHON__.version_info=[3,9,0,"final",0],__BRYTHON__.compiled_date="2021-01-04 17:16:14.255913",__BRYTHON__.timestamp=1609776974255,__BRYTHON__.builtin_module_names=["_aio","_ajax","_base64","_binascii","_cmath","_io_classes","_json","_jsre","_locale","_multiprocessing","_posixsubprocess","_profile","_sre_utils","_string","_strptime","_svg","_webcomponent","_webworker","_zlib_utils","array","bry_re","builtins","dis","encoding_cp932","hashlib","html_parser","long_int","marshal","math","math1","modulefinder","posix","python_re","random","unicodedata"],function($B){var js,$pos,res,$op;Number.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},Number.isSafeInteger=Number.isSafeInteger||function(e){return Number.isInteger(e)&&Math.abs(e)<=Number.MAX_SAFE_INTEGER};var _b_=$B.builtins,_window;_window=$B.isNode?{location:{href:"",origin:"",pathname:""}}:self,$B.parser={};var clone=$B.clone=function(e){var t={};for(var r in e)t[r]=e[r];return t};$B.last=function(e){return void 0===e&&console.log($B.frames_stack.slice()),e[e.length-1]},$B.list2obj=function(e,t){var r={},n=e.length;for(void 0===t&&(t=!0);n-- >0;)r[e[n]]=t;return r},$B.op2method={operations:{"**":"pow","//":"floordiv","<<":"lshift",">>":"rshift","+":"add","-":"sub","*":"mul","/":"truediv","%":"mod","@":"matmul"},augmented_assigns:{"//=":"ifloordiv",">>=":"irshift","<<=":"ilshift","**=":"ipow","+=":"iadd","-=":"isub","*=":"imul","/=":"itruediv","%=":"imod","&=":"iand","|=":"ior","^=":"ixor","@=":"imatmul"},binary:{"&":"and","|":"or","~":"invert","^":"xor"},comparisons:{"<":"lt",">":"gt","<=":"le",">=":"ge","==":"eq","!=":"ne"},boolean:{or:"or",and:"and",in:"in",not:"not",is:"is",not_in:"not_in",is_not:"is_not"},subset:function(){var e={},t=[];if("all"==arguments[0])(t=Object.keys($B.op2method)).splice(t.indexOf("subset"),1);else for(var r=0,n=arguments.length;r",">=","!=","==","is","is_not"],["|"],["^"],["&"],[">>","<<"],["+"],["-"],["*","@","/","//","%"],["unary_neg","unary_inv","unary_pos"],["**"]],$op_weight={},$weight=1;$op_order.forEach((function(e){e.forEach((function(e){$op_weight[e]=$weight})),$weight++}));var $loop_num=0,create_temp_name=$B.parser.create_temp_name=function(e){return(e||"$temp")+$loop_num++},replace_node=$B.parser.replace_node=function(e,t){var r=e.parent,n=get_rank_in_parent(e);r.children[n]=t,t.parent=r,t.bindings=e.bindings},get_rank_in_parent=$B.parser.get_rank_in_parent=function(e){return e.parent.children.indexOf(e)},add_identnode=$B.parser.add_identnode=function(e,t,r,n){var o=new $Node;o.parent=e,o.locals=e.locals,o.module=e.module;var a=new $NodeCtx(o),s=new $ExprCtx(a,"id",!0),i=(new $IdCtx(s,r),new $AssignCtx(s));return-1===t?e.add(o):e.insert(t,o),i.tree[1]=n,o},chained_comp_num=0,$_SyntaxError=$B.parser.$_SyntaxError=function(e,t,r){for(var n=e;"node"!==n.type;)n=n.parent;for(var o=n.node,a=o;void 0!==a.parent;)a=a.parent;var s=o.module,i=a.src,_=o.line_num;if(i&&(_=i.substr(0,$pos).split("\n").length),a.line_info&&(_=a.line_info),void 0!==r&&"number"==typeof r)throw $B.$IndentationError(s,t,i,$pos,_,a);Array.isArray(t)&&$B.$SyntaxError(s,t[0],i,$pos,_,a),"Triple string end not found"===t&&$B.$SyntaxError(s,"invalid syntax : triple string end not found",i,$pos,_,a);var l="invalid syntax";t.startsWith("token ")||(l+=" ("+t+")"),$B.$SyntaxError(s,l,i,$pos,_,a)};function SyntaxWarning(e,t){var r=$get_node(e),n=$get_module(e),o=n.src.split("\n"),a=`Module ${n.module}line ${r.line_num}:${t}\n `+o[r.line_num-1];$B.$getattr($B.stderr,"write")(a)}function check_assignment(e){for(var t=e,r=["assert","del","import","raise","return"];t;)r.indexOf(t.type)>-1?$_SyntaxError(e,"invalid syntax - assign"):"expr"==t.type&&"op"==t.tree[0].type&&(void 0!==$B.op2method.comparisons[t.tree[0].op]?$_SyntaxError(e,["cannot assign to comparison"]):$_SyntaxError(e,["cannot assign to operator"])),t=t.parent}var $Node=$B.parser.$Node=function(e){this.type=e,this.children=[]};$Node.prototype.add=function(e){this.children[this.children.length]=e,e.parent=this,e.module=this.module},$Node.prototype.insert=function(e,t){this.children.splice(e,0,t),t.parent=this,t.module=this.module},$Node.prototype.toString=function(){return""},$Node.prototype.show=function(e){var t="";return"module"===this.type?(this.children.forEach((function(r){t+=r.show(e)})),t):(t+=" ".repeat(e=e||0),t+=this.C,this.children.length>0&&(t+="{"),t+="\n",this.children.forEach((function(r){t+="["+i+"] "+r.show(e+4)})),this.children.length>0&&(t+=" ".repeat(e),t+="}\n"),t)},$Node.prototype.to_js=function(e){if(void 0!==this.js)return this.js;if(this.res=[],this.unbound=[],"module"===this.type)return this.children.forEach((function(e){this.res.push(e.to_js())}),this),this.js=this.res.join(""),this.js;e=e||0;var t=this.C.to_js();return t&&(this.res.push(" ".repeat(e)),this.res.push(t),this.children.length>0&&this.res.push("{"),this.res.push("\n"),this.children.forEach((function(t){this.res.push(t.to_js(e+4))}),this),this.children.length>0&&(this.res.push(" ".repeat(e)),this.res.push("}\n"))),this.js=this.res.join(""),this.js},$Node.prototype.transform=function(e){if(this.has_await)return this.parent.insert(e,$NodeJS("var save_stack = $B.save_stack()")),this.parent.insert(e+2,$NodeJS("$B.restore_stack(save_stack, $locals)")),this.has_await=!1,1;if(this.has_yield&&!this.has_yield.transformed){var t=this.parent;if(this.has_yield.from){var r=new $Node,n=new $NodeCtx(r),o=new $ExprCtx(n,"js",!1),a=new $RawJSCtx(o,"var _i"+this.has_yield.from_num),s=new $AssignCtx(o);new $ExprCtx(s).tree=this.has_yield.tree,t.insert(e,r);$get_node(this.has_yield);var i=this.has_yield.from_num,_=`$B.$import("sys",[],{})\n_i${i}=_b_.iter(_i${i})\nvar $failed${i}=false\ntry{var _y${i}=_b_.next(_i${i})}catch(_e){$B.set_exc(_e)\n$failed${i}=true\n$B.pmframe=$B.last($B.frames_stack)\n_e=$B.exception(_e)\nif(_e.__class__===_b_.StopIteration){var _r${i}=$B.$getattr(_e,"value")}else{throw _e}}\nif(! $failed${i}){while(true){var $failed1${i}=false\ntry{$B.leave_frame({$locals})\nvar _s${i}=yield _y${i}\n$B.frames_stack.push($top_frame)}catch(_e){if(_e.__class__===_b_.GeneratorExit){var $failed2${i}=false\ntry{var _m${i}=$B.$geatttr(_i${i},"close")}catch(_e1){$failed2${i}=true\nif(_e1.__class__ !==_b_.AttributeError){throw _e1}}\nif(! $failed2${i}){$B.$call(_m${i})()}\nthrow _e}else if($B.is_exc(_e,[_b_.BaseException])){var _x=$B.$call($B.$getattr($locals.sys,"exc_info"))()\nvar $failed3${i}=false\ntry{var _m${i}=$B.$getattr(_i${i},"throw")}catch(err){$failed3${i}=true\nif($B.is_exc(err,[_b_.AttributeError])){throw err}}\nif(! $failed3${i}){try{_y${i}=$B.$call(_m${i}).apply(null,_b_.list.$factory(_x${i}))}catch(err){if($B.$is_exc(err,[_b_.StopIteration])){_r${i}=$B.$getattr(err,"value")\nbreak}\nthrow err}}}}\nif(! $failed1${i}){try{if(_s${i}===_b_.None){_y${i}=_b_.next(_i${i})}else{_y${i}=$B.$call($B.$getattr(_i${i},"send"))(_s${i})}}catch(err){if($B.is_exc(err,[_b_.StopIteration])){_r${i}=$B.$getattr(err,"value")\nbreak}\nthrow err}}}}`;return t.insert(e+1,$NodeJS(_)),3}if(t.children.splice(e,1),"abstract_expr"===this.has_yield.tree[0].type)r=$NodeJS("var result = _b_.None");else{r=new $Node,n=new $NodeCtx(r),o=new $ExprCtx(n,"js",!1),a=new $RawJSCtx(o,"var result");(s=new $AssignCtx(o)).tree[1]=this.has_yield.tree[0],a.parent=s}r.line_num=this.line_num,t.insert(e,r);var l=new $NodeJS("try");l.add($NodeJS("$B.leave_frame({$locals})")),l.add(this),t.insert(e+1,l),this.has_yield.to_js=function(){return"yield result"},this.has_yield.transformed=!0;for(var c=0;c0&&"id"==e.tree[0].type){var r=e.tree[0].value;t.globals&&t.globals.has(r)>-1&&$_SyntaxError(e,["annotated name '"+r+"' can't be global"]),t.annotations=t.annotations||new Set,t.annotations.add(r),e.$in_parens||(t.binding=t.binding||{},t.binding[r]=!0)}};$AnnotationCtx.prototype.toString=function(){return"(annotation) "+this.tree},$AnnotationCtx.prototype.transition=function(e,t){var r=this;return"eol"==e&&1==r.tree.length&&0==r.tree[0].tree.length?$_SyntaxError(r,"empty annotation"):":"==e&&"def"!=r.parent.type?$_SyntaxError(r,"more than one annotation"):"augm_assign"==e?$_SyntaxError(r,"augmented assign as annotation"):"op"==e&&$_SyntaxError(r,"operator as annotation"),$transition(r.parent,e)},$AnnotationCtx.prototype.to_js=function(){return $to_js(this.tree)};var $AssertCtx=$B.parser.$AssertCtx=function(e){this.type="assert",this.parent=e,this.tree=[],e.tree[e.tree.length]=this};$AssertCtx.prototype.toString=function(){return"(assert) "+this.tree},$AssertCtx.prototype.transition=function(e,t){var r=this;return","==e?(this.tree.length>1&&$_SyntaxError(r,"too many commas after assert"),new $AbstractExprCtx(this,!1)):"eol"==e?$transition(r.parent,e):void $_SyntaxError(r,e)},$AssertCtx.prototype.transform=function(e,t){if(this.tree.length>1)var r=this.tree[0],n=this.tree[1];else r=this.tree[0],n=null;if("expr"==this.tree[0].type&&"tuple"==this.tree[0].name&&this.tree[0].tree[0].tree.length>1){var o=_b_.SyntaxWarning.$factory("assertion is always true, perhaps remove parentheses?"),a=$get_module(this);$B.$syntax_err_line(o,a.filename,a.src,$pos,$get_node(this).line_num),$B.imported._warnings.warn(o)}var s=new $ConditionCtx(e.C,"if");new $NotCtx(s).tree=[r],e.C=s;var i=new $Node,_="throw _b_.AssertionError.$factory()";null!==n&&(_="throw _b_.AssertionError.$factory(_b_.str.$factory("+n.to_js()+"))"),new $NodeJSCtx(i,_),e.add(i)};var $AssignCtx=$B.parser.$AssignCtx=function(e,t){check_assignment(e),"expr"==e.type&&"lambda"==e.tree[0].type&&$_SyntaxError(e,["cannot assign to lambda"]),this.type="assign","expression"==t&&(this.expression=!0,console.log("parent of assign expr",e.parent)),e.parent.tree.pop(),e.parent.tree[e.parent.tree.length]=this,this.parent=e.parent,this.tree=[e];var r=$get_scope(this);if("expr"==e.type&&"call"==e.tree[0].type)$_SyntaxError(e,["cannot assign to function call "]);else if("list_or_tuple"==e.type||"expr"==e.type&&"list_or_tuple"==e.tree[0].type)"expr"==e.type&&(e=e.tree[0]),e.bind_ids(r);else if("assign"==e.type)e.tree.forEach((function(e){var t=e.tree[0];"id"==t.type&&$bind(t.value,r,this)}),this);else{var n=e.tree[0];if(n&&"id"==n.type)if(!0===noassign[n.value]&&$_SyntaxError(e,["cannot assign to keyword"]),n.bound=!0,r.globals&&r.globals.has(n.value)){var o=$get_module(e);n.global_module=o.module,$bind(n.value,o,this)}else{$get_node(this).bound_before=Object.keys(r.binding),$bind(n.value,r,this)}else["str","int","float","complex"].indexOf(n.type)>-1?$_SyntaxError(e,["cannot assign to literal"]):"unary"==n.type&&$_SyntaxError(e,["cannot assign to operator"])}};$AssignCtx.prototype.guess_type=function(){},$AssignCtx.prototype.toString=function(){return"(assign) "+this.tree[0]+"="+this.tree[1]},$AssignCtx.prototype.transition=function(e,t){var r=this;if("eol"==e)return"abstract_expr"==r.tree[1].type&&$_SyntaxError(r,"token "+e+" after "+r),r.guess_type(),$transition(r.parent,"eol");$_SyntaxError(r,"token "+e+" after "+r)},$AssignCtx.prototype.transform=function(e,t){for(var r=$get_scope(this),n=this.tree[0],o=this.tree[1],a=[];"assign"==n.type;)a.push(n.tree[1]),n=n.tree[0];if(a.length>0){a.push(n);var s=e.C;s.tree=[];var i=new $RawJSCtx(s,"var $temp"+$loop_num);return i.tree=s.tree,new $AssignCtx(i).tree[1]=o,a.forEach((function(r){"expr"==r.type&&"list_or_tuple"==r.tree[0].type&&"tuple"==r.tree[0].real&&1==r.tree[0].tree.length&&(r=r.tree[0].tree[0]);var n=new $Node,o=new $NodeCtx(n);n.locals=e.locals,n.line_num=e.line_num,e.parent.insert(t+1,n),r.parent=o;var a=new $AssignCtx(r);new $RawJSCtx(a,"$temp"+$loop_num)})),$loop_num++,void(this.tree[0]=n)}var _=null;switch(n.type){case"expr":if(n.tree.length>1)_=n.tree;else if("list_or_tuple"==n.tree[0].type||"target_list"==n.tree[0].type)_=n.tree[0].tree;else if("id"==n.tree[0].type){var l=n.tree[0].value;r.globals&&r.globals.has(l)||(n.tree[0].bound=!0)}break;case"target_list":case"list_or_tuple":_=n.tree}o=this.tree[1];if(null!==_){var c=null;if(("list"==o.type||"tuple"==o.type||"expr"==o.type&&o.tree.length>1)&&(c=o.tree),null!==c){if(c.length>_.length)throw Error("ValueError : too many values to unpack (expected "+_.length+")");if(c.length<_.length)throw Error("ValueError : need more than "+c.length+" to unpack");var u=[],f=0;(h=new $Node).line_num=e.line_num,new $NodeJSCtx(h,"void(0)"),u[f++]=h;var p="$temp"+$loop_num;(h=new $Node).line_num=e.line_num,new $NodeJSCtx(h,"var "+p+" = [], $pos = 0"),u[f++]=h,c.forEach((function(t){var r=p+"[$pos++] = "+t.to_js(),n=new $Node;n.line_num=e.line_num,new $NodeJSCtx(n,r),u[f++]=n}));var $=$get_node(this);_.forEach((function(t){var r=new $Node;r.id=$.module,r.locals=$.locals,r.line_num=e.line_num;var n=new $NodeCtx(r);t.parent=n,new $AssignCtx(t,!1).tree[1]=new $JSCode(p+"["+d+"]"),u[f++]=r}),this),e.parent.children.splice(t,1);for(var d=u.length-1;d>=0;d--)e.parent.insert(t,u[d]);$loop_num++}else{e.parent.children.splice(t,1);var h,m=create_temp_name("$right"),g=create_temp_name("$rlist");(h=$NodeJS("var "+m+" = $B.$getattr($B.$iter("+o.to_js()+'), "__next__");')).line_num=e.line_num,e.parent.insert(t++,h),e.parent.insert(t++,$NodeJS("var "+g+"=[], $pos=0;while(1){try{"+g+"[$pos++] = "+m+"()}catch(err){break}}"));var b=null,y=_.length;for(d=0;d<_.length;d++){var v=_[d];if("packed"==v.type||"expr"==v.type&&"packed"==v.tree[0].type){b=d,y--;break}}e.parent.insert(t++,$NodeJS("if("+g+".length<"+y+'){throw _b_.ValueError.$factory("need more than " +'+g+'.length + " value" + ('+g+'.length > 1 ? "s" : "") + " to unpack")}')),null==b&&e.parent.insert(t++,$NodeJS("if("+g+".length>"+y+'){throw _b_.ValueError.$factory("too many values to unpack (expected '+_.length+')")}')),_.forEach((function(n,o){var a=new $Node;a.id=r.id,a.line_num=e.line_num,e.parent.insert(t++,a);var s=new $NodeCtx(a);n.parent=s;var i=new $AssignCtx(n,!1),l=g;l+=null==b||o-1&&$_SyntaxError(e,["cannot assign to literal"])}$get_node(this).bound_before=Object.keys(r.binding),this.module=r.module};$AugmentedAssignCtx.prototype.toString=function(){return"(augm assign) "+this.tree},$AugmentedAssignCtx.prototype.transition=function(e,t){var r=this;if("eol"==e)return"abstract_expr"==r.tree[1].type&&$_SyntaxError(r,"token "+e+" after "+r),$transition(r.parent,"eol");$_SyntaxError(r,"token "+e+" after "+r)},$AugmentedAssignCtx.prototype.transform=function(e,t){var r=this.C,n=this.op,o="__"+$operators[n]+"__",a=0,s=e.parent,i=e.line_num,_=!1;s.children.splice(t,1);var l="expr"==this.tree[0].type&&"id"==this.tree[0].tree[0].type;if(l){var c="int"==this.tree[0].tree[0].bindingType(this.scope);if(this.tree[0].tree[0].augm_assign=!0,$B.debug>0){var u=$NodeJS("if("+this.tree[0].to_js()+" === undefined){throw _b_.NameError.$factory(\"name '"+this.tree[0].tree[0].value+"' is not defined\")}");e.parent.insert(t,u),a++}var f=this.tree[0].tree[0].value,p=void 0!==this.scope.binding[f],$=this.tree[0].tree[0].unbound}var d="expr"==this.tree[1].type&&"int"==this.tree[1].tree[0].type;if(d){var h=this.tree[1].tree[0].value,m=parseInt(h[1],h[0]);d=m>$B.min_int&&m<$B.max_int}var g=d?this.tree[1].tree[0].to_js():"$temp";if(!d){(j=new $Node).line_num=i,_=!0,new $NodeJSCtx(j,"var $temp,$left;"),s.insert(t,j),a++,(j=new $Node).id=this.scope.id;var b=new $NodeCtx(j),y=new $ExprCtx(b,"js",!1),v=new $RawJSCtx(y,"$temp"),x=new $AssignCtx(y);x.tree[1]=this.tree[1],v.parent=x,s.insert(t+a,j),a++}var B="",w=!1;switch(n){case"+=":case"-=":case"*=":case"/=":if(l){var k=this.scope,E="$local_"+k.module.replace(/\./g,"_");switch(k.ntype){case"module":B=E;break;case"def":case"generator":B=k.globals&&k.globals.has(r.tree[0].value)?E:"$locals";break;case"class":var j=new $Node;_||(j.line_num=i,_=!0),new $NodeJSCtx(j,"var $left = "+r.to_js()),s.insert(t+a,j),w=!0,a++}}}var N=r.tree[0].to_js();if("id"==r.tree[0].type){var C=r.tree[0].firstBindingScopeId(),S=r.tree[0].value;N=C?"$locals_"+C.replace(/\./g,"_")+'["'+S+'"]':'$locals["'+S+'"]'}if(c&&d&&"//="!=n)return s.insert(t+a,$NodeJS(N+" "+n+" "+g)),a++;B=B&&!r.tree[0].unknown_binding&&!$;var A=n.charAt(0);if(B){var O=w?"$left":N;j=new $Node;_||(j.line_num=i,_=!0),T=d?"if(":'if(typeof $temp.valueOf() == "number" && ',T+=O+".constructor === Number",T+=" && Number.isSafeInteger("+N+A+g+")){"+(d?"(":'(typeof $temp == "number" && ')+"typeof "+O+' == "number") ? ',T+=N+n+g,new $NodeJSCtx(j,T+=" : "+N+" = new Number("+N+A+(d?g:g+".valueOf()")+")}"),s.insert(t+a,j),a++}if("sub"==r.tree[0].type&&("+="==n||"-="==n||"*="==n)&&1==r.tree[0].tree.length){var I="$B.augm_item_"+{"+=":"add","-=":"sub","*=":"mul"}[n]+"("+r.tree[0].value.to_js()+","+r.tree[0].tree[0].to_js()+","+g+");_b_.None;";j=new $Node;return _||(j.line_num=i,_=!0),new $NodeJSCtx(j,I),s.insert(t+a,j),void a++}j=new $Node;_||(j.line_num=i,_=!0);var T="";B&&(T+="else "),T+="if(! _b_.hasattr("+r.to_js()+',"'+o+'"))',new $NodeJSCtx(j,T),s.insert(t+a,j),a++;var F=new $Node;F.id=this.scope.id,F.line_num=e.line_num,j.add(F);var R=new $NodeCtx(F),J=new $ExprCtx(R,"clone",!1);$?new $RawJSCtx(J,N):(J.tree=r.tree,J.tree.forEach((function(e){e.parent=J})));var M=new $AssignCtx(J),L=new $OpCtx(J,n.substr(0,n.length-1));L.parent=M,new $RawJSCtx(L,g),M.tree.push(L),J.parent.tree.pop(),J.parent.tree.push(M);var P=$NodeJS("else");s.insert(t+a,P);var q=new $Node;q.line_num=e.line_num,P.add(q);var D=new $NodeCtx(q),z=new $ExprCtx(D,"clone",!1);if($){T=N;C||(T='$B.$local_search("'+S+'");'+N),new $RawJSCtx(z,T)}else z.tree=r.tree,z.tree.forEach((function(e){e.parent=z}));var V=new $AssignCtx(z);return V.tree.push($NodeJS("$B.$getattr("+r.to_js()+',"'+o+'")('+g+")")),z.parent.tree.pop(),z.parent.tree.push(V),!l||p||this.scope.blurred||(this.scope.binding[f]=void 0),a},$AugmentedAssignCtx.prototype.to_js=function(){return""};var $AwaitCtx=$B.parser.$AwaitCtx=function(e){this.type="await",this.parent=e,this.tree=[],e.tree.push(this);for(var t=e;t;)"list_or_tuple"==t.type&&(t.is_await=!0),t=t.parent};$AwaitCtx.prototype.transition=function(e,t){return this.parent.is_await=!0,$transition(this.parent,e,t)},$AwaitCtx.prototype.to_js=function(){return"var save_stack = $B.save_stack();await ($B.promise("+$to_js(this.tree)+"));$B.restore_stack(save_stack, $locals); "};var $BodyCtx=$B.parser.$BodyCtx=function(e){for(var t=e.parent;"node"!==t.type;)t=t.parent;var r=t.node,n=new $Node;return n.is_body_node=!0,n.line_num=r.line_num,r.insert(0,n),new $NodeCtx(n)},set_loop_context=$B.parser.set_loop_context=function(e,t){for(var r=e;"node"!==r.type;)r=r.parent;for(var n=r.node.parent,o=!1;;)if("module"==n.type)$_SyntaxError(e,t+" outside of a loop");else{var a=n.C.tree[0];if("condition"==a.type&&"while"==a.token){this.loop_ctx=a,a["has_"+t]=!0;break}switch(a.type){case"for":this.loop_ctx=a,a["has_"+t]=!0,o=!0;break;case"def":case"generator":case"class":$_SyntaxError(e,t+" outside of a loop");default:n=n.parent}if(o)break}},$BreakCtx=$B.parser.$BreakCtx=function(e){this.type="break",this.parent=e,e.tree[e.tree.length]=this,set_loop_context.apply(this,[e,"break"])};$BreakCtx.prototype.toString=function(){return"break "},$BreakCtx.prototype.transition=function(e,t){if("eol"==e)return $transition(this.parent,"eol");$_SyntaxError(this,e)},$BreakCtx.prototype.to_js=function(){this.js_processed=!0;var e=";$locals_"+$get_scope(this).id.replace(/\./g,"_")+'["$no_break'+this.loop_ctx.loop_num+'"] = false';return"asyncfor"!=this.loop_ctx.type?e+=";break":e+=";throw _b_.StopIteration.$factory("+this.loop_ctx.loop_num+")",e};var $CallArgCtx=$B.parser.$CallArgCtx=function(e){this.type="call_arg",this.parent=e,this.start=$pos,this.tree=[],e.tree.push(this),this.expect="id"};$CallArgCtx.prototype.toString=function(){return"call_arg "+this.tree},$CallArgCtx.prototype.transition=function(e,t){var r=this;switch(e){case"await":case"id":case"imaginary":case"int":case"float":case"str":case"bytes":case"[":case"(":case"{":case".":case"not":case"lambda":if("id"==r.expect){r.expect=",";var n=new $AbstractExprCtx(r,!1);return $transition(n,e,t)}break;case"=":if(","==r.expect)return new $ExprCtx(new $KwArgCtx(r),"kw_value",!1);break;case"for":this.parent.tree.length>1&&$_SyntaxError(r,"non-parenthesized generator expression");var o=new $ListOrTupleCtx(r,"gen_expr");o.vars=r.vars,o.locals=r.locals,o.intervals=[r.start],r.tree.pop(),o.expression=r.tree,r.tree=[o],o.tree=[];var a=new $ComprehensionCtx(o);return new $TargetListCtx(new $CompForCtx(a));case"op":if("id"==r.expect){var s=t;switch(r.expect=",",s){case"+":case"-":case"~":return $transition(new $AbstractExprCtx(r,!1),e,s);case"*":return new $StarArgCtx(r);case"**":return new $DoubleStarArgCtx(r)}}$_SyntaxError(r,"token "+e+" after "+r);case")":if(r.parent.kwargs&&$B.last(r.parent.tree).tree[0]&&-1==["kwarg","star_arg","double_star_arg"].indexOf($B.last(r.parent.tree).tree[0].type)&&$_SyntaxError(r,["non-keyword argument after keyword argument"]),r.tree.length>0){var i=r.tree[r.tree.length-1];"list_or_tuple"==i.type&&"gen_expr"==i.real&&i.intervals.push($pos)}return $transition(r.parent,e);case":":if(","==r.expect&&"lambda"==r.parent.parent.type)return $transition(r.parent.parent,e);break;case",":if(","==r.expect)return r.parent.kwargs&&-1==["kwarg","star_arg","double_star_arg"].indexOf($B.last(r.parent.tree).tree[0].type)&&$_SyntaxError(r,["non-keyword argument after keyword argument"]),$transition(r.parent,e,t)}$_SyntaxError(r,"token "+e+" after "+r)},$CallArgCtx.prototype.to_js=function(){return this.js_processed=!0,$to_js(this.tree)};var $CallCtx=$B.parser.$CallCtx=function(e){this.type="call",this.func=e.tree[0],void 0!==this.func&&(this.func.parent=this),this.parent=e,"class"!=e.type?(e.tree.pop(),e.tree[e.tree.length]=this):e.args=this,this.expect="id",this.tree=[],this.start=$pos,this.func&&"attribute"==this.func.type&&"wait"==this.func.name&&"id"==this.func.value.type&&"time"==this.func.value.value&&(console.log("call",this.func),$get_node(this).blocking={type:"wait",call:this}),this.func&&"input"==this.func.value&&($get_node(this).blocking={type:"input"})};$CallCtx.prototype.toString=function(){return"(call) "+this.func+"("+this.tree+")"},$CallCtx.prototype.transition=function(e,t){var r=this;switch(e){case",":return"id"==r.expect&&$_SyntaxError(r,e),r.expect="id",r;case"await":case"id":case"imaginary":case"int":case"float":case"str":case"bytes":case"[":case"(":case"{":case".":case"not":case"lambda":return r.expect=",",$transition(new $CallArgCtx(r),e,t);case")":return r.end=$pos,r.parent;case"op":switch(r.expect=",",t){case"-":case"~":case"+":return r.expect=",",$transition(new $CallArgCtx(r),e,t);case"*":return r.has_star=!0,new $StarArgCtx(r);case"**":return r.has_dstar=!0,new $DoubleStarArgCtx(r)}$_SyntaxError(r,e);case"yield":$_SyntaxError(r,e)}return $transition(r.parent,e,t)},$CallCtx.prototype.to_js=function(){this.js_processed=!0,this.tree.length>0&&0==this.tree[this.tree.length-1].tree.length&&this.tree.pop();var e=this.func.to_js();if(void 0!==this.func){switch(this.func.value){case"classmethod":return"_b_.classmethod.$factory("+$to_js(this.tree)+")";default:if("unary"==this.func.type){var t="$B.$getattr("+$to_js(this.tree);switch(this.func.op){case"+":return t+',"__pos__")()';case"-":return t+',"__neg__")()';case"~":return t+',"__invert__")()'}}}var r,n=[],o=[],a=!1,s=[];if(this.tree.forEach((function(e){switch(e.type){case"star_arg":a=!0,n.push([e.tree[0].tree[0].to_js(),"*"]);break;case"double_star_arg":s.push(e.tree[0].tree[0].to_js());break;case"id":n.push([e.to_js(),"s"]);break;default:switch(e.tree[0].type){case"expr":n.push([e.to_js(),"s"]);break;case"kwarg":o.push(e.tree[0].tree[0].value+":"+e.tree[0].tree[1].to_js());break;case"list_or_tuple":case"op":n.push([e.to_js(),"s"]);break;case"star_arg":a=!0,n.push([e.tree[0].tree[0].to_js(),"*"]);break;case"double_star_arg":s.push(e.tree[0].tree[0].to_js());break;default:n.push([e.to_js(),"s"])}}})),a){for(var i=[],_=0,l=n.length;_-1&&"id"==this.func.type&&this.func.is_builtin){if(void 0!==$B.builtin_funcs[this.func.value])return-1==["complex","bytes","bytearray","object","memoryview","int","float","str","list","tuple","dict","set","frozenset","range","slice","zip","bool","type","classmethod","staticmethod","enumerate","reversed","property","$$super","zip","map","filter"].indexOf(this.func.value)?e+r:e+".$factory"+r}return f}};var $ClassCtx=$B.parser.$ClassCtx=function(e){this.type="class",this.parent=e,this.tree=[],e.tree[e.tree.length]=this,this.expect="id";var t=this.scope=$get_scope(this);this.parent.node.parent_block=t,this.parent.node.bound={},this.parent.node.binding={__annotations__:!0}};$ClassCtx.prototype.toString=function(){return"(class) "+this.name+" "+this.tree+" args "+this.args},$ClassCtx.prototype.transition=function(e,t){var r=this;switch(e){case"id":if("id"==r.expect)return r.set_name(t),r.expect="(:",r;break;case"(":return new $CallCtx(r);case":":return $BodyCtx(r)}$_SyntaxError(r,"token "+e+" after "+r)},$ClassCtx.prototype.set_name=function(e){var t=this.parent;this.random=$B.UUID(),this.name=e,this.id=t.node.module+"_"+e+"_"+this.random,this.binding={},this.parent.node.id=this.id;for(var r=this.scope,n=r,o=r,a=[];"class"==o.ntype;)a.splice(0,0,o.C.tree[0].name),o=o.parent;for(this.qualname=a.concat([e]).join(".");n.C&&"class"==n.C.tree[0].type;)n=n.parent;for(;n.C&&"def"!=n.C.tree[0].type&&"generator"!=n.C.tree[0].type;)n=n.parent;this.parent.node.parent_block=n,$bind(e,r,this),r.is_function&&-1==r.C.tree[0].locals.indexOf(e)&&r.C.tree[0].locals.push(e)},$ClassCtx.prototype.transform=function(e,t){this.doc_string=$get_docstring(e),this.module=$get_module(this).module.replace(/\./g,"_");var r="\n"+" ".repeat(e.indent+12),n=new $Node,o="$locals_"+this.id.replace(/\./g,"_");new $NodeJSCtx(n,i="var "+o+" = {__annotations__: $B.empty_dict()}, "+r+"$locals = "+o),e.insert(0,n);for(var a=this.scope;"__builtins__"!==a.parent_block.id;)a=a.parent_block;var s="$locals_"+a.id.replace(/\./g,"_"),i=" ".repeat(e.indent+4)+'$locals.$name = "'+this.name+'"'+r+'$locals.$qualname = "'+this.qualname+'"'+r+"$locals.$is_class = true; "+r+'$locals.$line_info = "'+e.line_num+","+this.module+'";'+r+'var $top_frame = ["'+o+'", $locals,"'+a.id+'", '+s+"]"+r+"$locals.$f_trace = $B.enter_frame($top_frame);"+r+"if($locals.$f_trace !== _b_.None){$locals.$f_trace = $B.trace_line()}";e.insert(1,$NodeJS(i)),e.add($NodeJS("if($locals.$f_trace !== _b_.None){$B.trace_return(_b_.None)}")),e.add($NodeJS("$B.leave_frame({$locals})"));var _=new $Node;new $NodeJSCtx(_,"return "+o+";"),e.insert(e.children.length,_);var l=new $Node;new $NodeJSCtx(l,")();"),e.parent.insert(t+1,l);var c="$locals_"+this.module+".__name__";t++,e.parent.insert(t+1,$NodeJS("$"+this.name+"_"+this.random+".__module__ = "+c));var u=$get_scope(this),f=";$locals_"+u.id.replace(/\./g,"_"),p=1;if((i=[(f+='["'+this.name+'"]')+' = $B.$class_constructor("'+this.name])[p++]='", $'+this.name+"_"+this.random,void 0!==this.args){var $=this.args.tree,d=[],h=[];$.forEach((function(e){"kwarg"==e.tree[0].type?h.push(e.tree[0]):d.push(e.to_js())})),i[p++]=", _b_.tuple.$factory(["+d.join(",")+"]),[";var m=new RegExp('"',"g"),g=[],b=0;d.forEach((function(e){g[b++]='"'+e.replace(m,'\\"')+'"'})),i[p++]=g.join(",")+"]",g=[],b=0,h.forEach((function(e){g[b++]='["'+e.tree[0].value+'",'+e.tree[1].to_js()+"]"})),i[p++]=",["+g.join(",")+"]"}else i[p++]=", _b_.tuple.$factory([]),[],[]";i[p++]=")";var y=new $Node;new $NodeJSCtx(y,i.join("")),t++,e.parent.insert(t+1,y),t++;var v=new $Node;if(i=f+".__doc__ = "+(this.doc_string||"_b_.None")+";",new $NodeJSCtx(v,i),e.parent.insert(t+1,v),"module"==u.ntype){var x=new $Node;new $NodeJSCtx(x,'$locals["'+this.name+'"] = '+this.name)}e.parent.insert(t+2,$NodeJS("_b_.None;")),this.transformed=!0},$ClassCtx.prototype.to_js=function(){return this.js_processed=!0,"var $"+this.name+"_"+this.random+" = (function()"};var $CompIfCtx=$B.parser.$CompIfCtx=function(e){this.type="comp_if",e.parent.intervals.push($pos),this.parent=e,this.tree=[],e.tree[e.tree.length]=this};$CompIfCtx.prototype.toString=function(){return"(comp if) "+this.tree},$CompIfCtx.prototype.transition=function(e,t){return $transition(this.parent,e,t)},$CompIfCtx.prototype.to_js=function(){return this.js_processed=!0,$to_js(this.tree)};var $ComprehensionCtx=$B.parser.$ComprehensionCtx=function(e){this.type="comprehension",this.parent=e,this.tree=[],e.tree[e.tree.length]=this};$ComprehensionCtx.prototype.toString=function(){return"(comprehension) "+this.tree},$ComprehensionCtx.prototype.transition=function(e,t){var r=this;switch(e){case"if":return new $AbstractExprCtx(new $CompIfCtx(r),!1);case"for":return new $TargetListCtx(new $CompForCtx(r))}return $transition(r.parent,e,t)},$ComprehensionCtx.prototype.to_js=function(){this.js_processed=!0;var e=[];return this.tree.forEach((function(t){e.push(t.start)})),e};var $CompForCtx=$B.parser.$CompForCtx=function(e){this.type="comp_for",e.parent.intervals.push($pos),this.parent=e,this.tree=[],this.expect="in",e.tree[e.tree.length]=this};$CompForCtx.prototype.toString=function(){return"(comp for) "+this.tree},$CompForCtx.prototype.transition=function(e,t){var r=this;return"in"==e&&"in"==r.expect?(r.expect=null,new $AbstractExprCtx(new $CompIterableCtx(r),!0)):null===r.expect?$transition(r.parent,e,t):void $_SyntaxError(r,"token "+e+" after "+r)},$CompForCtx.prototype.to_js=function(){return this.js_processed=!0,$to_js(this.tree)};var $CompIterableCtx=$B.parser.$CompIterableCtx=function(e){this.type="comp_iterable",this.parent=e,this.tree=[],e.tree[e.tree.length]=this};$CompIterableCtx.prototype.toString=function(){return"(comp iter) "+this.tree},$CompIterableCtx.prototype.transition=function(e,t){return $transition(this.parent,e,t)},$CompIterableCtx.prototype.to_js=function(){return this.js_processed=!0,$to_js(this.tree)};var $ConditionCtx=$B.parser.$ConditionCtx=function(e,t){this.type="condition",this.token=t,this.parent=e,this.tree=[],this.scope=$get_scope(this),"while"==t&&(this.loop_num=$loop_num++),e.tree[e.tree.length]=this};$ConditionCtx.prototype.toString=function(){return this.token+" "+this.tree},$ConditionCtx.prototype.transition=function(e,t){var r=this;if(":"==e)return"abstract_expr"==r.tree[0].type&&0==r.tree[0].tree.length&&$_SyntaxError(r,"token "+e+" after "+r),$BodyCtx(r);$_SyntaxError(r,"token "+e+" after "+r)},$ConditionCtx.prototype.transform=function(e,t){$get_scope(this);if("while"==this.token){e.parent.insert(t,$NodeJS('$locals["$no_break'+this.loop_num+'"] = true'));var r=$get_module(this).module;if("return"!=$B.last(e.children).C.tree[0].type){var n='$locals.$line_info = "'+e.line_num+","+r+'";if($locals.$f_trace !== _b_.None){$B.trace_line()};_b_.None;';e.add($NodeJS(n))}return 2}},$ConditionCtx.prototype.to_js=function(){this.js_processed=!0;var e=this.token;"elif"==e&&(e="else if");var t=[e+"($B.$bool("];if("while"==e)t.push('$locals["$no_break'+this.loop_num+'"] && ');else if("else if"==e){var r=$get_node(this).line_num+","+$get_scope(this).id;t.push('($B.set_line("'+r+'")) && ')}return 1==this.tree.length?t.push($to_js(this.tree)+"))"):(t.push(this.tree[0].to_js()+"))"),this.tree[1].tree.length>0&&t.push("{"+this.tree[1].to_js()+"}")),t.join("")};var $ContinueCtx=$B.parser.$ContinueCtx=function(e){this.type="continue",this.parent=e,$get_node(this).is_continue=!0,e.tree[e.tree.length]=this,set_loop_context.apply(this,[e,"continue"])};$ContinueCtx.prototype.toString=function(){return"(continue)"},$ContinueCtx.prototype.transition=function(e,t){var r=this;if("eol"==e)return r.parent;$_SyntaxError(r,"token "+e+" after "+r)},$ContinueCtx.prototype.to_js=function(){this.js_processed=!0;var e="continue";return this.loop_ctx.has_break&&(e=`$locals["$no_break${this.loop_ctx.loop_num}"]=true;${e}`),e};var $DebuggerCtx=$B.parser.$DebuggerCtx=function(e){this.type="continue",this.parent=e,e.tree[e.tree.length]=this};$DebuggerCtx.prototype.toString=function(){return"(debugger)"},$DebuggerCtx.prototype.transition=function(e,t){},$DebuggerCtx.prototype.to_js=function(){return this.js_processed=!0,"debugger"};var $DecoratorCtx=$B.parser.$DecoratorCtx=function(e){this.type="decorator",this.parent=e,e.tree[e.tree.length]=this,this.tree=[]};$DecoratorCtx.prototype.toString=function(){return"(decorator) "+this.tree},$DecoratorCtx.prototype.transition=function(e,t){var r=this;return"id"==e&&0==r.tree.length?$transition(new $AbstractExprCtx(r,!1),e,t):"eol"==e?$transition(r.parent,e):void $_SyntaxError(r,"token "+e+" after "+r)},$DecoratorCtx.prototype.transform=function(e,t){for(var r=t+1,n=e.parent.children,o=[this.tree];;)if(r>=n.length)$_SyntaxError(C,["decorator expects function"]);else if("node_js"==n[r].C.type)r++;else{if("decorator"!=n[r].C.tree[0].type)break;o.push(n[r].C.tree[0].tree),n.splice(r,1)}this.dec_ids=[];o.forEach((function(){this.dec_ids.push("$id"+$B.UUID())}),this);var a=n[r].C.tree[0];"def"==a.type&&(a.decorated=!0,a.alias="$dec"+$B.UUID());var s="",i=$get_scope(this),_='$locals["';i.globals&&i.globals.has(a.name)&&(_="$locals_"+$get_module(this).id+'["');var l=(_+=a.name+'"]')+" = ";o.forEach((function(e,t){l+="$B.$call("+this.dec_ids[t]+")(",s+=")"}),this),l+=(a.decorated?a.alias:_)+s+";",$bind(a.name,i,this),e.parent.insert(r+1,$NodeJS(l)),this.decorators=o},$DecoratorCtx.prototype.to_js=function(){this.js_processed=!0;var e=[];return this.decorators.forEach((function(t,r){e.push("var "+this.dec_ids[r]+" = "+$to_js(t)+";")}),this),e.join("")};var $DefCtx=$B.parser.$DefCtx=function(e){this.type="def",this.name=null,this.parent=e,this.tree=[],this.async=e.async,this.locals=[],e.tree[e.tree.length]=this,this.enclosing=[];var t=this.scope=$get_scope(this);t.C&&"class"==t.C.tree[0].type&&(this.class_name=t.C.tree[0].name),e.node.binding={};for(var r=t;r.C&&"class"==r.C.tree[0].type;)r=r.parent;for(;r.C&&"def"!=r.C.tree[0].type;)r=r.parent;this.parent.node.parent_block=r;var n=r;for(this.is_comp=n.is_comp;n&&n.C;){if("def"==n.C.tree[0].type){this.inside_function=!0;break}n=n.parent_block}this.module=t.module,this.root=$get_module(this),this.num=$loop_num,$loop_num++,this.positional_list=[],this.default_list=[],this.other_args=null,this.other_kw=null,this.after_star=[]};$DefCtx.prototype.set_name=function(e){try{e=$mangle(e,this.parent.tree[0])}catch(e){throw console.log(e),console.log("parent",this.parent),e}var t=new $IdCtx(this,e);this.name=e,this.id=this.scope.id+"_"+e,this.id=this.id.replace(/\./g,"_"),this.id+="_"+$B.UUID(),this.parent.node.id=this.id,this.parent.node.module=this.module,this.binding={};var r=this.scope;void 0!==r.globals&&r.globals.has(e)?$bind(e,this.root,this):$bind(e,r,this),t.bound=!0,r.is_function&&-1==r.C.tree[0].locals.indexOf(e)&&r.C.tree[0].locals.push(e)},$DefCtx.prototype.toString=function(){return"def "+this.name+"("+this.tree+")"},$DefCtx.prototype.transition=function(e,t){var r=this;switch(e){case"id":return r.name&&$_SyntaxError(r,"token "+e+" after "+r),r.set_name(t),r;case"(":return null==r.name&&$_SyntaxError(r,"missing name in function definition"),r.has_args=!0,new $FuncArgs(r);case"annotation":return new $AbstractExprCtx(new $AnnotationCtx(r),!0);case":":if(r.has_args)return $BodyCtx(r);$_SyntaxError(r,"missing function parameters");case"eol":r.has_args&&$_SyntaxError(r,"missing colon")}$_SyntaxError(r,"token "+e+" after "+r)},$DefCtx.prototype.transform=function(e,t){if(this.is_comp&&($get_node(this).is_comp=!0),void 0===this.transformed){var r=this.scope;this.doc_string=$get_docstring(e),this.rank=t;var n=e.indent+12;if(this.name.substr(0,15)=="lambda_"+$B.lambda_magic){var o=r.parent_block;o.C&&"def"==o.C.tree[0].type&&this.enclosing.push(o)}for(var a=this.parent.node;a.parent&&a.parent.is_def_func;)this.enclosing.push(a.parent.parent),a=a.parent.parent;var s=[],i=[],_=!1;this.argcount=0,this.kwonlyargcount=0,this.kwonlyargsdefaults=[],this.otherdefaults=[],this.varnames={},this.args=[],this.__defaults__=[],this.slots=[];var l=[],c=[],u=[];this.annotation&&u.push('"return":'+this.annotation.to_js()),this.func_name=this.tree[0].to_js();var f=this.func_name;this.decorated&&(this.func_name="var "+this.alias,f=this.alias),this.tree[1].tree.forEach((function(e){if("end_positional"==e.type?(this.args.push("/"),l.push('"/"'),_=!0):(this.args.push(e.name),this.varnames[e.name]=!0),"func_arg_id"==e.type?(this.star_arg?(this.kwonlyargcount++,e.has_default&&this.kwonlyargsdefaults.push(e.name)):(this.argcount++,e.has_default&&this.otherdefaults.push(e.name)),this.slots.push(e.name+":null"),l.push('"'+e.name+'"'),c.push(e.name+":"+e.name),e.tree.length>0&&(s.push('"'+e.name+'"'),i.push(e.name+":"+$to_js(e.tree)),this.__defaults__.push($to_js(e.tree)))):"func_star_arg"==e.type&&("*"==e.op?this.star_arg=e.name:"**"==e.op&&(this.kw_arg=e.name)),e.annotation){var t=$mangle(e.name,this);u.push(t+": "+e.annotation.to_js())}}),this),c="{"+c.join(", ")+"}";var p=67;this.star_arg&&(p|=4),this.kw_arg&&(p|=8),"generator"==this.type&&(p|=32),this.async&&(p|=128);for(var $=[],d=r;d.parent_block&&"__builtins__"!==d.parent_block.id;)d=d.parent_block;var h="$locals_"+d.id.replace(/\./g,"_"),m=this.name+this.num,g="$locals_"+this.id;v="var "+g+" = {},"+(M="\n"+" ".repeat(n))+"$locals = "+g+";",(x=new $Node).locals_def=!0,x.func_node=e,new $NodeJSCtx(x,v),$.push(x);var b=[$NodeJS('$locals.$line_info = "'+e.line_num+","+this.module+'"'),$NodeJS(`var $top_frame=["${this.id}",$locals,"`+d.id+'", '+h+", "+(this.is_comp?this.name:m)+"]"),$NodeJS("$locals.$f_trace = $B.enter_frame($top_frame)"),$NodeJS("var $stack_length = $B.frames_stack.length;")];"generator"==this.type&&b.push($NodeJS("$locals.$is_generator = true")),this.async&&b.splice(1,0,$NodeJS(`$locals.$async="${this.id}"`)),b.forEach((function(e){e.enter_frame=!0})),this.is_comp&&$.push($NodeJS("var $defaults = {}")),this.env=[];var y=[],v=g+' = $locals = $B.args("'+this.name+'", '+this.argcount+", {"+this.slots.join(", ")+"}, ["+l.join(", ")+"], arguments, $defaults, "+this.other_args+", "+this.other_kw+");",x=new $Node;new $NodeJSCtx(x,v),y.push(x);var B=!1;if(null!==this.other_args||null!==this.other_kw||0!=this.after_star.length||_)$.push(y[0]),y.length>1&&$.push(y[1]);else{B=!0,$.push($NodeJS("var $len = arguments.length;"));x=new $Node;new $NodeJSCtx(x,v="if($len > 0 && arguments[$len - 1].$nat !== undefined)"),$.push(x),y.forEach((function(e){x.add(e)}));var w=new $Node;new $NodeJSCtx(w,"else"),$.push(w);var k=this.slots.length,E=$NodeJS("if($len == "+k+")");w.add(E),E.add($NodeJS(g+" = $locals = "+c)),w.add($NodeJS("else if($len > "+k+'){$B.wrong_nb_args("'+this.name+'", $len, '+k+", ["+l+"])}")),k>0&&(w.add($NodeJS("else if($len + Object.keys($defaults).length < "+k+'){$B.wrong_nb_args("'+this.name+'", $len, '+k+", ["+l+"])}")),subelse_node=$NodeJS("else"),w.add(subelse_node),subelse_node.add($NodeJS(g+" = $locals = "+c)),subelse_node.add($NodeJS("var defparams = ["+l+"]")),subelse_node.add($NodeJS("for(var i = $len; i < defparams.length; i++){$locals[defparams[i]] = $defaults[defparams[i]]}")))}$=$.concat(b),"class"==r.ntype&&(class_ref="$locals_"+r.parent_block.id.replace(/\./g,"_")+"."+r.C.tree[0].qualname,this.parent.node.binding.__class__=!0,$.push($NodeJS("$locals.__class__ = "+class_ref))),$.push($NodeJS("$B.js_this = this;"));for(var j=$.length-1;j>=0;j--)e.children.splice(0,0,$[j]);var N=new $Node;this.params="",B&&(this.params=Object.keys(this.varnames).join(", ")),new $NodeJSCtx(N,""),N.is_def_func=!0,N.module=this.module;var C=e.children[e.children.length-1];n=C.indent;"return"!=C.C.tree[0].type&&(v="if($locals.$f_trace !== _b_.None){\n"+" ".repeat(n)+"$B.trace_return(_b_.None)\n"+" ".repeat(n)+"}\n"+" ".repeat(n),v+="$B.leave_frame","$exec"==this.id.substr(0,5)&&(v+="_exec"),v+="({$locals});return _b_.None",e.add($NodeJS(v)));var S=[];if(this.parent.node.referenced)for(var A in this.parent.node.referenced)this.parent.node.binding[A]||S.push('"'+A+'"');e.add(N);var O=1;n=e.indent;if(!this.is_comp){e.parent.insert(t+O++,$NodeJS(m+".$is_func = true")),this.$has_yield_in_cm&&e.parent.insert(t+O++,$NodeJS(m+".$has_yield_in_cm = true")),e.parent.insert(t+O++,$NodeJS(m+".$infos = {"));var I=this.name;"$$"==this.name.substr(0,2)&&(I=I.substr(2)),I.substr(0,15)=="lambda_"+$B.lambda_magic&&(I=""),v=' __name__:"'+$B.from_alias(I)+'",',e.parent.insert(t+O++,$NodeJS(v));var T=I;if(this.class_name&&(T=this.class_name+"."+$B.from_alias(I)),v=' __qualname__:"'+T+'",',e.parent.insert(t+O++,$NodeJS(v)),this.otherdefaults.length>0){var F=[];this.otherdefaults.forEach((function(e){F.push("$defaults."+e)})),e.parent.insert(t+O++,$NodeJS(" __defaults__ : $B.fast_tuple(["+F.join(", ")+"]),"))}else e.parent.insert(t+O++,$NodeJS(" __defaults__ : _b_.None,"));if(this.kwonlyargsdefaults.lengh>0){F=[];this.kwonlyargsdefaults.forEach((function(e){F.push("$defaults."+e)})),e.parent.insert(t+O++,$NodeJS(" __kwdefaults__ : $B.fast_tuple(["+F.join(", ")+"]),"))}else e.parent.insert(t+O++,$NodeJS(" __kwdefaults__ : _b_.None,"));e.parent.insert(t+O++,$NodeJS(" __annotations__: {"+u.join(",")+"},")),e.parent.insert(t+O++,$NodeJS(" __dict__: $B.empty_dict(),")),e.parent.insert(t+O++,$NodeJS(" __doc__: "+(this.doc_string||"_b_.None")+","));var R=$get_module(this);for(var A in e.parent.insert(t+O++,$NodeJS(' __module__ : "'+R.module+'",')),this.binding)this.varnames[A]=!0;var J=[];for(var A in this.varnames)J.push('"'+$B.from_alias(A)+'"');var M;this.name,this.num;v=" __code__:{"+(M="\n"+" ".repeat(n+8))+" co_argcount:"+this.argcount;var L=","+M+" ".repeat(4);v+=L+"co_filename:$locals_"+$get_module(this).module.replace(/\./g,"_")+'["__file__"] || ""'+L+"co_firstlineno:"+e.line_num+L+"co_flags:"+p+L+"co_freevars: ["+S+"]"+L+"co_kwonlyargcount:"+this.kwonlyargcount+L+'co_name: "'+this.name+'"'+L+"co_nlocals: "+J.length+L+"co_posonlyargcount: "+(this.pos_only||0)+L+"co_varnames: $B.fast_tuple(["+J.join(", ")+"])"+M+"}\n"+" ".repeat(n+4)+"};",v+="_b_.None;",e.parent.insert(t+O++,$NodeJS(v))}if(this.default_str="{"+i.join(", ")+"}",!this.is_comp){var P=m;"generator"==this.type&&(P=`$B.generator.$factory(${m})`);var q="return "+P;this.async&&(q="generator"==this.type?`return $B.async_generator.$factory(${m})`:"return $B.make_async("+P+")"),e.parent.insert(t+O++,$NodeJS(q+"}")),e.parent.insert(t+O++,$NodeJS(this.func_name+" = "+this.name+"$"+this.num+"("+this.default_str+")")),e.parent.insert(t+O++,$NodeJS(f+".$set_defaults = function(value){return "+f+" = "+this.name+"$"+this.num+"(value)}")),this.$has_yield_in_cm&&e.parent.insert(t+O++,$NodeJS(f+".$has_yield_in_cm=true"))}for(var D=e,z=0;z-1?"_b_.list.$factory("+n.to_js()+")":"["+n.to_js()+"]",o>0&&(t=".concat("+t+")"),r+=t})),r},$DictOrSetCtx.prototype.to_js=function(){switch(this.js_processed=!0,this.real){case"dict":if((r=this.packed_indices()).length>0)return"_b_.dict.$factory("+this.unpack_dict(r)+")"+$to_js(this.tree);for(var e=[],t=0;t0?"_b_.set.$factory("+this.unpack_set(r)+")":"_b_.set.$factory(["+$to_js(this.items)+"])"+$to_js(this.tree)};var $DoubleStarArgCtx=$B.parser.$DoubleStarArgCtx=function(e){this.type="double_star_arg",this.parent=e,this.tree=[],e.tree[e.tree.length]=this};$DoubleStarArgCtx.prototype.toString=function(){return"**"+this.tree},$DoubleStarArgCtx.prototype.transition=function(e,t){var r=this;switch(e){case"id":case"imaginary":case"int":case"float":case"str":case"bytes":case"[":case"(":case"{":case".":case"not":case"lambda":return $transition(new $AbstractExprCtx(r,!1),e,t);case",":case")":return $transition(r.parent,e);case":":if("lambda"==r.parent.parent.type)return $transition(r.parent.parent,e)}$_SyntaxError(r,"token "+e+" after "+r)},$DoubleStarArgCtx.prototype.to_js=function(){return this.js_processed=!0,'{$nat:"pdict",arg:'+$to_js(this.tree)+"}"};var $EllipsisCtx=$B.parser.$EllipsisCtx=function(e){this.type="ellipsis",this.parent=e,this.nbdots=1,this.start=$pos,e.tree[e.tree.length]=this};$EllipsisCtx.prototype.toString=function(){return"ellipsis"},$EllipsisCtx.prototype.transition=function(e,t){var r=this;return"."==e?(r.nbdots++,3==r.nbdots&&$pos-r.start==2&&(r.$complete=!0),r):r.$complete?$transition(r.parent,e,t):($pos--,void $_SyntaxError(r,"token "+e+" after "+r))},$EllipsisCtx.prototype.to_js=function(){return this.js_processed=!0,'$B.builtins["Ellipsis"]'};var $EndOfPositionalCtx=$B.parser.$EndOfConditionalCtx=function(e){this.type="end_positional",this.parent=e,e.has_end_positional=!0,e.parent.pos_only=e.tree.length,e.tree.push(this)};$EndOfPositionalCtx.prototype.transition=function(e,t){var r=this;if(","==e||")"==e)return $transition(r.parent,e,t);$_SyntaxError(r,"token "+e+" after "+r)},$EndOfPositionalCtx.prototype.to_js=function(){return"/"};var $ExceptCtx=$B.parser.$ExceptCtx=function(e){this.type="except",this.parent=e,e.tree[e.tree.length]=this,this.tree=[],this.expect="id",this.scope=$get_scope(this)};$ExceptCtx.prototype.toString=function(){return"(except) "},$ExceptCtx.prototype.transition=function(e,t){var r=this;switch(e){case"id":case"imaginary":case"int":case"float":case"str":case"bytes":case"[":case"(":case"{":case"not":case"lambda":if("id"==r.expect)return r.expect="as",$transition(new $AbstractExprCtx(r,!1),e,t);case"as":if("as"==r.expect&&void 0===r.has_alias)return r.expect="alias",r.has_alias=!0,r;case"id":if("alias"==r.expect)return r.expect=":",r.set_alias(t),r;break;case":":var n=r.expect;if("id"==n||"as"==n||":"==n)return $BodyCtx(r);break;case"(":if("id"==r.expect&&0==r.tree.length)return r.parenth=!0,r;break;case")":if(","==r.expect||"as"==r.expect)return r.expect="as",r;case",":if(void 0!==r.parenth&&void 0===r.has_alias&&("as"==r.expect||","==r.expect))return r.expect="id",r}$_SyntaxError(r,"token "+e+" after "+r.expect)},$ExceptCtx.prototype.set_alias=function(e){this.tree[0].alias=$mangle(e,this),$bind(e,this.scope,this)},$ExceptCtx.prototype.transform=function(e,t){var r=$NodeJS("void(0)");r.line_num=e.line_num,e.insert(0,r);var n=$B.last(e.children);n.C.tree&&n.C.tree[0]&&"return"==n.C.tree[0].type||e.add($NodeJS("$B.del_exc()"))},$ExceptCtx.prototype.to_js=function(){switch(this.js_processed=!0,this.tree.length){case 0:return"else";case 1:if("Exception"==this.tree[0].name)return"else if(1)"}var e=[];this.tree.forEach((function(t){e.push(t.to_js())}));var t="";if($B.debug>0){var r=$get_module(this);t='($locals.$line_info = "'+$get_node(this).line_num+","+r.id+'") && '}return"else if("+t+"$B.is_exc("+this.error_name+",["+e.join(",")+"]))"};var $ExprCtx=$B.parser.$ExprCtx=function(e,t,r){if(this.type="expr",this.name=t,this.with_commas=r,this.expect=",",this.parent=e,e.packed&&(this.packed=e.packed),e.is_await){var n=$get_node(this);n.has_await=n.has_await||[],this.is_await=e.is_await,n.has_await.push(this)}e.assign&&(this.assign=e.assign),this.tree=[],e.tree[e.tree.length]=this};$ExprCtx.prototype.toString=function(){return"(expr "+this.with_commas+") "+this.tree},$ExprCtx.prototype.transition=function(e,t){var r=this;switch(e){case"bytes":case"float":case"id":case"imaginary":case"int":case"lambda":case"pass":case"str":console.log("syntax error",r,e,t),$_SyntaxError(r,"token "+e+" after "+r);break;case"{":return"id"==r.tree[0].type&&-1!=["print","exec"].indexOf(r.tree[0].value)||$_SyntaxError(r,"token "+e+" after "+r),new $DictOrSetCtx(r);case"[":case"(":case".":case"not":if("expr"==r.expect)return r.expect=",",$transition(new $AbstractExprCtx(r,!1),e,t)}switch(e){case"not":if(","==r.expect)return new $ExprNot(r);break;case"in":if("target_list"==r.parent.type)return $transition(r.parent,e);if(","==r.expect)return $transition(r,"op","in");case",":if(","==r.expect&&(r.with_commas||["assign","return"].indexOf(r.parent.type)>-1)){$parent_match(r,{type:"yield",from:!0})&&$_SyntaxError(r,"no implicit tuple for yield from"),r.parent.tree.pop();var n=new $ListOrTupleCtx(r.parent,"tuple");return n.implicit=!0,n.has_comma=!0,n.tree=[r],r.parent=n,n}return $transition(r.parent,e);case".":return new $AttrCtx(r);case"[":return new $AbstractExprCtx(new $SubCtx(r),!0);case"(":return new $CallCtx(r);case"op":var o=r.parent,a=t;if("ternary"==o.type&&o.in_else){var s=new $OpCtx(r,a);return new $AbstractExprCtx(s,!1)}for(var i=r.parent,_=null;;)if("expr"==i.type)i=i.parent;else if("op"==i.type&&$op_weight[i.op]>=$op_weight[a]&&("**"!=i.op||"**"!=a))_=i,i=i.parent;else{if(!("not"==i.type&&$op_weight.not>$op_weight[a]))break;_=i,i=i.parent}if(null===_){for(;r.parent!==i;)o=(r=r.parent).parent;var l;r.parent.tree.pop(),(l=new $ExprCtx(o,"operand",r.with_commas)).expect=",",r.parent=l;s=new $OpCtx(r,a);return new $AbstractExprCtx(s,!1)}if("and"===a||"or"===a)for(;"not"==_.parent.type||"expr"==_.parent.type&&"not"==_.parent.parent.type;)o=(_=_.parent).parent;if("op"==_.type){var c=!1;switch(_.op){case"<":case"<=":case"==":case"!=":case"is":case">=":case">":c=!0}if(c)switch(a){case"<":case"<=":case"==":case"!=":case"is":case">=":case">":var u=_.tree[1],f=u.to_js(),p=new Object;for(var $ in u)p[$]=u[$];var d="$c"+chained_comp_num;for(u.to_js=function(){return d},p.to_js=function(){return d},chained_comp_num++;_.parent&&"op"==_.parent.type&&$op_weight[_.parent.op]<$op_weight[_.op];)_=_.parent;_.parent.tree.pop();var h=new $OpCtx(_,"and");h.wrap={name:d,js:f},p.parent=h,h.tree.push("xxx");s=new $OpCtx(p,a);return new $AbstractExprCtx(s,!1)}}_.parent.tree.pop(),(l=new $ExprCtx(_.parent,"operand",!1)).tree=[i],_.parent=l;s=new $OpCtx(_,a);return new $AbstractExprCtx(s,!1);case"augm_assign":for(var m=r;m;)"assign"==m.type||"augm_assign"==m.type?$_SyntaxError(r,"augmented assignment inside assignment"):"op"==m.type?$_SyntaxError(r,["cannot assign to operator"]):"list_or_tuple"==m.type?$_SyntaxError(r,[`'${m.real}' is an illegal expression for augmented assignment`]):["list","tuple"].indexOf(m.name)>-1?$_SyntaxError(r,[`'${m.name}' is an illegal expression for augmented assignment`]):["dict_or_set"].indexOf(m.name)>-1&&$_SyntaxError(r,[`'${m.tree[0].real} display' is an illegal expression for augmented assignment`]),m=m.parent;return","==r.expect?new $AbstractExprCtx(new $AugmentedAssignCtx(r,t),!0):$transition(r.parent,e,t);case":":if("sub"==r.parent.type||"list_or_tuple"==r.parent.type&&"sub"==r.parent.parent.type)return new $AbstractExprCtx(new $SliceCtx(r.parent),!1);if("slice"==r.parent.type)return $transition(r.parent,e,t);if("node"==r.parent.type){if(1==r.tree.length){var g=r.tree[0];if(["id","sub","attribute"].indexOf(g.type)>-1)return new $AbstractExprCtx(new $AnnotationCtx(r),!1);if("tuple"==g.real&&","==g.expect&&1==g.tree.length)return new $AbstractExprCtx(new $AnnotationCtx(g.tree[0]),!1)}$_SyntaxError(r,"invalid target for annotation")}break;case"=":var b;if(","==r.expect){if("call_arg"==r.parent.type)return"id"!=r.tree[0].type&&$_SyntaxError(r,['expression cannot contain assignment, perhaps you meant "=="?']),new $AbstractExprCtx(new $KwArgCtx(r),!0);if(b=function(e,t){for(;e.parent;){if(e.parent.type==t)return e.parent;e=e.parent}return!1}(r,"annotation"))return $transition(b,e,t);if("op"==r.parent.type)$_SyntaxError(r,["cannot assign to operator"]);else if("not"==r.parent.type)$_SyntaxError(r,["cannot assign to operator"]);else if("list_or_tuple"==r.parent.type)for(var y=0;y0&&r.tree[0].assign?$_SyntaxError(r,["cannot assign to named expression"]):"expr"==r.parent.type&&"target list"==r.parent.name?$_SyntaxError(r,"token "+e+" after "+r):"lambda"==r.parent.type&&"node"!=r.parent.parent.parent.type&&$_SyntaxError(r,['expression cannot contain assignment, perhaps you meant "=="?']);for(;void 0!==r.parent;)"condition"==(r=r.parent).type?$_SyntaxError(r,"token "+e+" after "+r):"augm_assign"==r.type&&$_SyntaxError(r,"assignment inside augmented assignment");return r=r.tree[0],new $AbstractExprCtx(new $AssignCtx(r),!0)}break;case":=":var x=r.parent.type;if(["node","assign","kwarg","annotation"].indexOf(x)>-1||"func_arg_id"==x&&r.parent.tree.length>0?$_SyntaxError(r,":= invalid, parent "+x):"call_arg"==x&&"call"==r.parent.parent.type&&"lambda"==r.parent.parent.parent.type&&$_SyntaxError(r,":= invalid inside function arguments"),1==r.tree.length&&"id"==r.tree[0].type){for(var B=$get_scope(r),w=r.tree[0].value;B.is_comp;)B=B.parent_block;$bind(w,B,r),(m=r.parent).tree.pop();var k=new $AbstractExprCtx(m,!1);return k.assign=r.tree[0],k}$_SyntaxError(r,"token "+e+" after "+r);case"if":if("comp_iterable"==r.parent.type)break;for(var E=!1,j=r.parent;j&&"list_or_tuple"!=j.type&&"comp_for"!=j.type;){if("comp_if"==j.type){E=!0;break}if("call_arg"==j.type||"sub"==j.type)break;if("expr"==j.type&&"comp_iterable"==j.parent.type){E=!0;break}j=j.parent}if(E)break;for(j=r;j.parent&&("op"==j.parent.type||"not"==j.parent.type||"expr"==j.parent.type&&"operand"==j.parent.name);)j=j.parent;return new $AbstractExprCtx(new $TernaryCtx(j),!0);case"eol":if(2==r.tree.length&&"id"==r.tree[0].type&&["print","exec"].indexOf(r.tree[0].value)>-1&&$_SyntaxError(r,["Missing parentheses in call to '"+r.tree[0].value+"'."]),-1==["dict_or_set","list_or_tuple","str"].indexOf(r.parent.type)){var N=r.tree[0];"packed"==N.type?($pos=N.pos,$_SyntaxError(r,["can't use starred expression here"])):"call"==N.type&&"packed"==N.func.type&&($pos=N.func.pos,$_SyntaxError(r,["can't use starred expression here"]))}}return $transition(r.parent,e)},$ExprCtx.prototype.to_js=function(e){var t;if(this.js_processed=!0,t="list"==this.type?"["+$to_js(this.tree)+"]":1==this.tree.length?this.tree[0].to_js(e):"_b_.tuple.$factory(["+$to_js(this.tree)+"])",this.is_await&&(t="await ($B.promise("+t+"))"),this.assign){for(var r=$get_scope(this);r.is_comp;)r=r.parent_block;if(r.globals&&r.globals.has(this.assign.value))for(;r.parent_block&&"__builtins__"!==r.parent_block.id;)r=r.parent_block;else r.nonlocals&&r.nonlocals[this.assign.value]&&(r=r.parent_block);t="($locals_"+r.id.replace(/\./g,"_")+'["'+this.assign.value+'"] = '+t+")"}return"call"==this.name&&(t+="()"),t};var $ExprNot=$B.parser.$ExprNot=function(e){this.type="expr_not",this.parent=e,this.tree=[],e.tree[e.tree.length]=this};$ExprNot.prototype.transition=function(e,t){var r=this;if("in"==e)return r.parent.tree.pop(),new $AbstractExprCtx(new $OpCtx(r.parent,"not_in"),!1);$_SyntaxError(r,"token "+e+" after "+r)},$ExprNot.prototype.toString=function(){return"(expr_not)"};var $ForExpr=$B.parser.$ForExpr=function(e){e.node.parent.is_comp&&(e.node.parent.first_for=this),this.type="for",this.parent=e,this.tree=[],e.tree[e.tree.length]=this,this.loop_num=$loop_num,this.scope=$get_scope(this),this.scope.is_comp,this.module=this.scope.module,$loop_num++};$ForExpr.prototype.toString=function(){return"(for) "+this.tree},$ForExpr.prototype.transition=function(e,t){var r=this;switch(e){case"in":return 0==r.tree[0].tree.length&&$_SyntaxError(r,"missing target between 'for' and 'in'"),new $AbstractExprCtx(new $ExprCtx(r,"target list",!0),!1);case":":return(r.tree.length<2||"abstract_expr"==r.tree[1].tree[0].type)&&$_SyntaxError(r,"token "+e+" after "+r),$BodyCtx(r)}$_SyntaxError(r,"token "+e+" after "+r)},$ForExpr.prototype.transform=function(e,t){for(var r=this.parent.node.parent;r;){if(r.is_comp){var n=$get_module(this);void 0===n.outermost_expr&&(r.outermost_expr=this.tree[1],n.outermost_expr=this.tree[1],this.tree.pop(),new $RawJSCtx(this,"expr"));break}r=r.parent}if(this.async)return this.transform_async(e,t);var o=$get_scope(this),a=this.tree[0],s=1==a.tree.length&&"id"==a.expect,i=this.tree[1],_=this.loop_num,l="$locals_"+o.id.replace(/\./g,"_"),c="\n"+" ".repeat(e.indent+4),u=!1;if(1==a.tree.length&&!o.blurred&&"id"!=a.expct&&"expr"==i.type&&"expr"==i.tree[0].type&&"call"==i.tree[0].tree[0].type){var f=i.tree[0].tree[0];if("id"==f.func.type)"range"==f.func.value&&f.tree.length<3&&f.tree.length>0&&(u=f)}var p=[],$=0,d=e.children;if(u){this.has_break&&(O=new $Node,new $NodeJSCtx(O,l+'["$no_break'+_+'"] = true'),p[$++]=O);for(var h,m=$get_scope(this),g=[];m.binding.range&&g.push(m.id),m.parent_block;)m=m.parent_block;h=1==g.length&&"__builtins__"==g[0];var b=new $Node;b.module=e.parent.module,new $NodeJSCtx(b,h?"if(1)":"if("+f.func.to_js()+" === _b_.range)"),p[$++]=b;var y=a.to_js(),v=!1;if(1==u.tree.length){if("int"==(w=u.tree[0].tree[0]).tree[0].type&&0<(w=parseInt(w.to_js()))<$B.max_int){v=!0;var x="$i"+$B.UUID();(E=$NodeJS("for (var "+x+" = 0; "+x+" < "+w+"; "+x+"++)")).add($NodeJS(y+" = "+x))}var B=0,w=u.tree[0].to_js()}else B=u.tree[0].to_js(),w=u.tree[1].to_js();if(!v){var k="var $stop_"+_+" = $B.int_or_bool("+w+"),"+c+" $next"+_+" = "+B+","+c+" $safe"+_+" = typeof $next"+_+' == "number" && typeof $stop_'+_+' == "number";'+c+" while(true)",E=new $Node;new $NodeJSCtx(E,k),E.add($NodeJS("if($safe"+_+" && $next"+_+">= $stop_"+_+"){break}")),E.add($NodeJS("else if(!$safe"+_+" && $B.ge($next"+_+", $stop_"+_+")){break}")),E.add($NodeJS(y+" = $next"+_)),E.add($NodeJS("if($safe"+_+"){$next"+_+" += 1}")),E.add($NodeJS("else{$next"+_+" = $B.add($next"+_+",1)}"))}if(d.forEach((function(e){E.add(e.clone_tree())})),"return"!=$B.last(e.children).C.tree[0].type){k='$locals.$line_info = "'+e.line_num+","+this.module+'";if($locals.$f_trace !== _b_.None){$B.trace_line()};_b_.None;';E.add($NodeJS(k))}var j=!1;if("module"==o.ntype)for(r=e.parent;r;){if(r.for_wrapper){j=!0;break}r=r.parent}if("module"!=o.ntype||j)b.add(E);else{var N=new $Node;N.for_wrapper=!0,k="function $f"+_+"(",this.has_break&&(k+="$no_break"+_),new $NodeJSCtx(N,k+=")"),b.add(N),N.add(E),this.has_break&&N.add($NodeJS("return $no_break"+_)),b.add($NodeJS("var $res"+_+" = $f"+_+"();")),this.has_break&&b.add($NodeJS("var $no_break"+_+" = $res"+_))}if(h){e.parent.children.splice(t,1);var C=0;return this.has_break&&(e.parent.insert(t,p[0]),C++),p[C].children.forEach((function(r){e.parent.insert(t+C,r)})),e.parent.children[t].line_num=e.line_num,e.parent.children[t].bindings=e.bindings,e.children=[],0}var S=$NodeJS("else");p[$++]=S;for(var A=p.length-1;A>=0;A--)e.parent.insert(t+1,p[A]);this.test_range=!0,p=[],$=0}var O=new $Node;O.line_num=$get_node(this).line_num;var I=i.to_js(),T="$iter"+_;new $NodeJSCtx(O,k="var "+T+" = "+I+';$locals["$next'+_+'"] = $B.$getattr($B.$iter('+T+'),"__next__")'),p[$++]=O,this.has_break&&(p[$++]=$NodeJS(l+'["$no_break'+_+'"] = true;'));var F=new $Node;if(k=this.has_break?"while("+l+'["$no_break'+_+'"])':"while(true)",new $NodeJSCtx(F,k),F.C.loop_num=_,F.C.type="for",p[$++]=F,e.parent.children.splice(t,1),this.test_range)for(A=p.length-1;A>=0;A--)S.insert(0,p[A]);else for(A=p.length-1;A>=0;A--)e.parent.insert(t,p[A]),p.length;var R=$NodeJS("try");R.bindings=e.bindings,F.add(R);var J=new $Node;J.id=this.module;var M=new $NodeCtx(J),L=new $ExprCtx(M,"left",!0);if(s){var P=new $ListOrTupleCtx(L);P.real="tuple",P.tree=a.tree}else L.tree=a.tree;if(new $AssignCtx(L).tree[1]=new $JSCode('$locals["$next'+_+'"]()'),R.add(J),F.add($NodeJS("catch($err){if($B.is_exc($err, [_b_.StopIteration])){break;}else{throw($err)}}")),d.forEach((function(e){F.add(e.clone())})),0==e.children.length&&console.log("bizarre",this),"return"!=$B.last(e.children).C.tree[0].type){k='$locals.$line_info = "'+e.line_num+","+this.module+'";if($locals.$f_trace !== _b_.None){$B.trace_line()};_b_.None;';F.add($NodeJS(k))}return e.children=[],0},$ForExpr.prototype.transform_async=function(e,t){var r=$get_scope(this),n=this.tree[0],o=(1==n.tree.length&&n.expect,this.tree[1]),a=this.loop_num,s=(r.id.replace(/\./g,"_")," ".repeat(e.indent+4),[]),i="$iter"+a,_="$type"+a,l="$running"+a,c="$anext"+a,u="var "+i+" = "+o.to_js();s.push($NodeJS(u)),s.push($NodeJS("var "+_+" = _b_.type.$factory( "+i+")")),u=i+" = $B.$call($B.$getattr("+_+', "__aiter__"))('+i+")",s.push($NodeJS(u)),s.push($NodeJS("var "+l+" = true")),s.push($NodeJS("var "+c+" = $B.$call($B.$getattr("+_+', "__anext__"))'));var f=$NodeJS("while("+l+")");s.push(f);var p=$NodeJS("try");if(f.add(p),1==n.tree.length){u=n.to_js()+" = await ($B.promise("+c+"("+i+")))";p.add($NodeJS(u))}else{var $=new $Node,d=new $NodeCtx($),h=new $ExprCtx(d,"left",!1);h.tree.push(n),n.parent=h;var m=new $AssignCtx(h);new $RawJSCtx(m,"await ($B.promise("+c+"("+i+")))"),p.add($)}var g=$NodeJS("catch(err)");f.add(g);u="if(err.__class__ === _b_.StopAsyncIteration){"+l+" = false; continue}else{throw err}";g.add($NodeJS(u)),e.children.forEach((function(e){f.add(e)})),e.parent.children.splice(t,1);for(var b=s.length-1;b>=0;b--)e.parent.insert(t,s[b]);return e.children=[],0},$ForExpr.prototype.to_js=function(){this.js_processed=!0;var e=this.tree.pop();return"for ("+$to_js(this.tree)+" in "+e.to_js()+")"};var $FromCtx=$B.parser.$FromCtx=function(e){this.type="from",this.parent=e,this.module="",this.names=[],e.tree[e.tree.length]=this,this.expect="module",this.scope=$get_scope(this)};$FromCtx.prototype.add_name=function(e){this.names[this.names.length]=e,"*"==e&&(this.scope.blurred=!0)},$FromCtx.prototype.bind_names=function(){var e=$get_scope(this);this.names.forEach((function(t){Array.isArray(t)&&(t=t[1]),$bind(t,e,this)}),this)},$FromCtx.prototype.transition=function(e,t){var r=this;switch(e){case"id":if("id"==r.expect)return r.add_name(t),r.expect=",",r;if("alias"==r.expect)return r.names[r.names.length-1]=[$B.last(r.names),t],r.expect=",",r;case".":if("module"==r.expect)return r.module+="id"==e?t:".",r;case"import":if("module"==r.expect)return r.expect="id",r;case"op":if("*"==t&&"id"==r.expect&&0==r.names.length)return"module"!==$get_scope(r).ntype&&$_SyntaxError(r,["import * only allowed at module level"]),r.add_name("*"),r.expect="eol",r;case",":if(","==r.expect)return r.expect="id",r;case"eol":switch(r.expect){case",":case"eol":return r.bind_names(),$transition(r.parent,e);case"id":$_SyntaxError(r,["trailing comma not allowed without surrounding parentheses"]);default:$_SyntaxError(r,["invalid syntax"])}case"as":if(","==r.expect||"eol"==r.expect)return r.expect="alias",r;case"(":if("id"==r.expect)return r.expect="id",r;case")":if(","==r.expect||"id"==r.expect)return r.expect="eol",r}$_SyntaxError(r,"token "+e+" after "+r)},$FromCtx.prototype.toString=function(){return"(from) "+this.module+" (import) "+this.names},$FromCtx.prototype.to_js=function(){this.js_processed=!0;var e=$get_scope(this),t=$get_module(this),r=t.module,n=[],o=0,a=$get_node(this).indent,s=" ".repeat(a);if(r.startsWith("$exec")){var i=$B.last($B.frames_stack)[1];i.module&&i.module.__name__&&(r=i.module.__name__)}for(var _=this.module.split("."),l=0;l<_.length;l++)t.imports[_.slice(0,l+1).join(".")]=!0;for(var c,u=this.module.replace(/\$/g,""),f=[];u.length>0&&"."==u.charAt(0);){if(void 0===c?void 0!==$B.imported[r]&&(f=(c=$B.imported[r].__package__).split(".")):(c=$B.imported[c],f.pop()),void 0===c)return"throw _b_.SystemError.$factory(\"Parent module '' not loaded, cannot perform relative import\")";"None"==c&&console.log("package is None !"),u=u.substr(1)}u&&f.push(u),this.module=f.join(".");var p=this.module.replace(/\$/g,"");n[o++]='var module = $B.$import("',n[o++]=p+'",["';for(var $=[],d=(l=0,this.names.length);l-1&&$_SyntaxError(r,["duplicate argument "+t+" in function definition"])),new $FuncArgIdCtx(r,t);case",":if(","==r.expect)return r.expect="id",r;$_SyntaxError(r,"token "+e+" after "+r);case")":var n=$B.last(r.tree);return n&&"func_star_arg"==n.type&&"*"==n.name&&("*"==r.op?$_SyntaxError(r,["named arguments must follow bare *"]):$_SyntaxError(r,"invalid syntax")),r.parent;case"op":r.has_kw_arg&&$_SyntaxError(r,"duplicate keyword argument");var o=t;if(r.expect=",","*"==o)return r.has_star_arg&&$_SyntaxError(r,"duplicate star argument"),new $FuncStarArgCtx(r,"*");if("**"==o)return new $FuncStarArgCtx(r,"**");if("/"==o)return r.has_end_positional?$_SyntaxError(r,["duplicate / in function parameters"]):r.has_star_arg&&$_SyntaxError(r,["/ after * in function parameters"]),new $EndOfPositionalCtx(r);$_SyntaxError(r,"token "+o+" after "+r);case":":if("lambda"==r.parent.type)return $transition(r.parent,e)}$_SyntaxError(r,"token "+e+" after "+r)},$FuncArgs.prototype.to_js=function(){return this.js_processed=!0,$to_js(this.tree)};var $FuncArgIdCtx=$B.parser.$FuncArgIdCtx=function(e,t){this.type="func_arg_id",this.name=t,this.parent=e,e.has_star_arg?e.parent.after_star.push(t):e.parent.positional_list.push(t);var r=$get_node(this);r.binding[t]&&$_SyntaxError(e,["duplicate argument '"+t+"' in function definition"]),$bind(t,r,this),this.tree=[],e.tree[e.tree.length]=this;for(var n=e;void 0!==n.parent;){if("def"==n.type){n.locals.push(t);break}n=n.parent}this.expect="="};$FuncArgIdCtx.prototype.toString=function(){return"func arg id "+this.name+"="+this.tree},$FuncArgIdCtx.prototype.transition=function(e,t){var r=this;switch(e){case"=":if("="==r.expect){r.has_default=!0;var n=r.parent.parent;return r.parent.has_star_arg?n.default_list.push(n.after_star.pop()):n.default_list.push(n.positional_list.pop()),new $AbstractExprCtx(r,!1)}break;case",":case")":if(!r.parent.has_default||0!=r.tree.length||void 0!==r.parent.has_star_arg)return $transition(r.parent,e);$pos-=r.name.length,$_SyntaxError(r,["non-default argument follows default argument"]);case":":return"lambda"==r.parent.parent.type?$transition(r.parent.parent,":"):(r.has_default&&$_SyntaxError(r,"token "+e+" after "+r),new $AbstractExprCtx(new $AnnotationCtx(r),!1))}$_SyntaxError(r,"token "+e+" after "+r)},$FuncArgIdCtx.prototype.to_js=function(){return this.js_processed=!0,this.name+$to_js(this.tree)};var $FuncStarArgCtx=$B.parser.$FuncStarArgCtx=function(e,t){this.type="func_star_arg",this.op=t,this.parent=e,this.node=$get_node(this),e.has_star_arg="*"==t,e.has_kw_arg="**"==t,e.tree[e.tree.length]=this};$FuncStarArgCtx.prototype.toString=function(){return"(func star arg "+this.op+") "+this.name},$FuncStarArgCtx.prototype.transition=function(e,t){var r=this;switch(e){case"id":return void 0===r.name&&r.parent.names.indexOf(t)>-1&&$_SyntaxError(r,["duplicate argument "+t+" in function definition"]),r.set_name(t),r.parent.names.push(t),r;case",":case")":return void 0===r.name&&(r.set_name("*"),r.parent.names.push("*")),$transition(r.parent,e);case":":return"lambda"==r.parent.parent.type?$transition(r.parent.parent,":"):(void 0===r.name&&$_SyntaxError(r,"annotation on an unnamed parameter"),new $AbstractExprCtx(new $AnnotationCtx(r),!1))}$_SyntaxError(r,"token "+e+" after "+r)},$FuncStarArgCtx.prototype.set_name=function(e){this.name=e,this.node.binding[e]&&$_SyntaxError(C,["duplicate argument '"+e+"' in function definition"]),$bind(e,this.node,this);for(var t=this.parent;void 0!==t.parent;){if("def"==t.type){t.locals.push(e);break}t=t.parent}"*"==this.op?t.other_args='"'+e+'"':t.other_kw='"'+e+'"'};var $GlobalCtx=$B.parser.$GlobalCtx=function(e){for(this.type="global",this.parent=e,this.tree=[],e.tree[e.tree.length]=this,this.expect="id",this.scope=$get_scope(this),this.scope.globals=this.scope.globals||new Set,this.module=$get_module(this);this.module.module!=this.module.id;)this.module=this.module.parent_block;this.module.binding=this.module.binding||{}};$GlobalCtx.prototype.toString=function(){return"global "+this.tree},$GlobalCtx.prototype.transition=function(e,t){var r=this;switch(e){case"id":if("id"==r.expect)return new $IdCtx(r,t),r.add(t),r.expect=",",r;break;case",":if(","==r.expect)return r.expect="id",r;break;case"eol":if(","==r.expect)return $transition(r.parent,e)}$_SyntaxError(r,"token "+e+" after "+r)},$GlobalCtx.prototype.add=function(e){this.scope.annotations&&this.scope.annotations.has(e)&&$_SyntaxError(this,["annotated name '"+e+"' can't be global"]),this.scope.globals.add(e);var t=this.scope.parent_block;if(this.module.module.startsWith("$exec"))for(;t&&t.parent_block!==this.module;)t._globals=t._globals||{},t._globals[e]=this.module.id,delete t.binding[e],t=t.parent_block;this.module.binding[e]=!0},$GlobalCtx.prototype.to_js=function(){return this.js_processed=!0,""};var $IdCtx=$B.parser.$IdCtx=function(e,t){this.type="id",this.value=$mangle(t,e),this.parent=e,this.tree=[],e.tree[e.tree.length]=this;var r=this.scope=$get_scope(this);this.blurred_scope=this.scope.blurred,this.env=clone(this.scope.binding),["def","generator"].indexOf(r.ntype)>-1&&(r.referenced=r.referenced||{},$B.builtins[this.value]||(r.referenced[this.value]=!0)),"call_arg"==e.parent.type&&(this.call_arg=!0);for(var n=e;void 0!==n.parent;){switch(n.type){case"ctx_manager_alias":$bind(t,r,this);break;case"list_or_tuple":case"dict_or_set":case"call_arg":case"def":case"lambda":void 0===n.vars?n.vars=[t]:-1==n.vars.indexOf(t)&&n.vars.push(t),this.call_arg&&"lambda"==n.type&&(void 0===n.locals?n.locals=[t]:n.locals.push(t))}n=n.parent}if($parent_match(e,{type:"target_list"})&&(this.no_bindings=!0,$bind(t,r,this),this.bound=!0),["def","generator"].indexOf(r.ntype)>-1){for(var o=this.parent;o;){if("list_or_tuple"==o.type&&o.is_comp()){this.in_comp=!0;break}o=o.parent}"expr"==e.type&&"comp_if"==e.parent.type||"global"==e.type&&(void 0===r.globals?r.globals=new Set([t]):r.globals.add(t))}};$IdCtx.prototype.toString=function(){return"(id) "+this.value+":"+(this.tree||"")},$IdCtx.prototype.transition=function(e,t){var r=this;switch(e){case"=":return"expr"==r.parent.type&&void 0!==r.parent.parent&&"call_arg"==r.parent.parent.type?new $AbstractExprCtx(new $KwArgCtx(r.parent),!1):$transition(r.parent,e,t);case"op":return $transition(r.parent,e,t);case"id":case"str":case"int":case"float":case"imaginary":["print","exec"].indexOf(r.value)>-1&&$_SyntaxError(r,["missing parenthesis in call to '"+r.value+"'"]),$_SyntaxError(r,"token "+e+" after "+r)}return"packed"==this.parent.parent.type&&-1==[".","[","("].indexOf(e)?this.parent.parent.transition(e,t):$transition(r.parent,e,t)},$IdCtx.prototype.firstBindingScopeId=function(){for(var e=this.scope;e;){if(e.globals&&e.globals.has(this.value))return $get_module(this).id;if(e.binding&&e.binding[this.value])return e.id;e=e.parent}},$IdCtx.prototype.boundBefore=function(e){var t=$get_node(this),r=!1;for(r;t.parent;){var n=t.parent;if(n.bindings&&n.bindings[this.value])return n.bindings[this.value];for(var o=0;o0){t=!0;break}if(_===o)break}return t||a}if(s===e)break;o=s}return a},$IdCtx.prototype.to_js=function(e){if(void 0!==this.result&&"generator"==this.scope.ntype)return this.result;var t=this.value;if("__BRYTHON__"==t||"$B"==t)return t;if(t.startsWith("comp_result_"+$B.lambda_magic))return this.bound?"var "+t:t;if(this.js_processed=!0,this.scope._globals&&this.scope._globals[t]&&(this.global_module=this.scope._globals[t]),this.global_module)return"$locals_"+this.global_module.replace(/\./g,"_")+'["'+t+'"]';var r=void 0!==this.scope.binding[t],n=$get_node(this),o=n.bound_before;if(this.nonlocal=this.scope.nonlocals&&void 0!==this.scope.nonlocals[t],this.unbound=this.unbound||r&&!this.bound&&o&&-1==o.indexOf(t),!this.bound&&this.scope.C&&"class"==this.scope.ntype&&this.scope.C.tree[0].name==t)return'$B.$search("'+t+'")';if(this.unbound&&!this.nonlocal)return"def"==this.scope.ntype||"generator"==this.scope.ntype?'$B.$local_search("'+t+'")':'$B.$search("'+t+'")';for(var a=$get_scope(this),s=a,i=[],_=['"'+a.id+'"'],l=a;;){if(l.parent_block){if(l.parent_block==$B.builtins_scope)break;if(void 0===l.parent_block.id)break;l=l.parent_block}_.push('"'+l.id+'"')}if(_="["+_.join(", ")+"]",a.globals&&a.globals.has(t)&&(_=['"'+l.id+'"'],a=l),this.nonlocal||this.bound){var c=this.firstBindingScopeId();if(void 0!==c)return"$locals_"+c.replace(/\./g,"_")+'["'+t+'"]';if(this.bound)return"$locals_"+a.id.replace(/\./g,"_")+'["'+t+'"]'}for(var u="$locals_"+l.id.replace(/\./g,"_");;){if(void 0!==s.globals&&s.globals.has(t))return this.boundBefore(l)||this.augm_assign?u+'["'+t+'"]':'$B.$global_search("'+t+'", '+_+")";if(s===a){if(o)(o.indexOf(t)>-1||s.C&&"def"==s.C.tree[0].type&&s.C.tree[0].env.indexOf(t)>-1)&&i.push(s);else if(s.binding[t]){if(void 0!==n.locals[t]){i.push(s);break}s.is_comp||s.parent_block&&s.parent_block.is_comp||i.push(s)}}else void 0===s.binding&&console.log("scope",s,t,"no binding",a),s.binding[t]&&i.push(s);if(!s.parent_block)break;s=s.parent_block}if(this.found=i,this.nonlocal&&i[0]===a&&i.shift(),i.length>0){if(i[0].C&&i[0]===a&&"$"!=t.charAt(0)){var f=n.locals||{},p=a.nonlocals;try{if(void 0===f[t]&&!this.augm_assign&&("def"!=a.type||"generator"!=a.type)&&"class"!=a.ntype&&a.C.tree[0].args&&-1==a.C.tree[0].args.indexOf(t)&&(void 0===p||void 0===p[t]))return this.result='$B.$local_search("'+t+'")',this.result}catch(e){throw console.log("error",t,a),e}}if(i.length>1&&i[0].C&&"class"==i[0].C.tree[0].type){var $="$locals_"+i[0].id.replace(/\./g,"_"),d="$locals_"+i[1].id.replace(/\./g,"_");if(o)return o.indexOf(t)>-1?(this.found=i[0].binding[t],h=$):(this.found=i[1].binding[t],h=d),this.result=h+'["'+t+'"]',this.result;this.found=!1;var h=$+'["'+t+'"] !== undefined ? ';return h+=$+'["'+t+'"] : ',this.result="("+h+d+'["'+t+'"])',this.result}s=i[0];this.found=s.binding[t];var m="$locals_"+s.id.replace(/\./g,"_");if(void 0===s.C)if("__builtins__"==s.id)l.blurred?t="("+u+'["'+t+'"] || _b_.'+t+")":(t="_b_."+t,this.is_builtin=!0);else if(this.bound||this.augm_assign)t=m+'["'+t+'"]';else{if(s===a&&void 0===this.env[t])return this.result='$B.$search("'+t+'")',this.result;t=this.boundBefore(s)?m+'["'+t+'"]':'$B.$check_def("'+t+'",'+m+'["'+t+'"])'}else t=s===a?s.globals&&s.globals.has(t)?u+'["'+t+'"]':this.bound||this.augm_assign||this.boundBefore(s)?'$locals["'+t+'"]':'$B.$check_def_local("'+t+'",$locals["'+t+'"])':this.augm_assign?m+'["'+t+'"]':'$B.$check_def_free("'+t+'",'+m+'["'+t+'"])';return this.result=t+$to_js(this.tree,""),this.result}return this.unknown_binding=!0,this.result='$B.$global_search("'+t+'", '+_+")",this.result};var $ImportCtx=$B.parser.$ImportCtx=function(e){this.type="import",this.parent=e,this.tree=[],e.tree[e.tree.length]=this,this.expect="id"};$ImportCtx.prototype.toString=function(){return"import "+this.tree},$ImportCtx.prototype.transition=function(e,t){var r=this;switch(e){case"id":if("id"==r.expect)return new $ImportedModuleCtx(r,t),r.expect=",",r;if("qual"==r.expect)return r.expect=",",r.tree[r.tree.length-1].name+="."+t,r.tree[r.tree.length-1].alias+="."+t,r;if("alias"==r.expect)return r.expect=",",r.tree[r.tree.length-1].alias=t,r;break;case".":if(","==r.expect)return r.expect="qual",r;break;case",":if(","==r.expect)return r.expect="id",r;break;case"as":if(","==r.expect)return r.expect="alias",r;break;case"eol":if(","==r.expect)return r.bind_names(),$transition(r.parent,e)}$_SyntaxError(r,"token "+e+" after "+r)},$ImportCtx.prototype.bind_names=function(){var e=$get_scope(this);this.tree.forEach((function(t){if(t.name==t.alias){var r=t.name,n=r.split("."),o=r;n.length>1&&(o=n[0])}else o=t.alias;$bind(o,e,this)}),this)},$ImportCtx.prototype.to_js=function(){this.js_processed=!0;var e=$get_scope(this),t=[],r=$get_module(this);return this.tree.forEach((function(n){for(var o=n.name,a=n.name==n.alias?"{}":'{"'+o+'" : "'+n.alias+'"}',s="$locals_"+e.id.replace(/\./g,"_"),i=n.name.split("."),_=0;_0?r.parent.tree[0]:r.parent.parent:r.parent}break;case"dict_or_set_comp":if("}"==e){if(r.expression.yields)for(const e of r.expression.yields){$pos=e[1];var s="set_comp"==r.parent.real?"set":"dict";$_SyntaxError(r,[`'yield' inside ${s}comprehension`])}return r.intervals.push($pos),$transition(r.parent,e)}}switch(e){case",":return"tuple"==r.real&&(r.has_comma=!0),r.expect="id",r;case"for":"list"==r.real?(this.tree.length>1&&$_SyntaxError(r,"unparenthesized expression before 'for'"),r.real="list_comp"):r.real="gen_expr",r.intervals=[r.start+1],r.expression=r.tree,r.yields&&(r.expression.yields=r.yields,delete r.yields),r.tree=[];var i=new $ComprehensionCtx(r);return new $TargetListCtx(new $CompForCtx(i))}return $transition(r.parent,e,t)}if("id"!=r.expect)return $transition(r.parent,e,t);switch(r.real){case"tuple":if(")"==e)return r.close(),r.parent;if("eol"==e&&!0===r.implicit)return r.close(),$transition(r.parent,e);break;case"gen_expr":if(")"==e)return r.close(),$transition(r.parent,e);break;case"list":if("]"==e)return r.close(),r}switch(e){case"=":if("tuple"==r.real&&!0===r.implicit)return r.close(),r.parent.tree.pop(),(_=new $ExprCtx(r.parent,"tuple",!1)).tree=[r],r.parent=_,$transition(r.parent,e);break;case")":break;case"]":if("tuple"==r.real&&!0===r.implicit)return $transition(r.parent,e,t);break;case",":$_SyntaxError(r,"unexpected comma inside list");default:r.expect=",";var _=new $AbstractExprCtx(r,!1);return $transition(_,e,t)}},$ListOrTupleCtx.prototype.close=function(){this.closed=!0;for(var e=0,t=this.tree.length;e-1?"_b_.list.$factory("+this.tree[n].to_js()+")":"["+this.tree[n].to_js()+"]",n>0&&(t=".concat("+t+")"),r+=t;return r},$ListOrTupleCtx.prototype.to_js=function(){this.js_processed=!0;var e=$get_scope(this),t=(e.id.replace(/\//g,"_"),0),r=(m=$get_module(this)).module;switch(this.real){case"list":return(N=this.packed_indices()).length>0?"$B.$list("+this.unpack(N)+")":"$B.$list(["+$to_js(this.tree)+"])";case"list_comp":case"gen_expr":case"dict_or_set_comp":for(var n=this.get_src(),o=[],a=[],s=new RegExp('"',"g"),i=m.comments,_=1;_=0;f--){var p=i[f];if(p[0]>l&&p[0]0?"$B.fast_tuple("+this.unpack(N)+")":1==this.tree.length&&void 0===this.has_comma?this.tree[0].to_js():"$B.fast_tuple(["+$to_js(this.tree)+"])"}};var $NodeCtx=$B.parser.$NodeCtx=function(e){this.node=e,e.C=this,this.tree=[],this.type="node";for(var t=null,r=e;r.parent&&"module"!=r.parent.type;){var n=!1;switch(r.parent.C.tree[0].type){case"def":case"class":case"generator":t=r.parent,n=!0}if(n)break;r=r.parent}null===t&&(t=r.parent||r),this.node.locals=clone(t.binding),this.scope=t};$NodeCtx.prototype.toString=function(){return"node "+this.tree},$NodeCtx.prototype.transition=function(e,t){var r=this;switch(e){case"id":case"imaginary":case"int":case"float":case"str":case"bytes":case"[":case"(":case"{":case"not":case"lambda":case".":var n=new $AbstractExprCtx(r,!0);return $transition(n,e,t);case"op":switch(t){case"*":case"+":case"-":case"~":n=new $AbstractExprCtx(r,!0);return $transition(n,e,t)}break;case"async":return new $AsyncCtx(r);case"await":return new $AbstractExprCtx(new $AwaitCtx(r),!0);case"class":return new $ClassCtx(r);case"continue":return new $ContinueCtx(r);case"__debugger__":return new $DebuggerCtx(r);case"break":return new $BreakCtx(r);case"def":return new $DefCtx(r);case"for":return new $TargetListCtx(new $ForExpr(r));case"if":case"while":return new $AbstractExprCtx(new $ConditionCtx(r,e),!1);case"elif":var o=$previous(r);return-1!=["condition"].indexOf(o.type)&&"while"!=o.token||$_SyntaxError(r,"elif after "+o.type),new $AbstractExprCtx(new $ConditionCtx(r,e),!1);case"else":o=$previous(r);return-1==["condition","except","for"].indexOf(o.type)&&$_SyntaxError(r,"else after "+o.type),new $SingleKwCtx(r,e);case"finally":o=$previous(r);return-1!=["try","except"].indexOf(o.type)||"single_kw"==o.type&&"else"==o.token||$_SyntaxError(r,"finally after "+o.type),new $SingleKwCtx(r,e);case"try":return new $TryCtx(r);case"except":o=$previous(r);return-1==["try","except"].indexOf(o.type)&&$_SyntaxError(r,"except after "+o.type),new $ExceptCtx(r);case"assert":return new $AbstractExprCtx(new $AssertCtx(r),!1,!0);case"from":return new $FromCtx(r);case"import":return new $ImportCtx(r);case"global":return new $GlobalCtx(r);case"nonlocal":return new $NonlocalCtx(r);case"lambda":return new $LambdaCtx(r);case"pass":return new $PassCtx(r);case"raise":return new $AbstractExprCtx(new $RaiseCtx(r),!0);case"return":return new $AbstractExprCtx(new $ReturnCtx(r),!0);case"with":return new $AbstractExprCtx(new $WithCtx(r),!1);case"yield":return new $AbstractExprCtx(new $YieldCtx(r),!0);case"del":return new $AbstractExprCtx(new $DelCtx(r),!0);case"@":return new $DecoratorCtx(r);case",":r.tree&&0==r.tree.length&&$_SyntaxError(r,"token "+e+" after "+r);var a=r.tree[0];r.tree=[];var s=new $ListOrTupleCtx(r);return s.real="tuple",s.implicit=0,s.tree.push(a),a.parent=s,s;case"eol":return 0==r.tree.length?(r.node.parent.children.pop(),r.node.parent.C):r}$_SyntaxError(r,"token "+e+" after "+r)},$NodeCtx.prototype.to_js=function(){if(void 0!==this.js)return this.js;if(this.js_processed=!0,this.tree.length>1){var e=new $Node;new $NodeCtx(e).tree=[this.tree[1]],e.indent=node.indent+4,this.tree.pop(),node.add(e)}if(this.js="",this.tree[0]){var t=-1==["def","generator"].indexOf(this.scope.ntype);if(this.tree[0].annotation)if(t){if("expr"==this.tree[0].type&&!this.tree[0].$in_parens&&"id"==this.tree[0].tree[0].type){var r="";return this.create_annotations&&(r+="$locals.__annotations__ = $B.empty_dict();"),r+"_b_.dict.$setitem($locals.__annotations__, '"+this.tree[0].tree[0].value+"', "+this.tree[0].annotation.to_js()+");"}"def"==this.tree[0].type||"generator"==this.tree[0].type?this.js=this.tree[0].annotation.to_js()+";":(this.js="",this.tree=[])}else-1==["def","generator"].indexOf(this.tree[0].type)&&(this.tree=[]);else if("assign"==this.tree[0].type&&!this.tree[0].tree[0].$in_parens&&this.tree[0].tree[0].annotation){var n=this.tree[0].tree[0],o=this.tree[0].tree[1];if(this.create_annotations&&(this.js+="$locals.__annotations__ = $B.empty_dict();"),this.js+="var $value = "+o.to_js()+";",this.tree[0].tree.splice(1,1),new $RawJSCtx(this.tree[0],"$value"),!n.tree[0]||"id"!=n.tree[0].type||!t)return this.js+=$to_js(this.tree)+";",t&&(this.js+=n.annotation.to_js()),this.js;this.js+="_b_.dict.$setitem($locals.__annotations__, '"+n.tree[0].value+"', "+n.annotation.to_js()+");"}}return 0==this.node.children.length?this.js+=$to_js(this.tree)+";":this.js+=$to_js(this.tree),this.js};var $NodeJS=$B.parser.$NodeJS=function(e){var t=new $Node;return new $NodeJSCtx(t,e),t},$NodeJSCtx=$B.parser.$NodeJSCtx=function(e,t){this.node=e,e.C=this,this.type="node_js",this.tree=[t]};$NodeJSCtx.prototype.toString=function(){return"js "+js},$NodeJSCtx.prototype.to_js=function(){return this.js_processed=!0,this.tree[0]};var $NonlocalCtx=$B.parser.$NonlocalCtx=function(e){this.type="nonlocal",this.parent=e,this.tree=[],this.names={},e.tree[e.tree.length]=this,this.expect="id",this.scope=$get_scope(this),this.scope.nonlocals=this.scope.nonlocals||{},void 0===this.scope.C&&$_SyntaxError(e,["nonlocal declaration not allowed at module level"])};$NonlocalCtx.prototype.toString=function(){return"nonlocal "+this.tree},$NonlocalCtx.prototype.add=function(e){"arg"==this.scope.binding[e]&&$_SyntaxError(C,["name '"+e+"' is parameter and nonlocal"]),this.names[e]=[!1,$pos],this.scope.nonlocals[e]=!0},$NonlocalCtx.prototype.transition=function(e,t){var r=this;switch(e){case"id":if("id"==r.expect)return new $IdCtx(r,t),r.add(t),r.expect=",",r;break;case",":if(","==r.expect)return r.expect="id",r;break;case"eol":if(","==r.expect)return $transition(r.parent,e)}$_SyntaxError(r,"token "+e+" after "+r)},$NonlocalCtx.prototype.transform=function(e,t){var r=this.parent,n=this.scope.parent_block;if(void 0===n.C)$_SyntaxError(r,["no binding for nonlocal '"+$B.last(Object.keys(this.names))+"' found"]);else{for(;void 0!==n&&void 0!==n.C;){for(var o in this.names)void 0!==n.binding[o]&&(this.names[o]=[!0]);n=n.parent_block}for(var o in this.names)this.names[o][0]||(console.log("nonlocal error, C "+r),$pos=this.names[o][1],$_SyntaxError(r,["no binding for nonlocal '"+o+"' found"]))}},$NonlocalCtx.prototype.to_js=function(){return this.js_processed=!0,""};var $NotCtx=$B.parser.$NotCtx=function(e){this.type="not",this.parent=e,this.tree=[],e.tree[e.tree.length]=this};$NotCtx.prototype.toString=function(){return"not ("+this.tree+")"},$NotCtx.prototype.transition=function(e,t){var r=this;switch(e){case"in":return r.parent.parent.tree.pop(),new $ExprCtx(new $OpCtx(r.parent,"not_in"),"op",!1);case"id":case"imaginary":case"int":case"float":case"str":case"bytes":case"[":case"(":case"{":case".":case"not":case"lambda":var n=new $AbstractExprCtx(r,!1);return $transition(n,e,t);case"op":if("+"==t||"-"==t||"~"==t){n=new $AbstractExprCtx(r,!1);return $transition(n,e,t)}}return $transition(r.parent,e)},$NotCtx.prototype.to_js=function(){return this.js_processed=!0,"!$B.$bool("+$to_js(this.tree)+")"};var $NumberCtx=$B.parser.$NumberCtx=function(e,t,r){this.type=e,this.value=r,this.parent=t,this.tree=[],t.tree[t.tree.length]=this};$NumberCtx.prototype.toString=function(){return this.type+" "+this.value},$NumberCtx.prototype.transition=function(e,t){var r=this;switch(e){case"id":case"imaginary":case"int":case"float":case"str":case"bytes":case"[":case"(":case"{":case"not":case"lambda":$_SyntaxError(r,"token "+e+" after "+r)}return $transition(r.parent,e,t)},$NumberCtx.prototype.to_js=function(){this.js_processed=!0;var type=this.type,value=this.value;if("int"==type){var v=parseInt(value[1],value[0]);if(v>$B.min_int&&v<$B.max_int)return this.unary_op&&(v=eval(this.unary_op+v)),v;var v=$B.long_int.$factory(value[1],value[0]);switch(this.unary_op){case"-":v=$B.long_int.__neg__(v);break;case"~":v=$B.long_int.__invert__(v)}return'$B.fast_long_int("'+v.value+'", '+v.pos+")"}return"float"==type?/^\d+$/.exec(value)||/^\d+\.\d*$/.exec(value)?"(new Number("+this.value+"))":"_b_.float.$factory("+value+")":"imaginary"==type?"$B.make_complex(0,"+value+")":void 0};var $OpCtx=$B.parser.$OpCtx=function(e,t){if(this.type="op",this.op=t,this.parent=e.parent,this.tree=[e],this.scope=$get_scope(this),"expr"==e.type)if(["int","float","str"].indexOf(e.tree[0].type)>-1)this.left_type=e.tree[0].type;else if("id"==e.tree[0].type){var r=this.scope.binding[e.tree[0].value];r&&(this.left_type=r.type)}e.parent.tree.pop(),e.parent.tree.push(this)};$OpCtx.prototype.toString=function(){return"(op "+this.op+") ["+this.tree+"]"},$OpCtx.prototype.transition=function(e,t){var r=this;if(void 0===r.op&&$_SyntaxError(r,["C op undefined "+r]),"unary"==r.op.substr(0,5)){if("eol"!=e&&("assign"==r.parent.type||"return"==r.parent.type)){r.parent.tree.pop();var n=new $ListOrTupleCtx(r.parent,"tuple");return n.tree.push(r),r.parent=n,n}2==r.tree.length&&"expr"==r.tree[1].type&&"int"==r.tree[1].tree[0].type&&(r.parent.tree.pop(),r.parent.tree.push(r.tree[1]),r.tree[1].parent=r.parent,r.tree[1].tree[0].unary_op=r.tree[0].op)}switch(e){case"id":case"imaginary":case"int":case"float":case"str":case"bytes":case"[":case"(":case"{":case".":case"not":case"lambda":return $transition(new $AbstractExprCtx(r,!1),e,t);case"op":switch(t){case"+":case"-":case"~":return new $UnaryCtx(r,t)}default:"abstract_expr"==r.tree[r.tree.length-1].type&&$_SyntaxError(r,"token "+e+" after "+r)}return $transition(r.parent,e)},$OpCtx.prototype.to_js=function(){this.js_processed=!0;var e={"==":"eq","!=":"ne",">=":"ge","<=":"le","<":"lt",">":"gt"};if(void 0!==e[this.op]){var t=e[this.op];if("expr"==this.tree[0].type&&"expr"==this.tree[1].type){var r=this.tree[0].tree[0],n=this.tree[1].tree[0],o=r.to_js(),a=n.to_js();switch(n.type){case"int":switch(r.type){case"int":return Number.isSafeInteger(r.value)&&Number.isSafeInteger(n.value)?o+this.op+a:"$B.$getattr("+this.tree[0].to_js()+',"__'+t+'__")('+this.tree[1].to_js()+")";case"str":switch(this.op){case"==":return"false";case"!=":return"true";default:return'$B.$TypeError("unorderable types: int() '+this.op+' str()")'}case"id":return"(typeof "+o+' == "number" ? '+o+this.op+a+' : $B.rich_comp("__'+t+'__",'+this.tree[0].to_js()+","+this.tree[1].to_js()+"))"}break;case"str":switch(r.type){case"str":return o+this.op+a;case"int":switch(this.op){case"==":return"false";case"!=":return"true";default:return'$B.$TypeError("unorderable types: str() '+this.op+' int()")'}case"id":return"(typeof "+o+' == "string" ? '+o+this.op+a+' : $B.rich_comp("__'+t+'__",'+this.tree[0].to_js()+","+this.tree[1].to_js()+"))"}break;case"id":if("id"==r.type)return"typeof "+o+'!="object" && typeof '+o+'!="function" && typeof '+o+" == typeof "+a+" ? "+o+this.op+a+' : $B.rich_comp("__'+t+'__",'+this.tree[0].to_js()+","+this.tree[1].to_js()+")"}}}switch(this.op){case"and":var s=this.tree[0].to_js(),i=this.tree[1].to_js();return void 0!==this.wrap?"(function(){var "+this.wrap.name+" = "+this.wrap.js+";return $B.$test_expr($B.$test_item("+s+") && $B.$test_item("+i+"))})()":"$B.$test_expr($B.$test_item("+s+")&&$B.$test_item("+i+"))";case"or":return(y="$B.$test_expr($B.$test_item("+this.tree[0].to_js()+")||")+"$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":if("unary_neg"==this.op?(c="-",t="__neg__"):"unary_pos"==this.op?(c="+",t="__pos__"):(c="~",t="__invert__"),"expr"==this.tree[1].type){var _=this.tree[1].tree[0];switch(_.type){case"int":var l=parseInt(_.value[1],_.value[0]);return Number.isSafeInteger(l)?c+l:"$B.$getattr("+_.to_js()+', "'+t+'")()';case"float":return"_b_.float.$factory("+c+_.value+")";case"imaginary":return"$B.make_complex(0,"+c+_.value+")"}}return"$B.$getattr("+this.tree[1].to_js()+',"'+t+'")()';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"+":return"$B.add("+this.tree[0].to_js()+", "+this.tree[1].to_js()+")";case"*":case"-":var c=this.op,u=[],f=!1,p=$get_scope(this);function $(e,t){var r;return["int","float","str"].indexOf(t.type)>-1?r=t.type:"id"==t.type&&e[t.value]&&(r=e[t.value].type),r}var d=this.tree[0],h=this.tree[1];if(function e(t){if("expr"==t.type&&"int"==t.tree[0].type)return!0;if("expr"==t.type&&"float"==t.tree[0].type)return f=!0,!0;if("expr"==t.type&&"list_or_tuple"==t.tree[0].type&&"tuple"==t.tree[0].real&&1==t.tree[0].tree.length&&"expr"==t.tree[0].tree[0].type)return e(t.tree[0].tree[0].tree[0]);if("expr"==t.type&&"id"==t.tree[0].type){var r=t.tree[0].to_js();return-1==u.indexOf(r)&&u.push(r),!0}if("op"==t.type&&["*","+","-"].indexOf(t.op)>-1){for(var n=0;n-1&&["int","float"].indexOf(n)>-1)switch(this.result_type="int"==r&&"int"==n?"int":"float",this.op){case"-":return"$B.sub("+m.to_js()+","+g.to_js()+")";case"*":return"$B.mul("+m.to_js()+","+g.to_js()+")"}var y,v=[],x=[];u.forEach((function(e){v.push("typeof "+e+'.valueOf() == "number"'),x.push("typeof "+e+' == "number"')})),(y=[v.join(" && ")+" ? "]).push("("+x.join(" && ")+" ? "),y.push(this.simple_js()),y.push(" : new Number("+this.simple_js()+")"),y.push(")");r=this.tree[0].to_js(),n=this.tree[1].to_js();return"+"==this.op&&y.push(" : (typeof "+r+' == "string" && typeof '+n+' == "string") ? '+r+"+"+n),y.push(': $B.rich_op("'+$operators[this.op]+'",'+r+","+n+")"),"("+y.join("")+")"}return this.simple_js()}return void 0!==e[this.op]?'$B.rich_comp("__'+$operators[this.op]+'__",'+d.to_js()+","+h.to_js()+")":'$B.rich_op("'+$operators[this.op]+'", '+d.to_js()+", "+h.to_js()+")";default:return void 0!==e[this.op]?'$B.rich_comp("__'+$operators[this.op]+'__",'+this.tree[0].to_js()+","+this.tree[1].to_js()+")":'$B.rich_op("'+$operators[this.op]+'", '+this.tree[0].to_js()+", "+this.tree[1].to_js()+")"}},$OpCtx.prototype.simple_js=function(){var e=this.op;function t(e){return"op"==e.type?e.simple_js():"expr"==e.type&&"list_or_tuple"==e.tree[0].type&&"tuple"==e.tree[0].real&&1==e.tree[0].tree.length&&"expr"==e.tree[0].tree[0].type?"("+e.tree[0].tree[0].tree[0].simple_js()+")":e.tree[0].to_js()}return"+"==e?"$B.add("+t(this.tree[0])+","+t(this.tree[1])+")":"-"==e?"$B.sub("+t(this.tree[0])+","+t(this.tree[1])+")":"*"==e?"$B.mul("+t(this.tree[0])+","+t(this.tree[1])+")":"/"==e?"$B.div("+t(this.tree[0])+","+t(this.tree[1])+")":t(this.tree[0])+e+t(this.tree[1])};var $PackedCtx=$B.parser.$PackedCtx=function(e){if(this.type="packed","list_or_tuple"==e.parent.type&&"node"==e.parent.parent.type)for(var t=0;t0&&"packed"==r.tree[0].type&&$_SyntaxError(e,["two starred expressions in assignment"])}this.parent=e,this.tree=[],this.pos=$pos-1,e.tree[e.tree.length]=this};$PackedCtx.prototype.toString=function(){return"(packed) "+this.tree},$PackedCtx.prototype.transition=function(e,t){var r=this;if(r.tree.length>0&&"["==e)return $transition(r.tree[0],e,t);switch(e){case"id":var n=new $AbstractExprCtx(r,!1);return n.packed=!0,r.parent.expect=",",$transition(n,e,t);case"[":return r.parent.expect=",",new $ListOrTupleCtx(r,"list");case"(":return r.parent.expect=",",new $ListOrTupleCtx(r,"tuple");case"str":return r.parent.expect=",",new $StringCtx(r,t);case"]":return $transition(r.parent,e,t);case"{":return r.parent.expect=",",new $DictOrSetCtx(r);case"op":switch(t){case"+":case"-":case"~":return r.parent.expect=",",new $UnaryCtx(r,t);default:$_SyntaxError(r,["can't use starred expression here"])}}return r.parent.transition(e,r)},$PackedCtx.prototype.to_js=function(){return this.js_processed=!0,$to_js(this.tree)};var $PassCtx=$B.parser.$PassCtx=function(e){this.type="pass",this.parent=e,this.tree=[],e.tree[e.tree.length]=this};$PassCtx.prototype.toString=function(){return"(pass)"},$PassCtx.prototype.transition=function(e,t){var r=this;if("eol"==e)return r.parent;$_SyntaxError(r,"token "+e+" after "+r)},$PassCtx.prototype.to_js=function(){return this.js_processed=!0,"void(0)"};var $RaiseCtx=$B.parser.$RaiseCtx=function(e){this.type="raise",this.parent=e,this.tree=[],e.tree[e.tree.length]=this,this.scope_type=$get_scope(this).ntype};$RaiseCtx.prototype.toString=function(){return" (raise) "+this.tree},$RaiseCtx.prototype.transition=function(e,t){var r=this;switch(e){case"id":if(0==r.tree.length)return new $IdCtx(new $ExprCtx(r,"exc",!1),t);break;case"from":if(r.tree.length>0)return new $AbstractExprCtx(r,!1);break;case"eol":return $transition(r.parent,e)}$_SyntaxError(r,"token "+e+" after "+r)},$RaiseCtx.prototype.to_js=function(){return this.js_processed=!0,"$B.$raise("+(0==this.tree.length?"":this.tree[0].to_js())+")"};var $RawJSCtx=$B.parser.$RawJSCtx=function(e,t){this.type="raw_js",e.tree[e.tree.length]=this,this.parent=e,this.js=t};$RawJSCtx.prototype.toString=function(){return"(js) "+this.js},$RawJSCtx.prototype.transition=function(e,t){},$RawJSCtx.prototype.to_js=function(){return this.js_processed=!0,this.js};var $ReturnCtx=$B.parser.$ReturnCtx=function(e){this.type="return",this.parent=e,this.tree=[],e.tree[e.tree.length]=this,this.scope=$get_scope(this),-1==["def","generator"].indexOf(this.scope.ntype)&&$_SyntaxError(e,["'return' outside function"]);for(var t=this.node=$get_node(this);t.parent;){if(t.parent.C){var r=t.parent.C.tree[0];if("for"==r.type){r.has_return=!0;break}("try"==r.type||"single_kw"==r.type&&"finally"==r.token)&&(r.has_return=!0)}t=t.parent}};$ReturnCtx.prototype.toString=function(){return"return "+this.tree},$ReturnCtx.prototype.transition=function(e,t){return $transition(this.parent,e)},$ReturnCtx.prototype.to_js=function(){this.js_processed=!0,1==this.tree.length&&"abstract_expr"==this.tree[0].type&&(this.tree.pop(),new $IdCtx(new $ExprCtx(this,"rvalue",!1),"None"));var e=this.scope;if("generator"==e.ntype)return"var $res = "+$to_js(this.tree)+"; $B.leave_frame({$locals});return $B.generator_return($res)";var t=" ".repeat(this.node.indent-1),r="var $res = "+$to_js(this.tree)+";\n"+t+"if($locals.$f_trace !== _b_.None){$B.trace_return($res)}\n"+t+"$B.leave_frame";return"$exec_"==e.id.substr(0,6)&&(r+="_exec"),r+="({$locals});\n"+t+"return $res"};var $SingleKwCtx=$B.parser.$SingleKwCtx=function(e,t){if(this.type="single_kw",this.token=t,this.parent=e,this.tree=[],e.tree[e.tree.length]=this,"else"==t){for(var r=e.node,n=r.parent,o=0;o0){var s=a.tree[0];("for"==s.type||"asyncfor"==s.type||"condition"==s.type&&"while"==s.token)&&(s.has_break=!0,s.else_node=$get_node(this),this.loop_num=s.loop_num)}}};$SingleKwCtx.prototype.toString=function(){return this.token},$SingleKwCtx.prototype.transition=function(e,t){var r=this;if(":"==e)return $BodyCtx(r);$_SyntaxError(r,"token "+e+" after "+r)},$SingleKwCtx.prototype.transform=function(e,t){if("finally"==this.token){var r=$get_scope(this);e.insert(0,$NodeJS("var $exit;if($B.frames_stack.length < $stack_length){$exit = true;$B.frames_stack.push($top_frame)}"));r.id.replace(/\./g,"_");"return"!=e.children[e.children.length-1].C.tree[0].type&&e.add($NodeJS("if($exit){$B.leave_frame({$locals})}"))}},$SingleKwCtx.prototype.to_js=function(){return this.js_processed=!0,"finally"==this.token?this.token:void 0!==this.loop_num?"if($locals_"+$get_scope(this).id.replace(/\./g,"_")+'["$no_break'+this.loop_num+'"])':this.token};var $SliceCtx=$B.parser.$SliceCtx=function(e){this.type="slice",this.parent=e,this.tree=e.tree.length>0?[e.tree.pop()]:[],e.tree.push(this)};$SliceCtx.prototype.transition=function(e,t){return":"==e?new $AbstractExprCtx(this,!1):$transition(this.parent,e,t)},$SliceCtx.prototype.to_js=function(){for(var e=0;e=55296&&code<=56319)return!0}return!1},$StringCtx.prototype.to_js=function(){this.js_processed=!0;var e="",t=null,r=$get_scope(this),n=!1;function o(e){for(var t=[],a=0;a-1?_.push(c):")]}".indexOf(c)>-1&&_.pop(),i++}s=l[0];var u=$pos,f=$B.py2js(s,r.module,r.id,r);f.to_js(),$pos=u;for(var p=0;p0)for(;"\n;".indexOf(h.charAt(h.length-1))>-1;)h=h.substr(0,h.length-1);else console.log("f-string: empty expression not allowed");break}break}}switch(e[a].conversion){case"a":h="_b_.ascii("+h+")";break;case"r":h="_b_.repr("+h+")";break;case"s":h="_b_.str.$factory("+h+")"}var m=l[1];if(void 0!==m){var g=$B.parse_fstring(m),b="_b_.str.format('{0:' + "+(m=g.length>1?o(g):"'"+m+"'")+" + '}', "+h+")";t.push(b)}else null===e[a].conversion&&(h="_b_.str.$factory("+h+")"),t.push(h)}else{var y=new RegExp("'","g"),v=e[a].replace(y,"\\'").replace(/\n/g,"\\n");n=n||$B.has_surrogate(v),t.push("'"+v+"'")}return t.join(" + ")}function a(e){return e=(e=e.replace(/\n/g,"\\n\\\n")).replace(/\r/g,"\\r\\\r")}for(var s=0;s0)return r.parent;break;case":":return new $AbstractExprCtx(new $SliceCtx(r),!1);case",":return new $AbstractExprCtx(r,!1)}$_SyntaxError(r,"token "+e+" after "+r)},$SubCtx.prototype.to_js=function(){if(this.js_processed=!0,"getitem"==this.func&&"id"==this.value.type){var e=$get_node(this).locals[this.value.value],t=this.value.to_js();if("list"==e||"tuple"==e){if(1==this.tree.length)return"$B.list_key("+t+", "+this.tree[0].to_js()+")";if(2==this.tree.length)return"$B.list_slice("+t+", "+(this.tree[0].to_js()||"null")+","+(this.tree[1].to_js()||"null")+")";if(3==this.tree.length)return"$B.list_slice_step("+t+", "+(this.tree[0].to_js()||"null")+","+(this.tree[1].to_js()||"null")+","+(this.tree[2].to_js()||"null")+")"}}if("getitem"==this.func&&1==this.tree.length)return"slice"==this.tree[0].type?`$B.getitem_slice(${this.value.to_js()},`+this.tree[0].to_js()+")":"$B.$getitem("+this.value.to_js()+","+this.tree[0].to_js()+")";var r="",n=!1;if("delitem"!==this.func&&1==this.tree.length&&!this.in_sub){var o="",a=this;for(n=!0;"sub"==a.value.type;)o+="["+a.tree[0].to_js()+"]",a.value.in_sub=!0,a=a.value;var s=a.value.to_js()+"["+a.tree[0].to_js()+"]((Array.isArray("+a.value.to_js()+") || typeof "+a.value.to_js()+' == "string") && '+s+" !== undefined ?"+s+o+" : "}if(r+="$B.$getattr("+(t=this.value.to_js())+',"__'+this.func+'__")(',1==this.tree.length)r+=this.tree[0].to_js()+")";else{var i=[];this.tree.forEach((function(e){"abstract_expr"==e.type?i.push("_b_.None"):i.push(e.to_js())})),r+="_b_.tuple.$factory(["+i.join(",")+"]))"}return n?r+")":r};var $TargetListCtx=$B.parser.$TargetListCtx=function(e){this.type="target_list",this.parent=e,this.tree=[],this.expect="id",e.tree[e.tree.length]=this};$TargetListCtx.prototype.toString=function(){return"(target list) "+this.tree},$TargetListCtx.prototype.transition=function(e,t){var r=this;switch(e){case"id":if("id"==r.expect)return r.expect=",",new $IdCtx(new $ExprCtx(r,"target",!1),t);case"op":if("id"==r.expect&&"*"==t)return new $PackedCtx(r);case"(":case"[":if("id"==r.expect)return r.expect=",",new $ListOrTupleCtx(r,"("==e?"tuple":"list");case")":case"]":if(","==r.expect)return r.parent;case",":if(","==r.expect)return r.expect="id",r}return","==r.expect||"in"==e?$transition(r.parent,e,t):void $_SyntaxError(r,"token "+e+" after "+r)},$TargetListCtx.prototype.to_js=function(){return this.js_processed=!0,$to_js(this.tree)};var ternaries=[],$TernaryCtx=$B.parser.$TernaryCtx=function(e){this.type="ternary",this.parent=e.parent,e.parent.tree.pop(),e.parent.tree.push(this),e.parent=this,this.tree=[e],ternaries.push(this)};$TernaryCtx.prototype.toString=function(){return"(ternary) "+this.tree},$TernaryCtx.prototype.transition=function(e,t){var r=this;if("else"==e)return r.in_else=!0,new $AbstractExprCtx(r,!1);if(r.in_else){if(","==e&&["assign","augm_assign","node","return"].indexOf(r.parent.type)>-1){r.parent.tree.pop();var n=new $ListOrTupleCtx(r.parent,"tuple");return n.implicit=!0,n.tree[0]=r,r.parent=n,n.expect="id",n}}else $_SyntaxError(r,"token "+e+" after "+r);return $transition(r.parent,e,t)},$TernaryCtx.prototype.to_js=function(){this.js_processed=!0;var e="$B.$bool("+this.tree[1].to_js()+") ? ";return(e+=this.tree[0].to_js()+" : ")+this.tree[2].to_js()};var $TryCtx=$B.parser.$TryCtx=function(e){this.type="try",this.parent=e,e.tree[e.tree.length]=this};$TryCtx.prototype.toString=function(){return"(try) "},$TryCtx.prototype.transition=function(e,t){var r=this;if(":"==e)return $BodyCtx(r);$_SyntaxError(r,"token "+e+" after "+r)},$TryCtx.prototype.transform=function(e,t){if(e.parent.children.length==t+1)$_SyntaxError(C,["unexpected EOF while parsing"]);else switch(e.parent.children[t+1].C.tree[0].type){case"except":case"finally":case"single_kw":break;default:$pos=e.parent.children[t+1].pos,$_SyntaxError(e.parent.children[t+1].C.tree[0],"no clause after try")}var r=$get_scope(this),n=create_temp_name("$err"),o="$locals."+create_temp_name("$failed"),a=o+" = false;\n"+" ".repeat(e.indent+4)+"try";new $NodeJSCtx(e,a),e.has_return=this.has_return;var s=$NodeJS("catch("+n+")");e.parent.insert(t+1,s),s.add($NodeJS("$B.set_exc("+n+")")),s.add($NodeJS("if($locals.$f_trace !== _b_.None){$locals.$f_trace = $B.trace_exception()}")),s.add($NodeJS(o+" = true;$B.pmframe = $B.last($B.frames_stack);if(false){}"));for(var i=t+2,_=!1,l=!1,c=!1;i!=e.parent.children.length;){if(void 0===(d=e.parent.children[i].C.tree[0]))break;if("except"==d.type){if(l&&$_SyntaxError(C,"'except' or 'finally' after 'else'"),c&&$_SyntaxError(C,"'except' after 'finally'"),d.error_name=n,d.tree.length>0&&null!==d.tree[0].alias&&void 0!==d.tree[0].alias){var u=d.tree[0].alias;e.parent.children[i].insert(0,$NodeJS('$locals["'+u+'"] = $B.exception('+n+")"))}s.insert(s.children.length,e.parent.children[i]),0==d.tree.length&&(_&&$_SyntaxError(C,"more than one except: line"),_=!0),e.parent.children.splice(i,1)}else if("single_kw"==d.type&&"finally"==d.token){c=!0;var f=e.parent.children[i];i++}else{if("single_kw"!=d.type||"else"!=d.token)break;l&&$_SyntaxError(C,"more than one 'else'"),c&&$_SyntaxError(C,"'else' after 'finally'"),l=!0;var p=e.parent.children[i];e.parent.children.splice(i,1)}}if(!_){var $=new $Node,d=new $NodeCtx($);s.insert(s.children.length,$),new $SingleKwCtx(d,"else"),$.add($NodeJS("throw "+n))}if(l){var h=new $Node;h.module=r.module,new $NodeJSCtx(h,"if(!"+o+")"),p.children.forEach((function(e){h.add(e)})),c?f.insert(0,h):e.parent.insert(i,h),i++}$loop_num++},$TryCtx.prototype.to_js=function(){return this.js_processed=!0,"try"};var $UnaryCtx=$B.parser.$UnaryCtx=function(e,t){this.type="unary",this.op=t,this.parent=e,e.tree[e.tree.length]=this};$UnaryCtx.prototype.toString=function(){return"(unary) "+this.op},$UnaryCtx.prototype.transition=function(e,t){var r=this;switch(e){case"int":case"float":case"imaginary":"packed"==r.parent.type&&$_SyntaxError(r,["can't use starred expression here"]);var n=r.parent;return r.parent.parent.tree.pop(),"-"==r.op?t="-"+t:"~"==r.op&&(t=~t),$transition(r.parent.parent,e,t);case"id":var o=r.parent.parent.tree.pop();if("packed"==o.type){r.parent.parent.tree.push(o),o.tree.pop();n=new $ExprCtx(o,"call",!1)}else n=new $ExprCtx(r.parent.parent,"call",!1);var a=new $ExprCtx(n,"id",!1);new $IdCtx(a,t);var s=new $AttrCtx(n);return"+"==r.op?s.name="__pos__":"-"==r.op?s.name="__neg__":s.name="__invert__",a;case"op":if("+"==t||"-"==t)return r.op===t?r.op="+":r.op="-",r}return $transition(r.parent,e,t)},$UnaryCtx.prototype.to_js=function(){return this.js_processed=!0,this.op};var $WithCtx=$B.parser.$WithCtx=function(e){this.type="with",this.parent=e,e.tree[e.tree.length]=this,this.tree=[],this.expect="as",this.scope=$get_scope(this)};$WithCtx.prototype.toString=function(){return"(with) "+this.tree},$WithCtx.prototype.transition=function(e,t){var r=this;switch(e){case"id":if("id"==r.expect)return r.expect="as",$transition(new $AbstractExprCtx(r,!1),e,t);$_SyntaxError(r,"token "+e+" after "+r);case"as":return new $AbstractExprCtx(new $AliasCtx(r));case":":switch(r.expect){case"id":case"as":case":":return $BodyCtx(r)}break;case"(":if("id"==r.expect&&0==r.tree.length)return r.parenth=!0,r;if("alias"==r.expect)return r.expect=":",new $TargetListCtx(r,!1);break;case")":if(","==r.expect||"as"==r.expect)return r.expect=":",r;break;case",":if(void 0!==r.parenth&&void 0===r.has_alias&&(","==r.expect||"as"==r.expect))return r.expect="id",r;if("as"==r.expect)return r.expect="id",r;if(":"==r.expect)return r.expect="id",r}$_SyntaxError(r,"token "+e+" after "+r.expect)},$WithCtx.prototype.set_alias=function(e){var t=[];"id"==e.type?t=[e]:"list_or_tuple"==e.type&&e.tree.forEach((function(e){"expr"==e.type&&"id"==e.tree[0].type&&t.push(e.tree[0])}));for(var r=0,n=t.length;r1;){var r=e.children,n=this.tree.pop(),o=new $Node,a=new $NodeCtx(o),s=new $WithCtx(a);n.parent=s,s.tree=[n],s.async=this.async,r.forEach((function(e){o.add(e)})),e.children=[o]}if(!this.transformed){if(this.prefix="",this.tree.length>1){var i=new $Node;a=new $NodeCtx(i);i.parent=e,i.module=e.module,i.indent=e.indent+4;var _=new $WithCtx(a);return _.async=this.async,_.tree=this.tree.slice(1),e.children.forEach((function(e){i.add(e)})),e.children=[i],void(this.transformed=!0)}if(this.async)return this.transform_async(e,t);var l=$NodeJS("try");e.parent.insert(t+1,l);var c=this.num=$loop_num++;if(l.ctx_manager_num=c,this.cm_name=this.prefix+"$ctx_manager"+c,this.cmexit_name=this.prefix+"$ctx_manager_exit"+c,this.exc_name=this.prefix+"$exc"+c,this.err_name="$err"+c,this.val_name="$value"+c,this.yield_name=this.prefix+"$yield"+c,null===this.tree[0].alias&&(this.tree[0].alias="$temp"),"expr"==this.tree[0].type&&"list_or_tuple"==this.tree[0].tree[0].type){"expr"==this.tree[1].type&&"list_or_tuple"==this.tree[1].tree[0].type||$_SyntaxError(C),this.tree[0].tree[0].tree.length!=this.tree[1].tree[0].tree.length&&$_SyntaxError(C,["wrong number of alias"]);var u=this.tree[0].tree[0].tree,f=this.tree[1].tree[0].tree;this.tree.shift(),this.tree.shift();for(var p=u.length-1;p>=0;p--)u[p].alias=f[p].value,this.tree.splice(0,0,u[p])}var $=e.children;e.children=[];var d=new $Node;if(new $NodeJSCtx(d,"try"),l.add(d),this.tree[0].alias){f=this.tree[0].alias.tree[0].tree[0].value;d.add($NodeJS('$locals["'+f+'"] = '+this.val_name))}$.forEach((function(e){d.add(e)}));var h=new $Node;new $NodeJSCtx(h,"catch("+this.err_name+")");var m=this.exc_name+" = false;"+this.err_name+" = $B.exception("+this.err_name+", true)\n"+" ".repeat(e.indent+4)+"var $b = "+this.cmexit_name+"("+this.err_name+".__class__,"+this.err_name+",$B.$getattr("+this.err_name+', "__traceback__"));';"generator"==this.scope.ntype&&(m+="$B.set_cm_in_generator("+this.cmexit_name+");"),m+="if(!$B.$bool($b)){throw "+this.err_name+"}",h.add($NodeJS(m)),l.add(h);var g=new $Node;new $NodeJSCtx(g,"finally"),g.C.type="single_kw",g.C.token="finally",g.C.in_ctx_manager=!0,g.is_except=!0,g.in_ctx_manager=!0;m="if("+this.exc_name;m+="){"+this.cmexit_name+"(_b_.None, _b_.None, _b_.None);","generator"==this.scope.ntype&&(m+="delete "+this.cmexit_name),m+="};",g.add($NodeJS(m)),e.parent.insert(t+2,g),this.transformed=!0}},$WithCtx.prototype.transform_async=function(e,t){$get_scope(this);var r=this.tree[0],n=this.tree[0].alias,o=[],a=this.num=$loop_num++;this.cm_name="$ctx_manager"+a,this.cmexit_name="$ctx_manager_exit"+a,this.exc_name="$exc"+a;var s="$ctx_mgr_type"+a,i="$ctx_manager_enter"+a,_="$err"+a,l="var "+this.cm_name+" = "+r.to_js()+",";if(o.push($NodeJS(l)),o.push($NodeJS(" "+s+" = _b_.type.$factory("+this.cm_name+"),")),o.push($NodeJS(" "+this.cmexit_name+" = $B.$call($B.$getattr("+s+', "__aexit__")),')),o.push($NodeJS(" "+i+" = $B.$call($B.$getattr("+s+', "__aenter__"))('+this.cm_name+"),")),o.push($NodeJS(" "+this.exc_name+" = false")),l="",n)if("list_or_tuple"!=n.tree[0].tree[0].type){l=n.tree[0].to_js()+" = await ($B.promise("+i+"))";o.push($NodeJS(l))}else{var c=new $Node,u=new $NodeCtx(c);(r=new $ExprCtx(u,"left",!1)).tree.push(n.tree[0].tree[0]),n.tree[0].tree[0].parent=r;var f=new $AssignCtx(r);new $RawJSCtx(f,"await ($B.promise("+i+"))"),o.push(c)}else o.push($NodeJS("await ($B.promise("+i+"))"));var p=new $NodeJS("try");e.children.forEach((function(e){p.add(e)})),o.push(p);var $=new $NodeJS("catch(err)");o.push($),$.add($NodeJS(this.exc_name+" = true")),$.add($NodeJS("var "+_+' = $B.imported["_sys"].exc_info()'));var d=$NodeJS("if(! await ($B.promise("+this.cmexit_name+"("+this.cm_name+", "+_+"[0], "+_+"[1], "+_+"[2]))))");$.add(d),d.add($NodeJS("$B.$raise()"));var h=$NodeJS("if(! "+this.exc_name+")");o.push(h),h.add($NodeJS("await ($B.promise("+this.cmexit_name+"("+this.cm_name+", _b_.None, _b_.None, _b_.None)))")),e.parent.children.splice(t,1);for(var m=o.length-1;m>=0;m--)e.parent.insert(t,o[m]);return e.children=[],0},$WithCtx.prototype.to_js=function(){this.js_processed=!0;var e=$get_node(this).indent,t=" ".repeat(e),r=this.num,n=""==this.prefix?"var ":this.prefix,o="$ctx_manager"+r,a=n+"$ctx_manager_exit"+r,s=n+"$exc"+r,i="$value"+r;return"var "+o+" = "+this.tree[0].to_js()+"\n"+t+a+" = $B.$getattr("+o+',"__exit__")\n'+t+"var "+i+" = $B.$getattr("+o+',"__enter__")()\n'+t+s+" = true\n"};var $YieldCtx=$B.parser.$YieldCtx=function(e,t){this.type="yield",this.parent=e,this.tree=[],this.is_await=t,e.tree[e.tree.length]=this,"list_or_tuple"==e.type&&e.tree.length>1&&$_SyntaxError(e,"non-parenthesized yield"),$parent_match(e,{type:"annotation"})&&$_SyntaxError(e,["'yield' outside function"]);for(var r=this;;){var n=$parent_match(r,{type:"list_or_tuple"});if(!n)break;n.yields=n.yields||[],n.yields.push([this,$pos]),r=n}for(r=this;;){var o=$parent_match(r,{type:"dict_or_set"});if(!o)break;o.yields=o.yields||[],o.yields.push([this,$pos]),r=o}var a=$get_module(this);a.yields_func_check=a.yields_func_check||[],a.yields_func_check.push([this,$pos]);var s=this.scope=$get_scope(this,!0),i=$get_node(this);i.has_yield=this;var _=$parent_match(this,{type:"comprehension"});if($get_scope(this).id.startsWith("lc"+$B.lambda_magic)&&delete i.has_yield,_){var l=_.tree[0].tree[1];for(r=e;r&&r!==l;)r=r.parent;r||$_SyntaxError(e,["'yield' inside list comprehension"])}var c=!1;for(r=e;r;){if("lambda"==r.type){c=!0,this.in_lambda=!0;break}r=r.parent}for(r=i.parent;r;){if(r.C&&r.C.tree.length>0&&"with"==r.C.tree[0].type){s.C.tree[0].$has_yield_in_cm=!0;break}r=r.parent}if(!c)switch(e.type){case"node":break;case"assign":case"list_or_tuple":break;default:$_SyntaxError(e,"yield atom must be inside ()")}};$YieldCtx.prototype.toString=function(){return"(yield) "+(this.from?"(from) ":"")+this.tree},$YieldCtx.prototype.transition=function(e,t){var r=this;return"from"==e?("abstract_expr"!=r.tree[0].type&&$_SyntaxError(r,"'from' must follow 'yield'"),r.from=!0,r.from_num=$B.UUID(),r.tree[0]):$transition(r.parent,e)},$YieldCtx.prototype.transform=function(e,t){for(var r=e.parent;r;){if(void 0!==r.ctx_manager_num){e.parent.insert(t+1,$NodeJS("$top_frame[1].$has_yield_in_cm = true"));break}r=r.parent}},$YieldCtx.prototype.to_js=function(){return this.from?"_r"+this.from_num:"yield "+$to_js(this.tree)},$YieldCtx.prototype.check_in_function=function(){if(!this.in_lambda){var e=$get_scope(this),t=e.is_function,r=e;if(!t&&e.is_comp){for(var n=e.parent_block;n.is_comp;)n=parent_block;t=n.is_function,r=n}if(t){var o=r.C.tree[0];this.is_await||(o.type="generator")}else $_SyntaxError(this.parent,["'yield' outside function"])}};var $add_line_num=$B.parser.$add_line_num=function(e,t,r){if("module"!=e.type){if("marker"!==e.type){for(var n=e.C.tree[0],o=1,a=!0,s=e;void 0!==s.parent;)s=s.parent;var i=s.id,_=e.line_num;if(void 0===_&&(a=!1),("condition"==n.type&&"elif"==n.token||"except"==n.type||"single_kw"==n.type)&&(a=!1),a){var l=';$locals.$line_info = "'+(void 0===r?_+","+i:r)+'";if($locals.$f_trace !== _b_.None){$B.trace_line()};_b_.None;',c=new $Node;c.is_line_num=!0,new $NodeJSCtx(c,l),e.parent.insert(t,c),o=2}for(u=0;u0){var r=e.children[0];if(r.C.tree&&r.C.tree.length>0&&"expr"==r.C.tree[0].type){var n=r.C.tree[0].tree[0];"str"!=n.type||Array.isArray(n.tree[0])||(t=r.C.tree[0].tree[0].to_js())}}return t},$get_scope=$B.parser.$get_scope=function(e,t){for(var r=e.parent;"node"!==r.type;)r=r.parent;for(var n=r.node,o=null;n.parent&&"module"!==n.parent.type;){var a=n.parent.C.tree[0].type;switch(a){case"def":case"class":case"generator":return(o=n.parent).ntype=a,o.is_function="class"!=a,o}n=n.parent}return(o=n.parent||n).ntype="module",o},$get_line_num=$B.parser.$get_line_num=function(e){var t=$get_node(e),r=t.line_num;if(void 0===t.line_num){for(t=t.parent;t&&void 0===t.line_num;)t=t.parent;t&&t.line_num&&(r=t.line_num)}return r},$get_module=$B.parser.$get_module=function(e){for(var t=e.parent;"node"!==t.type;)t=t.parent;var r=t.node;if("module"==r.ntype)return r;for(var n=null;"module"!=r.parent.type;)r=r.parent;return(n=r.parent).ntype="module",n},$get_src=$B.parser.$get_src=function(e){for(var t=$get_node(e);void 0!==t.parent;)t=t.parent;return t.src},$get_node=$B.parser.$get_node=function(e){for(var t=e;t.parent;)t=t.parent;return t.node},$to_js_map=$B.parser.$to_js_map=function(e){if(void 0!==e.to_js)return e.to_js();throw Error("no to_js() for "+e)},$to_js=$B.parser.$to_js=function(e,t){return void 0===t&&(t=","),e.map($to_js_map).join(t)},$mangle=$B.parser.$mangle=function(e,t){if("__"!=e.substr(0,2)||"__"===e.substr(e.length-2))return e;for(var r=$get_scope(t);;){if("module"==r.ntype)return e;if("class"==r.ntype){for(var n=r.C.tree[0].name;"_"==n.charAt(0);)n=n.substr(1);return"_"+n+e}if(!r.parent||!r.parent.C)return e;r=$get_scope(r.C.tree[0])}},$transition=$B.parser.$transition=function(e,t,r){return e.transition(t,r)};$B.forbidden=["alert","arguments","case","catch","const","constructor","Date","debugger","delete","default","do","document","enum","export","eval","extends","Error","history","function","instanceof","keys","length","location","Math","message","new","null","Number","RegExp","String","super","switch","this","throw","typeof","var","window","toLocaleString","toString","void"],$B.aliased_names=$B.list2obj($B.forbidden);for(var s_escaped="abfnrtvxuU\"0123456789'\\",is_escaped={},i=0;i>10)+String.fromCharCode(56320|1023&e)}function test_escape(e,t,r){var n,o=r-$pos-2;if(a=/^[0-7]{1,3}/.exec(t.substr(r+1)))return[String.fromCharCode(parseInt(a[0],8)),1+a[0].length];switch(t[r+1]){case"x":if(null!==(a=/^[0-9A-F]{2}/i.exec(t.substr(r+2))))return[String.fromCharCode(parseInt(a[0],16)),2+a[0].length];n=Math.min(o+2,t.length-r-3),$_SyntaxError(e,[`(unicode error) 'unicodeescape' codec can't decode bytes in position ${o}-${n}:truncated \\xXX escape`]);case"u":if(null!==(a=/^[0-9A-F]{4}/i.exec(t.substr(r+2))))return[String.fromCharCode(parseInt(a[0],16)),2+a[0].length];n=Math.min(o+4,t.length-r-3),$_SyntaxError(e,[`(unicode error) 'unicodeescape' codec can't decode bytes in position ${o}-${n}:truncated \\uXXXX escape`]);case"U":var a;if(null===(a=/^[0-9A-F]{8}/i.exec(t.substr(r+2))))n=Math.min(o+8,t.length-r-3),$_SyntaxError(e,[`(unicode error) 'unicodeescape' codec can't decode bytes in position ${o}-${n}:truncated \\uXXXX escape`]);else{var s=parseInt(a[0],16);if(!(s>1114111))return[String.fromCharCode(s),2+a[0].length];$_SyntaxError("invalid unicode escape "+a[0])}}}function test_num(e,t){var r=t.length,n=0,o=null,a={b:"binary",o:"octal",x:"hexadecimal"},s=/[_\d]/;function i(t){$pos+=n,$_SyntaxError(e,[t])}function _(e){if(0==e.value.length){i("invalid "+(a[e.subtype]||"decimal")+" literal")}else{if(!e.value[e.value.length-1].match(/[\-+_]/))return e.value=e.value.replace(/_/g,""),e.length=n,e;i("invalid "+(a[e.subtype]||"decimal")+" literal")}}for(;n-1))return _(o);o.value+=l,n++}else{if(!l.match(/j/i))break;if(o&&(!o.subtype||"float"==o.subtype))return o.imaginary=!0,_(o),o.length++,o;i("invalid syntax")}}return _(o)}var $tokenize=$B.parser.$tokenize=function(root,src){for(var br_close={")":"(","]":"[","}":"{"},br_stack="",br_pos=[],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__","async","await"],unsupported=[],$indented=["class","def","for","condition","single_kw","try","except","with"],C=null,new_node=new $Node,current=root,name="",_type=null,pos=0,indent=null,string_modifier=!1,module=root.module,lnum=root.line_num||1;pos=55296&&cp<=56319&&(cp=_b_.ord(src.substr(pos,2)),car=src.substr(pos,2),has_surrogate=!0,pos++),$B.unicode_tables.XID_Start[cp]){name=car;var p0=pos;for(pos++;pos=55296&&cp<=56319&&(cp=_b_.ord(src.substr(pos,2)),car=src.substr(pos,2),has_surrogate=!0,pos++),$B.unicode_tables.XID_Continue[cp]);)name+=car,pos++}if(name){if(kwdict.indexOf(name)>-1)$pos=pos-name.length,unsupported.indexOf(name)>-1&&$_SyntaxError(C,"Unsupported Python keyword '"+name+"'"),C=$transition(C,name);else if("string"==typeof $operators[name]&&-1==["is_not","not_in"].indexOf(name))if("is"==name){var re=/^\s+not\s+/,res=re.exec(src.substr(pos));null!==res?(pos+=res[0].length,$pos=pos-name.length,C=$transition(C,"op","is_not")):($pos=pos-name.length,C=$transition(C,"op",name))}else if("not"==name){var re=/^\s+in\s+/,res=re.exec(src.substr(pos));null!==res?(pos+=res[0].length,$pos=pos-name.length,C=$transition(C,"op","not_in")):($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))&&-1!==["r","b","u","rb","br","f","fr","rf"].indexOf(name.toLowerCase())){string_modifier=name.toLowerCase(),name="";continue}$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-1;)j++;"j"==src.charAt(j)?(C=$transition(C,"imaginary","0"+rmu(src.substr(pos,j-pos))),j++):C=$transition(C,"float","0"+rmu(src.substr(pos,j-pos))),pos=j;break}$pos=pos,C=$transition(C,"."),pos++;break;case"0":var num=test_num(C,src.substr(pos)),base;if(void 0===num.subtype?"0"!=num.value&&(base=10):base={b:2,o:8,x:16}[num.subtype],void 0!==base){C=$transition(C,"int",[base,num.value]),pos+=num.length;break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":$pos=pos;var num=test_num(C,src.substr(pos));C="float"==num.subtype?$transition(C,num.imaginary?"imaginary":"float",num.value):$transition(C,num.imaginary?"imaginary":"int",num.imaginary?num.value:[10,num.value]),pos+=num.length;break;case"\n":lnum++,br_stack.length>0||(current.C.tree.length>0||current.C.async?($pos=pos,C=$transition(C,"eol"),indent=null,new_node=new $Node):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"}":""==br_stack?($pos=pos,$_SyntaxError(C,"Unexpected closing bracket")):br_close[car]!=br_stack.charAt(br_stack.length-1)?($pos=pos,$_SyntaxError(C,"Unbalanced bracket")):(br_stack=br_stack.substr(0,br_stack.length-1),$pos=pos,C=$transition(C,car),pos++);break;case"=":"="!=src.charAt(pos+1)?($pos=pos,C=$transition(C,"="),pos++):($pos=pos,C=$transition(C,"op","=="),pos+=2);break;case",":case":":$pos=pos,":="==src.substr(pos,2)?(C=$transition(C,":="),pos++):C=$transition(C,car),pos++;break;case";":$transition(C,"eol"),0==current.C.tree.length&&($pos=pos,$_SyntaxError(C,"invalid syntax"));for(var pos1=pos+1,ends_line=!1;pos1":case"<":case"-":case"+":case"*":case"@":case"/":case"^":case"=":case"|":case"~":case"!":if("-"==car&&">"==src.charAt(pos+1)){C=$transition(C,"annotation"),pos+=2;continue}if("@"==car&&"node"==C.type){$pos=pos,C=$transition(C,car),pos++;break}var op_match="";for(var op_sign in $operators)op_sign==src.substr(pos,op_sign.length)&&op_sign.length>op_match.length&&(op_match=op_sign);$pos=pos,op_match.length>0?(C=$transition(C,op_match in $augmented_assigns?"augm_assign":"op",op_match),pos+=op_match.length):$_SyntaxError(C,"invalid character: "+car);break;case"\\":if("\n"==src.charAt(pos+1)){lnum++,pos+=2,pos==src.length?$_SyntaxError(C,["unexpected EOF while parsing"]):"node"==C.type&&$_SyntaxError(C,"nothing before \\");break}$pos=pos,$_SyntaxError(C,["unexpected character after line continuation character"]);case String.fromCharCode(12):pos+=1;break;default:$pos=pos,$_SyntaxError(C,"unknown token ["+car+"]")}}else{var raw="str"==C.type&&C.raw,bytes=!1,fstring=!1,sm_length,end=null;if(string_modifier){switch(string_modifier){case"r":raw=!0;break;case"u":break;case"b":bytes=!0;break;case"rb":case"br":bytes=!0,raw=!0;break;case"f":fstring=!0,sm_length=1;break;case"rf":fstring=!0,sm_length=2,raw=!0}string_modifier=!1}src.substr(pos,3)==car+car+car?(_type="triple_string",end=pos+3):(_type="string",end=pos+1);for(var escaped=!1,zone=car,found=!1;end0&&(indent+=8-indent%8)}}var _s=src.charAt(pos);if("\n"==_s){pos++,lnum++,indent=null;continue}if("#"==_s){var offset=src.substr(pos).search(/\n/);if(-1==offset)break;pos+=offset+1,lnum++,indent=null;continue}if(new_node.indent=indent,new_node.line_num=lnum,new_node.module=module,new_node.pos=pos,current.is_body_node&&(current.indent=indent),indent>current.indent)null!==C&&-1==$indented.indexOf(C.tree[0].type)&&($pos=pos,$_SyntaxError(C,"unexpected indent",pos)),current.add(new_node);else if(indent<=current.indent&&C&&C.tree[0]&&$indented.indexOf(C.tree[0].type)>-1&&C.tree.length<2)$pos=pos,$_SyntaxError(C,"expected an indented block",pos);else{for(;indent!==current.indent;)current=current.parent,(void 0===current||indent>current.indent)&&($pos=pos,$_SyntaxError(C,"unexpected indent",pos));current.parent.add(new_node)}current=new_node,C=new $NodeCtx(new_node)}function rmu(e){return e.replace(/_/g,"")}}if(0!=br_stack.length){var br_err=br_pos[0];$pos=br_err[1];var lines=src.split("\n"),id=root.id,fname=id.startsWith("$")?"":id;$_SyntaxError(br_err[0],["unexpected EOF while parsing ("+fname+", line "+(lines.length-1)+")"])}if(null!==C){if("async"==C.type)throw console.log("error with async",pos,src,src.substr(pos)),$pos=pos-7,$_SyntaxError(C,"car "+car+"after async",pos);if(C.tree[0]&&$indented.indexOf(C.tree[0].type)>-1)$pos=pos-1,$_SyntaxError(C,"expected an indented block",pos);else{var parent=current.parent;if(parent.C&&parent.C.tree&&parent.C.tree[0]&&"try"==parent.C.tree[0].type&&($pos=pos-1,$_SyntaxError(C,["unexpected EOF while parsing"])),root.yields_func_check){var save_pos=$pos;for(const e of root.yields_func_check)$pos=e[1],e[0].check_in_function();$pos=save_pos}}}},$create_root_node=$B.parser.$create_root_node=function(e,t,r,n,o){var a=new $Node("module");return a.module=t,a.id=r,a.binding={__doc__:!0,__name__:!0,__file__:!0,__package__:!0},a.parent_block=n,a.line_num=o,a.indent=-1,a.comments=[],a.imports={},"object"==typeof e&&(a.is_comp=e.is_comp,a.filename=e.filename,e.has_annotations&&(a.binding.__annotations__=!0),e=e.src),a.src=e,a};$B.py2js=function(e,t,r,n,o){if($pos=0,"object"==typeof t){var a=t.__package__;t=t.__name__}else a="";n=n||$B.builtins_scope;var s=(new Date).getTime(),i=!1,_=!0;if("object"==typeof e){i=e.is_comp,_=e.has_annotations;var l=e.line_info,c=e.ix,u=e.filename;void 0!==l&&(o=parseInt(l.split(",")[0])),e=e.src}(e=e.replace(/\r\n/gm,"\n")).endsWith("\\")&&!e.endsWith("\\\\")&&(e=e.substr(0,e.length-1)),"\n"!=e.charAt(e.length-1)&&(e+="\n"),Array.isArray(r)&&(r=r[0]);r.charAt(0);var f="$locals_"+r.replace(/\./g,"_"),p="$locals_"+t.replace(/\./g,"_"),$=$create_root_node({src:e,is_comp:i,has_annotations:_,filename:u},t,r,n,o);$tokenize($,e),$.is_comp=i,null!=c&&($.ix=c),$.transform();var d=1;(g=["var $B = __BRYTHON__;\n"])[d++]="var _b_ = __BRYTHON__.builtins;\n",g[2]="var $locals = "+f,i&&(g[2]+=" = {}");var h=0;$.insert(0,$NodeJS(g.join(""))),h++,$.insert(h++,$NodeJS(f+'.__package__ = "'+a+'"')),$.binding.__annotations__&&$.insert(h++,$NodeJS("$locals.__annotations__ = $B.empty_dict()"));var m=h,g='var $top_frame = ["'+r.replace(/\./g,"_")+'", '+f+', "'+t.replace(/\./g,"_")+'", '+p+"]\n$locals.$f_trace = $B.enter_frame($top_frame)\nvar $stack_length = $B.frames_stack.length;";$.insert(h++,$NodeJS(g));var b=new $NodeJS("try"),y=$.children.slice(m+1,$.children.length);$.insert(m+1,b),0==y.length&&(y=[$NodeJS("")]),y.forEach((function(e){b.add(e)})),b.add($NodeJS("$B.leave_frame({$locals, value: _b_.None})")),$.children.splice(m+2,$.children.length);var v=$NodeJS("catch(err)");v.add($NodeJS("$B.leave_frame({$locals, value: _b_.None})")),v.add($NodeJS("throw err")),$.add(v),$add_line_num($,null,l);var x=(new Date).getTime();return $B.debug>2&&t==r&&console.log("module "+t+" translated in "+(x-s)+" ms"),$B.compile_time+=x-s,$},$B.set_import_paths=function(){var e=[],t=[];$B.use_VFS&&e.push($B.finders.VFS),!1!==$B.$options.static_stdlib_import&&"file"!=$B.protocol&&(e.push($B.finders.stdlib_static),$B.path.length>3&&($B.path.shift(),$B.path.shift())),"file"!==$B.protocol&&(e.push($B.finders.path),t.push($B.url_hook)),$B.$options.cpython_import&&("replace"==$B.$options.cpython_import&&$B.path.pop(),e.push($B.finders.CPython)),$B.meta_path=e,$B.path_hooks=t};var brython=$B.parser.brython=function(e){void 0===e&&(e={debug:1}),"number"==typeof e&&(e={debug:e}),void 0===e.debug&&(e.debug=1),$B.debug=e.debug,_b_.__debug__=$B.debug>0,$B.compile_time=0,void 0===e.profile&&(e.profile=0),$B.profile=e.profile,void 0===e.indexedDB&&(e.indexedDB=!0),void 0===e.static_stdlib_import&&(e.static_stdlib_import=!0),$B.static_stdlib_import=e.static_stdlib_import,$B.$options=e,$B.set_import_paths();var t=($B.script_path=_window.location.href).split("/");if(t.pop(),($B.isWebWorker||$B.isNode)&&t.pop(),$B.curdir=t.join("/"),void 0!==e.pythonpath&&($B.path=e.pythonpath,$B.$options.static_stdlib_import=!1),e.python_paths&&e.python_paths.forEach((function(e){var t,r;"string"!=typeof e&&(t=e.lang,r=e.prefetch,e=e.path),$B.path.push(e),".vfs.js"!=e.slice(-7).toLowerCase()||void 0!==r&&!0!==r||($B.path_importer_cache[e+"/"]=$B.imported._importlib.VFSPathFinder(e)),t&&o.optimize_import_for_path(e,t)})),!$B.isWebWorker&&!$B.isNode)for(var r,n=document.querySelectorAll("head link[rel~=pythonpath]"),o=$B.imported._importlib,a=0;r=n[a];++a){var s=r.href;-1!=(" "+r.rel+" ").indexOf(" prepend ")?$B.path.unshift(s):$B.path.push(s);var i=r.hreflang;i&&("x-"==i.slice(0,2)&&(i=i.slice(2)),o.optimize_import_for_path(r.href,i))}$B.$options.args?$B.__ARGV=$B.$options.args:$B.__ARGV=_b_.list.$factory([]),$B.isWebWorker||$B.isNode||_run_scripts(e)};$B.run_script=function(e,t,r){$B.$py_module_path[t]=$B.script_path;try{var n=$B.py2js(e,t,t),o=n.to_js(),a={__doc__:n.__doc__,js:o,__name__:t,$src:e,__file__:$B.script_path+($B.script_path.endsWith("/")?"":"/")+t};$B.file_cache[a.__file__]=e,$B.debug>1&&console.log(o)}catch(e){$B.handle_error(e)}if($B.hasOwnProperty("VFS")&&$B.has_indexedDB){var s=Object.keys(n.imports).slice().filter((function(e){return $B.VFS.hasOwnProperty(e)}));Object.keys(s).forEach((function(e){if($B.VFS.hasOwnProperty(e)){var t=$B.VFS[e],r=t[0];if(".py"==r){t[1];var n=t[2];t.length;".py"==r&&required_stdlib_imports(n),n.forEach((function(e){-1==s.indexOf(e)&&s.push(e)}))}}}));for(var i=0;i1&&$log(js),eval(js),$B.clear_ns(module_name),root=null,js=null}catch(e){if(root=null,js=null,console.log(e),$B.debug>1)for(var attr in console.log(e),e)console.log(attr+" : ",e[attr]);void 0===e.$py_error&&(console.log("Javascript error",e),e=_b_.RuntimeError.$factory(e+""));var $trace=$B.$getattr(e,"info")+"\n"+e.__name__+": "+e.args;try{$B.$getattr($B.stderr,"write")($trace)}catch(e){console.log($trace)}throw e}}else{$elts.length>0&&options.indexedDB&&$B.has_indexedDB&&$B.hasOwnProperty("VFS")&&$B.tasks.push([$B.idb_open]);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+"'");defined_ids[elt.id]=!0}}for(var src,i=0,len=webworkers.length;i1&&console.log("store precompiled",t,"package",i),document.dispatchEvent(new CustomEvent("precompile",{detail:"cache module "+t}));var u=e.outdated.indexOf(t);u>-1&&e.outdated.splice(u,1),c.onsuccess=function(r){e.tasks.splice(0,0,[n,t]),a()}}function n(t){var s=e.idb_cx.result.transaction("modules","readonly");try{var i=s.objectStore("modules");req=i.get(t),req.onsuccess=function(s){!function(t,s){var i=t.target.result;if(e.timestamp,void 0===i||i.timestamp!=e.timestamp||e.VFS[s]&&i.source_ts!==e.VFS[s].timestamp){if(void 0!==e.VFS[s]){var _=(v=e.VFS[s])[0],l=v[1];if(".py"==_){var c,u,f=v[2],p=4==v.length,$=v.timestamp;p?c=s:((u=s.split(".")).pop(),c=u.join(".")),e.imported[s]=e.module.$factory(s,"",c);try{var d=e.py2js(l,s,s).to_js()}catch(t){e.handle_error(t)}delete e.imported[s],e.debug>1&&console.log("precompile",s),(u=s.split(".")).length>1&&u.pop(),e.stdlib.hasOwnProperty(u.join("."))&&(f=(f=v[2]).join(","),e.tasks.splice(0,0,[r,s,d,$,f,p]))}else console.log("bizarre",s,_)}}else if(i.is_package?e.precompiled[s]=[i.content]:e.precompiled[s]=i.content,i.imports.length>0){e.debug>1&&console.log(s,"imports",i.imports);for(var h=i.imports.split(","),m=0;me.timestamp&&(e.timestamp=e.VFS_timestamp),e.idb_open=function(t){e.idb_name="brython-cache";var r=e.idb_cx=indexedDB.open(e.idb_name);r.onsuccess=function(){var t=r.result;if(t.objectStoreNames.contains("modules")){e.debug>1&&console.info("using indexedDB for stdlib modules cache");var n,o=t.transaction("modules","readwrite").objectStore("modules"),s=[],i=o.openCursor();i.onerror=function(e){console.log("open cursor error",e)},i.onsuccess=function(t){cursor=t.target.result,cursor?((n=cursor.value).timestamp==e.timestamp?e.VFS&&e.VFS[n.name]&&e.VFS[n.name].timestamp!=n.source_ts?s.push(n.name):(n.is_package?e.precompiled[n.name]=[n.content]:e.precompiled[n.name]=n.content,e.debug>1&&console.info("load from cache",n.name)):s.push(n.name),cursor.continue()):(e.debug>1&&console.log("done"),e.outdated=s,a())}}else{var _=t.version;t.close(),console.info("create object store",_),(r=indexedDB.open(e.idb_name,_+1)).onupgradeneeded=function(){console.info("upgrade needed"),e.idb_cx.result.createObjectStore("modules",{keyPath:"name"}).onsuccess=a},r.onversionchanged=function(){console.log("version changed")},r.onsuccess=function(){console.info("db opened",r),r.result.createObjectStore("modules",{keyPath:"name"}).onsuccess=a}}},r.onupgradeneeded=function(){console.info("upgrade needed"),r.result.createObjectStore("modules",{keyPath:"name"}).onsuccess=a},r.onerror=function(){console.info("could not open indexedDB database"),e.idb_cx=null,e.idb_name=null,e.$options.indexedDB=!1,a()}},e.ajax_load_script=function(r){var n=r.url,o=r.name;if(e.files&&e.files.hasOwnProperty(o))e.tasks.splice(0,0,[e.run_script,e.files[o],o,!0]);else{if("file"==e.protocol)throw t.IOError.$factory("can't load external script at "+r.url+" (Ajax calls not supported with protocol file:///)");var s=new XMLHttpRequest,i=e.$options.cache?"":(n.search(/\?/)>-1?"&":"?")+Date.now();s.open("GET",n+i,!0),s.onreadystatechange=function(){if(4==this.readyState)if(200==this.status){var t=this.responseText;r.is_ww?e.webworkers[o]=t:e.tasks.splice(0,0,[e.run_script,t,o,!0]),a()}else if(404==this.status)throw Error(n+" not found")},s.send()}};e.inImported=function(t){if(e.imported.hasOwnProperty(t));else if(__BRYTHON__.VFS&&__BRYTHON__.VFS.hasOwnProperty(t)){var r=__BRYTHON__.VFS[t];void 0===r&&console.log("bizarre",t);var s=r[0],i=r[1];r.length;".py"==s?e.idb_cx&&!e.idb_cx.$closed&&e.tasks.splice(0,0,[n,t]):o(t,i)}else console.log("bizarre",t);a()};var a=e.loop=function(){if(0!=e.tasks.length){var r=e.tasks.shift(),n=r[0],o=r.slice(1);if("execute"==n){try{var s=r[1],i=s.__name__.replace(/\./g,"_");(l=e.module.$factory(s.__name__)).$src=s.$src,l.__file__=s.__file__,e.imported[i]=l,new Function("$locals_"+i,s.js)(l)}catch(r){void 0===r.__class__&&(console.log("Javascript error",r),e.is_recursion_error(r)?r=t.RecursionError.$factory("too much recursion"):(e.print_stack(),r=t.RuntimeError.$factory(r+""))),e.debug>1&&(console.log("handle error",r.__class__,r.args,r.$stack),console.log(e.frames_stack.slice())),e.handle_error(r)}a()}else try{n.apply(null,o)}catch(t){e.handle_error(t)}}else{if(e.idb_cx&&!e.idb_cx.$closed){for(var _=e.idb_cx.result.transaction("modules","readwrite").objectStore("modules");e.outdated.length>0;){var l=e.outdated.pop();_.delete(l).onsuccess=function(t){e.debug>1&&console.info("delete outdated",l),document.dispatchEvent(new CustomEvent("precompile",{detail:"remove outdated "+l+" from cache"}))}}document.dispatchEvent(new CustomEvent("precompile",{detail:"close"})),e.idb_cx.result.close(),e.idb_cx.$closed=!0}document.dispatchEvent(new CustomEvent("brython_done",{detail:e.obj_dict(e.$options)}))}};e.tasks=[],e.has_indexedDB=void 0!==self.indexedDB,e.handle_error=function(r){if(e.debug>1&&console.log("handle error",r.__class__,r.args),void 0!==r.__class__){var n=e.class_name(r),o=e.$getattr(r,"info");if("SyntaxError"==n||"IndentationError"==n){var a=r.args[1][2];o+="\n "+" ".repeat(a)+"^\n"+n+": "+r.args[0]}else o+="\n"+n,void 0!==r.args[0]&&r.args[0]!==t.None&&(o+=": "+t.str.$factory(r.args[0]))}else console.log(r),o=r+"";try{e.$getattr(e.stderr,"write")(o);var s=e.$getattr(e.stderr,"flush",t.None);s!==t.None&&s()}catch(e){console.debug(o)}throw r}}(__BRYTHON__),__BRYTHON__.builtins.object=function(e){var t=e.builtins,r={$infos:{__name__:"object"},$is_class:!0,$native:!0};function n(t){return e.$getattr(t,"__new__").apply(null,arguments)}return r.__delattr__=function(r,n){if(n=e.from_alias(n),r.__dict__&&r.__dict__.$string_dict&&void 0!==r.__dict__.$string_dict[n])return delete r.__dict__.$string_dict[n],t.None;if(void 0===r.__dict__&&void 0!==r[n])return delete r[n],t.None;var o=r.__class__;if(o){var a=e.$getattr(o,n);if(a.__class__===t.property&&void 0!==a.__delete__)return a.__delete__(r),t.None}throw t.AttributeError.$factory(n)},r.__dir__=function(r){var n;if(r.$is_class)n=[r].concat(r.__mro__);else{var o=r.__class__||e.get_class(r);n=[r,o].concat(o.__mro__)}for(var a=[],s=0,i=n.length;s0)throw t.TypeError.$factory("object() takes no parameters");return{__class__:n,__dict__:e.empty_dict()}},r.__ne__=function(r,n){if(r===n)return!1;var o=e.$getattr(r,"__eq__",null);if(null!==o){var a=e.$call(o)(n);return a===t.NotImplemented?a:!e.$bool(a)}return t.NotImplemented},r.__reduce__=function(r){function n(t){return e.$call(t)()}n.$infos={__qualname__:"_reconstructor"};var o=[n];o.push(t.tuple.$factory([r.__class__].concat(r.__class__.__mro__)));var a=e.empty_dict();for(var s in r.__dict__.$string_dict)t.dict.$setitem(a.$string_dict,s,r.__dict__.$string_dict[s][0]);return console.log("object.__reduce__, d",a),o.push(a),t.tuple.$factory(o)},n.$infos={__name__:"__newobj__",__qualname__:"__newobj__"},t.__newobj__=n,r.__reduce_ex__=function(r){var o=[n],a=t.tuple.$factory([r.__class__]);Array.isArray(r)&&r.forEach((function(e){a.push(e)})),o.push(a);var s=e.empty_dict(),i=0;if(void 0===r.__dict__)throw t.TypeError.$factory("cannot pickle '"+e.class_name(r)+"' object");for(var _ in r.__dict__.$string_dict)"__class__"==_||_.startsWith("$")||(t.dict.$setitem(s,_,r.__dict__.$string_dict[_][0]),i++);return 0==i&&(s=t.None),o.push(s),o.push(t.None),t.tuple.$factory(o)},r.__repr__=function(n){if(n===r)return"";if(n.__class__===t.type)return"";var o=n.__class__.$infos.__module__;return void 0===o||o.startsWith("$")||"builtins"===o?"<"+e.class_name(n)+" object>":"<"+n.__class__.$infos.__module__+"."+e.class_name(n)+" object>"},r.__setattr__=function(n,o,a){if(void 0===a)throw t.TypeError.$factory("can't set attributes of built-in/extension type 'object'");if(n.__class__===r)throw void 0===r[o]?t.AttributeError.$factory("'object' object has no attribute '"+o+"'"):t.AttributeError.$factory("'object' object attribute '"+o+"' is read-only");return e.aliased_names[o]&&(o="$$"+o),n.__dict__?t.dict.$setitem(n.__dict__,o,a):n[o]=a,t.None},r.__setattr__.__get__=function(e){return function(t,n){r.__setattr__(e,t,n)}},r.__setattr__.__str__=function(){return"method object.setattr"},r.__str__=function(t){var r=e.$getattr(t,"__repr__");return e.$call(r)()},r.__subclasshook__=function(){return t.NotImplemented},r.$factory=function(){var e={__class__:r},t=[e].concat(Array.prototype.slice.call(arguments));return r.__init__.apply(null,t),e},e.set_func_names(r,"builtins"),e.make_class=function(e,n){var o={__class__:t.type,__mro__:[r],$infos:{__name__:e},$is_class:!0};return o.$factory=n,o},r}(__BRYTHON__),function(e){var t=e.builtins;e.$class_constructor=function(r,n,o,a,s){var i;o=o||[];var _=n.__module__;void 0===_&&(_=n.__module__=e.last(e.frames_stack)[2]);for(var l=0;l0){if(void 0===(i=o[0].__class__)){if("function"!=typeof o[0])throw t.TypeError.$factory("Argument of "+r+"is not a class (type '"+e.class_name(o[0])+"')");if(1!=o.length)throw t.TypeError.$factory("A Brython class can inherit at most 1 Javascript constructor");i=o[0].__class__=e.JSMeta,e.set_func_names(o[0],_)}for(l=1;l-1)return a.$factory(n,r);if(r.__class__&&r.__class__[n]&&r.__class__[n].__get__&&r.__class__[n].__set__)return r.__class__[n].__get__(r);if(void 0===h){if(void 0===(p=r[n])){var f;void 0===(f=r.__mro__)&&console.log("pas de mro pour",r);for(i=0;i1&&console.log("warning: no attribute $infos for",h,"klass",r,"attr",n),"__new__"!=n&&h.__class__!==e.builtin_function||(h.$type="staticmethod"),"__class_getitem__"==n&&h.__class__!==e.method&&(h=t.classmethod.$factory(h)),"__init_subclass__"==n&&(h=t.classmethod.$factory(h)),h.__class__===e.method?h.__get__(null,r):h):h:h.__class__.__get__(h,t.None,r)}},r.__hash__=function(e){return t.hash(e)},r.__init__=function(){},r.__init_subclass__=function(){var r=e.args("__init_subclass__",1,{},[],arguments,{},"args","kwargs");if(void 0!==r.kwargs&&(r.kwargs.__class__!==t.dict||Object.keys(r.kwargs.$string_dict).length>0))throw t.TypeError.$factory("__init_subclass__() takes no keyword arguments");return t.None},r.__instancecheck__=function(t,r){var n=r.__class__||e.get_class(r);if(n===t)return!0;for(var o=0;o"},r.__prepare__=function(){return e.empty_dict()},r.__qualname__={__get__:function(e){return e.$infos.__qualname__||e.$infos.__name__},__set__:function(e,t){e.$infos.__qualname__=t},__str__:function(e){console.log("type.__qualname__")},__eq__:function(e,t){return e.$infos.__qualname__==t}},r.mro=function(r){for(var n=r.__bases__,o=[],a=0,s=0;s0&&(p[_++]=o[s]);if(0==p.length)break;for(s=0;s-1&&(d[_++]=m)}if(!(d.length>0))break;$=null}if(null===$)throw t.TypeError.$factory("inconsistent hierarchy, no C3 MRO is possible");u[f++]=$;for(s=0;s-1},e.set_func_names(r,"builtins"),t.type=r;var n=e.make_class("wrapper_descriptor");e.set_func_names(n,"builtins"),r.__call__.__class__=n;e.$instance_creator=function(r){if(r.prototype&&r.prototype.constructor==r)return function(){return new r(...arguments)};if(void 0!==r.$instanciable)return function(){throw t.TypeError.$factory("Can't instantiate abstract class interface with abstract methods")};var n,o=r.__class__||e.get_class(r);if(o!==t.type||r.__bases__&&0!=r.__bases__.length){n=t.type.__getattribute__(o,"__call__");var a=function(){return n.bind(null,r).apply(null,arguments)}}else a=r.hasOwnProperty("__new__")?r.hasOwnProperty("__init__")?function(){var e=r.__new__.bind(null,r).apply(null,arguments);return r.__init__.bind(null,e).apply(null,arguments),e}:function(){return r.__new__.bind(null,r).apply(null,arguments)}:r.hasOwnProperty("__init__")?function(){var t={__class__:r,__dict__:e.empty_dict()};return r.__init__.bind(null,t).apply(null,arguments),t}:function(){if(arguments.length>0&&(1!=arguments.length||!arguments[0].$nat||0!=Object.keys(arguments[0].kw).length))throw t.TypeError.$factory("object() takes no parameters");return{__class__:r,__dict__:e.empty_dict()}};return a.__class__=e.Function,a.$infos={__name__:r.$infos.__name__,__module__:r.$infos.__module__},a};var o=e.method_wrapper=e.make_class("method_wrapper",(function(e,t,r){var n=function(){return r.apply(null,arguments)};return n.$infos={__name__:e,__module__:t.__module__},n}));o.__str__=o.__repr__=function(e){return""};var a=e.make_class("member_descriptor",(function(e,t){return{__class__:a,cls:t,attr:e}}));a.__str__=a.__repr__=function(e){return""},e.set_func_names(a,"builtins");var s=e.method=e.make_class("method",(function(t,r){var n=function(){return e.$call(t).bind(null,r).apply(null,arguments)};return n.__class__=s,n.$infos=t.$infos,n}));s.__eq__=function(e,t){return void 0!==e.$infos&&void 0!==t.$infos&&e.$infos.__func__===t.$infos.__func__&&e.$infos.__self__===t.$infos.__self__},s.__ne__=function(t,r){return!e.method.__eq__(t,r)},s.__get__=function(t){var r=function(){return t(arguments)};return r.__class__=e.method_wrapper,r.$infos=s.$infos,r},s.__getattribute__=function(r,n){var o=r.$infos;if(o&&o[n]){if("__code__"==n){var a={__class__:e.Code};for(var n in o.__code__)a[n]=o.__code__[n];return a}return o[n]}return s.hasOwnProperty(n)?t.object.__getattribute__(r,n):e.Function.__getattribute__(r.$infos.__func__,n)},s.__repr__=s.__str__=function(e){return""},s.__setattr__=function(e,r,n){if("__class__"==r)throw t.TypeError.$factory("__class__ assignment only supported for heap types or ModuleType subclasses");throw t.AttributeError.$factory("'method' object has no attribute '"+r+"'")},e.set_func_names(s,"builtins"),e.method_descriptor=e.make_class("method_descriptor"),e.classmethod_descriptor=e.make_class("classmethod_descriptor"),e.GenericAlias=e.make_class("GenericAlias",(function(t,r){return{__class__:e.GenericAlias,origin_class:t,items:r}})),e.GenericAlias.__args__={__get__:function(t){return e.fast_tuple(t.items)}},e.GenericAlias.__call__=function(e,...t){return e.origin_class.$factory.apply(null,t)},e.GenericAlias.__eq__=function(t,r){return e.rich_comp("__eq__",t.origin_class,r.origin_class)&&e.rich_comp("__eq__",t.items,r.items)},e.GenericAlias.__getitem__=function(r,n){throw t.TypeError.$factory("descriptor '__getitem__' for '"+r.origin_class.$infos.__name__+"' objects doesn't apply to a '"+e.class_name(n)+"' object")},e.GenericAlias.__origin__={__get__:function(e){return e.origin_class}},e.GenericAlias.__parameters__={__get__:function(t){return e.fast_tuple([])}},e.GenericAlias.__repr__=function(e){for(var r=e.items,n=0,o=r.length;n");var _,l,c=!1,u=o.length,f=0,p=n.indexOf("/");if(-1!=p&&(n.splice(p,1),l=n.slice(0,p)),u>0&&o[u-1]&&o[u-1].$nat&&(u--,Object.keys(o[u].kw).length>0)){c=!0;var $=o[u].kw;if(Array.isArray($)){for(var d=$[0],h=1,m=$.length;ht){if(null===s||"*"==s)throw j=e+"() takes "+t+" positional argument"+(t>1?"s":"")+" but more were given",_b_.TypeError.$factory(j);for(h=t;h-1)throw _b_.TypeError.$factory(e+"() got an unexpected keyword argument '"+x+"'");r[w]=B}}var k=[];for(var E in r)null===r[E]&&(void 0!==a[E]?r[E]=a[E]:k.push("'"+E+"'"));if(k.length>0){if(1==k.length)throw _b_.TypeError.$factory(e+" missing 1 positional argument: "+k[0]);var j=e+" missing "+k.length+" positional arguments: ";throw j+=k.join(" and "),_b_.TypeError.$factory(j)}return i&&(r[i]=_),r},$B.wrong_nb_args=function(e,t,r,n){if(t1?"s":"")+": "+n.slice(t))}throw _b_.TypeError.$factory(e+"() takes "+r+" positional argument"+(r>1?"s":"")+" but more were given")},$B.get_class=function(e){if(null===e)return $B.$NoneDict;if(void 0===e)return $B.UndefinedClass;var t=e.__class__;if(void 0===t)switch(typeof e){case"number":return e%1==0?_b_.int:_b_.float;case"string":return _b_.str;case"boolean":return _b_.bool;case"function":return e.$is_js_func?$B.JSObj:(e.__class__=$B.Function,$B.Function);case"object":if(Array.isArray(e)){if(Object.getPrototypeOf(e)===Array.prototype)return e.__class__=_b_.list,_b_.list}else{if(e.constructor===Number)return _b_.float;if("undefined"!=typeof Node&&e instanceof Node)return $B.DOMNode}}return void 0===t?$B.JSObj:t},$B.class_name=function(e){var t=$B.get_class(e);return t===$B.JSObj?"Javascript "+e.constructor.name:t.$infos.__name__},$B.$list_comp=function(e){for(var t=$B.UUID(),r="comp_result_"+$B.lambda_magic+t,n=r+" = []\n",o=0,a=1,s=e.length;a-1&&void 0!==n[1][e])return n[1][e];if(t.indexOf(n[2])>-1&&void 0!==n[3][e])return n[3][e]}for(r=0;r=0;n--){if(void 0!==(r=$B.frames_stack[n][1][e]))return r;if(void 0!==(r=$B.frames_stack[n][3][e]))return r}throw _b_.NameError.$factory("free variable '"+$B.from_alias(e)+"' referenced before assignment in enclosing scope")},$B.$check_def_free1=function(e,t){for(var r,n=$B.frames_stack.length-1;n>=0;n--){var o=$B.frames_stack[n];if(void 0!==(r=o[1][e]))return r;if(o[1].$parent&&void 0!==(r=o[1].$parent[e]))return r;if(o[2]==t&&void 0!==(r=o[3][e]))return r}throw _b_.NameError.$factory("free variable '"+$B.from_alias(e)+"' referenced before assignment in enclosing scope")},$B.$JS2Py=function(e){return"number"==typeof e?e%1==0?e:_b_.float.$factory(e):null==e?_b_.None:(Array.isArray(e)&&Object.getPrototypeOf(e)===Array.prototype&&(e.$brython_class="js"),e)},$B.list_key=function(e,t){(t=$B.$GetInt(t))<0&&(t+=e.length);var r=e[t];if(void 0===r)throw _b_.IndexError.$factory("list index out of range");return r},$B.list_slice=function(e,t,r){return null===t?t=0:(t=$B.$GetInt(t))<0&&(t=Math.max(0,t+e.length)),null===r?e.slice(t):((r=$B.$GetInt(r))<0&&(r=Math.max(0,r+e.length)),e.slice(t,r))},$B.list_slice_step=function(e,t,r,n){if(null===n||1==n)return $B.list_slice(e,t,r);if(0==n)throw _b_.ValueError.$factory("slice step cannot be zero");n=$B.$GetInt(n),null===t?t=n>=0?0:e.length-1:(t=$B.$GetInt(t))<0&&(t=Math.min(0,t+e.length)),null===r?r=n>=0?e.length:-1:(r=$B.$GetInt(r))<0&&(r=Math.max(0,r+e.length));var o=[];if(n>0)for(var a=t;ar;a+=n)o.push(e[a]);return o},$B.$getitem=function(e,t){var r=Array.isArray(e)&&e.__class__===_b_.list,n=e.__class__===_b_.dict&&!e.$jsobj;if("number"==typeof t){if(r||"string"==typeof e){if(void 0!==e[t=t>=0?t:e.length+t])return e[t];index_error(e)}else if(n&&void 0!==e.$numeric_dict[t])return e.$numeric_dict[t][0]}else if("string"==typeof t&&n){var o=e.$string_dict[t];if(void 0!==o)return o[0];throw _b_.KeyError.$factory(t)}if(e.$is_class){var a=$B.$getattr(e,"__class_getitem__",_b_.None);if(a!==_b_.None)return a(t);if(e.__class__){if((a=$B.$getattr(e.__class__,"__getitem__",_b_.None))!==_b_.None)return a(e,t);throw _b_.TypeError.$factory("'"+$B.class_name(e.__class__)+"' object is not subscriptable")}}if(r)return _b_.list.$getitem(e,t);if(n)return _b_.dict.$getitem(e,t);var s=$B.$getattr(e,"__getitem__",_b_.None);if(s!==_b_.None)return s(t);throw _b_.TypeError.$factory("'"+$B.class_name(e)+"' object is not subscriptable")},$B.getitem_slice=function(e,t){var r;return Array.isArray(e)?(t.start===_b_.None&&t.stop===_b_.None?t.step===_b_.None||1==t.step?r=e.slice():-1==t.step&&(r=e.slice().reverse()):t.step===_b_.None&&(t.start===_b_.None&&(t.start=0),t.stop===_b_.None&&(t.stop=e.length),"number"==typeof t.start&&"number"==typeof t.stop&&(t.start<0&&(t.start+=e.length),t.stop<0&&(t.stop+=e.length),r=e.slice(t.start,t.stop))),r?(r.__class__=e.__class__,r):_b_.list.$getitem(e,t)):$B.$getattr(e,"__getitem__")(t)},$B.set_list_key=function(e,t,r){try{t=$B.$GetInt(t)}catch(o){if(_b_.isinstance(t,_b_.slice)){var n=_b_.slice.$conv_for_seq(t,e.length);return $B.set_list_slice_step(e,n.start,n.stop,n.step,r)}}if(t<0&&(t+=e.length),void 0===e[t])throw console.log(e,t),_b_.IndexError.$factory("list assignment index out of range");e[t]=r},$B.set_list_slice=function(e,t,r,n){null===t?t=0:(t=$B.$GetInt(t))<0&&(t=Math.max(0,t+e.length)),null===r&&(r=e.length),(r=$B.$GetInt(r))<0&&(r=Math.max(0,r+e.length));var o=_b_.list.$factory(n);e.splice.apply(e,[t,r-t].concat(o))},$B.set_list_slice_step=function(e,t,r,n,o){if(null===n||1==n)return $B.set_list_slice(e,t,r,o);if(0==n)throw _b_.ValueError.$factory("slice step cannot be zero");n=$B.$GetInt(n),t=null===t?n>0?0:e.length-1:$B.$GetInt(t),r=null===r?n>0?e.length:-1:$B.$GetInt(r);var a,s=_b_.list.$factory(o),i=0,_=0;a=n>0?function(e){return er};for(var l=t;a(l);l+=n)_++;if(_!=s.length)throw _b_.ValueError.$factory("attempt to assign sequence of size "+s.length+" to extended slice of size "+_);for(l=t;a(l);l+=n)e[l]=s[i],i++},$B.$setitem=function(e,t,r){if(!Array.isArray(e)||void 0!==e.__class__||"number"!=typeof t||_b_.isinstance(e,_b_.tuple)){if(e.__class__!==_b_.dict)return e.__class__===_b_.list?_b_.list.$setitem(e,t,r):void $B.$getattr(e,"__setitem__")(t,r);_b_.dict.$setitem(e,t,r)}else{if(t<0&&(t+=e.length),void 0===e[t])throw _b_.IndexError.$factory("list assignment index out of range");e[t]=r}},$B.augm_item_add=function(e,t,r){if(Array.isArray(e)&&"number"==typeof t&&void 0!==e[t]){if(Array.isArray(e[t])&&Array.isArray(r)){for(var n=0,o=r.length;n>","&","^","|"];function exit_ctx_managers_in_generators(e){for(key in e[1]){if(e[1][key]&&e[1][key].__class__==$B.generator)e[1][key].return()}}$B.make_rmethods=function(e){for(var t=0,r=ropnames.length;t=0;t--)if($B.frames_stack[t][0]==$B.tracefunc.$frame_id)return _b_.None;return $B.tracefunc($B._frame.$factory($B.frames_stack,$B.frames_stack.length-1),"call",_b_.None)}return _b_.None},$B.trace_exception=function(){var e=$B.last($B.frames_stack);if(e[0]==$B.tracefunc.$current_frame_id)return _b_.None;var t=e[1].$f_trace,r=e[1].$current_exception;return t($B._frame.$factory($B.frames_stack,$B.frames_stack.length-1),"exception",$B.fast_tuple([r.__class__,r,$B.traceback.$factory(r)]))},$B.trace_line=function(){var e=$B.last($B.frames_stack);return e[0]==$B.tracefunc.$current_frame_id?_b_.None:(0,e[1].$f_trace)($B._frame.$factory($B.frames_stack,$B.frames_stack.length-1),"line",_b_.None)},$B.set_line=function(e){var t=$B.last($B.frames_stack);if($B.tracefunc&&t[0]==$B.tracefunc.$current_frame_id)return _b_.None;t[1].$line_info=e;var r=t[1].$f_trace;if(r!==_b_.None){var n=$B._frame.$factory($B.frames_stack,$B.frames_stack.length-1);t[1].$ftrace=r(n,"line",_b_.None)}return!0},$B.trace_return=function(e){var t=$B.last($B.frames_stack),r=t[1].$f_trace,n=$B._frame.$factory($B.frames_stack,$B.frames_stack.length-1);if(t[0]==$B.tracefunc.$current_frame_id)return _b_.None;r(n,"return",e)},$B.set_cm_in_generator=function(e){void 0!==e&&$B.frames_stack.forEach((function(t){t[1].$cm_in_gen=t[1].$cm_in_gen||new Set,t[1].$cm_in_gen.add(e)}))},$B.leave_frame=function(e){if(0!=$B.frames_stack.length){e&&void 0!==e.value&&$B.tracefunc&&(void 0===$B.last($B.frames_stack)[1].$f_trace&&($B.last($B.frames_stack)[1].$f_trace=$B.tracefunc),$B.last($B.frames_stack)[1].$f_trace!==_b_.None&&$B.trace_return(e.value));var t=$B.frames_stack.pop();if(t[1].$current_exception=void 0,t[1].$close_generators)for(var r=0,n=t[1].$close_generators.length;r0&&$B.$profile.return(),0!=$B.frames_stack.length){var t=$B.frames_stack.pop();exit_ctx_managers_in_generators(t);for(var r=$B.frames_stack.length-1;r>=0;r--)$B.frames_stack[r][2]==t[2]&&($B.frames_stack[r][3]=t[3])}else console.log("empty stack")};var min_int=Math.pow(-2,53),max_int=Math.pow(2,53)-1;$B.is_safe_int=function(){for(var e=0;emax_int)return!1}return!0},$B.add=function(e,t){if("number"==typeof e.valueOf()&&"number"==typeof t.valueOf()){if("number"==typeof e&&"number"==typeof t){var r=e+t;return r<$B.max_int&&r>$B.min_int?r:r===1/0?_b_.float.$factory("inf"):r===-1/0?_b_.float.$factory("-inf"):isNaN(r)?_b_.float.$factory("nan"):$B.long_int.__add__($B.long_int.$factory(e),$B.long_int.$factory(t))}return new Number(e+t)}if("string"==typeof e&&"string"==typeof t)return e+t;try{var n=$B.$getattr(e.__class__||$B.get_class(e),"__add__")}catch(r){if(r.__class__===_b_.AttributeError)throw _b_.TypeError.$factory("unsupported operand type(s) for +: '"+$B.class_name(e)+"' and '"+$B.class_name(t)+"'");throw r}var o=$B.$call(n)(e,t);return o===_b_.NotImplemented?$B.rich_op("add",e,t):o},$B.div=function(e,t){var r=e/t;return e>min_int&&emin_int&&tmin_int&&rmin_int&&emin_int&&tmin_int&&emin_int&&tmin_int&&rmin_int&&emin_int&&tmin_int&&r0?e:-e}return $B.long_int.__mul__($B.long_int.$factory(e),$B.long_int.$factory(t))},$B.sub=function(e,t){var r="number"!=typeof e||"number"!=typeof t?new Number(e-t):e-t;if(e>min_int&&emin_int&&tmin_int&&r=t:"number"==typeof e&&"number"!=typeof t?!t.pos:"number"!=typeof e&&"number"==typeof t?!0===e.pos:$B.long_int.__ge__(e,t)},$B.gt=function(e,t){return"number"==typeof e&&"number"==typeof t?e>t:"number"==typeof e&&"number"!=typeof t?!t.pos:"number"!=typeof e&&"number"==typeof t?!0===e.pos:$B.long_int.__gt__(e,t)};var reversed_op={__lt__:"__gt__",__le__:"__ge__",__gt__:"__lt__",__ge__:"__le__"},method2comp={__lt__:"<",__le__:"<=",__gt__:">",__ge__:">="};$B.rich_comp=function(e,t,r){var n,o,a=t.valueOf(),s=r.valueOf();if("number"==typeof a&&"number"==typeof s&&void 0===t.__class__&&void 0===r.__class__)switch(e){case"__eq__":return a==s;case"__ne__":return a!=s;case"__le__":return a<=s;case"__lt__":return a=s;case"__gt__":return a>s}if(t.$is_class||t.$factory){if("__eq__"==e)return t===r;if("__ne__"==e)return!(t===r);throw _b_.TypeError.$factory("'"+method2comp[e]+"' not supported between instances of '"+$B.class_name(t)+"' and '"+$B.class_name(r)+"'")}if(t.__class__&&r.__class__&&r.__class__.__mro__.indexOf(t.__class__)>-1){o=reversed_op[e]||e;$B.$getattr(r,o);if((n=$B.$call($B.$getattr(r,o))(t))!==_b_.NotImplemented)return n}if((n=$B.$call($B.$getattr(t,e))(r))!==_b_.NotImplemented)return n;if(o=reversed_op[e]||e,(n=$B.$call($B.$getattr(r,o))(t))!==_b_.NotImplemented)return n;if("__eq__"==e)return _b_.False;if("__ne__"==e)return _b_.True;throw _b_.TypeError.$factory("'"+method2comp[e]+"' not supported between instances of '"+$B.class_name(t)+"' and '"+$B.class_name(r)+"'")};var opname2opsign={sub:"-",xor:"^",mul:"*"};$B.rich_op=function(e,t,r){var n,o,a=t.__class__||$B.get_class(t);if(a===(r.__class__||$B.get_class(r))){if(a===_b_.int)return _b_.int["__"+e+"__"](t,r);try{n=$B.$call($B.$getattr(t,"__"+e+"__"))}catch(r){if(r.__class__===_b_.AttributeError){var s=$B.class_name(t);throw _b_.TypeError.$factory("unsupported operand type(s) for "+opname2opsign[e]+" : '"+s+"' and '"+s+"'")}throw r}return n(r)}try{n=$B.$call($B.$getattr(t,"__"+e+"__"))}catch(n){if(n.__class__!==_b_.AttributeError)throw n;if((o=$B.$call($B.$getattr(r,"__r"+e+"__"))(t))!==_b_.NotImplemented)return o;throw _b_.TypeError.$factory("'"+(opname2opsign[e]||e)+"' not supported between instances of '"+$B.class_name(t)+"' and '"+$B.class_name(r)+"'")}if((o=n(r))===_b_.NotImplemented){if((o=$B.$call($B.$getattr(r,"__r"+e+"__"))(t))!==_b_.NotImplemented)return o;throw _b_.TypeError.$factory("'"+(opname2opsign[e]||e)+"' not supported between instances of '"+$B.class_name(t)+"' and '"+$B.class_name(r)+"'")}return o},$B.is_none=function(e){return null==e||e==_b_.None};var repr_stack=new Set;$B.repr={enter:function(e){if(repr_stack.has(e))return!0;repr_stack.add(e)},leave:function(e){repr_stack.delete(e)}}}(__BRYTHON__),function($B){var _b_=$B.builtins;_b_.__debug__=!1,$B.$comps={">":"gt",">=":"ge","<":"lt","<=":"le"},$B.$inv_comps={">":"lt",">=":"le","<":"gt","<=":"ge"};var check_nb_args=$B.check_nb_args=function(e,t,r){var n=r.length,o=r[n-1];if(o&&"kw"==o.$nat){var a=o.kw;Array.isArray(a)&&a[1]&&a[1].__class__===_b_.dict&&0==Object.keys(a[1].$string_dict).length&&n--}if(n!=t)throw 0==t?_b_.TypeError.$factory(e+"() takes no argument ("+n+" given)"):_b_.TypeError.$factory(e+"() takes exactly "+t+" argument"+(t<2?"":"s")+" ("+n+" given)")},check_no_kw=$B.check_no_kw=function(e,t,r){if(void 0===t&&console.log("x undef",e,t,r),t.$nat&&t.kw&&t.kw[0]&&t.kw[0].length>0||void 0!==r&&r.$nat)throw _b_.TypeError.$factory(e+"() takes no keyword arguments")},NoneType={$factory:function(){return None},$infos:{__name__:"NoneType",__module__:"builtins"},__bool__:function(e){return False},__class__:_b_.type,__hash__:function(e){return 0},__mro__:[_b_.object],__repr__:function(e){return"None"},__str__:function(e){return"None"},$is_class:!0,__setattr__:function(e,t){return no_set_attr(NoneType,t)}},None={__class__:NoneType};for(var $op in $B.$comps){var key=$B.$comps[$op];switch(key){case"ge":case"gt":case"le":case"lt":NoneType["__"+key+"__"]=function(e){return _b_.NotImplemented}}}for(var $func in None)"function"==typeof None[$func]&&(None[$func].__str__=function(e){return function(){return""}}($func));function abs(e){if(check_nb_args("abs",1,arguments),check_no_kw("abs",e),isinstance(e,_b_.int))return e.__class__===$B.long_int?{__class__:$B.long_int,value:e.value,pos:!0}:_b_.int.$factory(Math.abs(e));if(isinstance(e,_b_.float))return _b_.float.$factory(Math.abs(_b_.float.numerator(e)));var t=e.__class__||$B.get_class(e);try{var r=$B.$getattr(t,"__abs__")}catch(t){if(t.__class__===_b_.AttributeError)throw _b_.TypeError.$factory("Bad operand type for abs(): '"+$B.class_name(e)+"'");throw t}return $B.$call(r)(e)}function all(e){check_nb_args("all",1,arguments),check_no_kw("all",e);for(var t=iter(e);;)try{var r=next(t);if(!$B.$bool(r))return!1}catch(e){return!0}}function any(e){check_nb_args("any",1,arguments),check_no_kw("any",e);for(var t=iter(e);;)try{var r=next(t);if($B.$bool(r))return!0}catch(e){return!1}}function ascii(e){check_nb_args("ascii",1,arguments),check_no_kw("ascii",e);for(var t,r=repr(e),n="",o=0;o=0?r+o.toString(t):"-"+r+(-o).toString(t)}function bin_hex_oct(e,t){if(isinstance(t,_b_.int))return $builtin_base_convert_helper(t,e);try{var r=t.__class__||$B.get_class(t),n=$B.$getattr(r,"__index__")}catch(e){if(e.__class__===_b_.AttributeError)throw _b_.TypeError.$factory("'"+$B.class_name(t)+"' object cannot be interpreted as an integer");throw e}return $builtin_base_convert_helper($B.$call(n)(t),e)}function bin(e){return check_nb_args("bin",1,arguments),check_no_kw("bin",e),bin_hex_oct(2,e)}function breakpoint(){$B.$import("sys",[]);var e={},t=$B.$getattr($B.imported.sys,"breakpointhook",e);if(t===e)throw _b_.RuntimeError.$factory("lost sys.breakpointhook");return $B.$call(t).apply(null,arguments)}function callable(e){return check_nb_args("callable",1,arguments),check_no_kw("callable",e),hasattr(e,"__call__")}function chr(e){if(check_nb_args("chr",1,arguments),check_no_kw("chr",e),e<0||e>1114111)throw _b_.ValueError.$factory("Outside valid range");if(e>=65536&&e<=1114111){var t=e-65536;return _b_.str.$surrogate.$factory(String.fromCodePoint(55296|t>>10)+String.fromCodePoint(56320|1023&t))}return String.fromCodePoint(e)}$B.set_func_names(NoneType,"builtins");var classmethod=$B.make_class("classmethod",(function(e){check_nb_args("classmethod",1,arguments),check_no_kw("classmethod",e);var t=function(){return e.apply(null,arguments)};if(t.__class__=$B.method,e.$attrs)for(var r in e.$attrs)t[r]=e.$attrs[r];return t.$infos={__func__:e,__name__:e.$infos.__name__},t.__get__=function(r,n){var o=function(){return t(n,...arguments)};return o.__class__=$B.method,o.$infos={__self__:n,__func__:t,__name__:e.$infos.__name__,__qualname__:n.$infos.__name__+"."+e.$infos.__name__},o},t.__get__.__class__=$B.method_wrapper,t.__get__.$infos=e.$infos,t}));$B.set_func_names(classmethod,"builtins");var code=$B.code=$B.make_class("code");function compile(){var e=$B.args("compile",6,{source:null,filename:null,mode:null,flags:null,dont_inherit:null,optimize:null,_feature_version:null},["source","filename","mode","flags","dont_inherit","optimize","_feature_version"],arguments,{flags:0,dont_inherit:!1,optimize:-1,_feature_version:0},null,null),t="$exec_"+$B.UUID();$B.clear_ns(t),e.__class__=code,e.co_flags=e.flags,e.name="";var r="single"==e.mode&&512&e.flags;if(r&&!e.source.endsWith("\n")){var n=e.source.split("\n");if($B.last(n).startsWith(" "))throw _b_.SyntaxError.$factory("unexpected EOF while parsing")}return $B.py2js({src:e.source,filename:e.filename},t,t),e}code.__repr__=code.__str__=function(e){return""},code.__getattribute__=function(e,t){return e[t]},$B.set_func_names(code,"builtins");var __debug__=$B.debug>0;function delattr(e,t){if(check_no_kw("delattr",e,t),check_nb_args("delattr",2,arguments),"string"!=typeof t)throw _b_.TypeError.$factory("attribute name must be string, not '"+$B.class_name(t)+"'");return $B.$getattr(e,"__delattr__")(t)}function dir(e){if(void 0===e){var t=$B.last($B.frames_stack);for(var r in locals_obj=t[1],o=_b_.list.$factory(),a=0,locals_obj)"$"==r.charAt(0)&&"$"!=r.charAt(1)||(o[a++]=r);return _b_.list.sort(o),o}check_nb_args("dir",1,arguments),check_no_kw("dir",e);e.__class__||$B.get_class(e);if(e.$is_class){var n=$B.$getattr(e.__class__,"__dir__");return $B.$call(n)(e)}try{var o=$B.$call($B.$getattr(e,"__dir__"))();return o=_b_.list.$factory(o)}catch(e){}o=[];var a=0;for(var r in e)"$"!==r.charAt(0)&&"__class__"!==r&&void 0!==e[r]&&(o[a++]=r);return o.sort(),o}function divmod(e,t){check_no_kw("divmod",e,t),check_nb_args("divmod",2,arguments);var r=e.__class__||$B.get_class(e),n=$B.$getattr(r,"__divmod__",_b_.None);return n!==_b_.None?n(e,t):_b_.tuple.$factory([$B.$getattr(r,"__floordiv__")(e,t),$B.$getattr(r,"__mod__")(e,t)])}$B.$delete=function(e,t){function r(e){e.__class__===$B.generator&&e.return()}var n=!1,o=$B.last($B.frames_stack);if(t?o[2]!=o[0]&&void 0!==o[3][e]&&(n=!0,r(o[3][e]),delete o[3][e]):void 0!==o[1][e]&&(n=!0,r(o[1][e]),delete o[1][e]),!n)throw _b_.NameError.$factory(e)};var enumerate=$B.make_class("enumerate",(function(){var e=$B.args("enumerate",2,{iterable:null,start:null},["iterable","start"],arguments,{start:0},null,null),t=iter(e.iterable),r=e.start;return{__class__:enumerate,__name__:"enumerate iterator",counter:r-1,iter:t,start:r}}));function $$eval(src,_globals,_locals){var $=$B.args("eval",4,{src:null,globals:null,locals:null,mode:null},["src","globals","locals","mode"],arguments,{globals:_b_.None,locals:_b_.None,mode:"eval"},null,null),src=$.src,_globals=$.globals,_locals=$.locals,mode=$.mode;$.src.mode&&"single"==$.src.mode&&["",""].indexOf($.src.filename)>-1&&_b_.print(">",$.src.source.trim());var current_frame=$B.frames_stack[$B.frames_stack.length-1];if(void 0!==current_frame)var current_locals_id=current_frame[0].replace(/\./g,"_"),current_globals_id=current_frame[2].replace(/\./g,"_");var stack_len=$B.frames_stack.length;if(src.__class__===code)mode=src.mode,src=src.source;else if("string"!=typeof src)throw _b_.TypeError.$factory("eval() arg 1 must be a string, bytes or code object");var globals_id="$exec_"+$B.UUID(),globals_name=globals_id,locals_id="$exec_"+$B.UUID(),parent_scope;if(_globals===_b_.None){current_locals_id==current_globals_id&&(locals_id=globals_id);var local_scope={module:globals_id,id:locals_id,binding:{},bindings:{}};for(var attr in current_frame[1])local_scope.binding[attr]=!0,local_scope.bindings[attr]=!0;var global_scope={module:globals_id,id:globals_id,binding:{},bindings:{}};for(var attr in current_frame[3])global_scope.binding[attr]=!0,global_scope.bindings[attr]=!0;local_scope.parent_block=global_scope,global_scope.parent_block=$B.builtins_scope,parent_scope=local_scope,eval("$locals_"+parent_scope.id+" = current_frame[1]")}else{if(_globals.__class__!=_b_.dict)throw _b_.TypeError.$factory("exec() globals must be a dict, not "+$B.class_name(_globals));if(_globals.globals_id&&(globals_id=globals_name=_globals.globals_id),_globals.globals_id=globals_id,_locals===_globals||_locals===_b_.None)locals_id=globals_id,parent_scope=$B.builtins_scope;else{var grandparent_scope={id:globals_id,parent_block:$B.builtins_scope,binding:{}};for(var attr in parent_scope={id:locals_id,parent_block:grandparent_scope,binding:{}},_globals.$string_dict)grandparent_scope.binding[$B.to_alias(attr)]=!0;for(var attr in _locals.$string_dict)parent_scope.binding[$B.to_alias(attr)]=!0}}if($B.$py_module_path[globals_id]=$B.$py_module_path[current_globals_id],eval("var $locals_"+globals_id+" = {}\nvar $locals_"+locals_id+" = {}"),_globals===_b_.None){var gobj=current_frame[3],ex="var $locals_"+globals_id+" = gobj;",obj={};for(var attr in eval(ex),gobj)attr.startsWith("$")&&!attr.startsWith("$$")||(obj[attr]=gobj[attr]);eval("$locals_"+globals_id+" = obj")}else{var globals_is_dict=!1;if(_globals.$jsobj)var items=_globals.$jsobj;else{var items=_b_.dict.$to_obj(_globals);_globals.$jsobj=items,globals_is_dict=!0}for(var item in eval("$locals_"+globals_id+" = _globals.$jsobj"),items){var item1=$B.to_alias(item);try{eval("$locals_"+globals_id+'["'+item1+'"] = items.'+item)}catch(e){console.log(e),console.log("error setting",item);break}}}if(_globals.$is_namespace=!0,_locals===_b_.None)if(_globals!==_b_.None)eval("var $locals_"+locals_id+" = $locals_"+globals_id);else{var lobj=current_frame[1],ex="",obj={};for(var attr in current_frame[1])attr.startsWith("$")&&!attr.startsWith("$$")||(obj[attr]=lobj[attr]);eval("$locals_"+locals_id+" = obj")}else{var locals_is_dict=!1;if(_locals.$jsobj)var items=_locals.$jsobj;else{locals_id_dict=!0;var items=_b_.dict.$to_obj(_locals);_locals.$jsobj=items}for(var item in items){var item1=$B.to_alias(item);try{eval("$locals_"+locals_id+'["'+item1+'"] = items.'+item)}catch(e){console.log(e),console.log("error setting",item);break}}eval("$locals_"+locals_id+".$exec_locals = true")}_locals.$is_namespace=!0,_globals===_b_.None&&_locals===_b_.None&¤t_frame[0]==current_frame[2]||eval("$locals_"+locals_id+".$src = src");var root=$B.py2js(src,globals_id,locals_id,parent_scope),js,gns,lns;if(_globals!==_b_.None&&_locals==_b_.None)for(var attr in _globals.$string_dict)root.binding[attr]=!0;try{var try_node=root.children[root.children.length-2],instr=try_node.children[try_node.children.length-2],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",1,1,src)}if("eval"!=mode){var last=$B.last(root.children),js=last.to_js();-1==["node_js"].indexOf(last.C.type)&&(last.to_js=function(){for(;js.endsWith("\n");)js=js.substr(0,js.length-1);for(;js.endsWith(";");)js=js.substr(0,js.length-1);return"return ("+js+")"}),js=root.to_js();var locals_obj=eval("$locals_"+locals_id),globals_obj=eval("$locals_"+globals_id);if(_globals===_b_.None)var res=new Function("$locals_"+globals_id,"$locals_"+locals_id,js)(globals_obj,locals_obj);else{current_globals_obj=current_frame[3],current_locals_obj=current_frame[1];var res=new Function("$locals_"+globals_id,"$locals_"+locals_id,"$locals_"+current_globals_id,"$locals_"+current_locals_id,js)(globals_obj,locals_obj,current_globals_obj,current_locals_obj)}$.src.mode&&"single"==$.src.mode&&""==$.src.filename&&res!==_b_.None&&void 0!==res&&_b_.print(_b_.repr(res))}else{js=root.to_js();var res=eval(js)}if(""==$.src.filename&&"single"==$.src.mode&&void 0!==res&&res!==_b_.None&&_b_.print(res),gns=eval("$locals_"+globals_id),$B.frames_stack[$B.frames_stack.length-1][2]==globals_id&&(gns=$B.frames_stack[$B.frames_stack.length-1][3]),_locals!==_b_.None)for(var attr in lns=eval("$locals_"+locals_id),lns){var attr1=$B.from_alias(attr);"$"!=attr1.charAt(0)&&(_locals.$jsobj?_locals.$jsobj[attr]=lns[attr]:_b_.dict.$setitem(_locals,attr1,lns[attr]))}else for(var attr in lns)"$src"!==attr&&(current_frame[1][attr]=lns[attr]);if(_globals!==_b_.None){if(globals_is_dict){var jsobj=_globals.$jsobj;delete _globals.$jsobj}for(var attr in gns)attr1=$B.from_alias(attr),"$"!=attr1.charAt(0)&&(globals_is_dict?_b_.dict.$setitem(_globals,attr,gns[attr]):_globals.$jsobj[attr1]=gns[attr]);for(var attr in _globals.$string_dict)attr.startsWith("$")&&!attr.startsWith("$$")&&delete _globals.$string_dict[attr]}else for(var attr in gns)"$src"!==attr&&(current_frame[3][attr]=gns[attr]);return void 0===res?_b_.None:res}catch(e){if(e.src=src,e.module=globals_id,void 0===e.$py_error)throw $B.exception(e);throw e}finally{$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)}}function exec(e,t,r){var n=$B.args("exec",3,{src:null,globals:null,locals:null},["src","globals","locals"],arguments,{globals:_b_.None,locals:_b_.None},null,null);return $$eval(e=n.src,t=n.globals,r=n.locals,"exec")||_b_.None}function exit(){throw _b_.SystemExit}enumerate.__iter__=function(e){return e.counter=e.start-1,e},enumerate.__next__=function(e){return e.counter++,$B.fast_tuple([e.counter,next(e.iter)])},$B.set_func_names(enumerate,"builtins"),$B.from_alias=function(e){return"$$"==e.substr(0,2)&&$B.aliased_names[e.substr(2)]?e.substr(2):e},$B.to_alias=function(e){return $B.aliased_names[e]?"$$"+e:e},$$eval.$is_func=!0,exec.$is_func=!0,exit.__repr__=exit.__str__=function(){return"Use exit() or Ctrl-Z plus Return to exit"};var filter=$B.make_class("filter",(function(e,t){return check_no_kw("filter",e,t),check_nb_args("filter",2,arguments),t=iter(t),e===_b_.None&&(e=$B.$bool),{__class__:filter,func:e,iterable:t}}));function format(e,t){var r=$B.args("format",2,{value:null,format_spec:null},["value","format_spec"],arguments,{format_spec:""},null,null),n=e.__class__||$B.get_class(e);try{var o=$B.$getattr(n,"__format__")}catch(t){if(t.__class__===_b_.AttributeError)throw _b_.NotImplementedError("__format__ is not implemented for object '"+_b_.str.$factory(e)+"'");throw t}return $B.$call(o)(e,r.format_spec)}function attr_error(e,t){var r="bad operand type for unary #: '"+t+"'";switch(e){case"__neg__":throw _b_.TypeError.$factory(r.replace("#","-"));case"__pos__":throw _b_.TypeError.$factory(r.replace("#","+"));case"__invert__":throw _b_.TypeError.$factory(r.replace("#","~"));case"__call__":throw _b_.TypeError.$factory("'"+t+"' object is not callable");default:for(;"$"==e.charAt(0);)e=e.substr(1);throw _b_.AttributeError.$factory("'"+t+"' object has no attribute '"+e+"'")}}function getattr(){var e={},t=$B.args("getattr",3,{obj:null,attr:null,_default:null},["obj","attr","_default"],arguments,{_default:e},null,null);return $B.$getattr(t.obj,t.attr,t._default===e?void 0:t._default)}function in_mro(e,t){if(void 0===e)return!1;if(e.hasOwnProperty(t))return e[t];for(var r=e.__mro__,n=0,o=r.length;n-1)return!1}else if(e.contructor===Number&&Number.isFinite(e)){if(t==_b_.float)return!0}else if("number"==typeof e&&Number.isFinite(e)&&Number.isFinite(e)&&t==_b_.int)return!0;n=$B.get_class(e)}if(void 0===n)return!1;function o(e,t){return e===t||(t===_b_.str&&e===$B.StringSubclass||(t===_b_.int&&e===$B.IntSubclass||void 0))}if(o(n,t))return!0;var a=n.__mro__;for(r=0;r-1))return!0;var n=$B.$getattr(t.__class__||$B.get_class(t),"__subclasscheck__",_b_.None);return n!=_b_.None&&n(t,e)}help.__repr__=help.__str__=function(){return"Type help() for interactive help, or help(object) for help about object."};var iterator_class=$B.make_class("iterator",(function(e,t){return{__class__:iterator_class,getitem:e,len:t,counter:-1}}));function iter(){var e=$B.args("iter",1,{obj:null},["obj"],arguments,{},"args","kw");if(e.args.length>0)var t=e.args[0];return $B.$iter(e.obj,t)}function len(e){check_no_kw("len",e),check_nb_args("len",1,arguments);var t=e.__class__||$B.get_class(e);try{var r=$B.$getattr(t,"__len__")}catch(t){throw _b_.TypeError.$factory("object of type '"+$B.class_name(e)+"' has no len()")}return $B.$call(r)(e)}function locals(){check_nb_args("locals",0,arguments);var e=$B.obj_dict($B.last($B.frames_stack)[1]);return e.$is_namespace=!0,delete e.$jsobj.__annotations__,e}iterator_class.__next__=function(e){if(e.counter++,null!==e.len&&e.counter==e.len)throw _b_.StopIteration.$factory("");try{return e.getitem(e.counter)}catch(e){throw _b_.StopIteration.$factory("")}},callable_iterator=$B.make_class("callable_iterator",(function(e,t){return{__class__:callable_iterator,func:e,sentinel:t}})),callable_iterator.__iter__=function(e){return e},callable_iterator.__next__=function(e){var t=e.func();if($B.rich_comp("__eq__",t,e.sentinel))throw _b_.StopIteration.$factory();return t},$B.$iter=function(e,t){if(void 0===t){var r=e.__class__||$B.get_class(e);try{var n=$B.$call($B.$getattr(r,"__iter__"))}catch(t){if(t.__class__===_b_.AttributeError)try{var o=$B.$call($B.$getattr(r,"__getitem__"));len(e);return iterator_class.$factory((function(t){return o(e,t)}),len)}catch(t){throw _b_.TypeError.$factory("'"+$B.class_name(e)+"' object is not iterable")}throw t}var a=$B.$call(n)(e);try{$B.$getattr(a,"__next__")}catch(e){if(isinstance(e,_b_.AttributeError))throw _b_.TypeError.$factory("iter() returned non-iterator of type '"+$B.class_name(a)+"'")}return a}return callable_iterator.$factory(e,t)};var map=$B.make_class("map",(function(){var e=$B.args("map",2,{func:null,it1:null},["func","it1"],arguments,{},"args",null),t=$B.$call(e.func),r=[$B.$iter(e.it1)];e.args.forEach((function(e){r.push($B.$iter(e))}));var n={__class__:map,args:r,func:t};return n}));function $extreme(e,t){var r="min";if("__gt__"===t&&(r="max"),0==e.length)throw _b_.TypeError.$factory(r+" expected 1 arguments, got 0");var n=e[e.length-1],o=e.length,a=!1,s=!1;if("kw"==n.$nat)for(var i in o--,n=n.kw)switch(i){case"key":s=n[i];break;case"$$default":var _=n[i];a=!0;break;default:throw _b_.TypeError.$factory("'"+i+"' is an invalid keyword argument for this function")}if(s||(s=function(e){return e}),0==o)throw _b_.TypeError.$factory(r+" expected 1 argument, got 0");if(1!=o){if(a)throw _b_.TypeError.$factory("Cannot specify a default for "+r+"() with multiple positional arguments");u=null;for(var l=0;l-1){if(t>e.obj.source.length-1)throw _b_.KeyError.$factory(t);return e.obj.source[t]}return e.obj.source[t]}n=e.obj.__class__.__getitem__(e.obj,t);if(t.__class__===_b_.slice)return memoryview.$factory(n)},memoryview.__len__=function(e){return len(e.obj)/e.itemsize},memoryview.cast=function(e,t){switch(t){case"B":return memoryview.$factory(e.obj);case"I":var r=memoryview.$factory(e.obj),n=len(e.obj);if(r.itemsize=4,r.format="I",n%4!=0)throw _b_.TypeError.$factory("memoryview: length is not a multiple of itemsize");return r}},memoryview.hex=function(e){var t="";return _b_.bytes.$factory(e).source.forEach((function(e){t+=e.toString(16)})),t},memoryview.tobytes=function(e){return _b_.bytes.$factory(e.obj)},memoryview.tolist=function(e){if(1==e.itemsize)return _b_.list.$factory(_b_.bytes.$factory(e.obj));if(4==e.itemsize&&"I"==e.format){for(var t=[],r=0;r-1)m=!0;else for(a=0;a<_.__mro__.length;a++){if(h(_.__mro__[a]).indexOf(n)>-1){m=!0;break}}if(!m)throw _b_.AttributeError.$factory("'"+_.$infos.__name__+"' object has no attribute '"+n+"'")}return $?$(e,t,r):void 0===e.__dict__?e[t]=r:_b_.dict.$setitem(e.__dict__,n,r),None};var staticmethod=$B.make_class("staticmethod",(function(e){var t={$infos:e.$infos,__get__:function(){return e}};return t.__get__.__class__=$B.method_wrapper,t.__get__.$infos=e.$infos,t}));function sum(e,t){var r=$B.args("sum",2,{iterable:null,start:null},["iterable","start"],arguments,{start:0},null,null);e=r.iterable,t=r.start;if(_b_.isinstance(t,[_b_.str,_b_.bytes]))throw _b_.TypeError.$factory("TypeError: sum() can't sum bytes [use b''.join(seq) instead]");var n=t;for(e=iter(e);;)try{var o=next(e);n=$B.$getattr(n,"__add__")(o)}catch(e){if(e.__class__===_b_.StopIteration)break;throw e}return n}$B.set_func_names(staticmethod,"builtins"),$B.missing_super2=function(e){return e.$missing=!0,e};var $$super=$B.make_class("super",(function(e,t){if(void 0===e&&void 0===t){var r=$B.last($B.frames_stack),n=$B.imported._sys.Getframe();if(!n.f_code||!n.f_code.co_varnames)throw _b_.RuntimeError.$factory("super(): no arguments");if(void 0===(e=r[1].__class__))throw _b_.RuntimeError.$factory("super(): no arguments");t=r[1][n.f_code.co_varnames[0]]}return Array.isArray(t)&&(t=t[0]),{__class__:$$super,__thisclass__:e,__self_class__:t}}));function vars(){var e={},t=$B.args("vars",1,{obj:null},["obj"],arguments,{obj:e},null,null);if(t.obj===e)return _b_.locals();try{return $B.$getattr(t.obj,"__dict__")}catch(e){if(e.__class__===_b_.AttributeError)throw _b_.TypeError.$factory("vars() argument must have __dict__ attribute");throw e}}$$super.__get__=function(e,t,r){return $$super.$factory(e.__thisclass__,t)},$$super.__getattribute__=function(e,t){var r=e.__thisclass__.__mro__;if(e.__thisclass__.$is_js_class&&"__init__"==t)return function(){r[0].$js_func.call(e.__self_class__,...arguments)};var n=e.__self_class__;if(void 0!==n){n.$is_class||(n=n.__class__||$B.get_class(n));for(var o=[n].concat(n.__mro__),a=0;a";return void 0!==e.__self_class__?t+=", <"+e.__self_class__.__class__.$infos.__name__+" object>":t+=", NULL",t+">"},$B.set_func_names($$super,"builtins");var $Reader=$B.make_class("Reader");function make_content(e){e.$binary&&void 0===e.$bytes?e.$bytes=_b_.str.encode(e.$string,e.encoding):e.$binary||void 0!==e.$string||(e.$string=_b_.bytes.decode(e.$bytes,e.encoding))}function make_lines(e){if(void 0===e.$lines)if(make_content(e),e.$binary){console.log("make lines, binary");for(var t=[],r=e.$bytes.source;;){var n=r.indexOf(10);if(-1==n){t.push({__class__:_b_.bytes,source:r});break}t.push({__class__:_b_.bytes,source:r.slice(0,n+1)}),r=r.slice(n+1)}e.$lines=t}else e.$lines=e.$string.split("\n")}$Reader.__enter__=function(e){return e},$Reader.__exit__=function(e){return!1},$Reader.__iter__=function(e){return iter($Reader.readlines(e))},$Reader.__len__=function(e){return e.lines.length},$Reader.close=function(e){e.closed=!0},$Reader.flush=function(e){return None},$Reader.read=function(){var e=$B.args("read",2,{self:null,size:null},["self","size"],arguments,{size:-1},null,null),t=e.self,r=$B.$GetInt(e.size);if(!0===t.closed)throw _b_.ValueError.$factory("I/O operation on closed file");make_content(t);var n=t.$binary?t.$bytes.source.length:t.$string.length;return r<0&&(r=n-t.$counter),t.$binary?res=_b_.bytes.$factory(t.$bytes.source.slice(t.$counter,t.$counter+r)):res=t.$string.substr(t.$counter,r),t.$counter+=r,res},$Reader.readable=function(e){return!0},$Reader.readline=function(e,t){var r=$B.args("readline",2,{self:null,size:null},["self","size"],arguments,{size:-1},null,null);e=r.self,t=$B.$GetInt(r.size);if(e.$lc=void 0===e.$lc?-1:e.$lc,!0===e.closed)throw _b_.ValueError.$factory("I/O operation on closed file");if(make_content(e),e.$binary){var n;if(-1==(n=e.$bytes.source.indexOf(10,e.$counter)))return _b_.bytes.$factory();var o={__class__:_b_.bytes,source:e.$bytes.source.slice(e.$counter,n+1)};return e.$counter=n+1,o}if(-1==(n=e.$string.indexOf("\n",e.$counter)))return"";o=e.$string.substring(e.$counter,n+1);return e.$counter=n+1,e.$lc+=1,o},$Reader.readlines=function(){var e=$B.args("readlines",2,{self:null,hint:null},["self","hint"],arguments,{hint:-1},null,null),t=e.self,r=$B.$GetInt(e.hint),n=0;if(!0===t.closed)throw _b_.ValueError.$factory("I/O operation on closed file");if(t.$lc=void 0===t.$lc?-1:t.$lc,make_lines(t),r<0)var o=t.$lines.slice(t.$lc+1);else for(o=[];t.$lc0)var mode=args[0];if(args.length>1)var encoding=args[1];if(mode.search("w")>-1)throw _b_.IOError.$factory("Browsers cannot write on disk");if(-1==["r","rb"].indexOf(mode))throw _b_.ValueError.$factory("Invalid mode '"+mode+"'");if(isinstance(file,_b_.str)){var is_binary=mode.search("b")>-1;if($B.file_cache.hasOwnProperty($ns.file))$string=$B.file_cache[$ns.file];else if($B.files&&$B.files.hasOwnProperty($ns.file)){$res=atob($B.files[$ns.file].content);var source=[];for(const e of $res)source.push(e.charCodeAt(0));$bytes=_b_.bytes.$factory(),$bytes.source=source}else{if("file"==$B.protocol)throw _b_.FileNotFoundError.$factory("cannot use 'open()' with protocol 'file'");if(is_binary)throw _b_.IOError.$factory("open() in binary mode is not supported");var req=new XMLHttpRequest;req.onreadystatechange=function(){try{var e=this.status;$res=404==e?_b_.FileNotFoundError.$factory(file):200!=e?_b_.IOError.$factory("Could not open file "+file+" : status "+e):this.responseText}catch(e){$res=_b_.IOError.$factory("Could not open file "+file+" : error "+e)}};var fake_qs=$B.$options.cache?"":"?foo="+(new Date).getTime();if(req.open("GET",file+fake_qs,!1),req.overrideMimeType("text/plain; charset=utf-8"),req.send(),$res.constructor===Error)throw $res;$string=$res}if(void 0===$string&&void 0===$bytes)throw _b_.FileNotFoundError.$factory($ns.file);var res={$binary:is_binary,$string:$string,$bytes:$bytes,$counter:0,closed:False,encoding:encoding,mode:mode,name:file};return res.__class__=is_binary?$BufferedReader:$TextIOWrapper,res}throw _b_.TypeError.$factory("invalid argument for open(): "+_b_.str.$factory(file))}$TextIOWrapper.__mro__=[$Reader,_b_.object],$B.set_func_names($TextIOWrapper,"builtins"),$B.Reader=$Reader,$B.TextIOWrapper=$TextIOWrapper,$B.BufferedReader=$BufferedReader;var zip=$B.make_class("zip",(function(){var e={__class__:zip,items:[]};if(0==arguments.length)return e;for(var t=$B.args("zip",0,{},[],arguments,{},"args","kw"),r=t.args,n=[],o=0;o"}}($func));$B.set_func_names(ellipsis);var FunctionCode=$B.make_class("function code"),FunctionGlobals=$B.make_class("function globals");$B.Function={__class__:_b_.type,__code__:{__class__:FunctionCode,__name__:"function code"},__globals__:{__class__:FunctionGlobals,__name__:"function globals"},__mro__:[_b_.object],$infos:{__name__:"function",__module__:"builtins"},$is_class:!0},$B.Function.__delattr__=function(e,t){if("__dict__"==t)throw _b_.TypeError.$factory("can't deleted function __dict__")},$B.Function.__dir__=function(e){var t=e.$infos||{},r=e.$attrs||{};return Object.keys(t).concat(Object.keys(r))},$B.Function.__eq__=function(e,t){return e===t},$B.Function.__get__=function(e,t){if(t===_b_.None)return e;var r=function(){return e(t,...arguments)};return r.__class__=$B.method,void 0===e.$infos&&(console.log("no $infos",e),console.log($B.last($B.frames_stack))),r.$infos={__name__:e.$infos.__name__,__qualname__:$B.class_name(t)+"."+e.$infos.__name__,__self__:t,__func__:e},r},$B.Function.__getattribute__=function(e,t){if(!e.$infos||void 0===e.$infos[t]){if(e.$infos&&e.$infos.__dict__&&void 0!==e.$infos.__dict__.$string_dict[t])return e.$infos.__dict__.$string_dict[t][0];if("__closure__"==t){var r=e.$infos.__code__.co_freevars;if(0==r.length)return None;for(var n=[],o=0;o":""},$B.Function.__mro__=[_b_.object],$B.Function.__setattr__=function(e,t,r){if("__closure__"==t)throw _b_.AttributeError.$factory("readonly attribute");if("__defaults__"==t){if(r===_b_.None)r=[];else if(!isinstance(r,_b_.tuple))throw _b_.TypeError.$factory("__defaults__ must be set to a tuple object");var n=e.$set_defaults;if(void 0===n)throw _b_.AttributeError.$factory("cannot set attribute "+t+" of "+_b_.str.$factory(e));if(!e.$infos||!e.$infos.__code__)throw _b_.AttributeError.$factory("cannot set attribute "+t+" of "+_b_.str.$factory(e));for(var o=e.$infos.__code__.co_argcount,a=e.$infos.__code__.co_varnames.slice(0,o),s={},i=r.length-1;i>=0;i--){var _=a.length-r.length+i;if(_<0)break;s[a[_]]=r[i]}var l=e.$infos.$class,c=n(s);return c.$set_defaults=n,l?(l[e.$infos.__name__]=c,c.$infos.$class=l,c.$infos.__defaults__=r):(e.$infos.$defaults=r,e.$infos.__defaults__=r),_b_.None}void 0!==e.$infos[t]?e.$infos[t]=r:(e.$attrs=e.$attrs||{},e.$attrs[t]=r)},$B.Function.$factory=function(){},$B.set_func_names($B.Function,"builtins"),_b_.__BRYTHON__=__BRYTHON__,$B.builtin_funcs=["abs","all","any","ascii","bin","breakpoint","callable","chr","compile","delattr","dir","divmod","eval","exec","exit","format","getattr","globals","hasattr","hash","help","hex","id","input","isinstance","issubclass","iter","len","locals","max","min","next","oct","open","ord","pow","print","quit","repr","round","setattr","sorted","sum","vars"];var builtin_function=$B.builtin_function=$B.make_class("builtin_function_or_method",(function(e){return e.__class__=builtin_function,e}));builtin_function.__getattribute__=$B.Function.__getattribute__,builtin_function.__reduce_ex__=builtin_function.__reduce__=function(e){return e.$infos.__name__},builtin_function.__repr__=builtin_function.__str__=function(e){return""},$B.set_func_names(builtin_function,"builtins");var method_wrapper=$B.make_class("method_wrapper");method_wrapper.__repr__=method_wrapper.__str__=function(e){return""},$B.set_func_names(method_wrapper,"builtins");var wrapper_descriptor=$B.wrapper_descriptor=$B.make_class("wrapper_descriptor");wrapper_descriptor.__getattribute__=$B.Function.__getattribute__,wrapper_descriptor.__repr__=wrapper_descriptor.__str__=function(e){return""},$B.set_func_names(wrapper_descriptor,"builtins"),$B.builtin_classes=["bool","bytearray","bytes","classmethod","complex","dict","enumerate","filter","float","frozenset","int","list","map","memoryview","object","property","range","reversed","set","slice","staticmethod","str","super","tuple","type","zip"];for(var other_builtins=["Ellipsis","False","None","True","__debug__","__import__","copyright","credits","license","NotImplemented"],builtin_names=$B.builtin_funcs.concat($B.builtin_classes).concat(other_builtins),i=0;i-1&&(_b_[name].__class__=builtin_function,_b_[name].$infos={__module__:"builtins",__name__:orig_name,__qualname__:orig_name})}catch(e){}}_b_.open=$url_open,_b_.print=$print,_b_.$$super=$$super,_b_.object.__init__.__class__=wrapper_descriptor,_b_.object.__new__.__class__=builtin_function}(__BRYTHON__),function($B){var bltns=$B.InjectBuiltins();eval(bltns),$B.del_exc=function(){$B.last($B.frames_stack)[1].$current_exception=void 0},$B.set_exc=function(e){var t=$B.last($B.frames_stack);void 0===t&&console.log("no frame",e),t[1].$current_exception=$B.exception(e)},$B.get_exc=function(){return $B.last($B.frames_stack)[1].$current_exception},$B.$raise=function(e){if(void 0===e){var t=$B.get_exc();if(void 0!==t)throw t;throw _b_.RuntimeError.$factory("No active exception to reraise")}if(isinstance(e,BaseException))throw e.__class__===_b_.StopIteration&&$B.last($B.frames_stack)[1].$is_generator&&(e=_b_.RuntimeError.$factory("generator raised StopIteration")),e;if(e.$is_class&&issubclass(e,BaseException)){if(e===_b_.StopIteration&&$B.last($B.frames_stack)[1].$is_generator)throw _b_.RuntimeError.$factory("generator raised StopIteration");throw $B.$call(e)()}throw _b_.TypeError.$factory("exceptions must derive from BaseException")},$B.$syntax_err_line=function(e,t,r,n,o){var a={},s=1;t="$"==t.charAt(0)?"":t;if(void 0===r)e.$line_info=o+","+t,e.args=$B.fast_tuple([$B.$getitem(e.args,0),$B.fast_tuple([t,o,0,0])]);else{for(var i={1:0},_=0,l=r.length;_0&&u--;e.offset=u,e.args=$B.fast_tuple([$B.$getitem(e.args,0),$B.fast_tuple([t,o,u,c])])}e.lineno=o,e.msg=e.args[0],e.filename=t},$B.$SyntaxError=function(e,t,r,n,o,a){void 0!==a&&void 0!==a.line_info&&(o=a.line_info);var s=_b_.SyntaxError.$factory(t);throw $B.$syntax_err_line(s,e,r,n,o),s},$B.$IndentationError=function(e,t,r,n,o,a){$B.frames_stack.push([e,{$line_info:o+","+e},e,{$src:r}]),void 0!==a&&void 0!==a.line_info&&(o=a.line_info);var s=_b_.IndentationError.$factory(t);throw $B.$syntax_err_line(s,e,r,n,o),s},$B.print_stack=function(e){e=e||$B.frames_stack;var t=[];return e.forEach((function(e){var r=e[1].$line_info;if(void 0!==r){var n=r.split(",");n[1].startsWith("$exec")&&(n[1]=""),t.push(n[1]+" line "+n[0]);var o=$B.file_cache[e[3].__file__];if(o){var a=o.split("\n")[parseInt(n[0])-1];t.push(" "+a.trim())}}})),console.log("print stack ok",t),t.join("\n")};var traceback=$B.traceback=$B.make_class("traceback",(function(e,t){$B.last($B.frames_stack);return void 0===t&&(t=e.$stack),{__class__:traceback,$stack:t,exc:e}}));traceback.__getattribute__=function(e,t){var r;if("tb_frame"===t||"tb_lineno"===t||"tb_lasti"===t||"tb_next"===t){0==e.$stack.length&&console.log("no stack",t);var n=e.$stack[0];r=e.exc.$line_infos[e.exc.$line_infos.length-e.$stack.length]}switch(t){case"tb_frame":return frame.$factory(e.$stack);case"tb_lineno":return void 0===r||n[0].startsWith($B.lambda_magic)?n[4]&&n[4].$infos&&n[4].$infos.__code__?n[4].$infos.__code__.co_firstlineno:-1:parseInt(r.split(",")[0]);case"tb_lasti":if(void 0===r)return console.log("no line info",e.$stack),"";for(var o,a,s=r.split(","),i=e.$stack.length-1;i>=0;i--){var _=e.$stack[i];if(_[2]==s[1].replace(/\./g,"_")){a=_[3].__file__;break}}if(void 0===o&&($B.file_cache.hasOwnProperty(a)?o=$B.file_cache[a]:$B.imported[s[1]]&&$B.imported[s[1]].__file__&&(o=$B.file_cache[$B.imported[s[1]].__file__],console.log("from filecache",r,$B.imported[s[1]].__file__))),void 0===o)return console.log(a),console.log("no src for",s),"";try{return o.split("\n")[parseInt(s[0]-1)].trim()}catch(t){throw console.log("error in attr tb_lasti of",e),console.log(o,s),t}case"tb_next":return e.$stack.length<=1?None:traceback.$factory(e.exc,e.$stack.slice(1));default:return _b_.object.__getattribute__(e,t)}},$B.set_func_names(traceback,"builtins");var frame=$B.make_class("frame",(function(e,t){var r=e,n={__class__:frame,f_builtins:{},$stack:e.slice()};if(void 0===t&&(t=0),n.$pos=t,r.length){var o,a=r[t],s=a[0];try{n.f_locals=$B.obj_dict(a[1])}catch(e){throw console.log("err "+e),e}if(n.f_globals=$B.obj_dict(a[3]),void 0!==a[3].__file__&&(o=a[3].__file__),s.startsWith("$exec")&&(o=""),void 0===a[1].$line_info)n.f_lineno=-1;else{var i=a[1].$line_info.split(",");n.f_lineno=parseInt(i[0]);var _=i[1];$B.imported.hasOwnProperty(_)&&(o=$B.imported[_].__file__),n.f_lineno=parseInt(a[1].$line_info.split(",")[0])}var l=s.startsWith("$exec")?"":s;s==a[2]?l="":s.startsWith("lc"+$B.lambda_magic)?l="":a[1].$name?l=a[1].$name:a[1].$dict_comp?l="":a[1].$list_comp?l="":a.length>4&&(l=a[4].$infos?a[4].$infos.__name__:a[4].name,void 0===a[4].$infos?a[4].name.startsWith("__ge")?l="":a[4].name.startsWith("set_comp"+$B.lambda_magic)?l="":a[4].name.startsWith("lambda"+$B.lambda_magic)&&(l=""):void 0===o&&a[4].$infos.__code__&&(void 0===(o=a[4].$infos.__code__.co_filename)&&(o=a[4].$infos.__module__),n.f_lineno=a[4].$infos.__code__.co_firstlineno)),a.length>4&&void 0!==a[4].$infos?n.f_code=a[4].$infos.__code__:n.f_code={co_name:l,co_filename:o},n.f_code.__class__=$B.code,n.f_code.co_code=_b_.None,void 0===o&&(n.f_code.co_filename="")}return n}));frame.__delattr__=function(e,t){"f_trace"==t&&($B.last(e.$stack)[1].$f_trace=_b_.None)},frame.__getattr__=function(e,t){if("f_back"==t)return e.$pos>0?frame.$factory(e.$stack.slice(0,e.$stack.length-1),e.$pos-1):_b_.None;if("clear"==t)return function(){};if("f_trace"==t){var r=$B.last(e.$stack)[1];return void 0===r.$f_trace?_b_.None:r.$f_trace}},frame.__setattr__=function(e,t,r){"f_trace"==t&&($B.last(e.$stack)[1].$f_trace=r)},frame.__str__=frame.__repr__=function(e){return""},$B.set_func_names(frame,"builtins"),$B._frame=frame;var BaseException=_b_.BaseException={__class__:_b_.type,__bases__:[_b_.object],__mro__:[_b_.object],args:[],$infos:{__name__:"BaseException",__module__:"builtins"},$is_class:!0};BaseException.__init__=function(e){var t=void 0===arguments[1]?[]:[arguments[1]];e.args=_b_.tuple.$factory(t)},BaseException.__repr__=function(e){var t=e.__class__.$infos.__name__;return void 0!==e.args[0]&&(t+="("+repr(e.args[0])),e.args.length>1&&(t+=", "+repr($B.fast_tuple(e.args.slice(1)))),t+")"},BaseException.__str__=function(e){return e.args.length>0?_b_.str.$factory(e.args[0]):e.__class__.$infos.__name__},BaseException.__new__=function(e){var t=_b_.BaseException.$factory();return t.__class__=e,t.__dict__=$B.empty_dict(),t};var getExceptionTrace=function(e,t){if(void 0===e.__class__)return $B.debug>1&&console.log("no class",e),e+"";var r="";void 0!==e.$js_exc&&t&&(r+="\nJS stack:\n"+e.$js_exc.stack+"\n"),r+="Traceback (most recent call last):";for(var n=e.$line_info,o=0;o",_=n[1],l="$"==_.charAt(0);if(l&&(_=""),r+="\n File "+i+" line "+n[0],a.length>4)if(a[4].$infos){var c=a[4].$infos.__name__;c.startsWith("lc"+$B.lambda_magic)?r+=",in ":r+=", in "+c}else a[4].name.startsWith("__ge")?r+=", in ":a[4].name.startsWith("set_comp"+$B.lambda_magic)?r+=", in ":a[4].name.startsWith("lc"+$B.lambda_magic)?r+=", in ":console.log("frame[4]",a[4]);else a[1].$list_comp?r+=", in ":a[1].$dict_comp?r+=", in ":r+=", in ";if(void 0!==s&&!l){var u=s.split("\n")[parseInt(n[0])-1];u&&(u=u.replace(/^[ ]+/g,"")),r+="\n "+u}}}return e.__class__===_b_.SyntaxError&&(r+="\n File "+e.args[1][0]+", line "+e.args[1][1]+"\n "+e.args[1][3]),r};BaseException.__getattr__=function(e,t){if("info"==t)return getExceptionTrace(e,!1);if("infoWithInternal"==t)return getExceptionTrace(e,!0);if("__traceback__"==t)return void 0!==e.$traceback?e.$traceback:traceback.$factory(e);throw _b_.AttributeError.$factory(e.__class__.$infos.__name__+" has no attribute '"+t+"'")},BaseException.with_traceback=function(e,t){return e.$traceback=t,e},$B.deep_copy=function(e){var t=[];for(const o of e){var r=[o[0],{},o[2],{}];void 0!==o[4]&&r.push(o[4]);for(const e of[1,3])for(var n in o[e])r[e][n]=o[e][n];t.push(r)}return t},$B.save_stack=function(){return $B.deep_copy($B.frames_stack)},$B.restore_stack=function(e,t){$B.frames_stack=e,$B.frames_stack[$B.frames_stack.length-1][1]=t},$B.freeze=function(e){if(void 0===e.$stack){e.$line_infos=[];for(var t=0,r=$B.frames_stack.length;t: "+(e.message||"<"+e+">");a.args=_b_.tuple.$factory([s]),a.$py_error=!0,$B.freeze(a)}return a},$B.is_exc=function(e,t){void 0===e.__class__&&(e=$B.exception(e));for(var r=e.$is_class?e:e.__class__,n=0;no?t.stop:e.add(t.start,e.mul(t.step,r))}n.__contains__=function(t,r){if(0==n.__len__(t))return!1;try{r=e.int_or_bool(r)}catch(e){try{return n.index(t,r),!0}catch(e){return!1}}var o=e.sub(r,t.start),a=e.floordiv(o,t.step),s=e.mul(t.step,a);return!!e.eq(s,o)&&(e.gt(t.stop,t.start)?e.ge(r,t.start)&&e.gt(t.stop,r):e.ge(t.start,r)&&e.gt(r,t.stop))},n.__delattr__=function(e,r,n){throw t.AttributeError.$factory("readonly attribute")},n.__eq__=function(r,o){if(t.isinstance(o,n)){var a=n.__len__(r);return!!e.eq(a,n.__len__(o))&&(0==a||!!e.eq(r.start,o.start)&&(1==a||e.eq(r.step,o.step)))}return!1},n.__getitem__=function(r,a){if(t.isinstance(a,t.slice)){var s=t.slice.$conv_for_seq(a,n.__len__(r)),i=e.mul(r.step,s.step),_=o(r,s.start),l=o(r,s.stop);return n.$factory(_,l,i)}"number"!=typeof a&&(a=e.$GetInt(a)),e.gt(0,a)&&(a=e.add(a,n.__len__(r)));var c=e.add(r.start,e.mul(a,r.step));if(e.gt(r.step,0)&&(e.ge(c,r.stop)||e.gt(r.start,c))||e.gt(0,r.step)&&(e.ge(r.stop,c)||e.gt(c,r.start)))throw t.IndexError.$factory("range object index out of range");return c},n.__hash__=function(e){var o=n.__len__(e);return 0==o?t.hash(t.tuple.$factory([0,r,r])):1==o?t.hash(t.tuple.$factory([1,e.start,r])):t.hash(t.tuple.$factory([o,e.start,e.step]))};var a={__class__:t.type,__mro__:[t.object],__iter__:function(e){return e},__next__:function(e){return t.next(e.obj)},$infos:{__name__:"range_iterator",__module__:"builtins"},$is_class:!0,$factory:function(e){return{__class__:a,obj:e}}};e.set_func_names(a,"builtins"),n.__iter__=function(t){var r={__class__:n,start:t.start,stop:t.stop,step:t.step};return t.$safe?r.$counter=t.start-t.step:r.$counter=e.sub(t.start,t.step),a.$factory(r)},n.__len__=function(t){var r;if(e.gt(t.step,0)){if(e.ge(t.start,t.stop))return 0;var n=e.sub(t.stop,e.add(1,t.start)),o=e.floordiv(n,t.step);r=e.add(1,o)}else{if(e.ge(t.stop,t.start))return 0;n=e.sub(t.start,e.add(1,t.stop)),o=e.floordiv(n,e.mul(-1,t.step));r=e.add(1,o)}return void 0===e.maxsize&&(e.maxsize=e.long_int.__pow__(e.long_int.$factory(2),63),e.maxsize=e.long_int.__sub__(e.maxsize,1)),r},n.__next__=function(r){if(r.$safe){if(r.$counter+=r.step,r.step>0&&r.$counter>=r.stop||r.step<0&&r.$counter<=r.stop)throw t.StopIteration.$factory("")}else if(r.$counter=e.add(r.$counter,r.step),e.gt(r.step,0)&&e.ge(r.$counter,r.stop)||e.gt(0,r.step)&&e.ge(r.stop,r.$counter))throw t.StopIteration.$factory("");return r.$counter},n.__reversed__=function(t){var r=e.sub(n.__len__(t),1);return n.$factory(e.add(t.start,e.mul(r,t.step)),e.sub(t.start,t.step),e.mul(-1,t.step))},n.__repr__=n.__str__=function(e){var r="range("+t.str.$factory(e.start)+", "+t.str.$factory(e.stop);return 1!=e.step&&(r+=", "+t.str.$factory(e.step)),r+")"},n.__setattr__=function(e,r,n){throw t.AttributeError.$factory("readonly attribute")},n.start=function(e){return e.start},n.step=function(e){return e.step},n.stop=function(e){return e.stop},n.count=function(r,o){if(t.isinstance(o,[t.int,t.float,t.bool]))return t.int.$factory(n.__contains__(r,o));for(var s=n.__iter__(r),i=a.__next__,_=0;;)try{l=i(s),e.rich_comp("__eq__",o,l)&&_++}catch(e){if(t.isinstance(e,t.StopIteration))return _;throw e}var l},n.index=function(r,o){var s=e.args("index",2,{self:null,other:null},["self","other"],arguments,{},null,null);r=s.self,o=s.other;try{o=e.int_or_bool(o)}catch(s){for(var i=function(t){return e.rich_comp("__eq__",o,t)},_=n.__iter__(r),l=a.__next__,c=0;;)try{if(i(l(_)))return c;c++}catch(e){if(t.isinstance(e,t.StopIteration))throw t.ValueError.$factory(t.str.$factory(o)+" not in range");throw e}}var u=e.sub(o,r.start),f=e.floordiv(u,r.step),p=e.mul(r.step,f);if(e.eq(p,u)){if(e.gt(r.stop,r.start)&&e.ge(o,r.start)&&e.gt(r.stop,o)||e.ge(r.start,r.stop)&&e.ge(r.start,o)&&e.gt(o,r.stop))return f;throw t.ValueError.$factory(t.str.$factory(o)+" not in range")}throw t.ValueError.$factory(t.str.$factory(o)+" not in range")},n.$factory=function(){var r=e.args("range",3,{start:null,stop:null,step:null},["start","stop","step"],arguments,{start:null,stop:null,step:null},null,null),o=r.start,a=r.stop,s=r.step;if(null===a&&null===s){if(null==o)throw t.TypeError.$factory("range expected 1 arguments, got 0");return a=e.PyNumber_Index(o),{__class__:n,start:0,stop:a,step:1,$is_range:!0,$safe:"number"==typeof a}}if(null===s&&(s=1),o=e.PyNumber_Index(o),a=e.PyNumber_Index(a),0==(s=e.PyNumber_Index(s)))throw t.ValueError.$factory("range arg 3 must not be zero");return{__class__:n,start:o,stop:a,step:s,$is_range:!0,$safe:"number"==typeof o&&"number"==typeof a&&"number"==typeof s}},e.set_func_names(n,"builtins");var s={__class__:t.type,__mro__:[t.object],$infos:{__module__:"builtins",__name__:"slice"},$is_class:!0,$native:!0,$descriptors:{start:!0,step:!0,stop:!0}};function i(r){for(var n=["start","stop","step"],o=[],a=0;a=0&&-1!=r.indexOf(e.source[a]);a--);return _.$factory(e.source.slice(0,a+1))}function a(e){return!t.isinstance(e,[_,s])}e.to_bytes=function(r){var n;if(t.isinstance(r,[_,s]))n=r.source;else{var o=e.$getattr(r,"tobytes",null);if(null===o)throw t.TypeError.$factory("object doesn't support the buffer protocol");n=e.$call(o)().source}return n};var s={__class__:t.type,__mro__:[t.object],$buffer_protocol:!0,$infos:{__module__:"builtins",__name__:"bytearray"},$is_class:!0};["__delitem__","clear","copy","count","index","pop","remove","reverse","sort"].forEach((function(e){var r;s[e]=(r=e,function(e){for(var n=[e.source],o=1,a=1,s=arguments.length;a255)throw t.ValueError.$factory("byte must be in range(0, 256)");var a=n;if(n<0&&(a=r.source.length+a),!(a>=0&&a=0;l--){if(!t.isinstance(_[l],t.int))throw t.TypeError.$factory("an integer is required");if(_[l]>255)throw ValueError.$factory("byte must be in range(0, 256)");r.source.splice(s,0,_[l])}}catch(e){throw t.TypeError.$factory("can only assign an iterable")}}},s.append=function(e,r){if(2!=arguments.length)throw t.TypeError.$factory("append takes exactly one argument ("+(arguments.length-1)+" given)");if(!t.isinstance(r,t.int))throw t.TypeError.$factory("an integer is required");if(r>255)throw ValueError.$factory("byte must be in range(0, 256)");e.source[e.source.length]=r},s.extend=function(e,r){if(e.in_iteration)throw t.BufferError.$factory("Existing exports of data: object cannot be re-sized");if(r.__class__===s||r.__class__===_)return r.source.forEach((function(t){e.source.push(t)})),t.None;for(var n=t.iter(r);;)try{s.__add__(e,t.next(n))}catch(e){if(e===t.StopIteration)break;throw e}return t.None},s.insert=function(e,r,n){if(3!=arguments.length)throw t.TypeError.$factory("insert takes exactly 2 arguments ("+(arguments.length-1)+" given)");if(!t.isinstance(n,t.int))throw t.TypeError.$factory("an integer is required");if(n>255)throw ValueError.$factory("byte must be in range(0, 256)");t.list.insert(e.source,r,n)},s.$factory=function(){for(var e=[s],t=0,r=arguments.length;t-1;if(e.source.length=0&&n0){if((s=Math.min(s,e.source.length))<=a)return _.$factory([]);for(c=a;c=a)return _.$factory([]);s=Math.max(0,s);for(c=a;c>=s;c+=i)l[n++]=e.source[c]}return _.$factory(l)}if(t.isinstance(r,t.bool))return e.source.__getitem__(t.int.$factory(r))},_.__gt__=function(e,r){return a(r)?t.NotImplemented:t.list.__gt__(e.source,r.source)},_.__hash__=function(t){if(void 0===t)return _.__hashvalue__||e.$py_next_hash--;for(var r=1,n=0,o=t.source.length;n255)throw t.ValueError.$factory("bytes must be in range(0, 256)")}}return s.source=i,s.encoding=o,s.errors=a,s},_.__repr__=_.__str__=function(e){for(var t="",r=0,n=e.source.length;r=128){var a=o.toString(16);t+="\\x"+(a=(1==a.length?"0":"")+a)}else o=="\\".charCodeAt(0)?t+="\\\\":t+=String.fromCharCode(o)}return t.indexOf("'")>-1&&-1==t.indexOf('"')?'b"'+t+'"':"b'"+t.replace(new RegExp("'","g"),"\\'")+"'"},_.__reduce_ex__=function(e){return _.__repr__(e)},_.capitalize=function(e){var t=e.source,r=t.length,n=t.slice();n[0]>96&&n[0]<123&&(n[0]-=32);for(var o=1;o64&&n[o]<91&&(n[o]+=32);return _.$factory(n)},_.center=function(){var t=e.args("center",3,{self:null,width:null,fillbyte:null},["self","width","fillbyte"],arguments,{fillbyte:_.$factory([32])},null,null),r=t.width-t.self.source.length;if(r<=0)return _.$factory(t.self.source);var n=_.ljust(t.self,t.self.source.length+Math.floor(r/2),t.fillbyte);return _.rjust(n,t.width,t.fillbyte)},_.count=function(){var r=e.args("count",4,{self:null,sub:null,start:null,end:null},["self","sub","start","end"],arguments,{start:0,end:-1},null,null),n=0,o=-1,a=0;if("number"==typeof r.sub){if(r.sub<0||r.sub>255)throw t.ValueError.$factory("byte must be in range(0, 256)");a=1}else{if(!r.sub.__class__)throw t.TypeError.$factory("first argument must be a bytes-like object, not '"+e.class_name(r.sub)+"'");if(!r.sub.__class__.$buffer_protocol)throw t.TypeError.$factory("first argument must be a bytes-like object, not '"+e.class_name(r.sub)+"'");a=r.sub.source.length}do{-1!=(o=_.find(r.self,r.sub,Math.max(o+a,r.start),r.end))&&n++}while(-1!=o);return n},_.decode=function(t,r,n){var o=e.args("decode",3,{self:null,encoding:null,errors:null},["self","encoding","errors"],arguments,{encoding:"utf-8",errors:"strict"},null,null);switch(o.errors){case"strict":case"ignore":case"replace":case"surrogateescape":case"surrogatepass":case"xmlcharrefreplace":case"backslashreplace":return p(o.self,o.encoding,o.errors)}},_.endswith=function(){var r=e.args("endswith",4,{self:null,suffix:null,start:null,end:null},["self","suffix","start","end"],arguments,{start:-1,end:-1},null,null);if(t.isinstance(r.suffix,_)){for(var n=-1==r.start?r.self.source.length-r.suffix.source.length:Math.min(r.self.source.length-r.suffix.source.length,r.start),o=-1==r.end?-1==r.start?r.self.source.length:n+r.suffix.source.length:Math.min(r.self.source.length-1,r.end),a=!0,s=r.suffix.source.length-1,i=r.suffix.source.length;s>=0&&a;--s)a=r.self.source[o-i+s]==r.suffix.source[s];return a}if(t.isinstance(r.suffix,t.tuple)){for(s=0;s255)throw t.ValueError.$factory("byte must be in range(0, 256)");return r.source.slice(0,-1==s?void 0:s).indexOf(n,a)}if(!n.__class__)throw t.TypeError.$factory("first argument must be a bytes-like object, not '"+e.class_name(n)+"'");if(!n.__class__.$buffer_protocol)throw t.TypeError.$factory("first argument must be a bytes-like object, not '"+e.class_name(n)+"'");s=-1==s?r.source.length:Math.min(r.source.length,s);for(var i=n.source.length,_=a;_<=s-i;_++){for(var l=r.source.slice(_,_+i),c=!0,u=0;un.length)throw t.ValueError.$factory("non-hexadecimal number found in fromhex() arg");o.push(t.int.$factory(n.substr(a,2),16))}return r.cls.$factory(o)},_.hex=function(){for(var t=e.args("hex",1,{self:null},["self"],arguments,{},null,null),r=t.self,n="",o=0,a=r.source.length;o0,o=0;o96&&t[o]<123||t[o]>64&&t[o]<91||t[o]>47&&t[o]<58;return n},_.isalpha=function(e){for(var t=e.source,r=t.length,n=r>0,o=0;o96&&t[o]<123||t[o]>64&&t[o]<91;return n},_.isdigit=function(e){var t=e.source,r=t.length,n=r>0;for(let e=0;e47&&t[e]<58;return n},_.islower=function(e){var t=e.source,r=t.length,n=!1;for(let e=0;e96&&t[e]<123,t[e]>64&&t[e]<91)return!1;return n},_.isspace=function(e){var t=e.source,r=t.length;for(let e=0;e64&&t[e]<91,t[e]>96&&t[e]<123)return!1;return n},_.istitle=function(e){for(var t=e.source,r=t.length,n=!1,o=!1,a=!1,s=!1,i=0;i96&&t[i]<123,a=t[i]>64&&t[i]<91,(n=s||a)&&o&&a||!o&&s)return!1;o=n}return!0},_.join=function(){for(var r=e.args("join",2,{self:null,iterable:null},["self","iterable"],arguments,{}),n=r.self,o=r.iterable,a=e.$getattr(t.iter(o),"__next__"),s=n.__class__.$factory(),i=!0;;)try{var l=a();i?i=!1:s=_.__add__(s,n),s=_.__add__(s,l)}catch(e){if(t.isinstance(e,t.StopIteration))break;throw e}return s};_.lower=function(e){for(var t,r=[],n=0,o=0,a=e.source.length;o=65&&t<=90?t+32:t);return _.$factory(r)},_.ljust=function(){var r=e.args("ljust",3,{self:null,width:null,fillbyte:null},["self","width","fillbyte"],arguments,{fillbyte:_.$factory([32])},null,null);if(!r.fillbyte.__class__)throw t.TypeError.$factory("argument 2 must be a byte string of length 1, not '"+e.class_name(r.fillbyte)+"'");if(!r.fillbyte.__class__.$buffer_protocol)throw t.TypeError.$factory("argument 2 must be a byte string of length 1, not '"+e.class_name(r.fillbyte)+"'");for(var n=[],o=r.width-r.self.source.length,a=0;a=0?r.count:a.length;if(!r.old.__class__)throw t.TypeError.$factory("first argument must be a bytes-like object, not '"+e.class_name(r.old)+"'");if(!r.old.__class__.$buffer_protocol)throw t.TypeError.$factory("first argument must be a bytes-like object, not '"+e.class_name(r.sep)+"'");if(!r.new.__class__)throw t.TypeError.$factory("second argument must be a bytes-like object, not '"+e.class_name(r.old)+"'");if(!r.new.__class__.$buffer_protocol)throw t.TypeError.$factory("second argument must be a bytes-like object, not '"+e.class_name(r.sep)+"'");for(var u=0;u255)throw t.ValueError.$factory("byte must be in range(0, 256)");return i.self.source.slice(a,-1==i.end?void 0:i.end).lastIndexOf(o)+a}if(!o.__class__)throw t.TypeError.$factory("first argument must be a bytes-like object, not '"+e.class_name(i.sub)+"'");if(!o.__class__.$buffer_protocol)throw t.TypeError.$factory("first argument must be a bytes-like object, not '"+e.class_name(o)+"'");s=-1==s?r.source.length:Math.min(r.source.length,s);for(var l=o.source.length,c=s-l;c>=a;--c){for(var u=r.source.slice(c,c+l),f=!0,p=0;po)&&n.push(_.$factory(l.slice(o,a))),n},_.splitlines=function(r){var n=e.args("splitlines",2,{self:null,keepends:null},["self","keepends"],arguments,{keepends:!1},null,null);if(!t.isinstance(n.keepends,[t.bool,t.int]))throw t.TypeError("integer argument expected, got "+e.get_class(n.keepends).__name);var o=t.int.$factory(n.keepends),a=[],s=n.self.source,i=0,l=0;if(!s.length)return a;for(;l96&&n[o]<123?n[o]-=32:n[o]>64&&n[o]<91&&(n[o]+=32);return _.$factory(n)},_.title=function(e){var t=e.source,r=t.length;buffer=t.slice(),current_char_is_letter=!1,prev_char_was_letter=!1,is_uppercase=!1,is_lowercase=!1;for(var n=0;n96&&buffer[n]<123,is_uppercase=buffer[n]>64&&buffer[n]<91,current_char_is_letter=is_lowercase||is_uppercase,current_char_is_letter&&(prev_char_was_letter&&is_uppercase?buffer[n]+=32:!prev_char_was_letter&&is_lowercase&&(buffer[n]-=32)),prev_char_was_letter=current_char_is_letter;return _.$factory(buffer)},_.translate=function(r,n,o){if(void 0===o)o=[];else{if(!t.isinstance(o,_))throw t.TypeError.$factory("Type "+e.get_class(o).__name+" doesn't support the buffer API");o=o.source}var a=[],s=0;if(t.isinstance(n,_)&&256==n.source.length)for(var i=0,l=r.source.length;i-1||(a[s++]=n.source[r.source[i]]);return _.$factory(a)};function c(e,r,n){throw t.UnicodeEncodeError.$factory("'"+e+"' codec can't encode character "+t.hex(r)+" in position "+n)}function u(e){var t=e.toLowerCase();return"windows"==t.substr(0,7)&&(t="cp"+t.substr(7)),(t.startsWith("cp")||t.startsWith("iso"))&&(t=t.replace("-","")),t=t.replace(/-/g,"_")}function f(n){if(void 0===r[n]){var o=t.__import__("encodings."+n);o[n].getregentry&&(r[n]=e.$getattr(o[n].getregentry(),"encode"))}}_.upper=function(e){for(var t,r=[],n=0,o=0,a=e.source.length;o=97&&t<=122?t-32:t);return _.$factory(r)},_.zfill=function(e,t){for(var r=e.source.slice(),n=43==r[0]||45==r[0]?1:0,o=t-e.source.length,a=[],s=0;s>5==6)if(void 0===l[d+1]?$=[h,d,"end"]:128!=(192&l[d+1])&&($=[h,d,"continuation"]),null!==$){if("ignore"!=a)throw t.UnicodeDecodeError.$factory("'utf-8' codec can't decode byte 0x"+$[0].toString(16)+" in position "+$[1]+("end"==$[2]?": unexpected end of data":": invalid continuation byte"));d++}else{var m=31&h;m<<=6,m+=63&l[d+1],i+=String.fromCodePoint(m),d+=2}else if(h>>4==14)if(void 0===l[d+1]?$=[h,d,"end",d+1]:128!=(192&l[d+1])?$=[h,d,"continuation",d+2]:void 0===l[d+2]?$=[h,d+"-"+(d+1),"end",d+2]:128!=(192&l[d+2])&&($=[h,d,"continuation",d+3]),null!==$)if("ignore"==a)d=$[3];else{if("surrogateescape"!=a)throw t.UnicodeDecodeError.$factory("'utf-8' codec can't decode byte 0x"+$[0].toString(16)+" in position "+$[1]+("end"==$[2]?": unexpected end of data":": invalid continuation byte"));for(var g=d;g<$[3];g++)i+=String.fromCodePoint(56448+l[g]-128);d=$[3]}else{m=15&h;m<<=12,m+=(63&l[d+1])<<6,m+=63&l[d+2],i+=String.fromCodePoint(m),d+=3}else if(h>>3==30)if(f=!0,void 0===l[d+1]?$=[h,d,"end",d+1]:128!=(192&l[d+1])?$=[h,d,"continuation",d+2]:void 0===l[d+2]?$=[h,d+"-"+(d+1),"end",d+2]:128!=(192&l[d+2])?$=[h,d,"continuation",d+3]:void 0===l[d+3]?$=[h,d+"-"+(d+1)+"-"+(d+2),"end",d+3]:128!=(192&l[d+2])&&($=[h,d,"continuation",d+3]),null!==$)if("ignore"==a)d=$[3];else{if("surrogateescape"!=a)throw t.UnicodeDecodeError.$factory("'utf-8' codec can't decode byte 0x"+$[0].toString(16)+" in position "+$[1]+("end"==$[2]?": unexpected end of data":": invalid continuation byte"));for(g=d;g<$[3];g++)i+=String.fromCodePoint(56448+l[g]-128);d=$[3]}else{m=15&h;m<<=18,m+=(63&l[d+1])<<12,m+=(63&l[d+2])<<6,m+=63&l[d+3],i+=String.fromCodePoint(m),d+=4}else if("ignore"==a)d++;else{if("surrogateescape"!=a)throw t.UnicodeDecodeError.$factory("'utf-8' codec can't decode byte 0x"+h.toString(16)+" in position "+d+": invalid start byte");i+=String.fromCodePoint(56448+l[d]-128),d++}else i+=String.fromCodePoint(h),d++}return f?t.str.$surrogate.$factory(i):i;case"latin_1":case"windows1252":case"iso-8859-1":case"iso8859-1":case"8859":case"cp819":case"latin":case"latin1":case"L1":l.forEach((function(e){i+=String.fromCharCode(e)}));break;case"unicode_escape":return r.__class__!==_&&r.__class__!==s||(r=p(r,"latin-1","strict")),r.replace(/\\n/g,"\n").replace(/\\a/g,"").replace(/\\b/g,"\b").replace(/\\f/g,"\f").replace(/\\t/g,"\t").replace(/\\'/g,"'").replace(/\\"/g,'"');case"raw_unicode_escape":return r.__class__!==_&&r.__class__!==s||(r=p(r,"latin-1","strict")),r.replace(/\\u([a-fA-F0-9]{4})/g,(function(e){var t=parseInt(e.substr(2),16);return String.fromCharCode(t)}));case"ascii":g=0;for(var b=l.length;g>6),128+(63&h)):h<65535?p.push(224+(h>>12),128+((4095&h)>>6),128+(63&h)):console.log("4 bytes")}return p;case"latin":case"latin1":case"latin-1":case"latin_1":case"L1":case"iso8859_1":case"iso_8859_1":case"8859":case"cp819":case"windows1252":for($=0,d=o.length;$=0;r--)if(isNaN(e.$items[r]))return!0;return!1}return t instanceof Number?e.$numbers.indexOf(t.valueOf())>-1:e.$items.indexOf(t)>-1}if("string"==typeof t)return e.$items.indexOf(t)>-1}_b_.isinstance(t,set)||$B.$getattr(t,"__hash__");var n=_b_.hash(t);if(e.$hashes[n]){r=0;for(var o=e.$hashes[n].length;r-1);else if("number"==typeof t&&e.$numbers.indexOf(t)>-1);else{e.$items.push(t);var a=t.valueOf();"number"==typeof a&&e.$numbers.push(a)}else t!==e.$items[o]&&e.$items.push(t)}else{var s=_b_.hash(t);if(void 0===(i=e.$hashes[s]))e.$hashes[s]=[t],e.$items.push(t);else{for(var i,_=0,l=(i=e.$hashes[s]).length;_-1&&e.$items.splice(i,1)}else for(var _=0;_-1?a.push(_):s.push(r)}else{for(var l=!1,c=0;!l&&c0||Object.keys(e.$object_dict).length>0))throw _b_.TypeError.$factory("a dictionary with non-string keys does not support structured clone");var a=$B.dict_to_list(e);for(r={},n=0,o=a.length;n",__name__:"JSConstructor"},$is_class:!0,__call__:function(e){return function(){for(var t=[null],r=0,n=arguments.length;r-1)return e;if([_b_.list,_b_.tuple].indexOf(t)>-1){var r=[];return e.forEach((function(e){r.push(pyobj2jsobj(e))})),r}if(t===_b_.dict||_b_.issubclass(t,_b_.dict)){var n={};return _b_.list.$factory(_b_.dict.items(e)).forEach((function(e){"function"==typeof e[1]&&e[1].bind(n),n[e[0]]=pyobj2jsobj(e[1])})),n}return t===_b_.float?e.valueOf():(t===$B.Function||t===$B.method)&&(e.prototype.constructor!==e||e.$is_func)?function(){try{for(var t=[],r=0;r0?e.args[0]:""),e}}:e}};function pyargs2jsargs(e){for(var t=[],r=0,n=e.length;r0)throw _b_.TypeError.$factory("A Javascript function can't take keyword arguments")}else t.push($B.pyobj2jsobj(o))}return t}$B.JSConstructor=JSConstructor,$B.JSObj=$B.make_class("JSObj",(function(e){if(Array.isArray(e));else if("function"==typeof e)e.$is_js_func=!0,e.__new__=function(){return new e.$js_func(...arguments)};else if("number"==typeof e&&!Number.isInteger(e))return new Number(e);return e})),$B.JSObj.__sub__=function(e,t){if("bigint"==typeof e&&"bigint"==typeof t)return e-t;throw _b_.TypeError.$factory("unsupported operand type(s) for - : '"+$B.class_name(e)+"' and '"+$B.class_name(t)+"'")};var ops={"+":"__add__","*":"__mul__","**":"__pow__","%":"__mod__"};for(var op in ops)eval("$B.JSObj."+ops[op]+" = "+($B.JSObj.__sub__+"").replace(/-/g,op));$B.JSObj.__eq__=function(e,t){switch(typeof e){case"object":if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var r in e)if(!$B.JSObj.__eq__(e[r],t[r]))return!1;default:return e===t}},$B.JSObj.__ne__=function(e,t){return!$B.JSObj.__eq__(e,t)},$B.JSObj.__getattribute__=function(e,t){if("$$new"==t&&"function"==typeof e)return e.$js_func?function(){var t=pyargs2jsargs(arguments);return $B.JSObj.$factory(new e.$js_func(...t))}:function(){var t=pyargs2jsargs(arguments);return $B.JSObj.$factory(new e(...t))};"string"==typeof t&&(t=$B.from_alias(t));var r=e[t];if(null==r&&"function"==typeof e&&e.$js_func&&(r=e.$js_func[t]),void 0===r){var n;if("function"==typeof e.getNamedItem)if(void 0!==(n=e.getNamedItem(t)))return $B.JSObj.$factory(n);var o=$B.get_class(e);if(o&&o[t]){var a=o[t];return"function"==typeof a?function(){for(var t=[e],r=0,n=arguments.length;r0&&(n.$infos.__module__=$B.last($B.frames_stack)[3].__name__),$B.JSObj.$factory(n)):$B.JSObj.$factory(r)},$B.JSObj.__setattr__=function(e,t,r){return"string"==typeof t&&(t=$B.from_alias(t)),e[t]=$B.pyobj2structuredclone(r),_b_.None},$B.JSObj.__getitem__=function(e,t){if("string"==typeof t)return $B.JSObj.__getattribute__(e,t);if("number"==typeof t){if(void 0!==e[t])return $B.JSObj.$factory(e[t]);if("number"==typeof e.length&&("number"==typeof t||"boolean"==typeof t)&&"function"==typeof e.item){var r=_b_.int.$factory(t);r<0&&(r+=e.length);var n=e.item(r);if(null===n)throw _b_.IndexError.$factory(r);return $B.JSObj.$factory(n)}}throw _b_.KeyError.$factory(r)},$B.JSObj.__setitem__=$B.JSObj.__setattr__;var JSObj_iterator=$B.make_iterator_class("JS object iterator");$B.JSObj.__iter__=function(e){var t=[];if(_window.Symbol&&void 0!==e[Symbol.iterator]){t=[];if(void 0!==e.next)for(;;){var r=e.next();if(r.done)break;t.push($B.JSObj.$factory(r.value))}else if(void 0!==e.length&&void 0!==e.item)for(var n=0;n"},$B.JSObj.bind=function(e,t,r){return e.addEventListener(t,(function(e){return r(jsobj2pyobj(e))})),_b_.None},$B.JSObj.to_dict=function(e){return $B.structuredclone2pyobj(e)},$B.set_func_names($B.JSObj,"builtins"),$B.JSMeta=$B.make_class("JSMeta"),$B.JSMeta.__call__=function(e){for(var t=[],r=arguments[0],n=1,o=arguments.length;n-1?"":""},"builtins"!=r.name&&(n.__file__=t);return $B.imported[r.__name__]=n,!0}function show_ns(){for(var kk=Object.keys(_window),i=0,len=kk.length;i1){for(var attr in console.log(e+" for module "+module.__name__),console.log("module",module),console.log(root),$B.debug>1&&console.log(js),e)console.log(attr,e[attr]);console.log($B.$getattr(e,"info","[no info]")),console.log("message: "+e.$message),console.log("filename: "+e.fileName),console.log("linenum: "+e.lineNumber)}throw $B.debug>0&&console.log("line info "+$B.line_info),e}finally{$B.clear_ns(module.__name__)}try{var mod=eval("$module");for(var attr in mod)module[attr]=mod[attr];return module.__initializing__=!1,$B.imported[module.__name__]=module,{content:src,name:mod_name,imports:Object.keys(root.imports).join(",")}}catch(e){for(var attr in console.log(e+" for module "+module.__name__),e)console.log(attr+" "+e[attr]);throw $B.debug>0&&console.log("line info "+__BRYTHON__.line_info),e}}Module.__new__=function(e,t,r,n){return{__class__:e,__name__:t,__doc__:r||_b_.None,__package__:n||_b_.None}},Module.__repr__=Module.__str__=function(e){var t=""},Module.__setattr__=function(e,t,r){"__builtins__"==e.__name__?$B.builtins[t]=r:e[t]=r},$B.set_func_names(Module,"builtins"),$B.$download_module=$download_module,$B.run_py=run_py;var ModuleSpec=$B.make_class("ModuleSpec",(function(e){return e.__class__=ModuleSpec,e}));function parent_package(e){var t=e.split(".");return t.pop(),t.join(".")}ModuleSpec.__str__=ModuleSpec.__repr__=function(e){var t=`ModuleSpec(name='${e.name}',loader=${_b_.str.$factory(e.loader)},origin='${e.origin}'`;return e.submodule_search_locations!==_b_.None&&(t+=",submodule_search_locations="+_b_.str.$factory(e.submodule_search_locations)),t+")"},$B.set_func_names(ModuleSpec,"builtins");var VFSFinder=$B.make_class("VFSFinder",(function(){return{__class__:VFSFinder}}));for(var method in VFSFinder.find_spec=function(e,t,r){var n,o,a;if(!$B.use_VFS)return _b_.None;if(void 0===(n=$B.VFS[t]))return _b_.None;if(o=n[3]||!1,a=n.timestamp,n){var s=$B.builtin_module_names.indexOf(t)>-1;return ModuleSpec.$factory({name:t,loader:VFSLoader.$factory(),origin:s?"built-in":"brython_stdlib",submodule_search_locations:o?[]:_b_.None,loader_state:{stored:n,timestamp:a},cached:_b_.None,parent:o?t:parent_package(t),has_location:_b_.False})}},$B.set_func_names(VFSFinder,""),VFSFinder)"function"==typeof VFSFinder[method]&&(VFSFinder[method]=_b_.classmethod.$factory(VFSFinder[method]));VFSLoader=$B.make_class("VFSLoader",(function(){return{__class__:VFSLoader}})),VFSLoader.create_module=function(e,t){return _b_.None},VFSLoader.exec_module=function(e,t){var r=t.__spec__.loader_state.stored,n=t.__spec__.loader_state.timestamp;delete t.__spec__.loader_state;var o=r[0],a=r[1];r[2];t.$is_package=r[3]||!1;var s="VFS."+t.__name__;if(s+=t.$is_package?"/__init__.py":o,t.__file__=s,$B.file_cache[t.__file__]=$B.VFS[t.__name__][1],".js"==o)run_js(a,t.__path__,t);else{if($B.precompiled.hasOwnProperty(t.__name__)){$B.debug>1&&console.info("load",t.__name__,"from precompiled");for(var i=t.__name__.split("."),_=0;_",f.__package__=l;else(g=l.split(".")).pop(),f.__package__=g.join(".");f.__file__=s;try{var p=l.replace(/\./g,"_");c+="return $locals_"+p;var $=new Function("$locals_"+p,c)(f)}catch(e){if($B.debug>1){for(var d in console.log(e),e)console.log(d,e[d]);console.log(Object.keys($B.imported)),$B.debug>2&&console.log(t,"mod_js",c)}throw e}for(var h in $)f[h]=$[h];$.__file__=s,_>0&&$B.builtins.setattr($B.imported[i.slice(0,_).join(".")],i[_],$)}}return $}var m=t.__name__;$B.debug>1&&console.log("run Python code from VFS",m);var g,b=run_py(a,t.__path__,t);b.is_package=t.$is_package,b.timestamp=$B.timestamp,b.source_ts=n,$B.precompiled[m]=b.is_package?[b.content]:b.content,(g=m.split(".")).length>1&&g.pop(),$B.$options.indexedDB&&$B.indexedDB&&$B.idb_name&&(indexedDB.open($B.idb_name).onsuccess=function(e){var r=e.target.result.transaction("modules","readwrite").objectStore("modules"),n=(r.openCursor(),r.put(b));n.onsuccess=function(){$B.debug>1&&console.info(t.__name__,"stored in db")},n.onerror=function(){console.info("could not store "+t.__name__)}})}},$B.set_func_names(VFSLoader,"builtins");var finder_cpython={__class__:_b_.type,__mro__:[_b_.object],$infos:{__module__:"builtins",__name__:"CPythonFinder"},create_module:function(e,t){return _b_.None},exec_module:function(e,t){console.log("exec PYthon module",t);var r=t.__spec__.loader_state,n=r.content;delete t.__spec__.loader_state,t.$is_package=r.is_package,t.__file__=r.__file__,$B.file_cache[t.__file__]=n;var o=t.__name__;$B.debug>1&&console.log("run Python code from CPython",o),run_py(n,t.__path__,t)},find_module:function(e,t,r){return{__class__:Loader,load_module:function(t,r){var n=e.find_spec(e,t,r),o=Module.$factory(t);$B.imported[t]=o,o.__spec__=n,e.exec_module(e,o)}}},find_spec:function(e,t,r){console.log("finder cpython",t);var n,o=new XMLHttpRequest,a="/cpython_import?module="+t;return o.open("GET",a,!1),o.onreadystatechange=function(){if(4==this.readyState&&200==this.status){var r=JSON.parse(this.responseText);n=ModuleSpec.$factory({name:t,loader:e,origin:"CPython",submodule_search_locations:r.is_package?[]:_b_.None,loader_state:{content:r.content},cached:_b_.None,parent:r.is_package?t:parent_package(t),has_location:_b_.False})}},o.send(),n}};for(var method in $B.set_func_names(finder_cpython,""),finder_cpython)"function"==typeof finder_cpython[method]&&(finder_cpython[method]=_b_.classmethod.$factory(finder_cpython[method]));finder_cpython.$factory=function(){return{__class__:finder_cpython}};var StdlibStaticFinder=$B.make_class("StdlibStaticFinder",(function(){return{__class__:StdlibStaticFinder}}));for(var method in StdlibStaticFinder.find_spec=function(e,t,r){if($B.stdlib&&$B.$options.static_stdlib_import){var n=$B.stdlib[t];if(void 0===n){var o=t.split(".");if(o.length>1){o.pop();var a=$B.stdlib[o.join(".")];a&&a[1]&&(n=["py"])}}if(void 0!==n){var s=n[0],i=void 0!==n[1],_={ext:s,is_package:i,path:(r=$B.brython_path+("py"==s?"Lib/":"libs/")+t.replace(/\./g,"/"))+(i?"/__init__.py":"py"==s?".py":".js"),address:n},l=Module.$factory(t);return _.code=$download_module(l,_.path),ModuleSpec.$factory({name:t,loader:PathLoader.$factory(),origin:_.path,submodule_search_locations:i?[r]:_b_.None,loader_state:_,cached:_b_.None,parent:i?t:parent_package(t),has_location:_b_.True})}}return _b_.None},$B.set_func_names(StdlibStaticFinder,""),StdlibStaticFinder)"function"==typeof StdlibStaticFinder[method]&&(StdlibStaticFinder[method]=_b_.classmethod.$factory(StdlibStaticFinder[method]));StdlibStaticFinder.$factory=function(){return{__class__:StdlibStaticFinder}};var PathFinder=$B.make_class("PathFinder",(function(){return{__class__:PathFinder}}));for(var method in PathFinder.find_spec=function(e,t,r){if($B.VFS&&$B.VFS[t])return _b_.None;$B.is_none(r)&&(r=$B.path);for(var n=0,o=r.length;n"),PathFinder)"function"==typeof PathFinder[method]&&(PathFinder[method]=_b_.classmethod.$factory(PathFinder[method]));var PathEntryFinder=$B.make_class("PathEntryFinder",(function(e,t){return{__class__:PathEntryFinder,path_entry:e,hint:t}}));PathEntryFinder.find_spec=function(e,t){var r={},n=!0,o=e.hint,a=e.path_entry+t.match(/[^.]+$/g)[0],s=[];(void 0===o||"py"==o)&&(s=s.concat([[a+".py","py",!1],[a+"/__init__.py","py",!0]]));for(var i=0;n&&i-1&&a.splice(i,1)}for(var _=0,l=a.length;_0;if(i==_b_.None&&import_error(e),void 0===i){$B.is_none(n)&&(n=[]);for(var c=0,u="",f="",p=_.length-1,$=_b_.None;c<=p;++c){var d=f;if(f+=u+_[c],u=".",(i=$B.imported[f])==_b_.None)import_error(f);else if(void 0===i){try{import_engine(f,$,a)}catch(e){throw delete $B.imported[f],e}$B.is_none($B.imported[f])?import_error(f):d&&_b_.setattr($B.imported[d],_[c],$B.imported[f])}else $B.imported[d]&&void 0===$B.imported[d][_[c]]&&_b_.setattr($B.imported[d],_[c],$B.imported[f]);if(c0?$B.imported[e]:$B.imported[_[0]]},$B.$import=function(e,t,r,n){t=void 0===t?[]:t,r=void 0===r?{}:r,n=void 0===n?{}:n;var o=e.split(".");"."==e[e.length-1]&&o.pop();for(var a=[],s=!0,i=0,_=o.length;i<_;i++){var l=o[i];if(s&&""==l){if(elt=a.pop(),void 0===elt)throw _b_.ImportError.$factory("Parent module '' not loaded, cannot perform relative import")}else s=!1,a.push("$$"==l.substr(0,2)?l.substr(2):l)}e=a.join(".");10==$B.$options.debug&&(console.log("$import "+e),console.log("use VFS ? "+$B.use_VFS),console.log("use static stdlib paths ? "+$B.static_stdlib_import));var c=$B.frames_stack[$B.frames_stack.length-1],u=c[3],f=u.__import__,p=$B.obj_dict(u);void 0===f&&(f=$B.$__import__);var $=("function"==typeof f?f:$B.$getattr(f,"__call__"))(e,p,void 0,t,0);if(t&&0!=t.length){var d=t,h={};if(t&&"*"==t[0]&&(d=$B.$getattr($,"__all__",h))!==h&&(r={}),d===h)for(var m in $)"_"!==m[0]&&(n[m]=$[m]);else{i=0;for(var g=d.length;i1&&(console.log(t),console.log($B.last($B.frames_stack))),_b_.ImportError.$factory("cannot import name '"+b+"'")}}}}return n}(y=r[e])?n[y]=$B.imported[e]:n[$B.to_alias(a[0])]=$},$B.import_all=function(e,t){for(var r in t)(r.startsWith("$$")||-1=="_$".indexOf(r.charAt(0)))&&(e[r]=t[r])},$B.$path_hooks=[url_hook],$B.$meta_path=[VFSFinder,StdlibStaticFinder,PathFinder],$B.finders={VFS:VFSFinder,stdlib_static:StdlibStaticFinder,path:PathFinder,CPython:finder_cpython};var Loader={__class__:$B.$type,__mro__:[_b_.object],__name__:"Loader"},_importlib_module={__class__:Module,__name__:"_importlib",Loader:Loader,VFSFinder:VFSFinder,StdlibStatic:StdlibStaticFinder,ImporterPath:PathFinder,UrlPathFinder:url_hook,optimize_import_for_path:optimize_import_for_path};_importlib_module.__repr__=_importlib_module.__str__=function(){return""},$B.imported._importlib=_importlib_module}(__BRYTHON__),function($B){var bltns=$B.InjectBuiltins();eval(bltns);var object=_b_.object;function $err(e,t){var r="unsupported operand type(s) for "+e+": 'float' and '"+$B.class_name(t)+"'";throw _b_.TypeError.$factory(r)}function float_value(e){return void 0!==e.$brython_value?e.$brython_value:e}var float={__class__:_b_.type,__dir__:object.__dir__,$infos:{__module__:"builtins",__name__:"float"},$is_class:!0,$native:!0,$descriptors:{numerator:!0,denominator:!0,imag:!0,real:!0}};function preformat(e,t){if(t.empty)return _b_.str.$factory(e);if(t.type&&-1=="eEfFgGn%".indexOf(t.type))throw _b_.ValueError.$factory("Unknown format code '"+t.type+"' for object of type 'float'");if(isNaN(e))return"f"==t.type||"g"==t.type?"nan":"NAN";if(e==Number.POSITIVE_INFINITY)return"f"==t.type||"g"==t.type?"inf":"INF";if(void 0===t.precision&&void 0!==t.type&&(t.precision=6),"%"==t.type&&(e*=100),"e"==t.type){var r=e.toExponential(t.precision),n=parseInt(r.substr(r.search("e")+1));return Math.abs(n)<10&&(r=r.substr(0,r.length-1)+"0"+r.charAt(r.length-1)),r}if(void 0!==t.precision){var o=t.precision;if(0==o)return Math.round(e)+"";var a=(r=e.toFixed(o)).indexOf(".");if(void 0===t.type||"%"!=t.type&&"f"!=t.type.toLowerCase()){if(t.type&&"g"==t.type.toLowerCase()){var s=preformat(e,{type:"e"}).split("e"),i=(r=-4<=(n=parseInt(s[1]))&&n=t.precision-1){for(var c=l.split("e");c[0].endsWith("0");)c[0]=c[0].substr(0,c[0].length-1);r=c.join("e")}}}else if(-1==a)r+="."+"0".repeat(t.precision);else{var u=t.precision-r.length+a+1;u>0&&(r+="0".repeat(u))}}else r=_b_.str.$factory(e);if(void 0===t.type||-1!="gGn".indexOf(t.type)){if(-1==r.search("e"))for(;"0"==r.charAt(r.length-1);)r=r.substr(0,r.length-1);"."==r.charAt(r.length-1)&&(void 0===t.type?r+="0":r=r.substr(0,r.length-1))}return void 0!==t.sign&&(" "==t.sign||"+"==t.sign)&&e>0&&(r=t.sign+r),"%"==t.type&&(r+="%"),r}float.numerator=function(e){return float_value(e)},float.denominator=function(e){return _b_.int.$factory(1)},float.imag=function(e){return _b_.int.$factory(0)},float.real=function(e){return float_value(e)},float.__float__=function(e){return float_value(e)},float.as_integer_ratio=function(e){if((e=float_value(e)).valueOf()==Number.POSITIVE_INFINITY||e.valueOf()==Number.NEGATIVE_INFINITY)throw _b_.OverflowError.$factory("Cannot pass infinity to float.as_integer_ratio.");if(!Number.isFinite(e.valueOf()))throw _b_.ValueError.$factory("Cannot pass NaN to float.as_integer_ratio.");for(var t=_b_.$frexp(e.valueOf()),r=t[0],n=t[1],o=0;o<300&&r!=Math.floor(r);o++)r*=2,n--;return numerator=float.$factory(r),py_exponent=abs(n),denominator=1,py_exponent=_b_.getattr(_b_.int.$factory(denominator),"__lshift__")(py_exponent),n>0?numerator*=py_exponent:denominator=py_exponent,_b_.tuple.$factory([_b_.int.$factory(numerator),_b_.int.$factory(denominator)])},float.__bool__=function(e){return e=float_value(e),_b_.bool.$factory(e.valueOf())},float.__eq__=function(e,t){return e=float_value(e),t=float_value(t),(!isNaN(e)||!isNaN(t))&&(isinstance(t,_b_.int)?e==t:isinstance(t,float)?e.valueOf()==t.valueOf():isinstance(t,_b_.complex)?0==t.$imag&&e==t.$real:_b_.NotImplemented)},float.__floordiv__=function(e,t){if(e=float_value(e),t=float_value(t),isinstance(t,[_b_.int,float])){if(0==t.valueOf())throw ZeroDivisionError.$factory("division by zero");return float.$factory(Math.floor(e/t))}if(hasattr(t,"__rfloordiv__"))return getattr(t,"__rfloordiv__")(e);$err("//",t)},float.fromhex=function(e){if(!isinstance(e,_b_.str))throw _b_.ValueError.$factory("argument must be a string");var t,r=e.trim();switch(r.toLowerCase()){case"+inf":case"inf":case"+infinity":case"infinity":return $FloatClass(1/0);case"-inf":case"-infinity":return $FloatClass(-1/0);case"+nan":case"nan":return $FloatClass(Number.NaN);case"-nan":return $FloatClass(-Number.NaN);case"":throw _b_.ValueError.$factory("could not convert string to float")}if(null!==(t=/^(\d*\.?\d*)$/.exec(r)))return $FloatClass(parseFloat(t[1]));if(null==(t=/^(\+|-)?(0x)?([0-9A-F]+\.?)?(\.[0-9A-F]+)?(p(\+|-)?\d+)?$/i.exec(r)))throw _b_.ValueError.$factory("invalid hexadecimal floating-point string");var n=t[1],o=parseInt(t[3]||"0",16),a=t[4]||".0",s=t[5]||"p0";n="-"==n?-1:1;for(var i=o,_=1,l=a.length;_";var n=preformat(e,r).split("."),o=n[0];if(r.comma){for(var a=o.length,s=Math.ceil(o.length/3),i=[],_=0;_0?float.$factory(e):float.$factory(-e)},_b_.$frexp=function(e){var t=e;if(isinstance(e,float)&&(t=e.valueOf()),isNaN(t)||_b_.$isinf(t))return[t,-1];if(0==t)return[0,0];var r=1,n=0,o=t;for(o<0&&(r=-r,o=-o);o<.5;)o*=2,n--;for(;o>=1;)o*=.5,n++;return[o*=r,n]},_b_.$ldexp=function(e,t){if(_b_.$isninf(e))return float.$factory("-inf");if(_b_.$isinf(e))return float.$factory("inf");var r=e;if(isinstance(e,float)&&(r=e.valueOf()),0==r)return r;var n=t;return isinstance(t,float)&&(n=t.valueOf()),r*Math.pow(2,n)},float.hex=function(e){switch((e=float_value(e)).valueOf()){case 1/0:case-1/0:case Number.NaN:case-Number.NaN:return e;case-0:return"-0x0.0p0";case 0:return"0x0.0p0"}var t=_b_.$frexp(_b_.$fabs(e.valueOf())),r=t[0],n=t[1],o=1-Math.max(-1021-n,0);r=_b_.$ldexp(r,o),n-=o;var a="0123456789ABCDEF".split(""),s=a[Math.floor(r)];s+=".",r-=Math.floor(r);for(var i=0;i<13;i++)r*=16,s+=a[Math.floor(r)],r-=Math.floor(r);var _="+";return n<0&&(_="-",n=-n),e.value<0?"-0x"+s+"p"+_+n:"0x"+s+"p"+_+n},float.__init__=function(e,t){return _b_.None},float.__int__=function(e){return parseInt(e)},float.is_integer=function(e){return _b_.int.$factory(e)==e},float.__mod__=function(e,t){if(e=float_value(e),0==(t=float_value(t)))throw ZeroDivisionError.$factory("float modulo");if(isinstance(t,_b_.int))return new Number((e%t+t)%t);if(isinstance(t,float)){var r=Math.floor(e/t);return new Number(e-t*r)}if(isinstance(t,_b_.bool)){var n=0;return t.valueOf()&&(n=1),new Number((e%n+n)%n)}if(hasattr(t,"__rmod__"))return getattr(t,"__rmod__")(e);$err("%",t)},float.__mro__=[object],float.__mul__=function(e,t){if(e=float_value(e),t=float_value(t),isinstance(t,_b_.int))return t.__class__==$B.long_int?new Number(e*parseFloat(t.value)):new Number(e*t);if(isinstance(t,float))return new Number(e*float_value(t));if(isinstance(t,_b_.bool)){var r=0;return t.valueOf()&&(r=1),new Number(e*r)}return isinstance(t,_b_.complex)?$B.make_complex(float.$factory(e*t.$real),float.$factory(e*t.$imag)):_b_.NotImplemented},float.__ne__=function(e,t){var r=float.__eq__(e,t);return r===_b_.NotImplemented?r:!r},float.__neg__=function(e,t){return float.$factory(-float_value(e))},float.__new__=function(e,t){if(void 0===e)throw _b_.TypeError.$factory("float.__new__(): not enough arguments");if(!_b_.isinstance(e,_b_.type))throw _b_.TypeError.$factory("float.__new__(X): X is not a type object");return e===float?float.$factory(t):{__class__:e,__dict__:$B.empty_dict(),$brython_value:t||0}},float.__pos__=function(e){return float_value(e)},float.__pow__=function(e,t){if(e=float_value(e),t=float_value(t),isinstance(t,_b_.int)||isinstance(t,float)){if(1==e)return e;if(0==t)return new Number(1);if(!(-1!=e||isFinite(t)&&t.__class__!==$B.long_int&&$B.is_safe_int(t)||isNaN(t)))return new Number(1);if(0==e&&isFinite(t)&&t<0)throw _b_.ZeroDivisionError.$factory("0.0 cannot be raised to a negative power");return e!=Number.NEGATIVE_INFINITY||isNaN(t)?e!=Number.POSITIVE_INFINITY||isNaN(t)?t!=Number.NEGATIVE_INFINITY||isNaN(e)?t!=Number.POSITIVE_INFINITY||isNaN(e)?e<0&&!_b_.getattr(t,"__eq__")(_b_.int.$factory(t))?_b_.complex.__pow__($B.make_complex(e,0),t):float.$factory(Math.pow(e,t)):Math.abs(e)<1?new Number(0):Number.POSITIVE_INFINITY:Math.abs(e)<1?Number.POSITIVE_INFINITY:new Number(0):t>0?e:new Number(0):t<0&&t%2==1?new Number(-0):t<0?new Number(0):t>0&&t%2==1?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY}if(isinstance(t,_b_.complex)){var r=Math.pow(e,t.$real),n=Math.log(e);return $B.make_complex(r*Math.cos(n),r*Math.sin(n))}if(hasattr(t,"__rpow__"))return getattr(t,"__rpow__")(e);$err("** or pow()",t)},float.__repr__=float.__str__=function(e){if((e=float_value(e).valueOf())==1/0)return"inf";if(e==-1/0)return"-inf";if(isNaN(e))return"nan";if(0===e)return 1/e==-1/0?"-0.0":"0.0";var t,r,n=e+"";if(-1==n.indexOf(".")&&(n+=".0"),[t,r]=n.split("."),t.length>16){for(var o=t.length-1,a=t[0],s=t.substr(1)+r;s.endsWith("0");)s=s.substr(0,s.length-1);var i=a;return s.length>0&&(i+="."+s),i+"e+"+o}if("0"==t){for(o=0;o3){var _=r.substr(o);for(o=(o+1).toString();_.endsWith("0");)_=_.substr(0,n.length-1);i=_[0];return _.length>1&&(i+="."+_.substr(1)),1==o.length&&(o="0"+o),i+"e-"+o}}return _b_.str.$factory(n)},float.__setattr__=function(e,t,r){if(e.constructor===Number)throw void 0===float[t]?_b_.AttributeError.$factory("'float' object has no attribute '"+t+"'"):_b_.AttributeError.$factory("'float' object attribute '"+t+"' is read-only");return e[t]=r,_b_.None},float.__truediv__=function(e,t){if(e=float_value(e),t=float_value(t),isinstance(t,[_b_.int,float])){if(0==t.valueOf())throw ZeroDivisionError.$factory("division by zero");return float.$factory(e/t)}if(isinstance(t,_b_.complex)){var r=t.$real*t.$real+t.$imag*t.$imag;if(0==r)throw _b_.ZeroDivisionError.$factory("division by zero");return $B.make_complex(float.$factory(e*t.$real/r),float.$factory(-e*t.$imag/r))}if(hasattr(t,"__rtruediv__"))return getattr(t,"__rtruediv__")(e);$err("/",t)};var $op_func=function(e,t){if(e=float_value(e),t=float_value(t),isinstance(t,_b_.int))return"boolean"==typeof t?t?e-1:e:t.__class__===$B.long_int?float.$factory(e-parseInt(t.value)):float.$factory(e-t);if(isinstance(t,float))return float.$factory(e-t);if(isinstance(t,_b_.bool)){var r=0;return t.valueOf()&&(r=1),float.$factory(e-r)}return isinstance(t,_b_.complex)?0==t.$imag?$B.make_complex(e-t.$real,0):$B.make_complex(e-t.$real,-t.$imag):hasattr(t,"__rsub__")?getattr(t,"__rsub__")(e):void $err("-",t)};$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("float.__"+$ops[$op]+"__ = "+$opf)}var $comp_func=function(e,t){if(e=float_value(e),t=float_value(t),isinstance(t,_b_.int))return t.__class__===$B.long_int?e>parseInt(t.value):e>t.valueOf();if(isinstance(t,float))return e>t;if(isinstance(t,_b_.bool))return e.valueOf()>_b_.bool.__hash__(t);if(hasattr(t,"__int__")||hasattr(t,"__index__"))return _b_.int.__gt__(e,$B.$GetInt(t));var r=getattr(t,"__le__",None);if(r!==None)return r(e);throw _b_.TypeError.$factory("unorderable types: float() > "+$B.class_name(t)+"()")};for(var $op in $comp_func+="",$B.$comps)eval("float.__"+$B.$comps[$op]+"__ = "+$comp_func.replace(/>/gm,$op).replace(/__gt__/gm,"__"+$B.$comps[$op]+"__").replace(/__le__/,"__"+$B.$inv_comps[$op]+"__"));$B.make_rmethods(float);var $notimplemented=function(e,t){throw _b_.TypeError.$factory("unsupported operand types for OPERATOR: 'float' and '"+$B.class_name(t)+"'")};for(var $op in $notimplemented+="",$B.$operators)if(void 0===$B.augmented_assigns[$op]){var $opfunc="__"+$B.$operators[$op]+"__";void 0===float[$opfunc]&&eval("float."+$opfunc+"="+$notimplemented.replace(/OPERATOR/gm,$op))}function $FloatClass(e){return new Number(e)}function to_digits(e){for(var t="",r=0;r-1?n:e[r]}return t}float.$factory=function(value){switch(value){case void 0:return $FloatClass(0);case Number.MAX_VALUE:return $FloatClass(1/0);case-Number.MAX_VALUE:return $FloatClass(-1/0);case!0:return new Number(1);case!1:return new Number(0)}if("number"==typeof value)return new Number(value);if(isinstance(value,float))return float_value(value);if(isinstance(value,bytes)){var s=getattr(value,"decode")("latin-1");return float.$factory(getattr(value,"decode")("latin-1"))}if("string"==typeof value)switch(value=value.trim(),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.$factory("count not convert string to float");default:if(value=value.charAt(0)+value.substr(1).replace(/_/g,""),value=to_digits(value),isFinite(value))return $FloatClass(eval(value));throw _b_.str.encode(value,"latin-1"),_b_.ValueError.$factory("Could not convert to float(): '"+_b_.str.$factory(value)+"'")}var klass=value.__class__||$B.get_class(value),num_value=$B.to_num(value,["__float__","__index__"]);if(null!==num_value)return num_value;throw _b_.TypeError.$factory("float() argument must be a string or a number, not '"+$B.class_name(value)+"'")},$B.$FloatClass=$FloatClass,$B.set_func_names(float,"builtins");var FloatSubclass=$B.FloatSubclass={__class__:_b_.type,__mro__:[object],$infos:{__module__:"builtins",__name__:"float"},$is_class:!0};for(var $attr in float)"function"==typeof float[$attr]&&(FloatSubclass[$attr]=function(e){return function(){var t=[],r=0;if(arguments.length>0){t=[arguments[0].valueOf()],r=1;for(var n=1,o=arguments.length;n=0&&(r=t.sign+r),r}function extended_euclidean(e,t){var r,n,o;return 0==t?[e,1,0]:([r,n,o]=extended_euclidean(t,e%t),[r,o,n-Math.floor(e/t)*o])}int.as_integer_ratio=function(){var e=$B.args("as_integer_ratio",1,{self:null},["self"],arguments,{},null,null);return $B.$list([e.self,1])},int.from_bytes=function(){var e,t,r=$B.args("from_bytes",3,{bytes:null,byteorder:null,signed:null},["bytes","byteorder","signed"],arguments,{signed:!1},null,null),n=r.bytes,o=r.byteorder,a=r.signed;if(_b_.isinstance(n,[_b_.bytes,_b_.bytearray]))e=n.source,t=n.source.length;else{t=(e=_b_.list.$factory(n)).length;for(var s=0;s=128&&(i-=256);var _=256;for(s=1;s0;){var i=Math.floor(s/256),_=s-256*i;if(a.push(_),a.length>r)throw _b_.OverflowError.$factory("int too big to convert");s=i}for(;a.length";var n=preformat(e,r);if(r.comma){for(var o="-"==n[0]?"-":"",a=n.substr(o.length),s=a.length,i=Math.ceil(a.length/3),_=[],l=0;l$B.min_int&&n<$B.max_int?n:int.$factory($B.long_int.__mul__($B.long_int.$factory(e),$B.long_int.$factory(t)));if(_b_.isinstance(t,_b_.float))return new Number(e*_b_.float.numerator(t));if(_b_.isinstance(t,_b_.bool))return t.valueOf()?e:int.$factory(0);if(_b_.isinstance(t,_b_.complex))return $B.make_complex(int.__mul__(e,t.$real),int.__mul__(e,t.$imag));if(_b_.isinstance(t,[_b_.list,_b_.tuple])){for(var n=[],o=t.slice(0,t.length),a=0;a0;)a%2==1&&(n*o>$B.max_int?(n=s.__mul__(s.$factory(n),s.$factory(o)),n=s.__mod__(n,r)):n=n*o%r),a>>=1,o*o>$B.max_int?(o=s.__mul__(s.$factory(o),s.$factory(o)),o=s.__mod__(o,r)):o=o*o%r;return n}var c=Math.pow(e.valueOf(),t.valueOf());return c>$B.min_int&&c<$B.max_int?c:c===1/0||isFinite(c)?$B.BigInt?{__class__:$B.long_int,value:($B.BigInt(e)**$B.BigInt(t)).toString(),pos:!0}:$B.long_int.__pow__($B.long_int.$from_int(e),$B.long_int.$from_int(t)):c}if(_b_.isinstance(t,_b_.float))return t=_b_.float.numerator(t),e>=0?new Number(Math.pow(e,t)):_b_.complex.__pow__($B.make_complex(e,0),t);if(_b_.isinstance(t,_b_.complex)){var u=Math.pow(e,t.$real),f=Math.log(e);return $B.make_complex(u*Math.cos(f),u*Math.sin(f))}var p=$B.$getattr(t,"__rpow__",_b_.None);if(p!==_b_.None)return p(e);$err("**",t)},int.__repr__=function(e){return e===int?"":e.toString()},int.__rshift__=function(e,t){if(_b_.isinstance(t,int))return t=int_value(t),int.$factory($B.long_int.__rshift__($B.long_int.$factory(e),$B.long_int.$factory(t)));var r=$B.$getattr(t,"__rrshift__",_b_.None);if(r!==_b_.None)return r(e);$err(">>",t)},int.__setattr__=function(e,t,r){if("number"==typeof e)throw void 0===int.$factory[t]?_b_.AttributeError.$factory("'int' object has no attribute '"+t+"'"):_b_.AttributeError.$factory("'int' object attribute '"+t+"' is read-only");return _b_.dict.$setitem(e.__dict__,t,r),_b_.None},int.__str__=int.__repr__,int.__truediv__=function(e,t){if(_b_.isinstance(t,int)){if(0==(t=int_value(t)))throw _b_.ZeroDivisionError.$factory("division by zero");return t.__class__===$B.long_int?new Number(e/parseInt(t.value)):new Number(e/t)}if(_b_.isinstance(t,_b_.float)){if(!(t=_b_.float.numerator(t)).valueOf())throw _b_.ZeroDivisionError.$factory("division by zero");return new Number(e/t)}if(_b_.isinstance(t,_b_.complex)){var r=t.$real*t.$real+t.$imag*t.$imag;if(0==r)throw _b_.ZeroDivisionError.$factory("division by zero");return $B.make_complex(e*t.$real/r,-e*t.$imag/r)}if(_b_.hasattr(t,"__rtruediv__"))return $B.$getattr(t,"__rtruediv__")(e);$err("/",t)},int.bit_length=function(e){return s=_b_.bin(e),s=$B.$getattr(s,"lstrip")("-0b"),s.length},int.numerator=function(e){return e},int.denominator=function(e){return int.$factory(1)},int.imag=function(e){return int.$factory(0)},int.real=function(e){return e},$B.max_int32=2147483647,$B.min_int32=-$B.max_int32;var $op_func=function(e,t){if(_b_.isinstance(t,int))return t.__class__===$B.long_int?$B.long_int.__sub__($B.long_int.$factory(e),$B.long_int.$factory(t)):(t=int_value(t),e>$B.max_int32||e<$B.min_int32||t>$B.max_int32||t<$B.min_int32?$B.long_int.__sub__($B.long_int.$factory(e),$B.long_int.$factory(t)):e-t);if(_b_.isinstance(t,_b_.bool))return e-t;var r=$B.$getattr(t,"__rsub__",_b_.None);if(r!==_b_.None)return r(e);$err("-",t)};$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("int.__"+$ops[$op]+"__ = "+opf)}var $op_func=function(e,t){if(_b_.isinstance(t,int)){if("number"==typeof(t=int_value(t))){var r=e.valueOf()-t.valueOf();return r>$B.min_int&&r<$B.max_int?r:$B.long_int.__sub__($B.long_int.$factory(e),$B.long_int.$factory(t))}return"boolean"==typeof t?t?e-1:e:$B.long_int.__sub__($B.long_int.$factory(e),$B.long_int.$factory(t))}if(_b_.isinstance(t,_b_.float))return new Number(e-_b_.float.numerator(t));if(_b_.isinstance(t,_b_.complex))return 0==t.$imag?$B.make_complex(e-t.$real,0):$B.make_complex(e-t.$real,-t.$imag);if(_b_.isinstance(t,_b_.bool)){var n=0;return t.valueOf()&&(n=1),e-n}if(_b_.isinstance(t,_b_.complex))return $B.make_complex(e.valueOf()-t.$real,t.$imag);var o=$B.$getattr(t,"__rsub__",_b_.None);if(o!==_b_.None)return o(e);throw $err("-",t)};$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("int.__"+$ops[$op]+"__ = "+opf)}var $comp_func=function(e,t){return t.__class__===$B.long_int?$B.long_int.__lt__(t,$B.long_int.$factory(e)):_b_.isinstance(t,int)?(t=int_value(t),e.valueOf()>t.valueOf()):_b_.isinstance(t,_b_.float)?e.valueOf()>_b_.float.numerator(t):_b_.isinstance(t,_b_.bool)?e.valueOf()>_b_.bool.__hash__(t):_b_.hasattr(t,"__int__")||_b_.hasattr(t,"__index__")?int.__gt__(e,$B.$GetInt(t)):_b_.NotImplemented};for(var $op in $comp_func+="",$B.$comps)eval("int.__"+$B.$comps[$op]+"__ = "+$comp_func.replace(/>/gm,$op).replace(/__gt__/gm,"__"+$B.$comps[$op]+"__").replace(/__lt__/,"__"+$B.$inv_comps[$op]+"__"));$B.make_rmethods(int);var $valid_digits=function(e){var t="";if(0===e)return"0";if(e<10){for(var r=0;r$B.max_int?$B.long_int.$from_float(e):e>0?Math.floor(e):Math.ceil(e);if(!(t>=2&&t<=36)&&0!=t)throw _b_.ValueError.$factory("invalid base");if("number"==typeof e){if(10==t)return e<$B.min_int||e>$B.max_int?$B.long_int.$factory(e):e;if(e.toString().search("e")>-1)throw _b_.OverflowError.$factory("can't convert to base "+t);var n=parseInt(e,t);return e<$B.min_int||e>$B.max_int?$B.long_int.$factory(e,t):n}if(!0===e)return Number(1);if(!1===e)return Number(0);if(e.__class__===$B.long_int){var o=parseInt(e.value);return o>$B.min_int&&o<$B.max_int?o:e}function a(e,t){throw _b_.ValueError.$factory("invalid literal for int() with base "+t+": '"+_b_.str.$factory(e)+"'")}if(t=$B.$GetInt(t),_b_.isinstance(e,_b_.str)&&(e=e.valueOf()),"string"==typeof e){var s=e.trim();if(2==s.length&&0==t&&("0b"==s||"0o"==s||"0x"==s))throw _b_.ValueError.$factory("invalid value");if(s.length>2){var i=s.substr(0,2).toUpperCase();if(0==t?("0B"==i&&(t=2),"0O"==i&&(t=8),"0X"==i&&(t=16)):("0X"==i&&16!=t||"0O"==i&&8!=t)&&a(s,t),"0B"==i&&2==t||"0O"==i||"0X"==i)for(s=s.substr(2);s.startsWith("_");)s=s.substr(1)}else 0==t&&(t=10);var _=$valid_digits(t),l=new RegExp("^[+-]?["+_+"]["+_+"_]*$","i"),c=l.exec(s);return null===c?a(e,t):e=s.replace(/_/g,""),t<=10&&!isFinite(e)&&a(s,t),(n=parseInt(e,t))<$B.min_int||n>$B.max_int?$B.long_int.$factory(e,t):n}if(_b_.isinstance(e,[_b_.bytes,_b_.bytearray]))return int.$factory($B.$getattr(e,"decode")("latin-1"),t);var u=$B.to_num(e,["__int__","__index__","__trunc__"]);if(null===u)throw _b_.TypeError.$factory("int() argument must be a string, a bytes-like object or a number, not '"+$B.class_name(e)+"'");return u},$B.set_func_names(int,"builtins"),_b_.int=int,$B.$bool=function(e){if(null==e)return!1;switch(typeof e){case"boolean":return e;case"number":case"string":return!!e;default:if(e.$is_class)return!0;var t=e.__class__||$B.get_class(e),r={},n=$B.$getattr(t,"__bool__",r);if(n!==r){var o=$B.$call(n)(e);if(!0!==o&&!1!==o)throw _b_.TypeError.$factory("__bool__ should return bool, returned "+$B.class_name(o));return o}try{return _b_.len(e)>0}catch(e){return!0}}};var bool={__bases__:[int],__class__:_b_.type,__mro__:[int,_b_.object],$infos:{__name__:"bool",__module__:"builtins"},$is_class:!0,$native:!0},methods=$B.op2method.subset("operations","binary","comparisons","boolean");for(var op in methods){var method="__"+methods[op]+"__";bool[method]=function(e){return function(t,r){var n=t?1:0;if(void 0!==int[e])return int[e](n,r)}}(method)}bool.__and__=function(e,t){return _b_.isinstance(t,bool)?e&&t:_b_.isinstance(t,int)?int.__and__(bool.__index__(e),int.__index__(t)):_b_.NotImplemented},bool.__hash__=bool.__index__=bool.__int__=function(e){return e.valueOf()?1:0},bool.__neg__=function(e){return-$B.int_or_bool(e)},bool.__or__=function(e,t){return _b_.isinstance(t,bool)?e||t:_b_.isinstance(t,int)?int.__or__(bool.__index__(e),int.__index__(t)):_b_.NotImplemented},bool.__pos__=$B.int_or_bool,bool.__repr__=bool.__str__=function(e){return e?"True":"False"},bool.__setattr__=function(e,t){if(_b_.dir(e).indexOf(t)>-1)var r="attribute '"+t+"' of 'int' objects is not writable";else r="'bool' object has no attribute '"+t+"'";throw _b_.AttributeError.$factory(r)},bool.__xor__=function(e,t){return _b_.isinstance(t,bool)?!!(e^t):_b_.isinstance(t,int)?int.__xor__(bool.__index__(e),int.__index__(t)):_b_.NotImplemented},bool.$factory=function(){var e=$B.args("bool",1,{x:null},["x"],arguments,{x:!1},null,null);return $B.$bool(e.x)},_b_.bool=bool,$B.set_func_names(bool,"builtins")}(__BRYTHON__),function($B){var bltns=$B.InjectBuiltins();eval(bltns);try{eval("window")}catch(e){window=self}var long_int={__class__:_b_.type,__mro__:[int,object],$infos:{__module__:"builtins",__name__:"int"},$is_class:!0,$native:!0,$descriptors:{numerator:!0,denominator:!0,imag:!0,real:!0}};function add_pos(e,t){if(window.BigInt)return{__class__:long_int,value:(BigInt(e)+BigInt(t)).toString(),pos:!0};for(var r,n="",o=0,a=e.length,s=t.length-1;s>=0;s--)2==(r=(o+(--a<0?0:parseInt(e.charAt(a)))+parseInt(t.charAt(s))).toString()).length?(n=r.charAt(1)+n,o=parseInt(r.charAt(0))):(n=r+n,o=0);for(;a>0;)a--,2==(r=(o+parseInt(e.charAt(a))).toString()).length?(n=r.charAt(1)+n,o=parseInt(r.charAt(0))):(n=r+n,o=0);return o&&(n=o+n),{__class__:long_int,value:n,pos:!0}}var len=(Math.pow(2,53)-1+"").length-1;function binary_pos(e){for(var t,r,n,o,a=Math.ceil(e.length/len),s=[],i=[],_=0;_0;)s.forEach((function(e,t){o=e%2,s[t]=Math.floor(e/2),o&&tt.length?1:e.lengtht?1:e0&&(c+="0".repeat(a-e.toString().length)+e)})),[c,l]}function divmod_pos(e,t){if(window.BigInt)return[{__class__:long_int,value:(BigInt(e)/BigInt(t)).toString(),pos:!0},{__class__:long_int,value:(BigInt(e)%BigInt(t)).toString(),pos:!0}];var r,n=parseInt(e),o=parseInt(t);if(n<$B.max_int&&o<$B.max_int){var a=n%o,s=Math.floor(n/o).toString();return[{__class__:long_int,value:s.toString(),pos:!0},{__class__:long_int,value:a.toString(),pos:!0}]}if(o<$B.max_int){var i=divmod_by_safe_int(e,o);return[long_int.$factory(i[0]),long_int.$factory(i[1])]}if(-1==comp_pos(e,t))_="0",r=long_int.$factory(e);else if(t==e)_="1",r=long_int.$factory("0");else{var _="",l=e.substr(0,t.length);e=0;i--)a--,r=(s=parseInt(e.charAt(a)))-o-parseInt(t.charAt(i)),isNaN(r)&&console.log("x is NaN",e.length,t.length,i,a,s,o,i,t.charAt(i)),r<0?(n=10+r+n,o=1):(n=r+n,o=0);for(n.startsWith("NaN")&&alert(n);a>0;)a--,(r=parseInt(e.charAt(a))-o)<0?(n=10+r+n,o=1):(n=r+n,o=0);for(;"0"==n.charAt(0)&&n.length>1;)n=n.substr(1);return n.startsWith("NaN")&&console.log("hoho !!",e,t,e>=t,n),{__class__:long_int,value:n,pos:!0}}function to_BigInt(e){var t=$B.BigInt(e.value);return e.pos?t:-t}function from_BigInt(e){var t=e>=0;return e=(e=(e=e.toString()).endsWith("n")?e.substr(0,e.length-1):e).startsWith("-")?e.substr(1):e,intOrLong({__class__:long_int,value:e,pos:t})}function digits(e){for(var t={},r=0;r10)for(r=0;r-1){var n=/-?(\d)(\.\d+)?e([+-])(\d*)/.exec(t),o=n[1],a=n[2],s=n[3],i=n[4];"+"==s&&(r=void 0===a?o+"0".repeat(i-1):o+a+"0".repeat(i-1-a.length))}return{__class__:long_int,value:r,pos:e>=0}},long_int.__abs__=function(e){return{__class__:long_int,value:e.value,pos:!0}},long_int.__add__=function(e,t){if(isinstance(t,_b_.float))return _b_.float.$factory(parseInt(e.value)+t.value);if("number"==typeof t)t=long_int.$factory(_b_.str.$factory(t));else if(t.__class__!==long_int)if(isinstance(t,_b_.bool))t=long_int.$factory(t?1:0);else{if(!isinstance(t,int))return _b_.NotImplemented;t=long_int.$factory(_b_.str.$factory(_b_.int.__index__(t)))}var r;if($B.BigInt,e.pos&&t.pos)return add_pos(e.value,t.value);if(e.pos||t.pos){if(e.pos&&!t.pos){switch(comp_pos(e.value,t.value)){case 1:r=sub_pos(e.value,t.value);break;case 0:r={__class__:long_int,value:0,pos:!0};break;case-1:(r=sub_pos(t.value,e.value)).pos=!1}return intOrLong(r)}switch(comp_pos(e.value,t.value)){case 1:(r=sub_pos(e.value,t.value)).pos=!1;break;case 0:r={__class__:long_int,value:0,pos:!0};break;case-1:r=sub_pos(t.value,e.value)}return intOrLong(r)}return(r=add_pos(e.value,t.value)).pos=!1,intOrLong(r)},long_int.__and__=function(e,t){if("number"==typeof t&&(t=long_int.$factory(_b_.str.$factory(t))),$B.BigInt)return from_BigInt(to_BigInt(e)&to_BigInt(t));e.value,t.value;var r="",n=!e.pos&&!t.pos;n&&(e=long_int.__neg__(e),t=long_int.__neg__(t));var o,a,s=binary(e),i=s.length,_=binary(t),l=_.length,c=1;for(r="";!(c>i&&c>l);)o=c>i?e.pos?"0":"1":s.charAt(i-c),a=c>l?t.pos?"0":"1":_.charAt(l-c),r="1"==o&&"1"==a?"1"+r:"0"+r,c++;for(;"0"==r.charAt(0);)r=r.substr(1);return r=$B.long_int.$factory(r,2),n&&(r.pos=!1),intOrLong(r)},long_int.__divmod__=function(e,t){"number"==typeof t&&(t=long_int.$factory(_b_.str.$factory(t)));var r=divmod_pos(e.value,t.value);return e.pos!==t.pos&&("0"!=r[0].value&&(r[0].pos=!1),"0"!=r[1].value&&(r[0]=long_int.__sub__(r[0],long_int.$factory("1")),r[1]=long_int.__sub__(e,long_int.__mul__(t,long_int.$factory(r[0]))))),$B.fast_tuple([intOrLong(r[0]),intOrLong(r[1])])},long_int.__eq__=function(e,t){return"number"==typeof t&&(t=long_int.$factory(_b_.str.$factory(t))),e.value==t.value&&e.pos==t.pos},long_int.__float__=function(e){return new Number(parseFloat(e.value))},long_int.__floordiv__=function(e,t){if(isinstance(t,_b_.float))return _b_.float.$factory(parseInt(e.value)/t);if("number"==typeof t){var r=divmod_by_safe_int(e.value,t),n=t>0?e.pos:!e.pos;return{__class__:long_int,value:r[0],pos:n}}return intOrLong(long_int.__divmod__(e,t)[0])},long_int.__ge__=function(e,t){return"number"==typeof t&&(t=long_int.$factory(_b_.str.$factory(t))),e.pos!=t.pos?!t.pos:e.value.length>t.value.length?e.pos:e.value.length=t.value:e.value<=t.value},long_int.__gt__=function(e,t){return!long_int.__le__(e,t)},long_int.__index__=function(e){for(var t,r="",n=e.value;r=(t=divmod_pos(n,"2"))[1].value+r,"0"!=(n=t[0].value););if(e.pos)r="0"+r;else{for(var o="",a=!1,s=r.length-1;s>=0;s--){"0"==r.charAt(s)?o=a?"1"+o:"0"+o:a?o="0"+o:(a=!0,o="1"+o)}r=o="1"+o}return intOrLong(r)},long_int.__invert__=function(e){return long_int.__sub__(long_int.$factory("-1"),e)},long_int.__le__=function(e,t){return"number"==typeof t&&(t=long_int.$factory(_b_.str.$factory(t))),e.pos!==t.pos||e.value.length>t.value.length?!e.pos:e.value.length=t.value},long_int.__lt__=function(e,t){return!long_int.__ge__(e,t)},long_int.__lshift__=function(e,t){if(window.BigInt)return t.__class__==long_int&&(t=t.value),intOrLong({__class__:long_int,value:(BigInt(e.value)<=0;_--)2==(a=(s+2*parseInt(o.charAt(_))).toString()).length?(i=a.charAt(1)+i,s=parseInt(a.charAt(0))):(i=a+i,s=0);if(s&&(i=s+i),o=i,r){if(0==--t)break}else if("0"==(t=sub_pos(t.value,"1")).value)break}return intOrLong({__class__:long_int,value:o,pos:e.pos})},long_int.__mod__=function(e,t){return intOrLong(long_int.__divmod__(e,t)[1])},long_int.__mro__=[_b_.int,_b_.object],long_int.__mul__=function(e,t){switch(e){case Number.NEGATIVE_INFINITY:case Number.POSITIVE_INFINITY:return $B.rich_comp("__eq__",t,0)?NaN:_b_.getattr(t,"__gt__")(0)?e:-e}if(isinstance(t,_b_.float))return _b_.float.$factory(parseInt(e.value)*t);if("number"==typeof t&&(t=long_int.$factory(t)),other_value=t.value,other_pos=t.pos,t.__class__!==long_int&&isinstance(t,int)){var r=int.__index__(t);other_value=_b_.str.$factory(r),other_pos=r>0}if($B.BigInt)return from_BigInt(to_BigInt(e)*to_BigInt(t));var n=mul_pos(e.value,other_value);return e.pos==other_pos||(n.pos=!1),intOrLong(n)},long_int.__neg__=function(e){return{__class__:long_int,value:e.value,pos:!e.pos}},long_int.__or__=function(e,t){t=long_int.$factory(t);var r=long_int.__index__(e),n=long_int.__index__(t);if(r.length0;)a%$B.BigInt(2)==1&&(o*=n),(a/=$B.BigInt(2))>0&&(n*=n),void 0!==r&&(o%=r);return{__class__:long_int,value:o.toString(),pos:!0}}o={__class__:long_int,value:"1",pos:!0},n=e;for(var s,i=t.value;"string"==typeof i&&parseInt(i)<$B.max_int&&(i=parseInt(i)),0!=i;)"string"==typeof i?(parseInt(i.charAt(i.length-1))%2==1&&(o=long_int.__mul__(o,n)),i=long_int.__floordiv__(i,2)):(i%2==1&&(o="number"==typeof o&&"number"==typeof n&&(s=o*n)<$B.max_int?s:long_int.__mul__(long_int.$factory(o),long_int.$factory(n))),i=Math.floor(i/2)),i>0&&("number"==typeof n&&(s=n*n)<$B.max_int?n=s:(n=long_int.$factory(n),n=long_int.__mul__(n,n))),void 0!==r&&(o=long_int.__mod__(o,r));return intOrLong(o)},long_int.__rshift__=function(e,t){if(window.BigInt)return t.__class__===long_int&&(t=t.value),intOrLong({__class__:long_int,value:(BigInt(e.value)>>BigInt(t)).toString(),pos:e.pos});if("number"==typeof t){var r=Math.pow(2,t);if(r<$B.max_int){var n=divmod_by_safe_int(e.value,r);return intOrLong({__class__:long_int,value:n[0],pos:e.pos})}}if("0"==(t=long_int.$factory(t)).value)return e;for(n=e.value;"0"!=(n=divmod_pos(n,"2")[0].value).value&&"0"!=(t=sub_pos(t.value,"1")).value;);return intOrLong({__class__:long_int,value:n,pos:e.pos})},long_int.__str__=long_int.__repr__=function(e){var t="";return e.pos||(t+="-"),t+e.value},long_int.__sub__=function(e,t){if(isinstance(t,_b_.float))return t=t instanceof Number?t:t.$brython_value,_b_.float.$factory(parseInt(e.value)-t);var r;if("number"==typeof t&&(t=long_int.$factory(_b_.str.$factory(t))),$B.BigInt,e.pos&&t.pos){switch(comp_pos(e.value,t.value)){case 1:r=sub_pos(e.value,t.value);break;case 0:r={__class__:long_int,value:"0",pos:!0};break;case-1:(r=sub_pos(t.value,e.value)).pos=!1}return intOrLong(r)}if(e.pos||t.pos)return e.pos&&!t.pos?intOrLong(add_pos(e.value,t.value)):((r=add_pos(e.value,t.value)).pos=!1,intOrLong(r));switch(comp_pos(e.value,t.value)){case 1:(r=sub_pos(e.value,t.value)).pos=!1;break;case 0:r={__class__:long_int,value:"0",pos:!0};break;case-1:r=sub_pos(t.value,e.value)}return intOrLong(r)},long_int.__truediv__=function(e,t){if(isinstance(t,long_int))return _b_.float.$factory(parseInt(e.value)/parseInt(t.value));if(isinstance(t,_b_.int))return _b_.float.$factory(parseInt(e.value)/t);if(isinstance(t,_b_.float))return _b_.float.$factory(parseInt(e.value)/t);throw TypeError.$factory("unsupported operand type(s) for /: 'int' and '"+$B.class_name(t)+"'")},long_int.__xor__=function(e,t){t=long_int.$factory(t);var r=long_int.__index__(e),n=long_int.__index__(t);if(r.length0;){var o=divmod_pos(n,t.toString());if(r=parseInt(o[1].value).toString(t)+r,0==(n=o[0].value))break}return r},long_int.to_bytes=function(e,t,r,n){var o=[],a=e.value;if(!$B.$bool(n)&&!e.pos)throw _b_.OverflowError.$factory("can't convert negative int to unsigned");for(;a>0;){var s=divmod_pos(a,256);if(a=parseInt(s[0].value),o.push(parseInt(s[1].value)),o.length>t)throw _b_.OverflowError.$factory("int too big to convert")}for(;o.lengthMIN_SAFE_INTEGER&&t0}},long_int.$factory=function(e,t){if(arguments.length>2)throw _b_.TypeError.$factory("long_int takes at most 2 arguments ("+arguments.length+" given)");if(void 0===t)t=10;else if(!isinstance(t,int))throw TypeError.$factory("'"+$B.class_name(t)+"' object cannot be interpreted as an integer");if(t<0||1==t||t>36)throw ValueError.$factory("long_int.$factory() base must be >= 2 and <= 36");if("number"==typeof e){var r=e>=0;if(isSafeInteger(e=Math.abs(e)))_=long_int.$from_int(e);else{if(e.constructor!=Number)throw ValueError.$factory("argument of long_int is not a safe integer");var n=e.toString(),o=n.search("e");if(o>-1){var a=n.substr(0,o),s=parseInt(n.substr(o+1));if((f=a.search(/\./))>-1){var i=a.substr(f+1).length;if(i>s){var _=a.substr(0,f)+a.substr(f+1).substr(0,s);_=long_int.$from_int(_)}else{_=a.substr(0,f)+a.substr(f+1)+"0".repeat(s-i);_=long_int.$from_int(_)}}else _=long_int.$from_int(a+"0".repeat(s))}else{_=(f=n.search(/\./))>-1?long_int.$from_int(n.substr(0,f)):long_int.$from_int(n)}}return _.pos=r,_}if(isinstance(e,_b_.float)){if(e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY)return e;e=new Number(e>=0?Math.round(e.value):Math.ceil(e.value))}else{if(isinstance(e,_b_.bool))return e.valueOf()?int.$factory(1):int.$factory(0);if(e.__class__===long_int)return e;if(isinstance(e,int))e=e.$brython_value+"";else if(isinstance(e,_b_.bool))e=_b_.bool.__int__(e)+"";else if("string"!=typeof e)throw ValueError.$factory("argument of long_int must be a string, not "+$B.class_name(e))}for(var l=!1,c=(r=!0,0);" "==e.charAt(0)&&e.length;)e=e.substr(1);for(;" "==e.charAt(e.length-1)&&e.length;)e=e.substr(0,e.length-1);if("+"==e.charAt(0)?l=!0:"-"==e.charAt(0)&&(l=!0,r=!1),l){if(1==e.length)throw ValueError.$factory('long_int argument is not a valid number: "'+e+'"');e=e.substr(1)}for(;c0||isNaN(e.$imag)?"("+t+"+"+r+"j)":0==e.$imag?1/e.$imag<0?"("+t+"-0j)":"("+t+"+0j)":"("+t+"-"+_b_.str.$factory(-e.$imag)+"j)"},complex.__sqrt__=function(e){if(0==e.$imag)return complex(Math.sqrt(e.$real));var t=e.$real,r=e.$imag,n=Math.sqrt((t+sqrt)/2),o=Number.sign(r)*Math.sqrt((-t+sqrt)/2);return make_complex(n,o)},complex.__truediv__=function(e,t){if(_b_.isinstance(t,complex)){if(0==t.$real&&0==t.$imag)throw _b_.ZeroDivisionError.$factory("division by zero");var r=e.$real*t.$real+e.$imag*t.$imag,n=t.$real*t.$real+t.$imag*t.$imag,o=e.$imag*t.$real-e.$real*t.$imag;return make_complex(r/n,o/n)}if(_b_.isinstance(t,_b_.int)){if(!t.valueOf())throw _b_.ZeroDivisionError.$factory("division by zero");return complex.__truediv__(e,complex.$factory(t.valueOf()))}if(_b_.isinstance(t,_b_.float)){if(!t.valueOf())throw _b_.ZeroDivisionError.$factory("division by zero");return complex.__truediv__(e,complex.$factory(t.valueOf()))}$UnsupportedOpType("//","complex",t.__class__)},complex.conjugate=function(e){return make_complex(e.$real,-e.$imag)};var $op_func=function(e,t){throw _b_.TypeError.$factory("TypeError: unsupported operand type(s) for -: 'complex' and '"+$B.class_name(t)+"'")};$op_func+="";var $ops={"&":"and","|":"ior","<<":"lshift",">>":"rshift","^":"xor"};for(var $op in $ops)eval("complex.__"+$ops[$op]+"__ = "+$op_func.replace(/-/gm,$op));complex.__ior__=complex.__or__;var $op_func=function(e,t){if(_b_.isinstance(t,complex))return make_complex(e.$real-t.$real,e.$imag-t.$imag);if(_b_.isinstance(t,_b_.int))return make_complex($B.sub(e.$real,t.valueOf()),e.$imag);if(_b_.isinstance(t,_b_.float))return make_complex(e.$real-t.valueOf(),e.$imag);if(_b_.isinstance(t,_b_.bool)){var r=0;return t.valueOf()&&(r=1),make_complex(e.$real-r,e.$imag)}throw _b_.TypeError.$factory("unsupported operand type(s) for -: "+e.__repr__()+" and '"+$B.class_name(t)+"'")};complex.__sub__=$op_func,$op_func+="",$op_func=$op_func.replace(/-/gm,"+").replace(/sub/gm,"add"),eval("complex.__add__ = "+$op_func);var $comp_func=function(e,t){if(void 0===t||t==_b_.None)return _b_.NotImplemented;throw _b_.TypeError.$factory("TypeError: no ordering relation is defined for complex numbers")};for(var $op in $comp_func+="",$B.$comps)eval("complex.__"+$B.$comps[$op]+"__ = "+$comp_func.replace(/>/gm,$op));$B.make_rmethods(complex),complex.real=function(e){return new Number(e.$real)},complex.real.setter=function(){throw _b_.AttributeError.$factory("readonly attribute")},complex.imag=function(e){return new Number(e.$imag)},complex.imag.setter=function(){throw _b_.AttributeError.$factory("readonly attribute")};var _real=1,_real_mantissa=2,_sign=3,_imag=4,_imag_mantissa=5,_j=6,type_conversions=["__complex__","__float__","__index__"],_convert=function(e){for(var t=e.__class__||$B.get_class(e),r=0;r=0)return-1;if(e>=0)return 1;e=-e,n=-n}al=r(e),bl=r(n);var o=0;return albl&&(n*=t[al-bl-1],e/=10,o=1),e===n?o:e=0;)o++;return o-t}function a(e,t,r,n,o){for(n===t&&n++;n>>1;o(a,e[_])<0?i=_:s=_+1}var l=n-s;switch(l){case 3:e[s+3]=e[s+2];case 2:e[s+2]=e[s+1];case 1:e[s+1]=e[s];break;default:for(;l>0;)e[s+l]=e[s+l-1],l--}e[s]=a}}function s(e,t,r,n,o,a){var s=0,i=0,_=1;if(a(e,t[r+o])>0){for(i=n-o;_0;)s=_,(_=1+(_<<1))<=0&&(_=i);_>i&&(_=i),s+=o,_+=o}else{for(i=o+1;_i&&(_=i);var l=s;s=o-_,_=o-l}for(s++;s<_;){var c=s+(_-s>>>1);a(e,t[r+c])>0?s=c+1:_=c}return _}function i(e,t,r,n,o,a){var s=0,i=0,_=1;if(a(e,t[r+o])<0){for(i=o+1;_i&&(_=i);var l=s;s=o-_,_=o-l}else{for(i=n-o;_=0;)s=_,(_=1+(_<<1))<=0&&(_=i);_>i&&(_=i),s+=o,_+=o}for(s++;s<_;){var c=s+(_-s>>>1);a(e,t[r+c])<0?_=c:s=c+1}return _}var _="TimSortAssertion",l=function(e){this.name=_,this.message=e},c=function(e,t){var r={array:e,compare:t,minGallop:7,length:e.length,tmpStorageLength:256,stackLength:0,runStart:null,runLength:null,stackSize:0,pushRun:function(e,t){this.runStart[this.stackSize]=e,this.runLength[this.stackSize]=t,this.stackSize+=1},mergeRuns:function(){for(;this.stackSize>1;){var e=this.stackSize-2;if(e>=1&&this.runLength[e-1]<=this.runLength[e]+this.runLength[e+1]||e>=2&&this.runLength[e-2]<=this.runLength[e]+this.runLength[e-1])this.runLength[e-1]this.runLength[e+1])break;this.mergeAt(e)}},forceMergeRuns:function(){for(;this.stackSize>1;){var e=this.stackSize-2;e>0&&this.runLength[e-1]=7||h>=7);if(m)break;$<0&&($=0),$+=2}if(this.minGallop=$,$<1&&(this.minGallop=1),1===t){for(c=0;c=0;c--)a[d+c]=a[$+c];if(0===t){b=!0;break}}if(a[p--]=_[f--],1==--n){b=!0;break}if(0!==(g=n-s(a[u],_,0,n,n-1,o))){n-=g,d=(p-=g)+1,$=(f-=g)+1;for(c=0;c=7||g>=7);if(b)break;h<0&&(h=0),h+=2}if(this.minGallop=h,h<1&&(this.minGallop=1),1===n){d=(p-=t)+1,$=(u-=t)+1;for(c=t-1;c>=0;c--)a[d+c]=a[$+c];a[p]=_[f]}else{if(0==n)throw new l("mergeHigh preconditions were not respected");$=p-(n-1);for(c=0;c=0;c--)a[d+c]=a[$+c];a[p]=_[f]}else{$=p-(n-1);for(var c=0;c>>1),r.tmp=new Array(r.tmpStorageLength),r.stackLength=r.length<120?5:r.length<1542?10:r.length<119151?19:40,r.runStart=new Array(r.stackLength),r.runLength=new Array(r.stackLength),r};e.$TimSort=function(e,t){try{!function(e,t,r,s){if(!Array.isArray(e))throw TypeError.$factory("Can only sort arrays");t?"function"!=typeof t&&(s=r,r=t,t=n):t=n,r||(r=0),s||(s=e.length);var i=s-r;if(!(i<2)){var _=0;if(i<32)a(e,r,s,r+(_=o(e,r,s,t)),t);else{var l=new c(e,t),u=function(e){for(var t=0;e>=32;)t|=1&e,e>>=1;return e+t}(i);do{if((_=o(e,r,s,t))u&&(f=u),a(e,r,r+f,r+_,t),_=f}l.pushRun(r,_),l.mergeRuns(),i-=_,r+=_}while(0!==i);l.forceMergeRuns()}}}(e,t,0,e.length)}catch(r){if(r.name!=_)throw r;e.sort(t)}},e.$AlphabeticalCompare=n}(__BRYTHON__),function(e){var t=e.builtins,r=t.object,n=e.$getattr,o=t.isinstance,a=t.None;function i(e,r){if(e.__class__===$)throw t.AttributeError.$factory("'tuple' object has no attribute '"+r+"'")}var _={__class__:t.type,__mro__:[r],$infos:{__module__:"builtins",__name__:"list"},$is_class:!0,$native:!0,__dir__:r.__dir__,__add__:function(r,a){if(e.get_class(r)!==e.get_class(a)){var s=n(a,"__radd__",t.NotImplemented);if(s!==t.NotImplemented)return s(r);throw t.TypeError.$factory('can only concatenate list (not "'+e.class_name(a)+'") to list')}var i=r.slice(),_="js"==a.$brython_class;for(const t of a)i.push(_?e.$JS2Py(t):t);return i.__brython__=!0,o(r,$)&&(i=$.$factory(i)),i},__class_getitem__:function(t,r){return Array.isArray(r)||(r=[r]),e.GenericAlias.$factory(t,r)},__contains__:function(t,r){for(var n=e.args("__contains__",2,{self:null,item:null},["self","item"],arguments,{},null,null),o=(t=n.self,r=n.item,function(t){return e.rich_comp("__eq__",r,t)}),a=0;a=0&&s0?0:r.length);var c=n.stop;c===a&&(c=i>0?r.length:0),l<0&&(l=r.length+l),c<0&&(c=r.length+c);var u=[],f=null;s=0;if(i>0){if(c>l)for(f=l;fc;f+=i)void 0!==r[f]&&(u[s++]=f);u.reverse()}for(f=u.length;f--;)r.splice(u[f],1);return a}if(t.hasattr(n,"__int__")||t.hasattr(n,"__index__"))return _.__delitem__(r,t.int.$factory(n)),a;throw t.TypeError.$factory(e.class_name(r)+" indices must be integer, not "+e.class_name(n))},__eq__:function(r,n){if(o(r,_))var a=_;else a=$;if(o(n,a)&&n.length==r.length){for(var s=r.length;s--;)if(!e.rich_comp("__eq__",r[s],n[s]))return!1;return!0}return t.NotImplemented},__getitem__:function(t,r){return e.check_no_kw("__getitem__",t,r),e.check_nb_args("__getitem__",2,arguments),_.$getitem(t,r)},$getitem:function(r,n){var a=(r.__class__||e.get_class(r)).$factory;try{var s=e.$GetInt(n),i=r.valueOf(),l=s;if(s<0&&(l=i.length+l),l>=0&&l0){if($<=p)return a(u);for(f=p;f<$;f+=d)u[l++]=i[f];return a(u)}if($>p)return a(u);for(f=p;f>$;f+=d)u[l++]=i[f];return a(u)}if(t.hasattr(n,"__int__")||t.hasattr(n,"__index__"))return _.__getitem__(r,t.int.$factory(n));throw t.TypeError.$factory(e.class_name(r)+" indices must be integer, not "+e.class_name(n))},__ge__:function(r,a){if(!o(a,[_,t.tuple]))return t.NotImplemented;for(var s=0;s=a.length)return!0;if(!e.rich_comp("__eq__",r[s],a[s])){if(res=n(r[s],"__ge__")(a[s]),res===t.NotImplemented)throw t.TypeError.$factory("unorderable types: "+e.class_name(r[s])+"() >= "+e.class_name(a[s])+"()");return res}s++}return a.length==r.length},__gt__:function(r,a){if(!o(a,[_,t.tuple]))return t.NotImplemented;for(var s=0;s=a.length)return!0;if(!e.rich_comp("__eq__",r[s],a[s])){if(res=n(r[s],"__gt__")(a[s]),res===t.NotImplemented)throw t.TypeError.$factory("unorderable types: "+e.class_name(r[s])+"() > "+e.class_name(a[s])+"()");return res}s++}return!1}};_.__hash__=a,_.__iadd__=function(){var r=e.args("__iadd__",2,{self:null,x:null},["self","x"],arguments,{},null,null),o=n(r.x,"__radd__",t.NotImplemented);if(o!==t.NotImplemented)return o(r.self);for(var a=_.$factory(e.$iter(r.x)),s=0;s=a.length)return!1;if(!e.rich_comp("__eq__",r[s],a[s])){if(res=n(r[s],"__lt__")(a[s]),res===t.NotImplemented)throw t.TypeError.$factory("unorderable types: "+e.class_name(r[s])+"() >= "+e.class_name(a[s])+"()");return res}s++}return a.length>r.length},_.__mul__=function(r,n){if(o(n,t.int)){for(var a=[],s=r.slice(),i=s.length,l=0;l=0&&i"},_)void 0===e.JSArray[p]&&"function"==typeof _[p]&&(e.JSArray[p]=function(t){return function(){return e.$JS2Py(_[t].apply(null,f(arguments)))}}(p));e.set_func_names(e.JSArray,"builtins");var $={__class__:t.type,__mro__:[r],$infos:{__module__:"builtins",__name__:"tuple"},$is_class:!0,$native:!0},d=e.make_iterator_class("tuple_iterator");for(var p in $.__iter__=function(e){return d.$factory(e)},$.$factory=function(){var e=_.$factory(...arguments);return e.__class__=$,e},e.fast_tuple=function(t){return t.__class__=$,t.__brython__=!0,t.__dict__=e.empty_dict(),t},_)switch(p){case"__delitem__":case"__iadd__":case"__imul__":case"__setitem__":case"append":case"extend":case"insert":case"remove":case"reverse":break;default:void 0===$[p]&&"function"==typeof _[p]&&($[p]=function(e){return function(){return _[e].apply(null,arguments)}}(p))}$.__eq__=function(e,t){return void 0===t?e===$:_.__eq__(e,t)},$.__hash__=function(e){for(var r,n=54880137,o=0,a=e.length;o=t[r][0]&&e' requires string as left operand, not "+t.__class__);if("string"==typeof t)var r=t.length;else r=_b_.len(t);if(0==r)return!0;if(0==e.length)return 0==r;for(var n=0,o=e.length;n=0&&r0){if(a<=o)return"";for(_=o;_=o)return"";for(_=o;_>a;_+=s)i+=e.charAt(_)}return i}if(isinstance(t,_b_.bool))return e.__getitem__(_b_.int.$factory(t));throw _b_.TypeError.$factory("string indices must be integers")};var prefix=2,suffix=3,mask=2**32-1,str_hash_cache={};function fnv(e){if(0==e.length)return 0;var t=prefix;t=(t^e.charCodeAt(0)<<7)&mask;for(var r=0,n=e.length;r1e5&&(str.$nb_str_hash_cache=0,str_hash_cache={}),str_hash_cache[e]=fnv(e))},str.__init__=function(e,t){return e.valueOf=function(){return t},e.toString=function(){return t},_b_.None};var str_iterator=$B.make_iterator_class("str_iterator");str.__iter__=function(e){var t=e.split("");return str_iterator.$factory(t)},str.__len__=function(e){return e.length};var kwarg_key=new RegExp("([^\\)]*)\\)"),NotANumber=function(){this.name="NotANumber"},number_check=function(e){if(!isinstance(e,[_b_.int,_b_.float]))throw new NotANumber},get_char_array=function(e,t){return e<=0?"":new Array(e+1).join(t)},format_padding=function(e,t,r){var n=t.padding;return n?(e=e.toString(),n=parseInt(n,10),r&&(n-=1),t.left?e+get_char_array(n-e.length,t.pad_char):get_char_array(n-e.length,t.pad_char)+e):e},format_int_precision=function(e,t){var r,n=t.precision;return n?(n=parseInt(n,10),"-"===(r=e.__class__===$B.long_int?$B.long_int.to_base(e,10):e.toString())[0]?"-"+get_char_array(n-r.length+1,"0")+r.slice(1):get_char_array(n-r.length,"0")+r):e.toString()},format_float_precision=function(e,t,r,n){var o=r.precision;return isFinite(e)?n(e,o,r,t):(e=e===1/0?"inf":e===-1/0?"-inf":"nan",t?e.toUpperCase():e)},format_sign=function(e,t){if(t.sign){if(e>=0)return"+"}else if(t.space&&e>=0)return" ";return""},str_format=function(e,t){return t.pad_char=" ",format_padding(str.$factory(e),t)},num_format=function(e,t){number_check(e),e=e.__class__===$B.long_int?$B.long_int.to_base(e,10):parseInt(e);var r=format_int_precision(e,t);if("0"===t.pad_char){if(e<0)return r=r.substring(1),"-"+format_padding(r,t,!0);var n=format_sign(e,t);if(""!==n)return n+format_padding(r,t,!0)}return format_padding(format_sign(e,t)+r,t)},repr_format=function(e,t){return t.pad_char=" ",format_padding(repr(e),t)},ascii_format=function(e,t){return t.pad_char=" ",format_padding(ascii(e),t)},_float_helper=function(e,t){return number_check(e),t.precision?(t.precision=parseInt(t.precision,10),validate_precision(t.precision)):t.decimal_point?t.precision=0:t.precision=6,parseFloat(e)},trailing_zeros=/(.*?)(0+)([eE].*)/,leading_zeros=/\.(0*)/,trailing_dot=/\.$/,validate_precision=function(e){e>20&&(e=20)},floating_point_format=function(e,t,r){if(e=_float_helper(e,r),v=e.toString(),v_len=v.length,dot_idx=v.indexOf("."),dot_idx<0&&(dot_idx=v_len),e<1&&e>-1){var n,o=leading_zeros.exec(v);if((n=o?o[1].length:0)>=4){if(e=format_sign(e,r)+format_float_precision(e,t,r,_floating_g_exp_helper),r.alternate)r.precision<=1&&(e=e[0]+"."+e.substring(1));else(a=trailing_zeros.exec(e))&&(e=a[1].replace(trailing_dot,"")+a[3]);return format_padding(e,r)}return r.precision=(r.precision||0)+n,format_padding(format_sign(e,r)+format_float_precision(e,t,r,(function(e,t){return e.toFixed(min(t,v_len-dot_idx)+n)})),r)}if(dot_idx>r.precision){var a;if(e=format_sign(e,r)+format_float_precision(e,t,r,_floating_g_exp_helper),r.alternate)r.precision<=1&&(e=e[0]+"."+e.substring(1));else(a=trailing_zeros.exec(e))&&(e=a[1].replace(trailing_dot,"")+a[3]);return format_padding(e,r)}return format_padding(format_sign(e,r)+format_float_precision(e,t,r,(function(e,t){return r.decimal_point?t>v_len&&(r.alternate||(t=v_len)):t=min(v_len-1,6),te.length-4&&(e=e.substring(0,o+2)+"0"+e.substring(o+2)),n?e.toUpperCase():e},floating_point_decimal_format=function(e,t,r){return e=_float_helper(e,r),format_padding(format_sign(e,r)+format_float_precision(e,t,r,(function(e,t,r){return e=e.toFixed(t),0===t&&r.alternate&&(e+="."),e})),r)},_floating_exp_helper=function(e,t,r,n){var o=(e=e.toExponential(t)).lastIndexOf("e");return o>e.length-4&&(e=e.substring(0,o+2)+"0"+e.substring(o+2)),n?e.toUpperCase():e},floating_point_exponential_format=function(e,t,r){return e=_float_helper(e,r),format_padding(format_sign(e,r)+format_float_precision(e,t,r,_floating_exp_helper),r)},signed_hex_format=function(e,t,r){var n;if(number_check(e),n=e.__class__===$B.long_int?$B.long_int.to_base(e,16):(n=parseInt(e)).toString(16),n=format_int_precision(n,r),t&&(n=n.toUpperCase()),"0"===r.pad_char){e<0&&(n=n.substring(1),n="-"+format_padding(n,r,!0));var o=format_sign(e,r);""!==o&&(n=o+format_padding(n,r,!0))}return r.alternate&&(n="-"===n.charAt(0)?t?"-0X"+n.slice(1):"-0x"+n.slice(1):t?"0X"+n:"0x"+n),format_padding(format_sign(e,r)+n,r)},octal_format=function(e,t){var r;if(number_check(e),r=e.__class__===$B.long_int?$B.long_int.to_base(8):(r=parseInt(e)).toString(8),r=format_int_precision(r,t),"0"===t.pad_char){e<0&&(r=r.substring(1),r="-"+format_padding(r,t,!0));var n=format_sign(e,t);""!==n&&(r=n+format_padding(r,t,!0))}return t.alternate&&(r="-"===r.charAt(0)?"-0o"+r.slice(1):"0o"+r),format_padding(r,t)};function series_of_bytes(e,t){if(e.__class__&&e.__class__.$buffer_protocol)for(var r=_b_.iter(e),n=[];;)try{n.push(_b_.next(r))}catch(e){if(e.__class__===_b_.StopIteration){var o=_b_.bytes.$factory(n);return format_padding(_b_.bytes.decode(o,"ascii"),t)}throw e}else try{return bytes_obj=$B.$getattr(e,"__bytes__"),format_padding(_b_.bytes.decode(bytes_obj),t)}catch(t){if(t.__class__===_b_.AttributeError)throw _b_.TypeError.$factory("%b does not accept '"+$B.class_name(e)+"'");throw t}}var single_char_format=function(e,t){if(isinstance(e,str)&&1==e.length)return e;if(isinstance(e,bytes)&&1==e.source.length)e=e.source[0];else try{e=_b_.int.$factory(e)}catch(e){throw _b_.TypeError.$factory("%c requires int or char")}return format_padding(chr(e),t)},num_flag=function(e,t){"0"!==e||t.padding||t.decimal_point||t.left?t.decimal_point?t.precision=(t.precision||"")+e:t.padding=(t.padding||"")+e:t.pad_char="0"},decimal_point_flag=function(e,t){if(t.decimal_point)throw new UnsupportedChar;t.decimal_point=!0},neg_flag=function(e,t){t.pad_char=" ",t.left=!0},space_flag=function(e,t){t.space=!0},sign_flag=function(e,t){t.sign=!0},alternate_flag=function(e,t){t.alternate=!0},char_mapping={b:series_of_bytes,s:str_format,d:num_format,i:num_format,u:num_format,o:octal_format,r:repr_format,a:ascii_format,g:function(e,t){return floating_point_format(e,!1,t)},G:function(e,t){return floating_point_format(e,!0,t)},f:function(e,t){return floating_point_decimal_format(e,!1,t)},F:function(e,t){return floating_point_decimal_format(e,!0,t)},e:function(e,t){return floating_point_exponential_format(e,!1,t)},E:function(e,t){return floating_point_exponential_format(e,!0,t)},x:function(e,t){return signed_hex_format(e,!1,t)},X:function(e,t){return signed_hex_format(e,!0,t)},c:single_char_format,0:function(e,t){return num_flag("0",t)},1:function(e,t){return num_flag("1",t)},2:function(e,t){return num_flag("2",t)},3:function(e,t){return num_flag("3",t)},4:function(e,t){return num_flag("4",t)},5:function(e,t){return num_flag("5",t)},6:function(e,t){return num_flag("6",t)},7:function(e,t){return num_flag("7",t)},8:function(e,t){return num_flag("8",t)},9:function(e,t){return num_flag("9",t)},"-":neg_flag," ":space_flag,"+":sign_flag,".":decimal_point_flag,"#":alternate_flag},UnsupportedChar=function(){this.name="UnsupportedChar"};str.__mod__=function(e,t){var r,n=e.length,o=0,a=null;_b_.isinstance(t,_b_.tuple)?a=0:r=_b_.getattr(t,"__getitem__",_b_.None);var s="",i=function(e){++o;var t=kwarg_key.exec(e.substring(u));if(!t)throw _b_.ValueError.$factory("incomplete format key");var n=t[1];u+=t[0].length;try{var a=r(n)}catch(e){if(e.__class__===_b_.KeyError)throw e;throw _b_.TypeError.$factory("format requires a mapping")}return l(e,a)},_=function(e){var r;if(null===a)r=t;else if(void 0===(r=t[a++]))throw _b_.TypeError.$factory("not enough arguments for format string");return l(e,r)},l=function(e,t){for(var r={pad_char:" "};;){var n=char_mapping[e[u]];try{if(void 0===n)throw new UnsupportedChar;var o=n(t,r);if(void 0!==o)return o;++u}catch(r){if("UnsupportedChar"==r.name){if(invalid_char=e[u],void 0===invalid_char)throw _b_.ValueError.$factory("incomplete format");throw _b_.ValueError.$factory("unsupported format character '"+invalid_char+"' (0x"+invalid_char.charCodeAt(0).toString(16)+") at index "+u)}if("NotANumber"===r.name){var a=e[u],s=t.__class__;throw s=s?s.$infos.__name__:"string"==typeof t?"str":typeof t,_b_.TypeError.$factory("%"+a+" format: a number is required, not "+s)}throw r}}},c=0;do{var u=e.indexOf("%",o);if(u<0){s+=e.substring(o);break}if(s+=e.substring(o,u),!(++ua)throw _b_.TypeError.$factory("not enough arguments for format string");if(t.lengtht};$comp_func+="";var $comps={">":"gt",">=":"ge","<":"lt","<=":"le"};for(var $op in $comps)eval("str.__"+$comps[$op]+"__ = "+$comp_func.replace(/>/gm,$op));$B.make_rmethods(str);var $notimplemented=function(e,t){throw NotImplementedError.$factory("OPERATOR not implemented for class str")};str.capitalize=function(e){$B.args("capitalize",1,{self:e},["self"],arguments,{},null,null);return 0==e.length?"":e.charAt(0).toUpperCase()+e.substr(1)},str.casefold=function(e){$B.args("casefold",1,{self:e},["self"],arguments,{},null,null);for(var t,r,n="",o=0,a=e.length;o=0;)n++,o+=e.sub.length;return n},str.encode=function(){var e=$B.args("encode",3,{self:null,encoding:null,errors:null},["self","encoding","errors"],arguments,{encoding:"utf-8",errors:"strict"},null,null);if("rot13"==e.encoding||"rot_13"==e.encoding){for(var t="",r=0,n=e.self.length;r0;)s+=" ",o++;break;case"\r":case"\n":s+=i,o=0;break;default:s+=i,o++}a++}return s},str.find=function(){var e=$B.args("str.find",4,{self:null,sub:null,start:null,end:null},["self","sub","start","end"],arguments,{start:0,end:null},null,null);if(check_str(e.sub),normalize_start_end(e),!isinstance(e.start,_b_.int)||!isinstance(e.end,_b_.int))throw _b_.TypeError.$factory("slice indices must be integers or None or have an __index__ method");for(var t="",r=e.start;r1&&(t=o[0],r=o[1]),void 0!==t){t=t.replace(/\.[_a-zA-Z][_a-zA-Z0-9]*|\[[_a-zA-Z][_a-zA-Z0-9]*\]|\[[0-9]+\]/g,(function(e){return a.push(e),""}))}return{name:t,name_ext:a,conv:r,spec:n||"",string:e}},$B.split_format=function(e){for(var t,r=0,n=e.length,o="",a=[],s=0;r0)throw ValueError.$factory("wrong format "+e);r=i}else o+=t,r++;return o&&a.push(o),a},str.format=function(e){var t=$B.last(arguments);if("mapping"==t.$nat){for(var r=t.mapping,n=$B.$getattr(r,"__getitem__"),o=[],a=0,s=arguments.length-1;a-1)var f=parseInt(_.name),p=_b_.tuple.__getitem__(i.$args,f);else p=n(_.name);for(var $=0;$<_.name_ext.length;$++){var d=_.name_ext[$];if("."==d.charAt(0))p=_b_.getattr(p,d.substr(1));else{var h=d.substr(1,d.length-2);h.charAt(0).search(/\d/)>-1&&(h=parseInt(h)),p=_b_.getattr(p,"__getitem__")(h)}}"a"==_.conv?p=_b_.ascii(p):"r"==_.conv?p=_b_.repr(p):"s"==_.conv&&(p=_b_.str.$factory(p)),p.$is_class||p.$factory?c+=p.__class__.__format__(p,_.spec):c+=$B.$getattr(p,"__format__")(_.spec)}else c+=l[a];return c},str.format_map=function(e,t){$B.args("format_map",2,{self:null,mapping:null},["self","mapping"],arguments,{},null,null);return str.format(e,{$nat:"mapping",mapping:t})},str.index=function(e){var t=str.find.apply(null,arguments);if(-1===t)throw _b_.ValueError.$factory("substring not found");return t},str.isascii=function(e){for(var t=0,r=e.length;t127)return!1;return!0},str.isalnum=function(e){$B.args("isalnum",1,{self:null},["self"],arguments,{},null,null);for(var t,r=0,n=e.length;r0},str.isdigit=function(e){$B.args("isdigit",1,{self:null},["self"],arguments,{},null,null);for(var t,r=0,n=e.length;r0},str.isidentifier=function(e){$B.args("isidentifier",1,{self:null},["self"],arguments,{},null,null);if(0==e.length)return!1;if(void 0===unicode_tables.XID_Start[e.charCodeAt(0)])return!1;for(var t=1,r=e.length;t0};var unprintable={},unprintable_gc=["Cc","Cf","Co","Cs","Zl","Zp","Zs"];function $re_escape(e){for(var t="[.*+?|()$^",r=0,n=t.length;r0},str.istitle=function(e){$B.args("istitle",1,{self:null},["self"],arguments,{},null,null);return e.length>0&&str.title(e)==e},str.isupper=function(e){$B.args("islower",1,{self:null},["self"],arguments,{},null,null);for(var t,r=!1,n=0,o=e.length;n0&&str.endswith(e.self,e.suffix)?e.self.substr(0,e.self.length-e.suffix.length):e.self.substr(0)},str.replace=function(e,t,r,n){var o=$B.args("replace",4,{self:null,old:null,$$new:null,count:null},["self","old","$$new","count"],arguments,{count:-1},null,null);n=o.count,e=o.self,t=o.old,r=o.$$new;if(check_str(t),check_str(r),!isinstance(n,[_b_.int,_b_.float]))throw _b_.TypeError.$factory("'"+$B.class_name(n)+"' object cannot be interpreted as an integer");if(isinstance(n,_b_.float))throw _b_.TypeError.$factory("integer argument expected, got float");if(0==n)return e;if(n.__class__==$B.long_int&&(n=parseInt(n.value)),""==t){if(""==r)return e;if(""==e)return r;var a=e.split("");if(n>-1&&a.length>=n){var s=a.slice(n).join("");return r+a.slice(0,n).join(r)+s}return r+a.join(r)+r}a=str.split(e,t,n);var i=e,_=-1;if(0==t.length){i=r;for(var l=0;l0&&!((_=i.indexOf(t,_))<0);)i=i.substr(0,_)+r+i.substr(_+t.length),_+=r.length,n--;return i},str.rfind=function(e,t){if(2==arguments.length&&"string"==typeof t)return e.lastIndexOf(t);var r=$B.args("rfind",4,{self:null,sub:null,start:null,end:null},["self","sub","start","end"],arguments,{start:0,end:null},null,null);if(normalize_start_end(r),check_str(r.sub),0==r.sub.length)return r.start>r.self.length?-1:r.self.length;for(var n=r.sub.length,o=r.end-n;o>=r.start;o--)if(r.self.substr(o,n)==r.sub)return o;return-1},str.rindex=function(){var e=str.rfind.apply(null,arguments);if(-1==e)throw _b_.ValueError.$factory("substring not found");return e},str.rjust=function(e){var t=$B.args("rjust",3,{self:null,width:null,fillchar:null},["self","width","fillchar"],arguments,{fillchar:" "},null,null);return t.width<=e.length?e:t.fillchar.repeat(t.width-e.length)+e},str.rpartition=function(e,t){var r=$B.args("rpartition",2,{self:null,sep:null},["self","sep"],arguments,{},null,null);check_str(r.sep);e=reverse(r.self),t=reverse(r.sep);for(var n=str.partition(e,t).reverse(),o=0;o=0;n--)if(-1==r.chars.indexOf(r.self.charAt(n)))return r.self.substring(0,n+1);return""},str.split=function(){var e=$B.args("split",3,{self:null,sep:null,maxsplit:null},["self","sep","maxsplit"],arguments,{sep:_b_.None,maxsplit:-1},null,null),t=e.sep,r=e.maxsplit,n=e.self,o=0;if(r.__class__===$B.long_int&&(r=parseInt(r.value)),""==t)throw _b_.ValueError.$factory("empty separator");if(t===_b_.None){for(var a=[];o-1;)o++;if(o===n.length-1)return[n];for(var s="";;){if(-1==n.charAt(o).search(/\s/))""==s?s=n.charAt(o):s+=n.charAt(o);else if(""!==s){if(a.push(s),-1!==r&&a.length==r+1)return a.pop(),a.push(s+n.substr(o)),a;s=""}if(++o>n.length-1){s&&a.push(s);break}}return a}a=[];var i="",_=t.length;if(0==r)return[n];for(;o-1&&a.length>=r)return a.push(n.substr(o)),a;i=""}else i+=n.charAt(o),o++;return a.push(i),a},str.splitlines=function(e){var t=$B.args("splitlines",2,{self:null,keepends:null},["self","keepends"],arguments,{keepends:!1},null,null);if(!_b_.isinstance(t.keepends,[_b_.bool,_b_.int]))throw _b_.TypeError("integer argument expected, got "+$B.get_class(t.keepends).__name);var r=_b_.int.$factory(t.keepends),n=[],o=0,a=0;if(!(e=t.self).length)return n;for(;a=t&&-1!=e.chars.indexOf(e.self.charAt(r));r--);return e.self.substring(t,r+1)},str.swapcase=function(e){$B.args("swapcase",1,{self:e},["self"],arguments,{},null,null);for(var t,r="",n=0,o=e.length;n";if(void 0!==t){var n=$B.args("str",3,{arg:null,encoding:null,errors:null},["arg","encoding","errors"],arguments,{encoding:"utf-8",errors:"strict"},null,null);t=n.encoding,r=n.errors}switch(typeof e){case"string":return str.__str__(e);case"number":if(isFinite(e))return e.toString()}try{if(e.$is_class||e.$factory){var o=$B.$getattr(e.__class__,"__str__");return o(e)}if(e.__class__&&e.__class__===_b_.bytes&&void 0!==t)return _b_.bytes.decode(e,n.encoding,n.errors);var a=e.__class__||$B.get_class(e);if(void 0===a)return $B.JSObj.__str__($B.JSObj.$factory(e));if(null===(s=$B.$getattr(a,"__str__",null))||e.__class__&&e.__class__!==_b_.object&&s.$infos&&s.$infos.__func__===_b_.object.__str__)var s=$B.$getattr(a,"__repr__")}catch(t){throw console.log("no __str__ for",e),console.log("err ",t),$B.debug>1&&console.log(t),console.log("Warning - no method __str__ or __repr__, default to toString",e),t}return $B.$call(s)(e)},str.__new__=function(e){if(void 0===e)throw _b_.TypeError.$factory("str.__new__(): not enough arguments");return{__class__:e}},$B.set_func_names(str,"builtins");var StringSubclass=$B.StringSubclass={__class__:_b_.type,__mro__:[object],$infos:{__module__:"builtins",__name__:"str"},$is_class:!0};for(var $attr in str)"function"==typeof str[$attr]&&(StringSubclass[$attr]=function(e){return function(){var t=[],r=0;if(arguments.length>0){t=[arguments[0].valueOf()],r=1;for(var n=1,o=arguments.length;n=^",n="0123456789",o=r.indexOf(e.charAt(0));-1!=o?e.charAt(1)&&-1!=r.indexOf(e.charAt(1))?(this.fill=e.charAt(0),this.align=e.charAt(1),t=2):(this.align=r[o],this.fill=" ",t++):(o=r.indexOf(e.charAt(1)),e.charAt(1)&&-1!=o&&(this.align=r[o],this.fill=e.charAt(0),t=2));var a=e.charAt(t);for("+"!=a&&"-"!=a&&" "!=a||(this.sign=a,t++,a=e.charAt(t)),"#"==a&&(this.alternate=!0,t++,a=e.charAt(t)),"0"==a&&(this.fill="0",-1==o&&(this.align="="),t++,a=e.charAt(t));a&&n.indexOf(a)>-1;)void 0===this.width?this.width=a:this.width+=a,t++,a=e.charAt(t);if(void 0!==this.width&&(this.width=parseInt(this.width)),void 0===this.width&&"{"==a){var s=e.substr(t).search("}");this.width=e.substring(t,s),console.log("width","["+this.width+"]"),t+=s+1}if(","==a&&(this.comma=!0,t++,a=e.charAt(t)),"."==a){if(-1==n.indexOf(e.charAt(t+1)))throw _b_.ValueError.$factory("Missing precision in format spec");for(this.precision=e.charAt(t+1),t+=2,a=e.charAt(t);a&&n.indexOf(a)>-1;)this.precision+=a,t++,a=e.charAt(t);this.precision=parseInt(this.precision)}if(a&&"bcdeEfFgGnosxX%".indexOf(a)>-1&&(this.type=a,t++,a=e.charAt(t)),t!==e.length)throw _b_.ValueError.$factory("Invalid format specifier: "+e)}this.toString=function(){return(void 0===this.fill?"":_b_.str.$factory(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(e,t){if(t.width&&e.length":return r.repeat(o)+e;case"=":return"+-".indexOf(e.charAt(0))>-1?e.charAt(0)+r.repeat(o)+e.substr(1):r.repeat(o)+e;case"^":var a=parseInt(o/2);return r.repeat(a)+e+r.repeat(o-a)}}return e},$B.parse_fstring=function(e){for(var t,r=[],n=0,o="",a=null,s=0;n-1){if(0==o.expression.length)throw Error("f-string: empty expression not allowed");if(-1=="ars".indexOf(e.charAt(i+1)))throw Error("f-string: invalid conversion character: expected 's', 'r', or 'a'");o.conversion=e.charAt(i+1),i+=2}else if("("==t)_++,o.expression+=t,i++;else if(")"==t)_--,o.expression+=t,i++;else if('"'==t){var l;if('"""'==e.substr(i,3))if(-1==(l=e.indexOf('"""',i+3)))fstring_error("f-string: unterminated string",n);else{var c=e.substring(i,l+3);c=c.replace("\n","\\n\\"),o.expression+=c,i=l+3}else-1==(l=e.indexOf('"',i+1))?fstring_error("f-string: unterminated string",n):(o.expression+=e.substring(i,l+1),i=l+1)}else if(0==_&&":"==t)o.fmt=!0,o.expression+=t,i++;else if("="==t){var u=o.expression,f=u.charAt(u.length-1),p=("()".indexOf(f)>-1?"\\":"")+f;if(0==u.length||_>0||"="==e.charAt(i+1)||"=!<>:".search(p)>-1)o.expression+=t,i+=1;else{for(tail=t;e.charAt(i+1).match(/\s/);)tail+=e.charAt(i+1),i++;for(r.push(o.expression+tail);u.match(/\s$/);)u=u.substr(0,u.length-1);o.expression=u,a="debug",i++}}else o.expression+=t,i++}s>0&&fstring_error("f-string: expected '}'",n)}return o.length>0&&r.push(o),r};var surrogate=str.$surrogate=$B.make_class("surrogate_string",(function(e){for(var t=[],r=0,n=e.length;r=55296&&o<=56319)r++,o=1024*(o-55296)+(e.charCodeAt(r)-56320)+65536;t.push(String.fromCodePoint(o))}return{__class__:str.$surrogate,items:t}}));surrogate.__mro__=[str,object],surrogate.__add__=function(e,t){if(t.__class__===str.$surrogate)return(r=str.$surrogate.$factory("")).items=e.items.concat(t.items),r;if(_b_.isinstance(t,str)){var r;(r=str.$surrogate.$factory("")).items=e.items;for(const e of t+"")r.items.push(e);return r}},surrogate.__contains__=function(e,t){return str.__contains__(e.items.join(""),t)},surrogate.__getitem__=function(e,t){if(isinstance(t,_b_.int)){var r=t;if(t<0&&(r+=e.items.length),r>=0&&r0){if(a<=o)return"";for(_=o;_=o)return"";for(_=o;_>a;_+=s)i+=e.items[_]}return i}if(isinstance(t,_b_.bool))return surrogate.__getitem__(e,_b_.int.$factory(t));throw _b_.TypeError.$factory("string indices must be integers")},surrogate.__hash__=function(e){return str.__hash__(e.items.join(""))},surrogate.__iter__=function(e){return str_iterator.$factory(e.items)},surrogate.__len__=function(e){return e.items.length},surrogate.__repr__=function(e){return str.__repr__(e.items.join(""))},surrogate.__str__=function(e){return str.__str__(e.items.join(""))},$B.set_func_names(surrogate,"builtins")}(__BRYTHON__),function($B){var bltns=$B.InjectBuiltins();eval(bltns);var str_hash=_b_.str.__hash__,$N=_b_.None,set_ops=["eq","le","lt","ge","gt","sub","rsub","and","or","xor"];function is_sublist(e,t){for(var r=0,n=e.length;r0},dict.__class_getitem__=function(e,t){return Array.isArray(t)||(t=[t]),$B.GenericAlias.$factory(e,t)},dict.__contains__=function(){var e=$B.args("__contains__",2,{self:null,key:null},["self","key"],arguments,{},null,null),t=e.self,r=e.key;if(t.$is_namespace&&(r=$B.to_alias(r)),t.$jsobj)return void 0!==t.$jsobj[r];switch(typeof r){case"string":return void 0!==t.$string_dict[r];case"number":return void 0!==t.$numeric_dict[r]}var n=_b_.hash(r);return!(void 0===t.$str_hash[n]||!$B.rich_comp("__eq__",r,t.$str_hash[n]))||(!(void 0===t.$numeric_dict[n]||!$B.rich_comp("__eq__",r,n))||rank(t,n,r)>-1)},dict.__delitem__=function(){var e=$B.args("__eq__",2,{self:null,arg:null},["self","arg"],arguments,{},null,null),t=e.self,r=e.arg;if(t.$jsobj){if(void 0===t.$jsobj[r])throw _b_.KeyError.$factory(r);return delete t.$jsobj[r],$N}switch(typeof r){case"string":if(void 0===t.$string_dict[r])throw _b_.KeyError.$factory(_b_.str.$factory(r));return delete t.$string_dict[r],delete t.$str_hash[str_hash(r)],t.$version++,$N;case"number":if(void 0===t.$numeric_dict[r])throw _b_.KeyError.$factory(_b_.str.$factory(r));return delete t.$numeric_dict[r],t.$version++,$N}var n,o=_b_.hash(r);if(!((n=rank(t,o,r))>-1))throw _b_.KeyError.$factory(_b_.str.$factory(r));return t.$object_dict[o].splice(n,1),t.$version++,$N},dict.__eq__=function(){var e=$B.args("__eq__",2,{self:null,other:null},["self","other"],arguments,{},null,null),t=e.self,r=e.other;if(!_b_.isinstance(r,dict))return!1;if(t.$jsobj&&(t=jsobj2dict(t.$jsobj)),r.$jsobj&&(r=jsobj2dict(r.$jsobj)),dict.__len__(t)!=dict.__len__(r))return!1;if(t.$string_dict.length!=r.$string_dict.length)return!1;for(var n in t.$numeric_dict)if(r.$numeric_dict.hasOwnProperty(n)){if(!$B.rich_comp("__eq__",r.$numeric_dict[n][0],t.$numeric_dict[n][0]))return!1}else{if(!r.$object_dict.hasOwnProperty(n))return!1;for(var o=!1,a=0,s=(_=r.$object_dict[n]).length;a-1)return e.$object_dict[n][i][1][0];if(e.__class__!==dict){try{var _=getattr(e.__class__,"__missing__",_b_.None)}catch(e){console.log(e)}if(_!==_b_.None)return _(e,t)}throw _b_.KeyError.$factory(t)},dict.__hash__=_b_.None,dict.__init__=function(e,t,r){var n;if(void 0===t)return $N;if(void 0===r){if("kw"!=t.$nat&&$B.get_class(t)===$B.JSObj){for(var o in t)e.$string_dict[o]=[t[o],e.$order++];return _b_.None}if(t.$jsobj){for(var a in e.$jsobj={},t.$jsobj)e.$jsobj[a]=t.$jsobj[a];return $N}if(Array.isArray(t))return init_from_list(e,t),$N}var s=(n=n||$B.args("dict",1,{self:null},["self"],arguments,{},"first","second")).first;if(s.length>1)throw _b_.TypeError.$factory("dict expected at most 1 argument, got 2");if(1==s.length)if((s=s[0]).__class__===dict)["$string_dict","$str_hash","$numeric_dict","$object_dict"].forEach((function(t){for(o in s[t])e[t][o]=s[t][o]}));else if(_b_.isinstance(s,dict))$copy_dict(e,s);else{var i=$B.$getattr(s,"keys",null);if(null!==i){var _=$B.$getattr(s,"__getitem__",null);if(null!==_){_=$B.$call(_);for(var l=_b_.iter($B.$call(i)());;)try{var c=_(o=_b_.next(l));dict.__setitem__(e,o,c)}catch(e){if(e.__class__===_b_.StopIteration)break;throw e}return $N}}Array.isArray(s)||(s=_b_.list.$factory(s)),init_from_list(e,s)}var u=n.second.$string_dict;for(var a in u)switch(typeof a){case"string":e.$string_dict[a]=[u[a][0],e.$order++],e.$str_hash[str_hash(a)]=a;break;case"number":e.$numeric_dict[a]=[u[a][0],e.$order++];break;default:si(e,a,u[a][0])}return $N},dict.__iter__=function(e){return _b_.iter(dict.$$keys(e))},dict.__ior__=function(e,t){return dict.update(e,t),e},dict.__len__=function(e){var t=0;if(e.$jsobj){for(var r in e.$jsobj)"$"!=r.charAt(0)&&t++;return t}for(var n in e.$numeric_dict)t++;for(var n in e.$string_dict)t++;for(var o in e.$object_dict)t+=e.$object_dict[o].length;return t},dict.__ne__=function(e,t){return!dict.__eq__(e,t)},dict.__new__=function(e){if(void 0===e)throw _b_.TypeError.$factory("int.__new__(): not enough arguments");var t={__class__:e,$numeric_dict:{},$object_dict:{},$string_dict:{},$str_hash:{},$version:0,$order:0};return e!==dict&&(t.__dict__=$B.empty_dict()),t},dict.__or__=function(e,t){if(!_b_.isinstance(t,dict))return _b_.NotImplemented;var r=dict.copy(e);return dict.update(r,t),r},dict.__repr__=function(e){if(e.$jsobj)return dict.__repr__(jsobj2dict(e.$jsobj));if($B.repr.enter(e))return"{...}";var t=[];return to_list(e).forEach((function(e){try{t.push(repr(e[0])+": "+repr(e[1]))}catch(e){throw e}})),$B.repr.leave(e),"{"+t.join(", ")+"}"},dict.__ror__=function(e,t){if(!_b_.isinstance(t,dict))return _b_.NotImplemented;var r=dict.copy(t);return dict.update(r,e),r},dict.__setitem__=function(e,t,r){var n=$B.args("__setitem__",3,{self:null,key:null,value:null},["self","key","value"],arguments,{},null,null);return dict.$setitem(n.self,n.key,n.value)},dict.$setitem=function(e,t,r,n){if(e.$jsobj)return e.$from_js&&(r=$B.pyobj2jsobj(r)),e.$jsobj.__class__===_b_.type?(e.$jsobj[t]=r,"__init__"!=t&&"__new__"!=t||(e.$jsobj.$factory=$B.$instance_creator(e.$jsobj))):e.$jsobj[t]=r,$N;switch(typeof t){case"string":return void 0===e.$string_dict&&console.log("pas de string dict",e,t,r),void 0!==e.$string_dict[t]?e.$string_dict[t][0]=r:(e.$string_dict[t]=[r,e.$order++],e.$str_hash[str_hash(t)]=t,e.$version++),$N;case"number":if(void 0!==e.$numeric_dict[t])e.$numeric_dict[t][0]=r;else{var o=!1;if((0==t||1==t)&&void 0!==e.$object_dict[t])for(const n of e.$object_dict[t])(0==t&&!1===n[0]||1==t&&!0===n[0])&&(n[1][0]=r,o=!0);o||(e.$numeric_dict[t]=[r,e.$order++]),e.$version++}return $N;case"boolean":var a=t?1:0;if(void 0!==e.$numeric_dict[a]){var s=e.$numeric_dict[a][1];return void(e.$numeric_dict[a]=[r,s])}void 0!==e.$object_dict[a]?e.$object_dict[a].push([t,[r,e.$order++]]):e.$object_dict[a]=[[t,[r,e.$order++]]]}var i=void 0===n?_b_.hash(t):n,_=function(e){return $B.rich_comp("__eq__",t,e)};if(void 0!==e.$numeric_dict[i]&&_(i))return e.$numeric_dict[i]=[r,e.$numeric_dict[i][1]],e.$version++,$N;var l=e.$str_hash[i];if(void 0!==l&&_(l))return e.$string_dict[l]=[r,e.$string_dict[l][1]],e.$version++,$N;if(n)return void 0!==e.$object_dict[n]?e.$object_dict[n].push([t,[r,e.$order++]]):e.$object_dict[n]=[[t,[r,e.$order++]]],e.$version++,$N;var c=rank(e,i,t);return c>-1?(e.$object_dict[i][c][1]=[r,e.$object_dict[i][c][1][1]],$N):(e.$object_dict.hasOwnProperty(i)?e.$object_dict[i].push([t,[r,e.$order++]]):e.$object_dict[i]=[[t,[r,e.$order++]]],e.$version++,$N)},dict.__str__=function(){return dict.__repr__.apply(null,arguments)},$B.make_rmethods(dict),dict.clear=function(){var e=$B.args("clear",1,{self:null},["self"],arguments,{},null,null),t=e.self;if(t.$numeric_dict={},t.$string_dict={},t.$str_hash={},t.$object_dict={},t.$jsobj)for(var r in t.$jsobj)"$"!==r.charAt(0)&&"__class__"!==r&&delete t.$jsobj[r];return t.$version++,t.$order=0,$N},dict.copy=function(e){var t=$B.args("copy",1,{self:null},["self"],arguments,{},null,null),r=(e=t.self,$B.empty_dict());return $copy_dict(r,e),r},dict.fromkeys=function(){for(var e=$B.args("fromkeys",3,{cls:null,keys:null,value:null},["cls","keys","value"],arguments,{value:_b_.None},null,null),t=e.keys,r=e.value,n=e.cls,o=$B.$call(n)(),a=$B.$iter(t);;)try{var s=_b_.next(a);n===dict?dict.$setitem(o,s,r):$B.$getattr(o,"__setitem__")(s,r)}catch(e){if($B.is_exc(e,[_b_.StopIteration]))return o;throw e}},dict.get=function(){var e=$B.args("get",3,{self:null,key:null,_default:null},["self","key","_default"],arguments,{_default:$N},null,null);try{return dict.__getitem__(e.self,e.key)}catch(t){if(_b_.isinstance(t,_b_.KeyError))return e._default;throw t}};var dict_items=$B.make_view("dict_items",!0);dict_items.$iterator=$B.make_iterator_class("dict_itemiterator"),dict.items=function(e){if(arguments.length>1){var t=arguments.length-1,r="items() takes no arguments ("+t+" given)";throw _b_.TypeError.$factory(r)}for(var n=to_list(e),o=!0,a=0,s=n.length;a1){var t=arguments.length-1,r="keys() takes no arguments ("+t+" given)";throw _b_.TypeError.$factory(r)}var n=dict_keys.$factory(e,to_list(e,0),!0);return n.dict_version=e.$version,n},dict.pop=function(){var e={},t=$B.args("pop",3,{self:null,key:null,_default:null},["self","key","_default"],arguments,{_default:e},null,null),r=t.self,n=t.key,o=t._default;try{var a=dict.__getitem__(r,n);return dict.__delitem__(r,n),a}catch(t){if(t.__class__===_b_.KeyError){if(o!==e)return o;throw t}throw t}},dict.popitem=function(e){try{var t=_b_.next(_b_.iter(dict.items(e)));return dict.__delitem__(e,t[0]),_b_.tuple.$factory(t)}catch(e){if(e.__class__==_b_.StopIteration)throw _b_.KeyError.$factory("'popitem(): dictionary is empty'")}},dict.setdefault=function(){var e=$B.args("setdefault",3,{self:null,key:null,_default:null},["self","key","_default"],arguments,{_default:$N},null,null),t=e.self,r=e.key,n=e._default;try{return dict.__getitem__(t,r)}catch(e){if(e.__class__!==_b_.KeyError)throw e;void 0===n&&(n=$N);var o=r.$hash;return r.$hash=void 0,dict.$setitem(t,r,n,o),n}},dict.update=function(e){var t=$B.args("update",1,{self:null},["self"],arguments,{},"args","kw"),r=(e=t.self,t.args),n=t.kw;if(r.length>0){var o=r[0];if(_b_.isinstance(o,dict))o.$jsobj&&(o=jsobj2dict(o.$jsobj)),$copy_dict(e,o);else if(_b_.hasattr(o,"keys"))for(var a=_b_.list.$factory($B.$call($B.$getattr(o,"keys"))()),s=0,i=a.length;s1){var t=arguments.length-1,r="values() takes no arguments ("+t+" given)";throw _b_.TypeError.$factory(r)}var n=to_list(e,1),o=dict_values.$factory(e,n,!1);return o.dict_version=e.$version,o},dict.$factory=function(){for(var e=dict.__new__(dict),t=[e],r=0,n=arguments.length;r`},$B.set_func_names($B.getset_descriptor,"builtins");var mappingproxy=$B.mappingproxy=$B.make_class("mappingproxy",(function(e){if(_b_.isinstance(e,dict))var t=$B.obj_dict(dict.$to_obj(e));else t=$B.obj_dict(e);return t.__class__=mappingproxy,t}));for(var attr in mappingproxy.__setitem__=function(){throw _b_.TypeError.$factory("'mappingproxy' object does not support item assignment")},dict)void 0!==mappingproxy[attr]||["__class__","__mro__","__new__","__init__","__delitem__","clear","fromkeys","pop","popitem","setdefault","update"].indexOf(attr)>-1||("function"==typeof dict[attr]?mappingproxy[attr]=function(e){return function(){return dict[e].apply(null,arguments)}}(attr):mappingproxy[attr]=dict[attr]);function jsobj2dict(e){var t=$B.empty_dict();for(var r in e)if("$"!=r.charAt(0)&&"__class__"!==r)if(null===e[r])t.$string_dict[r]=[_b_.None,t.$order++];else{if(void 0===e[r])continue;e[r].$jsobj===e?t.$string_dict[r]=[t,t.$order++]:t.$string_dict[r]=[$B.$JS2Py(e[r]),t.$order++]}return t}$B.set_func_names(mappingproxy,"builtins"),$B.obj_dict=function(e,t){var r=e.__class__||$B.get_class(e);if(void 0!==r&&r.$native)throw _b_.AttributeError.$factory(r.__name__+" has no attribute '__dict__'");var n=$B.empty_dict();return n.$jsobj=e,n.$from_js=t,n}}(__BRYTHON__),function(e){var t=e.builtins,r=t.object,n=self;function o(e){var t=0,r=0,n=e.width||e.offsetWidth,a=e.height||e.offsetHeight;for(document.scrollingElement.scrollTop;e.offsetParent;)t+=e.offsetLeft,r+=e.offsetTop,e=e.offsetParent;if(t+=e.offsetLeft||0,r+=e.offsetTop||0,e.parentElement){var s=o(e.parentElement);t+=s.left,r+=s.top}return{left:t,top:r,width:n,height:a}}function a(e){if(e.type.startsWith("touch"))return(r={}).x=t.int.$factory(e.touches[0].screenX),r.y=t.int.$factory(e.touches[0].screenY),r.__getattr__=function(e){return this[e]},r.__class__="MouseCoords",r;var r,o=0,a=0;if(!e)e=n.event;return e.pageX||e.pageY?(o=e.pageX,a=e.pageY):(e.clientX||e.clientY)&&(o=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,a=e.clientY+document.body.scrollTop+document.documentElement.scrollTop),(r={}).x=t.int.$factory(o),r.y=t.int.$factory(a),r.__getattr__=function(e){return this[e]},r.__class__="MouseCoords",r}e.$isNode=function(e){return"object"==typeof Node?e instanceof Node:e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},e.$isNodeList=function(e){try{var t=Object.prototype.toString.call(e),r=new RegExp("^\\[object (HTMLCollection|NodeList)\\]$");return"object"==typeof e&&null!==r.exec(t)&&void 0!==e.length&&(0==e.length||"object"==typeof e[0]&&e[0].nodeType>0)}catch(e){return!1}};var s=["NONE","CAPTURING_PHASE","AT_TARGET","BUBBLING_PHASE","type","target","currentTarget","eventPhase","bubbles","cancelable","timeStamp","stopPropagation","preventDefault","initEvent"],i=["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"];e.$isEvent=function(e){for(var t=!0,r=0;r");var c=e.DOMEvent={__class__:t.type,__mro__:[r],$infos:{__name__:"DOMEvent"}};function u(e,t){var r=e.createSVGPoint();return r.x=t.x,r.y=t.y,r.matrixTransform(e.getScreenCTM().inverse())}c.__new__=function(e,t){var r=new Event(t);return r.__class__=c,void 0===r.preventDefault&&(r.preventDefault=function(){r.returnValue=!1}),void 0===r.stopPropagation&&(r.stopPropagation=function(){r.cancelBubble=!0}),r},c.__getattribute__=function(r,n){switch(n){case"__repr__":case"__str__":return function(){return""};case"x":return a(r).x;case"y":return a(r).y;case"data":return null!==r.dataTransfer?p.$factory(r.dataTransfer):e.$JS2Py(r.data);case"target":if(void 0!==r.target)return m.$factory(r.target);case"char":return String.fromCharCode(r.which);case"svgX":if(r.target instanceof SVGSVGElement)return Math.floor(u(r.target,a(r)).x);throw t.AttributeError.$factory("event target is not an SVG element");case"svgY":if(r.target instanceof SVGSVGElement)return Math.floor(u(r.target,a(r)).y);throw t.AttributeError.$factory("event target is not an SVG element")}var o=r[n];if(void 0!==o){if("function"==typeof o){var s=function(){for(var t=[],n=0;n");var $=e.OpenFile={__class__:t.type,__mro__:[r],$infos:{__module__:"",__name__:"OpenFile"}};$.$factory=function(e,t,r){var n={__class__:$OpenFileDict,file:e,reader:new FileReader};return"r"===t?n.reader.readAsText(e,r):"rb"===t&&n.reader.readAsBinaryString(e),n},$.__getattr__=function(e,t){return void 0!==e["get_"+t]?e["get_"+t]:e.reader[t]},$.__setattr__=function(e,t,r){var n=e.reader;if("on"==t.substr(0,2)){n.addEventListener(t.substr(2),(function(e){return r(f(e))}))}else{if("set_"+t in n)return n["set_"+t](r);t in n?n[t]=r:setattr(n,t,r)}},e.set_func_names($,"");var d={File:function(){},FileReader:function(){}};d.File.__class__=t.type,d.File.__str__=function(){return""},d.FileReader.__class__=t.type,d.FileReader.__str__=function(){return""};var h={__class__:t.type,__delitem__:function(e,t){e.parent.options.remove(t.elt)},__getitem__:function(e,t){return m.$factory(e.parent.options[t])},__len__:function(e){return e.parent.options.length},__mro__:[r],__setattr__:function(e,t,r){e.parent.options[t]=r},__setitem__:function(t,r,n){t.parent.options[r]=e.$JS2Py(n)},__str__:function(e){return""},append:function(e,t){e.parent.options.add(t.elt)},insert:function(e,t,r){void 0===t?e.parent.options.add(r.elt):e.parent.options.add(r.elt,t)},item:function(e,t){return e.parent.options.item(t)},namedItem:function(e,t){return e.parent.options.namedItem(t)},remove:function(e,t){e.parent.options.remove(t.elt)},$infos:{__module__:"",__name__:"Options"},$factory:function(e){return{__class__:h,parent:e}}};e.set_func_names(h,"");var m={__class__:t.type,__mro__:[r],$infos:{__module__:"browser",__name__:"DOMNode"}};function g(e){for(var t=[],r=0;r-1)return function(e){return void 0===e?(n.select(),t.None):m.select(n,e)};if("query"==a&&9==n.nodeType){f={__class__:b,_keys:[],_values:{}};var d=location.search.substr(1).split("&");if(""!=location.search)for(p=0;p-1?f._values[y].push(v):(f._keys.push(y),f._values[y]=[v])}return f}var x=n[a];if((void 0===x&&e.aliased_names[a]&&(x=n["$$"+a]),void 0!==x&&n.__class__&&"browser.html"!=n.__class__.__module__)&&e.$getattr(n.__class__,a,t.None)!==t.None){var B=e.last(e.frames_stack)[1].$line_info.split(",")[0];console.info("Warning: line "+B+", "+n.tagName+" element has instance attribute '"+a+"' set. Attribute of class "+e.class_name(n)+" is ignored.")}if(void 0===x){if(n.tagName){var w=customElements.get(n.tagName.toLowerCase());if(void 0!==w&&void 0!==w.$cls){var k=n.__class__;n.__class__=w.$cls;try{var f=t.object.__getattribute__(n,a);return n.__class__=k,f}catch(r){if(n.__class__=k,!e.is_exc(r,[t.AttributeError]))throw r}}}return r.__getattribute__(n,a)}if(void 0!==(f=x)){if(null===f)return t.None;if("function"==typeof f){var E=function(r,n){return function(){for(var o=[],a=0,s=0;s0){for(var n=v.$factory(),o=n.children.length,a=0;a"}return""},m.__setattr__=function(r,n,o){if("on"!=n.substr(0,2)){switch(n){case"left":case"top":case"width":case"height":if(t.isinstance(o,t.int)&&1==r.nodeType)return r.style[n]=o+"px",t.None;throw t.ValueError.$factory(n+" value should be an integer, not "+e.class_name(o))}if(void 0!==m["set_"+n])return m["set_"+n](r,o);function a(t){console.log(t);var r=e.last(e.frames_stack);if(e.debug>0){var n=r[1].$line_info.split(",");if(console.log("module",n[1],"line",n[0]),e.$py_src.hasOwnProperty(n[1])){var o=e.$py_src[n[1]];console.log(o.split("\n")[parseInt(n[0])-1])}}else console.log("module",r[2])}for(var s=Object.getPrototypeOf(r),i=0;s&&s!==Object.prototype&&i++<10;){var _=Object.getOwnPropertyDescriptors(s);if(!_||"function"!=typeof _.hasOwnProperty)break;if(_.hasOwnProperty(n)){_[n].writable||void 0!==_[n].set||a("Warning: property '"+n+"' is not writable. Use element.attrs['"+n+"'] instead.");break}s=Object.getPrototypeOf(s)}return r.style&&void 0!==r.style[n]&&a("Warning: '"+n+"' is a property of element.style"),r[n]=o,t.None}e.$bool(o)?m.bind(r,n.substr(2),o):m.unbind(r,n.substr(2))},m.__setitem__=function(e,t,r){"number"==typeof t?e.childNodes[t]=r:"string"==typeof t&&e.attributes&&(e instanceof SVGElement?e.setAttributeNS(null,t,r):"function"==typeof e.setAttribute&&e.setAttribute(t,r))},m.abs_left={__get__:function(e){return o(e).left},__set__:function(){throw t.AttributeError.$factory("'DOMNode' objectattribute 'abs_left' is read-only")}},m.abs_top={__get__:function(e){return o(e).top},__set__:function(){throw t.AttributeError.$factory("'DOMNode' objectattribute 'abs_top' is read-only")}},m.attach=m.__le__,m.bind=function(r,n){var o=e.args("bind",4,{self:null,event:null,func:null,options:null},["self","event","func","options"],arguments,{func:t.None,options:t.None},null,null),a=(r=o.self,n=o.event,o.func),s=o.options;if(a===t.None)return function(e){return m.bind(r,n,e)};var i,_=(i=a,function(t){try{return i(f(t))}catch(t){if(void 0!==t.__class__)e.handle_error(t);else try{e.$getattr(e.stderr,"write")(t)}catch(e){console.log(t)}}});return _.$infos=a.$infos,_.$attrs=a.$attrs||{},_.$func=a,"boolean"==typeof s?r.addEventListener(n,_,s):s.__class__===t.dict?r.addEventListener(n,_,t.dict.$to_obj(s)):s===t.None&&r.addEventListener(n,_,!1),r.$events=r.$events||{},r.$events[n]=r.$events[n]||[],r.$events[n].push([a,_]),r},m.children=function(e){var t=[];return 9==e.nodeType&&(e=e.body),e.childNodes.forEach((function(e){t.push(m.$factory(e))})),t},m.clear=function(t){e.args("clear",1,{self:null},["self"],arguments,{},null,null);for(9==t.nodeType&&(t=t.body);t.firstChild;)t.removeChild(t.firstChild)},m.Class=function(e){return void 0!==e.className?e.className:t.None},m.class_name=function(e){return m.Class(e)},m.clone=function(e){var t=m.$factory(e.cloneNode(!0)),r=e.$events||{};for(var n in r){r[n].forEach((function(e){var r=e[0];m.bind(t,n,r)}))}return t},m.closest=function(r,n){e.args("closest",2,{self:null,selector:null},["self","selector"],arguments,{},null,null);var o=r.closest(n);if(null===o)throw t.KeyError.$factory("no parent with selector "+n);return m.$factory(o)},m.events=function(e,t){e.$events=e.$events||{};var r=e.$events[t]=e.$events[t]||[],n=[];return r.forEach((function(e){n.push(e[1])})),n},m.get=function(r){for(var n=[],o=1;o-1},__getitem__:function(e,r){var n=e._values[r];if(void 0===n)throw t.KeyError.$factory(r);return 1==n.length?n[0]:n}},y=e.make_iterator_class("query string iterator");b.__iter__=function(e){return y.$factory(e._keys)},b.__setitem__=function(e,r,n){return e._values[r]=[n],t.None},b.__str__=b.__repr__=function(e){var t=[];for(var r in e._values)for(const n of e._values[r])t.push(encodeURIComponent(r)+"="+encodeURIComponent(n));return 0==t.length?"":"?"+t.join("&")},b.getfirst=function(e,r,n){var o=e._values[r];return void 0===o?void 0===n?t.None:n:o[0]},b.getlist=function(e,t){var r=e._values[t];return void 0===r?[]:r},b.getvalue=function(e,r,n){try{return b.__getitem__(e,r)}catch(e){return void 0===n?t.None:n}},b.keys=function(e){return e._keys},e.set_func_names(b,"");var v={__class__:t.type,__mro__:[r],$infos:{__module__:"",__name__:"TagSum"},appendChild:function(e,t){e.children.push(t)},__add__:function(r,n){return e.get_class(n)===v?r.children=r.children.concat(n.children):t.isinstance(n,[t.str,t.int,t.float,t.dict,t.set,t.list])?r.children=r.children.concat(m.$factory(document.createTextNode(n))):r.children.push(n),r},__radd__:function(e,t){var r=v.$factory();return r.children=e.children.concat(m.$factory(document.createTextNode(t))),r},__repr__:function(e){for(var t=" ",r=0;r"),e.TagSum=v;var x=e.JSObj.$factory(n);x.get_postMessage=function(e,r){if(t.isinstance(e,dict)){var o={__class__:"dict"};t.list.$factory(t.dict.items(e)).forEach((function(e){o[e[0]]=e[1]})),e=o}return n.postMessage(e,r)},e.DOMNode=m,e.win=x}(__BRYTHON__),function($B){var _b_=$B.builtins,bltns=$B.InjectBuiltins();eval(bltns);var $GeneratorReturn={};$B.generator_return=function(e){return{__class__:$GeneratorReturn,value:e}},$B.generator=$B.make_class("generator",(function(e){var t=function(){var t=e.apply(null,arguments);if(t.$name=e.name,t.$func=e,t.$has_run=!1,t.__class__=$B.generator,e.$has_yield_in_cm){var r=$B.last($B.frames_stack)[1];r.$close_generators=r.$close_generators||[],r.$close_generators.push(t)}return t};return t.$infos=e.$infos,t.$is_genfunc=!0,t})),$B.generator.__iter__=function(e){return e},$B.generator.__next__=function(e){return $B.generator.send(e,_b_.None)},$B.generator.close=function(e){try{$B.generator.$$throw(e,_b_.GeneratorExit.$factory())}catch(e){if(!$B.is_exc(e,[_b_.GeneratorExit,_b_.StopIteration]))throw _b_.RuntimeError.$factory("generator ignored GeneratorExit")}},$B.generator.send=function(e,t){if(e.$has_run=!0,e.$finished)throw _b_.StopIteration.$factory(t);if(!0===e.gi_running)throw _b_.ValueError.$factory("generator already executing");e.gi_running=!0;try{var r=e.next(t)}catch(t){throw e.$finished=!0,t}if(r.value&&r.value.__class__===$GeneratorReturn)throw e.$finished=!0,_b_.StopIteration.$factory(r.value.value);if(e.gi_running=!1,r.done)throw _b_.StopIteration.$factory(r.value);return r.value},$B.generator.$$throw=function(e,t,r,n){var o=t;if(o.$is_class){if(!_b_.issubclass(t,_b_.BaseException))throw _b_.TypeError.$factory("exception value must be an instance of BaseException");void 0===r?o=$B.$call(o)():_b_.isinstance(r,t)&&(o=r)}else void 0===r?r=o:o=$B.$call(o)(r);void 0!==n&&(o.$traceback=n);var a=e.throw(o);if(a.done)throw _b_.StopIteration.$factory("StopIteration");return a.value},$B.set_func_names($B.generator,"builtins"),$B.async_generator=$B.make_class("async_generator",(function(e){return function(){var t=e.apply(null,arguments);return t.__class__=$B.async_generator,t}}));var ag_closed={};function rstrip(e,t){for(var r=t||" \t\n",n=0,o=e.length;n-1;)n++;return e.substr(0,o-n)}$B.async_generator.__aiter__=function(e){return e},$B.async_generator.__anext__=function(e){return $B.async_generator.asend(e,_b_.None)},$B.async_generator.aclose=function(e){return e.$finished=!0,_b_.None},$B.async_generator.asend=async function(e,t){if(e.$finished)throw _b_.StopAsyncIteration.$factory(t);if(!0===e.ag_running)throw _b_.ValueError.$factory("generator already executing");e.ag_running=!0;try{var r=await e.next(t)}catch(t){throw e.$finished=!0,t}if(r.done)throw _b_.StopAsyncIteration.$factory(t);if(r.value.__class__===$GeneratorReturn)throw e.$finished=!0,_b_.StopAsyncIteration.$factory(r.value.value);return e.ag_running=!1,r.value},$B.async_generator.athrow=async function(e,t,r,n){var o=t;if(o.$is_class){if(!_b_.issubclass(t,_b_.BaseException))throw _b_.TypeError.$factory("exception value must be an instance of BaseException");void 0===r&&(r=$B.$call(o)())}else void 0===r?r=o:o=$B.$call(o)(r);void 0!==n&&(o.$traceback=n),await e.throw(r)},$B.set_func_names($B.async_generator,"builtins")}(__BRYTHON__),function($B){var _b_=$B.builtins,update=function(e,t){for(attr in t)e[attr]=t[attr]},_window=self,modules={},browser={$package:!0,$is_package:!0,__initialized__:!0,__package__:"browser",__file__:$B.brython_path.replace(/\/*$/g,"")+"/Lib/browser/__init__.py",bind:function(){var e=$B.args("bind",3,{elt:null,evt:null,options:null},["elt","evt","options"],arguments,{options:_b_.None},null,null),t=e.options;return"boolean"==typeof t||t.__class__===_b_.dict&&(t=t.$string_dict),function(r){if($B.get_class(e.elt)===$B.JSObj){return e.elt.addEventListener(e.evt,(function(e){try{return r($B.JSObj.$factory(e))}catch(e){$B.handle_error(e)}}),t),r}if(_b_.isinstance(e.elt,$B.DOMNode))return $B.DOMNode.bind(e.elt,e.evt,r,t),r;if(_b_.isinstance(e.elt,_b_.str)){for(var n=document.querySelectorAll(e.elt),o=0;o1&&(console.log(e,e.__class__,e.args),console.log("first",first),console.log(arguments)),$B.handle_error(e)}}for(var items=_b_.list.$factory(_b_.dict.items($ns.kw)),i=0,len=items.length;i"},$B.Undefined={__class__:$B.UndefinedClass},$B.set_func_names($B.UndefinedClass,"javascript");var super_class=$B.make_class("JavascriptSuper",(function(){var e=_b_.$$super.$factory().__self_class__,t=Object.getPrototypeOf(e).constructor.$parent;return{__class__:super_class,__init__:function(){var r,n=t.bind(e);for(key in r=t.toString().startsWith("class")?new n(...arguments):n(...arguments))e[$B.to_alias(key)]=r[key];return r},__self_class__:e}}));super_class.__getattribute__=function(e,t){return"__init__"==t||"__call__"==t?e.__init__:$B.$getattr(e.__self_class__,t)},$B.set_func_names(super_class,"javascript"),modules.javascript={$$this:function(){return void 0===$B.js_this?$B.builtins.None:$B.JSObj.$factory($B.js_this)},$$Date:self.Date&&$B.JSObj.$factory(self.Date),$$extends:function(e){return function(t){if(t.$is_class){var r=function(){var e=$B.$getattr(t,"__init__",_b_.None);return e!==_b_.None&&e.bind(this,this).apply(this,arguments),this};for(var n in(r.prototype=Object.create(e.prototype)).constructor=r,r.$parent=e.$js_func,r.$is_class=!0,r.$infos=t.$infos,t)"function"==typeof t[n]&&(r.prototype[n]=function(e){return function(){return t[e].bind(this,this).apply(this,arguments)}}(n));return r}}},JSON:{__class__:$B.make_class("JSON"),parse:function(){return $B.structuredclone2pyobj(JSON.parse.apply(this,arguments))},stringify:function(e,t,r){return JSON.stringify($B.pyobj2structuredclone(e,!1),$B.JSObj.$factory(t),r)}},jsobj2pyobj:function(e){return $B.jsobj2pyobj(e)},load:function(script_url){console.log('"javascript.load" is deprecrated. Use browser.load instead.');var file_obj=$B.builtins.open(script_url),content=$B.$getattr(file_obj,"read")();eval(content)},$$Math:self.Math&&$B.JSObj.$factory(self.Math),NULL:null,$$Number:self.Number&&$B.JSObj.$factory(self.Number),py2js:function(e,t){return void 0===t&&(t="__main__"+$B.UUID()),$B.py2js(e,t,t,$B.builtins_scope).to_js()},pyobj2jsobj:function(e){return $B.pyobj2jsobj(e)},$$RegExp:self.RegExp&&$B.JSObj.$factory(self.RegExp),$$String:self.String&&$B.JSObj.$factory(self.String),$$super:super_class,UNDEFINED:$B.Undefined,UndefinedType:$B.UndefinedClass};var arraybuffers=["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];arraybuffers.forEach((function(e){void 0!==self[e]&&(modules.javascript[e]=$B.JSObj.$factory(self[e]))}));var _b_=$B.builtins;modules._sys={Getframe:function(){var e=$B.args("_getframe",1,{depth:null},["depth"],arguments,{depth:0},null,null),t=e.depth;return $B._frame.$factory($B.frames_stack,$B.frames_stack.length-t-1)},breakpointhook:function(){var e,t,r,n,o=$B.$options.breakpoint;void 0===o&&(o="pdb.set_trace"),[e,t,r]=_b_.str.rpartition(o,"."),""==t&&(e="builtins");try{$B.$import(e),n=$B.$getattr($B.imported[e],r)}catch(e){return console.warn("cannot import breakpoint",o),_b_.None}return $B.$call(n).apply(null,arguments)},exc_info:function(){for(var e=$B.frames_stack.length-1;e>=0;e--){var t=$B.frames_stack[e][1].$current_exception;if(t)return _b_.tuple.$factory([t.__class__,t,$B.$getattr(t,"__traceback__")])}return _b_.tuple.$factory([_b_.None,_b_.None,_b_.None])},excepthook:function(e,t,r){$B.handle_error(t)},gettrace:function(){return $B.tracefunc||_b_.None},modules:_b_.property.$factory((function(){return $B.obj_dict($B.imported)}),(function(e,t,r){throw _b_.TypeError.$factory("Read only property 'sys.modules'")})),path:_b_.property.$factory((function(){return $B.path}),(function(e,t,r){$B.path=r})),meta_path:_b_.property.$factory((function(){return $B.meta_path}),(function(e,t,r){$B.meta_path=r})),path_hooks:_b_.property.$factory((function(){return $B.path_hooks}),(function(e,t,r){$B.path_hooks=r})),path_importer_cache:_b_.property.$factory((function(){return _b_.dict.$factory($B.JSObj.$factory($B.path_importer_cache))}),(function(e,t,r){throw _b_.TypeError.$factory("Read only property 'sys.path_importer_cache'")})),settrace:function(){var e=$B.args("settrace",1,{tracefunc:null},["tracefunc"],arguments,{},null,null);return $B.tracefunc=e.tracefunc,$B.last($B.frames_stack)[1].$f_trace=$B.tracefunc,$B.tracefunc.$current_frame_id=$B.last($B.frames_stack)[0],_b_.None},stderr:_b_.property.$factory((function(){return $B.stderr}),(function(e,t){$B.stderr=t})),stdout:_b_.property.$factory((function(){return $B.stdout}),(function(e,t){$B.stdout=t})),stdin:_b_.property.$factory((function(){return $B.stdin}),(function(e,t){$B.stdin=t})),vfs:_b_.property.$factory((function(){return $B.hasOwnProperty("VFS")?$B.obj_dict($B.VFS):_b_.None}),(function(){throw _b_.TypeError.$factory("Read only property 'sys.vfs'")}))},modules._sys.__breakpointhook__=modules._sys.breakpointhook,modules._sys.stderr.write=function(e){return $B.$getattr(_sys.stderr.__get__(),"write")(e)},modules._sys.stdout.write=function(e){return $B.$getattr(_sys.stdout.__get__(),"write")(e)};var WarningMessage=$B.make_class("WarningMessage",(function(){var e=$B.make_args("WarningMessage",8,{message:null,category:null,filename:null,lineno:null,file:null,line:null,source:null},["message","category","filename","lineno","file","line","source"],arguments,{file:_b_.None,line:_b_.None,source:_b_.None},null,null);return{__class__:WarningMessage,message:e.message,category:e.category,filename:e.filename,lineno:e.lineno,file:e.file,line:e.line,source:e.source,_category_name:_b_.bool.$factory(e.category)?$B.$getattr(e.category,"__name__"):_b_.None}}));function load(e,t){for(var r in t.__class__=$B.module,t.__name__=e,$B.imported[e]=t,t)if("function"==typeof t[r]){var n=$B.from_alias(r);t[r].$infos={__module__:e,__name__:n,__qualname__:e+"."+n}}}for(var attr in modules._warnings={_defaultaction:"default",_filters_mutated:function(){},_onceregistry:$B.empty_dict(),filters:[$B.fast_tuple(["default",_b_.None,_b_.DeprecationWarning,"__main__",0]),$B.fast_tuple(["ignore",_b_.None,_b_.DeprecationWarning,_b_.None,0]),$B.fast_tuple(["ignore",_b_.None,_b_.PendingDeprecationWarning,_b_.None,0]),$B.fast_tuple(["ignore",_b_.None,_b_.ImportWarning,_b_.None,0]),$B.fast_tuple(["ignore",_b_.None,_b_.ResourceWarning,_b_.None,0])],warn:function(e){if($B.imported.warnings){if("error"==$B.imported.warnings.filters[0][0]){var t=_b_.SyntaxError.$factory(e.args[0]);throw t.args[1]=[e.filename,e.lineno,e.offset,e.line],t.filename=e.filename,t.lineno=e.lineno,t.offset=e.offset,t.line=e.line,t}var r=$B.imported._sys.Getframe();warning_message={__class__:WarningMessage,$$message:e,category:e.__class__,filename:e.filename||r.f_code.co_filename,lineno:e.lineno||r.f_lineno,file:_b_.None,line:_b_.None,source:_b_.None,_category_name:e.__class__.__name__},$B.imported.warnings._showwarnmsg_impl(warning_message)}else console.log("warnings not imported")},warn_explicit:function(){console.log("warn_explicit",arguments)}},modules)load(attr,modules[attr]);$B.isWebWorker||$B.isNode||(modules.browser.html=modules["browser.html"]);var _b_=$B.builtins;for(var attr in _b_.__builtins__=$B.module.$factory("__builtins__","Python builtins"),_b_)_b_.__builtins__[attr]=_b_[attr],$B.builtins_scope.binding[attr]=!0;for(var name in _b_.__builtins__.__setattr__=function(e,t){_b_[e]=t},$B.method_descriptor.__getattribute__=$B.Function.__getattribute__,$B.wrapper_descriptor.__getattribute__=$B.Function.__getattribute__,_b_)if(_b_[name].__class__===_b_.type)for(var key in $B.builtin_classes.push(_b_[name]),_b_[name]){var value=_b_[name][key];void 0!==value&&(value.__class__||"function"==typeof value&&("__new__"==key?value.__class__=$B.builtin_function:key.startsWith("__")?value.__class__=$B.wrapper_descriptor:value.__class__=$B.method_descriptor,value.__objclass__=_b_[name]))}for(var attr in $B)Array.isArray($B[attr])&&($B[attr].__class__=_b_.list);$B.cell=$B.make_class("cell",(function(e){return{__class__:$B.cell,$cell_contents:e}})),$B.cell.cell_contents=$B.$call(_b_.property)((function(e){if(null===e.$cell_contents)throw _b_.ValueError.$factory("empty cell");return e.$cell_contents}),(function(e,t){e.$cell_contents=t}));var $comps=Object.values($B.$comps).concat(["eq","ne"]);$comps.forEach((function(e){var t="__"+e+"__";$B.cell[t]=function(e){return function(t,r){return _b_.isinstance(r,$B.cell)?null===t.$cell_contents?null===r.$cell_contents?"__eq__"==e:["__ne__","__lt__","__le__"].indexOf(e)>-1:null===r.$cell_contents?["__ne__","__gt__","__ge__"].indexOf(e)>-1:$B.rich_comp(e,t.$cell_contents,r.$cell_contents):NotImplemented}}(t)})),$B.set_func_names($B.cell,"builtins")}(__BRYTHON__);var docs={ArithmeticError:"Base class for arithmetic errors.",AssertionError:"Assertion failed.",AttributeError:"Attribute not found.",BaseException:"Common base class for all exceptions",BlockingIOError:"I/O operation would block.",BrokenPipeError:"Broken pipe.",BufferError:"Buffer error.",BytesWarning:"Base class for warnings about bytes and buffer related problems, mostly\nrelated to conversion from str or comparing to str.",ChildProcessError:"Child process error.",ConnectionAbortedError:"Connection aborted.",ConnectionError:"Connection error.",ConnectionRefusedError:"Connection refused.",ConnectionResetError:"Connection reset.",DeprecationWarning:"Base class for warnings about deprecated features.",EOFError:"Read beyond end of file.",Ellipsis:"",EnvironmentError:"Base class for I/O related errors.",Exception:"Common base class for all non-exit exceptions.",False:"bool(x) -> bool\n\nReturns True when the argument x is true, False otherwise.\nThe builtins True and False are the only two instances of the class bool.\nThe class bool is a subclass of the class int, and cannot be subclassed.",FileExistsError:"File already exists.",FileNotFoundError:"File not found.",FloatingPointError:"Floating point operation failed.",FutureWarning:"Base class for warnings about constructs that will change semantically\nin the future.",GeneratorExit:"Request that a generator exit.",IOError:"Base class for I/O related errors.",ImportError:"Import can't find module, or can't find name in module.",ImportWarning:"Base class for warnings about probable mistakes in module imports",IndentationError:"Improper indentation.",IndexError:"Sequence index out of range.",InterruptedError:"Interrupted by signal.",IsADirectoryError:"Operation doesn't work on directories.",KeyError:"Mapping key not found.",KeyboardInterrupt:"Program interrupted by user.",LookupError:"Base class for lookup errors.",MemoryError:"Out of memory.",NameError:"Name not found globally.",None:"",NotADirectoryError:"Operation only works on directories.",NotImplemented:"",NotImplementedError:"Method or function hasn't been implemented yet.",OSError:"Base class for I/O related errors.",OverflowError:"Result too large to be represented.",PendingDeprecationWarning:"Base class for warnings about features which will be deprecated\nin the future.",PermissionError:"Not enough permissions.",ProcessLookupError:"Process not found.",ReferenceError:"Weak ref proxy used after referent went away.",ResourceWarning:"Base class for warnings about resource usage.",RuntimeError:"Unspecified run-time error.",RuntimeWarning:"Base class for warnings about dubious runtime behavior.",StopIteration:"Signal the end from iterator.__next__().",SyntaxError:"Invalid syntax.",SyntaxWarning:"Base class for warnings about dubious syntax.",SystemError:"Internal error in the Python interpreter.\n\nPlease report this to the Python maintainer, along with the traceback,\nthe Python version, and the hardware/OS platform and version.",SystemExit:"Request to exit from the interpreter.",TabError:"Improper mixture of spaces and tabs.",TimeoutError:"Timeout expired.",True:"bool(x) -> bool\n\nReturns True when the argument x is true, False otherwise.\nThe builtins True and False are the only two instances of the class bool.\nThe class bool is a subclass of the class int, and cannot be subclassed.",TypeError:"Inappropriate argument type.",UnboundLocalError:"Local name referenced but not bound to a value.",UnicodeDecodeError:"Unicode decoding error.",UnicodeEncodeError:"Unicode encoding error.",UnicodeError:"Unicode related error.",UnicodeTranslateError:"Unicode translation error.",UnicodeWarning:"Base class for warnings about Unicode related problems, mostly\nrelated to conversion problems.",UserWarning:"Base class for warnings generated by user code.",ValueError:"Inappropriate argument value (of correct type).",Warning:"Base class for warning categories.",WindowsError:"Base class for I/O related errors.",ZeroDivisionError:"Second argument to a division or modulo operation was zero.",__debug__:"bool(x) -> bool\n\nReturns True when the argument x is true, False otherwise.\nThe builtins True and False are the only two instances of the class bool.\nThe class bool is a subclass of the class int, and cannot be subclassed.",abs:"abs(number) -> number\n\nReturn the absolute value of the argument.",all:"all(iterable) -> bool\n\nReturn True if bool(x) is True for all values x in the iterable.\nIf the iterable is empty, return True.",any:"any(iterable) -> bool\n\nReturn True if bool(x) is True for any x in the iterable.\nIf the iterable is empty, return False.",ascii:"ascii(object) -> string\n\nAs repr(), return a string containing a printable representation of an\nobject, but escape the non-ASCII characters in the string returned by\nrepr() using \\x, \\u or \\U escapes. This generates a string similar\nto that returned by repr() in Python 2.",bin:"bin(number) -> string\n\nReturn the binary representation of an integer.\n\n >>> bin(2796202)\n '0b1010101010101010101010'\n",bool:"bool(x) -> bool\n\nReturns True when the argument x is true, False otherwise.\nThe builtins True and False are the only two instances of the class bool.\nThe class bool is a subclass of the class int, and cannot be subclassed.",bytearray:"bytearray(iterable_of_ints) -> bytearray\nbytearray(string, encoding[, errors]) -> bytearray\nbytearray(bytes_or_buffer) -> mutable copy of bytes_or_buffer\nbytearray(int) -> bytes array of size given by the parameter initialized with null bytes\nbytearray() -> empty bytes array\n\nConstruct an mutable bytearray object from:\n - an iterable yielding integers in range(256)\n - a text string encoded using the specified encoding\n - a bytes or a buffer object\n - any object implementing the buffer API.\n - an integer",bytes:"bytes(iterable_of_ints) -> bytes\nbytes(string, encoding[, errors]) -> bytes\nbytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer\nbytes(int) -> bytes object of size given by the parameter initialized with null bytes\nbytes() -> empty bytes object\n\nConstruct an immutable array of bytes from:\n - an iterable yielding integers in range(256)\n - a text string encoded using the specified encoding\n - any object implementing the buffer API.\n - an integer",callable:"callable(object) -> bool\n\nReturn whether the object is callable (i.e., some kind of function).\nNote that classes are callable, as are instances of classes with a\n__call__() method.",chr:"chr(i) -> Unicode character\n\nReturn a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff.",classmethod:"classmethod(function) -> method\n\nConvert a function to be a class method.\n\nA class method receives the class as implicit first argument,\njust like an instance method receives the instance.\nTo declare a class method, use this idiom:\n\n class C:\n def f(cls, arg1, arg2, ...): ...\n f = classmethod(f)\n\nIt can be called either on the class (e.g. C.f()) or on an instance\n(e.g. C().f()). The instance is ignored except for its class.\nIf a class method is called for a derived class, the derived class\nobject is passed as the implied first argument.\n\nClass methods are different than C++ or Java static methods.\nIf you want those, see the staticmethod builtin.",compile:"compile(source, filename, mode[, flags[, dont_inherit]]) -> code object\n\nCompile the source (a Python module, statement or expression)\ninto a code object that can be executed by exec() or eval().\nThe filename will be used for run-time error messages.\nThe mode must be 'exec' to compile a module, 'single' to compile a\nsingle (interactive) statement, or 'eval' to compile an expression.\nThe flags argument, if present, controls which future statements influence\nthe compilation of the code.\nThe dont_inherit argument, if non-zero, stops the compilation inheriting\nthe effects of any future statements in effect in the code calling\ncompile; if absent or zero these statements do influence the compilation,\nin addition to any features explicitly specified.",complex:"complex(real[, imag]) -> complex number\n\nCreate a complex number from a real part and an optional imaginary part.\nThis is equivalent to (real + imag*1j) where imag defaults to 0.",copyright:"interactive prompt objects for printing the license text, a list of\n contributors and the copyright notice.",credits:"interactive prompt objects for printing the license text, a list of\n contributors and the copyright notice.",delattr:"delattr(object, name)\n\nDelete a named attribute on an object; delattr(x, 'y') is equivalent to\n``del x.y''.",dict:"dict() -> new empty dictionary\ndict(mapping) -> new dictionary initialized from a mapping object's\n (key, value) pairs\ndict(iterable) -> new dictionary initialized as if via:\n d = {}\n for k, v in iterable:\n d[k] = v\ndict(**kwargs) -> new dictionary initialized with the name=value pairs\n in the keyword argument list. For example: dict(one=1, two=2)",dir:"dir([object]) -> list of strings\n\nIf called without an argument, return the names in the current scope.\nElse, return an alphabetized list of names comprising (some of) the attributes\nof the given object, and of attributes reachable from it.\nIf the object supplies a method named __dir__, it will be used; otherwise\nthe default dir() logic is used and returns:\n for a module object: the module's attributes.\n for a class object: its attributes, and recursively the attributes\n of its bases.\n for any other object: its attributes, its class's attributes, and\n recursively the attributes of its class's base classes.",divmod:"divmod(x, y) -> (div, mod)\n\nReturn the tuple ((x-x%y)/y, x%y). Invariant: div*y + mod == x.",enumerate:"enumerate(iterable[, start]) -> iterator for index, value of iterable\n\nReturn an enumerate object. iterable must be another object that supports\niteration. The enumerate object yields pairs containing a count (from\nstart, which defaults to zero) and a value yielded by the iterable argument.\nenumerate is useful for obtaining an indexed list:\n (0, seq[0]), (1, seq[1]), (2, seq[2]), ...",eval:"eval(source[, globals[, locals]]) -> value\n\nEvaluate the source in the C of globals and locals.\nThe source may be a string representing a Python expression\nor a code object as returned by compile().\nThe globals must be a dictionary and locals can be any mapping,\ndefaulting to the current globals and locals.\nIf only globals is given, locals defaults to it.\n",exec:"exec(object[, globals[, locals]])\n\nRead and execute code from an object, which can be a string or a code\nobject.\nThe globals and locals are dictionaries, defaulting to the current\nglobals and locals. If only globals is given, locals defaults to it.",exit:"",filter:"filter(function or None, iterable) --\x3e filter object\n\nReturn an iterator yielding those items of iterable for which function(item)\nis true. If function is None, return the items that are true.",float:"float(x) -> floating point number\n\nConvert a string or number to a floating point number, if possible.",format:'format(value[, format_spec]) -> string\n\nReturns value.__format__(format_spec)\nformat_spec defaults to ""',frozenset:"frozenset() -> empty frozenset object\nfrozenset(iterable) -> frozenset object\n\nBuild an immutable unordered collection of unique elements.",getattr:"getattr(object, name[, default]) -> value\n\nGet a named attribute from an object; getattr(x, 'y') is equivalent to x.y.\nWhen a default argument is given, it is returned when the attribute doesn't\nexist; without it, an exception is raised in that case.",globals:"globals() -> dictionary\n\nReturn the dictionary containing the current scope's global variables.",hasattr:"hasattr(object, name) -> bool\n\nReturn whether the object has an attribute with the given name.\n(This is done by calling getattr(object, name) and catching AttributeError.)",hash:"hash(object) -> integer\n\nReturn a hash value for the object. Two objects with the same value have\nthe same hash value. The reverse is not necessarily true, but likely.",help:"Define the builtin 'help'.\n\n This is a wrapper around pydoc.help that provides a helpful message\n when 'help' is typed at the Python interactive prompt.\n\n Calling help() at the Python prompt starts an interactive help session.\n Calling help(thing) prints help for the python object 'thing'.\n ",hex:"hex(number) -> string\n\nReturn the hexadecimal representation of an integer.\n\n >>> hex(3735928559)\n '0xdeadbeef'\n",id:"id(object) -> integer\n\nReturn the identity of an object. This is guaranteed to be unique among\nsimultaneously existing objects. (Hint: it's the object's memory address.)",input:"input([prompt]) -> string\n\nRead a string from standard input. The trailing newline is stripped.\nIf the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return), raise EOFError.\nOn Unix, GNU readline is used if enabled. The prompt string, if given,\nis printed without a trailing newline before reading.",int:"int(x=0) -> integer\nint(x, base=10) -> integer\n\nConvert a number or string to an integer, or return 0 if no arguments\nare given. If x is a number, return x.__int__(). For floating point\nnumbers, this truncates towards zero.\n\nIf x is not a number or if base is given, then x must be a string,\nbytes, or bytearray instance representing an integer literal in the\ngiven base. The literal can be preceded by '+' or '-' and be surrounded\nby whitespace. The base defaults to 10. Valid bases are 0 and 2-36.\nBase 0 means to interpret the base from the string as an integer literal.\n>>> int('0b100', base=0)\n4",isinstance:"isinstance(object, class-or-type-or-tuple) -> bool\n\nReturn whether an object is an instance of a class or of a subclass thereof.\nWith a type as second argument, return whether that is the object's type.\nThe form using a tuple, isinstance(x, (A, B, ...)), is a shortcut for\nisinstance(x, A) or isinstance(x, B) or ... (etc.).",issubclass:"issubclass(C, B) -> bool\n\nReturn whether class C is a subclass (i.e., a derived class) of class B.\nWhen using a tuple as the second argument issubclass(X, (A, B, ...)),\nis a shortcut for issubclass(X, A) or issubclass(X, B) or ... (etc.).",iter:"iter(iterable) -> iterator\niter(callable, sentinel) -> iterator\n\nGet an iterator from an object. In the first form, the argument must\nsupply its own iterator, or be a sequence.\nIn the second form, the callable is called until it returns the sentinel.",len:"len(object)\n\nReturn the number of items of a sequence or collection.",license:"interactive prompt objects for printing the license text, a list of\n contributors and the copyright notice.",list:"list() -> new empty list\nlist(iterable) -> new list initialized from iterable's items",locals:"locals() -> dictionary\n\nUpdate and return a dictionary containing the current scope's local variables.",map:"map(func, *iterables) --\x3e map object\n\nMake an iterator that computes the function using arguments from\neach of the iterables. Stops when the shortest iterable is exhausted.",max:"max(iterable, *[, default=obj, key=func]) -> value\nmax(arg1, arg2, *args, *[, key=func]) -> value\n\nWith a single iterable argument, return its biggest item. The\ndefault keyword-only argument specifies an object to return if\nthe provided iterable is empty.\nWith two or more arguments, return the largest argument.",memoryview:"memoryview(object)\n\nCreate a new memoryview object which references the given object.",min:"min(iterable, *[, default=obj, key=func]) -> value\nmin(arg1, arg2, *args, *[, key=func]) -> value\n\nWith a single iterable argument, return its smallest item. The\ndefault keyword-only argument specifies an object to return if\nthe provided iterable is empty.\nWith two or more arguments, return the smallest argument.",next:"next(iterator[, default])\n\nReturn the next item from the iterator. If default is given and the iterator\nis exhausted, it is returned instead of raising StopIteration.",object:"The most base type",oct:"oct(number) -> string\n\nReturn the octal representation of an integer.\n\n >>> oct(342391)\n '0o1234567'\n",open:"open(file, mode='r', buffering=-1, encoding=None,\n errors=None, newline=None, closefd=True, opener=None) -> file object\n\nOpen file and return a stream. Raise IOError upon failure.\n\nfile is either a text or byte string giving the name (and the path\nif the file isn't in the current working directory) of the file to\nbe opened or an integer file descriptor of the file to be\nwrapped. (If a file descriptor is given, it is closed when the\nreturned I/O object is closed, unless closefd is set to False.)\n\nmode is an optional string that specifies the mode in which the file\nis opened. It defaults to 'r' which means open for reading in text\nmode. Other common values are 'w' for writing (truncating the file if\nit already exists), 'x' for creating and writing to a new file, and\n'a' for appending (which on some Unix systems, means that all writes\nappend to the end of the file regardless of the current seek position).\nIn text mode, if encoding is not specified the encoding used is platform\ndependent: locale.getpreferredencoding(False) is called to get the\ncurrent locale encoding. (For reading and writing raw bytes use binary\nmode and leave encoding unspecified.) The available modes are:\n\n========= ===============================================================\nCharacter Meaning\n--------- ---------------------------------------------------------------\n'r' open for reading (default)\n'w' open for writing, truncating the file first\n'x' create a new file and open it for writing\n'a' open for writing, appending to the end of the file if it exists\n'b' binary mode\n't' text mode (default)\n'+' open a disk file for updating (reading and writing)\n'U' universal newline mode (deprecated)\n========= ===============================================================\n\nThe default mode is 'rt' (open for reading text). For binary random\naccess, the mode 'w+b' opens and truncates the file to 0 bytes, while\n'r+b' opens the file without truncation. The 'x' mode implies 'w' and\nraises an `FileExistsError` if the file already exists.\n\nPython distinguishes between files opened in binary and text modes,\neven when the underlying operating system doesn't. Files opened in\nbinary mode (appending 'b' to the mode argument) return contents as\nbytes objects without any decoding. In text mode (the default, or when\n't' is appended to the mode argument), the contents of the file are\nreturned as strings, the bytes having been first decoded using a\nplatform-dependent encoding or using the specified encoding if given.\n\n'U' mode is deprecated and will raise an exception in future versions\nof Python. It has no effect in Python 3. Use newline to control\nuniversal newlines mode.\n\nbuffering is an optional integer used to set the buffering policy.\nPass 0 to switch buffering off (only allowed in binary mode), 1 to select\nline buffering (only usable in text mode), and an integer > 1 to indicate\nthe size of a fixed-size chunk buffer. When no buffering argument is\ngiven, the default buffering policy works as follows:\n\n* Binary files are buffered in fixed-size chunks; the size of the buffer\n is chosen using a heuristic trying to determine the underlying device's\n \"block size\" and falling back on `io.DEFAULT_BUFFER_SIZE`.\n On many systems, the buffer will typically be 4096 or 8192 bytes long.\n\n* \"Interactive\" text files (files for which isatty() returns True)\n use line buffering. Other text files use the policy described above\n for binary files.\n\nencoding is the name of the encoding used to decode or encode the\nfile. This should only be used in text mode. The default encoding is\nplatform dependent, but any encoding supported by Python can be\npassed. See the codecs module for the list of supported encodings.\n\nerrors is an optional string that specifies how encoding errors are to\nbe handled---this argument should not be used in binary mode. Pass\n'strict' to raise a ValueError exception if there is an encoding error\n(the default of None has the same effect), or pass 'ignore' to ignore\nerrors. (Note that ignoring encoding errors can lead to data loss.)\nSee the documentation for codecs.register or run 'help(codecs.Codec)'\nfor a list of the permitted encoding error strings.\n\nnewline controls how universal newlines works (it only applies to text\nmode). It can be None, '', '\\n', '\\r', and '\\r\\n'. It works as\nfollows:\n\n* On input, if newline is None, universal newlines mode is\n enabled. Lines in the input can end in '\\n', '\\r', or '\\r\\n', and\n these are translated into '\\n' before being returned to the\n caller. If it is '', universal newline mode is enabled, but line\n endings are returned to the caller untranslated. If it has any of\n the other legal values, input lines are only terminated by the given\n string, and the line ending is returned to the caller untranslated.\n\n* On output, if newline is None, any '\\n' characters written are\n translated to the system default line separator, os.linesep. If\n newline is '' or '\\n', no translation takes place. If newline is any\n of the other legal values, any '\\n' characters written are translated\n to the given string.\n\nIf closefd is False, the underlying file descriptor will be kept open\nwhen the file is closed. This does not work when a file name is given\nand must be True in that case.\n\nA custom opener can be used by passing a callable as *opener*. The\nunderlying file descriptor for the file object is then obtained by\ncalling *opener* with (*file*, *flags*). *opener* must return an open\nfile descriptor (passing os.open as *opener* results in functionality\nsimilar to passing None).\n\nopen() returns a file object whose type depends on the mode, and\nthrough which the standard file operations such as reading and writing\nare performed. When open() is used to open a file in a text mode ('w',\n'r', 'wt', 'rt', etc.), it returns a TextIOWrapper. When used to open\na file in a binary mode, the returned class varies: in read binary\nmode, it returns a BufferedReader; in write binary and append binary\nmodes, it returns a BufferedWriter, and in read/write mode, it returns\na BufferedRandom.\n\nIt is also possible to use a string or bytearray as a file for both\nreading and writing. For strings StringIO can be used like a file\nopened in a text mode, and for bytes a BytesIO can be used like a file\nopened in a binary mode.\n",ord:"ord(c) -> integer\n\nReturn the integer ordinal of a one-character string.",pow:"pow(x, y[, z]) -> number\n\nWith two arguments, equivalent to x**y. With three arguments,\nequivalent to (x**y) % z, but may be more efficient (e.g. for ints).",print:"print(value, ..., sep=' ', end='\\n', file=sys.stdout, flush=False)\n\nPrints the values to a stream, or to sys.stdout by default.\nOptional keyword arguments:\nfile: a file-like object (stream); defaults to the current sys.stdout.\nsep: string inserted between values, default a space.\nend: string appended after the last value, default a newline.\nflush: whether to forcibly flush the stream.",property:"property(fget=None, fset=None, fdel=None, doc=None) -> property attribute\n\nfget is a function to be used for getting an attribute value, and likewise\nfset is a function for setting, and fdel a function for del'ing, an\nattribute. Typical use is to define a managed attribute x:\n\nclass C(object):\n def getx(self): return self._x\n def setx(self, value): self._x = value\n def delx(self): del self._x\n x = property(getx, setx, delx, \"I'm the 'x' property.\")\n\nDecorators make defining new properties or modifying existing ones easy:\n\nclass C(object):\n @property\n def x(self):\n \"I am the 'x' property.\"\n return self._x\n @x.setter\n def x(self, value):\n self._x = value\n @x.deleter\n def x(self):\n del self._x\n",quit:"",range:"range(stop) -> range object\nrange(start, stop[, step]) -> range object\n\nReturn a virtual sequence of numbers from start to stop by step.",repr:"repr(object) -> string\n\nReturn the canonical string representation of the object.\nFor most object types, eval(repr(object)) == object.",reversed:"reversed(sequence) -> reverse iterator over values of the sequence\n\nReturn a reverse iterator",round:"round(number[, ndigits]) -> number\n\nRound a number to a given precision in decimal digits (default 0 digits).\nThis returns an int when called with one argument, otherwise the\nsame type as the number. ndigits may be negative.",set:"set() -> new empty set object\nset(iterable) -> new set object\n\nBuild an unordered collection of unique elements.",setattr:"setattr(object, name, value)\n\nSet a named attribute on an object; setattr(x, 'y', v) is equivalent to\n``x.y = v''.",slice:"slice(stop)\nslice(start, stop[, step])\n\nCreate a slice object. This is used for extended slicing (e.g. a[0:10:2]).",sorted:"sorted(iterable, key=None, reverse=False) --\x3e new sorted list",staticmethod:"staticmethod(function) -> method\n\nConvert a function to be a static method.\n\nA static method does not receive an implicit first argument.\nTo declare a static method, use this idiom:\n\n class C:\n def f(arg1, arg2, ...): ...\n f = staticmethod(f)\n\nIt can be called either on the class (e.g. C.f()) or on an instance\n(e.g. C().f()). The instance is ignored except for its class.\n\nStatic methods in Python are similar to those found in Java or C++.\nFor a more advanced concept, see the classmethod builtin.",str:"str(object='') -> str\nstr(bytes_or_buffer[, encoding[, errors]]) -> str\n\nCreate a new string object from the given object. If encoding or\nerrors is specified, then the object must expose a data buffer\nthat will be decoded using the given encoding and error handler.\nOtherwise, returns the result of object.__str__() (if defined)\nor repr(object).\nencoding defaults to sys.getdefaultencoding().\nerrors defaults to 'strict'.",sum:"sum(iterable[, start]) -> value\n\nReturn the sum of an iterable of numbers (NOT strings) plus the value\nof parameter 'start' (which defaults to 0). When the iterable is\nempty, return start.",super:"super() -> same as super(__class__, )\nsuper(type) -> unbound super object\nsuper(type, obj) -> bound super object; requires isinstance(obj, type)\nsuper(type, type2) -> bound super object; requires issubclass(type2, type)\nTypical use to call a cooperative superclass method:\nclass C(B):\n def meth(self, arg):\n super().meth(arg)\nThis works for class methods too:\nclass C(B):\n @classmethod\n def cmeth(cls, arg):\n super().cmeth(arg)\n",tuple:"tuple() -> empty tuple\ntuple(iterable) -> tuple initialized from iterable's items\n\nIf the argument is a tuple, the return value is the same object.",type:"type(object_or_name, bases, dict)\ntype(object) -> the object's type\ntype(name, bases, dict) -> a new type",vars:"vars([object]) -> dictionary\n\nWithout arguments, equivalent to locals().\nWith an argument, equivalent to object.__dict__.",zip:"zip(iter1 [,iter2 [...]]) --\x3e zip object\n\nReturn a zip object whose .__next__() method returns a tuple where\nthe i-th element comes from the i-th iterable argument. The .__next__()\nmethod continues until the shortest iterable in the argument sequence\nis exhausted and then it raises StopIteration."};__BRYTHON__.builtins_doc=docs,function(e){e.builtins;var t=e.coroutine=e.make_class("coroutine");t.close=function(e){},t.send=function(e){return e.$func.apply(null,e.$args)},t.__repr__=t.__str__=function(e){return e.$func.$infos?"":""},e.set_func_names(t,"builtins"),e.make_async=r=>{if(r.$is_genfunc)return r;var n=function(){var n=arguments,o=e.deep_copy(e.frames_stack);return{__class__:t,$args:n,$func:r,$stack:o}};return n.$infos=r.$infos,n},e.promise=function(e){return e.__class__===t?t.send(e):"function"==typeof e?e():e}}(__BRYTHON__); //# sourceMappingURL=/sm/e70a0b9f1741db691940077d46cbfbe928dcb7d65b5d01d9d156ad38e320576e.map