From 47624cc7b9b657d0f47d613b2a32dff9a45d7bec Mon Sep 17 00:00:00 2001 From: mardanbeigi Date: Sun, 3 Nov 2024 10:06:34 -0500 Subject: [PATCH 1/2] 40k: mobile UI part 1 Start fixing mobile UI: - don't set width on datasheets, so they fill the entire width - abbreviate profile header titles like "Ranged Weapon" -> "Range"; this will save some horizontal space - switch keywords into flex (instead of table cells), and render on two lines in mobile Still to do - move weapon keywords to second row, since right now there's not enough room to have the entire weapon profile on one line - force single column on mobile - support mobile printing without using mobile UI --- css/prettyscribe.css | 121 +++++++++++++++++++++++++++++++++++++--- dist/prettyscribe.js | 2 +- src/renderer40k10th.tsx | 40 ++++++++++--- 3 files changed, 145 insertions(+), 18 deletions(-) diff --git a/css/prettyscribe.css b/css/prettyscribe.css index 7f7a6a8..5765087 100644 --- a/css/prettyscribe.css +++ b/css/prettyscribe.css @@ -197,14 +197,6 @@ label { padding: 0 10px 0 5px; } -.wh40k_unit_sheet.bigger { - width: 800px; -} - -.wh40k_unit_sheet:not(.bigger) { - width: 1110px; -} - .wh40k_unit_sheet > table { --borderColor: black; --notchSize: 0.8em; @@ -228,6 +220,60 @@ label { ); } +/* Desktop */ +@media only screen and (width > 768px) { + .mobile-only { + display: none; + } + + .wh40k_unit_sheet.bigger { + width: 800px; + } + + .wh40k_unit_sheet:not(.bigger) { + width: 1110px; + } +} + +@media print { + .mobile-only { + display: none; + } + + .wh40k_unit_sheet.bigger { + width: 800px; + } + + .wh40k_unit_sheet:not(.bigger) { + width: 1110px; + } +} + +/* Mobile */ +@media only screen and (width <= 768px) { + .desktop-only { + display: none; + } + + .wh40k_unit_sheet { + padding: 0px; + } + + .container-fluid { + --bs-gutter-x: 0px; + } + + .wh40k_unit_sheet > table { + --notchSize: 0.4em; + } + + /* Some special profile tables will have long names, so allow wrapping. */ + .wh40k_unit_sheet table > thead > tr.header_row > th { + white-space: normal; + } +} + + .wh40k_unit_sheet > .table > thead:not(:first-child) > :last-child > * { border-top-color: currentColor; } @@ -405,6 +451,65 @@ body:not(.single_column) .wh40k_unit_sheet > table > * > * > td.subTableTd > div line-height: 1; } +.wh40k_keywords_and_factions, +.wh40k_keywords, +.wh40k_factions { + display: flex; +} + +.wh40k_keywords > div, +.wh40k_factions > div { + display: inline; +} + +.wh40k_keywords > div:last-child, +.wh40k_factions > div:last-child { + font-weight: normal; +} + +.wh40k_keywords_and_factions { + display: flex; +} +.wh40k_keywords { + flex-basis: 70%; +} +.wh40k_factions { + flex-basis: 30%; +} + +.wh40k_keywords > div:first-child { + flex-basis: 13.5%; +} +.wh40k_keywords > div:last-child { + flex-basis: 86% +} +.wh40k_factions > div:first-child { + flex-basis: 33%; +} +.wh40k_factions > div:last-child { + flex-basis: 67%; +} +.wh40k_keywords > div:first-child, +.wh40k_factions > div:first-child { + /* Improves "KEYWORDS" for "Print: Larger Text" */ + padding-right: 3px; +} + +/* Mobile */ +@media only screen and (width <= 768px) { + .wh40k_keywords_and_factions { + display: block; + } + .wh40k_keywords > div:first-child, + .wh40k_factions > div:first-child { + flex-basis: 25%; + } + .wh40k_keywords > div:last-child, + .wh40k_factions > div:last-child { + flex-basis: 75%; + } +} + /* MESBG Start */ .mesbg_container { font-family: 'Crimson Pro', serif; diff --git a/dist/prettyscribe.js b/dist/prettyscribe.js index 5f7f132..d378adf 100644 --- a/dist/prettyscribe.js +++ b/dist/prettyscribe.js @@ -1,2 +1,2 @@ /*! For license information please see prettyscribe.js.LICENSE.txt */ -(()=>{var e={733:(e,t,n)=>{e.exports=function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[s]={exports:{}};t[s][0].call(c.exports,(function(e){return i(t[s][1][e]||e)}),c,c.exports,e,t,n,r)}return n[s].exports}for(var o=void 0,s=0;s>2,a=(3&t)<<4|n>>4,l=1>6:64,c=2>4,n=(15&s)<<4|(a=o.indexOf(e.charAt(c++)))>>2,r=(3&a)<<6|(l=o.indexOf(e.charAt(c++))),h[u++]=t,64!==a&&(h[u++]=n),64!==l&&(h[u++]=r);return h}},{"./support":30,"./utils":32}],2:[function(e,t,n){"use strict";var r=e("./external"),i=e("./stream/DataWorker"),o=e("./stream/Crc32Probe"),s=e("./stream/DataLengthProbe");function a(e,t,n,r,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=n,this.compression=r,this.compressedContent=i}a.prototype={getContentWorker:function(){var e=new i(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new s("data_length")),t=this;return e.on("end",(function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),e},getCompressedWorker:function(){return new i(r.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},a.createWorkerFrom=function(e,t,n){return e.pipe(new o).pipe(new s("uncompressedSize")).pipe(t.compressWorker(n)).pipe(new s("compressedSize")).withStreamInfo("compression",t)},t.exports=a},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,n){"use strict";var r=e("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(e){return new r("STORE compression")},uncompressWorker:function(){return new r("STORE decompression")}},n.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,n){"use strict";var r=e("./utils"),i=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==r.getTypeOf(e)?function(e,t,n,r){var o=i,s=0+n;e^=-1;for(var a=0;a>>8^o[255&(e^t[a])];return-1^e}(0|t,e,e.length):function(e,t,n,r){var o=i,s=0+n;e^=-1;for(var a=0;a>>8^o[255&(e^t.charCodeAt(a))];return-1^e}(0|t,e,e.length):0}},{"./utils":32}],5:[function(e,t,n){"use strict";n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(e,t,n){"use strict";var r;r="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:r}},{lie:37}],7:[function(e,t,n){"use strict";var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=e("pako"),o=e("./utils"),s=e("./stream/GenericWorker"),a=r?"uint8array":"array";function l(e,t){s.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}n.magic="\b\0",o.inherits(l,s),l.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(o.transformTo(a,e.data),!1)},l.prototype.flush=function(){s.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},l.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this._pako=null},l.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},n.compressWorker=function(e){return new l("Deflate",e)},n.uncompressWorker=function(){return new l("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,n){"use strict";function r(e,t){var n,r="";for(n=0;n>>=8;return r}function i(e,t,n,i,s,u){var d,h,f=e.file,p=e.compression,_=u!==a.utf8encode,m=o.transformTo("string",u(f.name)),g=o.transformTo("string",a.utf8encode(f.name)),v=f.comment,b=o.transformTo("string",u(v)),y=o.transformTo("string",a.utf8encode(v)),w=g.length!==f.name.length,C=y.length!==v.length,x="",E="",S="",k=f.dir,A=f.date,T={crc32:0,compressedSize:0,uncompressedSize:0};t&&!n||(T.crc32=e.crc32,T.compressedSize=e.compressedSize,T.uncompressedSize=e.uncompressedSize);var N=0;t&&(N|=8),_||!w&&!C||(N|=2048);var L=0,R=0;k&&(L|=16),"UNIX"===s?(R=798,L|=function(e,t){var n=e;return e||(n=t?16893:33204),(65535&n)<<16}(f.unixPermissions,k)):(R=20,L|=function(e){return 63&(e||0)}(f.dosPermissions)),d=A.getUTCHours(),d<<=6,d|=A.getUTCMinutes(),d<<=5,d|=A.getUTCSeconds()/2,h=A.getUTCFullYear()-1980,h<<=4,h|=A.getUTCMonth()+1,h<<=5,h|=A.getUTCDate(),w&&(E=r(1,1)+r(l(m),4)+g,x+="up"+r(E.length,2)+E),C&&(S=r(1,1)+r(l(b),4)+y,x+="uc"+r(S.length,2)+S);var P="";return P+="\n\0",P+=r(N,2),P+=p.magic,P+=r(d,2),P+=r(h,2),P+=r(T.crc32,4),P+=r(T.compressedSize,4),P+=r(T.uncompressedSize,4),P+=r(m.length,2),P+=r(x.length,2),{fileRecord:c.LOCAL_FILE_HEADER+P+m+x,dirRecord:c.CENTRAL_FILE_HEADER+r(R,2)+P+r(b.length,2)+"\0\0\0\0"+r(L,4)+r(i,4)+m+x+b}}var o=e("../utils"),s=e("../stream/GenericWorker"),a=e("../utf8"),l=e("../crc32"),c=e("../signature");function u(e,t,n,r){s.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=n,this.encodeFileName=r,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(u,s),u.prototype.push=function(e){var t=e.meta.percent||0,n=this.entriesCount,r=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,s.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:n?(t+100*(n-r-1))/n:100}}))},u.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var n=i(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:n.fileRecord,meta:{percent:0}})}else this.accumulate=!0},u.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,n=i(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(n.dirRecord),t)this.push({data:function(e){return c.DATA_DESCRIPTOR+r(e.crc32,4)+r(e.compressedSize,4)+r(e.uncompressedSize,4)}(e),meta:{percent:100}});else for(this.push({data:n.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},u.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t=this.index;t--)n=(n<<8)+this.byteAt(t);return this.index+=e,n},readString:function(e){return r.transformTo("string",this.readData(e))},readData:function(e){},lastIndexOfSignature:function(e){},readAndCheckSignature:function(e){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i},{"../utils":32}],19:[function(e,t,n){"use strict";var r=e("./Uint8ArrayReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,n){"use strict";var r=e("./DataReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],21:[function(e,t,n){"use strict";var r=e("./ArrayReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,n){"use strict";var r=e("../utils"),i=e("../support"),o=e("./ArrayReader"),s=e("./StringReader"),a=e("./NodeBufferReader"),l=e("./Uint8ArrayReader");t.exports=function(e){var t=r.getTypeOf(e);return r.checkSupport(t),"string"!==t||i.uint8array?"nodebuffer"===t?new a(e):i.uint8array?new l(r.transformTo("uint8array",e)):new o(r.transformTo("array",e)):new s(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,n){"use strict";n.LOCAL_FILE_HEADER="PK",n.CENTRAL_FILE_HEADER="PK",n.CENTRAL_DIRECTORY_END="PK",n.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",n.ZIP64_CENTRAL_DIRECTORY_END="PK",n.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,n){"use strict";var r=e("./GenericWorker"),i=e("../utils");function o(e){r.call(this,"ConvertWorker to "+e),this.destType=e}i.inherits(o,r),o.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta})},t.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,n){"use strict";var r=e("./GenericWorker"),i=e("../crc32");function o(){r.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(o,r),o.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,n){"use strict";var r=e("../utils"),i=e("./GenericWorker");function o(e){i.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}r.inherits(o,i),o.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}i.prototype.processChunk.call(this,e)},t.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,n){"use strict";var r=e("../utils"),i=e("./GenericWorker");function o(e){i.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then((function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=r.getTypeOf(e),t.isPaused||t._tickAndRepeat()}),(function(e){t.error(e)}))}r.inherits(o,i),o.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,n){"use strict";function r(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}r.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var n=0;n "+e:e}},t.exports=r},{}],29:[function(e,t,n){"use strict";var r=e("../utils"),i=e("./ConvertWorker"),o=e("./GenericWorker"),s=e("../base64"),a=e("../support"),l=e("../external"),c=null;if(a.nodestream)try{c=e("../nodejs/NodejsStreamOutputAdapter")}catch(e){}function u(e,t,n){var s=t;switch(t){case"blob":case"arraybuffer":s="uint8array";break;case"base64":s="string"}try{this._internalType=s,this._outputType=t,this._mimeType=n,r.checkSupport(s),this._worker=e.pipe(new i(s)),e.lock()}catch(e){this._worker=new o("error"),this._worker.error(e)}}u.prototype={accumulate:function(e){return function(e,t){return new l.Promise((function(n,i){var o=[],a=e._internalType,l=e._outputType,c=e._mimeType;e.on("data",(function(e,n){o.push(e),t&&t(n)})).on("error",(function(e){o=[],i(e)})).on("end",(function(){try{var e=function(e,t,n){switch(e){case"blob":return r.newBlob(r.transformTo("arraybuffer",t),n);case"base64":return s.encode(t);default:return r.transformTo(e,t)}}(l,function(e,t){var n,r=0,i=null,o=0;for(n=0;n>>6:(n<65536?t[s++]=224|n>>>12:(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63),t[s++]=128|n>>>6&63),t[s++]=128|63&n);return t}(e)},n.utf8decode=function(e){return i.nodebuffer?r.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,n,i,o,s=e.length,l=new Array(2*s);for(t=n=0;t>10&1023,l[n++]=56320|1023&i)}return l.length!==n&&(l.subarray?l=l.subarray(0,n):l.length=n),r.applyFromCharCode(l)}(e=r.transformTo(i.uint8array?"uint8array":"array",e))},r.inherits(c,s),c.prototype.processChunk=function(e){var t=r.transformTo(i.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var o=t;(t=new Uint8Array(o.length+this.leftOver.length)).set(this.leftOver,0),t.set(o,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var s=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+a[e[n]]>t?n:t}(t),l=t;s!==t.length&&(i.uint8array?(l=t.subarray(0,s),this.leftOver=t.subarray(s,t.length)):(l=t.slice(0,s),this.leftOver=t.slice(s,t.length))),this.push({data:n.utf8decode(l),meta:e.meta})},c.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=c,r.inherits(u,s),u.prototype.processChunk=function(e){this.push({data:n.utf8encode(e.data),meta:e.meta})},n.Utf8EncodeWorker=u},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,n){"use strict";var r=e("./support"),i=e("./base64"),o=e("./nodejsUtils"),s=e("./external");function a(e){return e}function l(e,t){for(var n=0;n>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(e){if(this.extraFields[1]){var t=r(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=t.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=t.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=t.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=t.readInt(4))}},readExtraFields:function(e){var t,n,r,i=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4>>6:(n<65536?t[s++]=224|n>>>12:(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63),t[s++]=128|n>>>6&63),t[s++]=128|63&n);return t},n.buf2binstring=function(e){return l(e,e.length)},n.binstring2buf=function(e){for(var t=new r.Buf8(e.length),n=0,i=t.length;n>10&1023,c[r++]=56320|1023&i)}return l(c,r)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+s[e[n]]>t?n:t}},{"./common":41}],43:[function(e,t,n){"use strict";t.exports=function(e,t,n,r){for(var i=65535&e|0,o=e>>>16&65535|0,s=0;0!==n;){for(n-=s=2e3>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,i){var o=r,s=i+n;e^=-1;for(var a=i;a>>8^o[255&(e^t[a])];return-1^e}},{}],46:[function(e,t,n){"use strict";var r,i=e("../utils/common"),o=e("./trees"),s=e("./adler32"),a=e("./crc32"),l=e("./messages"),c=-2,u=258,d=262,h=113;function f(e,t){return e.msg=l[t],t}function p(e){return(e<<1)-(4e.avail_out&&(n=e.avail_out),0!==n&&(i.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))}function g(e,t){o._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,m(e.strm)}function v(e,t){e.pending_buf[e.pending++]=t}function b(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function y(e,t){var n,r,i=e.max_chain_length,o=e.strstart,s=e.prev_length,a=e.nice_match,l=e.strstart>e.w_size-d?e.strstart-(e.w_size-d):0,c=e.window,h=e.w_mask,f=e.prev,p=e.strstart+u,_=c[o+s-1],m=c[o+s];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(c[(n=t)+s]===m&&c[n+s-1]===_&&c[n]===c[o]&&c[++n]===c[o+1]){o+=2,n++;do{}while(c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&ol&&0!=--i);return s<=e.lookahead?s:e.lookahead}function w(e){var t,n,r,o,l,c,u,h,f,p,_=e.w_size;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=_+(_-d)){for(i.arraySet(e.window,e.window,_,_,0),e.match_start-=_,e.strstart-=_,e.block_start-=_,t=n=e.hash_size;r=e.head[--t],e.head[t]=_<=r?r-_:0,--n;);for(t=n=_;r=e.prev[--t],e.prev[t]=_<=r?r-_:0,--n;);o+=_}if(0===e.strm.avail_in)break;if(c=e.strm,u=e.window,h=e.strstart+e.lookahead,p=void 0,(f=o)<(p=c.avail_in)&&(p=f),n=0===p?0:(c.avail_in-=p,i.arraySet(u,c.input,c.next_in,p,h),1===c.state.wrap?c.adler=s(c.adler,u,p,h):2===c.state.wrap&&(c.adler=a(c.adler,u,p,h)),c.next_in+=p,c.total_in+=p,p),e.lookahead+=n,e.lookahead+e.insert>=3)for(l=e.strstart-e.insert,e.ins_h=e.window[l],e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<=3)if(r=o._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<=3&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-3,r=o._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(w(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((0===e.strstart||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,g(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-d&&(g(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(g(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(g(e,!1),e.strm.avail_out),1)})),new E(4,4,8,4,C),new E(4,5,16,8,C),new E(4,6,32,32,C),new E(4,4,16,16,x),new E(8,16,32,32,x),new E(8,16,128,128,x),new E(8,32,128,256,x),new E(32,128,258,1024,x),new E(32,258,258,4096,x)],n.deflateInit=function(e,t){return T(e,t,8,15,8,0)},n.deflateInit2=T,n.deflateReset=A,n.deflateResetKeep=k,n.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?c:(e.state.gzhead=t,0):c},n.deflate=function(e,t){var n,i,s,l;if(!e||!e.state||5>8&255),v(i,i.gzhead.time>>16&255),v(i,i.gzhead.time>>24&255),v(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),v(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(v(i,255&i.gzhead.extra.length),v(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=a(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(v(i,0),v(i,0),v(i,0),v(i,0),v(i,0),v(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),v(i,3),i.status=h);else{var d=8+(i.w_bits-8<<4)<<8;d|=(2<=i.strategy||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(d|=32),d+=31-d%31,i.status=h,b(i,d),0!==i.strstart&&(b(i,e.adler>>>16),b(i,65535&e.adler)),e.adler=1}if(69===i.status)if(i.gzhead.extra){for(s=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),m(e),s=i.pending,i.pending!==i.pending_buf_size));)v(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){s=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),m(e),s=i.pending,i.pending===i.pending_buf_size)){l=1;break}l=i.gzindexs&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),0===l&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){s=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),m(e),s=i.pending,i.pending===i.pending_buf_size)){l=1;break}l=i.gzindexs&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),0===l&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&m(e),i.pending+2<=i.pending_buf_size&&(v(i,255&e.adler),v(i,e.adler>>8&255),e.adler=0,i.status=h)):i.status=h),0!==i.pending){if(m(e),0===e.avail_out)return i.last_flush=-1,0}else if(0===e.avail_in&&p(t)<=p(n)&&4!==t)return f(e,-5);if(666===i.status&&0!==e.avail_in)return f(e,-5);if(0!==e.avail_in||0!==i.lookahead||0!==t&&666!==i.status){var y=2===i.strategy?function(e,t){for(var n;;){if(0===e.lookahead&&(w(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(g(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(g(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(g(e,!1),0===e.strm.avail_out)?1:2}(i,t):3===i.strategy?function(e,t){for(var n,r,i,s,a=e.window;;){if(e.lookahead<=u){if(w(e),e.lookahead<=u&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&0e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=o._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(g(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(g(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(g(e,!1),0===e.strm.avail_out)?1:2}(i,t):r[i.level].func(i,t);if(3!==y&&4!==y||(i.status=666),1===y||3===y)return 0===e.avail_out&&(i.last_flush=-1),0;if(2===y&&(1===t?o._tr_align(i):5!==t&&(o._tr_stored_block(i,0,0,!1),3===t&&(_(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),m(e),0===e.avail_out))return i.last_flush=-1,0}return 4!==t?0:i.wrap<=0?1:(2===i.wrap?(v(i,255&e.adler),v(i,e.adler>>8&255),v(i,e.adler>>16&255),v(i,e.adler>>24&255),v(i,255&e.total_in),v(i,e.total_in>>8&255),v(i,e.total_in>>16&255),v(i,e.total_in>>24&255)):(b(i,e.adler>>>16),b(i,65535&e.adler)),m(e),0=n.w_size&&(0===a&&(_(n.head),n.strstart=0,n.block_start=0,n.insert=0),h=new i.Buf8(n.w_size),i.arraySet(h,t,f-n.w_size,n.w_size,0),t=h,f=n.w_size),l=e.avail_in,u=e.next_in,d=e.input,e.avail_in=f,e.next_in=0,e.input=t,w(n);n.lookahead>=3;){for(r=n.strstart,o=n.lookahead-2;n.ins_h=(n.ins_h<>>=y=b>>>24,p-=y,0==(y=b>>>16&255))k[o++]=65535&b;else{if(!(16&y)){if(0==(64&y)){b=_[(65535&b)+(f&(1<>>=y,p-=y),p<15&&(f+=S[r++]<>>=y=b>>>24,p-=y,!(16&(y=b>>>16&255))){if(0==(64&y)){b=m[(65535&b)+(f&(1<>>=y,p-=y,(y=o-s)>3,f&=(1<<(p-=w<<3))-1,e.next_in=r,e.next_out=o,e.avail_in=r>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function u(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function d(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new r.Buf32(852),t.distcode=t.distdyn=new r.Buf32(592),t.sane=1,t.back=-1,0):l}function h(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,d(e)):l}function f(e,t){var n,r;return e&&e.state?(r=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15=s.wsize?(r.arraySet(s.window,t,n-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(i<(o=s.wsize-s.wnext)&&(o=i),r.arraySet(s.window,t,n-i,o,s.wnext),(i-=o)?(r.arraySet(s.window,t,n-i,i,0),s.wnext=i,s.whave=s.wsize):(s.wnext+=o,s.wnext===s.wsize&&(s.wnext=0),s.whave>>8&255,n.check=o(n.check,I,2,0),g=m=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&m)<<8)+(m>>8))%31){e.msg="incorrect header check",n.mode=30;break}if(8!=(15&m)){e.msg="unknown compression method",n.mode=30;break}if(g-=4,R=8+(15&(m>>>=4)),0===n.wbits)n.wbits=R;else if(R>n.wbits){e.msg="invalid window size",n.mode=30;break}n.dmax=1<>8&1),512&n.flags&&(I[0]=255&m,I[1]=m>>>8&255,n.check=o(n.check,I,2,0)),g=m=0,n.mode=3;case 3:for(;g<32;){if(0===p)break e;p--,m+=u[h++]<>>8&255,I[2]=m>>>16&255,I[3]=m>>>24&255,n.check=o(n.check,I,4,0)),g=m=0,n.mode=4;case 4:for(;g<16;){if(0===p)break e;p--,m+=u[h++]<>8),512&n.flags&&(I[0]=255&m,I[1]=m>>>8&255,n.check=o(n.check,I,2,0)),g=m=0,n.mode=5;case 5:if(1024&n.flags){for(;g<16;){if(0===p)break e;p--,m+=u[h++]<>>8&255,n.check=o(n.check,I,2,0)),g=m=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&(p<(C=n.length)&&(C=p),C&&(n.head&&(R=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),r.arraySet(n.head.extra,u,h,C,R)),512&n.flags&&(n.check=o(n.check,u,C,h)),p-=C,h+=C,n.length-=C),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===p)break e;for(C=0;R=u[h+C++],n.head&&R&&n.length<65536&&(n.head.name+=String.fromCharCode(R)),R&&C>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;g<32;){if(0===p)break e;p--,m+=u[h++]<>>=7&g,g-=7&g,n.mode=27;break}for(;g<3;){if(0===p)break e;p--,m+=u[h++]<>>=1)){case 0:n.mode=14;break;case 1:if(v(n),n.mode=20,6!==t)break;m>>>=2,g-=2;break e;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=30}m>>>=2,g-=2;break;case 14:for(m>>>=7&g,g-=7&g;g<32;){if(0===p)break e;p--,m+=u[h++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&m,g=m=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(C=n.length){if(p>>=5,g-=5,n.ndist=1+(31&m),m>>>=5,g-=5,n.ncode=4+(15&m),m>>>=4,g-=4,286>>=3,g-=3}for(;n.have<19;)n.lens[B[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,O={bits:n.lenbits},P=a(0,n.lens,0,19,n.lencode,0,n.work,O),n.lenbits=O.bits,P){e.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have>>16&255,A=65535&z,!((S=z>>>24)<=g);){if(0===p)break e;p--,m+=u[h++]<>>=S,g-=S,n.lens[n.have++]=A;else{if(16===A){for(W=S+2;g>>=S,g-=S,0===n.have){e.msg="invalid bit length repeat",n.mode=30;break}R=n.lens[n.have-1],C=3+(3&m),m>>>=2,g-=2}else if(17===A){for(W=S+3;g>>=S)),m>>>=3,g-=3}else{for(W=S+7;g>>=S)),m>>>=7,g-=7}if(n.have+C>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=30;break}for(;C--;)n.lens[n.have++]=R}}if(30===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,O={bits:n.lenbits},P=a(1,n.lens,0,n.nlen,n.lencode,0,n.work,O),n.lenbits=O.bits,P){e.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,O={bits:n.distbits},P=a(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,O),n.distbits=O.bits,P){e.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(6<=p&&258<=_){e.next_out=f,e.avail_out=_,e.next_in=h,e.avail_in=p,n.hold=m,n.bits=g,s(e,w),f=e.next_out,d=e.output,_=e.avail_out,h=e.next_in,u=e.input,p=e.avail_in,m=n.hold,g=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;k=(z=n.lencode[m&(1<>>16&255,A=65535&z,!((S=z>>>24)<=g);){if(0===p)break e;p--,m+=u[h++]<>T)])>>>16&255,A=65535&z,!(T+(S=z>>>24)<=g);){if(0===p)break e;p--,m+=u[h++]<>>=T,g-=T,n.back+=T}if(m>>>=S,g-=S,n.back+=S,n.length=A,0===k){n.mode=26;break}if(32&k){n.back=-1,n.mode=12;break}if(64&k){e.msg="invalid literal/length code",n.mode=30;break}n.extra=15&k,n.mode=22;case 22:if(n.extra){for(W=n.extra;g>>=n.extra,g-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;k=(z=n.distcode[m&(1<>>16&255,A=65535&z,!((S=z>>>24)<=g);){if(0===p)break e;p--,m+=u[h++]<>T)])>>>16&255,A=65535&z,!(T+(S=z>>>24)<=g);){if(0===p)break e;p--,m+=u[h++]<>>=T,g-=T,n.back+=T}if(m>>>=S,g-=S,n.back+=S,64&k){e.msg="invalid distance code",n.mode=30;break}n.offset=A,n.extra=15&k,n.mode=24;case 24:if(n.extra){for(W=n.extra;g>>=n.extra,g-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===_)break e;if(C=w-_,n.offset>C){if((C=n.offset-C)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=30;break}x=C>n.wnext?(C-=n.wnext,n.wsize-C):n.wnext-C,C>n.length&&(C=n.length),E=n.window}else E=d,x=f-n.offset,C=n.length;for(_v?(y=B[M+d[E]],O[W+d[E]]):(y=96,0),f=1<>N)+(p-=f)]=b<<24|y<<16|w|0,0!==p;);for(f=1<>=1;if(0!==f?(P&=f-1,P+=f):P=0,E++,0==--z[x]){if(x===k)break;x=t[n+d[E]]}if(A>>7)]}function S(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function k(e,t,n){e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<>>=1,n<<=1,0<--t;);return n>>>1}function N(e,t,n){var r,i,o=new Array(16),s=0;for(r=1;r<=l;r++)o[r]=s=s+n[r-1]<<1;for(i=0;i<=t;i++){var a=e[2*i+1];0!==a&&(e[2*i]=T(o[a]++,a))}}function L(e){var t;for(t=0;t>1;1<=n;n--)O(e,o,n);for(i=c;n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],O(e,o,1),r=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=r,o[2*i]=o[2*n]+o[2*r],e.depth[i]=(e.depth[n]>=e.depth[r]?e.depth[n]:e.depth[r])+1,o[2*n+1]=o[2*r+1]=i,e.heap[1]=i++,O(e,o,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,r,i,o,s,a,c=t.dyn_tree,u=t.max_code,d=t.stat_desc.static_tree,h=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,_=t.stat_desc.max_length,m=0;for(o=0;o<=l;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n<573;n++)_<(o=c[2*c[2*(r=e.heap[n])+1]+1]+1)&&(o=_,m++),c[2*r+1]=o,u>=7;r>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t>>3,(s=e.static_len+3+7>>>3)<=i&&(i=s)):i=s=n+5,n+4<=i&&-1!==t?U(e,t,n,r):4===e.strategy||s===i?(k(e,2+(r?1:0),3),W(e,f,p)):(k(e,4+(r?1:0),3),function(e,t,n,r){var i;for(k(e,t-257,5),k(e,n-1,5),k(e,r-4,4),i=0;i>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(m[n]+o+1)]++,e.dyn_dtree[2*E(t)]++),e.last_lit===e.lit_bufsize-1},n._tr_align=function(e){k(e,2,3),A(e,256,f),function(e){16===e.bi_valid?(S(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":41}],53:[function(e,t,n){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,r){(function(e){!function(e,t){"use strict";if(!e.setImmediate){var n,r,i,o,s=1,a={},l=!1,c=e.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(e);u=u&&u.setTimeout?u:e,n="[object process]"==={}.toString.call(e.process)?function(e){process.nextTick((function(){h(e)}))}:function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?(o="setImmediate$"+Math.random()+"$",e.addEventListener?e.addEventListener("message",f,!1):e.attachEvent("onmessage",f),function(t){e.postMessage(o+t,"*")}):e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){h(e.data)},function(e){i.port2.postMessage(e)}):c&&"onreadystatechange"in c.createElement("script")?(r=c.documentElement,function(e){var t=c.createElement("script");t.onreadystatechange=function(){h(e),t.onreadystatechange=null,r.removeChild(t),t=null},r.appendChild(t)}):function(e){setTimeout(h,0,e)},u.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r"']/g,J=RegExp(V.source),$=RegExp(Y.source),X=/<%-([\s\S]+?)%>/g,G=/<%([\s\S]+?)%>/g,Z=/<%=([\s\S]+?)%>/g,K=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Q=/^\w*$/,ee=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,te=/[\\^$.*+?()[\]{}|]/g,ne=RegExp(te.source),re=/^\s+/,ie=/\s/,oe=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,se=/\{\n\/\* \[wrapped with (.+)\] \*/,ae=/,? & /,le=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ce=/[()=,{}\[\]\/\s]/,ue=/\\(\\)?/g,de=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,he=/\w*$/,fe=/^[-+]0x[0-9a-f]+$/i,pe=/^0b[01]+$/i,_e=/^\[object .+?Constructor\]$/,me=/^0o[0-7]+$/i,ge=/^(?:0|[1-9]\d*)$/,ve=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,be=/($^)/,ye=/['\n\r\u2028\u2029\\]/g,we="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ce="a-z\\xdf-\\xf6\\xf8-\\xff",xe="A-Z\\xc0-\\xd6\\xd8-\\xde",Ee="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Se="["+Ee+"]",ke="["+we+"]",Ae="\\d+",Te="["+Ce+"]",Ne="[^\\ud800-\\udfff"+Ee+Ae+"\\u2700-\\u27bf"+Ce+xe+"]",Le="\\ud83c[\\udffb-\\udfff]",Re="[^\\ud800-\\udfff]",Pe="(?:\\ud83c[\\udde6-\\uddff]){2}",Oe="[\\ud800-\\udbff][\\udc00-\\udfff]",We="["+xe+"]",ze="(?:"+Te+"|"+Ne+")",Ie="(?:"+We+"|"+Ne+")",Be="(?:['’](?:d|ll|m|re|s|t|ve))?",Me="(?:['’](?:D|LL|M|RE|S|T|VE))?",Ue="(?:"+ke+"|"+Le+")?",De="[\\ufe0e\\ufe0f]?",Fe=De+Ue+"(?:\\u200d(?:"+[Re,Pe,Oe].join("|")+")"+De+Ue+")*",qe="(?:"+["[\\u2700-\\u27bf]",Pe,Oe].join("|")+")"+Fe,He="(?:"+[Re+ke+"?",ke,Pe,Oe,"[\\ud800-\\udfff]"].join("|")+")",je=RegExp("['’]","g"),Ve=RegExp(ke,"g"),Ye=RegExp(Le+"(?="+Le+")|"+He+Fe,"g"),Je=RegExp([We+"?"+Te+"+"+Be+"(?="+[Se,We,"$"].join("|")+")",Ie+"+"+Me+"(?="+[Se,We+ze,"$"].join("|")+")",We+"?"+ze+"+"+Be,We+"+"+Me,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ae,qe].join("|"),"g"),$e=RegExp("[\\u200d\\ud800-\\udfff"+we+"\\ufe0e\\ufe0f]"),Xe=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Ge=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Ze=-1,Ke={};Ke[O]=Ke[W]=Ke[z]=Ke[I]=Ke[B]=Ke[M]=Ke[U]=Ke[D]=Ke[F]=!0,Ke[_]=Ke[m]=Ke[R]=Ke[g]=Ke[P]=Ke[v]=Ke[b]=Ke[y]=Ke[C]=Ke[x]=Ke[E]=Ke[k]=Ke[A]=Ke[T]=Ke[L]=!1;var Qe={};Qe[_]=Qe[m]=Qe[R]=Qe[P]=Qe[g]=Qe[v]=Qe[O]=Qe[W]=Qe[z]=Qe[I]=Qe[B]=Qe[C]=Qe[x]=Qe[E]=Qe[k]=Qe[A]=Qe[T]=Qe[N]=Qe[M]=Qe[U]=Qe[D]=Qe[F]=!0,Qe[b]=Qe[y]=Qe[L]=!1;var et={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},tt=parseFloat,nt=parseInt,rt="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,it="object"==typeof self&&self&&self.Object===Object&&self,ot=rt||it||Function("return this")(),st=t&&!t.nodeType&&t,at=st&&e&&!e.nodeType&&e,lt=at&&at.exports===st,ct=lt&&rt.process,ut=function(){try{return at&&at.require&&at.require("util").types||ct&&ct.binding&&ct.binding("util")}catch(e){}}(),dt=ut&&ut.isArrayBuffer,ht=ut&&ut.isDate,ft=ut&&ut.isMap,pt=ut&&ut.isRegExp,_t=ut&&ut.isSet,mt=ut&&ut.isTypedArray;function gt(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function vt(e,t,n,r){for(var i=-1,o=null==e?0:e.length;++i-1}function Et(e,t,n){for(var r=-1,i=null==e?0:e.length;++r-1;);return n}function Jt(e,t){for(var n=e.length;n--&&Ot(t,e[n],0)>-1;);return n}function $t(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}var Xt=Mt({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"}),Gt=Mt({"&":"&","<":"<",">":">",'"':""","'":"'"});function Zt(e){return"\\"+et[e]}function Kt(e){return $e.test(e)}function Qt(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function en(e,t){return function(n){return e(t(n))}}function tn(e,t){for(var n=-1,r=e.length,i=0,o=[];++n",""":'"',"'":"'"}),cn=function e(t){var n,r=(t=null==t?ot:cn.defaults(ot.Object(),t,cn.pick(ot,Ge))).Array,ie=t.Date,we=t.Error,Ce=t.Function,xe=t.Math,Ee=t.Object,Se=t.RegExp,ke=t.String,Ae=t.TypeError,Te=r.prototype,Ne=Ce.prototype,Le=Ee.prototype,Re=t["__core-js_shared__"],Pe=Ne.toString,Oe=Le.hasOwnProperty,We=0,ze=(n=/[^.]+$/.exec(Re&&Re.keys&&Re.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",Ie=Le.toString,Be=Pe.call(Ee),Me=ot._,Ue=Se("^"+Pe.call(Oe).replace(te,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),De=lt?t.Buffer:i,Fe=t.Symbol,qe=t.Uint8Array,He=De?De.allocUnsafe:i,Ye=en(Ee.getPrototypeOf,Ee),$e=Ee.create,et=Le.propertyIsEnumerable,rt=Te.splice,it=Fe?Fe.isConcatSpreadable:i,st=Fe?Fe.iterator:i,at=Fe?Fe.toStringTag:i,ct=function(){try{var e=co(Ee,"defineProperty");return e({},"",{}),e}catch(e){}}(),ut=t.clearTimeout!==ot.clearTimeout&&t.clearTimeout,Lt=ie&&ie.now!==ot.Date.now&&ie.now,Mt=t.setTimeout!==ot.setTimeout&&t.setTimeout,un=xe.ceil,dn=xe.floor,hn=Ee.getOwnPropertySymbols,fn=De?De.isBuffer:i,pn=t.isFinite,_n=Te.join,mn=en(Ee.keys,Ee),gn=xe.max,vn=xe.min,bn=ie.now,yn=t.parseInt,wn=xe.random,Cn=Te.reverse,xn=co(t,"DataView"),En=co(t,"Map"),Sn=co(t,"Promise"),kn=co(t,"Set"),An=co(t,"WeakMap"),Tn=co(Ee,"create"),Nn=An&&new An,Ln={},Rn=Uo(xn),Pn=Uo(En),On=Uo(Sn),Wn=Uo(kn),zn=Uo(An),In=Fe?Fe.prototype:i,Bn=In?In.valueOf:i,Mn=In?In.toString:i;function Un(e){if(na(e)&&!Vs(e)&&!(e instanceof Hn)){if(e instanceof qn)return e;if(Oe.call(e,"__wrapped__"))return Do(e)}return new qn(e)}var Dn=function(){function e(){}return function(t){if(!ta(t))return{};if($e)return $e(t);e.prototype=t;var n=new e;return e.prototype=i,n}}();function Fn(){}function qn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=i}function Hn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=f,this.__views__=[]}function jn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function ar(e,t,n,r,o,s){var a,l=1&t,c=2&t,u=4&t;if(n&&(a=o?n(e,r,o,s):n(e)),a!==i)return a;if(!ta(e))return e;var d=Vs(e);if(d){if(a=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&Oe.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e),!l)return Ai(e,a)}else{var h=fo(e),f=h==y||h==w;if(Xs(e))return wi(e,l);if(h==E||h==_||f&&!o){if(a=c||f?{}:_o(e),!l)return c?function(e,t){return Ti(e,ho(e),t)}(e,function(e,t){return e&&Ti(t,Oa(t),e)}(a,e)):function(e,t){return Ti(e,uo(e),t)}(e,rr(a,e))}else{if(!Qe[h])return o?e:{};a=function(e,t,n){var r,i=e.constructor;switch(t){case R:return Ci(e);case g:case v:return new i(+e);case P:return function(e,t){var n=t?Ci(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case O:case W:case z:case I:case B:case M:case U:case D:case F:return xi(e,n);case C:return new i;case x:case T:return new i(e);case k:return function(e){var t=new e.constructor(e.source,he.exec(e));return t.lastIndex=e.lastIndex,t}(e);case A:return new i;case N:return r=e,Bn?Ee(Bn.call(r)):{}}}(e,h,l)}}s||(s=new $n);var p=s.get(e);if(p)return p;s.set(e,a),aa(e)?e.forEach((function(r){a.add(ar(r,t,n,r,e,s))})):ra(e)&&e.forEach((function(r,i){a.set(i,ar(r,t,n,i,e,s))}));var m=d?i:(u?c?no:to:c?Oa:Pa)(e);return bt(m||e,(function(r,i){m&&(r=e[i=r]),er(a,i,ar(r,t,n,i,e,s))})),a}function lr(e,t,n){var r=n.length;if(null==e)return!r;for(e=Ee(e);r--;){var o=n[r],s=t[o],a=e[o];if(a===i&&!(o in e)||!s(a))return!1}return!0}function cr(e,t,n){if("function"!=typeof e)throw new Ae(o);return Lo((function(){e.apply(i,n)}),t)}function ur(e,t,n,r){var i=-1,o=xt,s=!0,a=e.length,l=[],c=t.length;if(!a)return l;n&&(t=St(t,Ht(n))),r?(o=Et,s=!1):t.length>=200&&(o=Vt,s=!1,t=new Jn(t));e:for(;++i-1},Vn.prototype.set=function(e,t){var n=this.__data__,r=tr(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},Yn.prototype.clear=function(){this.size=0,this.__data__={hash:new jn,map:new(En||Vn),string:new jn}},Yn.prototype.delete=function(e){var t=ao(this,e).delete(e);return this.size-=t?1:0,t},Yn.prototype.get=function(e){return ao(this,e).get(e)},Yn.prototype.has=function(e){return ao(this,e).has(e)},Yn.prototype.set=function(e,t){var n=ao(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},Jn.prototype.add=Jn.prototype.push=function(e){return this.__data__.set(e,s),this},Jn.prototype.has=function(e){return this.__data__.has(e)},$n.prototype.clear=function(){this.__data__=new Vn,this.size=0},$n.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},$n.prototype.get=function(e){return this.__data__.get(e)},$n.prototype.has=function(e){return this.__data__.has(e)},$n.prototype.set=function(e,t){var n=this.__data__;if(n instanceof Vn){var r=n.__data__;if(!En||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Yn(r)}return n.set(e,t),this.size=n.size,this};var dr=Ri(br),hr=Ri(yr,!0);function fr(e,t){var n=!0;return dr(e,(function(e,r,i){return n=!!t(e,r,i)})),n}function pr(e,t,n){for(var r=-1,o=e.length;++r0&&n(a)?t>1?mr(a,t-1,n,r,i):kt(i,a):r||(i[i.length]=a)}return i}var gr=Pi(),vr=Pi(!0);function br(e,t){return e&&gr(e,t,Pa)}function yr(e,t){return e&&vr(e,t,Pa)}function wr(e,t){return Ct(t,(function(t){return Ks(e[t])}))}function Cr(e,t){for(var n=0,r=(t=gi(t,e)).length;null!=e&&nt}function kr(e,t){return null!=e&&Oe.call(e,t)}function Ar(e,t){return null!=e&&t in Ee(e)}function Tr(e,t,n){for(var o=n?Et:xt,s=e[0].length,a=e.length,l=a,c=r(a),u=1/0,d=[];l--;){var h=e[l];l&&t&&(h=St(h,Ht(t))),u=vn(h.length,u),c[l]=!n&&(t||s>=120&&h.length>=120)?new Jn(l&&h):i}h=e[0];var f=-1,p=c[0];e:for(;++f=a?l:l*("desc"==n[r]?-1:1)}return e.index-t.index}(e,t,n)}));r--;)e[r]=e[r].value;return e}(i)}function Hr(e,t,n){for(var r=-1,i=t.length,o={};++r-1;)a!==e&&rt.call(a,l,1),rt.call(e,l,1);return e}function Vr(e,t){for(var n=e?t.length:0,r=n-1;n--;){var i=t[n];if(n==r||i!==o){var o=i;go(i)?rt.call(e,i,1):ci(e,i)}}return e}function Yr(e,t){return e+dn(wn()*(t-e+1))}function Jr(e,t){var n="";if(!e||t<1||t>d)return n;do{t%2&&(n+=e),(t=dn(t/2))&&(e+=e)}while(t);return n}function $r(e,t){return Ro(So(e,t,il),e+"")}function Xr(e){return Gn(Fa(e))}function Gr(e,t){var n=Fa(e);return Wo(n,sr(t,0,n.length))}function Zr(e,t,n,r){if(!ta(e))return e;for(var o=-1,s=(t=gi(t,e)).length,a=s-1,l=e;null!=l&&++oo?0:o+t),(n=n>o?o:n)<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var s=r(o);++i>>1,s=e[o];null!==s&&!ca(s)&&(n?s<=t:s=200){var c=t?null:Ji(e);if(c)return nn(c);s=!1,i=Vt,l=new Jn}else l=t?[]:a;e:for(;++r=r?e:ti(e,t,n)}var yi=ut||function(e){return ot.clearTimeout(e)};function wi(e,t){if(t)return e.slice();var n=e.length,r=He?He(n):new e.constructor(n);return e.copy(r),r}function Ci(e){var t=new e.constructor(e.byteLength);return new qe(t).set(new qe(e)),t}function xi(e,t){var n=t?Ci(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Ei(e,t){if(e!==t){var n=e!==i,r=null===e,o=e==e,s=ca(e),a=t!==i,l=null===t,c=t==t,u=ca(t);if(!l&&!u&&!s&&e>t||s&&a&&c&&!l&&!u||r&&a&&c||!n&&c||!o)return 1;if(!r&&!s&&!u&&e1?n[o-1]:i,a=o>2?n[2]:i;for(s=e.length>3&&"function"==typeof s?(o--,s):i,a&&vo(n[0],n[1],a)&&(s=o<3?i:s,o=1),t=Ee(t);++r-1?o[s?t[a]:a]:i}}function Bi(e){return eo((function(t){var n=t.length,r=n,s=qn.prototype.thru;for(e&&t.reverse();r--;){var a=t[r];if("function"!=typeof a)throw new Ae(o);if(s&&!l&&"wrapper"==io(a))var l=new qn([],!0)}for(r=l?r:n;++r1&&b.reverse(),f&&dl))return!1;var u=s.get(e),d=s.get(t);if(u&&d)return u==t&&d==e;var h=-1,f=!0,p=2&n?new Jn:i;for(s.set(e,t),s.set(t,e);++h-1&&e%1==0&&e1?"& ":"")+t[r],t=t.join(n>2?", ":" "),e.replace(oe,"{\n/* [wrapped with "+t+"] */\n")}(r,function(e,t){return bt(p,(function(n){var r="_."+n[0];t&n[1]&&!xt(e,r)&&e.push(r)})),e.sort()}(function(e){var t=e.match(se);return t?t[1].split(ae):[]}(r),n)))}function Oo(e){var t=0,n=0;return function(){var r=bn(),o=16-(r-n);if(n=r,o>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(i,arguments)}}function Wo(e,t){var n=-1,r=e.length,o=r-1;for(t=t===i?r:t;++n1?e[t-1]:i;return n="function"==typeof n?(e.pop(),n):i,ss(e,n)}));function fs(e){var t=Un(e);return t.__chain__=!0,t}function ps(e,t){return t(e)}var _s=eo((function(e){var t=e.length,n=t?e[0]:0,r=this.__wrapped__,o=function(t){return or(t,e)};return!(t>1||this.__actions__.length)&&r instanceof Hn&&go(n)?((r=r.slice(n,+n+(t?1:0))).__actions__.push({func:ps,args:[o],thisArg:i}),new qn(r,this.__chain__).thru((function(e){return t&&!e.length&&e.push(i),e}))):this.thru(o)})),ms=Ni((function(e,t,n){Oe.call(e,n)?++e[n]:ir(e,n,1)})),gs=Ii(jo),vs=Ii(Vo);function bs(e,t){return(Vs(e)?bt:dr)(e,so(t,3))}function ys(e,t){return(Vs(e)?yt:hr)(e,so(t,3))}var ws=Ni((function(e,t,n){Oe.call(e,n)?e[n].push(t):ir(e,n,[t])})),Cs=$r((function(e,t,n){var i=-1,o="function"==typeof t,s=Js(e)?r(e.length):[];return dr(e,(function(e){s[++i]=o?gt(t,e,n):Nr(e,t,n)})),s})),xs=Ni((function(e,t,n){ir(e,n,t)}));function Es(e,t){return(Vs(e)?St:Br)(e,so(t,3))}var Ss=Ni((function(e,t,n){e[n?0:1].push(t)}),(function(){return[[],[]]})),ks=$r((function(e,t){if(null==e)return[];var n=t.length;return n>1&&vo(e,t[0],t[1])?t=[]:n>2&&vo(t[0],t[1],t[2])&&(t=[t[0]]),qr(e,mr(t,1),[])})),As=Lt||function(){return ot.Date.now()};function Ts(e,t,n){return t=n?i:t,t=e&&null==t?e.length:t,Xi(e,c,i,i,i,i,t)}function Ns(e,t){var n;if("function"!=typeof t)throw new Ae(o);return e=_a(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=i),n}}var Ls=$r((function(e,t,n){var r=1;if(n.length){var i=tn(n,oo(Ls));r|=l}return Xi(e,r,t,n,i)})),Rs=$r((function(e,t,n){var r=3;if(n.length){var i=tn(n,oo(Rs));r|=l}return Xi(t,r,e,n,i)}));function Ps(e,t,n){var r,s,a,l,c,u,d=0,h=!1,f=!1,p=!0;if("function"!=typeof e)throw new Ae(o);function _(t){var n=r,o=s;return r=s=i,d=t,l=e.apply(o,n)}function m(e){return d=e,c=Lo(v,t),h?_(e):l}function g(e){var n=e-u;return u===i||n>=t||n<0||f&&e-d>=a}function v(){var e=As();if(g(e))return b(e);c=Lo(v,function(e){var n=t-(e-u);return f?vn(n,a-(e-d)):n}(e))}function b(e){return c=i,p&&r?_(e):(r=s=i,l)}function y(){var e=As(),n=g(e);if(r=arguments,s=this,u=e,n){if(c===i)return m(u);if(f)return yi(c),c=Lo(v,t),_(u)}return c===i&&(c=Lo(v,t)),l}return t=ga(t)||0,ta(n)&&(h=!!n.leading,a=(f="maxWait"in n)?gn(ga(n.maxWait)||0,t):a,p="trailing"in n?!!n.trailing:p),y.cancel=function(){c!==i&&yi(c),d=0,r=u=s=c=i},y.flush=function(){return c===i?l:b(As())},y}var Os=$r((function(e,t){return cr(e,1,t)})),Ws=$r((function(e,t,n){return cr(e,ga(t)||0,n)}));function zs(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Ae(o);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=e.apply(this,r);return n.cache=o.set(i,s)||o,s};return n.cache=new(zs.Cache||Yn),n}function Is(e){if("function"!=typeof e)throw new Ae(o);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}zs.Cache=Yn;var Bs=vi((function(e,t){var n=(t=1==t.length&&Vs(t[0])?St(t[0],Ht(so())):St(mr(t,1),Ht(so()))).length;return $r((function(r){for(var i=-1,o=vn(r.length,n);++i=t})),js=Lr(function(){return arguments}())?Lr:function(e){return na(e)&&Oe.call(e,"callee")&&!et.call(e,"callee")},Vs=r.isArray,Ys=dt?Ht(dt):function(e){return na(e)&&Er(e)==R};function Js(e){return null!=e&&ea(e.length)&&!Ks(e)}function $s(e){return na(e)&&Js(e)}var Xs=fn||gl,Gs=ht?Ht(ht):function(e){return na(e)&&Er(e)==v};function Zs(e){if(!na(e))return!1;var t=Er(e);return t==b||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!oa(e)}function Ks(e){if(!ta(e))return!1;var t=Er(e);return t==y||t==w||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Qs(e){return"number"==typeof e&&e==_a(e)}function ea(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=d}function ta(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function na(e){return null!=e&&"object"==typeof e}var ra=ft?Ht(ft):function(e){return na(e)&&fo(e)==C};function ia(e){return"number"==typeof e||na(e)&&Er(e)==x}function oa(e){if(!na(e)||Er(e)!=E)return!1;var t=Ye(e);if(null===t)return!0;var n=Oe.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Pe.call(n)==Be}var sa=pt?Ht(pt):function(e){return na(e)&&Er(e)==k},aa=_t?Ht(_t):function(e){return na(e)&&fo(e)==A};function la(e){return"string"==typeof e||!Vs(e)&&na(e)&&Er(e)==T}function ca(e){return"symbol"==typeof e||na(e)&&Er(e)==N}var ua=mt?Ht(mt):function(e){return na(e)&&ea(e.length)&&!!Ke[Er(e)]},da=ji(Ir),ha=ji((function(e,t){return e<=t}));function fa(e){if(!e)return[];if(Js(e))return la(e)?sn(e):Ai(e);if(st&&e[st])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[st]());var t=fo(e);return(t==C?Qt:t==A?nn:Fa)(e)}function pa(e){return e?(e=ga(e))===u||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function _a(e){var t=pa(e),n=t%1;return t==t?n?t-n:t:0}function ma(e){return e?sr(_a(e),0,f):0}function ga(e){if("number"==typeof e)return e;if(ca(e))return h;if(ta(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=ta(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=qt(e);var n=pe.test(e);return n||me.test(e)?nt(e.slice(2),n?2:8):fe.test(e)?h:+e}function va(e){return Ti(e,Oa(e))}function ba(e){return null==e?"":ai(e)}var ya=Li((function(e,t){if(Co(t)||Js(t))Ti(t,Pa(t),e);else for(var n in t)Oe.call(t,n)&&er(e,n,t[n])})),wa=Li((function(e,t){Ti(t,Oa(t),e)})),Ca=Li((function(e,t,n,r){Ti(t,Oa(t),e,r)})),xa=Li((function(e,t,n,r){Ti(t,Pa(t),e,r)})),Ea=eo(or),Sa=$r((function(e,t){e=Ee(e);var n=-1,r=t.length,o=r>2?t[2]:i;for(o&&vo(t[0],t[1],o)&&(r=1);++n1),t})),Ti(e,no(e),n),r&&(n=ar(n,7,Ki));for(var i=t.length;i--;)ci(n,t[i]);return n})),Ba=eo((function(e,t){return null==e?{}:function(e,t){return Hr(e,t,(function(t,n){return Ta(e,n)}))}(e,t)}));function Ma(e,t){if(null==e)return{};var n=St(no(e),(function(e){return[e]}));return t=so(t),Hr(e,n,(function(e,n){return t(e,n[0])}))}var Ua=$i(Pa),Da=$i(Oa);function Fa(e){return null==e?[]:jt(e,Pa(e))}var qa=Wi((function(e,t,n){return t=t.toLowerCase(),e+(n?Ha(t):t)}));function Ha(e){return Za(ba(e).toLowerCase())}function ja(e){return(e=ba(e))&&e.replace(ve,Xt).replace(Ve,"")}var Va=Wi((function(e,t,n){return e+(n?"-":"")+t.toLowerCase()})),Ya=Wi((function(e,t,n){return e+(n?" ":"")+t.toLowerCase()})),Ja=Oi("toLowerCase"),$a=Wi((function(e,t,n){return e+(n?"_":"")+t.toLowerCase()})),Xa=Wi((function(e,t,n){return e+(n?" ":"")+Za(t)})),Ga=Wi((function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})),Za=Oi("toUpperCase");function Ka(e,t,n){return e=ba(e),(t=n?i:t)===i?function(e){return Xe.test(e)}(e)?function(e){return e.match(Je)||[]}(e):function(e){return e.match(le)||[]}(e):e.match(t)||[]}var Qa=$r((function(e,t){try{return gt(e,i,t)}catch(e){return Zs(e)?e:new we(e)}})),el=eo((function(e,t){return bt(t,(function(t){t=Mo(t),ir(e,t,Ls(e[t],e))})),e}));function tl(e){return function(){return e}}var nl=Bi(),rl=Bi(!0);function il(e){return e}function ol(e){return Wr("function"==typeof e?e:ar(e,1))}var sl=$r((function(e,t){return function(n){return Nr(n,e,t)}})),al=$r((function(e,t){return function(n){return Nr(e,n,t)}}));function ll(e,t,n){var r=Pa(t),i=wr(t,r);null!=n||ta(t)&&(i.length||!r.length)||(n=t,t=e,e=this,i=wr(t,Pa(t)));var o=!(ta(n)&&"chain"in n&&!n.chain),s=Ks(e);return bt(i,(function(n){var r=t[n];e[n]=r,s&&(e.prototype[n]=function(){var t=this.__chain__;if(o||t){var n=e(this.__wrapped__),i=n.__actions__=Ai(this.__actions__);return i.push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,kt([this.value()],arguments))})})),e}function cl(){}var ul=Fi(St),dl=Fi(wt),hl=Fi(Nt);function fl(e){return bo(e)?Bt(Mo(e)):function(e){return function(t){return Cr(t,e)}}(e)}var pl=Hi(),_l=Hi(!0);function ml(){return[]}function gl(){return!1}var vl,bl=Di((function(e,t){return e+t}),0),yl=Yi("ceil"),wl=Di((function(e,t){return e/t}),1),Cl=Yi("floor"),xl=Di((function(e,t){return e*t}),1),El=Yi("round"),Sl=Di((function(e,t){return e-t}),0);return Un.after=function(e,t){if("function"!=typeof t)throw new Ae(o);return e=_a(e),function(){if(--e<1)return t.apply(this,arguments)}},Un.ary=Ts,Un.assign=ya,Un.assignIn=wa,Un.assignInWith=Ca,Un.assignWith=xa,Un.at=Ea,Un.before=Ns,Un.bind=Ls,Un.bindAll=el,Un.bindKey=Rs,Un.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Vs(e)?e:[e]},Un.chain=fs,Un.chunk=function(e,t,n){t=(n?vo(e,t,n):t===i)?1:gn(_a(t),0);var o=null==e?0:e.length;if(!o||t<1)return[];for(var s=0,a=0,l=r(un(o/t));so?0:o+n),(r=r===i||r>o?o:_a(r))<0&&(r+=o),r=n>r?0:ma(r);n>>0)?(e=ba(e))&&("string"==typeof t||null!=t&&!sa(t))&&!(t=ai(t))&&Kt(e)?bi(sn(e),0,n):e.split(t,n):[]},Un.spread=function(e,t){if("function"!=typeof e)throw new Ae(o);return t=null==t?0:gn(_a(t),0),$r((function(n){var r=n[t],i=bi(n,0,t);return r&&kt(i,r),gt(e,this,i)}))},Un.tail=function(e){var t=null==e?0:e.length;return t?ti(e,1,t):[]},Un.take=function(e,t,n){return e&&e.length?ti(e,0,(t=n||t===i?1:_a(t))<0?0:t):[]},Un.takeRight=function(e,t,n){var r=null==e?0:e.length;return r?ti(e,(t=r-(t=n||t===i?1:_a(t)))<0?0:t,r):[]},Un.takeRightWhile=function(e,t){return e&&e.length?di(e,so(t,3),!1,!0):[]},Un.takeWhile=function(e,t){return e&&e.length?di(e,so(t,3)):[]},Un.tap=function(e,t){return t(e),e},Un.throttle=function(e,t,n){var r=!0,i=!0;if("function"!=typeof e)throw new Ae(o);return ta(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),Ps(e,t,{leading:r,maxWait:t,trailing:i})},Un.thru=ps,Un.toArray=fa,Un.toPairs=Ua,Un.toPairsIn=Da,Un.toPath=function(e){return Vs(e)?St(e,Mo):ca(e)?[e]:Ai(Bo(ba(e)))},Un.toPlainObject=va,Un.transform=function(e,t,n){var r=Vs(e),i=r||Xs(e)||ua(e);if(t=so(t,4),null==n){var o=e&&e.constructor;n=i?r?new o:[]:ta(e)&&Ks(o)?Dn(Ye(e)):{}}return(i?bt:br)(e,(function(e,r,i){return t(n,e,r,i)})),n},Un.unary=function(e){return Ts(e,1)},Un.union=ns,Un.unionBy=rs,Un.unionWith=is,Un.uniq=function(e){return e&&e.length?li(e):[]},Un.uniqBy=function(e,t){return e&&e.length?li(e,so(t,2)):[]},Un.uniqWith=function(e,t){return t="function"==typeof t?t:i,e&&e.length?li(e,i,t):[]},Un.unset=function(e,t){return null==e||ci(e,t)},Un.unzip=os,Un.unzipWith=ss,Un.update=function(e,t,n){return null==e?e:ui(e,t,mi(n))},Un.updateWith=function(e,t,n,r){return r="function"==typeof r?r:i,null==e?e:ui(e,t,mi(n),r)},Un.values=Fa,Un.valuesIn=function(e){return null==e?[]:jt(e,Oa(e))},Un.without=as,Un.words=Ka,Un.wrap=function(e,t){return Ms(mi(t),e)},Un.xor=ls,Un.xorBy=cs,Un.xorWith=us,Un.zip=ds,Un.zipObject=function(e,t){return pi(e||[],t||[],er)},Un.zipObjectDeep=function(e,t){return pi(e||[],t||[],Zr)},Un.zipWith=hs,Un.entries=Ua,Un.entriesIn=Da,Un.extend=wa,Un.extendWith=Ca,ll(Un,Un),Un.add=bl,Un.attempt=Qa,Un.camelCase=qa,Un.capitalize=Ha,Un.ceil=yl,Un.clamp=function(e,t,n){return n===i&&(n=t,t=i),n!==i&&(n=(n=ga(n))==n?n:0),t!==i&&(t=(t=ga(t))==t?t:0),sr(ga(e),t,n)},Un.clone=function(e){return ar(e,4)},Un.cloneDeep=function(e){return ar(e,5)},Un.cloneDeepWith=function(e,t){return ar(e,5,t="function"==typeof t?t:i)},Un.cloneWith=function(e,t){return ar(e,4,t="function"==typeof t?t:i)},Un.conformsTo=function(e,t){return null==t||lr(e,t,Pa(t))},Un.deburr=ja,Un.defaultTo=function(e,t){return null==e||e!=e?t:e},Un.divide=wl,Un.endsWith=function(e,t,n){e=ba(e),t=ai(t);var r=e.length,o=n=n===i?r:sr(_a(n),0,r);return(n-=t.length)>=0&&e.slice(n,o)==t},Un.eq=Fs,Un.escape=function(e){return(e=ba(e))&&$.test(e)?e.replace(Y,Gt):e},Un.escapeRegExp=function(e){return(e=ba(e))&&ne.test(e)?e.replace(te,"\\$&"):e},Un.every=function(e,t,n){var r=Vs(e)?wt:fr;return n&&vo(e,t,n)&&(t=i),r(e,so(t,3))},Un.find=gs,Un.findIndex=jo,Un.findKey=function(e,t){return Rt(e,so(t,3),br)},Un.findLast=vs,Un.findLastIndex=Vo,Un.findLastKey=function(e,t){return Rt(e,so(t,3),yr)},Un.floor=Cl,Un.forEach=bs,Un.forEachRight=ys,Un.forIn=function(e,t){return null==e?e:gr(e,so(t,3),Oa)},Un.forInRight=function(e,t){return null==e?e:vr(e,so(t,3),Oa)},Un.forOwn=function(e,t){return e&&br(e,so(t,3))},Un.forOwnRight=function(e,t){return e&&yr(e,so(t,3))},Un.get=Aa,Un.gt=qs,Un.gte=Hs,Un.has=function(e,t){return null!=e&&po(e,t,kr)},Un.hasIn=Ta,Un.head=Jo,Un.identity=il,Un.includes=function(e,t,n,r){e=Js(e)?e:Fa(e),n=n&&!r?_a(n):0;var i=e.length;return n<0&&(n=gn(i+n,0)),la(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&Ot(e,t,n)>-1},Un.indexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:_a(n);return i<0&&(i=gn(r+i,0)),Ot(e,t,i)},Un.inRange=function(e,t,n){return t=pa(t),n===i?(n=t,t=0):n=pa(n),function(e,t,n){return e>=vn(t,n)&&e=-9007199254740991&&e<=d},Un.isSet=aa,Un.isString=la,Un.isSymbol=ca,Un.isTypedArray=ua,Un.isUndefined=function(e){return e===i},Un.isWeakMap=function(e){return na(e)&&fo(e)==L},Un.isWeakSet=function(e){return na(e)&&"[object WeakSet]"==Er(e)},Un.join=function(e,t){return null==e?"":_n.call(e,t)},Un.kebabCase=Va,Un.last=Zo,Un.lastIndexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var o=r;return n!==i&&(o=(o=_a(n))<0?gn(r+o,0):vn(o,r-1)),t==t?function(e,t,n){for(var r=n+1;r--;)if(e[r]===t)return r;return r}(e,t,o):Pt(e,zt,o,!0)},Un.lowerCase=Ya,Un.lowerFirst=Ja,Un.lt=da,Un.lte=ha,Un.max=function(e){return e&&e.length?pr(e,il,Sr):i},Un.maxBy=function(e,t){return e&&e.length?pr(e,so(t,2),Sr):i},Un.mean=function(e){return It(e,il)},Un.meanBy=function(e,t){return It(e,so(t,2))},Un.min=function(e){return e&&e.length?pr(e,il,Ir):i},Un.minBy=function(e,t){return e&&e.length?pr(e,so(t,2),Ir):i},Un.stubArray=ml,Un.stubFalse=gl,Un.stubObject=function(){return{}},Un.stubString=function(){return""},Un.stubTrue=function(){return!0},Un.multiply=xl,Un.nth=function(e,t){return e&&e.length?Fr(e,_a(t)):i},Un.noConflict=function(){return ot._===this&&(ot._=Me),this},Un.noop=cl,Un.now=As,Un.pad=function(e,t,n){e=ba(e);var r=(t=_a(t))?on(e):0;if(!t||r>=t)return e;var i=(t-r)/2;return qi(dn(i),n)+e+qi(un(i),n)},Un.padEnd=function(e,t,n){e=ba(e);var r=(t=_a(t))?on(e):0;return t&&rt){var r=e;e=t,t=r}if(n||e%1||t%1){var o=wn();return vn(e+o*(t-e+tt("1e-"+((o+"").length-1))),t)}return Yr(e,t)},Un.reduce=function(e,t,n){var r=Vs(e)?At:Ut,i=arguments.length<3;return r(e,so(t,4),n,i,dr)},Un.reduceRight=function(e,t,n){var r=Vs(e)?Tt:Ut,i=arguments.length<3;return r(e,so(t,4),n,i,hr)},Un.repeat=function(e,t,n){return t=(n?vo(e,t,n):t===i)?1:_a(t),Jr(ba(e),t)},Un.replace=function(){var e=arguments,t=ba(e[0]);return e.length<3?t:t.replace(e[1],e[2])},Un.result=function(e,t,n){var r=-1,o=(t=gi(t,e)).length;for(o||(o=1,e=i);++rd)return[];var n=f,r=vn(e,f);t=so(t),e-=f;for(var i=Ft(r,t);++n=s)return e;var l=n-on(r);if(l<1)return r;var c=a?bi(a,0,l).join(""):e.slice(0,l);if(o===i)return c+r;if(a&&(l+=c.length-l),sa(o)){if(e.slice(l).search(o)){var u,d=c;for(o.global||(o=Se(o.source,ba(he.exec(o))+"g")),o.lastIndex=0;u=o.exec(d);)var h=u.index;c=c.slice(0,h===i?l:h)}}else if(e.indexOf(ai(o),l)!=l){var f=c.lastIndexOf(o);f>-1&&(c=c.slice(0,f))}return c+r},Un.unescape=function(e){return(e=ba(e))&&J.test(e)?e.replace(V,ln):e},Un.uniqueId=function(e){var t=++We;return ba(e)+t},Un.upperCase=Ga,Un.upperFirst=Za,Un.each=bs,Un.eachRight=ys,Un.first=Jo,ll(Un,(vl={},br(Un,(function(e,t){Oe.call(Un.prototype,t)||(vl[t]=e)})),vl),{chain:!1}),Un.VERSION="4.17.21",bt(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){Un[e].placeholder=Un})),bt(["drop","take"],(function(e,t){Hn.prototype[e]=function(n){n=n===i?1:gn(_a(n),0);var r=this.__filtered__&&!t?new Hn(this):this.clone();return r.__filtered__?r.__takeCount__=vn(n,r.__takeCount__):r.__views__.push({size:vn(n,f),type:e+(r.__dir__<0?"Right":"")}),r},Hn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),bt(["filter","map","takeWhile"],(function(e,t){var n=t+1,r=1==n||3==n;Hn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:so(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}})),bt(["head","last"],(function(e,t){var n="take"+(t?"Right":"");Hn.prototype[e]=function(){return this[n](1).value()[0]}})),bt(["initial","tail"],(function(e,t){var n="drop"+(t?"":"Right");Hn.prototype[e]=function(){return this.__filtered__?new Hn(this):this[n](1)}})),Hn.prototype.compact=function(){return this.filter(il)},Hn.prototype.find=function(e){return this.filter(e).head()},Hn.prototype.findLast=function(e){return this.reverse().find(e)},Hn.prototype.invokeMap=$r((function(e,t){return"function"==typeof e?new Hn(this):this.map((function(n){return Nr(n,e,t)}))})),Hn.prototype.reject=function(e){return this.filter(Is(so(e)))},Hn.prototype.slice=function(e,t){e=_a(e);var n=this;return n.__filtered__&&(e>0||t<0)?new Hn(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==i&&(n=(t=_a(t))<0?n.dropRight(-t):n.take(t-e)),n)},Hn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Hn.prototype.toArray=function(){return this.take(f)},br(Hn.prototype,(function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),o=Un[r?"take"+("last"==t?"Right":""):t],s=r||/^find/.test(t);o&&(Un.prototype[t]=function(){var t=this.__wrapped__,a=r?[1]:arguments,l=t instanceof Hn,c=a[0],u=l||Vs(t),d=function(e){var t=o.apply(Un,kt([e],a));return r&&h?t[0]:t};u&&n&&"function"==typeof c&&1!=c.length&&(l=u=!1);var h=this.__chain__,f=!!this.__actions__.length,p=s&&!h,_=l&&!f;if(!s&&u){t=_?t:new Hn(this);var m=e.apply(t,a);return m.__actions__.push({func:ps,args:[d],thisArg:i}),new qn(m,h)}return p&&_?e.apply(this,a):(m=this.thru(d),p?r?m.value()[0]:m.value():m)})})),bt(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Te[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);Un.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply(Vs(i)?i:[],e)}return this[n]((function(n){return t.apply(Vs(n)?n:[],e)}))}})),br(Hn.prototype,(function(e,t){var n=Un[t];if(n){var r=n.name+"";Oe.call(Ln,r)||(Ln[r]=[]),Ln[r].push({name:t,func:n})}})),Ln[Mi(i,2).name]=[{name:"wrapper",func:i}],Hn.prototype.clone=function(){var e=new Hn(this.__wrapped__);return e.__actions__=Ai(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Ai(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Ai(this.__views__),e},Hn.prototype.reverse=function(){if(this.__filtered__){var e=new Hn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Hn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=Vs(e),r=t<0,i=n?e.length:0,o=function(e,t,n){for(var r=-1,i=n.length;++r=this.__values__.length;return{done:e,value:e?i:this.__values__[this.__index__++]}},Un.prototype.plant=function(e){for(var t,n=this;n instanceof Fn;){var r=Do(n);r.__index__=0,r.__values__=i,t?o.__wrapped__=r:t=r;var o=r;n=n.__wrapped__}return o.__wrapped__=e,t},Un.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof Hn){var t=e;return this.__actions__.length&&(t=new Hn(this)),(t=t.reverse()).__actions__.push({func:ps,args:[ts],thisArg:i}),new qn(t,this.__chain__)}return this.thru(ts)},Un.prototype.toJSON=Un.prototype.valueOf=Un.prototype.value=function(){return hi(this.__wrapped__,this.__actions__)},Un.prototype.first=Un.prototype.head,st&&(Un.prototype[st]=function(){return this}),Un}();ot._=cn,(r=function(){return cn}.call(t,n,t,e))===i||(e.exports=r)}.call(this)},752:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{l(r.next(e))}catch(e){o(e)}}function a(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=i(n(733)),s=n(249),a=n(96),l=n(288),c=n(208),u=n(467),d=n(391),h=n(544),f=n(980),p=n(66),_=n(774),m=n(964),g=n(320),v=n(717),b=n(542),y=n(452),w=n(385),C=n(580);function x(e,t){return r(this,void 0,void 0,(function*(){if(new Int8Array(e,0,1)[0]==="P".charCodeAt(0)){const n=new o.default;return(yield n.loadAsync(e)).file(t)[0].async("string")}return(new TextDecoder).decode(e)}))}let E=null;function S(e){$("#errorText").html(e),$("#errorDialog").modal("show")}$("#roster-file").on("change",(function(e){const t="resize"===(null==e?void 0:e.type)?null==E?void 0:E.target:null==e?void 0:e.target;if($("#roster-title").empty(),$("#roster-lists").empty(),$("#force-units").empty(),!(null==t?void 0:t.files))return;const n=null==t?void 0:t.files[0];"resize"!==(null==e?void 0:e.type)&&(E=e),n.arrayBuffer().then((e=>r(this,void 0,void 0,(function*(){n.name.match(/\.rosz?$/)?function(e){const t=(new DOMParser).parseFromString(e,"text/xml");if(!t)return;const n=t.querySelector("roster");if(!n)return;const r=n.getAttribute("gameSystemName");if(!r)return;const i=n.getAttribute("name");i&&(document.title=`PrettyScribe ${i}`);const o=$("#roster-title")[0],C=$("#roster-lists")[0],x=$("#force-units")[0];if("Warhammer 40,000 8th Edition"==r){const e=(0,l.Create40kRoster)(t);e&&e._forces.length>0&&new u.Renderer40k(e).render(o,C,x)}else if("Warhammer 40,000 9th Edition"==r){const e=(0,l.Create40kRoster)(t);e&&e._forces.length>0&&new u.Renderer40k(e).render(o,C,x)}else if("Warhammer 40,000: Kill Team (2018)"==r){const e=(0,l.Create40kRoster)(t,!1);e&&e._forces.length>0&&new u.Renderer40k(e).render(o,C,x)}else if("Warhammer 40,000: Kill Team (2021)"==r){const e=(0,s.CreateKT21Roster)(t);e&&e._forces.length>0&&new a.RendererKT21(e).render(o,C,x)}else if("Age of Sigmar"==r){const e=(0,_.CreateAoSRoster)(t);e&&new m.RendererAoS(e).render(o,C,x)}else if("Warhammer Age of Sigmar: Warcry"==r){const e=(0,g.CreateWarcryRoster)(t);e&&new v.RendererWarcry(e).render(o,C,x)}else if("Warhammer 30,000 - The Horus Heresy"==r){const e=(0,d.Create30kRoster)(t);e&&e._forces.length>0&&new h.Renderer30k(e).render(o,C,x)}else if(r.includes("Horus Heresy (2022)")){const e=f.HorusHeresy.CreateRoster(t);e&&e._forces.length>0&&new p.RendererHH2(e).render(o,C,x)}else if("Warhammer 40,000 10th Edition"==r){const e=c.Wh40k.CreateRoster(t);window.roster=e,e&&e._forces.length>0&&new b.Wh40kRenderer(e).render(o,C,x)}else if("Middle-Earth Strategy Battle Game"===r){const e=(0,y.CreateMESBGRoster)(t);null!==e&&(console.log(e),(0,w.renderMESBG)(e,o,C,x))}else S("PrettyScribe does not support game type '"+r+"'.")}(yield x(e,/[^/]+\.ros$/)):n.name.match(/\.regi[sz]try$/)?function(e){const t=JSON.parse(e);window.registry=t;const n=$("#roster-title")[0],r=$("#roster-lists")[0],i=$("#force-units")[0],o=t.info.game;if("Warhammer 40k"===o){const e=(0,C.Create40kRosterFromRegistry)(t);window.roster=e,new b.Wh40kRenderer(e).render(n,r,i)}else S("PrettyScribe does not support game type '"+o+"'.")}(yield x(e,/[^/]+\.registry$/)):S(`PrettyScribe does not support extension of ${n.name}.`)})))).catch((e=>{S(`Error opening ${n.name}: ${e}`),console.error(e)}))})),document.addEventListener("DOMContentLoaded",(()=>{if(navigator.userAgent.match(/AppleWebKit.*Safari/)&&!navigator.userAgent.includes("Chrome")){const e=document.querySelector('input[type="file"');null==e||e.removeAttribute("accept")}}))},361:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toggleHidden=t.addHideAble=void 0,t.addHideAble=function(e){return e.classList.add("hide_able"),e},t.toggleHidden=function(e){var t,n,r;if(!e.target)return;const i=e.target;null===(t=i.closest(".hide_able"))||void 0===t||t.classList.toggle("hidden"),null===(r=null===(n=i.closest(".unit_header"))||void 0===n?void 0:n.closest(".wh40k_unit_sheet"))||void 0===r||r.classList.toggle("hidden")}},77:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PsJsx=void 0,function(e){function t(e,n){if(null!=n)if(Array.isArray(n))for(const r of n)t(e,r);else"string"==typeof n?e.appendChild(document.createTextNode(n)):n instanceof Node?e.appendChild(n):"boolean"==typeof n||e.appendChild(document.createTextNode(String(n)))}e.createFragment=function(){return document.createDocumentFragment()},e.createElement=function(e,n,...r){const i="function"==typeof e?e():document.createElement(e);if(n)for(const e of Object.keys(n)){const t=n[e];if("boolean"==typeof t)i.setAttribute(e,"");else if("function"==typeof t)if("ref"===e)t(i);else{if(!e.startsWith("on"))throw new Error("Unexpected function attribute");i.addEventListener(e.substring(2),t)}else"className"===e?i.setAttribute("class",t):i.setAttribute(e,t)}for(const e of r)t(i,e);return i}}(t.PsJsx||(t.PsJsx={}))},219:(e,t)=>{"use strict";function n(e,t){try{window.localStorage[e]=t}catch(e){}}Object.defineProperty(t,"__esModule",{value:!0}),t.loadOptionsFromLocalStorage=t.saveOptionToLocalStorage=t.renderCheckboxOption=t.renderOptionsToggle=void 0,t.renderOptionsToggle=function(e){e.classList.add("wh40k_options_toggle"),e.id="wh40k_options_toggle";const t="[−] Options:";e.appendChild(document.createTextNode(t)),e.addEventListener("click",(e=>{const r=document.getElementById("wh40k_options_div"),i=document.getElementById("wh40k_options_toggle");r&&i&&(r.classList.contains("hide_options")?(r.classList.remove("hide_options"),i.innerText=t,n("option-toggle-hidden","false")):(r.classList.add("hide_options"),i.innerText="[+] Options",n("option-toggle-hidden","true")))}))},t.renderCheckboxOption=function(e,t,r,i,o=!1){const s=e.appendChild(document.createElement("div"));s.classList.add("wh40k_option");const a=s.appendChild(document.createElement("input"));a.setAttribute("type","checkbox"),a.setAttribute("name",t),a.setAttribute("id",t),o&&(a.checked=!0),a.addEventListener("input",i),a.addEventListener("change",(e=>function(e){const t=document.getElementById(e);t&&n(`option-checkbox-${e}`,t.checked)}(t)));const l=s.appendChild(document.createElement("label"));l.setAttribute("for",t),l.appendChild(document.createTextNode(` ${r}`))},t.saveOptionToLocalStorage=n,t.loadOptionsFromLocalStorage=function(){var e;try{for(let t=0;t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createNotesHead=t.createNoteHead=t.createTableRow=void 0;const r=n(361);function i(e,t,n=!1){const i=(0,r.addHideAble)(document.createElement("tr"));n&&i.classList.add("header_row");for(let r=0,o=0;re._customNotes)))return null;const n=document.createElement("thead");n.classList.add("info_row");const r=document.createElement("div");for(const e of t){if(!e.notes())continue;const t=r.appendChild(document.createElement("div"));t.appendChild(document.createElement("b")).appendChild(document.createTextNode(`${e.name()}: `)),t.appendChild(document.createTextNode(e._customNotes))}return n.appendChild(i([e,r],[.1,.9],!1)),n}},580:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateRoster=t.Create40kRosterFromRegistry=void 0;const r=n(208),i=n(596);function o(e){const t=new r.Wh40k.Roster40k,n=new r.Wh40k.Force;t._name=e.name,n._name=e.info.name,function(e,t){const n=e.assets.traits.filter((e=>"Detachment"===e.classification))[0];n&&(t._faction=n.designation,t._rules.set(n.designation,n.text))}(e,n);for(const r of[...e.assets.included,...e.assets.traits]){if("Unit"!=r.classIdentity)continue;const e=s(r);n._units.push(e),t._cost.add(e._cost);for(const t of[...e._rules.entries(),...e._weaponRules.entries()])n._rules.set(t[0],t[1])}return n._rules=new Map([...n._rules.entries()].sort()),t._forces.push(n),t}function s(e){var t,n;const i=new r.Wh40k.Unit;return i._name=e.designation,function(e,t){var n,r,i;const o=(null===(r=null===(n=e.rules.finalModelTally)||void 0===n?void 0:n.evals[1])||void 0===r?void 0:r.result.integer)||(null===(i=e.stats.Models)||void 0===i?void 0:i.value);e.stats.model3rdTally.value&&o>e.stats.model3rdTally.value?t._cost._points=e.stats.model4thCost.value:e.stats.model2ndTally.value&&o>e.stats.model2ndTally.value?t._cost._points=e.stats.model3rdCost.value:e.stats.model1stTally.value&&o>e.stats.model1stTally.value?t._cost._points=e.stats.model2ndCost.value:e.stats.Points&&(t._cost._points=e.stats.Points.value),function e(n){var r;for(const i of[...n.assets.included,...n.assets.traits])(null===(r=i.stats.Points)||void 0===r?void 0:r.value)&&(t._cost._points+=i.stats.Points.value),e(i)}(e)}(e,i),null===(t=e.keywords.Faction)||void 0===t||t.sort().forEach((e=>i._factions.add(e))),null===(n=e.keywords.Keywords)||void 0===n||n.sort().forEach((e=>i._keywords.add(e))),function(e,t){const n=[...e.assets.traits,...e.assets.included].filter((e=>"Model"===e.classification));0===n.length?n.push(e):d({designation:"Unit Upgrades",assets:e.assets,quantity:1},t,!1);for(const e of n)u(e,t),d(e,t)}(e,i),a(e,i),i.normalize(),i}function a(e,t){for(const n of[...e.assets.traits,...e.assets.included]){const e=n.classification;if("Wargear"===e||"Enhancement"===e)t._abilities[e]||(t._abilities[e]=new Map),t._abilities[e].set(n.designation,n.text);else if("Ability"===e)if("Leader"===n.designation){const e=n.text.indexOf("This model can be attached"),r=n.text.substring(0,e).trim();r&&t._rules.set(n.designation,r);const i=n.text.substring(e);t._abilities.Abilities||(t._abilities.Abilities=new Map),t._abilities.Abilities.set(n.designation,i)}else!n.tally.Core&&!n.tally.Faction||n.designation.startsWith("Damaged:")?(t._abilities.Abilities||(t._abilities.Abilities=new Map),t._abilities.Abilities.set(n.designation,n.text)):t._rules.set(n.designation,n.text);else if("Model"===e)a(n,t);else if("Ranged Weapon"===e||"Melee Weapon"===e||"Weapon"===e){l(n,t);const e=n.assets.traits.filter((e=>e.classification.endsWith("Weapon")));for(const r of e)l(r,t,n.designation)}else console.error(`Unexepcted classification '${e}': ${n.designation}`)}}function l(e,t,n){const i=`${e.classification}s`,o=c(e,i);if(n&&(o[Object.keys(o)[0]]=`${n} - ${o[Object.keys(o)[0]]}`),Object.keys(o).length<=1)return;const s=e.assets.traits.filter((e=>"Ability"===e.classification));if(s.length>0){s.forEach((e=>t._weaponRules.set(e.designation,e.text)));const e=s.map((e=>e.designation));Object.assign(o,{Keywords:e.join(", ")})}t._profileTables[i]||(t._profileTables[i]=new r.Wh40k.TabularProfile),t._profileTables[i].addRow(o)}function c(e,t,n){const r=(0,i.filterAndOrderStats)(e.stats);return Object.assign({[t]:e.designation},Object.fromEntries(r.map((e=>[e[0],(0,i.formatStat)(e[1])]))))}function u(e,t){const n=c(e,"Unit");Object.keys(n).length>1&&(t._profileTables.Unit||(t._profileTables.Unit=new r.Wh40k.TabularProfile),t._profileTables.Unit.addRow(Object.assign({Unit:e.designation},n)))}function d(e,t,n=!0){var i;const o=new r.Wh40k.Model;o._name=e.designation,o._count=e.quantity;const s=[...e.assets.traits,...e.assets.included].filter((e=>"Wargear"===e.classification||"Weapon"===e.classification||"Ranged Weapon"===e.classification||"Melee Weapon"===e.classification||"Enhancement"===e.classification));for(const e of s){const t=new r.Wh40k.Upgrade;t._name=e.designation;const n=null===(i=e.stats.Points)||void 0===i?void 0:i.value;n&&(t._cost._points=n),o._upgrades.push(t)}(n||s.length>0)&&t._models.push(o)}t.Create40kRosterFromRegistry=function(e){return o(e)},t.CreateRoster=o},419:(e,t)=>{"use strict";var n,r;function i(e,t,i,o,s,a,l,c){if(e&&t.length){e.textBaseline="top";let u=e.measureText(t);const d=u.width,h=u.actualBoundingBoxDescent-u.actualBoundingBoxAscent;let f=o;c==r.Top?f=o:c==r.Bottom?f=o+a-h:c==r.Center&&(f=o+(a-h)/2),l==n.Center?e.fillText(t,i+Math.max((s-d)/2,0),f,s):l==n.Left?e.fillText(t,i,f,s):l==n.Right&&e.fillText(t,i+s-d,f,s)}}Object.defineProperty(t,"__esModule",{value:!0}),t.FixDPI=t.RenderParagraph=t.RenderText=t.RenderTextFull=t.VertAlign=t.Justification=void 0,function(e){e[e.Left=0]="Left",e[e.Right=1]="Right",e[e.Center=2]="Center"}(n=t.Justification||(t.Justification={})),function(e){e[e.Top=0]="Top",e[e.Bottom=1]="Bottom",e[e.Center=2]="Center"}(r=t.VertAlign||(t.VertAlign={})),t.RenderTextFull=i,t.RenderText=function(e,t,n,o,s,a,l){i(e,t,n,o,s,a,l,r.Center)},t.RenderParagraph=function(e,t,n,r,i,o){let s=r;if(e&&t.length){let r=[],a=[];e.textBaseline="top";let l=0;const c=e.measureText(" ").width,u=e.measureText(t),d=1.2*(u.actualBoundingBoxDescent-u.actualBoundingBoxAscent);let h=i-o;t.split(" ").forEach((function(t){const n=e.measureText(t);l+n.width>h&&(r.push(a.join(" ")),h=i,a.length=0,l=0),l+=n.width+c,a.push(t)})),a.length>0&&r.push(a.join(" "));let f=n+o;for(let t of r)e.fillText(t,f,s),f=n,s+=d}return s},t.FixDPI=function(e){let t=window.devicePixelRatio,n=+getComputedStyle(e).getPropertyValue("height").slice(0,-2),r=+getComputedStyle(e).getPropertyValue("width").slice(0,-2);0==n&&(n=e.height),0==r&&(r=e.width),e.setAttribute("height",(n*t).toString()),e.setAttribute("width",(r*t).toString())}},544:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Renderer30k=void 0;const r=n(391),i=n(419);class o{constructor(e){this._descriptionStartX=190,this._descriptionWidth=600,this._showWoundBoxes=!1,this._roster=null,this._currentX=0,this._currentY=0,this._maxWidth=0,this._octagon=null,this._roles=new Map,this._unitLabelWidthsNormalized=[.3,.077,.077,.077,.077,.077,.077,.077,.077,.077],this._vehicleLabelWidthsNormalized=[.3,.1,.1,.1,.1,.1,.2],this._walkerLabelWidthsNormalized=[.3,.06,.06,.06,.06,.06,.06,.06,.06,.06,.15],this._flyerLabelWidthsNormalized=[.3,.077,.077,.077,.077,.077,.077,.077,.077,.077],this._weaponLabelWidthNormalized=[.3,.1,.1,.1,.4],this._spellLabelWidthNormalized=[.3,.1,.1,.5],this._roster=e,this._octagon=document.getElementById("octagon"),this._roles.set(r.UnitRole30k.HQ,document.getElementById("role_hq")),this._roles.set(r.UnitRole30k.TR,document.getElementById("role_tr")),this._roles.set(r.UnitRole30k.EL,document.getElementById("role_el")),this._roles.set(r.UnitRole30k.FA,document.getElementById("role_fa")),this._roles.set(r.UnitRole30k.HS,document.getElementById("role_hs")),this._roles.set(r.UnitRole30k.FL,document.getElementById("role_fl")),this._roles.set(r.UnitRole30k.DT,document.getElementById("role_dt")),this._roles.set(r.UnitRole30k.FT,document.getElementById("role_ft")),this._roles.set(r.UnitRole30k.LW,document.getElementById("role_lw"))}render(e,t,n){if(null!=this._roster){e&&(e.innerHTML="

"+this._roster._name+" ("+this._roster._points+" pts)

");for(let e of this._roster._forces){const s=document.createElement("div");s&&(s.innerHTML="

"+e._catalog+" "+e._name+"

"),t&&t.appendChild(s);const a=document.createElement("table");a.classList.add("table"),a.classList.add("table-sm"),a.classList.add("table-striped");const l=document.createElement("thead");a.appendChild(l),l.classList.add("thead-light");const c=document.createElement("tr");l.appendChild(c),[{name:"NAME",w:"25%"},{name:"ROLE",w:"20%"},{name:"MODELS",w:"40%"},{name:"POINTS",w:"15%"}].forEach((e=>{let t=document.createElement("th");t.scope="col",t.innerHTML=e.name,t.style.width=e.w,c.appendChild(t)})),s.appendChild(a);let u=document.createElement("tbody");a.appendChild(u);for(let t of e._units){let e=document.createElement("tr"),n=document.createElement("td");n.innerHTML=t._name;let i=document.createElement("td");i.innerHTML=r.UnitRoleToString30k[t._role];let o=document.createElement("td");o.innerHTML="";let s=0;for(const e of t._models)e._count>1?o.innerHTML+=e._count+" "+e._name:o.innerHTML+=e._name,s++,s!=t._models.length&&(o.innerHTML+=", ");let a=document.createElement("td");a.innerHTML=t._points.toString(),e.appendChild(n),e.appendChild(i),e.appendChild(o),e.appendChild(a),u.appendChild(e)}if(e._rules.size>0){let t=document.createElement("div"),r=document.createElement("h3");t.appendChild(r),r.textContent=e._catalog+" Allegiance Rules";for(let n of e._rules){let e=document.createElement("div"),r=document.createElement("h4");r.textContent=n[0];let i=document.createElement("p");i.textContent=n[1],e.appendChild(r),e.appendChild(i),t.appendChild(e)}n&&n.appendChild(t)}for(let t of e._units){let e=document.createElement("canvas");e.width=7.5*o._res,e.height=20*o._res,this._descriptionWidth=e.width-this._descriptionStartX-10,(0,i.FixDPI)(e);const r=this.renderUnit(t,e,0,0),s=25;let a=document.createElement("canvas");a.width=r[0]+2*s,a.height=r[1]+2*s;let l=a.getContext("2d");if(null==l||l.drawImage(e,s,s),n){let e=document.createElement("div");e.appendChild(a),n.appendChild(e)}}}}}renderBorder(e,t,n,r,i){e.strokeStyle=o._blackColor,e.beginPath(),e.moveTo(t,n+o._bevelSize),e.lineTo(t,n+i-o._bevelSize),e.lineTo(t+o._bevelSize,n+i),e.lineTo(t+r-o._bevelSize,n+i),e.lineTo(t+r,n+i-o._bevelSize),e.lineTo(t+r,n+o._bevelSize),e.lineTo(t+r-o._bevelSize,n),e.lineTo(t+o._bevelSize,n),e.closePath(),e.stroke(),e.save(),e.fillStyle=o._fillColor,e.globalCompositeOperation="destination-over",e.beginPath(),e.moveTo(t,n+o._bevelSize),e.lineTo(t,n+i-o._bevelSize),e.lineTo(t+o._bevelSize,n+i),e.lineTo(t+r-o._bevelSize,n+i),e.lineTo(t+r,n+i-o._bevelSize),e.lineTo(t+r,n+o._bevelSize),e.lineTo(t+r-o._bevelSize,n),e.lineTo(t+o._bevelSize,n),e.closePath(),e.fill(),e.restore()}renderWatermark(e){}renderLine(e){e.lineWidth=2,e.strokeStyle=o._blackColor,e.beginPath(),e.moveTo(this._currentX,this._currentY),e.lineTo(this._currentX+this._maxWidth,this._currentY),e.stroke(),this._currentY+=1}renderTableHeader(e,t,n){let r=this._currentX;const s=this._maxWidth;e.fillStyle=o._grey1,e.fillRect(this._currentX,this._currentY,s,22),e.fillStyle=o._blackColor,e.font=o._titleFont;var a=50;if(t){e.font=o._headerFont;for(let o=0;o1?n+=e._count+" "+e._name:n+=e._name,r++,r!=t.length&&(n+=", ");this._currentY+=2,this._currentY=(0,i.RenderParagraph)(e,n,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth,0),this._currentY+=2}renderWoundBoxes(e,t){e.font=o._titleFont,(0,i.RenderText)(e,"WOUNDS",this._currentX+20,this._currentY,100,16,i.Justification.Left);const n=this._currentX+this._descriptionStartX,r=n+195;e.save();for(let s of t)if(s._wounds>1){let t=this._currentY;e.font=o._font,e.fillStyle=o._blackColor,this._currentY=(0,i.RenderParagraph)(e,s._name,n,this._currentY+3,195,0);let a=this._currentX+r;e.strokeStyle=o._blackColor,e.fillStyle="#ffffff";for(let n=0;n{u.push(e*this._maxWidth)}));const d=[];this._vehicleLabelWidthsNormalized.forEach((e=>{d.push(e*this._maxWidth)}));const h=[];this._walkerLabelWidthsNormalized.forEach((e=>{h.push(e*this._maxWidth)}));const f=[];for(var p of(this._flyerLabelWidthsNormalized.forEach((e=>{f.push(e*this._maxWidth)})),e._models)){c.push(p);for(let e of p._weapons)s.push(e);for(let e of p._psychicPowers)a.push(e);p._psyker&&l.push(p._psyker)}const _=[],m=new Map;for(const e of c)m.has(e._name)||(m.set(e._name,e),_.push(e));if(_.length>0){this.renderTableHeader(i,o._unitLabels,u);let e=0;for(var p of _)this.renderModel(i,p,u,e%2),e++}if(e._vehicles.length>0){this.renderTableHeader(i,o._vehicleLabels,d);let t=0;for(var g of e._vehicles)this.renderVehicle(i,g,d,t%2),t++}if(e._walkers.length>0){this.renderTableHeader(i,o._walkerLabels,h);let t=0;for(var v of e._walkers)this.renderWalker(i,v,h,t%2),t++}if(e._flyers.length>0){this.renderTableHeader(i,o._flyerLabels,f);let t=0;for(var b of e._flyers)this.renderFlyer(i,b,f,t%2),t++}const y=[],w=new Map;for(const e of s)w.has(e._name)||(w.set(e._name,e),y.push(e));if(y.length>0){const e=[];this._weaponLabelWidthNormalized.forEach((t=>{e.push(t*this._maxWidth)})),this.renderLine(i),this.renderTableHeader(i,o._weaponLabels,e),this.renderWeapons(i,y,e)}if(a.length>0){const e=[];this._spellLabelWidthNormalized.forEach((t=>{e.push(t*this._maxWidth)})),this.renderLine(i),this.renderTableHeader(i,o._spellLabels,e),this.renderPowers(i,a,e)}if(e._abilities.size>0&&(this.renderLine(i),this._currentY+=2,this.renderAbilities(i,e)),l.length>0&&(this.renderLine(i),this._currentY+=2,this.renderPsykers(i,l)),e._rules.size>0&&(this.renderLine(i),this._currentY+=2,this.renderRules(i,e)),e._factions.size>0&&(this.renderLine(i),this._currentY+=2,this.renderFactions(i,e)),e._keywords.size>0&&(this.renderLine(i),this._currentY+=2,this.renderKeywords(i,e)),e._models.length>0&&(this.renderLine(i),this._currentY+=2,this.renderModelList(i,_)),this._showWoundBoxes){let t=!1;for(let n of e._models)n._wounds>2&&(t=!0);t&&(this.renderLine(i),this._currentY+=5,this.renderWoundBoxes(i,e._models))}this._currentY+=2;const C=this._currentY-(r+o._margin),x=this._maxWidth;return this.renderBorder(i,this._currentX,r+o._margin,x,C),this.renderWatermark(i),[this._maxWidth,this._currentY]}renderHeader(e,t){t.globalAlpha=1,t.fillStyle=o._blackColor;const n=this._currentX,r=this._currentX+this._maxWidth,s=this._currentY,a=s+36;t.beginPath(),t.moveTo(n,s+o._bevelSize),t.lineTo(n,a),t.lineTo(r,a),t.lineTo(r,s+o._bevelSize),t.lineTo(r-o._bevelSize,s),t.lineTo(n+o._bevelSize,s),t.closePath(),t.fill();let l=n+6;if(this._octagon){t.drawImage(this._octagon,l,s+2,32,32);const n=this._roles.get(e._role);n&&t.drawImage(n,l+4,s+2+4,24,24),t.fillStyle="white",t.font="18px serif",l+=34,t.drawImage(this._octagon,l,s+2,32,32),(0,i.RenderText)(t,e._points.toString(),l,s+2,32,32,i.Justification.Center)}let c=0,u=28;const d=l+6;t.font=u+"px bold serif";const h=e._name.toLocaleUpperCase();let f=t.measureText(h);const p=this._maxWidth-d;for(;c<6&&f.width>p;)c+=1,u-=2,t.font=u+"px bold serif",f=t.measureText(h);t.fillStyle="white",t.textBaseline="top",(0,i.RenderText)(t,h,d,s,p,36,i.Justification.Center),this._currentY+=36}renderPsykers(e,t){e.font=o._titleFont,(0,i.RenderText)(e,"PSYKERS",this._currentX+20,this._currentY,100,16,i.Justification.Left),e.font=o._font,this._currentY+=2;for(let n of t)this._currentY=(0,i.RenderParagraph)(e,"MASTERY LEVEL: "+n._masteryLevel,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth,0),this._currentY+=2,this._currentY=(0,i.RenderParagraph)(e,"DISCIPLINES: "+n._disciplines,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth,0),this._currentY+=2}}t.Renderer30k=o,o._res=144,o._margin=0,o._bevelSize=15,o._blackColor="#1d272a",o._grey1="#b3bbb5",o._greyLight="#dde1df",o._fillColor="#f6f6f6",o._titleFont="bold 14px sans-serif",o._headerFont="bold 14px sans-serif",o._font="14px sans-serif",o._boldFont="bold 14px sans-serif",o._unitLabels=["MODEL","WS","BS","S","T","W","I","A","LD","SAVE"],o._vehicleLabels=["MODEL","BS","FRONT","SIDE","REAR","HP","TYPE"],o._walkerLabels=["MODEL","WS","BS","S","FRONT","SIDE","REAR","I","A","HP","TYPE"],o._flyerLabels=["MODEL","BS","FRONT","SIDE","REAR","HP","TYPE","ROLE","PURSUIT","AGILITY"],o._weaponLabels=["WEAPONS","RANGE","S","AP","TYPE"],o._spellLabels=["PSYCHIC POWER","WARP CHARGE","RANGE","DETAILS"]},467:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Renderer40k=void 0;const r=n(288),i=n(682),o=n(361),s=n(219);class a{constructor(e){this._roster=null,this._roles=new Map,this._unitLabelWidthsNormalized=[.25,.05,.05,.05,.05,.05,.05,.05,.05,.05],this._weaponLabelWidthNormalized=[.25,.05,.1,.05,.05,.05,.45],this._spellLabelWidthNormalized=[.25,.05,.1,.6],this._explosionLabelWidthNormalized=[.2,.1,.1,.15],this._trackerLabelWidth=[.2,.15,.1,.1,.1],this._roster=e,this._roles.set(r.UnitRole.HQ,document.getElementById("role_hq")),this._roles.set(r.UnitRole.TR,document.getElementById("role_tr")),this._roles.set(r.UnitRole.EL,document.getElementById("role_el")),this._roles.set(r.UnitRole.FA,document.getElementById("role_fa")),this._roles.set(r.UnitRole.HS,document.getElementById("role_hs")),this._roles.set(r.UnitRole.FL,document.getElementById("role_fl")),this._roles.set(r.UnitRole.DT,document.getElementById("role_dt")),this._roles.set(r.UnitRole.FT,document.getElementById("role_ft")),this._roles.set(r.UnitRole.LW,document.getElementById("role_lw"))}render(e,t,n){if(null!=this._roster){if(e){this.renderOptionsDiv(e);const t=[`${this._roster._cost._points} pts`,`${this._roster._cost._powerLevel} PL`,`${this._roster._cost._commandPoints} CP`];for(const e in this._roster._cost._freeformValues)t.push(`${this._roster._cost._freeformValues[e]}${e}`);const n=`${this._roster.name()} (${t.join(", ")})`;e.appendChild(document.createElement("h3")).appendChild(document.createTextNode(n));const r=e.appendChild(document.createElement("div"));r.classList.add("footer"),r.appendChild(document.createElement("div")).appendChild(document.createTextNode("PrettyScribe")),r.appendChild(document.createElement("div")).appendChild(document.createTextNode(n)),this._roster._customNotes&&e.appendChild(document.createElement("p")).appendChild(document.createTextNode(this._roster._customNotes))}t&&(this.renderRosterSummary(t),this.renderAbilitiesByPhase(t)),n&&this.renderRosterDetails(n),(0,s.loadOptionsFromLocalStorage)()}}renderRosterSummary(e){if(!this._roster)return;const t=this._roster._forces.some((e=>e._units.some((e=>0!==e._cost._commandPoints))));for(const n of this._roster._forces){const i=document.createElement("div");if(n._faction?i.appendChild(document.createTextNode(`${n._catalog} ${n.name()} (${n._faction})`)):i.appendChild(document.createTextNode(`${n._catalog} ${n.name()}`)),n._configurations.length>0){const e=i.appendChild(document.createElement("ul"));for(const t of n._configurations)e.appendChild(document.createElement("li")).appendChild(document.createElement("i")).appendChild(document.createTextNode(t))}e.appendChild(i);const o=document.createElement("table");o.classList.add("table","table-sm","table-striped");const s=document.createElement("thead");o.appendChild(s),s.classList.add("thead-light");const a=document.createElement("tr");s.appendChild(a);const l=[{name:"NAME",w:"20%"},{name:"ROLE",w:"15%"},{name:"MODELS",w:"55%"},{name:"POINTS",w:"5%"},{name:"POWER",w:"5%"}];t&&l.push({name:"CP",w:"5%"}),l.forEach((e=>{let t=document.createElement("th");t.scope="col",t.appendChild(document.createTextNode(e.name)),t.style.width=e.w,a.appendChild(t)})),i.appendChild(o);let c=document.createElement("tbody");o.appendChild(c);for(let e of n._units){const n=document.createElement("tr");n.appendChild(document.createElement("td")).appendChild(document.createTextNode(e.nameWithExtraCosts())),n.appendChild(document.createElement("td")).appendChild(document.createTextNode(r.UnitRoleToString[e._role]));const i=n.appendChild(document.createElement("td"));if(this.renderModelList(i,e),n.appendChild(document.createElement("td")).appendChild(document.createTextNode(e._cost._points.toString())),n.appendChild(document.createElement("td")).appendChild(document.createTextNode(e._cost._powerLevel.toString())),t){const t=(e._cost._commandPoints||"")+"";n.appendChild(document.createElement("td")).appendChild(document.createTextNode(t))}c.appendChild(n)}}}renderOptionsDiv(e){const t=e.appendChild(document.createElement("div"));t.classList.add("wh40k_options_div","d-print-none"),t.id="wh40k_options_div";const n=t.appendChild(document.createElement("span"));(0,s.renderOptionsToggle)(n),(0,s.renderCheckboxOption)(t,"showPhaseAbilities","Show abilities by phase",(e=>{const t=document.getElementById("wh40k_abilities_list");t&&(e.target.checked?t.classList.remove("d-none"):t.classList.add("d-none"))})),(0,s.renderCheckboxOption)(t,"showUpgradeCosts","Show upgrade costs",(e=>{const t=document.getElementsByClassName("wh40k_upgrade_cost");for(const n of t)e.target.checked?n.classList.remove("d-none"):n.classList.add("d-none")})),(0,s.renderCheckboxOption)(t,"collateDatasheets","Collate Detachment Datasheets",(e=>{const t=document.getElementById("collated_sheets"),n=document.getElementById("detachment_sheets");t&&n&&(e.target.checked?(t.classList.remove("d-none"),n.classList.add("d-none")):(t.classList.add("d-none"),n.classList.remove("d-none")))}));const r=t.appendChild(document.createElement("span"));r.classList.add("wh40k_options_print_subsection"),r.appendChild(document.createTextNode("Print:")),(0,s.renderCheckboxOption)(r,"printBigger","Larger Text",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("bigger"):n.classList.remove("bigger")})),(0,s.renderCheckboxOption)(r,"hideElements","Hide Elements",(e=>{const t=document.body;e.target.checked?(t.classList.add("hide_enabled"),t.addEventListener("click",o.toggleHidden)):(t.classList.remove("hide_enabled"),t.removeEventListener("click",o.toggleHidden))})),(0,s.renderCheckboxOption)(r,"datasheetPageBreaks","One Datasheet per Page",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("page_break"):n.classList.remove("page_break")}))}renderAbilitiesByPhase(e){if(!this._roster)return;const t={},n={};for(const e of this._roster._forces)for(const r of e._units)for(const e of Object.values(r._abilities))for(const[i,s]of e.entries()){const e=[...s.matchAll(/(?:before the first turn begins|set up|Reinforcements|(?:Command|Movement|Psychic|Shooting|Charge|Fight|Morale) phase)/gi)];if(0===e.length)continue;const a=(0,o.addHideAble)(document.createElement("div"));a.appendChild(document.createElement("b")).appendChild(document.createTextNode(r.name())),a.appendChild(document.createTextNode(" - ")),a.appendChild(document.createElement("b")).appendChild(document.createTextNode(i)),a.appendChild(document.createTextNode(" - "));let l=s;for(const r of e){if(!r.index)continue;const e=r[0].toLocaleLowerCase();let o=e;switch(e){case"before the first turn begins":o="pre-game phase";break;case"set up":s.includes("reinforcements")||(o="pre-game phase");break;case"reinforcements":o="movement phase"}if(s.toLocaleLowerCase().includes("as if it were your "+o))continue;const c=r.index-(s.length-l.length);c>0&&a.appendChild(document.createTextNode(l.substring(0,c)));const u=t[o]=t[o]||[],d=n[o]=n[o]||[];d.includes(i)||(d.push(i),u.push(a)),a.appendChild(document.createElement("u")).appendChild(document.createTextNode(r[0]));const h=c+e.length;l=l.substring(h)}l.length>0&&a.appendChild(document.createTextNode(l))}const r=e.appendChild(document.createElement("div"));r.setAttribute("id","wh40k_abilities_list"),r.classList.add("d-none"),r.appendChild(document.createElement("h3")).appendChild(document.createTextNode("Abilities by Phase"));const i=["pre-game phase","command phase","movement phase","psychic phase","shooting phase","charge phase","fight phase","morale phase"].filter((e=>!!t[e]));if(0===i.length)r.appendChild(document.createTextNode("No phase-specific abilities in roster"));else for(const e of i){r.appendChild(document.createElement("h4")).appendChild(document.createTextNode(e));for(const n of t[e])r.appendChild(n.parentElement?n.cloneNode(!0):n)}}renderRosterDetails(e){if(!this._roster)return;const t=new Map,n=new Map,i=e.appendChild(document.createElement("div"));i.id="detachment_sheets";const o=e.appendChild(document.createElement("div"));o.id="collated_sheets",o.style.pageBreakBefore="always",o.classList.add("d-none");const s=[];for(const e of this._roster._forces){const r=document.createElement("div");if(r.style.pageBreakBefore="always",r){const t=document.createElement("p");t.appendChild(document.createTextNode(e._catalog)),e._faction&&t.appendChild(document.createTextNode(" ("+e._faction+")")),r.appendChild(t)}let o=document.createElement("h3");o.appendChild(r),i.appendChild(o),this.renderDatasheets(i,e._units),s.push(...e._units),l(t,e._catalog,e._rules),l(n,e._faction,e._factionRules)}s.sort(((e,t)=>e._role!=t._role?e._role-t._role:e._name!=t._name?(0,r.Compare)(e._name,t._name):e._cost._points-t._cost._points)),this.renderDatasheets(o,s);let a=document.createElement("div");a.style.pageBreakBefore="always",this.printRules(t,a),this.printRules(n,a),e.appendChild(a)}renderDatasheets(e,t){let n=0;for(let r=0;r1?` (${n})`:""),d],[.1,.8,.1]));const h=l.appendChild(document.createElement("tr"));for(let e=0;e<20;e++){const e=h.appendChild(document.createElement("td"));e.colSpan=1,e.style.width="5%",e.style.padding="0"}let f=(0,i.createNoteHead)("Unit notes",t);f&&s.appendChild(f),l=s.appendChild(document.createElement("thead")),l.classList.add("table-active"),l.appendChild((0,i.createTableRow)(a._unitLabels,this._unitLabelWidthsNormalized,!0));let p=s.appendChild(document.createElement("tbody"));p.append(document.createElement("tr"));for(const e of t._modelStats)p.append((0,i.createTableRow)([e._name,e._move,e._ws,e._bs,e._str.toString(),e._toughness.toString(),e._wounds.toString(),e._attacks.toString(),e._leadership.toString(),e._save],this._unitLabelWidthsNormalized));if(f=(0,i.createNotesHead)("Model notes",t._modelStats),f&&s.appendChild(f),t._woundTracker.length>0){const e=Array.from(a._trackerLabels);if(4==t._woundTracker.length){const n=Array.from(t._woundTracker[0]._table.values());e.splice(1,n.length,...n)}else if(3==t._woundTracker.length){const n=Array.from(t._woundTracker[0]._table.keys());e.splice(1,n.length,...n)}l=s.appendChild(document.createElement("thead")),l.classList.add("table-active"),l.appendChild((0,i.createTableRow)(e,this._trackerLabelWidth,!0)),p=s.appendChild(document.createElement("tbody")),p.append(document.createElement("tr"));for(const e of t._woundTracker)p.appendChild((0,i.createTableRow)([""].concat(Array.from(e._table.values())),this._trackerLabelWidth))}if(t._weapons.length>0){l=s.appendChild(document.createElement("thead")),l.classList.add("table-active"),l.appendChild((0,i.createTableRow)(a._weaponLabels,this._weaponLabelWidthNormalized,!0)),p=s.appendChild(document.createElement("tbody")),p.append(document.createElement("tr"));for(const e of t._weapons)p.append((0,i.createTableRow)([e.name().toString(),e._range,e._type,e._str.toString(),e._ap,e._damage,e._abilities],this._weaponLabelWidthNormalized))}if(f=(0,i.createNotesHead)("Weapon notes",t._weapons),f&&s.appendChild(f),t._spells.length>0){l=s.appendChild(document.createElement("thead")),l.classList.add("table-active"),l.appendChild((0,i.createTableRow)(a._spellLabels,this._spellLabelWidthNormalized,!0)),p=s.appendChild(document.createElement("tbody")),p.append(document.createElement("tr"));for(const e of t._spells)p.append((0,i.createTableRow)([e.name(),e._manifest.toString(),e._range,e._details],this._spellLabelWidthNormalized))}if(f=(0,i.createNotesHead)("Spell notes",t._spells),f&&s.appendChild(f),t._psykers.length>0){l=s.appendChild(document.createElement("thead")),l.classList.add("info_row");const e=document.createElement("div");for(const n of t._psykers){let t=`CAST: ${n._cast}, DENY: ${n._deny}, POWERS KNOWN: ${n._powers}`;n._other&&(t+=`, OTHER: ${n._other}`),e.appendChild(document.createElement("div")).appendChild(document.createTextNode(t))}l.appendChild((0,i.createTableRow)(["Psykers",e],[.1,.9],!1))}f=(0,i.createNotesHead)("Psyker notes",t._psykers),f&&s.appendChild(f),!t._abilities.Abilities&&t._rules.size>0&&this.renderUnitAbilitiesAndRules(s,"Abilities",new Map,t._rules);for(const e of Object.keys(t._abilities).sort()){const n=t._abilities[e],r="Abilities"===e?t._rules:void 0;this.renderUnitAbilitiesAndRules(s,e,n,r)}l=s.appendChild(document.createElement("thead")),l.classList.add("info_row");const _=Array.from(t._factions).sort(r.Compare).join(", ").toLocaleUpperCase();l.appendChild((0,i.createTableRow)(["Factions",_],[.1,.9],!1)),l=s.appendChild(document.createElement("thead")),l.classList.add("info_row");const m=Array.from(t._keywords).sort(r.Compare).join(", ").toLocaleUpperCase();l.appendChild((0,i.createTableRow)(["Keywords",m],[.1,.9],!1)),l=s.appendChild(document.createElement("thead")),l.classList.add("info_row");const g=document.createElement("div");if(this.renderModelList(g,t),l.appendChild((0,i.createTableRow)(["MODELS",g],[.1,.9],!1)),t._explosions.length>0){l=s.appendChild(document.createElement("thead")),l.classList.add("table-active"),l.appendChild((0,i.createTableRow)(a._explosionLabels,this._explosionLabelWidthNormalized,!0)),p=s.appendChild(document.createElement("tbody")),p.append(document.createElement("tr"));for(const e of t._explosions)p.append((0,i.createTableRow)([e.name(),e._diceRoll,e._distance,e._mortalWounds],this._explosionLabelWidthNormalized))}f=(0,i.createNotesHead)("Explosion notes",t._explosions),f&&s.appendChild(f)}renderUnitAbilitiesAndRules(e,t,n,s){const a=e.appendChild(document.createElement("thead"));a.classList.add("info_row");const l=document.createElement("div");if(s&&s.size>0){const e=Array.from(s.keys()).sort(r.Compare).join(", ");l.appendChild(document.createElement("div")).appendChild(document.createElement("b")).appendChild(document.createTextNode(e))}const c=Array.from(n.keys()).sort(r.Compare);for(const e of c){const t=(0,o.addHideAble)(l.appendChild(document.createElement("div")));t.appendChild(document.createElement("b")).appendChild(document.createTextNode(`${e.toUpperCase()}: `)),t.appendChild(document.createTextNode(n.get(e)||"??"))}a.appendChild((0,i.createTableRow)([t,l],[.1,.9],!1))}renderModelList(e,t){for(const n of t._models){const t=e.appendChild(document.createElement("div"));t.appendChild(document.createTextNode((n._count>1?`${n._count}x `:"")+n.name()));const r=n.getDedupedWeaponsAndUpgrades();if(0!==r.length){t.appendChild(document.createTextNode(" ("));for(const e of r)if(e!==r[0]&&t.appendChild(document.createTextNode(", ")),t.appendChild(document.createTextNode((e._count>1?`${e._count}x `:"")+e.selectionName())),e._cost.hasValues()){const n=t.appendChild(document.createElement("span"));n.classList.add("wh40k_upgrade_cost","d-none"),n.appendChild(document.createTextNode(` ${e._cost.toString()}`))}t.appendChild(document.createTextNode(")"))}}}printRules(e,t){if(0!==e.size&&t)for(let[n,r]of e.entries()){let e=document.createElement("div");e.classList.add("wh40k_rules");let i=document.createElement("h3");e.appendChild(i),i.appendChild(document.createTextNode(n));for(let t of r){let n=(0,o.addHideAble)(document.createElement("div")),r=document.createElement("b");r.appendChild(document.createTextNode(t[0]));let i=document.createElement("p");i.appendChild(document.createTextNode(t[1]||"")),n.appendChild(r),n.appendChild(i),e.appendChild(n)}t.appendChild(e)}}}function l(e,t,n){0!==n.size&&e.set(t,new Map([...e.get(t)||[],...n]))}t.Renderer40k=a,a._unitLabels=["MODEL","M","WS","BS","S","T","W","A","LD","SAVE"],a._weaponLabels=["WEAPONS","RANGE","TYPE","S","AP","D","ABILITIES"],a._spellLabels=["PSYCHIC POWER","MANIFEST","RANGE","DETAILS"],a._explosionLabels=["EXPLOSION","DICE ROLL","DISTANCE","MORTAL WOUNDS"],a._trackerLabels=["WOUND TRACK","REMAINING W","ATTRIBUTE","ATTRIBUTE","ATTRIBUTE"]},542:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Wh40kRenderer=void 0;const r=n(208),i=n(361),o=n(219),s=n(77);function a(e,t,n){0!==n.size&&e.set(t,new Map([...e.get(t)||[],...n]))}t.Wh40kRenderer=class{constructor(e){var t,n;this._roster=null,this._roles=new Map,this._unitLabelWidthsNormalized=[.4,.05,.05,.05,.05,.05,.05,.3],this._weaponLabelWidthNormalized=[.3,.1,.1,.05,.05,.05,.05,.3],this._roster=e;const i=(null===(t=this._roster)||void 0===t?void 0:t.hash())||0;this._rosterId=`${null===(n=this._roster)||void 0===n?void 0:n.name()}:${(i>>>0).toString(16)}`,this._roles.set(r.Wh40k.UnitRole.EpicHero,document.getElementById("role_hq")),this._roles.set(r.Wh40k.UnitRole.Character,document.getElementById("role_hq")),this._roles.set(r.Wh40k.UnitRole.Battleline,document.getElementById("role_tr")),this._roles.set(r.Wh40k.UnitRole.Infantry,document.getElementById("role_el")),this._roles.set(r.Wh40k.UnitRole.Vehicle,document.getElementById("role_hs")),this._roles.set(r.Wh40k.UnitRole.Mounted,document.getElementById("role_fa")),this._roles.set(r.Wh40k.UnitRole.Transport,document.getElementById("role_dt")),this._roles.set(r.Wh40k.UnitRole.Fortification,document.getElementById("role_ft"))}render(e,t,n){if(null==this._roster)return;const r=[`${this._roster._cost._points} pts`];for(const e in this._roster._cost._freeformValues)r.push(`${this._roster._cost._freeformValues[e]}${e}`);const i=`${this._roster.name()} (${r.join(", ")})`;null==e||e.appendChild(s.PsJsx.createElement(s.PsJsx.createFragment,null,this.renderOptionsDiv(),s.PsJsx.createElement("h3",null,i),s.PsJsx.createElement("div",{className:"footer"},s.PsJsx.createElement("div",null,"PrettyScribe"),s.PsJsx.createElement("div",null,i)),this._roster._customNotes&&s.PsJsx.createElement("p",null,this._roster._customNotes))),null==t||t.appendChild(s.PsJsx.createElement(s.PsJsx.createFragment,null,this.renderRosterSummary(),this.renderAbilitiesByPhase())),null==n||n.appendChild(this.renderRosterDetails()),(0,o.loadOptionsFromLocalStorage)(),this.loadDatasheetOrderFromLocalStorage(),this.collapseIdenticalUnits()}renderRosterSummary(){var e;return s.PsJsx.createElement(s.PsJsx.createFragment,null,null===(e=this._roster)||void 0===e?void 0:e._forces.map((e=>this.renderForceSummary(e))))}renderForceSummary(e){let t;const n=s.PsJsx.createElement("div",null,e._faction?`${e._catalog} ${e.name()} (${e._faction})`:`${e._catalog} ${e.name()}`,e._configurations.length>0&&s.PsJsx.createElement("ul",null,e._configurations.map((e=>s.PsJsx.createElement("li",null,s.PsJsx.createElement("i",null,e))))),s.PsJsx.createElement("table",{className:"table table-sm table-striped"},s.PsJsx.createElement("thead",{className:"thead-light"},s.PsJsx.createElement("tr",null,s.PsJsx.createElement("th",{scope:"col",style:"width: 20%;"},"NAME"),s.PsJsx.createElement("th",{scope:"col",style:"width: 15%;"},"ROLE"),s.PsJsx.createElement("th",{scope:"col",style:"width: 55%;"},"MODELS"),s.PsJsx.createElement("th",{scope:"col",style:"width: 5%;"},"POINTS"))),s.PsJsx.createElement("tbody",{ref:e=>{t=e}},e._units.map(((e,t)=>s.PsJsx.createElement("tr",{"data-index":t},s.PsJsx.createElement("td",null,e.nameWithExtraCosts()),s.PsJsx.createElement("td",null,r.Wh40k.UnitRoleToString[e._role]),s.PsJsx.createElement("td",null,this.renderModelList(e)),s.PsJsx.createElement("td",null,e._cost._points.toString())))))),s.PsJsx.createElement("button",{id:"reset-order-button",className:"d-none btn btn-secondary d-print-none",onclick:e=>this.resetDatasheetOrder(t)},"Reset datasheet order"));return this.makeForceSummaryListItemsDraggable(t),n}makeForceSummaryListItemsDraggable(e){for(const t of e.children)t.draggable=!0,t.classList.add("draggable");let t,n;e.addEventListener("dragstart",(e=>{t=e.target.closest("[draggable]"),e.dataTransfer.effectAllowed="move"})),e.addEventListener("dragover",(e=>{e.preventDefault();const t=e.target.closest("[draggable]");n!==t&&(null==n||n.classList.remove("draggable_drop_target_top"),null==t||t.classList.add("draggable_drop_target_top"),n=t)})),e.addEventListener("drop",(e=>{e.preventDefault(),null==n||n.classList.remove("draggable_drop_target_top");const r=e.target.closest("[draggable]");if(!t||t===r)return;const i=t.parentElement;i.insertBefore(t,r),this.orderDatasheetsToMatchSummary(i),this.collapseIdenticalUnits(),this.saveDatasheetOrderToLocalStorage()}))}orderDatasheetsToMatchSummary(e){const t=e.children;let n=!0;for(let e=0;e0){const i=t[e-1].dataset.index||-1;n&&(n=+(r||0)>+i)}const i=document.querySelector(`.wh40k_unit_sheet[data-index="${r}"]`);i&&(i.style.order=String(e))}const r=document.querySelector("#reset-order-button");n?null==r||r.classList.add("d-none"):null==r||r.classList.remove("d-none")}collapseIdenticalUnits(){var e,t;const n=document.querySelectorAll(".wh40k_unit_sheet"),r=Array.from(n).sort(((e,t)=>+e.style.order-+t.style.order));let i=null;for(const n of r){n.classList.remove("d-none");const r=n.querySelector("div.unit_count > span");if(i&&(null==i?void 0:i.dataset.hash)===n.dataset.hash){i.classList.add("d-none");const t=i.querySelector("div.unit_count > span"),n=+((null==t?void 0:t.dataset.count)||"");r.dataset.count=String(n+1),null===(e=r.parentElement)||void 0===e||e.classList.remove("d-none")}else r.dataset.count=String(1),null===(t=r.parentElement)||void 0===t||t.classList.add("d-none");i=n}}saveDatasheetOrderToLocalStorage(){try{const e=document.querySelectorAll("tr.draggable"),t=Array.from(e).map((e=>e.dataset.index));(0,o.saveOptionToLocalStorage)(`40k-order-${this._rosterId}`,JSON.stringify(t))}catch(e){console.warn("Error in saveDatasheetOrderToLocalStorage",e)}}loadDatasheetOrderFromLocalStorage(){var e;try{const t=JSON.parse(window.localStorage[`40k-order-${this._rosterId}`]||"[]"),n=null===(e=document.querySelector("tr.draggable"))||void 0===e?void 0:e.parentElement;if(t.length){const e=Array.from(n.children);for(let r=0;r+(e.dataset.index||0)-+(t.dataset.index||0)));for(const n of t)e.appendChild(n);this.orderDatasheetsToMatchSummary(e),this.collapseIdenticalUnits()}catch(e){console.warn("Error in resetDatasheetOrder",e)}}renderOptionsDiv(){const e=s.PsJsx.createElement("div",{className:"wh40k_options_div d-print-none",id:"wh40k_options_div"}),t=e.appendChild(s.PsJsx.createElement("span",null));(0,o.renderOptionsToggle)(t),(0,o.renderCheckboxOption)(e,"showPhaseAbilities","Show abilities by phase",(e=>{const t=document.getElementById("wh40k_abilities_list");t&&(e.target.checked?t.classList.remove("d-none"):t.classList.add("d-none"))})),(0,o.renderCheckboxOption)(e,"showUpgradeCosts","Show upgrade costs",(e=>{const t=document.getElementsByClassName("wh40k_upgrade_cost");for(const n of t)e.target.checked?n.classList.remove("d-none"):n.classList.add("d-none")})),(0,o.renderCheckboxOption)(e,"showArmyRules","Show army rules",(e=>{const t=document.getElementById("all-army-rules");e.target.checked?null==t||t.classList.remove("d-none"):null==t||t.classList.add("d-none")}),!0),(0,o.renderCheckboxOption)(e,"singleColumnDatasheets","Single-Column Datasheets",(e=>{e.target.checked?document.body.classList.add("single_column"):document.body.classList.remove("single_column")}));const n=e.appendChild(s.PsJsx.createElement("span",{className:"wh40k_options_print_subsection"},"Print:"));return(0,o.renderCheckboxOption)(n,"printBigger","Larger Text",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("bigger"):n.classList.remove("bigger")})),(0,o.renderCheckboxOption)(n,"hideElements","Hide Elements",(e=>{const t=document.body;e.target.checked?(t.classList.add("hide_enabled"),t.addEventListener("click",i.toggleHidden)):(t.classList.remove("hide_enabled"),t.removeEventListener("click",i.toggleHidden))})),(0,o.renderCheckboxOption)(n,"datasheetPageBreaks","One Datasheet per Page",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("page_break"):n.classList.remove("page_break")})),e}renderAbilitiesByPhase(){if(!this._roster)return;const e={},t={};for(const n of this._roster._forces)for(const r of n._units)for(const n of Object.values(r._abilities))for(const[i,o]of n.entries()){const n=[...o.matchAll(/(?:before the first turn begins|set up|Reinforcements|(?:Command|Movement|Psychic|Shooting|Charge|Fight|Morale) phase)/gi)];if(0===n.length)continue;const a=s.PsJsx.createElement("div",{className:"hide_able"},s.PsJsx.createElement("b",null,r.name())," - ",s.PsJsx.createElement("b",null,i)," - ");let l=o;for(const r of n){if(!r.index)continue;const n=r[0].toLocaleLowerCase();let c=n;switch(n){case"before the first turn begins":c="pre-game phase";break;case"set up":o.includes("reinforcements")||(c="pre-game phase");break;case"reinforcements":c="movement phase"}if(o.toLocaleLowerCase().includes("as if it were your "+c))continue;const u=r.index-(o.length-l.length);u>0&&a.appendChild(document.createTextNode(l.substring(0,u)));const d=e[c]=e[c]||[],h=t[c]=t[c]||[];h.includes(i)||(h.push(i),d.push(a)),a.appendChild(s.PsJsx.createElement("u",null,r[0]));const f=u+n.length;l=l.substring(f)}l.length>0&&a.appendChild(document.createTextNode(l))}const n=["pre-game phase","command phase","movement phase","psychic phase","shooting phase","charge phase","fight phase","morale phase"].filter((t=>!!e[t]));return s.PsJsx.createElement("div",{id:"wh40k_abilities_list",className:"d-none"},s.PsJsx.createElement("h3",null,"Abilities by Phase"),0===n.length?"No phase-specific abilities in roster":n.map((t=>s.PsJsx.createElement(s.PsJsx.createFragment,null,s.PsJsx.createElement("h4",null,t),e[t].map((e=>e.cloneNode(!0)))))))}renderRosterDetails(){if(!this._roster)return;const e=new Map,t=new Map;return s.PsJsx.createElement(s.PsJsx.createFragment,null,s.PsJsx.createElement("div",{className:"page_break",style:"display: flex; flex-direction: column;"},this._roster._forces.map((n=>s.PsJsx.createElement(s.PsJsx.createFragment,null,this._roster._forces.length>1&&s.PsJsx.createElement("h3",null,s.PsJsx.createElement("div",{style:"page-break-before: always;"},s.PsJsx.createElement("p",null,n._catalog,n._faction&&` (${n._faction})`))),a(e,n._catalog,n._rules),a(t,n._faction,n._factionRules),n._units.map(((e,t)=>this.renderUnit(e,t))))))),s.PsJsx.createElement("div",{id:"all-army-rules",style:"page-break-before: always;"},this.renderRules(e),this.renderRules(t)))}renderUnit(e,t){var n;return s.PsJsx.createElement("div",{className:"wh40k_unit_sheet","data-hash":(e.hash()>>>0).toString(16),"data-name":e.name(),"data-index":String(t),style:`order: ${t};`},s.PsJsx.createElement("table",{className:"table table-sm table-striped"},s.PsJsx.createElement("thead",{className:"table-dark unit_header"},s.PsJsx.createElement("tr",{className:"hide_able"},s.PsJsx.createElement("td",{scope:"col",colspan:"2",style:"width: 10%;"},s.PsJsx.createElement("div",{className:"unit_costs"},s.PsJsx.createElement("span",null,(null===(n=this._roles.get(e._role))||void 0===n?void 0:n.cloneNode())||"-"),s.PsJsx.createElement("span",null,e._cost._points.toString()))),s.PsJsx.createElement("td",{scope:"col",colspan:"16",style:"width: 80%;"},e.name()),s.PsJsx.createElement("td",{scope:"col",colspan:"2",style:"width: 10%;"},s.PsJsx.createElement("div",{className:"unit_costs unit_count"},s.PsJsx.createElement("span",{className:"unit_count","data-count":"1"})))),s.PsJsx.createElement("tr",null,[...Array(20).keys()].map((e=>s.PsJsx.createElement("td",{colspan:"1",style:"width: 5%; padding: 0px;"})))),this.renderNotesHead("Unit notes",e)),s.PsJsx.createElement("thead",null,s.PsJsx.createElement("tr",null,s.PsJsx.createElement("td",{colspan:"20",className:"subTableTd"},s.PsJsx.createElement("div",null,this.renderProfilesTables(e),s.PsJsx.createElement("table",{className:"table table-sm table-striped"},!e._abilities.Abilities&&e._rules.size>0&&this.renderUnitAbilitiesAndRules("Abilities",new Map,e._rules),Object.entries(e._abilities).sort().map((([t,n])=>this.renderUnitAbilitiesAndRules(t,n,"Abilities"===t?e._rules:void 0)))))))),s.PsJsx.createElement("thead",{className:"info_row keywords_row"},s.PsJsx.createElement("tr",{class:"hide_able"},s.PsJsx.createElement("td",{scope:"col",colspan:"2",style:"width: 10%;"},"Keywords"),s.PsJsx.createElement("td",{scope:"col",colspan:"12",style:"width: 60%;"},Array.from(e._keywords).sort(r.Wh40k.Compare).join(", ").toLocaleUpperCase()),s.PsJsx.createElement("td",{scope:"col",colspan:"2",style:"width: 10%;"},"Factions"),s.PsJsx.createElement("td",{scope:"col",colspan:"4",style:"width: 20%;"},Array.from(e._factions).sort(r.Wh40k.Compare).join(", ").toLocaleUpperCase()))),s.PsJsx.createElement("thead",{className:"info_row"},s.PsJsx.createElement("tr",{class:"hide_able"},s.PsJsx.createElement("td",{scope:"col",colspan:"2",style:"width: 10%;"},"MODELS"),s.PsJsx.createElement("td",{scope:"col",colspan:"18",style:"width: 90%;"},s.PsJsx.createElement("div",null,this.renderModelList(e)))))))}renderProfilesTables(e){const t=Object.entries(e._profileTables).sort(((e,t)=>r.Wh40k.CompareProfileTableName(e[0],t[0]))).map((([e,t])=>[t,"Unit"===e?this._unitLabelWidthsNormalized:this._weaponLabelWidthNormalized]));return s.PsJsx.createElement("table",{className:"table table-sm table-striped"},t.map((([e,t])=>s.PsJsx.createElement(s.PsJsx.createFragment,null,s.PsJsx.createElement("thead",{className:"table-active"},s.PsJsx.createElement("tr",{className:"hide_able header_row"},t.map(((t,n)=>s.PsJsx.createElement("th",{scope:"col",colspan:Math.round(t/.05),style:`width: ${100*t}%;`},e._headers[n]))))),s.PsJsx.createElement("tbody",null,s.PsJsx.createElement("tr",null)," ",e._contents.map((e=>s.PsJsx.createElement("tr",{className:"hide_able"},t.map(((t,n)=>s.PsJsx.createElement("td",{scope:"col",colspan:Math.round(t/.05),style:`width: ${100*t}%;`},e[n])))))))))))}renderUnitAbilitiesAndRules(e,t,n){return s.PsJsx.createElement(s.PsJsx.createFragment,null,s.PsJsx.createElement("thead",{className:"info_row table-active"},s.PsJsx.createElement("tr",{className:"header_row"},s.PsJsx.createElement("th",{colspan:"20"},e))),s.PsJsx.createElement("tbody",{className:"info_row"},s.PsJsx.createElement("tr",null)," ",n&&n.size>0&&s.PsJsx.createElement("tr",{className:"hide_able"},s.PsJsx.createElement("td",{scope:"col",colspan:"20",style:"width: 100%;"},s.PsJsx.createElement("div",null,s.PsJsx.createElement("div",null,s.PsJsx.createElement("b",null,Array.from(n.keys()).sort(r.Wh40k.Compare).join(", ")))))),Array.from(t.keys()).sort(r.Wh40k.Compare).map((e=>s.PsJsx.createElement("tr",{className:"hide_able"},s.PsJsx.createElement("td",{scope:"col",colspan:"20",style:"width: 100%;"},s.PsJsx.createElement("div",null,s.PsJsx.createElement("div",{className:"hide_able"},s.PsJsx.createElement("b",null,`${e.toUpperCase()}: `),t.get(e)||"??"))))))))}renderModelList(e){return e._models.map((e=>s.PsJsx.createElement("div",null,e._count>1?`${e._count}x `:"",e.name(),e.getDedupedWeaponsAndUpgrades().length>0&&s.PsJsx.createElement(s.PsJsx.createFragment,null," (",e.getDedupedWeaponsAndUpgrades().map(((e,t)=>s.PsJsx.createElement(s.PsJsx.createFragment,null,t>0?", ":"",e._count>1?`${e._count}x `:"",e.selectionName(),e._cost.hasValues()&&s.PsJsx.createElement("span",{className:"wh40k_upgrade_cost d-none"},` ${e._cost.toString()}`)))),")"))))}renderRules(e){return 0===e.size?null:s.PsJsx.createElement(s.PsJsx.createFragment,null,Array.from(e.entries()).map((([e,t])=>s.PsJsx.createElement("div",{className:"wh40k_rules"},s.PsJsx.createElement("h3",null,e),Array.from(t.entries()).map((e=>s.PsJsx.createElement("div",{className:"hide_able"},s.PsJsx.createElement("b",null,e[0]),s.PsJsx.createElement("p",null,e[1]))))))))}renderNotesHead(e,t){return t.notes()?s.PsJsx.createElement("thead",{className:"info_row"},s.PsJsx.createElement("tr",null,s.PsJsx.createElement("td",{style:"width: 10%",colspan:"2"},e),s.PsJsx.createElement("td",{style:"width: 90%",colspan:"18"},t._customNotes))):null}}},964:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RendererAoS=void 0;const r=n(774);t.RendererAoS=class{constructor(e){this._roster=null,this._roster=e}render(e,t,n){if(null!=this._roster){if(e){e.innerHTML="

"+this._roster._name.toUpperCase()+" ("+this._roster._points+" pts, "+this._roster._commandPoints+" CP)

";let t=document.createElement("h3");t.textContent="ROSTER",e.appendChild(t)}for(let e of this._roster._forces){const i=document.createElement("div");i&&(i.innerHTML="

"+e._catalog+" "+e._name+"

"),t&&t.appendChild(i);const o=[{name:"NAME",width:"35%"},{name:"ROLE",width:"15%"},{name:"SELECTIONS",width:"40%"},{name:"POINTS",width:"10%"}],s=this.createTable(o);s.classList.add("table","table-sm","aos_font"),i.appendChild(s);let a=document.createElement("tbody");s.appendChild(a);for(let t of e._units){let e=document.createElement("tr"),n=document.createElement("td");n.innerHTML=`${t._name}`;let i=document.createElement("td");i.innerHTML=r.AoSUnitRoleToString[t._role];let o=document.createElement("td");o.innerHTML="";for(const e of t._selections)o.innerHTML+=e+"
";let s=document.createElement("td");s.textContent=t._points.toString(),e.appendChild(n),e.appendChild(i),e.appendChild(o),e.appendChild(s),a.appendChild(e)}let l=document.createElement("div"),c=document.createElement("h3");if(c.textContent=e._allegiance._name.toUpperCase(),l.appendChild(c),e._allegiance._commandAbilities.size>0&&this.renderAbilityMap(l,"ABILITIES",e._allegiance._commandAbilities),e._allegiance._battleTraits.size>0&&this.renderAbilityMap(l,"BATTLE TRAITS",e._allegiance._battleTraits),e._allegiance._spells.length>0){let t=document.createElement("h4");t.textContent="ALLEGIANCE SPELLS",l.append(t),this.renderSpells(l,e._allegiance._spells)}if(e._allegiance._extraProfiles.length>0){let t="";for(let n of e._allegiance._extraProfiles)if(1==n._value._fields.size){if(t!=n._value._typeName){let e=document.createElement("h4");l.appendChild(e),e.textContent=n._value._typeName.toUpperCase(),t=n._value._typeName}const e=n._value._fields.values();let r=document.createElement("p");r.classList.add("aos_font"),r.innerHTML=`${n._name}: ${e.next().value}`,l.appendChild(r)}else console.log("Table profiles not implemented. "+n._value._typeName)}if(e._grandStrategy&&""!=e._grandStrategy._name){let t=document.createElement("h3");l.appendChild(t),t.textContent="GRAND STRATEGY";let n=document.createElement("div"),r=document.createElement("h4");r.textContent=e._grandStrategy._name;let i=document.createElement("p");i.textContent=e._grandStrategy._description,n.appendChild(r),n.appendChild(i),l.appendChild(n)}if(e._triumph&&""!=e._triumph._name){let t=document.createElement("h3");l.appendChild(t),t.textContent="TRIUMPH";let n=document.createElement("div"),r=document.createElement("h4");r.textContent=e._triumph._name;let i=document.createElement("p");i.textContent=e._triumph._description,n.appendChild(r),n.appendChild(i),l.appendChild(n)}if(e._realmOfBattle&&e._realmOfBattle._name.length>0){let t=document.createElement("h3");if(l.appendChild(t),t.textContent="REALM OF BATTLE ("+e._realmOfBattle._name+")",e._realmOfBattle._spells.length>0){let t=document.createElement("h4");t.textContent="SPELLS",l.append(t),this.renderSpells(l,e._realmOfBattle._spells)}if(e._realmOfBattle._commandAbilities.size>0&&this.renderAbilityMap(l,"COMMAND ABILITIES",e._realmOfBattle._commandAbilities),e._realmOfBattle._rules.length>0){let t=document.createElement("h4");t.textContent="SPECIAL RULES",l.append(t);for(let t of e._realmOfBattle._rules){let e=document.createElement("div"),n=document.createElement("p");n.textContent=t._name+": "+t._description,e.appendChild(n),l.appendChild(e)}}}for(let t of e._rules){let e=document.createElement("h3");l.appendChild(e),e.textContent="RULES";let n=document.createElement("div"),r=document.createElement("h4");r.textContent=t[0];let i=document.createElement("p");i.textContent=t[1],n.appendChild(r),n.appendChild(i),l.appendChild(n)}if(e._battleTactics.size>0){let t=document.createElement("h3");t.textContent="BATTLE TACTICS",l.appendChild(t);const n=[{name:"NAME",width:"20%"},{name:"DESCRIPTION",width:"80%"}],r=this.createTable(n);r.classList.add("table","table-sm","aos_table","aos_font");let i=document.createElement("tbody");r.appendChild(i);for(let t of e._battleTactics){let e=document.createElement("tr"),n=document.createElement("td");n.textContent=t[0];let r=document.createElement("td");r.textContent=t[1],e.appendChild(n),e.appendChild(r),i.appendChild(e)}l.appendChild(r)}for(let t of e._battalions){let e=document.createElement("h3");l.appendChild(e),e.textContent=t._name.toUpperCase();for(let e of t._abilities){let t=document.createElement("div"),n=document.createElement("h4");n.textContent=e[0];let r=document.createElement("p");r.textContent=e[1],t.appendChild(n),t.appendChild(r),l.appendChild(t)}}if(!n)continue;n.appendChild(l);let u=document.createElement("hr");u.classList.add("aos_dark"),n.appendChild(u);for(let t of e._units){n.appendChild(this.renderUnitHtml(t));let e=document.createElement("hr");e.classList.add("aos_dark"),n.appendChild(e)}}}}createTable(e){const t=document.createElement("table"),n=document.createElement("thead");t.appendChild(n),n.classList.add("aos_light");const r=document.createElement("tr");return n.appendChild(r),e.forEach((e=>{let t=document.createElement("th");t.scope="col",t.textContent=e.name,t.style.width=e.width,r.appendChild(t)})),t}internalKeyword(e){return e.toUpperCase()!=e}renderUnitHtml(e){let t=document.createElement("div");t.classList.add("container-fluid","aos_unit");let n=document.createElement("div");n.classList.add("p-2","mb-2","aos_medium","text-center","text-uppercase","text-black"),n.innerHTML=`${e._name}`,t.append(n);let r=document.createElement("div");if(r.classList.add("row"),t.append(r),e.isNormalUnit()){let t=document.createElement("div");t.classList.add("col-3"),t.innerHTML=`
\n

${e._move}

\n

${e._wounds}

\n

${e._bravery}

\n

${e._save}

\n
`,r.append(t)}let i=document.createElement("div");i.classList.add("col"),r.appendChild(i);let o=document.createElement("table");o.classList.add("table","table-sm","aos_table","aos_font","text-center");let s=document.createElement("thead");o.appendChild(s),o.innerHTML='\n Missile Weapons\n Range\n Attacks\n To Hit\n To Wound\n Rend\n Damage\n ';let a=document.createElement("tbody");o.appendChild(a);let l=document.createElement("table");l.classList.add("table","table-sm","aos_table","aos_font","text-center"),s=document.createElement("thead"),l.appendChild(s),l.innerHTML='\n Melee Weapons\n Range\n Attacks\n To Hit\n To Wound\n Rend\n Damage\n ';let c=document.createElement("tbody");l.appendChild(c);let u=!1,d=!1;for(let t of e._weapons)if("Missile"===t._type){let e=document.createElement("tr");e.innerHTML=`${t._name}${t._range}${t._attacks}\n ${t._toHit}${t._toWound}${t._rend}${t._damage}`,a.appendChild(e),u=!0}else if("Melee"===t._type){let e=document.createElement("tr");e.innerHTML=`${t._name}${t._range}${t._attacks}\n ${t._toHit}${t._toWound}${t._rend}${t._damage}`,c.appendChild(e),d=!0}if(u&&i.appendChild(o),d&&i.appendChild(l),e._woundTracker&&e._woundTracker._labels.length>0){let t=[];const n=(1/e._woundTracker._labels.length*100).toString()+"%";for(let r of e._woundTracker._labels)t.push({name:r,width:n});const r=this.createTable(t);r.classList.add("table","table-sm","aos_table","aos_font","text-center"),i.appendChild(r);let o=document.createElement("tbody");r.appendChild(o);for(let t of e._woundTracker._table){let e=document.createElement("tr");for(let n of t){let t=document.createElement("td");t.textContent=n,e.appendChild(t)}o.appendChild(e)}}if(e._abilities.size>0&&this.renderAbilityMap(i,"ABILITIES",e._abilities),e._commandAbilities.size>0&&this.renderAbilityMap(i,"COMMAND ABILITIES",e._commandAbilities),e._commandTraits.size>0&&this.renderAbilityMap(i,"COMMAND TRAITS",e._commandTraits),e._magic.size>0&&this.renderAbilityMap(i,"MAGIC",e._magic),e._spells.length>0){let t=document.createElement("h4");t.textContent="SPELLS",i.appendChild(t),this.renderSpells(i,e._spells)}if(e._prayers.length>0){let t=document.createElement("h4");t.textContent="PRAYERS",i.appendChild(t);const n=[{name:"NAME",width:"20%"},{name:"ANSWER VALUE",width:"10%"},{name:"RANGE",width:"10%"},{name:"DESCRIPTION",width:"60%"}],r=this.createTable(n);r.classList.add("table","table-sm","aos_table","aos_font");let o=document.createElement("tbody");r.appendChild(o);for(let t of e._prayers){let e=document.createElement("tr"),n=document.createElement("td");n.textContent=t._name;let r=document.createElement("td");r.textContent=t._answerValue.toString();let i=document.createElement("td");i.textContent=t._range.toString();let s=document.createElement("td");s.textContent=t._description,e.appendChild(n),e.appendChild(r),e.appendChild(i),e.appendChild(s),o.appendChild(e)}i.appendChild(r)}e._artefacts.size>0&&this.renderAbilityMap(i,"ARTEFACTS",e._artefacts);let h="";for(let t of e._extraProfiles)if(1==t._value._fields.size){if(h!=t._value._typeName){let e=document.createElement("h4");i.appendChild(e),e.textContent=t._value._typeName.toUpperCase(),h=t._value._typeName}const e=t._value._fields.values();let n=document.createElement("p");n.classList.add("aos_font"),n.innerHTML=`${t._name}: ${e.next().value}`,i.appendChild(n)}else console.log("Table profiles not implemented. "+t._value._typeName);if(e._keywords.size>0){let n=document.createElement("div");n.classList.add("container-fluid");let r=document.createElement("div");r.classList.add("row"),n.appendChild(r);let i=document.createElement("div");i.classList.add("col-5","border","aos_dark","text-center"),i.innerHTML="KEYWORDS",r.appendChild(i);let o="",s="";for(let t of e._keywords)this.internalKeyword(t)||(s+=o,s+=t,o=", ");let a=document.createElement("div");a.classList.add("col","border","text-left","text-uppercase"),a.innerText=s,r.appendChild(a),t.appendChild(n)}return t}renderAbilityMap(e,t,n){let r=document.createElement("h4");r.textContent=t,e.appendChild(r);for(let e of n){let t=document.createElement("p");t.classList.add("aos_font"),t.innerHTML=`${e[0]}: ${e[1]}`,r.appendChild(t)}}renderSpells(e,t){const n=this.createTable([{name:"NAME",width:"25%"},{name:"CASTING VALUE",width:"15%"},{name:"RANGE",width:"10%"},{name:"DESCRIPTION",width:"50%"}]);n.classList.add("table","table-sm","aos_font");let r=document.createElement("tbody");n.appendChild(r);for(let e of t){let t=document.createElement("tr"),n=document.createElement("td");n.textContent=e._name;let i=document.createElement("td");i.textContent=e._castingValue.toString();let o=document.createElement("td");o.textContent=e._range.toString();let s=document.createElement("td");s.textContent=e._description,t.appendChild(n),t.appendChild(i),t.appendChild(o),t.appendChild(s),r.appendChild(t)}e.appendChild(n)}}},66:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RendererHH2=void 0;const r=n(980);class i{constructor(e){this._roster=null,this._roles=new Map,this._infantryLabelWidthsNormalized=[.2,.2,.05,.05,.05,.05,.05,.05,.05,.05,.05,.05,.1],this._vehicleLabelWidthsNormalized=[.2,.2,.05,.05,.05,.05,.05,.05,.2,.1],this._knightLabelWidthsNormalized=[.2,.2,.05,.05,.05,.05,.05,.05,.05,.05,.05,.05,.1],this._fortificationLabelWidthsNormalized=[.2,.2,.05,.05,.05,.05,.05,.2,.15],this._weaponLabelWidthNormalized=[.25,.05,.05,.05,.15,.35],this._psychicWeaponLabelWidthNormalized=[.25,.05,.05,.05,.15,.35],this._psychicPowerLabelWidthNormalized=[.25,.75],this._wargearLabelWidthNormalized=[.25,.75],this._roster=e,this._roles.set(r.HorusHeresy.UnitRole.HQ,document.getElementById("role_hq")),this._roles.set(r.HorusHeresy.UnitRole.TR,document.getElementById("role_tr")),this._roles.set(r.HorusHeresy.UnitRole.EL,document.getElementById("role_el")),this._roles.set(r.HorusHeresy.UnitRole.FA,document.getElementById("role_fa")),this._roles.set(r.HorusHeresy.UnitRole.HS,document.getElementById("role_hs")),this._roles.set(r.HorusHeresy.UnitRole.FL,document.getElementById("role_fl")),this._roles.set(r.HorusHeresy.UnitRole.DT,document.getElementById("role_dt")),this._roles.set(r.HorusHeresy.UnitRole.FT,document.getElementById("role_ft")),this._roles.set(r.HorusHeresy.UnitRole.LW,document.getElementById("role_lw")),this._roles.set(r.HorusHeresy.UnitRole.PR,document.getElementById("role_lw"))}render(e,t,n){if(null!=this._roster){if(e){this.renderOptionsDiv(e);const t=[`${this._roster._cost._points} pts`],n=`${this._roster._name} (${t.join(", ")})`;e.appendChild(document.createElement("h3")).appendChild(document.createTextNode(n));const r=e.appendChild(document.createElement("div"));r.classList.add("footer"),r.appendChild(document.createElement("div")).appendChild(document.createTextNode("PrettyScribe")),r.appendChild(document.createElement("div")).appendChild(document.createTextNode(n))}t&&this.renderRosterSummary(t),n&&this.renderRosterDetails(n),this.loadOptionsFromLocalStorage()}}renderRosterSummary(e){if(this._roster)for(const t of this._roster._forces){const n=document.createElement("div");t._faction?n.appendChild(document.createTextNode(`${t._catalog} ${t._name} (${t._faction})`)):n.appendChild(document.createTextNode(`${t._catalog} ${t._name}`)),e.appendChild(n);const i=document.createElement("table");i.classList.add("table","table-sm","table-striped");const o=document.createElement("thead");i.appendChild(o),o.classList.add("thead-light");const s=document.createElement("tr");o.appendChild(s),[{name:"NAME",w:"20%"},{name:"ROLE",w:"15%"},{name:"MODELS",w:"55%"},{name:"POINTS",w:"5%"}].forEach((e=>{let t=document.createElement("th");t.scope="col",t.appendChild(document.createTextNode(e.name)),t.style.width=e.w,s.appendChild(t)})),n.appendChild(i);let a=document.createElement("tbody");i.appendChild(a);for(let e of t._units){const t=document.createElement("tr");t.appendChild(document.createElement("td")).appendChild(document.createTextNode(e._name)),t.appendChild(document.createElement("td")).appendChild(document.createTextNode(r.HorusHeresy.UnitRoleToString[e._role]));const n=t.appendChild(document.createElement("td"));this.renderModelList(n,e),t.appendChild(document.createElement("td")).appendChild(document.createTextNode(e._points.toString())),a.appendChild(t)}}}renderOptionsDiv(e){const t=e.appendChild(document.createElement("div"));t.classList.add("wh40k_options_div","d-print-none"),t.id="wh40k_options_div";const n=t.appendChild(document.createElement("span"));n.classList.add("wh40k_options_toggle"),n.id="wh40k_options_toggle";const r="[−] Options:";n.appendChild(document.createTextNode(r)),n.addEventListener("click",(e=>{const t=document.getElementById("wh40k_options_div"),n=document.getElementById("wh40k_options_toggle");t&&n&&(t.classList.contains("hide_options")?(t.classList.remove("hide_options"),n.innerText=r,this.saveOptionToLocalStorage("option-toggle-hidden","false")):(t.classList.add("hide_options"),n.innerText="[+] Options",this.saveOptionToLocalStorage("option-toggle-hidden","true")))})),this.renderCheckboxOption(t,"showUpgradeCosts","Show upgrade costs",(e=>{const t=document.getElementsByClassName("wh40k_upgrade_cost");for(const n of t)e.target.checked?n.classList.remove("d-none"):n.classList.add("d-none")})),this.renderCheckboxOption(t,"collateDatasheets","Collate Detachment Datasheets",(e=>{const t=document.getElementById("collated_sheets"),n=document.getElementById("detachment_sheets");t&&n&&(e.target.checked?(t.classList.remove("d-none"),n.classList.add("d-none")):(t.classList.add("d-none"),n.classList.remove("d-none")))}));const i=t.appendChild(document.createElement("span"));i.classList.add("wh40k_options_print_subsection"),i.appendChild(document.createTextNode("Print:")),this.renderCheckboxOption(i,"printBigger","Larger Text",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("bigger"):n.classList.remove("bigger")})),this.renderCheckboxOption(i,"hideElements","Hide Elements",(e=>{const t=document.body;e.target.checked?(t.classList.add("hide_enabled"),t.addEventListener("click",l)):(t.classList.remove("hide_enabled"),t.removeEventListener("click",l))})),this.renderCheckboxOption(i,"datasheetPageBreaks","One Datasheet per Page",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("page_break"):n.classList.remove("page_break")}))}renderCheckboxOption(e,t,n,r){const i=e.appendChild(document.createElement("div"));i.classList.add("wh40k_option");const o=i.appendChild(document.createElement("input"));o.setAttribute("type","checkbox"),o.setAttribute("name",t),o.setAttribute("id",t),o.addEventListener("input",r),o.addEventListener("change",(e=>this.saveCheckboxToLocalStorage(t)));const s=i.appendChild(document.createElement("label"));s.setAttribute("for",t),s.appendChild(document.createTextNode(` ${n}`))}saveCheckboxToLocalStorage(e){const t=document.getElementById(e);t&&this.saveOptionToLocalStorage(`option-checkbox-${e}`,t.checked)}saveOptionToLocalStorage(e,t){try{window.localStorage[e]=t}catch(e){}}loadOptionsFromLocalStorage(){var e;try{for(let t=0;te._role!=t._role?e._role-t._role:e._name!=t._name?r.HorusHeresy.Compare(e._name,t._name):e._points-t._points)),this.renderDatasheets(o,s);let u=document.createElement("div");u.style.pageBreakBefore="always",this.printRules(t,u),this.printRules(n,u),e.appendChild(u)}renderDatasheets(e,t){let n=0;for(let r=0;r1?` (${n})`:""),""],[.1,.8,.1]));const h=c.appendChild(document.createElement("tr"));for(let e=0;e<20;e++){const e=h.appendChild(document.createElement("td"));e.colSpan=1,e.style.width="5%",e.style.padding="0"}let f=function(e,t){if(!t.notes())return null;const n=document.createElement("thead");return n.classList.add("info_row"),n.appendChild(o(["Unit notes",t._customNotes],[.1,.9],!1)),n}(0,t);if(f&&l.appendChild(f),t._modelStats.length>0){const e=function(e){let t=new Map;const n=e.filter((e=>e instanceof r.HorusHeresy.Vehicle));t.set("Vehicles",n);const i=e.filter((e=>e instanceof r.HorusHeresy.Knight));t.set("Knights",i);const o=e.filter((e=>e instanceof r.HorusHeresy.Fortification));t.set("Fortifications",o);const s=e.filter((e=>e instanceof r.HorusHeresy.Model));return t.set("Models",s),t}(t._modelStats),n=e.get("Models");if(null!=n&&n.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._infantryLabels,this._infantryLabelWidthsNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of n){let n=t;e.append(o([n._name,n._type,n._move.toString(),n._ws.toString(),n._bs.toString(),n._str.toString(),n._toughness.toString(),n._wounds.toString(),n._initiative.toString(),n._attacks.toString(),n._leadership.toString(),n._save],this._infantryLabelWidthsNormalized))}}const s=e.get("Vehicles");if(null!=s&&s.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._vehicleLabels,this._vehicleLabelWidthsNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of s){let n=t;e.append(o([n._name,n._type,n._move.toString(),n._bs.toString(),n._front.toString(),n._side.toString(),n._rear.toString(),n._hp.toString(),n._capacity.toString()],this._vehicleLabelWidthsNormalized))}}const a=e.get("Knights");if(null!=a&&a.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._knightLabels,this._knightLabelWidthsNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of a){let n=t;e.append(o([n._name,n._type,n._move.toString(),n._ws.toString(),n._bs.toString(),n._str.toString(),n._front.toString(),n._side.toString(),n._rear.toString(),n._hp.toString(),n._initiative.toString(),n._attacks.toString(),n._hp.toString()],this._knightLabelWidthsNormalized))}}const u=e.get("Fortifications");if(null!=u&&u.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._fortificationLabels,this._fortificationLabelWidthsNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of u){let n=t;e.append(o([n._name,n._type,n._bs.toString(),n._front.toString(),n._side.toString(),n._rear.toString(),n._hp.toString(),n._capacity.toString()],this._fortificationLabelWidthsNormalized))}}}f=s("Model notes",t._models),f&&l.appendChild(f);const p=t.weapons();if(p.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._weaponLabels,this._weaponLabelWidthNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of p){let n=t._type.split(","),r=n[0].trim(),i=document.createElement("div");n.forEach(((e,t)=>{let n=e.trim();if(t>1&&i.appendChild(document.createTextNode(", ")),0!=t){let e=document.createElement("a");e.classList.add("hh2-rule-link"),e.href="#"+n,e.text=n,i.appendChild(e)}})),e.append(o([t.name().toString(),t._range,t._str.toString(),t._ap,r,i],this._weaponLabelWidthNormalized))}}f=s("Weapon notes",p),f&&l.appendChild(f);const _=t.wargear();if(_.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._wargearLabels,this._wargearLabelWidthNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of _)e.append(o([t.name(),t._description],this._wargearLabelWidthNormalized))}f=s("Wargear Item notes",_),f&&l.appendChild(f);const m=t.psychicWeapons();if(m.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._psychicWeaponLabels,this._psychicWeaponLabelWidthNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of m){let n=t._type.split(","),r=n[0].trim(),i=document.createElement("div");n.forEach(((e,t)=>{let n=e.trim();if(t>1&&i.appendChild(document.createTextNode(", ")),0!=t){let e=document.createElement("a");e.classList.add("hh2-rule-link"),e.href="#"+n,e.text=n,i.appendChild(e)}})),e.append(o([t.name().toString(),t._range,t._str.toString(),t._ap,r,i],this._psychicWeaponLabelWidthNormalized))}}f=s("Psychic Weapon notes",m),f&&l.appendChild(f);const g=t.psychicPowers();if(g.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._psychicPowerLabels,this._psychicPowerLabelWidthNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of g)e.append(o([t.name(),t._description],this._psychicPowerLabelWidthNormalized))}f=s("Psychic Power notes",g),f&&l.appendChild(f);const v=t.warlordTraits();if(v.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(["Warlord Trait","Description"],[.25,.75],!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of v)e.append(o([t.name(),t._description],[.25,.75]))}f=s("Warlord Trait notes",v),f&&l.appendChild(f);const b=t.reactions();if(b.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(["Reaction","Description"],[.25,.75],!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of b)e.append(o([t.name(),t._description],[.25,.75]))}if(t._rules.size>0){const e=Array.from(t._rules.keys()).sort(r.HorusHeresy.Compare),n=t.weaponRules();let i=[];for(const t of e)n.includes(t)||i.push(t);this.renderUnitRules(l,"Rules",i)}c=l.appendChild(document.createElement("thead")),c.classList.add("info_row");const y=Array.from(t._keywords).sort(r.HorusHeresy.Compare).join(", ").toLocaleUpperCase();c.appendChild(o(["Keywords",y],[.1,.9],!1)),c=l.appendChild(document.createElement("thead")),c.classList.add("info_row");const w=document.createElement("div");this.renderModelList(w,t),c.appendChild(o(["MODELS",w],[.1,.9],!1))}renderUnitRules(e,t,n){const r=e.appendChild(document.createElement("thead"));r.classList.add("info_row");const i=document.createElement("div");n.forEach(((e,t)=>{let n=e.trim();if(t>1&&i.appendChild(document.createTextNode(", ")),0!=t){let e=document.createElement("a");e.classList.add("hh2-rule-link"),e.href="#"+n,e.text=n,i.appendChild(e)}})),r.appendChild(o([t,i],[.1,.9],!1))}renderModelList(e,t){for(const n of t._models){const t=e.appendChild(document.createElement("div"));t.appendChild(document.createTextNode((n._count>1?`${n._count}x `:"")+n._name));const r=n.getDedupedWeaponsAndUpgrades();if(0!==r.length){t.appendChild(document.createTextNode(" ("));for(const e of r)if(e!==r[0]&&t.appendChild(document.createTextNode(", ")),t.appendChild(document.createTextNode((e._count>1?`${e._count}x `:"")+e.selectionName())),e._cost.hasValues()){const n=t.appendChild(document.createElement("span"));n.classList.add("wh40k_upgrade_cost","d-none"),n.appendChild(document.createTextNode(` ${e._cost.toString()}`))}t.appendChild(document.createTextNode(")"))}}}printRules(e,t){if(0!==e.size&&t)for(let[n,r]of e.entries()){let e=document.createElement("div");e.classList.add("wh40k_rules");let i=document.createElement("h3");e.appendChild(i),i.appendChild(document.createTextNode(n));for(let t of r){let n=a(document.createElement("div")),r=document.createElement("b");r.id=t[0],r.appendChild(document.createTextNode(t[0]));let i=document.createElement("p");i.appendChild(document.createTextNode(t[1]||"")),n.appendChild(r),n.appendChild(i),e.appendChild(n)}t.appendChild(e)}}}function o(e,t,n=!1){const r=a(document.createElement("tr"));n&&r.classList.add("header_row");for(let i=0,o=0;ie._customNotes)))return null;const n=document.createElement("thead");n.classList.add("info_row");const r=document.createElement("div");for(const e of t){if(!e.notes())continue;const t=r.appendChild(document.createElement("div"));t.appendChild(document.createElement("b")).appendChild(document.createTextNode(`${e.name()}: `)),t.appendChild(document.createTextNode(e._customNotes))}return n.appendChild(o([e,r],[.1,.9],!1)),n}function a(e){return e.classList.add("hide_able"),e}function l(e){let t=e.target;t&&(t=t.closest(".hide_able")),t&&(t.classList.contains("hidden")?t.classList.remove("hidden"):t.classList.add("hidden"))}t.RendererHH2=i,i._infantryLabels=["Model","Type","M","WS","BS","S","T","W","I","A","Ld","Sv",""],i._vehicleLabels=["Model","Type","M","BS","Front","Side","Rear","HP","Capacity",""],i._knightLabels=["Model","Type","M","WS","BS","S","Front","Side","Rear","I","A","HP",""],i._fortificationLabels=["Model","Type","BS","Front","Side","Rear","HP","Capacity",""],i._weaponLabels=["Weapon","Range","Str","AP","Type","Rules"],i._psychicWeaponLabels=["Psychic Weapon","Range","Str","AP","Type","Rules"],i._psychicPowerLabels=["Psychic Power","Description"],i._wargearLabels=["Wargear Item","Description"]},96:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RendererKT21=void 0;const r=n(249),i=n(419),o=n(682),s=n(361),a=n(219);class l{constructor(e){this._descriptionStartX=140,this._descriptionWidth=600,this._roster=null,this._octagon=null,this._specialisms=new Map,this._currentX=0,this._currentY=0,this._maxWidth=0,this._maxHeight=0,this._unitLabelWidthsNormalized=[.25,.05,.05,.05,.05,.05,.05],this._weaponLabelWidthNormalized=[.25,.05,.05,.05,.2,.2],this._spellLabelWidthNormalized=[.25,.75],this._roster=e,this._octagon=document.getElementById("octagon"),this._specialisms.set(r.Specialism.NONE,document.getElementById("role_hq")),this._specialisms.set(r.Specialism.COMBAT,document.getElementById("role_hs")),this._specialisms.set(r.Specialism.STAUNCH,document.getElementById("role_fa")),this._specialisms.set(r.Specialism.MARKSMAN,document.getElementById("role_el")),this._specialisms.set(r.Specialism.SCOUT,document.getElementById("role_tr"))}render(e,t,n){if(null==this._roster)return void console.log("Roster is NULL");if(e){this.renderOptionsDiv(e);const s=`${this._roster.name()} (${this._roster._equipmentPoints} EP)`;e.appendChild(document.createElement("h3")).appendChild(document.createTextNode(s))}let r=new Map,i=new Map;for(let l of this._roster._forces){let c=r.get(l._catalog);c||(c=new Map,r.set(l._catalog,c));let u=i.get(l._catalog);u||(u=new Map,i.set(l._faction,u));const d=document.createElement("div");d&&(l._faction?d.innerHTML="

"+l._faction+" - "+l.name()+"

":d.innerHTML="

"+l.name()+"

"),t&&t.appendChild(d);const h=document.createElement("table");h.classList.add("table"),h.classList.add("table-sm"),h.classList.add("table-striped");const f=document.createElement("thead");h.appendChild(f),f.classList.add("thead-light");const p=document.createElement("tr");f.appendChild(p),[{name:"MODELS",w:"55%"},{name:"EP",w:"5%"}].forEach((e=>{let t=document.createElement("th");t.scope="col",t.innerHTML=e.name,t.style.width=e.w,p.appendChild(t)})),d.appendChild(h);let _=document.createElement("tbody");if(h.appendChild(_),l._leader){let g=document.createElement("tr"),v=document.createElement("td");v.innerHTML=l._leader.nameAndGear();let b=document.createElement("td");b.innerHTML=l._leader.costs().toString(),g.appendChild(v),g.appendChild(b),_.appendChild(g)}for(let y of l._operatives){let w=document.createElement("tr"),C=document.createElement("td");C.innerHTML=y.nameAndGear();let x=document.createElement("td");x.innerHTML=y.costs().toString(),w.appendChild(C),w.appendChild(x),_.appendChild(w)}if(n){const E=document.createElement("div");if(E){const N=document.createElement("p");N.appendChild(document.createTextNode(l.name())),l._faction&&N.appendChild(document.createTextNode(" ("+l._faction+")")),E.appendChild(N)}let S=document.createElement("h3");S.appendChild(E),n.appendChild(S);const k=n.appendChild(document.createElement("div"));k.id="kt_canvas",k.classList.add("d-none");const A=n.appendChild(document.createElement("div"));A.id="kt_html",l._leader&&(this.printOperative(l._leader,null,k),this.printOperativeHtml(l._leader,null,A));let T=null;for(let L of l._operatives)this.printOperative(L,T,k),this.printOperativeHtml(L,T,A),T=L}function m(e,t){for(const n of t)e.set(n[0],n[1])}if(l._rules.size>0&&m(c,l._rules),l._factionRules.size>0&&m(u,l._factionRules),l._leader&&l._leader._rules.size>0&&m(c,l._leader._rules),l._operatives&&l._operatives.length>0)for(const R of l._operatives)R._rules&&R._rules.size>0&&m(c,R._rules)}let o=document.createElement("div");o.style.pageBreakBefore="always",this.printRules(r,o),this.printRules(i,o),n&&n.appendChild(o),(0,a.loadOptionsFromLocalStorage)()}renderOptionsDiv(e){const t=e.appendChild(document.createElement("div"));t.classList.add("wh40k_options_div","d-print-none"),t.id="wh40k_options_div";const n=t.appendChild(document.createElement("span"));(0,a.renderOptionsToggle)(n),(0,a.renderCheckboxOption)(t,"ktWithCanvas","Use old formatting",(e=>{const t=document.getElementById("kt_html"),n=document.getElementById("kt_canvas"),r=document.getElementById("ktHtmlOptions");t&&n&&r&&(e.target.checked?(t.classList.add("d-none"),r.classList.add("d-none"),n.classList.remove("d-none")):(t.classList.remove("d-none"),r.classList.remove("d-none"),n.classList.add("d-none")))}));const r=t.appendChild(document.createElement("span"));r.classList.add("wh40k_options_print_subsection"),r.id="ktHtmlOptions",r.appendChild(document.createTextNode("Print:")),(0,a.renderCheckboxOption)(r,"printBigger","Larger Text",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("bigger"):n.classList.remove("bigger")})),(0,a.renderCheckboxOption)(r,"hideElements","Hide Elements",(e=>{const t=document.body;e.target.checked?(t.classList.add("hide_enabled"),t.addEventListener("click",s.toggleHidden)):(t.classList.remove("hide_enabled"),t.removeEventListener("click",s.toggleHidden))})),(0,a.renderCheckboxOption)(r,"datasheetPageBreaks","One Datasheet per Page",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("page_break"):n.classList.remove("page_break")}))}printOperativeHtml(e,t,n){if(e.equal(t))return;const i=n.appendChild(document.createElement("div"));i.classList.add("wh40k_unit_sheet");const a=document.createElement("table");a.classList.add("table","table-sm","table-striped"),i.appendChild(a);let c=a.appendChild(document.createElement("thead"));c.classList.add("table-dark","unit_header");const u=document.createElement("div");u.classList.add("unit_costs");const d=this._specialisms.get(e._role);u.appendChild(document.createElement("span")).appendChild((null==d?void 0:d.cloneNode())||document.createTextNode("-")),c.appendChild((0,o.createTableRow)([u,e.name()],[.1,.9]));const h=c.appendChild(document.createElement("tr"));for(let e=0;e<20;e++){const e=h.appendChild(document.createElement("td"));e.colSpan=1,e.style.width="5%",e.style.padding="0"}const f=[],p=new Map;p.has(e.name())||(p.set(e.name(),e),f.push(e));let _=(0,o.createNoteHead)("Operative notes",e);_&&a.appendChild(_),c=a.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild((0,o.createTableRow)(l._unitLabels,this._unitLabelWidthsNormalized,!0));let m=a.appendChild(document.createElement("tbody"));m.append(document.createElement("tr"));for(const e of f)m.append((0,o.createTableRow)([e.name(),e._move,e._apl,e._groupActivations,e._defence.toString(),e._saves,e._wounds.toString()],this._unitLabelWidthsNormalized));const g=[],v=new Map;for(const t of e._weapons)v.has(t.name())||(v.set(t.name(),t),g.push(t));if(g.length>0){c=a.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild((0,o.createTableRow)(l._weaponLabels,this._weaponLabelWidthNormalized,!0)),m=a.appendChild(document.createElement("tbody")),m.append(document.createElement("tr"));for(const e of g)m.append((0,o.createTableRow)([e.nameAndCosts(),e._attacks,e._skill,e._damage,e._rules,e._criticalEffects],this._weaponLabelWidthNormalized))}if(_=(0,o.createNotesHead)("Weapon notes",e._weapons),_&&a.appendChild(_),e._psychicPowers.length>0){c=a.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild((0,o.createTableRow)(l._spellLabels,this._spellLabelWidthNormalized,!0)),m=a.appendChild(document.createElement("tbody")),m.append(document.createElement("tr"));for(const t of e._psychicPowers)m.append((0,o.createTableRow)([t.name(),t._effect],this._spellLabelWidthNormalized))}if(_=(0,o.createNotesHead)("Spell notes",e._psychicPowers),_&&a.appendChild(_),e._abilities.size>0||e._rules.size>0){const t=a.appendChild(document.createElement("thead"));t.classList.add("info_row");const n=document.createElement("div");if(e._rules.size>0){const t=Array.from(e._rules.keys()).sort(r.Compare).join(", ");n.appendChild(document.createElement("div")).appendChild(document.createElement("b")).appendChild(document.createTextNode(t))}const i=Array.from(e._abilities.keys()).sort(r.Compare);for(const t of i){const r=(0,s.addHideAble)(n.appendChild(document.createElement("div")));r.appendChild(document.createElement("b")).appendChild(document.createTextNode(`${t.toUpperCase()}: `)),r.appendChild(document.createTextNode(e._abilities.get(t)||"??"))}t.appendChild((0,o.createTableRow)(["Abilities",n],[.1,.9],!1))}if(e._factions.size>0){c=a.appendChild(document.createElement("thead")),c.classList.add("info_row");const t=Array.from(e._factions).sort(r.Compare).join(", ").toLocaleUpperCase();c.appendChild((0,o.createTableRow)(["Factions",t],[.1,.9],!1))}if(e._keywords.size>0){c=a.appendChild(document.createElement("thead")),c.classList.add("info_row");const t=Array.from(e._keywords).sort(r.Compare).join(", ").toLocaleUpperCase();c.appendChild((0,o.createTableRow)(["Keywords",t],[.1,.9],!1))}c=a.appendChild(document.createElement("thead")),c.classList.add("info_row");const b=document.createElement("div");for(const t of[e])b.appendChild(document.createElement("div")).appendChild(document.createTextNode(t.nameAndGear()));c.appendChild((0,o.createTableRow)(["MODELS",b],[.1,.9],!1))}printOperative(e,t,n){let r=document.createElement("canvas");if(r.width=7.5*l._res,r.height=12*l._res,r.style.width=r.width.toString(),r.style.height=r.height.toString(),this._descriptionWidth=r.width-this._descriptionStartX-10,e.equal(t))return;const i=this.renderOperative(e,r,0,0);let o=document.createElement("canvas");o.width=i[0]+30,o.height=i[1]+30,o.style.width=o.width.toString(),o.style.height=o.height.toString();let s=o.getContext("2d");if(null==s||s.drawImage(r,15,15),n){let e=document.createElement("div");e.appendChild(o),n.appendChild(e)}}printRules(e,t){if(e.size>0)for(let[n,r]of e.entries()){if(0==r.size)continue;let e=document.createElement("div"),i=document.createElement("h3");e.appendChild(i),i.textContent=n;for(let t of r){let n=document.createElement("div"),r=document.createElement("b");r.textContent=t[0];let i=document.createElement("p");i.setAttribute("style","white-space: pre-wrap;"),i.appendChild(document.createTextNode(t[1]||"")),n.appendChild(r),n.appendChild(i),e.appendChild(n)}t&&t.appendChild(e)}}renderBorder(e,t,n,r,i){e.strokeStyle=l._blackColor,e.beginPath(),e.moveTo(t,n+l._bevelSize),e.lineTo(t,n+i-l._bevelSize),e.lineTo(t+l._bevelSize,n+i),e.lineTo(t+r-l._bevelSize,n+i),e.lineTo(t+r,n+i-l._bevelSize),e.lineTo(t+r,n+l._bevelSize),e.lineTo(t+r-l._bevelSize,n),e.lineTo(t+l._bevelSize,n),e.closePath(),e.stroke(),e.save(),e.fillStyle=l._fillColor,e.globalCompositeOperation="destination-over",e.beginPath(),e.moveTo(t,n+l._bevelSize),e.lineTo(t,n+i-l._bevelSize),e.lineTo(t+l._bevelSize,n+i),e.lineTo(t+r-l._bevelSize,n+i),e.lineTo(t+r,n+i-l._bevelSize),e.lineTo(t+r,n+l._bevelSize),e.lineTo(t+r-l._bevelSize,n),e.lineTo(t+l._bevelSize,n),e.closePath(),e.fill(),e.restore()}renderNotes(e,t,n){n._customNotes&&(this.renderLine(e),e.font=l._headerFont,(0,i.RenderText)(e,t.toLocaleUpperCase(),this._currentX+l._offset,this._currentY,100,16,i.Justification.Left),e.font=l._font,this._currentY+=2,this._currentY=(0,i.RenderParagraph)(e,n._customNotes,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth-l._offset,0),this._currentY+=2)}renderNotesArray(e,t,n){let r=0;for(const e of n)e._customNotes&&r++;if(0!=r){this.renderLine(e),e.font=l._headerFont,(0,i.RenderText)(e,t.toLocaleUpperCase(),this._currentX+l._offset,this._currentY,100,16,i.Justification.Left);for(const t of n){const n=t.name()+":",r=t._customNotes;if(!r)continue;e.font=l._headerFont,this._currentY+=2,(0,i.RenderTextFull)(e,n,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth,16,i.Justification.Left,i.VertAlign.Top);let o=e.measureText(n).width;e.font=l._font,this._currentY=(0,i.RenderParagraph)(e," "+r,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth-l._offset,o),this._currentY+=2}}}renderLine(e){e.lineWidth=2,e.strokeStyle=l._blackColor,e.beginPath(),e.moveTo(this._currentX,this._currentY),e.lineTo(this._currentX+this._maxWidth,this._currentY),e.stroke(),this._currentY+=1}renderTableHeader(e,t,n,r){let o=this._currentX;const s=this._maxWidth;e.fillStyle=l._grey1,e.fillRect(this._currentX,this._currentY,s,22),e.fillStyle=l._blackColor,e.font=l._titleFont;var a=50;if(t){e.font=l._headerFont;for(let s=0;s{a.push(e*this._maxWidth)}));for(let t of e._weapons)o.push(t);for(let t of e._psychicPowers)s.push(t);const c=[],u=new Map;u.has(e.name())||(u.set(e.name(),e),c.push(e)),this.renderNotes(i,"Operative notes",e),this.renderTableHeader(i,l._unitLabels,a,null);let d=0;for(var h of c)this.renderModel(i,h,a,d%2),d++;this.renderNotes(i,"Model notes",e);const f=[],p=new Map;for(const e of o)p.has(e.name())||(p.set(e.name(),e),f.push(e));if(f.length>0){const e=[];this._weaponLabelWidthNormalized.forEach((t=>{e.push(t*this._maxWidth)})),this.renderLine(i),this.renderTableHeader(i,l._weaponLabels,e,l._weaponJustifications),this.renderWeapons(i,f,e)}if(this.renderNotesArray(i,"Weapons notes",o),s.length>0){const e=[];this._spellLabelWidthNormalized.forEach((t=>{e.push(t*this._maxWidth)})),this.renderLine(i),this.renderTableHeader(i,l._spellLabels,e,null),this.renderSpells(i,s,e)}this.renderNotesArray(i,"Spell notes",s),(e._abilities.size>0||e._rules.size>0)&&(this.renderLine(i),this._currentY+=2,this.renderAbilities(i,e)),e._factions.size>0&&(this.renderLine(i),this._currentY+=2,this.renderFactions(i,e)),e._keywords.size>0&&(this.renderLine(i),this._currentY+=2,this.renderKeywords(i,e)),this.renderLine(i),this._currentY+=2,this.renderModelList(i,[e]),this._currentY+=2;const _=this._currentY-(r+l._margin),m=this._maxWidth;return this.renderBorder(i,this._currentX,r+l._margin,m,_),[this._maxWidth,this._currentY]}renderHeader(e,t){t.globalAlpha=1,t.fillStyle=l._blackColor;const n=this._currentX,r=this._currentX+this._maxWidth,o=this._currentY,s=o+36;t.beginPath(),t.moveTo(n,o+l._bevelSize),t.lineTo(n,s),t.lineTo(r,s),t.lineTo(r,o+l._bevelSize),t.lineTo(r-l._bevelSize,o),t.lineTo(n+l._bevelSize,o),t.closePath(),t.fill();let a=n+6;if(this._octagon){t.drawImage(this._octagon,a,o+2,32,32);const n=this._specialisms.get(e._role);n&&t.drawImage(n,a+4,o+2+4,24,24),t.fillStyle="white",t.font="18px serif",a+=34,t.drawImage(this._octagon,a,o+2,32,32),(0,i.RenderText)(t,e.costs().toString(),a,o+2,32,32,i.Justification.Center)}let c=0,u=28;const d=a+6;t.font=u+"px bold serif";const h=e.name().toLocaleUpperCase();let f=t.measureText(h);const p=this._maxWidth-d;for(;c<6&&f.width>p;)c+=1,u-=2,t.font=u+"px bold serif",f=t.measureText(h);t.fillStyle="white",t.textBaseline="top",(0,i.RenderText)(t,h,d,o,p,36,i.Justification.Center),this._currentY+=36}}t.RendererKT21=l,l._res=144,l._margin=0,l._bevelSize=15,l._blackColor="#1d272a",l._grey1="#b3bbb5",l._greyLight="#dde1df",l._fillColor="#f6f6f6",l._offset=20,l._titleFont="bold 14px sans-serif",l._headerFont="bold 14px sans-serif",l._font="14px sans-serif",l._boldFont="bold 14px sans-serif",l._unitLabels=["Operative","M","APL","GA","DF","Save","W"],l._weaponLabels=["WEAPONS","A","WS/BS","D","SR","!"],l._weaponJustifications=[i.Justification.Left,i.Justification.Center,i.Justification.Center,i.Justification.Center,i.Justification.Left,i.Justification.Left],l._spellLabels=["PSYCHIC POWER","DETAILS"]},385:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.renderMESBG=void 0;const n=/\s+/g,r=(e,t="")=>{const n=document.createElement(e);return n.className=t,n},i=(e,t="",n="")=>{const i=r(e,t);return i.appendChild(document.createTextNode(n)),i},o=()=>r("div","mesbg_noBreak mesbg_bumpDown"),s=()=>r("table","mesbg_profileTable mesbg_noBreak mesbg_bumpDown"),a=(e,t)=>{const n=s();return n.appendChild((e=>{const t=r("tr");return e.forEach((e=>{t.appendChild(i("th","",e))})),t})(e)),n.appendChild((e=>{const t=r("tr");return e.forEach((e=>{t.appendChild(i("td","",e))})),t})(t)),n},l=e=>[e.movement,e.fight,e.strength,e.defense,e.attack,e.wounds,e.courage].join("-"),c=e=>i("h2","mesbg_h2",e),u=e=>i("h2","mesbg_h2",e),d={showTracker:!0,showRules:!0,woundChart:!0},h=(e,t)=>{const n=document.createElement("input");n.setAttribute("type","checkbox"),n.setAttribute("name",e),n.setAttribute("id",e),d[e]&&n.setAttribute("checked","checked"),n.addEventListener("change",(e=>()=>{const t=!d[e];d[e]=t;const n=document.querySelector(`.mesbg_${e}`);null!==n&&(t?n.classList.remove("mesbg_hideMe"):n.classList.add("mesbg_hideMe"))})(e));const r=document.createElement("label");return r.setAttribute("for",e),r.appendChild(document.createTextNode(` ${t} `)),r.prepend(n),r},f=["Mv","F","S","D","A","W","C"];t.renderMESBG=(e,t,d,p)=>{if(null!==t){const n=r("div","mesbg_noPrint mesbg_toggleHolder");n.appendChild(h("showRules","show rules text")),n.appendChild(h("showTracker","include hero points tracker")),n.appendChild(h("woundChart","include To Wound Chart")),t.appendChild(n),t.appendChild((_=e.name,i("h1","mesbg_h1",_))),t.appendChild(i("h4","mesbg_rosterInfo",`${e.points} points | ${e.warriors} warriors `))}var _;if(null!==d){const t=r("div","mesbg_container");d.appendChild(t),e.forces.forEach((n=>{t.appendChild(i("h2","mesbg_forceName",n.name)),t.appendChild(i("h4","mesbg_h4 mesbg_bumpDown",`${n.breakpoints.modelCount} models\n | broken at ${n.breakpoints.half} casualties\n | quartered at ${n.breakpoints.quarter} models remaining\n `)),i("p","mesbg_rosterInfo",`${e.points} points | ${e.warriors} warriors `);const o=r("div","mesbg_flexGrid");t.appendChild(o),n.units.forEach((e=>{var t,n;const s=r("div","mesbg_card");s.appendChild(c(`${e.leader.name} - ${e.leader.points}pts ${(null===(t=e.leader.heroStuff)||void 0===t?void 0:t.isLeader)?" (Leader)":""}`)),s.appendChild((e=>i("p","mesbg_equipmentList",e))(`${e.leader.wargear.map((e=>e.name)).join(", ")}${e.leader.mount?", "+(null===(n=e.leader.mount)||void 0===n?void 0:n.name):""}`)),s.appendChild(r("hr","mesbg_bumpDown")),e.warband.forEach((e=>{var t;const n=u(`${e.count} ${e.model.name} - ${e.points}pts`);s.appendChild(n),s.appendChild(i("p","mesbg_equipmentList",`${e.model.wargear.map((e=>e.name)).join(", ")}${e.model.mount?", "+(null===(t=e.model.mount)||void 0===t?void 0:t.name):""}`))})),o.appendChild(s)}))}))}if(null!=p){const t=r("div","mesbg_container");p.appendChild(t),e.forces.forEach((e=>{const d=new Map;e.units.forEach((e=>{var h,p,_,m,g,v,b,y,w,C,x,E;const S=r("div","mesbg_card"),k=r("div","mesbg_twoColumn");S.appendChild(c(`${e.leader.name} - ${e.leader.points}pts`)),S.appendChild(i("h3","mesbg_h3 mesbg_bumpDown",e.leader.keywords.join(", ")));const A=r("div","mesbg_flex mesbg_noBreak");A.appendChild(a(f,[e.leader.profile.movement,e.leader.profile.fight,e.leader.profile.strength,e.leader.profile.defense,e.leader.profile.attack,e.leader.profile.wounds,e.leader.profile.courage])),A.appendChild(a(["M","W","F"],[null!==(p=null===(h=e.leader.heroStuff)||void 0===h?void 0:h.might)&&void 0!==p?p:"-",null!==(m=null===(_=e.leader.heroStuff)||void 0===_?void 0:_.will)&&void 0!==m?m:"-",null!==(v=null===(g=e.leader.heroStuff)||void 0===g?void 0:g.fate)&&void 0!==v?v:"-"])),k.appendChild(A);const T=o();if(T.appendChild(i("h3","mesbg_h3","Wargear")),0===e.leader.wargear.length?T.appendChild(i("i","","none")):T.appendChild(i("p","mesbg_cardWargear",e.leader.wargear.map((e=>e.name)).join(", "))),k.appendChild(T),null!==(y=null===(b=e.leader.heroStuff)||void 0===b?void 0:b.actions.length)&&void 0!==y&&y){const t=o();t.appendChild(i("h3","mesbg_h3","Heroic Actions"));const n=r("ul","mesbg_list mesbg_noBreak mesbg_bumpDown");null===(w=e.leader.heroStuff)||void 0===w||w.actions.forEach((e=>{n.appendChild(r("li")).appendChild(document.createTextNode(e))})),t.appendChild(n),k.appendChild(t)}if(k.appendChild(i("h3","mesbg_h3","Special Rules")),k.appendChild(i("p","mesbg_bumpDown",e.leader.rules.map((e=>e.name)).join(", "))),null!==(x=null===(C=e.leader.heroStuff)||void 0===C?void 0:C.magicalPowers.length)&&void 0!==x&&x){const t=s();t.className="mesbg_powerTable mesbg_noBreak";const n=r("tr");n.appendChild(r("th")).appendChild(i("h3","mesbg_h3","Magical Powers")),n.appendChild(r("th")).appendChild(i("span","","Range")),n.appendChild(r("th")).appendChild(i("span","","Casting")),t.appendChild(n),null===(E=e.leader.heroStuff)||void 0===E||E.magicalPowers.forEach((e=>{const n=r("tr");n.appendChild(r("td")).appendChild(i("span","",e.name)),n.appendChild(r("td")).appendChild(i("span","",e.range)),n.appendChild(r("td")).appendChild(i("span","",e.casting)),t.appendChild(n)})),k.appendChild(t)}if(void 0!==e.leader.mount){const t=o();t.appendChild(u(`Mount: ${e.leader.mount.name}`));const n=r("div","mesbg_flex mesbg_noBreak");n.appendChild(a(f,[e.leader.mount.profile.movement,e.leader.mount.profile.fight,e.leader.mount.profile.strength,e.leader.mount.profile.defense,e.leader.mount.profile.attack,e.leader.mount.profile.wounds,e.leader.mount.profile.courage])),t.append(n),k.append(t)}S.appendChild(k),t.appendChild(S),e.warband.forEach((e=>{const t=e.model,r=(e=>{var t,r;return e.name.trim().replace(n,"-")+(null!==(r=null===(t=e.mount)||void 0===t?void 0:t.name.trim().replace(n,"-"))&&void 0!==r?r:"")})(t);if(d.has(r)){const e=d.get(r),n=l(t.profile),i=null==e?void 0:e.statLines.get(n),o=t.wargear.map((e=>e.name.trim())).join(", ");void 0===i?null==e||e.statLines.set(n,{profile:t.profile,equipments:new Set([o])}):i.equipments.add(o)}else{const e={name:t.name,keywords:t.keywords.join(", "),mount:t.mount,ruleNames:t.rules.map((e=>e.name)).join(", "),statLines:new Map([[l(t.profile),{profile:t.profile,equipments:new Set([t.wargear.map((e=>e.name.trim())).join(", ")])}]])};d.set(r,e)}}))}));const h=r("div","mesbg_twoColumnGrid");d.forEach(((e,t)=>{const n=r("div","mesbg_card"),s=r("div","mesbg_twoColumn");if(n.appendChild(u(e.name)),n.appendChild(i("p","mesbg_cardWargear mesbg_bumpDown",e.keywords)),e.statLines.forEach(((e,t)=>{const n=r("div","mesbg_noBreak");n.appendChild(i("h3","mesbg_h3","Wargear")),e.equipments.forEach((e=>{n.appendChild(i("p","mesbg_cardWargear",e))})),n.appendChild(a(f,[e.profile.movement,e.profile.fight,e.profile.strength,e.profile.defense,e.profile.attack,e.profile.wounds,e.profile.courage])),s.appendChild(n)})),e.ruleNames.length>0&&(s.appendChild(i("h3","mesbg_h3","Special Rules")),s.appendChild(i("p","mesbg_bumpDown",e.ruleNames))),void 0!==e.mount){const t=o();t.appendChild(u(`Mount: ${e.mount.name}`));const n=r("div","mesbg_flex mesbg_noBreak");n.appendChild(a(f,[e.mount.profile.movement,e.mount.profile.fight,e.mount.profile.strength,e.mount.profile.defense,e.mount.profile.attack,e.mount.profile.wounds,e.mount.profile.courage])),t.append(n),s.append(t)}n.appendChild(s),h.appendChild(n)})),t.appendChild(h)}));const d=new Set,h=r("div","mesbg_pageBreak mesbg_showRules");h.appendChild(i("h1","mesbg_h1","Rules"));const _=r("div","mesbg_twoColumn");e.forces.forEach((n=>{n.armyBonus.forEach((e=>{_.appendChild(i("h3","mesbg_h3",`"${e.name}" (Army Bonus)`)),_.appendChild(i("p","mesbg_bumpDown",e.ruleText))})),n.units.forEach((e=>{e.leader.rules.forEach((e=>{!1===d.has(e.name)&&(_.appendChild(i("h3","mesbg_h3",e.name)),_.appendChild(i("p","mesbg_bumpDown",e.ruleText)),d.add(e.name))})),e.warband.forEach((e=>{e.model.rules.forEach((e=>{!1===d.has(e.name)&&(_.appendChild(i("h3","mesbg_h3",e.name)),_.appendChild(i("p","mesbg_bumpDown",e.ruleText)),d.add(e.name))}))}))})),h.appendChild(_),t.appendChild(h);const o=r("table","mesbg_pageBreak mesbg_trackerTable mesbg_showTracker");o.innerHTML="MWF",e.forces.forEach((e=>{e.units.forEach((e=>{const t=r("tr");t.innerHTML=`

${e.leader.name}

`,o.appendChild(t)}))})),t.appendChild(o);const s=r("table","mesbg_pageBreak mesbg_woundChart");s.innerHTML='\n \n \n  Defence\n \n \n \n \n Strength\n   1 2 3 4 5 6 7 8 9 10\n \n \n 1 4 5 5 6 6 6/4 6/5 6/6 - -\n \n \n 2 4 4 5 5 6 6 6/4 6/5 6/6 -\n \n \n 3 3 4 4 5 5 6 6 6/4 6/5 6/6\n \n \n 4 3 3 4 4 5 5 6 6 6/4 6/5\n \n \n 5 3 3 3 4 4 5 5 6 6 6/4 \n \n 6 3 3 3 3 4 4 5 5 6 6\n \n \n 7 3 3 3 3 3 4 4 5 5 6\n \n \n 8 3 3 3 3 3 3 4 4 5 5\n \n \n 9 3 3 3 3 3 3 3 4 4 5\n \n \n 10 3 3 3 3 3 3 3 3 4 4\n \n \n ',t.appendChild(s)}))}}},717:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RendererWarcry=void 0;const r=n(320);t.RendererWarcry=class{constructor(e){this._roster=null,this._roster=e}render(e,t,n){if(null!=this._roster){e&&(e.innerHTML="

"+this._roster._name+" ("+this._roster._points+" pts

");for(let e of this._roster._forces){const i=document.createElement("div");i&&(i.innerHTML="

"+e._catalog+" "+e._name+"

"),t&&t.appendChild(i);const o=document.createElement("table");o.classList.add("table"),o.classList.add("table-sm"),o.classList.add("table-striped");const s=document.createElement("thead");o.appendChild(s),s.classList.add("thead-light");const a=document.createElement("tr");s.appendChild(a),[{name:"NAME",w:"35%"},{name:"ROLE",w:"25%"},{name:"POINTS",w:"15%"}].forEach((e=>{let t=document.createElement("th");t.scope="col",t.innerHTML=e.name,t.style.width=e.w,a.appendChild(t)})),i.appendChild(o);let l=document.createElement("tbody");o.appendChild(l);for(let t of e._units){let e=document.createElement("tr"),n=document.createElement("td");n.innerHTML=t._name;let i=document.createElement("td");i.innerHTML=r.WarcryUnitRoleToString[t._role];let o=document.createElement("td");o.innerHTML=t._points.toString(),e.appendChild(n),e.appendChild(i),e.appendChild(o),l.appendChild(e)}let c=document.createElement("div");if(e._allegiance._rules.size>0){let t=document.createElement("h3");c.appendChild(t),t.textContent=e._allegiance._name+" Abilities";for(let t of e._allegiance._rules){let e=document.createElement("div"),n=document.createElement("h4");n.textContent=t[0];let r=document.createElement("p");r.textContent=t[1],e.appendChild(n),e.appendChild(r),c.appendChild(e)}}if(!n)return;n.appendChild(c);let u=document.createElement("div");for(let t of e._units){u.appendChild(this.renderUnitHtml(t));let e=document.createElement("hr");e.className="aos_dark",u.appendChild(e)}n.appendChild(u)}}}createCharacteristicCard(e,t){let n=document.createElement("div");return n.className="col",n.innerHTML=`\n
\n \n
\n

${t}

\n
\n
`,n}createWeapon(e,t){let n=document.createElement("p");n.className="card-title warcry_font",n.innerHTML=e._name,t.appendChild(n);let r=document.createElement("div");r.className="row",t.appendChild(r);let i=this.getWeaponTypeRunemark(e._name),o=document.createElement("div");o.className="col",o.innerHTML=`\n
\n \n
`,r.appendChild(o);let s=this.createCharacteristicCard("range",e._range);r.appendChild(s);let a=this.createCharacteristicCard("attacks",e._attacks);r.appendChild(a);let l=this.createCharacteristicCard("strength",e._strength);r.appendChild(l);let c=this.createCharacteristicCard("damage",e._damage);r.appendChild(c)}renderUnitHtml(e){let t=document.createElement("div");t.className="container-fluid warcry_unit border bg-light";let n=document.createElement("div");n.className="row align-items-center",t.append(n);let r=document.createElement("div");r.className="col-1",r.innerHTML=``,n.appendChild(r);let i=document.createElement("div");i.className="col",i.innerHTML=`${e._name}`,n.appendChild(i);let o=document.createElement("div");o.className="col-4",n.appendChild(o);for(let t of e._keywords){const e=this.getAbilityRunemark(t);if(""!=e){let t=new Image;t.className="border border-dark rounded-circle warcry_card",t.src=`./assets/warcry/runemarks/black/fighters-${e}.svg`,o.appendChild(t)}}let s=document.createElement("div");s.className="col-1",s.innerHTML=`
${e._points}
`,n.appendChild(s);let a=document.createElement("div");a.className="row align-items-center",t.append(a);let l=document.createElement("div");l.className="col-7",a.appendChild(l),2==e._weapons.length&&this.createWeapon(e._weapons[1],l);let c=document.createElement("div");c.className="col",a.appendChild(c);let u=document.createElement("div");u.className="row align-items-center",t.append(u);let d=document.createElement("div");d.className="col-7",u.appendChild(d),e._weapons.length>=1&&this.createWeapon(e._weapons[0],d);let h=document.createElement("div");h.className="col",u.appendChild(h);let f=document.createElement("div");f.className="row",h.appendChild(f);let p=document.createElement("div");p.className="col",f.appendChild(p);let _=this.createCharacteristicCard("move",e._move.toString());f.appendChild(_);let m=this.createCharacteristicCard("toughness",e._toughness.toString());f.appendChild(m);let g=this.createCharacteristicCard("wounds",e._wounds.toString());if(f.appendChild(g),e._damageTable.length>0){let n=document.createElement("div");n.className="row w-75 align-items-center",t.append(n);let r=document.createElement("div");r.className="p-2 mb-2 text-center text-uppercase text-black",r.innerHTML='Damage Table',n.appendChild(r);let i=[{name:"Damage Points Allocated",width:"50%"},{name:"Move",width:"25%"},{name:"Damage ",width:"25%"}],o=1;for(let t of e._damageTable[0]._table)i[o++].name=t[0];const s=this.createTable(i);n.appendChild(s);let a=document.createElement("tbody");s.appendChild(a);for(let t of e._damageTable){let e=document.createElement("tr"),n=document.createElement("td");n.innerHTML=t._name,e.appendChild(n);for(let n of t._table){let t=document.createElement("td");t.innerHTML=n[1],e.appendChild(t)}a.appendChild(e)}}return t}createTable(e){const t=document.createElement("table");t.className="table table-bordered table-sm text-center";const n=document.createElement("thead");t.appendChild(n),n.classList.add("warcry_light");const r=document.createElement("tr");return n.appendChild(r),e.forEach((e=>{let t=document.createElement("th");t.scope="col",t.innerHTML=e.name,t.style.width=e.width,r.appendChild(t)})),t}getAbilityRunemark(e){const t=e.toLowerCase();return t.includes("agile")?"agile":t.includes("ally")?"ally":t.includes("beast")?"beast":t.includes("berserker")?"berserker":t.includes("brute")?"brute":t.includes("bulwark")?"bulwark":t.includes("champion")?"champion":t.includes("destroyer")?"destroyer":t.includes("elite")?"elite":t.includes("ferocious")?"ferocious":t.includes("fly")?"fly":t.includes("frenzied")?"frenzied":t.includes("gargantuan")?"gargantuan":t.includes("icon")?"icon-bearer":t.includes("leader")?"leader":t.includes("minion")?"minion":t.includes("mount")?"mount":t.includes("mystic")?"mystic":t.includes("priest")?"priest":t.includes("scout")?"scout":t.includes("sentience")?"sentience":t.includes("terrifying")?"terrifying":t.includes("thrall")?"thrall":t.includes("trapper")?"trapper":t.includes("warrior")?"warrior":""}getWeaponTypeRunemark(e){const t=e.toLowerCase();return t.includes("axe")||t.includes("cleaver")?"axe":t.includes("claws")||t.includes("talon")||t.includes("grasping")||t.includes("pincher")?"claws":t.includes("club")?"club":t.includes("dagger")||t.includes("shank")?"dagger":t.includes("fangs")||t.includes("teeth")||t.includes("jaws")||t.includes("maw")?"fangs":t.includes("hammer")||t.includes("anvil")?"hammer":t.includes("mace")||t.includes("staff")||t.includes("stave")||t.includes("flail")?"mace":t.includes("scythe")?"scythe":t.includes("spear")||t.includes("glaive")||t.includes("halberd")||t.includes("lance")||t.includes("harpoon")||t.includes("polearm")?"spear":t.includes("sword")||t.includes("blade")||t.includes("sickles")?"sword":t.includes("arcane bolt")||t.includes("sorcerous bolt")?"blast":t.includes("bow")||t.includes("bolas")||t.includes("cannon")||t.includes("pistol")||t.includes("javelin")?"ranged-weapon":t.includes("whip")?"reach-weapon":"unarmed"}}},391:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Create30kRoster=t.Roster30k=t.Force30k=t.Unit30k=t.Fortification30k=t.Model30k=t.Flyer30k=t.Walker30k=t.Vehicle30k=t.UnitRoleToString30k=t.UnitRole30k=t.PsychicPower30k=t.Psyker30k=t.Weapon30k=void 0;class n{constructor(){this._name="",this._range="Melee",this._str="user",this._ap="",this._type="Melee"}}t.Weapon30k=n;class r{constructor(){this._name="",this._masteryLevel="",this._disciplines=""}}t.Psyker30k=r;class i{constructor(){this._name="",this._warpCharge=0,this._category="",this._range="",this._details=""}}var o;t.PsychicPower30k=i,function(e){e[e.NONE=0]="NONE",e[e.HQ=1]="HQ",e[e.TR=2]="TR",e[e.EL=3]="EL",e[e.FA=4]="FA",e[e.HS=5]="HS",e[e.FL=6]="FL",e[e.DT=7]="DT",e[e.FT=8]="FT",e[e.LW=9]="LW"}(o=t.UnitRole30k||(t.UnitRole30k={})),t.UnitRoleToString30k=["None","HQ","Troops","Elites","Fast Attack","Heavy Support","Flyer","Dedicated Transport","Fortification","Lord of War"];class s{constructor(){this._name="",this._bs="",this._front=4,this._side=4,this._rear=4,this._hp=1,this._type="",this._weapons=[]}}t.Vehicle30k=s;class a{constructor(){this._name="",this._ws="",this._bs="",this._str=4,this._front=4,this._side=4,this._rear=4,this._initiative=1,this._attacks="",this._hp=1,this._type="",this._weapons=[]}}t.Walker30k=a;class l{constructor(){this._name="",this._bs="",this._front=4,this._side=4,this._rear=4,this._hp=1,this._type="",this._role="",this._pursuit="",this._agility="",this._weapons=[]}}t.Flyer30k=l;class c{constructor(){this._name="",this._count=0,this._ws="",this._bs="",this._str=4,this._toughness=4,this._wounds=1,this._initiative=1,this._attacks="",this._leadership=7,this._save="",this._weapons=[],this._psyker=null,this._psychicPowers=[]}}t.Model30k=c,t.Fortification30k=class{constructor(){this._name="",this._composition="",this._type=""}};class u{constructor(){this._name="",this._role=o.NONE,this._factions=new Set,this._keywords=new Set,this._abilities=new Map,this._rules=new Map,this._models=[],this._walkers=[],this._vehicles=[],this._flyers=[],this._points=0}}t.Unit30k=u;class d{constructor(){this._catalog="",this._name="Unknown",this._faction="Unknown",this._rules=new Map,this._units=[]}}t.Force30k=d;class h{constructor(){this._commandPoints=0,this._points=0,this._name="",this._forces=[]}}function f(e,t){if(!t||!e)return!1;for(let n of t._forces)if(n._catalog===e._catalog)return!0;return!1}function p(e,t){let n=e.querySelectorAll("force>selections>selection");for(let e of n){let n=m(e);n&&n._role!=o.NONE&&t._units.push(n)}t._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?0:-1))}function _(e){switch(e){case"HQ":return o.HQ;case"Troops":return o.TR;case"Elites":return o.EL;case"Fast Attack":return o.FA;case"Heavy Support":return o.HS;case"Flyer":return o.FL;case"Dedicated Transport":return o.DT;case"Fortification":return o.FT;case"Lord of War":return o.LW}return o.NONE}function m(e){var t,d,h,f,p,m,g,v,b,y,w,C,x,E,S,k,A,T,N;let L=new u,R=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;R&&(L._name=R);let P=e.querySelectorAll(":scope categories>category");for(let e of P){let t=null===(d=e.getAttributeNode("name"))||void 0===d?void 0:d.nodeValue;if(t){const e="Faction: ",n=t.lastIndexOf(e);if(n>=0){const r=t.slice(n+e.length);L._factions.add(r)}else{const e=_(t.trim());e!=o.NONE?L._role=e:L._keywords.add(t)}}}let O=null,W=null,z=null,I=null,B=e.querySelectorAll(":scope profiles>profile");for(let e of B){let t=null===(h=e.getAttributeNode("name"))||void 0===h?void 0:h.nodeValue,n=null===(f=e.getAttributeNode("typeName"))||void 0===f?void 0:f.nodeValue;if(t&&n)if("Unit"===n){O=new c,O._name=t;let n=e.querySelectorAll("characteristics>characteristic");for(let t of n){let n=null===(p=t.getAttributeNode("name"))||void 0===p?void 0:p.nodeValue;if(n&&t.textContent)switch(n){case"WS":O._ws=t.textContent;break;case"BS":O._bs=t.textContent;break;case"S":O._str=+t.textContent;break;case"T":O._toughness=+t.textContent;break;case"W":O._wounds=+t.textContent;break;case"I":O._initiative=+t.textContent;break;case"A":O._attacks=t.textContent;break;case"LD":O._leadership=+t.textContent;break;case"Save":O._save=t.textContent}if(e.parentElement&&e.parentElement.parentElement){let t=null===(m=e.parentElement.parentElement.getAttributeNode("number"))||void 0===m?void 0:m.nodeValue;t&&(O._count=+t)}}L._models.push(O)}else if("Walker"===n){W=new a,W._name=t;let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let t=null===(g=e.getAttributeNode("name"))||void 0===g?void 0:g.nodeValue;if(t&&e.textContent)switch(t){case"WS":W._ws=e.textContent;break;case"BS":W._bs=e.textContent;break;case"S":W._str=+e.textContent;break;case"Front":W._front=+e.textContent;break;case"Side":W._side=+e.textContent;break;case"Rear":W._rear=+e.textContent;break;case"I":W._initiative=+e.textContent;break;case"A":W._attacks=e.textContent;break;case"HP":W._hp=+e.textContent;break;case"Type":W._type=e.textContent}}L._walkers.push(W)}else if("Vehicle"===n){z=new s,z._name=t;let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let t=null===(v=e.getAttributeNode("name"))||void 0===v?void 0:v.nodeValue;if(t&&e.textContent)switch(t){case"BS":z._bs=e.textContent;break;case"Front":z._front=+e.textContent;break;case"Side":z._side=+e.textContent;break;case"Rear":z._rear=+e.textContent;break;case"HP":z._hp=+e.textContent;break;case"Type":z._type=e.textContent}}L._vehicles.push(z)}else if("Flyer"===n){I=new l,I._name=t;let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let t=null===(b=e.getAttributeNode("name"))||void 0===b?void 0:b.nodeValue;if(t&&e.textContent)switch(t){case"BS":I._bs=e.textContent;break;case"Front":I._front=+e.textContent;break;case"Side":I._side=+e.textContent;break;case"Rear":I._rear=+e.textContent;break;case"HP":I._hp=+e.textContent;break;case"Combat Role":I._role=e.textContent;break;case"Pursuit":I._pursuit=e.textContent;break;case"Agility":I._agility=e.textContent}}L._flyers.push(I)}}for(let e of B){let t=null===(y=e.getAttributeNode("name"))||void 0===y?void 0:y.nodeValue,o=null===(w=e.getAttributeNode("typeName"))||void 0===w?void 0:w.nodeValue;if(t&&o){if("Wargear Item"===o){let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let n=null===(C=e.getAttributeNode("name"))||void 0===C?void 0:C.nodeValue;n&&e.textContent&&t&&"Description"===n&&L._abilities.set(t,e.textContent)}}else if("Weapon"===o){let r=new n;r._name=t;let i=e.querySelectorAll("characteristics>characteristic");for(let e of i){let t=null===(x=e.getAttributeNode("name"))||void 0===x?void 0:x.nodeValue;if(t&&e.textContent)switch(t){case"Range":r._range=e.textContent;break;case"Type":r._type=e.textContent;break;case"Strength":r._str=e.textContent;break;case"AP":r._ap=e.textContent}}O?O._weapons.push(r):W?W._weapons.push(r):z?z._weapons.push(r):I?I._weapons.push(r):console.log("Unexpected: Created a weapon without an active model. Unit: "+R)}else if("Transport"==o){let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let n=null===(E=e.getAttributeNode("name"))||void 0===E?void 0:E.nodeValue;n&&e.textContent&&t&&"Capacity"===n&&L._abilities.set(t,e.textContent)}}else if("Psychic Power"==o){let n=new i;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(S=e.getAttributeNode("name"))||void 0===S?void 0:S.nodeValue;if(t&&e.textContent)switch(t){case"Warp Charge":n._warpCharge=+e.textContent;break;case"Power Category":n._category=e.textContent;break;case"Range":n._range=e.textContent;break;case"Details":n._details=e.textContent}}O?O._psychicPowers.push(n):console.log("Unexpected: Created a psychic power without an active model. Unit: "+R)}else if("Psyker"==o){let n=new r;n._name=t;let i=e.querySelectorAll("characteristics>characteristic");for(let e of i){let t=null===(k=e.getAttributeNode("name"))||void 0===k?void 0:k.nodeValue;if(t&&e.textContent)switch(t){case"Mastery Level":n._masteryLevel=e.textContent;break;case"Disciplines":n._disciplines=e.textContent}}O?O._psyker=n:console.log("Unexpected: Created a psyker without an active model. Unit: "+R)}}else"Unit"===o||"Walker"===o||"Vehicle"===o||console.log("Unknown property type: "+o)}let M=e.querySelectorAll(":scope costs>cost");for(let e of M)if(e.hasAttribute("name")&&e.hasAttribute("value")){let t=null===(A=e.getAttributeNode("name"))||void 0===A?void 0:A.nodeValue,n=null===(T=e.getAttributeNode("value"))||void 0===T?void 0:T.nodeValue;n&&"pts"==t&&(L._points+=+n)}let U=e.querySelectorAll(":scope rules > rule");for(let e of U)if(e.hasAttribute("name")){let t=null===(N=e.getAttributeNode("name"))||void 0===N?void 0:N.nodeValue,n=e.querySelector("description");t&&n&&n.textContent&&L._rules.set(t,n.textContent)}return L}t.Roster30k=h,t.Create30kRoster=function(e){var t;if(e){let n=e.querySelector("roster");if(n){const r=new h,i=null===(t=n.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;return r._name=i||"30k Army Roster",function(e,t){var n,r;let i=e.querySelectorAll("roster>costs>cost");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("value")){let i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("value"))||void 0===r?void 0:r.nodeValue;o&&("pts"===i?t._points=+o:"CP"===i&&(t._commandPoints=+o))}}(e,r),function(e,t){var n,r,i;let o=e.querySelectorAll("roster>forces>force");for(let e of o)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let o=new d,s=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,a=null===(r=e.getAttributeNode("catalogueName"))||void 0===r?void 0:r.nodeValue;if(s&&(o._name=s),a&&(o._catalog=a),!f(o,t)){const t=e.querySelectorAll("force>rules>rule");for(let e of t)if(e.hasAttribute("name")){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;const n=e.querySelector("rule>description");t&&n&&o._rules.set(t,n.textContent)}}p(e,o),t._forces.push(o)}}(e,r),r}}return null}},288:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Compare=t.CompareWeapon=t.Create40kRoster=t.Costs=t.Roster40k=t.Force=t.Unit=t.Model=t.UnitRoleToString=t.UnitRole=t.PsychicPower=t.Psyker=t.Explosion=t.WoundTracker=t.Weapon=t.Upgrade=t.BaseNotes=void 0;const s=o(n(486));class a{constructor(){this._name="",this._customName="",this._customNotes=""}name(){return this._customName?this._customName:this._name}notes(){return this._customNotes}equal(e){return null!=e&&this._name===e._name}}t.BaseNotes=a;class l extends a{constructor(){super(...arguments),this._cost=new b,this._count=1}selectionName(){return this.name()}toString(){let e=this.selectionName();return this._count>1&&(e=`${this._count}x ${e}`),this._cost.hasValues()&&(e+=` ${this._cost.toString()}`),e}}t.Upgrade=l;class c extends l{constructor(){super(...arguments),this._selectionName="",this._range="Melee",this._type="Melee",this._str="user",this._ap="",this._damage="",this._abilities=""}selectionName(){return this._selectionName||this.name()}}t.Weapon=c;class u extends a{constructor(){super(...arguments),this._name="",this._table=new Map}}t.WoundTracker=u;class d extends a{constructor(){super(...arguments),this._name="",this._diceRoll="",this._distance="",this._mortalWounds=""}}t.Explosion=d;class h extends a{constructor(){super(...arguments),this._cast="",this._deny="",this._powers="",this._other=""}}t.Psyker=h;class f extends a{constructor(){super(...arguments),this._name="",this._manifest=0,this._range="",this._details=""}}var p;t.PsychicPower=f,function(e){e[e.NONE=0]="NONE",e[e.SCD=1]="SCD",e[e.HQ=2]="HQ",e[e.TR=3]="TR",e[e.EL=4]="EL",e[e.FA=5]="FA",e[e.HS=6]="HS",e[e.FL=7]="FL",e[e.DT=8]="DT",e[e.FT=9]="FT",e[e.LW=10]="LW",e[e.AGENTS=11]="AGENTS",e[e.NF=12]="NF",e[e.COMMANDER=13]="COMMANDER",e[e.LEADER=14]="LEADER",e[e.SPECIALIST=15]="SPECIALIST",e[e.NON_SPECIALIST=16]="NON_SPECIALIST"}(p=t.UnitRole||(t.UnitRole={})),t.UnitRoleToString=["None","Supreme Command Detachment","HQ","Troops","Elites","Fast Attack","Heavy Support","Flyer","Dedicated Transport","Fortification","Lord of War","Agent of the Imperium","No Force Org Slot","Commander","Leader","Specialist","Non-specialist"];class _ extends a{constructor(){super(...arguments),this._count=0,this._move='0"',this._ws="",this._bs="",this._str=4,this._toughness=4,this._wounds=1,this._attacks="",this._leadership=7,this._save="",this._weapons=[],this._upgrades=[],this._psyker=null,this._psychicPowers=[],this._explosions=[]}equal(e){if(null==e)return!1;if(this._name===e._name&&this._count===e._count&&this._weapons.length===e._weapons.length&&this._upgrades.length===e._upgrades.length){for(let t=0;t0||this._upgrades.length>0)&&(e+=` (${this.getDedupedWeaponsAndUpgrades().map((e=>e.toString())).join(", ")})`),e}getDedupedWeaponsAndUpgrades(){const e=[];for(const t of[...this._weapons,...this._upgrades])e.some((e=>t.selectionName()===e.selectionName()))||e.push(t);return e}normalize(){this._weapons.sort(q),this._upgrades.sort(D),this.normalizeUpgrades(this._weapons),this.normalizeUpgrades(this._upgrades)}normalizeUpgrades(e){for(let t=0;t(e._count>1?`${e._count}x `:"")+e.nameAndGear())),this._weapons=this._models.map((e=>e._weapons)).reduce(((e,t)=>e.concat(t)),[]).sort(q).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())})),this._spells.push(...this._models.map((e=>e._psychicPowers)).reduce(((e,t)=>e.concat(t)),[])),this._psykers.push(...this._models.map((e=>e._psyker)).filter((e=>e))),this._explosions.push(...this._models.map((e=>e._explosions)).reduce(((e,t)=>e.concat(t)),[]))}}t.Unit=m;class g extends a{constructor(){super(...arguments),this._catalog="",this._faction="Unknown",this._factionRules=new Map,this._configurations=[],this._rules=new Map,this._units=[]}}t.Force=g;class v extends a{constructor(){super(...arguments),this._cost=new b,this._forces=[]}}t.Roster40k=v;class b{constructor(){this._powerLevel=0,this._commandPoints=0,this._points=0}hasValues(){return 0!==this._powerLevel||0!==this._commandPoints||0!==this._points}toString(){const e=[];return 0!==this._points&&e.push(`${this._points} pts`),0!==this._powerLevel&&e.push(`${this._powerLevel} PL`),0!==this._commandPoints&&e.push(`${this._commandPoints} CP`),`[${e.join(" / ")}]`}add(e){this._powerLevel+=e._powerLevel,this._commandPoints+=e._commandPoints,this._points+=e._points;for(const t in e._freeformValues)this.addFreeformValue(t,e._freeformValues[t])}addFreeformValue(e,t){this._freeformValues||(this._freeformValues={});const n=this._freeformValues[e]||0;this._freeformValues[e]=n+t}}function y(e,t,n){var r;let i=e.querySelectorAll("force>selections>selection");for(let e of i){let i=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue;if(i)if(i.includes("Detachment Command Cost"));else if("Battle Size"===i||"Gametype"===i)w(e,t);else if(e.querySelector('profile[typeName="Unit"]')){const r=P(e,n);t._units.push(r);for(const e of r._rules.entries())t._rules.set(e[0],e[1])}else if("upgrade"===e.getAttribute("type")){x(e,t._rules),w(e,t);const n=e.querySelectorAll("selections>selection");for(let e of n){const n=e.getAttribute("name");n&&"upgrade"===e.getAttribute("type")&&("Unknown"===t._faction&&(t._faction=n),x(e,t._factionRules))}}else console.log("** UNEXPECTED SELECTION **",i,e)}for(const e of t._factionRules.keys())t._rules.delete(e);t._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?e._name>t._name?1:e._name==t._name?0:-1:-1))}function w(e,t){var n;const r=e.getAttribute("name");if(!r)return;const i=null===(n=e.querySelector("category"))||void 0===n?void 0:n.getAttribute("name"),o=e.querySelectorAll("selections>selection"),s=[];let a=L(e);for(const e of o)s.push(e.getAttribute("name")),a.add(L(e));let l=i&&"Configuration"!==i?`${i} - ${r}`:r;s.length>0&&(l+=`: ${s.join(", ")}`),a.hasValues()&&(l+=` ${a.toString()}`),t._configurations.push(l)}function C(e,t){if(!t||!e)return!1;for(let n of t._forces)if(n._catalog===e._catalog)return!0;return!1}function x(e,t){const n=e.querySelectorAll("profiles>profile");for(const e of n){const n=e.getAttribute("name");if(!n)continue;const r=e.getAttribute("typeName");"Abilities"!==r&&"Dynastic Code"!==r&&"Household Tradition"!==r||W(e,n,0,t)}const r=e.querySelectorAll("rules>rule");for(const e of r)E(e,t)}function E(e,t){const n=e.getAttribute("name"),r=e.querySelector("description");n&&(null==r?void 0:r.textContent)&&t.set(n,r.textContent)}function S(e){switch(e){case"HQ":return p.HQ;case"Troops":return p.TR;case"Elites":return p.EL;case"Fast Attack":return p.FA;case"Heavy Support":return p.HS;case"Flyer":return p.FL;case"Dedicated Transport":return p.DT;case"Fortification":return p.FT;case"Lord of War":return p.LW;case"Agent of the Imperium":return p.AGENTS;case"No Force Org Slot":return p.NF;case"Primarch | Daemon Primarch | Supreme Commander":return p.SCD}return p.NONE}function k(e){switch(e){case"Commander":return p.COMMANDER;case"Leader":return p.LEADER;case"Specialist":return p.SPECIALIST;case"Non-specialist":return p.NON_SPECIALIST}return p.NONE}function A(e,t){var n,r;t._name=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;let i=e;"profile"===e.tagName&&e.parentElement&&e.parentElement.parentElement&&(i=e.parentElement.parentElement),t._customName=null===(r=i.getAttributeNode("customName"))||void 0===r?void 0:r.nodeValue;let o=i.firstElementChild;return o&&"customNotes"===o.tagName&&(t._customNotes=o.textContent),t._name}function T(e){const t=[];for(const n of e.children)if("selections"===n.tagName)for(const e of n.children)"selection"===e.tagName&&t.push(e);return t}function N(e,t){for(const n of e.children)if("profiles"===n.tagName)for(const e of n.children)if("profile"===e.tagName&&e.getAttribute("typeName")===t)return!0;return!1}function L(e){const t=new b;for(const n of e.children)if("costs"===n.tagName)for(const e of n.children)t.add(R(e));return t}function R(e){const t=new b,n=e.getAttribute("name"),r=e.getAttribute("value");return n&&r&&(" PL"===n?t._powerLevel+=+r:"pts"===n?t._points+=+r:"CP"===n?t._commandPoints+=+r:t.addFreeformValue(n,+r)),t}function P(e,t){var n;let r=new m;A(e,r);let i=e.querySelectorAll("categories>category");for(let e of i){const i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;if(i){const e="Faction: ",n=i.lastIndexOf(e);if(n>=0){const t=i.slice(n+e.length);r._factions.add(t)}else{const e=i.trim();let n=S(e);n!=p.NONE?r._role=n:t?r._keywords.add(i):(n=k(e),n!=p.NONE?r._role=n:r._keywords.add(i))}}}const o=[],s=Array.from(e.querySelectorAll('profile[typeName="Unit"],profile[typeName="Model"]'));!function(e,t,n){for(const n of e){const e=n.getAttribute("name"),r=n.getAttribute("typeName");if(!e||!r)return;const i=new _;i._name=e,t._modelStats.push(i),A(n,i);const o=n.querySelectorAll("characteristics>characteristic");for(const e of o){const t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"M":i._move=e.textContent;break;case"WS":i._ws=e.textContent;break;case"BS":i._bs=e.textContent;break;case"S":i._str=+e.textContent;break;case"T":i._toughness=+e.textContent;break;case"W":i._wounds=+e.textContent;break;case"A":i._attacks=e.textContent;break;case"Ld":i._leadership=+e.textContent;break;case"Save":i._save=e.textContent}}}}(s,r),o.push(...s);const a=[];if("model"===e.getAttribute("type"))a.push(e);else{const t=T(e);for(const e of t)("model"===e.getAttribute("type")||N(e,"Unit"))&&a.push(e);0===a.length&&a.push(...Array.from(e.querySelectorAll('selection[type="model"]'))),0===a.length&&N(e,"Unit")&&a.push(e)}for(const e of a){const t=Array.from(e.querySelectorAll("profiles>profile")),n=t.filter((e=>!o.includes(e)));o.push(...n);const i=new _;i._name=e.getAttribute("name")||"Unknown Model",i._count=Number(e.getAttribute("number")||1),r._models.push(i),O(t,i,r);for(const t of e.querySelectorAll('selections>selection[type="upgrade"]')){if(t.querySelector('selections>selection[type="upgrade"]')&&!N(t,"Abilities"))continue;let e=t.getAttribute("name");if(e){const n=new l;n._name=e,n._cost=L(t),n._count=Number(t.getAttribute("number")),i._upgrades.push(n)}}}let c=Array.from(e.querySelectorAll("profiles>profile")).filter((e=>!o.includes(e)));if(o.push(...c),c.length>0){const t=new _;if(t._name="Unit Upgrades",O(c,t,r),t._weapons.length>0&&r._models.length>0){for(const e of r._models)e._weapons.push(...t._weapons);t._weapons.length=0}t._psychicPowers.length>0&&(r._spells.push(...t._psychicPowers),t._psychicPowers.length=0),t._psyker&&(r._psykers.push(t._psyker),t._psyker=null),t._explosions.length>0&&(r._explosions.push(...t._explosions),t._explosions.length=0);for(const n of T(e)){if("upgrade"!==n.getAttribute("type"))continue;if(a.includes(n))continue;if(n.querySelector('profiles>profile[typeName="Weapon"]'))continue;let e=n.getAttribute("name");if(!e)continue;const r=new l;r._name=e,r._cost=L(n),r._count=Number(n.getAttribute("number")),t._upgrades.push(r)}(t._weapons.length>0||t._upgrades.length>0)&&r._models.push(t)}let u=e.querySelectorAll("costs>cost");for(let e of u)r._cost.add(R(e));let d=e.querySelectorAll("rules > rule");for(let e of d)E(e,r._rules);return r.normalize(),r}function O(e,t,n){for(const r of e){const e=r.getAttribute("name"),i=r.getAttribute("typeName");if(e&&i)if("Unit"===i||"Model"===i||"model"===r.getAttribute("type"));else if("Weapon"===i){const e=z(r);t._weapons.push(e)}else if(i.includes("Wound Track")||i.includes("Stat Damage")||i.includes(" Wounds")){const e=I(r);n._woundTracker.push(e)}else if("Psychic Power"==i){const e=B(r);t._psychicPowers.push(e)}else if(i.includes("Explosion")){const e=M(r);t._explosions.push(e)}else"Psyker"==i?t._psyker=U(r):(n._abilities[i]||(n._abilities[i]=new Map),W(r,e,0,n._abilities[i]))}}function W(e,t,n,r){const i=e.querySelectorAll("characteristics>characteristic");for(const e of i){if(!e.textContent)continue;const n=e.getAttribute("name");n&&i.length>1?r.set([t,n.toString()].join(" - "),e.textContent):r.set(t,e.textContent)}}function z(e){var t;const n=new c;A(e,n),n._count=function(e){var t;if(e.parentElement&&e.parentElement.parentElement){const n=null===(t=e.parentElement.parentElement.getAttributeNode("number"))||void 0===t?void 0:t.nodeValue;if(n)return+n}return 0}(e);let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"Range":n._range=e.textContent;break;case"Type":n._type=e.textContent;break;case"S":n._str=e.textContent;break;case"AP":n._ap=e.textContent;break;case"D":n._damage=e.textContent;break;case"Abilities":n._abilities=e.textContent}}const i=null===(t=e.parentElement)||void 0===t?void 0:t.parentElement,o=null==i?void 0:i.getAttribute("name");return"upgrade"===(null==i?void 0:i.getAttribute("type"))&&o&&(n._selectionName=o,n._cost=L(i)),n}function I(e){let t=new u;A(e,t);let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){const n=e.getAttribute("name");n&&(e.textContent?t._table.set(n,e.textContent):t._table.set(n,"-"))}return t}function B(e){const t=new f;A(e,t);const n=e.querySelectorAll("characteristics>characteristic");for(let e of n){const n=e.getAttribute("name");if(n&&e.textContent)switch(n){case"Range":t._range=e.textContent;break;case"Warp Charge":t._manifest=+e.textContent;break;case"Details":t._details=e.textContent}}return t}function M(e){const t=new d;A(e,t);const n=e.querySelectorAll("characteristics>characteristic");for(const e of n){const n=e.getAttribute("name");if(n&&e.textContent)switch(n){case"Dice Roll":t._diceRoll=e.textContent;break;case"Distance":t._distance=e.textContent;break;case"Mortal Wounds":t._mortalWounds=e.textContent}}return t}function U(e){const t=new h;A(e,t);const n=e.querySelectorAll("characteristics>characteristic");for(const e of n){const n=e.getAttribute("name");if(n&&e.textContent)switch(n){case"Cast":t._cast=e.textContent;break;case"Deny":t._deny=e.textContent;break;case"Powers Known":t._powers=e.textContent;break;case"Other":t._other=e.textContent}}return t}function D(e,t){return H(e._name,t._name)}function F(e,t){return e._name===t._name?H(e.nameAndGear(),t.nameAndGear()):"Unit Upgrades"===e._name?1:"Unit Upgrades"===t._name?-1:H(e._name,t._name)}function q(e,t){return(e._type.startsWith("Grenade")?2:e._type.startsWith("Melee")?1:0)-(t._type.startsWith("Grenade")?2:t._type.startsWith("Melee")?1:0)||e.name().localeCompare(t.name())}function H(e,t){return e>t?1:e==t?0:-1}t.Costs=b,t.Create40kRoster=function(e,t=!0){var n;if(e){let r=e.querySelector("roster");if(r){const i=new v,o=null===(n=r.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;i._name=o||"40k Army Roster";let s=r.querySelector("customNotes");return s&&(i._customNotes=s.textContent),function(e,t){let n=e.querySelectorAll("roster>costs>cost");for(let e of n)t._cost.add(R(e))}(e,i),function(e,t,n){var r,i;let o=e.querySelectorAll("roster>forces>force");for(let e of o)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let o=new g,s=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue,a=null===(i=e.getAttributeNode("catalogueName"))||void 0===i?void 0:i.nodeValue;if(s&&(o._name=s),a&&(o._catalog=a),!C(o,t)){const t=e.querySelectorAll("force>rules>rule");for(let e of t)E(e,o._rules)}y(e,o,n),t._forces.push(o)}}(e,i,t),i}}return null},t.CompareWeapon=q,t.Compare=H},208:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Wh40k=void 0;const s=o(n(486));!function(e){class t{constructor(){this._name="",this._customName="",this._customNotes=""}name(){return this._customName?this._customName:this._name}notes(){return this._customNotes}equal(e){return null!=e&&this._name===e._name}hash(){return N(this.name())}}e.BaseNotes=t;class n extends t{constructor(){super(...arguments),this._cost=new d,this._count=1}selectionName(){return this.name()}toString(){let e=this.selectionName();return this._count>1&&(e=`${this._count}x ${e}`),this._cost.hasValues()&&(e+=` ${this._cost.toString()}`),e}}let r;function i(e){switch(e){case"Epic Hero":return r.EpicHero;case"Character":return r.Character;case"Battleline":return r.Battleline;case"Infantry":return r.Infantry;case"Swarm":return r.Swarm;case"Mounted":return r.Mounted;case"Beast":return r.Beast;case"Monster":return r.Monster;case"Vehicle":return r.Vehicle;case"Dedicated Transport":return r.Transport;case"Fortification":return r.Fortification;case"Allied Units":return r.Allied;default:return r.NONE}}e.Upgrade=n,e.Weapon=class extends n{constructor(){super(...arguments),this._selectionName="",this._range="Melee",this._attacks="1",this._skill="",this._str="user",this._ap="",this._damage="",this._abilities=""}selectionName(){return this._selectionName||this.name()}},function(e){e[e.NONE=0]="NONE",e[e.EpicHero=1]="EpicHero",e[e.Character=2]="Character",e[e.Battleline=3]="Battleline",e[e.Infantry=4]="Infantry",e[e.Swarm=5]="Swarm",e[e.Mounted=6]="Mounted",e[e.Beast=7]="Beast",e[e.Monster=8]="Monster",e[e.Vehicle=9]="Vehicle",e[e.Transport=10]="Transport",e[e.Fortification=11]="Fortification",e[e.Allied=12]="Allied"}(r=e.UnitRole||(e.UnitRole={})),e.UnitRoleToString={[r.NONE]:"None",[r.EpicHero]:"Epic Hero",[r.Character]:"Character",[r.Battleline]:"Battleline",[r.Infantry]:"Infantry",[r.Swarm]:"Swarm",[r.Mounted]:"Mounted",[r.Beast]:"Beast",[r.Monster]:"Monster",[r.Vehicle]:"Vehicle",[r.Transport]:"Dedicated Transport",[r.Fortification]:"Fortification",[r.Allied]:"Allied Units"};class o extends t{constructor(){super(...arguments),this._count=0,this._move='0"',this._toughness=4,this._save="4+",this._wounds=1,this._leadership="6+",this._objControl=1,this._weapons=[],this._upgrades=[]}equal(e){if(null==e)return!1;if(this._name===e._name&&this._count===e._count&&this._weapons.length===e._weapons.length&&this._upgrades.length===e._upgrades.length){for(let t=0;t0||this._upgrades.length>0)&&(e+=` (${this.getDedupedWeaponsAndUpgrades().map((e=>e.toString())).join(", ")})`),e}getDedupedWeaponsAndUpgrades(){const e=[];for(const t of[...this._weapons,...this._upgrades])e.some((e=>t.selectionName()===e.selectionName()))||e.push(t);return e}normalize(){this._weapons.sort(A),this._upgrades.sort(S),this.normalizeUpgrades(this._weapons),this.normalizeUpgrades(this._upgrades)}normalizeUpgrades(e){for(let t=0;te[0])).flat();this._profileTables[e]._contents=t.filter(((e,t)=>n.indexOf(e[0])===t))}for(let e=0;e(e._count>1?`${e._count}x `:"")+e.nameAndGear())),this._weapons=this._models.map((e=>e._weapons)).reduce(((e,t)=>e.concat(t)),[]).sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}}e.Unit=l;class c extends t{constructor(){super(...arguments),this._catalog="",this._faction="Unknown",this._factionRules=new Map,this._configurations=[],this._rules=new Map,this._units=[]}hash(){let e=71;for(const t of this._units)e=L(e,t.hash());return e}}e.Force=c;class u extends t{constructor(){super(...arguments),this._cost=new d,this._forces=[]}hash(){let e=59;for(const t of this._forces)e=L(e,t.hash());return e}}e.Roster40k=u;class d{constructor(){this._points=0}hasValues(){return 0!==this._points}toString(){const e=[];return 0!==this._points&&e.push(`${this._points} pts`),`[${e.join(" / ")}]`}add(e){this._points+=e._points;for(const t in e._freeformValues)this.addFreeformValue(t,e._freeformValues[t])}addFreeformValue(e,t){this._freeformValues||(this._freeformValues={});const n=this._freeformValues[e]||0;this._freeformValues[e]=n+t}}function h(e,t,n){var r;let i=e.querySelectorAll("force>selections>selection");for(let e of i){let n=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue;if(n)if(n.includes("Detachment Command Cost"));else if("Battle Size"===n||"Gametype"===n)f(e,t);else if(e.querySelector('profile[typeName="Unit"]')){const n=w(e);t._units.push(n);for(const e of n._rules.entries())t._rules.set(e[0],e[1]);for(const e of n._weaponRules.entries())t._rules.set(e[0],e[1])}else if("upgrade"===e.getAttribute("type")){_(e,t._rules),f(e,t);const n=e.querySelectorAll("selections>selection");for(let e of n){const n=e.getAttribute("name");n&&"upgrade"===e.getAttribute("type")&&("Unknown"===t._faction&&(t._faction=n),_(e,t._factionRules))}}else console.log("** UNEXPECTED SELECTION **",n,e)}for(const e of t._factionRules.keys())t._rules.delete(e);t._rules=new Map([...t._rules.entries()].sort()),t._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?e._name>t._name?1:e._name==t._name?0:-1:-1))}function f(e,t){var n;const r=e.getAttribute("name");if(!r)return;const i=null===(n=e.querySelector("category"))||void 0===n?void 0:n.getAttribute("name"),o=e.querySelectorAll("selections>selection"),s=[];let a=b(e);for(const e of o)s.push(e.getAttribute("name")),a.add(b(e));let l=i&&"Configuration"!==i?`${i} - ${r}`:r;s.length>0&&(l+=`: ${s.join(", ")}`),a.hasValues()&&(l+=` ${a.toString()}`),t._configurations.push(l)}function p(e,t){if(!t||!e)return!1;for(let n of t._forces)if(n._catalog===e._catalog)return!0;return!1}function _(e,t){const n=e.querySelectorAll("profiles>profile");for(const e of n){const n=e.getAttribute("name");if(!n)continue;const r=e.getAttribute("typeName");"Abilities"!==r&&"Dynastic Code"!==r&&"Household Tradition"!==r||E(e,n,0,t)}const r=e.querySelectorAll("rules>rule");for(const e of r)m(e,t)}function m(e,t){const n=e.getAttribute("name"),r=e.querySelector("description");n&&(null==r?void 0:r.textContent)&&t.set(n,r.textContent)}function g(e){const t=[];for(const n of e.children)if("selections"===n.tagName)for(const e of n.children)"selection"===e.tagName&&t.push(e);return t}function v(e,t){for(const n of e.children)if("profiles"===n.tagName)for(const e of n.children)if("profile"===e.tagName&&e.getAttribute("typeName")===t)return!0;return!1}function b(e){const t=new d;for(const n of e.children)if("costs"===n.tagName)for(const e of n.children)t.add(y(e));return t}function y(e){const t=new d,n=e.getAttribute("name"),r=e.getAttribute("value");return n&&r&&("pts"===n?t._points+=+r:t.addFreeformValue(n,+r)),t}function w(e,t){var s,c;let u=new l;!function(e,t){var n,r;t._name=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;let i=e;"profile"===e.tagName&&e.parentElement&&e.parentElement.parentElement&&(i=e.parentElement.parentElement),t._customName=null===(r=i.getAttributeNode("customName"))||void 0===r?void 0:r.nodeValue;let o=i.firstElementChild;o&&"customNotes"===o.tagName&&(t._customNotes=o.textContent),t._name}(e,u);let d=e.querySelectorAll("categories>category");for(let e of d){const t=null===(s=e.getAttributeNode("name"))||void 0===s?void 0:s.nodeValue;if(t){const e="Faction: ",n=t.lastIndexOf(e);if(n>=0){const r=t.slice(n+e.length);u._factions.add(r)}else{let e=i(t.trim());e!=r.NONE&&(u._role=e),u._keywords.add(t)}}}const h=[],f=Array.from(e.querySelectorAll('profile[typeName="Unit"],profile[typeName="Model"]'));for(const e of f){const t=e.getAttribute("name"),n=e.getAttribute("typeName");t&&n&&(u._profileTables[n]||(u._profileTables[n]=new a),x(e,t,n,u._profileTables[n]))}h.push(...f);const p=[];if("model"===e.getAttribute("type"))p.push(e);else{const t=g(e);for(const e of t)("model"===e.getAttribute("type")||v(e,"Unit"))&&p.push(e);0===p.length&&p.push(...Array.from(e.querySelectorAll('selection[type="model"]'))),0===p.length&&v(e,"Unit")&&p.push(e)}for(const e of p){const t=Array.from(e.querySelectorAll("profiles>profile")),r=t.filter((e=>!h.includes(e)));h.push(...r);const i=new o;i._name=e.getAttribute("name")||"Unknown Model",i._count=Number(e.getAttribute("number")||1),u._models.push(i),C(t,0,u);for(const t of e.querySelectorAll('selections>selection[type="upgrade"]')){if(t.querySelector('selections>selection[type="upgrade"]')&&!v(t,"Abilities"))continue;let e=t.getAttribute("name");if(e){const r=new n;r._name=e,r._cost=b(t),r._count=Number(t.getAttribute("number")),i._upgrades.push(r)}}}let _=Array.from(e.querySelectorAll("profiles>profile")).filter((e=>!h.includes(e)));if(h.push(..._),_.length>0){const t=new o;if(t._name="Unit Upgrades",C(_,0,u),t._weapons.length>0&&u._models.length>0){for(const e of u._models)e._weapons.push(...t._weapons);t._weapons.length=0}for(const r of g(e)){if("upgrade"!==r.getAttribute("type"))continue;if(p.includes(r))continue;if(r.querySelector('profiles>profile[typeName="Weapon"]'))continue;let e=r.getAttribute("name");if(!e)continue;const i=new n;i._name=e,i._cost=b(r),i._count=Number(r.getAttribute("number")),t._upgrades.push(i)}(t._weapons.length>0||t._upgrades.length>0)&&u._models.push(t)}let w=e.querySelectorAll("costs>cost");for(let e of w)u._cost.add(y(e));let E=e.querySelectorAll("rules > rule");for(let e of E){const t=null===(c=e.parentElement)||void 0===c?void 0:c.parentElement;t&&(v(t,"Ranged Weapons")||v(t,"Melee Weapons"))?m(e,u._weaponRules):m(e,u._rules)}return u.normalize(),u}function C(e,t,n){for(const t of e){const e=t.getAttribute("name"),r=t.getAttribute("typeName");e&&r&&(t.querySelectorAll("characteristics>characteristic").length>1?(n._profileTables[r]||(n._profileTables[r]=new a),x(t,e,r,n._profileTables[r])):(n._abilities[r]||(n._abilities[r]=new Map),E(t,e,0,n._abilities[r])))}}function x(e,t,n,r){const i=e.querySelectorAll("characteristics>characteristic"),o={[n]:t};for(const e of i){if(!e.textContent)continue;const t=e.getAttribute("name");t&&(o[t]=e.textContent)}r.addRow(o)}function E(e,t,n,r){const i=e.querySelectorAll("characteristics>characteristic");for(const e of i){if(!e.textContent)continue;const n=e.getAttribute("name");n&&i.length>1?r.set([t,n.toString()].join(" - "),e.textContent):r.set(t,e.textContent)}}function S(e,t){return T(e._name,t._name)}function k(e,t){return e._name===t._name?T(e.nameAndGear(),t.nameAndGear()):"Unit Upgrades"===e._name?1:"Unit Upgrades"===t._name?-1:T(e._name,t._name)}function A(e,t){return e.name().localeCompare(t.name())}function T(e,t){return e>t?1:e==t?0:-1}function N(e){let t=23;for(var n=0;ncosts>cost");for(let e of n)t._cost.add(y(e))}(e,r),function(e,t,n){var r,i;let o=e.querySelectorAll("roster>forces>force");for(let e of o)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let n=new c,o=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue,s=null===(i=e.getAttributeNode("catalogueName"))||void 0===i?void 0:i.nodeValue;if(o&&(n._name=o),s&&(n._catalog=s),!p(n,t)){const t=e.querySelectorAll("force>rules>rule");for(let e of t)m(e,n._rules)}h(e,n),t._forces.push(n)}}(e,r),r}}return null},e.CompareWeapon=A,e.Compare=T,e.CompareProfileTableName=function(e,t){const n=["Unit","Ranged Weapons","Melee Weapons"];return(n.includes(e)?n.indexOf(e):n.length)-(n.includes(t)?n.indexOf(t):n.length)}}(t.Wh40k||(t.Wh40k={}))},774:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CreateAoSRoster=t.RosterAoS=t.AoSForce=t.AoSUnit=t.AoSUnitRoleToString=t.AoSUnitRole=t.AoSRealmOfBattle=t.AoSSpecialRules=t.AoSCoreBattalion=t.AoSTriumph=t.AoSGrandStrategy=t.AoSAllegiance=t.AoSPrayer=t.AoSSpell=t.AoSWoundTracker=t.AoSWeapon=t.AoSProfile=t.AoSProfileType=void 0;const s=o(n(486));class a{constructor(){this._typeName="anonymous",this._fields=new Map}}t.AoSProfileType=a;class l{constructor(){this._name="none",this._value=new a}}t.AoSProfile=l;class c{constructor(){this._name="",this._type="Melee",this._range="",this._attacks="",this._toHit="",this._toWound="",this._rend="",this._damage=""}}t.AoSWeapon=c;class u{constructor(){this._title="",this._labels=[],this._table=[[]]}}t.AoSWoundTracker=u;class d{constructor(){this._name="",this._castingValue=0,this._range="",this._description=""}}t.AoSSpell=d;class h{constructor(){this._name="",this._answerValue=0,this._range="",this._description=""}}t.AoSPrayer=h;class f{constructor(){this._name="",this._battleTraits=new Map,this._commandAbilities=new Map,this._spells=[],this._extraProfiles=[]}}t.AoSAllegiance=f;class p{constructor(){this._name="",this._description=""}}t.AoSGrandStrategy=p;class _{constructor(){this._name="",this._description=""}}t.AoSTriumph=_;class m{constructor(){this._name="",this._abilities=new Map}}t.AoSCoreBattalion=m;class g{constructor(){this._name="",this._description=""}}t.AoSSpecialRules=g;class v{constructor(){this._name="",this._spells=[],this._commandAbilities=new Map,this._rules=[]}}var b;t.AoSRealmOfBattle=v,function(e){e[e.NONE=0]="NONE",e[e.LEADER=1]="LEADER",e[e.BATTLELINE=2]="BATTLELINE",e[e.BEHEMOTH=3]="BEHEMOTH",e[e.ARTILLERY=4]="ARTILLERY",e[e.OTHER=5]="OTHER",e[e.SCENERY=6]="SCENERY",e[e.BATTALION=7]="BATTALION",e[e.MALIGN_SORCERY=8]="MALIGN_SORCERY",e[e.REALM=9]="REALM"}(b=t.AoSUnitRole||(t.AoSUnitRole={})),t.AoSUnitRoleToString=["None","Leader","Battleline","Behemoth","Artillery","Other","Scenery","Battalion","Malign Sorcery","Realm"];class y{constructor(){this._name="",this._id=0,this._role=b.NONE,this._keywords=new Set,this._abilities=new Map,this._commandAbilities=new Map,this._commandTraits=new Map,this._magic=new Map,this._artefacts=new Map,this._count=0,this._move='0"',this._wounds=1,this._bravery=7,this._save="",this._weapons=[],this._spells=[],this._prayers=[],this._points=0,this._woundTracker=null,this._extraProfiles=[],this._selections=new Set}equal(e){return null!=e&&e._name===this._name&&e._role===this._role&&!!s.isEqual(this._commandTraits,e._commandTraits)&&!!s.isEqual(this._artefacts,e._artefacts)&&!!s.isEqual(this._weapons,e._weapons)}isNormalUnit(){return this._role==b.ARTILLERY||this._role==b.BATTLELINE||this._role==b.BEHEMOTH||this._role==b.LEADER||this._role==b.OTHER}}t.AoSUnit=y;class w{constructor(){this._catalog="",this._name="Unknown",this._units=[],this._battalions=[],this._rules=new Map,this._battleTactics=new Map,this._allegiance=new f,this._grandStrategy=new p,this._triumph=new _,this._realmOfBattle=new v}}t.AoSForce=w;class C{constructor(){this._commandPoints=0,this._points=0,this._name="",this._forces=[]}}function x(e){switch(e){case"Leader":return b.LEADER;case"Battleline":return b.BATTLELINE;case"Other":return b.OTHER;case"Behemoth":return b.BEHEMOTH;case"Artillery":return b.ARTILLERY;case"Scenery":return b.SCENERY;case"Battalion":return b.BATTALION;case"Malign Sorcery":return b.MALIGN_SORCERY;case"Realm":return b.REALM}return b.NONE}function E(e,t){var n,r,i,o,s,a,l;let c=e.querySelectorAll("force>selections>selection"),u=0;for(let e of c){let c=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;if(c)if(c.includes("Allegiance")){let n=A(e);n&&(t._allegiance=n)}else if(c.includes("Grand Strategy")){let n=T(e);n&&(t._grandStrategy=n)}else if(c.includes("Game Type"));else if(c.includes("Core Battalion")){let n=new m;n._name=c;let s=e.querySelectorAll("profiles>profile");for(let e of s)for(let e of s){let t=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue,s=null===(i=e.getAttributeNode("typeName"))||void 0===i?void 0:i.nodeValue;if(t&&s){let t=e.querySelectorAll("characteristics>characteristic");for(let e of t){let t=null===(o=e.getAttributeNode("name"))||void 0===o?void 0:o.nodeValue;t&&e.textContent&&n._abilities.set(t,e.textContent)}}}t._battalions.push(n)}else if(c.includes("Realm of Battle")){let n=L(e);n&&(t._realmOfBattle=n)}else if(c.includes("GHB 2023 Rules")){let n=R(e);n&&(t._realmOfBattle=n)}else if(c.includes("Triumphs")){let n=N(e);n&&(t._triumph=n)}else if(c.includes("Battle Tactic")){let n=e.querySelectorAll("profiles>profile");for(let e of n)for(let e of n){let n=null===(s=e.getAttributeNode("name"))||void 0===s?void 0:s.nodeValue,r=null===(a=e.getAttributeNode("typeName"))||void 0===a?void 0:a.nodeValue;if(n&&r){let r=e.querySelectorAll("characteristics>characteristic");for(let e of r)(null===(l=e.getAttributeNode("name"))||void 0===l?void 0:l.nodeValue)&&e.textContent&&t._battleTactics.set(n,e.textContent)}}}else{let n=k(e);n&&n._role!=b.NONE&&(n._id=u++,t._units.push(n))}}t._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?0:-1))}function S(e,t){var n;let r=e.querySelectorAll("force>rules>rule");for(let e of r){let r=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,i=e.querySelectorAll("description");if(r&&i)for(let e of i)e.textContent&&t._rules.set(r,e.textContent)}}function k(e){var t,n,r,i,o,s,a,l,f,p,_,m,g,v,w;let C=new y,E=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;E&&(C._name=E);let S=e.querySelectorAll("profiles>profile");for(let e of S){let t=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,p=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(t&&p)if("Unit"==p){C._name||(C._name=t);let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(t&&e.textContent)switch(t){case"Move":C._move=e.textContent;break;case"Wounds":C._wounds=+e.textContent;break;case"Bravery":C._bravery=+e.textContent;break;case"Save":C._save=e.textContent}}}else if("Unit Abilities"==p){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&C._abilities.set(t,n.textContent)}else if("Command Abilities"==p){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&C._commandAbilities.set(t,n.textContent)}else if("Magic"==p){let t=e.querySelectorAll("characteristics>characteristic");for(let e of t){let t=null===(o=e.getAttributeNode("name"))||void 0===o?void 0:o.nodeValue;t&&e.textContent&&C._magic.set(t,e.textContent)}}else if("Unit Leader"==p){let t=e.querySelector("characteristics>characteristic");t&&t.textContent&&C._abilities.set(p,t.textContent)}else if("Spell"==p){let n=new d;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(s=e.getAttributeNode("name"))||void 0===s?void 0:s.nodeValue;if(t&&e.textContent)switch(t){case"Casting Value":n._castingValue=+e.textContent;break;case"Range":n._range=e.textContent;break;case"Description":n._description=e.textContent}}C._spells.push(n)}else if("Weapon"==p){let n=new c;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(a=e.getAttributeNode("name"))||void 0===a?void 0:a.nodeValue;if(t&&e.textContent)switch(t){case"Range":n._range=e.textContent;break;case"Type":n._type=e.textContent;break;case"Attacks":n._attacks=e.textContent;break;case"Rend":n._rend=e.textContent;break;case"To Hit":n._toHit=e.textContent;break;case"To Wound":n._toWound=e.textContent;break;case"Damage":n._damage=e.textContent}}C._weapons.push(n)}else if("Command Trait"==p){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&C._commandTraits.set(t,n.textContent)}else if("Artefact"==p){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&C._artefacts.set(t,n.textContent)}else if("Prayer"==p){let n=new h;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(l=e.getAttributeNode("name"))||void 0===l?void 0:l.nodeValue;if(t&&e.textContent)switch(t){case"Answer Value":n._answerValue=+e.textContent;break;case"Range":n._range=e.textContent;break;case"Description":n._description=e.textContent}}C._prayers.push(n)}else if(p.includes("Damage Table")||p.includes("Wounds")||p.includes("Wound Track")||p.includes("Wound Table")){let n=[];if(C._woundTracker){let r=e.querySelectorAll("characteristics>characteristic");if(r.length<=3){let e=t;e?n.push(e):n.push("Unknown");for(let e of r)e.textContent?n.push(e.textContent):n.push("Unknown")}else for(let e of r)e.textContent?n.push(e.textContent):n.push("Unknown");C._woundTracker._table.push(n),n=[]}else{C._woundTracker=new u,C._woundTracker._title=p;let r=e.querySelectorAll("characteristics>characteristic");if(r.length<=3){C._woundTracker._labels.push("Wounds Suffered"),n.push(t);for(let e of r){let t=null===(f=e.getAttributeNode("name"))||void 0===f?void 0:f.nodeValue;t?C._woundTracker._labels.push(t):C._woundTracker._labels.push("Unknown"),e.textContent?n.push(e.textContent):n.push("Unknown")}}else for(let e of r)e.textContent?C._woundTracker._labels.push(e.textContent):C._woundTracker._labels.push("Unknown");C._woundTracker._table.push(n),n=[]}}else{let t=P(e);t?C._extraProfiles.push(t):console.log("Unknown unit profile type: "+p)}}let k=e.querySelectorAll("selections>selection");for(let e of k){let t=null===(p=e.getAttributeNode("name"))||void 0===p?void 0:p.nodeValue;if(t&&(C._selections.add(t),t.includes("Wound Track"))){C._woundTracker=new u,C._woundTracker._title=t,C._woundTracker._labels=["Wounds Suffered"];let n=e.querySelectorAll("profiles>profile"),r=!0;for(let e of n){let t=null===(_=e.getAttributeNode("name"))||void 0===_?void 0:_.nodeValue,n=e.querySelectorAll("characteristics>characteristic"),i=[];t?i.push(t):i.push("--");for(let e of n){let t=null===(m=e.getAttributeNode("name"))||void 0===m?void 0:m.nodeValue,n=e.textContent;r&&(t?C._woundTracker._labels.push(t):C._woundTracker._labels.push("Unknown")),n?i.push(n):i.push("Unknown")}r=!1,C._woundTracker._table.push(i)}}}let A=e.querySelectorAll("costs>cost");for(let e of A)if(e.hasAttribute("name")&&e.hasAttribute("value")){let t=null===(g=e.getAttributeNode("name"))||void 0===g?void 0:g.nodeValue,n=null===(v=e.getAttributeNode("value"))||void 0===v?void 0:v.nodeValue;n&&"pts"===t&&(C._points+=+n)}let T=e.querySelectorAll(":scope categories>category");for(let e of T){let t=null===(w=e.getAttributeNode("name"))||void 0===w?void 0:w.nodeValue;if(t){var N=x(t.trim());N!=b.NONE?C._role=N:C._keywords.add(t)}}return C}function A(e){var t,n,r,i;let o=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;if(o){let t=new f;t._name=o;let s=e.querySelectorAll("profiles>profile");for(let e of s){let o=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(o&&s)if("Battle Trait"==s){let n=e.querySelector("characteristics>characteristic");if(n){let e=n.textContent;e&&(null==t||t._battleTraits.set(o,e))}}else if("Command Abilities"==s){let n=e.querySelector("characteristics>characteristic");if(n){let e=n.textContent;e&&(null==t||t._commandAbilities.set(o,e))}}else if("Spell"==s){let n=new d;n._name=o;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(t&&e.textContent)switch(t){case"Casting Value":n._castingValue=+e.textContent;break;case"Range":n._range=e.textContent;break;case"Description":n._description=e.textContent}}null==t||t._spells.push(n)}else{let n=P(e);n?null==t||t._extraProfiles.push(n):console.log("Unexpected allegiance profile type: "+s)}}return t}return null}function T(e){var t,n,r;let i=null,o=e.querySelector("selections>selection");if(o){let e=null===(t=o.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;e&&(i=new p,i._name=e);let s=o.querySelectorAll("profiles>profile");for(let e of s){let t=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(t&&o)if("Grand Strategy"==o){let t=e.querySelector("characteristics>characteristic");if(t){let e=t.textContent;e&&i&&(i._description=e)}}else console.log("Unexpected Grand Strategy profile type: "+o)}}return i}function N(e){var t,n,r;let i=null,o=e.querySelector("selections>selection");if(o){let e=null===(t=o.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;e&&(i=new _,i._name=e);let s=o.querySelectorAll("profiles>profile");for(let e of s){let t=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(t&&o)if("Triumph"==o){let t=e.querySelector("characteristics>characteristic");if(t){let e=t.textContent;e&&i&&(i._description=e)}}else console.log("Unexpected Triumph profile type: "+o)}}return i}function L(e){var t,n,r,i;let o=null,s=e.querySelector("selections>selection");if(s){let e=null===(t=s.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;if(e){o=new v,o._name=e;let t=s.querySelectorAll("profiles>profile");for(let e of t){let t=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(t&&s)if("Spell"==s){let n=new d;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(t&&e.textContent)switch(t){case"Casting Value":n._castingValue=+e.textContent;break;case"Range":n._range=e.textContent;break;case"Description":n._description=e.textContent}}o._spells.push(n)}else if("Command Abilities"==s){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&o._commandAbilities.set(t,n.textContent)}else if("Special Rules"==s){let n=e.querySelector("characteristics>characteristic");if(n&&n.textContent){let e=new g;e._name=t,e._description=n.textContent,o._rules.push(e)}}else console.log("Unexpected Realm of Battle profile type: "+s)}}}return o}function R(e){var t,n,r,i;let o=null,s=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;if(s){o=new v,o._name=s;let t=e.querySelectorAll("profiles>profile");for(let e of t){let t=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(t&&s)if("Spell"==s){let n=new d;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(t&&e.textContent)switch(t){case"Casting Value":n._castingValue=+e.textContent;break;case"Range":n._range=e.textContent;break;case"Description":n._description=e.textContent}}o._spells.push(n)}else if("Command Abilities"==s){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&o._commandAbilities.set(t,n.textContent)}else if("Special Rules"==s||"Heroic Action"==s){let n=e.querySelector("characteristics>characteristic");if(n&&n.textContent){let e=new g;e._name=t,e._description=n.textContent,o._rules.push(e)}}else console.log("Unexpected Realm of Battle profile type: "+s)}}return o}function P(e){var t,n,r;if(!e)return null;let i=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue,o=null===(n=e.getAttributeNode("typeName"))||void 0===n?void 0:n.nodeValue;if(!i||!o)return null;let s=new l;s._name=i,s._value._typeName=o;let a=e.querySelectorAll("characteristics>characteristic");for(let e of a){let t=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue;t&&e.textContent&&s._value._fields.set(t,e.textContent)}return s}t.RosterAoS=C,t.CreateAoSRoster=function(e){var t;if(e){let n=e.querySelector("roster");if(n){const r=new C,i=null===(t=n.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;return r._name=i||"Age of Sigmar Roster",function(e,t){var n,r;let i=e.querySelectorAll("roster>costs>cost");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("value")){let i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("value"))||void 0===r?void 0:r.nodeValue;o&&"pts"===i&&(t._points=+o)}}(e,r),function(e,t){var n,r;let i=e.querySelectorAll("roster>forces>force");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let i=new w,o=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("catalogueName"))||void 0===r?void 0:r.nodeValue;o&&(i._name=o),s&&(i._catalog=s),E(e,i),S(e,i),t._forces.push(i)}}(e,r),r}}return null}},980:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.HorusHeresy=void 0;const s=o(n(486));!function(e){let t;!function(e){e[e.NONE=0]="NONE",e[e.HQ=1]="HQ",e[e.TR=2]="TR",e[e.EL=3]="EL",e[e.FA=4]="FA",e[e.HS=5]="HS",e[e.FL=6]="FL",e[e.DT=7]="DT",e[e.FT=8]="FT",e[e.LW=9]="LW",e[e.PR=10]="PR"}(t=e.UnitRole||(e.UnitRole={})),e.UnitRoleToString=["None","HQ","Troops","Elites","Fast Attack","Heavy Support","Flyer","Dedicated Transport","Fortification","Lord of War","Primarch"];class n{constructor(){this._name="",this._customName="",this._customNotes=""}name(){return this._customName?this._customName:this._name}notes(){return this._customNotes}equal(e){return null!=e&&this._name===e._name}}e.BaseNote=n;class r extends n{constructor(){super(...arguments),this._description="",this._cost=new p,this._count=1}selectionName(){return this.name()}toString(){let e=this.selectionName();return this._count>1&&(e=`${this._count}x ${e}`),this._cost.hasValues()&&(e+=` ${this._cost.toString()}`),e}}e.Upgrade=r;class i extends r{constructor(){super(...arguments),this._selectionName="",this._range="Melee",this._str="user",this._ap="",this._type="Melee"}getRules(){let e=this._type.split(",");return e.length>0&&(e=e.slice(1).map((e=>e.trim()))),e}}e.Weapon=i;class o extends n{constructor(){super(...arguments),this._count=0,this._type="",this._weapons=[],this._upgrades=[],this._wargear=[],this._warlordTraits=[],this._reactions=[],this._psychicWeapons=[],this._psychicPowers=[]}equal(e){if(null==e)return!1;if(this._name===e._name&&this._count===e._count&&this._weapons.length===e._weapons.length&&this._upgrades.length===e._upgrades.length&&this._wargear.length===e._wargear.length&&this._psychicWeapons.length===e._psychicWeapons.length&&this._psychicPowers.length===e._psychicPowers.length){for(let t=0;t0||this._upgrades.length>0)&&(e+=` (${this.getDedupedWeaponsAndUpgrades().map((e=>e.toString())).join(", ")})`),e}getDedupedWeaponsAndUpgrades(){const e=[];for(const t of[...this._weapons,...this._upgrades])e.some((e=>t.selectionName()===e.selectionName()))||e.push(t);return e}normalize(){this._weapons.sort(N),this._upgrades.sort(A),this._wargear.sort(A),this._psychicPowers.sort(A),this._psychicWeapons.sort(N),this.normalizeUpgrades(this._weapons),this.normalizeUpgrades(this._upgrades),this.normalizeUpgrades(this._wargear),this.normalizeUpgrades(this._psychicPowers),this.normalizeUpgrades(this._psychicWeapons)}normalizeUpgrades(e){for(let t=0;t(e._count>1?`${e._count}x `:"")+e.nameAndGear()))}weapons(){let e=this._models.map((e=>e._weapons)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._weapons),e.sort(N).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}psychicWeapons(){let e=this._models.map((e=>e._psychicWeapons)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._psychicWeapons),e.sort(N).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}psychicPowers(){let e=this._models.map((e=>e._psychicPowers)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._psychicPowers),e.sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}wargear(){let e=this._models.map((e=>e._wargear)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._wargear),e.sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}weaponRules(){let e=[];return e=this.weapons().map((e=>e.getRules())).reduce(((e,t)=>e.concat(t)),[]),e.sort().filter(((e,t,n)=>e!==n[t-1]))}warlordTraits(){let e=this._models.map((e=>e._warlordTraits)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._warlordTraits),e.sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}upgrades(){let e=this._models.map((e=>e._upgrades)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._upgrades),e.sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}reactions(){let e=this._models.map((e=>e._reactions)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._reactions),e.sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}}e.Unit=d;class h extends n{constructor(){super(),this._catalog="",this._name="Unknown",this._faction="Unknown",this._factionRules=new Map,this._rules=new Map,this._units=[]}}e.Force=h;class f extends n{constructor(){super(),this._cost=new p,this._name="",this._forces=[]}}e.Roster=f;class p{constructor(){this._points=0}hasValues(){return 0!==this._points}toString(){const e=[];return 0!==this._points&&e.push(`${this._points} pts`),`[${e.join(" / ")}]`}add(e){this._points+=e._points;for(const t in e._freeformValues)this.addFreeformValue(t,e._freeformValues[t])}addFreeformValue(e,t){this._freeformValues||(this._freeformValues={});const n=this._freeformValues[e]||0;this._freeformValues[e]=n+t}}function _(e,t){return e>t?1:e==t?0:-1}function m(e,t){return typeof e>typeof t?1:typeof e==typeof t?0:-1}function g(e){const t=new p,n=e.getAttribute("name"),r=e.getAttribute("value");return n&&r&&("Pts"===n?t._points+=+r:t.addFreeformValue(n,+r)),t}function v(e,n){var i,o;let s=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(!s)return;let h=null===(o=e.getAttributeNode("type"))||void 0===o?void 0:o.nodeValue;if(h)if(e.querySelector('profile[typeId="4bb2-cb95-e6c8-5a21"]')||e.querySelector('profile[typeId="2fae-b053-3f78-e7b2"]')||e.querySelector('profile[typeId="75b5-9f7a-156e-6889"]')||e.querySelector('profile[typeId="eeec-bde3-8ee4-35b0"]')){const i=function(e){var n,i,o;let s=new d;b(e,s);let h=e.querySelectorAll("categories>category");for(let e of h){const r=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;if(r){let e=S(r.trim());e!=t.NONE?s._role=e:r.endsWith(":")||s._keywords.add(r)}}const f=[],p=Array.from(e.querySelectorAll('profile[typeId="4bb2-cb95-e6c8-5a21"],profile[typeId="2fae-b053-3f78-e7b2"],profile[typeId="75b5-9f7a-156e-6889"],profile[typeId="eeec-bde3-8ee4-35b0"]'));(function(e,t,n){var r,i;for(const n of e){const e=n.getAttribute("name"),o=n.getAttribute("typeName");if(!e||!o)return;if("Unit"===o.trim()){const r=new l;r._name=e,t._modelStats.push(r),b(n,r);const i=n.querySelectorAll("characteristics>characteristic");for(const e of i){const t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"Unit Type":r._type=e.textContent;break;case"Move":r._move=k(e.textContent);break;case"WS":r._ws=+e.textContent;break;case"BS":r._bs=+e.textContent;break;case"S":r._str=+e.textContent;break;case"T":r._toughness=+e.textContent;break;case"W":r._wounds=+e.textContent;break;case"I":r._initiative=+e.textContent;break;case"A":r._attacks=+e.textContent;break;case"Ld":r._leadership=+e.textContent;break;case"Save":r._save=e.textContent}}}else if("Knights and Titans"===o.trim()){let r=new c;r._name=e,t._modelStats.push(r),b(n,r);const i=n.querySelectorAll("characteristics>characteristic");for(const e of i){const t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"Unit Type":r._type=e.textContent;break;case"Move":r._move=k(e.textContent);break;case"WS":r._ws=+e.textContent;break;case"BS":r._bs=+e.textContent;break;case"S":r._str=+e.textContent;break;case"Front":r._front=+e.textContent;break;case"Side":r._side=+e.textContent;break;case"Rear":r._rear=+e.textContent;break;case"I":r._initiative=+e.textContent;break;case"A":r._attacks=+e.textContent;break;case"HP":r._hp=+e.textContent}}}else if("Vehicle"===o.trim()){let i=new a;i._name=e,t._modelStats.push(i),b(n,i);const o=n.querySelectorAll("characteristics>characteristic");for(const e of o){const t=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue;if(t&&e.textContent)switch(t){case"Unit Type":i._type=e.textContent;break;case"Move":i._move=k(e.textContent);break;case"BS":i._bs=+e.textContent;break;case"Front":i._front=+e.textContent;break;case"Side":i._side=+e.textContent;break;case"Rear":i._rear=+e.textContent;break;case"HP":i._hp=+e.textContent;break;case"Transport Capacity":i._capacity=e.textContent;break;case"Access Points":i._accessPoints=e.textContent}}}else if("Fortification"===o.trim()){let r=new u;r._name=e,t._modelStats.push(r),b(n,r);const o=n.querySelectorAll("characteristics>characteristic");for(const e of o){const t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(t&&e.textContent)switch(t){case"Unit Type":r._type=e.textContent;break;case"BS":r._bs=e.textContent;break;case"Front":r._front=+e.textContent;break;case"Side":r._side=+e.textContent;break;case"Rear":r._rear=+e.textContent;break;case"HP":r._hp=+e.textContent;break;case"Transport Capacity":r._capacity=e.textContent;break;case"Fire Points":r._firePoints=e.textContent}}}}})(p,s),f.push(...p);const _=[];if("model"===e.getAttribute("type"))_.push(e);else{const t=function(e){const t=[];for(const n of e.children)if("selections"===n.tagName)for(const e of n.children)"selection"===e.tagName&&t.push(e);return t}(e);for(const e of t)("model"===e.getAttribute("type")||O(e,"Unit")||O(e,"Fortification")||O(e,"Vehicle")||O(e,"Knights and Titans"))&&_.push(e);0===_.length&&_.push(...Array.from(e.querySelectorAll('selection[type="model"]'))),(0===_.length&&O(e,"Unit")||O(e,"Fortification")||O(e,"Vehicle")||O(e,"Knights and Titans"))&&_.push(e)}for(const e of _){const t=Array.from(e.querySelectorAll("profiles>profile")),n=t.filter((e=>!f.includes(e)));f.push(...n);const i=new l;i._name=e.getAttribute("name")||"Unknown Model",i._count=Number(e.getAttribute("number")||1),s._models.push(i),R(t,i);for(const t of e.querySelectorAll('selections>selection[type="upgrade"]')){let e=t.getAttribute("name");if(e){const n=new r;n._name=e,n._cost=L(t),n._count=Number(t.getAttribute("number")),i._upgrades.push(n)}}}let m=e.querySelectorAll('selections>selection[type="upgrade"]');for(const e of m){R(Array.from(e.querySelectorAll("profiles>profile")),s);const t=e.getAttribute("name");if(t){const n=new r;n._name=t,n._cost=L(e),n._count=Number(e.getAttribute("number")),s._upgrades.push(n)}}let g=e.querySelectorAll("costs>cost");for(let e of g)if(e.hasAttribute("name")&&e.hasAttribute("value")){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue,n=null===(o=e.getAttributeNode("value"))||void 0===o?void 0:o.nodeValue;n&&"Pts"==t&&(s._points+=+n)}let v=e.querySelectorAll("rules>rule");for(let e of v)P(e,s._rules);return s.normalize(),s}(e);if(i){n._units.push(i);for(const e of i._rules.entries())n._rules.set(e[0],e[1])}}else"upgrade"===h?function(e,t){const n=e.querySelectorAll("rules>rule");for(const e of n)P(e,t)}(e,n._rules):console.log("** UNEXPECTED SELECTION **",s,h,e)}function b(e,t){var n,r;t._name=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;let i=e;"profile"===e.tagName&&e.parentElement&&e.parentElement.parentElement&&(i=e.parentElement.parentElement),t._customName=null===(r=i.getAttributeNode("customName"))||void 0===r?void 0:r.nodeValue;let o=i.firstElementChild;return o&&"customNotes"===o.tagName&&(t._customNotes=o.textContent),t._name}function y(e){var t;if(e.parentElement&&e.parentElement.parentElement){const n=null===(t=e.parentElement.parentElement.getAttributeNode("number"))||void 0===t?void 0:t.nodeValue;if(n)return+n}return 0}function w(e){var t;const n=new i;b(e,n),n._count=y(e);let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"Range":n._range=e.textContent;break;case"Type":n._type=e.textContent;break;case"Strength":n._str=e.textContent;break;case"AP":n._ap=e.textContent}}const o=null===(t=e.parentElement)||void 0===t?void 0:t.parentElement,s=null==o?void 0:o.getAttribute("name");return"upgrade"===(null==o?void 0:o.getAttribute("type"))&&s&&(n._selectionName=s,n._cost=L(o)),n}function C(e){var t;const n=new i;b(e,n),n._count=y(e);let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"Range":n._range=e.textContent;break;case"Type":n._type=e.textContent;break;case"Strength":n._str=e.textContent;break;case"AP":n._ap=e.textContent}}const o=null===(t=e.parentElement)||void 0===t?void 0:t.parentElement,s=null==o?void 0:o.getAttribute("name");return"upgrade"===(null==o?void 0:o.getAttribute("type"))&&s&&(n._selectionName=s,n._cost=L(o)),n}function x(e){const t=new r;b(e,t),t._count=y(e);let n=e.querySelectorAll("characteristics>characteristic");for(let e of n)if(e.textContent){let n=e.getAttribute("name");if(n)switch(n){case"Description":case"Text":t._description=e.textContent}}return t}function E(e,t){if(!t||!e)return!1;for(let n of t._forces)if(n._catalog===e._catalog)return!0;return!1}function S(e){switch(e){case"HQ:":return t.HQ;case"Troops:":return t.TR;case"Elites:":return t.EL;case"Fast Attack:":return t.FA;case"Heavy Support:":return t.HS;case"Flyer":return t.FL;case"Transport Sub-type:":return t.DT;case"Fortification:":return t.FT;case"Lords of War:":return t.LW;case"Primarch:":return t.PR}return t.NONE}function k(e){return function(e){return null!=e&&""!==e&&!isNaN(Number(e.toString()))}(e)?e.toString()+'"':e.toString()}function A(e,t){return _(e._name,t._name)}function T(e,t){return e._name===t._name?_(e.nameAndGear(),t.nameAndGear()):_(e._name,t._name)}function N(e,t){return(e._type.startsWith("Grenade")?2:e._type.startsWith("Melee")?1:0)-(t._type.startsWith("Grenade")?2:t._type.startsWith("Melee")?1:0)||e.name().localeCompare(t.name())}function L(e){const t=new p;for(const n of e.children)if("costs"===n.tagName)for(const e of n.children)t.add(g(e));return t}function R(e,t){for(const n of e){const e=n.getAttribute("name");let r=n.getAttribute("typeName");if(e&&r)if(r=r.trim(),"Unit"===r||"Vehicle"===r||"Knights and Titans"===r||"Fortification"===r||"model"===n.getAttribute("type"));else if("Weapon"===r){const e=w(n);t._weapons.push(e)}else if("Psychic Weapon"===r){const e=C(n);t._psychicWeapons.push(e)}else if("Psychic Power"===r){const e=x(n);t._psychicPowers.push(e)}else if("Wargear Item"===r){const e=x(n);t._wargear.push(e)}else if("Warlord Trait"===r){const e=x(n);t._warlordTraits.push(e)}else if("Reactions"===r){const e=x(n);t._reactions.push(e)}else console.log("Unhandled model/unit profile "+e+" of type "+r+".")}}function P(e,t){const n=e.getAttribute("name"),r=e.querySelector("description");n&&(null==r?void 0:r.textContent)&&t.set(n,r.textContent)}function O(e,t){var n;for(const r of e.children)if("profiles"===r.tagName)for(const e of r.children)if("profile"===e.tagName&&(null===(n=e.getAttribute("typeName"))||void 0===n?void 0:n.trim())===t)return!0;return!1}e.Costs=p,e.Compare=_,e.CompareModelTypes=m,e.CreateRoster=function(e){var t;if(e){let n=e.querySelector("roster");if(n){const r=new f,i=null===(t=n.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;return r._name=i||"Horus Heresy Army Roster",function(e,t){let n=e.querySelectorAll("roster>costs>cost");for(let e of n)t._cost.add(g(e))}(e,r),function(e,t){var n,r;let i=e.querySelectorAll("roster>forces>force");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let i=new h,o=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("catalogueName"))||void 0===r?void 0:r.nodeValue;if(o&&(i._name=o),s&&(i._catalog=s),!E(i,t)){const t=e.querySelectorAll("force>rules>rule");for(let e of t)P(e,i._rules)}let a=e.querySelectorAll(":scope>selections>selection");for(let e of a)v(e,i);i._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?0:-1)),t._forces.push(i)}}(e,r),r}}return null},e.CompareWeapon=N}(t.HorusHeresy||(t.HorusHeresy={}))},249:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Compare=t.CreateKT21Roster=t.RosterKT21=t.Force=t.Operative=t.OperativeRoleToString=t.Specialism=t.PsychicPowerWeapon=t.PsychicPower=t.UniqueActions=t.Weapons=t.BaseNotes=void 0;const s=o(n(486));class a{constructor(){this._name="",this._customName="",this._customNotes="",this._costs="0"}name(){return this._customName?this._customName:this._name}nameAndCosts(){let e=this._name;return this._customName&&(e=this._customName),this.costs()>0&&(e+=" ("+this.costs()+" EP)"),e}notes(){return this._customNotes}costs(){return Math.floor(+this._costs)}equal(e){return null!=e&&this._name===e._name}}t.BaseNotes=a;class l extends a{constructor(){super(...arguments),this._count=0,this._attacks="0",this._skill="0+",this._damage="0/0",this._rules="",this._criticalEffects=""}}t.Weapons=l,t.UniqueActions=class extends a{constructor(){super(...arguments),this._description=""}};class c extends a{constructor(){super(...arguments),this._effect="",this._weapons=[]}}var u;t.PsychicPower=c,t.PsychicPowerWeapon=class extends l{},function(e){e[e.NONE=0]="NONE",e[e.COMBAT=1]="COMBAT",e[e.STAUNCH=2]="STAUNCH",e[e.MARKSMAN=3]="MARKSMAN",e[e.SCOUT=4]="SCOUT"}(u=t.Specialism||(t.Specialism={})),t.OperativeRoleToString=["None","Combat","Staunch","Marksman","Scout"];class d extends a{constructor(){super(...arguments),this._role=u.NONE,this._model="",this._factions=new Set,this._keywords=new Set,this._abilities=new Map,this._rules=new Map,this._move='0"',this._apl="0",this._groupActivations="0",this._defence=0,this._saves="0+",this._wounds=0,this._weapons=[],this._upgrades=[],this._psychicPowers=[],this._psychicPowersWeapon=[]}equal(e){if(null==e)return!1;if(e._name===this._name&&e._role===this._role&&e._weapons.length===this._weapons.length){for(let t=0;t0||this._upgrades.length>0){let t=0;e+=" (";for(const n of this._weapons)e+=n.name(),t++,t!=this._weapons.length&&(e+=", ");this._upgrades.length>0&&!e.endsWith("(")&&(e+=", "),e+=this._upgrades.join(", "),e+=")"}return e}normalize(){this._weapons.sort(x),this._upgrades.sort(E);for(let e=0;eselections>selection");for(let e of r){let r=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;if(r&&"Game Type"!==r)if(r.includes("Detachment Command Cost"))console.log("Found Detachment Command Cost");else if(r.includes("Chapter Tactics"))console.log("Found chapter tactics."),m(e,t._rules);else{let n=w(e);if(n){n._keywords.has("Leader")?t._leader=n:t._operatives.push(n);for(const e of n._rules.entries())t._rules.set(e[0],e[1])}else if("upgrade"===e.getAttribute("type")){m(e,t._rules);const n=e.querySelectorAll("selections>selection");for(let e of n){const n=e.getAttribute("name");n&&"upgrade"===e.getAttribute("type")&&("Unknown"===t._faction&&(t._faction=n),m(e,t._factionRules))}}}}for(const e of t._factionRules.keys())t._rules.delete(e);t._operatives.sort(((e,t)=>e._role>t._role?1:e._role==t._role?e._name>t._name?1:e._name==t._name?0:-1:-1))}function _(e,t){if(!t||!e)return!1;for(let n of t._forces)if(n._catalog===e._catalog)return!0;return!1}function m(e,t){var n,r,i,o,s;const a=e.querySelectorAll(":scope profiles>profile");for(const l of a){const a=null===(n=l.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,c=null===(r=l.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(console.log("Prop name:"+a+" Type: "+c),a&&c)if("Abilities"===c||"Dynastic Code"===c||"Chapter Tactics"===c){const e=l.querySelectorAll("characteristics>characteristic");for(const n of e){const e=null===(i=n.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;e&&n.textContent&&a&&("Description"!==e&&"Ability"!==e&&"Effect"!=e&&"Chapter Tactic"!=e||t.set(a,n.textContent))}}else if("Weapons"===c){const n=e.querySelectorAll("rules>rule");for(const e of n)e.getAttributeNode("name")&&t.set(null===(o=e.getAttributeNode("name"))||void 0===o?void 0:o.nodeValue,null===(s=e.firstChild)||void 0===s?void 0:s.textContent)}}}function g(e){switch(e){case"Combat":return u.COMBAT;case"Staunch":return u.STAUNCH;case"Marksman":return u.MARKSMAN;case"Scout":return u.SCOUT}return u.NONE}function v(e,t){var n,r;let i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;console.log("Unknown profile type: "+o+" with name: "+i+". Found in operative: "+t._name)}function b(e,t){var n,r,i;t._name=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;let o=e;"profile"===e.tagName&&e.parentElement&&e.parentElement.parentElement&&(o=e.parentElement.parentElement),t._customName=null===(r=o.getAttributeNode("customName"))||void 0===r?void 0:r.nodeValue;let s=o.firstElementChild;if(s&&"customNotes"===s.tagName&&(t._customNotes=s.textContent),"selection"===o.tagName){let e=o.querySelector("costs>cost");e&&e.getAttributeNode("value")&&(t._costs=null===(i=e.getAttributeNode("value"))||void 0===i?void 0:i.nodeValue)}return t._name}function y(e){var t;if(e.parentElement&&e.parentElement.parentElement){const n=null===(t=e.parentElement.parentElement.getAttributeNode("number"))||void 0===t?void 0:t.nodeValue;if(n)return+n}return 0}function w(e){var t,n,r,i,o;let s=new d;b(e,s);let a=e.querySelectorAll(":scope categories>category");for(let e of a){const n=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;if(n){const e="Faction: ",t=n.lastIndexOf(e);if(t>=0){const r=n.slice(t+e.length);s._factions.add(r)}else{let e=g(n.trim());e!=u.NONE?s._role=e:s._keywords.add(n)}}}let l=[],c=[];for(let t of e.querySelectorAll('profile[typeName="Operative"]')){let e=null===(n=t.parentElement)||void 0===n?void 0:n.parentElement;if(!e||c.includes(e))continue;c.push(e);let r=Array.from(e.querySelectorAll(":scope profiles>profile")||[]);C(r,s),l=l.concat(r)}C(Array.from(e.querySelectorAll(":scope profiles>profile")).filter((e=>!l.includes(e))),s,0,!0);let h=e.querySelectorAll(":scope costs>cost");for(let e of h)if(e.hasAttribute("name")&&e.hasAttribute("value")){let t=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue,n=null===(i=e.getAttributeNode("value"))||void 0===i?void 0:i.nodeValue;" EP"==t&&n&&+n>0&&(s._costs=(s.costs()+parseInt(n)).toString())}let f=e.querySelectorAll("rules > rule");for(let e of f)if(e.hasAttribute("name")){let t=null===(o=e.getAttributeNode("name"))||void 0===o?void 0:o.nodeValue,n=e.querySelector("description");t&&n&&n.textContent&&s._rules.set(t,n.textContent)}return s.normalize(),s}function C(e,t,n,r=!1){var i,o,s,a,u,d,h,f,p,_,g,w;for(let n of e){const e=null===(i=n.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue,r=null===(o=n.getAttributeNode("typeName"))||void 0===o?void 0:o.nodeValue;if(e&&r)if("Operative"===r){let e=t._name;b(n,t),t._model=t._name,t._name=e;let r=n.querySelectorAll("characteristics>characteristic");for(let e of r){let n=null===(s=e.getAttributeNode("name"))||void 0===s?void 0:s.nodeValue;if(n&&e.textContent)switch(n){case"M":t._move=e.textContent;break;case"APL":t._apl=e.textContent;break;case"GA":t._groupActivations=e.textContent;break;case"DF":t._defence=+e.textContent;break;case"SV":t._saves=e.textContent;break;case"W":t._wounds=+e.textContent}}}else if("Abilities"===r||"Equipment"===r||"Ability"===r||"Unique Actions"===r||"Chapter Tactics"==r){let r=n.querySelectorAll("characteristics>characteristic");for(let i of r)if((null===(a=i.getAttributeNode("name"))||void 0===a?void 0:a.nodeValue)&&i.textContent&&e){let r=null===(d=null===(u=n.parentElement)||void 0===u?void 0:u.parentElement)||void 0===d?void 0:d.querySelector("costs>cost"),o=e;if(r&&(null===(h=r.getAttributeNode("value"))||void 0===h?void 0:h.nodeValue)){let e=null===(f=r.getAttributeNode("value"))||void 0===f?void 0:f.nodeValue;e&&+e>0&&(o+=" ("+Math.floor(+e)+" EP)")}t._abilities.set(o,i.textContent)}if(n.parentElement&&n.parentElement.parentElement){const r=n.parentElement.parentElement;"upgrade"===(null===(p=r.getAttributeNode("type"))||void 0===p?void 0:p.nodeValue)&&r.parentElement&&r.parentElement.parentElement&&"model"===(null===(_=r.parentElement.parentElement.getAttributeNode("type"))||void 0===_?void 0:_.nodeValue)&&t._upgrades.push(e)}}else if("Weapons"===r){let e=new l;b(n,e),n.parentElement&&n.parentElement.parentElement&&m(n.parentElement.parentElement,t._rules),e._count=y(n);let r=n.querySelectorAll("characteristics>characteristic");for(let t of r){let n=null===(g=t.getAttributeNode("name"))||void 0===g?void 0:g.nodeValue;if(n&&t.textContent)switch(n){case"A":e._attacks=t.textContent;break;case"WS/BS":e._skill=t.textContent;break;case"D":e._damage=t.textContent;break;case"SR":e._rules=t.textContent;break;case"!":e._criticalEffects=t.textContent}}t._weapons.push(e)}else if("Psychic Power"==r){let e=new c;b(n,e);let r=n.querySelectorAll("characteristics>characteristic");for(let t of r)"Effect"===(null===(w=t.getAttributeNode("name"))||void 0===w?void 0:w.nodeValue)&&t.textContent&&(e._effect=t.textContent);t._psychicPowers.push(e)}else v(n,t)}}function x(e,t){return E(e._name,t._name)}function E(e,t){return e>t?1:e==t?0:-1}t.RosterKT21=f,t.CreateKT21Roster=function(e){var t;if(e){let n=e.querySelector("roster");if(n){const r=new f,i=null===(t=n.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;return r._name=i||"Kill Team (2021) Army Roster",function(e,t){var n,r;let i=e.querySelectorAll("roster>costs>cost");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("value")){let i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("value"))||void 0===r?void 0:r.nodeValue;o&&" EP"==i&&(t._equipmentPoints=+o)}}(e,r),function(e,t){var n,r,i;let o=e.querySelectorAll("roster>forces>force");for(let e of o)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let o=new h,l=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,c=null===(r=e.getAttributeNode("catalogueName"))||void 0===r?void 0:r.nodeValue;if(l&&(o._name=l),c&&(o._catalog=c,o._faction=c),!_(o,t)){var s=e.querySelectorAll("force>rules>rule");for(let e of s)if(e.hasAttribute("name")){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;var a=e.querySelector("rule>description");t&&a&&o._rules.set(t,a.textContent)}}p(e,o),t._forces.push(o)}}(e,r),r}}return null},t.Compare=E},452:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateMESBGRoster=void 0;const n=/\r\n|\r|\n| /,r=e=>{var t;return null!==(t=e.getAttribute("catalogueName"))&&void 0!==t?t:"MESBG Force"},i=e=>{var t;const n={half:0,quarter:0,modelCount:0};for(let r of e.querySelectorAll("rules>rule")){const e=null!==(t=r.getAttribute("name"))&&void 0!==t?t:"";if(e.endsWith("is halfway. (model)")){const t=parseFloat(e);isNaN(t)||(n.half=Math.ceil(t))}if(e.endsWith("models remaining. (model)")){const t=parseFloat(e);isNaN(t)||(n.quarter=Math.ceil(t))}if(e.endsWith("total models in Army. (model)")){const t=parseFloat(e);isNaN(t)||(n.modelCount=t)}}return n},o=e=>{var t,r,i,o,s,a,l,c,u,d,h,f,p,_,m,g,v,b,y;let w="",C="",x="",E=[],S="",k=!1;const A=[];for(let u of e.querySelectorAll('profiles > profile[typeName="Hero"]'))for(let e of u.querySelectorAll("characteristics > characteristic"))switch(null!==(r=null===(t=e.getAttribute("name"))||void 0===t?void 0:t.trim())&&void 0!==r?r:""){case"Might":x=null!==(i=e.textContent)&&void 0!==i?i:"";break;case"Fate":w=null!==(o=e.textContent)&&void 0!==o?o:"";break;case"Will":C=null!==(s=e.textContent)&&void 0!==s?s:"";break;case"Heroic Actions":E=null!==(l=null===(a=e.textContent)||void 0===a?void 0:a.split(n))&&void 0!==l?l:[];break;case"Heroic Tier":S=null!==(c=e.textContent)&&void 0!==c?c:""}for(let t of e.querySelectorAll('profile[typeName="Magical Power"]')){const e=null!==(u=t.getAttribute("name"))&&void 0!==u?u:"Unnamed Magic Power",n=null!==(h=null===(d=t.querySelector(':scope characteristic[name~="Duration"]'))||void 0===d?void 0:d.textContent)&&void 0!==h?h:"",r=null!==(p=null===(f=t.querySelector(':scope characteristic[name~="Range"]'))||void 0===f?void 0:f.textContent)&&void 0!==p?p:"",i=null!==(m=null===(_=t.querySelector(':scope characteristic[name~="Casting"]'))||void 0===_?void 0:_.textContent)&&void 0!==m?m:"",o=null!==(v=null===(g=t.querySelector(':scope characteristic[name~="Rule"]'))||void 0===g?void 0:g.textContent)&&void 0!==v?v:"",s=null!==(y=null===(b=t.querySelector(':scope characteristic[name~="Channelled"]'))||void 0===b?void 0:b.textContent)&&void 0!==y?y:"";A.push({name:e,duration:n,range:r,casting:i,normalEffect:o,channelledEffect:s})}return k=!!e.querySelector('selections > selection[name$="Leader (Valour)"]'),{fate:w,will:C,might:x,heroicTier:S,actions:E,magicalPowers:A,isLeader:k}},s=e=>{var t,r,i,a,u,d,h,f,p,_,m,g,v,b,y,w,C,x,E,S,k,A,T,N,L;const R=(e=>{var t,n,r;const i=[];for(let o of e)if(o.hasAttribute("name")){const e=null!==(t=o.getAttribute("name"))&&void 0!==t?t:null,s=null!==(r=null===(n=o.querySelector("rule>description"))||void 0===n?void 0:n.textContent)&&void 0!==r?r:"";null!==e&&i.push({name:e,ruleText:s})}return i})(null!==(t=e.querySelectorAll("rules > rule"))&&void 0!==t?t:[]),P=null!==(i=null===(r=e.getAttribute("name"))||void 0===r?void 0:r.trim())&&void 0!==i?i:"Unknown Model Name";let O=[];const W=[];let z,I,B="",M="",U="",D="",F="",q="",H="";e.querySelectorAll("profiles > profile");for(let t of e.querySelectorAll(":scope profiles > profile")){const r=t.getAttribute("typeName"),i=null!==(u=null===(a=t.getAttribute("name"))||void 0===a?void 0:a.trim())&&void 0!==u?u:"wowza";if(("Hero"===r||"Warrior"===r)&&i.startsWith(P)){for(let e of t.querySelectorAll("characteristics > characteristic"))switch(null!==(h=null===(d=e.getAttribute("name"))||void 0===d?void 0:d.trim())&&void 0!==h?h:""){case"Wounds":q=null!==(f=e.textContent)&&void 0!==f?f:"";break;case"Courage":H=null!==(p=e.textContent)&&void 0!==p?p:"";break;case"Attack":F=null!==(_=e.textContent)&&void 0!==_?_:"";break;case"Defense":D=null!==(m=e.textContent)&&void 0!==m?m:"";break;case"Strength":U=null!==(g=e.textContent)&&void 0!==g?g:"";break;case"Fight":M=null!==(v=e.textContent)&&void 0!==v?v:"";break;case"Movement":B=null!==(b=e.textContent)&&void 0!==b?b:"";break;case"Keywords":O=null!==(w=null===(y=e.textContent)||void 0===y?void 0:y.split(n))&&void 0!==w?w:[]}for(let t of null!==(C=l(e))&&void 0!==C?C:[]){if("Shield"===t.getAttribute("name")||t.querySelector('profile[typeName$="Wargear"]')||t.querySelector('profile[typeName$="Shooting Weapon"]')){const e=null!==(x=t.getAttribute("name"))&&void 0!==x?x:"Equipment",n=parseInt(null!==(S=null===(E=t.querySelector('cost[name$="Points"]'))||void 0===E?void 0:E.getAttribute("value"))&&void 0!==S?S:"0"),r=[];for(let e of t.querySelectorAll("characteristics > characteristic"))null!==e.textContent&&r.push(e.textContent);W.push({name:e,points:n,rules:r})}t.querySelector('profile[typeName$="Warrior"]')&&(z=s(null===(A=null===(k=t.querySelector('profile[typeName$="Warrior"]'))||void 0===k?void 0:k.parentElement)||void 0===A?void 0:A.parentElement))}"Hero"===r&&(I=o(e))}}let j=0;for(let t of null!==(T=c(e))&&void 0!==T?T:[])"Points"===(null===(N=t.getAttribute("name"))||void 0===N?void 0:N.trim())&&(j=parseInt(null!==(L=t.getAttribute("value"))&&void 0!==L?L:"0"));return{name:P,points:j,keywords:O,rules:R,profile:{attack:F,courage:H,defense:D,fight:M,movement:B,strength:U,wounds:q},wargear:W,mount:z,heroStuff:I}},a=e=>{var t,n,r,i;const o=[];for(let a of null!==(t=l(e))&&void 0!==t?t:[]){const e=a.querySelector('selection[type~="model"]');if(null!==e){const t=s(a),l=parseInt(null!==(n=e.getAttribute("number"))&&void 0!==n?n:"0"),c=parseInt(null!==(i=null===(r=e.querySelector('cost[name~="Points"]'))||void 0===r?void 0:r.getAttribute("value"))&&void 0!==i?i:"0");o.push({model:t,count:l,points:c})}}return o},l=e=>{var t,n;return null!==(n=null===(t=e.querySelector("selections"))||void 0===t?void 0:t.querySelectorAll(":scope > selection"))&&void 0!==n?n:null},c=e=>{var t,n;return null!==(n=null===(t=e.querySelector("costs"))||void 0===t?void 0:t.querySelectorAll(":scope > cost"))&&void 0!==n?n:null},u=e=>{let t=null,n=[];const r=l(e);if(null===r)return r;for(let e of r)"model"===e.getAttribute("type")&&(t=s(e)),"Warband"===e.getAttribute("name")&&(n=a(e));return null!==t?{leader:t,warband:n}:null},d=e=>{var t;let n=!1;for(let r of null!==(t=l(e))&&void 0!==t?t:[])"model"===r.getAttribute("type")&&(n=!0);return n};t.CreateMESBGRoster=function(e){var t,n;if(e){const o=null!==(n=null===(t=e.querySelector("roster"))||void 0===t?void 0:t.getAttribute("name"))&&void 0!==n?n:"Middle-Earth Stratgegy Battle Game Roster",{points:s,warriors:a}=(e=>{var t,n,r,i;const o=e.querySelectorAll("roster>costs>cost");let s=0,a=0;for(let e of o)"Points"===(null===(t=e.getAttribute("name"))||void 0===t?void 0:t.trim())&&(s=parseInt(null!==(n=e.getAttribute("value"))&&void 0!==n?n:"0")),"Warriors"===(null===(r=e.getAttribute("name"))||void 0===r?void 0:r.trim())&&(a=parseInt(null!==(i=e.getAttribute("value"))&&void 0!==i?i:"0"));return{points:s,warriors:a}})(e),c=(e=>{var t,n,o;const s=e.querySelectorAll("roster>forces>force"),a=[];for(let e of s){const s=r(e);let c={half:0,quarter:0,modelCount:0};const h=[],f=[],p=l(e);if(null!==p){for(let e of p)if("Determine Breakpoint & 25%"===e.getAttribute("name"))c=i(e);else if(d(e)){const t=u(e);null!==t&&h.push(t)}else{const r=e.querySelectorAll("rules > rule");for(let e of r){const r=null!==(n=null===(t=e.querySelector("description"))||void 0===t?void 0:t.textContent)&&void 0!==n?n:"";f.push({name:null!==(o=e.getAttribute("name"))&&void 0!==o?o:"",ruleText:r})}}a.push({name:s,breakpoints:c,units:h,armyBonus:f})}}return a})(e);return{name:o,forces:c,points:s,warriors:a}}return alert("Bad Input File"),null}},320:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateWarcryRoster=t.RosterWarcry=t.WarcryForce=t.WarcryUnit=t.WarcryDamageTable=t.WarcryUnitRoleToString=t.WarcryUnitRole=t.WarcryWeapon=t.WarcryAllegiance=void 0;class n{constructor(){this._name="",this._rules=new Map}}t.WarcryAllegiance=n;class r{constructor(){this._name="",this._range="",this._attacks="",this._strength="",this._damage=""}}var i;t.WarcryWeapon=r,function(e){e[e.NONE=0]="NONE",e[e.LEADER=1]="LEADER",e[e.FIGHTER=2]="FIGHTER",e[e.ALLY=3]="ALLY",e[e.MONSTER=4]="MONSTER",e[e.HERO=5]="HERO",e[e.THRALL=6]="THRALL"}(i=t.WarcryUnitRole||(t.WarcryUnitRole={})),t.WarcryUnitRoleToString=["None","Leader","Fighter","Ally","Monster","Hero","Thrall"];class o{constructor(){this._name="",this._table=new Map}}t.WarcryDamageTable=o;class s{constructor(){this._name="",this._role=i.NONE,this._faction="chaos-iron-golems",this._keywords=new Set,this._abilities=new Map,this._move="1",this._wounds="1",this._toughness="1",this._weapons=[],this._damageTable=[],this._points=0}}t.WarcryUnit=s;class a{constructor(){this._catalog="",this._name="Unknown",this._units=[],this._allegiance=new n}}t.WarcryForce=a;class l{constructor(){this._points=0,this._name="",this._forces=[]}}function c(e){const t=e.toLowerCase();return t.includes("chaotic beasts")?"monster-chaotic-beasts":t.includes("monster")?t.includes("order")?"monster-of-order":t.includes("destruction")?"monster-of-destruction":t.includes("death")?"monster-of-death":"monster-chaotic-beasts":t.includes("beasts of chaos")?"factions-chaos-beasts-of-chaos":t.includes("corvus")?"factions-chaos-corvus-cabal":t.includes("cypher")?"factions-chaos-cypher-lords":t.includes("everchosen")?"factions-chaos-everchosen":t.includes("golems")?"factions-chaos-iron-golems":t.includes("khorne")&&t.includes("bloodbound")?"factions-chaos-khorne-bloodbound":t.includes("khorne")&&t.includes("daemon")?"factions-chaos-khorne-daemons":t.includes("nurgle")&&t.includes("rotbringer")?"factions-chaos-nurgle-rotbringers":t.includes("nurgle")&&t.includes("daemon")?"factions-chaos-nurgle-daemons":t.includes("scions")?"factions-chaos-scions-of-the-flame":t.includes("skaven")?"factions-chaos-skaven":t.includes("slaanesh")&&t.includes("sybariteI g")?"factions-chaos-slaanesh-syberites":t.includes("slaanesh")&&t.includes("daemon")?"factions-chaos-slaanesh-daemons":t.includes("slaves")?"factions-chaos-slaves-to-darkness":t.includes("spire")?"factions-chaos-spire-tyrants":t.includes("splintered")?"factions-chaos-splintered-fang":t.includes("unmade")?"factions-chaos-the-unmade":t.includes("tzeentch")&&t.includes("arcanite")?"factions-chaos-tzeentch-arcanites":t.includes("tzeentch")&&t.includes("daemon")?"factions-chaos-tzeentch-daemons":t.includes("untamed")?"factions-chaos-untamed-beasts":t.includes("flesh")?"factions-death-flesh-eater-courts":t.includes("nagash")?"factions-death-legions-of-nagash":t.includes("nighthaunt")?"factions-death-nighthaunt":t.includes("ossiarch")?"factions-death-ossiarch-bonereapers":t.includes("soulblight")?"factions-death-soulblight-gravelords":t.includes("bonesplitterz")?"factions-destruction-bonesplitterz":t.includes("fimirach")?"factions-destruction-fimirach":t.includes("gloomspite")?"factions-destruction-gloomspite-gitz":t.includes("ironjawz")?"factions-destruction-ironjawz":t.includes("kruleboyz")?"factions-destruction-kruleboyz":t.includes("ogor")?"factions-destruction-ogor-mawtribes":t.includes("cities of sigmar")?"factions-order-cities-of-sigmar":t.includes("khaine")?"factions-order-daughters-of-khaine":t.includes("fyreslayers")?"factions-order-fyreslayers":t.includes("idoneth")?"factions-order-idoneth-deepkin":t.includes("shadowstalkers")?"factions-order-khainite-shadowstalkers":t.includes("kharadron")?"factions-order-kharadron-overlords":t.includes("lumineth")?"factions-order-lumineth-realmlords":t.includes("seraphon")?"factions-order-seraphon":t.includes("stormcast")?t.includes("sacrosanct")?"factions-order-stormcast-eternals-sacrosanct":t.includes("thunderstrike")?"factions-order-stormcast-eternals-thunderstrike":t.includes("vanguard")?"factions-order-stormcast-eternals-vanguard":"factions-order-stormcast-eternals-warrior":t.includes("sylvaneth")?"factions-order-sylvaneth":""}function u(e,t){var r;let i=new n,o=e.querySelectorAll("rules>rule");for(let e of o)if(e.hasAttribute("name")){let t=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue;var s=e.querySelector("rule>description");t&&s&&s.textContent&&i._rules.set(t,s.textContent)}t._allegiance=i}function d(e,t){var n,r;let o=e.querySelectorAll("force>selections>selection");for(let e of o){if(!(null===(n=e.getAttributeNode("type"))||void 0===n?void 0:n.nodeValue))continue;if(!(null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue))continue;let o=h(e);o&&o._role!=i.NONE&&t._units.push(o)}t._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?0:-1))}function h(e){var t,n,a,l,u,d,h,f,p;let _=new s,m=e.querySelectorAll("profiles>profile");for(let e of m){let i=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue,s=null===(n=e.getAttributeNode("typeName"))||void 0===n?void 0:n.nodeValue;if(i&&s)if("Model"==s){_._name=i;let t=e.querySelectorAll("characteristics>characteristic");for(let e of t){let t=null===(a=e.getAttributeNode("name"))||void 0===a?void 0:a.nodeValue;if(t&&e.textContent)switch(t){case"Move":_._move=e.textContent;break;case"Wounds":_._wounds=e.textContent;break;case"Toughness":_._toughness=e.textContent}}}else if("Weapon"==s){let t=new r;t._name=i;let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let n=null===(l=e.getAttributeNode("name"))||void 0===l?void 0:l.nodeValue;if(n&&e.textContent)switch(n){case"Range":t._range=e.textContent;break;case"Attacks":t._attacks=e.textContent;break;case"Strength":t._strength=e.textContent;break;case"Damage":t._damage=e.textContent}}_._weapons.push(t)}else if("Damage Points Allocated"==s){let t=new o;t._name=i;let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let n=null===(u=e.getAttributeNode("name"))||void 0===u?void 0:u.nodeValue;n&&i&&(e.textContent?t._table.set(n,e.textContent):t._table.set(n,"-"))}_._damageTable.push(t)}else console.log("Unknown unit profile type: "+s)}let g=e.querySelectorAll("costs>cost");for(let e of g)if(e.hasAttribute("name")&&e.hasAttribute("value")){let t=null===(d=e.getAttributeNode("name"))||void 0===d?void 0:d.nodeValue,n=null===(h=e.getAttributeNode("value"))||void 0===h?void 0:h.nodeValue;n&&"pts"===t&&(_._points+=+n)}let v=e.querySelectorAll(":scope categories>category");for(let e of v){let t=null===(f=e.getAttributeNode("name"))||void 0===f?void 0:f.nodeValue;if(t){var b=(y=t.trim()).includes("Leader")?i.LEADER:y.includes("Fighter")?i.FIGHTER:y.includes("Allies")||y.includes("Ally")?i.ALLY:y.includes("Monster")?i.MONSTER:y.includes("Hero")?i.HERO:y.includes("Thrall")?i.THRALL:i.NONE;b!=i.NONE?_._role=b:_._keywords.add(t)}}var y;let w=e.querySelectorAll(":scope selections>selection");for(let e of w){let t=null===(p=e.getAttributeNode("name"))||void 0===p?void 0:p.nodeValue;if(t){let e=c(t);e.length>0?_._faction=e:_._keywords.add(t)}}return _}t.RosterWarcry=l,t.CreateWarcryRoster=function(e){var t;if(e){let n=e.querySelector("roster");if(n){const r=new l,i=null===(t=n.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;return r._name=i||"Age of Sigmar Warcry Roster",function(e,t){var n,r;let i=e.querySelectorAll("roster>costs>cost");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("value")){let i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("value"))||void 0===r?void 0:r.nodeValue;o&&"pts"===i&&(t._points=+o)}}(e,r),function(e,t){var n,r;let i=e.querySelectorAll("roster>forces>force");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let i=new a,o=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("catalogueName"))||void 0===r?void 0:r.nodeValue;o&&(i._name=o),s&&(i._catalog=s),u(e,i),d(e,i),t._forces.push(i)}console.log(t)}(e,r),r}}return null}},596:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.formatStat=t.filterAndOrderStats=void 0,t.filterAndOrderStats=function(e){return Object.entries(e).filter((e=>e[1].statOrder>=0&&void 0===e[1].groupOrder&&"normal"===e[1].visibility)).sort(((e,t)=>e[1].statOrder-t[1].statOrder))},t.formatStat=function(e){const t=String(e.value);return e.format?e.format.replace(/{[vt]}/,t):t}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),n(752)})(); \ No newline at end of file +(()=>{var e={733:(e,t,n)=>{e.exports=function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[s]={exports:{}};t[s][0].call(c.exports,(function(e){return i(t[s][1][e]||e)}),c,c.exports,e,t,n,r)}return n[s].exports}for(var o=void 0,s=0;s>2,a=(3&t)<<4|n>>4,l=1>6:64,c=2>4,n=(15&s)<<4|(a=o.indexOf(e.charAt(c++)))>>2,r=(3&a)<<6|(l=o.indexOf(e.charAt(c++))),h[u++]=t,64!==a&&(h[u++]=n),64!==l&&(h[u++]=r);return h}},{"./support":30,"./utils":32}],2:[function(e,t,n){"use strict";var r=e("./external"),i=e("./stream/DataWorker"),o=e("./stream/Crc32Probe"),s=e("./stream/DataLengthProbe");function a(e,t,n,r,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=n,this.compression=r,this.compressedContent=i}a.prototype={getContentWorker:function(){var e=new i(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new s("data_length")),t=this;return e.on("end",(function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),e},getCompressedWorker:function(){return new i(r.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},a.createWorkerFrom=function(e,t,n){return e.pipe(new o).pipe(new s("uncompressedSize")).pipe(t.compressWorker(n)).pipe(new s("compressedSize")).withStreamInfo("compression",t)},t.exports=a},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,n){"use strict";var r=e("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(e){return new r("STORE compression")},uncompressWorker:function(){return new r("STORE decompression")}},n.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,n){"use strict";var r=e("./utils"),i=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==r.getTypeOf(e)?function(e,t,n,r){var o=i,s=0+n;e^=-1;for(var a=0;a>>8^o[255&(e^t[a])];return-1^e}(0|t,e,e.length):function(e,t,n,r){var o=i,s=0+n;e^=-1;for(var a=0;a>>8^o[255&(e^t.charCodeAt(a))];return-1^e}(0|t,e,e.length):0}},{"./utils":32}],5:[function(e,t,n){"use strict";n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(e,t,n){"use strict";var r;r="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:r}},{lie:37}],7:[function(e,t,n){"use strict";var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=e("pako"),o=e("./utils"),s=e("./stream/GenericWorker"),a=r?"uint8array":"array";function l(e,t){s.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}n.magic="\b\0",o.inherits(l,s),l.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(o.transformTo(a,e.data),!1)},l.prototype.flush=function(){s.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},l.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this._pako=null},l.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},n.compressWorker=function(e){return new l("Deflate",e)},n.uncompressWorker=function(){return new l("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,n){"use strict";function r(e,t){var n,r="";for(n=0;n>>=8;return r}function i(e,t,n,i,s,u){var d,h,f=e.file,p=e.compression,_=u!==a.utf8encode,m=o.transformTo("string",u(f.name)),g=o.transformTo("string",a.utf8encode(f.name)),v=f.comment,b=o.transformTo("string",u(v)),y=o.transformTo("string",a.utf8encode(v)),w=g.length!==f.name.length,C=y.length!==v.length,x="",E="",S="",k=f.dir,A=f.date,T={crc32:0,compressedSize:0,uncompressedSize:0};t&&!n||(T.crc32=e.crc32,T.compressedSize=e.compressedSize,T.uncompressedSize=e.uncompressedSize);var N=0;t&&(N|=8),_||!w&&!C||(N|=2048);var L=0,R=0;k&&(L|=16),"UNIX"===s?(R=798,L|=function(e,t){var n=e;return e||(n=t?16893:33204),(65535&n)<<16}(f.unixPermissions,k)):(R=20,L|=function(e){return 63&(e||0)}(f.dosPermissions)),d=A.getUTCHours(),d<<=6,d|=A.getUTCMinutes(),d<<=5,d|=A.getUTCSeconds()/2,h=A.getUTCFullYear()-1980,h<<=4,h|=A.getUTCMonth()+1,h<<=5,h|=A.getUTCDate(),w&&(E=r(1,1)+r(l(m),4)+g,x+="up"+r(E.length,2)+E),C&&(S=r(1,1)+r(l(b),4)+y,x+="uc"+r(S.length,2)+S);var P="";return P+="\n\0",P+=r(N,2),P+=p.magic,P+=r(d,2),P+=r(h,2),P+=r(T.crc32,4),P+=r(T.compressedSize,4),P+=r(T.uncompressedSize,4),P+=r(m.length,2),P+=r(x.length,2),{fileRecord:c.LOCAL_FILE_HEADER+P+m+x,dirRecord:c.CENTRAL_FILE_HEADER+r(R,2)+P+r(b.length,2)+"\0\0\0\0"+r(L,4)+r(i,4)+m+x+b}}var o=e("../utils"),s=e("../stream/GenericWorker"),a=e("../utf8"),l=e("../crc32"),c=e("../signature");function u(e,t,n,r){s.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=n,this.encodeFileName=r,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(u,s),u.prototype.push=function(e){var t=e.meta.percent||0,n=this.entriesCount,r=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,s.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:n?(t+100*(n-r-1))/n:100}}))},u.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var n=i(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:n.fileRecord,meta:{percent:0}})}else this.accumulate=!0},u.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,n=i(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(n.dirRecord),t)this.push({data:function(e){return c.DATA_DESCRIPTOR+r(e.crc32,4)+r(e.compressedSize,4)+r(e.uncompressedSize,4)}(e),meta:{percent:100}});else for(this.push({data:n.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},u.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t=this.index;t--)n=(n<<8)+this.byteAt(t);return this.index+=e,n},readString:function(e){return r.transformTo("string",this.readData(e))},readData:function(e){},lastIndexOfSignature:function(e){},readAndCheckSignature:function(e){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i},{"../utils":32}],19:[function(e,t,n){"use strict";var r=e("./Uint8ArrayReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,n){"use strict";var r=e("./DataReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],21:[function(e,t,n){"use strict";var r=e("./ArrayReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,n){"use strict";var r=e("../utils"),i=e("../support"),o=e("./ArrayReader"),s=e("./StringReader"),a=e("./NodeBufferReader"),l=e("./Uint8ArrayReader");t.exports=function(e){var t=r.getTypeOf(e);return r.checkSupport(t),"string"!==t||i.uint8array?"nodebuffer"===t?new a(e):i.uint8array?new l(r.transformTo("uint8array",e)):new o(r.transformTo("array",e)):new s(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,n){"use strict";n.LOCAL_FILE_HEADER="PK",n.CENTRAL_FILE_HEADER="PK",n.CENTRAL_DIRECTORY_END="PK",n.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",n.ZIP64_CENTRAL_DIRECTORY_END="PK",n.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,n){"use strict";var r=e("./GenericWorker"),i=e("../utils");function o(e){r.call(this,"ConvertWorker to "+e),this.destType=e}i.inherits(o,r),o.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta})},t.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,n){"use strict";var r=e("./GenericWorker"),i=e("../crc32");function o(){r.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(o,r),o.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,n){"use strict";var r=e("../utils"),i=e("./GenericWorker");function o(e){i.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}r.inherits(o,i),o.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}i.prototype.processChunk.call(this,e)},t.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,n){"use strict";var r=e("../utils"),i=e("./GenericWorker");function o(e){i.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then((function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=r.getTypeOf(e),t.isPaused||t._tickAndRepeat()}),(function(e){t.error(e)}))}r.inherits(o,i),o.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,n){"use strict";function r(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}r.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var n=0;n "+e:e}},t.exports=r},{}],29:[function(e,t,n){"use strict";var r=e("../utils"),i=e("./ConvertWorker"),o=e("./GenericWorker"),s=e("../base64"),a=e("../support"),l=e("../external"),c=null;if(a.nodestream)try{c=e("../nodejs/NodejsStreamOutputAdapter")}catch(e){}function u(e,t,n){var s=t;switch(t){case"blob":case"arraybuffer":s="uint8array";break;case"base64":s="string"}try{this._internalType=s,this._outputType=t,this._mimeType=n,r.checkSupport(s),this._worker=e.pipe(new i(s)),e.lock()}catch(e){this._worker=new o("error"),this._worker.error(e)}}u.prototype={accumulate:function(e){return function(e,t){return new l.Promise((function(n,i){var o=[],a=e._internalType,l=e._outputType,c=e._mimeType;e.on("data",(function(e,n){o.push(e),t&&t(n)})).on("error",(function(e){o=[],i(e)})).on("end",(function(){try{var e=function(e,t,n){switch(e){case"blob":return r.newBlob(r.transformTo("arraybuffer",t),n);case"base64":return s.encode(t);default:return r.transformTo(e,t)}}(l,function(e,t){var n,r=0,i=null,o=0;for(n=0;n>>6:(n<65536?t[s++]=224|n>>>12:(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63),t[s++]=128|n>>>6&63),t[s++]=128|63&n);return t}(e)},n.utf8decode=function(e){return i.nodebuffer?r.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,n,i,o,s=e.length,l=new Array(2*s);for(t=n=0;t>10&1023,l[n++]=56320|1023&i)}return l.length!==n&&(l.subarray?l=l.subarray(0,n):l.length=n),r.applyFromCharCode(l)}(e=r.transformTo(i.uint8array?"uint8array":"array",e))},r.inherits(c,s),c.prototype.processChunk=function(e){var t=r.transformTo(i.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var o=t;(t=new Uint8Array(o.length+this.leftOver.length)).set(this.leftOver,0),t.set(o,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var s=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+a[e[n]]>t?n:t}(t),l=t;s!==t.length&&(i.uint8array?(l=t.subarray(0,s),this.leftOver=t.subarray(s,t.length)):(l=t.slice(0,s),this.leftOver=t.slice(s,t.length))),this.push({data:n.utf8decode(l),meta:e.meta})},c.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=c,r.inherits(u,s),u.prototype.processChunk=function(e){this.push({data:n.utf8encode(e.data),meta:e.meta})},n.Utf8EncodeWorker=u},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,n){"use strict";var r=e("./support"),i=e("./base64"),o=e("./nodejsUtils"),s=e("./external");function a(e){return e}function l(e,t){for(var n=0;n>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(e){if(this.extraFields[1]){var t=r(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=t.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=t.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=t.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=t.readInt(4))}},readExtraFields:function(e){var t,n,r,i=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4>>6:(n<65536?t[s++]=224|n>>>12:(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63),t[s++]=128|n>>>6&63),t[s++]=128|63&n);return t},n.buf2binstring=function(e){return l(e,e.length)},n.binstring2buf=function(e){for(var t=new r.Buf8(e.length),n=0,i=t.length;n>10&1023,c[r++]=56320|1023&i)}return l(c,r)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+s[e[n]]>t?n:t}},{"./common":41}],43:[function(e,t,n){"use strict";t.exports=function(e,t,n,r){for(var i=65535&e|0,o=e>>>16&65535|0,s=0;0!==n;){for(n-=s=2e3>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,i){var o=r,s=i+n;e^=-1;for(var a=i;a>>8^o[255&(e^t[a])];return-1^e}},{}],46:[function(e,t,n){"use strict";var r,i=e("../utils/common"),o=e("./trees"),s=e("./adler32"),a=e("./crc32"),l=e("./messages"),c=-2,u=258,d=262,h=113;function f(e,t){return e.msg=l[t],t}function p(e){return(e<<1)-(4e.avail_out&&(n=e.avail_out),0!==n&&(i.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))}function g(e,t){o._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,m(e.strm)}function v(e,t){e.pending_buf[e.pending++]=t}function b(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function y(e,t){var n,r,i=e.max_chain_length,o=e.strstart,s=e.prev_length,a=e.nice_match,l=e.strstart>e.w_size-d?e.strstart-(e.w_size-d):0,c=e.window,h=e.w_mask,f=e.prev,p=e.strstart+u,_=c[o+s-1],m=c[o+s];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(c[(n=t)+s]===m&&c[n+s-1]===_&&c[n]===c[o]&&c[++n]===c[o+1]){o+=2,n++;do{}while(c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&ol&&0!=--i);return s<=e.lookahead?s:e.lookahead}function w(e){var t,n,r,o,l,c,u,h,f,p,_=e.w_size;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=_+(_-d)){for(i.arraySet(e.window,e.window,_,_,0),e.match_start-=_,e.strstart-=_,e.block_start-=_,t=n=e.hash_size;r=e.head[--t],e.head[t]=_<=r?r-_:0,--n;);for(t=n=_;r=e.prev[--t],e.prev[t]=_<=r?r-_:0,--n;);o+=_}if(0===e.strm.avail_in)break;if(c=e.strm,u=e.window,h=e.strstart+e.lookahead,p=void 0,(f=o)<(p=c.avail_in)&&(p=f),n=0===p?0:(c.avail_in-=p,i.arraySet(u,c.input,c.next_in,p,h),1===c.state.wrap?c.adler=s(c.adler,u,p,h):2===c.state.wrap&&(c.adler=a(c.adler,u,p,h)),c.next_in+=p,c.total_in+=p,p),e.lookahead+=n,e.lookahead+e.insert>=3)for(l=e.strstart-e.insert,e.ins_h=e.window[l],e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<=3)if(r=o._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<=3&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-3,r=o._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(w(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((0===e.strstart||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,g(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-d&&(g(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(g(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(g(e,!1),e.strm.avail_out),1)})),new E(4,4,8,4,C),new E(4,5,16,8,C),new E(4,6,32,32,C),new E(4,4,16,16,x),new E(8,16,32,32,x),new E(8,16,128,128,x),new E(8,32,128,256,x),new E(32,128,258,1024,x),new E(32,258,258,4096,x)],n.deflateInit=function(e,t){return T(e,t,8,15,8,0)},n.deflateInit2=T,n.deflateReset=A,n.deflateResetKeep=k,n.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?c:(e.state.gzhead=t,0):c},n.deflate=function(e,t){var n,i,s,l;if(!e||!e.state||5>8&255),v(i,i.gzhead.time>>16&255),v(i,i.gzhead.time>>24&255),v(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),v(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(v(i,255&i.gzhead.extra.length),v(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=a(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(v(i,0),v(i,0),v(i,0),v(i,0),v(i,0),v(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),v(i,3),i.status=h);else{var d=8+(i.w_bits-8<<4)<<8;d|=(2<=i.strategy||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(d|=32),d+=31-d%31,i.status=h,b(i,d),0!==i.strstart&&(b(i,e.adler>>>16),b(i,65535&e.adler)),e.adler=1}if(69===i.status)if(i.gzhead.extra){for(s=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),m(e),s=i.pending,i.pending!==i.pending_buf_size));)v(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){s=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),m(e),s=i.pending,i.pending===i.pending_buf_size)){l=1;break}l=i.gzindexs&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),0===l&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){s=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),m(e),s=i.pending,i.pending===i.pending_buf_size)){l=1;break}l=i.gzindexs&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),0===l&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&m(e),i.pending+2<=i.pending_buf_size&&(v(i,255&e.adler),v(i,e.adler>>8&255),e.adler=0,i.status=h)):i.status=h),0!==i.pending){if(m(e),0===e.avail_out)return i.last_flush=-1,0}else if(0===e.avail_in&&p(t)<=p(n)&&4!==t)return f(e,-5);if(666===i.status&&0!==e.avail_in)return f(e,-5);if(0!==e.avail_in||0!==i.lookahead||0!==t&&666!==i.status){var y=2===i.strategy?function(e,t){for(var n;;){if(0===e.lookahead&&(w(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(g(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(g(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(g(e,!1),0===e.strm.avail_out)?1:2}(i,t):3===i.strategy?function(e,t){for(var n,r,i,s,a=e.window;;){if(e.lookahead<=u){if(w(e),e.lookahead<=u&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&0e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=o._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(g(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(g(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(g(e,!1),0===e.strm.avail_out)?1:2}(i,t):r[i.level].func(i,t);if(3!==y&&4!==y||(i.status=666),1===y||3===y)return 0===e.avail_out&&(i.last_flush=-1),0;if(2===y&&(1===t?o._tr_align(i):5!==t&&(o._tr_stored_block(i,0,0,!1),3===t&&(_(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),m(e),0===e.avail_out))return i.last_flush=-1,0}return 4!==t?0:i.wrap<=0?1:(2===i.wrap?(v(i,255&e.adler),v(i,e.adler>>8&255),v(i,e.adler>>16&255),v(i,e.adler>>24&255),v(i,255&e.total_in),v(i,e.total_in>>8&255),v(i,e.total_in>>16&255),v(i,e.total_in>>24&255)):(b(i,e.adler>>>16),b(i,65535&e.adler)),m(e),0=n.w_size&&(0===a&&(_(n.head),n.strstart=0,n.block_start=0,n.insert=0),h=new i.Buf8(n.w_size),i.arraySet(h,t,f-n.w_size,n.w_size,0),t=h,f=n.w_size),l=e.avail_in,u=e.next_in,d=e.input,e.avail_in=f,e.next_in=0,e.input=t,w(n);n.lookahead>=3;){for(r=n.strstart,o=n.lookahead-2;n.ins_h=(n.ins_h<>>=y=b>>>24,p-=y,0==(y=b>>>16&255))k[o++]=65535&b;else{if(!(16&y)){if(0==(64&y)){b=_[(65535&b)+(f&(1<>>=y,p-=y),p<15&&(f+=S[r++]<>>=y=b>>>24,p-=y,!(16&(y=b>>>16&255))){if(0==(64&y)){b=m[(65535&b)+(f&(1<>>=y,p-=y,(y=o-s)>3,f&=(1<<(p-=w<<3))-1,e.next_in=r,e.next_out=o,e.avail_in=r>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function u(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function d(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new r.Buf32(852),t.distcode=t.distdyn=new r.Buf32(592),t.sane=1,t.back=-1,0):l}function h(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,d(e)):l}function f(e,t){var n,r;return e&&e.state?(r=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15=s.wsize?(r.arraySet(s.window,t,n-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(i<(o=s.wsize-s.wnext)&&(o=i),r.arraySet(s.window,t,n-i,o,s.wnext),(i-=o)?(r.arraySet(s.window,t,n-i,i,0),s.wnext=i,s.whave=s.wsize):(s.wnext+=o,s.wnext===s.wsize&&(s.wnext=0),s.whave>>8&255,n.check=o(n.check,I,2,0),g=m=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&m)<<8)+(m>>8))%31){e.msg="incorrect header check",n.mode=30;break}if(8!=(15&m)){e.msg="unknown compression method",n.mode=30;break}if(g-=4,R=8+(15&(m>>>=4)),0===n.wbits)n.wbits=R;else if(R>n.wbits){e.msg="invalid window size",n.mode=30;break}n.dmax=1<>8&1),512&n.flags&&(I[0]=255&m,I[1]=m>>>8&255,n.check=o(n.check,I,2,0)),g=m=0,n.mode=3;case 3:for(;g<32;){if(0===p)break e;p--,m+=u[h++]<>>8&255,I[2]=m>>>16&255,I[3]=m>>>24&255,n.check=o(n.check,I,4,0)),g=m=0,n.mode=4;case 4:for(;g<16;){if(0===p)break e;p--,m+=u[h++]<>8),512&n.flags&&(I[0]=255&m,I[1]=m>>>8&255,n.check=o(n.check,I,2,0)),g=m=0,n.mode=5;case 5:if(1024&n.flags){for(;g<16;){if(0===p)break e;p--,m+=u[h++]<>>8&255,n.check=o(n.check,I,2,0)),g=m=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&(p<(C=n.length)&&(C=p),C&&(n.head&&(R=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),r.arraySet(n.head.extra,u,h,C,R)),512&n.flags&&(n.check=o(n.check,u,C,h)),p-=C,h+=C,n.length-=C),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===p)break e;for(C=0;R=u[h+C++],n.head&&R&&n.length<65536&&(n.head.name+=String.fromCharCode(R)),R&&C>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;g<32;){if(0===p)break e;p--,m+=u[h++]<>>=7&g,g-=7&g,n.mode=27;break}for(;g<3;){if(0===p)break e;p--,m+=u[h++]<>>=1)){case 0:n.mode=14;break;case 1:if(v(n),n.mode=20,6!==t)break;m>>>=2,g-=2;break e;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=30}m>>>=2,g-=2;break;case 14:for(m>>>=7&g,g-=7&g;g<32;){if(0===p)break e;p--,m+=u[h++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&m,g=m=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(C=n.length){if(p>>=5,g-=5,n.ndist=1+(31&m),m>>>=5,g-=5,n.ncode=4+(15&m),m>>>=4,g-=4,286>>=3,g-=3}for(;n.have<19;)n.lens[B[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,O={bits:n.lenbits},P=a(0,n.lens,0,19,n.lencode,0,n.work,O),n.lenbits=O.bits,P){e.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have>>16&255,A=65535&z,!((S=z>>>24)<=g);){if(0===p)break e;p--,m+=u[h++]<>>=S,g-=S,n.lens[n.have++]=A;else{if(16===A){for(W=S+2;g>>=S,g-=S,0===n.have){e.msg="invalid bit length repeat",n.mode=30;break}R=n.lens[n.have-1],C=3+(3&m),m>>>=2,g-=2}else if(17===A){for(W=S+3;g>>=S)),m>>>=3,g-=3}else{for(W=S+7;g>>=S)),m>>>=7,g-=7}if(n.have+C>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=30;break}for(;C--;)n.lens[n.have++]=R}}if(30===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,O={bits:n.lenbits},P=a(1,n.lens,0,n.nlen,n.lencode,0,n.work,O),n.lenbits=O.bits,P){e.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,O={bits:n.distbits},P=a(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,O),n.distbits=O.bits,P){e.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(6<=p&&258<=_){e.next_out=f,e.avail_out=_,e.next_in=h,e.avail_in=p,n.hold=m,n.bits=g,s(e,w),f=e.next_out,d=e.output,_=e.avail_out,h=e.next_in,u=e.input,p=e.avail_in,m=n.hold,g=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;k=(z=n.lencode[m&(1<>>16&255,A=65535&z,!((S=z>>>24)<=g);){if(0===p)break e;p--,m+=u[h++]<>T)])>>>16&255,A=65535&z,!(T+(S=z>>>24)<=g);){if(0===p)break e;p--,m+=u[h++]<>>=T,g-=T,n.back+=T}if(m>>>=S,g-=S,n.back+=S,n.length=A,0===k){n.mode=26;break}if(32&k){n.back=-1,n.mode=12;break}if(64&k){e.msg="invalid literal/length code",n.mode=30;break}n.extra=15&k,n.mode=22;case 22:if(n.extra){for(W=n.extra;g>>=n.extra,g-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;k=(z=n.distcode[m&(1<>>16&255,A=65535&z,!((S=z>>>24)<=g);){if(0===p)break e;p--,m+=u[h++]<>T)])>>>16&255,A=65535&z,!(T+(S=z>>>24)<=g);){if(0===p)break e;p--,m+=u[h++]<>>=T,g-=T,n.back+=T}if(m>>>=S,g-=S,n.back+=S,64&k){e.msg="invalid distance code",n.mode=30;break}n.offset=A,n.extra=15&k,n.mode=24;case 24:if(n.extra){for(W=n.extra;g>>=n.extra,g-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===_)break e;if(C=w-_,n.offset>C){if((C=n.offset-C)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=30;break}x=C>n.wnext?(C-=n.wnext,n.wsize-C):n.wnext-C,C>n.length&&(C=n.length),E=n.window}else E=d,x=f-n.offset,C=n.length;for(_v?(y=B[M+d[E]],O[W+d[E]]):(y=96,0),f=1<>N)+(p-=f)]=b<<24|y<<16|w|0,0!==p;);for(f=1<>=1;if(0!==f?(P&=f-1,P+=f):P=0,E++,0==--z[x]){if(x===k)break;x=t[n+d[E]]}if(A>>7)]}function S(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function k(e,t,n){e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<>>=1,n<<=1,0<--t;);return n>>>1}function N(e,t,n){var r,i,o=new Array(16),s=0;for(r=1;r<=l;r++)o[r]=s=s+n[r-1]<<1;for(i=0;i<=t;i++){var a=e[2*i+1];0!==a&&(e[2*i]=T(o[a]++,a))}}function L(e){var t;for(t=0;t>1;1<=n;n--)O(e,o,n);for(i=c;n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],O(e,o,1),r=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=r,o[2*i]=o[2*n]+o[2*r],e.depth[i]=(e.depth[n]>=e.depth[r]?e.depth[n]:e.depth[r])+1,o[2*n+1]=o[2*r+1]=i,e.heap[1]=i++,O(e,o,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,r,i,o,s,a,c=t.dyn_tree,u=t.max_code,d=t.stat_desc.static_tree,h=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,_=t.stat_desc.max_length,m=0;for(o=0;o<=l;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n<573;n++)_<(o=c[2*c[2*(r=e.heap[n])+1]+1]+1)&&(o=_,m++),c[2*r+1]=o,u>=7;r>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t>>3,(s=e.static_len+3+7>>>3)<=i&&(i=s)):i=s=n+5,n+4<=i&&-1!==t?U(e,t,n,r):4===e.strategy||s===i?(k(e,2+(r?1:0),3),W(e,f,p)):(k(e,4+(r?1:0),3),function(e,t,n,r){var i;for(k(e,t-257,5),k(e,n-1,5),k(e,r-4,4),i=0;i>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(m[n]+o+1)]++,e.dyn_dtree[2*E(t)]++),e.last_lit===e.lit_bufsize-1},n._tr_align=function(e){k(e,2,3),A(e,256,f),function(e){16===e.bi_valid?(S(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":41}],53:[function(e,t,n){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,r){(function(e){!function(e,t){"use strict";if(!e.setImmediate){var n,r,i,o,s=1,a={},l=!1,c=e.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(e);u=u&&u.setTimeout?u:e,n="[object process]"==={}.toString.call(e.process)?function(e){process.nextTick((function(){h(e)}))}:function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?(o="setImmediate$"+Math.random()+"$",e.addEventListener?e.addEventListener("message",f,!1):e.attachEvent("onmessage",f),function(t){e.postMessage(o+t,"*")}):e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){h(e.data)},function(e){i.port2.postMessage(e)}):c&&"onreadystatechange"in c.createElement("script")?(r=c.documentElement,function(e){var t=c.createElement("script");t.onreadystatechange=function(){h(e),t.onreadystatechange=null,r.removeChild(t),t=null},r.appendChild(t)}):function(e){setTimeout(h,0,e)},u.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r"']/g,J=RegExp(V.source),$=RegExp(Y.source),X=/<%-([\s\S]+?)%>/g,G=/<%([\s\S]+?)%>/g,Z=/<%=([\s\S]+?)%>/g,K=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Q=/^\w*$/,ee=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,te=/[\\^$.*+?()[\]{}|]/g,ne=RegExp(te.source),re=/^\s+/,ie=/\s/,oe=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,se=/\{\n\/\* \[wrapped with (.+)\] \*/,ae=/,? & /,le=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ce=/[()=,{}\[\]\/\s]/,ue=/\\(\\)?/g,de=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,he=/\w*$/,fe=/^[-+]0x[0-9a-f]+$/i,pe=/^0b[01]+$/i,_e=/^\[object .+?Constructor\]$/,me=/^0o[0-7]+$/i,ge=/^(?:0|[1-9]\d*)$/,ve=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,be=/($^)/,ye=/['\n\r\u2028\u2029\\]/g,we="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ce="a-z\\xdf-\\xf6\\xf8-\\xff",xe="A-Z\\xc0-\\xd6\\xd8-\\xde",Ee="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Se="["+Ee+"]",ke="["+we+"]",Ae="\\d+",Te="["+Ce+"]",Ne="[^\\ud800-\\udfff"+Ee+Ae+"\\u2700-\\u27bf"+Ce+xe+"]",Le="\\ud83c[\\udffb-\\udfff]",Re="[^\\ud800-\\udfff]",Pe="(?:\\ud83c[\\udde6-\\uddff]){2}",Oe="[\\ud800-\\udbff][\\udc00-\\udfff]",We="["+xe+"]",ze="(?:"+Te+"|"+Ne+")",Ie="(?:"+We+"|"+Ne+")",Be="(?:['’](?:d|ll|m|re|s|t|ve))?",Me="(?:['’](?:D|LL|M|RE|S|T|VE))?",Ue="(?:"+ke+"|"+Le+")?",De="[\\ufe0e\\ufe0f]?",Fe=De+Ue+"(?:\\u200d(?:"+[Re,Pe,Oe].join("|")+")"+De+Ue+")*",qe="(?:"+["[\\u2700-\\u27bf]",Pe,Oe].join("|")+")"+Fe,He="(?:"+[Re+ke+"?",ke,Pe,Oe,"[\\ud800-\\udfff]"].join("|")+")",je=RegExp("['’]","g"),Ve=RegExp(ke,"g"),Ye=RegExp(Le+"(?="+Le+")|"+He+Fe,"g"),Je=RegExp([We+"?"+Te+"+"+Be+"(?="+[Se,We,"$"].join("|")+")",Ie+"+"+Me+"(?="+[Se,We+ze,"$"].join("|")+")",We+"?"+ze+"+"+Be,We+"+"+Me,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ae,qe].join("|"),"g"),$e=RegExp("[\\u200d\\ud800-\\udfff"+we+"\\ufe0e\\ufe0f]"),Xe=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Ge=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Ze=-1,Ke={};Ke[O]=Ke[W]=Ke[z]=Ke[I]=Ke[B]=Ke[M]=Ke[U]=Ke[D]=Ke[F]=!0,Ke[_]=Ke[m]=Ke[R]=Ke[g]=Ke[P]=Ke[v]=Ke[b]=Ke[y]=Ke[C]=Ke[x]=Ke[E]=Ke[k]=Ke[A]=Ke[T]=Ke[L]=!1;var Qe={};Qe[_]=Qe[m]=Qe[R]=Qe[P]=Qe[g]=Qe[v]=Qe[O]=Qe[W]=Qe[z]=Qe[I]=Qe[B]=Qe[C]=Qe[x]=Qe[E]=Qe[k]=Qe[A]=Qe[T]=Qe[N]=Qe[M]=Qe[U]=Qe[D]=Qe[F]=!0,Qe[b]=Qe[y]=Qe[L]=!1;var et={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},tt=parseFloat,nt=parseInt,rt="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,it="object"==typeof self&&self&&self.Object===Object&&self,ot=rt||it||Function("return this")(),st=t&&!t.nodeType&&t,at=st&&e&&!e.nodeType&&e,lt=at&&at.exports===st,ct=lt&&rt.process,ut=function(){try{return at&&at.require&&at.require("util").types||ct&&ct.binding&&ct.binding("util")}catch(e){}}(),dt=ut&&ut.isArrayBuffer,ht=ut&&ut.isDate,ft=ut&&ut.isMap,pt=ut&&ut.isRegExp,_t=ut&&ut.isSet,mt=ut&&ut.isTypedArray;function gt(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function vt(e,t,n,r){for(var i=-1,o=null==e?0:e.length;++i-1}function Et(e,t,n){for(var r=-1,i=null==e?0:e.length;++r-1;);return n}function Jt(e,t){for(var n=e.length;n--&&Ot(t,e[n],0)>-1;);return n}function $t(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}var Xt=Mt({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"}),Gt=Mt({"&":"&","<":"<",">":">",'"':""","'":"'"});function Zt(e){return"\\"+et[e]}function Kt(e){return $e.test(e)}function Qt(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function en(e,t){return function(n){return e(t(n))}}function tn(e,t){for(var n=-1,r=e.length,i=0,o=[];++n",""":'"',"'":"'"}),cn=function e(t){var n,r=(t=null==t?ot:cn.defaults(ot.Object(),t,cn.pick(ot,Ge))).Array,ie=t.Date,we=t.Error,Ce=t.Function,xe=t.Math,Ee=t.Object,Se=t.RegExp,ke=t.String,Ae=t.TypeError,Te=r.prototype,Ne=Ce.prototype,Le=Ee.prototype,Re=t["__core-js_shared__"],Pe=Ne.toString,Oe=Le.hasOwnProperty,We=0,ze=(n=/[^.]+$/.exec(Re&&Re.keys&&Re.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",Ie=Le.toString,Be=Pe.call(Ee),Me=ot._,Ue=Se("^"+Pe.call(Oe).replace(te,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),De=lt?t.Buffer:i,Fe=t.Symbol,qe=t.Uint8Array,He=De?De.allocUnsafe:i,Ye=en(Ee.getPrototypeOf,Ee),$e=Ee.create,et=Le.propertyIsEnumerable,rt=Te.splice,it=Fe?Fe.isConcatSpreadable:i,st=Fe?Fe.iterator:i,at=Fe?Fe.toStringTag:i,ct=function(){try{var e=co(Ee,"defineProperty");return e({},"",{}),e}catch(e){}}(),ut=t.clearTimeout!==ot.clearTimeout&&t.clearTimeout,Lt=ie&&ie.now!==ot.Date.now&&ie.now,Mt=t.setTimeout!==ot.setTimeout&&t.setTimeout,un=xe.ceil,dn=xe.floor,hn=Ee.getOwnPropertySymbols,fn=De?De.isBuffer:i,pn=t.isFinite,_n=Te.join,mn=en(Ee.keys,Ee),gn=xe.max,vn=xe.min,bn=ie.now,yn=t.parseInt,wn=xe.random,Cn=Te.reverse,xn=co(t,"DataView"),En=co(t,"Map"),Sn=co(t,"Promise"),kn=co(t,"Set"),An=co(t,"WeakMap"),Tn=co(Ee,"create"),Nn=An&&new An,Ln={},Rn=Uo(xn),Pn=Uo(En),On=Uo(Sn),Wn=Uo(kn),zn=Uo(An),In=Fe?Fe.prototype:i,Bn=In?In.valueOf:i,Mn=In?In.toString:i;function Un(e){if(na(e)&&!Vs(e)&&!(e instanceof Hn)){if(e instanceof qn)return e;if(Oe.call(e,"__wrapped__"))return Do(e)}return new qn(e)}var Dn=function(){function e(){}return function(t){if(!ta(t))return{};if($e)return $e(t);e.prototype=t;var n=new e;return e.prototype=i,n}}();function Fn(){}function qn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=i}function Hn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=f,this.__views__=[]}function jn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function ar(e,t,n,r,o,s){var a,l=1&t,c=2&t,u=4&t;if(n&&(a=o?n(e,r,o,s):n(e)),a!==i)return a;if(!ta(e))return e;var d=Vs(e);if(d){if(a=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&Oe.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e),!l)return Ai(e,a)}else{var h=fo(e),f=h==y||h==w;if(Xs(e))return wi(e,l);if(h==E||h==_||f&&!o){if(a=c||f?{}:_o(e),!l)return c?function(e,t){return Ti(e,ho(e),t)}(e,function(e,t){return e&&Ti(t,Oa(t),e)}(a,e)):function(e,t){return Ti(e,uo(e),t)}(e,rr(a,e))}else{if(!Qe[h])return o?e:{};a=function(e,t,n){var r,i=e.constructor;switch(t){case R:return Ci(e);case g:case v:return new i(+e);case P:return function(e,t){var n=t?Ci(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case O:case W:case z:case I:case B:case M:case U:case D:case F:return xi(e,n);case C:return new i;case x:case T:return new i(e);case k:return function(e){var t=new e.constructor(e.source,he.exec(e));return t.lastIndex=e.lastIndex,t}(e);case A:return new i;case N:return r=e,Bn?Ee(Bn.call(r)):{}}}(e,h,l)}}s||(s=new $n);var p=s.get(e);if(p)return p;s.set(e,a),aa(e)?e.forEach((function(r){a.add(ar(r,t,n,r,e,s))})):ra(e)&&e.forEach((function(r,i){a.set(i,ar(r,t,n,i,e,s))}));var m=d?i:(u?c?no:to:c?Oa:Pa)(e);return bt(m||e,(function(r,i){m&&(r=e[i=r]),er(a,i,ar(r,t,n,i,e,s))})),a}function lr(e,t,n){var r=n.length;if(null==e)return!r;for(e=Ee(e);r--;){var o=n[r],s=t[o],a=e[o];if(a===i&&!(o in e)||!s(a))return!1}return!0}function cr(e,t,n){if("function"!=typeof e)throw new Ae(o);return Lo((function(){e.apply(i,n)}),t)}function ur(e,t,n,r){var i=-1,o=xt,s=!0,a=e.length,l=[],c=t.length;if(!a)return l;n&&(t=St(t,Ht(n))),r?(o=Et,s=!1):t.length>=200&&(o=Vt,s=!1,t=new Jn(t));e:for(;++i-1},Vn.prototype.set=function(e,t){var n=this.__data__,r=tr(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},Yn.prototype.clear=function(){this.size=0,this.__data__={hash:new jn,map:new(En||Vn),string:new jn}},Yn.prototype.delete=function(e){var t=ao(this,e).delete(e);return this.size-=t?1:0,t},Yn.prototype.get=function(e){return ao(this,e).get(e)},Yn.prototype.has=function(e){return ao(this,e).has(e)},Yn.prototype.set=function(e,t){var n=ao(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},Jn.prototype.add=Jn.prototype.push=function(e){return this.__data__.set(e,s),this},Jn.prototype.has=function(e){return this.__data__.has(e)},$n.prototype.clear=function(){this.__data__=new Vn,this.size=0},$n.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},$n.prototype.get=function(e){return this.__data__.get(e)},$n.prototype.has=function(e){return this.__data__.has(e)},$n.prototype.set=function(e,t){var n=this.__data__;if(n instanceof Vn){var r=n.__data__;if(!En||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Yn(r)}return n.set(e,t),this.size=n.size,this};var dr=Ri(br),hr=Ri(yr,!0);function fr(e,t){var n=!0;return dr(e,(function(e,r,i){return n=!!t(e,r,i)})),n}function pr(e,t,n){for(var r=-1,o=e.length;++r0&&n(a)?t>1?mr(a,t-1,n,r,i):kt(i,a):r||(i[i.length]=a)}return i}var gr=Pi(),vr=Pi(!0);function br(e,t){return e&&gr(e,t,Pa)}function yr(e,t){return e&&vr(e,t,Pa)}function wr(e,t){return Ct(t,(function(t){return Ks(e[t])}))}function Cr(e,t){for(var n=0,r=(t=gi(t,e)).length;null!=e&&nt}function kr(e,t){return null!=e&&Oe.call(e,t)}function Ar(e,t){return null!=e&&t in Ee(e)}function Tr(e,t,n){for(var o=n?Et:xt,s=e[0].length,a=e.length,l=a,c=r(a),u=1/0,d=[];l--;){var h=e[l];l&&t&&(h=St(h,Ht(t))),u=vn(h.length,u),c[l]=!n&&(t||s>=120&&h.length>=120)?new Jn(l&&h):i}h=e[0];var f=-1,p=c[0];e:for(;++f=a?l:l*("desc"==n[r]?-1:1)}return e.index-t.index}(e,t,n)}));r--;)e[r]=e[r].value;return e}(i)}function Hr(e,t,n){for(var r=-1,i=t.length,o={};++r-1;)a!==e&&rt.call(a,l,1),rt.call(e,l,1);return e}function Vr(e,t){for(var n=e?t.length:0,r=n-1;n--;){var i=t[n];if(n==r||i!==o){var o=i;go(i)?rt.call(e,i,1):ci(e,i)}}return e}function Yr(e,t){return e+dn(wn()*(t-e+1))}function Jr(e,t){var n="";if(!e||t<1||t>d)return n;do{t%2&&(n+=e),(t=dn(t/2))&&(e+=e)}while(t);return n}function $r(e,t){return Ro(So(e,t,il),e+"")}function Xr(e){return Gn(Fa(e))}function Gr(e,t){var n=Fa(e);return Wo(n,sr(t,0,n.length))}function Zr(e,t,n,r){if(!ta(e))return e;for(var o=-1,s=(t=gi(t,e)).length,a=s-1,l=e;null!=l&&++oo?0:o+t),(n=n>o?o:n)<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var s=r(o);++i>>1,s=e[o];null!==s&&!ca(s)&&(n?s<=t:s=200){var c=t?null:Ji(e);if(c)return nn(c);s=!1,i=Vt,l=new Jn}else l=t?[]:a;e:for(;++r=r?e:ti(e,t,n)}var yi=ut||function(e){return ot.clearTimeout(e)};function wi(e,t){if(t)return e.slice();var n=e.length,r=He?He(n):new e.constructor(n);return e.copy(r),r}function Ci(e){var t=new e.constructor(e.byteLength);return new qe(t).set(new qe(e)),t}function xi(e,t){var n=t?Ci(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Ei(e,t){if(e!==t){var n=e!==i,r=null===e,o=e==e,s=ca(e),a=t!==i,l=null===t,c=t==t,u=ca(t);if(!l&&!u&&!s&&e>t||s&&a&&c&&!l&&!u||r&&a&&c||!n&&c||!o)return 1;if(!r&&!s&&!u&&e1?n[o-1]:i,a=o>2?n[2]:i;for(s=e.length>3&&"function"==typeof s?(o--,s):i,a&&vo(n[0],n[1],a)&&(s=o<3?i:s,o=1),t=Ee(t);++r-1?o[s?t[a]:a]:i}}function Bi(e){return eo((function(t){var n=t.length,r=n,s=qn.prototype.thru;for(e&&t.reverse();r--;){var a=t[r];if("function"!=typeof a)throw new Ae(o);if(s&&!l&&"wrapper"==io(a))var l=new qn([],!0)}for(r=l?r:n;++r1&&b.reverse(),f&&dl))return!1;var u=s.get(e),d=s.get(t);if(u&&d)return u==t&&d==e;var h=-1,f=!0,p=2&n?new Jn:i;for(s.set(e,t),s.set(t,e);++h-1&&e%1==0&&e1?"& ":"")+t[r],t=t.join(n>2?", ":" "),e.replace(oe,"{\n/* [wrapped with "+t+"] */\n")}(r,function(e,t){return bt(p,(function(n){var r="_."+n[0];t&n[1]&&!xt(e,r)&&e.push(r)})),e.sort()}(function(e){var t=e.match(se);return t?t[1].split(ae):[]}(r),n)))}function Oo(e){var t=0,n=0;return function(){var r=bn(),o=16-(r-n);if(n=r,o>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(i,arguments)}}function Wo(e,t){var n=-1,r=e.length,o=r-1;for(t=t===i?r:t;++n1?e[t-1]:i;return n="function"==typeof n?(e.pop(),n):i,ss(e,n)}));function fs(e){var t=Un(e);return t.__chain__=!0,t}function ps(e,t){return t(e)}var _s=eo((function(e){var t=e.length,n=t?e[0]:0,r=this.__wrapped__,o=function(t){return or(t,e)};return!(t>1||this.__actions__.length)&&r instanceof Hn&&go(n)?((r=r.slice(n,+n+(t?1:0))).__actions__.push({func:ps,args:[o],thisArg:i}),new qn(r,this.__chain__).thru((function(e){return t&&!e.length&&e.push(i),e}))):this.thru(o)})),ms=Ni((function(e,t,n){Oe.call(e,n)?++e[n]:ir(e,n,1)})),gs=Ii(jo),vs=Ii(Vo);function bs(e,t){return(Vs(e)?bt:dr)(e,so(t,3))}function ys(e,t){return(Vs(e)?yt:hr)(e,so(t,3))}var ws=Ni((function(e,t,n){Oe.call(e,n)?e[n].push(t):ir(e,n,[t])})),Cs=$r((function(e,t,n){var i=-1,o="function"==typeof t,s=Js(e)?r(e.length):[];return dr(e,(function(e){s[++i]=o?gt(t,e,n):Nr(e,t,n)})),s})),xs=Ni((function(e,t,n){ir(e,n,t)}));function Es(e,t){return(Vs(e)?St:Br)(e,so(t,3))}var Ss=Ni((function(e,t,n){e[n?0:1].push(t)}),(function(){return[[],[]]})),ks=$r((function(e,t){if(null==e)return[];var n=t.length;return n>1&&vo(e,t[0],t[1])?t=[]:n>2&&vo(t[0],t[1],t[2])&&(t=[t[0]]),qr(e,mr(t,1),[])})),As=Lt||function(){return ot.Date.now()};function Ts(e,t,n){return t=n?i:t,t=e&&null==t?e.length:t,Xi(e,c,i,i,i,i,t)}function Ns(e,t){var n;if("function"!=typeof t)throw new Ae(o);return e=_a(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=i),n}}var Ls=$r((function(e,t,n){var r=1;if(n.length){var i=tn(n,oo(Ls));r|=l}return Xi(e,r,t,n,i)})),Rs=$r((function(e,t,n){var r=3;if(n.length){var i=tn(n,oo(Rs));r|=l}return Xi(t,r,e,n,i)}));function Ps(e,t,n){var r,s,a,l,c,u,d=0,h=!1,f=!1,p=!0;if("function"!=typeof e)throw new Ae(o);function _(t){var n=r,o=s;return r=s=i,d=t,l=e.apply(o,n)}function m(e){return d=e,c=Lo(v,t),h?_(e):l}function g(e){var n=e-u;return u===i||n>=t||n<0||f&&e-d>=a}function v(){var e=As();if(g(e))return b(e);c=Lo(v,function(e){var n=t-(e-u);return f?vn(n,a-(e-d)):n}(e))}function b(e){return c=i,p&&r?_(e):(r=s=i,l)}function y(){var e=As(),n=g(e);if(r=arguments,s=this,u=e,n){if(c===i)return m(u);if(f)return yi(c),c=Lo(v,t),_(u)}return c===i&&(c=Lo(v,t)),l}return t=ga(t)||0,ta(n)&&(h=!!n.leading,a=(f="maxWait"in n)?gn(ga(n.maxWait)||0,t):a,p="trailing"in n?!!n.trailing:p),y.cancel=function(){c!==i&&yi(c),d=0,r=u=s=c=i},y.flush=function(){return c===i?l:b(As())},y}var Os=$r((function(e,t){return cr(e,1,t)})),Ws=$r((function(e,t,n){return cr(e,ga(t)||0,n)}));function zs(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Ae(o);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=e.apply(this,r);return n.cache=o.set(i,s)||o,s};return n.cache=new(zs.Cache||Yn),n}function Is(e){if("function"!=typeof e)throw new Ae(o);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}zs.Cache=Yn;var Bs=vi((function(e,t){var n=(t=1==t.length&&Vs(t[0])?St(t[0],Ht(so())):St(mr(t,1),Ht(so()))).length;return $r((function(r){for(var i=-1,o=vn(r.length,n);++i=t})),js=Lr(function(){return arguments}())?Lr:function(e){return na(e)&&Oe.call(e,"callee")&&!et.call(e,"callee")},Vs=r.isArray,Ys=dt?Ht(dt):function(e){return na(e)&&Er(e)==R};function Js(e){return null!=e&&ea(e.length)&&!Ks(e)}function $s(e){return na(e)&&Js(e)}var Xs=fn||gl,Gs=ht?Ht(ht):function(e){return na(e)&&Er(e)==v};function Zs(e){if(!na(e))return!1;var t=Er(e);return t==b||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!oa(e)}function Ks(e){if(!ta(e))return!1;var t=Er(e);return t==y||t==w||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Qs(e){return"number"==typeof e&&e==_a(e)}function ea(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=d}function ta(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function na(e){return null!=e&&"object"==typeof e}var ra=ft?Ht(ft):function(e){return na(e)&&fo(e)==C};function ia(e){return"number"==typeof e||na(e)&&Er(e)==x}function oa(e){if(!na(e)||Er(e)!=E)return!1;var t=Ye(e);if(null===t)return!0;var n=Oe.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Pe.call(n)==Be}var sa=pt?Ht(pt):function(e){return na(e)&&Er(e)==k},aa=_t?Ht(_t):function(e){return na(e)&&fo(e)==A};function la(e){return"string"==typeof e||!Vs(e)&&na(e)&&Er(e)==T}function ca(e){return"symbol"==typeof e||na(e)&&Er(e)==N}var ua=mt?Ht(mt):function(e){return na(e)&&ea(e.length)&&!!Ke[Er(e)]},da=ji(Ir),ha=ji((function(e,t){return e<=t}));function fa(e){if(!e)return[];if(Js(e))return la(e)?sn(e):Ai(e);if(st&&e[st])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[st]());var t=fo(e);return(t==C?Qt:t==A?nn:Fa)(e)}function pa(e){return e?(e=ga(e))===u||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function _a(e){var t=pa(e),n=t%1;return t==t?n?t-n:t:0}function ma(e){return e?sr(_a(e),0,f):0}function ga(e){if("number"==typeof e)return e;if(ca(e))return h;if(ta(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=ta(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=qt(e);var n=pe.test(e);return n||me.test(e)?nt(e.slice(2),n?2:8):fe.test(e)?h:+e}function va(e){return Ti(e,Oa(e))}function ba(e){return null==e?"":ai(e)}var ya=Li((function(e,t){if(Co(t)||Js(t))Ti(t,Pa(t),e);else for(var n in t)Oe.call(t,n)&&er(e,n,t[n])})),wa=Li((function(e,t){Ti(t,Oa(t),e)})),Ca=Li((function(e,t,n,r){Ti(t,Oa(t),e,r)})),xa=Li((function(e,t,n,r){Ti(t,Pa(t),e,r)})),Ea=eo(or),Sa=$r((function(e,t){e=Ee(e);var n=-1,r=t.length,o=r>2?t[2]:i;for(o&&vo(t[0],t[1],o)&&(r=1);++n1),t})),Ti(e,no(e),n),r&&(n=ar(n,7,Ki));for(var i=t.length;i--;)ci(n,t[i]);return n})),Ba=eo((function(e,t){return null==e?{}:function(e,t){return Hr(e,t,(function(t,n){return Ta(e,n)}))}(e,t)}));function Ma(e,t){if(null==e)return{};var n=St(no(e),(function(e){return[e]}));return t=so(t),Hr(e,n,(function(e,n){return t(e,n[0])}))}var Ua=$i(Pa),Da=$i(Oa);function Fa(e){return null==e?[]:jt(e,Pa(e))}var qa=Wi((function(e,t,n){return t=t.toLowerCase(),e+(n?Ha(t):t)}));function Ha(e){return Za(ba(e).toLowerCase())}function ja(e){return(e=ba(e))&&e.replace(ve,Xt).replace(Ve,"")}var Va=Wi((function(e,t,n){return e+(n?"-":"")+t.toLowerCase()})),Ya=Wi((function(e,t,n){return e+(n?" ":"")+t.toLowerCase()})),Ja=Oi("toLowerCase"),$a=Wi((function(e,t,n){return e+(n?"_":"")+t.toLowerCase()})),Xa=Wi((function(e,t,n){return e+(n?" ":"")+Za(t)})),Ga=Wi((function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})),Za=Oi("toUpperCase");function Ka(e,t,n){return e=ba(e),(t=n?i:t)===i?function(e){return Xe.test(e)}(e)?function(e){return e.match(Je)||[]}(e):function(e){return e.match(le)||[]}(e):e.match(t)||[]}var Qa=$r((function(e,t){try{return gt(e,i,t)}catch(e){return Zs(e)?e:new we(e)}})),el=eo((function(e,t){return bt(t,(function(t){t=Mo(t),ir(e,t,Ls(e[t],e))})),e}));function tl(e){return function(){return e}}var nl=Bi(),rl=Bi(!0);function il(e){return e}function ol(e){return Wr("function"==typeof e?e:ar(e,1))}var sl=$r((function(e,t){return function(n){return Nr(n,e,t)}})),al=$r((function(e,t){return function(n){return Nr(e,n,t)}}));function ll(e,t,n){var r=Pa(t),i=wr(t,r);null!=n||ta(t)&&(i.length||!r.length)||(n=t,t=e,e=this,i=wr(t,Pa(t)));var o=!(ta(n)&&"chain"in n&&!n.chain),s=Ks(e);return bt(i,(function(n){var r=t[n];e[n]=r,s&&(e.prototype[n]=function(){var t=this.__chain__;if(o||t){var n=e(this.__wrapped__),i=n.__actions__=Ai(this.__actions__);return i.push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,kt([this.value()],arguments))})})),e}function cl(){}var ul=Fi(St),dl=Fi(wt),hl=Fi(Nt);function fl(e){return bo(e)?Bt(Mo(e)):function(e){return function(t){return Cr(t,e)}}(e)}var pl=Hi(),_l=Hi(!0);function ml(){return[]}function gl(){return!1}var vl,bl=Di((function(e,t){return e+t}),0),yl=Yi("ceil"),wl=Di((function(e,t){return e/t}),1),Cl=Yi("floor"),xl=Di((function(e,t){return e*t}),1),El=Yi("round"),Sl=Di((function(e,t){return e-t}),0);return Un.after=function(e,t){if("function"!=typeof t)throw new Ae(o);return e=_a(e),function(){if(--e<1)return t.apply(this,arguments)}},Un.ary=Ts,Un.assign=ya,Un.assignIn=wa,Un.assignInWith=Ca,Un.assignWith=xa,Un.at=Ea,Un.before=Ns,Un.bind=Ls,Un.bindAll=el,Un.bindKey=Rs,Un.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Vs(e)?e:[e]},Un.chain=fs,Un.chunk=function(e,t,n){t=(n?vo(e,t,n):t===i)?1:gn(_a(t),0);var o=null==e?0:e.length;if(!o||t<1)return[];for(var s=0,a=0,l=r(un(o/t));so?0:o+n),(r=r===i||r>o?o:_a(r))<0&&(r+=o),r=n>r?0:ma(r);n>>0)?(e=ba(e))&&("string"==typeof t||null!=t&&!sa(t))&&!(t=ai(t))&&Kt(e)?bi(sn(e),0,n):e.split(t,n):[]},Un.spread=function(e,t){if("function"!=typeof e)throw new Ae(o);return t=null==t?0:gn(_a(t),0),$r((function(n){var r=n[t],i=bi(n,0,t);return r&&kt(i,r),gt(e,this,i)}))},Un.tail=function(e){var t=null==e?0:e.length;return t?ti(e,1,t):[]},Un.take=function(e,t,n){return e&&e.length?ti(e,0,(t=n||t===i?1:_a(t))<0?0:t):[]},Un.takeRight=function(e,t,n){var r=null==e?0:e.length;return r?ti(e,(t=r-(t=n||t===i?1:_a(t)))<0?0:t,r):[]},Un.takeRightWhile=function(e,t){return e&&e.length?di(e,so(t,3),!1,!0):[]},Un.takeWhile=function(e,t){return e&&e.length?di(e,so(t,3)):[]},Un.tap=function(e,t){return t(e),e},Un.throttle=function(e,t,n){var r=!0,i=!0;if("function"!=typeof e)throw new Ae(o);return ta(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),Ps(e,t,{leading:r,maxWait:t,trailing:i})},Un.thru=ps,Un.toArray=fa,Un.toPairs=Ua,Un.toPairsIn=Da,Un.toPath=function(e){return Vs(e)?St(e,Mo):ca(e)?[e]:Ai(Bo(ba(e)))},Un.toPlainObject=va,Un.transform=function(e,t,n){var r=Vs(e),i=r||Xs(e)||ua(e);if(t=so(t,4),null==n){var o=e&&e.constructor;n=i?r?new o:[]:ta(e)&&Ks(o)?Dn(Ye(e)):{}}return(i?bt:br)(e,(function(e,r,i){return t(n,e,r,i)})),n},Un.unary=function(e){return Ts(e,1)},Un.union=ns,Un.unionBy=rs,Un.unionWith=is,Un.uniq=function(e){return e&&e.length?li(e):[]},Un.uniqBy=function(e,t){return e&&e.length?li(e,so(t,2)):[]},Un.uniqWith=function(e,t){return t="function"==typeof t?t:i,e&&e.length?li(e,i,t):[]},Un.unset=function(e,t){return null==e||ci(e,t)},Un.unzip=os,Un.unzipWith=ss,Un.update=function(e,t,n){return null==e?e:ui(e,t,mi(n))},Un.updateWith=function(e,t,n,r){return r="function"==typeof r?r:i,null==e?e:ui(e,t,mi(n),r)},Un.values=Fa,Un.valuesIn=function(e){return null==e?[]:jt(e,Oa(e))},Un.without=as,Un.words=Ka,Un.wrap=function(e,t){return Ms(mi(t),e)},Un.xor=ls,Un.xorBy=cs,Un.xorWith=us,Un.zip=ds,Un.zipObject=function(e,t){return pi(e||[],t||[],er)},Un.zipObjectDeep=function(e,t){return pi(e||[],t||[],Zr)},Un.zipWith=hs,Un.entries=Ua,Un.entriesIn=Da,Un.extend=wa,Un.extendWith=Ca,ll(Un,Un),Un.add=bl,Un.attempt=Qa,Un.camelCase=qa,Un.capitalize=Ha,Un.ceil=yl,Un.clamp=function(e,t,n){return n===i&&(n=t,t=i),n!==i&&(n=(n=ga(n))==n?n:0),t!==i&&(t=(t=ga(t))==t?t:0),sr(ga(e),t,n)},Un.clone=function(e){return ar(e,4)},Un.cloneDeep=function(e){return ar(e,5)},Un.cloneDeepWith=function(e,t){return ar(e,5,t="function"==typeof t?t:i)},Un.cloneWith=function(e,t){return ar(e,4,t="function"==typeof t?t:i)},Un.conformsTo=function(e,t){return null==t||lr(e,t,Pa(t))},Un.deburr=ja,Un.defaultTo=function(e,t){return null==e||e!=e?t:e},Un.divide=wl,Un.endsWith=function(e,t,n){e=ba(e),t=ai(t);var r=e.length,o=n=n===i?r:sr(_a(n),0,r);return(n-=t.length)>=0&&e.slice(n,o)==t},Un.eq=Fs,Un.escape=function(e){return(e=ba(e))&&$.test(e)?e.replace(Y,Gt):e},Un.escapeRegExp=function(e){return(e=ba(e))&&ne.test(e)?e.replace(te,"\\$&"):e},Un.every=function(e,t,n){var r=Vs(e)?wt:fr;return n&&vo(e,t,n)&&(t=i),r(e,so(t,3))},Un.find=gs,Un.findIndex=jo,Un.findKey=function(e,t){return Rt(e,so(t,3),br)},Un.findLast=vs,Un.findLastIndex=Vo,Un.findLastKey=function(e,t){return Rt(e,so(t,3),yr)},Un.floor=Cl,Un.forEach=bs,Un.forEachRight=ys,Un.forIn=function(e,t){return null==e?e:gr(e,so(t,3),Oa)},Un.forInRight=function(e,t){return null==e?e:vr(e,so(t,3),Oa)},Un.forOwn=function(e,t){return e&&br(e,so(t,3))},Un.forOwnRight=function(e,t){return e&&yr(e,so(t,3))},Un.get=Aa,Un.gt=qs,Un.gte=Hs,Un.has=function(e,t){return null!=e&&po(e,t,kr)},Un.hasIn=Ta,Un.head=Jo,Un.identity=il,Un.includes=function(e,t,n,r){e=Js(e)?e:Fa(e),n=n&&!r?_a(n):0;var i=e.length;return n<0&&(n=gn(i+n,0)),la(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&Ot(e,t,n)>-1},Un.indexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:_a(n);return i<0&&(i=gn(r+i,0)),Ot(e,t,i)},Un.inRange=function(e,t,n){return t=pa(t),n===i?(n=t,t=0):n=pa(n),function(e,t,n){return e>=vn(t,n)&&e=-9007199254740991&&e<=d},Un.isSet=aa,Un.isString=la,Un.isSymbol=ca,Un.isTypedArray=ua,Un.isUndefined=function(e){return e===i},Un.isWeakMap=function(e){return na(e)&&fo(e)==L},Un.isWeakSet=function(e){return na(e)&&"[object WeakSet]"==Er(e)},Un.join=function(e,t){return null==e?"":_n.call(e,t)},Un.kebabCase=Va,Un.last=Zo,Un.lastIndexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var o=r;return n!==i&&(o=(o=_a(n))<0?gn(r+o,0):vn(o,r-1)),t==t?function(e,t,n){for(var r=n+1;r--;)if(e[r]===t)return r;return r}(e,t,o):Pt(e,zt,o,!0)},Un.lowerCase=Ya,Un.lowerFirst=Ja,Un.lt=da,Un.lte=ha,Un.max=function(e){return e&&e.length?pr(e,il,Sr):i},Un.maxBy=function(e,t){return e&&e.length?pr(e,so(t,2),Sr):i},Un.mean=function(e){return It(e,il)},Un.meanBy=function(e,t){return It(e,so(t,2))},Un.min=function(e){return e&&e.length?pr(e,il,Ir):i},Un.minBy=function(e,t){return e&&e.length?pr(e,so(t,2),Ir):i},Un.stubArray=ml,Un.stubFalse=gl,Un.stubObject=function(){return{}},Un.stubString=function(){return""},Un.stubTrue=function(){return!0},Un.multiply=xl,Un.nth=function(e,t){return e&&e.length?Fr(e,_a(t)):i},Un.noConflict=function(){return ot._===this&&(ot._=Me),this},Un.noop=cl,Un.now=As,Un.pad=function(e,t,n){e=ba(e);var r=(t=_a(t))?on(e):0;if(!t||r>=t)return e;var i=(t-r)/2;return qi(dn(i),n)+e+qi(un(i),n)},Un.padEnd=function(e,t,n){e=ba(e);var r=(t=_a(t))?on(e):0;return t&&rt){var r=e;e=t,t=r}if(n||e%1||t%1){var o=wn();return vn(e+o*(t-e+tt("1e-"+((o+"").length-1))),t)}return Yr(e,t)},Un.reduce=function(e,t,n){var r=Vs(e)?At:Ut,i=arguments.length<3;return r(e,so(t,4),n,i,dr)},Un.reduceRight=function(e,t,n){var r=Vs(e)?Tt:Ut,i=arguments.length<3;return r(e,so(t,4),n,i,hr)},Un.repeat=function(e,t,n){return t=(n?vo(e,t,n):t===i)?1:_a(t),Jr(ba(e),t)},Un.replace=function(){var e=arguments,t=ba(e[0]);return e.length<3?t:t.replace(e[1],e[2])},Un.result=function(e,t,n){var r=-1,o=(t=gi(t,e)).length;for(o||(o=1,e=i);++rd)return[];var n=f,r=vn(e,f);t=so(t),e-=f;for(var i=Ft(r,t);++n=s)return e;var l=n-on(r);if(l<1)return r;var c=a?bi(a,0,l).join(""):e.slice(0,l);if(o===i)return c+r;if(a&&(l+=c.length-l),sa(o)){if(e.slice(l).search(o)){var u,d=c;for(o.global||(o=Se(o.source,ba(he.exec(o))+"g")),o.lastIndex=0;u=o.exec(d);)var h=u.index;c=c.slice(0,h===i?l:h)}}else if(e.indexOf(ai(o),l)!=l){var f=c.lastIndexOf(o);f>-1&&(c=c.slice(0,f))}return c+r},Un.unescape=function(e){return(e=ba(e))&&J.test(e)?e.replace(V,ln):e},Un.uniqueId=function(e){var t=++We;return ba(e)+t},Un.upperCase=Ga,Un.upperFirst=Za,Un.each=bs,Un.eachRight=ys,Un.first=Jo,ll(Un,(vl={},br(Un,(function(e,t){Oe.call(Un.prototype,t)||(vl[t]=e)})),vl),{chain:!1}),Un.VERSION="4.17.21",bt(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){Un[e].placeholder=Un})),bt(["drop","take"],(function(e,t){Hn.prototype[e]=function(n){n=n===i?1:gn(_a(n),0);var r=this.__filtered__&&!t?new Hn(this):this.clone();return r.__filtered__?r.__takeCount__=vn(n,r.__takeCount__):r.__views__.push({size:vn(n,f),type:e+(r.__dir__<0?"Right":"")}),r},Hn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),bt(["filter","map","takeWhile"],(function(e,t){var n=t+1,r=1==n||3==n;Hn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:so(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}})),bt(["head","last"],(function(e,t){var n="take"+(t?"Right":"");Hn.prototype[e]=function(){return this[n](1).value()[0]}})),bt(["initial","tail"],(function(e,t){var n="drop"+(t?"":"Right");Hn.prototype[e]=function(){return this.__filtered__?new Hn(this):this[n](1)}})),Hn.prototype.compact=function(){return this.filter(il)},Hn.prototype.find=function(e){return this.filter(e).head()},Hn.prototype.findLast=function(e){return this.reverse().find(e)},Hn.prototype.invokeMap=$r((function(e,t){return"function"==typeof e?new Hn(this):this.map((function(n){return Nr(n,e,t)}))})),Hn.prototype.reject=function(e){return this.filter(Is(so(e)))},Hn.prototype.slice=function(e,t){e=_a(e);var n=this;return n.__filtered__&&(e>0||t<0)?new Hn(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==i&&(n=(t=_a(t))<0?n.dropRight(-t):n.take(t-e)),n)},Hn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Hn.prototype.toArray=function(){return this.take(f)},br(Hn.prototype,(function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),o=Un[r?"take"+("last"==t?"Right":""):t],s=r||/^find/.test(t);o&&(Un.prototype[t]=function(){var t=this.__wrapped__,a=r?[1]:arguments,l=t instanceof Hn,c=a[0],u=l||Vs(t),d=function(e){var t=o.apply(Un,kt([e],a));return r&&h?t[0]:t};u&&n&&"function"==typeof c&&1!=c.length&&(l=u=!1);var h=this.__chain__,f=!!this.__actions__.length,p=s&&!h,_=l&&!f;if(!s&&u){t=_?t:new Hn(this);var m=e.apply(t,a);return m.__actions__.push({func:ps,args:[d],thisArg:i}),new qn(m,h)}return p&&_?e.apply(this,a):(m=this.thru(d),p?r?m.value()[0]:m.value():m)})})),bt(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Te[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);Un.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply(Vs(i)?i:[],e)}return this[n]((function(n){return t.apply(Vs(n)?n:[],e)}))}})),br(Hn.prototype,(function(e,t){var n=Un[t];if(n){var r=n.name+"";Oe.call(Ln,r)||(Ln[r]=[]),Ln[r].push({name:t,func:n})}})),Ln[Mi(i,2).name]=[{name:"wrapper",func:i}],Hn.prototype.clone=function(){var e=new Hn(this.__wrapped__);return e.__actions__=Ai(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Ai(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Ai(this.__views__),e},Hn.prototype.reverse=function(){if(this.__filtered__){var e=new Hn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Hn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=Vs(e),r=t<0,i=n?e.length:0,o=function(e,t,n){for(var r=-1,i=n.length;++r=this.__values__.length;return{done:e,value:e?i:this.__values__[this.__index__++]}},Un.prototype.plant=function(e){for(var t,n=this;n instanceof Fn;){var r=Do(n);r.__index__=0,r.__values__=i,t?o.__wrapped__=r:t=r;var o=r;n=n.__wrapped__}return o.__wrapped__=e,t},Un.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof Hn){var t=e;return this.__actions__.length&&(t=new Hn(this)),(t=t.reverse()).__actions__.push({func:ps,args:[ts],thisArg:i}),new qn(t,this.__chain__)}return this.thru(ts)},Un.prototype.toJSON=Un.prototype.valueOf=Un.prototype.value=function(){return hi(this.__wrapped__,this.__actions__)},Un.prototype.first=Un.prototype.head,st&&(Un.prototype[st]=function(){return this}),Un}();ot._=cn,(r=function(){return cn}.call(t,n,t,e))===i||(e.exports=r)}.call(this)},752:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{l(r.next(e))}catch(e){o(e)}}function a(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=i(n(733)),s=n(249),a=n(96),l=n(288),c=n(208),u=n(467),d=n(391),h=n(544),f=n(980),p=n(66),_=n(774),m=n(964),g=n(320),v=n(717),b=n(542),y=n(452),w=n(385),C=n(580);function x(e,t){return r(this,void 0,void 0,(function*(){if(new Int8Array(e,0,1)[0]==="P".charCodeAt(0)){const n=new o.default;return(yield n.loadAsync(e)).file(t)[0].async("string")}return(new TextDecoder).decode(e)}))}let E=null;function S(e){$("#errorText").html(e),$("#errorDialog").modal("show")}$("#roster-file").on("change",(function(e){const t="resize"===(null==e?void 0:e.type)?null==E?void 0:E.target:null==e?void 0:e.target;if($("#roster-title").empty(),$("#roster-lists").empty(),$("#force-units").empty(),!(null==t?void 0:t.files))return;const n=null==t?void 0:t.files[0];"resize"!==(null==e?void 0:e.type)&&(E=e),n.arrayBuffer().then((e=>r(this,void 0,void 0,(function*(){n.name.match(/\.rosz?$/)?function(e){const t=(new DOMParser).parseFromString(e,"text/xml");if(!t)return;const n=t.querySelector("roster");if(!n)return;const r=n.getAttribute("gameSystemName");if(!r)return;const i=n.getAttribute("name");i&&(document.title=`PrettyScribe ${i}`);const o=$("#roster-title")[0],C=$("#roster-lists")[0],x=$("#force-units")[0];if("Warhammer 40,000 8th Edition"==r){const e=(0,l.Create40kRoster)(t);e&&e._forces.length>0&&new u.Renderer40k(e).render(o,C,x)}else if("Warhammer 40,000 9th Edition"==r){const e=(0,l.Create40kRoster)(t);e&&e._forces.length>0&&new u.Renderer40k(e).render(o,C,x)}else if("Warhammer 40,000: Kill Team (2018)"==r){const e=(0,l.Create40kRoster)(t,!1);e&&e._forces.length>0&&new u.Renderer40k(e).render(o,C,x)}else if("Warhammer 40,000: Kill Team (2021)"==r){const e=(0,s.CreateKT21Roster)(t);e&&e._forces.length>0&&new a.RendererKT21(e).render(o,C,x)}else if("Age of Sigmar"==r){const e=(0,_.CreateAoSRoster)(t);e&&new m.RendererAoS(e).render(o,C,x)}else if("Warhammer Age of Sigmar: Warcry"==r){const e=(0,g.CreateWarcryRoster)(t);e&&new v.RendererWarcry(e).render(o,C,x)}else if("Warhammer 30,000 - The Horus Heresy"==r){const e=(0,d.Create30kRoster)(t);e&&e._forces.length>0&&new h.Renderer30k(e).render(o,C,x)}else if(r.includes("Horus Heresy (2022)")){const e=f.HorusHeresy.CreateRoster(t);e&&e._forces.length>0&&new p.RendererHH2(e).render(o,C,x)}else if("Warhammer 40,000 10th Edition"==r){const e=c.Wh40k.CreateRoster(t);window.roster=e,e&&e._forces.length>0&&new b.Wh40kRenderer(e).render(o,C,x)}else if("Middle-Earth Strategy Battle Game"===r){const e=(0,y.CreateMESBGRoster)(t);null!==e&&(console.log(e),(0,w.renderMESBG)(e,o,C,x))}else S("PrettyScribe does not support game type '"+r+"'.")}(yield x(e,/[^/]+\.ros$/)):n.name.match(/\.regi[sz]try$/)?function(e){const t=JSON.parse(e);window.registry=t;const n=$("#roster-title")[0],r=$("#roster-lists")[0],i=$("#force-units")[0],o=t.info.game;if("Warhammer 40k"===o){const e=(0,C.Create40kRosterFromRegistry)(t);window.roster=e,new b.Wh40kRenderer(e).render(n,r,i)}else S("PrettyScribe does not support game type '"+o+"'.")}(yield x(e,/[^/]+\.registry$/)):S(`PrettyScribe does not support extension of ${n.name}.`)})))).catch((e=>{S(`Error opening ${n.name}: ${e}`),console.error(e)}))})),document.addEventListener("DOMContentLoaded",(()=>{if(navigator.userAgent.match(/AppleWebKit.*Safari/)&&!navigator.userAgent.includes("Chrome")){const e=document.querySelector('input[type="file"');null==e||e.removeAttribute("accept")}}))},361:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toggleHidden=t.addHideAble=void 0,t.addHideAble=function(e){return e.classList.add("hide_able"),e},t.toggleHidden=function(e){var t,n,r;if(!e.target)return;const i=e.target;null===(t=i.closest(".hide_able"))||void 0===t||t.classList.toggle("hidden"),null===(r=null===(n=i.closest(".unit_header"))||void 0===n?void 0:n.closest(".wh40k_unit_sheet"))||void 0===r||r.classList.toggle("hidden")}},77:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PsJsx=void 0,function(e){function t(e,n){if(null!=n)if(Array.isArray(n))for(const r of n)t(e,r);else"string"==typeof n?e.appendChild(document.createTextNode(n)):n instanceof Node?e.appendChild(n):"boolean"==typeof n||e.appendChild(document.createTextNode(String(n)))}e.createFragment=function(){return document.createDocumentFragment()},e.createElement=function(e,n,...r){const i="function"==typeof e?e():document.createElement(e);if(n)for(const e of Object.keys(n)){const t=n[e];if("boolean"==typeof t)i.setAttribute(e,"");else if("function"==typeof t)if("ref"===e)t(i);else{if(!e.startsWith("on"))throw new Error("Unexpected function attribute");i.addEventListener(e.substring(2),t)}else"className"===e?i.setAttribute("class",t):i.setAttribute(e,t)}for(const e of r)t(i,e);return i}}(t.PsJsx||(t.PsJsx={}))},219:(e,t)=>{"use strict";function n(e,t){try{window.localStorage[e]=t}catch(e){}}Object.defineProperty(t,"__esModule",{value:!0}),t.loadOptionsFromLocalStorage=t.saveOptionToLocalStorage=t.renderCheckboxOption=t.renderOptionsToggle=void 0,t.renderOptionsToggle=function(e){e.classList.add("wh40k_options_toggle"),e.id="wh40k_options_toggle";const t="[−] Options:";e.appendChild(document.createTextNode(t)),e.addEventListener("click",(e=>{const r=document.getElementById("wh40k_options_div"),i=document.getElementById("wh40k_options_toggle");r&&i&&(r.classList.contains("hide_options")?(r.classList.remove("hide_options"),i.innerText=t,n("option-toggle-hidden","false")):(r.classList.add("hide_options"),i.innerText="[+] Options",n("option-toggle-hidden","true")))}))},t.renderCheckboxOption=function(e,t,r,i,o=!1){const s=e.appendChild(document.createElement("div"));s.classList.add("wh40k_option");const a=s.appendChild(document.createElement("input"));a.setAttribute("type","checkbox"),a.setAttribute("name",t),a.setAttribute("id",t),o&&(a.checked=!0),a.addEventListener("input",i),a.addEventListener("change",(e=>function(e){const t=document.getElementById(e);t&&n(`option-checkbox-${e}`,t.checked)}(t)));const l=s.appendChild(document.createElement("label"));l.setAttribute("for",t),l.appendChild(document.createTextNode(` ${r}`))},t.saveOptionToLocalStorage=n,t.loadOptionsFromLocalStorage=function(){var e;try{for(let t=0;t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createNotesHead=t.createNoteHead=t.createTableRow=void 0;const r=n(361);function i(e,t,n=!1){const i=(0,r.addHideAble)(document.createElement("tr"));n&&i.classList.add("header_row");for(let r=0,o=0;re._customNotes)))return null;const n=document.createElement("thead");n.classList.add("info_row");const r=document.createElement("div");for(const e of t){if(!e.notes())continue;const t=r.appendChild(document.createElement("div"));t.appendChild(document.createElement("b")).appendChild(document.createTextNode(`${e.name()}: `)),t.appendChild(document.createTextNode(e._customNotes))}return n.appendChild(i([e,r],[.1,.9],!1)),n}},580:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateRoster=t.Create40kRosterFromRegistry=void 0;const r=n(208),i=n(596);function o(e){const t=new r.Wh40k.Roster40k,n=new r.Wh40k.Force;t._name=e.name,n._name=e.info.name,function(e,t){const n=e.assets.traits.filter((e=>"Detachment"===e.classification))[0];n&&(t._faction=n.designation,t._rules.set(n.designation,n.text))}(e,n);for(const r of[...e.assets.included,...e.assets.traits]){if("Unit"!=r.classIdentity)continue;const e=s(r);n._units.push(e),t._cost.add(e._cost);for(const t of[...e._rules.entries(),...e._weaponRules.entries()])n._rules.set(t[0],t[1])}return n._rules=new Map([...n._rules.entries()].sort()),t._forces.push(n),t}function s(e){var t,n;const i=new r.Wh40k.Unit;return i._name=e.designation,function(e,t){var n,r,i;const o=(null===(r=null===(n=e.rules.finalModelTally)||void 0===n?void 0:n.evals[1])||void 0===r?void 0:r.result.integer)||(null===(i=e.stats.Models)||void 0===i?void 0:i.value);e.stats.model3rdTally.value&&o>e.stats.model3rdTally.value?t._cost._points=e.stats.model4thCost.value:e.stats.model2ndTally.value&&o>e.stats.model2ndTally.value?t._cost._points=e.stats.model3rdCost.value:e.stats.model1stTally.value&&o>e.stats.model1stTally.value?t._cost._points=e.stats.model2ndCost.value:e.stats.Points&&(t._cost._points=e.stats.Points.value),function e(n){var r;for(const i of[...n.assets.included,...n.assets.traits])(null===(r=i.stats.Points)||void 0===r?void 0:r.value)&&(t._cost._points+=i.stats.Points.value),e(i)}(e)}(e,i),null===(t=e.keywords.Faction)||void 0===t||t.sort().forEach((e=>i._factions.add(e))),null===(n=e.keywords.Keywords)||void 0===n||n.sort().forEach((e=>i._keywords.add(e))),function(e,t){const n=[...e.assets.traits,...e.assets.included].filter((e=>"Model"===e.classification));0===n.length?n.push(e):d({designation:"Unit Upgrades",assets:e.assets,quantity:1},t,!1);for(const e of n)u(e,t),d(e,t)}(e,i),a(e,i),i.normalize(),i}function a(e,t){for(const n of[...e.assets.traits,...e.assets.included]){const e=n.classification;if("Wargear"===e||"Enhancement"===e)t._abilities[e]||(t._abilities[e]=new Map),t._abilities[e].set(n.designation,n.text);else if("Ability"===e)if("Leader"===n.designation){const e=n.text.indexOf("This model can be attached"),r=n.text.substring(0,e).trim();r&&t._rules.set(n.designation,r);const i=n.text.substring(e);t._abilities.Abilities||(t._abilities.Abilities=new Map),t._abilities.Abilities.set(n.designation,i)}else!n.tally.Core&&!n.tally.Faction||n.designation.startsWith("Damaged:")?(t._abilities.Abilities||(t._abilities.Abilities=new Map),t._abilities.Abilities.set(n.designation,n.text)):t._rules.set(n.designation,n.text);else if("Model"===e)a(n,t);else if("Ranged Weapon"===e||"Melee Weapon"===e||"Weapon"===e){l(n,t);const e=n.assets.traits.filter((e=>e.classification.endsWith("Weapon")));for(const r of e)l(r,t,n.designation)}else console.error(`Unexepcted classification '${e}': ${n.designation}`)}}function l(e,t,n){const i=`${e.classification}s`,o=c(e,i);if(n&&(o[Object.keys(o)[0]]=`${n} - ${o[Object.keys(o)[0]]}`),Object.keys(o).length<=1)return;const s=e.assets.traits.filter((e=>"Ability"===e.classification));if(s.length>0){s.forEach((e=>t._weaponRules.set(e.designation,e.text)));const e=s.map((e=>e.designation));Object.assign(o,{Keywords:e.join(", ")})}t._profileTables[i]||(t._profileTables[i]=new r.Wh40k.TabularProfile),t._profileTables[i].addRow(o)}function c(e,t,n){const r=(0,i.filterAndOrderStats)(e.stats);return Object.assign({[t]:e.designation},Object.fromEntries(r.map((e=>[e[0],(0,i.formatStat)(e[1])]))))}function u(e,t){const n=c(e,"Unit");Object.keys(n).length>1&&(t._profileTables.Unit||(t._profileTables.Unit=new r.Wh40k.TabularProfile),t._profileTables.Unit.addRow(Object.assign({Unit:e.designation},n)))}function d(e,t,n=!0){var i;const o=new r.Wh40k.Model;o._name=e.designation,o._count=e.quantity;const s=[...e.assets.traits,...e.assets.included].filter((e=>"Wargear"===e.classification||"Weapon"===e.classification||"Ranged Weapon"===e.classification||"Melee Weapon"===e.classification||"Enhancement"===e.classification));for(const e of s){const t=new r.Wh40k.Upgrade;t._name=e.designation;const n=null===(i=e.stats.Points)||void 0===i?void 0:i.value;n&&(t._cost._points=n),o._upgrades.push(t)}(n||s.length>0)&&t._models.push(o)}t.Create40kRosterFromRegistry=function(e){return o(e)},t.CreateRoster=o},419:(e,t)=>{"use strict";var n,r;function i(e,t,i,o,s,a,l,c){if(e&&t.length){e.textBaseline="top";let u=e.measureText(t);const d=u.width,h=u.actualBoundingBoxDescent-u.actualBoundingBoxAscent;let f=o;c==r.Top?f=o:c==r.Bottom?f=o+a-h:c==r.Center&&(f=o+(a-h)/2),l==n.Center?e.fillText(t,i+Math.max((s-d)/2,0),f,s):l==n.Left?e.fillText(t,i,f,s):l==n.Right&&e.fillText(t,i+s-d,f,s)}}Object.defineProperty(t,"__esModule",{value:!0}),t.FixDPI=t.RenderParagraph=t.RenderText=t.RenderTextFull=t.VertAlign=t.Justification=void 0,function(e){e[e.Left=0]="Left",e[e.Right=1]="Right",e[e.Center=2]="Center"}(n=t.Justification||(t.Justification={})),function(e){e[e.Top=0]="Top",e[e.Bottom=1]="Bottom",e[e.Center=2]="Center"}(r=t.VertAlign||(t.VertAlign={})),t.RenderTextFull=i,t.RenderText=function(e,t,n,o,s,a,l){i(e,t,n,o,s,a,l,r.Center)},t.RenderParagraph=function(e,t,n,r,i,o){let s=r;if(e&&t.length){let r=[],a=[];e.textBaseline="top";let l=0;const c=e.measureText(" ").width,u=e.measureText(t),d=1.2*(u.actualBoundingBoxDescent-u.actualBoundingBoxAscent);let h=i-o;t.split(" ").forEach((function(t){const n=e.measureText(t);l+n.width>h&&(r.push(a.join(" ")),h=i,a.length=0,l=0),l+=n.width+c,a.push(t)})),a.length>0&&r.push(a.join(" "));let f=n+o;for(let t of r)e.fillText(t,f,s),f=n,s+=d}return s},t.FixDPI=function(e){let t=window.devicePixelRatio,n=+getComputedStyle(e).getPropertyValue("height").slice(0,-2),r=+getComputedStyle(e).getPropertyValue("width").slice(0,-2);0==n&&(n=e.height),0==r&&(r=e.width),e.setAttribute("height",(n*t).toString()),e.setAttribute("width",(r*t).toString())}},544:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Renderer30k=void 0;const r=n(391),i=n(419);class o{constructor(e){this._descriptionStartX=190,this._descriptionWidth=600,this._showWoundBoxes=!1,this._roster=null,this._currentX=0,this._currentY=0,this._maxWidth=0,this._octagon=null,this._roles=new Map,this._unitLabelWidthsNormalized=[.3,.077,.077,.077,.077,.077,.077,.077,.077,.077],this._vehicleLabelWidthsNormalized=[.3,.1,.1,.1,.1,.1,.2],this._walkerLabelWidthsNormalized=[.3,.06,.06,.06,.06,.06,.06,.06,.06,.06,.15],this._flyerLabelWidthsNormalized=[.3,.077,.077,.077,.077,.077,.077,.077,.077,.077],this._weaponLabelWidthNormalized=[.3,.1,.1,.1,.4],this._spellLabelWidthNormalized=[.3,.1,.1,.5],this._roster=e,this._octagon=document.getElementById("octagon"),this._roles.set(r.UnitRole30k.HQ,document.getElementById("role_hq")),this._roles.set(r.UnitRole30k.TR,document.getElementById("role_tr")),this._roles.set(r.UnitRole30k.EL,document.getElementById("role_el")),this._roles.set(r.UnitRole30k.FA,document.getElementById("role_fa")),this._roles.set(r.UnitRole30k.HS,document.getElementById("role_hs")),this._roles.set(r.UnitRole30k.FL,document.getElementById("role_fl")),this._roles.set(r.UnitRole30k.DT,document.getElementById("role_dt")),this._roles.set(r.UnitRole30k.FT,document.getElementById("role_ft")),this._roles.set(r.UnitRole30k.LW,document.getElementById("role_lw"))}render(e,t,n){if(null!=this._roster){e&&(e.innerHTML="

"+this._roster._name+" ("+this._roster._points+" pts)

");for(let e of this._roster._forces){const s=document.createElement("div");s&&(s.innerHTML="

"+e._catalog+" "+e._name+"

"),t&&t.appendChild(s);const a=document.createElement("table");a.classList.add("table"),a.classList.add("table-sm"),a.classList.add("table-striped");const l=document.createElement("thead");a.appendChild(l),l.classList.add("thead-light");const c=document.createElement("tr");l.appendChild(c),[{name:"NAME",w:"25%"},{name:"ROLE",w:"20%"},{name:"MODELS",w:"40%"},{name:"POINTS",w:"15%"}].forEach((e=>{let t=document.createElement("th");t.scope="col",t.innerHTML=e.name,t.style.width=e.w,c.appendChild(t)})),s.appendChild(a);let u=document.createElement("tbody");a.appendChild(u);for(let t of e._units){let e=document.createElement("tr"),n=document.createElement("td");n.innerHTML=t._name;let i=document.createElement("td");i.innerHTML=r.UnitRoleToString30k[t._role];let o=document.createElement("td");o.innerHTML="";let s=0;for(const e of t._models)e._count>1?o.innerHTML+=e._count+" "+e._name:o.innerHTML+=e._name,s++,s!=t._models.length&&(o.innerHTML+=", ");let a=document.createElement("td");a.innerHTML=t._points.toString(),e.appendChild(n),e.appendChild(i),e.appendChild(o),e.appendChild(a),u.appendChild(e)}if(e._rules.size>0){let t=document.createElement("div"),r=document.createElement("h3");t.appendChild(r),r.textContent=e._catalog+" Allegiance Rules";for(let n of e._rules){let e=document.createElement("div"),r=document.createElement("h4");r.textContent=n[0];let i=document.createElement("p");i.textContent=n[1],e.appendChild(r),e.appendChild(i),t.appendChild(e)}n&&n.appendChild(t)}for(let t of e._units){let e=document.createElement("canvas");e.width=7.5*o._res,e.height=20*o._res,this._descriptionWidth=e.width-this._descriptionStartX-10,(0,i.FixDPI)(e);const r=this.renderUnit(t,e,0,0),s=25;let a=document.createElement("canvas");a.width=r[0]+2*s,a.height=r[1]+2*s;let l=a.getContext("2d");if(null==l||l.drawImage(e,s,s),n){let e=document.createElement("div");e.appendChild(a),n.appendChild(e)}}}}}renderBorder(e,t,n,r,i){e.strokeStyle=o._blackColor,e.beginPath(),e.moveTo(t,n+o._bevelSize),e.lineTo(t,n+i-o._bevelSize),e.lineTo(t+o._bevelSize,n+i),e.lineTo(t+r-o._bevelSize,n+i),e.lineTo(t+r,n+i-o._bevelSize),e.lineTo(t+r,n+o._bevelSize),e.lineTo(t+r-o._bevelSize,n),e.lineTo(t+o._bevelSize,n),e.closePath(),e.stroke(),e.save(),e.fillStyle=o._fillColor,e.globalCompositeOperation="destination-over",e.beginPath(),e.moveTo(t,n+o._bevelSize),e.lineTo(t,n+i-o._bevelSize),e.lineTo(t+o._bevelSize,n+i),e.lineTo(t+r-o._bevelSize,n+i),e.lineTo(t+r,n+i-o._bevelSize),e.lineTo(t+r,n+o._bevelSize),e.lineTo(t+r-o._bevelSize,n),e.lineTo(t+o._bevelSize,n),e.closePath(),e.fill(),e.restore()}renderWatermark(e){}renderLine(e){e.lineWidth=2,e.strokeStyle=o._blackColor,e.beginPath(),e.moveTo(this._currentX,this._currentY),e.lineTo(this._currentX+this._maxWidth,this._currentY),e.stroke(),this._currentY+=1}renderTableHeader(e,t,n){let r=this._currentX;const s=this._maxWidth;e.fillStyle=o._grey1,e.fillRect(this._currentX,this._currentY,s,22),e.fillStyle=o._blackColor,e.font=o._titleFont;var a=50;if(t){e.font=o._headerFont;for(let o=0;o1?n+=e._count+" "+e._name:n+=e._name,r++,r!=t.length&&(n+=", ");this._currentY+=2,this._currentY=(0,i.RenderParagraph)(e,n,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth,0),this._currentY+=2}renderWoundBoxes(e,t){e.font=o._titleFont,(0,i.RenderText)(e,"WOUNDS",this._currentX+20,this._currentY,100,16,i.Justification.Left);const n=this._currentX+this._descriptionStartX,r=n+195;e.save();for(let s of t)if(s._wounds>1){let t=this._currentY;e.font=o._font,e.fillStyle=o._blackColor,this._currentY=(0,i.RenderParagraph)(e,s._name,n,this._currentY+3,195,0);let a=this._currentX+r;e.strokeStyle=o._blackColor,e.fillStyle="#ffffff";for(let n=0;n{u.push(e*this._maxWidth)}));const d=[];this._vehicleLabelWidthsNormalized.forEach((e=>{d.push(e*this._maxWidth)}));const h=[];this._walkerLabelWidthsNormalized.forEach((e=>{h.push(e*this._maxWidth)}));const f=[];for(var p of(this._flyerLabelWidthsNormalized.forEach((e=>{f.push(e*this._maxWidth)})),e._models)){c.push(p);for(let e of p._weapons)s.push(e);for(let e of p._psychicPowers)a.push(e);p._psyker&&l.push(p._psyker)}const _=[],m=new Map;for(const e of c)m.has(e._name)||(m.set(e._name,e),_.push(e));if(_.length>0){this.renderTableHeader(i,o._unitLabels,u);let e=0;for(var p of _)this.renderModel(i,p,u,e%2),e++}if(e._vehicles.length>0){this.renderTableHeader(i,o._vehicleLabels,d);let t=0;for(var g of e._vehicles)this.renderVehicle(i,g,d,t%2),t++}if(e._walkers.length>0){this.renderTableHeader(i,o._walkerLabels,h);let t=0;for(var v of e._walkers)this.renderWalker(i,v,h,t%2),t++}if(e._flyers.length>0){this.renderTableHeader(i,o._flyerLabels,f);let t=0;for(var b of e._flyers)this.renderFlyer(i,b,f,t%2),t++}const y=[],w=new Map;for(const e of s)w.has(e._name)||(w.set(e._name,e),y.push(e));if(y.length>0){const e=[];this._weaponLabelWidthNormalized.forEach((t=>{e.push(t*this._maxWidth)})),this.renderLine(i),this.renderTableHeader(i,o._weaponLabels,e),this.renderWeapons(i,y,e)}if(a.length>0){const e=[];this._spellLabelWidthNormalized.forEach((t=>{e.push(t*this._maxWidth)})),this.renderLine(i),this.renderTableHeader(i,o._spellLabels,e),this.renderPowers(i,a,e)}if(e._abilities.size>0&&(this.renderLine(i),this._currentY+=2,this.renderAbilities(i,e)),l.length>0&&(this.renderLine(i),this._currentY+=2,this.renderPsykers(i,l)),e._rules.size>0&&(this.renderLine(i),this._currentY+=2,this.renderRules(i,e)),e._factions.size>0&&(this.renderLine(i),this._currentY+=2,this.renderFactions(i,e)),e._keywords.size>0&&(this.renderLine(i),this._currentY+=2,this.renderKeywords(i,e)),e._models.length>0&&(this.renderLine(i),this._currentY+=2,this.renderModelList(i,_)),this._showWoundBoxes){let t=!1;for(let n of e._models)n._wounds>2&&(t=!0);t&&(this.renderLine(i),this._currentY+=5,this.renderWoundBoxes(i,e._models))}this._currentY+=2;const C=this._currentY-(r+o._margin),x=this._maxWidth;return this.renderBorder(i,this._currentX,r+o._margin,x,C),this.renderWatermark(i),[this._maxWidth,this._currentY]}renderHeader(e,t){t.globalAlpha=1,t.fillStyle=o._blackColor;const n=this._currentX,r=this._currentX+this._maxWidth,s=this._currentY,a=s+36;t.beginPath(),t.moveTo(n,s+o._bevelSize),t.lineTo(n,a),t.lineTo(r,a),t.lineTo(r,s+o._bevelSize),t.lineTo(r-o._bevelSize,s),t.lineTo(n+o._bevelSize,s),t.closePath(),t.fill();let l=n+6;if(this._octagon){t.drawImage(this._octagon,l,s+2,32,32);const n=this._roles.get(e._role);n&&t.drawImage(n,l+4,s+2+4,24,24),t.fillStyle="white",t.font="18px serif",l+=34,t.drawImage(this._octagon,l,s+2,32,32),(0,i.RenderText)(t,e._points.toString(),l,s+2,32,32,i.Justification.Center)}let c=0,u=28;const d=l+6;t.font=u+"px bold serif";const h=e._name.toLocaleUpperCase();let f=t.measureText(h);const p=this._maxWidth-d;for(;c<6&&f.width>p;)c+=1,u-=2,t.font=u+"px bold serif",f=t.measureText(h);t.fillStyle="white",t.textBaseline="top",(0,i.RenderText)(t,h,d,s,p,36,i.Justification.Center),this._currentY+=36}renderPsykers(e,t){e.font=o._titleFont,(0,i.RenderText)(e,"PSYKERS",this._currentX+20,this._currentY,100,16,i.Justification.Left),e.font=o._font,this._currentY+=2;for(let n of t)this._currentY=(0,i.RenderParagraph)(e,"MASTERY LEVEL: "+n._masteryLevel,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth,0),this._currentY+=2,this._currentY=(0,i.RenderParagraph)(e,"DISCIPLINES: "+n._disciplines,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth,0),this._currentY+=2}}t.Renderer30k=o,o._res=144,o._margin=0,o._bevelSize=15,o._blackColor="#1d272a",o._grey1="#b3bbb5",o._greyLight="#dde1df",o._fillColor="#f6f6f6",o._titleFont="bold 14px sans-serif",o._headerFont="bold 14px sans-serif",o._font="14px sans-serif",o._boldFont="bold 14px sans-serif",o._unitLabels=["MODEL","WS","BS","S","T","W","I","A","LD","SAVE"],o._vehicleLabels=["MODEL","BS","FRONT","SIDE","REAR","HP","TYPE"],o._walkerLabels=["MODEL","WS","BS","S","FRONT","SIDE","REAR","I","A","HP","TYPE"],o._flyerLabels=["MODEL","BS","FRONT","SIDE","REAR","HP","TYPE","ROLE","PURSUIT","AGILITY"],o._weaponLabels=["WEAPONS","RANGE","S","AP","TYPE"],o._spellLabels=["PSYCHIC POWER","WARP CHARGE","RANGE","DETAILS"]},467:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Renderer40k=void 0;const r=n(288),i=n(682),o=n(361),s=n(219);class a{constructor(e){this._roster=null,this._roles=new Map,this._unitLabelWidthsNormalized=[.25,.05,.05,.05,.05,.05,.05,.05,.05,.05],this._weaponLabelWidthNormalized=[.25,.05,.1,.05,.05,.05,.45],this._spellLabelWidthNormalized=[.25,.05,.1,.6],this._explosionLabelWidthNormalized=[.2,.1,.1,.15],this._trackerLabelWidth=[.2,.15,.1,.1,.1],this._roster=e,this._roles.set(r.UnitRole.HQ,document.getElementById("role_hq")),this._roles.set(r.UnitRole.TR,document.getElementById("role_tr")),this._roles.set(r.UnitRole.EL,document.getElementById("role_el")),this._roles.set(r.UnitRole.FA,document.getElementById("role_fa")),this._roles.set(r.UnitRole.HS,document.getElementById("role_hs")),this._roles.set(r.UnitRole.FL,document.getElementById("role_fl")),this._roles.set(r.UnitRole.DT,document.getElementById("role_dt")),this._roles.set(r.UnitRole.FT,document.getElementById("role_ft")),this._roles.set(r.UnitRole.LW,document.getElementById("role_lw"))}render(e,t,n){if(null!=this._roster){if(e){this.renderOptionsDiv(e);const t=[`${this._roster._cost._points} pts`,`${this._roster._cost._powerLevel} PL`,`${this._roster._cost._commandPoints} CP`];for(const e in this._roster._cost._freeformValues)t.push(`${this._roster._cost._freeformValues[e]}${e}`);const n=`${this._roster.name()} (${t.join(", ")})`;e.appendChild(document.createElement("h3")).appendChild(document.createTextNode(n));const r=e.appendChild(document.createElement("div"));r.classList.add("footer"),r.appendChild(document.createElement("div")).appendChild(document.createTextNode("PrettyScribe")),r.appendChild(document.createElement("div")).appendChild(document.createTextNode(n)),this._roster._customNotes&&e.appendChild(document.createElement("p")).appendChild(document.createTextNode(this._roster._customNotes))}t&&(this.renderRosterSummary(t),this.renderAbilitiesByPhase(t)),n&&this.renderRosterDetails(n),(0,s.loadOptionsFromLocalStorage)()}}renderRosterSummary(e){if(!this._roster)return;const t=this._roster._forces.some((e=>e._units.some((e=>0!==e._cost._commandPoints))));for(const n of this._roster._forces){const i=document.createElement("div");if(n._faction?i.appendChild(document.createTextNode(`${n._catalog} ${n.name()} (${n._faction})`)):i.appendChild(document.createTextNode(`${n._catalog} ${n.name()}`)),n._configurations.length>0){const e=i.appendChild(document.createElement("ul"));for(const t of n._configurations)e.appendChild(document.createElement("li")).appendChild(document.createElement("i")).appendChild(document.createTextNode(t))}e.appendChild(i);const o=document.createElement("table");o.classList.add("table","table-sm","table-striped");const s=document.createElement("thead");o.appendChild(s),s.classList.add("thead-light");const a=document.createElement("tr");s.appendChild(a);const l=[{name:"NAME",w:"20%"},{name:"ROLE",w:"15%"},{name:"MODELS",w:"55%"},{name:"POINTS",w:"5%"},{name:"POWER",w:"5%"}];t&&l.push({name:"CP",w:"5%"}),l.forEach((e=>{let t=document.createElement("th");t.scope="col",t.appendChild(document.createTextNode(e.name)),t.style.width=e.w,a.appendChild(t)})),i.appendChild(o);let c=document.createElement("tbody");o.appendChild(c);for(let e of n._units){const n=document.createElement("tr");n.appendChild(document.createElement("td")).appendChild(document.createTextNode(e.nameWithExtraCosts())),n.appendChild(document.createElement("td")).appendChild(document.createTextNode(r.UnitRoleToString[e._role]));const i=n.appendChild(document.createElement("td"));if(this.renderModelList(i,e),n.appendChild(document.createElement("td")).appendChild(document.createTextNode(e._cost._points.toString())),n.appendChild(document.createElement("td")).appendChild(document.createTextNode(e._cost._powerLevel.toString())),t){const t=(e._cost._commandPoints||"")+"";n.appendChild(document.createElement("td")).appendChild(document.createTextNode(t))}c.appendChild(n)}}}renderOptionsDiv(e){const t=e.appendChild(document.createElement("div"));t.classList.add("wh40k_options_div","d-print-none"),t.id="wh40k_options_div";const n=t.appendChild(document.createElement("span"));(0,s.renderOptionsToggle)(n),(0,s.renderCheckboxOption)(t,"showPhaseAbilities","Show abilities by phase",(e=>{const t=document.getElementById("wh40k_abilities_list");t&&(e.target.checked?t.classList.remove("d-none"):t.classList.add("d-none"))})),(0,s.renderCheckboxOption)(t,"showUpgradeCosts","Show upgrade costs",(e=>{const t=document.getElementsByClassName("wh40k_upgrade_cost");for(const n of t)e.target.checked?n.classList.remove("d-none"):n.classList.add("d-none")})),(0,s.renderCheckboxOption)(t,"collateDatasheets","Collate Detachment Datasheets",(e=>{const t=document.getElementById("collated_sheets"),n=document.getElementById("detachment_sheets");t&&n&&(e.target.checked?(t.classList.remove("d-none"),n.classList.add("d-none")):(t.classList.add("d-none"),n.classList.remove("d-none")))}));const r=t.appendChild(document.createElement("span"));r.classList.add("wh40k_options_print_subsection"),r.appendChild(document.createTextNode("Print:")),(0,s.renderCheckboxOption)(r,"printBigger","Larger Text",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("bigger"):n.classList.remove("bigger")})),(0,s.renderCheckboxOption)(r,"hideElements","Hide Elements",(e=>{const t=document.body;e.target.checked?(t.classList.add("hide_enabled"),t.addEventListener("click",o.toggleHidden)):(t.classList.remove("hide_enabled"),t.removeEventListener("click",o.toggleHidden))})),(0,s.renderCheckboxOption)(r,"datasheetPageBreaks","One Datasheet per Page",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("page_break"):n.classList.remove("page_break")}))}renderAbilitiesByPhase(e){if(!this._roster)return;const t={},n={};for(const e of this._roster._forces)for(const r of e._units)for(const e of Object.values(r._abilities))for(const[i,s]of e.entries()){const e=[...s.matchAll(/(?:before the first turn begins|set up|Reinforcements|(?:Command|Movement|Psychic|Shooting|Charge|Fight|Morale) phase)/gi)];if(0===e.length)continue;const a=(0,o.addHideAble)(document.createElement("div"));a.appendChild(document.createElement("b")).appendChild(document.createTextNode(r.name())),a.appendChild(document.createTextNode(" - ")),a.appendChild(document.createElement("b")).appendChild(document.createTextNode(i)),a.appendChild(document.createTextNode(" - "));let l=s;for(const r of e){if(!r.index)continue;const e=r[0].toLocaleLowerCase();let o=e;switch(e){case"before the first turn begins":o="pre-game phase";break;case"set up":s.includes("reinforcements")||(o="pre-game phase");break;case"reinforcements":o="movement phase"}if(s.toLocaleLowerCase().includes("as if it were your "+o))continue;const c=r.index-(s.length-l.length);c>0&&a.appendChild(document.createTextNode(l.substring(0,c)));const u=t[o]=t[o]||[],d=n[o]=n[o]||[];d.includes(i)||(d.push(i),u.push(a)),a.appendChild(document.createElement("u")).appendChild(document.createTextNode(r[0]));const h=c+e.length;l=l.substring(h)}l.length>0&&a.appendChild(document.createTextNode(l))}const r=e.appendChild(document.createElement("div"));r.setAttribute("id","wh40k_abilities_list"),r.classList.add("d-none"),r.appendChild(document.createElement("h3")).appendChild(document.createTextNode("Abilities by Phase"));const i=["pre-game phase","command phase","movement phase","psychic phase","shooting phase","charge phase","fight phase","morale phase"].filter((e=>!!t[e]));if(0===i.length)r.appendChild(document.createTextNode("No phase-specific abilities in roster"));else for(const e of i){r.appendChild(document.createElement("h4")).appendChild(document.createTextNode(e));for(const n of t[e])r.appendChild(n.parentElement?n.cloneNode(!0):n)}}renderRosterDetails(e){if(!this._roster)return;const t=new Map,n=new Map,i=e.appendChild(document.createElement("div"));i.id="detachment_sheets";const o=e.appendChild(document.createElement("div"));o.id="collated_sheets",o.style.pageBreakBefore="always",o.classList.add("d-none");const s=[];for(const e of this._roster._forces){const r=document.createElement("div");if(r.style.pageBreakBefore="always",r){const t=document.createElement("p");t.appendChild(document.createTextNode(e._catalog)),e._faction&&t.appendChild(document.createTextNode(" ("+e._faction+")")),r.appendChild(t)}let o=document.createElement("h3");o.appendChild(r),i.appendChild(o),this.renderDatasheets(i,e._units),s.push(...e._units),l(t,e._catalog,e._rules),l(n,e._faction,e._factionRules)}s.sort(((e,t)=>e._role!=t._role?e._role-t._role:e._name!=t._name?(0,r.Compare)(e._name,t._name):e._cost._points-t._cost._points)),this.renderDatasheets(o,s);let a=document.createElement("div");a.style.pageBreakBefore="always",this.printRules(t,a),this.printRules(n,a),e.appendChild(a)}renderDatasheets(e,t){let n=0;for(let r=0;r1?` (${n})`:""),d],[.1,.8,.1]));const h=l.appendChild(document.createElement("tr"));for(let e=0;e<20;e++){const e=h.appendChild(document.createElement("td"));e.colSpan=1,e.style.width="5%",e.style.padding="0"}let f=(0,i.createNoteHead)("Unit notes",t);f&&s.appendChild(f),l=s.appendChild(document.createElement("thead")),l.classList.add("table-active"),l.appendChild((0,i.createTableRow)(a._unitLabels,this._unitLabelWidthsNormalized,!0));let p=s.appendChild(document.createElement("tbody"));p.append(document.createElement("tr"));for(const e of t._modelStats)p.append((0,i.createTableRow)([e._name,e._move,e._ws,e._bs,e._str.toString(),e._toughness.toString(),e._wounds.toString(),e._attacks.toString(),e._leadership.toString(),e._save],this._unitLabelWidthsNormalized));if(f=(0,i.createNotesHead)("Model notes",t._modelStats),f&&s.appendChild(f),t._woundTracker.length>0){const e=Array.from(a._trackerLabels);if(4==t._woundTracker.length){const n=Array.from(t._woundTracker[0]._table.values());e.splice(1,n.length,...n)}else if(3==t._woundTracker.length){const n=Array.from(t._woundTracker[0]._table.keys());e.splice(1,n.length,...n)}l=s.appendChild(document.createElement("thead")),l.classList.add("table-active"),l.appendChild((0,i.createTableRow)(e,this._trackerLabelWidth,!0)),p=s.appendChild(document.createElement("tbody")),p.append(document.createElement("tr"));for(const e of t._woundTracker)p.appendChild((0,i.createTableRow)([""].concat(Array.from(e._table.values())),this._trackerLabelWidth))}if(t._weapons.length>0){l=s.appendChild(document.createElement("thead")),l.classList.add("table-active"),l.appendChild((0,i.createTableRow)(a._weaponLabels,this._weaponLabelWidthNormalized,!0)),p=s.appendChild(document.createElement("tbody")),p.append(document.createElement("tr"));for(const e of t._weapons)p.append((0,i.createTableRow)([e.name().toString(),e._range,e._type,e._str.toString(),e._ap,e._damage,e._abilities],this._weaponLabelWidthNormalized))}if(f=(0,i.createNotesHead)("Weapon notes",t._weapons),f&&s.appendChild(f),t._spells.length>0){l=s.appendChild(document.createElement("thead")),l.classList.add("table-active"),l.appendChild((0,i.createTableRow)(a._spellLabels,this._spellLabelWidthNormalized,!0)),p=s.appendChild(document.createElement("tbody")),p.append(document.createElement("tr"));for(const e of t._spells)p.append((0,i.createTableRow)([e.name(),e._manifest.toString(),e._range,e._details],this._spellLabelWidthNormalized))}if(f=(0,i.createNotesHead)("Spell notes",t._spells),f&&s.appendChild(f),t._psykers.length>0){l=s.appendChild(document.createElement("thead")),l.classList.add("info_row");const e=document.createElement("div");for(const n of t._psykers){let t=`CAST: ${n._cast}, DENY: ${n._deny}, POWERS KNOWN: ${n._powers}`;n._other&&(t+=`, OTHER: ${n._other}`),e.appendChild(document.createElement("div")).appendChild(document.createTextNode(t))}l.appendChild((0,i.createTableRow)(["Psykers",e],[.1,.9],!1))}f=(0,i.createNotesHead)("Psyker notes",t._psykers),f&&s.appendChild(f),!t._abilities.Abilities&&t._rules.size>0&&this.renderUnitAbilitiesAndRules(s,"Abilities",new Map,t._rules);for(const e of Object.keys(t._abilities).sort()){const n=t._abilities[e],r="Abilities"===e?t._rules:void 0;this.renderUnitAbilitiesAndRules(s,e,n,r)}l=s.appendChild(document.createElement("thead")),l.classList.add("info_row");const _=Array.from(t._factions).sort(r.Compare).join(", ").toLocaleUpperCase();l.appendChild((0,i.createTableRow)(["Factions",_],[.1,.9],!1)),l=s.appendChild(document.createElement("thead")),l.classList.add("info_row");const m=Array.from(t._keywords).sort(r.Compare).join(", ").toLocaleUpperCase();l.appendChild((0,i.createTableRow)(["Keywords",m],[.1,.9],!1)),l=s.appendChild(document.createElement("thead")),l.classList.add("info_row");const g=document.createElement("div");if(this.renderModelList(g,t),l.appendChild((0,i.createTableRow)(["MODELS",g],[.1,.9],!1)),t._explosions.length>0){l=s.appendChild(document.createElement("thead")),l.classList.add("table-active"),l.appendChild((0,i.createTableRow)(a._explosionLabels,this._explosionLabelWidthNormalized,!0)),p=s.appendChild(document.createElement("tbody")),p.append(document.createElement("tr"));for(const e of t._explosions)p.append((0,i.createTableRow)([e.name(),e._diceRoll,e._distance,e._mortalWounds],this._explosionLabelWidthNormalized))}f=(0,i.createNotesHead)("Explosion notes",t._explosions),f&&s.appendChild(f)}renderUnitAbilitiesAndRules(e,t,n,s){const a=e.appendChild(document.createElement("thead"));a.classList.add("info_row");const l=document.createElement("div");if(s&&s.size>0){const e=Array.from(s.keys()).sort(r.Compare).join(", ");l.appendChild(document.createElement("div")).appendChild(document.createElement("b")).appendChild(document.createTextNode(e))}const c=Array.from(n.keys()).sort(r.Compare);for(const e of c){const t=(0,o.addHideAble)(l.appendChild(document.createElement("div")));t.appendChild(document.createElement("b")).appendChild(document.createTextNode(`${e.toUpperCase()}: `)),t.appendChild(document.createTextNode(n.get(e)||"??"))}a.appendChild((0,i.createTableRow)([t,l],[.1,.9],!1))}renderModelList(e,t){for(const n of t._models){const t=e.appendChild(document.createElement("div"));t.appendChild(document.createTextNode((n._count>1?`${n._count}x `:"")+n.name()));const r=n.getDedupedWeaponsAndUpgrades();if(0!==r.length){t.appendChild(document.createTextNode(" ("));for(const e of r)if(e!==r[0]&&t.appendChild(document.createTextNode(", ")),t.appendChild(document.createTextNode((e._count>1?`${e._count}x `:"")+e.selectionName())),e._cost.hasValues()){const n=t.appendChild(document.createElement("span"));n.classList.add("wh40k_upgrade_cost","d-none"),n.appendChild(document.createTextNode(` ${e._cost.toString()}`))}t.appendChild(document.createTextNode(")"))}}}printRules(e,t){if(0!==e.size&&t)for(let[n,r]of e.entries()){let e=document.createElement("div");e.classList.add("wh40k_rules");let i=document.createElement("h3");e.appendChild(i),i.appendChild(document.createTextNode(n));for(let t of r){let n=(0,o.addHideAble)(document.createElement("div")),r=document.createElement("b");r.appendChild(document.createTextNode(t[0]));let i=document.createElement("p");i.appendChild(document.createTextNode(t[1]||"")),n.appendChild(r),n.appendChild(i),e.appendChild(n)}t.appendChild(e)}}}function l(e,t,n){0!==n.size&&e.set(t,new Map([...e.get(t)||[],...n]))}t.Renderer40k=a,a._unitLabels=["MODEL","M","WS","BS","S","T","W","A","LD","SAVE"],a._weaponLabels=["WEAPONS","RANGE","TYPE","S","AP","D","ABILITIES"],a._spellLabels=["PSYCHIC POWER","MANIFEST","RANGE","DETAILS"],a._explosionLabels=["EXPLOSION","DICE ROLL","DISTANCE","MORTAL WOUNDS"],a._trackerLabels=["WOUND TRACK","REMAINING W","ATTRIBUTE","ATTRIBUTE","ATTRIBUTE"]},542:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Wh40kRenderer=void 0;const r=n(208),i=n(361),o=n(219),s=n(77);function a(e,t,n){0!==n.size&&e.set(t,new Map([...e.get(t)||[],...n]))}t.Wh40kRenderer=class{constructor(e){var t,n;this._roster=null,this._roles=new Map,this._unitLabelWidthsNormalized=[.4,.05,.05,.05,.05,.05,.05,.3],this._weaponLabelWidthNormalized=[.3,.1,.1,.05,.05,.05,.05,.3],this._roster=e;const i=(null===(t=this._roster)||void 0===t?void 0:t.hash())||0;this._rosterId=`${null===(n=this._roster)||void 0===n?void 0:n.name()}:${(i>>>0).toString(16)}`,this._roles.set(r.Wh40k.UnitRole.EpicHero,document.getElementById("role_hq")),this._roles.set(r.Wh40k.UnitRole.Character,document.getElementById("role_hq")),this._roles.set(r.Wh40k.UnitRole.Battleline,document.getElementById("role_tr")),this._roles.set(r.Wh40k.UnitRole.Infantry,document.getElementById("role_el")),this._roles.set(r.Wh40k.UnitRole.Vehicle,document.getElementById("role_hs")),this._roles.set(r.Wh40k.UnitRole.Mounted,document.getElementById("role_fa")),this._roles.set(r.Wh40k.UnitRole.Transport,document.getElementById("role_dt")),this._roles.set(r.Wh40k.UnitRole.Fortification,document.getElementById("role_ft"))}render(e,t,n){if(null==this._roster)return;const r=[`${this._roster._cost._points} pts`];for(const e in this._roster._cost._freeformValues)r.push(`${this._roster._cost._freeformValues[e]}${e}`);const i=`${this._roster.name()} (${r.join(", ")})`;null==e||e.appendChild(s.PsJsx.createElement(s.PsJsx.createFragment,null,this.renderOptionsDiv(),s.PsJsx.createElement("h3",null,i),s.PsJsx.createElement("div",{className:"footer"},s.PsJsx.createElement("div",null,"PrettyScribe"),s.PsJsx.createElement("div",null,i)),this._roster._customNotes&&s.PsJsx.createElement("p",null,this._roster._customNotes))),null==t||t.appendChild(s.PsJsx.createElement(s.PsJsx.createFragment,null,this.renderRosterSummary(),this.renderAbilitiesByPhase())),null==n||n.appendChild(this.renderRosterDetails()),(0,o.loadOptionsFromLocalStorage)(),this.loadDatasheetOrderFromLocalStorage(),this.collapseIdenticalUnits()}renderRosterSummary(){var e;return s.PsJsx.createElement(s.PsJsx.createFragment,null,null===(e=this._roster)||void 0===e?void 0:e._forces.map((e=>this.renderForceSummary(e))))}renderForceSummary(e){let t;const n=s.PsJsx.createElement("div",null,e._faction?`${e._catalog} ${e.name()} (${e._faction})`:`${e._catalog} ${e.name()}`,e._configurations.length>0&&s.PsJsx.createElement("ul",null,e._configurations.map((e=>s.PsJsx.createElement("li",null,s.PsJsx.createElement("i",null,e))))),s.PsJsx.createElement("table",{className:"table table-sm table-striped"},s.PsJsx.createElement("thead",{className:"thead-light"},s.PsJsx.createElement("tr",null,s.PsJsx.createElement("th",{scope:"col",style:"width: 20%;"},"NAME"),s.PsJsx.createElement("th",{scope:"col",style:"width: 15%;"},"ROLE"),s.PsJsx.createElement("th",{scope:"col",style:"width: 55%;"},"MODELS"),s.PsJsx.createElement("th",{scope:"col",style:"width: 5%;"},"POINTS"))),s.PsJsx.createElement("tbody",{ref:e=>{t=e}},e._units.map(((e,t)=>s.PsJsx.createElement("tr",{"data-index":t},s.PsJsx.createElement("td",null,e.nameWithExtraCosts()),s.PsJsx.createElement("td",null,r.Wh40k.UnitRoleToString[e._role]),s.PsJsx.createElement("td",null,this.renderModelList(e)),s.PsJsx.createElement("td",null,e._cost._points.toString())))))),s.PsJsx.createElement("button",{id:"reset-order-button",className:"d-none btn btn-secondary d-print-none",onclick:e=>this.resetDatasheetOrder(t)},"Reset datasheet order"));return this.makeForceSummaryListItemsDraggable(t),n}makeForceSummaryListItemsDraggable(e){for(const t of e.children)t.draggable=!0,t.classList.add("draggable");let t,n;e.addEventListener("dragstart",(e=>{t=e.target.closest("[draggable]"),e.dataTransfer.effectAllowed="move"})),e.addEventListener("dragover",(e=>{e.preventDefault();const t=e.target.closest("[draggable]");n!==t&&(null==n||n.classList.remove("draggable_drop_target_top"),null==t||t.classList.add("draggable_drop_target_top"),n=t)})),e.addEventListener("drop",(e=>{e.preventDefault(),null==n||n.classList.remove("draggable_drop_target_top");const r=e.target.closest("[draggable]");if(!t||t===r)return;const i=t.parentElement;i.insertBefore(t,r),this.orderDatasheetsToMatchSummary(i),this.collapseIdenticalUnits(),this.saveDatasheetOrderToLocalStorage()}))}orderDatasheetsToMatchSummary(e){const t=e.children;let n=!0;for(let e=0;e0){const i=t[e-1].dataset.index||-1;n&&(n=+(r||0)>+i)}const i=document.querySelector(`.wh40k_unit_sheet[data-index="${r}"]`);i&&(i.style.order=String(e))}const r=document.querySelector("#reset-order-button");n?null==r||r.classList.add("d-none"):null==r||r.classList.remove("d-none")}collapseIdenticalUnits(){var e,t;const n=document.querySelectorAll(".wh40k_unit_sheet"),r=Array.from(n).sort(((e,t)=>+e.style.order-+t.style.order));let i=null;for(const n of r){n.classList.remove("d-none");const r=n.querySelector("div.unit_count > span");if(i&&(null==i?void 0:i.dataset.hash)===n.dataset.hash){i.classList.add("d-none");const t=i.querySelector("div.unit_count > span"),n=+((null==t?void 0:t.dataset.count)||"");r.dataset.count=String(n+1),null===(e=r.parentElement)||void 0===e||e.classList.remove("d-none")}else r.dataset.count=String(1),null===(t=r.parentElement)||void 0===t||t.classList.add("d-none");i=n}}saveDatasheetOrderToLocalStorage(){try{const e=document.querySelectorAll("tr.draggable"),t=Array.from(e).map((e=>e.dataset.index));(0,o.saveOptionToLocalStorage)(`40k-order-${this._rosterId}`,JSON.stringify(t))}catch(e){console.warn("Error in saveDatasheetOrderToLocalStorage",e)}}loadDatasheetOrderFromLocalStorage(){var e;try{const t=JSON.parse(window.localStorage[`40k-order-${this._rosterId}`]||"[]"),n=null===(e=document.querySelector("tr.draggable"))||void 0===e?void 0:e.parentElement;if(t.length){const e=Array.from(n.children);for(let r=0;r+(e.dataset.index||0)-+(t.dataset.index||0)));for(const n of t)e.appendChild(n);this.orderDatasheetsToMatchSummary(e),this.collapseIdenticalUnits()}catch(e){console.warn("Error in resetDatasheetOrder",e)}}renderOptionsDiv(){const e=s.PsJsx.createElement("div",{className:"wh40k_options_div d-print-none",id:"wh40k_options_div"}),t=e.appendChild(s.PsJsx.createElement("span",null));(0,o.renderOptionsToggle)(t),(0,o.renderCheckboxOption)(e,"showPhaseAbilities","Show abilities by phase",(e=>{const t=document.getElementById("wh40k_abilities_list");t&&(e.target.checked?t.classList.remove("d-none"):t.classList.add("d-none"))})),(0,o.renderCheckboxOption)(e,"showUpgradeCosts","Show upgrade costs",(e=>{const t=document.getElementsByClassName("wh40k_upgrade_cost");for(const n of t)e.target.checked?n.classList.remove("d-none"):n.classList.add("d-none")})),(0,o.renderCheckboxOption)(e,"showArmyRules","Show army rules",(e=>{const t=document.getElementById("all-army-rules");e.target.checked?null==t||t.classList.remove("d-none"):null==t||t.classList.add("d-none")}),!0),(0,o.renderCheckboxOption)(e,"singleColumnDatasheets","Single-Column Datasheets",(e=>{e.target.checked?document.body.classList.add("single_column"):document.body.classList.remove("single_column")}));const n=e.appendChild(s.PsJsx.createElement("span",{className:"wh40k_options_print_subsection"},"Print:"));return(0,o.renderCheckboxOption)(n,"printBigger","Larger Text",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("bigger"):n.classList.remove("bigger")})),(0,o.renderCheckboxOption)(n,"hideElements","Hide Elements",(e=>{const t=document.body;e.target.checked?(t.classList.add("hide_enabled"),t.addEventListener("click",i.toggleHidden)):(t.classList.remove("hide_enabled"),t.removeEventListener("click",i.toggleHidden))})),(0,o.renderCheckboxOption)(n,"datasheetPageBreaks","One Datasheet per Page",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("page_break"):n.classList.remove("page_break")})),e}renderAbilitiesByPhase(){if(!this._roster)return;const e={},t={};for(const n of this._roster._forces)for(const r of n._units)for(const n of Object.values(r._abilities))for(const[i,o]of n.entries()){const n=[...o.matchAll(/(?:before the first turn begins|set up|Reinforcements|(?:Command|Movement|Psychic|Shooting|Charge|Fight|Morale) phase)/gi)];if(0===n.length)continue;const a=s.PsJsx.createElement("div",{className:"hide_able"},s.PsJsx.createElement("b",null,r.name())," - ",s.PsJsx.createElement("b",null,i)," - ");let l=o;for(const r of n){if(!r.index)continue;const n=r[0].toLocaleLowerCase();let c=n;switch(n){case"before the first turn begins":c="pre-game phase";break;case"set up":o.includes("reinforcements")||(c="pre-game phase");break;case"reinforcements":c="movement phase"}if(o.toLocaleLowerCase().includes("as if it were your "+c))continue;const u=r.index-(o.length-l.length);u>0&&a.appendChild(document.createTextNode(l.substring(0,u)));const d=e[c]=e[c]||[],h=t[c]=t[c]||[];h.includes(i)||(h.push(i),d.push(a)),a.appendChild(s.PsJsx.createElement("u",null,r[0]));const f=u+n.length;l=l.substring(f)}l.length>0&&a.appendChild(document.createTextNode(l))}const n=["pre-game phase","command phase","movement phase","psychic phase","shooting phase","charge phase","fight phase","morale phase"].filter((t=>!!e[t]));return s.PsJsx.createElement("div",{id:"wh40k_abilities_list",className:"d-none"},s.PsJsx.createElement("h3",null,"Abilities by Phase"),0===n.length?"No phase-specific abilities in roster":n.map((t=>s.PsJsx.createElement(s.PsJsx.createFragment,null,s.PsJsx.createElement("h4",null,t),e[t].map((e=>e.cloneNode(!0)))))))}renderRosterDetails(){if(!this._roster)return;const e=new Map,t=new Map;return s.PsJsx.createElement(s.PsJsx.createFragment,null,s.PsJsx.createElement("div",{className:"page_break",style:"display: flex; flex-direction: column;"},this._roster._forces.map((n=>s.PsJsx.createElement(s.PsJsx.createFragment,null,this._roster._forces.length>1&&s.PsJsx.createElement("h3",null,s.PsJsx.createElement("div",{style:"page-break-before: always;"},s.PsJsx.createElement("p",null,n._catalog,n._faction&&` (${n._faction})`))),a(e,n._catalog,n._rules),a(t,n._faction,n._factionRules),n._units.map(((e,t)=>this.renderUnit(e,t))))))),s.PsJsx.createElement("div",{id:"all-army-rules",style:"page-break-before: always;"},this.renderRules(e),this.renderRules(t)))}renderUnit(e,t){var n;return s.PsJsx.createElement("div",{className:"wh40k_unit_sheet","data-hash":(e.hash()>>>0).toString(16),"data-name":e.name(),"data-index":String(t),style:`order: ${t};`},s.PsJsx.createElement("table",{className:"table table-sm table-striped"},s.PsJsx.createElement("thead",{className:"table-dark unit_header"},s.PsJsx.createElement("tr",{className:"hide_able"},s.PsJsx.createElement("td",{scope:"col",colspan:"2",style:"width: 10%;"},s.PsJsx.createElement("div",{className:"unit_costs"},s.PsJsx.createElement("span",null,(null===(n=this._roles.get(e._role))||void 0===n?void 0:n.cloneNode())||"-"),s.PsJsx.createElement("span",null,e._cost._points.toString()))),s.PsJsx.createElement("td",{scope:"col",colspan:"16",style:"width: 80%;"},e.name()),s.PsJsx.createElement("td",{scope:"col",colspan:"2",style:"width: 10%;"},s.PsJsx.createElement("div",{className:"unit_costs unit_count"},s.PsJsx.createElement("span",{className:"unit_count","data-count":"1"})))),s.PsJsx.createElement("tr",null,[...Array(20).keys()].map((e=>s.PsJsx.createElement("td",{colspan:"1",style:"width: 5%; padding: 0px;"})))),this.renderNotesHead("Unit notes",e)),s.PsJsx.createElement("thead",null,s.PsJsx.createElement("tr",null,s.PsJsx.createElement("td",{colspan:"20",className:"subTableTd"},s.PsJsx.createElement("div",null,this.renderProfilesTables(e),s.PsJsx.createElement("table",{className:"table table-sm table-striped"},!e._abilities.Abilities&&e._rules.size>0&&this.renderUnitAbilitiesAndRules("Abilities",new Map,e._rules),Object.entries(e._abilities).sort().map((([t,n])=>this.renderUnitAbilitiesAndRules(t,n,"Abilities"===t?e._rules:void 0)))))))),s.PsJsx.createElement("thead",{className:"info_row keywords_row"},s.PsJsx.createElement("tr",{class:"hide_able"},s.PsJsx.createElement("td",{colspan:"20"},s.PsJsx.createElement("div",{class:"wh40k_keywords_and_factions"},s.PsJsx.createElement("div",{class:"wh40k_keywords"},s.PsJsx.createElement("div",null,"Keywords"),s.PsJsx.createElement("div",null,Array.from(e._keywords).sort(r.Wh40k.Compare).join(", ").toLocaleUpperCase())),s.PsJsx.createElement("div",{class:"wh40k_factions"},s.PsJsx.createElement("div",null,"Factions"),s.PsJsx.createElement("div",null,Array.from(e._factions).sort(r.Wh40k.Compare).join(", ").toLocaleUpperCase())))))),s.PsJsx.createElement("thead",{className:"info_row"},s.PsJsx.createElement("tr",{class:"hide_able"},s.PsJsx.createElement("td",{scope:"col",colspan:"2",style:"width: 10%;"},"MODELS"),s.PsJsx.createElement("td",{scope:"col",colspan:"18",style:"width: 90%;"},s.PsJsx.createElement("div",null,this.renderModelList(e)))))))}renderProfilesTables(e){const t=Object.entries(e._profileTables).sort(((e,t)=>r.Wh40k.CompareProfileTableName(e[0],t[0]))).map((([e,t])=>[t,"Unit"===e?this._unitLabelWidthsNormalized:this._weaponLabelWidthNormalized]));return s.PsJsx.createElement("table",{className:"table table-sm table-striped wh40k_profiles"},t.map((([e,t])=>s.PsJsx.createElement(s.PsJsx.createFragment,null,s.PsJsx.createElement("thead",{className:"table-active"},s.PsJsx.createElement("tr",{className:"hide_able header_row"},t.map(((t,n)=>s.PsJsx.createElement("th",{scope:"col",colspan:Math.round(t/.05),style:`width: ${100*t}%;`},this.renderProfileTableHeaderCell(e._headers[n])))))),s.PsJsx.createElement("tbody",null,s.PsJsx.createElement("tr",null)," ",e._contents.map((e=>s.PsJsx.createElement("tr",{className:"hide_able"},t.map(((t,n)=>s.PsJsx.createElement("td",{scope:"col",colspan:Math.round(t/.05),style:`width: ${100*t}%;`},e[n])))))))))))}renderProfileTableHeaderCell(e){return"Ranged Weapons"===e||"Melee Weapons"===e?s.PsJsx.createElement(s.PsJsx.createFragment,null,s.PsJsx.createElement("span",{class:"desktop-only"},e),s.PsJsx.createElement("span",{class:"mobile-only"},e.replace(" Weapons",""))):"Range"===e?s.PsJsx.createElement(s.PsJsx.createFragment,null,s.PsJsx.createElement("span",{class:"desktop-only"},e),s.PsJsx.createElement("span",{class:"mobile-only"},"Rng")):s.PsJsx.createElement(s.PsJsx.createFragment,null,e)}renderUnitAbilitiesAndRules(e,t,n){return s.PsJsx.createElement(s.PsJsx.createFragment,null,s.PsJsx.createElement("thead",{className:"info_row table-active"},s.PsJsx.createElement("tr",{className:"header_row"},s.PsJsx.createElement("th",null,e))),s.PsJsx.createElement("tbody",{className:"info_row"},s.PsJsx.createElement("tr",null)," ",n&&n.size>0&&s.PsJsx.createElement("tr",{className:"hide_able"},s.PsJsx.createElement("td",{scope:"col",style:"width: 100%;"},s.PsJsx.createElement("div",null,s.PsJsx.createElement("div",null,s.PsJsx.createElement("b",null,Array.from(n.keys()).sort(r.Wh40k.Compare).join(", ")))))),Array.from(t.keys()).sort(r.Wh40k.Compare).map((e=>s.PsJsx.createElement("tr",{className:"hide_able"},s.PsJsx.createElement("td",{scope:"col",style:"width: 100%;"},s.PsJsx.createElement("div",null,s.PsJsx.createElement("div",{className:"hide_able"},s.PsJsx.createElement("b",null,`${e.toUpperCase()}: `),t.get(e)||"??"))))))))}renderModelList(e){return e._models.map((e=>s.PsJsx.createElement("div",null,e._count>1?`${e._count}x `:"",e.name(),e.getDedupedWeaponsAndUpgrades().length>0&&s.PsJsx.createElement(s.PsJsx.createFragment,null," (",e.getDedupedWeaponsAndUpgrades().map(((e,t)=>s.PsJsx.createElement(s.PsJsx.createFragment,null,t>0?", ":"",e._count>1?`${e._count}x `:"",e.selectionName(),e._cost.hasValues()&&s.PsJsx.createElement("span",{className:"wh40k_upgrade_cost d-none"},` ${e._cost.toString()}`)))),")"))))}renderRules(e){return 0===e.size?null:s.PsJsx.createElement(s.PsJsx.createFragment,null,Array.from(e.entries()).map((([e,t])=>s.PsJsx.createElement("div",{className:"wh40k_rules"},s.PsJsx.createElement("h3",null,e),Array.from(t.entries()).map((e=>s.PsJsx.createElement("div",{className:"hide_able"},s.PsJsx.createElement("b",null,e[0]),s.PsJsx.createElement("p",null,e[1]))))))))}renderNotesHead(e,t){return t.notes()?s.PsJsx.createElement("thead",{className:"info_row"},s.PsJsx.createElement("tr",null,s.PsJsx.createElement("td",{style:"width: 10%",colspan:"2"},e),s.PsJsx.createElement("td",{style:"width: 90%",colspan:"18"},t._customNotes))):null}}},964:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RendererAoS=void 0;const r=n(774);t.RendererAoS=class{constructor(e){this._roster=null,this._roster=e}render(e,t,n){if(null!=this._roster){if(e){e.innerHTML="

"+this._roster._name.toUpperCase()+" ("+this._roster._points+" pts, "+this._roster._commandPoints+" CP)

";let t=document.createElement("h3");t.textContent="ROSTER",e.appendChild(t)}for(let e of this._roster._forces){const i=document.createElement("div");i&&(i.innerHTML="

"+e._catalog+" "+e._name+"

"),t&&t.appendChild(i);const o=[{name:"NAME",width:"35%"},{name:"ROLE",width:"15%"},{name:"SELECTIONS",width:"40%"},{name:"POINTS",width:"10%"}],s=this.createTable(o);s.classList.add("table","table-sm","aos_font"),i.appendChild(s);let a=document.createElement("tbody");s.appendChild(a);for(let t of e._units){let e=document.createElement("tr"),n=document.createElement("td");n.innerHTML=`${t._name}`;let i=document.createElement("td");i.innerHTML=r.AoSUnitRoleToString[t._role];let o=document.createElement("td");o.innerHTML="";for(const e of t._selections)o.innerHTML+=e+"
";let s=document.createElement("td");s.textContent=t._points.toString(),e.appendChild(n),e.appendChild(i),e.appendChild(o),e.appendChild(s),a.appendChild(e)}let l=document.createElement("div"),c=document.createElement("h3");if(c.textContent=e._allegiance._name.toUpperCase(),l.appendChild(c),e._allegiance._commandAbilities.size>0&&this.renderAbilityMap(l,"ABILITIES",e._allegiance._commandAbilities),e._allegiance._battleTraits.size>0&&this.renderAbilityMap(l,"BATTLE TRAITS",e._allegiance._battleTraits),e._allegiance._spells.length>0){let t=document.createElement("h4");t.textContent="ALLEGIANCE SPELLS",l.append(t),this.renderSpells(l,e._allegiance._spells)}if(e._allegiance._extraProfiles.length>0){let t="";for(let n of e._allegiance._extraProfiles)if(1==n._value._fields.size){if(t!=n._value._typeName){let e=document.createElement("h4");l.appendChild(e),e.textContent=n._value._typeName.toUpperCase(),t=n._value._typeName}const e=n._value._fields.values();let r=document.createElement("p");r.classList.add("aos_font"),r.innerHTML=`${n._name}: ${e.next().value}`,l.appendChild(r)}else console.log("Table profiles not implemented. "+n._value._typeName)}if(e._grandStrategy&&""!=e._grandStrategy._name){let t=document.createElement("h3");l.appendChild(t),t.textContent="GRAND STRATEGY";let n=document.createElement("div"),r=document.createElement("h4");r.textContent=e._grandStrategy._name;let i=document.createElement("p");i.textContent=e._grandStrategy._description,n.appendChild(r),n.appendChild(i),l.appendChild(n)}if(e._triumph&&""!=e._triumph._name){let t=document.createElement("h3");l.appendChild(t),t.textContent="TRIUMPH";let n=document.createElement("div"),r=document.createElement("h4");r.textContent=e._triumph._name;let i=document.createElement("p");i.textContent=e._triumph._description,n.appendChild(r),n.appendChild(i),l.appendChild(n)}if(e._realmOfBattle&&e._realmOfBattle._name.length>0){let t=document.createElement("h3");if(l.appendChild(t),t.textContent="REALM OF BATTLE ("+e._realmOfBattle._name+")",e._realmOfBattle._spells.length>0){let t=document.createElement("h4");t.textContent="SPELLS",l.append(t),this.renderSpells(l,e._realmOfBattle._spells)}if(e._realmOfBattle._commandAbilities.size>0&&this.renderAbilityMap(l,"COMMAND ABILITIES",e._realmOfBattle._commandAbilities),e._realmOfBattle._rules.length>0){let t=document.createElement("h4");t.textContent="SPECIAL RULES",l.append(t);for(let t of e._realmOfBattle._rules){let e=document.createElement("div"),n=document.createElement("p");n.textContent=t._name+": "+t._description,e.appendChild(n),l.appendChild(e)}}}for(let t of e._rules){let e=document.createElement("h3");l.appendChild(e),e.textContent="RULES";let n=document.createElement("div"),r=document.createElement("h4");r.textContent=t[0];let i=document.createElement("p");i.textContent=t[1],n.appendChild(r),n.appendChild(i),l.appendChild(n)}if(e._battleTactics.size>0){let t=document.createElement("h3");t.textContent="BATTLE TACTICS",l.appendChild(t);const n=[{name:"NAME",width:"20%"},{name:"DESCRIPTION",width:"80%"}],r=this.createTable(n);r.classList.add("table","table-sm","aos_table","aos_font");let i=document.createElement("tbody");r.appendChild(i);for(let t of e._battleTactics){let e=document.createElement("tr"),n=document.createElement("td");n.textContent=t[0];let r=document.createElement("td");r.textContent=t[1],e.appendChild(n),e.appendChild(r),i.appendChild(e)}l.appendChild(r)}for(let t of e._battalions){let e=document.createElement("h3");l.appendChild(e),e.textContent=t._name.toUpperCase();for(let e of t._abilities){let t=document.createElement("div"),n=document.createElement("h4");n.textContent=e[0];let r=document.createElement("p");r.textContent=e[1],t.appendChild(n),t.appendChild(r),l.appendChild(t)}}if(!n)continue;n.appendChild(l);let u=document.createElement("hr");u.classList.add("aos_dark"),n.appendChild(u);for(let t of e._units){n.appendChild(this.renderUnitHtml(t));let e=document.createElement("hr");e.classList.add("aos_dark"),n.appendChild(e)}}}}createTable(e){const t=document.createElement("table"),n=document.createElement("thead");t.appendChild(n),n.classList.add("aos_light");const r=document.createElement("tr");return n.appendChild(r),e.forEach((e=>{let t=document.createElement("th");t.scope="col",t.textContent=e.name,t.style.width=e.width,r.appendChild(t)})),t}internalKeyword(e){return e.toUpperCase()!=e}renderUnitHtml(e){let t=document.createElement("div");t.classList.add("container-fluid","aos_unit");let n=document.createElement("div");n.classList.add("p-2","mb-2","aos_medium","text-center","text-uppercase","text-black"),n.innerHTML=`${e._name}`,t.append(n);let r=document.createElement("div");if(r.classList.add("row"),t.append(r),e.isNormalUnit()){let t=document.createElement("div");t.classList.add("col-3"),t.innerHTML=`
\n

${e._move}

\n

${e._wounds}

\n

${e._bravery}

\n

${e._save}

\n
`,r.append(t)}let i=document.createElement("div");i.classList.add("col"),r.appendChild(i);let o=document.createElement("table");o.classList.add("table","table-sm","aos_table","aos_font","text-center");let s=document.createElement("thead");o.appendChild(s),o.innerHTML='\n Missile Weapons\n Range\n Attacks\n To Hit\n To Wound\n Rend\n Damage\n ';let a=document.createElement("tbody");o.appendChild(a);let l=document.createElement("table");l.classList.add("table","table-sm","aos_table","aos_font","text-center"),s=document.createElement("thead"),l.appendChild(s),l.innerHTML='\n Melee Weapons\n Range\n Attacks\n To Hit\n To Wound\n Rend\n Damage\n ';let c=document.createElement("tbody");l.appendChild(c);let u=!1,d=!1;for(let t of e._weapons)if("Missile"===t._type){let e=document.createElement("tr");e.innerHTML=`${t._name}${t._range}${t._attacks}\n ${t._toHit}${t._toWound}${t._rend}${t._damage}`,a.appendChild(e),u=!0}else if("Melee"===t._type){let e=document.createElement("tr");e.innerHTML=`${t._name}${t._range}${t._attacks}\n ${t._toHit}${t._toWound}${t._rend}${t._damage}`,c.appendChild(e),d=!0}if(u&&i.appendChild(o),d&&i.appendChild(l),e._woundTracker&&e._woundTracker._labels.length>0){let t=[];const n=(1/e._woundTracker._labels.length*100).toString()+"%";for(let r of e._woundTracker._labels)t.push({name:r,width:n});const r=this.createTable(t);r.classList.add("table","table-sm","aos_table","aos_font","text-center"),i.appendChild(r);let o=document.createElement("tbody");r.appendChild(o);for(let t of e._woundTracker._table){let e=document.createElement("tr");for(let n of t){let t=document.createElement("td");t.textContent=n,e.appendChild(t)}o.appendChild(e)}}if(e._abilities.size>0&&this.renderAbilityMap(i,"ABILITIES",e._abilities),e._commandAbilities.size>0&&this.renderAbilityMap(i,"COMMAND ABILITIES",e._commandAbilities),e._commandTraits.size>0&&this.renderAbilityMap(i,"COMMAND TRAITS",e._commandTraits),e._magic.size>0&&this.renderAbilityMap(i,"MAGIC",e._magic),e._spells.length>0){let t=document.createElement("h4");t.textContent="SPELLS",i.appendChild(t),this.renderSpells(i,e._spells)}if(e._prayers.length>0){let t=document.createElement("h4");t.textContent="PRAYERS",i.appendChild(t);const n=[{name:"NAME",width:"20%"},{name:"ANSWER VALUE",width:"10%"},{name:"RANGE",width:"10%"},{name:"DESCRIPTION",width:"60%"}],r=this.createTable(n);r.classList.add("table","table-sm","aos_table","aos_font");let o=document.createElement("tbody");r.appendChild(o);for(let t of e._prayers){let e=document.createElement("tr"),n=document.createElement("td");n.textContent=t._name;let r=document.createElement("td");r.textContent=t._answerValue.toString();let i=document.createElement("td");i.textContent=t._range.toString();let s=document.createElement("td");s.textContent=t._description,e.appendChild(n),e.appendChild(r),e.appendChild(i),e.appendChild(s),o.appendChild(e)}i.appendChild(r)}e._artefacts.size>0&&this.renderAbilityMap(i,"ARTEFACTS",e._artefacts);let h="";for(let t of e._extraProfiles)if(1==t._value._fields.size){if(h!=t._value._typeName){let e=document.createElement("h4");i.appendChild(e),e.textContent=t._value._typeName.toUpperCase(),h=t._value._typeName}const e=t._value._fields.values();let n=document.createElement("p");n.classList.add("aos_font"),n.innerHTML=`${t._name}: ${e.next().value}`,i.appendChild(n)}else console.log("Table profiles not implemented. "+t._value._typeName);if(e._keywords.size>0){let n=document.createElement("div");n.classList.add("container-fluid");let r=document.createElement("div");r.classList.add("row"),n.appendChild(r);let i=document.createElement("div");i.classList.add("col-5","border","aos_dark","text-center"),i.innerHTML="KEYWORDS",r.appendChild(i);let o="",s="";for(let t of e._keywords)this.internalKeyword(t)||(s+=o,s+=t,o=", ");let a=document.createElement("div");a.classList.add("col","border","text-left","text-uppercase"),a.innerText=s,r.appendChild(a),t.appendChild(n)}return t}renderAbilityMap(e,t,n){let r=document.createElement("h4");r.textContent=t,e.appendChild(r);for(let e of n){let t=document.createElement("p");t.classList.add("aos_font"),t.innerHTML=`${e[0]}: ${e[1]}`,r.appendChild(t)}}renderSpells(e,t){const n=this.createTable([{name:"NAME",width:"25%"},{name:"CASTING VALUE",width:"15%"},{name:"RANGE",width:"10%"},{name:"DESCRIPTION",width:"50%"}]);n.classList.add("table","table-sm","aos_font");let r=document.createElement("tbody");n.appendChild(r);for(let e of t){let t=document.createElement("tr"),n=document.createElement("td");n.textContent=e._name;let i=document.createElement("td");i.textContent=e._castingValue.toString();let o=document.createElement("td");o.textContent=e._range.toString();let s=document.createElement("td");s.textContent=e._description,t.appendChild(n),t.appendChild(i),t.appendChild(o),t.appendChild(s),r.appendChild(t)}e.appendChild(n)}}},66:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RendererHH2=void 0;const r=n(980);class i{constructor(e){this._roster=null,this._roles=new Map,this._infantryLabelWidthsNormalized=[.2,.2,.05,.05,.05,.05,.05,.05,.05,.05,.05,.05,.1],this._vehicleLabelWidthsNormalized=[.2,.2,.05,.05,.05,.05,.05,.05,.2,.1],this._knightLabelWidthsNormalized=[.2,.2,.05,.05,.05,.05,.05,.05,.05,.05,.05,.05,.1],this._fortificationLabelWidthsNormalized=[.2,.2,.05,.05,.05,.05,.05,.2,.15],this._weaponLabelWidthNormalized=[.25,.05,.05,.05,.15,.35],this._psychicWeaponLabelWidthNormalized=[.25,.05,.05,.05,.15,.35],this._psychicPowerLabelWidthNormalized=[.25,.75],this._wargearLabelWidthNormalized=[.25,.75],this._roster=e,this._roles.set(r.HorusHeresy.UnitRole.HQ,document.getElementById("role_hq")),this._roles.set(r.HorusHeresy.UnitRole.TR,document.getElementById("role_tr")),this._roles.set(r.HorusHeresy.UnitRole.EL,document.getElementById("role_el")),this._roles.set(r.HorusHeresy.UnitRole.FA,document.getElementById("role_fa")),this._roles.set(r.HorusHeresy.UnitRole.HS,document.getElementById("role_hs")),this._roles.set(r.HorusHeresy.UnitRole.FL,document.getElementById("role_fl")),this._roles.set(r.HorusHeresy.UnitRole.DT,document.getElementById("role_dt")),this._roles.set(r.HorusHeresy.UnitRole.FT,document.getElementById("role_ft")),this._roles.set(r.HorusHeresy.UnitRole.LW,document.getElementById("role_lw")),this._roles.set(r.HorusHeresy.UnitRole.PR,document.getElementById("role_lw"))}render(e,t,n){if(null!=this._roster){if(e){this.renderOptionsDiv(e);const t=[`${this._roster._cost._points} pts`],n=`${this._roster._name} (${t.join(", ")})`;e.appendChild(document.createElement("h3")).appendChild(document.createTextNode(n));const r=e.appendChild(document.createElement("div"));r.classList.add("footer"),r.appendChild(document.createElement("div")).appendChild(document.createTextNode("PrettyScribe")),r.appendChild(document.createElement("div")).appendChild(document.createTextNode(n))}t&&this.renderRosterSummary(t),n&&this.renderRosterDetails(n),this.loadOptionsFromLocalStorage()}}renderRosterSummary(e){if(this._roster)for(const t of this._roster._forces){const n=document.createElement("div");t._faction?n.appendChild(document.createTextNode(`${t._catalog} ${t._name} (${t._faction})`)):n.appendChild(document.createTextNode(`${t._catalog} ${t._name}`)),e.appendChild(n);const i=document.createElement("table");i.classList.add("table","table-sm","table-striped");const o=document.createElement("thead");i.appendChild(o),o.classList.add("thead-light");const s=document.createElement("tr");o.appendChild(s),[{name:"NAME",w:"20%"},{name:"ROLE",w:"15%"},{name:"MODELS",w:"55%"},{name:"POINTS",w:"5%"}].forEach((e=>{let t=document.createElement("th");t.scope="col",t.appendChild(document.createTextNode(e.name)),t.style.width=e.w,s.appendChild(t)})),n.appendChild(i);let a=document.createElement("tbody");i.appendChild(a);for(let e of t._units){const t=document.createElement("tr");t.appendChild(document.createElement("td")).appendChild(document.createTextNode(e._name)),t.appendChild(document.createElement("td")).appendChild(document.createTextNode(r.HorusHeresy.UnitRoleToString[e._role]));const n=t.appendChild(document.createElement("td"));this.renderModelList(n,e),t.appendChild(document.createElement("td")).appendChild(document.createTextNode(e._points.toString())),a.appendChild(t)}}}renderOptionsDiv(e){const t=e.appendChild(document.createElement("div"));t.classList.add("wh40k_options_div","d-print-none"),t.id="wh40k_options_div";const n=t.appendChild(document.createElement("span"));n.classList.add("wh40k_options_toggle"),n.id="wh40k_options_toggle";const r="[−] Options:";n.appendChild(document.createTextNode(r)),n.addEventListener("click",(e=>{const t=document.getElementById("wh40k_options_div"),n=document.getElementById("wh40k_options_toggle");t&&n&&(t.classList.contains("hide_options")?(t.classList.remove("hide_options"),n.innerText=r,this.saveOptionToLocalStorage("option-toggle-hidden","false")):(t.classList.add("hide_options"),n.innerText="[+] Options",this.saveOptionToLocalStorage("option-toggle-hidden","true")))})),this.renderCheckboxOption(t,"showUpgradeCosts","Show upgrade costs",(e=>{const t=document.getElementsByClassName("wh40k_upgrade_cost");for(const n of t)e.target.checked?n.classList.remove("d-none"):n.classList.add("d-none")})),this.renderCheckboxOption(t,"collateDatasheets","Collate Detachment Datasheets",(e=>{const t=document.getElementById("collated_sheets"),n=document.getElementById("detachment_sheets");t&&n&&(e.target.checked?(t.classList.remove("d-none"),n.classList.add("d-none")):(t.classList.add("d-none"),n.classList.remove("d-none")))}));const i=t.appendChild(document.createElement("span"));i.classList.add("wh40k_options_print_subsection"),i.appendChild(document.createTextNode("Print:")),this.renderCheckboxOption(i,"printBigger","Larger Text",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("bigger"):n.classList.remove("bigger")})),this.renderCheckboxOption(i,"hideElements","Hide Elements",(e=>{const t=document.body;e.target.checked?(t.classList.add("hide_enabled"),t.addEventListener("click",l)):(t.classList.remove("hide_enabled"),t.removeEventListener("click",l))})),this.renderCheckboxOption(i,"datasheetPageBreaks","One Datasheet per Page",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("page_break"):n.classList.remove("page_break")}))}renderCheckboxOption(e,t,n,r){const i=e.appendChild(document.createElement("div"));i.classList.add("wh40k_option");const o=i.appendChild(document.createElement("input"));o.setAttribute("type","checkbox"),o.setAttribute("name",t),o.setAttribute("id",t),o.addEventListener("input",r),o.addEventListener("change",(e=>this.saveCheckboxToLocalStorage(t)));const s=i.appendChild(document.createElement("label"));s.setAttribute("for",t),s.appendChild(document.createTextNode(` ${n}`))}saveCheckboxToLocalStorage(e){const t=document.getElementById(e);t&&this.saveOptionToLocalStorage(`option-checkbox-${e}`,t.checked)}saveOptionToLocalStorage(e,t){try{window.localStorage[e]=t}catch(e){}}loadOptionsFromLocalStorage(){var e;try{for(let t=0;te._role!=t._role?e._role-t._role:e._name!=t._name?r.HorusHeresy.Compare(e._name,t._name):e._points-t._points)),this.renderDatasheets(o,s);let u=document.createElement("div");u.style.pageBreakBefore="always",this.printRules(t,u),this.printRules(n,u),e.appendChild(u)}renderDatasheets(e,t){let n=0;for(let r=0;r1?` (${n})`:""),""],[.1,.8,.1]));const h=c.appendChild(document.createElement("tr"));for(let e=0;e<20;e++){const e=h.appendChild(document.createElement("td"));e.colSpan=1,e.style.width="5%",e.style.padding="0"}let f=function(e,t){if(!t.notes())return null;const n=document.createElement("thead");return n.classList.add("info_row"),n.appendChild(o(["Unit notes",t._customNotes],[.1,.9],!1)),n}(0,t);if(f&&l.appendChild(f),t._modelStats.length>0){const e=function(e){let t=new Map;const n=e.filter((e=>e instanceof r.HorusHeresy.Vehicle));t.set("Vehicles",n);const i=e.filter((e=>e instanceof r.HorusHeresy.Knight));t.set("Knights",i);const o=e.filter((e=>e instanceof r.HorusHeresy.Fortification));t.set("Fortifications",o);const s=e.filter((e=>e instanceof r.HorusHeresy.Model));return t.set("Models",s),t}(t._modelStats),n=e.get("Models");if(null!=n&&n.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._infantryLabels,this._infantryLabelWidthsNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of n){let n=t;e.append(o([n._name,n._type,n._move.toString(),n._ws.toString(),n._bs.toString(),n._str.toString(),n._toughness.toString(),n._wounds.toString(),n._initiative.toString(),n._attacks.toString(),n._leadership.toString(),n._save],this._infantryLabelWidthsNormalized))}}const s=e.get("Vehicles");if(null!=s&&s.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._vehicleLabels,this._vehicleLabelWidthsNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of s){let n=t;e.append(o([n._name,n._type,n._move.toString(),n._bs.toString(),n._front.toString(),n._side.toString(),n._rear.toString(),n._hp.toString(),n._capacity.toString()],this._vehicleLabelWidthsNormalized))}}const a=e.get("Knights");if(null!=a&&a.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._knightLabels,this._knightLabelWidthsNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of a){let n=t;e.append(o([n._name,n._type,n._move.toString(),n._ws.toString(),n._bs.toString(),n._str.toString(),n._front.toString(),n._side.toString(),n._rear.toString(),n._hp.toString(),n._initiative.toString(),n._attacks.toString(),n._hp.toString()],this._knightLabelWidthsNormalized))}}const u=e.get("Fortifications");if(null!=u&&u.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._fortificationLabels,this._fortificationLabelWidthsNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of u){let n=t;e.append(o([n._name,n._type,n._bs.toString(),n._front.toString(),n._side.toString(),n._rear.toString(),n._hp.toString(),n._capacity.toString()],this._fortificationLabelWidthsNormalized))}}}f=s("Model notes",t._models),f&&l.appendChild(f);const p=t.weapons();if(p.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._weaponLabels,this._weaponLabelWidthNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of p){let n=t._type.split(","),r=n[0].trim(),i=document.createElement("div");n.forEach(((e,t)=>{let n=e.trim();if(t>1&&i.appendChild(document.createTextNode(", ")),0!=t){let e=document.createElement("a");e.classList.add("hh2-rule-link"),e.href="#"+n,e.text=n,i.appendChild(e)}})),e.append(o([t.name().toString(),t._range,t._str.toString(),t._ap,r,i],this._weaponLabelWidthNormalized))}}f=s("Weapon notes",p),f&&l.appendChild(f);const _=t.wargear();if(_.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._wargearLabels,this._wargearLabelWidthNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of _)e.append(o([t.name(),t._description],this._wargearLabelWidthNormalized))}f=s("Wargear Item notes",_),f&&l.appendChild(f);const m=t.psychicWeapons();if(m.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._psychicWeaponLabels,this._psychicWeaponLabelWidthNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of m){let n=t._type.split(","),r=n[0].trim(),i=document.createElement("div");n.forEach(((e,t)=>{let n=e.trim();if(t>1&&i.appendChild(document.createTextNode(", ")),0!=t){let e=document.createElement("a");e.classList.add("hh2-rule-link"),e.href="#"+n,e.text=n,i.appendChild(e)}})),e.append(o([t.name().toString(),t._range,t._str.toString(),t._ap,r,i],this._psychicWeaponLabelWidthNormalized))}}f=s("Psychic Weapon notes",m),f&&l.appendChild(f);const g=t.psychicPowers();if(g.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._psychicPowerLabels,this._psychicPowerLabelWidthNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of g)e.append(o([t.name(),t._description],this._psychicPowerLabelWidthNormalized))}f=s("Psychic Power notes",g),f&&l.appendChild(f);const v=t.warlordTraits();if(v.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(["Warlord Trait","Description"],[.25,.75],!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of v)e.append(o([t.name(),t._description],[.25,.75]))}f=s("Warlord Trait notes",v),f&&l.appendChild(f);const b=t.reactions();if(b.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(["Reaction","Description"],[.25,.75],!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of b)e.append(o([t.name(),t._description],[.25,.75]))}if(t._rules.size>0){const e=Array.from(t._rules.keys()).sort(r.HorusHeresy.Compare),n=t.weaponRules();let i=[];for(const t of e)n.includes(t)||i.push(t);this.renderUnitRules(l,"Rules",i)}c=l.appendChild(document.createElement("thead")),c.classList.add("info_row");const y=Array.from(t._keywords).sort(r.HorusHeresy.Compare).join(", ").toLocaleUpperCase();c.appendChild(o(["Keywords",y],[.1,.9],!1)),c=l.appendChild(document.createElement("thead")),c.classList.add("info_row");const w=document.createElement("div");this.renderModelList(w,t),c.appendChild(o(["MODELS",w],[.1,.9],!1))}renderUnitRules(e,t,n){const r=e.appendChild(document.createElement("thead"));r.classList.add("info_row");const i=document.createElement("div");n.forEach(((e,t)=>{let n=e.trim();if(t>1&&i.appendChild(document.createTextNode(", ")),0!=t){let e=document.createElement("a");e.classList.add("hh2-rule-link"),e.href="#"+n,e.text=n,i.appendChild(e)}})),r.appendChild(o([t,i],[.1,.9],!1))}renderModelList(e,t){for(const n of t._models){const t=e.appendChild(document.createElement("div"));t.appendChild(document.createTextNode((n._count>1?`${n._count}x `:"")+n._name));const r=n.getDedupedWeaponsAndUpgrades();if(0!==r.length){t.appendChild(document.createTextNode(" ("));for(const e of r)if(e!==r[0]&&t.appendChild(document.createTextNode(", ")),t.appendChild(document.createTextNode((e._count>1?`${e._count}x `:"")+e.selectionName())),e._cost.hasValues()){const n=t.appendChild(document.createElement("span"));n.classList.add("wh40k_upgrade_cost","d-none"),n.appendChild(document.createTextNode(` ${e._cost.toString()}`))}t.appendChild(document.createTextNode(")"))}}}printRules(e,t){if(0!==e.size&&t)for(let[n,r]of e.entries()){let e=document.createElement("div");e.classList.add("wh40k_rules");let i=document.createElement("h3");e.appendChild(i),i.appendChild(document.createTextNode(n));for(let t of r){let n=a(document.createElement("div")),r=document.createElement("b");r.id=t[0],r.appendChild(document.createTextNode(t[0]));let i=document.createElement("p");i.appendChild(document.createTextNode(t[1]||"")),n.appendChild(r),n.appendChild(i),e.appendChild(n)}t.appendChild(e)}}}function o(e,t,n=!1){const r=a(document.createElement("tr"));n&&r.classList.add("header_row");for(let i=0,o=0;ie._customNotes)))return null;const n=document.createElement("thead");n.classList.add("info_row");const r=document.createElement("div");for(const e of t){if(!e.notes())continue;const t=r.appendChild(document.createElement("div"));t.appendChild(document.createElement("b")).appendChild(document.createTextNode(`${e.name()}: `)),t.appendChild(document.createTextNode(e._customNotes))}return n.appendChild(o([e,r],[.1,.9],!1)),n}function a(e){return e.classList.add("hide_able"),e}function l(e){let t=e.target;t&&(t=t.closest(".hide_able")),t&&(t.classList.contains("hidden")?t.classList.remove("hidden"):t.classList.add("hidden"))}t.RendererHH2=i,i._infantryLabels=["Model","Type","M","WS","BS","S","T","W","I","A","Ld","Sv",""],i._vehicleLabels=["Model","Type","M","BS","Front","Side","Rear","HP","Capacity",""],i._knightLabels=["Model","Type","M","WS","BS","S","Front","Side","Rear","I","A","HP",""],i._fortificationLabels=["Model","Type","BS","Front","Side","Rear","HP","Capacity",""],i._weaponLabels=["Weapon","Range","Str","AP","Type","Rules"],i._psychicWeaponLabels=["Psychic Weapon","Range","Str","AP","Type","Rules"],i._psychicPowerLabels=["Psychic Power","Description"],i._wargearLabels=["Wargear Item","Description"]},96:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RendererKT21=void 0;const r=n(249),i=n(419),o=n(682),s=n(361),a=n(219);class l{constructor(e){this._descriptionStartX=140,this._descriptionWidth=600,this._roster=null,this._octagon=null,this._specialisms=new Map,this._currentX=0,this._currentY=0,this._maxWidth=0,this._maxHeight=0,this._unitLabelWidthsNormalized=[.25,.05,.05,.05,.05,.05,.05],this._weaponLabelWidthNormalized=[.25,.05,.05,.05,.2,.2],this._spellLabelWidthNormalized=[.25,.75],this._roster=e,this._octagon=document.getElementById("octagon"),this._specialisms.set(r.Specialism.NONE,document.getElementById("role_hq")),this._specialisms.set(r.Specialism.COMBAT,document.getElementById("role_hs")),this._specialisms.set(r.Specialism.STAUNCH,document.getElementById("role_fa")),this._specialisms.set(r.Specialism.MARKSMAN,document.getElementById("role_el")),this._specialisms.set(r.Specialism.SCOUT,document.getElementById("role_tr"))}render(e,t,n){if(null==this._roster)return void console.log("Roster is NULL");if(e){this.renderOptionsDiv(e);const s=`${this._roster.name()} (${this._roster._equipmentPoints} EP)`;e.appendChild(document.createElement("h3")).appendChild(document.createTextNode(s))}let r=new Map,i=new Map;for(let l of this._roster._forces){let c=r.get(l._catalog);c||(c=new Map,r.set(l._catalog,c));let u=i.get(l._catalog);u||(u=new Map,i.set(l._faction,u));const d=document.createElement("div");d&&(l._faction?d.innerHTML="

"+l._faction+" - "+l.name()+"

":d.innerHTML="

"+l.name()+"

"),t&&t.appendChild(d);const h=document.createElement("table");h.classList.add("table"),h.classList.add("table-sm"),h.classList.add("table-striped");const f=document.createElement("thead");h.appendChild(f),f.classList.add("thead-light");const p=document.createElement("tr");f.appendChild(p),[{name:"MODELS",w:"55%"},{name:"EP",w:"5%"}].forEach((e=>{let t=document.createElement("th");t.scope="col",t.innerHTML=e.name,t.style.width=e.w,p.appendChild(t)})),d.appendChild(h);let _=document.createElement("tbody");if(h.appendChild(_),l._leader){let g=document.createElement("tr"),v=document.createElement("td");v.innerHTML=l._leader.nameAndGear();let b=document.createElement("td");b.innerHTML=l._leader.costs().toString(),g.appendChild(v),g.appendChild(b),_.appendChild(g)}for(let y of l._operatives){let w=document.createElement("tr"),C=document.createElement("td");C.innerHTML=y.nameAndGear();let x=document.createElement("td");x.innerHTML=y.costs().toString(),w.appendChild(C),w.appendChild(x),_.appendChild(w)}if(n){const E=document.createElement("div");if(E){const N=document.createElement("p");N.appendChild(document.createTextNode(l.name())),l._faction&&N.appendChild(document.createTextNode(" ("+l._faction+")")),E.appendChild(N)}let S=document.createElement("h3");S.appendChild(E),n.appendChild(S);const k=n.appendChild(document.createElement("div"));k.id="kt_canvas",k.classList.add("d-none");const A=n.appendChild(document.createElement("div"));A.id="kt_html",l._leader&&(this.printOperative(l._leader,null,k),this.printOperativeHtml(l._leader,null,A));let T=null;for(let L of l._operatives)this.printOperative(L,T,k),this.printOperativeHtml(L,T,A),T=L}function m(e,t){for(const n of t)e.set(n[0],n[1])}if(l._rules.size>0&&m(c,l._rules),l._factionRules.size>0&&m(u,l._factionRules),l._leader&&l._leader._rules.size>0&&m(c,l._leader._rules),l._operatives&&l._operatives.length>0)for(const R of l._operatives)R._rules&&R._rules.size>0&&m(c,R._rules)}let o=document.createElement("div");o.style.pageBreakBefore="always",this.printRules(r,o),this.printRules(i,o),n&&n.appendChild(o),(0,a.loadOptionsFromLocalStorage)()}renderOptionsDiv(e){const t=e.appendChild(document.createElement("div"));t.classList.add("wh40k_options_div","d-print-none"),t.id="wh40k_options_div";const n=t.appendChild(document.createElement("span"));(0,a.renderOptionsToggle)(n),(0,a.renderCheckboxOption)(t,"ktWithCanvas","Use old formatting",(e=>{const t=document.getElementById("kt_html"),n=document.getElementById("kt_canvas"),r=document.getElementById("ktHtmlOptions");t&&n&&r&&(e.target.checked?(t.classList.add("d-none"),r.classList.add("d-none"),n.classList.remove("d-none")):(t.classList.remove("d-none"),r.classList.remove("d-none"),n.classList.add("d-none")))}));const r=t.appendChild(document.createElement("span"));r.classList.add("wh40k_options_print_subsection"),r.id="ktHtmlOptions",r.appendChild(document.createTextNode("Print:")),(0,a.renderCheckboxOption)(r,"printBigger","Larger Text",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("bigger"):n.classList.remove("bigger")})),(0,a.renderCheckboxOption)(r,"hideElements","Hide Elements",(e=>{const t=document.body;e.target.checked?(t.classList.add("hide_enabled"),t.addEventListener("click",s.toggleHidden)):(t.classList.remove("hide_enabled"),t.removeEventListener("click",s.toggleHidden))})),(0,a.renderCheckboxOption)(r,"datasheetPageBreaks","One Datasheet per Page",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("page_break"):n.classList.remove("page_break")}))}printOperativeHtml(e,t,n){if(e.equal(t))return;const i=n.appendChild(document.createElement("div"));i.classList.add("wh40k_unit_sheet");const a=document.createElement("table");a.classList.add("table","table-sm","table-striped"),i.appendChild(a);let c=a.appendChild(document.createElement("thead"));c.classList.add("table-dark","unit_header");const u=document.createElement("div");u.classList.add("unit_costs");const d=this._specialisms.get(e._role);u.appendChild(document.createElement("span")).appendChild((null==d?void 0:d.cloneNode())||document.createTextNode("-")),c.appendChild((0,o.createTableRow)([u,e.name()],[.1,.9]));const h=c.appendChild(document.createElement("tr"));for(let e=0;e<20;e++){const e=h.appendChild(document.createElement("td"));e.colSpan=1,e.style.width="5%",e.style.padding="0"}const f=[],p=new Map;p.has(e.name())||(p.set(e.name(),e),f.push(e));let _=(0,o.createNoteHead)("Operative notes",e);_&&a.appendChild(_),c=a.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild((0,o.createTableRow)(l._unitLabels,this._unitLabelWidthsNormalized,!0));let m=a.appendChild(document.createElement("tbody"));m.append(document.createElement("tr"));for(const e of f)m.append((0,o.createTableRow)([e.name(),e._move,e._apl,e._groupActivations,e._defence.toString(),e._saves,e._wounds.toString()],this._unitLabelWidthsNormalized));const g=[],v=new Map;for(const t of e._weapons)v.has(t.name())||(v.set(t.name(),t),g.push(t));if(g.length>0){c=a.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild((0,o.createTableRow)(l._weaponLabels,this._weaponLabelWidthNormalized,!0)),m=a.appendChild(document.createElement("tbody")),m.append(document.createElement("tr"));for(const e of g)m.append((0,o.createTableRow)([e.nameAndCosts(),e._attacks,e._skill,e._damage,e._rules,e._criticalEffects],this._weaponLabelWidthNormalized))}if(_=(0,o.createNotesHead)("Weapon notes",e._weapons),_&&a.appendChild(_),e._psychicPowers.length>0){c=a.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild((0,o.createTableRow)(l._spellLabels,this._spellLabelWidthNormalized,!0)),m=a.appendChild(document.createElement("tbody")),m.append(document.createElement("tr"));for(const t of e._psychicPowers)m.append((0,o.createTableRow)([t.name(),t._effect],this._spellLabelWidthNormalized))}if(_=(0,o.createNotesHead)("Spell notes",e._psychicPowers),_&&a.appendChild(_),e._abilities.size>0||e._rules.size>0){const t=a.appendChild(document.createElement("thead"));t.classList.add("info_row");const n=document.createElement("div");if(e._rules.size>0){const t=Array.from(e._rules.keys()).sort(r.Compare).join(", ");n.appendChild(document.createElement("div")).appendChild(document.createElement("b")).appendChild(document.createTextNode(t))}const i=Array.from(e._abilities.keys()).sort(r.Compare);for(const t of i){const r=(0,s.addHideAble)(n.appendChild(document.createElement("div")));r.appendChild(document.createElement("b")).appendChild(document.createTextNode(`${t.toUpperCase()}: `)),r.appendChild(document.createTextNode(e._abilities.get(t)||"??"))}t.appendChild((0,o.createTableRow)(["Abilities",n],[.1,.9],!1))}if(e._factions.size>0){c=a.appendChild(document.createElement("thead")),c.classList.add("info_row");const t=Array.from(e._factions).sort(r.Compare).join(", ").toLocaleUpperCase();c.appendChild((0,o.createTableRow)(["Factions",t],[.1,.9],!1))}if(e._keywords.size>0){c=a.appendChild(document.createElement("thead")),c.classList.add("info_row");const t=Array.from(e._keywords).sort(r.Compare).join(", ").toLocaleUpperCase();c.appendChild((0,o.createTableRow)(["Keywords",t],[.1,.9],!1))}c=a.appendChild(document.createElement("thead")),c.classList.add("info_row");const b=document.createElement("div");for(const t of[e])b.appendChild(document.createElement("div")).appendChild(document.createTextNode(t.nameAndGear()));c.appendChild((0,o.createTableRow)(["MODELS",b],[.1,.9],!1))}printOperative(e,t,n){let r=document.createElement("canvas");if(r.width=7.5*l._res,r.height=12*l._res,r.style.width=r.width.toString(),r.style.height=r.height.toString(),this._descriptionWidth=r.width-this._descriptionStartX-10,e.equal(t))return;const i=this.renderOperative(e,r,0,0);let o=document.createElement("canvas");o.width=i[0]+30,o.height=i[1]+30,o.style.width=o.width.toString(),o.style.height=o.height.toString();let s=o.getContext("2d");if(null==s||s.drawImage(r,15,15),n){let e=document.createElement("div");e.appendChild(o),n.appendChild(e)}}printRules(e,t){if(e.size>0)for(let[n,r]of e.entries()){if(0==r.size)continue;let e=document.createElement("div"),i=document.createElement("h3");e.appendChild(i),i.textContent=n;for(let t of r){let n=document.createElement("div"),r=document.createElement("b");r.textContent=t[0];let i=document.createElement("p");i.setAttribute("style","white-space: pre-wrap;"),i.appendChild(document.createTextNode(t[1]||"")),n.appendChild(r),n.appendChild(i),e.appendChild(n)}t&&t.appendChild(e)}}renderBorder(e,t,n,r,i){e.strokeStyle=l._blackColor,e.beginPath(),e.moveTo(t,n+l._bevelSize),e.lineTo(t,n+i-l._bevelSize),e.lineTo(t+l._bevelSize,n+i),e.lineTo(t+r-l._bevelSize,n+i),e.lineTo(t+r,n+i-l._bevelSize),e.lineTo(t+r,n+l._bevelSize),e.lineTo(t+r-l._bevelSize,n),e.lineTo(t+l._bevelSize,n),e.closePath(),e.stroke(),e.save(),e.fillStyle=l._fillColor,e.globalCompositeOperation="destination-over",e.beginPath(),e.moveTo(t,n+l._bevelSize),e.lineTo(t,n+i-l._bevelSize),e.lineTo(t+l._bevelSize,n+i),e.lineTo(t+r-l._bevelSize,n+i),e.lineTo(t+r,n+i-l._bevelSize),e.lineTo(t+r,n+l._bevelSize),e.lineTo(t+r-l._bevelSize,n),e.lineTo(t+l._bevelSize,n),e.closePath(),e.fill(),e.restore()}renderNotes(e,t,n){n._customNotes&&(this.renderLine(e),e.font=l._headerFont,(0,i.RenderText)(e,t.toLocaleUpperCase(),this._currentX+l._offset,this._currentY,100,16,i.Justification.Left),e.font=l._font,this._currentY+=2,this._currentY=(0,i.RenderParagraph)(e,n._customNotes,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth-l._offset,0),this._currentY+=2)}renderNotesArray(e,t,n){let r=0;for(const e of n)e._customNotes&&r++;if(0!=r){this.renderLine(e),e.font=l._headerFont,(0,i.RenderText)(e,t.toLocaleUpperCase(),this._currentX+l._offset,this._currentY,100,16,i.Justification.Left);for(const t of n){const n=t.name()+":",r=t._customNotes;if(!r)continue;e.font=l._headerFont,this._currentY+=2,(0,i.RenderTextFull)(e,n,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth,16,i.Justification.Left,i.VertAlign.Top);let o=e.measureText(n).width;e.font=l._font,this._currentY=(0,i.RenderParagraph)(e," "+r,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth-l._offset,o),this._currentY+=2}}}renderLine(e){e.lineWidth=2,e.strokeStyle=l._blackColor,e.beginPath(),e.moveTo(this._currentX,this._currentY),e.lineTo(this._currentX+this._maxWidth,this._currentY),e.stroke(),this._currentY+=1}renderTableHeader(e,t,n,r){let o=this._currentX;const s=this._maxWidth;e.fillStyle=l._grey1,e.fillRect(this._currentX,this._currentY,s,22),e.fillStyle=l._blackColor,e.font=l._titleFont;var a=50;if(t){e.font=l._headerFont;for(let s=0;s{a.push(e*this._maxWidth)}));for(let t of e._weapons)o.push(t);for(let t of e._psychicPowers)s.push(t);const c=[],u=new Map;u.has(e.name())||(u.set(e.name(),e),c.push(e)),this.renderNotes(i,"Operative notes",e),this.renderTableHeader(i,l._unitLabels,a,null);let d=0;for(var h of c)this.renderModel(i,h,a,d%2),d++;this.renderNotes(i,"Model notes",e);const f=[],p=new Map;for(const e of o)p.has(e.name())||(p.set(e.name(),e),f.push(e));if(f.length>0){const e=[];this._weaponLabelWidthNormalized.forEach((t=>{e.push(t*this._maxWidth)})),this.renderLine(i),this.renderTableHeader(i,l._weaponLabels,e,l._weaponJustifications),this.renderWeapons(i,f,e)}if(this.renderNotesArray(i,"Weapons notes",o),s.length>0){const e=[];this._spellLabelWidthNormalized.forEach((t=>{e.push(t*this._maxWidth)})),this.renderLine(i),this.renderTableHeader(i,l._spellLabels,e,null),this.renderSpells(i,s,e)}this.renderNotesArray(i,"Spell notes",s),(e._abilities.size>0||e._rules.size>0)&&(this.renderLine(i),this._currentY+=2,this.renderAbilities(i,e)),e._factions.size>0&&(this.renderLine(i),this._currentY+=2,this.renderFactions(i,e)),e._keywords.size>0&&(this.renderLine(i),this._currentY+=2,this.renderKeywords(i,e)),this.renderLine(i),this._currentY+=2,this.renderModelList(i,[e]),this._currentY+=2;const _=this._currentY-(r+l._margin),m=this._maxWidth;return this.renderBorder(i,this._currentX,r+l._margin,m,_),[this._maxWidth,this._currentY]}renderHeader(e,t){t.globalAlpha=1,t.fillStyle=l._blackColor;const n=this._currentX,r=this._currentX+this._maxWidth,o=this._currentY,s=o+36;t.beginPath(),t.moveTo(n,o+l._bevelSize),t.lineTo(n,s),t.lineTo(r,s),t.lineTo(r,o+l._bevelSize),t.lineTo(r-l._bevelSize,o),t.lineTo(n+l._bevelSize,o),t.closePath(),t.fill();let a=n+6;if(this._octagon){t.drawImage(this._octagon,a,o+2,32,32);const n=this._specialisms.get(e._role);n&&t.drawImage(n,a+4,o+2+4,24,24),t.fillStyle="white",t.font="18px serif",a+=34,t.drawImage(this._octagon,a,o+2,32,32),(0,i.RenderText)(t,e.costs().toString(),a,o+2,32,32,i.Justification.Center)}let c=0,u=28;const d=a+6;t.font=u+"px bold serif";const h=e.name().toLocaleUpperCase();let f=t.measureText(h);const p=this._maxWidth-d;for(;c<6&&f.width>p;)c+=1,u-=2,t.font=u+"px bold serif",f=t.measureText(h);t.fillStyle="white",t.textBaseline="top",(0,i.RenderText)(t,h,d,o,p,36,i.Justification.Center),this._currentY+=36}}t.RendererKT21=l,l._res=144,l._margin=0,l._bevelSize=15,l._blackColor="#1d272a",l._grey1="#b3bbb5",l._greyLight="#dde1df",l._fillColor="#f6f6f6",l._offset=20,l._titleFont="bold 14px sans-serif",l._headerFont="bold 14px sans-serif",l._font="14px sans-serif",l._boldFont="bold 14px sans-serif",l._unitLabels=["Operative","M","APL","GA","DF","Save","W"],l._weaponLabels=["WEAPONS","A","WS/BS","D","SR","!"],l._weaponJustifications=[i.Justification.Left,i.Justification.Center,i.Justification.Center,i.Justification.Center,i.Justification.Left,i.Justification.Left],l._spellLabels=["PSYCHIC POWER","DETAILS"]},385:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.renderMESBG=void 0;const n=/\s+/g,r=(e,t="")=>{const n=document.createElement(e);return n.className=t,n},i=(e,t="",n="")=>{const i=r(e,t);return i.appendChild(document.createTextNode(n)),i},o=()=>r("div","mesbg_noBreak mesbg_bumpDown"),s=()=>r("table","mesbg_profileTable mesbg_noBreak mesbg_bumpDown"),a=(e,t)=>{const n=s();return n.appendChild((e=>{const t=r("tr");return e.forEach((e=>{t.appendChild(i("th","",e))})),t})(e)),n.appendChild((e=>{const t=r("tr");return e.forEach((e=>{t.appendChild(i("td","",e))})),t})(t)),n},l=e=>[e.movement,e.fight,e.strength,e.defense,e.attack,e.wounds,e.courage].join("-"),c=e=>i("h2","mesbg_h2",e),u=e=>i("h2","mesbg_h2",e),d={showTracker:!0,showRules:!0,woundChart:!0},h=(e,t)=>{const n=document.createElement("input");n.setAttribute("type","checkbox"),n.setAttribute("name",e),n.setAttribute("id",e),d[e]&&n.setAttribute("checked","checked"),n.addEventListener("change",(e=>()=>{const t=!d[e];d[e]=t;const n=document.querySelector(`.mesbg_${e}`);null!==n&&(t?n.classList.remove("mesbg_hideMe"):n.classList.add("mesbg_hideMe"))})(e));const r=document.createElement("label");return r.setAttribute("for",e),r.appendChild(document.createTextNode(` ${t} `)),r.prepend(n),r},f=["Mv","F","S","D","A","W","C"];t.renderMESBG=(e,t,d,p)=>{if(null!==t){const n=r("div","mesbg_noPrint mesbg_toggleHolder");n.appendChild(h("showRules","show rules text")),n.appendChild(h("showTracker","include hero points tracker")),n.appendChild(h("woundChart","include To Wound Chart")),t.appendChild(n),t.appendChild((_=e.name,i("h1","mesbg_h1",_))),t.appendChild(i("h4","mesbg_rosterInfo",`${e.points} points | ${e.warriors} warriors `))}var _;if(null!==d){const t=r("div","mesbg_container");d.appendChild(t),e.forces.forEach((n=>{t.appendChild(i("h2","mesbg_forceName",n.name)),t.appendChild(i("h4","mesbg_h4 mesbg_bumpDown",`${n.breakpoints.modelCount} models\n | broken at ${n.breakpoints.half} casualties\n | quartered at ${n.breakpoints.quarter} models remaining\n `)),i("p","mesbg_rosterInfo",`${e.points} points | ${e.warriors} warriors `);const o=r("div","mesbg_flexGrid");t.appendChild(o),n.units.forEach((e=>{var t,n;const s=r("div","mesbg_card");s.appendChild(c(`${e.leader.name} - ${e.leader.points}pts ${(null===(t=e.leader.heroStuff)||void 0===t?void 0:t.isLeader)?" (Leader)":""}`)),s.appendChild((e=>i("p","mesbg_equipmentList",e))(`${e.leader.wargear.map((e=>e.name)).join(", ")}${e.leader.mount?", "+(null===(n=e.leader.mount)||void 0===n?void 0:n.name):""}`)),s.appendChild(r("hr","mesbg_bumpDown")),e.warband.forEach((e=>{var t;const n=u(`${e.count} ${e.model.name} - ${e.points}pts`);s.appendChild(n),s.appendChild(i("p","mesbg_equipmentList",`${e.model.wargear.map((e=>e.name)).join(", ")}${e.model.mount?", "+(null===(t=e.model.mount)||void 0===t?void 0:t.name):""}`))})),o.appendChild(s)}))}))}if(null!=p){const t=r("div","mesbg_container");p.appendChild(t),e.forces.forEach((e=>{const d=new Map;e.units.forEach((e=>{var h,p,_,m,g,v,b,y,w,C,x,E;const S=r("div","mesbg_card"),k=r("div","mesbg_twoColumn");S.appendChild(c(`${e.leader.name} - ${e.leader.points}pts`)),S.appendChild(i("h3","mesbg_h3 mesbg_bumpDown",e.leader.keywords.join(", ")));const A=r("div","mesbg_flex mesbg_noBreak");A.appendChild(a(f,[e.leader.profile.movement,e.leader.profile.fight,e.leader.profile.strength,e.leader.profile.defense,e.leader.profile.attack,e.leader.profile.wounds,e.leader.profile.courage])),A.appendChild(a(["M","W","F"],[null!==(p=null===(h=e.leader.heroStuff)||void 0===h?void 0:h.might)&&void 0!==p?p:"-",null!==(m=null===(_=e.leader.heroStuff)||void 0===_?void 0:_.will)&&void 0!==m?m:"-",null!==(v=null===(g=e.leader.heroStuff)||void 0===g?void 0:g.fate)&&void 0!==v?v:"-"])),k.appendChild(A);const T=o();if(T.appendChild(i("h3","mesbg_h3","Wargear")),0===e.leader.wargear.length?T.appendChild(i("i","","none")):T.appendChild(i("p","mesbg_cardWargear",e.leader.wargear.map((e=>e.name)).join(", "))),k.appendChild(T),null!==(y=null===(b=e.leader.heroStuff)||void 0===b?void 0:b.actions.length)&&void 0!==y&&y){const t=o();t.appendChild(i("h3","mesbg_h3","Heroic Actions"));const n=r("ul","mesbg_list mesbg_noBreak mesbg_bumpDown");null===(w=e.leader.heroStuff)||void 0===w||w.actions.forEach((e=>{n.appendChild(r("li")).appendChild(document.createTextNode(e))})),t.appendChild(n),k.appendChild(t)}if(k.appendChild(i("h3","mesbg_h3","Special Rules")),k.appendChild(i("p","mesbg_bumpDown",e.leader.rules.map((e=>e.name)).join(", "))),null!==(x=null===(C=e.leader.heroStuff)||void 0===C?void 0:C.magicalPowers.length)&&void 0!==x&&x){const t=s();t.className="mesbg_powerTable mesbg_noBreak";const n=r("tr");n.appendChild(r("th")).appendChild(i("h3","mesbg_h3","Magical Powers")),n.appendChild(r("th")).appendChild(i("span","","Range")),n.appendChild(r("th")).appendChild(i("span","","Casting")),t.appendChild(n),null===(E=e.leader.heroStuff)||void 0===E||E.magicalPowers.forEach((e=>{const n=r("tr");n.appendChild(r("td")).appendChild(i("span","",e.name)),n.appendChild(r("td")).appendChild(i("span","",e.range)),n.appendChild(r("td")).appendChild(i("span","",e.casting)),t.appendChild(n)})),k.appendChild(t)}if(void 0!==e.leader.mount){const t=o();t.appendChild(u(`Mount: ${e.leader.mount.name}`));const n=r("div","mesbg_flex mesbg_noBreak");n.appendChild(a(f,[e.leader.mount.profile.movement,e.leader.mount.profile.fight,e.leader.mount.profile.strength,e.leader.mount.profile.defense,e.leader.mount.profile.attack,e.leader.mount.profile.wounds,e.leader.mount.profile.courage])),t.append(n),k.append(t)}S.appendChild(k),t.appendChild(S),e.warband.forEach((e=>{const t=e.model,r=(e=>{var t,r;return e.name.trim().replace(n,"-")+(null!==(r=null===(t=e.mount)||void 0===t?void 0:t.name.trim().replace(n,"-"))&&void 0!==r?r:"")})(t);if(d.has(r)){const e=d.get(r),n=l(t.profile),i=null==e?void 0:e.statLines.get(n),o=t.wargear.map((e=>e.name.trim())).join(", ");void 0===i?null==e||e.statLines.set(n,{profile:t.profile,equipments:new Set([o])}):i.equipments.add(o)}else{const e={name:t.name,keywords:t.keywords.join(", "),mount:t.mount,ruleNames:t.rules.map((e=>e.name)).join(", "),statLines:new Map([[l(t.profile),{profile:t.profile,equipments:new Set([t.wargear.map((e=>e.name.trim())).join(", ")])}]])};d.set(r,e)}}))}));const h=r("div","mesbg_twoColumnGrid");d.forEach(((e,t)=>{const n=r("div","mesbg_card"),s=r("div","mesbg_twoColumn");if(n.appendChild(u(e.name)),n.appendChild(i("p","mesbg_cardWargear mesbg_bumpDown",e.keywords)),e.statLines.forEach(((e,t)=>{const n=r("div","mesbg_noBreak");n.appendChild(i("h3","mesbg_h3","Wargear")),e.equipments.forEach((e=>{n.appendChild(i("p","mesbg_cardWargear",e))})),n.appendChild(a(f,[e.profile.movement,e.profile.fight,e.profile.strength,e.profile.defense,e.profile.attack,e.profile.wounds,e.profile.courage])),s.appendChild(n)})),e.ruleNames.length>0&&(s.appendChild(i("h3","mesbg_h3","Special Rules")),s.appendChild(i("p","mesbg_bumpDown",e.ruleNames))),void 0!==e.mount){const t=o();t.appendChild(u(`Mount: ${e.mount.name}`));const n=r("div","mesbg_flex mesbg_noBreak");n.appendChild(a(f,[e.mount.profile.movement,e.mount.profile.fight,e.mount.profile.strength,e.mount.profile.defense,e.mount.profile.attack,e.mount.profile.wounds,e.mount.profile.courage])),t.append(n),s.append(t)}n.appendChild(s),h.appendChild(n)})),t.appendChild(h)}));const d=new Set,h=r("div","mesbg_pageBreak mesbg_showRules");h.appendChild(i("h1","mesbg_h1","Rules"));const _=r("div","mesbg_twoColumn");e.forces.forEach((n=>{n.armyBonus.forEach((e=>{_.appendChild(i("h3","mesbg_h3",`"${e.name}" (Army Bonus)`)),_.appendChild(i("p","mesbg_bumpDown",e.ruleText))})),n.units.forEach((e=>{e.leader.rules.forEach((e=>{!1===d.has(e.name)&&(_.appendChild(i("h3","mesbg_h3",e.name)),_.appendChild(i("p","mesbg_bumpDown",e.ruleText)),d.add(e.name))})),e.warband.forEach((e=>{e.model.rules.forEach((e=>{!1===d.has(e.name)&&(_.appendChild(i("h3","mesbg_h3",e.name)),_.appendChild(i("p","mesbg_bumpDown",e.ruleText)),d.add(e.name))}))}))})),h.appendChild(_),t.appendChild(h);const o=r("table","mesbg_pageBreak mesbg_trackerTable mesbg_showTracker");o.innerHTML="MWF",e.forces.forEach((e=>{e.units.forEach((e=>{const t=r("tr");t.innerHTML=`

${e.leader.name}

`,o.appendChild(t)}))})),t.appendChild(o);const s=r("table","mesbg_pageBreak mesbg_woundChart");s.innerHTML='\n \n \n  Defence\n \n \n \n \n Strength\n   1 2 3 4 5 6 7 8 9 10\n \n \n 1 4 5 5 6 6 6/4 6/5 6/6 - -\n \n \n 2 4 4 5 5 6 6 6/4 6/5 6/6 -\n \n \n 3 3 4 4 5 5 6 6 6/4 6/5 6/6\n \n \n 4 3 3 4 4 5 5 6 6 6/4 6/5\n \n \n 5 3 3 3 4 4 5 5 6 6 6/4 \n \n 6 3 3 3 3 4 4 5 5 6 6\n \n \n 7 3 3 3 3 3 4 4 5 5 6\n \n \n 8 3 3 3 3 3 3 4 4 5 5\n \n \n 9 3 3 3 3 3 3 3 4 4 5\n \n \n 10 3 3 3 3 3 3 3 3 4 4\n \n \n ',t.appendChild(s)}))}}},717:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RendererWarcry=void 0;const r=n(320);t.RendererWarcry=class{constructor(e){this._roster=null,this._roster=e}render(e,t,n){if(null!=this._roster){e&&(e.innerHTML="

"+this._roster._name+" ("+this._roster._points+" pts

");for(let e of this._roster._forces){const i=document.createElement("div");i&&(i.innerHTML="

"+e._catalog+" "+e._name+"

"),t&&t.appendChild(i);const o=document.createElement("table");o.classList.add("table"),o.classList.add("table-sm"),o.classList.add("table-striped");const s=document.createElement("thead");o.appendChild(s),s.classList.add("thead-light");const a=document.createElement("tr");s.appendChild(a),[{name:"NAME",w:"35%"},{name:"ROLE",w:"25%"},{name:"POINTS",w:"15%"}].forEach((e=>{let t=document.createElement("th");t.scope="col",t.innerHTML=e.name,t.style.width=e.w,a.appendChild(t)})),i.appendChild(o);let l=document.createElement("tbody");o.appendChild(l);for(let t of e._units){let e=document.createElement("tr"),n=document.createElement("td");n.innerHTML=t._name;let i=document.createElement("td");i.innerHTML=r.WarcryUnitRoleToString[t._role];let o=document.createElement("td");o.innerHTML=t._points.toString(),e.appendChild(n),e.appendChild(i),e.appendChild(o),l.appendChild(e)}let c=document.createElement("div");if(e._allegiance._rules.size>0){let t=document.createElement("h3");c.appendChild(t),t.textContent=e._allegiance._name+" Abilities";for(let t of e._allegiance._rules){let e=document.createElement("div"),n=document.createElement("h4");n.textContent=t[0];let r=document.createElement("p");r.textContent=t[1],e.appendChild(n),e.appendChild(r),c.appendChild(e)}}if(!n)return;n.appendChild(c);let u=document.createElement("div");for(let t of e._units){u.appendChild(this.renderUnitHtml(t));let e=document.createElement("hr");e.className="aos_dark",u.appendChild(e)}n.appendChild(u)}}}createCharacteristicCard(e,t){let n=document.createElement("div");return n.className="col",n.innerHTML=`\n
\n \n
\n

${t}

\n
\n
`,n}createWeapon(e,t){let n=document.createElement("p");n.className="card-title warcry_font",n.innerHTML=e._name,t.appendChild(n);let r=document.createElement("div");r.className="row",t.appendChild(r);let i=this.getWeaponTypeRunemark(e._name),o=document.createElement("div");o.className="col",o.innerHTML=`\n
\n \n
`,r.appendChild(o);let s=this.createCharacteristicCard("range",e._range);r.appendChild(s);let a=this.createCharacteristicCard("attacks",e._attacks);r.appendChild(a);let l=this.createCharacteristicCard("strength",e._strength);r.appendChild(l);let c=this.createCharacteristicCard("damage",e._damage);r.appendChild(c)}renderUnitHtml(e){let t=document.createElement("div");t.className="container-fluid warcry_unit border bg-light";let n=document.createElement("div");n.className="row align-items-center",t.append(n);let r=document.createElement("div");r.className="col-1",r.innerHTML=``,n.appendChild(r);let i=document.createElement("div");i.className="col",i.innerHTML=`${e._name}`,n.appendChild(i);let o=document.createElement("div");o.className="col-4",n.appendChild(o);for(let t of e._keywords){const e=this.getAbilityRunemark(t);if(""!=e){let t=new Image;t.className="border border-dark rounded-circle warcry_card",t.src=`./assets/warcry/runemarks/black/fighters-${e}.svg`,o.appendChild(t)}}let s=document.createElement("div");s.className="col-1",s.innerHTML=`
${e._points}
`,n.appendChild(s);let a=document.createElement("div");a.className="row align-items-center",t.append(a);let l=document.createElement("div");l.className="col-7",a.appendChild(l),2==e._weapons.length&&this.createWeapon(e._weapons[1],l);let c=document.createElement("div");c.className="col",a.appendChild(c);let u=document.createElement("div");u.className="row align-items-center",t.append(u);let d=document.createElement("div");d.className="col-7",u.appendChild(d),e._weapons.length>=1&&this.createWeapon(e._weapons[0],d);let h=document.createElement("div");h.className="col",u.appendChild(h);let f=document.createElement("div");f.className="row",h.appendChild(f);let p=document.createElement("div");p.className="col",f.appendChild(p);let _=this.createCharacteristicCard("move",e._move.toString());f.appendChild(_);let m=this.createCharacteristicCard("toughness",e._toughness.toString());f.appendChild(m);let g=this.createCharacteristicCard("wounds",e._wounds.toString());if(f.appendChild(g),e._damageTable.length>0){let n=document.createElement("div");n.className="row w-75 align-items-center",t.append(n);let r=document.createElement("div");r.className="p-2 mb-2 text-center text-uppercase text-black",r.innerHTML='Damage Table',n.appendChild(r);let i=[{name:"Damage Points Allocated",width:"50%"},{name:"Move",width:"25%"},{name:"Damage ",width:"25%"}],o=1;for(let t of e._damageTable[0]._table)i[o++].name=t[0];const s=this.createTable(i);n.appendChild(s);let a=document.createElement("tbody");s.appendChild(a);for(let t of e._damageTable){let e=document.createElement("tr"),n=document.createElement("td");n.innerHTML=t._name,e.appendChild(n);for(let n of t._table){let t=document.createElement("td");t.innerHTML=n[1],e.appendChild(t)}a.appendChild(e)}}return t}createTable(e){const t=document.createElement("table");t.className="table table-bordered table-sm text-center";const n=document.createElement("thead");t.appendChild(n),n.classList.add("warcry_light");const r=document.createElement("tr");return n.appendChild(r),e.forEach((e=>{let t=document.createElement("th");t.scope="col",t.innerHTML=e.name,t.style.width=e.width,r.appendChild(t)})),t}getAbilityRunemark(e){const t=e.toLowerCase();return t.includes("agile")?"agile":t.includes("ally")?"ally":t.includes("beast")?"beast":t.includes("berserker")?"berserker":t.includes("brute")?"brute":t.includes("bulwark")?"bulwark":t.includes("champion")?"champion":t.includes("destroyer")?"destroyer":t.includes("elite")?"elite":t.includes("ferocious")?"ferocious":t.includes("fly")?"fly":t.includes("frenzied")?"frenzied":t.includes("gargantuan")?"gargantuan":t.includes("icon")?"icon-bearer":t.includes("leader")?"leader":t.includes("minion")?"minion":t.includes("mount")?"mount":t.includes("mystic")?"mystic":t.includes("priest")?"priest":t.includes("scout")?"scout":t.includes("sentience")?"sentience":t.includes("terrifying")?"terrifying":t.includes("thrall")?"thrall":t.includes("trapper")?"trapper":t.includes("warrior")?"warrior":""}getWeaponTypeRunemark(e){const t=e.toLowerCase();return t.includes("axe")||t.includes("cleaver")?"axe":t.includes("claws")||t.includes("talon")||t.includes("grasping")||t.includes("pincher")?"claws":t.includes("club")?"club":t.includes("dagger")||t.includes("shank")?"dagger":t.includes("fangs")||t.includes("teeth")||t.includes("jaws")||t.includes("maw")?"fangs":t.includes("hammer")||t.includes("anvil")?"hammer":t.includes("mace")||t.includes("staff")||t.includes("stave")||t.includes("flail")?"mace":t.includes("scythe")?"scythe":t.includes("spear")||t.includes("glaive")||t.includes("halberd")||t.includes("lance")||t.includes("harpoon")||t.includes("polearm")?"spear":t.includes("sword")||t.includes("blade")||t.includes("sickles")?"sword":t.includes("arcane bolt")||t.includes("sorcerous bolt")?"blast":t.includes("bow")||t.includes("bolas")||t.includes("cannon")||t.includes("pistol")||t.includes("javelin")?"ranged-weapon":t.includes("whip")?"reach-weapon":"unarmed"}}},391:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Create30kRoster=t.Roster30k=t.Force30k=t.Unit30k=t.Fortification30k=t.Model30k=t.Flyer30k=t.Walker30k=t.Vehicle30k=t.UnitRoleToString30k=t.UnitRole30k=t.PsychicPower30k=t.Psyker30k=t.Weapon30k=void 0;class n{constructor(){this._name="",this._range="Melee",this._str="user",this._ap="",this._type="Melee"}}t.Weapon30k=n;class r{constructor(){this._name="",this._masteryLevel="",this._disciplines=""}}t.Psyker30k=r;class i{constructor(){this._name="",this._warpCharge=0,this._category="",this._range="",this._details=""}}var o;t.PsychicPower30k=i,function(e){e[e.NONE=0]="NONE",e[e.HQ=1]="HQ",e[e.TR=2]="TR",e[e.EL=3]="EL",e[e.FA=4]="FA",e[e.HS=5]="HS",e[e.FL=6]="FL",e[e.DT=7]="DT",e[e.FT=8]="FT",e[e.LW=9]="LW"}(o=t.UnitRole30k||(t.UnitRole30k={})),t.UnitRoleToString30k=["None","HQ","Troops","Elites","Fast Attack","Heavy Support","Flyer","Dedicated Transport","Fortification","Lord of War"];class s{constructor(){this._name="",this._bs="",this._front=4,this._side=4,this._rear=4,this._hp=1,this._type="",this._weapons=[]}}t.Vehicle30k=s;class a{constructor(){this._name="",this._ws="",this._bs="",this._str=4,this._front=4,this._side=4,this._rear=4,this._initiative=1,this._attacks="",this._hp=1,this._type="",this._weapons=[]}}t.Walker30k=a;class l{constructor(){this._name="",this._bs="",this._front=4,this._side=4,this._rear=4,this._hp=1,this._type="",this._role="",this._pursuit="",this._agility="",this._weapons=[]}}t.Flyer30k=l;class c{constructor(){this._name="",this._count=0,this._ws="",this._bs="",this._str=4,this._toughness=4,this._wounds=1,this._initiative=1,this._attacks="",this._leadership=7,this._save="",this._weapons=[],this._psyker=null,this._psychicPowers=[]}}t.Model30k=c,t.Fortification30k=class{constructor(){this._name="",this._composition="",this._type=""}};class u{constructor(){this._name="",this._role=o.NONE,this._factions=new Set,this._keywords=new Set,this._abilities=new Map,this._rules=new Map,this._models=[],this._walkers=[],this._vehicles=[],this._flyers=[],this._points=0}}t.Unit30k=u;class d{constructor(){this._catalog="",this._name="Unknown",this._faction="Unknown",this._rules=new Map,this._units=[]}}t.Force30k=d;class h{constructor(){this._commandPoints=0,this._points=0,this._name="",this._forces=[]}}function f(e,t){if(!t||!e)return!1;for(let n of t._forces)if(n._catalog===e._catalog)return!0;return!1}function p(e,t){let n=e.querySelectorAll("force>selections>selection");for(let e of n){let n=m(e);n&&n._role!=o.NONE&&t._units.push(n)}t._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?0:-1))}function _(e){switch(e){case"HQ":return o.HQ;case"Troops":return o.TR;case"Elites":return o.EL;case"Fast Attack":return o.FA;case"Heavy Support":return o.HS;case"Flyer":return o.FL;case"Dedicated Transport":return o.DT;case"Fortification":return o.FT;case"Lord of War":return o.LW}return o.NONE}function m(e){var t,d,h,f,p,m,g,v,b,y,w,C,x,E,S,k,A,T,N;let L=new u,R=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;R&&(L._name=R);let P=e.querySelectorAll(":scope categories>category");for(let e of P){let t=null===(d=e.getAttributeNode("name"))||void 0===d?void 0:d.nodeValue;if(t){const e="Faction: ",n=t.lastIndexOf(e);if(n>=0){const r=t.slice(n+e.length);L._factions.add(r)}else{const e=_(t.trim());e!=o.NONE?L._role=e:L._keywords.add(t)}}}let O=null,W=null,z=null,I=null,B=e.querySelectorAll(":scope profiles>profile");for(let e of B){let t=null===(h=e.getAttributeNode("name"))||void 0===h?void 0:h.nodeValue,n=null===(f=e.getAttributeNode("typeName"))||void 0===f?void 0:f.nodeValue;if(t&&n)if("Unit"===n){O=new c,O._name=t;let n=e.querySelectorAll("characteristics>characteristic");for(let t of n){let n=null===(p=t.getAttributeNode("name"))||void 0===p?void 0:p.nodeValue;if(n&&t.textContent)switch(n){case"WS":O._ws=t.textContent;break;case"BS":O._bs=t.textContent;break;case"S":O._str=+t.textContent;break;case"T":O._toughness=+t.textContent;break;case"W":O._wounds=+t.textContent;break;case"I":O._initiative=+t.textContent;break;case"A":O._attacks=t.textContent;break;case"LD":O._leadership=+t.textContent;break;case"Save":O._save=t.textContent}if(e.parentElement&&e.parentElement.parentElement){let t=null===(m=e.parentElement.parentElement.getAttributeNode("number"))||void 0===m?void 0:m.nodeValue;t&&(O._count=+t)}}L._models.push(O)}else if("Walker"===n){W=new a,W._name=t;let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let t=null===(g=e.getAttributeNode("name"))||void 0===g?void 0:g.nodeValue;if(t&&e.textContent)switch(t){case"WS":W._ws=e.textContent;break;case"BS":W._bs=e.textContent;break;case"S":W._str=+e.textContent;break;case"Front":W._front=+e.textContent;break;case"Side":W._side=+e.textContent;break;case"Rear":W._rear=+e.textContent;break;case"I":W._initiative=+e.textContent;break;case"A":W._attacks=e.textContent;break;case"HP":W._hp=+e.textContent;break;case"Type":W._type=e.textContent}}L._walkers.push(W)}else if("Vehicle"===n){z=new s,z._name=t;let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let t=null===(v=e.getAttributeNode("name"))||void 0===v?void 0:v.nodeValue;if(t&&e.textContent)switch(t){case"BS":z._bs=e.textContent;break;case"Front":z._front=+e.textContent;break;case"Side":z._side=+e.textContent;break;case"Rear":z._rear=+e.textContent;break;case"HP":z._hp=+e.textContent;break;case"Type":z._type=e.textContent}}L._vehicles.push(z)}else if("Flyer"===n){I=new l,I._name=t;let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let t=null===(b=e.getAttributeNode("name"))||void 0===b?void 0:b.nodeValue;if(t&&e.textContent)switch(t){case"BS":I._bs=e.textContent;break;case"Front":I._front=+e.textContent;break;case"Side":I._side=+e.textContent;break;case"Rear":I._rear=+e.textContent;break;case"HP":I._hp=+e.textContent;break;case"Combat Role":I._role=e.textContent;break;case"Pursuit":I._pursuit=e.textContent;break;case"Agility":I._agility=e.textContent}}L._flyers.push(I)}}for(let e of B){let t=null===(y=e.getAttributeNode("name"))||void 0===y?void 0:y.nodeValue,o=null===(w=e.getAttributeNode("typeName"))||void 0===w?void 0:w.nodeValue;if(t&&o){if("Wargear Item"===o){let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let n=null===(C=e.getAttributeNode("name"))||void 0===C?void 0:C.nodeValue;n&&e.textContent&&t&&"Description"===n&&L._abilities.set(t,e.textContent)}}else if("Weapon"===o){let r=new n;r._name=t;let i=e.querySelectorAll("characteristics>characteristic");for(let e of i){let t=null===(x=e.getAttributeNode("name"))||void 0===x?void 0:x.nodeValue;if(t&&e.textContent)switch(t){case"Range":r._range=e.textContent;break;case"Type":r._type=e.textContent;break;case"Strength":r._str=e.textContent;break;case"AP":r._ap=e.textContent}}O?O._weapons.push(r):W?W._weapons.push(r):z?z._weapons.push(r):I?I._weapons.push(r):console.log("Unexpected: Created a weapon without an active model. Unit: "+R)}else if("Transport"==o){let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let n=null===(E=e.getAttributeNode("name"))||void 0===E?void 0:E.nodeValue;n&&e.textContent&&t&&"Capacity"===n&&L._abilities.set(t,e.textContent)}}else if("Psychic Power"==o){let n=new i;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(S=e.getAttributeNode("name"))||void 0===S?void 0:S.nodeValue;if(t&&e.textContent)switch(t){case"Warp Charge":n._warpCharge=+e.textContent;break;case"Power Category":n._category=e.textContent;break;case"Range":n._range=e.textContent;break;case"Details":n._details=e.textContent}}O?O._psychicPowers.push(n):console.log("Unexpected: Created a psychic power without an active model. Unit: "+R)}else if("Psyker"==o){let n=new r;n._name=t;let i=e.querySelectorAll("characteristics>characteristic");for(let e of i){let t=null===(k=e.getAttributeNode("name"))||void 0===k?void 0:k.nodeValue;if(t&&e.textContent)switch(t){case"Mastery Level":n._masteryLevel=e.textContent;break;case"Disciplines":n._disciplines=e.textContent}}O?O._psyker=n:console.log("Unexpected: Created a psyker without an active model. Unit: "+R)}}else"Unit"===o||"Walker"===o||"Vehicle"===o||console.log("Unknown property type: "+o)}let M=e.querySelectorAll(":scope costs>cost");for(let e of M)if(e.hasAttribute("name")&&e.hasAttribute("value")){let t=null===(A=e.getAttributeNode("name"))||void 0===A?void 0:A.nodeValue,n=null===(T=e.getAttributeNode("value"))||void 0===T?void 0:T.nodeValue;n&&"pts"==t&&(L._points+=+n)}let U=e.querySelectorAll(":scope rules > rule");for(let e of U)if(e.hasAttribute("name")){let t=null===(N=e.getAttributeNode("name"))||void 0===N?void 0:N.nodeValue,n=e.querySelector("description");t&&n&&n.textContent&&L._rules.set(t,n.textContent)}return L}t.Roster30k=h,t.Create30kRoster=function(e){var t;if(e){let n=e.querySelector("roster");if(n){const r=new h,i=null===(t=n.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;return r._name=i||"30k Army Roster",function(e,t){var n,r;let i=e.querySelectorAll("roster>costs>cost");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("value")){let i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("value"))||void 0===r?void 0:r.nodeValue;o&&("pts"===i?t._points=+o:"CP"===i&&(t._commandPoints=+o))}}(e,r),function(e,t){var n,r,i;let o=e.querySelectorAll("roster>forces>force");for(let e of o)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let o=new d,s=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,a=null===(r=e.getAttributeNode("catalogueName"))||void 0===r?void 0:r.nodeValue;if(s&&(o._name=s),a&&(o._catalog=a),!f(o,t)){const t=e.querySelectorAll("force>rules>rule");for(let e of t)if(e.hasAttribute("name")){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;const n=e.querySelector("rule>description");t&&n&&o._rules.set(t,n.textContent)}}p(e,o),t._forces.push(o)}}(e,r),r}}return null}},288:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Compare=t.CompareWeapon=t.Create40kRoster=t.Costs=t.Roster40k=t.Force=t.Unit=t.Model=t.UnitRoleToString=t.UnitRole=t.PsychicPower=t.Psyker=t.Explosion=t.WoundTracker=t.Weapon=t.Upgrade=t.BaseNotes=void 0;const s=o(n(486));class a{constructor(){this._name="",this._customName="",this._customNotes=""}name(){return this._customName?this._customName:this._name}notes(){return this._customNotes}equal(e){return null!=e&&this._name===e._name}}t.BaseNotes=a;class l extends a{constructor(){super(...arguments),this._cost=new b,this._count=1}selectionName(){return this.name()}toString(){let e=this.selectionName();return this._count>1&&(e=`${this._count}x ${e}`),this._cost.hasValues()&&(e+=` ${this._cost.toString()}`),e}}t.Upgrade=l;class c extends l{constructor(){super(...arguments),this._selectionName="",this._range="Melee",this._type="Melee",this._str="user",this._ap="",this._damage="",this._abilities=""}selectionName(){return this._selectionName||this.name()}}t.Weapon=c;class u extends a{constructor(){super(...arguments),this._name="",this._table=new Map}}t.WoundTracker=u;class d extends a{constructor(){super(...arguments),this._name="",this._diceRoll="",this._distance="",this._mortalWounds=""}}t.Explosion=d;class h extends a{constructor(){super(...arguments),this._cast="",this._deny="",this._powers="",this._other=""}}t.Psyker=h;class f extends a{constructor(){super(...arguments),this._name="",this._manifest=0,this._range="",this._details=""}}var p;t.PsychicPower=f,function(e){e[e.NONE=0]="NONE",e[e.SCD=1]="SCD",e[e.HQ=2]="HQ",e[e.TR=3]="TR",e[e.EL=4]="EL",e[e.FA=5]="FA",e[e.HS=6]="HS",e[e.FL=7]="FL",e[e.DT=8]="DT",e[e.FT=9]="FT",e[e.LW=10]="LW",e[e.AGENTS=11]="AGENTS",e[e.NF=12]="NF",e[e.COMMANDER=13]="COMMANDER",e[e.LEADER=14]="LEADER",e[e.SPECIALIST=15]="SPECIALIST",e[e.NON_SPECIALIST=16]="NON_SPECIALIST"}(p=t.UnitRole||(t.UnitRole={})),t.UnitRoleToString=["None","Supreme Command Detachment","HQ","Troops","Elites","Fast Attack","Heavy Support","Flyer","Dedicated Transport","Fortification","Lord of War","Agent of the Imperium","No Force Org Slot","Commander","Leader","Specialist","Non-specialist"];class _ extends a{constructor(){super(...arguments),this._count=0,this._move='0"',this._ws="",this._bs="",this._str=4,this._toughness=4,this._wounds=1,this._attacks="",this._leadership=7,this._save="",this._weapons=[],this._upgrades=[],this._psyker=null,this._psychicPowers=[],this._explosions=[]}equal(e){if(null==e)return!1;if(this._name===e._name&&this._count===e._count&&this._weapons.length===e._weapons.length&&this._upgrades.length===e._upgrades.length){for(let t=0;t0||this._upgrades.length>0)&&(e+=` (${this.getDedupedWeaponsAndUpgrades().map((e=>e.toString())).join(", ")})`),e}getDedupedWeaponsAndUpgrades(){const e=[];for(const t of[...this._weapons,...this._upgrades])e.some((e=>t.selectionName()===e.selectionName()))||e.push(t);return e}normalize(){this._weapons.sort(q),this._upgrades.sort(D),this.normalizeUpgrades(this._weapons),this.normalizeUpgrades(this._upgrades)}normalizeUpgrades(e){for(let t=0;t(e._count>1?`${e._count}x `:"")+e.nameAndGear())),this._weapons=this._models.map((e=>e._weapons)).reduce(((e,t)=>e.concat(t)),[]).sort(q).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())})),this._spells.push(...this._models.map((e=>e._psychicPowers)).reduce(((e,t)=>e.concat(t)),[])),this._psykers.push(...this._models.map((e=>e._psyker)).filter((e=>e))),this._explosions.push(...this._models.map((e=>e._explosions)).reduce(((e,t)=>e.concat(t)),[]))}}t.Unit=m;class g extends a{constructor(){super(...arguments),this._catalog="",this._faction="Unknown",this._factionRules=new Map,this._configurations=[],this._rules=new Map,this._units=[]}}t.Force=g;class v extends a{constructor(){super(...arguments),this._cost=new b,this._forces=[]}}t.Roster40k=v;class b{constructor(){this._powerLevel=0,this._commandPoints=0,this._points=0}hasValues(){return 0!==this._powerLevel||0!==this._commandPoints||0!==this._points}toString(){const e=[];return 0!==this._points&&e.push(`${this._points} pts`),0!==this._powerLevel&&e.push(`${this._powerLevel} PL`),0!==this._commandPoints&&e.push(`${this._commandPoints} CP`),`[${e.join(" / ")}]`}add(e){this._powerLevel+=e._powerLevel,this._commandPoints+=e._commandPoints,this._points+=e._points;for(const t in e._freeformValues)this.addFreeformValue(t,e._freeformValues[t])}addFreeformValue(e,t){this._freeformValues||(this._freeformValues={});const n=this._freeformValues[e]||0;this._freeformValues[e]=n+t}}function y(e,t,n){var r;let i=e.querySelectorAll("force>selections>selection");for(let e of i){let i=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue;if(i)if(i.includes("Detachment Command Cost"));else if("Battle Size"===i||"Gametype"===i)w(e,t);else if(e.querySelector('profile[typeName="Unit"]')){const r=P(e,n);t._units.push(r);for(const e of r._rules.entries())t._rules.set(e[0],e[1])}else if("upgrade"===e.getAttribute("type")){x(e,t._rules),w(e,t);const n=e.querySelectorAll("selections>selection");for(let e of n){const n=e.getAttribute("name");n&&"upgrade"===e.getAttribute("type")&&("Unknown"===t._faction&&(t._faction=n),x(e,t._factionRules))}}else console.log("** UNEXPECTED SELECTION **",i,e)}for(const e of t._factionRules.keys())t._rules.delete(e);t._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?e._name>t._name?1:e._name==t._name?0:-1:-1))}function w(e,t){var n;const r=e.getAttribute("name");if(!r)return;const i=null===(n=e.querySelector("category"))||void 0===n?void 0:n.getAttribute("name"),o=e.querySelectorAll("selections>selection"),s=[];let a=L(e);for(const e of o)s.push(e.getAttribute("name")),a.add(L(e));let l=i&&"Configuration"!==i?`${i} - ${r}`:r;s.length>0&&(l+=`: ${s.join(", ")}`),a.hasValues()&&(l+=` ${a.toString()}`),t._configurations.push(l)}function C(e,t){if(!t||!e)return!1;for(let n of t._forces)if(n._catalog===e._catalog)return!0;return!1}function x(e,t){const n=e.querySelectorAll("profiles>profile");for(const e of n){const n=e.getAttribute("name");if(!n)continue;const r=e.getAttribute("typeName");"Abilities"!==r&&"Dynastic Code"!==r&&"Household Tradition"!==r||W(e,n,0,t)}const r=e.querySelectorAll("rules>rule");for(const e of r)E(e,t)}function E(e,t){const n=e.getAttribute("name"),r=e.querySelector("description");n&&(null==r?void 0:r.textContent)&&t.set(n,r.textContent)}function S(e){switch(e){case"HQ":return p.HQ;case"Troops":return p.TR;case"Elites":return p.EL;case"Fast Attack":return p.FA;case"Heavy Support":return p.HS;case"Flyer":return p.FL;case"Dedicated Transport":return p.DT;case"Fortification":return p.FT;case"Lord of War":return p.LW;case"Agent of the Imperium":return p.AGENTS;case"No Force Org Slot":return p.NF;case"Primarch | Daemon Primarch | Supreme Commander":return p.SCD}return p.NONE}function k(e){switch(e){case"Commander":return p.COMMANDER;case"Leader":return p.LEADER;case"Specialist":return p.SPECIALIST;case"Non-specialist":return p.NON_SPECIALIST}return p.NONE}function A(e,t){var n,r;t._name=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;let i=e;"profile"===e.tagName&&e.parentElement&&e.parentElement.parentElement&&(i=e.parentElement.parentElement),t._customName=null===(r=i.getAttributeNode("customName"))||void 0===r?void 0:r.nodeValue;let o=i.firstElementChild;return o&&"customNotes"===o.tagName&&(t._customNotes=o.textContent),t._name}function T(e){const t=[];for(const n of e.children)if("selections"===n.tagName)for(const e of n.children)"selection"===e.tagName&&t.push(e);return t}function N(e,t){for(const n of e.children)if("profiles"===n.tagName)for(const e of n.children)if("profile"===e.tagName&&e.getAttribute("typeName")===t)return!0;return!1}function L(e){const t=new b;for(const n of e.children)if("costs"===n.tagName)for(const e of n.children)t.add(R(e));return t}function R(e){const t=new b,n=e.getAttribute("name"),r=e.getAttribute("value");return n&&r&&(" PL"===n?t._powerLevel+=+r:"pts"===n?t._points+=+r:"CP"===n?t._commandPoints+=+r:t.addFreeformValue(n,+r)),t}function P(e,t){var n;let r=new m;A(e,r);let i=e.querySelectorAll("categories>category");for(let e of i){const i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;if(i){const e="Faction: ",n=i.lastIndexOf(e);if(n>=0){const t=i.slice(n+e.length);r._factions.add(t)}else{const e=i.trim();let n=S(e);n!=p.NONE?r._role=n:t?r._keywords.add(i):(n=k(e),n!=p.NONE?r._role=n:r._keywords.add(i))}}}const o=[],s=Array.from(e.querySelectorAll('profile[typeName="Unit"],profile[typeName="Model"]'));!function(e,t,n){for(const n of e){const e=n.getAttribute("name"),r=n.getAttribute("typeName");if(!e||!r)return;const i=new _;i._name=e,t._modelStats.push(i),A(n,i);const o=n.querySelectorAll("characteristics>characteristic");for(const e of o){const t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"M":i._move=e.textContent;break;case"WS":i._ws=e.textContent;break;case"BS":i._bs=e.textContent;break;case"S":i._str=+e.textContent;break;case"T":i._toughness=+e.textContent;break;case"W":i._wounds=+e.textContent;break;case"A":i._attacks=e.textContent;break;case"Ld":i._leadership=+e.textContent;break;case"Save":i._save=e.textContent}}}}(s,r),o.push(...s);const a=[];if("model"===e.getAttribute("type"))a.push(e);else{const t=T(e);for(const e of t)("model"===e.getAttribute("type")||N(e,"Unit"))&&a.push(e);0===a.length&&a.push(...Array.from(e.querySelectorAll('selection[type="model"]'))),0===a.length&&N(e,"Unit")&&a.push(e)}for(const e of a){const t=Array.from(e.querySelectorAll("profiles>profile")),n=t.filter((e=>!o.includes(e)));o.push(...n);const i=new _;i._name=e.getAttribute("name")||"Unknown Model",i._count=Number(e.getAttribute("number")||1),r._models.push(i),O(t,i,r);for(const t of e.querySelectorAll('selections>selection[type="upgrade"]')){if(t.querySelector('selections>selection[type="upgrade"]')&&!N(t,"Abilities"))continue;let e=t.getAttribute("name");if(e){const n=new l;n._name=e,n._cost=L(t),n._count=Number(t.getAttribute("number")),i._upgrades.push(n)}}}let c=Array.from(e.querySelectorAll("profiles>profile")).filter((e=>!o.includes(e)));if(o.push(...c),c.length>0){const t=new _;if(t._name="Unit Upgrades",O(c,t,r),t._weapons.length>0&&r._models.length>0){for(const e of r._models)e._weapons.push(...t._weapons);t._weapons.length=0}t._psychicPowers.length>0&&(r._spells.push(...t._psychicPowers),t._psychicPowers.length=0),t._psyker&&(r._psykers.push(t._psyker),t._psyker=null),t._explosions.length>0&&(r._explosions.push(...t._explosions),t._explosions.length=0);for(const n of T(e)){if("upgrade"!==n.getAttribute("type"))continue;if(a.includes(n))continue;if(n.querySelector('profiles>profile[typeName="Weapon"]'))continue;let e=n.getAttribute("name");if(!e)continue;const r=new l;r._name=e,r._cost=L(n),r._count=Number(n.getAttribute("number")),t._upgrades.push(r)}(t._weapons.length>0||t._upgrades.length>0)&&r._models.push(t)}let u=e.querySelectorAll("costs>cost");for(let e of u)r._cost.add(R(e));let d=e.querySelectorAll("rules > rule");for(let e of d)E(e,r._rules);return r.normalize(),r}function O(e,t,n){for(const r of e){const e=r.getAttribute("name"),i=r.getAttribute("typeName");if(e&&i)if("Unit"===i||"Model"===i||"model"===r.getAttribute("type"));else if("Weapon"===i){const e=z(r);t._weapons.push(e)}else if(i.includes("Wound Track")||i.includes("Stat Damage")||i.includes(" Wounds")){const e=I(r);n._woundTracker.push(e)}else if("Psychic Power"==i){const e=B(r);t._psychicPowers.push(e)}else if(i.includes("Explosion")){const e=M(r);t._explosions.push(e)}else"Psyker"==i?t._psyker=U(r):(n._abilities[i]||(n._abilities[i]=new Map),W(r,e,0,n._abilities[i]))}}function W(e,t,n,r){const i=e.querySelectorAll("characteristics>characteristic");for(const e of i){if(!e.textContent)continue;const n=e.getAttribute("name");n&&i.length>1?r.set([t,n.toString()].join(" - "),e.textContent):r.set(t,e.textContent)}}function z(e){var t;const n=new c;A(e,n),n._count=function(e){var t;if(e.parentElement&&e.parentElement.parentElement){const n=null===(t=e.parentElement.parentElement.getAttributeNode("number"))||void 0===t?void 0:t.nodeValue;if(n)return+n}return 0}(e);let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"Range":n._range=e.textContent;break;case"Type":n._type=e.textContent;break;case"S":n._str=e.textContent;break;case"AP":n._ap=e.textContent;break;case"D":n._damage=e.textContent;break;case"Abilities":n._abilities=e.textContent}}const i=null===(t=e.parentElement)||void 0===t?void 0:t.parentElement,o=null==i?void 0:i.getAttribute("name");return"upgrade"===(null==i?void 0:i.getAttribute("type"))&&o&&(n._selectionName=o,n._cost=L(i)),n}function I(e){let t=new u;A(e,t);let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){const n=e.getAttribute("name");n&&(e.textContent?t._table.set(n,e.textContent):t._table.set(n,"-"))}return t}function B(e){const t=new f;A(e,t);const n=e.querySelectorAll("characteristics>characteristic");for(let e of n){const n=e.getAttribute("name");if(n&&e.textContent)switch(n){case"Range":t._range=e.textContent;break;case"Warp Charge":t._manifest=+e.textContent;break;case"Details":t._details=e.textContent}}return t}function M(e){const t=new d;A(e,t);const n=e.querySelectorAll("characteristics>characteristic");for(const e of n){const n=e.getAttribute("name");if(n&&e.textContent)switch(n){case"Dice Roll":t._diceRoll=e.textContent;break;case"Distance":t._distance=e.textContent;break;case"Mortal Wounds":t._mortalWounds=e.textContent}}return t}function U(e){const t=new h;A(e,t);const n=e.querySelectorAll("characteristics>characteristic");for(const e of n){const n=e.getAttribute("name");if(n&&e.textContent)switch(n){case"Cast":t._cast=e.textContent;break;case"Deny":t._deny=e.textContent;break;case"Powers Known":t._powers=e.textContent;break;case"Other":t._other=e.textContent}}return t}function D(e,t){return H(e._name,t._name)}function F(e,t){return e._name===t._name?H(e.nameAndGear(),t.nameAndGear()):"Unit Upgrades"===e._name?1:"Unit Upgrades"===t._name?-1:H(e._name,t._name)}function q(e,t){return(e._type.startsWith("Grenade")?2:e._type.startsWith("Melee")?1:0)-(t._type.startsWith("Grenade")?2:t._type.startsWith("Melee")?1:0)||e.name().localeCompare(t.name())}function H(e,t){return e>t?1:e==t?0:-1}t.Costs=b,t.Create40kRoster=function(e,t=!0){var n;if(e){let r=e.querySelector("roster");if(r){const i=new v,o=null===(n=r.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;i._name=o||"40k Army Roster";let s=r.querySelector("customNotes");return s&&(i._customNotes=s.textContent),function(e,t){let n=e.querySelectorAll("roster>costs>cost");for(let e of n)t._cost.add(R(e))}(e,i),function(e,t,n){var r,i;let o=e.querySelectorAll("roster>forces>force");for(let e of o)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let o=new g,s=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue,a=null===(i=e.getAttributeNode("catalogueName"))||void 0===i?void 0:i.nodeValue;if(s&&(o._name=s),a&&(o._catalog=a),!C(o,t)){const t=e.querySelectorAll("force>rules>rule");for(let e of t)E(e,o._rules)}y(e,o,n),t._forces.push(o)}}(e,i,t),i}}return null},t.CompareWeapon=q,t.Compare=H},208:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Wh40k=void 0;const s=o(n(486));!function(e){class t{constructor(){this._name="",this._customName="",this._customNotes=""}name(){return this._customName?this._customName:this._name}notes(){return this._customNotes}equal(e){return null!=e&&this._name===e._name}hash(){return N(this.name())}}e.BaseNotes=t;class n extends t{constructor(){super(...arguments),this._cost=new d,this._count=1}selectionName(){return this.name()}toString(){let e=this.selectionName();return this._count>1&&(e=`${this._count}x ${e}`),this._cost.hasValues()&&(e+=` ${this._cost.toString()}`),e}}let r;function i(e){switch(e){case"Epic Hero":return r.EpicHero;case"Character":return r.Character;case"Battleline":return r.Battleline;case"Infantry":return r.Infantry;case"Swarm":return r.Swarm;case"Mounted":return r.Mounted;case"Beast":return r.Beast;case"Monster":return r.Monster;case"Vehicle":return r.Vehicle;case"Dedicated Transport":return r.Transport;case"Fortification":return r.Fortification;case"Allied Units":return r.Allied;default:return r.NONE}}e.Upgrade=n,e.Weapon=class extends n{constructor(){super(...arguments),this._selectionName="",this._range="Melee",this._attacks="1",this._skill="",this._str="user",this._ap="",this._damage="",this._abilities=""}selectionName(){return this._selectionName||this.name()}},function(e){e[e.NONE=0]="NONE",e[e.EpicHero=1]="EpicHero",e[e.Character=2]="Character",e[e.Battleline=3]="Battleline",e[e.Infantry=4]="Infantry",e[e.Swarm=5]="Swarm",e[e.Mounted=6]="Mounted",e[e.Beast=7]="Beast",e[e.Monster=8]="Monster",e[e.Vehicle=9]="Vehicle",e[e.Transport=10]="Transport",e[e.Fortification=11]="Fortification",e[e.Allied=12]="Allied"}(r=e.UnitRole||(e.UnitRole={})),e.UnitRoleToString={[r.NONE]:"None",[r.EpicHero]:"Epic Hero",[r.Character]:"Character",[r.Battleline]:"Battleline",[r.Infantry]:"Infantry",[r.Swarm]:"Swarm",[r.Mounted]:"Mounted",[r.Beast]:"Beast",[r.Monster]:"Monster",[r.Vehicle]:"Vehicle",[r.Transport]:"Dedicated Transport",[r.Fortification]:"Fortification",[r.Allied]:"Allied Units"};class o extends t{constructor(){super(...arguments),this._count=0,this._move='0"',this._toughness=4,this._save="4+",this._wounds=1,this._leadership="6+",this._objControl=1,this._weapons=[],this._upgrades=[]}equal(e){if(null==e)return!1;if(this._name===e._name&&this._count===e._count&&this._weapons.length===e._weapons.length&&this._upgrades.length===e._upgrades.length){for(let t=0;t0||this._upgrades.length>0)&&(e+=` (${this.getDedupedWeaponsAndUpgrades().map((e=>e.toString())).join(", ")})`),e}getDedupedWeaponsAndUpgrades(){const e=[];for(const t of[...this._weapons,...this._upgrades])e.some((e=>t.selectionName()===e.selectionName()))||e.push(t);return e}normalize(){this._weapons.sort(A),this._upgrades.sort(S),this.normalizeUpgrades(this._weapons),this.normalizeUpgrades(this._upgrades)}normalizeUpgrades(e){for(let t=0;te[0])).flat();this._profileTables[e]._contents=t.filter(((e,t)=>n.indexOf(e[0])===t))}for(let e=0;e(e._count>1?`${e._count}x `:"")+e.nameAndGear())),this._weapons=this._models.map((e=>e._weapons)).reduce(((e,t)=>e.concat(t)),[]).sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}}e.Unit=l;class c extends t{constructor(){super(...arguments),this._catalog="",this._faction="Unknown",this._factionRules=new Map,this._configurations=[],this._rules=new Map,this._units=[]}hash(){let e=71;for(const t of this._units)e=L(e,t.hash());return e}}e.Force=c;class u extends t{constructor(){super(...arguments),this._cost=new d,this._forces=[]}hash(){let e=59;for(const t of this._forces)e=L(e,t.hash());return e}}e.Roster40k=u;class d{constructor(){this._points=0}hasValues(){return 0!==this._points}toString(){const e=[];return 0!==this._points&&e.push(`${this._points} pts`),`[${e.join(" / ")}]`}add(e){this._points+=e._points;for(const t in e._freeformValues)this.addFreeformValue(t,e._freeformValues[t])}addFreeformValue(e,t){this._freeformValues||(this._freeformValues={});const n=this._freeformValues[e]||0;this._freeformValues[e]=n+t}}function h(e,t,n){var r;let i=e.querySelectorAll("force>selections>selection");for(let e of i){let n=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue;if(n)if(n.includes("Detachment Command Cost"));else if("Battle Size"===n||"Gametype"===n)f(e,t);else if(e.querySelector('profile[typeName="Unit"]')){const n=w(e);t._units.push(n);for(const e of n._rules.entries())t._rules.set(e[0],e[1]);for(const e of n._weaponRules.entries())t._rules.set(e[0],e[1])}else if("upgrade"===e.getAttribute("type")){_(e,t._rules),f(e,t);const n=e.querySelectorAll("selections>selection");for(let e of n){const n=e.getAttribute("name");n&&"upgrade"===e.getAttribute("type")&&("Unknown"===t._faction&&(t._faction=n),_(e,t._factionRules))}}else console.log("** UNEXPECTED SELECTION **",n,e)}for(const e of t._factionRules.keys())t._rules.delete(e);t._rules=new Map([...t._rules.entries()].sort()),t._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?e._name>t._name?1:e._name==t._name?0:-1:-1))}function f(e,t){var n;const r=e.getAttribute("name");if(!r)return;const i=null===(n=e.querySelector("category"))||void 0===n?void 0:n.getAttribute("name"),o=e.querySelectorAll("selections>selection"),s=[];let a=b(e);for(const e of o)s.push(e.getAttribute("name")),a.add(b(e));let l=i&&"Configuration"!==i?`${i} - ${r}`:r;s.length>0&&(l+=`: ${s.join(", ")}`),a.hasValues()&&(l+=` ${a.toString()}`),t._configurations.push(l)}function p(e,t){if(!t||!e)return!1;for(let n of t._forces)if(n._catalog===e._catalog)return!0;return!1}function _(e,t){const n=e.querySelectorAll("profiles>profile");for(const e of n){const n=e.getAttribute("name");if(!n)continue;const r=e.getAttribute("typeName");"Abilities"!==r&&"Dynastic Code"!==r&&"Household Tradition"!==r||E(e,n,0,t)}const r=e.querySelectorAll("rules>rule");for(const e of r)m(e,t)}function m(e,t){const n=e.getAttribute("name"),r=e.querySelector("description");n&&(null==r?void 0:r.textContent)&&t.set(n,r.textContent)}function g(e){const t=[];for(const n of e.children)if("selections"===n.tagName)for(const e of n.children)"selection"===e.tagName&&t.push(e);return t}function v(e,t){for(const n of e.children)if("profiles"===n.tagName)for(const e of n.children)if("profile"===e.tagName&&e.getAttribute("typeName")===t)return!0;return!1}function b(e){const t=new d;for(const n of e.children)if("costs"===n.tagName)for(const e of n.children)t.add(y(e));return t}function y(e){const t=new d,n=e.getAttribute("name"),r=e.getAttribute("value");return n&&r&&("pts"===n?t._points+=+r:t.addFreeformValue(n,+r)),t}function w(e,t){var s,c;let u=new l;!function(e,t){var n,r;t._name=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;let i=e;"profile"===e.tagName&&e.parentElement&&e.parentElement.parentElement&&(i=e.parentElement.parentElement),t._customName=null===(r=i.getAttributeNode("customName"))||void 0===r?void 0:r.nodeValue;let o=i.firstElementChild;o&&"customNotes"===o.tagName&&(t._customNotes=o.textContent),t._name}(e,u);let d=e.querySelectorAll("categories>category");for(let e of d){const t=null===(s=e.getAttributeNode("name"))||void 0===s?void 0:s.nodeValue;if(t){const e="Faction: ",n=t.lastIndexOf(e);if(n>=0){const r=t.slice(n+e.length);u._factions.add(r)}else{let e=i(t.trim());e!=r.NONE&&(u._role=e),u._keywords.add(t)}}}const h=[],f=Array.from(e.querySelectorAll('profile[typeName="Unit"],profile[typeName="Model"]'));for(const e of f){const t=e.getAttribute("name"),n=e.getAttribute("typeName");t&&n&&(u._profileTables[n]||(u._profileTables[n]=new a),x(e,t,n,u._profileTables[n]))}h.push(...f);const p=[];if("model"===e.getAttribute("type"))p.push(e);else{const t=g(e);for(const e of t)("model"===e.getAttribute("type")||v(e,"Unit"))&&p.push(e);0===p.length&&p.push(...Array.from(e.querySelectorAll('selection[type="model"]'))),0===p.length&&v(e,"Unit")&&p.push(e)}for(const e of p){const t=Array.from(e.querySelectorAll("profiles>profile")),r=t.filter((e=>!h.includes(e)));h.push(...r);const i=new o;i._name=e.getAttribute("name")||"Unknown Model",i._count=Number(e.getAttribute("number")||1),u._models.push(i),C(t,0,u);for(const t of e.querySelectorAll('selections>selection[type="upgrade"]')){if(t.querySelector('selections>selection[type="upgrade"]')&&!v(t,"Abilities"))continue;let e=t.getAttribute("name");if(e){const r=new n;r._name=e,r._cost=b(t),r._count=Number(t.getAttribute("number")),i._upgrades.push(r)}}}let _=Array.from(e.querySelectorAll("profiles>profile")).filter((e=>!h.includes(e)));if(h.push(..._),_.length>0){const t=new o;if(t._name="Unit Upgrades",C(_,0,u),t._weapons.length>0&&u._models.length>0){for(const e of u._models)e._weapons.push(...t._weapons);t._weapons.length=0}for(const r of g(e)){if("upgrade"!==r.getAttribute("type"))continue;if(p.includes(r))continue;if(r.querySelector('profiles>profile[typeName="Weapon"]'))continue;let e=r.getAttribute("name");if(!e)continue;const i=new n;i._name=e,i._cost=b(r),i._count=Number(r.getAttribute("number")),t._upgrades.push(i)}(t._weapons.length>0||t._upgrades.length>0)&&u._models.push(t)}let w=e.querySelectorAll("costs>cost");for(let e of w)u._cost.add(y(e));let E=e.querySelectorAll("rules > rule");for(let e of E){const t=null===(c=e.parentElement)||void 0===c?void 0:c.parentElement;t&&(v(t,"Ranged Weapons")||v(t,"Melee Weapons"))?m(e,u._weaponRules):m(e,u._rules)}return u.normalize(),u}function C(e,t,n){for(const t of e){const e=t.getAttribute("name"),r=t.getAttribute("typeName");e&&r&&(t.querySelectorAll("characteristics>characteristic").length>1?(n._profileTables[r]||(n._profileTables[r]=new a),x(t,e,r,n._profileTables[r])):(n._abilities[r]||(n._abilities[r]=new Map),E(t,e,0,n._abilities[r])))}}function x(e,t,n,r){const i=e.querySelectorAll("characteristics>characteristic"),o={[n]:t};for(const e of i){if(!e.textContent)continue;const t=e.getAttribute("name");t&&(o[t]=e.textContent)}r.addRow(o)}function E(e,t,n,r){const i=e.querySelectorAll("characteristics>characteristic");for(const e of i){if(!e.textContent)continue;const n=e.getAttribute("name");n&&i.length>1?r.set([t,n.toString()].join(" - "),e.textContent):r.set(t,e.textContent)}}function S(e,t){return T(e._name,t._name)}function k(e,t){return e._name===t._name?T(e.nameAndGear(),t.nameAndGear()):"Unit Upgrades"===e._name?1:"Unit Upgrades"===t._name?-1:T(e._name,t._name)}function A(e,t){return e.name().localeCompare(t.name())}function T(e,t){return e>t?1:e==t?0:-1}function N(e){let t=23;for(var n=0;ncosts>cost");for(let e of n)t._cost.add(y(e))}(e,r),function(e,t,n){var r,i;let o=e.querySelectorAll("roster>forces>force");for(let e of o)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let n=new c,o=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue,s=null===(i=e.getAttributeNode("catalogueName"))||void 0===i?void 0:i.nodeValue;if(o&&(n._name=o),s&&(n._catalog=s),!p(n,t)){const t=e.querySelectorAll("force>rules>rule");for(let e of t)m(e,n._rules)}h(e,n),t._forces.push(n)}}(e,r),r}}return null},e.CompareWeapon=A,e.Compare=T,e.CompareProfileTableName=function(e,t){const n=["Unit","Ranged Weapons","Melee Weapons"];return(n.includes(e)?n.indexOf(e):n.length)-(n.includes(t)?n.indexOf(t):n.length)}}(t.Wh40k||(t.Wh40k={}))},774:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CreateAoSRoster=t.RosterAoS=t.AoSForce=t.AoSUnit=t.AoSUnitRoleToString=t.AoSUnitRole=t.AoSRealmOfBattle=t.AoSSpecialRules=t.AoSCoreBattalion=t.AoSTriumph=t.AoSGrandStrategy=t.AoSAllegiance=t.AoSPrayer=t.AoSSpell=t.AoSWoundTracker=t.AoSWeapon=t.AoSProfile=t.AoSProfileType=void 0;const s=o(n(486));class a{constructor(){this._typeName="anonymous",this._fields=new Map}}t.AoSProfileType=a;class l{constructor(){this._name="none",this._value=new a}}t.AoSProfile=l;class c{constructor(){this._name="",this._type="Melee",this._range="",this._attacks="",this._toHit="",this._toWound="",this._rend="",this._damage=""}}t.AoSWeapon=c;class u{constructor(){this._title="",this._labels=[],this._table=[[]]}}t.AoSWoundTracker=u;class d{constructor(){this._name="",this._castingValue=0,this._range="",this._description=""}}t.AoSSpell=d;class h{constructor(){this._name="",this._answerValue=0,this._range="",this._description=""}}t.AoSPrayer=h;class f{constructor(){this._name="",this._battleTraits=new Map,this._commandAbilities=new Map,this._spells=[],this._extraProfiles=[]}}t.AoSAllegiance=f;class p{constructor(){this._name="",this._description=""}}t.AoSGrandStrategy=p;class _{constructor(){this._name="",this._description=""}}t.AoSTriumph=_;class m{constructor(){this._name="",this._abilities=new Map}}t.AoSCoreBattalion=m;class g{constructor(){this._name="",this._description=""}}t.AoSSpecialRules=g;class v{constructor(){this._name="",this._spells=[],this._commandAbilities=new Map,this._rules=[]}}var b;t.AoSRealmOfBattle=v,function(e){e[e.NONE=0]="NONE",e[e.LEADER=1]="LEADER",e[e.BATTLELINE=2]="BATTLELINE",e[e.BEHEMOTH=3]="BEHEMOTH",e[e.ARTILLERY=4]="ARTILLERY",e[e.OTHER=5]="OTHER",e[e.SCENERY=6]="SCENERY",e[e.BATTALION=7]="BATTALION",e[e.MALIGN_SORCERY=8]="MALIGN_SORCERY",e[e.REALM=9]="REALM"}(b=t.AoSUnitRole||(t.AoSUnitRole={})),t.AoSUnitRoleToString=["None","Leader","Battleline","Behemoth","Artillery","Other","Scenery","Battalion","Malign Sorcery","Realm"];class y{constructor(){this._name="",this._id=0,this._role=b.NONE,this._keywords=new Set,this._abilities=new Map,this._commandAbilities=new Map,this._commandTraits=new Map,this._magic=new Map,this._artefacts=new Map,this._count=0,this._move='0"',this._wounds=1,this._bravery=7,this._save="",this._weapons=[],this._spells=[],this._prayers=[],this._points=0,this._woundTracker=null,this._extraProfiles=[],this._selections=new Set}equal(e){return null!=e&&e._name===this._name&&e._role===this._role&&!!s.isEqual(this._commandTraits,e._commandTraits)&&!!s.isEqual(this._artefacts,e._artefacts)&&!!s.isEqual(this._weapons,e._weapons)}isNormalUnit(){return this._role==b.ARTILLERY||this._role==b.BATTLELINE||this._role==b.BEHEMOTH||this._role==b.LEADER||this._role==b.OTHER}}t.AoSUnit=y;class w{constructor(){this._catalog="",this._name="Unknown",this._units=[],this._battalions=[],this._rules=new Map,this._battleTactics=new Map,this._allegiance=new f,this._grandStrategy=new p,this._triumph=new _,this._realmOfBattle=new v}}t.AoSForce=w;class C{constructor(){this._commandPoints=0,this._points=0,this._name="",this._forces=[]}}function x(e){switch(e){case"Leader":return b.LEADER;case"Battleline":return b.BATTLELINE;case"Other":return b.OTHER;case"Behemoth":return b.BEHEMOTH;case"Artillery":return b.ARTILLERY;case"Scenery":return b.SCENERY;case"Battalion":return b.BATTALION;case"Malign Sorcery":return b.MALIGN_SORCERY;case"Realm":return b.REALM}return b.NONE}function E(e,t){var n,r,i,o,s,a,l;let c=e.querySelectorAll("force>selections>selection"),u=0;for(let e of c){let c=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;if(c)if(c.includes("Allegiance")){let n=A(e);n&&(t._allegiance=n)}else if(c.includes("Grand Strategy")){let n=T(e);n&&(t._grandStrategy=n)}else if(c.includes("Game Type"));else if(c.includes("Core Battalion")){let n=new m;n._name=c;let s=e.querySelectorAll("profiles>profile");for(let e of s)for(let e of s){let t=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue,s=null===(i=e.getAttributeNode("typeName"))||void 0===i?void 0:i.nodeValue;if(t&&s){let t=e.querySelectorAll("characteristics>characteristic");for(let e of t){let t=null===(o=e.getAttributeNode("name"))||void 0===o?void 0:o.nodeValue;t&&e.textContent&&n._abilities.set(t,e.textContent)}}}t._battalions.push(n)}else if(c.includes("Realm of Battle")){let n=L(e);n&&(t._realmOfBattle=n)}else if(c.includes("GHB 2023 Rules")){let n=R(e);n&&(t._realmOfBattle=n)}else if(c.includes("Triumphs")){let n=N(e);n&&(t._triumph=n)}else if(c.includes("Battle Tactic")){let n=e.querySelectorAll("profiles>profile");for(let e of n)for(let e of n){let n=null===(s=e.getAttributeNode("name"))||void 0===s?void 0:s.nodeValue,r=null===(a=e.getAttributeNode("typeName"))||void 0===a?void 0:a.nodeValue;if(n&&r){let r=e.querySelectorAll("characteristics>characteristic");for(let e of r)(null===(l=e.getAttributeNode("name"))||void 0===l?void 0:l.nodeValue)&&e.textContent&&t._battleTactics.set(n,e.textContent)}}}else{let n=k(e);n&&n._role!=b.NONE&&(n._id=u++,t._units.push(n))}}t._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?0:-1))}function S(e,t){var n;let r=e.querySelectorAll("force>rules>rule");for(let e of r){let r=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,i=e.querySelectorAll("description");if(r&&i)for(let e of i)e.textContent&&t._rules.set(r,e.textContent)}}function k(e){var t,n,r,i,o,s,a,l,f,p,_,m,g,v,w;let C=new y,E=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;E&&(C._name=E);let S=e.querySelectorAll("profiles>profile");for(let e of S){let t=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,p=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(t&&p)if("Unit"==p){C._name||(C._name=t);let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(t&&e.textContent)switch(t){case"Move":C._move=e.textContent;break;case"Wounds":C._wounds=+e.textContent;break;case"Bravery":C._bravery=+e.textContent;break;case"Save":C._save=e.textContent}}}else if("Unit Abilities"==p){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&C._abilities.set(t,n.textContent)}else if("Command Abilities"==p){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&C._commandAbilities.set(t,n.textContent)}else if("Magic"==p){let t=e.querySelectorAll("characteristics>characteristic");for(let e of t){let t=null===(o=e.getAttributeNode("name"))||void 0===o?void 0:o.nodeValue;t&&e.textContent&&C._magic.set(t,e.textContent)}}else if("Unit Leader"==p){let t=e.querySelector("characteristics>characteristic");t&&t.textContent&&C._abilities.set(p,t.textContent)}else if("Spell"==p){let n=new d;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(s=e.getAttributeNode("name"))||void 0===s?void 0:s.nodeValue;if(t&&e.textContent)switch(t){case"Casting Value":n._castingValue=+e.textContent;break;case"Range":n._range=e.textContent;break;case"Description":n._description=e.textContent}}C._spells.push(n)}else if("Weapon"==p){let n=new c;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(a=e.getAttributeNode("name"))||void 0===a?void 0:a.nodeValue;if(t&&e.textContent)switch(t){case"Range":n._range=e.textContent;break;case"Type":n._type=e.textContent;break;case"Attacks":n._attacks=e.textContent;break;case"Rend":n._rend=e.textContent;break;case"To Hit":n._toHit=e.textContent;break;case"To Wound":n._toWound=e.textContent;break;case"Damage":n._damage=e.textContent}}C._weapons.push(n)}else if("Command Trait"==p){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&C._commandTraits.set(t,n.textContent)}else if("Artefact"==p){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&C._artefacts.set(t,n.textContent)}else if("Prayer"==p){let n=new h;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(l=e.getAttributeNode("name"))||void 0===l?void 0:l.nodeValue;if(t&&e.textContent)switch(t){case"Answer Value":n._answerValue=+e.textContent;break;case"Range":n._range=e.textContent;break;case"Description":n._description=e.textContent}}C._prayers.push(n)}else if(p.includes("Damage Table")||p.includes("Wounds")||p.includes("Wound Track")||p.includes("Wound Table")){let n=[];if(C._woundTracker){let r=e.querySelectorAll("characteristics>characteristic");if(r.length<=3){let e=t;e?n.push(e):n.push("Unknown");for(let e of r)e.textContent?n.push(e.textContent):n.push("Unknown")}else for(let e of r)e.textContent?n.push(e.textContent):n.push("Unknown");C._woundTracker._table.push(n),n=[]}else{C._woundTracker=new u,C._woundTracker._title=p;let r=e.querySelectorAll("characteristics>characteristic");if(r.length<=3){C._woundTracker._labels.push("Wounds Suffered"),n.push(t);for(let e of r){let t=null===(f=e.getAttributeNode("name"))||void 0===f?void 0:f.nodeValue;t?C._woundTracker._labels.push(t):C._woundTracker._labels.push("Unknown"),e.textContent?n.push(e.textContent):n.push("Unknown")}}else for(let e of r)e.textContent?C._woundTracker._labels.push(e.textContent):C._woundTracker._labels.push("Unknown");C._woundTracker._table.push(n),n=[]}}else{let t=P(e);t?C._extraProfiles.push(t):console.log("Unknown unit profile type: "+p)}}let k=e.querySelectorAll("selections>selection");for(let e of k){let t=null===(p=e.getAttributeNode("name"))||void 0===p?void 0:p.nodeValue;if(t&&(C._selections.add(t),t.includes("Wound Track"))){C._woundTracker=new u,C._woundTracker._title=t,C._woundTracker._labels=["Wounds Suffered"];let n=e.querySelectorAll("profiles>profile"),r=!0;for(let e of n){let t=null===(_=e.getAttributeNode("name"))||void 0===_?void 0:_.nodeValue,n=e.querySelectorAll("characteristics>characteristic"),i=[];t?i.push(t):i.push("--");for(let e of n){let t=null===(m=e.getAttributeNode("name"))||void 0===m?void 0:m.nodeValue,n=e.textContent;r&&(t?C._woundTracker._labels.push(t):C._woundTracker._labels.push("Unknown")),n?i.push(n):i.push("Unknown")}r=!1,C._woundTracker._table.push(i)}}}let A=e.querySelectorAll("costs>cost");for(let e of A)if(e.hasAttribute("name")&&e.hasAttribute("value")){let t=null===(g=e.getAttributeNode("name"))||void 0===g?void 0:g.nodeValue,n=null===(v=e.getAttributeNode("value"))||void 0===v?void 0:v.nodeValue;n&&"pts"===t&&(C._points+=+n)}let T=e.querySelectorAll(":scope categories>category");for(let e of T){let t=null===(w=e.getAttributeNode("name"))||void 0===w?void 0:w.nodeValue;if(t){var N=x(t.trim());N!=b.NONE?C._role=N:C._keywords.add(t)}}return C}function A(e){var t,n,r,i;let o=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;if(o){let t=new f;t._name=o;let s=e.querySelectorAll("profiles>profile");for(let e of s){let o=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(o&&s)if("Battle Trait"==s){let n=e.querySelector("characteristics>characteristic");if(n){let e=n.textContent;e&&(null==t||t._battleTraits.set(o,e))}}else if("Command Abilities"==s){let n=e.querySelector("characteristics>characteristic");if(n){let e=n.textContent;e&&(null==t||t._commandAbilities.set(o,e))}}else if("Spell"==s){let n=new d;n._name=o;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(t&&e.textContent)switch(t){case"Casting Value":n._castingValue=+e.textContent;break;case"Range":n._range=e.textContent;break;case"Description":n._description=e.textContent}}null==t||t._spells.push(n)}else{let n=P(e);n?null==t||t._extraProfiles.push(n):console.log("Unexpected allegiance profile type: "+s)}}return t}return null}function T(e){var t,n,r;let i=null,o=e.querySelector("selections>selection");if(o){let e=null===(t=o.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;e&&(i=new p,i._name=e);let s=o.querySelectorAll("profiles>profile");for(let e of s){let t=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(t&&o)if("Grand Strategy"==o){let t=e.querySelector("characteristics>characteristic");if(t){let e=t.textContent;e&&i&&(i._description=e)}}else console.log("Unexpected Grand Strategy profile type: "+o)}}return i}function N(e){var t,n,r;let i=null,o=e.querySelector("selections>selection");if(o){let e=null===(t=o.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;e&&(i=new _,i._name=e);let s=o.querySelectorAll("profiles>profile");for(let e of s){let t=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(t&&o)if("Triumph"==o){let t=e.querySelector("characteristics>characteristic");if(t){let e=t.textContent;e&&i&&(i._description=e)}}else console.log("Unexpected Triumph profile type: "+o)}}return i}function L(e){var t,n,r,i;let o=null,s=e.querySelector("selections>selection");if(s){let e=null===(t=s.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;if(e){o=new v,o._name=e;let t=s.querySelectorAll("profiles>profile");for(let e of t){let t=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(t&&s)if("Spell"==s){let n=new d;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(t&&e.textContent)switch(t){case"Casting Value":n._castingValue=+e.textContent;break;case"Range":n._range=e.textContent;break;case"Description":n._description=e.textContent}}o._spells.push(n)}else if("Command Abilities"==s){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&o._commandAbilities.set(t,n.textContent)}else if("Special Rules"==s){let n=e.querySelector("characteristics>characteristic");if(n&&n.textContent){let e=new g;e._name=t,e._description=n.textContent,o._rules.push(e)}}else console.log("Unexpected Realm of Battle profile type: "+s)}}}return o}function R(e){var t,n,r,i;let o=null,s=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;if(s){o=new v,o._name=s;let t=e.querySelectorAll("profiles>profile");for(let e of t){let t=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(t&&s)if("Spell"==s){let n=new d;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(t&&e.textContent)switch(t){case"Casting Value":n._castingValue=+e.textContent;break;case"Range":n._range=e.textContent;break;case"Description":n._description=e.textContent}}o._spells.push(n)}else if("Command Abilities"==s){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&o._commandAbilities.set(t,n.textContent)}else if("Special Rules"==s||"Heroic Action"==s){let n=e.querySelector("characteristics>characteristic");if(n&&n.textContent){let e=new g;e._name=t,e._description=n.textContent,o._rules.push(e)}}else console.log("Unexpected Realm of Battle profile type: "+s)}}return o}function P(e){var t,n,r;if(!e)return null;let i=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue,o=null===(n=e.getAttributeNode("typeName"))||void 0===n?void 0:n.nodeValue;if(!i||!o)return null;let s=new l;s._name=i,s._value._typeName=o;let a=e.querySelectorAll("characteristics>characteristic");for(let e of a){let t=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue;t&&e.textContent&&s._value._fields.set(t,e.textContent)}return s}t.RosterAoS=C,t.CreateAoSRoster=function(e){var t;if(e){let n=e.querySelector("roster");if(n){const r=new C,i=null===(t=n.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;return r._name=i||"Age of Sigmar Roster",function(e,t){var n,r;let i=e.querySelectorAll("roster>costs>cost");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("value")){let i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("value"))||void 0===r?void 0:r.nodeValue;o&&"pts"===i&&(t._points=+o)}}(e,r),function(e,t){var n,r;let i=e.querySelectorAll("roster>forces>force");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let i=new w,o=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("catalogueName"))||void 0===r?void 0:r.nodeValue;o&&(i._name=o),s&&(i._catalog=s),E(e,i),S(e,i),t._forces.push(i)}}(e,r),r}}return null}},980:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.HorusHeresy=void 0;const s=o(n(486));!function(e){let t;!function(e){e[e.NONE=0]="NONE",e[e.HQ=1]="HQ",e[e.TR=2]="TR",e[e.EL=3]="EL",e[e.FA=4]="FA",e[e.HS=5]="HS",e[e.FL=6]="FL",e[e.DT=7]="DT",e[e.FT=8]="FT",e[e.LW=9]="LW",e[e.PR=10]="PR"}(t=e.UnitRole||(e.UnitRole={})),e.UnitRoleToString=["None","HQ","Troops","Elites","Fast Attack","Heavy Support","Flyer","Dedicated Transport","Fortification","Lord of War","Primarch"];class n{constructor(){this._name="",this._customName="",this._customNotes=""}name(){return this._customName?this._customName:this._name}notes(){return this._customNotes}equal(e){return null!=e&&this._name===e._name}}e.BaseNote=n;class r extends n{constructor(){super(...arguments),this._description="",this._cost=new p,this._count=1}selectionName(){return this.name()}toString(){let e=this.selectionName();return this._count>1&&(e=`${this._count}x ${e}`),this._cost.hasValues()&&(e+=` ${this._cost.toString()}`),e}}e.Upgrade=r;class i extends r{constructor(){super(...arguments),this._selectionName="",this._range="Melee",this._str="user",this._ap="",this._type="Melee"}getRules(){let e=this._type.split(",");return e.length>0&&(e=e.slice(1).map((e=>e.trim()))),e}}e.Weapon=i;class o extends n{constructor(){super(...arguments),this._count=0,this._type="",this._weapons=[],this._upgrades=[],this._wargear=[],this._warlordTraits=[],this._reactions=[],this._psychicWeapons=[],this._psychicPowers=[]}equal(e){if(null==e)return!1;if(this._name===e._name&&this._count===e._count&&this._weapons.length===e._weapons.length&&this._upgrades.length===e._upgrades.length&&this._wargear.length===e._wargear.length&&this._psychicWeapons.length===e._psychicWeapons.length&&this._psychicPowers.length===e._psychicPowers.length){for(let t=0;t0||this._upgrades.length>0)&&(e+=` (${this.getDedupedWeaponsAndUpgrades().map((e=>e.toString())).join(", ")})`),e}getDedupedWeaponsAndUpgrades(){const e=[];for(const t of[...this._weapons,...this._upgrades])e.some((e=>t.selectionName()===e.selectionName()))||e.push(t);return e}normalize(){this._weapons.sort(N),this._upgrades.sort(A),this._wargear.sort(A),this._psychicPowers.sort(A),this._psychicWeapons.sort(N),this.normalizeUpgrades(this._weapons),this.normalizeUpgrades(this._upgrades),this.normalizeUpgrades(this._wargear),this.normalizeUpgrades(this._psychicPowers),this.normalizeUpgrades(this._psychicWeapons)}normalizeUpgrades(e){for(let t=0;t(e._count>1?`${e._count}x `:"")+e.nameAndGear()))}weapons(){let e=this._models.map((e=>e._weapons)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._weapons),e.sort(N).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}psychicWeapons(){let e=this._models.map((e=>e._psychicWeapons)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._psychicWeapons),e.sort(N).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}psychicPowers(){let e=this._models.map((e=>e._psychicPowers)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._psychicPowers),e.sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}wargear(){let e=this._models.map((e=>e._wargear)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._wargear),e.sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}weaponRules(){let e=[];return e=this.weapons().map((e=>e.getRules())).reduce(((e,t)=>e.concat(t)),[]),e.sort().filter(((e,t,n)=>e!==n[t-1]))}warlordTraits(){let e=this._models.map((e=>e._warlordTraits)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._warlordTraits),e.sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}upgrades(){let e=this._models.map((e=>e._upgrades)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._upgrades),e.sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}reactions(){let e=this._models.map((e=>e._reactions)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._reactions),e.sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}}e.Unit=d;class h extends n{constructor(){super(),this._catalog="",this._name="Unknown",this._faction="Unknown",this._factionRules=new Map,this._rules=new Map,this._units=[]}}e.Force=h;class f extends n{constructor(){super(),this._cost=new p,this._name="",this._forces=[]}}e.Roster=f;class p{constructor(){this._points=0}hasValues(){return 0!==this._points}toString(){const e=[];return 0!==this._points&&e.push(`${this._points} pts`),`[${e.join(" / ")}]`}add(e){this._points+=e._points;for(const t in e._freeformValues)this.addFreeformValue(t,e._freeformValues[t])}addFreeformValue(e,t){this._freeformValues||(this._freeformValues={});const n=this._freeformValues[e]||0;this._freeformValues[e]=n+t}}function _(e,t){return e>t?1:e==t?0:-1}function m(e,t){return typeof e>typeof t?1:typeof e==typeof t?0:-1}function g(e){const t=new p,n=e.getAttribute("name"),r=e.getAttribute("value");return n&&r&&("Pts"===n?t._points+=+r:t.addFreeformValue(n,+r)),t}function v(e,n){var i,o;let s=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(!s)return;let h=null===(o=e.getAttributeNode("type"))||void 0===o?void 0:o.nodeValue;if(h)if(e.querySelector('profile[typeId="4bb2-cb95-e6c8-5a21"]')||e.querySelector('profile[typeId="2fae-b053-3f78-e7b2"]')||e.querySelector('profile[typeId="75b5-9f7a-156e-6889"]')||e.querySelector('profile[typeId="eeec-bde3-8ee4-35b0"]')){const i=function(e){var n,i,o;let s=new d;b(e,s);let h=e.querySelectorAll("categories>category");for(let e of h){const r=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;if(r){let e=S(r.trim());e!=t.NONE?s._role=e:r.endsWith(":")||s._keywords.add(r)}}const f=[],p=Array.from(e.querySelectorAll('profile[typeId="4bb2-cb95-e6c8-5a21"],profile[typeId="2fae-b053-3f78-e7b2"],profile[typeId="75b5-9f7a-156e-6889"],profile[typeId="eeec-bde3-8ee4-35b0"]'));(function(e,t,n){var r,i;for(const n of e){const e=n.getAttribute("name"),o=n.getAttribute("typeName");if(!e||!o)return;if("Unit"===o.trim()){const r=new l;r._name=e,t._modelStats.push(r),b(n,r);const i=n.querySelectorAll("characteristics>characteristic");for(const e of i){const t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"Unit Type":r._type=e.textContent;break;case"Move":r._move=k(e.textContent);break;case"WS":r._ws=+e.textContent;break;case"BS":r._bs=+e.textContent;break;case"S":r._str=+e.textContent;break;case"T":r._toughness=+e.textContent;break;case"W":r._wounds=+e.textContent;break;case"I":r._initiative=+e.textContent;break;case"A":r._attacks=+e.textContent;break;case"Ld":r._leadership=+e.textContent;break;case"Save":r._save=e.textContent}}}else if("Knights and Titans"===o.trim()){let r=new c;r._name=e,t._modelStats.push(r),b(n,r);const i=n.querySelectorAll("characteristics>characteristic");for(const e of i){const t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"Unit Type":r._type=e.textContent;break;case"Move":r._move=k(e.textContent);break;case"WS":r._ws=+e.textContent;break;case"BS":r._bs=+e.textContent;break;case"S":r._str=+e.textContent;break;case"Front":r._front=+e.textContent;break;case"Side":r._side=+e.textContent;break;case"Rear":r._rear=+e.textContent;break;case"I":r._initiative=+e.textContent;break;case"A":r._attacks=+e.textContent;break;case"HP":r._hp=+e.textContent}}}else if("Vehicle"===o.trim()){let i=new a;i._name=e,t._modelStats.push(i),b(n,i);const o=n.querySelectorAll("characteristics>characteristic");for(const e of o){const t=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue;if(t&&e.textContent)switch(t){case"Unit Type":i._type=e.textContent;break;case"Move":i._move=k(e.textContent);break;case"BS":i._bs=+e.textContent;break;case"Front":i._front=+e.textContent;break;case"Side":i._side=+e.textContent;break;case"Rear":i._rear=+e.textContent;break;case"HP":i._hp=+e.textContent;break;case"Transport Capacity":i._capacity=e.textContent;break;case"Access Points":i._accessPoints=e.textContent}}}else if("Fortification"===o.trim()){let r=new u;r._name=e,t._modelStats.push(r),b(n,r);const o=n.querySelectorAll("characteristics>characteristic");for(const e of o){const t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(t&&e.textContent)switch(t){case"Unit Type":r._type=e.textContent;break;case"BS":r._bs=e.textContent;break;case"Front":r._front=+e.textContent;break;case"Side":r._side=+e.textContent;break;case"Rear":r._rear=+e.textContent;break;case"HP":r._hp=+e.textContent;break;case"Transport Capacity":r._capacity=e.textContent;break;case"Fire Points":r._firePoints=e.textContent}}}}})(p,s),f.push(...p);const _=[];if("model"===e.getAttribute("type"))_.push(e);else{const t=function(e){const t=[];for(const n of e.children)if("selections"===n.tagName)for(const e of n.children)"selection"===e.tagName&&t.push(e);return t}(e);for(const e of t)("model"===e.getAttribute("type")||O(e,"Unit")||O(e,"Fortification")||O(e,"Vehicle")||O(e,"Knights and Titans"))&&_.push(e);0===_.length&&_.push(...Array.from(e.querySelectorAll('selection[type="model"]'))),(0===_.length&&O(e,"Unit")||O(e,"Fortification")||O(e,"Vehicle")||O(e,"Knights and Titans"))&&_.push(e)}for(const e of _){const t=Array.from(e.querySelectorAll("profiles>profile")),n=t.filter((e=>!f.includes(e)));f.push(...n);const i=new l;i._name=e.getAttribute("name")||"Unknown Model",i._count=Number(e.getAttribute("number")||1),s._models.push(i),R(t,i);for(const t of e.querySelectorAll('selections>selection[type="upgrade"]')){let e=t.getAttribute("name");if(e){const n=new r;n._name=e,n._cost=L(t),n._count=Number(t.getAttribute("number")),i._upgrades.push(n)}}}let m=e.querySelectorAll('selections>selection[type="upgrade"]');for(const e of m){R(Array.from(e.querySelectorAll("profiles>profile")),s);const t=e.getAttribute("name");if(t){const n=new r;n._name=t,n._cost=L(e),n._count=Number(e.getAttribute("number")),s._upgrades.push(n)}}let g=e.querySelectorAll("costs>cost");for(let e of g)if(e.hasAttribute("name")&&e.hasAttribute("value")){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue,n=null===(o=e.getAttributeNode("value"))||void 0===o?void 0:o.nodeValue;n&&"Pts"==t&&(s._points+=+n)}let v=e.querySelectorAll("rules>rule");for(let e of v)P(e,s._rules);return s.normalize(),s}(e);if(i){n._units.push(i);for(const e of i._rules.entries())n._rules.set(e[0],e[1])}}else"upgrade"===h?function(e,t){const n=e.querySelectorAll("rules>rule");for(const e of n)P(e,t)}(e,n._rules):console.log("** UNEXPECTED SELECTION **",s,h,e)}function b(e,t){var n,r;t._name=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;let i=e;"profile"===e.tagName&&e.parentElement&&e.parentElement.parentElement&&(i=e.parentElement.parentElement),t._customName=null===(r=i.getAttributeNode("customName"))||void 0===r?void 0:r.nodeValue;let o=i.firstElementChild;return o&&"customNotes"===o.tagName&&(t._customNotes=o.textContent),t._name}function y(e){var t;if(e.parentElement&&e.parentElement.parentElement){const n=null===(t=e.parentElement.parentElement.getAttributeNode("number"))||void 0===t?void 0:t.nodeValue;if(n)return+n}return 0}function w(e){var t;const n=new i;b(e,n),n._count=y(e);let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"Range":n._range=e.textContent;break;case"Type":n._type=e.textContent;break;case"Strength":n._str=e.textContent;break;case"AP":n._ap=e.textContent}}const o=null===(t=e.parentElement)||void 0===t?void 0:t.parentElement,s=null==o?void 0:o.getAttribute("name");return"upgrade"===(null==o?void 0:o.getAttribute("type"))&&s&&(n._selectionName=s,n._cost=L(o)),n}function C(e){var t;const n=new i;b(e,n),n._count=y(e);let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"Range":n._range=e.textContent;break;case"Type":n._type=e.textContent;break;case"Strength":n._str=e.textContent;break;case"AP":n._ap=e.textContent}}const o=null===(t=e.parentElement)||void 0===t?void 0:t.parentElement,s=null==o?void 0:o.getAttribute("name");return"upgrade"===(null==o?void 0:o.getAttribute("type"))&&s&&(n._selectionName=s,n._cost=L(o)),n}function x(e){const t=new r;b(e,t),t._count=y(e);let n=e.querySelectorAll("characteristics>characteristic");for(let e of n)if(e.textContent){let n=e.getAttribute("name");if(n)switch(n){case"Description":case"Text":t._description=e.textContent}}return t}function E(e,t){if(!t||!e)return!1;for(let n of t._forces)if(n._catalog===e._catalog)return!0;return!1}function S(e){switch(e){case"HQ:":return t.HQ;case"Troops:":return t.TR;case"Elites:":return t.EL;case"Fast Attack:":return t.FA;case"Heavy Support:":return t.HS;case"Flyer":return t.FL;case"Transport Sub-type:":return t.DT;case"Fortification:":return t.FT;case"Lords of War:":return t.LW;case"Primarch:":return t.PR}return t.NONE}function k(e){return function(e){return null!=e&&""!==e&&!isNaN(Number(e.toString()))}(e)?e.toString()+'"':e.toString()}function A(e,t){return _(e._name,t._name)}function T(e,t){return e._name===t._name?_(e.nameAndGear(),t.nameAndGear()):_(e._name,t._name)}function N(e,t){return(e._type.startsWith("Grenade")?2:e._type.startsWith("Melee")?1:0)-(t._type.startsWith("Grenade")?2:t._type.startsWith("Melee")?1:0)||e.name().localeCompare(t.name())}function L(e){const t=new p;for(const n of e.children)if("costs"===n.tagName)for(const e of n.children)t.add(g(e));return t}function R(e,t){for(const n of e){const e=n.getAttribute("name");let r=n.getAttribute("typeName");if(e&&r)if(r=r.trim(),"Unit"===r||"Vehicle"===r||"Knights and Titans"===r||"Fortification"===r||"model"===n.getAttribute("type"));else if("Weapon"===r){const e=w(n);t._weapons.push(e)}else if("Psychic Weapon"===r){const e=C(n);t._psychicWeapons.push(e)}else if("Psychic Power"===r){const e=x(n);t._psychicPowers.push(e)}else if("Wargear Item"===r){const e=x(n);t._wargear.push(e)}else if("Warlord Trait"===r){const e=x(n);t._warlordTraits.push(e)}else if("Reactions"===r){const e=x(n);t._reactions.push(e)}else console.log("Unhandled model/unit profile "+e+" of type "+r+".")}}function P(e,t){const n=e.getAttribute("name"),r=e.querySelector("description");n&&(null==r?void 0:r.textContent)&&t.set(n,r.textContent)}function O(e,t){var n;for(const r of e.children)if("profiles"===r.tagName)for(const e of r.children)if("profile"===e.tagName&&(null===(n=e.getAttribute("typeName"))||void 0===n?void 0:n.trim())===t)return!0;return!1}e.Costs=p,e.Compare=_,e.CompareModelTypes=m,e.CreateRoster=function(e){var t;if(e){let n=e.querySelector("roster");if(n){const r=new f,i=null===(t=n.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;return r._name=i||"Horus Heresy Army Roster",function(e,t){let n=e.querySelectorAll("roster>costs>cost");for(let e of n)t._cost.add(g(e))}(e,r),function(e,t){var n,r;let i=e.querySelectorAll("roster>forces>force");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let i=new h,o=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("catalogueName"))||void 0===r?void 0:r.nodeValue;if(o&&(i._name=o),s&&(i._catalog=s),!E(i,t)){const t=e.querySelectorAll("force>rules>rule");for(let e of t)P(e,i._rules)}let a=e.querySelectorAll(":scope>selections>selection");for(let e of a)v(e,i);i._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?0:-1)),t._forces.push(i)}}(e,r),r}}return null},e.CompareWeapon=N}(t.HorusHeresy||(t.HorusHeresy={}))},249:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Compare=t.CreateKT21Roster=t.RosterKT21=t.Force=t.Operative=t.OperativeRoleToString=t.Specialism=t.PsychicPowerWeapon=t.PsychicPower=t.UniqueActions=t.Weapons=t.BaseNotes=void 0;const s=o(n(486));class a{constructor(){this._name="",this._customName="",this._customNotes="",this._costs="0"}name(){return this._customName?this._customName:this._name}nameAndCosts(){let e=this._name;return this._customName&&(e=this._customName),this.costs()>0&&(e+=" ("+this.costs()+" EP)"),e}notes(){return this._customNotes}costs(){return Math.floor(+this._costs)}equal(e){return null!=e&&this._name===e._name}}t.BaseNotes=a;class l extends a{constructor(){super(...arguments),this._count=0,this._attacks="0",this._skill="0+",this._damage="0/0",this._rules="",this._criticalEffects=""}}t.Weapons=l,t.UniqueActions=class extends a{constructor(){super(...arguments),this._description=""}};class c extends a{constructor(){super(...arguments),this._effect="",this._weapons=[]}}var u;t.PsychicPower=c,t.PsychicPowerWeapon=class extends l{},function(e){e[e.NONE=0]="NONE",e[e.COMBAT=1]="COMBAT",e[e.STAUNCH=2]="STAUNCH",e[e.MARKSMAN=3]="MARKSMAN",e[e.SCOUT=4]="SCOUT"}(u=t.Specialism||(t.Specialism={})),t.OperativeRoleToString=["None","Combat","Staunch","Marksman","Scout"];class d extends a{constructor(){super(...arguments),this._role=u.NONE,this._model="",this._factions=new Set,this._keywords=new Set,this._abilities=new Map,this._rules=new Map,this._move='0"',this._apl="0",this._groupActivations="0",this._defence=0,this._saves="0+",this._wounds=0,this._weapons=[],this._upgrades=[],this._psychicPowers=[],this._psychicPowersWeapon=[]}equal(e){if(null==e)return!1;if(e._name===this._name&&e._role===this._role&&e._weapons.length===this._weapons.length){for(let t=0;t0||this._upgrades.length>0){let t=0;e+=" (";for(const n of this._weapons)e+=n.name(),t++,t!=this._weapons.length&&(e+=", ");this._upgrades.length>0&&!e.endsWith("(")&&(e+=", "),e+=this._upgrades.join(", "),e+=")"}return e}normalize(){this._weapons.sort(x),this._upgrades.sort(E);for(let e=0;eselections>selection");for(let e of r){let r=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;if(r&&"Game Type"!==r)if(r.includes("Detachment Command Cost"))console.log("Found Detachment Command Cost");else if(r.includes("Chapter Tactics"))console.log("Found chapter tactics."),m(e,t._rules);else{let n=w(e);if(n){n._keywords.has("Leader")?t._leader=n:t._operatives.push(n);for(const e of n._rules.entries())t._rules.set(e[0],e[1])}else if("upgrade"===e.getAttribute("type")){m(e,t._rules);const n=e.querySelectorAll("selections>selection");for(let e of n){const n=e.getAttribute("name");n&&"upgrade"===e.getAttribute("type")&&("Unknown"===t._faction&&(t._faction=n),m(e,t._factionRules))}}}}for(const e of t._factionRules.keys())t._rules.delete(e);t._operatives.sort(((e,t)=>e._role>t._role?1:e._role==t._role?e._name>t._name?1:e._name==t._name?0:-1:-1))}function _(e,t){if(!t||!e)return!1;for(let n of t._forces)if(n._catalog===e._catalog)return!0;return!1}function m(e,t){var n,r,i,o,s;const a=e.querySelectorAll(":scope profiles>profile");for(const l of a){const a=null===(n=l.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,c=null===(r=l.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(console.log("Prop name:"+a+" Type: "+c),a&&c)if("Abilities"===c||"Dynastic Code"===c||"Chapter Tactics"===c){const e=l.querySelectorAll("characteristics>characteristic");for(const n of e){const e=null===(i=n.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;e&&n.textContent&&a&&("Description"!==e&&"Ability"!==e&&"Effect"!=e&&"Chapter Tactic"!=e||t.set(a,n.textContent))}}else if("Weapons"===c){const n=e.querySelectorAll("rules>rule");for(const e of n)e.getAttributeNode("name")&&t.set(null===(o=e.getAttributeNode("name"))||void 0===o?void 0:o.nodeValue,null===(s=e.firstChild)||void 0===s?void 0:s.textContent)}}}function g(e){switch(e){case"Combat":return u.COMBAT;case"Staunch":return u.STAUNCH;case"Marksman":return u.MARKSMAN;case"Scout":return u.SCOUT}return u.NONE}function v(e,t){var n,r;let i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;console.log("Unknown profile type: "+o+" with name: "+i+". Found in operative: "+t._name)}function b(e,t){var n,r,i;t._name=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;let o=e;"profile"===e.tagName&&e.parentElement&&e.parentElement.parentElement&&(o=e.parentElement.parentElement),t._customName=null===(r=o.getAttributeNode("customName"))||void 0===r?void 0:r.nodeValue;let s=o.firstElementChild;if(s&&"customNotes"===s.tagName&&(t._customNotes=s.textContent),"selection"===o.tagName){let e=o.querySelector("costs>cost");e&&e.getAttributeNode("value")&&(t._costs=null===(i=e.getAttributeNode("value"))||void 0===i?void 0:i.nodeValue)}return t._name}function y(e){var t;if(e.parentElement&&e.parentElement.parentElement){const n=null===(t=e.parentElement.parentElement.getAttributeNode("number"))||void 0===t?void 0:t.nodeValue;if(n)return+n}return 0}function w(e){var t,n,r,i,o;let s=new d;b(e,s);let a=e.querySelectorAll(":scope categories>category");for(let e of a){const n=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;if(n){const e="Faction: ",t=n.lastIndexOf(e);if(t>=0){const r=n.slice(t+e.length);s._factions.add(r)}else{let e=g(n.trim());e!=u.NONE?s._role=e:s._keywords.add(n)}}}let l=[],c=[];for(let t of e.querySelectorAll('profile[typeName="Operative"]')){let e=null===(n=t.parentElement)||void 0===n?void 0:n.parentElement;if(!e||c.includes(e))continue;c.push(e);let r=Array.from(e.querySelectorAll(":scope profiles>profile")||[]);C(r,s),l=l.concat(r)}C(Array.from(e.querySelectorAll(":scope profiles>profile")).filter((e=>!l.includes(e))),s,0,!0);let h=e.querySelectorAll(":scope costs>cost");for(let e of h)if(e.hasAttribute("name")&&e.hasAttribute("value")){let t=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue,n=null===(i=e.getAttributeNode("value"))||void 0===i?void 0:i.nodeValue;" EP"==t&&n&&+n>0&&(s._costs=(s.costs()+parseInt(n)).toString())}let f=e.querySelectorAll("rules > rule");for(let e of f)if(e.hasAttribute("name")){let t=null===(o=e.getAttributeNode("name"))||void 0===o?void 0:o.nodeValue,n=e.querySelector("description");t&&n&&n.textContent&&s._rules.set(t,n.textContent)}return s.normalize(),s}function C(e,t,n,r=!1){var i,o,s,a,u,d,h,f,p,_,g,w;for(let n of e){const e=null===(i=n.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue,r=null===(o=n.getAttributeNode("typeName"))||void 0===o?void 0:o.nodeValue;if(e&&r)if("Operative"===r){let e=t._name;b(n,t),t._model=t._name,t._name=e;let r=n.querySelectorAll("characteristics>characteristic");for(let e of r){let n=null===(s=e.getAttributeNode("name"))||void 0===s?void 0:s.nodeValue;if(n&&e.textContent)switch(n){case"M":t._move=e.textContent;break;case"APL":t._apl=e.textContent;break;case"GA":t._groupActivations=e.textContent;break;case"DF":t._defence=+e.textContent;break;case"SV":t._saves=e.textContent;break;case"W":t._wounds=+e.textContent}}}else if("Abilities"===r||"Equipment"===r||"Ability"===r||"Unique Actions"===r||"Chapter Tactics"==r){let r=n.querySelectorAll("characteristics>characteristic");for(let i of r)if((null===(a=i.getAttributeNode("name"))||void 0===a?void 0:a.nodeValue)&&i.textContent&&e){let r=null===(d=null===(u=n.parentElement)||void 0===u?void 0:u.parentElement)||void 0===d?void 0:d.querySelector("costs>cost"),o=e;if(r&&(null===(h=r.getAttributeNode("value"))||void 0===h?void 0:h.nodeValue)){let e=null===(f=r.getAttributeNode("value"))||void 0===f?void 0:f.nodeValue;e&&+e>0&&(o+=" ("+Math.floor(+e)+" EP)")}t._abilities.set(o,i.textContent)}if(n.parentElement&&n.parentElement.parentElement){const r=n.parentElement.parentElement;"upgrade"===(null===(p=r.getAttributeNode("type"))||void 0===p?void 0:p.nodeValue)&&r.parentElement&&r.parentElement.parentElement&&"model"===(null===(_=r.parentElement.parentElement.getAttributeNode("type"))||void 0===_?void 0:_.nodeValue)&&t._upgrades.push(e)}}else if("Weapons"===r){let e=new l;b(n,e),n.parentElement&&n.parentElement.parentElement&&m(n.parentElement.parentElement,t._rules),e._count=y(n);let r=n.querySelectorAll("characteristics>characteristic");for(let t of r){let n=null===(g=t.getAttributeNode("name"))||void 0===g?void 0:g.nodeValue;if(n&&t.textContent)switch(n){case"A":e._attacks=t.textContent;break;case"WS/BS":e._skill=t.textContent;break;case"D":e._damage=t.textContent;break;case"SR":e._rules=t.textContent;break;case"!":e._criticalEffects=t.textContent}}t._weapons.push(e)}else if("Psychic Power"==r){let e=new c;b(n,e);let r=n.querySelectorAll("characteristics>characteristic");for(let t of r)"Effect"===(null===(w=t.getAttributeNode("name"))||void 0===w?void 0:w.nodeValue)&&t.textContent&&(e._effect=t.textContent);t._psychicPowers.push(e)}else v(n,t)}}function x(e,t){return E(e._name,t._name)}function E(e,t){return e>t?1:e==t?0:-1}t.RosterKT21=f,t.CreateKT21Roster=function(e){var t;if(e){let n=e.querySelector("roster");if(n){const r=new f,i=null===(t=n.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;return r._name=i||"Kill Team (2021) Army Roster",function(e,t){var n,r;let i=e.querySelectorAll("roster>costs>cost");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("value")){let i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("value"))||void 0===r?void 0:r.nodeValue;o&&" EP"==i&&(t._equipmentPoints=+o)}}(e,r),function(e,t){var n,r,i;let o=e.querySelectorAll("roster>forces>force");for(let e of o)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let o=new h,l=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,c=null===(r=e.getAttributeNode("catalogueName"))||void 0===r?void 0:r.nodeValue;if(l&&(o._name=l),c&&(o._catalog=c,o._faction=c),!_(o,t)){var s=e.querySelectorAll("force>rules>rule");for(let e of s)if(e.hasAttribute("name")){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;var a=e.querySelector("rule>description");t&&a&&o._rules.set(t,a.textContent)}}p(e,o),t._forces.push(o)}}(e,r),r}}return null},t.Compare=E},452:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateMESBGRoster=void 0;const n=/\r\n|\r|\n| /,r=e=>{var t;return null!==(t=e.getAttribute("catalogueName"))&&void 0!==t?t:"MESBG Force"},i=e=>{var t;const n={half:0,quarter:0,modelCount:0};for(let r of e.querySelectorAll("rules>rule")){const e=null!==(t=r.getAttribute("name"))&&void 0!==t?t:"";if(e.endsWith("is halfway. (model)")){const t=parseFloat(e);isNaN(t)||(n.half=Math.ceil(t))}if(e.endsWith("models remaining. (model)")){const t=parseFloat(e);isNaN(t)||(n.quarter=Math.ceil(t))}if(e.endsWith("total models in Army. (model)")){const t=parseFloat(e);isNaN(t)||(n.modelCount=t)}}return n},o=e=>{var t,r,i,o,s,a,l,c,u,d,h,f,p,_,m,g,v,b,y;let w="",C="",x="",E=[],S="",k=!1;const A=[];for(let u of e.querySelectorAll('profiles > profile[typeName="Hero"]'))for(let e of u.querySelectorAll("characteristics > characteristic"))switch(null!==(r=null===(t=e.getAttribute("name"))||void 0===t?void 0:t.trim())&&void 0!==r?r:""){case"Might":x=null!==(i=e.textContent)&&void 0!==i?i:"";break;case"Fate":w=null!==(o=e.textContent)&&void 0!==o?o:"";break;case"Will":C=null!==(s=e.textContent)&&void 0!==s?s:"";break;case"Heroic Actions":E=null!==(l=null===(a=e.textContent)||void 0===a?void 0:a.split(n))&&void 0!==l?l:[];break;case"Heroic Tier":S=null!==(c=e.textContent)&&void 0!==c?c:""}for(let t of e.querySelectorAll('profile[typeName="Magical Power"]')){const e=null!==(u=t.getAttribute("name"))&&void 0!==u?u:"Unnamed Magic Power",n=null!==(h=null===(d=t.querySelector(':scope characteristic[name~="Duration"]'))||void 0===d?void 0:d.textContent)&&void 0!==h?h:"",r=null!==(p=null===(f=t.querySelector(':scope characteristic[name~="Range"]'))||void 0===f?void 0:f.textContent)&&void 0!==p?p:"",i=null!==(m=null===(_=t.querySelector(':scope characteristic[name~="Casting"]'))||void 0===_?void 0:_.textContent)&&void 0!==m?m:"",o=null!==(v=null===(g=t.querySelector(':scope characteristic[name~="Rule"]'))||void 0===g?void 0:g.textContent)&&void 0!==v?v:"",s=null!==(y=null===(b=t.querySelector(':scope characteristic[name~="Channelled"]'))||void 0===b?void 0:b.textContent)&&void 0!==y?y:"";A.push({name:e,duration:n,range:r,casting:i,normalEffect:o,channelledEffect:s})}return k=!!e.querySelector('selections > selection[name$="Leader (Valour)"]'),{fate:w,will:C,might:x,heroicTier:S,actions:E,magicalPowers:A,isLeader:k}},s=e=>{var t,r,i,a,u,d,h,f,p,_,m,g,v,b,y,w,C,x,E,S,k,A,T,N,L;const R=(e=>{var t,n,r;const i=[];for(let o of e)if(o.hasAttribute("name")){const e=null!==(t=o.getAttribute("name"))&&void 0!==t?t:null,s=null!==(r=null===(n=o.querySelector("rule>description"))||void 0===n?void 0:n.textContent)&&void 0!==r?r:"";null!==e&&i.push({name:e,ruleText:s})}return i})(null!==(t=e.querySelectorAll("rules > rule"))&&void 0!==t?t:[]),P=null!==(i=null===(r=e.getAttribute("name"))||void 0===r?void 0:r.trim())&&void 0!==i?i:"Unknown Model Name";let O=[];const W=[];let z,I,B="",M="",U="",D="",F="",q="",H="";e.querySelectorAll("profiles > profile");for(let t of e.querySelectorAll(":scope profiles > profile")){const r=t.getAttribute("typeName"),i=null!==(u=null===(a=t.getAttribute("name"))||void 0===a?void 0:a.trim())&&void 0!==u?u:"wowza";if(("Hero"===r||"Warrior"===r)&&i.startsWith(P)){for(let e of t.querySelectorAll("characteristics > characteristic"))switch(null!==(h=null===(d=e.getAttribute("name"))||void 0===d?void 0:d.trim())&&void 0!==h?h:""){case"Wounds":q=null!==(f=e.textContent)&&void 0!==f?f:"";break;case"Courage":H=null!==(p=e.textContent)&&void 0!==p?p:"";break;case"Attack":F=null!==(_=e.textContent)&&void 0!==_?_:"";break;case"Defense":D=null!==(m=e.textContent)&&void 0!==m?m:"";break;case"Strength":U=null!==(g=e.textContent)&&void 0!==g?g:"";break;case"Fight":M=null!==(v=e.textContent)&&void 0!==v?v:"";break;case"Movement":B=null!==(b=e.textContent)&&void 0!==b?b:"";break;case"Keywords":O=null!==(w=null===(y=e.textContent)||void 0===y?void 0:y.split(n))&&void 0!==w?w:[]}for(let t of null!==(C=l(e))&&void 0!==C?C:[]){if("Shield"===t.getAttribute("name")||t.querySelector('profile[typeName$="Wargear"]')||t.querySelector('profile[typeName$="Shooting Weapon"]')){const e=null!==(x=t.getAttribute("name"))&&void 0!==x?x:"Equipment",n=parseInt(null!==(S=null===(E=t.querySelector('cost[name$="Points"]'))||void 0===E?void 0:E.getAttribute("value"))&&void 0!==S?S:"0"),r=[];for(let e of t.querySelectorAll("characteristics > characteristic"))null!==e.textContent&&r.push(e.textContent);W.push({name:e,points:n,rules:r})}t.querySelector('profile[typeName$="Warrior"]')&&(z=s(null===(A=null===(k=t.querySelector('profile[typeName$="Warrior"]'))||void 0===k?void 0:k.parentElement)||void 0===A?void 0:A.parentElement))}"Hero"===r&&(I=o(e))}}let j=0;for(let t of null!==(T=c(e))&&void 0!==T?T:[])"Points"===(null===(N=t.getAttribute("name"))||void 0===N?void 0:N.trim())&&(j=parseInt(null!==(L=t.getAttribute("value"))&&void 0!==L?L:"0"));return{name:P,points:j,keywords:O,rules:R,profile:{attack:F,courage:H,defense:D,fight:M,movement:B,strength:U,wounds:q},wargear:W,mount:z,heroStuff:I}},a=e=>{var t,n,r,i;const o=[];for(let a of null!==(t=l(e))&&void 0!==t?t:[]){const e=a.querySelector('selection[type~="model"]');if(null!==e){const t=s(a),l=parseInt(null!==(n=e.getAttribute("number"))&&void 0!==n?n:"0"),c=parseInt(null!==(i=null===(r=e.querySelector('cost[name~="Points"]'))||void 0===r?void 0:r.getAttribute("value"))&&void 0!==i?i:"0");o.push({model:t,count:l,points:c})}}return o},l=e=>{var t,n;return null!==(n=null===(t=e.querySelector("selections"))||void 0===t?void 0:t.querySelectorAll(":scope > selection"))&&void 0!==n?n:null},c=e=>{var t,n;return null!==(n=null===(t=e.querySelector("costs"))||void 0===t?void 0:t.querySelectorAll(":scope > cost"))&&void 0!==n?n:null},u=e=>{let t=null,n=[];const r=l(e);if(null===r)return r;for(let e of r)"model"===e.getAttribute("type")&&(t=s(e)),"Warband"===e.getAttribute("name")&&(n=a(e));return null!==t?{leader:t,warband:n}:null},d=e=>{var t;let n=!1;for(let r of null!==(t=l(e))&&void 0!==t?t:[])"model"===r.getAttribute("type")&&(n=!0);return n};t.CreateMESBGRoster=function(e){var t,n;if(e){const o=null!==(n=null===(t=e.querySelector("roster"))||void 0===t?void 0:t.getAttribute("name"))&&void 0!==n?n:"Middle-Earth Stratgegy Battle Game Roster",{points:s,warriors:a}=(e=>{var t,n,r,i;const o=e.querySelectorAll("roster>costs>cost");let s=0,a=0;for(let e of o)"Points"===(null===(t=e.getAttribute("name"))||void 0===t?void 0:t.trim())&&(s=parseInt(null!==(n=e.getAttribute("value"))&&void 0!==n?n:"0")),"Warriors"===(null===(r=e.getAttribute("name"))||void 0===r?void 0:r.trim())&&(a=parseInt(null!==(i=e.getAttribute("value"))&&void 0!==i?i:"0"));return{points:s,warriors:a}})(e),c=(e=>{var t,n,o;const s=e.querySelectorAll("roster>forces>force"),a=[];for(let e of s){const s=r(e);let c={half:0,quarter:0,modelCount:0};const h=[],f=[],p=l(e);if(null!==p){for(let e of p)if("Determine Breakpoint & 25%"===e.getAttribute("name"))c=i(e);else if(d(e)){const t=u(e);null!==t&&h.push(t)}else{const r=e.querySelectorAll("rules > rule");for(let e of r){const r=null!==(n=null===(t=e.querySelector("description"))||void 0===t?void 0:t.textContent)&&void 0!==n?n:"";f.push({name:null!==(o=e.getAttribute("name"))&&void 0!==o?o:"",ruleText:r})}}a.push({name:s,breakpoints:c,units:h,armyBonus:f})}}return a})(e);return{name:o,forces:c,points:s,warriors:a}}return alert("Bad Input File"),null}},320:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateWarcryRoster=t.RosterWarcry=t.WarcryForce=t.WarcryUnit=t.WarcryDamageTable=t.WarcryUnitRoleToString=t.WarcryUnitRole=t.WarcryWeapon=t.WarcryAllegiance=void 0;class n{constructor(){this._name="",this._rules=new Map}}t.WarcryAllegiance=n;class r{constructor(){this._name="",this._range="",this._attacks="",this._strength="",this._damage=""}}var i;t.WarcryWeapon=r,function(e){e[e.NONE=0]="NONE",e[e.LEADER=1]="LEADER",e[e.FIGHTER=2]="FIGHTER",e[e.ALLY=3]="ALLY",e[e.MONSTER=4]="MONSTER",e[e.HERO=5]="HERO",e[e.THRALL=6]="THRALL"}(i=t.WarcryUnitRole||(t.WarcryUnitRole={})),t.WarcryUnitRoleToString=["None","Leader","Fighter","Ally","Monster","Hero","Thrall"];class o{constructor(){this._name="",this._table=new Map}}t.WarcryDamageTable=o;class s{constructor(){this._name="",this._role=i.NONE,this._faction="chaos-iron-golems",this._keywords=new Set,this._abilities=new Map,this._move="1",this._wounds="1",this._toughness="1",this._weapons=[],this._damageTable=[],this._points=0}}t.WarcryUnit=s;class a{constructor(){this._catalog="",this._name="Unknown",this._units=[],this._allegiance=new n}}t.WarcryForce=a;class l{constructor(){this._points=0,this._name="",this._forces=[]}}function c(e){const t=e.toLowerCase();return t.includes("chaotic beasts")?"monster-chaotic-beasts":t.includes("monster")?t.includes("order")?"monster-of-order":t.includes("destruction")?"monster-of-destruction":t.includes("death")?"monster-of-death":"monster-chaotic-beasts":t.includes("beasts of chaos")?"factions-chaos-beasts-of-chaos":t.includes("corvus")?"factions-chaos-corvus-cabal":t.includes("cypher")?"factions-chaos-cypher-lords":t.includes("everchosen")?"factions-chaos-everchosen":t.includes("golems")?"factions-chaos-iron-golems":t.includes("khorne")&&t.includes("bloodbound")?"factions-chaos-khorne-bloodbound":t.includes("khorne")&&t.includes("daemon")?"factions-chaos-khorne-daemons":t.includes("nurgle")&&t.includes("rotbringer")?"factions-chaos-nurgle-rotbringers":t.includes("nurgle")&&t.includes("daemon")?"factions-chaos-nurgle-daemons":t.includes("scions")?"factions-chaos-scions-of-the-flame":t.includes("skaven")?"factions-chaos-skaven":t.includes("slaanesh")&&t.includes("sybariteI g")?"factions-chaos-slaanesh-syberites":t.includes("slaanesh")&&t.includes("daemon")?"factions-chaos-slaanesh-daemons":t.includes("slaves")?"factions-chaos-slaves-to-darkness":t.includes("spire")?"factions-chaos-spire-tyrants":t.includes("splintered")?"factions-chaos-splintered-fang":t.includes("unmade")?"factions-chaos-the-unmade":t.includes("tzeentch")&&t.includes("arcanite")?"factions-chaos-tzeentch-arcanites":t.includes("tzeentch")&&t.includes("daemon")?"factions-chaos-tzeentch-daemons":t.includes("untamed")?"factions-chaos-untamed-beasts":t.includes("flesh")?"factions-death-flesh-eater-courts":t.includes("nagash")?"factions-death-legions-of-nagash":t.includes("nighthaunt")?"factions-death-nighthaunt":t.includes("ossiarch")?"factions-death-ossiarch-bonereapers":t.includes("soulblight")?"factions-death-soulblight-gravelords":t.includes("bonesplitterz")?"factions-destruction-bonesplitterz":t.includes("fimirach")?"factions-destruction-fimirach":t.includes("gloomspite")?"factions-destruction-gloomspite-gitz":t.includes("ironjawz")?"factions-destruction-ironjawz":t.includes("kruleboyz")?"factions-destruction-kruleboyz":t.includes("ogor")?"factions-destruction-ogor-mawtribes":t.includes("cities of sigmar")?"factions-order-cities-of-sigmar":t.includes("khaine")?"factions-order-daughters-of-khaine":t.includes("fyreslayers")?"factions-order-fyreslayers":t.includes("idoneth")?"factions-order-idoneth-deepkin":t.includes("shadowstalkers")?"factions-order-khainite-shadowstalkers":t.includes("kharadron")?"factions-order-kharadron-overlords":t.includes("lumineth")?"factions-order-lumineth-realmlords":t.includes("seraphon")?"factions-order-seraphon":t.includes("stormcast")?t.includes("sacrosanct")?"factions-order-stormcast-eternals-sacrosanct":t.includes("thunderstrike")?"factions-order-stormcast-eternals-thunderstrike":t.includes("vanguard")?"factions-order-stormcast-eternals-vanguard":"factions-order-stormcast-eternals-warrior":t.includes("sylvaneth")?"factions-order-sylvaneth":""}function u(e,t){var r;let i=new n,o=e.querySelectorAll("rules>rule");for(let e of o)if(e.hasAttribute("name")){let t=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue;var s=e.querySelector("rule>description");t&&s&&s.textContent&&i._rules.set(t,s.textContent)}t._allegiance=i}function d(e,t){var n,r;let o=e.querySelectorAll("force>selections>selection");for(let e of o){if(!(null===(n=e.getAttributeNode("type"))||void 0===n?void 0:n.nodeValue))continue;if(!(null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue))continue;let o=h(e);o&&o._role!=i.NONE&&t._units.push(o)}t._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?0:-1))}function h(e){var t,n,a,l,u,d,h,f,p;let _=new s,m=e.querySelectorAll("profiles>profile");for(let e of m){let i=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue,s=null===(n=e.getAttributeNode("typeName"))||void 0===n?void 0:n.nodeValue;if(i&&s)if("Model"==s){_._name=i;let t=e.querySelectorAll("characteristics>characteristic");for(let e of t){let t=null===(a=e.getAttributeNode("name"))||void 0===a?void 0:a.nodeValue;if(t&&e.textContent)switch(t){case"Move":_._move=e.textContent;break;case"Wounds":_._wounds=e.textContent;break;case"Toughness":_._toughness=e.textContent}}}else if("Weapon"==s){let t=new r;t._name=i;let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let n=null===(l=e.getAttributeNode("name"))||void 0===l?void 0:l.nodeValue;if(n&&e.textContent)switch(n){case"Range":t._range=e.textContent;break;case"Attacks":t._attacks=e.textContent;break;case"Strength":t._strength=e.textContent;break;case"Damage":t._damage=e.textContent}}_._weapons.push(t)}else if("Damage Points Allocated"==s){let t=new o;t._name=i;let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let n=null===(u=e.getAttributeNode("name"))||void 0===u?void 0:u.nodeValue;n&&i&&(e.textContent?t._table.set(n,e.textContent):t._table.set(n,"-"))}_._damageTable.push(t)}else console.log("Unknown unit profile type: "+s)}let g=e.querySelectorAll("costs>cost");for(let e of g)if(e.hasAttribute("name")&&e.hasAttribute("value")){let t=null===(d=e.getAttributeNode("name"))||void 0===d?void 0:d.nodeValue,n=null===(h=e.getAttributeNode("value"))||void 0===h?void 0:h.nodeValue;n&&"pts"===t&&(_._points+=+n)}let v=e.querySelectorAll(":scope categories>category");for(let e of v){let t=null===(f=e.getAttributeNode("name"))||void 0===f?void 0:f.nodeValue;if(t){var b=(y=t.trim()).includes("Leader")?i.LEADER:y.includes("Fighter")?i.FIGHTER:y.includes("Allies")||y.includes("Ally")?i.ALLY:y.includes("Monster")?i.MONSTER:y.includes("Hero")?i.HERO:y.includes("Thrall")?i.THRALL:i.NONE;b!=i.NONE?_._role=b:_._keywords.add(t)}}var y;let w=e.querySelectorAll(":scope selections>selection");for(let e of w){let t=null===(p=e.getAttributeNode("name"))||void 0===p?void 0:p.nodeValue;if(t){let e=c(t);e.length>0?_._faction=e:_._keywords.add(t)}}return _}t.RosterWarcry=l,t.CreateWarcryRoster=function(e){var t;if(e){let n=e.querySelector("roster");if(n){const r=new l,i=null===(t=n.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;return r._name=i||"Age of Sigmar Warcry Roster",function(e,t){var n,r;let i=e.querySelectorAll("roster>costs>cost");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("value")){let i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("value"))||void 0===r?void 0:r.nodeValue;o&&"pts"===i&&(t._points=+o)}}(e,r),function(e,t){var n,r;let i=e.querySelectorAll("roster>forces>force");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let i=new a,o=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("catalogueName"))||void 0===r?void 0:r.nodeValue;o&&(i._name=o),s&&(i._catalog=s),u(e,i),d(e,i),t._forces.push(i)}console.log(t)}(e,r),r}}return null}},596:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.formatStat=t.filterAndOrderStats=void 0,t.filterAndOrderStats=function(e){return Object.entries(e).filter((e=>e[1].statOrder>=0&&void 0===e[1].groupOrder&&"normal"===e[1].visibility)).sort(((e,t)=>e[1].statOrder-t[1].statOrder))},t.formatStat=function(e){const t=String(e.value);return e.format?e.format.replace(/{[vt]}/,t):t}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),n(752)})(); \ No newline at end of file diff --git a/src/renderer40k10th.tsx b/src/renderer40k10th.tsx index efcc9b6..3ad1bab 100644 --- a/src/renderer40k10th.tsx +++ b/src/renderer40k10th.tsx @@ -555,10 +555,18 @@ export class Wh40kRenderer implements Renderer { - Keywords - {Array.from(unit._keywords).sort(Wh40k.Compare).join(', ').toLocaleUpperCase()} - Factions - {Array.from(unit._factions).sort(Wh40k.Compare).join(', ').toLocaleUpperCase()} + +
+
+
Keywords
+
{Array.from(unit._keywords).sort(Wh40k.Compare).join(', ').toLocaleUpperCase()}
+
+
+
Factions
+
{Array.from(unit._factions).sort(Wh40k.Compare).join(', ').toLocaleUpperCase()}
+
+
+ @@ -581,7 +589,7 @@ export class Wh40kRenderer implements Renderer { }) as [Wh40k.TabularProfile, number[]][]; ; - return + return
{entries.map(([table, widths]) => <> @@ -589,7 +597,7 @@ export class Wh40kRenderer implements Renderer { scope='col' colspan={Math.round(width / 0.05)} style={`width: ${width * 100}%;`}> - {table._headers[i]} + {this.renderProfileTableHeaderCell(table._headers[i])} )} @@ -607,22 +615,36 @@ export class Wh40kRenderer implements Renderer {
; } + private renderProfileTableHeaderCell(name: string) { + if (name === 'Ranged Weapons' || name === 'Melee Weapons') { + return <> + {name}{name.replace(' Weapons', '')} + + } else if (name === 'Range') { + return <> + {name}Rng + + } else { + return <>{name}; + } + } + private renderUnitAbilitiesAndRules(abilitiesGroup: string, abilitiesMap: Map, rulesMap?: Map) { return <> - {abilitiesGroup} + {abilitiesGroup} {/* Reverse the stripe coloring to start with white. */} {/* TODO remove the nested div; it was added to confirm TSX transition */} {rulesMap && rulesMap.size > 0 && -
+
{Array.from(rulesMap.keys()).sort(Wh40k.Compare).join(', ')}
} {Array.from(abilitiesMap.keys()).sort(Wh40k.Compare).map(ability => -
+
{`${ability.toUpperCase()}: `} {abilitiesMap.get(ability) || '??'}
)} From 14126b094eacef5c220f4076f49b7920b2b0517a Mon Sep 17 00:00:00 2001 From: mardanbeigi Date: Sun, 3 Nov 2024 11:59:18 -0500 Subject: [PATCH 2/2] 40k: mobile UI part 2 Update weapon profile tables to support mobile UI: - switch from table to flex - in mobile UI, move the keywords column to a second row for weapons - if there are no keywords (or if it's '-'), it won't be shown - force single column on mobile - support mobile printing without using mobile UI --- css/prettyscribe.css | 156 +++++++++++++++++++++++++++++++++++++--- dist/prettyscribe.js | 2 +- src/renderer40k10th.tsx | 47 +++++------- 3 files changed, 167 insertions(+), 38 deletions(-) diff --git a/css/prettyscribe.css b/css/prettyscribe.css index 5765087..b90a93f 100644 --- a/css/prettyscribe.css +++ b/css/prettyscribe.css @@ -422,35 +422,175 @@ label { margin-top: -1px; /* not sure why this is necessary */ } +.wh40k_unit_sheet > table > * > * > td.subTableTd > div > table { + margin-bottom: 0; +} + body.single_column .wh40k_unit_sheet > table > * > * > td.subTableTd > div { flex-direction: column; } - -.wh40k_unit_sheet > table > * > * > td.subTableTd > div > table { - margin-bottom: 0; +/* Mobile */ +@media only screen and (width <= 768px) { + body .wh40k_unit_sheet > table > * > * > td.subTableTd > div { + flex-direction: column; + } } -body:not(.single_column) .wh40k_unit_sheet > table > * > * > td.subTableTd > div > table:first-child { +body .wh40k_unit_sheet > table > * > * > td.subTableTd > div > *:first-child { border-right: 1px solid black; width: 60%; } -body.single_column .wh40k_unit_sheet > table > * > * > td.subTableTd > div > table:last-child { - border-top: 1px solid black; +body.single_column .wh40k_unit_sheet > table > * > * > td.subTableTd > div > *:first-child { + border-right: 0px solid black; + width: 100%; +} + +/* Mobile */ +@media only screen and (width <= 768px) { + body .wh40k_unit_sheet > table > * > * > td.subTableTd > div > *:first-child { + border-right: 0px solid black; + width: 100%; + } } -body:not(.single_column) .wh40k_unit_sheet > table > * > * > td.subTableTd > div > table:last-child { - border-left: 1px solid black; +body .wh40k_unit_sheet > table > * > * > td.subTableTd > div > table:last-child { + border-left: 1px solid black; /* for double-column layout */ margin-left: -1px; /* counter overlap between left and right columns' shared border */ width: 40%; } +body.single_column .wh40k_unit_sheet > table > * > * > td.subTableTd > div > table:last-child { + border-top: 1px solid black; + border-left: unset; + margin-left: unset; + width: 100%; +} + +/* Mobile */ +@media only screen and (width <= 768px) { + body .wh40k_unit_sheet > table > * > * > td.subTableTd > div > table:last-child { + border-top: 1px solid black; + border-left: unset; + margin-left: unset; + width: 100%; + } +} + .wh40k_rules > div > p { white-space: pre-wrap; line-height: 1; } +.wh40k_unit_profile_table, +.wh40k_weapon_profile_table { + width: 100%; +} + +.wh40k_unit_profile_table > div, +.wh40k_weapon_profile_table > div { + display: flex; + flex-wrap: wrap; +} + +.wh40k_unit_profile_table > div:nth-of-type(odd), +.wh40k_weapon_profile_table > div:nth-of-type(odd) { + background-color: var(--bs-table-striped-bg); +} + +.wh40k_unit_profile_table > div:first-child, +.wh40k_weapon_profile_table > div:first-child { + background-color: var(--bs-table-active-bg); + text-transform: uppercase; + white-space: nowrap; + font-weight: bold; + border-top: 1px solid black; + border-bottom: 1px solid black; +} + +.wh40k_unit_profile_table:first-child > div:first-child, +.wh40k_weapon_profile_table:first-child > div:first-child { + border-top: 0px; +} + +.wh40k_unit_profile_table > div:not(:first-child), +.wh40k_weapon_profile_table > div:not(:first-child) { + border-bottom: 1px solid var(--bs-table-active-bg); +} + +.wh40k_unit_profile_table > div:first-child > div, +.wh40k_weapon_profile_table > div:first-child > div { + padding: 0.25rem 0; +} + +.wh40k_unit_profile_table > div:not(:first-child) > div, +.wh40k_weapon_profile_table > div:not(:first-child) > div { + padding: 0.05rem 0; +} + +.wh40k_unit_profile_table > div > div, +.wh40k_weapon_profile_table > div > div { + flex-basis: 5%; +} + +.wh40k_unit_profile_table > div > div:first-child { + flex-basis: 40%; + padding-left: var(--notchSize); +} + +.wh40k_weapon_profile_table > div > div:first-child { + flex-basis: 30%; + padding-left: var(--notchSize); +} + +.wh40k_weapon_profile_table > div > div:nth-child(2), +.wh40k_weapon_profile_table > div > div:nth-child(3) { + flex-basis: 10%; +} + +.wh40k_weapon_profile_table > div > div:last-child { + flex-basis: 30%; +} + +.wh40k_unit_profile_table > div > div:not(:first-child), +.wh40k_weapon_profile_table > div > div:not(:first-child):not(:last-child) { + text-align: center; +} + +/* Mobile */ +@media only screen and (width <= 768px) { + .wh40k_unit_profile_table > div > div, + .wh40k_weapon_profile_table > div > div { + flex-basis: 8%; + flex-shrink: 0; + } + + .wh40k_unit_profile_table > div > div:first-child, + .wh40k_weapon_profile_table > div > div:first-child { + /* Leave some space for long attributes like D6+3 in other columns */ + flex-basis: 46%; + } + + .wh40k_weapon_profile_table > div > div:nth-child(2) { + flex-basis: 12%; + } + + .wh40k_weapon_profile_table > div > div:nth-child(3) { + flex-basis: 8%; + } + + .wh40k_weapon_profile_table > div:first-child > div:last-child { + display: none; /* Hide the Keywords column */ + } + + .wh40k_weapon_profile_table > div > div:last-child { + flex-basis: 100%; + font-style: italic; + padding-left: calc(2 * var(--notchSize)); + } +} + .wh40k_keywords_and_factions, .wh40k_keywords, .wh40k_factions { diff --git a/dist/prettyscribe.js b/dist/prettyscribe.js index d378adf..2fa217d 100644 --- a/dist/prettyscribe.js +++ b/dist/prettyscribe.js @@ -1,2 +1,2 @@ /*! For license information please see prettyscribe.js.LICENSE.txt */ -(()=>{var e={733:(e,t,n)=>{e.exports=function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[s]={exports:{}};t[s][0].call(c.exports,(function(e){return i(t[s][1][e]||e)}),c,c.exports,e,t,n,r)}return n[s].exports}for(var o=void 0,s=0;s>2,a=(3&t)<<4|n>>4,l=1>6:64,c=2>4,n=(15&s)<<4|(a=o.indexOf(e.charAt(c++)))>>2,r=(3&a)<<6|(l=o.indexOf(e.charAt(c++))),h[u++]=t,64!==a&&(h[u++]=n),64!==l&&(h[u++]=r);return h}},{"./support":30,"./utils":32}],2:[function(e,t,n){"use strict";var r=e("./external"),i=e("./stream/DataWorker"),o=e("./stream/Crc32Probe"),s=e("./stream/DataLengthProbe");function a(e,t,n,r,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=n,this.compression=r,this.compressedContent=i}a.prototype={getContentWorker:function(){var e=new i(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new s("data_length")),t=this;return e.on("end",(function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),e},getCompressedWorker:function(){return new i(r.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},a.createWorkerFrom=function(e,t,n){return e.pipe(new o).pipe(new s("uncompressedSize")).pipe(t.compressWorker(n)).pipe(new s("compressedSize")).withStreamInfo("compression",t)},t.exports=a},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,n){"use strict";var r=e("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(e){return new r("STORE compression")},uncompressWorker:function(){return new r("STORE decompression")}},n.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,n){"use strict";var r=e("./utils"),i=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==r.getTypeOf(e)?function(e,t,n,r){var o=i,s=0+n;e^=-1;for(var a=0;a>>8^o[255&(e^t[a])];return-1^e}(0|t,e,e.length):function(e,t,n,r){var o=i,s=0+n;e^=-1;for(var a=0;a>>8^o[255&(e^t.charCodeAt(a))];return-1^e}(0|t,e,e.length):0}},{"./utils":32}],5:[function(e,t,n){"use strict";n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(e,t,n){"use strict";var r;r="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:r}},{lie:37}],7:[function(e,t,n){"use strict";var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=e("pako"),o=e("./utils"),s=e("./stream/GenericWorker"),a=r?"uint8array":"array";function l(e,t){s.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}n.magic="\b\0",o.inherits(l,s),l.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(o.transformTo(a,e.data),!1)},l.prototype.flush=function(){s.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},l.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this._pako=null},l.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},n.compressWorker=function(e){return new l("Deflate",e)},n.uncompressWorker=function(){return new l("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,n){"use strict";function r(e,t){var n,r="";for(n=0;n>>=8;return r}function i(e,t,n,i,s,u){var d,h,f=e.file,p=e.compression,_=u!==a.utf8encode,m=o.transformTo("string",u(f.name)),g=o.transformTo("string",a.utf8encode(f.name)),v=f.comment,b=o.transformTo("string",u(v)),y=o.transformTo("string",a.utf8encode(v)),w=g.length!==f.name.length,C=y.length!==v.length,x="",E="",S="",k=f.dir,A=f.date,T={crc32:0,compressedSize:0,uncompressedSize:0};t&&!n||(T.crc32=e.crc32,T.compressedSize=e.compressedSize,T.uncompressedSize=e.uncompressedSize);var N=0;t&&(N|=8),_||!w&&!C||(N|=2048);var L=0,R=0;k&&(L|=16),"UNIX"===s?(R=798,L|=function(e,t){var n=e;return e||(n=t?16893:33204),(65535&n)<<16}(f.unixPermissions,k)):(R=20,L|=function(e){return 63&(e||0)}(f.dosPermissions)),d=A.getUTCHours(),d<<=6,d|=A.getUTCMinutes(),d<<=5,d|=A.getUTCSeconds()/2,h=A.getUTCFullYear()-1980,h<<=4,h|=A.getUTCMonth()+1,h<<=5,h|=A.getUTCDate(),w&&(E=r(1,1)+r(l(m),4)+g,x+="up"+r(E.length,2)+E),C&&(S=r(1,1)+r(l(b),4)+y,x+="uc"+r(S.length,2)+S);var P="";return P+="\n\0",P+=r(N,2),P+=p.magic,P+=r(d,2),P+=r(h,2),P+=r(T.crc32,4),P+=r(T.compressedSize,4),P+=r(T.uncompressedSize,4),P+=r(m.length,2),P+=r(x.length,2),{fileRecord:c.LOCAL_FILE_HEADER+P+m+x,dirRecord:c.CENTRAL_FILE_HEADER+r(R,2)+P+r(b.length,2)+"\0\0\0\0"+r(L,4)+r(i,4)+m+x+b}}var o=e("../utils"),s=e("../stream/GenericWorker"),a=e("../utf8"),l=e("../crc32"),c=e("../signature");function u(e,t,n,r){s.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=n,this.encodeFileName=r,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(u,s),u.prototype.push=function(e){var t=e.meta.percent||0,n=this.entriesCount,r=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,s.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:n?(t+100*(n-r-1))/n:100}}))},u.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var n=i(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:n.fileRecord,meta:{percent:0}})}else this.accumulate=!0},u.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,n=i(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(n.dirRecord),t)this.push({data:function(e){return c.DATA_DESCRIPTOR+r(e.crc32,4)+r(e.compressedSize,4)+r(e.uncompressedSize,4)}(e),meta:{percent:100}});else for(this.push({data:n.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},u.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t=this.index;t--)n=(n<<8)+this.byteAt(t);return this.index+=e,n},readString:function(e){return r.transformTo("string",this.readData(e))},readData:function(e){},lastIndexOfSignature:function(e){},readAndCheckSignature:function(e){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i},{"../utils":32}],19:[function(e,t,n){"use strict";var r=e("./Uint8ArrayReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,n){"use strict";var r=e("./DataReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],21:[function(e,t,n){"use strict";var r=e("./ArrayReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,n){"use strict";var r=e("../utils"),i=e("../support"),o=e("./ArrayReader"),s=e("./StringReader"),a=e("./NodeBufferReader"),l=e("./Uint8ArrayReader");t.exports=function(e){var t=r.getTypeOf(e);return r.checkSupport(t),"string"!==t||i.uint8array?"nodebuffer"===t?new a(e):i.uint8array?new l(r.transformTo("uint8array",e)):new o(r.transformTo("array",e)):new s(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,n){"use strict";n.LOCAL_FILE_HEADER="PK",n.CENTRAL_FILE_HEADER="PK",n.CENTRAL_DIRECTORY_END="PK",n.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",n.ZIP64_CENTRAL_DIRECTORY_END="PK",n.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,n){"use strict";var r=e("./GenericWorker"),i=e("../utils");function o(e){r.call(this,"ConvertWorker to "+e),this.destType=e}i.inherits(o,r),o.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta})},t.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,n){"use strict";var r=e("./GenericWorker"),i=e("../crc32");function o(){r.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(o,r),o.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,n){"use strict";var r=e("../utils"),i=e("./GenericWorker");function o(e){i.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}r.inherits(o,i),o.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}i.prototype.processChunk.call(this,e)},t.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,n){"use strict";var r=e("../utils"),i=e("./GenericWorker");function o(e){i.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then((function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=r.getTypeOf(e),t.isPaused||t._tickAndRepeat()}),(function(e){t.error(e)}))}r.inherits(o,i),o.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,n){"use strict";function r(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}r.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var n=0;n "+e:e}},t.exports=r},{}],29:[function(e,t,n){"use strict";var r=e("../utils"),i=e("./ConvertWorker"),o=e("./GenericWorker"),s=e("../base64"),a=e("../support"),l=e("../external"),c=null;if(a.nodestream)try{c=e("../nodejs/NodejsStreamOutputAdapter")}catch(e){}function u(e,t,n){var s=t;switch(t){case"blob":case"arraybuffer":s="uint8array";break;case"base64":s="string"}try{this._internalType=s,this._outputType=t,this._mimeType=n,r.checkSupport(s),this._worker=e.pipe(new i(s)),e.lock()}catch(e){this._worker=new o("error"),this._worker.error(e)}}u.prototype={accumulate:function(e){return function(e,t){return new l.Promise((function(n,i){var o=[],a=e._internalType,l=e._outputType,c=e._mimeType;e.on("data",(function(e,n){o.push(e),t&&t(n)})).on("error",(function(e){o=[],i(e)})).on("end",(function(){try{var e=function(e,t,n){switch(e){case"blob":return r.newBlob(r.transformTo("arraybuffer",t),n);case"base64":return s.encode(t);default:return r.transformTo(e,t)}}(l,function(e,t){var n,r=0,i=null,o=0;for(n=0;n>>6:(n<65536?t[s++]=224|n>>>12:(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63),t[s++]=128|n>>>6&63),t[s++]=128|63&n);return t}(e)},n.utf8decode=function(e){return i.nodebuffer?r.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,n,i,o,s=e.length,l=new Array(2*s);for(t=n=0;t>10&1023,l[n++]=56320|1023&i)}return l.length!==n&&(l.subarray?l=l.subarray(0,n):l.length=n),r.applyFromCharCode(l)}(e=r.transformTo(i.uint8array?"uint8array":"array",e))},r.inherits(c,s),c.prototype.processChunk=function(e){var t=r.transformTo(i.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var o=t;(t=new Uint8Array(o.length+this.leftOver.length)).set(this.leftOver,0),t.set(o,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var s=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+a[e[n]]>t?n:t}(t),l=t;s!==t.length&&(i.uint8array?(l=t.subarray(0,s),this.leftOver=t.subarray(s,t.length)):(l=t.slice(0,s),this.leftOver=t.slice(s,t.length))),this.push({data:n.utf8decode(l),meta:e.meta})},c.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=c,r.inherits(u,s),u.prototype.processChunk=function(e){this.push({data:n.utf8encode(e.data),meta:e.meta})},n.Utf8EncodeWorker=u},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,n){"use strict";var r=e("./support"),i=e("./base64"),o=e("./nodejsUtils"),s=e("./external");function a(e){return e}function l(e,t){for(var n=0;n>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(e){if(this.extraFields[1]){var t=r(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=t.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=t.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=t.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=t.readInt(4))}},readExtraFields:function(e){var t,n,r,i=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4>>6:(n<65536?t[s++]=224|n>>>12:(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63),t[s++]=128|n>>>6&63),t[s++]=128|63&n);return t},n.buf2binstring=function(e){return l(e,e.length)},n.binstring2buf=function(e){for(var t=new r.Buf8(e.length),n=0,i=t.length;n>10&1023,c[r++]=56320|1023&i)}return l(c,r)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+s[e[n]]>t?n:t}},{"./common":41}],43:[function(e,t,n){"use strict";t.exports=function(e,t,n,r){for(var i=65535&e|0,o=e>>>16&65535|0,s=0;0!==n;){for(n-=s=2e3>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,i){var o=r,s=i+n;e^=-1;for(var a=i;a>>8^o[255&(e^t[a])];return-1^e}},{}],46:[function(e,t,n){"use strict";var r,i=e("../utils/common"),o=e("./trees"),s=e("./adler32"),a=e("./crc32"),l=e("./messages"),c=-2,u=258,d=262,h=113;function f(e,t){return e.msg=l[t],t}function p(e){return(e<<1)-(4e.avail_out&&(n=e.avail_out),0!==n&&(i.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))}function g(e,t){o._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,m(e.strm)}function v(e,t){e.pending_buf[e.pending++]=t}function b(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function y(e,t){var n,r,i=e.max_chain_length,o=e.strstart,s=e.prev_length,a=e.nice_match,l=e.strstart>e.w_size-d?e.strstart-(e.w_size-d):0,c=e.window,h=e.w_mask,f=e.prev,p=e.strstart+u,_=c[o+s-1],m=c[o+s];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(c[(n=t)+s]===m&&c[n+s-1]===_&&c[n]===c[o]&&c[++n]===c[o+1]){o+=2,n++;do{}while(c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&ol&&0!=--i);return s<=e.lookahead?s:e.lookahead}function w(e){var t,n,r,o,l,c,u,h,f,p,_=e.w_size;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=_+(_-d)){for(i.arraySet(e.window,e.window,_,_,0),e.match_start-=_,e.strstart-=_,e.block_start-=_,t=n=e.hash_size;r=e.head[--t],e.head[t]=_<=r?r-_:0,--n;);for(t=n=_;r=e.prev[--t],e.prev[t]=_<=r?r-_:0,--n;);o+=_}if(0===e.strm.avail_in)break;if(c=e.strm,u=e.window,h=e.strstart+e.lookahead,p=void 0,(f=o)<(p=c.avail_in)&&(p=f),n=0===p?0:(c.avail_in-=p,i.arraySet(u,c.input,c.next_in,p,h),1===c.state.wrap?c.adler=s(c.adler,u,p,h):2===c.state.wrap&&(c.adler=a(c.adler,u,p,h)),c.next_in+=p,c.total_in+=p,p),e.lookahead+=n,e.lookahead+e.insert>=3)for(l=e.strstart-e.insert,e.ins_h=e.window[l],e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<=3)if(r=o._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<=3&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-3,r=o._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(w(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((0===e.strstart||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,g(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-d&&(g(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(g(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(g(e,!1),e.strm.avail_out),1)})),new E(4,4,8,4,C),new E(4,5,16,8,C),new E(4,6,32,32,C),new E(4,4,16,16,x),new E(8,16,32,32,x),new E(8,16,128,128,x),new E(8,32,128,256,x),new E(32,128,258,1024,x),new E(32,258,258,4096,x)],n.deflateInit=function(e,t){return T(e,t,8,15,8,0)},n.deflateInit2=T,n.deflateReset=A,n.deflateResetKeep=k,n.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?c:(e.state.gzhead=t,0):c},n.deflate=function(e,t){var n,i,s,l;if(!e||!e.state||5>8&255),v(i,i.gzhead.time>>16&255),v(i,i.gzhead.time>>24&255),v(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),v(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(v(i,255&i.gzhead.extra.length),v(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=a(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(v(i,0),v(i,0),v(i,0),v(i,0),v(i,0),v(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),v(i,3),i.status=h);else{var d=8+(i.w_bits-8<<4)<<8;d|=(2<=i.strategy||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(d|=32),d+=31-d%31,i.status=h,b(i,d),0!==i.strstart&&(b(i,e.adler>>>16),b(i,65535&e.adler)),e.adler=1}if(69===i.status)if(i.gzhead.extra){for(s=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),m(e),s=i.pending,i.pending!==i.pending_buf_size));)v(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){s=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),m(e),s=i.pending,i.pending===i.pending_buf_size)){l=1;break}l=i.gzindexs&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),0===l&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){s=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),m(e),s=i.pending,i.pending===i.pending_buf_size)){l=1;break}l=i.gzindexs&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),0===l&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&m(e),i.pending+2<=i.pending_buf_size&&(v(i,255&e.adler),v(i,e.adler>>8&255),e.adler=0,i.status=h)):i.status=h),0!==i.pending){if(m(e),0===e.avail_out)return i.last_flush=-1,0}else if(0===e.avail_in&&p(t)<=p(n)&&4!==t)return f(e,-5);if(666===i.status&&0!==e.avail_in)return f(e,-5);if(0!==e.avail_in||0!==i.lookahead||0!==t&&666!==i.status){var y=2===i.strategy?function(e,t){for(var n;;){if(0===e.lookahead&&(w(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(g(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(g(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(g(e,!1),0===e.strm.avail_out)?1:2}(i,t):3===i.strategy?function(e,t){for(var n,r,i,s,a=e.window;;){if(e.lookahead<=u){if(w(e),e.lookahead<=u&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&0e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=o._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(g(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(g(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(g(e,!1),0===e.strm.avail_out)?1:2}(i,t):r[i.level].func(i,t);if(3!==y&&4!==y||(i.status=666),1===y||3===y)return 0===e.avail_out&&(i.last_flush=-1),0;if(2===y&&(1===t?o._tr_align(i):5!==t&&(o._tr_stored_block(i,0,0,!1),3===t&&(_(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),m(e),0===e.avail_out))return i.last_flush=-1,0}return 4!==t?0:i.wrap<=0?1:(2===i.wrap?(v(i,255&e.adler),v(i,e.adler>>8&255),v(i,e.adler>>16&255),v(i,e.adler>>24&255),v(i,255&e.total_in),v(i,e.total_in>>8&255),v(i,e.total_in>>16&255),v(i,e.total_in>>24&255)):(b(i,e.adler>>>16),b(i,65535&e.adler)),m(e),0=n.w_size&&(0===a&&(_(n.head),n.strstart=0,n.block_start=0,n.insert=0),h=new i.Buf8(n.w_size),i.arraySet(h,t,f-n.w_size,n.w_size,0),t=h,f=n.w_size),l=e.avail_in,u=e.next_in,d=e.input,e.avail_in=f,e.next_in=0,e.input=t,w(n);n.lookahead>=3;){for(r=n.strstart,o=n.lookahead-2;n.ins_h=(n.ins_h<>>=y=b>>>24,p-=y,0==(y=b>>>16&255))k[o++]=65535&b;else{if(!(16&y)){if(0==(64&y)){b=_[(65535&b)+(f&(1<>>=y,p-=y),p<15&&(f+=S[r++]<>>=y=b>>>24,p-=y,!(16&(y=b>>>16&255))){if(0==(64&y)){b=m[(65535&b)+(f&(1<>>=y,p-=y,(y=o-s)>3,f&=(1<<(p-=w<<3))-1,e.next_in=r,e.next_out=o,e.avail_in=r>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function u(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function d(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new r.Buf32(852),t.distcode=t.distdyn=new r.Buf32(592),t.sane=1,t.back=-1,0):l}function h(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,d(e)):l}function f(e,t){var n,r;return e&&e.state?(r=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15=s.wsize?(r.arraySet(s.window,t,n-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(i<(o=s.wsize-s.wnext)&&(o=i),r.arraySet(s.window,t,n-i,o,s.wnext),(i-=o)?(r.arraySet(s.window,t,n-i,i,0),s.wnext=i,s.whave=s.wsize):(s.wnext+=o,s.wnext===s.wsize&&(s.wnext=0),s.whave>>8&255,n.check=o(n.check,I,2,0),g=m=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&m)<<8)+(m>>8))%31){e.msg="incorrect header check",n.mode=30;break}if(8!=(15&m)){e.msg="unknown compression method",n.mode=30;break}if(g-=4,R=8+(15&(m>>>=4)),0===n.wbits)n.wbits=R;else if(R>n.wbits){e.msg="invalid window size",n.mode=30;break}n.dmax=1<>8&1),512&n.flags&&(I[0]=255&m,I[1]=m>>>8&255,n.check=o(n.check,I,2,0)),g=m=0,n.mode=3;case 3:for(;g<32;){if(0===p)break e;p--,m+=u[h++]<>>8&255,I[2]=m>>>16&255,I[3]=m>>>24&255,n.check=o(n.check,I,4,0)),g=m=0,n.mode=4;case 4:for(;g<16;){if(0===p)break e;p--,m+=u[h++]<>8),512&n.flags&&(I[0]=255&m,I[1]=m>>>8&255,n.check=o(n.check,I,2,0)),g=m=0,n.mode=5;case 5:if(1024&n.flags){for(;g<16;){if(0===p)break e;p--,m+=u[h++]<>>8&255,n.check=o(n.check,I,2,0)),g=m=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&(p<(C=n.length)&&(C=p),C&&(n.head&&(R=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),r.arraySet(n.head.extra,u,h,C,R)),512&n.flags&&(n.check=o(n.check,u,C,h)),p-=C,h+=C,n.length-=C),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===p)break e;for(C=0;R=u[h+C++],n.head&&R&&n.length<65536&&(n.head.name+=String.fromCharCode(R)),R&&C>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;g<32;){if(0===p)break e;p--,m+=u[h++]<>>=7&g,g-=7&g,n.mode=27;break}for(;g<3;){if(0===p)break e;p--,m+=u[h++]<>>=1)){case 0:n.mode=14;break;case 1:if(v(n),n.mode=20,6!==t)break;m>>>=2,g-=2;break e;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=30}m>>>=2,g-=2;break;case 14:for(m>>>=7&g,g-=7&g;g<32;){if(0===p)break e;p--,m+=u[h++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&m,g=m=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(C=n.length){if(p>>=5,g-=5,n.ndist=1+(31&m),m>>>=5,g-=5,n.ncode=4+(15&m),m>>>=4,g-=4,286>>=3,g-=3}for(;n.have<19;)n.lens[B[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,O={bits:n.lenbits},P=a(0,n.lens,0,19,n.lencode,0,n.work,O),n.lenbits=O.bits,P){e.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have>>16&255,A=65535&z,!((S=z>>>24)<=g);){if(0===p)break e;p--,m+=u[h++]<>>=S,g-=S,n.lens[n.have++]=A;else{if(16===A){for(W=S+2;g>>=S,g-=S,0===n.have){e.msg="invalid bit length repeat",n.mode=30;break}R=n.lens[n.have-1],C=3+(3&m),m>>>=2,g-=2}else if(17===A){for(W=S+3;g>>=S)),m>>>=3,g-=3}else{for(W=S+7;g>>=S)),m>>>=7,g-=7}if(n.have+C>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=30;break}for(;C--;)n.lens[n.have++]=R}}if(30===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,O={bits:n.lenbits},P=a(1,n.lens,0,n.nlen,n.lencode,0,n.work,O),n.lenbits=O.bits,P){e.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,O={bits:n.distbits},P=a(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,O),n.distbits=O.bits,P){e.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(6<=p&&258<=_){e.next_out=f,e.avail_out=_,e.next_in=h,e.avail_in=p,n.hold=m,n.bits=g,s(e,w),f=e.next_out,d=e.output,_=e.avail_out,h=e.next_in,u=e.input,p=e.avail_in,m=n.hold,g=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;k=(z=n.lencode[m&(1<>>16&255,A=65535&z,!((S=z>>>24)<=g);){if(0===p)break e;p--,m+=u[h++]<>T)])>>>16&255,A=65535&z,!(T+(S=z>>>24)<=g);){if(0===p)break e;p--,m+=u[h++]<>>=T,g-=T,n.back+=T}if(m>>>=S,g-=S,n.back+=S,n.length=A,0===k){n.mode=26;break}if(32&k){n.back=-1,n.mode=12;break}if(64&k){e.msg="invalid literal/length code",n.mode=30;break}n.extra=15&k,n.mode=22;case 22:if(n.extra){for(W=n.extra;g>>=n.extra,g-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;k=(z=n.distcode[m&(1<>>16&255,A=65535&z,!((S=z>>>24)<=g);){if(0===p)break e;p--,m+=u[h++]<>T)])>>>16&255,A=65535&z,!(T+(S=z>>>24)<=g);){if(0===p)break e;p--,m+=u[h++]<>>=T,g-=T,n.back+=T}if(m>>>=S,g-=S,n.back+=S,64&k){e.msg="invalid distance code",n.mode=30;break}n.offset=A,n.extra=15&k,n.mode=24;case 24:if(n.extra){for(W=n.extra;g>>=n.extra,g-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===_)break e;if(C=w-_,n.offset>C){if((C=n.offset-C)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=30;break}x=C>n.wnext?(C-=n.wnext,n.wsize-C):n.wnext-C,C>n.length&&(C=n.length),E=n.window}else E=d,x=f-n.offset,C=n.length;for(_v?(y=B[M+d[E]],O[W+d[E]]):(y=96,0),f=1<>N)+(p-=f)]=b<<24|y<<16|w|0,0!==p;);for(f=1<>=1;if(0!==f?(P&=f-1,P+=f):P=0,E++,0==--z[x]){if(x===k)break;x=t[n+d[E]]}if(A>>7)]}function S(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function k(e,t,n){e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<>>=1,n<<=1,0<--t;);return n>>>1}function N(e,t,n){var r,i,o=new Array(16),s=0;for(r=1;r<=l;r++)o[r]=s=s+n[r-1]<<1;for(i=0;i<=t;i++){var a=e[2*i+1];0!==a&&(e[2*i]=T(o[a]++,a))}}function L(e){var t;for(t=0;t>1;1<=n;n--)O(e,o,n);for(i=c;n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],O(e,o,1),r=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=r,o[2*i]=o[2*n]+o[2*r],e.depth[i]=(e.depth[n]>=e.depth[r]?e.depth[n]:e.depth[r])+1,o[2*n+1]=o[2*r+1]=i,e.heap[1]=i++,O(e,o,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,r,i,o,s,a,c=t.dyn_tree,u=t.max_code,d=t.stat_desc.static_tree,h=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,_=t.stat_desc.max_length,m=0;for(o=0;o<=l;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n<573;n++)_<(o=c[2*c[2*(r=e.heap[n])+1]+1]+1)&&(o=_,m++),c[2*r+1]=o,u>=7;r>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t>>3,(s=e.static_len+3+7>>>3)<=i&&(i=s)):i=s=n+5,n+4<=i&&-1!==t?U(e,t,n,r):4===e.strategy||s===i?(k(e,2+(r?1:0),3),W(e,f,p)):(k(e,4+(r?1:0),3),function(e,t,n,r){var i;for(k(e,t-257,5),k(e,n-1,5),k(e,r-4,4),i=0;i>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(m[n]+o+1)]++,e.dyn_dtree[2*E(t)]++),e.last_lit===e.lit_bufsize-1},n._tr_align=function(e){k(e,2,3),A(e,256,f),function(e){16===e.bi_valid?(S(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":41}],53:[function(e,t,n){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,r){(function(e){!function(e,t){"use strict";if(!e.setImmediate){var n,r,i,o,s=1,a={},l=!1,c=e.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(e);u=u&&u.setTimeout?u:e,n="[object process]"==={}.toString.call(e.process)?function(e){process.nextTick((function(){h(e)}))}:function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?(o="setImmediate$"+Math.random()+"$",e.addEventListener?e.addEventListener("message",f,!1):e.attachEvent("onmessage",f),function(t){e.postMessage(o+t,"*")}):e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){h(e.data)},function(e){i.port2.postMessage(e)}):c&&"onreadystatechange"in c.createElement("script")?(r=c.documentElement,function(e){var t=c.createElement("script");t.onreadystatechange=function(){h(e),t.onreadystatechange=null,r.removeChild(t),t=null},r.appendChild(t)}):function(e){setTimeout(h,0,e)},u.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r"']/g,J=RegExp(V.source),$=RegExp(Y.source),X=/<%-([\s\S]+?)%>/g,G=/<%([\s\S]+?)%>/g,Z=/<%=([\s\S]+?)%>/g,K=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Q=/^\w*$/,ee=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,te=/[\\^$.*+?()[\]{}|]/g,ne=RegExp(te.source),re=/^\s+/,ie=/\s/,oe=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,se=/\{\n\/\* \[wrapped with (.+)\] \*/,ae=/,? & /,le=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ce=/[()=,{}\[\]\/\s]/,ue=/\\(\\)?/g,de=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,he=/\w*$/,fe=/^[-+]0x[0-9a-f]+$/i,pe=/^0b[01]+$/i,_e=/^\[object .+?Constructor\]$/,me=/^0o[0-7]+$/i,ge=/^(?:0|[1-9]\d*)$/,ve=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,be=/($^)/,ye=/['\n\r\u2028\u2029\\]/g,we="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ce="a-z\\xdf-\\xf6\\xf8-\\xff",xe="A-Z\\xc0-\\xd6\\xd8-\\xde",Ee="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Se="["+Ee+"]",ke="["+we+"]",Ae="\\d+",Te="["+Ce+"]",Ne="[^\\ud800-\\udfff"+Ee+Ae+"\\u2700-\\u27bf"+Ce+xe+"]",Le="\\ud83c[\\udffb-\\udfff]",Re="[^\\ud800-\\udfff]",Pe="(?:\\ud83c[\\udde6-\\uddff]){2}",Oe="[\\ud800-\\udbff][\\udc00-\\udfff]",We="["+xe+"]",ze="(?:"+Te+"|"+Ne+")",Ie="(?:"+We+"|"+Ne+")",Be="(?:['’](?:d|ll|m|re|s|t|ve))?",Me="(?:['’](?:D|LL|M|RE|S|T|VE))?",Ue="(?:"+ke+"|"+Le+")?",De="[\\ufe0e\\ufe0f]?",Fe=De+Ue+"(?:\\u200d(?:"+[Re,Pe,Oe].join("|")+")"+De+Ue+")*",qe="(?:"+["[\\u2700-\\u27bf]",Pe,Oe].join("|")+")"+Fe,He="(?:"+[Re+ke+"?",ke,Pe,Oe,"[\\ud800-\\udfff]"].join("|")+")",je=RegExp("['’]","g"),Ve=RegExp(ke,"g"),Ye=RegExp(Le+"(?="+Le+")|"+He+Fe,"g"),Je=RegExp([We+"?"+Te+"+"+Be+"(?="+[Se,We,"$"].join("|")+")",Ie+"+"+Me+"(?="+[Se,We+ze,"$"].join("|")+")",We+"?"+ze+"+"+Be,We+"+"+Me,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ae,qe].join("|"),"g"),$e=RegExp("[\\u200d\\ud800-\\udfff"+we+"\\ufe0e\\ufe0f]"),Xe=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Ge=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Ze=-1,Ke={};Ke[O]=Ke[W]=Ke[z]=Ke[I]=Ke[B]=Ke[M]=Ke[U]=Ke[D]=Ke[F]=!0,Ke[_]=Ke[m]=Ke[R]=Ke[g]=Ke[P]=Ke[v]=Ke[b]=Ke[y]=Ke[C]=Ke[x]=Ke[E]=Ke[k]=Ke[A]=Ke[T]=Ke[L]=!1;var Qe={};Qe[_]=Qe[m]=Qe[R]=Qe[P]=Qe[g]=Qe[v]=Qe[O]=Qe[W]=Qe[z]=Qe[I]=Qe[B]=Qe[C]=Qe[x]=Qe[E]=Qe[k]=Qe[A]=Qe[T]=Qe[N]=Qe[M]=Qe[U]=Qe[D]=Qe[F]=!0,Qe[b]=Qe[y]=Qe[L]=!1;var et={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},tt=parseFloat,nt=parseInt,rt="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,it="object"==typeof self&&self&&self.Object===Object&&self,ot=rt||it||Function("return this")(),st=t&&!t.nodeType&&t,at=st&&e&&!e.nodeType&&e,lt=at&&at.exports===st,ct=lt&&rt.process,ut=function(){try{return at&&at.require&&at.require("util").types||ct&&ct.binding&&ct.binding("util")}catch(e){}}(),dt=ut&&ut.isArrayBuffer,ht=ut&&ut.isDate,ft=ut&&ut.isMap,pt=ut&&ut.isRegExp,_t=ut&&ut.isSet,mt=ut&&ut.isTypedArray;function gt(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function vt(e,t,n,r){for(var i=-1,o=null==e?0:e.length;++i-1}function Et(e,t,n){for(var r=-1,i=null==e?0:e.length;++r-1;);return n}function Jt(e,t){for(var n=e.length;n--&&Ot(t,e[n],0)>-1;);return n}function $t(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}var Xt=Mt({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"}),Gt=Mt({"&":"&","<":"<",">":">",'"':""","'":"'"});function Zt(e){return"\\"+et[e]}function Kt(e){return $e.test(e)}function Qt(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function en(e,t){return function(n){return e(t(n))}}function tn(e,t){for(var n=-1,r=e.length,i=0,o=[];++n",""":'"',"'":"'"}),cn=function e(t){var n,r=(t=null==t?ot:cn.defaults(ot.Object(),t,cn.pick(ot,Ge))).Array,ie=t.Date,we=t.Error,Ce=t.Function,xe=t.Math,Ee=t.Object,Se=t.RegExp,ke=t.String,Ae=t.TypeError,Te=r.prototype,Ne=Ce.prototype,Le=Ee.prototype,Re=t["__core-js_shared__"],Pe=Ne.toString,Oe=Le.hasOwnProperty,We=0,ze=(n=/[^.]+$/.exec(Re&&Re.keys&&Re.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",Ie=Le.toString,Be=Pe.call(Ee),Me=ot._,Ue=Se("^"+Pe.call(Oe).replace(te,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),De=lt?t.Buffer:i,Fe=t.Symbol,qe=t.Uint8Array,He=De?De.allocUnsafe:i,Ye=en(Ee.getPrototypeOf,Ee),$e=Ee.create,et=Le.propertyIsEnumerable,rt=Te.splice,it=Fe?Fe.isConcatSpreadable:i,st=Fe?Fe.iterator:i,at=Fe?Fe.toStringTag:i,ct=function(){try{var e=co(Ee,"defineProperty");return e({},"",{}),e}catch(e){}}(),ut=t.clearTimeout!==ot.clearTimeout&&t.clearTimeout,Lt=ie&&ie.now!==ot.Date.now&&ie.now,Mt=t.setTimeout!==ot.setTimeout&&t.setTimeout,un=xe.ceil,dn=xe.floor,hn=Ee.getOwnPropertySymbols,fn=De?De.isBuffer:i,pn=t.isFinite,_n=Te.join,mn=en(Ee.keys,Ee),gn=xe.max,vn=xe.min,bn=ie.now,yn=t.parseInt,wn=xe.random,Cn=Te.reverse,xn=co(t,"DataView"),En=co(t,"Map"),Sn=co(t,"Promise"),kn=co(t,"Set"),An=co(t,"WeakMap"),Tn=co(Ee,"create"),Nn=An&&new An,Ln={},Rn=Uo(xn),Pn=Uo(En),On=Uo(Sn),Wn=Uo(kn),zn=Uo(An),In=Fe?Fe.prototype:i,Bn=In?In.valueOf:i,Mn=In?In.toString:i;function Un(e){if(na(e)&&!Vs(e)&&!(e instanceof Hn)){if(e instanceof qn)return e;if(Oe.call(e,"__wrapped__"))return Do(e)}return new qn(e)}var Dn=function(){function e(){}return function(t){if(!ta(t))return{};if($e)return $e(t);e.prototype=t;var n=new e;return e.prototype=i,n}}();function Fn(){}function qn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=i}function Hn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=f,this.__views__=[]}function jn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function ar(e,t,n,r,o,s){var a,l=1&t,c=2&t,u=4&t;if(n&&(a=o?n(e,r,o,s):n(e)),a!==i)return a;if(!ta(e))return e;var d=Vs(e);if(d){if(a=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&Oe.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e),!l)return Ai(e,a)}else{var h=fo(e),f=h==y||h==w;if(Xs(e))return wi(e,l);if(h==E||h==_||f&&!o){if(a=c||f?{}:_o(e),!l)return c?function(e,t){return Ti(e,ho(e),t)}(e,function(e,t){return e&&Ti(t,Oa(t),e)}(a,e)):function(e,t){return Ti(e,uo(e),t)}(e,rr(a,e))}else{if(!Qe[h])return o?e:{};a=function(e,t,n){var r,i=e.constructor;switch(t){case R:return Ci(e);case g:case v:return new i(+e);case P:return function(e,t){var n=t?Ci(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case O:case W:case z:case I:case B:case M:case U:case D:case F:return xi(e,n);case C:return new i;case x:case T:return new i(e);case k:return function(e){var t=new e.constructor(e.source,he.exec(e));return t.lastIndex=e.lastIndex,t}(e);case A:return new i;case N:return r=e,Bn?Ee(Bn.call(r)):{}}}(e,h,l)}}s||(s=new $n);var p=s.get(e);if(p)return p;s.set(e,a),aa(e)?e.forEach((function(r){a.add(ar(r,t,n,r,e,s))})):ra(e)&&e.forEach((function(r,i){a.set(i,ar(r,t,n,i,e,s))}));var m=d?i:(u?c?no:to:c?Oa:Pa)(e);return bt(m||e,(function(r,i){m&&(r=e[i=r]),er(a,i,ar(r,t,n,i,e,s))})),a}function lr(e,t,n){var r=n.length;if(null==e)return!r;for(e=Ee(e);r--;){var o=n[r],s=t[o],a=e[o];if(a===i&&!(o in e)||!s(a))return!1}return!0}function cr(e,t,n){if("function"!=typeof e)throw new Ae(o);return Lo((function(){e.apply(i,n)}),t)}function ur(e,t,n,r){var i=-1,o=xt,s=!0,a=e.length,l=[],c=t.length;if(!a)return l;n&&(t=St(t,Ht(n))),r?(o=Et,s=!1):t.length>=200&&(o=Vt,s=!1,t=new Jn(t));e:for(;++i-1},Vn.prototype.set=function(e,t){var n=this.__data__,r=tr(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},Yn.prototype.clear=function(){this.size=0,this.__data__={hash:new jn,map:new(En||Vn),string:new jn}},Yn.prototype.delete=function(e){var t=ao(this,e).delete(e);return this.size-=t?1:0,t},Yn.prototype.get=function(e){return ao(this,e).get(e)},Yn.prototype.has=function(e){return ao(this,e).has(e)},Yn.prototype.set=function(e,t){var n=ao(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},Jn.prototype.add=Jn.prototype.push=function(e){return this.__data__.set(e,s),this},Jn.prototype.has=function(e){return this.__data__.has(e)},$n.prototype.clear=function(){this.__data__=new Vn,this.size=0},$n.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},$n.prototype.get=function(e){return this.__data__.get(e)},$n.prototype.has=function(e){return this.__data__.has(e)},$n.prototype.set=function(e,t){var n=this.__data__;if(n instanceof Vn){var r=n.__data__;if(!En||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Yn(r)}return n.set(e,t),this.size=n.size,this};var dr=Ri(br),hr=Ri(yr,!0);function fr(e,t){var n=!0;return dr(e,(function(e,r,i){return n=!!t(e,r,i)})),n}function pr(e,t,n){for(var r=-1,o=e.length;++r0&&n(a)?t>1?mr(a,t-1,n,r,i):kt(i,a):r||(i[i.length]=a)}return i}var gr=Pi(),vr=Pi(!0);function br(e,t){return e&&gr(e,t,Pa)}function yr(e,t){return e&&vr(e,t,Pa)}function wr(e,t){return Ct(t,(function(t){return Ks(e[t])}))}function Cr(e,t){for(var n=0,r=(t=gi(t,e)).length;null!=e&&nt}function kr(e,t){return null!=e&&Oe.call(e,t)}function Ar(e,t){return null!=e&&t in Ee(e)}function Tr(e,t,n){for(var o=n?Et:xt,s=e[0].length,a=e.length,l=a,c=r(a),u=1/0,d=[];l--;){var h=e[l];l&&t&&(h=St(h,Ht(t))),u=vn(h.length,u),c[l]=!n&&(t||s>=120&&h.length>=120)?new Jn(l&&h):i}h=e[0];var f=-1,p=c[0];e:for(;++f=a?l:l*("desc"==n[r]?-1:1)}return e.index-t.index}(e,t,n)}));r--;)e[r]=e[r].value;return e}(i)}function Hr(e,t,n){for(var r=-1,i=t.length,o={};++r-1;)a!==e&&rt.call(a,l,1),rt.call(e,l,1);return e}function Vr(e,t){for(var n=e?t.length:0,r=n-1;n--;){var i=t[n];if(n==r||i!==o){var o=i;go(i)?rt.call(e,i,1):ci(e,i)}}return e}function Yr(e,t){return e+dn(wn()*(t-e+1))}function Jr(e,t){var n="";if(!e||t<1||t>d)return n;do{t%2&&(n+=e),(t=dn(t/2))&&(e+=e)}while(t);return n}function $r(e,t){return Ro(So(e,t,il),e+"")}function Xr(e){return Gn(Fa(e))}function Gr(e,t){var n=Fa(e);return Wo(n,sr(t,0,n.length))}function Zr(e,t,n,r){if(!ta(e))return e;for(var o=-1,s=(t=gi(t,e)).length,a=s-1,l=e;null!=l&&++oo?0:o+t),(n=n>o?o:n)<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var s=r(o);++i>>1,s=e[o];null!==s&&!ca(s)&&(n?s<=t:s=200){var c=t?null:Ji(e);if(c)return nn(c);s=!1,i=Vt,l=new Jn}else l=t?[]:a;e:for(;++r=r?e:ti(e,t,n)}var yi=ut||function(e){return ot.clearTimeout(e)};function wi(e,t){if(t)return e.slice();var n=e.length,r=He?He(n):new e.constructor(n);return e.copy(r),r}function Ci(e){var t=new e.constructor(e.byteLength);return new qe(t).set(new qe(e)),t}function xi(e,t){var n=t?Ci(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Ei(e,t){if(e!==t){var n=e!==i,r=null===e,o=e==e,s=ca(e),a=t!==i,l=null===t,c=t==t,u=ca(t);if(!l&&!u&&!s&&e>t||s&&a&&c&&!l&&!u||r&&a&&c||!n&&c||!o)return 1;if(!r&&!s&&!u&&e1?n[o-1]:i,a=o>2?n[2]:i;for(s=e.length>3&&"function"==typeof s?(o--,s):i,a&&vo(n[0],n[1],a)&&(s=o<3?i:s,o=1),t=Ee(t);++r-1?o[s?t[a]:a]:i}}function Bi(e){return eo((function(t){var n=t.length,r=n,s=qn.prototype.thru;for(e&&t.reverse();r--;){var a=t[r];if("function"!=typeof a)throw new Ae(o);if(s&&!l&&"wrapper"==io(a))var l=new qn([],!0)}for(r=l?r:n;++r1&&b.reverse(),f&&dl))return!1;var u=s.get(e),d=s.get(t);if(u&&d)return u==t&&d==e;var h=-1,f=!0,p=2&n?new Jn:i;for(s.set(e,t),s.set(t,e);++h-1&&e%1==0&&e1?"& ":"")+t[r],t=t.join(n>2?", ":" "),e.replace(oe,"{\n/* [wrapped with "+t+"] */\n")}(r,function(e,t){return bt(p,(function(n){var r="_."+n[0];t&n[1]&&!xt(e,r)&&e.push(r)})),e.sort()}(function(e){var t=e.match(se);return t?t[1].split(ae):[]}(r),n)))}function Oo(e){var t=0,n=0;return function(){var r=bn(),o=16-(r-n);if(n=r,o>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(i,arguments)}}function Wo(e,t){var n=-1,r=e.length,o=r-1;for(t=t===i?r:t;++n1?e[t-1]:i;return n="function"==typeof n?(e.pop(),n):i,ss(e,n)}));function fs(e){var t=Un(e);return t.__chain__=!0,t}function ps(e,t){return t(e)}var _s=eo((function(e){var t=e.length,n=t?e[0]:0,r=this.__wrapped__,o=function(t){return or(t,e)};return!(t>1||this.__actions__.length)&&r instanceof Hn&&go(n)?((r=r.slice(n,+n+(t?1:0))).__actions__.push({func:ps,args:[o],thisArg:i}),new qn(r,this.__chain__).thru((function(e){return t&&!e.length&&e.push(i),e}))):this.thru(o)})),ms=Ni((function(e,t,n){Oe.call(e,n)?++e[n]:ir(e,n,1)})),gs=Ii(jo),vs=Ii(Vo);function bs(e,t){return(Vs(e)?bt:dr)(e,so(t,3))}function ys(e,t){return(Vs(e)?yt:hr)(e,so(t,3))}var ws=Ni((function(e,t,n){Oe.call(e,n)?e[n].push(t):ir(e,n,[t])})),Cs=$r((function(e,t,n){var i=-1,o="function"==typeof t,s=Js(e)?r(e.length):[];return dr(e,(function(e){s[++i]=o?gt(t,e,n):Nr(e,t,n)})),s})),xs=Ni((function(e,t,n){ir(e,n,t)}));function Es(e,t){return(Vs(e)?St:Br)(e,so(t,3))}var Ss=Ni((function(e,t,n){e[n?0:1].push(t)}),(function(){return[[],[]]})),ks=$r((function(e,t){if(null==e)return[];var n=t.length;return n>1&&vo(e,t[0],t[1])?t=[]:n>2&&vo(t[0],t[1],t[2])&&(t=[t[0]]),qr(e,mr(t,1),[])})),As=Lt||function(){return ot.Date.now()};function Ts(e,t,n){return t=n?i:t,t=e&&null==t?e.length:t,Xi(e,c,i,i,i,i,t)}function Ns(e,t){var n;if("function"!=typeof t)throw new Ae(o);return e=_a(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=i),n}}var Ls=$r((function(e,t,n){var r=1;if(n.length){var i=tn(n,oo(Ls));r|=l}return Xi(e,r,t,n,i)})),Rs=$r((function(e,t,n){var r=3;if(n.length){var i=tn(n,oo(Rs));r|=l}return Xi(t,r,e,n,i)}));function Ps(e,t,n){var r,s,a,l,c,u,d=0,h=!1,f=!1,p=!0;if("function"!=typeof e)throw new Ae(o);function _(t){var n=r,o=s;return r=s=i,d=t,l=e.apply(o,n)}function m(e){return d=e,c=Lo(v,t),h?_(e):l}function g(e){var n=e-u;return u===i||n>=t||n<0||f&&e-d>=a}function v(){var e=As();if(g(e))return b(e);c=Lo(v,function(e){var n=t-(e-u);return f?vn(n,a-(e-d)):n}(e))}function b(e){return c=i,p&&r?_(e):(r=s=i,l)}function y(){var e=As(),n=g(e);if(r=arguments,s=this,u=e,n){if(c===i)return m(u);if(f)return yi(c),c=Lo(v,t),_(u)}return c===i&&(c=Lo(v,t)),l}return t=ga(t)||0,ta(n)&&(h=!!n.leading,a=(f="maxWait"in n)?gn(ga(n.maxWait)||0,t):a,p="trailing"in n?!!n.trailing:p),y.cancel=function(){c!==i&&yi(c),d=0,r=u=s=c=i},y.flush=function(){return c===i?l:b(As())},y}var Os=$r((function(e,t){return cr(e,1,t)})),Ws=$r((function(e,t,n){return cr(e,ga(t)||0,n)}));function zs(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Ae(o);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=e.apply(this,r);return n.cache=o.set(i,s)||o,s};return n.cache=new(zs.Cache||Yn),n}function Is(e){if("function"!=typeof e)throw new Ae(o);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}zs.Cache=Yn;var Bs=vi((function(e,t){var n=(t=1==t.length&&Vs(t[0])?St(t[0],Ht(so())):St(mr(t,1),Ht(so()))).length;return $r((function(r){for(var i=-1,o=vn(r.length,n);++i=t})),js=Lr(function(){return arguments}())?Lr:function(e){return na(e)&&Oe.call(e,"callee")&&!et.call(e,"callee")},Vs=r.isArray,Ys=dt?Ht(dt):function(e){return na(e)&&Er(e)==R};function Js(e){return null!=e&&ea(e.length)&&!Ks(e)}function $s(e){return na(e)&&Js(e)}var Xs=fn||gl,Gs=ht?Ht(ht):function(e){return na(e)&&Er(e)==v};function Zs(e){if(!na(e))return!1;var t=Er(e);return t==b||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!oa(e)}function Ks(e){if(!ta(e))return!1;var t=Er(e);return t==y||t==w||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Qs(e){return"number"==typeof e&&e==_a(e)}function ea(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=d}function ta(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function na(e){return null!=e&&"object"==typeof e}var ra=ft?Ht(ft):function(e){return na(e)&&fo(e)==C};function ia(e){return"number"==typeof e||na(e)&&Er(e)==x}function oa(e){if(!na(e)||Er(e)!=E)return!1;var t=Ye(e);if(null===t)return!0;var n=Oe.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Pe.call(n)==Be}var sa=pt?Ht(pt):function(e){return na(e)&&Er(e)==k},aa=_t?Ht(_t):function(e){return na(e)&&fo(e)==A};function la(e){return"string"==typeof e||!Vs(e)&&na(e)&&Er(e)==T}function ca(e){return"symbol"==typeof e||na(e)&&Er(e)==N}var ua=mt?Ht(mt):function(e){return na(e)&&ea(e.length)&&!!Ke[Er(e)]},da=ji(Ir),ha=ji((function(e,t){return e<=t}));function fa(e){if(!e)return[];if(Js(e))return la(e)?sn(e):Ai(e);if(st&&e[st])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[st]());var t=fo(e);return(t==C?Qt:t==A?nn:Fa)(e)}function pa(e){return e?(e=ga(e))===u||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function _a(e){var t=pa(e),n=t%1;return t==t?n?t-n:t:0}function ma(e){return e?sr(_a(e),0,f):0}function ga(e){if("number"==typeof e)return e;if(ca(e))return h;if(ta(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=ta(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=qt(e);var n=pe.test(e);return n||me.test(e)?nt(e.slice(2),n?2:8):fe.test(e)?h:+e}function va(e){return Ti(e,Oa(e))}function ba(e){return null==e?"":ai(e)}var ya=Li((function(e,t){if(Co(t)||Js(t))Ti(t,Pa(t),e);else for(var n in t)Oe.call(t,n)&&er(e,n,t[n])})),wa=Li((function(e,t){Ti(t,Oa(t),e)})),Ca=Li((function(e,t,n,r){Ti(t,Oa(t),e,r)})),xa=Li((function(e,t,n,r){Ti(t,Pa(t),e,r)})),Ea=eo(or),Sa=$r((function(e,t){e=Ee(e);var n=-1,r=t.length,o=r>2?t[2]:i;for(o&&vo(t[0],t[1],o)&&(r=1);++n1),t})),Ti(e,no(e),n),r&&(n=ar(n,7,Ki));for(var i=t.length;i--;)ci(n,t[i]);return n})),Ba=eo((function(e,t){return null==e?{}:function(e,t){return Hr(e,t,(function(t,n){return Ta(e,n)}))}(e,t)}));function Ma(e,t){if(null==e)return{};var n=St(no(e),(function(e){return[e]}));return t=so(t),Hr(e,n,(function(e,n){return t(e,n[0])}))}var Ua=$i(Pa),Da=$i(Oa);function Fa(e){return null==e?[]:jt(e,Pa(e))}var qa=Wi((function(e,t,n){return t=t.toLowerCase(),e+(n?Ha(t):t)}));function Ha(e){return Za(ba(e).toLowerCase())}function ja(e){return(e=ba(e))&&e.replace(ve,Xt).replace(Ve,"")}var Va=Wi((function(e,t,n){return e+(n?"-":"")+t.toLowerCase()})),Ya=Wi((function(e,t,n){return e+(n?" ":"")+t.toLowerCase()})),Ja=Oi("toLowerCase"),$a=Wi((function(e,t,n){return e+(n?"_":"")+t.toLowerCase()})),Xa=Wi((function(e,t,n){return e+(n?" ":"")+Za(t)})),Ga=Wi((function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})),Za=Oi("toUpperCase");function Ka(e,t,n){return e=ba(e),(t=n?i:t)===i?function(e){return Xe.test(e)}(e)?function(e){return e.match(Je)||[]}(e):function(e){return e.match(le)||[]}(e):e.match(t)||[]}var Qa=$r((function(e,t){try{return gt(e,i,t)}catch(e){return Zs(e)?e:new we(e)}})),el=eo((function(e,t){return bt(t,(function(t){t=Mo(t),ir(e,t,Ls(e[t],e))})),e}));function tl(e){return function(){return e}}var nl=Bi(),rl=Bi(!0);function il(e){return e}function ol(e){return Wr("function"==typeof e?e:ar(e,1))}var sl=$r((function(e,t){return function(n){return Nr(n,e,t)}})),al=$r((function(e,t){return function(n){return Nr(e,n,t)}}));function ll(e,t,n){var r=Pa(t),i=wr(t,r);null!=n||ta(t)&&(i.length||!r.length)||(n=t,t=e,e=this,i=wr(t,Pa(t)));var o=!(ta(n)&&"chain"in n&&!n.chain),s=Ks(e);return bt(i,(function(n){var r=t[n];e[n]=r,s&&(e.prototype[n]=function(){var t=this.__chain__;if(o||t){var n=e(this.__wrapped__),i=n.__actions__=Ai(this.__actions__);return i.push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,kt([this.value()],arguments))})})),e}function cl(){}var ul=Fi(St),dl=Fi(wt),hl=Fi(Nt);function fl(e){return bo(e)?Bt(Mo(e)):function(e){return function(t){return Cr(t,e)}}(e)}var pl=Hi(),_l=Hi(!0);function ml(){return[]}function gl(){return!1}var vl,bl=Di((function(e,t){return e+t}),0),yl=Yi("ceil"),wl=Di((function(e,t){return e/t}),1),Cl=Yi("floor"),xl=Di((function(e,t){return e*t}),1),El=Yi("round"),Sl=Di((function(e,t){return e-t}),0);return Un.after=function(e,t){if("function"!=typeof t)throw new Ae(o);return e=_a(e),function(){if(--e<1)return t.apply(this,arguments)}},Un.ary=Ts,Un.assign=ya,Un.assignIn=wa,Un.assignInWith=Ca,Un.assignWith=xa,Un.at=Ea,Un.before=Ns,Un.bind=Ls,Un.bindAll=el,Un.bindKey=Rs,Un.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Vs(e)?e:[e]},Un.chain=fs,Un.chunk=function(e,t,n){t=(n?vo(e,t,n):t===i)?1:gn(_a(t),0);var o=null==e?0:e.length;if(!o||t<1)return[];for(var s=0,a=0,l=r(un(o/t));so?0:o+n),(r=r===i||r>o?o:_a(r))<0&&(r+=o),r=n>r?0:ma(r);n>>0)?(e=ba(e))&&("string"==typeof t||null!=t&&!sa(t))&&!(t=ai(t))&&Kt(e)?bi(sn(e),0,n):e.split(t,n):[]},Un.spread=function(e,t){if("function"!=typeof e)throw new Ae(o);return t=null==t?0:gn(_a(t),0),$r((function(n){var r=n[t],i=bi(n,0,t);return r&&kt(i,r),gt(e,this,i)}))},Un.tail=function(e){var t=null==e?0:e.length;return t?ti(e,1,t):[]},Un.take=function(e,t,n){return e&&e.length?ti(e,0,(t=n||t===i?1:_a(t))<0?0:t):[]},Un.takeRight=function(e,t,n){var r=null==e?0:e.length;return r?ti(e,(t=r-(t=n||t===i?1:_a(t)))<0?0:t,r):[]},Un.takeRightWhile=function(e,t){return e&&e.length?di(e,so(t,3),!1,!0):[]},Un.takeWhile=function(e,t){return e&&e.length?di(e,so(t,3)):[]},Un.tap=function(e,t){return t(e),e},Un.throttle=function(e,t,n){var r=!0,i=!0;if("function"!=typeof e)throw new Ae(o);return ta(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),Ps(e,t,{leading:r,maxWait:t,trailing:i})},Un.thru=ps,Un.toArray=fa,Un.toPairs=Ua,Un.toPairsIn=Da,Un.toPath=function(e){return Vs(e)?St(e,Mo):ca(e)?[e]:Ai(Bo(ba(e)))},Un.toPlainObject=va,Un.transform=function(e,t,n){var r=Vs(e),i=r||Xs(e)||ua(e);if(t=so(t,4),null==n){var o=e&&e.constructor;n=i?r?new o:[]:ta(e)&&Ks(o)?Dn(Ye(e)):{}}return(i?bt:br)(e,(function(e,r,i){return t(n,e,r,i)})),n},Un.unary=function(e){return Ts(e,1)},Un.union=ns,Un.unionBy=rs,Un.unionWith=is,Un.uniq=function(e){return e&&e.length?li(e):[]},Un.uniqBy=function(e,t){return e&&e.length?li(e,so(t,2)):[]},Un.uniqWith=function(e,t){return t="function"==typeof t?t:i,e&&e.length?li(e,i,t):[]},Un.unset=function(e,t){return null==e||ci(e,t)},Un.unzip=os,Un.unzipWith=ss,Un.update=function(e,t,n){return null==e?e:ui(e,t,mi(n))},Un.updateWith=function(e,t,n,r){return r="function"==typeof r?r:i,null==e?e:ui(e,t,mi(n),r)},Un.values=Fa,Un.valuesIn=function(e){return null==e?[]:jt(e,Oa(e))},Un.without=as,Un.words=Ka,Un.wrap=function(e,t){return Ms(mi(t),e)},Un.xor=ls,Un.xorBy=cs,Un.xorWith=us,Un.zip=ds,Un.zipObject=function(e,t){return pi(e||[],t||[],er)},Un.zipObjectDeep=function(e,t){return pi(e||[],t||[],Zr)},Un.zipWith=hs,Un.entries=Ua,Un.entriesIn=Da,Un.extend=wa,Un.extendWith=Ca,ll(Un,Un),Un.add=bl,Un.attempt=Qa,Un.camelCase=qa,Un.capitalize=Ha,Un.ceil=yl,Un.clamp=function(e,t,n){return n===i&&(n=t,t=i),n!==i&&(n=(n=ga(n))==n?n:0),t!==i&&(t=(t=ga(t))==t?t:0),sr(ga(e),t,n)},Un.clone=function(e){return ar(e,4)},Un.cloneDeep=function(e){return ar(e,5)},Un.cloneDeepWith=function(e,t){return ar(e,5,t="function"==typeof t?t:i)},Un.cloneWith=function(e,t){return ar(e,4,t="function"==typeof t?t:i)},Un.conformsTo=function(e,t){return null==t||lr(e,t,Pa(t))},Un.deburr=ja,Un.defaultTo=function(e,t){return null==e||e!=e?t:e},Un.divide=wl,Un.endsWith=function(e,t,n){e=ba(e),t=ai(t);var r=e.length,o=n=n===i?r:sr(_a(n),0,r);return(n-=t.length)>=0&&e.slice(n,o)==t},Un.eq=Fs,Un.escape=function(e){return(e=ba(e))&&$.test(e)?e.replace(Y,Gt):e},Un.escapeRegExp=function(e){return(e=ba(e))&&ne.test(e)?e.replace(te,"\\$&"):e},Un.every=function(e,t,n){var r=Vs(e)?wt:fr;return n&&vo(e,t,n)&&(t=i),r(e,so(t,3))},Un.find=gs,Un.findIndex=jo,Un.findKey=function(e,t){return Rt(e,so(t,3),br)},Un.findLast=vs,Un.findLastIndex=Vo,Un.findLastKey=function(e,t){return Rt(e,so(t,3),yr)},Un.floor=Cl,Un.forEach=bs,Un.forEachRight=ys,Un.forIn=function(e,t){return null==e?e:gr(e,so(t,3),Oa)},Un.forInRight=function(e,t){return null==e?e:vr(e,so(t,3),Oa)},Un.forOwn=function(e,t){return e&&br(e,so(t,3))},Un.forOwnRight=function(e,t){return e&&yr(e,so(t,3))},Un.get=Aa,Un.gt=qs,Un.gte=Hs,Un.has=function(e,t){return null!=e&&po(e,t,kr)},Un.hasIn=Ta,Un.head=Jo,Un.identity=il,Un.includes=function(e,t,n,r){e=Js(e)?e:Fa(e),n=n&&!r?_a(n):0;var i=e.length;return n<0&&(n=gn(i+n,0)),la(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&Ot(e,t,n)>-1},Un.indexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:_a(n);return i<0&&(i=gn(r+i,0)),Ot(e,t,i)},Un.inRange=function(e,t,n){return t=pa(t),n===i?(n=t,t=0):n=pa(n),function(e,t,n){return e>=vn(t,n)&&e=-9007199254740991&&e<=d},Un.isSet=aa,Un.isString=la,Un.isSymbol=ca,Un.isTypedArray=ua,Un.isUndefined=function(e){return e===i},Un.isWeakMap=function(e){return na(e)&&fo(e)==L},Un.isWeakSet=function(e){return na(e)&&"[object WeakSet]"==Er(e)},Un.join=function(e,t){return null==e?"":_n.call(e,t)},Un.kebabCase=Va,Un.last=Zo,Un.lastIndexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var o=r;return n!==i&&(o=(o=_a(n))<0?gn(r+o,0):vn(o,r-1)),t==t?function(e,t,n){for(var r=n+1;r--;)if(e[r]===t)return r;return r}(e,t,o):Pt(e,zt,o,!0)},Un.lowerCase=Ya,Un.lowerFirst=Ja,Un.lt=da,Un.lte=ha,Un.max=function(e){return e&&e.length?pr(e,il,Sr):i},Un.maxBy=function(e,t){return e&&e.length?pr(e,so(t,2),Sr):i},Un.mean=function(e){return It(e,il)},Un.meanBy=function(e,t){return It(e,so(t,2))},Un.min=function(e){return e&&e.length?pr(e,il,Ir):i},Un.minBy=function(e,t){return e&&e.length?pr(e,so(t,2),Ir):i},Un.stubArray=ml,Un.stubFalse=gl,Un.stubObject=function(){return{}},Un.stubString=function(){return""},Un.stubTrue=function(){return!0},Un.multiply=xl,Un.nth=function(e,t){return e&&e.length?Fr(e,_a(t)):i},Un.noConflict=function(){return ot._===this&&(ot._=Me),this},Un.noop=cl,Un.now=As,Un.pad=function(e,t,n){e=ba(e);var r=(t=_a(t))?on(e):0;if(!t||r>=t)return e;var i=(t-r)/2;return qi(dn(i),n)+e+qi(un(i),n)},Un.padEnd=function(e,t,n){e=ba(e);var r=(t=_a(t))?on(e):0;return t&&rt){var r=e;e=t,t=r}if(n||e%1||t%1){var o=wn();return vn(e+o*(t-e+tt("1e-"+((o+"").length-1))),t)}return Yr(e,t)},Un.reduce=function(e,t,n){var r=Vs(e)?At:Ut,i=arguments.length<3;return r(e,so(t,4),n,i,dr)},Un.reduceRight=function(e,t,n){var r=Vs(e)?Tt:Ut,i=arguments.length<3;return r(e,so(t,4),n,i,hr)},Un.repeat=function(e,t,n){return t=(n?vo(e,t,n):t===i)?1:_a(t),Jr(ba(e),t)},Un.replace=function(){var e=arguments,t=ba(e[0]);return e.length<3?t:t.replace(e[1],e[2])},Un.result=function(e,t,n){var r=-1,o=(t=gi(t,e)).length;for(o||(o=1,e=i);++rd)return[];var n=f,r=vn(e,f);t=so(t),e-=f;for(var i=Ft(r,t);++n=s)return e;var l=n-on(r);if(l<1)return r;var c=a?bi(a,0,l).join(""):e.slice(0,l);if(o===i)return c+r;if(a&&(l+=c.length-l),sa(o)){if(e.slice(l).search(o)){var u,d=c;for(o.global||(o=Se(o.source,ba(he.exec(o))+"g")),o.lastIndex=0;u=o.exec(d);)var h=u.index;c=c.slice(0,h===i?l:h)}}else if(e.indexOf(ai(o),l)!=l){var f=c.lastIndexOf(o);f>-1&&(c=c.slice(0,f))}return c+r},Un.unescape=function(e){return(e=ba(e))&&J.test(e)?e.replace(V,ln):e},Un.uniqueId=function(e){var t=++We;return ba(e)+t},Un.upperCase=Ga,Un.upperFirst=Za,Un.each=bs,Un.eachRight=ys,Un.first=Jo,ll(Un,(vl={},br(Un,(function(e,t){Oe.call(Un.prototype,t)||(vl[t]=e)})),vl),{chain:!1}),Un.VERSION="4.17.21",bt(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){Un[e].placeholder=Un})),bt(["drop","take"],(function(e,t){Hn.prototype[e]=function(n){n=n===i?1:gn(_a(n),0);var r=this.__filtered__&&!t?new Hn(this):this.clone();return r.__filtered__?r.__takeCount__=vn(n,r.__takeCount__):r.__views__.push({size:vn(n,f),type:e+(r.__dir__<0?"Right":"")}),r},Hn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),bt(["filter","map","takeWhile"],(function(e,t){var n=t+1,r=1==n||3==n;Hn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:so(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}})),bt(["head","last"],(function(e,t){var n="take"+(t?"Right":"");Hn.prototype[e]=function(){return this[n](1).value()[0]}})),bt(["initial","tail"],(function(e,t){var n="drop"+(t?"":"Right");Hn.prototype[e]=function(){return this.__filtered__?new Hn(this):this[n](1)}})),Hn.prototype.compact=function(){return this.filter(il)},Hn.prototype.find=function(e){return this.filter(e).head()},Hn.prototype.findLast=function(e){return this.reverse().find(e)},Hn.prototype.invokeMap=$r((function(e,t){return"function"==typeof e?new Hn(this):this.map((function(n){return Nr(n,e,t)}))})),Hn.prototype.reject=function(e){return this.filter(Is(so(e)))},Hn.prototype.slice=function(e,t){e=_a(e);var n=this;return n.__filtered__&&(e>0||t<0)?new Hn(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==i&&(n=(t=_a(t))<0?n.dropRight(-t):n.take(t-e)),n)},Hn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Hn.prototype.toArray=function(){return this.take(f)},br(Hn.prototype,(function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),o=Un[r?"take"+("last"==t?"Right":""):t],s=r||/^find/.test(t);o&&(Un.prototype[t]=function(){var t=this.__wrapped__,a=r?[1]:arguments,l=t instanceof Hn,c=a[0],u=l||Vs(t),d=function(e){var t=o.apply(Un,kt([e],a));return r&&h?t[0]:t};u&&n&&"function"==typeof c&&1!=c.length&&(l=u=!1);var h=this.__chain__,f=!!this.__actions__.length,p=s&&!h,_=l&&!f;if(!s&&u){t=_?t:new Hn(this);var m=e.apply(t,a);return m.__actions__.push({func:ps,args:[d],thisArg:i}),new qn(m,h)}return p&&_?e.apply(this,a):(m=this.thru(d),p?r?m.value()[0]:m.value():m)})})),bt(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Te[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);Un.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply(Vs(i)?i:[],e)}return this[n]((function(n){return t.apply(Vs(n)?n:[],e)}))}})),br(Hn.prototype,(function(e,t){var n=Un[t];if(n){var r=n.name+"";Oe.call(Ln,r)||(Ln[r]=[]),Ln[r].push({name:t,func:n})}})),Ln[Mi(i,2).name]=[{name:"wrapper",func:i}],Hn.prototype.clone=function(){var e=new Hn(this.__wrapped__);return e.__actions__=Ai(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Ai(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Ai(this.__views__),e},Hn.prototype.reverse=function(){if(this.__filtered__){var e=new Hn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Hn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=Vs(e),r=t<0,i=n?e.length:0,o=function(e,t,n){for(var r=-1,i=n.length;++r=this.__values__.length;return{done:e,value:e?i:this.__values__[this.__index__++]}},Un.prototype.plant=function(e){for(var t,n=this;n instanceof Fn;){var r=Do(n);r.__index__=0,r.__values__=i,t?o.__wrapped__=r:t=r;var o=r;n=n.__wrapped__}return o.__wrapped__=e,t},Un.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof Hn){var t=e;return this.__actions__.length&&(t=new Hn(this)),(t=t.reverse()).__actions__.push({func:ps,args:[ts],thisArg:i}),new qn(t,this.__chain__)}return this.thru(ts)},Un.prototype.toJSON=Un.prototype.valueOf=Un.prototype.value=function(){return hi(this.__wrapped__,this.__actions__)},Un.prototype.first=Un.prototype.head,st&&(Un.prototype[st]=function(){return this}),Un}();ot._=cn,(r=function(){return cn}.call(t,n,t,e))===i||(e.exports=r)}.call(this)},752:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{l(r.next(e))}catch(e){o(e)}}function a(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=i(n(733)),s=n(249),a=n(96),l=n(288),c=n(208),u=n(467),d=n(391),h=n(544),f=n(980),p=n(66),_=n(774),m=n(964),g=n(320),v=n(717),b=n(542),y=n(452),w=n(385),C=n(580);function x(e,t){return r(this,void 0,void 0,(function*(){if(new Int8Array(e,0,1)[0]==="P".charCodeAt(0)){const n=new o.default;return(yield n.loadAsync(e)).file(t)[0].async("string")}return(new TextDecoder).decode(e)}))}let E=null;function S(e){$("#errorText").html(e),$("#errorDialog").modal("show")}$("#roster-file").on("change",(function(e){const t="resize"===(null==e?void 0:e.type)?null==E?void 0:E.target:null==e?void 0:e.target;if($("#roster-title").empty(),$("#roster-lists").empty(),$("#force-units").empty(),!(null==t?void 0:t.files))return;const n=null==t?void 0:t.files[0];"resize"!==(null==e?void 0:e.type)&&(E=e),n.arrayBuffer().then((e=>r(this,void 0,void 0,(function*(){n.name.match(/\.rosz?$/)?function(e){const t=(new DOMParser).parseFromString(e,"text/xml");if(!t)return;const n=t.querySelector("roster");if(!n)return;const r=n.getAttribute("gameSystemName");if(!r)return;const i=n.getAttribute("name");i&&(document.title=`PrettyScribe ${i}`);const o=$("#roster-title")[0],C=$("#roster-lists")[0],x=$("#force-units")[0];if("Warhammer 40,000 8th Edition"==r){const e=(0,l.Create40kRoster)(t);e&&e._forces.length>0&&new u.Renderer40k(e).render(o,C,x)}else if("Warhammer 40,000 9th Edition"==r){const e=(0,l.Create40kRoster)(t);e&&e._forces.length>0&&new u.Renderer40k(e).render(o,C,x)}else if("Warhammer 40,000: Kill Team (2018)"==r){const e=(0,l.Create40kRoster)(t,!1);e&&e._forces.length>0&&new u.Renderer40k(e).render(o,C,x)}else if("Warhammer 40,000: Kill Team (2021)"==r){const e=(0,s.CreateKT21Roster)(t);e&&e._forces.length>0&&new a.RendererKT21(e).render(o,C,x)}else if("Age of Sigmar"==r){const e=(0,_.CreateAoSRoster)(t);e&&new m.RendererAoS(e).render(o,C,x)}else if("Warhammer Age of Sigmar: Warcry"==r){const e=(0,g.CreateWarcryRoster)(t);e&&new v.RendererWarcry(e).render(o,C,x)}else if("Warhammer 30,000 - The Horus Heresy"==r){const e=(0,d.Create30kRoster)(t);e&&e._forces.length>0&&new h.Renderer30k(e).render(o,C,x)}else if(r.includes("Horus Heresy (2022)")){const e=f.HorusHeresy.CreateRoster(t);e&&e._forces.length>0&&new p.RendererHH2(e).render(o,C,x)}else if("Warhammer 40,000 10th Edition"==r){const e=c.Wh40k.CreateRoster(t);window.roster=e,e&&e._forces.length>0&&new b.Wh40kRenderer(e).render(o,C,x)}else if("Middle-Earth Strategy Battle Game"===r){const e=(0,y.CreateMESBGRoster)(t);null!==e&&(console.log(e),(0,w.renderMESBG)(e,o,C,x))}else S("PrettyScribe does not support game type '"+r+"'.")}(yield x(e,/[^/]+\.ros$/)):n.name.match(/\.regi[sz]try$/)?function(e){const t=JSON.parse(e);window.registry=t;const n=$("#roster-title")[0],r=$("#roster-lists")[0],i=$("#force-units")[0],o=t.info.game;if("Warhammer 40k"===o){const e=(0,C.Create40kRosterFromRegistry)(t);window.roster=e,new b.Wh40kRenderer(e).render(n,r,i)}else S("PrettyScribe does not support game type '"+o+"'.")}(yield x(e,/[^/]+\.registry$/)):S(`PrettyScribe does not support extension of ${n.name}.`)})))).catch((e=>{S(`Error opening ${n.name}: ${e}`),console.error(e)}))})),document.addEventListener("DOMContentLoaded",(()=>{if(navigator.userAgent.match(/AppleWebKit.*Safari/)&&!navigator.userAgent.includes("Chrome")){const e=document.querySelector('input[type="file"');null==e||e.removeAttribute("accept")}}))},361:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toggleHidden=t.addHideAble=void 0,t.addHideAble=function(e){return e.classList.add("hide_able"),e},t.toggleHidden=function(e){var t,n,r;if(!e.target)return;const i=e.target;null===(t=i.closest(".hide_able"))||void 0===t||t.classList.toggle("hidden"),null===(r=null===(n=i.closest(".unit_header"))||void 0===n?void 0:n.closest(".wh40k_unit_sheet"))||void 0===r||r.classList.toggle("hidden")}},77:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PsJsx=void 0,function(e){function t(e,n){if(null!=n)if(Array.isArray(n))for(const r of n)t(e,r);else"string"==typeof n?e.appendChild(document.createTextNode(n)):n instanceof Node?e.appendChild(n):"boolean"==typeof n||e.appendChild(document.createTextNode(String(n)))}e.createFragment=function(){return document.createDocumentFragment()},e.createElement=function(e,n,...r){const i="function"==typeof e?e():document.createElement(e);if(n)for(const e of Object.keys(n)){const t=n[e];if("boolean"==typeof t)i.setAttribute(e,"");else if("function"==typeof t)if("ref"===e)t(i);else{if(!e.startsWith("on"))throw new Error("Unexpected function attribute");i.addEventListener(e.substring(2),t)}else"className"===e?i.setAttribute("class",t):i.setAttribute(e,t)}for(const e of r)t(i,e);return i}}(t.PsJsx||(t.PsJsx={}))},219:(e,t)=>{"use strict";function n(e,t){try{window.localStorage[e]=t}catch(e){}}Object.defineProperty(t,"__esModule",{value:!0}),t.loadOptionsFromLocalStorage=t.saveOptionToLocalStorage=t.renderCheckboxOption=t.renderOptionsToggle=void 0,t.renderOptionsToggle=function(e){e.classList.add("wh40k_options_toggle"),e.id="wh40k_options_toggle";const t="[−] Options:";e.appendChild(document.createTextNode(t)),e.addEventListener("click",(e=>{const r=document.getElementById("wh40k_options_div"),i=document.getElementById("wh40k_options_toggle");r&&i&&(r.classList.contains("hide_options")?(r.classList.remove("hide_options"),i.innerText=t,n("option-toggle-hidden","false")):(r.classList.add("hide_options"),i.innerText="[+] Options",n("option-toggle-hidden","true")))}))},t.renderCheckboxOption=function(e,t,r,i,o=!1){const s=e.appendChild(document.createElement("div"));s.classList.add("wh40k_option");const a=s.appendChild(document.createElement("input"));a.setAttribute("type","checkbox"),a.setAttribute("name",t),a.setAttribute("id",t),o&&(a.checked=!0),a.addEventListener("input",i),a.addEventListener("change",(e=>function(e){const t=document.getElementById(e);t&&n(`option-checkbox-${e}`,t.checked)}(t)));const l=s.appendChild(document.createElement("label"));l.setAttribute("for",t),l.appendChild(document.createTextNode(` ${r}`))},t.saveOptionToLocalStorage=n,t.loadOptionsFromLocalStorage=function(){var e;try{for(let t=0;t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createNotesHead=t.createNoteHead=t.createTableRow=void 0;const r=n(361);function i(e,t,n=!1){const i=(0,r.addHideAble)(document.createElement("tr"));n&&i.classList.add("header_row");for(let r=0,o=0;re._customNotes)))return null;const n=document.createElement("thead");n.classList.add("info_row");const r=document.createElement("div");for(const e of t){if(!e.notes())continue;const t=r.appendChild(document.createElement("div"));t.appendChild(document.createElement("b")).appendChild(document.createTextNode(`${e.name()}: `)),t.appendChild(document.createTextNode(e._customNotes))}return n.appendChild(i([e,r],[.1,.9],!1)),n}},580:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateRoster=t.Create40kRosterFromRegistry=void 0;const r=n(208),i=n(596);function o(e){const t=new r.Wh40k.Roster40k,n=new r.Wh40k.Force;t._name=e.name,n._name=e.info.name,function(e,t){const n=e.assets.traits.filter((e=>"Detachment"===e.classification))[0];n&&(t._faction=n.designation,t._rules.set(n.designation,n.text))}(e,n);for(const r of[...e.assets.included,...e.assets.traits]){if("Unit"!=r.classIdentity)continue;const e=s(r);n._units.push(e),t._cost.add(e._cost);for(const t of[...e._rules.entries(),...e._weaponRules.entries()])n._rules.set(t[0],t[1])}return n._rules=new Map([...n._rules.entries()].sort()),t._forces.push(n),t}function s(e){var t,n;const i=new r.Wh40k.Unit;return i._name=e.designation,function(e,t){var n,r,i;const o=(null===(r=null===(n=e.rules.finalModelTally)||void 0===n?void 0:n.evals[1])||void 0===r?void 0:r.result.integer)||(null===(i=e.stats.Models)||void 0===i?void 0:i.value);e.stats.model3rdTally.value&&o>e.stats.model3rdTally.value?t._cost._points=e.stats.model4thCost.value:e.stats.model2ndTally.value&&o>e.stats.model2ndTally.value?t._cost._points=e.stats.model3rdCost.value:e.stats.model1stTally.value&&o>e.stats.model1stTally.value?t._cost._points=e.stats.model2ndCost.value:e.stats.Points&&(t._cost._points=e.stats.Points.value),function e(n){var r;for(const i of[...n.assets.included,...n.assets.traits])(null===(r=i.stats.Points)||void 0===r?void 0:r.value)&&(t._cost._points+=i.stats.Points.value),e(i)}(e)}(e,i),null===(t=e.keywords.Faction)||void 0===t||t.sort().forEach((e=>i._factions.add(e))),null===(n=e.keywords.Keywords)||void 0===n||n.sort().forEach((e=>i._keywords.add(e))),function(e,t){const n=[...e.assets.traits,...e.assets.included].filter((e=>"Model"===e.classification));0===n.length?n.push(e):d({designation:"Unit Upgrades",assets:e.assets,quantity:1},t,!1);for(const e of n)u(e,t),d(e,t)}(e,i),a(e,i),i.normalize(),i}function a(e,t){for(const n of[...e.assets.traits,...e.assets.included]){const e=n.classification;if("Wargear"===e||"Enhancement"===e)t._abilities[e]||(t._abilities[e]=new Map),t._abilities[e].set(n.designation,n.text);else if("Ability"===e)if("Leader"===n.designation){const e=n.text.indexOf("This model can be attached"),r=n.text.substring(0,e).trim();r&&t._rules.set(n.designation,r);const i=n.text.substring(e);t._abilities.Abilities||(t._abilities.Abilities=new Map),t._abilities.Abilities.set(n.designation,i)}else!n.tally.Core&&!n.tally.Faction||n.designation.startsWith("Damaged:")?(t._abilities.Abilities||(t._abilities.Abilities=new Map),t._abilities.Abilities.set(n.designation,n.text)):t._rules.set(n.designation,n.text);else if("Model"===e)a(n,t);else if("Ranged Weapon"===e||"Melee Weapon"===e||"Weapon"===e){l(n,t);const e=n.assets.traits.filter((e=>e.classification.endsWith("Weapon")));for(const r of e)l(r,t,n.designation)}else console.error(`Unexepcted classification '${e}': ${n.designation}`)}}function l(e,t,n){const i=`${e.classification}s`,o=c(e,i);if(n&&(o[Object.keys(o)[0]]=`${n} - ${o[Object.keys(o)[0]]}`),Object.keys(o).length<=1)return;const s=e.assets.traits.filter((e=>"Ability"===e.classification));if(s.length>0){s.forEach((e=>t._weaponRules.set(e.designation,e.text)));const e=s.map((e=>e.designation));Object.assign(o,{Keywords:e.join(", ")})}t._profileTables[i]||(t._profileTables[i]=new r.Wh40k.TabularProfile),t._profileTables[i].addRow(o)}function c(e,t,n){const r=(0,i.filterAndOrderStats)(e.stats);return Object.assign({[t]:e.designation},Object.fromEntries(r.map((e=>[e[0],(0,i.formatStat)(e[1])]))))}function u(e,t){const n=c(e,"Unit");Object.keys(n).length>1&&(t._profileTables.Unit||(t._profileTables.Unit=new r.Wh40k.TabularProfile),t._profileTables.Unit.addRow(Object.assign({Unit:e.designation},n)))}function d(e,t,n=!0){var i;const o=new r.Wh40k.Model;o._name=e.designation,o._count=e.quantity;const s=[...e.assets.traits,...e.assets.included].filter((e=>"Wargear"===e.classification||"Weapon"===e.classification||"Ranged Weapon"===e.classification||"Melee Weapon"===e.classification||"Enhancement"===e.classification));for(const e of s){const t=new r.Wh40k.Upgrade;t._name=e.designation;const n=null===(i=e.stats.Points)||void 0===i?void 0:i.value;n&&(t._cost._points=n),o._upgrades.push(t)}(n||s.length>0)&&t._models.push(o)}t.Create40kRosterFromRegistry=function(e){return o(e)},t.CreateRoster=o},419:(e,t)=>{"use strict";var n,r;function i(e,t,i,o,s,a,l,c){if(e&&t.length){e.textBaseline="top";let u=e.measureText(t);const d=u.width,h=u.actualBoundingBoxDescent-u.actualBoundingBoxAscent;let f=o;c==r.Top?f=o:c==r.Bottom?f=o+a-h:c==r.Center&&(f=o+(a-h)/2),l==n.Center?e.fillText(t,i+Math.max((s-d)/2,0),f,s):l==n.Left?e.fillText(t,i,f,s):l==n.Right&&e.fillText(t,i+s-d,f,s)}}Object.defineProperty(t,"__esModule",{value:!0}),t.FixDPI=t.RenderParagraph=t.RenderText=t.RenderTextFull=t.VertAlign=t.Justification=void 0,function(e){e[e.Left=0]="Left",e[e.Right=1]="Right",e[e.Center=2]="Center"}(n=t.Justification||(t.Justification={})),function(e){e[e.Top=0]="Top",e[e.Bottom=1]="Bottom",e[e.Center=2]="Center"}(r=t.VertAlign||(t.VertAlign={})),t.RenderTextFull=i,t.RenderText=function(e,t,n,o,s,a,l){i(e,t,n,o,s,a,l,r.Center)},t.RenderParagraph=function(e,t,n,r,i,o){let s=r;if(e&&t.length){let r=[],a=[];e.textBaseline="top";let l=0;const c=e.measureText(" ").width,u=e.measureText(t),d=1.2*(u.actualBoundingBoxDescent-u.actualBoundingBoxAscent);let h=i-o;t.split(" ").forEach((function(t){const n=e.measureText(t);l+n.width>h&&(r.push(a.join(" ")),h=i,a.length=0,l=0),l+=n.width+c,a.push(t)})),a.length>0&&r.push(a.join(" "));let f=n+o;for(let t of r)e.fillText(t,f,s),f=n,s+=d}return s},t.FixDPI=function(e){let t=window.devicePixelRatio,n=+getComputedStyle(e).getPropertyValue("height").slice(0,-2),r=+getComputedStyle(e).getPropertyValue("width").slice(0,-2);0==n&&(n=e.height),0==r&&(r=e.width),e.setAttribute("height",(n*t).toString()),e.setAttribute("width",(r*t).toString())}},544:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Renderer30k=void 0;const r=n(391),i=n(419);class o{constructor(e){this._descriptionStartX=190,this._descriptionWidth=600,this._showWoundBoxes=!1,this._roster=null,this._currentX=0,this._currentY=0,this._maxWidth=0,this._octagon=null,this._roles=new Map,this._unitLabelWidthsNormalized=[.3,.077,.077,.077,.077,.077,.077,.077,.077,.077],this._vehicleLabelWidthsNormalized=[.3,.1,.1,.1,.1,.1,.2],this._walkerLabelWidthsNormalized=[.3,.06,.06,.06,.06,.06,.06,.06,.06,.06,.15],this._flyerLabelWidthsNormalized=[.3,.077,.077,.077,.077,.077,.077,.077,.077,.077],this._weaponLabelWidthNormalized=[.3,.1,.1,.1,.4],this._spellLabelWidthNormalized=[.3,.1,.1,.5],this._roster=e,this._octagon=document.getElementById("octagon"),this._roles.set(r.UnitRole30k.HQ,document.getElementById("role_hq")),this._roles.set(r.UnitRole30k.TR,document.getElementById("role_tr")),this._roles.set(r.UnitRole30k.EL,document.getElementById("role_el")),this._roles.set(r.UnitRole30k.FA,document.getElementById("role_fa")),this._roles.set(r.UnitRole30k.HS,document.getElementById("role_hs")),this._roles.set(r.UnitRole30k.FL,document.getElementById("role_fl")),this._roles.set(r.UnitRole30k.DT,document.getElementById("role_dt")),this._roles.set(r.UnitRole30k.FT,document.getElementById("role_ft")),this._roles.set(r.UnitRole30k.LW,document.getElementById("role_lw"))}render(e,t,n){if(null!=this._roster){e&&(e.innerHTML="

"+this._roster._name+" ("+this._roster._points+" pts)

");for(let e of this._roster._forces){const s=document.createElement("div");s&&(s.innerHTML="

"+e._catalog+" "+e._name+"

"),t&&t.appendChild(s);const a=document.createElement("table");a.classList.add("table"),a.classList.add("table-sm"),a.classList.add("table-striped");const l=document.createElement("thead");a.appendChild(l),l.classList.add("thead-light");const c=document.createElement("tr");l.appendChild(c),[{name:"NAME",w:"25%"},{name:"ROLE",w:"20%"},{name:"MODELS",w:"40%"},{name:"POINTS",w:"15%"}].forEach((e=>{let t=document.createElement("th");t.scope="col",t.innerHTML=e.name,t.style.width=e.w,c.appendChild(t)})),s.appendChild(a);let u=document.createElement("tbody");a.appendChild(u);for(let t of e._units){let e=document.createElement("tr"),n=document.createElement("td");n.innerHTML=t._name;let i=document.createElement("td");i.innerHTML=r.UnitRoleToString30k[t._role];let o=document.createElement("td");o.innerHTML="";let s=0;for(const e of t._models)e._count>1?o.innerHTML+=e._count+" "+e._name:o.innerHTML+=e._name,s++,s!=t._models.length&&(o.innerHTML+=", ");let a=document.createElement("td");a.innerHTML=t._points.toString(),e.appendChild(n),e.appendChild(i),e.appendChild(o),e.appendChild(a),u.appendChild(e)}if(e._rules.size>0){let t=document.createElement("div"),r=document.createElement("h3");t.appendChild(r),r.textContent=e._catalog+" Allegiance Rules";for(let n of e._rules){let e=document.createElement("div"),r=document.createElement("h4");r.textContent=n[0];let i=document.createElement("p");i.textContent=n[1],e.appendChild(r),e.appendChild(i),t.appendChild(e)}n&&n.appendChild(t)}for(let t of e._units){let e=document.createElement("canvas");e.width=7.5*o._res,e.height=20*o._res,this._descriptionWidth=e.width-this._descriptionStartX-10,(0,i.FixDPI)(e);const r=this.renderUnit(t,e,0,0),s=25;let a=document.createElement("canvas");a.width=r[0]+2*s,a.height=r[1]+2*s;let l=a.getContext("2d");if(null==l||l.drawImage(e,s,s),n){let e=document.createElement("div");e.appendChild(a),n.appendChild(e)}}}}}renderBorder(e,t,n,r,i){e.strokeStyle=o._blackColor,e.beginPath(),e.moveTo(t,n+o._bevelSize),e.lineTo(t,n+i-o._bevelSize),e.lineTo(t+o._bevelSize,n+i),e.lineTo(t+r-o._bevelSize,n+i),e.lineTo(t+r,n+i-o._bevelSize),e.lineTo(t+r,n+o._bevelSize),e.lineTo(t+r-o._bevelSize,n),e.lineTo(t+o._bevelSize,n),e.closePath(),e.stroke(),e.save(),e.fillStyle=o._fillColor,e.globalCompositeOperation="destination-over",e.beginPath(),e.moveTo(t,n+o._bevelSize),e.lineTo(t,n+i-o._bevelSize),e.lineTo(t+o._bevelSize,n+i),e.lineTo(t+r-o._bevelSize,n+i),e.lineTo(t+r,n+i-o._bevelSize),e.lineTo(t+r,n+o._bevelSize),e.lineTo(t+r-o._bevelSize,n),e.lineTo(t+o._bevelSize,n),e.closePath(),e.fill(),e.restore()}renderWatermark(e){}renderLine(e){e.lineWidth=2,e.strokeStyle=o._blackColor,e.beginPath(),e.moveTo(this._currentX,this._currentY),e.lineTo(this._currentX+this._maxWidth,this._currentY),e.stroke(),this._currentY+=1}renderTableHeader(e,t,n){let r=this._currentX;const s=this._maxWidth;e.fillStyle=o._grey1,e.fillRect(this._currentX,this._currentY,s,22),e.fillStyle=o._blackColor,e.font=o._titleFont;var a=50;if(t){e.font=o._headerFont;for(let o=0;o1?n+=e._count+" "+e._name:n+=e._name,r++,r!=t.length&&(n+=", ");this._currentY+=2,this._currentY=(0,i.RenderParagraph)(e,n,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth,0),this._currentY+=2}renderWoundBoxes(e,t){e.font=o._titleFont,(0,i.RenderText)(e,"WOUNDS",this._currentX+20,this._currentY,100,16,i.Justification.Left);const n=this._currentX+this._descriptionStartX,r=n+195;e.save();for(let s of t)if(s._wounds>1){let t=this._currentY;e.font=o._font,e.fillStyle=o._blackColor,this._currentY=(0,i.RenderParagraph)(e,s._name,n,this._currentY+3,195,0);let a=this._currentX+r;e.strokeStyle=o._blackColor,e.fillStyle="#ffffff";for(let n=0;n{u.push(e*this._maxWidth)}));const d=[];this._vehicleLabelWidthsNormalized.forEach((e=>{d.push(e*this._maxWidth)}));const h=[];this._walkerLabelWidthsNormalized.forEach((e=>{h.push(e*this._maxWidth)}));const f=[];for(var p of(this._flyerLabelWidthsNormalized.forEach((e=>{f.push(e*this._maxWidth)})),e._models)){c.push(p);for(let e of p._weapons)s.push(e);for(let e of p._psychicPowers)a.push(e);p._psyker&&l.push(p._psyker)}const _=[],m=new Map;for(const e of c)m.has(e._name)||(m.set(e._name,e),_.push(e));if(_.length>0){this.renderTableHeader(i,o._unitLabels,u);let e=0;for(var p of _)this.renderModel(i,p,u,e%2),e++}if(e._vehicles.length>0){this.renderTableHeader(i,o._vehicleLabels,d);let t=0;for(var g of e._vehicles)this.renderVehicle(i,g,d,t%2),t++}if(e._walkers.length>0){this.renderTableHeader(i,o._walkerLabels,h);let t=0;for(var v of e._walkers)this.renderWalker(i,v,h,t%2),t++}if(e._flyers.length>0){this.renderTableHeader(i,o._flyerLabels,f);let t=0;for(var b of e._flyers)this.renderFlyer(i,b,f,t%2),t++}const y=[],w=new Map;for(const e of s)w.has(e._name)||(w.set(e._name,e),y.push(e));if(y.length>0){const e=[];this._weaponLabelWidthNormalized.forEach((t=>{e.push(t*this._maxWidth)})),this.renderLine(i),this.renderTableHeader(i,o._weaponLabels,e),this.renderWeapons(i,y,e)}if(a.length>0){const e=[];this._spellLabelWidthNormalized.forEach((t=>{e.push(t*this._maxWidth)})),this.renderLine(i),this.renderTableHeader(i,o._spellLabels,e),this.renderPowers(i,a,e)}if(e._abilities.size>0&&(this.renderLine(i),this._currentY+=2,this.renderAbilities(i,e)),l.length>0&&(this.renderLine(i),this._currentY+=2,this.renderPsykers(i,l)),e._rules.size>0&&(this.renderLine(i),this._currentY+=2,this.renderRules(i,e)),e._factions.size>0&&(this.renderLine(i),this._currentY+=2,this.renderFactions(i,e)),e._keywords.size>0&&(this.renderLine(i),this._currentY+=2,this.renderKeywords(i,e)),e._models.length>0&&(this.renderLine(i),this._currentY+=2,this.renderModelList(i,_)),this._showWoundBoxes){let t=!1;for(let n of e._models)n._wounds>2&&(t=!0);t&&(this.renderLine(i),this._currentY+=5,this.renderWoundBoxes(i,e._models))}this._currentY+=2;const C=this._currentY-(r+o._margin),x=this._maxWidth;return this.renderBorder(i,this._currentX,r+o._margin,x,C),this.renderWatermark(i),[this._maxWidth,this._currentY]}renderHeader(e,t){t.globalAlpha=1,t.fillStyle=o._blackColor;const n=this._currentX,r=this._currentX+this._maxWidth,s=this._currentY,a=s+36;t.beginPath(),t.moveTo(n,s+o._bevelSize),t.lineTo(n,a),t.lineTo(r,a),t.lineTo(r,s+o._bevelSize),t.lineTo(r-o._bevelSize,s),t.lineTo(n+o._bevelSize,s),t.closePath(),t.fill();let l=n+6;if(this._octagon){t.drawImage(this._octagon,l,s+2,32,32);const n=this._roles.get(e._role);n&&t.drawImage(n,l+4,s+2+4,24,24),t.fillStyle="white",t.font="18px serif",l+=34,t.drawImage(this._octagon,l,s+2,32,32),(0,i.RenderText)(t,e._points.toString(),l,s+2,32,32,i.Justification.Center)}let c=0,u=28;const d=l+6;t.font=u+"px bold serif";const h=e._name.toLocaleUpperCase();let f=t.measureText(h);const p=this._maxWidth-d;for(;c<6&&f.width>p;)c+=1,u-=2,t.font=u+"px bold serif",f=t.measureText(h);t.fillStyle="white",t.textBaseline="top",(0,i.RenderText)(t,h,d,s,p,36,i.Justification.Center),this._currentY+=36}renderPsykers(e,t){e.font=o._titleFont,(0,i.RenderText)(e,"PSYKERS",this._currentX+20,this._currentY,100,16,i.Justification.Left),e.font=o._font,this._currentY+=2;for(let n of t)this._currentY=(0,i.RenderParagraph)(e,"MASTERY LEVEL: "+n._masteryLevel,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth,0),this._currentY+=2,this._currentY=(0,i.RenderParagraph)(e,"DISCIPLINES: "+n._disciplines,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth,0),this._currentY+=2}}t.Renderer30k=o,o._res=144,o._margin=0,o._bevelSize=15,o._blackColor="#1d272a",o._grey1="#b3bbb5",o._greyLight="#dde1df",o._fillColor="#f6f6f6",o._titleFont="bold 14px sans-serif",o._headerFont="bold 14px sans-serif",o._font="14px sans-serif",o._boldFont="bold 14px sans-serif",o._unitLabels=["MODEL","WS","BS","S","T","W","I","A","LD","SAVE"],o._vehicleLabels=["MODEL","BS","FRONT","SIDE","REAR","HP","TYPE"],o._walkerLabels=["MODEL","WS","BS","S","FRONT","SIDE","REAR","I","A","HP","TYPE"],o._flyerLabels=["MODEL","BS","FRONT","SIDE","REAR","HP","TYPE","ROLE","PURSUIT","AGILITY"],o._weaponLabels=["WEAPONS","RANGE","S","AP","TYPE"],o._spellLabels=["PSYCHIC POWER","WARP CHARGE","RANGE","DETAILS"]},467:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Renderer40k=void 0;const r=n(288),i=n(682),o=n(361),s=n(219);class a{constructor(e){this._roster=null,this._roles=new Map,this._unitLabelWidthsNormalized=[.25,.05,.05,.05,.05,.05,.05,.05,.05,.05],this._weaponLabelWidthNormalized=[.25,.05,.1,.05,.05,.05,.45],this._spellLabelWidthNormalized=[.25,.05,.1,.6],this._explosionLabelWidthNormalized=[.2,.1,.1,.15],this._trackerLabelWidth=[.2,.15,.1,.1,.1],this._roster=e,this._roles.set(r.UnitRole.HQ,document.getElementById("role_hq")),this._roles.set(r.UnitRole.TR,document.getElementById("role_tr")),this._roles.set(r.UnitRole.EL,document.getElementById("role_el")),this._roles.set(r.UnitRole.FA,document.getElementById("role_fa")),this._roles.set(r.UnitRole.HS,document.getElementById("role_hs")),this._roles.set(r.UnitRole.FL,document.getElementById("role_fl")),this._roles.set(r.UnitRole.DT,document.getElementById("role_dt")),this._roles.set(r.UnitRole.FT,document.getElementById("role_ft")),this._roles.set(r.UnitRole.LW,document.getElementById("role_lw"))}render(e,t,n){if(null!=this._roster){if(e){this.renderOptionsDiv(e);const t=[`${this._roster._cost._points} pts`,`${this._roster._cost._powerLevel} PL`,`${this._roster._cost._commandPoints} CP`];for(const e in this._roster._cost._freeformValues)t.push(`${this._roster._cost._freeformValues[e]}${e}`);const n=`${this._roster.name()} (${t.join(", ")})`;e.appendChild(document.createElement("h3")).appendChild(document.createTextNode(n));const r=e.appendChild(document.createElement("div"));r.classList.add("footer"),r.appendChild(document.createElement("div")).appendChild(document.createTextNode("PrettyScribe")),r.appendChild(document.createElement("div")).appendChild(document.createTextNode(n)),this._roster._customNotes&&e.appendChild(document.createElement("p")).appendChild(document.createTextNode(this._roster._customNotes))}t&&(this.renderRosterSummary(t),this.renderAbilitiesByPhase(t)),n&&this.renderRosterDetails(n),(0,s.loadOptionsFromLocalStorage)()}}renderRosterSummary(e){if(!this._roster)return;const t=this._roster._forces.some((e=>e._units.some((e=>0!==e._cost._commandPoints))));for(const n of this._roster._forces){const i=document.createElement("div");if(n._faction?i.appendChild(document.createTextNode(`${n._catalog} ${n.name()} (${n._faction})`)):i.appendChild(document.createTextNode(`${n._catalog} ${n.name()}`)),n._configurations.length>0){const e=i.appendChild(document.createElement("ul"));for(const t of n._configurations)e.appendChild(document.createElement("li")).appendChild(document.createElement("i")).appendChild(document.createTextNode(t))}e.appendChild(i);const o=document.createElement("table");o.classList.add("table","table-sm","table-striped");const s=document.createElement("thead");o.appendChild(s),s.classList.add("thead-light");const a=document.createElement("tr");s.appendChild(a);const l=[{name:"NAME",w:"20%"},{name:"ROLE",w:"15%"},{name:"MODELS",w:"55%"},{name:"POINTS",w:"5%"},{name:"POWER",w:"5%"}];t&&l.push({name:"CP",w:"5%"}),l.forEach((e=>{let t=document.createElement("th");t.scope="col",t.appendChild(document.createTextNode(e.name)),t.style.width=e.w,a.appendChild(t)})),i.appendChild(o);let c=document.createElement("tbody");o.appendChild(c);for(let e of n._units){const n=document.createElement("tr");n.appendChild(document.createElement("td")).appendChild(document.createTextNode(e.nameWithExtraCosts())),n.appendChild(document.createElement("td")).appendChild(document.createTextNode(r.UnitRoleToString[e._role]));const i=n.appendChild(document.createElement("td"));if(this.renderModelList(i,e),n.appendChild(document.createElement("td")).appendChild(document.createTextNode(e._cost._points.toString())),n.appendChild(document.createElement("td")).appendChild(document.createTextNode(e._cost._powerLevel.toString())),t){const t=(e._cost._commandPoints||"")+"";n.appendChild(document.createElement("td")).appendChild(document.createTextNode(t))}c.appendChild(n)}}}renderOptionsDiv(e){const t=e.appendChild(document.createElement("div"));t.classList.add("wh40k_options_div","d-print-none"),t.id="wh40k_options_div";const n=t.appendChild(document.createElement("span"));(0,s.renderOptionsToggle)(n),(0,s.renderCheckboxOption)(t,"showPhaseAbilities","Show abilities by phase",(e=>{const t=document.getElementById("wh40k_abilities_list");t&&(e.target.checked?t.classList.remove("d-none"):t.classList.add("d-none"))})),(0,s.renderCheckboxOption)(t,"showUpgradeCosts","Show upgrade costs",(e=>{const t=document.getElementsByClassName("wh40k_upgrade_cost");for(const n of t)e.target.checked?n.classList.remove("d-none"):n.classList.add("d-none")})),(0,s.renderCheckboxOption)(t,"collateDatasheets","Collate Detachment Datasheets",(e=>{const t=document.getElementById("collated_sheets"),n=document.getElementById("detachment_sheets");t&&n&&(e.target.checked?(t.classList.remove("d-none"),n.classList.add("d-none")):(t.classList.add("d-none"),n.classList.remove("d-none")))}));const r=t.appendChild(document.createElement("span"));r.classList.add("wh40k_options_print_subsection"),r.appendChild(document.createTextNode("Print:")),(0,s.renderCheckboxOption)(r,"printBigger","Larger Text",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("bigger"):n.classList.remove("bigger")})),(0,s.renderCheckboxOption)(r,"hideElements","Hide Elements",(e=>{const t=document.body;e.target.checked?(t.classList.add("hide_enabled"),t.addEventListener("click",o.toggleHidden)):(t.classList.remove("hide_enabled"),t.removeEventListener("click",o.toggleHidden))})),(0,s.renderCheckboxOption)(r,"datasheetPageBreaks","One Datasheet per Page",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("page_break"):n.classList.remove("page_break")}))}renderAbilitiesByPhase(e){if(!this._roster)return;const t={},n={};for(const e of this._roster._forces)for(const r of e._units)for(const e of Object.values(r._abilities))for(const[i,s]of e.entries()){const e=[...s.matchAll(/(?:before the first turn begins|set up|Reinforcements|(?:Command|Movement|Psychic|Shooting|Charge|Fight|Morale) phase)/gi)];if(0===e.length)continue;const a=(0,o.addHideAble)(document.createElement("div"));a.appendChild(document.createElement("b")).appendChild(document.createTextNode(r.name())),a.appendChild(document.createTextNode(" - ")),a.appendChild(document.createElement("b")).appendChild(document.createTextNode(i)),a.appendChild(document.createTextNode(" - "));let l=s;for(const r of e){if(!r.index)continue;const e=r[0].toLocaleLowerCase();let o=e;switch(e){case"before the first turn begins":o="pre-game phase";break;case"set up":s.includes("reinforcements")||(o="pre-game phase");break;case"reinforcements":o="movement phase"}if(s.toLocaleLowerCase().includes("as if it were your "+o))continue;const c=r.index-(s.length-l.length);c>0&&a.appendChild(document.createTextNode(l.substring(0,c)));const u=t[o]=t[o]||[],d=n[o]=n[o]||[];d.includes(i)||(d.push(i),u.push(a)),a.appendChild(document.createElement("u")).appendChild(document.createTextNode(r[0]));const h=c+e.length;l=l.substring(h)}l.length>0&&a.appendChild(document.createTextNode(l))}const r=e.appendChild(document.createElement("div"));r.setAttribute("id","wh40k_abilities_list"),r.classList.add("d-none"),r.appendChild(document.createElement("h3")).appendChild(document.createTextNode("Abilities by Phase"));const i=["pre-game phase","command phase","movement phase","psychic phase","shooting phase","charge phase","fight phase","morale phase"].filter((e=>!!t[e]));if(0===i.length)r.appendChild(document.createTextNode("No phase-specific abilities in roster"));else for(const e of i){r.appendChild(document.createElement("h4")).appendChild(document.createTextNode(e));for(const n of t[e])r.appendChild(n.parentElement?n.cloneNode(!0):n)}}renderRosterDetails(e){if(!this._roster)return;const t=new Map,n=new Map,i=e.appendChild(document.createElement("div"));i.id="detachment_sheets";const o=e.appendChild(document.createElement("div"));o.id="collated_sheets",o.style.pageBreakBefore="always",o.classList.add("d-none");const s=[];for(const e of this._roster._forces){const r=document.createElement("div");if(r.style.pageBreakBefore="always",r){const t=document.createElement("p");t.appendChild(document.createTextNode(e._catalog)),e._faction&&t.appendChild(document.createTextNode(" ("+e._faction+")")),r.appendChild(t)}let o=document.createElement("h3");o.appendChild(r),i.appendChild(o),this.renderDatasheets(i,e._units),s.push(...e._units),l(t,e._catalog,e._rules),l(n,e._faction,e._factionRules)}s.sort(((e,t)=>e._role!=t._role?e._role-t._role:e._name!=t._name?(0,r.Compare)(e._name,t._name):e._cost._points-t._cost._points)),this.renderDatasheets(o,s);let a=document.createElement("div");a.style.pageBreakBefore="always",this.printRules(t,a),this.printRules(n,a),e.appendChild(a)}renderDatasheets(e,t){let n=0;for(let r=0;r1?` (${n})`:""),d],[.1,.8,.1]));const h=l.appendChild(document.createElement("tr"));for(let e=0;e<20;e++){const e=h.appendChild(document.createElement("td"));e.colSpan=1,e.style.width="5%",e.style.padding="0"}let f=(0,i.createNoteHead)("Unit notes",t);f&&s.appendChild(f),l=s.appendChild(document.createElement("thead")),l.classList.add("table-active"),l.appendChild((0,i.createTableRow)(a._unitLabels,this._unitLabelWidthsNormalized,!0));let p=s.appendChild(document.createElement("tbody"));p.append(document.createElement("tr"));for(const e of t._modelStats)p.append((0,i.createTableRow)([e._name,e._move,e._ws,e._bs,e._str.toString(),e._toughness.toString(),e._wounds.toString(),e._attacks.toString(),e._leadership.toString(),e._save],this._unitLabelWidthsNormalized));if(f=(0,i.createNotesHead)("Model notes",t._modelStats),f&&s.appendChild(f),t._woundTracker.length>0){const e=Array.from(a._trackerLabels);if(4==t._woundTracker.length){const n=Array.from(t._woundTracker[0]._table.values());e.splice(1,n.length,...n)}else if(3==t._woundTracker.length){const n=Array.from(t._woundTracker[0]._table.keys());e.splice(1,n.length,...n)}l=s.appendChild(document.createElement("thead")),l.classList.add("table-active"),l.appendChild((0,i.createTableRow)(e,this._trackerLabelWidth,!0)),p=s.appendChild(document.createElement("tbody")),p.append(document.createElement("tr"));for(const e of t._woundTracker)p.appendChild((0,i.createTableRow)([""].concat(Array.from(e._table.values())),this._trackerLabelWidth))}if(t._weapons.length>0){l=s.appendChild(document.createElement("thead")),l.classList.add("table-active"),l.appendChild((0,i.createTableRow)(a._weaponLabels,this._weaponLabelWidthNormalized,!0)),p=s.appendChild(document.createElement("tbody")),p.append(document.createElement("tr"));for(const e of t._weapons)p.append((0,i.createTableRow)([e.name().toString(),e._range,e._type,e._str.toString(),e._ap,e._damage,e._abilities],this._weaponLabelWidthNormalized))}if(f=(0,i.createNotesHead)("Weapon notes",t._weapons),f&&s.appendChild(f),t._spells.length>0){l=s.appendChild(document.createElement("thead")),l.classList.add("table-active"),l.appendChild((0,i.createTableRow)(a._spellLabels,this._spellLabelWidthNormalized,!0)),p=s.appendChild(document.createElement("tbody")),p.append(document.createElement("tr"));for(const e of t._spells)p.append((0,i.createTableRow)([e.name(),e._manifest.toString(),e._range,e._details],this._spellLabelWidthNormalized))}if(f=(0,i.createNotesHead)("Spell notes",t._spells),f&&s.appendChild(f),t._psykers.length>0){l=s.appendChild(document.createElement("thead")),l.classList.add("info_row");const e=document.createElement("div");for(const n of t._psykers){let t=`CAST: ${n._cast}, DENY: ${n._deny}, POWERS KNOWN: ${n._powers}`;n._other&&(t+=`, OTHER: ${n._other}`),e.appendChild(document.createElement("div")).appendChild(document.createTextNode(t))}l.appendChild((0,i.createTableRow)(["Psykers",e],[.1,.9],!1))}f=(0,i.createNotesHead)("Psyker notes",t._psykers),f&&s.appendChild(f),!t._abilities.Abilities&&t._rules.size>0&&this.renderUnitAbilitiesAndRules(s,"Abilities",new Map,t._rules);for(const e of Object.keys(t._abilities).sort()){const n=t._abilities[e],r="Abilities"===e?t._rules:void 0;this.renderUnitAbilitiesAndRules(s,e,n,r)}l=s.appendChild(document.createElement("thead")),l.classList.add("info_row");const _=Array.from(t._factions).sort(r.Compare).join(", ").toLocaleUpperCase();l.appendChild((0,i.createTableRow)(["Factions",_],[.1,.9],!1)),l=s.appendChild(document.createElement("thead")),l.classList.add("info_row");const m=Array.from(t._keywords).sort(r.Compare).join(", ").toLocaleUpperCase();l.appendChild((0,i.createTableRow)(["Keywords",m],[.1,.9],!1)),l=s.appendChild(document.createElement("thead")),l.classList.add("info_row");const g=document.createElement("div");if(this.renderModelList(g,t),l.appendChild((0,i.createTableRow)(["MODELS",g],[.1,.9],!1)),t._explosions.length>0){l=s.appendChild(document.createElement("thead")),l.classList.add("table-active"),l.appendChild((0,i.createTableRow)(a._explosionLabels,this._explosionLabelWidthNormalized,!0)),p=s.appendChild(document.createElement("tbody")),p.append(document.createElement("tr"));for(const e of t._explosions)p.append((0,i.createTableRow)([e.name(),e._diceRoll,e._distance,e._mortalWounds],this._explosionLabelWidthNormalized))}f=(0,i.createNotesHead)("Explosion notes",t._explosions),f&&s.appendChild(f)}renderUnitAbilitiesAndRules(e,t,n,s){const a=e.appendChild(document.createElement("thead"));a.classList.add("info_row");const l=document.createElement("div");if(s&&s.size>0){const e=Array.from(s.keys()).sort(r.Compare).join(", ");l.appendChild(document.createElement("div")).appendChild(document.createElement("b")).appendChild(document.createTextNode(e))}const c=Array.from(n.keys()).sort(r.Compare);for(const e of c){const t=(0,o.addHideAble)(l.appendChild(document.createElement("div")));t.appendChild(document.createElement("b")).appendChild(document.createTextNode(`${e.toUpperCase()}: `)),t.appendChild(document.createTextNode(n.get(e)||"??"))}a.appendChild((0,i.createTableRow)([t,l],[.1,.9],!1))}renderModelList(e,t){for(const n of t._models){const t=e.appendChild(document.createElement("div"));t.appendChild(document.createTextNode((n._count>1?`${n._count}x `:"")+n.name()));const r=n.getDedupedWeaponsAndUpgrades();if(0!==r.length){t.appendChild(document.createTextNode(" ("));for(const e of r)if(e!==r[0]&&t.appendChild(document.createTextNode(", ")),t.appendChild(document.createTextNode((e._count>1?`${e._count}x `:"")+e.selectionName())),e._cost.hasValues()){const n=t.appendChild(document.createElement("span"));n.classList.add("wh40k_upgrade_cost","d-none"),n.appendChild(document.createTextNode(` ${e._cost.toString()}`))}t.appendChild(document.createTextNode(")"))}}}printRules(e,t){if(0!==e.size&&t)for(let[n,r]of e.entries()){let e=document.createElement("div");e.classList.add("wh40k_rules");let i=document.createElement("h3");e.appendChild(i),i.appendChild(document.createTextNode(n));for(let t of r){let n=(0,o.addHideAble)(document.createElement("div")),r=document.createElement("b");r.appendChild(document.createTextNode(t[0]));let i=document.createElement("p");i.appendChild(document.createTextNode(t[1]||"")),n.appendChild(r),n.appendChild(i),e.appendChild(n)}t.appendChild(e)}}}function l(e,t,n){0!==n.size&&e.set(t,new Map([...e.get(t)||[],...n]))}t.Renderer40k=a,a._unitLabels=["MODEL","M","WS","BS","S","T","W","A","LD","SAVE"],a._weaponLabels=["WEAPONS","RANGE","TYPE","S","AP","D","ABILITIES"],a._spellLabels=["PSYCHIC POWER","MANIFEST","RANGE","DETAILS"],a._explosionLabels=["EXPLOSION","DICE ROLL","DISTANCE","MORTAL WOUNDS"],a._trackerLabels=["WOUND TRACK","REMAINING W","ATTRIBUTE","ATTRIBUTE","ATTRIBUTE"]},542:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Wh40kRenderer=void 0;const r=n(208),i=n(361),o=n(219),s=n(77);function a(e,t,n){0!==n.size&&e.set(t,new Map([...e.get(t)||[],...n]))}t.Wh40kRenderer=class{constructor(e){var t,n;this._roster=null,this._roles=new Map,this._unitLabelWidthsNormalized=[.4,.05,.05,.05,.05,.05,.05,.3],this._weaponLabelWidthNormalized=[.3,.1,.1,.05,.05,.05,.05,.3],this._roster=e;const i=(null===(t=this._roster)||void 0===t?void 0:t.hash())||0;this._rosterId=`${null===(n=this._roster)||void 0===n?void 0:n.name()}:${(i>>>0).toString(16)}`,this._roles.set(r.Wh40k.UnitRole.EpicHero,document.getElementById("role_hq")),this._roles.set(r.Wh40k.UnitRole.Character,document.getElementById("role_hq")),this._roles.set(r.Wh40k.UnitRole.Battleline,document.getElementById("role_tr")),this._roles.set(r.Wh40k.UnitRole.Infantry,document.getElementById("role_el")),this._roles.set(r.Wh40k.UnitRole.Vehicle,document.getElementById("role_hs")),this._roles.set(r.Wh40k.UnitRole.Mounted,document.getElementById("role_fa")),this._roles.set(r.Wh40k.UnitRole.Transport,document.getElementById("role_dt")),this._roles.set(r.Wh40k.UnitRole.Fortification,document.getElementById("role_ft"))}render(e,t,n){if(null==this._roster)return;const r=[`${this._roster._cost._points} pts`];for(const e in this._roster._cost._freeformValues)r.push(`${this._roster._cost._freeformValues[e]}${e}`);const i=`${this._roster.name()} (${r.join(", ")})`;null==e||e.appendChild(s.PsJsx.createElement(s.PsJsx.createFragment,null,this.renderOptionsDiv(),s.PsJsx.createElement("h3",null,i),s.PsJsx.createElement("div",{className:"footer"},s.PsJsx.createElement("div",null,"PrettyScribe"),s.PsJsx.createElement("div",null,i)),this._roster._customNotes&&s.PsJsx.createElement("p",null,this._roster._customNotes))),null==t||t.appendChild(s.PsJsx.createElement(s.PsJsx.createFragment,null,this.renderRosterSummary(),this.renderAbilitiesByPhase())),null==n||n.appendChild(this.renderRosterDetails()),(0,o.loadOptionsFromLocalStorage)(),this.loadDatasheetOrderFromLocalStorage(),this.collapseIdenticalUnits()}renderRosterSummary(){var e;return s.PsJsx.createElement(s.PsJsx.createFragment,null,null===(e=this._roster)||void 0===e?void 0:e._forces.map((e=>this.renderForceSummary(e))))}renderForceSummary(e){let t;const n=s.PsJsx.createElement("div",null,e._faction?`${e._catalog} ${e.name()} (${e._faction})`:`${e._catalog} ${e.name()}`,e._configurations.length>0&&s.PsJsx.createElement("ul",null,e._configurations.map((e=>s.PsJsx.createElement("li",null,s.PsJsx.createElement("i",null,e))))),s.PsJsx.createElement("table",{className:"table table-sm table-striped"},s.PsJsx.createElement("thead",{className:"thead-light"},s.PsJsx.createElement("tr",null,s.PsJsx.createElement("th",{scope:"col",style:"width: 20%;"},"NAME"),s.PsJsx.createElement("th",{scope:"col",style:"width: 15%;"},"ROLE"),s.PsJsx.createElement("th",{scope:"col",style:"width: 55%;"},"MODELS"),s.PsJsx.createElement("th",{scope:"col",style:"width: 5%;"},"POINTS"))),s.PsJsx.createElement("tbody",{ref:e=>{t=e}},e._units.map(((e,t)=>s.PsJsx.createElement("tr",{"data-index":t},s.PsJsx.createElement("td",null,e.nameWithExtraCosts()),s.PsJsx.createElement("td",null,r.Wh40k.UnitRoleToString[e._role]),s.PsJsx.createElement("td",null,this.renderModelList(e)),s.PsJsx.createElement("td",null,e._cost._points.toString())))))),s.PsJsx.createElement("button",{id:"reset-order-button",className:"d-none btn btn-secondary d-print-none",onclick:e=>this.resetDatasheetOrder(t)},"Reset datasheet order"));return this.makeForceSummaryListItemsDraggable(t),n}makeForceSummaryListItemsDraggable(e){for(const t of e.children)t.draggable=!0,t.classList.add("draggable");let t,n;e.addEventListener("dragstart",(e=>{t=e.target.closest("[draggable]"),e.dataTransfer.effectAllowed="move"})),e.addEventListener("dragover",(e=>{e.preventDefault();const t=e.target.closest("[draggable]");n!==t&&(null==n||n.classList.remove("draggable_drop_target_top"),null==t||t.classList.add("draggable_drop_target_top"),n=t)})),e.addEventListener("drop",(e=>{e.preventDefault(),null==n||n.classList.remove("draggable_drop_target_top");const r=e.target.closest("[draggable]");if(!t||t===r)return;const i=t.parentElement;i.insertBefore(t,r),this.orderDatasheetsToMatchSummary(i),this.collapseIdenticalUnits(),this.saveDatasheetOrderToLocalStorage()}))}orderDatasheetsToMatchSummary(e){const t=e.children;let n=!0;for(let e=0;e0){const i=t[e-1].dataset.index||-1;n&&(n=+(r||0)>+i)}const i=document.querySelector(`.wh40k_unit_sheet[data-index="${r}"]`);i&&(i.style.order=String(e))}const r=document.querySelector("#reset-order-button");n?null==r||r.classList.add("d-none"):null==r||r.classList.remove("d-none")}collapseIdenticalUnits(){var e,t;const n=document.querySelectorAll(".wh40k_unit_sheet"),r=Array.from(n).sort(((e,t)=>+e.style.order-+t.style.order));let i=null;for(const n of r){n.classList.remove("d-none");const r=n.querySelector("div.unit_count > span");if(i&&(null==i?void 0:i.dataset.hash)===n.dataset.hash){i.classList.add("d-none");const t=i.querySelector("div.unit_count > span"),n=+((null==t?void 0:t.dataset.count)||"");r.dataset.count=String(n+1),null===(e=r.parentElement)||void 0===e||e.classList.remove("d-none")}else r.dataset.count=String(1),null===(t=r.parentElement)||void 0===t||t.classList.add("d-none");i=n}}saveDatasheetOrderToLocalStorage(){try{const e=document.querySelectorAll("tr.draggable"),t=Array.from(e).map((e=>e.dataset.index));(0,o.saveOptionToLocalStorage)(`40k-order-${this._rosterId}`,JSON.stringify(t))}catch(e){console.warn("Error in saveDatasheetOrderToLocalStorage",e)}}loadDatasheetOrderFromLocalStorage(){var e;try{const t=JSON.parse(window.localStorage[`40k-order-${this._rosterId}`]||"[]"),n=null===(e=document.querySelector("tr.draggable"))||void 0===e?void 0:e.parentElement;if(t.length){const e=Array.from(n.children);for(let r=0;r+(e.dataset.index||0)-+(t.dataset.index||0)));for(const n of t)e.appendChild(n);this.orderDatasheetsToMatchSummary(e),this.collapseIdenticalUnits()}catch(e){console.warn("Error in resetDatasheetOrder",e)}}renderOptionsDiv(){const e=s.PsJsx.createElement("div",{className:"wh40k_options_div d-print-none",id:"wh40k_options_div"}),t=e.appendChild(s.PsJsx.createElement("span",null));(0,o.renderOptionsToggle)(t),(0,o.renderCheckboxOption)(e,"showPhaseAbilities","Show abilities by phase",(e=>{const t=document.getElementById("wh40k_abilities_list");t&&(e.target.checked?t.classList.remove("d-none"):t.classList.add("d-none"))})),(0,o.renderCheckboxOption)(e,"showUpgradeCosts","Show upgrade costs",(e=>{const t=document.getElementsByClassName("wh40k_upgrade_cost");for(const n of t)e.target.checked?n.classList.remove("d-none"):n.classList.add("d-none")})),(0,o.renderCheckboxOption)(e,"showArmyRules","Show army rules",(e=>{const t=document.getElementById("all-army-rules");e.target.checked?null==t||t.classList.remove("d-none"):null==t||t.classList.add("d-none")}),!0),(0,o.renderCheckboxOption)(e,"singleColumnDatasheets","Single-Column Datasheets",(e=>{e.target.checked?document.body.classList.add("single_column"):document.body.classList.remove("single_column")}));const n=e.appendChild(s.PsJsx.createElement("span",{className:"wh40k_options_print_subsection"},"Print:"));return(0,o.renderCheckboxOption)(n,"printBigger","Larger Text",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("bigger"):n.classList.remove("bigger")})),(0,o.renderCheckboxOption)(n,"hideElements","Hide Elements",(e=>{const t=document.body;e.target.checked?(t.classList.add("hide_enabled"),t.addEventListener("click",i.toggleHidden)):(t.classList.remove("hide_enabled"),t.removeEventListener("click",i.toggleHidden))})),(0,o.renderCheckboxOption)(n,"datasheetPageBreaks","One Datasheet per Page",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("page_break"):n.classList.remove("page_break")})),e}renderAbilitiesByPhase(){if(!this._roster)return;const e={},t={};for(const n of this._roster._forces)for(const r of n._units)for(const n of Object.values(r._abilities))for(const[i,o]of n.entries()){const n=[...o.matchAll(/(?:before the first turn begins|set up|Reinforcements|(?:Command|Movement|Psychic|Shooting|Charge|Fight|Morale) phase)/gi)];if(0===n.length)continue;const a=s.PsJsx.createElement("div",{className:"hide_able"},s.PsJsx.createElement("b",null,r.name())," - ",s.PsJsx.createElement("b",null,i)," - ");let l=o;for(const r of n){if(!r.index)continue;const n=r[0].toLocaleLowerCase();let c=n;switch(n){case"before the first turn begins":c="pre-game phase";break;case"set up":o.includes("reinforcements")||(c="pre-game phase");break;case"reinforcements":c="movement phase"}if(o.toLocaleLowerCase().includes("as if it were your "+c))continue;const u=r.index-(o.length-l.length);u>0&&a.appendChild(document.createTextNode(l.substring(0,u)));const d=e[c]=e[c]||[],h=t[c]=t[c]||[];h.includes(i)||(h.push(i),d.push(a)),a.appendChild(s.PsJsx.createElement("u",null,r[0]));const f=u+n.length;l=l.substring(f)}l.length>0&&a.appendChild(document.createTextNode(l))}const n=["pre-game phase","command phase","movement phase","psychic phase","shooting phase","charge phase","fight phase","morale phase"].filter((t=>!!e[t]));return s.PsJsx.createElement("div",{id:"wh40k_abilities_list",className:"d-none"},s.PsJsx.createElement("h3",null,"Abilities by Phase"),0===n.length?"No phase-specific abilities in roster":n.map((t=>s.PsJsx.createElement(s.PsJsx.createFragment,null,s.PsJsx.createElement("h4",null,t),e[t].map((e=>e.cloneNode(!0)))))))}renderRosterDetails(){if(!this._roster)return;const e=new Map,t=new Map;return s.PsJsx.createElement(s.PsJsx.createFragment,null,s.PsJsx.createElement("div",{className:"page_break",style:"display: flex; flex-direction: column;"},this._roster._forces.map((n=>s.PsJsx.createElement(s.PsJsx.createFragment,null,this._roster._forces.length>1&&s.PsJsx.createElement("h3",null,s.PsJsx.createElement("div",{style:"page-break-before: always;"},s.PsJsx.createElement("p",null,n._catalog,n._faction&&` (${n._faction})`))),a(e,n._catalog,n._rules),a(t,n._faction,n._factionRules),n._units.map(((e,t)=>this.renderUnit(e,t))))))),s.PsJsx.createElement("div",{id:"all-army-rules",style:"page-break-before: always;"},this.renderRules(e),this.renderRules(t)))}renderUnit(e,t){var n;return s.PsJsx.createElement("div",{className:"wh40k_unit_sheet","data-hash":(e.hash()>>>0).toString(16),"data-name":e.name(),"data-index":String(t),style:`order: ${t};`},s.PsJsx.createElement("table",{className:"table table-sm table-striped"},s.PsJsx.createElement("thead",{className:"table-dark unit_header"},s.PsJsx.createElement("tr",{className:"hide_able"},s.PsJsx.createElement("td",{scope:"col",colspan:"2",style:"width: 10%;"},s.PsJsx.createElement("div",{className:"unit_costs"},s.PsJsx.createElement("span",null,(null===(n=this._roles.get(e._role))||void 0===n?void 0:n.cloneNode())||"-"),s.PsJsx.createElement("span",null,e._cost._points.toString()))),s.PsJsx.createElement("td",{scope:"col",colspan:"16",style:"width: 80%;"},e.name()),s.PsJsx.createElement("td",{scope:"col",colspan:"2",style:"width: 10%;"},s.PsJsx.createElement("div",{className:"unit_costs unit_count"},s.PsJsx.createElement("span",{className:"unit_count","data-count":"1"})))),s.PsJsx.createElement("tr",null,[...Array(20).keys()].map((e=>s.PsJsx.createElement("td",{colspan:"1",style:"width: 5%; padding: 0px;"})))),this.renderNotesHead("Unit notes",e)),s.PsJsx.createElement("thead",null,s.PsJsx.createElement("tr",null,s.PsJsx.createElement("td",{colspan:"20",className:"subTableTd"},s.PsJsx.createElement("div",null,this.renderProfilesTables(e),s.PsJsx.createElement("table",{className:"table table-sm table-striped"},!e._abilities.Abilities&&e._rules.size>0&&this.renderUnitAbilitiesAndRules("Abilities",new Map,e._rules),Object.entries(e._abilities).sort().map((([t,n])=>this.renderUnitAbilitiesAndRules(t,n,"Abilities"===t?e._rules:void 0)))))))),s.PsJsx.createElement("thead",{className:"info_row keywords_row"},s.PsJsx.createElement("tr",{class:"hide_able"},s.PsJsx.createElement("td",{colspan:"20"},s.PsJsx.createElement("div",{class:"wh40k_keywords_and_factions"},s.PsJsx.createElement("div",{class:"wh40k_keywords"},s.PsJsx.createElement("div",null,"Keywords"),s.PsJsx.createElement("div",null,Array.from(e._keywords).sort(r.Wh40k.Compare).join(", ").toLocaleUpperCase())),s.PsJsx.createElement("div",{class:"wh40k_factions"},s.PsJsx.createElement("div",null,"Factions"),s.PsJsx.createElement("div",null,Array.from(e._factions).sort(r.Wh40k.Compare).join(", ").toLocaleUpperCase())))))),s.PsJsx.createElement("thead",{className:"info_row"},s.PsJsx.createElement("tr",{class:"hide_able"},s.PsJsx.createElement("td",{scope:"col",colspan:"2",style:"width: 10%;"},"MODELS"),s.PsJsx.createElement("td",{scope:"col",colspan:"18",style:"width: 90%;"},s.PsJsx.createElement("div",null,this.renderModelList(e)))))))}renderProfilesTables(e){const t=Object.entries(e._profileTables).sort(((e,t)=>r.Wh40k.CompareProfileTableName(e[0],t[0]))).map((([e,t])=>[t,"Unit"===e?this._unitLabelWidthsNormalized:this._weaponLabelWidthNormalized]));return s.PsJsx.createElement("table",{className:"table table-sm table-striped wh40k_profiles"},t.map((([e,t])=>s.PsJsx.createElement(s.PsJsx.createFragment,null,s.PsJsx.createElement("thead",{className:"table-active"},s.PsJsx.createElement("tr",{className:"hide_able header_row"},t.map(((t,n)=>s.PsJsx.createElement("th",{scope:"col",colspan:Math.round(t/.05),style:`width: ${100*t}%;`},this.renderProfileTableHeaderCell(e._headers[n])))))),s.PsJsx.createElement("tbody",null,s.PsJsx.createElement("tr",null)," ",e._contents.map((e=>s.PsJsx.createElement("tr",{className:"hide_able"},t.map(((t,n)=>s.PsJsx.createElement("td",{scope:"col",colspan:Math.round(t/.05),style:`width: ${100*t}%;`},e[n])))))))))))}renderProfileTableHeaderCell(e){return"Ranged Weapons"===e||"Melee Weapons"===e?s.PsJsx.createElement(s.PsJsx.createFragment,null,s.PsJsx.createElement("span",{class:"desktop-only"},e),s.PsJsx.createElement("span",{class:"mobile-only"},e.replace(" Weapons",""))):"Range"===e?s.PsJsx.createElement(s.PsJsx.createFragment,null,s.PsJsx.createElement("span",{class:"desktop-only"},e),s.PsJsx.createElement("span",{class:"mobile-only"},"Rng")):s.PsJsx.createElement(s.PsJsx.createFragment,null,e)}renderUnitAbilitiesAndRules(e,t,n){return s.PsJsx.createElement(s.PsJsx.createFragment,null,s.PsJsx.createElement("thead",{className:"info_row table-active"},s.PsJsx.createElement("tr",{className:"header_row"},s.PsJsx.createElement("th",null,e))),s.PsJsx.createElement("tbody",{className:"info_row"},s.PsJsx.createElement("tr",null)," ",n&&n.size>0&&s.PsJsx.createElement("tr",{className:"hide_able"},s.PsJsx.createElement("td",{scope:"col",style:"width: 100%;"},s.PsJsx.createElement("div",null,s.PsJsx.createElement("div",null,s.PsJsx.createElement("b",null,Array.from(n.keys()).sort(r.Wh40k.Compare).join(", ")))))),Array.from(t.keys()).sort(r.Wh40k.Compare).map((e=>s.PsJsx.createElement("tr",{className:"hide_able"},s.PsJsx.createElement("td",{scope:"col",style:"width: 100%;"},s.PsJsx.createElement("div",null,s.PsJsx.createElement("div",{className:"hide_able"},s.PsJsx.createElement("b",null,`${e.toUpperCase()}: `),t.get(e)||"??"))))))))}renderModelList(e){return e._models.map((e=>s.PsJsx.createElement("div",null,e._count>1?`${e._count}x `:"",e.name(),e.getDedupedWeaponsAndUpgrades().length>0&&s.PsJsx.createElement(s.PsJsx.createFragment,null," (",e.getDedupedWeaponsAndUpgrades().map(((e,t)=>s.PsJsx.createElement(s.PsJsx.createFragment,null,t>0?", ":"",e._count>1?`${e._count}x `:"",e.selectionName(),e._cost.hasValues()&&s.PsJsx.createElement("span",{className:"wh40k_upgrade_cost d-none"},` ${e._cost.toString()}`)))),")"))))}renderRules(e){return 0===e.size?null:s.PsJsx.createElement(s.PsJsx.createFragment,null,Array.from(e.entries()).map((([e,t])=>s.PsJsx.createElement("div",{className:"wh40k_rules"},s.PsJsx.createElement("h3",null,e),Array.from(t.entries()).map((e=>s.PsJsx.createElement("div",{className:"hide_able"},s.PsJsx.createElement("b",null,e[0]),s.PsJsx.createElement("p",null,e[1]))))))))}renderNotesHead(e,t){return t.notes()?s.PsJsx.createElement("thead",{className:"info_row"},s.PsJsx.createElement("tr",null,s.PsJsx.createElement("td",{style:"width: 10%",colspan:"2"},e),s.PsJsx.createElement("td",{style:"width: 90%",colspan:"18"},t._customNotes))):null}}},964:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RendererAoS=void 0;const r=n(774);t.RendererAoS=class{constructor(e){this._roster=null,this._roster=e}render(e,t,n){if(null!=this._roster){if(e){e.innerHTML="

"+this._roster._name.toUpperCase()+" ("+this._roster._points+" pts, "+this._roster._commandPoints+" CP)

";let t=document.createElement("h3");t.textContent="ROSTER",e.appendChild(t)}for(let e of this._roster._forces){const i=document.createElement("div");i&&(i.innerHTML="

"+e._catalog+" "+e._name+"

"),t&&t.appendChild(i);const o=[{name:"NAME",width:"35%"},{name:"ROLE",width:"15%"},{name:"SELECTIONS",width:"40%"},{name:"POINTS",width:"10%"}],s=this.createTable(o);s.classList.add("table","table-sm","aos_font"),i.appendChild(s);let a=document.createElement("tbody");s.appendChild(a);for(let t of e._units){let e=document.createElement("tr"),n=document.createElement("td");n.innerHTML=`${t._name}`;let i=document.createElement("td");i.innerHTML=r.AoSUnitRoleToString[t._role];let o=document.createElement("td");o.innerHTML="";for(const e of t._selections)o.innerHTML+=e+"
";let s=document.createElement("td");s.textContent=t._points.toString(),e.appendChild(n),e.appendChild(i),e.appendChild(o),e.appendChild(s),a.appendChild(e)}let l=document.createElement("div"),c=document.createElement("h3");if(c.textContent=e._allegiance._name.toUpperCase(),l.appendChild(c),e._allegiance._commandAbilities.size>0&&this.renderAbilityMap(l,"ABILITIES",e._allegiance._commandAbilities),e._allegiance._battleTraits.size>0&&this.renderAbilityMap(l,"BATTLE TRAITS",e._allegiance._battleTraits),e._allegiance._spells.length>0){let t=document.createElement("h4");t.textContent="ALLEGIANCE SPELLS",l.append(t),this.renderSpells(l,e._allegiance._spells)}if(e._allegiance._extraProfiles.length>0){let t="";for(let n of e._allegiance._extraProfiles)if(1==n._value._fields.size){if(t!=n._value._typeName){let e=document.createElement("h4");l.appendChild(e),e.textContent=n._value._typeName.toUpperCase(),t=n._value._typeName}const e=n._value._fields.values();let r=document.createElement("p");r.classList.add("aos_font"),r.innerHTML=`${n._name}: ${e.next().value}`,l.appendChild(r)}else console.log("Table profiles not implemented. "+n._value._typeName)}if(e._grandStrategy&&""!=e._grandStrategy._name){let t=document.createElement("h3");l.appendChild(t),t.textContent="GRAND STRATEGY";let n=document.createElement("div"),r=document.createElement("h4");r.textContent=e._grandStrategy._name;let i=document.createElement("p");i.textContent=e._grandStrategy._description,n.appendChild(r),n.appendChild(i),l.appendChild(n)}if(e._triumph&&""!=e._triumph._name){let t=document.createElement("h3");l.appendChild(t),t.textContent="TRIUMPH";let n=document.createElement("div"),r=document.createElement("h4");r.textContent=e._triumph._name;let i=document.createElement("p");i.textContent=e._triumph._description,n.appendChild(r),n.appendChild(i),l.appendChild(n)}if(e._realmOfBattle&&e._realmOfBattle._name.length>0){let t=document.createElement("h3");if(l.appendChild(t),t.textContent="REALM OF BATTLE ("+e._realmOfBattle._name+")",e._realmOfBattle._spells.length>0){let t=document.createElement("h4");t.textContent="SPELLS",l.append(t),this.renderSpells(l,e._realmOfBattle._spells)}if(e._realmOfBattle._commandAbilities.size>0&&this.renderAbilityMap(l,"COMMAND ABILITIES",e._realmOfBattle._commandAbilities),e._realmOfBattle._rules.length>0){let t=document.createElement("h4");t.textContent="SPECIAL RULES",l.append(t);for(let t of e._realmOfBattle._rules){let e=document.createElement("div"),n=document.createElement("p");n.textContent=t._name+": "+t._description,e.appendChild(n),l.appendChild(e)}}}for(let t of e._rules){let e=document.createElement("h3");l.appendChild(e),e.textContent="RULES";let n=document.createElement("div"),r=document.createElement("h4");r.textContent=t[0];let i=document.createElement("p");i.textContent=t[1],n.appendChild(r),n.appendChild(i),l.appendChild(n)}if(e._battleTactics.size>0){let t=document.createElement("h3");t.textContent="BATTLE TACTICS",l.appendChild(t);const n=[{name:"NAME",width:"20%"},{name:"DESCRIPTION",width:"80%"}],r=this.createTable(n);r.classList.add("table","table-sm","aos_table","aos_font");let i=document.createElement("tbody");r.appendChild(i);for(let t of e._battleTactics){let e=document.createElement("tr"),n=document.createElement("td");n.textContent=t[0];let r=document.createElement("td");r.textContent=t[1],e.appendChild(n),e.appendChild(r),i.appendChild(e)}l.appendChild(r)}for(let t of e._battalions){let e=document.createElement("h3");l.appendChild(e),e.textContent=t._name.toUpperCase();for(let e of t._abilities){let t=document.createElement("div"),n=document.createElement("h4");n.textContent=e[0];let r=document.createElement("p");r.textContent=e[1],t.appendChild(n),t.appendChild(r),l.appendChild(t)}}if(!n)continue;n.appendChild(l);let u=document.createElement("hr");u.classList.add("aos_dark"),n.appendChild(u);for(let t of e._units){n.appendChild(this.renderUnitHtml(t));let e=document.createElement("hr");e.classList.add("aos_dark"),n.appendChild(e)}}}}createTable(e){const t=document.createElement("table"),n=document.createElement("thead");t.appendChild(n),n.classList.add("aos_light");const r=document.createElement("tr");return n.appendChild(r),e.forEach((e=>{let t=document.createElement("th");t.scope="col",t.textContent=e.name,t.style.width=e.width,r.appendChild(t)})),t}internalKeyword(e){return e.toUpperCase()!=e}renderUnitHtml(e){let t=document.createElement("div");t.classList.add("container-fluid","aos_unit");let n=document.createElement("div");n.classList.add("p-2","mb-2","aos_medium","text-center","text-uppercase","text-black"),n.innerHTML=`${e._name}`,t.append(n);let r=document.createElement("div");if(r.classList.add("row"),t.append(r),e.isNormalUnit()){let t=document.createElement("div");t.classList.add("col-3"),t.innerHTML=`
\n

${e._move}

\n

${e._wounds}

\n

${e._bravery}

\n

${e._save}

\n
`,r.append(t)}let i=document.createElement("div");i.classList.add("col"),r.appendChild(i);let o=document.createElement("table");o.classList.add("table","table-sm","aos_table","aos_font","text-center");let s=document.createElement("thead");o.appendChild(s),o.innerHTML='\n Missile Weapons\n Range\n Attacks\n To Hit\n To Wound\n Rend\n Damage\n ';let a=document.createElement("tbody");o.appendChild(a);let l=document.createElement("table");l.classList.add("table","table-sm","aos_table","aos_font","text-center"),s=document.createElement("thead"),l.appendChild(s),l.innerHTML='\n Melee Weapons\n Range\n Attacks\n To Hit\n To Wound\n Rend\n Damage\n ';let c=document.createElement("tbody");l.appendChild(c);let u=!1,d=!1;for(let t of e._weapons)if("Missile"===t._type){let e=document.createElement("tr");e.innerHTML=`${t._name}${t._range}${t._attacks}\n ${t._toHit}${t._toWound}${t._rend}${t._damage}`,a.appendChild(e),u=!0}else if("Melee"===t._type){let e=document.createElement("tr");e.innerHTML=`${t._name}${t._range}${t._attacks}\n ${t._toHit}${t._toWound}${t._rend}${t._damage}`,c.appendChild(e),d=!0}if(u&&i.appendChild(o),d&&i.appendChild(l),e._woundTracker&&e._woundTracker._labels.length>0){let t=[];const n=(1/e._woundTracker._labels.length*100).toString()+"%";for(let r of e._woundTracker._labels)t.push({name:r,width:n});const r=this.createTable(t);r.classList.add("table","table-sm","aos_table","aos_font","text-center"),i.appendChild(r);let o=document.createElement("tbody");r.appendChild(o);for(let t of e._woundTracker._table){let e=document.createElement("tr");for(let n of t){let t=document.createElement("td");t.textContent=n,e.appendChild(t)}o.appendChild(e)}}if(e._abilities.size>0&&this.renderAbilityMap(i,"ABILITIES",e._abilities),e._commandAbilities.size>0&&this.renderAbilityMap(i,"COMMAND ABILITIES",e._commandAbilities),e._commandTraits.size>0&&this.renderAbilityMap(i,"COMMAND TRAITS",e._commandTraits),e._magic.size>0&&this.renderAbilityMap(i,"MAGIC",e._magic),e._spells.length>0){let t=document.createElement("h4");t.textContent="SPELLS",i.appendChild(t),this.renderSpells(i,e._spells)}if(e._prayers.length>0){let t=document.createElement("h4");t.textContent="PRAYERS",i.appendChild(t);const n=[{name:"NAME",width:"20%"},{name:"ANSWER VALUE",width:"10%"},{name:"RANGE",width:"10%"},{name:"DESCRIPTION",width:"60%"}],r=this.createTable(n);r.classList.add("table","table-sm","aos_table","aos_font");let o=document.createElement("tbody");r.appendChild(o);for(let t of e._prayers){let e=document.createElement("tr"),n=document.createElement("td");n.textContent=t._name;let r=document.createElement("td");r.textContent=t._answerValue.toString();let i=document.createElement("td");i.textContent=t._range.toString();let s=document.createElement("td");s.textContent=t._description,e.appendChild(n),e.appendChild(r),e.appendChild(i),e.appendChild(s),o.appendChild(e)}i.appendChild(r)}e._artefacts.size>0&&this.renderAbilityMap(i,"ARTEFACTS",e._artefacts);let h="";for(let t of e._extraProfiles)if(1==t._value._fields.size){if(h!=t._value._typeName){let e=document.createElement("h4");i.appendChild(e),e.textContent=t._value._typeName.toUpperCase(),h=t._value._typeName}const e=t._value._fields.values();let n=document.createElement("p");n.classList.add("aos_font"),n.innerHTML=`${t._name}: ${e.next().value}`,i.appendChild(n)}else console.log("Table profiles not implemented. "+t._value._typeName);if(e._keywords.size>0){let n=document.createElement("div");n.classList.add("container-fluid");let r=document.createElement("div");r.classList.add("row"),n.appendChild(r);let i=document.createElement("div");i.classList.add("col-5","border","aos_dark","text-center"),i.innerHTML="KEYWORDS",r.appendChild(i);let o="",s="";for(let t of e._keywords)this.internalKeyword(t)||(s+=o,s+=t,o=", ");let a=document.createElement("div");a.classList.add("col","border","text-left","text-uppercase"),a.innerText=s,r.appendChild(a),t.appendChild(n)}return t}renderAbilityMap(e,t,n){let r=document.createElement("h4");r.textContent=t,e.appendChild(r);for(let e of n){let t=document.createElement("p");t.classList.add("aos_font"),t.innerHTML=`${e[0]}: ${e[1]}`,r.appendChild(t)}}renderSpells(e,t){const n=this.createTable([{name:"NAME",width:"25%"},{name:"CASTING VALUE",width:"15%"},{name:"RANGE",width:"10%"},{name:"DESCRIPTION",width:"50%"}]);n.classList.add("table","table-sm","aos_font");let r=document.createElement("tbody");n.appendChild(r);for(let e of t){let t=document.createElement("tr"),n=document.createElement("td");n.textContent=e._name;let i=document.createElement("td");i.textContent=e._castingValue.toString();let o=document.createElement("td");o.textContent=e._range.toString();let s=document.createElement("td");s.textContent=e._description,t.appendChild(n),t.appendChild(i),t.appendChild(o),t.appendChild(s),r.appendChild(t)}e.appendChild(n)}}},66:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RendererHH2=void 0;const r=n(980);class i{constructor(e){this._roster=null,this._roles=new Map,this._infantryLabelWidthsNormalized=[.2,.2,.05,.05,.05,.05,.05,.05,.05,.05,.05,.05,.1],this._vehicleLabelWidthsNormalized=[.2,.2,.05,.05,.05,.05,.05,.05,.2,.1],this._knightLabelWidthsNormalized=[.2,.2,.05,.05,.05,.05,.05,.05,.05,.05,.05,.05,.1],this._fortificationLabelWidthsNormalized=[.2,.2,.05,.05,.05,.05,.05,.2,.15],this._weaponLabelWidthNormalized=[.25,.05,.05,.05,.15,.35],this._psychicWeaponLabelWidthNormalized=[.25,.05,.05,.05,.15,.35],this._psychicPowerLabelWidthNormalized=[.25,.75],this._wargearLabelWidthNormalized=[.25,.75],this._roster=e,this._roles.set(r.HorusHeresy.UnitRole.HQ,document.getElementById("role_hq")),this._roles.set(r.HorusHeresy.UnitRole.TR,document.getElementById("role_tr")),this._roles.set(r.HorusHeresy.UnitRole.EL,document.getElementById("role_el")),this._roles.set(r.HorusHeresy.UnitRole.FA,document.getElementById("role_fa")),this._roles.set(r.HorusHeresy.UnitRole.HS,document.getElementById("role_hs")),this._roles.set(r.HorusHeresy.UnitRole.FL,document.getElementById("role_fl")),this._roles.set(r.HorusHeresy.UnitRole.DT,document.getElementById("role_dt")),this._roles.set(r.HorusHeresy.UnitRole.FT,document.getElementById("role_ft")),this._roles.set(r.HorusHeresy.UnitRole.LW,document.getElementById("role_lw")),this._roles.set(r.HorusHeresy.UnitRole.PR,document.getElementById("role_lw"))}render(e,t,n){if(null!=this._roster){if(e){this.renderOptionsDiv(e);const t=[`${this._roster._cost._points} pts`],n=`${this._roster._name} (${t.join(", ")})`;e.appendChild(document.createElement("h3")).appendChild(document.createTextNode(n));const r=e.appendChild(document.createElement("div"));r.classList.add("footer"),r.appendChild(document.createElement("div")).appendChild(document.createTextNode("PrettyScribe")),r.appendChild(document.createElement("div")).appendChild(document.createTextNode(n))}t&&this.renderRosterSummary(t),n&&this.renderRosterDetails(n),this.loadOptionsFromLocalStorage()}}renderRosterSummary(e){if(this._roster)for(const t of this._roster._forces){const n=document.createElement("div");t._faction?n.appendChild(document.createTextNode(`${t._catalog} ${t._name} (${t._faction})`)):n.appendChild(document.createTextNode(`${t._catalog} ${t._name}`)),e.appendChild(n);const i=document.createElement("table");i.classList.add("table","table-sm","table-striped");const o=document.createElement("thead");i.appendChild(o),o.classList.add("thead-light");const s=document.createElement("tr");o.appendChild(s),[{name:"NAME",w:"20%"},{name:"ROLE",w:"15%"},{name:"MODELS",w:"55%"},{name:"POINTS",w:"5%"}].forEach((e=>{let t=document.createElement("th");t.scope="col",t.appendChild(document.createTextNode(e.name)),t.style.width=e.w,s.appendChild(t)})),n.appendChild(i);let a=document.createElement("tbody");i.appendChild(a);for(let e of t._units){const t=document.createElement("tr");t.appendChild(document.createElement("td")).appendChild(document.createTextNode(e._name)),t.appendChild(document.createElement("td")).appendChild(document.createTextNode(r.HorusHeresy.UnitRoleToString[e._role]));const n=t.appendChild(document.createElement("td"));this.renderModelList(n,e),t.appendChild(document.createElement("td")).appendChild(document.createTextNode(e._points.toString())),a.appendChild(t)}}}renderOptionsDiv(e){const t=e.appendChild(document.createElement("div"));t.classList.add("wh40k_options_div","d-print-none"),t.id="wh40k_options_div";const n=t.appendChild(document.createElement("span"));n.classList.add("wh40k_options_toggle"),n.id="wh40k_options_toggle";const r="[−] Options:";n.appendChild(document.createTextNode(r)),n.addEventListener("click",(e=>{const t=document.getElementById("wh40k_options_div"),n=document.getElementById("wh40k_options_toggle");t&&n&&(t.classList.contains("hide_options")?(t.classList.remove("hide_options"),n.innerText=r,this.saveOptionToLocalStorage("option-toggle-hidden","false")):(t.classList.add("hide_options"),n.innerText="[+] Options",this.saveOptionToLocalStorage("option-toggle-hidden","true")))})),this.renderCheckboxOption(t,"showUpgradeCosts","Show upgrade costs",(e=>{const t=document.getElementsByClassName("wh40k_upgrade_cost");for(const n of t)e.target.checked?n.classList.remove("d-none"):n.classList.add("d-none")})),this.renderCheckboxOption(t,"collateDatasheets","Collate Detachment Datasheets",(e=>{const t=document.getElementById("collated_sheets"),n=document.getElementById("detachment_sheets");t&&n&&(e.target.checked?(t.classList.remove("d-none"),n.classList.add("d-none")):(t.classList.add("d-none"),n.classList.remove("d-none")))}));const i=t.appendChild(document.createElement("span"));i.classList.add("wh40k_options_print_subsection"),i.appendChild(document.createTextNode("Print:")),this.renderCheckboxOption(i,"printBigger","Larger Text",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("bigger"):n.classList.remove("bigger")})),this.renderCheckboxOption(i,"hideElements","Hide Elements",(e=>{const t=document.body;e.target.checked?(t.classList.add("hide_enabled"),t.addEventListener("click",l)):(t.classList.remove("hide_enabled"),t.removeEventListener("click",l))})),this.renderCheckboxOption(i,"datasheetPageBreaks","One Datasheet per Page",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("page_break"):n.classList.remove("page_break")}))}renderCheckboxOption(e,t,n,r){const i=e.appendChild(document.createElement("div"));i.classList.add("wh40k_option");const o=i.appendChild(document.createElement("input"));o.setAttribute("type","checkbox"),o.setAttribute("name",t),o.setAttribute("id",t),o.addEventListener("input",r),o.addEventListener("change",(e=>this.saveCheckboxToLocalStorage(t)));const s=i.appendChild(document.createElement("label"));s.setAttribute("for",t),s.appendChild(document.createTextNode(` ${n}`))}saveCheckboxToLocalStorage(e){const t=document.getElementById(e);t&&this.saveOptionToLocalStorage(`option-checkbox-${e}`,t.checked)}saveOptionToLocalStorage(e,t){try{window.localStorage[e]=t}catch(e){}}loadOptionsFromLocalStorage(){var e;try{for(let t=0;te._role!=t._role?e._role-t._role:e._name!=t._name?r.HorusHeresy.Compare(e._name,t._name):e._points-t._points)),this.renderDatasheets(o,s);let u=document.createElement("div");u.style.pageBreakBefore="always",this.printRules(t,u),this.printRules(n,u),e.appendChild(u)}renderDatasheets(e,t){let n=0;for(let r=0;r1?` (${n})`:""),""],[.1,.8,.1]));const h=c.appendChild(document.createElement("tr"));for(let e=0;e<20;e++){const e=h.appendChild(document.createElement("td"));e.colSpan=1,e.style.width="5%",e.style.padding="0"}let f=function(e,t){if(!t.notes())return null;const n=document.createElement("thead");return n.classList.add("info_row"),n.appendChild(o(["Unit notes",t._customNotes],[.1,.9],!1)),n}(0,t);if(f&&l.appendChild(f),t._modelStats.length>0){const e=function(e){let t=new Map;const n=e.filter((e=>e instanceof r.HorusHeresy.Vehicle));t.set("Vehicles",n);const i=e.filter((e=>e instanceof r.HorusHeresy.Knight));t.set("Knights",i);const o=e.filter((e=>e instanceof r.HorusHeresy.Fortification));t.set("Fortifications",o);const s=e.filter((e=>e instanceof r.HorusHeresy.Model));return t.set("Models",s),t}(t._modelStats),n=e.get("Models");if(null!=n&&n.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._infantryLabels,this._infantryLabelWidthsNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of n){let n=t;e.append(o([n._name,n._type,n._move.toString(),n._ws.toString(),n._bs.toString(),n._str.toString(),n._toughness.toString(),n._wounds.toString(),n._initiative.toString(),n._attacks.toString(),n._leadership.toString(),n._save],this._infantryLabelWidthsNormalized))}}const s=e.get("Vehicles");if(null!=s&&s.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._vehicleLabels,this._vehicleLabelWidthsNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of s){let n=t;e.append(o([n._name,n._type,n._move.toString(),n._bs.toString(),n._front.toString(),n._side.toString(),n._rear.toString(),n._hp.toString(),n._capacity.toString()],this._vehicleLabelWidthsNormalized))}}const a=e.get("Knights");if(null!=a&&a.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._knightLabels,this._knightLabelWidthsNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of a){let n=t;e.append(o([n._name,n._type,n._move.toString(),n._ws.toString(),n._bs.toString(),n._str.toString(),n._front.toString(),n._side.toString(),n._rear.toString(),n._hp.toString(),n._initiative.toString(),n._attacks.toString(),n._hp.toString()],this._knightLabelWidthsNormalized))}}const u=e.get("Fortifications");if(null!=u&&u.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._fortificationLabels,this._fortificationLabelWidthsNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of u){let n=t;e.append(o([n._name,n._type,n._bs.toString(),n._front.toString(),n._side.toString(),n._rear.toString(),n._hp.toString(),n._capacity.toString()],this._fortificationLabelWidthsNormalized))}}}f=s("Model notes",t._models),f&&l.appendChild(f);const p=t.weapons();if(p.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._weaponLabels,this._weaponLabelWidthNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of p){let n=t._type.split(","),r=n[0].trim(),i=document.createElement("div");n.forEach(((e,t)=>{let n=e.trim();if(t>1&&i.appendChild(document.createTextNode(", ")),0!=t){let e=document.createElement("a");e.classList.add("hh2-rule-link"),e.href="#"+n,e.text=n,i.appendChild(e)}})),e.append(o([t.name().toString(),t._range,t._str.toString(),t._ap,r,i],this._weaponLabelWidthNormalized))}}f=s("Weapon notes",p),f&&l.appendChild(f);const _=t.wargear();if(_.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._wargearLabels,this._wargearLabelWidthNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of _)e.append(o([t.name(),t._description],this._wargearLabelWidthNormalized))}f=s("Wargear Item notes",_),f&&l.appendChild(f);const m=t.psychicWeapons();if(m.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._psychicWeaponLabels,this._psychicWeaponLabelWidthNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of m){let n=t._type.split(","),r=n[0].trim(),i=document.createElement("div");n.forEach(((e,t)=>{let n=e.trim();if(t>1&&i.appendChild(document.createTextNode(", ")),0!=t){let e=document.createElement("a");e.classList.add("hh2-rule-link"),e.href="#"+n,e.text=n,i.appendChild(e)}})),e.append(o([t.name().toString(),t._range,t._str.toString(),t._ap,r,i],this._psychicWeaponLabelWidthNormalized))}}f=s("Psychic Weapon notes",m),f&&l.appendChild(f);const g=t.psychicPowers();if(g.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._psychicPowerLabels,this._psychicPowerLabelWidthNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of g)e.append(o([t.name(),t._description],this._psychicPowerLabelWidthNormalized))}f=s("Psychic Power notes",g),f&&l.appendChild(f);const v=t.warlordTraits();if(v.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(["Warlord Trait","Description"],[.25,.75],!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of v)e.append(o([t.name(),t._description],[.25,.75]))}f=s("Warlord Trait notes",v),f&&l.appendChild(f);const b=t.reactions();if(b.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(["Reaction","Description"],[.25,.75],!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of b)e.append(o([t.name(),t._description],[.25,.75]))}if(t._rules.size>0){const e=Array.from(t._rules.keys()).sort(r.HorusHeresy.Compare),n=t.weaponRules();let i=[];for(const t of e)n.includes(t)||i.push(t);this.renderUnitRules(l,"Rules",i)}c=l.appendChild(document.createElement("thead")),c.classList.add("info_row");const y=Array.from(t._keywords).sort(r.HorusHeresy.Compare).join(", ").toLocaleUpperCase();c.appendChild(o(["Keywords",y],[.1,.9],!1)),c=l.appendChild(document.createElement("thead")),c.classList.add("info_row");const w=document.createElement("div");this.renderModelList(w,t),c.appendChild(o(["MODELS",w],[.1,.9],!1))}renderUnitRules(e,t,n){const r=e.appendChild(document.createElement("thead"));r.classList.add("info_row");const i=document.createElement("div");n.forEach(((e,t)=>{let n=e.trim();if(t>1&&i.appendChild(document.createTextNode(", ")),0!=t){let e=document.createElement("a");e.classList.add("hh2-rule-link"),e.href="#"+n,e.text=n,i.appendChild(e)}})),r.appendChild(o([t,i],[.1,.9],!1))}renderModelList(e,t){for(const n of t._models){const t=e.appendChild(document.createElement("div"));t.appendChild(document.createTextNode((n._count>1?`${n._count}x `:"")+n._name));const r=n.getDedupedWeaponsAndUpgrades();if(0!==r.length){t.appendChild(document.createTextNode(" ("));for(const e of r)if(e!==r[0]&&t.appendChild(document.createTextNode(", ")),t.appendChild(document.createTextNode((e._count>1?`${e._count}x `:"")+e.selectionName())),e._cost.hasValues()){const n=t.appendChild(document.createElement("span"));n.classList.add("wh40k_upgrade_cost","d-none"),n.appendChild(document.createTextNode(` ${e._cost.toString()}`))}t.appendChild(document.createTextNode(")"))}}}printRules(e,t){if(0!==e.size&&t)for(let[n,r]of e.entries()){let e=document.createElement("div");e.classList.add("wh40k_rules");let i=document.createElement("h3");e.appendChild(i),i.appendChild(document.createTextNode(n));for(let t of r){let n=a(document.createElement("div")),r=document.createElement("b");r.id=t[0],r.appendChild(document.createTextNode(t[0]));let i=document.createElement("p");i.appendChild(document.createTextNode(t[1]||"")),n.appendChild(r),n.appendChild(i),e.appendChild(n)}t.appendChild(e)}}}function o(e,t,n=!1){const r=a(document.createElement("tr"));n&&r.classList.add("header_row");for(let i=0,o=0;ie._customNotes)))return null;const n=document.createElement("thead");n.classList.add("info_row");const r=document.createElement("div");for(const e of t){if(!e.notes())continue;const t=r.appendChild(document.createElement("div"));t.appendChild(document.createElement("b")).appendChild(document.createTextNode(`${e.name()}: `)),t.appendChild(document.createTextNode(e._customNotes))}return n.appendChild(o([e,r],[.1,.9],!1)),n}function a(e){return e.classList.add("hide_able"),e}function l(e){let t=e.target;t&&(t=t.closest(".hide_able")),t&&(t.classList.contains("hidden")?t.classList.remove("hidden"):t.classList.add("hidden"))}t.RendererHH2=i,i._infantryLabels=["Model","Type","M","WS","BS","S","T","W","I","A","Ld","Sv",""],i._vehicleLabels=["Model","Type","M","BS","Front","Side","Rear","HP","Capacity",""],i._knightLabels=["Model","Type","M","WS","BS","S","Front","Side","Rear","I","A","HP",""],i._fortificationLabels=["Model","Type","BS","Front","Side","Rear","HP","Capacity",""],i._weaponLabels=["Weapon","Range","Str","AP","Type","Rules"],i._psychicWeaponLabels=["Psychic Weapon","Range","Str","AP","Type","Rules"],i._psychicPowerLabels=["Psychic Power","Description"],i._wargearLabels=["Wargear Item","Description"]},96:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RendererKT21=void 0;const r=n(249),i=n(419),o=n(682),s=n(361),a=n(219);class l{constructor(e){this._descriptionStartX=140,this._descriptionWidth=600,this._roster=null,this._octagon=null,this._specialisms=new Map,this._currentX=0,this._currentY=0,this._maxWidth=0,this._maxHeight=0,this._unitLabelWidthsNormalized=[.25,.05,.05,.05,.05,.05,.05],this._weaponLabelWidthNormalized=[.25,.05,.05,.05,.2,.2],this._spellLabelWidthNormalized=[.25,.75],this._roster=e,this._octagon=document.getElementById("octagon"),this._specialisms.set(r.Specialism.NONE,document.getElementById("role_hq")),this._specialisms.set(r.Specialism.COMBAT,document.getElementById("role_hs")),this._specialisms.set(r.Specialism.STAUNCH,document.getElementById("role_fa")),this._specialisms.set(r.Specialism.MARKSMAN,document.getElementById("role_el")),this._specialisms.set(r.Specialism.SCOUT,document.getElementById("role_tr"))}render(e,t,n){if(null==this._roster)return void console.log("Roster is NULL");if(e){this.renderOptionsDiv(e);const s=`${this._roster.name()} (${this._roster._equipmentPoints} EP)`;e.appendChild(document.createElement("h3")).appendChild(document.createTextNode(s))}let r=new Map,i=new Map;for(let l of this._roster._forces){let c=r.get(l._catalog);c||(c=new Map,r.set(l._catalog,c));let u=i.get(l._catalog);u||(u=new Map,i.set(l._faction,u));const d=document.createElement("div");d&&(l._faction?d.innerHTML="

"+l._faction+" - "+l.name()+"

":d.innerHTML="

"+l.name()+"

"),t&&t.appendChild(d);const h=document.createElement("table");h.classList.add("table"),h.classList.add("table-sm"),h.classList.add("table-striped");const f=document.createElement("thead");h.appendChild(f),f.classList.add("thead-light");const p=document.createElement("tr");f.appendChild(p),[{name:"MODELS",w:"55%"},{name:"EP",w:"5%"}].forEach((e=>{let t=document.createElement("th");t.scope="col",t.innerHTML=e.name,t.style.width=e.w,p.appendChild(t)})),d.appendChild(h);let _=document.createElement("tbody");if(h.appendChild(_),l._leader){let g=document.createElement("tr"),v=document.createElement("td");v.innerHTML=l._leader.nameAndGear();let b=document.createElement("td");b.innerHTML=l._leader.costs().toString(),g.appendChild(v),g.appendChild(b),_.appendChild(g)}for(let y of l._operatives){let w=document.createElement("tr"),C=document.createElement("td");C.innerHTML=y.nameAndGear();let x=document.createElement("td");x.innerHTML=y.costs().toString(),w.appendChild(C),w.appendChild(x),_.appendChild(w)}if(n){const E=document.createElement("div");if(E){const N=document.createElement("p");N.appendChild(document.createTextNode(l.name())),l._faction&&N.appendChild(document.createTextNode(" ("+l._faction+")")),E.appendChild(N)}let S=document.createElement("h3");S.appendChild(E),n.appendChild(S);const k=n.appendChild(document.createElement("div"));k.id="kt_canvas",k.classList.add("d-none");const A=n.appendChild(document.createElement("div"));A.id="kt_html",l._leader&&(this.printOperative(l._leader,null,k),this.printOperativeHtml(l._leader,null,A));let T=null;for(let L of l._operatives)this.printOperative(L,T,k),this.printOperativeHtml(L,T,A),T=L}function m(e,t){for(const n of t)e.set(n[0],n[1])}if(l._rules.size>0&&m(c,l._rules),l._factionRules.size>0&&m(u,l._factionRules),l._leader&&l._leader._rules.size>0&&m(c,l._leader._rules),l._operatives&&l._operatives.length>0)for(const R of l._operatives)R._rules&&R._rules.size>0&&m(c,R._rules)}let o=document.createElement("div");o.style.pageBreakBefore="always",this.printRules(r,o),this.printRules(i,o),n&&n.appendChild(o),(0,a.loadOptionsFromLocalStorage)()}renderOptionsDiv(e){const t=e.appendChild(document.createElement("div"));t.classList.add("wh40k_options_div","d-print-none"),t.id="wh40k_options_div";const n=t.appendChild(document.createElement("span"));(0,a.renderOptionsToggle)(n),(0,a.renderCheckboxOption)(t,"ktWithCanvas","Use old formatting",(e=>{const t=document.getElementById("kt_html"),n=document.getElementById("kt_canvas"),r=document.getElementById("ktHtmlOptions");t&&n&&r&&(e.target.checked?(t.classList.add("d-none"),r.classList.add("d-none"),n.classList.remove("d-none")):(t.classList.remove("d-none"),r.classList.remove("d-none"),n.classList.add("d-none")))}));const r=t.appendChild(document.createElement("span"));r.classList.add("wh40k_options_print_subsection"),r.id="ktHtmlOptions",r.appendChild(document.createTextNode("Print:")),(0,a.renderCheckboxOption)(r,"printBigger","Larger Text",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("bigger"):n.classList.remove("bigger")})),(0,a.renderCheckboxOption)(r,"hideElements","Hide Elements",(e=>{const t=document.body;e.target.checked?(t.classList.add("hide_enabled"),t.addEventListener("click",s.toggleHidden)):(t.classList.remove("hide_enabled"),t.removeEventListener("click",s.toggleHidden))})),(0,a.renderCheckboxOption)(r,"datasheetPageBreaks","One Datasheet per Page",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("page_break"):n.classList.remove("page_break")}))}printOperativeHtml(e,t,n){if(e.equal(t))return;const i=n.appendChild(document.createElement("div"));i.classList.add("wh40k_unit_sheet");const a=document.createElement("table");a.classList.add("table","table-sm","table-striped"),i.appendChild(a);let c=a.appendChild(document.createElement("thead"));c.classList.add("table-dark","unit_header");const u=document.createElement("div");u.classList.add("unit_costs");const d=this._specialisms.get(e._role);u.appendChild(document.createElement("span")).appendChild((null==d?void 0:d.cloneNode())||document.createTextNode("-")),c.appendChild((0,o.createTableRow)([u,e.name()],[.1,.9]));const h=c.appendChild(document.createElement("tr"));for(let e=0;e<20;e++){const e=h.appendChild(document.createElement("td"));e.colSpan=1,e.style.width="5%",e.style.padding="0"}const f=[],p=new Map;p.has(e.name())||(p.set(e.name(),e),f.push(e));let _=(0,o.createNoteHead)("Operative notes",e);_&&a.appendChild(_),c=a.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild((0,o.createTableRow)(l._unitLabels,this._unitLabelWidthsNormalized,!0));let m=a.appendChild(document.createElement("tbody"));m.append(document.createElement("tr"));for(const e of f)m.append((0,o.createTableRow)([e.name(),e._move,e._apl,e._groupActivations,e._defence.toString(),e._saves,e._wounds.toString()],this._unitLabelWidthsNormalized));const g=[],v=new Map;for(const t of e._weapons)v.has(t.name())||(v.set(t.name(),t),g.push(t));if(g.length>0){c=a.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild((0,o.createTableRow)(l._weaponLabels,this._weaponLabelWidthNormalized,!0)),m=a.appendChild(document.createElement("tbody")),m.append(document.createElement("tr"));for(const e of g)m.append((0,o.createTableRow)([e.nameAndCosts(),e._attacks,e._skill,e._damage,e._rules,e._criticalEffects],this._weaponLabelWidthNormalized))}if(_=(0,o.createNotesHead)("Weapon notes",e._weapons),_&&a.appendChild(_),e._psychicPowers.length>0){c=a.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild((0,o.createTableRow)(l._spellLabels,this._spellLabelWidthNormalized,!0)),m=a.appendChild(document.createElement("tbody")),m.append(document.createElement("tr"));for(const t of e._psychicPowers)m.append((0,o.createTableRow)([t.name(),t._effect],this._spellLabelWidthNormalized))}if(_=(0,o.createNotesHead)("Spell notes",e._psychicPowers),_&&a.appendChild(_),e._abilities.size>0||e._rules.size>0){const t=a.appendChild(document.createElement("thead"));t.classList.add("info_row");const n=document.createElement("div");if(e._rules.size>0){const t=Array.from(e._rules.keys()).sort(r.Compare).join(", ");n.appendChild(document.createElement("div")).appendChild(document.createElement("b")).appendChild(document.createTextNode(t))}const i=Array.from(e._abilities.keys()).sort(r.Compare);for(const t of i){const r=(0,s.addHideAble)(n.appendChild(document.createElement("div")));r.appendChild(document.createElement("b")).appendChild(document.createTextNode(`${t.toUpperCase()}: `)),r.appendChild(document.createTextNode(e._abilities.get(t)||"??"))}t.appendChild((0,o.createTableRow)(["Abilities",n],[.1,.9],!1))}if(e._factions.size>0){c=a.appendChild(document.createElement("thead")),c.classList.add("info_row");const t=Array.from(e._factions).sort(r.Compare).join(", ").toLocaleUpperCase();c.appendChild((0,o.createTableRow)(["Factions",t],[.1,.9],!1))}if(e._keywords.size>0){c=a.appendChild(document.createElement("thead")),c.classList.add("info_row");const t=Array.from(e._keywords).sort(r.Compare).join(", ").toLocaleUpperCase();c.appendChild((0,o.createTableRow)(["Keywords",t],[.1,.9],!1))}c=a.appendChild(document.createElement("thead")),c.classList.add("info_row");const b=document.createElement("div");for(const t of[e])b.appendChild(document.createElement("div")).appendChild(document.createTextNode(t.nameAndGear()));c.appendChild((0,o.createTableRow)(["MODELS",b],[.1,.9],!1))}printOperative(e,t,n){let r=document.createElement("canvas");if(r.width=7.5*l._res,r.height=12*l._res,r.style.width=r.width.toString(),r.style.height=r.height.toString(),this._descriptionWidth=r.width-this._descriptionStartX-10,e.equal(t))return;const i=this.renderOperative(e,r,0,0);let o=document.createElement("canvas");o.width=i[0]+30,o.height=i[1]+30,o.style.width=o.width.toString(),o.style.height=o.height.toString();let s=o.getContext("2d");if(null==s||s.drawImage(r,15,15),n){let e=document.createElement("div");e.appendChild(o),n.appendChild(e)}}printRules(e,t){if(e.size>0)for(let[n,r]of e.entries()){if(0==r.size)continue;let e=document.createElement("div"),i=document.createElement("h3");e.appendChild(i),i.textContent=n;for(let t of r){let n=document.createElement("div"),r=document.createElement("b");r.textContent=t[0];let i=document.createElement("p");i.setAttribute("style","white-space: pre-wrap;"),i.appendChild(document.createTextNode(t[1]||"")),n.appendChild(r),n.appendChild(i),e.appendChild(n)}t&&t.appendChild(e)}}renderBorder(e,t,n,r,i){e.strokeStyle=l._blackColor,e.beginPath(),e.moveTo(t,n+l._bevelSize),e.lineTo(t,n+i-l._bevelSize),e.lineTo(t+l._bevelSize,n+i),e.lineTo(t+r-l._bevelSize,n+i),e.lineTo(t+r,n+i-l._bevelSize),e.lineTo(t+r,n+l._bevelSize),e.lineTo(t+r-l._bevelSize,n),e.lineTo(t+l._bevelSize,n),e.closePath(),e.stroke(),e.save(),e.fillStyle=l._fillColor,e.globalCompositeOperation="destination-over",e.beginPath(),e.moveTo(t,n+l._bevelSize),e.lineTo(t,n+i-l._bevelSize),e.lineTo(t+l._bevelSize,n+i),e.lineTo(t+r-l._bevelSize,n+i),e.lineTo(t+r,n+i-l._bevelSize),e.lineTo(t+r,n+l._bevelSize),e.lineTo(t+r-l._bevelSize,n),e.lineTo(t+l._bevelSize,n),e.closePath(),e.fill(),e.restore()}renderNotes(e,t,n){n._customNotes&&(this.renderLine(e),e.font=l._headerFont,(0,i.RenderText)(e,t.toLocaleUpperCase(),this._currentX+l._offset,this._currentY,100,16,i.Justification.Left),e.font=l._font,this._currentY+=2,this._currentY=(0,i.RenderParagraph)(e,n._customNotes,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth-l._offset,0),this._currentY+=2)}renderNotesArray(e,t,n){let r=0;for(const e of n)e._customNotes&&r++;if(0!=r){this.renderLine(e),e.font=l._headerFont,(0,i.RenderText)(e,t.toLocaleUpperCase(),this._currentX+l._offset,this._currentY,100,16,i.Justification.Left);for(const t of n){const n=t.name()+":",r=t._customNotes;if(!r)continue;e.font=l._headerFont,this._currentY+=2,(0,i.RenderTextFull)(e,n,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth,16,i.Justification.Left,i.VertAlign.Top);let o=e.measureText(n).width;e.font=l._font,this._currentY=(0,i.RenderParagraph)(e," "+r,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth-l._offset,o),this._currentY+=2}}}renderLine(e){e.lineWidth=2,e.strokeStyle=l._blackColor,e.beginPath(),e.moveTo(this._currentX,this._currentY),e.lineTo(this._currentX+this._maxWidth,this._currentY),e.stroke(),this._currentY+=1}renderTableHeader(e,t,n,r){let o=this._currentX;const s=this._maxWidth;e.fillStyle=l._grey1,e.fillRect(this._currentX,this._currentY,s,22),e.fillStyle=l._blackColor,e.font=l._titleFont;var a=50;if(t){e.font=l._headerFont;for(let s=0;s{a.push(e*this._maxWidth)}));for(let t of e._weapons)o.push(t);for(let t of e._psychicPowers)s.push(t);const c=[],u=new Map;u.has(e.name())||(u.set(e.name(),e),c.push(e)),this.renderNotes(i,"Operative notes",e),this.renderTableHeader(i,l._unitLabels,a,null);let d=0;for(var h of c)this.renderModel(i,h,a,d%2),d++;this.renderNotes(i,"Model notes",e);const f=[],p=new Map;for(const e of o)p.has(e.name())||(p.set(e.name(),e),f.push(e));if(f.length>0){const e=[];this._weaponLabelWidthNormalized.forEach((t=>{e.push(t*this._maxWidth)})),this.renderLine(i),this.renderTableHeader(i,l._weaponLabels,e,l._weaponJustifications),this.renderWeapons(i,f,e)}if(this.renderNotesArray(i,"Weapons notes",o),s.length>0){const e=[];this._spellLabelWidthNormalized.forEach((t=>{e.push(t*this._maxWidth)})),this.renderLine(i),this.renderTableHeader(i,l._spellLabels,e,null),this.renderSpells(i,s,e)}this.renderNotesArray(i,"Spell notes",s),(e._abilities.size>0||e._rules.size>0)&&(this.renderLine(i),this._currentY+=2,this.renderAbilities(i,e)),e._factions.size>0&&(this.renderLine(i),this._currentY+=2,this.renderFactions(i,e)),e._keywords.size>0&&(this.renderLine(i),this._currentY+=2,this.renderKeywords(i,e)),this.renderLine(i),this._currentY+=2,this.renderModelList(i,[e]),this._currentY+=2;const _=this._currentY-(r+l._margin),m=this._maxWidth;return this.renderBorder(i,this._currentX,r+l._margin,m,_),[this._maxWidth,this._currentY]}renderHeader(e,t){t.globalAlpha=1,t.fillStyle=l._blackColor;const n=this._currentX,r=this._currentX+this._maxWidth,o=this._currentY,s=o+36;t.beginPath(),t.moveTo(n,o+l._bevelSize),t.lineTo(n,s),t.lineTo(r,s),t.lineTo(r,o+l._bevelSize),t.lineTo(r-l._bevelSize,o),t.lineTo(n+l._bevelSize,o),t.closePath(),t.fill();let a=n+6;if(this._octagon){t.drawImage(this._octagon,a,o+2,32,32);const n=this._specialisms.get(e._role);n&&t.drawImage(n,a+4,o+2+4,24,24),t.fillStyle="white",t.font="18px serif",a+=34,t.drawImage(this._octagon,a,o+2,32,32),(0,i.RenderText)(t,e.costs().toString(),a,o+2,32,32,i.Justification.Center)}let c=0,u=28;const d=a+6;t.font=u+"px bold serif";const h=e.name().toLocaleUpperCase();let f=t.measureText(h);const p=this._maxWidth-d;for(;c<6&&f.width>p;)c+=1,u-=2,t.font=u+"px bold serif",f=t.measureText(h);t.fillStyle="white",t.textBaseline="top",(0,i.RenderText)(t,h,d,o,p,36,i.Justification.Center),this._currentY+=36}}t.RendererKT21=l,l._res=144,l._margin=0,l._bevelSize=15,l._blackColor="#1d272a",l._grey1="#b3bbb5",l._greyLight="#dde1df",l._fillColor="#f6f6f6",l._offset=20,l._titleFont="bold 14px sans-serif",l._headerFont="bold 14px sans-serif",l._font="14px sans-serif",l._boldFont="bold 14px sans-serif",l._unitLabels=["Operative","M","APL","GA","DF","Save","W"],l._weaponLabels=["WEAPONS","A","WS/BS","D","SR","!"],l._weaponJustifications=[i.Justification.Left,i.Justification.Center,i.Justification.Center,i.Justification.Center,i.Justification.Left,i.Justification.Left],l._spellLabels=["PSYCHIC POWER","DETAILS"]},385:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.renderMESBG=void 0;const n=/\s+/g,r=(e,t="")=>{const n=document.createElement(e);return n.className=t,n},i=(e,t="",n="")=>{const i=r(e,t);return i.appendChild(document.createTextNode(n)),i},o=()=>r("div","mesbg_noBreak mesbg_bumpDown"),s=()=>r("table","mesbg_profileTable mesbg_noBreak mesbg_bumpDown"),a=(e,t)=>{const n=s();return n.appendChild((e=>{const t=r("tr");return e.forEach((e=>{t.appendChild(i("th","",e))})),t})(e)),n.appendChild((e=>{const t=r("tr");return e.forEach((e=>{t.appendChild(i("td","",e))})),t})(t)),n},l=e=>[e.movement,e.fight,e.strength,e.defense,e.attack,e.wounds,e.courage].join("-"),c=e=>i("h2","mesbg_h2",e),u=e=>i("h2","mesbg_h2",e),d={showTracker:!0,showRules:!0,woundChart:!0},h=(e,t)=>{const n=document.createElement("input");n.setAttribute("type","checkbox"),n.setAttribute("name",e),n.setAttribute("id",e),d[e]&&n.setAttribute("checked","checked"),n.addEventListener("change",(e=>()=>{const t=!d[e];d[e]=t;const n=document.querySelector(`.mesbg_${e}`);null!==n&&(t?n.classList.remove("mesbg_hideMe"):n.classList.add("mesbg_hideMe"))})(e));const r=document.createElement("label");return r.setAttribute("for",e),r.appendChild(document.createTextNode(` ${t} `)),r.prepend(n),r},f=["Mv","F","S","D","A","W","C"];t.renderMESBG=(e,t,d,p)=>{if(null!==t){const n=r("div","mesbg_noPrint mesbg_toggleHolder");n.appendChild(h("showRules","show rules text")),n.appendChild(h("showTracker","include hero points tracker")),n.appendChild(h("woundChart","include To Wound Chart")),t.appendChild(n),t.appendChild((_=e.name,i("h1","mesbg_h1",_))),t.appendChild(i("h4","mesbg_rosterInfo",`${e.points} points | ${e.warriors} warriors `))}var _;if(null!==d){const t=r("div","mesbg_container");d.appendChild(t),e.forces.forEach((n=>{t.appendChild(i("h2","mesbg_forceName",n.name)),t.appendChild(i("h4","mesbg_h4 mesbg_bumpDown",`${n.breakpoints.modelCount} models\n | broken at ${n.breakpoints.half} casualties\n | quartered at ${n.breakpoints.quarter} models remaining\n `)),i("p","mesbg_rosterInfo",`${e.points} points | ${e.warriors} warriors `);const o=r("div","mesbg_flexGrid");t.appendChild(o),n.units.forEach((e=>{var t,n;const s=r("div","mesbg_card");s.appendChild(c(`${e.leader.name} - ${e.leader.points}pts ${(null===(t=e.leader.heroStuff)||void 0===t?void 0:t.isLeader)?" (Leader)":""}`)),s.appendChild((e=>i("p","mesbg_equipmentList",e))(`${e.leader.wargear.map((e=>e.name)).join(", ")}${e.leader.mount?", "+(null===(n=e.leader.mount)||void 0===n?void 0:n.name):""}`)),s.appendChild(r("hr","mesbg_bumpDown")),e.warband.forEach((e=>{var t;const n=u(`${e.count} ${e.model.name} - ${e.points}pts`);s.appendChild(n),s.appendChild(i("p","mesbg_equipmentList",`${e.model.wargear.map((e=>e.name)).join(", ")}${e.model.mount?", "+(null===(t=e.model.mount)||void 0===t?void 0:t.name):""}`))})),o.appendChild(s)}))}))}if(null!=p){const t=r("div","mesbg_container");p.appendChild(t),e.forces.forEach((e=>{const d=new Map;e.units.forEach((e=>{var h,p,_,m,g,v,b,y,w,C,x,E;const S=r("div","mesbg_card"),k=r("div","mesbg_twoColumn");S.appendChild(c(`${e.leader.name} - ${e.leader.points}pts`)),S.appendChild(i("h3","mesbg_h3 mesbg_bumpDown",e.leader.keywords.join(", ")));const A=r("div","mesbg_flex mesbg_noBreak");A.appendChild(a(f,[e.leader.profile.movement,e.leader.profile.fight,e.leader.profile.strength,e.leader.profile.defense,e.leader.profile.attack,e.leader.profile.wounds,e.leader.profile.courage])),A.appendChild(a(["M","W","F"],[null!==(p=null===(h=e.leader.heroStuff)||void 0===h?void 0:h.might)&&void 0!==p?p:"-",null!==(m=null===(_=e.leader.heroStuff)||void 0===_?void 0:_.will)&&void 0!==m?m:"-",null!==(v=null===(g=e.leader.heroStuff)||void 0===g?void 0:g.fate)&&void 0!==v?v:"-"])),k.appendChild(A);const T=o();if(T.appendChild(i("h3","mesbg_h3","Wargear")),0===e.leader.wargear.length?T.appendChild(i("i","","none")):T.appendChild(i("p","mesbg_cardWargear",e.leader.wargear.map((e=>e.name)).join(", "))),k.appendChild(T),null!==(y=null===(b=e.leader.heroStuff)||void 0===b?void 0:b.actions.length)&&void 0!==y&&y){const t=o();t.appendChild(i("h3","mesbg_h3","Heroic Actions"));const n=r("ul","mesbg_list mesbg_noBreak mesbg_bumpDown");null===(w=e.leader.heroStuff)||void 0===w||w.actions.forEach((e=>{n.appendChild(r("li")).appendChild(document.createTextNode(e))})),t.appendChild(n),k.appendChild(t)}if(k.appendChild(i("h3","mesbg_h3","Special Rules")),k.appendChild(i("p","mesbg_bumpDown",e.leader.rules.map((e=>e.name)).join(", "))),null!==(x=null===(C=e.leader.heroStuff)||void 0===C?void 0:C.magicalPowers.length)&&void 0!==x&&x){const t=s();t.className="mesbg_powerTable mesbg_noBreak";const n=r("tr");n.appendChild(r("th")).appendChild(i("h3","mesbg_h3","Magical Powers")),n.appendChild(r("th")).appendChild(i("span","","Range")),n.appendChild(r("th")).appendChild(i("span","","Casting")),t.appendChild(n),null===(E=e.leader.heroStuff)||void 0===E||E.magicalPowers.forEach((e=>{const n=r("tr");n.appendChild(r("td")).appendChild(i("span","",e.name)),n.appendChild(r("td")).appendChild(i("span","",e.range)),n.appendChild(r("td")).appendChild(i("span","",e.casting)),t.appendChild(n)})),k.appendChild(t)}if(void 0!==e.leader.mount){const t=o();t.appendChild(u(`Mount: ${e.leader.mount.name}`));const n=r("div","mesbg_flex mesbg_noBreak");n.appendChild(a(f,[e.leader.mount.profile.movement,e.leader.mount.profile.fight,e.leader.mount.profile.strength,e.leader.mount.profile.defense,e.leader.mount.profile.attack,e.leader.mount.profile.wounds,e.leader.mount.profile.courage])),t.append(n),k.append(t)}S.appendChild(k),t.appendChild(S),e.warband.forEach((e=>{const t=e.model,r=(e=>{var t,r;return e.name.trim().replace(n,"-")+(null!==(r=null===(t=e.mount)||void 0===t?void 0:t.name.trim().replace(n,"-"))&&void 0!==r?r:"")})(t);if(d.has(r)){const e=d.get(r),n=l(t.profile),i=null==e?void 0:e.statLines.get(n),o=t.wargear.map((e=>e.name.trim())).join(", ");void 0===i?null==e||e.statLines.set(n,{profile:t.profile,equipments:new Set([o])}):i.equipments.add(o)}else{const e={name:t.name,keywords:t.keywords.join(", "),mount:t.mount,ruleNames:t.rules.map((e=>e.name)).join(", "),statLines:new Map([[l(t.profile),{profile:t.profile,equipments:new Set([t.wargear.map((e=>e.name.trim())).join(", ")])}]])};d.set(r,e)}}))}));const h=r("div","mesbg_twoColumnGrid");d.forEach(((e,t)=>{const n=r("div","mesbg_card"),s=r("div","mesbg_twoColumn");if(n.appendChild(u(e.name)),n.appendChild(i("p","mesbg_cardWargear mesbg_bumpDown",e.keywords)),e.statLines.forEach(((e,t)=>{const n=r("div","mesbg_noBreak");n.appendChild(i("h3","mesbg_h3","Wargear")),e.equipments.forEach((e=>{n.appendChild(i("p","mesbg_cardWargear",e))})),n.appendChild(a(f,[e.profile.movement,e.profile.fight,e.profile.strength,e.profile.defense,e.profile.attack,e.profile.wounds,e.profile.courage])),s.appendChild(n)})),e.ruleNames.length>0&&(s.appendChild(i("h3","mesbg_h3","Special Rules")),s.appendChild(i("p","mesbg_bumpDown",e.ruleNames))),void 0!==e.mount){const t=o();t.appendChild(u(`Mount: ${e.mount.name}`));const n=r("div","mesbg_flex mesbg_noBreak");n.appendChild(a(f,[e.mount.profile.movement,e.mount.profile.fight,e.mount.profile.strength,e.mount.profile.defense,e.mount.profile.attack,e.mount.profile.wounds,e.mount.profile.courage])),t.append(n),s.append(t)}n.appendChild(s),h.appendChild(n)})),t.appendChild(h)}));const d=new Set,h=r("div","mesbg_pageBreak mesbg_showRules");h.appendChild(i("h1","mesbg_h1","Rules"));const _=r("div","mesbg_twoColumn");e.forces.forEach((n=>{n.armyBonus.forEach((e=>{_.appendChild(i("h3","mesbg_h3",`"${e.name}" (Army Bonus)`)),_.appendChild(i("p","mesbg_bumpDown",e.ruleText))})),n.units.forEach((e=>{e.leader.rules.forEach((e=>{!1===d.has(e.name)&&(_.appendChild(i("h3","mesbg_h3",e.name)),_.appendChild(i("p","mesbg_bumpDown",e.ruleText)),d.add(e.name))})),e.warband.forEach((e=>{e.model.rules.forEach((e=>{!1===d.has(e.name)&&(_.appendChild(i("h3","mesbg_h3",e.name)),_.appendChild(i("p","mesbg_bumpDown",e.ruleText)),d.add(e.name))}))}))})),h.appendChild(_),t.appendChild(h);const o=r("table","mesbg_pageBreak mesbg_trackerTable mesbg_showTracker");o.innerHTML="MWF",e.forces.forEach((e=>{e.units.forEach((e=>{const t=r("tr");t.innerHTML=`

${e.leader.name}

`,o.appendChild(t)}))})),t.appendChild(o);const s=r("table","mesbg_pageBreak mesbg_woundChart");s.innerHTML='\n \n \n  Defence\n \n \n \n \n Strength\n   1 2 3 4 5 6 7 8 9 10\n \n \n 1 4 5 5 6 6 6/4 6/5 6/6 - -\n \n \n 2 4 4 5 5 6 6 6/4 6/5 6/6 -\n \n \n 3 3 4 4 5 5 6 6 6/4 6/5 6/6\n \n \n 4 3 3 4 4 5 5 6 6 6/4 6/5\n \n \n 5 3 3 3 4 4 5 5 6 6 6/4 \n \n 6 3 3 3 3 4 4 5 5 6 6\n \n \n 7 3 3 3 3 3 4 4 5 5 6\n \n \n 8 3 3 3 3 3 3 4 4 5 5\n \n \n 9 3 3 3 3 3 3 3 4 4 5\n \n \n 10 3 3 3 3 3 3 3 3 4 4\n \n \n ',t.appendChild(s)}))}}},717:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RendererWarcry=void 0;const r=n(320);t.RendererWarcry=class{constructor(e){this._roster=null,this._roster=e}render(e,t,n){if(null!=this._roster){e&&(e.innerHTML="

"+this._roster._name+" ("+this._roster._points+" pts

");for(let e of this._roster._forces){const i=document.createElement("div");i&&(i.innerHTML="

"+e._catalog+" "+e._name+"

"),t&&t.appendChild(i);const o=document.createElement("table");o.classList.add("table"),o.classList.add("table-sm"),o.classList.add("table-striped");const s=document.createElement("thead");o.appendChild(s),s.classList.add("thead-light");const a=document.createElement("tr");s.appendChild(a),[{name:"NAME",w:"35%"},{name:"ROLE",w:"25%"},{name:"POINTS",w:"15%"}].forEach((e=>{let t=document.createElement("th");t.scope="col",t.innerHTML=e.name,t.style.width=e.w,a.appendChild(t)})),i.appendChild(o);let l=document.createElement("tbody");o.appendChild(l);for(let t of e._units){let e=document.createElement("tr"),n=document.createElement("td");n.innerHTML=t._name;let i=document.createElement("td");i.innerHTML=r.WarcryUnitRoleToString[t._role];let o=document.createElement("td");o.innerHTML=t._points.toString(),e.appendChild(n),e.appendChild(i),e.appendChild(o),l.appendChild(e)}let c=document.createElement("div");if(e._allegiance._rules.size>0){let t=document.createElement("h3");c.appendChild(t),t.textContent=e._allegiance._name+" Abilities";for(let t of e._allegiance._rules){let e=document.createElement("div"),n=document.createElement("h4");n.textContent=t[0];let r=document.createElement("p");r.textContent=t[1],e.appendChild(n),e.appendChild(r),c.appendChild(e)}}if(!n)return;n.appendChild(c);let u=document.createElement("div");for(let t of e._units){u.appendChild(this.renderUnitHtml(t));let e=document.createElement("hr");e.className="aos_dark",u.appendChild(e)}n.appendChild(u)}}}createCharacteristicCard(e,t){let n=document.createElement("div");return n.className="col",n.innerHTML=`\n
\n \n
\n

${t}

\n
\n
`,n}createWeapon(e,t){let n=document.createElement("p");n.className="card-title warcry_font",n.innerHTML=e._name,t.appendChild(n);let r=document.createElement("div");r.className="row",t.appendChild(r);let i=this.getWeaponTypeRunemark(e._name),o=document.createElement("div");o.className="col",o.innerHTML=`\n
\n \n
`,r.appendChild(o);let s=this.createCharacteristicCard("range",e._range);r.appendChild(s);let a=this.createCharacteristicCard("attacks",e._attacks);r.appendChild(a);let l=this.createCharacteristicCard("strength",e._strength);r.appendChild(l);let c=this.createCharacteristicCard("damage",e._damage);r.appendChild(c)}renderUnitHtml(e){let t=document.createElement("div");t.className="container-fluid warcry_unit border bg-light";let n=document.createElement("div");n.className="row align-items-center",t.append(n);let r=document.createElement("div");r.className="col-1",r.innerHTML=``,n.appendChild(r);let i=document.createElement("div");i.className="col",i.innerHTML=`${e._name}`,n.appendChild(i);let o=document.createElement("div");o.className="col-4",n.appendChild(o);for(let t of e._keywords){const e=this.getAbilityRunemark(t);if(""!=e){let t=new Image;t.className="border border-dark rounded-circle warcry_card",t.src=`./assets/warcry/runemarks/black/fighters-${e}.svg`,o.appendChild(t)}}let s=document.createElement("div");s.className="col-1",s.innerHTML=`
${e._points}
`,n.appendChild(s);let a=document.createElement("div");a.className="row align-items-center",t.append(a);let l=document.createElement("div");l.className="col-7",a.appendChild(l),2==e._weapons.length&&this.createWeapon(e._weapons[1],l);let c=document.createElement("div");c.className="col",a.appendChild(c);let u=document.createElement("div");u.className="row align-items-center",t.append(u);let d=document.createElement("div");d.className="col-7",u.appendChild(d),e._weapons.length>=1&&this.createWeapon(e._weapons[0],d);let h=document.createElement("div");h.className="col",u.appendChild(h);let f=document.createElement("div");f.className="row",h.appendChild(f);let p=document.createElement("div");p.className="col",f.appendChild(p);let _=this.createCharacteristicCard("move",e._move.toString());f.appendChild(_);let m=this.createCharacteristicCard("toughness",e._toughness.toString());f.appendChild(m);let g=this.createCharacteristicCard("wounds",e._wounds.toString());if(f.appendChild(g),e._damageTable.length>0){let n=document.createElement("div");n.className="row w-75 align-items-center",t.append(n);let r=document.createElement("div");r.className="p-2 mb-2 text-center text-uppercase text-black",r.innerHTML='Damage Table',n.appendChild(r);let i=[{name:"Damage Points Allocated",width:"50%"},{name:"Move",width:"25%"},{name:"Damage ",width:"25%"}],o=1;for(let t of e._damageTable[0]._table)i[o++].name=t[0];const s=this.createTable(i);n.appendChild(s);let a=document.createElement("tbody");s.appendChild(a);for(let t of e._damageTable){let e=document.createElement("tr"),n=document.createElement("td");n.innerHTML=t._name,e.appendChild(n);for(let n of t._table){let t=document.createElement("td");t.innerHTML=n[1],e.appendChild(t)}a.appendChild(e)}}return t}createTable(e){const t=document.createElement("table");t.className="table table-bordered table-sm text-center";const n=document.createElement("thead");t.appendChild(n),n.classList.add("warcry_light");const r=document.createElement("tr");return n.appendChild(r),e.forEach((e=>{let t=document.createElement("th");t.scope="col",t.innerHTML=e.name,t.style.width=e.width,r.appendChild(t)})),t}getAbilityRunemark(e){const t=e.toLowerCase();return t.includes("agile")?"agile":t.includes("ally")?"ally":t.includes("beast")?"beast":t.includes("berserker")?"berserker":t.includes("brute")?"brute":t.includes("bulwark")?"bulwark":t.includes("champion")?"champion":t.includes("destroyer")?"destroyer":t.includes("elite")?"elite":t.includes("ferocious")?"ferocious":t.includes("fly")?"fly":t.includes("frenzied")?"frenzied":t.includes("gargantuan")?"gargantuan":t.includes("icon")?"icon-bearer":t.includes("leader")?"leader":t.includes("minion")?"minion":t.includes("mount")?"mount":t.includes("mystic")?"mystic":t.includes("priest")?"priest":t.includes("scout")?"scout":t.includes("sentience")?"sentience":t.includes("terrifying")?"terrifying":t.includes("thrall")?"thrall":t.includes("trapper")?"trapper":t.includes("warrior")?"warrior":""}getWeaponTypeRunemark(e){const t=e.toLowerCase();return t.includes("axe")||t.includes("cleaver")?"axe":t.includes("claws")||t.includes("talon")||t.includes("grasping")||t.includes("pincher")?"claws":t.includes("club")?"club":t.includes("dagger")||t.includes("shank")?"dagger":t.includes("fangs")||t.includes("teeth")||t.includes("jaws")||t.includes("maw")?"fangs":t.includes("hammer")||t.includes("anvil")?"hammer":t.includes("mace")||t.includes("staff")||t.includes("stave")||t.includes("flail")?"mace":t.includes("scythe")?"scythe":t.includes("spear")||t.includes("glaive")||t.includes("halberd")||t.includes("lance")||t.includes("harpoon")||t.includes("polearm")?"spear":t.includes("sword")||t.includes("blade")||t.includes("sickles")?"sword":t.includes("arcane bolt")||t.includes("sorcerous bolt")?"blast":t.includes("bow")||t.includes("bolas")||t.includes("cannon")||t.includes("pistol")||t.includes("javelin")?"ranged-weapon":t.includes("whip")?"reach-weapon":"unarmed"}}},391:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Create30kRoster=t.Roster30k=t.Force30k=t.Unit30k=t.Fortification30k=t.Model30k=t.Flyer30k=t.Walker30k=t.Vehicle30k=t.UnitRoleToString30k=t.UnitRole30k=t.PsychicPower30k=t.Psyker30k=t.Weapon30k=void 0;class n{constructor(){this._name="",this._range="Melee",this._str="user",this._ap="",this._type="Melee"}}t.Weapon30k=n;class r{constructor(){this._name="",this._masteryLevel="",this._disciplines=""}}t.Psyker30k=r;class i{constructor(){this._name="",this._warpCharge=0,this._category="",this._range="",this._details=""}}var o;t.PsychicPower30k=i,function(e){e[e.NONE=0]="NONE",e[e.HQ=1]="HQ",e[e.TR=2]="TR",e[e.EL=3]="EL",e[e.FA=4]="FA",e[e.HS=5]="HS",e[e.FL=6]="FL",e[e.DT=7]="DT",e[e.FT=8]="FT",e[e.LW=9]="LW"}(o=t.UnitRole30k||(t.UnitRole30k={})),t.UnitRoleToString30k=["None","HQ","Troops","Elites","Fast Attack","Heavy Support","Flyer","Dedicated Transport","Fortification","Lord of War"];class s{constructor(){this._name="",this._bs="",this._front=4,this._side=4,this._rear=4,this._hp=1,this._type="",this._weapons=[]}}t.Vehicle30k=s;class a{constructor(){this._name="",this._ws="",this._bs="",this._str=4,this._front=4,this._side=4,this._rear=4,this._initiative=1,this._attacks="",this._hp=1,this._type="",this._weapons=[]}}t.Walker30k=a;class l{constructor(){this._name="",this._bs="",this._front=4,this._side=4,this._rear=4,this._hp=1,this._type="",this._role="",this._pursuit="",this._agility="",this._weapons=[]}}t.Flyer30k=l;class c{constructor(){this._name="",this._count=0,this._ws="",this._bs="",this._str=4,this._toughness=4,this._wounds=1,this._initiative=1,this._attacks="",this._leadership=7,this._save="",this._weapons=[],this._psyker=null,this._psychicPowers=[]}}t.Model30k=c,t.Fortification30k=class{constructor(){this._name="",this._composition="",this._type=""}};class u{constructor(){this._name="",this._role=o.NONE,this._factions=new Set,this._keywords=new Set,this._abilities=new Map,this._rules=new Map,this._models=[],this._walkers=[],this._vehicles=[],this._flyers=[],this._points=0}}t.Unit30k=u;class d{constructor(){this._catalog="",this._name="Unknown",this._faction="Unknown",this._rules=new Map,this._units=[]}}t.Force30k=d;class h{constructor(){this._commandPoints=0,this._points=0,this._name="",this._forces=[]}}function f(e,t){if(!t||!e)return!1;for(let n of t._forces)if(n._catalog===e._catalog)return!0;return!1}function p(e,t){let n=e.querySelectorAll("force>selections>selection");for(let e of n){let n=m(e);n&&n._role!=o.NONE&&t._units.push(n)}t._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?0:-1))}function _(e){switch(e){case"HQ":return o.HQ;case"Troops":return o.TR;case"Elites":return o.EL;case"Fast Attack":return o.FA;case"Heavy Support":return o.HS;case"Flyer":return o.FL;case"Dedicated Transport":return o.DT;case"Fortification":return o.FT;case"Lord of War":return o.LW}return o.NONE}function m(e){var t,d,h,f,p,m,g,v,b,y,w,C,x,E,S,k,A,T,N;let L=new u,R=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;R&&(L._name=R);let P=e.querySelectorAll(":scope categories>category");for(let e of P){let t=null===(d=e.getAttributeNode("name"))||void 0===d?void 0:d.nodeValue;if(t){const e="Faction: ",n=t.lastIndexOf(e);if(n>=0){const r=t.slice(n+e.length);L._factions.add(r)}else{const e=_(t.trim());e!=o.NONE?L._role=e:L._keywords.add(t)}}}let O=null,W=null,z=null,I=null,B=e.querySelectorAll(":scope profiles>profile");for(let e of B){let t=null===(h=e.getAttributeNode("name"))||void 0===h?void 0:h.nodeValue,n=null===(f=e.getAttributeNode("typeName"))||void 0===f?void 0:f.nodeValue;if(t&&n)if("Unit"===n){O=new c,O._name=t;let n=e.querySelectorAll("characteristics>characteristic");for(let t of n){let n=null===(p=t.getAttributeNode("name"))||void 0===p?void 0:p.nodeValue;if(n&&t.textContent)switch(n){case"WS":O._ws=t.textContent;break;case"BS":O._bs=t.textContent;break;case"S":O._str=+t.textContent;break;case"T":O._toughness=+t.textContent;break;case"W":O._wounds=+t.textContent;break;case"I":O._initiative=+t.textContent;break;case"A":O._attacks=t.textContent;break;case"LD":O._leadership=+t.textContent;break;case"Save":O._save=t.textContent}if(e.parentElement&&e.parentElement.parentElement){let t=null===(m=e.parentElement.parentElement.getAttributeNode("number"))||void 0===m?void 0:m.nodeValue;t&&(O._count=+t)}}L._models.push(O)}else if("Walker"===n){W=new a,W._name=t;let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let t=null===(g=e.getAttributeNode("name"))||void 0===g?void 0:g.nodeValue;if(t&&e.textContent)switch(t){case"WS":W._ws=e.textContent;break;case"BS":W._bs=e.textContent;break;case"S":W._str=+e.textContent;break;case"Front":W._front=+e.textContent;break;case"Side":W._side=+e.textContent;break;case"Rear":W._rear=+e.textContent;break;case"I":W._initiative=+e.textContent;break;case"A":W._attacks=e.textContent;break;case"HP":W._hp=+e.textContent;break;case"Type":W._type=e.textContent}}L._walkers.push(W)}else if("Vehicle"===n){z=new s,z._name=t;let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let t=null===(v=e.getAttributeNode("name"))||void 0===v?void 0:v.nodeValue;if(t&&e.textContent)switch(t){case"BS":z._bs=e.textContent;break;case"Front":z._front=+e.textContent;break;case"Side":z._side=+e.textContent;break;case"Rear":z._rear=+e.textContent;break;case"HP":z._hp=+e.textContent;break;case"Type":z._type=e.textContent}}L._vehicles.push(z)}else if("Flyer"===n){I=new l,I._name=t;let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let t=null===(b=e.getAttributeNode("name"))||void 0===b?void 0:b.nodeValue;if(t&&e.textContent)switch(t){case"BS":I._bs=e.textContent;break;case"Front":I._front=+e.textContent;break;case"Side":I._side=+e.textContent;break;case"Rear":I._rear=+e.textContent;break;case"HP":I._hp=+e.textContent;break;case"Combat Role":I._role=e.textContent;break;case"Pursuit":I._pursuit=e.textContent;break;case"Agility":I._agility=e.textContent}}L._flyers.push(I)}}for(let e of B){let t=null===(y=e.getAttributeNode("name"))||void 0===y?void 0:y.nodeValue,o=null===(w=e.getAttributeNode("typeName"))||void 0===w?void 0:w.nodeValue;if(t&&o){if("Wargear Item"===o){let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let n=null===(C=e.getAttributeNode("name"))||void 0===C?void 0:C.nodeValue;n&&e.textContent&&t&&"Description"===n&&L._abilities.set(t,e.textContent)}}else if("Weapon"===o){let r=new n;r._name=t;let i=e.querySelectorAll("characteristics>characteristic");for(let e of i){let t=null===(x=e.getAttributeNode("name"))||void 0===x?void 0:x.nodeValue;if(t&&e.textContent)switch(t){case"Range":r._range=e.textContent;break;case"Type":r._type=e.textContent;break;case"Strength":r._str=e.textContent;break;case"AP":r._ap=e.textContent}}O?O._weapons.push(r):W?W._weapons.push(r):z?z._weapons.push(r):I?I._weapons.push(r):console.log("Unexpected: Created a weapon without an active model. Unit: "+R)}else if("Transport"==o){let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let n=null===(E=e.getAttributeNode("name"))||void 0===E?void 0:E.nodeValue;n&&e.textContent&&t&&"Capacity"===n&&L._abilities.set(t,e.textContent)}}else if("Psychic Power"==o){let n=new i;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(S=e.getAttributeNode("name"))||void 0===S?void 0:S.nodeValue;if(t&&e.textContent)switch(t){case"Warp Charge":n._warpCharge=+e.textContent;break;case"Power Category":n._category=e.textContent;break;case"Range":n._range=e.textContent;break;case"Details":n._details=e.textContent}}O?O._psychicPowers.push(n):console.log("Unexpected: Created a psychic power without an active model. Unit: "+R)}else if("Psyker"==o){let n=new r;n._name=t;let i=e.querySelectorAll("characteristics>characteristic");for(let e of i){let t=null===(k=e.getAttributeNode("name"))||void 0===k?void 0:k.nodeValue;if(t&&e.textContent)switch(t){case"Mastery Level":n._masteryLevel=e.textContent;break;case"Disciplines":n._disciplines=e.textContent}}O?O._psyker=n:console.log("Unexpected: Created a psyker without an active model. Unit: "+R)}}else"Unit"===o||"Walker"===o||"Vehicle"===o||console.log("Unknown property type: "+o)}let M=e.querySelectorAll(":scope costs>cost");for(let e of M)if(e.hasAttribute("name")&&e.hasAttribute("value")){let t=null===(A=e.getAttributeNode("name"))||void 0===A?void 0:A.nodeValue,n=null===(T=e.getAttributeNode("value"))||void 0===T?void 0:T.nodeValue;n&&"pts"==t&&(L._points+=+n)}let U=e.querySelectorAll(":scope rules > rule");for(let e of U)if(e.hasAttribute("name")){let t=null===(N=e.getAttributeNode("name"))||void 0===N?void 0:N.nodeValue,n=e.querySelector("description");t&&n&&n.textContent&&L._rules.set(t,n.textContent)}return L}t.Roster30k=h,t.Create30kRoster=function(e){var t;if(e){let n=e.querySelector("roster");if(n){const r=new h,i=null===(t=n.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;return r._name=i||"30k Army Roster",function(e,t){var n,r;let i=e.querySelectorAll("roster>costs>cost");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("value")){let i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("value"))||void 0===r?void 0:r.nodeValue;o&&("pts"===i?t._points=+o:"CP"===i&&(t._commandPoints=+o))}}(e,r),function(e,t){var n,r,i;let o=e.querySelectorAll("roster>forces>force");for(let e of o)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let o=new d,s=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,a=null===(r=e.getAttributeNode("catalogueName"))||void 0===r?void 0:r.nodeValue;if(s&&(o._name=s),a&&(o._catalog=a),!f(o,t)){const t=e.querySelectorAll("force>rules>rule");for(let e of t)if(e.hasAttribute("name")){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;const n=e.querySelector("rule>description");t&&n&&o._rules.set(t,n.textContent)}}p(e,o),t._forces.push(o)}}(e,r),r}}return null}},288:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Compare=t.CompareWeapon=t.Create40kRoster=t.Costs=t.Roster40k=t.Force=t.Unit=t.Model=t.UnitRoleToString=t.UnitRole=t.PsychicPower=t.Psyker=t.Explosion=t.WoundTracker=t.Weapon=t.Upgrade=t.BaseNotes=void 0;const s=o(n(486));class a{constructor(){this._name="",this._customName="",this._customNotes=""}name(){return this._customName?this._customName:this._name}notes(){return this._customNotes}equal(e){return null!=e&&this._name===e._name}}t.BaseNotes=a;class l extends a{constructor(){super(...arguments),this._cost=new b,this._count=1}selectionName(){return this.name()}toString(){let e=this.selectionName();return this._count>1&&(e=`${this._count}x ${e}`),this._cost.hasValues()&&(e+=` ${this._cost.toString()}`),e}}t.Upgrade=l;class c extends l{constructor(){super(...arguments),this._selectionName="",this._range="Melee",this._type="Melee",this._str="user",this._ap="",this._damage="",this._abilities=""}selectionName(){return this._selectionName||this.name()}}t.Weapon=c;class u extends a{constructor(){super(...arguments),this._name="",this._table=new Map}}t.WoundTracker=u;class d extends a{constructor(){super(...arguments),this._name="",this._diceRoll="",this._distance="",this._mortalWounds=""}}t.Explosion=d;class h extends a{constructor(){super(...arguments),this._cast="",this._deny="",this._powers="",this._other=""}}t.Psyker=h;class f extends a{constructor(){super(...arguments),this._name="",this._manifest=0,this._range="",this._details=""}}var p;t.PsychicPower=f,function(e){e[e.NONE=0]="NONE",e[e.SCD=1]="SCD",e[e.HQ=2]="HQ",e[e.TR=3]="TR",e[e.EL=4]="EL",e[e.FA=5]="FA",e[e.HS=6]="HS",e[e.FL=7]="FL",e[e.DT=8]="DT",e[e.FT=9]="FT",e[e.LW=10]="LW",e[e.AGENTS=11]="AGENTS",e[e.NF=12]="NF",e[e.COMMANDER=13]="COMMANDER",e[e.LEADER=14]="LEADER",e[e.SPECIALIST=15]="SPECIALIST",e[e.NON_SPECIALIST=16]="NON_SPECIALIST"}(p=t.UnitRole||(t.UnitRole={})),t.UnitRoleToString=["None","Supreme Command Detachment","HQ","Troops","Elites","Fast Attack","Heavy Support","Flyer","Dedicated Transport","Fortification","Lord of War","Agent of the Imperium","No Force Org Slot","Commander","Leader","Specialist","Non-specialist"];class _ extends a{constructor(){super(...arguments),this._count=0,this._move='0"',this._ws="",this._bs="",this._str=4,this._toughness=4,this._wounds=1,this._attacks="",this._leadership=7,this._save="",this._weapons=[],this._upgrades=[],this._psyker=null,this._psychicPowers=[],this._explosions=[]}equal(e){if(null==e)return!1;if(this._name===e._name&&this._count===e._count&&this._weapons.length===e._weapons.length&&this._upgrades.length===e._upgrades.length){for(let t=0;t0||this._upgrades.length>0)&&(e+=` (${this.getDedupedWeaponsAndUpgrades().map((e=>e.toString())).join(", ")})`),e}getDedupedWeaponsAndUpgrades(){const e=[];for(const t of[...this._weapons,...this._upgrades])e.some((e=>t.selectionName()===e.selectionName()))||e.push(t);return e}normalize(){this._weapons.sort(q),this._upgrades.sort(D),this.normalizeUpgrades(this._weapons),this.normalizeUpgrades(this._upgrades)}normalizeUpgrades(e){for(let t=0;t(e._count>1?`${e._count}x `:"")+e.nameAndGear())),this._weapons=this._models.map((e=>e._weapons)).reduce(((e,t)=>e.concat(t)),[]).sort(q).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())})),this._spells.push(...this._models.map((e=>e._psychicPowers)).reduce(((e,t)=>e.concat(t)),[])),this._psykers.push(...this._models.map((e=>e._psyker)).filter((e=>e))),this._explosions.push(...this._models.map((e=>e._explosions)).reduce(((e,t)=>e.concat(t)),[]))}}t.Unit=m;class g extends a{constructor(){super(...arguments),this._catalog="",this._faction="Unknown",this._factionRules=new Map,this._configurations=[],this._rules=new Map,this._units=[]}}t.Force=g;class v extends a{constructor(){super(...arguments),this._cost=new b,this._forces=[]}}t.Roster40k=v;class b{constructor(){this._powerLevel=0,this._commandPoints=0,this._points=0}hasValues(){return 0!==this._powerLevel||0!==this._commandPoints||0!==this._points}toString(){const e=[];return 0!==this._points&&e.push(`${this._points} pts`),0!==this._powerLevel&&e.push(`${this._powerLevel} PL`),0!==this._commandPoints&&e.push(`${this._commandPoints} CP`),`[${e.join(" / ")}]`}add(e){this._powerLevel+=e._powerLevel,this._commandPoints+=e._commandPoints,this._points+=e._points;for(const t in e._freeformValues)this.addFreeformValue(t,e._freeformValues[t])}addFreeformValue(e,t){this._freeformValues||(this._freeformValues={});const n=this._freeformValues[e]||0;this._freeformValues[e]=n+t}}function y(e,t,n){var r;let i=e.querySelectorAll("force>selections>selection");for(let e of i){let i=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue;if(i)if(i.includes("Detachment Command Cost"));else if("Battle Size"===i||"Gametype"===i)w(e,t);else if(e.querySelector('profile[typeName="Unit"]')){const r=P(e,n);t._units.push(r);for(const e of r._rules.entries())t._rules.set(e[0],e[1])}else if("upgrade"===e.getAttribute("type")){x(e,t._rules),w(e,t);const n=e.querySelectorAll("selections>selection");for(let e of n){const n=e.getAttribute("name");n&&"upgrade"===e.getAttribute("type")&&("Unknown"===t._faction&&(t._faction=n),x(e,t._factionRules))}}else console.log("** UNEXPECTED SELECTION **",i,e)}for(const e of t._factionRules.keys())t._rules.delete(e);t._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?e._name>t._name?1:e._name==t._name?0:-1:-1))}function w(e,t){var n;const r=e.getAttribute("name");if(!r)return;const i=null===(n=e.querySelector("category"))||void 0===n?void 0:n.getAttribute("name"),o=e.querySelectorAll("selections>selection"),s=[];let a=L(e);for(const e of o)s.push(e.getAttribute("name")),a.add(L(e));let l=i&&"Configuration"!==i?`${i} - ${r}`:r;s.length>0&&(l+=`: ${s.join(", ")}`),a.hasValues()&&(l+=` ${a.toString()}`),t._configurations.push(l)}function C(e,t){if(!t||!e)return!1;for(let n of t._forces)if(n._catalog===e._catalog)return!0;return!1}function x(e,t){const n=e.querySelectorAll("profiles>profile");for(const e of n){const n=e.getAttribute("name");if(!n)continue;const r=e.getAttribute("typeName");"Abilities"!==r&&"Dynastic Code"!==r&&"Household Tradition"!==r||W(e,n,0,t)}const r=e.querySelectorAll("rules>rule");for(const e of r)E(e,t)}function E(e,t){const n=e.getAttribute("name"),r=e.querySelector("description");n&&(null==r?void 0:r.textContent)&&t.set(n,r.textContent)}function S(e){switch(e){case"HQ":return p.HQ;case"Troops":return p.TR;case"Elites":return p.EL;case"Fast Attack":return p.FA;case"Heavy Support":return p.HS;case"Flyer":return p.FL;case"Dedicated Transport":return p.DT;case"Fortification":return p.FT;case"Lord of War":return p.LW;case"Agent of the Imperium":return p.AGENTS;case"No Force Org Slot":return p.NF;case"Primarch | Daemon Primarch | Supreme Commander":return p.SCD}return p.NONE}function k(e){switch(e){case"Commander":return p.COMMANDER;case"Leader":return p.LEADER;case"Specialist":return p.SPECIALIST;case"Non-specialist":return p.NON_SPECIALIST}return p.NONE}function A(e,t){var n,r;t._name=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;let i=e;"profile"===e.tagName&&e.parentElement&&e.parentElement.parentElement&&(i=e.parentElement.parentElement),t._customName=null===(r=i.getAttributeNode("customName"))||void 0===r?void 0:r.nodeValue;let o=i.firstElementChild;return o&&"customNotes"===o.tagName&&(t._customNotes=o.textContent),t._name}function T(e){const t=[];for(const n of e.children)if("selections"===n.tagName)for(const e of n.children)"selection"===e.tagName&&t.push(e);return t}function N(e,t){for(const n of e.children)if("profiles"===n.tagName)for(const e of n.children)if("profile"===e.tagName&&e.getAttribute("typeName")===t)return!0;return!1}function L(e){const t=new b;for(const n of e.children)if("costs"===n.tagName)for(const e of n.children)t.add(R(e));return t}function R(e){const t=new b,n=e.getAttribute("name"),r=e.getAttribute("value");return n&&r&&(" PL"===n?t._powerLevel+=+r:"pts"===n?t._points+=+r:"CP"===n?t._commandPoints+=+r:t.addFreeformValue(n,+r)),t}function P(e,t){var n;let r=new m;A(e,r);let i=e.querySelectorAll("categories>category");for(let e of i){const i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;if(i){const e="Faction: ",n=i.lastIndexOf(e);if(n>=0){const t=i.slice(n+e.length);r._factions.add(t)}else{const e=i.trim();let n=S(e);n!=p.NONE?r._role=n:t?r._keywords.add(i):(n=k(e),n!=p.NONE?r._role=n:r._keywords.add(i))}}}const o=[],s=Array.from(e.querySelectorAll('profile[typeName="Unit"],profile[typeName="Model"]'));!function(e,t,n){for(const n of e){const e=n.getAttribute("name"),r=n.getAttribute("typeName");if(!e||!r)return;const i=new _;i._name=e,t._modelStats.push(i),A(n,i);const o=n.querySelectorAll("characteristics>characteristic");for(const e of o){const t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"M":i._move=e.textContent;break;case"WS":i._ws=e.textContent;break;case"BS":i._bs=e.textContent;break;case"S":i._str=+e.textContent;break;case"T":i._toughness=+e.textContent;break;case"W":i._wounds=+e.textContent;break;case"A":i._attacks=e.textContent;break;case"Ld":i._leadership=+e.textContent;break;case"Save":i._save=e.textContent}}}}(s,r),o.push(...s);const a=[];if("model"===e.getAttribute("type"))a.push(e);else{const t=T(e);for(const e of t)("model"===e.getAttribute("type")||N(e,"Unit"))&&a.push(e);0===a.length&&a.push(...Array.from(e.querySelectorAll('selection[type="model"]'))),0===a.length&&N(e,"Unit")&&a.push(e)}for(const e of a){const t=Array.from(e.querySelectorAll("profiles>profile")),n=t.filter((e=>!o.includes(e)));o.push(...n);const i=new _;i._name=e.getAttribute("name")||"Unknown Model",i._count=Number(e.getAttribute("number")||1),r._models.push(i),O(t,i,r);for(const t of e.querySelectorAll('selections>selection[type="upgrade"]')){if(t.querySelector('selections>selection[type="upgrade"]')&&!N(t,"Abilities"))continue;let e=t.getAttribute("name");if(e){const n=new l;n._name=e,n._cost=L(t),n._count=Number(t.getAttribute("number")),i._upgrades.push(n)}}}let c=Array.from(e.querySelectorAll("profiles>profile")).filter((e=>!o.includes(e)));if(o.push(...c),c.length>0){const t=new _;if(t._name="Unit Upgrades",O(c,t,r),t._weapons.length>0&&r._models.length>0){for(const e of r._models)e._weapons.push(...t._weapons);t._weapons.length=0}t._psychicPowers.length>0&&(r._spells.push(...t._psychicPowers),t._psychicPowers.length=0),t._psyker&&(r._psykers.push(t._psyker),t._psyker=null),t._explosions.length>0&&(r._explosions.push(...t._explosions),t._explosions.length=0);for(const n of T(e)){if("upgrade"!==n.getAttribute("type"))continue;if(a.includes(n))continue;if(n.querySelector('profiles>profile[typeName="Weapon"]'))continue;let e=n.getAttribute("name");if(!e)continue;const r=new l;r._name=e,r._cost=L(n),r._count=Number(n.getAttribute("number")),t._upgrades.push(r)}(t._weapons.length>0||t._upgrades.length>0)&&r._models.push(t)}let u=e.querySelectorAll("costs>cost");for(let e of u)r._cost.add(R(e));let d=e.querySelectorAll("rules > rule");for(let e of d)E(e,r._rules);return r.normalize(),r}function O(e,t,n){for(const r of e){const e=r.getAttribute("name"),i=r.getAttribute("typeName");if(e&&i)if("Unit"===i||"Model"===i||"model"===r.getAttribute("type"));else if("Weapon"===i){const e=z(r);t._weapons.push(e)}else if(i.includes("Wound Track")||i.includes("Stat Damage")||i.includes(" Wounds")){const e=I(r);n._woundTracker.push(e)}else if("Psychic Power"==i){const e=B(r);t._psychicPowers.push(e)}else if(i.includes("Explosion")){const e=M(r);t._explosions.push(e)}else"Psyker"==i?t._psyker=U(r):(n._abilities[i]||(n._abilities[i]=new Map),W(r,e,0,n._abilities[i]))}}function W(e,t,n,r){const i=e.querySelectorAll("characteristics>characteristic");for(const e of i){if(!e.textContent)continue;const n=e.getAttribute("name");n&&i.length>1?r.set([t,n.toString()].join(" - "),e.textContent):r.set(t,e.textContent)}}function z(e){var t;const n=new c;A(e,n),n._count=function(e){var t;if(e.parentElement&&e.parentElement.parentElement){const n=null===(t=e.parentElement.parentElement.getAttributeNode("number"))||void 0===t?void 0:t.nodeValue;if(n)return+n}return 0}(e);let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"Range":n._range=e.textContent;break;case"Type":n._type=e.textContent;break;case"S":n._str=e.textContent;break;case"AP":n._ap=e.textContent;break;case"D":n._damage=e.textContent;break;case"Abilities":n._abilities=e.textContent}}const i=null===(t=e.parentElement)||void 0===t?void 0:t.parentElement,o=null==i?void 0:i.getAttribute("name");return"upgrade"===(null==i?void 0:i.getAttribute("type"))&&o&&(n._selectionName=o,n._cost=L(i)),n}function I(e){let t=new u;A(e,t);let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){const n=e.getAttribute("name");n&&(e.textContent?t._table.set(n,e.textContent):t._table.set(n,"-"))}return t}function B(e){const t=new f;A(e,t);const n=e.querySelectorAll("characteristics>characteristic");for(let e of n){const n=e.getAttribute("name");if(n&&e.textContent)switch(n){case"Range":t._range=e.textContent;break;case"Warp Charge":t._manifest=+e.textContent;break;case"Details":t._details=e.textContent}}return t}function M(e){const t=new d;A(e,t);const n=e.querySelectorAll("characteristics>characteristic");for(const e of n){const n=e.getAttribute("name");if(n&&e.textContent)switch(n){case"Dice Roll":t._diceRoll=e.textContent;break;case"Distance":t._distance=e.textContent;break;case"Mortal Wounds":t._mortalWounds=e.textContent}}return t}function U(e){const t=new h;A(e,t);const n=e.querySelectorAll("characteristics>characteristic");for(const e of n){const n=e.getAttribute("name");if(n&&e.textContent)switch(n){case"Cast":t._cast=e.textContent;break;case"Deny":t._deny=e.textContent;break;case"Powers Known":t._powers=e.textContent;break;case"Other":t._other=e.textContent}}return t}function D(e,t){return H(e._name,t._name)}function F(e,t){return e._name===t._name?H(e.nameAndGear(),t.nameAndGear()):"Unit Upgrades"===e._name?1:"Unit Upgrades"===t._name?-1:H(e._name,t._name)}function q(e,t){return(e._type.startsWith("Grenade")?2:e._type.startsWith("Melee")?1:0)-(t._type.startsWith("Grenade")?2:t._type.startsWith("Melee")?1:0)||e.name().localeCompare(t.name())}function H(e,t){return e>t?1:e==t?0:-1}t.Costs=b,t.Create40kRoster=function(e,t=!0){var n;if(e){let r=e.querySelector("roster");if(r){const i=new v,o=null===(n=r.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;i._name=o||"40k Army Roster";let s=r.querySelector("customNotes");return s&&(i._customNotes=s.textContent),function(e,t){let n=e.querySelectorAll("roster>costs>cost");for(let e of n)t._cost.add(R(e))}(e,i),function(e,t,n){var r,i;let o=e.querySelectorAll("roster>forces>force");for(let e of o)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let o=new g,s=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue,a=null===(i=e.getAttributeNode("catalogueName"))||void 0===i?void 0:i.nodeValue;if(s&&(o._name=s),a&&(o._catalog=a),!C(o,t)){const t=e.querySelectorAll("force>rules>rule");for(let e of t)E(e,o._rules)}y(e,o,n),t._forces.push(o)}}(e,i,t),i}}return null},t.CompareWeapon=q,t.Compare=H},208:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Wh40k=void 0;const s=o(n(486));!function(e){class t{constructor(){this._name="",this._customName="",this._customNotes=""}name(){return this._customName?this._customName:this._name}notes(){return this._customNotes}equal(e){return null!=e&&this._name===e._name}hash(){return N(this.name())}}e.BaseNotes=t;class n extends t{constructor(){super(...arguments),this._cost=new d,this._count=1}selectionName(){return this.name()}toString(){let e=this.selectionName();return this._count>1&&(e=`${this._count}x ${e}`),this._cost.hasValues()&&(e+=` ${this._cost.toString()}`),e}}let r;function i(e){switch(e){case"Epic Hero":return r.EpicHero;case"Character":return r.Character;case"Battleline":return r.Battleline;case"Infantry":return r.Infantry;case"Swarm":return r.Swarm;case"Mounted":return r.Mounted;case"Beast":return r.Beast;case"Monster":return r.Monster;case"Vehicle":return r.Vehicle;case"Dedicated Transport":return r.Transport;case"Fortification":return r.Fortification;case"Allied Units":return r.Allied;default:return r.NONE}}e.Upgrade=n,e.Weapon=class extends n{constructor(){super(...arguments),this._selectionName="",this._range="Melee",this._attacks="1",this._skill="",this._str="user",this._ap="",this._damage="",this._abilities=""}selectionName(){return this._selectionName||this.name()}},function(e){e[e.NONE=0]="NONE",e[e.EpicHero=1]="EpicHero",e[e.Character=2]="Character",e[e.Battleline=3]="Battleline",e[e.Infantry=4]="Infantry",e[e.Swarm=5]="Swarm",e[e.Mounted=6]="Mounted",e[e.Beast=7]="Beast",e[e.Monster=8]="Monster",e[e.Vehicle=9]="Vehicle",e[e.Transport=10]="Transport",e[e.Fortification=11]="Fortification",e[e.Allied=12]="Allied"}(r=e.UnitRole||(e.UnitRole={})),e.UnitRoleToString={[r.NONE]:"None",[r.EpicHero]:"Epic Hero",[r.Character]:"Character",[r.Battleline]:"Battleline",[r.Infantry]:"Infantry",[r.Swarm]:"Swarm",[r.Mounted]:"Mounted",[r.Beast]:"Beast",[r.Monster]:"Monster",[r.Vehicle]:"Vehicle",[r.Transport]:"Dedicated Transport",[r.Fortification]:"Fortification",[r.Allied]:"Allied Units"};class o extends t{constructor(){super(...arguments),this._count=0,this._move='0"',this._toughness=4,this._save="4+",this._wounds=1,this._leadership="6+",this._objControl=1,this._weapons=[],this._upgrades=[]}equal(e){if(null==e)return!1;if(this._name===e._name&&this._count===e._count&&this._weapons.length===e._weapons.length&&this._upgrades.length===e._upgrades.length){for(let t=0;t0||this._upgrades.length>0)&&(e+=` (${this.getDedupedWeaponsAndUpgrades().map((e=>e.toString())).join(", ")})`),e}getDedupedWeaponsAndUpgrades(){const e=[];for(const t of[...this._weapons,...this._upgrades])e.some((e=>t.selectionName()===e.selectionName()))||e.push(t);return e}normalize(){this._weapons.sort(A),this._upgrades.sort(S),this.normalizeUpgrades(this._weapons),this.normalizeUpgrades(this._upgrades)}normalizeUpgrades(e){for(let t=0;te[0])).flat();this._profileTables[e]._contents=t.filter(((e,t)=>n.indexOf(e[0])===t))}for(let e=0;e(e._count>1?`${e._count}x `:"")+e.nameAndGear())),this._weapons=this._models.map((e=>e._weapons)).reduce(((e,t)=>e.concat(t)),[]).sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}}e.Unit=l;class c extends t{constructor(){super(...arguments),this._catalog="",this._faction="Unknown",this._factionRules=new Map,this._configurations=[],this._rules=new Map,this._units=[]}hash(){let e=71;for(const t of this._units)e=L(e,t.hash());return e}}e.Force=c;class u extends t{constructor(){super(...arguments),this._cost=new d,this._forces=[]}hash(){let e=59;for(const t of this._forces)e=L(e,t.hash());return e}}e.Roster40k=u;class d{constructor(){this._points=0}hasValues(){return 0!==this._points}toString(){const e=[];return 0!==this._points&&e.push(`${this._points} pts`),`[${e.join(" / ")}]`}add(e){this._points+=e._points;for(const t in e._freeformValues)this.addFreeformValue(t,e._freeformValues[t])}addFreeformValue(e,t){this._freeformValues||(this._freeformValues={});const n=this._freeformValues[e]||0;this._freeformValues[e]=n+t}}function h(e,t,n){var r;let i=e.querySelectorAll("force>selections>selection");for(let e of i){let n=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue;if(n)if(n.includes("Detachment Command Cost"));else if("Battle Size"===n||"Gametype"===n)f(e,t);else if(e.querySelector('profile[typeName="Unit"]')){const n=w(e);t._units.push(n);for(const e of n._rules.entries())t._rules.set(e[0],e[1]);for(const e of n._weaponRules.entries())t._rules.set(e[0],e[1])}else if("upgrade"===e.getAttribute("type")){_(e,t._rules),f(e,t);const n=e.querySelectorAll("selections>selection");for(let e of n){const n=e.getAttribute("name");n&&"upgrade"===e.getAttribute("type")&&("Unknown"===t._faction&&(t._faction=n),_(e,t._factionRules))}}else console.log("** UNEXPECTED SELECTION **",n,e)}for(const e of t._factionRules.keys())t._rules.delete(e);t._rules=new Map([...t._rules.entries()].sort()),t._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?e._name>t._name?1:e._name==t._name?0:-1:-1))}function f(e,t){var n;const r=e.getAttribute("name");if(!r)return;const i=null===(n=e.querySelector("category"))||void 0===n?void 0:n.getAttribute("name"),o=e.querySelectorAll("selections>selection"),s=[];let a=b(e);for(const e of o)s.push(e.getAttribute("name")),a.add(b(e));let l=i&&"Configuration"!==i?`${i} - ${r}`:r;s.length>0&&(l+=`: ${s.join(", ")}`),a.hasValues()&&(l+=` ${a.toString()}`),t._configurations.push(l)}function p(e,t){if(!t||!e)return!1;for(let n of t._forces)if(n._catalog===e._catalog)return!0;return!1}function _(e,t){const n=e.querySelectorAll("profiles>profile");for(const e of n){const n=e.getAttribute("name");if(!n)continue;const r=e.getAttribute("typeName");"Abilities"!==r&&"Dynastic Code"!==r&&"Household Tradition"!==r||E(e,n,0,t)}const r=e.querySelectorAll("rules>rule");for(const e of r)m(e,t)}function m(e,t){const n=e.getAttribute("name"),r=e.querySelector("description");n&&(null==r?void 0:r.textContent)&&t.set(n,r.textContent)}function g(e){const t=[];for(const n of e.children)if("selections"===n.tagName)for(const e of n.children)"selection"===e.tagName&&t.push(e);return t}function v(e,t){for(const n of e.children)if("profiles"===n.tagName)for(const e of n.children)if("profile"===e.tagName&&e.getAttribute("typeName")===t)return!0;return!1}function b(e){const t=new d;for(const n of e.children)if("costs"===n.tagName)for(const e of n.children)t.add(y(e));return t}function y(e){const t=new d,n=e.getAttribute("name"),r=e.getAttribute("value");return n&&r&&("pts"===n?t._points+=+r:t.addFreeformValue(n,+r)),t}function w(e,t){var s,c;let u=new l;!function(e,t){var n,r;t._name=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;let i=e;"profile"===e.tagName&&e.parentElement&&e.parentElement.parentElement&&(i=e.parentElement.parentElement),t._customName=null===(r=i.getAttributeNode("customName"))||void 0===r?void 0:r.nodeValue;let o=i.firstElementChild;o&&"customNotes"===o.tagName&&(t._customNotes=o.textContent),t._name}(e,u);let d=e.querySelectorAll("categories>category");for(let e of d){const t=null===(s=e.getAttributeNode("name"))||void 0===s?void 0:s.nodeValue;if(t){const e="Faction: ",n=t.lastIndexOf(e);if(n>=0){const r=t.slice(n+e.length);u._factions.add(r)}else{let e=i(t.trim());e!=r.NONE&&(u._role=e),u._keywords.add(t)}}}const h=[],f=Array.from(e.querySelectorAll('profile[typeName="Unit"],profile[typeName="Model"]'));for(const e of f){const t=e.getAttribute("name"),n=e.getAttribute("typeName");t&&n&&(u._profileTables[n]||(u._profileTables[n]=new a),x(e,t,n,u._profileTables[n]))}h.push(...f);const p=[];if("model"===e.getAttribute("type"))p.push(e);else{const t=g(e);for(const e of t)("model"===e.getAttribute("type")||v(e,"Unit"))&&p.push(e);0===p.length&&p.push(...Array.from(e.querySelectorAll('selection[type="model"]'))),0===p.length&&v(e,"Unit")&&p.push(e)}for(const e of p){const t=Array.from(e.querySelectorAll("profiles>profile")),r=t.filter((e=>!h.includes(e)));h.push(...r);const i=new o;i._name=e.getAttribute("name")||"Unknown Model",i._count=Number(e.getAttribute("number")||1),u._models.push(i),C(t,0,u);for(const t of e.querySelectorAll('selections>selection[type="upgrade"]')){if(t.querySelector('selections>selection[type="upgrade"]')&&!v(t,"Abilities"))continue;let e=t.getAttribute("name");if(e){const r=new n;r._name=e,r._cost=b(t),r._count=Number(t.getAttribute("number")),i._upgrades.push(r)}}}let _=Array.from(e.querySelectorAll("profiles>profile")).filter((e=>!h.includes(e)));if(h.push(..._),_.length>0){const t=new o;if(t._name="Unit Upgrades",C(_,0,u),t._weapons.length>0&&u._models.length>0){for(const e of u._models)e._weapons.push(...t._weapons);t._weapons.length=0}for(const r of g(e)){if("upgrade"!==r.getAttribute("type"))continue;if(p.includes(r))continue;if(r.querySelector('profiles>profile[typeName="Weapon"]'))continue;let e=r.getAttribute("name");if(!e)continue;const i=new n;i._name=e,i._cost=b(r),i._count=Number(r.getAttribute("number")),t._upgrades.push(i)}(t._weapons.length>0||t._upgrades.length>0)&&u._models.push(t)}let w=e.querySelectorAll("costs>cost");for(let e of w)u._cost.add(y(e));let E=e.querySelectorAll("rules > rule");for(let e of E){const t=null===(c=e.parentElement)||void 0===c?void 0:c.parentElement;t&&(v(t,"Ranged Weapons")||v(t,"Melee Weapons"))?m(e,u._weaponRules):m(e,u._rules)}return u.normalize(),u}function C(e,t,n){for(const t of e){const e=t.getAttribute("name"),r=t.getAttribute("typeName");e&&r&&(t.querySelectorAll("characteristics>characteristic").length>1?(n._profileTables[r]||(n._profileTables[r]=new a),x(t,e,r,n._profileTables[r])):(n._abilities[r]||(n._abilities[r]=new Map),E(t,e,0,n._abilities[r])))}}function x(e,t,n,r){const i=e.querySelectorAll("characteristics>characteristic"),o={[n]:t};for(const e of i){if(!e.textContent)continue;const t=e.getAttribute("name");t&&(o[t]=e.textContent)}r.addRow(o)}function E(e,t,n,r){const i=e.querySelectorAll("characteristics>characteristic");for(const e of i){if(!e.textContent)continue;const n=e.getAttribute("name");n&&i.length>1?r.set([t,n.toString()].join(" - "),e.textContent):r.set(t,e.textContent)}}function S(e,t){return T(e._name,t._name)}function k(e,t){return e._name===t._name?T(e.nameAndGear(),t.nameAndGear()):"Unit Upgrades"===e._name?1:"Unit Upgrades"===t._name?-1:T(e._name,t._name)}function A(e,t){return e.name().localeCompare(t.name())}function T(e,t){return e>t?1:e==t?0:-1}function N(e){let t=23;for(var n=0;ncosts>cost");for(let e of n)t._cost.add(y(e))}(e,r),function(e,t,n){var r,i;let o=e.querySelectorAll("roster>forces>force");for(let e of o)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let n=new c,o=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue,s=null===(i=e.getAttributeNode("catalogueName"))||void 0===i?void 0:i.nodeValue;if(o&&(n._name=o),s&&(n._catalog=s),!p(n,t)){const t=e.querySelectorAll("force>rules>rule");for(let e of t)m(e,n._rules)}h(e,n),t._forces.push(n)}}(e,r),r}}return null},e.CompareWeapon=A,e.Compare=T,e.CompareProfileTableName=function(e,t){const n=["Unit","Ranged Weapons","Melee Weapons"];return(n.includes(e)?n.indexOf(e):n.length)-(n.includes(t)?n.indexOf(t):n.length)}}(t.Wh40k||(t.Wh40k={}))},774:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CreateAoSRoster=t.RosterAoS=t.AoSForce=t.AoSUnit=t.AoSUnitRoleToString=t.AoSUnitRole=t.AoSRealmOfBattle=t.AoSSpecialRules=t.AoSCoreBattalion=t.AoSTriumph=t.AoSGrandStrategy=t.AoSAllegiance=t.AoSPrayer=t.AoSSpell=t.AoSWoundTracker=t.AoSWeapon=t.AoSProfile=t.AoSProfileType=void 0;const s=o(n(486));class a{constructor(){this._typeName="anonymous",this._fields=new Map}}t.AoSProfileType=a;class l{constructor(){this._name="none",this._value=new a}}t.AoSProfile=l;class c{constructor(){this._name="",this._type="Melee",this._range="",this._attacks="",this._toHit="",this._toWound="",this._rend="",this._damage=""}}t.AoSWeapon=c;class u{constructor(){this._title="",this._labels=[],this._table=[[]]}}t.AoSWoundTracker=u;class d{constructor(){this._name="",this._castingValue=0,this._range="",this._description=""}}t.AoSSpell=d;class h{constructor(){this._name="",this._answerValue=0,this._range="",this._description=""}}t.AoSPrayer=h;class f{constructor(){this._name="",this._battleTraits=new Map,this._commandAbilities=new Map,this._spells=[],this._extraProfiles=[]}}t.AoSAllegiance=f;class p{constructor(){this._name="",this._description=""}}t.AoSGrandStrategy=p;class _{constructor(){this._name="",this._description=""}}t.AoSTriumph=_;class m{constructor(){this._name="",this._abilities=new Map}}t.AoSCoreBattalion=m;class g{constructor(){this._name="",this._description=""}}t.AoSSpecialRules=g;class v{constructor(){this._name="",this._spells=[],this._commandAbilities=new Map,this._rules=[]}}var b;t.AoSRealmOfBattle=v,function(e){e[e.NONE=0]="NONE",e[e.LEADER=1]="LEADER",e[e.BATTLELINE=2]="BATTLELINE",e[e.BEHEMOTH=3]="BEHEMOTH",e[e.ARTILLERY=4]="ARTILLERY",e[e.OTHER=5]="OTHER",e[e.SCENERY=6]="SCENERY",e[e.BATTALION=7]="BATTALION",e[e.MALIGN_SORCERY=8]="MALIGN_SORCERY",e[e.REALM=9]="REALM"}(b=t.AoSUnitRole||(t.AoSUnitRole={})),t.AoSUnitRoleToString=["None","Leader","Battleline","Behemoth","Artillery","Other","Scenery","Battalion","Malign Sorcery","Realm"];class y{constructor(){this._name="",this._id=0,this._role=b.NONE,this._keywords=new Set,this._abilities=new Map,this._commandAbilities=new Map,this._commandTraits=new Map,this._magic=new Map,this._artefacts=new Map,this._count=0,this._move='0"',this._wounds=1,this._bravery=7,this._save="",this._weapons=[],this._spells=[],this._prayers=[],this._points=0,this._woundTracker=null,this._extraProfiles=[],this._selections=new Set}equal(e){return null!=e&&e._name===this._name&&e._role===this._role&&!!s.isEqual(this._commandTraits,e._commandTraits)&&!!s.isEqual(this._artefacts,e._artefacts)&&!!s.isEqual(this._weapons,e._weapons)}isNormalUnit(){return this._role==b.ARTILLERY||this._role==b.BATTLELINE||this._role==b.BEHEMOTH||this._role==b.LEADER||this._role==b.OTHER}}t.AoSUnit=y;class w{constructor(){this._catalog="",this._name="Unknown",this._units=[],this._battalions=[],this._rules=new Map,this._battleTactics=new Map,this._allegiance=new f,this._grandStrategy=new p,this._triumph=new _,this._realmOfBattle=new v}}t.AoSForce=w;class C{constructor(){this._commandPoints=0,this._points=0,this._name="",this._forces=[]}}function x(e){switch(e){case"Leader":return b.LEADER;case"Battleline":return b.BATTLELINE;case"Other":return b.OTHER;case"Behemoth":return b.BEHEMOTH;case"Artillery":return b.ARTILLERY;case"Scenery":return b.SCENERY;case"Battalion":return b.BATTALION;case"Malign Sorcery":return b.MALIGN_SORCERY;case"Realm":return b.REALM}return b.NONE}function E(e,t){var n,r,i,o,s,a,l;let c=e.querySelectorAll("force>selections>selection"),u=0;for(let e of c){let c=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;if(c)if(c.includes("Allegiance")){let n=A(e);n&&(t._allegiance=n)}else if(c.includes("Grand Strategy")){let n=T(e);n&&(t._grandStrategy=n)}else if(c.includes("Game Type"));else if(c.includes("Core Battalion")){let n=new m;n._name=c;let s=e.querySelectorAll("profiles>profile");for(let e of s)for(let e of s){let t=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue,s=null===(i=e.getAttributeNode("typeName"))||void 0===i?void 0:i.nodeValue;if(t&&s){let t=e.querySelectorAll("characteristics>characteristic");for(let e of t){let t=null===(o=e.getAttributeNode("name"))||void 0===o?void 0:o.nodeValue;t&&e.textContent&&n._abilities.set(t,e.textContent)}}}t._battalions.push(n)}else if(c.includes("Realm of Battle")){let n=L(e);n&&(t._realmOfBattle=n)}else if(c.includes("GHB 2023 Rules")){let n=R(e);n&&(t._realmOfBattle=n)}else if(c.includes("Triumphs")){let n=N(e);n&&(t._triumph=n)}else if(c.includes("Battle Tactic")){let n=e.querySelectorAll("profiles>profile");for(let e of n)for(let e of n){let n=null===(s=e.getAttributeNode("name"))||void 0===s?void 0:s.nodeValue,r=null===(a=e.getAttributeNode("typeName"))||void 0===a?void 0:a.nodeValue;if(n&&r){let r=e.querySelectorAll("characteristics>characteristic");for(let e of r)(null===(l=e.getAttributeNode("name"))||void 0===l?void 0:l.nodeValue)&&e.textContent&&t._battleTactics.set(n,e.textContent)}}}else{let n=k(e);n&&n._role!=b.NONE&&(n._id=u++,t._units.push(n))}}t._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?0:-1))}function S(e,t){var n;let r=e.querySelectorAll("force>rules>rule");for(let e of r){let r=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,i=e.querySelectorAll("description");if(r&&i)for(let e of i)e.textContent&&t._rules.set(r,e.textContent)}}function k(e){var t,n,r,i,o,s,a,l,f,p,_,m,g,v,w;let C=new y,E=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;E&&(C._name=E);let S=e.querySelectorAll("profiles>profile");for(let e of S){let t=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,p=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(t&&p)if("Unit"==p){C._name||(C._name=t);let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(t&&e.textContent)switch(t){case"Move":C._move=e.textContent;break;case"Wounds":C._wounds=+e.textContent;break;case"Bravery":C._bravery=+e.textContent;break;case"Save":C._save=e.textContent}}}else if("Unit Abilities"==p){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&C._abilities.set(t,n.textContent)}else if("Command Abilities"==p){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&C._commandAbilities.set(t,n.textContent)}else if("Magic"==p){let t=e.querySelectorAll("characteristics>characteristic");for(let e of t){let t=null===(o=e.getAttributeNode("name"))||void 0===o?void 0:o.nodeValue;t&&e.textContent&&C._magic.set(t,e.textContent)}}else if("Unit Leader"==p){let t=e.querySelector("characteristics>characteristic");t&&t.textContent&&C._abilities.set(p,t.textContent)}else if("Spell"==p){let n=new d;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(s=e.getAttributeNode("name"))||void 0===s?void 0:s.nodeValue;if(t&&e.textContent)switch(t){case"Casting Value":n._castingValue=+e.textContent;break;case"Range":n._range=e.textContent;break;case"Description":n._description=e.textContent}}C._spells.push(n)}else if("Weapon"==p){let n=new c;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(a=e.getAttributeNode("name"))||void 0===a?void 0:a.nodeValue;if(t&&e.textContent)switch(t){case"Range":n._range=e.textContent;break;case"Type":n._type=e.textContent;break;case"Attacks":n._attacks=e.textContent;break;case"Rend":n._rend=e.textContent;break;case"To Hit":n._toHit=e.textContent;break;case"To Wound":n._toWound=e.textContent;break;case"Damage":n._damage=e.textContent}}C._weapons.push(n)}else if("Command Trait"==p){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&C._commandTraits.set(t,n.textContent)}else if("Artefact"==p){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&C._artefacts.set(t,n.textContent)}else if("Prayer"==p){let n=new h;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(l=e.getAttributeNode("name"))||void 0===l?void 0:l.nodeValue;if(t&&e.textContent)switch(t){case"Answer Value":n._answerValue=+e.textContent;break;case"Range":n._range=e.textContent;break;case"Description":n._description=e.textContent}}C._prayers.push(n)}else if(p.includes("Damage Table")||p.includes("Wounds")||p.includes("Wound Track")||p.includes("Wound Table")){let n=[];if(C._woundTracker){let r=e.querySelectorAll("characteristics>characteristic");if(r.length<=3){let e=t;e?n.push(e):n.push("Unknown");for(let e of r)e.textContent?n.push(e.textContent):n.push("Unknown")}else for(let e of r)e.textContent?n.push(e.textContent):n.push("Unknown");C._woundTracker._table.push(n),n=[]}else{C._woundTracker=new u,C._woundTracker._title=p;let r=e.querySelectorAll("characteristics>characteristic");if(r.length<=3){C._woundTracker._labels.push("Wounds Suffered"),n.push(t);for(let e of r){let t=null===(f=e.getAttributeNode("name"))||void 0===f?void 0:f.nodeValue;t?C._woundTracker._labels.push(t):C._woundTracker._labels.push("Unknown"),e.textContent?n.push(e.textContent):n.push("Unknown")}}else for(let e of r)e.textContent?C._woundTracker._labels.push(e.textContent):C._woundTracker._labels.push("Unknown");C._woundTracker._table.push(n),n=[]}}else{let t=P(e);t?C._extraProfiles.push(t):console.log("Unknown unit profile type: "+p)}}let k=e.querySelectorAll("selections>selection");for(let e of k){let t=null===(p=e.getAttributeNode("name"))||void 0===p?void 0:p.nodeValue;if(t&&(C._selections.add(t),t.includes("Wound Track"))){C._woundTracker=new u,C._woundTracker._title=t,C._woundTracker._labels=["Wounds Suffered"];let n=e.querySelectorAll("profiles>profile"),r=!0;for(let e of n){let t=null===(_=e.getAttributeNode("name"))||void 0===_?void 0:_.nodeValue,n=e.querySelectorAll("characteristics>characteristic"),i=[];t?i.push(t):i.push("--");for(let e of n){let t=null===(m=e.getAttributeNode("name"))||void 0===m?void 0:m.nodeValue,n=e.textContent;r&&(t?C._woundTracker._labels.push(t):C._woundTracker._labels.push("Unknown")),n?i.push(n):i.push("Unknown")}r=!1,C._woundTracker._table.push(i)}}}let A=e.querySelectorAll("costs>cost");for(let e of A)if(e.hasAttribute("name")&&e.hasAttribute("value")){let t=null===(g=e.getAttributeNode("name"))||void 0===g?void 0:g.nodeValue,n=null===(v=e.getAttributeNode("value"))||void 0===v?void 0:v.nodeValue;n&&"pts"===t&&(C._points+=+n)}let T=e.querySelectorAll(":scope categories>category");for(let e of T){let t=null===(w=e.getAttributeNode("name"))||void 0===w?void 0:w.nodeValue;if(t){var N=x(t.trim());N!=b.NONE?C._role=N:C._keywords.add(t)}}return C}function A(e){var t,n,r,i;let o=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;if(o){let t=new f;t._name=o;let s=e.querySelectorAll("profiles>profile");for(let e of s){let o=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(o&&s)if("Battle Trait"==s){let n=e.querySelector("characteristics>characteristic");if(n){let e=n.textContent;e&&(null==t||t._battleTraits.set(o,e))}}else if("Command Abilities"==s){let n=e.querySelector("characteristics>characteristic");if(n){let e=n.textContent;e&&(null==t||t._commandAbilities.set(o,e))}}else if("Spell"==s){let n=new d;n._name=o;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(t&&e.textContent)switch(t){case"Casting Value":n._castingValue=+e.textContent;break;case"Range":n._range=e.textContent;break;case"Description":n._description=e.textContent}}null==t||t._spells.push(n)}else{let n=P(e);n?null==t||t._extraProfiles.push(n):console.log("Unexpected allegiance profile type: "+s)}}return t}return null}function T(e){var t,n,r;let i=null,o=e.querySelector("selections>selection");if(o){let e=null===(t=o.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;e&&(i=new p,i._name=e);let s=o.querySelectorAll("profiles>profile");for(let e of s){let t=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(t&&o)if("Grand Strategy"==o){let t=e.querySelector("characteristics>characteristic");if(t){let e=t.textContent;e&&i&&(i._description=e)}}else console.log("Unexpected Grand Strategy profile type: "+o)}}return i}function N(e){var t,n,r;let i=null,o=e.querySelector("selections>selection");if(o){let e=null===(t=o.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;e&&(i=new _,i._name=e);let s=o.querySelectorAll("profiles>profile");for(let e of s){let t=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(t&&o)if("Triumph"==o){let t=e.querySelector("characteristics>characteristic");if(t){let e=t.textContent;e&&i&&(i._description=e)}}else console.log("Unexpected Triumph profile type: "+o)}}return i}function L(e){var t,n,r,i;let o=null,s=e.querySelector("selections>selection");if(s){let e=null===(t=s.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;if(e){o=new v,o._name=e;let t=s.querySelectorAll("profiles>profile");for(let e of t){let t=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(t&&s)if("Spell"==s){let n=new d;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(t&&e.textContent)switch(t){case"Casting Value":n._castingValue=+e.textContent;break;case"Range":n._range=e.textContent;break;case"Description":n._description=e.textContent}}o._spells.push(n)}else if("Command Abilities"==s){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&o._commandAbilities.set(t,n.textContent)}else if("Special Rules"==s){let n=e.querySelector("characteristics>characteristic");if(n&&n.textContent){let e=new g;e._name=t,e._description=n.textContent,o._rules.push(e)}}else console.log("Unexpected Realm of Battle profile type: "+s)}}}return o}function R(e){var t,n,r,i;let o=null,s=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;if(s){o=new v,o._name=s;let t=e.querySelectorAll("profiles>profile");for(let e of t){let t=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(t&&s)if("Spell"==s){let n=new d;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(t&&e.textContent)switch(t){case"Casting Value":n._castingValue=+e.textContent;break;case"Range":n._range=e.textContent;break;case"Description":n._description=e.textContent}}o._spells.push(n)}else if("Command Abilities"==s){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&o._commandAbilities.set(t,n.textContent)}else if("Special Rules"==s||"Heroic Action"==s){let n=e.querySelector("characteristics>characteristic");if(n&&n.textContent){let e=new g;e._name=t,e._description=n.textContent,o._rules.push(e)}}else console.log("Unexpected Realm of Battle profile type: "+s)}}return o}function P(e){var t,n,r;if(!e)return null;let i=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue,o=null===(n=e.getAttributeNode("typeName"))||void 0===n?void 0:n.nodeValue;if(!i||!o)return null;let s=new l;s._name=i,s._value._typeName=o;let a=e.querySelectorAll("characteristics>characteristic");for(let e of a){let t=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue;t&&e.textContent&&s._value._fields.set(t,e.textContent)}return s}t.RosterAoS=C,t.CreateAoSRoster=function(e){var t;if(e){let n=e.querySelector("roster");if(n){const r=new C,i=null===(t=n.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;return r._name=i||"Age of Sigmar Roster",function(e,t){var n,r;let i=e.querySelectorAll("roster>costs>cost");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("value")){let i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("value"))||void 0===r?void 0:r.nodeValue;o&&"pts"===i&&(t._points=+o)}}(e,r),function(e,t){var n,r;let i=e.querySelectorAll("roster>forces>force");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let i=new w,o=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("catalogueName"))||void 0===r?void 0:r.nodeValue;o&&(i._name=o),s&&(i._catalog=s),E(e,i),S(e,i),t._forces.push(i)}}(e,r),r}}return null}},980:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.HorusHeresy=void 0;const s=o(n(486));!function(e){let t;!function(e){e[e.NONE=0]="NONE",e[e.HQ=1]="HQ",e[e.TR=2]="TR",e[e.EL=3]="EL",e[e.FA=4]="FA",e[e.HS=5]="HS",e[e.FL=6]="FL",e[e.DT=7]="DT",e[e.FT=8]="FT",e[e.LW=9]="LW",e[e.PR=10]="PR"}(t=e.UnitRole||(e.UnitRole={})),e.UnitRoleToString=["None","HQ","Troops","Elites","Fast Attack","Heavy Support","Flyer","Dedicated Transport","Fortification","Lord of War","Primarch"];class n{constructor(){this._name="",this._customName="",this._customNotes=""}name(){return this._customName?this._customName:this._name}notes(){return this._customNotes}equal(e){return null!=e&&this._name===e._name}}e.BaseNote=n;class r extends n{constructor(){super(...arguments),this._description="",this._cost=new p,this._count=1}selectionName(){return this.name()}toString(){let e=this.selectionName();return this._count>1&&(e=`${this._count}x ${e}`),this._cost.hasValues()&&(e+=` ${this._cost.toString()}`),e}}e.Upgrade=r;class i extends r{constructor(){super(...arguments),this._selectionName="",this._range="Melee",this._str="user",this._ap="",this._type="Melee"}getRules(){let e=this._type.split(",");return e.length>0&&(e=e.slice(1).map((e=>e.trim()))),e}}e.Weapon=i;class o extends n{constructor(){super(...arguments),this._count=0,this._type="",this._weapons=[],this._upgrades=[],this._wargear=[],this._warlordTraits=[],this._reactions=[],this._psychicWeapons=[],this._psychicPowers=[]}equal(e){if(null==e)return!1;if(this._name===e._name&&this._count===e._count&&this._weapons.length===e._weapons.length&&this._upgrades.length===e._upgrades.length&&this._wargear.length===e._wargear.length&&this._psychicWeapons.length===e._psychicWeapons.length&&this._psychicPowers.length===e._psychicPowers.length){for(let t=0;t0||this._upgrades.length>0)&&(e+=` (${this.getDedupedWeaponsAndUpgrades().map((e=>e.toString())).join(", ")})`),e}getDedupedWeaponsAndUpgrades(){const e=[];for(const t of[...this._weapons,...this._upgrades])e.some((e=>t.selectionName()===e.selectionName()))||e.push(t);return e}normalize(){this._weapons.sort(N),this._upgrades.sort(A),this._wargear.sort(A),this._psychicPowers.sort(A),this._psychicWeapons.sort(N),this.normalizeUpgrades(this._weapons),this.normalizeUpgrades(this._upgrades),this.normalizeUpgrades(this._wargear),this.normalizeUpgrades(this._psychicPowers),this.normalizeUpgrades(this._psychicWeapons)}normalizeUpgrades(e){for(let t=0;t(e._count>1?`${e._count}x `:"")+e.nameAndGear()))}weapons(){let e=this._models.map((e=>e._weapons)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._weapons),e.sort(N).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}psychicWeapons(){let e=this._models.map((e=>e._psychicWeapons)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._psychicWeapons),e.sort(N).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}psychicPowers(){let e=this._models.map((e=>e._psychicPowers)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._psychicPowers),e.sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}wargear(){let e=this._models.map((e=>e._wargear)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._wargear),e.sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}weaponRules(){let e=[];return e=this.weapons().map((e=>e.getRules())).reduce(((e,t)=>e.concat(t)),[]),e.sort().filter(((e,t,n)=>e!==n[t-1]))}warlordTraits(){let e=this._models.map((e=>e._warlordTraits)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._warlordTraits),e.sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}upgrades(){let e=this._models.map((e=>e._upgrades)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._upgrades),e.sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}reactions(){let e=this._models.map((e=>e._reactions)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._reactions),e.sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}}e.Unit=d;class h extends n{constructor(){super(),this._catalog="",this._name="Unknown",this._faction="Unknown",this._factionRules=new Map,this._rules=new Map,this._units=[]}}e.Force=h;class f extends n{constructor(){super(),this._cost=new p,this._name="",this._forces=[]}}e.Roster=f;class p{constructor(){this._points=0}hasValues(){return 0!==this._points}toString(){const e=[];return 0!==this._points&&e.push(`${this._points} pts`),`[${e.join(" / ")}]`}add(e){this._points+=e._points;for(const t in e._freeformValues)this.addFreeformValue(t,e._freeformValues[t])}addFreeformValue(e,t){this._freeformValues||(this._freeformValues={});const n=this._freeformValues[e]||0;this._freeformValues[e]=n+t}}function _(e,t){return e>t?1:e==t?0:-1}function m(e,t){return typeof e>typeof t?1:typeof e==typeof t?0:-1}function g(e){const t=new p,n=e.getAttribute("name"),r=e.getAttribute("value");return n&&r&&("Pts"===n?t._points+=+r:t.addFreeformValue(n,+r)),t}function v(e,n){var i,o;let s=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(!s)return;let h=null===(o=e.getAttributeNode("type"))||void 0===o?void 0:o.nodeValue;if(h)if(e.querySelector('profile[typeId="4bb2-cb95-e6c8-5a21"]')||e.querySelector('profile[typeId="2fae-b053-3f78-e7b2"]')||e.querySelector('profile[typeId="75b5-9f7a-156e-6889"]')||e.querySelector('profile[typeId="eeec-bde3-8ee4-35b0"]')){const i=function(e){var n,i,o;let s=new d;b(e,s);let h=e.querySelectorAll("categories>category");for(let e of h){const r=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;if(r){let e=S(r.trim());e!=t.NONE?s._role=e:r.endsWith(":")||s._keywords.add(r)}}const f=[],p=Array.from(e.querySelectorAll('profile[typeId="4bb2-cb95-e6c8-5a21"],profile[typeId="2fae-b053-3f78-e7b2"],profile[typeId="75b5-9f7a-156e-6889"],profile[typeId="eeec-bde3-8ee4-35b0"]'));(function(e,t,n){var r,i;for(const n of e){const e=n.getAttribute("name"),o=n.getAttribute("typeName");if(!e||!o)return;if("Unit"===o.trim()){const r=new l;r._name=e,t._modelStats.push(r),b(n,r);const i=n.querySelectorAll("characteristics>characteristic");for(const e of i){const t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"Unit Type":r._type=e.textContent;break;case"Move":r._move=k(e.textContent);break;case"WS":r._ws=+e.textContent;break;case"BS":r._bs=+e.textContent;break;case"S":r._str=+e.textContent;break;case"T":r._toughness=+e.textContent;break;case"W":r._wounds=+e.textContent;break;case"I":r._initiative=+e.textContent;break;case"A":r._attacks=+e.textContent;break;case"Ld":r._leadership=+e.textContent;break;case"Save":r._save=e.textContent}}}else if("Knights and Titans"===o.trim()){let r=new c;r._name=e,t._modelStats.push(r),b(n,r);const i=n.querySelectorAll("characteristics>characteristic");for(const e of i){const t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"Unit Type":r._type=e.textContent;break;case"Move":r._move=k(e.textContent);break;case"WS":r._ws=+e.textContent;break;case"BS":r._bs=+e.textContent;break;case"S":r._str=+e.textContent;break;case"Front":r._front=+e.textContent;break;case"Side":r._side=+e.textContent;break;case"Rear":r._rear=+e.textContent;break;case"I":r._initiative=+e.textContent;break;case"A":r._attacks=+e.textContent;break;case"HP":r._hp=+e.textContent}}}else if("Vehicle"===o.trim()){let i=new a;i._name=e,t._modelStats.push(i),b(n,i);const o=n.querySelectorAll("characteristics>characteristic");for(const e of o){const t=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue;if(t&&e.textContent)switch(t){case"Unit Type":i._type=e.textContent;break;case"Move":i._move=k(e.textContent);break;case"BS":i._bs=+e.textContent;break;case"Front":i._front=+e.textContent;break;case"Side":i._side=+e.textContent;break;case"Rear":i._rear=+e.textContent;break;case"HP":i._hp=+e.textContent;break;case"Transport Capacity":i._capacity=e.textContent;break;case"Access Points":i._accessPoints=e.textContent}}}else if("Fortification"===o.trim()){let r=new u;r._name=e,t._modelStats.push(r),b(n,r);const o=n.querySelectorAll("characteristics>characteristic");for(const e of o){const t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(t&&e.textContent)switch(t){case"Unit Type":r._type=e.textContent;break;case"BS":r._bs=e.textContent;break;case"Front":r._front=+e.textContent;break;case"Side":r._side=+e.textContent;break;case"Rear":r._rear=+e.textContent;break;case"HP":r._hp=+e.textContent;break;case"Transport Capacity":r._capacity=e.textContent;break;case"Fire Points":r._firePoints=e.textContent}}}}})(p,s),f.push(...p);const _=[];if("model"===e.getAttribute("type"))_.push(e);else{const t=function(e){const t=[];for(const n of e.children)if("selections"===n.tagName)for(const e of n.children)"selection"===e.tagName&&t.push(e);return t}(e);for(const e of t)("model"===e.getAttribute("type")||O(e,"Unit")||O(e,"Fortification")||O(e,"Vehicle")||O(e,"Knights and Titans"))&&_.push(e);0===_.length&&_.push(...Array.from(e.querySelectorAll('selection[type="model"]'))),(0===_.length&&O(e,"Unit")||O(e,"Fortification")||O(e,"Vehicle")||O(e,"Knights and Titans"))&&_.push(e)}for(const e of _){const t=Array.from(e.querySelectorAll("profiles>profile")),n=t.filter((e=>!f.includes(e)));f.push(...n);const i=new l;i._name=e.getAttribute("name")||"Unknown Model",i._count=Number(e.getAttribute("number")||1),s._models.push(i),R(t,i);for(const t of e.querySelectorAll('selections>selection[type="upgrade"]')){let e=t.getAttribute("name");if(e){const n=new r;n._name=e,n._cost=L(t),n._count=Number(t.getAttribute("number")),i._upgrades.push(n)}}}let m=e.querySelectorAll('selections>selection[type="upgrade"]');for(const e of m){R(Array.from(e.querySelectorAll("profiles>profile")),s);const t=e.getAttribute("name");if(t){const n=new r;n._name=t,n._cost=L(e),n._count=Number(e.getAttribute("number")),s._upgrades.push(n)}}let g=e.querySelectorAll("costs>cost");for(let e of g)if(e.hasAttribute("name")&&e.hasAttribute("value")){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue,n=null===(o=e.getAttributeNode("value"))||void 0===o?void 0:o.nodeValue;n&&"Pts"==t&&(s._points+=+n)}let v=e.querySelectorAll("rules>rule");for(let e of v)P(e,s._rules);return s.normalize(),s}(e);if(i){n._units.push(i);for(const e of i._rules.entries())n._rules.set(e[0],e[1])}}else"upgrade"===h?function(e,t){const n=e.querySelectorAll("rules>rule");for(const e of n)P(e,t)}(e,n._rules):console.log("** UNEXPECTED SELECTION **",s,h,e)}function b(e,t){var n,r;t._name=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;let i=e;"profile"===e.tagName&&e.parentElement&&e.parentElement.parentElement&&(i=e.parentElement.parentElement),t._customName=null===(r=i.getAttributeNode("customName"))||void 0===r?void 0:r.nodeValue;let o=i.firstElementChild;return o&&"customNotes"===o.tagName&&(t._customNotes=o.textContent),t._name}function y(e){var t;if(e.parentElement&&e.parentElement.parentElement){const n=null===(t=e.parentElement.parentElement.getAttributeNode("number"))||void 0===t?void 0:t.nodeValue;if(n)return+n}return 0}function w(e){var t;const n=new i;b(e,n),n._count=y(e);let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"Range":n._range=e.textContent;break;case"Type":n._type=e.textContent;break;case"Strength":n._str=e.textContent;break;case"AP":n._ap=e.textContent}}const o=null===(t=e.parentElement)||void 0===t?void 0:t.parentElement,s=null==o?void 0:o.getAttribute("name");return"upgrade"===(null==o?void 0:o.getAttribute("type"))&&s&&(n._selectionName=s,n._cost=L(o)),n}function C(e){var t;const n=new i;b(e,n),n._count=y(e);let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"Range":n._range=e.textContent;break;case"Type":n._type=e.textContent;break;case"Strength":n._str=e.textContent;break;case"AP":n._ap=e.textContent}}const o=null===(t=e.parentElement)||void 0===t?void 0:t.parentElement,s=null==o?void 0:o.getAttribute("name");return"upgrade"===(null==o?void 0:o.getAttribute("type"))&&s&&(n._selectionName=s,n._cost=L(o)),n}function x(e){const t=new r;b(e,t),t._count=y(e);let n=e.querySelectorAll("characteristics>characteristic");for(let e of n)if(e.textContent){let n=e.getAttribute("name");if(n)switch(n){case"Description":case"Text":t._description=e.textContent}}return t}function E(e,t){if(!t||!e)return!1;for(let n of t._forces)if(n._catalog===e._catalog)return!0;return!1}function S(e){switch(e){case"HQ:":return t.HQ;case"Troops:":return t.TR;case"Elites:":return t.EL;case"Fast Attack:":return t.FA;case"Heavy Support:":return t.HS;case"Flyer":return t.FL;case"Transport Sub-type:":return t.DT;case"Fortification:":return t.FT;case"Lords of War:":return t.LW;case"Primarch:":return t.PR}return t.NONE}function k(e){return function(e){return null!=e&&""!==e&&!isNaN(Number(e.toString()))}(e)?e.toString()+'"':e.toString()}function A(e,t){return _(e._name,t._name)}function T(e,t){return e._name===t._name?_(e.nameAndGear(),t.nameAndGear()):_(e._name,t._name)}function N(e,t){return(e._type.startsWith("Grenade")?2:e._type.startsWith("Melee")?1:0)-(t._type.startsWith("Grenade")?2:t._type.startsWith("Melee")?1:0)||e.name().localeCompare(t.name())}function L(e){const t=new p;for(const n of e.children)if("costs"===n.tagName)for(const e of n.children)t.add(g(e));return t}function R(e,t){for(const n of e){const e=n.getAttribute("name");let r=n.getAttribute("typeName");if(e&&r)if(r=r.trim(),"Unit"===r||"Vehicle"===r||"Knights and Titans"===r||"Fortification"===r||"model"===n.getAttribute("type"));else if("Weapon"===r){const e=w(n);t._weapons.push(e)}else if("Psychic Weapon"===r){const e=C(n);t._psychicWeapons.push(e)}else if("Psychic Power"===r){const e=x(n);t._psychicPowers.push(e)}else if("Wargear Item"===r){const e=x(n);t._wargear.push(e)}else if("Warlord Trait"===r){const e=x(n);t._warlordTraits.push(e)}else if("Reactions"===r){const e=x(n);t._reactions.push(e)}else console.log("Unhandled model/unit profile "+e+" of type "+r+".")}}function P(e,t){const n=e.getAttribute("name"),r=e.querySelector("description");n&&(null==r?void 0:r.textContent)&&t.set(n,r.textContent)}function O(e,t){var n;for(const r of e.children)if("profiles"===r.tagName)for(const e of r.children)if("profile"===e.tagName&&(null===(n=e.getAttribute("typeName"))||void 0===n?void 0:n.trim())===t)return!0;return!1}e.Costs=p,e.Compare=_,e.CompareModelTypes=m,e.CreateRoster=function(e){var t;if(e){let n=e.querySelector("roster");if(n){const r=new f,i=null===(t=n.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;return r._name=i||"Horus Heresy Army Roster",function(e,t){let n=e.querySelectorAll("roster>costs>cost");for(let e of n)t._cost.add(g(e))}(e,r),function(e,t){var n,r;let i=e.querySelectorAll("roster>forces>force");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let i=new h,o=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("catalogueName"))||void 0===r?void 0:r.nodeValue;if(o&&(i._name=o),s&&(i._catalog=s),!E(i,t)){const t=e.querySelectorAll("force>rules>rule");for(let e of t)P(e,i._rules)}let a=e.querySelectorAll(":scope>selections>selection");for(let e of a)v(e,i);i._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?0:-1)),t._forces.push(i)}}(e,r),r}}return null},e.CompareWeapon=N}(t.HorusHeresy||(t.HorusHeresy={}))},249:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Compare=t.CreateKT21Roster=t.RosterKT21=t.Force=t.Operative=t.OperativeRoleToString=t.Specialism=t.PsychicPowerWeapon=t.PsychicPower=t.UniqueActions=t.Weapons=t.BaseNotes=void 0;const s=o(n(486));class a{constructor(){this._name="",this._customName="",this._customNotes="",this._costs="0"}name(){return this._customName?this._customName:this._name}nameAndCosts(){let e=this._name;return this._customName&&(e=this._customName),this.costs()>0&&(e+=" ("+this.costs()+" EP)"),e}notes(){return this._customNotes}costs(){return Math.floor(+this._costs)}equal(e){return null!=e&&this._name===e._name}}t.BaseNotes=a;class l extends a{constructor(){super(...arguments),this._count=0,this._attacks="0",this._skill="0+",this._damage="0/0",this._rules="",this._criticalEffects=""}}t.Weapons=l,t.UniqueActions=class extends a{constructor(){super(...arguments),this._description=""}};class c extends a{constructor(){super(...arguments),this._effect="",this._weapons=[]}}var u;t.PsychicPower=c,t.PsychicPowerWeapon=class extends l{},function(e){e[e.NONE=0]="NONE",e[e.COMBAT=1]="COMBAT",e[e.STAUNCH=2]="STAUNCH",e[e.MARKSMAN=3]="MARKSMAN",e[e.SCOUT=4]="SCOUT"}(u=t.Specialism||(t.Specialism={})),t.OperativeRoleToString=["None","Combat","Staunch","Marksman","Scout"];class d extends a{constructor(){super(...arguments),this._role=u.NONE,this._model="",this._factions=new Set,this._keywords=new Set,this._abilities=new Map,this._rules=new Map,this._move='0"',this._apl="0",this._groupActivations="0",this._defence=0,this._saves="0+",this._wounds=0,this._weapons=[],this._upgrades=[],this._psychicPowers=[],this._psychicPowersWeapon=[]}equal(e){if(null==e)return!1;if(e._name===this._name&&e._role===this._role&&e._weapons.length===this._weapons.length){for(let t=0;t0||this._upgrades.length>0){let t=0;e+=" (";for(const n of this._weapons)e+=n.name(),t++,t!=this._weapons.length&&(e+=", ");this._upgrades.length>0&&!e.endsWith("(")&&(e+=", "),e+=this._upgrades.join(", "),e+=")"}return e}normalize(){this._weapons.sort(x),this._upgrades.sort(E);for(let e=0;eselections>selection");for(let e of r){let r=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;if(r&&"Game Type"!==r)if(r.includes("Detachment Command Cost"))console.log("Found Detachment Command Cost");else if(r.includes("Chapter Tactics"))console.log("Found chapter tactics."),m(e,t._rules);else{let n=w(e);if(n){n._keywords.has("Leader")?t._leader=n:t._operatives.push(n);for(const e of n._rules.entries())t._rules.set(e[0],e[1])}else if("upgrade"===e.getAttribute("type")){m(e,t._rules);const n=e.querySelectorAll("selections>selection");for(let e of n){const n=e.getAttribute("name");n&&"upgrade"===e.getAttribute("type")&&("Unknown"===t._faction&&(t._faction=n),m(e,t._factionRules))}}}}for(const e of t._factionRules.keys())t._rules.delete(e);t._operatives.sort(((e,t)=>e._role>t._role?1:e._role==t._role?e._name>t._name?1:e._name==t._name?0:-1:-1))}function _(e,t){if(!t||!e)return!1;for(let n of t._forces)if(n._catalog===e._catalog)return!0;return!1}function m(e,t){var n,r,i,o,s;const a=e.querySelectorAll(":scope profiles>profile");for(const l of a){const a=null===(n=l.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,c=null===(r=l.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(console.log("Prop name:"+a+" Type: "+c),a&&c)if("Abilities"===c||"Dynastic Code"===c||"Chapter Tactics"===c){const e=l.querySelectorAll("characteristics>characteristic");for(const n of e){const e=null===(i=n.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;e&&n.textContent&&a&&("Description"!==e&&"Ability"!==e&&"Effect"!=e&&"Chapter Tactic"!=e||t.set(a,n.textContent))}}else if("Weapons"===c){const n=e.querySelectorAll("rules>rule");for(const e of n)e.getAttributeNode("name")&&t.set(null===(o=e.getAttributeNode("name"))||void 0===o?void 0:o.nodeValue,null===(s=e.firstChild)||void 0===s?void 0:s.textContent)}}}function g(e){switch(e){case"Combat":return u.COMBAT;case"Staunch":return u.STAUNCH;case"Marksman":return u.MARKSMAN;case"Scout":return u.SCOUT}return u.NONE}function v(e,t){var n,r;let i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;console.log("Unknown profile type: "+o+" with name: "+i+". Found in operative: "+t._name)}function b(e,t){var n,r,i;t._name=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;let o=e;"profile"===e.tagName&&e.parentElement&&e.parentElement.parentElement&&(o=e.parentElement.parentElement),t._customName=null===(r=o.getAttributeNode("customName"))||void 0===r?void 0:r.nodeValue;let s=o.firstElementChild;if(s&&"customNotes"===s.tagName&&(t._customNotes=s.textContent),"selection"===o.tagName){let e=o.querySelector("costs>cost");e&&e.getAttributeNode("value")&&(t._costs=null===(i=e.getAttributeNode("value"))||void 0===i?void 0:i.nodeValue)}return t._name}function y(e){var t;if(e.parentElement&&e.parentElement.parentElement){const n=null===(t=e.parentElement.parentElement.getAttributeNode("number"))||void 0===t?void 0:t.nodeValue;if(n)return+n}return 0}function w(e){var t,n,r,i,o;let s=new d;b(e,s);let a=e.querySelectorAll(":scope categories>category");for(let e of a){const n=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;if(n){const e="Faction: ",t=n.lastIndexOf(e);if(t>=0){const r=n.slice(t+e.length);s._factions.add(r)}else{let e=g(n.trim());e!=u.NONE?s._role=e:s._keywords.add(n)}}}let l=[],c=[];for(let t of e.querySelectorAll('profile[typeName="Operative"]')){let e=null===(n=t.parentElement)||void 0===n?void 0:n.parentElement;if(!e||c.includes(e))continue;c.push(e);let r=Array.from(e.querySelectorAll(":scope profiles>profile")||[]);C(r,s),l=l.concat(r)}C(Array.from(e.querySelectorAll(":scope profiles>profile")).filter((e=>!l.includes(e))),s,0,!0);let h=e.querySelectorAll(":scope costs>cost");for(let e of h)if(e.hasAttribute("name")&&e.hasAttribute("value")){let t=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue,n=null===(i=e.getAttributeNode("value"))||void 0===i?void 0:i.nodeValue;" EP"==t&&n&&+n>0&&(s._costs=(s.costs()+parseInt(n)).toString())}let f=e.querySelectorAll("rules > rule");for(let e of f)if(e.hasAttribute("name")){let t=null===(o=e.getAttributeNode("name"))||void 0===o?void 0:o.nodeValue,n=e.querySelector("description");t&&n&&n.textContent&&s._rules.set(t,n.textContent)}return s.normalize(),s}function C(e,t,n,r=!1){var i,o,s,a,u,d,h,f,p,_,g,w;for(let n of e){const e=null===(i=n.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue,r=null===(o=n.getAttributeNode("typeName"))||void 0===o?void 0:o.nodeValue;if(e&&r)if("Operative"===r){let e=t._name;b(n,t),t._model=t._name,t._name=e;let r=n.querySelectorAll("characteristics>characteristic");for(let e of r){let n=null===(s=e.getAttributeNode("name"))||void 0===s?void 0:s.nodeValue;if(n&&e.textContent)switch(n){case"M":t._move=e.textContent;break;case"APL":t._apl=e.textContent;break;case"GA":t._groupActivations=e.textContent;break;case"DF":t._defence=+e.textContent;break;case"SV":t._saves=e.textContent;break;case"W":t._wounds=+e.textContent}}}else if("Abilities"===r||"Equipment"===r||"Ability"===r||"Unique Actions"===r||"Chapter Tactics"==r){let r=n.querySelectorAll("characteristics>characteristic");for(let i of r)if((null===(a=i.getAttributeNode("name"))||void 0===a?void 0:a.nodeValue)&&i.textContent&&e){let r=null===(d=null===(u=n.parentElement)||void 0===u?void 0:u.parentElement)||void 0===d?void 0:d.querySelector("costs>cost"),o=e;if(r&&(null===(h=r.getAttributeNode("value"))||void 0===h?void 0:h.nodeValue)){let e=null===(f=r.getAttributeNode("value"))||void 0===f?void 0:f.nodeValue;e&&+e>0&&(o+=" ("+Math.floor(+e)+" EP)")}t._abilities.set(o,i.textContent)}if(n.parentElement&&n.parentElement.parentElement){const r=n.parentElement.parentElement;"upgrade"===(null===(p=r.getAttributeNode("type"))||void 0===p?void 0:p.nodeValue)&&r.parentElement&&r.parentElement.parentElement&&"model"===(null===(_=r.parentElement.parentElement.getAttributeNode("type"))||void 0===_?void 0:_.nodeValue)&&t._upgrades.push(e)}}else if("Weapons"===r){let e=new l;b(n,e),n.parentElement&&n.parentElement.parentElement&&m(n.parentElement.parentElement,t._rules),e._count=y(n);let r=n.querySelectorAll("characteristics>characteristic");for(let t of r){let n=null===(g=t.getAttributeNode("name"))||void 0===g?void 0:g.nodeValue;if(n&&t.textContent)switch(n){case"A":e._attacks=t.textContent;break;case"WS/BS":e._skill=t.textContent;break;case"D":e._damage=t.textContent;break;case"SR":e._rules=t.textContent;break;case"!":e._criticalEffects=t.textContent}}t._weapons.push(e)}else if("Psychic Power"==r){let e=new c;b(n,e);let r=n.querySelectorAll("characteristics>characteristic");for(let t of r)"Effect"===(null===(w=t.getAttributeNode("name"))||void 0===w?void 0:w.nodeValue)&&t.textContent&&(e._effect=t.textContent);t._psychicPowers.push(e)}else v(n,t)}}function x(e,t){return E(e._name,t._name)}function E(e,t){return e>t?1:e==t?0:-1}t.RosterKT21=f,t.CreateKT21Roster=function(e){var t;if(e){let n=e.querySelector("roster");if(n){const r=new f,i=null===(t=n.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;return r._name=i||"Kill Team (2021) Army Roster",function(e,t){var n,r;let i=e.querySelectorAll("roster>costs>cost");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("value")){let i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("value"))||void 0===r?void 0:r.nodeValue;o&&" EP"==i&&(t._equipmentPoints=+o)}}(e,r),function(e,t){var n,r,i;let o=e.querySelectorAll("roster>forces>force");for(let e of o)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let o=new h,l=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,c=null===(r=e.getAttributeNode("catalogueName"))||void 0===r?void 0:r.nodeValue;if(l&&(o._name=l),c&&(o._catalog=c,o._faction=c),!_(o,t)){var s=e.querySelectorAll("force>rules>rule");for(let e of s)if(e.hasAttribute("name")){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;var a=e.querySelector("rule>description");t&&a&&o._rules.set(t,a.textContent)}}p(e,o),t._forces.push(o)}}(e,r),r}}return null},t.Compare=E},452:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateMESBGRoster=void 0;const n=/\r\n|\r|\n| /,r=e=>{var t;return null!==(t=e.getAttribute("catalogueName"))&&void 0!==t?t:"MESBG Force"},i=e=>{var t;const n={half:0,quarter:0,modelCount:0};for(let r of e.querySelectorAll("rules>rule")){const e=null!==(t=r.getAttribute("name"))&&void 0!==t?t:"";if(e.endsWith("is halfway. (model)")){const t=parseFloat(e);isNaN(t)||(n.half=Math.ceil(t))}if(e.endsWith("models remaining. (model)")){const t=parseFloat(e);isNaN(t)||(n.quarter=Math.ceil(t))}if(e.endsWith("total models in Army. (model)")){const t=parseFloat(e);isNaN(t)||(n.modelCount=t)}}return n},o=e=>{var t,r,i,o,s,a,l,c,u,d,h,f,p,_,m,g,v,b,y;let w="",C="",x="",E=[],S="",k=!1;const A=[];for(let u of e.querySelectorAll('profiles > profile[typeName="Hero"]'))for(let e of u.querySelectorAll("characteristics > characteristic"))switch(null!==(r=null===(t=e.getAttribute("name"))||void 0===t?void 0:t.trim())&&void 0!==r?r:""){case"Might":x=null!==(i=e.textContent)&&void 0!==i?i:"";break;case"Fate":w=null!==(o=e.textContent)&&void 0!==o?o:"";break;case"Will":C=null!==(s=e.textContent)&&void 0!==s?s:"";break;case"Heroic Actions":E=null!==(l=null===(a=e.textContent)||void 0===a?void 0:a.split(n))&&void 0!==l?l:[];break;case"Heroic Tier":S=null!==(c=e.textContent)&&void 0!==c?c:""}for(let t of e.querySelectorAll('profile[typeName="Magical Power"]')){const e=null!==(u=t.getAttribute("name"))&&void 0!==u?u:"Unnamed Magic Power",n=null!==(h=null===(d=t.querySelector(':scope characteristic[name~="Duration"]'))||void 0===d?void 0:d.textContent)&&void 0!==h?h:"",r=null!==(p=null===(f=t.querySelector(':scope characteristic[name~="Range"]'))||void 0===f?void 0:f.textContent)&&void 0!==p?p:"",i=null!==(m=null===(_=t.querySelector(':scope characteristic[name~="Casting"]'))||void 0===_?void 0:_.textContent)&&void 0!==m?m:"",o=null!==(v=null===(g=t.querySelector(':scope characteristic[name~="Rule"]'))||void 0===g?void 0:g.textContent)&&void 0!==v?v:"",s=null!==(y=null===(b=t.querySelector(':scope characteristic[name~="Channelled"]'))||void 0===b?void 0:b.textContent)&&void 0!==y?y:"";A.push({name:e,duration:n,range:r,casting:i,normalEffect:o,channelledEffect:s})}return k=!!e.querySelector('selections > selection[name$="Leader (Valour)"]'),{fate:w,will:C,might:x,heroicTier:S,actions:E,magicalPowers:A,isLeader:k}},s=e=>{var t,r,i,a,u,d,h,f,p,_,m,g,v,b,y,w,C,x,E,S,k,A,T,N,L;const R=(e=>{var t,n,r;const i=[];for(let o of e)if(o.hasAttribute("name")){const e=null!==(t=o.getAttribute("name"))&&void 0!==t?t:null,s=null!==(r=null===(n=o.querySelector("rule>description"))||void 0===n?void 0:n.textContent)&&void 0!==r?r:"";null!==e&&i.push({name:e,ruleText:s})}return i})(null!==(t=e.querySelectorAll("rules > rule"))&&void 0!==t?t:[]),P=null!==(i=null===(r=e.getAttribute("name"))||void 0===r?void 0:r.trim())&&void 0!==i?i:"Unknown Model Name";let O=[];const W=[];let z,I,B="",M="",U="",D="",F="",q="",H="";e.querySelectorAll("profiles > profile");for(let t of e.querySelectorAll(":scope profiles > profile")){const r=t.getAttribute("typeName"),i=null!==(u=null===(a=t.getAttribute("name"))||void 0===a?void 0:a.trim())&&void 0!==u?u:"wowza";if(("Hero"===r||"Warrior"===r)&&i.startsWith(P)){for(let e of t.querySelectorAll("characteristics > characteristic"))switch(null!==(h=null===(d=e.getAttribute("name"))||void 0===d?void 0:d.trim())&&void 0!==h?h:""){case"Wounds":q=null!==(f=e.textContent)&&void 0!==f?f:"";break;case"Courage":H=null!==(p=e.textContent)&&void 0!==p?p:"";break;case"Attack":F=null!==(_=e.textContent)&&void 0!==_?_:"";break;case"Defense":D=null!==(m=e.textContent)&&void 0!==m?m:"";break;case"Strength":U=null!==(g=e.textContent)&&void 0!==g?g:"";break;case"Fight":M=null!==(v=e.textContent)&&void 0!==v?v:"";break;case"Movement":B=null!==(b=e.textContent)&&void 0!==b?b:"";break;case"Keywords":O=null!==(w=null===(y=e.textContent)||void 0===y?void 0:y.split(n))&&void 0!==w?w:[]}for(let t of null!==(C=l(e))&&void 0!==C?C:[]){if("Shield"===t.getAttribute("name")||t.querySelector('profile[typeName$="Wargear"]')||t.querySelector('profile[typeName$="Shooting Weapon"]')){const e=null!==(x=t.getAttribute("name"))&&void 0!==x?x:"Equipment",n=parseInt(null!==(S=null===(E=t.querySelector('cost[name$="Points"]'))||void 0===E?void 0:E.getAttribute("value"))&&void 0!==S?S:"0"),r=[];for(let e of t.querySelectorAll("characteristics > characteristic"))null!==e.textContent&&r.push(e.textContent);W.push({name:e,points:n,rules:r})}t.querySelector('profile[typeName$="Warrior"]')&&(z=s(null===(A=null===(k=t.querySelector('profile[typeName$="Warrior"]'))||void 0===k?void 0:k.parentElement)||void 0===A?void 0:A.parentElement))}"Hero"===r&&(I=o(e))}}let j=0;for(let t of null!==(T=c(e))&&void 0!==T?T:[])"Points"===(null===(N=t.getAttribute("name"))||void 0===N?void 0:N.trim())&&(j=parseInt(null!==(L=t.getAttribute("value"))&&void 0!==L?L:"0"));return{name:P,points:j,keywords:O,rules:R,profile:{attack:F,courage:H,defense:D,fight:M,movement:B,strength:U,wounds:q},wargear:W,mount:z,heroStuff:I}},a=e=>{var t,n,r,i;const o=[];for(let a of null!==(t=l(e))&&void 0!==t?t:[]){const e=a.querySelector('selection[type~="model"]');if(null!==e){const t=s(a),l=parseInt(null!==(n=e.getAttribute("number"))&&void 0!==n?n:"0"),c=parseInt(null!==(i=null===(r=e.querySelector('cost[name~="Points"]'))||void 0===r?void 0:r.getAttribute("value"))&&void 0!==i?i:"0");o.push({model:t,count:l,points:c})}}return o},l=e=>{var t,n;return null!==(n=null===(t=e.querySelector("selections"))||void 0===t?void 0:t.querySelectorAll(":scope > selection"))&&void 0!==n?n:null},c=e=>{var t,n;return null!==(n=null===(t=e.querySelector("costs"))||void 0===t?void 0:t.querySelectorAll(":scope > cost"))&&void 0!==n?n:null},u=e=>{let t=null,n=[];const r=l(e);if(null===r)return r;for(let e of r)"model"===e.getAttribute("type")&&(t=s(e)),"Warband"===e.getAttribute("name")&&(n=a(e));return null!==t?{leader:t,warband:n}:null},d=e=>{var t;let n=!1;for(let r of null!==(t=l(e))&&void 0!==t?t:[])"model"===r.getAttribute("type")&&(n=!0);return n};t.CreateMESBGRoster=function(e){var t,n;if(e){const o=null!==(n=null===(t=e.querySelector("roster"))||void 0===t?void 0:t.getAttribute("name"))&&void 0!==n?n:"Middle-Earth Stratgegy Battle Game Roster",{points:s,warriors:a}=(e=>{var t,n,r,i;const o=e.querySelectorAll("roster>costs>cost");let s=0,a=0;for(let e of o)"Points"===(null===(t=e.getAttribute("name"))||void 0===t?void 0:t.trim())&&(s=parseInt(null!==(n=e.getAttribute("value"))&&void 0!==n?n:"0")),"Warriors"===(null===(r=e.getAttribute("name"))||void 0===r?void 0:r.trim())&&(a=parseInt(null!==(i=e.getAttribute("value"))&&void 0!==i?i:"0"));return{points:s,warriors:a}})(e),c=(e=>{var t,n,o;const s=e.querySelectorAll("roster>forces>force"),a=[];for(let e of s){const s=r(e);let c={half:0,quarter:0,modelCount:0};const h=[],f=[],p=l(e);if(null!==p){for(let e of p)if("Determine Breakpoint & 25%"===e.getAttribute("name"))c=i(e);else if(d(e)){const t=u(e);null!==t&&h.push(t)}else{const r=e.querySelectorAll("rules > rule");for(let e of r){const r=null!==(n=null===(t=e.querySelector("description"))||void 0===t?void 0:t.textContent)&&void 0!==n?n:"";f.push({name:null!==(o=e.getAttribute("name"))&&void 0!==o?o:"",ruleText:r})}}a.push({name:s,breakpoints:c,units:h,armyBonus:f})}}return a})(e);return{name:o,forces:c,points:s,warriors:a}}return alert("Bad Input File"),null}},320:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateWarcryRoster=t.RosterWarcry=t.WarcryForce=t.WarcryUnit=t.WarcryDamageTable=t.WarcryUnitRoleToString=t.WarcryUnitRole=t.WarcryWeapon=t.WarcryAllegiance=void 0;class n{constructor(){this._name="",this._rules=new Map}}t.WarcryAllegiance=n;class r{constructor(){this._name="",this._range="",this._attacks="",this._strength="",this._damage=""}}var i;t.WarcryWeapon=r,function(e){e[e.NONE=0]="NONE",e[e.LEADER=1]="LEADER",e[e.FIGHTER=2]="FIGHTER",e[e.ALLY=3]="ALLY",e[e.MONSTER=4]="MONSTER",e[e.HERO=5]="HERO",e[e.THRALL=6]="THRALL"}(i=t.WarcryUnitRole||(t.WarcryUnitRole={})),t.WarcryUnitRoleToString=["None","Leader","Fighter","Ally","Monster","Hero","Thrall"];class o{constructor(){this._name="",this._table=new Map}}t.WarcryDamageTable=o;class s{constructor(){this._name="",this._role=i.NONE,this._faction="chaos-iron-golems",this._keywords=new Set,this._abilities=new Map,this._move="1",this._wounds="1",this._toughness="1",this._weapons=[],this._damageTable=[],this._points=0}}t.WarcryUnit=s;class a{constructor(){this._catalog="",this._name="Unknown",this._units=[],this._allegiance=new n}}t.WarcryForce=a;class l{constructor(){this._points=0,this._name="",this._forces=[]}}function c(e){const t=e.toLowerCase();return t.includes("chaotic beasts")?"monster-chaotic-beasts":t.includes("monster")?t.includes("order")?"monster-of-order":t.includes("destruction")?"monster-of-destruction":t.includes("death")?"monster-of-death":"monster-chaotic-beasts":t.includes("beasts of chaos")?"factions-chaos-beasts-of-chaos":t.includes("corvus")?"factions-chaos-corvus-cabal":t.includes("cypher")?"factions-chaos-cypher-lords":t.includes("everchosen")?"factions-chaos-everchosen":t.includes("golems")?"factions-chaos-iron-golems":t.includes("khorne")&&t.includes("bloodbound")?"factions-chaos-khorne-bloodbound":t.includes("khorne")&&t.includes("daemon")?"factions-chaos-khorne-daemons":t.includes("nurgle")&&t.includes("rotbringer")?"factions-chaos-nurgle-rotbringers":t.includes("nurgle")&&t.includes("daemon")?"factions-chaos-nurgle-daemons":t.includes("scions")?"factions-chaos-scions-of-the-flame":t.includes("skaven")?"factions-chaos-skaven":t.includes("slaanesh")&&t.includes("sybariteI g")?"factions-chaos-slaanesh-syberites":t.includes("slaanesh")&&t.includes("daemon")?"factions-chaos-slaanesh-daemons":t.includes("slaves")?"factions-chaos-slaves-to-darkness":t.includes("spire")?"factions-chaos-spire-tyrants":t.includes("splintered")?"factions-chaos-splintered-fang":t.includes("unmade")?"factions-chaos-the-unmade":t.includes("tzeentch")&&t.includes("arcanite")?"factions-chaos-tzeentch-arcanites":t.includes("tzeentch")&&t.includes("daemon")?"factions-chaos-tzeentch-daemons":t.includes("untamed")?"factions-chaos-untamed-beasts":t.includes("flesh")?"factions-death-flesh-eater-courts":t.includes("nagash")?"factions-death-legions-of-nagash":t.includes("nighthaunt")?"factions-death-nighthaunt":t.includes("ossiarch")?"factions-death-ossiarch-bonereapers":t.includes("soulblight")?"factions-death-soulblight-gravelords":t.includes("bonesplitterz")?"factions-destruction-bonesplitterz":t.includes("fimirach")?"factions-destruction-fimirach":t.includes("gloomspite")?"factions-destruction-gloomspite-gitz":t.includes("ironjawz")?"factions-destruction-ironjawz":t.includes("kruleboyz")?"factions-destruction-kruleboyz":t.includes("ogor")?"factions-destruction-ogor-mawtribes":t.includes("cities of sigmar")?"factions-order-cities-of-sigmar":t.includes("khaine")?"factions-order-daughters-of-khaine":t.includes("fyreslayers")?"factions-order-fyreslayers":t.includes("idoneth")?"factions-order-idoneth-deepkin":t.includes("shadowstalkers")?"factions-order-khainite-shadowstalkers":t.includes("kharadron")?"factions-order-kharadron-overlords":t.includes("lumineth")?"factions-order-lumineth-realmlords":t.includes("seraphon")?"factions-order-seraphon":t.includes("stormcast")?t.includes("sacrosanct")?"factions-order-stormcast-eternals-sacrosanct":t.includes("thunderstrike")?"factions-order-stormcast-eternals-thunderstrike":t.includes("vanguard")?"factions-order-stormcast-eternals-vanguard":"factions-order-stormcast-eternals-warrior":t.includes("sylvaneth")?"factions-order-sylvaneth":""}function u(e,t){var r;let i=new n,o=e.querySelectorAll("rules>rule");for(let e of o)if(e.hasAttribute("name")){let t=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue;var s=e.querySelector("rule>description");t&&s&&s.textContent&&i._rules.set(t,s.textContent)}t._allegiance=i}function d(e,t){var n,r;let o=e.querySelectorAll("force>selections>selection");for(let e of o){if(!(null===(n=e.getAttributeNode("type"))||void 0===n?void 0:n.nodeValue))continue;if(!(null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue))continue;let o=h(e);o&&o._role!=i.NONE&&t._units.push(o)}t._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?0:-1))}function h(e){var t,n,a,l,u,d,h,f,p;let _=new s,m=e.querySelectorAll("profiles>profile");for(let e of m){let i=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue,s=null===(n=e.getAttributeNode("typeName"))||void 0===n?void 0:n.nodeValue;if(i&&s)if("Model"==s){_._name=i;let t=e.querySelectorAll("characteristics>characteristic");for(let e of t){let t=null===(a=e.getAttributeNode("name"))||void 0===a?void 0:a.nodeValue;if(t&&e.textContent)switch(t){case"Move":_._move=e.textContent;break;case"Wounds":_._wounds=e.textContent;break;case"Toughness":_._toughness=e.textContent}}}else if("Weapon"==s){let t=new r;t._name=i;let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let n=null===(l=e.getAttributeNode("name"))||void 0===l?void 0:l.nodeValue;if(n&&e.textContent)switch(n){case"Range":t._range=e.textContent;break;case"Attacks":t._attacks=e.textContent;break;case"Strength":t._strength=e.textContent;break;case"Damage":t._damage=e.textContent}}_._weapons.push(t)}else if("Damage Points Allocated"==s){let t=new o;t._name=i;let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let n=null===(u=e.getAttributeNode("name"))||void 0===u?void 0:u.nodeValue;n&&i&&(e.textContent?t._table.set(n,e.textContent):t._table.set(n,"-"))}_._damageTable.push(t)}else console.log("Unknown unit profile type: "+s)}let g=e.querySelectorAll("costs>cost");for(let e of g)if(e.hasAttribute("name")&&e.hasAttribute("value")){let t=null===(d=e.getAttributeNode("name"))||void 0===d?void 0:d.nodeValue,n=null===(h=e.getAttributeNode("value"))||void 0===h?void 0:h.nodeValue;n&&"pts"===t&&(_._points+=+n)}let v=e.querySelectorAll(":scope categories>category");for(let e of v){let t=null===(f=e.getAttributeNode("name"))||void 0===f?void 0:f.nodeValue;if(t){var b=(y=t.trim()).includes("Leader")?i.LEADER:y.includes("Fighter")?i.FIGHTER:y.includes("Allies")||y.includes("Ally")?i.ALLY:y.includes("Monster")?i.MONSTER:y.includes("Hero")?i.HERO:y.includes("Thrall")?i.THRALL:i.NONE;b!=i.NONE?_._role=b:_._keywords.add(t)}}var y;let w=e.querySelectorAll(":scope selections>selection");for(let e of w){let t=null===(p=e.getAttributeNode("name"))||void 0===p?void 0:p.nodeValue;if(t){let e=c(t);e.length>0?_._faction=e:_._keywords.add(t)}}return _}t.RosterWarcry=l,t.CreateWarcryRoster=function(e){var t;if(e){let n=e.querySelector("roster");if(n){const r=new l,i=null===(t=n.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;return r._name=i||"Age of Sigmar Warcry Roster",function(e,t){var n,r;let i=e.querySelectorAll("roster>costs>cost");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("value")){let i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("value"))||void 0===r?void 0:r.nodeValue;o&&"pts"===i&&(t._points=+o)}}(e,r),function(e,t){var n,r;let i=e.querySelectorAll("roster>forces>force");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let i=new a,o=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("catalogueName"))||void 0===r?void 0:r.nodeValue;o&&(i._name=o),s&&(i._catalog=s),u(e,i),d(e,i),t._forces.push(i)}console.log(t)}(e,r),r}}return null}},596:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.formatStat=t.filterAndOrderStats=void 0,t.filterAndOrderStats=function(e){return Object.entries(e).filter((e=>e[1].statOrder>=0&&void 0===e[1].groupOrder&&"normal"===e[1].visibility)).sort(((e,t)=>e[1].statOrder-t[1].statOrder))},t.formatStat=function(e){const t=String(e.value);return e.format?e.format.replace(/{[vt]}/,t):t}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),n(752)})(); \ No newline at end of file +(()=>{var e={733:(e,t,n)=>{e.exports=function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[s]={exports:{}};t[s][0].call(c.exports,(function(e){return i(t[s][1][e]||e)}),c,c.exports,e,t,n,r)}return n[s].exports}for(var o=void 0,s=0;s>2,a=(3&t)<<4|n>>4,l=1>6:64,c=2>4,n=(15&s)<<4|(a=o.indexOf(e.charAt(c++)))>>2,r=(3&a)<<6|(l=o.indexOf(e.charAt(c++))),h[u++]=t,64!==a&&(h[u++]=n),64!==l&&(h[u++]=r);return h}},{"./support":30,"./utils":32}],2:[function(e,t,n){"use strict";var r=e("./external"),i=e("./stream/DataWorker"),o=e("./stream/Crc32Probe"),s=e("./stream/DataLengthProbe");function a(e,t,n,r,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=n,this.compression=r,this.compressedContent=i}a.prototype={getContentWorker:function(){var e=new i(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new s("data_length")),t=this;return e.on("end",(function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),e},getCompressedWorker:function(){return new i(r.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},a.createWorkerFrom=function(e,t,n){return e.pipe(new o).pipe(new s("uncompressedSize")).pipe(t.compressWorker(n)).pipe(new s("compressedSize")).withStreamInfo("compression",t)},t.exports=a},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,n){"use strict";var r=e("./stream/GenericWorker");n.STORE={magic:"\0\0",compressWorker:function(e){return new r("STORE compression")},uncompressWorker:function(){return new r("STORE decompression")}},n.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,n){"use strict";var r=e("./utils"),i=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==r.getTypeOf(e)?function(e,t,n,r){var o=i,s=0+n;e^=-1;for(var a=0;a>>8^o[255&(e^t[a])];return-1^e}(0|t,e,e.length):function(e,t,n,r){var o=i,s=0+n;e^=-1;for(var a=0;a>>8^o[255&(e^t.charCodeAt(a))];return-1^e}(0|t,e,e.length):0}},{"./utils":32}],5:[function(e,t,n){"use strict";n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(e,t,n){"use strict";var r;r="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:r}},{lie:37}],7:[function(e,t,n){"use strict";var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=e("pako"),o=e("./utils"),s=e("./stream/GenericWorker"),a=r?"uint8array":"array";function l(e,t){s.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}n.magic="\b\0",o.inherits(l,s),l.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(o.transformTo(a,e.data),!1)},l.prototype.flush=function(){s.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},l.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this._pako=null},l.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},n.compressWorker=function(e){return new l("Deflate",e)},n.uncompressWorker=function(){return new l("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,n){"use strict";function r(e,t){var n,r="";for(n=0;n>>=8;return r}function i(e,t,n,i,s,u){var d,h,f=e.file,p=e.compression,_=u!==a.utf8encode,m=o.transformTo("string",u(f.name)),g=o.transformTo("string",a.utf8encode(f.name)),v=f.comment,b=o.transformTo("string",u(v)),y=o.transformTo("string",a.utf8encode(v)),w=g.length!==f.name.length,C=y.length!==v.length,x="",E="",S="",k=f.dir,A=f.date,T={crc32:0,compressedSize:0,uncompressedSize:0};t&&!n||(T.crc32=e.crc32,T.compressedSize=e.compressedSize,T.uncompressedSize=e.uncompressedSize);var N=0;t&&(N|=8),_||!w&&!C||(N|=2048);var L=0,R=0;k&&(L|=16),"UNIX"===s?(R=798,L|=function(e,t){var n=e;return e||(n=t?16893:33204),(65535&n)<<16}(f.unixPermissions,k)):(R=20,L|=function(e){return 63&(e||0)}(f.dosPermissions)),d=A.getUTCHours(),d<<=6,d|=A.getUTCMinutes(),d<<=5,d|=A.getUTCSeconds()/2,h=A.getUTCFullYear()-1980,h<<=4,h|=A.getUTCMonth()+1,h<<=5,h|=A.getUTCDate(),w&&(E=r(1,1)+r(l(m),4)+g,x+="up"+r(E.length,2)+E),C&&(S=r(1,1)+r(l(b),4)+y,x+="uc"+r(S.length,2)+S);var P="";return P+="\n\0",P+=r(N,2),P+=p.magic,P+=r(d,2),P+=r(h,2),P+=r(T.crc32,4),P+=r(T.compressedSize,4),P+=r(T.uncompressedSize,4),P+=r(m.length,2),P+=r(x.length,2),{fileRecord:c.LOCAL_FILE_HEADER+P+m+x,dirRecord:c.CENTRAL_FILE_HEADER+r(R,2)+P+r(b.length,2)+"\0\0\0\0"+r(L,4)+r(i,4)+m+x+b}}var o=e("../utils"),s=e("../stream/GenericWorker"),a=e("../utf8"),l=e("../crc32"),c=e("../signature");function u(e,t,n,r){s.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=n,this.encodeFileName=r,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(u,s),u.prototype.push=function(e){var t=e.meta.percent||0,n=this.entriesCount,r=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,s.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:n?(t+100*(n-r-1))/n:100}}))},u.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var n=i(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:n.fileRecord,meta:{percent:0}})}else this.accumulate=!0},u.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,n=i(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(n.dirRecord),t)this.push({data:function(e){return c.DATA_DESCRIPTOR+r(e.crc32,4)+r(e.compressedSize,4)+r(e.uncompressedSize,4)}(e),meta:{percent:100}});else for(this.push({data:n.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},u.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t=this.index;t--)n=(n<<8)+this.byteAt(t);return this.index+=e,n},readString:function(e){return r.transformTo("string",this.readData(e))},readData:function(e){},lastIndexOfSignature:function(e){},readAndCheckSignature:function(e){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i},{"../utils":32}],19:[function(e,t,n){"use strict";var r=e("./Uint8ArrayReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,n){"use strict";var r=e("./DataReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],21:[function(e,t,n){"use strict";var r=e("./ArrayReader");function i(e){r.call(this,e)}e("../utils").inherits(i,r),i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,n){"use strict";var r=e("../utils"),i=e("../support"),o=e("./ArrayReader"),s=e("./StringReader"),a=e("./NodeBufferReader"),l=e("./Uint8ArrayReader");t.exports=function(e){var t=r.getTypeOf(e);return r.checkSupport(t),"string"!==t||i.uint8array?"nodebuffer"===t?new a(e):i.uint8array?new l(r.transformTo("uint8array",e)):new o(r.transformTo("array",e)):new s(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,n){"use strict";n.LOCAL_FILE_HEADER="PK",n.CENTRAL_FILE_HEADER="PK",n.CENTRAL_DIRECTORY_END="PK",n.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",n.ZIP64_CENTRAL_DIRECTORY_END="PK",n.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,n){"use strict";var r=e("./GenericWorker"),i=e("../utils");function o(e){r.call(this,"ConvertWorker to "+e),this.destType=e}i.inherits(o,r),o.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta})},t.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,n){"use strict";var r=e("./GenericWorker"),i=e("../crc32");function o(){r.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(o,r),o.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,n){"use strict";var r=e("../utils"),i=e("./GenericWorker");function o(e){i.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}r.inherits(o,i),o.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}i.prototype.processChunk.call(this,e)},t.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,n){"use strict";var r=e("../utils"),i=e("./GenericWorker");function o(e){i.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then((function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=r.getTypeOf(e),t.isPaused||t._tickAndRepeat()}),(function(e){t.error(e)}))}r.inherits(o,i),o.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,n){"use strict";function r(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}r.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var n=0;n "+e:e}},t.exports=r},{}],29:[function(e,t,n){"use strict";var r=e("../utils"),i=e("./ConvertWorker"),o=e("./GenericWorker"),s=e("../base64"),a=e("../support"),l=e("../external"),c=null;if(a.nodestream)try{c=e("../nodejs/NodejsStreamOutputAdapter")}catch(e){}function u(e,t,n){var s=t;switch(t){case"blob":case"arraybuffer":s="uint8array";break;case"base64":s="string"}try{this._internalType=s,this._outputType=t,this._mimeType=n,r.checkSupport(s),this._worker=e.pipe(new i(s)),e.lock()}catch(e){this._worker=new o("error"),this._worker.error(e)}}u.prototype={accumulate:function(e){return function(e,t){return new l.Promise((function(n,i){var o=[],a=e._internalType,l=e._outputType,c=e._mimeType;e.on("data",(function(e,n){o.push(e),t&&t(n)})).on("error",(function(e){o=[],i(e)})).on("end",(function(){try{var e=function(e,t,n){switch(e){case"blob":return r.newBlob(r.transformTo("arraybuffer",t),n);case"base64":return s.encode(t);default:return r.transformTo(e,t)}}(l,function(e,t){var n,r=0,i=null,o=0;for(n=0;n>>6:(n<65536?t[s++]=224|n>>>12:(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63),t[s++]=128|n>>>6&63),t[s++]=128|63&n);return t}(e)},n.utf8decode=function(e){return i.nodebuffer?r.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,n,i,o,s=e.length,l=new Array(2*s);for(t=n=0;t>10&1023,l[n++]=56320|1023&i)}return l.length!==n&&(l.subarray?l=l.subarray(0,n):l.length=n),r.applyFromCharCode(l)}(e=r.transformTo(i.uint8array?"uint8array":"array",e))},r.inherits(c,s),c.prototype.processChunk=function(e){var t=r.transformTo(i.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var o=t;(t=new Uint8Array(o.length+this.leftOver.length)).set(this.leftOver,0),t.set(o,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var s=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+a[e[n]]>t?n:t}(t),l=t;s!==t.length&&(i.uint8array?(l=t.subarray(0,s),this.leftOver=t.subarray(s,t.length)):(l=t.slice(0,s),this.leftOver=t.slice(s,t.length))),this.push({data:n.utf8decode(l),meta:e.meta})},c.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=c,r.inherits(u,s),u.prototype.processChunk=function(e){this.push({data:n.utf8encode(e.data),meta:e.meta})},n.Utf8EncodeWorker=u},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,n){"use strict";var r=e("./support"),i=e("./base64"),o=e("./nodejsUtils"),s=e("./external");function a(e){return e}function l(e,t){for(var n=0;n>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(e){if(this.extraFields[1]){var t=r(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=t.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=t.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=t.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=t.readInt(4))}},readExtraFields:function(e){var t,n,r,i=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4>>6:(n<65536?t[s++]=224|n>>>12:(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63),t[s++]=128|n>>>6&63),t[s++]=128|63&n);return t},n.buf2binstring=function(e){return l(e,e.length)},n.binstring2buf=function(e){for(var t=new r.Buf8(e.length),n=0,i=t.length;n>10&1023,c[r++]=56320|1023&i)}return l(c,r)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+s[e[n]]>t?n:t}},{"./common":41}],43:[function(e,t,n){"use strict";t.exports=function(e,t,n,r){for(var i=65535&e|0,o=e>>>16&65535|0,s=0;0!==n;){for(n-=s=2e3>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,i){var o=r,s=i+n;e^=-1;for(var a=i;a>>8^o[255&(e^t[a])];return-1^e}},{}],46:[function(e,t,n){"use strict";var r,i=e("../utils/common"),o=e("./trees"),s=e("./adler32"),a=e("./crc32"),l=e("./messages"),c=-2,u=258,d=262,h=113;function f(e,t){return e.msg=l[t],t}function p(e){return(e<<1)-(4e.avail_out&&(n=e.avail_out),0!==n&&(i.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))}function g(e,t){o._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,m(e.strm)}function v(e,t){e.pending_buf[e.pending++]=t}function b(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function y(e,t){var n,r,i=e.max_chain_length,o=e.strstart,s=e.prev_length,a=e.nice_match,l=e.strstart>e.w_size-d?e.strstart-(e.w_size-d):0,c=e.window,h=e.w_mask,f=e.prev,p=e.strstart+u,_=c[o+s-1],m=c[o+s];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(c[(n=t)+s]===m&&c[n+s-1]===_&&c[n]===c[o]&&c[++n]===c[o+1]){o+=2,n++;do{}while(c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&c[++o]===c[++n]&&ol&&0!=--i);return s<=e.lookahead?s:e.lookahead}function w(e){var t,n,r,o,l,c,u,h,f,p,_=e.w_size;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=_+(_-d)){for(i.arraySet(e.window,e.window,_,_,0),e.match_start-=_,e.strstart-=_,e.block_start-=_,t=n=e.hash_size;r=e.head[--t],e.head[t]=_<=r?r-_:0,--n;);for(t=n=_;r=e.prev[--t],e.prev[t]=_<=r?r-_:0,--n;);o+=_}if(0===e.strm.avail_in)break;if(c=e.strm,u=e.window,h=e.strstart+e.lookahead,p=void 0,(f=o)<(p=c.avail_in)&&(p=f),n=0===p?0:(c.avail_in-=p,i.arraySet(u,c.input,c.next_in,p,h),1===c.state.wrap?c.adler=s(c.adler,u,p,h):2===c.state.wrap&&(c.adler=a(c.adler,u,p,h)),c.next_in+=p,c.total_in+=p,p),e.lookahead+=n,e.lookahead+e.insert>=3)for(l=e.strstart-e.insert,e.ins_h=e.window[l],e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<=3)if(r=o._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<=3&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-3,r=o._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(w(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((0===e.strstart||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,g(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-d&&(g(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(g(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(g(e,!1),e.strm.avail_out),1)})),new E(4,4,8,4,C),new E(4,5,16,8,C),new E(4,6,32,32,C),new E(4,4,16,16,x),new E(8,16,32,32,x),new E(8,16,128,128,x),new E(8,32,128,256,x),new E(32,128,258,1024,x),new E(32,258,258,4096,x)],n.deflateInit=function(e,t){return T(e,t,8,15,8,0)},n.deflateInit2=T,n.deflateReset=A,n.deflateResetKeep=k,n.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?c:(e.state.gzhead=t,0):c},n.deflate=function(e,t){var n,i,s,l;if(!e||!e.state||5>8&255),v(i,i.gzhead.time>>16&255),v(i,i.gzhead.time>>24&255),v(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),v(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(v(i,255&i.gzhead.extra.length),v(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=a(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(v(i,0),v(i,0),v(i,0),v(i,0),v(i,0),v(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),v(i,3),i.status=h);else{var d=8+(i.w_bits-8<<4)<<8;d|=(2<=i.strategy||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(d|=32),d+=31-d%31,i.status=h,b(i,d),0!==i.strstart&&(b(i,e.adler>>>16),b(i,65535&e.adler)),e.adler=1}if(69===i.status)if(i.gzhead.extra){for(s=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),m(e),s=i.pending,i.pending!==i.pending_buf_size));)v(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){s=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),m(e),s=i.pending,i.pending===i.pending_buf_size)){l=1;break}l=i.gzindexs&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),0===l&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){s=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>s&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),m(e),s=i.pending,i.pending===i.pending_buf_size)){l=1;break}l=i.gzindexs&&(e.adler=a(e.adler,i.pending_buf,i.pending-s,s)),0===l&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&m(e),i.pending+2<=i.pending_buf_size&&(v(i,255&e.adler),v(i,e.adler>>8&255),e.adler=0,i.status=h)):i.status=h),0!==i.pending){if(m(e),0===e.avail_out)return i.last_flush=-1,0}else if(0===e.avail_in&&p(t)<=p(n)&&4!==t)return f(e,-5);if(666===i.status&&0!==e.avail_in)return f(e,-5);if(0!==e.avail_in||0!==i.lookahead||0!==t&&666!==i.status){var y=2===i.strategy?function(e,t){for(var n;;){if(0===e.lookahead&&(w(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(g(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(g(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(g(e,!1),0===e.strm.avail_out)?1:2}(i,t):3===i.strategy?function(e,t){for(var n,r,i,s,a=e.window;;){if(e.lookahead<=u){if(w(e),e.lookahead<=u&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&0e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=o._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=o._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(g(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(g(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(g(e,!1),0===e.strm.avail_out)?1:2}(i,t):r[i.level].func(i,t);if(3!==y&&4!==y||(i.status=666),1===y||3===y)return 0===e.avail_out&&(i.last_flush=-1),0;if(2===y&&(1===t?o._tr_align(i):5!==t&&(o._tr_stored_block(i,0,0,!1),3===t&&(_(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),m(e),0===e.avail_out))return i.last_flush=-1,0}return 4!==t?0:i.wrap<=0?1:(2===i.wrap?(v(i,255&e.adler),v(i,e.adler>>8&255),v(i,e.adler>>16&255),v(i,e.adler>>24&255),v(i,255&e.total_in),v(i,e.total_in>>8&255),v(i,e.total_in>>16&255),v(i,e.total_in>>24&255)):(b(i,e.adler>>>16),b(i,65535&e.adler)),m(e),0=n.w_size&&(0===a&&(_(n.head),n.strstart=0,n.block_start=0,n.insert=0),h=new i.Buf8(n.w_size),i.arraySet(h,t,f-n.w_size,n.w_size,0),t=h,f=n.w_size),l=e.avail_in,u=e.next_in,d=e.input,e.avail_in=f,e.next_in=0,e.input=t,w(n);n.lookahead>=3;){for(r=n.strstart,o=n.lookahead-2;n.ins_h=(n.ins_h<>>=y=b>>>24,p-=y,0==(y=b>>>16&255))k[o++]=65535&b;else{if(!(16&y)){if(0==(64&y)){b=_[(65535&b)+(f&(1<>>=y,p-=y),p<15&&(f+=S[r++]<>>=y=b>>>24,p-=y,!(16&(y=b>>>16&255))){if(0==(64&y)){b=m[(65535&b)+(f&(1<>>=y,p-=y,(y=o-s)>3,f&=(1<<(p-=w<<3))-1,e.next_in=r,e.next_out=o,e.avail_in=r>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function u(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function d(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new r.Buf32(852),t.distcode=t.distdyn=new r.Buf32(592),t.sane=1,t.back=-1,0):l}function h(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,d(e)):l}function f(e,t){var n,r;return e&&e.state?(r=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15=s.wsize?(r.arraySet(s.window,t,n-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(i<(o=s.wsize-s.wnext)&&(o=i),r.arraySet(s.window,t,n-i,o,s.wnext),(i-=o)?(r.arraySet(s.window,t,n-i,i,0),s.wnext=i,s.whave=s.wsize):(s.wnext+=o,s.wnext===s.wsize&&(s.wnext=0),s.whave>>8&255,n.check=o(n.check,I,2,0),g=m=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&m)<<8)+(m>>8))%31){e.msg="incorrect header check",n.mode=30;break}if(8!=(15&m)){e.msg="unknown compression method",n.mode=30;break}if(g-=4,R=8+(15&(m>>>=4)),0===n.wbits)n.wbits=R;else if(R>n.wbits){e.msg="invalid window size",n.mode=30;break}n.dmax=1<>8&1),512&n.flags&&(I[0]=255&m,I[1]=m>>>8&255,n.check=o(n.check,I,2,0)),g=m=0,n.mode=3;case 3:for(;g<32;){if(0===p)break e;p--,m+=u[h++]<>>8&255,I[2]=m>>>16&255,I[3]=m>>>24&255,n.check=o(n.check,I,4,0)),g=m=0,n.mode=4;case 4:for(;g<16;){if(0===p)break e;p--,m+=u[h++]<>8),512&n.flags&&(I[0]=255&m,I[1]=m>>>8&255,n.check=o(n.check,I,2,0)),g=m=0,n.mode=5;case 5:if(1024&n.flags){for(;g<16;){if(0===p)break e;p--,m+=u[h++]<>>8&255,n.check=o(n.check,I,2,0)),g=m=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&(p<(C=n.length)&&(C=p),C&&(n.head&&(R=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),r.arraySet(n.head.extra,u,h,C,R)),512&n.flags&&(n.check=o(n.check,u,C,h)),p-=C,h+=C,n.length-=C),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===p)break e;for(C=0;R=u[h+C++],n.head&&R&&n.length<65536&&(n.head.name+=String.fromCharCode(R)),R&&C>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;g<32;){if(0===p)break e;p--,m+=u[h++]<>>=7&g,g-=7&g,n.mode=27;break}for(;g<3;){if(0===p)break e;p--,m+=u[h++]<>>=1)){case 0:n.mode=14;break;case 1:if(v(n),n.mode=20,6!==t)break;m>>>=2,g-=2;break e;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=30}m>>>=2,g-=2;break;case 14:for(m>>>=7&g,g-=7&g;g<32;){if(0===p)break e;p--,m+=u[h++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&m,g=m=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(C=n.length){if(p>>=5,g-=5,n.ndist=1+(31&m),m>>>=5,g-=5,n.ncode=4+(15&m),m>>>=4,g-=4,286>>=3,g-=3}for(;n.have<19;)n.lens[B[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,O={bits:n.lenbits},P=a(0,n.lens,0,19,n.lencode,0,n.work,O),n.lenbits=O.bits,P){e.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have>>16&255,A=65535&z,!((S=z>>>24)<=g);){if(0===p)break e;p--,m+=u[h++]<>>=S,g-=S,n.lens[n.have++]=A;else{if(16===A){for(W=S+2;g>>=S,g-=S,0===n.have){e.msg="invalid bit length repeat",n.mode=30;break}R=n.lens[n.have-1],C=3+(3&m),m>>>=2,g-=2}else if(17===A){for(W=S+3;g>>=S)),m>>>=3,g-=3}else{for(W=S+7;g>>=S)),m>>>=7,g-=7}if(n.have+C>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=30;break}for(;C--;)n.lens[n.have++]=R}}if(30===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,O={bits:n.lenbits},P=a(1,n.lens,0,n.nlen,n.lencode,0,n.work,O),n.lenbits=O.bits,P){e.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,O={bits:n.distbits},P=a(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,O),n.distbits=O.bits,P){e.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(6<=p&&258<=_){e.next_out=f,e.avail_out=_,e.next_in=h,e.avail_in=p,n.hold=m,n.bits=g,s(e,w),f=e.next_out,d=e.output,_=e.avail_out,h=e.next_in,u=e.input,p=e.avail_in,m=n.hold,g=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;k=(z=n.lencode[m&(1<>>16&255,A=65535&z,!((S=z>>>24)<=g);){if(0===p)break e;p--,m+=u[h++]<>T)])>>>16&255,A=65535&z,!(T+(S=z>>>24)<=g);){if(0===p)break e;p--,m+=u[h++]<>>=T,g-=T,n.back+=T}if(m>>>=S,g-=S,n.back+=S,n.length=A,0===k){n.mode=26;break}if(32&k){n.back=-1,n.mode=12;break}if(64&k){e.msg="invalid literal/length code",n.mode=30;break}n.extra=15&k,n.mode=22;case 22:if(n.extra){for(W=n.extra;g>>=n.extra,g-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;k=(z=n.distcode[m&(1<>>16&255,A=65535&z,!((S=z>>>24)<=g);){if(0===p)break e;p--,m+=u[h++]<>T)])>>>16&255,A=65535&z,!(T+(S=z>>>24)<=g);){if(0===p)break e;p--,m+=u[h++]<>>=T,g-=T,n.back+=T}if(m>>>=S,g-=S,n.back+=S,64&k){e.msg="invalid distance code",n.mode=30;break}n.offset=A,n.extra=15&k,n.mode=24;case 24:if(n.extra){for(W=n.extra;g>>=n.extra,g-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===_)break e;if(C=w-_,n.offset>C){if((C=n.offset-C)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=30;break}x=C>n.wnext?(C-=n.wnext,n.wsize-C):n.wnext-C,C>n.length&&(C=n.length),E=n.window}else E=d,x=f-n.offset,C=n.length;for(_v?(y=B[M+d[E]],O[W+d[E]]):(y=96,0),f=1<>N)+(p-=f)]=b<<24|y<<16|w|0,0!==p;);for(f=1<>=1;if(0!==f?(P&=f-1,P+=f):P=0,E++,0==--z[x]){if(x===k)break;x=t[n+d[E]]}if(A>>7)]}function S(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function k(e,t,n){e.bi_valid>16-n?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<>>=1,n<<=1,0<--t;);return n>>>1}function N(e,t,n){var r,i,o=new Array(16),s=0;for(r=1;r<=l;r++)o[r]=s=s+n[r-1]<<1;for(i=0;i<=t;i++){var a=e[2*i+1];0!==a&&(e[2*i]=T(o[a]++,a))}}function L(e){var t;for(t=0;t>1;1<=n;n--)O(e,o,n);for(i=c;n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],O(e,o,1),r=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=r,o[2*i]=o[2*n]+o[2*r],e.depth[i]=(e.depth[n]>=e.depth[r]?e.depth[n]:e.depth[r])+1,o[2*n+1]=o[2*r+1]=i,e.heap[1]=i++,O(e,o,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,r,i,o,s,a,c=t.dyn_tree,u=t.max_code,d=t.stat_desc.static_tree,h=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,_=t.stat_desc.max_length,m=0;for(o=0;o<=l;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n<573;n++)_<(o=c[2*c[2*(r=e.heap[n])+1]+1]+1)&&(o=_,m++),c[2*r+1]=o,u>=7;r>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t>>3,(s=e.static_len+3+7>>>3)<=i&&(i=s)):i=s=n+5,n+4<=i&&-1!==t?U(e,t,n,r):4===e.strategy||s===i?(k(e,2+(r?1:0),3),W(e,f,p)):(k(e,4+(r?1:0),3),function(e,t,n,r){var i;for(k(e,t-257,5),k(e,n-1,5),k(e,r-4,4),i=0;i>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(m[n]+o+1)]++,e.dyn_dtree[2*E(t)]++),e.last_lit===e.lit_bufsize-1},n._tr_align=function(e){k(e,2,3),A(e,256,f),function(e){16===e.bi_valid?(S(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":41}],53:[function(e,t,n){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,r){(function(e){!function(e,t){"use strict";if(!e.setImmediate){var n,r,i,o,s=1,a={},l=!1,c=e.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(e);u=u&&u.setTimeout?u:e,n="[object process]"==={}.toString.call(e.process)?function(e){process.nextTick((function(){h(e)}))}:function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?(o="setImmediate$"+Math.random()+"$",e.addEventListener?e.addEventListener("message",f,!1):e.attachEvent("onmessage",f),function(t){e.postMessage(o+t,"*")}):e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){h(e.data)},function(e){i.port2.postMessage(e)}):c&&"onreadystatechange"in c.createElement("script")?(r=c.documentElement,function(e){var t=c.createElement("script");t.onreadystatechange=function(){h(e),t.onreadystatechange=null,r.removeChild(t),t=null},r.appendChild(t)}):function(e){setTimeout(h,0,e)},u.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r"']/g,J=RegExp(V.source),$=RegExp(Y.source),X=/<%-([\s\S]+?)%>/g,G=/<%([\s\S]+?)%>/g,Z=/<%=([\s\S]+?)%>/g,K=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Q=/^\w*$/,ee=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,te=/[\\^$.*+?()[\]{}|]/g,ne=RegExp(te.source),re=/^\s+/,ie=/\s/,oe=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,se=/\{\n\/\* \[wrapped with (.+)\] \*/,ae=/,? & /,le=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ce=/[()=,{}\[\]\/\s]/,ue=/\\(\\)?/g,de=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,he=/\w*$/,fe=/^[-+]0x[0-9a-f]+$/i,pe=/^0b[01]+$/i,_e=/^\[object .+?Constructor\]$/,me=/^0o[0-7]+$/i,ge=/^(?:0|[1-9]\d*)$/,ve=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,be=/($^)/,ye=/['\n\r\u2028\u2029\\]/g,we="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ce="a-z\\xdf-\\xf6\\xf8-\\xff",xe="A-Z\\xc0-\\xd6\\xd8-\\xde",Ee="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Se="["+Ee+"]",ke="["+we+"]",Ae="\\d+",Te="["+Ce+"]",Ne="[^\\ud800-\\udfff"+Ee+Ae+"\\u2700-\\u27bf"+Ce+xe+"]",Le="\\ud83c[\\udffb-\\udfff]",Re="[^\\ud800-\\udfff]",Pe="(?:\\ud83c[\\udde6-\\uddff]){2}",Oe="[\\ud800-\\udbff][\\udc00-\\udfff]",We="["+xe+"]",ze="(?:"+Te+"|"+Ne+")",Ie="(?:"+We+"|"+Ne+")",Be="(?:['’](?:d|ll|m|re|s|t|ve))?",Me="(?:['’](?:D|LL|M|RE|S|T|VE))?",Ue="(?:"+ke+"|"+Le+")?",De="[\\ufe0e\\ufe0f]?",Fe=De+Ue+"(?:\\u200d(?:"+[Re,Pe,Oe].join("|")+")"+De+Ue+")*",qe="(?:"+["[\\u2700-\\u27bf]",Pe,Oe].join("|")+")"+Fe,He="(?:"+[Re+ke+"?",ke,Pe,Oe,"[\\ud800-\\udfff]"].join("|")+")",je=RegExp("['’]","g"),Ve=RegExp(ke,"g"),Ye=RegExp(Le+"(?="+Le+")|"+He+Fe,"g"),Je=RegExp([We+"?"+Te+"+"+Be+"(?="+[Se,We,"$"].join("|")+")",Ie+"+"+Me+"(?="+[Se,We+ze,"$"].join("|")+")",We+"?"+ze+"+"+Be,We+"+"+Me,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ae,qe].join("|"),"g"),$e=RegExp("[\\u200d\\ud800-\\udfff"+we+"\\ufe0e\\ufe0f]"),Xe=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Ge=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Ze=-1,Ke={};Ke[O]=Ke[W]=Ke[z]=Ke[I]=Ke[B]=Ke[M]=Ke[U]=Ke[D]=Ke[F]=!0,Ke[_]=Ke[m]=Ke[R]=Ke[g]=Ke[P]=Ke[v]=Ke[b]=Ke[y]=Ke[C]=Ke[x]=Ke[E]=Ke[k]=Ke[A]=Ke[T]=Ke[L]=!1;var Qe={};Qe[_]=Qe[m]=Qe[R]=Qe[P]=Qe[g]=Qe[v]=Qe[O]=Qe[W]=Qe[z]=Qe[I]=Qe[B]=Qe[C]=Qe[x]=Qe[E]=Qe[k]=Qe[A]=Qe[T]=Qe[N]=Qe[M]=Qe[U]=Qe[D]=Qe[F]=!0,Qe[b]=Qe[y]=Qe[L]=!1;var et={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},tt=parseFloat,nt=parseInt,rt="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,it="object"==typeof self&&self&&self.Object===Object&&self,ot=rt||it||Function("return this")(),st=t&&!t.nodeType&&t,at=st&&e&&!e.nodeType&&e,lt=at&&at.exports===st,ct=lt&&rt.process,ut=function(){try{return at&&at.require&&at.require("util").types||ct&&ct.binding&&ct.binding("util")}catch(e){}}(),dt=ut&&ut.isArrayBuffer,ht=ut&&ut.isDate,ft=ut&&ut.isMap,pt=ut&&ut.isRegExp,_t=ut&&ut.isSet,mt=ut&&ut.isTypedArray;function gt(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function vt(e,t,n,r){for(var i=-1,o=null==e?0:e.length;++i-1}function Et(e,t,n){for(var r=-1,i=null==e?0:e.length;++r-1;);return n}function Jt(e,t){for(var n=e.length;n--&&Ot(t,e[n],0)>-1;);return n}function $t(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}var Xt=Mt({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"}),Gt=Mt({"&":"&","<":"<",">":">",'"':""","'":"'"});function Zt(e){return"\\"+et[e]}function Kt(e){return $e.test(e)}function Qt(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function en(e,t){return function(n){return e(t(n))}}function tn(e,t){for(var n=-1,r=e.length,i=0,o=[];++n",""":'"',"'":"'"}),cn=function e(t){var n,r=(t=null==t?ot:cn.defaults(ot.Object(),t,cn.pick(ot,Ge))).Array,ie=t.Date,we=t.Error,Ce=t.Function,xe=t.Math,Ee=t.Object,Se=t.RegExp,ke=t.String,Ae=t.TypeError,Te=r.prototype,Ne=Ce.prototype,Le=Ee.prototype,Re=t["__core-js_shared__"],Pe=Ne.toString,Oe=Le.hasOwnProperty,We=0,ze=(n=/[^.]+$/.exec(Re&&Re.keys&&Re.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",Ie=Le.toString,Be=Pe.call(Ee),Me=ot._,Ue=Se("^"+Pe.call(Oe).replace(te,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),De=lt?t.Buffer:i,Fe=t.Symbol,qe=t.Uint8Array,He=De?De.allocUnsafe:i,Ye=en(Ee.getPrototypeOf,Ee),$e=Ee.create,et=Le.propertyIsEnumerable,rt=Te.splice,it=Fe?Fe.isConcatSpreadable:i,st=Fe?Fe.iterator:i,at=Fe?Fe.toStringTag:i,ct=function(){try{var e=co(Ee,"defineProperty");return e({},"",{}),e}catch(e){}}(),ut=t.clearTimeout!==ot.clearTimeout&&t.clearTimeout,Lt=ie&&ie.now!==ot.Date.now&&ie.now,Mt=t.setTimeout!==ot.setTimeout&&t.setTimeout,un=xe.ceil,dn=xe.floor,hn=Ee.getOwnPropertySymbols,fn=De?De.isBuffer:i,pn=t.isFinite,_n=Te.join,mn=en(Ee.keys,Ee),gn=xe.max,vn=xe.min,bn=ie.now,yn=t.parseInt,wn=xe.random,Cn=Te.reverse,xn=co(t,"DataView"),En=co(t,"Map"),Sn=co(t,"Promise"),kn=co(t,"Set"),An=co(t,"WeakMap"),Tn=co(Ee,"create"),Nn=An&&new An,Ln={},Rn=Uo(xn),Pn=Uo(En),On=Uo(Sn),Wn=Uo(kn),zn=Uo(An),In=Fe?Fe.prototype:i,Bn=In?In.valueOf:i,Mn=In?In.toString:i;function Un(e){if(na(e)&&!Vs(e)&&!(e instanceof Hn)){if(e instanceof qn)return e;if(Oe.call(e,"__wrapped__"))return Do(e)}return new qn(e)}var Dn=function(){function e(){}return function(t){if(!ta(t))return{};if($e)return $e(t);e.prototype=t;var n=new e;return e.prototype=i,n}}();function Fn(){}function qn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=i}function Hn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=f,this.__views__=[]}function jn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function ar(e,t,n,r,o,s){var a,l=1&t,c=2&t,u=4&t;if(n&&(a=o?n(e,r,o,s):n(e)),a!==i)return a;if(!ta(e))return e;var d=Vs(e);if(d){if(a=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&Oe.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e),!l)return Ai(e,a)}else{var h=fo(e),f=h==y||h==w;if(Xs(e))return wi(e,l);if(h==E||h==_||f&&!o){if(a=c||f?{}:_o(e),!l)return c?function(e,t){return Ti(e,ho(e),t)}(e,function(e,t){return e&&Ti(t,Oa(t),e)}(a,e)):function(e,t){return Ti(e,uo(e),t)}(e,rr(a,e))}else{if(!Qe[h])return o?e:{};a=function(e,t,n){var r,i=e.constructor;switch(t){case R:return Ci(e);case g:case v:return new i(+e);case P:return function(e,t){var n=t?Ci(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case O:case W:case z:case I:case B:case M:case U:case D:case F:return xi(e,n);case C:return new i;case x:case T:return new i(e);case k:return function(e){var t=new e.constructor(e.source,he.exec(e));return t.lastIndex=e.lastIndex,t}(e);case A:return new i;case N:return r=e,Bn?Ee(Bn.call(r)):{}}}(e,h,l)}}s||(s=new $n);var p=s.get(e);if(p)return p;s.set(e,a),aa(e)?e.forEach((function(r){a.add(ar(r,t,n,r,e,s))})):ra(e)&&e.forEach((function(r,i){a.set(i,ar(r,t,n,i,e,s))}));var m=d?i:(u?c?no:to:c?Oa:Pa)(e);return bt(m||e,(function(r,i){m&&(r=e[i=r]),er(a,i,ar(r,t,n,i,e,s))})),a}function lr(e,t,n){var r=n.length;if(null==e)return!r;for(e=Ee(e);r--;){var o=n[r],s=t[o],a=e[o];if(a===i&&!(o in e)||!s(a))return!1}return!0}function cr(e,t,n){if("function"!=typeof e)throw new Ae(o);return Lo((function(){e.apply(i,n)}),t)}function ur(e,t,n,r){var i=-1,o=xt,s=!0,a=e.length,l=[],c=t.length;if(!a)return l;n&&(t=St(t,Ht(n))),r?(o=Et,s=!1):t.length>=200&&(o=Vt,s=!1,t=new Jn(t));e:for(;++i-1},Vn.prototype.set=function(e,t){var n=this.__data__,r=tr(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},Yn.prototype.clear=function(){this.size=0,this.__data__={hash:new jn,map:new(En||Vn),string:new jn}},Yn.prototype.delete=function(e){var t=ao(this,e).delete(e);return this.size-=t?1:0,t},Yn.prototype.get=function(e){return ao(this,e).get(e)},Yn.prototype.has=function(e){return ao(this,e).has(e)},Yn.prototype.set=function(e,t){var n=ao(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},Jn.prototype.add=Jn.prototype.push=function(e){return this.__data__.set(e,s),this},Jn.prototype.has=function(e){return this.__data__.has(e)},$n.prototype.clear=function(){this.__data__=new Vn,this.size=0},$n.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},$n.prototype.get=function(e){return this.__data__.get(e)},$n.prototype.has=function(e){return this.__data__.has(e)},$n.prototype.set=function(e,t){var n=this.__data__;if(n instanceof Vn){var r=n.__data__;if(!En||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Yn(r)}return n.set(e,t),this.size=n.size,this};var dr=Ri(br),hr=Ri(yr,!0);function fr(e,t){var n=!0;return dr(e,(function(e,r,i){return n=!!t(e,r,i)})),n}function pr(e,t,n){for(var r=-1,o=e.length;++r0&&n(a)?t>1?mr(a,t-1,n,r,i):kt(i,a):r||(i[i.length]=a)}return i}var gr=Pi(),vr=Pi(!0);function br(e,t){return e&&gr(e,t,Pa)}function yr(e,t){return e&&vr(e,t,Pa)}function wr(e,t){return Ct(t,(function(t){return Ks(e[t])}))}function Cr(e,t){for(var n=0,r=(t=gi(t,e)).length;null!=e&&nt}function kr(e,t){return null!=e&&Oe.call(e,t)}function Ar(e,t){return null!=e&&t in Ee(e)}function Tr(e,t,n){for(var o=n?Et:xt,s=e[0].length,a=e.length,l=a,c=r(a),u=1/0,d=[];l--;){var h=e[l];l&&t&&(h=St(h,Ht(t))),u=vn(h.length,u),c[l]=!n&&(t||s>=120&&h.length>=120)?new Jn(l&&h):i}h=e[0];var f=-1,p=c[0];e:for(;++f=a?l:l*("desc"==n[r]?-1:1)}return e.index-t.index}(e,t,n)}));r--;)e[r]=e[r].value;return e}(i)}function Hr(e,t,n){for(var r=-1,i=t.length,o={};++r-1;)a!==e&&rt.call(a,l,1),rt.call(e,l,1);return e}function Vr(e,t){for(var n=e?t.length:0,r=n-1;n--;){var i=t[n];if(n==r||i!==o){var o=i;go(i)?rt.call(e,i,1):ci(e,i)}}return e}function Yr(e,t){return e+dn(wn()*(t-e+1))}function Jr(e,t){var n="";if(!e||t<1||t>d)return n;do{t%2&&(n+=e),(t=dn(t/2))&&(e+=e)}while(t);return n}function $r(e,t){return Ro(So(e,t,il),e+"")}function Xr(e){return Gn(Fa(e))}function Gr(e,t){var n=Fa(e);return Wo(n,sr(t,0,n.length))}function Zr(e,t,n,r){if(!ta(e))return e;for(var o=-1,s=(t=gi(t,e)).length,a=s-1,l=e;null!=l&&++oo?0:o+t),(n=n>o?o:n)<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var s=r(o);++i>>1,s=e[o];null!==s&&!ca(s)&&(n?s<=t:s=200){var c=t?null:Ji(e);if(c)return nn(c);s=!1,i=Vt,l=new Jn}else l=t?[]:a;e:for(;++r=r?e:ti(e,t,n)}var yi=ut||function(e){return ot.clearTimeout(e)};function wi(e,t){if(t)return e.slice();var n=e.length,r=He?He(n):new e.constructor(n);return e.copy(r),r}function Ci(e){var t=new e.constructor(e.byteLength);return new qe(t).set(new qe(e)),t}function xi(e,t){var n=t?Ci(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Ei(e,t){if(e!==t){var n=e!==i,r=null===e,o=e==e,s=ca(e),a=t!==i,l=null===t,c=t==t,u=ca(t);if(!l&&!u&&!s&&e>t||s&&a&&c&&!l&&!u||r&&a&&c||!n&&c||!o)return 1;if(!r&&!s&&!u&&e1?n[o-1]:i,a=o>2?n[2]:i;for(s=e.length>3&&"function"==typeof s?(o--,s):i,a&&vo(n[0],n[1],a)&&(s=o<3?i:s,o=1),t=Ee(t);++r-1?o[s?t[a]:a]:i}}function Bi(e){return eo((function(t){var n=t.length,r=n,s=qn.prototype.thru;for(e&&t.reverse();r--;){var a=t[r];if("function"!=typeof a)throw new Ae(o);if(s&&!l&&"wrapper"==io(a))var l=new qn([],!0)}for(r=l?r:n;++r1&&b.reverse(),f&&dl))return!1;var u=s.get(e),d=s.get(t);if(u&&d)return u==t&&d==e;var h=-1,f=!0,p=2&n?new Jn:i;for(s.set(e,t),s.set(t,e);++h-1&&e%1==0&&e1?"& ":"")+t[r],t=t.join(n>2?", ":" "),e.replace(oe,"{\n/* [wrapped with "+t+"] */\n")}(r,function(e,t){return bt(p,(function(n){var r="_."+n[0];t&n[1]&&!xt(e,r)&&e.push(r)})),e.sort()}(function(e){var t=e.match(se);return t?t[1].split(ae):[]}(r),n)))}function Oo(e){var t=0,n=0;return function(){var r=bn(),o=16-(r-n);if(n=r,o>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(i,arguments)}}function Wo(e,t){var n=-1,r=e.length,o=r-1;for(t=t===i?r:t;++n1?e[t-1]:i;return n="function"==typeof n?(e.pop(),n):i,ss(e,n)}));function fs(e){var t=Un(e);return t.__chain__=!0,t}function ps(e,t){return t(e)}var _s=eo((function(e){var t=e.length,n=t?e[0]:0,r=this.__wrapped__,o=function(t){return or(t,e)};return!(t>1||this.__actions__.length)&&r instanceof Hn&&go(n)?((r=r.slice(n,+n+(t?1:0))).__actions__.push({func:ps,args:[o],thisArg:i}),new qn(r,this.__chain__).thru((function(e){return t&&!e.length&&e.push(i),e}))):this.thru(o)})),ms=Ni((function(e,t,n){Oe.call(e,n)?++e[n]:ir(e,n,1)})),gs=Ii(jo),vs=Ii(Vo);function bs(e,t){return(Vs(e)?bt:dr)(e,so(t,3))}function ys(e,t){return(Vs(e)?yt:hr)(e,so(t,3))}var ws=Ni((function(e,t,n){Oe.call(e,n)?e[n].push(t):ir(e,n,[t])})),Cs=$r((function(e,t,n){var i=-1,o="function"==typeof t,s=Js(e)?r(e.length):[];return dr(e,(function(e){s[++i]=o?gt(t,e,n):Nr(e,t,n)})),s})),xs=Ni((function(e,t,n){ir(e,n,t)}));function Es(e,t){return(Vs(e)?St:Br)(e,so(t,3))}var Ss=Ni((function(e,t,n){e[n?0:1].push(t)}),(function(){return[[],[]]})),ks=$r((function(e,t){if(null==e)return[];var n=t.length;return n>1&&vo(e,t[0],t[1])?t=[]:n>2&&vo(t[0],t[1],t[2])&&(t=[t[0]]),qr(e,mr(t,1),[])})),As=Lt||function(){return ot.Date.now()};function Ts(e,t,n){return t=n?i:t,t=e&&null==t?e.length:t,Xi(e,c,i,i,i,i,t)}function Ns(e,t){var n;if("function"!=typeof t)throw new Ae(o);return e=_a(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=i),n}}var Ls=$r((function(e,t,n){var r=1;if(n.length){var i=tn(n,oo(Ls));r|=l}return Xi(e,r,t,n,i)})),Rs=$r((function(e,t,n){var r=3;if(n.length){var i=tn(n,oo(Rs));r|=l}return Xi(t,r,e,n,i)}));function Ps(e,t,n){var r,s,a,l,c,u,d=0,h=!1,f=!1,p=!0;if("function"!=typeof e)throw new Ae(o);function _(t){var n=r,o=s;return r=s=i,d=t,l=e.apply(o,n)}function m(e){return d=e,c=Lo(v,t),h?_(e):l}function g(e){var n=e-u;return u===i||n>=t||n<0||f&&e-d>=a}function v(){var e=As();if(g(e))return b(e);c=Lo(v,function(e){var n=t-(e-u);return f?vn(n,a-(e-d)):n}(e))}function b(e){return c=i,p&&r?_(e):(r=s=i,l)}function y(){var e=As(),n=g(e);if(r=arguments,s=this,u=e,n){if(c===i)return m(u);if(f)return yi(c),c=Lo(v,t),_(u)}return c===i&&(c=Lo(v,t)),l}return t=ga(t)||0,ta(n)&&(h=!!n.leading,a=(f="maxWait"in n)?gn(ga(n.maxWait)||0,t):a,p="trailing"in n?!!n.trailing:p),y.cancel=function(){c!==i&&yi(c),d=0,r=u=s=c=i},y.flush=function(){return c===i?l:b(As())},y}var Os=$r((function(e,t){return cr(e,1,t)})),Ws=$r((function(e,t,n){return cr(e,ga(t)||0,n)}));function zs(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Ae(o);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=e.apply(this,r);return n.cache=o.set(i,s)||o,s};return n.cache=new(zs.Cache||Yn),n}function Is(e){if("function"!=typeof e)throw new Ae(o);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}zs.Cache=Yn;var Bs=vi((function(e,t){var n=(t=1==t.length&&Vs(t[0])?St(t[0],Ht(so())):St(mr(t,1),Ht(so()))).length;return $r((function(r){for(var i=-1,o=vn(r.length,n);++i=t})),js=Lr(function(){return arguments}())?Lr:function(e){return na(e)&&Oe.call(e,"callee")&&!et.call(e,"callee")},Vs=r.isArray,Ys=dt?Ht(dt):function(e){return na(e)&&Er(e)==R};function Js(e){return null!=e&&ea(e.length)&&!Ks(e)}function $s(e){return na(e)&&Js(e)}var Xs=fn||gl,Gs=ht?Ht(ht):function(e){return na(e)&&Er(e)==v};function Zs(e){if(!na(e))return!1;var t=Er(e);return t==b||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!oa(e)}function Ks(e){if(!ta(e))return!1;var t=Er(e);return t==y||t==w||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Qs(e){return"number"==typeof e&&e==_a(e)}function ea(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=d}function ta(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function na(e){return null!=e&&"object"==typeof e}var ra=ft?Ht(ft):function(e){return na(e)&&fo(e)==C};function ia(e){return"number"==typeof e||na(e)&&Er(e)==x}function oa(e){if(!na(e)||Er(e)!=E)return!1;var t=Ye(e);if(null===t)return!0;var n=Oe.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Pe.call(n)==Be}var sa=pt?Ht(pt):function(e){return na(e)&&Er(e)==k},aa=_t?Ht(_t):function(e){return na(e)&&fo(e)==A};function la(e){return"string"==typeof e||!Vs(e)&&na(e)&&Er(e)==T}function ca(e){return"symbol"==typeof e||na(e)&&Er(e)==N}var ua=mt?Ht(mt):function(e){return na(e)&&ea(e.length)&&!!Ke[Er(e)]},da=ji(Ir),ha=ji((function(e,t){return e<=t}));function fa(e){if(!e)return[];if(Js(e))return la(e)?sn(e):Ai(e);if(st&&e[st])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[st]());var t=fo(e);return(t==C?Qt:t==A?nn:Fa)(e)}function pa(e){return e?(e=ga(e))===u||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function _a(e){var t=pa(e),n=t%1;return t==t?n?t-n:t:0}function ma(e){return e?sr(_a(e),0,f):0}function ga(e){if("number"==typeof e)return e;if(ca(e))return h;if(ta(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=ta(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=qt(e);var n=pe.test(e);return n||me.test(e)?nt(e.slice(2),n?2:8):fe.test(e)?h:+e}function va(e){return Ti(e,Oa(e))}function ba(e){return null==e?"":ai(e)}var ya=Li((function(e,t){if(Co(t)||Js(t))Ti(t,Pa(t),e);else for(var n in t)Oe.call(t,n)&&er(e,n,t[n])})),wa=Li((function(e,t){Ti(t,Oa(t),e)})),Ca=Li((function(e,t,n,r){Ti(t,Oa(t),e,r)})),xa=Li((function(e,t,n,r){Ti(t,Pa(t),e,r)})),Ea=eo(or),Sa=$r((function(e,t){e=Ee(e);var n=-1,r=t.length,o=r>2?t[2]:i;for(o&&vo(t[0],t[1],o)&&(r=1);++n1),t})),Ti(e,no(e),n),r&&(n=ar(n,7,Ki));for(var i=t.length;i--;)ci(n,t[i]);return n})),Ba=eo((function(e,t){return null==e?{}:function(e,t){return Hr(e,t,(function(t,n){return Ta(e,n)}))}(e,t)}));function Ma(e,t){if(null==e)return{};var n=St(no(e),(function(e){return[e]}));return t=so(t),Hr(e,n,(function(e,n){return t(e,n[0])}))}var Ua=$i(Pa),Da=$i(Oa);function Fa(e){return null==e?[]:jt(e,Pa(e))}var qa=Wi((function(e,t,n){return t=t.toLowerCase(),e+(n?Ha(t):t)}));function Ha(e){return Za(ba(e).toLowerCase())}function ja(e){return(e=ba(e))&&e.replace(ve,Xt).replace(Ve,"")}var Va=Wi((function(e,t,n){return e+(n?"-":"")+t.toLowerCase()})),Ya=Wi((function(e,t,n){return e+(n?" ":"")+t.toLowerCase()})),Ja=Oi("toLowerCase"),$a=Wi((function(e,t,n){return e+(n?"_":"")+t.toLowerCase()})),Xa=Wi((function(e,t,n){return e+(n?" ":"")+Za(t)})),Ga=Wi((function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})),Za=Oi("toUpperCase");function Ka(e,t,n){return e=ba(e),(t=n?i:t)===i?function(e){return Xe.test(e)}(e)?function(e){return e.match(Je)||[]}(e):function(e){return e.match(le)||[]}(e):e.match(t)||[]}var Qa=$r((function(e,t){try{return gt(e,i,t)}catch(e){return Zs(e)?e:new we(e)}})),el=eo((function(e,t){return bt(t,(function(t){t=Mo(t),ir(e,t,Ls(e[t],e))})),e}));function tl(e){return function(){return e}}var nl=Bi(),rl=Bi(!0);function il(e){return e}function ol(e){return Wr("function"==typeof e?e:ar(e,1))}var sl=$r((function(e,t){return function(n){return Nr(n,e,t)}})),al=$r((function(e,t){return function(n){return Nr(e,n,t)}}));function ll(e,t,n){var r=Pa(t),i=wr(t,r);null!=n||ta(t)&&(i.length||!r.length)||(n=t,t=e,e=this,i=wr(t,Pa(t)));var o=!(ta(n)&&"chain"in n&&!n.chain),s=Ks(e);return bt(i,(function(n){var r=t[n];e[n]=r,s&&(e.prototype[n]=function(){var t=this.__chain__;if(o||t){var n=e(this.__wrapped__),i=n.__actions__=Ai(this.__actions__);return i.push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,kt([this.value()],arguments))})})),e}function cl(){}var ul=Fi(St),dl=Fi(wt),hl=Fi(Nt);function fl(e){return bo(e)?Bt(Mo(e)):function(e){return function(t){return Cr(t,e)}}(e)}var pl=Hi(),_l=Hi(!0);function ml(){return[]}function gl(){return!1}var vl,bl=Di((function(e,t){return e+t}),0),yl=Yi("ceil"),wl=Di((function(e,t){return e/t}),1),Cl=Yi("floor"),xl=Di((function(e,t){return e*t}),1),El=Yi("round"),Sl=Di((function(e,t){return e-t}),0);return Un.after=function(e,t){if("function"!=typeof t)throw new Ae(o);return e=_a(e),function(){if(--e<1)return t.apply(this,arguments)}},Un.ary=Ts,Un.assign=ya,Un.assignIn=wa,Un.assignInWith=Ca,Un.assignWith=xa,Un.at=Ea,Un.before=Ns,Un.bind=Ls,Un.bindAll=el,Un.bindKey=Rs,Un.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Vs(e)?e:[e]},Un.chain=fs,Un.chunk=function(e,t,n){t=(n?vo(e,t,n):t===i)?1:gn(_a(t),0);var o=null==e?0:e.length;if(!o||t<1)return[];for(var s=0,a=0,l=r(un(o/t));so?0:o+n),(r=r===i||r>o?o:_a(r))<0&&(r+=o),r=n>r?0:ma(r);n>>0)?(e=ba(e))&&("string"==typeof t||null!=t&&!sa(t))&&!(t=ai(t))&&Kt(e)?bi(sn(e),0,n):e.split(t,n):[]},Un.spread=function(e,t){if("function"!=typeof e)throw new Ae(o);return t=null==t?0:gn(_a(t),0),$r((function(n){var r=n[t],i=bi(n,0,t);return r&&kt(i,r),gt(e,this,i)}))},Un.tail=function(e){var t=null==e?0:e.length;return t?ti(e,1,t):[]},Un.take=function(e,t,n){return e&&e.length?ti(e,0,(t=n||t===i?1:_a(t))<0?0:t):[]},Un.takeRight=function(e,t,n){var r=null==e?0:e.length;return r?ti(e,(t=r-(t=n||t===i?1:_a(t)))<0?0:t,r):[]},Un.takeRightWhile=function(e,t){return e&&e.length?di(e,so(t,3),!1,!0):[]},Un.takeWhile=function(e,t){return e&&e.length?di(e,so(t,3)):[]},Un.tap=function(e,t){return t(e),e},Un.throttle=function(e,t,n){var r=!0,i=!0;if("function"!=typeof e)throw new Ae(o);return ta(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),Ps(e,t,{leading:r,maxWait:t,trailing:i})},Un.thru=ps,Un.toArray=fa,Un.toPairs=Ua,Un.toPairsIn=Da,Un.toPath=function(e){return Vs(e)?St(e,Mo):ca(e)?[e]:Ai(Bo(ba(e)))},Un.toPlainObject=va,Un.transform=function(e,t,n){var r=Vs(e),i=r||Xs(e)||ua(e);if(t=so(t,4),null==n){var o=e&&e.constructor;n=i?r?new o:[]:ta(e)&&Ks(o)?Dn(Ye(e)):{}}return(i?bt:br)(e,(function(e,r,i){return t(n,e,r,i)})),n},Un.unary=function(e){return Ts(e,1)},Un.union=ns,Un.unionBy=rs,Un.unionWith=is,Un.uniq=function(e){return e&&e.length?li(e):[]},Un.uniqBy=function(e,t){return e&&e.length?li(e,so(t,2)):[]},Un.uniqWith=function(e,t){return t="function"==typeof t?t:i,e&&e.length?li(e,i,t):[]},Un.unset=function(e,t){return null==e||ci(e,t)},Un.unzip=os,Un.unzipWith=ss,Un.update=function(e,t,n){return null==e?e:ui(e,t,mi(n))},Un.updateWith=function(e,t,n,r){return r="function"==typeof r?r:i,null==e?e:ui(e,t,mi(n),r)},Un.values=Fa,Un.valuesIn=function(e){return null==e?[]:jt(e,Oa(e))},Un.without=as,Un.words=Ka,Un.wrap=function(e,t){return Ms(mi(t),e)},Un.xor=ls,Un.xorBy=cs,Un.xorWith=us,Un.zip=ds,Un.zipObject=function(e,t){return pi(e||[],t||[],er)},Un.zipObjectDeep=function(e,t){return pi(e||[],t||[],Zr)},Un.zipWith=hs,Un.entries=Ua,Un.entriesIn=Da,Un.extend=wa,Un.extendWith=Ca,ll(Un,Un),Un.add=bl,Un.attempt=Qa,Un.camelCase=qa,Un.capitalize=Ha,Un.ceil=yl,Un.clamp=function(e,t,n){return n===i&&(n=t,t=i),n!==i&&(n=(n=ga(n))==n?n:0),t!==i&&(t=(t=ga(t))==t?t:0),sr(ga(e),t,n)},Un.clone=function(e){return ar(e,4)},Un.cloneDeep=function(e){return ar(e,5)},Un.cloneDeepWith=function(e,t){return ar(e,5,t="function"==typeof t?t:i)},Un.cloneWith=function(e,t){return ar(e,4,t="function"==typeof t?t:i)},Un.conformsTo=function(e,t){return null==t||lr(e,t,Pa(t))},Un.deburr=ja,Un.defaultTo=function(e,t){return null==e||e!=e?t:e},Un.divide=wl,Un.endsWith=function(e,t,n){e=ba(e),t=ai(t);var r=e.length,o=n=n===i?r:sr(_a(n),0,r);return(n-=t.length)>=0&&e.slice(n,o)==t},Un.eq=Fs,Un.escape=function(e){return(e=ba(e))&&$.test(e)?e.replace(Y,Gt):e},Un.escapeRegExp=function(e){return(e=ba(e))&&ne.test(e)?e.replace(te,"\\$&"):e},Un.every=function(e,t,n){var r=Vs(e)?wt:fr;return n&&vo(e,t,n)&&(t=i),r(e,so(t,3))},Un.find=gs,Un.findIndex=jo,Un.findKey=function(e,t){return Rt(e,so(t,3),br)},Un.findLast=vs,Un.findLastIndex=Vo,Un.findLastKey=function(e,t){return Rt(e,so(t,3),yr)},Un.floor=Cl,Un.forEach=bs,Un.forEachRight=ys,Un.forIn=function(e,t){return null==e?e:gr(e,so(t,3),Oa)},Un.forInRight=function(e,t){return null==e?e:vr(e,so(t,3),Oa)},Un.forOwn=function(e,t){return e&&br(e,so(t,3))},Un.forOwnRight=function(e,t){return e&&yr(e,so(t,3))},Un.get=Aa,Un.gt=qs,Un.gte=Hs,Un.has=function(e,t){return null!=e&&po(e,t,kr)},Un.hasIn=Ta,Un.head=Jo,Un.identity=il,Un.includes=function(e,t,n,r){e=Js(e)?e:Fa(e),n=n&&!r?_a(n):0;var i=e.length;return n<0&&(n=gn(i+n,0)),la(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&Ot(e,t,n)>-1},Un.indexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:_a(n);return i<0&&(i=gn(r+i,0)),Ot(e,t,i)},Un.inRange=function(e,t,n){return t=pa(t),n===i?(n=t,t=0):n=pa(n),function(e,t,n){return e>=vn(t,n)&&e=-9007199254740991&&e<=d},Un.isSet=aa,Un.isString=la,Un.isSymbol=ca,Un.isTypedArray=ua,Un.isUndefined=function(e){return e===i},Un.isWeakMap=function(e){return na(e)&&fo(e)==L},Un.isWeakSet=function(e){return na(e)&&"[object WeakSet]"==Er(e)},Un.join=function(e,t){return null==e?"":_n.call(e,t)},Un.kebabCase=Va,Un.last=Zo,Un.lastIndexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var o=r;return n!==i&&(o=(o=_a(n))<0?gn(r+o,0):vn(o,r-1)),t==t?function(e,t,n){for(var r=n+1;r--;)if(e[r]===t)return r;return r}(e,t,o):Pt(e,zt,o,!0)},Un.lowerCase=Ya,Un.lowerFirst=Ja,Un.lt=da,Un.lte=ha,Un.max=function(e){return e&&e.length?pr(e,il,Sr):i},Un.maxBy=function(e,t){return e&&e.length?pr(e,so(t,2),Sr):i},Un.mean=function(e){return It(e,il)},Un.meanBy=function(e,t){return It(e,so(t,2))},Un.min=function(e){return e&&e.length?pr(e,il,Ir):i},Un.minBy=function(e,t){return e&&e.length?pr(e,so(t,2),Ir):i},Un.stubArray=ml,Un.stubFalse=gl,Un.stubObject=function(){return{}},Un.stubString=function(){return""},Un.stubTrue=function(){return!0},Un.multiply=xl,Un.nth=function(e,t){return e&&e.length?Fr(e,_a(t)):i},Un.noConflict=function(){return ot._===this&&(ot._=Me),this},Un.noop=cl,Un.now=As,Un.pad=function(e,t,n){e=ba(e);var r=(t=_a(t))?on(e):0;if(!t||r>=t)return e;var i=(t-r)/2;return qi(dn(i),n)+e+qi(un(i),n)},Un.padEnd=function(e,t,n){e=ba(e);var r=(t=_a(t))?on(e):0;return t&&rt){var r=e;e=t,t=r}if(n||e%1||t%1){var o=wn();return vn(e+o*(t-e+tt("1e-"+((o+"").length-1))),t)}return Yr(e,t)},Un.reduce=function(e,t,n){var r=Vs(e)?At:Ut,i=arguments.length<3;return r(e,so(t,4),n,i,dr)},Un.reduceRight=function(e,t,n){var r=Vs(e)?Tt:Ut,i=arguments.length<3;return r(e,so(t,4),n,i,hr)},Un.repeat=function(e,t,n){return t=(n?vo(e,t,n):t===i)?1:_a(t),Jr(ba(e),t)},Un.replace=function(){var e=arguments,t=ba(e[0]);return e.length<3?t:t.replace(e[1],e[2])},Un.result=function(e,t,n){var r=-1,o=(t=gi(t,e)).length;for(o||(o=1,e=i);++rd)return[];var n=f,r=vn(e,f);t=so(t),e-=f;for(var i=Ft(r,t);++n=s)return e;var l=n-on(r);if(l<1)return r;var c=a?bi(a,0,l).join(""):e.slice(0,l);if(o===i)return c+r;if(a&&(l+=c.length-l),sa(o)){if(e.slice(l).search(o)){var u,d=c;for(o.global||(o=Se(o.source,ba(he.exec(o))+"g")),o.lastIndex=0;u=o.exec(d);)var h=u.index;c=c.slice(0,h===i?l:h)}}else if(e.indexOf(ai(o),l)!=l){var f=c.lastIndexOf(o);f>-1&&(c=c.slice(0,f))}return c+r},Un.unescape=function(e){return(e=ba(e))&&J.test(e)?e.replace(V,ln):e},Un.uniqueId=function(e){var t=++We;return ba(e)+t},Un.upperCase=Ga,Un.upperFirst=Za,Un.each=bs,Un.eachRight=ys,Un.first=Jo,ll(Un,(vl={},br(Un,(function(e,t){Oe.call(Un.prototype,t)||(vl[t]=e)})),vl),{chain:!1}),Un.VERSION="4.17.21",bt(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){Un[e].placeholder=Un})),bt(["drop","take"],(function(e,t){Hn.prototype[e]=function(n){n=n===i?1:gn(_a(n),0);var r=this.__filtered__&&!t?new Hn(this):this.clone();return r.__filtered__?r.__takeCount__=vn(n,r.__takeCount__):r.__views__.push({size:vn(n,f),type:e+(r.__dir__<0?"Right":"")}),r},Hn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),bt(["filter","map","takeWhile"],(function(e,t){var n=t+1,r=1==n||3==n;Hn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:so(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}})),bt(["head","last"],(function(e,t){var n="take"+(t?"Right":"");Hn.prototype[e]=function(){return this[n](1).value()[0]}})),bt(["initial","tail"],(function(e,t){var n="drop"+(t?"":"Right");Hn.prototype[e]=function(){return this.__filtered__?new Hn(this):this[n](1)}})),Hn.prototype.compact=function(){return this.filter(il)},Hn.prototype.find=function(e){return this.filter(e).head()},Hn.prototype.findLast=function(e){return this.reverse().find(e)},Hn.prototype.invokeMap=$r((function(e,t){return"function"==typeof e?new Hn(this):this.map((function(n){return Nr(n,e,t)}))})),Hn.prototype.reject=function(e){return this.filter(Is(so(e)))},Hn.prototype.slice=function(e,t){e=_a(e);var n=this;return n.__filtered__&&(e>0||t<0)?new Hn(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==i&&(n=(t=_a(t))<0?n.dropRight(-t):n.take(t-e)),n)},Hn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Hn.prototype.toArray=function(){return this.take(f)},br(Hn.prototype,(function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),o=Un[r?"take"+("last"==t?"Right":""):t],s=r||/^find/.test(t);o&&(Un.prototype[t]=function(){var t=this.__wrapped__,a=r?[1]:arguments,l=t instanceof Hn,c=a[0],u=l||Vs(t),d=function(e){var t=o.apply(Un,kt([e],a));return r&&h?t[0]:t};u&&n&&"function"==typeof c&&1!=c.length&&(l=u=!1);var h=this.__chain__,f=!!this.__actions__.length,p=s&&!h,_=l&&!f;if(!s&&u){t=_?t:new Hn(this);var m=e.apply(t,a);return m.__actions__.push({func:ps,args:[d],thisArg:i}),new qn(m,h)}return p&&_?e.apply(this,a):(m=this.thru(d),p?r?m.value()[0]:m.value():m)})})),bt(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Te[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);Un.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply(Vs(i)?i:[],e)}return this[n]((function(n){return t.apply(Vs(n)?n:[],e)}))}})),br(Hn.prototype,(function(e,t){var n=Un[t];if(n){var r=n.name+"";Oe.call(Ln,r)||(Ln[r]=[]),Ln[r].push({name:t,func:n})}})),Ln[Mi(i,2).name]=[{name:"wrapper",func:i}],Hn.prototype.clone=function(){var e=new Hn(this.__wrapped__);return e.__actions__=Ai(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Ai(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Ai(this.__views__),e},Hn.prototype.reverse=function(){if(this.__filtered__){var e=new Hn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Hn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=Vs(e),r=t<0,i=n?e.length:0,o=function(e,t,n){for(var r=-1,i=n.length;++r=this.__values__.length;return{done:e,value:e?i:this.__values__[this.__index__++]}},Un.prototype.plant=function(e){for(var t,n=this;n instanceof Fn;){var r=Do(n);r.__index__=0,r.__values__=i,t?o.__wrapped__=r:t=r;var o=r;n=n.__wrapped__}return o.__wrapped__=e,t},Un.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof Hn){var t=e;return this.__actions__.length&&(t=new Hn(this)),(t=t.reverse()).__actions__.push({func:ps,args:[ts],thisArg:i}),new qn(t,this.__chain__)}return this.thru(ts)},Un.prototype.toJSON=Un.prototype.valueOf=Un.prototype.value=function(){return hi(this.__wrapped__,this.__actions__)},Un.prototype.first=Un.prototype.head,st&&(Un.prototype[st]=function(){return this}),Un}();ot._=cn,(r=function(){return cn}.call(t,n,t,e))===i||(e.exports=r)}.call(this)},752:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{l(r.next(e))}catch(e){o(e)}}function a(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=i(n(733)),s=n(249),a=n(96),l=n(288),c=n(208),u=n(467),d=n(391),h=n(544),f=n(980),p=n(66),_=n(774),m=n(964),g=n(320),v=n(717),b=n(542),y=n(452),w=n(385),C=n(580);function x(e,t){return r(this,void 0,void 0,(function*(){if(new Int8Array(e,0,1)[0]==="P".charCodeAt(0)){const n=new o.default;return(yield n.loadAsync(e)).file(t)[0].async("string")}return(new TextDecoder).decode(e)}))}let E=null;function S(e){$("#errorText").html(e),$("#errorDialog").modal("show")}$("#roster-file").on("change",(function(e){const t="resize"===(null==e?void 0:e.type)?null==E?void 0:E.target:null==e?void 0:e.target;if($("#roster-title").empty(),$("#roster-lists").empty(),$("#force-units").empty(),!(null==t?void 0:t.files))return;const n=null==t?void 0:t.files[0];"resize"!==(null==e?void 0:e.type)&&(E=e),n.arrayBuffer().then((e=>r(this,void 0,void 0,(function*(){n.name.match(/\.rosz?$/)?function(e){const t=(new DOMParser).parseFromString(e,"text/xml");if(!t)return;const n=t.querySelector("roster");if(!n)return;const r=n.getAttribute("gameSystemName");if(!r)return;const i=n.getAttribute("name");i&&(document.title=`PrettyScribe ${i}`);const o=$("#roster-title")[0],C=$("#roster-lists")[0],x=$("#force-units")[0];if("Warhammer 40,000 8th Edition"==r){const e=(0,l.Create40kRoster)(t);e&&e._forces.length>0&&new u.Renderer40k(e).render(o,C,x)}else if("Warhammer 40,000 9th Edition"==r){const e=(0,l.Create40kRoster)(t);e&&e._forces.length>0&&new u.Renderer40k(e).render(o,C,x)}else if("Warhammer 40,000: Kill Team (2018)"==r){const e=(0,l.Create40kRoster)(t,!1);e&&e._forces.length>0&&new u.Renderer40k(e).render(o,C,x)}else if("Warhammer 40,000: Kill Team (2021)"==r){const e=(0,s.CreateKT21Roster)(t);e&&e._forces.length>0&&new a.RendererKT21(e).render(o,C,x)}else if("Age of Sigmar"==r){const e=(0,_.CreateAoSRoster)(t);e&&new m.RendererAoS(e).render(o,C,x)}else if("Warhammer Age of Sigmar: Warcry"==r){const e=(0,g.CreateWarcryRoster)(t);e&&new v.RendererWarcry(e).render(o,C,x)}else if("Warhammer 30,000 - The Horus Heresy"==r){const e=(0,d.Create30kRoster)(t);e&&e._forces.length>0&&new h.Renderer30k(e).render(o,C,x)}else if(r.includes("Horus Heresy (2022)")){const e=f.HorusHeresy.CreateRoster(t);e&&e._forces.length>0&&new p.RendererHH2(e).render(o,C,x)}else if("Warhammer 40,000 10th Edition"==r){const e=c.Wh40k.CreateRoster(t);window.roster=e,e&&e._forces.length>0&&new b.Wh40kRenderer(e).render(o,C,x)}else if("Middle-Earth Strategy Battle Game"===r){const e=(0,y.CreateMESBGRoster)(t);null!==e&&(console.log(e),(0,w.renderMESBG)(e,o,C,x))}else S("PrettyScribe does not support game type '"+r+"'.")}(yield x(e,/[^/]+\.ros$/)):n.name.match(/\.regi[sz]try$/)?function(e){const t=JSON.parse(e);window.registry=t;const n=$("#roster-title")[0],r=$("#roster-lists")[0],i=$("#force-units")[0],o=t.info.game;if("Warhammer 40k"===o){const e=(0,C.Create40kRosterFromRegistry)(t);window.roster=e,new b.Wh40kRenderer(e).render(n,r,i)}else S("PrettyScribe does not support game type '"+o+"'.")}(yield x(e,/[^/]+\.registry$/)):S(`PrettyScribe does not support extension of ${n.name}.`)})))).catch((e=>{S(`Error opening ${n.name}: ${e}`),console.error(e)}))})),document.addEventListener("DOMContentLoaded",(()=>{if(navigator.userAgent.match(/AppleWebKit.*Safari/)&&!navigator.userAgent.includes("Chrome")){const e=document.querySelector('input[type="file"');null==e||e.removeAttribute("accept")}}))},361:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toggleHidden=t.addHideAble=void 0,t.addHideAble=function(e){return e.classList.add("hide_able"),e},t.toggleHidden=function(e){var t,n,r;if(!e.target)return;const i=e.target;null===(t=i.closest(".hide_able"))||void 0===t||t.classList.toggle("hidden"),null===(r=null===(n=i.closest(".unit_header"))||void 0===n?void 0:n.closest(".wh40k_unit_sheet"))||void 0===r||r.classList.toggle("hidden")}},77:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PsJsx=void 0,function(e){function t(e,n){if(null!=n)if(Array.isArray(n))for(const r of n)t(e,r);else"string"==typeof n?e.appendChild(document.createTextNode(n)):n instanceof Node?e.appendChild(n):"boolean"==typeof n||e.appendChild(document.createTextNode(String(n)))}e.createFragment=function(){return document.createDocumentFragment()},e.createElement=function(e,n,...r){const i="function"==typeof e?e():document.createElement(e);if(n)for(const e of Object.keys(n)){const t=n[e];if("boolean"==typeof t)i.setAttribute(e,"");else if("function"==typeof t)if("ref"===e)t(i);else{if(!e.startsWith("on"))throw new Error("Unexpected function attribute");i.addEventListener(e.substring(2),t)}else"className"===e?i.setAttribute("class",t):i.setAttribute(e,t)}for(const e of r)t(i,e);return i}}(t.PsJsx||(t.PsJsx={}))},219:(e,t)=>{"use strict";function n(e,t){try{window.localStorage[e]=t}catch(e){}}Object.defineProperty(t,"__esModule",{value:!0}),t.loadOptionsFromLocalStorage=t.saveOptionToLocalStorage=t.renderCheckboxOption=t.renderOptionsToggle=void 0,t.renderOptionsToggle=function(e){e.classList.add("wh40k_options_toggle"),e.id="wh40k_options_toggle";const t="[−] Options:";e.appendChild(document.createTextNode(t)),e.addEventListener("click",(e=>{const r=document.getElementById("wh40k_options_div"),i=document.getElementById("wh40k_options_toggle");r&&i&&(r.classList.contains("hide_options")?(r.classList.remove("hide_options"),i.innerText=t,n("option-toggle-hidden","false")):(r.classList.add("hide_options"),i.innerText="[+] Options",n("option-toggle-hidden","true")))}))},t.renderCheckboxOption=function(e,t,r,i,o=!1){const s=e.appendChild(document.createElement("div"));s.classList.add("wh40k_option");const a=s.appendChild(document.createElement("input"));a.setAttribute("type","checkbox"),a.setAttribute("name",t),a.setAttribute("id",t),o&&(a.checked=!0),a.addEventListener("input",i),a.addEventListener("change",(e=>function(e){const t=document.getElementById(e);t&&n(`option-checkbox-${e}`,t.checked)}(t)));const l=s.appendChild(document.createElement("label"));l.setAttribute("for",t),l.appendChild(document.createTextNode(` ${r}`))},t.saveOptionToLocalStorage=n,t.loadOptionsFromLocalStorage=function(){var e;try{for(let t=0;t{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createNotesHead=t.createNoteHead=t.createTableRow=void 0;const r=n(361);function i(e,t,n=!1){const i=(0,r.addHideAble)(document.createElement("tr"));n&&i.classList.add("header_row");for(let r=0,o=0;re._customNotes)))return null;const n=document.createElement("thead");n.classList.add("info_row");const r=document.createElement("div");for(const e of t){if(!e.notes())continue;const t=r.appendChild(document.createElement("div"));t.appendChild(document.createElement("b")).appendChild(document.createTextNode(`${e.name()}: `)),t.appendChild(document.createTextNode(e._customNotes))}return n.appendChild(i([e,r],[.1,.9],!1)),n}},580:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateRoster=t.Create40kRosterFromRegistry=void 0;const r=n(208),i=n(596);function o(e){const t=new r.Wh40k.Roster40k,n=new r.Wh40k.Force;t._name=e.name,n._name=e.info.name,function(e,t){const n=e.assets.traits.filter((e=>"Detachment"===e.classification))[0];n&&(t._faction=n.designation,t._rules.set(n.designation,n.text))}(e,n);for(const r of[...e.assets.included,...e.assets.traits]){if("Unit"!=r.classIdentity)continue;const e=s(r);n._units.push(e),t._cost.add(e._cost);for(const t of[...e._rules.entries(),...e._weaponRules.entries()])n._rules.set(t[0],t[1])}return n._rules=new Map([...n._rules.entries()].sort()),t._forces.push(n),t}function s(e){var t,n;const i=new r.Wh40k.Unit;return i._name=e.designation,function(e,t){var n,r,i;const o=(null===(r=null===(n=e.rules.finalModelTally)||void 0===n?void 0:n.evals[1])||void 0===r?void 0:r.result.integer)||(null===(i=e.stats.Models)||void 0===i?void 0:i.value);e.stats.model3rdTally.value&&o>e.stats.model3rdTally.value?t._cost._points=e.stats.model4thCost.value:e.stats.model2ndTally.value&&o>e.stats.model2ndTally.value?t._cost._points=e.stats.model3rdCost.value:e.stats.model1stTally.value&&o>e.stats.model1stTally.value?t._cost._points=e.stats.model2ndCost.value:e.stats.Points&&(t._cost._points=e.stats.Points.value),function e(n){var r;for(const i of[...n.assets.included,...n.assets.traits])(null===(r=i.stats.Points)||void 0===r?void 0:r.value)&&(t._cost._points+=i.stats.Points.value),e(i)}(e)}(e,i),null===(t=e.keywords.Faction)||void 0===t||t.sort().forEach((e=>i._factions.add(e))),null===(n=e.keywords.Keywords)||void 0===n||n.sort().forEach((e=>i._keywords.add(e))),function(e,t){const n=[...e.assets.traits,...e.assets.included].filter((e=>"Model"===e.classification));0===n.length?n.push(e):d({designation:"Unit Upgrades",assets:e.assets,quantity:1},t,!1);for(const e of n)u(e,t),d(e,t)}(e,i),a(e,i),i.normalize(),i}function a(e,t){for(const n of[...e.assets.traits,...e.assets.included]){const e=n.classification;if("Wargear"===e||"Enhancement"===e)t._abilities[e]||(t._abilities[e]=new Map),t._abilities[e].set(n.designation,n.text);else if("Ability"===e)if("Leader"===n.designation){const e=n.text.indexOf("This model can be attached"),r=n.text.substring(0,e).trim();r&&t._rules.set(n.designation,r);const i=n.text.substring(e);t._abilities.Abilities||(t._abilities.Abilities=new Map),t._abilities.Abilities.set(n.designation,i)}else!n.tally.Core&&!n.tally.Faction||n.designation.startsWith("Damaged:")?(t._abilities.Abilities||(t._abilities.Abilities=new Map),t._abilities.Abilities.set(n.designation,n.text)):t._rules.set(n.designation,n.text);else if("Model"===e)a(n,t);else if("Ranged Weapon"===e||"Melee Weapon"===e||"Weapon"===e){l(n,t);const e=n.assets.traits.filter((e=>e.classification.endsWith("Weapon")));for(const r of e)l(r,t,n.designation)}else console.error(`Unexepcted classification '${e}': ${n.designation}`)}}function l(e,t,n){const i=`${e.classification}s`,o=c(e,i);if(n&&(o[Object.keys(o)[0]]=`${n} - ${o[Object.keys(o)[0]]}`),Object.keys(o).length<=1)return;const s=e.assets.traits.filter((e=>"Ability"===e.classification));if(s.length>0){s.forEach((e=>t._weaponRules.set(e.designation,e.text)));const e=s.map((e=>e.designation));Object.assign(o,{Keywords:e.join(", ")})}t._profileTables[i]||(t._profileTables[i]=new r.Wh40k.TabularProfile),t._profileTables[i].addRow(o)}function c(e,t,n){const r=(0,i.filterAndOrderStats)(e.stats);return Object.assign({[t]:e.designation},Object.fromEntries(r.map((e=>[e[0],(0,i.formatStat)(e[1])]))))}function u(e,t){const n=c(e,"Unit");Object.keys(n).length>1&&(t._profileTables.Unit||(t._profileTables.Unit=new r.Wh40k.TabularProfile),t._profileTables.Unit.addRow(Object.assign({Unit:e.designation},n)))}function d(e,t,n=!0){var i;const o=new r.Wh40k.Model;o._name=e.designation,o._count=e.quantity;const s=[...e.assets.traits,...e.assets.included].filter((e=>"Wargear"===e.classification||"Weapon"===e.classification||"Ranged Weapon"===e.classification||"Melee Weapon"===e.classification||"Enhancement"===e.classification));for(const e of s){const t=new r.Wh40k.Upgrade;t._name=e.designation;const n=null===(i=e.stats.Points)||void 0===i?void 0:i.value;n&&(t._cost._points=n),o._upgrades.push(t)}(n||s.length>0)&&t._models.push(o)}t.Create40kRosterFromRegistry=function(e){return o(e)},t.CreateRoster=o},419:(e,t)=>{"use strict";var n,r;function i(e,t,i,o,s,a,l,c){if(e&&t.length){e.textBaseline="top";let u=e.measureText(t);const d=u.width,h=u.actualBoundingBoxDescent-u.actualBoundingBoxAscent;let f=o;c==r.Top?f=o:c==r.Bottom?f=o+a-h:c==r.Center&&(f=o+(a-h)/2),l==n.Center?e.fillText(t,i+Math.max((s-d)/2,0),f,s):l==n.Left?e.fillText(t,i,f,s):l==n.Right&&e.fillText(t,i+s-d,f,s)}}Object.defineProperty(t,"__esModule",{value:!0}),t.FixDPI=t.RenderParagraph=t.RenderText=t.RenderTextFull=t.VertAlign=t.Justification=void 0,function(e){e[e.Left=0]="Left",e[e.Right=1]="Right",e[e.Center=2]="Center"}(n=t.Justification||(t.Justification={})),function(e){e[e.Top=0]="Top",e[e.Bottom=1]="Bottom",e[e.Center=2]="Center"}(r=t.VertAlign||(t.VertAlign={})),t.RenderTextFull=i,t.RenderText=function(e,t,n,o,s,a,l){i(e,t,n,o,s,a,l,r.Center)},t.RenderParagraph=function(e,t,n,r,i,o){let s=r;if(e&&t.length){let r=[],a=[];e.textBaseline="top";let l=0;const c=e.measureText(" ").width,u=e.measureText(t),d=1.2*(u.actualBoundingBoxDescent-u.actualBoundingBoxAscent);let h=i-o;t.split(" ").forEach((function(t){const n=e.measureText(t);l+n.width>h&&(r.push(a.join(" ")),h=i,a.length=0,l=0),l+=n.width+c,a.push(t)})),a.length>0&&r.push(a.join(" "));let f=n+o;for(let t of r)e.fillText(t,f,s),f=n,s+=d}return s},t.FixDPI=function(e){let t=window.devicePixelRatio,n=+getComputedStyle(e).getPropertyValue("height").slice(0,-2),r=+getComputedStyle(e).getPropertyValue("width").slice(0,-2);0==n&&(n=e.height),0==r&&(r=e.width),e.setAttribute("height",(n*t).toString()),e.setAttribute("width",(r*t).toString())}},544:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Renderer30k=void 0;const r=n(391),i=n(419);class o{constructor(e){this._descriptionStartX=190,this._descriptionWidth=600,this._showWoundBoxes=!1,this._roster=null,this._currentX=0,this._currentY=0,this._maxWidth=0,this._octagon=null,this._roles=new Map,this._unitLabelWidthsNormalized=[.3,.077,.077,.077,.077,.077,.077,.077,.077,.077],this._vehicleLabelWidthsNormalized=[.3,.1,.1,.1,.1,.1,.2],this._walkerLabelWidthsNormalized=[.3,.06,.06,.06,.06,.06,.06,.06,.06,.06,.15],this._flyerLabelWidthsNormalized=[.3,.077,.077,.077,.077,.077,.077,.077,.077,.077],this._weaponLabelWidthNormalized=[.3,.1,.1,.1,.4],this._spellLabelWidthNormalized=[.3,.1,.1,.5],this._roster=e,this._octagon=document.getElementById("octagon"),this._roles.set(r.UnitRole30k.HQ,document.getElementById("role_hq")),this._roles.set(r.UnitRole30k.TR,document.getElementById("role_tr")),this._roles.set(r.UnitRole30k.EL,document.getElementById("role_el")),this._roles.set(r.UnitRole30k.FA,document.getElementById("role_fa")),this._roles.set(r.UnitRole30k.HS,document.getElementById("role_hs")),this._roles.set(r.UnitRole30k.FL,document.getElementById("role_fl")),this._roles.set(r.UnitRole30k.DT,document.getElementById("role_dt")),this._roles.set(r.UnitRole30k.FT,document.getElementById("role_ft")),this._roles.set(r.UnitRole30k.LW,document.getElementById("role_lw"))}render(e,t,n){if(null!=this._roster){e&&(e.innerHTML="

"+this._roster._name+" ("+this._roster._points+" pts)

");for(let e of this._roster._forces){const s=document.createElement("div");s&&(s.innerHTML="

"+e._catalog+" "+e._name+"

"),t&&t.appendChild(s);const a=document.createElement("table");a.classList.add("table"),a.classList.add("table-sm"),a.classList.add("table-striped");const l=document.createElement("thead");a.appendChild(l),l.classList.add("thead-light");const c=document.createElement("tr");l.appendChild(c),[{name:"NAME",w:"25%"},{name:"ROLE",w:"20%"},{name:"MODELS",w:"40%"},{name:"POINTS",w:"15%"}].forEach((e=>{let t=document.createElement("th");t.scope="col",t.innerHTML=e.name,t.style.width=e.w,c.appendChild(t)})),s.appendChild(a);let u=document.createElement("tbody");a.appendChild(u);for(let t of e._units){let e=document.createElement("tr"),n=document.createElement("td");n.innerHTML=t._name;let i=document.createElement("td");i.innerHTML=r.UnitRoleToString30k[t._role];let o=document.createElement("td");o.innerHTML="";let s=0;for(const e of t._models)e._count>1?o.innerHTML+=e._count+" "+e._name:o.innerHTML+=e._name,s++,s!=t._models.length&&(o.innerHTML+=", ");let a=document.createElement("td");a.innerHTML=t._points.toString(),e.appendChild(n),e.appendChild(i),e.appendChild(o),e.appendChild(a),u.appendChild(e)}if(e._rules.size>0){let t=document.createElement("div"),r=document.createElement("h3");t.appendChild(r),r.textContent=e._catalog+" Allegiance Rules";for(let n of e._rules){let e=document.createElement("div"),r=document.createElement("h4");r.textContent=n[0];let i=document.createElement("p");i.textContent=n[1],e.appendChild(r),e.appendChild(i),t.appendChild(e)}n&&n.appendChild(t)}for(let t of e._units){let e=document.createElement("canvas");e.width=7.5*o._res,e.height=20*o._res,this._descriptionWidth=e.width-this._descriptionStartX-10,(0,i.FixDPI)(e);const r=this.renderUnit(t,e,0,0),s=25;let a=document.createElement("canvas");a.width=r[0]+2*s,a.height=r[1]+2*s;let l=a.getContext("2d");if(null==l||l.drawImage(e,s,s),n){let e=document.createElement("div");e.appendChild(a),n.appendChild(e)}}}}}renderBorder(e,t,n,r,i){e.strokeStyle=o._blackColor,e.beginPath(),e.moveTo(t,n+o._bevelSize),e.lineTo(t,n+i-o._bevelSize),e.lineTo(t+o._bevelSize,n+i),e.lineTo(t+r-o._bevelSize,n+i),e.lineTo(t+r,n+i-o._bevelSize),e.lineTo(t+r,n+o._bevelSize),e.lineTo(t+r-o._bevelSize,n),e.lineTo(t+o._bevelSize,n),e.closePath(),e.stroke(),e.save(),e.fillStyle=o._fillColor,e.globalCompositeOperation="destination-over",e.beginPath(),e.moveTo(t,n+o._bevelSize),e.lineTo(t,n+i-o._bevelSize),e.lineTo(t+o._bevelSize,n+i),e.lineTo(t+r-o._bevelSize,n+i),e.lineTo(t+r,n+i-o._bevelSize),e.lineTo(t+r,n+o._bevelSize),e.lineTo(t+r-o._bevelSize,n),e.lineTo(t+o._bevelSize,n),e.closePath(),e.fill(),e.restore()}renderWatermark(e){}renderLine(e){e.lineWidth=2,e.strokeStyle=o._blackColor,e.beginPath(),e.moveTo(this._currentX,this._currentY),e.lineTo(this._currentX+this._maxWidth,this._currentY),e.stroke(),this._currentY+=1}renderTableHeader(e,t,n){let r=this._currentX;const s=this._maxWidth;e.fillStyle=o._grey1,e.fillRect(this._currentX,this._currentY,s,22),e.fillStyle=o._blackColor,e.font=o._titleFont;var a=50;if(t){e.font=o._headerFont;for(let o=0;o1?n+=e._count+" "+e._name:n+=e._name,r++,r!=t.length&&(n+=", ");this._currentY+=2,this._currentY=(0,i.RenderParagraph)(e,n,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth,0),this._currentY+=2}renderWoundBoxes(e,t){e.font=o._titleFont,(0,i.RenderText)(e,"WOUNDS",this._currentX+20,this._currentY,100,16,i.Justification.Left);const n=this._currentX+this._descriptionStartX,r=n+195;e.save();for(let s of t)if(s._wounds>1){let t=this._currentY;e.font=o._font,e.fillStyle=o._blackColor,this._currentY=(0,i.RenderParagraph)(e,s._name,n,this._currentY+3,195,0);let a=this._currentX+r;e.strokeStyle=o._blackColor,e.fillStyle="#ffffff";for(let n=0;n{u.push(e*this._maxWidth)}));const d=[];this._vehicleLabelWidthsNormalized.forEach((e=>{d.push(e*this._maxWidth)}));const h=[];this._walkerLabelWidthsNormalized.forEach((e=>{h.push(e*this._maxWidth)}));const f=[];for(var p of(this._flyerLabelWidthsNormalized.forEach((e=>{f.push(e*this._maxWidth)})),e._models)){c.push(p);for(let e of p._weapons)s.push(e);for(let e of p._psychicPowers)a.push(e);p._psyker&&l.push(p._psyker)}const _=[],m=new Map;for(const e of c)m.has(e._name)||(m.set(e._name,e),_.push(e));if(_.length>0){this.renderTableHeader(i,o._unitLabels,u);let e=0;for(var p of _)this.renderModel(i,p,u,e%2),e++}if(e._vehicles.length>0){this.renderTableHeader(i,o._vehicleLabels,d);let t=0;for(var g of e._vehicles)this.renderVehicle(i,g,d,t%2),t++}if(e._walkers.length>0){this.renderTableHeader(i,o._walkerLabels,h);let t=0;for(var v of e._walkers)this.renderWalker(i,v,h,t%2),t++}if(e._flyers.length>0){this.renderTableHeader(i,o._flyerLabels,f);let t=0;for(var b of e._flyers)this.renderFlyer(i,b,f,t%2),t++}const y=[],w=new Map;for(const e of s)w.has(e._name)||(w.set(e._name,e),y.push(e));if(y.length>0){const e=[];this._weaponLabelWidthNormalized.forEach((t=>{e.push(t*this._maxWidth)})),this.renderLine(i),this.renderTableHeader(i,o._weaponLabels,e),this.renderWeapons(i,y,e)}if(a.length>0){const e=[];this._spellLabelWidthNormalized.forEach((t=>{e.push(t*this._maxWidth)})),this.renderLine(i),this.renderTableHeader(i,o._spellLabels,e),this.renderPowers(i,a,e)}if(e._abilities.size>0&&(this.renderLine(i),this._currentY+=2,this.renderAbilities(i,e)),l.length>0&&(this.renderLine(i),this._currentY+=2,this.renderPsykers(i,l)),e._rules.size>0&&(this.renderLine(i),this._currentY+=2,this.renderRules(i,e)),e._factions.size>0&&(this.renderLine(i),this._currentY+=2,this.renderFactions(i,e)),e._keywords.size>0&&(this.renderLine(i),this._currentY+=2,this.renderKeywords(i,e)),e._models.length>0&&(this.renderLine(i),this._currentY+=2,this.renderModelList(i,_)),this._showWoundBoxes){let t=!1;for(let n of e._models)n._wounds>2&&(t=!0);t&&(this.renderLine(i),this._currentY+=5,this.renderWoundBoxes(i,e._models))}this._currentY+=2;const C=this._currentY-(r+o._margin),x=this._maxWidth;return this.renderBorder(i,this._currentX,r+o._margin,x,C),this.renderWatermark(i),[this._maxWidth,this._currentY]}renderHeader(e,t){t.globalAlpha=1,t.fillStyle=o._blackColor;const n=this._currentX,r=this._currentX+this._maxWidth,s=this._currentY,a=s+36;t.beginPath(),t.moveTo(n,s+o._bevelSize),t.lineTo(n,a),t.lineTo(r,a),t.lineTo(r,s+o._bevelSize),t.lineTo(r-o._bevelSize,s),t.lineTo(n+o._bevelSize,s),t.closePath(),t.fill();let l=n+6;if(this._octagon){t.drawImage(this._octagon,l,s+2,32,32);const n=this._roles.get(e._role);n&&t.drawImage(n,l+4,s+2+4,24,24),t.fillStyle="white",t.font="18px serif",l+=34,t.drawImage(this._octagon,l,s+2,32,32),(0,i.RenderText)(t,e._points.toString(),l,s+2,32,32,i.Justification.Center)}let c=0,u=28;const d=l+6;t.font=u+"px bold serif";const h=e._name.toLocaleUpperCase();let f=t.measureText(h);const p=this._maxWidth-d;for(;c<6&&f.width>p;)c+=1,u-=2,t.font=u+"px bold serif",f=t.measureText(h);t.fillStyle="white",t.textBaseline="top",(0,i.RenderText)(t,h,d,s,p,36,i.Justification.Center),this._currentY+=36}renderPsykers(e,t){e.font=o._titleFont,(0,i.RenderText)(e,"PSYKERS",this._currentX+20,this._currentY,100,16,i.Justification.Left),e.font=o._font,this._currentY+=2;for(let n of t)this._currentY=(0,i.RenderParagraph)(e,"MASTERY LEVEL: "+n._masteryLevel,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth,0),this._currentY+=2,this._currentY=(0,i.RenderParagraph)(e,"DISCIPLINES: "+n._disciplines,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth,0),this._currentY+=2}}t.Renderer30k=o,o._res=144,o._margin=0,o._bevelSize=15,o._blackColor="#1d272a",o._grey1="#b3bbb5",o._greyLight="#dde1df",o._fillColor="#f6f6f6",o._titleFont="bold 14px sans-serif",o._headerFont="bold 14px sans-serif",o._font="14px sans-serif",o._boldFont="bold 14px sans-serif",o._unitLabels=["MODEL","WS","BS","S","T","W","I","A","LD","SAVE"],o._vehicleLabels=["MODEL","BS","FRONT","SIDE","REAR","HP","TYPE"],o._walkerLabels=["MODEL","WS","BS","S","FRONT","SIDE","REAR","I","A","HP","TYPE"],o._flyerLabels=["MODEL","BS","FRONT","SIDE","REAR","HP","TYPE","ROLE","PURSUIT","AGILITY"],o._weaponLabels=["WEAPONS","RANGE","S","AP","TYPE"],o._spellLabels=["PSYCHIC POWER","WARP CHARGE","RANGE","DETAILS"]},467:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Renderer40k=void 0;const r=n(288),i=n(682),o=n(361),s=n(219);class a{constructor(e){this._roster=null,this._roles=new Map,this._unitLabelWidthsNormalized=[.25,.05,.05,.05,.05,.05,.05,.05,.05,.05],this._weaponLabelWidthNormalized=[.25,.05,.1,.05,.05,.05,.45],this._spellLabelWidthNormalized=[.25,.05,.1,.6],this._explosionLabelWidthNormalized=[.2,.1,.1,.15],this._trackerLabelWidth=[.2,.15,.1,.1,.1],this._roster=e,this._roles.set(r.UnitRole.HQ,document.getElementById("role_hq")),this._roles.set(r.UnitRole.TR,document.getElementById("role_tr")),this._roles.set(r.UnitRole.EL,document.getElementById("role_el")),this._roles.set(r.UnitRole.FA,document.getElementById("role_fa")),this._roles.set(r.UnitRole.HS,document.getElementById("role_hs")),this._roles.set(r.UnitRole.FL,document.getElementById("role_fl")),this._roles.set(r.UnitRole.DT,document.getElementById("role_dt")),this._roles.set(r.UnitRole.FT,document.getElementById("role_ft")),this._roles.set(r.UnitRole.LW,document.getElementById("role_lw"))}render(e,t,n){if(null!=this._roster){if(e){this.renderOptionsDiv(e);const t=[`${this._roster._cost._points} pts`,`${this._roster._cost._powerLevel} PL`,`${this._roster._cost._commandPoints} CP`];for(const e in this._roster._cost._freeformValues)t.push(`${this._roster._cost._freeformValues[e]}${e}`);const n=`${this._roster.name()} (${t.join(", ")})`;e.appendChild(document.createElement("h3")).appendChild(document.createTextNode(n));const r=e.appendChild(document.createElement("div"));r.classList.add("footer"),r.appendChild(document.createElement("div")).appendChild(document.createTextNode("PrettyScribe")),r.appendChild(document.createElement("div")).appendChild(document.createTextNode(n)),this._roster._customNotes&&e.appendChild(document.createElement("p")).appendChild(document.createTextNode(this._roster._customNotes))}t&&(this.renderRosterSummary(t),this.renderAbilitiesByPhase(t)),n&&this.renderRosterDetails(n),(0,s.loadOptionsFromLocalStorage)()}}renderRosterSummary(e){if(!this._roster)return;const t=this._roster._forces.some((e=>e._units.some((e=>0!==e._cost._commandPoints))));for(const n of this._roster._forces){const i=document.createElement("div");if(n._faction?i.appendChild(document.createTextNode(`${n._catalog} ${n.name()} (${n._faction})`)):i.appendChild(document.createTextNode(`${n._catalog} ${n.name()}`)),n._configurations.length>0){const e=i.appendChild(document.createElement("ul"));for(const t of n._configurations)e.appendChild(document.createElement("li")).appendChild(document.createElement("i")).appendChild(document.createTextNode(t))}e.appendChild(i);const o=document.createElement("table");o.classList.add("table","table-sm","table-striped");const s=document.createElement("thead");o.appendChild(s),s.classList.add("thead-light");const a=document.createElement("tr");s.appendChild(a);const l=[{name:"NAME",w:"20%"},{name:"ROLE",w:"15%"},{name:"MODELS",w:"55%"},{name:"POINTS",w:"5%"},{name:"POWER",w:"5%"}];t&&l.push({name:"CP",w:"5%"}),l.forEach((e=>{let t=document.createElement("th");t.scope="col",t.appendChild(document.createTextNode(e.name)),t.style.width=e.w,a.appendChild(t)})),i.appendChild(o);let c=document.createElement("tbody");o.appendChild(c);for(let e of n._units){const n=document.createElement("tr");n.appendChild(document.createElement("td")).appendChild(document.createTextNode(e.nameWithExtraCosts())),n.appendChild(document.createElement("td")).appendChild(document.createTextNode(r.UnitRoleToString[e._role]));const i=n.appendChild(document.createElement("td"));if(this.renderModelList(i,e),n.appendChild(document.createElement("td")).appendChild(document.createTextNode(e._cost._points.toString())),n.appendChild(document.createElement("td")).appendChild(document.createTextNode(e._cost._powerLevel.toString())),t){const t=(e._cost._commandPoints||"")+"";n.appendChild(document.createElement("td")).appendChild(document.createTextNode(t))}c.appendChild(n)}}}renderOptionsDiv(e){const t=e.appendChild(document.createElement("div"));t.classList.add("wh40k_options_div","d-print-none"),t.id="wh40k_options_div";const n=t.appendChild(document.createElement("span"));(0,s.renderOptionsToggle)(n),(0,s.renderCheckboxOption)(t,"showPhaseAbilities","Show abilities by phase",(e=>{const t=document.getElementById("wh40k_abilities_list");t&&(e.target.checked?t.classList.remove("d-none"):t.classList.add("d-none"))})),(0,s.renderCheckboxOption)(t,"showUpgradeCosts","Show upgrade costs",(e=>{const t=document.getElementsByClassName("wh40k_upgrade_cost");for(const n of t)e.target.checked?n.classList.remove("d-none"):n.classList.add("d-none")})),(0,s.renderCheckboxOption)(t,"collateDatasheets","Collate Detachment Datasheets",(e=>{const t=document.getElementById("collated_sheets"),n=document.getElementById("detachment_sheets");t&&n&&(e.target.checked?(t.classList.remove("d-none"),n.classList.add("d-none")):(t.classList.add("d-none"),n.classList.remove("d-none")))}));const r=t.appendChild(document.createElement("span"));r.classList.add("wh40k_options_print_subsection"),r.appendChild(document.createTextNode("Print:")),(0,s.renderCheckboxOption)(r,"printBigger","Larger Text",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("bigger"):n.classList.remove("bigger")})),(0,s.renderCheckboxOption)(r,"hideElements","Hide Elements",(e=>{const t=document.body;e.target.checked?(t.classList.add("hide_enabled"),t.addEventListener("click",o.toggleHidden)):(t.classList.remove("hide_enabled"),t.removeEventListener("click",o.toggleHidden))})),(0,s.renderCheckboxOption)(r,"datasheetPageBreaks","One Datasheet per Page",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("page_break"):n.classList.remove("page_break")}))}renderAbilitiesByPhase(e){if(!this._roster)return;const t={},n={};for(const e of this._roster._forces)for(const r of e._units)for(const e of Object.values(r._abilities))for(const[i,s]of e.entries()){const e=[...s.matchAll(/(?:before the first turn begins|set up|Reinforcements|(?:Command|Movement|Psychic|Shooting|Charge|Fight|Morale) phase)/gi)];if(0===e.length)continue;const a=(0,o.addHideAble)(document.createElement("div"));a.appendChild(document.createElement("b")).appendChild(document.createTextNode(r.name())),a.appendChild(document.createTextNode(" - ")),a.appendChild(document.createElement("b")).appendChild(document.createTextNode(i)),a.appendChild(document.createTextNode(" - "));let l=s;for(const r of e){if(!r.index)continue;const e=r[0].toLocaleLowerCase();let o=e;switch(e){case"before the first turn begins":o="pre-game phase";break;case"set up":s.includes("reinforcements")||(o="pre-game phase");break;case"reinforcements":o="movement phase"}if(s.toLocaleLowerCase().includes("as if it were your "+o))continue;const c=r.index-(s.length-l.length);c>0&&a.appendChild(document.createTextNode(l.substring(0,c)));const u=t[o]=t[o]||[],d=n[o]=n[o]||[];d.includes(i)||(d.push(i),u.push(a)),a.appendChild(document.createElement("u")).appendChild(document.createTextNode(r[0]));const h=c+e.length;l=l.substring(h)}l.length>0&&a.appendChild(document.createTextNode(l))}const r=e.appendChild(document.createElement("div"));r.setAttribute("id","wh40k_abilities_list"),r.classList.add("d-none"),r.appendChild(document.createElement("h3")).appendChild(document.createTextNode("Abilities by Phase"));const i=["pre-game phase","command phase","movement phase","psychic phase","shooting phase","charge phase","fight phase","morale phase"].filter((e=>!!t[e]));if(0===i.length)r.appendChild(document.createTextNode("No phase-specific abilities in roster"));else for(const e of i){r.appendChild(document.createElement("h4")).appendChild(document.createTextNode(e));for(const n of t[e])r.appendChild(n.parentElement?n.cloneNode(!0):n)}}renderRosterDetails(e){if(!this._roster)return;const t=new Map,n=new Map,i=e.appendChild(document.createElement("div"));i.id="detachment_sheets";const o=e.appendChild(document.createElement("div"));o.id="collated_sheets",o.style.pageBreakBefore="always",o.classList.add("d-none");const s=[];for(const e of this._roster._forces){const r=document.createElement("div");if(r.style.pageBreakBefore="always",r){const t=document.createElement("p");t.appendChild(document.createTextNode(e._catalog)),e._faction&&t.appendChild(document.createTextNode(" ("+e._faction+")")),r.appendChild(t)}let o=document.createElement("h3");o.appendChild(r),i.appendChild(o),this.renderDatasheets(i,e._units),s.push(...e._units),l(t,e._catalog,e._rules),l(n,e._faction,e._factionRules)}s.sort(((e,t)=>e._role!=t._role?e._role-t._role:e._name!=t._name?(0,r.Compare)(e._name,t._name):e._cost._points-t._cost._points)),this.renderDatasheets(o,s);let a=document.createElement("div");a.style.pageBreakBefore="always",this.printRules(t,a),this.printRules(n,a),e.appendChild(a)}renderDatasheets(e,t){let n=0;for(let r=0;r1?` (${n})`:""),d],[.1,.8,.1]));const h=l.appendChild(document.createElement("tr"));for(let e=0;e<20;e++){const e=h.appendChild(document.createElement("td"));e.colSpan=1,e.style.width="5%",e.style.padding="0"}let f=(0,i.createNoteHead)("Unit notes",t);f&&s.appendChild(f),l=s.appendChild(document.createElement("thead")),l.classList.add("table-active"),l.appendChild((0,i.createTableRow)(a._unitLabels,this._unitLabelWidthsNormalized,!0));let p=s.appendChild(document.createElement("tbody"));p.append(document.createElement("tr"));for(const e of t._modelStats)p.append((0,i.createTableRow)([e._name,e._move,e._ws,e._bs,e._str.toString(),e._toughness.toString(),e._wounds.toString(),e._attacks.toString(),e._leadership.toString(),e._save],this._unitLabelWidthsNormalized));if(f=(0,i.createNotesHead)("Model notes",t._modelStats),f&&s.appendChild(f),t._woundTracker.length>0){const e=Array.from(a._trackerLabels);if(4==t._woundTracker.length){const n=Array.from(t._woundTracker[0]._table.values());e.splice(1,n.length,...n)}else if(3==t._woundTracker.length){const n=Array.from(t._woundTracker[0]._table.keys());e.splice(1,n.length,...n)}l=s.appendChild(document.createElement("thead")),l.classList.add("table-active"),l.appendChild((0,i.createTableRow)(e,this._trackerLabelWidth,!0)),p=s.appendChild(document.createElement("tbody")),p.append(document.createElement("tr"));for(const e of t._woundTracker)p.appendChild((0,i.createTableRow)([""].concat(Array.from(e._table.values())),this._trackerLabelWidth))}if(t._weapons.length>0){l=s.appendChild(document.createElement("thead")),l.classList.add("table-active"),l.appendChild((0,i.createTableRow)(a._weaponLabels,this._weaponLabelWidthNormalized,!0)),p=s.appendChild(document.createElement("tbody")),p.append(document.createElement("tr"));for(const e of t._weapons)p.append((0,i.createTableRow)([e.name().toString(),e._range,e._type,e._str.toString(),e._ap,e._damage,e._abilities],this._weaponLabelWidthNormalized))}if(f=(0,i.createNotesHead)("Weapon notes",t._weapons),f&&s.appendChild(f),t._spells.length>0){l=s.appendChild(document.createElement("thead")),l.classList.add("table-active"),l.appendChild((0,i.createTableRow)(a._spellLabels,this._spellLabelWidthNormalized,!0)),p=s.appendChild(document.createElement("tbody")),p.append(document.createElement("tr"));for(const e of t._spells)p.append((0,i.createTableRow)([e.name(),e._manifest.toString(),e._range,e._details],this._spellLabelWidthNormalized))}if(f=(0,i.createNotesHead)("Spell notes",t._spells),f&&s.appendChild(f),t._psykers.length>0){l=s.appendChild(document.createElement("thead")),l.classList.add("info_row");const e=document.createElement("div");for(const n of t._psykers){let t=`CAST: ${n._cast}, DENY: ${n._deny}, POWERS KNOWN: ${n._powers}`;n._other&&(t+=`, OTHER: ${n._other}`),e.appendChild(document.createElement("div")).appendChild(document.createTextNode(t))}l.appendChild((0,i.createTableRow)(["Psykers",e],[.1,.9],!1))}f=(0,i.createNotesHead)("Psyker notes",t._psykers),f&&s.appendChild(f),!t._abilities.Abilities&&t._rules.size>0&&this.renderUnitAbilitiesAndRules(s,"Abilities",new Map,t._rules);for(const e of Object.keys(t._abilities).sort()){const n=t._abilities[e],r="Abilities"===e?t._rules:void 0;this.renderUnitAbilitiesAndRules(s,e,n,r)}l=s.appendChild(document.createElement("thead")),l.classList.add("info_row");const _=Array.from(t._factions).sort(r.Compare).join(", ").toLocaleUpperCase();l.appendChild((0,i.createTableRow)(["Factions",_],[.1,.9],!1)),l=s.appendChild(document.createElement("thead")),l.classList.add("info_row");const m=Array.from(t._keywords).sort(r.Compare).join(", ").toLocaleUpperCase();l.appendChild((0,i.createTableRow)(["Keywords",m],[.1,.9],!1)),l=s.appendChild(document.createElement("thead")),l.classList.add("info_row");const g=document.createElement("div");if(this.renderModelList(g,t),l.appendChild((0,i.createTableRow)(["MODELS",g],[.1,.9],!1)),t._explosions.length>0){l=s.appendChild(document.createElement("thead")),l.classList.add("table-active"),l.appendChild((0,i.createTableRow)(a._explosionLabels,this._explosionLabelWidthNormalized,!0)),p=s.appendChild(document.createElement("tbody")),p.append(document.createElement("tr"));for(const e of t._explosions)p.append((0,i.createTableRow)([e.name(),e._diceRoll,e._distance,e._mortalWounds],this._explosionLabelWidthNormalized))}f=(0,i.createNotesHead)("Explosion notes",t._explosions),f&&s.appendChild(f)}renderUnitAbilitiesAndRules(e,t,n,s){const a=e.appendChild(document.createElement("thead"));a.classList.add("info_row");const l=document.createElement("div");if(s&&s.size>0){const e=Array.from(s.keys()).sort(r.Compare).join(", ");l.appendChild(document.createElement("div")).appendChild(document.createElement("b")).appendChild(document.createTextNode(e))}const c=Array.from(n.keys()).sort(r.Compare);for(const e of c){const t=(0,o.addHideAble)(l.appendChild(document.createElement("div")));t.appendChild(document.createElement("b")).appendChild(document.createTextNode(`${e.toUpperCase()}: `)),t.appendChild(document.createTextNode(n.get(e)||"??"))}a.appendChild((0,i.createTableRow)([t,l],[.1,.9],!1))}renderModelList(e,t){for(const n of t._models){const t=e.appendChild(document.createElement("div"));t.appendChild(document.createTextNode((n._count>1?`${n._count}x `:"")+n.name()));const r=n.getDedupedWeaponsAndUpgrades();if(0!==r.length){t.appendChild(document.createTextNode(" ("));for(const e of r)if(e!==r[0]&&t.appendChild(document.createTextNode(", ")),t.appendChild(document.createTextNode((e._count>1?`${e._count}x `:"")+e.selectionName())),e._cost.hasValues()){const n=t.appendChild(document.createElement("span"));n.classList.add("wh40k_upgrade_cost","d-none"),n.appendChild(document.createTextNode(` ${e._cost.toString()}`))}t.appendChild(document.createTextNode(")"))}}}printRules(e,t){if(0!==e.size&&t)for(let[n,r]of e.entries()){let e=document.createElement("div");e.classList.add("wh40k_rules");let i=document.createElement("h3");e.appendChild(i),i.appendChild(document.createTextNode(n));for(let t of r){let n=(0,o.addHideAble)(document.createElement("div")),r=document.createElement("b");r.appendChild(document.createTextNode(t[0]));let i=document.createElement("p");i.appendChild(document.createTextNode(t[1]||"")),n.appendChild(r),n.appendChild(i),e.appendChild(n)}t.appendChild(e)}}}function l(e,t,n){0!==n.size&&e.set(t,new Map([...e.get(t)||[],...n]))}t.Renderer40k=a,a._unitLabels=["MODEL","M","WS","BS","S","T","W","A","LD","SAVE"],a._weaponLabels=["WEAPONS","RANGE","TYPE","S","AP","D","ABILITIES"],a._spellLabels=["PSYCHIC POWER","MANIFEST","RANGE","DETAILS"],a._explosionLabels=["EXPLOSION","DICE ROLL","DISTANCE","MORTAL WOUNDS"],a._trackerLabels=["WOUND TRACK","REMAINING W","ATTRIBUTE","ATTRIBUTE","ATTRIBUTE"]},542:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Wh40kRenderer=void 0;const r=n(208),i=n(361),o=n(219),s=n(77);function a(e,t,n){0!==n.size&&e.set(t,new Map([...e.get(t)||[],...n]))}t.Wh40kRenderer=class{constructor(e){var t,n;this._roster=null,this._roles=new Map,this._unitLabelWidthsNormalized=[.4,.05,.05,.05,.05,.05,.05,.3],this._weaponLabelWidthNormalized=[.3,.1,.1,.05,.05,.05,.05,.3],this._roster=e;const i=(null===(t=this._roster)||void 0===t?void 0:t.hash())||0;this._rosterId=`${null===(n=this._roster)||void 0===n?void 0:n.name()}:${(i>>>0).toString(16)}`,this._roles.set(r.Wh40k.UnitRole.EpicHero,document.getElementById("role_hq")),this._roles.set(r.Wh40k.UnitRole.Character,document.getElementById("role_hq")),this._roles.set(r.Wh40k.UnitRole.Battleline,document.getElementById("role_tr")),this._roles.set(r.Wh40k.UnitRole.Infantry,document.getElementById("role_el")),this._roles.set(r.Wh40k.UnitRole.Vehicle,document.getElementById("role_hs")),this._roles.set(r.Wh40k.UnitRole.Mounted,document.getElementById("role_fa")),this._roles.set(r.Wh40k.UnitRole.Transport,document.getElementById("role_dt")),this._roles.set(r.Wh40k.UnitRole.Fortification,document.getElementById("role_ft"))}render(e,t,n){if(null==this._roster)return;const r=[`${this._roster._cost._points} pts`];for(const e in this._roster._cost._freeformValues)r.push(`${this._roster._cost._freeformValues[e]}${e}`);const i=`${this._roster.name()} (${r.join(", ")})`;null==e||e.appendChild(s.PsJsx.createElement(s.PsJsx.createFragment,null,this.renderOptionsDiv(),s.PsJsx.createElement("h3",null,i),s.PsJsx.createElement("div",{className:"footer"},s.PsJsx.createElement("div",null,"PrettyScribe"),s.PsJsx.createElement("div",null,i)),this._roster._customNotes&&s.PsJsx.createElement("p",null,this._roster._customNotes))),null==t||t.appendChild(s.PsJsx.createElement(s.PsJsx.createFragment,null,this.renderRosterSummary(),this.renderAbilitiesByPhase())),null==n||n.appendChild(this.renderRosterDetails()),(0,o.loadOptionsFromLocalStorage)(),this.loadDatasheetOrderFromLocalStorage(),this.collapseIdenticalUnits()}renderRosterSummary(){var e;return s.PsJsx.createElement(s.PsJsx.createFragment,null,null===(e=this._roster)||void 0===e?void 0:e._forces.map((e=>this.renderForceSummary(e))))}renderForceSummary(e){let t;const n=s.PsJsx.createElement("div",null,e._faction?`${e._catalog} ${e.name()} (${e._faction})`:`${e._catalog} ${e.name()}`,e._configurations.length>0&&s.PsJsx.createElement("ul",null,e._configurations.map((e=>s.PsJsx.createElement("li",null,s.PsJsx.createElement("i",null,e))))),s.PsJsx.createElement("table",{className:"table table-sm table-striped"},s.PsJsx.createElement("thead",{className:"thead-light"},s.PsJsx.createElement("tr",null,s.PsJsx.createElement("th",{scope:"col",style:"width: 20%;"},"NAME"),s.PsJsx.createElement("th",{scope:"col",style:"width: 15%;"},"ROLE"),s.PsJsx.createElement("th",{scope:"col",style:"width: 55%;"},"MODELS"),s.PsJsx.createElement("th",{scope:"col",style:"width: 5%;"},"POINTS"))),s.PsJsx.createElement("tbody",{ref:e=>{t=e}},e._units.map(((e,t)=>s.PsJsx.createElement("tr",{"data-index":t},s.PsJsx.createElement("td",null,e.nameWithExtraCosts()),s.PsJsx.createElement("td",null,r.Wh40k.UnitRoleToString[e._role]),s.PsJsx.createElement("td",null,this.renderModelList(e)),s.PsJsx.createElement("td",null,e._cost._points.toString())))))),s.PsJsx.createElement("button",{id:"reset-order-button",className:"d-none btn btn-secondary d-print-none",onclick:e=>this.resetDatasheetOrder(t)},"Reset datasheet order"));return this.makeForceSummaryListItemsDraggable(t),n}makeForceSummaryListItemsDraggable(e){for(const t of e.children)t.draggable=!0,t.classList.add("draggable");let t,n;e.addEventListener("dragstart",(e=>{t=e.target.closest("[draggable]"),e.dataTransfer.effectAllowed="move"})),e.addEventListener("dragover",(e=>{e.preventDefault();const t=e.target.closest("[draggable]");n!==t&&(null==n||n.classList.remove("draggable_drop_target_top"),null==t||t.classList.add("draggable_drop_target_top"),n=t)})),e.addEventListener("drop",(e=>{e.preventDefault(),null==n||n.classList.remove("draggable_drop_target_top");const r=e.target.closest("[draggable]");if(!t||t===r)return;const i=t.parentElement;i.insertBefore(t,r),this.orderDatasheetsToMatchSummary(i),this.collapseIdenticalUnits(),this.saveDatasheetOrderToLocalStorage()}))}orderDatasheetsToMatchSummary(e){const t=e.children;let n=!0;for(let e=0;e0){const i=t[e-1].dataset.index||-1;n&&(n=+(r||0)>+i)}const i=document.querySelector(`.wh40k_unit_sheet[data-index="${r}"]`);i&&(i.style.order=String(e))}const r=document.querySelector("#reset-order-button");n?null==r||r.classList.add("d-none"):null==r||r.classList.remove("d-none")}collapseIdenticalUnits(){var e,t;const n=document.querySelectorAll(".wh40k_unit_sheet"),r=Array.from(n).sort(((e,t)=>+e.style.order-+t.style.order));let i=null;for(const n of r){n.classList.remove("d-none");const r=n.querySelector("div.unit_count > span");if(i&&(null==i?void 0:i.dataset.hash)===n.dataset.hash){i.classList.add("d-none");const t=i.querySelector("div.unit_count > span"),n=+((null==t?void 0:t.dataset.count)||"");r.dataset.count=String(n+1),null===(e=r.parentElement)||void 0===e||e.classList.remove("d-none")}else r.dataset.count=String(1),null===(t=r.parentElement)||void 0===t||t.classList.add("d-none");i=n}}saveDatasheetOrderToLocalStorage(){try{const e=document.querySelectorAll("tr.draggable"),t=Array.from(e).map((e=>e.dataset.index));(0,o.saveOptionToLocalStorage)(`40k-order-${this._rosterId}`,JSON.stringify(t))}catch(e){console.warn("Error in saveDatasheetOrderToLocalStorage",e)}}loadDatasheetOrderFromLocalStorage(){var e;try{const t=JSON.parse(window.localStorage[`40k-order-${this._rosterId}`]||"[]"),n=null===(e=document.querySelector("tr.draggable"))||void 0===e?void 0:e.parentElement;if(t.length){const e=Array.from(n.children);for(let r=0;r+(e.dataset.index||0)-+(t.dataset.index||0)));for(const n of t)e.appendChild(n);this.orderDatasheetsToMatchSummary(e),this.collapseIdenticalUnits()}catch(e){console.warn("Error in resetDatasheetOrder",e)}}renderOptionsDiv(){const e=s.PsJsx.createElement("div",{className:"wh40k_options_div d-print-none",id:"wh40k_options_div"}),t=e.appendChild(s.PsJsx.createElement("span",null));(0,o.renderOptionsToggle)(t),(0,o.renderCheckboxOption)(e,"showPhaseAbilities","Show abilities by phase",(e=>{const t=document.getElementById("wh40k_abilities_list");t&&(e.target.checked?t.classList.remove("d-none"):t.classList.add("d-none"))})),(0,o.renderCheckboxOption)(e,"showUpgradeCosts","Show upgrade costs",(e=>{const t=document.getElementsByClassName("wh40k_upgrade_cost");for(const n of t)e.target.checked?n.classList.remove("d-none"):n.classList.add("d-none")})),(0,o.renderCheckboxOption)(e,"showArmyRules","Show army rules",(e=>{const t=document.getElementById("all-army-rules");e.target.checked?null==t||t.classList.remove("d-none"):null==t||t.classList.add("d-none")}),!0),(0,o.renderCheckboxOption)(e,"singleColumnDatasheets","Single-Column Datasheets",(e=>{e.target.checked?document.body.classList.add("single_column"):document.body.classList.remove("single_column")}));const n=e.appendChild(s.PsJsx.createElement("span",{className:"wh40k_options_print_subsection"},"Print:"));return(0,o.renderCheckboxOption)(n,"printBigger","Larger Text",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("bigger"):n.classList.remove("bigger")})),(0,o.renderCheckboxOption)(n,"hideElements","Hide Elements",(e=>{const t=document.body;e.target.checked?(t.classList.add("hide_enabled"),t.addEventListener("click",i.toggleHidden)):(t.classList.remove("hide_enabled"),t.removeEventListener("click",i.toggleHidden))})),(0,o.renderCheckboxOption)(n,"datasheetPageBreaks","One Datasheet per Page",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("page_break"):n.classList.remove("page_break")})),e}renderAbilitiesByPhase(){if(!this._roster)return;const e={},t={};for(const n of this._roster._forces)for(const r of n._units)for(const n of Object.values(r._abilities))for(const[i,o]of n.entries()){const n=[...o.matchAll(/(?:before the first turn begins|set up|Reinforcements|(?:Command|Movement|Psychic|Shooting|Charge|Fight|Morale) phase)/gi)];if(0===n.length)continue;const a=s.PsJsx.createElement("div",{className:"hide_able"},s.PsJsx.createElement("b",null,r.name())," - ",s.PsJsx.createElement("b",null,i)," - ");let l=o;for(const r of n){if(!r.index)continue;const n=r[0].toLocaleLowerCase();let c=n;switch(n){case"before the first turn begins":c="pre-game phase";break;case"set up":o.includes("reinforcements")||(c="pre-game phase");break;case"reinforcements":c="movement phase"}if(o.toLocaleLowerCase().includes("as if it were your "+c))continue;const u=r.index-(o.length-l.length);u>0&&a.appendChild(document.createTextNode(l.substring(0,u)));const d=e[c]=e[c]||[],h=t[c]=t[c]||[];h.includes(i)||(h.push(i),d.push(a)),a.appendChild(s.PsJsx.createElement("u",null,r[0]));const f=u+n.length;l=l.substring(f)}l.length>0&&a.appendChild(document.createTextNode(l))}const n=["pre-game phase","command phase","movement phase","psychic phase","shooting phase","charge phase","fight phase","morale phase"].filter((t=>!!e[t]));return s.PsJsx.createElement("div",{id:"wh40k_abilities_list",className:"d-none"},s.PsJsx.createElement("h3",null,"Abilities by Phase"),0===n.length?"No phase-specific abilities in roster":n.map((t=>s.PsJsx.createElement(s.PsJsx.createFragment,null,s.PsJsx.createElement("h4",null,t),e[t].map((e=>e.cloneNode(!0)))))))}renderRosterDetails(){if(!this._roster)return;const e=new Map,t=new Map;return s.PsJsx.createElement(s.PsJsx.createFragment,null,s.PsJsx.createElement("div",{className:"page_break",style:"display: flex; flex-direction: column;"},this._roster._forces.map((n=>s.PsJsx.createElement(s.PsJsx.createFragment,null,this._roster._forces.length>1&&s.PsJsx.createElement("h3",null,s.PsJsx.createElement("div",{style:"page-break-before: always;"},s.PsJsx.createElement("p",null,n._catalog,n._faction&&` (${n._faction})`))),a(e,n._catalog,n._rules),a(t,n._faction,n._factionRules),n._units.map(((e,t)=>this.renderUnit(e,t))))))),s.PsJsx.createElement("div",{id:"all-army-rules",style:"page-break-before: always;"},this.renderRules(e),this.renderRules(t)))}renderUnit(e,t){var n;return s.PsJsx.createElement("div",{className:"wh40k_unit_sheet","data-hash":(e.hash()>>>0).toString(16),"data-name":e.name(),"data-index":String(t),style:`order: ${t};`},s.PsJsx.createElement("table",{className:"table table-sm table-striped"},s.PsJsx.createElement("thead",{className:"table-dark unit_header"},s.PsJsx.createElement("tr",{className:"hide_able"},s.PsJsx.createElement("td",{scope:"col",colspan:"2",style:"width: 10%;"},s.PsJsx.createElement("div",{className:"unit_costs"},s.PsJsx.createElement("span",null,(null===(n=this._roles.get(e._role))||void 0===n?void 0:n.cloneNode())||"-"),s.PsJsx.createElement("span",null,e._cost._points.toString()))),s.PsJsx.createElement("td",{scope:"col",colspan:"16",style:"width: 80%;"},e.name()),s.PsJsx.createElement("td",{scope:"col",colspan:"2",style:"width: 10%;"},s.PsJsx.createElement("div",{className:"unit_costs unit_count"},s.PsJsx.createElement("span",{className:"unit_count","data-count":"1"})))),s.PsJsx.createElement("tr",null,[...Array(20).keys()].map((e=>s.PsJsx.createElement("td",{colspan:"1",style:"width: 5%; padding: 0px;"})))),this.renderNotesHead("Unit notes",e)),s.PsJsx.createElement("thead",null,s.PsJsx.createElement("tr",null,s.PsJsx.createElement("td",{colspan:"20",className:"subTableTd"},s.PsJsx.createElement("div",null,this.renderProfilesTables(e),s.PsJsx.createElement("table",{className:"table table-sm table-striped"},!e._abilities.Abilities&&e._rules.size>0&&this.renderUnitAbilitiesAndRules("Abilities",new Map,e._rules),Object.entries(e._abilities).sort().map((([t,n])=>this.renderUnitAbilitiesAndRules(t,n,"Abilities"===t?e._rules:void 0)))))))),s.PsJsx.createElement("thead",{className:"info_row keywords_row"},s.PsJsx.createElement("tr",{class:"hide_able"},s.PsJsx.createElement("td",{colspan:"20"},s.PsJsx.createElement("div",{class:"wh40k_keywords_and_factions"},s.PsJsx.createElement("div",{class:"wh40k_keywords"},s.PsJsx.createElement("div",null,"Keywords"),s.PsJsx.createElement("div",null,Array.from(e._keywords).sort(r.Wh40k.Compare).join(", ").toLocaleUpperCase())),s.PsJsx.createElement("div",{class:"wh40k_factions"},s.PsJsx.createElement("div",null,"Factions"),s.PsJsx.createElement("div",null,Array.from(e._factions).sort(r.Wh40k.Compare).join(", ").toLocaleUpperCase())))))),s.PsJsx.createElement("thead",{className:"info_row"},s.PsJsx.createElement("tr",{class:"hide_able"},s.PsJsx.createElement("td",{scope:"col",colspan:"2",style:"width: 10%;"},"MODELS"),s.PsJsx.createElement("td",{scope:"col",colspan:"18",style:"width: 90%;"},s.PsJsx.createElement("div",null,this.renderModelList(e)))))))}renderProfilesTables(e){const t=Object.entries(e._profileTables).sort(((e,t)=>r.Wh40k.CompareProfileTableName(e[0],t[0]))).map((([e,t])=>[t,"Unit"===e?"wh40k_unit_profile_table":"wh40k_weapon_profile_table"]));return s.PsJsx.createElement("div",null,t.map((([e,t])=>s.PsJsx.createElement("div",{class:t},s.PsJsx.createElement("div",{className:"hide_able"},e._headers.map((e=>s.PsJsx.createElement("div",null,this.renderProfileTableHeaderCell(e))))),e._contents.map((e=>s.PsJsx.createElement("div",{className:"hide_able"},e.map((e=>s.PsJsx.createElement("div",null,"-"===e?"":e))))))))))}renderProfileTableHeaderCell(e){return"Ranged Weapons"===e||"Melee Weapons"===e?s.PsJsx.createElement(s.PsJsx.createFragment,null,s.PsJsx.createElement("span",{class:"desktop-only"},e),s.PsJsx.createElement("span",{class:"mobile-only"},e.replace(" Weapons",""))):"Range"===e?s.PsJsx.createElement(s.PsJsx.createFragment,null,s.PsJsx.createElement("span",{class:"desktop-only"},e),s.PsJsx.createElement("span",{class:"mobile-only"},"Rng")):s.PsJsx.createElement(s.PsJsx.createFragment,null,e)}renderUnitAbilitiesAndRules(e,t,n){return s.PsJsx.createElement(s.PsJsx.createFragment,null,s.PsJsx.createElement("thead",{className:"info_row table-active"},s.PsJsx.createElement("tr",{className:"header_row"},s.PsJsx.createElement("th",null,e))),s.PsJsx.createElement("tbody",{className:"info_row"},s.PsJsx.createElement("tr",null)," ",n&&n.size>0&&s.PsJsx.createElement("tr",{className:"hide_able"},s.PsJsx.createElement("td",{scope:"col",style:"width: 100%;"},s.PsJsx.createElement("div",null,s.PsJsx.createElement("div",null,s.PsJsx.createElement("b",null,Array.from(n.keys()).sort(r.Wh40k.Compare).join(", ")))))),Array.from(t.keys()).sort(r.Wh40k.Compare).map((e=>s.PsJsx.createElement("tr",{className:"hide_able"},s.PsJsx.createElement("td",{scope:"col",style:"width: 100%;"},s.PsJsx.createElement("div",null,s.PsJsx.createElement("div",{className:"hide_able"},s.PsJsx.createElement("b",null,`${e.toUpperCase()}: `),t.get(e)||"??"))))))))}renderModelList(e){return e._models.map((e=>s.PsJsx.createElement("div",null,e._count>1?`${e._count}x `:"",e.name(),e.getDedupedWeaponsAndUpgrades().length>0&&s.PsJsx.createElement(s.PsJsx.createFragment,null," (",e.getDedupedWeaponsAndUpgrades().map(((e,t)=>s.PsJsx.createElement(s.PsJsx.createFragment,null,t>0?", ":"",e._count>1?`${e._count}x `:"",e.selectionName(),e._cost.hasValues()&&s.PsJsx.createElement("span",{className:"wh40k_upgrade_cost d-none"},` ${e._cost.toString()}`)))),")"))))}renderRules(e){return 0===e.size?null:s.PsJsx.createElement(s.PsJsx.createFragment,null,Array.from(e.entries()).map((([e,t])=>s.PsJsx.createElement("div",{className:"wh40k_rules"},s.PsJsx.createElement("h3",null,e),Array.from(t.entries()).map((e=>s.PsJsx.createElement("div",{className:"hide_able"},s.PsJsx.createElement("b",null,e[0]),s.PsJsx.createElement("p",null,e[1]))))))))}renderNotesHead(e,t){return t.notes()?s.PsJsx.createElement("thead",{className:"info_row"},s.PsJsx.createElement("tr",null,s.PsJsx.createElement("td",{style:"width: 10%",colspan:"2"},e),s.PsJsx.createElement("td",{style:"width: 90%",colspan:"18"},t._customNotes))):null}}},964:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RendererAoS=void 0;const r=n(774);t.RendererAoS=class{constructor(e){this._roster=null,this._roster=e}render(e,t,n){if(null!=this._roster){if(e){e.innerHTML="

"+this._roster._name.toUpperCase()+" ("+this._roster._points+" pts, "+this._roster._commandPoints+" CP)

";let t=document.createElement("h3");t.textContent="ROSTER",e.appendChild(t)}for(let e of this._roster._forces){const i=document.createElement("div");i&&(i.innerHTML="

"+e._catalog+" "+e._name+"

"),t&&t.appendChild(i);const o=[{name:"NAME",width:"35%"},{name:"ROLE",width:"15%"},{name:"SELECTIONS",width:"40%"},{name:"POINTS",width:"10%"}],s=this.createTable(o);s.classList.add("table","table-sm","aos_font"),i.appendChild(s);let a=document.createElement("tbody");s.appendChild(a);for(let t of e._units){let e=document.createElement("tr"),n=document.createElement("td");n.innerHTML=`${t._name}`;let i=document.createElement("td");i.innerHTML=r.AoSUnitRoleToString[t._role];let o=document.createElement("td");o.innerHTML="";for(const e of t._selections)o.innerHTML+=e+"
";let s=document.createElement("td");s.textContent=t._points.toString(),e.appendChild(n),e.appendChild(i),e.appendChild(o),e.appendChild(s),a.appendChild(e)}let l=document.createElement("div"),c=document.createElement("h3");if(c.textContent=e._allegiance._name.toUpperCase(),l.appendChild(c),e._allegiance._commandAbilities.size>0&&this.renderAbilityMap(l,"ABILITIES",e._allegiance._commandAbilities),e._allegiance._battleTraits.size>0&&this.renderAbilityMap(l,"BATTLE TRAITS",e._allegiance._battleTraits),e._allegiance._spells.length>0){let t=document.createElement("h4");t.textContent="ALLEGIANCE SPELLS",l.append(t),this.renderSpells(l,e._allegiance._spells)}if(e._allegiance._extraProfiles.length>0){let t="";for(let n of e._allegiance._extraProfiles)if(1==n._value._fields.size){if(t!=n._value._typeName){let e=document.createElement("h4");l.appendChild(e),e.textContent=n._value._typeName.toUpperCase(),t=n._value._typeName}const e=n._value._fields.values();let r=document.createElement("p");r.classList.add("aos_font"),r.innerHTML=`${n._name}: ${e.next().value}`,l.appendChild(r)}else console.log("Table profiles not implemented. "+n._value._typeName)}if(e._grandStrategy&&""!=e._grandStrategy._name){let t=document.createElement("h3");l.appendChild(t),t.textContent="GRAND STRATEGY";let n=document.createElement("div"),r=document.createElement("h4");r.textContent=e._grandStrategy._name;let i=document.createElement("p");i.textContent=e._grandStrategy._description,n.appendChild(r),n.appendChild(i),l.appendChild(n)}if(e._triumph&&""!=e._triumph._name){let t=document.createElement("h3");l.appendChild(t),t.textContent="TRIUMPH";let n=document.createElement("div"),r=document.createElement("h4");r.textContent=e._triumph._name;let i=document.createElement("p");i.textContent=e._triumph._description,n.appendChild(r),n.appendChild(i),l.appendChild(n)}if(e._realmOfBattle&&e._realmOfBattle._name.length>0){let t=document.createElement("h3");if(l.appendChild(t),t.textContent="REALM OF BATTLE ("+e._realmOfBattle._name+")",e._realmOfBattle._spells.length>0){let t=document.createElement("h4");t.textContent="SPELLS",l.append(t),this.renderSpells(l,e._realmOfBattle._spells)}if(e._realmOfBattle._commandAbilities.size>0&&this.renderAbilityMap(l,"COMMAND ABILITIES",e._realmOfBattle._commandAbilities),e._realmOfBattle._rules.length>0){let t=document.createElement("h4");t.textContent="SPECIAL RULES",l.append(t);for(let t of e._realmOfBattle._rules){let e=document.createElement("div"),n=document.createElement("p");n.textContent=t._name+": "+t._description,e.appendChild(n),l.appendChild(e)}}}for(let t of e._rules){let e=document.createElement("h3");l.appendChild(e),e.textContent="RULES";let n=document.createElement("div"),r=document.createElement("h4");r.textContent=t[0];let i=document.createElement("p");i.textContent=t[1],n.appendChild(r),n.appendChild(i),l.appendChild(n)}if(e._battleTactics.size>0){let t=document.createElement("h3");t.textContent="BATTLE TACTICS",l.appendChild(t);const n=[{name:"NAME",width:"20%"},{name:"DESCRIPTION",width:"80%"}],r=this.createTable(n);r.classList.add("table","table-sm","aos_table","aos_font");let i=document.createElement("tbody");r.appendChild(i);for(let t of e._battleTactics){let e=document.createElement("tr"),n=document.createElement("td");n.textContent=t[0];let r=document.createElement("td");r.textContent=t[1],e.appendChild(n),e.appendChild(r),i.appendChild(e)}l.appendChild(r)}for(let t of e._battalions){let e=document.createElement("h3");l.appendChild(e),e.textContent=t._name.toUpperCase();for(let e of t._abilities){let t=document.createElement("div"),n=document.createElement("h4");n.textContent=e[0];let r=document.createElement("p");r.textContent=e[1],t.appendChild(n),t.appendChild(r),l.appendChild(t)}}if(!n)continue;n.appendChild(l);let u=document.createElement("hr");u.classList.add("aos_dark"),n.appendChild(u);for(let t of e._units){n.appendChild(this.renderUnitHtml(t));let e=document.createElement("hr");e.classList.add("aos_dark"),n.appendChild(e)}}}}createTable(e){const t=document.createElement("table"),n=document.createElement("thead");t.appendChild(n),n.classList.add("aos_light");const r=document.createElement("tr");return n.appendChild(r),e.forEach((e=>{let t=document.createElement("th");t.scope="col",t.textContent=e.name,t.style.width=e.width,r.appendChild(t)})),t}internalKeyword(e){return e.toUpperCase()!=e}renderUnitHtml(e){let t=document.createElement("div");t.classList.add("container-fluid","aos_unit");let n=document.createElement("div");n.classList.add("p-2","mb-2","aos_medium","text-center","text-uppercase","text-black"),n.innerHTML=`${e._name}`,t.append(n);let r=document.createElement("div");if(r.classList.add("row"),t.append(r),e.isNormalUnit()){let t=document.createElement("div");t.classList.add("col-3"),t.innerHTML=`
\n

${e._move}

\n

${e._wounds}

\n

${e._bravery}

\n

${e._save}

\n
`,r.append(t)}let i=document.createElement("div");i.classList.add("col"),r.appendChild(i);let o=document.createElement("table");o.classList.add("table","table-sm","aos_table","aos_font","text-center");let s=document.createElement("thead");o.appendChild(s),o.innerHTML='\n Missile Weapons\n Range\n Attacks\n To Hit\n To Wound\n Rend\n Damage\n ';let a=document.createElement("tbody");o.appendChild(a);let l=document.createElement("table");l.classList.add("table","table-sm","aos_table","aos_font","text-center"),s=document.createElement("thead"),l.appendChild(s),l.innerHTML='\n Melee Weapons\n Range\n Attacks\n To Hit\n To Wound\n Rend\n Damage\n ';let c=document.createElement("tbody");l.appendChild(c);let u=!1,d=!1;for(let t of e._weapons)if("Missile"===t._type){let e=document.createElement("tr");e.innerHTML=`${t._name}${t._range}${t._attacks}\n ${t._toHit}${t._toWound}${t._rend}${t._damage}`,a.appendChild(e),u=!0}else if("Melee"===t._type){let e=document.createElement("tr");e.innerHTML=`${t._name}${t._range}${t._attacks}\n ${t._toHit}${t._toWound}${t._rend}${t._damage}`,c.appendChild(e),d=!0}if(u&&i.appendChild(o),d&&i.appendChild(l),e._woundTracker&&e._woundTracker._labels.length>0){let t=[];const n=(1/e._woundTracker._labels.length*100).toString()+"%";for(let r of e._woundTracker._labels)t.push({name:r,width:n});const r=this.createTable(t);r.classList.add("table","table-sm","aos_table","aos_font","text-center"),i.appendChild(r);let o=document.createElement("tbody");r.appendChild(o);for(let t of e._woundTracker._table){let e=document.createElement("tr");for(let n of t){let t=document.createElement("td");t.textContent=n,e.appendChild(t)}o.appendChild(e)}}if(e._abilities.size>0&&this.renderAbilityMap(i,"ABILITIES",e._abilities),e._commandAbilities.size>0&&this.renderAbilityMap(i,"COMMAND ABILITIES",e._commandAbilities),e._commandTraits.size>0&&this.renderAbilityMap(i,"COMMAND TRAITS",e._commandTraits),e._magic.size>0&&this.renderAbilityMap(i,"MAGIC",e._magic),e._spells.length>0){let t=document.createElement("h4");t.textContent="SPELLS",i.appendChild(t),this.renderSpells(i,e._spells)}if(e._prayers.length>0){let t=document.createElement("h4");t.textContent="PRAYERS",i.appendChild(t);const n=[{name:"NAME",width:"20%"},{name:"ANSWER VALUE",width:"10%"},{name:"RANGE",width:"10%"},{name:"DESCRIPTION",width:"60%"}],r=this.createTable(n);r.classList.add("table","table-sm","aos_table","aos_font");let o=document.createElement("tbody");r.appendChild(o);for(let t of e._prayers){let e=document.createElement("tr"),n=document.createElement("td");n.textContent=t._name;let r=document.createElement("td");r.textContent=t._answerValue.toString();let i=document.createElement("td");i.textContent=t._range.toString();let s=document.createElement("td");s.textContent=t._description,e.appendChild(n),e.appendChild(r),e.appendChild(i),e.appendChild(s),o.appendChild(e)}i.appendChild(r)}e._artefacts.size>0&&this.renderAbilityMap(i,"ARTEFACTS",e._artefacts);let h="";for(let t of e._extraProfiles)if(1==t._value._fields.size){if(h!=t._value._typeName){let e=document.createElement("h4");i.appendChild(e),e.textContent=t._value._typeName.toUpperCase(),h=t._value._typeName}const e=t._value._fields.values();let n=document.createElement("p");n.classList.add("aos_font"),n.innerHTML=`${t._name}: ${e.next().value}`,i.appendChild(n)}else console.log("Table profiles not implemented. "+t._value._typeName);if(e._keywords.size>0){let n=document.createElement("div");n.classList.add("container-fluid");let r=document.createElement("div");r.classList.add("row"),n.appendChild(r);let i=document.createElement("div");i.classList.add("col-5","border","aos_dark","text-center"),i.innerHTML="KEYWORDS",r.appendChild(i);let o="",s="";for(let t of e._keywords)this.internalKeyword(t)||(s+=o,s+=t,o=", ");let a=document.createElement("div");a.classList.add("col","border","text-left","text-uppercase"),a.innerText=s,r.appendChild(a),t.appendChild(n)}return t}renderAbilityMap(e,t,n){let r=document.createElement("h4");r.textContent=t,e.appendChild(r);for(let e of n){let t=document.createElement("p");t.classList.add("aos_font"),t.innerHTML=`${e[0]}: ${e[1]}`,r.appendChild(t)}}renderSpells(e,t){const n=this.createTable([{name:"NAME",width:"25%"},{name:"CASTING VALUE",width:"15%"},{name:"RANGE",width:"10%"},{name:"DESCRIPTION",width:"50%"}]);n.classList.add("table","table-sm","aos_font");let r=document.createElement("tbody");n.appendChild(r);for(let e of t){let t=document.createElement("tr"),n=document.createElement("td");n.textContent=e._name;let i=document.createElement("td");i.textContent=e._castingValue.toString();let o=document.createElement("td");o.textContent=e._range.toString();let s=document.createElement("td");s.textContent=e._description,t.appendChild(n),t.appendChild(i),t.appendChild(o),t.appendChild(s),r.appendChild(t)}e.appendChild(n)}}},66:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RendererHH2=void 0;const r=n(980);class i{constructor(e){this._roster=null,this._roles=new Map,this._infantryLabelWidthsNormalized=[.2,.2,.05,.05,.05,.05,.05,.05,.05,.05,.05,.05,.1],this._vehicleLabelWidthsNormalized=[.2,.2,.05,.05,.05,.05,.05,.05,.2,.1],this._knightLabelWidthsNormalized=[.2,.2,.05,.05,.05,.05,.05,.05,.05,.05,.05,.05,.1],this._fortificationLabelWidthsNormalized=[.2,.2,.05,.05,.05,.05,.05,.2,.15],this._weaponLabelWidthNormalized=[.25,.05,.05,.05,.15,.35],this._psychicWeaponLabelWidthNormalized=[.25,.05,.05,.05,.15,.35],this._psychicPowerLabelWidthNormalized=[.25,.75],this._wargearLabelWidthNormalized=[.25,.75],this._roster=e,this._roles.set(r.HorusHeresy.UnitRole.HQ,document.getElementById("role_hq")),this._roles.set(r.HorusHeresy.UnitRole.TR,document.getElementById("role_tr")),this._roles.set(r.HorusHeresy.UnitRole.EL,document.getElementById("role_el")),this._roles.set(r.HorusHeresy.UnitRole.FA,document.getElementById("role_fa")),this._roles.set(r.HorusHeresy.UnitRole.HS,document.getElementById("role_hs")),this._roles.set(r.HorusHeresy.UnitRole.FL,document.getElementById("role_fl")),this._roles.set(r.HorusHeresy.UnitRole.DT,document.getElementById("role_dt")),this._roles.set(r.HorusHeresy.UnitRole.FT,document.getElementById("role_ft")),this._roles.set(r.HorusHeresy.UnitRole.LW,document.getElementById("role_lw")),this._roles.set(r.HorusHeresy.UnitRole.PR,document.getElementById("role_lw"))}render(e,t,n){if(null!=this._roster){if(e){this.renderOptionsDiv(e);const t=[`${this._roster._cost._points} pts`],n=`${this._roster._name} (${t.join(", ")})`;e.appendChild(document.createElement("h3")).appendChild(document.createTextNode(n));const r=e.appendChild(document.createElement("div"));r.classList.add("footer"),r.appendChild(document.createElement("div")).appendChild(document.createTextNode("PrettyScribe")),r.appendChild(document.createElement("div")).appendChild(document.createTextNode(n))}t&&this.renderRosterSummary(t),n&&this.renderRosterDetails(n),this.loadOptionsFromLocalStorage()}}renderRosterSummary(e){if(this._roster)for(const t of this._roster._forces){const n=document.createElement("div");t._faction?n.appendChild(document.createTextNode(`${t._catalog} ${t._name} (${t._faction})`)):n.appendChild(document.createTextNode(`${t._catalog} ${t._name}`)),e.appendChild(n);const i=document.createElement("table");i.classList.add("table","table-sm","table-striped");const o=document.createElement("thead");i.appendChild(o),o.classList.add("thead-light");const s=document.createElement("tr");o.appendChild(s),[{name:"NAME",w:"20%"},{name:"ROLE",w:"15%"},{name:"MODELS",w:"55%"},{name:"POINTS",w:"5%"}].forEach((e=>{let t=document.createElement("th");t.scope="col",t.appendChild(document.createTextNode(e.name)),t.style.width=e.w,s.appendChild(t)})),n.appendChild(i);let a=document.createElement("tbody");i.appendChild(a);for(let e of t._units){const t=document.createElement("tr");t.appendChild(document.createElement("td")).appendChild(document.createTextNode(e._name)),t.appendChild(document.createElement("td")).appendChild(document.createTextNode(r.HorusHeresy.UnitRoleToString[e._role]));const n=t.appendChild(document.createElement("td"));this.renderModelList(n,e),t.appendChild(document.createElement("td")).appendChild(document.createTextNode(e._points.toString())),a.appendChild(t)}}}renderOptionsDiv(e){const t=e.appendChild(document.createElement("div"));t.classList.add("wh40k_options_div","d-print-none"),t.id="wh40k_options_div";const n=t.appendChild(document.createElement("span"));n.classList.add("wh40k_options_toggle"),n.id="wh40k_options_toggle";const r="[−] Options:";n.appendChild(document.createTextNode(r)),n.addEventListener("click",(e=>{const t=document.getElementById("wh40k_options_div"),n=document.getElementById("wh40k_options_toggle");t&&n&&(t.classList.contains("hide_options")?(t.classList.remove("hide_options"),n.innerText=r,this.saveOptionToLocalStorage("option-toggle-hidden","false")):(t.classList.add("hide_options"),n.innerText="[+] Options",this.saveOptionToLocalStorage("option-toggle-hidden","true")))})),this.renderCheckboxOption(t,"showUpgradeCosts","Show upgrade costs",(e=>{const t=document.getElementsByClassName("wh40k_upgrade_cost");for(const n of t)e.target.checked?n.classList.remove("d-none"):n.classList.add("d-none")})),this.renderCheckboxOption(t,"collateDatasheets","Collate Detachment Datasheets",(e=>{const t=document.getElementById("collated_sheets"),n=document.getElementById("detachment_sheets");t&&n&&(e.target.checked?(t.classList.remove("d-none"),n.classList.add("d-none")):(t.classList.add("d-none"),n.classList.remove("d-none")))}));const i=t.appendChild(document.createElement("span"));i.classList.add("wh40k_options_print_subsection"),i.appendChild(document.createTextNode("Print:")),this.renderCheckboxOption(i,"printBigger","Larger Text",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("bigger"):n.classList.remove("bigger")})),this.renderCheckboxOption(i,"hideElements","Hide Elements",(e=>{const t=document.body;e.target.checked?(t.classList.add("hide_enabled"),t.addEventListener("click",l)):(t.classList.remove("hide_enabled"),t.removeEventListener("click",l))})),this.renderCheckboxOption(i,"datasheetPageBreaks","One Datasheet per Page",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("page_break"):n.classList.remove("page_break")}))}renderCheckboxOption(e,t,n,r){const i=e.appendChild(document.createElement("div"));i.classList.add("wh40k_option");const o=i.appendChild(document.createElement("input"));o.setAttribute("type","checkbox"),o.setAttribute("name",t),o.setAttribute("id",t),o.addEventListener("input",r),o.addEventListener("change",(e=>this.saveCheckboxToLocalStorage(t)));const s=i.appendChild(document.createElement("label"));s.setAttribute("for",t),s.appendChild(document.createTextNode(` ${n}`))}saveCheckboxToLocalStorage(e){const t=document.getElementById(e);t&&this.saveOptionToLocalStorage(`option-checkbox-${e}`,t.checked)}saveOptionToLocalStorage(e,t){try{window.localStorage[e]=t}catch(e){}}loadOptionsFromLocalStorage(){var e;try{for(let t=0;te._role!=t._role?e._role-t._role:e._name!=t._name?r.HorusHeresy.Compare(e._name,t._name):e._points-t._points)),this.renderDatasheets(o,s);let u=document.createElement("div");u.style.pageBreakBefore="always",this.printRules(t,u),this.printRules(n,u),e.appendChild(u)}renderDatasheets(e,t){let n=0;for(let r=0;r1?` (${n})`:""),""],[.1,.8,.1]));const h=c.appendChild(document.createElement("tr"));for(let e=0;e<20;e++){const e=h.appendChild(document.createElement("td"));e.colSpan=1,e.style.width="5%",e.style.padding="0"}let f=function(e,t){if(!t.notes())return null;const n=document.createElement("thead");return n.classList.add("info_row"),n.appendChild(o(["Unit notes",t._customNotes],[.1,.9],!1)),n}(0,t);if(f&&l.appendChild(f),t._modelStats.length>0){const e=function(e){let t=new Map;const n=e.filter((e=>e instanceof r.HorusHeresy.Vehicle));t.set("Vehicles",n);const i=e.filter((e=>e instanceof r.HorusHeresy.Knight));t.set("Knights",i);const o=e.filter((e=>e instanceof r.HorusHeresy.Fortification));t.set("Fortifications",o);const s=e.filter((e=>e instanceof r.HorusHeresy.Model));return t.set("Models",s),t}(t._modelStats),n=e.get("Models");if(null!=n&&n.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._infantryLabels,this._infantryLabelWidthsNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of n){let n=t;e.append(o([n._name,n._type,n._move.toString(),n._ws.toString(),n._bs.toString(),n._str.toString(),n._toughness.toString(),n._wounds.toString(),n._initiative.toString(),n._attacks.toString(),n._leadership.toString(),n._save],this._infantryLabelWidthsNormalized))}}const s=e.get("Vehicles");if(null!=s&&s.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._vehicleLabels,this._vehicleLabelWidthsNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of s){let n=t;e.append(o([n._name,n._type,n._move.toString(),n._bs.toString(),n._front.toString(),n._side.toString(),n._rear.toString(),n._hp.toString(),n._capacity.toString()],this._vehicleLabelWidthsNormalized))}}const a=e.get("Knights");if(null!=a&&a.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._knightLabels,this._knightLabelWidthsNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of a){let n=t;e.append(o([n._name,n._type,n._move.toString(),n._ws.toString(),n._bs.toString(),n._str.toString(),n._front.toString(),n._side.toString(),n._rear.toString(),n._hp.toString(),n._initiative.toString(),n._attacks.toString(),n._hp.toString()],this._knightLabelWidthsNormalized))}}const u=e.get("Fortifications");if(null!=u&&u.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._fortificationLabels,this._fortificationLabelWidthsNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of u){let n=t;e.append(o([n._name,n._type,n._bs.toString(),n._front.toString(),n._side.toString(),n._rear.toString(),n._hp.toString(),n._capacity.toString()],this._fortificationLabelWidthsNormalized))}}}f=s("Model notes",t._models),f&&l.appendChild(f);const p=t.weapons();if(p.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._weaponLabels,this._weaponLabelWidthNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of p){let n=t._type.split(","),r=n[0].trim(),i=document.createElement("div");n.forEach(((e,t)=>{let n=e.trim();if(t>1&&i.appendChild(document.createTextNode(", ")),0!=t){let e=document.createElement("a");e.classList.add("hh2-rule-link"),e.href="#"+n,e.text=n,i.appendChild(e)}})),e.append(o([t.name().toString(),t._range,t._str.toString(),t._ap,r,i],this._weaponLabelWidthNormalized))}}f=s("Weapon notes",p),f&&l.appendChild(f);const _=t.wargear();if(_.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._wargearLabels,this._wargearLabelWidthNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of _)e.append(o([t.name(),t._description],this._wargearLabelWidthNormalized))}f=s("Wargear Item notes",_),f&&l.appendChild(f);const m=t.psychicWeapons();if(m.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._psychicWeaponLabels,this._psychicWeaponLabelWidthNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of m){let n=t._type.split(","),r=n[0].trim(),i=document.createElement("div");n.forEach(((e,t)=>{let n=e.trim();if(t>1&&i.appendChild(document.createTextNode(", ")),0!=t){let e=document.createElement("a");e.classList.add("hh2-rule-link"),e.href="#"+n,e.text=n,i.appendChild(e)}})),e.append(o([t.name().toString(),t._range,t._str.toString(),t._ap,r,i],this._psychicWeaponLabelWidthNormalized))}}f=s("Psychic Weapon notes",m),f&&l.appendChild(f);const g=t.psychicPowers();if(g.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(i._psychicPowerLabels,this._psychicPowerLabelWidthNormalized,!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of g)e.append(o([t.name(),t._description],this._psychicPowerLabelWidthNormalized))}f=s("Psychic Power notes",g),f&&l.appendChild(f);const v=t.warlordTraits();if(v.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(["Warlord Trait","Description"],[.25,.75],!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of v)e.append(o([t.name(),t._description],[.25,.75]))}f=s("Warlord Trait notes",v),f&&l.appendChild(f);const b=t.reactions();if(b.length>0){c=l.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild(o(["Reaction","Description"],[.25,.75],!0));let e=l.appendChild(document.createElement("tbody"));e.append(document.createElement("tr"));for(const t of b)e.append(o([t.name(),t._description],[.25,.75]))}if(t._rules.size>0){const e=Array.from(t._rules.keys()).sort(r.HorusHeresy.Compare),n=t.weaponRules();let i=[];for(const t of e)n.includes(t)||i.push(t);this.renderUnitRules(l,"Rules",i)}c=l.appendChild(document.createElement("thead")),c.classList.add("info_row");const y=Array.from(t._keywords).sort(r.HorusHeresy.Compare).join(", ").toLocaleUpperCase();c.appendChild(o(["Keywords",y],[.1,.9],!1)),c=l.appendChild(document.createElement("thead")),c.classList.add("info_row");const w=document.createElement("div");this.renderModelList(w,t),c.appendChild(o(["MODELS",w],[.1,.9],!1))}renderUnitRules(e,t,n){const r=e.appendChild(document.createElement("thead"));r.classList.add("info_row");const i=document.createElement("div");n.forEach(((e,t)=>{let n=e.trim();if(t>1&&i.appendChild(document.createTextNode(", ")),0!=t){let e=document.createElement("a");e.classList.add("hh2-rule-link"),e.href="#"+n,e.text=n,i.appendChild(e)}})),r.appendChild(o([t,i],[.1,.9],!1))}renderModelList(e,t){for(const n of t._models){const t=e.appendChild(document.createElement("div"));t.appendChild(document.createTextNode((n._count>1?`${n._count}x `:"")+n._name));const r=n.getDedupedWeaponsAndUpgrades();if(0!==r.length){t.appendChild(document.createTextNode(" ("));for(const e of r)if(e!==r[0]&&t.appendChild(document.createTextNode(", ")),t.appendChild(document.createTextNode((e._count>1?`${e._count}x `:"")+e.selectionName())),e._cost.hasValues()){const n=t.appendChild(document.createElement("span"));n.classList.add("wh40k_upgrade_cost","d-none"),n.appendChild(document.createTextNode(` ${e._cost.toString()}`))}t.appendChild(document.createTextNode(")"))}}}printRules(e,t){if(0!==e.size&&t)for(let[n,r]of e.entries()){let e=document.createElement("div");e.classList.add("wh40k_rules");let i=document.createElement("h3");e.appendChild(i),i.appendChild(document.createTextNode(n));for(let t of r){let n=a(document.createElement("div")),r=document.createElement("b");r.id=t[0],r.appendChild(document.createTextNode(t[0]));let i=document.createElement("p");i.appendChild(document.createTextNode(t[1]||"")),n.appendChild(r),n.appendChild(i),e.appendChild(n)}t.appendChild(e)}}}function o(e,t,n=!1){const r=a(document.createElement("tr"));n&&r.classList.add("header_row");for(let i=0,o=0;ie._customNotes)))return null;const n=document.createElement("thead");n.classList.add("info_row");const r=document.createElement("div");for(const e of t){if(!e.notes())continue;const t=r.appendChild(document.createElement("div"));t.appendChild(document.createElement("b")).appendChild(document.createTextNode(`${e.name()}: `)),t.appendChild(document.createTextNode(e._customNotes))}return n.appendChild(o([e,r],[.1,.9],!1)),n}function a(e){return e.classList.add("hide_able"),e}function l(e){let t=e.target;t&&(t=t.closest(".hide_able")),t&&(t.classList.contains("hidden")?t.classList.remove("hidden"):t.classList.add("hidden"))}t.RendererHH2=i,i._infantryLabels=["Model","Type","M","WS","BS","S","T","W","I","A","Ld","Sv",""],i._vehicleLabels=["Model","Type","M","BS","Front","Side","Rear","HP","Capacity",""],i._knightLabels=["Model","Type","M","WS","BS","S","Front","Side","Rear","I","A","HP",""],i._fortificationLabels=["Model","Type","BS","Front","Side","Rear","HP","Capacity",""],i._weaponLabels=["Weapon","Range","Str","AP","Type","Rules"],i._psychicWeaponLabels=["Psychic Weapon","Range","Str","AP","Type","Rules"],i._psychicPowerLabels=["Psychic Power","Description"],i._wargearLabels=["Wargear Item","Description"]},96:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RendererKT21=void 0;const r=n(249),i=n(419),o=n(682),s=n(361),a=n(219);class l{constructor(e){this._descriptionStartX=140,this._descriptionWidth=600,this._roster=null,this._octagon=null,this._specialisms=new Map,this._currentX=0,this._currentY=0,this._maxWidth=0,this._maxHeight=0,this._unitLabelWidthsNormalized=[.25,.05,.05,.05,.05,.05,.05],this._weaponLabelWidthNormalized=[.25,.05,.05,.05,.2,.2],this._spellLabelWidthNormalized=[.25,.75],this._roster=e,this._octagon=document.getElementById("octagon"),this._specialisms.set(r.Specialism.NONE,document.getElementById("role_hq")),this._specialisms.set(r.Specialism.COMBAT,document.getElementById("role_hs")),this._specialisms.set(r.Specialism.STAUNCH,document.getElementById("role_fa")),this._specialisms.set(r.Specialism.MARKSMAN,document.getElementById("role_el")),this._specialisms.set(r.Specialism.SCOUT,document.getElementById("role_tr"))}render(e,t,n){if(null==this._roster)return void console.log("Roster is NULL");if(e){this.renderOptionsDiv(e);const s=`${this._roster.name()} (${this._roster._equipmentPoints} EP)`;e.appendChild(document.createElement("h3")).appendChild(document.createTextNode(s))}let r=new Map,i=new Map;for(let l of this._roster._forces){let c=r.get(l._catalog);c||(c=new Map,r.set(l._catalog,c));let u=i.get(l._catalog);u||(u=new Map,i.set(l._faction,u));const d=document.createElement("div");d&&(l._faction?d.innerHTML="

"+l._faction+" - "+l.name()+"

":d.innerHTML="

"+l.name()+"

"),t&&t.appendChild(d);const h=document.createElement("table");h.classList.add("table"),h.classList.add("table-sm"),h.classList.add("table-striped");const f=document.createElement("thead");h.appendChild(f),f.classList.add("thead-light");const p=document.createElement("tr");f.appendChild(p),[{name:"MODELS",w:"55%"},{name:"EP",w:"5%"}].forEach((e=>{let t=document.createElement("th");t.scope="col",t.innerHTML=e.name,t.style.width=e.w,p.appendChild(t)})),d.appendChild(h);let _=document.createElement("tbody");if(h.appendChild(_),l._leader){let g=document.createElement("tr"),v=document.createElement("td");v.innerHTML=l._leader.nameAndGear();let b=document.createElement("td");b.innerHTML=l._leader.costs().toString(),g.appendChild(v),g.appendChild(b),_.appendChild(g)}for(let y of l._operatives){let w=document.createElement("tr"),C=document.createElement("td");C.innerHTML=y.nameAndGear();let x=document.createElement("td");x.innerHTML=y.costs().toString(),w.appendChild(C),w.appendChild(x),_.appendChild(w)}if(n){const E=document.createElement("div");if(E){const N=document.createElement("p");N.appendChild(document.createTextNode(l.name())),l._faction&&N.appendChild(document.createTextNode(" ("+l._faction+")")),E.appendChild(N)}let S=document.createElement("h3");S.appendChild(E),n.appendChild(S);const k=n.appendChild(document.createElement("div"));k.id="kt_canvas",k.classList.add("d-none");const A=n.appendChild(document.createElement("div"));A.id="kt_html",l._leader&&(this.printOperative(l._leader,null,k),this.printOperativeHtml(l._leader,null,A));let T=null;for(let L of l._operatives)this.printOperative(L,T,k),this.printOperativeHtml(L,T,A),T=L}function m(e,t){for(const n of t)e.set(n[0],n[1])}if(l._rules.size>0&&m(c,l._rules),l._factionRules.size>0&&m(u,l._factionRules),l._leader&&l._leader._rules.size>0&&m(c,l._leader._rules),l._operatives&&l._operatives.length>0)for(const R of l._operatives)R._rules&&R._rules.size>0&&m(c,R._rules)}let o=document.createElement("div");o.style.pageBreakBefore="always",this.printRules(r,o),this.printRules(i,o),n&&n.appendChild(o),(0,a.loadOptionsFromLocalStorage)()}renderOptionsDiv(e){const t=e.appendChild(document.createElement("div"));t.classList.add("wh40k_options_div","d-print-none"),t.id="wh40k_options_div";const n=t.appendChild(document.createElement("span"));(0,a.renderOptionsToggle)(n),(0,a.renderCheckboxOption)(t,"ktWithCanvas","Use old formatting",(e=>{const t=document.getElementById("kt_html"),n=document.getElementById("kt_canvas"),r=document.getElementById("ktHtmlOptions");t&&n&&r&&(e.target.checked?(t.classList.add("d-none"),r.classList.add("d-none"),n.classList.remove("d-none")):(t.classList.remove("d-none"),r.classList.remove("d-none"),n.classList.add("d-none")))}));const r=t.appendChild(document.createElement("span"));r.classList.add("wh40k_options_print_subsection"),r.id="ktHtmlOptions",r.appendChild(document.createTextNode("Print:")),(0,a.renderCheckboxOption)(r,"printBigger","Larger Text",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("bigger"):n.classList.remove("bigger")})),(0,a.renderCheckboxOption)(r,"hideElements","Hide Elements",(e=>{const t=document.body;e.target.checked?(t.classList.add("hide_enabled"),t.addEventListener("click",s.toggleHidden)):(t.classList.remove("hide_enabled"),t.removeEventListener("click",s.toggleHidden))})),(0,a.renderCheckboxOption)(r,"datasheetPageBreaks","One Datasheet per Page",(e=>{const t=document.getElementsByClassName("wh40k_unit_sheet");for(const n of t)e.target.checked?n.classList.add("page_break"):n.classList.remove("page_break")}))}printOperativeHtml(e,t,n){if(e.equal(t))return;const i=n.appendChild(document.createElement("div"));i.classList.add("wh40k_unit_sheet");const a=document.createElement("table");a.classList.add("table","table-sm","table-striped"),i.appendChild(a);let c=a.appendChild(document.createElement("thead"));c.classList.add("table-dark","unit_header");const u=document.createElement("div");u.classList.add("unit_costs");const d=this._specialisms.get(e._role);u.appendChild(document.createElement("span")).appendChild((null==d?void 0:d.cloneNode())||document.createTextNode("-")),c.appendChild((0,o.createTableRow)([u,e.name()],[.1,.9]));const h=c.appendChild(document.createElement("tr"));for(let e=0;e<20;e++){const e=h.appendChild(document.createElement("td"));e.colSpan=1,e.style.width="5%",e.style.padding="0"}const f=[],p=new Map;p.has(e.name())||(p.set(e.name(),e),f.push(e));let _=(0,o.createNoteHead)("Operative notes",e);_&&a.appendChild(_),c=a.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild((0,o.createTableRow)(l._unitLabels,this._unitLabelWidthsNormalized,!0));let m=a.appendChild(document.createElement("tbody"));m.append(document.createElement("tr"));for(const e of f)m.append((0,o.createTableRow)([e.name(),e._move,e._apl,e._groupActivations,e._defence.toString(),e._saves,e._wounds.toString()],this._unitLabelWidthsNormalized));const g=[],v=new Map;for(const t of e._weapons)v.has(t.name())||(v.set(t.name(),t),g.push(t));if(g.length>0){c=a.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild((0,o.createTableRow)(l._weaponLabels,this._weaponLabelWidthNormalized,!0)),m=a.appendChild(document.createElement("tbody")),m.append(document.createElement("tr"));for(const e of g)m.append((0,o.createTableRow)([e.nameAndCosts(),e._attacks,e._skill,e._damage,e._rules,e._criticalEffects],this._weaponLabelWidthNormalized))}if(_=(0,o.createNotesHead)("Weapon notes",e._weapons),_&&a.appendChild(_),e._psychicPowers.length>0){c=a.appendChild(document.createElement("thead")),c.classList.add("table-active"),c.appendChild((0,o.createTableRow)(l._spellLabels,this._spellLabelWidthNormalized,!0)),m=a.appendChild(document.createElement("tbody")),m.append(document.createElement("tr"));for(const t of e._psychicPowers)m.append((0,o.createTableRow)([t.name(),t._effect],this._spellLabelWidthNormalized))}if(_=(0,o.createNotesHead)("Spell notes",e._psychicPowers),_&&a.appendChild(_),e._abilities.size>0||e._rules.size>0){const t=a.appendChild(document.createElement("thead"));t.classList.add("info_row");const n=document.createElement("div");if(e._rules.size>0){const t=Array.from(e._rules.keys()).sort(r.Compare).join(", ");n.appendChild(document.createElement("div")).appendChild(document.createElement("b")).appendChild(document.createTextNode(t))}const i=Array.from(e._abilities.keys()).sort(r.Compare);for(const t of i){const r=(0,s.addHideAble)(n.appendChild(document.createElement("div")));r.appendChild(document.createElement("b")).appendChild(document.createTextNode(`${t.toUpperCase()}: `)),r.appendChild(document.createTextNode(e._abilities.get(t)||"??"))}t.appendChild((0,o.createTableRow)(["Abilities",n],[.1,.9],!1))}if(e._factions.size>0){c=a.appendChild(document.createElement("thead")),c.classList.add("info_row");const t=Array.from(e._factions).sort(r.Compare).join(", ").toLocaleUpperCase();c.appendChild((0,o.createTableRow)(["Factions",t],[.1,.9],!1))}if(e._keywords.size>0){c=a.appendChild(document.createElement("thead")),c.classList.add("info_row");const t=Array.from(e._keywords).sort(r.Compare).join(", ").toLocaleUpperCase();c.appendChild((0,o.createTableRow)(["Keywords",t],[.1,.9],!1))}c=a.appendChild(document.createElement("thead")),c.classList.add("info_row");const b=document.createElement("div");for(const t of[e])b.appendChild(document.createElement("div")).appendChild(document.createTextNode(t.nameAndGear()));c.appendChild((0,o.createTableRow)(["MODELS",b],[.1,.9],!1))}printOperative(e,t,n){let r=document.createElement("canvas");if(r.width=7.5*l._res,r.height=12*l._res,r.style.width=r.width.toString(),r.style.height=r.height.toString(),this._descriptionWidth=r.width-this._descriptionStartX-10,e.equal(t))return;const i=this.renderOperative(e,r,0,0);let o=document.createElement("canvas");o.width=i[0]+30,o.height=i[1]+30,o.style.width=o.width.toString(),o.style.height=o.height.toString();let s=o.getContext("2d");if(null==s||s.drawImage(r,15,15),n){let e=document.createElement("div");e.appendChild(o),n.appendChild(e)}}printRules(e,t){if(e.size>0)for(let[n,r]of e.entries()){if(0==r.size)continue;let e=document.createElement("div"),i=document.createElement("h3");e.appendChild(i),i.textContent=n;for(let t of r){let n=document.createElement("div"),r=document.createElement("b");r.textContent=t[0];let i=document.createElement("p");i.setAttribute("style","white-space: pre-wrap;"),i.appendChild(document.createTextNode(t[1]||"")),n.appendChild(r),n.appendChild(i),e.appendChild(n)}t&&t.appendChild(e)}}renderBorder(e,t,n,r,i){e.strokeStyle=l._blackColor,e.beginPath(),e.moveTo(t,n+l._bevelSize),e.lineTo(t,n+i-l._bevelSize),e.lineTo(t+l._bevelSize,n+i),e.lineTo(t+r-l._bevelSize,n+i),e.lineTo(t+r,n+i-l._bevelSize),e.lineTo(t+r,n+l._bevelSize),e.lineTo(t+r-l._bevelSize,n),e.lineTo(t+l._bevelSize,n),e.closePath(),e.stroke(),e.save(),e.fillStyle=l._fillColor,e.globalCompositeOperation="destination-over",e.beginPath(),e.moveTo(t,n+l._bevelSize),e.lineTo(t,n+i-l._bevelSize),e.lineTo(t+l._bevelSize,n+i),e.lineTo(t+r-l._bevelSize,n+i),e.lineTo(t+r,n+i-l._bevelSize),e.lineTo(t+r,n+l._bevelSize),e.lineTo(t+r-l._bevelSize,n),e.lineTo(t+l._bevelSize,n),e.closePath(),e.fill(),e.restore()}renderNotes(e,t,n){n._customNotes&&(this.renderLine(e),e.font=l._headerFont,(0,i.RenderText)(e,t.toLocaleUpperCase(),this._currentX+l._offset,this._currentY,100,16,i.Justification.Left),e.font=l._font,this._currentY+=2,this._currentY=(0,i.RenderParagraph)(e,n._customNotes,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth-l._offset,0),this._currentY+=2)}renderNotesArray(e,t,n){let r=0;for(const e of n)e._customNotes&&r++;if(0!=r){this.renderLine(e),e.font=l._headerFont,(0,i.RenderText)(e,t.toLocaleUpperCase(),this._currentX+l._offset,this._currentY,100,16,i.Justification.Left);for(const t of n){const n=t.name()+":",r=t._customNotes;if(!r)continue;e.font=l._headerFont,this._currentY+=2,(0,i.RenderTextFull)(e,n,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth,16,i.Justification.Left,i.VertAlign.Top);let o=e.measureText(n).width;e.font=l._font,this._currentY=(0,i.RenderParagraph)(e," "+r,this._currentX+this._descriptionStartX,this._currentY,this._descriptionWidth-l._offset,o),this._currentY+=2}}}renderLine(e){e.lineWidth=2,e.strokeStyle=l._blackColor,e.beginPath(),e.moveTo(this._currentX,this._currentY),e.lineTo(this._currentX+this._maxWidth,this._currentY),e.stroke(),this._currentY+=1}renderTableHeader(e,t,n,r){let o=this._currentX;const s=this._maxWidth;e.fillStyle=l._grey1,e.fillRect(this._currentX,this._currentY,s,22),e.fillStyle=l._blackColor,e.font=l._titleFont;var a=50;if(t){e.font=l._headerFont;for(let s=0;s{a.push(e*this._maxWidth)}));for(let t of e._weapons)o.push(t);for(let t of e._psychicPowers)s.push(t);const c=[],u=new Map;u.has(e.name())||(u.set(e.name(),e),c.push(e)),this.renderNotes(i,"Operative notes",e),this.renderTableHeader(i,l._unitLabels,a,null);let d=0;for(var h of c)this.renderModel(i,h,a,d%2),d++;this.renderNotes(i,"Model notes",e);const f=[],p=new Map;for(const e of o)p.has(e.name())||(p.set(e.name(),e),f.push(e));if(f.length>0){const e=[];this._weaponLabelWidthNormalized.forEach((t=>{e.push(t*this._maxWidth)})),this.renderLine(i),this.renderTableHeader(i,l._weaponLabels,e,l._weaponJustifications),this.renderWeapons(i,f,e)}if(this.renderNotesArray(i,"Weapons notes",o),s.length>0){const e=[];this._spellLabelWidthNormalized.forEach((t=>{e.push(t*this._maxWidth)})),this.renderLine(i),this.renderTableHeader(i,l._spellLabels,e,null),this.renderSpells(i,s,e)}this.renderNotesArray(i,"Spell notes",s),(e._abilities.size>0||e._rules.size>0)&&(this.renderLine(i),this._currentY+=2,this.renderAbilities(i,e)),e._factions.size>0&&(this.renderLine(i),this._currentY+=2,this.renderFactions(i,e)),e._keywords.size>0&&(this.renderLine(i),this._currentY+=2,this.renderKeywords(i,e)),this.renderLine(i),this._currentY+=2,this.renderModelList(i,[e]),this._currentY+=2;const _=this._currentY-(r+l._margin),m=this._maxWidth;return this.renderBorder(i,this._currentX,r+l._margin,m,_),[this._maxWidth,this._currentY]}renderHeader(e,t){t.globalAlpha=1,t.fillStyle=l._blackColor;const n=this._currentX,r=this._currentX+this._maxWidth,o=this._currentY,s=o+36;t.beginPath(),t.moveTo(n,o+l._bevelSize),t.lineTo(n,s),t.lineTo(r,s),t.lineTo(r,o+l._bevelSize),t.lineTo(r-l._bevelSize,o),t.lineTo(n+l._bevelSize,o),t.closePath(),t.fill();let a=n+6;if(this._octagon){t.drawImage(this._octagon,a,o+2,32,32);const n=this._specialisms.get(e._role);n&&t.drawImage(n,a+4,o+2+4,24,24),t.fillStyle="white",t.font="18px serif",a+=34,t.drawImage(this._octagon,a,o+2,32,32),(0,i.RenderText)(t,e.costs().toString(),a,o+2,32,32,i.Justification.Center)}let c=0,u=28;const d=a+6;t.font=u+"px bold serif";const h=e.name().toLocaleUpperCase();let f=t.measureText(h);const p=this._maxWidth-d;for(;c<6&&f.width>p;)c+=1,u-=2,t.font=u+"px bold serif",f=t.measureText(h);t.fillStyle="white",t.textBaseline="top",(0,i.RenderText)(t,h,d,o,p,36,i.Justification.Center),this._currentY+=36}}t.RendererKT21=l,l._res=144,l._margin=0,l._bevelSize=15,l._blackColor="#1d272a",l._grey1="#b3bbb5",l._greyLight="#dde1df",l._fillColor="#f6f6f6",l._offset=20,l._titleFont="bold 14px sans-serif",l._headerFont="bold 14px sans-serif",l._font="14px sans-serif",l._boldFont="bold 14px sans-serif",l._unitLabels=["Operative","M","APL","GA","DF","Save","W"],l._weaponLabels=["WEAPONS","A","WS/BS","D","SR","!"],l._weaponJustifications=[i.Justification.Left,i.Justification.Center,i.Justification.Center,i.Justification.Center,i.Justification.Left,i.Justification.Left],l._spellLabels=["PSYCHIC POWER","DETAILS"]},385:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.renderMESBG=void 0;const n=/\s+/g,r=(e,t="")=>{const n=document.createElement(e);return n.className=t,n},i=(e,t="",n="")=>{const i=r(e,t);return i.appendChild(document.createTextNode(n)),i},o=()=>r("div","mesbg_noBreak mesbg_bumpDown"),s=()=>r("table","mesbg_profileTable mesbg_noBreak mesbg_bumpDown"),a=(e,t)=>{const n=s();return n.appendChild((e=>{const t=r("tr");return e.forEach((e=>{t.appendChild(i("th","",e))})),t})(e)),n.appendChild((e=>{const t=r("tr");return e.forEach((e=>{t.appendChild(i("td","",e))})),t})(t)),n},l=e=>[e.movement,e.fight,e.strength,e.defense,e.attack,e.wounds,e.courage].join("-"),c=e=>i("h2","mesbg_h2",e),u=e=>i("h2","mesbg_h2",e),d={showTracker:!0,showRules:!0,woundChart:!0},h=(e,t)=>{const n=document.createElement("input");n.setAttribute("type","checkbox"),n.setAttribute("name",e),n.setAttribute("id",e),d[e]&&n.setAttribute("checked","checked"),n.addEventListener("change",(e=>()=>{const t=!d[e];d[e]=t;const n=document.querySelector(`.mesbg_${e}`);null!==n&&(t?n.classList.remove("mesbg_hideMe"):n.classList.add("mesbg_hideMe"))})(e));const r=document.createElement("label");return r.setAttribute("for",e),r.appendChild(document.createTextNode(` ${t} `)),r.prepend(n),r},f=["Mv","F","S","D","A","W","C"];t.renderMESBG=(e,t,d,p)=>{if(null!==t){const n=r("div","mesbg_noPrint mesbg_toggleHolder");n.appendChild(h("showRules","show rules text")),n.appendChild(h("showTracker","include hero points tracker")),n.appendChild(h("woundChart","include To Wound Chart")),t.appendChild(n),t.appendChild((_=e.name,i("h1","mesbg_h1",_))),t.appendChild(i("h4","mesbg_rosterInfo",`${e.points} points | ${e.warriors} warriors `))}var _;if(null!==d){const t=r("div","mesbg_container");d.appendChild(t),e.forces.forEach((n=>{t.appendChild(i("h2","mesbg_forceName",n.name)),t.appendChild(i("h4","mesbg_h4 mesbg_bumpDown",`${n.breakpoints.modelCount} models\n | broken at ${n.breakpoints.half} casualties\n | quartered at ${n.breakpoints.quarter} models remaining\n `)),i("p","mesbg_rosterInfo",`${e.points} points | ${e.warriors} warriors `);const o=r("div","mesbg_flexGrid");t.appendChild(o),n.units.forEach((e=>{var t,n;const s=r("div","mesbg_card");s.appendChild(c(`${e.leader.name} - ${e.leader.points}pts ${(null===(t=e.leader.heroStuff)||void 0===t?void 0:t.isLeader)?" (Leader)":""}`)),s.appendChild((e=>i("p","mesbg_equipmentList",e))(`${e.leader.wargear.map((e=>e.name)).join(", ")}${e.leader.mount?", "+(null===(n=e.leader.mount)||void 0===n?void 0:n.name):""}`)),s.appendChild(r("hr","mesbg_bumpDown")),e.warband.forEach((e=>{var t;const n=u(`${e.count} ${e.model.name} - ${e.points}pts`);s.appendChild(n),s.appendChild(i("p","mesbg_equipmentList",`${e.model.wargear.map((e=>e.name)).join(", ")}${e.model.mount?", "+(null===(t=e.model.mount)||void 0===t?void 0:t.name):""}`))})),o.appendChild(s)}))}))}if(null!=p){const t=r("div","mesbg_container");p.appendChild(t),e.forces.forEach((e=>{const d=new Map;e.units.forEach((e=>{var h,p,_,m,g,v,b,y,w,C,x,E;const S=r("div","mesbg_card"),k=r("div","mesbg_twoColumn");S.appendChild(c(`${e.leader.name} - ${e.leader.points}pts`)),S.appendChild(i("h3","mesbg_h3 mesbg_bumpDown",e.leader.keywords.join(", ")));const A=r("div","mesbg_flex mesbg_noBreak");A.appendChild(a(f,[e.leader.profile.movement,e.leader.profile.fight,e.leader.profile.strength,e.leader.profile.defense,e.leader.profile.attack,e.leader.profile.wounds,e.leader.profile.courage])),A.appendChild(a(["M","W","F"],[null!==(p=null===(h=e.leader.heroStuff)||void 0===h?void 0:h.might)&&void 0!==p?p:"-",null!==(m=null===(_=e.leader.heroStuff)||void 0===_?void 0:_.will)&&void 0!==m?m:"-",null!==(v=null===(g=e.leader.heroStuff)||void 0===g?void 0:g.fate)&&void 0!==v?v:"-"])),k.appendChild(A);const T=o();if(T.appendChild(i("h3","mesbg_h3","Wargear")),0===e.leader.wargear.length?T.appendChild(i("i","","none")):T.appendChild(i("p","mesbg_cardWargear",e.leader.wargear.map((e=>e.name)).join(", "))),k.appendChild(T),null!==(y=null===(b=e.leader.heroStuff)||void 0===b?void 0:b.actions.length)&&void 0!==y&&y){const t=o();t.appendChild(i("h3","mesbg_h3","Heroic Actions"));const n=r("ul","mesbg_list mesbg_noBreak mesbg_bumpDown");null===(w=e.leader.heroStuff)||void 0===w||w.actions.forEach((e=>{n.appendChild(r("li")).appendChild(document.createTextNode(e))})),t.appendChild(n),k.appendChild(t)}if(k.appendChild(i("h3","mesbg_h3","Special Rules")),k.appendChild(i("p","mesbg_bumpDown",e.leader.rules.map((e=>e.name)).join(", "))),null!==(x=null===(C=e.leader.heroStuff)||void 0===C?void 0:C.magicalPowers.length)&&void 0!==x&&x){const t=s();t.className="mesbg_powerTable mesbg_noBreak";const n=r("tr");n.appendChild(r("th")).appendChild(i("h3","mesbg_h3","Magical Powers")),n.appendChild(r("th")).appendChild(i("span","","Range")),n.appendChild(r("th")).appendChild(i("span","","Casting")),t.appendChild(n),null===(E=e.leader.heroStuff)||void 0===E||E.magicalPowers.forEach((e=>{const n=r("tr");n.appendChild(r("td")).appendChild(i("span","",e.name)),n.appendChild(r("td")).appendChild(i("span","",e.range)),n.appendChild(r("td")).appendChild(i("span","",e.casting)),t.appendChild(n)})),k.appendChild(t)}if(void 0!==e.leader.mount){const t=o();t.appendChild(u(`Mount: ${e.leader.mount.name}`));const n=r("div","mesbg_flex mesbg_noBreak");n.appendChild(a(f,[e.leader.mount.profile.movement,e.leader.mount.profile.fight,e.leader.mount.profile.strength,e.leader.mount.profile.defense,e.leader.mount.profile.attack,e.leader.mount.profile.wounds,e.leader.mount.profile.courage])),t.append(n),k.append(t)}S.appendChild(k),t.appendChild(S),e.warband.forEach((e=>{const t=e.model,r=(e=>{var t,r;return e.name.trim().replace(n,"-")+(null!==(r=null===(t=e.mount)||void 0===t?void 0:t.name.trim().replace(n,"-"))&&void 0!==r?r:"")})(t);if(d.has(r)){const e=d.get(r),n=l(t.profile),i=null==e?void 0:e.statLines.get(n),o=t.wargear.map((e=>e.name.trim())).join(", ");void 0===i?null==e||e.statLines.set(n,{profile:t.profile,equipments:new Set([o])}):i.equipments.add(o)}else{const e={name:t.name,keywords:t.keywords.join(", "),mount:t.mount,ruleNames:t.rules.map((e=>e.name)).join(", "),statLines:new Map([[l(t.profile),{profile:t.profile,equipments:new Set([t.wargear.map((e=>e.name.trim())).join(", ")])}]])};d.set(r,e)}}))}));const h=r("div","mesbg_twoColumnGrid");d.forEach(((e,t)=>{const n=r("div","mesbg_card"),s=r("div","mesbg_twoColumn");if(n.appendChild(u(e.name)),n.appendChild(i("p","mesbg_cardWargear mesbg_bumpDown",e.keywords)),e.statLines.forEach(((e,t)=>{const n=r("div","mesbg_noBreak");n.appendChild(i("h3","mesbg_h3","Wargear")),e.equipments.forEach((e=>{n.appendChild(i("p","mesbg_cardWargear",e))})),n.appendChild(a(f,[e.profile.movement,e.profile.fight,e.profile.strength,e.profile.defense,e.profile.attack,e.profile.wounds,e.profile.courage])),s.appendChild(n)})),e.ruleNames.length>0&&(s.appendChild(i("h3","mesbg_h3","Special Rules")),s.appendChild(i("p","mesbg_bumpDown",e.ruleNames))),void 0!==e.mount){const t=o();t.appendChild(u(`Mount: ${e.mount.name}`));const n=r("div","mesbg_flex mesbg_noBreak");n.appendChild(a(f,[e.mount.profile.movement,e.mount.profile.fight,e.mount.profile.strength,e.mount.profile.defense,e.mount.profile.attack,e.mount.profile.wounds,e.mount.profile.courage])),t.append(n),s.append(t)}n.appendChild(s),h.appendChild(n)})),t.appendChild(h)}));const d=new Set,h=r("div","mesbg_pageBreak mesbg_showRules");h.appendChild(i("h1","mesbg_h1","Rules"));const _=r("div","mesbg_twoColumn");e.forces.forEach((n=>{n.armyBonus.forEach((e=>{_.appendChild(i("h3","mesbg_h3",`"${e.name}" (Army Bonus)`)),_.appendChild(i("p","mesbg_bumpDown",e.ruleText))})),n.units.forEach((e=>{e.leader.rules.forEach((e=>{!1===d.has(e.name)&&(_.appendChild(i("h3","mesbg_h3",e.name)),_.appendChild(i("p","mesbg_bumpDown",e.ruleText)),d.add(e.name))})),e.warband.forEach((e=>{e.model.rules.forEach((e=>{!1===d.has(e.name)&&(_.appendChild(i("h3","mesbg_h3",e.name)),_.appendChild(i("p","mesbg_bumpDown",e.ruleText)),d.add(e.name))}))}))})),h.appendChild(_),t.appendChild(h);const o=r("table","mesbg_pageBreak mesbg_trackerTable mesbg_showTracker");o.innerHTML="MWF",e.forces.forEach((e=>{e.units.forEach((e=>{const t=r("tr");t.innerHTML=`

${e.leader.name}

`,o.appendChild(t)}))})),t.appendChild(o);const s=r("table","mesbg_pageBreak mesbg_woundChart");s.innerHTML='\n \n \n  Defence\n \n \n \n \n Strength\n   1 2 3 4 5 6 7 8 9 10\n \n \n 1 4 5 5 6 6 6/4 6/5 6/6 - -\n \n \n 2 4 4 5 5 6 6 6/4 6/5 6/6 -\n \n \n 3 3 4 4 5 5 6 6 6/4 6/5 6/6\n \n \n 4 3 3 4 4 5 5 6 6 6/4 6/5\n \n \n 5 3 3 3 4 4 5 5 6 6 6/4 \n \n 6 3 3 3 3 4 4 5 5 6 6\n \n \n 7 3 3 3 3 3 4 4 5 5 6\n \n \n 8 3 3 3 3 3 3 4 4 5 5\n \n \n 9 3 3 3 3 3 3 3 4 4 5\n \n \n 10 3 3 3 3 3 3 3 3 4 4\n \n \n ',t.appendChild(s)}))}}},717:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RendererWarcry=void 0;const r=n(320);t.RendererWarcry=class{constructor(e){this._roster=null,this._roster=e}render(e,t,n){if(null!=this._roster){e&&(e.innerHTML="

"+this._roster._name+" ("+this._roster._points+" pts

");for(let e of this._roster._forces){const i=document.createElement("div");i&&(i.innerHTML="

"+e._catalog+" "+e._name+"

"),t&&t.appendChild(i);const o=document.createElement("table");o.classList.add("table"),o.classList.add("table-sm"),o.classList.add("table-striped");const s=document.createElement("thead");o.appendChild(s),s.classList.add("thead-light");const a=document.createElement("tr");s.appendChild(a),[{name:"NAME",w:"35%"},{name:"ROLE",w:"25%"},{name:"POINTS",w:"15%"}].forEach((e=>{let t=document.createElement("th");t.scope="col",t.innerHTML=e.name,t.style.width=e.w,a.appendChild(t)})),i.appendChild(o);let l=document.createElement("tbody");o.appendChild(l);for(let t of e._units){let e=document.createElement("tr"),n=document.createElement("td");n.innerHTML=t._name;let i=document.createElement("td");i.innerHTML=r.WarcryUnitRoleToString[t._role];let o=document.createElement("td");o.innerHTML=t._points.toString(),e.appendChild(n),e.appendChild(i),e.appendChild(o),l.appendChild(e)}let c=document.createElement("div");if(e._allegiance._rules.size>0){let t=document.createElement("h3");c.appendChild(t),t.textContent=e._allegiance._name+" Abilities";for(let t of e._allegiance._rules){let e=document.createElement("div"),n=document.createElement("h4");n.textContent=t[0];let r=document.createElement("p");r.textContent=t[1],e.appendChild(n),e.appendChild(r),c.appendChild(e)}}if(!n)return;n.appendChild(c);let u=document.createElement("div");for(let t of e._units){u.appendChild(this.renderUnitHtml(t));let e=document.createElement("hr");e.className="aos_dark",u.appendChild(e)}n.appendChild(u)}}}createCharacteristicCard(e,t){let n=document.createElement("div");return n.className="col",n.innerHTML=`\n
\n \n
\n

${t}

\n
\n
`,n}createWeapon(e,t){let n=document.createElement("p");n.className="card-title warcry_font",n.innerHTML=e._name,t.appendChild(n);let r=document.createElement("div");r.className="row",t.appendChild(r);let i=this.getWeaponTypeRunemark(e._name),o=document.createElement("div");o.className="col",o.innerHTML=`\n
\n \n
`,r.appendChild(o);let s=this.createCharacteristicCard("range",e._range);r.appendChild(s);let a=this.createCharacteristicCard("attacks",e._attacks);r.appendChild(a);let l=this.createCharacteristicCard("strength",e._strength);r.appendChild(l);let c=this.createCharacteristicCard("damage",e._damage);r.appendChild(c)}renderUnitHtml(e){let t=document.createElement("div");t.className="container-fluid warcry_unit border bg-light";let n=document.createElement("div");n.className="row align-items-center",t.append(n);let r=document.createElement("div");r.className="col-1",r.innerHTML=``,n.appendChild(r);let i=document.createElement("div");i.className="col",i.innerHTML=`${e._name}`,n.appendChild(i);let o=document.createElement("div");o.className="col-4",n.appendChild(o);for(let t of e._keywords){const e=this.getAbilityRunemark(t);if(""!=e){let t=new Image;t.className="border border-dark rounded-circle warcry_card",t.src=`./assets/warcry/runemarks/black/fighters-${e}.svg`,o.appendChild(t)}}let s=document.createElement("div");s.className="col-1",s.innerHTML=`
${e._points}
`,n.appendChild(s);let a=document.createElement("div");a.className="row align-items-center",t.append(a);let l=document.createElement("div");l.className="col-7",a.appendChild(l),2==e._weapons.length&&this.createWeapon(e._weapons[1],l);let c=document.createElement("div");c.className="col",a.appendChild(c);let u=document.createElement("div");u.className="row align-items-center",t.append(u);let d=document.createElement("div");d.className="col-7",u.appendChild(d),e._weapons.length>=1&&this.createWeapon(e._weapons[0],d);let h=document.createElement("div");h.className="col",u.appendChild(h);let f=document.createElement("div");f.className="row",h.appendChild(f);let p=document.createElement("div");p.className="col",f.appendChild(p);let _=this.createCharacteristicCard("move",e._move.toString());f.appendChild(_);let m=this.createCharacteristicCard("toughness",e._toughness.toString());f.appendChild(m);let g=this.createCharacteristicCard("wounds",e._wounds.toString());if(f.appendChild(g),e._damageTable.length>0){let n=document.createElement("div");n.className="row w-75 align-items-center",t.append(n);let r=document.createElement("div");r.className="p-2 mb-2 text-center text-uppercase text-black",r.innerHTML='Damage Table',n.appendChild(r);let i=[{name:"Damage Points Allocated",width:"50%"},{name:"Move",width:"25%"},{name:"Damage ",width:"25%"}],o=1;for(let t of e._damageTable[0]._table)i[o++].name=t[0];const s=this.createTable(i);n.appendChild(s);let a=document.createElement("tbody");s.appendChild(a);for(let t of e._damageTable){let e=document.createElement("tr"),n=document.createElement("td");n.innerHTML=t._name,e.appendChild(n);for(let n of t._table){let t=document.createElement("td");t.innerHTML=n[1],e.appendChild(t)}a.appendChild(e)}}return t}createTable(e){const t=document.createElement("table");t.className="table table-bordered table-sm text-center";const n=document.createElement("thead");t.appendChild(n),n.classList.add("warcry_light");const r=document.createElement("tr");return n.appendChild(r),e.forEach((e=>{let t=document.createElement("th");t.scope="col",t.innerHTML=e.name,t.style.width=e.width,r.appendChild(t)})),t}getAbilityRunemark(e){const t=e.toLowerCase();return t.includes("agile")?"agile":t.includes("ally")?"ally":t.includes("beast")?"beast":t.includes("berserker")?"berserker":t.includes("brute")?"brute":t.includes("bulwark")?"bulwark":t.includes("champion")?"champion":t.includes("destroyer")?"destroyer":t.includes("elite")?"elite":t.includes("ferocious")?"ferocious":t.includes("fly")?"fly":t.includes("frenzied")?"frenzied":t.includes("gargantuan")?"gargantuan":t.includes("icon")?"icon-bearer":t.includes("leader")?"leader":t.includes("minion")?"minion":t.includes("mount")?"mount":t.includes("mystic")?"mystic":t.includes("priest")?"priest":t.includes("scout")?"scout":t.includes("sentience")?"sentience":t.includes("terrifying")?"terrifying":t.includes("thrall")?"thrall":t.includes("trapper")?"trapper":t.includes("warrior")?"warrior":""}getWeaponTypeRunemark(e){const t=e.toLowerCase();return t.includes("axe")||t.includes("cleaver")?"axe":t.includes("claws")||t.includes("talon")||t.includes("grasping")||t.includes("pincher")?"claws":t.includes("club")?"club":t.includes("dagger")||t.includes("shank")?"dagger":t.includes("fangs")||t.includes("teeth")||t.includes("jaws")||t.includes("maw")?"fangs":t.includes("hammer")||t.includes("anvil")?"hammer":t.includes("mace")||t.includes("staff")||t.includes("stave")||t.includes("flail")?"mace":t.includes("scythe")?"scythe":t.includes("spear")||t.includes("glaive")||t.includes("halberd")||t.includes("lance")||t.includes("harpoon")||t.includes("polearm")?"spear":t.includes("sword")||t.includes("blade")||t.includes("sickles")?"sword":t.includes("arcane bolt")||t.includes("sorcerous bolt")?"blast":t.includes("bow")||t.includes("bolas")||t.includes("cannon")||t.includes("pistol")||t.includes("javelin")?"ranged-weapon":t.includes("whip")?"reach-weapon":"unarmed"}}},391:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Create30kRoster=t.Roster30k=t.Force30k=t.Unit30k=t.Fortification30k=t.Model30k=t.Flyer30k=t.Walker30k=t.Vehicle30k=t.UnitRoleToString30k=t.UnitRole30k=t.PsychicPower30k=t.Psyker30k=t.Weapon30k=void 0;class n{constructor(){this._name="",this._range="Melee",this._str="user",this._ap="",this._type="Melee"}}t.Weapon30k=n;class r{constructor(){this._name="",this._masteryLevel="",this._disciplines=""}}t.Psyker30k=r;class i{constructor(){this._name="",this._warpCharge=0,this._category="",this._range="",this._details=""}}var o;t.PsychicPower30k=i,function(e){e[e.NONE=0]="NONE",e[e.HQ=1]="HQ",e[e.TR=2]="TR",e[e.EL=3]="EL",e[e.FA=4]="FA",e[e.HS=5]="HS",e[e.FL=6]="FL",e[e.DT=7]="DT",e[e.FT=8]="FT",e[e.LW=9]="LW"}(o=t.UnitRole30k||(t.UnitRole30k={})),t.UnitRoleToString30k=["None","HQ","Troops","Elites","Fast Attack","Heavy Support","Flyer","Dedicated Transport","Fortification","Lord of War"];class s{constructor(){this._name="",this._bs="",this._front=4,this._side=4,this._rear=4,this._hp=1,this._type="",this._weapons=[]}}t.Vehicle30k=s;class a{constructor(){this._name="",this._ws="",this._bs="",this._str=4,this._front=4,this._side=4,this._rear=4,this._initiative=1,this._attacks="",this._hp=1,this._type="",this._weapons=[]}}t.Walker30k=a;class l{constructor(){this._name="",this._bs="",this._front=4,this._side=4,this._rear=4,this._hp=1,this._type="",this._role="",this._pursuit="",this._agility="",this._weapons=[]}}t.Flyer30k=l;class c{constructor(){this._name="",this._count=0,this._ws="",this._bs="",this._str=4,this._toughness=4,this._wounds=1,this._initiative=1,this._attacks="",this._leadership=7,this._save="",this._weapons=[],this._psyker=null,this._psychicPowers=[]}}t.Model30k=c,t.Fortification30k=class{constructor(){this._name="",this._composition="",this._type=""}};class u{constructor(){this._name="",this._role=o.NONE,this._factions=new Set,this._keywords=new Set,this._abilities=new Map,this._rules=new Map,this._models=[],this._walkers=[],this._vehicles=[],this._flyers=[],this._points=0}}t.Unit30k=u;class d{constructor(){this._catalog="",this._name="Unknown",this._faction="Unknown",this._rules=new Map,this._units=[]}}t.Force30k=d;class h{constructor(){this._commandPoints=0,this._points=0,this._name="",this._forces=[]}}function f(e,t){if(!t||!e)return!1;for(let n of t._forces)if(n._catalog===e._catalog)return!0;return!1}function p(e,t){let n=e.querySelectorAll("force>selections>selection");for(let e of n){let n=m(e);n&&n._role!=o.NONE&&t._units.push(n)}t._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?0:-1))}function _(e){switch(e){case"HQ":return o.HQ;case"Troops":return o.TR;case"Elites":return o.EL;case"Fast Attack":return o.FA;case"Heavy Support":return o.HS;case"Flyer":return o.FL;case"Dedicated Transport":return o.DT;case"Fortification":return o.FT;case"Lord of War":return o.LW}return o.NONE}function m(e){var t,d,h,f,p,m,g,v,b,y,w,C,x,E,S,k,A,T,N;let L=new u,R=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;R&&(L._name=R);let P=e.querySelectorAll(":scope categories>category");for(let e of P){let t=null===(d=e.getAttributeNode("name"))||void 0===d?void 0:d.nodeValue;if(t){const e="Faction: ",n=t.lastIndexOf(e);if(n>=0){const r=t.slice(n+e.length);L._factions.add(r)}else{const e=_(t.trim());e!=o.NONE?L._role=e:L._keywords.add(t)}}}let O=null,W=null,z=null,I=null,B=e.querySelectorAll(":scope profiles>profile");for(let e of B){let t=null===(h=e.getAttributeNode("name"))||void 0===h?void 0:h.nodeValue,n=null===(f=e.getAttributeNode("typeName"))||void 0===f?void 0:f.nodeValue;if(t&&n)if("Unit"===n){O=new c,O._name=t;let n=e.querySelectorAll("characteristics>characteristic");for(let t of n){let n=null===(p=t.getAttributeNode("name"))||void 0===p?void 0:p.nodeValue;if(n&&t.textContent)switch(n){case"WS":O._ws=t.textContent;break;case"BS":O._bs=t.textContent;break;case"S":O._str=+t.textContent;break;case"T":O._toughness=+t.textContent;break;case"W":O._wounds=+t.textContent;break;case"I":O._initiative=+t.textContent;break;case"A":O._attacks=t.textContent;break;case"LD":O._leadership=+t.textContent;break;case"Save":O._save=t.textContent}if(e.parentElement&&e.parentElement.parentElement){let t=null===(m=e.parentElement.parentElement.getAttributeNode("number"))||void 0===m?void 0:m.nodeValue;t&&(O._count=+t)}}L._models.push(O)}else if("Walker"===n){W=new a,W._name=t;let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let t=null===(g=e.getAttributeNode("name"))||void 0===g?void 0:g.nodeValue;if(t&&e.textContent)switch(t){case"WS":W._ws=e.textContent;break;case"BS":W._bs=e.textContent;break;case"S":W._str=+e.textContent;break;case"Front":W._front=+e.textContent;break;case"Side":W._side=+e.textContent;break;case"Rear":W._rear=+e.textContent;break;case"I":W._initiative=+e.textContent;break;case"A":W._attacks=e.textContent;break;case"HP":W._hp=+e.textContent;break;case"Type":W._type=e.textContent}}L._walkers.push(W)}else if("Vehicle"===n){z=new s,z._name=t;let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let t=null===(v=e.getAttributeNode("name"))||void 0===v?void 0:v.nodeValue;if(t&&e.textContent)switch(t){case"BS":z._bs=e.textContent;break;case"Front":z._front=+e.textContent;break;case"Side":z._side=+e.textContent;break;case"Rear":z._rear=+e.textContent;break;case"HP":z._hp=+e.textContent;break;case"Type":z._type=e.textContent}}L._vehicles.push(z)}else if("Flyer"===n){I=new l,I._name=t;let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let t=null===(b=e.getAttributeNode("name"))||void 0===b?void 0:b.nodeValue;if(t&&e.textContent)switch(t){case"BS":I._bs=e.textContent;break;case"Front":I._front=+e.textContent;break;case"Side":I._side=+e.textContent;break;case"Rear":I._rear=+e.textContent;break;case"HP":I._hp=+e.textContent;break;case"Combat Role":I._role=e.textContent;break;case"Pursuit":I._pursuit=e.textContent;break;case"Agility":I._agility=e.textContent}}L._flyers.push(I)}}for(let e of B){let t=null===(y=e.getAttributeNode("name"))||void 0===y?void 0:y.nodeValue,o=null===(w=e.getAttributeNode("typeName"))||void 0===w?void 0:w.nodeValue;if(t&&o){if("Wargear Item"===o){let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let n=null===(C=e.getAttributeNode("name"))||void 0===C?void 0:C.nodeValue;n&&e.textContent&&t&&"Description"===n&&L._abilities.set(t,e.textContent)}}else if("Weapon"===o){let r=new n;r._name=t;let i=e.querySelectorAll("characteristics>characteristic");for(let e of i){let t=null===(x=e.getAttributeNode("name"))||void 0===x?void 0:x.nodeValue;if(t&&e.textContent)switch(t){case"Range":r._range=e.textContent;break;case"Type":r._type=e.textContent;break;case"Strength":r._str=e.textContent;break;case"AP":r._ap=e.textContent}}O?O._weapons.push(r):W?W._weapons.push(r):z?z._weapons.push(r):I?I._weapons.push(r):console.log("Unexpected: Created a weapon without an active model. Unit: "+R)}else if("Transport"==o){let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let n=null===(E=e.getAttributeNode("name"))||void 0===E?void 0:E.nodeValue;n&&e.textContent&&t&&"Capacity"===n&&L._abilities.set(t,e.textContent)}}else if("Psychic Power"==o){let n=new i;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(S=e.getAttributeNode("name"))||void 0===S?void 0:S.nodeValue;if(t&&e.textContent)switch(t){case"Warp Charge":n._warpCharge=+e.textContent;break;case"Power Category":n._category=e.textContent;break;case"Range":n._range=e.textContent;break;case"Details":n._details=e.textContent}}O?O._psychicPowers.push(n):console.log("Unexpected: Created a psychic power without an active model. Unit: "+R)}else if("Psyker"==o){let n=new r;n._name=t;let i=e.querySelectorAll("characteristics>characteristic");for(let e of i){let t=null===(k=e.getAttributeNode("name"))||void 0===k?void 0:k.nodeValue;if(t&&e.textContent)switch(t){case"Mastery Level":n._masteryLevel=e.textContent;break;case"Disciplines":n._disciplines=e.textContent}}O?O._psyker=n:console.log("Unexpected: Created a psyker without an active model. Unit: "+R)}}else"Unit"===o||"Walker"===o||"Vehicle"===o||console.log("Unknown property type: "+o)}let M=e.querySelectorAll(":scope costs>cost");for(let e of M)if(e.hasAttribute("name")&&e.hasAttribute("value")){let t=null===(A=e.getAttributeNode("name"))||void 0===A?void 0:A.nodeValue,n=null===(T=e.getAttributeNode("value"))||void 0===T?void 0:T.nodeValue;n&&"pts"==t&&(L._points+=+n)}let U=e.querySelectorAll(":scope rules > rule");for(let e of U)if(e.hasAttribute("name")){let t=null===(N=e.getAttributeNode("name"))||void 0===N?void 0:N.nodeValue,n=e.querySelector("description");t&&n&&n.textContent&&L._rules.set(t,n.textContent)}return L}t.Roster30k=h,t.Create30kRoster=function(e){var t;if(e){let n=e.querySelector("roster");if(n){const r=new h,i=null===(t=n.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;return r._name=i||"30k Army Roster",function(e,t){var n,r;let i=e.querySelectorAll("roster>costs>cost");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("value")){let i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("value"))||void 0===r?void 0:r.nodeValue;o&&("pts"===i?t._points=+o:"CP"===i&&(t._commandPoints=+o))}}(e,r),function(e,t){var n,r,i;let o=e.querySelectorAll("roster>forces>force");for(let e of o)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let o=new d,s=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,a=null===(r=e.getAttributeNode("catalogueName"))||void 0===r?void 0:r.nodeValue;if(s&&(o._name=s),a&&(o._catalog=a),!f(o,t)){const t=e.querySelectorAll("force>rules>rule");for(let e of t)if(e.hasAttribute("name")){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;const n=e.querySelector("rule>description");t&&n&&o._rules.set(t,n.textContent)}}p(e,o),t._forces.push(o)}}(e,r),r}}return null}},288:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Compare=t.CompareWeapon=t.Create40kRoster=t.Costs=t.Roster40k=t.Force=t.Unit=t.Model=t.UnitRoleToString=t.UnitRole=t.PsychicPower=t.Psyker=t.Explosion=t.WoundTracker=t.Weapon=t.Upgrade=t.BaseNotes=void 0;const s=o(n(486));class a{constructor(){this._name="",this._customName="",this._customNotes=""}name(){return this._customName?this._customName:this._name}notes(){return this._customNotes}equal(e){return null!=e&&this._name===e._name}}t.BaseNotes=a;class l extends a{constructor(){super(...arguments),this._cost=new b,this._count=1}selectionName(){return this.name()}toString(){let e=this.selectionName();return this._count>1&&(e=`${this._count}x ${e}`),this._cost.hasValues()&&(e+=` ${this._cost.toString()}`),e}}t.Upgrade=l;class c extends l{constructor(){super(...arguments),this._selectionName="",this._range="Melee",this._type="Melee",this._str="user",this._ap="",this._damage="",this._abilities=""}selectionName(){return this._selectionName||this.name()}}t.Weapon=c;class u extends a{constructor(){super(...arguments),this._name="",this._table=new Map}}t.WoundTracker=u;class d extends a{constructor(){super(...arguments),this._name="",this._diceRoll="",this._distance="",this._mortalWounds=""}}t.Explosion=d;class h extends a{constructor(){super(...arguments),this._cast="",this._deny="",this._powers="",this._other=""}}t.Psyker=h;class f extends a{constructor(){super(...arguments),this._name="",this._manifest=0,this._range="",this._details=""}}var p;t.PsychicPower=f,function(e){e[e.NONE=0]="NONE",e[e.SCD=1]="SCD",e[e.HQ=2]="HQ",e[e.TR=3]="TR",e[e.EL=4]="EL",e[e.FA=5]="FA",e[e.HS=6]="HS",e[e.FL=7]="FL",e[e.DT=8]="DT",e[e.FT=9]="FT",e[e.LW=10]="LW",e[e.AGENTS=11]="AGENTS",e[e.NF=12]="NF",e[e.COMMANDER=13]="COMMANDER",e[e.LEADER=14]="LEADER",e[e.SPECIALIST=15]="SPECIALIST",e[e.NON_SPECIALIST=16]="NON_SPECIALIST"}(p=t.UnitRole||(t.UnitRole={})),t.UnitRoleToString=["None","Supreme Command Detachment","HQ","Troops","Elites","Fast Attack","Heavy Support","Flyer","Dedicated Transport","Fortification","Lord of War","Agent of the Imperium","No Force Org Slot","Commander","Leader","Specialist","Non-specialist"];class _ extends a{constructor(){super(...arguments),this._count=0,this._move='0"',this._ws="",this._bs="",this._str=4,this._toughness=4,this._wounds=1,this._attacks="",this._leadership=7,this._save="",this._weapons=[],this._upgrades=[],this._psyker=null,this._psychicPowers=[],this._explosions=[]}equal(e){if(null==e)return!1;if(this._name===e._name&&this._count===e._count&&this._weapons.length===e._weapons.length&&this._upgrades.length===e._upgrades.length){for(let t=0;t0||this._upgrades.length>0)&&(e+=` (${this.getDedupedWeaponsAndUpgrades().map((e=>e.toString())).join(", ")})`),e}getDedupedWeaponsAndUpgrades(){const e=[];for(const t of[...this._weapons,...this._upgrades])e.some((e=>t.selectionName()===e.selectionName()))||e.push(t);return e}normalize(){this._weapons.sort(q),this._upgrades.sort(D),this.normalizeUpgrades(this._weapons),this.normalizeUpgrades(this._upgrades)}normalizeUpgrades(e){for(let t=0;t(e._count>1?`${e._count}x `:"")+e.nameAndGear())),this._weapons=this._models.map((e=>e._weapons)).reduce(((e,t)=>e.concat(t)),[]).sort(q).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())})),this._spells.push(...this._models.map((e=>e._psychicPowers)).reduce(((e,t)=>e.concat(t)),[])),this._psykers.push(...this._models.map((e=>e._psyker)).filter((e=>e))),this._explosions.push(...this._models.map((e=>e._explosions)).reduce(((e,t)=>e.concat(t)),[]))}}t.Unit=m;class g extends a{constructor(){super(...arguments),this._catalog="",this._faction="Unknown",this._factionRules=new Map,this._configurations=[],this._rules=new Map,this._units=[]}}t.Force=g;class v extends a{constructor(){super(...arguments),this._cost=new b,this._forces=[]}}t.Roster40k=v;class b{constructor(){this._powerLevel=0,this._commandPoints=0,this._points=0}hasValues(){return 0!==this._powerLevel||0!==this._commandPoints||0!==this._points}toString(){const e=[];return 0!==this._points&&e.push(`${this._points} pts`),0!==this._powerLevel&&e.push(`${this._powerLevel} PL`),0!==this._commandPoints&&e.push(`${this._commandPoints} CP`),`[${e.join(" / ")}]`}add(e){this._powerLevel+=e._powerLevel,this._commandPoints+=e._commandPoints,this._points+=e._points;for(const t in e._freeformValues)this.addFreeformValue(t,e._freeformValues[t])}addFreeformValue(e,t){this._freeformValues||(this._freeformValues={});const n=this._freeformValues[e]||0;this._freeformValues[e]=n+t}}function y(e,t,n){var r;let i=e.querySelectorAll("force>selections>selection");for(let e of i){let i=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue;if(i)if(i.includes("Detachment Command Cost"));else if("Battle Size"===i||"Gametype"===i)w(e,t);else if(e.querySelector('profile[typeName="Unit"]')){const r=P(e,n);t._units.push(r);for(const e of r._rules.entries())t._rules.set(e[0],e[1])}else if("upgrade"===e.getAttribute("type")){x(e,t._rules),w(e,t);const n=e.querySelectorAll("selections>selection");for(let e of n){const n=e.getAttribute("name");n&&"upgrade"===e.getAttribute("type")&&("Unknown"===t._faction&&(t._faction=n),x(e,t._factionRules))}}else console.log("** UNEXPECTED SELECTION **",i,e)}for(const e of t._factionRules.keys())t._rules.delete(e);t._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?e._name>t._name?1:e._name==t._name?0:-1:-1))}function w(e,t){var n;const r=e.getAttribute("name");if(!r)return;const i=null===(n=e.querySelector("category"))||void 0===n?void 0:n.getAttribute("name"),o=e.querySelectorAll("selections>selection"),s=[];let a=L(e);for(const e of o)s.push(e.getAttribute("name")),a.add(L(e));let l=i&&"Configuration"!==i?`${i} - ${r}`:r;s.length>0&&(l+=`: ${s.join(", ")}`),a.hasValues()&&(l+=` ${a.toString()}`),t._configurations.push(l)}function C(e,t){if(!t||!e)return!1;for(let n of t._forces)if(n._catalog===e._catalog)return!0;return!1}function x(e,t){const n=e.querySelectorAll("profiles>profile");for(const e of n){const n=e.getAttribute("name");if(!n)continue;const r=e.getAttribute("typeName");"Abilities"!==r&&"Dynastic Code"!==r&&"Household Tradition"!==r||W(e,n,0,t)}const r=e.querySelectorAll("rules>rule");for(const e of r)E(e,t)}function E(e,t){const n=e.getAttribute("name"),r=e.querySelector("description");n&&(null==r?void 0:r.textContent)&&t.set(n,r.textContent)}function S(e){switch(e){case"HQ":return p.HQ;case"Troops":return p.TR;case"Elites":return p.EL;case"Fast Attack":return p.FA;case"Heavy Support":return p.HS;case"Flyer":return p.FL;case"Dedicated Transport":return p.DT;case"Fortification":return p.FT;case"Lord of War":return p.LW;case"Agent of the Imperium":return p.AGENTS;case"No Force Org Slot":return p.NF;case"Primarch | Daemon Primarch | Supreme Commander":return p.SCD}return p.NONE}function k(e){switch(e){case"Commander":return p.COMMANDER;case"Leader":return p.LEADER;case"Specialist":return p.SPECIALIST;case"Non-specialist":return p.NON_SPECIALIST}return p.NONE}function A(e,t){var n,r;t._name=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;let i=e;"profile"===e.tagName&&e.parentElement&&e.parentElement.parentElement&&(i=e.parentElement.parentElement),t._customName=null===(r=i.getAttributeNode("customName"))||void 0===r?void 0:r.nodeValue;let o=i.firstElementChild;return o&&"customNotes"===o.tagName&&(t._customNotes=o.textContent),t._name}function T(e){const t=[];for(const n of e.children)if("selections"===n.tagName)for(const e of n.children)"selection"===e.tagName&&t.push(e);return t}function N(e,t){for(const n of e.children)if("profiles"===n.tagName)for(const e of n.children)if("profile"===e.tagName&&e.getAttribute("typeName")===t)return!0;return!1}function L(e){const t=new b;for(const n of e.children)if("costs"===n.tagName)for(const e of n.children)t.add(R(e));return t}function R(e){const t=new b,n=e.getAttribute("name"),r=e.getAttribute("value");return n&&r&&(" PL"===n?t._powerLevel+=+r:"pts"===n?t._points+=+r:"CP"===n?t._commandPoints+=+r:t.addFreeformValue(n,+r)),t}function P(e,t){var n;let r=new m;A(e,r);let i=e.querySelectorAll("categories>category");for(let e of i){const i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;if(i){const e="Faction: ",n=i.lastIndexOf(e);if(n>=0){const t=i.slice(n+e.length);r._factions.add(t)}else{const e=i.trim();let n=S(e);n!=p.NONE?r._role=n:t?r._keywords.add(i):(n=k(e),n!=p.NONE?r._role=n:r._keywords.add(i))}}}const o=[],s=Array.from(e.querySelectorAll('profile[typeName="Unit"],profile[typeName="Model"]'));!function(e,t,n){for(const n of e){const e=n.getAttribute("name"),r=n.getAttribute("typeName");if(!e||!r)return;const i=new _;i._name=e,t._modelStats.push(i),A(n,i);const o=n.querySelectorAll("characteristics>characteristic");for(const e of o){const t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"M":i._move=e.textContent;break;case"WS":i._ws=e.textContent;break;case"BS":i._bs=e.textContent;break;case"S":i._str=+e.textContent;break;case"T":i._toughness=+e.textContent;break;case"W":i._wounds=+e.textContent;break;case"A":i._attacks=e.textContent;break;case"Ld":i._leadership=+e.textContent;break;case"Save":i._save=e.textContent}}}}(s,r),o.push(...s);const a=[];if("model"===e.getAttribute("type"))a.push(e);else{const t=T(e);for(const e of t)("model"===e.getAttribute("type")||N(e,"Unit"))&&a.push(e);0===a.length&&a.push(...Array.from(e.querySelectorAll('selection[type="model"]'))),0===a.length&&N(e,"Unit")&&a.push(e)}for(const e of a){const t=Array.from(e.querySelectorAll("profiles>profile")),n=t.filter((e=>!o.includes(e)));o.push(...n);const i=new _;i._name=e.getAttribute("name")||"Unknown Model",i._count=Number(e.getAttribute("number")||1),r._models.push(i),O(t,i,r);for(const t of e.querySelectorAll('selections>selection[type="upgrade"]')){if(t.querySelector('selections>selection[type="upgrade"]')&&!N(t,"Abilities"))continue;let e=t.getAttribute("name");if(e){const n=new l;n._name=e,n._cost=L(t),n._count=Number(t.getAttribute("number")),i._upgrades.push(n)}}}let c=Array.from(e.querySelectorAll("profiles>profile")).filter((e=>!o.includes(e)));if(o.push(...c),c.length>0){const t=new _;if(t._name="Unit Upgrades",O(c,t,r),t._weapons.length>0&&r._models.length>0){for(const e of r._models)e._weapons.push(...t._weapons);t._weapons.length=0}t._psychicPowers.length>0&&(r._spells.push(...t._psychicPowers),t._psychicPowers.length=0),t._psyker&&(r._psykers.push(t._psyker),t._psyker=null),t._explosions.length>0&&(r._explosions.push(...t._explosions),t._explosions.length=0);for(const n of T(e)){if("upgrade"!==n.getAttribute("type"))continue;if(a.includes(n))continue;if(n.querySelector('profiles>profile[typeName="Weapon"]'))continue;let e=n.getAttribute("name");if(!e)continue;const r=new l;r._name=e,r._cost=L(n),r._count=Number(n.getAttribute("number")),t._upgrades.push(r)}(t._weapons.length>0||t._upgrades.length>0)&&r._models.push(t)}let u=e.querySelectorAll("costs>cost");for(let e of u)r._cost.add(R(e));let d=e.querySelectorAll("rules > rule");for(let e of d)E(e,r._rules);return r.normalize(),r}function O(e,t,n){for(const r of e){const e=r.getAttribute("name"),i=r.getAttribute("typeName");if(e&&i)if("Unit"===i||"Model"===i||"model"===r.getAttribute("type"));else if("Weapon"===i){const e=z(r);t._weapons.push(e)}else if(i.includes("Wound Track")||i.includes("Stat Damage")||i.includes(" Wounds")){const e=I(r);n._woundTracker.push(e)}else if("Psychic Power"==i){const e=B(r);t._psychicPowers.push(e)}else if(i.includes("Explosion")){const e=M(r);t._explosions.push(e)}else"Psyker"==i?t._psyker=U(r):(n._abilities[i]||(n._abilities[i]=new Map),W(r,e,0,n._abilities[i]))}}function W(e,t,n,r){const i=e.querySelectorAll("characteristics>characteristic");for(const e of i){if(!e.textContent)continue;const n=e.getAttribute("name");n&&i.length>1?r.set([t,n.toString()].join(" - "),e.textContent):r.set(t,e.textContent)}}function z(e){var t;const n=new c;A(e,n),n._count=function(e){var t;if(e.parentElement&&e.parentElement.parentElement){const n=null===(t=e.parentElement.parentElement.getAttributeNode("number"))||void 0===t?void 0:t.nodeValue;if(n)return+n}return 0}(e);let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"Range":n._range=e.textContent;break;case"Type":n._type=e.textContent;break;case"S":n._str=e.textContent;break;case"AP":n._ap=e.textContent;break;case"D":n._damage=e.textContent;break;case"Abilities":n._abilities=e.textContent}}const i=null===(t=e.parentElement)||void 0===t?void 0:t.parentElement,o=null==i?void 0:i.getAttribute("name");return"upgrade"===(null==i?void 0:i.getAttribute("type"))&&o&&(n._selectionName=o,n._cost=L(i)),n}function I(e){let t=new u;A(e,t);let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){const n=e.getAttribute("name");n&&(e.textContent?t._table.set(n,e.textContent):t._table.set(n,"-"))}return t}function B(e){const t=new f;A(e,t);const n=e.querySelectorAll("characteristics>characteristic");for(let e of n){const n=e.getAttribute("name");if(n&&e.textContent)switch(n){case"Range":t._range=e.textContent;break;case"Warp Charge":t._manifest=+e.textContent;break;case"Details":t._details=e.textContent}}return t}function M(e){const t=new d;A(e,t);const n=e.querySelectorAll("characteristics>characteristic");for(const e of n){const n=e.getAttribute("name");if(n&&e.textContent)switch(n){case"Dice Roll":t._diceRoll=e.textContent;break;case"Distance":t._distance=e.textContent;break;case"Mortal Wounds":t._mortalWounds=e.textContent}}return t}function U(e){const t=new h;A(e,t);const n=e.querySelectorAll("characteristics>characteristic");for(const e of n){const n=e.getAttribute("name");if(n&&e.textContent)switch(n){case"Cast":t._cast=e.textContent;break;case"Deny":t._deny=e.textContent;break;case"Powers Known":t._powers=e.textContent;break;case"Other":t._other=e.textContent}}return t}function D(e,t){return H(e._name,t._name)}function F(e,t){return e._name===t._name?H(e.nameAndGear(),t.nameAndGear()):"Unit Upgrades"===e._name?1:"Unit Upgrades"===t._name?-1:H(e._name,t._name)}function q(e,t){return(e._type.startsWith("Grenade")?2:e._type.startsWith("Melee")?1:0)-(t._type.startsWith("Grenade")?2:t._type.startsWith("Melee")?1:0)||e.name().localeCompare(t.name())}function H(e,t){return e>t?1:e==t?0:-1}t.Costs=b,t.Create40kRoster=function(e,t=!0){var n;if(e){let r=e.querySelector("roster");if(r){const i=new v,o=null===(n=r.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;i._name=o||"40k Army Roster";let s=r.querySelector("customNotes");return s&&(i._customNotes=s.textContent),function(e,t){let n=e.querySelectorAll("roster>costs>cost");for(let e of n)t._cost.add(R(e))}(e,i),function(e,t,n){var r,i;let o=e.querySelectorAll("roster>forces>force");for(let e of o)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let o=new g,s=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue,a=null===(i=e.getAttributeNode("catalogueName"))||void 0===i?void 0:i.nodeValue;if(s&&(o._name=s),a&&(o._catalog=a),!C(o,t)){const t=e.querySelectorAll("force>rules>rule");for(let e of t)E(e,o._rules)}y(e,o,n),t._forces.push(o)}}(e,i,t),i}}return null},t.CompareWeapon=q,t.Compare=H},208:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Wh40k=void 0;const s=o(n(486));!function(e){class t{constructor(){this._name="",this._customName="",this._customNotes=""}name(){return this._customName?this._customName:this._name}notes(){return this._customNotes}equal(e){return null!=e&&this._name===e._name}hash(){return N(this.name())}}e.BaseNotes=t;class n extends t{constructor(){super(...arguments),this._cost=new d,this._count=1}selectionName(){return this.name()}toString(){let e=this.selectionName();return this._count>1&&(e=`${this._count}x ${e}`),this._cost.hasValues()&&(e+=` ${this._cost.toString()}`),e}}let r;function i(e){switch(e){case"Epic Hero":return r.EpicHero;case"Character":return r.Character;case"Battleline":return r.Battleline;case"Infantry":return r.Infantry;case"Swarm":return r.Swarm;case"Mounted":return r.Mounted;case"Beast":return r.Beast;case"Monster":return r.Monster;case"Vehicle":return r.Vehicle;case"Dedicated Transport":return r.Transport;case"Fortification":return r.Fortification;case"Allied Units":return r.Allied;default:return r.NONE}}e.Upgrade=n,e.Weapon=class extends n{constructor(){super(...arguments),this._selectionName="",this._range="Melee",this._attacks="1",this._skill="",this._str="user",this._ap="",this._damage="",this._abilities=""}selectionName(){return this._selectionName||this.name()}},function(e){e[e.NONE=0]="NONE",e[e.EpicHero=1]="EpicHero",e[e.Character=2]="Character",e[e.Battleline=3]="Battleline",e[e.Infantry=4]="Infantry",e[e.Swarm=5]="Swarm",e[e.Mounted=6]="Mounted",e[e.Beast=7]="Beast",e[e.Monster=8]="Monster",e[e.Vehicle=9]="Vehicle",e[e.Transport=10]="Transport",e[e.Fortification=11]="Fortification",e[e.Allied=12]="Allied"}(r=e.UnitRole||(e.UnitRole={})),e.UnitRoleToString={[r.NONE]:"None",[r.EpicHero]:"Epic Hero",[r.Character]:"Character",[r.Battleline]:"Battleline",[r.Infantry]:"Infantry",[r.Swarm]:"Swarm",[r.Mounted]:"Mounted",[r.Beast]:"Beast",[r.Monster]:"Monster",[r.Vehicle]:"Vehicle",[r.Transport]:"Dedicated Transport",[r.Fortification]:"Fortification",[r.Allied]:"Allied Units"};class o extends t{constructor(){super(...arguments),this._count=0,this._move='0"',this._toughness=4,this._save="4+",this._wounds=1,this._leadership="6+",this._objControl=1,this._weapons=[],this._upgrades=[]}equal(e){if(null==e)return!1;if(this._name===e._name&&this._count===e._count&&this._weapons.length===e._weapons.length&&this._upgrades.length===e._upgrades.length){for(let t=0;t0||this._upgrades.length>0)&&(e+=` (${this.getDedupedWeaponsAndUpgrades().map((e=>e.toString())).join(", ")})`),e}getDedupedWeaponsAndUpgrades(){const e=[];for(const t of[...this._weapons,...this._upgrades])e.some((e=>t.selectionName()===e.selectionName()))||e.push(t);return e}normalize(){this._weapons.sort(A),this._upgrades.sort(S),this.normalizeUpgrades(this._weapons),this.normalizeUpgrades(this._upgrades)}normalizeUpgrades(e){for(let t=0;te[0])).flat();this._profileTables[e]._contents=t.filter(((e,t)=>n.indexOf(e[0])===t))}for(let e=0;e(e._count>1?`${e._count}x `:"")+e.nameAndGear())),this._weapons=this._models.map((e=>e._weapons)).reduce(((e,t)=>e.concat(t)),[]).sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}}e.Unit=l;class c extends t{constructor(){super(...arguments),this._catalog="",this._faction="Unknown",this._factionRules=new Map,this._configurations=[],this._rules=new Map,this._units=[]}hash(){let e=71;for(const t of this._units)e=L(e,t.hash());return e}}e.Force=c;class u extends t{constructor(){super(...arguments),this._cost=new d,this._forces=[]}hash(){let e=59;for(const t of this._forces)e=L(e,t.hash());return e}}e.Roster40k=u;class d{constructor(){this._points=0}hasValues(){return 0!==this._points}toString(){const e=[];return 0!==this._points&&e.push(`${this._points} pts`),`[${e.join(" / ")}]`}add(e){this._points+=e._points;for(const t in e._freeformValues)this.addFreeformValue(t,e._freeformValues[t])}addFreeformValue(e,t){this._freeformValues||(this._freeformValues={});const n=this._freeformValues[e]||0;this._freeformValues[e]=n+t}}function h(e,t,n){var r;let i=e.querySelectorAll("force>selections>selection");for(let e of i){let n=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue;if(n)if(n.includes("Detachment Command Cost"));else if("Battle Size"===n||"Gametype"===n)f(e,t);else if(e.querySelector('profile[typeName="Unit"]')){const n=w(e);t._units.push(n);for(const e of n._rules.entries())t._rules.set(e[0],e[1]);for(const e of n._weaponRules.entries())t._rules.set(e[0],e[1])}else if("upgrade"===e.getAttribute("type")){_(e,t._rules),f(e,t);const n=e.querySelectorAll("selections>selection");for(let e of n){const n=e.getAttribute("name");n&&"upgrade"===e.getAttribute("type")&&("Unknown"===t._faction&&(t._faction=n),_(e,t._factionRules))}}else console.log("** UNEXPECTED SELECTION **",n,e)}for(const e of t._factionRules.keys())t._rules.delete(e);t._rules=new Map([...t._rules.entries()].sort()),t._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?e._name>t._name?1:e._name==t._name?0:-1:-1))}function f(e,t){var n;const r=e.getAttribute("name");if(!r)return;const i=null===(n=e.querySelector("category"))||void 0===n?void 0:n.getAttribute("name"),o=e.querySelectorAll("selections>selection"),s=[];let a=b(e);for(const e of o)s.push(e.getAttribute("name")),a.add(b(e));let l=i&&"Configuration"!==i?`${i} - ${r}`:r;s.length>0&&(l+=`: ${s.join(", ")}`),a.hasValues()&&(l+=` ${a.toString()}`),t._configurations.push(l)}function p(e,t){if(!t||!e)return!1;for(let n of t._forces)if(n._catalog===e._catalog)return!0;return!1}function _(e,t){const n=e.querySelectorAll("profiles>profile");for(const e of n){const n=e.getAttribute("name");if(!n)continue;const r=e.getAttribute("typeName");"Abilities"!==r&&"Dynastic Code"!==r&&"Household Tradition"!==r||E(e,n,0,t)}const r=e.querySelectorAll("rules>rule");for(const e of r)m(e,t)}function m(e,t){const n=e.getAttribute("name"),r=e.querySelector("description");n&&(null==r?void 0:r.textContent)&&t.set(n,r.textContent)}function g(e){const t=[];for(const n of e.children)if("selections"===n.tagName)for(const e of n.children)"selection"===e.tagName&&t.push(e);return t}function v(e,t){for(const n of e.children)if("profiles"===n.tagName)for(const e of n.children)if("profile"===e.tagName&&e.getAttribute("typeName")===t)return!0;return!1}function b(e){const t=new d;for(const n of e.children)if("costs"===n.tagName)for(const e of n.children)t.add(y(e));return t}function y(e){const t=new d,n=e.getAttribute("name"),r=e.getAttribute("value");return n&&r&&("pts"===n?t._points+=+r:t.addFreeformValue(n,+r)),t}function w(e,t){var s,c;let u=new l;!function(e,t){var n,r;t._name=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;let i=e;"profile"===e.tagName&&e.parentElement&&e.parentElement.parentElement&&(i=e.parentElement.parentElement),t._customName=null===(r=i.getAttributeNode("customName"))||void 0===r?void 0:r.nodeValue;let o=i.firstElementChild;o&&"customNotes"===o.tagName&&(t._customNotes=o.textContent),t._name}(e,u);let d=e.querySelectorAll("categories>category");for(let e of d){const t=null===(s=e.getAttributeNode("name"))||void 0===s?void 0:s.nodeValue;if(t){const e="Faction: ",n=t.lastIndexOf(e);if(n>=0){const r=t.slice(n+e.length);u._factions.add(r)}else{let e=i(t.trim());e!=r.NONE&&(u._role=e),u._keywords.add(t)}}}const h=[],f=Array.from(e.querySelectorAll('profile[typeName="Unit"],profile[typeName="Model"]'));for(const e of f){const t=e.getAttribute("name"),n=e.getAttribute("typeName");t&&n&&(u._profileTables[n]||(u._profileTables[n]=new a),x(e,t,n,u._profileTables[n]))}h.push(...f);const p=[];if("model"===e.getAttribute("type"))p.push(e);else{const t=g(e);for(const e of t)("model"===e.getAttribute("type")||v(e,"Unit"))&&p.push(e);0===p.length&&p.push(...Array.from(e.querySelectorAll('selection[type="model"]'))),0===p.length&&v(e,"Unit")&&p.push(e)}for(const e of p){const t=Array.from(e.querySelectorAll("profiles>profile")),r=t.filter((e=>!h.includes(e)));h.push(...r);const i=new o;i._name=e.getAttribute("name")||"Unknown Model",i._count=Number(e.getAttribute("number")||1),u._models.push(i),C(t,0,u);for(const t of e.querySelectorAll('selections>selection[type="upgrade"]')){if(t.querySelector('selections>selection[type="upgrade"]')&&!v(t,"Abilities"))continue;let e=t.getAttribute("name");if(e){const r=new n;r._name=e,r._cost=b(t),r._count=Number(t.getAttribute("number")),i._upgrades.push(r)}}}let _=Array.from(e.querySelectorAll("profiles>profile")).filter((e=>!h.includes(e)));if(h.push(..._),_.length>0){const t=new o;if(t._name="Unit Upgrades",C(_,0,u),t._weapons.length>0&&u._models.length>0){for(const e of u._models)e._weapons.push(...t._weapons);t._weapons.length=0}for(const r of g(e)){if("upgrade"!==r.getAttribute("type"))continue;if(p.includes(r))continue;if(r.querySelector('profiles>profile[typeName="Weapon"]'))continue;let e=r.getAttribute("name");if(!e)continue;const i=new n;i._name=e,i._cost=b(r),i._count=Number(r.getAttribute("number")),t._upgrades.push(i)}(t._weapons.length>0||t._upgrades.length>0)&&u._models.push(t)}let w=e.querySelectorAll("costs>cost");for(let e of w)u._cost.add(y(e));let E=e.querySelectorAll("rules > rule");for(let e of E){const t=null===(c=e.parentElement)||void 0===c?void 0:c.parentElement;t&&(v(t,"Ranged Weapons")||v(t,"Melee Weapons"))?m(e,u._weaponRules):m(e,u._rules)}return u.normalize(),u}function C(e,t,n){for(const t of e){const e=t.getAttribute("name"),r=t.getAttribute("typeName");e&&r&&(t.querySelectorAll("characteristics>characteristic").length>1?(n._profileTables[r]||(n._profileTables[r]=new a),x(t,e,r,n._profileTables[r])):(n._abilities[r]||(n._abilities[r]=new Map),E(t,e,0,n._abilities[r])))}}function x(e,t,n,r){const i=e.querySelectorAll("characteristics>characteristic"),o={[n]:t};for(const e of i){if(!e.textContent)continue;const t=e.getAttribute("name");t&&(o[t]=e.textContent)}r.addRow(o)}function E(e,t,n,r){const i=e.querySelectorAll("characteristics>characteristic");for(const e of i){if(!e.textContent)continue;const n=e.getAttribute("name");n&&i.length>1?r.set([t,n.toString()].join(" - "),e.textContent):r.set(t,e.textContent)}}function S(e,t){return T(e._name,t._name)}function k(e,t){return e._name===t._name?T(e.nameAndGear(),t.nameAndGear()):"Unit Upgrades"===e._name?1:"Unit Upgrades"===t._name?-1:T(e._name,t._name)}function A(e,t){return e.name().localeCompare(t.name())}function T(e,t){return e>t?1:e==t?0:-1}function N(e){let t=23;for(var n=0;ncosts>cost");for(let e of n)t._cost.add(y(e))}(e,r),function(e,t,n){var r,i;let o=e.querySelectorAll("roster>forces>force");for(let e of o)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let n=new c,o=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue,s=null===(i=e.getAttributeNode("catalogueName"))||void 0===i?void 0:i.nodeValue;if(o&&(n._name=o),s&&(n._catalog=s),!p(n,t)){const t=e.querySelectorAll("force>rules>rule");for(let e of t)m(e,n._rules)}h(e,n),t._forces.push(n)}}(e,r),r}}return null},e.CompareWeapon=A,e.Compare=T,e.CompareProfileTableName=function(e,t){const n=["Unit","Ranged Weapons","Melee Weapons"];return(n.includes(e)?n.indexOf(e):n.length)-(n.includes(t)?n.indexOf(t):n.length)}}(t.Wh40k||(t.Wh40k={}))},774:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CreateAoSRoster=t.RosterAoS=t.AoSForce=t.AoSUnit=t.AoSUnitRoleToString=t.AoSUnitRole=t.AoSRealmOfBattle=t.AoSSpecialRules=t.AoSCoreBattalion=t.AoSTriumph=t.AoSGrandStrategy=t.AoSAllegiance=t.AoSPrayer=t.AoSSpell=t.AoSWoundTracker=t.AoSWeapon=t.AoSProfile=t.AoSProfileType=void 0;const s=o(n(486));class a{constructor(){this._typeName="anonymous",this._fields=new Map}}t.AoSProfileType=a;class l{constructor(){this._name="none",this._value=new a}}t.AoSProfile=l;class c{constructor(){this._name="",this._type="Melee",this._range="",this._attacks="",this._toHit="",this._toWound="",this._rend="",this._damage=""}}t.AoSWeapon=c;class u{constructor(){this._title="",this._labels=[],this._table=[[]]}}t.AoSWoundTracker=u;class d{constructor(){this._name="",this._castingValue=0,this._range="",this._description=""}}t.AoSSpell=d;class h{constructor(){this._name="",this._answerValue=0,this._range="",this._description=""}}t.AoSPrayer=h;class f{constructor(){this._name="",this._battleTraits=new Map,this._commandAbilities=new Map,this._spells=[],this._extraProfiles=[]}}t.AoSAllegiance=f;class p{constructor(){this._name="",this._description=""}}t.AoSGrandStrategy=p;class _{constructor(){this._name="",this._description=""}}t.AoSTriumph=_;class m{constructor(){this._name="",this._abilities=new Map}}t.AoSCoreBattalion=m;class g{constructor(){this._name="",this._description=""}}t.AoSSpecialRules=g;class v{constructor(){this._name="",this._spells=[],this._commandAbilities=new Map,this._rules=[]}}var b;t.AoSRealmOfBattle=v,function(e){e[e.NONE=0]="NONE",e[e.LEADER=1]="LEADER",e[e.BATTLELINE=2]="BATTLELINE",e[e.BEHEMOTH=3]="BEHEMOTH",e[e.ARTILLERY=4]="ARTILLERY",e[e.OTHER=5]="OTHER",e[e.SCENERY=6]="SCENERY",e[e.BATTALION=7]="BATTALION",e[e.MALIGN_SORCERY=8]="MALIGN_SORCERY",e[e.REALM=9]="REALM"}(b=t.AoSUnitRole||(t.AoSUnitRole={})),t.AoSUnitRoleToString=["None","Leader","Battleline","Behemoth","Artillery","Other","Scenery","Battalion","Malign Sorcery","Realm"];class y{constructor(){this._name="",this._id=0,this._role=b.NONE,this._keywords=new Set,this._abilities=new Map,this._commandAbilities=new Map,this._commandTraits=new Map,this._magic=new Map,this._artefacts=new Map,this._count=0,this._move='0"',this._wounds=1,this._bravery=7,this._save="",this._weapons=[],this._spells=[],this._prayers=[],this._points=0,this._woundTracker=null,this._extraProfiles=[],this._selections=new Set}equal(e){return null!=e&&e._name===this._name&&e._role===this._role&&!!s.isEqual(this._commandTraits,e._commandTraits)&&!!s.isEqual(this._artefacts,e._artefacts)&&!!s.isEqual(this._weapons,e._weapons)}isNormalUnit(){return this._role==b.ARTILLERY||this._role==b.BATTLELINE||this._role==b.BEHEMOTH||this._role==b.LEADER||this._role==b.OTHER}}t.AoSUnit=y;class w{constructor(){this._catalog="",this._name="Unknown",this._units=[],this._battalions=[],this._rules=new Map,this._battleTactics=new Map,this._allegiance=new f,this._grandStrategy=new p,this._triumph=new _,this._realmOfBattle=new v}}t.AoSForce=w;class C{constructor(){this._commandPoints=0,this._points=0,this._name="",this._forces=[]}}function x(e){switch(e){case"Leader":return b.LEADER;case"Battleline":return b.BATTLELINE;case"Other":return b.OTHER;case"Behemoth":return b.BEHEMOTH;case"Artillery":return b.ARTILLERY;case"Scenery":return b.SCENERY;case"Battalion":return b.BATTALION;case"Malign Sorcery":return b.MALIGN_SORCERY;case"Realm":return b.REALM}return b.NONE}function E(e,t){var n,r,i,o,s,a,l;let c=e.querySelectorAll("force>selections>selection"),u=0;for(let e of c){let c=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;if(c)if(c.includes("Allegiance")){let n=A(e);n&&(t._allegiance=n)}else if(c.includes("Grand Strategy")){let n=T(e);n&&(t._grandStrategy=n)}else if(c.includes("Game Type"));else if(c.includes("Core Battalion")){let n=new m;n._name=c;let s=e.querySelectorAll("profiles>profile");for(let e of s)for(let e of s){let t=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue,s=null===(i=e.getAttributeNode("typeName"))||void 0===i?void 0:i.nodeValue;if(t&&s){let t=e.querySelectorAll("characteristics>characteristic");for(let e of t){let t=null===(o=e.getAttributeNode("name"))||void 0===o?void 0:o.nodeValue;t&&e.textContent&&n._abilities.set(t,e.textContent)}}}t._battalions.push(n)}else if(c.includes("Realm of Battle")){let n=L(e);n&&(t._realmOfBattle=n)}else if(c.includes("GHB 2023 Rules")){let n=R(e);n&&(t._realmOfBattle=n)}else if(c.includes("Triumphs")){let n=N(e);n&&(t._triumph=n)}else if(c.includes("Battle Tactic")){let n=e.querySelectorAll("profiles>profile");for(let e of n)for(let e of n){let n=null===(s=e.getAttributeNode("name"))||void 0===s?void 0:s.nodeValue,r=null===(a=e.getAttributeNode("typeName"))||void 0===a?void 0:a.nodeValue;if(n&&r){let r=e.querySelectorAll("characteristics>characteristic");for(let e of r)(null===(l=e.getAttributeNode("name"))||void 0===l?void 0:l.nodeValue)&&e.textContent&&t._battleTactics.set(n,e.textContent)}}}else{let n=k(e);n&&n._role!=b.NONE&&(n._id=u++,t._units.push(n))}}t._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?0:-1))}function S(e,t){var n;let r=e.querySelectorAll("force>rules>rule");for(let e of r){let r=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,i=e.querySelectorAll("description");if(r&&i)for(let e of i)e.textContent&&t._rules.set(r,e.textContent)}}function k(e){var t,n,r,i,o,s,a,l,f,p,_,m,g,v,w;let C=new y,E=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;E&&(C._name=E);let S=e.querySelectorAll("profiles>profile");for(let e of S){let t=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,p=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(t&&p)if("Unit"==p){C._name||(C._name=t);let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(t&&e.textContent)switch(t){case"Move":C._move=e.textContent;break;case"Wounds":C._wounds=+e.textContent;break;case"Bravery":C._bravery=+e.textContent;break;case"Save":C._save=e.textContent}}}else if("Unit Abilities"==p){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&C._abilities.set(t,n.textContent)}else if("Command Abilities"==p){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&C._commandAbilities.set(t,n.textContent)}else if("Magic"==p){let t=e.querySelectorAll("characteristics>characteristic");for(let e of t){let t=null===(o=e.getAttributeNode("name"))||void 0===o?void 0:o.nodeValue;t&&e.textContent&&C._magic.set(t,e.textContent)}}else if("Unit Leader"==p){let t=e.querySelector("characteristics>characteristic");t&&t.textContent&&C._abilities.set(p,t.textContent)}else if("Spell"==p){let n=new d;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(s=e.getAttributeNode("name"))||void 0===s?void 0:s.nodeValue;if(t&&e.textContent)switch(t){case"Casting Value":n._castingValue=+e.textContent;break;case"Range":n._range=e.textContent;break;case"Description":n._description=e.textContent}}C._spells.push(n)}else if("Weapon"==p){let n=new c;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(a=e.getAttributeNode("name"))||void 0===a?void 0:a.nodeValue;if(t&&e.textContent)switch(t){case"Range":n._range=e.textContent;break;case"Type":n._type=e.textContent;break;case"Attacks":n._attacks=e.textContent;break;case"Rend":n._rend=e.textContent;break;case"To Hit":n._toHit=e.textContent;break;case"To Wound":n._toWound=e.textContent;break;case"Damage":n._damage=e.textContent}}C._weapons.push(n)}else if("Command Trait"==p){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&C._commandTraits.set(t,n.textContent)}else if("Artefact"==p){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&C._artefacts.set(t,n.textContent)}else if("Prayer"==p){let n=new h;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(l=e.getAttributeNode("name"))||void 0===l?void 0:l.nodeValue;if(t&&e.textContent)switch(t){case"Answer Value":n._answerValue=+e.textContent;break;case"Range":n._range=e.textContent;break;case"Description":n._description=e.textContent}}C._prayers.push(n)}else if(p.includes("Damage Table")||p.includes("Wounds")||p.includes("Wound Track")||p.includes("Wound Table")){let n=[];if(C._woundTracker){let r=e.querySelectorAll("characteristics>characteristic");if(r.length<=3){let e=t;e?n.push(e):n.push("Unknown");for(let e of r)e.textContent?n.push(e.textContent):n.push("Unknown")}else for(let e of r)e.textContent?n.push(e.textContent):n.push("Unknown");C._woundTracker._table.push(n),n=[]}else{C._woundTracker=new u,C._woundTracker._title=p;let r=e.querySelectorAll("characteristics>characteristic");if(r.length<=3){C._woundTracker._labels.push("Wounds Suffered"),n.push(t);for(let e of r){let t=null===(f=e.getAttributeNode("name"))||void 0===f?void 0:f.nodeValue;t?C._woundTracker._labels.push(t):C._woundTracker._labels.push("Unknown"),e.textContent?n.push(e.textContent):n.push("Unknown")}}else for(let e of r)e.textContent?C._woundTracker._labels.push(e.textContent):C._woundTracker._labels.push("Unknown");C._woundTracker._table.push(n),n=[]}}else{let t=P(e);t?C._extraProfiles.push(t):console.log("Unknown unit profile type: "+p)}}let k=e.querySelectorAll("selections>selection");for(let e of k){let t=null===(p=e.getAttributeNode("name"))||void 0===p?void 0:p.nodeValue;if(t&&(C._selections.add(t),t.includes("Wound Track"))){C._woundTracker=new u,C._woundTracker._title=t,C._woundTracker._labels=["Wounds Suffered"];let n=e.querySelectorAll("profiles>profile"),r=!0;for(let e of n){let t=null===(_=e.getAttributeNode("name"))||void 0===_?void 0:_.nodeValue,n=e.querySelectorAll("characteristics>characteristic"),i=[];t?i.push(t):i.push("--");for(let e of n){let t=null===(m=e.getAttributeNode("name"))||void 0===m?void 0:m.nodeValue,n=e.textContent;r&&(t?C._woundTracker._labels.push(t):C._woundTracker._labels.push("Unknown")),n?i.push(n):i.push("Unknown")}r=!1,C._woundTracker._table.push(i)}}}let A=e.querySelectorAll("costs>cost");for(let e of A)if(e.hasAttribute("name")&&e.hasAttribute("value")){let t=null===(g=e.getAttributeNode("name"))||void 0===g?void 0:g.nodeValue,n=null===(v=e.getAttributeNode("value"))||void 0===v?void 0:v.nodeValue;n&&"pts"===t&&(C._points+=+n)}let T=e.querySelectorAll(":scope categories>category");for(let e of T){let t=null===(w=e.getAttributeNode("name"))||void 0===w?void 0:w.nodeValue;if(t){var N=x(t.trim());N!=b.NONE?C._role=N:C._keywords.add(t)}}return C}function A(e){var t,n,r,i;let o=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;if(o){let t=new f;t._name=o;let s=e.querySelectorAll("profiles>profile");for(let e of s){let o=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(o&&s)if("Battle Trait"==s){let n=e.querySelector("characteristics>characteristic");if(n){let e=n.textContent;e&&(null==t||t._battleTraits.set(o,e))}}else if("Command Abilities"==s){let n=e.querySelector("characteristics>characteristic");if(n){let e=n.textContent;e&&(null==t||t._commandAbilities.set(o,e))}}else if("Spell"==s){let n=new d;n._name=o;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(t&&e.textContent)switch(t){case"Casting Value":n._castingValue=+e.textContent;break;case"Range":n._range=e.textContent;break;case"Description":n._description=e.textContent}}null==t||t._spells.push(n)}else{let n=P(e);n?null==t||t._extraProfiles.push(n):console.log("Unexpected allegiance profile type: "+s)}}return t}return null}function T(e){var t,n,r;let i=null,o=e.querySelector("selections>selection");if(o){let e=null===(t=o.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;e&&(i=new p,i._name=e);let s=o.querySelectorAll("profiles>profile");for(let e of s){let t=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(t&&o)if("Grand Strategy"==o){let t=e.querySelector("characteristics>characteristic");if(t){let e=t.textContent;e&&i&&(i._description=e)}}else console.log("Unexpected Grand Strategy profile type: "+o)}}return i}function N(e){var t,n,r;let i=null,o=e.querySelector("selections>selection");if(o){let e=null===(t=o.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;e&&(i=new _,i._name=e);let s=o.querySelectorAll("profiles>profile");for(let e of s){let t=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(t&&o)if("Triumph"==o){let t=e.querySelector("characteristics>characteristic");if(t){let e=t.textContent;e&&i&&(i._description=e)}}else console.log("Unexpected Triumph profile type: "+o)}}return i}function L(e){var t,n,r,i;let o=null,s=e.querySelector("selections>selection");if(s){let e=null===(t=s.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;if(e){o=new v,o._name=e;let t=s.querySelectorAll("profiles>profile");for(let e of t){let t=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(t&&s)if("Spell"==s){let n=new d;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(t&&e.textContent)switch(t){case"Casting Value":n._castingValue=+e.textContent;break;case"Range":n._range=e.textContent;break;case"Description":n._description=e.textContent}}o._spells.push(n)}else if("Command Abilities"==s){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&o._commandAbilities.set(t,n.textContent)}else if("Special Rules"==s){let n=e.querySelector("characteristics>characteristic");if(n&&n.textContent){let e=new g;e._name=t,e._description=n.textContent,o._rules.push(e)}}else console.log("Unexpected Realm of Battle profile type: "+s)}}}return o}function R(e){var t,n,r,i;let o=null,s=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;if(s){o=new v,o._name=s;let t=e.querySelectorAll("profiles>profile");for(let e of t){let t=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(t&&s)if("Spell"==s){let n=new d;n._name=t;let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(t&&e.textContent)switch(t){case"Casting Value":n._castingValue=+e.textContent;break;case"Range":n._range=e.textContent;break;case"Description":n._description=e.textContent}}o._spells.push(n)}else if("Command Abilities"==s){let n=e.querySelector("characteristics>characteristic");n&&n.textContent&&o._commandAbilities.set(t,n.textContent)}else if("Special Rules"==s||"Heroic Action"==s){let n=e.querySelector("characteristics>characteristic");if(n&&n.textContent){let e=new g;e._name=t,e._description=n.textContent,o._rules.push(e)}}else console.log("Unexpected Realm of Battle profile type: "+s)}}return o}function P(e){var t,n,r;if(!e)return null;let i=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue,o=null===(n=e.getAttributeNode("typeName"))||void 0===n?void 0:n.nodeValue;if(!i||!o)return null;let s=new l;s._name=i,s._value._typeName=o;let a=e.querySelectorAll("characteristics>characteristic");for(let e of a){let t=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue;t&&e.textContent&&s._value._fields.set(t,e.textContent)}return s}t.RosterAoS=C,t.CreateAoSRoster=function(e){var t;if(e){let n=e.querySelector("roster");if(n){const r=new C,i=null===(t=n.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;return r._name=i||"Age of Sigmar Roster",function(e,t){var n,r;let i=e.querySelectorAll("roster>costs>cost");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("value")){let i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("value"))||void 0===r?void 0:r.nodeValue;o&&"pts"===i&&(t._points=+o)}}(e,r),function(e,t){var n,r;let i=e.querySelectorAll("roster>forces>force");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let i=new w,o=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("catalogueName"))||void 0===r?void 0:r.nodeValue;o&&(i._name=o),s&&(i._catalog=s),E(e,i),S(e,i),t._forces.push(i)}}(e,r),r}}return null}},980:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.HorusHeresy=void 0;const s=o(n(486));!function(e){let t;!function(e){e[e.NONE=0]="NONE",e[e.HQ=1]="HQ",e[e.TR=2]="TR",e[e.EL=3]="EL",e[e.FA=4]="FA",e[e.HS=5]="HS",e[e.FL=6]="FL",e[e.DT=7]="DT",e[e.FT=8]="FT",e[e.LW=9]="LW",e[e.PR=10]="PR"}(t=e.UnitRole||(e.UnitRole={})),e.UnitRoleToString=["None","HQ","Troops","Elites","Fast Attack","Heavy Support","Flyer","Dedicated Transport","Fortification","Lord of War","Primarch"];class n{constructor(){this._name="",this._customName="",this._customNotes=""}name(){return this._customName?this._customName:this._name}notes(){return this._customNotes}equal(e){return null!=e&&this._name===e._name}}e.BaseNote=n;class r extends n{constructor(){super(...arguments),this._description="",this._cost=new p,this._count=1}selectionName(){return this.name()}toString(){let e=this.selectionName();return this._count>1&&(e=`${this._count}x ${e}`),this._cost.hasValues()&&(e+=` ${this._cost.toString()}`),e}}e.Upgrade=r;class i extends r{constructor(){super(...arguments),this._selectionName="",this._range="Melee",this._str="user",this._ap="",this._type="Melee"}getRules(){let e=this._type.split(",");return e.length>0&&(e=e.slice(1).map((e=>e.trim()))),e}}e.Weapon=i;class o extends n{constructor(){super(...arguments),this._count=0,this._type="",this._weapons=[],this._upgrades=[],this._wargear=[],this._warlordTraits=[],this._reactions=[],this._psychicWeapons=[],this._psychicPowers=[]}equal(e){if(null==e)return!1;if(this._name===e._name&&this._count===e._count&&this._weapons.length===e._weapons.length&&this._upgrades.length===e._upgrades.length&&this._wargear.length===e._wargear.length&&this._psychicWeapons.length===e._psychicWeapons.length&&this._psychicPowers.length===e._psychicPowers.length){for(let t=0;t0||this._upgrades.length>0)&&(e+=` (${this.getDedupedWeaponsAndUpgrades().map((e=>e.toString())).join(", ")})`),e}getDedupedWeaponsAndUpgrades(){const e=[];for(const t of[...this._weapons,...this._upgrades])e.some((e=>t.selectionName()===e.selectionName()))||e.push(t);return e}normalize(){this._weapons.sort(N),this._upgrades.sort(A),this._wargear.sort(A),this._psychicPowers.sort(A),this._psychicWeapons.sort(N),this.normalizeUpgrades(this._weapons),this.normalizeUpgrades(this._upgrades),this.normalizeUpgrades(this._wargear),this.normalizeUpgrades(this._psychicPowers),this.normalizeUpgrades(this._psychicWeapons)}normalizeUpgrades(e){for(let t=0;t(e._count>1?`${e._count}x `:"")+e.nameAndGear()))}weapons(){let e=this._models.map((e=>e._weapons)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._weapons),e.sort(N).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}psychicWeapons(){let e=this._models.map((e=>e._psychicWeapons)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._psychicWeapons),e.sort(N).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}psychicPowers(){let e=this._models.map((e=>e._psychicPowers)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._psychicPowers),e.sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}wargear(){let e=this._models.map((e=>e._wargear)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._wargear),e.sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}weaponRules(){let e=[];return e=this.weapons().map((e=>e.getRules())).reduce(((e,t)=>e.concat(t)),[]),e.sort().filter(((e,t,n)=>e!==n[t-1]))}warlordTraits(){let e=this._models.map((e=>e._warlordTraits)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._warlordTraits),e.sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}upgrades(){let e=this._models.map((e=>e._upgrades)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._upgrades),e.sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}reactions(){let e=this._models.map((e=>e._reactions)).reduce(((e,t)=>e.concat(t)),[]);return e.push(...this._reactions),e.sort(A).filter(((e,t,n)=>{var r;return e.name()!==(null===(r=n[t-1])||void 0===r?void 0:r.name())}))}}e.Unit=d;class h extends n{constructor(){super(),this._catalog="",this._name="Unknown",this._faction="Unknown",this._factionRules=new Map,this._rules=new Map,this._units=[]}}e.Force=h;class f extends n{constructor(){super(),this._cost=new p,this._name="",this._forces=[]}}e.Roster=f;class p{constructor(){this._points=0}hasValues(){return 0!==this._points}toString(){const e=[];return 0!==this._points&&e.push(`${this._points} pts`),`[${e.join(" / ")}]`}add(e){this._points+=e._points;for(const t in e._freeformValues)this.addFreeformValue(t,e._freeformValues[t])}addFreeformValue(e,t){this._freeformValues||(this._freeformValues={});const n=this._freeformValues[e]||0;this._freeformValues[e]=n+t}}function _(e,t){return e>t?1:e==t?0:-1}function m(e,t){return typeof e>typeof t?1:typeof e==typeof t?0:-1}function g(e){const t=new p,n=e.getAttribute("name"),r=e.getAttribute("value");return n&&r&&("Pts"===n?t._points+=+r:t.addFreeformValue(n,+r)),t}function v(e,n){var i,o;let s=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(!s)return;let h=null===(o=e.getAttributeNode("type"))||void 0===o?void 0:o.nodeValue;if(h)if(e.querySelector('profile[typeId="4bb2-cb95-e6c8-5a21"]')||e.querySelector('profile[typeId="2fae-b053-3f78-e7b2"]')||e.querySelector('profile[typeId="75b5-9f7a-156e-6889"]')||e.querySelector('profile[typeId="eeec-bde3-8ee4-35b0"]')){const i=function(e){var n,i,o;let s=new d;b(e,s);let h=e.querySelectorAll("categories>category");for(let e of h){const r=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;if(r){let e=S(r.trim());e!=t.NONE?s._role=e:r.endsWith(":")||s._keywords.add(r)}}const f=[],p=Array.from(e.querySelectorAll('profile[typeId="4bb2-cb95-e6c8-5a21"],profile[typeId="2fae-b053-3f78-e7b2"],profile[typeId="75b5-9f7a-156e-6889"],profile[typeId="eeec-bde3-8ee4-35b0"]'));(function(e,t,n){var r,i;for(const n of e){const e=n.getAttribute("name"),o=n.getAttribute("typeName");if(!e||!o)return;if("Unit"===o.trim()){const r=new l;r._name=e,t._modelStats.push(r),b(n,r);const i=n.querySelectorAll("characteristics>characteristic");for(const e of i){const t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"Unit Type":r._type=e.textContent;break;case"Move":r._move=k(e.textContent);break;case"WS":r._ws=+e.textContent;break;case"BS":r._bs=+e.textContent;break;case"S":r._str=+e.textContent;break;case"T":r._toughness=+e.textContent;break;case"W":r._wounds=+e.textContent;break;case"I":r._initiative=+e.textContent;break;case"A":r._attacks=+e.textContent;break;case"Ld":r._leadership=+e.textContent;break;case"Save":r._save=e.textContent}}}else if("Knights and Titans"===o.trim()){let r=new c;r._name=e,t._modelStats.push(r),b(n,r);const i=n.querySelectorAll("characteristics>characteristic");for(const e of i){const t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"Unit Type":r._type=e.textContent;break;case"Move":r._move=k(e.textContent);break;case"WS":r._ws=+e.textContent;break;case"BS":r._bs=+e.textContent;break;case"S":r._str=+e.textContent;break;case"Front":r._front=+e.textContent;break;case"Side":r._side=+e.textContent;break;case"Rear":r._rear=+e.textContent;break;case"I":r._initiative=+e.textContent;break;case"A":r._attacks=+e.textContent;break;case"HP":r._hp=+e.textContent}}}else if("Vehicle"===o.trim()){let i=new a;i._name=e,t._modelStats.push(i),b(n,i);const o=n.querySelectorAll("characteristics>characteristic");for(const e of o){const t=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue;if(t&&e.textContent)switch(t){case"Unit Type":i._type=e.textContent;break;case"Move":i._move=k(e.textContent);break;case"BS":i._bs=+e.textContent;break;case"Front":i._front=+e.textContent;break;case"Side":i._side=+e.textContent;break;case"Rear":i._rear=+e.textContent;break;case"HP":i._hp=+e.textContent;break;case"Transport Capacity":i._capacity=e.textContent;break;case"Access Points":i._accessPoints=e.textContent}}}else if("Fortification"===o.trim()){let r=new u;r._name=e,t._modelStats.push(r),b(n,r);const o=n.querySelectorAll("characteristics>characteristic");for(const e of o){const t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;if(t&&e.textContent)switch(t){case"Unit Type":r._type=e.textContent;break;case"BS":r._bs=e.textContent;break;case"Front":r._front=+e.textContent;break;case"Side":r._side=+e.textContent;break;case"Rear":r._rear=+e.textContent;break;case"HP":r._hp=+e.textContent;break;case"Transport Capacity":r._capacity=e.textContent;break;case"Fire Points":r._firePoints=e.textContent}}}}})(p,s),f.push(...p);const _=[];if("model"===e.getAttribute("type"))_.push(e);else{const t=function(e){const t=[];for(const n of e.children)if("selections"===n.tagName)for(const e of n.children)"selection"===e.tagName&&t.push(e);return t}(e);for(const e of t)("model"===e.getAttribute("type")||O(e,"Unit")||O(e,"Fortification")||O(e,"Vehicle")||O(e,"Knights and Titans"))&&_.push(e);0===_.length&&_.push(...Array.from(e.querySelectorAll('selection[type="model"]'))),(0===_.length&&O(e,"Unit")||O(e,"Fortification")||O(e,"Vehicle")||O(e,"Knights and Titans"))&&_.push(e)}for(const e of _){const t=Array.from(e.querySelectorAll("profiles>profile")),n=t.filter((e=>!f.includes(e)));f.push(...n);const i=new l;i._name=e.getAttribute("name")||"Unknown Model",i._count=Number(e.getAttribute("number")||1),s._models.push(i),R(t,i);for(const t of e.querySelectorAll('selections>selection[type="upgrade"]')){let e=t.getAttribute("name");if(e){const n=new r;n._name=e,n._cost=L(t),n._count=Number(t.getAttribute("number")),i._upgrades.push(n)}}}let m=e.querySelectorAll('selections>selection[type="upgrade"]');for(const e of m){R(Array.from(e.querySelectorAll("profiles>profile")),s);const t=e.getAttribute("name");if(t){const n=new r;n._name=t,n._cost=L(e),n._count=Number(e.getAttribute("number")),s._upgrades.push(n)}}let g=e.querySelectorAll("costs>cost");for(let e of g)if(e.hasAttribute("name")&&e.hasAttribute("value")){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue,n=null===(o=e.getAttributeNode("value"))||void 0===o?void 0:o.nodeValue;n&&"Pts"==t&&(s._points+=+n)}let v=e.querySelectorAll("rules>rule");for(let e of v)P(e,s._rules);return s.normalize(),s}(e);if(i){n._units.push(i);for(const e of i._rules.entries())n._rules.set(e[0],e[1])}}else"upgrade"===h?function(e,t){const n=e.querySelectorAll("rules>rule");for(const e of n)P(e,t)}(e,n._rules):console.log("** UNEXPECTED SELECTION **",s,h,e)}function b(e,t){var n,r;t._name=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;let i=e;"profile"===e.tagName&&e.parentElement&&e.parentElement.parentElement&&(i=e.parentElement.parentElement),t._customName=null===(r=i.getAttributeNode("customName"))||void 0===r?void 0:r.nodeValue;let o=i.firstElementChild;return o&&"customNotes"===o.tagName&&(t._customNotes=o.textContent),t._name}function y(e){var t;if(e.parentElement&&e.parentElement.parentElement){const n=null===(t=e.parentElement.parentElement.getAttributeNode("number"))||void 0===t?void 0:t.nodeValue;if(n)return+n}return 0}function w(e){var t;const n=new i;b(e,n),n._count=y(e);let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"Range":n._range=e.textContent;break;case"Type":n._type=e.textContent;break;case"Strength":n._str=e.textContent;break;case"AP":n._ap=e.textContent}}const o=null===(t=e.parentElement)||void 0===t?void 0:t.parentElement,s=null==o?void 0:o.getAttribute("name");return"upgrade"===(null==o?void 0:o.getAttribute("type"))&&s&&(n._selectionName=s,n._cost=L(o)),n}function C(e){var t;const n=new i;b(e,n),n._count=y(e);let r=e.querySelectorAll("characteristics>characteristic");for(let e of r){let t=e.getAttribute("name");if(t&&e.textContent)switch(t){case"Range":n._range=e.textContent;break;case"Type":n._type=e.textContent;break;case"Strength":n._str=e.textContent;break;case"AP":n._ap=e.textContent}}const o=null===(t=e.parentElement)||void 0===t?void 0:t.parentElement,s=null==o?void 0:o.getAttribute("name");return"upgrade"===(null==o?void 0:o.getAttribute("type"))&&s&&(n._selectionName=s,n._cost=L(o)),n}function x(e){const t=new r;b(e,t),t._count=y(e);let n=e.querySelectorAll("characteristics>characteristic");for(let e of n)if(e.textContent){let n=e.getAttribute("name");if(n)switch(n){case"Description":case"Text":t._description=e.textContent}}return t}function E(e,t){if(!t||!e)return!1;for(let n of t._forces)if(n._catalog===e._catalog)return!0;return!1}function S(e){switch(e){case"HQ:":return t.HQ;case"Troops:":return t.TR;case"Elites:":return t.EL;case"Fast Attack:":return t.FA;case"Heavy Support:":return t.HS;case"Flyer":return t.FL;case"Transport Sub-type:":return t.DT;case"Fortification:":return t.FT;case"Lords of War:":return t.LW;case"Primarch:":return t.PR}return t.NONE}function k(e){return function(e){return null!=e&&""!==e&&!isNaN(Number(e.toString()))}(e)?e.toString()+'"':e.toString()}function A(e,t){return _(e._name,t._name)}function T(e,t){return e._name===t._name?_(e.nameAndGear(),t.nameAndGear()):_(e._name,t._name)}function N(e,t){return(e._type.startsWith("Grenade")?2:e._type.startsWith("Melee")?1:0)-(t._type.startsWith("Grenade")?2:t._type.startsWith("Melee")?1:0)||e.name().localeCompare(t.name())}function L(e){const t=new p;for(const n of e.children)if("costs"===n.tagName)for(const e of n.children)t.add(g(e));return t}function R(e,t){for(const n of e){const e=n.getAttribute("name");let r=n.getAttribute("typeName");if(e&&r)if(r=r.trim(),"Unit"===r||"Vehicle"===r||"Knights and Titans"===r||"Fortification"===r||"model"===n.getAttribute("type"));else if("Weapon"===r){const e=w(n);t._weapons.push(e)}else if("Psychic Weapon"===r){const e=C(n);t._psychicWeapons.push(e)}else if("Psychic Power"===r){const e=x(n);t._psychicPowers.push(e)}else if("Wargear Item"===r){const e=x(n);t._wargear.push(e)}else if("Warlord Trait"===r){const e=x(n);t._warlordTraits.push(e)}else if("Reactions"===r){const e=x(n);t._reactions.push(e)}else console.log("Unhandled model/unit profile "+e+" of type "+r+".")}}function P(e,t){const n=e.getAttribute("name"),r=e.querySelector("description");n&&(null==r?void 0:r.textContent)&&t.set(n,r.textContent)}function O(e,t){var n;for(const r of e.children)if("profiles"===r.tagName)for(const e of r.children)if("profile"===e.tagName&&(null===(n=e.getAttribute("typeName"))||void 0===n?void 0:n.trim())===t)return!0;return!1}e.Costs=p,e.Compare=_,e.CompareModelTypes=m,e.CreateRoster=function(e){var t;if(e){let n=e.querySelector("roster");if(n){const r=new f,i=null===(t=n.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;return r._name=i||"Horus Heresy Army Roster",function(e,t){let n=e.querySelectorAll("roster>costs>cost");for(let e of n)t._cost.add(g(e))}(e,r),function(e,t){var n,r;let i=e.querySelectorAll("roster>forces>force");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let i=new h,o=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("catalogueName"))||void 0===r?void 0:r.nodeValue;if(o&&(i._name=o),s&&(i._catalog=s),!E(i,t)){const t=e.querySelectorAll("force>rules>rule");for(let e of t)P(e,i._rules)}let a=e.querySelectorAll(":scope>selections>selection");for(let e of a)v(e,i);i._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?0:-1)),t._forces.push(i)}}(e,r),r}}return null},e.CompareWeapon=N}(t.HorusHeresy||(t.HorusHeresy={}))},249:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.Compare=t.CreateKT21Roster=t.RosterKT21=t.Force=t.Operative=t.OperativeRoleToString=t.Specialism=t.PsychicPowerWeapon=t.PsychicPower=t.UniqueActions=t.Weapons=t.BaseNotes=void 0;const s=o(n(486));class a{constructor(){this._name="",this._customName="",this._customNotes="",this._costs="0"}name(){return this._customName?this._customName:this._name}nameAndCosts(){let e=this._name;return this._customName&&(e=this._customName),this.costs()>0&&(e+=" ("+this.costs()+" EP)"),e}notes(){return this._customNotes}costs(){return Math.floor(+this._costs)}equal(e){return null!=e&&this._name===e._name}}t.BaseNotes=a;class l extends a{constructor(){super(...arguments),this._count=0,this._attacks="0",this._skill="0+",this._damage="0/0",this._rules="",this._criticalEffects=""}}t.Weapons=l,t.UniqueActions=class extends a{constructor(){super(...arguments),this._description=""}};class c extends a{constructor(){super(...arguments),this._effect="",this._weapons=[]}}var u;t.PsychicPower=c,t.PsychicPowerWeapon=class extends l{},function(e){e[e.NONE=0]="NONE",e[e.COMBAT=1]="COMBAT",e[e.STAUNCH=2]="STAUNCH",e[e.MARKSMAN=3]="MARKSMAN",e[e.SCOUT=4]="SCOUT"}(u=t.Specialism||(t.Specialism={})),t.OperativeRoleToString=["None","Combat","Staunch","Marksman","Scout"];class d extends a{constructor(){super(...arguments),this._role=u.NONE,this._model="",this._factions=new Set,this._keywords=new Set,this._abilities=new Map,this._rules=new Map,this._move='0"',this._apl="0",this._groupActivations="0",this._defence=0,this._saves="0+",this._wounds=0,this._weapons=[],this._upgrades=[],this._psychicPowers=[],this._psychicPowersWeapon=[]}equal(e){if(null==e)return!1;if(e._name===this._name&&e._role===this._role&&e._weapons.length===this._weapons.length){for(let t=0;t0||this._upgrades.length>0){let t=0;e+=" (";for(const n of this._weapons)e+=n.name(),t++,t!=this._weapons.length&&(e+=", ");this._upgrades.length>0&&!e.endsWith("(")&&(e+=", "),e+=this._upgrades.join(", "),e+=")"}return e}normalize(){this._weapons.sort(x),this._upgrades.sort(E);for(let e=0;eselections>selection");for(let e of r){let r=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;if(r&&"Game Type"!==r)if(r.includes("Detachment Command Cost"))console.log("Found Detachment Command Cost");else if(r.includes("Chapter Tactics"))console.log("Found chapter tactics."),m(e,t._rules);else{let n=w(e);if(n){n._keywords.has("Leader")?t._leader=n:t._operatives.push(n);for(const e of n._rules.entries())t._rules.set(e[0],e[1])}else if("upgrade"===e.getAttribute("type")){m(e,t._rules);const n=e.querySelectorAll("selections>selection");for(let e of n){const n=e.getAttribute("name");n&&"upgrade"===e.getAttribute("type")&&("Unknown"===t._faction&&(t._faction=n),m(e,t._factionRules))}}}}for(const e of t._factionRules.keys())t._rules.delete(e);t._operatives.sort(((e,t)=>e._role>t._role?1:e._role==t._role?e._name>t._name?1:e._name==t._name?0:-1:-1))}function _(e,t){if(!t||!e)return!1;for(let n of t._forces)if(n._catalog===e._catalog)return!0;return!1}function m(e,t){var n,r,i,o,s;const a=e.querySelectorAll(":scope profiles>profile");for(const l of a){const a=null===(n=l.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,c=null===(r=l.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;if(console.log("Prop name:"+a+" Type: "+c),a&&c)if("Abilities"===c||"Dynastic Code"===c||"Chapter Tactics"===c){const e=l.querySelectorAll("characteristics>characteristic");for(const n of e){const e=null===(i=n.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;e&&n.textContent&&a&&("Description"!==e&&"Ability"!==e&&"Effect"!=e&&"Chapter Tactic"!=e||t.set(a,n.textContent))}}else if("Weapons"===c){const n=e.querySelectorAll("rules>rule");for(const e of n)e.getAttributeNode("name")&&t.set(null===(o=e.getAttributeNode("name"))||void 0===o?void 0:o.nodeValue,null===(s=e.firstChild)||void 0===s?void 0:s.textContent)}}}function g(e){switch(e){case"Combat":return u.COMBAT;case"Staunch":return u.STAUNCH;case"Marksman":return u.MARKSMAN;case"Scout":return u.SCOUT}return u.NONE}function v(e,t){var n,r;let i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("typeName"))||void 0===r?void 0:r.nodeValue;console.log("Unknown profile type: "+o+" with name: "+i+". Found in operative: "+t._name)}function b(e,t){var n,r,i;t._name=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue;let o=e;"profile"===e.tagName&&e.parentElement&&e.parentElement.parentElement&&(o=e.parentElement.parentElement),t._customName=null===(r=o.getAttributeNode("customName"))||void 0===r?void 0:r.nodeValue;let s=o.firstElementChild;if(s&&"customNotes"===s.tagName&&(t._customNotes=s.textContent),"selection"===o.tagName){let e=o.querySelector("costs>cost");e&&e.getAttributeNode("value")&&(t._costs=null===(i=e.getAttributeNode("value"))||void 0===i?void 0:i.nodeValue)}return t._name}function y(e){var t;if(e.parentElement&&e.parentElement.parentElement){const n=null===(t=e.parentElement.parentElement.getAttributeNode("number"))||void 0===t?void 0:t.nodeValue;if(n)return+n}return 0}function w(e){var t,n,r,i,o;let s=new d;b(e,s);let a=e.querySelectorAll(":scope categories>category");for(let e of a){const n=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;if(n){const e="Faction: ",t=n.lastIndexOf(e);if(t>=0){const r=n.slice(t+e.length);s._factions.add(r)}else{let e=g(n.trim());e!=u.NONE?s._role=e:s._keywords.add(n)}}}let l=[],c=[];for(let t of e.querySelectorAll('profile[typeName="Operative"]')){let e=null===(n=t.parentElement)||void 0===n?void 0:n.parentElement;if(!e||c.includes(e))continue;c.push(e);let r=Array.from(e.querySelectorAll(":scope profiles>profile")||[]);C(r,s),l=l.concat(r)}C(Array.from(e.querySelectorAll(":scope profiles>profile")).filter((e=>!l.includes(e))),s,0,!0);let h=e.querySelectorAll(":scope costs>cost");for(let e of h)if(e.hasAttribute("name")&&e.hasAttribute("value")){let t=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue,n=null===(i=e.getAttributeNode("value"))||void 0===i?void 0:i.nodeValue;" EP"==t&&n&&+n>0&&(s._costs=(s.costs()+parseInt(n)).toString())}let f=e.querySelectorAll("rules > rule");for(let e of f)if(e.hasAttribute("name")){let t=null===(o=e.getAttributeNode("name"))||void 0===o?void 0:o.nodeValue,n=e.querySelector("description");t&&n&&n.textContent&&s._rules.set(t,n.textContent)}return s.normalize(),s}function C(e,t,n,r=!1){var i,o,s,a,u,d,h,f,p,_,g,w;for(let n of e){const e=null===(i=n.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue,r=null===(o=n.getAttributeNode("typeName"))||void 0===o?void 0:o.nodeValue;if(e&&r)if("Operative"===r){let e=t._name;b(n,t),t._model=t._name,t._name=e;let r=n.querySelectorAll("characteristics>characteristic");for(let e of r){let n=null===(s=e.getAttributeNode("name"))||void 0===s?void 0:s.nodeValue;if(n&&e.textContent)switch(n){case"M":t._move=e.textContent;break;case"APL":t._apl=e.textContent;break;case"GA":t._groupActivations=e.textContent;break;case"DF":t._defence=+e.textContent;break;case"SV":t._saves=e.textContent;break;case"W":t._wounds=+e.textContent}}}else if("Abilities"===r||"Equipment"===r||"Ability"===r||"Unique Actions"===r||"Chapter Tactics"==r){let r=n.querySelectorAll("characteristics>characteristic");for(let i of r)if((null===(a=i.getAttributeNode("name"))||void 0===a?void 0:a.nodeValue)&&i.textContent&&e){let r=null===(d=null===(u=n.parentElement)||void 0===u?void 0:u.parentElement)||void 0===d?void 0:d.querySelector("costs>cost"),o=e;if(r&&(null===(h=r.getAttributeNode("value"))||void 0===h?void 0:h.nodeValue)){let e=null===(f=r.getAttributeNode("value"))||void 0===f?void 0:f.nodeValue;e&&+e>0&&(o+=" ("+Math.floor(+e)+" EP)")}t._abilities.set(o,i.textContent)}if(n.parentElement&&n.parentElement.parentElement){const r=n.parentElement.parentElement;"upgrade"===(null===(p=r.getAttributeNode("type"))||void 0===p?void 0:p.nodeValue)&&r.parentElement&&r.parentElement.parentElement&&"model"===(null===(_=r.parentElement.parentElement.getAttributeNode("type"))||void 0===_?void 0:_.nodeValue)&&t._upgrades.push(e)}}else if("Weapons"===r){let e=new l;b(n,e),n.parentElement&&n.parentElement.parentElement&&m(n.parentElement.parentElement,t._rules),e._count=y(n);let r=n.querySelectorAll("characteristics>characteristic");for(let t of r){let n=null===(g=t.getAttributeNode("name"))||void 0===g?void 0:g.nodeValue;if(n&&t.textContent)switch(n){case"A":e._attacks=t.textContent;break;case"WS/BS":e._skill=t.textContent;break;case"D":e._damage=t.textContent;break;case"SR":e._rules=t.textContent;break;case"!":e._criticalEffects=t.textContent}}t._weapons.push(e)}else if("Psychic Power"==r){let e=new c;b(n,e);let r=n.querySelectorAll("characteristics>characteristic");for(let t of r)"Effect"===(null===(w=t.getAttributeNode("name"))||void 0===w?void 0:w.nodeValue)&&t.textContent&&(e._effect=t.textContent);t._psychicPowers.push(e)}else v(n,t)}}function x(e,t){return E(e._name,t._name)}function E(e,t){return e>t?1:e==t?0:-1}t.RosterKT21=f,t.CreateKT21Roster=function(e){var t;if(e){let n=e.querySelector("roster");if(n){const r=new f,i=null===(t=n.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;return r._name=i||"Kill Team (2021) Army Roster",function(e,t){var n,r;let i=e.querySelectorAll("roster>costs>cost");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("value")){let i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("value"))||void 0===r?void 0:r.nodeValue;o&&" EP"==i&&(t._equipmentPoints=+o)}}(e,r),function(e,t){var n,r,i;let o=e.querySelectorAll("roster>forces>force");for(let e of o)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let o=new h,l=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,c=null===(r=e.getAttributeNode("catalogueName"))||void 0===r?void 0:r.nodeValue;if(l&&(o._name=l),c&&(o._catalog=c,o._faction=c),!_(o,t)){var s=e.querySelectorAll("force>rules>rule");for(let e of s)if(e.hasAttribute("name")){let t=null===(i=e.getAttributeNode("name"))||void 0===i?void 0:i.nodeValue;var a=e.querySelector("rule>description");t&&a&&o._rules.set(t,a.textContent)}}p(e,o),t._forces.push(o)}}(e,r),r}}return null},t.Compare=E},452:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateMESBGRoster=void 0;const n=/\r\n|\r|\n| /,r=e=>{var t;return null!==(t=e.getAttribute("catalogueName"))&&void 0!==t?t:"MESBG Force"},i=e=>{var t;const n={half:0,quarter:0,modelCount:0};for(let r of e.querySelectorAll("rules>rule")){const e=null!==(t=r.getAttribute("name"))&&void 0!==t?t:"";if(e.endsWith("is halfway. (model)")){const t=parseFloat(e);isNaN(t)||(n.half=Math.ceil(t))}if(e.endsWith("models remaining. (model)")){const t=parseFloat(e);isNaN(t)||(n.quarter=Math.ceil(t))}if(e.endsWith("total models in Army. (model)")){const t=parseFloat(e);isNaN(t)||(n.modelCount=t)}}return n},o=e=>{var t,r,i,o,s,a,l,c,u,d,h,f,p,_,m,g,v,b,y;let w="",C="",x="",E=[],S="",k=!1;const A=[];for(let u of e.querySelectorAll('profiles > profile[typeName="Hero"]'))for(let e of u.querySelectorAll("characteristics > characteristic"))switch(null!==(r=null===(t=e.getAttribute("name"))||void 0===t?void 0:t.trim())&&void 0!==r?r:""){case"Might":x=null!==(i=e.textContent)&&void 0!==i?i:"";break;case"Fate":w=null!==(o=e.textContent)&&void 0!==o?o:"";break;case"Will":C=null!==(s=e.textContent)&&void 0!==s?s:"";break;case"Heroic Actions":E=null!==(l=null===(a=e.textContent)||void 0===a?void 0:a.split(n))&&void 0!==l?l:[];break;case"Heroic Tier":S=null!==(c=e.textContent)&&void 0!==c?c:""}for(let t of e.querySelectorAll('profile[typeName="Magical Power"]')){const e=null!==(u=t.getAttribute("name"))&&void 0!==u?u:"Unnamed Magic Power",n=null!==(h=null===(d=t.querySelector(':scope characteristic[name~="Duration"]'))||void 0===d?void 0:d.textContent)&&void 0!==h?h:"",r=null!==(p=null===(f=t.querySelector(':scope characteristic[name~="Range"]'))||void 0===f?void 0:f.textContent)&&void 0!==p?p:"",i=null!==(m=null===(_=t.querySelector(':scope characteristic[name~="Casting"]'))||void 0===_?void 0:_.textContent)&&void 0!==m?m:"",o=null!==(v=null===(g=t.querySelector(':scope characteristic[name~="Rule"]'))||void 0===g?void 0:g.textContent)&&void 0!==v?v:"",s=null!==(y=null===(b=t.querySelector(':scope characteristic[name~="Channelled"]'))||void 0===b?void 0:b.textContent)&&void 0!==y?y:"";A.push({name:e,duration:n,range:r,casting:i,normalEffect:o,channelledEffect:s})}return k=!!e.querySelector('selections > selection[name$="Leader (Valour)"]'),{fate:w,will:C,might:x,heroicTier:S,actions:E,magicalPowers:A,isLeader:k}},s=e=>{var t,r,i,a,u,d,h,f,p,_,m,g,v,b,y,w,C,x,E,S,k,A,T,N,L;const R=(e=>{var t,n,r;const i=[];for(let o of e)if(o.hasAttribute("name")){const e=null!==(t=o.getAttribute("name"))&&void 0!==t?t:null,s=null!==(r=null===(n=o.querySelector("rule>description"))||void 0===n?void 0:n.textContent)&&void 0!==r?r:"";null!==e&&i.push({name:e,ruleText:s})}return i})(null!==(t=e.querySelectorAll("rules > rule"))&&void 0!==t?t:[]),P=null!==(i=null===(r=e.getAttribute("name"))||void 0===r?void 0:r.trim())&&void 0!==i?i:"Unknown Model Name";let O=[];const W=[];let z,I,B="",M="",U="",D="",F="",q="",H="";e.querySelectorAll("profiles > profile");for(let t of e.querySelectorAll(":scope profiles > profile")){const r=t.getAttribute("typeName"),i=null!==(u=null===(a=t.getAttribute("name"))||void 0===a?void 0:a.trim())&&void 0!==u?u:"wowza";if(("Hero"===r||"Warrior"===r)&&i.startsWith(P)){for(let e of t.querySelectorAll("characteristics > characteristic"))switch(null!==(h=null===(d=e.getAttribute("name"))||void 0===d?void 0:d.trim())&&void 0!==h?h:""){case"Wounds":q=null!==(f=e.textContent)&&void 0!==f?f:"";break;case"Courage":H=null!==(p=e.textContent)&&void 0!==p?p:"";break;case"Attack":F=null!==(_=e.textContent)&&void 0!==_?_:"";break;case"Defense":D=null!==(m=e.textContent)&&void 0!==m?m:"";break;case"Strength":U=null!==(g=e.textContent)&&void 0!==g?g:"";break;case"Fight":M=null!==(v=e.textContent)&&void 0!==v?v:"";break;case"Movement":B=null!==(b=e.textContent)&&void 0!==b?b:"";break;case"Keywords":O=null!==(w=null===(y=e.textContent)||void 0===y?void 0:y.split(n))&&void 0!==w?w:[]}for(let t of null!==(C=l(e))&&void 0!==C?C:[]){if("Shield"===t.getAttribute("name")||t.querySelector('profile[typeName$="Wargear"]')||t.querySelector('profile[typeName$="Shooting Weapon"]')){const e=null!==(x=t.getAttribute("name"))&&void 0!==x?x:"Equipment",n=parseInt(null!==(S=null===(E=t.querySelector('cost[name$="Points"]'))||void 0===E?void 0:E.getAttribute("value"))&&void 0!==S?S:"0"),r=[];for(let e of t.querySelectorAll("characteristics > characteristic"))null!==e.textContent&&r.push(e.textContent);W.push({name:e,points:n,rules:r})}t.querySelector('profile[typeName$="Warrior"]')&&(z=s(null===(A=null===(k=t.querySelector('profile[typeName$="Warrior"]'))||void 0===k?void 0:k.parentElement)||void 0===A?void 0:A.parentElement))}"Hero"===r&&(I=o(e))}}let j=0;for(let t of null!==(T=c(e))&&void 0!==T?T:[])"Points"===(null===(N=t.getAttribute("name"))||void 0===N?void 0:N.trim())&&(j=parseInt(null!==(L=t.getAttribute("value"))&&void 0!==L?L:"0"));return{name:P,points:j,keywords:O,rules:R,profile:{attack:F,courage:H,defense:D,fight:M,movement:B,strength:U,wounds:q},wargear:W,mount:z,heroStuff:I}},a=e=>{var t,n,r,i;const o=[];for(let a of null!==(t=l(e))&&void 0!==t?t:[]){const e=a.querySelector('selection[type~="model"]');if(null!==e){const t=s(a),l=parseInt(null!==(n=e.getAttribute("number"))&&void 0!==n?n:"0"),c=parseInt(null!==(i=null===(r=e.querySelector('cost[name~="Points"]'))||void 0===r?void 0:r.getAttribute("value"))&&void 0!==i?i:"0");o.push({model:t,count:l,points:c})}}return o},l=e=>{var t,n;return null!==(n=null===(t=e.querySelector("selections"))||void 0===t?void 0:t.querySelectorAll(":scope > selection"))&&void 0!==n?n:null},c=e=>{var t,n;return null!==(n=null===(t=e.querySelector("costs"))||void 0===t?void 0:t.querySelectorAll(":scope > cost"))&&void 0!==n?n:null},u=e=>{let t=null,n=[];const r=l(e);if(null===r)return r;for(let e of r)"model"===e.getAttribute("type")&&(t=s(e)),"Warband"===e.getAttribute("name")&&(n=a(e));return null!==t?{leader:t,warband:n}:null},d=e=>{var t;let n=!1;for(let r of null!==(t=l(e))&&void 0!==t?t:[])"model"===r.getAttribute("type")&&(n=!0);return n};t.CreateMESBGRoster=function(e){var t,n;if(e){const o=null!==(n=null===(t=e.querySelector("roster"))||void 0===t?void 0:t.getAttribute("name"))&&void 0!==n?n:"Middle-Earth Stratgegy Battle Game Roster",{points:s,warriors:a}=(e=>{var t,n,r,i;const o=e.querySelectorAll("roster>costs>cost");let s=0,a=0;for(let e of o)"Points"===(null===(t=e.getAttribute("name"))||void 0===t?void 0:t.trim())&&(s=parseInt(null!==(n=e.getAttribute("value"))&&void 0!==n?n:"0")),"Warriors"===(null===(r=e.getAttribute("name"))||void 0===r?void 0:r.trim())&&(a=parseInt(null!==(i=e.getAttribute("value"))&&void 0!==i?i:"0"));return{points:s,warriors:a}})(e),c=(e=>{var t,n,o;const s=e.querySelectorAll("roster>forces>force"),a=[];for(let e of s){const s=r(e);let c={half:0,quarter:0,modelCount:0};const h=[],f=[],p=l(e);if(null!==p){for(let e of p)if("Determine Breakpoint & 25%"===e.getAttribute("name"))c=i(e);else if(d(e)){const t=u(e);null!==t&&h.push(t)}else{const r=e.querySelectorAll("rules > rule");for(let e of r){const r=null!==(n=null===(t=e.querySelector("description"))||void 0===t?void 0:t.textContent)&&void 0!==n?n:"";f.push({name:null!==(o=e.getAttribute("name"))&&void 0!==o?o:"",ruleText:r})}}a.push({name:s,breakpoints:c,units:h,armyBonus:f})}}return a})(e);return{name:o,forces:c,points:s,warriors:a}}return alert("Bad Input File"),null}},320:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CreateWarcryRoster=t.RosterWarcry=t.WarcryForce=t.WarcryUnit=t.WarcryDamageTable=t.WarcryUnitRoleToString=t.WarcryUnitRole=t.WarcryWeapon=t.WarcryAllegiance=void 0;class n{constructor(){this._name="",this._rules=new Map}}t.WarcryAllegiance=n;class r{constructor(){this._name="",this._range="",this._attacks="",this._strength="",this._damage=""}}var i;t.WarcryWeapon=r,function(e){e[e.NONE=0]="NONE",e[e.LEADER=1]="LEADER",e[e.FIGHTER=2]="FIGHTER",e[e.ALLY=3]="ALLY",e[e.MONSTER=4]="MONSTER",e[e.HERO=5]="HERO",e[e.THRALL=6]="THRALL"}(i=t.WarcryUnitRole||(t.WarcryUnitRole={})),t.WarcryUnitRoleToString=["None","Leader","Fighter","Ally","Monster","Hero","Thrall"];class o{constructor(){this._name="",this._table=new Map}}t.WarcryDamageTable=o;class s{constructor(){this._name="",this._role=i.NONE,this._faction="chaos-iron-golems",this._keywords=new Set,this._abilities=new Map,this._move="1",this._wounds="1",this._toughness="1",this._weapons=[],this._damageTable=[],this._points=0}}t.WarcryUnit=s;class a{constructor(){this._catalog="",this._name="Unknown",this._units=[],this._allegiance=new n}}t.WarcryForce=a;class l{constructor(){this._points=0,this._name="",this._forces=[]}}function c(e){const t=e.toLowerCase();return t.includes("chaotic beasts")?"monster-chaotic-beasts":t.includes("monster")?t.includes("order")?"monster-of-order":t.includes("destruction")?"monster-of-destruction":t.includes("death")?"monster-of-death":"monster-chaotic-beasts":t.includes("beasts of chaos")?"factions-chaos-beasts-of-chaos":t.includes("corvus")?"factions-chaos-corvus-cabal":t.includes("cypher")?"factions-chaos-cypher-lords":t.includes("everchosen")?"factions-chaos-everchosen":t.includes("golems")?"factions-chaos-iron-golems":t.includes("khorne")&&t.includes("bloodbound")?"factions-chaos-khorne-bloodbound":t.includes("khorne")&&t.includes("daemon")?"factions-chaos-khorne-daemons":t.includes("nurgle")&&t.includes("rotbringer")?"factions-chaos-nurgle-rotbringers":t.includes("nurgle")&&t.includes("daemon")?"factions-chaos-nurgle-daemons":t.includes("scions")?"factions-chaos-scions-of-the-flame":t.includes("skaven")?"factions-chaos-skaven":t.includes("slaanesh")&&t.includes("sybariteI g")?"factions-chaos-slaanesh-syberites":t.includes("slaanesh")&&t.includes("daemon")?"factions-chaos-slaanesh-daemons":t.includes("slaves")?"factions-chaos-slaves-to-darkness":t.includes("spire")?"factions-chaos-spire-tyrants":t.includes("splintered")?"factions-chaos-splintered-fang":t.includes("unmade")?"factions-chaos-the-unmade":t.includes("tzeentch")&&t.includes("arcanite")?"factions-chaos-tzeentch-arcanites":t.includes("tzeentch")&&t.includes("daemon")?"factions-chaos-tzeentch-daemons":t.includes("untamed")?"factions-chaos-untamed-beasts":t.includes("flesh")?"factions-death-flesh-eater-courts":t.includes("nagash")?"factions-death-legions-of-nagash":t.includes("nighthaunt")?"factions-death-nighthaunt":t.includes("ossiarch")?"factions-death-ossiarch-bonereapers":t.includes("soulblight")?"factions-death-soulblight-gravelords":t.includes("bonesplitterz")?"factions-destruction-bonesplitterz":t.includes("fimirach")?"factions-destruction-fimirach":t.includes("gloomspite")?"factions-destruction-gloomspite-gitz":t.includes("ironjawz")?"factions-destruction-ironjawz":t.includes("kruleboyz")?"factions-destruction-kruleboyz":t.includes("ogor")?"factions-destruction-ogor-mawtribes":t.includes("cities of sigmar")?"factions-order-cities-of-sigmar":t.includes("khaine")?"factions-order-daughters-of-khaine":t.includes("fyreslayers")?"factions-order-fyreslayers":t.includes("idoneth")?"factions-order-idoneth-deepkin":t.includes("shadowstalkers")?"factions-order-khainite-shadowstalkers":t.includes("kharadron")?"factions-order-kharadron-overlords":t.includes("lumineth")?"factions-order-lumineth-realmlords":t.includes("seraphon")?"factions-order-seraphon":t.includes("stormcast")?t.includes("sacrosanct")?"factions-order-stormcast-eternals-sacrosanct":t.includes("thunderstrike")?"factions-order-stormcast-eternals-thunderstrike":t.includes("vanguard")?"factions-order-stormcast-eternals-vanguard":"factions-order-stormcast-eternals-warrior":t.includes("sylvaneth")?"factions-order-sylvaneth":""}function u(e,t){var r;let i=new n,o=e.querySelectorAll("rules>rule");for(let e of o)if(e.hasAttribute("name")){let t=null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue;var s=e.querySelector("rule>description");t&&s&&s.textContent&&i._rules.set(t,s.textContent)}t._allegiance=i}function d(e,t){var n,r;let o=e.querySelectorAll("force>selections>selection");for(let e of o){if(!(null===(n=e.getAttributeNode("type"))||void 0===n?void 0:n.nodeValue))continue;if(!(null===(r=e.getAttributeNode("name"))||void 0===r?void 0:r.nodeValue))continue;let o=h(e);o&&o._role!=i.NONE&&t._units.push(o)}t._units.sort(((e,t)=>e._role>t._role?1:e._role==t._role?0:-1))}function h(e){var t,n,a,l,u,d,h,f,p;let _=new s,m=e.querySelectorAll("profiles>profile");for(let e of m){let i=null===(t=e.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue,s=null===(n=e.getAttributeNode("typeName"))||void 0===n?void 0:n.nodeValue;if(i&&s)if("Model"==s){_._name=i;let t=e.querySelectorAll("characteristics>characteristic");for(let e of t){let t=null===(a=e.getAttributeNode("name"))||void 0===a?void 0:a.nodeValue;if(t&&e.textContent)switch(t){case"Move":_._move=e.textContent;break;case"Wounds":_._wounds=e.textContent;break;case"Toughness":_._toughness=e.textContent}}}else if("Weapon"==s){let t=new r;t._name=i;let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let n=null===(l=e.getAttributeNode("name"))||void 0===l?void 0:l.nodeValue;if(n&&e.textContent)switch(n){case"Range":t._range=e.textContent;break;case"Attacks":t._attacks=e.textContent;break;case"Strength":t._strength=e.textContent;break;case"Damage":t._damage=e.textContent}}_._weapons.push(t)}else if("Damage Points Allocated"==s){let t=new o;t._name=i;let n=e.querySelectorAll("characteristics>characteristic");for(let e of n){let n=null===(u=e.getAttributeNode("name"))||void 0===u?void 0:u.nodeValue;n&&i&&(e.textContent?t._table.set(n,e.textContent):t._table.set(n,"-"))}_._damageTable.push(t)}else console.log("Unknown unit profile type: "+s)}let g=e.querySelectorAll("costs>cost");for(let e of g)if(e.hasAttribute("name")&&e.hasAttribute("value")){let t=null===(d=e.getAttributeNode("name"))||void 0===d?void 0:d.nodeValue,n=null===(h=e.getAttributeNode("value"))||void 0===h?void 0:h.nodeValue;n&&"pts"===t&&(_._points+=+n)}let v=e.querySelectorAll(":scope categories>category");for(let e of v){let t=null===(f=e.getAttributeNode("name"))||void 0===f?void 0:f.nodeValue;if(t){var b=(y=t.trim()).includes("Leader")?i.LEADER:y.includes("Fighter")?i.FIGHTER:y.includes("Allies")||y.includes("Ally")?i.ALLY:y.includes("Monster")?i.MONSTER:y.includes("Hero")?i.HERO:y.includes("Thrall")?i.THRALL:i.NONE;b!=i.NONE?_._role=b:_._keywords.add(t)}}var y;let w=e.querySelectorAll(":scope selections>selection");for(let e of w){let t=null===(p=e.getAttributeNode("name"))||void 0===p?void 0:p.nodeValue;if(t){let e=c(t);e.length>0?_._faction=e:_._keywords.add(t)}}return _}t.RosterWarcry=l,t.CreateWarcryRoster=function(e){var t;if(e){let n=e.querySelector("roster");if(n){const r=new l,i=null===(t=n.getAttributeNode("name"))||void 0===t?void 0:t.nodeValue;return r._name=i||"Age of Sigmar Warcry Roster",function(e,t){var n,r;let i=e.querySelectorAll("roster>costs>cost");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("value")){let i=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,o=null===(r=e.getAttributeNode("value"))||void 0===r?void 0:r.nodeValue;o&&"pts"===i&&(t._points=+o)}}(e,r),function(e,t){var n,r;let i=e.querySelectorAll("roster>forces>force");for(let e of i)if(e.hasAttribute("name")&&e.hasAttribute("catalogueName")){let i=new a,o=null===(n=e.getAttributeNode("name"))||void 0===n?void 0:n.nodeValue,s=null===(r=e.getAttributeNode("catalogueName"))||void 0===r?void 0:r.nodeValue;o&&(i._name=o),s&&(i._catalog=s),u(e,i),d(e,i),t._forces.push(i)}console.log(t)}(e,r),r}}return null}},596:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.formatStat=t.filterAndOrderStats=void 0,t.filterAndOrderStats=function(e){return Object.entries(e).filter((e=>e[1].statOrder>=0&&void 0===e[1].groupOrder&&"normal"===e[1].visibility)).sort(((e,t)=>e[1].statOrder-t[1].statOrder))},t.formatStat=function(e){const t=String(e.value);return e.format?e.format.replace(/{[vt]}/,t):t}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),n(752)})(); \ No newline at end of file diff --git a/src/renderer40k10th.tsx b/src/renderer40k10th.tsx index 3ad1bab..364e2b8 100644 --- a/src/renderer40k10th.tsx +++ b/src/renderer40k10th.tsx @@ -584,35 +584,24 @@ export class Wh40kRenderer implements Renderer { const entries = Object.entries(unit._profileTables) .sort((a, b) => Wh40k.CompareProfileTableName(a[0], b[0])) .map(([typeName, table]) => { - const widths = typeName === 'Unit' ? this._unitLabelWidthsNormalized : this._weaponLabelWidthNormalized; - return [table, widths]; - }) as [Wh40k.TabularProfile, number[]][]; - ; - - return - {entries.map(([table, widths]) => <> - - - {widths.map((width, i) => )} - - - - {/* Reverse the stripe coloring to start with white. */} - {table._contents.map(row => - {widths.map((width, i) => )} - )} - - )} -
- {this.renderProfileTableHeaderCell(table._headers[i])} -
- {row[i]} -
; + const className = typeName === 'Unit' ? 'wh40k_unit_profile_table' : 'wh40k_weapon_profile_table'; + return [table, className]; + }) as [Wh40k.TabularProfile, string][]; + + return
+ {entries.map(([table, className]) =>
+
+ {table._headers.map((header) =>
+ {this.renderProfileTableHeaderCell(header)} +
)} +
+ {table._contents.map(row =>
+ {row.map((cell) =>
+ {cell === '-' ? '' : cell} +
)} +
)} +
)} +
} private renderProfileTableHeaderCell(name: string) {