!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.Tesseract=n():e.Tesseract=n()}(window,function(){return function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=2)}([function(e,n,t){var r;!function(o){"use strict";var s,i,u,a,c,f,l,p,h,d,b,y,g;function m(e){return null!=e}function v(e){return"number"==typeof e&&e>d&&en}function _(e,n){return v(e)&&e=n}function O(e,n){return v(e)&&e<=n}function E(e){return"string"==typeof e}function x(e){return E(e)&&""!==e}function P(e){return"[object Object]"===Object.prototype.toString.call(e)}function S(e,n){try{return e instanceof n}catch(e){return!1}}function q(e,n){var t;for(t in n)if(n.hasOwnProperty(t)){if(!1===e.hasOwnProperty(t)||typeof e[t]!=typeof n[t])return!1;if(P(e[t])&&!1===q(e[t],n[t]))return!1}return!0}function I(e){return y(e)}function T(e){return m(e)&&k(e.length,0)}function A(e){return"function"==typeof e}function J(e,n){var t;for(t=0;tt}},{n:"greaterOrEqual",f:k},{n:"lessOrEqual",f:O},{n:"inRange",f:function(e,n,t){if(n=t}},{n:"positive",f:function(e){return j(e,0)}},{n:"negative",f:function(e){return _(e,0)}},{n:"string",f:E,s:"s"},{n:"emptyString",f:function(e){return""===e},s:"s"},{n:"nonEmptyString",f:x,s:"s"},{n:"contains",f:function(e,n){return E(e)&&-1!==e.indexOf(n)},s:"s"},{n:"match",f:function(e,n){return E(e)&&!!e.match(n)},s:"s"},{n:"boolean",f:function(e){return!1===e||!0===e},s:"b"},{n:"object",f:P,s:"o"},{n:"emptyObject",f:function(e){return P(e)&&0===Object.keys(e).length},s:"o"},{n:"nonEmptyObject",f:function(e){return P(e)&&Object.keys(e).length>0},s:"o"},{n:"instanceStrict",f:S,s:"t"},{n:"instance",f:function(e,n){try{return S(e,n)||e.constructor.name===n.name||Object.prototype.toString.call(e)==="[object "+n.name+"]"}catch(e){return!1}},s:"t"},{n:"like",f:q,s:"t"},{n:"array",f:I,s:"a"},{n:"emptyArray",f:function(e){return I(e)&&0===e.length},s:"a"},{n:"nonEmptyArray",f:function(e){return I(e)&&j(e.length,0)},s:"a"},{n:"arrayLike",f:T,s:"al"},{n:"iterable",f:function(e){if(!g)return T(e);return m(e)&&A(e[Symbol.iterator])},s:"i"},{n:"date",f:function(e){return S(e,Date)&&w(e.getTime())},s:"d"},{n:"function",f:A,s:"f"},{n:"hasLength",f:function(e,n){return m(e)&&e.length===n},s:"l"}].map(function(e){var n=e.n;i[n]="Invalid "+s[e.s||"n"],u[n]=e.f}),a={apply:function(e,n){if(c.array(e),A(n))return e.map(function(e){return n(e)});return c.array(n),c.hasLength(e,n.length),e.map(function(e,t){return n[t](e)})},map:function(e,n){if(c.object(e),A(n))return function(e,n){var t={};return Object.keys(e).forEach(function(r){t[r]=n(e[r])}),t}(e,n);return c.object(n),function e(n,t){var r={};return Object.keys(t).forEach(function(o){var s=t[o];A(s)?f.assigned(n)?r[o]=!!s.m:r[o]=s(n[o]):P(s)&&(r[o]=e(n[o],s))}),r}(e,n)},all:function(e){if(I(e))return J(e,!1);return c.object(e),M(e,!1)},any:function(e){if(I(e))return J(e,!0);return c.object(e),M(e,!0)}},p=["array","arrayLike","iterable","object"],h=Array.prototype.slice,d=Number.NEGATIVE_INFINITY,b=Number.POSITIVE_INFINITY,y=Array.isArray,g="function"==typeof Symbol,a=N(a,u),c=U(W,L),f=U(B,R),l=U(function(e){var n=function(){return!!f.assigned(arguments[0])||e.apply(null,arguments)};return n.l=e.length,n.m=!0,n},function(e){if(!1===m(e))return!0;return e}),c.not=F(W,f),c.maybe=F(W,l),p.forEach(function(e){u[e].of=z([$.bind(null,null),u[e],u,null])}),C(c,W),C(f,B),p.forEach(function(e){l[e].of=z([$.bind(null,"maybe"),u[e],u,null]),c.maybe[e].of=F(W,l[e].of),c.not[e].of=F(W,f[e].of)}),function(o){void 0===(r=function(){return o}.call(n,t,n,e))||(e.exports=r)}(N(a,{assert:c,not:f,maybe:l}))}()},function(e,n,t){const r=t(0),o=t(3),{defaultOptions:s}=t(4),{version:i}=t(5);n.defaultOptions={...s,workerPath:`https://cdn.jsdelivr.net/gh/naptha/tesseract.js@v${i}/dist/worker.min.js`,corePath:`https://cdn.jsdelivr.net/gh/naptha/tesseract.js-core@v2.0.0-beta.5/tesseract-core${"object"==typeof WebAssembly?"":".asm"}.js`},n.spawnWorker=((e,n)=>{let t;if(window.Blob&&window.URL){const e=new Blob([`importScripts("${n.workerPath}");`]);t=new Worker(window.URL.createObjectURL(e))}else t=new Worker(n.workerPath);return t.onmessage=(({data:n})=>{e._recv(n)}),t}),n.terminateWorker=(e=>{e.worker.terminate()}),n.sendPacket=((e,n)=>{(e=>r.string(e)?fetch(o(e)).then(e=>e.arrayBuffer()):r.instance(e,File)?new Promise(n=>{const t=new FileReader;t.onload=(()=>{n(t.result)}),t.readAsArrayBuffer(e)}):Promise.reject())(n.payload.image).then(e=>new Uint8Array(e)).then(t=>{e.worker.postMessage({...n,payload:{...n.payload,image:Array.from(t)}})})})},function(e,n,t){const r=t(0),o=t(1),s=t(6),i=t(7);e.exports={TesseractWorker:class{constructor(e={}){this.worker=null,this.workerOptions=Object.assign({},o.defaultOptions,e),this._currentJob=null,this._queue=[]}recognize(e,n={lang:"eng"}){return this._delay(t=>{t._send("recognize",{image:e,options:r.string(n)?{lang:n||"eng"}:n,workerOptions:this.workerOptions})})}detect(e,n={}){return this._delay(t=>{t._send("detect",{image:e,options:n,workerOptions:this.workerOptions})})}terminate(){this.worker&&o.terminateWorker(this),this.worker=null,this._currentJob=null,this._queue=[]}_delay(e){r.null(this.worker)&&(this.worker=o.spawnWorker(this,this.workerOptions));const n=new i(this);return this._queue.push(()=>{this._queue.shift(),this._currentJob=n,e(n)}),r.null(this._currentJob)&&this._dequeue(),n}_dequeue(){this._currentJob=null,this._queue.length&&this._queue[0]()}_recv(e){this._currentJob.id===e.jobId?this._currentJob._handle({...e,data:"resolve"===e.status&&"recognize"===e.action?s(e.data):e.data}):console.warn(`Job ID ${e.jobId} not known.`)}}}},function(e,n,t){var r,o;void 0===(o="function"==typeof(r=function(){return function(){var e=arguments.length;if(0===e)throw new Error("resolveUrl requires at least one argument; got none.");var n=document.createElement("base");if(n.href=arguments[0],1===e)return n.href;var t=document.getElementsByTagName("head")[0];t.insertBefore(n,t.firstChild);for(var r,o=document.createElement("a"),s=1;s{const n={...e,paragraphs:[],lines:[],words:[],symbols:[]};return n.blocks.forEach(e=>{const t={...e,page:n,lines:[],words:[],symbols:[]};t.paragraphs.forEach(e=>{const r={...e,block:t,page:n,words:[],symbols:[]};r.lines.forEach(e=>{const o={...e,paragraph:r,block:t,page:n,symbols:[]};o.words.forEach(e=>{const s={...e,line:o,paragraph:r,block:t,page:n};s.symbols.forEach(e=>{const i={...e,word:s,line:o,paragraph:r,block:t,page:n};i.line.symbols.push(i),i.paragraph.symbols.push(i),i.block.symbols.push(i),i.page.symbols.push(i)}),s.paragraph.words.push(s),s.block.words.push(s),s.page.words.push(s)}),o.block.lines.push(o),o.page.lines.push(o)}),r.page.paragraphs.push(r)})}),n})},function(e,n,t){const r=t(1);let o=0;e.exports=class{constructor(e){o+=1,this.id=`Job-${o}-${Math.random().toString(16).slice(3,8)}`,this._instance=e,this._resolve=[],this._reject=[],this._progress=[],this._finally=[]}then(e,n){return this._resolve.push?this._resolve.push(e):e(this._resolve),n&&this.catch(n),this}catch(e){return this._reject.push?this._reject.push(e):e(this._reject),this}progress(e){return this._progress.push(e),this}finally(e){return this._finally.push(e),this}_send(e,n){r.sendPacket(this._instance,{jobId:this.id,action:e,payload:n})}_handle(e){const{data:n}=e;let t=!1;"resolve"===e.status?(0===this._resolve.length&&console.log(n),this._resolve.forEach(e=>{const t=e(n);t&&"function"==typeof t.then&&console.warn("TesseractJob instances do not chain like ES6 Promises. To convert it into a real promise, use Promise.resolve.")}),this._resolve=n,this._instance._dequeue(),t=!0):"reject"===e.status?(0===this._reject.length&&console.error(n),this._reject.forEach(e=>e(n)),this._reject=n,this._instance._dequeue(),t=!0):"progress"===e.status?this._progress.forEach(e=>e(n)):console.warn("Message type unknown",e.status),t&&this._finally.forEach(e=>e(n))}}}])}); //# sourceMappingURL=tesseract.min.js.map