CyberChef/Hashing.js

101 lines
107 KiB
JavaScript
Raw Normal View History

/**
* CyberChef - The Cyber Swiss Army Knife
*
* @copyright Crown Copyright 2016
* @license Apache-2.0
*
* Copyright 2016 Crown Copyright
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/!function(t){var e={};function r(n){if(e[n])return e[n].exports;var a=e[n]={i:n,l:!1,exports:{}};return t[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)r.d(n,a,function(e){return t[e]}.bind(null,a));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=1510)}({0:function(t,e,r){"use strict";var n=r(15),a=r.n(n),o=r(10),i=r(7),u=r(19),s=r(18);function c(t,e,r,n,a,o,i){try{var u=t[o](i),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,a)}function l(t){return function(){var e=this,r=arguments;return new Promise(function(n,a){var o=t.apply(e,r);function i(t){c(o,n,a,i,u,"next",t)}function u(t){c(o,n,a,i,u,"throw",t)}i(void 0)})}}function h(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}
/**
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2016
* @license Apache-2.0
*/
var f=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}var e,r,n;return e=t,r=null,n=[{key:"chr",value:function(t){if(t>65535){t-=65536;var e=String.fromCharCode(t>>>10&1023|55296);return t=56320|1023&t,e+String.fromCharCode(t)}return String.fromCharCode(t)}},{key:"ord",value:function(t){if(2===t.length){var e=t.charCodeAt(0),r=t.charCodeAt(1);if(e>=55296&&e<56320&&r>=56320&&r<57344)return 1024*(e-55296)+r-56320+65536}return t.charCodeAt(0)}},{key:"padBytesRight",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=new Array(e);return n.fill(r),Array.prototype.map.call(t,function(t,e){n[e]=t}),n}},{key:"truncate",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"...";return t.length>e&&(t=t.slice(0,e-r.length)+r),t}},{key:"hex",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return(e="string"==typeof e?t.ord(e):e).toString(16).padStart(r,"0")}},{key:"bin",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;return(e="string"==typeof e?t.ord(e):e).toString(2).padStart(r,"0")}},{key:"printable",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];"object"==typeof window&&window.app&&!window.app.options.treatAsUtf8&&(e=t.byteArrayToChars(t.strToByteArray(e)));return e=e.replace(/[\0-\x08\x0B-\x0C\x0E-\x1F\x7F-\x9F\xAD\u0378\u0379\u037F-\u0383\u038B\u038D\u03A2\u0528-\u0530\u0557\u0558\u0560\u0588\u058B-\u058E\u0590\u05C8-\u05CF\u05EB-\u05EF\u05F5-\u0605\u061C\u061D\u06DD\u070E\u070F\u074B\u074C\u07B2-\u07BF\u07FB-\u07FF\u082E\u082F\u083F\u085C\u085D\u085F-\u089F\u08A1\u08AD-\u08E3\u08FF\u0978\u0980\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA\u09BB\u09C5\u09C6\u09C9\u09CA\u09CF-\u09D6\u09D8-\u09DB\u09DE\u09E4\u09E5\u09FC-\u0A00\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A\u0A3B\u0A3D\u0A43-\u0A46\u0A49\u0A4A\u0A4E-\u0A50\u0A52-\u0A58\u0A5D\u0A5F-\u0A65\u0A76-\u0A80\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA\u0ABB\u0AC6\u0ACA\u0ACE\u0ACF\u0AD1-\u0ADF\u0AE4\u0AE5\u0AF2-\u0B00\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A\u0B3B\u0B45\u0B46\u0B49\u0B4A\u0B4E-\u0B55\u0B58-\u0B5B\u0B5E\u0B64\u0B65\u0B78-\u0B81\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BBD\u0BC3-\u0BC5\u0BC9\u0BCE\u0BCF\u0BD1-\u0BD6\u0BD8-\u0BE5\u0BFB-\u0C00\u0C04\u0C0D\u0C11\u0C29\u0C34\u0C3A-\u0C3C\u0C45\u0C49\u0C4E-\u0C54\u0C57\u0C5A-\u0C5F\u0C64\u0C65\u0C70-\u0C77\u0C80\u0C81\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA\u0CBB\u0CC5\u0CC9\u0CCE-\u0CD4\u0CD7-\u0CDD\u0CDF\u0CE4\u0CE5\u0CF0\u0CF3-\u0D01\u0D04\u0D0D\u0D11\u0D3B\u0D3C\u0D45\u0D49\u0D4F-\u0D56\u0D58-\u0D5F\u0D64\u0D65\u0D76-\u0D78\u0D80\u0D81\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DC9\u0DCB-\u0DCE\u0DD5\u0DD7\u0DE0-\u0DF1\u0DF5-\u0E00\u0E3B-\u0E3E\u0E5C-\u0E80\u0E83\u0E85\u0E86\u0E89\u0E8B\u0E8C\u0E8E-\u0E93\u0E98\u0EA0\u0EA4\u0EA6\u0EA8\u0EA9\u0EAC\u0EBA\u0EBE\u0EBF\u0EC5\u0EC7\u0ECE\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F48\u0F6D-\u0F70\u0F98\u0FBD\u0FCD\u0FDB-\u0FFF\u10C6\u10C8-\u10CC\u10CE\u10CF\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B\u135C\u137D-\u137F\u139A-\u139F\u13F5-\u13FF\u169D-\u169F\u16F1-\u16FF\u170D\u1715-\u171F\u1737-\u173F\u1754-\u175F\u176D\u1771\u1774-\u177F\u17DE\u17DF\u17EA-\u17EF\u17FA-\u17FF\u180F\u181A-\u181F\u1878-\u187F\u18AB-\u18AF\u18F6-\u18FF\u191D-\u191F\u192C-\u192F\u193C-\u193F\u1941-\u1943\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DB-\u19DD\u1A1C\u1A1D\u1A5F\u1A7D\u1A7E\u1A8A-\u1A8F\u1A9A-\u1A9F\u1AAE-\u1AFF\u1B4C-\u1B4F\u1B7D-\u1B7F\u1BF4-\u1BFB\u1C38-\u1C3A\u1C4A-\u1C4C\u1C80-\u1CBF\u1CC8-\u1CCF\u1CF7-\u1CFF\u1DE7-\u1DFB\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FC5\u1FD4\u1FD5\u1FDC\u1FF0\u1FF1\u1FF5\u1FFF\u200B-\u200F\u202A-\u202E\u2060-\u206F\u2072\u2073\u208F\u209D-\u209F\u20BB-\u20CF\u20F1-\u
/**
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2016
* @license Apache-2.0
*/
var u=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.name="",this.type="",this._value=null,this.disabled=!1,this.hint="",this.rows=0,this.toggleValues=[],this.target=null,this.defaultIndex=0,e&&this._parseConfig(e)}var e,r,n;return e=t,n=[{key:"prepare",value:function(t,e){var r;switch(e){case"binaryString":case"binaryShortString":case"editableOption":case"editableOptionShort":return a.a.parseEscapedChars(t);case"byteArray":return"string"==typeof t?(t=t.replace(/\s+/g,""),Object(o.c)(t)):t;case"number":if(r=parseFloat(t),isNaN(r))throw"Invalid ingredient value. Not a number: "+a.a.truncate(t.toString(),10);return r;default:return t}}}],(r=[{key:"_parseConfig",value:function(t){this.name=t.name,this.type=t.type,this.defaultValue=t.value,this.disabled=!!t.disabled,this.hint=t.hint||!1,this.rows=t.rows||!1,this.toggleValues=t.toggleValues,this.target=void 0!==t.target?t.target:null,this.defaultIndex=void 0!==t.defaultIndex?t.defaultIndex:0}},{key:"config",get:function(){return this._value}},{key:"value",set:function(e){this._value=t.prepare(e,this.type)},get:function(){return this._value}}])&&i(e.prototype,r),n&&i(e,n),t}();function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}
/**
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2016
* @license Apache-2.0
*/
var c=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._inputType=-1,this._outputType=-1,this._presentType=-1,this._breakpoint=!1,this._disabled=!1,this._flowControl=!1,this._manualBake=!1,this._ingList=[],this.name="",this.module="",this.description="",this.infoURL=null}var e,r,a;return e=t,(r=[{key:"run",value:function(t,e){return t}},{key:"highlight",value:function(t,e){return!1}},{key:"highlightReverse",value:function(t,e){return!1}},{key:"present",value:function(t,e){return t}},{key:"addIngredient",value:function(t){this._ingList.push(t)}},{key:"inputType",set:function(t){this._inputType=n.a.typeEnum(t)},get:function(){return n.a.enumLookup(this._inputType)}},{key:"outputType",set:function(t){this._outputType=n.a.typeEnum(t),this._presentType<0&&(this._presentType=this._outputType)},get:function(){return n.a.enumLookup(this._outputType)}},{key:"presentType",set:function(t){this._presentType=n.a.typeEnum(t)},get:function(){return n.a.enumLookup(this._presentType)}},{key:"args",set:function(t){var e=this;t.forEach(function(t){var r=new u(t);e.addIngredient(r)})},get:function(){return this._ingList.map(function(t){var e={name:t.name,type:t.type,value:t.defaultValue};return t.toggleValues&&(e.toggleValues=t.toggleValues),t.hint&&(e.hint=t.hint),t.rows&&(e.rows=t.rows),t.disabled&&(e.disabled=t.disabled),t.target&&(e.target=t.target),t.defaultIndex&&(e.defaultIndex=t.defaultIndex),e})}},{key:"config",get:function(){return{op:this.name,args:this._ingList.map(function(t){return t.config})}}},{key:"ingValues",set:function(t){var e=this;t.forEach(function(t,r){e._ingList[r].value=t})},get:function(){return this._ingList.map(function(t){return t.value})}},{key:"breakpoint",set:function(t){this._breakpoint=!!t},get:function(){return this._breakpoint}},{key:"disabled",set:function(t){this._disabled=!!t},get:function(){return this._disabled}},{key:"flowControl",get:function(){return this._flowControl},set:function(t){this._flowControl=!!t}},{key:"manualBake",get:function(){return this._manualBake},set:function(t){this._manualBake=!!t}}])&&s(e.prototype,r),a&&s(e,a),t}();e.a=c},10:function(t,e,r){"use strict";r.d(e,"c",function(){return a}),r.d(e,"b",function(){return o}),r.d(e,"a",function(){return i});var n=r(0);
/**
* Base64 functions.
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2016
* @license Apache-2.0
*/function a(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"A-Za-z0-9+/=";if(!t)return"";"string"==typeof t&&(t=n.a.strToByteArray(t)),e=n.a.expandAlphRange(e).join("");for(var r,a,o,i,u,s,c,l="",h=0;h<t.length;)i=(r=t[h++])>>2,u=(3&r)<<4|(a=t[h++])>>4,s=(15&a)<<2|(o=t[h++])>>6,c=63&o,isNaN(a)?s=c=64:isNaN(o)&&(c=64),l+=e.charAt(i)+e.charAt(u)+e.charAt(s)+e.charAt(c);return l}function o(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"A-Za-z0-9+/=",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"string",a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(!t)return"string"===r?"":[];e=e||"A-Za-z0-9+/=",e=n.a.expandAlphRange(e).join("");var o,i,u,s,c,l,h=[],f=0;if(a){var p=new RegExp("[^"+e.replace(/[[\]\\\-^$]/g,"\\$&")+"]","g");t=t.replace(p,"")}for(;f<t.length;)o=e.indexOf(t.charAt(f++))<<2|(s=-1===(s=e.indexOf(t.charAt(f++)||"="))?64:s)>>4,i=(15&s)<<4|(c=-1===(c=e.indexOf(t.charAt(f++)||"="))?64:c)>>2,u=(3&c)<<6|(l=-1===(l=e.indexOf(t.charAt(f++)||"="))?64:l),h.push(o),64!==c&&h.push(i),64!==l&&h.push(u);return"string"===r?n.a.byteArrayToUtf8(h):h}var i=[{name:"Standard (RFC 4648): A-Za-z0-9+/=",value:"A-Za-z0-9+/="},{name:"URL safe (RFC 4648 §5): A-Za-z0-9-_",value:"A-Za-z0-9-_"},{name:"Filename safe: A-Za-z0-9+-=",value:"A-Za-z0-9+\\-="},{name:"itoa64: ./0-9A-Za-z=",value:"./0-9A-Za-z="},{name:"XML: A-Za-z0-9_.",value:"A-Za-z0-9_."},{name:"y64: A-Za-z0-9._-",value:"A-Za-z0-9._-"},{name:"z64: 0-9a-zA-Z+/=",value:"0-9a-zA-Z+/="},{name:"Radix-64 (RFC 4880): 0-9A-Za-z+/=",value:"0-9A-Za-z+/="},{name:"Uuencoding: [space]-_",value:" -_"},{name:"Xxencoding: +-0-9A-Za-z",value:"+\\-0-9A-Za-z"},{name:"BinHex: !-,-0-689@A-NP-VX-Z[`a-fh-mp-r",value:"!-,-0-689@A-NP-VX-Z[`a-fh-mp-r"},{name:"ROT13: N-ZA-Mn-za-m0-9+/=",value:"N-ZA-Mn-za-m0-9+/="},{name:"UNIX crypt: ./0-9A-Za-z",value:"./0-9A-Za-z"}]},105:function(t,e,r){"use strict";e.LatLonSpherical=r(1377),e.LatLonEllipsoidal=r(452);var n=r(1378);for(var a in n)e.LatLonEllipsoidal[a]=n[a];e.LatLonVectors=r(1379),e.Vector3d=r(586),e.Utm=r(719),e.Mgrs=r(1380),e.OsGridRef=r(1381),e.Dms=r(501)},12:function(t,e,r){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function a(t){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function i(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function u(t){function e(){var e=Reflect.construct(t,Array.from(arguments));return Object.setPrototypeOf(e,Object.getPrototypeOf(this)),e}return e.prototype=Object.create(t.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t,e}
/**
* Custom error type for handling Dish type errors.
* i.e. where the Dish cannot be successfully translated between types
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/var s=function(t){function e(){var t,r,o,u;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var s=arguments.length,c=new Array(s),l=0;l<s;l++)c[l]=arguments[l];return o=this,(r=!(u=(t=a(e)).call.apply(t,[this].concat(c)))||"object"!==n(u)&&"function"!=typeof u?i(o):u).type="DishError",Error.captureStackTrace&&Error.captureStackTrace(i(i(r)),e),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&o(t,e)}(e,u(Error)),e}();e.a=s},1377:function(t,e,r){"use strict";if(t.exports)var n=r(501);function a(t,e){if(!(this instanceof a))return new a(t,e);this.lat=Number(t),this.lon=Number(e)}a.prototype.distanceTo=function(t,e){if(!(t instanceof a))throw new TypeError("point is not LatLon object");var r=e=void 0===e?6371e3:Number(e),n=this.lat.toRadians(),o=this.lon.toRadians(),i=t.lat.toRadians(),u=i-n,s=t.lon.toRadians()-o,c=Math.sin(u/2)*Math.sin(u/2)+Math.cos(n)*Math.cos(i)*Math.sin(s/2)*Math.sin(s/2);return r*(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)))},a.prototype.bearingTo=function(t){if(!(t instanceof a))throw new TypeError("point is not LatLon object");var e=this.lat.toRadians(),r=t.lat.toRadians(),n=(t.lon-this.lon).toRadians(),o=Math.sin(n)*Math.cos(r),i=Math.cos(e)*Math.sin(r)-Math.sin(e)*Math.cos(r)*Math.cos(n);return(Math.atan2(o,i).toDegrees()+360)%360},a.prototype.finalBearingTo=function(t){if(!(t instanceof a))throw new TypeError("point is not LatLon object");return(t.bearingTo(this)+180)%360},a.prototype.midpointTo=function(t){if(!(t instanceof a))throw new TypeError("point is not LatLon object");var e=this.lat.toRadians(),r=this.lon.toRadians(),n=t.lat.toRadians(),o=(t.lon-this.lon).toRadians(),i=Math.cos(n)*Math.cos(o),u=Math.cos(n)*Math.sin(o),s=Math.sqrt((Math.cos(e)+i)*(Math.cos(e)+i)+u*u),c=Math.sin(e)+Math.sin(n),l=Math.atan2(c,s),h=r+Math.atan2(u,Math.cos(e)+i);return new a(l.toDegrees(),(h.toDegrees()+540)%360-180)},a.prototype.intermediatePointTo=function(t,e){if(!(t instanceof a))throw new TypeError("point is not LatLon object");var r=this.lat.toRadians(),n=this.lon.toRadians(),o=t.lat.toRadians(),i=t.lon.toRadians(),u=Math.sin(r),s=Math.cos(r),c=Math.sin(n),l=Math.cos(n),h=Math.sin(o),f=Math.cos(o),p=Math.sin(i),d=Math.cos(i),g=o-r,v=i-n,y=Math.sin(g/2)*Math.sin(g/2)+Math.cos(r)*Math.cos(o)*Math.sin(v/2)*Math.sin(v/2),m=2*Math.atan2(Math.sqrt(y),Math.sqrt(1-y)),b=Math.sin((1-e)*m)/Math.sin(m),M=Math.sin(e*m)/Math.sin(m),w=b*s*l+M*f*d,A=b*s*c+M*f*p,F=b*u+M*h,E=Math.atan2(F,Math.sqrt(w*w+A*A)),N=Math.atan2(A,w);return new a(E.toDegrees(),(N.toDegrees()+540)%360-180)},a.prototype.destinationPoint=function(t,e,r){r=void 0===r?6371e3:r;var n=Number(t)/Number(r),o=Number(e).toRadians(),i=this.lat.toRadians(),u=this.lon.toRadians(),s=Math.sin(i),c=Math.cos(i),l=Math.sin(n),h=Math.cos(n),f=Math.sin(o),p=s*h+c*l*Math.cos(o),d=Math.asin(p),g=f*l*c,v=h-s*p,y=u+Math.atan2(g,v);return new a(d.toDegrees(),(y.toDegrees()+540)%360-180)},a.intersection=function(t,e,r,n){if(!(t instanceof a))throw new TypeError("p1 is not LatLon object");if(!(r instanceof a))throw new TypeError("p2 is not LatLon object");var o=t.lat.toRadians(),i=t.lon.toRadians(),u=r.lat.toRadians(),s=r.lon.toRadians(),c=Number(e).toRadians(),l=Number(n).toRadians(),h=u-o,f=s-i,p=2*Math.asin(Math.sqrt(Math.sin(h/2)*Math.sin(h/2)+Math.cos(o)*Math.cos(u)*Math.sin(f/2)*Math.sin(f/2)));if(0==p)return null;var d=Math.acos((Math.sin(u)-Math.sin(o)*Math.cos(p))/(Math.sin(p)*Math.cos(o)));isNaN(d)&&(d=0);var g=Math.acos((Math.sin(o)-Math.sin(u)*Math.cos(p))/(Math.sin(p)*Math.cos(u))),v=c-(Math.sin(s-i)>0?d:2*Math.PI-d),y=(Math.sin(s-i)>0?2*Math.PI-g:g)-l;if(0==Math.sin(v)&&0==Math.sin(y))return null;if(Math.sin(v)*Math.sin(y)<0)return null;var m=-Math.cos(v)*Math.cos(y)+Math.sin(v)*Math.sin(y)*Math.cos(p),b=Math.atan2(Math.sin(p)*Math.sin(v)*Math.sin(y),Math.cos(y)+Math.cos(v)*m),M=Math.asin(Math.sin(o)*Math.cos(b)+Math.cos(o)*Ma
/**
* Co-ordinate conversion resources.
*
* @author j433866 [j433866@gmail.com]
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/(t)||function(t,e){var r=[],n=!0,a=!1,o=void 0;try{for(var i,u=t[Symbol.iterator]();!(n=(i=u.next()).done)&&(r.push(i.value),!e||r.length!==e);n=!0);}catch(t){a=!0,o=t}finally{try{n||null==u.return||u.return()}finally{if(a)throw o}}return r}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var l=["Degrees Minutes Seconds","Degrees Decimal Minutes","Decimal Degrees","Geohash","Military Grid Reference System","Ordnance Survey National Grid","Universal Transverse Mercator"],h=["Geohash","Military Grid Reference System","Ordnance Survey National Grid","Universal Transverse Mercator"];function f(t,e,r,n,a,i,l){var f,M,w,A,F,E,N,D,B,C,S,R=!1;if(l<0&&(l=0),"Auto"===r){if(null===(r=function(t){t=t.trim();var e=[",",";",":"],r=t.match(/[NnEeSsWw]/g);if(null!==r&&r.length>0&&r.length<3){var n=t.split(/[NnEeSsWw]/);if(n.length<=3&&n.length>0){if(""===n[0])return"Direction Preceding";if(""===n[n.length-1])return"Direction Following"}}for(var a=0;a<e.length;a++){var o=e[a];if(t.includes(o)){var i=t.split(o);if(i.length<=3&&i.length>0)return o}}return null}(t)))throw new s.a("Unable to detect the input delimiter automatically.")}else r.includes("Direction")||(r=b(r));if("Auto"===e&&null===(e=function(t,e){var r,n=new RegExp(/^[0-9]{2}\s?[C-HJ-NP-X]{1}\s?[A-HJ-NP-Z][A-HJ-NP-V]\s?[0-9\s]+/),a=new RegExp(/^[A-HJ-Z]{2}\s+[0-9\s]+$/),o=new RegExp(/^[0123456789BCDEFGHJKMNPQRSTUVWXYZ]+$/),i=new RegExp(/^[0-9]{2}\s?[C-HJ-NP-X]\s[0-9.]+\s?[0-9.]+$/),u=new RegExp(/[°'"]/g);if(t=t.trim(),null!==e&&e.includes("Direction")){var s=t.split(/[NnEeSsWw]/);s.length>1&&(r=""===s[0]?s[1]:s[0])}else if(null!==e&&""!==e)if(t.includes(e)){var c=t.split(e);c.length>1&&(r=""===c[0]?c[1]:c[0])}else r=t;if(!u.test(t)){var l=t.toUpperCase().replace(e,"");if(i.test(l))return"Universal Transverse Mercator";if(n.test(l))return"Military Grid Reference System";if(a.test(l))return"Ordnance Survey National Grid";if(o.test(l))return"Geohash"}if(void 0!==r){var h=p(r);switch(h.length){case 3:return"Degrees Minutes Seconds";case 2:return"Degrees Decimal Minutes";case 1:return"Decimal Degrees"}}return null}(t,r)))throw new s.a("Unable to detect the input format automatically.");if(a=b(a),h.includes(e))t=t.replace(r,""),R=!0;else{r.includes("Direction")?""===(f=t.split(/[NnEeSsWw]/g))[0]&&(f=f.slice(1)):f=t.split(r);for(var x=0;x<f.length;x++)f[x]=f[x].replace(/[°˝´'"]/g," ");f.length>1&&(R=!0)}switch(e){case"Geohash":E=o.a.decode(t.replace(/[^A-Za-z0-9]/g,"")),M=new u.a.LatLonEllipsoidal(E.latitude,E.longitude);break;case"Military Grid Reference System":M=u.a.Mgrs.parse(t.replace(/[^A-Za-z0-9]/g,"")).toUtm().toLatLonE();break;case"Ordnance Survey National Grid":N=u.a.OsGridRef.parse(t.replace(/[^A-Za-z0-9]/g,"")),M=u.a.OsGridRef.osGridToLatLon(N);break;case"Universal Transverse Mercator":/^[\d]{2}[A-Za-z]/.test(t)&&(t=t.slice(0,2)+" "+t.slice(2)),M=u.a.Utm.parse(t).toLatLonE();break;case"Degrees Minutes Seconds":if(R){if(D=p(f[0]),B=p(f[1]),!(D.length>=3&&B.length>=3))throw new s.a("Invalid co-ordinate format for Degrees Minutes Seconds");C=d(D[0],D[1],D[2],10),S=d(B[0],B[1],B[2],10),M=new u.a.LatLonEllipsoidal(C.degrees,S.degrees)}else{if(!((D=p(f[0])).length>=3))throw new s.a("Invalid co-ordinate format for Degrees Minutes Seconds");C=d(D[0],D[1],D[2]),M=new u.a.LatLonEllipsoidal(C.degrees,C.degrees)}break;case"Degrees Decimal Minutes":if(R){if(D=p(f[0]),B=p(f[1]),2!==D.length||2!==B.length)throw new s.a("Invalid co-ordinate format for Degrees Decimal Minutes.");C=g(D[0],D[1],10),S=g(B[0],B[1],10),M=new u.a.LatLonEllipsoidal(C.degrees,S.degrees)}else{if(2!==(D=p(t)).length)throw new s.a("Invalid co-ordinate format for Degrees Decimal Minutes.");C=g(D[0],D[1],10),M=new u.a.LatLonEllipsoidal(C.degrees,C.degrees)}break;case"Decimal Degrees":if(R){if(D=p(f[0]),B=p(f[1]),1!==D.length||1!==B.length)throw new s.a("Invalid co-ordinate format for Decimal Degrees.");M=new u.a.LatLonEllipsoidal(D[0],B[0])}else{if(1!==(D=p(f[0])).length)throw new s.a("Invalid co-ordinate format for Decimal Degrees.");M=new u.a.LatLonEllipsoidal(
/**
* @author j433866 [j433866@gmail.com]
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/var C=function(t){function e(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(t=N(this,D(e).call(this))).name="Convert co-ordinate format",t.module="Hashing",t.description="Converts geographical coordinates between different formats.<br><br>Supported formats:<ul><li>Degrees Minutes Seconds (DMS)</li><li>Degrees Decimal Minutes (DDM)</li><li>Decimal Degrees (DD)</li><li>Geohash</li><li>Military Grid Reference System (MGRS)</li><li>Ordnance Survey National Grid (OSNG)</li><li>Universal Transverse Mercator (UTM)</li></ul><br>The operation can try to detect the input co-ordinate format and delimiter automatically, but this may not always work correctly.",t.infoURL="https://wikipedia.org/wiki/Geographic_coordinate_conversion",t.inputType="string",t.outputType="string",t.args=[{name:"Input Format",type:"option",value:["Auto"].concat(l)},{name:"Input Delimiter",type:"option",value:["Auto","Direction Preceding","Direction Following","\\n","Comma","Semi-colon","Colon"]},{name:"Output Format",type:"option",value:l},{name:"Output Delimiter",type:"option",value:["Space","\\n","Comma","Semi-colon","Colon"]},{name:"Include Compass Directions",type:"option",value:["None","Before","After"]},{name:"Precision",type:"number",value:3}],t}var r,a,o;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&B(t,e)}(e,n["a"]),r=e,(a=[{key:"run",value:function(t,e){if(""!==t.replace(/[\s+]/g,"")){var r=F(e,6);return f(t,r[0],r[1],r[2],r[3],r[4],r[5])}return t}}])&&E(r.prototype,a),o&&E(r,o),e}(),S="undefined"==typeof self?{}:self.OpModules||{};S.Hashing={"Convert co-ordinate format":C};e.default=S},18:function(t,e,r){"use strict";r.d(e,"b",function(){return a}),r.d(e,"a",function(){return o});var n=r(0);
/**
* Binary functions.
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/function a(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Space",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:8;if(!t)return"";e=n.a.charRep(e);for(var a="",o=0;o<t.length;o++)a+=t[o].toString(2).padStart(r,"0")+e;return e.length?a.slice(0,-e.length):a}function o(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Space",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:8,a=n.a.regexRep(e);t=t.replace(a,"");for(var o=[],i=0;i<t.length;i+=r)o.push(parseInt(t.substr(i,r),2));return o}},19:function(t,e,r){"use strict";r.d(e,"a",function(){return a});var n=r(0);
/**
* Decimal functions.
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/function a(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Auto";e=n.a.charRep(e);var r=[],a=t.split(e);""===a[a.length-1]&&(a=a.slice(0,a.length-1));for(var o=0;o<a.length;o++)r[o]=parseInt(a[o],10);return r}},3:function(t,e,r){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function a(t){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function i(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function u(t){function e(){var e=Reflect.construct(t,Array.from(arguments));return Object.setPrototypeOf(e,Object.getPrototypeOf(this)),e}return e.prototype=Object.create(t.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t,e}
/**
* Custom error type for handling operation input errors.
* i.e. where the operation can handle the error and print a message to the screen.
*
* @author d98762625 [d98762625@gmail.com]
* @copyright Crown Copyright 2018
* @license Apache-2.0
*/var s=function(t){function e(){var t,r,o,u;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var s=arguments.length,c=new Array(s),l=0;l<s;l++)c[l]=arguments[l];return o=this,(r=!(u=(t=a(e)).call.apply(t,[this].concat(c)))||"object"!==n(u)&&"function"!=typeof u?i(o):u).type="OperationError",Error.captureStackTrace&&Error.captureStackTrace(i(i(r)),e),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&o(t,e)}(e,u(Error)),e}();e.a=s},4:function(t,e,r){var n;!function(a){"use strict";var o,i=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,u=Math.ceil,s=Math.floor,c="[BigNumber Error] ",l=c+"Number primitive has more than 15 significant digits: ",h=1e14,f=14,p=9007199254740991,d=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],g=1e7,v=1e9;function y(t){var e=0|t;return t>0||t===e?e:e-1}function m(t){for(var e,r,n=1,a=t.length,o=t[0]+"";n<a;){for(e=t[n++]+"",r=f-e.length;r--;e="0"+e);o+=e}for(a=o.length;48===o.charCodeAt(--a););return o.slice(0,a+1||1)}function b(t,e){var r,n,a=t.c,o=e.c,i=t.s,u=e.s,s=t.e,c=e.e;if(!i||!u)return null;if(r=a&&!a[0],n=o&&!o[0],r||n)return r?n?0:-u:i;if(i!=u)return i;if(r=i<0,n=s==c,!a||!o)return n?0:!a^r?1:-1;if(!n)return s>c^r?1:-1;for(u=(s=a.length)<(c=o.length)?s:c,i=0;i<u;i++)if(a[i]!=o[i])return a[i]>o[i]^r?1:-1;return s==c?0:s>c^r?1:-1}function M(t,e,r,n){if(t<e||t>r||t!==(t<0?u(t):s(t)))throw Error(c+(n||"Argument")+("number"==typeof t?t<e||t>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function w(t){var e=t.c.length-1;return y(t.e/f)==e&&t.c[e]%2!=0}function A(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function F(t,e,r){var n,a;if(e<0){for(a=r+".";++e;a+=r);t=a+t}else if(++e>(n=t.length)){for(a=r,e-=n;--e;a+=r);t+=a}else e<n&&(t=t.slice(0,e)+"."+t.slice(e));return t}(o=function t(e){var r,n,a,o,E,N,D,B,C,S=z.prototype={constructor:z,toString:null,valueOf:null},R=new z(1),x=20,L=4,T=-7,k=21,O=-1e7,I=1e7,_=!1,P=1,U=0,j={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},G="0123456789abcdefghijklmnopqrstuvwxyz";function z(t,e){var r,o,u,c,h,d,g,v,y=this;if(!(y instanceof z))return new z(t,e);if(null==e){if(t instanceof z)return y.s=t.s,y.e=t.e,void(y.c=(t=t.c)?t.slice():t);if((d="number"==typeof t)&&0*t==0){if(y.s=1/t<0?(t=-t,-1):1,t===~~t){for(c=0,h=t;h>=10;h/=10,c++);return y.e=c,void(y.c=[t])}v=String(t)}else{if(v=String(t),!i.test(v))return a(y,v,d);y.s=45==v.charCodeAt(0)?(v=v.slice(1),-1):1}(c=v.indexOf("."))>-1&&(v=v.replace(".","")),(h=v.search(/e/i))>0?(c<0&&(c=h),c+=+v.slice(h+1),v=v.substring(0,h)):c<0&&(c=v.length)}else{if(M(e,2,G.length,"Base"),v=String(t),10==e)return H(y=new z(t instanceof z?t:v),x+y.e+1,L);if(d="number"==typeof t){if(0*t!=0)return a(y,v,d,e);if(y.s=1/t<0?(v=v.slice(1),-1):1,z.DEBUG&&v.replace(/^0\.0*|\./,"").length>15)throw Error(l+t);d=!1}else y.s=45===v.charCodeAt(0)?(v=v.slice(1),-1):1;for(r=G.slice(0,e),c=h=0,g=v.length;h<g;h++)if(r.indexOf(o=v.charAt(h))<0){if("."==o){if(h>c){c=g;continue}}else if(!u&&(v==v.toUpperCase()&&(v=v.toLowerCase())||v==v.toLowerCase()&&(v=v.toUpperCase()))){u=!0,h=-1,c=0;continue}return a(y,String(t),d,e)}(c=(v=n(v,e,10,y.s)).indexOf("."))>-1?v=v.replace(".",""):c=v.length}for(h=0;48===v.charCodeAt(h);h++);for(g=v.length;48===v.charCodeAt(--g););if(v=v.slice(h,++g)){if(g-=h,d&&z.DEBUG&&g>15&&(t>p||t!==s(t)))throw Error(l+y.s*t);if((c=c-h-1)>I)y.c=y.e=null;else if(c<O)y.c=[y.e=0];else{if(y.e=c,y.c=[],h=(c+1)%f,c<0&&(h+=f),h<g){for(h&&y.c.push(+v.slice(0,h)),g-=f;h<g;)y.c.push(+v.slice(h,h+=f));v=v.slice(h),h=f-v.length}else h-=g;for(;h--;v+="0");y.c.push(+v)}}else y.c=[y.e=0]}function V(t,e,r,n){var a,o,i,u,s;if(null==r?r=L:M(r,0,8),!t.c)return t.toString();if(a=t.c[0],i=t.e,null==e)s=m(t.c),s=1==n||2==n&&(i<=T||i>=k)?A(s,i):F(s,i,"0");els
/**
* Hexadecimal functions.
*
* @author n1474335 [n1474335@gmail.com]
* @copyright Crown Copyright 2016
* @license Apache-2.0
*/function a(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:" ",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;if(!t)return"";for(var n="",a=0;a<t.length;a++)n+=t[a].toString(16).padStart(r,"0")+e;return"0x"===e&&(n="0x"+n),"\\x"===e&&(n="\\x"+n),e.length?n.slice(0,-e.length):n}function o(t){if(!t)return"";for(var e=[],r=0;r<t.length;r++)e.push((t[r]>>>4).toString(16)),e.push((15&t[r]).toString(16));return e.join("")}function i(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Auto",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;if("None"!==e){var a="Auto"===e?/[^a-f\d]/gi:n.a.regexRep(e);t=t.replace(a,"")}for(var o=[],i=0;i<t.length;i+=r)o.push(parseInt(t.substr(i,r),16));return o}var u=["Space","Comma","Semi-colon","Colon","Line feed","CRLF","0x","\\x","None"],s=["Auto"].concat(u)},719:function(t,e,r){"use strict";if(t.exports)var n=r(452);function a(t,e,r,o,i,u,s){if(!(this instanceof a))return new a(t,e,r,o,i,u,s);if(void 0===i&&(i=n.datum.WGS84),void 0===u&&(u=null),void 0===s&&(s=null),!(1<=t&&t<=60))throw new Error("Invalid UTM zone "+t);if(!e.match(/[NS]/i))throw new Error("Invalid UTM hemisphere "+e);this.zone=Number(t),this.hemisphere=e.toUpperCase(),this.easting=Number(r),this.northing=Number(o),this.datum=i,this.convergence=null===u?null:Number(u),this.scale=null===s?null:Number(s)}n.prototype.toUtm=function(){if(isNaN(this.lat)||isNaN(this.lon))throw new Error("Invalid point");if(!(-80<=this.lat&&this.lat<=84))throw new Error("Outside UTM limits");var t=Math.floor((this.lon+180)/6)+1,e=(6*(t-1)-180+3).toRadians(),r="CDEFGHJKLMNPQRSTUVWXX".charAt(Math.floor(this.lat/8+10));31==t&&"V"==r&&this.lon>=3&&(t++,e+=6..toRadians()),32==t&&"X"==r&&this.lon<9&&(t--,e-=6..toRadians()),32==t&&"X"==r&&this.lon>=9&&(t++,e+=6..toRadians()),34==t&&"X"==r&&this.lon<21&&(t--,e-=6..toRadians()),34==t&&"X"==r&&this.lon>=21&&(t++,e+=6..toRadians()),36==t&&"X"==r&&this.lon<33&&(t--,e-=6..toRadians()),36==t&&"X"==r&&this.lon>=33&&(t++,e+=6..toRadians());for(var n=this.lat.toRadians(),o=this.lon.toRadians()-e,i=this.datum.ellipsoid.a,u=this.datum.ellipsoid.f,s=Math.sqrt(u*(2-u)),c=u/(2-u),l=c*c,h=c*l,f=c*h,p=c*f,d=c*p,g=Math.cos(o),v=Math.sin(o),y=Math.tan(o),m=Math.tan(n),b=Math.sinh(s*Math.atanh(s*m/Math.sqrt(1+m*m))),M=m*Math.sqrt(1+b*b)-b*Math.sqrt(1+m*m),w=Math.atan2(M,g),A=Math.asinh(v/Math.sqrt(M*M+g*g)),F=i/(1+c)*(1+.25*l+1/64*f+1/256*d),E=[null,.5*c-2/3*l+5/16*h+41/180*f-127/288*p+7891/37800*d,13/48*l-.6*h+557/1440*f+281/630*p-1983433/1935360*d,61/240*h-103/140*f+15061/26880*p+167603/181440*d,49561/161280*f-179/168*p+6601661/7257600*d,34729/80640*p-3418889/1995840*d,.6650675310896665*d],N=w,D=1;D<=6;D++)N+=E[D]*Math.sin(2*D*w)*Math.cosh(2*D*A);var B=A;for(D=1;D<=6;D++)B+=E[D]*Math.cos(2*D*w)*Math.sinh(2*D*A);var C=.9996*F*B,S=.9996*F*N,R=1;for(D=1;D<=6;D++)R+=2*D*E[D]*Math.cos(2*D*w)*Math.cosh(2*D*A);var x=0;for(D=1;D<=6;D++)x+=2*D*E[D]*Math.sin(2*D*w)*Math.sinh(2*D*A);var L=Math.atan(M/Math.sqrt(1+M*M)*y)+Math.atan2(x,R),T=Math.sin(n),k=.9996*(Math.sqrt(1-s*s*T*T)*Math.sqrt(1+m*m)/Math.sqrt(M*M+g*g))*(F/i*Math.sqrt(R*R+x*x));C+=5e5,S<0&&(S+=1e7),C=Number(C.toFixed(6)),S=Number(S.toFixed(6));var O=Number(L.toDegrees().toFixed(9)),I=Number(k.toFixed(12));return new a(t,this.lat>=0?"N":"S",C,S,this.datum,O,I)},a.prototype.toLatLonE=function(){var t=this.zone,e=this.hemisphere,r=this.easting,a=this.northing;if(isNaN(t)||isNaN(r)||isNaN(a))throw new Error("Invalid coordinate");var o=this.datum.ellipsoid.a,i=this.datum.ellipsoid.f;r-=5e5,a="S"==e?a-1e7:a;for(var u=Math.sqrt(i*(2-i)),s=i/(2-i),c=s*s,l=s*c,h=s*l,f=s*h,p=s*f,d=o/(1+s)*(1+.25*c+1/64*h+1/256*p),g=r/(.9996*d),v=a/(.9996*d),y=[null,.5*s-2/3*c+37/96*l-1/360*h-81/512*f+96199/604800*p,1/48*c+1/15*l-437/1440*h+46/105*f-1118711/3870720*p,17/480*l-37/840*h-209/4480*f+5569/90720*p,4397/161280*h-11/504*f-830251/7257600*p,4583/161280*f-108847/3991680*p,.03233083094085698*p],m=v,b=1;b<=6;b++)m-=y[b]*Math.sin(2*b*v)*Math.cosh(2*b*g);var M=g;for(b=1;b<=6;b++)M-=y[b]*Math.cos(2*b*v)*Math.sinh(2*b*g);var w=Math.sinh(M),A=Math
/**
* @author n1474335 [n1474335@gmail.com]
* @author Matt C [matt@artemisbot.uk]
* @copyright Crown Copyright 2016
* @license Apache-2.0
*/
var f=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.value=[],this.type=t.BYTE_ARRAY,e&&e.hasOwnProperty("value")&&e.hasOwnProperty("type")&&this.set(e.value,e.type)}var e,r,o;return e=t,r=[{key:"set",value:function(e,r){if("string"==typeof r&&(r=t.typeEnum(r)),s.a.debug("Dish type: "+t.enumLookup(r)),this.value=e,this.type=r,!this.valid()){var o=n.a.truncate(JSON.stringify(this.value),13);throw new a.a("Data is not a valid ".concat(t.enumLookup(r),": ").concat(o))}}},{key:"get",value:function(){var e=l(regeneratorRuntime.mark(function e(r){var n,a=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=a.length>1&&void 0!==a[1]&&a[1],"string"==typeof r&&(r=t.typeEnum(r)),this.type===r){e.next=5;break}return e.next=5,this._translate(r,n);case 5:return e.abrupt("return",this.value);case 6:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"_translate",value:function(){var e=l(regeneratorRuntime.mark(function e(r){var o,u,c=arguments;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:o=c.length>1&&void 0!==c[1]&&c[1],s.a.debug("Translating Dish from ".concat(t.enumLookup(this.type)," to ").concat(t.enumLookup(r))),u=o?n.a.byteArrayToChars:n.a.byteArrayToUtf8,e.prev=3,e.t0=this.type,e.next=e.t0===t.STRING?7:e.t0===t.NUMBER?9:e.t0===t.HTML?11:e.t0===t.ARRAY_BUFFER?13:e.t0===t.BIG_NUMBER?15:e.t0===t.JSON?17:e.t0===t.FILE?19:e.t0===t.LIST_FILE?24:30;break;case 7:return this.value=this.value?n.a.strToByteArray(this.value):[],e.abrupt("break",31);case 9:return this.value="number"==typeof this.value?n.a.strToByteArray(this.value.toString()):[],e.abrupt("break",31);case 11:return this.value=this.value?n.a.strToByteArray(n.a.unescapeHtml(n.a.stripHtmlTags(this.value,!0))):[],e.abrupt("break",31);case 13:return this.value=Array.prototype.slice.call(new Uint8Array(this.value)),e.abrupt("break",31);case 15:return this.value=i.a.isBigNumber(this.value)?n.a.strToByteArray(this.value.toFixed()):[],e.abrupt("break",31);case 17:return this.value=this.value?n.a.strToByteArray(JSON.stringify(this.value,null,4)):[],e.abrupt("break",31);case 19:return e.next=21,n.a.readFile(this.value);case 21:return this.value=e.sent,this.value=Array.prototype.slice.call(this.value),e.abrupt("break",31);case 24:return e.next=26,Promise.all(this.value.map(function(){var t=l(regeneratorRuntime.mark(function t(e){return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",n.a.readFile(e));case 1:case"end":return t.stop()}},t,this)}));return function(e){return t.apply(this,arguments)}}()));case 26:return this.value=e.sent,this.value=this.value.map(function(t){return Array.prototype.slice.call(t)}),this.value=[].concat.apply([],this.value),e.abrupt("break",31);case 30:return e.abrupt("break",31);case 31:e.next=36;break;case 33:throw e.prev=33,e.t1=e.catch(3),new a.a("Error translating from ".concat(t.enumLookup(this.type)," to byteArray: ").concat(e.t1));case 36:this.type=t.BYTE_ARRAY,e.prev=37,e.t2=r,e.next=e.t2===t.STRING?41:e.t2===t.HTML?41:e.t2===t.NUMBER?44:e.t2===t.ARRAY_BUFFER?47:e.t2===t.BIG_NUMBER?50:e.t2===t.JSON?53:e.t2===t.FILE?56:e.t2===t.LIST_FILE?58:61;break;case 41:return this.value=this.value?u(this.value):"",this.type=t.STRING,e.abrupt("break",62);case 44:return this.value=this.value?parseFloat(u(this.value)):0,this.type=t.NUMBER,e.abrupt("break",62);case 47:return this.value=new Uint8Array(this.value).buffer,this.type=t.ARRAY_BUFFER,e.abrupt("break",62);case 50:try{this.value=new i.a(u(this.value))}catch(t){this.value=new i.a(NaN)}return this.type=t.BIG_NUMBER,e.abrupt("break",62);case 53:return this.value=JSON.parse(u(this.value)),this.type=t.JSON,e.abrupt("break",62);case 56:return this.value=new File(this.value,"unknown"),e.abrupt("break",62);case 58:return this.value=[new File(this.value,"unknown")],this.type=t.LIST_FILE,e.abrupt("break",