-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathimage-decoder-framework.dev.js
More file actions
6 lines (6 loc) · 118 KB
/
image-decoder-framework.dev.js
File metadata and controls
6 lines (6 loc) · 118 KB
1
2
3
4
5
6
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.resourceScheduler=e()}}(function(){return function e(t,r,o){function i(s,u){if(!r[s]){if(!t[s]){var d="function"==typeof require&&require;if(!u&&d)return d(s,!0);if(n)return n(s,!0);var h=new Error("Cannot find module '"+s+"'");throw h.code="MODULE_NOT_FOUND",h}var l=r[s]={exports:{}};t[s][0].call(l.exports,function(e){var r=t[s][1][e];return i(r?r:e)},l,l.exports,e,t,r,o)}return r[s].exports}for(var n="function"==typeof require&&require,s=0;s<o.length;s++)i(o[s]);return i}({1:[function(e,t,r){"use strict";var o=function(){function e(e,t){this._resourceCreator=e,this._jobsLimit=t,this._freeResourcesCount=this._jobsLimit,this._freeResources=new Array(this._jobsLimit),this._pendingJobs=[]}function t(e,t){this._scheduler=e,this._resource=t}return e.prototype.enqueueJob=function(e,t){if(this._freeResourcesCount>0){--this._freeResourcesCount;var r=this._freeResources.pop();void 0===r&&(r=this._resourceCreator()),this._schedule(e,r,t)}else this._pendingJobs.push({jobFunc:e,jobContext:t})},e.prototype.shouldAbort=function(e){return!1},e.prototype._schedule=function(e,r,o){var i=new t(this,r);e(r,o,i)},t.prototype.jobDone=function(){if(this._scheduler._pendingJobs.length>0){var e=this._scheduler._pendingJobs.pop();this._scheduler._schedule(e.jobFunc,this._resource,e.jobContext)}else this._scheduler._freeResources.push(this._resource),++this._scheduler._freeResourcesCount},t.prototype.shouldYieldOrAbort=function(){return!1},t.prototype.tryYield=function(){return!1},e}();t.exports=o},{}],2:[function(e,t,r){"use strict";var o=function(){function e(){this.clear()}return e.prototype.clear=function(){this._first={_prev:null,_parent:this},this._last={_next:null,_parent:this},this._count=0,this._last._prev=this._first,this._first._next=this._last},e.prototype.add=function(e,t){null!==t&&void 0!==t||(t=this._last),this._validateIteratorOfThis(t),++this._count;var r={_value:e,_next:t,_prev:t._prev,_parent:this};return r._prev._next=r,t._prev=r,r},e.prototype.remove=function(e){this._validateIteratorOfThis(e),--this._count,e._prev._next=e._next,e._next._prev=e._prev,e._parent=null},e.prototype.getFromIterator=function(e){return this._validateIteratorOfThis(e),e._value},e.prototype.getFirstIterator=function(){var e=this.getNextIterator(this._first);return e},e.prototype.getLastIterator=function(){var e=this.getPrevIterator(this._last);return e},e.prototype.getNextIterator=function(e){return this._validateIteratorOfThis(e),e._next===this._last?null:e._next},e.prototype.getPrevIterator=function(e){return this._validateIteratorOfThis(e),e._prev===this._first?null:e._prev},e.prototype.getCount=function(){return this._count},e.prototype._validateIteratorOfThis=function(e){if(e._parent!==this)throw"iterator must be of the current LinkedList"},e}();t.exports=o},{}],3:[function(e,t,r){"use strict";var o=e("linked-list"),i=function(){function e(e,t,r,i){i=i||{},this._resourceCreator=e,this._jobsLimit=t,this._prioritizer=r,this._showLog=i.showLog,this._schedulerName=i.schedulerName,this._numNewJobs=i.numNewJobs||20,this._numJobsBeforeRerankOldPriorities=i.numJobsBeforeRerankOldPriorities||20,this._freeResourcesCount=this._jobsLimit,this._freeResources=new Array(this._jobsLimit),this._resourcesGuaranteedForHighPriority=i.resourcesGuaranteedForHighPriority||0,this._highPriorityToGuaranteeResource=i.highPriorityToGuaranteeResource||0,this._logCallIndentPrefix=">",this._pendingJobsCount=0,this._oldPendingJobsByPriority=[],this._newPendingJobsLinkedList=new o,this._schedulesCounter=0}function t(e,t,r){if(e._showLog){var o=e._prioritizer.getPriority(r);y(e,"jobDone() start: job done of priority "+o,1)}_(e,t),g(e),y(e,"jobDone() end",-1)}function r(e,t){y(e,"shouldYieldOrAbort() start",1);var r=e._prioritizer.getPriority(t),o=r<0||n(e,r);return y(e,"shouldYieldOrAbort() end",-1),o}function i(e,t,r,o,i,n){y(e,"tryYield() start",1);var u=e._prioritizer.getPriority(r);if(u<0)return o(r),_(e,n),y(e,"tryYield() end: job aborted",-1),!0;var h=s(e,u);if(g(e),null===h)return y(e,"tryYield() end: job continues",-1),!1;i(r);var l={jobFunc:t,jobAbortedFunc:o,jobContext:r};return d(e,l,u),g(e),a(e,h,n),g(e),y(e,"tryYield() end: job yielded",-1),!0}function n(e,t){var r=e._newPendingJobsLinkedList.getFirstIterator();for(y(e,"hasNewJobWithHigherPriority() start",1);null!==r;){var o=e._newPendingJobsLinkedList.getNextIterator(r),i=e._newPendingJobsLinkedList.getFromIterator(r),n=e._prioritizer.getPriority(i.jobContext);if(n<0)f(e,r),--e._pendingJobsCount,i.jobAbortedFunc(i.jobContext),r=o;else{if(n>t)return y(e,"hasNewJobWithHigherPriority() end: returns true",-1),!0;r=o}}return y(e,"hasNewJobWithHigherPriority() end: returns false",-1),!1}function s(e,t){y(e,"tryDequeueNewJobWithHigherPriority() start",1);for(var r=null,o=t,i=[],n=e._newPendingJobsLinkedList.getFirstIterator();null!==n;){var s=e._newPendingJobsLinkedList.getNextIterator(n),u=e._newPendingJobsLinkedList.getFromIterator(n),d=e._prioritizer.getPriority(u.jobContext);d<0?(f(e,n),--e._pendingJobsCount,u.jobAbortedFunc(u.jobContext),n=s):((void 0===o||d>o)&&(o=d,r=n),e._showLog?(void 0===i[d]?i[d]=1:++i[d],n=s):n=s)}var h=null;if(null!==r&&(h=f(e,r),--e._pendingJobsCount),e._showLog){for(var l="tryDequeueNewJobWithHigherPriority(): Jobs list:",_=0;_<i.length;++_)void 0!==i[_]&&(l+=i[_]+" jobs of priority "+_+";");y(e,l),null!==h&&y(e,"tryDequeueNewJobWithHigherPriority(): dequeued new job of priority "+o)}return g(e),y(e,"tryDequeueNewJobWithHigherPriority() end",-1),h}function u(e){if(y(e,"tryGetFreeResource() start",1),0===e._freeResourcesCount)return null;--e._freeResourcesCount;var t=e._freeResources.pop();return void 0===t&&(t=e._resourceCreator()),g(e),y(e,"tryGetFreeResource() end",-1),t}function d(e,t,r){y(e,"enqueueNewJob() start",1),++e._pendingJobsCount;var o=e._newPendingJobsLinkedList.getFirstIterator();if(c(e,t,o),e._showLog&&y(e,"enqueueNewJob(): enqueued job of priority "+r),e._newPendingJobsLinkedList.getCount()<=e._numNewJobs)return g(e),void y(e,"enqueueNewJob() end: _newPendingJobsLinkedList is small enough",-1);var i=e._newPendingJobsLinkedList.getLastIterator(),n=f(e,i);h(e,n),g(e),y(e,"enqueueNewJob() end: One job moved from new job list to old job list",-1)}function h(e,t){y(e,"enqueueOldJob() start",1);var r=e._prioritizer.getPriority(t.jobContext);return r<0?(--e._pendingJobsCount,t.jobAbortedFunc(t.jobContext),void y(e,"enqueueOldJob() end: job aborted",-1)):(void 0===e._oldPendingJobsByPriority[r]&&(e._oldPendingJobsByPriority[r]=[]),e._oldPendingJobsByPriority[r].push(t),void y(e,"enqueueOldJob() end: job enqueued to old job list",-1))}function l(e){y(e,"rerankPriorities() start",1);var t=e._oldPendingJobsByPriority,r=e._newPendingJobsLinkedList;if(0===t.length)return void y(e,"rerankPriorities() end: no need to rerank",-1);e._oldPendingJobsByPriority=[],e._newPendingJobsLinkedList=new o;for(var i=0;i<t.length;++i)if(void 0!==t[i])for(var n=0;n<t[i].length;++n)h(e,t[i][n]);for(var s=r.getFirstIterator();null!==s;){var u=r.getFromIterator(s);h(e,u),s=r.getNextIterator(s)}for(var d="rerankPriorities(): ",l=e._oldPendingJobsByPriority.length-1;l>=0;--l){var _=e._oldPendingJobsByPriority[l];if(void 0!==_){for(e._showLog&&(d+=_.length+" jobs in priority "+l+";");_.length>0&&e._newPendingJobsLinkedList.getCount()<e._numNewJobs;){var a=_.pop();c(e,a)}if(e._newPendingJobsLinkedList.getCount()>=e._numNewJobs&&!e._showLog)break}}e._showLog&&y(e,d),g(e),y(e,"rerankPriorities() end: rerank done",-1)}function _(e,t){y(e,"resourceFreed() start",1),++e._freeResourcesCount;var r=p(e);--e._freeResourcesCount;var o=s(e,r-1);if(null!==o)return g(e),a(e,o,t),g(e),void y(e,"resourceFreed() end: new job scheduled",-1);var i=e._pendingJobsCount>e._newPendingJobsLinkedList.getCount();if(!i)return e._freeResources.push(t),++e._freeResourcesCount,g(e),void y(e,"resourceFreed() end: no job to schedule",-1);for(var n,u=e._oldPendingJobsByPriority.length,d=u-1;d>=0;--d){var h=e._oldPendingJobsByPriority[d];if(void 0!==h&&0!==h.length){for(var l=h.length-1;l>=0;--l){if(o=h[l],n=e._prioritizer.getPriority(o.jobContext),n>=d){h.length=l;break}n<0?(--e._pendingJobsCount,o.jobAbortedFunc(o.jobContext)):(void 0===e._oldPendingJobsByPriority[n]&&(e._oldPendingJobsByPriority[n]=[]),e._oldPendingJobsByPriority[n].push(o)),o=null}if(null!==o)break;h.length=0}}return null===o?(e._freeResources.push(t),++e._freeResourcesCount,g(e),void y(e,"resourceFreed() end: no non-aborted job to schedule",-1)):(e._showLog&&y(e,"resourceFreed(): dequeued old job of priority "+n),--e._pendingJobsCount,g(e),a(e,o,t),g(e),void y(e,"resourceFreed() end: job scheduled",-1))}function a(e,t,r){if(y(e,"schedule() start",1),++e._schedulesCounter,e._schedulesCounter>=e._numJobsBeforeRerankOldPriorities&&(e._schedulesCounter=0,l(e)),e._showLog){var o=e._prioritizer.getPriority(t.jobContext);y(e,"schedule(): scheduled job of priority "+o)}var i=new v(e,r,t.jobContext);t.jobFunc(r,t.jobContext,i),y(e,"schedule() end",-1)}function c(e,t,r){y(e,"addJobToLinkedList() start",1),e._newPendingJobsLinkedList.add(t,r),b(e),y(e,"addJobToLinkedList() end",-1)}function f(e,t){y(e,"extractJobFromLinkedList() start",1);var r=e._newPendingJobsLinkedList.getFromIterator(t);return e._newPendingJobsLinkedList.remove(t),b(e),y(e,"extractJobFromLinkedList() end",-1),r}function b(e){if(e._showLog){y(e,"ensureNumberOfNodes() start",1);for(var t=e._newPendingJobsLinkedList.getFirstIterator(),r=0;null!==t;)++r,t=e._newPendingJobsLinkedList.getNextIterator(t);if(r!==e._newPendingJobsLinkedList.getCount())throw"Unexpected count of new jobs";y(e,"ensureNumberOfNodes() end",-1)}}function g(e){if(e._showLog){y(e,"ensurePendingJobsCount() start",1);for(var t=0,r=0;r<e._oldPendingJobsByPriority.length;++r){var o=e._oldPendingJobsByPriority[r];void 0!==o&&(t+=o.length)}var i=t+e._newPendingJobsLinkedList.getCount();if(i!==e._pendingJobsCount)throw"Unexpected count of jobs";y(e,"ensurePendingJobsCount() end",-1)}}function p(e){return y(e,"getMinimalPriorityToSchedule() start",1),e._freeResourcesCount<=e._resourcesGuaranteedForHighPriority?(y(e,"getMinimalPriorityToSchedule() end: guarantee resource for high priority is needed",-1),e._highPriorityToGuaranteeResources):(y(e,"getMinimalPriorityToSchedule() end: enough resources, no need to guarantee resource for high priority",-1),0)}function y(e,t,r){e._showLog&&(r===-1&&(e._logCallIndentPrefix=e._logCallIndentPrefix.substr(1)),void 0!==e._schedulerName?console.log(e._logCallIndentPrefix+"PriorityScheduler "+e._schedulerName+": "+t):console.log(e._logCallIndentPrefix+"PriorityScheduler: "+t),1===r&&(e._logCallIndentPrefix+=">"))}function v(e,t,r){this._isValid=!0,this._scheduler=e,this._resource=t,this._context=r}return e.prototype.enqueueJob=function(e,t,r){y(this,"enqueueJob() start",1);var o=this._prioritizer.getPriority(t);if(o<0)return r(t),void y(this,"enqueueJob() end: job aborted",-1);var i={jobFunc:e,jobAbortedFunc:r,jobContext:t},n=p(this),s=null;return o>=n&&(s=u(this)),null!==s?(a(this,i,s),void y(this,"enqueueJob() end: job scheduled",-1)):(d(this,i,o),g(this),void y(this,"enqueueJob() end: job pending",-1))},e.prototype.shouldAbort=function(e){y(this,"enqueueJob() start",1);var t=this._prioritizer.getPriority(e);return y(this,"enqueueJob() end",-1),t<0},v.prototype._checkValidity=function(){if(!this._isValid)throw"ResourceScheduler error: Already terminated job"},v.prototype._clearValidity=function(){this._isValid=!1,this._resource=null,this._context=null,this._scheduler=null},v.prototype.jobDone=function(){this._checkValidity(),t(this._scheduler,this._resource,this._context),this._clearValidity()},v.prototype.shouldYieldOrAbort=function(){return this._checkValidity(),r(this._scheduler,this._context)},v.prototype.tryYield=function(e,t,r){this._checkValidity();var o=i(this._scheduler,e,this._context,t,r,this._resource);return o&&this._clearValidity(),o},e}();t.exports=i},{"linked-list":2}],4:[function(e,t,r){"use strict";t.exports.PriorityScheduler=e("priority-scheduler"),t.exports.LifoScheduler=e("lifo-scheduler")},{"lifo-scheduler":1,"priority-scheduler":3}]},{},[4])(4)});
!function(r){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.asyncProxy=r()}}(function(){return function r(e,t,a){function o(s,i){if(!t[s]){if(!e[s]){var l="function"==typeof require&&require;if(!i&&l)return l(s,!0);if(n)return n(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var u=t[s]={exports:{}};e[s][0].call(u.exports,function(r){var t=e[s][1][r];return o(t?t:r)},u,u.exports,r,e,t,a)}return t[s].exports}for(var n="function"==typeof require&&require,s=0;s<a.length;s++)o(a[s]);return o}({1:[function(r,e,t){"use strict";e.exports.SubWorkerEmulationForChrome=r("sub-worker-emulation-for-chrome"),e.exports.AsyncProxyFactory=r("async-proxy-factory"),e.exports.AsyncProxySlave=r("async-proxy-slave"),e.exports.AsyncProxyMaster=r("async-proxy-master"),e.exports.ScriptsToImportPool=r("scripts-to-Import-Pool")},{"async-proxy-factory":2,"async-proxy-master":3,"async-proxy-slave":4,"scripts-to-Import-Pool":5,"sub-worker-emulation-for-chrome":7}],2:[function(r,e,t){"use strict";var a=r("async-proxy-master"),o=function(){function r(r,t,a){a[0]||{};r.prototype[t]=function(){for(var r=e.getWorkerHelper(this),o=[],n=0;n<arguments.length;++n){var s=a[n+1],i=arguments[n];if("callback"===s)o[n]=r.wrapCallback(i);else{if(s)throw"AsyncProxyFactory error: Unrecognized argument description "+s+" in argument "+(n+1)+" of method "+t;o[n]=i}}return r.callFunction(t,o,a[0])}}var e={};return e.create=function(r,t,a,o){if(!r||!r.length)throw"AsyncProxyFactory error: missing scriptsToImport (2nd argument)";var n=o||function(){var a=e.convertArgs(arguments);e.initialize(this,r,t,a)};return a&&e.addMethods(n,a),n},e.addMethods=function(e,t){for(var a in t)r(e,a,t[a]||[]);return e},e.initialize=function(r,e,t,a){if(r.__workerHelperInitArgs)throw"asyncProxy error: Double initialization of AsyncProxy master";r.__workerHelperInitArgs={scriptsToImport:e,ctorName:t,ctorArgs:a}},e.convertArgs=function(r){for(var e=new Array(r.length),t=0;t<r.length;++t)e[t]=r[t];return e},e.getWorkerHelper=function(r){if(!r.__workerHelper){if(!r.__workerHelperInitArgs)throw"asyncProxy error: asyncProxyFactory.initialize() not called yet";r.__workerHelper=new a(r.__workerHelperInitArgs.scriptsToImport,r.__workerHelperInitArgs.ctorName,r.__workerHelperInitArgs.ctorArgs||[])}return r.__workerHelper},e}();e.exports=o},{"async-proxy-master":3}],3:[function(r,e,t){"use strict";var a=r("scripts-to-import-pool"),o=function(){function r(a,n,s,i){function l(r){o(u,r)}var u=this;i=i||{},u._callbacks=[],u._pendingPromiseCalls=[],u._subWorkerById=[],u._subWorkers=[],u._userDataHandler=null,u._notReturnedFunctions=0,u._functionsBufferSize=i.functionsBufferSize||5,u._pendingMessages=[];var p=e(),f=t.toString();f=f.replace("SCRIPT_PLACEHOLDER",p);var d=new Blob(["(",f,")()"],{type:"application/javascript"}),y=URL.createObjectURL(d);u._worker=new Worker(y),u._worker.onmessage=l,u._worker.postMessage({functionToCall:"ctor",scriptsToImport:a,ctorName:n,args:s,callId:++c,isPromise:!1,masterEntryUrl:r.getEntryUrl()})}function e(){var r=new Error;return a._getScriptName(r)}function t(){importScripts("SCRIPT_PLACEHOLDER"),asyncProxy.AsyncProxySlave._initializeSlave()}function o(r,e){var t=e.data.callId;switch(e.data.type){case"functionCalled":--r._notReturnedFunctions,i(r);break;case"promiseResult":var a=r._pendingPromiseCalls[t];delete r._pendingPromiseCalls[t];var o=e.data.result;a.resolve(o);break;case"promiseFailure":var s=r._pendingPromiseCalls[t];delete r._pendingPromiseCalls[t];var l=e.data.reason;s.reject(l);break;case"userData":null!==r._userDataHandler&&r._userDataHandler(e.data.userData);break;case"callback":var c=r._callbacks[e.data.callId];if(void 0===c)throw"Unexpected message from SlaveWorker of callback ID: "+e.data.callId+". Maybe should indicate isMultipleTimesCallback = true on creation?";c.isMultipleTimeCallback||r.freeCallback(r._callbacks[e.data.callId]),null!==c.callback&&c.callback.apply(null,e.data.args);break;case"subWorkerCtor":var u=new Worker(e.data.scriptUrl),p=e.data.subWorkerId;r._subWorkerById[p]=u,r._subWorkers.push(u),u.onmessage=function(e){n(r,e.ports,!1,{functionToCall:"subWorkerOnMessage",subWorkerId:p,data:e.data})};break;case"subWorkerPostMessage":var f=r._subWorkerById[e.data.subWorkerId];f.postMessage(e.data.data);break;case"subWorkerTerminate":var d=r._subWorkerById[e.data.subWorkerId];d.terminate();break;default:throw"Unknown message from AsyncProxySlave of type: "+e.data.type}}function n(r,e,t,a){return r._notReturnedFunctions>=r._functionsBufferSize?void r._pendingMessages.push({transferables:e,isFunctionCall:t,message:a}):void s(r,e,t,a)}function s(r,e,t,a){t&&++r._notReturnedFunctions,r._worker.postMessage(a,e)}function i(r){for(;r._notReturnedFunctions<r._functionsBufferSize&&r._pendingMessages.length>0;){var e=r._pendingMessages.shift();s(r,e.transferables,e.isFunctionCall,e.message)}}function l(){var r=location.href,e=r.lastIndexOf("/");return e>=0&&(r=r.substring(0,e)),r}var c=0,u=!1,p=l();return r.prototype.setUserDataHandler=function(r){this._userDataHandler=r},r.prototype.terminate=function(){this._worker.terminate();for(var r=0;r<this._subWorkers.length;++r)this._subWorkers[r].terminate()},r.prototype.callFunction=function(e,t,a){a=a||{};var o=!!a.isReturnPromise,i=a.transferables||[],l=a.pathsToTransferablesInPromiseResult,u=++c,p=null,f=this;o&&(p=new Promise(function(r,e){f._pendingPromiseCalls[u]={resolve:r,reject:e}}));var d,y=a.isSendImmediately?s:n;if(d="function"==typeof i?i():r._extractTransferables(i,t),y(this,d,!0,{functionToCall:e,args:t||[],callId:u,isPromise:o,pathsToTransferablesInPromiseResult:l}),o)return p},r.prototype.wrapCallback=function(r,e,t){t=t||{};var a=++c,o={isWorkerHelperCallback:!0,isMultipleTimeCallback:!!t.isMultipleTimeCallback,callId:a,callbackName:e,pathsToTransferables:t.pathsToTransferables},n={isMultipleTimeCallback:!!t.isMultipleTimeCallback,callId:a,callback:r,pathsToTransferables:t.pathsToTransferables};return this._callbacks[a]=n,o},r.prototype.freeCallback=function(r){delete this._callbacks[r.callId]},r.getEntryUrl=function(){return u=!0,p},r._setEntryUrl=function(r){if(p!==r&&u)throw"Previous values returned from getMasterEntryUrl is wrong. Avoid calling it within the slave c`tor";p=r},r._extractTransferables=function(r,e){if(void 0!==r){for(var t=new Array(r.length),a=0;a<r.length;++a){for(var o=r[a],n=e,s=0;s<o.length;++s){var i=o[s];n=n[i]}t[a]=n}return t}},r}();e.exports=o},{"scripts-to-import-pool":6}],4:[function(r,e,t){"use strict";var a=r("async-proxy-master"),o=r("sub-worker-emulation-for-chrome"),n=function(){function r(r){var e=r.data.functionToCall,t=r.data.args,o=r.data.callId,l=r.data.isPromise,p=r.data.pathsToTransferablesInPromiseResult,f=null;switch(e){case"ctor":a._setEntryUrl(r.data.masterEntryUrl);var d=r.data.scriptsToImport;s=r.data.ctorName;for(var y=0;y<d.length;++y)importScripts(d[y]);return void(n=c.apply(null,t));case"subWorkerOnMessage":var m=u[r.data.subWorkerId],k={data:r.data.data};return void m.onmessage(k)}t=new Array(r.data.args.length);for(var b=0;b<r.data.args.length;++b){var v=r.data.args[b];void 0!==v&&null!==v&&v.isWorkerHelperCallback&&(v=i.wrapCallbackFromSlaveSide(v)),t[b]=v}for(var g,_=n;_&&!(g=n[e]);)_=_.__proto__;if(!g)throw"AsyncProxy error: could not find function "+e;var h=g.apply(n,t);l&&i.wrapPromiseFromSlaveSide(o,h,p),self.postMessage({type:"functionCalled",callId:r.data.callId,result:f})}function e(){var r;try{for(var e=s.split("."),a=self,o=0;o<e.length;++o)a=a[e[o]];var n=a,i=[null].concat(t(arguments));r=new(Function.prototype.bind.apply(n,i))}catch(l){throw new Error("Failed locating class name "+s+": "+l)}return r}function t(r){for(var e=new Array(r.length),t=0;t<r.length;++t)e[t]=r[t];return e}var n,s,i={},l=null,c=e,u={};return i._initializeSlave=function(){self.onmessage=r},i.setSlaveSideCreator=function(r){c=r},i.setBeforeOperationListener=function(r){l=r},i.sendUserDataToMaster=function(r){self.postMessage({type:"userData",userData:r})},i.wrapPromiseFromSlaveSide=function(r,e,t){var o=e.then(function(e){var o=a._extractTransferables(t,e);self.postMessage({type:"promiseResult",callId:r,result:e},o)});o["catch"](function(e){self.postMessage({type:"promiseFailure",callId:r,reason:e})})},i.wrapCallbackFromSlaveSide=function(r){function e(){if(o)throw"Callback is called twice but isMultipleTimeCallback = false";var e=t(arguments);if(null!==l)try{l.call(n,"callback",r.callbackName,e)}catch(s){console.log("AsyncProxySlave.beforeOperationListener has thrown an exception: "+s)}var i=a._extractTransferables(r.pathsToTransferables,e);self.postMessage({type:"callback",callId:r.callId,args:e},i),r.isMultipleTimeCallback||(o=!0)}var o=!1;return e},void 0===self.Worker&&(o.initialize(u),self.Worker=o),i}();e.exports=n},{"async-proxy-master":3,"sub-worker-emulation-for-chrome":7}],5:[function(r,e,t){"use strict";var a=function(){function r(){var r=this;r._scriptsByName={},r._scriptsArray=null}var e=/at (|[^ ]+ \()([^ ]+):\d+:\d+/,t=new RegExp(/.+@(.*?):\d+:\d+/),a=new RegExp(/.+\/(.*?):\d+(:\d+)*$/);return r.prototype.addScriptFromErrorWithStackTrace=function(e){var t=r._getScriptName(e);this._scriptsByName[t]||(this._scriptsByName[t]=!0,this._scriptsArray=null)},r.prototype.getScriptsForWorkerImport=function(){if(null===this._scriptsArray){this._scriptsArray=[];for(var r in this._scriptsByName)this._scriptsArray.push(r)}return this._scriptsArray},r._getScriptName=function(r){var o=r.stack.trim(),n=e.exec(o);if(n&&""!==n[2])return n[2];if(n=t.exec(o),n&&""!==n[1])return n[1];if(n=a.exec(o),n&&""!==n[1])return n[1];if(void 0!==r.fileName)return r.fileName;throw"async-proxy.js: Could not get current script URL"},r}();e.exports=a},{}],6:[function(r,e,t){arguments[4][5][0].apply(t,arguments)},{dup:5}],7:[function(r,e,t){"use strict";var a=function(){function r(r){if(null===t)throw"AsyncProxy internal error: SubWorkerEmulationForChrome not initialized";var a=this;a._subWorkerId=++e,t[a._subWorkerId]=a,self.postMessage({type:"subWorkerCtor",subWorkerId:a._subWorkerId,scriptUrl:r})}var e=0,t=null;return r.initialize=function(r){t=r},r.prototype.postMessage=function(r,e){self.postMessage({type:"subWorkerPostMessage",subWorkerId:this._subWorkerId,data:r},e)},r.prototype.terminate=function(r,e){self.postMessage({type:"subWorkerTerminate",subWorkerId:this._subWorkerId},e)},r}();e.exports=a},{}]},{},[1])(1)});
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.dependencyWorkers=e()}}(function(){return function e(t,r,n){function i(a,o){if(!r[a]){if(!t[a]){var d="function"==typeof require&&require;if(!o&&d)return d(a,!0);if(s)return s(a,!0);var p=new Error("Cannot find module '"+a+"'");throw p.code="MODULE_NOT_FOUND",p}var l=r[a]={exports:{}};t[a][0].call(l.exports,function(e){var r=t[a][1][e];return i(r?r:e)},l,l.exports,e,t,r,n)}return r[a].exports}for(var s="function"==typeof require&&require,a=0;a<n.length;a++)i(n[a]);return i}({1:[function(e,t,r){"use strict";t.exports.DependencyWorkers=e("dependency-workers"),t.exports.DependencyWorkersTaskContext=e("dependency-workers-task-context"),t.exports.DependencyWorkersTask=e("dependency-workers-task"),t.exports.WrapperInputRetreiverBase=e("wrapper-input-retreiver-base"),t.exports.SchedulerDependencyWorkers=e("scheduler-dependency-workers"),t.exports.DependencyWorkersTaskScheduler=e("dependency-workers-task-scheduler")},{"dependency-workers":6,"dependency-workers-task":5,"dependency-workers-task-context":2,"dependency-workers-task-scheduler":4,"scheduler-dependency-workers":10,"wrapper-input-retreiver-base":11}],2:[function(e,t,r){"use strict";var n=function(){function e(e,t){this._taskInternals=e,this._callbacks=t,this._taskContextsIterator=e.taskContexts.add(this),t.priorityCalculator?this._priorityCalculatorIterator=this._taskInternals.priorityCalculators.add(t):this._priorityCalculatorIterator=null}return Object.defineProperty(e.prototype,"isActive",{get:function(){return this._taskInternals.isActualTerminationPending||!this._taskInternals.isTerminated}}),Object.defineProperty(e.prototype,"isTerminated",{get:function(){return this._taskInternals.isTerminated}}),e.prototype.getProcessedData=function(){return this._taskInternals.processedData},e.prototype.unregister=function(){if(!this._taskContextsIterator)throw"dependencyWorkers: Already unregistered";null!==this._priorityCalculatorIterator&&(this._taskInternals.priorityCalculators.remove(this._priorityCalculatorIterator),this._priorityCalculatorIterator=null),this._taskInternals.taskContexts.remove(this._taskContextsIterator),this._taskContextsIterator=null,this._taskInternals.isTerminated||(0===this._taskInternals.taskContexts.getCount()?this._taskInternals.abort(!1):this._taskInternals.statusUpdate())},e}();t.exports=n},{}],3:[function(e,t,r){"use strict";var n=e("linked-list"),i=e("js-builtin-hash-map"),s=e("dependency-workers-task"),a=function(){function e(){this.isTerminated=!1,this.isActualTerminationPending=!1,this.processedData=[],this.taskApi=null,this.pendingDataForWorker=[],this.canSkipLastPendingDataForWorker=!1,this.taskContexts=new n,this.priorityCalculators=new n,this.taskKey=null,this._dependsTasksTerminatedCount=0,this._parentDependencyWorkers=null,this._workerInputRetreiver=null,this._parentList=null,this._parentIterator=null,this._dependsTaskContexts=null,this._priorityCalculator=null,this._isDetached=!1,this._canSkipLastProcessedData=!1,this._jobCallbacks=null,this._isAborted=!1,this._isAbortedNotByScheduler=!1,this._isUserCalledTerminate=!1,this._isWaitingForWorkerResult=!1,this._dependTaskKeys=[],this._dependTaskResults=[],this._hasDependTaskData=[],this._shouldDelayActions=!0,this._pendingDelayedAction=!1,this._pendingDelayedDependencyData=[],this._pendingDelayedEnded=!1,this._pendingDelayedNewData=[],this._pendingDelayedCanSkipLastNewData=!1,this._pendingWorkerDone=!1,this._pendingDelayedDependsTaskTerminated=0;var e=this;this._priorityCalculator=function(){return e.calculatePriority()},this._scheduleNotifier={calculatePriority:this._priorityCalculator,schedule:function(t){if(null!==e._jobCallbacks)throw"dependencyWorkers: scheduleNotifier.schedule was called twice";if(!t||!t.jobDone)throw"dependencyWorkers: Passed invalid jobCallbacks argument to scheduleNotifier.schedule(). Ensure jobCallbacks has jobDone method";if(e._isAbortedNotByScheduler)return void t.jobDone();if(this.isTerminated&&!this.isActualTerminationPending)throw"dependencyWorkers: scheduled after termination";var r=e.pendingDataForWorker.shift(),n=!1;0===e.pendingDataForWorker.length&&(n=e.canSkipLastPendingDataForWorker,e.canSkipLastPendingDataForWorker=!1),e._jobCallbacks=t,e._parentDependencyWorkers._dataReady(e,r.data,r.workerType,n)},abort:function(t){e.abort(t)}}}return e.prototype.initialize=function(e,t,r,n,a){this.taskKey=e,this._parentDependencyWorkers=t,this._workerInputRetreiver=r,this._parentList=n,this._parentIterator=a,this._dependsTaskContexts=new i,this.taskApi=new s(this,e),t.initializingTask(this.taskApi,this._scheduleNotifier)},e.prototype.afterTaskStarted=function(){this._shouldDelayActions=!1,this._performPendingDelayedActions()},e.prototype.ended=function(){this._pendingDelayedEnded=!0,this._schedulePendingDelayedActions()},e.prototype.statusUpdate=function(){var e={hasListeners:this.taskContexts.getCount()>0,isWaitingForWorkerResult:this._isWaitingForWorkerResult,terminatedDependsTasks:this._dependsTasksTerminatedCount,dependsTasks:this._dependsTaskContexts.getCount()};this.taskApi._onEvent("statusUpdated",e),this.isActualTerminationPending&&!this._isWaitingForWorkerResult&&(this.isActualTerminationPending=!1,this.ended())},e.prototype.calculatePriority=function(){for(var e=this.priorityCalculators.getFirstIterator(),t=!0,r=0;null!==e;){var n=this.priorityCalculators.getFromIterator(e),i=n.priorityCalculator();(t||i>r)&&(r=i,t=!1),e=this.priorityCalculators.getNextIterator(e)}return r},e.prototype.newData=function(e,t){this._pendingDelayedCanSkipLastNewData?this._pendingDelayedNewData[this._pendingDelayedNewData.length-1]=e:this._pendingDelayedNewData.push(e),this._pendingDelayedCanSkipLastNewData=!!t,this._schedulePendingDelayedActions()},e.prototype.workerDone=function(){if(null===this._jobCallbacks)throw"dependencyWorkers: Job done without previously started";var e=this._jobCallbacks;this._jobCallbacks=null,0===this.pendingDataForWorker.length&&(this._pendingWorkerDone=!0,this._schedulePendingDelayedActions()),e.jobDone(),this.pendingDataForWorker.length>0&&this.waitForSchedule()},e.prototype.dataReady=function(e,t,r){if(this.isTerminated){if(this._isUserCalledTerminate)throw"dependencyWorkers: already terminated"}else{var n={data:e,workerType:t};this.canSkipLastPendingDataForWorker?this.pendingDataForWorker[this.pendingDataForWorker.length-1]=n:this.pendingDataForWorker.push(n),this.canSkipLastPendingDataForWorker=!!r,this._isWaitingForWorkerResult&&!this._pendingWorkerDone||(this._isWaitingForWorkerResult=!0,this._pendingWorkerDone=!1,this.waitForSchedule(),this.statusUpdate())}},e.prototype.waitForSchedule=function(){var e=this.pendingDataForWorker[0].workerType;this._parentDependencyWorkers.waitForSchedule(this._scheduleNotifier,e)},e.prototype.detachBeforeTermination=function(){if(!this._isDetached){this._isDetached=!0,this._parentList.remove(this._parentIterator),this._parentIterator=null;for(var e=this._dependsTaskContexts.getFirstIterator();null!==e;){var t=this._dependsTaskContexts.getFromIterator(e).taskContext;e=this._dependsTaskContexts.getNextIterator(e),t.unregister()}this._dependsTaskContexts.clear()}},e.prototype.customEvent=function(e,t){if(this.isTerminated&&!this.isActualTerminationPending)throw"dependencyWorkers: already terminated";this._iterateCallbacks(function(r){r.onCustom&&r.onCustom(e,t)}),this.taskApi._onEvent("custom",e,t)},e.prototype.terminate=function(){if(this._isUserCalledTerminate)throw"dependencyWorkers: already terminated";this._isUserCalledTerminate=!0,this._terminateInternal()},e.prototype.abort=function(e){if(!this._isAborted){if(this._isAborted=!0,this.isTerminated){if(!this.isActualTerminationPending&&!this._isAbortedNotByScheduler)throw"dependencyWorkers: aborted after termination"}else if(e){if(0===this.pendingDataForWorker.length)throw"dependencyWorkers: Abort without task waiting for schedule";this._isWaitingForWorkerResult=!1}else this._isAbortedNotByScheduler=!0;this.pendingDataForWorker=[],this.canSkipLastPendingDataForWorker=!1,this.isTerminated||this.customEvent("aborting",this.taskKey),this._terminateInternal()}},Object.defineProperty(e.prototype,"dependTaskKeys",{get:function(){return this._dependTaskKeys}}),Object.defineProperty(e.prototype,"dependTaskResults",{get:function(){return this._dependTaskResults}}),e.prototype.registerTaskDependency=function(e){function t(r){return o=!0,a._pendingDelayedDependencyData.length>0?(a._pendingDelayedDependencyData.push({data:r,onDependencyTaskData:t}),void a._schedulePendingDelayedActions()):(a._dependTaskResults[p]=r,a._hasDependTaskData[p]=!0,void a.taskApi._onEvent("dependencyTaskData",r,e))}function r(e,t){a.taskApi._onEvent("dependencyTaskCustom",e,t)}function n(){if(d)throw"dependencyWorkers: Double termination";d=!0,++a._pendingDelayedDependsTaskTerminated,a._schedulePendingDelayedActions()}var i=this._workerInputRetreiver.getKeyAsString(e),s=this._dependsTaskContexts.tryAdd(i,function(){return{taskContext:null}});if(!s.isNew)throw"dependencyWorkers: Cannot add task dependency twice";var a=this,o=!1,d=!1,p=this._dependTaskKeys.length;if(this._dependTaskKeys[p]=e,s.value.taskContext=this._parentDependencyWorkers.startTask(e,{onData:t,onTerminated:n,onCustom:r,priorityCalculator:this._priorityCalculator,calleeForDebug:this}),!s.value.taskContext.isActive&&!o)throw"dependency-workers error: dependant task already terminated without data";if(s.value.taskContext._taskInternals._isAborted)throw"dependencyWorkers error: dependant task already aborted";for(var l=s.value.taskContext.getProcessedData(),h=0;h<l.length;++h)this._pendingDelayedDependencyData.push({data:l[h],onDependencyTaskData:t});return l.length>0&&this._schedulePendingDelayedActions(),s.value.taskContext},e.prototype._terminateInternal=function(){this.isTerminated||(this.detachBeforeTermination(),this.isTerminated=!0,this._isWaitingForWorkerResult?this.isActualTerminationPending=!0:this.ended())},e.prototype._schedulePendingDelayedActions=function(){this._pendingDelayedAction=!0,this._shouldDelayActions||this._performPendingDelayedActions()},e.prototype._performPendingDelayedActions=function(){if(this._pendingDelayedAction){var e=this;if(this._pendingDelayedAction=!1,this._pendingDelayedDependencyData.length>0){var t=this._pendingDelayedDependencyData;this._pendingDelayedDependencyData=[];for(var r=0;r<t.length;++r)t[r].onDependencyTaskData(t[r].data)}if(this._pendingDelayedDependsTaskTerminated>0&&(this._dependsTasksTerminatedCount+=this._pendingDelayedDependsTaskTerminated,this._pendingDelayedDependsTaskTerminated=0,this._dependsTasksTerminatedCount===this._dependsTaskContexts.getCount()&&this.taskApi._onEvent("allDependTasksTerminated"),this.statusUpdate()),this._pendingDelayedNewData.length>0){var n=this._pendingDelayedNewData,i=this._pendingDelayedCanSkipLastNewData;this._pendingDelayedNewData=[],this._pendingDelayedCanSkipLastNewData=!1,this._canSkipLastProcessedData&&this.processedData.pop();for(var r=0;r<n.length;++r)this.processedData.push(n[r]),this._canSkipLastProcessedData=i&&r===n.length-1,this._iterateCallbacks(function(t){t.onData(n[r],e.taskKey)})}this._pendingWorkerDone&&(this._isWaitingForWorkerResult=!1,this.statusUpdate()),this._pendingDelayedEnded&&(this._pendingDelayedEnded=!1,this._iterateCallbacks(function(t){t.onTerminated&&t.onTerminated(e._isAborted)}),this.taskContexts.clear())}},e.prototype._iterateCallbacks=function(e){for(var t=this.taskContexts.getFirstIterator();null!==t;){var r=this.taskContexts.getFromIterator(t);t=this.taskContexts.getNextIterator(t),e(r._callbacks)}},e}();t.exports=a},{"dependency-workers-task":5,"js-builtin-hash-map":8,"linked-list":9}],4:[function(e,t,r){"use strict";function n(){return{}}function i(e,t){resourceScheduler.PriorityScheduler.call(this,n,e,s,t)}var s={getPriority:function(e){return e.calculatePriority()}};i.prototype=Object.create(resourceScheduler.PriorityScheduler.prototype),t.exports=i},{}],5:[function(e,t,r){"use strict";var n=function(){function e(e,t,r){if(this._wrapped=e,e.__wrappingTaskForDebug=this,this._key=t,this._eventListeners={dependencyTaskData:[],statusUpdated:[],allDependTasksTerminated:[],custom:[],dependencyTaskCustom:[]},r)for(var n in this._eventListeners)this._registerWrappedEvent(n)}return Object.defineProperty(e.prototype,"isTerminated",{get:function(){return this._wrapped.isTerminated}}),e.prototype.dataReady=function(e,t,r){this._wrapped.dataReady(e,t,r)},e.prototype.detachBeforeTermination=function(){this._wrapped.detachBeforeTermination()},e.prototype.terminate=function(){this._wrapped.terminate()},e.prototype.registerTaskDependency=function(e){return this._wrapped.registerTaskDependency(e)},e.prototype.calculatePriority=function(){return this._wrapped.calculatePriority()},e.prototype.customEvent=function(e,t){return this._wrapped.customEvent(e,t)},e.prototype.on=function(e,t){if(!this._eventListeners[e])throw"dependencyWorkers: Task has no event "+e;this._eventListeners[e].push(t)},Object.defineProperty(e.prototype,"key",{get:function(){return this._key}}),Object.defineProperty(e.prototype,"dependTaskKeys",{get:function(){return this._wrapped.dependTaskKeys}}),Object.defineProperty(e.prototype,"dependTaskResults",{get:function(){return this._wrapped.dependTaskResults}}),e.prototype._onEvent=function(e,t,r){"statusUpdated"==e&&(t=this._modifyStatus(t));for(var n=this._eventListeners[e],i=0;i<n.length;++i)n[i].call(this,t,r)},e.prototype._modifyStatus=function(e){return e},e.prototype._registerWrappedEvent=function(e){var t=this;this._wrapped.on(e,function(r,n){t._onEvent(e,r,n)})},e}();t.exports=n},{}],6:[function(e,t,r){"use strict";var n=e("js-builtin-hash-map"),i=e("dependency-workers-task-internals"),s=e("dependency-workers-task-context"),a=function(){function e(e){var t=this;if(t._workerInputRetreiver=e,t._taskInternalss=new n,t._workerPoolByTaskType=[],t._taskOptionsByTaskType=[],!e.getWorkerTypeOptions)throw"dependencyWorkers: No workerInputRetreiver.getWorkerTypeOptions() method";if(!e.getKeyAsString)throw"dependencyWorkers: No workerInputRetreiver.getKeyAsString() method"}return e.prototype.startTask=function(e,t){var r=this._workerInputRetreiver.getKeyAsString(e),n=this._taskInternalss.tryAdd(r,function(){return new i}),a=n.value,o=new s(a,t);return n.isNew&&(a.initialize(e,this,this._workerInputRetreiver,this._taskInternalss,n.iterator,this._workerInputRetreiver),this._workerInputRetreiver.taskStarted(a.taskApi),a.afterTaskStarted()),o},e.prototype.startTaskPromise=function(e){var t=this;return new Promise(function(r,n){function i(e){p=!0,a=e}function s(e){e?n("Task is aborted"):p?r(a):n("Task terminated but no data returned")}var a,o=t.startTask(e,{onData:i,onTerminated:s}),d=o.getProcessedData(),p=d.length>0;p&&(a=d[d.length-1])})},e.prototype.terminateInactiveWorkers=function(){for(var e in this._workerPoolByTaskType){for(var t=this._workerPoolByTaskType[e],r=0;r<t.length;++r)t[r].proxy.terminate();t.length=0}},e.prototype._dataReady=function(e,t,r,n){var i,s=this,a=s._workerPoolByTaskType[r];if(a||(a=[],s._workerPoolByTaskType[r]=a),a.length>0)i=a.pop();else{var o=s._workerInputRetreiver.getWorkerTypeOptions(r);if(!o)return e.newData(t),void e.workerDone();i={proxy:new asyncProxy.AsyncProxyMaster(o.scriptsToImport,o.ctorName,o.ctorArgs),transferables:o.transferables,pathToTransferablesInPromiseResult:o.pathToTransferablesInPromiseResult}}var d=[t,e.taskKey],p={isReturnPromise:!0,transferables:i.transferables,pathToTransferablesInPromiseResult:i.pathToTransferablesInPromiseResult},l=i.proxy.callFunction("start",d,p);l.then(function(t){return e.newData(t,n),t})["catch"](function(e){return console.log("Error in DependencyWorkers' worker: "+e),e}).then(function(t){a.push(i),e.workerDone()})},e.prototype.waitForSchedule=function(e){e.schedule({jobDone:function(){}})},e.prototype.initializingTask=function(e){},e}();t.exports=a},{"dependency-workers-task-context":2,"dependency-workers-task-internals":3,"js-builtin-hash-map":8}],7:[function(e,t,r){"use strict";var n=e("linked-list"),i=function(){function e(e){var t=this;t._hasher=e,t.clear()}return e.prototype.clear=function(){this._listByKey=[],this._listOfLists=new n,this._count=0},e.prototype.getFromKey=function(e){var t=this._hasher.getHashCode(e),r=this._listByKey[t];if(!r)return null;for(var n=r.list,i=n.getFirstIterator();null!==i;){var s=n.getFromIterator(i);if(this._hasher.isEqual(s.key,e))return s.value;i=n.getNextIterator(i)}return null},e.prototype.getFromIterator=function(e){return e._hashElements.list.getFromIterator(e._internalIterator).value},e.prototype.tryAdd=function(e,t){var r=this._hasher.getHashCode(e),i=this._listByKey[r];i||(i={hashCode:r,list:new n,listOfListsIterator:null},i.listOfListsIterator=this._listOfLists.add(i),this._listByKey[r]=i);var s={_hashElements:i,_internalIterator:null};for(s._internalIterator=i.list.getFirstIterator();null!==s._internalIterator;){var a=i.list.getFromIterator(s._internalIterator);if(this._hasher.isEqual(a.key,e))return{iterator:s,isNew:!1,value:a.value};s._internalIterator=i.list.getNextIterator(s._internalIterator)}var o=t();return s._internalIterator=i.list.add({key:e,value:o}),++this._count,{iterator:s,isNew:!0,value:o}},e.prototype.remove=function(e){var t=e._hashElements.list.getCount();e._hashElements.list.remove(e._internalIterator);var r=e._hashElements.list.getCount();this._count+=r-t,0===r&&(this._listOfLists.remove(e._hashElements.listOfListsIterator),delete this._listByKey[e._hashElements.hashCode])},e.prototype.getCount=function(){return this._count},e.prototype.getFirstIterator=function(){var e=this._listOfLists.getFirstIterator(),t=null,r=null;return null!==e&&(t=this._listOfLists.getFromIterator(e),r=t.list.getFirstIterator()),null===r?null:{_hashElements:t,_internalIterator:r}},e.prototype.getNextIterator=function(e){for(var t={_hashElements:e._hashElements,_internalIterator:e._hashElements.list.getNextIterator(e._internalIterator)};null===t._internalIterator;){var r=this._listOfLists.getNextIterator(e._hashElements.listOfListsIterator);if(null===r)return null;t._hashElements=this._listOfLists.getFromIterator(r),t._internalIterator=t._hashElements.list.getFirstIterator()}return t},e}();t.exports=i},{"linked-list":9}],8:[function(e,t,r){"use strict";var n=e("hash-map"),i=function(){function e(){n.call(this,t)}var t={getHashCode:function(e){return e},isEqual:function(e,t){return e===t}};return e.prototype=Object.create(n.prototype),e}();t.exports=i},{"hash-map":7}],9:[function(e,t,r){"use strict";var n=function(){function e(){this.clear()}return e.prototype.clear=function(){this._first={_prev:null,_parent:this},this._last={_next:null,_parent:this},this._count=0,this._last._prev=this._first,this._first._next=this._last},e.prototype.add=function(e,t){null!==t&&void 0!==t||(t=this._last),this._validateIteratorOfThis(t),++this._count;var r={_value:e,_next:t,_prev:t._prev,_parent:this};return r._prev._next=r,t._prev=r,r},e.prototype.remove=function(e){this._validateIteratorOfThis(e),--this._count,e._prev._next=e._next,e._next._prev=e._prev,e._parent=null},e.prototype.getFromIterator=function(e){return this._validateIteratorOfThis(e),e._value},e.prototype.getFirstIterator=function(){var e=this.getNextIterator(this._first);return e},e.prototype.getLastIterator=function(){var e=this.getPrevIterator(this._last);return e},e.prototype.getNextIterator=function(e){return this._validateIteratorOfThis(e),e._next===this._last?null:e._next},e.prototype.getPrevIterator=function(e){return this._validateIteratorOfThis(e),e._prev===this._first?null:e._prev},e.prototype.getCount=function(){return this._count},e.prototype._validateIteratorOfThis=function(e){if(e._parent!==this)throw"iterator must be of the current LinkedList"},e}();t.exports=n},{}],10:[function(e,t,r){"use strict";var n=e("dependency-workers"),i=function(){function e(e,t){var r=this;n.call(this,t),r._scheduler=e,r._isDisableWorkerCache=[],r._inputRetreiver=t}return e.prototype=Object.create(n.prototype),e.prototype.initializingTask=function(e,t){var r=this;e.on("dependencyTaskCustom",function(e,n){if("aborting"===e){if(!r._scheduler.shouldAbort(t))throw"Task "+n+" aborted but a task depends on it didn't. Check scheduler consistency";t.abort(!1)}})},e.prototype.waitForSchedule=function(e,t){if(void 0===this._isDisableWorkerCache[t]&&(this._isDisableWorkerCache[t]=null===this._inputRetreiver.getWorkerTypeOptions(t)),this._isDisableWorkerCache[t])return void n.prototype.waitForSchedule.call(this,e);var r=!1,i=null;this._scheduler.enqueueJob(function(t,n,s){if(n!==e)throw"dependencyWorkers: Wrong jobContext - seems internal error in resource-scheduler.js";if(r)throw"dependencyWorkers: scheduled after finish";if(null!==i)throw"dependencyWorkers: Scheduled twice";i=s,e.schedule(i)},e,function(){if(r)throw"dependencyWorkers: abort after finish";if(null!==i)throw"dependencyWorkers: abort after scheduled";i=null,r=!0,e.abort(!0)})},e}();t.exports=i},{"dependency-workers":6}],11:[function(e,t,r){"use strict";var n=function(){function e(e){if(!e.getKeyAsString)throw"dependencyWorkers: No inputRetreiver.getKeyAsString() method";if(!e.getWorkerTypeOptions)throw"dependencyWorkers: No inputRetreiver.getTaskTypeOptions() method";var t=this;t._inputRetreiver=e}return e.prototype.taskStarted=function(e){throw"dependencyWorkers: Not implemented taskStarted()"},e.prototype.getKeyAsString=function(e){return this._inputRetreiver.getKeyAsString(e)},e.prototype.getWorkerTypeOptions=function(e){return this._inputRetreiver.getWorkerTypeOptions(e)},e}();t.exports=n},{}]},{},[1])(1)});
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.imageDecoderFramework=e()}}(function(){return function e(t,i,r){function a(o,n){if(!i[o]){if(!t[o]){var h="function"==typeof require&&require;if(!n&&h)return h(o,!0);if(s)return s(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=i[o]={exports:{}};t[o][0].call(c.exports,function(e){var i=t[o][1][e];return a(i?i:e)},c,c.exports,e,t,i,r)}return i[o].exports}for(var s="function"==typeof require&&require,o=0;o<r.length;o++)a(r[o]);return a}({1:[function(e,t,i){"use strict";function r(e,t){if(void 0===t&&(t={}),void 0===e)throw new DeveloperError("canvas is required.");this._canvas=e,this._errorEvent=new Event("CanvasImageryProviderStatus"),this._ready=!1;var i=t.credit;"string"==typeof i&&(i=new Credit(i)),this._credit=i}t.exports=r,r.prototype={get tileWidth(){if(!this._ready)throw new DeveloperError("tileWidth must not be called before the imagery provider is ready.");return this._canvas.width},get tileHeight(){if(!this._ready)throw new DeveloperError("tileHeight must not be called before the imagery provider is ready.");return this._canvas.height},get maximumLevel(){if(!this._ready)throw new DeveloperError("maximumLevel must not be called before the imagery provider is ready.");return 0},get minimumLevel(){if(!this._ready)throw new DeveloperError("minimumLevel must not be called before the imagery provider is ready.");return 0},get tilingScheme(){if(!this._ready)throw new DeveloperError("tilingScheme must not be called before the imagery provider is ready.");return this._tilingScheme},get rectangle(){return this._tilingScheme.rectangle},get tileDiscardPolicy(){if(!this._ready)throw new DeveloperError("tileDiscardPolicy must not be called before the imagery provider is ready.")},get errorEvent(){return this._errorEvent},get ready(){return this._ready},get credit(){return this._credit},get hasAlphaChannel(){return!0}},r.prototype.setRectangle=function(e){this._tilingScheme=new Cesium.GeographicTilingScheme({rectangle:e,numberOfLevelZeroTilesX:1,numberOfLevelZeroTilesY:1}),this._ready||(this._ready=!0,Cesium.TileProviderError.handleSuccess(this._errorEvent))},r.prototype.getTileWidth=function(){return this.tileWidth},r.prototype.getTileHeight=function(){return this.tileHeight},r.prototype.getMaximumLevel=function(){return this.maximumLevel},r.prototype.getMinimumLevel=function(){return this.minimumLevel},r.prototype.isReady=function(){return this.ready},r.prototype.getCredit=function(){return this.credit},r.prototype.getRectangle=function(){return this.tilingScheme.rectangle},r.prototype.getTilingScheme=function(){return this.tilingScheme},r.prototype.getTileDiscardPolicy=function(){return this.tileDiscardPolicy},r.prototype.getErrorEvent=function(){return this.errorEvent},r.prototype.getHasAlphaChannel=function(){return this.hasAlphaChannel},r.prototype.getTileCredits=function(e,t,i){},r.prototype.requestImage=function(e,t,i){if(!this._ready)throw new DeveloperError("requestImage must not be called before the imagery provider is ready.");return this._canvas},r.prototype.pickFeatures=function(){}},{}],2:[function(e,t,i){"use strict";function r(e){var t={x:e.scene.canvas.width,y:e.scene.canvas.height},i=[];a(0,0,t.x,t.y,i,e,0);var r=Cesium.Rectangle.fromCartographicArray(i);(r.east<r.west||r.north<r.south)&&(r={east:Math.max(r.east,r.west),west:Math.min(r.east,r.west),north:Math.max(r.north,r.south),south:Math.min(r.north,r.south)});var s=o.calculateFrustum2DFromBounds(r,t);return s}function a(e,t,i,r,o,h,l){var c=0;c+=s(e,t,h,o),c+=s(i,t,h,o),c+=s(e,r,h,o),c+=s(i,r,h,o);var u=n;if(!(4===c||l>=u)){++l;var d=(e+i)/2,m=(t+r)/2;a(e,t,d,m,o,h,l),a(e,m,d,r,o,h,l),a(d,t,i,m,o,h,l),a(d,m,i,r,o,h,l)}}function s(e,t,i,r){var a=new Cesium.Cartesian2(e,t),s=i.scene.mapProjection.ellipsoid,o=i.scene.camera.pickEllipsoid(a,s);if(void 0===o)return 0;var n=s.cartesianToCartographic(o);return void 0===n?0:(r.push(n),1)}t.exports=r;var o=e("image-helper-functions.js"),n=4},{"image-helper-functions.js":13}],3:[function(e,t,i){"use strict";function r(e,t){this._options=t||{},void 0!==this._options.rectangle&&(this._options=JSON.parse(JSON.stringify(t)),this._options.cartographicBounds={west:t.rectangle.west,east:t.rectangle.east,south:t.rectangle.south,north:t.rectangle.north}),this._options.minFunctionCallIntervalMilliseconds=t.minFunctionCallIntervalMilliseconds||100,this._openArg=t.openArg,this._targetCanvas=document.createElement("canvas"),this._imageryProviders=[new a(this._targetCanvas),new a(this._targetCanvas)],this._imageryLayerShown=new Cesium.ImageryLayer(this._imageryProviders[0]),this._imageryLayerPending=new Cesium.ImageryLayer(this._imageryProviders[1]),this._canvasUpdatedCallbackBound=this._canvasUpdatedCallback.bind(this),this._isPendingUpdateCallback=!1,this._isWhileReplaceLayerShown=!1,this._pendingPositionRectangle=null,this._imageViewer=new s(e,this._canvasUpdatedCallbackBound,this._options),this._imageViewer.setTargetCanvas(this._targetCanvas),this._updateFrustumBound=this._updateFrustum.bind(this),this._postRenderBound=this._postRender.bind(this)}t.exports=r;var a=e("canvas-imagery-provider.js"),s=e("image-decoder-viewer.js"),o=e("cesium-frustum-calculator.js");r.prototype.setExceptionCallback=function(e){this._imageViewer.setExceptionCallback(e)},r.prototype.open=function(e){this._widget=e,this._layers=e.scene.imageryLayers,e.scene.postRender.addEventListener(this._postRenderBound),this._imageViewer.open(this._openArg),this._layers.add(this._imageryLayerShown),this._intervalHandle=setInterval(this._updateFrustumBound,500)},r.prototype.close=function(){this._imageViewer.close(),clearInterval(this._intervalHandle),this._layers.remove(this._imageryLayerShown),this._widget.removeEventListener(this._postRenderBound),this._isWhileReplaceLayerShown&&(this._isWhileReplaceLayerShown=!1,this._isPendingUpdateCallback=!1,this._layers.remove(this._imageryLayerPending))},r.prototype.getImageryLayers=function(){return[this._imageryLayerShown,this._imageryLayerPending]},r.prototype._updateFrustum=function(){var e=o(this._widget);null!==e&&this._imageViewer.updateViewArea(e)},r.prototype._canvasUpdatedCallback=function(e){if(this._isWhileReplaceLayerShown&&(this._isPendingUpdateCallback=!0,this._pendingPositionRectangle=e),null!==e){var t=new Cesium.Rectangle(e.west,e.south,e.east,e.north);this._imageryProviders[0].setRectangle(t),this._imageryProviders[1].setRectangle(t)}this._removeAndReAddLayer()},r.prototype._removeAndReAddLayer=function(){var e=this._layers.indexOf(this._imageryLayerShown);if(e<0)throw"Layer was removed from viewer's layers without closing layer manager. Use CesiumImageDecoderLayerManager.close() instead";this._isWhileReplaceLayerShown=!0,this._layers.add(this._imageryLayerPending,e)},r.prototype._postRender=function(){if(this._isWhileReplaceLayerShown){this._isWhileReplaceLayerShown=!1,this._layers.remove(this._imageryLayerShown,!1);var e=this._imageryLayerShown;this._imageryLayerShown=this._imageryLayerPending,this._imageryLayerPending=e,this._isPendingUpdateCallback&&(this._isPendingUpdateCallback=!1,this._canvasUpdatedCallback(this._pendingPositionRectangle))}}},{"canvas-imagery-provider.js":1,"cesium-frustum-calculator.js":2,"image-decoder-viewer.js":15}],4:[function(e,t,i){"use strict";function r(e,t){var i=t.url;this._openArg=t.openArg,this._adaptProportions=t.adaptProportions,this._rectangle=t.rectangle,this._proxy=t.proxy,this._updateFrustumInterval=1e3,this._credit=t.credit,"string"==typeof this._credit&&(this._credit=new Credit(this._credit)),void 0===this._rectangle&&(this._rectangle=Cesium.Rectangle.fromDegrees(-180,-90,180,90)),void 0===this._adaptProportions&&(this._adaptProportions=!0),t=JSON.parse(JSON.stringify(t||{})),t.cartographicBounds={west:this._rectangle.west,east:this._rectangle.east,south:this._rectangle.south,north:this._rectangle.north},this._url=i,this._tilingScheme=void 0,this._tileWidth=0,this._tileHeight=0,this._errorEvent=new Event("ImageDecoderImageryProviderStatus"),this._ready=!1,this._exceptionCallback=null,this._cesiumWidget=null,this._updateFrustumIntervalHandle=null;var r=i;i||(i="unknown-url"),void 0!==this._proxy&&(r=this._proxy.getURL(r)),this._imageDecoder=e,this._url=r}function a(e){var t=new Cesium.Rectangle(e.west,e.south,e.east,e.north),i=new Cesium.GeographicTilingScheme({rectangle:t,numberOfLevelZeroTilesX:e.levelZeroTilesX,numberOfLevelZeroTilesY:e.levelZeroTilesY});return i}t.exports=r;var s=e("cesium-frustum-calculator.js"),o=e("image-helper-functions.js");r.prototype={get url(){return this._url},get proxy(){return this._proxy},get tileWidth(){if(!this._ready)throw new DeveloperError("tileWidth must not be called before the imagery provider is ready.");return this._tileWidth},get tileHeight(){if(!this._ready)throw new DeveloperError("tileHeight must not be called before the imagery provider is ready.");return this._tileHeight},get maximumLevel(){if(!this._ready)throw new DeveloperError("maximumLevel must not be called before the imagery provider is ready.");return this._numResolutionLevels-1},get minimumLevel(){if(!this._ready)throw new DeveloperError("minimumLevel must not be called before the imagery provider is ready.");return 0},get tilingScheme(){if(!this._ready)throw new DeveloperError("tilingScheme must not be called before the imagery provider is ready.");return this._tilingScheme},get rectangle(){return this._tilingScheme.rectangle},get tileDiscardPolicy(){if(!this._ready)throw new DeveloperError("tileDiscardPolicy must not be called before the imagery provider is ready.")},get errorEvent(){return this._errorEvent},get ready(){return this._ready},get credit(){return this._credit},get hasAlphaChannel(){return!0}},r.prototype.setExceptionCallback=function(e){this._exceptionCallback=e},r.prototype.open=function(e){if(null!==this._updateFrustumIntervalHandle)throw new DeveloperError("Cannot set two parent viewers.");if(void 0===e)throw new DeveloperError("widgetOrViewer should be given. It is needed for frustum calculation for the priority mechanism");this._imageDecoder.open(this._openArg).then(this._opened.bind(this))["catch"](this._onException.bind(this)),this._cesiumWidget=e,this._updateFrustumIntervalHandle=setInterval(this._setPriorityByFrustum.bind(this),this._updateFrustumInterval)},r.prototype.close=function(){clearInterval(this._updateFrustumIntervalHandle),this._imageDecoder.close()},r.prototype.getTileWidth=function(){return this.tileWidth},r.prototype.getTileHeight=function(){return this.tileHeight},r.prototype.getMaximumLevel=function(){return this.maximumLevel},r.prototype.getMinimumLevel=function(){return this.minimumLevel},r.prototype.getUrl=function(){return this._url},r.prototype.getProxy=function(){return this.proxy},r.prototype.isReady=function(){return this.ready},r.prototype.getCredit=function(){return this.credit},r.prototype.getRectangle=function(){return this.tilingScheme.rectangle},r.prototype.getTilingScheme=function(){return this.tilingScheme},r.prototype.getTileDiscardPolicy=function(){return this.tileDiscardPolicy},r.prototype.getErrorEvent=function(){return this.errorEvent},r.prototype.getHasAlphaChannel=function(){return this.hasAlphaChannel},r.prototype.getTileCredits=function(e,t,i){},r.prototype.requestImage=function(e,t,i){function r(e){var t=e.imageData.width,i=e.imageData.height;t>0&&i>0&&f.putImageData(e.imageData,e.xInOriginalRequest,e.yInOriginalRequest)}function a(e){e?P("Fetch request or decode aborted"):(_.drawImage(v,0,0,g,p,d.croppedScreen.minX,d.croppedScreen.minY,d.croppedScreen.maxXExclusive,d.croppedScreen.maxYExclusive),y(m))}if(!this._ready)throw new DeveloperError("requestImage must not be called before the imagery provider is ready.");var s=this,n=Math.pow(2,this._numResolutionLevels-i-1),h=e*this._tileWidth*n,l=t*this._tileHeight*n,c=(e+1)*this._tileWidth*n,u=(t+1)*this._tileHeight*n,d=o.alignParamsToTilesAndLevel({minX:h,minY:l,maxXExclusive:c,maxYExclusive:u,screenWidth:this._tileWidth,screenHeight:this._tileHeight},this._imageDecoder),m=document.createElement("canvas");m.width=this._tileWidth,m.height=this._tileHeight;var _=m.getContext("2d");_.clearRect(0,0,this._tileWidth,this._tileHeight);var g=d.imagePartParams.maxXExclusive-d.imagePartParams.minX,p=d.imagePartParams.maxYExclusive-d.imagePartParams.minY;if(g<=0||p<=0)return m;var v=document.createElement("canvas");v.width=g,v.height=p;var f=v.getContext("2d");f.clearRect(0,0,g,p),d.imagePartParams.quality=this._quality,d.imagePartParams.requestPriorityData={imageRectangle:this._rectangle};var y,P,x=new Promise(function(e,t){y=e,P=t,s._imageDecoder.requestPixelsProgressive(d.imagePartParams,r,a)});return x},r.prototype._setPriorityByFrustum=function(){if(this._ready){var e=s(this._cesiumWidget,this);null!==e&&(e.imageRectangle=this.getRectangle(),e.exactlevel=null,this._imageDecoder.setFetchPrioritizerData(e),this._imageDecoder.setDecodePrioritizerData(e))}},r.prototype.pickFeatures=function(){},r.prototype._onException=function(e){null!==this._exceptionCallback&&this._exceptionCallback(e)},r.prototype._opened=function(){if(this._ready)throw"imageDecoderImageryProvider error: opened() was called more than once!";this._ready=!0,this._numResolutionLevels=this._imageDecoder.getNumResolutionLevelsForLimittedViewer(),this._quality=this._imageDecoder.getHighestQuality();var e=this._numResolutionLevels-1;this._tileWidth=this._imageDecoder.getTileWidth(),this._tileHeight=this._imageDecoder.getTileHeight();var t=this._imageDecoder.getImageWidth(),i=this._imageDecoder.getImageHeight(),r=Math.ceil(t/this._tileWidth)>>e,s=Math.ceil(i/this._tileHeight)>>e;o.fixBounds(this._rectangle,this._imageDecoder,this._adaptProportions);var n=this._rectangle.east-this._rectangle.west,h=this._rectangle.north-this._rectangle.south,l=1<<e,c=this._tileWidth*r*l,u=this._tileHeight*s*l,d=n*c/t,m=h*u/i,_=this._rectangle.west+d,g=this._rectangle.north-m;this._tilingSchemeParams={west:this._rectangle.west,east:_,south:g,north:this._rectangle.north,levelZeroTilesX:r,levelZeroTilesY:s,maximumLevel:e},this._tilingScheme=a(this._tilingSchemeParams),Cesium.TileProviderError.handleSuccess(this._errorEvent)}},{"cesium-frustum-calculator.js":2,"image-helper-functions.js":13}],5:[function(e,t,i){"use strict";var r=e("image-decoder.js"),a=e("worker-proxy-image-decoder.js");e("image-helper-functions.js");t.exports.ImageDecoder=r,t.exports.WorkerProxyImageDecoder=a,t.exports.ImageDecoderViewer=e("image-decoder-viewer.js"),t.exports.SimpleFetcherBase=e("simple-fetcher-base.js"),t.exports.GridImageBase=e("grid-image-base.js"),t.exports.GridFetcherBase=e("grid-fetcher-base.js"),t.exports.GridDecoderWorkerBase=e("grid-decoder-worker-base.js"),t.exports.GridLevelCalculator=e("grid-level-calculator.js"),t.exports.CesiumImageDecoderLayerManager=e("cesium-image-decoder-layer-manager.js"),t.exports.ImageDecoderImageryProvider=e("image-decoder-imagery-provider.js"),t.exports.ImageDecoderRegionLayer=e("image-decoder-region-layer.js")},{"cesium-image-decoder-layer-manager.js":3,"grid-decoder-worker-base.js":22,"grid-fetcher-base.js":23,"grid-image-base.js":24,"grid-level-calculator.js":25,"image-decoder-imagery-provider.js":4,"image-decoder-region-layer.js":20,"image-decoder-viewer.js":15,"image-decoder.js":19,"image-helper-functions.js":13,"simple-fetcher-base.js":26,"worker-proxy-image-decoder.js":18}],6:[function(e,t,i){"use strict";function r(e,t,i){this._progressiveStagesDone=0,this._listenerHandle=e,this._imagePartParams=t,this._allRelevantBytesLoaded=0;var r=e.imagePartParams;this._offsetX=t.minX-r.minX,this._offsetY=t.minY-r.minY,this._requestWidth=r.maxXExclusive-r.minX,this._requestHeight=r.maxYExclusive-r.minY}function a(e,t,i){r.call(this,e,t),this._prioritizer=i}t.exports=r;e("linked-list.js");r.WithPriority=a,r.prototype.onData=function(e){++this._progressiveStagesDone;var t=e.allRelevantBytesLoaded-this._allRelevantBytesLoaded;this._allRelevantBytesLoaded=e.allRelevantBytesLoaded,this._listenerHandle.allRelevantBytesLoaded+=t;var i={originalRequestWidth:this._requestWidth,originalRequestHeight:this._requestHeight,xInOriginalRequest:this._offsetX,yInOriginalRequest:this._offsetY,imageData:e,allRelevantBytesLoaded:this._listenerHandle.allRelevantBytesLoaded};this._listenerHandle.callback(i)},r.prototype.onTerminated=function(){var e=--this._listenerHandle.remainingDecodeJobs;if(e<0)throw"imageDecoderFramework error: Inconsistent number of done requests";var t=0===e;t&&(this._listenerHandle.isTerminatedCallbackCalled=!0,this._listenerHandle.terminatedCallback(this._listenerHandle.isAnyDecoderAborted))},Object.defineProperty(r.prototype,"imagePartParams",{get:function(){return this._imagePartParams}}),Object.defineProperty(r.prototype,"progressiveStagesDone",{get:function(){return this._progressiveStagesDone}}),a.prototype=Object.create(r.prototype),a.prototype.priorityCalculator=function(){return this._prioritizer.getPriority(this)}},{"linked-list.js":14}],7:[function(e,t,i){"use strict";function r(e,t,i,r){this._prioritizer=t,this._tileWidth=i,this._tileHeight=r,this._decodeDependencyWorkers=e}function a(e,t,i,r,a){if(void 0===a)return!1;for(var s=0;s<a.length;++s){var o=a[s],n=e>=o.minX&&i<=o.maxXExclusive,h=t>=o.minY&&r<=o.maxYExclusive;if(n&&h)return!0}return!1}t.exports=r;var s=e("decode-job.js");r.prototype.forkDecodeJobs=function(e,t,i,r){var s=e.minX,o=e.minY,n=e.maxXExclusive,h=e.maxYExclusive,l=e.level||0,c=e.quality,u=e.requestPriorityData,d=s%this._tileWidth===0&&o%this._tileHeight===0,m=n%this._tileWidth===0||n===e.levelWidth,_=h%this._tileHeight===0||h===e.levelHeight,g=s<n&&o<h;if(!(d&&m&&_&&g))throw"imageDecoderFramework error: imagePartParams for decoders is not aligned to tile size or not in valid order";for(var p=Math.ceil((n-s)/this._tileWidth),v=Math.ceil((h-o)/this._tileHeight),f={imagePartParams:e,callback:t,terminatedCallback:i,remainingDecodeJobs:p*v,isAnyDecoderAborted:!1,isTerminatedCallbackCalled:!1,allRelevantBytesLoaded:0,taskContexts:[]},y=s;y<n;y+=this._tileWidth)for(var P=Math.min(y+this._tileWidth,e.levelWidth),x=o;x<h;x+=this._tileHeight){var T=Math.min(x+this._tileHeight,e.levelHeight),w=a(y,x,P,T,r);if(w)--f.remainingDecodeJobs;else{var C={minX:y,minY:x,maxXExclusive:P,maxYExclusive:T,levelWidth:e.levelWidth,levelHeight:e.levelHeight,level:l,quality:c,requestPriorityData:u};this._startNewTask(f,C)}}return f.isTerminatedCallbackCalled||0!==f.remainingDecodeJobs||(f.isTerminatedCallbackCalled=!0,f.terminatedCallback(f.isAnyDecoderAborted)),f},r.prototype._startNewTask=function(e,t){var i=null===this._prioritizer?new s(e,t):new s.WithPriority(e,t,this._prioritizer),r=this._decodeDependencyWorkers.startTask(t,i);e.taskContexts.push(r)},r.prototype.unregisterForkedJobs=function(e){if(0!==e.remainingDecodeJobs)for(var t=0;t<e.taskContexts.length;++t)e.taskContexts[t].unregister()}},{"decode-job.js":6}],8:[function(e,t,i){"use strict";function r(){this._events={isProgressiveChanged:[],move:[],terminate:[],stop:[],resume:[],internalStopped:[],internalDone:[]}}t.exports=r,r.prototype.stopped=function(){this._onEvent("internalStopped",!1)},r.prototype.done=function(){this._onEvent("internalDone")},r.prototype.on=function(e,t,i){var r=this._events[e];if(!r)throw"imageDecoderFramework error: event "+e+" does not exist in FetchContext";return r.push({listener:t,listenerThis:i||this}),this},r.prototype._onEvent=function(e,t,i){for(var r=this._events[e],a=0;a<r.length;++a)r[a].listener.call(r[a].listenerThis,t,i)}},{}],9:[function(e,t,i){"use strict";function r(e,t,i,a,s,o){this._fetcher=e,this._fetcherCloser=t,this._scheduler=i,this._scheduledJobsList=a,this._scheduledJobsListIterator=null,this._terminatedListeners=[],this._imagePartParams=null,this._state=r.FETCH_STATUS_WAIT_FOR_FETCH_CALL,this._isMovable=s===r.FETCH_TYPE_MOVABLE,this._contextVars=o,this._isOnlyWaitForData=s===r.FETCH_TYPE_ONLY_WAIT_FOR_DATA,this._useScheduler=s===r.FETCH_TYPE_REQUEST,this._resource=null,this._fetchContextApi=null}function a(e,t,i){if(null!==t._resource)throw"imageDecoderFramework error: Unexpected restart of already started request";if(t._state===r.FETCH_STATUS_REQUEST_ABOUT_TO_ABORT)return void t._fetchStopped(!0);if(t._state!==r.FETCH_STATUS_REQUEST_WAIT_FOR_SCHEDULE)throw"imageDecoderFramework error: Unexpected state on schedule: "+t._state;t._resource=e,t._schedulerCallbacks=i,null!==e&&(t._scheduledJobsListIterator=t._scheduledJobsList.add(t)),t._startFetch()}function s(e,t){if(t._isMovable)throw"imageDecoderFramework error: Unexpected call to continueYieldedRequest on movable fetch";if(t._state===r.FETCH_STATUS_REQUEST_ABOUT_TO_ABORT||t._state===r.FETCH_STATUS_UNEXPECTED_FAILURE)return void t._schedulerCallbacks.jobDone();if(t._state!==r.FETCH_STATUS_REQUEST_YIELDED)throw"imageDecoderFramework error: Unexpected request state on continue: "+t._state;t._state=r.FETCH_STATUS_ACTIVE,t._resource=e,t._scheduledJobsListIterator=t._scheduledJobsList.add(t),t._onEvent("resume")}function o(e){if(e._resource=null,e._scheduledJobsList.remove(e._scheduledJobsListIterator),e.state!==r.FETCH_STATUS_REQUEST_ABOUT_TO_YIELD)throw e._state=r.FETCH_STATUS_UNEXPECTED_FAILURE,"imageDecoderFramework error: Unexpected request state on yield process: "+e._state;e._state=r.FETCH_STATUS_REQUEST_YIELDED}function n(e){e._resource=null,e._fetchStopped(!0)}var h=e("fetch-context-api.js");t.exports=r,r.FETCH_TYPE_REQUEST=1,r.FETCH_TYPE_MOVABLE=2,r.FETCH_TYPE_ONLY_WAIT_FOR_DATA=3,r.FETCH_STATUS_WAIT_FOR_FETCH_CALL=1,r.FETCH_STATUS_MOVABLE_WAIT_FOR_MOVE_CALL=2,r.FETCH_STATUS_REQUEST_WAIT_FOR_SCHEDULE=3,r.FETCH_STATUS_ACTIVE=4,r.FETCH_STATUS_REQUEST_ABOUT_TO_YIELD=5,r.FETCH_STATUS_REQUEST_YIELDED=6,r.FETCH_STATUS_REQUEST_ABOUT_TO_ABORT=7,r.FETCH_STATUS_REQUEST_TERMINATED=8,r.FETCH_STATUS_UNEXPECTED_FAILURE=9,r.prototype.fetch=function(e){if(this._isMovable)return this._imagePartParams=e,void this._startFetch();if(null!==this._imagePartParams)throw'imageDecoderFramework error: Cannot fetch twice on fetch type of "request"';if(this._state!==r.FETCH_STATUS_WAIT_FOR_FETCH_CALL)throw this._state=r.FETCH_STATUS_UNEXPECTED_FAILURE,"imageDecoderFramework error: Unexpected state on fetch(): "+this._state;return this._imagePartParams=e,this._state=r.FETCH_STATUS_REQUEST_WAIT_FOR_SCHEDULE,this._useScheduler?void this._scheduler.enqueueJob(a,this,n):void a(null,this)},r.prototype.manualAbortRequest=function(){switch(this._state){case r.FETCH_STATUS_REQUEST_TERMINATED:case r.FETCH_STATUS_UNEXPECTED_FAILURE:return;case r.FETCH_STATUS_REQUEST_ABOUT_TO_ABORT:throw"imageDecoderFramework error: Double call to manualAbortRequest()";case r.FETCH_STATUS_ACTIVE:this._state=r.FETCH_STATUS_REQUEST_ABOUT_TO_ABORT,this._isOnlyWaitForData?this._fetchStopped(!0):this._fetchContextApi._onEvent("stop",!0);break;case r.FETCH_STATUS_WAIT_FOR_FETCH_CALL:return void(this._state=r.FETCH_STATUS_REQUEST_TERMINATED);case r.FETCH_STATUS_REQUEST_WAIT_FOR_SCHEDULE:case r.FETCH_STATUS_REQUEST_ABOUT_TO_YIELD:case r.FETCH_STATUS_REQUEST_YIELDED:this._state=r.FETCH_STATUS_REQUEST_ABOUT_TO_ABORT;break;default:throw"imageDecoderFramework error: Unknown state in manualAbortRequest() implementation: "+this._state}},r.prototype.getContextVars=function(){return this._contextVars},r.prototype.on=function(e,t){switch(e){case"terminated":this._terminatedListeners.push(t);break;default:throw"imageDecoderFramework error: Unexpected event "+e}},r.prototype.setIsProgressive=function(e){this._isProgressive=e,null!==this._fetchContextApi&&this._fetchContextApi._onEvent("isProgressiveChanged",e)},r.prototype.getIsProgressive=function(){return this._isProgressive},r.prototype._startFetch=function(){var e=this._state;if(this._state=r.FETCH_STATUS_ACTIVE,e!==r.FETCH_STATUS_WAIT_FOR_FETCH_CALL&&e!==r.FETCH_STATUS_MOVABLE_WAIT_FOR_MOVE_CALL||this._fetcherCloser.changeActiveFetchesCount(1),this._isOnlyWaitForData)this._fetchContextApi=this._extractAlreadyFetchedData();else if(this._isMovable&&e!==r.FETCH_STATUS_WAIT_FOR_FETCH_CALL)this._fetchContextApi._onEvent("move",this._imagePartParams);else{if(null!==this._fetchContextApi)throw"imageDecoderFramework error: Cannot start fetch of already started fetch";this._fetchContextApi=new h(this),this._fetchContextApi.on("internalStopped",this._fetchStopped,this),this._fetchContextApi.on("internalDone",this._fetchDone,this),this._isMovable?this._fetcher.startMovableFetch(this._fetchContextApi,this._imagePartParams):this._fetcher.startFetch(this._fetchContextApi,this._imagePartParams)}null!==this._fetchContextApi&&this._fetchContextApi._onEvent("isProgressiveChanged",this._isProgressive)},r.prototype.checkIfShouldYield=function(){try{if(!this._useScheduler||this._state===r.FETCH_STATUS_REQUEST_TERMINATED)return;if(null===this._resource)throw"imageDecoderFramework error: No resource allocated but fetch callback called";if(!this._schedulerCallbacks.shouldYieldOrAbort())return;this._state=r.FETCH_STATUS_REQUEST_ABOUT_TO_YIELD,this._fetchContextApi._onEvent("stop",!1)}catch(e){this._state=r.FETCH_STATUS_UNEXPECTED_FAILURE,n(this)}},r.prototype._fetchDone=function(){switch(this._state){case r.FETCH_STATUS_REQUEST_ABOUT_TO_ABORT:case r.FETCH_STATUS_ACTIVE:case r.FETCH_STATUS_REQUEST_ABOUT_TO_YIELD:break;default:throw"imageDecoderFramework error: Unexpected state on fetch done: "+this._state}if(this._isMovable&&(this._state=r.FETCH_STATUS_MOVABLE_WAIT_FOR_MOVE_CALL),this._fetcherCloser.changeActiveFetchesCount(-1),null!==this._resource)this._scheduledJobsList.remove(this._scheduledJobsListIterator),this._schedulerCallbacks.jobDone(),this._resource=null;else if(this._useScheduler)throw"imageDecoderFramework error: Job expected to have resource on successful termination";this._terminateNonMovableFetch()},r.prototype._fetchStopped=function(e){switch(this._state){case r.FETCH_STATUS_REQUEST_ABOUT_TO_ABORT:e=!0;break;case r.FETCH_STATUS_REQUEST_ABOUT_TO_YIELD:var t=this._schedulerCallbacks.tryYield(s,n,o);if(!t){if(this._state!==r.FETCH_STATUS_REQUEST_ABOUT_TO_YIELD)throw"imageDecoderFramework error: Unexpected state on tryYield() false: "+this._state;return this._state=r.FETCH_STATUS_ACTIVE,void this._fetchContextApi._onEvent("resume")}break;default:throw"imageDecoderFramework error: Unexpected state on fetch stopped: "+this._state}if(null!==this._resource)throw"imageDecoderFramework error: Unexpected request termination without resource allocated";this._fetcherCloser.changeActiveFetchesCount(-1),this._isMovable?this._state=r.FETCH_STATUS_MOVABLE_WAIT_FOR_MOVE_CALL:e||this._terminateNonMovableFetch()},r.prototype._terminateNonMovableFetch=function(){if(!this._isMovable){this._state=r.FETCH_STATUS_REQUEST_TERMINATED;for(var e=0;e<this._terminatedListeners.length;++e)this._terminatedListeners[e](this._contextVars);null!==this._fetchContextApi&&this._state!==r.FETCH_STATUS_UNEXPECTED_FAILURE&&(this._fetchContextApi._onEvent("terminate"),this._fetchContextApi=null)}},Object.defineProperty(r.prototype,"imagePartParams",{get:function(){return this._imagePartParams}})},{"fetch-context-api.js":8}],10:[function(e,t,i){"use strict";function r(e,t){t=t||{},this._fetchesLimit=t.fetchesLimit||5,this._showLog=t.showLog,this._scheduler=null,this._fetchPrioritizer=null,this._prioritizerType=null,this._movableHandleCounter=0,this._movableHandles=[],this._requestById=[],this._imageParams=null,this._scheduledJobsList=new h,this._fetcherCloser=new l,this._fetcher=o.getOrCreateInstance(e,"fetcher",r.fetcherExpectedMethods)}function a(e){delete e.self._requestById[e.requestId]}function s(){return{}}t.exports=r;var o=e("image-helper-functions.js"),n=e("fetch-context.js"),h=e("linked-list.js"),l=e("fetcher-closer.js");r.fetcherExpectedMethods=["open","on","close","startFetch","startMovableFetch"],r.prototype.open=function(e){var t=o.createPrioritizer(this._fetchesLimit,this._prioritizerType,"fetch",this._showLog);this._fetchPrioritizer=t.prioritizer,null!==t.prioritizer?this._scheduler=new resourceScheduler.PriorityScheduler(s,this._fetchesLimit,t.prioritizer,t.schedulerOptions):this._scheduler=new resourceScheduler.LifoScheduler(s,this._fetchesLimit,t.schedulerOptions);var i=this;return this._fetcher.open(e).then(function(e){return i._imageParams=e,e})},r.prototype.on=function(e,t,i){return this._fetcher.on(e,t,i)},r.prototype.close=function(){function e(e){t._fetcherCloser.close().then(function(){i(e)})["catch"](r)}var t=this,i=null,r=null;return new Promise(function(a,s){i=a,r=s,t._fetcher.close().then(e)["catch"](s)})},r.prototype.setPrioritizerType=function(e){if(null!==this._scheduler)throw"imageDecoderFramework error: cannot set prioritizer type after FetchManager.open() called";this._prioritizerType=e},r.prototype.getImageParams=function(){return this._imageParams},r.prototype.setIsProgressiveRequest=function(e,t){var i=this._requestById[e];return void 0===i?null:void i.setIsProgressive(t)},r.prototype.createMovableFetch=function(){var e=this;return new Promise(function(t,i){var r=++e._movableHandleCounter;e._movableHandles[r]=new n(e._fetcher,e._fetcherCloser,e._scheduler,e._scheduledJobsList,n.FETCH_TYPE_MOVABLE,null),t(r)})},r.prototype.moveFetch=function(e,t){var i=this._movableHandles[e];i.fetch(t)},r.prototype.createRequest=function(e,t){var i={progressiveStagesDone:0,isLastCallbackCalledWithoutLowQualityLimit:!1,requestId:e,fetchJob:null,self:this},r=n.FETCH_TYPE_REQUEST,s=new n(this._fetcher,this._fetcherCloser,this._scheduler,this._scheduledJobsList,r,i);if(i.fetchJob=s,void 0!==this._requestById[e])throw"imageDecoderFramework error: Duplication of requestId "+e;void 0!==e&&(this._requestById[e]=s),s.on("terminated",a),s.fetch(t),this._yieldFetchJobs()},r.prototype.manualAbortRequest=function(e){var t=this._requestById[e];void 0!==t&&(t.manualAbortRequest(),delete this._requestById[e])},r.prototype.setFetchPrioritizerData=function(e){if(null===this._fetchPrioritizer)throw"imageDecoderFramework error: No fetch prioritizer has been set";this._showLog&&console.log("setFetchPrioritizerData("+e+")"),e.image=this,this._fetchPrioritizer.setPrioritizerData(e),this._yieldFetchJobs()},r.prototype._yieldFetchJobs=function(){for(var e=this._scheduledJobsList.getFirstIterator();null!==e;){var t=this._scheduledJobsList.getValue(e);e=this._scheduledJobsList.getNextIterator(e),t.checkIfShouldYield()}}},{"fetch-context.js":9,"fetcher-closer.js":11,"image-helper-functions.js":13,"linked-list.js":14}],11:[function(e,t,i){"use strict";function r(){this._resolveClose=null,this._activeFetches=0,this._isClosed=!1}t.exports=r,r.prototype.changeActiveFetchesCount=function(e){if(this._isClosed)throw"imageDecoderFramework error: Unexpected change of active fetches count after closed";this._activeFetches+=e,0===this._activeFetches&&this._resolveClose&&(this._isClosed=!0,this._resolveClose())},r.prototype.isCloseRequested=function(){return this._isClosed||null!==this._resolveClose},r.prototype.close=function(){if(this.isCloseRequested())throw"imageDecoderFramework error: close() called twice";var e=this;return new Promise(function(t,i){e._resolveClose=t,0===e._activeFetches&&e._resolveClose()})}},{}],12:[function(e,t,i){"use strict";function r(e,t){this._frustumData=null,this._isAbortRequestsNotInFrustum=e,this._isPrioritizeLowProgressiveStage=t}t.exports=r;var a=-1,s=0,o=1,n=2,h=3,l=4,c=5,u=6,d=7,m=5,_=13;Math.log(2);Object.defineProperty(r.prototype,"minimalLowQualityPriority",{get:function(){return l+m}}),r.prototype.setPrioritizerData=function(e){this._frustumData=e},r.prototype.getPriority=function(e){var t=e.imagePartParams;if(t.requestPriorityData.overrideHighestPriority)return _;var i=this._getPriorityInternal(t),r=i>=l;if(this._isAbortRequestsNotInFrustum&&!r)return a;var s=0;return this._isPrioritizeLowProgressiveStage&&r&&(s=0===e.progressiveStagesDone?m:1===e.progressiveStagesDone?1:0),
i+s},r.prototype._getPriorityInternal=function(e){if(null===this._frustumData)return s;if(void 0===this._frustumData.imageRectangle)throw"imageDecoderFramework error: No imageRectangle information passed in setPrioritizerData";var t=this._frustumData.exactlevel;if(void 0===this._frustumData.exactlevel)throw"imageDecoderFramework error: No exactlevel information passed in setPrioritizerData. Use null if unknown";var i,r=this._pixelToCartographicX(e.minX,e),a=this._pixelToCartographicX(e.maxXExclusive,e),m=this._pixelToCartographicY(e.minY,e),_=this._pixelToCartographicY(e.maxYExclusive,e),g=e.maxXExclusive-e.minX,p=e.maxYExclusive-e.minY,v=e.level||0;if(null===t){var f=g/(a-r),y=p/(m-_),P=Math.max(f,y),x=this._frustumData.resolution;if(i=P/x,i>2)return o}else if(v<t)return o;var T=this._frustumData.rectangle,w=Math.max(T.west,r),C=Math.min(T.east,a),F=Math.max(T.south,_),E=Math.min(T.north,m),b=C-w,D=E-F;if(b<0||D<0)return n;if(null!==t){if(v>t)return h}else if(v>0&&i<.25)return h;var S=b*D,I=(a-r)*(m-_),L=S/I;return L>.99?d:L>.7?u:L>.3?c:l},r.prototype._pixelToCartographicX=function(e,t){var i=e/t.levelWidth,r=this._frustumData.imageRectangle,a=r.east-r.west,s=r.west+i*a;return s},r.prototype._pixelToCartographicY=function(e,t,i){var r=e/t.levelHeight,a=this._frustumData.imageRectangle,s=a.north-a.south,o=a.north-r*s;return o}},{}],13:[function(e,t,i){"use strict";function r(e,t){var i=t.x*t.x+t.y*t.y,r=e.east-e.west,a=e.north-e.south,s=r*r+a*a,o=Math.sqrt(i/s),n={resolution:o,rectangle:e,screenSize:t};return n}function a(e,t,i,r){var a,s=!1;"frustum"===t?(s=!0,a=new d):"frustumOnly"===t?(s=!0,a=new d((!0),(!0))):a=t?t:null;var o={schedulerName:i,showLog:r};return s&&(o.resourceGuaranteedForHighPriority=e-2,o.highPriorityToGuaranteeResource=a.minimalLowQualityPriority),{prioritizer:a,schedulerOptions:o}}function s(e,t,i){if(i){var r=e.east-e.west,a=e.north-e.south,s=t.getImageWidth()/t.getImageHeight(),o=r/a;if(s<o){var n=r;r=a*s;var h=n-r;e.east-=h/2,e.west+=h/2}else{var l=a;a=r/s;var c=l-a;e.north-=c/2,e.south+=c/2}}}function o(e){if("function"!=typeof e.getLevel)throw"imageDecoderFramework error: Missing method levelCalculator.getLevel()";if("function"!=typeof e.getLevelWidth)throw"imageDecoderFramework error: Missing method levelCalculator.getLevelWidth()";if("function"!=typeof e.getLevelHeight)throw"imageDecoderFramework error: Missing method levelCalculator.getLevelHeight()"}function n(e,t){var i=t.getTileWidth(),r=t.getTileHeight(),a=e.minX,s=e.minY,o=e.maxXExclusive,n=e.maxYExclusive,h=e.screenWidth,l=e.screenHeight,c=a<o&&s<n;if(!c)throw"imageDecoderFramework error: Parameters order is invalid";var u=t.getImageWidth(),d=t.getImageHeight();if(o<0||a>=u||n<0||s>=d)return null;var m=t.getLevelCalculator(),_=m.getLevel(e),g=m.getLevelWidth(_),p=m.getLevelHeight(_),v=u/g,f=d/p,y=Math.floor(a/(v*i)),P=Math.floor(s/(f*r)),x=Math.ceil(o/(v*i)),T=Math.ceil(n/(f*r)),w=y*i,C=P*r,F=x*i,E=T*r,b=Math.max(0,Math.min(g,w)),D=Math.max(0,Math.min(p,C)),S=Math.max(0,Math.min(g,F)),I=Math.max(0,Math.min(p,E)),L=h/(F-w),k=l/(E-C),A={minX:b,minY:D,maxXExclusive:S,maxYExclusive:I,levelWidth:g,levelHeight:p,level:_},R={minX:b*v,minY:D*f,maxXExclusive:S*v,maxYExclusive:I*f},H={minX:Math.floor((b-w)*L),minY:Math.floor((D-C)*k),maxXExclusive:Math.ceil((S-w)*L),maxYExclusive:Math.ceil((I-C)*k)};return{imagePartParams:A,positionInImage:R,croppedScreen:H}}function h(e,t,i){if(!l(e,t,i))return e;var r=null;try{r=c(window,e.ctorName)}catch(a){}if(!r)try{r=c(globals,e.ctorName)}catch(a){}if(!r)try{r=c(self,e.ctorName)}catch(a){}if(!r)throw"imageDecoderFramework error: Could not find class "+e.ctorName+" in global scope to create an instance of "+t;var s=new r;return l(s,t,i,!0),s}function l(e,t,i,r){if(!e)throw"imageDecoderFramework error: missing argument "+t;for(var a,s=0;s<i.length;++s)if("function"!=typeof e[i[s]]){a=i[s];break}if(s===i.length)return!1;if(r)throw"imageDecoderFramework error: Could not find method "+a+" in object "+t;if("string"!=typeof e.ctorName)throw"imageDecoderFramework error: Could not find method "+a+" in object "+t+". Either method should be exist or the object's ctorName property should point to a class to create instance from";if(!e.scriptsToImport)throw"imageDecoderFramework error: Could not find method "+a+" in object "+t+". Either method should be exist or the object's scriptsToImport property should be exist";return!0}function c(e,t){if(e[t])return e[t];for(var i=e,r=t.split("."),a=0;a<r.length;++a)i=i[r[a]];return i}function u(e,t,i,r,a){function s(e){o||(o=document.createElement("canvas"),o.width=c.maxXExclusive-c.minX,o.height=c.maxYExclusive-c.minY,h=o.getContext("2d"),h.clearRect(0,0,o.width,o.height)),h.putImageData(e.imageData,e.xInOriginalRequest,e.yInOriginalRequest);var i=l.croppedScreen;u.drawImage(o,i.minX,i.minY,i.maxXExclusive-i.minX,i.maxYExclusive-i.minY,r||0,a||0,t.screenWidth,t.screenHeight)}var o,h,l,c,u=e.getContext("2d");return new Promise(function(e,r){l=n(t,i),c=l.imagePartParams,i.requestPixelsProgressive(c,s,function(t){t?r("Fetch is aborted"):e()})})}var d=e("frustum-requests-prioritizer.js");t.exports={calculateFrustum2DFromBounds:r,createPrioritizer:a,fixBounds:s,ensureLevelCalculator:o,alignParamsToTilesAndLevel:n,getOrCreateInstance:h,isIndirectCreationNeeded:l,renderToCanvas:u}},{"frustum-requests-prioritizer.js":12}],14:[function(e,t,i){"use strict";function r(e){this._first={_prev:null,_parent:this},this._last={_next:null,_parent:this},this._count=0,this._useAutomaticHazardHeuristics=e,this._last._prev=this._first,this._first._next=this._last}t.exports=r,r.prototype.add=function(e,t){null!==t&&void 0!==t||(t=this._last),this._validateIteratorOfThis(t),++this._count;var i={_value:e,_next:t,_prev:t._prev,_isIterated:!1,_parent:this};return i._prev._next=i,t._prev=i,i},r.prototype.remove=function(e){if(this._validateIteratorOfThis(e),this._useAutomaticHazardHeuristics&&e._isIterated)throw"dependency-workers error: Suspect removal while iteration";--this._count,e._prev._next=e._next,e._next._prev=e._prev,e._parent=null},r.prototype.getValue=function(e){return this._validateIteratorOfThis(e),e._value},r.prototype.getFirstIterator=function(){var e=this.getNextIterator(this._first);return e},r.prototype.getLastIterator=function(){var e=this.getPrevIterator(this._last);return e._isIterated=!0,e},r.prototype.getNextIterator=function(e){return this._validateIteratorOfThis(e),e._isIterated=!1,e._next===this._last?null:(e._next._isIterated=!0,e._next)},r.prototype.getPrevIterator=function(e){return this._validateIteratorOfThis(e),e._isIterated=!1,e._prev===this._first?null:(e._prev._isIterated=!0,e._prev)},r.prototype.getCount=function(){return this._count},r.prototype._validateIteratorOfThis=function(e){if(e._parent!==this)throw"dependency-workers error: iterator must be of the current LinkedList"}},{}],15:[function(e,t,i){"use strict";function r(e,t,i){this._canvasUpdatedCallback=t,this._adaptProportions=i.adaptProportions,this._cartographicBounds=i.cartographicBounds,this._allowMultipleMovableFetchesInSession=i.allowMultipleMovableFetchesInSession,this._minFunctionCallIntervalMilliseconds=i.minFunctionCallIntervalMilliseconds,this._overviewResolutionX=i.overviewResolutionX||100,this._overviewResolutionY=i.overviewResolutionY||100,this._lastRequestIndex=0,this._pendingUpdateViewArea=null,this._regions=[],this._targetCanvas=null,this._callPendingCallbacksBound=this._callPendingCallbacks.bind(this),this._createdMovableFetchBound=this._createdMovableFetch.bind(this),this._pendingCallbacksIntervalHandle=0,this._pendingCallbackCalls=[],this._canShowDynamicRegion=!1,void 0===this._cartographicBounds&&(this._cartographicBounds={west:-175,east:175,south:-85,north:85}),void 0===this._adaptProportions&&(this._adaptProportions=!0),this._imageDecoder=e,e.setDecodePrioritizerType("frustumOnly"),e.setFetchPrioritizerType("frustumOnly")}t.exports=r;var a=e("image-helper-functions.js"),s=1,o=2,n=0,h=1;r.prototype.setExceptionCallback=function(e){this._exceptionCallback=e},r.prototype.open=function(e){return this._imageDecoder.open(e).then(this._opened.bind(this))["catch"](this._exceptionCallback)},r.prototype.close=function(){var e=this._imageDecoder.close();return e["catch"](this._exceptionCallback),this._isReady=!1,this._canShowDynamicRegion=!1,this._targetCanvas=null,e},r.prototype.setTargetCanvas=function(e){this._targetCanvas=e},r.prototype.updateViewArea=function(e){if(null===this._targetCanvas)throw"imageDecoderFramework error: Cannot update dynamic region before setTargetCanvas()";if(!this._canShowDynamicRegion)return void(this._pendingUpdateViewArea=e);var t=e.rectangle,i=e.screenSize,r={minX:t.west*this._scaleX+this._translateX,minY:t.north*this._scaleY+this._translateY,maxXExclusive:t.east*this._scaleX+this._translateX,maxYExclusive:t.south*this._scaleY+this._translateY,screenWidth:i.x,screenHeight:i.y},s=a.alignParamsToTilesAndLevel(r,this._imageDecoder),o=null===s;if(!o){s.imagePartParams.quality=this._quality;var n=void 0!==this._dynamicFetchParams&&this._isImagePartsEqual(s.imagePartParams,this._dynamicFetchParams.imagePartParams);if(!n){e.imageRectangle=this._cartographicBoundsFixed,e.exactlevel=s.imagePartParams.level,this._imageDecoder.setDecodePrioritizerData(e),this._imageDecoder.setFetchPrioritizerData(e),this._dynamicFetchParams=s;var l=!1,c=!this._allowMultipleMovableFetchesInSession;this._fetch(h,s,l,c)}}},r.prototype.getBounds=function(){if(!this._isReady)throw"imageDecoderFramework error: ImageDecoderViewer error: Image is not ready yet";return this._cartographicBoundsFixed},r.prototype._isImagePartsEqual=function(e,t){var i=void 0!==this._dynamicFetchParams&&e.minX===t.minX&&e.minY===t.minY&&e.maxXExclusive===t.maxXExclusive&&e.maxYExclusive===t.maxYExclusive&&e.level===t.level;return i},r.prototype._fetch=function(e,t,i,r){function a(i){C._tilesDecodedCallback(e,t,f,i)}function s(r){r&&h.requestPriorityData.overrideHighestPriority&&C._imageDecoder.requestPixelsProgressive(t.imagePartParams,a,s,l),C._fetchTerminatedCallback(e,t.imagePartParams.requestPriorityData,r,i)}var o=++this._lastRequestIndex,h=t.imagePartParams;h.requestPriorityData=h.requestPriorityData||{},h.requestPriorityData.requestIndex=o;var l,c=t.positionInImage.minX,u=t.positionInImage.minY,d=t.positionInImage.maxXExclusive,m=t.positionInImage.maxYExclusive,_=(c-this._translateX)/this._scaleX,g=(d-this._translateX)/this._scaleX,p=(u-this._translateY)/this._scaleY,v=(m-this._translateY)/this._scaleY,f={west:_,east:g,north:p,south:v},y=!1,P=this._regions[e];if(void 0!==P){var x=h.level,T=P.imagePartParams.level;if(y=x===T,y&&P.donePartParams&&(l=[P.donePartParams]),e!==n){var w=this._checkIfRepositionNeeded(P,h,f);w&&this._notifyNewPendingCalls()}}var C=this,F=r?this._movableHandle:void 0;this._imageDecoder.requestPixelsProgressive(t.imagePartParams,a,s,l,F)},r.prototype._fetchTerminatedCallback=function(e,t,i,r){var a=this._regions[e];void 0!==a&&(t.overrideHighestPriority||t.requestIndex===this._lastRequestIndex)&&(a.isDone=!i&&this._isReady,a.isDone&&(a.donePartParams=a.imagePartParams),r&&this._imageDecoder.createMovableFetch().then(this._createdMovableFetchBound))},r.prototype._createdMovableFetch=function(e){this._movableHandle=e,this._startShowingDynamicRegion()},r.prototype._startShowingDynamicRegion=function(){this._canShowDynamicRegion=!0,null!==this._pendingUpdateViewArea&&(this.updateViewArea(this._pendingUpdateViewArea),this._pendingUpdateViewArea=null)},r.prototype._tilesDecodedCallback=function(e,t,i,r){if(this._isReady){var a=this._regions[e];if(void 0===a)switch(a={},this._regions[e]=a,e){case h:a.canvas=this._targetCanvas;break;case n:a.canvas=document.createElement("canvas");break;default:throw"imageDecoderFramework error: Unexpected regionId "+e}var o=t.imagePartParams;!o.requestPriorityData.overrideHighestPriority&&o.requestPriorityData.requestIndex<a.currentDisplayRequestIndex||(this._checkIfRepositionNeeded(a,o,i),this._pendingCallbackCalls.push({type:s,region:a,decoded:r}),this._notifyNewPendingCalls())}},r.prototype._checkIfRepositionNeeded=function(e,t,i){var r=e.imagePartParams,a=e.donePartParams,s=t.level,n=void 0===r||r.minX!==t.minX||r.minY!==t.minY||r.maxXExclusive!==t.maxXExclusive||r.maxYExclusive!==t.maxYExclusive||r.level!==s;if(!n)return!1;var h,l,c,u,d,m=!1;void 0!==r&&(u=t.levelWidth/r.levelWidth,d=t.levelHeight/r.levelHeight,l={minX:Math.max(r.minX*u,t.minX),minY:Math.max(r.minY*d,t.minY),maxX:Math.min(r.maxXExclusive*u,t.maxXExclusive),maxY:Math.min(r.maxYExclusive*d,t.maxYExclusive)},m=l.maxX>l.minX&&l.maxY>l.minY),m&&(h={fromX:l.minX/u-r.minX,fromY:l.minY/d-r.minY,fromWidth:(l.maxX-l.minX)/u,fromHeight:(l.maxY-l.minY)/d,toX:l.minX-t.minX,toY:l.minY-t.minY,toWidth:l.maxX-l.minX,toHeight:l.maxY-l.minY},a&&r.level===s&&(c={minX:Math.max(a.minX,t.minX),minY:Math.max(a.minY,t.minY),maxXExclusive:Math.min(a.maxXExclusive,t.maxXExclusive),maxYExclusive:Math.min(a.maxYExclusive,t.maxYExclusive)})),e.imagePartParams=t,e.isDone=!1,e.currentDisplayRequestIndex=t.requestPriorityData.requestIndex;var _={type:o,region:e,position:i,donePartParams:c,copyData:h,pixelsWidth:t.maxXExclusive-t.minX,pixelsHeight:t.maxYExclusive-t.minY};return this._pendingCallbackCalls.push(_),!0},r.prototype._notifyNewPendingCalls=function(){this._isNearCallbackCalled||this._callPendingCallbacks()},r.prototype._callPendingCallbacks=function(){if(0===this._pendingCallbackCalls.length||!this._isReady)return void(this._isNearCallbackCalled=!1);this._isNearCallbackCalled&&clearTimeout(this._pendingCallbacksIntervalHandle),void 0!==this._minFunctionCallIntervalMilliseconds&&(this._pendingCallbacksIntervalHandle=setTimeout(this._callPendingCallbacksBound,this._minFunctionCallIntervalMilliseconds),this._isNearCallbackCalled=!0);for(var e=null,t=0;t<this._pendingCallbackCalls.length;++t){var i=this._pendingCallbackCalls[t];if(i.type===o)this._repositionCanvas(i),e=i.position;else{if(i.type!==s)throw"imageDecoderFramework error: Internal ImageDecoderViewer Error: Unexpected call type "+i.type;this._pixelsUpdated(i)}}this._pendingCallbackCalls.length=0,this._canvasUpdatedCallback(e)},r.prototype._pixelsUpdated=function(e){var t=e.region,i=e.decoded;if(0!==i.imageData.width&&0!==i.imageData.height){var r=i.xInOriginalRequest,a=i.yInOriginalRequest,s=t.canvas.getContext("2d");s.putImageData(i.imageData,r,a)}},r.prototype._repositionCanvas=function(e){var t,i=e.region,r=e.position,a=e.donePartParams,s=e.copyData,o=e.pixelsWidth,h=e.pixelsHeight,l=i.canvas.getContext("2d");void 0!==s&&(s.fromWidth===s.toWidth&&s.fromHeight===s.toHeight?t=l.getImageData(s.fromX,s.fromY,s.fromWidth,s.fromHeight):(this._tmpCanvas||(this._tmpCanvas=document.createElement("canvas"),this._tmpCanvasContext=this._tmpCanvas.getContext("2d")),this._tmpCanvas.width=s.toWidth,this._tmpCanvas.height=s.toHeight,this._tmpCanvasContext.drawImage(i.canvas,s.fromX,s.fromY,s.fromWidth,s.fromHeight,0,0,s.toWidth,s.toHeight),t=this._tmpCanvasContext.getImageData(0,0,s.toWidth,s.toHeight))),i.canvas.width=o,i.canvas.height=h,i!==this._regions[n]&&this._copyOverviewToCanvas(l,r,o,h),void 0!==s&&l.putImageData(t,s.toX,s.toY),i.position=r,i.donePartParams=a},r.prototype._copyOverviewToCanvas=function(e,t,i,r){var a=this._regions[n].position,s=this._regions[n].imagePartParams,o=s.maxXExclusive-s.minX,h=s.maxYExclusive-s.minY,l=a.east-a.west,c=a.north-a.south,u=o/l,d=h/c,m=t.east-t.west,_=t.north-t.south,g=m*u,p=_*d,v=t.west-a.west,f=a.north-t.north,y=v*u,P=f*d;e.drawImage(this._regions[n].canvas,y,P,g,p,0,0,i,r)},r.prototype._opened=function(){this._isReady=!0;var e={west:this._cartographicBounds.west,east:this._cartographicBounds.east,south:this._cartographicBounds.south,north:this._cartographicBounds.north};a.fixBounds(e,this._imageDecoder,this._adaptProportions),this._cartographicBoundsFixed=e;var t=this._imageDecoder.getImageWidth(),i=this._imageDecoder.getImageHeight();this._quality=this._imageDecoder.getHighestQuality();var r=e.east-e.west,s=e.north-e.south;this._scaleX=t/r,this._scaleY=-i/s,this._translateX=-e.west*this._scaleX,this._translateY=-e.north*this._scaleY;var o={minX:0,minY:0,maxXExclusive:t,maxYExclusive:i,screenWidth:this._overviewResolutionX,screenHeight:this._overviewResolutionY},h=a.alignParamsToTilesAndLevel(o,this._imageDecoder);h.imagePartParams.requestPriorityData=h.imagePartParams.requestPriorityData||{},h.imagePartParams.requestPriorityData.overrideHighestPriority=!0,h.imagePartParams.quality=this._imageDecoder.getLowestQuality();var l=!this._allowMultipleMovableFetchesInSession;this._fetch(n,h,l),this._allowMultipleMovableFetchesInSession&&this._startShowingDynamicRegion()}},{"image-helper-functions.js":13}],16:[function(e,t,i){"use strict";function r(){this._sizesParams=null}t.exports=r,r.prototype.getImageLevel=function(){var e=this.getImageParams();return e.imageLevel},r.prototype.getImageWidth=function(){var e=this.getImageParams();return e.imageWidth},r.prototype.getImageHeight=function(){var e=this.getImageParams();return e.imageHeight},r.prototype.getNumResolutionLevelsForLimittedViewer=function(){var e=this.getImageParams();return e.numResolutionLevelsForLimittedViewer},r.prototype.getLowestQuality=function(){var e=this.getImageParams();return e.lowestQuality},r.prototype.getHighestQuality=function(){var e=this.getImageParams();return e.highestQuality},r.prototype.getImageParams=function(){if(!this._sizesParams){if(this._sizesParams=this._getImageParamsInternal(),!this._sizesParams)throw"imageDecoderFramework error: getImageParamsInternal() returned falsy value; Maybe image not ready yet?";if(void 0===this._sizesParams.imageLevel)throw"imageDecoderFramework error: getImageParamsInternal() result has no imageLevel property";if(void 0===this._sizesParams.imageWidth)throw"imageDecoderFramework error: getImageParamsInternal() result has no imageWidth property";if(void 0===this._sizesParams.imageHeight)throw"imageDecoderFramework error: getImageParamsInternal() result has no imageHeight property";if(void 0===this._sizesParams.numResolutionLevelsForLimittedViewer)throw"imageDecoderFramework error: getImageParamsInternal() result has no numResolutionLevelsForLimittedViewer property";if(void 0===this._sizesParams.lowestQuality)throw"imageDecoderFramework error: getImageParamsInternal() result has no lowestQuality property";if(void 0===this._sizesParams.highestQuality)throw"imageDecoderFramework error: getImageParamsInternal() result has no highestQuality property"}return this._sizesParams},r.prototype._getImageParamsInternal=function(){throw"imageDecoderFramework error: ImageParamsRetrieverProxy inheritor did not implement _getImageParamsInternal()"}},{}],17:[function(e,t,i){"use strict";function r(e,t){this._options=t||{},this._internalSizesParams=null,this._tileWidth=0,this._tileHeight=0,asyncProxy.AsyncProxyFactory.initialize(this,e.scriptsToImport,"imageDecoderFramework.FetchManager",[e,t])}t.exports=r,asyncProxy.AsyncProxyFactory.addMethods(r,{close:[{isReturnPromise:!0}],setPrioritizerType:[],setFetchPrioritizerData:[],setIsProgressiveRequest:[],createMovableFetch:[{isReturnPromise:!0}],moveFetch:[],createRequest:[],manualAbortRequest:[]}),r.prototype.open=function(e){var t=this,i=asyncProxy.AsyncProxyFactory.getWorkerHelper(this);return i.callFunction("open",[e],{isReturnPromise:!0}).then(function(e){return t._internalSizesParams=e,t.getImageParams(),e})},r.prototype.getImageParams=function(){if(!this._internalSizesParams)throw"imageDecoderFramework error: not opened yet";return this._internalSizesParams},r.prototype.on=function(e,t){var i=this._options.transferablePathsOfDataCallback,r=asyncProxy.AsyncProxyFactory.getWorkerHelper(this),a=r.wrapCallback(t,e+"-callback",{isMultipleTimeCallback:!0,pathsToTransferables:i});return r.callFunction("on",[e,a])}},{}],18:[function(e,t,i){"use strict";function r(e,t){if(a.call(this),"function"!=typeof e.createLevelCalculator)throw"imageDecoderFramework error: Missing method image.createLevelCalculator()";asyncProxy.AsyncProxyFactory.initialize(this,e.scriptsToImport,"imageDecoderFramework.ImageDecoder",[{ctorName:e.ctorName},t]),this._image=e,this._levelCalculator=null,this._internalSizesParams=null,this._tileWidth=0,this._tileHeight=0}var a=e("image-params-retriever-proxy.js"),s=e("image-helper-functions.js");t.exports=r,r.prototype=Object.create(a.prototype),asyncProxy.AsyncProxyFactory.addMethods(r,{setFetchPrioritizerData:[],setDecodePrioritizerData:[],setFetchPrioritizerType:[],setDecodePrioritizerType:[],close:[{isReturnPromise:!0}],createMovableFetch:[{isReturnPromise:!0}],requestPixels:[{isReturnPromise:!0}]}),r.prototype.open=function(e){var t=this,i=asyncProxy.AsyncProxyFactory.getWorkerHelper(this);return i.callFunction("open",[e],{isReturnPromise:!0}).then(function(e){return t._internalSizesParams=e.sizesParams,t._tileWidth=e.applicativeTileWidth,t._tileHeight=e.applicativeTileHeight,t.getImageParams(),t._levelCalculator=t._image.createLevelCalculator(t),s.ensureLevelCalculator(t._levelCalculator),e})},r.prototype._getImageParamsInternal=function(){if(!this._internalSizesParams)throw"imageDecoderFramework error: not opened yet";return this._internalSizesParams},r.prototype.getTileWidth=function(){return this._getImageParamsInternal(),this._tileWidth},r.prototype.getTileHeight=function(){return this._getImageParamsInternal(),this._tileHeight},r.prototype.onFetcherEvent=function(e,t){var i,r=asyncProxy.AsyncProxyFactory.getWorkerHelper(this),a=(r.wrapCallback(t,"onFetcherEventCallback",{isMultipleTimeCallback:!0,pathsToTransferables:i}),[e,t]);r.callFunction("on",a)},r.prototype.requestPixelsProgressive=function(e,t,i,r,a){function s(e){n.freeCallback(h),i(e)}var o,n=asyncProxy.AsyncProxyFactory.getWorkerHelper(this),h=n.wrapCallback(t,"requestPixelsProgressiveCallback",{isMultipleTimeCallback:!0,pathsToTransferables:o}),l=n.wrapCallback(s,"requestPixelsProgressiveTerminatedCallback",{isMultipleTimeCallback:!1}),c=[e,h,l,r,a];n.callFunction("requestPixelsProgressive",c)}},{"image-helper-functions.js":13,"image-params-retriever-proxy.js":16}],19:[function(e,t,i){"use strict";function r(e,t){n.call(this),this._options=t||{},this._decodeWorkersLimit=this._options.decodeWorkersLimit||5,this._tileWidth=this._options.tileWidth||256,this._tileHeight=this._options.tileHeight||256,this._showLog=!!this._options.showLog,this._fetchManager=null,this._decodeDependencyWorkers=null,this._requestsDecodeJobsPool=null,this._movablesDecodeJobsPool=null,this._levelCalculator=null,this._fetchRequestId=0,this._movableStates=[],this._decoders=[],this._decodeScheduler=null,this._decodePrioritizer=null,this._prioritizerType=null,this._image=s.getOrCreateInstance(e,"image",r._imageExpectedMethods)}function a(){}t.exports=r;var s=e("image-helper-functions.js"),o=e("decode-jobs-pool.js"),n=e("image-params-retriever-proxy.js"),h=e("fetch-manager.js"),l=e("worker-proxy-fetch-manager.js"),c=e("worker-proxy-image-decoder.js");r.alignParamsToTilesAndLevel=s.alignParamsToTilesAndLevel,r.renderToCanvas=s.renderToCanvas,r.fromImage=function(e,t){var i=s.isIndirectCreationNeeded(e,"image",r._imageExpectedMethods);return i&&e.useWorker?new c(e,t):new r(e,t)},r._imageExpectedMethods=["opened","getLevelCalculator","getFetcher","getDecoderWorkersInputRetreiver"],r.prototype=Object.create(n.prototype),r.prototype.getTileWidth=function(){return this._tileWidth},r.prototype.getTileHeight=function(){return this._tileHeight},r.prototype.setFetchPrioritizerData=function(e){this._validateFetcher(),this._fetchManager.setFetchPrioritizerData(e)},r.prototype.setDecodePrioritizerData=function(e){if(this._validateDecoder(),null===this._decodePrioritizer)throw"imageDecoderFramework error: No decode prioritizer has been set";this._showLog&&console.log("setDecodePrioritizerData("+e+")");var t=Object.create(e);t.image=this,this._decodePrioritizer.setPrioritizerData(t)},r.prototype.setDecodePrioritizerType=function(e){if(null!==this._decodeScheduler)throw"imageDecoderFramework error: Cannot set prioritizer type at this time";this._prioritizerType=e},r.prototype.setFetchPrioritizerType=function(e){this._validateFetcher(),this._fetchManager.setPrioritizerType(e)},r.prototype.open=function(e){this._validateFetcher();var t=this,i=this._fetchManager.open(e);return i.then(function(e){return t._internalSizesParams=e,t._image.opened(t),t._levelCalculator=t._image.getLevelCalculator(),s.ensureLevelCalculator(t._levelCalculator),{sizesParams:e,applicativeTileWidth:t.getTileWidth(),applicativeTileHeight:t.getTileHeight()}})},r.prototype.close=function(){this._validateFetcher(),this._validateDecoder();for(var e=0;e<this._decoders.length;++e)this._decoders[e].terminate();var t=this;return this._fetchManager.close().then(function(){t._decodeDependencyWorkers.terminateInactiveWorkers()})},r.prototype.onFetcherEvent=function(e,t){this._validateFetcher(),this._fetchManager.on(e,t)},r.prototype.createMovableFetch=function(){this._validateFetcher(),this.getImageParams();var e=this;return this._fetchManager.createMovableFetch().then(function(t){return e._movableStates[t]={decodeJobsListenerHandle:null},t})},r.prototype.requestPixels=function(e){function t(t,o){a=t,s=o,n._requestsDecodeJobsPool.forkDecodeJobs(e,i,r)}function i(e){n._copyPixelsToAccumulatedResult(e,o)}function r(e){e?s("Request was aborted due to failure or priority"):a(o)}this._validateDecoder(),this.getImageParams();var a,s,o={},n=this,h=new Promise(t);return h},r.prototype.requestPixelsProgressive=function(e,t,i,r,a){this._validateDecoder(),this.getImageParams();var s,o=null;if(void 0===a)s=this._requestsDecodeJobsPool;else if(s=this._movablesDecodeJobsPool,o=this._movableStates[a],void 0===o)throw"imageDecoderFramework error: Movable handle does not exist";var n=s.forkDecodeJobs(e,t,i||function(){},r);void 0!==a?(null!==o.decodeJobsListenerHandle&&s.unregisterForkedJobs(o.decodeJobsListenerHandle),o.decodeJobsListenerHandle=n,this._fetchManager.moveFetch(a,e)):this._fetchManager.createRequest(++this._fetchRequestId,e)},r.prototype.getLevelCalculator=function(){return this._levelCalculator},r.prototype._validateFetcher=function(){if(null===this._fetchManager){var e=this._image.getFetcher(),t=s.isIndirectCreationNeeded(e,"fetcher",h.fetcherExpectedMethods);t&&e.useWorker?this._fetchManager=new l(e,this._options):this._fetchManager=new h(e,this._options)}},r.prototype._validateDecoder=function(){if(null===this._decodeDependencyWorkers){var e=s.createPrioritizer(this._decodeWorkersLimit,this._prioritizerType,"decode",this._showLog);null!==e.prioritizer?(this._decodeScheduler=new dependencyWorkers.DependencyWorkersTaskScheduler(this._decodeWorkersLimit,e.schedulerOptions),this._decodePrioritizer=e.prioritizer):(this._decodeScheduler=new resourceScheduler.LifoScheduler(a,this._decodeWorkersLimit,e.schedulerOptions),this._decodePrioritizer=null);var t=this._image.getDecoderWorkersInputRetreiver();this._decodeDependencyWorkers=new dependencyWorkers.SchedulerDependencyWorkers(this._decodeScheduler,t),this._requestsDecodeJobsPool=new o(this._decodeDependencyWorkers,this._decodePrioritizer,this._tileWidth,this._tileHeight),this._movablesDecodeJobsPool=new o(this._decodeDependencyWorkers,this._decodePrioritizer,this._tileWidth,this._tileHeight)}},r.prototype._getImageParamsInternal=function(){return this._internalSizesParams},r.prototype._copyPixelsToAccumulatedResult=function(e,t){var i=4,r=e.width*i,a=e.originalRequestWidth*i;if(void 0===t.pixels){var s=a*e.originalRequestHeight;t.pixels=new Uint8Array(s),t.xInOriginalRequest=0,t.yInOriginalRequest=0;var o=e.originalRequestWidth;t.originalRequestWidth=o,t.width=o;var n=e.originalRequestHeight;t.originalRequestHeight=n,t.height=n}t.allRelevantBytesLoaded=e.allRelevantBytesLoaded;for(var h=0,l=e.xInOriginalRequest*i+e.yInOriginalRequest*a,c=0;c<e.height;++c){var u=e.pixels.subarray(h,h+r);t.pixels.set(u,l),h+=r,l+=a}}},{"decode-jobs-pool.js":7,"fetch-manager.js":10,"image-helper-functions.js":13,"image-params-retriever-proxy.js":16,"worker-proxy-fetch-manager.js":17,"worker-proxy-image-decoder.js":18}],20:[function(e,t,i){"use strict";function r(){return{initialize:function(e){if(this._options=e||{},void 0!==this._options.latLngBounds){this._options={};for(var t in e)this._options[t]=e[t];this._options.cartographicBounds={west:e.latLngBounds.getWest(),east:e.latLngBounds.getEast(),south:e.latLngBounds.getSouth(),north:e.latLngBounds.getNorth()}}this._targetCanvas=null,this._canvasPosition=null,this._canvasUpdatedCallbackBound=this._canvasUpdatedCallback.bind(this),this._imageViewer=null,this._exceptionCallback=null},setExceptionCallback:function(e){this._exceptionCallback=e,null!==this._imageViewer&&this._imageViewer.setExceptionCallback(e)},_createImage:function(){null===this._imageViewer&&(this._imageViewer=new a(this._options.imageDecoder,this._canvasUpdatedCallbackBound,this._options),null!==this._exceptionCallback&&this._imageViewer.setExceptionCallback(this._exceptionCallback),this._imageViewer.open(this._options.openArg)["catch"](this._exceptionCallback))},onAdd:function(e){if(void 0!==this._map)throw"imageDecoderFramework error: Cannot add this layer to two maps";this._map=e,this._createImage(),this._targetCanvas=L.DomUtil.create("canvas","image-decoder-layer-canvas leaflet-zoom-animated"),this._imageViewer.setTargetCanvas(this._targetCanvas),this._canvasPosition=null,e.getPanes().mapPane.appendChild(this._targetCanvas),e.on("viewreset",this._moved,this),e.on("move",this._moved,this),L.Browser.any3d&&e.on("zoomanim",this._animateZoom,this),this._moved()},onRemove:function(e){if(e!==this._map)throw"imageDecoderFramework error: Removed from wrong map";e.off("viewreset",this._moved,this),e.off("move",this._moved,this),e.off("zoomanim",this._animateZoom,this),e.getPanes().mapPane.removeChild(this._targetCanvas),this._targetCanvas=null,this._canvasPosition=null,this._map=void 0,this._imageViewer.close(),this._imageViewer=null},_moved:function(){this._moveCanvases();var e=s(this._map);this._imageViewer.updateViewArea(e)},_canvasUpdatedCallback:function(e){null!==e&&(this._canvasPosition=e,this._moveCanvases())},_moveCanvases:function(){if(null!==this._canvasPosition){var e=this._canvasPosition.west,t=this._canvasPosition.east,i=this._canvasPosition.south,r=this._canvasPosition.north,a=this._map.latLngToLayerPoint([r,e]),s=this._map.latLngToLayerPoint([i,t]),o=s.subtract(a);L.DomUtil.setPosition(this._targetCanvas,a),this._targetCanvas.style.width=o.x+"px",this._targetCanvas.style.height=o.y+"px"}},_animateZoom:function(e){if(null!==this._canvasPosition){var t=this._canvasPosition.west,i=this._canvasPosition.east,r=this._canvasPosition.south,a=this._canvasPosition.north,s=this._map._latLngToNewLayerPoint([a,t],e.zoom,e.center),o=this._map._latLngToNewLayerPoint([r,i],e.zoom,e.center),n=this._map.getZoomScale(e.zoom),h=o.subtract(s),l=h.multiplyBy(.5*(1-1/n)),c=s.add(l);this._targetCanvas.style[L.DomUtil.TRANSFORM]=L.DomUtil.getTranslateString(c)+" scale("+n+") "}}}}var a=e("image-decoder-viewer.js"),s=e("leaflet-frustum-calculator.js");self.L?t.exports=L.Class.extend(r()):t.exports=function(){throw new Error("imageDecoderFramework error: Cannot instantiate ImageDecoderRegionLayer: No Leaflet namespace in scope")}},{"image-decoder-viewer.js":15,"leaflet-frustum-calculator.js":21}],21:[function(e,t,i){"use strict";var r=e("image-helper-functions.js");t.exports=function(e){var t=e.getSize(),i=e.getBounds(),a={west:i.getWest(),east:i.getEast(),south:i.getSouth(),north:i.getNorth()},s=r.calculateFrustum2DFromBounds(a,t);return s}},{"image-helper-functions.js":13}],22:[function(e,t,i){"use strict";function r(){r.prototype.start=function(e){for(var t=e.imagePartParams,i=t.maxXExclusive-t.minX,r=t.maxYExclusive-t.minY,a=new ImageData(i,r),s=[],o={minX:0,minY:0,maxXExclusive:0,maxYExclusive:0,width:e.tileWidth,height:e.tileHeight},n={minX:0,minY:0,maxXExclusive:0,maxYExclusive:0,width:0,height:0},h={x:0,y:0},l={tileX:0,
tileY:0,level:0,position:o,content:null},c=0;c<e.tileIndices.length;++c)o.minX=e.tileIndices[c].tileX*e.tileWidth,o.minY=e.tileIndices[c].tileY*e.tileHeight,o.maxXExclusive=o.minX+e.tileWidth,o.maxYExclusive=o.minY+e.tileHeight,n.minX=Math.max(o.minX,t.minX),n.minY=Math.max(o.minY,t.minY),n.maxXExclusive=Math.min(o.maxXExclusive,t.maxXExclusive),n.maxYExclusive=Math.min(o.maxYExclusive,t.maxYExclusive),n.width=n.maxXExclusive-n.minX,n.height=n.maxYExclusive-n.minY,h.x=n.minX-t.minX,h.y=n.minY-t.minY,l.tileY=e.tileIndices[c].tileY,l.tileX=e.tileIndices[c].tileX,l.level=e.tileIndices[c].level,l.content=e.tileContents[c],s.push(this.decodeRegion(a,h,n,l));return Promise.all(s).then(function(){return a})},r.prototype.decodeRegion=function(e,t,i,r){throw"imageDecoderFramework error: decodeRegion is not implemented"}}t.exports=r},{}],23:[function(e,t,i){"use strict";function r(e){n.call(this,e),this._gridFetcherBaseCache=[],this._events={data:[],"tile-terminated":[]}}function a(){var e=this;e.isPendingStop=!0,e.self._checkIfShouldStop(e)}function s(){var e=this;e.isPendingStop=!1,e.self._changeSingleListenerCountOfOverlappingFetches(e,-1),e.isActive=!0}function o(){var e=this;if(e.isActive)throw"imageDecoderFramework error: Unexpected grid fetch terminated of a still active fetch";for(var t=0;t<e.tileListeners.length;++t)e.tileListeners[t].tileContext.dependFetches.remove(e.tileListeners[t].iterator)}t.exports=r;var n=e("simple-fetcher-base.js"),h=e("grid-image-base.js"),l=e("linked-list.js"),c=0,u=1,d=3;r.prototype=Object.create(n.prototype),r.prototype.fetchTile=function(e,t,i,r){throw"imageDecoderFramework error: GridFetcherBase.fetchTile is not implemented by inheritor"},r.prototype.on=function(e,t){var i=this._events[e];if(!i)throw"imageDecoderFramework error: Unexpected event "+e+" in GridFetcherBase";i.push(t)},r.prototype.startFetch=function(e,t){var i={activeTilesCount:0,activeTilesCountWithSingleListener:0,tileListeners:[],fetchContext:e,isPendingStop:!1,isActive:!1,imagePartParams:t,self:this};e.on("stop",a,i),e.on("resume",s,i),e.on("terminate",o,i);var r=[],n=[],l=[],c=h.getTilesRange(this.getImageParams(),t);i.activeTilesCount=(c.maxTileX-c.minTileX)*(c.maxTileY-c.minTileY);for(var u=c.minTileX;u<c.maxTileX;++u)for(var d=c.minTileY;d<c.maxTileY;++d){var m=this._addToCache(u,d,i);null!==m&&(r.push(u),n.push(d),l.push(m))}s.call(i);for(var _=0;_<r.length;++_)this._loadTile(i.imagePartParams.level,r[_],n[_],l[_])},r.prototype._checkIfShouldStop=function(e){!e.isPendingStop||e.activeTilesCountWithSingleListener>0||(e.isPendingStop=!1,e.isActive=!1,this._changeSingleListenerCountOfOverlappingFetches(e,1),e.fetchContext.stopped())},r.prototype._changeSingleListenerCountOfOverlappingFetches=function(e,t){for(var i=0;i<e.tileListeners.length;++i){var r=e.tileListeners[i].tileContext;this._changeSingleListenerCount(r.dependFetches,t)}},r.prototype._decrementActiveTiles=function(e){for(var t=e.getFirstIterator();null!==t;){var i=e.getValue(t);t=e.getNextIterator(t),--i.activeTilesCount,0===i.activeTilesCount&&(i.isActive=!1,i.fetchContext.done())}},r.prototype._changeSingleListenerCount=function(e,t){for(var i=null,r=!1,a=e.getFirstIterator();null!==a;){var s=e.getValue(a);if(a=e.getNextIterator(a),s.isActive)if(null===i)i=s,r=!0;else if(r)return}null!==i&&(i.activeTilesCountWithSingleListener+=t,this._checkIfShouldStop(i))},r.prototype._loadTile=function(e,t,i,r){var a={fetchWaitTask:!0,tileX:t,tileY:i,level:e},s=this,o={dataReady:function(o){if(r.tileState!==c&&r.tileState!==u)throw"imageDecoderFramework error: either stopped or already terminated in GridFetcherBase.fetchTile()";if(s._gridFetcherBaseCache[e][t][i]!==r)throw"imageDecoderFramework error: Unexpected fetch in GridFetcherBase.gridFetcherBaseCache";for(var n={tileKey:a,tileContent:o},h=0;h<s._events.data.length;++h)s._events.data[h](n)},terminate:function(){if(r.tileState!==c&&r.tileState!==u)throw"imageDecoderFramework error: either stopped or already terminated in GridFetcherBase.fetchTile()";if(s._gridFetcherBaseCache[e][t][i]!==r)throw"imageDecoderFramework error: Unexpected fetch in GridFetcherBase.gridFetcherBaseCache";r.tileState=d,s._gridFetcherBaseCache[e][t][i]=null;for(var o=0;o<s._events["tile-terminated"].length;++o)s._events["tile-terminated"][o](a);s._decrementActiveTiles(r.dependFetches),s._changeSingleListenerCount(r.dependFetches,-1)}};this.fetchTile(e,t,i,o)},r.prototype._addToCache=function(e,t,i){var r=this._gridFetcherBaseCache[i.imagePartParams.level];r||(r=[],this._gridFetcherBaseCache[i.imagePartParams.level]=r);var a=r[e];a||(a=[],r[e]=a);var s=a[t],o=!1;return s||(s={dependFetches:new l,stopListeners:[],resumeListeners:[],tileState:c},a[t]=s,++i.activeTilesCountWithSingleListener,o=!0),i.tileListeners.push({tileContext:s,iterator:s.dependFetches.add(i)}),o?s:null}},{"grid-image-base.js":24,"linked-list.js":14,"simple-fetcher-base.js":26}],24:[function(e,t,i){"use strict";function r(e){this._fetcher=e,this._imageParams=null,this._waitingFetches={},this._levelCalculator=null}var a=e("grid-level-calculator.js");t.exports=r;var s=0,o=1;r.prototype.opened=function(e){this._imageParams=e.getImageParams(),e.onFetcherEvent("data",this._onDataFetched.bind(this)),e.onFetcherEvent("tile-terminated",this._onTileTerminated.bind(this))},r.prototype.getLevelCalculator=function(){return null===this._levelCalculator&&(this._levelCalculator=new a(this._imageParams)),this._levelCalculator},r.prototype.getDecodeWorkerTypeOptions=function(){throw"imageDecoderFramework error: GridImageBase.getDecodeWorkerTypeOptions is not implemented by inheritor"},r.prototype.getDecoderWorkersInputRetreiver=function(){return this},r.prototype.decodeTaskStarted=function(e){var t=this;e.on("allDependTasksTerminated",function(){t.dataReadyForDecode(e),e.terminate()})},r.prototype.dataReadyForDecode=function(e){e.dataReady({tileContents:e.dependTaskResults,tileIndices:e.dependTaskKeys,imagePartParams:e.key,tileWidth:this._imageParams.tileWidth,tileHeight:this._imageParams.tileHeight},o,!0)},r.prototype.getFetcher=function(){return this._fetcher},r.prototype.getWorkerTypeOptions=function(e){if(e===s)return null;if(e===o)return this.getDecodeWorkerTypeOptions();throw"imageDecoderFramework internal error: GridImageBase.getTaskTypeOptions got unexpected task type "+e},r.prototype.getKeyAsString=function(e){return e.fetchWaitTask?"fetchWait:"+e.tileX+","+e.tileY+":"+e.level:JSON.stringify(e)},r.prototype.taskStarted=function(e){if(e.key.fetchWaitTask){var t=this.getKeyAsString(e.key);return void(this._waitingFetches[t]=e)}null===this._imageParams&&(this._imageParams=this.getImageParams());for(var i=e.key,a=r.getTilesRange(this._imageParams,i),s=a.minTileX;s<a.maxTileX;++s)for(var o=a.minTileY;o<a.maxTileY;++o)e.registerTaskDependency({fetchWaitTask:!0,tileX:s,tileY:o,level:i.level});this.decodeTaskStarted(e)},r.prototype._onDataFetched=function(e){var t=this.getKeyAsString(e.tileKey),i=this._waitingFetches[t];i&&i.dataReady(e.tileContent,s)},r.prototype._onTileTerminated=function(e){var t=this.getKeyAsString(e),i=this._waitingFetches[t];i&&(i.terminate(),this._waitingFetches[t]=null)},r.getTilesRange=function(e,t){var i=e.imageWidth*Math.pow(2,t.level-e.imageLevel),r=e.imageHeight*Math.pow(2,t.level-e.imageLevel),a=Math.ceil(i/e.tileWidth),s=Math.ceil(r/e.tileHeight);return{minTileX:Math.max(0,Math.floor(t.minX/e.tileWidth)),minTileY:Math.max(0,Math.floor(t.minY/e.tileHeight)),maxTileX:Math.min(a,Math.ceil(t.maxXExclusive/e.tileWidth)),maxTileY:Math.min(s,Math.ceil(t.maxYExclusive/e.tileHeight))}}},{"grid-level-calculator.js":25}],25:[function(e,t,i){"use strict";function r(e){this._imageParams=e}t.exports=r,r.prototype.getLevelWidth=function(e){var t=this._imageParams.imageWidth*Math.pow(2,e-this._imageParams.imageLevel);return t},r.prototype.getLevelHeight=function(e){var t=this._imageParams.imageHeight*Math.pow(2,e-this._imageParams.imageLevel);return t},r.prototype.getLevel=function(e){var t=Math.log(2),i=Math.log(e.screenWidth/(e.maxXExclusive-e.minX))/t,r=Math.log(e.screenHeight/(e.maxYExclusive-e.minY))/t,a=Math.ceil(Math.min(i,r));return a+=this._imageParams.imageLevel}},{}],26:[function(e,t,i){"use strict";function r(e){this._maxActiveFetchesInMovableFetch=(e||{}).maxActiveFetchesInMovableFetch||2,this._indirectCloseIndication={isCloseRequested:!1}}var a=e("simple-movable-fetch.js");t.exports=r,r.prototype.startMovableFetch=function(e,t){var i=new a(this,this._indirectCloseIndication,e,this._maxActiveFetchesInMovableFetch);i.start(t)},r.prototype.close=function(){if(this.startMovableFetch!==r.prototype.startMovableFetch)throw"imageDecoderFramework error: Must override Fetcher.close() when Fetcher.startMovableFetch() was overriden";return this._indirectCloseIndication.isCloseRequested=!0,Promise.resolve()}},{"simple-movable-fetch.js":27}],27:[function(e,t,i){"use strict";function r(e,t,i,r){this._fetcher=e,this._indirectCloseIndication=t,this._movableFetchContext=i,this._maxActiveFetchesInMovableFetch=r,this._lastFetch=null,this._activeFetchesInMovableFetch=0,this._pendingImagePartParams=null,this._movableState=n,this._isProgressive=!1,this._isProgressiveChangedCalled=!1,i.on("move",this._onMove,this),i.on("terminate",this._onTerminated,this),i.on("isProgressiveChanged",this._onIsProgressiveChanged,this),i.on("stop",this._onStop,this),i.on("resume",this._onResume,this)}function a(){var e=this,t=e.self;if(e.state!==l)throw"imageDecoderFramework error: Unexpected state of fetch "+e.state+" on stopped";t._isLastFetch(e)?(e.state=c,t._switchState(c,l),t._movableFetchContext.stopped()):t._singleFetchStopped(e)}function s(){var e=this,t=e.self;if(e.state!==h&&e.state!==l)throw"imageDecoderFramework error: Unexpected state of fetch "+e.state+" on done";e.state=u,t._isLastFetch(e)&&(t._switchState(n,h,l),t._movableFetchContext.done()),t._singleFetchStopped(e)}var o=e("fetch-context-api.js");t.exports=r;var n=1,h=2,l=3,c=4,u=5;r.prototype.start=function(e){this._onMove(e)},r.prototype._onIsProgressiveChanged=function(e){this._isProgressive=e;var t=this._getLastFetchActive();null!==t?t._onEvent("isProgressiveChanged",e):this._isProgressiveChangedCalled=!0},r.prototype._onStop=function(e){this._switchState(l,h);var t=this._getLastFetchActive();null!==t&&t._onEvent("stop",e)},r.prototype._onResume=function(){if(this._switchState(h,c,l),null===this._lastFetch)throw"imageDecoderFramework error: resuming non stopped fetch";this._isProgressiveChangedCalled&&(this._isProgressiveChangedCalled=!1,this._lastFetch._onEvent("isProgressiveChanged",this._isProgressive)),this._lastFetch._onEvent("resume")},r.prototype._onTerminated=function(e){throw"imageDecoderFramework error: Unexpected termination of movable fetch"},r.prototype._onMove=function(e){this._pendingImagePartParams=e,this._movableState=h,this._tryStartPendingFetch()},r.prototype._tryStartPendingFetch=function(){if(!(this._indirectCloseIndication.isCloseRequested||this._activeFetchesInMovableFetch>=this._maxActiveFetchesInMovableFetch||null===this._pendingImagePartParams||this._movableState!==h)){var e={imagePartParams:this._pendingImagePartParams,state:h,fetchContext:null,self:this};this._pendingImagePartParams=null,++this._activeFetchesInMovableFetch,e.fetchContext=new o,e.fetchContext.on("internalStopped",a,e),e.fetchContext.on("internalDone",s,e),this._fetcher.startFetch(e.fetchContext,e.imagePartParams)}},r.prototype._singleFetchStopped=function(e,t){--this._activeFetchesInMovableFetch,this._lastFetch=null,e.state=u,this._tryStartPendingFetch()},r.prototype._getLastFetchActive=function(){return this._movableState===c||null===this._lastFetch?null:this._lastFetch.state===h?this._lastFetch.fetchContext:null},r.prototype._switchState=function(e,t,i,r){if(this._movableState!==t&&this._movableState!==i&&this._movableState!==r)throw"imageDecoderFramework error: Unexpected state "+this._movableState+", expected "+t+" or "+i+" or "+r;this._movableState=e},r.prototype._isLastFetch=function(e){return this._lastFetch===e&&null===this._pendingImagePartParams}},{"fetch-context-api.js":8}]},{},[5])(5)});