UNPKG

codemirror-typo

Version:

:snail: Spellcheck your CodeMirror editor in style

11 lines (10 loc) 46.9 kB
/** * codemirror-typo * @version v1.0.1 * @link https://github.com/pirtleshell/codemirror-typo#readme * @license MIT * @author Robert Pirtle */ !function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.codeMirrorTypo=t()}}(function(){var t;return function t(e,r,n){function i(s,u){if(!r[s]){if(!e[s]){var a="function"==typeof require&&require;if(!u&&a)return a(s,!0);if(o)return o(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[s]={exports:{}};e[s][0].call(c.exports,function(t){var r=e[s][1][t];return i(r?r:t)},c,c.exports,t,e,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s<n.length;s++)i(n[s]);return i}({1:[function(t,e,r){"use strict";function n(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function i(t){return 3*t.length/4-n(t)}function o(t){var e,r,i,o,s,u,a=t.length;s=n(t),u=new h(3*a/4-s),i=s>0?a-4:a;var f=0;for(e=0,r=0;e<i;e+=4,r+=3)o=c[t.charCodeAt(e)]<<18|c[t.charCodeAt(e+1)]<<12|c[t.charCodeAt(e+2)]<<6|c[t.charCodeAt(e+3)],u[f++]=o>>16&255,u[f++]=o>>8&255,u[f++]=255&o;return 2===s?(o=c[t.charCodeAt(e)]<<2|c[t.charCodeAt(e+1)]>>4,u[f++]=255&o):1===s&&(o=c[t.charCodeAt(e)]<<10|c[t.charCodeAt(e+1)]<<4|c[t.charCodeAt(e+2)]>>2,u[f++]=o>>8&255,u[f++]=255&o),u}function s(t){return f[t>>18&63]+f[t>>12&63]+f[t>>6&63]+f[63&t]}function u(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16)+(t[o+1]<<8)+t[o+2],i.push(s(n));return i.join("")}function a(t){for(var e,r=t.length,n=r%3,i="",o=[],s=16383,a=0,c=r-n;a<c;a+=s)o.push(u(t,a,a+s>c?c:a+s));return 1===n?(e=t[r-1],i+=f[e>>2],i+=f[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=f[e>>10],i+=f[e>>4&63],i+=f[e<<2&63],i+="="),o.push(i),o.join("")}r.byteLength=i,r.toByteArray=o,r.fromByteArray=a;for(var f=[],c=[],h="undefined"!=typeof Uint8Array?Uint8Array:Array,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,d=l.length;p<d;++p)f[p]=l[p],c[l.charCodeAt(p)]=p;c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63},{}],2:[function(t,e,r){},{}],3:[function(t,e,r){(function(e){"use strict";function n(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}function i(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(t,e){if(i()<e)throw new RangeError("Invalid typed array length");return s.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e),t.__proto__=s.prototype):(null===t&&(t=new s(e)),t.length=e),t}function s(t,e,r){if(!(s.TYPED_ARRAY_SUPPORT||this instanceof s))return new s(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return c(this,t)}return u(this,t,e,r)}function u(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?p(t,e,r,n):"string"==typeof e?h(t,e,r):d(t,e)}function a(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function f(t,e,r,n){return a(e),e<=0?o(t,e):void 0!==r?"string"==typeof n?o(t,e).fill(r,n):o(t,e).fill(r):o(t,e)}function c(t,e){if(a(e),t=o(t,e<0?0:0|g(e)),!s.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function h(t,e,r){if("string"==typeof r&&""!==r||(r="utf8"),!s.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|v(e,r);t=o(t,n);var i=t.write(e,r);return i!==n&&(t=t.slice(0,i)),t}function l(t,e){var r=e.length<0?0:0|g(e.length);t=o(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function p(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n),s.TYPED_ARRAY_SUPPORT?(t=e,t.__proto__=s.prototype):t=l(t,e),t}function d(t,e){if(s.isBuffer(e)){var r=0|g(e.length);return t=o(t,r),0===t.length?t:(e.copy(t,0,0,r),t)}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||J(e.length)?o(t,0):l(t,e);if("Buffer"===e.type&&Q(e.data))return l(t,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function g(t){if(t>=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|t}function y(t){return+t!=t&&(t=0),s.alloc(+t)}function v(t,e){if(s.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return G(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return K(t).length;default:if(n)return G(t).length;e=(""+e).toLowerCase(),n=!0}}function m(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if(r>>>=0,e>>>=0,r<=e)return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return M(this,e,r);case"latin1":case"binary":return U(this,e,r);case"base64":return P(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function w(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function b(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:_(t,e,r,n,i);if("number"==typeof e)return e=255&e,s.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):_(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function _(t,e,r,n,i){function o(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}var s=1,u=t.length,a=e.length;if(void 0!==n&&(n=String(n).toLowerCase(),"ucs2"===n||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,u/=2,a/=2,r/=2}var f;if(i){var c=-1;for(f=r;f<u;f++)if(o(t,f)===o(e,c===-1?0:f-c)){if(c===-1&&(c=f),f-c+1===a)return c*s}else c!==-1&&(f-=f-c),c=-1}else for(r+a>u&&(r=u-a),f=r;f>=0;f--){for(var h=!0,l=0;l<a;l++)if(o(t,f+l)!==o(e,l)){h=!1;break}if(h)return f}return-1}function E(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var o=e.length;if(o%2!==0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var u=parseInt(e.substr(2*s,2),16);if(isNaN(u))return s;t[r+s]=u}return s}function A(t,e,r,n){return V(G(e,t.length-r),t,r,n)}function R(t,e,r,n){return V($(e),t,r,n)}function T(t,e,r,n){return R(t,e,r,n)}function C(t,e,r,n){return V(K(e),t,r,n)}function S(t,e,r,n){return V(H(e,t.length-r),t,r,n)}function P(t,e,r){return 0===e&&r===t.length?W.fromByteArray(t):W.fromByteArray(t.slice(e,r))}function x(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var o=t[i],s=null,u=o>239?4:o>223?3:o>191?2:1;if(i+u<=r){var a,f,c,h;switch(u){case 1:o<128&&(s=o);break;case 2:a=t[i+1],128===(192&a)&&(h=(31&o)<<6|63&a,h>127&&(s=h));break;case 3:a=t[i+1],f=t[i+2],128===(192&a)&&128===(192&f)&&(h=(15&o)<<12|(63&a)<<6|63&f,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:a=t[i+1],f=t[i+2],c=t[i+3],128===(192&a)&&128===(192&f)&&128===(192&c)&&(h=(15&o)<<18|(63&a)<<12|(63&f)<<6|63&c,h>65535&&h<1114112&&(s=h))}}null===s?(s=65533,u=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),i+=u}return O(n)}function O(t){var e=t.length;if(e<=tt)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=tt));return r}function M(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function U(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function B(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=e;o<r;++o)i+=X(t[o]);return i}function I(t,e,r){for(var n=t.slice(e,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function L(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function j(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function Y(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);i<o;++i)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function k(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);i<o;++i)t[r+i]=e>>>8*(n?i:3-i)&255}function N(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function F(t,e,r,n,i){return i||N(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),Z.write(t,e,r,n,23,4),r+4}function D(t,e,r,n,i){return i||N(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),Z.write(t,e,r,n,52,8),r+8}function z(t){if(t=q(t).replace(et,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function q(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function X(t){return t<16?"0"+t.toString(16):t.toString(16)}function G(t,e){e=e||1/0;for(var r,n=t.length,i=null,o=[],s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function $(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}function H(t,e){for(var r,n,i,o=[],s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function K(t){return W.toByteArray(z(t))}function V(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function J(t){return t!==t}var W=t("base64-js"),Z=t("ieee754"),Q=t("isarray");r.Buffer=s,r.SlowBuffer=y,r.INSPECT_MAX_BYTES=50,s.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:n(),r.kMaxLength=i(),s.poolSize=8192,s._augment=function(t){return t.__proto__=s.prototype,t},s.from=function(t,e,r){return u(null,t,e,r)},s.TYPED_ARRAY_SUPPORT&&(s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&s[Symbol.species]===s&&Object.defineProperty(s,Symbol.species,{value:null,configurable:!0})),s.alloc=function(t,e,r){return f(null,t,e,r)},s.allocUnsafe=function(t){return c(null,t)},s.allocUnsafeSlow=function(t){return c(null,t)},s.isBuffer=function(t){return!(null==t||!t._isBuffer)},s.compare=function(t,e){if(!s.isBuffer(t)||!s.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},s.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(t,e){if(!Q(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return s.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=s.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){var o=t[r];if(!s.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},s.byteLength=v,s.prototype._isBuffer=!0,s.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)w(this,e,e+1);return this},s.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)w(this,e,e+3),w(this,e+1,e+2);return this},s.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)w(this,e,e+7),w(this,e+1,e+6),w(this,e+2,e+5),w(this,e+3,e+4);return this},s.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?x(this,0,t):m.apply(this,arguments)},s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),"<Buffer "+t+">"},s.prototype.compare=function(t,e,r,n,i){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,i>>>=0,this===t)return 0;for(var o=i-n,u=r-e,a=Math.min(o,u),f=this.slice(n,i),c=t.slice(e,r),h=0;h<a;++h)if(f[h]!==c[h]){o=f[h],u=c[h];break}return o<u?-1:u<o?1:0},s.prototype.includes=function(t,e,r){return this.indexOf(t,e,r)!==-1},s.prototype.indexOf=function(t,e,r){return b(this,t,e,r,!0)},s.prototype.lastIndexOf=function(t,e,r){return b(this,t,e,r,!1)},s.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e=0|e,isFinite(r)?(r=0|r,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return E(this,t,e,r);case"utf8":case"utf-8":return A(this,t,e,r);case"ascii":return R(this,t,e,r);case"latin1":case"binary":return T(this,t,e,r);case"base64":return C(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var tt=4096;s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),e<t&&(e=t);var n;if(s.TYPED_ARRAY_SUPPORT)n=this.subarray(t,e),n.__proto__=s.prototype;else{var i=e-t;n=new s(i,(void 0));for(var o=0;o<i;++o)n[o]=this[o+t]}return n},s.prototype.readUIntLE=function(t,e,r){t=0|t,e=0|e,r||L(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n},s.prototype.readUIntBE=function(t,e,r){t=0|t,e=0|e,r||L(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return e||L(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return e||L(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return e||L(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return e||L(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return e||L(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t=0|t,e=0|e,r||L(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t=0|t,e=0|e,r||L(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return e||L(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},s.prototype.readInt16LE=function(t,e){e||L(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){e||L(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return e||L(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return e||L(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return e||L(t,4,this.length),Z.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return e||L(t,4,this.length),Z.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return e||L(t,8,this.length),Z.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return e||L(t,8,this.length),Z.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e=0|e,r=0|r,!n){var i=Math.pow(2,8*r)-1;j(this,t,e,r,i,0)}var o=1,s=0;for(this[e]=255&t;++s<r&&(o*=256);)this[e+s]=t/o&255;return e+r},s.prototype.writeUIntBE=function(t,e,r,n){if(t=+t,e=0|e,r=0|r,!n){var i=Math.pow(2,8*r)-1;j(this,t,e,r,i,0)}var o=r-1,s=1;for(this[e+o]=255&t;--o>=0&&(s*=256);)this[e+o]=t/s&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e=0|e,r||j(this,t,e,1,255,0),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=0|e,r||j(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):Y(this,t,e,!0),e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=0|e,r||j(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):Y(this,t,e,!1),e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=0|e,r||j(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):k(this,t,e,!0),e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=0|e,r||j(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):k(this,t,e,!1),e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);j(this,t,e,r,i-1,-i)}var o=0,s=1,u=0;for(this[e]=255&t;++o<r&&(s*=256);)t<0&&0===u&&0!==this[e+o-1]&&(u=1),this[e+o]=(t/s>>0)-u&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e=0|e,!n){var i=Math.pow(2,8*r-1);j(this,t,e,r,i-1,-i)}var o=r-1,s=1,u=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===u&&0!==this[e+o+1]&&(u=1),this[e+o]=(t/s>>0)-u&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e=0|e,r||j(this,t,e,1,127,-128),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e=0|e,r||j(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):Y(this,t,e,!0),e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e=0|e,r||j(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):Y(this,t,e,!1),e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e=0|e,r||j(this,t,e,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):k(this,t,e,!0),e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e=0|e,r||j(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):k(this,t,e,!1),e+4},s.prototype.writeFloatLE=function(t,e,r){return F(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return F(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return D(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return D(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var i,o=n-r;if(this===t&&r<e&&e<n)for(i=o-1;i>=0;--i)t[i+e]=this[i+r];else if(o<1e3||!s.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+o),e);return o},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t=255&t);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0);var o;if("number"==typeof t)for(o=e;o<r;++o)this[o]=t;else{var u=s.isBuffer(t)?t:G(new s(t,n).toString()),a=u.length;for(o=0;o<r-e;++o)this[o+e]=u[o%a]}return this};var et=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":1,ieee754:5,isarray:6}],4:[function(e,r,n){(function(i,o){!function(e,i){"object"==typeof n&&"undefined"!=typeof r?r.exports=i():"function"==typeof t&&t.amd?t(i):e.ES6Promise=i()}(this,function(){"use strict";function t(t){return"function"==typeof t||"object"==typeof t&&null!==t}function r(t){return"function"==typeof t}function n(t){V=t}function s(t){J=t}function u(){return function(){return i.nextTick(l)}}function a(){return"undefined"!=typeof K?function(){K(l)}:h()}function f(){var t=0,e=new Q(l),r=document.createTextNode("");return e.observe(r,{characterData:!0}),function(){r.data=t=++t%2}}function c(){var t=new MessageChannel;return t.port1.onmessage=l,function(){return t.port2.postMessage(0)}}function h(){var t=setTimeout;return function(){return t(l,1)}}function l(){for(var t=0;t<H;t+=2){var e=rt[t],r=rt[t+1];e(r),rt[t]=void 0,rt[t+1]=void 0}H=0}function p(){try{var t=e,r=t("vertx");return K=r.runOnLoop||r.runOnContext,a()}catch(t){return h()}}function d(t,e){var r=arguments,n=this,i=new this.constructor(y);void 0===i[it]&&L(i);var o=n._state;return o?!function(){var t=r[o-1];J(function(){return U(o,i,t,n._result)})}():P(n,i,t,e),i}function g(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var r=new e(y);return R(r,t),r}function y(){}function v(){return new TypeError("You cannot resolve a promise with itself")}function m(){return new TypeError("A promises callback cannot return that same promise.")}function w(t){try{return t.then}catch(t){return at.error=t,at}}function b(t,e,r,n){try{t.call(e,r,n)}catch(t){return t}}function _(t,e,r){J(function(t){var n=!1,i=b(r,e,function(r){n||(n=!0,e!==r?R(t,r):C(t,r))},function(e){n||(n=!0,S(t,e))},"Settle: "+(t._label||" unknown promise"));!n&&i&&(n=!0,S(t,i))},t)}function E(t,e){e._state===st?C(t,e._result):e._state===ut?S(t,e._result):P(e,void 0,function(e){return R(t,e)},function(e){return S(t,e)})}function A(t,e,n){e.constructor===t.constructor&&n===d&&e.constructor.resolve===g?E(t,e):n===at?S(t,at.error):void 0===n?C(t,e):r(n)?_(t,e,n):C(t,e)}function R(e,r){e===r?S(e,v()):t(r)?A(e,r,w(r)):C(e,r)}function T(t){t._onerror&&t._onerror(t._result),x(t)}function C(t,e){t._state===ot&&(t._result=e,t._state=st,0!==t._subscribers.length&&J(x,t))}function S(t,e){t._state===ot&&(t._state=ut,t._result=e,J(T,t))}function P(t,e,r,n){var i=t._subscribers,o=i.length;t._onerror=null,i[o]=e,i[o+st]=r,i[o+ut]=n,0===o&&t._state&&J(x,t)}function x(t){var e=t._subscribers,r=t._state;if(0!==e.length){for(var n=void 0,i=void 0,o=t._result,s=0;s<e.length;s+=3)n=e[s],i=e[s+r],n?U(r,n,i,o):i(o);t._subscribers.length=0}}function O(){this.error=null}function M(t,e){try{return t(e)}catch(t){return ft.error=t,ft}}function U(t,e,n,i){var o=r(n),s=void 0,u=void 0,a=void 0,f=void 0;if(o){if(s=M(n,i),s===ft?(f=!0,u=s.error,s=null):a=!0,e===s)return void S(e,m())}else s=i,a=!0;e._state!==ot||(o&&a?R(e,s):f?S(e,u):t===st?C(e,s):t===ut&&S(e,s))}function B(t,e){try{e(function(e){R(t,e)},function(e){S(t,e)})}catch(e){S(t,e)}}function I(){return ct++}function L(t){t[it]=ct++,t._state=void 0,t._result=void 0,t._subscribers=[]}function j(t,e){this._instanceConstructor=t,this.promise=new t(y),this.promise[it]||L(this.promise),$(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?C(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&C(this.promise,this._result))):S(this.promise,Y())}function Y(){return new Error("Array Methods must be provided an Array")}function k(t){return new j(this,t).promise}function N(t){var e=this;return new e($(t)?function(r,n){for(var i=t.length,o=0;o<i;o++)e.resolve(t[o]).then(r,n)}:function(t,e){return e(new TypeError("You must pass an array to race."))})}function F(t){var e=this,r=new e(y);return S(r,t),r}function D(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function z(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function q(t){this[it]=I(),this._result=this._state=void 0,this._subscribers=[],y!==t&&("function"!=typeof t&&D(),this instanceof q?B(this,t):z())}function X(){var t=void 0;if("undefined"!=typeof o)t=o;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(t){throw new Error("polyfill failed because global object is unavailable in this environment")}var e=t.Promise;if(e){var r=null;try{r=Object.prototype.toString.call(e.resolve())}catch(t){}if("[object Promise]"===r&&!e.cast)return}t.Promise=q}var G=void 0;G=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var $=G,H=0,K=void 0,V=void 0,J=function(t,e){rt[H]=t,rt[H+1]=e,H+=2,2===H&&(V?V(l):nt())},W="undefined"!=typeof window?window:void 0,Z=W||{},Q=Z.MutationObserver||Z.WebKitMutationObserver,tt="undefined"==typeof self&&"undefined"!=typeof i&&"[object process]"==={}.toString.call(i),et="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,rt=new Array(1e3),nt=void 0;nt=tt?u():Q?f():et?c():void 0===W&&"function"==typeof e?p():h();var it=Math.random().toString(36).substring(16),ot=void 0,st=1,ut=2,at=new O,ft=new O,ct=0;return j.prototype._enumerate=function(){for(var t=this.length,e=this._input,r=0;this._state===ot&&r<t;r++)this._eachEntry(e[r],r)},j.prototype._eachEntry=function(t,e){var r=this._instanceConstructor,n=r.resolve;if(n===g){var i=w(t);if(i===d&&t._state!==ot)this._settledAt(t._state,e,t._result);else if("function"!=typeof i)this._remaining--,this._result[e]=t;else if(r===q){var o=new r(y);A(o,t,i),this._willSettleAt(o,e)}else this._willSettleAt(new r(function(e){return e(t)}),e)}else this._willSettleAt(n(t),e)},j.prototype._settledAt=function(t,e,r){var n=this.promise;n._state===ot&&(this._remaining--,t===ut?S(n,r):this._result[e]=r),0===this._remaining&&C(n,this._result)},j.prototype._willSettleAt=function(t,e){var r=this;P(t,void 0,function(t){return r._settledAt(st,e,t)},function(t){return r._settledAt(ut,e,t)})},q.all=k,q.race=N,q.resolve=g,q.reject=F,q._setScheduler=n,q._setAsap=s,q._asap=J,q.prototype={constructor:q,then:d,catch:function(t){return this.then(null,t)}},q.polyfill=X,q.Promise=q,q})}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:9}],5:[function(t,e,r){r.read=function(t,e,r,n,i){var o,s,u=8*i-n-1,a=(1<<u)-1,f=a>>1,c=-7,h=r?i-1:0,l=r?-1:1,p=t[e+h];for(h+=l,o=p&(1<<-c)-1,p>>=-c,c+=u;c>0;o=256*o+t[e+h],h+=l,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=n;c>0;s=256*s+t[e+h],h+=l,c-=8);if(0===o)o=1-f;else{if(o===a)return s?NaN:(p?-1:1)*(1/0);s+=Math.pow(2,n),o-=f}return(p?-1:1)*s*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var s,u,a,f=8*o-i-1,c=(1<<f)-1,h=c>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-s))<1&&(s--,a*=2),e+=s+h>=1?l/a:l*Math.pow(2,1-h),e*a>=2&&(s++,a/=2),s+h>=c?(u=0,s=c):s+h>=1?(u=(e*a-1)*Math.pow(2,i),s+=h):(u=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&u,p+=d,u/=256,i-=8);for(s=s<<i|u,f+=i;f>0;t[r+p]=255&s,p+=d,s/=256,f-=8);t[r+p-d]|=128*g}},{}],6:[function(t,e,r){var n={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],7:[function(t,e,r){"use strict";function n(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}function i(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;var n=Object.getOwnPropertyNames(e).map(function(t){return e[t]});if("0123456789"!==n.join(""))return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach(function(t){i[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},i)).join("")}catch(t){return!1}}var o=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;e.exports=i()?Object.assign:function(t,e){for(var r,i,u=n(t),a=1;a<arguments.length;a++){r=Object(arguments[a]);for(var f in r)o.call(r,f)&&(u[f]=r[f]);if(Object.getOwnPropertySymbols){i=Object.getOwnPropertySymbols(r);for(var c=0;c<i.length;c++)s.call(r,i[c])&&(u[i[c]]=r[i[c]])}}return u}},{}],8:[function(t,e,r){(function(t){function e(t,e){for(var r=0,n=t.length-1;n>=0;n--){var i=t[n];"."===i?t.splice(n,1):".."===i?(t.splice(n,1),r++):r&&(t.splice(n,1),r--)}if(e)for(;r--;r)t.unshift("..");return t}function n(t,e){if(t.filter)return t.filter(e);for(var r=[],n=0;n<t.length;n++)e(t[n],n,t)&&r.push(t[n]);return r}var i=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,o=function(t){return i.exec(t).slice(1)};r.resolve=function(){for(var r="",i=!1,o=arguments.length-1;o>=-1&&!i;o--){var s=o>=0?arguments[o]:t.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(r=s+"/"+r,i="/"===s.charAt(0))}return r=e(n(r.split("/"),function(t){return!!t}),!i).join("/"),(i?"/":"")+r||"."},r.normalize=function(t){var i=r.isAbsolute(t),o="/"===s(t,-1);return t=e(n(t.split("/"),function(t){return!!t}),!i).join("/"),t||i||(t="."),t&&o&&(t+="/"),(i?"/":"")+t},r.isAbsolute=function(t){return"/"===t.charAt(0)},r.join=function(){var t=Array.prototype.slice.call(arguments,0);return r.normalize(n(t,function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))},r.relative=function(t,e){function n(t){for(var e=0;e<t.length&&""===t[e];e++);for(var r=t.length-1;r>=0&&""===t[r];r--); return e>r?[]:t.slice(e,r-e+1)}t=r.resolve(t).substr(1),e=r.resolve(e).substr(1);for(var i=n(t.split("/")),o=n(e.split("/")),s=Math.min(i.length,o.length),u=s,a=0;a<s;a++)if(i[a]!==o[a]){u=a;break}for(var f=[],a=u;a<i.length;a++)f.push("..");return f=f.concat(o.slice(u)),f.join("/")},r.sep="/",r.delimiter=":",r.dirname=function(t){var e=o(t),r=e[0],n=e[1];return r||n?(n&&(n=n.substr(0,n.length-1)),r+n):"."},r.basename=function(t,e){var r=o(t)[2];return e&&r.substr(-1*e.length)===e&&(r=r.substr(0,r.length-e.length)),r},r.extname=function(t){return o(t)[3]};var s="b"==="ab".substr(-1)?function(t,e,r){return t.substr(e,r)}:function(t,e,r){return e<0&&(e=t.length+e),t.substr(e,r)}}).call(this,t("_process"))},{_process:9}],9:[function(t,e,r){function n(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function o(t){if(h===setTimeout)return setTimeout(t,0);if((h===n||!h)&&setTimeout)return h=setTimeout,setTimeout(t,0);try{return h(t,0)}catch(e){try{return h.call(null,t,0)}catch(e){return h.call(this,t,0)}}}function s(t){if(l===clearTimeout)return clearTimeout(t);if((l===i||!l)&&clearTimeout)return l=clearTimeout,clearTimeout(t);try{return l(t)}catch(e){try{return l.call(null,t)}catch(e){return l.call(this,t)}}}function u(){y&&d&&(y=!1,d.length?g=d.concat(g):v=-1,g.length&&a())}function a(){if(!y){var t=o(u);y=!0;for(var e=g.length;e;){for(d=g,g=[];++v<e;)d&&d[v].run();v=-1,e=g.length}d=null,y=!1,s(t)}}function f(t,e){this.fun=t,this.array=e}function c(){}var h,l,p=e.exports={};!function(){try{h="function"==typeof setTimeout?setTimeout:n}catch(t){h=n}try{l="function"==typeof clearTimeout?clearTimeout:i}catch(t){l=i}}();var d,g=[],y=!1,v=-1;p.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];g.push(new f(t,e)),1!==g.length||y||o(a)},f.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=c,p.addListener=c,p.once=c,p.off=c,p.removeListener=c,p.removeAllListeners=c,p.emit=c,p.binding=function(t){throw new Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(t){throw new Error("process.chdir is not supported")},p.umask=function(){return 0}},{}],10:[function(t,e,r){(function(r,n){"use strict";var i=function(t,e,r,i){if(i=i||{},this.dictionary=null,this.rules={},this.dictionaryTable={},this.compoundRules=[],this.compoundRuleCodes={},this.replacementTable=[],this.flags=i.flags||{},t){if(this.dictionary=t,"undefined"!=typeof window&&"chrome"in window&&"extension"in window.chrome&&"getURL"in window.chrome.extension)e||(e=this._readFile(chrome.extension.getURL("lib/typo/dictionaries/"+t+"/"+t+".aff"))),r||(r=this._readFile(chrome.extension.getURL("lib/typo/dictionaries/"+t+"/"+t+".dic")));else{if(i.dictionaryPath)var o=i.dictionaryPath;else if("undefined"!=typeof n)var o=n+"/dictionaries";else var o="./dictionaries";e||(e=this._readFile(o+"/"+t+"/"+t+".aff")),r||(r=this._readFile(o+"/"+t+"/"+t+".dic"))}this.rules=this._parseAFF(e),this.compoundRuleCodes={};for(var s=0,u=this.compoundRules.length;s<u;s++)for(var a=this.compoundRules[s],f=0,c=a.length;f<c;f++)this.compoundRuleCodes[a[f]]=[];"ONLYINCOMPOUND"in this.flags&&(this.compoundRuleCodes[this.flags.ONLYINCOMPOUND]=[]),this.dictionaryTable=this._parseDIC(r);for(var s in this.compoundRuleCodes)0==this.compoundRuleCodes[s].length&&delete this.compoundRuleCodes[s];for(var s=0,u=this.compoundRules.length;s<u;s++){for(var h=this.compoundRules[s],l="",f=0,c=h.length;f<c;f++){var p=h[f];l+=p in this.compoundRuleCodes?"("+this.compoundRuleCodes[p].join("|")+")":p}this.compoundRules[s]=new RegExp(l,"i")}}return this};i.prototype={load:function(t){for(var e in t)this[e]=t[e];return this},_readFile:function(e,n){if(n||(n="utf8"),"undefined"!=typeof XMLHttpRequest){var i=new XMLHttpRequest;return i.open("GET",e,!1),i.overrideMimeType&&i.overrideMimeType("text/plain; charset="+n),i.send(null),i.responseText}if("undefined"!=typeof t){var o=t("fs");try{if(o.existsSync(e)){var s=o.statSync(e),u=o.openSync(e,"r"),a=new r(s.size);return o.readSync(u,a,0,a.length,null),a.toString(n,0,a.length)}console.log("Path "+e+" does not exist.")}catch(t){return console.log(t),""}}},_parseAFF:function(t){var e={};t=this._removeAffixComments(t);for(var r=t.split("\n"),n=0,i=r.length;n<i;n++){var o=r[n],s=o.split(/\s+/),u=s[0];if("PFX"==u||"SFX"==u){for(var a=s[1],f=s[2],c=parseInt(s[3],10),h=[],l=n+1,p=n+1+c;l<p;l++){var o=r[l],d=o.split(/\s+/),g=d[2],y=d[3].split("/"),v=y[0];"0"===v&&(v="");var m=this.parseRuleCodes(y[1]),w=d[4],b={};b.add=v,m.length>0&&(b.continuationClasses=m),"."!==w&&("SFX"===u?b.match=new RegExp(w+"$"):b.match=new RegExp("^"+w)),"0"!=g&&("SFX"===u?b.remove=new RegExp(g+"$"):b.remove=g),h.push(b)}e[a]={type:u,combineable:"Y"==f,entries:h},n+=c}else if("COMPOUNDRULE"===u){for(var c=parseInt(s[1],10),l=n+1,p=n+1+c;l<p;l++){var o=r[l],d=o.split(/\s+/);this.compoundRules.push(d[1])}n+=c}else if("REP"===u){var d=o.split(/\s+/);3===d.length&&this.replacementTable.push([d[1],d[2]])}else this.flags[u]=s[1]}return e},_removeAffixComments:function(t){return t=t.replace(/#.*$/gm,""),t=t.replace(/^\s\s*/m,"").replace(/\s\s*$/m,""),t=t.replace(/\n{2,}/g,"\n"),t=t.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},_parseDIC:function(t){function e(t,e){t in n&&"object"==typeof n[t]||(n[t]=[]),n[t].push(e)}t=this._removeDicComments(t);for(var r=t.split("\n"),n={},i=1,o=r.length;i<o;i++){var s=r[i],u=s.split("/",2),a=u[0];if(u.length>1){var f=this.parseRuleCodes(u[1]);"NEEDAFFIX"in this.flags&&f.indexOf(this.flags.NEEDAFFIX)!=-1||e(a,f);for(var c=0,h=f.length;c<h;c++){var l=f[c],p=this.rules[l];if(p)for(var d=this._applyRule(a,p),g=0,y=d.length;g<y;g++){var v=d[g];if(e(v,[]),p.combineable)for(var m=c+1;m<h;m++){var w=f[m],b=this.rules[w];if(b&&b.combineable&&p.type!=b.type)for(var _=this._applyRule(v,b),E=0,A=_.length;E<A;E++){var R=_[E];e(R,[])}}}l in this.compoundRuleCodes&&this.compoundRuleCodes[l].push(a)}}else e(a.trim(),[])}return n},_removeDicComments:function(t){return t=t.replace(/^\t.*$/gm,"")},parseRuleCodes:function(t){if(!t)return[];if(!("FLAG"in this.flags))return t.split("");if("long"===this.flags.FLAG){for(var e=[],r=0,n=t.length;r<n;r+=2)e.push(t.substr(r,2));return e}return"num"===this.flags.FLAG?textCode.split(","):void 0},_applyRule:function(t,e){for(var r=e.entries,n=[],i=0,o=r.length;i<o;i++){var s=r[i];if(!s.match||t.match(s.match)){var u=t;if(s.remove&&(u=u.replace(s.remove,"")),"SFX"===e.type?u+=s.add:u=s.add+u,n.push(u),"continuationClasses"in s)for(var a=0,f=s.continuationClasses.length;a<f;a++){var c=this.rules[s.continuationClasses[a]];c&&(n=n.concat(this._applyRule(u,c)))}}}return n},check:function(t){var e=t.replace(/^\s\s*/,"").replace(/\s\s*$/,"");if(this.checkExact(e))return!0;if(e.toUpperCase()===e){var r=e[0]+e.substring(1).toLowerCase();if(this.hasFlag(r,"KEEPCASE"))return!1;if(this.checkExact(r))return!0}var n=e.toLowerCase();if(n!==e){if(this.hasFlag(n,"KEEPCASE"))return!1;if(this.checkExact(n))return!0}return!1},checkExact:function(t){var e=this.dictionaryTable[t];if("undefined"==typeof e){if("COMPOUNDMIN"in this.flags&&t.length>=this.flags.COMPOUNDMIN)for(var r=0,n=this.compoundRules.length;r<n;r++)if(t.match(this.compoundRules[r]))return!0;return!1}if("object"==typeof e){for(var r=0,n=e.length;r<n;r++)if(!this.hasFlag(t,"ONLYINCOMPOUND",e[r]))return!0;return!1}},hasFlag:function(t,e,r){if(e in this.flags){if("undefined"==typeof r)var r=Array.prototype.concat.apply([],this.dictionaryTable[t]);if(r&&r.indexOf(this.flags[e])!==-1)return!0}return!1},alphabet:"",suggest:function(t,e){function r(t){for(var e=[],r=0,n=t.length;r<n;r++){for(var i=t[r],o=[],s=0,u=i.length+1;s<u;s++)o.push([i.substring(0,s),i.substring(s,i.length)]);for(var a=[],s=0,u=o.length;s<u;s++){var c=o[s];c[1]&&a.push(c[0]+c[1].substring(1))}for(var h=[],s=0,u=o.length;s<u;s++){var c=o[s];c[1].length>1&&h.push(c[0]+c[1][1]+c[1][0]+c[1].substring(2))}for(var l=[],s=0,u=o.length;s<u;s++){var c=o[s];if(c[1])for(var p=0,d=f.alphabet.length;p<d;p++)l.push(c[0]+f.alphabet[p]+c[1].substring(1))}for(var g=[],s=0,u=o.length;s<u;s++){var c=o[s];if(c[1])for(var p=0,d=f.alphabet.length;p<d;p++)l.push(c[0]+f.alphabet[p]+c[1])}e=e.concat(a),e=e.concat(h),e=e.concat(l),e=e.concat(g)}return e}function n(t){for(var e=[],r=0;r<t.length;r++)f.check(t[r])&&e.push(t[r]);return e}function i(t){function i(t,e){return t[1]<e[1]?-1:1}for(var o=r([t]),s=r(o),u=n(o).concat(n(s)),a={},c=0,h=u.length;c<h;c++)u[c]in a?a[u[c]]+=1:a[u[c]]=1;var l=[];for(var c in a)l.push([c,a[c]]);l.sort(i).reverse();for(var p=[],c=0,h=Math.min(e,l.length);c<h;c++)f.hasFlag(l[c][0],"NOSUGGEST")||p.push(l[c][0]);return p}if(e||(e=5),this.check(t))return[];for(var o=0,s=this.replacementTable.length;o<s;o++){var u=this.replacementTable[o];if(t.indexOf(u[0])!==-1){var a=t.replace(u[0],u[1]);if(this.check(a))return[a]}}var f=this;return f.alphabet="abcdefghijklmnopqrstuvwxyz",i(t)}},"undefined"!=typeof e&&(e.exports=i)}).call(this,t("buffer").Buffer,"/node_modules/typo-js")},{buffer:3,fs:2}],11:[function(t,e,r){"use strict";var n=t("./typo-tools");e.exports=function(t,e,r,i,o,s){if(r===o.gutterClass){window.typoIsSetup||n.setupTypoMenuEnv(t,s,o.gutterMarkClass),window.typoMenuOpen&&window.removeTypoMenu();var u=t.lineInfo(e);if(u.gutterMarkers){var a=n.getTypos(o,u);if(console.log(a),window.typoMenuOpen=!0,a.length>0){var f=document.createElement("div");f.id="typoMenu",f.style.left=i.pageX+"px",f.style.top=i.pageY+"px",f.setAttribute("data-lineN",e),document.body.appendChild(f);var c=document.createElement("div");c.className="typoItemContainer",f.appendChild(c);for(var h=0;h<a.length;h++){var l=a[h],p=document.createElement("div");p.className="typoItem",p.setAttribute("data-word",l),p.addEventListener("mouseenter",window.showSugMenu),p.addEventListener("mouseleave",window.hideSugMenu),p.appendChild(document.createTextNode(l)),c.appendChild(p)}}for(var d=0;d<a.length;d++)n.addSuggestionMenu(t,a[d],s)}}}},{"./typo-tools":13}],12:[function(t,e,r){"use strict";function n(t,e,r){if(!(!t|!e)){var n={dictPath:"dictionary/"+e,dictFolder:"",filename:e,affFile:"",dicFile:"",typoClass:"typo",typoCSS:"background: rgba(255,0,0,.25)",excludeClasses:["url","comment","tag","word"],gutterClass:"typoFlags",gutterMarkClass:"typoMark"};"string"==typeof r?n.dictPath=r:"object"==typeof r&&(n=o(n,r));var f,c=i.join(n.dictPath,n.dictFolder,"/"),h=n.affFile?n.affFile:n.filename,l=n.dicFile?n.dicFile:n.filename,p=[c+h+".aff",c+l+".dic"];Promise.all(p.map(u.get)).then(function(r){f=new s(e,r[0],r[1],{platform:"any"});var i=' `~!@#$%^&*()-_=+[]{}\\|;:"<>,./?©';try{t.addOverlay({token:function(t){var e=t.peek(),r="";if(i.indexOf(e)>=0)return t.next(),null;for(;(e=t.peek())&&i.indexOf(e)<0;)r+=e,t.next();return f.check(r)?void 0:n.typoClass}})}catch(t){console.error(t)}}),u.insertCSS(n);var d=function(t){var e=document.createElement("i");return e.className=t.gutterMarkClass,e.innerHTML="🐌",e},g=function(t){if("string"==typeof t&&t.indexOf(n.typoClass)>=0){for(var e=0;e<n.excludeClasses.length;e++)if(t.indexOf(n.excludeClasses[e])>=0)return!1;return!0}return!1},y=function(t,e){if(e.styles){var r=e.styles.filter(g);r.length>0?t.setGutterMarker(e,n.gutterClass,d(n)):t.setGutterMarker(e,n.gutterClass,null)}else t.setGutterMarker(e,n.gutterClass,null)},v=function(t){try{t.eachLine(function(e){return y(t,e)})}catch(t){console.log(t)}};t.setOption("gutters",t.getOption("gutters").concat(n.gutterClass)),t.refresh(),t.on("cursorActivity",function(t){return v(t)}),t.on("gutterClick",function(t,e,r,i){return a(t,e,r,i,n,f)})}}var i=t("path"),o=t("object-assign"),s=t("typo-js"),u=t("./typo-tools"),a=t("./gutter-menu");e.exports=n},{"./gutter-menu":11,"./typo-tools":13,"object-assign":7,path:8,"typo-js":10}],13:[function(t,e,r){"use strict";var n=t("es6-promise");e.exports={get:function(t){return new n(function(e,r){var n=new XMLHttpRequest;n.open("GET",t),n.onload=function(){200===n.status?e(n.response):r(Error(n.statusText))},n.onerror=function(){r(Error("Network Error"))},n.send()})},insertCSS:function(t){var e=document.createElement("style");e.type="text/css";for(var r=".CodeMirror .cm-"+t.typoClass,n=0;n<t.excludeClasses.length;n++)r+=":not(.cm-"+t.excludeClasses[n]+")";var i=r+" {"+t.typoCSS+"}",o=[" ."+t.gutterClass+" {","width: 20px;","white-space: nowrap;","-moz-box-sizing: content-box;","box-sizing: content-box;","}"," ."+t.gutterMarkClass+" {","width: 20px;","color: #551A8B;","transition: all 0.2s;","}"," ."+t.gutterMarkClass+":hover {","cursor: pointer;","color: #885EAD","}"].join("");i+=o,e.appendChild(document.createTextNode(i)),document.head.appendChild(e)},getTypos:function(t,e){var r=[],n=e.handle.styles,i=-1,o=function(e){if(i++,"string"==typeof e&&e.indexOf(t.typoClass)>=0){for(var n=0;n<t.excludeClasses.length;n++)if(e.indexOf(t.excludeClasses[n])>=0)return;r.push(i)}};n.map(o);for(var s=[],u=0;u<r.length;u++){var a;a=r[u]-3<=0?n[r[u]-1]:n[r[u]-1]-n[r[u]-3];var f=e.text.substr(n[r[u]-3],a);s.push(f)}return s},setupTypoMenuEnv:function(t,e,r){window.typoIsSetup=!0,window.removeTypoMenu=function(){var t=document.getElementById("typoMenu");document.body.removeChild(t),window.typoMenuOpen=!1},document.addEventListener("mousedown",function(t){var e=t.target.className.indexOf("typoItem")>=0||t.target.className.indexOf(r)>=0||t.target.className.indexOf("typoSugItem")>=0;!e&&window.typoMenuOpen&&window.removeTypoMenu()}),window.showSugMenu=function(t){var e=t.target.getAttribute("data-word"),r=document.querySelector(".typoSugMenu[data-word = "+e+"]");r.style.display="inline-block"},window.hideSugMenu=function(t){var e=t.target.getAttribute("data-word"),r=document.querySelector(".typoSugMenu[data-word = "+e+"]");r.style.display="none"},window.replaceTypo=function(e){var r=e.target.innerHTML,n=e.target.parentElement,i=n.getAttribute("data-word"),o=n.parentElement.getAttribute("data-linen"),s=t.getLine(o).indexOf(i),u=s+i.length;t.replaceRange(r,{line:o,ch:s},{line:o,ch:u}),window.removeTypoMenu()}},addSuggestionMenu:function(t,e,r){var i=document.getElementById("typoMenu"),o=document.createElement("div");i.appendChild(o),o.className="typoSugMenu",o.setAttribute("data-word",e),n.resolve(r.suggest(e)).then(function(t){0===t.length?o.innerHTML="No suggestions found.":t.map(function(t){var e=document.createElement("div");return e.className="typoSugItem",e.appendChild(document.createTextNode(t)),e.onclick=window.replaceTypo,o.appendChild(e)})})}}},{"es6-promise":4}]},{},[12])(12)}); //# sourceMappingURL=../lib/src/index.js.map