File: //data/geometra-4-host-prod/webviewer/core/StreamingPartRetriever.chunk.js
/** Notice * This file contains works from many authors under various (but compatible) licenses. Please see legal.txt for more information. **/
(function(){(window.wpCoreControlsBundle=window.wpCoreControlsBundle||[]).push([[12],{351:function(ia,da,h){h.r(da);var ca=h(3),aa=h(0);h.n(aa);var fa=h(1),ea=h(117);ia=h(34);var z=h(73),x=h(145),n=h(49),f=h(198);h=h(297);var y=window,w=function(){function e(e,h,r){var w=-1===e.indexOf("?")?"?":"&";switch(h){case n.a.NEVER_CACHE:this.url=e+w+"_="+Object(aa.uniqueId)();break;default:this.url=e}this.yf=r;this.request=new XMLHttpRequest;this.request.open("GET",this.url,!0);this.request.setRequestHeader("X-Requested-With",
"XMLHttpRequest");this.request.overrideMimeType?this.request.overrideMimeType("text/plain; charset=x-user-defined"):this.request.setRequestHeader("Accept-Charset","x-user-defined");this.status=f.a.NOT_STARTED}e.prototype.start=function(h,n){var r=this,w=this,x=this.request,y;w.Ps=0;h&&Object.keys(h).forEach(function(e){r.request.setRequestHeader(e,h[e])});n&&(this.request.withCredentials=n);this.fy=setInterval(function(){var h=0===window.document.URL.indexOf("file:///");h=200===x.status||h&&0===x.status;
if(x.readyState!==f.b.DONE||h){try{x.responseText}catch(pa){return}w.Ps<x.responseText.length&&(y=w.J0())&&w.trigger(e.Events.DATA,[y]);0===x.readyState&&(clearInterval(w.fy),w.trigger(e.Events.DONE))}else clearInterval(w.fy),w.trigger(e.Events.DONE,["Error received return status "+x.status])},1E3);this.request.send(null);this.status=f.a.STARTED};e.prototype.J0=function(){var f=this.request,h=f.responseText;if(0!==h.length)if(this.Ps===h.length)clearInterval(this.fy),this.trigger(e.Events.DONE);else return h=
Math.min(this.Ps+3E6,h.length),f=y.OK(f,this.Ps,!0,h),this.Ps=h,f};e.prototype.abort=function(){clearInterval(this.fy);var h=this;this.request.onreadystatechange=function(){Object(fa.h)("StreamingRequest aborted");h.status=f.a.ABORTED;return h.trigger(e.Events.ABORTED)};this.request.abort()};e.prototype.finish=function(){var h=this;this.request.onreadystatechange=function(){h.status=f.a.SUCCESS;return h.trigger(e.Events.DONE)};this.request.abort()};e.Events={DONE:"done",DATA:"data",ABORTED:"aborted"};
return e}();Object(ia.b)(w);var e;(function(e){e[e.LOCAL_HEADER=0]="LOCAL_HEADER";e[e.FILE=1]="FILE";e[e.CENTRAL_DIR=2]="CENTRAL_DIR"})(e||(e={}));var r=function(f){function h(){var h=f.call(this)||this;h.buffer="";h.state=e.LOCAL_HEADER;h.ME=4;h.Yj=null;h.Jp=ea.c;h.gl={};return h}Object(ca.c)(h,f);h.prototype.F0=function(f){var n;for(f=this.buffer+f;f.length>=this.Jp;)switch(this.state){case e.LOCAL_HEADER:this.Yj=n=this.M0(f.slice(0,this.Jp));if(n.gq!==ea.g)throw Error("Wrong signature in local header: "+
n.gq);f=f.slice(this.Jp);this.state=e.FILE;this.Jp=n.JA+n.sn+n.Ur+this.ME;this.trigger(h.Events.HEADER,[n]);break;case e.FILE:this.Yj.name=f.slice(0,this.Yj.sn);this.gl[this.Yj.name]=this.Yj;n=this.Jp-this.ME;var r=f.slice(this.Yj.sn+this.Yj.Ur,n);this.trigger(h.Events.FILE,[this.Yj.name,r,this.Yj.ZA]);f=f.slice(n);if(f.slice(0,this.ME)===ea.h)this.state=e.LOCAL_HEADER,this.Jp=ea.c;else return this.state=e.CENTRAL_DIR,!0}this.buffer=f;return!1};h.Events={HEADER:"header",FILE:"file"};return h}(x.a);
Object(ia.b)(r);ia=function(e){function f(f,h,n,x,y){n=e.call(this,f,n,x)||this;n.url=f;n.stream=new w(f,h);n.zd=new r;n.RM=window.createPromiseCapability();n.gN={};n.yf=y;return n}Object(ca.c)(f,e);f.prototype.Ct=function(e){var f=this;this.request([this.Sh,this.Zi,this.Rh]);this.stream.on(w.Events.DATA,function(h){try{if(f.zd.F0(h))return f.stream.finish()}catch(ka){throw f.stream.abort(),f.Rr(ka),e(ka),ka;}});this.stream.on(w.Events.DONE,function(h){f.o0=!0;f.RM.resolve();h&&(f.Rr(h),e(h))});this.zd.on(r.Events.HEADER,
Object(aa.bind)(this.fN,this));this.zd.on(r.Events.FILE,Object(aa.bind)(this.P0,this));return this.stream.start(this.yf,this.withCredentials)};f.prototype.LK=function(e){var f=this;this.RM.promise.then(function(){e(Object.keys(f.zd.gl))})};f.prototype.Gl=function(){return!0};f.prototype.request=function(e){var f=this;this.o0&&e.forEach(function(e){f.gN[e]||f.g4(e)})};f.prototype.fN=function(){};f.prototype.abort=function(){this.stream&&this.stream.abort()};f.prototype.g4=function(e){this.trigger(z.a.Events.PART_READY,
[{Wa:e,error:"Requested part not found",gh:!1,wf:!1}])};f.prototype.P0=function(e,f,h){this.gN[e]=!0;this.trigger(z.a.Events.PART_READY,[{Wa:e,data:f,gh:!1,wf:!1,error:null,Mc:h}])};return f}(z.a);Object(h.a)(ia);Object(h.b)(ia);da["default"]=ia}}]);}).call(this || window)