-
Notifications
You must be signed in to change notification settings - Fork 2
/
bitwrench_ESM.min.js
1 lines (1 loc) · 41.7 KB
/
bitwrench_ESM.min.js
1
export let bw=(()=>{var bw={};bw.exportName="bw";bw.exportModuleType="AMD";bw.choice=function(x,choices,def){var z=x in choices?choices[x]:def;return _to(z)=="function"?z(x):z};bw.jsonClone=function(x){return JSON.parse(JSON.stringify(x))};bw.typeOf=function(x,baseTypeOnly){if(x===null)return"null";var y=typeof x=="undefined"?"undefined":{}.toString.call(x).match(/\s([a-zA-Z]+)/)[1].toLocaleLowerCase();if(y!="object"&&y!="function")return y;if(baseTypeOnly==true)return y;var r=y;try{r=x.constructor.name.toLocaleLowerCase()==y.toLocaleLowerCase()?y:x.constructor.name}catch(e){}if(r=="object"){if(x["_is_BW_HTMLNode"]==true)r="BW_HTMLNode"}return r};var _to=bw.typeOf;bw.to=_to;bw.typeAssign=function(a,typeString,trueValue,falseValue){if(["string","array"].indexOf(_to(typeString))==-1)typeString="notValidType";if(_to(typeString)=="string")typeString=[typeString];return typeString.indexOf(_to(a))>=0?trueValue:falseValue};var _toa=bw.toa=bw.typeAssign;bw.typeConvert=function(a,typeString,trueValue,falseValue){if(["string","array"].indexOf(_to(typeString))==-1)typeString="notValidType";if(_to(typeString)=="string")typeString=[typeString];return typeString.indexOf(_to(a))>=0?_to(trueValue)=="function"?trueValue(a):trueValue:_to(falseValue)=="function"?falseValue(a):falseValue};var _toc=bw.tc=bw.typeConvert;var optsCopy=function(dopts,opts){if(_to(opts)=="object"&&_to(dopts)=="object"){var i;for(i in opts){if(_to(opts[i])=="object"||_to(dopts[i])=="object"){var j;for(j in opts[i])dopts[i][j]=opts[i][j]}else dopts[i]=opts[i]}}return dopts};bw._oc=optsCopy;bw.arrayUniq=function(x){if(_to(x)!="array")return[];return x.filter(function(v,i,arr){return arr.indexOf(v)==i})};bw.arrayBinA=function(a,b){if(_to(a)!="array"||_to(b)!=="array")return[];return bw.arrayUniq(a.filter(function(n){return b.indexOf(n)!==-1}))};bw.arrayBNotInA=function(a,b){if(_to(a)!="array"||_to(b)!=="array")return[];return bw.arrayUniq(b.filter(function(n){return a.indexOf(n)<0}))};bw.DOMIsElement=function(el){var r=false;try{if(_to(el)=="undefined")return r;if(bw.isNodeJS()==false||typeof Element=="function")r=el instanceof Element}catch(e){r=typeof HTMLElement==="object"?el instanceof HTMLElement:el&&typeof el==="object"&&el!==null&&el.nodeType===1&&typeof el.nodeName==="string";bw.logd(e.toString())}return r};var _isEl=bw.DOMIsElement;bw.DOMGetElements=function(el,type){var r=[],a=[],i;if(bw.isNodeJS()==false){if(_isEl(el))return[el];if(_to(el)=="string"){type=_toa(type,"string",type,"auto");el.trim();if(type=="auto")type=bw.choice(el[0],{".":"className","#":"id"},"tagName");type=type.toLowerCase();switch(type){case"id":el=el[0]=="#"?el.substring(1,el.length):el;a=document.getElementById(el);a=_toa(a,"null",[],[a]);break;case"classname":el=el[0]=="."?el.substring(1,el.length):el;a=document.getElementsByClassName(el);break;case"tagname":a=document.getElementsByTagName(el);break;case"name":a=document.getElementsByName(el);break;case"css":a=document.querySelectorAll(el);break;default:a=document.querySelectorAll(el)}for(i in a)r.push(a[i])}}return r.filter(function(x){return _isEl(x)})};bw.DOMSetElements=function(domElement,param){var els=bw.DOMGetElements(domElement);if(els==[])bw.log("dom element not found");var i,l,e,ef=function(x,p){bw.log(x,p)};for(l=0;l<els.length;l++){e=els[l];switch(_to(param)){case"array":try{for(i=0;i<param.length;i++)e[param[i][0]]=param[i][1]}catch(d){ef(d,param)}break;case"object":try{for(i in param)e[i]=param[i]}catch(d){ef(d,param)}break;case"string":try{e.innerHTML=param}catch(d){ef(d,param)}break;case"function":try{param(e)}catch(d){ef(d,param)}break;default:break}}return els};bw.DOM=bw.DOMSetElements;bw.DOMInsertElement=function(parentEl,htmldata,putFirst){var el=null;if(bw.isNodeJS()==false){if(bw.DOMIsElement(htmldata))el=htmldata;else{el=document.createElement("div");el.innerHTML=bw.html(htmldata);el=el.firstChild}if(parentEl){parentEl=bw.DOM(parentEl)[0];if(putFirst){parentEl.insertBefore(el,parentEl.firstChild)}else parentEl.appendChild(el)}}return el};bw.DOMIns=bw.DOMInsertElement;bw.htmlToElement=function(htmldata){var el=null;if(bw.isNodeJS()==false){if(bw.DOMIsElement(htmldata))el=htmldata;else{el=document.createElement("div");el.innerHTML=bw.html(htmldata);el=el.firstChild}}return el};bw.DOMReplaceElement=function(oldEl,newEl){if(bw.isNodeJS()==false){var e=bw.DOM(oldEl)[0];return e.parentNode.replaceChild(bw.htmlToElement(newEl),e)}return null};bw.colorInterp=function(x,in0,in1,colors,stretch){var c=_toa(colors,"array",colors,["#000","#fff"]);c=c.length==0?["#000","#fff"]:c;if(c.length==1)return c[0];c=c.map(function(x){return bw.colorParse(x)});var a=bw.mapScale(x,in0,in1,0,c.length-1,{clip:true,expScale:stretch});var i=bw.clip(Math.floor(a),0,c.length-2);var r=a-i;var _f=function(x){return bw.mapScale(r,0,1,c[i][x],c[i+1][x],{clip:true})};return[_f(0),_f(1),_f(2),_f(3),"rgb"]};bw.colorHslToRgb=function(h,s,l,a,rnd){if(_to(h)=="array"){s=h[1];l=h[2];a=h[3];h=h[0]}var _fn=rnd==false?function(x){return x}:function(x){return bw.clip(Math.round(x),0,255)};var r,g,b,c,x,m;h=(h+360)%360;h/=60;if(h<0)h=6- -h%6;h%=6;s=Math.max(0,Math.min(1,s/100));l=Math.max(0,Math.min(1,l/100));c=(1-Math.abs(2*l-1))*s;x=c*(1-Math.abs(h%2-1));if(h<1){r=c;g=x;b=0}else if(h<2){r=x;g=c;b=0}else if(h<3){r=0;g=c;b=x}else if(h<4){r=0;g=x;b=c}else if(h<5){r=x;g=0;b=c}else{r=c;g=0;b=x}m=l-c/2;r=(r+m)*255;g=(g+m)*255;b=(b+m)*255;return[_fn(r),_fn(g),_fn(b),a,"rgb"]};bw.colorRgbToHsl=function(r,g,b,a,rnd){if(_to(r)=="array"){g=r[1];b=r[2];a=r[3];r=r[0]}r/=255,g/=255,b/=255;var max=Math.max(r,g,b),min=Math.min(r,g,b);var h,s,l=(max+min)/2;if(max==min){h=s=0}else{var d=max-min;s=l>.5?d/(2-max-min):d/(max+min);switch(max){case r:h=(g-b)/d+(g<b?6:0);break;case g:h=(b-r)/d+2;break;case b:h=(r-g)/d+4;break}h/=6}var _fn=rnd==false?function(x){return x}:function(x){return Math.round(x)};return[_fn(h*360),_fn(s*100),_fn(l*100),a,"hsl"]};bw.colorParse=function(s,defAlpha){defAlpha=_toa(defAlpha,"number",defAlpha,255);var r=[0,0,0,defAlpha,"rgb"];if(_to(s)=="array"){var p,df=[0,0,0,255,"rgb"];for(p=0;p<s.length;p++)df[p]=s[p];s=String(df[4])+"("+String(df[0])+","+String(df[1])+","+String(df[2])+","+String(df[3])+")"}s=String(s).replace(/\s/g,"");var reT=/\s*(#|hsl|rgb|yuv|hsv){1}([a-f|A-F|0-9|,().\t ]*)/gim;var i,j=0,x=reT.exec(s);if(_to(x)=="array"&&x.length>=3){r[4]=x[1]=="#"?"rgb":x;if(x[1]=="#"){switch(x[2].length){case 3:case 4:for(i=0;i<x[2].length;i++)r[i]=parseInt(x[2][i]+x[2][i],16);break;case 6:case 8:for(i=0;i<x[2].length;i+=2)r[j++]=parseInt(x[2][i]+x[2][i+1],16);break;default:bw.logd("bw.parseColor bad input "+s)}}else{r[4]=x[1].toLocaleLowerCase();if(x[2][0]=="("&&x[2][x[2].length-1]==")"){var v=x[2].substring(1,x[2].length-1);v=v.split(",");switch(v.length){case 3:case 4:for(i=0;i<v.length;i++)r[i]=Number(v[i]);break;default:bw.logd("bw.parseColor bad input : "+s)}}else{bw.logd("bw.parseColor bad input : "+s)}}}return r};bw.colorToRGBHex=function(c,format){var r="#00000000";var ph=function(x){var y=bw.clip(Math.round(x),0,255).toString(16);return y.length==1?"0"+y:y};c=bw.colorParse(c);switch(c[4]){case"rgb":r="#"+ph(c[0])+ph(c[1])+ph(c[2]);if(!(format=="auto"&&c[3]==255))r+=ph(c[3]);break;case"hsl":r=bw.colorToRGBHex(bw.colorHslToRgb(c));break;default:bw.logd("colorToRGBHex : unsupported format"+c[4])}return r};bw.colorConvertColorSpace=function(c,space,rnd){c=bw.colorParse(c);if(space==c[4])return c;switch(c[4]){case"rgb":break;case"hsl":c=bw.colorHslToRgb(c[0],c[1],c[2],c[3],rnd);break;default:bw.logd("colorConvertColorSpace: unsupported color format")}switch(space){case"rgb":break;case"hsl":c=bw.colorRgbToHsl(c[0],c[1],c[2],c[3],rnd);break;default:bw.logd("colorConvertColorSpace: unsupported color format")}return c};var _logdata=[];bw.log=function(value,msg,opts){var dopts={clear:false,saveMethod:"raw"};dopts=optsCopy(dopts,opts);if(dopts["clear"]==true||dopts["clear"]=="clear-only"){_logdata=[["Time-stamp (ms)"," Value "," Message "]];var ct=new Date;_logdata.push([0,ct.getTime()," log started at "+ct.toString()])}msg=_toa(msg,"undefined","",String(msg));value=dopts["saveMethod"]=="raw"?value:JSON.stringify(value);if(_to(value)!="undefined"&&dopts["clear"]!="clear-only")_logdata.push([(new Date).getTime()-_logdata[1][1],value,msg]);return _logdata.length-1};bw.log("","",{clear:"clear-only"});bw.logd=function(){var logdargs="bwlogd"in bw.bwargs?bw.bwargs["bwlogd"].split(","):[];if(logdargs.indexOf("none")<0){var i=0;var _a=[];for(i=0;i<arguments.length;i++)_a.push(arguments[i]);bw.log(_a,"bw.logd: "+bw.bwargs["bwlogd"])}};bw.logExport=function(opts){var dopts={format:"raw"};dopts=optsCopy(dopts,opts);var _ld=_logdata;if(dopts["format"]=="HTML"){return bw.makeHTMLTableStr(_ld,{sortable:true})}if(dopts["format"]=="text"){return _ld.map(function(x){return x.map(function(y){return bw.padString(y.toString(),16,"left")}).join("\t")}).join("\n")}return _ld};bw.setCookie=function(cname,cvalue,exdays){var d=new Date;d.setTime(d.getTime()+exdays*24*60*60*1e3);var expires="expires="+d.toUTCString();document.cookie=cname+"="+cvalue+"; "+expires};bw.getCookie=function(cname,defaultValue){var name=cname+"=";var ca=document.cookie.split(";");for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==" ")c=c.substring(1);if(c.indexOf(name)==0)return c.substring(name.length,c.length)}return defaultValue};bw.getURLParam=function(key,defaultValue){if(bw.isNodeJS()==true||typeof window!="object")return defaultValue;try{if(window.location.href){return bw.URLParamParse(window.location.href,key,defaultValue)}}catch(e){bw.log(e)}return defaultValue};bw.URLHash=function(url,defValue){if(_to(url)=="undefined")url=typeof window=="object"?window.location.href:"";var r=url.split(/#+/);return url.includes("#")?r[r.length-1]:defValue};bw.URLParamParse=function(url,key,defValue,allowHash){try{var hs=function(u){var x=u.split(/^.*\?+/);return x.length==2?x[1]:""};var sh=function(u,b){return b==true?u:u.split(/#+/)[0]};var params={},parts=sh(hs(url),allowHash).split("&");for(var i=0;i<parts.length;i++){var e=parts[i].split("=");if(!e[0])continue;params[decodeURIComponent(e[0])]=_to(e[1])=="string"?decodeURIComponent(e[1].replace("#","%23")):true}if(_to(key)=="undefined")return params;return params.hasOwnProperty(key)?params[key]:defValue}catch(e){bw.log(e);return defValue}};bw.URLParamPack=function(simpleDict,inclQuestion){var k,s=[];if(_to(simpleDict)=="object"){for(k in simpleDict){s.push([encodeURIComponent(k)+"="+encodeURIComponent(simpleDict[k].toString())])}s=s.join("&")}else s="";return(inclQuestion?"?":"")+s};bw.htmlSafeStr=function(str){var c={"<":"<",">":">","&":"&",'"':""","'":"'","#":"#","\\\\":"","\n":"<br>","\t":" "};return str.toString().replace(new RegExp("["+Object.keys(c).join("")+"]","gm"),function(s){return c[s]})};bw.htmlFavicon=function(iconStr,color){iconStr=iconStr?iconStr:"🔧";var c=bw.to(color)=="string"?color:"black";return bw.html({t:"link",a:{href:"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='0.9em' font-size='90' style='fill:"+c+"'>"+iconStr+"</text></svg>",rel:"icon"}})};bw.htmlJSON=function(json,pwrap){function f(json){json=JSON.stringify(json,undefined,2);if(typeof json!="string"){json=JSON.stringify(json,undefined,2)}json=json.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?)/g,function(match){var sty="color: darkorange;";if(/^"/.test(match)){if(/:$/.test(match)){sty="color:red"}else{sty="color:purple"}}else if(/true|false/.test(match)){sty="color:grey"}else if(/null/.test(match)){sty="color:black"}else sty="color:green";return'<span style="'+sty+'">'+match+"</span>"})}pwrap=_toa(pwrap,"undefined","white-space:pre-wrap;","");return"<pre style='"+pwrap+"'>"+f(json)+"</pre>"};bw.makeCSS=function(cssData,options){var dopts={emitStyleTag:false,atr:{},pretty:false};dopts=optsCopy(dopts,options);var s="\n";var tb=function(a){a=String(a).trim();a=(a[0]=="{"?" ":" {")+a;a+=(a[a.length]=="}"?"":"}")+"\n";return a};try{switch(_to(cssData)){case"string":s+=cssData+"\n";break;case"array":var i;for(i=0;i<cssData.length;i++){var j=cssData[i];switch(_to(j)){case"string":s+=j+"\n";break;case"array":if(j.length==1&&_to(j[0])=="string"){s+=j[0]+"\n";break}if(j.length==2){var _name=j[0],_rule=j[1],_ruleOutput="";if(_to(_name)=="array"){s+=_name.join(", ")}else{s+=String(_name)}switch(_to(_rule)){case"array":_ruleOutput=_rule.join("; ")+";";break;case"object":{var x;for(x in _rule){_ruleOutput+=x+": "+_rule[x]+"; "}}break;case"string":default:_ruleOutput=_rule}s+=tb(_ruleOutput)+"\n"}break;default:}}break;default:s=""}}catch(e){bw.logd(e)}if(dopts["emitStyleTag"]){s=bw.html(["style",dopts["atr"],s])}s.replace(/\n+/g,"\n").replace(/s+/g," ");return s};bw.makeCSSRule=function(cssData,options){var dopts={emitStyleTag:false,atr:{},pretty:true};dopts=optsCopy(dopts,options);var k,d,v=[],s="",sp=dopts.pretty?" ":"",cr=dopts.pretty?"\n":"";try{if(_to(cssData)=="array"){k=cssData[0],d=cssData[1];s+=_toa(k,"array",k,[k.toString()]).join(","+sp)+cr;for(k in d){v.push([sp+sp+k+":"+sp+cssData[1][k]+";"+sp+cr])}s+="{"+cr+v.join("")+"}"+cr}}catch(e){bw.logd(e)}return s};bw.htmlIsVoidTag=function(tag){return" area base br col command embed hr img input keygen link meta param source track wbr ".search(" "+String(tag).trim().toLowerCase()+" ")>=0};bw.htmlNode=function(x,opts){var err="",dopts={functionExec:true,atomic2span:false};dopts=optsCopy(dopts,opts);var isv=bw.htmlIsVoidTag;var isnu=function(x){return bw.toa(x,["null","undefined"],true,false)};var HTMLNode=function BW_HTMLNode(){this.t="div";this.a={};this.c=[];this.o={tagClose:"auto"};this._is_BW_HTMLNode=true};var i,n=new HTMLNode;switch(bw.to(x)){case"null":case"undefined":n="";err="error: html node content is "+bw.to(x);break;case"object":[["tag","t"],["attrib","a"],["content","c"],["options","o"]].forEach(function(z){n[z[1]]=z[0]in x?x[z[0]]:n[z[1]]});for(i in n){n[i]=i in x?x[i]:n[i];if(isnu(n[i])){n="";err="Error HTMLNode : a field is null or undefined";break}}break;case"BW_HTMLNode":for(i in x){n[i]=x[i]}break;case"array":var idx=[[],["c"],["t","c"],["t","a","c"],["t","a","c","o"]];var m=x.length>4?4:x.length;for(i=0;i<m;i++){n[idx[m][i]]=x[i]}for(i in n)if(isnu(n[i])){n="";err="Error HTMLNode : bad array array input";break}break;case"function":var h;if(dopts.functionExec){h=bw.htmlNode(x(),dopts);n=h.node;err=h.error}else n=h;break;default:if(dopts.atomic2span){n.c=[x.toString()];n.t="span"}else n=x.toString()}var r={node:n,ntype:bw.typeOf(n),error:err,isVoidTag:bw.typeOf(n)=="BW_HTMLNode"?isv(n.t):false};return r};bw.htmlEmit=function(htmlData,opts,state){var dopts={tagClose:"inherit",htmlEscContent:false};state=bw.toa(state,["undefined","null"],{nodesCnt:0,levelCnt:0,levelMax:0},state);dopts=optsCopy(dopts,opts);var _atr=function(n){var as=[],k,v,vr;for(k in n.a){v=n.a[k];if(v==null){as.push(k);continue}if(k.search(/^on/)>=0){if(bw.to(v)=="function"){if(n.o["atrOnEventRegister"]==false){vr=String(v())}else{vr=bw.funcGetDispatchStr(bw.funcRegister(v),"this")}}else{vr="";try{vr=v.toString()}catch(e){vr=String(v)}}}else{switch(k){case"style":if(_to(v)=="string")vr=v.toString();else vr=bw.makeCSSRule(["",v],{pretty:false}).trim().replace(/^{/,"").replace(/}$/,"").trim();break;default:if(bw.to(v)=="array")vr=v.join(" ");vr=v.toString()}}as.push(k+"="+'"'+vr.replace('"','\\"')+'"')}as=as.join(" ");return(as.length>0?" ":"")+as+(as.length>0?" ":"")};var h=[],n=bw.htmlNode(htmlData);if(_to(n.node)=="function"){n=bw.htmlNode(n.node());n=_toa(n.ntype,["BW_HTMLNode","string"],n,"")}state.nodesCnt++;if(n.ntype!="BW_HTMLNode"){h.push(dopts.htmlEscContent?bw.htmlSafeStr(n.node.toString()):n.node.toString())}else{if(n.node.t!="")h.push("<",n.node.t,_atr(n.node));var tagClose=dopts.tagClose!="inherit"?dopts.tagClose:n.node.o.tagClose;switch(tagClose){case"auto":if(n.isVoidTag){h.push("/>");break}case"all":default:if(n.node.t!="")h.push(">");var i,x;if(bw.typeOf(n.node.c)!="array"){state.levelCnt++;state.levelMax=state.levelCnt>state.levelMax?state.levelCnt:state.levelMax;x=bw.htmlEmit(n.node.c,dopts,state);state.levelCnt--;h.push(x.html)}else{for(i in n.node.c){state.levelCnt++;state.levelMax=state.levelCnt>state.levelMax?state.levelCnt:state.levelMax;x=bw.htmlEmit(n.node.c[i],dopts,state);state.levelCnt--;h.push(x.html)}}if(tagClose!="none"){if(n.node.t!="")h.push("</",n.node.t,">")}}}var html=h.join("");return{html:html,state:state}};bw.html=function(data,options){return bw.htmlEmit(data,options).html};bw.htmla=function(listData,options){if(_to(listData)!="array")return bw.html(listData,options);return listData.map(function(x){return bw.html(x,options)}).join("")};bw.htmlList=function(listData,listType,atr,atri){if(_to(listData)!="array")return"";if(listData.length<1)return"";atr=_toa(atr,"object",atr,{});atri=_toa(atr,"object",atr,{});var lc=listData.map(function(x){return bw.html(["li",atri,x])});listType=["ul","ol"].indexOf(listType)==-1?"ol":listType;return bw.html({t:listType,a:atr,c:lc})};bw.openFullScreen=function(){var elem=document.documentElement;if(elem.requestFullscreen){elem.requestFullscreen()}else if(elem.mozRequestFullScreen){elem.mozRequestFullScreen()}else if(elem.webkitRequestFullscreen){elem.webkitRequestFullscreen()}else if(elem.msRequestFullscreen){elem.msRequestFullscreen()}};bw.classStrAddDel=function(classData,classesToAdd,classesToDel){var tnorm=function(x){x=bw.toa(x,"undefined",[],x);return bw.to(x)=="array"?x:x.toString().trim().split(/\s+/gi)};var c=tnorm(classData);var ca=tnorm(classesToAdd);var cd=tnorm(classesToDel);return bw.arrayBNotInA(cd,c.concat(ca)).join(" ").trim().replace(/\s+/gi," ")};bw.classStrToggle=function(classData,classesToToggle){var tnorma=function(x){x=bw.toa(x,"undefined",[],x);return bw.to(x)=="array"?x:x.toString().trim().split(/\s+/gi)};var c=tnorma(classData);var t=tnorma(classesToToggle);return bw.classStrAddDel(classData,bw.arrayBNotInA(c,t),bw.arrayBinA(c,t))};bw.htmlTabs=function(tabData,opts){if(_to(tabData)!="array")return"";if(tabData.length<1)return"";var dopts={atr:{class:""},tab_atr:{class:""},tabc_atr:{class:""},indent:"",pretty:false};dopts=optsCopy(dopts,opts);var ti=tabData.map(function(x){return["li",{class:"bw-tab-item",onclick:"bw.selectTabContent(this)"},x[0]]});var tc=tabData.map(function(x){return["div",{class:"bw-tab-content"},x[1]]});ti[0][1]["class"]=bw.classStrAddDel(ti[0][1]["class"],"bw-tab-active");tc[0][1]["class"]=bw.classStrAddDel(tc[0][1]["class"],"bw-show");dopts["atr"]["class"]=bw.classStrAddDel(dopts["atr"]["class"],"bw-tab-container");dopts["tab_atr"]["class"]=bw.classStrAddDel(dopts["tab_atr"]["class"],"bw-tab-item-list");dopts["tabc_atr"]["class"]=bw.classStrAddDel(dopts["tabc_atr"]["class"],"bw-tab-content-list");return bw.html({t:"div",a:dopts["atr"],c:[["ul",dopts["tab_atr"],ti],["div",dopts["tabc_atr"],tc]]})};bw.htmlTable=function(data,opts){if(_to(data)!="array"||data.length<1)return"";var dopts={useFirstRowAsHeaders:true,useDefaultStyle:true,atr:{},thead_atr:{},th_atr:{},tbody_atr:{},tr_atr:{},td_atr:{},caption:"",sortable:false};var i=0,head="",body="",r,_hs=bw.html;dopts=optsCopy(dopts,opts);if(dopts.useDefaultStyle){dopts.atr["class"]="bw-table bw-table-stripe"}if(dopts.sortable==true){dopts.th_atr["onclick"]="bw.sortTableDispatch(this)";if("class"in dopts.th_atr)dopts.th_atr["class"]+=dopts.th_atr["class"].split(/[ ]+/).indexOf("bw-table-sort-xxa")<0?" bw-table-sort-xxa":"";else dopts.th_atr["class"]="bw-table-sort-xxa"}else{if(_to(dopts.sortable)=="function"){var sfid=bw.funcRegister(dopts.sortable);dopts.th_atr["onclick"]=bw.funcGetDispatchStr(sfid,"this")}}if(dopts["useFirstRowAsHeaders"]){head=data[0].map(function(x){return _hs({t:"th",a:dopts.th_atr,c:x})}).join("");head=_hs({t:"tr",a:dopts.tr_atr,c:head});i=1}else i=0;head=bw.html({t:"thead",a:dopts.thead_atr,c:head});for(;i<data.length;i++){r=data[i].map(function(x){return _hs({t:"td",a:dopts.td_atr,c:x})}).join("");body+=_hs({t:"tr",a:dopts.tr_atr,c:r})}body=bw.html({t:"tbody",a:dopts.tbody_atr,c:body});dopts.caption=dopts.caption==""?"":_hs({t:"caption",a:{},c:dopts.caption});return _hs({t:"table",a:dopts.atr,c:[dopts.caption,head,body]})};bw.htmlAccordian=function(data,opts){var s="";if(_to(data)!=="array")return s;var dopts={atr:{class:"bw-accordian-container"},atr_h:{onclick:"bw.DOMClassToggle(this.nextSibling,'bw-hide')",class:"bw-thm-light"},atr_c:{class:"bw-hide"}};dopts=optsCopy(dopts,opts);dopts.atr_h["onclick"]="bw.DOMClassToggle(this.nextSibling,'bw-hide')";s=data.map(function(x){var a=dopts["atr_c"],show;show=x.length>2&&x[2].show==true;if(a["class"]){a["class"]=show?bw.classStrAddDel(a["class"],"","bw-hide"):bw.classStrAddDel(a["class"],"bw-hide")}else a["class"]=show?"":"bw-hide";return bw.html({t:"div",a:dopts["atr_h"],c:[x[0]]})+bw.html({t:"div",a:a,c:[x[1]]})}).join("");s=bw.html({t:"div",a:dopts["atr"],c:[s]});return s};bw.htmlSign=function(content,opts){var dopts={atr:{style:{"font-weight":"700","font-size":"7em"}},escContent:false};dopts=optsCopy(dopts,opts);content=dopts.escContent!=false?bw.htmlSafeStr(content):content;var c={a:{class:"bw-sign"},c:[{c:{a:dopts.atr,c:[content]}}]};return bw.html(c)};bw.getFile=function(fname,callback_fn,options){var dops={parser:"raw"};dops=optsCopy(dops,options);if(_to(fname)!="string"){return"invalid filename"}var prs=dops["parser"]=="JSON"?JSON.parse:function(s){return s};if(bw.isNodeJS()==true){var fs=require("fs");fs.readFile(fname,"utf8",function(err,data){if(err)throw err;callback_fn(prs(data))})}else{var x=new XMLHttpRequest;x.overrideMimeType("application/json");x.open("GET",fname,true);x.onreadystatechange=function(){if(x.readyState==4&&x.status=="200"){callback_fn(prs(x.responseText))}};x.send(null)}return"BW_OK"};bw.getJSONFile=function(fname,callback_fn){return bw.getFile(fname,callback_fn,{parser:"JSON"})};bw.copyToClipboard=function(data){if(bw.isNodeJS())return;var listener=function(e){e.clipboardData.setData("text/html",data);e.clipboardData.setData("text/plain",data);e.preventDefault()};document.addEventListener("copy",listener);document.execCommand("copy");document.removeEventListener("copy",listener)};bw.saveClientFile=function(fname,data){if(bw.isNodeJS()){var fs=require("fs");fs.writeFile(fname,data,function(err){if(err)return bw.log(err);bw.log("error saving ",fname,data)})}else{var saveData=function(){var a=document.createElement("a");document.body.appendChild(a);a.style="display: none";return function(data,fname){var json=JSON.stringify(data),blob=new Blob([json],{type:"octet/stream"}),url=window.URL.createObjectURL(blob);a.href=url;a.download=fname;a.click();window.URL.revokeObjectURL(url)}}();saveData(data,fname)}};var gBWTime=(new Date).getTime();bw.clearTimer=function(message){gBWTime=(new Date).getTime();if(_to(message)!="undefined")bw.logd(String(message));return gBWTime};bw.readTimer=function(message){var ct=(new Date).getTime();if(_to(message)!="undefined")bw.logd(String(message));return ct-gBWTime};bw.clearTimer();bw.setIntervalX=function(callback,delay,number_of_repetitions){var x=0;var intervalID=setInterval(function(){callback(x);if(++x>=number_of_repetitions){clearInterval(intervalID)}},delay)};bw.repeatUntil=function(testFn,successFn,failFn,delay,maxReps,lastFn){var _count=0;if(typeof testFn!="function")return"err";if(typeof delay!="number")delay=250;if(typeof maxReps!="number")maxReps=1;var _testFn=testFn;var _successFn=typeof successFn=="function"?successFn:function(){};var _failFn=typeof failFn=="function"?failFn:function(){};var _lastFn=typeof lastFn=="function"?lastFn:function(){};var _f=function(){var success=_testFn();if(true==success){_successFn();_lastFn(true,_count)}else{_failFn();if(_count>=maxReps){_lastFn(success,_count)}else{_count++;window.setTimeout(_f,delay)}}};_f()};bw.naturalCompare=function(as,bs){var a,b,a1,b1,i=0,L,rx=/(\d+)|(\D+)/g,rd=/\d/;if(isFinite(as)&&isFinite(bs))return Math.sign(as-bs);a=String(as).toLocaleLowerCase();b=String(bs).toLocaleLowerCase();if(a===b)return as>bs?1:0;if(!(rd.test(a)&&rd.test(b)))return a>b?1:-1;a=a.match(rx);b=b.match(rx);L=a.length>b.length?b.length:a.length;while(i<L){a1=a[i];b1=b[i++];if(a1!==b1){if(isFinite(a1)&&isFinite(b1)){if(a1.charAt(0)==="0")a1="."+a1;if(b1.charAt(0)==="0")b1="."+b1;return a1-b1}else return a1>b1?1:-1}}return Math.sign(a.length-b.length)};bw.sortHTMLTable=function(table,col,dir,sortFunction){var rows,switching,i,x,y,shouldSwitch;var sortF=_to(sortFunction)=="function"?sortFunction:bw.naturalCompare;table=bw.DOM(table)[0];dir=dir==true||dir=="up"?true:false;switching=true;col=_to(col)=="number"?col:0;while(switching){switching=0;rows=table.getElementsByTagName("TR");for(i=1;i<rows.length-1;i++){shouldSwitch=0;x=rows[i].getElementsByTagName("TD")[col].innerHTML;y=rows[i+1].getElementsByTagName("TD")[col].innerHTML;shouldSwitch=dir?sortF(x,y,col)>0:sortF(x,y,col)<0;if(shouldSwitch)break}if(shouldSwitch){rows[i].parentNode.insertBefore(rows[i+1],rows[i]);switching=true}}};bw.sortTableDispatch=function(item,fn){var i;item=bw.DOM(item)[0];if(_to(item).substr(0,4)!="html")return false;var index=0,dir;var cols=item.parentElement.getElementsByTagName("th");for(i=0;i<cols.length;i++){if(cols[i]==item){index=i;dir=bw.DOMClass(cols[i],"bw-table-sort-upa");if(dir){bw.DOMClass(cols[i],"bw-table-sort-upa","bw-table-sort-dna")}else{if(bw.DOMClass(cols[i],"bw-table-sort-dna")){bw.DOMClass(cols[i],"bw-table-sort-dna","bw-table-sort-upa")}else bw.DOMClass(cols[i],"bw-table-sort-xxa","bw-table-sort-upa")}}else{bw.DOMClass(cols[i],"bw-table-sort-upa","");bw.DOMClass(cols[i],"bw-table-sort-dna","");bw.DOMClass(cols[i],"bw-table-sort-xxa","bw-table-sort-xxa")}}bw.sortHTMLTable(item.parentElement.parentElement.parentElement,index,dir,fn)};var _fnRegistry={};var _fnIDCounter=0;bw.funcRegister=function(fn,forceName){var fnID="class_bwfn_"+_fnIDCounter;_fnIDCounter++;fnID=_to(forceName)=="string"?forceName:fnID;fnID.trim();_fnRegistry[fnID]=fn;return fnID};bw.funcUnregister=function(fnID){if(fnID in _fnRegistry)delete _fnRegistry[fnID]};bw.funcGetById=function(fnID,errFn){fnID=String(fnID);if(fnID in _fnRegistry)return _fnRegistry[fnID];else{var _id=fnID;return _to(errFn)=="function"?errFn:function(){bw.log(_id,"bw.funcGetById(): unregistered fn error")}}};bw.funcGetDispatchStr=function(fnID,argstring){switch(_to(argstring)){case"string":case"number":argstring=String(argstring);break;case"array":argstring=argstring.join(",");break;case"function":argstring=argstring();break;default:argstring=""}return"bw.funcGetById('"+fnID+"')("+argstring+")"};bw.funcGetRegistry=function(){return _fnRegistry};bw.loremIpsum=function(numChars,startSpot,startWithCapitalLetter){startSpot=_to(startSpot)!="number"?0:Math.round(startSpot);var l="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ";startSpot=startSpot%l.length;l=l.substring(startSpot,l.length)+l.substring(0,startSpot);if(_to(numChars)!="number")numChars=l.length;var i=numChars,s="";while(i>0){s+=i<l.length?l.substring(0,i):l;i-=l.length}if(s[s.length-1]==" ")s=s.substring(0,s.length-1)+".";if(startWithCapitalLetter!=false){var c=s[0].toUpperCase();c=c.match(/[A-Z]/)?c:"M";s=c+s.substring(1,s.length)}return s};bw.docString=function(s,options){var dopts={docType:"jsdoc",delims:["/**","*/"],parseJSDocParams:false,dropLeadin:false};dopts=optsCopy(dopts,options);var _es=function(str){return str.replace(/(?=[\\^$*+?.()|{}[\]])/g,"\\")};dopts["delims"]=bw.choice(dopts["docType"],{jsdoc:["/**","*/"],python:['"""','"""'],jspy:['/**"""','"""*/']},dopts["delims"]);var c=_to(s)=="function"?s.toString():String(s);var r=[];try{var re=new RegExp(_es(dopts["delims"][0])+"\\s*\\n*([^\\*]|(\\*(?!\\/)))*"+_es(dopts["delims"][1]),"ig");r=c.match(re)}catch(e){bw.log(String(e))}if(_to(r)=="array"){r=r.map(function(x){return x.substring(dopts["delims"][0].length,x.length-dopts["delims"][1].length)});r=dopts["dropLeadin"]==true?r.map(function(x){return x.split(/[\n\r]/).map(function(y){return bw.trim(y,"left")+"\n"})}):r}else r=[];return r};bw.docStringParseLine=function(s){var r={source:s,field:"",types:"",name:"",description:""};var a=s.replace(/^\s*(\/\*\*?)?|(\*\/)?\s*$/gi,"");a=a.replace(/^\s*\**\s*/,"");if(a.charAt(0)=="@"){var e,x;var t=bw.trim;e=/^@([A-Za-z0-9_<>[\]]*)/i;x=a.match(e);if(x!=null){r["field"]=t(x[1])}else return r;a=a.replace(e,"");e=/^\s*\{([A-Za-z0-9_|\s,.\-+!@#$%^&*()=[\]]*)\}/i;x=a.match(e);if(x!=null){r["types"]=t(x[1])}a=a.replace(e,"");e=/^\s*([\S]*)/i;x=a.match(e);if(x!=null){r["description"]=t(x[1])}a=a.replace(e,"");e=/^\s*([\S]*)/i;x=a.match(e);if(x!=null){r["name"]=t(x[1])}a=a.replace(e,"");if(r["name"].match(/^\s*-+\s*/)!=null){r["name"]=r["description"];r["description"]=t(a)}else{r["description"]=r["description"]+" "+r["name"]+" "+t(a);r["name"]=""}}return r};bw.docStringParse=function(s){s=bw.docString(s)[0];var a=s.split("\n");var i,r=[bw.docStringParseLine(a[0])];for(i=1;i<a.length;i++){var l=bw.docStringParseLine(a[i]);if(l["field"]==""){if(r[r.length-1]["field"]==""){r[r.length-1]["source"]+=l["source"]}else r[r.length-1]["description"]+=l["source"]}else r.push(l)}return r};bw.isHexStr=function(str,allowChars){if(_to(str)=="string"){str=str.replace(new RegExp("["+allowChars+"]","g"),"");var isHexReg=new RegExp("^[0-9A-Fa-f]{"+str.length+"}$");return isHexReg.test(str)==true?str.length:false}return false};bw.__monkey_patch_is_nodejs__=new function(){var _t="ignore";this.set=function(x){_t=_toa(x,"boolean",x,"ignore")};this.get=function(){return _t};return this};bw.isNodeJS=function(){if(bw.__monkey_patch_is_nodejs__.get()!="ignore")return bw.__monkey_patch_is_nodejs__.get();return(typeof module!=="undefined"&&module.exports)!==false};bw.fixNum=function(num,digits){num=Number(num);if(isNaN(num))return NaN;digits=_to(digits)=="number"?digits:3;num*=Math.pow(10,digits);num=num>0?Math.floor(num):Math.ceil(num);num/=Math.pow(10,digits);return num};bw.multiArray=function(value,dims){var v=function(){return _to(value)=="function"?value():value};dims=_to(dims)=="number"?[dims]:dims;var _array=function(a,dim){if(dim<dims.length){for(var i=0;i<dims[dim];i++){a[i]=dim==dims.length-1?v():_array([],dim+1)}return a}};return _array([],0)};bw.clip=function(data,min,max){var l=min<max?min:max;var h=max>min?max:min;if(_to(data)=="array"){return data.map(function(x){return x<l?l:x>h?h:x})}else return data<l?l:data>h?h:data};bw.mapScale=function(x,in0,in1,out0,out1,options){var dopts={clip:true,expScale:false};dopts=optsCopy(dopts,options);if(in0==in1)return x;out0=_toa(out0,"number",out0,0);out1=_toa(out1,"number",out1,1);var ms=function(z){if(dopts["expScale"]){var y=(z-(in1+in0)/2)/(in1-in0)*dopts["expScale"];z=(out1-out0)*(1/(1+Math.exp(-y)))+out0}else z=(z-in0)/(in1-in0)*(out1-out0)+out0;if(dopts["clip"])z=bw.clip(z,out0,out1);return z};if(_to(x)=="number")return ms(x);return x.map(ms)};bw.padNum=function(x,width,options){var dopts={pad:" "};dopts=optsCopy(dopts,options);x=String(x);return x.length>=width?x:new Array(width-x.length+1).join(dopts["pad"])+x};bw.trim=function(s,dir){var t=bw.choice(dir,{left:/^[\s\uFEFF\xA0\n]+/g,right:/[\s\uFEFF\xA0\n]+$/g,none:/(?!)/},/^[\s\uFEFF\xA0\n]+|[\s\uFEFF\xA0\n]+$/g);return String(_toa(s,"undefined","",s)).replace(t,"")};bw.padString=function(s,width,dir,options){var dopts={pad:" ",trimDir:"both"};dopts=optsCopy(dopts,options);s=String(s);var x=bw.trim(s,dopts["trimDir"]);var p=width>x.length?width-x.length+1:0;var q=bw.choice(dir,{left:[p,0],right:[0,p],center:[Math.round(p/2),p-Math.round(p/2)+1]},[0,0]);return new Array(q[0]).join(dopts["pad"])+x+new Array(q[1]).join(dopts["pad"])};bw.random=function(rangeBegin,rangeEnd,options){rangeBegin=_to(rangeBegin)=="number"?rangeBegin:0;rangeEnd=_to(rangeEnd)=="number"?rangeEnd:100;var dopts={setType:"int",dims:false};dopts=optsCopy(dopts,options);var _rnd=function(){var n=0;dopts.setType=["int","float","number"].indexOf(dopts.setType)==-1?"int":dopts.setType;if(rangeEnd<rangeBegin){rangeBegin^=rangeEnd;rangeEnd^=rangeBegin;rangeBegin^=rangeEnd}n=Math.random()*(rangeEnd-rangeBegin)+rangeBegin;return dopts.setType=="int"?Math.round(n):n};if(_to(dopts["dims"])=="array"||_to(dopts["dims"])=="number")return bw.multiArray(_rnd,dopts["dims"]);return _rnd()};bw.prandom=function(rangeBegin,rangeEnd,seed,options){rangeBegin=_to(rangeBegin)=="number"?rangeBegin:0;rangeEnd=_to(rangeEnd)=="number"?rangeEnd:100;var dopts={setType:"int",dims:false};dopts=optsCopy(dopts,options);var _cseed=seed;var _rnd=function(){var n=0;dopts.setType=["int","float","number"].indexOf(dopts.setType)==-1?"int":dopts.setType;if(rangeEnd<rangeBegin){rangeBegin^=rangeEnd;rangeEnd^=rangeBegin;rangeBegin^=rangeEnd}n=(bw.hashFnv32a("start string",_cseed)&65535)/65536*(rangeEnd-rangeBegin)+rangeBegin;_cseed=dopts.setType=="int"?Math.round(n):n;return dopts.setType=="int"?Math.round(n):n};if(_to(dopts["dims"])=="array"||_to(dopts["dims"])=="number")return bw.multiArray(_rnd,dopts["dims"]);return _rnd()};bw.hashFnv32a=function(str,seed,returnHexStr){var i,l,hval=typeof seed=="undefined"?2166136261:seed;for(i=0,l=str.length;i<l;i++){hval^=str.charCodeAt(i);hval+=(hval<<1)+(hval<<4)+(hval<<7)+(hval<<8)+(hval<<24)}if(returnHexStr){return("0000000"+(hval>>>0).toString(16)).substr(-8)}return hval>>>0};bw.CSSMakeTheme=function(color){var c=bw.colorRgbToHsl(bw.colorParse(color));var p="bw-theme-";var thm=["l5","l4","l3","l2","l1","d1","d2","d3","d4","d5"].map(function(x){return p+x});var im=" !important";thm=thm.map(function(x,i){return[x,[["color",(i<5?"#000":"#fff")+im],["background-color",c+im]]]});return thm};bw.CSSSimpleStyles=function(appendToHead,options){var dopts={globals:false,id:"bw-default-styles",exportCSS:false,colorset:{color:"#000","background-color":"#ddd",active:"#222"},pretty:false,themes:[[".bw-thm-light",{color:"#020202 !important;","background-color":"#e2e2e2 !important;"}],[".bw-thm-dark",{color:"#e2e2e2 !important;","background-color":"#020202 !important;"}]]};var s="\n",i;var _r=bw.fixNum;var rl=bw.makeCSSRule;dopts=optsCopy(dopts,options);var defs={defGlobals:{"box-sizing":"border-box"},defContainer:{height:"100%",width:"90%",margin:"0 auto","padding-left":"2%","padding-right":"2%",left:"0",top:"1%","box-sizing":"border-box"},defFontSerif:{"font-family":"Times New Roman, Times, serif"},defFontSansSerif:{"font-family":"Arial, Helvetica, sans-serif"}};if(dopts["globals"]=="load"){s+=rl([["html","body"],defs.defContainer]);s+=rl(["*"+defs.defFontSansSerif])}var d=[["*",defs.defGlobals],[".bw-def-page-setup",defs.defContainer],[".bw-font-serif",defs.defFontSerif],[".bw-font-sans-serif",defs.defFontSansSerif],"\n",[".bw-left",{"text-align":"left"}],[".bw-right",{"text-align":"right"}],[".bw-center",{"text-align":"center",margin:"0 auto"}],[".bw-justify",{"text-align":"justify"}],[".bw-code",{"font-family":"monospace","white-space":"pre-wrap"}],[".bw-pad1",{"padding-left":"1%","padding-right":"1%"}],"\n",[".bw-table",{"border-collapse":"collapse","border-spacing":"0",border:"1px solid #444"}],[".bw-table th",{"background-color":"#bbb",padding:"4px",border:"1px solid #444"}],[".bw-table td",{padding:"4px",border:"1px solid #444"}],[".bw-table-stripe tr:nth-child(even)",{"background-color":"#f0f0f0"}],[".bw-table tr td:first-child",{"font-weight":"700"}],[".bw-table-border-round",{"border-radius":"2px"}],[".bw-table-sort-upa::after",{content:'"\\2191"'}],[".bw-table-sort-dna::after",{content:'"\\2193"'}],[".bw-table-sort-xxa::after",{content:'"\\00a0"'}],"\n",[".bw-tab-item-list",{margin:0,"padding-inline-start":0}],[".bw-tab-item",{display:"inline","padding-top":"0.75em","padding-left":"0.75em","padding-right":"0.75em","border-top-right-radius":"7px","border-top-left-radius":"7px"}],[".bw-tab-active",{"font-weight":"700"}],[".bw-tab:hover",{cursor:"pointer","font-weight":700}],[".bw-tab-content-list",{margin:0,"padding-top":"0.0em"}],[".bw-tab-content",{display:"none","border-radius":0}],[".bw-tab-content, .bw-tab-active",{"background-color":"#ddd",padding:"0.5em"}],"\n",[".bw-accordian-container > div",{padding:"0.5em"}],"\n",[".bw-container",{margin:"0 auto"}],[".bw-row",{width:"100%",display:"block"}],['.bw-row [class^="bw-col"]',{float:"left"}],[".bw-row::after",{content:'""',display:"table",clear:"both"}],[".bw-box-1",{"padding-top":"10px","padding-bottom":"10px","border-radius":"8px"}],"\n",[".bw-sign",{position:"inherit",display:"table",height:"100%",width:"100%"}],[".bw-sign > div",{display:"table-cell","vertical-align":"middle"}],[".bw-sign > div > div",{"text-align":"center"}],"\n",[".bw-hide",{display:"none"}],[".bw-show",{display:"block"}]];[1,2,3,4,5,6].map(function(x){d.push([".bw-h"+x,{"font-size":_r(3.2*Math.pow(.85,x+1))+"rem"}])});d.push("\n");for(var k=1;k<=12;k++)d.push([".bw-col-"+k,{width:_r(k*100/12)+"%"}]);d.push("\n");s+=d.map(function(x){return rl(x,{pretty:dopts.pretty})}).join("\n")+"\n";d.push("\n");for(i in dopts["colorset"]){s+=".bw-color-"+i+" {"+i+":"+dopts["colorset"][i]+"}\n"}d.push("\n");bw.makeCSS(dopts["themes"]);for(i=0;i<dopts["themes"].length;i++){s+=rl(dopts["themes"][i])}var m="@media only screen and (min-width: ";s+=m+"540px) {.bw-def-page-setup {width: 96%;}}\n";s+=m+"720px) {.bw-def-page-setup {width: 92%;}}\n";s+=m+"960px) {.bw-def-page-setup {width: 88%;}}\n";s+=m+"1100px){.bw-def-page-setup {width: 86%;}}\n";s+=m+"1600px){.bw-def-page-setup {width: 84%;}}\n";if(bw.isNodeJS()==false){var h=bw.DOM("head")[0];var el=document.createElement("style");el.id=dopts["id"];el.textContent=s;if(appendToHead&&document.getElementById(dopts["id"])==null)h.appendChild(el)}if(dopts["exportCSS"])s=bw.html(["style",{id:dopts["id"]},"\n/**\n bitwrench basic css styles\n version: "+bw.version()["version"]+"\n */"+s]);return s};bw.CSSSimpleThemes=function(d,appendToHead){var s="",xs={};var def=[{css:[["*",{"background-color":"#333",color:"#ddd","font-family":"sans-serif","box-sizing":"border-box"}],["body",{"margin-top":"1%"}],["th",{"background-color":"#555"}],["tbody tr:nth-child(even)",{"background-color":"#f0f0f0"}],[["table","td","th"],{"border-collapse":"collapse",border:"1px solid #ddd"}],[["td","th"],{padding:"4px"}],[["div","body","button","table","input"],{"border-radius":"2px"}]]},{css:[["*",{"background-color":"#f8f8f8",color:"#111","font-family":"sans-serif","box-sizing":"border-box"}],["body",{"margin-top":"1%"}],["th",{"background-color":"#ddd"}],["tbody tr:nth-child(even)",{"background-color":"#ddd"}],[["table","td","th"],{"border-collapse":"collapse",border:"1px solid #111"}],[["td","th"],{padding:"4px"}],[["div","body","button","table","input"],{"border-radius":"2px"}]]}];xs=bw.choice(_to(d),{object:d,number:d>=0&&d<def.length?def[d].css:def[0].css},def[0].css);s=xs.map(function(y){return bw.makeCSSRule(y,{pretty:false})}).join("\n");if(appendToHead!=false){var hs=bw.DOM("bw-simple-theme-styles");if(hs.length==0){var h=bw.DOM("head")[0];var el=document.createElement("style");el.id="bw-simple-theme-styles";el.textContent=s;h.appendChild(el)}else{hs.textContent=s}}return s};bw.selectTabContent=function(item,target){item=bw.DOM(item)[0];if(_to(item).substr(0,4)!="html")return false;document.gx=item;var i,j,index=0;var cols=item.parentNode.getElementsByTagName("li");for(i=0;i<cols.length;i++){if(cols[i]==item){index=i;cols[i].className=bw.classStrAddDel(cols[i].className,"bw-tab-active")}else{cols[i].className=bw.classStrAddDel(cols[i].className,"","bw-tab-active")}}var tcols=[];for(i=0;i<item.parentNode.parentNode.children.length;i++){if(item.parentNode.parentNode.children[i].className.trim().split(/\s+/).indexOf("bw-tab-content-list")>=0){for(j=0;j<item.parentNode.parentNode.children[i].children.length;j++){if(item.parentNode.parentNode.children[i].children[j].className.trim().split(/\s+/).indexOf("bw-tab-content")>=0)tcols.push(item.parentNode.parentNode.children[i].children[j])}}}if(tcols.length<=0)return false;target=_to(target)=="undefined"?tcols[index]:target;target=_to(target)=="string"?bw.DOM(target)[0]:target;for(i=0;i<tcols.length;i++){if(tcols[i]==target)tcols[i].className=bw.classStrAddDel(tcols[i].className,"bw-show");else tcols[i].className=bw.classStrAddDel(tcols[i].className,"","bw-show")}return true};bw.DOMClass=function(el,key,replace){var r=false,elems,x,j;elems=bw.DOM(el);if(elems.length<=0)return r;for(j=0;j<elems.length;j++){x=elems[j];try{var c=x.className.split(/[ ]+/);var i=c.indexOf(key);if(i>=0)r=true;if(_to(replace)=="string"&&c.indexOf(replace)==-1){if(i==-1)c.push(replace);else{if(replace.length>0)c[i]=replace;else c.splice(i,1)}x.className=c.join(" ").trim();r=true}}catch(e){bw.log(e)}}return r};bw.DOMClassToggle=function(el,className){var x,i,elems=bw.DOM(el),r=false;for(i=0;i<elems.length;i++){x=elems[i];try{r=bw.DOMClass(x,className);if(r)bw.DOMClass(x,className,"");else bw.DOMClass(x,className,className)}catch(e){bw.log(e)}}return!r};bw.version=function(){var v={version:"1.2.16",about:"bitwrench is a simple library of miscellaneous Javascript helper functions for common web design tasks.",copy:"(c) M A Chatterjee deftio (at) deftio (dot) com",url:"http://github.com/deftio/bitwrench",license:"BSD-2-Clause"};return v};bw.bwargs={enableUJURLArgs:"true"};var parseArgs=function(s){var args={};if(typeof s=="string"&&s!=""){s=s.split(";");var j;for(j in s){var k=s[j].split(":");args[k[0]]=k[1]}}return args};var getArgs=function(){if(bw.isNodeJS()==false){var els=bw.DOM("script");var i,a,b;for(i in els){try{var el=els[i];if(el.hasOwnProperty("src")!=false)break;var s=String(el.getAttribute("src"));var f="bitwrench.js";if(s.toLocaleLowerCase().substring(s.length-f.length,s.length)==f.toLocaleLowerCase()){s=_to(s)=="string"?el.getAttribute("bwargs"):[""];s=_to(s)=="string"?el.getAttribute("data-bwargs"):s;a=parseArgs(s);for(b in a)bw.bwargs[b]=a[b]}}catch(e){}}if(bw.bwargs["enableUJURLArgs"]=="true"){a=parseArgs(bw.getURLParam("bwargs",""));for(b in a)bw.bwargs[b]=a[b]}}};getArgs();var loadStyles=bw.bwargs["bw-load-styles"]!="false";var loadStyleBasics=bw.typeAssign(bw.bwargs["bw-load-style-basics"],"string",bw.bwargs["bw-load-style-basics"],"load");bw.CSSSimpleStyles(loadStyles,{globals:loadStyleBasics});bw.funcRegister(bw.log,"bw_log");return bw})();export default bw;