@realsee/five 5.0.0-alpha.58 → 5.0.0-alpha.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/classes/five.AnimationFrameLoop.html +4 -4
- package/docs/classes/five.BVH.html +4 -4
- package/docs/classes/five.BVHNode.html +4 -4
- package/docs/classes/five.BVHVector3.html +4 -4
- package/docs/classes/five.Camera.html +4 -4
- package/docs/classes/five.Five.html +4 -4
- package/docs/classes/five.InternalWebGLRenderer.html +4 -4
- package/docs/classes/five.Model.html +4 -4
- package/docs/classes/five.NetworkSubscribe.html +4 -4
- package/docs/classes/five.PBMContainer.html +4 -4
- package/docs/classes/five.PBMGroup.html +4 -4
- package/docs/classes/five.PBMMaterial.html +4 -4
- package/docs/classes/five.PBMMesh.html +4 -4
- package/docs/classes/five.Scene.html +4 -4
- package/docs/classes/five.Subscribe.html +4 -4
- package/docs/classes/five.Work.html +4 -4
- package/docs/classes/gltf_loader.GLTFLoader.html +4 -4
- package/docs/classes/gltf_loader.GLTFObject.html +4 -4
- package/docs/classes/line.Line.html +4 -4
- package/docs/classes/line.LineGeometry.html +4 -4
- package/docs/classes/line.LineMaterial.html +4 -4
- package/docs/classes/line.LineSegmentsGeometry.html +4 -4
- package/docs/classes/line.THREE_Line2.html +4 -4
- package/docs/classes/line.THREE_LineSegments2.html +4 -4
- package/docs/classes/react.Store.html +4 -4
- package/docs/classes/server.BVH.html +4 -4
- package/docs/classes/server.BVHNode.html +4 -4
- package/docs/classes/server.BVHVector3.html +4 -4
- package/docs/classes/server.Model.html +4 -4
- package/docs/classes/server.PBMGroup.html +4 -4
- package/docs/classes/server.PBMMesh.html +4 -4
- package/docs/classes/sticker.Sticker.html +4 -4
- package/docs/index.html +4 -4
- package/docs/interfaces/five.AddableObject.html +4 -4
- package/docs/interfaces/five.AnimationFrame.html +4 -4
- package/docs/interfaces/five.BVHIntersect.html +4 -4
- package/docs/interfaces/five.CameraPose.html +4 -4
- package/docs/interfaces/five.DepthPanoramaControllerCustomInitArgs.html +4 -4
- package/docs/interfaces/five.EventCallback.html +4 -4
- package/docs/interfaces/five.FiveInitArgs.html +4 -4
- package/docs/interfaces/five.FloorplanControllerCustomInitArgs.html +4 -4
- package/docs/interfaces/five.ImageOptions.html +4 -4
- package/docs/interfaces/five.ImageURLOptions.html +4 -4
- package/docs/interfaces/five.IntersectMeshInterface.html +4 -4
- package/docs/interfaces/five.Intersection.html +4 -4
- package/docs/interfaces/five.ModelControllerCustomInitArgs.html +4 -4
- package/docs/interfaces/five.ModelEventCallback.html +4 -4
- package/docs/interfaces/five.MovePanoOptions.html +4 -4
- package/docs/interfaces/five.PBMPanoPicture.html +4 -4
- package/docs/interfaces/five.PBMPanoVideo.html +4 -4
- package/docs/interfaces/five.PBMParameters.html +4 -4
- package/docs/interfaces/five.PanoCircleMeshInterface.html +4 -4
- package/docs/interfaces/five.PanoramaControllerCustomInitArgs.html +4 -4
- package/docs/interfaces/five.PanoramaLikeControllerCustomInitArgs.html +4 -4
- package/docs/interfaces/five.Pose.html +4 -4
- package/docs/interfaces/five.Scissor.html +4 -4
- package/docs/interfaces/five.State.html +4 -4
- package/docs/interfaces/five.SubscribeMixinType.emit.html +4 -4
- package/docs/interfaces/five.SubscribeMixinType.hasListener.html +4 -4
- package/docs/interfaces/five.SubscribeMixinType.off.html +4 -4
- package/docs/interfaces/five.SubscribeMixinType.on.html +4 -4
- package/docs/interfaces/five.SubscribeMixinType.once.html +4 -4
- package/docs/interfaces/five.TextureOptions.html +4 -4
- package/docs/interfaces/five.TopviewControllerCustomInitArgs.html +4 -4
- package/docs/interfaces/five.VRPanoramaControllerCustomInitArgs.html +4 -4
- package/docs/interfaces/five.WorkCubeImage.html +4 -4
- package/docs/interfaces/five.WorkImage.html +4 -4
- package/docs/interfaces/five.WorkInitial.html +4 -4
- package/docs/interfaces/five.WorkModel.html +4 -4
- package/docs/interfaces/five.WorkObserver.html +4 -4
- package/docs/interfaces/five.WorkTile.html +4 -4
- package/docs/interfaces/five.WorkVideo.html +4 -4
- package/docs/interfaces/gltf_loader.GLTF.html +4 -4
- package/docs/interfaces/react.FiveActionReactCallbacks.html +4 -4
- package/docs/interfaces/react.FiveInjectionTypes.html +4 -4
- package/docs/interfaces/react.PropTypeOfFiveFeatures.html +4 -4
- package/docs/interfaces/server.BVHIntersect.html +4 -4
- package/docs/interfaces/server.Intersection.html +4 -4
- package/docs/interfaces/server.ModelEventCallback.html +4 -4
- package/docs/interfaces/sticker.IntersectionLike.html +4 -4
- package/docs/modules/five.SubscribeMixinType.html +4 -4
- package/docs/modules/five.html +4 -4
- package/docs/modules/gltf_loader.html +4 -4
- package/docs/modules/line.html +4 -4
- package/docs/modules/react.html +4 -4
- package/docs/modules/server.html +4 -4
- package/docs/modules/sticker.html +4 -4
- package/docs/modules.html +4 -4
- package/five/index.js +2 -2
- package/gltf-loader/index.js +1 -1
- package/line/index.js +1 -1
- package/package.json +1 -1
- package/react/index.js +1 -1
- package/server/index.js +1 -1
- package/sticker/index.js +1 -1
- package/umd/five.js +1 -1
package/five/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @realsee/five
|
|
3
3
|
*
|
|
4
4
|
* Generated: 2021-12-01
|
|
5
|
-
* Version: 5.0.0-alpha.
|
|
5
|
+
* Version: 5.0.0-alpha.59
|
|
6
6
|
*
|
|
7
7
|
* Terms:
|
|
8
8
|
* Realsee SDK License Agreement
|
|
@@ -364,7 +364,7 @@ var L="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";functio
|
|
|
364
364
|
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ */
|
|
365
365
|
function W(e,t){return new h(e,t)}function q(e,t,i){for(var n="",r=0;n.length<t;)n+=i(String.fromCharCode.apply(String,e.concat([(4278190080&r)>>24,(16711680&r)>>16,(65280&r)>>8,255&r]))),r+=1;return n}function K(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function Z(e,t,i){for(var n="",r=0;n.length<t;)n+=i(e+String.fromCharCode.apply(String,[(4278190080&r)>>24,(16711680&r)>>16,(65280&r)>>8,255&r])),r+=1;return n}function X(e){for(var t="",i=0;i<e.length;i++){var n=e[i].toString(16);1==n.length&&(n="0"+n),t+=n}return t}function J(e){return X(function(e){for(var t=new Array,i=0;i<e.length;i++)t[i]=e.charCodeAt(i);return t}(e))}function $(e){return e.length%4==2?e+="==":e.length%4==3&&(e+="="),e=(e=e.replace(/-/g,"+")).replace(/_/g,"/")}function ee(e){return e.length%2==1&&(e="0"+e),function(e){return(e=(e=e.replace(/\=/g,"")).replace(/\+/g,"-")).replace(/\//g,"_")}(k(e))}function te(e){return C($(e))}function ie(e){return function(e){return e.replace(/%/g,"")}(function(e){for(var t=encodeURIComponent(e),i="",n=0;n<t.length;n++)"%"==t[n]?(i+=t.substr(n,3),n+=2):i=i+"%"+J(t[n]);return i}(e))}function ne(e){return decodeURIComponent(function(e){return e.replace(/(..)/g,"%$1")}(e))}function re(e){for(var t="",i=0;i<e.length-1;i+=2)t+=String.fromCharCode(parseInt(e.substr(i,2),16));return t}function oe(e){for(var t="",i=0;i<e.length;i++)t+=("0"+e.charCodeAt(i).toString(16)).slice(-2);return t}function se(e){var t=function(e){return k(e)}(e).replace(/(.{64})/g,"$1\r\n");return t=t.replace(/\r\n$/,"")}function ae(e,t){return"-----BEGIN "+t+"-----\r\n"+se(e)+"\r\n-----END "+t+"-----\r\n"}function ue(e,t){if(-1==e.indexOf("-----BEGIN "))throw"can't find PEM header: "+t;return function(e){return C(e.replace(/[^0-9A-Za-z\/+=]*/g,""))}(e=void 0!==t?(e=e.replace(new RegExp("^[^]*-----BEGIN "+t+"-----"),"")).replace(new RegExp("-----END "+t+"-----[^]*$"),""):(e=e.replace(/^[^]*-----BEGIN [^-]+-----/,"")).replace(/-----END [^-]+-----[^]*$/,""))}function ce(e){var t="malformed hex value";if(!e.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw t;if(8!=e.length)return 32==e.length?function(e){if(!e.match(/^[0-9A-Fa-f]{32}$/))throw"malformed IPv6 address octet";for(var t=(e=e.toLowerCase()).match(/.{1,4}/g),i=0;i<8;i++)t[i]=t[i].replace(/^0+/,""),""==t[i]&&(t[i]="0");var n=(e=":"+t.join(":")+":").match(/:(0:){2,}/g);if(null===n)return e.slice(1,-1);var r="";for(i=0;i<n.length;i++)n[i].length>r.length&&(r=n[i]);return(e=e.replace(r,"::")).slice(1,-1)}(e):e;try{return parseInt(e.substr(0,2),16)+"."+parseInt(e.substr(2,2),16)+"."+parseInt(e.substr(4,2),16)+"."+parseInt(e.substr(6,2),16)}catch(e){throw t}}function le(e){return e.match(/.{4}/g).map((function(e){var t=parseInt(e.substr(0,2),16),i=parseInt(e.substr(2),16);if(0==t&i<128)return String.fromCharCode(i);if(t<8){var n=128|63&i;return ne((192|(7&t)<<3|(192&i)>>6).toString(16)+n.toString(16))}n=128|(15&t)<<2|(192&i)>>6;var r=128|63&i;return ne((224|(240&t)>>4).toString(16)+n.toString(16)+r.toString(16))})).join("")}function he(e){return!(e.length%2!=0||!e.match(/^[0-9a-f]+$/)&&!e.match(/^[0-9A-F]+$/))}function de(e){return e.length%2==1?"0"+e:e.substr(0,1)>"7"?"00"+e:e}G.prototype.nextBytes=function(e){var t;for(t=0;t<e.length;++t)e[t]=H()},K.prototype.doPublic=function(e){return e.modPowInt(this.e,this.n)},K.prototype.setPublic=function(e,t){if(this.isPublic=!0,this.isPrivate=!1,"string"!=typeof e)this.n=e,this.e=t;else{if(!(null!=e&&null!=t&&e.length>0&&t.length>0))throw"Invalid RSA public key";this.n=W(e,16),this.e=parseInt(t,16)}},K.prototype.encrypt=function(e){var t=function(e,t){if(t<e.length+11)throw"Message too long for RSA";for(var i=new Array,n=e.length-1;n>=0&&t>0;){var r=e.charCodeAt(n--);r<128?i[--t]=r:r>127&&r<2048?(i[--t]=63&r|128,i[--t]=r>>6|192):(i[--t]=63&r|128,i[--t]=r>>6&63|128,i[--t]=r>>12|224)}i[--t]=0;for(var o=new G,s=new Array;t>2;){for(s[0]=0;0==s[0];)o.nextBytes(s);i[--t]=s[0]}return i[--t]=2,i[--t]=0,new h(i)}(e,this.n.bitLength()+7>>3);if(null==t)return null;var i=this.doPublic(t);if(null==i)return null;var n=i.toString(16);return 0==(1&n.length)?n:"0"+n},K.prototype.encryptOAEP=function(e,t,i){var n=function(e,t,i,n){var r=u.crypto.MessageDigest,o=u.crypto.Util,s=null;if(i||(i="sha1"),"string"==typeof i&&(s=r.getCanonicalAlgName(i),n=r.getHashLength(s),i=function(e){return re(o.hashHex(oe(e),s))}),e.length+2*n+2>t)throw"Message too long for RSA";var a,c="";for(a=0;a<t-e.length-2*n-2;a+=1)c+="\0";var l=i("")+c+""+e,d=new Array(n);(new G).nextBytes(d);var p=q(d,l.length,i),A=[];for(a=0;a<l.length;a+=1)A[a]=l.charCodeAt(a)^p.charCodeAt(a);var f=q(A,d.length,i),M=[0];for(a=0;a<d.length;a+=1)M[a+1]=d[a]^f.charCodeAt(a);return new h(M.concat(A))}(e,this.n.bitLength()+7>>3,t,i);if(null==n)return null;var r=this.doPublic(n);if(null==r)return null;var o=r.toString(16);return 0==(1&o.length)?o:"0"+o},K.prototype.type="RSA",K.prototype.doPrivate=function(e){if(null==this.p||null==this.q)return e.modPow(this.d,this.n);for(var t=e.mod(this.p).modPow(this.dmp1,this.p),i=e.mod(this.q).modPow(this.dmq1,this.q);t.compareTo(i)<0;)t=t.add(this.p);return t.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)},K.prototype.setPrivate=function(e,t,i){if(this.isPrivate=!0,"string"!=typeof e)this.n=e,this.e=t,this.d=i;else{if(!(null!=e&&null!=t&&e.length>0&&t.length>0))throw"Invalid RSA private key";this.n=W(e,16),this.e=parseInt(t,16),this.d=W(i,16)}},K.prototype.setPrivateEx=function(e,t,i,n,r,o,s,a){if(this.isPrivate=!0,this.isPublic=!1,null==e)throw"RSASetPrivateEx N == null";if(null==t)throw"RSASetPrivateEx E == null";if(0==e.length)throw"RSASetPrivateEx N.length == 0";if(0==t.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=e&&null!=t&&e.length>0&&t.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=W(e,16),this.e=parseInt(t,16),this.d=W(i,16),this.p=W(n,16),this.q=W(r,16),this.dmp1=W(o,16),this.dmq1=W(s,16),this.coeff=W(a,16)},K.prototype.generate=function(e,t){var i=new G,n=e>>1;this.e=parseInt(t,16);for(var r=new h(t,16);;){for(;this.p=new h(e-n,1,i),0!=this.p.subtract(h.ONE).gcd(r).compareTo(h.ONE)||!this.p.isProbablePrime(10););for(;this.q=new h(n,1,i),0!=this.q.subtract(h.ONE).gcd(r).compareTo(h.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var o=this.p;this.p=this.q,this.q=o}var s=this.p.subtract(h.ONE),a=this.q.subtract(h.ONE),u=s.multiply(a);if(0==u.gcd(r).compareTo(h.ONE)&&(this.n=this.p.multiply(this.q),this.n.bitLength()==e)){this.d=r.modInverse(u),this.dmp1=this.d.mod(s),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=!0},K.prototype.decrypt=function(e){if(e.length!=Math.ceil(this.n.bitLength()/4))throw new Error("wrong ctext length");var t=W(e,16),i=this.doPrivate(t);return null==i?null:
|
|
366
366
|
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ */
|
|
367
|
-
function(e,t){for(var i=e.toByteArray(),n=0;n<i.length&&0==i[n];)++n;if(i.length-n!=t-1||2!=i[n])return null;for(++n;0!=i[n];)if(++n>=i.length)return null;for(var r="";++n<i.length;){var o=255&i[n];o<128?r+=String.fromCharCode(o):o>191&&o<224?(r+=String.fromCharCode((31&o)<<6|63&i[n+1]),++n):(r+=String.fromCharCode((15&o)<<12|(63&i[n+1])<<6|63&i[n+2]),n+=2)}return r}(i,this.n.bitLength()+7>>3)},K.prototype.decryptOAEP=function(e,t,i){if(e.length!=Math.ceil(this.n.bitLength()/4))throw new Error("wrong ctext length");var n=W(e,16),r=this.doPrivate(n);return null==r?null:function(e,t,i,n){var r=u.crypto.MessageDigest,o=u.crypto.Util,s=null;for(i||(i="sha1"),"string"==typeof i&&(s=r.getCanonicalAlgName(i),n=r.getHashLength(s),i=function(e){return re(o.hashHex(oe(e),s))}),e=e.toByteArray(),a=0;a<e.length;a+=1)e[a]&=255;for(;e.length<t;)e.unshift(0);if((e=String.fromCharCode.apply(String,e)).length<2*n+2)throw"Cipher too short";var a,c=e.substr(1,n),l=e.substr(n+1),h=Z(l,n,i),d=[];for(a=0;a<c.length;a+=1)d[a]=c.charCodeAt(a)^h.charCodeAt(a);var p=Z(String.fromCharCode.apply(String,d),e.length-n,i),A=[];for(a=0;a<l.length;a+=1)A[a]=l.charCodeAt(a)^p.charCodeAt(a);if((A=String.fromCharCode.apply(String,A)).substr(0,n)!==i(""))throw"Hash mismatch";var f=(A=A.substr(n)).indexOf("");if((-1!=f?A.substr(0,f).lastIndexOf("\0"):-1)+1!=f)throw"Malformed data";return A.substr(f+1)}(r,this.n.bitLength()+7>>3,t,i)},void 0!==u.lang&&u.lang||(u.lang={}),u.lang.String=function(){},u.lang.String.isInteger=function(e){return!!e.match(/^[0-9]+$/)||!!e.match(/^-[0-9]+$/)},u.lang.String.isHex=function(e){return he(e)},u.lang.String.isBase64=function(e){return!(!(e=e.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||e.length%4!=0)},u.lang.String.isBase64URL=function(e){return!e.match(/[+/=]/)&&(e=$(e),u.lang.String.isBase64(e))},u.lang.String.isIntegerArray=function(e){return!!(e=e.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)},u.lang.String.isPrintable=function(e){return null!==e.match(/^[0-9A-Za-z '()+,-./:=?]*$/)},u.lang.String.isIA5=function(e){return null!==e.match(/^[\x20-\x21\x23-\x7f]*$/)},u.lang.String.isMail=function(e){return null!==e.match(/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]{1,}\.[A-Za-z0-9]{1,}$/)};var pe=function(e,t,i){return null==i&&(i="0"),e.length>=t?e:new Array(t-e.length+1).join(i)+e};function Ae(e,t){var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e,e.superclass=t.prototype,t.prototype.constructor==Object.prototype.constructor&&(t.prototype.constructor=t)}void 0!==u.crypto&&u.crypto||(u.crypto={}),u.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414"},this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa"},this.CRYPTOJSMESSAGEDIGESTNAME={md5:l.algo.MD5,sha1:l.algo.SHA1,sha224:l.algo.SHA224,sha256:l.algo.SHA256,sha384:l.algo.SHA384,sha512:l.algo.SHA512,ripemd160:l.algo.RIPEMD160},this.getDigestInfoHex=function(e,t){if(void 0===this.DIGESTINFOHEAD[t])throw"alg not supported in Util.DIGESTINFOHEAD: "+t;return this.DIGESTINFOHEAD[t]+e},this.getPaddedDigestInfoHex=function(e,t,i){var n=this.getDigestInfoHex(e,t),r=i/4;if(n.length+22>r)throw"key is too short for SigAlg: keylen="+i+","+t;for(var o="0001",s="00"+n,a="",u=r-o.length-s.length,c=0;c<u;c+=2)a+="ff";return o+a+s},this.hashString=function(e,t){return new u.crypto.MessageDigest({alg:t}).digestString(e)},this.hashHex=function(e,t){return new u.crypto.MessageDigest({alg:t}).digestHex(e)},this.sha1=function(e){return this.hashString(e,"sha1")},this.sha256=function(e){return this.hashString(e,"sha256")},this.sha256Hex=function(e){return this.hashHex(e,"sha256")},this.sha512=function(e){return this.hashString(e,"sha512")},this.sha512Hex=function(e){return this.hashHex(e,"sha512")},this.isKey=function(e){return e instanceof K||e instanceof u.crypto.DSA||e instanceof u.crypto.ECDSA}},u.crypto.Util.md5=function(e){return new u.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(e)},u.crypto.Util.ripemd160=function(e){return new u.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(e)},u.crypto.Util.SECURERANDOMGEN=new G,u.crypto.Util.getRandomHexOfNbytes=function(e){var t=new Array(e);return u.crypto.Util.SECURERANDOMGEN.nextBytes(t),X(t)},u.crypto.Util.getRandomBigIntegerOfNbytes=function(e){return new h(u.crypto.Util.getRandomHexOfNbytes(e),16)},u.crypto.Util.getRandomHexOfNbits=function(e){var t=e%8,i=new Array((e-t)/8+1);return u.crypto.Util.SECURERANDOMGEN.nextBytes(i),i[0]=(255<<t&255^255)&i[0],X(i)},u.crypto.Util.getRandomBigIntegerOfNbits=function(e){return new h(u.crypto.Util.getRandomHexOfNbits(e),16)},u.crypto.Util.getRandomBigIntegerZeroToMax=function(e){for(var t=e.bitLength();;){var i=u.crypto.Util.getRandomBigIntegerOfNbits(t);if(-1!=e.compareTo(i))return i}},u.crypto.Util.getRandomBigIntegerMinToMax=function(e,t){var i=e.compareTo(t);if(1==i)throw"biMin is greater than biMax";if(0==i)return e;var n=t.subtract(e);return u.crypto.Util.getRandomBigIntegerZeroToMax(n).add(e)},u.crypto.MessageDigest=function(e){this.setAlgAndProvider=function(e,t){if(null!==(e=u.crypto.MessageDigest.getCanonicalAlgName(e))&&void 0===t&&(t=u.crypto.Util.DEFAULTPROVIDER[e]),-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(e)&&"cryptojs"==t){try{this.md=u.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[e].create()}catch(t){throw"setAlgAndProvider hash alg set fail alg="+e+"/"+t}this.updateString=function(e){this.md.update(e)},this.updateHex=function(e){var t=l.enc.Hex.parse(e);this.md.update(t)},this.digest=function(){return this.md.finalize().toString(l.enc.Hex)},this.digestString=function(e){return this.updateString(e),this.digest()},this.digestHex=function(e){return this.updateHex(e),this.digest()}}if(-1!=":sha256:".indexOf(e)&&"sjcl"==t){try{this.md=new sjcl.hash.sha256}catch(t){throw"setAlgAndProvider hash alg set fail alg="+e+"/"+t}this.updateString=function(e){this.md.update(e)},this.updateHex=function(e){var t=sjcl.codec.hex.toBits(e);this.md.update(t)},this.digest=function(){var e=this.md.finalize();return sjcl.codec.hex.fromBits(e)},this.digestString=function(e){return this.updateString(e),this.digest()},this.digestHex=function(e){return this.updateHex(e),this.digest()}}},this.updateString=function(e){throw"updateString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.updateHex=function(e){throw"updateHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digest=function(){throw"digest() not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestString=function(e){throw"digestString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestHex=function(e){throw"digestHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},void 0!==e&&void 0!==e.alg&&(this.algName=e.alg,void 0===e.prov&&(this.provName=u.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},u.crypto.MessageDigest.getCanonicalAlgName=function(e){return"string"==typeof e&&(e=(e=e.toLowerCase()).replace(/-/,"")),e},u.crypto.MessageDigest.getHashLength=function(e){var t=u.crypto.MessageDigest,i=t.getCanonicalAlgName(e);if(void 0===t.HASHLENGTH[i])throw"not supported algorithm: "+e;return t.HASHLENGTH[i]},u.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},u.crypto.Mac=function(e){this.setAlgAndProvider=function(e,t){if(null==(e=e.toLowerCase())&&(e="hmacsha1"),"hmac"!=(e=e.toLowerCase()).substr(0,4))throw"setAlgAndProvider unsupported HMAC alg: "+e;void 0===t&&(t=u.crypto.Util.DEFAULTPROVIDER[e]),this.algProv=e+"/"+t;var i=e.substr(4);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(i)&&"cryptojs"==t){try{var n=u.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[i];this.mac=l.algo.HMAC.create(n,this.pass)}catch(e){throw"setAlgAndProvider hash alg set fail hashAlg="+i+"/"+e}this.updateString=function(e){this.mac.update(e)},this.updateHex=function(e){var t=l.enc.Hex.parse(e);this.mac.update(t)},this.doFinal=function(){return this.mac.finalize().toString(l.enc.Hex)},this.doFinalString=function(e){return this.updateString(e),this.doFinal()},this.doFinalHex=function(e){return this.updateHex(e),this.doFinal()}}},this.updateString=function(e){throw"updateString(str) not supported for this alg/prov: "+this.algProv},this.updateHex=function(e){throw"updateHex(hex) not supported for this alg/prov: "+this.algProv},this.doFinal=function(){throw"digest() not supported for this alg/prov: "+this.algProv},this.doFinalString=function(e){throw"digestString(str) not supported for this alg/prov: "+this.algProv},this.doFinalHex=function(e){throw"digestHex(hex) not supported for this alg/prov: "+this.algProv},this.setPassword=function(e){if("string"==typeof e){var t=e;return e.length%2!=1&&e.match(/^[0-9A-Fa-f]+$/)||(t=oe(e)),void(this.pass=l.enc.Hex.parse(t))}if("object"!=typeof e)throw"KJUR.crypto.Mac unsupported password type: "+e;t=null;if(void 0!==e.hex){if(e.hex.length%2!=0||!e.hex.match(/^[0-9A-Fa-f]+$/))throw"Mac: wrong hex password: "+e.hex;t=e.hex}if(void 0!==e.utf8&&(t=ie(e.utf8)),void 0!==e.rstr&&(t=oe(e.rstr)),void 0!==e.b64&&(t=C(e.b64)),void 0!==e.b64u&&(t=te(e.b64u)),null==t)throw"KJUR.crypto.Mac unsupported password type: "+e;this.pass=l.enc.Hex.parse(t)},void 0!==e&&(void 0!==e.pass&&this.setPassword(e.pass),void 0!==e.alg&&(this.algName=e.alg,void 0===e.prov&&(this.provName=u.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))},u.crypto.Signature=function(e){var t=null;if(this._setAlgNames=function(){var e=this.algName.match(/^(.+)with(.+)$/);e&&(this.mdAlgName=e[1].toLowerCase(),this.pubkeyAlgName=e[2].toLowerCase(),"rsaandmgf1"==this.pubkeyAlgName&&"sha"==this.mdAlgName&&(this.mdAlgName="sha1"))},this._zeroPaddingOfSignature=function(e,t){for(var i="",n=t/4-e.length,r=0;r<n;r++)i+="0";return i+e},this.setAlgAndProvider=function(e,t){if(this._setAlgNames(),"cryptojs/jsrsa"!=t)throw new Error("provider not supported: "+t);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(this.mdAlgName)){try{this.md=new u.crypto.MessageDigest({alg:this.mdAlgName})}catch(e){throw new Error("setAlgAndProvider hash alg set fail alg="+this.mdAlgName+"/"+e)}this.init=function(e,t){var i=null;try{i=void 0===t?we.getKey(e):we.getKey(e,t)}catch(e){throw"init failed:"+e}if(!0===i.isPrivate)this.prvKey=i,this.state="SIGN";else{if(!0!==i.isPublic)throw"init failed.:"+i;this.pubKey=i,this.state="VERIFY"}},this.updateString=function(e){this.md.updateString(e)},this.updateHex=function(e){this.md.updateHex(e)},this.sign=function(){if(this.sHashHex=this.md.digest(),void 0===this.prvKey&&void 0!==this.ecprvhex&&void 0!==this.eccurvename&&void 0!==u.crypto.ECDSA&&(this.prvKey=new u.crypto.ECDSA({curve:this.eccurvename,prv:this.ecprvhex})),this.prvKey instanceof K&&"rsaandmgf1"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHashPSS(this.sHashHex,this.mdAlgName,this.pssSaltLen);else if(this.prvKey instanceof K&&"rsa"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex,this.mdAlgName);else if(this.prvKey instanceof u.crypto.ECDSA)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex);else{if(!(this.prvKey instanceof u.crypto.DSA))throw"Signature: unsupported private key alg: "+this.pubkeyAlgName;this.hSign=this.prvKey.signWithMessageHash(this.sHashHex)}return this.hSign},this.signString=function(e){return this.updateString(e),this.sign()},this.signHex=function(e){return this.updateHex(e),this.sign()},this.verify=function(e){if(this.sHashHex=this.md.digest(),void 0===this.pubKey&&void 0!==this.ecpubhex&&void 0!==this.eccurvename&&void 0!==u.crypto.ECDSA&&(this.pubKey=new u.crypto.ECDSA({curve:this.eccurvename,pub:this.ecpubhex})),this.pubKey instanceof K&&"rsaandmgf1"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHashPSS(this.sHashHex,e,this.mdAlgName,this.pssSaltLen);if(this.pubKey instanceof K&&"rsa"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHash(this.sHashHex,e);if(void 0!==u.crypto.ECDSA&&this.pubKey instanceof u.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,e);if(void 0!==u.crypto.DSA&&this.pubKey instanceof u.crypto.DSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,e);throw"Signature: unsupported public key alg: "+this.pubkeyAlgName}}},this.init=function(e,t){throw"init(key, pass) not supported for this alg:prov="+this.algProvName},this.updateString=function(e){throw"updateString(str) not supported for this alg:prov="+this.algProvName},this.updateHex=function(e){throw"updateHex(hex) not supported for this alg:prov="+this.algProvName},this.sign=function(){throw"sign() not supported for this alg:prov="+this.algProvName},this.signString=function(e){throw"digestString(str) not supported for this alg:prov="+this.algProvName},this.signHex=function(e){throw"digestHex(hex) not supported for this alg:prov="+this.algProvName},this.verify=function(e){throw"verify(hSigVal) not supported for this alg:prov="+this.algProvName},this.initParams=e,void 0!==e&&(void 0!==e.alg&&(this.algName=e.alg,void 0===e.prov?this.provName=u.crypto.Util.DEFAULTPROVIDER[this.algName]:this.provName=e.prov,this.algProvName=this.algName+":"+this.provName,this.setAlgAndProvider(this.algName,this.provName),this._setAlgNames()),void 0!==e.psssaltlen&&(this.pssSaltLen=e.psssaltlen),void 0!==e.prvkeypem)){if(void 0!==e.prvkeypas)throw"both prvkeypem and prvkeypas parameters not supported";try{t=we.getKey(e.prvkeypem);this.init(t)}catch(e){throw"fatal error to load pem private key: "+e}}},u.crypto.Cipher=function(e){},u.crypto.Cipher.encrypt=function(e,t,i){if(t instanceof K&&t.isPublic){var n=u.crypto.Cipher.getAlgByKeyAndName(t,i);if("RSA"===n)return t.encrypt(e);if("RSAOAEP"===n)return t.encryptOAEP(e,"sha1");var r=n.match(/^RSAOAEP(\d+)$/);if(null!==r)return t.encryptOAEP(e,"sha"+r[1]);throw"Cipher.encrypt: unsupported algorithm for RSAKey: "+i}throw"Cipher.encrypt: unsupported key or algorithm"},u.crypto.Cipher.decrypt=function(e,t,i){if(t instanceof K&&t.isPrivate){var n=u.crypto.Cipher.getAlgByKeyAndName(t,i);if("RSA"===n)return t.decrypt(e);if("RSAOAEP"===n)return t.decryptOAEP(e,"sha1");var r=n.match(/^RSAOAEP(\d+)$/);if(null!==r)return t.decryptOAEP(e,"sha"+r[1]);throw"Cipher.decrypt: unsupported algorithm for RSAKey: "+i}throw"Cipher.decrypt: unsupported key or algorithm"},u.crypto.Cipher.getAlgByKeyAndName=function(e,t){if(e instanceof K){if(-1!=":RSA:RSAOAEP:RSAOAEP224:RSAOAEP256:RSAOAEP384:RSAOAEP512:".indexOf(t))return t;if(null==t)return"RSA";throw"getAlgByKeyAndName: not supported algorithm name for RSAKey: "+t}throw"getAlgByKeyAndName: not supported algorithm name: "+t},u.crypto.OID=new function(){this.oidhex2name={"2a864886f70d010101":"rsaEncryption","2a8648ce3d0201":"ecPublicKey","2a8648ce380401":"dsa","2a8648ce3d030107":"secp256r1","2b8104001f":"secp192k1","2b81040021":"secp224r1","2b8104000a":"secp256k1","2b81040023":"secp521r1","2b81040022":"secp384r1","2a8648ce380403":"SHA1withDSA","608648016503040301":"SHA224withDSA","608648016503040302":"SHA256withDSA"}};var fe,Me,ge,ye,me,ve,Ne,De,we=(fe=function(e,t,i){return Me(l.AES,e,t,i)},Me=function(e,t,i,n){var r=l.enc.Hex.parse(t),o=l.enc.Hex.parse(i),s=l.enc.Hex.parse(n),a={};a.key=o,a.iv=s,a.ciphertext=r;var u=e.decrypt(a,o,{iv:s});return l.enc.Hex.stringify(u)},ge=function(e,t,i){return ye(l.AES,e,t,i)},ye=function(e,t,i,n){var r=l.enc.Hex.parse(t),o=l.enc.Hex.parse(i),s=l.enc.Hex.parse(n),a=e.encrypt(r,o,{iv:s}),u=l.enc.Hex.parse(a.toString());return l.enc.Base64.stringify(u)},me={"AES-256-CBC":{proc:fe,eproc:ge,keylen:32,ivlen:16},"AES-192-CBC":{proc:fe,eproc:ge,keylen:24,ivlen:16},"AES-128-CBC":{proc:fe,eproc:ge,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(e,t,i){return Me(l.TripleDES,e,t,i)},eproc:function(e,t,i){return ye(l.TripleDES,e,t,i)},keylen:24,ivlen:8},"DES-CBC":{proc:function(e,t,i){return Me(l.DES,e,t,i)},eproc:function(e,t,i){return ye(l.DES,e,t,i)},keylen:8,ivlen:8}},ve=function(e){var t={},i=e.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));i&&(t.cipher=i[1],t.ivsalt=i[2]);var n=e.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(t.type=n[1]);var r=-1,o=0;-1!=e.indexOf("\r\n\r\n")&&(r=e.indexOf("\r\n\r\n"),o=2),-1!=e.indexOf("\n\n")&&(r=e.indexOf("\n\n"),o=1);var s=e.indexOf("-----END");if(-1!=r&&-1!=s){var a=e.substring(r+2*o,s-o);a=a.replace(/\s+/g,""),t.data=a}return t},Ne=function(e,t,i){for(var n=i.substring(0,16),r=l.enc.Hex.parse(n),o=l.enc.Utf8.parse(t),s=me[e].keylen+me[e].ivlen,a="",u=null;;){var c=l.algo.MD5.create();if(null!=u&&c.update(u),c.update(o),c.update(r),u=c.finalize(),(a+=l.enc.Hex.stringify(u)).length>=2*s)break}var h={};return h.keyhex=a.substr(0,2*me[e].keylen),h.ivhex=a.substr(2*me[e].keylen,2*me[e].ivlen),h},De=function(e,t,i,n){var r=l.enc.Base64.parse(e),o=l.enc.Hex.stringify(r);return(0,me[t].proc)(o,i,n)},{version:"1.0.0",parsePKCS5PEM:function(e){return ve(e)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(e,t,i){return Ne(e,t,i)},decryptKeyB64:function(e,t,i,n){return De(e,t,i,n)},getDecryptedKeyHex:function(e,t){var i=ve(e);i.type;var n=i.cipher,r=i.ivsalt,o=i.data,s=Ne(n,t,r).keyhex;return De(o,n,s,r)},getEncryptedPKCS5PEMFromPrvKeyHex:function(e,t,i,n,r){var o="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===me[n])throw"KEYUTIL unsupported algorithm: "+n;void 0!==r&&null!=r||(r=function(e){var t=l.lib.WordArray.random(e);return l.enc.Hex.stringify(t)}(me[n].ivlen).toUpperCase());var s=function(e,t,i,n){return(0,me[t].eproc)(e,i,n)}(t,n,Ne(n,i,r).keyhex,r);return o="-----BEGIN "+e+" PRIVATE KEY-----\r\n",o+="Proc-Type: 4,ENCRYPTED\r\n",o+="DEK-Info: "+n+","+r+"\r\n",o+="\r\n",o+=s.replace(/(.{64})/g,"$1\r\n"),o+="\r\n-----END "+e+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(e){var t=Te,i=t.getChildIdx,n=t.getV,r={},o=i(e,0);if(2!=o.length)throw"malformed format: SEQUENCE(0).items != 2: "+o.length;r.ciphertext=n(e,o[1]);var s=i(e,o[0]);if(2!=s.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+s.length;if("2a864886f70d01050d"!=n(e,s[0]))throw"this only supports pkcs5PBES2";var a=i(e,s[1]);if(2!=s.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+a.length;var u=i(e,a[1]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+u.length;if("2a864886f70d0307"!=n(e,u[0]))throw"this only supports TripleDES";r.encryptionSchemeAlg="TripleDES",r.encryptionSchemeIV=n(e,u[1]);var c=i(e,a[0]);if(2!=c.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+c.length;if("2a864886f70d01050c"!=n(e,c[0]))throw"this only supports pkcs5PBKDF2";var l=i(e,c[1]);if(l.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+l.length;r.pbkdf2Salt=n(e,l[0]);var h=n(e,l[1]);try{r.pbkdf2Iter=parseInt(h,16)}catch(e){throw"malformed format pbkdf2Iter: "+h}return r},getPBKDF2KeyHexFromParam:function(e,t){var i=l.enc.Hex.parse(e.pbkdf2Salt),n=e.pbkdf2Iter,r=l.PBKDF2(t,i,{keySize:6,iterations:n});return l.enc.Hex.stringify(r)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(e,t){var i=ue(e,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(i),r=we.getPBKDF2KeyHexFromParam(n,t),o={};o.ciphertext=l.enc.Hex.parse(n.ciphertext);var s=l.enc.Hex.parse(r),a=l.enc.Hex.parse(n.encryptionSchemeIV),u=l.TripleDES.decrypt(o,s,{iv:a});return l.enc.Hex.stringify(u)},getKeyFromEncryptedPKCS8PEM:function(e,t){var i=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(e,t);return this.getKeyFromPlainPrivatePKCS8Hex(i)},parsePlainPrivatePKCS8Hex:function(e){var t=Te,i=t.getChildIdx,n=t.getV,r={algparam:null};if("30"!=e.substr(0,2))throw new Error("malformed plain PKCS8 private key(code:001)");var o=i(e,0);if(o.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if("30"!=e.substr(o[1],2))throw new Error("malformed PKCS8 private key(code:003)");var s=i(e,o[1]);if(2!=s.length)throw new Error("malformed PKCS8 private key(code:004)");if("06"!=e.substr(s[0],2))throw new Error("malformed PKCS8 private key(code:005)");if(r.algoid=n(e,s[0]),"06"==e.substr(s[1],2)&&(r.algparam=n(e,s[1])),"04"!=e.substr(o[2],2))throw new Error("malformed PKCS8 private key(code:006)");return r.keyidx=t.getVidx(e,o[2]),r},getKeyFromPlainPrivatePKCS8PEM:function(e){var t=ue(e,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(t)},getKeyFromPlainPrivatePKCS8Hex:function(e){var t,i=this.parsePlainPrivatePKCS8Hex(e);if("2a864886f70d010101"==i.algoid)t=new K;else if("2a8648ce380401"==i.algoid)t=new u.crypto.DSA;else{if("2a8648ce3d0201"!=i.algoid)throw"unsupported private key algorithm";t=new u.crypto.ECDSA}return t.readPKCS8PrvKeyHex(e),t},_getKeyFromPublicPKCS8Hex:function(e){var t,i=Te.getVbyList(e,0,[0,0],"06");if("2a864886f70d010101"===i)t=new K;else if("2a8648ce380401"===i)t=new u.crypto.DSA;else{if("2a8648ce3d0201"!==i)throw"unsupported PKCS#8 public key hex";t=new u.crypto.ECDSA}return t.readPKCS8PubKeyHex(e),t},parsePublicRawRSAKeyHex:function(e){var t=Te,i=t.getChildIdx,n=t.getV,r={};if("30"!=e.substr(0,2))throw"malformed RSA key(code:001)";var o=i(e,0);if(2!=o.length)throw"malformed RSA key(code:002)";if("02"!=e.substr(o[0],2))throw"malformed RSA key(code:003)";if(r.n=n(e,o[0]),"02"!=e.substr(o[1],2))throw"malformed RSA key(code:004)";return r.e=n(e,o[1]),r},parsePublicPKCS8Hex:function(e){var t=Te,i=t.getChildIdx,n=t.getV,r={algparam:null},o=i(e,0);if(2!=o.length)throw"outer DERSequence shall have 2 elements: "+o.length;var s=o[0];if("30"!=e.substr(s,2))throw"malformed PKCS8 public key(code:001)";var a=i(e,s);if(2!=a.length)throw"malformed PKCS8 public key(code:002)";if("06"!=e.substr(a[0],2))throw"malformed PKCS8 public key(code:003)";if(r.algoid=n(e,a[0]),"06"==e.substr(a[1],2)?r.algparam=n(e,a[1]):"30"==e.substr(a[1],2)&&(r.algparam={},r.algparam.p=t.getVbyList(e,a[1],[0],"02"),r.algparam.q=t.getVbyList(e,a[1],[1],"02"),r.algparam.g=t.getVbyList(e,a[1],[2],"02")),"03"!=e.substr(o[1],2))throw"malformed PKCS8 public key(code:004)";return r.key=n(e,o[1]).substr(2),r}});we.getKey=function(e,t,i){var n=(y=Te).getChildIdx;y.getV;var r=y.getVbyList,o=u.crypto,s=o.ECDSA,a=o.DSA,c=K,l=ue,d=we;if(void 0!==c&&e instanceof c)return e;if(void 0!==s&&e instanceof s)return e;if(void 0!==a&&e instanceof a)return e;if(void 0!==e.curve&&void 0!==e.xy&&void 0===e.d)return new s({pub:e.xy,curve:e.curve});if(void 0!==e.curve&&void 0!==e.d)return new s({prv:e.d,curve:e.curve});if(void 0===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0===e.d)return(I=new c).setPublic(e.n,e.e),I;if(void 0===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d&&void 0!==e.p&&void 0!==e.q&&void 0!==e.dp&&void 0!==e.dq&&void 0!==e.co&&void 0===e.qi)return(I=new c).setPrivateEx(e.n,e.e,e.d,e.p,e.q,e.dp,e.dq,e.co),I;if(void 0===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d&&void 0===e.p)return(I=new c).setPrivate(e.n,e.e,e.d),I;if(void 0!==e.p&&void 0!==e.q&&void 0!==e.g&&void 0!==e.y&&void 0===e.x)return(I=new a).setPublic(e.p,e.q,e.g,e.y),I;if(void 0!==e.p&&void 0!==e.q&&void 0!==e.g&&void 0!==e.y&&void 0!==e.x)return(I=new a).setPrivate(e.p,e.q,e.g,e.y,e.x),I;if("RSA"===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0===e.d)return(I=new c).setPublic(te(e.n),te(e.e)),I;if("RSA"===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d&&void 0!==e.p&&void 0!==e.q&&void 0!==e.dp&&void 0!==e.dq&&void 0!==e.qi)return(I=new c).setPrivateEx(te(e.n),te(e.e),te(e.d),te(e.p),te(e.q),te(e.dp),te(e.dq),te(e.qi)),I;if("RSA"===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d)return(I=new c).setPrivate(te(e.n),te(e.e),te(e.d)),I;if("EC"===e.kty&&void 0!==e.crv&&void 0!==e.x&&void 0!==e.y&&void 0===e.d){var p=(z=new s({curve:e.crv})).ecparams.keylen/4,A="04"+("0000000000"+te(e.x)).slice(-p)+("0000000000"+te(e.y)).slice(-p);return z.setPublicKeyHex(A),z}if("EC"===e.kty&&void 0!==e.crv&&void 0!==e.x&&void 0!==e.y&&void 0!==e.d){p=(z=new s({curve:e.crv})).ecparams.keylen/4,A="04"+("0000000000"+te(e.x)).slice(-p)+("0000000000"+te(e.y)).slice(-p);var f=("0000000000"+te(e.d)).slice(-p);return z.setPublicKeyHex(A),z.setPrivateKeyHex(f),z}if("pkcs5prv"===i){var M,g=e,y=Te;if(9===(M=n(g,0)).length)(I=new c).readPKCS5PrvKeyHex(g);else if(6===M.length)(I=new a).readPKCS5PrvKeyHex(g);else{if(!(M.length>2&&"04"===g.substr(M[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(I=new s).readPKCS5PrvKeyHex(g)}return I}if("pkcs8prv"===i)return I=d.getKeyFromPlainPrivatePKCS8Hex(e);if("pkcs8pub"===i)return d._getKeyFromPublicPKCS8Hex(e);if("x509pub"===i)return ze.getPublicKeyFromCertHex(e);if(-1!=e.indexOf("-END CERTIFICATE-",0)||-1!=e.indexOf("-END X509 CERTIFICATE-",0)||-1!=e.indexOf("-END TRUSTED CERTIFICATE-",0))return ze.getPublicKeyFromCertPEM(e);if(-1!=e.indexOf("-END PUBLIC KEY-")){var m=ue(e,"PUBLIC KEY");return d._getKeyFromPublicPKCS8Hex(m)}if(-1!=e.indexOf("-END RSA PRIVATE KEY-")&&-1==e.indexOf("4,ENCRYPTED")){var v=l(e,"RSA PRIVATE KEY");return d.getKey(v,null,"pkcs5prv")}if(-1!=e.indexOf("-END DSA PRIVATE KEY-")&&-1==e.indexOf("4,ENCRYPTED")){var N=r(S=l(e,"DSA PRIVATE KEY"),0,[1],"02"),D=r(S,0,[2],"02"),w=r(S,0,[3],"02"),T=r(S,0,[4],"02"),x=r(S,0,[5],"02");return(I=new a).setPrivate(new h(N,16),new h(D,16),new h(w,16),new h(T,16),new h(x,16)),I}if(-1!=e.indexOf("-END EC PRIVATE KEY-")&&-1==e.indexOf("4,ENCRYPTED")){v=l(e,"EC PRIVATE KEY");return d.getKey(v,null,"pkcs5prv")}if(-1!=e.indexOf("-END PRIVATE KEY-"))return d.getKeyFromPlainPrivatePKCS8PEM(e);if(-1!=e.indexOf("-END RSA PRIVATE KEY-")&&-1!=e.indexOf("4,ENCRYPTED")){var E=d.getDecryptedKeyHex(e,t),j=new K;return j.readPKCS5PrvKeyHex(E),j}if(-1!=e.indexOf("-END EC PRIVATE KEY-")&&-1!=e.indexOf("4,ENCRYPTED")){var z,I=r(S=d.getDecryptedKeyHex(e,t),0,[1],"04"),b=r(S,0,[2,0],"06"),O=r(S,0,[3,0],"03").substr(2);if(void 0===u.crypto.OID.oidhex2name[b])throw"undefined OID(hex) in KJUR.crypto.OID: "+b;return(z=new s({curve:u.crypto.OID.oidhex2name[b]})).setPublicKeyHex(O),z.setPrivateKeyHex(I),z.isPublic=!1,z}if(-1!=e.indexOf("-END DSA PRIVATE KEY-")&&-1!=e.indexOf("4,ENCRYPTED")){var S;N=r(S=d.getDecryptedKeyHex(e,t),0,[1],"02"),D=r(S,0,[2],"02"),w=r(S,0,[3],"02"),T=r(S,0,[4],"02"),x=r(S,0,[5],"02");return(I=new a).setPrivate(new h(N,16),new h(D,16),new h(w,16),new h(T,16),new h(x,16)),I}if(-1!=e.indexOf("-END ENCRYPTED PRIVATE KEY-"))return d.getKeyFromEncryptedPKCS8PEM(e,t);throw new Error("not supported argument")},we.generateKeypair=function(e,t){if("RSA"==e){var i=t;(s=new K).generate(i,"10001"),s.isPrivate=!0,s.isPublic=!0;var n=new K,r=s.n.toString(16),o=s.e.toString(16);return n.setPublic(r,o),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=s,a.pubKeyObj=n,a}if("EC"==e){var s,a,c=t,l=new u.crypto.ECDSA({curve:c}).generateKeyPairHex();return(s=new u.crypto.ECDSA({curve:c})).setPublicKeyHex(l.ecpubhex),s.setPrivateKeyHex(l.ecprvhex),s.isPrivate=!0,s.isPublic=!1,(n=new u.crypto.ECDSA({curve:c})).setPublicKeyHex(l.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=s,a.pubKeyObj=n,a}throw"unknown algorithm: "+e},we.getPEM=function(e,t,i,n,r,o){var s=u,a=s.asn1,c=a.DERObjectIdentifier,h=a.DERInteger,d=a.ASN1Util.newObject,p=a.x509.SubjectPublicKeyInfo,A=s.crypto,f=A.DSA,M=A.ECDSA,g=K;function y(e){return d({seq:[{int:0},{int:{bigint:e.n}},{int:e.e},{int:{bigint:e.d}},{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.dmp1}},{int:{bigint:e.dmq1}},{int:{bigint:e.coeff}}]})}function m(e){return d({seq:[{int:1},{octstr:{hex:e.prvKeyHex}},{tag:["a0",!0,{oid:{name:e.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+e.pubKeyHex}}]}]})}function v(e){return d({seq:[{int:0},{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}},{int:{bigint:e.y}},{int:{bigint:e.x}}]})}if((void 0!==g&&e instanceof g||void 0!==f&&e instanceof f||void 0!==M&&e instanceof M)&&1==e.isPublic&&(void 0===t||"PKCS8PUB"==t))return ae(T=new p(e).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==t&&void 0!==g&&e instanceof g&&(void 0===i||null==i)&&1==e.isPrivate)return ae(T=y(e).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==t&&void 0!==M&&e instanceof M&&(void 0===i||null==i)&&1==e.isPrivate){var N=new c({name:e.curveName}).getEncodedHex(),D=m(e).getEncodedHex(),w="";return w+=ae(N,"EC PARAMETERS"),w+=ae(D,"EC PRIVATE KEY")}if("PKCS1PRV"==t&&void 0!==f&&e instanceof f&&(void 0===i||null==i)&&1==e.isPrivate)return ae(T=v(e).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==t&&void 0!==g&&e instanceof g&&void 0!==i&&null!=i&&1==e.isPrivate){var T=y(e).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",T,i,n,o)}if("PKCS5PRV"==t&&void 0!==M&&e instanceof M&&void 0!==i&&null!=i&&1==e.isPrivate){T=m(e).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",T,i,n,o)}if("PKCS5PRV"==t&&void 0!==f&&e instanceof f&&void 0!==i&&null!=i&&1==e.isPrivate){T=v(e).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",T,i,n,o)}var x=function(e,t){var i=E(e,t);return new d({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:i.pbkdf2Salt}},{int:i.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:i.encryptionSchemeIV}}]}]}]},{octstr:{hex:i.ciphertext}}]}).getEncodedHex()},E=function(e,t){var i=l.lib.WordArray.random(8),n=l.lib.WordArray.random(8),r=l.PBKDF2(t,i,{keySize:6,iterations:100}),o=l.enc.Hex.parse(e),s=l.TripleDES.encrypt(o,r,{iv:n})+"",a={};return a.ciphertext=s,a.pbkdf2Salt=l.enc.Hex.stringify(i),a.pbkdf2Iter=100,a.encryptionSchemeAlg="DES-EDE3-CBC",a.encryptionSchemeIV=l.enc.Hex.stringify(n),a};if("PKCS8PRV"==t&&null!=g&&e instanceof g&&1==e.isPrivate){var j=y(e).getEncodedHex();T=d({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:j}}]}).getEncodedHex();return void 0===i||null==i?ae(T,"PRIVATE KEY"):ae(D=x(T,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==t&&void 0!==M&&e instanceof M&&1==e.isPrivate){j=new d({seq:[{int:1},{octstr:{hex:e.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+e.pubKeyHex}}]}]}).getEncodedHex(),T=d({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:e.curveName}}]},{octstr:{hex:j}}]}).getEncodedHex();return void 0===i||null==i?ae(T,"PRIVATE KEY"):ae(D=x(T,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==t&&void 0!==f&&e instanceof f&&1==e.isPrivate){j=new h({bigint:e.x}).getEncodedHex(),T=d({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}}]}]},{octstr:{hex:j}}]}).getEncodedHex();return void 0===i||null==i?ae(T,"PRIVATE KEY"):ae(D=x(T,i),"ENCRYPTED PRIVATE KEY")}throw new Error("unsupported object nor format")},we.getKeyFromCSRPEM=function(e){var t=ue(e,"CERTIFICATE REQUEST");return we.getKeyFromCSRHex(t)},we.getKeyFromCSRHex=function(e){var t=we.parseCSRHex(e);return we.getKey(t.p8pubkeyhex,null,"pkcs8pub")},we.parseCSRHex=function(e){var t=Te,i=t.getChildIdx,n=t.getTLV,r={},o=e;if("30"!=o.substr(0,2))throw"malformed CSR(code:001)";var s=i(o,0);if(s.length<1)throw"malformed CSR(code:002)";if("30"!=o.substr(s[0],2))throw"malformed CSR(code:003)";var a=i(o,s[0]);if(a.length<3)throw"malformed CSR(code:004)";return r.p8pubkeyhex=n(o,a[2]),r},we.getKeyID=function(e){var t=we,i=Te;"string"==typeof e&&-1!=e.indexOf("BEGIN ")&&(e=t.getKey(e));var n=ue(t.getPEM(e)),r=i.getIdxbyList(n,0,[1]),o=i.getV(n,r).substring(2);return u.crypto.Util.hashHex(o,"sha1")},we.getJWKFromKey=function(e){var t={};if(e instanceof K&&e.isPrivate)return t.kty="RSA",t.n=ee(e.n.toString(16)),t.e=ee(e.e.toString(16)),t.d=ee(e.d.toString(16)),t.p=ee(e.p.toString(16)),t.q=ee(e.q.toString(16)),t.dp=ee(e.dmp1.toString(16)),t.dq=ee(e.dmq1.toString(16)),t.qi=ee(e.coeff.toString(16)),t;if(e instanceof K&&e.isPublic)return t.kty="RSA",t.n=ee(e.n.toString(16)),t.e=ee(e.e.toString(16)),t;if(e instanceof u.crypto.ECDSA&&e.isPrivate){if("P-256"!==(n=e.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;var i=e.getPublicKeyXYHex();return t.kty="EC",t.crv=n,t.x=ee(i.x),t.y=ee(i.y),t.d=ee(e.prvKeyHex),t}if(e instanceof u.crypto.ECDSA&&e.isPublic){var n;if("P-256"!==(n=e.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;i=e.getPublicKeyXYHex();return t.kty="EC",t.crv=n,t.x=ee(i.x),t.y=ee(i.y),t}throw"not supported key object"},void 0!==u.asn1&&u.asn1||(u.asn1={}),u.asn1.ASN1Util=new function(){this.integerToByteHex=function(e){var t=e.toString(16);return t.length%2==1&&(t="0"+t),t},this.bigIntToMinTwosComplementsHex=function(e){var t=e.toString(16);if("-"!=t.substr(0,1))t.length%2==1?t="0"+t:t.match(/^[0-7]/)||(t="00"+t);else{var i=t.substr(1).length;i%2==1?i+=1:t.match(/^[0-7]/)||(i+=2);for(var n="",r=0;r<i;r++)n+="f";t=new h(n,16).xor(e).add(h.ONE).toString(16).replace(/^-/,"")}return t},this.getPEMStringFromHex=function(e,t){return ae(e,t)},this.newObject=function(e){var t=u.asn1,i=t.ASN1Object,n=t.DERBoolean,r=t.DERInteger,o=t.DERBitString,s=t.DEROctetString,a=t.DERNull,c=t.DERObjectIdentifier,l=t.DEREnumerated,h=t.DERUTF8String,d=t.DERNumericString,p=t.DERPrintableString,A=t.DERTeletexString,f=t.DERIA5String,M=t.DERUTCTime,g=t.DERGeneralizedTime,y=t.DERVisibleString,m=t.DERBMPString,v=t.DERSequence,N=t.DERSet,D=t.DERTaggedObject,w=t.ASN1Util.newObject;if(e instanceof t.ASN1Object)return e;var T=Object.keys(e);if(1!=T.length)throw new Error("key of param shall be only one.");var x=T[0];if(-1==":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+x+":"))throw new Error("undefined key: "+x);if("bool"==x)return new n(e[x]);if("int"==x)return new r(e[x]);if("bitstr"==x)return new o(e[x]);if("octstr"==x)return new s(e[x]);if("null"==x)return new a(e[x]);if("oid"==x)return new c(e[x]);if("enum"==x)return new l(e[x]);if("utf8str"==x)return new h(e[x]);if("numstr"==x)return new d(e[x]);if("prnstr"==x)return new p(e[x]);if("telstr"==x)return new A(e[x]);if("ia5str"==x)return new f(e[x]);if("utctime"==x)return new M(e[x]);if("gentime"==x)return new g(e[x]);if("visstr"==x)return new y(e[x]);if("bmpstr"==x)return new m(e[x]);if("asn1"==x)return new i(e[x]);if("seq"==x){for(var E=e[x],j=[],z=0;z<E.length;z++){var I=w(E[z]);j.push(I)}return new v({array:j})}if("set"==x){for(E=e[x],j=[],z=0;z<E.length;z++){I=w(E[z]);j.push(I)}return new N({array:j})}if("tag"==x){var b=e[x];if("[object Array]"===Object.prototype.toString.call(b)&&3==b.length){var O=w(b[2]);return new D({tag:b[0],explicit:b[1],obj:O})}return new D(b)}},this.jsonToASN1HEX=function(e){return this.newObject(e).getEncodedHex()}},u.asn1.ASN1Util.oidHexToInt=function(e){for(var t="",i=parseInt(e.substr(0,2),16),n=(t=Math.floor(i/40)+"."+i%40,""),r=2;r<e.length;r+=2){var o=("00000000"+parseInt(e.substr(r,2),16).toString(2)).slice(-8);if(n+=o.substr(1,7),"0"==o.substr(0,1))t=t+"."+new h(n,2).toString(10),n=""}return t},u.asn1.ASN1Util.oidIntToHex=function(e){var t=function(e){var t=e.toString(16);return 1==t.length&&(t="0"+t),t},i=function(e){var i="",n=new h(e,10).toString(2),r=7-n.length%7;7==r&&(r=0);for(var o="",s=0;s<r;s++)o+="0";n=o+n;for(s=0;s<n.length-1;s+=7){var a=n.substr(s,7);s!=n.length-7&&(a="1"+a),i+=t(parseInt(a,2))}return i};if(!e.match(/^[0-9.]+$/))throw"malformed oid string: "+e;var n="",r=e.split("."),o=40*parseInt(r[0])+parseInt(r[1]);n+=t(o),r.splice(0,2);for(var s=0;s<r.length;s++)n+=i(r[s]);return n},u.asn1.ASN1Object=function(e){this.params=null,this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw new Error("this.hV is null or undefined");if(this.hV.length%2==1)throw new Error("value hex must be even length: n="+"".length+",v="+this.hV);var e=this.hV.length/2,t=e.toString(16);if(t.length%2==1&&(t="0"+t),e<128)return t;var i=t.length/2;if(i>15)throw"ASN.1 length too long to represent by 8x: n = "+e.toString(16);return(128+i).toString(16)+t},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""},this.setByParam=function(e){this.params=e},null!=e&&null!=e.tlv&&(this.hTLV=e.tlv,this.isModified=!1)},u.asn1.DERAbstractString=function(e){u.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(e){this.hTLV=null,this.isModified=!0,this.s=e,this.hV=ie(this.s).toLowerCase()},this.setStringHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e?this.setString(e):void 0!==e.str?this.setString(e.str):void 0!==e.hex&&this.setStringHex(e.hex))},c.lang.extend(u.asn1.DERAbstractString,u.asn1.ASN1Object),u.asn1.DERAbstractTime=function(e){u.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(e){var t=e.getTime()+6e4*e.getTimezoneOffset();return new Date(t)},this.formatDate=function(e,t,i){var n=this.zeroPadding,r=this.localDateToUTC(e),o=String(r.getFullYear());"utc"==t&&(o=o.substr(2,2));var s=o+n(String(r.getMonth()+1),2)+n(String(r.getDate()),2)+n(String(r.getHours()),2)+n(String(r.getMinutes()),2)+n(String(r.getSeconds()),2);if(!0===i){var a=r.getMilliseconds();if(0!=a){var u=n(String(a),3);s=s+"."+(u=u.replace(/[0]+$/,""))}}return s+"Z"},this.zeroPadding=function(e,t){return e.length>=t?e:new Array(t-e.length+1).join("0")+e},this.getString=function(){return this.s},this.setString=function(e){this.hTLV=null,this.isModified=!0,this.s=e,this.hV=J(e)},this.setByDateValue=function(e,t,i,n,r,o){var s=new Date(Date.UTC(e,t-1,i,n,r,o,0));this.setByDate(s)},this.getFreshValueHex=function(){return this.hV}},c.lang.extend(u.asn1.DERAbstractTime,u.asn1.ASN1Object),u.asn1.DERAbstractStructured=function(e){u.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(e){this.hTLV=null,this.isModified=!0,this.asn1Array=e},this.appendASN1Object=function(e){this.hTLV=null,this.isModified=!0,this.asn1Array.push(e)},this.asn1Array=new Array,void 0!==e&&void 0!==e.array&&(this.asn1Array=e.array)},c.lang.extend(u.asn1.DERAbstractStructured,u.asn1.ASN1Object),u.asn1.DERBoolean=function(e){u.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=0==e?"010100":"0101ff"},c.lang.extend(u.asn1.DERBoolean,u.asn1.ASN1Object),u.asn1.DERInteger=function(e){u.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(e){this.hTLV=null,this.isModified=!0,this.hV=u.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e)},this.setByInteger=function(e){var t=new h(String(e),10);this.setByBigInteger(t)},this.setValueHex=function(e){this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.bigint?this.setByBigInteger(e.bigint):void 0!==e.int?this.setByInteger(e.int):"number"==typeof e?this.setByInteger(e):void 0!==e.hex&&this.setValueHex(e.hex))},c.lang.extend(u.asn1.DERInteger,u.asn1.ASN1Object),u.asn1.DERBitString=function(e){if(void 0!==e&&void 0!==e.obj){var t=u.asn1.ASN1Util.newObject(e.obj);e.hex="00"+t.getEncodedHex()}u.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(e){this.hTLV=null,this.isModified=!0,this.hV=e},this.setUnusedBitsAndHexValue=function(e,t){if(e<0||7<e)throw"unused bits shall be from 0 to 7: u = "+e;var i="0"+e;this.hTLV=null,this.isModified=!0,this.hV=i+t},this.setByBinaryString=function(e){var t=8-(e=e.replace(/0+$/,"")).length%8;8==t&&(t=0);for(var i=0;i<=t;i++)e+="0";var n="";for(i=0;i<e.length-1;i+=8){var r=e.substr(i,8),o=parseInt(r,2).toString(16);1==o.length&&(o="0"+o),n+=o}this.hTLV=null,this.isModified=!0,this.hV="0"+t+n},this.setByBooleanArray=function(e){for(var t="",i=0;i<e.length;i++)1==e[i]?t+="1":t+="0";this.setByBinaryString(t)},this.newFalseArray=function(e){for(var t=new Array(e),i=0;i<e;i++)t[i]=!1;return t},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e&&e.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(e):void 0!==e.hex?this.setHexValueIncludingUnusedBits(e.hex):void 0!==e.bin?this.setByBinaryString(e.bin):void 0!==e.array&&this.setByBooleanArray(e.array))},c.lang.extend(u.asn1.DERBitString,u.asn1.ASN1Object),u.asn1.DEROctetString=function(e){if(void 0!==e&&void 0!==e.obj){var t=u.asn1.ASN1Util.newObject(e.obj);e.hex=t.getEncodedHex()}u.asn1.DEROctetString.superclass.constructor.call(this,e),this.hT="04"},c.lang.extend(u.asn1.DEROctetString,u.asn1.DERAbstractString),u.asn1.DERNull=function(){u.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},c.lang.extend(u.asn1.DERNull,u.asn1.ASN1Object),u.asn1.DERObjectIdentifier=function(e){u.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueOidString=function(e){var t=function(e){var t=function(e){var t=e.toString(16);return 1==t.length&&(t="0"+t),t},i=function(e){var i="",n=parseInt(e,10).toString(2),r=7-n.length%7;7==r&&(r=0);for(var o="",s=0;s<r;s++)o+="0";for(n=o+n,s=0;s<n.length-1;s+=7){var a=n.substr(s,7);s!=n.length-7&&(a="1"+a),i+=t(parseInt(a,2))}return i};try{if(!e.match(/^[0-9.]+$/))return null;var n="",r=e.split("."),o=40*parseInt(r[0],10)+parseInt(r[1],10);n+=t(o),r.splice(0,2);for(var s=0;s<r.length;s++)n+=i(r[s]);return n}catch(e){return null}}(e);if(null==t)throw new Error("malformed oid string: "+e);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueName=function(e){var t=u.asn1.x509.OID.name2oid(e);if(""===t)throw new Error("DERObjectIdentifier oidName undefined: "+e);this.setValueOidString(t)},this.setValueNameOrOid=function(e){e.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(e):this.setValueName(e)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(e){"string"==typeof e?this.setValueNameOrOid(e):void 0!==e.oid?this.setValueNameOrOid(e.oid):void 0!==e.name?this.setValueNameOrOid(e.name):void 0!==e.hex&&this.setValueHex(e.hex)},void 0!==e&&this.setByParam(e)},c.lang.extend(u.asn1.DERObjectIdentifier,u.asn1.ASN1Object),u.asn1.DEREnumerated=function(e){u.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(e){this.hTLV=null,this.isModified=!0,this.hV=u.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e)},this.setByInteger=function(e){var t=new h(String(e),10);this.setByBigInteger(t)},this.setValueHex=function(e){this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.int?this.setByInteger(e.int):"number"==typeof e?this.setByInteger(e):void 0!==e.hex&&this.setValueHex(e.hex))},c.lang.extend(u.asn1.DEREnumerated,u.asn1.ASN1Object),u.asn1.DERUTF8String=function(e){u.asn1.DERUTF8String.superclass.constructor.call(this,e),this.hT="0c"},c.lang.extend(u.asn1.DERUTF8String,u.asn1.DERAbstractString),u.asn1.DERNumericString=function(e){u.asn1.DERNumericString.superclass.constructor.call(this,e),this.hT="12"},c.lang.extend(u.asn1.DERNumericString,u.asn1.DERAbstractString),u.asn1.DERPrintableString=function(e){u.asn1.DERPrintableString.superclass.constructor.call(this,e),this.hT="13"},c.lang.extend(u.asn1.DERPrintableString,u.asn1.DERAbstractString),u.asn1.DERTeletexString=function(e){u.asn1.DERTeletexString.superclass.constructor.call(this,e),this.hT="14"},c.lang.extend(u.asn1.DERTeletexString,u.asn1.DERAbstractString),u.asn1.DERIA5String=function(e){u.asn1.DERIA5String.superclass.constructor.call(this,e),this.hT="16"},c.lang.extend(u.asn1.DERIA5String,u.asn1.DERAbstractString),u.asn1.DERVisibleString=function(e){u.asn1.DERIA5String.superclass.constructor.call(this,e),this.hT="1a"},c.lang.extend(u.asn1.DERVisibleString,u.asn1.DERAbstractString),u.asn1.DERBMPString=function(e){u.asn1.DERBMPString.superclass.constructor.call(this,e),this.hT="1e"},c.lang.extend(u.asn1.DERBMPString,u.asn1.DERAbstractString),u.asn1.DERUTCTime=function(e){u.asn1.DERUTCTime.superclass.constructor.call(this,e),this.hT="17",this.setByDate=function(e){this.hTLV=null,this.isModified=!0,this.date=e,this.s=this.formatDate(this.date,"utc"),this.hV=J(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=J(this.s)),this.hV},void 0!==e&&(void 0!==e.str?this.setString(e.str):"string"==typeof e&&e.match(/^[0-9]{12}Z$/)?this.setString(e):void 0!==e.hex?this.setStringHex(e.hex):void 0!==e.date&&this.setByDate(e.date))},c.lang.extend(u.asn1.DERUTCTime,u.asn1.DERAbstractTime),u.asn1.DERGeneralizedTime=function(e){u.asn1.DERGeneralizedTime.superclass.constructor.call(this,e),this.hT="18",this.withMillis=!1,this.setByDate=function(e){this.hTLV=null,this.isModified=!0,this.date=e,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=J(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=J(this.s)),this.hV},void 0!==e&&(void 0!==e.str?this.setString(e.str):"string"==typeof e&&e.match(/^[0-9]{14}Z$/)?this.setString(e):void 0!==e.hex?this.setStringHex(e.hex):void 0!==e.date&&this.setByDate(e.date),!0===e.millis&&(this.withMillis=!0))},c.lang.extend(u.asn1.DERGeneralizedTime,u.asn1.DERAbstractTime),u.asn1.DERSequence=function(e){u.asn1.DERSequence.superclass.constructor.call(this,e),this.hT="30",this.getFreshValueHex=function(){for(var e="",t=0;t<this.asn1Array.length;t++){e+=this.asn1Array[t].getEncodedHex()}return this.hV=e,this.hV}},c.lang.extend(u.asn1.DERSequence,u.asn1.DERAbstractStructured),u.asn1.DERSet=function(e){u.asn1.DERSet.superclass.constructor.call(this,e),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var e=new Array,t=0;t<this.asn1Array.length;t++){var i=this.asn1Array[t];e.push(i.getEncodedHex())}return 1==this.sortFlag&&e.sort(),this.hV=e.join(""),this.hV},void 0!==e&&void 0!==e.sortflag&&0==e.sortflag&&(this.sortFlag=!1)},c.lang.extend(u.asn1.DERSet,u.asn1.DERAbstractStructured),u.asn1.DERTaggedObject=function(e){u.asn1.DERTaggedObject.superclass.constructor.call(this);var t=u.asn1;this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(e,t,i){this.hT=t,this.isExplicit=e,this.asn1Object=i,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=i.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,t),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(e){null!=e.tag&&(this.hT=e.tag),null!=e.explicit&&(this.isExplicit=e.explicit),null!=e.tage&&(this.hT=e.tage,this.isExplicit=!0),null!=e.tagi&&(this.hT=e.tagi,this.isExplicit=!1),null!=e.obj&&(e.obj instanceof t.ASN1Object?(this.asn1Object=e.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)):"object"==typeof e.obj&&(this.asn1Object=t.ASN1Util.newObject(e.obj),this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},null!=e&&this.setByParam(e)},c.lang.extend(u.asn1.DERTaggedObject,u.asn1.ASN1Object);var Te=new function(){};function xe(e,t){for(var i="",n=t/4-e.length,r=0;r<n;r++)i+="0";return i+e}function Ee(e,t,i){for(var n="",r=0;n.length<t;)n+=re(i(oe(e+String.fromCharCode.apply(String,[(4278190080&r)>>24,(16711680&r)>>16,(65280&r)>>8,255&r])))),r+=1;return n}function je(e){for(var t in u.crypto.Util.DIGESTINFOHEAD){var i=u.crypto.Util.DIGESTINFOHEAD[t],n=i.length;if(e.substring(0,n)==i)return[t,e.substring(n)]}return[]}function ze(e){var t,i=Te,n=i.getChildIdx,r=i.getV,o=i.getTLV,s=i.getVbyList,a=i.getVbyListEx,c=i.getTLVbyList,l=i.getTLVbyListEx,h=i.getIdxbyList,d=i.getIdxbyListEx,p=i.getVidx,A=i.getInt,f=i.oidname,M=i.hextooidstr,g=ue;try{t=u.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV}catch(e){}this.HEX2STAG={"0c":"utf8",13:"prn",16:"ia5","1a":"vis","1e":"bmp"},this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){if(null===this.hex||0!==this.version)return this.version;var e=c(this.hex,0,[0,0]);if("a0"==e.substr(0,2)){var t=c(e,0,[0]),i=A(t,0);if(i<0||2<i)throw new Error("malformed version field");return this.version=i+1,this.version}return this.version=1,this.foffset=-1,1},this.getSerialNumberHex=function(){return a(this.hex,0,[0,0],"02")},this.getSignatureAlgorithmField=function(){var e=l(this.hex,0,[0,1]);return this.getAlgorithmIdentifierName(e)},this.getAlgorithmIdentifierName=function(e){for(var i in t)if(e===t[i])return i;return f(a(e,0,[0],"06"))},this.getIssuer=function(){return this.getX500Name(this.getIssuerHex())},this.getIssuerHex=function(){return c(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return this.getIssuer().str},this.getSubject=function(){return this.getX500Name(this.getSubjectHex())},this.getSubjectHex=function(){return c(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return this.getSubject().str},this.getNotBefore=function(){var e=s(this.hex,0,[0,4+this.foffset,0]);return e=e.replace(/(..)/g,"%$1"),e=decodeURIComponent(e)},this.getNotAfter=function(){var e=s(this.hex,0,[0,4+this.foffset,1]);return e=e.replace(/(..)/g,"%$1"),e=decodeURIComponent(e)},this.getPublicKeyHex=function(){return i.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return h(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var e=this.getPublicKeyIdx();return h(this.hex,e,[1,0],"30")},this.getPublicKey=function(){return we.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){var e=c(this.hex,0,[1],"30");return this.getAlgorithmIdentifierName(e)},this.getSignatureValueHex=function(){return s(this.hex,0,[2],"03",!0)},this.verifySignature=function(e){var t=this.getSignatureAlgorithmField(),i=this.getSignatureValueHex(),n=c(this.hex,0,[0],"30"),r=new u.crypto.Signature({alg:t});return r.init(e),r.updateHex(n),r.verify(i)},this.parseExt=function(e){var t,o,a;if(void 0===e){if(a=this.hex,3!==this.version)return-1;t=h(a,0,[0,7,0],"30"),o=n(a,t)}else{a=ue(e);var u=h(a,0,[0,3,0,0],"06");if("2a864886f70d01090e"!=r(a,u))return void(this.aExtInfo=new Array);t=h(a,0,[0,3,0,1,0],"30"),o=n(a,t),this.hex=a}this.aExtInfo=new Array;for(var c=0;c<o.length;c++){var l={critical:!1},d=0;3===n(a,o[c]).length&&(l.critical=!0,d=1),l.oid=i.hextooidstr(s(a,o[c],[0],"06"));var A=h(a,o[c],[1+d]);l.vidx=p(a,A),this.aExtInfo.push(l)}},this.getExtInfo=function(e){var t=this.aExtInfo,i=e;if(e.match(/^[0-9.]+$/)||(i=u.asn1.x509.OID.name2oid(e)),""!==i)for(var n=0;n<t.length;n++)if(t[n].oid===i)return t[n]},this.getExtBasicConstraints=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("basicConstraints");if(void 0===i)return;e=o(this.hex,i.vidx),t=i.critical}var n={extname:"basicConstraints"};if(t&&(n.critical=!0),"3000"===e)return n;if("30030101ff"===e)return n.cA=!0,n;if("30060101ff02"===e.substr(0,12)){var s=r(e,10),a=parseInt(s,16);return n.cA=!0,n.pathLen=a,n}throw new Error("hExtV parse error: "+e)},this.getExtKeyUsage=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("keyUsage");if(void 0===i)return;e=o(this.hex,i.vidx),t=i.critical}var n={extname:"keyUsage"};return t&&(n.critical=!0),n.names=this.getExtKeyUsageString(e).split(","),n},this.getExtKeyUsageBin=function(e){if(void 0===e){var t=this.getExtInfo("keyUsage");if(void 0===t)return"";e=o(this.hex,t.vidx)}if(8!=e.length&&10!=e.length)throw new Error("malformed key usage value: "+e);var i="000000000000000"+parseInt(e.substr(6),16).toString(2);return 8==e.length&&(i=i.slice(-8)),10==e.length&&(i=i.slice(-16)),""==(i=i.replace(/0+$/,""))&&(i="0"),i},this.getExtKeyUsageString=function(e){for(var t=this.getExtKeyUsageBin(e),i=new Array,n=0;n<t.length;n++)"1"==t.substr(n,1)&&i.push(ze.KEYUSAGE_NAME[n]);return i.join(",")},this.getExtSubjectKeyIdentifier=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("subjectKeyIdentifier");if(void 0===i)return;e=o(this.hex,i.vidx),t=i.critical}var n={extname:"subjectKeyIdentifier"};t&&(n.critical=!0);var s=r(e,0);return n.kid={hex:s},n},this.getExtAuthorityKeyIdentifier=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("authorityKeyIdentifier");if(void 0===i)return;e=o(this.hex,i.vidx),t=i.critical}var s={extname:"authorityKeyIdentifier"};t&&(s.critical=!0);for(var a=n(e,0),u=0;u<a.length;u++){var c=e.substr(a[u],2);if("80"===c&&(s.kid={hex:r(e,a[u])}),"a1"===c){var l=o(e,a[u]),h=this.getGeneralNames(l);s.issuer=h[0].dn}"82"===c&&(s.sn={hex:r(e,a[u])})}return s},this.getExtExtKeyUsage=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("extKeyUsage");if(void 0===i)return;e=o(this.hex,i.vidx),t=i.critical}var s={extname:"extKeyUsage",array:[]};t&&(s.critical=!0);for(var a=n(e,0),u=0;u<a.length;u++)s.array.push(f(r(e,a[u])));return s},this.getExtExtKeyUsageName=function(){var e=this.getExtInfo("extKeyUsage");if(void 0===e)return e;var t=new Array,i=o(this.hex,e.vidx);if(""===i)return t;for(var s=n(i,0),a=0;a<s.length;a++)t.push(f(r(i,s[a])));return t},this.getExtSubjectAltName=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("subjectAltName");if(void 0===i)return;e=o(this.hex,i.vidx),t=i.critical}var n={extname:"subjectAltName",array:[]};return t&&(n.critical=!0),n.array=this.getGeneralNames(e),n},this.getExtIssuerAltName=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("issuerAltName");if(void 0===i)return;e=o(this.hex,i.vidx),t=i.critical}var n={extname:"issuerAltName",array:[]};return t&&(n.critical=!0),n.array=this.getGeneralNames(e),n},this.getGeneralNames=function(e){for(var t=n(e,0),i=[],r=0;r<t.length;r++){var s=this.getGeneralName(o(e,t[r]));void 0!==s&&i.push(s)}return i},this.getGeneralName=function(e){var t=e.substr(0,2),i=r(e,0),n=re(i);return"81"==t?{rfc822:n}:"82"==t?{dns:n}:"86"==t?{uri:n}:"87"==t?{ip:ce(i)}:"a4"==t?{dn:this.getX500Name(i)}:void 0},this.getExtSubjectAltName2=function(){var e,t,i,s=this.getExtInfo("subjectAltName");if(void 0===s)return s;for(var a=new Array,u=o(this.hex,s.vidx),c=n(u,0),l=0;l<c.length;l++)i=u.substr(c[l],2),e=r(u,c[l]),"81"===i&&(t=ne(e),a.push(["MAIL",t])),"82"===i&&(t=ne(e),a.push(["DNS",t])),"84"===i&&(t=ze.hex2dn(e,0),a.push(["DN",t])),"86"===i&&(t=ne(e),a.push(["URI",t])),"87"===i&&(t=ce(e),a.push(["IP",t]));return a},this.getExtCRLDistributionPoints=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("cRLDistributionPoints");if(void 0===i)return;e=o(this.hex,i.vidx),t=i.critical}var r={extname:"cRLDistributionPoints",array:[]};t&&(r.critical=!0);for(var s=n(e,0),a=0;a<s.length;a++){var u=o(e,s[a]);r.array.push(this.getDistributionPoint(u))}return r},this.getDistributionPoint=function(e){for(var t={},i=n(e,0),r=0;r<i.length;r++){var s=e.substr(i[r],2),a=o(e,i[r]);"a0"==s&&(t.dpname=this.getDistributionPointName(a))}return t},this.getDistributionPointName=function(e){for(var t={},i=n(e,0),r=0;r<i.length;r++){var s=e.substr(i[r],2),a=o(e,i[r]);"a0"==s&&(t.full=this.getGeneralNames(a))}return t},this.getExtCRLDistributionPointsURI=function(){var e=this.getExtInfo("cRLDistributionPoints");if(void 0===e)return e;for(var t=new Array,i=n(this.hex,e.vidx),r=0;r<i.length;r++)try{var o=ne(s(this.hex,i[r],[0,0,0],"86"));t.push(o)}catch(e){}return t},this.getExtAIAInfo=function(){var e=this.getExtInfo("authorityInfoAccess");if(void 0===e)return e;for(var t={ocsp:[],caissuer:[]},i=n(this.hex,e.vidx),r=0;r<i.length;r++){var o=s(this.hex,i[r],[0],"06"),a=s(this.hex,i[r],[1],"86");"2b06010505073001"===o&&t.ocsp.push(ne(a)),"2b06010505073002"===o&&t.caissuer.push(ne(a))}return t},this.getExtAuthorityInfoAccess=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("authorityInfoAccess");if(void 0===i)return;e=o(this.hex,i.vidx),t=i.critical}var r={extname:"authorityInfoAccess",array:[]};t&&(r.critical=!0);for(var u=n(e,0),c=0;c<u.length;c++){var l=a(e,u[c],[0],"06"),h=ne(s(e,u[c],[1],"86"));if("2b06010505073001"==l)r.array.push({ocsp:h});else{if("2b06010505073002"!=l)throw new Error("unknown method: "+l);r.array.push({caissuer:h})}}return r},this.getExtCertificatePolicies=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("certificatePolicies");if(void 0===i)return;e=o(this.hex,i.vidx),t=i.critical}var r={extname:"certificatePolicies",array:[]};t&&(r.critical=!0);for(var s=n(e,0),a=0;a<s.length;a++){var u=o(e,s[a]),c=this.getPolicyInformation(u);r.array.push(c)}return r},this.getPolicyInformation=function(e){var t={},i=s(e,0,[0],"06");t.policyoid=f(i);var r=d(e,0,[1],"30");if(-1!=r){t.array=[];for(var a=n(e,r),u=0;u<a.length;u++){var c=o(e,a[u]),l=this.getPolicyQualifierInfo(c);t.array.push(l)}}return t},this.getPolicyQualifierInfo=function(e){var t={},i=s(e,0,[0],"06");if("2b06010505070201"===i){var n=a(e,0,[1],"16");t.cps=re(n)}else if("2b06010505070202"===i){var r=c(e,0,[1],"30");t.unotice=this.getUserNotice(r)}return t},this.getUserNotice=function(e){for(var t={},i=n(e,0),r=0;r<i.length;r++){var s=o(e,i[r]);"30"!=s.substr(0,2)&&(t.exptext=this.getDisplayText(s))}return t},this.getDisplayText=function(e){var t={};return t.type={"0c":"utf8",16:"ia5","1a":"vis","1e":"bmp"}[e.substr(0,2)],t.str=re(r(e,0)),t},this.getExtCRLNumber=function(e,t){var i={extname:"cRLNumber"};if(t&&(i.critical=!0),"02"==e.substr(0,2))return i.num={hex:r(e,0)},i;throw new Error("hExtV parse error: "+e)},this.getExtCRLReason=function(e,t){var i={extname:"cRLReason"};if(t&&(i.critical=!0),"0a"==e.substr(0,2))return i.code=parseInt(r(e,0),16),i;throw new Error("hExtV parse error: "+e)},this.getExtOcspNonce=function(e,t){var i={extname:"ocspNonce"};t&&(i.critical=!0);var n=r(e,0);return i.hex=n,i},this.getExtOcspNoCheck=function(e,t){var i={extname:"ocspNoCheck"};return t&&(i.critical=!0),i},this.getExtAdobeTimeStamp=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("adobeTimeStamp");if(void 0===i)return;e=o(this.hex,i.vidx),t=i.critical}var r={extname:"adobeTimeStamp"};t&&(r.critical=!0);var s=n(e,0);if(s.length>1){var a=o(e,s[1]),u=this.getGeneralName(a);null!=u.uri&&(r.uri=u.uri)}if(s.length>2){var c=o(e,s[2]);"0101ff"==c&&(r.reqauth=!0),"010100"==c&&(r.reqauth=!1)}return r},this.getX500NameRule=function(e){for(var t=null,i=[],n=0;n<e.length;n++)for(var r=e[n],o=0;o<r.length;o++)i.push(r[o]);for(n=0;n<i.length;n++){var s=i[n],a=s.ds,c=s.value,l=s.type;if("prn"!=a&&"utf8"!=a&&"ia5"!=a)return"mixed";if("ia5"==a){if("CN"!=l)return"mixed";if(u.lang.String.isMail(c))continue;return"mixed"}if("C"==l){if("prn"==a)continue;return"mixed"}if(null==t)t=a;else if(t!==a)return"mixed"}return null==t?"prn":t},this.getX500Name=function(e){var t=this.getX500NameArray(e);return{array:t,str:this.dnarraytostr(t)}},this.getX500NameArray=function(e){for(var t=[],i=n(e,0),r=0;r<i.length;r++)t.push(this.getRDN(o(e,i[r])));return t},this.getRDN=function(e){for(var t=[],i=n(e,0),r=0;r<i.length;r++)t.push(this.getAttrTypeAndValue(o(e,i[r])));return t},this.getAttrTypeAndValue=function(e){var t={type:null,value:null,ds:null},i=n(e,0),r=s(e,i[0],[],"06"),o=s(e,i[1],[]),a=u.asn1.ASN1Util.oidHexToInt(r);return t.type=u.asn1.x509.OID.oid2atype(a),t.ds=this.HEX2STAG[e.substr(i[1],2)],"bmp"!=t.ds?t.value=ne(o):t.value=le(o),t},this.readCertPEM=function(e){this.readCertHex(g(e))},this.readCertHex=function(e){this.hex=e,this.getVersion();try{h(this.hex,0,[0,7],"a3"),this.parseExt()}catch(e){}},this.getParam=function(){var e={};return e.version=this.getVersion(),e.serial={hex:this.getSerialNumberHex()},e.sigalg=this.getSignatureAlgorithmField(),e.issuer=this.getIssuer(),e.notbefore=this.getNotBefore(),e.notafter=this.getNotAfter(),e.subject=this.getSubject(),e.sbjpubkey=ae(this.getPublicKeyHex(),"PUBLIC KEY"),this.aExtInfo.length>0&&(e.ext=this.getExtParamArray()),e.sighex=this.getSignatureValueHex(),e},this.getExtParamArray=function(e){null==e&&(-1!=d(this.hex,0,[0,"[3]"])&&(e=l(this.hex,0,[0,"[3]",0],"30")));for(var t=[],i=n(e,0),r=0;r<i.length;r++){var s=o(e,i[r]),a=this.getExtParam(s);null!=a&&t.push(a)}return t},this.getExtParam=function(e){var t=n(e,0).length;if(2!=t&&3!=t)throw new Error("wrong number elements in Extension: "+t+" "+e);var i=M(s(e,0,[0],"06")),r=!1;3==t&&"0101ff"==c(e,0,[1])&&(r=!0);var o=c(e,0,[t-1,0]),a=void 0;if("2.5.29.14"==i?a=this.getExtSubjectKeyIdentifier(o,r):"2.5.29.15"==i?a=this.getExtKeyUsage(o,r):"2.5.29.17"==i?a=this.getExtSubjectAltName(o,r):"2.5.29.18"==i?a=this.getExtIssuerAltName(o,r):"2.5.29.19"==i?a=this.getExtBasicConstraints(o,r):"2.5.29.31"==i?a=this.getExtCRLDistributionPoints(o,r):"2.5.29.32"==i?a=this.getExtCertificatePolicies(o,r):"2.5.29.35"==i?a=this.getExtAuthorityKeyIdentifier(o,r):"2.5.29.37"==i?a=this.getExtExtKeyUsage(o,r):"1.3.6.1.5.5.7.1.1"==i?a=this.getExtAuthorityInfoAccess(o,r):"2.5.29.20"==i?a=this.getExtCRLNumber(o,r):"2.5.29.21"==i?a=this.getExtCRLReason(o,r):"1.3.6.1.5.5.7.48.1.2"==i?a=this.getExtOcspNonce(o,r):"1.3.6.1.5.5.7.48.1.5"==i?a=this.getExtOcspNoCheck(o,r):"1.2.840.113583.1.1.9.1"==i&&(a=this.getExtAdobeTimeStamp(o,r)),null!=a)return a;var u={extname:i,extn:o};return r&&(u.critical=!0),u},this.findExt=function(e,t){for(var i=0;i<e.length;i++)if(e[i].extname==t)return e[i];return null},this.updateExtCDPFullURI=function(e,t){var i=this.findExt(e,"cRLDistributionPoints");if(null!=i&&null!=i.array)for(var n=i.array,r=0;r<n.length;r++)if(null!=n[r].dpname&&null!=n[r].dpname.full)for(var o=n[r].dpname.full,s=0;s<o.length;s++){var a=o[r];null!=a.uri&&(a.uri=t)}},this.updateExtAIAOCSP=function(e,t){var i=this.findExt(e,"authorityInfoAccess");if(null!=i&&null!=i.array)for(var n=i.array,r=0;r<n.length;r++)null!=n[r].ocsp&&(n[r].ocsp=t)},this.updateExtAIACAIssuer=function(e,t){var i=this.findExt(e,"authorityInfoAccess");if(null!=i&&null!=i.array)for(var n=i.array,r=0;r<n.length;r++)null!=n[r].caissuer&&(n[r].caissuer=t)},this.dnarraytostr=function(e){return"/"+e.map((function(e){return function(e){return e.map((function(e){return function(e){return e.type+"="+e.value}(e).replace(/\+/,"\\+")})).join("+")}(e).replace(/\//,"\\/")})).join("/")},this.getInfo=function(){var e,t,i,n,r=function(e){for(var t="",i=e.array,n=0;n<i.length;n++){var r=i[n];if(t+=" policy oid: "+r.policyoid+"\n",void 0!==r.array)for(var o=0;o<r.array.length;o++){var s=r.array[o];void 0!==s.cps&&(t+=" cps: "+s.cps+"\n")}}return t},o=function(e){for(var t="",i=e.array,n=0;n<i.length;n++){var r=i[n];try{void 0!==r.dpname.full[0].uri&&(t+=" "+r.dpname.full[0].uri+"\n")}catch(e){}try{void 0!==r.dname.full[0].dn.hex&&(t+=" "+ze.hex2dn(r.dpname.full[0].dn.hex)+"\n")}catch(e){}}return t},s=function(e){for(var t="",i=e.array,n=0;n<i.length;n++){var r=i[n];void 0!==r.caissuer&&(t+=" caissuer: "+r.caissuer+"\n"),void 0!==r.ocsp&&(t+=" ocsp: "+r.ocsp+"\n")}return t};if(e="Basic Fields\n",e+=" serial number: "+this.getSerialNumberHex()+"\n",e+=" signature algorithm: "+this.getSignatureAlgorithmField()+"\n",e+=" issuer: "+this.getIssuerString()+"\n",e+=" notBefore: "+this.getNotBefore()+"\n",e+=" notAfter: "+this.getNotAfter()+"\n",e+=" subject: "+this.getSubjectString()+"\n",e+=" subject public key info: \n",e+=" key algorithm: "+(t=this.getPublicKey()).type+"\n","RSA"===t.type&&(e+=" n="+de(t.n.toString(16)).substr(0,16)+"...\n",e+=" e="+de(t.e.toString(16))+"\n"),null!=(i=this.aExtInfo)){e+="X509v3 Extensions:\n";for(var a=0;a<i.length;a++){var c=i[a],l=u.asn1.x509.OID.oid2name(c.oid);""===l&&(l=c.oid);var h="";if(!0===c.critical&&(h="CRITICAL"),e+=" "+l+" "+h+":\n","basicConstraints"===l){var d=this.getExtBasicConstraints();void 0===d.cA?e+=" {}\n":(e+=" cA=true",void 0!==d.pathLen&&(e+=", pathLen="+d.pathLen),e+="\n")}else if("keyUsage"===l)e+=" "+this.getExtKeyUsageString()+"\n";else if("subjectKeyIdentifier"===l)e+=" "+this.getExtSubjectKeyIdentifier().kid.hex+"\n";else if("authorityKeyIdentifier"===l){var p=this.getExtAuthorityKeyIdentifier();void 0!==p.kid&&(e+=" kid="+p.kid.hex+"\n")}else{if("extKeyUsage"===l)e+=" "+this.getExtExtKeyUsage().array.join(", ")+"\n";else if("subjectAltName"===l)e+=" "+(n=this.getExtSubjectAltName(),JSON.stringify(n.array).replace(/[\[\]\{\}\"]/g,""))+"\n";else if("cRLDistributionPoints"===l)e+=o(this.getExtCRLDistributionPoints());else if("authorityInfoAccess"===l)e+=s(this.getExtAuthorityInfoAccess());else"certificatePolicies"===l&&(e+=r(this.getExtCertificatePolicies()))}}}return e+="signature algorithm: "+this.getSignatureAlgorithmName()+"\n",e+="signature: "+this.getSignatureValueHex().substr(0,16)+"...\n"},"string"==typeof e&&(-1!=e.indexOf("-----BEGIN")?this.readCertPEM(e):u.lang.String.isHex(e)&&this.readCertHex(e))}function Ie(e){return l.SHA256(e).toString()}Te.getLblen=function(e,t){if("8"!=e.substr(t+2,1))return 1;var i=parseInt(e.substr(t+3,1));return 0==i?-1:0<i&&i<10?i+1:-2},Te.getL=function(e,t){var i=Te.getLblen(e,t);return i<1?"":e.substr(t+2,2*i)},Te.getVblen=function(e,t){var i;return""==(i=Te.getL(e,t))?-1:("8"===i.substr(0,1)?new h(i.substr(2),16):new h(i,16)).intValue()},Te.getVidx=function(e,t){var i=Te.getLblen(e,t);return i<0?i:t+2*(i+1)},Te.getV=function(e,t){var i=Te.getVidx(e,t),n=Te.getVblen(e,t);return e.substr(i,2*n)},Te.getTLV=function(e,t){return e.substr(t,2)+Te.getL(e,t)+Te.getV(e,t)},Te.getTLVblen=function(e,t){return 2+2*Te.getLblen(e,t)+2*Te.getVblen(e,t)},Te.getNextSiblingIdx=function(e,t){return Te.getVidx(e,t)+2*Te.getVblen(e,t)},Te.getChildIdx=function(e,t){var i,n,r,o=Te,s=[];i=o.getVidx(e,t),n=2*o.getVblen(e,t),"03"==e.substr(t,2)&&(i+=2,n-=2),r=0;for(var a=i;r<=n;){var u=o.getTLVblen(e,a);if((r+=u)<=n&&s.push(a),a+=u,r>=n)break}return s},Te.getNthChildIdx=function(e,t,i){return Te.getChildIdx(e,t)[i]},Te.getIdxbyList=function(e,t,i,n){var r,o,s=Te;return 0==i.length?void 0!==n&&e.substr(t,2)!==n?-1:t:(r=i.shift())>=(o=s.getChildIdx(e,t)).length?-1:s.getIdxbyList(e,o[r],i,n)},Te.getIdxbyListEx=function(e,t,i,n){var r,o,s=Te;if(0==i.length)return void 0!==n&&e.substr(t,2)!==n?-1:t;r=i.shift(),o=s.getChildIdx(e,t);for(var a=0,u=0;u<o.length;u++){var c=e.substr(o[u],2);if("number"==typeof r&&!s.isContextTag(c)&&a==r||"string"==typeof r&&s.isContextTag(c,r))return s.getIdxbyListEx(e,o[u],i,n);s.isContextTag(c)||a++}return-1},Te.getTLVbyList=function(e,t,i,n){var r=Te,o=r.getIdxbyList(e,t,i,n);return-1==o||o>=e.length?null:r.getTLV(e,o)},Te.getTLVbyListEx=function(e,t,i,n){var r=Te,o=r.getIdxbyListEx(e,t,i,n);return-1==o?null:r.getTLV(e,o)},Te.getVbyList=function(e,t,i,n,r){var o,s,a=Te;return-1==(o=a.getIdxbyList(e,t,i,n))||o>=e.length?null:(s=a.getV(e,o),!0===r&&(s=s.substr(2)),s)},Te.getVbyListEx=function(e,t,i,n,r){var o,s,a=Te;return-1==(o=a.getIdxbyListEx(e,t,i,n))?null:(s=a.getV(e,o),"03"==e.substr(o,2)&&!1!==r&&(s=s.substr(2)),s)},Te.getInt=function(e,t,i){null==i&&(i=-1);try{var n=e.substr(t,2);if("02"!=n&&"03"!=n)return i;var r=Te.getV(e,t);return"02"==n?parseInt(r,16):function(e){try{var t=e.substr(0,2);if("00"==t)return parseInt(e.substr(2),16);var i=parseInt(t,16),n=e.substr(2),r=parseInt(n,16).toString(2);return"0"==r&&(r="00000000"),r=r.slice(0,0-i),parseInt(r,2)}catch(e){return-1}}(r)}catch(e){return i}},Te.getOID=function(e,t,i){null==i&&(i=null);try{return"06"!=e.substr(t,2)?i:function(e){if(!he(e))return null;try{var t=[],i=e.substr(0,2),n=parseInt(i,16);t[0]=new String(Math.floor(n/40)),t[1]=new String(n%40);for(var r=e.substr(2),o=[],s=0;s<r.length/2;s++)o.push(parseInt(r.substr(2*s,2),16));var a=[],u="";for(s=0;s<o.length;s++)128&o[s]?u+=pe((127&o[s]).toString(2),7):(u+=pe((127&o[s]).toString(2),7),a.push(new String(parseInt(u,2))),u="");var c=t.join(".");return a.length>0&&(c=c+"."+a.join(".")),c}catch(e){return null}}(Te.getV(e,t))}catch(e){return i}},Te.getOIDName=function(e,t,i){null==i&&(i=null);try{var n=Te.getOID(e,t,i);if(n==i)return i;var r=u.asn1.x509.OID.oid2name(n);return""==r?n:r}catch(e){return i}},Te.getString=function(e,t,i){null==i&&(i=null);try{return re(Te.getV(e,t))}catch(e){return i}},Te.hextooidstr=function(e){var t=function(e,t){return e.length>=t?e:new Array(t-e.length+1).join("0")+e},i=[],n=e.substr(0,2),r=parseInt(n,16);i[0]=new String(Math.floor(r/40)),i[1]=new String(r%40);for(var o=e.substr(2),s=[],a=0;a<o.length/2;a++)s.push(parseInt(o.substr(2*a,2),16));var u=[],c="";for(a=0;a<s.length;a++)128&s[a]?c+=t((127&s[a]).toString(2),7):(c+=t((127&s[a]).toString(2),7),u.push(new String(parseInt(c,2))),c="");var l=i.join(".");return u.length>0&&(l=l+"."+u.join(".")),l},Te.dump=function(e,t,i,n){var r=Te,o=r.getV,s=r.dump,a=r.getChildIdx,c=e;e instanceof u.asn1.ASN1Object&&(c=e.getEncodedHex());var l=function(e,t){return e.length<=2*t?e:e.substr(0,t)+"..(total "+e.length/2+"bytes).."+e.substr(e.length-t,t)};void 0===t&&(t={ommit_long_octet:32}),void 0===i&&(i=0),void 0===n&&(n="");var h,d=t.ommit_long_octet;if("01"==(h=c.substr(i,2)))return"00"==(p=o(c,i))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==h)return n+"INTEGER "+l(p=o(c,i),d)+"\n";if("03"==h){var p=o(c,i);if(r.isASN1HEX(p.substr(2))){var A=n+"BITSTRING, encapsulates\n";return A+=s(p.substr(2),t,0,n+" ")}return n+"BITSTRING "+l(p,d)+"\n"}if("04"==h){p=o(c,i);if(r.isASN1HEX(p)){A=n+"OCTETSTRING, encapsulates\n";return A+=s(p,t,0,n+" ")}return n+"OCTETSTRING "+l(p,d)+"\n"}if("05"==h)return n+"NULL\n";if("06"==h){var f=o(c,i),M=u.asn1.ASN1Util.oidHexToInt(f),g=u.asn1.x509.OID.oid2name(M),y=M.replace(/\./g," ");return""!=g?n+"ObjectIdentifier "+g+" ("+y+")\n":n+"ObjectIdentifier ("+y+")\n"}if("0a"==h)return n+"ENUMERATED "+parseInt(o(c,i))+"\n";if("0c"==h)return n+"UTF8String '"+ne(o(c,i))+"'\n";if("13"==h)return n+"PrintableString '"+ne(o(c,i))+"'\n";if("14"==h)return n+"TeletexString '"+ne(o(c,i))+"'\n";if("16"==h)return n+"IA5String '"+ne(o(c,i))+"'\n";if("17"==h)return n+"UTCTime "+ne(o(c,i))+"\n";if("18"==h)return n+"GeneralizedTime "+ne(o(c,i))+"\n";if("1a"==h)return n+"VisualString '"+ne(o(c,i))+"'\n";if("1e"==h)return n+"BMPString '"+le(o(c,i))+"'\n";if("30"==h){if("3000"==c.substr(i,4))return n+"SEQUENCE {}\n";A=n+"SEQUENCE\n";var m=t;if((2==(D=a(c,i)).length||3==D.length)&&"06"==c.substr(D[0],2)&&"04"==c.substr(D[D.length-1],2)){g=r.oidname(o(c,D[0]));var v=JSON.parse(JSON.stringify(t));v.x509ExtName=g,m=v}for(var N=0;N<D.length;N++)A+=s(c,m,D[N],n+" ");return A}if("31"==h){A=n+"SET\n";var D=a(c,i);for(N=0;N<D.length;N++)A+=s(c,t,D[N],n+" ");return A}if(0!=(128&(h=parseInt(h,16)))){var w=31&h;if(0!=(32&h)){for(A=n+"["+w+"]\n",D=a(c,i),N=0;N<D.length;N++)A+=s(c,t,D[N],n+" ");return A}p=o(c,i);if(Te.isASN1HEX(p)){var A=n+"["+w+"]\n";return A+=s(p,t,0,n+" ")}return("68747470"==p.substr(0,8)||"subjectAltName"===t.x509ExtName&&2==w)&&(p=ne(p)),A=n+"["+w+"] "+p+"\n"}return n+"UNKNOWN("+h+") "+o(c,i)+"\n"},Te.isContextTag=function(e,t){var i,n;e=e.toLowerCase();try{i=parseInt(e,16)}catch(e){return-1}if(void 0===t)return 128==(192&i);try{return null!=t.match(/^\[[0-9]+\]$/)&&(!((n=parseInt(t.substr(1,t.length-1),10))>31)&&(128==(192&i)&&(31&i)==n))}catch(e){return!1}},Te.isASN1HEX=function(e){var t=Te;if(e.length%2==1)return!1;var i=t.getVblen(e,0),n=e.substr(0,2),r=t.getL(e,0);return e.length-n.length-r.length==2*i},Te.checkStrictDER=function(e,t,i,n,r){var o=Te;if(void 0===i){if("string"!=typeof e)throw new Error("not hex string");if(e=e.toLowerCase(),!u.lang.String.isHex(e))throw new Error("not hex string");i=e.length,r=(n=e.length/2)<128?1:Math.ceil(n.toString(16))+1}if(o.getL(e,t).length>2*r)throw new Error("L of TLV too long: idx="+t);var s=o.getVblen(e,t);if(s>n)throw new Error("value of L too long than hex: idx="+t);var a=o.getTLV(e,t),c=a.length-2-o.getL(e,t).length;if(c!==2*s)throw new Error("V string length and L's value not the same:"+c+"/"+2*s);if(0===t&&e.length!=a.length)throw new Error("total length and TLV length unmatch:"+e.length+"!="+a.length);var l=e.substr(t,2);if("02"===l){var h=o.getVidx(e,t);if("00"==e.substr(h,2)&&e.charCodeAt(h+2)<56)throw new Error("not least zeros for DER INTEGER")}if(32&parseInt(l,16)){for(var d=o.getVblen(e,t),p=0,A=o.getChildIdx(e,t),f=0;f<A.length;f++){p+=o.getTLV(e,A[f]).length,o.checkStrictDER(e,A[f],i,n,r)}if(2*d!=p)throw new Error("sum of children's TLV length and L unmatch: "+2*d+"!="+p)}},Te.oidname=function(e){var t=u.asn1;u.lang.String.isHex(e)&&(e=t.ASN1Util.oidHexToInt(e));var i=t.x509.OID.oid2name(e);return""===i&&(i=e),i},void 0!==u.asn1&&u.asn1||(u.asn1={}),void 0!==u.asn1.x509&&u.asn1.x509||(u.asn1.x509={}),u.asn1.x509.Certificate=function(e){u.asn1.x509.Certificate.superclass.constructor.call(this);var t=u.asn1,i=t.DERBitString,n=t.DERSequence,r=t.x509,o=r.TBSCertificate,s=r.AlgorithmIdentifier;this.params=void 0,this.setByParam=function(e){this.params=e},this.sign=function(){var e=this.params,t=e.sigalg;null!=e.sigalg.name&&(t=e.sigalg.name);var i=e.tbsobj.getEncodedHex(),n=new u.crypto.Signature({alg:t});n.init(e.cakey),n.updateHex(i),e.sighex=n.sign()},this.getPEM=function(){return ae(this.getEncodedHex(),"CERTIFICATE")},this.getEncodedHex=function(){var e=this.params;if(null!=e.tbsobj&&null!=e.tbsobj||(e.tbsobj=new o(e)),null==e.sighex&&null!=e.cakey&&this.sign(),null==e.sighex)throw new Error("sighex or cakey parameter not defined");var t=[];return t.push(e.tbsobj),t.push(new s({name:e.sigalg})),t.push(new i({hex:"00"+e.sighex})),new n({array:t}).getEncodedHex()},null!=e&&(this.params=e)},Ae(u.asn1.x509.Certificate,u.asn1.ASN1Object),u.asn1.x509.TBSCertificate=function(e){u.asn1.x509.TBSCertificate.superclass.constructor.call(this);var t=u.asn1,i=t.x509,n=t.DERTaggedObject,r=t.DERInteger,o=t.DERSequence,s=i.AlgorithmIdentifier,a=i.Time,c=i.X500Name,l=i.Extensions,h=i.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(e){this.params=e},this.getEncodedHex=function(){var e=[],t=this.params;if(null!=t.version||1!=t.version){var i=2;null!=t.version&&(i=t.version-1);var d=new n({obj:new r({int:i})});e.push(d)}return e.push(new r(t.serial)),e.push(new s({name:t.sigalg})),e.push(new c(t.issuer)),e.push(new o({array:[new a(t.notbefore),new a(t.notafter)]})),e.push(new c(t.subject)),e.push(new h(we.getKey(t.sbjpubkey))),void 0!==t.ext&&t.ext.length>0&&e.push(new n({tag:"a3",obj:new l(t.ext)})),new u.asn1.DERSequence({array:e}).getEncodedHex()},void 0!==e&&this.setByParam(e)},Ae(u.asn1.x509.TBSCertificate,u.asn1.ASN1Object),u.asn1.x509.Extensions=function(e){u.asn1.x509.Extensions.superclass.constructor.call(this);var t=u.asn1,i=t.DERSequence,n=t.x509;this.aParam=[],this.setByParam=function(e){this.aParam=e},this.getEncodedHex=function(){for(var e=[],t=0;t<this.aParam.length;t++){var r=this.aParam[t],o=r.extname,s=null;if(null!=r.extn)s=new n.PrivateExtension(r);else if("subjectKeyIdentifier"==o)s=new n.SubjectKeyIdentifier(r);else if("keyUsage"==o)s=new n.KeyUsage(r);else if("subjectAltName"==o)s=new n.SubjectAltName(r);else if("issuerAltName"==o)s=new n.IssuerAltName(r);else if("basicConstraints"==o)s=new n.BasicConstraints(r);else if("cRLDistributionPoints"==o)s=new n.CRLDistributionPoints(r);else if("certificatePolicies"==o)s=new n.CertificatePolicies(r);else if("authorityKeyIdentifier"==o)s=new n.AuthorityKeyIdentifier(r);else if("extKeyUsage"==o)s=new n.ExtKeyUsage(r);else if("authorityInfoAccess"==o)s=new n.AuthorityInfoAccess(r);else if("cRLNumber"==o)s=new n.CRLNumber(r);else if("cRLReason"==o)s=new n.CRLReason(r);else if("ocspNonce"==o)s=new n.OCSPNonce(r);else if("ocspNoCheck"==o)s=new n.OCSPNoCheck(r);else if("adobeTimeStamp"==o)s=new n.AdobeTimeStamp(r);else{if("subjectDirectoryAttributes"!=o)throw new Error("extension not supported:"+JSON.stringify(r));s=new n.SubjectDirectoryAttributes(r)}null!=s&&e.push(s)}return new i({array:e}).getEncodedHex()},null!=e&&this.setByParam(e)},Ae(u.asn1.x509.Extensions,u.asn1.ASN1Object),u.asn1.x509.Extension=function(e){u.asn1.x509.Extension.superclass.constructor.call(this);var t=u.asn1,i=t.DERObjectIdentifier,n=t.DEROctetString;t.DERBitString;var r=t.DERBoolean,o=t.DERSequence;this.getEncodedHex=function(){var e=new i({oid:this.oid}),t=new n({hex:this.getExtnValueHex()}),s=new Array;return s.push(e),this.critical&&s.push(new r),s.push(t),new o({array:s}).getEncodedHex()},this.critical=!1,void 0!==e&&void 0!==e.critical&&(this.critical=e.critical)},Ae(u.asn1.x509.Extension,u.asn1.ASN1Object),u.asn1.x509.KeyUsage=function(e){u.asn1.x509.KeyUsage.superclass.constructor.call(this,e);var t=ze.KEYUSAGE_NAME;if(this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.15",void 0!==e&&(void 0!==e.bin&&(this.asn1ExtnValue=new u.asn1.DERBitString(e)),void 0!==e.names&&void 0!==e.names.length)){for(var i=e.names,n="000000000",r=0;r<i.length;r++)for(var o=0;o<t.length;o++)i[r]===t[o]&&(n=n.substring(0,o)+"1"+n.substring(o+1,n.length));this.asn1ExtnValue=new u.asn1.DERBitString({bin:n})}},Ae(u.asn1.x509.KeyUsage,u.asn1.x509.Extension),u.asn1.x509.BasicConstraints=function(e){u.asn1.x509.BasicConstraints.superclass.constructor.call(this,e);var t=u.asn1,i=t.DERBoolean,n=t.DERInteger,r=t.DERSequence;this.getExtnValueHex=function(){var e=new Array;this.cA&&e.push(new i),this.pathLen>-1&&e.push(new n({int:this.pathLen}));var t=new r({array:e});return this.asn1ExtnValue=t,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==e&&(void 0!==e.cA&&(this.cA=e.cA),void 0!==e.pathLen&&(this.pathLen=e.pathLen))},Ae(u.asn1.x509.BasicConstraints,u.asn1.x509.Extension),u.asn1.x509.CRLDistributionPoints=function(e){u.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,e);var t=u.asn1,i=t.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(e){for(var n=[],r=0;r<e.length;r++)if(e[r]instanceof u.asn1.ASN1Object)n.push(e[r]);else{var o=new i.DistributionPoint(e[r]);n.push(o)}this.asn1ExtnValue=new t.DERSequence({array:n})},this.setByOneURI=function(e){var t=new i.DistributionPoint({fulluri:e});this.setByDPArray([t])},this.oid="2.5.29.31",void 0!==e&&(void 0!==e.array?this.setByDPArray(e.array):void 0!==e.uri&&this.setByOneURI(e.uri))},Ae(u.asn1.x509.CRLDistributionPoints,u.asn1.x509.Extension),u.asn1.x509.DistributionPoint=function(e){u.asn1.x509.DistributionPoint.superclass.constructor.call(this);var t=u.asn1,i=t.x509.DistributionPointName;this.getEncodedHex=function(){var e=new t.DERSequence;if(null!=this.asn1DP){var i=new t.DERTaggedObject({explicit:!0,tag:"a0",obj:this.asn1DP});e.appendASN1Object(i)}return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==e&&(void 0!==e.dpobj?this.asn1DP=e.dpobj:void 0!==e.dpname?this.asn1DP=new i(e.dpname):void 0!==e.fulluri&&(this.asn1DP=new i({full:[{uri:e.fulluri}]})))},Ae(u.asn1.x509.DistributionPoint,u.asn1.ASN1Object),u.asn1.x509.DistributionPointName=function(e){u.asn1.x509.DistributionPointName.superclass.constructor.call(this);var t=u.asn1,i=t.DERTaggedObject;if(this.getEncodedHex=function(){if("full"!=this.type)throw new Error("currently type shall be 'full': "+this.type);return this.asn1Obj=new i({explicit:!1,tag:this.tag,obj:this.asn1V}),this.hTLV=this.asn1Obj.getEncodedHex(),this.hTLV},void 0!==e)if(t.x509.GeneralNames.prototype.isPrototypeOf(e))this.type="full",this.tag="a0",this.asn1V=e;else{if(void 0===e.full)throw new Error("This class supports GeneralNames only as argument");this.type="full",this.tag="a0",this.asn1V=new t.x509.GeneralNames(e.full)}},Ae(u.asn1.x509.DistributionPointName,u.asn1.ASN1Object),u.asn1.x509.CertificatePolicies=function(e){u.asn1.x509.CertificatePolicies.superclass.constructor.call(this,e);var t=u.asn1,i=t.x509,n=t.DERSequence,r=i.PolicyInformation;this.params=null,this.getExtnValueHex=function(){for(var e=[],t=0;t<this.params.array.length;t++)e.push(new r(this.params.array[t]));var i=new n({array:e});return this.asn1ExtnValue=i,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.32",void 0!==e&&(this.params=e)},Ae(u.asn1.x509.CertificatePolicies,u.asn1.x509.Extension),u.asn1.x509.PolicyInformation=function(e){u.asn1.x509.PolicyInformation.superclass.constructor.call(this,e);var t=u.asn1,i=t.DERSequence,n=t.DERObjectIdentifier,r=t.x509.PolicyQualifierInfo;this.params=null,this.getEncodedHex=function(){if(void 0===this.params.policyoid&&void 0===this.params.array)throw new Error("parameter oid and array missing");var e=[new n(this.params.policyoid)];if(void 0!==this.params.array){for(var t=[],o=0;o<this.params.array.length;o++)t.push(new r(this.params.array[o]));t.length>0&&e.push(new i({array:t}))}return new i({array:e}).getEncodedHex()},void 0!==e&&(this.params=e)},Ae(u.asn1.x509.PolicyInformation,u.asn1.ASN1Object),u.asn1.x509.PolicyQualifierInfo=function(e){u.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var t=u.asn1,i=t.DERSequence,n=t.DERIA5String,r=t.DERObjectIdentifier,o=t.x509.UserNotice;this.params=null,this.getEncodedHex=function(){return void 0!==this.params.cps?new i({array:[new r({oid:"1.3.6.1.5.5.7.2.1"}),new n({str:this.params.cps})]}).getEncodedHex():null!=this.params.unotice?new i({array:[new r({oid:"1.3.6.1.5.5.7.2.2"}),new o(this.params.unotice)]}).getEncodedHex():void 0},void 0!==e&&(this.params=e)},Ae(u.asn1.x509.PolicyQualifierInfo,u.asn1.ASN1Object),u.asn1.x509.UserNotice=function(e){u.asn1.x509.UserNotice.superclass.constructor.call(this,e);var t=u.asn1.DERSequence;u.asn1.DERInteger;var i=u.asn1.x509.DisplayText,n=u.asn1.x509.NoticeReference;this.params=null,this.getEncodedHex=function(){var e=[];return void 0!==this.params.noticeref&&e.push(new n(this.params.noticeref)),void 0!==this.params.exptext&&e.push(new i(this.params.exptext)),new t({array:e}).getEncodedHex()},void 0!==e&&(this.params=e)},Ae(u.asn1.x509.UserNotice,u.asn1.ASN1Object),u.asn1.x509.NoticeReference=function(e){u.asn1.x509.NoticeReference.superclass.constructor.call(this,e);var t=u.asn1.DERSequence,i=u.asn1.DERInteger,n=u.asn1.x509.DisplayText;this.params=null,this.getEncodedHex=function(){var e=[];if(void 0!==this.params.org&&e.push(new n(this.params.org)),void 0!==this.params.noticenum){for(var r=[],o=this.params.noticenum,s=0;s<o.length;s++)r.push(new i(o[s]));e.push(new t({array:r}))}if(0==e.length)throw new Error("parameter is empty");return new t({array:e}).getEncodedHex()},void 0!==e&&(this.params=e)},Ae(u.asn1.x509.NoticeReference,u.asn1.ASN1Object),u.asn1.x509.DisplayText=function(e){u.asn1.x509.DisplayText.superclass.constructor.call(this,e),this.hT="0c",void 0!==e&&("ia5"===e.type?this.hT="16":"vis"===e.type?this.hT="1a":"bmp"===e.type&&(this.hT="1e"))},Ae(u.asn1.x509.DisplayText,u.asn1.DERAbstractString),u.asn1.x509.ExtKeyUsage=function(e){u.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,e);var t=u.asn1;this.setPurposeArray=function(e){this.asn1ExtnValue=new t.DERSequence;for(var i=0;i<e.length;i++){var n=new t.DERObjectIdentifier(e[i]);this.asn1ExtnValue.appendASN1Object(n)}},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.37",void 0!==e&&void 0!==e.array&&this.setPurposeArray(e.array)},Ae(u.asn1.x509.ExtKeyUsage,u.asn1.x509.Extension),u.asn1.x509.AuthorityKeyIdentifier=function(e){u.asn1.x509.AuthorityKeyIdentifier.superclass.constructor.call(this,e);var t=u,i=t.asn1,n=i.DERTaggedObject,r=i.x509.GeneralNames;t.crypto.Util.isKey,this.asn1KID=null,this.asn1CertIssuer=null,this.asn1CertSN=null,this.getExtnValueHex=function(){var e=new Array;this.asn1KID&&e.push(new n({explicit:!1,tag:"80",obj:this.asn1KID})),this.asn1CertIssuer&&e.push(new n({explicit:!1,tag:"a1",obj:new r([{dn:this.asn1CertIssuer}])})),this.asn1CertSN&&e.push(new n({explicit:!1,tag:"82",obj:this.asn1CertSN}));var t=new i.DERSequence({array:e});return this.asn1ExtnValue=t,this.asn1ExtnValue.getEncodedHex()},this.setKIDByParam=function(e){if(void 0!==e.str||void 0!==e.hex)this.asn1KID=new u.asn1.DEROctetString(e);else if("object"==typeof e&&u.crypto.Util.isKey(e)||"string"==typeof e&&-1!=e.indexOf("BEGIN ")){var t=e;"string"==typeof e&&(t=we.getKey(e));var i=we.getKeyID(t);this.asn1KID=new u.asn1.DEROctetString({hex:i})}},this.setCertIssuerByParam=function(e){void 0!==e.str||void 0!==e.ldapstr||void 0!==e.hex||void 0!==e.certsubject||void 0!==e.certissuer?this.asn1CertIssuer=new u.asn1.x509.X500Name(e):"string"==typeof e&&-1!=e.indexOf("BEGIN ")&&-1!=e.indexOf("CERTIFICATE")&&(this.asn1CertIssuer=new u.asn1.x509.X500Name({certissuer:e}))},this.setCertSNByParam=function(e){if(void 0!==e.str||void 0!==e.bigint||void 0!==e.hex)this.asn1CertSN=new u.asn1.DERInteger(e);else if("string"==typeof e&&-1!=e.indexOf("BEGIN ")&&e.indexOf("CERTIFICATE")){var t=new ze;t.readCertPEM(e);var i=t.getSerialNumberHex();this.asn1CertSN=new u.asn1.DERInteger({hex:i})}},this.oid="2.5.29.35",void 0!==e&&(void 0!==e.kid&&this.setKIDByParam(e.kid),void 0!==e.issuer&&this.setCertIssuerByParam(e.issuer),void 0!==e.sn&&this.setCertSNByParam(e.sn),void 0!==e.issuersn&&"string"==typeof e.issuersn&&-1!=e.issuersn.indexOf("BEGIN ")&&e.issuersn.indexOf("CERTIFICATE")&&(this.setCertSNByParam(e.issuersn),this.setCertIssuerByParam(e.issuersn)))},Ae(u.asn1.x509.AuthorityKeyIdentifier,u.asn1.x509.Extension),u.asn1.x509.SubjectKeyIdentifier=function(e){u.asn1.x509.SubjectKeyIdentifier.superclass.constructor.call(this,e);var t=u.asn1.DEROctetString;this.asn1KID=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=this.asn1KID,this.asn1ExtnValue.getEncodedHex()},this.setKIDByParam=function(e){if(void 0!==e.str||void 0!==e.hex)this.asn1KID=new t(e);else if("object"==typeof e&&u.crypto.Util.isKey(e)||"string"==typeof e&&-1!=e.indexOf("BEGIN")){var i=e;"string"==typeof e&&(i=we.getKey(e));var n=we.getKeyID(i);this.asn1KID=new u.asn1.DEROctetString({hex:n})}},this.oid="2.5.29.14",void 0!==e&&void 0!==e.kid&&this.setKIDByParam(e.kid)},Ae(u.asn1.x509.SubjectKeyIdentifier,u.asn1.x509.Extension),u.asn1.x509.AuthorityInfoAccess=function(e){u.asn1.x509.AuthorityInfoAccess.superclass.constructor.call(this,e),this.setAccessDescriptionArray=function(e){for(var t=new Array,i=u.asn1,n=i.DERSequence,r=i.DERObjectIdentifier,o=i.x509.GeneralName,s=0;s<e.length;s++){var a,c=e[s];if(void 0!==c.ocsp)a=new n({array:[new r({oid:"1.3.6.1.5.5.7.48.1"}),new o({uri:c.ocsp})]});else{if(void 0===c.caissuer)throw new Error("unknown AccessMethod parameter: "+JSON.stringify(c));a=new n({array:[new r({oid:"1.3.6.1.5.5.7.48.2"}),new o({uri:c.caissuer})]})}t.push(a)}this.asn1ExtnValue=new n({array:t})},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.1.1",void 0!==e&&void 0!==e.array&&this.setAccessDescriptionArray(e.array)},Ae(u.asn1.x509.AuthorityInfoAccess,u.asn1.x509.Extension),u.asn1.x509.SubjectAltName=function(e){u.asn1.x509.SubjectAltName.superclass.constructor.call(this,e),this.setNameArray=function(e){this.asn1ExtnValue=new u.asn1.x509.GeneralNames(e)},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.17",void 0!==e&&void 0!==e.array&&this.setNameArray(e.array)},Ae(u.asn1.x509.SubjectAltName,u.asn1.x509.Extension),u.asn1.x509.IssuerAltName=function(e){u.asn1.x509.IssuerAltName.superclass.constructor.call(this,e),this.setNameArray=function(e){this.asn1ExtnValue=new u.asn1.x509.GeneralNames(e)},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.18",void 0!==e&&void 0!==e.array&&this.setNameArray(e.array)},Ae(u.asn1.x509.IssuerAltName,u.asn1.x509.Extension),u.asn1.x509.SubjectDirectoryAttributes=function(e){u.asn1.x509.SubjectDirectoryAttributes.superclass.constructor.call(this,e);var t=u.asn1,i=t.DERSequence,n=t.ASN1Util.newObject,r=t.x509.OID.name2oid;this.params=null,this.getExtnValueHex=function(){for(var e=[],t=0;t<this.params.array.length;t++){var o=this.params.array[t],s={seq:[{oid:"1.2.3.4"},{set:[{utf8str:"DE"}]}]};if("dateOfBirth"==o.attr)s.seq[0].oid=r(o.attr),s.seq[1].set[0]={gentime:o.str};else if("placeOfBirth"==o.attr)s.seq[0].oid=r(o.attr),s.seq[1].set[0]={utf8str:o.str};else if("gender"==o.attr)s.seq[0].oid=r(o.attr),s.seq[1].set[0]={prnstr:o.str};else if("countryOfCitizenship"==o.attr)s.seq[0].oid=r(o.attr),s.seq[1].set[0]={prnstr:o.str};else{if("countryOfResidence"!=o.attr)throw new Error("unsupported attribute: "+o.attr);s.seq[0].oid=r(o.attr),s.seq[1].set[0]={prnstr:o.str}}e.push(new n(s))}var a=new i({array:e});return this.asn1ExtnValue=a,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.9",void 0!==e&&(this.params=e)},Ae(u.asn1.x509.SubjectDirectoryAttributes,u.asn1.x509.Extension),u.asn1.x509.PrivateExtension=function(e){u.asn1.x509.PrivateExtension.superclass.constructor.call(this,e);var t=u,i=t.lang.String.isHex,n=t.asn1,r=n.x509.OID.name2oid,o=n.ASN1Util.newObject;this.params=null,this.setByParam=function(e){this.oid=r(e.extname),this.params=e},this.getExtnValueHex=function(){if(null==this.params.extname||null==this.params.extn)throw new Error("extname or extnhex not specified");var e=this.params.extn;if("string"==typeof e&&i(e))return e;if("object"==typeof e)try{return o(e).getEncodedHex()}catch(e){}throw new Error("unsupported extn value")},null!=e&&this.setByParam(e)},Ae(u.asn1.x509.PrivateExtension,u.asn1.x509.Extension),u.asn1.x509.CRL=function(e){u.asn1.x509.CRL.superclass.constructor.call(this);var t=u.asn1,i=t.DERSequence,n=t.DERBitString,r=t.x509,o=r.AlgorithmIdentifier,s=r.TBSCertList;this.params=void 0,this.setByParam=function(e){this.params=e},this.sign=function(){var e=new s(this.params).getEncodedHex(),t=new u.crypto.Signature({alg:this.params.sigalg});t.init(this.params.cakey),t.updateHex(e);var i=t.sign();this.params.sighex=i},this.getPEM=function(){return ae(this.getEncodedHex(),"X509 CRL")},this.getEncodedHex=function(){var e=this.params;if(null==e.tbsobj&&(e.tbsobj=new s(e)),null==e.sighex&&null!=e.cakey&&this.sign(),null==e.sighex)throw new Error("sighex or cakey parameter not defined");var t=[];return t.push(e.tbsobj),t.push(new o({name:e.sigalg})),t.push(new n({hex:"00"+e.sighex})),new i({array:t}).getEncodedHex()},null!=e&&(this.params=e)},Ae(u.asn1.x509.CRL,u.asn1.ASN1Object),u.asn1.x509.TBSCertList=function(e){u.asn1.x509.TBSCertList.superclass.constructor.call(this);var t=u.asn1,i=t.DERInteger,n=t.DERSequence,r=t.DERTaggedObject;t.DERObjectIdentifier;var o=t.x509,s=o.AlgorithmIdentifier,a=o.Time,c=o.Extensions,l=o.X500Name;this.params=null,this.setByParam=function(e){this.params=e},this.getRevCertSequence=function(){for(var e=[],t=this.params.revcert,r=0;r<t.length;r++){var o=[new i(t[r].sn),new a(t[r].date)];null!=t[r].ext&&o.push(new c(t[r].ext)),e.push(new n({array:o}))}return new n({array:e})},this.getEncodedHex=function(){var e=[],t=this.params;if(null!=t.version){var o=t.version-1,u=new i({int:o});e.push(u)}if(e.push(new s({name:t.sigalg})),e.push(new l(t.issuer)),e.push(new a(t.thisupdate)),null!=t.nextupdate&&e.push(new a(t.nextupdate)),null!=t.revcert&&e.push(this.getRevCertSequence()),null!=t.ext){var h=new c(t.ext);e.push(new r({tag:"a0",explicit:!0,obj:h}))}return new n({array:e}).getEncodedHex()},void 0!==e&&this.setByParam(e)},Ae(u.asn1.x509.TBSCertList,u.asn1.ASN1Object),u.asn1.x509.CRLEntry=function(e){u.asn1.x509.CRLEntry.superclass.constructor.call(this);var t=u.asn1;this.setCertSerial=function(e){this.sn=new t.DERInteger(e)},this.setRevocationDate=function(e){this.time=new t.x509.Time(e)},this.getEncodedHex=function(){var e=new t.DERSequence({array:[this.sn,this.time]});return this.TLV=e.getEncodedHex(),this.TLV},void 0!==e&&(void 0!==e.time&&this.setRevocationDate(e.time),void 0!==e.sn&&this.setCertSerial(e.sn))},Ae(u.asn1.x509.CRLEntry,u.asn1.ASN1Object),u.asn1.x509.CRLNumber=function(e){u.asn1.x509.CRLNumber.superclass.constructor.call(this,e),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new u.asn1.DERInteger(this.params.num),this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.20",null!=e&&(this.params=e)},Ae(u.asn1.x509.CRLNumber,u.asn1.x509.Extension),u.asn1.x509.CRLReason=function(e){u.asn1.x509.CRLReason.superclass.constructor.call(this,e),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new u.asn1.DEREnumerated(this.params.code),this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.21",null!=e&&(this.params=e)},Ae(u.asn1.x509.CRLReason,u.asn1.x509.Extension),u.asn1.x509.OCSPNonce=function(e){u.asn1.x509.OCSPNonce.superclass.constructor.call(this,e),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new u.asn1.DEROctetString(this.params),this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.48.1.2",null!=e&&(this.params=e)},Ae(u.asn1.x509.OCSPNonce,u.asn1.x509.Extension),u.asn1.x509.OCSPNoCheck=function(e){u.asn1.x509.OCSPNoCheck.superclass.constructor.call(this,e),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new u.asn1.DERNull,this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.48.1.5",null!=e&&(this.params=e)},Ae(u.asn1.x509.OCSPNoCheck,u.asn1.x509.Extension),u.asn1.x509.AdobeTimeStamp=function(e){u.asn1.x509.AdobeTimeStamp.superclass.constructor.call(this,e);var t=u.asn1,i=t.DERInteger,n=t.DERBoolean,r=t.DERSequence,o=t.x509.GeneralName;this.params=null,this.getExtnValueHex=function(){var e=this.params,t=[new i(1)];return t.push(new o({uri:e.uri})),null!=e.reqauth&&t.push(new n(e.reqauth)),this.asn1ExtnValue=new r({array:t}),this.asn1ExtnValue.getEncodedHex()},this.oid="1.2.840.113583.1.1.9.1",void 0!==e&&this.setByParam(e)},Ae(u.asn1.x509.AdobeTimeStamp,u.asn1.x509.Extension),u.asn1.x509.X500Name=function(e){u.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var t=u.asn1,i=t.x509,n=i.RDN;this.setByString=function(e,t){void 0!==t&&(this.sRule=t);var i=e.split("/");i.shift();for(var r=[],o=0;o<i.length;o++)if(i[o].match(/^[^=]+=.+$/))r.push(i[o]);else{var s=r.length-1;r[s]=r[s]+"/"+i[o]}for(o=0;o<r.length;o++)this.asn1Array.push(new n({str:r[o],rule:this.sRule}))},this.setByLdapString=function(e,t){void 0!==t&&(this.sRule=t);var n=i.X500Name.ldapToCompat(e);this.setByString(n,t)},this.setByObject=function(e,t){for(var i in void 0!==t&&(this.sRule=t),e)if(e.hasOwnProperty(i)){var r=new n({str:i+"="+e[i],rule:this.sRule});this.asn1Array?this.asn1Array.push(r):this.asn1Array=[r]}},this.setByParam=function(e){var t;(void 0!==e.rule&&(this.sRule=e.rule),void 0!==e.array)?this.paramArray=e.array:void 0!==e.str?this.setByString(e.str):void 0!==e.ldapstr?this.setByLdapString(e.ldapstr):void 0!==e.hex?this.hTLV=e.hex:void 0!==e.certissuer?((t=new ze).readCertPEM(e.certissuer),this.hTLV=t.getIssuerHex()):void 0!==e.certsubject?((t=new ze).readCertPEM(e.certsubject),this.hTLV=t.getSubjectHex()):"object"==typeof e&&void 0===e.certsubject&&void 0===e.certissuer&&this.setByObject(e)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(0==this.asn1Array.length&&this.paramArray.length>0)for(var e=0;e<this.paramArray.length;e++){var i={array:this.paramArray[e]};"utf8"!=this.sRule&&(i.rule=this.sRule);var r=new n(i);this.asn1Array.push(r)}var o=new t.DERSequence({array:this.asn1Array});return this.hTLV=o.getEncodedHex(),this.hTLV},void 0!==e&&this.setByParam(e)},Ae(u.asn1.x509.X500Name,u.asn1.ASN1Object),u.asn1.x509.X500Name.compatToLDAP=function(e){if("/"!==e.substr(0,1))throw"malformed input";var t=(e=e.substr(1)).split("/");return t.reverse(),(t=t.map((function(e){return e.replace(/,/,"\\,")}))).join(",")},u.asn1.x509.X500Name.onelineToLDAP=function(e){return u.asn1.x509.X500Name.compatToLDAP(e)},u.asn1.x509.X500Name.ldapToCompat=function(e){for(var t=e.split(","),i=!1,n=[],r=0;t.length>0;r++){var o=t.shift();if(!0===i){var s=(n.pop()+","+o).replace(/\\,/g,",");n.push(s),i=!1}else n.push(o);"\\"===o.substr(-1,1)&&(i=!0)}return(n=n.map((function(e){return e.replace("/","\\/")}))).reverse(),"/"+n.join("/")},u.asn1.x509.X500Name.ldapToOneline=function(e){return u.asn1.x509.X500Name.ldapToCompat(e)},u.asn1.x509.RDN=function(e){u.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var t=u.asn1.x509.AttributeTypeAndValue;this.setByParam=function(e){void 0!==e.rule&&(this.sRule=e.rule),void 0!==e.str&&this.addByMultiValuedString(e.str),void 0!==e.array&&(this.paramArray=e.array)},this.addByString=function(e){this.asn1Array.push(new u.asn1.x509.AttributeTypeAndValue({str:e,rule:this.sRule}))},this.addByMultiValuedString=function(e){for(var t=u.asn1.x509.RDN.parseString(e),i=0;i<t.length;i++)this.addByString(t[i])},this.getEncodedHex=function(){if(0==this.asn1Array.length&&this.paramArray.length>0)for(var e=0;e<this.paramArray.length;e++){var i=this.paramArray[e];void 0!==i.rule&&"utf8"!=this.sRule&&(i.rule=this.sRule);var n=new t(i);this.asn1Array.push(n)}var r=new u.asn1.DERSet({array:this.asn1Array});return this.TLV=r.getEncodedHex(),this.TLV},void 0!==e&&this.setByParam(e)},Ae(u.asn1.x509.RDN,u.asn1.ASN1Object),u.asn1.x509.RDN.parseString=function(e){for(var t=e.split(/\+/),i=!1,n=[],r=0;t.length>0;r++){var o=t.shift();if(!0===i){var s=(n.pop()+"+"+o).replace(/\\\+/g,"+");n.push(s),i=!1}else n.push(o);"\\"===o.substr(-1,1)&&(i=!0)}var a=!1,u=[];for(r=0;n.length>0;r++){o=n.shift();if(!0===a){var c=u.pop();if(o.match(/"$/)){s=(c+"+"+o).replace(/^([^=]+)="(.*)"$/,"$1=$2");u.push(s),a=!1}else u.push(c+"+"+o)}else u.push(o);o.match(/^[^=]+="/)&&(a=!0)}return u},u.asn1.x509.AttributeTypeAndValue=function(e){u.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var t=u,i=t.asn1,n=i.DERSequence,r=i.DERUTF8String,o=i.DERPrintableString,s=i.DERTeletexString,a=i.DERIA5String,c=i.DERVisibleString,l=i.DERBMPString,h=t.lang.String.isMail,d=t.lang.String.isPrintable;this.setByParam=function(e){if(void 0!==e.rule&&(this.sRule=e.rule),void 0!==e.ds&&(this.dsType=e.ds),void 0===e.value&&void 0!==e.str){var t=e.str.match(/^([^=]+)=(.+)$/);if(!t)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.sType=t[1],this.sValue=t[2]}else this.sType=e.type,this.sValue=e.value},this.setByString=function(e,t){void 0!==t&&(this.sRule=t);var i=e.match(/^([^=]+)=(.+)$/);if(!i)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.setByAttrTypeAndValueStr(i[1],i[2])},this._getDsType=function(){var e=this.sType,t=this.sValue,i=this.sRule;return"prn"===i?"CN"==e&&h(t)?"ia5":d(t)?"prn":"utf8":"utf8"===i?"CN"==e&&h(t)?"ia5":"C"==e?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(e,t,i){void 0!==i&&(this.sRule=i),this.sType=e,this.sValue=t},this.getValueObj=function(e,t){if("utf8"==e)return new r({str:t});if("prn"==e)return new o({str:t});if("tel"==e)return new s({str:t});if("ia5"==e)return new a({str:t});if("vis"==e)return new c({str:t});if("bmp"==e)return new l({str:t});throw new Error("unsupported directory string type: type="+e+" value="+t)},this.getEncodedHex=function(){null==this.dsType&&(this.dsType=this._getDsType());var e=u.asn1.x509.OID.atype2obj(this.sType),t=this.getValueObj(this.dsType,this.sValue),i=new n({array:[e,t]});return this.TLV=i.getEncodedHex(),this.TLV},void 0!==e&&this.setByParam(e)},Ae(u.asn1.x509.AttributeTypeAndValue,u.asn1.ASN1Object),u.asn1.x509.SubjectPublicKeyInfo=function(e){u.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var t=u,i=t.asn1,n=i.DERInteger,r=i.DERBitString,o=i.DERObjectIdentifier,s=i.DERSequence,a=i.ASN1Util.newObject,c=i.x509.AlgorithmIdentifier,l=t.crypto;l.ECDSA,l.DSA,this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new s({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.getEncodedHex=function(){var e=this.getASN1Object();return this.hTLV=e.getEncodedHex(),this.hTLV},this.setPubKey=function(e){try{if(e instanceof K){var t=a({seq:[{int:{bigint:e.n}},{int:{int:e.e}}]}).getEncodedHex();this.asn1AlgId=new c({name:"rsaEncryption"}),this.asn1SubjPKey=new r({hex:"00"+t})}}catch(e){}try{if(e instanceof u.crypto.ECDSA){var i=new o({name:e.curveName});this.asn1AlgId=new c({name:"ecPublicKey",asn1params:i}),this.asn1SubjPKey=new r({hex:"00"+e.pubKeyHex})}}catch(e){}try{if(e instanceof u.crypto.DSA){i=new a({seq:[{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}}]});this.asn1AlgId=new c({name:"dsa",asn1params:i});var s=new n({bigint:e.y});this.asn1SubjPKey=new r({hex:"00"+s.getEncodedHex()})}}catch(e){}},void 0!==e&&this.setPubKey(e)},Ae(u.asn1.x509.SubjectPublicKeyInfo,u.asn1.ASN1Object),u.asn1.x509.Time=function(e){u.asn1.x509.Time.superclass.constructor.call(this);var t=u.asn1,i=t.DERUTCTime,n=t.DERGeneralizedTime;this.setTimeParams=function(e){this.timeParams=e},this.getEncodedHex=function(){var e=null;return e=null!=this.timeParams?"utc"==this.type?new i(this.timeParams):new n(this.timeParams):"utc"==this.type?new i:new n,this.TLV=e.getEncodedHex(),this.TLV},this.type="utc",void 0!==e&&(void 0!==e.type?this.type=e.type:void 0!==e.str&&(e.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),e.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=e)},Ae(u.asn1.x509.Time,u.asn1.ASN1Object),u.asn1.x509.AlgorithmIdentifier=function(e){u.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var t=u.asn1,i=t.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;if(this.getEncodedHex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw new Error("algorithm not specified");if(null!==this.nameAlg){var e=null;for(var n in i)n===this.nameAlg&&(e=i[n]);if(null!==e)return this.hTLV=e,this.hTLV}null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=t.x509.OID.name2obj(this.nameAlg));var r=[this.asn1Alg];null!==this.asn1Params&&r.push(this.asn1Params);var o=new t.DERSequence({array:r});return this.hTLV=o.getEncodedHex(),this.hTLV},void 0!==e&&(void 0!==e.name&&(this.nameAlg=e.name),void 0!==e.asn1params&&(this.asn1Params=e.asn1params),void 0!==e.paramempty&&(this.paramEmpty=e.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){void 0!==this.nameAlg.name&&(this.nameAlg=this.nameAlg.name);var n=this.nameAlg.toLowerCase();"withdsa"!==n.substr(-7,7)&&"withecdsa"!==n.substr(-9,9)&&(this.asn1Params=new t.DERNull)}},Ae(u.asn1.x509.AlgorithmIdentifier,u.asn1.ASN1Object),u.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"},u.asn1.x509.GeneralName=function(e){u.asn1.x509.GeneralName.superclass.constructor.call(this);var t={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},i=u.asn1;i.DERSequence;var n=i.DEROctetString,r=i.DERIA5String,o=i.DERTaggedObject,s=i.ASN1Object,a=i.x509.X500Name,c=ue;this.explicit=!1,this.setByParam=function(e){var i=null;if(void 0!==e){if(void 0!==e.rfc822&&(this.type="rfc822",i=new r({str:e[this.type]})),void 0!==e.dns&&(this.type="dns",i=new r({str:e[this.type]})),void 0!==e.uri&&(this.type="uri",i=new r({str:e[this.type]})),void 0!==e.dn&&(this.type="dn",this.explicit=!0,i="string"==typeof e.dn?new a({str:e.dn}):e.dn instanceof u.asn1.x509.X500Name?e.dn:new a(e.dn)),void 0!==e.ldapdn&&(this.type="dn",this.explicit=!0,i=new a({ldapstr:e.ldapdn})),void 0!==e.certissuer){this.type="dn",this.explicit=!0;var l=null;if((d=e.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=d.indexOf("-----BEGIN ")&&(l=c(d)),null==l)throw"certissuer param not cert";(p=new ze).hex=l;var h=p.getIssuerHex();(i=new s).hTLV=h}if(void 0!==e.certsubj){this.type="dn",this.explicit=!0;var d,p;l=null;if((d=e.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=d.indexOf("-----BEGIN ")&&(l=c(d)),null==l)throw"certsubj param not cert";(p=new ze).hex=l;h=p.getSubjectHex();(i=new s).hTLV=h}if(void 0!==e.ip){this.type="ip",this.explicit=!1;var A,f=e.ip,M="malformed IP address";if(f.match(/^[0-9.]+[.][0-9.]+$/)){if(8!==(A=function(e){e=(e=(e=e.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return e.split(/,/).map((function(e,t,i){var n=parseInt(e);if(n<0||255<n)throw"integer not in range 0-255";return("00"+n.toString(16)).slice(-2)})).join("")}catch(e){throw"malformed integer array string: "+e}}("["+f.split(".").join(",")+"]")).length)throw M}else if(f.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))A=function(e){var t="malformed IPv6 address";if(!e.match(/^[0-9A-Fa-f:]+$/))throw t;var i=(e=e.toLowerCase()).split(":").length-1;if(i<2)throw t;var n=":".repeat(7-i+2),r=(e=e.replace("::",n)).split(":");if(8!=r.length)throw t;for(var o=0;o<8;o++)r[o]=("0000"+r[o]).slice(-4);return r.join("")}(f);else{if(!f.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw M;A=f}i=new n({hex:A})}if(null==this.type)throw"unsupported type in params="+e;this.asn1Obj=new o({explicit:this.explicit,tag:t[this.type],obj:i})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==e&&this.setByParam(e)},Ae(u.asn1.x509.GeneralName,u.asn1.ASN1Object),u.asn1.x509.GeneralNames=function(e){u.asn1.x509.GeneralNames.superclass.constructor.call(this);var t=u.asn1;this.setByParamArray=function(e){for(var i=0;i<e.length;i++){var n=new t.x509.GeneralName(e[i]);this.asn1Array.push(n)}},this.getEncodedHex=function(){return new t.DERSequence({array:this.asn1Array}).getEncodedHex()},this.asn1Array=new Array,void 0!==e&&this.setByParamArray(e)},Ae(u.asn1.x509.GeneralNames,u.asn1.ASN1Object),u.asn1.x509.OID=new function(e){this.atype2oidList={CN:"2.5.4.3",L:"2.5.4.7",ST:"2.5.4.8",O:"2.5.4.10",OU:"2.5.4.11",C:"2.5.4.6",STREET:"2.5.4.9",DC:"0.9.2342.19200300.100.1.25",UID:"0.9.2342.19200300.100.1.1",SN:"2.5.4.4",T:"2.5.4.12",DN:"2.5.4.49",E:"1.2.840.113549.1.9.1",description:"2.5.4.13",businessCategory:"2.5.4.15",postalCode:"2.5.4.17",serialNumber:"2.5.4.5",uniqueIdentifier:"2.5.4.45",organizationIdentifier:"2.5.4.97",jurisdictionOfIncorporationL:"1.3.6.1.4.1.311.60.2.1.1",jurisdictionOfIncorporationSP:"1.3.6.1.4.1.311.60.2.1.2",jurisdictionOfIncorporationC:"1.3.6.1.4.1.311.60.2.1.3"},this.name2oidList={sha1:"1.3.14.3.2.26",sha256:"2.16.840.1.101.3.4.2.1",sha384:"2.16.840.1.101.3.4.2.2",sha512:"2.16.840.1.101.3.4.2.3",sha224:"2.16.840.1.101.3.4.2.4",md5:"1.2.840.113549.2.5",md2:"1.3.14.7.2.2.1",ripemd160:"1.3.36.3.2.1",MD2withRSA:"1.2.840.113549.1.1.2",MD4withRSA:"1.2.840.113549.1.1.3",MD5withRSA:"1.2.840.113549.1.1.4",SHA1withRSA:"1.2.840.113549.1.1.5","pkcs1-MGF":"1.2.840.113549.1.1.8",rsaPSS:"1.2.840.113549.1.1.10",SHA224withRSA:"1.2.840.113549.1.1.14",SHA256withRSA:"1.2.840.113549.1.1.11",SHA384withRSA:"1.2.840.113549.1.1.12",SHA512withRSA:"1.2.840.113549.1.1.13",SHA1withECDSA:"1.2.840.10045.4.1",SHA224withECDSA:"1.2.840.10045.4.3.1",SHA256withECDSA:"1.2.840.10045.4.3.2",SHA384withECDSA:"1.2.840.10045.4.3.3",SHA512withECDSA:"1.2.840.10045.4.3.4",dsa:"1.2.840.10040.4.1",SHA1withDSA:"1.2.840.10040.4.3",SHA224withDSA:"2.16.840.1.101.3.4.3.1",SHA256withDSA:"2.16.840.1.101.3.4.3.2",rsaEncryption:"1.2.840.113549.1.1.1",commonName:"2.5.4.3",countryName:"2.5.4.6",localityName:"2.5.4.7",stateOrProvinceName:"2.5.4.8",streetAddress:"2.5.4.9",organizationName:"2.5.4.10",organizationalUnitName:"2.5.4.11",domainComponent:"0.9.2342.19200300.100.1.25",userId:"0.9.2342.19200300.100.1.1",surname:"2.5.4.4",givenName:"2.5.4.42",title:"2.5.4.12",distinguishedName:"2.5.4.49",emailAddress:"1.2.840.113549.1.9.1",description:"2.5.4.13",businessCategory:"2.5.4.15",postalCode:"2.5.4.17",uniqueIdentifier:"2.5.4.45",organizationIdentifier:"2.5.4.97",jurisdictionOfIncorporationL:"1.3.6.1.4.1.311.60.2.1.1",jurisdictionOfIncorporationSP:"1.3.6.1.4.1.311.60.2.1.2",jurisdictionOfIncorporationC:"1.3.6.1.4.1.311.60.2.1.3",subjectDirectoryAttributes:"2.5.29.9",subjectKeyIdentifier:"2.5.29.14",keyUsage:"2.5.29.15",subjectAltName:"2.5.29.17",issuerAltName:"2.5.29.18",basicConstraints:"2.5.29.19",cRLNumber:"2.5.29.20",cRLReason:"2.5.29.21",nameConstraints:"2.5.29.30",cRLDistributionPoints:"2.5.29.31",certificatePolicies:"2.5.29.32",anyPolicy:"2.5.29.32.0",authorityKeyIdentifier:"2.5.29.35",policyConstraints:"2.5.29.36",extKeyUsage:"2.5.29.37",authorityInfoAccess:"1.3.6.1.5.5.7.1.1",ocsp:"1.3.6.1.5.5.7.48.1",ocspBasic:"1.3.6.1.5.5.7.48.1.1",ocspNonce:"1.3.6.1.5.5.7.48.1.2",ocspNoCheck:"1.3.6.1.5.5.7.48.1.5",caIssuers:"1.3.6.1.5.5.7.48.2",anyExtendedKeyUsage:"2.5.29.37.0",serverAuth:"1.3.6.1.5.5.7.3.1",clientAuth:"1.3.6.1.5.5.7.3.2",codeSigning:"1.3.6.1.5.5.7.3.3",emailProtection:"1.3.6.1.5.5.7.3.4",timeStamping:"1.3.6.1.5.5.7.3.8",ocspSigning:"1.3.6.1.5.5.7.3.9",dateOfBirth:"1.3.6.1.5.5.7.9.1",placeOfBirth:"1.3.6.1.5.5.7.9.2",gender:"1.3.6.1.5.5.7.9.3",countryOfCitizenship:"1.3.6.1.5.5.7.9.4",countryOfResidence:"1.3.6.1.5.5.7.9.5",ecPublicKey:"1.2.840.10045.2.1","P-256":"1.2.840.10045.3.1.7",secp256r1:"1.2.840.10045.3.1.7",secp256k1:"1.3.132.0.10",secp384r1:"1.3.132.0.34",pkcs5PBES2:"1.2.840.113549.1.5.13",pkcs5PBKDF2:"1.2.840.113549.1.5.12","des-EDE3-CBC":"1.2.840.113549.3.7",data:"1.2.840.113549.1.7.1","signed-data":"1.2.840.113549.1.7.2","enveloped-data":"1.2.840.113549.1.7.3","digested-data":"1.2.840.113549.1.7.5","encrypted-data":"1.2.840.113549.1.7.6","authenticated-data":"1.2.840.113549.1.9.16.1.2",tstinfo:"1.2.840.113549.1.9.16.1.4",signingCertificate:"1.2.840.113549.1.9.16.2.12",timeStampToken:"1.2.840.113549.1.9.16.2.14",signaturePolicyIdentifier:"1.2.840.113549.1.9.16.2.15",etsArchiveTimeStamp:"1.2.840.113549.1.9.16.2.27",signingCertificateV2:"1.2.840.113549.1.9.16.2.47",etsArchiveTimeStampV2:"1.2.840.113549.1.9.16.2.48",extensionRequest:"1.2.840.113549.1.9.14",contentType:"1.2.840.113549.1.9.3",messageDigest:"1.2.840.113549.1.9.4",signingTime:"1.2.840.113549.1.9.5",counterSignature:"1.2.840.113549.1.9.6",archiveTimeStampV3:"0.4.0.1733.2.4",pdfRevocationInfoArchival:"1.2.840.113583.1.1.8",adobeTimeStamp:"1.2.840.113583.1.1.9.1"},this.objCache={},this.name2obj=function(e){if(void 0!==this.objCache[e])return this.objCache[e];if(void 0===this.name2oidList[e])throw"Name of ObjectIdentifier not defined: "+e;var t=this.name2oidList[e],i=new u.asn1.DERObjectIdentifier({oid:t});return this.objCache[e]=i,i},this.atype2obj=function(e){if(void 0!==this.objCache[e])return this.objCache[e];var t;if(e.match(/^\d+\.\d+\.[0-9.]+$/))t=e;else if(void 0!==this.atype2oidList[e])t=this.atype2oidList[e];else{if(void 0===this.name2oidList[e])throw"AttributeType name undefined: "+e;t=this.name2oidList[e]}var i=new u.asn1.DERObjectIdentifier({oid:t});return this.objCache[e]=i,i}},u.asn1.x509.OID.oid2name=function(e){var t=u.asn1.x509.OID.name2oidList;for(var i in t)if(t[i]==e)return i;return""},u.asn1.x509.OID.oid2atype=function(e){var t=u.asn1.x509.OID.atype2oidList;for(var i in t)if(t[i]==e)return i;return e},u.asn1.x509.OID.name2oid=function(e){if(e.match(/^[0-9.]+$/))return e;var t=u.asn1.x509.OID.name2oidList;return void 0===t[e]?"":t[e]},u.asn1.x509.X509Util={},u.asn1.x509.X509Util.newCertPEM=function(e){var t=u.asn1.x509;return t.TBSCertificate,new(0,t.Certificate)(e).getPEM()},K.getPosArrayOfChildrenFromHex=function(e){return Te.getChildIdx(e,0)},K.getHexValueArrayOfChildrenFromHex=function(e){var t,i=Te.getV,n=i(e,(t=K.getPosArrayOfChildrenFromHex(e))[0]),r=i(e,t[1]),o=i(e,t[2]),s=i(e,t[3]),a=i(e,t[4]),u=i(e,t[5]),c=i(e,t[6]),l=i(e,t[7]),h=i(e,t[8]);return(t=new Array).push(n,r,o,s,a,u,c,l,h),t},K.prototype.readPrivateKeyFromPEMString=function(e){var t=ue(e),i=K.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8])},K.prototype.readPKCS5PrvKeyHex=function(e){var t=K.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},K.prototype.readPKCS8PrvKeyHex=function(e){var t,i,n,r,o,s,a,u,c=Te,l=c.getVbyListEx;if(!1===c.isASN1HEX(e))throw new Error("not ASN.1 hex string");try{t=l(e,0,[2,0,1],"02"),i=l(e,0,[2,0,2],"02"),n=l(e,0,[2,0,3],"02"),r=l(e,0,[2,0,4],"02"),o=l(e,0,[2,0,5],"02"),s=l(e,0,[2,0,6],"02"),a=l(e,0,[2,0,7],"02"),u=l(e,0,[2,0,8],"02")}catch(e){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(t,i,n,r,o,s,a,u)},K.prototype.readPKCS5PubKeyHex=function(e){var t=Te,i=t.getV;if(!1===t.isASN1HEX(e))throw new Error("keyHex is not ASN.1 hex string");var n=t.getChildIdx(e,0);if(2!==n.length||"02"!==e.substr(n[0],2)||"02"!==e.substr(n[1],2))throw new Error("wrong hex for PKCS#5 public key");var r=i(e,n[0]),o=i(e,n[1]);this.setPublic(r,o)},K.prototype.readPKCS8PubKeyHex=function(e){var t=Te;if(!1===t.isASN1HEX(e))throw new Error("not ASN.1 hex string");if("06092a864886f70d010101"!==t.getTLVbyListEx(e,0,[0,0]))throw new Error("not PKCS8 RSA public key");var i=t.getTLVbyListEx(e,0,[1,0]);this.readPKCS5PubKeyHex(i)},K.prototype.readCertPubKeyHex=function(e,t){var i,n;(i=new ze).readCertHex(e),n=i.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)},K.prototype.sign=function(e,t){var i,n=(i=e,u.crypto.Util.hashString(i,t));return this.signWithMessageHash(n,t)},K.prototype.signWithMessageHash=function(e,t){var i=W(u.crypto.Util.getPaddedDigestInfoHex(e,t,this.n.bitLength()),16);return xe(this.doPrivate(i).toString(16),this.n.bitLength())},K.prototype.signPSS=function(e,t,i){var n,r=(n=oe(e),u.crypto.Util.hashHex(n,t));return void 0===i&&(i=-1),this.signWithMessageHashPSS(r,t,i)},K.prototype.signWithMessageHashPSS=function(e,t,i){var n,r=re(e),o=r.length,s=this.n.bitLength()-1,a=Math.ceil(s/8),c=function(e){return u.crypto.Util.hashHex(e,t)};if(-1===i||void 0===i)i=o;else if(-2===i)i=a-o-2;else if(i<-2)throw new Error("invalid salt length");if(a<o+i+2)throw new Error("data too long");var l="";i>0&&(l=new Array(i),(new G).nextBytes(l),l=String.fromCharCode.apply(String,l));var d=re(c(oe("\0\0\0\0\0\0\0\0"+r+l))),p=[];for(n=0;n<a-i-o-2;n+=1)p[n]=0;var A=String.fromCharCode.apply(String,p)+""+l,f=Ee(d,A.length,c),M=[];for(n=0;n<A.length;n+=1)M[n]=A.charCodeAt(n)^f.charCodeAt(n);var g=65280>>8*a-s&255;for(M[0]&=~g,n=0;n<o;n++)M.push(d.charCodeAt(n));return M.push(188),xe(this.doPrivate(new h(M)).toString(16),this.n.bitLength())},K.prototype.verify=function(e,t){if(null==(t=t.toLowerCase()).match(/^[0-9a-f]+$/))return!1;var i=W(t,16),n=this.n.bitLength();if(i.bitLength()>n)return!1;var r=this.doPublic(i).toString(16);if(r.length+3!=n/4)return!1;var o=je(r.replace(/^1f+00/,""));if(0==o.length)return!1;var s,a=o[0];return o[1]==(s=e,u.crypto.Util.hashString(s,a))},K.prototype.verifyWithMessageHash=function(e,t){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var i=W(t,16);if(i.bitLength()>this.n.bitLength())return 0;var n=je(this.doPublic(i).toString(16).replace(/^1f+00/,""));return 0!=n.length&&(n[0],n[1]==e)},K.prototype.verifyPSS=function(e,t,i,n){var r=function(e){return u.crypto.Util.hashHex(e,i)}(oe(e));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(r,t,i,n)},K.prototype.verifyWithMessageHashPSS=function(e,t,i,n){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var r,o=new h(t,16),s=function(e){return u.crypto.Util.hashHex(e,i)},a=re(e),c=a.length,l=this.n.bitLength()-1,d=Math.ceil(l/8);if(-1===n||void 0===n)n=c;else if(-2===n)n=d-c-2;else if(n<-2)throw new Error("invalid salt length");if(d<c+n+2)throw new Error("data too long");var p=this.doPublic(o).toByteArray();for(r=0;r<p.length;r+=1)p[r]&=255;for(;p.length<d;)p.unshift(0);if(188!==p[d-1])throw new Error("encoded message does not end in 0xbc");var A=(p=String.fromCharCode.apply(String,p)).substr(0,d-c-1),f=p.substr(A.length,c),M=65280>>8*d-l&255;if(0!=(A.charCodeAt(0)&M))throw new Error("bits beyond keysize not zero");var g=Ee(f,A.length,s),y=[];for(r=0;r<A.length;r+=1)y[r]=A.charCodeAt(r)^g.charCodeAt(r);y[0]&=~M;var m=d-c-n-2;for(r=0;r<m;r+=1)if(0!==y[r])throw new Error("leftmost octets not zero");if(1!==y[m])throw new Error("0x01 marker not found");return f===re(s(oe("\0\0\0\0\0\0\0\0"+a+String.fromCharCode.apply(String,y.slice(-n)))))},K.SALT_LEN_HLEN=-1,K.SALT_LEN_MAX=-2,K.SALT_LEN_RECOVER=-2,ze.hex2dn=function(e,t){void 0===t&&(t=0);var i=new ze;return Te.getTLV(e,t),i.getX500Name(e).str},ze.hex2rdn=function(e,t){if(void 0===t&&(t=0),"31"!==e.substr(t,2))throw new Error("malformed RDN");for(var i=new Array,n=Te.getChildIdx(e,t),r=0;r<n.length;r++)i.push(ze.hex2attrTypeValue(e,n[r]));return(i=i.map((function(e){return e.replace("+","\\+")}))).join("+")},ze.hex2attrTypeValue=function(e,t){var i=Te,n=i.getV;if(void 0===t&&(t=0),"30"!==e.substr(t,2))throw new Error("malformed attribute type and value");var r=i.getChildIdx(e,t);2!==r.length||e.substr(r[0],2);var o=n(e,r[0]),s=u.asn1.ASN1Util.oidHexToInt(o);return u.asn1.x509.OID.oid2atype(s)+"="+re(n(e,r[1]))},ze.getPublicKeyFromCertHex=function(e){var t=new ze;return t.readCertHex(e),t.getPublicKey()},ze.getPublicKeyFromCertPEM=function(e){var t=new ze;return t.readCertPEM(e),t.getPublicKey()},ze.getPublicKeyInfoPropOfCertPEM=function(e){var t,i,n=Te.getVbyList,r={};return r.algparam=null,(t=new ze).readCertPEM(e),i=t.getPublicKeyHex(),r.keyhex=n(i,0,[1],"03").substr(2),r.algoid=n(i,0,[0,0],"06"),"2a8648ce3d0201"===r.algoid&&(r.algparam=n(i,0,[0,1],"06")),r},ze.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"];var be,Oe=[(be=new ze,be.readCertPEM(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=113,n=126,r=0,o="";return arguments[r].split(o).map((function(e){return e.charCodeAt(r)>n?e:String.fromCharCode((e.charCodeAt(r)+i)%n)})).join(o)}(":::::ORTV[-PR_aVSVPNaR:::::ZVVS@\tPPNErtNVONtVWNZR}@]nU\0ZaZN=TP`\0T`Vo@Q^ROPbNZVTSZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg\tR^ZNATN>bROU^zc}nzyg\tR]ZN=TN>bRPtTn?bf?FZ_NQtfQc^^YQNq`gdSp?cyZ^P^fQc^^QQNWQ^aRvZPNTP`\0T`Vo@Q^RWN_fapzFqSFwfbOndSnzyuYz[oaNrS=\\QN>Z\tN\\Q^B[QqnS=\b\\QN>Zwp\\Q^B[QqnZVTSZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg\tR^ZNATN>bROU^zc}nzyg\tR]ZN=TN>bRPtTn?bf?FZ_NQtfQc^^YQNq`gdSp?cyZ^P^fQc^^QQNWQ^aRvZPNTP`\0T`Vo@Q^RWN_fapzFqSFwfbOndSnzyuYz[oaPPNvVQ^fWX|gVup[N^ROO^NQttV]NQPPNt|PttVONZU|C\b\\@@e^Xv{[vTtd8`nyO@ebN[bqx=ng?\tS^w@|XAz|qUTwfzn]Bu<qs_ae\\y<}u`eRAoE`_\\s\0r|b{rp_o<oC@o=x\bw_cUUZPApQevD\\FxFoFgE=<sq[p<coqyn>TEpP@aSC_YDU8\0|8TB?c>r\\=rp`pcwP}c\0PP_\\RS\\EPVSy8x`\0?R|NP\tP>}A^VP}Ex\bUZa=syDw}>Ya8wPp[pRnn\brU^dE8U?a\bcW|<FEbbupn^`ZNr\tsof[wA}e{\\z}w[YDQ|dt=wC\tNvbRZ@@U|ZAYpFsabCBB\\`wrqxsYW8uFyWdaWezeUeA_8VoVupvY[TD[OYdpO\bC[wX\\O]=[QRpV\0d`N\0RXt^Z}vEpdC=\bY?=V}?^W\bad|qN@Ww>@PycaqANE]asPcE^OB_VA?>wzeftac\tZ\tguf\bF]DCP?znNYf\tuaYu[`=b|v]Bp=RAS``\\PRDW]_`UXdUg=SuqwVFDeB\tD8{B>\\sPYbEU\tFQXz\0@`zsqgfD\0[WY\bPeZc}\t\0bx?Rfed}BUe|Uo\0y?\bsSXZOSBCgbFqf\0Bs?b?d<VE\\Zzns\\d@?dPvf\\{}_\0Sd[<q_YBY`Ffg=sY>{t<fu]xrFNtZONNTwbQO\\ZO=TN>bqQt^dOOaAFXw=\tPCVxsv?{`a\bvS8YQ[aNsOt[cU`ZRTQNdtOaAFXw=\tPCVxsv?{`a\bvS8YQ[aNZOt[cU_ZROaNQN^U<ZN=TP`\0T`Vo@Q^ROPbNNAVPN^P\0{y\0Bs\\8\0R[z]w??qZP?NpgdenSuvv?>|f_?UpYPcQ\\gCb8zxtSvsOQNg>[\\\0\bx\b_o@8\0g`Z<PyUE`8yu}\\g{@`s`zUgErRtve{YdCvoO@>WFDtABNp\0feUWszpQaEYNAc]^xB[@]BDAN8\b}XA=EnO}Pud8TA\t?yPrVv{\\>E]o`BO^RE^X[W[rEU?x\bf>V\tOUwY=>X[\\E`tW[8}VwpFBQcnrPF}yUtd8<Doe_\b[oOVUep@pYY\0cegY{r\t?\bAbq?ff8}UaXoN_D]_X_8yozYFT`N{`\\{zvu?\bDWT}=_<StX\tNx\0\b\t\0aT=c@ucnWfR[vf>RFxAFV}{N`dN^\\<eawBPxx}quT=|{T_R@Fp^Y<ZevRsWaZ]V\tCVrRVtAAc[\tQp|d|tqoQ=T|XX\t=u\\N8XNCx\\aU>wz\tX<e@Vc?dy\\|^FEq|=p`pBdF@bs^d<]vp\\^TZ\tP\bZ\b\\YNNSZ_\\w^|TsD8db\t_\tY\\o^Cw>Z\0x\\^aN]wWf\bA}\tC^d_{ZC@\by]gY@E\tBFY?OsaqbDcVgQbZeFc\tovtucxnq|<TnuyXRveYFOegCpAs{YTe|>bE<OXsSqCBWD_SVepfvCCUg]z\tZvQ[\0s|U>pFz\b=OwT``fNJJ:::::R[Q-PR_aVSVPNaR:::::")),be)];function Se(e,t){var i=e.getIssuerHex();if(i===e.getSubjectHex())return e.verifySignature(e.getPublicKey());var n=function(e,t){for(var i=0,n=t;i<n.length;i++){var r=n[i];if(r.getSubjectHex()===e)return r}}(i,t);return!!n&&(!1!==e.verifySignature(n.getPublicKey())&&Se(n,t))}function Le(e){return e.getIssuerHex()!==e.getSubjectHex()&&Se(e,Oe)}!function(e){var t=new ze;"string"==typeof e?t.readCertPEM(e):t.readCertHex(e.hex);var i=Le(t);Oe.push(t)}(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=113,n=126,r=0,o="";return arguments[r].split(o).map((function(e){return e.charCodeAt(r)>n?e:String.fromCharCode((e.charCodeAt(r)+i)%n)})).join(o)}(":::::ORTV[-PR_aVSVPNaR:::::ZVVTU\tPPONrtNVONtVWNW=_SVw\tVE=ZN=TP`\0T`Vo@Q^ROPbNZVTSZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg\tR^ZNATN>bROU^zc}nzyg\tR]ZN=TN>bRPtTn?bf?FZ_NQtfQc^^YQNq`gdSp?cyZ^P^fQc^^QQNWQ^aRvZPNTP`\0T`Vo@Q^RWN_fapzFqSFwfbOndSnzyuYz[oaNrS=\bZQNAZaN\\aZ\t[QSnS=\b[aNBZQZ\\aZ\t[QSnZVTaZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg\tR^ZNATN>bROU^zc}nzyg\tRbZOVTN>bRPtYoTyuoz}}f`Bwo?=RQN\\Ot[cONZO>Wyfd\tgdbRaN]Ot[cONZZPRuupz_@feWyZ`bVfWX|gVup[N^xOSugnec|fdyndB{^T}fdB\0ndRf?FZVVPVwN[Otx\0uxvTF=ON^RSNN\\PNtENZVVPPtXPNtRN?=?]q[VD|{\\oyo`oOu}F\tSAe`tn[t\tu\b8^a]qx\bE_^ZN?[QC\0yuOpybY8r\\RPAS=8rUq\0E8>xean^e\bf]Y`XO}{C[Ur^?\0x[SRXvVQ\\CFr}QnAPRQFO=Yw\0_TePCOFV@|N>ROXcDrT<>bW<ssO?NOT{^s]uU\0gS\bBffsfE\0AfDyQEZR`]XBo|Qw}yYdwwTvOFcBndUz^\\{]\tb=^yQYSTQ`]\0?tR{WRUun\\\0bVe_E|VWWV|r\tAo\0\tF`fdzCnRtq\br\t\b8eBp=Z\\TRaadc}@Eub`quuNqAdF\0aUay{}x>tgVz`\t_YBFwu_q?egt8v[o\x008\twTQcrA\t<z{DZoEE^rZTrpaZQzqpBY]^zt8[bQv}yEWw\tXDYQB\0QB\bx_^X]|uEDtPf[n[r_bpB[bE}?ung|bnU|NYOoedY_tvXySZfYPdWV]OE^\bOFwA}<uXoO}_NDz8aonzWOfcv@?>snfqu@FeEx^\\\bVfuO`\\\0tSg]zDU}QrAT|\tOZV|OvpVD<sN@z`<_cSrNCW>?=Au?g_8v{|}}WF>Sr>QBxO\td_D}eBb?Uq^b\t[y}x]}{?P|BQtecTB[pQBW>|p|nfv\0zUxOO}WqwE=<PURZy@X8r\\]u=<pPNRNNn\\OtaO<ZOETPdPT`NTT8RVOQ^^`SuO`gdSp?cyVRg\bo?B=VR[OZO=TN>bqQt^dOO`FyWadZcAD\tpeXybcW@}Qf\\QNsOt[cU`ZRTQNdtOaAFXw=\tPCVxsv?{`a\bvS8YQ[aN]Ot[cU_ZONsEROaNQN^U<ZNTN>bqQ^RNVOOwN[Otx\0uxvTF=ON^SNN\\PNtRNrx\ta[}tP_g8FbD\0^\0qt<f88ufuN]^}]gp\bqYudF88Fas_Ef`\t?^x>X}esa{>\\r?eE]CC_cZ[vQs\t\t>gX[szONg=^pn=<e]nbSz\bZvac\b[w^nA_`vP|@8w[}nQobe=??oRYf{vpRxcC}yCd>8[NDx{Ne\\t8oou=guC>>gvb}ACd\t``Ntq\0yC[Q{|ynpNQqSqzxF<_PFDw<]Bnnu>F<XgU_Zf\\\\A=gu\\codOwQ]oQ<f>gv_pwozwC}xX>C`c]suEdfW?cbeo\b`BbyR@eFTUwSud=t]sS\\onc\tXSq\t{\0DvAVBbnTqEE[QzDyqF`bF}R=Q?VeDo<Vzb\0w}D}NZ\0t}^?OyFP\bVaVNrTNYqe?[NRYTSQby@yzWvT`wQo}y]c_WgxBYCy\tRNRg@NZCaaq8?`\t^`?ryD\t=obzw?E]Ou]n@>bVzqAQT?@_zo@}CxWVTUsAYdNd?{APQr8{P]]AZ>aR\0[D<z?Tr@`u@X|YDwd_<p<>zWE>]\0=X`\b@uucp|^_Qb@uZouTX^o\0\\{PCq{ug8^f[YQAWad8FNqxFQE?ZOo\t}RnO\bsQc\txyccn=nxvs>bDBf\b\bW\\TuTnvAO^U\0QXC>xx8FxRFf<tJ:::::R[Q-PR_aVSVPNaR:::::"));var ke=2*Math.PI,Ce=Math.PI/2;function Pe(e){return e>0&&e<=ke?e:(e%ke+ke)%ke}var Be=function(e){function i(t){var i=e.call(this,t,1,.1,1e3)||this;return i.pose={longitude:0,latitude:0,fov:t,distance:0,offset:new r.Vector3},i.computePose(),i}return t.__extends(i,e),i.prototype.computePose=function(){var e=this.getWorldDirection(new r.Vector3);return this.pose.longitude=Pe(-Math.atan2(e.x,-e.z)),this.pose.latitude=-Math.asin(e.y/1),this.pose.fov=this.fov,this.pose.distance=0,this.pose.offset.copy(this.position),this},i.prototype.setFromPose=function(e){var t,i,n,o,s,a=Pe(null!==(t=e.longitude)&&void 0!==t?t:this.pose.longitude),u=Math.max(1e-4-Ce,Math.min(Ce-1e-4,null!==(i=e.latitude)&&void 0!==i?i:this.pose.latitude)),c=null!==(n=e.fov)&&void 0!==n?n:this.pose.fov,l=null!==(o=e.distance)&&void 0!==o?o:this.pose.distance,h=null!==(s=e.offset)&&void 0!==s?s:this.pose.offset,d=function(e){var t=Math.abs(Math.cos(e.latitude));return new r.Vector3(-Math.sin(e.longitude)*t,-Math.sin(e.latitude),-Math.cos(e.longitude)*t)}({longitude:a,latitude:u}).normalize();return this.position.set(0,0,0),this.lookAt(d),this.position.add(h).sub(d.clone().setLength(l)),this.fov!==c&&(this.fov=c,this.updateProjectionMatrix()),this.updateMatrixWorld(),this.pose.longitude=a,this.pose.latitude=u,this.pose.fov=c,this.pose.distance=l,this.pose.offset.copy(h),this},i.prototype.copyPose=function(){return{longitude:this.pose.longitude,latitude:this.pose.latitude,fov:this.pose.fov,distance:this.pose.distance,offset:this.pose.offset.clone()}},i}(r.PerspectiveCamera),_e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(i,e),i.prototype.add=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];return e.prototype.add.apply(this,t)},i.prototype.remove=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];return e.prototype.remove.apply(this,t)},i}(r.Scene),Ue=function(e){function i(t){var i=t.preserveDrawingBuffer,n=void 0===i||i,o=t.backgroundColor,s=void 0===o?1579548:o,a=t.backgroundAlpha,u=void 0===a?1:a,c=t.pixelRatio,l=void 0===c?1:c,h=t.antialias,d=void 0!==h&&h,p=e.call(this,{antialias:d,preserveDrawingBuffer:n,alpha:u<1})||this;return p.setPixelRatio(l),p.setClearColor(s,u),p.outputEncoding=r.sRGBEncoding,p.autoClear=!0,p}return t.__extends(i,e),i}(r.WebGLRenderer);function Re(e){return null==e}function Qe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t]}function Ye(){return(65536*(1+Math.random())|0).toString(16).substring(1)}function Fe(){return(Ye()+Ye()+"-"+Ye()+"-4"+Ye().substr(0,3)+"-"+Ye()+"-"+Ye()+Ye()+Ye()).toLowerCase()}var Ve="undefined"!=typeof performance&&void 0!==performance.timing?performance.timing.navigationStart:Date.now(),He="undefined"!=typeof performance?function(){return Ve+performance.now()}:function(){return Date.now()},Ge=function(){if("undefined"!=typeof window){var e=window;return e.requestAnimationFrame||e.mozRequestAnimationFrame||e.webkitRequestAnimationFrame||e.msRequestAnimationFrame||function(e){return setTimeout(e,16)}}return function(e){return setTimeout(e,16)}}(),We=function(){function e(){this.frames=[],this.stoped=!1,this.time=He(),this.loop=this.loop.bind(this),this.loop()}return Object.defineProperty(e,"shared",{get:function(){return this.sharedInstance||(this.sharedInstance=new e),this.sharedInstance},enumerable:!1,configurable:!0}),e.prototype.loop=function(){if(!this.stoped){var e=He(),t=e-this.time;this.time=e;for(var i=[],n=0,r=this.frames;n<r.length;n++){var o=r[n];if(o.delay>0)o.delay=o.delay-1;else{try{o.callback(e,t)}catch(e){console.error(e)}o.once&&i.push(o)}}i.length>0&&(this.frames=this.frames.filter((function(e){return-1===i.indexOf(e)}))),Ge(this.loop)}},e.prototype.remove=function(e){var t=this.frames.indexOf(e);t>=0&&this.frames.splice(t,1)},e.prototype.add=function(e,t,i,n){var r=this;void 0===t&&(t=!1),void 0===i&&(i=0),void 0===n&&(n=5);var o={callback:e,once:t,delay:i,order:n};return this.frames.push(o),this.frames.sort((function(e,t){return e.order-t.order})),function(){return r.remove(o)}},e.prototype.disponse=function(){this.stoped=!0,this.frames.length=0},e.prototype.getFrameTime=function(e){return this.add((function(t,i){return e(i)}),!0,0,0)},e}(),qe=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.floorIndex=0,t.needsRender=!0,t}return t.__extends(i,e),i}(r.Mesh),Ke=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.needsRender=!0,t}return t.__extends(i,e),i.prototype.getTransparent=function(){var e;return this.traverse((function(t){void 0===e&&t instanceof qe&&t.material.forEach((function(t){void 0===e&&1===t.uniforms.originOpacity.value&&(e=t.transparent)}))})),null!=e&&e},i.prototype.setTransparent=function(e){this.traverse((function(t){t instanceof qe&&t.material.forEach((function(t){1===t.uniforms.originOpacity.value&&(t.transparent=e)}))}))},i.prototype.getMaterial=function(){var e=null;return this.traverse((function(t){if(null===e&&t instanceof qe){var i=t.material[0];e={pano0:i.pano0,pano1:i.pano1,modelAlpha:i.modelAlpha,progress:i.progress,useBlackTransition:i.useBlackTransition,perspToOrtho:i.perspToOrtho,opacity:i.opacity,panoVideo:i.panoVideo}}})),e},i.prototype.setMaterial=function(e){this.traverse((function(t){t instanceof qe&&t.material.forEach((function(t){void 0!==e.pano0&&(t.pano0=e.pano0),void 0!==e.pano1&&(t.pano1=e.pano1),void 0!==e.modelAlpha&&(t.modelAlpha=e.modelAlpha),void 0!==e.progress&&(t.progress=e.progress),void 0!==e.useBlackTransition&&(t.useBlackTransition=e.useBlackTransition),void 0!==e.perspToOrtho&&(t.perspToOrtho=e.perspToOrtho),void 0!==e.opacity&&(t.opacity=e.opacity),void 0!==e.panoVideo&&(t.panoVideo=e.panoVideo)}))}))},i.prototype.disposeMaterial=function(){this.traverse((function(e){if(e instanceof qe){var t=[];e.material.forEach((function(e){var i=e.uniforms;Object.keys(i).map((function(e){if(["pano0DepthMap"].indexOf(e)>=0)i[e].value=null;else{var n=i[e].value;n&&"function"==typeof n.dispose&&-1===t.indexOf(n)&&(i[e].value=null,t.push(n))}})),e.dispose()})),t.forEach((function(e){return e.dispose()}))}}))},i.prototype.disposeGeometry=function(){this.traverse((function(e){e instanceof qe&&e.geometry.dispose()}))},i}(r.Group),Ze=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.floorIndex=0,t}return t.__extends(i,e),i}(Ke),Xe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=113,n=126,r=0,o="";return arguments[r].split(o).map((function(e){return e.charCodeAt(r)>n?e:String.fromCharCode((e.charCodeAt(r)+i)%n)})).join(o)}("{vs|z-rp@-z|qryPr{rH{vs|z-sy|n-}r}a|\\u|Hn\bv{t-rp@-[|znyHn\bv{t-rp@-cvr]|vv|{Hn\bv{t-rp@-|yq]|vv|{H0v{pyqr-Ip|zz|{K0v{pyqr-Il}nlrrK0v{pyqr-I?l}nlrrK0v{pyqr-Ip|y|l}nlrrK|vq-znv{56-\n--0v{pyqr-IlrrK--0v{pyqr-I?lrrK--0v{pyqr-Ip|y|lrrK--0v{pyqr-Iortv{{|znylrrK--0v{pyqr-Iqrsny{|znylrrK--rpA-n{s|zrq-J-rpA5}|vv|{9->;=6H--rpA-z]|vv|{-J-z|qrycvrZnv-7-n{s|zrqH--[|zny-J-{|znyv\tr5n{s|zrq[|zny6H--cvr]|vv|{-J-:z]|vv|{;\b\tH--|yq]|vv|{-J-5z|qryZnv-7-n{s|zrq6;\b\tH--tyl]|vv|{-J-}|wrpv|{Znv-7-z|qrycvrZnv-7-n{s|zrqH--<<-修正正交相机模拟--rp@-pnzrn[|zny-J-5z|qrycvrZnv-7-rpA5=;=9-=;=9->;=9-=;=66;\b\tH--sy|n-|u|Qvn{pr-J-zn5=;=>9-q|5pnzrn[|zny9-z|qryPr{r-:-pnzrn]|vv|{66H--tyl]|vv|{;-J-zv5-tyl]|vv|{;9-tyl]|vv|{;-7-5-tyl]|vv|{;\t-<-|u|Qvn{pr-69-}r}a|\\u|-6H--tyl]|vv|{;\b-J-zv5-tyl]|vv|{;\b9-tyl]|vv|{;\b-7-5-tyl]|vv|{;\t-<-|u|Qvn{pr-69-}r}a|\\u|-6H\f"),Je=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=113,n=126,r=0,o="";return arguments[r].split(o).map((function(e){return e.charCodeAt(r)>n?e:String.fromCharCode((e.charCodeAt(r)+i)%n)})).join(o)}("0qrsv{r-OYNPXlP\\Y\\_-rpA5=;=EC9-=;>=C9-=;>AF9->;=60qrsv{r-aNb-C;?E@>EB?0vs-qrsv{rq5b`RlYbZV[N[PR6p-]n{|]vpr-\n--nz}yrPor-zn}H--nz}yrPor-yzv{n{prZn}H--znA-znvH\fH0ryrp-]n{|]vpr-\n--nz}yrPor-zn}H--znA-znvH\fH0r{qvsp-]n{|cvqr|-\n--rp?-v\trH--znA-znvH--sy|n-ny}unH--nz}yr?Q-zn}H\fH{vs|z-rp@-qvssrH{vs|z-rp@-rzvvrH{vs|z-rp@-}rpynH{vs|z-sy|n-uv{v{rH{vs|z-sy|n-r}|rH{vs|z-sy|n-|}npv\bH{vs|z-sy|n-|vtv{\\}npv\bH{vs|z-sy|n-z|qryNy}unH{vs|z-sy|n-}|trH{vs|z-]n{|]vpr-}n{|=H{vs|z-]n{|]vpr-}n{|>H0vs-qrsv{rq5b`Rl]N[\\lcVQR\\6--{vs|z-]n{|cvqr|-}n{|cvqr|H0r{qvsn\bv{t-rp@-|yq]|vv|{H0v{pyqr-Ip|zz|{K0v{pyqr-I}npxv{tK0v{pyqr-Ip|y|l}nlsntzr{K0v{pyqr-Il}nlsntzr{K0v{pyqr-I?l}nlsntzr{K0v{pyqr-Izn}l}nlsntzr{K0v{pyqr-Iny}unzn}l}nlsntzr{K0v{pyqr-In|zn}l}nlsntzr{K0v{pyqr-Iyvtuzn}l}nlsntzr{K0v{pyqr-Irzvvrzn}l}nlsntzr{K0v{pyqr-Ir{zn}l}nlsntzr{K0v{pyqr-Itnqvr{zn}l}nlsntzr{K0v{pyqr-Is|tl}nlsntzr{K0v{pyqr-IoqsK0v{pyqr-Iyvtul}nlortv{K0v{pyqr-Iyvtul}u|{tl}nlsntzr{Krp?-|P||q5rp@-rp|6-\n--sy|n--J-yr{tu5rp|6H--sy|n-urn-J-np|5rp|;\b-<-6H--sy|n-}uv-J-nn{5rp|;9-rp|;\t6H--r{-rp?5=;B-8-}uv-<-aNb9-urn-<-]V6H\f|vq-znv{56-\n--rpA-qvssrP|y|-J-rpA5qvssr9-|vtv{\\}npv\b6H--_rsyrprqYvtu-rsyrprqYvtu-J-_rsyrprqYvtu5rp@5=;=69-rp@5=;=69-rp@5=;=69-rp@5=;=66H--rp@-|nyRzvvr_nqvn{pr-J-rzvvrH--0v{pyqr-Izn}lsntzr{K--0v{pyqr-Ip|y|lsntzr{K--0v{pyqr-Iny}unzn}lsntzr{K--0v{pyqr-Iny}unrlsntzr{K--0v{pyqr-I}rpynzn}lsntzr{K--0v{pyqr-I{|znylsntzr{lortv{K--0v{pyqr-I{|znylsntzr{lzn}K--0v{pyqr-Irzvvrzn}lsntzr{K--0v{pyqr-Iyvtul}u|{tlsntzr{K--0v{pyqr-Iyvtulsntzr{lortv{K--<<-调整曝光值--vnqvn{pr-J-vnqvn{pr-7-r}|rH--0v{pyqr-Iyvtulsntzr{lzn}K--0v{pyqr-Iyvtulsntzr{lr{qK--0v{pyqr-In|zn}lsntzr{K--<<-减少方向光对模型的影响--rp@-|t|v{tYvtu-J-5rsyrprqYvtu;qvrpQvssr-7-=;?6-8----rsyrprqYvtu;v{qvrpQvssr-8----rsyrprqYvtu;v{qvrp`}rpyn-8----|nyRzvvr_nqvn{prH--<<-修复黑色面片的问题--vs-5|t|v{tYvtu;-K-=;=-\v\v-|t|v{tYvtu;t-K-=;=-\v\v-|t|v{tYvtu;o-K-=;=6-\n----tylSntP|y|-J-rpA5|t|v{tYvtu9-qvssrP|y|;n6H--\f-ryr-\n----tylSntP|y|-J-rpA5OYNPXlP\\Y\\_;\b\t9-qvssrP|y|;n6H--\f--rp@-}n{|=a|crr-J-5|yq]|vv|{-:-}n{|=;znvh@j;\b\t6-7-zn@5}n{|=;znv6H--rp@-}n{|>a|crr-J-5|yq]|vv|{-:-}n{|>;znvh@j;\b\t6-7-zn@5}n{|>;znv6H--rpA-}n{|P|y|H--rpA-}n{|=P|y|-J-rrPor5}n{|=;zn}9-}n{|=a|crr6H--rpA-}n{|>P|y|-J-rrPor5}n{|>;zn}9-}n{|>a|crr6H--0vs-qrsv{rq5b`RlYbZV[N[PR6----}n{|=P|y|;n-J->;=-:-rrPor5}n{|=;yzv{n{prZn}9-}n{|=a|crr6;H----}n{|>P|y|;n-J->;=-:-rrPor5}n{|>;yzv{n{prZn}9-}n{|>a|crr6;H--0r{qvs--0vs-qrsv{rq5b`RlOYNPXla_N[`VaV\\[6----sy|n-oynpx]|tr-J-np|5:?;=-7-}|tr-8->;=6H----}n{|P|y|-J-zv5}n{|=P|y|9-OYNPXlP\\Y\\_9-zv{5>;=9-oynpx]|tr66H----}n{|P|y|-J-zv5}n{|P|y|9-}n{|>P|y|9-zn5=;=9-oynpx]|tr-:-?;=66H--0ryr----}n{|P|y|-J-zv5}n{|=P|y|9-}n{|>P|y|9-}|tr6H--0r{qvs--0vs-qrsv{rq5b`Rl]N[\\lcVQR\\6----rp@-pnzrna|crr-J-|yq]|vv|{-:-pnzrn]|vv|{H----rpA-zn}P||q-J-rpA5pnzrna|crr9->;=6-7-}n{|cvqr|;znvH----rp?--J-rp?5------=;B-8-zn}P||q;-<-zn}P||q;\t-<-}n{|cvqr|;v\tr;9------=;B-:-zn}P||q;\b-<-zn}P||q;\t-<-}n{|cvqr|;v\tr;\b----6H----rpA-vqr|P|y|-J-rr?Q5}n{|cvqr|;zn}9-6H----sy|n-znpu-J-5>;=-:-r}5=;=9-zn}P||q;\t66-7-5>;=-:-r}5=;B9-no5;-:-=;B666-7-5>;=-:-r}5=;B9-no5;\b-:-=;B666H----sy|n-ny}un-J-pynz}5=;=9->;=9-B;=-7-5>;=-:-pynz}5qvn{pr59-rp?5=;B9-=;B66-<-=;BB-9-=;=9->;=666H----}n{|P|y|-J-zv5}n{|P|y|9-vqr|P|y|9-znpu-7-ny}un-7-}n{|cvqr|;ny}un6H--0r{qvs--tylSntP|y|-J-rpA5tylSntP|y|;to9-|}npv\b6H--tylSntP|y|-J-zv5}n{|P|y|9-tylSntP|y|9-z|qryNy}un6H\f");function $e(){return"undefined"==typeof document?{}:document.createElementNS("http://www.w3.org/1999/xhtml","img")}var et=$e();et.width=et.height=8;var tt=new r.Texture(et);tt.name="EMPTY_TEXTURE";var it=new r.CubeTexture([et,et,et,et,et,et]);it.name="EMPTY_CUBE_TEXTURE",tt.dispose=it.dispose=function(){};var nt=Object.assign({modelAlpha:new r.Uniform(0),originOpacity:new r.Uniform(1),progress:new r.Uniform(0),pano0:new r.Uniform({map:it,luminanceMap:null,matrix:new r.Matrix4}),pano1:new r.Uniform({map:it,luminanceMap:null,matrix:new r.Matrix4}),pano0DepthMap:new r.Uniform(null),panoVideo:new r.Uniform(null),modelCenter:new r.Uniform(new r.Vector3),perspToOrtho:new r.Uniform(0)},{exposure:new r.Uniform(1),emissive:new r.Uniform(new r.Color(0)),emissiveMap:new r.Uniform(null),specular:new r.Uniform(new r.Color(1118481)),specularMap:new r.Uniform(null),normalMap:new r.Uniform(null),bumpMap:new r.Uniform(null),shininess:new r.Uniform(30)},r.UniformsLib.common,r.UniformsLib.lights),rt=function(e){function i(t){var i,n,o,s,a,u,c,l;void 0===t&&(t={});var h=e.call(this,{vertexShader:Xe,fragmentShader:Je,uniforms:r.UniformsUtils.clone(nt),defines:{USE_MAP:!0,USE_UV:!0,USE_LUMINANCE:!1,USE_BLACK_TRANSITION:!1,USE_PANO_VIDEO:!1},blending:r.NoBlending,lights:!0})||this;return Object.defineProperties(h,{pano0:{get:function(){var e=this.uniforms.pano0.value;return e.map===it?null:{map:e.map,luminanceMap:e.luminanceMap,matrix:e.matrix.clone()}},set:function(e){this.uniforms.pano0.value=null===e?{map:it,luminanceMap:null,matrix:new r.Matrix4}:{map:e.map,luminanceMap:e.luminanceMap,matrix:e.matrix.clone()};var t=null!==this.uniforms.pano0.value.luminanceMap&&null!==this.uniforms.pano1.value.luminanceMap;this.defines.USE_LUMINANCE!==t&&(this.defines.USE_LUMINANCE=t,this.needsUpdate=!0)}},pano1:{get:function(){var e=this.uniforms.pano1.value;return e.map===it?null:{map:e.map,luminanceMap:e.luminanceMap,matrix:e.matrix.clone()}},set:function(e){this.uniforms.pano1.value=null===e?{map:it,luminanceMap:null,matrix:new r.Matrix4}:{map:e.map,luminanceMap:e.luminanceMap,matrix:e.matrix.clone()};var t=null!==this.uniforms.pano0.value.luminanceMap&&null!==this.uniforms.pano1.value.luminanceMap;this.defines.USE_LUMINANCE!==t&&(this.defines.USE_LUMINANCE=t,this.needsUpdate=!0)}},modelAlpha:{get:function(){return this.uniforms.modelAlpha.value},set:function(e){this.uniforms.modelAlpha.value=e}},progress:{get:function(){return this.uniforms.progress.value},set:function(e){this.uniforms.progress.value=e}},useBlackTransition:{get:function(){return this.defines.USE_BLACK_TRANSITION},set:function(e){this.defines.USE_BLACK_TRANSITION!==e&&(this.defines.USE_BLACK_TRANSITION=e,this.needsUpdate=!0)}},opacity:{get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e,this.blending=e<1?r.NormalBlending:r.NoBlending}},perspToOrtho:{get:function(){return this.uniforms.perspToOrtho.value},set:function(e){this.uniforms.perspToOrtho.value=e}},panoVideo:{get:function(){return this.uniforms.panoVideo.value},set:function(e){this.uniforms.panoVideo.value=e;var t=null!==e;t!==this.defines.USE_PANO_VIDEO&&(this.defines.USE_PANO_VIDEO=t,this.needsUpdate=!0)}}}),h.pano0=null!==(i=t.pano0)&&void 0!==i?i:null,h.pano1=null!==(n=t.pano1)&&void 0!==n?n:null,h.modelAlpha=null!==(o=t.modelAlpha)&&void 0!==o?o:1,h.progress=null!==(s=t.progress)&&void 0!==s?s:0,h.useBlackTransition=null!==(a=t.useBlackTransition)&&void 0!==a&&a,h.perspToOrtho=null!==(u=t.perspToOrtho)&&void 0!==u?u:0,h.opacity=null!==(c=t.opacity)&&void 0!==c?c:1,h.panoVideo=null!==(l=t.panoVideo)&&void 0!==l?l:null,h}return t.__extends(i,e),i}(r.ShaderMaterial),ot=new r.Vector3(0,0,0),st=function(e){function i(t,i){void 0===i&&(i=ot);var n=e.call(this)||this,o=new r.BoxBufferGeometry(t.max.x-t.min.x+2*i.x,t.max.y-t.min.y+2*i.y,t.max.z-t.min.z+2*i.z,1,1);o.groups.length=0,o.groups.push({start:0,count:36,materialIndex:0}),o.applyMatrix4((new r.Matrix4).makeScale(-1,1,1));var s=new rt;s.defines.USE_MAP=!1,s.defines.USE_UV=!1,s.uniforms.diffuse.value=new r.Color(16777215);var a=new qe(o,[s]);return a.floorIndex=-1,a.position.copy(t.getCenter(new r.Vector3)),a.frustumCulled=!1,n.renderOrder=-1,n.add(a),n.boundingBox=new r.Box3,n.computeBoundingBox(),n}return t.__extends(i,e),i.prototype.computeBoundingBox=function(){this.boundingBox.setFromObject(this)},i.prototype.dispose=function(){this.disposeMaterial(),this.disposeGeometry()},i}(Ze);function at(e,t){return void 0===t&&(t=ot),new st(e,t)}var ut,ct,lt,ht,dt=function(){function e(e,t,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),this.x=e,this.y=t,this.z=i}return e.prototype.copy=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},e.prototype.set=function(e,t,i){return this.x=e,this.y=t,this.z=i,this},e.prototype.fromArray=function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},e.prototype.add=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this},e.prototype.multiplyScalar=function(e){return this.x*=e,this.y*=e,this.z*=e,this},e.prototype.subVectors=function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},e.prototype.dot=function(e){return this.x*e.x+this.y*e.y+this.z*e.z},e.prototype.cross=function(e){var t=this.x,i=this.y,n=this.z;return this.x=i*e.z-n*e.y,this.y=n*e.x-t*e.z,this.z=t*e.y-i*e.x,this},e.prototype.crossVectors=function(e,t){var i=e.x,n=e.y,r=e.z,o=t.x,s=t.y,a=t.z;return this.x=n*a-r*s,this.y=r*o-i*a,this.z=i*s-n*o,this},e.prototype.clone=function(){return new e(this.x,this.y,this.z)},e}(),pt=function(){function e(e,t,i,n,r){this._extentsMin=e,this._extentsMax=t,this._startIndex=i,this._endIndex=n,this._level=r,this._node0=null,this._node1=null,this.elementCount=n-i,this.center=[(e.x+t.x)/2,(e.y+t.y)/2,(e.z+t.z)/2];var o,s=this.size=[t.x-e.x,t.y-e.y,t.z-e.z];o=s[0]>s[1]?s[1]>s[2]?[2,1,0]:s[0]>s[2]?[1,2,0]:[1,0,2]:s[1]>s[2]?s[0]>s[2]?[2,0,1]:[0,2,1]:[0,1,2],this.order=o}return e.prototype.clearShapes=function(){this._startIndex=-1,this._endIndex=-1,this.elementCount=0},e}(),At=(ut=new dt,ct=new dt,lt=new dt,ht=new dt,function(e,t,i,n,r,o){ct.subVectors(t,e),lt.subVectors(i,e),ht.crossVectors(ct,lt);var s,a=r.dot(ht);if(a>0){if(o)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}ut.subVectors(n,e);var u=s*r.dot(lt.crossVectors(ut,lt));if(u<0)return null;var c=s*r.dot(ct.cross(ut));if(c<0)return null;if(u+c>a)return null;var l=-s*ut.dot(ht);if(l<0)return null;var h=l/a;return(new dt).copy(r).multiplyScalar(h).add(n)});function ft(e,t,i){var n={min:0,max:0};t.x>=0?(n.min=(i._extentsMin.x-e.x)*t.x,n.max=(i._extentsMax.x-e.x)*t.x):(n.min=(i._extentsMax.x-e.x)*t.x,n.max=(i._extentsMin.x-e.x)*t.x);var r={min:0,max:0};if(t.y>=0?(r.min=(i._extentsMin.y-e.y)*t.y,r.max=(i._extentsMax.y-e.y)*t.y):(r.min=(i._extentsMax.y-e.y)*t.y,r.max=(i._extentsMin.y-e.y)*t.y),n.min>r.max||r.min>n.max)return!1;r.min>n.min&&(n.min=r.min),r.max<n.max&&(n.max=r.max);var o={min:0,max:0};return t.z>=0?(o.min=(i._extentsMin.z-e.z)*t.z,o.max=(i._extentsMax.z-e.z)*t.z):(o.min=(i._extentsMax.z-e.z)*t.z,o.max=(i._extentsMin.z-e.z)*t.z),!(n.min>o.max||o.min>n.max)&&(o.min>n.min&&(n.min=o.min),o.max<n.max&&(n.max=o.max),!(n.max<0))}var Mt=function(){function e(e,t){void 0===t&&(t=10),this._trianglesArray=e,this._maxTrianglesPerNode=t,this._bboxArray=this.calcBoundingBoxes(e),this._bboxHelper=new Float32Array(this._bboxArray.length),this._bboxHelper.set(this._bboxArray);var i=e.length/9,n=this.calcExtents(0,i,1e-6);this._rootNode=new pt(n[0],n[1],0,i,0),this._nodesToSplit=[this._rootNode],this.splitNode()}return e.prototype.calcBoundingBoxes=function(e){for(var t,i,n,r,o,s,a,u,c,l,h,d,p,A,f,M=e.length/9,g=new Float32Array(7*M),y=0,m=0,v=0;v<M;y+=9,m+=7,v++)t=e[y],i=e[y+1],n=e[y+2],r=e[y+3],o=e[y+4],s=e[y+5],r<(l=t)&&(l=r),(a=e[y+6])<l&&(l=a),o<(h=i)&&(h=o),(u=e[y+7])<h&&(h=u),s<(d=n)&&(d=s),(c=e[y+8])<d&&(d=c),r>(p=t)&&(p=r),a>p&&(p=a),o>(A=i)&&(A=o),u>A&&(A=u),s>(f=n)&&(f=s),c>f&&(f=c),g[m]=v,g[m+1]=l,g[m+2]=h,g[m+3]=d,g[m+4]=p,g[m+5]=A,g[m+6]=f;return g},e.prototype.splitNode=function(){if(this._rootNode)for(this._splitNode(this._rootNode);this._nodesToSplit.length>0;)this._splitNode(this._nodesToSplit.pop())},e.prototype._splitNode=function(e){if(!(e.elementCount<=this._maxTrianglesPerNode||0===e.elementCount)){for(var t=e._startIndex,i=e._endIndex,n=[[],[],[]],r=[[],[],[]],o=e.center,s=7*(v=t);v<i;v++,s+=7)for(var a=0;a<3;a++)(this._bboxArray[s+1+a]+this._bboxArray[s+4+a])/2<o[a]?n[a][n[a].length]=v:r[a][r[a].length]=v;var u=[!(n[0].length&r[0].length),!(n[1].length&r[1].length),!(n[2].length&r[2].length)];if(!(u[0]&u[1]&u[2])){var c,l,h=e.order;for(a=0;a<3;a++){var d=h[a];if(!u[d]){c=n[d],l=r[d];break}}for(var p,A=t,f=A+c.length,M=f,g=i,y=e._startIndex,m=c.concat(l),v=0;v<m.length;v++)p=m[v],this._bboxHelper[7*y]=this._bboxArray[7*p],this._bboxHelper[7*y+1]=this._bboxArray[7*p+1],this._bboxHelper[7*y+2]=this._bboxArray[7*p+2],this._bboxHelper[7*y+3]=this._bboxArray[7*p+3],this._bboxHelper[7*y+4]=this._bboxArray[7*p+4],this._bboxHelper[7*y+5]=this._bboxArray[7*p+5],this._bboxHelper[7*y+6]=this._bboxArray[7*p+6],y++;var N=this._bboxHelper.subarray(7*e._startIndex,7*e._endIndex);this._bboxArray.set(N,7*e._startIndex);var D=this.calcExtents(A,f,1e-6),w=this.calcExtents(M,g,1e-6),T=new pt(D[0],D[1],A,f,e._level+1),x=new pt(w[0],w[1],M,g,e._level+1);e._node0=T,e._node1=x,e.clearShapes(),this._nodesToSplit.push(T,x)}}},e.prototype.calcExtents=function(e,t,i){if(e>=t)return[{x:0,y:0,z:0},{x:0,y:0,z:0}];var n,r=7*e,o=7*t+1,s=this._bboxArray[r+1],a=this._bboxArray[r+2],u=this._bboxArray[r+3],c=this._bboxArray[r+4],l=this._bboxArray[r+5],h=this._bboxArray[r+6],d=this._bboxArray;for(r+=7;r<o;r+=7)(n=d[r+1])<s&&(s=n),(n=d[r+2])<a&&(a=n),(n=d[r+3])<u&&(u=n),(n=d[r+4])>c&&(c=n),(n=d[r+5])>l&&(l=n),(n=d[r+6])>h&&(h=n);return[{x:s-i,y:a-i,z:u-i},{x:c+i,y:l+i,z:h+i}]},e.prototype.intersectRay=function(e,t,i){for(var n=[this._rootNode],r=[],o=[],s=new dt(1/t.x,1/t.y,1/t.z);n.length>0;){var a=n.pop();if(ft(e,s,a)){a._node0&&n.push(a._node0),a._node1&&n.push(a._node1);for(var u=a._startIndex;u<a._endIndex;u++)r.push(this._bboxArray[7*u])}}var c=new dt,l=new dt,h=new dt,d=new dt(e.x,e.y,e.z),p=new dt(t.x,t.y,t.z);for(u=0;u<r.length;u++){var A=r[u];c.fromArray(this._trianglesArray,9*A),l.fromArray(this._trianglesArray,9*A+3),h.fromArray(this._trianglesArray,9*A+6);var f=At(c,l,h,d,p,i);f&&o.push({triangle:[c.clone(),l.clone(),h.clone()],triangleIndex:A,intersectionPoint:f})}return o},e.prototype.dispose=function(){this._trianglesArray=new Float32Array,this._bboxArray=new Float32Array,this._bboxHelper=new Float32Array,this._rootNode=null,this._nodesToSplit.length=0},e}();var gt,yt=(gt="$$FIVE_EVENT$$","undefined"==typeof Symbol?"$Symbol<"+gt+">$":Symbol(gt));function mt(e){return e[yt]||(e[yt]={}),e[yt]}var vt=function(){function e(){}return e.prototype.hasListener=function(e){var t=mt(this);return t&&t[e]&&t[e].length>0},e.prototype.on=function(e,t,i){var n=this,r=mt(this);return r[e]||(r[e]=[]),r[e].push([t,i||!1]),function(){return n.off(e,t)}},e.prototype.once=function(e,t){return this.on(e,t,!0)},e.prototype.off=function(e,t){if(void 0!==e){var i,n=mt(this);if(n[e]||(n[e]=[]),void 0!==t){for(var r=0;r<n[e].length&&n[e][r][0]!==t;r++);r<n[e].length&&n[e].splice(r,1)}else n[e].length=0}else(i=this)[yt]||delete i[yt]},e.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];for(var n=!1,r=mt(this),o=r[e]||[],s=0,a=o.slice();s<a.length;s++){var u=a[s],c=u[0],l=u[1],h=void 0!==l&&l,d=c.apply(void 0,t);h&&this.off(e,c),!1===d&&(n=!0)}return n},e}();function Nt(e){Object.freeze(e);var t="function"==typeof e,i=Object.prototype.hasOwnProperty;return Object.getOwnPropertyNames(e).forEach((function(n){!i.call(e,n)||t&&("caller"===n||"callee"===n||"arguments"===n)||null===e[n]||"object"!=typeof e[n]&&"function"!=typeof e[n]||Object.isFrozen(e[n])||Nt(e[n])})),e}var Dt=/^([^.]+)(\.([^.]+))*$/;function wt(e){return/^(([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])(\.(?!$)|$)){4}$/.test(e)}function Tt(e,t){return Dt.test(e)&&Dt.test(t)&&function(e,t){if("*"===e)return!0;var i=e.split(".").reverse(),n=t.split(".").reverse();if(i.length<=1)return e===t;for(var r=0;r<i.length;r++)if(i[r]!==n[r])return!1;return!0}(e,t)}var xt=[/\.([0-9a-z]+)\.jsonp([\?\#].*)?$/i,/jsonp_([0-9a-z]+)([\?\#].*)?$/i],Et=Nt(JSON.parse(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=113,n=126,r=0,o="";return arguments[r].split(o).map((function(e){return e.charCodeAt(r)>n?e:String.fromCharCode((e.charCodeAt(r)+i)%n)})).join(o)}("h-/y|pnyu|/9-/xr;p|z/9-/yvn{wvn;p|z/9-/rnyrr;p|z/9-/rnyrr;p{/9-/uv;p|z/9-/uv;p{/9-/ywpq{;p|z/9-/pnyp{|qr;vr/-j"))),jt=function(e){function i(t,i,n){return e.call(this,"[NETWORK]: response error(type: "+i+", reason: "+n+"): "+t)||this}return t.__extends(i,e),i}(Error),zt=function(e){function i(t,i,n){var r=e.call(this,"[NETWORK]: response error(type: "+i+", status: "+n+"): "+t)||this;return r.httpStatus=n,r}return t.__extends(i,e),i}(Error);!function(e){function i(t,i){return e.call(this,"[NETWORK]: request abort(type: "+i+"): "+t)||this}t.__extends(i,e)}(Error);var It=function(e){function i(t,i,n){return e.call(this,"[NETWORK]: request timeout(type: "+i+", timeout: "+n+"ms): "+t)||this}return t.__extends(i,e),i}(Error);function bt(e){for(var t=0,i=xt;t<i.length;t++){var n=i[t],r=e.match(n);if(r)return"jsonp_"+r[1]}return null}function Ot(e){return null!==bt(e)}function St(e){return xt.reduce((function(e,t){return e.replace(t,"")}),e)}function Lt(e){var t=e.match(/^[0-9a-z]+\:\/\/(([^:/?#]*)(?::[0-9]+)?)/);return t?t[2]:location.hostname}!function(e){function i(t,i,n){return e.call(this,"[NETWORK]: request forbidden(type: "+i+", reason: "+n+"): "+t)||this}t.__extends(i,e)}(Error);var kt=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(i,e),i}(vt);function Ct(e,t,i,n,r){return void 0===t&&(t={}),void 0===i&&(i=Qe),void 0===n&&(n=Qe),void 0===r&&(r=Qe),new Promise((function(o,s){var a,u=t.allowHosts?Et.concat(t.allowHosts):Et.slice(),c=Lt(e),l=bt(e);if(0!==location.hostname.length&&!wt(location.hostname)&&0===Et.filter((function(e){return Tt(e,location.hostname)})).length&&!wt(c)&&0===u.filter((function(e){return Tt(e,c)})).length){var h=l?"Script":"XMLHttpRequest",d=new jt(e,h,"request host("+c+") is not allowed");return n(d),s(d),void(null===(a=t.networkSubscribe)||void 0===a||a.emit("network",e,h,"forbidden",d.message))}if(l){var p=window,A=null,f=!1,M=He(),g=document.createElement("script");p[l]=function(r){var o,a,u=He(),c=u-M;if(delete p[l],g.parentNode&&g.parentNode.removeChild(g),null!==A&&(window.clearTimeout(A),A=null),!0!==f){if(0!==r.indexOf("data:")){var h=new zt(e,"Script",500);return n(h),s(h),void(null===(o=t.networkSubscribe)||void 0===o||o.emit("network",e,"Script","error",h.message))}var d=r.split(","),y=(d[0].match(/:(.*?);/)||[])[1],m=d[1];if("arraybuffer"===t.responseType||"blob"===t.responseType){for(var v=atob(d[1]),N=v.length,D=new Uint8Array(N),w=0;w<N;w++)D[w]=v.charCodeAt(w);m="arraybuffer"===t.responseType?D.buffer:new Blob([D],{type:y})}var T={body:m,meta:{source:e,requestTime:M,responseTime:u,costs:c,headers:{}}};i(T),s(T),null===(a=t.networkSubscribe)||void 0===a||a.emit("network",e,"Script","ok",JSON.stringify(T.meta)),f=!0}},g.src=e,document.body.appendChild(g),"number"==typeof t.timeout&&(A=window.setTimeout((function(){var i;if(A=null,!0!==f){f=!0;var r=new It(e,"Script",t.timeout||NaN);n(r),s(r),null===(i=t.networkSubscribe)||void 0===i||i.emit("network",e,"Script","timeout",r.message)}}),t.timeout))}else{var y=He(),m=!1,v=new XMLHttpRequest,N=function(){v&&(v.removeEventListener("timeout",D,!1),v.removeEventListener("progress",w,!1),v.removeEventListener("load",T,!1),v.removeEventListener("error",x,!1)),v=null,N=Qe},D=function(){var i;if(!0!==m){m=!0,N();var r=new It(e,"XMLHttpRequest",t.timeout||NaN);n(r),s(r),null===(i=t.networkSubscribe)||void 0===i||i.emit("network",e,"XMLHttpRequest","timeout",r.message)}},w=function(e){if(!0!==m&&e.lengthComputable){var t=e.loaded,i=e.total;r(t/i)}},T=function(n){var r;if(!0!==m){m=!0,N();var s=He(),a=s-y,u=function(e){if(!e)return{};for(var t={},i=e.trim().split("\n"),n=0;n<i.length;n++){var r=i[n],o=r.indexOf(":"),s=r.slice(0,o).trim().toLowerCase(),a=r.slice(o+1).trim();a&&(t[s]?t[s]+=", "+a:t[s]=a)}return t}(this.getAllResponseHeaders()),c=n.total,l={body:this.response,meta:{source:e,requestTime:y,responseTime:s,costs:a,headers:u,size:c}};i(l),o(l),null===(r=t.networkSubscribe)||void 0===r||r.emit("network",e,"XMLHttpRequest","ok",JSON.stringify(l.meta))}},x=function(){var i;if(!0!==m){m=!0,N();var r=new zt(e,"XMLHttpRequest",this.status);n(r),s(r),null===(i=t.networkSubscribe)||void 0===i||i.emit("network",e,"XMLHttpRequest","error",r.message)}};v.addEventListener("timeout",D,!1),v.addEventListener("progress",w,!1),v.addEventListener("load",T,!1),v.addEventListener("error",x,!1),t.responseType&&(v.responseType=t.responseType),"number"==typeof t.timeout&&(v.timeout=t.timeout),v.open("GET",e,!0),v.send(null)}}))}var Pt={};function Bt(e,t,i,n,r,o){return void 0===t&&(t={}),void 0===i&&(i=Qe),void 0===n&&(n=Qe),void 0===r&&(r=Qe),new Promise((function(s,a){var u,c=t.allowHosts?Et.concat(t.allowHosts):Et.slice(),l=Lt(e);if(0!==location.hostname.length&&!wt(location.hostname)&&0===Et.filter((function(e){return Tt(e,location.hostname)})).length&&!wt(l)&&0===c.filter((function(e){return Tt(e,l)})).length){var h=new jt(e,"Image","request host("+l+") is not allowed");return n(h),a(h),void(null===(u=t.networkSubscribe)||void 0===u||u.emit("network",e,"Image","forbidden",h.message))}var d=null!=o?o:new Image,p=He(),A=!1,f=null,M=function(){var n;if(d.removeEventListener("load",M,!1),d.removeEventListener("error",g,!1),null!==f&&(clearTimeout(f),f=null),!0!==A){var o=He();A=!0;var a={body:d,meta:{headers:{},source:e,requestTime:p,responseTime:o,costs:o-p}};r(1),i(a),s(a),null===(n=t.networkSubscribe)||void 0===n||n.emit("network",e,"Image","ok",JSON.stringify(a.meta))}},g=function(i){var r;if(d.removeEventListener("load",M,!1),d.removeEventListener("error",g,!1),null!==f&&(clearTimeout(f),f=null),!0!==A){A=!0;var o=new zt(e,"Image",0);n(o),a(o),null===(r=t.networkSubscribe)||void 0===r||r.emit("network",e,"Image","ok",o.message)}};"number"==typeof t.timeout&&(f=window.setTimeout((function(){var i;if(d.removeEventListener("load",M,!1),d.removeEventListener("error",g,!1),f=null,!0!==A){A=!0;var r=new It(e,"Image",t.timeout);n(r),a(r),null===(i=t.networkSubscribe)||void 0===i||i.emit("network",e,"Image","timeout",r.message)}}),t.timeout)),d.addEventListener("load",M,!1),d.addEventListener("error",g,!1),r(0),d.src=e}))}var _t=null,Ut=!1,Rt=[];function Qt(e){if(void 0===e&&(e=!1),e||!Ut)if(_t)Ut=!1;else{Ut=!0;var t=Rt.shift();if(t){try{t()}catch(e){}We.shared.add((function(){return Qt(!0)}),!0,2)}else Ut=!1}}function Yt(){_t=null,Qt()}function Ft(e){return new Promise((function(t,i){Rt.push((function(){try{t(e())}catch(e){i(e)}})),Qt()}))}var Vt={OutWindow:function(){this._windowSize=0}};Vt.OutWindow.prototype.create=function(e){this._buffer&&this._windowSize===e||(this._buffer=[]),this._windowSize=e,this._pos=0,this._streamPos=0},Vt.OutWindow.prototype.flush=function(){var e=this._pos-this._streamPos;if(0!==e){for(;e--;)this._stream.writeByte(this._buffer[this._streamPos++]);this._pos>=this._windowSize&&(this._pos=0),this._streamPos=this._pos}},Vt.OutWindow.prototype.releaseStream=function(){this.flush(),this._stream=null},Vt.OutWindow.prototype.setStream=function(e){this.releaseStream(),this._stream=e},Vt.OutWindow.prototype.init=function(e){e||(this._streamPos=0,this._pos=0)},Vt.OutWindow.prototype.copyBlock=function(e,t){var i=this._pos-e-1;for(i<0&&(i+=this._windowSize);t--;)i>=this._windowSize&&(i=0),this._buffer[this._pos++]=this._buffer[i++],this._pos>=this._windowSize&&this.flush()},Vt.OutWindow.prototype.putByte=function(e){this._buffer[this._pos++]=e,this._pos>=this._windowSize&&this.flush()},Vt.OutWindow.prototype.getByte=function(e){var t=this._pos-e-1;return t<0&&(t+=this._windowSize),this._buffer[t]},Vt.RangeDecoder=function(){},Vt.RangeDecoder.prototype.setStream=function(e){this._stream=e},Vt.RangeDecoder.prototype.releaseStream=function(){this._stream=null},Vt.RangeDecoder.prototype.init=function(){var e=5;for(this._code=0,this._range=-1;e--;)this._code=this._code<<8|this._stream.readByte()},Vt.RangeDecoder.prototype.decodeDirectBits=function(e){for(var t,i=0,n=e;n--;)this._range>>>=1,t=this._code-this._range>>>31,this._code-=this._range&t-1,i=i<<1|1-t,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8);return i},Vt.RangeDecoder.prototype.decodeBit=function(e,t){var i=e[t],n=(this._range>>>11)*i;return(2147483648^this._code)<(2147483648^n)?(this._range=n,e[t]+=2048-i>>>5,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8),0):(this._range-=n,this._code-=n,e[t]-=i>>>5,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8),1)},Vt.initBitModels=function(e,t){for(;t--;)e[t]=1024},Vt.BitTreeDecoder=function(e){this._models=[],this._numBitLevels=e},Vt.BitTreeDecoder.prototype.init=function(){Vt.initBitModels(this._models,1<<this._numBitLevels)},Vt.BitTreeDecoder.prototype.decode=function(e){for(var t=1,i=this._numBitLevels;i--;)t=t<<1|e.decodeBit(this._models,t);return t-(1<<this._numBitLevels)},Vt.BitTreeDecoder.prototype.reverseDecode=function(e){for(var t,i=1,n=0,r=0;r<this._numBitLevels;++r)i=i<<1|(t=e.decodeBit(this._models,i)),n|=t<<r;return n},Vt.reverseDecode2=function(e,t,i,n){for(var r,o=1,s=0,a=0;a<n;++a)o=o<<1|(r=i.decodeBit(e,t+o)),s|=r<<a;return s},Vt.LenDecoder=function(){this._choice=[],this._lowCoder=[],this._midCoder=[],this._highCoder=new Vt.BitTreeDecoder(8),this._numPosStates=0},Vt.LenDecoder.prototype.create=function(e){for(;this._numPosStates<e;++this._numPosStates)this._lowCoder[this._numPosStates]=new Vt.BitTreeDecoder(3),this._midCoder[this._numPosStates]=new Vt.BitTreeDecoder(3)},Vt.LenDecoder.prototype.init=function(){var e=this._numPosStates;for(Vt.initBitModels(this._choice,2);e--;)this._lowCoder[e].init(),this._midCoder[e].init();this._highCoder.init()},Vt.LenDecoder.prototype.decode=function(e,t){return 0===e.decodeBit(this._choice,0)?this._lowCoder[t].decode(e):0===e.decodeBit(this._choice,1)?8+this._midCoder[t].decode(e):16+this._highCoder.decode(e)},Vt.Decoder2=function(){this._decoders=[]},Vt.Decoder2.prototype.init=function(){Vt.initBitModels(this._decoders,768)},Vt.Decoder2.prototype.decodeNormal=function(e){var t=1;do{t=t<<1|e.decodeBit(this._decoders,t)}while(t<256);return 255&t},Vt.Decoder2.prototype.decodeWithMatchByte=function(e,t){var i,n,r=1;do{if(i=t>>7&1,t<<=1,r=r<<1|(n=e.decodeBit(this._decoders,(1+i<<8)+r)),i!==n){for(;r<256;)r=r<<1|e.decodeBit(this._decoders,r);break}}while(r<256);return 255&r},Vt.LiteralDecoder=function(){},Vt.LiteralDecoder.prototype.create=function(e,t){var i;if(!this._coders||this._numPrevBits!==t||this._numPosBits!==e)for(this._numPosBits=e,this._posMask=(1<<e)-1,this._numPrevBits=t,this._coders=[],i=1<<this._numPrevBits+this._numPosBits;i--;)this._coders[i]=new Vt.Decoder2},Vt.LiteralDecoder.prototype.init=function(){for(var e=1<<this._numPrevBits+this._numPosBits;e--;)this._coders[e].init()},Vt.LiteralDecoder.prototype.getDecoder=function(e,t){return this._coders[((e&this._posMask)<<this._numPrevBits)+((255&t)>>>8-this._numPrevBits)]},Vt.Decoder=function(){this._outWindow=new Vt.OutWindow,this._rangeDecoder=new Vt.RangeDecoder,this._isMatchDecoders=[],this._isRepDecoders=[],this._isRepG0Decoders=[],this._isRepG1Decoders=[],this._isRepG2Decoders=[],this._isRep0LongDecoders=[],this._posSlotDecoder=[],this._posDecoders=[],this._posAlignDecoder=new Vt.BitTreeDecoder(4),this._lenDecoder=new Vt.LenDecoder,this._repLenDecoder=new Vt.LenDecoder,this._literalDecoder=new Vt.LiteralDecoder,this._dictionarySize=-1,this._dictionarySizeCheck=-1,this._posSlotDecoder[0]=new Vt.BitTreeDecoder(6),this._posSlotDecoder[1]=new Vt.BitTreeDecoder(6),this._posSlotDecoder[2]=new Vt.BitTreeDecoder(6),this._posSlotDecoder[3]=new Vt.BitTreeDecoder(6)},Vt.Decoder.prototype.setDictionarySize=function(e){return!(e<0)&&(this._dictionarySize!==e&&(this._dictionarySize=e,this._dictionarySizeCheck=Math.max(this._dictionarySize,1),this._outWindow.create(Math.max(this._dictionarySizeCheck,4096))),!0)},Vt.Decoder.prototype.setLcLpPb=function(e,t,i){var n=1<<i;return!(e>8||t>4||i>4)&&(this._literalDecoder.create(t,e),this._lenDecoder.create(n),this._repLenDecoder.create(n),this._posStateMask=n-1,!0)},Vt.Decoder.prototype.init=function(){var e=4;for(this._outWindow.init(!1),Vt.initBitModels(this._isMatchDecoders,192),Vt.initBitModels(this._isRep0LongDecoders,192),Vt.initBitModels(this._isRepDecoders,12),Vt.initBitModels(this._isRepG0Decoders,12),Vt.initBitModels(this._isRepG1Decoders,12),Vt.initBitModels(this._isRepG2Decoders,12),Vt.initBitModels(this._posDecoders,114),this._literalDecoder.init();e--;)this._posSlotDecoder[e].init();this._lenDecoder.init(),this._repLenDecoder.init(),this._posAlignDecoder.init(),this._rangeDecoder.init()},Vt.Decoder.prototype.decode=function(e,t,i){var n,r,o,s,a,u,c=0,l=0,h=0,d=0,p=0,A=0,f=0;for(this._rangeDecoder.setStream(e),this._outWindow.setStream(t),this.init();i<0||A<i;)if(n=A&this._posStateMask,0===this._rangeDecoder.decodeBit(this._isMatchDecoders,(c<<4)+n))r=this._literalDecoder.getDecoder(A++,f),f=c>=7?r.decodeWithMatchByte(this._rangeDecoder,this._outWindow.getByte(l)):r.decodeNormal(this._rangeDecoder),this._outWindow.putByte(f),c=c<4?0:c-(c<10?3:6);else{if(1===this._rangeDecoder.decodeBit(this._isRepDecoders,c))o=0,0===this._rangeDecoder.decodeBit(this._isRepG0Decoders,c)?0===this._rangeDecoder.decodeBit(this._isRep0LongDecoders,(c<<4)+n)&&(c=c<7?9:11,o=1):(0===this._rangeDecoder.decodeBit(this._isRepG1Decoders,c)?s=h:(0===this._rangeDecoder.decodeBit(this._isRepG2Decoders,c)?s=d:(s=p,p=d),d=h),h=l,l=s),0===o&&(o=2+this._repLenDecoder.decode(this._rangeDecoder,n),c=c<7?8:11);else if(p=d,d=h,h=l,o=2+this._lenDecoder.decode(this._rangeDecoder,n),c=c<7?7:10,(a=this._posSlotDecoder[o<=5?o-2:3].decode(this._rangeDecoder))>=4){if(l=(2|1&a)<<(u=(a>>1)-1),a<14)l+=Vt.reverseDecode2(this._posDecoders,l-a-1,this._rangeDecoder,u);else if(l+=this._rangeDecoder.decodeDirectBits(u-4)<<4,(l+=this._posAlignDecoder.reverseDecode(this._rangeDecoder))<0){if(-1===l)break;return!1}}else l=a;if(l>=A||l>=this._dictionarySizeCheck)return!1;this._outWindow.copyBlock(l,o),A+=o,f=this._outWindow.getByte(0)}return this._outWindow.flush(),this._outWindow.releaseStream(),this._rangeDecoder.releaseStream(),!0},Vt.Decoder.prototype.setDecoderProperties=function(e){var t,i,n,r,o;return!(e.size<5)&&(i=(t=e.readByte())%9,n=(t=~~(t/9))%5,r=~~(t/5),!!this.setLcLpPb(i,n,r)&&(o=e.readByte(),o|=e.readByte()<<8,o|=e.readByte()<<16,o+=16777216*e.readByte(),this.setDictionarySize(o)))},Vt.decompress=function(e,t,i,n){var r=new Vt.Decoder;if(!r.setDecoderProperties(e))throw"Incorrect stream properties";if(!r.decode(t,i,n))throw"Error in data stream";return!0},Vt.decompressFile=function(e,t){var i,n=new Vt.Decoder;if(!n.setDecoderProperties(e))throw"Incorrect stream properties";if(i=e.readByte(),i|=e.readByte()<<8,i|=e.readByte()<<16,i+=16777216*e.readByte(),e.readByte(),e.readByte(),e.readByte(),e.readByte(),!n.decode(e,t,i))throw"Error in data stream";return!0};var Ht="undefined"!=typeof Worker&&"undefined"!=typeof Blob,Gt="";if(Ht)try{var Wt=new Blob(['\n self.onmessage = function (event) {\n var Packet = event.data;\n var Result = null;\n try {\n if (!Packet.PacketID) {\n throw new Error(\'No incoming id.\');\n }\n if (!Packet.Data) {\n throw new Error(\'No input data.\');\n }\n if (Packet.Type == \'compress\') {\n // C: checking if input is valid\n if (Packet.Data.constructor != Uint8Array) {\n throw new Error(\'Input data is not Uint8Array.\');\n }\n // C: encoding data\n Result = Util.compressFile(Packet.Data, null, Packet.Level, null);\n } else if (Packet.Type == \'decompress\') {\n // C: checking if input is valid\n if (Packet.Data.constructor != Uint8Array) {\n throw new Error(\'Input data is not Uint8Array.\');\n }\n var inStream = {\n data: Packet.Data,\n offset: 0,\n readByte () {\n return this.data[this.offset++];\n }\n };\n var partLength = inStream.data.length;\n var outStream = {\n data: [],\n offset: 0,\n writeByte (value) {\n var partIndex = Math.floor(this.offset / partLength);\n if (!this.data[partIndex]) {\n this.data[partIndex] = new Uint8Array(partLength);\n }\n this.data[partIndex][this.offset % partLength] = value;\n this.offset++;\n }\n }\n // C: decoding data\n\n LZMA.decompressFile(inStream, outStream);\n Result = new Uint8Array(outStream.offset)\n for (var i = 0; i < outStream.offset; i++) {\n Result[i] = outStream.data[Math.floor(i / partLength)][i % partLength];\n }\n }\n postMessage({ PacketID: Packet.PacketID, Result, Error: null }, [Result.buffer]);\n } catch (error) {\n postMessage({ PacketID: Packet.PacketID, Error: error.toString() });\n }\n };\n\n\n /*\n Copyright (c) 2011 Juan Mellado\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the "Software"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n THE SOFTWARE.\n */\n\n /*\n References:\n - "LZMA SDK" by Igor Pavlov\n http://www.7-zip.org/sdk.html\n */\n\n var LZMA = LZMA || {};\n\n LZMA.OutWindow = function(){\n this._windowSize = 0;\n };\n\n LZMA.OutWindow.prototype.create = function(windowSize){\n if ( (!this._buffer) || (this._windowSize !== windowSize) ){\n this._buffer = [];\n }\n this._windowSize = windowSize;\n this._pos = 0;\n this._streamPos = 0;\n };\n\n LZMA.OutWindow.prototype.flush = function(){\n var size = this._pos - this._streamPos;\n if (size !== 0){\n while(size --){\n this._stream.writeByte(this._buffer[this._streamPos ++]);\n }\n if (this._pos >= this._windowSize){\n this._pos = 0;\n }\n this._streamPos = this._pos;\n }\n };\n\n LZMA.OutWindow.prototype.releaseStream = function(){\n this.flush();\n this._stream = null;\n };\n\n LZMA.OutWindow.prototype.setStream = function(stream){\n this.releaseStream();\n this._stream = stream;\n };\n\n LZMA.OutWindow.prototype.init = function(solid){\n if (!solid){\n this._streamPos = 0;\n this._pos = 0;\n }\n };\n\n LZMA.OutWindow.prototype.copyBlock = function(distance, len){\n var pos = this._pos - distance - 1;\n if (pos < 0){\n pos += this._windowSize;\n }\n while(len --){\n if (pos >= this._windowSize){\n pos = 0;\n }\n this._buffer[this._pos ++] = this._buffer[pos ++];\n if (this._pos >= this._windowSize){\n this.flush();\n }\n }\n };\n\n LZMA.OutWindow.prototype.putByte = function(b){\n this._buffer[this._pos ++] = b;\n if (this._pos >= this._windowSize){\n this.flush();\n }\n };\n\n LZMA.OutWindow.prototype.getByte = function(distance){\n var pos = this._pos - distance - 1;\n if (pos < 0){\n pos += this._windowSize;\n }\n return this._buffer[pos];\n };\n\n LZMA.RangeDecoder = function(){\n };\n\n LZMA.RangeDecoder.prototype.setStream = function(stream){\n this._stream = stream;\n };\n\n LZMA.RangeDecoder.prototype.releaseStream = function(){\n this._stream = null;\n };\n\n LZMA.RangeDecoder.prototype.init = function(){\n var i = 5;\n\n this._code = 0;\n this._range = -1;\n\n while(i --){\n this._code = (this._code << 8) | this._stream.readByte();\n }\n };\n\n LZMA.RangeDecoder.prototype.decodeDirectBits = function(numTotalBits){\n var result = 0, i = numTotalBits, t;\n\n while(i --){\n this._range >>>= 1;\n t = (this._code - this._range) >>> 31;\n this._code -= this._range & (t - 1);\n result = (result << 1) | (1 - t);\n\n if ( (this._range & 0xff000000) === 0){\n this._code = (this._code << 8) | this._stream.readByte();\n this._range <<= 8;\n }\n }\n\n return result;\n };\n\n LZMA.RangeDecoder.prototype.decodeBit = function(probs, index){\n var prob = probs[index],\n newBound = (this._range >>> 11) * prob;\n\n if ( (this._code ^ 0x80000000) < (newBound ^ 0x80000000) ){\n this._range = newBound;\n probs[index] += (2048 - prob) >>> 5;\n if ( (this._range & 0xff000000) === 0){\n this._code = (this._code << 8) | this._stream.readByte();\n this._range <<= 8;\n }\n return 0;\n }\n\n this._range -= newBound;\n this._code -= newBound;\n probs[index] -= prob >>> 5;\n if ( (this._range & 0xff000000) === 0){\n this._code = (this._code << 8) | this._stream.readByte();\n this._range <<= 8;\n }\n return 1;\n };\n\n LZMA.initBitModels = function(probs, len){\n while(len --){\n probs[len] = 1024;\n }\n };\n\n LZMA.BitTreeDecoder = function(numBitLevels){\n this._models = [];\n this._numBitLevels = numBitLevels;\n };\n\n LZMA.BitTreeDecoder.prototype.init = function(){\n LZMA.initBitModels(this._models, 1 << this._numBitLevels);\n };\n\n LZMA.BitTreeDecoder.prototype.decode = function(rangeDecoder){\n var m = 1, i = this._numBitLevels;\n\n while(i --){\n m = (m << 1) | rangeDecoder.decodeBit(this._models, m);\n }\n return m - (1 << this._numBitLevels);\n };\n\n LZMA.BitTreeDecoder.prototype.reverseDecode = function(rangeDecoder){\n var m = 1, symbol = 0, i = 0, bit;\n\n for (; i < this._numBitLevels; ++ i){\n bit = rangeDecoder.decodeBit(this._models, m);\n m = (m << 1) | bit;\n symbol |= bit << i;\n }\n return symbol;\n };\n\n LZMA.reverseDecode2 = function(models, startIndex, rangeDecoder, numBitLevels){\n var m = 1, symbol = 0, i = 0, bit;\n\n for (; i < numBitLevels; ++ i){\n bit = rangeDecoder.decodeBit(models, startIndex + m);\n m = (m << 1) | bit;\n symbol |= bit << i;\n }\n return symbol;\n };\n\n LZMA.LenDecoder = function(){\n this._choice = [];\n this._lowCoder = [];\n this._midCoder = [];\n this._highCoder = new LZMA.BitTreeDecoder(8);\n this._numPosStates = 0;\n };\n\n LZMA.LenDecoder.prototype.create = function(numPosStates){\n for (; this._numPosStates < numPosStates; ++ this._numPosStates){\n this._lowCoder[this._numPosStates] = new LZMA.BitTreeDecoder(3);\n this._midCoder[this._numPosStates] = new LZMA.BitTreeDecoder(3);\n }\n };\n\n LZMA.LenDecoder.prototype.init = function(){\n var i = this._numPosStates;\n LZMA.initBitModels(this._choice, 2);\n while(i --){\n this._lowCoder[i].init();\n this._midCoder[i].init();\n }\n this._highCoder.init();\n };\n\n LZMA.LenDecoder.prototype.decode = function(rangeDecoder, posState){\n if (rangeDecoder.decodeBit(this._choice, 0) === 0){\n return this._lowCoder[posState].decode(rangeDecoder);\n }\n if (rangeDecoder.decodeBit(this._choice, 1) === 0){\n return 8 + this._midCoder[posState].decode(rangeDecoder);\n }\n return 16 + this._highCoder.decode(rangeDecoder);\n };\n\n LZMA.Decoder2 = function(){\n this._decoders = [];\n };\n\n LZMA.Decoder2.prototype.init = function(){\n LZMA.initBitModels(this._decoders, 0x300);\n };\n\n LZMA.Decoder2.prototype.decodeNormal = function(rangeDecoder){\n var symbol = 1;\n\n do{\n symbol = (symbol << 1) | rangeDecoder.decodeBit(this._decoders, symbol);\n }while(symbol < 0x100);\n\n return symbol & 0xff;\n };\n\n LZMA.Decoder2.prototype.decodeWithMatchByte = function(rangeDecoder, matchByte){\n var symbol = 1, matchBit, bit;\n\n do{\n matchBit = (matchByte >> 7) & 1;\n matchByte <<= 1;\n bit = rangeDecoder.decodeBit(this._decoders, ( (1 + matchBit) << 8) + symbol);\n symbol = (symbol << 1) | bit;\n if (matchBit !== bit){\n while(symbol < 0x100){\n symbol = (symbol << 1) | rangeDecoder.decodeBit(this._decoders, symbol);\n }\n break;\n }\n }while(symbol < 0x100);\n\n return symbol & 0xff;\n };\n\n LZMA.LiteralDecoder = function(){\n };\n\n LZMA.LiteralDecoder.prototype.create = function(numPosBits, numPrevBits){\n var i;\n\n if (this._coders\n && (this._numPrevBits === numPrevBits)\n && (this._numPosBits === numPosBits) ){\n return;\n }\n this._numPosBits = numPosBits;\n this._posMask = (1 << numPosBits) - 1;\n this._numPrevBits = numPrevBits;\n\n this._coders = [];\n\n i = 1 << (this._numPrevBits + this._numPosBits);\n while(i --){\n this._coders[i] = new LZMA.Decoder2();\n }\n };\n\n LZMA.LiteralDecoder.prototype.init = function(){\n var i = 1 << (this._numPrevBits + this._numPosBits);\n while(i --){\n this._coders[i].init();\n }\n };\n\n LZMA.LiteralDecoder.prototype.getDecoder = function(pos, prevByte){\n return this._coders[( (pos & this._posMask) << this._numPrevBits)\n + ( (prevByte & 0xff) >>> (8 - this._numPrevBits) )];\n };\n\n LZMA.Decoder = function(){\n this._outWindow = new LZMA.OutWindow();\n this._rangeDecoder = new LZMA.RangeDecoder();\n this._isMatchDecoders = [];\n this._isRepDecoders = [];\n this._isRepG0Decoders = [];\n this._isRepG1Decoders = [];\n this._isRepG2Decoders = [];\n this._isRep0LongDecoders = [];\n this._posSlotDecoder = [];\n this._posDecoders = [];\n this._posAlignDecoder = new LZMA.BitTreeDecoder(4);\n this._lenDecoder = new LZMA.LenDecoder();\n this._repLenDecoder = new LZMA.LenDecoder();\n this._literalDecoder = new LZMA.LiteralDecoder();\n this._dictionarySize = -1;\n this._dictionarySizeCheck = -1;\n\n this._posSlotDecoder[0] = new LZMA.BitTreeDecoder(6);\n this._posSlotDecoder[1] = new LZMA.BitTreeDecoder(6);\n this._posSlotDecoder[2] = new LZMA.BitTreeDecoder(6);\n this._posSlotDecoder[3] = new LZMA.BitTreeDecoder(6);\n };\n\n LZMA.Decoder.prototype.setDictionarySize = function(dictionarySize){\n if (dictionarySize < 0){\n return false;\n }\n if (this._dictionarySize !== dictionarySize){\n this._dictionarySize = dictionarySize;\n this._dictionarySizeCheck = Math.max(this._dictionarySize, 1);\n this._outWindow.create( Math.max(this._dictionarySizeCheck, 4096) );\n }\n return true;\n };\n\n LZMA.Decoder.prototype.setLcLpPb = function(lc, lp, pb){\n var numPosStates = 1 << pb;\n\n if (lc > 8 || lp > 4 || pb > 4){\n return false;\n }\n\n this._literalDecoder.create(lp, lc);\n\n this._lenDecoder.create(numPosStates);\n this._repLenDecoder.create(numPosStates);\n this._posStateMask = numPosStates - 1;\n\n return true;\n };\n\n LZMA.Decoder.prototype.init = function(){\n var i = 4;\n\n this._outWindow.init(false);\n\n LZMA.initBitModels(this._isMatchDecoders, 192);\n LZMA.initBitModels(this._isRep0LongDecoders, 192);\n LZMA.initBitModels(this._isRepDecoders, 12);\n LZMA.initBitModels(this._isRepG0Decoders, 12);\n LZMA.initBitModels(this._isRepG1Decoders, 12);\n LZMA.initBitModels(this._isRepG2Decoders, 12);\n LZMA.initBitModels(this._posDecoders, 114);\n\n this._literalDecoder.init();\n\n while(i --){\n this._posSlotDecoder[i].init();\n }\n\n this._lenDecoder.init();\n this._repLenDecoder.init();\n this._posAlignDecoder.init();\n this._rangeDecoder.init();\n };\n\n LZMA.Decoder.prototype.decode = function(inStream, outStream, outSize){\n var state = 0, rep0 = 0, rep1 = 0, rep2 = 0, rep3 = 0, nowPos64 = 0, prevByte = 0,\n posState, decoder2, len, distance, posSlot, numDirectBits;\n\n this._rangeDecoder.setStream(inStream);\n this._outWindow.setStream(outStream);\n\n this.init();\n\n while(outSize < 0 || nowPos64 < outSize){\n posState = nowPos64 & this._posStateMask;\n\n if (this._rangeDecoder.decodeBit(this._isMatchDecoders, (state << 4) + posState) === 0){\n decoder2 = this._literalDecoder.getDecoder(nowPos64 ++, prevByte);\n\n if (state >= 7){\n prevByte = decoder2.decodeWithMatchByte(this._rangeDecoder, this._outWindow.getByte(rep0) );\n }else{\n prevByte = decoder2.decodeNormal(this._rangeDecoder);\n }\n this._outWindow.putByte(prevByte);\n\n state = state < 4? 0: state - (state < 10? 3: 6);\n\n }else{\n\n if (this._rangeDecoder.decodeBit(this._isRepDecoders, state) === 1){\n len = 0;\n if (this._rangeDecoder.decodeBit(this._isRepG0Decoders, state) === 0){\n if (this._rangeDecoder.decodeBit(this._isRep0LongDecoders, (state << 4) + posState) === 0){\n state = state < 7? 9: 11;\n len = 1;\n }\n }else{\n if (this._rangeDecoder.decodeBit(this._isRepG1Decoders, state) === 0){\n distance = rep1;\n }else{\n if (this._rangeDecoder.decodeBit(this._isRepG2Decoders, state) === 0){\n distance = rep2;\n }else{\n distance = rep3;\n rep3 = rep2;\n }\n rep2 = rep1;\n }\n rep1 = rep0;\n rep0 = distance;\n }\n if (len === 0){\n len = 2 + this._repLenDecoder.decode(this._rangeDecoder, posState);\n state = state < 7? 8: 11;\n }\n }else{\n rep3 = rep2;\n rep2 = rep1;\n rep1 = rep0;\n\n len = 2 + this._lenDecoder.decode(this._rangeDecoder, posState);\n state = state < 7? 7: 10;\n\n posSlot = this._posSlotDecoder[len <= 5? len - 2: 3].decode(this._rangeDecoder);\n if (posSlot >= 4){\n\n numDirectBits = (posSlot >> 1) - 1;\n rep0 = (2 | (posSlot & 1) ) << numDirectBits;\n\n if (posSlot < 14){\n rep0 += LZMA.reverseDecode2(this._posDecoders,\n rep0 - posSlot - 1, this._rangeDecoder, numDirectBits);\n }else{\n rep0 += this._rangeDecoder.decodeDirectBits(numDirectBits - 4) << 4;\n rep0 += this._posAlignDecoder.reverseDecode(this._rangeDecoder);\n if (rep0 < 0){\n if (rep0 === -1){\n break;\n }\n return false;\n }\n }\n }else{\n rep0 = posSlot;\n }\n }\n\n if (rep0 >= nowPos64 || rep0 >= this._dictionarySizeCheck){\n return false;\n }\n\n this._outWindow.copyBlock(rep0, len);\n nowPos64 += len;\n prevByte = this._outWindow.getByte(0);\n }\n }\n\n this._outWindow.flush();\n this._outWindow.releaseStream();\n this._rangeDecoder.releaseStream();\n\n return true;\n };\n\n LZMA.Decoder.prototype.setDecoderProperties = function(properties){\n var value, lc, lp, pb, dictionarySize;\n\n if (properties.size < 5){\n return false;\n }\n\n value = properties.readByte();\n lc = value % 9;\n value = ~~(value / 9);\n lp = value % 5;\n pb = ~~(value / 5);\n\n if ( !this.setLcLpPb(lc, lp, pb) ){\n return false;\n }\n\n dictionarySize = properties.readByte();\n dictionarySize |= properties.readByte() << 8;\n dictionarySize |= properties.readByte() << 16;\n dictionarySize += properties.readByte() * 16777216;\n\n return this.setDictionarySize(dictionarySize);\n };\n\n LZMA.decompress = function(properties, inStream, outStream, outSize){\n var decoder = new LZMA.Decoder();\n\n if ( !decoder.setDecoderProperties(properties) ){\n throw "Incorrect stream properties";\n }\n\n if ( !decoder.decode(inStream, outStream, outSize) ){\n throw "Error in data stream";\n }\n\n return true;\n };\n\n LZMA.decompressFile = function(inStream, outStream){\n var decoder = new LZMA.Decoder(), outSize;\n\n if ( !decoder.setDecoderProperties(inStream) ){\n throw "Incorrect stream properties";\n }\n\n outSize = inStream.readByte();\n outSize |= inStream.readByte() << 8;\n outSize |= inStream.readByte() << 16;\n outSize += inStream.readByte() * 16777216;\n\n inStream.readByte();\n inStream.readByte();\n inStream.readByte();\n inStream.readByte();\n\n if ( !decoder.decode(inStream, outStream, outSize) ){\n throw "Error in data stream";\n }\n\n return true;\n };\n'],{type:"text/javascript"});Gt=URL.createObjectURL(Wt)}catch(e){}var qt=function(){function e(){var e=this;if(this.callCounter=0,this.requests=[],!Ht)throw new Error("LZMACaller cannot work in this broswer.");var t=this.worker=new Worker(Gt);t.onmessage=function(t){var i,n,r=t.data,o=r.PacketID,s=r.Result,a=r.Error;a?null===(n=e.requests[o])||void 0===n||n.onCompleteCallback(new Error(a)):null===(i=e.requests[o])||void 0===i||i.onCompleteCallback(null,s),delete e.requests[o]},t.onerror=function(e){return console.error(e)}}return e.prototype.compress=function(e,t,i){var n=++this.callCounter;this.requests[n]={onCompleteCallback:i},this.worker.postMessage({Type:"compress",PacketID:n,Data:e,Level:t},[e.buffer])},e.prototype.decompress=function(e,t){var i=++this.callCounter;this.requests[i]={onCompleteCallback:t},this.worker.postMessage({Type:"decompress",PacketID:i,Data:e},[e.buffer])},e.prototype.terminate=function(){this.worker.terminate()},e.support=Ht,e}();function Kt(e){return Array.prototype.reduce.call(e,(function(e,t,i){return e|t<<8*i}),0)}function Zt(e){for(var t=new Uint8Array(e),i=Kt(t.slice(0,4)),n=[],r=[],o=4+4*i,s=0;s<i;s++)r[s]=Kt(t.slice(4+4*s,8+4*s)),n[s]=s===i-1?t.subarray(o,o+r[s]):t.slice(o,o+r[s]),o+=r[s];return qt.support?function(e){for(var t=[],i=e.length,n=function(i){t.push(new Promise((function(t,n){var r=new qt;r.decompress(e[i],(function(e,i){if(r.terminate(),e)return n(e);t(i)}))})))},r=0;r<i;r++)n(r);return Promise.all(t)}(n):Promise.resolve(function(e){for(var t,i=[],n=e.length,r=function(n){var r={data:e[n],offset:0,readByte:function(){return this.data[this.offset++]}},o=r.data.length,s={data:[],offset:0,writeByte:function(e){var t=Math.floor(this.offset/o);this.data[t]||(this.data[t]=new Uint8Array(o)),this.data[t][this.offset%o]=e,this.offset++}};Vt.decompressFile(r,s),t=new Uint8Array(s.offset);for(var a=0;a<s.offset;a++)t[a]=s.data[Math.floor(a/o)][a%o];i.push(t)},o=0;o<n;o++)r(o);return i}(n))}function Xt(e,t){for(var i={},n=0,r=t;n<r.length;n++){var o=r[n];o in e&&(i[o]=e[o])}return i}var Jt="//vrlab-public.ljcdn.com/",$t="//vrlab-image[1-4].ljcdn.com/";function ei(e,t){var i,n=e.split("?")[0],r=n.split(".").pop();if("jpeg"===r&&(r="jpg"),"png"!==r&&"jpg"!==r)return e;var o="";if(void 0!==t.format&&t.format!==r&&(o+="/format/"+t.format),void 0!==t.cut&&(o+="/cut/"+t.cut[2]+"x"+t.cut[3]+"x"+t.cut[0]+"x"+t.cut[1]),void 0!==t.size&&(o+="/thumbnail/"+t.size+"x"),void 0!==t.quality){var s=null!==(i=t.format)&&void 0!==i?i:r;s&&["jpg","webp","tpg","heif","avif"].indexOf(s)>=0&&(o+="/quality/"+t.quality)}return o.length&&(o="?imageMogr2"+o),n+o}function ti(e,t){return e.indexOf(Jt)>=0?(/\.basis(\?|$)/.test(e)&&!0!==t.basisLoaderInitialized&&(e=e.replace(/\.basis(\?|$)/,".jpg$1")),ei(function(e,t){var i=t.split("."),n=i[0],r=i.slice(1);if("texture"===n)return e.replace(Jt,$t.replace("[1-4]","3"));if("pano"===n||"pano_luminance"===n)switch(r[0],r[1]){case"front":case"left":case"up":return e.replace(Jt,$t.replace("[1-4]","1"));case"down":case"right":case"back":return e.replace(Jt,$t.replace("[1-4]","2"))}else if("pano_tile"===n||"pano_tile_luminance"===n){r[0],r[1];var o=r[2],s=r[3],a=r[4],u=Math.pow(2,Number(o))*Number(s)+Number(a);if(!isNaN(u))return e.replace(Jt,"//vr-tile-[1-2].realsee-cdn.com/".replace("[1-2]",String(u%2+1)))}return e.replace(Jt,$t.replace("[1-4]","3"))}(e,t.key),t)):e.indexOf("//test-vr-public.realsee-cdn.com/")>=0?(/\.basis(\?|$)/.test(e)&&!0!==t.basisLoaderInitialized&&(e=e.replace(/\.basis(\?|$)/,".jpg$1")),ei(e.replace("//test-vr-public.realsee-cdn.com/","//test-vr-image.realsee-cdn.com/"),t)):e}var ii=!1;try{ii="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}var ni=[],ri=[];function oi(){var e=this;/^blob\:/.test(this.src)&&URL.revokeObjectURL(this.src),this.onerror=this.onload=Qe,this.removeAttribute("src"),We.shared.add((function(){ni.push(e)}),!0,1)}function si(){ri.push(this)}function ai(){var e;return null!==(e=ni.shift())&&void 0!==e?e:Object.assign(new Image,{crossOrigin:"",close:oi})}function ui(e){return new Promise((function(t,i){var n=ai(),r=function(){n.removeEventListener("load",r,!1),n.removeEventListener("error",o,!1),t(n)},o=function(){n.removeEventListener("load",r,!1),n.removeEventListener("error",o,!1),i(new Error("image load error: "+n.src)),n.close()};n.addEventListener("load",r,!1),n.addEventListener("error",o,!1),n.src=URL.createObjectURL(e)}))}function ci(e,t){if(t&&(e.width>t.width||e.height>t.height)){var i=function(e,t){var i=ri.shift();if(i)return i.width=e,i.height=t,i;if(ii){var n=new OffscreenCanvas(e,t);return Object.assign(n,{close:si})}return n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),Object.assign(n,{close:si})}(Math.min(e.width,t.width),Math.min(e.height,t.height));i.getContext("2d").drawImage(e,0,0,i.width,i.height),e.close();var n=new r.Texture(i);n.needsUpdate=!0,n.flipY=!0;var o=n.dispose;return n.dispose=function(){i.close(),o.call(n)},n}var s=new r.Texture(e);s.needsUpdate=!0,s.flipY=!0;var a=s.dispose;return s.dispose=function(){e.close(),a.call(s)},s}var li=new r.WebGLRenderTarget(1,1),hi=new r.OrthographicCamera(-1,1,1,-1,0,1),di=new r.BufferGeometry;di.setAttribute("position",new r.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),di.setAttribute("uv",new r.Float32BufferAttribute([0,2,0,0,2,0],2));var pi=new r.Mesh(di),Ai=new r.Scene;Ai.add(pi);var fi,Mi=new r.RawShaderMaterial({uniforms:{map:{value:null}},vertexShader:"\n void main() {\n gl_Position = vec4(0, 0, 0, 0);\n }\n ",fragmentShader:"\n uniform sampler2D map;\n void main() {\n gl_FragColor = textureCube(map, vec3(0, 0));\n }\n "}),gi=new r.RawShaderMaterial({uniforms:{map:{value:null}},vertexShader:"\n void main() {\n gl_Position = vec4(0, 0, 0, 0);\n }\n ",fragmentShader:"\n uniform samplerCube map;\n void main() {\n gl_FragColor = textureCube(map, vec3(0, 0, 0));\n }\n "});function yi(e,t,i){return void 0!==t.flipY&&(e.flipY=t.flipY),void 0!==t.format&&(e.format=t.format),void 0!==t.encoding&&(e.encoding=t.encoding),void 0!==t.minFilter&&(e.minFilter=t.minFilter),void 0!==t.magFilter&&(e.magFilter=t.magFilter),i?new Promise((function(t){We.shared.add((function(){try{var n=i.getRenderTarget();i.setRenderTarget(li),e instanceof r.CubeTexture?(pi.material=gi,gi.uniforms.map.value=e,i.render(Ai,hi),gi.uniforms.map.value=null):(pi.material=Mi,Mi.uniforms.map.value=e,i.render(Ai,hi),gi.uniforms.map.value=null),i.setRenderTarget(n),t(e)}catch(i){t(e)}}),!0,1,1e3)})):Promise.resolve(e)}var mi='\nvar config, transcoderPending, _BasisFile;\nself.onmessage = function(e) {\n var message = e.data;\n switch (message.type) {\n case "init":\n config = message.config;\n init(message.transcoderBinary);\n break;\n case "transcode":\n transcoderPending.then(function() {\n try {\n var result = transcode(message.buffer);\n var width = result.width;\n var height = result.height;\n var hasAlpha = result.hasAlpha;\n var mipmaps = result.mipmaps;\n var format = result.format;\n var buffers = [];\n for (var i = 0; i < mipmaps.length; ++i) {\n buffers.push(mipmaps[i].data.buffer);\n }\n self.postMessage({ type: "transcode", id: message.id, width, height, hasAlpha, mipmaps, format }, buffers);\n } catch (error) {\n console.error(error);\n self.postMessage({ type: "error", id: message.id, error: error.message });\n }\n });\n break;\n default: break;\n }\n};\n\nfunction init(wasmBinary) {\n var BasisModule;\n transcoderPending = new Promise(function(resolve) {\n BasisModule = { wasmBinary, onRuntimeInitialized: resolve };\n BASIS(BasisModule); // eslint-disable-line no-undef\n }).then(function() {\n _BasisFile = BasisModule.BasisFile;\n BasisModule.initializeBasis();\n self.postMessage({ type: "initialized" });\n });\n}\n\nfunction transcode(buffer) {\n var basisFile = new _BasisFile(new Uint8Array(buffer));\n var width = basisFile.getImageWidth(0, 0);\n var height = basisFile.getImageHeight(0, 0);\n var levels = basisFile.getNumLevels(0);\n var hasAlpha = basisFile.getHasAlpha();\n function cleanup() {\n basisFile.close();\n basisFile.delete();\n }\n if (!hasAlpha) {\n switch (config.format) {\n case 9: // Hardcoded: BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGBA\n config.format = 8; // Hardcoded: BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGB;\n break;\n default: break;\n }\n }\n if (!width || !height || !levels) {\n cleanup();\n throw new Error("BasisTextureLoader: Invalid .basis file");\n }\n if (!basisFile.startTranscoding()) {\n cleanup();\n throw new Error("BasisTextureLoader: .startTranscoding failed");\n }\n var mipmaps = [];\n for (var mip = 0; mip < levels; mip++) {\n var mipWidth = basisFile.getImageWidth(0, mip);\n var mipHeight = basisFile.getImageHeight(0, mip);\n var dst = new Uint8Array(basisFile.getImageTranscodedSizeInBytes(0, mip, config.format));\n var status = basisFile.transcodeImage(dst, 0, mip, config.format, 0, hasAlpha);\n if (!status) {\n cleanup();\n throw new Error("BasisTextureLoader: .transcodeImage failed.");\n }\n mipmaps.push({ data: dst, width: mipWidth, height: mipHeight });\n }\n cleanup();\n return { width, height, hasAlpha, mipmaps, format: config.format };\n}\n',vi={cTFETC1:0,cTFETC2:1,cTFBC1:2,cTFBC3:3,cTFBC4:4,cTFBC5:5,cTFBC7_M6_OPAQUE_ONLY:6,cTFBC7_M5:7,cTFPVRTC1_4_RGB:8,cTFPVRTC1_4_RGBA:9,cTFASTC_4x4:10,cTFATC_RGB:11,cTFATC_RGBA_INTERPOLATED_ALPHA:12,cTFRGBA32:13,cTFRGB565:14,cTFBGR565:15,cTFRGBA4444:16},Ni={COMPRESSED_RGB_S3TC_DXT1_EXT:33776,COMPRESSED_RGBA_S3TC_DXT1_EXT:33777,COMPRESSED_RGBA_S3TC_DXT3_EXT:33778,COMPRESSED_RGBA_S3TC_DXT5_EXT:33779},Di=((fi={})[vi.cTFBC1]=Ni.COMPRESSED_RGB_S3TC_DXT1_EXT,fi[vi.cTFBC3]=Ni.COMPRESSED_RGBA_S3TC_DXT5_EXT,fi),wi=function(){function e(){}return e.setTranscoderPath=function(e){return this.transcoderPath=e,this},e.setWorkerLimit=function(e){return this.workerLimit=e,this},e.isInitialized=function(){return 0!==this.workerPool.filter((function(e){return e._initialized})).length},e.detectSupport=function(t){var i=this.workerConfig;if(i.astcSupported=!!t.extensions.get("WEBGL_compressed_texture_astc"),i.bptcSupported=!!t.extensions.get("EXT_texture_compression_bptc"),i.etcSupported=!!t.extensions.get("WEBGL_compressed_texture_etc1"),i.dxtSupported=!!t.extensions.get("WEBGL_compressed_texture_s3tc"),i.pvrtcSupported=!!t.extensions.get("WEBGL_compressed_texture_pvrtc")||!!t.extensions.get("WEBKIT_WEBGL_compressed_texture_pvrtc"),i.astcSupported)i.format=e.BASIS_FORMAT.cTFASTC_4x4;else if(i.bptcSupported)i.format=e.BASIS_FORMAT.cTFBC7_M5;else if(i.dxtSupported)i.format=e.BASIS_FORMAT.cTFBC3;else if(i.pvrtcSupported)i.format=e.BASIS_FORMAT.cTFPVRTC1_4_RGBA;else{if(!i.etcSupported)throw new Error("BasisTextureLoader: No suitable compressed texture format found.");i.format=e.BASIS_FORMAT.cTFETC1}return this},e.createTexture=function(e){var t,i,n=this,o=e.byteLength,s=this._allocateWorker(o).then((function(r){return t=r,i=n.workerNextTaskID++,new Promise((function(n,r){t._callbacks[i]={resolve:n,reject:r},t.postMessage({type:"transcode",id:i,buffer:e},[e])}))})).then((function(e){var t,i=n.workerConfig,o=e.width,s=e.height,a=e.mipmaps;switch(e.format){case vi.cTFASTC_4x4:t=new r.CompressedTexture(a,o,s,r.RGBA_ASTC_4x4_Format);break;case vi.cTFBC1:case vi.cTFBC3:t=new r.CompressedTexture(a,o,s,Di[i.format],r.UnsignedByteType);break;case vi.cTFETC1:t=new r.CompressedTexture(a,o,s,r.RGB_ETC1_Format);break;case vi.cTFPVRTC1_4_RGB:t=new r.CompressedTexture(a,o,s,r.RGB_PVRTC_4BPPV1_Format);break;case vi.cTFPVRTC1_4_RGBA:t=new r.CompressedTexture(a,o,s,r.RGBA_PVRTC_4BPPV1_Format);break;default:throw new Error("BasisTextureLoader: No supported format available.")}return t.minFilter=1===a.length?r.LinearFilter:r.LinearMipmapLinearFilter,t.magFilter=r.LinearFilter,t.generateMipmaps=!1,t.needsUpdate=!0,t}));return s.catch((function(){return!0})).then((function(){t&&i&&(t._taskLoad-=o,delete t._callbacks[i])})),s},e._initTranscoder=function(){var e=this;if(!this.transcoderPending){var t=new r.FileLoader;t.setPath(this.transcoderPath);var i=new Promise((function(e,i){t.load("basis_transcoder.js",e,void 0,i)})),n=new r.FileLoader;n.setPath(this.transcoderPath),n.setResponseType("arraybuffer");var o=new Promise((function(e,t){n.load("basis_transcoder.wasm",e,void 0,t)}));this.transcoderPending=Promise.all([i,o]).then((function(t){var i=t[0],n=t[1],r=["/* basis_transcoder.js */",i,"/* worker */",mi].join("\n");e.workerSourceURL=URL.createObjectURL(new Blob([r])),e.transcoderBinary=n}))}return this.transcoderPending},e._allocateWorker=function(e){var t=this;return this._initTranscoder().then((function(){if(t.workerPool.length<t.workerLimit){var i=function(e){var t=new Worker(e);return Object.assign(t,{_callbacks:{},_initialized:!1,_taskLoad:0})}(t.workerSourceURL);i._callbacks={},i._initialized=!1,i._taskLoad=0,i.postMessage({type:"init",config:t.workerConfig,transcoderBinary:t.transcoderBinary}),i.onmessage=function(e){var t=e.data;switch(t.type){case"initialized":i._initialized=!0,console.log("BasisTextureLoader: basis loader initialized");break;case"transcode":i._callbacks[t.id].resolve(t);break;case"error":i._callbacks[t.id].reject(t);break;default:console.error('BasisTextureLoader: Unexpected message, "'+t.type+'"')}},t.workerPool.push(i)}else t.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));var n=t.workerPool[t.workerPool.length-1];return n._taskLoad+=e,n}))},e.prototype.dispose=function(){for(var t=0;t<e.workerPool.length;t++)e.workerPool[t].terminate();return e.workerPool.length=0,this},e.BASIS_FORMAT=vi,e.DXT_FORMAT=Ni,e.DXT_FORMAT_MAP=Di,e.transcoderPath="https://vrlab-public.ljcdn.com/release/static/image/release/five/basis/",e.transcoderBinary=null,e.transcoderPending=null,e.workerLimit=1,e.workerPool=[],e.workerNextTaskID=1,e.workerSourceURL="",e.workerConfig={format:null,astcSupported:!1,bptcSupported:!1,etcSupported:!1,dxtSupported:!1,pvrtcSupported:!1},e}();function Ti(e){var t=e.match(/^([0-9a-z]+\:)\/\/(([^:/?#]*)(?::[0-9]+)?)/);return t?t[1]:location.protocol}var xi=function(){function e(e){this.timeout=e.timeout,this.allowHosts=e.allowHosts,this.networkSubscribe=e.networkSubscribe}return e.prototype.setAllowHosts=function(e){this.allowHosts=e},e.prototype.setNetworkSubscribe=function(e){this.networkSubscribe=e},e.prototype.load=function(e,i,n,o,s,a){void 0===i&&(i={}),void 0===n&&(n=Qe),void 0===o&&(o=Qe),void 0===s&&(s=Qe);var u=Ti(e),c={timeout:this.timeout,allowHosts:this.allowHosts,networkSubscribe:this.networkSubscribe};if(/^https?:$/.test(u)||Ot(e)){if(/\.basis$/.test(St(e).split("?")[0])){var l=null,h="arraybuffer";return!0===i.flipY?Promise.reject(new Error(".basis cannnot set flipY: true.")):Ct(e,t.__assign(t.__assign({},c),{responseType:h}),void 0,void 0,s).then((function(e){return l=e.meta,wi.createTexture(e.body)})).then((function(e){return yi(e,t.__assign({flipY:!1,encoding:r.sRGBEncoding},Xt(i,["wrapS","wrapT"])),a)})).then((function(e){var t={meta:l,body:e};return n(t),t})).catch((function(e){return o(e),Promise.reject(e)}))}h="blob";return Ct(e,t.__assign(t.__assign({},c),{responseType:h}),void 0,void 0,s).then((function(e){return ui(e.body)})).then((function(e){return ci(e,i.maxSize)})).then((function(e){return yi(e,t.__assign({flipY:!0,encoding:r.sRGBEncoding},i),a)})).then((function(e){var t={meta:null,body:e};return n(t),t})).catch((function(e){return o(e),Promise.reject(e)}))}var d=null,p=ai();return Bt(e,c,void 0,void 0,s,p).then((function(e){return d=e.meta,ci(e.body,i.maxSize)})).then((function(e){return yi(e,t.__assign({flipY:!0,encoding:r.sRGBEncoding},i),a)})).then((function(e){var t={meta:d,body:e};return n(t),t})).catch((function(e){return p.close(),o(e),Promise.reject(e)}))},e.prototype.loadCube=function(e,i,n,o,s,a){void 0===i&&(i={}),void 0===n&&(n=Qe),void 0===o&&(o=Qe),void 0===s&&(s=Qe),Array.isArray(e)||(e=[e.right,e.left,e.up,e.down,e.front,e.back]);for(var u={timeout:this.timeout,allowHosts:this.allowHosts,networkSubscribe:this.networkSubscribe},c=[],l=[0,0,0,0,0,0],h=[],d=function(i){var n=e[i],r=Ti(n),o=function(e){l[i]=e,s(l.reduce((function(e,t){return e+t}),0)/6)};if(/^https?\:$/.test(r)||Ot(n))if(/\.basis$/.test(St(n).split("?")[0])){var a="arraybuffer",d=Ct(n,t.__assign(t.__assign({},u),{responseType:a}),void 0,void 0,o).then((function(e){return h[i]=e.meta,wi.createTexture(e.body)}));c.push(d)}else{a="blob",d=Ct(n,t.__assign(t.__assign({},u),{responseType:a}),void 0,void 0,o).then((function(e){return h[i]=e.meta,"undefined"!=typeof createImageBitmap?createImageBitmap(e.body,{colorSpaceConversion:"none"}):ui(e.body)}));c.push(d)}else{var p=ai();d=Bt(n,u,void 0,void 0,o,p).then((function(e){return h[i]=e.meta,e.body})).catch((function(e){return p.close(),Promise.reject(e)}));c.push(d)}},p=0;p<6;p++)d(p);return Promise.all(c).then((function(e){return e[0]instanceof r.CompressedTexture?function(e){var t=new r.CubeTexture(e);t.needsUpdate=!0;var i=t.dispose;return t.dispose=function(){for(var n=0,r=e;n<r.length;n++)r[n].dispose();i.call(t)},t.isCompressedTexture=!0,t.format=e[0].format,t.minFilter=e[0].minFilter,t.magFilter=e[0].magFilter,t}(e):function(e){var t=new r.CubeTexture(e);t.needsUpdate=!0,t.flipY=!1;var i=t.dispose;return t.dispose=function(){for(var n=0,r=e;n<r.length;n++)r[n].close();i.call(t)},t}(e)})).then((function(e){return e.isCompressedTexture?yi(e,t.__assign({flipY:!1,encoding:r.sRGBEncoding},Xt(i,["wrapS","wrapT"])),a):yi(e,t.__assign({flipY:!1,encoding:r.sRGBEncoding},i),a)})).then((function(e){var t={body:e,meta:h};return n(t),t})).catch((function(e){for(var t=0,i=c;t<i.length;t++){i[t].then((function(e){e instanceof r.Texture?e.dispose():e.close()})).catch(Qe)}return o(e),Promise.reject(e)}))},e}(),Ei={computeTangents:function(e){var t=e.index,i=e.attributes;if(null!==t&&void 0!==i.position&&void 0!==i.normal&&void 0!==i.uv){var n=t.array,o=i.position.array,s=i.normal.array,a=i.uv.array,u=o.length/3;void 0===i.tangent&&e.setAttribute("tangent",new r.BufferAttribute(new Float32Array(4*u),4));for(var c=i.tangent.array,l=[],h=[],d=0;d<u;d++)l[d]=new r.Vector3,h[d]=new r.Vector3;var p=new r.Vector3,A=new r.Vector3,f=new r.Vector3,M=new r.Vector2,g=new r.Vector2,y=new r.Vector2,m=new r.Vector3,v=new r.Vector3,N=e.groups;0===N.length&&(N=[{start:0,count:n.length}]);d=0;for(var D=N.length;d<D;++d)for(var w=L=(S=N[d]).start,T=L+S.count;w<T;w+=3)k(n[w+0],n[w+1],n[w+2]);var x,E,j,z=new r.Vector3,I=new r.Vector3,b=new r.Vector3,O=new r.Vector3;for(d=0,D=N.length;d<D;++d){var S,L;for(w=L=(S=N[d]).start,T=L+S.count;w<T;w+=3)C(n[w+0]),C(n[w+1]),C(n[w+2])}}else console.warn("THREE.BufferGeometry: Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");function k(e,t,i){p.fromArray(o,3*e),A.fromArray(o,3*t),f.fromArray(o,3*i),M.fromArray(a,2*e),g.fromArray(a,2*t),y.fromArray(a,2*i);var n=A.x-p.x,r=f.x-p.x,s=A.y-p.y,u=f.y-p.y,c=A.z-p.z,d=f.z-p.z,N=g.x-M.x,D=y.x-M.x,w=g.y-M.y,T=y.y-M.y,x=1/(N*T-D*w);m.set((T*n-w*r)*x,(T*s-w*u)*x,(T*c-w*d)*x),v.set((N*r-D*n)*x,(N*u-D*s)*x,(N*d-D*c)*x),l[e].add(m),l[t].add(m),l[i].add(m),h[e].add(v),h[t].add(v),h[i].add(v)}function C(e){b.fromArray(s,3*e),O.copy(b),E=l[e],z.copy(E),z.sub(b.multiplyScalar(b.dot(E))).normalize(),I.crossVectors(O,E),j=I.dot(h[e]),x=j<0?-1:1,c[4*e]=z.x,c[4*e+1]=z.y,c[4*e+2]=z.z,c[4*e+3]=x}},mergeBufferGeometries:function(e,t){for(var i=null!==e[0].index,n=new Set(Object.keys(e[0].attributes)),o=new Set(Object.keys(e[0].morphAttributes)),s={},a={},u=new r.BufferGeometry,c=0,l=0;l<e.length;++l){var h=e[l];if(i!==(null!==h.index))return null;for(var d in h.attributes){if(!n.has(d))return null;void 0===s[d]&&(s[d]=[]),s[d].push(h.attributes[d])}for(var d in h.morphAttributes){if(!o.has(d))return null;void 0===a[d]&&(a[d]=[]),a[d].push(h.morphAttributes[d])}if(u.userData.mergedUserData=u.userData.mergedUserData||[],u.userData.mergedUserData.push(h.userData),t){var p;if(i)p=h.index.count;else{if(void 0===h.attributes.position)return null;p=h.attributes.position.count}u.addGroup(c,p,l),c+=p}}if(i){var A=0,f=[];for(l=0;l<e.length;++l){for(var M=e[l].index,g=0;g<M.count;++g)f.push(M.getX(g)+A);A+=e[l].attributes.position.count}u.setIndex(f)}for(var d in s){var y=this.mergeBufferAttributes(s[d]);if(!y)return null;u.setAttribute(d,y)}for(var d in a){var m=a[d][0].length;if(0===m)break;u.morphAttributes=u.morphAttributes||{},u.morphAttributes[d]=[];for(l=0;l<m;++l){var v=[];for(g=0;g<a[d].length;++g)v.push(a[d][g][l]);var N=this.mergeBufferAttributes(v);if(!N)return null;u.morphAttributes[d].push(N)}}return u},mergeBufferAttributes:function(e){for(var t,i,n,o=0,s=0;s<e.length;++s){var a=e[s];if(a.isInterleavedBufferAttribute)return null;if(void 0===t&&(t=a.array.constructor),t!==a.array.constructor)return null;if(void 0===i&&(i=a.itemSize),i!==a.itemSize)return null;if(void 0===n&&(n=a.normalized),n!==a.normalized)return null;o+=a.array.length}var u=new t(o),c=0;for(s=0;s<e.length;++s)u.set(e[s].array,c),c+=e[s].array.length;return new r.BufferAttribute(u,i,n)},interleaveAttributes:function(e){for(var t,i=0,n=0,o=0,s=e.length;o<s;++o){var a=e[o];if(void 0===t&&(t=a.array.constructor),t!==a.array.constructor)return console.warn("AttributeBuffers of different types cannot be interleaved"),null;i+=a.array.length,n+=a.itemSize}var u=new r.InterleavedBuffer(new t(i),n),c=0,l=[],h=["getX","getY","getZ","getW"],d=["setX","setY","setZ","setW"],p=0;for(s=e.length;p<s;p++){var A=(a=e[p]).itemSize,f=a.count,M=new r.InterleavedBufferAttribute(u,A,c,a.normalized);l.push(M),c+=A;for(var g=0;g<f;g++)for(var y=0;y<A;y++)M[d[y]](g,a[h[y]](g))}return l},estimateBytesUsed:function(e){var t=0;for(var i in e.attributes){var n=e.getAttribute(i);t+=n.count*n.itemSize*n.array.BYTES_PER_ELEMENT}var r=e.getIndex();return t+=r?r.count*r.itemSize*r.array.BYTES_PER_ELEMENT:0},mergeVertices:function(e,t){void 0===t&&(t=1e-4),t=Math.max(t,Number.EPSILON);for(var i={},n=e.getIndex(),o=e.getAttribute("position"),s=n?n.count:o.count,a=0,u=Object.keys(e.attributes),c={},l={},h=[],d=["getX","getY","getZ","getW"],p=0,A=u.length;p<A;p++){c[v=u[p]]=[],(T=e.morphAttributes[v])&&(l[v]=new Array(T.length).fill().map((function(){return[]})))}var f=Math.log10(1/t),M=Math.pow(10,f);for(p=0;p<s;p++){var g=n?n.getX(p):p,y="",m=0;for(A=u.length;m<A;m++)for(var v=u[m],N=(w=e.getAttribute(v)).itemSize,D=0;D<N;D++)y+=~~(w[d[D]](g)*M)+",";if(y in i)h.push(i[y]);else{for(m=0,A=u.length;m<A;m++){v=u[m];var w=e.getAttribute(v),T=e.morphAttributes[v],x=(N=w.itemSize,c[v]),E=l[v];for(D=0;D<N;D++){var j=d[D];if(x.push(w[j](g)),T)for(var z=0,I=T.length;z<I;z++)E[z].push(T[z][j](g))}}i[y]=a,h.push(a),a++}}var b=e.clone();for(p=0,A=u.length;p<A;p++){v=u[p];var O=e.getAttribute(v),S=new O.array.constructor(c[v]);w=new r.BufferAttribute(S,O.itemSize,O.normalized);if(b.setAttribute(v,w),v in l)for(m=0;m<l[v].length;m++){var L=e.morphAttributes[v][m],k=(S=new L.array.constructor(l[v][m]),new r.BufferAttribute(S,L.itemSize,L.normalized));b.morphAttributes[v][m]=k}}return b.setIndex(h),b}};const ji=o.Reader,zi=o.Writer,Ii=o.util,bi=o.roots["@REALSEE/FIVE:1"]||(o.roots["@REALSEE/FIVE:1"]={}),Oi=bi.Model=(()=>{function e(e){if(this.chunks=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.chunks=Ii.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=zi.create()),null!=e.chunks&&e.chunks.length)for(let i=0;i<e.chunks.length;++i)bi.Chunk.encode(e.chunks[i],t.uint32(10).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof ji||(e=ji.create(e));let i=void 0===t?e.len:e.pos+t,n=new bi.Model;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:n.chunks&&n.chunks.length||(n.chunks=[]),n.chunks.push(bi.Chunk.decode(e,e.uint32()));break;default:e.skipType(7&t)}}return n},e.decodeDelimited=function(e){return e instanceof ji||(e=new ji(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.chunks&&e.hasOwnProperty("chunks")){if(!Array.isArray(e.chunks))return"chunks: array expected";for(let t=0;t<e.chunks.length;++t){let i=bi.Chunk.verify(e.chunks[t]);if(i)return"chunks."+i}}return null},e.fromObject=function(e){if(e instanceof bi.Model)return e;let t=new bi.Model;if(e.chunks){if(!Array.isArray(e.chunks))throw TypeError(".Model.chunks: array expected");t.chunks=[];for(let i=0;i<e.chunks.length;++i){if("object"!=typeof e.chunks[i])throw TypeError(".Model.chunks: object expected");t.chunks[i]=bi.Chunk.fromObject(e.chunks[i])}}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.chunks=[]),e.chunks&&e.chunks.length){i.chunks=[];for(let n=0;n<e.chunks.length;++n)i.chunks[n]=bi.Chunk.toObject(e.chunks[n],t)}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})();bi.Chunk=(()=>{function e(e){if(e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.vertices=null,e.prototype.faces=null,e.prototype.name="",e.prototype.texture="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=zi.create()),bi.Vertices.encode(e.vertices,t.uint32(10).fork()).ldelim(),bi.Faces.encode(e.faces,t.uint32(18).fork()).ldelim(),t.uint32(26).string(e.name),null!=e.texture&&Object.hasOwnProperty.call(e,"texture")&&t.uint32(34).string(e.texture),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof ji||(e=ji.create(e));let i=void 0===t?e.len:e.pos+t,n=new bi.Chunk;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:n.vertices=bi.Vertices.decode(e,e.uint32());break;case 2:n.faces=bi.Faces.decode(e,e.uint32());break;case 3:n.name=e.string();break;case 4:n.texture=e.string();break;default:e.skipType(7&t)}}if(!n.hasOwnProperty("vertices"))throw Ii.ProtocolError("missing required 'vertices'",{instance:n});if(!n.hasOwnProperty("faces"))throw Ii.ProtocolError("missing required 'faces'",{instance:n});if(!n.hasOwnProperty("name"))throw Ii.ProtocolError("missing required 'name'",{instance:n});return n},e.decodeDelimited=function(e){return e instanceof ji||(e=new ji(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";{let t=bi.Vertices.verify(e.vertices);if(t)return"vertices."+t}{let t=bi.Faces.verify(e.faces);if(t)return"faces."+t}return Ii.isString(e.name)?null!=e.texture&&e.hasOwnProperty("texture")&&!Ii.isString(e.texture)?"texture: string expected":null:"name: string expected"},e.fromObject=function(e){if(e instanceof bi.Chunk)return e;let t=new bi.Chunk;if(null!=e.vertices){if("object"!=typeof e.vertices)throw TypeError(".Chunk.vertices: object expected");t.vertices=bi.Vertices.fromObject(e.vertices)}if(null!=e.faces){if("object"!=typeof e.faces)throw TypeError(".Chunk.faces: object expected");t.faces=bi.Faces.fromObject(e.faces)}return null!=e.name&&(t.name=String(e.name)),null!=e.texture&&(t.texture=String(e.texture)),t},e.toObject=function(e,t){t||(t={});let i={};return t.defaults&&(i.vertices=null,i.faces=null,i.name="",i.texture=""),null!=e.vertices&&e.hasOwnProperty("vertices")&&(i.vertices=bi.Vertices.toObject(e.vertices,t)),null!=e.faces&&e.hasOwnProperty("faces")&&(i.faces=bi.Faces.toObject(e.faces,t)),null!=e.name&&e.hasOwnProperty("name")&&(i.name=e.name),null!=e.texture&&e.hasOwnProperty("texture")&&(i.texture=e.texture),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})(),bi.Vertices=(()=>{function e(e){if(this.xyz=[],this.uvs=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.xyz=Ii.emptyArray,e.prototype.uvs=Ii.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=zi.create()),null!=e.xyz&&e.xyz.length){t.uint32(10).fork();for(let i=0;i<e.xyz.length;++i)t.float(e.xyz[i]);t.ldelim()}if(null!=e.uvs&&e.uvs.length){t.uint32(18).fork();for(let i=0;i<e.uvs.length;++i)t.float(e.uvs[i]);t.ldelim()}return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof ji||(e=ji.create(e));let i=void 0===t?e.len:e.pos+t,n=new bi.Vertices;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:if(n.xyz&&n.xyz.length||(n.xyz=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.xyz.push(e.float())}else n.xyz.push(e.float());break;case 2:if(n.uvs&&n.uvs.length||(n.uvs=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.uvs.push(e.float())}else n.uvs.push(e.float());break;default:e.skipType(7&t)}}return n},e.decodeDelimited=function(e){return e instanceof ji||(e=new ji(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.xyz&&e.hasOwnProperty("xyz")){if(!Array.isArray(e.xyz))return"xyz: array expected";for(let t=0;t<e.xyz.length;++t)if("number"!=typeof e.xyz[t])return"xyz: number[] expected"}if(null!=e.uvs&&e.hasOwnProperty("uvs")){if(!Array.isArray(e.uvs))return"uvs: array expected";for(let t=0;t<e.uvs.length;++t)if("number"!=typeof e.uvs[t])return"uvs: number[] expected"}return null},e.fromObject=function(e){if(e instanceof bi.Vertices)return e;let t=new bi.Vertices;if(e.xyz){if(!Array.isArray(e.xyz))throw TypeError(".Vertices.xyz: array expected");t.xyz=[];for(let i=0;i<e.xyz.length;++i)t.xyz[i]=Number(e.xyz[i])}if(e.uvs){if(!Array.isArray(e.uvs))throw TypeError(".Vertices.uvs: array expected");t.uvs=[];for(let i=0;i<e.uvs.length;++i)t.uvs[i]=Number(e.uvs[i])}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.xyz=[],i.uvs=[]),e.xyz&&e.xyz.length){i.xyz=[];for(let n=0;n<e.xyz.length;++n)i.xyz[n]=t.json&&!isFinite(e.xyz[n])?String(e.xyz[n]):e.xyz[n]}if(e.uvs&&e.uvs.length){i.uvs=[];for(let n=0;n<e.uvs.length;++n)i.uvs[n]=t.json&&!isFinite(e.uvs[n])?String(e.uvs[n]):e.uvs[n]}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})(),bi.Faces=(()=>{function e(e){if(this.indices=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.indices=Ii.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=zi.create()),null!=e.indices&&e.indices.length){t.uint32(10).fork();for(let i=0;i<e.indices.length;++i)t.uint32(e.indices[i]);t.ldelim()}return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof ji||(e=ji.create(e));let i=void 0===t?e.len:e.pos+t,n=new bi.Faces;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:if(n.indices&&n.indices.length||(n.indices=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.indices.push(e.uint32())}else n.indices.push(e.uint32());break;default:e.skipType(7&t)}}return n},e.decodeDelimited=function(e){return e instanceof ji||(e=new ji(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.indices&&e.hasOwnProperty("indices")){if(!Array.isArray(e.indices))return"indices: array expected";for(let t=0;t<e.indices.length;++t)if(!Ii.isInteger(e.indices[t]))return"indices: integer[] expected"}return null},e.fromObject=function(e){if(e instanceof bi.Faces)return e;let t=new bi.Faces;if(e.indices){if(!Array.isArray(e.indices))throw TypeError(".Faces.indices: array expected");t.indices=[];for(let i=0;i<e.indices.length;++i)t.indices[i]=e.indices[i]>>>0}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.indices=[]),e.indices&&e.indices.length){i.indices=[];for(let t=0;t<e.indices.length;++t)i.indices[t]=e.indices[t]}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})();var Si=(new r.Matrix4).set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1);function Li(e){var t=e.match(/(group|floor)-?(\d+)/);return t?parseInt(t[2],10):0}function ki(e){var t=e.match(/(chunk)-?(\d+)/);return t?parseInt(t[2],10):0}function Ci(e){var t=e.indices,i=e.vertices,n=e.uvs,o=new r.BufferGeometry;o.setIndex(new r.BufferAttribute(new Uint32Array(t),1)),o.setAttribute("position",new r.BufferAttribute(new Float32Array(i),3)),o.attributes.position.applyMatrix4(Si),Re(n)||o.setAttribute("uv",new r.BufferAttribute(new Float32Array(n),2));for(var s=new Float32Array(i.length),a=new r.Vector3,u=new r.Vector3,c=new r.Vector3,l=new r.Vector3,h=new r.Vector3,d=new r.Vector3,p=0,A=o.index.array.length,f=void 0,M=void 0,g=void 0;p<A;p+=3)f=3*t[p+0],M=3*t[p+1],g=3*t[p+2],a.x=i[f],a.y=i[f+1],a.z=i[f+2],u.x=i[M],u.y=i[M+1],u.z=i[M+2],c.x=i[g],c.y=i[g+1],c.z=i[g+2],l.x=c.x-u.x,l.y=c.y-u.y,l.z=c.z-u.z,h.x=a.x-u.x,h.y=a.y-u.y,h.z=a.z-u.z,d.x=l.y*h.z-l.z*h.y,d.y=l.z*h.x-l.x*h.z,d.z=l.x*h.y-l.y*h.x,s[f]+=d.x,s[f+1]+=d.y,s[f+2]+=d.z,s[M]+=d.x,s[M+1]+=d.y,s[M+2]+=d.z,s[g]+=d.x,s[g+1]+=d.y,s[g+2]+=d.z;return o.setAttribute("normal",new r.BufferAttribute(s,3)),o}function Pi(e,i,n,o){var s=t.__assign({key:"texture.pbm",basisLoaderInitialized:wi.isInitialized()},Xt(i,["format","quality","size"]));return e=i.transform?i.transform(e,s):ti(e,s),new xi({allowHosts:n,networkSubscribe:o}).load(e,{wrapS:r.ClampToEdgeWrapping,wrapT:r.ClampToEdgeWrapping,minFilter:r.LinearFilter,maxSize:new r.Vector2(1024,1024)}).then((function(e){var t=e.body;return t.needsUpdate=!0,t}))}function Bi(e){var t=new rt;return e.catch((function(){return null})).then((function(e){t.uniforms.map.value=e,t.uniforms.exposure.value=3.3})),t}function _i(e,t,i,n,o,s,a){void 0===o&&(o={});for(var u=0,c=e;u<c.length;u++){var l=c[u];l.chunkName=ki(l.name),l.floorName=Li(l.name),l.texture&&(l.texture=i[l.chunkName]=i[l.chunkName]||t+l.texture)}e.sort((function(e,t){return 1e3*e.floorName+e.chunkName-(1e3*t.floorName+t.chunkName)}));var h=[],d=[],p=Promise.resolve();return(p=(p=p.then((function(){return Ft((function(){for(var t=e.length,i=0;i<t;i++){var u=e[i],c=Li(u.name),l=h[c]=h[c]||{geometries:[],materials:[]},d=Ci({vertices:u.vertices.xyz,uvs:u.vertices.uvs,indices:u.faces.indices});if(d.name="model_geo_chunk_"+i,l.geometries.push(d),u.texture){(p=Bi(u.texture in o?o[u.texture]:o[u.texture]=Pi(u.texture,n,s,a))).name="model_mtl_chunk_"+i,l.materials.push(p)}else{var p;(p=new rt).defines.USE_MAP=!1,p.uniforms.color.value=new r.Color(16777215),p.name="model_mtl_chunk_"+i,l.materials.push(p)}}}))}))).then((function(){return Ft((function(){for(var e=0;e<h.length;e++){var t=h[e];if(t){var i=Ei.mergeBufferGeometries(t.geometries,!0);t.geometries.forEach((function(e){return e.dispose()}));var n=new qe(i,t.materials);n.floorIndex=e,n.name="model_floor_"+e,d.push(n)}}}))}))).then((function(){var e=Object.keys(o).map((function(e){return o[e].catch((function(){}))}));return Promise.all(e).then((function(){return d}))}))}function Ui(e,t){return!1!==(e=Object.assign({},e)).autoResize&&(e.size=t>96?Math.min(e.size||1/0,100):t>48?Math.min(e.size||1/0,200):t>24?Math.min(e.size||1/0,400):t>12?Math.min(e.size||1/0,800):Math.min(e.size||1/0,1024)),e}function Ri(e){return 0===e.indexOf("//")||/^[0-9a-z]+\:\/\//i.test(e)}const Qi=o.Reader,Yi=o.Writer,Fi=o.util,Vi=o.roots["@REALSEE/FIVE:0"]||(o.roots["@REALSEE/FIVE:0"]={}),Hi=Vi.Model=(()=>{function e(e){if(this.meshes=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.meshes=Fi.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=Yi.create()),null!=e.meshes&&e.meshes.length)for(let i=0;i<e.meshes.length;++i)Vi.Mesh.encode(e.meshes[i],t.uint32(10).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof Qi||(e=Qi.create(e));let i=void 0===t?e.len:e.pos+t,n=new Vi.Model;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:n.meshes&&n.meshes.length||(n.meshes=[]),n.meshes.push(Vi.Mesh.decode(e,e.uint32()));break;default:e.skipType(7&t)}}return n},e.decodeDelimited=function(e){return e instanceof Qi||(e=new Qi(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.meshes&&e.hasOwnProperty("meshes")){if(!Array.isArray(e.meshes))return"meshes: array expected";for(let t=0;t<e.meshes.length;++t){let i=Vi.Mesh.verify(e.meshes[t]);if(i)return"meshes."+i}}return null},e.fromObject=function(e){if(e instanceof Vi.Model)return e;let t=new Vi.Model;if(e.meshes){if(!Array.isArray(e.meshes))throw TypeError(".Model.meshes: array expected");t.meshes=[];for(let i=0;i<e.meshes.length;++i){if("object"!=typeof e.meshes[i])throw TypeError(".Model.meshes: object expected");t.meshes[i]=Vi.Mesh.fromObject(e.meshes[i])}}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.meshes=[]),e.meshes&&e.meshes.length){i.meshes=[];for(let n=0;n<e.meshes.length;++n)i.meshes[n]=Vi.Mesh.toObject(e.meshes[n],t)}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})();Vi.Mesh=(()=>{function e(e){if(this.chunks=[],this.matrix=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.name="",e.prototype.chunks=Fi.emptyArray,e.prototype.matrix=Fi.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=Yi.create()),t.uint32(10).string(e.name),null!=e.chunks&&e.chunks.length)for(let i=0;i<e.chunks.length;++i)Vi.Chunk.encode(e.chunks[i],t.uint32(18).fork()).ldelim();if(null!=e.matrix&&e.matrix.length)for(let i=0;i<e.matrix.length;++i)Vi.Matrix.encode(e.matrix[i],t.uint32(26).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof Qi||(e=Qi.create(e));let i=void 0===t?e.len:e.pos+t,n=new Vi.Mesh;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:n.name=e.string();break;case 2:n.chunks&&n.chunks.length||(n.chunks=[]),n.chunks.push(Vi.Chunk.decode(e,e.uint32()));break;case 3:n.matrix&&n.matrix.length||(n.matrix=[]),n.matrix.push(Vi.Matrix.decode(e,e.uint32()));break;default:e.skipType(7&t)}}if(!n.hasOwnProperty("name"))throw Fi.ProtocolError("missing required 'name'",{instance:n});return n},e.decodeDelimited=function(e){return e instanceof Qi||(e=new Qi(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(!Fi.isString(e.name))return"name: string expected";if(null!=e.chunks&&e.hasOwnProperty("chunks")){if(!Array.isArray(e.chunks))return"chunks: array expected";for(let t=0;t<e.chunks.length;++t){let i=Vi.Chunk.verify(e.chunks[t]);if(i)return"chunks."+i}}if(null!=e.matrix&&e.hasOwnProperty("matrix")){if(!Array.isArray(e.matrix))return"matrix: array expected";for(let t=0;t<e.matrix.length;++t){let i=Vi.Matrix.verify(e.matrix[t]);if(i)return"matrix."+i}}return null},e.fromObject=function(e){if(e instanceof Vi.Mesh)return e;let t=new Vi.Mesh;if(null!=e.name&&(t.name=String(e.name)),e.chunks){if(!Array.isArray(e.chunks))throw TypeError(".Mesh.chunks: array expected");t.chunks=[];for(let i=0;i<e.chunks.length;++i){if("object"!=typeof e.chunks[i])throw TypeError(".Mesh.chunks: object expected");t.chunks[i]=Vi.Chunk.fromObject(e.chunks[i])}}if(e.matrix){if(!Array.isArray(e.matrix))throw TypeError(".Mesh.matrix: array expected");t.matrix=[];for(let i=0;i<e.matrix.length;++i){if("object"!=typeof e.matrix[i])throw TypeError(".Mesh.matrix: object expected");t.matrix[i]=Vi.Matrix.fromObject(e.matrix[i])}}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.chunks=[],i.matrix=[]),t.defaults&&(i.name=""),null!=e.name&&e.hasOwnProperty("name")&&(i.name=e.name),e.chunks&&e.chunks.length){i.chunks=[];for(let n=0;n<e.chunks.length;++n)i.chunks[n]=Vi.Chunk.toObject(e.chunks[n],t)}if(e.matrix&&e.matrix.length){i.matrix=[];for(let n=0;n<e.matrix.length;++n)i.matrix[n]=Vi.Matrix.toObject(e.matrix[n],t)}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})(),Vi.Matrix=(()=>{function e(e){if(this.elements=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.elements=Fi.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=Yi.create()),null!=e.elements&&e.elements.length)for(let i=0;i<e.elements.length;++i)t.uint32(13).float(e.elements[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof Qi||(e=Qi.create(e));let i=void 0===t?e.len:e.pos+t,n=new Vi.Matrix;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:if(n.elements&&n.elements.length||(n.elements=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.elements.push(e.float())}else n.elements.push(e.float());break;default:e.skipType(7&t)}}return n},e.decodeDelimited=function(e){return e instanceof Qi||(e=new Qi(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.elements&&e.hasOwnProperty("elements")){if(!Array.isArray(e.elements))return"elements: array expected";for(let t=0;t<e.elements.length;++t)if("number"!=typeof e.elements[t])return"elements: number[] expected"}return null},e.fromObject=function(e){if(e instanceof Vi.Matrix)return e;let t=new Vi.Matrix;if(e.elements){if(!Array.isArray(e.elements))throw TypeError(".Matrix.elements: array expected");t.elements=[];for(let i=0;i<e.elements.length;++i)t.elements[i]=Number(e.elements[i])}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.elements=[]),e.elements&&e.elements.length){i.elements=[];for(let n=0;n<e.elements.length;++n)i.elements[n]=t.json&&!isFinite(e.elements[n])?String(e.elements[n]):e.elements[n]}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})(),Vi.Chunk=(()=>{function e(e){if(this.material=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.geometry=null,e.prototype.material=Fi.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=Yi.create()),Vi.Geometry.encode(e.geometry,t.uint32(18).fork()).ldelim(),null!=e.material&&e.material.length)for(let i=0;i<e.material.length;++i)Vi.Material.encode(e.material[i],t.uint32(26).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof Qi||(e=Qi.create(e));let i=void 0===t?e.len:e.pos+t,n=new Vi.Chunk;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 2:n.geometry=Vi.Geometry.decode(e,e.uint32());break;case 3:n.material&&n.material.length||(n.material=[]),n.material.push(Vi.Material.decode(e,e.uint32()));break;default:e.skipType(7&t)}}if(!n.hasOwnProperty("geometry"))throw Fi.ProtocolError("missing required 'geometry'",{instance:n});return n},e.decodeDelimited=function(e){return e instanceof Qi||(e=new Qi(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";{let t=Vi.Geometry.verify(e.geometry);if(t)return"geometry."+t}if(null!=e.material&&e.hasOwnProperty("material")){if(!Array.isArray(e.material))return"material: array expected";for(let t=0;t<e.material.length;++t){let i=Vi.Material.verify(e.material[t]);if(i)return"material."+i}}return null},e.fromObject=function(e){if(e instanceof Vi.Chunk)return e;let t=new Vi.Chunk;if(null!=e.geometry){if("object"!=typeof e.geometry)throw TypeError(".Chunk.geometry: object expected");t.geometry=Vi.Geometry.fromObject(e.geometry)}if(e.material){if(!Array.isArray(e.material))throw TypeError(".Chunk.material: array expected");t.material=[];for(let i=0;i<e.material.length;++i){if("object"!=typeof e.material[i])throw TypeError(".Chunk.material: object expected");t.material[i]=Vi.Material.fromObject(e.material[i])}}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.material=[]),t.defaults&&(i.geometry=null),null!=e.geometry&&e.hasOwnProperty("geometry")&&(i.geometry=Vi.Geometry.toObject(e.geometry,t)),e.material&&e.material.length){i.material=[];for(let n=0;n<e.material.length;++n)i.material[n]=Vi.Material.toObject(e.material[n],t)}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})(),Vi.Geometry=(()=>{function e(e){if(this.groups=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.position=null,e.prototype.uv=null,e.prototype.uv2=null,e.prototype.normal=null,e.prototype.groups=Fi.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=Yi.create()),Vi.Position.encode(e.position,t.uint32(10).fork()).ldelim(),null!=e.uv&&Object.hasOwnProperty.call(e,"uv")&&Vi.UV.encode(e.uv,t.uint32(18).fork()).ldelim(),null!=e.uv2&&Object.hasOwnProperty.call(e,"uv2")&&Vi.UV.encode(e.uv2,t.uint32(26).fork()).ldelim(),Vi.Normal.encode(e.normal,t.uint32(34).fork()).ldelim(),null!=e.groups&&e.groups.length)for(let i=0;i<e.groups.length;++i)Vi.Group.encode(e.groups[i],t.uint32(42).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof Qi||(e=Qi.create(e));let i=void 0===t?e.len:e.pos+t,n=new Vi.Geometry;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:n.position=Vi.Position.decode(e,e.uint32());break;case 2:n.uv=Vi.UV.decode(e,e.uint32());break;case 3:n.uv2=Vi.UV.decode(e,e.uint32());break;case 4:n.normal=Vi.Normal.decode(e,e.uint32());break;case 5:n.groups&&n.groups.length||(n.groups=[]),n.groups.push(Vi.Group.decode(e,e.uint32()));break;default:e.skipType(7&t)}}if(!n.hasOwnProperty("position"))throw Fi.ProtocolError("missing required 'position'",{instance:n});if(!n.hasOwnProperty("normal"))throw Fi.ProtocolError("missing required 'normal'",{instance:n});return n},e.decodeDelimited=function(e){return e instanceof Qi||(e=new Qi(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";{let t=Vi.Position.verify(e.position);if(t)return"position."+t}if(null!=e.uv&&e.hasOwnProperty("uv")){let t=Vi.UV.verify(e.uv);if(t)return"uv."+t}if(null!=e.uv2&&e.hasOwnProperty("uv2")){let t=Vi.UV.verify(e.uv2);if(t)return"uv2."+t}{let t=Vi.Normal.verify(e.normal);if(t)return"normal."+t}if(null!=e.groups&&e.hasOwnProperty("groups")){if(!Array.isArray(e.groups))return"groups: array expected";for(let t=0;t<e.groups.length;++t){let i=Vi.Group.verify(e.groups[t]);if(i)return"groups."+i}}return null},e.fromObject=function(e){if(e instanceof Vi.Geometry)return e;let t=new Vi.Geometry;if(null!=e.position){if("object"!=typeof e.position)throw TypeError(".Geometry.position: object expected");t.position=Vi.Position.fromObject(e.position)}if(null!=e.uv){if("object"!=typeof e.uv)throw TypeError(".Geometry.uv: object expected");t.uv=Vi.UV.fromObject(e.uv)}if(null!=e.uv2){if("object"!=typeof e.uv2)throw TypeError(".Geometry.uv2: object expected");t.uv2=Vi.UV.fromObject(e.uv2)}if(null!=e.normal){if("object"!=typeof e.normal)throw TypeError(".Geometry.normal: object expected");t.normal=Vi.Normal.fromObject(e.normal)}if(e.groups){if(!Array.isArray(e.groups))throw TypeError(".Geometry.groups: array expected");t.groups=[];for(let i=0;i<e.groups.length;++i){if("object"!=typeof e.groups[i])throw TypeError(".Geometry.groups: object expected");t.groups[i]=Vi.Group.fromObject(e.groups[i])}}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.groups=[]),t.defaults&&(i.position=null,i.uv=null,i.uv2=null,i.normal=null),null!=e.position&&e.hasOwnProperty("position")&&(i.position=Vi.Position.toObject(e.position,t)),null!=e.uv&&e.hasOwnProperty("uv")&&(i.uv=Vi.UV.toObject(e.uv,t)),null!=e.uv2&&e.hasOwnProperty("uv2")&&(i.uv2=Vi.UV.toObject(e.uv2,t)),null!=e.normal&&e.hasOwnProperty("normal")&&(i.normal=Vi.Normal.toObject(e.normal,t)),e.groups&&e.groups.length){i.groups=[];for(let n=0;n<e.groups.length;++n)i.groups[n]=Vi.Group.toObject(e.groups[n],t)}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})(),Vi.Position=(()=>{function e(e){if(this.array=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.array=Fi.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=Yi.create()),null!=e.array&&e.array.length){t.uint32(10).fork();for(let i=0;i<e.array.length;++i)t.float(e.array[i]);t.ldelim()}return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof Qi||(e=Qi.create(e));let i=void 0===t?e.len:e.pos+t,n=new Vi.Position;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:if(n.array&&n.array.length||(n.array=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.array.push(e.float())}else n.array.push(e.float());break;default:e.skipType(7&t)}}return n},e.decodeDelimited=function(e){return e instanceof Qi||(e=new Qi(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.array&&e.hasOwnProperty("array")){if(!Array.isArray(e.array))return"array: array expected";for(let t=0;t<e.array.length;++t)if("number"!=typeof e.array[t])return"array: number[] expected"}return null},e.fromObject=function(e){if(e instanceof Vi.Position)return e;let t=new Vi.Position;if(e.array){if(!Array.isArray(e.array))throw TypeError(".Position.array: array expected");t.array=[];for(let i=0;i<e.array.length;++i)t.array[i]=Number(e.array[i])}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.array=[]),e.array&&e.array.length){i.array=[];for(let n=0;n<e.array.length;++n)i.array[n]=t.json&&!isFinite(e.array[n])?String(e.array[n]):e.array[n]}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})(),Vi.UV=(()=>{function e(e){if(this.array=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.array=Fi.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=Yi.create()),null!=e.array&&e.array.length){t.uint32(10).fork();for(let i=0;i<e.array.length;++i)t.float(e.array[i]);t.ldelim()}return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof Qi||(e=Qi.create(e));let i=void 0===t?e.len:e.pos+t,n=new Vi.UV;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:if(n.array&&n.array.length||(n.array=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.array.push(e.float())}else n.array.push(e.float());break;default:e.skipType(7&t)}}return n},e.decodeDelimited=function(e){return e instanceof Qi||(e=new Qi(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.array&&e.hasOwnProperty("array")){if(!Array.isArray(e.array))return"array: array expected";for(let t=0;t<e.array.length;++t)if("number"!=typeof e.array[t])return"array: number[] expected"}return null},e.fromObject=function(e){if(e instanceof Vi.UV)return e;let t=new Vi.UV;if(e.array){if(!Array.isArray(e.array))throw TypeError(".UV.array: array expected");t.array=[];for(let i=0;i<e.array.length;++i)t.array[i]=Number(e.array[i])}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.array=[]),e.array&&e.array.length){i.array=[];for(let n=0;n<e.array.length;++n)i.array[n]=t.json&&!isFinite(e.array[n])?String(e.array[n]):e.array[n]}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})(),Vi.Normal=(()=>{function e(e){if(this.array=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.array=Fi.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=Yi.create()),null!=e.array&&e.array.length){t.uint32(10).fork();for(let i=0;i<e.array.length;++i)t.float(e.array[i]);t.ldelim()}return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof Qi||(e=Qi.create(e));let i=void 0===t?e.len:e.pos+t,n=new Vi.Normal;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:if(n.array&&n.array.length||(n.array=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.array.push(e.float())}else n.array.push(e.float());break;default:e.skipType(7&t)}}return n},e.decodeDelimited=function(e){return e instanceof Qi||(e=new Qi(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.array&&e.hasOwnProperty("array")){if(!Array.isArray(e.array))return"array: array expected";for(let t=0;t<e.array.length;++t)if("number"!=typeof e.array[t])return"array: number[] expected"}return null},e.fromObject=function(e){if(e instanceof Vi.Normal)return e;let t=new Vi.Normal;if(e.array){if(!Array.isArray(e.array))throw TypeError(".Normal.array: array expected");t.array=[];for(let i=0;i<e.array.length;++i)t.array[i]=Number(e.array[i])}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.array=[]),e.array&&e.array.length){i.array=[];for(let n=0;n<e.array.length;++n)i.array[n]=t.json&&!isFinite(e.array[n])?String(e.array[n]):e.array[n]}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})(),Vi.Group=(()=>{function e(e){if(e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.start=0,e.prototype.count=0,e.prototype.materialIndex=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=Yi.create()),t.uint32(8).uint32(e.start),t.uint32(16).uint32(e.count),t.uint32(24).uint32(e.materialIndex),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof Qi||(e=Qi.create(e));let i=void 0===t?e.len:e.pos+t,n=new Vi.Group;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:n.start=e.uint32();break;case 2:n.count=e.uint32();break;case 3:n.materialIndex=e.uint32();break;default:e.skipType(7&t)}}if(!n.hasOwnProperty("start"))throw Fi.ProtocolError("missing required 'start'",{instance:n});if(!n.hasOwnProperty("count"))throw Fi.ProtocolError("missing required 'count'",{instance:n});if(!n.hasOwnProperty("materialIndex"))throw Fi.ProtocolError("missing required 'materialIndex'",{instance:n});return n},e.decodeDelimited=function(e){return e instanceof Qi||(e=new Qi(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":Fi.isInteger(e.start)?Fi.isInteger(e.count)?Fi.isInteger(e.materialIndex)?null:"materialIndex: integer expected":"count: integer expected":"start: integer expected"},e.fromObject=function(e){if(e instanceof Vi.Group)return e;let t=new Vi.Group;return null!=e.start&&(t.start=e.start>>>0),null!=e.count&&(t.count=e.count>>>0),null!=e.materialIndex&&(t.materialIndex=e.materialIndex>>>0),t},e.toObject=function(e,t){t||(t={});let i={};return t.defaults&&(i.start=0,i.count=0,i.materialIndex=0),null!=e.start&&e.hasOwnProperty("start")&&(i.start=e.start),null!=e.count&&e.hasOwnProperty("count")&&(i.count=e.count),null!=e.materialIndex&&e.hasOwnProperty("materialIndex")&&(i.materialIndex=e.materialIndex),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})(),Vi.Material=(()=>{function e(e){if(e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.kd=null,e.prototype.ks=null,e.prototype.ke=null,e.prototype.mapkd="",e.prototype.mapks="",e.prototype.mapke="",e.prototype.norm="",e.prototype.mapbump="",e.prototype.bump="",e.prototype.mapd="",e.prototype.ns=0,e.prototype.d=0,e.prototype.tr=0,e.prototype.mapkdrepeat="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=Yi.create()),null!=e.kd&&Object.hasOwnProperty.call(e,"kd")&&Vi.Color.encode(e.kd,t.uint32(10).fork()).ldelim(),null!=e.ks&&Object.hasOwnProperty.call(e,"ks")&&Vi.Color.encode(e.ks,t.uint32(18).fork()).ldelim(),null!=e.ke&&Object.hasOwnProperty.call(e,"ke")&&Vi.Color.encode(e.ke,t.uint32(26).fork()).ldelim(),null!=e.mapkd&&Object.hasOwnProperty.call(e,"mapkd")&&t.uint32(34).string(e.mapkd),null!=e.mapks&&Object.hasOwnProperty.call(e,"mapks")&&t.uint32(42).string(e.mapks),null!=e.mapke&&Object.hasOwnProperty.call(e,"mapke")&&t.uint32(50).string(e.mapke),null!=e.norm&&Object.hasOwnProperty.call(e,"norm")&&t.uint32(58).string(e.norm),null!=e.mapbump&&Object.hasOwnProperty.call(e,"mapbump")&&t.uint32(66).string(e.mapbump),null!=e.bump&&Object.hasOwnProperty.call(e,"bump")&&t.uint32(74).string(e.bump),null!=e.mapd&&Object.hasOwnProperty.call(e,"mapd")&&t.uint32(82).string(e.mapd),null!=e.ns&&Object.hasOwnProperty.call(e,"ns")&&t.uint32(93).float(e.ns),null!=e.d&&Object.hasOwnProperty.call(e,"d")&&t.uint32(101).float(e.d),null!=e.tr&&Object.hasOwnProperty.call(e,"tr")&&t.uint32(109).float(e.tr),null!=e.mapkdrepeat&&Object.hasOwnProperty.call(e,"mapkdrepeat")&&t.uint32(114).string(e.mapkdrepeat),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof Qi||(e=Qi.create(e));let i=void 0===t?e.len:e.pos+t,n=new Vi.Material;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:n.kd=Vi.Color.decode(e,e.uint32());break;case 2:n.ks=Vi.Color.decode(e,e.uint32());break;case 3:n.ke=Vi.Color.decode(e,e.uint32());break;case 4:n.mapkd=e.string();break;case 5:n.mapks=e.string();break;case 6:n.mapke=e.string();break;case 7:n.norm=e.string();break;case 8:n.mapbump=e.string();break;case 9:n.bump=e.string();break;case 10:n.mapd=e.string();break;case 11:n.ns=e.float();break;case 12:n.d=e.float();break;case 13:n.tr=e.float();break;case 14:n.mapkdrepeat=e.string();break;default:e.skipType(7&t)}}return n},e.decodeDelimited=function(e){return e instanceof Qi||(e=new Qi(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.kd&&e.hasOwnProperty("kd")){let t=Vi.Color.verify(e.kd);if(t)return"kd."+t}if(null!=e.ks&&e.hasOwnProperty("ks")){let t=Vi.Color.verify(e.ks);if(t)return"ks."+t}if(null!=e.ke&&e.hasOwnProperty("ke")){let t=Vi.Color.verify(e.ke);if(t)return"ke."+t}return null!=e.mapkd&&e.hasOwnProperty("mapkd")&&!Fi.isString(e.mapkd)?"mapkd: string expected":null!=e.mapks&&e.hasOwnProperty("mapks")&&!Fi.isString(e.mapks)?"mapks: string expected":null!=e.mapke&&e.hasOwnProperty("mapke")&&!Fi.isString(e.mapke)?"mapke: string expected":null!=e.norm&&e.hasOwnProperty("norm")&&!Fi.isString(e.norm)?"norm: string expected":null!=e.mapbump&&e.hasOwnProperty("mapbump")&&!Fi.isString(e.mapbump)?"mapbump: string expected":null!=e.bump&&e.hasOwnProperty("bump")&&!Fi.isString(e.bump)?"bump: string expected":null!=e.mapd&&e.hasOwnProperty("mapd")&&!Fi.isString(e.mapd)?"mapd: string expected":null!=e.ns&&e.hasOwnProperty("ns")&&"number"!=typeof e.ns?"ns: number expected":null!=e.d&&e.hasOwnProperty("d")&&"number"!=typeof e.d?"d: number expected":null!=e.tr&&e.hasOwnProperty("tr")&&"number"!=typeof e.tr?"tr: number expected":null!=e.mapkdrepeat&&e.hasOwnProperty("mapkdrepeat")&&!Fi.isString(e.mapkdrepeat)?"mapkdrepeat: string expected":null},e.fromObject=function(e){if(e instanceof Vi.Material)return e;let t=new Vi.Material;if(null!=e.kd){if("object"!=typeof e.kd)throw TypeError(".Material.kd: object expected");t.kd=Vi.Color.fromObject(e.kd)}if(null!=e.ks){if("object"!=typeof e.ks)throw TypeError(".Material.ks: object expected");t.ks=Vi.Color.fromObject(e.ks)}if(null!=e.ke){if("object"!=typeof e.ke)throw TypeError(".Material.ke: object expected");t.ke=Vi.Color.fromObject(e.ke)}return null!=e.mapkd&&(t.mapkd=String(e.mapkd)),null!=e.mapks&&(t.mapks=String(e.mapks)),null!=e.mapke&&(t.mapke=String(e.mapke)),null!=e.norm&&(t.norm=String(e.norm)),null!=e.mapbump&&(t.mapbump=String(e.mapbump)),null!=e.bump&&(t.bump=String(e.bump)),null!=e.mapd&&(t.mapd=String(e.mapd)),null!=e.ns&&(t.ns=Number(e.ns)),null!=e.d&&(t.d=Number(e.d)),null!=e.tr&&(t.tr=Number(e.tr)),null!=e.mapkdrepeat&&(t.mapkdrepeat=String(e.mapkdrepeat)),t},e.toObject=function(e,t){t||(t={});let i={};return t.defaults&&(i.kd=null,i.ks=null,i.ke=null,i.mapkd="",i.mapks="",i.mapke="",i.norm="",i.mapbump="",i.bump="",i.mapd="",i.ns=0,i.d=0,i.tr=0,i.mapkdrepeat=""),null!=e.kd&&e.hasOwnProperty("kd")&&(i.kd=Vi.Color.toObject(e.kd,t)),null!=e.ks&&e.hasOwnProperty("ks")&&(i.ks=Vi.Color.toObject(e.ks,t)),null!=e.ke&&e.hasOwnProperty("ke")&&(i.ke=Vi.Color.toObject(e.ke,t)),null!=e.mapkd&&e.hasOwnProperty("mapkd")&&(i.mapkd=e.mapkd),null!=e.mapks&&e.hasOwnProperty("mapks")&&(i.mapks=e.mapks),null!=e.mapke&&e.hasOwnProperty("mapke")&&(i.mapke=e.mapke),null!=e.norm&&e.hasOwnProperty("norm")&&(i.norm=e.norm),null!=e.mapbump&&e.hasOwnProperty("mapbump")&&(i.mapbump=e.mapbump),null!=e.bump&&e.hasOwnProperty("bump")&&(i.bump=e.bump),null!=e.mapd&&e.hasOwnProperty("mapd")&&(i.mapd=e.mapd),null!=e.ns&&e.hasOwnProperty("ns")&&(i.ns=t.json&&!isFinite(e.ns)?String(e.ns):e.ns),null!=e.d&&e.hasOwnProperty("d")&&(i.d=t.json&&!isFinite(e.d)?String(e.d):e.d),null!=e.tr&&e.hasOwnProperty("tr")&&(i.tr=t.json&&!isFinite(e.tr)?String(e.tr):e.tr),null!=e.mapkdrepeat&&e.hasOwnProperty("mapkdrepeat")&&(i.mapkdrepeat=e.mapkdrepeat),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})(),Vi.Color=(()=>{function e(e){if(this.rgb=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.rgb=Fi.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=Yi.create()),null!=e.rgb&&e.rgb.length)for(let i=0;i<e.rgb.length;++i)t.uint32(13).float(e.rgb[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof Qi||(e=Qi.create(e));let i=void 0===t?e.len:e.pos+t,n=new Vi.Color;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:if(n.rgb&&n.rgb.length||(n.rgb=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.rgb.push(e.float())}else n.rgb.push(e.float());break;default:e.skipType(7&t)}}return n},e.decodeDelimited=function(e){return e instanceof Qi||(e=new Qi(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.rgb&&e.hasOwnProperty("rgb")){if(!Array.isArray(e.rgb))return"rgb: array expected";for(let t=0;t<e.rgb.length;++t)if("number"!=typeof e.rgb[t])return"rgb: number[] expected"}return null},e.fromObject=function(e){if(e instanceof Vi.Color)return e;let t=new Vi.Color;if(e.rgb){if(!Array.isArray(e.rgb))throw TypeError(".Color.rgb: array expected");t.rgb=[];for(let i=0;i<e.rgb.length;++i)t.rgb[i]=Number(e.rgb[i])}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.rgb=[]),e.rgb&&e.rgb.length){i.rgb=[];for(let n=0;n<e.rgb.length;++n)i.rgb[n]=t.json&&!isFinite(e.rgb[n])?String(e.rgb[n]):e.rgb[n]}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})();var Gi={};function Wi(e,i,n,o,s){var a,u=[],c=[];function l(e,a,u){var l=function(e){var t=e.position,i=e.normal,n=e.uv,o=e.uv2,s=e.groups,a=new r.BufferGeometry;return a.setAttribute("position",new r.BufferAttribute(new Float32Array(t.array),3)),i&&a.setAttribute("normal",new r.BufferAttribute(new Float32Array(i.array),3)),n&&a.setAttribute("uv",new r.BufferAttribute(new Float32Array(n.array),2)),o&&a.setAttribute("uv2",new r.BufferAttribute(new Float32Array(o.array),2)),s.forEach((function(e){return a.addGroup(e.start,e.count,e.materialIndex)})),a}(e);l.applyMatrix4(u);var h=new r.Vector3,d=new r.Quaternion,p=new r.Vector3;u.decompose(h,d,p),p.x*p.y*p.z<0&&l.attributes.normal&&l.attributes.position&&l.attributes.uv&&function(e){for(var t=[0,0,0],i=0;i<e.attributes.normal.array.length/9;i++)t[0]=e.attributes.normal.array[9*i],t[1]=e.attributes.normal.array[9*i+1],t[2]=e.attributes.normal.array[9*i+2],e.attributes.normal.array[9*i]=e.attributes.normal.array[9*i+6],e.attributes.normal.array[9*i+1]=e.attributes.normal.array[9*i+7],e.attributes.normal.array[9*i+2]=e.attributes.normal.array[9*i+8],e.attributes.normal.array[9*i+6]=t[0],e.attributes.normal.array[9*i+7]=t[1],e.attributes.normal.array[9*i+8]=t[2];for(i=0;i<e.attributes.position.array.length/9;i++)t[0]=e.attributes.position.array[9*i],t[1]=e.attributes.position.array[9*i+1],t[2]=e.attributes.position.array[9*i+2],e.attributes.position.array[9*i]=e.attributes.position.array[9*i+6],e.attributes.position.array[9*i+1]=e.attributes.position.array[9*i+7],e.attributes.position.array[9*i+2]=e.attributes.position.array[9*i+8],e.attributes.position.array[9*i+6]=t[0],e.attributes.position.array[9*i+7]=t[1],e.attributes.position.array[9*i+8]=t[2];for(i=0;i<e.attributes.uv.array.length/6;i++)t[0]=e.attributes.uv.array[6*i],t[1]=e.attributes.uv.array[6*i+1],e.attributes.uv.array[6*i]=e.attributes.uv.array[6*i+4],e.attributes.uv.array[6*i+1]=e.attributes.uv.array[6*i+5],e.attributes.uv.array[6*i+4]=t[0],e.attributes.uv.array[6*i+5]=t[1];e.attributes.normal.needsUpdate=!0,e.attributes.position.needsUpdate=!0,e.attributes.uv.needsUpdate=!0}(l);var A=a.map((function(e){var a=function(e,i,n,o,s){function a(e,a){if(Gi[e])return Promise.resolve(Gi[e]);var u=new xi({allowHosts:o,networkSubscribe:s});Ri(e)||(e=i+e),-1!==(e=(e=e.replace(/\/\/vrlab-image\d*.ljcdn.com\//,"//vrlab-public.ljcdn.com/")).split("?")[0]).indexOf(".png")&&(e=e.split(".png")[0]+".png"),-1!==e.indexOf(".jpg")&&(e=e.split(".jpg")[0]+".jpg"),0===e.indexOf("//")&&(e="https:"+e);var c=t.__assign({key:"texture.dome",size:64,basisLoaderInitialized:wi.isInitialized()},Xt(n,["quality","format"]));return e=n.transform?n.transform(e,c):ti(e,c),u.load(e,{wrapS:r.RepeatWrapping,wrapT:r.RepeatWrapping}).then((function(t){var i=t.body;return a&&i.repeat.copy(a),i.needsUpdate=!0,i.updateMatrix(),Gi[e]=i,i}))}var u=[],c=new rt,l=c.uniforms;l.exposure.value=4.3;var h,d=c.defines;if(d.USE_MAP=!1,d.USE_UV=!1,e.hasOwnProperty("kd")&&(l.diffuse.value=(new r.Color).fromArray(e.kd.rgb)),e.hasOwnProperty("mapkd")){var p=void 0;if(e.mapkdrepeat){var A=e.mapkdrepeat.split(/\s+/).map((function(e){return Number(e)})),f=A[0],M=A[1];p=new r.Vector2(f,M)}u.push(a(e.mapkd,p).then((function(e){d.USE_MAP=!0,d.USE_UV=!0,l.map.value=e,l.uvTransform.value=e.matrix})).catch((function(e){})))}return e.hasOwnProperty("ks")&&(l.specular.value=(new r.Color).fromArray(e.ks.rgb)),e.hasOwnProperty("mapks")&&u.push(a(e.mapks).then((function(e){l.specularMap.value=e})).catch((function(e){}))),e.hasOwnProperty("ke")&&(l.emissive.value=(new r.Color).fromArray(e.ke.rgb)),e.hasOwnProperty("mapke")&&u.push(a(e.mapke).then((function(e){l.emissiveMap.value=e})).catch((function(e){}))),e.hasOwnProperty("norm")&&u.push(a(e.norm).then((function(e){l.normalMap.value=e})).catch((function(e){}))),e.hasOwnProperty("mapbump")&&u.push(a(e.mapbump).then((function(e){l.bumpMap.value=e})).catch((function(e){}))),e.hasOwnProperty("bump")&&u.push(a(e.bump).then((function(e){l.bumpMap.value=e})).catch((function(e){}))),e.hasOwnProperty("ns")&&(l.shininess.value=e.ns),e.hasOwnProperty("d")&&(h=e.d)>=0&&h<1&&(l.originOpacity.value=h),e.hasOwnProperty("tr")&&(h=1-e.tr)>=0&&h<1&&(l.originOpacity.value=h),l.originOpacity.value<1&&(c.transparent=!0),{material:c,textureReady:Promise.all(u).then((function(){}))}}(e,i,n,o,s),u=a.material,l=a.textureReady;return c.push(l),u}));return new qe(l,A)}return(a=e,Hi.decode(a).meshes).forEach((function(e){var t=e.name,i=e.chunks,n=e.matrix;"Ceiling"!==t&&"CeilingDrop"!==t&&n.map((function(e){var n,o=new r.Matrix4;if(o.elements=e.elements,1===i.length){var s=i[0],a=s.geometry,c=s.material;n=l(a,c,o)}else n=new Ze,i.forEach((function(e,t){var i=l(e.geometry,e.material,o);i.name="chunk"+t,n.add(i)}));n.floorIndex=0,n.name=t,u.push(n)}))})),Promise.all(c).catch((function(){})).then((function(){return u}))}function qi(){Object.keys(Gi).forEach((function(e){Gi[e].dispose(),delete Gi[e]}))}function Ki(e){var i;return new((i=r.Triangle).bind.apply(i,t.__spreadArray([void 0],e.map((function(e){return new r.Vector3(e.x,e.y,e.z)})),!1)))}var Zi={at3d:function(e,t){for(var i=Ui(t.textureOptions,e.textures.length),n={},r=0,o=e.textures;r<o.length;r++){var s=o[r];n[s]=Pi(s,i,t.allowHosts,t.networkSubscribe)}return Promise.resolve().then((function(){return Ct(e.file,{responseType:"arraybuffer",allowHosts:t.allowHosts,networkSubscribe:t.networkSubscribe})})).then((function(e){return Zt(e.body)})).then((function(e){return Ft((function(){for(var t=[],i=0,n=e;i<n.length;i++){var r=n[i];try{var o=Oi.decode(r);t.push.apply(t,o.chunks)}catch(e){console.log(e)}}return t}))})).then((function(r){return Ft((function(){return _i(r,e.textureBase,e.textures.slice(),i,n,t.allowHosts,t.networkSubscribe)}))}))},pbm:function(e,t){for(var i=Ui(t.textureOptions,e.textures.length),n={},r=0,o=e.textures;r<o.length;r++){var s=o[r];n[s]=Pi(s,i,t.allowHosts,t.networkSubscribe)}return Promise.resolve().then((function(){return Ct(e.file,{responseType:"arraybuffer",allowHosts:t.allowHosts,networkSubscribe:t.networkSubscribe})})).then((function(e){return Ft((function(){var t=new Uint8Array(e.body),i=Oi.decode(t);return[].concat(i.chunks)}))})).then((function(r){return Ft((function(){return _i(r,e.textureBase,e.textures.slice(),i,n,t.allowHosts,t.networkSubscribe)}))}))},dome:function(e,t){return Promise.resolve().then((function(){return qi()})).then((function(){return Ct(e.file,{responseType:"arraybuffer",allowHosts:t.allowHosts,networkSubscribe:t.networkSubscribe})})).then((function(i){return Wi(new Uint8Array(i.body),e.textureBase,t.textureOptions,t.allowHosts,t.networkSubscribe)}))},domez:function(e,t){return Promise.resolve().then((function(){return qi()})).then((function(){return Ct(e.file,{responseType:"arraybuffer",allowHosts:t.allowHosts,networkSubscribe:t.networkSubscribe})})).then((function(e){return Zt(e.body)})).then((function(e){var t=e.reduce((function(e,t){return e+t.length}),0),i=new Uint8Array(t),n=0;return e.forEach((function(e){i.set(e,n),n+=e.length})),i})).then((function(i){return Wi(i,e.textureBase,t.textureOptions,t.allowHosts,t.networkSubscribe)}))}},Xi=function(e){function i(t){void 0===t&&(t={});var i=e.call(this)||this;return i.empty=!1,i.name="model",i.loaded=!1,i.bvhs=Object.assign([],{loaded:!1}),i.bounding=new r.Box3,i.shownFloor=null,i.floorLength=0,i.networkSubscribe=t.networkSubscribe,i.allowHosts=t.allowHosts,i.renderOrder=-2,i}return t.__extends(i,e),Object.defineProperty(i.prototype,"shownfloor",{get:function(){return this.shownFloor},enumerable:!1,configurable:!0}),i.prototype.getEdges=function(e){var t;void 0===e&&(e=30/180*Math.PI);for(var i=Math.cos(e),n=[],o=0,s=this.children;o<s.length;o++){var a=s[o];if(a instanceof qe){for(var u={},c=["a","b","c"],l=Ei.mergeVertices(a.geometry),h=l.getAttribute("position").array,d=(null===(t=l.getIndex())||void 0===t?void 0:t.array)||[],p=[],A=[],f=0,M=h.length;f<M;f+=3)p.push(new r.Vector3(h[f],h[f+1],h[f+2]));for(f=0,M=d.length;f<M;f+=3){var g=d[f],y=d[f+1],m=d[f+2],v=(new r.Vector3).crossVectors(p[y].clone().sub(p[g]),p[m].clone().sub(p[g])).normalize();A.push({a:g,b:y,c:m,normal:v})}for(f=0,M=A.length;f<M;f++)for(var N=A[f],D=0;D<3;D++){var w=N[c[D]],T=N[c[(D+1)%3]],x=[Math.min(w,T),Math.max(w,T)];void 0===u[E=x[0]+"-"+x[1]]?u[E]={index1:x[0],index2:x[1],face1:f}:u[E].face2=f}for(var E in u){var j=u[E];if(void 0===j.face2||A[j.face1].normal.dot(A[j.face2].normal)<=i){var z=p[j.index1],I=p[j.index2];n.push(new r.Line3(z,I))}}l.dispose(),p.length=0,A.length=0}}return n},i.prototype.hasFloors=function(){return this.hasFloors_()},i.prototype.hasFloors_=function(){var e=[];return this.traverse((function(t){t instanceof qe&&(e[t.floorIndex]=!0)})),e.length},i.prototype.show=function(){for(var e,t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];var n=this.shownFloor,r=null,o=null!==(e=t[1])&&void 0!==e?e:.1,s=0!==t.length;this.shownFloor=r=s?t[0]:null,this.traverse((function(e){e instanceof qe&&e.material.forEach((function(t){null===r||r===e.floorIndex?t.opacity=1:t.opacity=o}))})),n!==this.shownFloor&&this.emit("shownFloorChange",this.shownFloor,this.floorLength),this.needsRender=!0},i.prototype.intersectRaycaster=function(e,t){var i=e.ray,n=i.origin,o=i.direction;if(Re(t))if(Re(this.shownFloor)){var s=this.floorLength;t=[];for(var a=0;a<s;a++)t.push(a)}else t=[this.shownFloor];var u=[],c=[];Array.isArray(t)?c.push.apply(c,t):c.push(t);for(var l=function(t){var i=h.bvhs&&h.bvhs[t];if(i){var s=new dt(n.x,n.y,n.z),a=new dt(o.x,o.y,o.z);(c=i.intersectRay(s,a,!0).map((function(e){var t=e.intersectionPoint,i=e.triangle,o=new r.Vector3(t.x,t.y,t.z);return{point:o,face:{normal:Ki(i).getNormal(new r.Vector3)},distance:n.distanceTo(o)}}))).length&&u.push.apply(u,c)}else{var c,l=[];h.traverse((function(e){e instanceof qe&&e.floorIndex===t&&l.push(e)})),(c=e.intersectObjects(l).map((function(e){var t=e.face?{normal:e.face.normal}:void 0;return{point:e.point,face:t,distance:e.distance}}))).length&&u.push.apply(u,c)}},h=this,d=0,p=c;d<p.length;d++){l(p[d])}return u.filter((function(t){var i=t.distance;return i<=e.far&&i>=e.near})).sort((function(e,t){return e.distance-t.distance}))},i.prototype.buildBVH=function(){var e,t=[];this.traverse((function(e){e instanceof qe&&(t[e.floorIndex]=t[e.floorIndex]||[],t[e.floorIndex].push(e.geometry))}));var i=t.map((function(e){var t=e.reduce((function(e,t){return e+(t.index?t.index.array.length:t.attributes.position.array.length)}),0),i=new Float32Array(3*t);return e.reduce((function(e,t){for(var n=t.index?t.index.array:null,r=t.attributes.position.array,o=n?n.length:r.length/3,s=0;s<o;s++){var a=3*(e+s),u=n?3*n[s]:3*s;i[a+0]=r[u+0],i[a+1]=r[u+1],i[a+2]=r[u+2]}return e+o}),0),new Mt(i,10)}));this.bvhs.length=0,(e=this.bvhs).push.apply(e,i),this.bvhs.loaded=!0,this.emit("bvhLoaded")},i.prototype.load=function(e,t){var i=this;if(void 0===t&&(t={}),!0===this.loaded)throw new Error("[MODEL LOAD ERROR]: model cannot load twice.");var n=function(e,t){void 0===t&&(t=[]);var i=/([0-9a-z\.\_\-]+)([\?\#].*)?$/i.exec(e);if(!i)return"";for(var n=0,r=String(i[1]).trim().split(".").slice(1).reverse();n<r.length;n++){var o=r[n],s=t.indexOf(o);if(s>=0)return t[s]}return""}(e.file,Object.keys(Zi)),o=Zi[n];if(!o)throw new Error("[MODEL LOAD ERROR]: file type("+n+") does not support.");return o(e,{textureOptions:t,allowHosts:this.allowHosts,networkSubscribe:this.networkSubscribe}).then((function(e){for(var t=[],n=0,o=e;n<o.length;n++){(c=o[n]).traverse((function(e){e instanceof qe&&(e.geometry.computeBoundingBox(),e.geometry.computeBoundingSphere(),t.push(e.geometry.boundingBox))})),i.add(c)}i.floorLength=i.hasFloors_(),i.bounding=function(e){for(var t=new r.Box3,i=0,n=e;i<n.length;i++){var o=n[i];t.union(o)}return t}(t);for(var s=i.bounding.getCenter(new r.Vector3),a=0,u=e;a<u.length;a++){var c;(c=u[a]).traverse((function(e){e instanceof qe&&e.material.forEach((function(e){e.uniforms.modelCenter.value=s}))}))}t.length=0,i.emit("geometryLoaded"),i.emit("materialLoaded"),i.loaded=!0,We.shared.add((function(){return i.emit("loaded")}),!0)})).catch((function(e){return i.emit("error",e),Promise.reject(e)}))},i.prototype.dispose=function(){for(this.off(),this.disposeGeometry(),this.disposeMaterial();this.children.length;)this.remove(this.children[0]);this.bvhs.length=0,this.bvhs.loaded=!1},i}(Ke);function Ji(e){switch(e.getError()){case e.INVALID_ENUM:return new Error("webgl error: INVALID_ENUM");case e.INVALID_VALUE:return new Error("webgl error: INVALID_VALUE");case e.INVALID_OPERATION:return new Error("webgl error: INVALID_OPERATION");case e.INVALID_FRAMEBUFFER_OPERATION:return new Error("webgl error: INVALID_FRAMEBUFFER_OPERATION");case e.OUT_OF_MEMORY:return new Error("webgl error: OUT_OF_MEMORY");case e.CONTEXT_LOST_WEBGL:return new Error("webgl error: CONTEXT_LOST_WEBGL");default:return null}}Object.assign(Xi.prototype,{on:vt.prototype.on,once:vt.prototype.once,off:vt.prototype.off,emit:vt.prototype.emit,hasListener:vt.prototype.hasListener});var $i=2*Math.PI;function en(e){return(e%$i+$i)%$i}var tn=Math.PI,nn=2*tn;function rn(e,t,i){if(e===t)return t;var n=t-e;return Math.abs(n)<=i?t:e+(n>0?1:-1)*i}var on=function(){function e(){this.name="",this.workCode="",this.expire=new Date,this.allowHosts=[],this.initial={mode:"Panorama",latitude:0,longitude:0,panoIndex:0,fov:80},this.observers=[],this.issuer="none",this.raw={work:null,option:{}}}return e.prototype.toJSON=function(){return this.raw.work},e}();function sn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=[];e=e.map((function(e){return e.trim()})).filter((function(e){return e.length>0&&!/^\/+$/.test(e)}));for(var n=0;n<e.length;n++){var r=0===n,o=n===e.length-1,s=e[n];r||(s=s.replace(/^\/+/,"")),o||(s=s.replace(/\/+$/,"")),i.push(s)}return i.join("/")}function an(e){return e instanceof Error}function un(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var i,n,r;if(Array.isArray(e)){if((i=e.length)!=t.length)return!1;for(n=i;0!=n--;)if(!un(e[n],t[n]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if((i=(r=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(n=i;0!=n--;)if(!Object.prototype.hasOwnProperty.call(t,r[n]))return!1;for(n=i;0!=n--;){var o=r[n];if(!un(e[o],t[o]))return!1}return!0}return e!=e&&t!=t}function cn(e){return"number"==typeof e}function ln(e){return 0==(e&e-1)&&0!==e}function hn(e,t){void 0===t&&(t=!1);var i=typeof e;if("string"===i)return JSON.stringify(e);if(!0===e)return"true";if(!1===e)return"false";if(null===e)return"null";if(e instanceof Array){for(var n="[",r=e.length-1,o=0;o<r;o++)n+=hn(e[o],!1)+",";return r>-1&&(n+=hn(e[o],!1)),n+"]"}if(e instanceof Object){if("function"==typeof e.toJSON)return hn(e.toJSON(),t);var s=Object.keys(e).sort(),a=s.length;for(n="",o=0;o<a;){var u=s[o],c=hn(e[u],!0);void 0!==c&&(o&&""!==n&&(n+=","),n+=JSON.stringify(u)+":"+c),o++}return"{"+n+"}"}switch(i){case"function":case"undefined":return t?void 0:null;case"number":return 0;default:return isFinite(e)?e:null}}function dn(e){return String(hn(e,!1))}function pn(e){var t,i,n,r=JSON.parse(e),o="undefined"!=typeof location?location.hostname:"",s=Date.now();if("object"!=typeof r)return new Error("input is not an object");if(0===o.length||wt(o)||Et.filter((function(e){return Tt(e,o)})).length>0){var a=String(null!==(t=r.certificate)&&void 0!==t?t:"");if(a){var u=new ze;return u.readCertPEM(a),{issuer:u.getSubjectString()}}return{issuer:"none"}}var c=String(null!==(i=r.certificate)&&void 0!==i?i:"");if(!c)return new Error("certificate is not existed.");var l=new ze;l.readCertPEM(c);var h=String(null!==(n=r._signature)&&void 0!==n?n:"");if(!h)return new Error("signature is not existed.");if(!1===function(e,t,i){var n=new ze;if("string"==typeof i?n.readCertPEM(i):n.readCertHex(i.hex),!1===Le(n))return!1;var r=new K;return r.readCertPubKeyHex(n.hex,6),!!r.verify(e,C(t))}(dn(function(e,t){for(var i={},n=0,r=Object.keys(e);n<r.length;n++){var o=r[n];-1===t.indexOf(o)&&(i[o]=e[o])}return i}(r,["_signature"])),h,l))return new Error("signature verify failed.");var d=new Date("string"==typeof r.expire_at&&/^\d+$/.test(r.expire_at)?Number(r.expire_at):r.expire_at);return s<d.getTime()?0===(Array.isArray(r.allow_hosts)?r.allow_hosts:[]).filter((function(e){return Tt(e,o)})).length?function(e){return new Error("host("+JSON.stringify(e)+") is not allowed.")}(o):{issuer:l.getSubjectString()}:function(e){return new Error("date("+e.toString()+") expired.")}(d)}var An=new WeakMap;function fn(e,t,i){var n,o=JSON.stringify(t),s=JSON.stringify(e),a=pn(s);e=JSON.parse(s),t=JSON.parse(o);var u=new on;u.issuer=a instanceof Error?"none":a.issuer,u.raw={work:e,options:t};var c=null!==(n=e.base_url)&&void 0!==n?n:"";c&&"/"!==c[c.length-1]&&(c+="/");var l=function(e,n){var r,o=e;!0===t.jsonp&&(o=(o=e.replace(/([\?\#].*)?$/i,""))+"."+Ie(""+o).slice(0,7)+".jsonp");if(!0===t.shortPath){var s=o.replace(c,"").split("."),a=null!==(r=s.shift())&&void 0!==r?r:"",u=s.join(".");o=sn(c,Ie(a))+(u?"."+u:"")}var l=o.replace(c,"");return t.baseURL&&(o=sn(t.baseURL,l)),i&&i(e,o,l,n),o},h=function(t,i){var n,r,o,s,a,u,h=t;if(!Ri(t)){var d=null!==(u=null!==(s=null!==(r=null===(n=e.panorama)||void 0===n?void 0:n.pano_high_cube_base_url)&&void 0!==r?r:null===(o=e.panorama)||void 0===o?void 0:o.pano_cube_base_url)&&void 0!==s?s:null===(a=e.panorama)||void 0===a?void 0:a.base_url)&&void 0!==u?u:"";d&&(d=sn(d,String(i))),h=sn(d,h)}return Ri(h)||(h=sn(c,h)),l(h,"panorama")},d=function(e){var t=e;return Ri(t)||(t=sn(c,e)),l(t,"model")},p=function(e,t){void 0===t&&(t="");var i=e;return Ri(i)||(i=sn(t,i)),Ri(i)||(i=sn(c,i)),l(i,"texture")};if(u.workCode=String(e.work_code||e.code||e.vr_code||e.workCode),u.name=String(e.name),u.expire=new Date("string"==typeof e.expire_at&&/^\d+$/.test(e.expire_at)?Number(e.expire_at):e.expire_at),u.allowHosts=e.allow_hosts||[],an(a))return a;if(e.initial&&("Floorplan"!==e.initial.mode&&"Topview"!==e.initial.mode&&"Panorama"!==e.initial.mode&&"VRPanorama"!==e.initial.mode&&"Model"!==e.initial.mode&&"DepthPanorama"!==e.initial.mode||(u.initial.mode=e.initial.mode),cn(e.initial.latitude)&&(u.initial.latitude=e.initial.latitude),cn(e.initial.longitude)?u.initial.longitude=e.initial.longitude:cn(e.initial.heading)&&(u.initial.longitude=-(360*(e.initial.heading-.25)+90)/180*Math.PI),cn(e.initial.fov)&&(u.initial.fov=e.initial.fov),cn(e.initial.panoIndex)?u.initial.panoIndex=e.initial.panoIndex:cn(e.initial.pano_index)?u.initial.panoIndex=e.initial.pano_index:cn(e.initial.pano)&&(u.initial.panoIndex=e.initial.pano)),an(a))return a;if(e.model){var A={bvh:!0,async:!1,textureBase:"",textures:[]};"boolean"==typeof t.modelBvh?A.bvh=t.modelBvh:"boolean"==typeof e.model.bvh?A.bvh=e.model.bvh:"boolean"==typeof e.bvh&&(A.bvh=e.bvh),t.modelAsync,A.async=t.modelAsync,e.model.file?A.file=d(e.model.file):e.model.file_url&&(A.file=d(e.model.file_url)),e.model.textureBase?A.textureBase=e.model.textureBase:e.model.material_base_url&&(A.textureBase=e.model.material_base_url),Array.isArray(e.model.textures)?A.textures=e.model.textures.map((function(e){return p(e,A.textureBase)})):Array.isArray(e.model.material_textures)&&(A.textures=e.model.material_textures.map((function(e){return p(e,A.textureBase)}))),A.file&&(u.model=A)}if(an(a))return a;if(e.observers&&Array.isArray(e.observers)){var f=[];e.panorama&&(Array.isArray(e.panorama)?f=e.panorama:Array.isArray(e.panorama.list)?f=e.panorama.list:Array.isArray(e.panorama.info)&&(f=e.panorama.info));for(var M=0;M<e.observers.length;M++){var g={},y=e.observers[M];if(!y)break;var m=f[M]||{};y=Object.assign({},y,m,{active:!1!==y.active&&!1!==m.active}),g.panoIndex=M,g.active=!1!==y.active,g.loadable=!0===y.loadable,g.images={up:h(y.images?y.images.up:y.up,M),down:h(y.images?y.images.down:y.down,M),right:h(y.images?y.images.right:y.right,M),left:h(y.images?y.images.left:y.left,M),front:h(y.images?y.images.front:y.front,M),back:h(y.images?y.images.back:y.back,M)};var v=y.images?y.images.depth:y.depth;v&&(g.images.depth=h(v,M));var N=y.images?y.images.luminance:y.luminance;N&&(g.images.luminance={up:h(N.up,M),down:h(N.down,M),right:h(N.right,M),left:h(N.left,M),front:h(N.front,M),back:h(N.back,M)});var D=y.images?y.images.tiles:y.tiles;if(D){for(var w=[],T=function(e){var t=e.match(/\/cube_(\d+)\//);if(t){var i=Number(t[1]);if(ln(i))return i}return!1},x=function(e,t){return e.replace(/\/cube_(\d+)\//,(function(){return"/cube_"+t+"/"}))},E=0,j=D;E<j.length;E++){var z=j[E];if("number"==typeof z){var I=z,b=T(g.images.front);if(!1===b)continue;if((B=Math.max(b,512*Math.pow(2,I)))>2048){var O=x(g.images.up,B),S=x(g.images.down,B),L=x(g.images.right,B),k=x(g.images.left,B),C=x(g.images.front,B),P=x(g.images.back,B);w.push({level:I,size:B,up:O,down:S,right:L,left:k,front:C,back:P})}else{O=g.images.up,S=g.images.down,L=g.images.right,k=g.images.left,C=g.images.front,P=g.images.back;w.push({level:I,size:B,up:O,down:S,right:L,left:k,front:C,back:P})}}else{var B;if("number"!=typeof(I=z.level))continue;if("number"!=typeof(B=z.size))continue;O=h(z.up,M),S=h(z.down,M),L=h(z.right,M),k=h(z.left,M),C=h(z.front,M),P=h(z.back,M);w.push({level:I,size:B,up:O,down:S,right:L,left:k,front:C,back:P})}}w.sort((function(e,t){return e.level-t.level})),g.images.tiles=w}if(y.position instanceof r.Vector3)g.position=y.position.clone();else{if(!Array.isArray(y.position))break;g.position=(new r.Vector3).fromArray(y.position)}if(y.standingPosition instanceof r.Vector3)g.standingPosition=y.standingPosition.clone();else if(Array.isArray(y.standingPosition))g.standingPosition=(new r.Vector3).fromArray(y.standingPosition);else if(y.standing_position instanceof r.Vector3)g.standingPosition=y.standing_position.clone();else{if(!Array.isArray(y.standing_position))break;g.standingPosition=(new r.Vector3).fromArray(y.standing_position)}if(y.quaternion instanceof r.Quaternion)g.quaternion=y.quaternion.clone();else if(Array.isArray(y.quaternion))g.quaternion=(new r.Quaternion).fromArray(y.quaternion);else{if(!y.quaternion)break;var _=y.quaternion,U=_.x,R=_.y,Q=_.z,Y=_.w;g.quaternion=new r.Quaternion(U,R,Q,Y)}if(Array.isArray(y.accessibleNodes)?g.accessibleNodes=y.accessibleNodes.slice():Array.isArray(y.accessible_nodes)&&(g.accessibleNodes=y.accessible_nodes.slice()),Array.isArray(y.visibleNodes)?g.visibleNodes=y.visibleNodes.slice():Array.isArray(y.visible_nodes)&&(g.visibleNodes=y.visible_nodes.slice()),cn(y.floorIndex)?g.floorIndex=y.floorIndex:cn(y.floor_index)?g.floorIndex=y.floor_index:g.floorIndex=0,y.video){var F={};"string"==typeof y.video.source&&(F.source=y.video.source),y.video.matrix instanceof r.Matrix4?F.matrix=y.video.matrix.clone():Array.isArray(y.video.matrix)&&(F.matrix=(new r.Matrix4).fromArray(y.video.matrix)),y.video.size instanceof r.Vector2?F.size=y.video.size.clone():Array.isArray(y.video.size)&&(F.size=(new r.Vector2).fromArray(y.video.size)),F.source&&F.matrix&&F.size&&(g.video=F)}u.observers[M]=g}}if(an(a))return a;for(var V=0,H=u.observers;V<H.length;V++){if(!(g=H[V]).accessibleNodes){g.accessibleNodes=[];for(var G=0;G<u.observers.length;G++)u.observers[G]!==g&&g.accessibleNodes.push(G)}if(!g.visibleNodes){g.visibleNodes=[];for(G=0;G<u.observers.length;G++)u.observers[G]!==g&&g.visibleNodes.push(G)}}if(an(a))return a;var W=Nt(u);return An.set(W,{work:s,options:o}),W}function Mn(e,t,i){"string"==typeof e&&"{"===e.trim()[0]&&(e=JSON.parse(e));var n=An.get(e);if(n){if(t&&!un(JSON.parse(n.options),t))throw new Error("[PARSE FAILED]: work is parsed with different options.");return e}var r=fn(e,null!=t?t:{},i);if(an(r))throw new Error("[PARSE FAILED]: "+r.message);return r}function gn(e,t){e.mode=t.mode,e.panoIndex=t.panoIndex,e.longitude=t.longitude,e.latitude=t.latitude,e.fov=t.fov,e.offset.copy(t.offset)}function yn(e,t){return e.panoIndex===t.panoIndex&&e.mode===t.mode&&Math.abs(e.longitude-t.longitude)<.001&&Math.abs(e.latitude-t.latitude)<.001&&Math.abs(e.fov-t.fov)<.001&&e.offset.distanceTo(t.offset)<.001}var mn=function(e){return Number(e)};function vn(e,t,i){var n;void 0===t&&(t=mn),void 0===i&&(i=!1);for(var r,o=1/0,s=0,a=e;s<a.length;s++){var u=a[s],c=t(u);c<=o&&(r=(n=[u,c])[0],o=n[1])}return i?[r,o]:r}function Nn(e,t,i){return Math.max(t,Math.min(i,e))}function Dn(e){for(var t in e)return!1;return!0}function wn(e){return{longitude:e.longitude,latitude:e.latitude,fov:e.fov,offset:e.offset.clone()}}
|
|
367
|
+
function(e,t){for(var i=e.toByteArray(),n=0;n<i.length&&0==i[n];)++n;if(i.length-n!=t-1||2!=i[n])return null;for(++n;0!=i[n];)if(++n>=i.length)return null;for(var r="";++n<i.length;){var o=255&i[n];o<128?r+=String.fromCharCode(o):o>191&&o<224?(r+=String.fromCharCode((31&o)<<6|63&i[n+1]),++n):(r+=String.fromCharCode((15&o)<<12|(63&i[n+1])<<6|63&i[n+2]),n+=2)}return r}(i,this.n.bitLength()+7>>3)},K.prototype.decryptOAEP=function(e,t,i){if(e.length!=Math.ceil(this.n.bitLength()/4))throw new Error("wrong ctext length");var n=W(e,16),r=this.doPrivate(n);return null==r?null:function(e,t,i,n){var r=u.crypto.MessageDigest,o=u.crypto.Util,s=null;for(i||(i="sha1"),"string"==typeof i&&(s=r.getCanonicalAlgName(i),n=r.getHashLength(s),i=function(e){return re(o.hashHex(oe(e),s))}),e=e.toByteArray(),a=0;a<e.length;a+=1)e[a]&=255;for(;e.length<t;)e.unshift(0);if((e=String.fromCharCode.apply(String,e)).length<2*n+2)throw"Cipher too short";var a,c=e.substr(1,n),l=e.substr(n+1),h=Z(l,n,i),d=[];for(a=0;a<c.length;a+=1)d[a]=c.charCodeAt(a)^h.charCodeAt(a);var p=Z(String.fromCharCode.apply(String,d),e.length-n,i),A=[];for(a=0;a<l.length;a+=1)A[a]=l.charCodeAt(a)^p.charCodeAt(a);if((A=String.fromCharCode.apply(String,A)).substr(0,n)!==i(""))throw"Hash mismatch";var f=(A=A.substr(n)).indexOf("");if((-1!=f?A.substr(0,f).lastIndexOf("\0"):-1)+1!=f)throw"Malformed data";return A.substr(f+1)}(r,this.n.bitLength()+7>>3,t,i)},void 0!==u.lang&&u.lang||(u.lang={}),u.lang.String=function(){},u.lang.String.isInteger=function(e){return!!e.match(/^[0-9]+$/)||!!e.match(/^-[0-9]+$/)},u.lang.String.isHex=function(e){return he(e)},u.lang.String.isBase64=function(e){return!(!(e=e.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||e.length%4!=0)},u.lang.String.isBase64URL=function(e){return!e.match(/[+/=]/)&&(e=$(e),u.lang.String.isBase64(e))},u.lang.String.isIntegerArray=function(e){return!!(e=e.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)},u.lang.String.isPrintable=function(e){return null!==e.match(/^[0-9A-Za-z '()+,-./:=?]*$/)},u.lang.String.isIA5=function(e){return null!==e.match(/^[\x20-\x21\x23-\x7f]*$/)},u.lang.String.isMail=function(e){return null!==e.match(/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]{1,}\.[A-Za-z0-9]{1,}$/)};var pe=function(e,t,i){return null==i&&(i="0"),e.length>=t?e:new Array(t-e.length+1).join(i)+e};function Ae(e,t){var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e,e.superclass=t.prototype,t.prototype.constructor==Object.prototype.constructor&&(t.prototype.constructor=t)}void 0!==u.crypto&&u.crypto||(u.crypto={}),u.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414"},this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa"},this.CRYPTOJSMESSAGEDIGESTNAME={md5:l.algo.MD5,sha1:l.algo.SHA1,sha224:l.algo.SHA224,sha256:l.algo.SHA256,sha384:l.algo.SHA384,sha512:l.algo.SHA512,ripemd160:l.algo.RIPEMD160},this.getDigestInfoHex=function(e,t){if(void 0===this.DIGESTINFOHEAD[t])throw"alg not supported in Util.DIGESTINFOHEAD: "+t;return this.DIGESTINFOHEAD[t]+e},this.getPaddedDigestInfoHex=function(e,t,i){var n=this.getDigestInfoHex(e,t),r=i/4;if(n.length+22>r)throw"key is too short for SigAlg: keylen="+i+","+t;for(var o="0001",s="00"+n,a="",u=r-o.length-s.length,c=0;c<u;c+=2)a+="ff";return o+a+s},this.hashString=function(e,t){return new u.crypto.MessageDigest({alg:t}).digestString(e)},this.hashHex=function(e,t){return new u.crypto.MessageDigest({alg:t}).digestHex(e)},this.sha1=function(e){return this.hashString(e,"sha1")},this.sha256=function(e){return this.hashString(e,"sha256")},this.sha256Hex=function(e){return this.hashHex(e,"sha256")},this.sha512=function(e){return this.hashString(e,"sha512")},this.sha512Hex=function(e){return this.hashHex(e,"sha512")},this.isKey=function(e){return e instanceof K||e instanceof u.crypto.DSA||e instanceof u.crypto.ECDSA}},u.crypto.Util.md5=function(e){return new u.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(e)},u.crypto.Util.ripemd160=function(e){return new u.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(e)},u.crypto.Util.SECURERANDOMGEN=new G,u.crypto.Util.getRandomHexOfNbytes=function(e){var t=new Array(e);return u.crypto.Util.SECURERANDOMGEN.nextBytes(t),X(t)},u.crypto.Util.getRandomBigIntegerOfNbytes=function(e){return new h(u.crypto.Util.getRandomHexOfNbytes(e),16)},u.crypto.Util.getRandomHexOfNbits=function(e){var t=e%8,i=new Array((e-t)/8+1);return u.crypto.Util.SECURERANDOMGEN.nextBytes(i),i[0]=(255<<t&255^255)&i[0],X(i)},u.crypto.Util.getRandomBigIntegerOfNbits=function(e){return new h(u.crypto.Util.getRandomHexOfNbits(e),16)},u.crypto.Util.getRandomBigIntegerZeroToMax=function(e){for(var t=e.bitLength();;){var i=u.crypto.Util.getRandomBigIntegerOfNbits(t);if(-1!=e.compareTo(i))return i}},u.crypto.Util.getRandomBigIntegerMinToMax=function(e,t){var i=e.compareTo(t);if(1==i)throw"biMin is greater than biMax";if(0==i)return e;var n=t.subtract(e);return u.crypto.Util.getRandomBigIntegerZeroToMax(n).add(e)},u.crypto.MessageDigest=function(e){this.setAlgAndProvider=function(e,t){if(null!==(e=u.crypto.MessageDigest.getCanonicalAlgName(e))&&void 0===t&&(t=u.crypto.Util.DEFAULTPROVIDER[e]),-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(e)&&"cryptojs"==t){try{this.md=u.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[e].create()}catch(t){throw"setAlgAndProvider hash alg set fail alg="+e+"/"+t}this.updateString=function(e){this.md.update(e)},this.updateHex=function(e){var t=l.enc.Hex.parse(e);this.md.update(t)},this.digest=function(){return this.md.finalize().toString(l.enc.Hex)},this.digestString=function(e){return this.updateString(e),this.digest()},this.digestHex=function(e){return this.updateHex(e),this.digest()}}if(-1!=":sha256:".indexOf(e)&&"sjcl"==t){try{this.md=new sjcl.hash.sha256}catch(t){throw"setAlgAndProvider hash alg set fail alg="+e+"/"+t}this.updateString=function(e){this.md.update(e)},this.updateHex=function(e){var t=sjcl.codec.hex.toBits(e);this.md.update(t)},this.digest=function(){var e=this.md.finalize();return sjcl.codec.hex.fromBits(e)},this.digestString=function(e){return this.updateString(e),this.digest()},this.digestHex=function(e){return this.updateHex(e),this.digest()}}},this.updateString=function(e){throw"updateString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.updateHex=function(e){throw"updateHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digest=function(){throw"digest() not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestString=function(e){throw"digestString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestHex=function(e){throw"digestHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},void 0!==e&&void 0!==e.alg&&(this.algName=e.alg,void 0===e.prov&&(this.provName=u.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},u.crypto.MessageDigest.getCanonicalAlgName=function(e){return"string"==typeof e&&(e=(e=e.toLowerCase()).replace(/-/,"")),e},u.crypto.MessageDigest.getHashLength=function(e){var t=u.crypto.MessageDigest,i=t.getCanonicalAlgName(e);if(void 0===t.HASHLENGTH[i])throw"not supported algorithm: "+e;return t.HASHLENGTH[i]},u.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},u.crypto.Mac=function(e){this.setAlgAndProvider=function(e,t){if(null==(e=e.toLowerCase())&&(e="hmacsha1"),"hmac"!=(e=e.toLowerCase()).substr(0,4))throw"setAlgAndProvider unsupported HMAC alg: "+e;void 0===t&&(t=u.crypto.Util.DEFAULTPROVIDER[e]),this.algProv=e+"/"+t;var i=e.substr(4);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(i)&&"cryptojs"==t){try{var n=u.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[i];this.mac=l.algo.HMAC.create(n,this.pass)}catch(e){throw"setAlgAndProvider hash alg set fail hashAlg="+i+"/"+e}this.updateString=function(e){this.mac.update(e)},this.updateHex=function(e){var t=l.enc.Hex.parse(e);this.mac.update(t)},this.doFinal=function(){return this.mac.finalize().toString(l.enc.Hex)},this.doFinalString=function(e){return this.updateString(e),this.doFinal()},this.doFinalHex=function(e){return this.updateHex(e),this.doFinal()}}},this.updateString=function(e){throw"updateString(str) not supported for this alg/prov: "+this.algProv},this.updateHex=function(e){throw"updateHex(hex) not supported for this alg/prov: "+this.algProv},this.doFinal=function(){throw"digest() not supported for this alg/prov: "+this.algProv},this.doFinalString=function(e){throw"digestString(str) not supported for this alg/prov: "+this.algProv},this.doFinalHex=function(e){throw"digestHex(hex) not supported for this alg/prov: "+this.algProv},this.setPassword=function(e){if("string"==typeof e){var t=e;return e.length%2!=1&&e.match(/^[0-9A-Fa-f]+$/)||(t=oe(e)),void(this.pass=l.enc.Hex.parse(t))}if("object"!=typeof e)throw"KJUR.crypto.Mac unsupported password type: "+e;t=null;if(void 0!==e.hex){if(e.hex.length%2!=0||!e.hex.match(/^[0-9A-Fa-f]+$/))throw"Mac: wrong hex password: "+e.hex;t=e.hex}if(void 0!==e.utf8&&(t=ie(e.utf8)),void 0!==e.rstr&&(t=oe(e.rstr)),void 0!==e.b64&&(t=C(e.b64)),void 0!==e.b64u&&(t=te(e.b64u)),null==t)throw"KJUR.crypto.Mac unsupported password type: "+e;this.pass=l.enc.Hex.parse(t)},void 0!==e&&(void 0!==e.pass&&this.setPassword(e.pass),void 0!==e.alg&&(this.algName=e.alg,void 0===e.prov&&(this.provName=u.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))},u.crypto.Signature=function(e){var t=null;if(this._setAlgNames=function(){var e=this.algName.match(/^(.+)with(.+)$/);e&&(this.mdAlgName=e[1].toLowerCase(),this.pubkeyAlgName=e[2].toLowerCase(),"rsaandmgf1"==this.pubkeyAlgName&&"sha"==this.mdAlgName&&(this.mdAlgName="sha1"))},this._zeroPaddingOfSignature=function(e,t){for(var i="",n=t/4-e.length,r=0;r<n;r++)i+="0";return i+e},this.setAlgAndProvider=function(e,t){if(this._setAlgNames(),"cryptojs/jsrsa"!=t)throw new Error("provider not supported: "+t);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(this.mdAlgName)){try{this.md=new u.crypto.MessageDigest({alg:this.mdAlgName})}catch(e){throw new Error("setAlgAndProvider hash alg set fail alg="+this.mdAlgName+"/"+e)}this.init=function(e,t){var i=null;try{i=void 0===t?we.getKey(e):we.getKey(e,t)}catch(e){throw"init failed:"+e}if(!0===i.isPrivate)this.prvKey=i,this.state="SIGN";else{if(!0!==i.isPublic)throw"init failed.:"+i;this.pubKey=i,this.state="VERIFY"}},this.updateString=function(e){this.md.updateString(e)},this.updateHex=function(e){this.md.updateHex(e)},this.sign=function(){if(this.sHashHex=this.md.digest(),void 0===this.prvKey&&void 0!==this.ecprvhex&&void 0!==this.eccurvename&&void 0!==u.crypto.ECDSA&&(this.prvKey=new u.crypto.ECDSA({curve:this.eccurvename,prv:this.ecprvhex})),this.prvKey instanceof K&&"rsaandmgf1"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHashPSS(this.sHashHex,this.mdAlgName,this.pssSaltLen);else if(this.prvKey instanceof K&&"rsa"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex,this.mdAlgName);else if(this.prvKey instanceof u.crypto.ECDSA)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex);else{if(!(this.prvKey instanceof u.crypto.DSA))throw"Signature: unsupported private key alg: "+this.pubkeyAlgName;this.hSign=this.prvKey.signWithMessageHash(this.sHashHex)}return this.hSign},this.signString=function(e){return this.updateString(e),this.sign()},this.signHex=function(e){return this.updateHex(e),this.sign()},this.verify=function(e){if(this.sHashHex=this.md.digest(),void 0===this.pubKey&&void 0!==this.ecpubhex&&void 0!==this.eccurvename&&void 0!==u.crypto.ECDSA&&(this.pubKey=new u.crypto.ECDSA({curve:this.eccurvename,pub:this.ecpubhex})),this.pubKey instanceof K&&"rsaandmgf1"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHashPSS(this.sHashHex,e,this.mdAlgName,this.pssSaltLen);if(this.pubKey instanceof K&&"rsa"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHash(this.sHashHex,e);if(void 0!==u.crypto.ECDSA&&this.pubKey instanceof u.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,e);if(void 0!==u.crypto.DSA&&this.pubKey instanceof u.crypto.DSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,e);throw"Signature: unsupported public key alg: "+this.pubkeyAlgName}}},this.init=function(e,t){throw"init(key, pass) not supported for this alg:prov="+this.algProvName},this.updateString=function(e){throw"updateString(str) not supported for this alg:prov="+this.algProvName},this.updateHex=function(e){throw"updateHex(hex) not supported for this alg:prov="+this.algProvName},this.sign=function(){throw"sign() not supported for this alg:prov="+this.algProvName},this.signString=function(e){throw"digestString(str) not supported for this alg:prov="+this.algProvName},this.signHex=function(e){throw"digestHex(hex) not supported for this alg:prov="+this.algProvName},this.verify=function(e){throw"verify(hSigVal) not supported for this alg:prov="+this.algProvName},this.initParams=e,void 0!==e&&(void 0!==e.alg&&(this.algName=e.alg,void 0===e.prov?this.provName=u.crypto.Util.DEFAULTPROVIDER[this.algName]:this.provName=e.prov,this.algProvName=this.algName+":"+this.provName,this.setAlgAndProvider(this.algName,this.provName),this._setAlgNames()),void 0!==e.psssaltlen&&(this.pssSaltLen=e.psssaltlen),void 0!==e.prvkeypem)){if(void 0!==e.prvkeypas)throw"both prvkeypem and prvkeypas parameters not supported";try{t=we.getKey(e.prvkeypem);this.init(t)}catch(e){throw"fatal error to load pem private key: "+e}}},u.crypto.Cipher=function(e){},u.crypto.Cipher.encrypt=function(e,t,i){if(t instanceof K&&t.isPublic){var n=u.crypto.Cipher.getAlgByKeyAndName(t,i);if("RSA"===n)return t.encrypt(e);if("RSAOAEP"===n)return t.encryptOAEP(e,"sha1");var r=n.match(/^RSAOAEP(\d+)$/);if(null!==r)return t.encryptOAEP(e,"sha"+r[1]);throw"Cipher.encrypt: unsupported algorithm for RSAKey: "+i}throw"Cipher.encrypt: unsupported key or algorithm"},u.crypto.Cipher.decrypt=function(e,t,i){if(t instanceof K&&t.isPrivate){var n=u.crypto.Cipher.getAlgByKeyAndName(t,i);if("RSA"===n)return t.decrypt(e);if("RSAOAEP"===n)return t.decryptOAEP(e,"sha1");var r=n.match(/^RSAOAEP(\d+)$/);if(null!==r)return t.decryptOAEP(e,"sha"+r[1]);throw"Cipher.decrypt: unsupported algorithm for RSAKey: "+i}throw"Cipher.decrypt: unsupported key or algorithm"},u.crypto.Cipher.getAlgByKeyAndName=function(e,t){if(e instanceof K){if(-1!=":RSA:RSAOAEP:RSAOAEP224:RSAOAEP256:RSAOAEP384:RSAOAEP512:".indexOf(t))return t;if(null==t)return"RSA";throw"getAlgByKeyAndName: not supported algorithm name for RSAKey: "+t}throw"getAlgByKeyAndName: not supported algorithm name: "+t},u.crypto.OID=new function(){this.oidhex2name={"2a864886f70d010101":"rsaEncryption","2a8648ce3d0201":"ecPublicKey","2a8648ce380401":"dsa","2a8648ce3d030107":"secp256r1","2b8104001f":"secp192k1","2b81040021":"secp224r1","2b8104000a":"secp256k1","2b81040023":"secp521r1","2b81040022":"secp384r1","2a8648ce380403":"SHA1withDSA","608648016503040301":"SHA224withDSA","608648016503040302":"SHA256withDSA"}};var fe,Me,ge,ye,me,ve,Ne,De,we=(fe=function(e,t,i){return Me(l.AES,e,t,i)},Me=function(e,t,i,n){var r=l.enc.Hex.parse(t),o=l.enc.Hex.parse(i),s=l.enc.Hex.parse(n),a={};a.key=o,a.iv=s,a.ciphertext=r;var u=e.decrypt(a,o,{iv:s});return l.enc.Hex.stringify(u)},ge=function(e,t,i){return ye(l.AES,e,t,i)},ye=function(e,t,i,n){var r=l.enc.Hex.parse(t),o=l.enc.Hex.parse(i),s=l.enc.Hex.parse(n),a=e.encrypt(r,o,{iv:s}),u=l.enc.Hex.parse(a.toString());return l.enc.Base64.stringify(u)},me={"AES-256-CBC":{proc:fe,eproc:ge,keylen:32,ivlen:16},"AES-192-CBC":{proc:fe,eproc:ge,keylen:24,ivlen:16},"AES-128-CBC":{proc:fe,eproc:ge,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(e,t,i){return Me(l.TripleDES,e,t,i)},eproc:function(e,t,i){return ye(l.TripleDES,e,t,i)},keylen:24,ivlen:8},"DES-CBC":{proc:function(e,t,i){return Me(l.DES,e,t,i)},eproc:function(e,t,i){return ye(l.DES,e,t,i)},keylen:8,ivlen:8}},ve=function(e){var t={},i=e.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));i&&(t.cipher=i[1],t.ivsalt=i[2]);var n=e.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(t.type=n[1]);var r=-1,o=0;-1!=e.indexOf("\r\n\r\n")&&(r=e.indexOf("\r\n\r\n"),o=2),-1!=e.indexOf("\n\n")&&(r=e.indexOf("\n\n"),o=1);var s=e.indexOf("-----END");if(-1!=r&&-1!=s){var a=e.substring(r+2*o,s-o);a=a.replace(/\s+/g,""),t.data=a}return t},Ne=function(e,t,i){for(var n=i.substring(0,16),r=l.enc.Hex.parse(n),o=l.enc.Utf8.parse(t),s=me[e].keylen+me[e].ivlen,a="",u=null;;){var c=l.algo.MD5.create();if(null!=u&&c.update(u),c.update(o),c.update(r),u=c.finalize(),(a+=l.enc.Hex.stringify(u)).length>=2*s)break}var h={};return h.keyhex=a.substr(0,2*me[e].keylen),h.ivhex=a.substr(2*me[e].keylen,2*me[e].ivlen),h},De=function(e,t,i,n){var r=l.enc.Base64.parse(e),o=l.enc.Hex.stringify(r);return(0,me[t].proc)(o,i,n)},{version:"1.0.0",parsePKCS5PEM:function(e){return ve(e)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(e,t,i){return Ne(e,t,i)},decryptKeyB64:function(e,t,i,n){return De(e,t,i,n)},getDecryptedKeyHex:function(e,t){var i=ve(e);i.type;var n=i.cipher,r=i.ivsalt,o=i.data,s=Ne(n,t,r).keyhex;return De(o,n,s,r)},getEncryptedPKCS5PEMFromPrvKeyHex:function(e,t,i,n,r){var o="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===me[n])throw"KEYUTIL unsupported algorithm: "+n;void 0!==r&&null!=r||(r=function(e){var t=l.lib.WordArray.random(e);return l.enc.Hex.stringify(t)}(me[n].ivlen).toUpperCase());var s=function(e,t,i,n){return(0,me[t].eproc)(e,i,n)}(t,n,Ne(n,i,r).keyhex,r);return o="-----BEGIN "+e+" PRIVATE KEY-----\r\n",o+="Proc-Type: 4,ENCRYPTED\r\n",o+="DEK-Info: "+n+","+r+"\r\n",o+="\r\n",o+=s.replace(/(.{64})/g,"$1\r\n"),o+="\r\n-----END "+e+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(e){var t=Te,i=t.getChildIdx,n=t.getV,r={},o=i(e,0);if(2!=o.length)throw"malformed format: SEQUENCE(0).items != 2: "+o.length;r.ciphertext=n(e,o[1]);var s=i(e,o[0]);if(2!=s.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+s.length;if("2a864886f70d01050d"!=n(e,s[0]))throw"this only supports pkcs5PBES2";var a=i(e,s[1]);if(2!=s.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+a.length;var u=i(e,a[1]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+u.length;if("2a864886f70d0307"!=n(e,u[0]))throw"this only supports TripleDES";r.encryptionSchemeAlg="TripleDES",r.encryptionSchemeIV=n(e,u[1]);var c=i(e,a[0]);if(2!=c.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+c.length;if("2a864886f70d01050c"!=n(e,c[0]))throw"this only supports pkcs5PBKDF2";var l=i(e,c[1]);if(l.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+l.length;r.pbkdf2Salt=n(e,l[0]);var h=n(e,l[1]);try{r.pbkdf2Iter=parseInt(h,16)}catch(e){throw"malformed format pbkdf2Iter: "+h}return r},getPBKDF2KeyHexFromParam:function(e,t){var i=l.enc.Hex.parse(e.pbkdf2Salt),n=e.pbkdf2Iter,r=l.PBKDF2(t,i,{keySize:6,iterations:n});return l.enc.Hex.stringify(r)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(e,t){var i=ue(e,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(i),r=we.getPBKDF2KeyHexFromParam(n,t),o={};o.ciphertext=l.enc.Hex.parse(n.ciphertext);var s=l.enc.Hex.parse(r),a=l.enc.Hex.parse(n.encryptionSchemeIV),u=l.TripleDES.decrypt(o,s,{iv:a});return l.enc.Hex.stringify(u)},getKeyFromEncryptedPKCS8PEM:function(e,t){var i=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(e,t);return this.getKeyFromPlainPrivatePKCS8Hex(i)},parsePlainPrivatePKCS8Hex:function(e){var t=Te,i=t.getChildIdx,n=t.getV,r={algparam:null};if("30"!=e.substr(0,2))throw new Error("malformed plain PKCS8 private key(code:001)");var o=i(e,0);if(o.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if("30"!=e.substr(o[1],2))throw new Error("malformed PKCS8 private key(code:003)");var s=i(e,o[1]);if(2!=s.length)throw new Error("malformed PKCS8 private key(code:004)");if("06"!=e.substr(s[0],2))throw new Error("malformed PKCS8 private key(code:005)");if(r.algoid=n(e,s[0]),"06"==e.substr(s[1],2)&&(r.algparam=n(e,s[1])),"04"!=e.substr(o[2],2))throw new Error("malformed PKCS8 private key(code:006)");return r.keyidx=t.getVidx(e,o[2]),r},getKeyFromPlainPrivatePKCS8PEM:function(e){var t=ue(e,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(t)},getKeyFromPlainPrivatePKCS8Hex:function(e){var t,i=this.parsePlainPrivatePKCS8Hex(e);if("2a864886f70d010101"==i.algoid)t=new K;else if("2a8648ce380401"==i.algoid)t=new u.crypto.DSA;else{if("2a8648ce3d0201"!=i.algoid)throw"unsupported private key algorithm";t=new u.crypto.ECDSA}return t.readPKCS8PrvKeyHex(e),t},_getKeyFromPublicPKCS8Hex:function(e){var t,i=Te.getVbyList(e,0,[0,0],"06");if("2a864886f70d010101"===i)t=new K;else if("2a8648ce380401"===i)t=new u.crypto.DSA;else{if("2a8648ce3d0201"!==i)throw"unsupported PKCS#8 public key hex";t=new u.crypto.ECDSA}return t.readPKCS8PubKeyHex(e),t},parsePublicRawRSAKeyHex:function(e){var t=Te,i=t.getChildIdx,n=t.getV,r={};if("30"!=e.substr(0,2))throw"malformed RSA key(code:001)";var o=i(e,0);if(2!=o.length)throw"malformed RSA key(code:002)";if("02"!=e.substr(o[0],2))throw"malformed RSA key(code:003)";if(r.n=n(e,o[0]),"02"!=e.substr(o[1],2))throw"malformed RSA key(code:004)";return r.e=n(e,o[1]),r},parsePublicPKCS8Hex:function(e){var t=Te,i=t.getChildIdx,n=t.getV,r={algparam:null},o=i(e,0);if(2!=o.length)throw"outer DERSequence shall have 2 elements: "+o.length;var s=o[0];if("30"!=e.substr(s,2))throw"malformed PKCS8 public key(code:001)";var a=i(e,s);if(2!=a.length)throw"malformed PKCS8 public key(code:002)";if("06"!=e.substr(a[0],2))throw"malformed PKCS8 public key(code:003)";if(r.algoid=n(e,a[0]),"06"==e.substr(a[1],2)?r.algparam=n(e,a[1]):"30"==e.substr(a[1],2)&&(r.algparam={},r.algparam.p=t.getVbyList(e,a[1],[0],"02"),r.algparam.q=t.getVbyList(e,a[1],[1],"02"),r.algparam.g=t.getVbyList(e,a[1],[2],"02")),"03"!=e.substr(o[1],2))throw"malformed PKCS8 public key(code:004)";return r.key=n(e,o[1]).substr(2),r}});we.getKey=function(e,t,i){var n=(y=Te).getChildIdx;y.getV;var r=y.getVbyList,o=u.crypto,s=o.ECDSA,a=o.DSA,c=K,l=ue,d=we;if(void 0!==c&&e instanceof c)return e;if(void 0!==s&&e instanceof s)return e;if(void 0!==a&&e instanceof a)return e;if(void 0!==e.curve&&void 0!==e.xy&&void 0===e.d)return new s({pub:e.xy,curve:e.curve});if(void 0!==e.curve&&void 0!==e.d)return new s({prv:e.d,curve:e.curve});if(void 0===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0===e.d)return(I=new c).setPublic(e.n,e.e),I;if(void 0===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d&&void 0!==e.p&&void 0!==e.q&&void 0!==e.dp&&void 0!==e.dq&&void 0!==e.co&&void 0===e.qi)return(I=new c).setPrivateEx(e.n,e.e,e.d,e.p,e.q,e.dp,e.dq,e.co),I;if(void 0===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d&&void 0===e.p)return(I=new c).setPrivate(e.n,e.e,e.d),I;if(void 0!==e.p&&void 0!==e.q&&void 0!==e.g&&void 0!==e.y&&void 0===e.x)return(I=new a).setPublic(e.p,e.q,e.g,e.y),I;if(void 0!==e.p&&void 0!==e.q&&void 0!==e.g&&void 0!==e.y&&void 0!==e.x)return(I=new a).setPrivate(e.p,e.q,e.g,e.y,e.x),I;if("RSA"===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0===e.d)return(I=new c).setPublic(te(e.n),te(e.e)),I;if("RSA"===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d&&void 0!==e.p&&void 0!==e.q&&void 0!==e.dp&&void 0!==e.dq&&void 0!==e.qi)return(I=new c).setPrivateEx(te(e.n),te(e.e),te(e.d),te(e.p),te(e.q),te(e.dp),te(e.dq),te(e.qi)),I;if("RSA"===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d)return(I=new c).setPrivate(te(e.n),te(e.e),te(e.d)),I;if("EC"===e.kty&&void 0!==e.crv&&void 0!==e.x&&void 0!==e.y&&void 0===e.d){var p=(z=new s({curve:e.crv})).ecparams.keylen/4,A="04"+("0000000000"+te(e.x)).slice(-p)+("0000000000"+te(e.y)).slice(-p);return z.setPublicKeyHex(A),z}if("EC"===e.kty&&void 0!==e.crv&&void 0!==e.x&&void 0!==e.y&&void 0!==e.d){p=(z=new s({curve:e.crv})).ecparams.keylen/4,A="04"+("0000000000"+te(e.x)).slice(-p)+("0000000000"+te(e.y)).slice(-p);var f=("0000000000"+te(e.d)).slice(-p);return z.setPublicKeyHex(A),z.setPrivateKeyHex(f),z}if("pkcs5prv"===i){var M,g=e,y=Te;if(9===(M=n(g,0)).length)(I=new c).readPKCS5PrvKeyHex(g);else if(6===M.length)(I=new a).readPKCS5PrvKeyHex(g);else{if(!(M.length>2&&"04"===g.substr(M[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(I=new s).readPKCS5PrvKeyHex(g)}return I}if("pkcs8prv"===i)return I=d.getKeyFromPlainPrivatePKCS8Hex(e);if("pkcs8pub"===i)return d._getKeyFromPublicPKCS8Hex(e);if("x509pub"===i)return ze.getPublicKeyFromCertHex(e);if(-1!=e.indexOf("-END CERTIFICATE-",0)||-1!=e.indexOf("-END X509 CERTIFICATE-",0)||-1!=e.indexOf("-END TRUSTED CERTIFICATE-",0))return ze.getPublicKeyFromCertPEM(e);if(-1!=e.indexOf("-END PUBLIC KEY-")){var m=ue(e,"PUBLIC KEY");return d._getKeyFromPublicPKCS8Hex(m)}if(-1!=e.indexOf("-END RSA PRIVATE KEY-")&&-1==e.indexOf("4,ENCRYPTED")){var v=l(e,"RSA PRIVATE KEY");return d.getKey(v,null,"pkcs5prv")}if(-1!=e.indexOf("-END DSA PRIVATE KEY-")&&-1==e.indexOf("4,ENCRYPTED")){var N=r(S=l(e,"DSA PRIVATE KEY"),0,[1],"02"),D=r(S,0,[2],"02"),w=r(S,0,[3],"02"),T=r(S,0,[4],"02"),x=r(S,0,[5],"02");return(I=new a).setPrivate(new h(N,16),new h(D,16),new h(w,16),new h(T,16),new h(x,16)),I}if(-1!=e.indexOf("-END EC PRIVATE KEY-")&&-1==e.indexOf("4,ENCRYPTED")){v=l(e,"EC PRIVATE KEY");return d.getKey(v,null,"pkcs5prv")}if(-1!=e.indexOf("-END PRIVATE KEY-"))return d.getKeyFromPlainPrivatePKCS8PEM(e);if(-1!=e.indexOf("-END RSA PRIVATE KEY-")&&-1!=e.indexOf("4,ENCRYPTED")){var E=d.getDecryptedKeyHex(e,t),j=new K;return j.readPKCS5PrvKeyHex(E),j}if(-1!=e.indexOf("-END EC PRIVATE KEY-")&&-1!=e.indexOf("4,ENCRYPTED")){var z,I=r(S=d.getDecryptedKeyHex(e,t),0,[1],"04"),b=r(S,0,[2,0],"06"),O=r(S,0,[3,0],"03").substr(2);if(void 0===u.crypto.OID.oidhex2name[b])throw"undefined OID(hex) in KJUR.crypto.OID: "+b;return(z=new s({curve:u.crypto.OID.oidhex2name[b]})).setPublicKeyHex(O),z.setPrivateKeyHex(I),z.isPublic=!1,z}if(-1!=e.indexOf("-END DSA PRIVATE KEY-")&&-1!=e.indexOf("4,ENCRYPTED")){var S;N=r(S=d.getDecryptedKeyHex(e,t),0,[1],"02"),D=r(S,0,[2],"02"),w=r(S,0,[3],"02"),T=r(S,0,[4],"02"),x=r(S,0,[5],"02");return(I=new a).setPrivate(new h(N,16),new h(D,16),new h(w,16),new h(T,16),new h(x,16)),I}if(-1!=e.indexOf("-END ENCRYPTED PRIVATE KEY-"))return d.getKeyFromEncryptedPKCS8PEM(e,t);throw new Error("not supported argument")},we.generateKeypair=function(e,t){if("RSA"==e){var i=t;(s=new K).generate(i,"10001"),s.isPrivate=!0,s.isPublic=!0;var n=new K,r=s.n.toString(16),o=s.e.toString(16);return n.setPublic(r,o),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=s,a.pubKeyObj=n,a}if("EC"==e){var s,a,c=t,l=new u.crypto.ECDSA({curve:c}).generateKeyPairHex();return(s=new u.crypto.ECDSA({curve:c})).setPublicKeyHex(l.ecpubhex),s.setPrivateKeyHex(l.ecprvhex),s.isPrivate=!0,s.isPublic=!1,(n=new u.crypto.ECDSA({curve:c})).setPublicKeyHex(l.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=s,a.pubKeyObj=n,a}throw"unknown algorithm: "+e},we.getPEM=function(e,t,i,n,r,o){var s=u,a=s.asn1,c=a.DERObjectIdentifier,h=a.DERInteger,d=a.ASN1Util.newObject,p=a.x509.SubjectPublicKeyInfo,A=s.crypto,f=A.DSA,M=A.ECDSA,g=K;function y(e){return d({seq:[{int:0},{int:{bigint:e.n}},{int:e.e},{int:{bigint:e.d}},{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.dmp1}},{int:{bigint:e.dmq1}},{int:{bigint:e.coeff}}]})}function m(e){return d({seq:[{int:1},{octstr:{hex:e.prvKeyHex}},{tag:["a0",!0,{oid:{name:e.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+e.pubKeyHex}}]}]})}function v(e){return d({seq:[{int:0},{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}},{int:{bigint:e.y}},{int:{bigint:e.x}}]})}if((void 0!==g&&e instanceof g||void 0!==f&&e instanceof f||void 0!==M&&e instanceof M)&&1==e.isPublic&&(void 0===t||"PKCS8PUB"==t))return ae(T=new p(e).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==t&&void 0!==g&&e instanceof g&&(void 0===i||null==i)&&1==e.isPrivate)return ae(T=y(e).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==t&&void 0!==M&&e instanceof M&&(void 0===i||null==i)&&1==e.isPrivate){var N=new c({name:e.curveName}).getEncodedHex(),D=m(e).getEncodedHex(),w="";return w+=ae(N,"EC PARAMETERS"),w+=ae(D,"EC PRIVATE KEY")}if("PKCS1PRV"==t&&void 0!==f&&e instanceof f&&(void 0===i||null==i)&&1==e.isPrivate)return ae(T=v(e).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==t&&void 0!==g&&e instanceof g&&void 0!==i&&null!=i&&1==e.isPrivate){var T=y(e).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",T,i,n,o)}if("PKCS5PRV"==t&&void 0!==M&&e instanceof M&&void 0!==i&&null!=i&&1==e.isPrivate){T=m(e).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",T,i,n,o)}if("PKCS5PRV"==t&&void 0!==f&&e instanceof f&&void 0!==i&&null!=i&&1==e.isPrivate){T=v(e).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",T,i,n,o)}var x=function(e,t){var i=E(e,t);return new d({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:i.pbkdf2Salt}},{int:i.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:i.encryptionSchemeIV}}]}]}]},{octstr:{hex:i.ciphertext}}]}).getEncodedHex()},E=function(e,t){var i=l.lib.WordArray.random(8),n=l.lib.WordArray.random(8),r=l.PBKDF2(t,i,{keySize:6,iterations:100}),o=l.enc.Hex.parse(e),s=l.TripleDES.encrypt(o,r,{iv:n})+"",a={};return a.ciphertext=s,a.pbkdf2Salt=l.enc.Hex.stringify(i),a.pbkdf2Iter=100,a.encryptionSchemeAlg="DES-EDE3-CBC",a.encryptionSchemeIV=l.enc.Hex.stringify(n),a};if("PKCS8PRV"==t&&null!=g&&e instanceof g&&1==e.isPrivate){var j=y(e).getEncodedHex();T=d({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:j}}]}).getEncodedHex();return void 0===i||null==i?ae(T,"PRIVATE KEY"):ae(D=x(T,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==t&&void 0!==M&&e instanceof M&&1==e.isPrivate){j=new d({seq:[{int:1},{octstr:{hex:e.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+e.pubKeyHex}}]}]}).getEncodedHex(),T=d({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:e.curveName}}]},{octstr:{hex:j}}]}).getEncodedHex();return void 0===i||null==i?ae(T,"PRIVATE KEY"):ae(D=x(T,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==t&&void 0!==f&&e instanceof f&&1==e.isPrivate){j=new h({bigint:e.x}).getEncodedHex(),T=d({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}}]}]},{octstr:{hex:j}}]}).getEncodedHex();return void 0===i||null==i?ae(T,"PRIVATE KEY"):ae(D=x(T,i),"ENCRYPTED PRIVATE KEY")}throw new Error("unsupported object nor format")},we.getKeyFromCSRPEM=function(e){var t=ue(e,"CERTIFICATE REQUEST");return we.getKeyFromCSRHex(t)},we.getKeyFromCSRHex=function(e){var t=we.parseCSRHex(e);return we.getKey(t.p8pubkeyhex,null,"pkcs8pub")},we.parseCSRHex=function(e){var t=Te,i=t.getChildIdx,n=t.getTLV,r={},o=e;if("30"!=o.substr(0,2))throw"malformed CSR(code:001)";var s=i(o,0);if(s.length<1)throw"malformed CSR(code:002)";if("30"!=o.substr(s[0],2))throw"malformed CSR(code:003)";var a=i(o,s[0]);if(a.length<3)throw"malformed CSR(code:004)";return r.p8pubkeyhex=n(o,a[2]),r},we.getKeyID=function(e){var t=we,i=Te;"string"==typeof e&&-1!=e.indexOf("BEGIN ")&&(e=t.getKey(e));var n=ue(t.getPEM(e)),r=i.getIdxbyList(n,0,[1]),o=i.getV(n,r).substring(2);return u.crypto.Util.hashHex(o,"sha1")},we.getJWKFromKey=function(e){var t={};if(e instanceof K&&e.isPrivate)return t.kty="RSA",t.n=ee(e.n.toString(16)),t.e=ee(e.e.toString(16)),t.d=ee(e.d.toString(16)),t.p=ee(e.p.toString(16)),t.q=ee(e.q.toString(16)),t.dp=ee(e.dmp1.toString(16)),t.dq=ee(e.dmq1.toString(16)),t.qi=ee(e.coeff.toString(16)),t;if(e instanceof K&&e.isPublic)return t.kty="RSA",t.n=ee(e.n.toString(16)),t.e=ee(e.e.toString(16)),t;if(e instanceof u.crypto.ECDSA&&e.isPrivate){if("P-256"!==(n=e.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;var i=e.getPublicKeyXYHex();return t.kty="EC",t.crv=n,t.x=ee(i.x),t.y=ee(i.y),t.d=ee(e.prvKeyHex),t}if(e instanceof u.crypto.ECDSA&&e.isPublic){var n;if("P-256"!==(n=e.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;i=e.getPublicKeyXYHex();return t.kty="EC",t.crv=n,t.x=ee(i.x),t.y=ee(i.y),t}throw"not supported key object"},void 0!==u.asn1&&u.asn1||(u.asn1={}),u.asn1.ASN1Util=new function(){this.integerToByteHex=function(e){var t=e.toString(16);return t.length%2==1&&(t="0"+t),t},this.bigIntToMinTwosComplementsHex=function(e){var t=e.toString(16);if("-"!=t.substr(0,1))t.length%2==1?t="0"+t:t.match(/^[0-7]/)||(t="00"+t);else{var i=t.substr(1).length;i%2==1?i+=1:t.match(/^[0-7]/)||(i+=2);for(var n="",r=0;r<i;r++)n+="f";t=new h(n,16).xor(e).add(h.ONE).toString(16).replace(/^-/,"")}return t},this.getPEMStringFromHex=function(e,t){return ae(e,t)},this.newObject=function(e){var t=u.asn1,i=t.ASN1Object,n=t.DERBoolean,r=t.DERInteger,o=t.DERBitString,s=t.DEROctetString,a=t.DERNull,c=t.DERObjectIdentifier,l=t.DEREnumerated,h=t.DERUTF8String,d=t.DERNumericString,p=t.DERPrintableString,A=t.DERTeletexString,f=t.DERIA5String,M=t.DERUTCTime,g=t.DERGeneralizedTime,y=t.DERVisibleString,m=t.DERBMPString,v=t.DERSequence,N=t.DERSet,D=t.DERTaggedObject,w=t.ASN1Util.newObject;if(e instanceof t.ASN1Object)return e;var T=Object.keys(e);if(1!=T.length)throw new Error("key of param shall be only one.");var x=T[0];if(-1==":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+x+":"))throw new Error("undefined key: "+x);if("bool"==x)return new n(e[x]);if("int"==x)return new r(e[x]);if("bitstr"==x)return new o(e[x]);if("octstr"==x)return new s(e[x]);if("null"==x)return new a(e[x]);if("oid"==x)return new c(e[x]);if("enum"==x)return new l(e[x]);if("utf8str"==x)return new h(e[x]);if("numstr"==x)return new d(e[x]);if("prnstr"==x)return new p(e[x]);if("telstr"==x)return new A(e[x]);if("ia5str"==x)return new f(e[x]);if("utctime"==x)return new M(e[x]);if("gentime"==x)return new g(e[x]);if("visstr"==x)return new y(e[x]);if("bmpstr"==x)return new m(e[x]);if("asn1"==x)return new i(e[x]);if("seq"==x){for(var E=e[x],j=[],z=0;z<E.length;z++){var I=w(E[z]);j.push(I)}return new v({array:j})}if("set"==x){for(E=e[x],j=[],z=0;z<E.length;z++){I=w(E[z]);j.push(I)}return new N({array:j})}if("tag"==x){var b=e[x];if("[object Array]"===Object.prototype.toString.call(b)&&3==b.length){var O=w(b[2]);return new D({tag:b[0],explicit:b[1],obj:O})}return new D(b)}},this.jsonToASN1HEX=function(e){return this.newObject(e).getEncodedHex()}},u.asn1.ASN1Util.oidHexToInt=function(e){for(var t="",i=parseInt(e.substr(0,2),16),n=(t=Math.floor(i/40)+"."+i%40,""),r=2;r<e.length;r+=2){var o=("00000000"+parseInt(e.substr(r,2),16).toString(2)).slice(-8);if(n+=o.substr(1,7),"0"==o.substr(0,1))t=t+"."+new h(n,2).toString(10),n=""}return t},u.asn1.ASN1Util.oidIntToHex=function(e){var t=function(e){var t=e.toString(16);return 1==t.length&&(t="0"+t),t},i=function(e){var i="",n=new h(e,10).toString(2),r=7-n.length%7;7==r&&(r=0);for(var o="",s=0;s<r;s++)o+="0";n=o+n;for(s=0;s<n.length-1;s+=7){var a=n.substr(s,7);s!=n.length-7&&(a="1"+a),i+=t(parseInt(a,2))}return i};if(!e.match(/^[0-9.]+$/))throw"malformed oid string: "+e;var n="",r=e.split("."),o=40*parseInt(r[0])+parseInt(r[1]);n+=t(o),r.splice(0,2);for(var s=0;s<r.length;s++)n+=i(r[s]);return n},u.asn1.ASN1Object=function(e){this.params=null,this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw new Error("this.hV is null or undefined");if(this.hV.length%2==1)throw new Error("value hex must be even length: n="+"".length+",v="+this.hV);var e=this.hV.length/2,t=e.toString(16);if(t.length%2==1&&(t="0"+t),e<128)return t;var i=t.length/2;if(i>15)throw"ASN.1 length too long to represent by 8x: n = "+e.toString(16);return(128+i).toString(16)+t},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""},this.setByParam=function(e){this.params=e},null!=e&&null!=e.tlv&&(this.hTLV=e.tlv,this.isModified=!1)},u.asn1.DERAbstractString=function(e){u.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(e){this.hTLV=null,this.isModified=!0,this.s=e,this.hV=ie(this.s).toLowerCase()},this.setStringHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e?this.setString(e):void 0!==e.str?this.setString(e.str):void 0!==e.hex&&this.setStringHex(e.hex))},c.lang.extend(u.asn1.DERAbstractString,u.asn1.ASN1Object),u.asn1.DERAbstractTime=function(e){u.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(e){var t=e.getTime()+6e4*e.getTimezoneOffset();return new Date(t)},this.formatDate=function(e,t,i){var n=this.zeroPadding,r=this.localDateToUTC(e),o=String(r.getFullYear());"utc"==t&&(o=o.substr(2,2));var s=o+n(String(r.getMonth()+1),2)+n(String(r.getDate()),2)+n(String(r.getHours()),2)+n(String(r.getMinutes()),2)+n(String(r.getSeconds()),2);if(!0===i){var a=r.getMilliseconds();if(0!=a){var u=n(String(a),3);s=s+"."+(u=u.replace(/[0]+$/,""))}}return s+"Z"},this.zeroPadding=function(e,t){return e.length>=t?e:new Array(t-e.length+1).join("0")+e},this.getString=function(){return this.s},this.setString=function(e){this.hTLV=null,this.isModified=!0,this.s=e,this.hV=J(e)},this.setByDateValue=function(e,t,i,n,r,o){var s=new Date(Date.UTC(e,t-1,i,n,r,o,0));this.setByDate(s)},this.getFreshValueHex=function(){return this.hV}},c.lang.extend(u.asn1.DERAbstractTime,u.asn1.ASN1Object),u.asn1.DERAbstractStructured=function(e){u.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(e){this.hTLV=null,this.isModified=!0,this.asn1Array=e},this.appendASN1Object=function(e){this.hTLV=null,this.isModified=!0,this.asn1Array.push(e)},this.asn1Array=new Array,void 0!==e&&void 0!==e.array&&(this.asn1Array=e.array)},c.lang.extend(u.asn1.DERAbstractStructured,u.asn1.ASN1Object),u.asn1.DERBoolean=function(e){u.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=0==e?"010100":"0101ff"},c.lang.extend(u.asn1.DERBoolean,u.asn1.ASN1Object),u.asn1.DERInteger=function(e){u.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(e){this.hTLV=null,this.isModified=!0,this.hV=u.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e)},this.setByInteger=function(e){var t=new h(String(e),10);this.setByBigInteger(t)},this.setValueHex=function(e){this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.bigint?this.setByBigInteger(e.bigint):void 0!==e.int?this.setByInteger(e.int):"number"==typeof e?this.setByInteger(e):void 0!==e.hex&&this.setValueHex(e.hex))},c.lang.extend(u.asn1.DERInteger,u.asn1.ASN1Object),u.asn1.DERBitString=function(e){if(void 0!==e&&void 0!==e.obj){var t=u.asn1.ASN1Util.newObject(e.obj);e.hex="00"+t.getEncodedHex()}u.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(e){this.hTLV=null,this.isModified=!0,this.hV=e},this.setUnusedBitsAndHexValue=function(e,t){if(e<0||7<e)throw"unused bits shall be from 0 to 7: u = "+e;var i="0"+e;this.hTLV=null,this.isModified=!0,this.hV=i+t},this.setByBinaryString=function(e){var t=8-(e=e.replace(/0+$/,"")).length%8;8==t&&(t=0);for(var i=0;i<=t;i++)e+="0";var n="";for(i=0;i<e.length-1;i+=8){var r=e.substr(i,8),o=parseInt(r,2).toString(16);1==o.length&&(o="0"+o),n+=o}this.hTLV=null,this.isModified=!0,this.hV="0"+t+n},this.setByBooleanArray=function(e){for(var t="",i=0;i<e.length;i++)1==e[i]?t+="1":t+="0";this.setByBinaryString(t)},this.newFalseArray=function(e){for(var t=new Array(e),i=0;i<e;i++)t[i]=!1;return t},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e&&e.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(e):void 0!==e.hex?this.setHexValueIncludingUnusedBits(e.hex):void 0!==e.bin?this.setByBinaryString(e.bin):void 0!==e.array&&this.setByBooleanArray(e.array))},c.lang.extend(u.asn1.DERBitString,u.asn1.ASN1Object),u.asn1.DEROctetString=function(e){if(void 0!==e&&void 0!==e.obj){var t=u.asn1.ASN1Util.newObject(e.obj);e.hex=t.getEncodedHex()}u.asn1.DEROctetString.superclass.constructor.call(this,e),this.hT="04"},c.lang.extend(u.asn1.DEROctetString,u.asn1.DERAbstractString),u.asn1.DERNull=function(){u.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},c.lang.extend(u.asn1.DERNull,u.asn1.ASN1Object),u.asn1.DERObjectIdentifier=function(e){u.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueOidString=function(e){var t=function(e){var t=function(e){var t=e.toString(16);return 1==t.length&&(t="0"+t),t},i=function(e){var i="",n=parseInt(e,10).toString(2),r=7-n.length%7;7==r&&(r=0);for(var o="",s=0;s<r;s++)o+="0";for(n=o+n,s=0;s<n.length-1;s+=7){var a=n.substr(s,7);s!=n.length-7&&(a="1"+a),i+=t(parseInt(a,2))}return i};try{if(!e.match(/^[0-9.]+$/))return null;var n="",r=e.split("."),o=40*parseInt(r[0],10)+parseInt(r[1],10);n+=t(o),r.splice(0,2);for(var s=0;s<r.length;s++)n+=i(r[s]);return n}catch(e){return null}}(e);if(null==t)throw new Error("malformed oid string: "+e);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueName=function(e){var t=u.asn1.x509.OID.name2oid(e);if(""===t)throw new Error("DERObjectIdentifier oidName undefined: "+e);this.setValueOidString(t)},this.setValueNameOrOid=function(e){e.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(e):this.setValueName(e)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(e){"string"==typeof e?this.setValueNameOrOid(e):void 0!==e.oid?this.setValueNameOrOid(e.oid):void 0!==e.name?this.setValueNameOrOid(e.name):void 0!==e.hex&&this.setValueHex(e.hex)},void 0!==e&&this.setByParam(e)},c.lang.extend(u.asn1.DERObjectIdentifier,u.asn1.ASN1Object),u.asn1.DEREnumerated=function(e){u.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(e){this.hTLV=null,this.isModified=!0,this.hV=u.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e)},this.setByInteger=function(e){var t=new h(String(e),10);this.setByBigInteger(t)},this.setValueHex=function(e){this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.int?this.setByInteger(e.int):"number"==typeof e?this.setByInteger(e):void 0!==e.hex&&this.setValueHex(e.hex))},c.lang.extend(u.asn1.DEREnumerated,u.asn1.ASN1Object),u.asn1.DERUTF8String=function(e){u.asn1.DERUTF8String.superclass.constructor.call(this,e),this.hT="0c"},c.lang.extend(u.asn1.DERUTF8String,u.asn1.DERAbstractString),u.asn1.DERNumericString=function(e){u.asn1.DERNumericString.superclass.constructor.call(this,e),this.hT="12"},c.lang.extend(u.asn1.DERNumericString,u.asn1.DERAbstractString),u.asn1.DERPrintableString=function(e){u.asn1.DERPrintableString.superclass.constructor.call(this,e),this.hT="13"},c.lang.extend(u.asn1.DERPrintableString,u.asn1.DERAbstractString),u.asn1.DERTeletexString=function(e){u.asn1.DERTeletexString.superclass.constructor.call(this,e),this.hT="14"},c.lang.extend(u.asn1.DERTeletexString,u.asn1.DERAbstractString),u.asn1.DERIA5String=function(e){u.asn1.DERIA5String.superclass.constructor.call(this,e),this.hT="16"},c.lang.extend(u.asn1.DERIA5String,u.asn1.DERAbstractString),u.asn1.DERVisibleString=function(e){u.asn1.DERIA5String.superclass.constructor.call(this,e),this.hT="1a"},c.lang.extend(u.asn1.DERVisibleString,u.asn1.DERAbstractString),u.asn1.DERBMPString=function(e){u.asn1.DERBMPString.superclass.constructor.call(this,e),this.hT="1e"},c.lang.extend(u.asn1.DERBMPString,u.asn1.DERAbstractString),u.asn1.DERUTCTime=function(e){u.asn1.DERUTCTime.superclass.constructor.call(this,e),this.hT="17",this.setByDate=function(e){this.hTLV=null,this.isModified=!0,this.date=e,this.s=this.formatDate(this.date,"utc"),this.hV=J(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=J(this.s)),this.hV},void 0!==e&&(void 0!==e.str?this.setString(e.str):"string"==typeof e&&e.match(/^[0-9]{12}Z$/)?this.setString(e):void 0!==e.hex?this.setStringHex(e.hex):void 0!==e.date&&this.setByDate(e.date))},c.lang.extend(u.asn1.DERUTCTime,u.asn1.DERAbstractTime),u.asn1.DERGeneralizedTime=function(e){u.asn1.DERGeneralizedTime.superclass.constructor.call(this,e),this.hT="18",this.withMillis=!1,this.setByDate=function(e){this.hTLV=null,this.isModified=!0,this.date=e,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=J(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=J(this.s)),this.hV},void 0!==e&&(void 0!==e.str?this.setString(e.str):"string"==typeof e&&e.match(/^[0-9]{14}Z$/)?this.setString(e):void 0!==e.hex?this.setStringHex(e.hex):void 0!==e.date&&this.setByDate(e.date),!0===e.millis&&(this.withMillis=!0))},c.lang.extend(u.asn1.DERGeneralizedTime,u.asn1.DERAbstractTime),u.asn1.DERSequence=function(e){u.asn1.DERSequence.superclass.constructor.call(this,e),this.hT="30",this.getFreshValueHex=function(){for(var e="",t=0;t<this.asn1Array.length;t++){e+=this.asn1Array[t].getEncodedHex()}return this.hV=e,this.hV}},c.lang.extend(u.asn1.DERSequence,u.asn1.DERAbstractStructured),u.asn1.DERSet=function(e){u.asn1.DERSet.superclass.constructor.call(this,e),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var e=new Array,t=0;t<this.asn1Array.length;t++){var i=this.asn1Array[t];e.push(i.getEncodedHex())}return 1==this.sortFlag&&e.sort(),this.hV=e.join(""),this.hV},void 0!==e&&void 0!==e.sortflag&&0==e.sortflag&&(this.sortFlag=!1)},c.lang.extend(u.asn1.DERSet,u.asn1.DERAbstractStructured),u.asn1.DERTaggedObject=function(e){u.asn1.DERTaggedObject.superclass.constructor.call(this);var t=u.asn1;this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(e,t,i){this.hT=t,this.isExplicit=e,this.asn1Object=i,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=i.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,t),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(e){null!=e.tag&&(this.hT=e.tag),null!=e.explicit&&(this.isExplicit=e.explicit),null!=e.tage&&(this.hT=e.tage,this.isExplicit=!0),null!=e.tagi&&(this.hT=e.tagi,this.isExplicit=!1),null!=e.obj&&(e.obj instanceof t.ASN1Object?(this.asn1Object=e.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)):"object"==typeof e.obj&&(this.asn1Object=t.ASN1Util.newObject(e.obj),this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},null!=e&&this.setByParam(e)},c.lang.extend(u.asn1.DERTaggedObject,u.asn1.ASN1Object);var Te=new function(){};function xe(e,t){for(var i="",n=t/4-e.length,r=0;r<n;r++)i+="0";return i+e}function Ee(e,t,i){for(var n="",r=0;n.length<t;)n+=re(i(oe(e+String.fromCharCode.apply(String,[(4278190080&r)>>24,(16711680&r)>>16,(65280&r)>>8,255&r])))),r+=1;return n}function je(e){for(var t in u.crypto.Util.DIGESTINFOHEAD){var i=u.crypto.Util.DIGESTINFOHEAD[t],n=i.length;if(e.substring(0,n)==i)return[t,e.substring(n)]}return[]}function ze(e){var t,i=Te,n=i.getChildIdx,r=i.getV,o=i.getTLV,s=i.getVbyList,a=i.getVbyListEx,c=i.getTLVbyList,l=i.getTLVbyListEx,h=i.getIdxbyList,d=i.getIdxbyListEx,p=i.getVidx,A=i.getInt,f=i.oidname,M=i.hextooidstr,g=ue;try{t=u.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV}catch(e){}this.HEX2STAG={"0c":"utf8",13:"prn",16:"ia5","1a":"vis","1e":"bmp"},this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){if(null===this.hex||0!==this.version)return this.version;var e=c(this.hex,0,[0,0]);if("a0"==e.substr(0,2)){var t=c(e,0,[0]),i=A(t,0);if(i<0||2<i)throw new Error("malformed version field");return this.version=i+1,this.version}return this.version=1,this.foffset=-1,1},this.getSerialNumberHex=function(){return a(this.hex,0,[0,0],"02")},this.getSignatureAlgorithmField=function(){var e=l(this.hex,0,[0,1]);return this.getAlgorithmIdentifierName(e)},this.getAlgorithmIdentifierName=function(e){for(var i in t)if(e===t[i])return i;return f(a(e,0,[0],"06"))},this.getIssuer=function(){return this.getX500Name(this.getIssuerHex())},this.getIssuerHex=function(){return c(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return this.getIssuer().str},this.getSubject=function(){return this.getX500Name(this.getSubjectHex())},this.getSubjectHex=function(){return c(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return this.getSubject().str},this.getNotBefore=function(){var e=s(this.hex,0,[0,4+this.foffset,0]);return e=e.replace(/(..)/g,"%$1"),e=decodeURIComponent(e)},this.getNotAfter=function(){var e=s(this.hex,0,[0,4+this.foffset,1]);return e=e.replace(/(..)/g,"%$1"),e=decodeURIComponent(e)},this.getPublicKeyHex=function(){return i.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return h(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var e=this.getPublicKeyIdx();return h(this.hex,e,[1,0],"30")},this.getPublicKey=function(){return we.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){var e=c(this.hex,0,[1],"30");return this.getAlgorithmIdentifierName(e)},this.getSignatureValueHex=function(){return s(this.hex,0,[2],"03",!0)},this.verifySignature=function(e){var t=this.getSignatureAlgorithmField(),i=this.getSignatureValueHex(),n=c(this.hex,0,[0],"30"),r=new u.crypto.Signature({alg:t});return r.init(e),r.updateHex(n),r.verify(i)},this.parseExt=function(e){var t,o,a;if(void 0===e){if(a=this.hex,3!==this.version)return-1;t=h(a,0,[0,7,0],"30"),o=n(a,t)}else{a=ue(e);var u=h(a,0,[0,3,0,0],"06");if("2a864886f70d01090e"!=r(a,u))return void(this.aExtInfo=new Array);t=h(a,0,[0,3,0,1,0],"30"),o=n(a,t),this.hex=a}this.aExtInfo=new Array;for(var c=0;c<o.length;c++){var l={critical:!1},d=0;3===n(a,o[c]).length&&(l.critical=!0,d=1),l.oid=i.hextooidstr(s(a,o[c],[0],"06"));var A=h(a,o[c],[1+d]);l.vidx=p(a,A),this.aExtInfo.push(l)}},this.getExtInfo=function(e){var t=this.aExtInfo,i=e;if(e.match(/^[0-9.]+$/)||(i=u.asn1.x509.OID.name2oid(e)),""!==i)for(var n=0;n<t.length;n++)if(t[n].oid===i)return t[n]},this.getExtBasicConstraints=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("basicConstraints");if(void 0===i)return;e=o(this.hex,i.vidx),t=i.critical}var n={extname:"basicConstraints"};if(t&&(n.critical=!0),"3000"===e)return n;if("30030101ff"===e)return n.cA=!0,n;if("30060101ff02"===e.substr(0,12)){var s=r(e,10),a=parseInt(s,16);return n.cA=!0,n.pathLen=a,n}throw new Error("hExtV parse error: "+e)},this.getExtKeyUsage=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("keyUsage");if(void 0===i)return;e=o(this.hex,i.vidx),t=i.critical}var n={extname:"keyUsage"};return t&&(n.critical=!0),n.names=this.getExtKeyUsageString(e).split(","),n},this.getExtKeyUsageBin=function(e){if(void 0===e){var t=this.getExtInfo("keyUsage");if(void 0===t)return"";e=o(this.hex,t.vidx)}if(8!=e.length&&10!=e.length)throw new Error("malformed key usage value: "+e);var i="000000000000000"+parseInt(e.substr(6),16).toString(2);return 8==e.length&&(i=i.slice(-8)),10==e.length&&(i=i.slice(-16)),""==(i=i.replace(/0+$/,""))&&(i="0"),i},this.getExtKeyUsageString=function(e){for(var t=this.getExtKeyUsageBin(e),i=new Array,n=0;n<t.length;n++)"1"==t.substr(n,1)&&i.push(ze.KEYUSAGE_NAME[n]);return i.join(",")},this.getExtSubjectKeyIdentifier=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("subjectKeyIdentifier");if(void 0===i)return;e=o(this.hex,i.vidx),t=i.critical}var n={extname:"subjectKeyIdentifier"};t&&(n.critical=!0);var s=r(e,0);return n.kid={hex:s},n},this.getExtAuthorityKeyIdentifier=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("authorityKeyIdentifier");if(void 0===i)return;e=o(this.hex,i.vidx),t=i.critical}var s={extname:"authorityKeyIdentifier"};t&&(s.critical=!0);for(var a=n(e,0),u=0;u<a.length;u++){var c=e.substr(a[u],2);if("80"===c&&(s.kid={hex:r(e,a[u])}),"a1"===c){var l=o(e,a[u]),h=this.getGeneralNames(l);s.issuer=h[0].dn}"82"===c&&(s.sn={hex:r(e,a[u])})}return s},this.getExtExtKeyUsage=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("extKeyUsage");if(void 0===i)return;e=o(this.hex,i.vidx),t=i.critical}var s={extname:"extKeyUsage",array:[]};t&&(s.critical=!0);for(var a=n(e,0),u=0;u<a.length;u++)s.array.push(f(r(e,a[u])));return s},this.getExtExtKeyUsageName=function(){var e=this.getExtInfo("extKeyUsage");if(void 0===e)return e;var t=new Array,i=o(this.hex,e.vidx);if(""===i)return t;for(var s=n(i,0),a=0;a<s.length;a++)t.push(f(r(i,s[a])));return t},this.getExtSubjectAltName=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("subjectAltName");if(void 0===i)return;e=o(this.hex,i.vidx),t=i.critical}var n={extname:"subjectAltName",array:[]};return t&&(n.critical=!0),n.array=this.getGeneralNames(e),n},this.getExtIssuerAltName=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("issuerAltName");if(void 0===i)return;e=o(this.hex,i.vidx),t=i.critical}var n={extname:"issuerAltName",array:[]};return t&&(n.critical=!0),n.array=this.getGeneralNames(e),n},this.getGeneralNames=function(e){for(var t=n(e,0),i=[],r=0;r<t.length;r++){var s=this.getGeneralName(o(e,t[r]));void 0!==s&&i.push(s)}return i},this.getGeneralName=function(e){var t=e.substr(0,2),i=r(e,0),n=re(i);return"81"==t?{rfc822:n}:"82"==t?{dns:n}:"86"==t?{uri:n}:"87"==t?{ip:ce(i)}:"a4"==t?{dn:this.getX500Name(i)}:void 0},this.getExtSubjectAltName2=function(){var e,t,i,s=this.getExtInfo("subjectAltName");if(void 0===s)return s;for(var a=new Array,u=o(this.hex,s.vidx),c=n(u,0),l=0;l<c.length;l++)i=u.substr(c[l],2),e=r(u,c[l]),"81"===i&&(t=ne(e),a.push(["MAIL",t])),"82"===i&&(t=ne(e),a.push(["DNS",t])),"84"===i&&(t=ze.hex2dn(e,0),a.push(["DN",t])),"86"===i&&(t=ne(e),a.push(["URI",t])),"87"===i&&(t=ce(e),a.push(["IP",t]));return a},this.getExtCRLDistributionPoints=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("cRLDistributionPoints");if(void 0===i)return;e=o(this.hex,i.vidx),t=i.critical}var r={extname:"cRLDistributionPoints",array:[]};t&&(r.critical=!0);for(var s=n(e,0),a=0;a<s.length;a++){var u=o(e,s[a]);r.array.push(this.getDistributionPoint(u))}return r},this.getDistributionPoint=function(e){for(var t={},i=n(e,0),r=0;r<i.length;r++){var s=e.substr(i[r],2),a=o(e,i[r]);"a0"==s&&(t.dpname=this.getDistributionPointName(a))}return t},this.getDistributionPointName=function(e){for(var t={},i=n(e,0),r=0;r<i.length;r++){var s=e.substr(i[r],2),a=o(e,i[r]);"a0"==s&&(t.full=this.getGeneralNames(a))}return t},this.getExtCRLDistributionPointsURI=function(){var e=this.getExtInfo("cRLDistributionPoints");if(void 0===e)return e;for(var t=new Array,i=n(this.hex,e.vidx),r=0;r<i.length;r++)try{var o=ne(s(this.hex,i[r],[0,0,0],"86"));t.push(o)}catch(e){}return t},this.getExtAIAInfo=function(){var e=this.getExtInfo("authorityInfoAccess");if(void 0===e)return e;for(var t={ocsp:[],caissuer:[]},i=n(this.hex,e.vidx),r=0;r<i.length;r++){var o=s(this.hex,i[r],[0],"06"),a=s(this.hex,i[r],[1],"86");"2b06010505073001"===o&&t.ocsp.push(ne(a)),"2b06010505073002"===o&&t.caissuer.push(ne(a))}return t},this.getExtAuthorityInfoAccess=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("authorityInfoAccess");if(void 0===i)return;e=o(this.hex,i.vidx),t=i.critical}var r={extname:"authorityInfoAccess",array:[]};t&&(r.critical=!0);for(var u=n(e,0),c=0;c<u.length;c++){var l=a(e,u[c],[0],"06"),h=ne(s(e,u[c],[1],"86"));if("2b06010505073001"==l)r.array.push({ocsp:h});else{if("2b06010505073002"!=l)throw new Error("unknown method: "+l);r.array.push({caissuer:h})}}return r},this.getExtCertificatePolicies=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("certificatePolicies");if(void 0===i)return;e=o(this.hex,i.vidx),t=i.critical}var r={extname:"certificatePolicies",array:[]};t&&(r.critical=!0);for(var s=n(e,0),a=0;a<s.length;a++){var u=o(e,s[a]),c=this.getPolicyInformation(u);r.array.push(c)}return r},this.getPolicyInformation=function(e){var t={},i=s(e,0,[0],"06");t.policyoid=f(i);var r=d(e,0,[1],"30");if(-1!=r){t.array=[];for(var a=n(e,r),u=0;u<a.length;u++){var c=o(e,a[u]),l=this.getPolicyQualifierInfo(c);t.array.push(l)}}return t},this.getPolicyQualifierInfo=function(e){var t={},i=s(e,0,[0],"06");if("2b06010505070201"===i){var n=a(e,0,[1],"16");t.cps=re(n)}else if("2b06010505070202"===i){var r=c(e,0,[1],"30");t.unotice=this.getUserNotice(r)}return t},this.getUserNotice=function(e){for(var t={},i=n(e,0),r=0;r<i.length;r++){var s=o(e,i[r]);"30"!=s.substr(0,2)&&(t.exptext=this.getDisplayText(s))}return t},this.getDisplayText=function(e){var t={};return t.type={"0c":"utf8",16:"ia5","1a":"vis","1e":"bmp"}[e.substr(0,2)],t.str=re(r(e,0)),t},this.getExtCRLNumber=function(e,t){var i={extname:"cRLNumber"};if(t&&(i.critical=!0),"02"==e.substr(0,2))return i.num={hex:r(e,0)},i;throw new Error("hExtV parse error: "+e)},this.getExtCRLReason=function(e,t){var i={extname:"cRLReason"};if(t&&(i.critical=!0),"0a"==e.substr(0,2))return i.code=parseInt(r(e,0),16),i;throw new Error("hExtV parse error: "+e)},this.getExtOcspNonce=function(e,t){var i={extname:"ocspNonce"};t&&(i.critical=!0);var n=r(e,0);return i.hex=n,i},this.getExtOcspNoCheck=function(e,t){var i={extname:"ocspNoCheck"};return t&&(i.critical=!0),i},this.getExtAdobeTimeStamp=function(e,t){if(void 0===e&&void 0===t){var i=this.getExtInfo("adobeTimeStamp");if(void 0===i)return;e=o(this.hex,i.vidx),t=i.critical}var r={extname:"adobeTimeStamp"};t&&(r.critical=!0);var s=n(e,0);if(s.length>1){var a=o(e,s[1]),u=this.getGeneralName(a);null!=u.uri&&(r.uri=u.uri)}if(s.length>2){var c=o(e,s[2]);"0101ff"==c&&(r.reqauth=!0),"010100"==c&&(r.reqauth=!1)}return r},this.getX500NameRule=function(e){for(var t=null,i=[],n=0;n<e.length;n++)for(var r=e[n],o=0;o<r.length;o++)i.push(r[o]);for(n=0;n<i.length;n++){var s=i[n],a=s.ds,c=s.value,l=s.type;if("prn"!=a&&"utf8"!=a&&"ia5"!=a)return"mixed";if("ia5"==a){if("CN"!=l)return"mixed";if(u.lang.String.isMail(c))continue;return"mixed"}if("C"==l){if("prn"==a)continue;return"mixed"}if(null==t)t=a;else if(t!==a)return"mixed"}return null==t?"prn":t},this.getX500Name=function(e){var t=this.getX500NameArray(e);return{array:t,str:this.dnarraytostr(t)}},this.getX500NameArray=function(e){for(var t=[],i=n(e,0),r=0;r<i.length;r++)t.push(this.getRDN(o(e,i[r])));return t},this.getRDN=function(e){for(var t=[],i=n(e,0),r=0;r<i.length;r++)t.push(this.getAttrTypeAndValue(o(e,i[r])));return t},this.getAttrTypeAndValue=function(e){var t={type:null,value:null,ds:null},i=n(e,0),r=s(e,i[0],[],"06"),o=s(e,i[1],[]),a=u.asn1.ASN1Util.oidHexToInt(r);return t.type=u.asn1.x509.OID.oid2atype(a),t.ds=this.HEX2STAG[e.substr(i[1],2)],"bmp"!=t.ds?t.value=ne(o):t.value=le(o),t},this.readCertPEM=function(e){this.readCertHex(g(e))},this.readCertHex=function(e){this.hex=e,this.getVersion();try{h(this.hex,0,[0,7],"a3"),this.parseExt()}catch(e){}},this.getParam=function(){var e={};return e.version=this.getVersion(),e.serial={hex:this.getSerialNumberHex()},e.sigalg=this.getSignatureAlgorithmField(),e.issuer=this.getIssuer(),e.notbefore=this.getNotBefore(),e.notafter=this.getNotAfter(),e.subject=this.getSubject(),e.sbjpubkey=ae(this.getPublicKeyHex(),"PUBLIC KEY"),this.aExtInfo.length>0&&(e.ext=this.getExtParamArray()),e.sighex=this.getSignatureValueHex(),e},this.getExtParamArray=function(e){null==e&&(-1!=d(this.hex,0,[0,"[3]"])&&(e=l(this.hex,0,[0,"[3]",0],"30")));for(var t=[],i=n(e,0),r=0;r<i.length;r++){var s=o(e,i[r]),a=this.getExtParam(s);null!=a&&t.push(a)}return t},this.getExtParam=function(e){var t=n(e,0).length;if(2!=t&&3!=t)throw new Error("wrong number elements in Extension: "+t+" "+e);var i=M(s(e,0,[0],"06")),r=!1;3==t&&"0101ff"==c(e,0,[1])&&(r=!0);var o=c(e,0,[t-1,0]),a=void 0;if("2.5.29.14"==i?a=this.getExtSubjectKeyIdentifier(o,r):"2.5.29.15"==i?a=this.getExtKeyUsage(o,r):"2.5.29.17"==i?a=this.getExtSubjectAltName(o,r):"2.5.29.18"==i?a=this.getExtIssuerAltName(o,r):"2.5.29.19"==i?a=this.getExtBasicConstraints(o,r):"2.5.29.31"==i?a=this.getExtCRLDistributionPoints(o,r):"2.5.29.32"==i?a=this.getExtCertificatePolicies(o,r):"2.5.29.35"==i?a=this.getExtAuthorityKeyIdentifier(o,r):"2.5.29.37"==i?a=this.getExtExtKeyUsage(o,r):"1.3.6.1.5.5.7.1.1"==i?a=this.getExtAuthorityInfoAccess(o,r):"2.5.29.20"==i?a=this.getExtCRLNumber(o,r):"2.5.29.21"==i?a=this.getExtCRLReason(o,r):"1.3.6.1.5.5.7.48.1.2"==i?a=this.getExtOcspNonce(o,r):"1.3.6.1.5.5.7.48.1.5"==i?a=this.getExtOcspNoCheck(o,r):"1.2.840.113583.1.1.9.1"==i&&(a=this.getExtAdobeTimeStamp(o,r)),null!=a)return a;var u={extname:i,extn:o};return r&&(u.critical=!0),u},this.findExt=function(e,t){for(var i=0;i<e.length;i++)if(e[i].extname==t)return e[i];return null},this.updateExtCDPFullURI=function(e,t){var i=this.findExt(e,"cRLDistributionPoints");if(null!=i&&null!=i.array)for(var n=i.array,r=0;r<n.length;r++)if(null!=n[r].dpname&&null!=n[r].dpname.full)for(var o=n[r].dpname.full,s=0;s<o.length;s++){var a=o[r];null!=a.uri&&(a.uri=t)}},this.updateExtAIAOCSP=function(e,t){var i=this.findExt(e,"authorityInfoAccess");if(null!=i&&null!=i.array)for(var n=i.array,r=0;r<n.length;r++)null!=n[r].ocsp&&(n[r].ocsp=t)},this.updateExtAIACAIssuer=function(e,t){var i=this.findExt(e,"authorityInfoAccess");if(null!=i&&null!=i.array)for(var n=i.array,r=0;r<n.length;r++)null!=n[r].caissuer&&(n[r].caissuer=t)},this.dnarraytostr=function(e){return"/"+e.map((function(e){return function(e){return e.map((function(e){return function(e){return e.type+"="+e.value}(e).replace(/\+/,"\\+")})).join("+")}(e).replace(/\//,"\\/")})).join("/")},this.getInfo=function(){var e,t,i,n,r=function(e){for(var t="",i=e.array,n=0;n<i.length;n++){var r=i[n];if(t+=" policy oid: "+r.policyoid+"\n",void 0!==r.array)for(var o=0;o<r.array.length;o++){var s=r.array[o];void 0!==s.cps&&(t+=" cps: "+s.cps+"\n")}}return t},o=function(e){for(var t="",i=e.array,n=0;n<i.length;n++){var r=i[n];try{void 0!==r.dpname.full[0].uri&&(t+=" "+r.dpname.full[0].uri+"\n")}catch(e){}try{void 0!==r.dname.full[0].dn.hex&&(t+=" "+ze.hex2dn(r.dpname.full[0].dn.hex)+"\n")}catch(e){}}return t},s=function(e){for(var t="",i=e.array,n=0;n<i.length;n++){var r=i[n];void 0!==r.caissuer&&(t+=" caissuer: "+r.caissuer+"\n"),void 0!==r.ocsp&&(t+=" ocsp: "+r.ocsp+"\n")}return t};if(e="Basic Fields\n",e+=" serial number: "+this.getSerialNumberHex()+"\n",e+=" signature algorithm: "+this.getSignatureAlgorithmField()+"\n",e+=" issuer: "+this.getIssuerString()+"\n",e+=" notBefore: "+this.getNotBefore()+"\n",e+=" notAfter: "+this.getNotAfter()+"\n",e+=" subject: "+this.getSubjectString()+"\n",e+=" subject public key info: \n",e+=" key algorithm: "+(t=this.getPublicKey()).type+"\n","RSA"===t.type&&(e+=" n="+de(t.n.toString(16)).substr(0,16)+"...\n",e+=" e="+de(t.e.toString(16))+"\n"),null!=(i=this.aExtInfo)){e+="X509v3 Extensions:\n";for(var a=0;a<i.length;a++){var c=i[a],l=u.asn1.x509.OID.oid2name(c.oid);""===l&&(l=c.oid);var h="";if(!0===c.critical&&(h="CRITICAL"),e+=" "+l+" "+h+":\n","basicConstraints"===l){var d=this.getExtBasicConstraints();void 0===d.cA?e+=" {}\n":(e+=" cA=true",void 0!==d.pathLen&&(e+=", pathLen="+d.pathLen),e+="\n")}else if("keyUsage"===l)e+=" "+this.getExtKeyUsageString()+"\n";else if("subjectKeyIdentifier"===l)e+=" "+this.getExtSubjectKeyIdentifier().kid.hex+"\n";else if("authorityKeyIdentifier"===l){var p=this.getExtAuthorityKeyIdentifier();void 0!==p.kid&&(e+=" kid="+p.kid.hex+"\n")}else{if("extKeyUsage"===l)e+=" "+this.getExtExtKeyUsage().array.join(", ")+"\n";else if("subjectAltName"===l)e+=" "+(n=this.getExtSubjectAltName(),JSON.stringify(n.array).replace(/[\[\]\{\}\"]/g,""))+"\n";else if("cRLDistributionPoints"===l)e+=o(this.getExtCRLDistributionPoints());else if("authorityInfoAccess"===l)e+=s(this.getExtAuthorityInfoAccess());else"certificatePolicies"===l&&(e+=r(this.getExtCertificatePolicies()))}}}return e+="signature algorithm: "+this.getSignatureAlgorithmName()+"\n",e+="signature: "+this.getSignatureValueHex().substr(0,16)+"...\n"},"string"==typeof e&&(-1!=e.indexOf("-----BEGIN")?this.readCertPEM(e):u.lang.String.isHex(e)&&this.readCertHex(e))}function Ie(e){return l.SHA256(e).toString()}Te.getLblen=function(e,t){if("8"!=e.substr(t+2,1))return 1;var i=parseInt(e.substr(t+3,1));return 0==i?-1:0<i&&i<10?i+1:-2},Te.getL=function(e,t){var i=Te.getLblen(e,t);return i<1?"":e.substr(t+2,2*i)},Te.getVblen=function(e,t){var i;return""==(i=Te.getL(e,t))?-1:("8"===i.substr(0,1)?new h(i.substr(2),16):new h(i,16)).intValue()},Te.getVidx=function(e,t){var i=Te.getLblen(e,t);return i<0?i:t+2*(i+1)},Te.getV=function(e,t){var i=Te.getVidx(e,t),n=Te.getVblen(e,t);return e.substr(i,2*n)},Te.getTLV=function(e,t){return e.substr(t,2)+Te.getL(e,t)+Te.getV(e,t)},Te.getTLVblen=function(e,t){return 2+2*Te.getLblen(e,t)+2*Te.getVblen(e,t)},Te.getNextSiblingIdx=function(e,t){return Te.getVidx(e,t)+2*Te.getVblen(e,t)},Te.getChildIdx=function(e,t){var i,n,r,o=Te,s=[];i=o.getVidx(e,t),n=2*o.getVblen(e,t),"03"==e.substr(t,2)&&(i+=2,n-=2),r=0;for(var a=i;r<=n;){var u=o.getTLVblen(e,a);if((r+=u)<=n&&s.push(a),a+=u,r>=n)break}return s},Te.getNthChildIdx=function(e,t,i){return Te.getChildIdx(e,t)[i]},Te.getIdxbyList=function(e,t,i,n){var r,o,s=Te;return 0==i.length?void 0!==n&&e.substr(t,2)!==n?-1:t:(r=i.shift())>=(o=s.getChildIdx(e,t)).length?-1:s.getIdxbyList(e,o[r],i,n)},Te.getIdxbyListEx=function(e,t,i,n){var r,o,s=Te;if(0==i.length)return void 0!==n&&e.substr(t,2)!==n?-1:t;r=i.shift(),o=s.getChildIdx(e,t);for(var a=0,u=0;u<o.length;u++){var c=e.substr(o[u],2);if("number"==typeof r&&!s.isContextTag(c)&&a==r||"string"==typeof r&&s.isContextTag(c,r))return s.getIdxbyListEx(e,o[u],i,n);s.isContextTag(c)||a++}return-1},Te.getTLVbyList=function(e,t,i,n){var r=Te,o=r.getIdxbyList(e,t,i,n);return-1==o||o>=e.length?null:r.getTLV(e,o)},Te.getTLVbyListEx=function(e,t,i,n){var r=Te,o=r.getIdxbyListEx(e,t,i,n);return-1==o?null:r.getTLV(e,o)},Te.getVbyList=function(e,t,i,n,r){var o,s,a=Te;return-1==(o=a.getIdxbyList(e,t,i,n))||o>=e.length?null:(s=a.getV(e,o),!0===r&&(s=s.substr(2)),s)},Te.getVbyListEx=function(e,t,i,n,r){var o,s,a=Te;return-1==(o=a.getIdxbyListEx(e,t,i,n))?null:(s=a.getV(e,o),"03"==e.substr(o,2)&&!1!==r&&(s=s.substr(2)),s)},Te.getInt=function(e,t,i){null==i&&(i=-1);try{var n=e.substr(t,2);if("02"!=n&&"03"!=n)return i;var r=Te.getV(e,t);return"02"==n?parseInt(r,16):function(e){try{var t=e.substr(0,2);if("00"==t)return parseInt(e.substr(2),16);var i=parseInt(t,16),n=e.substr(2),r=parseInt(n,16).toString(2);return"0"==r&&(r="00000000"),r=r.slice(0,0-i),parseInt(r,2)}catch(e){return-1}}(r)}catch(e){return i}},Te.getOID=function(e,t,i){null==i&&(i=null);try{return"06"!=e.substr(t,2)?i:function(e){if(!he(e))return null;try{var t=[],i=e.substr(0,2),n=parseInt(i,16);t[0]=new String(Math.floor(n/40)),t[1]=new String(n%40);for(var r=e.substr(2),o=[],s=0;s<r.length/2;s++)o.push(parseInt(r.substr(2*s,2),16));var a=[],u="";for(s=0;s<o.length;s++)128&o[s]?u+=pe((127&o[s]).toString(2),7):(u+=pe((127&o[s]).toString(2),7),a.push(new String(parseInt(u,2))),u="");var c=t.join(".");return a.length>0&&(c=c+"."+a.join(".")),c}catch(e){return null}}(Te.getV(e,t))}catch(e){return i}},Te.getOIDName=function(e,t,i){null==i&&(i=null);try{var n=Te.getOID(e,t,i);if(n==i)return i;var r=u.asn1.x509.OID.oid2name(n);return""==r?n:r}catch(e){return i}},Te.getString=function(e,t,i){null==i&&(i=null);try{return re(Te.getV(e,t))}catch(e){return i}},Te.hextooidstr=function(e){var t=function(e,t){return e.length>=t?e:new Array(t-e.length+1).join("0")+e},i=[],n=e.substr(0,2),r=parseInt(n,16);i[0]=new String(Math.floor(r/40)),i[1]=new String(r%40);for(var o=e.substr(2),s=[],a=0;a<o.length/2;a++)s.push(parseInt(o.substr(2*a,2),16));var u=[],c="";for(a=0;a<s.length;a++)128&s[a]?c+=t((127&s[a]).toString(2),7):(c+=t((127&s[a]).toString(2),7),u.push(new String(parseInt(c,2))),c="");var l=i.join(".");return u.length>0&&(l=l+"."+u.join(".")),l},Te.dump=function(e,t,i,n){var r=Te,o=r.getV,s=r.dump,a=r.getChildIdx,c=e;e instanceof u.asn1.ASN1Object&&(c=e.getEncodedHex());var l=function(e,t){return e.length<=2*t?e:e.substr(0,t)+"..(total "+e.length/2+"bytes).."+e.substr(e.length-t,t)};void 0===t&&(t={ommit_long_octet:32}),void 0===i&&(i=0),void 0===n&&(n="");var h,d=t.ommit_long_octet;if("01"==(h=c.substr(i,2)))return"00"==(p=o(c,i))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==h)return n+"INTEGER "+l(p=o(c,i),d)+"\n";if("03"==h){var p=o(c,i);if(r.isASN1HEX(p.substr(2))){var A=n+"BITSTRING, encapsulates\n";return A+=s(p.substr(2),t,0,n+" ")}return n+"BITSTRING "+l(p,d)+"\n"}if("04"==h){p=o(c,i);if(r.isASN1HEX(p)){A=n+"OCTETSTRING, encapsulates\n";return A+=s(p,t,0,n+" ")}return n+"OCTETSTRING "+l(p,d)+"\n"}if("05"==h)return n+"NULL\n";if("06"==h){var f=o(c,i),M=u.asn1.ASN1Util.oidHexToInt(f),g=u.asn1.x509.OID.oid2name(M),y=M.replace(/\./g," ");return""!=g?n+"ObjectIdentifier "+g+" ("+y+")\n":n+"ObjectIdentifier ("+y+")\n"}if("0a"==h)return n+"ENUMERATED "+parseInt(o(c,i))+"\n";if("0c"==h)return n+"UTF8String '"+ne(o(c,i))+"'\n";if("13"==h)return n+"PrintableString '"+ne(o(c,i))+"'\n";if("14"==h)return n+"TeletexString '"+ne(o(c,i))+"'\n";if("16"==h)return n+"IA5String '"+ne(o(c,i))+"'\n";if("17"==h)return n+"UTCTime "+ne(o(c,i))+"\n";if("18"==h)return n+"GeneralizedTime "+ne(o(c,i))+"\n";if("1a"==h)return n+"VisualString '"+ne(o(c,i))+"'\n";if("1e"==h)return n+"BMPString '"+le(o(c,i))+"'\n";if("30"==h){if("3000"==c.substr(i,4))return n+"SEQUENCE {}\n";A=n+"SEQUENCE\n";var m=t;if((2==(D=a(c,i)).length||3==D.length)&&"06"==c.substr(D[0],2)&&"04"==c.substr(D[D.length-1],2)){g=r.oidname(o(c,D[0]));var v=JSON.parse(JSON.stringify(t));v.x509ExtName=g,m=v}for(var N=0;N<D.length;N++)A+=s(c,m,D[N],n+" ");return A}if("31"==h){A=n+"SET\n";var D=a(c,i);for(N=0;N<D.length;N++)A+=s(c,t,D[N],n+" ");return A}if(0!=(128&(h=parseInt(h,16)))){var w=31&h;if(0!=(32&h)){for(A=n+"["+w+"]\n",D=a(c,i),N=0;N<D.length;N++)A+=s(c,t,D[N],n+" ");return A}p=o(c,i);if(Te.isASN1HEX(p)){var A=n+"["+w+"]\n";return A+=s(p,t,0,n+" ")}return("68747470"==p.substr(0,8)||"subjectAltName"===t.x509ExtName&&2==w)&&(p=ne(p)),A=n+"["+w+"] "+p+"\n"}return n+"UNKNOWN("+h+") "+o(c,i)+"\n"},Te.isContextTag=function(e,t){var i,n;e=e.toLowerCase();try{i=parseInt(e,16)}catch(e){return-1}if(void 0===t)return 128==(192&i);try{return null!=t.match(/^\[[0-9]+\]$/)&&(!((n=parseInt(t.substr(1,t.length-1),10))>31)&&(128==(192&i)&&(31&i)==n))}catch(e){return!1}},Te.isASN1HEX=function(e){var t=Te;if(e.length%2==1)return!1;var i=t.getVblen(e,0),n=e.substr(0,2),r=t.getL(e,0);return e.length-n.length-r.length==2*i},Te.checkStrictDER=function(e,t,i,n,r){var o=Te;if(void 0===i){if("string"!=typeof e)throw new Error("not hex string");if(e=e.toLowerCase(),!u.lang.String.isHex(e))throw new Error("not hex string");i=e.length,r=(n=e.length/2)<128?1:Math.ceil(n.toString(16))+1}if(o.getL(e,t).length>2*r)throw new Error("L of TLV too long: idx="+t);var s=o.getVblen(e,t);if(s>n)throw new Error("value of L too long than hex: idx="+t);var a=o.getTLV(e,t),c=a.length-2-o.getL(e,t).length;if(c!==2*s)throw new Error("V string length and L's value not the same:"+c+"/"+2*s);if(0===t&&e.length!=a.length)throw new Error("total length and TLV length unmatch:"+e.length+"!="+a.length);var l=e.substr(t,2);if("02"===l){var h=o.getVidx(e,t);if("00"==e.substr(h,2)&&e.charCodeAt(h+2)<56)throw new Error("not least zeros for DER INTEGER")}if(32&parseInt(l,16)){for(var d=o.getVblen(e,t),p=0,A=o.getChildIdx(e,t),f=0;f<A.length;f++){p+=o.getTLV(e,A[f]).length,o.checkStrictDER(e,A[f],i,n,r)}if(2*d!=p)throw new Error("sum of children's TLV length and L unmatch: "+2*d+"!="+p)}},Te.oidname=function(e){var t=u.asn1;u.lang.String.isHex(e)&&(e=t.ASN1Util.oidHexToInt(e));var i=t.x509.OID.oid2name(e);return""===i&&(i=e),i},void 0!==u.asn1&&u.asn1||(u.asn1={}),void 0!==u.asn1.x509&&u.asn1.x509||(u.asn1.x509={}),u.asn1.x509.Certificate=function(e){u.asn1.x509.Certificate.superclass.constructor.call(this);var t=u.asn1,i=t.DERBitString,n=t.DERSequence,r=t.x509,o=r.TBSCertificate,s=r.AlgorithmIdentifier;this.params=void 0,this.setByParam=function(e){this.params=e},this.sign=function(){var e=this.params,t=e.sigalg;null!=e.sigalg.name&&(t=e.sigalg.name);var i=e.tbsobj.getEncodedHex(),n=new u.crypto.Signature({alg:t});n.init(e.cakey),n.updateHex(i),e.sighex=n.sign()},this.getPEM=function(){return ae(this.getEncodedHex(),"CERTIFICATE")},this.getEncodedHex=function(){var e=this.params;if(null!=e.tbsobj&&null!=e.tbsobj||(e.tbsobj=new o(e)),null==e.sighex&&null!=e.cakey&&this.sign(),null==e.sighex)throw new Error("sighex or cakey parameter not defined");var t=[];return t.push(e.tbsobj),t.push(new s({name:e.sigalg})),t.push(new i({hex:"00"+e.sighex})),new n({array:t}).getEncodedHex()},null!=e&&(this.params=e)},Ae(u.asn1.x509.Certificate,u.asn1.ASN1Object),u.asn1.x509.TBSCertificate=function(e){u.asn1.x509.TBSCertificate.superclass.constructor.call(this);var t=u.asn1,i=t.x509,n=t.DERTaggedObject,r=t.DERInteger,o=t.DERSequence,s=i.AlgorithmIdentifier,a=i.Time,c=i.X500Name,l=i.Extensions,h=i.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(e){this.params=e},this.getEncodedHex=function(){var e=[],t=this.params;if(null!=t.version||1!=t.version){var i=2;null!=t.version&&(i=t.version-1);var d=new n({obj:new r({int:i})});e.push(d)}return e.push(new r(t.serial)),e.push(new s({name:t.sigalg})),e.push(new c(t.issuer)),e.push(new o({array:[new a(t.notbefore),new a(t.notafter)]})),e.push(new c(t.subject)),e.push(new h(we.getKey(t.sbjpubkey))),void 0!==t.ext&&t.ext.length>0&&e.push(new n({tag:"a3",obj:new l(t.ext)})),new u.asn1.DERSequence({array:e}).getEncodedHex()},void 0!==e&&this.setByParam(e)},Ae(u.asn1.x509.TBSCertificate,u.asn1.ASN1Object),u.asn1.x509.Extensions=function(e){u.asn1.x509.Extensions.superclass.constructor.call(this);var t=u.asn1,i=t.DERSequence,n=t.x509;this.aParam=[],this.setByParam=function(e){this.aParam=e},this.getEncodedHex=function(){for(var e=[],t=0;t<this.aParam.length;t++){var r=this.aParam[t],o=r.extname,s=null;if(null!=r.extn)s=new n.PrivateExtension(r);else if("subjectKeyIdentifier"==o)s=new n.SubjectKeyIdentifier(r);else if("keyUsage"==o)s=new n.KeyUsage(r);else if("subjectAltName"==o)s=new n.SubjectAltName(r);else if("issuerAltName"==o)s=new n.IssuerAltName(r);else if("basicConstraints"==o)s=new n.BasicConstraints(r);else if("cRLDistributionPoints"==o)s=new n.CRLDistributionPoints(r);else if("certificatePolicies"==o)s=new n.CertificatePolicies(r);else if("authorityKeyIdentifier"==o)s=new n.AuthorityKeyIdentifier(r);else if("extKeyUsage"==o)s=new n.ExtKeyUsage(r);else if("authorityInfoAccess"==o)s=new n.AuthorityInfoAccess(r);else if("cRLNumber"==o)s=new n.CRLNumber(r);else if("cRLReason"==o)s=new n.CRLReason(r);else if("ocspNonce"==o)s=new n.OCSPNonce(r);else if("ocspNoCheck"==o)s=new n.OCSPNoCheck(r);else if("adobeTimeStamp"==o)s=new n.AdobeTimeStamp(r);else{if("subjectDirectoryAttributes"!=o)throw new Error("extension not supported:"+JSON.stringify(r));s=new n.SubjectDirectoryAttributes(r)}null!=s&&e.push(s)}return new i({array:e}).getEncodedHex()},null!=e&&this.setByParam(e)},Ae(u.asn1.x509.Extensions,u.asn1.ASN1Object),u.asn1.x509.Extension=function(e){u.asn1.x509.Extension.superclass.constructor.call(this);var t=u.asn1,i=t.DERObjectIdentifier,n=t.DEROctetString;t.DERBitString;var r=t.DERBoolean,o=t.DERSequence;this.getEncodedHex=function(){var e=new i({oid:this.oid}),t=new n({hex:this.getExtnValueHex()}),s=new Array;return s.push(e),this.critical&&s.push(new r),s.push(t),new o({array:s}).getEncodedHex()},this.critical=!1,void 0!==e&&void 0!==e.critical&&(this.critical=e.critical)},Ae(u.asn1.x509.Extension,u.asn1.ASN1Object),u.asn1.x509.KeyUsage=function(e){u.asn1.x509.KeyUsage.superclass.constructor.call(this,e);var t=ze.KEYUSAGE_NAME;if(this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.15",void 0!==e&&(void 0!==e.bin&&(this.asn1ExtnValue=new u.asn1.DERBitString(e)),void 0!==e.names&&void 0!==e.names.length)){for(var i=e.names,n="000000000",r=0;r<i.length;r++)for(var o=0;o<t.length;o++)i[r]===t[o]&&(n=n.substring(0,o)+"1"+n.substring(o+1,n.length));this.asn1ExtnValue=new u.asn1.DERBitString({bin:n})}},Ae(u.asn1.x509.KeyUsage,u.asn1.x509.Extension),u.asn1.x509.BasicConstraints=function(e){u.asn1.x509.BasicConstraints.superclass.constructor.call(this,e);var t=u.asn1,i=t.DERBoolean,n=t.DERInteger,r=t.DERSequence;this.getExtnValueHex=function(){var e=new Array;this.cA&&e.push(new i),this.pathLen>-1&&e.push(new n({int:this.pathLen}));var t=new r({array:e});return this.asn1ExtnValue=t,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==e&&(void 0!==e.cA&&(this.cA=e.cA),void 0!==e.pathLen&&(this.pathLen=e.pathLen))},Ae(u.asn1.x509.BasicConstraints,u.asn1.x509.Extension),u.asn1.x509.CRLDistributionPoints=function(e){u.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,e);var t=u.asn1,i=t.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(e){for(var n=[],r=0;r<e.length;r++)if(e[r]instanceof u.asn1.ASN1Object)n.push(e[r]);else{var o=new i.DistributionPoint(e[r]);n.push(o)}this.asn1ExtnValue=new t.DERSequence({array:n})},this.setByOneURI=function(e){var t=new i.DistributionPoint({fulluri:e});this.setByDPArray([t])},this.oid="2.5.29.31",void 0!==e&&(void 0!==e.array?this.setByDPArray(e.array):void 0!==e.uri&&this.setByOneURI(e.uri))},Ae(u.asn1.x509.CRLDistributionPoints,u.asn1.x509.Extension),u.asn1.x509.DistributionPoint=function(e){u.asn1.x509.DistributionPoint.superclass.constructor.call(this);var t=u.asn1,i=t.x509.DistributionPointName;this.getEncodedHex=function(){var e=new t.DERSequence;if(null!=this.asn1DP){var i=new t.DERTaggedObject({explicit:!0,tag:"a0",obj:this.asn1DP});e.appendASN1Object(i)}return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==e&&(void 0!==e.dpobj?this.asn1DP=e.dpobj:void 0!==e.dpname?this.asn1DP=new i(e.dpname):void 0!==e.fulluri&&(this.asn1DP=new i({full:[{uri:e.fulluri}]})))},Ae(u.asn1.x509.DistributionPoint,u.asn1.ASN1Object),u.asn1.x509.DistributionPointName=function(e){u.asn1.x509.DistributionPointName.superclass.constructor.call(this);var t=u.asn1,i=t.DERTaggedObject;if(this.getEncodedHex=function(){if("full"!=this.type)throw new Error("currently type shall be 'full': "+this.type);return this.asn1Obj=new i({explicit:!1,tag:this.tag,obj:this.asn1V}),this.hTLV=this.asn1Obj.getEncodedHex(),this.hTLV},void 0!==e)if(t.x509.GeneralNames.prototype.isPrototypeOf(e))this.type="full",this.tag="a0",this.asn1V=e;else{if(void 0===e.full)throw new Error("This class supports GeneralNames only as argument");this.type="full",this.tag="a0",this.asn1V=new t.x509.GeneralNames(e.full)}},Ae(u.asn1.x509.DistributionPointName,u.asn1.ASN1Object),u.asn1.x509.CertificatePolicies=function(e){u.asn1.x509.CertificatePolicies.superclass.constructor.call(this,e);var t=u.asn1,i=t.x509,n=t.DERSequence,r=i.PolicyInformation;this.params=null,this.getExtnValueHex=function(){for(var e=[],t=0;t<this.params.array.length;t++)e.push(new r(this.params.array[t]));var i=new n({array:e});return this.asn1ExtnValue=i,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.32",void 0!==e&&(this.params=e)},Ae(u.asn1.x509.CertificatePolicies,u.asn1.x509.Extension),u.asn1.x509.PolicyInformation=function(e){u.asn1.x509.PolicyInformation.superclass.constructor.call(this,e);var t=u.asn1,i=t.DERSequence,n=t.DERObjectIdentifier,r=t.x509.PolicyQualifierInfo;this.params=null,this.getEncodedHex=function(){if(void 0===this.params.policyoid&&void 0===this.params.array)throw new Error("parameter oid and array missing");var e=[new n(this.params.policyoid)];if(void 0!==this.params.array){for(var t=[],o=0;o<this.params.array.length;o++)t.push(new r(this.params.array[o]));t.length>0&&e.push(new i({array:t}))}return new i({array:e}).getEncodedHex()},void 0!==e&&(this.params=e)},Ae(u.asn1.x509.PolicyInformation,u.asn1.ASN1Object),u.asn1.x509.PolicyQualifierInfo=function(e){u.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var t=u.asn1,i=t.DERSequence,n=t.DERIA5String,r=t.DERObjectIdentifier,o=t.x509.UserNotice;this.params=null,this.getEncodedHex=function(){return void 0!==this.params.cps?new i({array:[new r({oid:"1.3.6.1.5.5.7.2.1"}),new n({str:this.params.cps})]}).getEncodedHex():null!=this.params.unotice?new i({array:[new r({oid:"1.3.6.1.5.5.7.2.2"}),new o(this.params.unotice)]}).getEncodedHex():void 0},void 0!==e&&(this.params=e)},Ae(u.asn1.x509.PolicyQualifierInfo,u.asn1.ASN1Object),u.asn1.x509.UserNotice=function(e){u.asn1.x509.UserNotice.superclass.constructor.call(this,e);var t=u.asn1.DERSequence;u.asn1.DERInteger;var i=u.asn1.x509.DisplayText,n=u.asn1.x509.NoticeReference;this.params=null,this.getEncodedHex=function(){var e=[];return void 0!==this.params.noticeref&&e.push(new n(this.params.noticeref)),void 0!==this.params.exptext&&e.push(new i(this.params.exptext)),new t({array:e}).getEncodedHex()},void 0!==e&&(this.params=e)},Ae(u.asn1.x509.UserNotice,u.asn1.ASN1Object),u.asn1.x509.NoticeReference=function(e){u.asn1.x509.NoticeReference.superclass.constructor.call(this,e);var t=u.asn1.DERSequence,i=u.asn1.DERInteger,n=u.asn1.x509.DisplayText;this.params=null,this.getEncodedHex=function(){var e=[];if(void 0!==this.params.org&&e.push(new n(this.params.org)),void 0!==this.params.noticenum){for(var r=[],o=this.params.noticenum,s=0;s<o.length;s++)r.push(new i(o[s]));e.push(new t({array:r}))}if(0==e.length)throw new Error("parameter is empty");return new t({array:e}).getEncodedHex()},void 0!==e&&(this.params=e)},Ae(u.asn1.x509.NoticeReference,u.asn1.ASN1Object),u.asn1.x509.DisplayText=function(e){u.asn1.x509.DisplayText.superclass.constructor.call(this,e),this.hT="0c",void 0!==e&&("ia5"===e.type?this.hT="16":"vis"===e.type?this.hT="1a":"bmp"===e.type&&(this.hT="1e"))},Ae(u.asn1.x509.DisplayText,u.asn1.DERAbstractString),u.asn1.x509.ExtKeyUsage=function(e){u.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,e);var t=u.asn1;this.setPurposeArray=function(e){this.asn1ExtnValue=new t.DERSequence;for(var i=0;i<e.length;i++){var n=new t.DERObjectIdentifier(e[i]);this.asn1ExtnValue.appendASN1Object(n)}},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.37",void 0!==e&&void 0!==e.array&&this.setPurposeArray(e.array)},Ae(u.asn1.x509.ExtKeyUsage,u.asn1.x509.Extension),u.asn1.x509.AuthorityKeyIdentifier=function(e){u.asn1.x509.AuthorityKeyIdentifier.superclass.constructor.call(this,e);var t=u,i=t.asn1,n=i.DERTaggedObject,r=i.x509.GeneralNames;t.crypto.Util.isKey,this.asn1KID=null,this.asn1CertIssuer=null,this.asn1CertSN=null,this.getExtnValueHex=function(){var e=new Array;this.asn1KID&&e.push(new n({explicit:!1,tag:"80",obj:this.asn1KID})),this.asn1CertIssuer&&e.push(new n({explicit:!1,tag:"a1",obj:new r([{dn:this.asn1CertIssuer}])})),this.asn1CertSN&&e.push(new n({explicit:!1,tag:"82",obj:this.asn1CertSN}));var t=new i.DERSequence({array:e});return this.asn1ExtnValue=t,this.asn1ExtnValue.getEncodedHex()},this.setKIDByParam=function(e){if(void 0!==e.str||void 0!==e.hex)this.asn1KID=new u.asn1.DEROctetString(e);else if("object"==typeof e&&u.crypto.Util.isKey(e)||"string"==typeof e&&-1!=e.indexOf("BEGIN ")){var t=e;"string"==typeof e&&(t=we.getKey(e));var i=we.getKeyID(t);this.asn1KID=new u.asn1.DEROctetString({hex:i})}},this.setCertIssuerByParam=function(e){void 0!==e.str||void 0!==e.ldapstr||void 0!==e.hex||void 0!==e.certsubject||void 0!==e.certissuer?this.asn1CertIssuer=new u.asn1.x509.X500Name(e):"string"==typeof e&&-1!=e.indexOf("BEGIN ")&&-1!=e.indexOf("CERTIFICATE")&&(this.asn1CertIssuer=new u.asn1.x509.X500Name({certissuer:e}))},this.setCertSNByParam=function(e){if(void 0!==e.str||void 0!==e.bigint||void 0!==e.hex)this.asn1CertSN=new u.asn1.DERInteger(e);else if("string"==typeof e&&-1!=e.indexOf("BEGIN ")&&e.indexOf("CERTIFICATE")){var t=new ze;t.readCertPEM(e);var i=t.getSerialNumberHex();this.asn1CertSN=new u.asn1.DERInteger({hex:i})}},this.oid="2.5.29.35",void 0!==e&&(void 0!==e.kid&&this.setKIDByParam(e.kid),void 0!==e.issuer&&this.setCertIssuerByParam(e.issuer),void 0!==e.sn&&this.setCertSNByParam(e.sn),void 0!==e.issuersn&&"string"==typeof e.issuersn&&-1!=e.issuersn.indexOf("BEGIN ")&&e.issuersn.indexOf("CERTIFICATE")&&(this.setCertSNByParam(e.issuersn),this.setCertIssuerByParam(e.issuersn)))},Ae(u.asn1.x509.AuthorityKeyIdentifier,u.asn1.x509.Extension),u.asn1.x509.SubjectKeyIdentifier=function(e){u.asn1.x509.SubjectKeyIdentifier.superclass.constructor.call(this,e);var t=u.asn1.DEROctetString;this.asn1KID=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=this.asn1KID,this.asn1ExtnValue.getEncodedHex()},this.setKIDByParam=function(e){if(void 0!==e.str||void 0!==e.hex)this.asn1KID=new t(e);else if("object"==typeof e&&u.crypto.Util.isKey(e)||"string"==typeof e&&-1!=e.indexOf("BEGIN")){var i=e;"string"==typeof e&&(i=we.getKey(e));var n=we.getKeyID(i);this.asn1KID=new u.asn1.DEROctetString({hex:n})}},this.oid="2.5.29.14",void 0!==e&&void 0!==e.kid&&this.setKIDByParam(e.kid)},Ae(u.asn1.x509.SubjectKeyIdentifier,u.asn1.x509.Extension),u.asn1.x509.AuthorityInfoAccess=function(e){u.asn1.x509.AuthorityInfoAccess.superclass.constructor.call(this,e),this.setAccessDescriptionArray=function(e){for(var t=new Array,i=u.asn1,n=i.DERSequence,r=i.DERObjectIdentifier,o=i.x509.GeneralName,s=0;s<e.length;s++){var a,c=e[s];if(void 0!==c.ocsp)a=new n({array:[new r({oid:"1.3.6.1.5.5.7.48.1"}),new o({uri:c.ocsp})]});else{if(void 0===c.caissuer)throw new Error("unknown AccessMethod parameter: "+JSON.stringify(c));a=new n({array:[new r({oid:"1.3.6.1.5.5.7.48.2"}),new o({uri:c.caissuer})]})}t.push(a)}this.asn1ExtnValue=new n({array:t})},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.1.1",void 0!==e&&void 0!==e.array&&this.setAccessDescriptionArray(e.array)},Ae(u.asn1.x509.AuthorityInfoAccess,u.asn1.x509.Extension),u.asn1.x509.SubjectAltName=function(e){u.asn1.x509.SubjectAltName.superclass.constructor.call(this,e),this.setNameArray=function(e){this.asn1ExtnValue=new u.asn1.x509.GeneralNames(e)},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.17",void 0!==e&&void 0!==e.array&&this.setNameArray(e.array)},Ae(u.asn1.x509.SubjectAltName,u.asn1.x509.Extension),u.asn1.x509.IssuerAltName=function(e){u.asn1.x509.IssuerAltName.superclass.constructor.call(this,e),this.setNameArray=function(e){this.asn1ExtnValue=new u.asn1.x509.GeneralNames(e)},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.18",void 0!==e&&void 0!==e.array&&this.setNameArray(e.array)},Ae(u.asn1.x509.IssuerAltName,u.asn1.x509.Extension),u.asn1.x509.SubjectDirectoryAttributes=function(e){u.asn1.x509.SubjectDirectoryAttributes.superclass.constructor.call(this,e);var t=u.asn1,i=t.DERSequence,n=t.ASN1Util.newObject,r=t.x509.OID.name2oid;this.params=null,this.getExtnValueHex=function(){for(var e=[],t=0;t<this.params.array.length;t++){var o=this.params.array[t],s={seq:[{oid:"1.2.3.4"},{set:[{utf8str:"DE"}]}]};if("dateOfBirth"==o.attr)s.seq[0].oid=r(o.attr),s.seq[1].set[0]={gentime:o.str};else if("placeOfBirth"==o.attr)s.seq[0].oid=r(o.attr),s.seq[1].set[0]={utf8str:o.str};else if("gender"==o.attr)s.seq[0].oid=r(o.attr),s.seq[1].set[0]={prnstr:o.str};else if("countryOfCitizenship"==o.attr)s.seq[0].oid=r(o.attr),s.seq[1].set[0]={prnstr:o.str};else{if("countryOfResidence"!=o.attr)throw new Error("unsupported attribute: "+o.attr);s.seq[0].oid=r(o.attr),s.seq[1].set[0]={prnstr:o.str}}e.push(new n(s))}var a=new i({array:e});return this.asn1ExtnValue=a,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.9",void 0!==e&&(this.params=e)},Ae(u.asn1.x509.SubjectDirectoryAttributes,u.asn1.x509.Extension),u.asn1.x509.PrivateExtension=function(e){u.asn1.x509.PrivateExtension.superclass.constructor.call(this,e);var t=u,i=t.lang.String.isHex,n=t.asn1,r=n.x509.OID.name2oid,o=n.ASN1Util.newObject;this.params=null,this.setByParam=function(e){this.oid=r(e.extname),this.params=e},this.getExtnValueHex=function(){if(null==this.params.extname||null==this.params.extn)throw new Error("extname or extnhex not specified");var e=this.params.extn;if("string"==typeof e&&i(e))return e;if("object"==typeof e)try{return o(e).getEncodedHex()}catch(e){}throw new Error("unsupported extn value")},null!=e&&this.setByParam(e)},Ae(u.asn1.x509.PrivateExtension,u.asn1.x509.Extension),u.asn1.x509.CRL=function(e){u.asn1.x509.CRL.superclass.constructor.call(this);var t=u.asn1,i=t.DERSequence,n=t.DERBitString,r=t.x509,o=r.AlgorithmIdentifier,s=r.TBSCertList;this.params=void 0,this.setByParam=function(e){this.params=e},this.sign=function(){var e=new s(this.params).getEncodedHex(),t=new u.crypto.Signature({alg:this.params.sigalg});t.init(this.params.cakey),t.updateHex(e);var i=t.sign();this.params.sighex=i},this.getPEM=function(){return ae(this.getEncodedHex(),"X509 CRL")},this.getEncodedHex=function(){var e=this.params;if(null==e.tbsobj&&(e.tbsobj=new s(e)),null==e.sighex&&null!=e.cakey&&this.sign(),null==e.sighex)throw new Error("sighex or cakey parameter not defined");var t=[];return t.push(e.tbsobj),t.push(new o({name:e.sigalg})),t.push(new n({hex:"00"+e.sighex})),new i({array:t}).getEncodedHex()},null!=e&&(this.params=e)},Ae(u.asn1.x509.CRL,u.asn1.ASN1Object),u.asn1.x509.TBSCertList=function(e){u.asn1.x509.TBSCertList.superclass.constructor.call(this);var t=u.asn1,i=t.DERInteger,n=t.DERSequence,r=t.DERTaggedObject;t.DERObjectIdentifier;var o=t.x509,s=o.AlgorithmIdentifier,a=o.Time,c=o.Extensions,l=o.X500Name;this.params=null,this.setByParam=function(e){this.params=e},this.getRevCertSequence=function(){for(var e=[],t=this.params.revcert,r=0;r<t.length;r++){var o=[new i(t[r].sn),new a(t[r].date)];null!=t[r].ext&&o.push(new c(t[r].ext)),e.push(new n({array:o}))}return new n({array:e})},this.getEncodedHex=function(){var e=[],t=this.params;if(null!=t.version){var o=t.version-1,u=new i({int:o});e.push(u)}if(e.push(new s({name:t.sigalg})),e.push(new l(t.issuer)),e.push(new a(t.thisupdate)),null!=t.nextupdate&&e.push(new a(t.nextupdate)),null!=t.revcert&&e.push(this.getRevCertSequence()),null!=t.ext){var h=new c(t.ext);e.push(new r({tag:"a0",explicit:!0,obj:h}))}return new n({array:e}).getEncodedHex()},void 0!==e&&this.setByParam(e)},Ae(u.asn1.x509.TBSCertList,u.asn1.ASN1Object),u.asn1.x509.CRLEntry=function(e){u.asn1.x509.CRLEntry.superclass.constructor.call(this);var t=u.asn1;this.setCertSerial=function(e){this.sn=new t.DERInteger(e)},this.setRevocationDate=function(e){this.time=new t.x509.Time(e)},this.getEncodedHex=function(){var e=new t.DERSequence({array:[this.sn,this.time]});return this.TLV=e.getEncodedHex(),this.TLV},void 0!==e&&(void 0!==e.time&&this.setRevocationDate(e.time),void 0!==e.sn&&this.setCertSerial(e.sn))},Ae(u.asn1.x509.CRLEntry,u.asn1.ASN1Object),u.asn1.x509.CRLNumber=function(e){u.asn1.x509.CRLNumber.superclass.constructor.call(this,e),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new u.asn1.DERInteger(this.params.num),this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.20",null!=e&&(this.params=e)},Ae(u.asn1.x509.CRLNumber,u.asn1.x509.Extension),u.asn1.x509.CRLReason=function(e){u.asn1.x509.CRLReason.superclass.constructor.call(this,e),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new u.asn1.DEREnumerated(this.params.code),this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.21",null!=e&&(this.params=e)},Ae(u.asn1.x509.CRLReason,u.asn1.x509.Extension),u.asn1.x509.OCSPNonce=function(e){u.asn1.x509.OCSPNonce.superclass.constructor.call(this,e),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new u.asn1.DEROctetString(this.params),this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.48.1.2",null!=e&&(this.params=e)},Ae(u.asn1.x509.OCSPNonce,u.asn1.x509.Extension),u.asn1.x509.OCSPNoCheck=function(e){u.asn1.x509.OCSPNoCheck.superclass.constructor.call(this,e),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new u.asn1.DERNull,this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.48.1.5",null!=e&&(this.params=e)},Ae(u.asn1.x509.OCSPNoCheck,u.asn1.x509.Extension),u.asn1.x509.AdobeTimeStamp=function(e){u.asn1.x509.AdobeTimeStamp.superclass.constructor.call(this,e);var t=u.asn1,i=t.DERInteger,n=t.DERBoolean,r=t.DERSequence,o=t.x509.GeneralName;this.params=null,this.getExtnValueHex=function(){var e=this.params,t=[new i(1)];return t.push(new o({uri:e.uri})),null!=e.reqauth&&t.push(new n(e.reqauth)),this.asn1ExtnValue=new r({array:t}),this.asn1ExtnValue.getEncodedHex()},this.oid="1.2.840.113583.1.1.9.1",void 0!==e&&this.setByParam(e)},Ae(u.asn1.x509.AdobeTimeStamp,u.asn1.x509.Extension),u.asn1.x509.X500Name=function(e){u.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var t=u.asn1,i=t.x509,n=i.RDN;this.setByString=function(e,t){void 0!==t&&(this.sRule=t);var i=e.split("/");i.shift();for(var r=[],o=0;o<i.length;o++)if(i[o].match(/^[^=]+=.+$/))r.push(i[o]);else{var s=r.length-1;r[s]=r[s]+"/"+i[o]}for(o=0;o<r.length;o++)this.asn1Array.push(new n({str:r[o],rule:this.sRule}))},this.setByLdapString=function(e,t){void 0!==t&&(this.sRule=t);var n=i.X500Name.ldapToCompat(e);this.setByString(n,t)},this.setByObject=function(e,t){for(var i in void 0!==t&&(this.sRule=t),e)if(e.hasOwnProperty(i)){var r=new n({str:i+"="+e[i],rule:this.sRule});this.asn1Array?this.asn1Array.push(r):this.asn1Array=[r]}},this.setByParam=function(e){var t;(void 0!==e.rule&&(this.sRule=e.rule),void 0!==e.array)?this.paramArray=e.array:void 0!==e.str?this.setByString(e.str):void 0!==e.ldapstr?this.setByLdapString(e.ldapstr):void 0!==e.hex?this.hTLV=e.hex:void 0!==e.certissuer?((t=new ze).readCertPEM(e.certissuer),this.hTLV=t.getIssuerHex()):void 0!==e.certsubject?((t=new ze).readCertPEM(e.certsubject),this.hTLV=t.getSubjectHex()):"object"==typeof e&&void 0===e.certsubject&&void 0===e.certissuer&&this.setByObject(e)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(0==this.asn1Array.length&&this.paramArray.length>0)for(var e=0;e<this.paramArray.length;e++){var i={array:this.paramArray[e]};"utf8"!=this.sRule&&(i.rule=this.sRule);var r=new n(i);this.asn1Array.push(r)}var o=new t.DERSequence({array:this.asn1Array});return this.hTLV=o.getEncodedHex(),this.hTLV},void 0!==e&&this.setByParam(e)},Ae(u.asn1.x509.X500Name,u.asn1.ASN1Object),u.asn1.x509.X500Name.compatToLDAP=function(e){if("/"!==e.substr(0,1))throw"malformed input";var t=(e=e.substr(1)).split("/");return t.reverse(),(t=t.map((function(e){return e.replace(/,/,"\\,")}))).join(",")},u.asn1.x509.X500Name.onelineToLDAP=function(e){return u.asn1.x509.X500Name.compatToLDAP(e)},u.asn1.x509.X500Name.ldapToCompat=function(e){for(var t=e.split(","),i=!1,n=[],r=0;t.length>0;r++){var o=t.shift();if(!0===i){var s=(n.pop()+","+o).replace(/\\,/g,",");n.push(s),i=!1}else n.push(o);"\\"===o.substr(-1,1)&&(i=!0)}return(n=n.map((function(e){return e.replace("/","\\/")}))).reverse(),"/"+n.join("/")},u.asn1.x509.X500Name.ldapToOneline=function(e){return u.asn1.x509.X500Name.ldapToCompat(e)},u.asn1.x509.RDN=function(e){u.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var t=u.asn1.x509.AttributeTypeAndValue;this.setByParam=function(e){void 0!==e.rule&&(this.sRule=e.rule),void 0!==e.str&&this.addByMultiValuedString(e.str),void 0!==e.array&&(this.paramArray=e.array)},this.addByString=function(e){this.asn1Array.push(new u.asn1.x509.AttributeTypeAndValue({str:e,rule:this.sRule}))},this.addByMultiValuedString=function(e){for(var t=u.asn1.x509.RDN.parseString(e),i=0;i<t.length;i++)this.addByString(t[i])},this.getEncodedHex=function(){if(0==this.asn1Array.length&&this.paramArray.length>0)for(var e=0;e<this.paramArray.length;e++){var i=this.paramArray[e];void 0!==i.rule&&"utf8"!=this.sRule&&(i.rule=this.sRule);var n=new t(i);this.asn1Array.push(n)}var r=new u.asn1.DERSet({array:this.asn1Array});return this.TLV=r.getEncodedHex(),this.TLV},void 0!==e&&this.setByParam(e)},Ae(u.asn1.x509.RDN,u.asn1.ASN1Object),u.asn1.x509.RDN.parseString=function(e){for(var t=e.split(/\+/),i=!1,n=[],r=0;t.length>0;r++){var o=t.shift();if(!0===i){var s=(n.pop()+"+"+o).replace(/\\\+/g,"+");n.push(s),i=!1}else n.push(o);"\\"===o.substr(-1,1)&&(i=!0)}var a=!1,u=[];for(r=0;n.length>0;r++){o=n.shift();if(!0===a){var c=u.pop();if(o.match(/"$/)){s=(c+"+"+o).replace(/^([^=]+)="(.*)"$/,"$1=$2");u.push(s),a=!1}else u.push(c+"+"+o)}else u.push(o);o.match(/^[^=]+="/)&&(a=!0)}return u},u.asn1.x509.AttributeTypeAndValue=function(e){u.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var t=u,i=t.asn1,n=i.DERSequence,r=i.DERUTF8String,o=i.DERPrintableString,s=i.DERTeletexString,a=i.DERIA5String,c=i.DERVisibleString,l=i.DERBMPString,h=t.lang.String.isMail,d=t.lang.String.isPrintable;this.setByParam=function(e){if(void 0!==e.rule&&(this.sRule=e.rule),void 0!==e.ds&&(this.dsType=e.ds),void 0===e.value&&void 0!==e.str){var t=e.str.match(/^([^=]+)=(.+)$/);if(!t)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.sType=t[1],this.sValue=t[2]}else this.sType=e.type,this.sValue=e.value},this.setByString=function(e,t){void 0!==t&&(this.sRule=t);var i=e.match(/^([^=]+)=(.+)$/);if(!i)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.setByAttrTypeAndValueStr(i[1],i[2])},this._getDsType=function(){var e=this.sType,t=this.sValue,i=this.sRule;return"prn"===i?"CN"==e&&h(t)?"ia5":d(t)?"prn":"utf8":"utf8"===i?"CN"==e&&h(t)?"ia5":"C"==e?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(e,t,i){void 0!==i&&(this.sRule=i),this.sType=e,this.sValue=t},this.getValueObj=function(e,t){if("utf8"==e)return new r({str:t});if("prn"==e)return new o({str:t});if("tel"==e)return new s({str:t});if("ia5"==e)return new a({str:t});if("vis"==e)return new c({str:t});if("bmp"==e)return new l({str:t});throw new Error("unsupported directory string type: type="+e+" value="+t)},this.getEncodedHex=function(){null==this.dsType&&(this.dsType=this._getDsType());var e=u.asn1.x509.OID.atype2obj(this.sType),t=this.getValueObj(this.dsType,this.sValue),i=new n({array:[e,t]});return this.TLV=i.getEncodedHex(),this.TLV},void 0!==e&&this.setByParam(e)},Ae(u.asn1.x509.AttributeTypeAndValue,u.asn1.ASN1Object),u.asn1.x509.SubjectPublicKeyInfo=function(e){u.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var t=u,i=t.asn1,n=i.DERInteger,r=i.DERBitString,o=i.DERObjectIdentifier,s=i.DERSequence,a=i.ASN1Util.newObject,c=i.x509.AlgorithmIdentifier,l=t.crypto;l.ECDSA,l.DSA,this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new s({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.getEncodedHex=function(){var e=this.getASN1Object();return this.hTLV=e.getEncodedHex(),this.hTLV},this.setPubKey=function(e){try{if(e instanceof K){var t=a({seq:[{int:{bigint:e.n}},{int:{int:e.e}}]}).getEncodedHex();this.asn1AlgId=new c({name:"rsaEncryption"}),this.asn1SubjPKey=new r({hex:"00"+t})}}catch(e){}try{if(e instanceof u.crypto.ECDSA){var i=new o({name:e.curveName});this.asn1AlgId=new c({name:"ecPublicKey",asn1params:i}),this.asn1SubjPKey=new r({hex:"00"+e.pubKeyHex})}}catch(e){}try{if(e instanceof u.crypto.DSA){i=new a({seq:[{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}}]});this.asn1AlgId=new c({name:"dsa",asn1params:i});var s=new n({bigint:e.y});this.asn1SubjPKey=new r({hex:"00"+s.getEncodedHex()})}}catch(e){}},void 0!==e&&this.setPubKey(e)},Ae(u.asn1.x509.SubjectPublicKeyInfo,u.asn1.ASN1Object),u.asn1.x509.Time=function(e){u.asn1.x509.Time.superclass.constructor.call(this);var t=u.asn1,i=t.DERUTCTime,n=t.DERGeneralizedTime;this.setTimeParams=function(e){this.timeParams=e},this.getEncodedHex=function(){var e=null;return e=null!=this.timeParams?"utc"==this.type?new i(this.timeParams):new n(this.timeParams):"utc"==this.type?new i:new n,this.TLV=e.getEncodedHex(),this.TLV},this.type="utc",void 0!==e&&(void 0!==e.type?this.type=e.type:void 0!==e.str&&(e.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),e.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=e)},Ae(u.asn1.x509.Time,u.asn1.ASN1Object),u.asn1.x509.AlgorithmIdentifier=function(e){u.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var t=u.asn1,i=t.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;if(this.getEncodedHex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw new Error("algorithm not specified");if(null!==this.nameAlg){var e=null;for(var n in i)n===this.nameAlg&&(e=i[n]);if(null!==e)return this.hTLV=e,this.hTLV}null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=t.x509.OID.name2obj(this.nameAlg));var r=[this.asn1Alg];null!==this.asn1Params&&r.push(this.asn1Params);var o=new t.DERSequence({array:r});return this.hTLV=o.getEncodedHex(),this.hTLV},void 0!==e&&(void 0!==e.name&&(this.nameAlg=e.name),void 0!==e.asn1params&&(this.asn1Params=e.asn1params),void 0!==e.paramempty&&(this.paramEmpty=e.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){void 0!==this.nameAlg.name&&(this.nameAlg=this.nameAlg.name);var n=this.nameAlg.toLowerCase();"withdsa"!==n.substr(-7,7)&&"withecdsa"!==n.substr(-9,9)&&(this.asn1Params=new t.DERNull)}},Ae(u.asn1.x509.AlgorithmIdentifier,u.asn1.ASN1Object),u.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"},u.asn1.x509.GeneralName=function(e){u.asn1.x509.GeneralName.superclass.constructor.call(this);var t={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},i=u.asn1;i.DERSequence;var n=i.DEROctetString,r=i.DERIA5String,o=i.DERTaggedObject,s=i.ASN1Object,a=i.x509.X500Name,c=ue;this.explicit=!1,this.setByParam=function(e){var i=null;if(void 0!==e){if(void 0!==e.rfc822&&(this.type="rfc822",i=new r({str:e[this.type]})),void 0!==e.dns&&(this.type="dns",i=new r({str:e[this.type]})),void 0!==e.uri&&(this.type="uri",i=new r({str:e[this.type]})),void 0!==e.dn&&(this.type="dn",this.explicit=!0,i="string"==typeof e.dn?new a({str:e.dn}):e.dn instanceof u.asn1.x509.X500Name?e.dn:new a(e.dn)),void 0!==e.ldapdn&&(this.type="dn",this.explicit=!0,i=new a({ldapstr:e.ldapdn})),void 0!==e.certissuer){this.type="dn",this.explicit=!0;var l=null;if((d=e.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=d.indexOf("-----BEGIN ")&&(l=c(d)),null==l)throw"certissuer param not cert";(p=new ze).hex=l;var h=p.getIssuerHex();(i=new s).hTLV=h}if(void 0!==e.certsubj){this.type="dn",this.explicit=!0;var d,p;l=null;if((d=e.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=d.indexOf("-----BEGIN ")&&(l=c(d)),null==l)throw"certsubj param not cert";(p=new ze).hex=l;h=p.getSubjectHex();(i=new s).hTLV=h}if(void 0!==e.ip){this.type="ip",this.explicit=!1;var A,f=e.ip,M="malformed IP address";if(f.match(/^[0-9.]+[.][0-9.]+$/)){if(8!==(A=function(e){e=(e=(e=e.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return e.split(/,/).map((function(e,t,i){var n=parseInt(e);if(n<0||255<n)throw"integer not in range 0-255";return("00"+n.toString(16)).slice(-2)})).join("")}catch(e){throw"malformed integer array string: "+e}}("["+f.split(".").join(",")+"]")).length)throw M}else if(f.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))A=function(e){var t="malformed IPv6 address";if(!e.match(/^[0-9A-Fa-f:]+$/))throw t;var i=(e=e.toLowerCase()).split(":").length-1;if(i<2)throw t;var n=":".repeat(7-i+2),r=(e=e.replace("::",n)).split(":");if(8!=r.length)throw t;for(var o=0;o<8;o++)r[o]=("0000"+r[o]).slice(-4);return r.join("")}(f);else{if(!f.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw M;A=f}i=new n({hex:A})}if(null==this.type)throw"unsupported type in params="+e;this.asn1Obj=new o({explicit:this.explicit,tag:t[this.type],obj:i})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==e&&this.setByParam(e)},Ae(u.asn1.x509.GeneralName,u.asn1.ASN1Object),u.asn1.x509.GeneralNames=function(e){u.asn1.x509.GeneralNames.superclass.constructor.call(this);var t=u.asn1;this.setByParamArray=function(e){for(var i=0;i<e.length;i++){var n=new t.x509.GeneralName(e[i]);this.asn1Array.push(n)}},this.getEncodedHex=function(){return new t.DERSequence({array:this.asn1Array}).getEncodedHex()},this.asn1Array=new Array,void 0!==e&&this.setByParamArray(e)},Ae(u.asn1.x509.GeneralNames,u.asn1.ASN1Object),u.asn1.x509.OID=new function(e){this.atype2oidList={CN:"2.5.4.3",L:"2.5.4.7",ST:"2.5.4.8",O:"2.5.4.10",OU:"2.5.4.11",C:"2.5.4.6",STREET:"2.5.4.9",DC:"0.9.2342.19200300.100.1.25",UID:"0.9.2342.19200300.100.1.1",SN:"2.5.4.4",T:"2.5.4.12",DN:"2.5.4.49",E:"1.2.840.113549.1.9.1",description:"2.5.4.13",businessCategory:"2.5.4.15",postalCode:"2.5.4.17",serialNumber:"2.5.4.5",uniqueIdentifier:"2.5.4.45",organizationIdentifier:"2.5.4.97",jurisdictionOfIncorporationL:"1.3.6.1.4.1.311.60.2.1.1",jurisdictionOfIncorporationSP:"1.3.6.1.4.1.311.60.2.1.2",jurisdictionOfIncorporationC:"1.3.6.1.4.1.311.60.2.1.3"},this.name2oidList={sha1:"1.3.14.3.2.26",sha256:"2.16.840.1.101.3.4.2.1",sha384:"2.16.840.1.101.3.4.2.2",sha512:"2.16.840.1.101.3.4.2.3",sha224:"2.16.840.1.101.3.4.2.4",md5:"1.2.840.113549.2.5",md2:"1.3.14.7.2.2.1",ripemd160:"1.3.36.3.2.1",MD2withRSA:"1.2.840.113549.1.1.2",MD4withRSA:"1.2.840.113549.1.1.3",MD5withRSA:"1.2.840.113549.1.1.4",SHA1withRSA:"1.2.840.113549.1.1.5","pkcs1-MGF":"1.2.840.113549.1.1.8",rsaPSS:"1.2.840.113549.1.1.10",SHA224withRSA:"1.2.840.113549.1.1.14",SHA256withRSA:"1.2.840.113549.1.1.11",SHA384withRSA:"1.2.840.113549.1.1.12",SHA512withRSA:"1.2.840.113549.1.1.13",SHA1withECDSA:"1.2.840.10045.4.1",SHA224withECDSA:"1.2.840.10045.4.3.1",SHA256withECDSA:"1.2.840.10045.4.3.2",SHA384withECDSA:"1.2.840.10045.4.3.3",SHA512withECDSA:"1.2.840.10045.4.3.4",dsa:"1.2.840.10040.4.1",SHA1withDSA:"1.2.840.10040.4.3",SHA224withDSA:"2.16.840.1.101.3.4.3.1",SHA256withDSA:"2.16.840.1.101.3.4.3.2",rsaEncryption:"1.2.840.113549.1.1.1",commonName:"2.5.4.3",countryName:"2.5.4.6",localityName:"2.5.4.7",stateOrProvinceName:"2.5.4.8",streetAddress:"2.5.4.9",organizationName:"2.5.4.10",organizationalUnitName:"2.5.4.11",domainComponent:"0.9.2342.19200300.100.1.25",userId:"0.9.2342.19200300.100.1.1",surname:"2.5.4.4",givenName:"2.5.4.42",title:"2.5.4.12",distinguishedName:"2.5.4.49",emailAddress:"1.2.840.113549.1.9.1",description:"2.5.4.13",businessCategory:"2.5.4.15",postalCode:"2.5.4.17",uniqueIdentifier:"2.5.4.45",organizationIdentifier:"2.5.4.97",jurisdictionOfIncorporationL:"1.3.6.1.4.1.311.60.2.1.1",jurisdictionOfIncorporationSP:"1.3.6.1.4.1.311.60.2.1.2",jurisdictionOfIncorporationC:"1.3.6.1.4.1.311.60.2.1.3",subjectDirectoryAttributes:"2.5.29.9",subjectKeyIdentifier:"2.5.29.14",keyUsage:"2.5.29.15",subjectAltName:"2.5.29.17",issuerAltName:"2.5.29.18",basicConstraints:"2.5.29.19",cRLNumber:"2.5.29.20",cRLReason:"2.5.29.21",nameConstraints:"2.5.29.30",cRLDistributionPoints:"2.5.29.31",certificatePolicies:"2.5.29.32",anyPolicy:"2.5.29.32.0",authorityKeyIdentifier:"2.5.29.35",policyConstraints:"2.5.29.36",extKeyUsage:"2.5.29.37",authorityInfoAccess:"1.3.6.1.5.5.7.1.1",ocsp:"1.3.6.1.5.5.7.48.1",ocspBasic:"1.3.6.1.5.5.7.48.1.1",ocspNonce:"1.3.6.1.5.5.7.48.1.2",ocspNoCheck:"1.3.6.1.5.5.7.48.1.5",caIssuers:"1.3.6.1.5.5.7.48.2",anyExtendedKeyUsage:"2.5.29.37.0",serverAuth:"1.3.6.1.5.5.7.3.1",clientAuth:"1.3.6.1.5.5.7.3.2",codeSigning:"1.3.6.1.5.5.7.3.3",emailProtection:"1.3.6.1.5.5.7.3.4",timeStamping:"1.3.6.1.5.5.7.3.8",ocspSigning:"1.3.6.1.5.5.7.3.9",dateOfBirth:"1.3.6.1.5.5.7.9.1",placeOfBirth:"1.3.6.1.5.5.7.9.2",gender:"1.3.6.1.5.5.7.9.3",countryOfCitizenship:"1.3.6.1.5.5.7.9.4",countryOfResidence:"1.3.6.1.5.5.7.9.5",ecPublicKey:"1.2.840.10045.2.1","P-256":"1.2.840.10045.3.1.7",secp256r1:"1.2.840.10045.3.1.7",secp256k1:"1.3.132.0.10",secp384r1:"1.3.132.0.34",pkcs5PBES2:"1.2.840.113549.1.5.13",pkcs5PBKDF2:"1.2.840.113549.1.5.12","des-EDE3-CBC":"1.2.840.113549.3.7",data:"1.2.840.113549.1.7.1","signed-data":"1.2.840.113549.1.7.2","enveloped-data":"1.2.840.113549.1.7.3","digested-data":"1.2.840.113549.1.7.5","encrypted-data":"1.2.840.113549.1.7.6","authenticated-data":"1.2.840.113549.1.9.16.1.2",tstinfo:"1.2.840.113549.1.9.16.1.4",signingCertificate:"1.2.840.113549.1.9.16.2.12",timeStampToken:"1.2.840.113549.1.9.16.2.14",signaturePolicyIdentifier:"1.2.840.113549.1.9.16.2.15",etsArchiveTimeStamp:"1.2.840.113549.1.9.16.2.27",signingCertificateV2:"1.2.840.113549.1.9.16.2.47",etsArchiveTimeStampV2:"1.2.840.113549.1.9.16.2.48",extensionRequest:"1.2.840.113549.1.9.14",contentType:"1.2.840.113549.1.9.3",messageDigest:"1.2.840.113549.1.9.4",signingTime:"1.2.840.113549.1.9.5",counterSignature:"1.2.840.113549.1.9.6",archiveTimeStampV3:"0.4.0.1733.2.4",pdfRevocationInfoArchival:"1.2.840.113583.1.1.8",adobeTimeStamp:"1.2.840.113583.1.1.9.1"},this.objCache={},this.name2obj=function(e){if(void 0!==this.objCache[e])return this.objCache[e];if(void 0===this.name2oidList[e])throw"Name of ObjectIdentifier not defined: "+e;var t=this.name2oidList[e],i=new u.asn1.DERObjectIdentifier({oid:t});return this.objCache[e]=i,i},this.atype2obj=function(e){if(void 0!==this.objCache[e])return this.objCache[e];var t;if(e.match(/^\d+\.\d+\.[0-9.]+$/))t=e;else if(void 0!==this.atype2oidList[e])t=this.atype2oidList[e];else{if(void 0===this.name2oidList[e])throw"AttributeType name undefined: "+e;t=this.name2oidList[e]}var i=new u.asn1.DERObjectIdentifier({oid:t});return this.objCache[e]=i,i}},u.asn1.x509.OID.oid2name=function(e){var t=u.asn1.x509.OID.name2oidList;for(var i in t)if(t[i]==e)return i;return""},u.asn1.x509.OID.oid2atype=function(e){var t=u.asn1.x509.OID.atype2oidList;for(var i in t)if(t[i]==e)return i;return e},u.asn1.x509.OID.name2oid=function(e){if(e.match(/^[0-9.]+$/))return e;var t=u.asn1.x509.OID.name2oidList;return void 0===t[e]?"":t[e]},u.asn1.x509.X509Util={},u.asn1.x509.X509Util.newCertPEM=function(e){var t=u.asn1.x509;return t.TBSCertificate,new(0,t.Certificate)(e).getPEM()},K.getPosArrayOfChildrenFromHex=function(e){return Te.getChildIdx(e,0)},K.getHexValueArrayOfChildrenFromHex=function(e){var t,i=Te.getV,n=i(e,(t=K.getPosArrayOfChildrenFromHex(e))[0]),r=i(e,t[1]),o=i(e,t[2]),s=i(e,t[3]),a=i(e,t[4]),u=i(e,t[5]),c=i(e,t[6]),l=i(e,t[7]),h=i(e,t[8]);return(t=new Array).push(n,r,o,s,a,u,c,l,h),t},K.prototype.readPrivateKeyFromPEMString=function(e){var t=ue(e),i=K.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8])},K.prototype.readPKCS5PrvKeyHex=function(e){var t=K.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},K.prototype.readPKCS8PrvKeyHex=function(e){var t,i,n,r,o,s,a,u,c=Te,l=c.getVbyListEx;if(!1===c.isASN1HEX(e))throw new Error("not ASN.1 hex string");try{t=l(e,0,[2,0,1],"02"),i=l(e,0,[2,0,2],"02"),n=l(e,0,[2,0,3],"02"),r=l(e,0,[2,0,4],"02"),o=l(e,0,[2,0,5],"02"),s=l(e,0,[2,0,6],"02"),a=l(e,0,[2,0,7],"02"),u=l(e,0,[2,0,8],"02")}catch(e){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(t,i,n,r,o,s,a,u)},K.prototype.readPKCS5PubKeyHex=function(e){var t=Te,i=t.getV;if(!1===t.isASN1HEX(e))throw new Error("keyHex is not ASN.1 hex string");var n=t.getChildIdx(e,0);if(2!==n.length||"02"!==e.substr(n[0],2)||"02"!==e.substr(n[1],2))throw new Error("wrong hex for PKCS#5 public key");var r=i(e,n[0]),o=i(e,n[1]);this.setPublic(r,o)},K.prototype.readPKCS8PubKeyHex=function(e){var t=Te;if(!1===t.isASN1HEX(e))throw new Error("not ASN.1 hex string");if("06092a864886f70d010101"!==t.getTLVbyListEx(e,0,[0,0]))throw new Error("not PKCS8 RSA public key");var i=t.getTLVbyListEx(e,0,[1,0]);this.readPKCS5PubKeyHex(i)},K.prototype.readCertPubKeyHex=function(e,t){var i,n;(i=new ze).readCertHex(e),n=i.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)},K.prototype.sign=function(e,t){var i,n=(i=e,u.crypto.Util.hashString(i,t));return this.signWithMessageHash(n,t)},K.prototype.signWithMessageHash=function(e,t){var i=W(u.crypto.Util.getPaddedDigestInfoHex(e,t,this.n.bitLength()),16);return xe(this.doPrivate(i).toString(16),this.n.bitLength())},K.prototype.signPSS=function(e,t,i){var n,r=(n=oe(e),u.crypto.Util.hashHex(n,t));return void 0===i&&(i=-1),this.signWithMessageHashPSS(r,t,i)},K.prototype.signWithMessageHashPSS=function(e,t,i){var n,r=re(e),o=r.length,s=this.n.bitLength()-1,a=Math.ceil(s/8),c=function(e){return u.crypto.Util.hashHex(e,t)};if(-1===i||void 0===i)i=o;else if(-2===i)i=a-o-2;else if(i<-2)throw new Error("invalid salt length");if(a<o+i+2)throw new Error("data too long");var l="";i>0&&(l=new Array(i),(new G).nextBytes(l),l=String.fromCharCode.apply(String,l));var d=re(c(oe("\0\0\0\0\0\0\0\0"+r+l))),p=[];for(n=0;n<a-i-o-2;n+=1)p[n]=0;var A=String.fromCharCode.apply(String,p)+""+l,f=Ee(d,A.length,c),M=[];for(n=0;n<A.length;n+=1)M[n]=A.charCodeAt(n)^f.charCodeAt(n);var g=65280>>8*a-s&255;for(M[0]&=~g,n=0;n<o;n++)M.push(d.charCodeAt(n));return M.push(188),xe(this.doPrivate(new h(M)).toString(16),this.n.bitLength())},K.prototype.verify=function(e,t){if(null==(t=t.toLowerCase()).match(/^[0-9a-f]+$/))return!1;var i=W(t,16),n=this.n.bitLength();if(i.bitLength()>n)return!1;var r=this.doPublic(i).toString(16);if(r.length+3!=n/4)return!1;var o=je(r.replace(/^1f+00/,""));if(0==o.length)return!1;var s,a=o[0];return o[1]==(s=e,u.crypto.Util.hashString(s,a))},K.prototype.verifyWithMessageHash=function(e,t){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var i=W(t,16);if(i.bitLength()>this.n.bitLength())return 0;var n=je(this.doPublic(i).toString(16).replace(/^1f+00/,""));return 0!=n.length&&(n[0],n[1]==e)},K.prototype.verifyPSS=function(e,t,i,n){var r=function(e){return u.crypto.Util.hashHex(e,i)}(oe(e));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(r,t,i,n)},K.prototype.verifyWithMessageHashPSS=function(e,t,i,n){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var r,o=new h(t,16),s=function(e){return u.crypto.Util.hashHex(e,i)},a=re(e),c=a.length,l=this.n.bitLength()-1,d=Math.ceil(l/8);if(-1===n||void 0===n)n=c;else if(-2===n)n=d-c-2;else if(n<-2)throw new Error("invalid salt length");if(d<c+n+2)throw new Error("data too long");var p=this.doPublic(o).toByteArray();for(r=0;r<p.length;r+=1)p[r]&=255;for(;p.length<d;)p.unshift(0);if(188!==p[d-1])throw new Error("encoded message does not end in 0xbc");var A=(p=String.fromCharCode.apply(String,p)).substr(0,d-c-1),f=p.substr(A.length,c),M=65280>>8*d-l&255;if(0!=(A.charCodeAt(0)&M))throw new Error("bits beyond keysize not zero");var g=Ee(f,A.length,s),y=[];for(r=0;r<A.length;r+=1)y[r]=A.charCodeAt(r)^g.charCodeAt(r);y[0]&=~M;var m=d-c-n-2;for(r=0;r<m;r+=1)if(0!==y[r])throw new Error("leftmost octets not zero");if(1!==y[m])throw new Error("0x01 marker not found");return f===re(s(oe("\0\0\0\0\0\0\0\0"+a+String.fromCharCode.apply(String,y.slice(-n)))))},K.SALT_LEN_HLEN=-1,K.SALT_LEN_MAX=-2,K.SALT_LEN_RECOVER=-2,ze.hex2dn=function(e,t){void 0===t&&(t=0);var i=new ze;return Te.getTLV(e,t),i.getX500Name(e).str},ze.hex2rdn=function(e,t){if(void 0===t&&(t=0),"31"!==e.substr(t,2))throw new Error("malformed RDN");for(var i=new Array,n=Te.getChildIdx(e,t),r=0;r<n.length;r++)i.push(ze.hex2attrTypeValue(e,n[r]));return(i=i.map((function(e){return e.replace("+","\\+")}))).join("+")},ze.hex2attrTypeValue=function(e,t){var i=Te,n=i.getV;if(void 0===t&&(t=0),"30"!==e.substr(t,2))throw new Error("malformed attribute type and value");var r=i.getChildIdx(e,t);2!==r.length||e.substr(r[0],2);var o=n(e,r[0]),s=u.asn1.ASN1Util.oidHexToInt(o);return u.asn1.x509.OID.oid2atype(s)+"="+re(n(e,r[1]))},ze.getPublicKeyFromCertHex=function(e){var t=new ze;return t.readCertHex(e),t.getPublicKey()},ze.getPublicKeyFromCertPEM=function(e){var t=new ze;return t.readCertPEM(e),t.getPublicKey()},ze.getPublicKeyInfoPropOfCertPEM=function(e){var t,i,n=Te.getVbyList,r={};return r.algparam=null,(t=new ze).readCertPEM(e),i=t.getPublicKeyHex(),r.keyhex=n(i,0,[1],"03").substr(2),r.algoid=n(i,0,[0,0],"06"),"2a8648ce3d0201"===r.algoid&&(r.algparam=n(i,0,[0,1],"06")),r},ze.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"];var be,Oe=[(be=new ze,be.readCertPEM(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=113,n=126,r=0,o="";return arguments[r].split(o).map((function(e){return e.charCodeAt(r)>n?e:String.fromCharCode((e.charCodeAt(r)+i)%n)})).join(o)}(":::::ORTV[-PR_aVSVPNaR:::::ZVVS@\tPPNErtNVONtVWNZR}@]nU\0ZaZN=TP`\0T`Vo@Q^ROPbNZVTSZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg\tR^ZNATN>bROU^zc}nzyg\tR]ZN=TN>bRPtTn?bf?FZ_NQtfQc^^YQNq`gdSp?cyZ^P^fQc^^QQNWQ^aRvZPNTP`\0T`Vo@Q^RWN_fapzFqSFwfbOndSnzyuYz[oaNrS=\\QN>Z\tN\\Q^B[QqnS=\b\\QN>Zwp\\Q^B[QqnZVTSZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg\tR^ZNATN>bROU^zc}nzyg\tR]ZN=TN>bRPtTn?bf?FZ_NQtfQc^^YQNq`gdSp?cyZ^P^fQc^^QQNWQ^aRvZPNTP`\0T`Vo@Q^RWN_fapzFqSFwfbOndSnzyuYz[oaPPNvVQ^fWX|gVup[N^ROO^NQttV]NQPPNt|PttVONZU|C\b\\@@e^Xv{[vTtd8`nyO@ebN[bqx=ng?\tS^w@|XAz|qUTwfzn]Bu<qs_ae\\y<}u`eRAoE`_\\s\0r|b{rp_o<oC@o=x\bw_cUUZPApQevD\\FxFoFgE=<sq[p<coqyn>TEpP@aSC_YDU8\0|8TB?c>r\\=rp`pcwP}c\0PP_\\RS\\EPVSy8x`\0?R|NP\tP>}A^VP}Ex\bUZa=syDw}>Ya8wPp[pRnn\brU^dE8U?a\bcW|<FEbbupn^`ZNr\tsof[wA}e{\\z}w[YDQ|dt=wC\tNvbRZ@@U|ZAYpFsabCBB\\`wrqxsYW8uFyWdaWezeUeA_8VoVupvY[TD[OYdpO\bC[wX\\O]=[QRpV\0d`N\0RXt^Z}vEpdC=\bY?=V}?^W\bad|qN@Ww>@PycaqANE]asPcE^OB_VA?>wzeftac\tZ\tguf\bF]DCP?znNYf\tuaYu[`=b|v]Bp=RAS``\\PRDW]_`UXdUg=SuqwVFDeB\tD8{B>\\sPYbEU\tFQXz\0@`zsqgfD\0[WY\bPeZc}\t\0bx?Rfed}BUe|Uo\0y?\bsSXZOSBCgbFqf\0Bs?b?d<VE\\Zzns\\d@?dPvf\\{}_\0Sd[<q_YBY`Ffg=sY>{t<fu]xrFNtZONNTwbQO\\ZO=TN>bqQt^dOOaAFXw=\tPCVxsv?{`a\bvS8YQ[aNsOt[cU`ZRTQNdtOaAFXw=\tPCVxsv?{`a\bvS8YQ[aNZOt[cU_ZROaNQN^U<ZN=TP`\0T`Vo@Q^ROPbNNAVPN^P\0{y\0Bs\\8\0R[z]w??qZP?NpgdenSuvv?>|f_?UpYPcQ\\gCb8zxtSvsOQNg>[\\\0\bx\b_o@8\0g`Z<PyUE`8yu}\\g{@`s`zUgErRtve{YdCvoO@>WFDtABNp\0feUWszpQaEYNAc]^xB[@]BDAN8\b}XA=EnO}Pud8TA\t?yPrVv{\\>E]o`BO^RE^X[W[rEU?x\bf>V\tOUwY=>X[\\E`tW[8}VwpFBQcnrPF}yUtd8<Doe_\b[oOVUep@pYY\0cegY{r\t?\bAbq?ff8}UaXoN_D]_X_8yozYFT`N{`\\{zvu?\bDWT}=_<StX\tNx\0\b\t\0aT=c@ucnWfR[vf>RFxAFV}{N`dN^\\<eawBPxx}quT=|{T_R@Fp^Y<ZevRsWaZ]V\tCVrRVtAAc[\tQp|d|tqoQ=T|XX\t=u\\N8XNCx\\aU>wz\tX<e@Vc?dy\\|^FEq|=p`pBdF@bs^d<]vp\\^TZ\tP\bZ\b\\YNNSZ_\\w^|TsD8db\t_\tY\\o^Cw>Z\0x\\^aN]wWf\bA}\tC^d_{ZC@\by]gY@E\tBFY?OsaqbDcVgQbZeFc\tovtucxnq|<TnuyXRveYFOegCpAs{YTe|>bE<OXsSqCBWD_SVepfvCCUg]z\tZvQ[\0s|U>pFz\b=OwT``fNJJ:::::R[Q-PR_aVSVPNaR:::::")),be)];function Se(e,t){var i=e.getIssuerHex();if(i===e.getSubjectHex())return e.verifySignature(e.getPublicKey());var n=function(e,t){for(var i=0,n=t;i<n.length;i++){var r=n[i];if(r.getSubjectHex()===e)return r}}(i,t);return!!n&&(!1!==e.verifySignature(n.getPublicKey())&&Se(n,t))}function Le(e){return e.getIssuerHex()!==e.getSubjectHex()&&Se(e,Oe)}!function(e){var t=new ze;"string"==typeof e?t.readCertPEM(e):t.readCertHex(e.hex);var i=Le(t);Oe.push(t)}(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=113,n=126,r=0,o="";return arguments[r].split(o).map((function(e){return e.charCodeAt(r)>n?e:String.fromCharCode((e.charCodeAt(r)+i)%n)})).join(o)}(":::::ORTV[-PR_aVSVPNaR:::::ZVVTU\tPPONrtNVONtVWNW=_SVw\tVE=ZN=TP`\0T`Vo@Q^ROPbNZVTSZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg\tR^ZNATN>bROU^zc}nzyg\tR]ZN=TN>bRPtTn?bf?FZ_NQtfQc^^YQNq`gdSp?cyZ^P^fQc^^QQNWQ^aRvZPNTP`\0T`Vo@Q^RWN_fapzFqSFwfbOndSnzyuYz[oaNrS=\bZQNAZaN\\aZ\t[QSnS=\b[aNBZQZ\\aZ\t[QSnZVTaZ^P^fQc^^TRWQawR^ZNATN>bRPNU^zc}nzyg\tR^ZNATN>bROU^zc}nzyg\tRbZOVTN>bRPtYoTyuoz}}f`Bwo?=RQN\\Ot[cONZO>Wyfd\tgdbRaN]Ot[cONZZPRuupz_@feWyZ`bVfWX|gVup[N^xOSugnec|fdyndB{^T}fdB\0ndRf?FZVVPVwN[Otx\0uxvTF=ON^RSNN\\PNtENZVVPPtXPNtRN?=?]q[VD|{\\oyo`oOu}F\tSAe`tn[t\tu\b8^a]qx\bE_^ZN?[QC\0yuOpybY8r\\RPAS=8rUq\0E8>xean^e\bf]Y`XO}{C[Ur^?\0x[SRXvVQ\\CFr}QnAPRQFO=Yw\0_TePCOFV@|N>ROXcDrT<>bW<ssO?NOT{^s]uU\0gS\bBffsfE\0AfDyQEZR`]XBo|Qw}yYdwwTvOFcBndUz^\\{]\tb=^yQYSTQ`]\0?tR{WRUun\\\0bVe_E|VWWV|r\tAo\0\tF`fdzCnRtq\br\t\b8eBp=Z\\TRaadc}@Eub`quuNqAdF\0aUay{}x>tgVz`\t_YBFwu_q?egt8v[o\x008\twTQcrA\t<z{DZoEE^rZTrpaZQzqpBY]^zt8[bQv}yEWw\tXDYQB\0QB\bx_^X]|uEDtPf[n[r_bpB[bE}?ung|bnU|NYOoedY_tvXySZfYPdWV]OE^\bOFwA}<uXoO}_NDz8aonzWOfcv@?>snfqu@FeEx^\\\bVfuO`\\\0tSg]zDU}QrAT|\tOZV|OvpVD<sN@z`<_cSrNCW>?=Au?g_8v{|}}WF>Sr>QBxO\td_D}eBb?Uq^b\t[y}x]}{?P|BQtecTB[pQBW>|p|nfv\0zUxOO}WqwE=<PURZy@X8r\\]u=<pPNRNNn\\OtaO<ZOETPdPT`NTT8RVOQ^^`SuO`gdSp?cyVRg\bo?B=VR[OZO=TN>bqQt^dOO`FyWadZcAD\tpeXybcW@}Qf\\QNsOt[cU`ZRTQNdtOaAFXw=\tPCVxsv?{`a\bvS8YQ[aN]Ot[cU_ZONsEROaNQN^U<ZNTN>bqQ^RNVOOwN[Otx\0uxvTF=ON^SNN\\PNtRNrx\ta[}tP_g8FbD\0^\0qt<f88ufuN]^}]gp\bqYudF88Fas_Ef`\t?^x>X}esa{>\\r?eE]CC_cZ[vQs\t\t>gX[szONg=^pn=<e]nbSz\bZvac\b[w^nA_`vP|@8w[}nQobe=??oRYf{vpRxcC}yCd>8[NDx{Ne\\t8oou=guC>>gvb}ACd\t``Ntq\0yC[Q{|ynpNQqSqzxF<_PFDw<]Bnnu>F<XgU_Zf\\\\A=gu\\codOwQ]oQ<f>gv_pwozwC}xX>C`c]suEdfW?cbeo\b`BbyR@eFTUwSud=t]sS\\onc\tXSq\t{\0DvAVBbnTqEE[QzDyqF`bF}R=Q?VeDo<Vzb\0w}D}NZ\0t}^?OyFP\bVaVNrTNYqe?[NRYTSQby@yzWvT`wQo}y]c_WgxBYCy\tRNRg@NZCaaq8?`\t^`?ryD\t=obzw?E]Ou]n@>bVzqAQT?@_zo@}CxWVTUsAYdNd?{APQr8{P]]AZ>aR\0[D<z?Tr@`u@X|YDwd_<p<>zWE>]\0=X`\b@uucp|^_Qb@uZouTX^o\0\\{PCq{ug8^f[YQAWad8FNqxFQE?ZOo\t}RnO\bsQc\txyccn=nxvs>bDBf\b\bW\\TuTnvAO^U\0QXC>xx8FxRFf<tJ:::::R[Q-PR_aVSVPNaR:::::"));var ke=2*Math.PI,Ce=Math.PI/2;function Pe(e){return e>0&&e<=ke?e:(e%ke+ke)%ke}var Be=function(e){function i(t){var i=e.call(this,t,1,.1,1e3)||this;return i.pose={longitude:0,latitude:0,fov:t,distance:0,offset:new r.Vector3},i.computePose(),i}return t.__extends(i,e),i.prototype.computePose=function(){var e=this.getWorldDirection(new r.Vector3);return this.pose.longitude=Pe(-Math.atan2(e.x,-e.z)),this.pose.latitude=-Math.asin(e.y/1),this.pose.fov=this.fov,this.pose.distance=0,this.pose.offset.copy(this.position),this},i.prototype.setFromPose=function(e){var t,i,n,o,s,a=Pe(null!==(t=e.longitude)&&void 0!==t?t:this.pose.longitude),u=Math.max(1e-4-Ce,Math.min(Ce-1e-4,null!==(i=e.latitude)&&void 0!==i?i:this.pose.latitude)),c=null!==(n=e.fov)&&void 0!==n?n:this.pose.fov,l=null!==(o=e.distance)&&void 0!==o?o:this.pose.distance,h=null!==(s=e.offset)&&void 0!==s?s:this.pose.offset,d=function(e){var t=Math.abs(Math.cos(e.latitude));return new r.Vector3(-Math.sin(e.longitude)*t,-Math.sin(e.latitude),-Math.cos(e.longitude)*t)}({longitude:a,latitude:u}).normalize();return this.position.set(0,0,0),this.lookAt(d),this.position.add(h).sub(d.clone().setLength(l)),this.fov!==c&&(this.fov=c,this.updateProjectionMatrix()),this.updateMatrixWorld(),this.pose.longitude=a,this.pose.latitude=u,this.pose.fov=c,this.pose.distance=l,this.pose.offset.copy(h),this},i.prototype.copyPose=function(){return{longitude:this.pose.longitude,latitude:this.pose.latitude,fov:this.pose.fov,distance:this.pose.distance,offset:this.pose.offset.clone()}},i}(r.PerspectiveCamera),_e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(i,e),i.prototype.add=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];return e.prototype.add.apply(this,t)},i.prototype.remove=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];return e.prototype.remove.apply(this,t)},i}(r.Scene),Ue=function(e){function i(t){var i=t.preserveDrawingBuffer,n=void 0===i||i,o=t.backgroundColor,s=void 0===o?1579548:o,a=t.backgroundAlpha,u=void 0===a?1:a,c=t.pixelRatio,l=void 0===c?1:c,h=t.antialias,d=void 0!==h&&h,p=e.call(this,{antialias:d,preserveDrawingBuffer:n,alpha:u<1})||this;return p.setPixelRatio(l),p.setClearColor(s,u),p.outputEncoding=r.sRGBEncoding,p.autoClear=!0,p}return t.__extends(i,e),i}(r.WebGLRenderer);function Re(e){return null==e}function Qe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t]}function Ye(){return(65536*(1+Math.random())|0).toString(16).substring(1)}function Fe(){return(Ye()+Ye()+"-"+Ye()+"-4"+Ye().substr(0,3)+"-"+Ye()+"-"+Ye()+Ye()+Ye()).toLowerCase()}var Ve="undefined"!=typeof performance&&void 0!==performance.timing?performance.timing.navigationStart:Date.now(),He="undefined"!=typeof performance?function(){return Ve+performance.now()}:function(){return Date.now()},Ge=function(){if("undefined"!=typeof window){var e=window;return e.requestAnimationFrame||e.mozRequestAnimationFrame||e.webkitRequestAnimationFrame||e.msRequestAnimationFrame||function(e){return setTimeout(e,16)}}return function(e){return setTimeout(e,16)}}(),We=function(){function e(){this.frames=[],this.stoped=!1,this.time=He(),this.loop=this.loop.bind(this),this.loop()}return Object.defineProperty(e,"shared",{get:function(){return this.sharedInstance||(this.sharedInstance=new e),this.sharedInstance},enumerable:!1,configurable:!0}),e.prototype.loop=function(){if(!this.stoped){var e=He(),t=e-this.time;this.time=e;for(var i=[],n=0,r=this.frames;n<r.length;n++){var o=r[n];if(o.delay>0)o.delay=o.delay-1;else{try{o.callback(e,t)}catch(e){console.error(e)}o.once&&i.push(o)}}i.length>0&&(this.frames=this.frames.filter((function(e){return-1===i.indexOf(e)}))),Ge(this.loop)}},e.prototype.remove=function(e){var t=this.frames.indexOf(e);t>=0&&this.frames.splice(t,1)},e.prototype.add=function(e,t,i,n){var r=this;void 0===t&&(t=!1),void 0===i&&(i=0),void 0===n&&(n=5);var o={callback:e,once:t,delay:i,order:n};return this.frames.push(o),this.frames.sort((function(e,t){return e.order-t.order})),function(){return r.remove(o)}},e.prototype.disponse=function(){this.stoped=!0,this.frames.length=0},e.prototype.getFrameTime=function(e){return this.add((function(t,i){return e(i)}),!0,0,0)},e}(),qe=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.floorIndex=0,t.needsRender=!0,t}return t.__extends(i,e),i}(r.Mesh),Ke=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.needsRender=!0,t}return t.__extends(i,e),i.prototype.getTransparent=function(){var e;return this.traverse((function(t){void 0===e&&t instanceof qe&&t.material.forEach((function(t){void 0===e&&1===t.uniforms.originOpacity.value&&(e=t.transparent)}))})),null!=e&&e},i.prototype.setTransparent=function(e){this.traverse((function(t){t instanceof qe&&t.material.forEach((function(t){1===t.uniforms.originOpacity.value&&(t.transparent=e)}))}))},i.prototype.getMaterial=function(){var e=null;return this.traverse((function(t){if(null===e&&t instanceof qe){var i=t.material[0];e={pano0:i.pano0,pano1:i.pano1,modelAlpha:i.modelAlpha,progress:i.progress,useBlackTransition:i.useBlackTransition,perspToOrtho:i.perspToOrtho,opacity:i.opacity,panoVideo:i.panoVideo}}})),e},i.prototype.setMaterial=function(e){this.traverse((function(t){t instanceof qe&&t.material.forEach((function(t){void 0!==e.pano0&&(t.pano0=e.pano0),void 0!==e.pano1&&(t.pano1=e.pano1),void 0!==e.modelAlpha&&(t.modelAlpha=e.modelAlpha),void 0!==e.progress&&(t.progress=e.progress),void 0!==e.useBlackTransition&&(t.useBlackTransition=e.useBlackTransition),void 0!==e.perspToOrtho&&(t.perspToOrtho=e.perspToOrtho),void 0!==e.opacity&&(t.opacity=e.opacity),void 0!==e.panoVideo&&(t.panoVideo=e.panoVideo)}))}))},i.prototype.disposeMaterial=function(){this.traverse((function(e){if(e instanceof qe){var t=[];e.material.forEach((function(e){var i=e.uniforms;Object.keys(i).map((function(e){if(["pano0DepthMap"].indexOf(e)>=0)i[e].value=null;else{var n=i[e].value;n&&"function"==typeof n.dispose&&-1===t.indexOf(n)&&(i[e].value=null,t.push(n))}})),e.dispose()})),t.forEach((function(e){return e.dispose()}))}}))},i.prototype.disposeGeometry=function(){this.traverse((function(e){e instanceof qe&&e.geometry.dispose()}))},i}(r.Group),Ze=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.floorIndex=0,t}return t.__extends(i,e),i}(Ke),Xe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=113,n=126,r=0,o="";return arguments[r].split(o).map((function(e){return e.charCodeAt(r)>n?e:String.fromCharCode((e.charCodeAt(r)+i)%n)})).join(o)}("{vs|z-rp@-z|qryPr{rH{vs|z-sy|n-}r}a|\\u|Hn\bv{t-rp@-[|znyHn\bv{t-rp@-cvr]|vv|{Hn\bv{t-rp@-|yq]|vv|{H0v{pyqr-Ip|zz|{K0v{pyqr-Il}nlrrK0v{pyqr-I?l}nlrrK0v{pyqr-Ip|y|l}nlrrK|vq-znv{56-\n--0v{pyqr-IlrrK--0v{pyqr-I?lrrK--0v{pyqr-Ip|y|lrrK--0v{pyqr-Iortv{{|znylrrK--0v{pyqr-Iqrsny{|znylrrK--rpA-n{s|zrq-J-rpA5}|vv|{9->;=6H--rpA-z]|vv|{-J-z|qrycvrZnv-7-n{s|zrqH--[|zny-J-{|znyv\tr5n{s|zrq[|zny6H--cvr]|vv|{-J-:z]|vv|{;\b\tH--|yq]|vv|{-J-5z|qryZnv-7-n{s|zrq6;\b\tH--tyl]|vv|{-J-}|wrpv|{Znv-7-z|qrycvrZnv-7-n{s|zrqH--<<-修正正交相机模拟--rp@-pnzrn[|zny-J-5z|qrycvrZnv-7-rpA5=;=9-=;=9->;=9-=;=66;\b\tH--sy|n-|u|Qvn{pr-J-zn5=;=>9-q|5pnzrn[|zny9-z|qryPr{r-:-pnzrn]|vv|{66H--tyl]|vv|{;-J-zv5-tyl]|vv|{;9-tyl]|vv|{;-7-5-tyl]|vv|{;\t-<-|u|Qvn{pr-69-}r}a|\\u|-6H--tyl]|vv|{;\b-J-zv5-tyl]|vv|{;\b9-tyl]|vv|{;\b-7-5-tyl]|vv|{;\t-<-|u|Qvn{pr-69-}r}a|\\u|-6H\f"),Je=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=113,n=126,r=0,o="";return arguments[r].split(o).map((function(e){return e.charCodeAt(r)>n?e:String.fromCharCode((e.charCodeAt(r)+i)%n)})).join(o)}("0qrsv{r-OYNPXlP\\Y\\_-rpA5=;=EC9-=;>=C9-=;>AF9->;=60qrsv{r-aNb-C;?E@>EB?0vs-qrsv{rq5b`RlYbZV[N[PR6p-]n{|]vpr-\n--nz}yrPor-zn}H--nz}yrPor-yzv{n{prZn}H--znA-znvH\fH0ryrp-]n{|]vpr-\n--nz}yrPor-zn}H--znA-znvH\fH0r{qvsp-]n{|cvqr|-\n--rp?-v\trH--znA-znvH--sy|n-ny}unH--nz}yr?Q-zn}H\fH{vs|z-rp@-qvssrH{vs|z-rp@-rzvvrH{vs|z-rp@-}rpynH{vs|z-sy|n-uv{v{rH{vs|z-sy|n-r}|rH{vs|z-sy|n-|}npv\bH{vs|z-sy|n-|vtv{\\}npv\bH{vs|z-sy|n-z|qryNy}unH{vs|z-sy|n-}|trH{vs|z-]n{|]vpr-}n{|=H{vs|z-]n{|]vpr-}n{|>H0vs-qrsv{rq5b`Rl]N[\\lcVQR\\6--{vs|z-]n{|cvqr|-}n{|cvqr|H0r{qvsn\bv{t-rp@-|yq]|vv|{H0v{pyqr-Ip|zz|{K0v{pyqr-I}npxv{tK0v{pyqr-Ip|y|l}nlsntzr{K0v{pyqr-Il}nlsntzr{K0v{pyqr-I?l}nlsntzr{K0v{pyqr-Izn}l}nlsntzr{K0v{pyqr-Iny}unzn}l}nlsntzr{K0v{pyqr-In|zn}l}nlsntzr{K0v{pyqr-Iyvtuzn}l}nlsntzr{K0v{pyqr-Irzvvrzn}l}nlsntzr{K0v{pyqr-Ir{zn}l}nlsntzr{K0v{pyqr-Itnqvr{zn}l}nlsntzr{K0v{pyqr-Is|tl}nlsntzr{K0v{pyqr-IoqsK0v{pyqr-Iyvtul}nlortv{K0v{pyqr-Iyvtul}u|{tl}nlsntzr{Krp?-|P||q5rp@-rp|6-\n--sy|n--J-yr{tu5rp|6H--sy|n-urn-J-np|5rp|;\b-<-6H--sy|n-}uv-J-nn{5rp|;9-rp|;\t6H--r{-rp?5=;B-8-}uv-<-aNb9-urn-<-]V6H\f|vq-znv{56-\n--rpA-qvssrP|y|-J-rpA5qvssr9-|vtv{\\}npv\b6H--_rsyrprqYvtu-rsyrprqYvtu-J-_rsyrprqYvtu5rp@5=;=69-rp@5=;=69-rp@5=;=69-rp@5=;=66H--rp@-|nyRzvvr_nqvn{pr-J-rzvvrH--0v{pyqr-Izn}lsntzr{K--0v{pyqr-Ip|y|lsntzr{K--0v{pyqr-Iny}unzn}lsntzr{K--0v{pyqr-Iny}unrlsntzr{K--0v{pyqr-I}rpynzn}lsntzr{K--0v{pyqr-I{|znylsntzr{lortv{K--0v{pyqr-I{|znylsntzr{lzn}K--0v{pyqr-Irzvvrzn}lsntzr{K--0v{pyqr-Iyvtul}u|{tlsntzr{K--0v{pyqr-Iyvtulsntzr{lortv{K--<<-调整曝光值--vnqvn{pr-J-vnqvn{pr-7-r}|rH--0v{pyqr-Iyvtulsntzr{lzn}K--0v{pyqr-Iyvtulsntzr{lr{qK--0v{pyqr-In|zn}lsntzr{K--<<-减少方向光对模型的影响--rp@-|t|v{tYvtu-J-5rsyrprqYvtu;qvrpQvssr-7-=;?6-8----rsyrprqYvtu;v{qvrpQvssr-8----rsyrprqYvtu;v{qvrp`}rpyn-8----|nyRzvvr_nqvn{prH--<<-修复黑色面片的问题--vs-5|t|v{tYvtu;-K-=;=-\v\v-|t|v{tYvtu;t-K-=;=-\v\v-|t|v{tYvtu;o-K-=;=6-\n----tylSntP|y|-J-rpA5|t|v{tYvtu9-qvssrP|y|;n6H--\f-ryr-\n----tylSntP|y|-J-rpA5OYNPXlP\\Y\\_;\b\t9-qvssrP|y|;n6H--\f--rp@-}n{|=a|crr-J-5|yq]|vv|{-:-}n{|=;znvh@j;\b\t6-7-zn@5}n{|=;znv6H--rp@-}n{|>a|crr-J-5|yq]|vv|{-:-}n{|>;znvh@j;\b\t6-7-zn@5}n{|>;znv6H--rpA-}n{|P|y|H--rpA-}n{|=P|y|-J-rrPor5}n{|=;zn}9-}n{|=a|crr6H--rpA-}n{|>P|y|-J-rrPor5}n{|>;zn}9-}n{|>a|crr6H--0vs-qrsv{rq5b`RlYbZV[N[PR6----}n{|=P|y|;n-J->;=-:-rrPor5}n{|=;yzv{n{prZn}9-}n{|=a|crr6;H----}n{|>P|y|;n-J->;=-:-rrPor5}n{|>;yzv{n{prZn}9-}n{|>a|crr6;H--0r{qvs--0vs-qrsv{rq5b`RlOYNPXla_N[`VaV\\[6----sy|n-oynpx]|tr-J-np|5:?;=-7-}|tr-8->;=6H----}n{|P|y|-J-zv5}n{|=P|y|9-OYNPXlP\\Y\\_9-zv{5>;=9-oynpx]|tr66H----}n{|P|y|-J-zv5}n{|P|y|9-}n{|>P|y|9-zn5=;=9-oynpx]|tr-:-?;=66H--0ryr----}n{|P|y|-J-zv5}n{|=P|y|9-}n{|>P|y|9-}|tr6H--0r{qvs--0vs-qrsv{rq5b`Rl]N[\\lcVQR\\6----rp@-pnzrna|crr-J-|yq]|vv|{-:-pnzrn]|vv|{H----rpA-zn}P||q-J-rpA5pnzrna|crr9->;=6-7-}n{|cvqr|;znvH----rp?--J-rp?5------=;B-8-zn}P||q;-<-zn}P||q;\t-<-}n{|cvqr|;v\tr;9------=;B-:-zn}P||q;\b-<-zn}P||q;\t-<-}n{|cvqr|;v\tr;\b----6H----rpA-vqr|P|y|-J-rr?Q5}n{|cvqr|;zn}9-6H----sy|n-znpu-J-5>;=-:-r}5=;=9-zn}P||q;\t66-7-5>;=-:-r}5=;B9-no5;-:-=;B666-7-5>;=-:-r}5=;B9-no5;\b-:-=;B666H----sy|n-ny}un-J-pynz}5=;=9->;=9-B;=-7-5>;=-:-pynz}5qvn{pr59-rp?5=;B9-=;B66-<-=;BB-9-=;=9->;=666H----}n{|P|y|-J-zv5}n{|P|y|9-vqr|P|y|9-znpu-7-ny}un-7-}n{|cvqr|;ny}un6H--0r{qvs--tylSntP|y|-J-rpA5tylSntP|y|;to9-|}npv\b6H--tylSntP|y|-J-zv5}n{|P|y|9-tylSntP|y|9-z|qryNy}un6H\f");function $e(){return"undefined"==typeof document?{}:document.createElementNS("http://www.w3.org/1999/xhtml","img")}var et=$e();et.width=et.height=8;var tt=new r.Texture(et);tt.name="EMPTY_TEXTURE";var it=new r.CubeTexture([et,et,et,et,et,et]);it.name="EMPTY_CUBE_TEXTURE",tt.dispose=it.dispose=function(){};var nt=Object.assign({modelAlpha:new r.Uniform(0),originOpacity:new r.Uniform(1),progress:new r.Uniform(0),pano0:new r.Uniform({map:it,luminanceMap:null,matrix:new r.Matrix4}),pano1:new r.Uniform({map:it,luminanceMap:null,matrix:new r.Matrix4}),pano0DepthMap:new r.Uniform(null),panoVideo:new r.Uniform(null),modelCenter:new r.Uniform(new r.Vector3),perspToOrtho:new r.Uniform(0)},{exposure:new r.Uniform(1),emissive:new r.Uniform(new r.Color(0)),emissiveMap:new r.Uniform(null),specular:new r.Uniform(new r.Color(1118481)),specularMap:new r.Uniform(null),normalMap:new r.Uniform(null),bumpMap:new r.Uniform(null),shininess:new r.Uniform(30)},r.UniformsLib.common,r.UniformsLib.lights),rt=function(e){function i(t){var i,n,o,s,a,u,c,l;void 0===t&&(t={});var h=e.call(this,{vertexShader:Xe,fragmentShader:Je,uniforms:r.UniformsUtils.clone(nt),defines:{USE_MAP:!0,USE_UV:!0,USE_LUMINANCE:!1,USE_BLACK_TRANSITION:!1,USE_PANO_VIDEO:!1},blending:r.NoBlending,lights:!0})||this;return Object.defineProperties(h,{pano0:{get:function(){var e=this.uniforms.pano0.value;return e.map===it?null:{map:e.map,luminanceMap:e.luminanceMap,matrix:e.matrix.clone()}},set:function(e){this.uniforms.pano0.value=null===e?{map:it,luminanceMap:null,matrix:new r.Matrix4}:{map:e.map,luminanceMap:e.luminanceMap,matrix:e.matrix.clone()};var t=null!==this.uniforms.pano0.value.luminanceMap&&null!==this.uniforms.pano1.value.luminanceMap;this.defines.USE_LUMINANCE!==t&&(this.defines.USE_LUMINANCE=t,this.needsUpdate=!0)}},pano1:{get:function(){var e=this.uniforms.pano1.value;return e.map===it?null:{map:e.map,luminanceMap:e.luminanceMap,matrix:e.matrix.clone()}},set:function(e){this.uniforms.pano1.value=null===e?{map:it,luminanceMap:null,matrix:new r.Matrix4}:{map:e.map,luminanceMap:e.luminanceMap,matrix:e.matrix.clone()};var t=null!==this.uniforms.pano0.value.luminanceMap&&null!==this.uniforms.pano1.value.luminanceMap;this.defines.USE_LUMINANCE!==t&&(this.defines.USE_LUMINANCE=t,this.needsUpdate=!0)}},modelAlpha:{get:function(){return this.uniforms.modelAlpha.value},set:function(e){this.uniforms.modelAlpha.value=e}},progress:{get:function(){return this.uniforms.progress.value},set:function(e){this.uniforms.progress.value=e}},useBlackTransition:{get:function(){return this.defines.USE_BLACK_TRANSITION},set:function(e){this.defines.USE_BLACK_TRANSITION!==e&&(this.defines.USE_BLACK_TRANSITION=e,this.needsUpdate=!0)}},opacity:{get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e,this.blending=e<1?r.NormalBlending:r.NoBlending}},perspToOrtho:{get:function(){return this.uniforms.perspToOrtho.value},set:function(e){this.uniforms.perspToOrtho.value=e}},panoVideo:{get:function(){return this.uniforms.panoVideo.value},set:function(e){this.uniforms.panoVideo.value=e;var t=null!==e;t!==this.defines.USE_PANO_VIDEO&&(this.defines.USE_PANO_VIDEO=t,this.needsUpdate=!0)}}}),h.pano0=null!==(i=t.pano0)&&void 0!==i?i:null,h.pano1=null!==(n=t.pano1)&&void 0!==n?n:null,h.modelAlpha=null!==(o=t.modelAlpha)&&void 0!==o?o:1,h.progress=null!==(s=t.progress)&&void 0!==s?s:0,h.useBlackTransition=null!==(a=t.useBlackTransition)&&void 0!==a&&a,h.perspToOrtho=null!==(u=t.perspToOrtho)&&void 0!==u?u:0,h.opacity=null!==(c=t.opacity)&&void 0!==c?c:1,h.panoVideo=null!==(l=t.panoVideo)&&void 0!==l?l:null,h}return t.__extends(i,e),i}(r.ShaderMaterial),ot=new r.Vector3(0,0,0),st=function(e){function i(t,i){void 0===i&&(i=ot);var n=e.call(this)||this,o=new r.BoxBufferGeometry(t.max.x-t.min.x+2*i.x,t.max.y-t.min.y+2*i.y,t.max.z-t.min.z+2*i.z,1,1);o.groups.length=0,o.groups.push({start:0,count:36,materialIndex:0}),o.applyMatrix4((new r.Matrix4).makeScale(-1,1,1));var s=new rt;s.defines.USE_MAP=!1,s.defines.USE_UV=!1,s.uniforms.diffuse.value=new r.Color(16777215);var a=new qe(o,[s]);return a.floorIndex=-1,a.position.copy(t.getCenter(new r.Vector3)),a.frustumCulled=!1,n.renderOrder=-1,n.add(a),n.boundingBox=new r.Box3,n.computeBoundingBox(),n}return t.__extends(i,e),i.prototype.computeBoundingBox=function(){this.boundingBox.setFromObject(this)},i.prototype.dispose=function(){this.disposeMaterial(),this.disposeGeometry()},i}(Ze);function at(e,t){return void 0===t&&(t=ot),new st(e,t)}var ut,ct,lt,ht,dt=function(){function e(e,t,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),this.x=e,this.y=t,this.z=i}return e.prototype.copy=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},e.prototype.set=function(e,t,i){return this.x=e,this.y=t,this.z=i,this},e.prototype.fromArray=function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},e.prototype.add=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this},e.prototype.multiplyScalar=function(e){return this.x*=e,this.y*=e,this.z*=e,this},e.prototype.subVectors=function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},e.prototype.dot=function(e){return this.x*e.x+this.y*e.y+this.z*e.z},e.prototype.cross=function(e){var t=this.x,i=this.y,n=this.z;return this.x=i*e.z-n*e.y,this.y=n*e.x-t*e.z,this.z=t*e.y-i*e.x,this},e.prototype.crossVectors=function(e,t){var i=e.x,n=e.y,r=e.z,o=t.x,s=t.y,a=t.z;return this.x=n*a-r*s,this.y=r*o-i*a,this.z=i*s-n*o,this},e.prototype.clone=function(){return new e(this.x,this.y,this.z)},e}(),pt=function(){function e(e,t,i,n,r){this._extentsMin=e,this._extentsMax=t,this._startIndex=i,this._endIndex=n,this._level=r,this._node0=null,this._node1=null,this.elementCount=n-i,this.center=[(e.x+t.x)/2,(e.y+t.y)/2,(e.z+t.z)/2];var o,s=this.size=[t.x-e.x,t.y-e.y,t.z-e.z];o=s[0]>s[1]?s[1]>s[2]?[2,1,0]:s[0]>s[2]?[1,2,0]:[1,0,2]:s[1]>s[2]?s[0]>s[2]?[2,0,1]:[0,2,1]:[0,1,2],this.order=o}return e.prototype.clearShapes=function(){this._startIndex=-1,this._endIndex=-1,this.elementCount=0},e}(),At=(ut=new dt,ct=new dt,lt=new dt,ht=new dt,function(e,t,i,n,r,o){ct.subVectors(t,e),lt.subVectors(i,e),ht.crossVectors(ct,lt);var s,a=r.dot(ht);if(a>0){if(o)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}ut.subVectors(n,e);var u=s*r.dot(lt.crossVectors(ut,lt));if(u<0)return null;var c=s*r.dot(ct.cross(ut));if(c<0)return null;if(u+c>a)return null;var l=-s*ut.dot(ht);if(l<0)return null;var h=l/a;return(new dt).copy(r).multiplyScalar(h).add(n)});function ft(e,t,i){var n={min:0,max:0};t.x>=0?(n.min=(i._extentsMin.x-e.x)*t.x,n.max=(i._extentsMax.x-e.x)*t.x):(n.min=(i._extentsMax.x-e.x)*t.x,n.max=(i._extentsMin.x-e.x)*t.x);var r={min:0,max:0};if(t.y>=0?(r.min=(i._extentsMin.y-e.y)*t.y,r.max=(i._extentsMax.y-e.y)*t.y):(r.min=(i._extentsMax.y-e.y)*t.y,r.max=(i._extentsMin.y-e.y)*t.y),n.min>r.max||r.min>n.max)return!1;r.min>n.min&&(n.min=r.min),r.max<n.max&&(n.max=r.max);var o={min:0,max:0};return t.z>=0?(o.min=(i._extentsMin.z-e.z)*t.z,o.max=(i._extentsMax.z-e.z)*t.z):(o.min=(i._extentsMax.z-e.z)*t.z,o.max=(i._extentsMin.z-e.z)*t.z),!(n.min>o.max||o.min>n.max)&&(o.min>n.min&&(n.min=o.min),o.max<n.max&&(n.max=o.max),!(n.max<0))}var Mt=function(){function e(e,t){void 0===t&&(t=10),this._trianglesArray=e,this._maxTrianglesPerNode=t,this._bboxArray=this.calcBoundingBoxes(e),this._bboxHelper=new Float32Array(this._bboxArray.length),this._bboxHelper.set(this._bboxArray);var i=e.length/9,n=this.calcExtents(0,i,1e-6);this._rootNode=new pt(n[0],n[1],0,i,0),this._nodesToSplit=[this._rootNode],this.splitNode()}return e.prototype.calcBoundingBoxes=function(e){for(var t,i,n,r,o,s,a,u,c,l,h,d,p,A,f,M=e.length/9,g=new Float32Array(7*M),y=0,m=0,v=0;v<M;y+=9,m+=7,v++)t=e[y],i=e[y+1],n=e[y+2],r=e[y+3],o=e[y+4],s=e[y+5],r<(l=t)&&(l=r),(a=e[y+6])<l&&(l=a),o<(h=i)&&(h=o),(u=e[y+7])<h&&(h=u),s<(d=n)&&(d=s),(c=e[y+8])<d&&(d=c),r>(p=t)&&(p=r),a>p&&(p=a),o>(A=i)&&(A=o),u>A&&(A=u),s>(f=n)&&(f=s),c>f&&(f=c),g[m]=v,g[m+1]=l,g[m+2]=h,g[m+3]=d,g[m+4]=p,g[m+5]=A,g[m+6]=f;return g},e.prototype.splitNode=function(){if(this._rootNode)for(this._splitNode(this._rootNode);this._nodesToSplit.length>0;)this._splitNode(this._nodesToSplit.pop())},e.prototype._splitNode=function(e){if(!(e.elementCount<=this._maxTrianglesPerNode||0===e.elementCount)){for(var t=e._startIndex,i=e._endIndex,n=[[],[],[]],r=[[],[],[]],o=e.center,s=7*(v=t);v<i;v++,s+=7)for(var a=0;a<3;a++)(this._bboxArray[s+1+a]+this._bboxArray[s+4+a])/2<o[a]?n[a][n[a].length]=v:r[a][r[a].length]=v;var u=[!(n[0].length&r[0].length),!(n[1].length&r[1].length),!(n[2].length&r[2].length)];if(!(u[0]&u[1]&u[2])){var c,l,h=e.order;for(a=0;a<3;a++){var d=h[a];if(!u[d]){c=n[d],l=r[d];break}}for(var p,A=t,f=A+c.length,M=f,g=i,y=e._startIndex,m=c.concat(l),v=0;v<m.length;v++)p=m[v],this._bboxHelper[7*y]=this._bboxArray[7*p],this._bboxHelper[7*y+1]=this._bboxArray[7*p+1],this._bboxHelper[7*y+2]=this._bboxArray[7*p+2],this._bboxHelper[7*y+3]=this._bboxArray[7*p+3],this._bboxHelper[7*y+4]=this._bboxArray[7*p+4],this._bboxHelper[7*y+5]=this._bboxArray[7*p+5],this._bboxHelper[7*y+6]=this._bboxArray[7*p+6],y++;var N=this._bboxHelper.subarray(7*e._startIndex,7*e._endIndex);this._bboxArray.set(N,7*e._startIndex);var D=this.calcExtents(A,f,1e-6),w=this.calcExtents(M,g,1e-6),T=new pt(D[0],D[1],A,f,e._level+1),x=new pt(w[0],w[1],M,g,e._level+1);e._node0=T,e._node1=x,e.clearShapes(),this._nodesToSplit.push(T,x)}}},e.prototype.calcExtents=function(e,t,i){if(e>=t)return[{x:0,y:0,z:0},{x:0,y:0,z:0}];var n,r=7*e,o=7*t+1,s=this._bboxArray[r+1],a=this._bboxArray[r+2],u=this._bboxArray[r+3],c=this._bboxArray[r+4],l=this._bboxArray[r+5],h=this._bboxArray[r+6],d=this._bboxArray;for(r+=7;r<o;r+=7)(n=d[r+1])<s&&(s=n),(n=d[r+2])<a&&(a=n),(n=d[r+3])<u&&(u=n),(n=d[r+4])>c&&(c=n),(n=d[r+5])>l&&(l=n),(n=d[r+6])>h&&(h=n);return[{x:s-i,y:a-i,z:u-i},{x:c+i,y:l+i,z:h+i}]},e.prototype.intersectRay=function(e,t,i){for(var n=[this._rootNode],r=[],o=[],s=new dt(1/t.x,1/t.y,1/t.z);n.length>0;){var a=n.pop();if(ft(e,s,a)){a._node0&&n.push(a._node0),a._node1&&n.push(a._node1);for(var u=a._startIndex;u<a._endIndex;u++)r.push(this._bboxArray[7*u])}}var c=new dt,l=new dt,h=new dt,d=new dt(e.x,e.y,e.z),p=new dt(t.x,t.y,t.z);for(u=0;u<r.length;u++){var A=r[u];c.fromArray(this._trianglesArray,9*A),l.fromArray(this._trianglesArray,9*A+3),h.fromArray(this._trianglesArray,9*A+6);var f=At(c,l,h,d,p,i);f&&o.push({triangle:[c.clone(),l.clone(),h.clone()],triangleIndex:A,intersectionPoint:f})}return o},e.prototype.dispose=function(){this._trianglesArray=new Float32Array,this._bboxArray=new Float32Array,this._bboxHelper=new Float32Array,this._rootNode=null,this._nodesToSplit.length=0},e}();var gt,yt=(gt="$$FIVE_EVENT$$","undefined"==typeof Symbol?"$Symbol<"+gt+">$":Symbol(gt));function mt(e){return e[yt]||(e[yt]={}),e[yt]}var vt=function(){function e(){}return e.prototype.hasListener=function(e){var t=mt(this);return t&&t[e]&&t[e].length>0},e.prototype.on=function(e,t,i){var n=this,r=mt(this);return r[e]||(r[e]=[]),r[e].push([t,i||!1]),function(){return n.off(e,t)}},e.prototype.once=function(e,t){return this.on(e,t,!0)},e.prototype.off=function(e,t){if(void 0!==e){var i,n=mt(this);if(n[e]||(n[e]=[]),void 0!==t){for(var r=0;r<n[e].length&&n[e][r][0]!==t;r++);r<n[e].length&&n[e].splice(r,1)}else n[e].length=0}else(i=this)[yt]||delete i[yt]},e.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];for(var n=!1,r=mt(this),o=r[e]||[],s=0,a=o.slice();s<a.length;s++){var u=a[s],c=u[0],l=u[1],h=void 0!==l&&l,d=c.apply(void 0,t);h&&this.off(e,c),!1===d&&(n=!0)}return n},e}();function Nt(e){Object.freeze(e);var t="function"==typeof e,i=Object.prototype.hasOwnProperty;return Object.getOwnPropertyNames(e).forEach((function(n){!i.call(e,n)||t&&("caller"===n||"callee"===n||"arguments"===n)||null===e[n]||"object"!=typeof e[n]&&"function"!=typeof e[n]||Object.isFrozen(e[n])||Nt(e[n])})),e}var Dt=/^([^.]+)(\.([^.]+))*$/;function wt(e){return/^(([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])(\.(?!$)|$)){4}$/.test(e)}function Tt(e,t){return Dt.test(e)&&Dt.test(t)&&function(e,t){if("*"===e)return!0;var i=e.split(".").reverse(),n=t.split(".").reverse();if(i.length<=1)return e===t;for(var r=0;r<i.length;r++)if(i[r]!==n[r])return!1;return!0}(e,t)}var xt=[/\.([0-9a-z]+)\.jsonp([\?\#].*)?$/i,/jsonp_([0-9a-z]+)([\?\#].*)?$/i],Et=Nt(JSON.parse(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=113,n=126,r=0,o="";return arguments[r].split(o).map((function(e){return e.charCodeAt(r)>n?e:String.fromCharCode((e.charCodeAt(r)+i)%n)})).join(o)}("h-/y|pnyu|/9-/xr;p|z/9-/yvn{wvn;p|z/9-/rnyrr;p|z/9-/rnyrr;p{/9-/uv;p|z/9-/uv;p{/9-/ywpq{;p|z/9-/pnyp{|qr;vr/-j"))),jt=function(e){function i(t,i,n){return e.call(this,"[NETWORK]: response error(type: "+i+", reason: "+n+"): "+t)||this}return t.__extends(i,e),i}(Error),zt=function(e){function i(t,i,n){var r=e.call(this,"[NETWORK]: response error(type: "+i+", status: "+n+"): "+t)||this;return r.httpStatus=n,r}return t.__extends(i,e),i}(Error);!function(e){function i(t,i){return e.call(this,"[NETWORK]: request abort(type: "+i+"): "+t)||this}t.__extends(i,e)}(Error);var It=function(e){function i(t,i,n){return e.call(this,"[NETWORK]: request timeout(type: "+i+", timeout: "+n+"ms): "+t)||this}return t.__extends(i,e),i}(Error);function bt(e){for(var t=0,i=xt;t<i.length;t++){var n=i[t],r=e.match(n);if(r)return"jsonp_"+r[1]}return null}function Ot(e){return null!==bt(e)}function St(e){return xt.reduce((function(e,t){return e.replace(t,"")}),e)}function Lt(e){var t=e.match(/^[0-9a-z]+\:\/\/(([^:/?#]*)(?::[0-9]+)?)/);return t?t[2]:location.hostname}!function(e){function i(t,i,n){return e.call(this,"[NETWORK]: request forbidden(type: "+i+", reason: "+n+"): "+t)||this}t.__extends(i,e)}(Error);var kt=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(i,e),i}(vt);function Ct(e,t,i,n,r){return void 0===t&&(t={}),void 0===i&&(i=Qe),void 0===n&&(n=Qe),void 0===r&&(r=Qe),new Promise((function(o,s){var a,u=t.allowHosts?Et.concat(t.allowHosts):Et.slice(),c=Lt(e),l=bt(e);if(0!==location.hostname.length&&!wt(location.hostname)&&0===Et.filter((function(e){return Tt(e,location.hostname)})).length&&!wt(c)&&0===u.filter((function(e){return Tt(e,c)})).length){var h=l?"Script":"XMLHttpRequest",d=new jt(e,h,"request host("+c+") is not allowed");return n(d),s(d),void(null===(a=t.networkSubscribe)||void 0===a||a.emit("network",e,h,"forbidden",d.message))}if(l){var p=window,A=null,f=!1,M=He(),g=document.createElement("script");p[l]=function(r){var a,u,c=He(),h=c-M;if(delete p[l],g.parentNode&&g.parentNode.removeChild(g),null!==A&&(window.clearTimeout(A),A=null),!0!==f){if(0!==r.indexOf("data:")){var d=new zt(e,"Script",500);return n(d),s(d),void(null===(a=t.networkSubscribe)||void 0===a||a.emit("network",e,"Script","error",d.message))}var y=r.split(","),m=(y[0].match(/:(.*?);/)||[])[1],v=y[1];if("arraybuffer"===t.responseType||"blob"===t.responseType){for(var N=atob(y[1]),D=N.length,w=new Uint8Array(D),T=0;T<D;T++)w[T]=N.charCodeAt(T);v="arraybuffer"===t.responseType?w.buffer:new Blob([w],{type:m})}var x={body:v,meta:{source:e,requestTime:M,responseTime:c,costs:h,headers:{}}};i(x),o(x),null===(u=t.networkSubscribe)||void 0===u||u.emit("network",e,"Script","ok",JSON.stringify(x.meta)),f=!0}},g.src=e,document.body.appendChild(g),"number"==typeof t.timeout&&(A=window.setTimeout((function(){var i;if(A=null,!0!==f){f=!0;var r=new It(e,"Script",t.timeout||NaN);n(r),s(r),null===(i=t.networkSubscribe)||void 0===i||i.emit("network",e,"Script","timeout",r.message)}}),t.timeout))}else{var y=He(),m=!1,v=new XMLHttpRequest,N=function(){v&&(v.removeEventListener("timeout",D,!1),v.removeEventListener("progress",w,!1),v.removeEventListener("load",T,!1),v.removeEventListener("error",x,!1)),v=null,N=Qe},D=function(){var i;if(!0!==m){m=!0,N();var r=new It(e,"XMLHttpRequest",t.timeout||NaN);n(r),s(r),null===(i=t.networkSubscribe)||void 0===i||i.emit("network",e,"XMLHttpRequest","timeout",r.message)}},w=function(e){if(!0!==m&&e.lengthComputable){var t=e.loaded,i=e.total;r(t/i)}},T=function(n){var r;if(!0!==m){m=!0,N();var s=He(),a=s-y,u=function(e){if(!e)return{};for(var t={},i=e.trim().split("\n"),n=0;n<i.length;n++){var r=i[n],o=r.indexOf(":"),s=r.slice(0,o).trim().toLowerCase(),a=r.slice(o+1).trim();a&&(t[s]?t[s]+=", "+a:t[s]=a)}return t}(this.getAllResponseHeaders()),c=n.total,l={body:this.response,meta:{source:e,requestTime:y,responseTime:s,costs:a,headers:u,size:c}};i(l),o(l),null===(r=t.networkSubscribe)||void 0===r||r.emit("network",e,"XMLHttpRequest","ok",JSON.stringify(l.meta))}},x=function(){var i;if(!0!==m){m=!0,N();var r=new zt(e,"XMLHttpRequest",this.status);n(r),s(r),null===(i=t.networkSubscribe)||void 0===i||i.emit("network",e,"XMLHttpRequest","error",r.message)}};v.addEventListener("timeout",D,!1),v.addEventListener("progress",w,!1),v.addEventListener("load",T,!1),v.addEventListener("error",x,!1),t.responseType&&(v.responseType=t.responseType),"number"==typeof t.timeout&&(v.timeout=t.timeout),v.open("GET",e,!0),v.send(null)}}))}var Pt={};function Bt(e,t,i,n,r,o){return void 0===t&&(t={}),void 0===i&&(i=Qe),void 0===n&&(n=Qe),void 0===r&&(r=Qe),new Promise((function(s,a){var u,c=t.allowHosts?Et.concat(t.allowHosts):Et.slice(),l=Lt(e);if(0!==location.hostname.length&&!wt(location.hostname)&&0===Et.filter((function(e){return Tt(e,location.hostname)})).length&&!wt(l)&&0===c.filter((function(e){return Tt(e,l)})).length){var h=new jt(e,"Image","request host("+l+") is not allowed");return n(h),a(h),void(null===(u=t.networkSubscribe)||void 0===u||u.emit("network",e,"Image","forbidden",h.message))}var d=null!=o?o:new Image,p=He(),A=!1,f=null,M=function(){var n;if(d.removeEventListener("load",M,!1),d.removeEventListener("error",g,!1),null!==f&&(clearTimeout(f),f=null),!0!==A){var o=He();A=!0;var a={body:d,meta:{headers:{},source:e,requestTime:p,responseTime:o,costs:o-p}};r(1),i(a),s(a),null===(n=t.networkSubscribe)||void 0===n||n.emit("network",e,"Image","ok",JSON.stringify(a.meta))}},g=function(i){var r;if(d.removeEventListener("load",M,!1),d.removeEventListener("error",g,!1),null!==f&&(clearTimeout(f),f=null),!0!==A){A=!0;var o=new zt(e,"Image",0);n(o),a(o),null===(r=t.networkSubscribe)||void 0===r||r.emit("network",e,"Image","ok",o.message)}};"number"==typeof t.timeout&&(f=window.setTimeout((function(){var i;if(d.removeEventListener("load",M,!1),d.removeEventListener("error",g,!1),f=null,!0!==A){A=!0;var r=new It(e,"Image",t.timeout);n(r),a(r),null===(i=t.networkSubscribe)||void 0===i||i.emit("network",e,"Image","timeout",r.message)}}),t.timeout)),d.addEventListener("load",M,!1),d.addEventListener("error",g,!1),r(0),d.src=e}))}var _t=null,Ut=!1,Rt=[];function Qt(e){if(void 0===e&&(e=!1),e||!Ut)if(_t)Ut=!1;else{Ut=!0;var t=Rt.shift();if(t){try{t()}catch(e){}We.shared.add((function(){return Qt(!0)}),!0,2)}else Ut=!1}}function Yt(){_t=null,Qt()}function Ft(e){return new Promise((function(t,i){Rt.push((function(){try{t(e())}catch(e){i(e)}})),Qt()}))}var Vt={OutWindow:function(){this._windowSize=0}};Vt.OutWindow.prototype.create=function(e){this._buffer&&this._windowSize===e||(this._buffer=[]),this._windowSize=e,this._pos=0,this._streamPos=0},Vt.OutWindow.prototype.flush=function(){var e=this._pos-this._streamPos;if(0!==e){for(;e--;)this._stream.writeByte(this._buffer[this._streamPos++]);this._pos>=this._windowSize&&(this._pos=0),this._streamPos=this._pos}},Vt.OutWindow.prototype.releaseStream=function(){this.flush(),this._stream=null},Vt.OutWindow.prototype.setStream=function(e){this.releaseStream(),this._stream=e},Vt.OutWindow.prototype.init=function(e){e||(this._streamPos=0,this._pos=0)},Vt.OutWindow.prototype.copyBlock=function(e,t){var i=this._pos-e-1;for(i<0&&(i+=this._windowSize);t--;)i>=this._windowSize&&(i=0),this._buffer[this._pos++]=this._buffer[i++],this._pos>=this._windowSize&&this.flush()},Vt.OutWindow.prototype.putByte=function(e){this._buffer[this._pos++]=e,this._pos>=this._windowSize&&this.flush()},Vt.OutWindow.prototype.getByte=function(e){var t=this._pos-e-1;return t<0&&(t+=this._windowSize),this._buffer[t]},Vt.RangeDecoder=function(){},Vt.RangeDecoder.prototype.setStream=function(e){this._stream=e},Vt.RangeDecoder.prototype.releaseStream=function(){this._stream=null},Vt.RangeDecoder.prototype.init=function(){var e=5;for(this._code=0,this._range=-1;e--;)this._code=this._code<<8|this._stream.readByte()},Vt.RangeDecoder.prototype.decodeDirectBits=function(e){for(var t,i=0,n=e;n--;)this._range>>>=1,t=this._code-this._range>>>31,this._code-=this._range&t-1,i=i<<1|1-t,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8);return i},Vt.RangeDecoder.prototype.decodeBit=function(e,t){var i=e[t],n=(this._range>>>11)*i;return(2147483648^this._code)<(2147483648^n)?(this._range=n,e[t]+=2048-i>>>5,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8),0):(this._range-=n,this._code-=n,e[t]-=i>>>5,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8),1)},Vt.initBitModels=function(e,t){for(;t--;)e[t]=1024},Vt.BitTreeDecoder=function(e){this._models=[],this._numBitLevels=e},Vt.BitTreeDecoder.prototype.init=function(){Vt.initBitModels(this._models,1<<this._numBitLevels)},Vt.BitTreeDecoder.prototype.decode=function(e){for(var t=1,i=this._numBitLevels;i--;)t=t<<1|e.decodeBit(this._models,t);return t-(1<<this._numBitLevels)},Vt.BitTreeDecoder.prototype.reverseDecode=function(e){for(var t,i=1,n=0,r=0;r<this._numBitLevels;++r)i=i<<1|(t=e.decodeBit(this._models,i)),n|=t<<r;return n},Vt.reverseDecode2=function(e,t,i,n){for(var r,o=1,s=0,a=0;a<n;++a)o=o<<1|(r=i.decodeBit(e,t+o)),s|=r<<a;return s},Vt.LenDecoder=function(){this._choice=[],this._lowCoder=[],this._midCoder=[],this._highCoder=new Vt.BitTreeDecoder(8),this._numPosStates=0},Vt.LenDecoder.prototype.create=function(e){for(;this._numPosStates<e;++this._numPosStates)this._lowCoder[this._numPosStates]=new Vt.BitTreeDecoder(3),this._midCoder[this._numPosStates]=new Vt.BitTreeDecoder(3)},Vt.LenDecoder.prototype.init=function(){var e=this._numPosStates;for(Vt.initBitModels(this._choice,2);e--;)this._lowCoder[e].init(),this._midCoder[e].init();this._highCoder.init()},Vt.LenDecoder.prototype.decode=function(e,t){return 0===e.decodeBit(this._choice,0)?this._lowCoder[t].decode(e):0===e.decodeBit(this._choice,1)?8+this._midCoder[t].decode(e):16+this._highCoder.decode(e)},Vt.Decoder2=function(){this._decoders=[]},Vt.Decoder2.prototype.init=function(){Vt.initBitModels(this._decoders,768)},Vt.Decoder2.prototype.decodeNormal=function(e){var t=1;do{t=t<<1|e.decodeBit(this._decoders,t)}while(t<256);return 255&t},Vt.Decoder2.prototype.decodeWithMatchByte=function(e,t){var i,n,r=1;do{if(i=t>>7&1,t<<=1,r=r<<1|(n=e.decodeBit(this._decoders,(1+i<<8)+r)),i!==n){for(;r<256;)r=r<<1|e.decodeBit(this._decoders,r);break}}while(r<256);return 255&r},Vt.LiteralDecoder=function(){},Vt.LiteralDecoder.prototype.create=function(e,t){var i;if(!this._coders||this._numPrevBits!==t||this._numPosBits!==e)for(this._numPosBits=e,this._posMask=(1<<e)-1,this._numPrevBits=t,this._coders=[],i=1<<this._numPrevBits+this._numPosBits;i--;)this._coders[i]=new Vt.Decoder2},Vt.LiteralDecoder.prototype.init=function(){for(var e=1<<this._numPrevBits+this._numPosBits;e--;)this._coders[e].init()},Vt.LiteralDecoder.prototype.getDecoder=function(e,t){return this._coders[((e&this._posMask)<<this._numPrevBits)+((255&t)>>>8-this._numPrevBits)]},Vt.Decoder=function(){this._outWindow=new Vt.OutWindow,this._rangeDecoder=new Vt.RangeDecoder,this._isMatchDecoders=[],this._isRepDecoders=[],this._isRepG0Decoders=[],this._isRepG1Decoders=[],this._isRepG2Decoders=[],this._isRep0LongDecoders=[],this._posSlotDecoder=[],this._posDecoders=[],this._posAlignDecoder=new Vt.BitTreeDecoder(4),this._lenDecoder=new Vt.LenDecoder,this._repLenDecoder=new Vt.LenDecoder,this._literalDecoder=new Vt.LiteralDecoder,this._dictionarySize=-1,this._dictionarySizeCheck=-1,this._posSlotDecoder[0]=new Vt.BitTreeDecoder(6),this._posSlotDecoder[1]=new Vt.BitTreeDecoder(6),this._posSlotDecoder[2]=new Vt.BitTreeDecoder(6),this._posSlotDecoder[3]=new Vt.BitTreeDecoder(6)},Vt.Decoder.prototype.setDictionarySize=function(e){return!(e<0)&&(this._dictionarySize!==e&&(this._dictionarySize=e,this._dictionarySizeCheck=Math.max(this._dictionarySize,1),this._outWindow.create(Math.max(this._dictionarySizeCheck,4096))),!0)},Vt.Decoder.prototype.setLcLpPb=function(e,t,i){var n=1<<i;return!(e>8||t>4||i>4)&&(this._literalDecoder.create(t,e),this._lenDecoder.create(n),this._repLenDecoder.create(n),this._posStateMask=n-1,!0)},Vt.Decoder.prototype.init=function(){var e=4;for(this._outWindow.init(!1),Vt.initBitModels(this._isMatchDecoders,192),Vt.initBitModels(this._isRep0LongDecoders,192),Vt.initBitModels(this._isRepDecoders,12),Vt.initBitModels(this._isRepG0Decoders,12),Vt.initBitModels(this._isRepG1Decoders,12),Vt.initBitModels(this._isRepG2Decoders,12),Vt.initBitModels(this._posDecoders,114),this._literalDecoder.init();e--;)this._posSlotDecoder[e].init();this._lenDecoder.init(),this._repLenDecoder.init(),this._posAlignDecoder.init(),this._rangeDecoder.init()},Vt.Decoder.prototype.decode=function(e,t,i){var n,r,o,s,a,u,c=0,l=0,h=0,d=0,p=0,A=0,f=0;for(this._rangeDecoder.setStream(e),this._outWindow.setStream(t),this.init();i<0||A<i;)if(n=A&this._posStateMask,0===this._rangeDecoder.decodeBit(this._isMatchDecoders,(c<<4)+n))r=this._literalDecoder.getDecoder(A++,f),f=c>=7?r.decodeWithMatchByte(this._rangeDecoder,this._outWindow.getByte(l)):r.decodeNormal(this._rangeDecoder),this._outWindow.putByte(f),c=c<4?0:c-(c<10?3:6);else{if(1===this._rangeDecoder.decodeBit(this._isRepDecoders,c))o=0,0===this._rangeDecoder.decodeBit(this._isRepG0Decoders,c)?0===this._rangeDecoder.decodeBit(this._isRep0LongDecoders,(c<<4)+n)&&(c=c<7?9:11,o=1):(0===this._rangeDecoder.decodeBit(this._isRepG1Decoders,c)?s=h:(0===this._rangeDecoder.decodeBit(this._isRepG2Decoders,c)?s=d:(s=p,p=d),d=h),h=l,l=s),0===o&&(o=2+this._repLenDecoder.decode(this._rangeDecoder,n),c=c<7?8:11);else if(p=d,d=h,h=l,o=2+this._lenDecoder.decode(this._rangeDecoder,n),c=c<7?7:10,(a=this._posSlotDecoder[o<=5?o-2:3].decode(this._rangeDecoder))>=4){if(l=(2|1&a)<<(u=(a>>1)-1),a<14)l+=Vt.reverseDecode2(this._posDecoders,l-a-1,this._rangeDecoder,u);else if(l+=this._rangeDecoder.decodeDirectBits(u-4)<<4,(l+=this._posAlignDecoder.reverseDecode(this._rangeDecoder))<0){if(-1===l)break;return!1}}else l=a;if(l>=A||l>=this._dictionarySizeCheck)return!1;this._outWindow.copyBlock(l,o),A+=o,f=this._outWindow.getByte(0)}return this._outWindow.flush(),this._outWindow.releaseStream(),this._rangeDecoder.releaseStream(),!0},Vt.Decoder.prototype.setDecoderProperties=function(e){var t,i,n,r,o;return!(e.size<5)&&(i=(t=e.readByte())%9,n=(t=~~(t/9))%5,r=~~(t/5),!!this.setLcLpPb(i,n,r)&&(o=e.readByte(),o|=e.readByte()<<8,o|=e.readByte()<<16,o+=16777216*e.readByte(),this.setDictionarySize(o)))},Vt.decompress=function(e,t,i,n){var r=new Vt.Decoder;if(!r.setDecoderProperties(e))throw"Incorrect stream properties";if(!r.decode(t,i,n))throw"Error in data stream";return!0},Vt.decompressFile=function(e,t){var i,n=new Vt.Decoder;if(!n.setDecoderProperties(e))throw"Incorrect stream properties";if(i=e.readByte(),i|=e.readByte()<<8,i|=e.readByte()<<16,i+=16777216*e.readByte(),e.readByte(),e.readByte(),e.readByte(),e.readByte(),!n.decode(e,t,i))throw"Error in data stream";return!0};var Ht="undefined"!=typeof Worker&&"undefined"!=typeof Blob,Gt="";if(Ht)try{var Wt=new Blob(['\n self.onmessage = function (event) {\n var Packet = event.data;\n var Result = null;\n try {\n if (!Packet.PacketID) {\n throw new Error(\'No incoming id.\');\n }\n if (!Packet.Data) {\n throw new Error(\'No input data.\');\n }\n if (Packet.Type == \'compress\') {\n // C: checking if input is valid\n if (Packet.Data.constructor != Uint8Array) {\n throw new Error(\'Input data is not Uint8Array.\');\n }\n // C: encoding data\n Result = Util.compressFile(Packet.Data, null, Packet.Level, null);\n } else if (Packet.Type == \'decompress\') {\n // C: checking if input is valid\n if (Packet.Data.constructor != Uint8Array) {\n throw new Error(\'Input data is not Uint8Array.\');\n }\n var inStream = {\n data: Packet.Data,\n offset: 0,\n readByte () {\n return this.data[this.offset++];\n }\n };\n var partLength = inStream.data.length;\n var outStream = {\n data: [],\n offset: 0,\n writeByte (value) {\n var partIndex = Math.floor(this.offset / partLength);\n if (!this.data[partIndex]) {\n this.data[partIndex] = new Uint8Array(partLength);\n }\n this.data[partIndex][this.offset % partLength] = value;\n this.offset++;\n }\n }\n // C: decoding data\n\n LZMA.decompressFile(inStream, outStream);\n Result = new Uint8Array(outStream.offset)\n for (var i = 0; i < outStream.offset; i++) {\n Result[i] = outStream.data[Math.floor(i / partLength)][i % partLength];\n }\n }\n postMessage({ PacketID: Packet.PacketID, Result, Error: null }, [Result.buffer]);\n } catch (error) {\n postMessage({ PacketID: Packet.PacketID, Error: error.toString() });\n }\n };\n\n\n /*\n Copyright (c) 2011 Juan Mellado\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the "Software"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n THE SOFTWARE.\n */\n\n /*\n References:\n - "LZMA SDK" by Igor Pavlov\n http://www.7-zip.org/sdk.html\n */\n\n var LZMA = LZMA || {};\n\n LZMA.OutWindow = function(){\n this._windowSize = 0;\n };\n\n LZMA.OutWindow.prototype.create = function(windowSize){\n if ( (!this._buffer) || (this._windowSize !== windowSize) ){\n this._buffer = [];\n }\n this._windowSize = windowSize;\n this._pos = 0;\n this._streamPos = 0;\n };\n\n LZMA.OutWindow.prototype.flush = function(){\n var size = this._pos - this._streamPos;\n if (size !== 0){\n while(size --){\n this._stream.writeByte(this._buffer[this._streamPos ++]);\n }\n if (this._pos >= this._windowSize){\n this._pos = 0;\n }\n this._streamPos = this._pos;\n }\n };\n\n LZMA.OutWindow.prototype.releaseStream = function(){\n this.flush();\n this._stream = null;\n };\n\n LZMA.OutWindow.prototype.setStream = function(stream){\n this.releaseStream();\n this._stream = stream;\n };\n\n LZMA.OutWindow.prototype.init = function(solid){\n if (!solid){\n this._streamPos = 0;\n this._pos = 0;\n }\n };\n\n LZMA.OutWindow.prototype.copyBlock = function(distance, len){\n var pos = this._pos - distance - 1;\n if (pos < 0){\n pos += this._windowSize;\n }\n while(len --){\n if (pos >= this._windowSize){\n pos = 0;\n }\n this._buffer[this._pos ++] = this._buffer[pos ++];\n if (this._pos >= this._windowSize){\n this.flush();\n }\n }\n };\n\n LZMA.OutWindow.prototype.putByte = function(b){\n this._buffer[this._pos ++] = b;\n if (this._pos >= this._windowSize){\n this.flush();\n }\n };\n\n LZMA.OutWindow.prototype.getByte = function(distance){\n var pos = this._pos - distance - 1;\n if (pos < 0){\n pos += this._windowSize;\n }\n return this._buffer[pos];\n };\n\n LZMA.RangeDecoder = function(){\n };\n\n LZMA.RangeDecoder.prototype.setStream = function(stream){\n this._stream = stream;\n };\n\n LZMA.RangeDecoder.prototype.releaseStream = function(){\n this._stream = null;\n };\n\n LZMA.RangeDecoder.prototype.init = function(){\n var i = 5;\n\n this._code = 0;\n this._range = -1;\n\n while(i --){\n this._code = (this._code << 8) | this._stream.readByte();\n }\n };\n\n LZMA.RangeDecoder.prototype.decodeDirectBits = function(numTotalBits){\n var result = 0, i = numTotalBits, t;\n\n while(i --){\n this._range >>>= 1;\n t = (this._code - this._range) >>> 31;\n this._code -= this._range & (t - 1);\n result = (result << 1) | (1 - t);\n\n if ( (this._range & 0xff000000) === 0){\n this._code = (this._code << 8) | this._stream.readByte();\n this._range <<= 8;\n }\n }\n\n return result;\n };\n\n LZMA.RangeDecoder.prototype.decodeBit = function(probs, index){\n var prob = probs[index],\n newBound = (this._range >>> 11) * prob;\n\n if ( (this._code ^ 0x80000000) < (newBound ^ 0x80000000) ){\n this._range = newBound;\n probs[index] += (2048 - prob) >>> 5;\n if ( (this._range & 0xff000000) === 0){\n this._code = (this._code << 8) | this._stream.readByte();\n this._range <<= 8;\n }\n return 0;\n }\n\n this._range -= newBound;\n this._code -= newBound;\n probs[index] -= prob >>> 5;\n if ( (this._range & 0xff000000) === 0){\n this._code = (this._code << 8) | this._stream.readByte();\n this._range <<= 8;\n }\n return 1;\n };\n\n LZMA.initBitModels = function(probs, len){\n while(len --){\n probs[len] = 1024;\n }\n };\n\n LZMA.BitTreeDecoder = function(numBitLevels){\n this._models = [];\n this._numBitLevels = numBitLevels;\n };\n\n LZMA.BitTreeDecoder.prototype.init = function(){\n LZMA.initBitModels(this._models, 1 << this._numBitLevels);\n };\n\n LZMA.BitTreeDecoder.prototype.decode = function(rangeDecoder){\n var m = 1, i = this._numBitLevels;\n\n while(i --){\n m = (m << 1) | rangeDecoder.decodeBit(this._models, m);\n }\n return m - (1 << this._numBitLevels);\n };\n\n LZMA.BitTreeDecoder.prototype.reverseDecode = function(rangeDecoder){\n var m = 1, symbol = 0, i = 0, bit;\n\n for (; i < this._numBitLevels; ++ i){\n bit = rangeDecoder.decodeBit(this._models, m);\n m = (m << 1) | bit;\n symbol |= bit << i;\n }\n return symbol;\n };\n\n LZMA.reverseDecode2 = function(models, startIndex, rangeDecoder, numBitLevels){\n var m = 1, symbol = 0, i = 0, bit;\n\n for (; i < numBitLevels; ++ i){\n bit = rangeDecoder.decodeBit(models, startIndex + m);\n m = (m << 1) | bit;\n symbol |= bit << i;\n }\n return symbol;\n };\n\n LZMA.LenDecoder = function(){\n this._choice = [];\n this._lowCoder = [];\n this._midCoder = [];\n this._highCoder = new LZMA.BitTreeDecoder(8);\n this._numPosStates = 0;\n };\n\n LZMA.LenDecoder.prototype.create = function(numPosStates){\n for (; this._numPosStates < numPosStates; ++ this._numPosStates){\n this._lowCoder[this._numPosStates] = new LZMA.BitTreeDecoder(3);\n this._midCoder[this._numPosStates] = new LZMA.BitTreeDecoder(3);\n }\n };\n\n LZMA.LenDecoder.prototype.init = function(){\n var i = this._numPosStates;\n LZMA.initBitModels(this._choice, 2);\n while(i --){\n this._lowCoder[i].init();\n this._midCoder[i].init();\n }\n this._highCoder.init();\n };\n\n LZMA.LenDecoder.prototype.decode = function(rangeDecoder, posState){\n if (rangeDecoder.decodeBit(this._choice, 0) === 0){\n return this._lowCoder[posState].decode(rangeDecoder);\n }\n if (rangeDecoder.decodeBit(this._choice, 1) === 0){\n return 8 + this._midCoder[posState].decode(rangeDecoder);\n }\n return 16 + this._highCoder.decode(rangeDecoder);\n };\n\n LZMA.Decoder2 = function(){\n this._decoders = [];\n };\n\n LZMA.Decoder2.prototype.init = function(){\n LZMA.initBitModels(this._decoders, 0x300);\n };\n\n LZMA.Decoder2.prototype.decodeNormal = function(rangeDecoder){\n var symbol = 1;\n\n do{\n symbol = (symbol << 1) | rangeDecoder.decodeBit(this._decoders, symbol);\n }while(symbol < 0x100);\n\n return symbol & 0xff;\n };\n\n LZMA.Decoder2.prototype.decodeWithMatchByte = function(rangeDecoder, matchByte){\n var symbol = 1, matchBit, bit;\n\n do{\n matchBit = (matchByte >> 7) & 1;\n matchByte <<= 1;\n bit = rangeDecoder.decodeBit(this._decoders, ( (1 + matchBit) << 8) + symbol);\n symbol = (symbol << 1) | bit;\n if (matchBit !== bit){\n while(symbol < 0x100){\n symbol = (symbol << 1) | rangeDecoder.decodeBit(this._decoders, symbol);\n }\n break;\n }\n }while(symbol < 0x100);\n\n return symbol & 0xff;\n };\n\n LZMA.LiteralDecoder = function(){\n };\n\n LZMA.LiteralDecoder.prototype.create = function(numPosBits, numPrevBits){\n var i;\n\n if (this._coders\n && (this._numPrevBits === numPrevBits)\n && (this._numPosBits === numPosBits) ){\n return;\n }\n this._numPosBits = numPosBits;\n this._posMask = (1 << numPosBits) - 1;\n this._numPrevBits = numPrevBits;\n\n this._coders = [];\n\n i = 1 << (this._numPrevBits + this._numPosBits);\n while(i --){\n this._coders[i] = new LZMA.Decoder2();\n }\n };\n\n LZMA.LiteralDecoder.prototype.init = function(){\n var i = 1 << (this._numPrevBits + this._numPosBits);\n while(i --){\n this._coders[i].init();\n }\n };\n\n LZMA.LiteralDecoder.prototype.getDecoder = function(pos, prevByte){\n return this._coders[( (pos & this._posMask) << this._numPrevBits)\n + ( (prevByte & 0xff) >>> (8 - this._numPrevBits) )];\n };\n\n LZMA.Decoder = function(){\n this._outWindow = new LZMA.OutWindow();\n this._rangeDecoder = new LZMA.RangeDecoder();\n this._isMatchDecoders = [];\n this._isRepDecoders = [];\n this._isRepG0Decoders = [];\n this._isRepG1Decoders = [];\n this._isRepG2Decoders = [];\n this._isRep0LongDecoders = [];\n this._posSlotDecoder = [];\n this._posDecoders = [];\n this._posAlignDecoder = new LZMA.BitTreeDecoder(4);\n this._lenDecoder = new LZMA.LenDecoder();\n this._repLenDecoder = new LZMA.LenDecoder();\n this._literalDecoder = new LZMA.LiteralDecoder();\n this._dictionarySize = -1;\n this._dictionarySizeCheck = -1;\n\n this._posSlotDecoder[0] = new LZMA.BitTreeDecoder(6);\n this._posSlotDecoder[1] = new LZMA.BitTreeDecoder(6);\n this._posSlotDecoder[2] = new LZMA.BitTreeDecoder(6);\n this._posSlotDecoder[3] = new LZMA.BitTreeDecoder(6);\n };\n\n LZMA.Decoder.prototype.setDictionarySize = function(dictionarySize){\n if (dictionarySize < 0){\n return false;\n }\n if (this._dictionarySize !== dictionarySize){\n this._dictionarySize = dictionarySize;\n this._dictionarySizeCheck = Math.max(this._dictionarySize, 1);\n this._outWindow.create( Math.max(this._dictionarySizeCheck, 4096) );\n }\n return true;\n };\n\n LZMA.Decoder.prototype.setLcLpPb = function(lc, lp, pb){\n var numPosStates = 1 << pb;\n\n if (lc > 8 || lp > 4 || pb > 4){\n return false;\n }\n\n this._literalDecoder.create(lp, lc);\n\n this._lenDecoder.create(numPosStates);\n this._repLenDecoder.create(numPosStates);\n this._posStateMask = numPosStates - 1;\n\n return true;\n };\n\n LZMA.Decoder.prototype.init = function(){\n var i = 4;\n\n this._outWindow.init(false);\n\n LZMA.initBitModels(this._isMatchDecoders, 192);\n LZMA.initBitModels(this._isRep0LongDecoders, 192);\n LZMA.initBitModels(this._isRepDecoders, 12);\n LZMA.initBitModels(this._isRepG0Decoders, 12);\n LZMA.initBitModels(this._isRepG1Decoders, 12);\n LZMA.initBitModels(this._isRepG2Decoders, 12);\n LZMA.initBitModels(this._posDecoders, 114);\n\n this._literalDecoder.init();\n\n while(i --){\n this._posSlotDecoder[i].init();\n }\n\n this._lenDecoder.init();\n this._repLenDecoder.init();\n this._posAlignDecoder.init();\n this._rangeDecoder.init();\n };\n\n LZMA.Decoder.prototype.decode = function(inStream, outStream, outSize){\n var state = 0, rep0 = 0, rep1 = 0, rep2 = 0, rep3 = 0, nowPos64 = 0, prevByte = 0,\n posState, decoder2, len, distance, posSlot, numDirectBits;\n\n this._rangeDecoder.setStream(inStream);\n this._outWindow.setStream(outStream);\n\n this.init();\n\n while(outSize < 0 || nowPos64 < outSize){\n posState = nowPos64 & this._posStateMask;\n\n if (this._rangeDecoder.decodeBit(this._isMatchDecoders, (state << 4) + posState) === 0){\n decoder2 = this._literalDecoder.getDecoder(nowPos64 ++, prevByte);\n\n if (state >= 7){\n prevByte = decoder2.decodeWithMatchByte(this._rangeDecoder, this._outWindow.getByte(rep0) );\n }else{\n prevByte = decoder2.decodeNormal(this._rangeDecoder);\n }\n this._outWindow.putByte(prevByte);\n\n state = state < 4? 0: state - (state < 10? 3: 6);\n\n }else{\n\n if (this._rangeDecoder.decodeBit(this._isRepDecoders, state) === 1){\n len = 0;\n if (this._rangeDecoder.decodeBit(this._isRepG0Decoders, state) === 0){\n if (this._rangeDecoder.decodeBit(this._isRep0LongDecoders, (state << 4) + posState) === 0){\n state = state < 7? 9: 11;\n len = 1;\n }\n }else{\n if (this._rangeDecoder.decodeBit(this._isRepG1Decoders, state) === 0){\n distance = rep1;\n }else{\n if (this._rangeDecoder.decodeBit(this._isRepG2Decoders, state) === 0){\n distance = rep2;\n }else{\n distance = rep3;\n rep3 = rep2;\n }\n rep2 = rep1;\n }\n rep1 = rep0;\n rep0 = distance;\n }\n if (len === 0){\n len = 2 + this._repLenDecoder.decode(this._rangeDecoder, posState);\n state = state < 7? 8: 11;\n }\n }else{\n rep3 = rep2;\n rep2 = rep1;\n rep1 = rep0;\n\n len = 2 + this._lenDecoder.decode(this._rangeDecoder, posState);\n state = state < 7? 7: 10;\n\n posSlot = this._posSlotDecoder[len <= 5? len - 2: 3].decode(this._rangeDecoder);\n if (posSlot >= 4){\n\n numDirectBits = (posSlot >> 1) - 1;\n rep0 = (2 | (posSlot & 1) ) << numDirectBits;\n\n if (posSlot < 14){\n rep0 += LZMA.reverseDecode2(this._posDecoders,\n rep0 - posSlot - 1, this._rangeDecoder, numDirectBits);\n }else{\n rep0 += this._rangeDecoder.decodeDirectBits(numDirectBits - 4) << 4;\n rep0 += this._posAlignDecoder.reverseDecode(this._rangeDecoder);\n if (rep0 < 0){\n if (rep0 === -1){\n break;\n }\n return false;\n }\n }\n }else{\n rep0 = posSlot;\n }\n }\n\n if (rep0 >= nowPos64 || rep0 >= this._dictionarySizeCheck){\n return false;\n }\n\n this._outWindow.copyBlock(rep0, len);\n nowPos64 += len;\n prevByte = this._outWindow.getByte(0);\n }\n }\n\n this._outWindow.flush();\n this._outWindow.releaseStream();\n this._rangeDecoder.releaseStream();\n\n return true;\n };\n\n LZMA.Decoder.prototype.setDecoderProperties = function(properties){\n var value, lc, lp, pb, dictionarySize;\n\n if (properties.size < 5){\n return false;\n }\n\n value = properties.readByte();\n lc = value % 9;\n value = ~~(value / 9);\n lp = value % 5;\n pb = ~~(value / 5);\n\n if ( !this.setLcLpPb(lc, lp, pb) ){\n return false;\n }\n\n dictionarySize = properties.readByte();\n dictionarySize |= properties.readByte() << 8;\n dictionarySize |= properties.readByte() << 16;\n dictionarySize += properties.readByte() * 16777216;\n\n return this.setDictionarySize(dictionarySize);\n };\n\n LZMA.decompress = function(properties, inStream, outStream, outSize){\n var decoder = new LZMA.Decoder();\n\n if ( !decoder.setDecoderProperties(properties) ){\n throw "Incorrect stream properties";\n }\n\n if ( !decoder.decode(inStream, outStream, outSize) ){\n throw "Error in data stream";\n }\n\n return true;\n };\n\n LZMA.decompressFile = function(inStream, outStream){\n var decoder = new LZMA.Decoder(), outSize;\n\n if ( !decoder.setDecoderProperties(inStream) ){\n throw "Incorrect stream properties";\n }\n\n outSize = inStream.readByte();\n outSize |= inStream.readByte() << 8;\n outSize |= inStream.readByte() << 16;\n outSize += inStream.readByte() * 16777216;\n\n inStream.readByte();\n inStream.readByte();\n inStream.readByte();\n inStream.readByte();\n\n if ( !decoder.decode(inStream, outStream, outSize) ){\n throw "Error in data stream";\n }\n\n return true;\n };\n'],{type:"text/javascript"});Gt=URL.createObjectURL(Wt)}catch(e){}var qt=function(){function e(){var e=this;if(this.callCounter=0,this.requests=[],!Ht)throw new Error("LZMACaller cannot work in this broswer.");var t=this.worker=new Worker(Gt);t.onmessage=function(t){var i,n,r=t.data,o=r.PacketID,s=r.Result,a=r.Error;a?null===(n=e.requests[o])||void 0===n||n.onCompleteCallback(new Error(a)):null===(i=e.requests[o])||void 0===i||i.onCompleteCallback(null,s),delete e.requests[o]},t.onerror=function(e){return console.error(e)}}return e.prototype.compress=function(e,t,i){var n=++this.callCounter;this.requests[n]={onCompleteCallback:i},this.worker.postMessage({Type:"compress",PacketID:n,Data:e,Level:t},[e.buffer])},e.prototype.decompress=function(e,t){var i=++this.callCounter;this.requests[i]={onCompleteCallback:t},this.worker.postMessage({Type:"decompress",PacketID:i,Data:e},[e.buffer])},e.prototype.terminate=function(){this.worker.terminate()},e.support=Ht,e}();function Kt(e){return Array.prototype.reduce.call(e,(function(e,t,i){return e|t<<8*i}),0)}function Zt(e){for(var t=new Uint8Array(e),i=Kt(t.slice(0,4)),n=[],r=[],o=4+4*i,s=0;s<i;s++)r[s]=Kt(t.slice(4+4*s,8+4*s)),n[s]=s===i-1?t.subarray(o,o+r[s]):t.slice(o,o+r[s]),o+=r[s];return qt.support?function(e){for(var t=[],i=e.length,n=function(i){t.push(new Promise((function(t,n){var r=new qt;r.decompress(e[i],(function(e,i){if(r.terminate(),e)return n(e);t(i)}))})))},r=0;r<i;r++)n(r);return Promise.all(t)}(n):Promise.resolve(function(e){for(var t,i=[],n=e.length,r=function(n){var r={data:e[n],offset:0,readByte:function(){return this.data[this.offset++]}},o=r.data.length,s={data:[],offset:0,writeByte:function(e){var t=Math.floor(this.offset/o);this.data[t]||(this.data[t]=new Uint8Array(o)),this.data[t][this.offset%o]=e,this.offset++}};Vt.decompressFile(r,s),t=new Uint8Array(s.offset);for(var a=0;a<s.offset;a++)t[a]=s.data[Math.floor(a/o)][a%o];i.push(t)},o=0;o<n;o++)r(o);return i}(n))}function Xt(e,t){for(var i={},n=0,r=t;n<r.length;n++){var o=r[n];o in e&&(i[o]=e[o])}return i}var Jt="//vrlab-public.ljcdn.com/",$t="//vrlab-image[1-4].ljcdn.com/";function ei(e,t){var i,n=e.split("?")[0],r=n.split(".").pop();if("jpeg"===r&&(r="jpg"),"png"!==r&&"jpg"!==r)return e;var o="";if(void 0!==t.format&&t.format!==r&&(o+="/format/"+t.format),void 0!==t.cut&&(o+="/cut/"+t.cut[2]+"x"+t.cut[3]+"x"+t.cut[0]+"x"+t.cut[1]),void 0!==t.size&&(o+="/thumbnail/"+t.size+"x"),void 0!==t.quality){var s=null!==(i=t.format)&&void 0!==i?i:r;s&&["jpg","webp","tpg","heif","avif"].indexOf(s)>=0&&(o+="/quality/"+t.quality)}return o.length&&(o="?imageMogr2"+o),n+o}function ti(e,t){return e.indexOf(Jt)>=0?(/\.basis(\?|$)/.test(e)&&!0!==t.basisLoaderInitialized&&(e=e.replace(/\.basis(\?|$)/,".jpg$1")),ei(function(e,t){var i=t.split("."),n=i[0],r=i.slice(1);if("texture"===n)return e.replace(Jt,$t.replace("[1-4]","3"));if("pano"===n||"pano_luminance"===n)switch(r[0],r[1]){case"front":case"left":case"up":return e.replace(Jt,$t.replace("[1-4]","1"));case"down":case"right":case"back":return e.replace(Jt,$t.replace("[1-4]","2"))}else if("pano_tile"===n||"pano_tile_luminance"===n){r[0],r[1];var o=r[2],s=r[3],a=r[4],u=Math.pow(2,Number(o))*Number(s)+Number(a);if(!isNaN(u))return e.replace(Jt,"//vr-tile-[1-2].realsee-cdn.com/".replace("[1-2]",String(u%2+1)))}return e.replace(Jt,$t.replace("[1-4]","3"))}(e,t.key),t)):e.indexOf("//test-vr-public.realsee-cdn.com/")>=0?(/\.basis(\?|$)/.test(e)&&!0!==t.basisLoaderInitialized&&(e=e.replace(/\.basis(\?|$)/,".jpg$1")),ei(e.replace("//test-vr-public.realsee-cdn.com/","//test-vr-image.realsee-cdn.com/"),t)):e}var ii=!1;try{ii="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}var ni=[],ri=[];function oi(){var e=this;/^blob\:/.test(this.src)&&URL.revokeObjectURL(this.src),this.onerror=this.onload=Qe,this.removeAttribute("src"),We.shared.add((function(){ni.push(e)}),!0,1)}function si(){ri.push(this)}function ai(){var e;return null!==(e=ni.shift())&&void 0!==e?e:Object.assign(new Image,{crossOrigin:"",close:oi})}function ui(e){return new Promise((function(t,i){var n=ai(),r=function(){n.removeEventListener("load",r,!1),n.removeEventListener("error",o,!1),t(n)},o=function(){n.removeEventListener("load",r,!1),n.removeEventListener("error",o,!1),i(new Error("image load error: "+n.src)),n.close()};n.addEventListener("load",r,!1),n.addEventListener("error",o,!1),n.src=URL.createObjectURL(e)}))}function ci(e,t){if(t&&(e.width>t.width||e.height>t.height)){var i=function(e,t){var i=ri.shift();if(i)return i.width=e,i.height=t,i;if(ii){var n=new OffscreenCanvas(e,t);return Object.assign(n,{close:si})}return n=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),Object.assign(n,{close:si})}(Math.min(e.width,t.width),Math.min(e.height,t.height));i.getContext("2d").drawImage(e,0,0,i.width,i.height),e.close();var n=new r.Texture(i);n.needsUpdate=!0,n.flipY=!0;var o=n.dispose;return n.dispose=function(){i.close(),o.call(n)},n}var s=new r.Texture(e);s.needsUpdate=!0,s.flipY=!0;var a=s.dispose;return s.dispose=function(){e.close(),a.call(s)},s}var li=new r.WebGLRenderTarget(1,1),hi=new r.OrthographicCamera(-1,1,1,-1,0,1),di=new r.BufferGeometry;di.setAttribute("position",new r.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),di.setAttribute("uv",new r.Float32BufferAttribute([0,2,0,0,2,0],2));var pi=new r.Mesh(di),Ai=new r.Scene;Ai.add(pi);var fi,Mi=new r.RawShaderMaterial({uniforms:{map:{value:null}},vertexShader:"\n void main() {\n gl_Position = vec4(0, 0, 0, 0);\n }\n ",fragmentShader:"\n uniform sampler2D map;\n void main() {\n gl_FragColor = textureCube(map, vec3(0, 0));\n }\n "}),gi=new r.RawShaderMaterial({uniforms:{map:{value:null}},vertexShader:"\n void main() {\n gl_Position = vec4(0, 0, 0, 0);\n }\n ",fragmentShader:"\n uniform samplerCube map;\n void main() {\n gl_FragColor = textureCube(map, vec3(0, 0, 0));\n }\n "});function yi(e,t,i){return void 0!==t.flipY&&(e.flipY=t.flipY),void 0!==t.format&&(e.format=t.format),void 0!==t.encoding&&(e.encoding=t.encoding),void 0!==t.minFilter&&(e.minFilter=t.minFilter),void 0!==t.magFilter&&(e.magFilter=t.magFilter),i?new Promise((function(t){We.shared.add((function(){try{var n=i.getRenderTarget();i.setRenderTarget(li),e instanceof r.CubeTexture?(pi.material=gi,gi.uniforms.map.value=e,i.render(Ai,hi),gi.uniforms.map.value=null):(pi.material=Mi,Mi.uniforms.map.value=e,i.render(Ai,hi),gi.uniforms.map.value=null),i.setRenderTarget(n),t(e)}catch(i){t(e)}}),!0,1,1e3)})):Promise.resolve(e)}var mi='\nvar config, transcoderPending, _BasisFile;\nself.onmessage = function(e) {\n var message = e.data;\n switch (message.type) {\n case "init":\n config = message.config;\n init(message.transcoderBinary);\n break;\n case "transcode":\n transcoderPending.then(function() {\n try {\n var result = transcode(message.buffer);\n var width = result.width;\n var height = result.height;\n var hasAlpha = result.hasAlpha;\n var mipmaps = result.mipmaps;\n var format = result.format;\n var buffers = [];\n for (var i = 0; i < mipmaps.length; ++i) {\n buffers.push(mipmaps[i].data.buffer);\n }\n self.postMessage({ type: "transcode", id: message.id, width, height, hasAlpha, mipmaps, format }, buffers);\n } catch (error) {\n console.error(error);\n self.postMessage({ type: "error", id: message.id, error: error.message });\n }\n });\n break;\n default: break;\n }\n};\n\nfunction init(wasmBinary) {\n var BasisModule;\n transcoderPending = new Promise(function(resolve) {\n BasisModule = { wasmBinary, onRuntimeInitialized: resolve };\n BASIS(BasisModule); // eslint-disable-line no-undef\n }).then(function() {\n _BasisFile = BasisModule.BasisFile;\n BasisModule.initializeBasis();\n self.postMessage({ type: "initialized" });\n });\n}\n\nfunction transcode(buffer) {\n var basisFile = new _BasisFile(new Uint8Array(buffer));\n var width = basisFile.getImageWidth(0, 0);\n var height = basisFile.getImageHeight(0, 0);\n var levels = basisFile.getNumLevels(0);\n var hasAlpha = basisFile.getHasAlpha();\n function cleanup() {\n basisFile.close();\n basisFile.delete();\n }\n if (!hasAlpha) {\n switch (config.format) {\n case 9: // Hardcoded: BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGBA\n config.format = 8; // Hardcoded: BasisTextureLoader.BASIS_FORMAT.cTFPVRTC1_4_RGB;\n break;\n default: break;\n }\n }\n if (!width || !height || !levels) {\n cleanup();\n throw new Error("BasisTextureLoader: Invalid .basis file");\n }\n if (!basisFile.startTranscoding()) {\n cleanup();\n throw new Error("BasisTextureLoader: .startTranscoding failed");\n }\n var mipmaps = [];\n for (var mip = 0; mip < levels; mip++) {\n var mipWidth = basisFile.getImageWidth(0, mip);\n var mipHeight = basisFile.getImageHeight(0, mip);\n var dst = new Uint8Array(basisFile.getImageTranscodedSizeInBytes(0, mip, config.format));\n var status = basisFile.transcodeImage(dst, 0, mip, config.format, 0, hasAlpha);\n if (!status) {\n cleanup();\n throw new Error("BasisTextureLoader: .transcodeImage failed.");\n }\n mipmaps.push({ data: dst, width: mipWidth, height: mipHeight });\n }\n cleanup();\n return { width, height, hasAlpha, mipmaps, format: config.format };\n}\n',vi={cTFETC1:0,cTFETC2:1,cTFBC1:2,cTFBC3:3,cTFBC4:4,cTFBC5:5,cTFBC7_M6_OPAQUE_ONLY:6,cTFBC7_M5:7,cTFPVRTC1_4_RGB:8,cTFPVRTC1_4_RGBA:9,cTFASTC_4x4:10,cTFATC_RGB:11,cTFATC_RGBA_INTERPOLATED_ALPHA:12,cTFRGBA32:13,cTFRGB565:14,cTFBGR565:15,cTFRGBA4444:16},Ni={COMPRESSED_RGB_S3TC_DXT1_EXT:33776,COMPRESSED_RGBA_S3TC_DXT1_EXT:33777,COMPRESSED_RGBA_S3TC_DXT3_EXT:33778,COMPRESSED_RGBA_S3TC_DXT5_EXT:33779},Di=((fi={})[vi.cTFBC1]=Ni.COMPRESSED_RGB_S3TC_DXT1_EXT,fi[vi.cTFBC3]=Ni.COMPRESSED_RGBA_S3TC_DXT5_EXT,fi),wi=function(){function e(){}return e.setTranscoderPath=function(e){return this.transcoderPath=e,this},e.setWorkerLimit=function(e){return this.workerLimit=e,this},e.isInitialized=function(){return 0!==this.workerPool.filter((function(e){return e._initialized})).length},e.detectSupport=function(t){var i=this.workerConfig;if(i.astcSupported=!!t.extensions.get("WEBGL_compressed_texture_astc"),i.bptcSupported=!!t.extensions.get("EXT_texture_compression_bptc"),i.etcSupported=!!t.extensions.get("WEBGL_compressed_texture_etc1"),i.dxtSupported=!!t.extensions.get("WEBGL_compressed_texture_s3tc"),i.pvrtcSupported=!!t.extensions.get("WEBGL_compressed_texture_pvrtc")||!!t.extensions.get("WEBKIT_WEBGL_compressed_texture_pvrtc"),i.astcSupported)i.format=e.BASIS_FORMAT.cTFASTC_4x4;else if(i.bptcSupported)i.format=e.BASIS_FORMAT.cTFBC7_M5;else if(i.dxtSupported)i.format=e.BASIS_FORMAT.cTFBC3;else if(i.pvrtcSupported)i.format=e.BASIS_FORMAT.cTFPVRTC1_4_RGBA;else{if(!i.etcSupported)throw new Error("BasisTextureLoader: No suitable compressed texture format found.");i.format=e.BASIS_FORMAT.cTFETC1}return this},e.createTexture=function(e){var t,i,n=this,o=e.byteLength,s=this._allocateWorker(o).then((function(r){return t=r,i=n.workerNextTaskID++,new Promise((function(n,r){t._callbacks[i]={resolve:n,reject:r},t.postMessage({type:"transcode",id:i,buffer:e},[e])}))})).then((function(e){var t,i=n.workerConfig,o=e.width,s=e.height,a=e.mipmaps;switch(e.format){case vi.cTFASTC_4x4:t=new r.CompressedTexture(a,o,s,r.RGBA_ASTC_4x4_Format);break;case vi.cTFBC1:case vi.cTFBC3:t=new r.CompressedTexture(a,o,s,Di[i.format],r.UnsignedByteType);break;case vi.cTFETC1:t=new r.CompressedTexture(a,o,s,r.RGB_ETC1_Format);break;case vi.cTFPVRTC1_4_RGB:t=new r.CompressedTexture(a,o,s,r.RGB_PVRTC_4BPPV1_Format);break;case vi.cTFPVRTC1_4_RGBA:t=new r.CompressedTexture(a,o,s,r.RGBA_PVRTC_4BPPV1_Format);break;default:throw new Error("BasisTextureLoader: No supported format available.")}return t.minFilter=1===a.length?r.LinearFilter:r.LinearMipmapLinearFilter,t.magFilter=r.LinearFilter,t.generateMipmaps=!1,t.needsUpdate=!0,t}));return s.catch((function(){return!0})).then((function(){t&&i&&(t._taskLoad-=o,delete t._callbacks[i])})),s},e._initTranscoder=function(){var e=this;if(!this.transcoderPending){var t=new r.FileLoader;t.setPath(this.transcoderPath);var i=new Promise((function(e,i){t.load("basis_transcoder.js",e,void 0,i)})),n=new r.FileLoader;n.setPath(this.transcoderPath),n.setResponseType("arraybuffer");var o=new Promise((function(e,t){n.load("basis_transcoder.wasm",e,void 0,t)}));this.transcoderPending=Promise.all([i,o]).then((function(t){var i=t[0],n=t[1],r=["/* basis_transcoder.js */",i,"/* worker */",mi].join("\n");e.workerSourceURL=URL.createObjectURL(new Blob([r])),e.transcoderBinary=n}))}return this.transcoderPending},e._allocateWorker=function(e){var t=this;return this._initTranscoder().then((function(){if(t.workerPool.length<t.workerLimit){var i=function(e){var t=new Worker(e);return Object.assign(t,{_callbacks:{},_initialized:!1,_taskLoad:0})}(t.workerSourceURL);i._callbacks={},i._initialized=!1,i._taskLoad=0,i.postMessage({type:"init",config:t.workerConfig,transcoderBinary:t.transcoderBinary}),i.onmessage=function(e){var t=e.data;switch(t.type){case"initialized":i._initialized=!0,console.log("BasisTextureLoader: basis loader initialized");break;case"transcode":i._callbacks[t.id].resolve(t);break;case"error":i._callbacks[t.id].reject(t);break;default:console.error('BasisTextureLoader: Unexpected message, "'+t.type+'"')}},t.workerPool.push(i)}else t.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));var n=t.workerPool[t.workerPool.length-1];return n._taskLoad+=e,n}))},e.prototype.dispose=function(){for(var t=0;t<e.workerPool.length;t++)e.workerPool[t].terminate();return e.workerPool.length=0,this},e.BASIS_FORMAT=vi,e.DXT_FORMAT=Ni,e.DXT_FORMAT_MAP=Di,e.transcoderPath="https://vrlab-public.ljcdn.com/release/static/image/release/five/basis/",e.transcoderBinary=null,e.transcoderPending=null,e.workerLimit=1,e.workerPool=[],e.workerNextTaskID=1,e.workerSourceURL="",e.workerConfig={format:null,astcSupported:!1,bptcSupported:!1,etcSupported:!1,dxtSupported:!1,pvrtcSupported:!1},e}();function Ti(e){var t=e.match(/^([0-9a-z]+\:)\/\/(([^:/?#]*)(?::[0-9]+)?)/);return t?t[1]:location.protocol}var xi=function(){function e(e){this.timeout=e.timeout,this.allowHosts=e.allowHosts,this.networkSubscribe=e.networkSubscribe}return e.prototype.setAllowHosts=function(e){this.allowHosts=e},e.prototype.setNetworkSubscribe=function(e){this.networkSubscribe=e},e.prototype.load=function(e,i,n,o,s,a){void 0===i&&(i={}),void 0===n&&(n=Qe),void 0===o&&(o=Qe),void 0===s&&(s=Qe);var u=Ti(e),c={timeout:this.timeout,allowHosts:this.allowHosts,networkSubscribe:this.networkSubscribe};if(/^https?:$/.test(u)||Ot(e)){if(/\.basis$/.test(St(e).split("?")[0])){var l=null,h="arraybuffer";return!0===i.flipY?Promise.reject(new Error(".basis cannnot set flipY: true.")):Ct(e,t.__assign(t.__assign({},c),{responseType:h}),void 0,void 0,s).then((function(e){return l=e.meta,wi.createTexture(e.body)})).then((function(e){return yi(e,t.__assign({flipY:!1,encoding:r.sRGBEncoding},Xt(i,["wrapS","wrapT"])),a)})).then((function(e){var t={meta:l,body:e};return n(t),t})).catch((function(e){return o(e),Promise.reject(e)}))}h="blob";return Ct(e,t.__assign(t.__assign({},c),{responseType:h}),void 0,void 0,s).then((function(e){return ui(e.body)})).then((function(e){return ci(e,i.maxSize)})).then((function(e){return yi(e,t.__assign({flipY:!0,encoding:r.sRGBEncoding},i),a)})).then((function(e){var t={meta:null,body:e};return n(t),t})).catch((function(e){return o(e),Promise.reject(e)}))}var d=null,p=ai();return Bt(e,c,void 0,void 0,s,p).then((function(e){return d=e.meta,ci(e.body,i.maxSize)})).then((function(e){return yi(e,t.__assign({flipY:!0,encoding:r.sRGBEncoding},i),a)})).then((function(e){var t={meta:d,body:e};return n(t),t})).catch((function(e){return p.close(),o(e),Promise.reject(e)}))},e.prototype.loadCube=function(e,i,n,o,s,a){void 0===i&&(i={}),void 0===n&&(n=Qe),void 0===o&&(o=Qe),void 0===s&&(s=Qe),Array.isArray(e)||(e=[e.right,e.left,e.up,e.down,e.front,e.back]);for(var u={timeout:this.timeout,allowHosts:this.allowHosts,networkSubscribe:this.networkSubscribe},c=[],l=[0,0,0,0,0,0],h=[],d=function(i){var n=e[i],r=Ti(n),o=function(e){l[i]=e,s(l.reduce((function(e,t){return e+t}),0)/6)};if(/^https?\:$/.test(r)||Ot(n))if(/\.basis$/.test(St(n).split("?")[0])){var a="arraybuffer",d=Ct(n,t.__assign(t.__assign({},u),{responseType:a}),void 0,void 0,o).then((function(e){return h[i]=e.meta,wi.createTexture(e.body)}));c.push(d)}else{a="blob",d=Ct(n,t.__assign(t.__assign({},u),{responseType:a}),void 0,void 0,o).then((function(e){return h[i]=e.meta,"undefined"!=typeof createImageBitmap?createImageBitmap(e.body,{colorSpaceConversion:"none"}):ui(e.body)}));c.push(d)}else{var p=ai();d=Bt(n,u,void 0,void 0,o,p).then((function(e){return h[i]=e.meta,e.body})).catch((function(e){return p.close(),Promise.reject(e)}));c.push(d)}},p=0;p<6;p++)d(p);return Promise.all(c).then((function(e){return e[0]instanceof r.CompressedTexture?function(e){var t=new r.CubeTexture(e);t.needsUpdate=!0;var i=t.dispose;return t.dispose=function(){for(var n=0,r=e;n<r.length;n++)r[n].dispose();i.call(t)},t.isCompressedTexture=!0,t.format=e[0].format,t.minFilter=e[0].minFilter,t.magFilter=e[0].magFilter,t}(e):function(e){var t=new r.CubeTexture(e);t.needsUpdate=!0,t.flipY=!1;var i=t.dispose;return t.dispose=function(){for(var n=0,r=e;n<r.length;n++)r[n].close();i.call(t)},t}(e)})).then((function(e){return e.isCompressedTexture?yi(e,t.__assign({flipY:!1,encoding:r.sRGBEncoding},Xt(i,["wrapS","wrapT"])),a):yi(e,t.__assign({flipY:!1,encoding:r.sRGBEncoding},i),a)})).then((function(e){var t={body:e,meta:h};return n(t),t})).catch((function(e){for(var t=0,i=c;t<i.length;t++){i[t].then((function(e){e instanceof r.Texture?e.dispose():e.close()})).catch(Qe)}return o(e),Promise.reject(e)}))},e}(),Ei={computeTangents:function(e){var t=e.index,i=e.attributes;if(null!==t&&void 0!==i.position&&void 0!==i.normal&&void 0!==i.uv){var n=t.array,o=i.position.array,s=i.normal.array,a=i.uv.array,u=o.length/3;void 0===i.tangent&&e.setAttribute("tangent",new r.BufferAttribute(new Float32Array(4*u),4));for(var c=i.tangent.array,l=[],h=[],d=0;d<u;d++)l[d]=new r.Vector3,h[d]=new r.Vector3;var p=new r.Vector3,A=new r.Vector3,f=new r.Vector3,M=new r.Vector2,g=new r.Vector2,y=new r.Vector2,m=new r.Vector3,v=new r.Vector3,N=e.groups;0===N.length&&(N=[{start:0,count:n.length}]);d=0;for(var D=N.length;d<D;++d)for(var w=L=(S=N[d]).start,T=L+S.count;w<T;w+=3)k(n[w+0],n[w+1],n[w+2]);var x,E,j,z=new r.Vector3,I=new r.Vector3,b=new r.Vector3,O=new r.Vector3;for(d=0,D=N.length;d<D;++d){var S,L;for(w=L=(S=N[d]).start,T=L+S.count;w<T;w+=3)C(n[w+0]),C(n[w+1]),C(n[w+2])}}else console.warn("THREE.BufferGeometry: Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");function k(e,t,i){p.fromArray(o,3*e),A.fromArray(o,3*t),f.fromArray(o,3*i),M.fromArray(a,2*e),g.fromArray(a,2*t),y.fromArray(a,2*i);var n=A.x-p.x,r=f.x-p.x,s=A.y-p.y,u=f.y-p.y,c=A.z-p.z,d=f.z-p.z,N=g.x-M.x,D=y.x-M.x,w=g.y-M.y,T=y.y-M.y,x=1/(N*T-D*w);m.set((T*n-w*r)*x,(T*s-w*u)*x,(T*c-w*d)*x),v.set((N*r-D*n)*x,(N*u-D*s)*x,(N*d-D*c)*x),l[e].add(m),l[t].add(m),l[i].add(m),h[e].add(v),h[t].add(v),h[i].add(v)}function C(e){b.fromArray(s,3*e),O.copy(b),E=l[e],z.copy(E),z.sub(b.multiplyScalar(b.dot(E))).normalize(),I.crossVectors(O,E),j=I.dot(h[e]),x=j<0?-1:1,c[4*e]=z.x,c[4*e+1]=z.y,c[4*e+2]=z.z,c[4*e+3]=x}},mergeBufferGeometries:function(e,t){for(var i=null!==e[0].index,n=new Set(Object.keys(e[0].attributes)),o=new Set(Object.keys(e[0].morphAttributes)),s={},a={},u=new r.BufferGeometry,c=0,l=0;l<e.length;++l){var h=e[l];if(i!==(null!==h.index))return null;for(var d in h.attributes){if(!n.has(d))return null;void 0===s[d]&&(s[d]=[]),s[d].push(h.attributes[d])}for(var d in h.morphAttributes){if(!o.has(d))return null;void 0===a[d]&&(a[d]=[]),a[d].push(h.morphAttributes[d])}if(u.userData.mergedUserData=u.userData.mergedUserData||[],u.userData.mergedUserData.push(h.userData),t){var p;if(i)p=h.index.count;else{if(void 0===h.attributes.position)return null;p=h.attributes.position.count}u.addGroup(c,p,l),c+=p}}if(i){var A=0,f=[];for(l=0;l<e.length;++l){for(var M=e[l].index,g=0;g<M.count;++g)f.push(M.getX(g)+A);A+=e[l].attributes.position.count}u.setIndex(f)}for(var d in s){var y=this.mergeBufferAttributes(s[d]);if(!y)return null;u.setAttribute(d,y)}for(var d in a){var m=a[d][0].length;if(0===m)break;u.morphAttributes=u.morphAttributes||{},u.morphAttributes[d]=[];for(l=0;l<m;++l){var v=[];for(g=0;g<a[d].length;++g)v.push(a[d][g][l]);var N=this.mergeBufferAttributes(v);if(!N)return null;u.morphAttributes[d].push(N)}}return u},mergeBufferAttributes:function(e){for(var t,i,n,o=0,s=0;s<e.length;++s){var a=e[s];if(a.isInterleavedBufferAttribute)return null;if(void 0===t&&(t=a.array.constructor),t!==a.array.constructor)return null;if(void 0===i&&(i=a.itemSize),i!==a.itemSize)return null;if(void 0===n&&(n=a.normalized),n!==a.normalized)return null;o+=a.array.length}var u=new t(o),c=0;for(s=0;s<e.length;++s)u.set(e[s].array,c),c+=e[s].array.length;return new r.BufferAttribute(u,i,n)},interleaveAttributes:function(e){for(var t,i=0,n=0,o=0,s=e.length;o<s;++o){var a=e[o];if(void 0===t&&(t=a.array.constructor),t!==a.array.constructor)return console.warn("AttributeBuffers of different types cannot be interleaved"),null;i+=a.array.length,n+=a.itemSize}var u=new r.InterleavedBuffer(new t(i),n),c=0,l=[],h=["getX","getY","getZ","getW"],d=["setX","setY","setZ","setW"],p=0;for(s=e.length;p<s;p++){var A=(a=e[p]).itemSize,f=a.count,M=new r.InterleavedBufferAttribute(u,A,c,a.normalized);l.push(M),c+=A;for(var g=0;g<f;g++)for(var y=0;y<A;y++)M[d[y]](g,a[h[y]](g))}return l},estimateBytesUsed:function(e){var t=0;for(var i in e.attributes){var n=e.getAttribute(i);t+=n.count*n.itemSize*n.array.BYTES_PER_ELEMENT}var r=e.getIndex();return t+=r?r.count*r.itemSize*r.array.BYTES_PER_ELEMENT:0},mergeVertices:function(e,t){void 0===t&&(t=1e-4),t=Math.max(t,Number.EPSILON);for(var i={},n=e.getIndex(),o=e.getAttribute("position"),s=n?n.count:o.count,a=0,u=Object.keys(e.attributes),c={},l={},h=[],d=["getX","getY","getZ","getW"],p=0,A=u.length;p<A;p++){c[v=u[p]]=[],(T=e.morphAttributes[v])&&(l[v]=new Array(T.length).fill().map((function(){return[]})))}var f=Math.log10(1/t),M=Math.pow(10,f);for(p=0;p<s;p++){var g=n?n.getX(p):p,y="",m=0;for(A=u.length;m<A;m++)for(var v=u[m],N=(w=e.getAttribute(v)).itemSize,D=0;D<N;D++)y+=~~(w[d[D]](g)*M)+",";if(y in i)h.push(i[y]);else{for(m=0,A=u.length;m<A;m++){v=u[m];var w=e.getAttribute(v),T=e.morphAttributes[v],x=(N=w.itemSize,c[v]),E=l[v];for(D=0;D<N;D++){var j=d[D];if(x.push(w[j](g)),T)for(var z=0,I=T.length;z<I;z++)E[z].push(T[z][j](g))}}i[y]=a,h.push(a),a++}}var b=e.clone();for(p=0,A=u.length;p<A;p++){v=u[p];var O=e.getAttribute(v),S=new O.array.constructor(c[v]);w=new r.BufferAttribute(S,O.itemSize,O.normalized);if(b.setAttribute(v,w),v in l)for(m=0;m<l[v].length;m++){var L=e.morphAttributes[v][m],k=(S=new L.array.constructor(l[v][m]),new r.BufferAttribute(S,L.itemSize,L.normalized));b.morphAttributes[v][m]=k}}return b.setIndex(h),b}};const ji=o.Reader,zi=o.Writer,Ii=o.util,bi=o.roots["@REALSEE/FIVE:1"]||(o.roots["@REALSEE/FIVE:1"]={}),Oi=bi.Model=(()=>{function e(e){if(this.chunks=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.chunks=Ii.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=zi.create()),null!=e.chunks&&e.chunks.length)for(let i=0;i<e.chunks.length;++i)bi.Chunk.encode(e.chunks[i],t.uint32(10).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof ji||(e=ji.create(e));let i=void 0===t?e.len:e.pos+t,n=new bi.Model;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:n.chunks&&n.chunks.length||(n.chunks=[]),n.chunks.push(bi.Chunk.decode(e,e.uint32()));break;default:e.skipType(7&t)}}return n},e.decodeDelimited=function(e){return e instanceof ji||(e=new ji(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.chunks&&e.hasOwnProperty("chunks")){if(!Array.isArray(e.chunks))return"chunks: array expected";for(let t=0;t<e.chunks.length;++t){let i=bi.Chunk.verify(e.chunks[t]);if(i)return"chunks."+i}}return null},e.fromObject=function(e){if(e instanceof bi.Model)return e;let t=new bi.Model;if(e.chunks){if(!Array.isArray(e.chunks))throw TypeError(".Model.chunks: array expected");t.chunks=[];for(let i=0;i<e.chunks.length;++i){if("object"!=typeof e.chunks[i])throw TypeError(".Model.chunks: object expected");t.chunks[i]=bi.Chunk.fromObject(e.chunks[i])}}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.chunks=[]),e.chunks&&e.chunks.length){i.chunks=[];for(let n=0;n<e.chunks.length;++n)i.chunks[n]=bi.Chunk.toObject(e.chunks[n],t)}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})();bi.Chunk=(()=>{function e(e){if(e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.vertices=null,e.prototype.faces=null,e.prototype.name="",e.prototype.texture="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=zi.create()),bi.Vertices.encode(e.vertices,t.uint32(10).fork()).ldelim(),bi.Faces.encode(e.faces,t.uint32(18).fork()).ldelim(),t.uint32(26).string(e.name),null!=e.texture&&Object.hasOwnProperty.call(e,"texture")&&t.uint32(34).string(e.texture),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof ji||(e=ji.create(e));let i=void 0===t?e.len:e.pos+t,n=new bi.Chunk;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:n.vertices=bi.Vertices.decode(e,e.uint32());break;case 2:n.faces=bi.Faces.decode(e,e.uint32());break;case 3:n.name=e.string();break;case 4:n.texture=e.string();break;default:e.skipType(7&t)}}if(!n.hasOwnProperty("vertices"))throw Ii.ProtocolError("missing required 'vertices'",{instance:n});if(!n.hasOwnProperty("faces"))throw Ii.ProtocolError("missing required 'faces'",{instance:n});if(!n.hasOwnProperty("name"))throw Ii.ProtocolError("missing required 'name'",{instance:n});return n},e.decodeDelimited=function(e){return e instanceof ji||(e=new ji(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";{let t=bi.Vertices.verify(e.vertices);if(t)return"vertices."+t}{let t=bi.Faces.verify(e.faces);if(t)return"faces."+t}return Ii.isString(e.name)?null!=e.texture&&e.hasOwnProperty("texture")&&!Ii.isString(e.texture)?"texture: string expected":null:"name: string expected"},e.fromObject=function(e){if(e instanceof bi.Chunk)return e;let t=new bi.Chunk;if(null!=e.vertices){if("object"!=typeof e.vertices)throw TypeError(".Chunk.vertices: object expected");t.vertices=bi.Vertices.fromObject(e.vertices)}if(null!=e.faces){if("object"!=typeof e.faces)throw TypeError(".Chunk.faces: object expected");t.faces=bi.Faces.fromObject(e.faces)}return null!=e.name&&(t.name=String(e.name)),null!=e.texture&&(t.texture=String(e.texture)),t},e.toObject=function(e,t){t||(t={});let i={};return t.defaults&&(i.vertices=null,i.faces=null,i.name="",i.texture=""),null!=e.vertices&&e.hasOwnProperty("vertices")&&(i.vertices=bi.Vertices.toObject(e.vertices,t)),null!=e.faces&&e.hasOwnProperty("faces")&&(i.faces=bi.Faces.toObject(e.faces,t)),null!=e.name&&e.hasOwnProperty("name")&&(i.name=e.name),null!=e.texture&&e.hasOwnProperty("texture")&&(i.texture=e.texture),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})(),bi.Vertices=(()=>{function e(e){if(this.xyz=[],this.uvs=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.xyz=Ii.emptyArray,e.prototype.uvs=Ii.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=zi.create()),null!=e.xyz&&e.xyz.length){t.uint32(10).fork();for(let i=0;i<e.xyz.length;++i)t.float(e.xyz[i]);t.ldelim()}if(null!=e.uvs&&e.uvs.length){t.uint32(18).fork();for(let i=0;i<e.uvs.length;++i)t.float(e.uvs[i]);t.ldelim()}return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof ji||(e=ji.create(e));let i=void 0===t?e.len:e.pos+t,n=new bi.Vertices;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:if(n.xyz&&n.xyz.length||(n.xyz=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.xyz.push(e.float())}else n.xyz.push(e.float());break;case 2:if(n.uvs&&n.uvs.length||(n.uvs=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.uvs.push(e.float())}else n.uvs.push(e.float());break;default:e.skipType(7&t)}}return n},e.decodeDelimited=function(e){return e instanceof ji||(e=new ji(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.xyz&&e.hasOwnProperty("xyz")){if(!Array.isArray(e.xyz))return"xyz: array expected";for(let t=0;t<e.xyz.length;++t)if("number"!=typeof e.xyz[t])return"xyz: number[] expected"}if(null!=e.uvs&&e.hasOwnProperty("uvs")){if(!Array.isArray(e.uvs))return"uvs: array expected";for(let t=0;t<e.uvs.length;++t)if("number"!=typeof e.uvs[t])return"uvs: number[] expected"}return null},e.fromObject=function(e){if(e instanceof bi.Vertices)return e;let t=new bi.Vertices;if(e.xyz){if(!Array.isArray(e.xyz))throw TypeError(".Vertices.xyz: array expected");t.xyz=[];for(let i=0;i<e.xyz.length;++i)t.xyz[i]=Number(e.xyz[i])}if(e.uvs){if(!Array.isArray(e.uvs))throw TypeError(".Vertices.uvs: array expected");t.uvs=[];for(let i=0;i<e.uvs.length;++i)t.uvs[i]=Number(e.uvs[i])}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.xyz=[],i.uvs=[]),e.xyz&&e.xyz.length){i.xyz=[];for(let n=0;n<e.xyz.length;++n)i.xyz[n]=t.json&&!isFinite(e.xyz[n])?String(e.xyz[n]):e.xyz[n]}if(e.uvs&&e.uvs.length){i.uvs=[];for(let n=0;n<e.uvs.length;++n)i.uvs[n]=t.json&&!isFinite(e.uvs[n])?String(e.uvs[n]):e.uvs[n]}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})(),bi.Faces=(()=>{function e(e){if(this.indices=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.indices=Ii.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=zi.create()),null!=e.indices&&e.indices.length){t.uint32(10).fork();for(let i=0;i<e.indices.length;++i)t.uint32(e.indices[i]);t.ldelim()}return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof ji||(e=ji.create(e));let i=void 0===t?e.len:e.pos+t,n=new bi.Faces;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:if(n.indices&&n.indices.length||(n.indices=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.indices.push(e.uint32())}else n.indices.push(e.uint32());break;default:e.skipType(7&t)}}return n},e.decodeDelimited=function(e){return e instanceof ji||(e=new ji(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.indices&&e.hasOwnProperty("indices")){if(!Array.isArray(e.indices))return"indices: array expected";for(let t=0;t<e.indices.length;++t)if(!Ii.isInteger(e.indices[t]))return"indices: integer[] expected"}return null},e.fromObject=function(e){if(e instanceof bi.Faces)return e;let t=new bi.Faces;if(e.indices){if(!Array.isArray(e.indices))throw TypeError(".Faces.indices: array expected");t.indices=[];for(let i=0;i<e.indices.length;++i)t.indices[i]=e.indices[i]>>>0}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.indices=[]),e.indices&&e.indices.length){i.indices=[];for(let t=0;t<e.indices.length;++t)i.indices[t]=e.indices[t]}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})();var Si=(new r.Matrix4).set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1);function Li(e){var t=e.match(/(group|floor)-?(\d+)/);return t?parseInt(t[2],10):0}function ki(e){var t=e.match(/(chunk)-?(\d+)/);return t?parseInt(t[2],10):0}function Ci(e){var t=e.indices,i=e.vertices,n=e.uvs,o=new r.BufferGeometry;o.setIndex(new r.BufferAttribute(new Uint32Array(t),1)),o.setAttribute("position",new r.BufferAttribute(new Float32Array(i),3)),o.attributes.position.applyMatrix4(Si),Re(n)||o.setAttribute("uv",new r.BufferAttribute(new Float32Array(n),2));for(var s=new Float32Array(i.length),a=new r.Vector3,u=new r.Vector3,c=new r.Vector3,l=new r.Vector3,h=new r.Vector3,d=new r.Vector3,p=0,A=o.index.array.length,f=void 0,M=void 0,g=void 0;p<A;p+=3)f=3*t[p+0],M=3*t[p+1],g=3*t[p+2],a.x=i[f],a.y=i[f+1],a.z=i[f+2],u.x=i[M],u.y=i[M+1],u.z=i[M+2],c.x=i[g],c.y=i[g+1],c.z=i[g+2],l.x=c.x-u.x,l.y=c.y-u.y,l.z=c.z-u.z,h.x=a.x-u.x,h.y=a.y-u.y,h.z=a.z-u.z,d.x=l.y*h.z-l.z*h.y,d.y=l.z*h.x-l.x*h.z,d.z=l.x*h.y-l.y*h.x,s[f]+=d.x,s[f+1]+=d.y,s[f+2]+=d.z,s[M]+=d.x,s[M+1]+=d.y,s[M+2]+=d.z,s[g]+=d.x,s[g+1]+=d.y,s[g+2]+=d.z;return o.setAttribute("normal",new r.BufferAttribute(s,3)),o}function Pi(e,i,n,o){var s=t.__assign({key:"texture.pbm",basisLoaderInitialized:wi.isInitialized()},Xt(i,["format","quality","size"]));return e=i.transform?i.transform(e,s):ti(e,s),new xi({allowHosts:n,networkSubscribe:o}).load(e,{wrapS:r.ClampToEdgeWrapping,wrapT:r.ClampToEdgeWrapping,minFilter:r.LinearFilter,maxSize:new r.Vector2(1024,1024)}).then((function(e){var t=e.body;return t.needsUpdate=!0,t}))}function Bi(e){var t=new rt;return e.catch((function(){return null})).then((function(e){t.uniforms.map.value=e,t.uniforms.exposure.value=3.3})),t}function _i(e,t,i,n,o,s,a){void 0===o&&(o={});for(var u=0,c=e;u<c.length;u++){var l=c[u];l.chunkName=ki(l.name),l.floorName=Li(l.name),l.texture&&(l.texture=i[l.chunkName]=i[l.chunkName]||t+l.texture)}e.sort((function(e,t){return 1e3*e.floorName+e.chunkName-(1e3*t.floorName+t.chunkName)}));var h=[],d=[],p=Promise.resolve();return(p=(p=p.then((function(){return Ft((function(){for(var t=e.length,i=0;i<t;i++){var u=e[i],c=Li(u.name),l=h[c]=h[c]||{geometries:[],materials:[]},d=Ci({vertices:u.vertices.xyz,uvs:u.vertices.uvs,indices:u.faces.indices});if(d.name="model_geo_chunk_"+i,l.geometries.push(d),u.texture){(p=Bi(u.texture in o?o[u.texture]:o[u.texture]=Pi(u.texture,n,s,a))).name="model_mtl_chunk_"+i,l.materials.push(p)}else{var p;(p=new rt).defines.USE_MAP=!1,p.uniforms.color.value=new r.Color(16777215),p.name="model_mtl_chunk_"+i,l.materials.push(p)}}}))}))).then((function(){return Ft((function(){for(var e=0;e<h.length;e++){var t=h[e];if(t){var i=Ei.mergeBufferGeometries(t.geometries,!0);t.geometries.forEach((function(e){return e.dispose()}));var n=new qe(i,t.materials);n.floorIndex=e,n.name="model_floor_"+e,d.push(n)}}}))}))).then((function(){var e=Object.keys(o).map((function(e){return o[e].catch((function(){}))}));return Promise.all(e).then((function(){return d}))}))}function Ui(e,t){return!1!==(e=Object.assign({},e)).autoResize&&(e.size=t>96?Math.min(e.size||1/0,100):t>48?Math.min(e.size||1/0,200):t>24?Math.min(e.size||1/0,400):t>12?Math.min(e.size||1/0,800):Math.min(e.size||1/0,1024)),e}function Ri(e){return 0===e.indexOf("//")||/^[0-9a-z]+\:\/\//i.test(e)}const Qi=o.Reader,Yi=o.Writer,Fi=o.util,Vi=o.roots["@REALSEE/FIVE:0"]||(o.roots["@REALSEE/FIVE:0"]={}),Hi=Vi.Model=(()=>{function e(e){if(this.meshes=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.meshes=Fi.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=Yi.create()),null!=e.meshes&&e.meshes.length)for(let i=0;i<e.meshes.length;++i)Vi.Mesh.encode(e.meshes[i],t.uint32(10).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof Qi||(e=Qi.create(e));let i=void 0===t?e.len:e.pos+t,n=new Vi.Model;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:n.meshes&&n.meshes.length||(n.meshes=[]),n.meshes.push(Vi.Mesh.decode(e,e.uint32()));break;default:e.skipType(7&t)}}return n},e.decodeDelimited=function(e){return e instanceof Qi||(e=new Qi(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.meshes&&e.hasOwnProperty("meshes")){if(!Array.isArray(e.meshes))return"meshes: array expected";for(let t=0;t<e.meshes.length;++t){let i=Vi.Mesh.verify(e.meshes[t]);if(i)return"meshes."+i}}return null},e.fromObject=function(e){if(e instanceof Vi.Model)return e;let t=new Vi.Model;if(e.meshes){if(!Array.isArray(e.meshes))throw TypeError(".Model.meshes: array expected");t.meshes=[];for(let i=0;i<e.meshes.length;++i){if("object"!=typeof e.meshes[i])throw TypeError(".Model.meshes: object expected");t.meshes[i]=Vi.Mesh.fromObject(e.meshes[i])}}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.meshes=[]),e.meshes&&e.meshes.length){i.meshes=[];for(let n=0;n<e.meshes.length;++n)i.meshes[n]=Vi.Mesh.toObject(e.meshes[n],t)}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})();Vi.Mesh=(()=>{function e(e){if(this.chunks=[],this.matrix=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.name="",e.prototype.chunks=Fi.emptyArray,e.prototype.matrix=Fi.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=Yi.create()),t.uint32(10).string(e.name),null!=e.chunks&&e.chunks.length)for(let i=0;i<e.chunks.length;++i)Vi.Chunk.encode(e.chunks[i],t.uint32(18).fork()).ldelim();if(null!=e.matrix&&e.matrix.length)for(let i=0;i<e.matrix.length;++i)Vi.Matrix.encode(e.matrix[i],t.uint32(26).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof Qi||(e=Qi.create(e));let i=void 0===t?e.len:e.pos+t,n=new Vi.Mesh;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:n.name=e.string();break;case 2:n.chunks&&n.chunks.length||(n.chunks=[]),n.chunks.push(Vi.Chunk.decode(e,e.uint32()));break;case 3:n.matrix&&n.matrix.length||(n.matrix=[]),n.matrix.push(Vi.Matrix.decode(e,e.uint32()));break;default:e.skipType(7&t)}}if(!n.hasOwnProperty("name"))throw Fi.ProtocolError("missing required 'name'",{instance:n});return n},e.decodeDelimited=function(e){return e instanceof Qi||(e=new Qi(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(!Fi.isString(e.name))return"name: string expected";if(null!=e.chunks&&e.hasOwnProperty("chunks")){if(!Array.isArray(e.chunks))return"chunks: array expected";for(let t=0;t<e.chunks.length;++t){let i=Vi.Chunk.verify(e.chunks[t]);if(i)return"chunks."+i}}if(null!=e.matrix&&e.hasOwnProperty("matrix")){if(!Array.isArray(e.matrix))return"matrix: array expected";for(let t=0;t<e.matrix.length;++t){let i=Vi.Matrix.verify(e.matrix[t]);if(i)return"matrix."+i}}return null},e.fromObject=function(e){if(e instanceof Vi.Mesh)return e;let t=new Vi.Mesh;if(null!=e.name&&(t.name=String(e.name)),e.chunks){if(!Array.isArray(e.chunks))throw TypeError(".Mesh.chunks: array expected");t.chunks=[];for(let i=0;i<e.chunks.length;++i){if("object"!=typeof e.chunks[i])throw TypeError(".Mesh.chunks: object expected");t.chunks[i]=Vi.Chunk.fromObject(e.chunks[i])}}if(e.matrix){if(!Array.isArray(e.matrix))throw TypeError(".Mesh.matrix: array expected");t.matrix=[];for(let i=0;i<e.matrix.length;++i){if("object"!=typeof e.matrix[i])throw TypeError(".Mesh.matrix: object expected");t.matrix[i]=Vi.Matrix.fromObject(e.matrix[i])}}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.chunks=[],i.matrix=[]),t.defaults&&(i.name=""),null!=e.name&&e.hasOwnProperty("name")&&(i.name=e.name),e.chunks&&e.chunks.length){i.chunks=[];for(let n=0;n<e.chunks.length;++n)i.chunks[n]=Vi.Chunk.toObject(e.chunks[n],t)}if(e.matrix&&e.matrix.length){i.matrix=[];for(let n=0;n<e.matrix.length;++n)i.matrix[n]=Vi.Matrix.toObject(e.matrix[n],t)}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})(),Vi.Matrix=(()=>{function e(e){if(this.elements=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.elements=Fi.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=Yi.create()),null!=e.elements&&e.elements.length)for(let i=0;i<e.elements.length;++i)t.uint32(13).float(e.elements[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof Qi||(e=Qi.create(e));let i=void 0===t?e.len:e.pos+t,n=new Vi.Matrix;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:if(n.elements&&n.elements.length||(n.elements=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.elements.push(e.float())}else n.elements.push(e.float());break;default:e.skipType(7&t)}}return n},e.decodeDelimited=function(e){return e instanceof Qi||(e=new Qi(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.elements&&e.hasOwnProperty("elements")){if(!Array.isArray(e.elements))return"elements: array expected";for(let t=0;t<e.elements.length;++t)if("number"!=typeof e.elements[t])return"elements: number[] expected"}return null},e.fromObject=function(e){if(e instanceof Vi.Matrix)return e;let t=new Vi.Matrix;if(e.elements){if(!Array.isArray(e.elements))throw TypeError(".Matrix.elements: array expected");t.elements=[];for(let i=0;i<e.elements.length;++i)t.elements[i]=Number(e.elements[i])}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.elements=[]),e.elements&&e.elements.length){i.elements=[];for(let n=0;n<e.elements.length;++n)i.elements[n]=t.json&&!isFinite(e.elements[n])?String(e.elements[n]):e.elements[n]}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})(),Vi.Chunk=(()=>{function e(e){if(this.material=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.geometry=null,e.prototype.material=Fi.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=Yi.create()),Vi.Geometry.encode(e.geometry,t.uint32(18).fork()).ldelim(),null!=e.material&&e.material.length)for(let i=0;i<e.material.length;++i)Vi.Material.encode(e.material[i],t.uint32(26).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof Qi||(e=Qi.create(e));let i=void 0===t?e.len:e.pos+t,n=new Vi.Chunk;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 2:n.geometry=Vi.Geometry.decode(e,e.uint32());break;case 3:n.material&&n.material.length||(n.material=[]),n.material.push(Vi.Material.decode(e,e.uint32()));break;default:e.skipType(7&t)}}if(!n.hasOwnProperty("geometry"))throw Fi.ProtocolError("missing required 'geometry'",{instance:n});return n},e.decodeDelimited=function(e){return e instanceof Qi||(e=new Qi(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";{let t=Vi.Geometry.verify(e.geometry);if(t)return"geometry."+t}if(null!=e.material&&e.hasOwnProperty("material")){if(!Array.isArray(e.material))return"material: array expected";for(let t=0;t<e.material.length;++t){let i=Vi.Material.verify(e.material[t]);if(i)return"material."+i}}return null},e.fromObject=function(e){if(e instanceof Vi.Chunk)return e;let t=new Vi.Chunk;if(null!=e.geometry){if("object"!=typeof e.geometry)throw TypeError(".Chunk.geometry: object expected");t.geometry=Vi.Geometry.fromObject(e.geometry)}if(e.material){if(!Array.isArray(e.material))throw TypeError(".Chunk.material: array expected");t.material=[];for(let i=0;i<e.material.length;++i){if("object"!=typeof e.material[i])throw TypeError(".Chunk.material: object expected");t.material[i]=Vi.Material.fromObject(e.material[i])}}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.material=[]),t.defaults&&(i.geometry=null),null!=e.geometry&&e.hasOwnProperty("geometry")&&(i.geometry=Vi.Geometry.toObject(e.geometry,t)),e.material&&e.material.length){i.material=[];for(let n=0;n<e.material.length;++n)i.material[n]=Vi.Material.toObject(e.material[n],t)}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})(),Vi.Geometry=(()=>{function e(e){if(this.groups=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.position=null,e.prototype.uv=null,e.prototype.uv2=null,e.prototype.normal=null,e.prototype.groups=Fi.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=Yi.create()),Vi.Position.encode(e.position,t.uint32(10).fork()).ldelim(),null!=e.uv&&Object.hasOwnProperty.call(e,"uv")&&Vi.UV.encode(e.uv,t.uint32(18).fork()).ldelim(),null!=e.uv2&&Object.hasOwnProperty.call(e,"uv2")&&Vi.UV.encode(e.uv2,t.uint32(26).fork()).ldelim(),Vi.Normal.encode(e.normal,t.uint32(34).fork()).ldelim(),null!=e.groups&&e.groups.length)for(let i=0;i<e.groups.length;++i)Vi.Group.encode(e.groups[i],t.uint32(42).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof Qi||(e=Qi.create(e));let i=void 0===t?e.len:e.pos+t,n=new Vi.Geometry;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:n.position=Vi.Position.decode(e,e.uint32());break;case 2:n.uv=Vi.UV.decode(e,e.uint32());break;case 3:n.uv2=Vi.UV.decode(e,e.uint32());break;case 4:n.normal=Vi.Normal.decode(e,e.uint32());break;case 5:n.groups&&n.groups.length||(n.groups=[]),n.groups.push(Vi.Group.decode(e,e.uint32()));break;default:e.skipType(7&t)}}if(!n.hasOwnProperty("position"))throw Fi.ProtocolError("missing required 'position'",{instance:n});if(!n.hasOwnProperty("normal"))throw Fi.ProtocolError("missing required 'normal'",{instance:n});return n},e.decodeDelimited=function(e){return e instanceof Qi||(e=new Qi(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";{let t=Vi.Position.verify(e.position);if(t)return"position."+t}if(null!=e.uv&&e.hasOwnProperty("uv")){let t=Vi.UV.verify(e.uv);if(t)return"uv."+t}if(null!=e.uv2&&e.hasOwnProperty("uv2")){let t=Vi.UV.verify(e.uv2);if(t)return"uv2."+t}{let t=Vi.Normal.verify(e.normal);if(t)return"normal."+t}if(null!=e.groups&&e.hasOwnProperty("groups")){if(!Array.isArray(e.groups))return"groups: array expected";for(let t=0;t<e.groups.length;++t){let i=Vi.Group.verify(e.groups[t]);if(i)return"groups."+i}}return null},e.fromObject=function(e){if(e instanceof Vi.Geometry)return e;let t=new Vi.Geometry;if(null!=e.position){if("object"!=typeof e.position)throw TypeError(".Geometry.position: object expected");t.position=Vi.Position.fromObject(e.position)}if(null!=e.uv){if("object"!=typeof e.uv)throw TypeError(".Geometry.uv: object expected");t.uv=Vi.UV.fromObject(e.uv)}if(null!=e.uv2){if("object"!=typeof e.uv2)throw TypeError(".Geometry.uv2: object expected");t.uv2=Vi.UV.fromObject(e.uv2)}if(null!=e.normal){if("object"!=typeof e.normal)throw TypeError(".Geometry.normal: object expected");t.normal=Vi.Normal.fromObject(e.normal)}if(e.groups){if(!Array.isArray(e.groups))throw TypeError(".Geometry.groups: array expected");t.groups=[];for(let i=0;i<e.groups.length;++i){if("object"!=typeof e.groups[i])throw TypeError(".Geometry.groups: object expected");t.groups[i]=Vi.Group.fromObject(e.groups[i])}}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.groups=[]),t.defaults&&(i.position=null,i.uv=null,i.uv2=null,i.normal=null),null!=e.position&&e.hasOwnProperty("position")&&(i.position=Vi.Position.toObject(e.position,t)),null!=e.uv&&e.hasOwnProperty("uv")&&(i.uv=Vi.UV.toObject(e.uv,t)),null!=e.uv2&&e.hasOwnProperty("uv2")&&(i.uv2=Vi.UV.toObject(e.uv2,t)),null!=e.normal&&e.hasOwnProperty("normal")&&(i.normal=Vi.Normal.toObject(e.normal,t)),e.groups&&e.groups.length){i.groups=[];for(let n=0;n<e.groups.length;++n)i.groups[n]=Vi.Group.toObject(e.groups[n],t)}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})(),Vi.Position=(()=>{function e(e){if(this.array=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.array=Fi.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=Yi.create()),null!=e.array&&e.array.length){t.uint32(10).fork();for(let i=0;i<e.array.length;++i)t.float(e.array[i]);t.ldelim()}return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof Qi||(e=Qi.create(e));let i=void 0===t?e.len:e.pos+t,n=new Vi.Position;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:if(n.array&&n.array.length||(n.array=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.array.push(e.float())}else n.array.push(e.float());break;default:e.skipType(7&t)}}return n},e.decodeDelimited=function(e){return e instanceof Qi||(e=new Qi(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.array&&e.hasOwnProperty("array")){if(!Array.isArray(e.array))return"array: array expected";for(let t=0;t<e.array.length;++t)if("number"!=typeof e.array[t])return"array: number[] expected"}return null},e.fromObject=function(e){if(e instanceof Vi.Position)return e;let t=new Vi.Position;if(e.array){if(!Array.isArray(e.array))throw TypeError(".Position.array: array expected");t.array=[];for(let i=0;i<e.array.length;++i)t.array[i]=Number(e.array[i])}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.array=[]),e.array&&e.array.length){i.array=[];for(let n=0;n<e.array.length;++n)i.array[n]=t.json&&!isFinite(e.array[n])?String(e.array[n]):e.array[n]}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})(),Vi.UV=(()=>{function e(e){if(this.array=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.array=Fi.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=Yi.create()),null!=e.array&&e.array.length){t.uint32(10).fork();for(let i=0;i<e.array.length;++i)t.float(e.array[i]);t.ldelim()}return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof Qi||(e=Qi.create(e));let i=void 0===t?e.len:e.pos+t,n=new Vi.UV;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:if(n.array&&n.array.length||(n.array=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.array.push(e.float())}else n.array.push(e.float());break;default:e.skipType(7&t)}}return n},e.decodeDelimited=function(e){return e instanceof Qi||(e=new Qi(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.array&&e.hasOwnProperty("array")){if(!Array.isArray(e.array))return"array: array expected";for(let t=0;t<e.array.length;++t)if("number"!=typeof e.array[t])return"array: number[] expected"}return null},e.fromObject=function(e){if(e instanceof Vi.UV)return e;let t=new Vi.UV;if(e.array){if(!Array.isArray(e.array))throw TypeError(".UV.array: array expected");t.array=[];for(let i=0;i<e.array.length;++i)t.array[i]=Number(e.array[i])}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.array=[]),e.array&&e.array.length){i.array=[];for(let n=0;n<e.array.length;++n)i.array[n]=t.json&&!isFinite(e.array[n])?String(e.array[n]):e.array[n]}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})(),Vi.Normal=(()=>{function e(e){if(this.array=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.array=Fi.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=Yi.create()),null!=e.array&&e.array.length){t.uint32(10).fork();for(let i=0;i<e.array.length;++i)t.float(e.array[i]);t.ldelim()}return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof Qi||(e=Qi.create(e));let i=void 0===t?e.len:e.pos+t,n=new Vi.Normal;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:if(n.array&&n.array.length||(n.array=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.array.push(e.float())}else n.array.push(e.float());break;default:e.skipType(7&t)}}return n},e.decodeDelimited=function(e){return e instanceof Qi||(e=new Qi(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.array&&e.hasOwnProperty("array")){if(!Array.isArray(e.array))return"array: array expected";for(let t=0;t<e.array.length;++t)if("number"!=typeof e.array[t])return"array: number[] expected"}return null},e.fromObject=function(e){if(e instanceof Vi.Normal)return e;let t=new Vi.Normal;if(e.array){if(!Array.isArray(e.array))throw TypeError(".Normal.array: array expected");t.array=[];for(let i=0;i<e.array.length;++i)t.array[i]=Number(e.array[i])}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.array=[]),e.array&&e.array.length){i.array=[];for(let n=0;n<e.array.length;++n)i.array[n]=t.json&&!isFinite(e.array[n])?String(e.array[n]):e.array[n]}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})(),Vi.Group=(()=>{function e(e){if(e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.start=0,e.prototype.count=0,e.prototype.materialIndex=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=Yi.create()),t.uint32(8).uint32(e.start),t.uint32(16).uint32(e.count),t.uint32(24).uint32(e.materialIndex),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof Qi||(e=Qi.create(e));let i=void 0===t?e.len:e.pos+t,n=new Vi.Group;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:n.start=e.uint32();break;case 2:n.count=e.uint32();break;case 3:n.materialIndex=e.uint32();break;default:e.skipType(7&t)}}if(!n.hasOwnProperty("start"))throw Fi.ProtocolError("missing required 'start'",{instance:n});if(!n.hasOwnProperty("count"))throw Fi.ProtocolError("missing required 'count'",{instance:n});if(!n.hasOwnProperty("materialIndex"))throw Fi.ProtocolError("missing required 'materialIndex'",{instance:n});return n},e.decodeDelimited=function(e){return e instanceof Qi||(e=new Qi(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":Fi.isInteger(e.start)?Fi.isInteger(e.count)?Fi.isInteger(e.materialIndex)?null:"materialIndex: integer expected":"count: integer expected":"start: integer expected"},e.fromObject=function(e){if(e instanceof Vi.Group)return e;let t=new Vi.Group;return null!=e.start&&(t.start=e.start>>>0),null!=e.count&&(t.count=e.count>>>0),null!=e.materialIndex&&(t.materialIndex=e.materialIndex>>>0),t},e.toObject=function(e,t){t||(t={});let i={};return t.defaults&&(i.start=0,i.count=0,i.materialIndex=0),null!=e.start&&e.hasOwnProperty("start")&&(i.start=e.start),null!=e.count&&e.hasOwnProperty("count")&&(i.count=e.count),null!=e.materialIndex&&e.hasOwnProperty("materialIndex")&&(i.materialIndex=e.materialIndex),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})(),Vi.Material=(()=>{function e(e){if(e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.kd=null,e.prototype.ks=null,e.prototype.ke=null,e.prototype.mapkd="",e.prototype.mapks="",e.prototype.mapke="",e.prototype.norm="",e.prototype.mapbump="",e.prototype.bump="",e.prototype.mapd="",e.prototype.ns=0,e.prototype.d=0,e.prototype.tr=0,e.prototype.mapkdrepeat="",e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=Yi.create()),null!=e.kd&&Object.hasOwnProperty.call(e,"kd")&&Vi.Color.encode(e.kd,t.uint32(10).fork()).ldelim(),null!=e.ks&&Object.hasOwnProperty.call(e,"ks")&&Vi.Color.encode(e.ks,t.uint32(18).fork()).ldelim(),null!=e.ke&&Object.hasOwnProperty.call(e,"ke")&&Vi.Color.encode(e.ke,t.uint32(26).fork()).ldelim(),null!=e.mapkd&&Object.hasOwnProperty.call(e,"mapkd")&&t.uint32(34).string(e.mapkd),null!=e.mapks&&Object.hasOwnProperty.call(e,"mapks")&&t.uint32(42).string(e.mapks),null!=e.mapke&&Object.hasOwnProperty.call(e,"mapke")&&t.uint32(50).string(e.mapke),null!=e.norm&&Object.hasOwnProperty.call(e,"norm")&&t.uint32(58).string(e.norm),null!=e.mapbump&&Object.hasOwnProperty.call(e,"mapbump")&&t.uint32(66).string(e.mapbump),null!=e.bump&&Object.hasOwnProperty.call(e,"bump")&&t.uint32(74).string(e.bump),null!=e.mapd&&Object.hasOwnProperty.call(e,"mapd")&&t.uint32(82).string(e.mapd),null!=e.ns&&Object.hasOwnProperty.call(e,"ns")&&t.uint32(93).float(e.ns),null!=e.d&&Object.hasOwnProperty.call(e,"d")&&t.uint32(101).float(e.d),null!=e.tr&&Object.hasOwnProperty.call(e,"tr")&&t.uint32(109).float(e.tr),null!=e.mapkdrepeat&&Object.hasOwnProperty.call(e,"mapkdrepeat")&&t.uint32(114).string(e.mapkdrepeat),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof Qi||(e=Qi.create(e));let i=void 0===t?e.len:e.pos+t,n=new Vi.Material;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:n.kd=Vi.Color.decode(e,e.uint32());break;case 2:n.ks=Vi.Color.decode(e,e.uint32());break;case 3:n.ke=Vi.Color.decode(e,e.uint32());break;case 4:n.mapkd=e.string();break;case 5:n.mapks=e.string();break;case 6:n.mapke=e.string();break;case 7:n.norm=e.string();break;case 8:n.mapbump=e.string();break;case 9:n.bump=e.string();break;case 10:n.mapd=e.string();break;case 11:n.ns=e.float();break;case 12:n.d=e.float();break;case 13:n.tr=e.float();break;case 14:n.mapkdrepeat=e.string();break;default:e.skipType(7&t)}}return n},e.decodeDelimited=function(e){return e instanceof Qi||(e=new Qi(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.kd&&e.hasOwnProperty("kd")){let t=Vi.Color.verify(e.kd);if(t)return"kd."+t}if(null!=e.ks&&e.hasOwnProperty("ks")){let t=Vi.Color.verify(e.ks);if(t)return"ks."+t}if(null!=e.ke&&e.hasOwnProperty("ke")){let t=Vi.Color.verify(e.ke);if(t)return"ke."+t}return null!=e.mapkd&&e.hasOwnProperty("mapkd")&&!Fi.isString(e.mapkd)?"mapkd: string expected":null!=e.mapks&&e.hasOwnProperty("mapks")&&!Fi.isString(e.mapks)?"mapks: string expected":null!=e.mapke&&e.hasOwnProperty("mapke")&&!Fi.isString(e.mapke)?"mapke: string expected":null!=e.norm&&e.hasOwnProperty("norm")&&!Fi.isString(e.norm)?"norm: string expected":null!=e.mapbump&&e.hasOwnProperty("mapbump")&&!Fi.isString(e.mapbump)?"mapbump: string expected":null!=e.bump&&e.hasOwnProperty("bump")&&!Fi.isString(e.bump)?"bump: string expected":null!=e.mapd&&e.hasOwnProperty("mapd")&&!Fi.isString(e.mapd)?"mapd: string expected":null!=e.ns&&e.hasOwnProperty("ns")&&"number"!=typeof e.ns?"ns: number expected":null!=e.d&&e.hasOwnProperty("d")&&"number"!=typeof e.d?"d: number expected":null!=e.tr&&e.hasOwnProperty("tr")&&"number"!=typeof e.tr?"tr: number expected":null!=e.mapkdrepeat&&e.hasOwnProperty("mapkdrepeat")&&!Fi.isString(e.mapkdrepeat)?"mapkdrepeat: string expected":null},e.fromObject=function(e){if(e instanceof Vi.Material)return e;let t=new Vi.Material;if(null!=e.kd){if("object"!=typeof e.kd)throw TypeError(".Material.kd: object expected");t.kd=Vi.Color.fromObject(e.kd)}if(null!=e.ks){if("object"!=typeof e.ks)throw TypeError(".Material.ks: object expected");t.ks=Vi.Color.fromObject(e.ks)}if(null!=e.ke){if("object"!=typeof e.ke)throw TypeError(".Material.ke: object expected");t.ke=Vi.Color.fromObject(e.ke)}return null!=e.mapkd&&(t.mapkd=String(e.mapkd)),null!=e.mapks&&(t.mapks=String(e.mapks)),null!=e.mapke&&(t.mapke=String(e.mapke)),null!=e.norm&&(t.norm=String(e.norm)),null!=e.mapbump&&(t.mapbump=String(e.mapbump)),null!=e.bump&&(t.bump=String(e.bump)),null!=e.mapd&&(t.mapd=String(e.mapd)),null!=e.ns&&(t.ns=Number(e.ns)),null!=e.d&&(t.d=Number(e.d)),null!=e.tr&&(t.tr=Number(e.tr)),null!=e.mapkdrepeat&&(t.mapkdrepeat=String(e.mapkdrepeat)),t},e.toObject=function(e,t){t||(t={});let i={};return t.defaults&&(i.kd=null,i.ks=null,i.ke=null,i.mapkd="",i.mapks="",i.mapke="",i.norm="",i.mapbump="",i.bump="",i.mapd="",i.ns=0,i.d=0,i.tr=0,i.mapkdrepeat=""),null!=e.kd&&e.hasOwnProperty("kd")&&(i.kd=Vi.Color.toObject(e.kd,t)),null!=e.ks&&e.hasOwnProperty("ks")&&(i.ks=Vi.Color.toObject(e.ks,t)),null!=e.ke&&e.hasOwnProperty("ke")&&(i.ke=Vi.Color.toObject(e.ke,t)),null!=e.mapkd&&e.hasOwnProperty("mapkd")&&(i.mapkd=e.mapkd),null!=e.mapks&&e.hasOwnProperty("mapks")&&(i.mapks=e.mapks),null!=e.mapke&&e.hasOwnProperty("mapke")&&(i.mapke=e.mapke),null!=e.norm&&e.hasOwnProperty("norm")&&(i.norm=e.norm),null!=e.mapbump&&e.hasOwnProperty("mapbump")&&(i.mapbump=e.mapbump),null!=e.bump&&e.hasOwnProperty("bump")&&(i.bump=e.bump),null!=e.mapd&&e.hasOwnProperty("mapd")&&(i.mapd=e.mapd),null!=e.ns&&e.hasOwnProperty("ns")&&(i.ns=t.json&&!isFinite(e.ns)?String(e.ns):e.ns),null!=e.d&&e.hasOwnProperty("d")&&(i.d=t.json&&!isFinite(e.d)?String(e.d):e.d),null!=e.tr&&e.hasOwnProperty("tr")&&(i.tr=t.json&&!isFinite(e.tr)?String(e.tr):e.tr),null!=e.mapkdrepeat&&e.hasOwnProperty("mapkdrepeat")&&(i.mapkdrepeat=e.mapkdrepeat),i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})(),Vi.Color=(()=>{function e(e){if(this.rgb=[],e)for(let t=Object.keys(e),i=0;i<t.length;++i)null!=e[t[i]]&&(this[t[i]]=e[t[i]])}return e.prototype.rgb=Fi.emptyArray,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=Yi.create()),null!=e.rgb&&e.rgb.length)for(let i=0;i<e.rgb.length;++i)t.uint32(13).float(e.rgb[i]);return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof Qi||(e=Qi.create(e));let i=void 0===t?e.len:e.pos+t,n=new Vi.Color;for(;e.pos<i;){let t=e.uint32();switch(t>>>3){case 1:if(n.rgb&&n.rgb.length||(n.rgb=[]),2==(7&t)){let t=e.uint32()+e.pos;for(;e.pos<t;)n.rgb.push(e.float())}else n.rgb.push(e.float());break;default:e.skipType(7&t)}}return n},e.decodeDelimited=function(e){return e instanceof Qi||(e=new Qi(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.rgb&&e.hasOwnProperty("rgb")){if(!Array.isArray(e.rgb))return"rgb: array expected";for(let t=0;t<e.rgb.length;++t)if("number"!=typeof e.rgb[t])return"rgb: number[] expected"}return null},e.fromObject=function(e){if(e instanceof Vi.Color)return e;let t=new Vi.Color;if(e.rgb){if(!Array.isArray(e.rgb))throw TypeError(".Color.rgb: array expected");t.rgb=[];for(let i=0;i<e.rgb.length;++i)t.rgb[i]=Number(e.rgb[i])}return t},e.toObject=function(e,t){t||(t={});let i={};if((t.arrays||t.defaults)&&(i.rgb=[]),e.rgb&&e.rgb.length){i.rgb=[];for(let n=0;n<e.rgb.length;++n)i.rgb[n]=t.json&&!isFinite(e.rgb[n])?String(e.rgb[n]):e.rgb[n]}return i},e.prototype.toJSON=function(){return this.constructor.toObject(this,o.util.toJSONOptions)},e})();var Gi={};function Wi(e,i,n,o,s){var a,u=[],c=[];function l(e,a,u){var l=function(e){var t=e.position,i=e.normal,n=e.uv,o=e.uv2,s=e.groups,a=new r.BufferGeometry;return a.setAttribute("position",new r.BufferAttribute(new Float32Array(t.array),3)),i&&a.setAttribute("normal",new r.BufferAttribute(new Float32Array(i.array),3)),n&&a.setAttribute("uv",new r.BufferAttribute(new Float32Array(n.array),2)),o&&a.setAttribute("uv2",new r.BufferAttribute(new Float32Array(o.array),2)),s.forEach((function(e){return a.addGroup(e.start,e.count,e.materialIndex)})),a}(e);l.applyMatrix4(u);var h=new r.Vector3,d=new r.Quaternion,p=new r.Vector3;u.decompose(h,d,p),p.x*p.y*p.z<0&&l.attributes.normal&&l.attributes.position&&l.attributes.uv&&function(e){for(var t=[0,0,0],i=0;i<e.attributes.normal.array.length/9;i++)t[0]=e.attributes.normal.array[9*i],t[1]=e.attributes.normal.array[9*i+1],t[2]=e.attributes.normal.array[9*i+2],e.attributes.normal.array[9*i]=e.attributes.normal.array[9*i+6],e.attributes.normal.array[9*i+1]=e.attributes.normal.array[9*i+7],e.attributes.normal.array[9*i+2]=e.attributes.normal.array[9*i+8],e.attributes.normal.array[9*i+6]=t[0],e.attributes.normal.array[9*i+7]=t[1],e.attributes.normal.array[9*i+8]=t[2];for(i=0;i<e.attributes.position.array.length/9;i++)t[0]=e.attributes.position.array[9*i],t[1]=e.attributes.position.array[9*i+1],t[2]=e.attributes.position.array[9*i+2],e.attributes.position.array[9*i]=e.attributes.position.array[9*i+6],e.attributes.position.array[9*i+1]=e.attributes.position.array[9*i+7],e.attributes.position.array[9*i+2]=e.attributes.position.array[9*i+8],e.attributes.position.array[9*i+6]=t[0],e.attributes.position.array[9*i+7]=t[1],e.attributes.position.array[9*i+8]=t[2];for(i=0;i<e.attributes.uv.array.length/6;i++)t[0]=e.attributes.uv.array[6*i],t[1]=e.attributes.uv.array[6*i+1],e.attributes.uv.array[6*i]=e.attributes.uv.array[6*i+4],e.attributes.uv.array[6*i+1]=e.attributes.uv.array[6*i+5],e.attributes.uv.array[6*i+4]=t[0],e.attributes.uv.array[6*i+5]=t[1];e.attributes.normal.needsUpdate=!0,e.attributes.position.needsUpdate=!0,e.attributes.uv.needsUpdate=!0}(l);var A=a.map((function(e){var a=function(e,i,n,o,s){function a(e,a){if(Gi[e])return Promise.resolve(Gi[e]);var u=new xi({allowHosts:o,networkSubscribe:s});Ri(e)||(e=i+e),-1!==(e=(e=e.replace(/\/\/vrlab-image\d*.ljcdn.com\//,"//vrlab-public.ljcdn.com/")).split("?")[0]).indexOf(".png")&&(e=e.split(".png")[0]+".png"),-1!==e.indexOf(".jpg")&&(e=e.split(".jpg")[0]+".jpg"),0===e.indexOf("//")&&(e="https:"+e);var c=t.__assign({key:"texture.dome",size:64,basisLoaderInitialized:wi.isInitialized()},Xt(n,["quality","format"]));return e=n.transform?n.transform(e,c):ti(e,c),u.load(e,{wrapS:r.RepeatWrapping,wrapT:r.RepeatWrapping}).then((function(t){var i=t.body;return a&&i.repeat.copy(a),i.needsUpdate=!0,i.updateMatrix(),Gi[e]=i,i}))}var u=[],c=new rt,l=c.uniforms;l.exposure.value=4.3;var h,d=c.defines;if(d.USE_MAP=!1,d.USE_UV=!1,e.hasOwnProperty("kd")&&(l.diffuse.value=(new r.Color).fromArray(e.kd.rgb)),e.hasOwnProperty("mapkd")){var p=void 0;if(e.mapkdrepeat){var A=e.mapkdrepeat.split(/\s+/).map((function(e){return Number(e)})),f=A[0],M=A[1];p=new r.Vector2(f,M)}u.push(a(e.mapkd,p).then((function(e){d.USE_MAP=!0,d.USE_UV=!0,l.map.value=e,l.uvTransform.value=e.matrix})).catch((function(e){})))}return e.hasOwnProperty("ks")&&(l.specular.value=(new r.Color).fromArray(e.ks.rgb)),e.hasOwnProperty("mapks")&&u.push(a(e.mapks).then((function(e){l.specularMap.value=e})).catch((function(e){}))),e.hasOwnProperty("ke")&&(l.emissive.value=(new r.Color).fromArray(e.ke.rgb)),e.hasOwnProperty("mapke")&&u.push(a(e.mapke).then((function(e){l.emissiveMap.value=e})).catch((function(e){}))),e.hasOwnProperty("norm")&&u.push(a(e.norm).then((function(e){l.normalMap.value=e})).catch((function(e){}))),e.hasOwnProperty("mapbump")&&u.push(a(e.mapbump).then((function(e){l.bumpMap.value=e})).catch((function(e){}))),e.hasOwnProperty("bump")&&u.push(a(e.bump).then((function(e){l.bumpMap.value=e})).catch((function(e){}))),e.hasOwnProperty("ns")&&(l.shininess.value=e.ns),e.hasOwnProperty("d")&&(h=e.d)>=0&&h<1&&(l.originOpacity.value=h),e.hasOwnProperty("tr")&&(h=1-e.tr)>=0&&h<1&&(l.originOpacity.value=h),l.originOpacity.value<1&&(c.transparent=!0),{material:c,textureReady:Promise.all(u).then((function(){}))}}(e,i,n,o,s),u=a.material,l=a.textureReady;return c.push(l),u}));return new qe(l,A)}return(a=e,Hi.decode(a).meshes).forEach((function(e){var t=e.name,i=e.chunks,n=e.matrix;"Ceiling"!==t&&"CeilingDrop"!==t&&n.map((function(e){var n,o=new r.Matrix4;if(o.elements=e.elements,1===i.length){var s=i[0],a=s.geometry,c=s.material;n=l(a,c,o)}else n=new Ze,i.forEach((function(e,t){var i=l(e.geometry,e.material,o);i.name="chunk"+t,n.add(i)}));n.floorIndex=0,n.name=t,u.push(n)}))})),Promise.all(c).catch((function(){})).then((function(){return u}))}function qi(){Object.keys(Gi).forEach((function(e){Gi[e].dispose(),delete Gi[e]}))}function Ki(e){var i;return new((i=r.Triangle).bind.apply(i,t.__spreadArray([void 0],e.map((function(e){return new r.Vector3(e.x,e.y,e.z)})),!1)))}var Zi={at3d:function(e,t){for(var i=Ui(t.textureOptions,e.textures.length),n={},r=0,o=e.textures;r<o.length;r++){var s=o[r];n[s]=Pi(s,i,t.allowHosts,t.networkSubscribe)}return Promise.resolve().then((function(){return Ct(e.file,{responseType:"arraybuffer",allowHosts:t.allowHosts,networkSubscribe:t.networkSubscribe})})).then((function(e){return Zt(e.body)})).then((function(e){return Ft((function(){for(var t=[],i=0,n=e;i<n.length;i++){var r=n[i];try{var o=Oi.decode(r);t.push.apply(t,o.chunks)}catch(e){console.log(e)}}return t}))})).then((function(r){return Ft((function(){return _i(r,e.textureBase,e.textures.slice(),i,n,t.allowHosts,t.networkSubscribe)}))}))},pbm:function(e,t){for(var i=Ui(t.textureOptions,e.textures.length),n={},r=0,o=e.textures;r<o.length;r++){var s=o[r];n[s]=Pi(s,i,t.allowHosts,t.networkSubscribe)}return Promise.resolve().then((function(){return Ct(e.file,{responseType:"arraybuffer",allowHosts:t.allowHosts,networkSubscribe:t.networkSubscribe})})).then((function(e){return Ft((function(){var t=new Uint8Array(e.body),i=Oi.decode(t);return[].concat(i.chunks)}))})).then((function(r){return Ft((function(){return _i(r,e.textureBase,e.textures.slice(),i,n,t.allowHosts,t.networkSubscribe)}))}))},dome:function(e,t){return Promise.resolve().then((function(){return qi()})).then((function(){return Ct(e.file,{responseType:"arraybuffer",allowHosts:t.allowHosts,networkSubscribe:t.networkSubscribe})})).then((function(i){return Wi(new Uint8Array(i.body),e.textureBase,t.textureOptions,t.allowHosts,t.networkSubscribe)}))},domez:function(e,t){return Promise.resolve().then((function(){return qi()})).then((function(){return Ct(e.file,{responseType:"arraybuffer",allowHosts:t.allowHosts,networkSubscribe:t.networkSubscribe})})).then((function(e){return Zt(e.body)})).then((function(e){var t=e.reduce((function(e,t){return e+t.length}),0),i=new Uint8Array(t),n=0;return e.forEach((function(e){i.set(e,n),n+=e.length})),i})).then((function(i){return Wi(i,e.textureBase,t.textureOptions,t.allowHosts,t.networkSubscribe)}))}},Xi=function(e){function i(t){void 0===t&&(t={});var i=e.call(this)||this;return i.empty=!1,i.name="model",i.loaded=!1,i.bvhs=Object.assign([],{loaded:!1}),i.bounding=new r.Box3,i.shownFloor=null,i.floorLength=0,i.networkSubscribe=t.networkSubscribe,i.allowHosts=t.allowHosts,i.renderOrder=-2,i}return t.__extends(i,e),Object.defineProperty(i.prototype,"shownfloor",{get:function(){return this.shownFloor},enumerable:!1,configurable:!0}),i.prototype.getEdges=function(e){var t;void 0===e&&(e=30/180*Math.PI);for(var i=Math.cos(e),n=[],o=0,s=this.children;o<s.length;o++){var a=s[o];if(a instanceof qe){for(var u={},c=["a","b","c"],l=Ei.mergeVertices(a.geometry),h=l.getAttribute("position").array,d=(null===(t=l.getIndex())||void 0===t?void 0:t.array)||[],p=[],A=[],f=0,M=h.length;f<M;f+=3)p.push(new r.Vector3(h[f],h[f+1],h[f+2]));for(f=0,M=d.length;f<M;f+=3){var g=d[f],y=d[f+1],m=d[f+2],v=(new r.Vector3).crossVectors(p[y].clone().sub(p[g]),p[m].clone().sub(p[g])).normalize();A.push({a:g,b:y,c:m,normal:v})}for(f=0,M=A.length;f<M;f++)for(var N=A[f],D=0;D<3;D++){var w=N[c[D]],T=N[c[(D+1)%3]],x=[Math.min(w,T),Math.max(w,T)];void 0===u[E=x[0]+"-"+x[1]]?u[E]={index1:x[0],index2:x[1],face1:f}:u[E].face2=f}for(var E in u){var j=u[E];if(void 0===j.face2||A[j.face1].normal.dot(A[j.face2].normal)<=i){var z=p[j.index1],I=p[j.index2];n.push(new r.Line3(z,I))}}l.dispose(),p.length=0,A.length=0}}return n},i.prototype.hasFloors=function(){return this.hasFloors_()},i.prototype.hasFloors_=function(){var e=[];return this.traverse((function(t){t instanceof qe&&(e[t.floorIndex]=!0)})),e.length},i.prototype.show=function(){for(var e,t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];var n=this.shownFloor,r=null,o=null!==(e=t[1])&&void 0!==e?e:.1,s=0!==t.length;this.shownFloor=r=s?t[0]:null,this.traverse((function(e){e instanceof qe&&e.material.forEach((function(t){null===r||r===e.floorIndex?t.opacity=1:t.opacity=o}))})),n!==this.shownFloor&&this.emit("shownFloorChange",this.shownFloor,this.floorLength),this.needsRender=!0},i.prototype.intersectRaycaster=function(e,t){var i=e.ray,n=i.origin,o=i.direction;if(Re(t))if(Re(this.shownFloor)){var s=this.floorLength;t=[];for(var a=0;a<s;a++)t.push(a)}else t=[this.shownFloor];var u=[],c=[];Array.isArray(t)?c.push.apply(c,t):c.push(t);for(var l=function(t){var i=h.bvhs&&h.bvhs[t];if(i){var s=new dt(n.x,n.y,n.z),a=new dt(o.x,o.y,o.z);(c=i.intersectRay(s,a,!0).map((function(e){var t=e.intersectionPoint,i=e.triangle,o=new r.Vector3(t.x,t.y,t.z);return{point:o,face:{normal:Ki(i).getNormal(new r.Vector3)},distance:n.distanceTo(o)}}))).length&&u.push.apply(u,c)}else{var c,l=[];h.traverse((function(e){e instanceof qe&&e.floorIndex===t&&l.push(e)})),(c=e.intersectObjects(l).map((function(e){var t=e.face?{normal:e.face.normal}:void 0;return{point:e.point,face:t,distance:e.distance}}))).length&&u.push.apply(u,c)}},h=this,d=0,p=c;d<p.length;d++){l(p[d])}return u.filter((function(t){var i=t.distance;return i<=e.far&&i>=e.near})).sort((function(e,t){return e.distance-t.distance}))},i.prototype.buildBVH=function(){var e,t=[];this.traverse((function(e){e instanceof qe&&(t[e.floorIndex]=t[e.floorIndex]||[],t[e.floorIndex].push(e.geometry))}));var i=t.map((function(e){var t=e.reduce((function(e,t){return e+(t.index?t.index.array.length:t.attributes.position.array.length)}),0),i=new Float32Array(3*t);return e.reduce((function(e,t){for(var n=t.index?t.index.array:null,r=t.attributes.position.array,o=n?n.length:r.length/3,s=0;s<o;s++){var a=3*(e+s),u=n?3*n[s]:3*s;i[a+0]=r[u+0],i[a+1]=r[u+1],i[a+2]=r[u+2]}return e+o}),0),new Mt(i,10)}));this.bvhs.length=0,(e=this.bvhs).push.apply(e,i),this.bvhs.loaded=!0,this.emit("bvhLoaded")},i.prototype.load=function(e,t){var i=this;if(void 0===t&&(t={}),!0===this.loaded)throw new Error("[MODEL LOAD ERROR]: model cannot load twice.");var n=function(e,t){void 0===t&&(t=[]);var i=/([0-9a-z\.\_\-]+)([\?\#].*)?$/i.exec(e);if(!i)return"";for(var n=0,r=String(i[1]).trim().split(".").slice(1).reverse();n<r.length;n++){var o=r[n],s=t.indexOf(o);if(s>=0)return t[s]}return""}(e.file,Object.keys(Zi)),o=Zi[n];if(!o)throw new Error("[MODEL LOAD ERROR]: file type("+n+") does not support.");return o(e,{textureOptions:t,allowHosts:this.allowHosts,networkSubscribe:this.networkSubscribe}).then((function(e){for(var t=[],n=0,o=e;n<o.length;n++){(c=o[n]).traverse((function(e){e instanceof qe&&(e.geometry.computeBoundingBox(),e.geometry.computeBoundingSphere(),t.push(e.geometry.boundingBox))})),i.add(c)}i.floorLength=i.hasFloors_(),i.bounding=function(e){for(var t=new r.Box3,i=0,n=e;i<n.length;i++){var o=n[i];t.union(o)}return t}(t);for(var s=i.bounding.getCenter(new r.Vector3),a=0,u=e;a<u.length;a++){var c;(c=u[a]).traverse((function(e){e instanceof qe&&e.material.forEach((function(e){e.uniforms.modelCenter.value=s}))}))}t.length=0,i.emit("geometryLoaded"),i.emit("materialLoaded"),i.loaded=!0,We.shared.add((function(){return i.emit("loaded")}),!0)})).catch((function(e){return i.emit("error",e),Promise.reject(e)}))},i.prototype.dispose=function(){for(this.off(),this.disposeGeometry(),this.disposeMaterial();this.children.length;)this.remove(this.children[0]);this.bvhs.length=0,this.bvhs.loaded=!1},i}(Ke);function Ji(e){switch(e.getError()){case e.INVALID_ENUM:return new Error("webgl error: INVALID_ENUM");case e.INVALID_VALUE:return new Error("webgl error: INVALID_VALUE");case e.INVALID_OPERATION:return new Error("webgl error: INVALID_OPERATION");case e.INVALID_FRAMEBUFFER_OPERATION:return new Error("webgl error: INVALID_FRAMEBUFFER_OPERATION");case e.OUT_OF_MEMORY:return new Error("webgl error: OUT_OF_MEMORY");case e.CONTEXT_LOST_WEBGL:return new Error("webgl error: CONTEXT_LOST_WEBGL");default:return null}}Object.assign(Xi.prototype,{on:vt.prototype.on,once:vt.prototype.once,off:vt.prototype.off,emit:vt.prototype.emit,hasListener:vt.prototype.hasListener});var $i=2*Math.PI;function en(e){return(e%$i+$i)%$i}var tn=Math.PI,nn=2*tn;function rn(e,t,i){if(e===t)return t;var n=t-e;return Math.abs(n)<=i?t:e+(n>0?1:-1)*i}var on=function(){function e(){this.name="",this.workCode="",this.expire=new Date,this.allowHosts=[],this.initial={mode:"Panorama",latitude:0,longitude:0,panoIndex:0,fov:80},this.observers=[],this.issuer="none",this.raw={work:null,option:{}}}return e.prototype.toJSON=function(){return this.raw.work},e}();function sn(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=[];e=e.map((function(e){return e.trim()})).filter((function(e){return e.length>0&&!/^\/+$/.test(e)}));for(var n=0;n<e.length;n++){var r=0===n,o=n===e.length-1,s=e[n];r||(s=s.replace(/^\/+/,"")),o||(s=s.replace(/\/+$/,"")),i.push(s)}return i.join("/")}function an(e){return e instanceof Error}function un(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var i,n,r;if(Array.isArray(e)){if((i=e.length)!=t.length)return!1;for(n=i;0!=n--;)if(!un(e[n],t[n]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if((i=(r=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(n=i;0!=n--;)if(!Object.prototype.hasOwnProperty.call(t,r[n]))return!1;for(n=i;0!=n--;){var o=r[n];if(!un(e[o],t[o]))return!1}return!0}return e!=e&&t!=t}function cn(e){return"number"==typeof e}function ln(e){return 0==(e&e-1)&&0!==e}function hn(e,t){void 0===t&&(t=!1);var i=typeof e;if("string"===i)return JSON.stringify(e);if(!0===e)return"true";if(!1===e)return"false";if(null===e)return"null";if(e instanceof Array){for(var n="[",r=e.length-1,o=0;o<r;o++)n+=hn(e[o],!1)+",";return r>-1&&(n+=hn(e[o],!1)),n+"]"}if(e instanceof Object){if("function"==typeof e.toJSON)return hn(e.toJSON(),t);var s=Object.keys(e).sort(),a=s.length;for(n="",o=0;o<a;){var u=s[o],c=hn(e[u],!0);void 0!==c&&(o&&""!==n&&(n+=","),n+=JSON.stringify(u)+":"+c),o++}return"{"+n+"}"}switch(i){case"function":case"undefined":return t?void 0:null;case"number":return 0;default:return isFinite(e)?e:null}}function dn(e){return String(hn(e,!1))}function pn(e){var t,i,n,r=JSON.parse(e),o="undefined"!=typeof location?location.hostname:"",s=Date.now();if("object"!=typeof r)return new Error("input is not an object");if(0===o.length||wt(o)||Et.filter((function(e){return Tt(e,o)})).length>0){var a=String(null!==(t=r.certificate)&&void 0!==t?t:"");if(a){var u=new ze;return u.readCertPEM(a),{issuer:u.getSubjectString()}}return{issuer:"none"}}var c=String(null!==(i=r.certificate)&&void 0!==i?i:"");if(!c)return new Error("certificate is not existed.");var l=new ze;l.readCertPEM(c);var h=String(null!==(n=r._signature)&&void 0!==n?n:"");if(!h)return new Error("signature is not existed.");if(!1===function(e,t,i){var n=new ze;if("string"==typeof i?n.readCertPEM(i):n.readCertHex(i.hex),!1===Le(n))return!1;var r=new K;return r.readCertPubKeyHex(n.hex,6),!!r.verify(e,C(t))}(dn(function(e,t){for(var i={},n=0,r=Object.keys(e);n<r.length;n++){var o=r[n];-1===t.indexOf(o)&&(i[o]=e[o])}return i}(r,["_signature"])),h,l))return new Error("signature verify failed.");var d=new Date("string"==typeof r.expire_at&&/^\d+$/.test(r.expire_at)?Number(r.expire_at):r.expire_at);return s<d.getTime()?0===(Array.isArray(r.allow_hosts)?r.allow_hosts:[]).filter((function(e){return Tt(e,o)})).length?function(e){return new Error("host("+JSON.stringify(e)+") is not allowed.")}(o):{issuer:l.getSubjectString()}:function(e){return new Error("date("+e.toString()+") expired.")}(d)}var An=new WeakMap;function fn(e,t,i){var n,o=JSON.stringify(t),s=JSON.stringify(e),a=pn(s);e=JSON.parse(s),t=JSON.parse(o);var u=new on;u.issuer=a instanceof Error?"none":a.issuer,u.raw={work:e,options:t};var c=null!==(n=e.base_url)&&void 0!==n?n:"";c&&"/"!==c[c.length-1]&&(c+="/");var l=function(e,n){var r,o=e;!0===t.jsonp&&(o=(o=e.replace(/([\?\#].*)?$/i,""))+"."+Ie(""+o).slice(0,7)+".jsonp");if(!0===t.shortPath){var s=o.replace(c,"").split("."),a=null!==(r=s.shift())&&void 0!==r?r:"",u=s.join(".");o=sn(c,Ie(a))+(u?"."+u:"")}var l=o.replace(c,"");return t.baseURL&&(o=sn(t.baseURL,l)),i&&i(e,o,l,n),o},h=function(t,i){var n,r,o,s,a,u,h=t;if(!Ri(t)){var d=null!==(u=null!==(s=null!==(r=null===(n=e.panorama)||void 0===n?void 0:n.pano_high_cube_base_url)&&void 0!==r?r:null===(o=e.panorama)||void 0===o?void 0:o.pano_cube_base_url)&&void 0!==s?s:null===(a=e.panorama)||void 0===a?void 0:a.base_url)&&void 0!==u?u:"";d&&(d=sn(d,String(i))),h=sn(d,h)}return Ri(h)||(h=sn(c,h)),l(h,"panorama")},d=function(e){var t=e;return Ri(t)||(t=sn(c,e)),l(t,"model")},p=function(e,t){void 0===t&&(t="");var i=e;return Ri(i)||(i=sn(t,i)),Ri(i)||(i=sn(c,i)),l(i,"texture")};if(u.workCode=String(e.work_code||e.code||e.vr_code||e.workCode),u.name=String(e.name),u.expire=new Date("string"==typeof e.expire_at&&/^\d+$/.test(e.expire_at)?Number(e.expire_at):e.expire_at),u.allowHosts=e.allow_hosts||[],an(a))return a;if(e.initial&&("Floorplan"!==e.initial.mode&&"Topview"!==e.initial.mode&&"Panorama"!==e.initial.mode&&"VRPanorama"!==e.initial.mode&&"Model"!==e.initial.mode&&"DepthPanorama"!==e.initial.mode||(u.initial.mode=e.initial.mode),cn(e.initial.latitude)&&(u.initial.latitude=e.initial.latitude),cn(e.initial.longitude)?u.initial.longitude=e.initial.longitude:cn(e.initial.heading)&&(u.initial.longitude=-(360*(e.initial.heading-.25)+90)/180*Math.PI),cn(e.initial.fov)&&(u.initial.fov=e.initial.fov),cn(e.initial.panoIndex)?u.initial.panoIndex=e.initial.panoIndex:cn(e.initial.pano_index)?u.initial.panoIndex=e.initial.pano_index:cn(e.initial.pano)&&(u.initial.panoIndex=e.initial.pano)),an(a))return a;if(e.model){var A={bvh:!0,async:!1,textureBase:"",textures:[]};"boolean"==typeof t.modelBvh?A.bvh=t.modelBvh:"boolean"==typeof e.model.bvh?A.bvh=e.model.bvh:"boolean"==typeof e.bvh&&(A.bvh=e.bvh),t.modelAsync,A.async=t.modelAsync,e.model.file?A.file=d(e.model.file):e.model.file_url&&(A.file=d(e.model.file_url)),e.model.textureBase?A.textureBase=e.model.textureBase:e.model.material_base_url&&(A.textureBase=e.model.material_base_url),Array.isArray(e.model.textures)?A.textures=e.model.textures.map((function(e){return p(e,A.textureBase)})):Array.isArray(e.model.material_textures)&&(A.textures=e.model.material_textures.map((function(e){return p(e,A.textureBase)}))),A.file&&(u.model=A)}if(an(a))return a;if(e.observers&&Array.isArray(e.observers)){var f=[];e.panorama&&(Array.isArray(e.panorama)?f=e.panorama:Array.isArray(e.panorama.list)?f=e.panorama.list:Array.isArray(e.panorama.info)&&(f=e.panorama.info));for(var M=0;M<e.observers.length;M++){var g={},y=e.observers[M];if(!y)break;var m=f[M]||{};y=Object.assign({},y,m,{active:!1!==y.active&&!1!==m.active}),g.panoIndex=M,g.active=!1!==y.active,g.loadable=!0===y.loadable,g.images={up:h(y.images?y.images.up:y.up,M),down:h(y.images?y.images.down:y.down,M),right:h(y.images?y.images.right:y.right,M),left:h(y.images?y.images.left:y.left,M),front:h(y.images?y.images.front:y.front,M),back:h(y.images?y.images.back:y.back,M)};var v=y.images?y.images.depth:y.depth;v&&(g.images.depth=h(v,M));var N=y.images?y.images.luminance:y.luminance;N&&(g.images.luminance={up:h(N.up,M),down:h(N.down,M),right:h(N.right,M),left:h(N.left,M),front:h(N.front,M),back:h(N.back,M)});var D=y.images?y.images.tiles:y.tiles;if(D){for(var w=[],T=function(e){var t=e.match(/\/cube_(\d+)\//);if(t){var i=Number(t[1]);if(ln(i))return i}return!1},x=function(e,t){return e.replace(/\/cube_(\d+)\//,(function(){return"/cube_"+t+"/"}))},E=0,j=D;E<j.length;E++){var z=j[E];if("number"==typeof z){var I=z,b=T(g.images.front);if(!1===b)continue;if((B=Math.max(b,512*Math.pow(2,I)))>2048){var O=x(g.images.up,B),S=x(g.images.down,B),L=x(g.images.right,B),k=x(g.images.left,B),C=x(g.images.front,B),P=x(g.images.back,B);w.push({level:I,size:B,up:O,down:S,right:L,left:k,front:C,back:P})}else{O=g.images.up,S=g.images.down,L=g.images.right,k=g.images.left,C=g.images.front,P=g.images.back;w.push({level:I,size:B,up:O,down:S,right:L,left:k,front:C,back:P})}}else{var B;if("number"!=typeof(I=z.level))continue;if("number"!=typeof(B=z.size))continue;O=h(z.up,M),S=h(z.down,M),L=h(z.right,M),k=h(z.left,M),C=h(z.front,M),P=h(z.back,M);w.push({level:I,size:B,up:O,down:S,right:L,left:k,front:C,back:P})}}w.sort((function(e,t){return e.level-t.level})),g.images.tiles=w}if(y.position instanceof r.Vector3)g.position=y.position.clone();else{if(!Array.isArray(y.position))break;g.position=(new r.Vector3).fromArray(y.position)}if(y.standingPosition instanceof r.Vector3)g.standingPosition=y.standingPosition.clone();else if(Array.isArray(y.standingPosition))g.standingPosition=(new r.Vector3).fromArray(y.standingPosition);else if(y.standing_position instanceof r.Vector3)g.standingPosition=y.standing_position.clone();else{if(!Array.isArray(y.standing_position))break;g.standingPosition=(new r.Vector3).fromArray(y.standing_position)}if(y.quaternion instanceof r.Quaternion)g.quaternion=y.quaternion.clone();else if(Array.isArray(y.quaternion))g.quaternion=(new r.Quaternion).fromArray(y.quaternion);else{if(!y.quaternion)break;var _=y.quaternion,U=_.x,R=_.y,Q=_.z,Y=_.w;g.quaternion=new r.Quaternion(U,R,Q,Y)}if(Array.isArray(y.accessibleNodes)?g.accessibleNodes=y.accessibleNodes.slice():Array.isArray(y.accessible_nodes)&&(g.accessibleNodes=y.accessible_nodes.slice()),Array.isArray(y.visibleNodes)?g.visibleNodes=y.visibleNodes.slice():Array.isArray(y.visible_nodes)&&(g.visibleNodes=y.visible_nodes.slice()),cn(y.floorIndex)?g.floorIndex=y.floorIndex:cn(y.floor_index)?g.floorIndex=y.floor_index:g.floorIndex=0,y.video){var F={};"string"==typeof y.video.source&&(F.source=y.video.source),y.video.matrix instanceof r.Matrix4?F.matrix=y.video.matrix.clone():Array.isArray(y.video.matrix)&&(F.matrix=(new r.Matrix4).fromArray(y.video.matrix)),y.video.size instanceof r.Vector2?F.size=y.video.size.clone():Array.isArray(y.video.size)&&(F.size=(new r.Vector2).fromArray(y.video.size)),F.source&&F.matrix&&F.size&&(g.video=F)}u.observers[M]=g}}if(an(a))return a;for(var V=0,H=u.observers;V<H.length;V++){if(!(g=H[V]).accessibleNodes){g.accessibleNodes=[];for(var G=0;G<u.observers.length;G++)u.observers[G]!==g&&g.accessibleNodes.push(G)}if(!g.visibleNodes){g.visibleNodes=[];for(G=0;G<u.observers.length;G++)u.observers[G]!==g&&g.visibleNodes.push(G)}}if(an(a))return a;var W=Nt(u);return An.set(W,{work:s,options:o}),W}function Mn(e,t,i){"string"==typeof e&&"{"===e.trim()[0]&&(e=JSON.parse(e));var n=An.get(e);if(n){if(t&&!un(JSON.parse(n.options),t))throw new Error("[PARSE FAILED]: work is parsed with different options.");return e}var r=fn(e,null!=t?t:{},i);if(an(r))throw new Error("[PARSE FAILED]: "+r.message);return r}function gn(e,t){e.mode=t.mode,e.panoIndex=t.panoIndex,e.longitude=t.longitude,e.latitude=t.latitude,e.fov=t.fov,e.offset.copy(t.offset)}function yn(e,t){return e.panoIndex===t.panoIndex&&e.mode===t.mode&&Math.abs(e.longitude-t.longitude)<.001&&Math.abs(e.latitude-t.latitude)<.001&&Math.abs(e.fov-t.fov)<.001&&e.offset.distanceTo(t.offset)<.001}var mn=function(e){return Number(e)};function vn(e,t,i){var n;void 0===t&&(t=mn),void 0===i&&(i=!1);for(var r,o=1/0,s=0,a=e;s<a.length;s++){var u=a[s],c=t(u);c<=o&&(r=(n=[u,c])[0],o=n[1])}return i?[r,o]:r}function Nn(e,t,i){return Math.max(t,Math.min(i,e))}function Dn(e){for(var t in e)return!1;return!0}function wn(e){return{longitude:e.longitude,latitude:e.latitude,fov:e.fov,offset:e.offset.clone()}}
|
|
368
368
|
/*! Hammer.JS - v2.0.7 - 2016-04-22
|
|
369
369
|
* http://hammerjs.github.io/
|
|
370
370
|
*
|