import{__awaiter as t,__generator as i}from"tslib";import n from"localforage";import r from"../model/scene/ViewPoint";import e from"../core/Instance";import{TIMESPAN_SOON as o}from"../core/Constant";import s from"../libs/imgCompress";var u=function(){function u(t){this.t="default",this.i=n.o({name:"vps_"+this.t}),this.s=new Map,this.u=t,this.h()}return u.prototype.v=function(){return t(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(i){return n=(t=this).s,r=t.i,n.clear(),r.m((function(t){n.set(t.name,t)})),[2]}))}))},u.prototype.h=function(t){void 0===t&&(t="default"),this.i=n.o({name:"vps_"+t}),this.v()},u.prototype.create=function(n,e,o,u){return void 0===n&&(n="default"),void 0===e&&(e={}),void 0===o&&(o=!0),void 0===u&&(u=this.u.p),t(this,void 0,void 0,(function(){var t,c,a,f,h,v;return i(this,(function(i){switch(i.label){case 0:return t=(e=e||{}).l,c=e.g,a=e.C,(f=new r).position=u.position.clone(),f.direction=u.direction.clone(),f._=u._.clone(),f.name=n,c?(h=this.u.I.j.toDataURL("image/jpeg",.5),v=f,[4,s(h,t||100)]):[3,2];case 1:v.M=i.P(),i.label=2;case 2:return a&&a.status&&(f.C=a),o&&this.update(f),[2,f]}}))}))},u.prototype.update=function(n){return t(this,void 0,void 0,(function(){var t,r,e;return i(this,(function(i){switch(i.label){case 0:return r=(t=this).s,e=t.i,r.set(n.name,n),[4,e.setItem(n.name,n)];case 1:return[2,i.P()]}}))}))},u.prototype.find=function(t){return this.s.get(t)},u.prototype.list=function(){for(var t,i=this.s.values(),n=[];t=i.next().value;)n.push(t);return n},u.prototype.delete=function(n){return t(this,void 0,void 0,(function(){var t,r,e;return i(this,(function(i){switch(i.label){case 0:return r=(t=this).s,e=t.i,r.delete(n),[4,e.removeItem(n)];case 1:return i.P(),[2]}}))}))},u.prototype.V=function(n,r){return void 0===r&&(r=o),t(this,void 0,void 0,(function(){var t,o,s,u,c;return i(this,(function(i){switch(i.label){case 0:return[4,this.find(n)];case 1:return t=i.P(),o=this.u.p,t&&o?[4,e.k()]:[2];case 2:return s=i.P(),(u=t.C)&&u.status?[4,e.q()]:[3,6];case 3:return c=i.P(),[4,e.A()];case 4:return[4,i.P().B(u.position,c.D,u.direction,u.value)];case 5:i.P(),i.label=6;case 6:return s.F(o.position,t.position,r),s.F(o.direction,t.direction,r),s.F(o._,t._,r),[2]}}))}))},u}();export default u;