@realsee/five 5.0.0-alpha.71 → 5.0.0-alpha.72

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.
Files changed (108) hide show
  1. package/docs/.nojekyll +1 -0
  2. package/docs/assets/highlight.css +134 -0
  3. package/docs/assets/icons.css +1043 -0
  4. package/docs/assets/{images/icons.png → icons.png} +0 -0
  5. package/docs/assets/{images/icons@2x.png → icons@2x.png} +0 -0
  6. package/docs/assets/main.js +52 -0
  7. package/docs/assets/search.js +1 -0
  8. package/docs/assets/style.css +1388 -0
  9. package/docs/assets/{images/widgets.png → widgets.png} +0 -0
  10. package/docs/assets/{images/widgets@2x.png → widgets@2x.png} +0 -0
  11. package/docs/classes/five.AnimationFrameLoop.html +22 -522
  12. package/docs/classes/five.BVH.html +10 -488
  13. package/docs/classes/five.BVHNode.html +8 -468
  14. package/docs/classes/five.BVHVector3.html +1 -525
  15. package/docs/classes/five.Camera.html +11 -323
  16. package/docs/classes/five.Five.html +269 -2938
  17. package/docs/classes/five.InternalWebGLRenderer.html +1 -212
  18. package/docs/classes/five.Model.html +76 -1011
  19. package/docs/classes/five.NetworkSubscribe.html +50 -564
  20. package/docs/classes/five.PBMContainer.html +17 -428
  21. package/docs/classes/five.PBMGroup.html +19 -430
  22. package/docs/classes/five.PBMMaterial.html +15 -367
  23. package/docs/classes/five.PBMMesh.html +7 -254
  24. package/docs/classes/five.Scene.html +3 -263
  25. package/docs/classes/five.Subscribe.html +55 -599
  26. package/docs/classes/five.Work.html +1 -348
  27. package/docs/classes/gltf_loader.GLTFLoader.html +16 -411
  28. package/docs/classes/gltf_loader.GLTFObject.html +7 -287
  29. package/docs/classes/line.Line.html +1 -384
  30. package/docs/classes/line.LineGeometry.html +1 -530
  31. package/docs/classes/line.LineMaterial.html +1 -306
  32. package/docs/classes/line.LineSegmentsGeometry.html +1 -477
  33. package/docs/classes/line.THREE_Line2.html +1 -280
  34. package/docs/classes/line.THREE_LineSegments2.html +1 -282
  35. package/docs/classes/react.Store.html +28 -621
  36. package/docs/classes/server.BVH.html +10 -587
  37. package/docs/classes/server.BVHNode.html +8 -567
  38. package/docs/classes/server.BVHVector3.html +1 -624
  39. package/docs/classes/server.Model.html +62 -840
  40. package/docs/classes/server.PBMGroup.html +9 -384
  41. package/docs/classes/server.PBMMesh.html +7 -353
  42. package/docs/classes/sticker.Sticker.html +31 -470
  43. package/docs/index.html +166 -458
  44. package/docs/interfaces/five.AddableObject.html +1 -234
  45. package/docs/interfaces/five.AnimationFrame.html +1 -243
  46. package/docs/interfaces/five.BVHIntersect.html +1 -204
  47. package/docs/interfaces/five.CameraPose.html +1 -232
  48. package/docs/interfaces/five.DepthPanoramaControllerCustomInitArgs.html +28 -438
  49. package/docs/interfaces/five.EventCallback.html +370 -2644
  50. package/docs/interfaces/five.FiveInitArgs.html +93 -723
  51. package/docs/interfaces/five.FloorplanControllerCustomInitArgs.html +15 -295
  52. package/docs/interfaces/five.ImageOptions.html +16 -277
  53. package/docs/interfaces/five.ImageURLOptions.html +1 -260
  54. package/docs/interfaces/five.IntersectMeshInterface.html +1 -188
  55. package/docs/interfaces/five.Intersection.html +7 -227
  56. package/docs/interfaces/five.ModelControllerCustomInitArgs.html +20 -366
  57. package/docs/interfaces/five.ModelEventCallback.html +22 -367
  58. package/docs/interfaces/five.MovePanoOptions.html +39 -456
  59. package/docs/interfaces/five.PBMPanoPicture.html +7 -219
  60. package/docs/interfaces/five.PBMParameters.html +15 -303
  61. package/docs/interfaces/five.PanoCircleMeshInterface.html +5 -426
  62. package/docs/interfaces/five.PanoramaControllerCustomInitArgs.html +28 -452
  63. package/docs/interfaces/five.PanoramaLikeControllerCustomInitArgs.html +20 -365
  64. package/docs/interfaces/five.Pose.html +35 -270
  65. package/docs/interfaces/five.Scissor.html +14 -252
  66. package/docs/interfaces/five.State.html +16 -297
  67. package/docs/interfaces/five.SubscribeMixinType.emit.html +1 -180
  68. package/docs/interfaces/five.SubscribeMixinType.hasListener.html +1 -171
  69. package/docs/interfaces/five.SubscribeMixinType.off.html +1 -198
  70. package/docs/interfaces/five.SubscribeMixinType.on.html +1 -213
  71. package/docs/interfaces/five.SubscribeMixinType.once.html +1 -210
  72. package/docs/interfaces/five.TextureOptions.html +18 -296
  73. package/docs/interfaces/five.TopviewControllerCustomInitArgs.html +7 -226
  74. package/docs/interfaces/five.VRPanoramaControllerCustomInitArgs.html +27 -439
  75. package/docs/interfaces/five.WorkCubeImage.html +1 -251
  76. package/docs/interfaces/five.WorkImage.html +3 -306
  77. package/docs/interfaces/five.WorkInitial.html +13 -273
  78. package/docs/interfaces/five.WorkModel.html +3 -239
  79. package/docs/interfaces/five.WorkObserver.html +3 -323
  80. package/docs/interfaces/five.WorkTile.html +1 -274
  81. package/docs/interfaces/five.WorkVideo.html +3 -211
  82. package/docs/interfaces/gltf_loader.GLTF.html +7 -304
  83. package/docs/interfaces/react.FiveActionReactCallbacks.html +61 -585
  84. package/docs/interfaces/react.FiveInjectionTypes.html +154 -1645
  85. package/docs/interfaces/react.PropTypeOfFiveFeatures.html +1 -286
  86. package/docs/interfaces/server.BVHIntersect.html +1 -303
  87. package/docs/interfaces/server.Intersection.html +7 -326
  88. package/docs/interfaces/server.ModelEventCallback.html +18 -427
  89. package/docs/interfaces/sticker.IntersectionLike.html +8 -223
  90. package/docs/modules/five.SubscribeMixinType.html +1 -143
  91. package/docs/modules/five.html +442 -3044
  92. package/docs/modules/gltf_loader.html +1 -155
  93. package/docs/modules/line.html +1 -210
  94. package/docs/modules/react.html +130 -1607
  95. package/docs/modules/server.html +18 -560
  96. package/docs/modules/sticker.html +1 -151
  97. package/docs/modules.html +1 -136
  98. package/five/index.js +5 -5
  99. package/gltf-loader/index.js +2 -2
  100. package/line/index.js +2 -2
  101. package/package.json +1 -1
  102. package/react/index.js +2 -2
  103. package/server/index.js +3 -3
  104. package/sticker/index.js +2 -2
  105. package/umd/five.js +1 -1
  106. package/docs/assets/css/main.css +0 -2660
  107. package/docs/assets/js/main.js +0 -248
  108. package/docs/assets/js/search.js +0 -1
package/server/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * @realsee/five
3
3
  *
4
- * Generated: 2021-12-14
5
- * Version: 5.0.0-alpha.71
4
+ * Generated: 2021-12-16
5
+ * Version: 5.0.0-alpha.72
6
6
  *
7
7
  * Terms:
8
8
  * Realsee SDK License Agreement
@@ -364,4 +364,4 @@ var H="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";functio
364
364
  /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ */
365
365
  function $(t,e){return new y(t,e)}function J(t,e,r){for(var n="",i=0;n.length<e;)n+=r(String.fromCharCode.apply(String,t.concat([(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i]))),i+=1;return n}function tt(){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 et(t,e,r){for(var n="",i=0;n.length<e;)n+=r(t+String.fromCharCode.apply(String,[(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i])),i+=1;return n}function rt(t){for(var e="",r=0;r<t.length;r++){var n=t[r].toString(16);1==n.length&&(n="0"+n),e+=n}return e}function nt(t){return rt(function(t){for(var e=new Array,r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}(t))}function it(t){return t.length%4==2?t+="==":t.length%4==3&&(t+="="),t=(t=t.replace(/-/g,"+")).replace(/_/g,"/")}function st(t){return t.length%2==1&&(t="0"+t),function(t){return(t=(t=t.replace(/\=/g,"")).replace(/\+/g,"-")).replace(/\//g,"_")}(M(t))}function ot(t){return K(it(t))}function at(t){return function(t){return t.replace(/%/g,"")}(function(t){for(var e=encodeURIComponent(t),r="",n=0;n<e.length;n++)"%"==e[n]?(r+=e.substr(n,3),n+=2):r=r+"%"+nt(e[n]);return r}(t))}function ut(t){return decodeURIComponent(function(t){return t.replace(/(..)/g,"%$1")}(t))}function ht(t){for(var e="",r=0;r<t.length-1;r+=2)e+=String.fromCharCode(parseInt(t.substr(r,2),16));return e}function ct(t){for(var e="",r=0;r<t.length;r++)e+=("0"+t.charCodeAt(r).toString(16)).slice(-2);return e}function lt(t){var e=function(t){return M(t)}(t).replace(/(.{64})/g,"$1\r\n");return e=e.replace(/\r\n$/,"")}function ft(t,e){return"-----BEGIN "+e+"-----\r\n"+lt(t)+"\r\n-----END "+e+"-----\r\n"}function dt(t,e){if(-1==t.indexOf("-----BEGIN "))throw"can't find PEM header: "+e;return function(t){return K(t.replace(/[^0-9A-Za-z\/+=]*/g,""))}(t=void 0!==e?(t=t.replace(new RegExp("^[^]*-----BEGIN "+e+"-----"),"")).replace(new RegExp("-----END "+e+"-----[^]*$"),""):(t=t.replace(/^[^]*-----BEGIN [^-]+-----/,"")).replace(/-----END [^-]+-----[^]*$/,""))}function pt(t){var e="malformed hex value";if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8!=t.length)return 32==t.length?function(t){if(!t.match(/^[0-9A-Fa-f]{32}$/))throw"malformed IPv6 address octet";for(var e=(t=t.toLowerCase()).match(/.{1,4}/g),r=0;r<8;r++)e[r]=e[r].replace(/^0+/,""),""==e[r]&&(e[r]="0");var n=(t=":"+e.join(":")+":").match(/:(0:){2,}/g);if(null===n)return t.slice(1,-1);var i="";for(r=0;r<n.length;r++)n[r].length>i.length&&(i=n[r]);return(t=t.replace(i,"::")).slice(1,-1)}(t):t;try{return parseInt(t.substr(0,2),16)+"."+parseInt(t.substr(2,2),16)+"."+parseInt(t.substr(4,2),16)+"."+parseInt(t.substr(6,2),16)}catch(t){throw e}}function gt(t){return t.match(/.{4}/g).map((function(t){var e=parseInt(t.substr(0,2),16),r=parseInt(t.substr(2),16);if(0==e&r<128)return String.fromCharCode(r);if(e<8){var n=128|63&r;return ut((192|(7&e)<<3|(192&r)>>6).toString(16)+n.toString(16))}n=128|(15&e)<<2|(192&r)>>6;var i=128|63&r;return ut((224|(240&e)>>4).toString(16)+n.toString(16)+i.toString(16))})).join("")}function yt(t){return!(t.length%2!=0||!t.match(/^[0-9a-f]+$/)&&!t.match(/^[0-9A-F]+$/))}function mt(t){return t.length%2==1?"0"+t:t.substr(0,1)>"7"?"00"+t:t}X.prototype.nextBytes=function(t){var e;for(e=0;e<t.length;++e)t[e]=W()},tt.prototype.doPublic=function(t){return t.modPowInt(this.e,this.n)},tt.prototype.setPublic=function(t,e){if(this.isPublic=!0,this.isPrivate=!1,"string"!=typeof t)this.n=t,this.e=e;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA public key";this.n=$(t,16),this.e=parseInt(e,16)}},tt.prototype.encrypt=function(t){var e=function(t,e){if(e<t.length+11)throw"Message too long for RSA";for(var r=new Array,n=t.length-1;n>=0&&e>0;){var i=t.charCodeAt(n--);i<128?r[--e]=i:i>127&&i<2048?(r[--e]=63&i|128,r[--e]=i>>6|192):(r[--e]=63&i|128,r[--e]=i>>6&63|128,r[--e]=i>>12|224)}r[--e]=0;for(var s=new X,o=new Array;e>2;){for(o[0]=0;0==o[0];)s.nextBytes(o);r[--e]=o[0]}return r[--e]=2,r[--e]=0,new y(r)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var r=this.doPublic(e);if(null==r)return null;var n=r.toString(16);return 0==(1&n.length)?n:"0"+n},tt.prototype.encryptOAEP=function(t,e,r){var n=function(t,e,r,n){var i=d.crypto.MessageDigest,s=d.crypto.Util,o=null;if(r||(r="sha1"),"string"==typeof r&&(o=i.getCanonicalAlgName(r),n=i.getHashLength(o),r=function(t){return ht(s.hashHex(ct(t),o))}),t.length+2*n+2>e)throw"Message too long for RSA";var a,u="";for(a=0;a<e-t.length-2*n-2;a+=1)u+="\0";var h=r("")+u+""+t,c=new Array(n);(new X).nextBytes(c);var l=J(c,h.length,r),f=[];for(a=0;a<h.length;a+=1)f[a]=h.charCodeAt(a)^l.charCodeAt(a);var p=J(f,c.length,r),g=[0];for(a=0;a<c.length;a+=1)g[a+1]=c[a]^p.charCodeAt(a);return new y(g.concat(f))}(t,this.n.bitLength()+7>>3,e,r);if(null==n)return null;var i=this.doPublic(n);if(null==i)return null;var s=i.toString(16);return 0==(1&s.length)?s:"0"+s},tt.prototype.type="RSA",tt.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),r=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(r)<0;)e=e.add(this.p);return e.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)},tt.prototype.setPrivate=function(t,e,r){if(this.isPrivate=!0,"string"!=typeof t)this.n=t,this.e=e,this.d=r;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key";this.n=$(t,16),this.e=parseInt(e,16),this.d=$(r,16)}},tt.prototype.setPrivateEx=function(t,e,r,n,i,s,o,a){if(this.isPrivate=!0,this.isPublic=!1,null==t)throw"RSASetPrivateEx N == null";if(null==e)throw"RSASetPrivateEx E == null";if(0==t.length)throw"RSASetPrivateEx N.length == 0";if(0==e.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=$(t,16),this.e=parseInt(e,16),this.d=$(r,16),this.p=$(n,16),this.q=$(i,16),this.dmp1=$(s,16),this.dmq1=$(o,16),this.coeff=$(a,16)},tt.prototype.generate=function(t,e){var r=new X,n=t>>1;this.e=parseInt(e,16);for(var i=new y(e,16);;){for(;this.p=new y(t-n,1,r),0!=this.p.subtract(y.ONE).gcd(i).compareTo(y.ONE)||!this.p.isProbablePrime(10););for(;this.q=new y(n,1,r),0!=this.q.subtract(y.ONE).gcd(i).compareTo(y.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(y.ONE),a=this.q.subtract(y.ONE),u=o.multiply(a);if(0==u.gcd(i).compareTo(y.ONE)&&(this.n=this.p.multiply(this.q),this.n.bitLength()==t)){this.d=i.modInverse(u),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=!0},tt.prototype.decrypt=function(t){if(t.length!=Math.ceil(this.n.bitLength()/4))throw new Error("wrong ctext length");var e=$(t,16),r=this.doPrivate(e);return null==r?null:
366
366
  /*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ */
367
- function(t,e){for(var r=t.toByteArray(),n=0;n<r.length&&0==r[n];)++n;if(r.length-n!=e-1||2!=r[n])return null;for(++n;0!=r[n];)if(++n>=r.length)return null;for(var i="";++n<r.length;){var s=255&r[n];s<128?i+=String.fromCharCode(s):s>191&&s<224?(i+=String.fromCharCode((31&s)<<6|63&r[n+1]),++n):(i+=String.fromCharCode((15&s)<<12|(63&r[n+1])<<6|63&r[n+2]),n+=2)}return i}(r,this.n.bitLength()+7>>3)},tt.prototype.decryptOAEP=function(t,e,r){if(t.length!=Math.ceil(this.n.bitLength()/4))throw new Error("wrong ctext length");var n=$(t,16),i=this.doPrivate(n);return null==i?null:function(t,e,r,n){var i=d.crypto.MessageDigest,s=d.crypto.Util,o=null;for(r||(r="sha1"),"string"==typeof r&&(o=i.getCanonicalAlgName(r),n=i.getHashLength(o),r=function(t){return ht(s.hashHex(ct(t),o))}),t=t.toByteArray(),a=0;a<t.length;a+=1)t[a]&=255;for(;t.length<e;)t.unshift(0);if((t=String.fromCharCode.apply(String,t)).length<2*n+2)throw"Cipher too short";var a,u=t.substr(1,n),h=t.substr(n+1),c=et(h,n,r),l=[];for(a=0;a<u.length;a+=1)l[a]=u.charCodeAt(a)^c.charCodeAt(a);var f=et(String.fromCharCode.apply(String,l),t.length-n,r),p=[];for(a=0;a<h.length;a+=1)p[a]=h.charCodeAt(a)^f.charCodeAt(a);if((p=String.fromCharCode.apply(String,p)).substr(0,n)!==r(""))throw"Hash mismatch";var g=(p=p.substr(n)).indexOf("");if((-1!=g?p.substr(0,g).lastIndexOf("\0"):-1)+1!=g)throw"Malformed data";return p.substr(g+1)}(i,this.n.bitLength()+7>>3,e,r)},void 0!==d.lang&&d.lang||(d.lang={}),d.lang.String=function(){},d.lang.String.isInteger=function(t){return!!t.match(/^[0-9]+$/)||!!t.match(/^-[0-9]+$/)},d.lang.String.isHex=function(t){return yt(t)},d.lang.String.isBase64=function(t){return!(!(t=t.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||t.length%4!=0)},d.lang.String.isBase64URL=function(t){return!t.match(/[+/=]/)&&(t=it(t),d.lang.String.isBase64(t))},d.lang.String.isIntegerArray=function(t){return!!(t=t.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)},d.lang.String.isPrintable=function(t){return null!==t.match(/^[0-9A-Za-z '()+,-./:=?]*$/)},d.lang.String.isIA5=function(t){return null!==t.match(/^[\x20-\x21\x23-\x7f]*$/)},d.lang.String.isMail=function(t){return null!==t.match(/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]{1,}\.[A-Za-z0-9]{1,}$/)};var vt=function(t,e,r){return null==r&&(r="0"),t.length>=e?t:new Array(e-t.length+1).join(r)+t};function xt(t,e){var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e)}void 0!==d.crypto&&d.crypto||(d.crypto={}),d.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:g.algo.MD5,sha1:g.algo.SHA1,sha224:g.algo.SHA224,sha256:g.algo.SHA256,sha384:g.algo.SHA384,sha512:g.algo.SHA512,ripemd160:g.algo.RIPEMD160},this.getDigestInfoHex=function(t,e){if(void 0===this.DIGESTINFOHEAD[e])throw"alg not supported in Util.DIGESTINFOHEAD: "+e;return this.DIGESTINFOHEAD[e]+t},this.getPaddedDigestInfoHex=function(t,e,r){var n=this.getDigestInfoHex(t,e),i=r/4;if(n.length+22>i)throw"key is too short for SigAlg: keylen="+r+","+e;for(var s="0001",o="00"+n,a="",u=i-s.length-o.length,h=0;h<u;h+=2)a+="ff";return s+a+o},this.hashString=function(t,e){return new d.crypto.MessageDigest({alg:e}).digestString(t)},this.hashHex=function(t,e){return new d.crypto.MessageDigest({alg:e}).digestHex(t)},this.sha1=function(t){return this.hashString(t,"sha1")},this.sha256=function(t){return this.hashString(t,"sha256")},this.sha256Hex=function(t){return this.hashHex(t,"sha256")},this.sha512=function(t){return this.hashString(t,"sha512")},this.sha512Hex=function(t){return this.hashHex(t,"sha512")},this.isKey=function(t){return t instanceof tt||t instanceof d.crypto.DSA||t instanceof d.crypto.ECDSA}},d.crypto.Util.md5=function(t){return new d.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(t)},d.crypto.Util.ripemd160=function(t){return new d.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(t)},d.crypto.Util.SECURERANDOMGEN=new X,d.crypto.Util.getRandomHexOfNbytes=function(t){var e=new Array(t);return d.crypto.Util.SECURERANDOMGEN.nextBytes(e),rt(e)},d.crypto.Util.getRandomBigIntegerOfNbytes=function(t){return new y(d.crypto.Util.getRandomHexOfNbytes(t),16)},d.crypto.Util.getRandomHexOfNbits=function(t){var e=t%8,r=new Array((t-e)/8+1);return d.crypto.Util.SECURERANDOMGEN.nextBytes(r),r[0]=(255<<e&255^255)&r[0],rt(r)},d.crypto.Util.getRandomBigIntegerOfNbits=function(t){return new y(d.crypto.Util.getRandomHexOfNbits(t),16)},d.crypto.Util.getRandomBigIntegerZeroToMax=function(t){for(var e=t.bitLength();;){var r=d.crypto.Util.getRandomBigIntegerOfNbits(e);if(-1!=t.compareTo(r))return r}},d.crypto.Util.getRandomBigIntegerMinToMax=function(t,e){var r=t.compareTo(e);if(1==r)throw"biMin is greater than biMax";if(0==r)return t;var n=e.subtract(t);return d.crypto.Util.getRandomBigIntegerZeroToMax(n).add(t)},d.crypto.MessageDigest=function(t){this.setAlgAndProvider=function(t,e){if(null!==(t=d.crypto.MessageDigest.getCanonicalAlgName(t))&&void 0===e&&(e=d.crypto.Util.DEFAULTPROVIDER[t]),-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(t)&&"cryptojs"==e){try{this.md=d.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[t].create()}catch(e){throw"setAlgAndProvider hash alg set fail alg="+t+"/"+e}this.updateString=function(t){this.md.update(t)},this.updateHex=function(t){var e=g.enc.Hex.parse(t);this.md.update(e)},this.digest=function(){return this.md.finalize().toString(g.enc.Hex)},this.digestString=function(t){return this.updateString(t),this.digest()},this.digestHex=function(t){return this.updateHex(t),this.digest()}}if(-1!=":sha256:".indexOf(t)&&"sjcl"==e){try{this.md=new sjcl.hash.sha256}catch(e){throw"setAlgAndProvider hash alg set fail alg="+t+"/"+e}this.updateString=function(t){this.md.update(t)},this.updateHex=function(t){var e=sjcl.codec.hex.toBits(t);this.md.update(e)},this.digest=function(){var t=this.md.finalize();return sjcl.codec.hex.fromBits(t)},this.digestString=function(t){return this.updateString(t),this.digest()},this.digestHex=function(t){return this.updateHex(t),this.digest()}}},this.updateString=function(t){throw"updateString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.updateHex=function(t){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(t){throw"digestString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestHex=function(t){throw"digestHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},void 0!==t&&void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov&&(this.provName=d.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},d.crypto.MessageDigest.getCanonicalAlgName=function(t){return"string"==typeof t&&(t=(t=t.toLowerCase()).replace(/-/,"")),t},d.crypto.MessageDigest.getHashLength=function(t){var e=d.crypto.MessageDigest,r=e.getCanonicalAlgName(t);if(void 0===e.HASHLENGTH[r])throw"not supported algorithm: "+t;return e.HASHLENGTH[r]},d.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},d.crypto.Mac=function(t){this.setAlgAndProvider=function(t,e){if(null==(t=t.toLowerCase())&&(t="hmacsha1"),"hmac"!=(t=t.toLowerCase()).substr(0,4))throw"setAlgAndProvider unsupported HMAC alg: "+t;void 0===e&&(e=d.crypto.Util.DEFAULTPROVIDER[t]),this.algProv=t+"/"+e;var r=t.substr(4);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(r)&&"cryptojs"==e){try{var n=d.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[r];this.mac=g.algo.HMAC.create(n,this.pass)}catch(t){throw"setAlgAndProvider hash alg set fail hashAlg="+r+"/"+t}this.updateString=function(t){this.mac.update(t)},this.updateHex=function(t){var e=g.enc.Hex.parse(t);this.mac.update(e)},this.doFinal=function(){return this.mac.finalize().toString(g.enc.Hex)},this.doFinalString=function(t){return this.updateString(t),this.doFinal()},this.doFinalHex=function(t){return this.updateHex(t),this.doFinal()}}},this.updateString=function(t){throw"updateString(str) not supported for this alg/prov: "+this.algProv},this.updateHex=function(t){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(t){throw"digestString(str) not supported for this alg/prov: "+this.algProv},this.doFinalHex=function(t){throw"digestHex(hex) not supported for this alg/prov: "+this.algProv},this.setPassword=function(t){if("string"==typeof t){var e=t;return t.length%2!=1&&t.match(/^[0-9A-Fa-f]+$/)||(e=ct(t)),void(this.pass=g.enc.Hex.parse(e))}if("object"!=typeof t)throw"KJUR.crypto.Mac unsupported password type: "+t;e=null;if(void 0!==t.hex){if(t.hex.length%2!=0||!t.hex.match(/^[0-9A-Fa-f]+$/))throw"Mac: wrong hex password: "+t.hex;e=t.hex}if(void 0!==t.utf8&&(e=at(t.utf8)),void 0!==t.rstr&&(e=ct(t.rstr)),void 0!==t.b64&&(e=K(t.b64)),void 0!==t.b64u&&(e=ot(t.b64u)),null==e)throw"KJUR.crypto.Mac unsupported password type: "+t;this.pass=g.enc.Hex.parse(e)},void 0!==t&&(void 0!==t.pass&&this.setPassword(t.pass),void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov&&(this.provName=d.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))},d.crypto.Signature=function(t){var e=null;if(this._setAlgNames=function(){var t=this.algName.match(/^(.+)with(.+)$/);t&&(this.mdAlgName=t[1].toLowerCase(),this.pubkeyAlgName=t[2].toLowerCase(),"rsaandmgf1"==this.pubkeyAlgName&&"sha"==this.mdAlgName&&(this.mdAlgName="sha1"))},this._zeroPaddingOfSignature=function(t,e){for(var r="",n=e/4-t.length,i=0;i<n;i++)r+="0";return r+t},this.setAlgAndProvider=function(t,e){if(this._setAlgNames(),"cryptojs/jsrsa"!=e)throw new Error("provider not supported: "+e);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(this.mdAlgName)){try{this.md=new d.crypto.MessageDigest({alg:this.mdAlgName})}catch(t){throw new Error("setAlgAndProvider hash alg set fail alg="+this.mdAlgName+"/"+t)}this.init=function(t,e){var r=null;try{r=void 0===e?Ot.getKey(t):Ot.getKey(t,e)}catch(t){throw"init failed:"+t}if(!0===r.isPrivate)this.prvKey=r,this.state="SIGN";else{if(!0!==r.isPublic)throw"init failed.:"+r;this.pubKey=r,this.state="VERIFY"}},this.updateString=function(t){this.md.updateString(t)},this.updateHex=function(t){this.md.updateHex(t)},this.sign=function(){if(this.sHashHex=this.md.digest(),void 0===this.prvKey&&void 0!==this.ecprvhex&&void 0!==this.eccurvename&&void 0!==d.crypto.ECDSA&&(this.prvKey=new d.crypto.ECDSA({curve:this.eccurvename,prv:this.ecprvhex})),this.prvKey instanceof tt&&"rsaandmgf1"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHashPSS(this.sHashHex,this.mdAlgName,this.pssSaltLen);else if(this.prvKey instanceof tt&&"rsa"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex,this.mdAlgName);else if(this.prvKey instanceof d.crypto.ECDSA)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex);else{if(!(this.prvKey instanceof d.crypto.DSA))throw"Signature: unsupported private key alg: "+this.pubkeyAlgName;this.hSign=this.prvKey.signWithMessageHash(this.sHashHex)}return this.hSign},this.signString=function(t){return this.updateString(t),this.sign()},this.signHex=function(t){return this.updateHex(t),this.sign()},this.verify=function(t){if(this.sHashHex=this.md.digest(),void 0===this.pubKey&&void 0!==this.ecpubhex&&void 0!==this.eccurvename&&void 0!==d.crypto.ECDSA&&(this.pubKey=new d.crypto.ECDSA({curve:this.eccurvename,pub:this.ecpubhex})),this.pubKey instanceof tt&&"rsaandmgf1"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHashPSS(this.sHashHex,t,this.mdAlgName,this.pssSaltLen);if(this.pubKey instanceof tt&&"rsa"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==d.crypto.ECDSA&&this.pubKey instanceof d.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==d.crypto.DSA&&this.pubKey instanceof d.crypto.DSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);throw"Signature: unsupported public key alg: "+this.pubkeyAlgName}}},this.init=function(t,e){throw"init(key, pass) not supported for this alg:prov="+this.algProvName},this.updateString=function(t){throw"updateString(str) not supported for this alg:prov="+this.algProvName},this.updateHex=function(t){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(t){throw"digestString(str) not supported for this alg:prov="+this.algProvName},this.signHex=function(t){throw"digestHex(hex) not supported for this alg:prov="+this.algProvName},this.verify=function(t){throw"verify(hSigVal) not supported for this alg:prov="+this.algProvName},this.initParams=t,void 0!==t&&(void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov?this.provName=d.crypto.Util.DEFAULTPROVIDER[this.algName]:this.provName=t.prov,this.algProvName=this.algName+":"+this.provName,this.setAlgAndProvider(this.algName,this.provName),this._setAlgNames()),void 0!==t.psssaltlen&&(this.pssSaltLen=t.psssaltlen),void 0!==t.prvkeypem)){if(void 0!==t.prvkeypas)throw"both prvkeypem and prvkeypas parameters not supported";try{e=Ot.getKey(t.prvkeypem);this.init(e)}catch(t){throw"fatal error to load pem private key: "+t}}},d.crypto.Cipher=function(t){},d.crypto.Cipher.encrypt=function(t,e,r){if(e instanceof tt&&e.isPublic){var n=d.crypto.Cipher.getAlgByKeyAndName(e,r);if("RSA"===n)return e.encrypt(t);if("RSAOAEP"===n)return e.encryptOAEP(t,"sha1");var i=n.match(/^RSAOAEP(\d+)$/);if(null!==i)return e.encryptOAEP(t,"sha"+i[1]);throw"Cipher.encrypt: unsupported algorithm for RSAKey: "+r}throw"Cipher.encrypt: unsupported key or algorithm"},d.crypto.Cipher.decrypt=function(t,e,r){if(e instanceof tt&&e.isPrivate){var n=d.crypto.Cipher.getAlgByKeyAndName(e,r);if("RSA"===n)return e.decrypt(t);if("RSAOAEP"===n)return e.decryptOAEP(t,"sha1");var i=n.match(/^RSAOAEP(\d+)$/);if(null!==i)return e.decryptOAEP(t,"sha"+i[1]);throw"Cipher.decrypt: unsupported algorithm for RSAKey: "+r}throw"Cipher.decrypt: unsupported key or algorithm"},d.crypto.Cipher.getAlgByKeyAndName=function(t,e){if(t instanceof tt){if(-1!=":RSA:RSAOAEP:RSAOAEP224:RSAOAEP256:RSAOAEP384:RSAOAEP512:".indexOf(e))return e;if(null==e)return"RSA";throw"getAlgByKeyAndName: not supported algorithm name for RSAKey: "+e}throw"getAlgByKeyAndName: not supported algorithm name: "+e},d.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 bt,wt,St,Et,At,Pt,Dt,Nt,Ot=(bt=function(t,e,r){return wt(g.AES,t,e,r)},wt=function(t,e,r,n){var i=g.enc.Hex.parse(e),s=g.enc.Hex.parse(r),o=g.enc.Hex.parse(n),a={};a.key=s,a.iv=o,a.ciphertext=i;var u=t.decrypt(a,s,{iv:o});return g.enc.Hex.stringify(u)},St=function(t,e,r){return Et(g.AES,t,e,r)},Et=function(t,e,r,n){var i=g.enc.Hex.parse(e),s=g.enc.Hex.parse(r),o=g.enc.Hex.parse(n),a=t.encrypt(i,s,{iv:o}),u=g.enc.Hex.parse(a.toString());return g.enc.Base64.stringify(u)},At={"AES-256-CBC":{proc:bt,eproc:St,keylen:32,ivlen:16},"AES-192-CBC":{proc:bt,eproc:St,keylen:24,ivlen:16},"AES-128-CBC":{proc:bt,eproc:St,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,e,r){return wt(g.TripleDES,t,e,r)},eproc:function(t,e,r){return Et(g.TripleDES,t,e,r)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,e,r){return wt(g.DES,t,e,r)},eproc:function(t,e,r){return Et(g.DES,t,e,r)},keylen:8,ivlen:8}},Pt=function(t){var e={},r=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));r&&(e.cipher=r[1],e.ivsalt=r[2]);var n=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(e.type=n[1]);var i=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(i=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(i=t.indexOf("\n\n"),s=1);var o=t.indexOf("-----END");if(-1!=i&&-1!=o){var a=t.substring(i+2*s,o-s);a=a.replace(/\s+/g,""),e.data=a}return e},Dt=function(t,e,r){for(var n=r.substring(0,16),i=g.enc.Hex.parse(n),s=g.enc.Utf8.parse(e),o=At[t].keylen+At[t].ivlen,a="",u=null;;){var h=g.algo.MD5.create();if(null!=u&&h.update(u),h.update(s),h.update(i),u=h.finalize(),(a+=g.enc.Hex.stringify(u)).length>=2*o)break}var c={};return c.keyhex=a.substr(0,2*At[t].keylen),c.ivhex=a.substr(2*At[t].keylen,2*At[t].ivlen),c},Nt=function(t,e,r,n){var i=g.enc.Base64.parse(t),s=g.enc.Hex.stringify(i);return(0,At[e].proc)(s,r,n)},{version:"1.0.0",parsePKCS5PEM:function(t){return Pt(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,r){return Dt(t,e,r)},decryptKeyB64:function(t,e,r,n){return Nt(t,e,r,n)},getDecryptedKeyHex:function(t,e){var r=Pt(t);r.type;var n=r.cipher,i=r.ivsalt,s=r.data,o=Dt(n,e,i).keyhex;return Nt(s,n,o,i)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,r,n,i){var s="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===At[n])throw"KEYUTIL unsupported algorithm: "+n;void 0!==i&&null!=i||(i=function(t){var e=g.lib.WordArray.random(t);return g.enc.Hex.stringify(e)}(At[n].ivlen).toUpperCase());var o=function(t,e,r,n){return(0,At[e].eproc)(t,r,n)}(e,n,Dt(n,r,i).keyhex,i);return s="-----BEGIN "+t+" PRIVATE KEY-----\r\n",s+="Proc-Type: 4,ENCRYPTED\r\n",s+="DEK-Info: "+n+","+i+"\r\n",s+="\r\n",s+=o.replace(/(.{64})/g,"$1\r\n"),s+="\r\n-----END "+t+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(t){var e=Tt,r=e.getChildIdx,n=e.getV,i={},s=r(t,0);if(2!=s.length)throw"malformed format: SEQUENCE(0).items != 2: "+s.length;i.ciphertext=n(t,s[1]);var o=r(t,s[0]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+o.length;if("2a864886f70d01050d"!=n(t,o[0]))throw"this only supports pkcs5PBES2";var a=r(t,o[1]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+a.length;var u=r(t,a[1]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+u.length;if("2a864886f70d0307"!=n(t,u[0]))throw"this only supports TripleDES";i.encryptionSchemeAlg="TripleDES",i.encryptionSchemeIV=n(t,u[1]);var h=r(t,a[0]);if(2!=h.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+h.length;if("2a864886f70d01050c"!=n(t,h[0]))throw"this only supports pkcs5PBKDF2";var c=r(t,h[1]);if(c.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+c.length;i.pbkdf2Salt=n(t,c[0]);var l=n(t,c[1]);try{i.pbkdf2Iter=parseInt(l,16)}catch(t){throw"malformed format pbkdf2Iter: "+l}return i},getPBKDF2KeyHexFromParam:function(t,e){var r=g.enc.Hex.parse(t.pbkdf2Salt),n=t.pbkdf2Iter,i=g.PBKDF2(e,r,{keySize:6,iterations:n});return g.enc.Hex.stringify(i)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var r=dt(t,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(r),i=Ot.getPBKDF2KeyHexFromParam(n,e),s={};s.ciphertext=g.enc.Hex.parse(n.ciphertext);var o=g.enc.Hex.parse(i),a=g.enc.Hex.parse(n.encryptionSchemeIV),u=g.TripleDES.decrypt(s,o,{iv:a});return g.enc.Hex.stringify(u)},getKeyFromEncryptedPKCS8PEM:function(t,e){var r=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(r)},parsePlainPrivatePKCS8Hex:function(t){var e=Tt,r=e.getChildIdx,n=e.getV,i={algparam:null};if("30"!=t.substr(0,2))throw new Error("malformed plain PKCS8 private key(code:001)");var s=r(t,0);if(s.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if("30"!=t.substr(s[1],2))throw new Error("malformed PKCS8 private key(code:003)");var o=r(t,s[1]);if(2!=o.length)throw new Error("malformed PKCS8 private key(code:004)");if("06"!=t.substr(o[0],2))throw new Error("malformed PKCS8 private key(code:005)");if(i.algoid=n(t,o[0]),"06"==t.substr(o[1],2)&&(i.algparam=n(t,o[1])),"04"!=t.substr(s[2],2))throw new Error("malformed PKCS8 private key(code:006)");return i.keyidx=e.getVidx(t,s[2]),i},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=dt(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,r=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==r.algoid)e=new tt;else if("2a8648ce380401"==r.algoid)e=new d.crypto.DSA;else{if("2a8648ce3d0201"!=r.algoid)throw"unsupported private key algorithm";e=new d.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,r=Tt.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===r)e=new tt;else if("2a8648ce380401"===r)e=new d.crypto.DSA;else{if("2a8648ce3d0201"!==r)throw"unsupported PKCS#8 public key hex";e=new d.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=Tt,r=e.getChildIdx,n=e.getV,i={};if("30"!=t.substr(0,2))throw"malformed RSA key(code:001)";var s=r(t,0);if(2!=s.length)throw"malformed RSA key(code:002)";if("02"!=t.substr(s[0],2))throw"malformed RSA key(code:003)";if(i.n=n(t,s[0]),"02"!=t.substr(s[1],2))throw"malformed RSA key(code:004)";return i.e=n(t,s[1]),i},parsePublicPKCS8Hex:function(t){var e=Tt,r=e.getChildIdx,n=e.getV,i={algparam:null},s=r(t,0);if(2!=s.length)throw"outer DERSequence shall have 2 elements: "+s.length;var o=s[0];if("30"!=t.substr(o,2))throw"malformed PKCS8 public key(code:001)";var a=r(t,o);if(2!=a.length)throw"malformed PKCS8 public key(code:002)";if("06"!=t.substr(a[0],2))throw"malformed PKCS8 public key(code:003)";if(i.algoid=n(t,a[0]),"06"==t.substr(a[1],2)?i.algparam=n(t,a[1]):"30"==t.substr(a[1],2)&&(i.algparam={},i.algparam.p=e.getVbyList(t,a[1],[0],"02"),i.algparam.q=e.getVbyList(t,a[1],[1],"02"),i.algparam.g=e.getVbyList(t,a[1],[2],"02")),"03"!=t.substr(s[1],2))throw"malformed PKCS8 public key(code:004)";return i.key=n(t,s[1]).substr(2),i}});Ot.getKey=function(t,e,r){var n=(v=Tt).getChildIdx;v.getV;var i=v.getVbyList,s=d.crypto,o=s.ECDSA,a=s.DSA,u=tt,h=dt,c=Ot;if(void 0!==u&&t instanceof u)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new o({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new o({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(T=new u).setPublic(t.n,t.e),T;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(T=new u).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),T;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(T=new u).setPrivate(t.n,t.e,t.d),T;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(T=new a).setPublic(t.p,t.q,t.g,t.y),T;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(T=new a).setPrivate(t.p,t.q,t.g,t.y,t.x),T;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(T=new u).setPublic(ot(t.n),ot(t.e)),T;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(T=new u).setPrivateEx(ot(t.n),ot(t.e),ot(t.d),ot(t.p),ot(t.q),ot(t.dp),ot(t.dq),ot(t.qi)),T;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(T=new u).setPrivate(ot(t.n),ot(t.e),ot(t.d)),T;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var l=(O=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+ot(t.x)).slice(-l)+("0000000000"+ot(t.y)).slice(-l);return O.setPublicKeyHex(f),O}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){l=(O=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+ot(t.x)).slice(-l)+("0000000000"+ot(t.y)).slice(-l);var p=("0000000000"+ot(t.d)).slice(-l);return O.setPublicKeyHex(f),O.setPrivateKeyHex(p),O}if("pkcs5prv"===r){var g,m=t,v=Tt;if(9===(g=n(m,0)).length)(T=new u).readPKCS5PrvKeyHex(m);else if(6===g.length)(T=new a).readPKCS5PrvKeyHex(m);else{if(!(g.length>2&&"04"===m.substr(g[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(T=new o).readPKCS5PrvKeyHex(m)}return T}if("pkcs8prv"===r)return T=c.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===r)return c._getKeyFromPublicPKCS8Hex(t);if("x509pub"===r)return kt.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return kt.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var x=dt(t,"PUBLIC KEY");return c._getKeyFromPublicPKCS8Hex(x)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var b=h(t,"RSA PRIVATE KEY");return c.getKey(b,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var w=i(I=h(t,"DSA PRIVATE KEY"),0,[1],"02"),S=i(I,0,[2],"02"),E=i(I,0,[3],"02"),A=i(I,0,[4],"02"),P=i(I,0,[5],"02");return(T=new a).setPrivate(new y(w,16),new y(S,16),new y(E,16),new y(A,16),new y(P,16)),T}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){b=h(t,"EC PRIVATE KEY");return c.getKey(b,null,"pkcs5prv")}if(-1!=t.indexOf("-END PRIVATE KEY-"))return c.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var D=c.getDecryptedKeyHex(t,e),N=new tt;return N.readPKCS5PrvKeyHex(D),N}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var O,T=i(I=c.getDecryptedKeyHex(t,e),0,[1],"04"),R=i(I,0,[2,0],"06"),C=i(I,0,[3,0],"03").substr(2);if(void 0===d.crypto.OID.oidhex2name[R])throw"undefined OID(hex) in KJUR.crypto.OID: "+R;return(O=new o({curve:d.crypto.OID.oidhex2name[R]})).setPublicKeyHex(C),O.setPrivateKeyHex(T),O.isPublic=!1,O}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var I;w=i(I=c.getDecryptedKeyHex(t,e),0,[1],"02"),S=i(I,0,[2],"02"),E=i(I,0,[3],"02"),A=i(I,0,[4],"02"),P=i(I,0,[5],"02");return(T=new a).setPrivate(new y(w,16),new y(S,16),new y(E,16),new y(A,16),new y(P,16)),T}if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return c.getKeyFromEncryptedPKCS8PEM(t,e);throw new Error("not supported argument")},Ot.generateKeypair=function(t,e){if("RSA"==t){var r=e;(o=new tt).generate(r,"10001"),o.isPrivate=!0,o.isPublic=!0;var n=new tt,i=o.n.toString(16),s=o.e.toString(16);return n.setPublic(i,s),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}if("EC"==t){var o,a,u=e,h=new d.crypto.ECDSA({curve:u}).generateKeyPairHex();return(o=new d.crypto.ECDSA({curve:u})).setPublicKeyHex(h.ecpubhex),o.setPrivateKeyHex(h.ecprvhex),o.isPrivate=!0,o.isPublic=!1,(n=new d.crypto.ECDSA({curve:u})).setPublicKeyHex(h.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}throw"unknown algorithm: "+t},Ot.getPEM=function(t,e,r,n,i,s){var o=d,a=o.asn1,u=a.DERObjectIdentifier,h=a.DERInteger,c=a.ASN1Util.newObject,l=a.x509.SubjectPublicKeyInfo,f=o.crypto,p=f.DSA,y=f.ECDSA,m=tt;function v(t){return c({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function x(t){return c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function b(t){return c({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((void 0!==m&&t instanceof m||void 0!==p&&t instanceof p||void 0!==y&&t instanceof y)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return ft(A=new l(t).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==m&&t instanceof m&&(void 0===r||null==r)&&1==t.isPrivate)return ft(A=v(t).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==y&&t instanceof y&&(void 0===r||null==r)&&1==t.isPrivate){var w=new u({name:t.curveName}).getEncodedHex(),S=x(t).getEncodedHex(),E="";return E+=ft(w,"EC PARAMETERS"),E+=ft(S,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==p&&t instanceof p&&(void 0===r||null==r)&&1==t.isPrivate)return ft(A=b(t).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==m&&t instanceof m&&void 0!==r&&null!=r&&1==t.isPrivate){var A=v(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",A,r,n,s)}if("PKCS5PRV"==e&&void 0!==y&&t instanceof y&&void 0!==r&&null!=r&&1==t.isPrivate){A=x(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",A,r,n,s)}if("PKCS5PRV"==e&&void 0!==p&&t instanceof p&&void 0!==r&&null!=r&&1==t.isPrivate){A=b(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",A,r,n,s)}var P=function(t,e){var r=D(t,e);return new c({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:r.pbkdf2Salt}},{int:r.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:r.encryptionSchemeIV}}]}]}]},{octstr:{hex:r.ciphertext}}]}).getEncodedHex()},D=function(t,e){var r=g.lib.WordArray.random(8),n=g.lib.WordArray.random(8),i=g.PBKDF2(e,r,{keySize:6,iterations:100}),s=g.enc.Hex.parse(t),o=g.TripleDES.encrypt(s,i,{iv:n})+"",a={};return a.ciphertext=o,a.pbkdf2Salt=g.enc.Hex.stringify(r),a.pbkdf2Iter=100,a.encryptionSchemeAlg="DES-EDE3-CBC",a.encryptionSchemeIV=g.enc.Hex.stringify(n),a};if("PKCS8PRV"==e&&null!=m&&t instanceof m&&1==t.isPrivate){var N=v(t).getEncodedHex();A=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:N}}]}).getEncodedHex();return void 0===r||null==r?ft(A,"PRIVATE KEY"):ft(S=P(A,r),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==y&&t instanceof y&&1==t.isPrivate){N=new c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]}).getEncodedHex(),A=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:N}}]}).getEncodedHex();return void 0===r||null==r?ft(A,"PRIVATE KEY"):ft(S=P(A,r),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==p&&t instanceof p&&1==t.isPrivate){N=new h({bigint:t.x}).getEncodedHex(),A=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:N}}]}).getEncodedHex();return void 0===r||null==r?ft(A,"PRIVATE KEY"):ft(S=P(A,r),"ENCRYPTED PRIVATE KEY")}throw new Error("unsupported object nor format")},Ot.getKeyFromCSRPEM=function(t){var e=dt(t,"CERTIFICATE REQUEST");return Ot.getKeyFromCSRHex(e)},Ot.getKeyFromCSRHex=function(t){var e=Ot.parseCSRHex(t);return Ot.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Ot.parseCSRHex=function(t){var e=Tt,r=e.getChildIdx,n=e.getTLV,i={},s=t;if("30"!=s.substr(0,2))throw"malformed CSR(code:001)";var o=r(s,0);if(o.length<1)throw"malformed CSR(code:002)";if("30"!=s.substr(o[0],2))throw"malformed CSR(code:003)";var a=r(s,o[0]);if(a.length<3)throw"malformed CSR(code:004)";return i.p8pubkeyhex=n(s,a[2]),i},Ot.getKeyID=function(t){var e=Ot,r=Tt;"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&(t=e.getKey(t));var n=dt(e.getPEM(t)),i=r.getIdxbyList(n,0,[1]),s=r.getV(n,i).substring(2);return d.crypto.Util.hashHex(s,"sha1")},Ot.getJWKFromKey=function(t){var e={};if(t instanceof tt&&t.isPrivate)return e.kty="RSA",e.n=st(t.n.toString(16)),e.e=st(t.e.toString(16)),e.d=st(t.d.toString(16)),e.p=st(t.p.toString(16)),e.q=st(t.q.toString(16)),e.dp=st(t.dmp1.toString(16)),e.dq=st(t.dmq1.toString(16)),e.qi=st(t.coeff.toString(16)),e;if(t instanceof tt&&t.isPublic)return e.kty="RSA",e.n=st(t.n.toString(16)),e.e=st(t.e.toString(16)),e;if(t instanceof d.crypto.ECDSA&&t.isPrivate){if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;var r=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=st(r.x),e.y=st(r.y),e.d=st(t.prvKeyHex),e}if(t instanceof d.crypto.ECDSA&&t.isPublic){var n;if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;r=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=st(r.x),e.y=st(r.y),e}throw"not supported key object"},void 0!==d.asn1&&d.asn1||(d.asn1={}),d.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var r=e.substr(1).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var n="",i=0;i<r;i++)n+="f";e=new y(n,16).xor(t).add(y.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return ft(t,e)},this.newObject=function(t){var e=d.asn1,r=e.ASN1Object,n=e.DERBoolean,i=e.DERInteger,s=e.DERBitString,o=e.DEROctetString,a=e.DERNull,u=e.DERObjectIdentifier,h=e.DEREnumerated,c=e.DERUTF8String,l=e.DERNumericString,f=e.DERPrintableString,p=e.DERTeletexString,g=e.DERIA5String,y=e.DERUTCTime,m=e.DERGeneralizedTime,v=e.DERVisibleString,x=e.DERBMPString,b=e.DERSequence,w=e.DERSet,S=e.DERTaggedObject,E=e.ASN1Util.newObject;if(t instanceof e.ASN1Object)return t;var A=Object.keys(t);if(1!=A.length)throw new Error("key of param shall be only one.");var P=A[0];if(-1==":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+P+":"))throw new Error("undefined key: "+P);if("bool"==P)return new n(t[P]);if("int"==P)return new i(t[P]);if("bitstr"==P)return new s(t[P]);if("octstr"==P)return new o(t[P]);if("null"==P)return new a(t[P]);if("oid"==P)return new u(t[P]);if("enum"==P)return new h(t[P]);if("utf8str"==P)return new c(t[P]);if("numstr"==P)return new l(t[P]);if("prnstr"==P)return new f(t[P]);if("telstr"==P)return new p(t[P]);if("ia5str"==P)return new g(t[P]);if("utctime"==P)return new y(t[P]);if("gentime"==P)return new m(t[P]);if("visstr"==P)return new v(t[P]);if("bmpstr"==P)return new x(t[P]);if("asn1"==P)return new r(t[P]);if("seq"==P){for(var D=t[P],N=[],O=0;O<D.length;O++){var T=E(D[O]);N.push(T)}return new b({array:N})}if("set"==P){for(D=t[P],N=[],O=0;O<D.length;O++){T=E(D[O]);N.push(T)}return new w({array:N})}if("tag"==P){var R=t[P];if("[object Array]"===Object.prototype.toString.call(R)&&3==R.length){var C=E(R[2]);return new S({tag:R[0],explicit:R[1],obj:C})}return new S(R)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},d.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",r=parseInt(t.substr(0,2),16),n=(e=Math.floor(r/40)+"."+r%40,""),i=2;i<t.length;i+=2){var s=("00000000"+parseInt(t.substr(i,2),16).toString(2)).slice(-8);if(n+=s.substr(1,7),"0"==s.substr(0,1))e=e+"."+new y(n,2).toString(10),n=""}return e},d.asn1.ASN1Util.oidIntToHex=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",n=new y(t,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var s="",o=0;o<i;o++)s+="0";n=s+n;for(o=0;o<n.length-1;o+=7){var a=n.substr(o,7);o!=n.length-7&&(a="1"+a),r+=e(parseInt(a,2))}return r};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var n="",i=t.split("."),s=40*parseInt(i[0])+parseInt(i[1]);n+=e(s),i.splice(0,2);for(var o=0;o<i.length;o++)n+=r(i[o]);return n},d.asn1.ASN1Object=function(t){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 t=this.hV.length/2,e=t.toString(16);if(e.length%2==1&&(e="0"+e),t<128)return e;var r=e.length/2;if(r>15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+r).toString(16)+e},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(t){this.params=t},null!=t&&null!=t.tlv&&(this.hTLV=t.tlv,this.isModified=!1)},d.asn1.DERAbstractString=function(t){d.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=at(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},p.lang.extend(d.asn1.DERAbstractString,d.asn1.ASN1Object),d.asn1.DERAbstractTime=function(t){d.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(t){var e=t.getTime()+6e4*t.getTimezoneOffset();return new Date(e)},this.formatDate=function(t,e,r){var n=this.zeroPadding,i=this.localDateToUTC(t),s=String(i.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+n(String(i.getMonth()+1),2)+n(String(i.getDate()),2)+n(String(i.getHours()),2)+n(String(i.getMinutes()),2)+n(String(i.getSeconds()),2);if(!0===r){var a=i.getMilliseconds();if(0!=a){var u=n(String(a),3);o=o+"."+(u=u.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=nt(t)},this.setByDateValue=function(t,e,r,n,i,s){var o=new Date(Date.UTC(t,e-1,r,n,i,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},p.lang.extend(d.asn1.DERAbstractTime,d.asn1.ASN1Object),d.asn1.DERAbstractStructured=function(t){d.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},p.lang.extend(d.asn1.DERAbstractStructured,d.asn1.ASN1Object),d.asn1.DERBoolean=function(t){d.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=0==t?"010100":"0101ff"},p.lang.extend(d.asn1.DERBoolean,d.asn1.ASN1Object),d.asn1.DERInteger=function(t){d.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=d.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new y(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},p.lang.extend(d.asn1.DERInteger,d.asn1.ASN1Object),d.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=d.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}d.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var r="0"+t;this.hTLV=null,this.isModified=!0,this.hV=r+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0);for(var r=0;r<=e;r++)t+="0";var n="";for(r=0;r<t.length-1;r+=8){var i=t.substr(r,8),s=parseInt(i,2).toString(16);1==s.length&&(s="0"+s),n+=s}this.hTLV=null,this.isModified=!0,this.hV="0"+e+n},this.setByBooleanArray=function(t){for(var e="",r=0;r<t.length;r++)1==t[r]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=!1;return e},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t&&t.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(t):void 0!==t.hex?this.setHexValueIncludingUnusedBits(t.hex):void 0!==t.bin?this.setByBinaryString(t.bin):void 0!==t.array&&this.setByBooleanArray(t.array))},p.lang.extend(d.asn1.DERBitString,d.asn1.ASN1Object),d.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=d.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}d.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},p.lang.extend(d.asn1.DEROctetString,d.asn1.DERAbstractString),d.asn1.DERNull=function(){d.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},p.lang.extend(d.asn1.DERNull,d.asn1.ASN1Object),d.asn1.DERObjectIdentifier=function(t){d.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){var e=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",n=parseInt(t,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var s="",o=0;o<i;o++)s+="0";for(n=s+n,o=0;o<n.length-1;o+=7){var a=n.substr(o,7);o!=n.length-7&&(a="1"+a),r+=e(parseInt(a,2))}return r};try{if(!t.match(/^[0-9.]+$/))return null;var n="",i=t.split("."),s=40*parseInt(i[0],10)+parseInt(i[1],10);n+=e(s),i.splice(0,2);for(var o=0;o<i.length;o++)n+=r(i[o]);return n}catch(t){return null}}(t);if(null==e)throw new Error("malformed oid string: "+t);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueName=function(t){var e=d.asn1.x509.OID.name2oid(t);if(""===e)throw new Error("DERObjectIdentifier oidName undefined: "+t);this.setValueOidString(e)},this.setValueNameOrOid=function(t){t.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(t):this.setValueName(t)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(t){"string"==typeof t?this.setValueNameOrOid(t):void 0!==t.oid?this.setValueNameOrOid(t.oid):void 0!==t.name?this.setValueNameOrOid(t.name):void 0!==t.hex&&this.setValueHex(t.hex)},void 0!==t&&this.setByParam(t)},p.lang.extend(d.asn1.DERObjectIdentifier,d.asn1.ASN1Object),d.asn1.DEREnumerated=function(t){d.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=d.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new y(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},p.lang.extend(d.asn1.DEREnumerated,d.asn1.ASN1Object),d.asn1.DERUTF8String=function(t){d.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},p.lang.extend(d.asn1.DERUTF8String,d.asn1.DERAbstractString),d.asn1.DERNumericString=function(t){d.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},p.lang.extend(d.asn1.DERNumericString,d.asn1.DERAbstractString),d.asn1.DERPrintableString=function(t){d.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},p.lang.extend(d.asn1.DERPrintableString,d.asn1.DERAbstractString),d.asn1.DERTeletexString=function(t){d.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},p.lang.extend(d.asn1.DERTeletexString,d.asn1.DERAbstractString),d.asn1.DERIA5String=function(t){d.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},p.lang.extend(d.asn1.DERIA5String,d.asn1.DERAbstractString),d.asn1.DERVisibleString=function(t){d.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="1a"},p.lang.extend(d.asn1.DERVisibleString,d.asn1.DERAbstractString),d.asn1.DERBMPString=function(t){d.asn1.DERBMPString.superclass.constructor.call(this,t),this.hT="1e"},p.lang.extend(d.asn1.DERBMPString,d.asn1.DERAbstractString),d.asn1.DERUTCTime=function(t){d.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"utc"),this.hV=nt(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=nt(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{12}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date))},p.lang.extend(d.asn1.DERUTCTime,d.asn1.DERAbstractTime),d.asn1.DERGeneralizedTime=function(t){d.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.withMillis=!1,this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=nt(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=nt(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{14}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date),!0===t.millis&&(this.withMillis=!0))},p.lang.extend(d.asn1.DERGeneralizedTime,d.asn1.DERAbstractTime),d.asn1.DERSequence=function(t){d.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++){t+=this.asn1Array[e].getEncodedHex()}return this.hV=t,this.hV}},p.lang.extend(d.asn1.DERSequence,d.asn1.DERAbstractStructured),d.asn1.DERSet=function(t){d.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var r=this.asn1Array[e];t.push(r.getEncodedHex())}return 1==this.sortFlag&&t.sort(),this.hV=t.join(""),this.hV},void 0!==t&&void 0!==t.sortflag&&0==t.sortflag&&(this.sortFlag=!1)},p.lang.extend(d.asn1.DERSet,d.asn1.DERAbstractStructured),d.asn1.DERTaggedObject=function(t){d.asn1.DERTaggedObject.superclass.constructor.call(this);var e=d.asn1;this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,r){this.hT=e,this.isExplicit=t,this.asn1Object=r,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=r.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(t){null!=t.tag&&(this.hT=t.tag),null!=t.explicit&&(this.isExplicit=t.explicit),null!=t.tage&&(this.hT=t.tage,this.isExplicit=!0),null!=t.tagi&&(this.hT=t.tagi,this.isExplicit=!1),null!=t.obj&&(t.obj instanceof e.ASN1Object?(this.asn1Object=t.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)):"object"==typeof t.obj&&(this.asn1Object=e.ASN1Util.newObject(t.obj),this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},null!=t&&this.setByParam(t)},p.lang.extend(d.asn1.DERTaggedObject,d.asn1.ASN1Object);var Tt=new function(){};function Rt(t,e){for(var r="",n=e/4-t.length,i=0;i<n;i++)r+="0";return r+t}function Ct(t,e,r){for(var n="",i=0;n.length<e;)n+=ht(r(ct(t+String.fromCharCode.apply(String,[(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i])))),i+=1;return n}function It(t){for(var e in d.crypto.Util.DIGESTINFOHEAD){var r=d.crypto.Util.DIGESTINFOHEAD[e],n=r.length;if(t.substring(0,n)==r)return[e,t.substring(n)]}return[]}function kt(t){var e,r=Tt,n=r.getChildIdx,i=r.getV,s=r.getTLV,o=r.getVbyList,a=r.getVbyListEx,u=r.getTLVbyList,h=r.getTLVbyListEx,c=r.getIdxbyList,l=r.getIdxbyListEx,f=r.getVidx,p=r.getInt,g=r.oidname,y=r.hextooidstr,m=dt;try{e=d.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV}catch(t){}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 t=u(this.hex,0,[0,0]);if("a0"==t.substr(0,2)){var e=u(t,0,[0]),r=p(e,0);if(r<0||2<r)throw new Error("malformed version field");return this.version=r+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 t=h(this.hex,0,[0,1]);return this.getAlgorithmIdentifierName(t)},this.getAlgorithmIdentifierName=function(t){for(var r in e)if(t===e[r])return r;return g(a(t,0,[0],"06"))},this.getIssuer=function(){return this.getX500Name(this.getIssuerHex())},this.getIssuerHex=function(){return u(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 u(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return this.getSubject().str},this.getNotBefore=function(){var t=o(this.hex,0,[0,4+this.foffset,0]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getNotAfter=function(){var t=o(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getPublicKeyHex=function(){return r.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return c(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return c(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return Ot.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){var t=u(this.hex,0,[1],"30");return this.getAlgorithmIdentifierName(t)},this.getSignatureValueHex=function(){return o(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmField(),r=this.getSignatureValueHex(),n=u(this.hex,0,[0],"30"),i=new d.crypto.Signature({alg:e});return i.init(t),i.updateHex(n),i.verify(r)},this.parseExt=function(t){var e,s,a;if(void 0===t){if(a=this.hex,3!==this.version)return-1;e=c(a,0,[0,7,0],"30"),s=n(a,e)}else{a=dt(t);var u=c(a,0,[0,3,0,0],"06");if("2a864886f70d01090e"!=i(a,u))return void(this.aExtInfo=new Array);e=c(a,0,[0,3,0,1,0],"30"),s=n(a,e),this.hex=a}this.aExtInfo=new Array;for(var h=0;h<s.length;h++){var l={critical:!1},d=0;3===n(a,s[h]).length&&(l.critical=!0,d=1),l.oid=r.hextooidstr(o(a,s[h],[0],"06"));var p=c(a,s[h],[1+d]);l.vidx=f(a,p),this.aExtInfo.push(l)}},this.getExtInfo=function(t){var e=this.aExtInfo,r=t;if(t.match(/^[0-9.]+$/)||(r=d.asn1.x509.OID.name2oid(t)),""!==r)for(var n=0;n<e.length;n++)if(e[n].oid===r)return e[n]},this.getExtBasicConstraints=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("basicConstraints");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var n={extname:"basicConstraints"};if(e&&(n.critical=!0),"3000"===t)return n;if("30030101ff"===t)return n.cA=!0,n;if("30060101ff02"===t.substr(0,12)){var o=i(t,10),a=parseInt(o,16);return n.cA=!0,n.pathLen=a,n}throw new Error("hExtV parse error: "+t)},this.getExtKeyUsage=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("keyUsage");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var n={extname:"keyUsage"};return e&&(n.critical=!0),n.names=this.getExtKeyUsageString(t).split(","),n},this.getExtKeyUsageBin=function(t){if(void 0===t){var e=this.getExtInfo("keyUsage");if(void 0===e)return"";t=s(this.hex,e.vidx)}if(8!=t.length&&10!=t.length)throw new Error("malformed key usage value: "+t);var r="000000000000000"+parseInt(t.substr(6),16).toString(2);return 8==t.length&&(r=r.slice(-8)),10==t.length&&(r=r.slice(-16)),""==(r=r.replace(/0+$/,""))&&(r="0"),r},this.getExtKeyUsageString=function(t){for(var e=this.getExtKeyUsageBin(t),r=new Array,n=0;n<e.length;n++)"1"==e.substr(n,1)&&r.push(kt.KEYUSAGE_NAME[n]);return r.join(",")},this.getExtSubjectKeyIdentifier=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectKeyIdentifier");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var n={extname:"subjectKeyIdentifier"};e&&(n.critical=!0);var o=i(t,0);return n.kid={hex:o},n},this.getExtAuthorityKeyIdentifier=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("authorityKeyIdentifier");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var o={extname:"authorityKeyIdentifier"};e&&(o.critical=!0);for(var a=n(t,0),u=0;u<a.length;u++){var h=t.substr(a[u],2);if("80"===h&&(o.kid={hex:i(t,a[u])}),"a1"===h){var c=s(t,a[u]),l=this.getGeneralNames(c);o.issuer=l[0].dn}"82"===h&&(o.sn={hex:i(t,a[u])})}return o},this.getExtExtKeyUsage=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("extKeyUsage");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var o={extname:"extKeyUsage",array:[]};e&&(o.critical=!0);for(var a=n(t,0),u=0;u<a.length;u++)o.array.push(g(i(t,a[u])));return o},this.getExtExtKeyUsageName=function(){var t=this.getExtInfo("extKeyUsage");if(void 0===t)return t;var e=new Array,r=s(this.hex,t.vidx);if(""===r)return e;for(var o=n(r,0),a=0;a<o.length;a++)e.push(g(i(r,o[a])));return e},this.getExtSubjectAltName=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectAltName");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var n={extname:"subjectAltName",array:[]};return e&&(n.critical=!0),n.array=this.getGeneralNames(t),n},this.getExtIssuerAltName=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("issuerAltName");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var n={extname:"issuerAltName",array:[]};return e&&(n.critical=!0),n.array=this.getGeneralNames(t),n},this.getGeneralNames=function(t){for(var e=n(t,0),r=[],i=0;i<e.length;i++){var o=this.getGeneralName(s(t,e[i]));void 0!==o&&r.push(o)}return r},this.getGeneralName=function(t){var e=t.substr(0,2),r=i(t,0),n=ht(r);return"81"==e?{rfc822:n}:"82"==e?{dns:n}:"86"==e?{uri:n}:"87"==e?{ip:pt(r)}:"a4"==e?{dn:this.getX500Name(r)}:void 0},this.getExtSubjectAltName2=function(){var t,e,r,o=this.getExtInfo("subjectAltName");if(void 0===o)return o;for(var a=new Array,u=s(this.hex,o.vidx),h=n(u,0),c=0;c<h.length;c++)r=u.substr(h[c],2),t=i(u,h[c]),"81"===r&&(e=ut(t),a.push(["MAIL",e])),"82"===r&&(e=ut(t),a.push(["DNS",e])),"84"===r&&(e=kt.hex2dn(t,0),a.push(["DN",e])),"86"===r&&(e=ut(t),a.push(["URI",e])),"87"===r&&(e=pt(t),a.push(["IP",e]));return a},this.getExtCRLDistributionPoints=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("cRLDistributionPoints");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var i={extname:"cRLDistributionPoints",array:[]};e&&(i.critical=!0);for(var o=n(t,0),a=0;a<o.length;a++){var u=s(t,o[a]);i.array.push(this.getDistributionPoint(u))}return i},this.getDistributionPoint=function(t){for(var e={},r=n(t,0),i=0;i<r.length;i++){var o=t.substr(r[i],2),a=s(t,r[i]);"a0"==o&&(e.dpname=this.getDistributionPointName(a))}return e},this.getDistributionPointName=function(t){for(var e={},r=n(t,0),i=0;i<r.length;i++){var o=t.substr(r[i],2),a=s(t,r[i]);"a0"==o&&(e.full=this.getGeneralNames(a))}return e},this.getExtCRLDistributionPointsURI=function(){var t=this.getExtInfo("cRLDistributionPoints");if(void 0===t)return t;for(var e=new Array,r=n(this.hex,t.vidx),i=0;i<r.length;i++)try{var s=ut(o(this.hex,r[i],[0,0,0],"86"));e.push(s)}catch(t){}return e},this.getExtAIAInfo=function(){var t=this.getExtInfo("authorityInfoAccess");if(void 0===t)return t;for(var e={ocsp:[],caissuer:[]},r=n(this.hex,t.vidx),i=0;i<r.length;i++){var s=o(this.hex,r[i],[0],"06"),a=o(this.hex,r[i],[1],"86");"2b06010505073001"===s&&e.ocsp.push(ut(a)),"2b06010505073002"===s&&e.caissuer.push(ut(a))}return e},this.getExtAuthorityInfoAccess=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("authorityInfoAccess");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var i={extname:"authorityInfoAccess",array:[]};e&&(i.critical=!0);for(var u=n(t,0),h=0;h<u.length;h++){var c=a(t,u[h],[0],"06"),l=ut(o(t,u[h],[1],"86"));if("2b06010505073001"==c)i.array.push({ocsp:l});else{if("2b06010505073002"!=c)throw new Error("unknown method: "+c);i.array.push({caissuer:l})}}return i},this.getExtCertificatePolicies=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("certificatePolicies");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var i={extname:"certificatePolicies",array:[]};e&&(i.critical=!0);for(var o=n(t,0),a=0;a<o.length;a++){var u=s(t,o[a]),h=this.getPolicyInformation(u);i.array.push(h)}return i},this.getPolicyInformation=function(t){var e={},r=o(t,0,[0],"06");e.policyoid=g(r);var i=l(t,0,[1],"30");if(-1!=i){e.array=[];for(var a=n(t,i),u=0;u<a.length;u++){var h=s(t,a[u]),c=this.getPolicyQualifierInfo(h);e.array.push(c)}}return e},this.getPolicyQualifierInfo=function(t){var e={},r=o(t,0,[0],"06");if("2b06010505070201"===r){var n=a(t,0,[1],"16");e.cps=ht(n)}else if("2b06010505070202"===r){var i=u(t,0,[1],"30");e.unotice=this.getUserNotice(i)}return e},this.getUserNotice=function(t){for(var e={},r=n(t,0),i=0;i<r.length;i++){var o=s(t,r[i]);"30"!=o.substr(0,2)&&(e.exptext=this.getDisplayText(o))}return e},this.getDisplayText=function(t){var e={};return e.type={"0c":"utf8",16:"ia5","1a":"vis","1e":"bmp"}[t.substr(0,2)],e.str=ht(i(t,0)),e},this.getExtCRLNumber=function(t,e){var r={extname:"cRLNumber"};if(e&&(r.critical=!0),"02"==t.substr(0,2))return r.num={hex:i(t,0)},r;throw new Error("hExtV parse error: "+t)},this.getExtCRLReason=function(t,e){var r={extname:"cRLReason"};if(e&&(r.critical=!0),"0a"==t.substr(0,2))return r.code=parseInt(i(t,0),16),r;throw new Error("hExtV parse error: "+t)},this.getExtOcspNonce=function(t,e){var r={extname:"ocspNonce"};e&&(r.critical=!0);var n=i(t,0);return r.hex=n,r},this.getExtOcspNoCheck=function(t,e){var r={extname:"ocspNoCheck"};return e&&(r.critical=!0),r},this.getExtAdobeTimeStamp=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("adobeTimeStamp");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var i={extname:"adobeTimeStamp"};e&&(i.critical=!0);var o=n(t,0);if(o.length>1){var a=s(t,o[1]),u=this.getGeneralName(a);null!=u.uri&&(i.uri=u.uri)}if(o.length>2){var h=s(t,o[2]);"0101ff"==h&&(i.reqauth=!0),"010100"==h&&(i.reqauth=!1)}return i},this.getX500NameRule=function(t){for(var e=null,r=[],n=0;n<t.length;n++)for(var i=t[n],s=0;s<i.length;s++)r.push(i[s]);for(n=0;n<r.length;n++){var o=r[n],a=o.ds,u=o.value,h=o.type;if("prn"!=a&&"utf8"!=a&&"ia5"!=a)return"mixed";if("ia5"==a){if("CN"!=h)return"mixed";if(d.lang.String.isMail(u))continue;return"mixed"}if("C"==h){if("prn"==a)continue;return"mixed"}if(null==e)e=a;else if(e!==a)return"mixed"}return null==e?"prn":e},this.getX500Name=function(t){var e=this.getX500NameArray(t);return{array:e,str:this.dnarraytostr(e)}},this.getX500NameArray=function(t){for(var e=[],r=n(t,0),i=0;i<r.length;i++)e.push(this.getRDN(s(t,r[i])));return e},this.getRDN=function(t){for(var e=[],r=n(t,0),i=0;i<r.length;i++)e.push(this.getAttrTypeAndValue(s(t,r[i])));return e},this.getAttrTypeAndValue=function(t){var e={type:null,value:null,ds:null},r=n(t,0),i=o(t,r[0],[],"06"),s=o(t,r[1],[]),a=d.asn1.ASN1Util.oidHexToInt(i);return e.type=d.asn1.x509.OID.oid2atype(a),e.ds=this.HEX2STAG[t.substr(r[1],2)],"bmp"!=e.ds?e.value=ut(s):e.value=gt(s),e},this.readCertPEM=function(t){this.readCertHex(m(t))},this.readCertHex=function(t){this.hex=t,this.getVersion();try{c(this.hex,0,[0,7],"a3"),this.parseExt()}catch(t){}},this.getParam=function(){var t={};return t.version=this.getVersion(),t.serial={hex:this.getSerialNumberHex()},t.sigalg=this.getSignatureAlgorithmField(),t.issuer=this.getIssuer(),t.notbefore=this.getNotBefore(),t.notafter=this.getNotAfter(),t.subject=this.getSubject(),t.sbjpubkey=ft(this.getPublicKeyHex(),"PUBLIC KEY"),this.aExtInfo.length>0&&(t.ext=this.getExtParamArray()),t.sighex=this.getSignatureValueHex(),t},this.getExtParamArray=function(t){null==t&&(-1!=l(this.hex,0,[0,"[3]"])&&(t=h(this.hex,0,[0,"[3]",0],"30")));for(var e=[],r=n(t,0),i=0;i<r.length;i++){var o=s(t,r[i]),a=this.getExtParam(o);null!=a&&e.push(a)}return e},this.getExtParam=function(t){var e=n(t,0).length;if(2!=e&&3!=e)throw new Error("wrong number elements in Extension: "+e+" "+t);var r=y(o(t,0,[0],"06")),i=!1;3==e&&"0101ff"==u(t,0,[1])&&(i=!0);var s=u(t,0,[e-1,0]),a=void 0;if("2.5.29.14"==r?a=this.getExtSubjectKeyIdentifier(s,i):"2.5.29.15"==r?a=this.getExtKeyUsage(s,i):"2.5.29.17"==r?a=this.getExtSubjectAltName(s,i):"2.5.29.18"==r?a=this.getExtIssuerAltName(s,i):"2.5.29.19"==r?a=this.getExtBasicConstraints(s,i):"2.5.29.31"==r?a=this.getExtCRLDistributionPoints(s,i):"2.5.29.32"==r?a=this.getExtCertificatePolicies(s,i):"2.5.29.35"==r?a=this.getExtAuthorityKeyIdentifier(s,i):"2.5.29.37"==r?a=this.getExtExtKeyUsage(s,i):"1.3.6.1.5.5.7.1.1"==r?a=this.getExtAuthorityInfoAccess(s,i):"2.5.29.20"==r?a=this.getExtCRLNumber(s,i):"2.5.29.21"==r?a=this.getExtCRLReason(s,i):"1.3.6.1.5.5.7.48.1.2"==r?a=this.getExtOcspNonce(s,i):"1.3.6.1.5.5.7.48.1.5"==r?a=this.getExtOcspNoCheck(s,i):"1.2.840.113583.1.1.9.1"==r&&(a=this.getExtAdobeTimeStamp(s,i)),null!=a)return a;var h={extname:r,extn:s};return i&&(h.critical=!0),h},this.findExt=function(t,e){for(var r=0;r<t.length;r++)if(t[r].extname==e)return t[r];return null},this.updateExtCDPFullURI=function(t,e){var r=this.findExt(t,"cRLDistributionPoints");if(null!=r&&null!=r.array)for(var n=r.array,i=0;i<n.length;i++)if(null!=n[i].dpname&&null!=n[i].dpname.full)for(var s=n[i].dpname.full,o=0;o<s.length;o++){var a=s[i];null!=a.uri&&(a.uri=e)}},this.updateExtAIAOCSP=function(t,e){var r=this.findExt(t,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var n=r.array,i=0;i<n.length;i++)null!=n[i].ocsp&&(n[i].ocsp=e)},this.updateExtAIACAIssuer=function(t,e){var r=this.findExt(t,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var n=r.array,i=0;i<n.length;i++)null!=n[i].caissuer&&(n[i].caissuer=e)},this.dnarraytostr=function(t){return"/"+t.map((function(t){return function(t){return t.map((function(t){return function(t){return t.type+"="+t.value}(t).replace(/\+/,"\\+")})).join("+")}(t).replace(/\//,"\\/")})).join("/")},this.getInfo=function(){var t,e,r,n,i=function(t){for(var e="",r=t.array,n=0;n<r.length;n++){var i=r[n];if(e+=" policy oid: "+i.policyoid+"\n",void 0!==i.array)for(var s=0;s<i.array.length;s++){var o=i.array[s];void 0!==o.cps&&(e+=" cps: "+o.cps+"\n")}}return e},s=function(t){for(var e="",r=t.array,n=0;n<r.length;n++){var i=r[n];try{void 0!==i.dpname.full[0].uri&&(e+=" "+i.dpname.full[0].uri+"\n")}catch(t){}try{void 0!==i.dname.full[0].dn.hex&&(e+=" "+kt.hex2dn(i.dpname.full[0].dn.hex)+"\n")}catch(t){}}return e},o=function(t){for(var e="",r=t.array,n=0;n<r.length;n++){var i=r[n];void 0!==i.caissuer&&(e+=" caissuer: "+i.caissuer+"\n"),void 0!==i.ocsp&&(e+=" ocsp: "+i.ocsp+"\n")}return e};if(t="Basic Fields\n",t+=" serial number: "+this.getSerialNumberHex()+"\n",t+=" signature algorithm: "+this.getSignatureAlgorithmField()+"\n",t+=" issuer: "+this.getIssuerString()+"\n",t+=" notBefore: "+this.getNotBefore()+"\n",t+=" notAfter: "+this.getNotAfter()+"\n",t+=" subject: "+this.getSubjectString()+"\n",t+=" subject public key info: \n",t+=" key algorithm: "+(e=this.getPublicKey()).type+"\n","RSA"===e.type&&(t+=" n="+mt(e.n.toString(16)).substr(0,16)+"...\n",t+=" e="+mt(e.e.toString(16))+"\n"),null!=(r=this.aExtInfo)){t+="X509v3 Extensions:\n";for(var a=0;a<r.length;a++){var u=r[a],h=d.asn1.x509.OID.oid2name(u.oid);""===h&&(h=u.oid);var c="";if(!0===u.critical&&(c="CRITICAL"),t+=" "+h+" "+c+":\n","basicConstraints"===h){var l=this.getExtBasicConstraints();void 0===l.cA?t+=" {}\n":(t+=" cA=true",void 0!==l.pathLen&&(t+=", pathLen="+l.pathLen),t+="\n")}else if("keyUsage"===h)t+=" "+this.getExtKeyUsageString()+"\n";else if("subjectKeyIdentifier"===h)t+=" "+this.getExtSubjectKeyIdentifier().kid.hex+"\n";else if("authorityKeyIdentifier"===h){var f=this.getExtAuthorityKeyIdentifier();void 0!==f.kid&&(t+=" kid="+f.kid.hex+"\n")}else{if("extKeyUsage"===h)t+=" "+this.getExtExtKeyUsage().array.join(", ")+"\n";else if("subjectAltName"===h)t+=" "+(n=this.getExtSubjectAltName(),JSON.stringify(n.array).replace(/[\[\]\{\}\"]/g,""))+"\n";else if("cRLDistributionPoints"===h)t+=s(this.getExtCRLDistributionPoints());else if("authorityInfoAccess"===h)t+=o(this.getExtAuthorityInfoAccess());else"certificatePolicies"===h&&(t+=i(this.getExtCertificatePolicies()))}}}return t+="signature algorithm: "+this.getSignatureAlgorithmName()+"\n",t+="signature: "+this.getSignatureValueHex().substr(0,16)+"...\n"},"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?this.readCertPEM(t):d.lang.String.isHex(t)&&this.readCertHex(t))}function jt(t){return g.SHA256(t).toString()}Tt.getLblen=function(t,e){if("8"!=t.substr(e+2,1))return 1;var r=parseInt(t.substr(e+3,1));return 0==r?-1:0<r&&r<10?r+1:-2},Tt.getL=function(t,e){var r=Tt.getLblen(t,e);return r<1?"":t.substr(e+2,2*r)},Tt.getVblen=function(t,e){var r;return""==(r=Tt.getL(t,e))?-1:("8"===r.substr(0,1)?new y(r.substr(2),16):new y(r,16)).intValue()},Tt.getVidx=function(t,e){var r=Tt.getLblen(t,e);return r<0?r:e+2*(r+1)},Tt.getV=function(t,e){var r=Tt.getVidx(t,e),n=Tt.getVblen(t,e);return t.substr(r,2*n)},Tt.getTLV=function(t,e){return t.substr(e,2)+Tt.getL(t,e)+Tt.getV(t,e)},Tt.getTLVblen=function(t,e){return 2+2*Tt.getLblen(t,e)+2*Tt.getVblen(t,e)},Tt.getNextSiblingIdx=function(t,e){return Tt.getVidx(t,e)+2*Tt.getVblen(t,e)},Tt.getChildIdx=function(t,e){var r,n,i,s=Tt,o=[];r=s.getVidx(t,e),n=2*s.getVblen(t,e),"03"==t.substr(e,2)&&(r+=2,n-=2),i=0;for(var a=r;i<=n;){var u=s.getTLVblen(t,a);if((i+=u)<=n&&o.push(a),a+=u,i>=n)break}return o},Tt.getNthChildIdx=function(t,e,r){return Tt.getChildIdx(t,e)[r]},Tt.getIdxbyList=function(t,e,r,n){var i,s,o=Tt;return 0==r.length?void 0!==n&&t.substr(e,2)!==n?-1:e:(i=r.shift())>=(s=o.getChildIdx(t,e)).length?-1:o.getIdxbyList(t,s[i],r,n)},Tt.getIdxbyListEx=function(t,e,r,n){var i,s,o=Tt;if(0==r.length)return void 0!==n&&t.substr(e,2)!==n?-1:e;i=r.shift(),s=o.getChildIdx(t,e);for(var a=0,u=0;u<s.length;u++){var h=t.substr(s[u],2);if("number"==typeof i&&!o.isContextTag(h)&&a==i||"string"==typeof i&&o.isContextTag(h,i))return o.getIdxbyListEx(t,s[u],r,n);o.isContextTag(h)||a++}return-1},Tt.getTLVbyList=function(t,e,r,n){var i=Tt,s=i.getIdxbyList(t,e,r,n);return-1==s||s>=t.length?null:i.getTLV(t,s)},Tt.getTLVbyListEx=function(t,e,r,n){var i=Tt,s=i.getIdxbyListEx(t,e,r,n);return-1==s?null:i.getTLV(t,s)},Tt.getVbyList=function(t,e,r,n,i){var s,o,a=Tt;return-1==(s=a.getIdxbyList(t,e,r,n))||s>=t.length?null:(o=a.getV(t,s),!0===i&&(o=o.substr(2)),o)},Tt.getVbyListEx=function(t,e,r,n,i){var s,o,a=Tt;return-1==(s=a.getIdxbyListEx(t,e,r,n))?null:(o=a.getV(t,s),"03"==t.substr(s,2)&&!1!==i&&(o=o.substr(2)),o)},Tt.getInt=function(t,e,r){null==r&&(r=-1);try{var n=t.substr(e,2);if("02"!=n&&"03"!=n)return r;var i=Tt.getV(t,e);return"02"==n?parseInt(i,16):function(t){try{var e=t.substr(0,2);if("00"==e)return parseInt(t.substr(2),16);var r=parseInt(e,16),n=t.substr(2),i=parseInt(n,16).toString(2);return"0"==i&&(i="00000000"),i=i.slice(0,0-r),parseInt(i,2)}catch(t){return-1}}(i)}catch(t){return r}},Tt.getOID=function(t,e,r){null==r&&(r=null);try{return"06"!=t.substr(e,2)?r:function(t){if(!yt(t))return null;try{var e=[],r=t.substr(0,2),n=parseInt(r,16);e[0]=new String(Math.floor(n/40)),e[1]=new String(n%40);for(var i=t.substr(2),s=[],o=0;o<i.length/2;o++)s.push(parseInt(i.substr(2*o,2),16));var a=[],u="";for(o=0;o<s.length;o++)128&s[o]?u+=vt((127&s[o]).toString(2),7):(u+=vt((127&s[o]).toString(2),7),a.push(new String(parseInt(u,2))),u="");var h=e.join(".");return a.length>0&&(h=h+"."+a.join(".")),h}catch(t){return null}}(Tt.getV(t,e))}catch(t){return r}},Tt.getOIDName=function(t,e,r){null==r&&(r=null);try{var n=Tt.getOID(t,e,r);if(n==r)return r;var i=d.asn1.x509.OID.oid2name(n);return""==i?n:i}catch(t){return r}},Tt.getString=function(t,e,r){null==r&&(r=null);try{return ht(Tt.getV(t,e))}catch(t){return r}},Tt.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},r=[],n=t.substr(0,2),i=parseInt(n,16);r[0]=new String(Math.floor(i/40)),r[1]=new String(i%40);for(var s=t.substr(2),o=[],a=0;a<s.length/2;a++)o.push(parseInt(s.substr(2*a,2),16));var u=[],h="";for(a=0;a<o.length;a++)128&o[a]?h+=e((127&o[a]).toString(2),7):(h+=e((127&o[a]).toString(2),7),u.push(new String(parseInt(h,2))),h="");var c=r.join(".");return u.length>0&&(c=c+"."+u.join(".")),c},Tt.dump=function(t,e,r,n){var i=Tt,s=i.getV,o=i.dump,a=i.getChildIdx,u=t;t instanceof d.asn1.ASN1Object&&(u=t.getEncodedHex());var h=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===r&&(r=0),void 0===n&&(n="");var c,l=e.ommit_long_octet;if("01"==(c=u.substr(r,2)))return"00"==(f=s(u,r))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==c)return n+"INTEGER "+h(f=s(u,r),l)+"\n";if("03"==c){var f=s(u,r);if(i.isASN1HEX(f.substr(2))){var p=n+"BITSTRING, encapsulates\n";return p+=o(f.substr(2),e,0,n+" ")}return n+"BITSTRING "+h(f,l)+"\n"}if("04"==c){f=s(u,r);if(i.isASN1HEX(f)){p=n+"OCTETSTRING, encapsulates\n";return p+=o(f,e,0,n+" ")}return n+"OCTETSTRING "+h(f,l)+"\n"}if("05"==c)return n+"NULL\n";if("06"==c){var g=s(u,r),y=d.asn1.ASN1Util.oidHexToInt(g),m=d.asn1.x509.OID.oid2name(y),v=y.replace(/\./g," ");return""!=m?n+"ObjectIdentifier "+m+" ("+v+")\n":n+"ObjectIdentifier ("+v+")\n"}if("0a"==c)return n+"ENUMERATED "+parseInt(s(u,r))+"\n";if("0c"==c)return n+"UTF8String '"+ut(s(u,r))+"'\n";if("13"==c)return n+"PrintableString '"+ut(s(u,r))+"'\n";if("14"==c)return n+"TeletexString '"+ut(s(u,r))+"'\n";if("16"==c)return n+"IA5String '"+ut(s(u,r))+"'\n";if("17"==c)return n+"UTCTime "+ut(s(u,r))+"\n";if("18"==c)return n+"GeneralizedTime "+ut(s(u,r))+"\n";if("1a"==c)return n+"VisualString '"+ut(s(u,r))+"'\n";if("1e"==c)return n+"BMPString '"+gt(s(u,r))+"'\n";if("30"==c){if("3000"==u.substr(r,4))return n+"SEQUENCE {}\n";p=n+"SEQUENCE\n";var x=e;if((2==(S=a(u,r)).length||3==S.length)&&"06"==u.substr(S[0],2)&&"04"==u.substr(S[S.length-1],2)){m=i.oidname(s(u,S[0]));var b=JSON.parse(JSON.stringify(e));b.x509ExtName=m,x=b}for(var w=0;w<S.length;w++)p+=o(u,x,S[w],n+" ");return p}if("31"==c){p=n+"SET\n";var S=a(u,r);for(w=0;w<S.length;w++)p+=o(u,e,S[w],n+" ");return p}if(0!=(128&(c=parseInt(c,16)))){var E=31&c;if(0!=(32&c)){for(p=n+"["+E+"]\n",S=a(u,r),w=0;w<S.length;w++)p+=o(u,e,S[w],n+" ");return p}f=s(u,r);if(Tt.isASN1HEX(f)){var p=n+"["+E+"]\n";return p+=o(f,e,0,n+" ")}return("68747470"==f.substr(0,8)||"subjectAltName"===e.x509ExtName&&2==E)&&(f=ut(f)),p=n+"["+E+"] "+f+"\n"}return n+"UNKNOWN("+c+") "+s(u,r)+"\n"},Tt.isContextTag=function(t,e){var r,n;t=t.toLowerCase();try{r=parseInt(t,16)}catch(t){return-1}if(void 0===e)return 128==(192&r);try{return null!=e.match(/^\[[0-9]+\]$/)&&(!((n=parseInt(e.substr(1,e.length-1),10))>31)&&(128==(192&r)&&(31&r)==n))}catch(t){return!1}},Tt.isASN1HEX=function(t){var e=Tt;if(t.length%2==1)return!1;var r=e.getVblen(t,0),n=t.substr(0,2),i=e.getL(t,0);return t.length-n.length-i.length==2*r},Tt.checkStrictDER=function(t,e,r,n,i){var s=Tt;if(void 0===r){if("string"!=typeof t)throw new Error("not hex string");if(t=t.toLowerCase(),!d.lang.String.isHex(t))throw new Error("not hex string");r=t.length,i=(n=t.length/2)<128?1:Math.ceil(n.toString(16))+1}if(s.getL(t,e).length>2*i)throw new Error("L of TLV too long: idx="+e);var o=s.getVblen(t,e);if(o>n)throw new Error("value of L too long than hex: idx="+e);var a=s.getTLV(t,e),u=a.length-2-s.getL(t,e).length;if(u!==2*o)throw new Error("V string length and L's value not the same:"+u+"/"+2*o);if(0===e&&t.length!=a.length)throw new Error("total length and TLV length unmatch:"+t.length+"!="+a.length);var h=t.substr(e,2);if("02"===h){var c=s.getVidx(t,e);if("00"==t.substr(c,2)&&t.charCodeAt(c+2)<56)throw new Error("not least zeros for DER INTEGER")}if(32&parseInt(h,16)){for(var l=s.getVblen(t,e),f=0,p=s.getChildIdx(t,e),g=0;g<p.length;g++){f+=s.getTLV(t,p[g]).length,s.checkStrictDER(t,p[g],r,n,i)}if(2*l!=f)throw new Error("sum of children's TLV length and L unmatch: "+2*l+"!="+f)}},Tt.oidname=function(t){var e=d.asn1;d.lang.String.isHex(t)&&(t=e.ASN1Util.oidHexToInt(t));var r=e.x509.OID.oid2name(t);return""===r&&(r=t),r},void 0!==d.asn1&&d.asn1||(d.asn1={}),void 0!==d.asn1.x509&&d.asn1.x509||(d.asn1.x509={}),d.asn1.x509.Certificate=function(t){d.asn1.x509.Certificate.superclass.constructor.call(this);var e=d.asn1,r=e.DERBitString,n=e.DERSequence,i=e.x509,s=i.TBSCertificate,o=i.AlgorithmIdentifier;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=this.params,e=t.sigalg;null!=t.sigalg.name&&(e=t.sigalg.name);var r=t.tbsobj.getEncodedHex(),n=new d.crypto.Signature({alg:e});n.init(t.cakey),n.updateHex(r),t.sighex=n.sign()},this.getPEM=function(){return ft(this.getEncodedHex(),"CERTIFICATE")},this.getEncodedHex=function(){var t=this.params;if(null!=t.tbsobj&&null!=t.tbsobj||(t.tbsobj=new s(t)),null==t.sighex&&null!=t.cakey&&this.sign(),null==t.sighex)throw new Error("sighex or cakey parameter not defined");var e=[];return e.push(t.tbsobj),e.push(new o({name:t.sigalg})),e.push(new r({hex:"00"+t.sighex})),new n({array:e}).getEncodedHex()},null!=t&&(this.params=t)},xt(d.asn1.x509.Certificate,d.asn1.ASN1Object),d.asn1.x509.TBSCertificate=function(t){d.asn1.x509.TBSCertificate.superclass.constructor.call(this);var e=d.asn1,r=e.x509,n=e.DERTaggedObject,i=e.DERInteger,s=e.DERSequence,o=r.AlgorithmIdentifier,a=r.Time,u=r.X500Name,h=r.Extensions,c=r.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(t){this.params=t},this.getEncodedHex=function(){var t=[],e=this.params;if(null!=e.version||1!=e.version){var r=2;null!=e.version&&(r=e.version-1);var l=new n({obj:new i({int:r})});t.push(l)}return t.push(new i(e.serial)),t.push(new o({name:e.sigalg})),t.push(new u(e.issuer)),t.push(new s({array:[new a(e.notbefore),new a(e.notafter)]})),t.push(new u(e.subject)),t.push(new c(Ot.getKey(e.sbjpubkey))),void 0!==e.ext&&e.ext.length>0&&t.push(new n({tag:"a3",obj:new h(e.ext)})),new d.asn1.DERSequence({array:t}).getEncodedHex()},void 0!==t&&this.setByParam(t)},xt(d.asn1.x509.TBSCertificate,d.asn1.ASN1Object),d.asn1.x509.Extensions=function(t){d.asn1.x509.Extensions.superclass.constructor.call(this);var e=d.asn1,r=e.DERSequence,n=e.x509;this.aParam=[],this.setByParam=function(t){this.aParam=t},this.getEncodedHex=function(){for(var t=[],e=0;e<this.aParam.length;e++){var i=this.aParam[e],s=i.extname,o=null;if(null!=i.extn)o=new n.PrivateExtension(i);else if("subjectKeyIdentifier"==s)o=new n.SubjectKeyIdentifier(i);else if("keyUsage"==s)o=new n.KeyUsage(i);else if("subjectAltName"==s)o=new n.SubjectAltName(i);else if("issuerAltName"==s)o=new n.IssuerAltName(i);else if("basicConstraints"==s)o=new n.BasicConstraints(i);else if("cRLDistributionPoints"==s)o=new n.CRLDistributionPoints(i);else if("certificatePolicies"==s)o=new n.CertificatePolicies(i);else if("authorityKeyIdentifier"==s)o=new n.AuthorityKeyIdentifier(i);else if("extKeyUsage"==s)o=new n.ExtKeyUsage(i);else if("authorityInfoAccess"==s)o=new n.AuthorityInfoAccess(i);else if("cRLNumber"==s)o=new n.CRLNumber(i);else if("cRLReason"==s)o=new n.CRLReason(i);else if("ocspNonce"==s)o=new n.OCSPNonce(i);else if("ocspNoCheck"==s)o=new n.OCSPNoCheck(i);else if("adobeTimeStamp"==s)o=new n.AdobeTimeStamp(i);else{if("subjectDirectoryAttributes"!=s)throw new Error("extension not supported:"+JSON.stringify(i));o=new n.SubjectDirectoryAttributes(i)}null!=o&&t.push(o)}return new r({array:t}).getEncodedHex()},null!=t&&this.setByParam(t)},xt(d.asn1.x509.Extensions,d.asn1.ASN1Object),d.asn1.x509.Extension=function(t){d.asn1.x509.Extension.superclass.constructor.call(this);var e=d.asn1,r=e.DERObjectIdentifier,n=e.DEROctetString;e.DERBitString;var i=e.DERBoolean,s=e.DERSequence;this.getEncodedHex=function(){var t=new r({oid:this.oid}),e=new n({hex:this.getExtnValueHex()}),o=new Array;return o.push(t),this.critical&&o.push(new i),o.push(e),new s({array:o}).getEncodedHex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},xt(d.asn1.x509.Extension,d.asn1.ASN1Object),d.asn1.x509.KeyUsage=function(t){d.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=kt.KEYUSAGE_NAME;if(this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.15",void 0!==t&&(void 0!==t.bin&&(this.asn1ExtnValue=new d.asn1.DERBitString(t)),void 0!==t.names&&void 0!==t.names.length)){for(var r=t.names,n="000000000",i=0;i<r.length;i++)for(var s=0;s<e.length;s++)r[i]===e[s]&&(n=n.substring(0,s)+"1"+n.substring(s+1,n.length));this.asn1ExtnValue=new d.asn1.DERBitString({bin:n})}},xt(d.asn1.x509.KeyUsage,d.asn1.x509.Extension),d.asn1.x509.BasicConstraints=function(t){d.asn1.x509.BasicConstraints.superclass.constructor.call(this,t);var e=d.asn1,r=e.DERBoolean,n=e.DERInteger,i=e.DERSequence;this.getExtnValueHex=function(){var t=new Array;this.cA&&t.push(new r),this.pathLen>-1&&t.push(new n({int:this.pathLen}));var e=new i({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen&&(this.pathLen=t.pathLen))},xt(d.asn1.x509.BasicConstraints,d.asn1.x509.Extension),d.asn1.x509.CRLDistributionPoints=function(t){d.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=d.asn1,r=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(t){for(var n=[],i=0;i<t.length;i++)if(t[i]instanceof d.asn1.ASN1Object)n.push(t[i]);else{var s=new r.DistributionPoint(t[i]);n.push(s)}this.asn1ExtnValue=new e.DERSequence({array:n})},this.setByOneURI=function(t){var e=new r.DistributionPoint({fulluri:t});this.setByDPArray([e])},this.oid="2.5.29.31",void 0!==t&&(void 0!==t.array?this.setByDPArray(t.array):void 0!==t.uri&&this.setByOneURI(t.uri))},xt(d.asn1.x509.CRLDistributionPoints,d.asn1.x509.Extension),d.asn1.x509.DistributionPoint=function(t){d.asn1.x509.DistributionPoint.superclass.constructor.call(this);var e=d.asn1,r=e.x509.DistributionPointName;this.getEncodedHex=function(){var t=new e.DERSequence;if(null!=this.asn1DP){var r=new e.DERTaggedObject({explicit:!0,tag:"a0",obj:this.asn1DP});t.appendASN1Object(r)}return this.hTLV=t.getEncodedHex(),this.hTLV},void 0!==t&&(void 0!==t.dpobj?this.asn1DP=t.dpobj:void 0!==t.dpname?this.asn1DP=new r(t.dpname):void 0!==t.fulluri&&(this.asn1DP=new r({full:[{uri:t.fulluri}]})))},xt(d.asn1.x509.DistributionPoint,d.asn1.ASN1Object),d.asn1.x509.DistributionPointName=function(t){d.asn1.x509.DistributionPointName.superclass.constructor.call(this);var e=d.asn1,r=e.DERTaggedObject;if(this.getEncodedHex=function(){if("full"!=this.type)throw new Error("currently type shall be 'full': "+this.type);return this.asn1Obj=new r({explicit:!1,tag:this.tag,obj:this.asn1V}),this.hTLV=this.asn1Obj.getEncodedHex(),this.hTLV},void 0!==t)if(e.x509.GeneralNames.prototype.isPrototypeOf(t))this.type="full",this.tag="a0",this.asn1V=t;else{if(void 0===t.full)throw new Error("This class supports GeneralNames only as argument");this.type="full",this.tag="a0",this.asn1V=new e.x509.GeneralNames(t.full)}},xt(d.asn1.x509.DistributionPointName,d.asn1.ASN1Object),d.asn1.x509.CertificatePolicies=function(t){d.asn1.x509.CertificatePolicies.superclass.constructor.call(this,t);var e=d.asn1,r=e.x509,n=e.DERSequence,i=r.PolicyInformation;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++)t.push(new i(this.params.array[e]));var r=new n({array:t});return this.asn1ExtnValue=r,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.32",void 0!==t&&(this.params=t)},xt(d.asn1.x509.CertificatePolicies,d.asn1.x509.Extension),d.asn1.x509.PolicyInformation=function(t){d.asn1.x509.PolicyInformation.superclass.constructor.call(this,t);var e=d.asn1,r=e.DERSequence,n=e.DERObjectIdentifier,i=e.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 t=[new n(this.params.policyoid)];if(void 0!==this.params.array){for(var e=[],s=0;s<this.params.array.length;s++)e.push(new i(this.params.array[s]));e.length>0&&t.push(new r({array:e}))}return new r({array:t}).getEncodedHex()},void 0!==t&&(this.params=t)},xt(d.asn1.x509.PolicyInformation,d.asn1.ASN1Object),d.asn1.x509.PolicyQualifierInfo=function(t){d.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,t);var e=d.asn1,r=e.DERSequence,n=e.DERIA5String,i=e.DERObjectIdentifier,s=e.x509.UserNotice;this.params=null,this.getEncodedHex=function(){return void 0!==this.params.cps?new r({array:[new i({oid:"1.3.6.1.5.5.7.2.1"}),new n({str:this.params.cps})]}).getEncodedHex():null!=this.params.unotice?new r({array:[new i({oid:"1.3.6.1.5.5.7.2.2"}),new s(this.params.unotice)]}).getEncodedHex():void 0},void 0!==t&&(this.params=t)},xt(d.asn1.x509.PolicyQualifierInfo,d.asn1.ASN1Object),d.asn1.x509.UserNotice=function(t){d.asn1.x509.UserNotice.superclass.constructor.call(this,t);var e=d.asn1.DERSequence;d.asn1.DERInteger;var r=d.asn1.x509.DisplayText,n=d.asn1.x509.NoticeReference;this.params=null,this.getEncodedHex=function(){var t=[];return void 0!==this.params.noticeref&&t.push(new n(this.params.noticeref)),void 0!==this.params.exptext&&t.push(new r(this.params.exptext)),new e({array:t}).getEncodedHex()},void 0!==t&&(this.params=t)},xt(d.asn1.x509.UserNotice,d.asn1.ASN1Object),d.asn1.x509.NoticeReference=function(t){d.asn1.x509.NoticeReference.superclass.constructor.call(this,t);var e=d.asn1.DERSequence,r=d.asn1.DERInteger,n=d.asn1.x509.DisplayText;this.params=null,this.getEncodedHex=function(){var t=[];if(void 0!==this.params.org&&t.push(new n(this.params.org)),void 0!==this.params.noticenum){for(var i=[],s=this.params.noticenum,o=0;o<s.length;o++)i.push(new r(s[o]));t.push(new e({array:i}))}if(0==t.length)throw new Error("parameter is empty");return new e({array:t}).getEncodedHex()},void 0!==t&&(this.params=t)},xt(d.asn1.x509.NoticeReference,d.asn1.ASN1Object),d.asn1.x509.DisplayText=function(t){d.asn1.x509.DisplayText.superclass.constructor.call(this,t),this.hT="0c",void 0!==t&&("ia5"===t.type?this.hT="16":"vis"===t.type?this.hT="1a":"bmp"===t.type&&(this.hT="1e"))},xt(d.asn1.x509.DisplayText,d.asn1.DERAbstractString),d.asn1.x509.ExtKeyUsage=function(t){d.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=d.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new e.DERSequence;for(var r=0;r<t.length;r++){var n=new e.DERObjectIdentifier(t[r]);this.asn1ExtnValue.appendASN1Object(n)}},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.37",void 0!==t&&void 0!==t.array&&this.setPurposeArray(t.array)},xt(d.asn1.x509.ExtKeyUsage,d.asn1.x509.Extension),d.asn1.x509.AuthorityKeyIdentifier=function(t){d.asn1.x509.AuthorityKeyIdentifier.superclass.constructor.call(this,t);var e=d,r=e.asn1,n=r.DERTaggedObject,i=r.x509.GeneralNames;e.crypto.Util.isKey,this.asn1KID=null,this.asn1CertIssuer=null,this.asn1CertSN=null,this.getExtnValueHex=function(){var t=new Array;this.asn1KID&&t.push(new n({explicit:!1,tag:"80",obj:this.asn1KID})),this.asn1CertIssuer&&t.push(new n({explicit:!1,tag:"a1",obj:new i([{dn:this.asn1CertIssuer}])})),this.asn1CertSN&&t.push(new n({explicit:!1,tag:"82",obj:this.asn1CertSN}));var e=new r.DERSequence({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.setKIDByParam=function(t){if(void 0!==t.str||void 0!==t.hex)this.asn1KID=new d.asn1.DEROctetString(t);else if("object"==typeof t&&d.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN ")){var e=t;"string"==typeof t&&(e=Ot.getKey(t));var r=Ot.getKeyID(e);this.asn1KID=new d.asn1.DEROctetString({hex:r})}},this.setCertIssuerByParam=function(t){void 0!==t.str||void 0!==t.ldapstr||void 0!==t.hex||void 0!==t.certsubject||void 0!==t.certissuer?this.asn1CertIssuer=new d.asn1.x509.X500Name(t):"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&-1!=t.indexOf("CERTIFICATE")&&(this.asn1CertIssuer=new d.asn1.x509.X500Name({certissuer:t}))},this.setCertSNByParam=function(t){if(void 0!==t.str||void 0!==t.bigint||void 0!==t.hex)this.asn1CertSN=new d.asn1.DERInteger(t);else if("string"==typeof t&&-1!=t.indexOf("BEGIN ")&&t.indexOf("CERTIFICATE")){var e=new kt;e.readCertPEM(t);var r=e.getSerialNumberHex();this.asn1CertSN=new d.asn1.DERInteger({hex:r})}},this.oid="2.5.29.35",void 0!==t&&(void 0!==t.kid&&this.setKIDByParam(t.kid),void 0!==t.issuer&&this.setCertIssuerByParam(t.issuer),void 0!==t.sn&&this.setCertSNByParam(t.sn),void 0!==t.issuersn&&"string"==typeof t.issuersn&&-1!=t.issuersn.indexOf("BEGIN ")&&t.issuersn.indexOf("CERTIFICATE")&&(this.setCertSNByParam(t.issuersn),this.setCertIssuerByParam(t.issuersn)))},xt(d.asn1.x509.AuthorityKeyIdentifier,d.asn1.x509.Extension),d.asn1.x509.SubjectKeyIdentifier=function(t){d.asn1.x509.SubjectKeyIdentifier.superclass.constructor.call(this,t);var e=d.asn1.DEROctetString;this.asn1KID=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=this.asn1KID,this.asn1ExtnValue.getEncodedHex()},this.setKIDByParam=function(t){if(void 0!==t.str||void 0!==t.hex)this.asn1KID=new e(t);else if("object"==typeof t&&d.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN")){var r=t;"string"==typeof t&&(r=Ot.getKey(t));var n=Ot.getKeyID(r);this.asn1KID=new d.asn1.DEROctetString({hex:n})}},this.oid="2.5.29.14",void 0!==t&&void 0!==t.kid&&this.setKIDByParam(t.kid)},xt(d.asn1.x509.SubjectKeyIdentifier,d.asn1.x509.Extension),d.asn1.x509.AuthorityInfoAccess=function(t){d.asn1.x509.AuthorityInfoAccess.superclass.constructor.call(this,t),this.setAccessDescriptionArray=function(t){for(var e=new Array,r=d.asn1,n=r.DERSequence,i=r.DERObjectIdentifier,s=r.x509.GeneralName,o=0;o<t.length;o++){var a,u=t[o];if(void 0!==u.ocsp)a=new n({array:[new i({oid:"1.3.6.1.5.5.7.48.1"}),new s({uri:u.ocsp})]});else{if(void 0===u.caissuer)throw new Error("unknown AccessMethod parameter: "+JSON.stringify(u));a=new n({array:[new i({oid:"1.3.6.1.5.5.7.48.2"}),new s({uri:u.caissuer})]})}e.push(a)}this.asn1ExtnValue=new n({array:e})},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.1.1",void 0!==t&&void 0!==t.array&&this.setAccessDescriptionArray(t.array)},xt(d.asn1.x509.AuthorityInfoAccess,d.asn1.x509.Extension),d.asn1.x509.SubjectAltName=function(t){d.asn1.x509.SubjectAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new d.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.17",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},xt(d.asn1.x509.SubjectAltName,d.asn1.x509.Extension),d.asn1.x509.IssuerAltName=function(t){d.asn1.x509.IssuerAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new d.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.18",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},xt(d.asn1.x509.IssuerAltName,d.asn1.x509.Extension),d.asn1.x509.SubjectDirectoryAttributes=function(t){d.asn1.x509.SubjectDirectoryAttributes.superclass.constructor.call(this,t);var e=d.asn1,r=e.DERSequence,n=e.ASN1Util.newObject,i=e.x509.OID.name2oid;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++){var s=this.params.array[e],o={seq:[{oid:"1.2.3.4"},{set:[{utf8str:"DE"}]}]};if("dateOfBirth"==s.attr)o.seq[0].oid=i(s.attr),o.seq[1].set[0]={gentime:s.str};else if("placeOfBirth"==s.attr)o.seq[0].oid=i(s.attr),o.seq[1].set[0]={utf8str:s.str};else if("gender"==s.attr)o.seq[0].oid=i(s.attr),o.seq[1].set[0]={prnstr:s.str};else if("countryOfCitizenship"==s.attr)o.seq[0].oid=i(s.attr),o.seq[1].set[0]={prnstr:s.str};else{if("countryOfResidence"!=s.attr)throw new Error("unsupported attribute: "+s.attr);o.seq[0].oid=i(s.attr),o.seq[1].set[0]={prnstr:s.str}}t.push(new n(o))}var a=new r({array:t});return this.asn1ExtnValue=a,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.9",void 0!==t&&(this.params=t)},xt(d.asn1.x509.SubjectDirectoryAttributes,d.asn1.x509.Extension),d.asn1.x509.PrivateExtension=function(t){d.asn1.x509.PrivateExtension.superclass.constructor.call(this,t);var e=d,r=e.lang.String.isHex,n=e.asn1,i=n.x509.OID.name2oid,s=n.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.oid=i(t.extname),this.params=t},this.getExtnValueHex=function(){if(null==this.params.extname||null==this.params.extn)throw new Error("extname or extnhex not specified");var t=this.params.extn;if("string"==typeof t&&r(t))return t;if("object"==typeof t)try{return s(t).getEncodedHex()}catch(t){}throw new Error("unsupported extn value")},null!=t&&this.setByParam(t)},xt(d.asn1.x509.PrivateExtension,d.asn1.x509.Extension),d.asn1.x509.CRL=function(t){d.asn1.x509.CRL.superclass.constructor.call(this);var e=d.asn1,r=e.DERSequence,n=e.DERBitString,i=e.x509,s=i.AlgorithmIdentifier,o=i.TBSCertList;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=new o(this.params).getEncodedHex(),e=new d.crypto.Signature({alg:this.params.sigalg});e.init(this.params.cakey),e.updateHex(t);var r=e.sign();this.params.sighex=r},this.getPEM=function(){return ft(this.getEncodedHex(),"X509 CRL")},this.getEncodedHex=function(){var t=this.params;if(null==t.tbsobj&&(t.tbsobj=new o(t)),null==t.sighex&&null!=t.cakey&&this.sign(),null==t.sighex)throw new Error("sighex or cakey parameter not defined");var e=[];return e.push(t.tbsobj),e.push(new s({name:t.sigalg})),e.push(new n({hex:"00"+t.sighex})),new r({array:e}).getEncodedHex()},null!=t&&(this.params=t)},xt(d.asn1.x509.CRL,d.asn1.ASN1Object),d.asn1.x509.TBSCertList=function(t){d.asn1.x509.TBSCertList.superclass.constructor.call(this);var e=d.asn1,r=e.DERInteger,n=e.DERSequence,i=e.DERTaggedObject;e.DERObjectIdentifier;var s=e.x509,o=s.AlgorithmIdentifier,a=s.Time,u=s.Extensions,h=s.X500Name;this.params=null,this.setByParam=function(t){this.params=t},this.getRevCertSequence=function(){for(var t=[],e=this.params.revcert,i=0;i<e.length;i++){var s=[new r(e[i].sn),new a(e[i].date)];null!=e[i].ext&&s.push(new u(e[i].ext)),t.push(new n({array:s}))}return new n({array:t})},this.getEncodedHex=function(){var t=[],e=this.params;if(null!=e.version){var s=e.version-1,c=new r({int:s});t.push(c)}if(t.push(new o({name:e.sigalg})),t.push(new h(e.issuer)),t.push(new a(e.thisupdate)),null!=e.nextupdate&&t.push(new a(e.nextupdate)),null!=e.revcert&&t.push(this.getRevCertSequence()),null!=e.ext){var l=new u(e.ext);t.push(new i({tag:"a0",explicit:!0,obj:l}))}return new n({array:t}).getEncodedHex()},void 0!==t&&this.setByParam(t)},xt(d.asn1.x509.TBSCertList,d.asn1.ASN1Object),d.asn1.x509.CRLEntry=function(t){d.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=d.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn&&this.setCertSerial(t.sn))},xt(d.asn1.x509.CRLEntry,d.asn1.ASN1Object),d.asn1.x509.CRLNumber=function(t){d.asn1.x509.CRLNumber.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new d.asn1.DERInteger(this.params.num),this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.20",null!=t&&(this.params=t)},xt(d.asn1.x509.CRLNumber,d.asn1.x509.Extension),d.asn1.x509.CRLReason=function(t){d.asn1.x509.CRLReason.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new d.asn1.DEREnumerated(this.params.code),this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.21",null!=t&&(this.params=t)},xt(d.asn1.x509.CRLReason,d.asn1.x509.Extension),d.asn1.x509.OCSPNonce=function(t){d.asn1.x509.OCSPNonce.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new d.asn1.DEROctetString(this.params),this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.48.1.2",null!=t&&(this.params=t)},xt(d.asn1.x509.OCSPNonce,d.asn1.x509.Extension),d.asn1.x509.OCSPNoCheck=function(t){d.asn1.x509.OCSPNoCheck.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new d.asn1.DERNull,this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.48.1.5",null!=t&&(this.params=t)},xt(d.asn1.x509.OCSPNoCheck,d.asn1.x509.Extension),d.asn1.x509.AdobeTimeStamp=function(t){d.asn1.x509.AdobeTimeStamp.superclass.constructor.call(this,t);var e=d.asn1,r=e.DERInteger,n=e.DERBoolean,i=e.DERSequence,s=e.x509.GeneralName;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[new r(1)];return e.push(new s({uri:t.uri})),null!=t.reqauth&&e.push(new n(t.reqauth)),this.asn1ExtnValue=new i({array:e}),this.asn1ExtnValue.getEncodedHex()},this.oid="1.2.840.113583.1.1.9.1",void 0!==t&&this.setByParam(t)},xt(d.asn1.x509.AdobeTimeStamp,d.asn1.x509.Extension),d.asn1.x509.X500Name=function(t){d.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=d.asn1,r=e.x509,n=r.RDN;this.setByString=function(t,e){void 0!==e&&(this.sRule=e);var r=t.split("/");r.shift();for(var i=[],s=0;s<r.length;s++)if(r[s].match(/^[^=]+=.+$/))i.push(r[s]);else{var o=i.length-1;i[o]=i[o]+"/"+r[s]}for(s=0;s<i.length;s++)this.asn1Array.push(new n({str:i[s],rule:this.sRule}))},this.setByLdapString=function(t,e){void 0!==e&&(this.sRule=e);var n=r.X500Name.ldapToCompat(t);this.setByString(n,e)},this.setByObject=function(t,e){for(var r in void 0!==e&&(this.sRule=e),t)if(t.hasOwnProperty(r)){var i=new n({str:r+"="+t[r],rule:this.sRule});this.asn1Array?this.asn1Array.push(i):this.asn1Array=[i]}},this.setByParam=function(t){var e;(void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.array)?this.paramArray=t.array:void 0!==t.str?this.setByString(t.str):void 0!==t.ldapstr?this.setByLdapString(t.ldapstr):void 0!==t.hex?this.hTLV=t.hex:void 0!==t.certissuer?((e=new kt).readCertPEM(t.certissuer),this.hTLV=e.getIssuerHex()):void 0!==t.certsubject?((e=new kt).readCertPEM(t.certsubject),this.hTLV=e.getSubjectHex()):"object"==typeof t&&void 0===t.certsubject&&void 0===t.certissuer&&this.setByObject(t)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(0==this.asn1Array.length&&this.paramArray.length>0)for(var t=0;t<this.paramArray.length;t++){var r={array:this.paramArray[t]};"utf8"!=this.sRule&&(r.rule=this.sRule);var i=new n(r);this.asn1Array.push(i)}var s=new e.DERSequence({array:this.asn1Array});return this.hTLV=s.getEncodedHex(),this.hTLV},void 0!==t&&this.setByParam(t)},xt(d.asn1.x509.X500Name,d.asn1.ASN1Object),d.asn1.x509.X500Name.compatToLDAP=function(t){if("/"!==t.substr(0,1))throw"malformed input";var e=(t=t.substr(1)).split("/");return e.reverse(),(e=e.map((function(t){return t.replace(/,/,"\\,")}))).join(",")},d.asn1.x509.X500Name.onelineToLDAP=function(t){return d.asn1.x509.X500Name.compatToLDAP(t)},d.asn1.x509.X500Name.ldapToCompat=function(t){for(var e=t.split(","),r=!1,n=[],i=0;e.length>0;i++){var s=e.shift();if(!0===r){var o=(n.pop()+","+s).replace(/\\,/g,",");n.push(o),r=!1}else n.push(s);"\\"===s.substr(-1,1)&&(r=!0)}return(n=n.map((function(t){return t.replace("/","\\/")}))).reverse(),"/"+n.join("/")},d.asn1.x509.X500Name.ldapToOneline=function(t){return d.asn1.x509.X500Name.ldapToCompat(t)},d.asn1.x509.RDN=function(t){d.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=d.asn1.x509.AttributeTypeAndValue;this.setByParam=function(t){void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.str&&this.addByMultiValuedString(t.str),void 0!==t.array&&(this.paramArray=t.array)},this.addByString=function(t){this.asn1Array.push(new d.asn1.x509.AttributeTypeAndValue({str:t,rule:this.sRule}))},this.addByMultiValuedString=function(t){for(var e=d.asn1.x509.RDN.parseString(t),r=0;r<e.length;r++)this.addByString(e[r])},this.getEncodedHex=function(){if(0==this.asn1Array.length&&this.paramArray.length>0)for(var t=0;t<this.paramArray.length;t++){var r=this.paramArray[t];void 0!==r.rule&&"utf8"!=this.sRule&&(r.rule=this.sRule);var n=new e(r);this.asn1Array.push(n)}var i=new d.asn1.DERSet({array:this.asn1Array});return this.TLV=i.getEncodedHex(),this.TLV},void 0!==t&&this.setByParam(t)},xt(d.asn1.x509.RDN,d.asn1.ASN1Object),d.asn1.x509.RDN.parseString=function(t){for(var e=t.split(/\+/),r=!1,n=[],i=0;e.length>0;i++){var s=e.shift();if(!0===r){var o=(n.pop()+"+"+s).replace(/\\\+/g,"+");n.push(o),r=!1}else n.push(s);"\\"===s.substr(-1,1)&&(r=!0)}var a=!1,u=[];for(i=0;n.length>0;i++){s=n.shift();if(!0===a){var h=u.pop();if(s.match(/"$/)){o=(h+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");u.push(o),a=!1}else u.push(h+"+"+s)}else u.push(s);s.match(/^[^=]+="/)&&(a=!0)}return u},d.asn1.x509.AttributeTypeAndValue=function(t){d.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var e=d,r=e.asn1,n=r.DERSequence,i=r.DERUTF8String,s=r.DERPrintableString,o=r.DERTeletexString,a=r.DERIA5String,u=r.DERVisibleString,h=r.DERBMPString,c=e.lang.String.isMail,l=e.lang.String.isPrintable;this.setByParam=function(t){if(void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.ds&&(this.dsType=t.ds),void 0===t.value&&void 0!==t.str){var e=t.str.match(/^([^=]+)=(.+)$/);if(!e)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.sType=e[1],this.sValue=e[2]}else this.sType=t.type,this.sValue=t.value},this.setByString=function(t,e){void 0!==e&&(this.sRule=e);var r=t.match(/^([^=]+)=(.+)$/);if(!r)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.setByAttrTypeAndValueStr(r[1],r[2])},this._getDsType=function(){var t=this.sType,e=this.sValue,r=this.sRule;return"prn"===r?"CN"==t&&c(e)?"ia5":l(e)?"prn":"utf8":"utf8"===r?"CN"==t&&c(e)?"ia5":"C"==t?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(t,e,r){void 0!==r&&(this.sRule=r),this.sType=t,this.sValue=e},this.getValueObj=function(t,e){if("utf8"==t)return new i({str:e});if("prn"==t)return new s({str:e});if("tel"==t)return new o({str:e});if("ia5"==t)return new a({str:e});if("vis"==t)return new u({str:e});if("bmp"==t)return new h({str:e});throw new Error("unsupported directory string type: type="+t+" value="+e)},this.getEncodedHex=function(){null==this.dsType&&(this.dsType=this._getDsType());var t=d.asn1.x509.OID.atype2obj(this.sType),e=this.getValueObj(this.dsType,this.sValue),r=new n({array:[t,e]});return this.TLV=r.getEncodedHex(),this.TLV},void 0!==t&&this.setByParam(t)},xt(d.asn1.x509.AttributeTypeAndValue,d.asn1.ASN1Object),d.asn1.x509.SubjectPublicKeyInfo=function(t){d.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=d,r=e.asn1,n=r.DERInteger,i=r.DERBitString,s=r.DERObjectIdentifier,o=r.DERSequence,a=r.ASN1Util.newObject,u=r.x509.AlgorithmIdentifier,h=e.crypto;h.ECDSA,h.DSA,this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new o({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.getEncodedHex=function(){var t=this.getASN1Object();return this.hTLV=t.getEncodedHex(),this.hTLV},this.setPubKey=function(t){try{if(t instanceof tt){var e=a({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).getEncodedHex();this.asn1AlgId=new u({name:"rsaEncryption"}),this.asn1SubjPKey=new i({hex:"00"+e})}}catch(t){}try{if(t instanceof d.crypto.ECDSA){var r=new s({name:t.curveName});this.asn1AlgId=new u({name:"ecPublicKey",asn1params:r}),this.asn1SubjPKey=new i({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof d.crypto.DSA){r=new a({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]});this.asn1AlgId=new u({name:"dsa",asn1params:r});var o=new n({bigint:t.y});this.asn1SubjPKey=new i({hex:"00"+o.getEncodedHex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},xt(d.asn1.x509.SubjectPublicKeyInfo,d.asn1.ASN1Object),d.asn1.x509.Time=function(t){d.asn1.x509.Time.superclass.constructor.call(this);var e=d.asn1,r=e.DERUTCTime,n=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.getEncodedHex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new r(this.timeParams):new n(this.timeParams):"utc"==this.type?new r:new n,this.TLV=t.getEncodedHex(),this.TLV},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=t)},xt(d.asn1.x509.Time,d.asn1.ASN1Object),d.asn1.x509.AlgorithmIdentifier=function(t){d.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=d.asn1,r=e.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 t=null;for(var n in r)n===this.nameAlg&&(t=r[n]);if(null!==t)return this.hTLV=t,this.hTLV}null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var i=[this.asn1Alg];null!==this.asn1Params&&i.push(this.asn1Params);var s=new e.DERSequence({array:i});return this.hTLV=s.getEncodedHex(),this.hTLV},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty&&(this.paramEmpty=t.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 e.DERNull)}},xt(d.asn1.x509.AlgorithmIdentifier,d.asn1.ASN1Object),d.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"},d.asn1.x509.GeneralName=function(t){d.asn1.x509.GeneralName.superclass.constructor.call(this);var e={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},r=d.asn1;r.DERSequence;var n=r.DEROctetString,i=r.DERIA5String,s=r.DERTaggedObject,o=r.ASN1Object,a=r.x509.X500Name,u=dt;this.explicit=!1,this.setByParam=function(t){var r=null;if(void 0!==t){if(void 0!==t.rfc822&&(this.type="rfc822",r=new i({str:t[this.type]})),void 0!==t.dns&&(this.type="dns",r=new i({str:t[this.type]})),void 0!==t.uri&&(this.type="uri",r=new i({str:t[this.type]})),void 0!==t.dn&&(this.type="dn",this.explicit=!0,r="string"==typeof t.dn?new a({str:t.dn}):t.dn instanceof d.asn1.x509.X500Name?t.dn:new a(t.dn)),void 0!==t.ldapdn&&(this.type="dn",this.explicit=!0,r=new a({ldapstr:t.ldapdn})),void 0!==t.certissuer){this.type="dn",this.explicit=!0;var h=null;if((l=t.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(h=u(l)),null==h)throw"certissuer param not cert";(f=new kt).hex=h;var c=f.getIssuerHex();(r=new o).hTLV=c}if(void 0!==t.certsubj){this.type="dn",this.explicit=!0;var l,f;h=null;if((l=t.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(h=u(l)),null==h)throw"certsubj param not cert";(f=new kt).hex=h;c=f.getSubjectHex();(r=new o).hTLV=c}if(void 0!==t.ip){this.type="ip",this.explicit=!1;var p,g=t.ip,y="malformed IP address";if(g.match(/^[0-9.]+[.][0-9.]+$/)){if(8!==(p=function(t){t=(t=(t=t.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return t.split(/,/).map((function(t,e,r){var n=parseInt(t);if(n<0||255<n)throw"integer not in range 0-255";return("00"+n.toString(16)).slice(-2)})).join("")}catch(t){throw"malformed integer array string: "+t}}("["+g.split(".").join(",")+"]")).length)throw y}else if(g.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))p=function(t){var e="malformed IPv6 address";if(!t.match(/^[0-9A-Fa-f:]+$/))throw e;var r=(t=t.toLowerCase()).split(":").length-1;if(r<2)throw e;var n=":".repeat(7-r+2),i=(t=t.replace("::",n)).split(":");if(8!=i.length)throw e;for(var s=0;s<8;s++)i[s]=("0000"+i[s]).slice(-4);return i.join("")}(g);else{if(!g.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw y;p=g}r=new n({hex:p})}if(null==this.type)throw"unsupported type in params="+t;this.asn1Obj=new s({explicit:this.explicit,tag:e[this.type],obj:r})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==t&&this.setByParam(t)},xt(d.asn1.x509.GeneralName,d.asn1.ASN1Object),d.asn1.x509.GeneralNames=function(t){d.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=d.asn1;this.setByParamArray=function(t){for(var r=0;r<t.length;r++){var n=new e.x509.GeneralName(t[r]);this.asn1Array.push(n)}},this.getEncodedHex=function(){return new e.DERSequence({array:this.asn1Array}).getEncodedHex()},this.asn1Array=new Array,void 0!==t&&this.setByParamArray(t)},xt(d.asn1.x509.GeneralNames,d.asn1.ASN1Object),d.asn1.x509.OID=new function(t){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(t){if(void 0!==this.objCache[t])return this.objCache[t];if(void 0===this.name2oidList[t])throw"Name of ObjectIdentifier not defined: "+t;var e=this.name2oidList[t],r=new d.asn1.DERObjectIdentifier({oid:e});return this.objCache[t]=r,r},this.atype2obj=function(t){if(void 0!==this.objCache[t])return this.objCache[t];var e;if(t.match(/^\d+\.\d+\.[0-9.]+$/))e=t;else if(void 0!==this.atype2oidList[t])e=this.atype2oidList[t];else{if(void 0===this.name2oidList[t])throw"AttributeType name undefined: "+t;e=this.name2oidList[t]}var r=new d.asn1.DERObjectIdentifier({oid:e});return this.objCache[t]=r,r}},d.asn1.x509.OID.oid2name=function(t){var e=d.asn1.x509.OID.name2oidList;for(var r in e)if(e[r]==t)return r;return""},d.asn1.x509.OID.oid2atype=function(t){var e=d.asn1.x509.OID.atype2oidList;for(var r in e)if(e[r]==t)return r;return t},d.asn1.x509.OID.name2oid=function(t){if(t.match(/^[0-9.]+$/))return t;var e=d.asn1.x509.OID.name2oidList;return void 0===e[t]?"":e[t]},d.asn1.x509.X509Util={},d.asn1.x509.X509Util.newCertPEM=function(t){var e=d.asn1.x509;return e.TBSCertificate,new(0,e.Certificate)(t).getPEM()},tt.getPosArrayOfChildrenFromHex=function(t){return Tt.getChildIdx(t,0)},tt.getHexValueArrayOfChildrenFromHex=function(t){var e,r=Tt.getV,n=r(t,(e=tt.getPosArrayOfChildrenFromHex(t))[0]),i=r(t,e[1]),s=r(t,e[2]),o=r(t,e[3]),a=r(t,e[4]),u=r(t,e[5]),h=r(t,e[6]),c=r(t,e[7]),l=r(t,e[8]);return(e=new Array).push(n,i,s,o,a,u,h,c,l),e},tt.prototype.readPrivateKeyFromPEMString=function(t){var e=dt(t),r=tt.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8])},tt.prototype.readPKCS5PrvKeyHex=function(t){var e=tt.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},tt.prototype.readPKCS8PrvKeyHex=function(t){var e,r,n,i,s,o,a,u,h=Tt,c=h.getVbyListEx;if(!1===h.isASN1HEX(t))throw new Error("not ASN.1 hex string");try{e=c(t,0,[2,0,1],"02"),r=c(t,0,[2,0,2],"02"),n=c(t,0,[2,0,3],"02"),i=c(t,0,[2,0,4],"02"),s=c(t,0,[2,0,5],"02"),o=c(t,0,[2,0,6],"02"),a=c(t,0,[2,0,7],"02"),u=c(t,0,[2,0,8],"02")}catch(t){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(e,r,n,i,s,o,a,u)},tt.prototype.readPKCS5PubKeyHex=function(t){var e=Tt,r=e.getV;if(!1===e.isASN1HEX(t))throw new Error("keyHex is not ASN.1 hex string");var n=e.getChildIdx(t,0);if(2!==n.length||"02"!==t.substr(n[0],2)||"02"!==t.substr(n[1],2))throw new Error("wrong hex for PKCS#5 public key");var i=r(t,n[0]),s=r(t,n[1]);this.setPublic(i,s)},tt.prototype.readPKCS8PubKeyHex=function(t){var e=Tt;if(!1===e.isASN1HEX(t))throw new Error("not ASN.1 hex string");if("06092a864886f70d010101"!==e.getTLVbyListEx(t,0,[0,0]))throw new Error("not PKCS8 RSA public key");var r=e.getTLVbyListEx(t,0,[1,0]);this.readPKCS5PubKeyHex(r)},tt.prototype.readCertPubKeyHex=function(t,e){var r,n;(r=new kt).readCertHex(t),n=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)},tt.prototype.sign=function(t,e){var r,n=(r=t,d.crypto.Util.hashString(r,e));return this.signWithMessageHash(n,e)},tt.prototype.signWithMessageHash=function(t,e){var r=$(d.crypto.Util.getPaddedDigestInfoHex(t,e,this.n.bitLength()),16);return Rt(this.doPrivate(r).toString(16),this.n.bitLength())},tt.prototype.signPSS=function(t,e,r){var n,i=(n=ct(t),d.crypto.Util.hashHex(n,e));return void 0===r&&(r=-1),this.signWithMessageHashPSS(i,e,r)},tt.prototype.signWithMessageHashPSS=function(t,e,r){var n,i=ht(t),s=i.length,o=this.n.bitLength()-1,a=Math.ceil(o/8),u=function(t){return d.crypto.Util.hashHex(t,e)};if(-1===r||void 0===r)r=s;else if(-2===r)r=a-s-2;else if(r<-2)throw new Error("invalid salt length");if(a<s+r+2)throw new Error("data too long");var h="";r>0&&(h=new Array(r),(new X).nextBytes(h),h=String.fromCharCode.apply(String,h));var c=ht(u(ct("\0\0\0\0\0\0\0\0"+i+h))),l=[];for(n=0;n<a-r-s-2;n+=1)l[n]=0;var f=String.fromCharCode.apply(String,l)+""+h,p=Ct(c,f.length,u),g=[];for(n=0;n<f.length;n+=1)g[n]=f.charCodeAt(n)^p.charCodeAt(n);var m=65280>>8*a-o&255;for(g[0]&=~m,n=0;n<s;n++)g.push(c.charCodeAt(n));return g.push(188),Rt(this.doPrivate(new y(g)).toString(16),this.n.bitLength())},tt.prototype.verify=function(t,e){if(null==(e=e.toLowerCase()).match(/^[0-9a-f]+$/))return!1;var r=$(e,16),n=this.n.bitLength();if(r.bitLength()>n)return!1;var i=this.doPublic(r).toString(16);if(i.length+3!=n/4)return!1;var s=It(i.replace(/^1f+00/,""));if(0==s.length)return!1;var o,a=s[0];return s[1]==(o=t,d.crypto.Util.hashString(o,a))},tt.prototype.verifyWithMessageHash=function(t,e){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=$(e,16);if(r.bitLength()>this.n.bitLength())return 0;var n=It(this.doPublic(r).toString(16).replace(/^1f+00/,""));return 0!=n.length&&(n[0],n[1]==t)},tt.prototype.verifyPSS=function(t,e,r,n){var i=function(t){return d.crypto.Util.hashHex(t,r)}(ct(t));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(i,e,r,n)},tt.prototype.verifyWithMessageHashPSS=function(t,e,r,n){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var i,s=new y(e,16),o=function(t){return d.crypto.Util.hashHex(t,r)},a=ht(t),u=a.length,h=this.n.bitLength()-1,c=Math.ceil(h/8);if(-1===n||void 0===n)n=u;else if(-2===n)n=c-u-2;else if(n<-2)throw new Error("invalid salt length");if(c<u+n+2)throw new Error("data too long");var l=this.doPublic(s).toByteArray();for(i=0;i<l.length;i+=1)l[i]&=255;for(;l.length<c;)l.unshift(0);if(188!==l[c-1])throw new Error("encoded message does not end in 0xbc");var f=(l=String.fromCharCode.apply(String,l)).substr(0,c-u-1),p=l.substr(f.length,u),g=65280>>8*c-h&255;if(0!=(f.charCodeAt(0)&g))throw new Error("bits beyond keysize not zero");var m=Ct(p,f.length,o),v=[];for(i=0;i<f.length;i+=1)v[i]=f.charCodeAt(i)^m.charCodeAt(i);v[0]&=~g;var x=c-u-n-2;for(i=0;i<x;i+=1)if(0!==v[i])throw new Error("leftmost octets not zero");if(1!==v[x])throw new Error("0x01 marker not found");return p===ht(o(ct("\0\0\0\0\0\0\0\0"+a+String.fromCharCode.apply(String,v.slice(-n)))))},tt.SALT_LEN_HLEN=-1,tt.SALT_LEN_MAX=-2,tt.SALT_LEN_RECOVER=-2,kt.hex2dn=function(t,e){void 0===e&&(e=0);var r=new kt;return Tt.getTLV(t,e),r.getX500Name(t).str},kt.hex2rdn=function(t,e){if(void 0===e&&(e=0),"31"!==t.substr(e,2))throw new Error("malformed RDN");for(var r=new Array,n=Tt.getChildIdx(t,e),i=0;i<n.length;i++)r.push(kt.hex2attrTypeValue(t,n[i]));return(r=r.map((function(t){return t.replace("+","\\+")}))).join("+")},kt.hex2attrTypeValue=function(t,e){var r=Tt,n=r.getV;if(void 0===e&&(e=0),"30"!==t.substr(e,2))throw new Error("malformed attribute type and value");var i=r.getChildIdx(t,e);2!==i.length||t.substr(i[0],2);var s=n(t,i[0]),o=d.asn1.ASN1Util.oidHexToInt(s);return d.asn1.x509.OID.oid2atype(o)+"="+ht(n(t,i[1]))},kt.getPublicKeyFromCertHex=function(t){var e=new kt;return e.readCertHex(t),e.getPublicKey()},kt.getPublicKeyFromCertPEM=function(t){var e=new kt;return e.readCertPEM(t),e.getPublicKey()},kt.getPublicKeyInfoPropOfCertPEM=function(t){var e,r,n=Tt.getVbyList,i={};return i.algparam=null,(e=new kt).readCertPEM(t),r=e.getPublicKeyHex(),i.keyhex=n(r,0,[1],"03").substr(2),i.algoid=n(r,0,[0,0],"06"),"2a8648ce3d0201"===i.algoid&&(i.algparam=n(r,0,[0,1],"06")),i},kt.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"];var _t,Vt=[(_t=new kt,_t.readCertPEM(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=113,n=126,i=0,s="";return arguments[i].split(s).map((function(t){return t.charCodeAt(i)>n?t:String.fromCharCode((t.charCodeAt(i)+r)%n)})).join(s)}(":::::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:::::")),_t)];function Bt(t,e){var r=t.getIssuerHex();if(r===t.getSubjectHex())return t.verifySignature(t.getPublicKey());var n=function(t,e){for(var r=0,n=e;r<n.length;r++){var i=n[r];if(i.getSubjectHex()===t)return i}}(r,e);return!!n&&(!1!==t.verifySignature(n.getPublicKey())&&Bt(n,e))}function Ht(t){return t.getIssuerHex()!==t.getSubjectHex()&&Bt(t,Vt)}!function(t){var e=new kt;"string"==typeof t?e.readCertPEM(t):e.readCertHex(t.hex);var r=Ht(e);Vt.push(e)}(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=113,n=126,i=0,s="";return arguments[i].split(s).map((function(t){return t.charCodeAt(i)>n?t:String.fromCharCode((t.charCodeAt(i)+r)%n)})).join(s)}(":::::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 Mt,Kt,Lt,zt,Ft=function(){function t(t,e,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===r&&(r=0),this.x=t,this.y=e,this.z=r}return t.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},t.prototype.set=function(t,e,r){return this.x=t,this.y=e,this.z=r,this},t.prototype.fromArray=function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},t.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},t.prototype.multiplyScalar=function(t){return this.x*=t,this.y*=t,this.z*=t,this},t.prototype.subVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},t.prototype.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},t.prototype.cross=function(t){var e=this.x,r=this.y,n=this.z;return this.x=r*t.z-n*t.y,this.y=n*t.x-e*t.z,this.z=e*t.y-r*t.x,this},t.prototype.crossVectors=function(t,e){var r=t.x,n=t.y,i=t.z,s=e.x,o=e.y,a=e.z;return this.x=n*a-i*o,this.y=i*s-r*a,this.z=r*o-n*s,this},t.prototype.clone=function(){return new t(this.x,this.y,this.z)},t}(),Ut=function(){function t(t,e,r,n,i){this._extentsMin=t,this._extentsMax=e,this._startIndex=r,this._endIndex=n,this._level=i,this._node0=null,this._node1=null,this.elementCount=n-r,this.center=[(t.x+e.x)/2,(t.y+e.y)/2,(t.z+e.z)/2];var s,o=this.size=[e.x-t.x,e.y-t.y,e.z-t.z];s=o[0]>o[1]?o[1]>o[2]?[2,1,0]:o[0]>o[2]?[1,2,0]:[1,0,2]:o[1]>o[2]?o[0]>o[2]?[2,0,1]:[0,2,1]:[0,1,2],this.order=s}return t.prototype.clearShapes=function(){this._startIndex=-1,this._endIndex=-1,this.elementCount=0},t}(),qt=(Mt=new Ft,Kt=new Ft,Lt=new Ft,zt=new Ft,function(t,e,r,n,i,s){Kt.subVectors(e,t),Lt.subVectors(r,t),zt.crossVectors(Kt,Lt);var o,a=i.dot(zt);if(a>0){if(s)return null;o=1}else{if(!(a<0))return null;o=-1,a=-a}Mt.subVectors(n,t);var u=o*i.dot(Lt.crossVectors(Mt,Lt));if(u<0)return null;var h=o*i.dot(Kt.cross(Mt));if(h<0)return null;if(u+h>a)return null;var c=-o*Mt.dot(zt);if(c<0)return null;var l=c/a;return(new Ft).copy(i).multiplyScalar(l).add(n)});function Gt(t,e,r){var n={min:0,max:0};e.x>=0?(n.min=(r._extentsMin.x-t.x)*e.x,n.max=(r._extentsMax.x-t.x)*e.x):(n.min=(r._extentsMax.x-t.x)*e.x,n.max=(r._extentsMin.x-t.x)*e.x);var i={min:0,max:0};if(e.y>=0?(i.min=(r._extentsMin.y-t.y)*e.y,i.max=(r._extentsMax.y-t.y)*e.y):(i.min=(r._extentsMax.y-t.y)*e.y,i.max=(r._extentsMin.y-t.y)*e.y),n.min>i.max||i.min>n.max)return!1;i.min>n.min&&(n.min=i.min),i.max<n.max&&(n.max=i.max);var s={min:0,max:0};return e.z>=0?(s.min=(r._extentsMin.z-t.z)*e.z,s.max=(r._extentsMax.z-t.z)*e.z):(s.min=(r._extentsMax.z-t.z)*e.z,s.max=(r._extentsMin.z-t.z)*e.z),!(n.min>s.max||s.min>n.max)&&(s.min>n.min&&(n.min=s.min),s.max<n.max&&(n.max=s.max),!(n.max<0))}var Qt=function(){function t(t,e){void 0===e&&(e=10),this._trianglesArray=t,this._maxTrianglesPerNode=e,this._bboxArray=this.calcBoundingBoxes(t),this._bboxHelper=new Float32Array(this._bboxArray.length),this._bboxHelper.set(this._bboxArray);var r=t.length/9,n=this.calcExtents(0,r,1e-6);this._rootNode=new Ut(n[0],n[1],0,r,0),this._nodesToSplit=[this._rootNode],this.splitNode()}return t.prototype.calcBoundingBoxes=function(t){for(var e,r,n,i,s,o,a,u,h,c,l,f,d,p,g,y=t.length/9,m=new Float32Array(7*y),v=0,x=0,b=0;b<y;v+=9,x+=7,b++)e=t[v],r=t[v+1],n=t[v+2],i=t[v+3],s=t[v+4],o=t[v+5],i<(c=e)&&(c=i),(a=t[v+6])<c&&(c=a),s<(l=r)&&(l=s),(u=t[v+7])<l&&(l=u),o<(f=n)&&(f=o),(h=t[v+8])<f&&(f=h),i>(d=e)&&(d=i),a>d&&(d=a),s>(p=r)&&(p=s),u>p&&(p=u),o>(g=n)&&(g=o),h>g&&(g=h),m[x]=b,m[x+1]=c,m[x+2]=l,m[x+3]=f,m[x+4]=d,m[x+5]=p,m[x+6]=g;return m},t.prototype.splitNode=function(){if(this._rootNode)for(this._splitNode(this._rootNode);this._nodesToSplit.length>0;)this._splitNode(this._nodesToSplit.pop())},t.prototype._splitNode=function(t){if(!(t.elementCount<=this._maxTrianglesPerNode||0===t.elementCount)){for(var e=t._startIndex,r=t._endIndex,n=[[],[],[]],i=[[],[],[]],s=t.center,o=7*(b=e);b<r;b++,o+=7)for(var a=0;a<3;a++)(this._bboxArray[o+1+a]+this._bboxArray[o+4+a])/2<s[a]?n[a][n[a].length]=b:i[a][i[a].length]=b;var u=[!(n[0].length&i[0].length),!(n[1].length&i[1].length),!(n[2].length&i[2].length)];if(!(u[0]&u[1]&u[2])){var h,c,l=t.order;for(a=0;a<3;a++){var f=l[a];if(!u[f]){h=n[f],c=i[f];break}}for(var d,p=e,g=p+h.length,y=g,m=r,v=t._startIndex,x=h.concat(c),b=0;b<x.length;b++)d=x[b],this._bboxHelper[7*v]=this._bboxArray[7*d],this._bboxHelper[7*v+1]=this._bboxArray[7*d+1],this._bboxHelper[7*v+2]=this._bboxArray[7*d+2],this._bboxHelper[7*v+3]=this._bboxArray[7*d+3],this._bboxHelper[7*v+4]=this._bboxArray[7*d+4],this._bboxHelper[7*v+5]=this._bboxArray[7*d+5],this._bboxHelper[7*v+6]=this._bboxArray[7*d+6],v++;var w=this._bboxHelper.subarray(7*t._startIndex,7*t._endIndex);this._bboxArray.set(w,7*t._startIndex);var S=this.calcExtents(p,g,1e-6),E=this.calcExtents(y,m,1e-6),A=new Ut(S[0],S[1],p,g,t._level+1),P=new Ut(E[0],E[1],y,m,t._level+1);t._node0=A,t._node1=P,t.clearShapes(),this._nodesToSplit.push(A,P)}}},t.prototype.calcExtents=function(t,e,r){if(t>=e)return[{x:0,y:0,z:0},{x:0,y:0,z:0}];var n,i=7*t,s=7*e+1,o=this._bboxArray[i+1],a=this._bboxArray[i+2],u=this._bboxArray[i+3],h=this._bboxArray[i+4],c=this._bboxArray[i+5],l=this._bboxArray[i+6],f=this._bboxArray;for(i+=7;i<s;i+=7)(n=f[i+1])<o&&(o=n),(n=f[i+2])<a&&(a=n),(n=f[i+3])<u&&(u=n),(n=f[i+4])>h&&(h=n),(n=f[i+5])>c&&(c=n),(n=f[i+6])>l&&(l=n);return[{x:o-r,y:a-r,z:u-r},{x:h+r,y:c+r,z:l+r}]},t.prototype.intersectRay=function(t,e,r){for(var n=[this._rootNode],i=[],s=[],o=new Ft(1/e.x,1/e.y,1/e.z);n.length>0;){var a=n.pop();if(Gt(t,o,a)){a._node0&&n.push(a._node0),a._node1&&n.push(a._node1);for(var u=a._startIndex;u<a._endIndex;u++)i.push(this._bboxArray[7*u])}}var h=new Ft,c=new Ft,l=new Ft,f=new Ft(t.x,t.y,t.z),d=new Ft(e.x,e.y,e.z);for(u=0;u<i.length;u++){var p=i[u];h.fromArray(this._trianglesArray,9*p),c.fromArray(this._trianglesArray,9*p+3),l.fromArray(this._trianglesArray,9*p+6);var g=qt(h,c,l,f,d,r);g&&s.push({triangle:[h.clone(),c.clone(),l.clone()],triangleIndex:p,intersectionPoint:g})}return s},t.prototype.dispose=function(){this._trianglesArray=new Float32Array,this._bboxArray=new Float32Array,this._bboxHelper=new Float32Array,this._rootNode=null,this._nodesToSplit.length=0},t}();function Zt(t){return null==t}var Yt={computeTangents:function(t){var e=t.index,r=t.attributes;if(null!==e&&void 0!==r.position&&void 0!==r.normal&&void 0!==r.uv){var n=e.array,i=r.position.array,s=r.normal.array,o=r.uv.array,u=i.length/3;void 0===r.tangent&&t.setAttribute("tangent",new a.BufferAttribute(new Float32Array(4*u),4));for(var h=r.tangent.array,c=[],l=[],f=0;f<u;f++)c[f]=new a.Vector3,l[f]=new a.Vector3;var d=new a.Vector3,p=new a.Vector3,g=new a.Vector3,y=new a.Vector2,m=new a.Vector2,v=new a.Vector2,x=new a.Vector3,b=new a.Vector3,w=t.groups;0===w.length&&(w=[{start:0,count:n.length}]);f=0;for(var S=w.length;f<S;++f)for(var E=k=(I=w[f]).start,A=k+I.count;E<A;E+=3)j(n[E+0],n[E+1],n[E+2]);var P,D,N,O=new a.Vector3,T=new a.Vector3,R=new a.Vector3,C=new a.Vector3;for(f=0,S=w.length;f<S;++f){var I,k;for(E=k=(I=w[f]).start,A=k+I.count;E<A;E+=3)_(n[E+0]),_(n[E+1]),_(n[E+2])}}else console.warn("THREE.BufferGeometry: Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");function j(t,e,r){d.fromArray(i,3*t),p.fromArray(i,3*e),g.fromArray(i,3*r),y.fromArray(o,2*t),m.fromArray(o,2*e),v.fromArray(o,2*r);var n=p.x-d.x,s=g.x-d.x,a=p.y-d.y,u=g.y-d.y,h=p.z-d.z,f=g.z-d.z,w=m.x-y.x,S=v.x-y.x,E=m.y-y.y,A=v.y-y.y,P=1/(w*A-S*E);x.set((A*n-E*s)*P,(A*a-E*u)*P,(A*h-E*f)*P),b.set((w*s-S*n)*P,(w*u-S*a)*P,(w*f-S*h)*P),c[t].add(x),c[e].add(x),c[r].add(x),l[t].add(b),l[e].add(b),l[r].add(b)}function _(t){R.fromArray(s,3*t),C.copy(R),D=c[t],O.copy(D),O.sub(R.multiplyScalar(R.dot(D))).normalize(),T.crossVectors(C,D),N=T.dot(l[t]),P=N<0?-1:1,h[4*t]=O.x,h[4*t+1]=O.y,h[4*t+2]=O.z,h[4*t+3]=P}},mergeBufferGeometries:function(t,e){for(var r=null!==t[0].index,n=new Set(Object.keys(t[0].attributes)),i=new Set(Object.keys(t[0].morphAttributes)),s={},o={},u=new a.BufferGeometry,h=0,c=0;c<t.length;++c){var l=t[c];if(r!==(null!==l.index))return null;for(var f in l.attributes){if(!n.has(f))return null;void 0===s[f]&&(s[f]=[]),s[f].push(l.attributes[f])}for(var f in l.morphAttributes){if(!i.has(f))return null;void 0===o[f]&&(o[f]=[]),o[f].push(l.morphAttributes[f])}if(u.userData.mergedUserData=u.userData.mergedUserData||[],u.userData.mergedUserData.push(l.userData),e){var d;if(r)d=l.index.count;else{if(void 0===l.attributes.position)return null;d=l.attributes.position.count}u.addGroup(h,d,c),h+=d}}if(r){var p=0,g=[];for(c=0;c<t.length;++c){for(var y=t[c].index,m=0;m<y.count;++m)g.push(y.getX(m)+p);p+=t[c].attributes.position.count}u.setIndex(g)}for(var f in s){var v=this.mergeBufferAttributes(s[f]);if(!v)return null;u.setAttribute(f,v)}for(var f in o){var x=o[f][0].length;if(0===x)break;u.morphAttributes=u.morphAttributes||{},u.morphAttributes[f]=[];for(c=0;c<x;++c){var b=[];for(m=0;m<o[f].length;++m)b.push(o[f][m][c]);var w=this.mergeBufferAttributes(b);if(!w)return null;u.morphAttributes[f].push(w)}}return u},mergeBufferAttributes:function(t){for(var e,r,n,i=0,s=0;s<t.length;++s){var o=t[s];if(o.isInterleavedBufferAttribute)return null;if(void 0===e&&(e=o.array.constructor),e!==o.array.constructor)return null;if(void 0===r&&(r=o.itemSize),r!==o.itemSize)return null;if(void 0===n&&(n=o.normalized),n!==o.normalized)return null;i+=o.array.length}var u=new e(i),h=0;for(s=0;s<t.length;++s)u.set(t[s].array,h),h+=t[s].array.length;return new a.BufferAttribute(u,r,n)},interleaveAttributes:function(t){for(var e,r=0,n=0,i=0,s=t.length;i<s;++i){var o=t[i];if(void 0===e&&(e=o.array.constructor),e!==o.array.constructor)return console.warn("AttributeBuffers of different types cannot be interleaved"),null;r+=o.array.length,n+=o.itemSize}var u=new a.InterleavedBuffer(new e(r),n),h=0,c=[],l=["getX","getY","getZ","getW"],f=["setX","setY","setZ","setW"],d=0;for(s=t.length;d<s;d++){var p=(o=t[d]).itemSize,g=o.count,y=new a.InterleavedBufferAttribute(u,p,h,o.normalized);c.push(y),h+=p;for(var m=0;m<g;m++)for(var v=0;v<p;v++)y[f[v]](m,o[l[v]](m))}return c},estimateBytesUsed:function(t){var e=0;for(var r in t.attributes){var n=t.getAttribute(r);e+=n.count*n.itemSize*n.array.BYTES_PER_ELEMENT}var i=t.getIndex();return e+=i?i.count*i.itemSize*i.array.BYTES_PER_ELEMENT:0},mergeVertices:function(t,e){void 0===e&&(e=1e-4),e=Math.max(e,Number.EPSILON);for(var r={},n=t.getIndex(),i=t.getAttribute("position"),s=n?n.count:i.count,o=0,u=Object.keys(t.attributes),h={},c={},l=[],f=["getX","getY","getZ","getW"],d=0,p=u.length;d<p;d++){h[b=u[d]]=[],(A=t.morphAttributes[b])&&(c[b]=new Array(A.length).fill().map((function(){return[]})))}var g=Math.log10(1/e),y=Math.pow(10,g);for(d=0;d<s;d++){var m=n?n.getX(d):d,v="",x=0;for(p=u.length;x<p;x++)for(var b=u[x],w=(E=t.getAttribute(b)).itemSize,S=0;S<w;S++)v+=~~(E[f[S]](m)*y)+",";if(v in r)l.push(r[v]);else{for(x=0,p=u.length;x<p;x++){b=u[x];var E=t.getAttribute(b),A=t.morphAttributes[b],P=(w=E.itemSize,h[b]),D=c[b];for(S=0;S<w;S++){var N=f[S];if(P.push(E[N](m)),A)for(var O=0,T=A.length;O<T;O++)D[O].push(A[O][N](m))}}r[v]=o,l.push(o),o++}}var R=t.clone();for(d=0,p=u.length;d<p;d++){b=u[d];var C=t.getAttribute(b),I=new C.array.constructor(h[b]);E=new a.BufferAttribute(I,C.itemSize,C.normalized);if(R.setAttribute(b,E),b in c)for(x=0;x<c[b].length;x++){var k=t.morphAttributes[b][x],j=(I=new k.array.constructor(c[b][x]),new a.BufferAttribute(I,k.itemSize,k.normalized));R.morphAttributes[b][x]=j}}return R.setIndex(l),R}},Wt=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.floorIndex=0,e.needsRender=!0,e}return e.__extends(r,t),r}(a.Mesh);function Xt(t){return new Promise((function(e,r){(/^https\:/.test(t)?h.default:u.default).get(t,(function(t){var n=[];t.on("data",(function(t){return n.push(t)})),t.on("end",(function(){e(Buffer.concat(n).buffer)})),t.on("error",(function(t){return r(t)}))})).on("error",(function(t){return r(t)}))}))}const $t=c.Reader,Jt=c.Writer,te=c.util,ee=c.roots["@REALSEE/FIVE:3"]||(c.roots["@REALSEE/FIVE:3"]={}),re=ee.Model=(()=>{function t(t){if(this.chunks=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.chunks=te.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=Jt.create()),null!=t.chunks&&t.chunks.length)for(let r=0;r<t.chunks.length;++r)ee.Chunk.encode(t.chunks[r],e.uint32(10).fork()).ldelim();return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof $t||(t=$t.create(t));let r=void 0===e?t.len:t.pos+e,n=new ee.Model;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.chunks&&n.chunks.length||(n.chunks=[]),n.chunks.push(ee.Chunk.decode(t,t.uint32()));break;default:t.skipType(7&e)}}return n},t.decodeDelimited=function(t){return t instanceof $t||(t=new $t(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.chunks&&t.hasOwnProperty("chunks")){if(!Array.isArray(t.chunks))return"chunks: array expected";for(let e=0;e<t.chunks.length;++e){let r=ee.Chunk.verify(t.chunks[e]);if(r)return"chunks."+r}}return null},t.fromObject=function(t){if(t instanceof ee.Model)return t;let e=new ee.Model;if(t.chunks){if(!Array.isArray(t.chunks))throw TypeError(".Model.chunks: array expected");e.chunks=[];for(let r=0;r<t.chunks.length;++r){if("object"!=typeof t.chunks[r])throw TypeError(".Model.chunks: object expected");e.chunks[r]=ee.Chunk.fromObject(t.chunks[r])}}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.chunks=[]),t.chunks&&t.chunks.length){r.chunks=[];for(let n=0;n<t.chunks.length;++n)r.chunks[n]=ee.Chunk.toObject(t.chunks[n],e)}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})();ee.Chunk=(()=>{function t(t){if(t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.vertices=null,t.prototype.faces=null,t.prototype.name="",t.prototype.texture="",t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=Jt.create()),ee.Vertices.encode(t.vertices,e.uint32(10).fork()).ldelim(),ee.Faces.encode(t.faces,e.uint32(18).fork()).ldelim(),e.uint32(26).string(t.name),null!=t.texture&&Object.hasOwnProperty.call(t,"texture")&&e.uint32(34).string(t.texture),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof $t||(t=$t.create(t));let r=void 0===e?t.len:t.pos+e,n=new ee.Chunk;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.vertices=ee.Vertices.decode(t,t.uint32());break;case 2:n.faces=ee.Faces.decode(t,t.uint32());break;case 3:n.name=t.string();break;case 4:n.texture=t.string();break;default:t.skipType(7&e)}}if(!n.hasOwnProperty("vertices"))throw te.ProtocolError("missing required 'vertices'",{instance:n});if(!n.hasOwnProperty("faces"))throw te.ProtocolError("missing required 'faces'",{instance:n});if(!n.hasOwnProperty("name"))throw te.ProtocolError("missing required 'name'",{instance:n});return n},t.decodeDelimited=function(t){return t instanceof $t||(t=new $t(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";{let e=ee.Vertices.verify(t.vertices);if(e)return"vertices."+e}{let e=ee.Faces.verify(t.faces);if(e)return"faces."+e}return te.isString(t.name)?null!=t.texture&&t.hasOwnProperty("texture")&&!te.isString(t.texture)?"texture: string expected":null:"name: string expected"},t.fromObject=function(t){if(t instanceof ee.Chunk)return t;let e=new ee.Chunk;if(null!=t.vertices){if("object"!=typeof t.vertices)throw TypeError(".Chunk.vertices: object expected");e.vertices=ee.Vertices.fromObject(t.vertices)}if(null!=t.faces){if("object"!=typeof t.faces)throw TypeError(".Chunk.faces: object expected");e.faces=ee.Faces.fromObject(t.faces)}return null!=t.name&&(e.name=String(t.name)),null!=t.texture&&(e.texture=String(t.texture)),e},t.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(r.vertices=null,r.faces=null,r.name="",r.texture=""),null!=t.vertices&&t.hasOwnProperty("vertices")&&(r.vertices=ee.Vertices.toObject(t.vertices,e)),null!=t.faces&&t.hasOwnProperty("faces")&&(r.faces=ee.Faces.toObject(t.faces,e)),null!=t.name&&t.hasOwnProperty("name")&&(r.name=t.name),null!=t.texture&&t.hasOwnProperty("texture")&&(r.texture=t.texture),r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})(),ee.Vertices=(()=>{function t(t){if(this.xyz=[],this.uvs=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.xyz=te.emptyArray,t.prototype.uvs=te.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=Jt.create()),null!=t.xyz&&t.xyz.length){e.uint32(10).fork();for(let r=0;r<t.xyz.length;++r)e.float(t.xyz[r]);e.ldelim()}if(null!=t.uvs&&t.uvs.length){e.uint32(18).fork();for(let r=0;r<t.uvs.length;++r)e.float(t.uvs[r]);e.ldelim()}return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof $t||(t=$t.create(t));let r=void 0===e?t.len:t.pos+e,n=new ee.Vertices;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:if(n.xyz&&n.xyz.length||(n.xyz=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.xyz.push(t.float())}else n.xyz.push(t.float());break;case 2:if(n.uvs&&n.uvs.length||(n.uvs=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.uvs.push(t.float())}else n.uvs.push(t.float());break;default:t.skipType(7&e)}}return n},t.decodeDelimited=function(t){return t instanceof $t||(t=new $t(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.xyz&&t.hasOwnProperty("xyz")){if(!Array.isArray(t.xyz))return"xyz: array expected";for(let e=0;e<t.xyz.length;++e)if("number"!=typeof t.xyz[e])return"xyz: number[] expected"}if(null!=t.uvs&&t.hasOwnProperty("uvs")){if(!Array.isArray(t.uvs))return"uvs: array expected";for(let e=0;e<t.uvs.length;++e)if("number"!=typeof t.uvs[e])return"uvs: number[] expected"}return null},t.fromObject=function(t){if(t instanceof ee.Vertices)return t;let e=new ee.Vertices;if(t.xyz){if(!Array.isArray(t.xyz))throw TypeError(".Vertices.xyz: array expected");e.xyz=[];for(let r=0;r<t.xyz.length;++r)e.xyz[r]=Number(t.xyz[r])}if(t.uvs){if(!Array.isArray(t.uvs))throw TypeError(".Vertices.uvs: array expected");e.uvs=[];for(let r=0;r<t.uvs.length;++r)e.uvs[r]=Number(t.uvs[r])}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.xyz=[],r.uvs=[]),t.xyz&&t.xyz.length){r.xyz=[];for(let n=0;n<t.xyz.length;++n)r.xyz[n]=e.json&&!isFinite(t.xyz[n])?String(t.xyz[n]):t.xyz[n]}if(t.uvs&&t.uvs.length){r.uvs=[];for(let n=0;n<t.uvs.length;++n)r.uvs[n]=e.json&&!isFinite(t.uvs[n])?String(t.uvs[n]):t.uvs[n]}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})(),ee.Faces=(()=>{function t(t){if(this.indices=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.indices=te.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=Jt.create()),null!=t.indices&&t.indices.length){e.uint32(10).fork();for(let r=0;r<t.indices.length;++r)e.uint32(t.indices[r]);e.ldelim()}return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof $t||(t=$t.create(t));let r=void 0===e?t.len:t.pos+e,n=new ee.Faces;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:if(n.indices&&n.indices.length||(n.indices=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.indices.push(t.uint32())}else n.indices.push(t.uint32());break;default:t.skipType(7&e)}}return n},t.decodeDelimited=function(t){return t instanceof $t||(t=new $t(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.indices&&t.hasOwnProperty("indices")){if(!Array.isArray(t.indices))return"indices: array expected";for(let e=0;e<t.indices.length;++e)if(!te.isInteger(t.indices[e]))return"indices: integer[] expected"}return null},t.fromObject=function(t){if(t instanceof ee.Faces)return t;let e=new ee.Faces;if(t.indices){if(!Array.isArray(t.indices))throw TypeError(".Faces.indices: array expected");e.indices=[];for(let r=0;r<t.indices.length;++r)e.indices[r]=t.indices[r]>>>0}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.indices=[]),t.indices&&t.indices.length){r.indices=[];for(let e=0;e<t.indices.length;++e)r.indices[e]=t.indices[e]}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})();var ne=(new a.Matrix4).set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1);function ie(t){var e=t.match(/(group|floor)-?(\d+)/);return e?parseInt(e[2],10):0}function se(t){var e=t.indices,r=t.vertices,n=t.uvs,i=new a.BufferGeometry;i.setIndex(new a.BufferAttribute(new Uint32Array(e),1)),i.setAttribute("position",new a.BufferAttribute(new Float32Array(r),3)),i.attributes.position.applyMatrix4(ne),Zt(n)||i.setAttribute("uv",new a.BufferAttribute(new Float32Array(n),2));for(var s=new Float32Array(r.length),o=new a.Vector3,u=new a.Vector3,h=new a.Vector3,c=new a.Vector3,l=new a.Vector3,f=new a.Vector3,d=0,p=i.index.array.length,g=void 0,y=void 0,m=void 0;d<p;d+=3)g=3*e[d+0],y=3*e[d+1],m=3*e[d+2],o.x=r[g],o.y=r[g+1],o.z=r[g+2],u.x=r[y],u.y=r[y+1],u.z=r[y+2],h.x=r[m],h.y=r[m+1],h.z=r[m+2],c.x=h.x-u.x,c.y=h.y-u.y,c.z=h.z-u.z,l.x=o.x-u.x,l.y=o.y-u.y,l.z=o.z-u.z,f.x=c.y*l.z-c.z*l.y,f.y=c.z*l.x-c.x*l.z,f.z=c.x*l.y-c.y*l.x,s[g]+=f.x,s[g+1]+=f.y,s[g+2]+=f.z,s[y]+=f.x,s[y+1]+=f.y,s[y+2]+=f.z,s[m]+=f.x,s[m+1]+=f.y,s[m+2]+=f.z;return i.setAttribute("normal",new a.BufferAttribute(s,3)),i}function oe(t){for(var e=0,r=t;e<r.length;e++){(u=r[e]).chunkName=(n=u.name,i=void 0,(i=n.match(/(chunk)-?(\d+)/))?parseInt(i[2],10):0),u.floorName=ie(u.name)}var n,i;t.sort((function(t,e){return 1e3*t.floorName+t.chunkName-(1e3*e.floorName+e.chunkName)}));for(var s=[],o=[],a=0;a<t.length;a++){var u,h=ie((u=t[a]).name),c=s[h]=s[h]||{geometries:[]};(f=se({vertices:u.vertices.xyz,uvs:u.vertices.uvs,indices:u.faces.indices})).name="model_geo_chunk_"+a,c.geometries.push(f)}for(var l=0;l<s.length;l++){if(c=s[l]){var f=Yt.mergeBufferGeometries(c.geometries,!0);c.geometries.forEach((function(t){return t.dispose()}));var d=new Wt(f);d.floorIndex=l,d.name="model_floor_"+l,o.push(d)}}return{objects:o}}var ae={};function ue(t){return Array.prototype.reduce.call(t,(function(t,e,r){return t|e<<8*r}),0)}function he(t){for(var e=new Uint8Array(t),r=ue(e.slice(0,4)),n=[],i=[],s=4+4*r,o=0;o<r;o++)i[o]=ue(e.slice(4+4*o,8+4*o)),n[o]=o===r-1?e.subarray(s,s+i[o]):e.slice(s,s+i[o]),s+=i[o];return Promise.resolve(function(t){for(var e,r=[],n=t.length,i=function(n){var i={data:t[n],offset:0,readByte:function(){return this.data[this.offset++]}},s=i.data.length,o={data:[],offset:0,writeByte:function(t){var e=Math.floor(this.offset/s);this.data[e]||(this.data[e]=new Uint8Array(s)),this.data[e][this.offset%s]=t,this.offset++}};ae.decompressFile(i,o),e=new Uint8Array(o.offset);for(var a=0;a<o.offset;a++)e[a]=o.data[Math.floor(a/s)][a%s];r.push(e)},s=0;s<n;s++)i(s);return r}(n))}ae.OutWindow=function(){this._windowSize=0},ae.OutWindow.prototype.create=function(t){this._buffer&&this._windowSize===t||(this._buffer=[]),this._windowSize=t,this._pos=0,this._streamPos=0},ae.OutWindow.prototype.flush=function(){var t=this._pos-this._streamPos;if(0!==t){for(;t--;)this._stream.writeByte(this._buffer[this._streamPos++]);this._pos>=this._windowSize&&(this._pos=0),this._streamPos=this._pos}},ae.OutWindow.prototype.releaseStream=function(){this.flush(),this._stream=null},ae.OutWindow.prototype.setStream=function(t){this.releaseStream(),this._stream=t},ae.OutWindow.prototype.init=function(t){t||(this._streamPos=0,this._pos=0)},ae.OutWindow.prototype.copyBlock=function(t,e){var r=this._pos-t-1;for(r<0&&(r+=this._windowSize);e--;)r>=this._windowSize&&(r=0),this._buffer[this._pos++]=this._buffer[r++],this._pos>=this._windowSize&&this.flush()},ae.OutWindow.prototype.putByte=function(t){this._buffer[this._pos++]=t,this._pos>=this._windowSize&&this.flush()},ae.OutWindow.prototype.getByte=function(t){var e=this._pos-t-1;return e<0&&(e+=this._windowSize),this._buffer[e]},ae.RangeDecoder=function(){},ae.RangeDecoder.prototype.setStream=function(t){this._stream=t},ae.RangeDecoder.prototype.releaseStream=function(){this._stream=null},ae.RangeDecoder.prototype.init=function(){var t=5;for(this._code=0,this._range=-1;t--;)this._code=this._code<<8|this._stream.readByte()},ae.RangeDecoder.prototype.decodeDirectBits=function(t){for(var e,r=0,n=t;n--;)this._range>>>=1,e=this._code-this._range>>>31,this._code-=this._range&e-1,r=r<<1|1-e,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8);return r},ae.RangeDecoder.prototype.decodeBit=function(t,e){var r=t[e],n=(this._range>>>11)*r;return(2147483648^this._code)<(2147483648^n)?(this._range=n,t[e]+=2048-r>>>5,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8),0):(this._range-=n,this._code-=n,t[e]-=r>>>5,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8),1)},ae.initBitModels=function(t,e){for(;e--;)t[e]=1024},ae.BitTreeDecoder=function(t){this._models=[],this._numBitLevels=t},ae.BitTreeDecoder.prototype.init=function(){ae.initBitModels(this._models,1<<this._numBitLevels)},ae.BitTreeDecoder.prototype.decode=function(t){for(var e=1,r=this._numBitLevels;r--;)e=e<<1|t.decodeBit(this._models,e);return e-(1<<this._numBitLevels)},ae.BitTreeDecoder.prototype.reverseDecode=function(t){for(var e,r=1,n=0,i=0;i<this._numBitLevels;++i)r=r<<1|(e=t.decodeBit(this._models,r)),n|=e<<i;return n},ae.reverseDecode2=function(t,e,r,n){for(var i,s=1,o=0,a=0;a<n;++a)s=s<<1|(i=r.decodeBit(t,e+s)),o|=i<<a;return o},ae.LenDecoder=function(){this._choice=[],this._lowCoder=[],this._midCoder=[],this._highCoder=new ae.BitTreeDecoder(8),this._numPosStates=0},ae.LenDecoder.prototype.create=function(t){for(;this._numPosStates<t;++this._numPosStates)this._lowCoder[this._numPosStates]=new ae.BitTreeDecoder(3),this._midCoder[this._numPosStates]=new ae.BitTreeDecoder(3)},ae.LenDecoder.prototype.init=function(){var t=this._numPosStates;for(ae.initBitModels(this._choice,2);t--;)this._lowCoder[t].init(),this._midCoder[t].init();this._highCoder.init()},ae.LenDecoder.prototype.decode=function(t,e){return 0===t.decodeBit(this._choice,0)?this._lowCoder[e].decode(t):0===t.decodeBit(this._choice,1)?8+this._midCoder[e].decode(t):16+this._highCoder.decode(t)},ae.Decoder2=function(){this._decoders=[]},ae.Decoder2.prototype.init=function(){ae.initBitModels(this._decoders,768)},ae.Decoder2.prototype.decodeNormal=function(t){var e=1;do{e=e<<1|t.decodeBit(this._decoders,e)}while(e<256);return 255&e},ae.Decoder2.prototype.decodeWithMatchByte=function(t,e){var r,n,i=1;do{if(r=e>>7&1,e<<=1,i=i<<1|(n=t.decodeBit(this._decoders,(1+r<<8)+i)),r!==n){for(;i<256;)i=i<<1|t.decodeBit(this._decoders,i);break}}while(i<256);return 255&i},ae.LiteralDecoder=function(){},ae.LiteralDecoder.prototype.create=function(t,e){var r;if(!this._coders||this._numPrevBits!==e||this._numPosBits!==t)for(this._numPosBits=t,this._posMask=(1<<t)-1,this._numPrevBits=e,this._coders=[],r=1<<this._numPrevBits+this._numPosBits;r--;)this._coders[r]=new ae.Decoder2},ae.LiteralDecoder.prototype.init=function(){for(var t=1<<this._numPrevBits+this._numPosBits;t--;)this._coders[t].init()},ae.LiteralDecoder.prototype.getDecoder=function(t,e){return this._coders[((t&this._posMask)<<this._numPrevBits)+((255&e)>>>8-this._numPrevBits)]},ae.Decoder=function(){this._outWindow=new ae.OutWindow,this._rangeDecoder=new ae.RangeDecoder,this._isMatchDecoders=[],this._isRepDecoders=[],this._isRepG0Decoders=[],this._isRepG1Decoders=[],this._isRepG2Decoders=[],this._isRep0LongDecoders=[],this._posSlotDecoder=[],this._posDecoders=[],this._posAlignDecoder=new ae.BitTreeDecoder(4),this._lenDecoder=new ae.LenDecoder,this._repLenDecoder=new ae.LenDecoder,this._literalDecoder=new ae.LiteralDecoder,this._dictionarySize=-1,this._dictionarySizeCheck=-1,this._posSlotDecoder[0]=new ae.BitTreeDecoder(6),this._posSlotDecoder[1]=new ae.BitTreeDecoder(6),this._posSlotDecoder[2]=new ae.BitTreeDecoder(6),this._posSlotDecoder[3]=new ae.BitTreeDecoder(6)},ae.Decoder.prototype.setDictionarySize=function(t){return!(t<0)&&(this._dictionarySize!==t&&(this._dictionarySize=t,this._dictionarySizeCheck=Math.max(this._dictionarySize,1),this._outWindow.create(Math.max(this._dictionarySizeCheck,4096))),!0)},ae.Decoder.prototype.setLcLpPb=function(t,e,r){var n=1<<r;return!(t>8||e>4||r>4)&&(this._literalDecoder.create(e,t),this._lenDecoder.create(n),this._repLenDecoder.create(n),this._posStateMask=n-1,!0)},ae.Decoder.prototype.init=function(){var t=4;for(this._outWindow.init(!1),ae.initBitModels(this._isMatchDecoders,192),ae.initBitModels(this._isRep0LongDecoders,192),ae.initBitModels(this._isRepDecoders,12),ae.initBitModels(this._isRepG0Decoders,12),ae.initBitModels(this._isRepG1Decoders,12),ae.initBitModels(this._isRepG2Decoders,12),ae.initBitModels(this._posDecoders,114),this._literalDecoder.init();t--;)this._posSlotDecoder[t].init();this._lenDecoder.init(),this._repLenDecoder.init(),this._posAlignDecoder.init(),this._rangeDecoder.init()},ae.Decoder.prototype.decode=function(t,e,r){var n,i,s,o,a,u,h=0,c=0,l=0,f=0,d=0,p=0,g=0;for(this._rangeDecoder.setStream(t),this._outWindow.setStream(e),this.init();r<0||p<r;)if(n=p&this._posStateMask,0===this._rangeDecoder.decodeBit(this._isMatchDecoders,(h<<4)+n))i=this._literalDecoder.getDecoder(p++,g),g=h>=7?i.decodeWithMatchByte(this._rangeDecoder,this._outWindow.getByte(c)):i.decodeNormal(this._rangeDecoder),this._outWindow.putByte(g),h=h<4?0:h-(h<10?3:6);else{if(1===this._rangeDecoder.decodeBit(this._isRepDecoders,h))s=0,0===this._rangeDecoder.decodeBit(this._isRepG0Decoders,h)?0===this._rangeDecoder.decodeBit(this._isRep0LongDecoders,(h<<4)+n)&&(h=h<7?9:11,s=1):(0===this._rangeDecoder.decodeBit(this._isRepG1Decoders,h)?o=l:(0===this._rangeDecoder.decodeBit(this._isRepG2Decoders,h)?o=f:(o=d,d=f),f=l),l=c,c=o),0===s&&(s=2+this._repLenDecoder.decode(this._rangeDecoder,n),h=h<7?8:11);else if(d=f,f=l,l=c,s=2+this._lenDecoder.decode(this._rangeDecoder,n),h=h<7?7:10,(a=this._posSlotDecoder[s<=5?s-2:3].decode(this._rangeDecoder))>=4){if(c=(2|1&a)<<(u=(a>>1)-1),a<14)c+=ae.reverseDecode2(this._posDecoders,c-a-1,this._rangeDecoder,u);else if(c+=this._rangeDecoder.decodeDirectBits(u-4)<<4,(c+=this._posAlignDecoder.reverseDecode(this._rangeDecoder))<0){if(-1===c)break;return!1}}else c=a;if(c>=p||c>=this._dictionarySizeCheck)return!1;this._outWindow.copyBlock(c,s),p+=s,g=this._outWindow.getByte(0)}return this._outWindow.flush(),this._outWindow.releaseStream(),this._rangeDecoder.releaseStream(),!0},ae.Decoder.prototype.setDecoderProperties=function(t){var e,r,n,i,s;return!(t.size<5)&&(r=(e=t.readByte())%9,n=(e=~~(e/9))%5,i=~~(e/5),!!this.setLcLpPb(r,n,i)&&(s=t.readByte(),s|=t.readByte()<<8,s|=t.readByte()<<16,s+=16777216*t.readByte(),this.setDictionarySize(s)))},ae.decompress=function(t,e,r,n){var i=new ae.Decoder;if(!i.setDecoderProperties(t))throw"Incorrect stream properties";if(!i.decode(e,r,n))throw"Error in data stream";return!0},ae.decompressFile=function(t,e){var r,n=new ae.Decoder;if(!n.setDecoderProperties(t))throw"Incorrect stream properties";if(r=t.readByte(),r|=t.readByte()<<8,r|=t.readByte()<<16,r+=16777216*t.readByte(),t.readByte(),t.readByte(),t.readByte(),t.readByte(),!n.decode(t,e,r))throw"Error in data stream";return!0};var ce=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.floorIndex=0,e.needsRender=!0,e}return e.__extends(r,t),r.prototype.disposeGeometry=function(){this.traverse((function(t){t instanceof Wt&&t.geometry.dispose()}))},r}(a.Group);const le=c.Reader,fe=c.Writer,de=c.util,pe=c.roots["@REALSEE/FIVE:2"]||(c.roots["@REALSEE/FIVE:2"]={}),ge=pe.Model=(()=>{function t(t){if(this.meshes=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.meshes=de.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=fe.create()),null!=t.meshes&&t.meshes.length)for(let r=0;r<t.meshes.length;++r)pe.Mesh.encode(t.meshes[r],e.uint32(10).fork()).ldelim();return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof le||(t=le.create(t));let r=void 0===e?t.len:t.pos+e,n=new pe.Model;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.meshes&&n.meshes.length||(n.meshes=[]),n.meshes.push(pe.Mesh.decode(t,t.uint32()));break;default:t.skipType(7&e)}}return n},t.decodeDelimited=function(t){return t instanceof le||(t=new le(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.meshes&&t.hasOwnProperty("meshes")){if(!Array.isArray(t.meshes))return"meshes: array expected";for(let e=0;e<t.meshes.length;++e){let r=pe.Mesh.verify(t.meshes[e]);if(r)return"meshes."+r}}return null},t.fromObject=function(t){if(t instanceof pe.Model)return t;let e=new pe.Model;if(t.meshes){if(!Array.isArray(t.meshes))throw TypeError(".Model.meshes: array expected");e.meshes=[];for(let r=0;r<t.meshes.length;++r){if("object"!=typeof t.meshes[r])throw TypeError(".Model.meshes: object expected");e.meshes[r]=pe.Mesh.fromObject(t.meshes[r])}}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.meshes=[]),t.meshes&&t.meshes.length){r.meshes=[];for(let n=0;n<t.meshes.length;++n)r.meshes[n]=pe.Mesh.toObject(t.meshes[n],e)}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})();pe.Mesh=(()=>{function t(t){if(this.chunks=[],this.matrix=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.name="",t.prototype.chunks=de.emptyArray,t.prototype.matrix=de.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=fe.create()),e.uint32(10).string(t.name),null!=t.chunks&&t.chunks.length)for(let r=0;r<t.chunks.length;++r)pe.Chunk.encode(t.chunks[r],e.uint32(18).fork()).ldelim();if(null!=t.matrix&&t.matrix.length)for(let r=0;r<t.matrix.length;++r)pe.Matrix.encode(t.matrix[r],e.uint32(26).fork()).ldelim();return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof le||(t=le.create(t));let r=void 0===e?t.len:t.pos+e,n=new pe.Mesh;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.name=t.string();break;case 2:n.chunks&&n.chunks.length||(n.chunks=[]),n.chunks.push(pe.Chunk.decode(t,t.uint32()));break;case 3:n.matrix&&n.matrix.length||(n.matrix=[]),n.matrix.push(pe.Matrix.decode(t,t.uint32()));break;default:t.skipType(7&e)}}if(!n.hasOwnProperty("name"))throw de.ProtocolError("missing required 'name'",{instance:n});return n},t.decodeDelimited=function(t){return t instanceof le||(t=new le(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(!de.isString(t.name))return"name: string expected";if(null!=t.chunks&&t.hasOwnProperty("chunks")){if(!Array.isArray(t.chunks))return"chunks: array expected";for(let e=0;e<t.chunks.length;++e){let r=pe.Chunk.verify(t.chunks[e]);if(r)return"chunks."+r}}if(null!=t.matrix&&t.hasOwnProperty("matrix")){if(!Array.isArray(t.matrix))return"matrix: array expected";for(let e=0;e<t.matrix.length;++e){let r=pe.Matrix.verify(t.matrix[e]);if(r)return"matrix."+r}}return null},t.fromObject=function(t){if(t instanceof pe.Mesh)return t;let e=new pe.Mesh;if(null!=t.name&&(e.name=String(t.name)),t.chunks){if(!Array.isArray(t.chunks))throw TypeError(".Mesh.chunks: array expected");e.chunks=[];for(let r=0;r<t.chunks.length;++r){if("object"!=typeof t.chunks[r])throw TypeError(".Mesh.chunks: object expected");e.chunks[r]=pe.Chunk.fromObject(t.chunks[r])}}if(t.matrix){if(!Array.isArray(t.matrix))throw TypeError(".Mesh.matrix: array expected");e.matrix=[];for(let r=0;r<t.matrix.length;++r){if("object"!=typeof t.matrix[r])throw TypeError(".Mesh.matrix: object expected");e.matrix[r]=pe.Matrix.fromObject(t.matrix[r])}}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.chunks=[],r.matrix=[]),e.defaults&&(r.name=""),null!=t.name&&t.hasOwnProperty("name")&&(r.name=t.name),t.chunks&&t.chunks.length){r.chunks=[];for(let n=0;n<t.chunks.length;++n)r.chunks[n]=pe.Chunk.toObject(t.chunks[n],e)}if(t.matrix&&t.matrix.length){r.matrix=[];for(let n=0;n<t.matrix.length;++n)r.matrix[n]=pe.Matrix.toObject(t.matrix[n],e)}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})(),pe.Matrix=(()=>{function t(t){if(this.elements=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.elements=de.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=fe.create()),null!=t.elements&&t.elements.length)for(let r=0;r<t.elements.length;++r)e.uint32(13).float(t.elements[r]);return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof le||(t=le.create(t));let r=void 0===e?t.len:t.pos+e,n=new pe.Matrix;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:if(n.elements&&n.elements.length||(n.elements=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.elements.push(t.float())}else n.elements.push(t.float());break;default:t.skipType(7&e)}}return n},t.decodeDelimited=function(t){return t instanceof le||(t=new le(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.elements&&t.hasOwnProperty("elements")){if(!Array.isArray(t.elements))return"elements: array expected";for(let e=0;e<t.elements.length;++e)if("number"!=typeof t.elements[e])return"elements: number[] expected"}return null},t.fromObject=function(t){if(t instanceof pe.Matrix)return t;let e=new pe.Matrix;if(t.elements){if(!Array.isArray(t.elements))throw TypeError(".Matrix.elements: array expected");e.elements=[];for(let r=0;r<t.elements.length;++r)e.elements[r]=Number(t.elements[r])}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.elements=[]),t.elements&&t.elements.length){r.elements=[];for(let n=0;n<t.elements.length;++n)r.elements[n]=e.json&&!isFinite(t.elements[n])?String(t.elements[n]):t.elements[n]}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})(),pe.Chunk=(()=>{function t(t){if(this.material=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.geometry=null,t.prototype.material=de.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=fe.create()),pe.Geometry.encode(t.geometry,e.uint32(18).fork()).ldelim(),null!=t.material&&t.material.length)for(let r=0;r<t.material.length;++r)pe.Material.encode(t.material[r],e.uint32(26).fork()).ldelim();return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof le||(t=le.create(t));let r=void 0===e?t.len:t.pos+e,n=new pe.Chunk;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 2:n.geometry=pe.Geometry.decode(t,t.uint32());break;case 3:n.material&&n.material.length||(n.material=[]),n.material.push(pe.Material.decode(t,t.uint32()));break;default:t.skipType(7&e)}}if(!n.hasOwnProperty("geometry"))throw de.ProtocolError("missing required 'geometry'",{instance:n});return n},t.decodeDelimited=function(t){return t instanceof le||(t=new le(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";{let e=pe.Geometry.verify(t.geometry);if(e)return"geometry."+e}if(null!=t.material&&t.hasOwnProperty("material")){if(!Array.isArray(t.material))return"material: array expected";for(let e=0;e<t.material.length;++e){let r=pe.Material.verify(t.material[e]);if(r)return"material."+r}}return null},t.fromObject=function(t){if(t instanceof pe.Chunk)return t;let e=new pe.Chunk;if(null!=t.geometry){if("object"!=typeof t.geometry)throw TypeError(".Chunk.geometry: object expected");e.geometry=pe.Geometry.fromObject(t.geometry)}if(t.material){if(!Array.isArray(t.material))throw TypeError(".Chunk.material: array expected");e.material=[];for(let r=0;r<t.material.length;++r){if("object"!=typeof t.material[r])throw TypeError(".Chunk.material: object expected");e.material[r]=pe.Material.fromObject(t.material[r])}}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.material=[]),e.defaults&&(r.geometry=null),null!=t.geometry&&t.hasOwnProperty("geometry")&&(r.geometry=pe.Geometry.toObject(t.geometry,e)),t.material&&t.material.length){r.material=[];for(let n=0;n<t.material.length;++n)r.material[n]=pe.Material.toObject(t.material[n],e)}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})(),pe.Geometry=(()=>{function t(t){if(this.groups=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.position=null,t.prototype.uv=null,t.prototype.uv2=null,t.prototype.normal=null,t.prototype.groups=de.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=fe.create()),pe.Position.encode(t.position,e.uint32(10).fork()).ldelim(),null!=t.uv&&Object.hasOwnProperty.call(t,"uv")&&pe.UV.encode(t.uv,e.uint32(18).fork()).ldelim(),null!=t.uv2&&Object.hasOwnProperty.call(t,"uv2")&&pe.UV.encode(t.uv2,e.uint32(26).fork()).ldelim(),pe.Normal.encode(t.normal,e.uint32(34).fork()).ldelim(),null!=t.groups&&t.groups.length)for(let r=0;r<t.groups.length;++r)pe.Group.encode(t.groups[r],e.uint32(42).fork()).ldelim();return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof le||(t=le.create(t));let r=void 0===e?t.len:t.pos+e,n=new pe.Geometry;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.position=pe.Position.decode(t,t.uint32());break;case 2:n.uv=pe.UV.decode(t,t.uint32());break;case 3:n.uv2=pe.UV.decode(t,t.uint32());break;case 4:n.normal=pe.Normal.decode(t,t.uint32());break;case 5:n.groups&&n.groups.length||(n.groups=[]),n.groups.push(pe.Group.decode(t,t.uint32()));break;default:t.skipType(7&e)}}if(!n.hasOwnProperty("position"))throw de.ProtocolError("missing required 'position'",{instance:n});if(!n.hasOwnProperty("normal"))throw de.ProtocolError("missing required 'normal'",{instance:n});return n},t.decodeDelimited=function(t){return t instanceof le||(t=new le(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";{let e=pe.Position.verify(t.position);if(e)return"position."+e}if(null!=t.uv&&t.hasOwnProperty("uv")){let e=pe.UV.verify(t.uv);if(e)return"uv."+e}if(null!=t.uv2&&t.hasOwnProperty("uv2")){let e=pe.UV.verify(t.uv2);if(e)return"uv2."+e}{let e=pe.Normal.verify(t.normal);if(e)return"normal."+e}if(null!=t.groups&&t.hasOwnProperty("groups")){if(!Array.isArray(t.groups))return"groups: array expected";for(let e=0;e<t.groups.length;++e){let r=pe.Group.verify(t.groups[e]);if(r)return"groups."+r}}return null},t.fromObject=function(t){if(t instanceof pe.Geometry)return t;let e=new pe.Geometry;if(null!=t.position){if("object"!=typeof t.position)throw TypeError(".Geometry.position: object expected");e.position=pe.Position.fromObject(t.position)}if(null!=t.uv){if("object"!=typeof t.uv)throw TypeError(".Geometry.uv: object expected");e.uv=pe.UV.fromObject(t.uv)}if(null!=t.uv2){if("object"!=typeof t.uv2)throw TypeError(".Geometry.uv2: object expected");e.uv2=pe.UV.fromObject(t.uv2)}if(null!=t.normal){if("object"!=typeof t.normal)throw TypeError(".Geometry.normal: object expected");e.normal=pe.Normal.fromObject(t.normal)}if(t.groups){if(!Array.isArray(t.groups))throw TypeError(".Geometry.groups: array expected");e.groups=[];for(let r=0;r<t.groups.length;++r){if("object"!=typeof t.groups[r])throw TypeError(".Geometry.groups: object expected");e.groups[r]=pe.Group.fromObject(t.groups[r])}}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.groups=[]),e.defaults&&(r.position=null,r.uv=null,r.uv2=null,r.normal=null),null!=t.position&&t.hasOwnProperty("position")&&(r.position=pe.Position.toObject(t.position,e)),null!=t.uv&&t.hasOwnProperty("uv")&&(r.uv=pe.UV.toObject(t.uv,e)),null!=t.uv2&&t.hasOwnProperty("uv2")&&(r.uv2=pe.UV.toObject(t.uv2,e)),null!=t.normal&&t.hasOwnProperty("normal")&&(r.normal=pe.Normal.toObject(t.normal,e)),t.groups&&t.groups.length){r.groups=[];for(let n=0;n<t.groups.length;++n)r.groups[n]=pe.Group.toObject(t.groups[n],e)}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})(),pe.Position=(()=>{function t(t){if(this.array=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.array=de.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=fe.create()),null!=t.array&&t.array.length){e.uint32(10).fork();for(let r=0;r<t.array.length;++r)e.float(t.array[r]);e.ldelim()}return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof le||(t=le.create(t));let r=void 0===e?t.len:t.pos+e,n=new pe.Position;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:if(n.array&&n.array.length||(n.array=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.array.push(t.float())}else n.array.push(t.float());break;default:t.skipType(7&e)}}return n},t.decodeDelimited=function(t){return t instanceof le||(t=new le(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.array&&t.hasOwnProperty("array")){if(!Array.isArray(t.array))return"array: array expected";for(let e=0;e<t.array.length;++e)if("number"!=typeof t.array[e])return"array: number[] expected"}return null},t.fromObject=function(t){if(t instanceof pe.Position)return t;let e=new pe.Position;if(t.array){if(!Array.isArray(t.array))throw TypeError(".Position.array: array expected");e.array=[];for(let r=0;r<t.array.length;++r)e.array[r]=Number(t.array[r])}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.array=[]),t.array&&t.array.length){r.array=[];for(let n=0;n<t.array.length;++n)r.array[n]=e.json&&!isFinite(t.array[n])?String(t.array[n]):t.array[n]}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})(),pe.UV=(()=>{function t(t){if(this.array=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.array=de.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=fe.create()),null!=t.array&&t.array.length){e.uint32(10).fork();for(let r=0;r<t.array.length;++r)e.float(t.array[r]);e.ldelim()}return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof le||(t=le.create(t));let r=void 0===e?t.len:t.pos+e,n=new pe.UV;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:if(n.array&&n.array.length||(n.array=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.array.push(t.float())}else n.array.push(t.float());break;default:t.skipType(7&e)}}return n},t.decodeDelimited=function(t){return t instanceof le||(t=new le(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.array&&t.hasOwnProperty("array")){if(!Array.isArray(t.array))return"array: array expected";for(let e=0;e<t.array.length;++e)if("number"!=typeof t.array[e])return"array: number[] expected"}return null},t.fromObject=function(t){if(t instanceof pe.UV)return t;let e=new pe.UV;if(t.array){if(!Array.isArray(t.array))throw TypeError(".UV.array: array expected");e.array=[];for(let r=0;r<t.array.length;++r)e.array[r]=Number(t.array[r])}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.array=[]),t.array&&t.array.length){r.array=[];for(let n=0;n<t.array.length;++n)r.array[n]=e.json&&!isFinite(t.array[n])?String(t.array[n]):t.array[n]}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})(),pe.Normal=(()=>{function t(t){if(this.array=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.array=de.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=fe.create()),null!=t.array&&t.array.length){e.uint32(10).fork();for(let r=0;r<t.array.length;++r)e.float(t.array[r]);e.ldelim()}return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof le||(t=le.create(t));let r=void 0===e?t.len:t.pos+e,n=new pe.Normal;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:if(n.array&&n.array.length||(n.array=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.array.push(t.float())}else n.array.push(t.float());break;default:t.skipType(7&e)}}return n},t.decodeDelimited=function(t){return t instanceof le||(t=new le(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.array&&t.hasOwnProperty("array")){if(!Array.isArray(t.array))return"array: array expected";for(let e=0;e<t.array.length;++e)if("number"!=typeof t.array[e])return"array: number[] expected"}return null},t.fromObject=function(t){if(t instanceof pe.Normal)return t;let e=new pe.Normal;if(t.array){if(!Array.isArray(t.array))throw TypeError(".Normal.array: array expected");e.array=[];for(let r=0;r<t.array.length;++r)e.array[r]=Number(t.array[r])}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.array=[]),t.array&&t.array.length){r.array=[];for(let n=0;n<t.array.length;++n)r.array[n]=e.json&&!isFinite(t.array[n])?String(t.array[n]):t.array[n]}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})(),pe.Group=(()=>{function t(t){if(t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.start=0,t.prototype.count=0,t.prototype.materialIndex=0,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=fe.create()),e.uint32(8).uint32(t.start),e.uint32(16).uint32(t.count),e.uint32(24).uint32(t.materialIndex),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof le||(t=le.create(t));let r=void 0===e?t.len:t.pos+e,n=new pe.Group;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.start=t.uint32();break;case 2:n.count=t.uint32();break;case 3:n.materialIndex=t.uint32();break;default:t.skipType(7&e)}}if(!n.hasOwnProperty("start"))throw de.ProtocolError("missing required 'start'",{instance:n});if(!n.hasOwnProperty("count"))throw de.ProtocolError("missing required 'count'",{instance:n});if(!n.hasOwnProperty("materialIndex"))throw de.ProtocolError("missing required 'materialIndex'",{instance:n});return n},t.decodeDelimited=function(t){return t instanceof le||(t=new le(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":de.isInteger(t.start)?de.isInteger(t.count)?de.isInteger(t.materialIndex)?null:"materialIndex: integer expected":"count: integer expected":"start: integer expected"},t.fromObject=function(t){if(t instanceof pe.Group)return t;let e=new pe.Group;return null!=t.start&&(e.start=t.start>>>0),null!=t.count&&(e.count=t.count>>>0),null!=t.materialIndex&&(e.materialIndex=t.materialIndex>>>0),e},t.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(r.start=0,r.count=0,r.materialIndex=0),null!=t.start&&t.hasOwnProperty("start")&&(r.start=t.start),null!=t.count&&t.hasOwnProperty("count")&&(r.count=t.count),null!=t.materialIndex&&t.hasOwnProperty("materialIndex")&&(r.materialIndex=t.materialIndex),r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})(),pe.Material=(()=>{function t(t){if(t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.kd=null,t.prototype.ks=null,t.prototype.ke=null,t.prototype.mapkd="",t.prototype.mapks="",t.prototype.mapke="",t.prototype.norm="",t.prototype.mapbump="",t.prototype.bump="",t.prototype.mapd="",t.prototype.ns=0,t.prototype.d=0,t.prototype.tr=0,t.prototype.mapkdrepeat="",t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=fe.create()),null!=t.kd&&Object.hasOwnProperty.call(t,"kd")&&pe.Color.encode(t.kd,e.uint32(10).fork()).ldelim(),null!=t.ks&&Object.hasOwnProperty.call(t,"ks")&&pe.Color.encode(t.ks,e.uint32(18).fork()).ldelim(),null!=t.ke&&Object.hasOwnProperty.call(t,"ke")&&pe.Color.encode(t.ke,e.uint32(26).fork()).ldelim(),null!=t.mapkd&&Object.hasOwnProperty.call(t,"mapkd")&&e.uint32(34).string(t.mapkd),null!=t.mapks&&Object.hasOwnProperty.call(t,"mapks")&&e.uint32(42).string(t.mapks),null!=t.mapke&&Object.hasOwnProperty.call(t,"mapke")&&e.uint32(50).string(t.mapke),null!=t.norm&&Object.hasOwnProperty.call(t,"norm")&&e.uint32(58).string(t.norm),null!=t.mapbump&&Object.hasOwnProperty.call(t,"mapbump")&&e.uint32(66).string(t.mapbump),null!=t.bump&&Object.hasOwnProperty.call(t,"bump")&&e.uint32(74).string(t.bump),null!=t.mapd&&Object.hasOwnProperty.call(t,"mapd")&&e.uint32(82).string(t.mapd),null!=t.ns&&Object.hasOwnProperty.call(t,"ns")&&e.uint32(93).float(t.ns),null!=t.d&&Object.hasOwnProperty.call(t,"d")&&e.uint32(101).float(t.d),null!=t.tr&&Object.hasOwnProperty.call(t,"tr")&&e.uint32(109).float(t.tr),null!=t.mapkdrepeat&&Object.hasOwnProperty.call(t,"mapkdrepeat")&&e.uint32(114).string(t.mapkdrepeat),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof le||(t=le.create(t));let r=void 0===e?t.len:t.pos+e,n=new pe.Material;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.kd=pe.Color.decode(t,t.uint32());break;case 2:n.ks=pe.Color.decode(t,t.uint32());break;case 3:n.ke=pe.Color.decode(t,t.uint32());break;case 4:n.mapkd=t.string();break;case 5:n.mapks=t.string();break;case 6:n.mapke=t.string();break;case 7:n.norm=t.string();break;case 8:n.mapbump=t.string();break;case 9:n.bump=t.string();break;case 10:n.mapd=t.string();break;case 11:n.ns=t.float();break;case 12:n.d=t.float();break;case 13:n.tr=t.float();break;case 14:n.mapkdrepeat=t.string();break;default:t.skipType(7&e)}}return n},t.decodeDelimited=function(t){return t instanceof le||(t=new le(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.kd&&t.hasOwnProperty("kd")){let e=pe.Color.verify(t.kd);if(e)return"kd."+e}if(null!=t.ks&&t.hasOwnProperty("ks")){let e=pe.Color.verify(t.ks);if(e)return"ks."+e}if(null!=t.ke&&t.hasOwnProperty("ke")){let e=pe.Color.verify(t.ke);if(e)return"ke."+e}return null!=t.mapkd&&t.hasOwnProperty("mapkd")&&!de.isString(t.mapkd)?"mapkd: string expected":null!=t.mapks&&t.hasOwnProperty("mapks")&&!de.isString(t.mapks)?"mapks: string expected":null!=t.mapke&&t.hasOwnProperty("mapke")&&!de.isString(t.mapke)?"mapke: string expected":null!=t.norm&&t.hasOwnProperty("norm")&&!de.isString(t.norm)?"norm: string expected":null!=t.mapbump&&t.hasOwnProperty("mapbump")&&!de.isString(t.mapbump)?"mapbump: string expected":null!=t.bump&&t.hasOwnProperty("bump")&&!de.isString(t.bump)?"bump: string expected":null!=t.mapd&&t.hasOwnProperty("mapd")&&!de.isString(t.mapd)?"mapd: string expected":null!=t.ns&&t.hasOwnProperty("ns")&&"number"!=typeof t.ns?"ns: number expected":null!=t.d&&t.hasOwnProperty("d")&&"number"!=typeof t.d?"d: number expected":null!=t.tr&&t.hasOwnProperty("tr")&&"number"!=typeof t.tr?"tr: number expected":null!=t.mapkdrepeat&&t.hasOwnProperty("mapkdrepeat")&&!de.isString(t.mapkdrepeat)?"mapkdrepeat: string expected":null},t.fromObject=function(t){if(t instanceof pe.Material)return t;let e=new pe.Material;if(null!=t.kd){if("object"!=typeof t.kd)throw TypeError(".Material.kd: object expected");e.kd=pe.Color.fromObject(t.kd)}if(null!=t.ks){if("object"!=typeof t.ks)throw TypeError(".Material.ks: object expected");e.ks=pe.Color.fromObject(t.ks)}if(null!=t.ke){if("object"!=typeof t.ke)throw TypeError(".Material.ke: object expected");e.ke=pe.Color.fromObject(t.ke)}return null!=t.mapkd&&(e.mapkd=String(t.mapkd)),null!=t.mapks&&(e.mapks=String(t.mapks)),null!=t.mapke&&(e.mapke=String(t.mapke)),null!=t.norm&&(e.norm=String(t.norm)),null!=t.mapbump&&(e.mapbump=String(t.mapbump)),null!=t.bump&&(e.bump=String(t.bump)),null!=t.mapd&&(e.mapd=String(t.mapd)),null!=t.ns&&(e.ns=Number(t.ns)),null!=t.d&&(e.d=Number(t.d)),null!=t.tr&&(e.tr=Number(t.tr)),null!=t.mapkdrepeat&&(e.mapkdrepeat=String(t.mapkdrepeat)),e},t.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(r.kd=null,r.ks=null,r.ke=null,r.mapkd="",r.mapks="",r.mapke="",r.norm="",r.mapbump="",r.bump="",r.mapd="",r.ns=0,r.d=0,r.tr=0,r.mapkdrepeat=""),null!=t.kd&&t.hasOwnProperty("kd")&&(r.kd=pe.Color.toObject(t.kd,e)),null!=t.ks&&t.hasOwnProperty("ks")&&(r.ks=pe.Color.toObject(t.ks,e)),null!=t.ke&&t.hasOwnProperty("ke")&&(r.ke=pe.Color.toObject(t.ke,e)),null!=t.mapkd&&t.hasOwnProperty("mapkd")&&(r.mapkd=t.mapkd),null!=t.mapks&&t.hasOwnProperty("mapks")&&(r.mapks=t.mapks),null!=t.mapke&&t.hasOwnProperty("mapke")&&(r.mapke=t.mapke),null!=t.norm&&t.hasOwnProperty("norm")&&(r.norm=t.norm),null!=t.mapbump&&t.hasOwnProperty("mapbump")&&(r.mapbump=t.mapbump),null!=t.bump&&t.hasOwnProperty("bump")&&(r.bump=t.bump),null!=t.mapd&&t.hasOwnProperty("mapd")&&(r.mapd=t.mapd),null!=t.ns&&t.hasOwnProperty("ns")&&(r.ns=e.json&&!isFinite(t.ns)?String(t.ns):t.ns),null!=t.d&&t.hasOwnProperty("d")&&(r.d=e.json&&!isFinite(t.d)?String(t.d):t.d),null!=t.tr&&t.hasOwnProperty("tr")&&(r.tr=e.json&&!isFinite(t.tr)?String(t.tr):t.tr),null!=t.mapkdrepeat&&t.hasOwnProperty("mapkdrepeat")&&(r.mapkdrepeat=t.mapkdrepeat),r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})(),pe.Color=(()=>{function t(t){if(this.rgb=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.rgb=de.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=fe.create()),null!=t.rgb&&t.rgb.length)for(let r=0;r<t.rgb.length;++r)e.uint32(13).float(t.rgb[r]);return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof le||(t=le.create(t));let r=void 0===e?t.len:t.pos+e,n=new pe.Color;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:if(n.rgb&&n.rgb.length||(n.rgb=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.rgb.push(t.float())}else n.rgb.push(t.float());break;default:t.skipType(7&e)}}return n},t.decodeDelimited=function(t){return t instanceof le||(t=new le(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.rgb&&t.hasOwnProperty("rgb")){if(!Array.isArray(t.rgb))return"rgb: array expected";for(let e=0;e<t.rgb.length;++e)if("number"!=typeof t.rgb[e])return"rgb: number[] expected"}return null},t.fromObject=function(t){if(t instanceof pe.Color)return t;let e=new pe.Color;if(t.rgb){if(!Array.isArray(t.rgb))throw TypeError(".Color.rgb: array expected");e.rgb=[];for(let r=0;r<t.rgb.length;++r)e.rgb[r]=Number(t.rgb[r])}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.rgb=[]),t.rgb&&t.rgb.length){r.rgb=[];for(let n=0;n<t.rgb.length;++n)r.rgb[n]=e.json&&!isFinite(t.rgb[n])?String(t.rgb[n]):t.rgb[n]}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})();var ye={};function me(t){var e,r=[];function n(t,e,r){var n=function(t){var e=t.position,r=t.normal,n=t.uv,i=t.uv2,s=t.groups,o=new a.BufferGeometry;return o.setAttribute("position",new a.BufferAttribute(new Float32Array(e.array),3)),r&&o.setAttribute("normal",new a.BufferAttribute(new Float32Array(r.array),3)),n&&o.setAttribute("uv",new a.BufferAttribute(new Float32Array(n.array),2)),i&&o.setAttribute("uv2",new a.BufferAttribute(new Float32Array(i.array),2)),s.forEach((function(t){return o.addGroup(t.start,t.count,t.materialIndex)})),o}(t);n.applyMatrix4(r);var i=new a.Vector3,s=new a.Quaternion,o=new a.Vector3;return r.decompose(i,s,o),o.x*o.y*o.z<0&&n.attributes.normal&&n.attributes.position&&n.attributes.uv&&function(t){for(var e=[0,0,0],r=0;r<t.attributes.normal.array.length/9;r++)e[0]=t.attributes.normal.array[9*r],e[1]=t.attributes.normal.array[9*r+1],e[2]=t.attributes.normal.array[9*r+2],t.attributes.normal.array[9*r]=t.attributes.normal.array[9*r+6],t.attributes.normal.array[9*r+1]=t.attributes.normal.array[9*r+7],t.attributes.normal.array[9*r+2]=t.attributes.normal.array[9*r+8],t.attributes.normal.array[9*r+6]=e[0],t.attributes.normal.array[9*r+7]=e[1],t.attributes.normal.array[9*r+8]=e[2];for(r=0;r<t.attributes.position.array.length/9;r++)e[0]=t.attributes.position.array[9*r],e[1]=t.attributes.position.array[9*r+1],e[2]=t.attributes.position.array[9*r+2],t.attributes.position.array[9*r]=t.attributes.position.array[9*r+6],t.attributes.position.array[9*r+1]=t.attributes.position.array[9*r+7],t.attributes.position.array[9*r+2]=t.attributes.position.array[9*r+8],t.attributes.position.array[9*r+6]=e[0],t.attributes.position.array[9*r+7]=e[1],t.attributes.position.array[9*r+8]=e[2];for(r=0;r<t.attributes.uv.array.length/6;r++)e[0]=t.attributes.uv.array[6*r],e[1]=t.attributes.uv.array[6*r+1],t.attributes.uv.array[6*r]=t.attributes.uv.array[6*r+4],t.attributes.uv.array[6*r+1]=t.attributes.uv.array[6*r+5],t.attributes.uv.array[6*r+4]=e[0],t.attributes.uv.array[6*r+5]=e[1];t.attributes.normal.needsUpdate=!0,t.attributes.position.needsUpdate=!0,t.attributes.uv.needsUpdate=!0}(n),new Wt(n)}return(e=t,ge.decode(e).meshes).forEach((function(t){var e=t.name,i=t.chunks,s=t.matrix;"Ceiling"!==e&&"CeilingDrop"!==e&&s.map((function(t){var s,o=new a.Matrix4;if(o.elements=t.elements,1===i.length){var u=i[0],h=u.geometry;u.material;s=n(h,0,o)}else s=new ce,i.forEach((function(t,e){var r=t.geometry,i=(t.material,n(r,0,o));i.name="chunk"+e,s.add(i)}));s.floorIndex=0,s.name=e,r.push(s)}))})),{objects:r}}function ve(){Object.keys(ye).forEach((function(t){ye[t].dispose(),delete ye[t]}))}var xe,be=(xe="$$FIVE_EVENT$$","undefined"==typeof Symbol?"$Symbol<"+xe+">$":Symbol(xe));function we(t){return t[be]||(t[be]={}),t[be]}var Se=function(){function t(){}return t.prototype.hasListener=function(t){var e=we(this);return e&&e[t]&&e[t].length>0},t.prototype.on=function(t,e,r){var n=this,i=we(this);return i[t]||(i[t]=[]),i[t].push([e,r||!1]),function(){return n.off(t,e)}},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.off=function(t,e){if(void 0!==t){var r,n=we(this);if(n[t]||(n[t]=[]),void 0!==e){for(var i=0;i<n[t].length&&n[t][i][0]!==e;i++);i<n[t].length&&n[t].splice(i,1)}else n[t].length=0}else(r=this)[be]||delete r[be]},t.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];for(var n=!1,i=we(this),s=i[t]||[],o=0,a=s.slice();o<a.length;o++){var u=a[o],h=u[0],c=u[1],l=void 0!==c&&c,f=h.apply(void 0,e);l&&this.off(t,h),!1===f&&(n=!0)}return n},t}();function Ee(t){var r;return new((r=a.Triangle).bind.apply(r,e.__spreadArray([void 0],t.map((function(t){return new a.Vector3(t.x,t.y,t.z)})),!1)))}var Ae={at3d:function(t){return Promise.resolve().then((function(){return Xt(t.file)})).then((function(t){return he(t)})).then((function(t){for(var e=[],r=0,n=t;r<n.length;r++){var i=n[r],s=re.decode(i);e.push.apply(e,s.chunks)}return e})).then((function(t){return oe(t)}))},pbm:function(t){return Promise.resolve().then((function(){return Xt(t.file)})).then((function(t){var e=new Uint8Array(t),r=re.decode(e);return[].concat(r.chunks)})).then((function(t){return oe(t)}))},dome:function(t){return Promise.resolve().then((function(){return ve()})).then((function(){return Xt(t.file)})).then((function(t){return me(new Uint8Array(t))}))},domez:function(t){return Promise.resolve().then((function(){return ve()})).then((function(){return Xt(t.file)})).then((function(t){return he(t)})).then((function(t){var e=t.reduce((function(t,e){return t+e.length}),0),r=new Uint8Array(e),n=0;return t.forEach((function(t){r.set(t,n),n+=t.length})),r})).then((function(t){return me(t)}))}},Pe=function(t){function r(){var e=t.call(this)||this;return e.empty=!1,e.name="model",e.loaded=!1,e.bvhs=[],e.bounding=new a.Box3,e.shownfloor=null,e}return e.__extends(r,t),r.prototype.getEdges=function(t){var e;void 0===t&&(t=30/180*Math.PI);for(var r=Math.cos(t),n=[],i=0,s=this.children;i<s.length;i++){var o=s[i];if(o instanceof Wt){for(var u={},h=["a","b","c"],c=Yt.mergeVertices(o.geometry),l=c.getAttribute("position").array,f=(null===(e=c.getIndex())||void 0===e?void 0:e.array)||[],d=[],p=[],g=0,y=l.length;g<y;g+=3)d.push(new a.Vector3(l[g],l[g+1],l[g+2]));for(g=0,y=f.length;g<y;g+=3){var m=f[g],v=f[g+1],x=f[g+2],b=(new a.Vector3).crossVectors(d[v].clone().sub(d[m]),d[x].clone().sub(d[m])).normalize();p.push({a:m,b:v,c:x,normal:b})}for(g=0,y=p.length;g<y;g++)for(var w=p[g],S=0;S<3;S++){var E=w[h[S]],A=w[h[(S+1)%3]],P=[Math.min(E,A),Math.max(E,A)];void 0===u[D=P[0]+"-"+P[1]]?u[D]={index1:P[0],index2:P[1],face1:g}:u[D].face2=g}for(var D in u){var N=u[D];if(void 0===N.face2||p[N.face1].normal.dot(p[N.face2].normal)<=r){var O=d[N.index1],T=d[N.index2];n.push(new a.Line3(O,T))}}c.dispose(),d.length=0,p.length=0}}return n},r.prototype.hasFloors=function(){var t=[];return this.traverse((function(e){e instanceof Wt&&(t[e.floorIndex]=!0)})),t.length},r.prototype.show=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=0!==t.length;this.shownfloor=r?t[0]:null,this.needsRender=!0},r.prototype.intersectRaycaster=function(t,e){var r=t.ray,n=r.origin,i=r.direction;if(Zt(e))if(Zt(this.shownfloor)){var s=this.hasFloors();e=[];for(var o=0;o<s;o++)e.push(o)}else e=[this.shownfloor];var u=[],h=[];Array.isArray(e)?h.push.apply(h,e):h.push(e);for(var c=function(e){var r=l.bvhs&&l.bvhs[e];if(r){var s=new Ft(n.x,n.y,n.z),o=new Ft(i.x,i.y,i.z);(h=r.intersectRay(s,o,!0).map((function(t){var e=t.intersectionPoint,r=t.triangle,i=new a.Vector3(e.x,e.y,e.z);return{point:i,face:{normal:Ee(r).getNormal(new a.Vector3)},distance:n.distanceTo(i)}}))).length&&u.push.apply(u,h)}else{var h,c=[];l.traverse((function(t){t instanceof Wt&&t.floorIndex===e&&c.push(t)})),(h=t.intersectObjects(c).map((function(t){var e=t.face?{normal:t.face.normal}:void 0;return{point:t.point,face:e,distance:t.distance}}))).length&&u.push.apply(u,h)}},l=this,f=0,d=h;f<d.length;f++){c(d[f])}return u.filter((function(e){var r=e.distance;return r<=t.far&&r>=t.near})).sort((function(t,e){return t.distance-e.distance}))},r.prototype.buildBVH=function(){var t,e=[];this.traverse((function(t){t instanceof Wt&&(e[t.floorIndex]=e[t.floorIndex]||[],e[t.floorIndex].push(t.geometry))}));var r=e.map((function(t){var e=t.reduce((function(t,e){return t+(e.index?e.index.array.length:e.attributes.position.array.length)}),0),r=new Float32Array(3*e);return t.reduce((function(t,e){for(var n=e.index?e.index.array:null,i=e.attributes.position.array,s=n?n.length:i.length/3,o=0;o<s;o++){var a=3*(t+o),u=n?3*n[o]:3*o;r[a+0]=i[u+0],r[a+1]=i[u+1],r[a+2]=i[u+2]}return t+s}),0),new Qt(r,10)}));this.bvhs.length=0,(t=this.bvhs).push.apply(t,r),this.bvhs.loaded=!0,this.emit("bvhLoaded")},r.prototype.load=function(t){var e=this;if(!0===this.loaded)throw new Error("model 只能被 load 一次");var r=Ae[function(t,e){void 0===e&&(e=[]);var r=/([0-9a-z\.\_\-]+)([\?\#].*)?$/i.exec(t);if(r)for(var n=String(r[1]).trim().split("."),i=0,s=e;i<s.length;i++){var o=s[i];if(n.indexOf(o)>=0)return o}}(t.file,Object.keys(Ae))||""];if(!r)throw new Error("文件类型错误");return r(t).then((function(t){for(var r=t.objects,n=[],i=0,s=r;i<s.length;i++){var o=s[i];o.traverse((function(t){t instanceof Wt&&(t.geometry.computeBoundingBox(),t.geometry.computeBoundingSphere(),n.push(t.geometry.boundingBox))})),e.add(o)}e.emit("geometryLoaded"),n.length=0,e.emit("loaded"),e.loaded=!0})).catch((function(t){return e.emit("error",t),Promise.reject(t)}))},r.prototype.dispose=function(){for(this.off(),this.disposeGeometry();this.children.length;)this.remove(this.children[0]);this.bvhs.length=0,delete this.bvhs.loaded},r}(ce);Object.assign(Pe.prototype,{on:Se.prototype.on,once:Se.prototype.once,off:Se.prototype.off,emit:Se.prototype.emit,hasListener:Se.prototype.hasListener});var De=function(){function t(){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 t.prototype.toJSON=function(){return this.raw.work},t}();function Ne(t){return 0===t.indexOf("//")||/^[0-9a-z]+\:\/\//i.test(t)}function Oe(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=[];t=t.map((function(t){return t.trim()})).filter((function(t){return t.length>0&&!/^\/+$/.test(t)}));for(var n=0;n<t.length;n++){var i=0===n,s=n===t.length-1,o=t[n];i||(o=o.replace(/^\/+/,"")),s||(o=o.replace(/\/+$/,"")),r.push(o)}return r.join("/")}function Te(t){Object.freeze(t);var e="function"==typeof t,r=Object.prototype.hasOwnProperty;return Object.getOwnPropertyNames(t).forEach((function(n){!r.call(t,n)||e&&("caller"===n||"callee"===n||"arguments"===n)||null===t[n]||"object"!=typeof t[n]&&"function"!=typeof t[n]||Object.isFrozen(t[n])||Te(t[n])})),t}function Re(t){return t instanceof Error}function Ce(t,e){if(t===e)return!0;if(t&&e&&"object"==typeof t&&"object"==typeof e){if(t.constructor!==e.constructor)return!1;var r,n,i;if(Array.isArray(t)){if((r=t.length)!=e.length)return!1;for(n=r;0!=n--;)if(!Ce(t[n],e[n]))return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===e.toString();if((r=(i=Object.keys(t)).length)!==Object.keys(e).length)return!1;for(n=r;0!=n--;)if(!Object.prototype.hasOwnProperty.call(e,i[n]))return!1;for(n=r;0!=n--;){var s=i[n];if(!Ce(t[s],e[s]))return!1}return!0}return t!=t&&e!=e}function Ie(t){return"number"==typeof t}var ke=/^([^.]+)(\.([^.]+))*$/;function je(t,e){return ke.test(t)&&ke.test(e)&&function(t,e){if("*"===t)return!0;var r=t.split(".").reverse(),n=e.split(".").reverse();if(r.length<=1)return t===e;for(var i=0;i<r.length;i++)if(r[i]!==n[i])return!1;return!0}(t,e)}"undefined"!=typeof performance&&void 0!==performance.timing?performance.timing.navigationStart:Date.now();var _e=Te(JSON.parse(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=113,n=126,i=0,s="";return arguments[i].split(s).map((function(t){return t.charCodeAt(i)>n?t:String.fromCharCode((t.charCodeAt(i)+r)%n)})).join(s)}("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")));!function(t){function r(e,r,n){return t.call(this,"[NETWORK]: response error(type: "+r+", reason: "+n+"): "+e)||this}e.__extends(r,t)}(Error),function(t){function r(e,r,n){var i=t.call(this,"[NETWORK]: response error(type: "+r+", status: "+n+"): "+e)||this;return i.httpStatus=n,i}e.__extends(r,t)}(Error),function(t){function r(e,r){return t.call(this,"[NETWORK]: request abort(type: "+r+"): "+e)||this}e.__extends(r,t)}(Error),function(t){function r(e,r,n){return t.call(this,"[NETWORK]: request timeout(type: "+r+", timeout: "+n+"ms): "+e)||this}e.__extends(r,t)}(Error),function(t){function r(e,r,n){return t.call(this,"[NETWORK]: request forbidden(type: "+r+", reason: "+n+"): "+e)||this}e.__extends(r,t)}(Error),function(t){function r(){return null!==t&&t.apply(this,arguments)||this}e.__extends(r,t)}(Se);function Ve(t,e){void 0===e&&(e=!1);var r=typeof t;if("string"===r)return JSON.stringify(t);if(!0===t)return"true";if(!1===t)return"false";if(null===t)return"null";if(t instanceof Array){for(var n="[",i=t.length-1,s=0;s<i;s++)n+=Ve(t[s],!1)+",";return i>-1&&(n+=Ve(t[s],!1)),n+"]"}if(t instanceof Object){if("function"==typeof t.toJSON)return Ve(t.toJSON(),e);var o=Object.keys(t).sort(),a=o.length;for(n="",s=0;s<a;){var u=o[s],h=Ve(t[u],!0);void 0!==h&&(s&&""!==n&&(n+=","),n+=JSON.stringify(u)+":"+h),s++}return"{"+n+"}"}switch(r){case"function":case"undefined":return e?void 0:null;case"number":return 0;default:return isFinite(t)?t:null}}function Be(t){return String(Ve(t,!1))}function He(t){var e,r,n,i=JSON.parse(t),s="undefined"!=typeof location?location.hostname:"",o=Date.now();if("object"!=typeof i)return new Error("input is not an object");if(0===s.length||/^(([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])(\.(?!$)|$)){4}$/.test(s)||_e.filter((function(t){return je(t,s)})).length>0){var a=String(null!==(e=i.certificate)&&void 0!==e?e:"");if(a){var u=new kt;return u.readCertPEM(a),{issuer:u.getSubjectString()}}return{issuer:"none"}}var h=String(null!==(r=i.certificate)&&void 0!==r?r:"");if(!h)return new Error("certificate is not existed.");var c=new kt;c.readCertPEM(h);var l=String(null!==(n=i._signature)&&void 0!==n?n:"");if(!l)return new Error("signature is not existed.");if(!1===function(t,e,r){var n=new kt;if("string"==typeof r?n.readCertPEM(r):n.readCertHex(r.hex),!1===Ht(n))return!1;var i=new tt;return i.readCertPubKeyHex(n.hex,6),!!i.verify(t,K(e))}(Be(function(t,e){for(var r={},n=0,i=Object.keys(t);n<i.length;n++){var s=i[n];-1===e.indexOf(s)&&(r[s]=t[s])}return r}(i,["_signature"])),l,c))return new Error("signature verify failed.");var f=new Date("string"==typeof i.expire_at&&/^\d+$/.test(i.expire_at)?Number(i.expire_at):i.expire_at);return o<f.getTime()?0===(Array.isArray(i.allow_hosts)?i.allow_hosts:[]).filter((function(t){return je(t,s)})).length?function(t){return new Error("host("+JSON.stringify(t)+") is not allowed.")}(s):{issuer:c.getSubjectString()}:function(t){return new Error("date("+t.toString()+") expired.")}(f)}var Me=new WeakMap;function Ke(t,e,r){var n,i=JSON.stringify(e),s=JSON.stringify(t),o=He(s);t=JSON.parse(s),e=JSON.parse(i);var u=new De;u.issuer=o instanceof Error?"none":o.issuer,u.raw={work:t,options:e};var h=null!==(n=t.base_url)&&void 0!==n?n:"";h&&"/"!==h[h.length-1]&&(h+="/");var c=function(t,n){var i,s=t;!0===e.jsonp&&(s=(s=t.replace(/([\?\#].*)?$/i,""))+"."+jt(""+s).slice(0,7)+".jsonp");if(!0===e.shortPath){var o=s.replace(h,"").split("."),a=null!==(i=o.shift())&&void 0!==i?i:"",u=o.join(".");s=Oe(h,jt(a))+(u?"."+u:"")}var c=s.replace(h,"");return e.baseURL&&(s=Oe(e.baseURL,c)),r&&r(t,s,c,n),s},l=function(e,r){var n,i,s,o,a,u,l=e;if(!Ne(e)){var f=null!==(u=null!==(o=null!==(i=null===(n=t.panorama)||void 0===n?void 0:n.pano_high_cube_base_url)&&void 0!==i?i:null===(s=t.panorama)||void 0===s?void 0:s.pano_cube_base_url)&&void 0!==o?o:null===(a=t.panorama)||void 0===a?void 0:a.base_url)&&void 0!==u?u:"";f&&(f=Oe(f,String(r))),l=Oe(f,l)}return Ne(l)||(l=Oe(h,l)),c(l,"panorama")},f=function(t){var e=t;return Ne(e)||(e=Oe(h,t)),c(e,"model")},d=function(t,e){void 0===e&&(e="");var r=t;return Ne(r)||(r=Oe(e,r)),Ne(r)||(r=Oe(h,r)),c(r,"texture")};if(u.workCode=String(t.work_code||t.code||t.vr_code||t.workCode),u.name=String(t.name),u.expire=new Date("string"==typeof t.expire_at&&/^\d+$/.test(t.expire_at)?Number(t.expire_at):t.expire_at),u.allowHosts=t.allow_hosts||[],Re(o))return o;if(t.initial&&("Floorplan"!==t.initial.mode&&"Topview"!==t.initial.mode&&"Panorama"!==t.initial.mode&&"VRPanorama"!==t.initial.mode&&"Model"!==t.initial.mode&&"DepthPanorama"!==t.initial.mode||(u.initial.mode=t.initial.mode),Ie(t.initial.latitude)&&(u.initial.latitude=t.initial.latitude),Ie(t.initial.longitude)?u.initial.longitude=t.initial.longitude:Ie(t.initial.heading)&&(u.initial.longitude=-(360*(t.initial.heading-.25)+90)/180*Math.PI),Ie(t.initial.fov)&&(u.initial.fov=t.initial.fov),Ie(t.initial.panoIndex)?u.initial.panoIndex=t.initial.panoIndex:Ie(t.initial.pano_index)?u.initial.panoIndex=t.initial.pano_index:Ie(t.initial.pano)&&(u.initial.panoIndex=t.initial.pano)),Re(o))return o;if(t.model){var p={bvh:!0,async:!1,textureBase:"",textures:[]};"boolean"==typeof e.modelBvh?p.bvh=e.modelBvh:"boolean"==typeof t.model.bvh?p.bvh=t.model.bvh:"boolean"==typeof t.bvh&&(p.bvh=t.bvh),e.modelAsync,p.async=e.modelAsync,t.model.file?p.file=f(t.model.file):t.model.file_url&&(p.file=f(t.model.file_url)),t.model.textureBase?p.textureBase=t.model.textureBase:t.model.material_base_url&&(p.textureBase=t.model.material_base_url),Array.isArray(t.model.textures)?p.textures=t.model.textures.map((function(t){return d(t,p.textureBase)})):Array.isArray(t.model.material_textures)&&(p.textures=t.model.material_textures.map((function(t){return d(t,p.textureBase)}))),p.file&&(u.model=p)}if(Re(o))return o;if(t.observers&&Array.isArray(t.observers)){var g=[];t.panorama&&(Array.isArray(t.panorama)?g=t.panorama:Array.isArray(t.panorama.list)?g=t.panorama.list:Array.isArray(t.panorama.info)&&(g=t.panorama.info));for(var y=0;y<t.observers.length;y++){var m={},v=t.observers[y];if(!v)break;var x=g[y]||{};v=Object.assign({},v,x,{active:!1!==v.active&&!1!==x.active}),m.panoIndex=y,m.active=!1!==v.active,m.loadable=!0===v.loadable,m.images={up:l(v.images?v.images.up:v.up,y),down:l(v.images?v.images.down:v.down,y),right:l(v.images?v.images.right:v.right,y),left:l(v.images?v.images.left:v.left,y),front:l(v.images?v.images.front:v.front,y),back:l(v.images?v.images.back:v.back,y)};var b=v.images?v.images.depth:v.depth;b&&(m.images.depth=l(b,y));var w=v.images?v.images.luminance:v.luminance;w&&(m.images.luminance={up:l(w.up,y),down:l(w.down,y),right:l(w.right,y),left:l(w.left,y),front:l(w.front,y),back:l(w.back,y)});var S=v.images?v.images.tiles:v.tiles;if(S){for(var E=[],A=function(t){var e,r=t.match(/\/cube_(\d+)\//);if(r){var n=Number(r[1]);if(0==((e=n)&e-1)&&0!==e)return n}return!1},P=function(t,e){return t.replace(/\/cube_(\d+)\//,(function(){return"/cube_"+e+"/"}))},D=0,N=S;D<N.length;D++){var O=N[D];if("number"==typeof O){var T=O,R=A(m.images.front);if(!1===R)continue;if((B=Math.max(R,512*Math.pow(2,T)))>2048){var C=P(m.images.up,B),I=P(m.images.down,B),k=P(m.images.right,B),j=P(m.images.left,B),_=P(m.images.front,B),V=P(m.images.back,B);E.push({level:T,size:B,up:C,down:I,right:k,left:j,front:_,back:V})}else{C=m.images.up,I=m.images.down,k=m.images.right,j=m.images.left,_=m.images.front,V=m.images.back;E.push({level:T,size:B,up:C,down:I,right:k,left:j,front:_,back:V})}}else{var B;if("number"!=typeof(T=O.level))continue;if("number"!=typeof(B=O.size))continue;C=l(O.up,y),I=l(O.down,y),k=l(O.right,y),j=l(O.left,y),_=l(O.front,y),V=l(O.back,y);E.push({level:T,size:B,up:C,down:I,right:k,left:j,front:_,back:V})}}E.sort((function(t,e){return t.level-e.level})),m.images.tiles=E}if(v.position instanceof a.Vector3)m.position=v.position.clone();else{if(!Array.isArray(v.position))break;m.position=(new a.Vector3).fromArray(v.position)}if(v.standingPosition instanceof a.Vector3)m.standingPosition=v.standingPosition.clone();else if(Array.isArray(v.standingPosition))m.standingPosition=(new a.Vector3).fromArray(v.standingPosition);else if(v.standing_position instanceof a.Vector3)m.standingPosition=v.standing_position.clone();else{if(!Array.isArray(v.standing_position))break;m.standingPosition=(new a.Vector3).fromArray(v.standing_position)}if(v.quaternion instanceof a.Quaternion)m.quaternion=v.quaternion.clone();else if(Array.isArray(v.quaternion))m.quaternion=(new a.Quaternion).fromArray(v.quaternion);else{if(!v.quaternion)break;var H=v.quaternion,M=H.x,K=H.y,L=H.z,z=H.w;m.quaternion=new a.Quaternion(M,K,L,z)}if(Array.isArray(v.accessibleNodes)?m.accessibleNodes=v.accessibleNodes.slice():Array.isArray(v.accessible_nodes)&&(m.accessibleNodes=v.accessible_nodes.slice()),Array.isArray(v.visibleNodes)?m.visibleNodes=v.visibleNodes.slice():Array.isArray(v.visible_nodes)&&(m.visibleNodes=v.visible_nodes.slice()),Ie(v.floorIndex)?m.floorIndex=v.floorIndex:Ie(v.floor_index)?m.floorIndex=v.floor_index:m.floorIndex=0,v.video){var F={};"string"==typeof v.video.source&&(F.source=v.video.source),v.video.matrix instanceof a.Matrix4?F.matrix=v.video.matrix.clone():Array.isArray(v.video.matrix)&&(F.matrix=(new a.Matrix4).fromArray(v.video.matrix)),v.video.size instanceof a.Vector2?F.size=v.video.size.clone():Array.isArray(v.video.size)&&(F.size=(new a.Vector2).fromArray(v.video.size)),F.source&&F.matrix&&F.size&&(m.video=F)}u.observers[y]=m}}if(Re(o))return o;for(var U=0,q=u.observers;U<q.length;U++){if(!(m=q[U]).accessibleNodes){m.accessibleNodes=[];for(var G=0;G<u.observers.length;G++)u.observers[G]!==m&&m.accessibleNodes.push(G)}if(!m.visibleNodes){m.visibleNodes=[];for(G=0;G<u.observers.length;G++)u.observers[G]!==m&&m.visibleNodes.push(G)}}if(Re(o))return o;var Q=Te(u);return Me.set(Q,{work:s,options:i}),Q}exports.BVH=Qt,exports.BVHNode=Ut,exports.BVHVector3=Ft,exports.Model=Pe,exports.PBMGroup=ce,exports.PBMMesh=Wt,exports.Subscribe=Se,exports.parseWork=function(t,e,r){"string"==typeof t&&"{"===t.trim()[0]&&(t=JSON.parse(t));var n=Me.get(t);if(n){if(e&&!Ce(JSON.parse(n.options),e))throw new Error("[PARSE FAILED]: work is parsed with different options.");return t}var i=Ke(t,null!=e?e:{},r);if(Re(i))throw new Error("[PARSE FAILED]: "+i.message);return i};
367
+ function(t,e){for(var r=t.toByteArray(),n=0;n<r.length&&0==r[n];)++n;if(r.length-n!=e-1||2!=r[n])return null;for(++n;0!=r[n];)if(++n>=r.length)return null;for(var i="";++n<r.length;){var s=255&r[n];s<128?i+=String.fromCharCode(s):s>191&&s<224?(i+=String.fromCharCode((31&s)<<6|63&r[n+1]),++n):(i+=String.fromCharCode((15&s)<<12|(63&r[n+1])<<6|63&r[n+2]),n+=2)}return i}(r,this.n.bitLength()+7>>3)},tt.prototype.decryptOAEP=function(t,e,r){if(t.length!=Math.ceil(this.n.bitLength()/4))throw new Error("wrong ctext length");var n=$(t,16),i=this.doPrivate(n);return null==i?null:function(t,e,r,n){var i=d.crypto.MessageDigest,s=d.crypto.Util,o=null;for(r||(r="sha1"),"string"==typeof r&&(o=i.getCanonicalAlgName(r),n=i.getHashLength(o),r=function(t){return ht(s.hashHex(ct(t),o))}),t=t.toByteArray(),a=0;a<t.length;a+=1)t[a]&=255;for(;t.length<e;)t.unshift(0);if((t=String.fromCharCode.apply(String,t)).length<2*n+2)throw"Cipher too short";var a,u=t.substr(1,n),h=t.substr(n+1),c=et(h,n,r),l=[];for(a=0;a<u.length;a+=1)l[a]=u.charCodeAt(a)^c.charCodeAt(a);var f=et(String.fromCharCode.apply(String,l),t.length-n,r),p=[];for(a=0;a<h.length;a+=1)p[a]=h.charCodeAt(a)^f.charCodeAt(a);if((p=String.fromCharCode.apply(String,p)).substr(0,n)!==r(""))throw"Hash mismatch";var g=(p=p.substr(n)).indexOf("");if((-1!=g?p.substr(0,g).lastIndexOf("\0"):-1)+1!=g)throw"Malformed data";return p.substr(g+1)}(i,this.n.bitLength()+7>>3,e,r)},void 0!==d.lang&&d.lang||(d.lang={}),d.lang.String=function(){},d.lang.String.isInteger=function(t){return!!t.match(/^[0-9]+$/)||!!t.match(/^-[0-9]+$/)},d.lang.String.isHex=function(t){return yt(t)},d.lang.String.isBase64=function(t){return!(!(t=t.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||t.length%4!=0)},d.lang.String.isBase64URL=function(t){return!t.match(/[+/=]/)&&(t=it(t),d.lang.String.isBase64(t))},d.lang.String.isIntegerArray=function(t){return!!(t=t.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)},d.lang.String.isPrintable=function(t){return null!==t.match(/^[0-9A-Za-z '()+,-./:=?]*$/)},d.lang.String.isIA5=function(t){return null!==t.match(/^[\x20-\x21\x23-\x7f]*$/)},d.lang.String.isMail=function(t){return null!==t.match(/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]{1,}\.[A-Za-z0-9]{1,}$/)};var vt=function(t,e,r){return null==r&&(r="0"),t.length>=e?t:new Array(e-t.length+1).join(r)+t};function xt(t,e){var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e)}void 0!==d.crypto&&d.crypto||(d.crypto={}),d.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:g.algo.MD5,sha1:g.algo.SHA1,sha224:g.algo.SHA224,sha256:g.algo.SHA256,sha384:g.algo.SHA384,sha512:g.algo.SHA512,ripemd160:g.algo.RIPEMD160},this.getDigestInfoHex=function(t,e){if(void 0===this.DIGESTINFOHEAD[e])throw"alg not supported in Util.DIGESTINFOHEAD: "+e;return this.DIGESTINFOHEAD[e]+t},this.getPaddedDigestInfoHex=function(t,e,r){var n=this.getDigestInfoHex(t,e),i=r/4;if(n.length+22>i)throw"key is too short for SigAlg: keylen="+r+","+e;for(var s="0001",o="00"+n,a="",u=i-s.length-o.length,h=0;h<u;h+=2)a+="ff";return s+a+o},this.hashString=function(t,e){return new d.crypto.MessageDigest({alg:e}).digestString(t)},this.hashHex=function(t,e){return new d.crypto.MessageDigest({alg:e}).digestHex(t)},this.sha1=function(t){return this.hashString(t,"sha1")},this.sha256=function(t){return this.hashString(t,"sha256")},this.sha256Hex=function(t){return this.hashHex(t,"sha256")},this.sha512=function(t){return this.hashString(t,"sha512")},this.sha512Hex=function(t){return this.hashHex(t,"sha512")},this.isKey=function(t){return t instanceof tt||t instanceof d.crypto.DSA||t instanceof d.crypto.ECDSA}},d.crypto.Util.md5=function(t){return new d.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(t)},d.crypto.Util.ripemd160=function(t){return new d.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(t)},d.crypto.Util.SECURERANDOMGEN=new X,d.crypto.Util.getRandomHexOfNbytes=function(t){var e=new Array(t);return d.crypto.Util.SECURERANDOMGEN.nextBytes(e),rt(e)},d.crypto.Util.getRandomBigIntegerOfNbytes=function(t){return new y(d.crypto.Util.getRandomHexOfNbytes(t),16)},d.crypto.Util.getRandomHexOfNbits=function(t){var e=t%8,r=new Array((t-e)/8+1);return d.crypto.Util.SECURERANDOMGEN.nextBytes(r),r[0]=(255<<e&255^255)&r[0],rt(r)},d.crypto.Util.getRandomBigIntegerOfNbits=function(t){return new y(d.crypto.Util.getRandomHexOfNbits(t),16)},d.crypto.Util.getRandomBigIntegerZeroToMax=function(t){for(var e=t.bitLength();;){var r=d.crypto.Util.getRandomBigIntegerOfNbits(e);if(-1!=t.compareTo(r))return r}},d.crypto.Util.getRandomBigIntegerMinToMax=function(t,e){var r=t.compareTo(e);if(1==r)throw"biMin is greater than biMax";if(0==r)return t;var n=e.subtract(t);return d.crypto.Util.getRandomBigIntegerZeroToMax(n).add(t)},d.crypto.MessageDigest=function(t){this.setAlgAndProvider=function(t,e){if(null!==(t=d.crypto.MessageDigest.getCanonicalAlgName(t))&&void 0===e&&(e=d.crypto.Util.DEFAULTPROVIDER[t]),-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(t)&&"cryptojs"==e){try{this.md=d.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[t].create()}catch(e){throw"setAlgAndProvider hash alg set fail alg="+t+"/"+e}this.updateString=function(t){this.md.update(t)},this.updateHex=function(t){var e=g.enc.Hex.parse(t);this.md.update(e)},this.digest=function(){return this.md.finalize().toString(g.enc.Hex)},this.digestString=function(t){return this.updateString(t),this.digest()},this.digestHex=function(t){return this.updateHex(t),this.digest()}}if(-1!=":sha256:".indexOf(t)&&"sjcl"==e){try{this.md=new sjcl.hash.sha256}catch(e){throw"setAlgAndProvider hash alg set fail alg="+t+"/"+e}this.updateString=function(t){this.md.update(t)},this.updateHex=function(t){var e=sjcl.codec.hex.toBits(t);this.md.update(e)},this.digest=function(){var t=this.md.finalize();return sjcl.codec.hex.fromBits(t)},this.digestString=function(t){return this.updateString(t),this.digest()},this.digestHex=function(t){return this.updateHex(t),this.digest()}}},this.updateString=function(t){throw"updateString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.updateHex=function(t){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(t){throw"digestString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestHex=function(t){throw"digestHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},void 0!==t&&void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov&&(this.provName=d.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},d.crypto.MessageDigest.getCanonicalAlgName=function(t){return"string"==typeof t&&(t=(t=t.toLowerCase()).replace(/-/,"")),t},d.crypto.MessageDigest.getHashLength=function(t){var e=d.crypto.MessageDigest,r=e.getCanonicalAlgName(t);if(void 0===e.HASHLENGTH[r])throw"not supported algorithm: "+t;return e.HASHLENGTH[r]},d.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},d.crypto.Mac=function(t){this.setAlgAndProvider=function(t,e){if(null==(t=t.toLowerCase())&&(t="hmacsha1"),"hmac"!=(t=t.toLowerCase()).substr(0,4))throw"setAlgAndProvider unsupported HMAC alg: "+t;void 0===e&&(e=d.crypto.Util.DEFAULTPROVIDER[t]),this.algProv=t+"/"+e;var r=t.substr(4);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(r)&&"cryptojs"==e){try{var n=d.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[r];this.mac=g.algo.HMAC.create(n,this.pass)}catch(t){throw"setAlgAndProvider hash alg set fail hashAlg="+r+"/"+t}this.updateString=function(t){this.mac.update(t)},this.updateHex=function(t){var e=g.enc.Hex.parse(t);this.mac.update(e)},this.doFinal=function(){return this.mac.finalize().toString(g.enc.Hex)},this.doFinalString=function(t){return this.updateString(t),this.doFinal()},this.doFinalHex=function(t){return this.updateHex(t),this.doFinal()}}},this.updateString=function(t){throw"updateString(str) not supported for this alg/prov: "+this.algProv},this.updateHex=function(t){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(t){throw"digestString(str) not supported for this alg/prov: "+this.algProv},this.doFinalHex=function(t){throw"digestHex(hex) not supported for this alg/prov: "+this.algProv},this.setPassword=function(t){if("string"==typeof t){var e=t;return t.length%2!=1&&t.match(/^[0-9A-Fa-f]+$/)||(e=ct(t)),void(this.pass=g.enc.Hex.parse(e))}if("object"!=typeof t)throw"KJUR.crypto.Mac unsupported password type: "+t;e=null;if(void 0!==t.hex){if(t.hex.length%2!=0||!t.hex.match(/^[0-9A-Fa-f]+$/))throw"Mac: wrong hex password: "+t.hex;e=t.hex}if(void 0!==t.utf8&&(e=at(t.utf8)),void 0!==t.rstr&&(e=ct(t.rstr)),void 0!==t.b64&&(e=K(t.b64)),void 0!==t.b64u&&(e=ot(t.b64u)),null==e)throw"KJUR.crypto.Mac unsupported password type: "+t;this.pass=g.enc.Hex.parse(e)},void 0!==t&&(void 0!==t.pass&&this.setPassword(t.pass),void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov&&(this.provName=d.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))},d.crypto.Signature=function(t){var e=null;if(this._setAlgNames=function(){var t=this.algName.match(/^(.+)with(.+)$/);t&&(this.mdAlgName=t[1].toLowerCase(),this.pubkeyAlgName=t[2].toLowerCase(),"rsaandmgf1"==this.pubkeyAlgName&&"sha"==this.mdAlgName&&(this.mdAlgName="sha1"))},this._zeroPaddingOfSignature=function(t,e){for(var r="",n=e/4-t.length,i=0;i<n;i++)r+="0";return r+t},this.setAlgAndProvider=function(t,e){if(this._setAlgNames(),"cryptojs/jsrsa"!=e)throw new Error("provider not supported: "+e);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(this.mdAlgName)){try{this.md=new d.crypto.MessageDigest({alg:this.mdAlgName})}catch(t){throw new Error("setAlgAndProvider hash alg set fail alg="+this.mdAlgName+"/"+t)}this.init=function(t,e){var r=null;try{r=void 0===e?Ot.getKey(t):Ot.getKey(t,e)}catch(t){throw"init failed:"+t}if(!0===r.isPrivate)this.prvKey=r,this.state="SIGN";else{if(!0!==r.isPublic)throw"init failed.:"+r;this.pubKey=r,this.state="VERIFY"}},this.updateString=function(t){this.md.updateString(t)},this.updateHex=function(t){this.md.updateHex(t)},this.sign=function(){if(this.sHashHex=this.md.digest(),void 0===this.prvKey&&void 0!==this.ecprvhex&&void 0!==this.eccurvename&&void 0!==d.crypto.ECDSA&&(this.prvKey=new d.crypto.ECDSA({curve:this.eccurvename,prv:this.ecprvhex})),this.prvKey instanceof tt&&"rsaandmgf1"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHashPSS(this.sHashHex,this.mdAlgName,this.pssSaltLen);else if(this.prvKey instanceof tt&&"rsa"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex,this.mdAlgName);else if(this.prvKey instanceof d.crypto.ECDSA)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex);else{if(!(this.prvKey instanceof d.crypto.DSA))throw"Signature: unsupported private key alg: "+this.pubkeyAlgName;this.hSign=this.prvKey.signWithMessageHash(this.sHashHex)}return this.hSign},this.signString=function(t){return this.updateString(t),this.sign()},this.signHex=function(t){return this.updateHex(t),this.sign()},this.verify=function(t){if(this.sHashHex=this.md.digest(),void 0===this.pubKey&&void 0!==this.ecpubhex&&void 0!==this.eccurvename&&void 0!==d.crypto.ECDSA&&(this.pubKey=new d.crypto.ECDSA({curve:this.eccurvename,pub:this.ecpubhex})),this.pubKey instanceof tt&&"rsaandmgf1"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHashPSS(this.sHashHex,t,this.mdAlgName,this.pssSaltLen);if(this.pubKey instanceof tt&&"rsa"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==d.crypto.ECDSA&&this.pubKey instanceof d.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==d.crypto.DSA&&this.pubKey instanceof d.crypto.DSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);throw"Signature: unsupported public key alg: "+this.pubkeyAlgName}}},this.init=function(t,e){throw"init(key, pass) not supported for this alg:prov="+this.algProvName},this.updateString=function(t){throw"updateString(str) not supported for this alg:prov="+this.algProvName},this.updateHex=function(t){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(t){throw"digestString(str) not supported for this alg:prov="+this.algProvName},this.signHex=function(t){throw"digestHex(hex) not supported for this alg:prov="+this.algProvName},this.verify=function(t){throw"verify(hSigVal) not supported for this alg:prov="+this.algProvName},this.initParams=t,void 0!==t&&(void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov?this.provName=d.crypto.Util.DEFAULTPROVIDER[this.algName]:this.provName=t.prov,this.algProvName=this.algName+":"+this.provName,this.setAlgAndProvider(this.algName,this.provName),this._setAlgNames()),void 0!==t.psssaltlen&&(this.pssSaltLen=t.psssaltlen),void 0!==t.prvkeypem)){if(void 0!==t.prvkeypas)throw"both prvkeypem and prvkeypas parameters not supported";try{e=Ot.getKey(t.prvkeypem);this.init(e)}catch(t){throw"fatal error to load pem private key: "+t}}},d.crypto.Cipher=function(t){},d.crypto.Cipher.encrypt=function(t,e,r){if(e instanceof tt&&e.isPublic){var n=d.crypto.Cipher.getAlgByKeyAndName(e,r);if("RSA"===n)return e.encrypt(t);if("RSAOAEP"===n)return e.encryptOAEP(t,"sha1");var i=n.match(/^RSAOAEP(\d+)$/);if(null!==i)return e.encryptOAEP(t,"sha"+i[1]);throw"Cipher.encrypt: unsupported algorithm for RSAKey: "+r}throw"Cipher.encrypt: unsupported key or algorithm"},d.crypto.Cipher.decrypt=function(t,e,r){if(e instanceof tt&&e.isPrivate){var n=d.crypto.Cipher.getAlgByKeyAndName(e,r);if("RSA"===n)return e.decrypt(t);if("RSAOAEP"===n)return e.decryptOAEP(t,"sha1");var i=n.match(/^RSAOAEP(\d+)$/);if(null!==i)return e.decryptOAEP(t,"sha"+i[1]);throw"Cipher.decrypt: unsupported algorithm for RSAKey: "+r}throw"Cipher.decrypt: unsupported key or algorithm"},d.crypto.Cipher.getAlgByKeyAndName=function(t,e){if(t instanceof tt){if(-1!=":RSA:RSAOAEP:RSAOAEP224:RSAOAEP256:RSAOAEP384:RSAOAEP512:".indexOf(e))return e;if(null==e)return"RSA";throw"getAlgByKeyAndName: not supported algorithm name for RSAKey: "+e}throw"getAlgByKeyAndName: not supported algorithm name: "+e},d.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 bt,wt,St,Et,At,Pt,Dt,Nt,Ot=(bt=function(t,e,r){return wt(g.AES,t,e,r)},wt=function(t,e,r,n){var i=g.enc.Hex.parse(e),s=g.enc.Hex.parse(r),o=g.enc.Hex.parse(n),a={};a.key=s,a.iv=o,a.ciphertext=i;var u=t.decrypt(a,s,{iv:o});return g.enc.Hex.stringify(u)},St=function(t,e,r){return Et(g.AES,t,e,r)},Et=function(t,e,r,n){var i=g.enc.Hex.parse(e),s=g.enc.Hex.parse(r),o=g.enc.Hex.parse(n),a=t.encrypt(i,s,{iv:o}),u=g.enc.Hex.parse(a.toString());return g.enc.Base64.stringify(u)},At={"AES-256-CBC":{proc:bt,eproc:St,keylen:32,ivlen:16},"AES-192-CBC":{proc:bt,eproc:St,keylen:24,ivlen:16},"AES-128-CBC":{proc:bt,eproc:St,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,e,r){return wt(g.TripleDES,t,e,r)},eproc:function(t,e,r){return Et(g.TripleDES,t,e,r)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,e,r){return wt(g.DES,t,e,r)},eproc:function(t,e,r){return Et(g.DES,t,e,r)},keylen:8,ivlen:8}},Pt=function(t){var e={},r=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));r&&(e.cipher=r[1],e.ivsalt=r[2]);var n=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(e.type=n[1]);var i=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(i=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(i=t.indexOf("\n\n"),s=1);var o=t.indexOf("-----END");if(-1!=i&&-1!=o){var a=t.substring(i+2*s,o-s);a=a.replace(/\s+/g,""),e.data=a}return e},Dt=function(t,e,r){for(var n=r.substring(0,16),i=g.enc.Hex.parse(n),s=g.enc.Utf8.parse(e),o=At[t].keylen+At[t].ivlen,a="",u=null;;){var h=g.algo.MD5.create();if(null!=u&&h.update(u),h.update(s),h.update(i),u=h.finalize(),(a+=g.enc.Hex.stringify(u)).length>=2*o)break}var c={};return c.keyhex=a.substr(0,2*At[t].keylen),c.ivhex=a.substr(2*At[t].keylen,2*At[t].ivlen),c},Nt=function(t,e,r,n){var i=g.enc.Base64.parse(t),s=g.enc.Hex.stringify(i);return(0,At[e].proc)(s,r,n)},{version:"1.0.0",parsePKCS5PEM:function(t){return Pt(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,r){return Dt(t,e,r)},decryptKeyB64:function(t,e,r,n){return Nt(t,e,r,n)},getDecryptedKeyHex:function(t,e){var r=Pt(t);r.type;var n=r.cipher,i=r.ivsalt,s=r.data,o=Dt(n,e,i).keyhex;return Nt(s,n,o,i)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,r,n,i){var s="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===At[n])throw"KEYUTIL unsupported algorithm: "+n;void 0!==i&&null!=i||(i=function(t){var e=g.lib.WordArray.random(t);return g.enc.Hex.stringify(e)}(At[n].ivlen).toUpperCase());var o=function(t,e,r,n){return(0,At[e].eproc)(t,r,n)}(e,n,Dt(n,r,i).keyhex,i);return s="-----BEGIN "+t+" PRIVATE KEY-----\r\n",s+="Proc-Type: 4,ENCRYPTED\r\n",s+="DEK-Info: "+n+","+i+"\r\n",s+="\r\n",s+=o.replace(/(.{64})/g,"$1\r\n"),s+="\r\n-----END "+t+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(t){var e=Tt,r=e.getChildIdx,n=e.getV,i={},s=r(t,0);if(2!=s.length)throw"malformed format: SEQUENCE(0).items != 2: "+s.length;i.ciphertext=n(t,s[1]);var o=r(t,s[0]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+o.length;if("2a864886f70d01050d"!=n(t,o[0]))throw"this only supports pkcs5PBES2";var a=r(t,o[1]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+a.length;var u=r(t,a[1]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+u.length;if("2a864886f70d0307"!=n(t,u[0]))throw"this only supports TripleDES";i.encryptionSchemeAlg="TripleDES",i.encryptionSchemeIV=n(t,u[1]);var h=r(t,a[0]);if(2!=h.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+h.length;if("2a864886f70d01050c"!=n(t,h[0]))throw"this only supports pkcs5PBKDF2";var c=r(t,h[1]);if(c.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+c.length;i.pbkdf2Salt=n(t,c[0]);var l=n(t,c[1]);try{i.pbkdf2Iter=parseInt(l,16)}catch(t){throw"malformed format pbkdf2Iter: "+l}return i},getPBKDF2KeyHexFromParam:function(t,e){var r=g.enc.Hex.parse(t.pbkdf2Salt),n=t.pbkdf2Iter,i=g.PBKDF2(e,r,{keySize:6,iterations:n});return g.enc.Hex.stringify(i)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var r=dt(t,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(r),i=Ot.getPBKDF2KeyHexFromParam(n,e),s={};s.ciphertext=g.enc.Hex.parse(n.ciphertext);var o=g.enc.Hex.parse(i),a=g.enc.Hex.parse(n.encryptionSchemeIV),u=g.TripleDES.decrypt(s,o,{iv:a});return g.enc.Hex.stringify(u)},getKeyFromEncryptedPKCS8PEM:function(t,e){var r=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(r)},parsePlainPrivatePKCS8Hex:function(t){var e=Tt,r=e.getChildIdx,n=e.getV,i={algparam:null};if("30"!=t.substr(0,2))throw new Error("malformed plain PKCS8 private key(code:001)");var s=r(t,0);if(s.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if("30"!=t.substr(s[1],2))throw new Error("malformed PKCS8 private key(code:003)");var o=r(t,s[1]);if(2!=o.length)throw new Error("malformed PKCS8 private key(code:004)");if("06"!=t.substr(o[0],2))throw new Error("malformed PKCS8 private key(code:005)");if(i.algoid=n(t,o[0]),"06"==t.substr(o[1],2)&&(i.algparam=n(t,o[1])),"04"!=t.substr(s[2],2))throw new Error("malformed PKCS8 private key(code:006)");return i.keyidx=e.getVidx(t,s[2]),i},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=dt(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,r=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==r.algoid)e=new tt;else if("2a8648ce380401"==r.algoid)e=new d.crypto.DSA;else{if("2a8648ce3d0201"!=r.algoid)throw"unsupported private key algorithm";e=new d.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,r=Tt.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===r)e=new tt;else if("2a8648ce380401"===r)e=new d.crypto.DSA;else{if("2a8648ce3d0201"!==r)throw"unsupported PKCS#8 public key hex";e=new d.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=Tt,r=e.getChildIdx,n=e.getV,i={};if("30"!=t.substr(0,2))throw"malformed RSA key(code:001)";var s=r(t,0);if(2!=s.length)throw"malformed RSA key(code:002)";if("02"!=t.substr(s[0],2))throw"malformed RSA key(code:003)";if(i.n=n(t,s[0]),"02"!=t.substr(s[1],2))throw"malformed RSA key(code:004)";return i.e=n(t,s[1]),i},parsePublicPKCS8Hex:function(t){var e=Tt,r=e.getChildIdx,n=e.getV,i={algparam:null},s=r(t,0);if(2!=s.length)throw"outer DERSequence shall have 2 elements: "+s.length;var o=s[0];if("30"!=t.substr(o,2))throw"malformed PKCS8 public key(code:001)";var a=r(t,o);if(2!=a.length)throw"malformed PKCS8 public key(code:002)";if("06"!=t.substr(a[0],2))throw"malformed PKCS8 public key(code:003)";if(i.algoid=n(t,a[0]),"06"==t.substr(a[1],2)?i.algparam=n(t,a[1]):"30"==t.substr(a[1],2)&&(i.algparam={},i.algparam.p=e.getVbyList(t,a[1],[0],"02"),i.algparam.q=e.getVbyList(t,a[1],[1],"02"),i.algparam.g=e.getVbyList(t,a[1],[2],"02")),"03"!=t.substr(s[1],2))throw"malformed PKCS8 public key(code:004)";return i.key=n(t,s[1]).substr(2),i}});Ot.getKey=function(t,e,r){var n=(v=Tt).getChildIdx;v.getV;var i=v.getVbyList,s=d.crypto,o=s.ECDSA,a=s.DSA,u=tt,h=dt,c=Ot;if(void 0!==u&&t instanceof u)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new o({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new o({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(T=new u).setPublic(t.n,t.e),T;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(T=new u).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),T;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(T=new u).setPrivate(t.n,t.e,t.d),T;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(T=new a).setPublic(t.p,t.q,t.g,t.y),T;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(T=new a).setPrivate(t.p,t.q,t.g,t.y,t.x),T;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(T=new u).setPublic(ot(t.n),ot(t.e)),T;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(T=new u).setPrivateEx(ot(t.n),ot(t.e),ot(t.d),ot(t.p),ot(t.q),ot(t.dp),ot(t.dq),ot(t.qi)),T;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(T=new u).setPrivate(ot(t.n),ot(t.e),ot(t.d)),T;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var l=(O=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+ot(t.x)).slice(-l)+("0000000000"+ot(t.y)).slice(-l);return O.setPublicKeyHex(f),O}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){l=(O=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+ot(t.x)).slice(-l)+("0000000000"+ot(t.y)).slice(-l);var p=("0000000000"+ot(t.d)).slice(-l);return O.setPublicKeyHex(f),O.setPrivateKeyHex(p),O}if("pkcs5prv"===r){var g,m=t,v=Tt;if(9===(g=n(m,0)).length)(T=new u).readPKCS5PrvKeyHex(m);else if(6===g.length)(T=new a).readPKCS5PrvKeyHex(m);else{if(!(g.length>2&&"04"===m.substr(g[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(T=new o).readPKCS5PrvKeyHex(m)}return T}if("pkcs8prv"===r)return T=c.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===r)return c._getKeyFromPublicPKCS8Hex(t);if("x509pub"===r)return kt.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return kt.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var x=dt(t,"PUBLIC KEY");return c._getKeyFromPublicPKCS8Hex(x)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var b=h(t,"RSA PRIVATE KEY");return c.getKey(b,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var w=i(I=h(t,"DSA PRIVATE KEY"),0,[1],"02"),S=i(I,0,[2],"02"),E=i(I,0,[3],"02"),A=i(I,0,[4],"02"),P=i(I,0,[5],"02");return(T=new a).setPrivate(new y(w,16),new y(S,16),new y(E,16),new y(A,16),new y(P,16)),T}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){b=h(t,"EC PRIVATE KEY");return c.getKey(b,null,"pkcs5prv")}if(-1!=t.indexOf("-END PRIVATE KEY-"))return c.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var D=c.getDecryptedKeyHex(t,e),N=new tt;return N.readPKCS5PrvKeyHex(D),N}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var O,T=i(I=c.getDecryptedKeyHex(t,e),0,[1],"04"),R=i(I,0,[2,0],"06"),C=i(I,0,[3,0],"03").substr(2);if(void 0===d.crypto.OID.oidhex2name[R])throw"undefined OID(hex) in KJUR.crypto.OID: "+R;return(O=new o({curve:d.crypto.OID.oidhex2name[R]})).setPublicKeyHex(C),O.setPrivateKeyHex(T),O.isPublic=!1,O}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var I;w=i(I=c.getDecryptedKeyHex(t,e),0,[1],"02"),S=i(I,0,[2],"02"),E=i(I,0,[3],"02"),A=i(I,0,[4],"02"),P=i(I,0,[5],"02");return(T=new a).setPrivate(new y(w,16),new y(S,16),new y(E,16),new y(A,16),new y(P,16)),T}if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return c.getKeyFromEncryptedPKCS8PEM(t,e);throw new Error("not supported argument")},Ot.generateKeypair=function(t,e){if("RSA"==t){var r=e;(o=new tt).generate(r,"10001"),o.isPrivate=!0,o.isPublic=!0;var n=new tt,i=o.n.toString(16),s=o.e.toString(16);return n.setPublic(i,s),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}if("EC"==t){var o,a,u=e,h=new d.crypto.ECDSA({curve:u}).generateKeyPairHex();return(o=new d.crypto.ECDSA({curve:u})).setPublicKeyHex(h.ecpubhex),o.setPrivateKeyHex(h.ecprvhex),o.isPrivate=!0,o.isPublic=!1,(n=new d.crypto.ECDSA({curve:u})).setPublicKeyHex(h.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}throw"unknown algorithm: "+t},Ot.getPEM=function(t,e,r,n,i,s){var o=d,a=o.asn1,u=a.DERObjectIdentifier,h=a.DERInteger,c=a.ASN1Util.newObject,l=a.x509.SubjectPublicKeyInfo,f=o.crypto,p=f.DSA,y=f.ECDSA,m=tt;function v(t){return c({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function x(t){return c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function b(t){return c({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((void 0!==m&&t instanceof m||void 0!==p&&t instanceof p||void 0!==y&&t instanceof y)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return ft(A=new l(t).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==m&&t instanceof m&&(void 0===r||null==r)&&1==t.isPrivate)return ft(A=v(t).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==y&&t instanceof y&&(void 0===r||null==r)&&1==t.isPrivate){var w=new u({name:t.curveName}).getEncodedHex(),S=x(t).getEncodedHex(),E="";return E+=ft(w,"EC PARAMETERS"),E+=ft(S,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==p&&t instanceof p&&(void 0===r||null==r)&&1==t.isPrivate)return ft(A=b(t).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==m&&t instanceof m&&void 0!==r&&null!=r&&1==t.isPrivate){var A=v(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",A,r,n,s)}if("PKCS5PRV"==e&&void 0!==y&&t instanceof y&&void 0!==r&&null!=r&&1==t.isPrivate){A=x(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",A,r,n,s)}if("PKCS5PRV"==e&&void 0!==p&&t instanceof p&&void 0!==r&&null!=r&&1==t.isPrivate){A=b(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",A,r,n,s)}var P=function(t,e){var r=D(t,e);return new c({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:r.pbkdf2Salt}},{int:r.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:r.encryptionSchemeIV}}]}]}]},{octstr:{hex:r.ciphertext}}]}).getEncodedHex()},D=function(t,e){var r=g.lib.WordArray.random(8),n=g.lib.WordArray.random(8),i=g.PBKDF2(e,r,{keySize:6,iterations:100}),s=g.enc.Hex.parse(t),o=g.TripleDES.encrypt(s,i,{iv:n})+"",a={};return a.ciphertext=o,a.pbkdf2Salt=g.enc.Hex.stringify(r),a.pbkdf2Iter=100,a.encryptionSchemeAlg="DES-EDE3-CBC",a.encryptionSchemeIV=g.enc.Hex.stringify(n),a};if("PKCS8PRV"==e&&null!=m&&t instanceof m&&1==t.isPrivate){var N=v(t).getEncodedHex();A=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:N}}]}).getEncodedHex();return void 0===r||null==r?ft(A,"PRIVATE KEY"):ft(S=P(A,r),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==y&&t instanceof y&&1==t.isPrivate){N=new c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]}).getEncodedHex(),A=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:N}}]}).getEncodedHex();return void 0===r||null==r?ft(A,"PRIVATE KEY"):ft(S=P(A,r),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==p&&t instanceof p&&1==t.isPrivate){N=new h({bigint:t.x}).getEncodedHex(),A=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:N}}]}).getEncodedHex();return void 0===r||null==r?ft(A,"PRIVATE KEY"):ft(S=P(A,r),"ENCRYPTED PRIVATE KEY")}throw new Error("unsupported object nor format")},Ot.getKeyFromCSRPEM=function(t){var e=dt(t,"CERTIFICATE REQUEST");return Ot.getKeyFromCSRHex(e)},Ot.getKeyFromCSRHex=function(t){var e=Ot.parseCSRHex(t);return Ot.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Ot.parseCSRHex=function(t){var e=Tt,r=e.getChildIdx,n=e.getTLV,i={},s=t;if("30"!=s.substr(0,2))throw"malformed CSR(code:001)";var o=r(s,0);if(o.length<1)throw"malformed CSR(code:002)";if("30"!=s.substr(o[0],2))throw"malformed CSR(code:003)";var a=r(s,o[0]);if(a.length<3)throw"malformed CSR(code:004)";return i.p8pubkeyhex=n(s,a[2]),i},Ot.getKeyID=function(t){var e=Ot,r=Tt;"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&(t=e.getKey(t));var n=dt(e.getPEM(t)),i=r.getIdxbyList(n,0,[1]),s=r.getV(n,i).substring(2);return d.crypto.Util.hashHex(s,"sha1")},Ot.getJWKFromKey=function(t){var e={};if(t instanceof tt&&t.isPrivate)return e.kty="RSA",e.n=st(t.n.toString(16)),e.e=st(t.e.toString(16)),e.d=st(t.d.toString(16)),e.p=st(t.p.toString(16)),e.q=st(t.q.toString(16)),e.dp=st(t.dmp1.toString(16)),e.dq=st(t.dmq1.toString(16)),e.qi=st(t.coeff.toString(16)),e;if(t instanceof tt&&t.isPublic)return e.kty="RSA",e.n=st(t.n.toString(16)),e.e=st(t.e.toString(16)),e;if(t instanceof d.crypto.ECDSA&&t.isPrivate){if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;var r=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=st(r.x),e.y=st(r.y),e.d=st(t.prvKeyHex),e}if(t instanceof d.crypto.ECDSA&&t.isPublic){var n;if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;r=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=st(r.x),e.y=st(r.y),e}throw"not supported key object"},void 0!==d.asn1&&d.asn1||(d.asn1={}),d.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var r=e.substr(1).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var n="",i=0;i<r;i++)n+="f";e=new y(n,16).xor(t).add(y.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return ft(t,e)},this.newObject=function(t){var e=d.asn1,r=e.ASN1Object,n=e.DERBoolean,i=e.DERInteger,s=e.DERBitString,o=e.DEROctetString,a=e.DERNull,u=e.DERObjectIdentifier,h=e.DEREnumerated,c=e.DERUTF8String,l=e.DERNumericString,f=e.DERPrintableString,p=e.DERTeletexString,g=e.DERIA5String,y=e.DERUTCTime,m=e.DERGeneralizedTime,v=e.DERVisibleString,x=e.DERBMPString,b=e.DERSequence,w=e.DERSet,S=e.DERTaggedObject,E=e.ASN1Util.newObject;if(t instanceof e.ASN1Object)return t;var A=Object.keys(t);if(1!=A.length)throw new Error("key of param shall be only one.");var P=A[0];if(-1==":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+P+":"))throw new Error("undefined key: "+P);if("bool"==P)return new n(t[P]);if("int"==P)return new i(t[P]);if("bitstr"==P)return new s(t[P]);if("octstr"==P)return new o(t[P]);if("null"==P)return new a(t[P]);if("oid"==P)return new u(t[P]);if("enum"==P)return new h(t[P]);if("utf8str"==P)return new c(t[P]);if("numstr"==P)return new l(t[P]);if("prnstr"==P)return new f(t[P]);if("telstr"==P)return new p(t[P]);if("ia5str"==P)return new g(t[P]);if("utctime"==P)return new y(t[P]);if("gentime"==P)return new m(t[P]);if("visstr"==P)return new v(t[P]);if("bmpstr"==P)return new x(t[P]);if("asn1"==P)return new r(t[P]);if("seq"==P){for(var D=t[P],N=[],O=0;O<D.length;O++){var T=E(D[O]);N.push(T)}return new b({array:N})}if("set"==P){for(D=t[P],N=[],O=0;O<D.length;O++){T=E(D[O]);N.push(T)}return new w({array:N})}if("tag"==P){var R=t[P];if("[object Array]"===Object.prototype.toString.call(R)&&3==R.length){var C=E(R[2]);return new S({tag:R[0],explicit:R[1],obj:C})}return new S(R)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},d.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",r=parseInt(t.substr(0,2),16),n=(e=Math.floor(r/40)+"."+r%40,""),i=2;i<t.length;i+=2){var s=("00000000"+parseInt(t.substr(i,2),16).toString(2)).slice(-8);if(n+=s.substr(1,7),"0"==s.substr(0,1))e=e+"."+new y(n,2).toString(10),n=""}return e},d.asn1.ASN1Util.oidIntToHex=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",n=new y(t,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var s="",o=0;o<i;o++)s+="0";n=s+n;for(o=0;o<n.length-1;o+=7){var a=n.substr(o,7);o!=n.length-7&&(a="1"+a),r+=e(parseInt(a,2))}return r};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var n="",i=t.split("."),s=40*parseInt(i[0])+parseInt(i[1]);n+=e(s),i.splice(0,2);for(var o=0;o<i.length;o++)n+=r(i[o]);return n},d.asn1.ASN1Object=function(t){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 t=this.hV.length/2,e=t.toString(16);if(e.length%2==1&&(e="0"+e),t<128)return e;var r=e.length/2;if(r>15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+r).toString(16)+e},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(t){this.params=t},null!=t&&null!=t.tlv&&(this.hTLV=t.tlv,this.isModified=!1)},d.asn1.DERAbstractString=function(t){d.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=at(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},p.lang.extend(d.asn1.DERAbstractString,d.asn1.ASN1Object),d.asn1.DERAbstractTime=function(t){d.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(t){var e=t.getTime()+6e4*t.getTimezoneOffset();return new Date(e)},this.formatDate=function(t,e,r){var n=this.zeroPadding,i=this.localDateToUTC(t),s=String(i.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+n(String(i.getMonth()+1),2)+n(String(i.getDate()),2)+n(String(i.getHours()),2)+n(String(i.getMinutes()),2)+n(String(i.getSeconds()),2);if(!0===r){var a=i.getMilliseconds();if(0!=a){var u=n(String(a),3);o=o+"."+(u=u.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=nt(t)},this.setByDateValue=function(t,e,r,n,i,s){var o=new Date(Date.UTC(t,e-1,r,n,i,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},p.lang.extend(d.asn1.DERAbstractTime,d.asn1.ASN1Object),d.asn1.DERAbstractStructured=function(t){d.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},p.lang.extend(d.asn1.DERAbstractStructured,d.asn1.ASN1Object),d.asn1.DERBoolean=function(t){d.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=0==t?"010100":"0101ff"},p.lang.extend(d.asn1.DERBoolean,d.asn1.ASN1Object),d.asn1.DERInteger=function(t){d.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=d.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new y(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},p.lang.extend(d.asn1.DERInteger,d.asn1.ASN1Object),d.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=d.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}d.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var r="0"+t;this.hTLV=null,this.isModified=!0,this.hV=r+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0);for(var r=0;r<=e;r++)t+="0";var n="";for(r=0;r<t.length-1;r+=8){var i=t.substr(r,8),s=parseInt(i,2).toString(16);1==s.length&&(s="0"+s),n+=s}this.hTLV=null,this.isModified=!0,this.hV="0"+e+n},this.setByBooleanArray=function(t){for(var e="",r=0;r<t.length;r++)1==t[r]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=!1;return e},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t&&t.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(t):void 0!==t.hex?this.setHexValueIncludingUnusedBits(t.hex):void 0!==t.bin?this.setByBinaryString(t.bin):void 0!==t.array&&this.setByBooleanArray(t.array))},p.lang.extend(d.asn1.DERBitString,d.asn1.ASN1Object),d.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=d.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}d.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},p.lang.extend(d.asn1.DEROctetString,d.asn1.DERAbstractString),d.asn1.DERNull=function(){d.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},p.lang.extend(d.asn1.DERNull,d.asn1.ASN1Object),d.asn1.DERObjectIdentifier=function(t){d.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){var e=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",n=parseInt(t,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var s="",o=0;o<i;o++)s+="0";for(n=s+n,o=0;o<n.length-1;o+=7){var a=n.substr(o,7);o!=n.length-7&&(a="1"+a),r+=e(parseInt(a,2))}return r};try{if(!t.match(/^[0-9.]+$/))return null;var n="",i=t.split("."),s=40*parseInt(i[0],10)+parseInt(i[1],10);n+=e(s),i.splice(0,2);for(var o=0;o<i.length;o++)n+=r(i[o]);return n}catch(t){return null}}(t);if(null==e)throw new Error("malformed oid string: "+t);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueName=function(t){var e=d.asn1.x509.OID.name2oid(t);if(""===e)throw new Error("DERObjectIdentifier oidName undefined: "+t);this.setValueOidString(e)},this.setValueNameOrOid=function(t){t.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(t):this.setValueName(t)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(t){"string"==typeof t?this.setValueNameOrOid(t):void 0!==t.oid?this.setValueNameOrOid(t.oid):void 0!==t.name?this.setValueNameOrOid(t.name):void 0!==t.hex&&this.setValueHex(t.hex)},void 0!==t&&this.setByParam(t)},p.lang.extend(d.asn1.DERObjectIdentifier,d.asn1.ASN1Object),d.asn1.DEREnumerated=function(t){d.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=d.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new y(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},p.lang.extend(d.asn1.DEREnumerated,d.asn1.ASN1Object),d.asn1.DERUTF8String=function(t){d.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},p.lang.extend(d.asn1.DERUTF8String,d.asn1.DERAbstractString),d.asn1.DERNumericString=function(t){d.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},p.lang.extend(d.asn1.DERNumericString,d.asn1.DERAbstractString),d.asn1.DERPrintableString=function(t){d.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},p.lang.extend(d.asn1.DERPrintableString,d.asn1.DERAbstractString),d.asn1.DERTeletexString=function(t){d.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},p.lang.extend(d.asn1.DERTeletexString,d.asn1.DERAbstractString),d.asn1.DERIA5String=function(t){d.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},p.lang.extend(d.asn1.DERIA5String,d.asn1.DERAbstractString),d.asn1.DERVisibleString=function(t){d.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="1a"},p.lang.extend(d.asn1.DERVisibleString,d.asn1.DERAbstractString),d.asn1.DERBMPString=function(t){d.asn1.DERBMPString.superclass.constructor.call(this,t),this.hT="1e"},p.lang.extend(d.asn1.DERBMPString,d.asn1.DERAbstractString),d.asn1.DERUTCTime=function(t){d.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"utc"),this.hV=nt(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=nt(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{12}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date))},p.lang.extend(d.asn1.DERUTCTime,d.asn1.DERAbstractTime),d.asn1.DERGeneralizedTime=function(t){d.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.withMillis=!1,this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=nt(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=nt(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{14}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date),!0===t.millis&&(this.withMillis=!0))},p.lang.extend(d.asn1.DERGeneralizedTime,d.asn1.DERAbstractTime),d.asn1.DERSequence=function(t){d.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++){t+=this.asn1Array[e].getEncodedHex()}return this.hV=t,this.hV}},p.lang.extend(d.asn1.DERSequence,d.asn1.DERAbstractStructured),d.asn1.DERSet=function(t){d.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var r=this.asn1Array[e];t.push(r.getEncodedHex())}return 1==this.sortFlag&&t.sort(),this.hV=t.join(""),this.hV},void 0!==t&&void 0!==t.sortflag&&0==t.sortflag&&(this.sortFlag=!1)},p.lang.extend(d.asn1.DERSet,d.asn1.DERAbstractStructured),d.asn1.DERTaggedObject=function(t){d.asn1.DERTaggedObject.superclass.constructor.call(this);var e=d.asn1;this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,r){this.hT=e,this.isExplicit=t,this.asn1Object=r,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=r.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(t){null!=t.tag&&(this.hT=t.tag),null!=t.explicit&&(this.isExplicit=t.explicit),null!=t.tage&&(this.hT=t.tage,this.isExplicit=!0),null!=t.tagi&&(this.hT=t.tagi,this.isExplicit=!1),null!=t.obj&&(t.obj instanceof e.ASN1Object?(this.asn1Object=t.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)):"object"==typeof t.obj&&(this.asn1Object=e.ASN1Util.newObject(t.obj),this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},null!=t&&this.setByParam(t)},p.lang.extend(d.asn1.DERTaggedObject,d.asn1.ASN1Object);var Tt=new function(){};function Rt(t,e){for(var r="",n=e/4-t.length,i=0;i<n;i++)r+="0";return r+t}function Ct(t,e,r){for(var n="",i=0;n.length<e;)n+=ht(r(ct(t+String.fromCharCode.apply(String,[(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i])))),i+=1;return n}function It(t){for(var e in d.crypto.Util.DIGESTINFOHEAD){var r=d.crypto.Util.DIGESTINFOHEAD[e],n=r.length;if(t.substring(0,n)==r)return[e,t.substring(n)]}return[]}function kt(t){var e,r=Tt,n=r.getChildIdx,i=r.getV,s=r.getTLV,o=r.getVbyList,a=r.getVbyListEx,u=r.getTLVbyList,h=r.getTLVbyListEx,c=r.getIdxbyList,l=r.getIdxbyListEx,f=r.getVidx,p=r.getInt,g=r.oidname,y=r.hextooidstr,m=dt;try{e=d.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV}catch(t){}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 t=u(this.hex,0,[0,0]);if("a0"==t.substr(0,2)){var e=u(t,0,[0]),r=p(e,0);if(r<0||2<r)throw new Error("malformed version field");return this.version=r+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 t=h(this.hex,0,[0,1]);return this.getAlgorithmIdentifierName(t)},this.getAlgorithmIdentifierName=function(t){for(var r in e)if(t===e[r])return r;return g(a(t,0,[0],"06"))},this.getIssuer=function(){return this.getX500Name(this.getIssuerHex())},this.getIssuerHex=function(){return u(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 u(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return this.getSubject().str},this.getNotBefore=function(){var t=o(this.hex,0,[0,4+this.foffset,0]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getNotAfter=function(){var t=o(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getPublicKeyHex=function(){return r.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return c(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return c(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return Ot.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){var t=u(this.hex,0,[1],"30");return this.getAlgorithmIdentifierName(t)},this.getSignatureValueHex=function(){return o(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmField(),r=this.getSignatureValueHex(),n=u(this.hex,0,[0],"30"),i=new d.crypto.Signature({alg:e});return i.init(t),i.updateHex(n),i.verify(r)},this.parseExt=function(t){var e,s,a;if(void 0===t){if(a=this.hex,3!==this.version)return-1;e=c(a,0,[0,7,0],"30"),s=n(a,e)}else{a=dt(t);var u=c(a,0,[0,3,0,0],"06");if("2a864886f70d01090e"!=i(a,u))return void(this.aExtInfo=new Array);e=c(a,0,[0,3,0,1,0],"30"),s=n(a,e),this.hex=a}this.aExtInfo=new Array;for(var h=0;h<s.length;h++){var l={critical:!1},d=0;3===n(a,s[h]).length&&(l.critical=!0,d=1),l.oid=r.hextooidstr(o(a,s[h],[0],"06"));var p=c(a,s[h],[1+d]);l.vidx=f(a,p),this.aExtInfo.push(l)}},this.getExtInfo=function(t){var e=this.aExtInfo,r=t;if(t.match(/^[0-9.]+$/)||(r=d.asn1.x509.OID.name2oid(t)),""!==r)for(var n=0;n<e.length;n++)if(e[n].oid===r)return e[n]},this.getExtBasicConstraints=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("basicConstraints");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var n={extname:"basicConstraints"};if(e&&(n.critical=!0),"3000"===t)return n;if("30030101ff"===t)return n.cA=!0,n;if("30060101ff02"===t.substr(0,12)){var o=i(t,10),a=parseInt(o,16);return n.cA=!0,n.pathLen=a,n}throw new Error("hExtV parse error: "+t)},this.getExtKeyUsage=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("keyUsage");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var n={extname:"keyUsage"};return e&&(n.critical=!0),n.names=this.getExtKeyUsageString(t).split(","),n},this.getExtKeyUsageBin=function(t){if(void 0===t){var e=this.getExtInfo("keyUsage");if(void 0===e)return"";t=s(this.hex,e.vidx)}if(8!=t.length&&10!=t.length)throw new Error("malformed key usage value: "+t);var r="000000000000000"+parseInt(t.substr(6),16).toString(2);return 8==t.length&&(r=r.slice(-8)),10==t.length&&(r=r.slice(-16)),""==(r=r.replace(/0+$/,""))&&(r="0"),r},this.getExtKeyUsageString=function(t){for(var e=this.getExtKeyUsageBin(t),r=new Array,n=0;n<e.length;n++)"1"==e.substr(n,1)&&r.push(kt.KEYUSAGE_NAME[n]);return r.join(",")},this.getExtSubjectKeyIdentifier=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectKeyIdentifier");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var n={extname:"subjectKeyIdentifier"};e&&(n.critical=!0);var o=i(t,0);return n.kid={hex:o},n},this.getExtAuthorityKeyIdentifier=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("authorityKeyIdentifier");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var o={extname:"authorityKeyIdentifier"};e&&(o.critical=!0);for(var a=n(t,0),u=0;u<a.length;u++){var h=t.substr(a[u],2);if("80"===h&&(o.kid={hex:i(t,a[u])}),"a1"===h){var c=s(t,a[u]),l=this.getGeneralNames(c);o.issuer=l[0].dn}"82"===h&&(o.sn={hex:i(t,a[u])})}return o},this.getExtExtKeyUsage=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("extKeyUsage");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var o={extname:"extKeyUsage",array:[]};e&&(o.critical=!0);for(var a=n(t,0),u=0;u<a.length;u++)o.array.push(g(i(t,a[u])));return o},this.getExtExtKeyUsageName=function(){var t=this.getExtInfo("extKeyUsage");if(void 0===t)return t;var e=new Array,r=s(this.hex,t.vidx);if(""===r)return e;for(var o=n(r,0),a=0;a<o.length;a++)e.push(g(i(r,o[a])));return e},this.getExtSubjectAltName=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectAltName");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var n={extname:"subjectAltName",array:[]};return e&&(n.critical=!0),n.array=this.getGeneralNames(t),n},this.getExtIssuerAltName=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("issuerAltName");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var n={extname:"issuerAltName",array:[]};return e&&(n.critical=!0),n.array=this.getGeneralNames(t),n},this.getGeneralNames=function(t){for(var e=n(t,0),r=[],i=0;i<e.length;i++){var o=this.getGeneralName(s(t,e[i]));void 0!==o&&r.push(o)}return r},this.getGeneralName=function(t){var e=t.substr(0,2),r=i(t,0),n=ht(r);return"81"==e?{rfc822:n}:"82"==e?{dns:n}:"86"==e?{uri:n}:"87"==e?{ip:pt(r)}:"a4"==e?{dn:this.getX500Name(r)}:void 0},this.getExtSubjectAltName2=function(){var t,e,r,o=this.getExtInfo("subjectAltName");if(void 0===o)return o;for(var a=new Array,u=s(this.hex,o.vidx),h=n(u,0),c=0;c<h.length;c++)r=u.substr(h[c],2),t=i(u,h[c]),"81"===r&&(e=ut(t),a.push(["MAIL",e])),"82"===r&&(e=ut(t),a.push(["DNS",e])),"84"===r&&(e=kt.hex2dn(t,0),a.push(["DN",e])),"86"===r&&(e=ut(t),a.push(["URI",e])),"87"===r&&(e=pt(t),a.push(["IP",e]));return a},this.getExtCRLDistributionPoints=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("cRLDistributionPoints");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var i={extname:"cRLDistributionPoints",array:[]};e&&(i.critical=!0);for(var o=n(t,0),a=0;a<o.length;a++){var u=s(t,o[a]);i.array.push(this.getDistributionPoint(u))}return i},this.getDistributionPoint=function(t){for(var e={},r=n(t,0),i=0;i<r.length;i++){var o=t.substr(r[i],2),a=s(t,r[i]);"a0"==o&&(e.dpname=this.getDistributionPointName(a))}return e},this.getDistributionPointName=function(t){for(var e={},r=n(t,0),i=0;i<r.length;i++){var o=t.substr(r[i],2),a=s(t,r[i]);"a0"==o&&(e.full=this.getGeneralNames(a))}return e},this.getExtCRLDistributionPointsURI=function(){var t=this.getExtInfo("cRLDistributionPoints");if(void 0===t)return t;for(var e=new Array,r=n(this.hex,t.vidx),i=0;i<r.length;i++)try{var s=ut(o(this.hex,r[i],[0,0,0],"86"));e.push(s)}catch(t){}return e},this.getExtAIAInfo=function(){var t=this.getExtInfo("authorityInfoAccess");if(void 0===t)return t;for(var e={ocsp:[],caissuer:[]},r=n(this.hex,t.vidx),i=0;i<r.length;i++){var s=o(this.hex,r[i],[0],"06"),a=o(this.hex,r[i],[1],"86");"2b06010505073001"===s&&e.ocsp.push(ut(a)),"2b06010505073002"===s&&e.caissuer.push(ut(a))}return e},this.getExtAuthorityInfoAccess=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("authorityInfoAccess");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var i={extname:"authorityInfoAccess",array:[]};e&&(i.critical=!0);for(var u=n(t,0),h=0;h<u.length;h++){var c=a(t,u[h],[0],"06"),l=ut(o(t,u[h],[1],"86"));if("2b06010505073001"==c)i.array.push({ocsp:l});else{if("2b06010505073002"!=c)throw new Error("unknown method: "+c);i.array.push({caissuer:l})}}return i},this.getExtCertificatePolicies=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("certificatePolicies");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var i={extname:"certificatePolicies",array:[]};e&&(i.critical=!0);for(var o=n(t,0),a=0;a<o.length;a++){var u=s(t,o[a]),h=this.getPolicyInformation(u);i.array.push(h)}return i},this.getPolicyInformation=function(t){var e={},r=o(t,0,[0],"06");e.policyoid=g(r);var i=l(t,0,[1],"30");if(-1!=i){e.array=[];for(var a=n(t,i),u=0;u<a.length;u++){var h=s(t,a[u]),c=this.getPolicyQualifierInfo(h);e.array.push(c)}}return e},this.getPolicyQualifierInfo=function(t){var e={},r=o(t,0,[0],"06");if("2b06010505070201"===r){var n=a(t,0,[1],"16");e.cps=ht(n)}else if("2b06010505070202"===r){var i=u(t,0,[1],"30");e.unotice=this.getUserNotice(i)}return e},this.getUserNotice=function(t){for(var e={},r=n(t,0),i=0;i<r.length;i++){var o=s(t,r[i]);"30"!=o.substr(0,2)&&(e.exptext=this.getDisplayText(o))}return e},this.getDisplayText=function(t){var e={};return e.type={"0c":"utf8",16:"ia5","1a":"vis","1e":"bmp"}[t.substr(0,2)],e.str=ht(i(t,0)),e},this.getExtCRLNumber=function(t,e){var r={extname:"cRLNumber"};if(e&&(r.critical=!0),"02"==t.substr(0,2))return r.num={hex:i(t,0)},r;throw new Error("hExtV parse error: "+t)},this.getExtCRLReason=function(t,e){var r={extname:"cRLReason"};if(e&&(r.critical=!0),"0a"==t.substr(0,2))return r.code=parseInt(i(t,0),16),r;throw new Error("hExtV parse error: "+t)},this.getExtOcspNonce=function(t,e){var r={extname:"ocspNonce"};e&&(r.critical=!0);var n=i(t,0);return r.hex=n,r},this.getExtOcspNoCheck=function(t,e){var r={extname:"ocspNoCheck"};return e&&(r.critical=!0),r},this.getExtAdobeTimeStamp=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("adobeTimeStamp");if(void 0===r)return;t=s(this.hex,r.vidx),e=r.critical}var i={extname:"adobeTimeStamp"};e&&(i.critical=!0);var o=n(t,0);if(o.length>1){var a=s(t,o[1]),u=this.getGeneralName(a);null!=u.uri&&(i.uri=u.uri)}if(o.length>2){var h=s(t,o[2]);"0101ff"==h&&(i.reqauth=!0),"010100"==h&&(i.reqauth=!1)}return i},this.getX500NameRule=function(t){for(var e=null,r=[],n=0;n<t.length;n++)for(var i=t[n],s=0;s<i.length;s++)r.push(i[s]);for(n=0;n<r.length;n++){var o=r[n],a=o.ds,u=o.value,h=o.type;if("prn"!=a&&"utf8"!=a&&"ia5"!=a)return"mixed";if("ia5"==a){if("CN"!=h)return"mixed";if(d.lang.String.isMail(u))continue;return"mixed"}if("C"==h){if("prn"==a)continue;return"mixed"}if(null==e)e=a;else if(e!==a)return"mixed"}return null==e?"prn":e},this.getX500Name=function(t){var e=this.getX500NameArray(t);return{array:e,str:this.dnarraytostr(e)}},this.getX500NameArray=function(t){for(var e=[],r=n(t,0),i=0;i<r.length;i++)e.push(this.getRDN(s(t,r[i])));return e},this.getRDN=function(t){for(var e=[],r=n(t,0),i=0;i<r.length;i++)e.push(this.getAttrTypeAndValue(s(t,r[i])));return e},this.getAttrTypeAndValue=function(t){var e={type:null,value:null,ds:null},r=n(t,0),i=o(t,r[0],[],"06"),s=o(t,r[1],[]),a=d.asn1.ASN1Util.oidHexToInt(i);return e.type=d.asn1.x509.OID.oid2atype(a),e.ds=this.HEX2STAG[t.substr(r[1],2)],"bmp"!=e.ds?e.value=ut(s):e.value=gt(s),e},this.readCertPEM=function(t){this.readCertHex(m(t))},this.readCertHex=function(t){this.hex=t,this.getVersion();try{c(this.hex,0,[0,7],"a3"),this.parseExt()}catch(t){}},this.getParam=function(){var t={};return t.version=this.getVersion(),t.serial={hex:this.getSerialNumberHex()},t.sigalg=this.getSignatureAlgorithmField(),t.issuer=this.getIssuer(),t.notbefore=this.getNotBefore(),t.notafter=this.getNotAfter(),t.subject=this.getSubject(),t.sbjpubkey=ft(this.getPublicKeyHex(),"PUBLIC KEY"),this.aExtInfo.length>0&&(t.ext=this.getExtParamArray()),t.sighex=this.getSignatureValueHex(),t},this.getExtParamArray=function(t){null==t&&(-1!=l(this.hex,0,[0,"[3]"])&&(t=h(this.hex,0,[0,"[3]",0],"30")));for(var e=[],r=n(t,0),i=0;i<r.length;i++){var o=s(t,r[i]),a=this.getExtParam(o);null!=a&&e.push(a)}return e},this.getExtParam=function(t){var e=n(t,0).length;if(2!=e&&3!=e)throw new Error("wrong number elements in Extension: "+e+" "+t);var r=y(o(t,0,[0],"06")),i=!1;3==e&&"0101ff"==u(t,0,[1])&&(i=!0);var s=u(t,0,[e-1,0]),a=void 0;if("2.5.29.14"==r?a=this.getExtSubjectKeyIdentifier(s,i):"2.5.29.15"==r?a=this.getExtKeyUsage(s,i):"2.5.29.17"==r?a=this.getExtSubjectAltName(s,i):"2.5.29.18"==r?a=this.getExtIssuerAltName(s,i):"2.5.29.19"==r?a=this.getExtBasicConstraints(s,i):"2.5.29.31"==r?a=this.getExtCRLDistributionPoints(s,i):"2.5.29.32"==r?a=this.getExtCertificatePolicies(s,i):"2.5.29.35"==r?a=this.getExtAuthorityKeyIdentifier(s,i):"2.5.29.37"==r?a=this.getExtExtKeyUsage(s,i):"1.3.6.1.5.5.7.1.1"==r?a=this.getExtAuthorityInfoAccess(s,i):"2.5.29.20"==r?a=this.getExtCRLNumber(s,i):"2.5.29.21"==r?a=this.getExtCRLReason(s,i):"1.3.6.1.5.5.7.48.1.2"==r?a=this.getExtOcspNonce(s,i):"1.3.6.1.5.5.7.48.1.5"==r?a=this.getExtOcspNoCheck(s,i):"1.2.840.113583.1.1.9.1"==r&&(a=this.getExtAdobeTimeStamp(s,i)),null!=a)return a;var h={extname:r,extn:s};return i&&(h.critical=!0),h},this.findExt=function(t,e){for(var r=0;r<t.length;r++)if(t[r].extname==e)return t[r];return null},this.updateExtCDPFullURI=function(t,e){var r=this.findExt(t,"cRLDistributionPoints");if(null!=r&&null!=r.array)for(var n=r.array,i=0;i<n.length;i++)if(null!=n[i].dpname&&null!=n[i].dpname.full)for(var s=n[i].dpname.full,o=0;o<s.length;o++){var a=s[i];null!=a.uri&&(a.uri=e)}},this.updateExtAIAOCSP=function(t,e){var r=this.findExt(t,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var n=r.array,i=0;i<n.length;i++)null!=n[i].ocsp&&(n[i].ocsp=e)},this.updateExtAIACAIssuer=function(t,e){var r=this.findExt(t,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var n=r.array,i=0;i<n.length;i++)null!=n[i].caissuer&&(n[i].caissuer=e)},this.dnarraytostr=function(t){return"/"+t.map((function(t){return function(t){return t.map((function(t){return function(t){return t.type+"="+t.value}(t).replace(/\+/,"\\+")})).join("+")}(t).replace(/\//,"\\/")})).join("/")},this.getInfo=function(){var t,e,r,n,i=function(t){for(var e="",r=t.array,n=0;n<r.length;n++){var i=r[n];if(e+=" policy oid: "+i.policyoid+"\n",void 0!==i.array)for(var s=0;s<i.array.length;s++){var o=i.array[s];void 0!==o.cps&&(e+=" cps: "+o.cps+"\n")}}return e},s=function(t){for(var e="",r=t.array,n=0;n<r.length;n++){var i=r[n];try{void 0!==i.dpname.full[0].uri&&(e+=" "+i.dpname.full[0].uri+"\n")}catch(t){}try{void 0!==i.dname.full[0].dn.hex&&(e+=" "+kt.hex2dn(i.dpname.full[0].dn.hex)+"\n")}catch(t){}}return e},o=function(t){for(var e="",r=t.array,n=0;n<r.length;n++){var i=r[n];void 0!==i.caissuer&&(e+=" caissuer: "+i.caissuer+"\n"),void 0!==i.ocsp&&(e+=" ocsp: "+i.ocsp+"\n")}return e};if(t="Basic Fields\n",t+=" serial number: "+this.getSerialNumberHex()+"\n",t+=" signature algorithm: "+this.getSignatureAlgorithmField()+"\n",t+=" issuer: "+this.getIssuerString()+"\n",t+=" notBefore: "+this.getNotBefore()+"\n",t+=" notAfter: "+this.getNotAfter()+"\n",t+=" subject: "+this.getSubjectString()+"\n",t+=" subject public key info: \n",t+=" key algorithm: "+(e=this.getPublicKey()).type+"\n","RSA"===e.type&&(t+=" n="+mt(e.n.toString(16)).substr(0,16)+"...\n",t+=" e="+mt(e.e.toString(16))+"\n"),null!=(r=this.aExtInfo)){t+="X509v3 Extensions:\n";for(var a=0;a<r.length;a++){var u=r[a],h=d.asn1.x509.OID.oid2name(u.oid);""===h&&(h=u.oid);var c="";if(!0===u.critical&&(c="CRITICAL"),t+=" "+h+" "+c+":\n","basicConstraints"===h){var l=this.getExtBasicConstraints();void 0===l.cA?t+=" {}\n":(t+=" cA=true",void 0!==l.pathLen&&(t+=", pathLen="+l.pathLen),t+="\n")}else if("keyUsage"===h)t+=" "+this.getExtKeyUsageString()+"\n";else if("subjectKeyIdentifier"===h)t+=" "+this.getExtSubjectKeyIdentifier().kid.hex+"\n";else if("authorityKeyIdentifier"===h){var f=this.getExtAuthorityKeyIdentifier();void 0!==f.kid&&(t+=" kid="+f.kid.hex+"\n")}else{if("extKeyUsage"===h)t+=" "+this.getExtExtKeyUsage().array.join(", ")+"\n";else if("subjectAltName"===h)t+=" "+(n=this.getExtSubjectAltName(),JSON.stringify(n.array).replace(/[\[\]\{\}\"]/g,""))+"\n";else if("cRLDistributionPoints"===h)t+=s(this.getExtCRLDistributionPoints());else if("authorityInfoAccess"===h)t+=o(this.getExtAuthorityInfoAccess());else"certificatePolicies"===h&&(t+=i(this.getExtCertificatePolicies()))}}}return t+="signature algorithm: "+this.getSignatureAlgorithmName()+"\n",t+="signature: "+this.getSignatureValueHex().substr(0,16)+"...\n"},"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?this.readCertPEM(t):d.lang.String.isHex(t)&&this.readCertHex(t))}function jt(t){return g.SHA256(t).toString()}Tt.getLblen=function(t,e){if("8"!=t.substr(e+2,1))return 1;var r=parseInt(t.substr(e+3,1));return 0==r?-1:0<r&&r<10?r+1:-2},Tt.getL=function(t,e){var r=Tt.getLblen(t,e);return r<1?"":t.substr(e+2,2*r)},Tt.getVblen=function(t,e){var r;return""==(r=Tt.getL(t,e))?-1:("8"===r.substr(0,1)?new y(r.substr(2),16):new y(r,16)).intValue()},Tt.getVidx=function(t,e){var r=Tt.getLblen(t,e);return r<0?r:e+2*(r+1)},Tt.getV=function(t,e){var r=Tt.getVidx(t,e),n=Tt.getVblen(t,e);return t.substr(r,2*n)},Tt.getTLV=function(t,e){return t.substr(e,2)+Tt.getL(t,e)+Tt.getV(t,e)},Tt.getTLVblen=function(t,e){return 2+2*Tt.getLblen(t,e)+2*Tt.getVblen(t,e)},Tt.getNextSiblingIdx=function(t,e){return Tt.getVidx(t,e)+2*Tt.getVblen(t,e)},Tt.getChildIdx=function(t,e){var r,n,i,s=Tt,o=[];r=s.getVidx(t,e),n=2*s.getVblen(t,e),"03"==t.substr(e,2)&&(r+=2,n-=2),i=0;for(var a=r;i<=n;){var u=s.getTLVblen(t,a);if((i+=u)<=n&&o.push(a),a+=u,i>=n)break}return o},Tt.getNthChildIdx=function(t,e,r){return Tt.getChildIdx(t,e)[r]},Tt.getIdxbyList=function(t,e,r,n){var i,s,o=Tt;return 0==r.length?void 0!==n&&t.substr(e,2)!==n?-1:e:(i=r.shift())>=(s=o.getChildIdx(t,e)).length?-1:o.getIdxbyList(t,s[i],r,n)},Tt.getIdxbyListEx=function(t,e,r,n){var i,s,o=Tt;if(0==r.length)return void 0!==n&&t.substr(e,2)!==n?-1:e;i=r.shift(),s=o.getChildIdx(t,e);for(var a=0,u=0;u<s.length;u++){var h=t.substr(s[u],2);if("number"==typeof i&&!o.isContextTag(h)&&a==i||"string"==typeof i&&o.isContextTag(h,i))return o.getIdxbyListEx(t,s[u],r,n);o.isContextTag(h)||a++}return-1},Tt.getTLVbyList=function(t,e,r,n){var i=Tt,s=i.getIdxbyList(t,e,r,n);return-1==s||s>=t.length?null:i.getTLV(t,s)},Tt.getTLVbyListEx=function(t,e,r,n){var i=Tt,s=i.getIdxbyListEx(t,e,r,n);return-1==s?null:i.getTLV(t,s)},Tt.getVbyList=function(t,e,r,n,i){var s,o,a=Tt;return-1==(s=a.getIdxbyList(t,e,r,n))||s>=t.length?null:(o=a.getV(t,s),!0===i&&(o=o.substr(2)),o)},Tt.getVbyListEx=function(t,e,r,n,i){var s,o,a=Tt;return-1==(s=a.getIdxbyListEx(t,e,r,n))?null:(o=a.getV(t,s),"03"==t.substr(s,2)&&!1!==i&&(o=o.substr(2)),o)},Tt.getInt=function(t,e,r){null==r&&(r=-1);try{var n=t.substr(e,2);if("02"!=n&&"03"!=n)return r;var i=Tt.getV(t,e);return"02"==n?parseInt(i,16):function(t){try{var e=t.substr(0,2);if("00"==e)return parseInt(t.substr(2),16);var r=parseInt(e,16),n=t.substr(2),i=parseInt(n,16).toString(2);return"0"==i&&(i="00000000"),i=i.slice(0,0-r),parseInt(i,2)}catch(t){return-1}}(i)}catch(t){return r}},Tt.getOID=function(t,e,r){null==r&&(r=null);try{return"06"!=t.substr(e,2)?r:function(t){if(!yt(t))return null;try{var e=[],r=t.substr(0,2),n=parseInt(r,16);e[0]=new String(Math.floor(n/40)),e[1]=new String(n%40);for(var i=t.substr(2),s=[],o=0;o<i.length/2;o++)s.push(parseInt(i.substr(2*o,2),16));var a=[],u="";for(o=0;o<s.length;o++)128&s[o]?u+=vt((127&s[o]).toString(2),7):(u+=vt((127&s[o]).toString(2),7),a.push(new String(parseInt(u,2))),u="");var h=e.join(".");return a.length>0&&(h=h+"."+a.join(".")),h}catch(t){return null}}(Tt.getV(t,e))}catch(t){return r}},Tt.getOIDName=function(t,e,r){null==r&&(r=null);try{var n=Tt.getOID(t,e,r);if(n==r)return r;var i=d.asn1.x509.OID.oid2name(n);return""==i?n:i}catch(t){return r}},Tt.getString=function(t,e,r){null==r&&(r=null);try{return ht(Tt.getV(t,e))}catch(t){return r}},Tt.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},r=[],n=t.substr(0,2),i=parseInt(n,16);r[0]=new String(Math.floor(i/40)),r[1]=new String(i%40);for(var s=t.substr(2),o=[],a=0;a<s.length/2;a++)o.push(parseInt(s.substr(2*a,2),16));var u=[],h="";for(a=0;a<o.length;a++)128&o[a]?h+=e((127&o[a]).toString(2),7):(h+=e((127&o[a]).toString(2),7),u.push(new String(parseInt(h,2))),h="");var c=r.join(".");return u.length>0&&(c=c+"."+u.join(".")),c},Tt.dump=function(t,e,r,n){var i=Tt,s=i.getV,o=i.dump,a=i.getChildIdx,u=t;t instanceof d.asn1.ASN1Object&&(u=t.getEncodedHex());var h=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===r&&(r=0),void 0===n&&(n="");var c,l=e.ommit_long_octet;if("01"==(c=u.substr(r,2)))return"00"==(f=s(u,r))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==c)return n+"INTEGER "+h(f=s(u,r),l)+"\n";if("03"==c){var f=s(u,r);if(i.isASN1HEX(f.substr(2))){var p=n+"BITSTRING, encapsulates\n";return p+=o(f.substr(2),e,0,n+" ")}return n+"BITSTRING "+h(f,l)+"\n"}if("04"==c){f=s(u,r);if(i.isASN1HEX(f)){p=n+"OCTETSTRING, encapsulates\n";return p+=o(f,e,0,n+" ")}return n+"OCTETSTRING "+h(f,l)+"\n"}if("05"==c)return n+"NULL\n";if("06"==c){var g=s(u,r),y=d.asn1.ASN1Util.oidHexToInt(g),m=d.asn1.x509.OID.oid2name(y),v=y.replace(/\./g," ");return""!=m?n+"ObjectIdentifier "+m+" ("+v+")\n":n+"ObjectIdentifier ("+v+")\n"}if("0a"==c)return n+"ENUMERATED "+parseInt(s(u,r))+"\n";if("0c"==c)return n+"UTF8String '"+ut(s(u,r))+"'\n";if("13"==c)return n+"PrintableString '"+ut(s(u,r))+"'\n";if("14"==c)return n+"TeletexString '"+ut(s(u,r))+"'\n";if("16"==c)return n+"IA5String '"+ut(s(u,r))+"'\n";if("17"==c)return n+"UTCTime "+ut(s(u,r))+"\n";if("18"==c)return n+"GeneralizedTime "+ut(s(u,r))+"\n";if("1a"==c)return n+"VisualString '"+ut(s(u,r))+"'\n";if("1e"==c)return n+"BMPString '"+gt(s(u,r))+"'\n";if("30"==c){if("3000"==u.substr(r,4))return n+"SEQUENCE {}\n";p=n+"SEQUENCE\n";var x=e;if((2==(S=a(u,r)).length||3==S.length)&&"06"==u.substr(S[0],2)&&"04"==u.substr(S[S.length-1],2)){m=i.oidname(s(u,S[0]));var b=JSON.parse(JSON.stringify(e));b.x509ExtName=m,x=b}for(var w=0;w<S.length;w++)p+=o(u,x,S[w],n+" ");return p}if("31"==c){p=n+"SET\n";var S=a(u,r);for(w=0;w<S.length;w++)p+=o(u,e,S[w],n+" ");return p}if(0!=(128&(c=parseInt(c,16)))){var E=31&c;if(0!=(32&c)){for(p=n+"["+E+"]\n",S=a(u,r),w=0;w<S.length;w++)p+=o(u,e,S[w],n+" ");return p}f=s(u,r);if(Tt.isASN1HEX(f)){var p=n+"["+E+"]\n";return p+=o(f,e,0,n+" ")}return("68747470"==f.substr(0,8)||"subjectAltName"===e.x509ExtName&&2==E)&&(f=ut(f)),p=n+"["+E+"] "+f+"\n"}return n+"UNKNOWN("+c+") "+s(u,r)+"\n"},Tt.isContextTag=function(t,e){var r,n;t=t.toLowerCase();try{r=parseInt(t,16)}catch(t){return-1}if(void 0===e)return 128==(192&r);try{return null!=e.match(/^\[[0-9]+\]$/)&&(!((n=parseInt(e.substr(1,e.length-1),10))>31)&&(128==(192&r)&&(31&r)==n))}catch(t){return!1}},Tt.isASN1HEX=function(t){var e=Tt;if(t.length%2==1)return!1;var r=e.getVblen(t,0),n=t.substr(0,2),i=e.getL(t,0);return t.length-n.length-i.length==2*r},Tt.checkStrictDER=function(t,e,r,n,i){var s=Tt;if(void 0===r){if("string"!=typeof t)throw new Error("not hex string");if(t=t.toLowerCase(),!d.lang.String.isHex(t))throw new Error("not hex string");r=t.length,i=(n=t.length/2)<128?1:Math.ceil(n.toString(16))+1}if(s.getL(t,e).length>2*i)throw new Error("L of TLV too long: idx="+e);var o=s.getVblen(t,e);if(o>n)throw new Error("value of L too long than hex: idx="+e);var a=s.getTLV(t,e),u=a.length-2-s.getL(t,e).length;if(u!==2*o)throw new Error("V string length and L's value not the same:"+u+"/"+2*o);if(0===e&&t.length!=a.length)throw new Error("total length and TLV length unmatch:"+t.length+"!="+a.length);var h=t.substr(e,2);if("02"===h){var c=s.getVidx(t,e);if("00"==t.substr(c,2)&&t.charCodeAt(c+2)<56)throw new Error("not least zeros for DER INTEGER")}if(32&parseInt(h,16)){for(var l=s.getVblen(t,e),f=0,p=s.getChildIdx(t,e),g=0;g<p.length;g++){f+=s.getTLV(t,p[g]).length,s.checkStrictDER(t,p[g],r,n,i)}if(2*l!=f)throw new Error("sum of children's TLV length and L unmatch: "+2*l+"!="+f)}},Tt.oidname=function(t){var e=d.asn1;d.lang.String.isHex(t)&&(t=e.ASN1Util.oidHexToInt(t));var r=e.x509.OID.oid2name(t);return""===r&&(r=t),r},void 0!==d.asn1&&d.asn1||(d.asn1={}),void 0!==d.asn1.x509&&d.asn1.x509||(d.asn1.x509={}),d.asn1.x509.Certificate=function(t){d.asn1.x509.Certificate.superclass.constructor.call(this);var e=d.asn1,r=e.DERBitString,n=e.DERSequence,i=e.x509,s=i.TBSCertificate,o=i.AlgorithmIdentifier;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=this.params,e=t.sigalg;null!=t.sigalg.name&&(e=t.sigalg.name);var r=t.tbsobj.getEncodedHex(),n=new d.crypto.Signature({alg:e});n.init(t.cakey),n.updateHex(r),t.sighex=n.sign()},this.getPEM=function(){return ft(this.getEncodedHex(),"CERTIFICATE")},this.getEncodedHex=function(){var t=this.params;if(null!=t.tbsobj&&null!=t.tbsobj||(t.tbsobj=new s(t)),null==t.sighex&&null!=t.cakey&&this.sign(),null==t.sighex)throw new Error("sighex or cakey parameter not defined");var e=[];return e.push(t.tbsobj),e.push(new o({name:t.sigalg})),e.push(new r({hex:"00"+t.sighex})),new n({array:e}).getEncodedHex()},null!=t&&(this.params=t)},xt(d.asn1.x509.Certificate,d.asn1.ASN1Object),d.asn1.x509.TBSCertificate=function(t){d.asn1.x509.TBSCertificate.superclass.constructor.call(this);var e=d.asn1,r=e.x509,n=e.DERTaggedObject,i=e.DERInteger,s=e.DERSequence,o=r.AlgorithmIdentifier,a=r.Time,u=r.X500Name,h=r.Extensions,c=r.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(t){this.params=t},this.getEncodedHex=function(){var t=[],e=this.params;if(null!=e.version||1!=e.version){var r=2;null!=e.version&&(r=e.version-1);var l=new n({obj:new i({int:r})});t.push(l)}return t.push(new i(e.serial)),t.push(new o({name:e.sigalg})),t.push(new u(e.issuer)),t.push(new s({array:[new a(e.notbefore),new a(e.notafter)]})),t.push(new u(e.subject)),t.push(new c(Ot.getKey(e.sbjpubkey))),void 0!==e.ext&&e.ext.length>0&&t.push(new n({tag:"a3",obj:new h(e.ext)})),new d.asn1.DERSequence({array:t}).getEncodedHex()},void 0!==t&&this.setByParam(t)},xt(d.asn1.x509.TBSCertificate,d.asn1.ASN1Object),d.asn1.x509.Extensions=function(t){d.asn1.x509.Extensions.superclass.constructor.call(this);var e=d.asn1,r=e.DERSequence,n=e.x509;this.aParam=[],this.setByParam=function(t){this.aParam=t},this.getEncodedHex=function(){for(var t=[],e=0;e<this.aParam.length;e++){var i=this.aParam[e],s=i.extname,o=null;if(null!=i.extn)o=new n.PrivateExtension(i);else if("subjectKeyIdentifier"==s)o=new n.SubjectKeyIdentifier(i);else if("keyUsage"==s)o=new n.KeyUsage(i);else if("subjectAltName"==s)o=new n.SubjectAltName(i);else if("issuerAltName"==s)o=new n.IssuerAltName(i);else if("basicConstraints"==s)o=new n.BasicConstraints(i);else if("cRLDistributionPoints"==s)o=new n.CRLDistributionPoints(i);else if("certificatePolicies"==s)o=new n.CertificatePolicies(i);else if("authorityKeyIdentifier"==s)o=new n.AuthorityKeyIdentifier(i);else if("extKeyUsage"==s)o=new n.ExtKeyUsage(i);else if("authorityInfoAccess"==s)o=new n.AuthorityInfoAccess(i);else if("cRLNumber"==s)o=new n.CRLNumber(i);else if("cRLReason"==s)o=new n.CRLReason(i);else if("ocspNonce"==s)o=new n.OCSPNonce(i);else if("ocspNoCheck"==s)o=new n.OCSPNoCheck(i);else if("adobeTimeStamp"==s)o=new n.AdobeTimeStamp(i);else{if("subjectDirectoryAttributes"!=s)throw new Error("extension not supported:"+JSON.stringify(i));o=new n.SubjectDirectoryAttributes(i)}null!=o&&t.push(o)}return new r({array:t}).getEncodedHex()},null!=t&&this.setByParam(t)},xt(d.asn1.x509.Extensions,d.asn1.ASN1Object),d.asn1.x509.Extension=function(t){d.asn1.x509.Extension.superclass.constructor.call(this);var e=d.asn1,r=e.DERObjectIdentifier,n=e.DEROctetString;e.DERBitString;var i=e.DERBoolean,s=e.DERSequence;this.getEncodedHex=function(){var t=new r({oid:this.oid}),e=new n({hex:this.getExtnValueHex()}),o=new Array;return o.push(t),this.critical&&o.push(new i),o.push(e),new s({array:o}).getEncodedHex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},xt(d.asn1.x509.Extension,d.asn1.ASN1Object),d.asn1.x509.KeyUsage=function(t){d.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=kt.KEYUSAGE_NAME;if(this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.15",void 0!==t&&(void 0!==t.bin&&(this.asn1ExtnValue=new d.asn1.DERBitString(t)),void 0!==t.names&&void 0!==t.names.length)){for(var r=t.names,n="000000000",i=0;i<r.length;i++)for(var s=0;s<e.length;s++)r[i]===e[s]&&(n=n.substring(0,s)+"1"+n.substring(s+1,n.length));this.asn1ExtnValue=new d.asn1.DERBitString({bin:n})}},xt(d.asn1.x509.KeyUsage,d.asn1.x509.Extension),d.asn1.x509.BasicConstraints=function(t){d.asn1.x509.BasicConstraints.superclass.constructor.call(this,t);var e=d.asn1,r=e.DERBoolean,n=e.DERInteger,i=e.DERSequence;this.getExtnValueHex=function(){var t=new Array;this.cA&&t.push(new r),this.pathLen>-1&&t.push(new n({int:this.pathLen}));var e=new i({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen&&(this.pathLen=t.pathLen))},xt(d.asn1.x509.BasicConstraints,d.asn1.x509.Extension),d.asn1.x509.CRLDistributionPoints=function(t){d.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=d.asn1,r=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(t){for(var n=[],i=0;i<t.length;i++)if(t[i]instanceof d.asn1.ASN1Object)n.push(t[i]);else{var s=new r.DistributionPoint(t[i]);n.push(s)}this.asn1ExtnValue=new e.DERSequence({array:n})},this.setByOneURI=function(t){var e=new r.DistributionPoint({fulluri:t});this.setByDPArray([e])},this.oid="2.5.29.31",void 0!==t&&(void 0!==t.array?this.setByDPArray(t.array):void 0!==t.uri&&this.setByOneURI(t.uri))},xt(d.asn1.x509.CRLDistributionPoints,d.asn1.x509.Extension),d.asn1.x509.DistributionPoint=function(t){d.asn1.x509.DistributionPoint.superclass.constructor.call(this);var e=d.asn1,r=e.x509.DistributionPointName;this.getEncodedHex=function(){var t=new e.DERSequence;if(null!=this.asn1DP){var r=new e.DERTaggedObject({explicit:!0,tag:"a0",obj:this.asn1DP});t.appendASN1Object(r)}return this.hTLV=t.getEncodedHex(),this.hTLV},void 0!==t&&(void 0!==t.dpobj?this.asn1DP=t.dpobj:void 0!==t.dpname?this.asn1DP=new r(t.dpname):void 0!==t.fulluri&&(this.asn1DP=new r({full:[{uri:t.fulluri}]})))},xt(d.asn1.x509.DistributionPoint,d.asn1.ASN1Object),d.asn1.x509.DistributionPointName=function(t){d.asn1.x509.DistributionPointName.superclass.constructor.call(this);var e=d.asn1,r=e.DERTaggedObject;if(this.getEncodedHex=function(){if("full"!=this.type)throw new Error("currently type shall be 'full': "+this.type);return this.asn1Obj=new r({explicit:!1,tag:this.tag,obj:this.asn1V}),this.hTLV=this.asn1Obj.getEncodedHex(),this.hTLV},void 0!==t)if(e.x509.GeneralNames.prototype.isPrototypeOf(t))this.type="full",this.tag="a0",this.asn1V=t;else{if(void 0===t.full)throw new Error("This class supports GeneralNames only as argument");this.type="full",this.tag="a0",this.asn1V=new e.x509.GeneralNames(t.full)}},xt(d.asn1.x509.DistributionPointName,d.asn1.ASN1Object),d.asn1.x509.CertificatePolicies=function(t){d.asn1.x509.CertificatePolicies.superclass.constructor.call(this,t);var e=d.asn1,r=e.x509,n=e.DERSequence,i=r.PolicyInformation;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++)t.push(new i(this.params.array[e]));var r=new n({array:t});return this.asn1ExtnValue=r,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.32",void 0!==t&&(this.params=t)},xt(d.asn1.x509.CertificatePolicies,d.asn1.x509.Extension),d.asn1.x509.PolicyInformation=function(t){d.asn1.x509.PolicyInformation.superclass.constructor.call(this,t);var e=d.asn1,r=e.DERSequence,n=e.DERObjectIdentifier,i=e.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 t=[new n(this.params.policyoid)];if(void 0!==this.params.array){for(var e=[],s=0;s<this.params.array.length;s++)e.push(new i(this.params.array[s]));e.length>0&&t.push(new r({array:e}))}return new r({array:t}).getEncodedHex()},void 0!==t&&(this.params=t)},xt(d.asn1.x509.PolicyInformation,d.asn1.ASN1Object),d.asn1.x509.PolicyQualifierInfo=function(t){d.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,t);var e=d.asn1,r=e.DERSequence,n=e.DERIA5String,i=e.DERObjectIdentifier,s=e.x509.UserNotice;this.params=null,this.getEncodedHex=function(){return void 0!==this.params.cps?new r({array:[new i({oid:"1.3.6.1.5.5.7.2.1"}),new n({str:this.params.cps})]}).getEncodedHex():null!=this.params.unotice?new r({array:[new i({oid:"1.3.6.1.5.5.7.2.2"}),new s(this.params.unotice)]}).getEncodedHex():void 0},void 0!==t&&(this.params=t)},xt(d.asn1.x509.PolicyQualifierInfo,d.asn1.ASN1Object),d.asn1.x509.UserNotice=function(t){d.asn1.x509.UserNotice.superclass.constructor.call(this,t);var e=d.asn1.DERSequence;d.asn1.DERInteger;var r=d.asn1.x509.DisplayText,n=d.asn1.x509.NoticeReference;this.params=null,this.getEncodedHex=function(){var t=[];return void 0!==this.params.noticeref&&t.push(new n(this.params.noticeref)),void 0!==this.params.exptext&&t.push(new r(this.params.exptext)),new e({array:t}).getEncodedHex()},void 0!==t&&(this.params=t)},xt(d.asn1.x509.UserNotice,d.asn1.ASN1Object),d.asn1.x509.NoticeReference=function(t){d.asn1.x509.NoticeReference.superclass.constructor.call(this,t);var e=d.asn1.DERSequence,r=d.asn1.DERInteger,n=d.asn1.x509.DisplayText;this.params=null,this.getEncodedHex=function(){var t=[];if(void 0!==this.params.org&&t.push(new n(this.params.org)),void 0!==this.params.noticenum){for(var i=[],s=this.params.noticenum,o=0;o<s.length;o++)i.push(new r(s[o]));t.push(new e({array:i}))}if(0==t.length)throw new Error("parameter is empty");return new e({array:t}).getEncodedHex()},void 0!==t&&(this.params=t)},xt(d.asn1.x509.NoticeReference,d.asn1.ASN1Object),d.asn1.x509.DisplayText=function(t){d.asn1.x509.DisplayText.superclass.constructor.call(this,t),this.hT="0c",void 0!==t&&("ia5"===t.type?this.hT="16":"vis"===t.type?this.hT="1a":"bmp"===t.type&&(this.hT="1e"))},xt(d.asn1.x509.DisplayText,d.asn1.DERAbstractString),d.asn1.x509.ExtKeyUsage=function(t){d.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=d.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new e.DERSequence;for(var r=0;r<t.length;r++){var n=new e.DERObjectIdentifier(t[r]);this.asn1ExtnValue.appendASN1Object(n)}},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.37",void 0!==t&&void 0!==t.array&&this.setPurposeArray(t.array)},xt(d.asn1.x509.ExtKeyUsage,d.asn1.x509.Extension),d.asn1.x509.AuthorityKeyIdentifier=function(t){d.asn1.x509.AuthorityKeyIdentifier.superclass.constructor.call(this,t);var e=d,r=e.asn1,n=r.DERTaggedObject,i=r.x509.GeneralNames;e.crypto.Util.isKey,this.asn1KID=null,this.asn1CertIssuer=null,this.asn1CertSN=null,this.getExtnValueHex=function(){var t=new Array;this.asn1KID&&t.push(new n({explicit:!1,tag:"80",obj:this.asn1KID})),this.asn1CertIssuer&&t.push(new n({explicit:!1,tag:"a1",obj:new i([{dn:this.asn1CertIssuer}])})),this.asn1CertSN&&t.push(new n({explicit:!1,tag:"82",obj:this.asn1CertSN}));var e=new r.DERSequence({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.setKIDByParam=function(t){if(void 0!==t.str||void 0!==t.hex)this.asn1KID=new d.asn1.DEROctetString(t);else if("object"==typeof t&&d.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN ")){var e=t;"string"==typeof t&&(e=Ot.getKey(t));var r=Ot.getKeyID(e);this.asn1KID=new d.asn1.DEROctetString({hex:r})}},this.setCertIssuerByParam=function(t){void 0!==t.str||void 0!==t.ldapstr||void 0!==t.hex||void 0!==t.certsubject||void 0!==t.certissuer?this.asn1CertIssuer=new d.asn1.x509.X500Name(t):"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&-1!=t.indexOf("CERTIFICATE")&&(this.asn1CertIssuer=new d.asn1.x509.X500Name({certissuer:t}))},this.setCertSNByParam=function(t){if(void 0!==t.str||void 0!==t.bigint||void 0!==t.hex)this.asn1CertSN=new d.asn1.DERInteger(t);else if("string"==typeof t&&-1!=t.indexOf("BEGIN ")&&t.indexOf("CERTIFICATE")){var e=new kt;e.readCertPEM(t);var r=e.getSerialNumberHex();this.asn1CertSN=new d.asn1.DERInteger({hex:r})}},this.oid="2.5.29.35",void 0!==t&&(void 0!==t.kid&&this.setKIDByParam(t.kid),void 0!==t.issuer&&this.setCertIssuerByParam(t.issuer),void 0!==t.sn&&this.setCertSNByParam(t.sn),void 0!==t.issuersn&&"string"==typeof t.issuersn&&-1!=t.issuersn.indexOf("BEGIN ")&&t.issuersn.indexOf("CERTIFICATE")&&(this.setCertSNByParam(t.issuersn),this.setCertIssuerByParam(t.issuersn)))},xt(d.asn1.x509.AuthorityKeyIdentifier,d.asn1.x509.Extension),d.asn1.x509.SubjectKeyIdentifier=function(t){d.asn1.x509.SubjectKeyIdentifier.superclass.constructor.call(this,t);var e=d.asn1.DEROctetString;this.asn1KID=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=this.asn1KID,this.asn1ExtnValue.getEncodedHex()},this.setKIDByParam=function(t){if(void 0!==t.str||void 0!==t.hex)this.asn1KID=new e(t);else if("object"==typeof t&&d.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN")){var r=t;"string"==typeof t&&(r=Ot.getKey(t));var n=Ot.getKeyID(r);this.asn1KID=new d.asn1.DEROctetString({hex:n})}},this.oid="2.5.29.14",void 0!==t&&void 0!==t.kid&&this.setKIDByParam(t.kid)},xt(d.asn1.x509.SubjectKeyIdentifier,d.asn1.x509.Extension),d.asn1.x509.AuthorityInfoAccess=function(t){d.asn1.x509.AuthorityInfoAccess.superclass.constructor.call(this,t),this.setAccessDescriptionArray=function(t){for(var e=new Array,r=d.asn1,n=r.DERSequence,i=r.DERObjectIdentifier,s=r.x509.GeneralName,o=0;o<t.length;o++){var a,u=t[o];if(void 0!==u.ocsp)a=new n({array:[new i({oid:"1.3.6.1.5.5.7.48.1"}),new s({uri:u.ocsp})]});else{if(void 0===u.caissuer)throw new Error("unknown AccessMethod parameter: "+JSON.stringify(u));a=new n({array:[new i({oid:"1.3.6.1.5.5.7.48.2"}),new s({uri:u.caissuer})]})}e.push(a)}this.asn1ExtnValue=new n({array:e})},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.1.1",void 0!==t&&void 0!==t.array&&this.setAccessDescriptionArray(t.array)},xt(d.asn1.x509.AuthorityInfoAccess,d.asn1.x509.Extension),d.asn1.x509.SubjectAltName=function(t){d.asn1.x509.SubjectAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new d.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.17",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},xt(d.asn1.x509.SubjectAltName,d.asn1.x509.Extension),d.asn1.x509.IssuerAltName=function(t){d.asn1.x509.IssuerAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new d.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.18",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},xt(d.asn1.x509.IssuerAltName,d.asn1.x509.Extension),d.asn1.x509.SubjectDirectoryAttributes=function(t){d.asn1.x509.SubjectDirectoryAttributes.superclass.constructor.call(this,t);var e=d.asn1,r=e.DERSequence,n=e.ASN1Util.newObject,i=e.x509.OID.name2oid;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++){var s=this.params.array[e],o={seq:[{oid:"1.2.3.4"},{set:[{utf8str:"DE"}]}]};if("dateOfBirth"==s.attr)o.seq[0].oid=i(s.attr),o.seq[1].set[0]={gentime:s.str};else if("placeOfBirth"==s.attr)o.seq[0].oid=i(s.attr),o.seq[1].set[0]={utf8str:s.str};else if("gender"==s.attr)o.seq[0].oid=i(s.attr),o.seq[1].set[0]={prnstr:s.str};else if("countryOfCitizenship"==s.attr)o.seq[0].oid=i(s.attr),o.seq[1].set[0]={prnstr:s.str};else{if("countryOfResidence"!=s.attr)throw new Error("unsupported attribute: "+s.attr);o.seq[0].oid=i(s.attr),o.seq[1].set[0]={prnstr:s.str}}t.push(new n(o))}var a=new r({array:t});return this.asn1ExtnValue=a,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.9",void 0!==t&&(this.params=t)},xt(d.asn1.x509.SubjectDirectoryAttributes,d.asn1.x509.Extension),d.asn1.x509.PrivateExtension=function(t){d.asn1.x509.PrivateExtension.superclass.constructor.call(this,t);var e=d,r=e.lang.String.isHex,n=e.asn1,i=n.x509.OID.name2oid,s=n.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.oid=i(t.extname),this.params=t},this.getExtnValueHex=function(){if(null==this.params.extname||null==this.params.extn)throw new Error("extname or extnhex not specified");var t=this.params.extn;if("string"==typeof t&&r(t))return t;if("object"==typeof t)try{return s(t).getEncodedHex()}catch(t){}throw new Error("unsupported extn value")},null!=t&&this.setByParam(t)},xt(d.asn1.x509.PrivateExtension,d.asn1.x509.Extension),d.asn1.x509.CRL=function(t){d.asn1.x509.CRL.superclass.constructor.call(this);var e=d.asn1,r=e.DERSequence,n=e.DERBitString,i=e.x509,s=i.AlgorithmIdentifier,o=i.TBSCertList;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=new o(this.params).getEncodedHex(),e=new d.crypto.Signature({alg:this.params.sigalg});e.init(this.params.cakey),e.updateHex(t);var r=e.sign();this.params.sighex=r},this.getPEM=function(){return ft(this.getEncodedHex(),"X509 CRL")},this.getEncodedHex=function(){var t=this.params;if(null==t.tbsobj&&(t.tbsobj=new o(t)),null==t.sighex&&null!=t.cakey&&this.sign(),null==t.sighex)throw new Error("sighex or cakey parameter not defined");var e=[];return e.push(t.tbsobj),e.push(new s({name:t.sigalg})),e.push(new n({hex:"00"+t.sighex})),new r({array:e}).getEncodedHex()},null!=t&&(this.params=t)},xt(d.asn1.x509.CRL,d.asn1.ASN1Object),d.asn1.x509.TBSCertList=function(t){d.asn1.x509.TBSCertList.superclass.constructor.call(this);var e=d.asn1,r=e.DERInteger,n=e.DERSequence,i=e.DERTaggedObject;e.DERObjectIdentifier;var s=e.x509,o=s.AlgorithmIdentifier,a=s.Time,u=s.Extensions,h=s.X500Name;this.params=null,this.setByParam=function(t){this.params=t},this.getRevCertSequence=function(){for(var t=[],e=this.params.revcert,i=0;i<e.length;i++){var s=[new r(e[i].sn),new a(e[i].date)];null!=e[i].ext&&s.push(new u(e[i].ext)),t.push(new n({array:s}))}return new n({array:t})},this.getEncodedHex=function(){var t=[],e=this.params;if(null!=e.version){var s=e.version-1,c=new r({int:s});t.push(c)}if(t.push(new o({name:e.sigalg})),t.push(new h(e.issuer)),t.push(new a(e.thisupdate)),null!=e.nextupdate&&t.push(new a(e.nextupdate)),null!=e.revcert&&t.push(this.getRevCertSequence()),null!=e.ext){var l=new u(e.ext);t.push(new i({tag:"a0",explicit:!0,obj:l}))}return new n({array:t}).getEncodedHex()},void 0!==t&&this.setByParam(t)},xt(d.asn1.x509.TBSCertList,d.asn1.ASN1Object),d.asn1.x509.CRLEntry=function(t){d.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=d.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn&&this.setCertSerial(t.sn))},xt(d.asn1.x509.CRLEntry,d.asn1.ASN1Object),d.asn1.x509.CRLNumber=function(t){d.asn1.x509.CRLNumber.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new d.asn1.DERInteger(this.params.num),this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.20",null!=t&&(this.params=t)},xt(d.asn1.x509.CRLNumber,d.asn1.x509.Extension),d.asn1.x509.CRLReason=function(t){d.asn1.x509.CRLReason.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new d.asn1.DEREnumerated(this.params.code),this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.21",null!=t&&(this.params=t)},xt(d.asn1.x509.CRLReason,d.asn1.x509.Extension),d.asn1.x509.OCSPNonce=function(t){d.asn1.x509.OCSPNonce.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new d.asn1.DEROctetString(this.params),this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.48.1.2",null!=t&&(this.params=t)},xt(d.asn1.x509.OCSPNonce,d.asn1.x509.Extension),d.asn1.x509.OCSPNoCheck=function(t){d.asn1.x509.OCSPNoCheck.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new d.asn1.DERNull,this.asn1ExtnValue.getEncodedHex()},this.oid="1.3.6.1.5.5.7.48.1.5",null!=t&&(this.params=t)},xt(d.asn1.x509.OCSPNoCheck,d.asn1.x509.Extension),d.asn1.x509.AdobeTimeStamp=function(t){d.asn1.x509.AdobeTimeStamp.superclass.constructor.call(this,t);var e=d.asn1,r=e.DERInteger,n=e.DERBoolean,i=e.DERSequence,s=e.x509.GeneralName;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[new r(1)];return e.push(new s({uri:t.uri})),null!=t.reqauth&&e.push(new n(t.reqauth)),this.asn1ExtnValue=new i({array:e}),this.asn1ExtnValue.getEncodedHex()},this.oid="1.2.840.113583.1.1.9.1",void 0!==t&&this.setByParam(t)},xt(d.asn1.x509.AdobeTimeStamp,d.asn1.x509.Extension),d.asn1.x509.X500Name=function(t){d.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=d.asn1,r=e.x509,n=r.RDN;this.setByString=function(t,e){void 0!==e&&(this.sRule=e);var r=t.split("/");r.shift();for(var i=[],s=0;s<r.length;s++)if(r[s].match(/^[^=]+=.+$/))i.push(r[s]);else{var o=i.length-1;i[o]=i[o]+"/"+r[s]}for(s=0;s<i.length;s++)this.asn1Array.push(new n({str:i[s],rule:this.sRule}))},this.setByLdapString=function(t,e){void 0!==e&&(this.sRule=e);var n=r.X500Name.ldapToCompat(t);this.setByString(n,e)},this.setByObject=function(t,e){for(var r in void 0!==e&&(this.sRule=e),t)if(t.hasOwnProperty(r)){var i=new n({str:r+"="+t[r],rule:this.sRule});this.asn1Array?this.asn1Array.push(i):this.asn1Array=[i]}},this.setByParam=function(t){var e;(void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.array)?this.paramArray=t.array:void 0!==t.str?this.setByString(t.str):void 0!==t.ldapstr?this.setByLdapString(t.ldapstr):void 0!==t.hex?this.hTLV=t.hex:void 0!==t.certissuer?((e=new kt).readCertPEM(t.certissuer),this.hTLV=e.getIssuerHex()):void 0!==t.certsubject?((e=new kt).readCertPEM(t.certsubject),this.hTLV=e.getSubjectHex()):"object"==typeof t&&void 0===t.certsubject&&void 0===t.certissuer&&this.setByObject(t)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(0==this.asn1Array.length&&this.paramArray.length>0)for(var t=0;t<this.paramArray.length;t++){var r={array:this.paramArray[t]};"utf8"!=this.sRule&&(r.rule=this.sRule);var i=new n(r);this.asn1Array.push(i)}var s=new e.DERSequence({array:this.asn1Array});return this.hTLV=s.getEncodedHex(),this.hTLV},void 0!==t&&this.setByParam(t)},xt(d.asn1.x509.X500Name,d.asn1.ASN1Object),d.asn1.x509.X500Name.compatToLDAP=function(t){if("/"!==t.substr(0,1))throw"malformed input";var e=(t=t.substr(1)).split("/");return e.reverse(),(e=e.map((function(t){return t.replace(/,/,"\\,")}))).join(",")},d.asn1.x509.X500Name.onelineToLDAP=function(t){return d.asn1.x509.X500Name.compatToLDAP(t)},d.asn1.x509.X500Name.ldapToCompat=function(t){for(var e=t.split(","),r=!1,n=[],i=0;e.length>0;i++){var s=e.shift();if(!0===r){var o=(n.pop()+","+s).replace(/\\,/g,",");n.push(o),r=!1}else n.push(s);"\\"===s.substr(-1,1)&&(r=!0)}return(n=n.map((function(t){return t.replace("/","\\/")}))).reverse(),"/"+n.join("/")},d.asn1.x509.X500Name.ldapToOneline=function(t){return d.asn1.x509.X500Name.ldapToCompat(t)},d.asn1.x509.RDN=function(t){d.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=d.asn1.x509.AttributeTypeAndValue;this.setByParam=function(t){void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.str&&this.addByMultiValuedString(t.str),void 0!==t.array&&(this.paramArray=t.array)},this.addByString=function(t){this.asn1Array.push(new d.asn1.x509.AttributeTypeAndValue({str:t,rule:this.sRule}))},this.addByMultiValuedString=function(t){for(var e=d.asn1.x509.RDN.parseString(t),r=0;r<e.length;r++)this.addByString(e[r])},this.getEncodedHex=function(){if(0==this.asn1Array.length&&this.paramArray.length>0)for(var t=0;t<this.paramArray.length;t++){var r=this.paramArray[t];void 0!==r.rule&&"utf8"!=this.sRule&&(r.rule=this.sRule);var n=new e(r);this.asn1Array.push(n)}var i=new d.asn1.DERSet({array:this.asn1Array});return this.TLV=i.getEncodedHex(),this.TLV},void 0!==t&&this.setByParam(t)},xt(d.asn1.x509.RDN,d.asn1.ASN1Object),d.asn1.x509.RDN.parseString=function(t){for(var e=t.split(/\+/),r=!1,n=[],i=0;e.length>0;i++){var s=e.shift();if(!0===r){var o=(n.pop()+"+"+s).replace(/\\\+/g,"+");n.push(o),r=!1}else n.push(s);"\\"===s.substr(-1,1)&&(r=!0)}var a=!1,u=[];for(i=0;n.length>0;i++){s=n.shift();if(!0===a){var h=u.pop();if(s.match(/"$/)){o=(h+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");u.push(o),a=!1}else u.push(h+"+"+s)}else u.push(s);s.match(/^[^=]+="/)&&(a=!0)}return u},d.asn1.x509.AttributeTypeAndValue=function(t){d.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var e=d,r=e.asn1,n=r.DERSequence,i=r.DERUTF8String,s=r.DERPrintableString,o=r.DERTeletexString,a=r.DERIA5String,u=r.DERVisibleString,h=r.DERBMPString,c=e.lang.String.isMail,l=e.lang.String.isPrintable;this.setByParam=function(t){if(void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.ds&&(this.dsType=t.ds),void 0===t.value&&void 0!==t.str){var e=t.str.match(/^([^=]+)=(.+)$/);if(!e)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.sType=e[1],this.sValue=e[2]}else this.sType=t.type,this.sValue=t.value},this.setByString=function(t,e){void 0!==e&&(this.sRule=e);var r=t.match(/^([^=]+)=(.+)$/);if(!r)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.setByAttrTypeAndValueStr(r[1],r[2])},this._getDsType=function(){var t=this.sType,e=this.sValue,r=this.sRule;return"prn"===r?"CN"==t&&c(e)?"ia5":l(e)?"prn":"utf8":"utf8"===r?"CN"==t&&c(e)?"ia5":"C"==t?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(t,e,r){void 0!==r&&(this.sRule=r),this.sType=t,this.sValue=e},this.getValueObj=function(t,e){if("utf8"==t)return new i({str:e});if("prn"==t)return new s({str:e});if("tel"==t)return new o({str:e});if("ia5"==t)return new a({str:e});if("vis"==t)return new u({str:e});if("bmp"==t)return new h({str:e});throw new Error("unsupported directory string type: type="+t+" value="+e)},this.getEncodedHex=function(){null==this.dsType&&(this.dsType=this._getDsType());var t=d.asn1.x509.OID.atype2obj(this.sType),e=this.getValueObj(this.dsType,this.sValue),r=new n({array:[t,e]});return this.TLV=r.getEncodedHex(),this.TLV},void 0!==t&&this.setByParam(t)},xt(d.asn1.x509.AttributeTypeAndValue,d.asn1.ASN1Object),d.asn1.x509.SubjectPublicKeyInfo=function(t){d.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=d,r=e.asn1,n=r.DERInteger,i=r.DERBitString,s=r.DERObjectIdentifier,o=r.DERSequence,a=r.ASN1Util.newObject,u=r.x509.AlgorithmIdentifier,h=e.crypto;h.ECDSA,h.DSA,this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new o({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.getEncodedHex=function(){var t=this.getASN1Object();return this.hTLV=t.getEncodedHex(),this.hTLV},this.setPubKey=function(t){try{if(t instanceof tt){var e=a({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).getEncodedHex();this.asn1AlgId=new u({name:"rsaEncryption"}),this.asn1SubjPKey=new i({hex:"00"+e})}}catch(t){}try{if(t instanceof d.crypto.ECDSA){var r=new s({name:t.curveName});this.asn1AlgId=new u({name:"ecPublicKey",asn1params:r}),this.asn1SubjPKey=new i({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof d.crypto.DSA){r=new a({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]});this.asn1AlgId=new u({name:"dsa",asn1params:r});var o=new n({bigint:t.y});this.asn1SubjPKey=new i({hex:"00"+o.getEncodedHex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},xt(d.asn1.x509.SubjectPublicKeyInfo,d.asn1.ASN1Object),d.asn1.x509.Time=function(t){d.asn1.x509.Time.superclass.constructor.call(this);var e=d.asn1,r=e.DERUTCTime,n=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.getEncodedHex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new r(this.timeParams):new n(this.timeParams):"utc"==this.type?new r:new n,this.TLV=t.getEncodedHex(),this.TLV},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=t)},xt(d.asn1.x509.Time,d.asn1.ASN1Object),d.asn1.x509.AlgorithmIdentifier=function(t){d.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=d.asn1,r=e.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 t=null;for(var n in r)n===this.nameAlg&&(t=r[n]);if(null!==t)return this.hTLV=t,this.hTLV}null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var i=[this.asn1Alg];null!==this.asn1Params&&i.push(this.asn1Params);var s=new e.DERSequence({array:i});return this.hTLV=s.getEncodedHex(),this.hTLV},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty&&(this.paramEmpty=t.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 e.DERNull)}},xt(d.asn1.x509.AlgorithmIdentifier,d.asn1.ASN1Object),d.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"},d.asn1.x509.GeneralName=function(t){d.asn1.x509.GeneralName.superclass.constructor.call(this);var e={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},r=d.asn1;r.DERSequence;var n=r.DEROctetString,i=r.DERIA5String,s=r.DERTaggedObject,o=r.ASN1Object,a=r.x509.X500Name,u=dt;this.explicit=!1,this.setByParam=function(t){var r=null;if(void 0!==t){if(void 0!==t.rfc822&&(this.type="rfc822",r=new i({str:t[this.type]})),void 0!==t.dns&&(this.type="dns",r=new i({str:t[this.type]})),void 0!==t.uri&&(this.type="uri",r=new i({str:t[this.type]})),void 0!==t.dn&&(this.type="dn",this.explicit=!0,r="string"==typeof t.dn?new a({str:t.dn}):t.dn instanceof d.asn1.x509.X500Name?t.dn:new a(t.dn)),void 0!==t.ldapdn&&(this.type="dn",this.explicit=!0,r=new a({ldapstr:t.ldapdn})),void 0!==t.certissuer){this.type="dn",this.explicit=!0;var h=null;if((l=t.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(h=u(l)),null==h)throw"certissuer param not cert";(f=new kt).hex=h;var c=f.getIssuerHex();(r=new o).hTLV=c}if(void 0!==t.certsubj){this.type="dn",this.explicit=!0;var l,f;h=null;if((l=t.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(h=u(l)),null==h)throw"certsubj param not cert";(f=new kt).hex=h;c=f.getSubjectHex();(r=new o).hTLV=c}if(void 0!==t.ip){this.type="ip",this.explicit=!1;var p,g=t.ip,y="malformed IP address";if(g.match(/^[0-9.]+[.][0-9.]+$/)){if(8!==(p=function(t){t=(t=(t=t.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return t.split(/,/).map((function(t,e,r){var n=parseInt(t);if(n<0||255<n)throw"integer not in range 0-255";return("00"+n.toString(16)).slice(-2)})).join("")}catch(t){throw"malformed integer array string: "+t}}("["+g.split(".").join(",")+"]")).length)throw y}else if(g.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))p=function(t){var e="malformed IPv6 address";if(!t.match(/^[0-9A-Fa-f:]+$/))throw e;var r=(t=t.toLowerCase()).split(":").length-1;if(r<2)throw e;var n=":".repeat(7-r+2),i=(t=t.replace("::",n)).split(":");if(8!=i.length)throw e;for(var s=0;s<8;s++)i[s]=("0000"+i[s]).slice(-4);return i.join("")}(g);else{if(!g.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw y;p=g}r=new n({hex:p})}if(null==this.type)throw"unsupported type in params="+t;this.asn1Obj=new s({explicit:this.explicit,tag:e[this.type],obj:r})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==t&&this.setByParam(t)},xt(d.asn1.x509.GeneralName,d.asn1.ASN1Object),d.asn1.x509.GeneralNames=function(t){d.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=d.asn1;this.setByParamArray=function(t){for(var r=0;r<t.length;r++){var n=new e.x509.GeneralName(t[r]);this.asn1Array.push(n)}},this.getEncodedHex=function(){return new e.DERSequence({array:this.asn1Array}).getEncodedHex()},this.asn1Array=new Array,void 0!==t&&this.setByParamArray(t)},xt(d.asn1.x509.GeneralNames,d.asn1.ASN1Object),d.asn1.x509.OID=new function(t){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(t){if(void 0!==this.objCache[t])return this.objCache[t];if(void 0===this.name2oidList[t])throw"Name of ObjectIdentifier not defined: "+t;var e=this.name2oidList[t],r=new d.asn1.DERObjectIdentifier({oid:e});return this.objCache[t]=r,r},this.atype2obj=function(t){if(void 0!==this.objCache[t])return this.objCache[t];var e;if(t.match(/^\d+\.\d+\.[0-9.]+$/))e=t;else if(void 0!==this.atype2oidList[t])e=this.atype2oidList[t];else{if(void 0===this.name2oidList[t])throw"AttributeType name undefined: "+t;e=this.name2oidList[t]}var r=new d.asn1.DERObjectIdentifier({oid:e});return this.objCache[t]=r,r}},d.asn1.x509.OID.oid2name=function(t){var e=d.asn1.x509.OID.name2oidList;for(var r in e)if(e[r]==t)return r;return""},d.asn1.x509.OID.oid2atype=function(t){var e=d.asn1.x509.OID.atype2oidList;for(var r in e)if(e[r]==t)return r;return t},d.asn1.x509.OID.name2oid=function(t){if(t.match(/^[0-9.]+$/))return t;var e=d.asn1.x509.OID.name2oidList;return void 0===e[t]?"":e[t]},d.asn1.x509.X509Util={},d.asn1.x509.X509Util.newCertPEM=function(t){var e=d.asn1.x509;return e.TBSCertificate,new(0,e.Certificate)(t).getPEM()},tt.getPosArrayOfChildrenFromHex=function(t){return Tt.getChildIdx(t,0)},tt.getHexValueArrayOfChildrenFromHex=function(t){var e,r=Tt.getV,n=r(t,(e=tt.getPosArrayOfChildrenFromHex(t))[0]),i=r(t,e[1]),s=r(t,e[2]),o=r(t,e[3]),a=r(t,e[4]),u=r(t,e[5]),h=r(t,e[6]),c=r(t,e[7]),l=r(t,e[8]);return(e=new Array).push(n,i,s,o,a,u,h,c,l),e},tt.prototype.readPrivateKeyFromPEMString=function(t){var e=dt(t),r=tt.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8])},tt.prototype.readPKCS5PrvKeyHex=function(t){var e=tt.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},tt.prototype.readPKCS8PrvKeyHex=function(t){var e,r,n,i,s,o,a,u,h=Tt,c=h.getVbyListEx;if(!1===h.isASN1HEX(t))throw new Error("not ASN.1 hex string");try{e=c(t,0,[2,0,1],"02"),r=c(t,0,[2,0,2],"02"),n=c(t,0,[2,0,3],"02"),i=c(t,0,[2,0,4],"02"),s=c(t,0,[2,0,5],"02"),o=c(t,0,[2,0,6],"02"),a=c(t,0,[2,0,7],"02"),u=c(t,0,[2,0,8],"02")}catch(t){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(e,r,n,i,s,o,a,u)},tt.prototype.readPKCS5PubKeyHex=function(t){var e=Tt,r=e.getV;if(!1===e.isASN1HEX(t))throw new Error("keyHex is not ASN.1 hex string");var n=e.getChildIdx(t,0);if(2!==n.length||"02"!==t.substr(n[0],2)||"02"!==t.substr(n[1],2))throw new Error("wrong hex for PKCS#5 public key");var i=r(t,n[0]),s=r(t,n[1]);this.setPublic(i,s)},tt.prototype.readPKCS8PubKeyHex=function(t){var e=Tt;if(!1===e.isASN1HEX(t))throw new Error("not ASN.1 hex string");if("06092a864886f70d010101"!==e.getTLVbyListEx(t,0,[0,0]))throw new Error("not PKCS8 RSA public key");var r=e.getTLVbyListEx(t,0,[1,0]);this.readPKCS5PubKeyHex(r)},tt.prototype.readCertPubKeyHex=function(t,e){var r,n;(r=new kt).readCertHex(t),n=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)},tt.prototype.sign=function(t,e){var r,n=(r=t,d.crypto.Util.hashString(r,e));return this.signWithMessageHash(n,e)},tt.prototype.signWithMessageHash=function(t,e){var r=$(d.crypto.Util.getPaddedDigestInfoHex(t,e,this.n.bitLength()),16);return Rt(this.doPrivate(r).toString(16),this.n.bitLength())},tt.prototype.signPSS=function(t,e,r){var n,i=(n=ct(t),d.crypto.Util.hashHex(n,e));return void 0===r&&(r=-1),this.signWithMessageHashPSS(i,e,r)},tt.prototype.signWithMessageHashPSS=function(t,e,r){var n,i=ht(t),s=i.length,o=this.n.bitLength()-1,a=Math.ceil(o/8),u=function(t){return d.crypto.Util.hashHex(t,e)};if(-1===r||void 0===r)r=s;else if(-2===r)r=a-s-2;else if(r<-2)throw new Error("invalid salt length");if(a<s+r+2)throw new Error("data too long");var h="";r>0&&(h=new Array(r),(new X).nextBytes(h),h=String.fromCharCode.apply(String,h));var c=ht(u(ct("\0\0\0\0\0\0\0\0"+i+h))),l=[];for(n=0;n<a-r-s-2;n+=1)l[n]=0;var f=String.fromCharCode.apply(String,l)+""+h,p=Ct(c,f.length,u),g=[];for(n=0;n<f.length;n+=1)g[n]=f.charCodeAt(n)^p.charCodeAt(n);var m=65280>>8*a-o&255;for(g[0]&=~m,n=0;n<s;n++)g.push(c.charCodeAt(n));return g.push(188),Rt(this.doPrivate(new y(g)).toString(16),this.n.bitLength())},tt.prototype.verify=function(t,e){if(null==(e=e.toLowerCase()).match(/^[0-9a-f]+$/))return!1;var r=$(e,16),n=this.n.bitLength();if(r.bitLength()>n)return!1;var i=this.doPublic(r).toString(16);if(i.length+3!=n/4)return!1;var s=It(i.replace(/^1f+00/,""));if(0==s.length)return!1;var o,a=s[0];return s[1]==(o=t,d.crypto.Util.hashString(o,a))},tt.prototype.verifyWithMessageHash=function(t,e){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=$(e,16);if(r.bitLength()>this.n.bitLength())return 0;var n=It(this.doPublic(r).toString(16).replace(/^1f+00/,""));return 0!=n.length&&(n[0],n[1]==t)},tt.prototype.verifyPSS=function(t,e,r,n){var i=function(t){return d.crypto.Util.hashHex(t,r)}(ct(t));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(i,e,r,n)},tt.prototype.verifyWithMessageHashPSS=function(t,e,r,n){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var i,s=new y(e,16),o=function(t){return d.crypto.Util.hashHex(t,r)},a=ht(t),u=a.length,h=this.n.bitLength()-1,c=Math.ceil(h/8);if(-1===n||void 0===n)n=u;else if(-2===n)n=c-u-2;else if(n<-2)throw new Error("invalid salt length");if(c<u+n+2)throw new Error("data too long");var l=this.doPublic(s).toByteArray();for(i=0;i<l.length;i+=1)l[i]&=255;for(;l.length<c;)l.unshift(0);if(188!==l[c-1])throw new Error("encoded message does not end in 0xbc");var f=(l=String.fromCharCode.apply(String,l)).substr(0,c-u-1),p=l.substr(f.length,u),g=65280>>8*c-h&255;if(0!=(f.charCodeAt(0)&g))throw new Error("bits beyond keysize not zero");var m=Ct(p,f.length,o),v=[];for(i=0;i<f.length;i+=1)v[i]=f.charCodeAt(i)^m.charCodeAt(i);v[0]&=~g;var x=c-u-n-2;for(i=0;i<x;i+=1)if(0!==v[i])throw new Error("leftmost octets not zero");if(1!==v[x])throw new Error("0x01 marker not found");return p===ht(o(ct("\0\0\0\0\0\0\0\0"+a+String.fromCharCode.apply(String,v.slice(-n)))))},tt.SALT_LEN_HLEN=-1,tt.SALT_LEN_MAX=-2,tt.SALT_LEN_RECOVER=-2,kt.hex2dn=function(t,e){void 0===e&&(e=0);var r=new kt;return Tt.getTLV(t,e),r.getX500Name(t).str},kt.hex2rdn=function(t,e){if(void 0===e&&(e=0),"31"!==t.substr(e,2))throw new Error("malformed RDN");for(var r=new Array,n=Tt.getChildIdx(t,e),i=0;i<n.length;i++)r.push(kt.hex2attrTypeValue(t,n[i]));return(r=r.map((function(t){return t.replace("+","\\+")}))).join("+")},kt.hex2attrTypeValue=function(t,e){var r=Tt,n=r.getV;if(void 0===e&&(e=0),"30"!==t.substr(e,2))throw new Error("malformed attribute type and value");var i=r.getChildIdx(t,e);2!==i.length||t.substr(i[0],2);var s=n(t,i[0]),o=d.asn1.ASN1Util.oidHexToInt(s);return d.asn1.x509.OID.oid2atype(o)+"="+ht(n(t,i[1]))},kt.getPublicKeyFromCertHex=function(t){var e=new kt;return e.readCertHex(t),e.getPublicKey()},kt.getPublicKeyFromCertPEM=function(t){var e=new kt;return e.readCertPEM(t),e.getPublicKey()},kt.getPublicKeyInfoPropOfCertPEM=function(t){var e,r,n=Tt.getVbyList,i={};return i.algparam=null,(e=new kt).readCertPEM(t),r=e.getPublicKeyHex(),i.keyhex=n(r,0,[1],"03").substr(2),i.algoid=n(r,0,[0,0],"06"),"2a8648ce3d0201"===i.algoid&&(i.algparam=n(r,0,[0,1],"06")),i},kt.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"];var _t,Vt=[(_t=new kt,_t.readCertPEM(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=113,n=126,i=0,s="";return arguments[i].split(s).map((function(t){return t.charCodeAt(i)>n?t:String.fromCharCode((t.charCodeAt(i)+r)%n)})).join(s)}(":::::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:::::")),_t)];function Bt(t,e){var r=t.getIssuerHex();if(r===t.getSubjectHex())return t.verifySignature(t.getPublicKey());var n=function(t,e){for(var r=0,n=e;r<n.length;r++){var i=n[r];if(i.getSubjectHex()===t)return i}}(r,e);return!!n&&(!1!==t.verifySignature(n.getPublicKey())&&Bt(n,e))}function Ht(t){return t.getIssuerHex()!==t.getSubjectHex()&&Bt(t,Vt)}!function(t){var e=new kt;"string"==typeof t?e.readCertPEM(t):e.readCertHex(t.hex);var r=Ht(e);Vt.push(e)}(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=113,n=126,i=0,s="";return arguments[i].split(s).map((function(t){return t.charCodeAt(i)>n?t:String.fromCharCode((t.charCodeAt(i)+r)%n)})).join(s)}(":::::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 Mt,Kt,Lt,zt,Ft=function(){function t(t,e,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===r&&(r=0),this.x=t,this.y=e,this.z=r}return t.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},t.prototype.set=function(t,e,r){return this.x=t,this.y=e,this.z=r,this},t.prototype.fromArray=function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},t.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},t.prototype.multiplyScalar=function(t){return this.x*=t,this.y*=t,this.z*=t,this},t.prototype.subVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},t.prototype.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},t.prototype.cross=function(t){var e=this.x,r=this.y,n=this.z;return this.x=r*t.z-n*t.y,this.y=n*t.x-e*t.z,this.z=e*t.y-r*t.x,this},t.prototype.crossVectors=function(t,e){var r=t.x,n=t.y,i=t.z,s=e.x,o=e.y,a=e.z;return this.x=n*a-i*o,this.y=i*s-r*a,this.z=r*o-n*s,this},t.prototype.clone=function(){return new t(this.x,this.y,this.z)},t}(),Ut=function(){function t(t,e,r,n,i){this._extentsMin=t,this._extentsMax=e,this._startIndex=r,this._endIndex=n,this._level=i,this._node0=null,this._node1=null,this.elementCount=n-r,this.center=[(t.x+e.x)/2,(t.y+e.y)/2,(t.z+e.z)/2];var s,o=this.size=[e.x-t.x,e.y-t.y,e.z-t.z];s=o[0]>o[1]?o[1]>o[2]?[2,1,0]:o[0]>o[2]?[1,2,0]:[1,0,2]:o[1]>o[2]?o[0]>o[2]?[2,0,1]:[0,2,1]:[0,1,2],this.order=s}return t.prototype.clearShapes=function(){this._startIndex=-1,this._endIndex=-1,this.elementCount=0},t}(),qt=(Mt=new Ft,Kt=new Ft,Lt=new Ft,zt=new Ft,function(t,e,r,n,i,s){Kt.subVectors(e,t),Lt.subVectors(r,t),zt.crossVectors(Kt,Lt);var o,a=i.dot(zt);if(a>0){if(s)return null;o=1}else{if(!(a<0))return null;o=-1,a=-a}Mt.subVectors(n,t);var u=o*i.dot(Lt.crossVectors(Mt,Lt));if(u<0)return null;var h=o*i.dot(Kt.cross(Mt));if(h<0)return null;if(u+h>a)return null;var c=-o*Mt.dot(zt);if(c<0)return null;var l=c/a;return(new Ft).copy(i).multiplyScalar(l).add(n)});function Gt(t,e,r){var n={min:0,max:0};e.x>=0?(n.min=(r._extentsMin.x-t.x)*e.x,n.max=(r._extentsMax.x-t.x)*e.x):(n.min=(r._extentsMax.x-t.x)*e.x,n.max=(r._extentsMin.x-t.x)*e.x);var i={min:0,max:0};if(e.y>=0?(i.min=(r._extentsMin.y-t.y)*e.y,i.max=(r._extentsMax.y-t.y)*e.y):(i.min=(r._extentsMax.y-t.y)*e.y,i.max=(r._extentsMin.y-t.y)*e.y),n.min>i.max||i.min>n.max)return!1;i.min>n.min&&(n.min=i.min),i.max<n.max&&(n.max=i.max);var s={min:0,max:0};return e.z>=0?(s.min=(r._extentsMin.z-t.z)*e.z,s.max=(r._extentsMax.z-t.z)*e.z):(s.min=(r._extentsMax.z-t.z)*e.z,s.max=(r._extentsMin.z-t.z)*e.z),!(n.min>s.max||s.min>n.max)&&(s.min>n.min&&(n.min=s.min),s.max<n.max&&(n.max=s.max),!(n.max<0))}var Qt=function(){function t(t,e){void 0===e&&(e=10),this._trianglesArray=t,this._maxTrianglesPerNode=e,this._bboxArray=this.calcBoundingBoxes(t),this._bboxHelper=new Float32Array(this._bboxArray.length),this._bboxHelper.set(this._bboxArray);var r=t.length/9,n=this.calcExtents(0,r,1e-6);this._rootNode=new Ut(n[0],n[1],0,r,0),this._nodesToSplit=[this._rootNode],this.splitNode()}return t.prototype.calcBoundingBoxes=function(t){for(var e,r,n,i,s,o,a,u,h,c,l,f,d,p,g,y=t.length/9,m=new Float32Array(7*y),v=0,x=0,b=0;b<y;v+=9,x+=7,b++)e=t[v],r=t[v+1],n=t[v+2],i=t[v+3],s=t[v+4],o=t[v+5],i<(c=e)&&(c=i),(a=t[v+6])<c&&(c=a),s<(l=r)&&(l=s),(u=t[v+7])<l&&(l=u),o<(f=n)&&(f=o),(h=t[v+8])<f&&(f=h),i>(d=e)&&(d=i),a>d&&(d=a),s>(p=r)&&(p=s),u>p&&(p=u),o>(g=n)&&(g=o),h>g&&(g=h),m[x]=b,m[x+1]=c,m[x+2]=l,m[x+3]=f,m[x+4]=d,m[x+5]=p,m[x+6]=g;return m},t.prototype.splitNode=function(){if(this._rootNode)for(this._splitNode(this._rootNode);this._nodesToSplit.length>0;)this._splitNode(this._nodesToSplit.pop())},t.prototype._splitNode=function(t){if(!(t.elementCount<=this._maxTrianglesPerNode||0===t.elementCount)){for(var e=t._startIndex,r=t._endIndex,n=[[],[],[]],i=[[],[],[]],s=t.center,o=7*(b=e);b<r;b++,o+=7)for(var a=0;a<3;a++)(this._bboxArray[o+1+a]+this._bboxArray[o+4+a])/2<s[a]?n[a][n[a].length]=b:i[a][i[a].length]=b;var u=[!(n[0].length&i[0].length),!(n[1].length&i[1].length),!(n[2].length&i[2].length)];if(!(u[0]&u[1]&u[2])){var h,c,l=t.order;for(a=0;a<3;a++){var f=l[a];if(!u[f]){h=n[f],c=i[f];break}}for(var d,p=e,g=p+h.length,y=g,m=r,v=t._startIndex,x=h.concat(c),b=0;b<x.length;b++)d=x[b],this._bboxHelper[7*v]=this._bboxArray[7*d],this._bboxHelper[7*v+1]=this._bboxArray[7*d+1],this._bboxHelper[7*v+2]=this._bboxArray[7*d+2],this._bboxHelper[7*v+3]=this._bboxArray[7*d+3],this._bboxHelper[7*v+4]=this._bboxArray[7*d+4],this._bboxHelper[7*v+5]=this._bboxArray[7*d+5],this._bboxHelper[7*v+6]=this._bboxArray[7*d+6],v++;var w=this._bboxHelper.subarray(7*t._startIndex,7*t._endIndex);this._bboxArray.set(w,7*t._startIndex);var S=this.calcExtents(p,g,1e-6),E=this.calcExtents(y,m,1e-6),A=new Ut(S[0],S[1],p,g,t._level+1),P=new Ut(E[0],E[1],y,m,t._level+1);t._node0=A,t._node1=P,t.clearShapes(),this._nodesToSplit.push(A,P)}}},t.prototype.calcExtents=function(t,e,r){if(t>=e)return[{x:0,y:0,z:0},{x:0,y:0,z:0}];var n,i=7*t,s=7*e+1,o=this._bboxArray[i+1],a=this._bboxArray[i+2],u=this._bboxArray[i+3],h=this._bboxArray[i+4],c=this._bboxArray[i+5],l=this._bboxArray[i+6],f=this._bboxArray;for(i+=7;i<s;i+=7)(n=f[i+1])<o&&(o=n),(n=f[i+2])<a&&(a=n),(n=f[i+3])<u&&(u=n),(n=f[i+4])>h&&(h=n),(n=f[i+5])>c&&(c=n),(n=f[i+6])>l&&(l=n);return[{x:o-r,y:a-r,z:u-r},{x:h+r,y:c+r,z:l+r}]},t.prototype.intersectRay=function(t,e,r){for(var n=[this._rootNode],i=[],s=[],o=new Ft(1/e.x,1/e.y,1/e.z);n.length>0;){var a=n.pop();if(Gt(t,o,a)){a._node0&&n.push(a._node0),a._node1&&n.push(a._node1);for(var u=a._startIndex;u<a._endIndex;u++)i.push(this._bboxArray[7*u])}}var h=new Ft,c=new Ft,l=new Ft,f=new Ft(t.x,t.y,t.z),d=new Ft(e.x,e.y,e.z);for(u=0;u<i.length;u++){var p=i[u];h.fromArray(this._trianglesArray,9*p),c.fromArray(this._trianglesArray,9*p+3),l.fromArray(this._trianglesArray,9*p+6);var g=qt(h,c,l,f,d,r);g&&s.push({triangle:[h.clone(),c.clone(),l.clone()],triangleIndex:p,intersectionPoint:g})}return s},t.prototype.dispose=function(){this._trianglesArray=new Float32Array,this._bboxArray=new Float32Array,this._bboxHelper=new Float32Array,this._rootNode=null,this._nodesToSplit.length=0},t}();function Zt(t){return null==t}var Yt={computeTangents:function(t){var e=t.index,r=t.attributes;if(null!==e&&void 0!==r.position&&void 0!==r.normal&&void 0!==r.uv){var n=e.array,i=r.position.array,s=r.normal.array,o=r.uv.array,u=i.length/3;void 0===r.tangent&&t.setAttribute("tangent",new a.BufferAttribute(new Float32Array(4*u),4));for(var h=r.tangent.array,c=[],l=[],f=0;f<u;f++)c[f]=new a.Vector3,l[f]=new a.Vector3;var d=new a.Vector3,p=new a.Vector3,g=new a.Vector3,y=new a.Vector2,m=new a.Vector2,v=new a.Vector2,x=new a.Vector3,b=new a.Vector3,w=t.groups;0===w.length&&(w=[{start:0,count:n.length}]);f=0;for(var S=w.length;f<S;++f)for(var E=k=(I=w[f]).start,A=k+I.count;E<A;E+=3)j(n[E+0],n[E+1],n[E+2]);var P,D,N,O=new a.Vector3,T=new a.Vector3,R=new a.Vector3,C=new a.Vector3;for(f=0,S=w.length;f<S;++f){var I,k;for(E=k=(I=w[f]).start,A=k+I.count;E<A;E+=3)_(n[E+0]),_(n[E+1]),_(n[E+2])}}else console.warn("THREE.BufferGeometry: Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");function j(t,e,r){d.fromArray(i,3*t),p.fromArray(i,3*e),g.fromArray(i,3*r),y.fromArray(o,2*t),m.fromArray(o,2*e),v.fromArray(o,2*r);var n=p.x-d.x,s=g.x-d.x,a=p.y-d.y,u=g.y-d.y,h=p.z-d.z,f=g.z-d.z,w=m.x-y.x,S=v.x-y.x,E=m.y-y.y,A=v.y-y.y,P=1/(w*A-S*E);x.set((A*n-E*s)*P,(A*a-E*u)*P,(A*h-E*f)*P),b.set((w*s-S*n)*P,(w*u-S*a)*P,(w*f-S*h)*P),c[t].add(x),c[e].add(x),c[r].add(x),l[t].add(b),l[e].add(b),l[r].add(b)}function _(t){R.fromArray(s,3*t),C.copy(R),D=c[t],O.copy(D),O.sub(R.multiplyScalar(R.dot(D))).normalize(),T.crossVectors(C,D),N=T.dot(l[t]),P=N<0?-1:1,h[4*t]=O.x,h[4*t+1]=O.y,h[4*t+2]=O.z,h[4*t+3]=P}},mergeBufferGeometries:function(t,e){for(var r=null!==t[0].index,n=new Set(Object.keys(t[0].attributes)),i=new Set(Object.keys(t[0].morphAttributes)),s={},o={},u=new a.BufferGeometry,h=0,c=0;c<t.length;++c){var l=t[c];if(r!==(null!==l.index))return null;for(var f in l.attributes){if(!n.has(f))return null;void 0===s[f]&&(s[f]=[]),s[f].push(l.attributes[f])}for(var f in l.morphAttributes){if(!i.has(f))return null;void 0===o[f]&&(o[f]=[]),o[f].push(l.morphAttributes[f])}if(u.userData.mergedUserData=u.userData.mergedUserData||[],u.userData.mergedUserData.push(l.userData),e){var d;if(r)d=l.index.count;else{if(void 0===l.attributes.position)return null;d=l.attributes.position.count}u.addGroup(h,d,c),h+=d}}if(r){var p=0,g=[];for(c=0;c<t.length;++c){for(var y=t[c].index,m=0;m<y.count;++m)g.push(y.getX(m)+p);p+=t[c].attributes.position.count}u.setIndex(g)}for(var f in s){var v=this.mergeBufferAttributes(s[f]);if(!v)return null;u.setAttribute(f,v)}for(var f in o){var x=o[f][0].length;if(0===x)break;u.morphAttributes=u.morphAttributes||{},u.morphAttributes[f]=[];for(c=0;c<x;++c){var b=[];for(m=0;m<o[f].length;++m)b.push(o[f][m][c]);var w=this.mergeBufferAttributes(b);if(!w)return null;u.morphAttributes[f].push(w)}}return u},mergeBufferAttributes:function(t){for(var e,r,n,i=0,s=0;s<t.length;++s){var o=t[s];if(o.isInterleavedBufferAttribute)return null;if(void 0===e&&(e=o.array.constructor),e!==o.array.constructor)return null;if(void 0===r&&(r=o.itemSize),r!==o.itemSize)return null;if(void 0===n&&(n=o.normalized),n!==o.normalized)return null;i+=o.array.length}var u=new e(i),h=0;for(s=0;s<t.length;++s)u.set(t[s].array,h),h+=t[s].array.length;return new a.BufferAttribute(u,r,n)},interleaveAttributes:function(t){for(var e,r=0,n=0,i=0,s=t.length;i<s;++i){var o=t[i];if(void 0===e&&(e=o.array.constructor),e!==o.array.constructor)return console.warn("AttributeBuffers of different types cannot be interleaved"),null;r+=o.array.length,n+=o.itemSize}var u=new a.InterleavedBuffer(new e(r),n),h=0,c=[],l=["getX","getY","getZ","getW"],f=["setX","setY","setZ","setW"],d=0;for(s=t.length;d<s;d++){var p=(o=t[d]).itemSize,g=o.count,y=new a.InterleavedBufferAttribute(u,p,h,o.normalized);c.push(y),h+=p;for(var m=0;m<g;m++)for(var v=0;v<p;v++)y[f[v]](m,o[l[v]](m))}return c},estimateBytesUsed:function(t){var e=0;for(var r in t.attributes){var n=t.getAttribute(r);e+=n.count*n.itemSize*n.array.BYTES_PER_ELEMENT}var i=t.getIndex();return e+=i?i.count*i.itemSize*i.array.BYTES_PER_ELEMENT:0},mergeVertices:function(t,e){void 0===e&&(e=1e-4),e=Math.max(e,Number.EPSILON);for(var r={},n=t.getIndex(),i=t.getAttribute("position"),s=n?n.count:i.count,o=0,u=Object.keys(t.attributes),h={},c={},l=[],f=["getX","getY","getZ","getW"],d=0,p=u.length;d<p;d++){h[b=u[d]]=[],(A=t.morphAttributes[b])&&(c[b]=new Array(A.length).fill().map((function(){return[]})))}var g=Math.log10(1/e),y=Math.pow(10,g);for(d=0;d<s;d++){var m=n?n.getX(d):d,v="",x=0;for(p=u.length;x<p;x++)for(var b=u[x],w=(E=t.getAttribute(b)).itemSize,S=0;S<w;S++)v+="".concat(~~(E[f[S]](m)*y),",");if(v in r)l.push(r[v]);else{for(x=0,p=u.length;x<p;x++){b=u[x];var E=t.getAttribute(b),A=t.morphAttributes[b],P=(w=E.itemSize,h[b]),D=c[b];for(S=0;S<w;S++){var N=f[S];if(P.push(E[N](m)),A)for(var O=0,T=A.length;O<T;O++)D[O].push(A[O][N](m))}}r[v]=o,l.push(o),o++}}var R=t.clone();for(d=0,p=u.length;d<p;d++){b=u[d];var C=t.getAttribute(b),I=new C.array.constructor(h[b]);E=new a.BufferAttribute(I,C.itemSize,C.normalized);if(R.setAttribute(b,E),b in c)for(x=0;x<c[b].length;x++){var k=t.morphAttributes[b][x],j=(I=new k.array.constructor(c[b][x]),new a.BufferAttribute(I,k.itemSize,k.normalized));R.morphAttributes[b][x]=j}}return R.setIndex(l),R}},Wt=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.floorIndex=0,e.needsRender=!0,e}return e.__extends(r,t),r}(a.Mesh);function Xt(t){return new Promise((function(e,r){(/^https\:/.test(t)?h.default:u.default).get(t,(function(t){var n=[];t.on("data",(function(t){return n.push(t)})),t.on("end",(function(){e(Buffer.concat(n).buffer)})),t.on("error",(function(t){return r(t)}))})).on("error",(function(t){return r(t)}))}))}const $t=c.Reader,Jt=c.Writer,te=c.util,ee=c.roots["@REALSEE/FIVE:3"]||(c.roots["@REALSEE/FIVE:3"]={}),re=ee.Model=(()=>{function t(t){if(this.chunks=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.chunks=te.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=Jt.create()),null!=t.chunks&&t.chunks.length)for(let r=0;r<t.chunks.length;++r)ee.Chunk.encode(t.chunks[r],e.uint32(10).fork()).ldelim();return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof $t||(t=$t.create(t));let r=void 0===e?t.len:t.pos+e,n=new ee.Model;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.chunks&&n.chunks.length||(n.chunks=[]),n.chunks.push(ee.Chunk.decode(t,t.uint32()));break;default:t.skipType(7&e)}}return n},t.decodeDelimited=function(t){return t instanceof $t||(t=new $t(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.chunks&&t.hasOwnProperty("chunks")){if(!Array.isArray(t.chunks))return"chunks: array expected";for(let e=0;e<t.chunks.length;++e){let r=ee.Chunk.verify(t.chunks[e]);if(r)return"chunks."+r}}return null},t.fromObject=function(t){if(t instanceof ee.Model)return t;let e=new ee.Model;if(t.chunks){if(!Array.isArray(t.chunks))throw TypeError(".Model.chunks: array expected");e.chunks=[];for(let r=0;r<t.chunks.length;++r){if("object"!=typeof t.chunks[r])throw TypeError(".Model.chunks: object expected");e.chunks[r]=ee.Chunk.fromObject(t.chunks[r])}}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.chunks=[]),t.chunks&&t.chunks.length){r.chunks=[];for(let n=0;n<t.chunks.length;++n)r.chunks[n]=ee.Chunk.toObject(t.chunks[n],e)}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})();ee.Chunk=(()=>{function t(t){if(t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.vertices=null,t.prototype.faces=null,t.prototype.name="",t.prototype.texture="",t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=Jt.create()),ee.Vertices.encode(t.vertices,e.uint32(10).fork()).ldelim(),ee.Faces.encode(t.faces,e.uint32(18).fork()).ldelim(),e.uint32(26).string(t.name),null!=t.texture&&Object.hasOwnProperty.call(t,"texture")&&e.uint32(34).string(t.texture),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof $t||(t=$t.create(t));let r=void 0===e?t.len:t.pos+e,n=new ee.Chunk;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.vertices=ee.Vertices.decode(t,t.uint32());break;case 2:n.faces=ee.Faces.decode(t,t.uint32());break;case 3:n.name=t.string();break;case 4:n.texture=t.string();break;default:t.skipType(7&e)}}if(!n.hasOwnProperty("vertices"))throw te.ProtocolError("missing required 'vertices'",{instance:n});if(!n.hasOwnProperty("faces"))throw te.ProtocolError("missing required 'faces'",{instance:n});if(!n.hasOwnProperty("name"))throw te.ProtocolError("missing required 'name'",{instance:n});return n},t.decodeDelimited=function(t){return t instanceof $t||(t=new $t(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";{let e=ee.Vertices.verify(t.vertices);if(e)return"vertices."+e}{let e=ee.Faces.verify(t.faces);if(e)return"faces."+e}return te.isString(t.name)?null!=t.texture&&t.hasOwnProperty("texture")&&!te.isString(t.texture)?"texture: string expected":null:"name: string expected"},t.fromObject=function(t){if(t instanceof ee.Chunk)return t;let e=new ee.Chunk;if(null!=t.vertices){if("object"!=typeof t.vertices)throw TypeError(".Chunk.vertices: object expected");e.vertices=ee.Vertices.fromObject(t.vertices)}if(null!=t.faces){if("object"!=typeof t.faces)throw TypeError(".Chunk.faces: object expected");e.faces=ee.Faces.fromObject(t.faces)}return null!=t.name&&(e.name=String(t.name)),null!=t.texture&&(e.texture=String(t.texture)),e},t.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(r.vertices=null,r.faces=null,r.name="",r.texture=""),null!=t.vertices&&t.hasOwnProperty("vertices")&&(r.vertices=ee.Vertices.toObject(t.vertices,e)),null!=t.faces&&t.hasOwnProperty("faces")&&(r.faces=ee.Faces.toObject(t.faces,e)),null!=t.name&&t.hasOwnProperty("name")&&(r.name=t.name),null!=t.texture&&t.hasOwnProperty("texture")&&(r.texture=t.texture),r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})(),ee.Vertices=(()=>{function t(t){if(this.xyz=[],this.uvs=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.xyz=te.emptyArray,t.prototype.uvs=te.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=Jt.create()),null!=t.xyz&&t.xyz.length){e.uint32(10).fork();for(let r=0;r<t.xyz.length;++r)e.float(t.xyz[r]);e.ldelim()}if(null!=t.uvs&&t.uvs.length){e.uint32(18).fork();for(let r=0;r<t.uvs.length;++r)e.float(t.uvs[r]);e.ldelim()}return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof $t||(t=$t.create(t));let r=void 0===e?t.len:t.pos+e,n=new ee.Vertices;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:if(n.xyz&&n.xyz.length||(n.xyz=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.xyz.push(t.float())}else n.xyz.push(t.float());break;case 2:if(n.uvs&&n.uvs.length||(n.uvs=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.uvs.push(t.float())}else n.uvs.push(t.float());break;default:t.skipType(7&e)}}return n},t.decodeDelimited=function(t){return t instanceof $t||(t=new $t(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.xyz&&t.hasOwnProperty("xyz")){if(!Array.isArray(t.xyz))return"xyz: array expected";for(let e=0;e<t.xyz.length;++e)if("number"!=typeof t.xyz[e])return"xyz: number[] expected"}if(null!=t.uvs&&t.hasOwnProperty("uvs")){if(!Array.isArray(t.uvs))return"uvs: array expected";for(let e=0;e<t.uvs.length;++e)if("number"!=typeof t.uvs[e])return"uvs: number[] expected"}return null},t.fromObject=function(t){if(t instanceof ee.Vertices)return t;let e=new ee.Vertices;if(t.xyz){if(!Array.isArray(t.xyz))throw TypeError(".Vertices.xyz: array expected");e.xyz=[];for(let r=0;r<t.xyz.length;++r)e.xyz[r]=Number(t.xyz[r])}if(t.uvs){if(!Array.isArray(t.uvs))throw TypeError(".Vertices.uvs: array expected");e.uvs=[];for(let r=0;r<t.uvs.length;++r)e.uvs[r]=Number(t.uvs[r])}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.xyz=[],r.uvs=[]),t.xyz&&t.xyz.length){r.xyz=[];for(let n=0;n<t.xyz.length;++n)r.xyz[n]=e.json&&!isFinite(t.xyz[n])?String(t.xyz[n]):t.xyz[n]}if(t.uvs&&t.uvs.length){r.uvs=[];for(let n=0;n<t.uvs.length;++n)r.uvs[n]=e.json&&!isFinite(t.uvs[n])?String(t.uvs[n]):t.uvs[n]}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})(),ee.Faces=(()=>{function t(t){if(this.indices=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.indices=te.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=Jt.create()),null!=t.indices&&t.indices.length){e.uint32(10).fork();for(let r=0;r<t.indices.length;++r)e.uint32(t.indices[r]);e.ldelim()}return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof $t||(t=$t.create(t));let r=void 0===e?t.len:t.pos+e,n=new ee.Faces;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:if(n.indices&&n.indices.length||(n.indices=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.indices.push(t.uint32())}else n.indices.push(t.uint32());break;default:t.skipType(7&e)}}return n},t.decodeDelimited=function(t){return t instanceof $t||(t=new $t(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.indices&&t.hasOwnProperty("indices")){if(!Array.isArray(t.indices))return"indices: array expected";for(let e=0;e<t.indices.length;++e)if(!te.isInteger(t.indices[e]))return"indices: integer[] expected"}return null},t.fromObject=function(t){if(t instanceof ee.Faces)return t;let e=new ee.Faces;if(t.indices){if(!Array.isArray(t.indices))throw TypeError(".Faces.indices: array expected");e.indices=[];for(let r=0;r<t.indices.length;++r)e.indices[r]=t.indices[r]>>>0}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.indices=[]),t.indices&&t.indices.length){r.indices=[];for(let e=0;e<t.indices.length;++e)r.indices[e]=t.indices[e]}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})();var ne=(new a.Matrix4).set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1);function ie(t){var e=t.match(/(group|floor)-?(\d+)/);return e?parseInt(e[2],10):0}function se(t){var e=t.indices,r=t.vertices,n=t.uvs,i=new a.BufferGeometry;i.setIndex(new a.BufferAttribute(new Uint32Array(e),1)),i.setAttribute("position",new a.BufferAttribute(new Float32Array(r),3)),i.attributes.position.applyMatrix4(ne),Zt(n)||i.setAttribute("uv",new a.BufferAttribute(new Float32Array(n),2));for(var s=new Float32Array(r.length),o=new a.Vector3,u=new a.Vector3,h=new a.Vector3,c=new a.Vector3,l=new a.Vector3,f=new a.Vector3,d=0,p=i.index.array.length,g=void 0,y=void 0,m=void 0;d<p;d+=3)g=3*e[d+0],y=3*e[d+1],m=3*e[d+2],o.x=r[g],o.y=r[g+1],o.z=r[g+2],u.x=r[y],u.y=r[y+1],u.z=r[y+2],h.x=r[m],h.y=r[m+1],h.z=r[m+2],c.x=h.x-u.x,c.y=h.y-u.y,c.z=h.z-u.z,l.x=o.x-u.x,l.y=o.y-u.y,l.z=o.z-u.z,f.x=c.y*l.z-c.z*l.y,f.y=c.z*l.x-c.x*l.z,f.z=c.x*l.y-c.y*l.x,s[g]+=f.x,s[g+1]+=f.y,s[g+2]+=f.z,s[y]+=f.x,s[y+1]+=f.y,s[y+2]+=f.z,s[m]+=f.x,s[m+1]+=f.y,s[m+2]+=f.z;return i.setAttribute("normal",new a.BufferAttribute(s,3)),i}function oe(t){for(var e=0,r=t;e<r.length;e++){(u=r[e]).chunkName=(n=u.name,i=void 0,(i=n.match(/(chunk)-?(\d+)/))?parseInt(i[2],10):0),u.floorName=ie(u.name)}var n,i;t.sort((function(t,e){return 1e3*t.floorName+t.chunkName-(1e3*e.floorName+e.chunkName)}));for(var s=[],o=[],a=0;a<t.length;a++){var u,h=ie((u=t[a]).name),c=s[h]=s[h]||{geometries:[]};(f=se({vertices:u.vertices.xyz,uvs:u.vertices.uvs,indices:u.faces.indices})).name="model_geo_chunk_"+a,c.geometries.push(f)}for(var l=0;l<s.length;l++){if(c=s[l]){var f=Yt.mergeBufferGeometries(c.geometries,!0);c.geometries.forEach((function(t){return t.dispose()}));var d=new Wt(f);d.floorIndex=l,d.name="model_floor_"+l,o.push(d)}}return{objects:o}}var ae={};function ue(t){return Array.prototype.reduce.call(t,(function(t,e,r){return t|e<<8*r}),0)}function he(t){for(var e=new Uint8Array(t),r=ue(e.slice(0,4)),n=[],i=[],s=4+4*r,o=0;o<r;o++)i[o]=ue(e.slice(4+4*o,8+4*o)),n[o]=o===r-1?e.subarray(s,s+i[o]):e.slice(s,s+i[o]),s+=i[o];return Promise.resolve(function(t){for(var e,r=[],n=t.length,i=function(n){var i={data:t[n],offset:0,readByte:function(){return this.data[this.offset++]}},s=i.data.length,o={data:[],offset:0,writeByte:function(t){var e=Math.floor(this.offset/s);this.data[e]||(this.data[e]=new Uint8Array(s)),this.data[e][this.offset%s]=t,this.offset++}};ae.decompressFile(i,o),e=new Uint8Array(o.offset);for(var a=0;a<o.offset;a++)e[a]=o.data[Math.floor(a/s)][a%s];r.push(e)},s=0;s<n;s++)i(s);return r}(n))}ae.OutWindow=function(){this._windowSize=0},ae.OutWindow.prototype.create=function(t){this._buffer&&this._windowSize===t||(this._buffer=[]),this._windowSize=t,this._pos=0,this._streamPos=0},ae.OutWindow.prototype.flush=function(){var t=this._pos-this._streamPos;if(0!==t){for(;t--;)this._stream.writeByte(this._buffer[this._streamPos++]);this._pos>=this._windowSize&&(this._pos=0),this._streamPos=this._pos}},ae.OutWindow.prototype.releaseStream=function(){this.flush(),this._stream=null},ae.OutWindow.prototype.setStream=function(t){this.releaseStream(),this._stream=t},ae.OutWindow.prototype.init=function(t){t||(this._streamPos=0,this._pos=0)},ae.OutWindow.prototype.copyBlock=function(t,e){var r=this._pos-t-1;for(r<0&&(r+=this._windowSize);e--;)r>=this._windowSize&&(r=0),this._buffer[this._pos++]=this._buffer[r++],this._pos>=this._windowSize&&this.flush()},ae.OutWindow.prototype.putByte=function(t){this._buffer[this._pos++]=t,this._pos>=this._windowSize&&this.flush()},ae.OutWindow.prototype.getByte=function(t){var e=this._pos-t-1;return e<0&&(e+=this._windowSize),this._buffer[e]},ae.RangeDecoder=function(){},ae.RangeDecoder.prototype.setStream=function(t){this._stream=t},ae.RangeDecoder.prototype.releaseStream=function(){this._stream=null},ae.RangeDecoder.prototype.init=function(){var t=5;for(this._code=0,this._range=-1;t--;)this._code=this._code<<8|this._stream.readByte()},ae.RangeDecoder.prototype.decodeDirectBits=function(t){for(var e,r=0,n=t;n--;)this._range>>>=1,e=this._code-this._range>>>31,this._code-=this._range&e-1,r=r<<1|1-e,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8);return r},ae.RangeDecoder.prototype.decodeBit=function(t,e){var r=t[e],n=(this._range>>>11)*r;return(2147483648^this._code)<(2147483648^n)?(this._range=n,t[e]+=2048-r>>>5,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8),0):(this._range-=n,this._code-=n,t[e]-=r>>>5,0==(4278190080&this._range)&&(this._code=this._code<<8|this._stream.readByte(),this._range<<=8),1)},ae.initBitModels=function(t,e){for(;e--;)t[e]=1024},ae.BitTreeDecoder=function(t){this._models=[],this._numBitLevels=t},ae.BitTreeDecoder.prototype.init=function(){ae.initBitModels(this._models,1<<this._numBitLevels)},ae.BitTreeDecoder.prototype.decode=function(t){for(var e=1,r=this._numBitLevels;r--;)e=e<<1|t.decodeBit(this._models,e);return e-(1<<this._numBitLevels)},ae.BitTreeDecoder.prototype.reverseDecode=function(t){for(var e,r=1,n=0,i=0;i<this._numBitLevels;++i)r=r<<1|(e=t.decodeBit(this._models,r)),n|=e<<i;return n},ae.reverseDecode2=function(t,e,r,n){for(var i,s=1,o=0,a=0;a<n;++a)s=s<<1|(i=r.decodeBit(t,e+s)),o|=i<<a;return o},ae.LenDecoder=function(){this._choice=[],this._lowCoder=[],this._midCoder=[],this._highCoder=new ae.BitTreeDecoder(8),this._numPosStates=0},ae.LenDecoder.prototype.create=function(t){for(;this._numPosStates<t;++this._numPosStates)this._lowCoder[this._numPosStates]=new ae.BitTreeDecoder(3),this._midCoder[this._numPosStates]=new ae.BitTreeDecoder(3)},ae.LenDecoder.prototype.init=function(){var t=this._numPosStates;for(ae.initBitModels(this._choice,2);t--;)this._lowCoder[t].init(),this._midCoder[t].init();this._highCoder.init()},ae.LenDecoder.prototype.decode=function(t,e){return 0===t.decodeBit(this._choice,0)?this._lowCoder[e].decode(t):0===t.decodeBit(this._choice,1)?8+this._midCoder[e].decode(t):16+this._highCoder.decode(t)},ae.Decoder2=function(){this._decoders=[]},ae.Decoder2.prototype.init=function(){ae.initBitModels(this._decoders,768)},ae.Decoder2.prototype.decodeNormal=function(t){var e=1;do{e=e<<1|t.decodeBit(this._decoders,e)}while(e<256);return 255&e},ae.Decoder2.prototype.decodeWithMatchByte=function(t,e){var r,n,i=1;do{if(r=e>>7&1,e<<=1,i=i<<1|(n=t.decodeBit(this._decoders,(1+r<<8)+i)),r!==n){for(;i<256;)i=i<<1|t.decodeBit(this._decoders,i);break}}while(i<256);return 255&i},ae.LiteralDecoder=function(){},ae.LiteralDecoder.prototype.create=function(t,e){var r;if(!this._coders||this._numPrevBits!==e||this._numPosBits!==t)for(this._numPosBits=t,this._posMask=(1<<t)-1,this._numPrevBits=e,this._coders=[],r=1<<this._numPrevBits+this._numPosBits;r--;)this._coders[r]=new ae.Decoder2},ae.LiteralDecoder.prototype.init=function(){for(var t=1<<this._numPrevBits+this._numPosBits;t--;)this._coders[t].init()},ae.LiteralDecoder.prototype.getDecoder=function(t,e){return this._coders[((t&this._posMask)<<this._numPrevBits)+((255&e)>>>8-this._numPrevBits)]},ae.Decoder=function(){this._outWindow=new ae.OutWindow,this._rangeDecoder=new ae.RangeDecoder,this._isMatchDecoders=[],this._isRepDecoders=[],this._isRepG0Decoders=[],this._isRepG1Decoders=[],this._isRepG2Decoders=[],this._isRep0LongDecoders=[],this._posSlotDecoder=[],this._posDecoders=[],this._posAlignDecoder=new ae.BitTreeDecoder(4),this._lenDecoder=new ae.LenDecoder,this._repLenDecoder=new ae.LenDecoder,this._literalDecoder=new ae.LiteralDecoder,this._dictionarySize=-1,this._dictionarySizeCheck=-1,this._posSlotDecoder[0]=new ae.BitTreeDecoder(6),this._posSlotDecoder[1]=new ae.BitTreeDecoder(6),this._posSlotDecoder[2]=new ae.BitTreeDecoder(6),this._posSlotDecoder[3]=new ae.BitTreeDecoder(6)},ae.Decoder.prototype.setDictionarySize=function(t){return!(t<0)&&(this._dictionarySize!==t&&(this._dictionarySize=t,this._dictionarySizeCheck=Math.max(this._dictionarySize,1),this._outWindow.create(Math.max(this._dictionarySizeCheck,4096))),!0)},ae.Decoder.prototype.setLcLpPb=function(t,e,r){var n=1<<r;return!(t>8||e>4||r>4)&&(this._literalDecoder.create(e,t),this._lenDecoder.create(n),this._repLenDecoder.create(n),this._posStateMask=n-1,!0)},ae.Decoder.prototype.init=function(){var t=4;for(this._outWindow.init(!1),ae.initBitModels(this._isMatchDecoders,192),ae.initBitModels(this._isRep0LongDecoders,192),ae.initBitModels(this._isRepDecoders,12),ae.initBitModels(this._isRepG0Decoders,12),ae.initBitModels(this._isRepG1Decoders,12),ae.initBitModels(this._isRepG2Decoders,12),ae.initBitModels(this._posDecoders,114),this._literalDecoder.init();t--;)this._posSlotDecoder[t].init();this._lenDecoder.init(),this._repLenDecoder.init(),this._posAlignDecoder.init(),this._rangeDecoder.init()},ae.Decoder.prototype.decode=function(t,e,r){var n,i,s,o,a,u,h=0,c=0,l=0,f=0,d=0,p=0,g=0;for(this._rangeDecoder.setStream(t),this._outWindow.setStream(e),this.init();r<0||p<r;)if(n=p&this._posStateMask,0===this._rangeDecoder.decodeBit(this._isMatchDecoders,(h<<4)+n))i=this._literalDecoder.getDecoder(p++,g),g=h>=7?i.decodeWithMatchByte(this._rangeDecoder,this._outWindow.getByte(c)):i.decodeNormal(this._rangeDecoder),this._outWindow.putByte(g),h=h<4?0:h-(h<10?3:6);else{if(1===this._rangeDecoder.decodeBit(this._isRepDecoders,h))s=0,0===this._rangeDecoder.decodeBit(this._isRepG0Decoders,h)?0===this._rangeDecoder.decodeBit(this._isRep0LongDecoders,(h<<4)+n)&&(h=h<7?9:11,s=1):(0===this._rangeDecoder.decodeBit(this._isRepG1Decoders,h)?o=l:(0===this._rangeDecoder.decodeBit(this._isRepG2Decoders,h)?o=f:(o=d,d=f),f=l),l=c,c=o),0===s&&(s=2+this._repLenDecoder.decode(this._rangeDecoder,n),h=h<7?8:11);else if(d=f,f=l,l=c,s=2+this._lenDecoder.decode(this._rangeDecoder,n),h=h<7?7:10,(a=this._posSlotDecoder[s<=5?s-2:3].decode(this._rangeDecoder))>=4){if(c=(2|1&a)<<(u=(a>>1)-1),a<14)c+=ae.reverseDecode2(this._posDecoders,c-a-1,this._rangeDecoder,u);else if(c+=this._rangeDecoder.decodeDirectBits(u-4)<<4,(c+=this._posAlignDecoder.reverseDecode(this._rangeDecoder))<0){if(-1===c)break;return!1}}else c=a;if(c>=p||c>=this._dictionarySizeCheck)return!1;this._outWindow.copyBlock(c,s),p+=s,g=this._outWindow.getByte(0)}return this._outWindow.flush(),this._outWindow.releaseStream(),this._rangeDecoder.releaseStream(),!0},ae.Decoder.prototype.setDecoderProperties=function(t){var e,r,n,i,s;return!(t.size<5)&&(r=(e=t.readByte())%9,n=(e=~~(e/9))%5,i=~~(e/5),!!this.setLcLpPb(r,n,i)&&(s=t.readByte(),s|=t.readByte()<<8,s|=t.readByte()<<16,s+=16777216*t.readByte(),this.setDictionarySize(s)))},ae.decompress=function(t,e,r,n){var i=new ae.Decoder;if(!i.setDecoderProperties(t))throw"Incorrect stream properties";if(!i.decode(e,r,n))throw"Error in data stream";return!0},ae.decompressFile=function(t,e){var r,n=new ae.Decoder;if(!n.setDecoderProperties(t))throw"Incorrect stream properties";if(r=t.readByte(),r|=t.readByte()<<8,r|=t.readByte()<<16,r+=16777216*t.readByte(),t.readByte(),t.readByte(),t.readByte(),t.readByte(),!n.decode(t,e,r))throw"Error in data stream";return!0};var ce=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.floorIndex=0,e.needsRender=!0,e}return e.__extends(r,t),r.prototype.disposeGeometry=function(){this.traverse((function(t){t instanceof Wt&&t.geometry.dispose()}))},r}(a.Group);const le=c.Reader,fe=c.Writer,de=c.util,pe=c.roots["@REALSEE/FIVE:2"]||(c.roots["@REALSEE/FIVE:2"]={}),ge=pe.Model=(()=>{function t(t){if(this.meshes=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.meshes=de.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=fe.create()),null!=t.meshes&&t.meshes.length)for(let r=0;r<t.meshes.length;++r)pe.Mesh.encode(t.meshes[r],e.uint32(10).fork()).ldelim();return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof le||(t=le.create(t));let r=void 0===e?t.len:t.pos+e,n=new pe.Model;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.meshes&&n.meshes.length||(n.meshes=[]),n.meshes.push(pe.Mesh.decode(t,t.uint32()));break;default:t.skipType(7&e)}}return n},t.decodeDelimited=function(t){return t instanceof le||(t=new le(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.meshes&&t.hasOwnProperty("meshes")){if(!Array.isArray(t.meshes))return"meshes: array expected";for(let e=0;e<t.meshes.length;++e){let r=pe.Mesh.verify(t.meshes[e]);if(r)return"meshes."+r}}return null},t.fromObject=function(t){if(t instanceof pe.Model)return t;let e=new pe.Model;if(t.meshes){if(!Array.isArray(t.meshes))throw TypeError(".Model.meshes: array expected");e.meshes=[];for(let r=0;r<t.meshes.length;++r){if("object"!=typeof t.meshes[r])throw TypeError(".Model.meshes: object expected");e.meshes[r]=pe.Mesh.fromObject(t.meshes[r])}}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.meshes=[]),t.meshes&&t.meshes.length){r.meshes=[];for(let n=0;n<t.meshes.length;++n)r.meshes[n]=pe.Mesh.toObject(t.meshes[n],e)}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})();pe.Mesh=(()=>{function t(t){if(this.chunks=[],this.matrix=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.name="",t.prototype.chunks=de.emptyArray,t.prototype.matrix=de.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=fe.create()),e.uint32(10).string(t.name),null!=t.chunks&&t.chunks.length)for(let r=0;r<t.chunks.length;++r)pe.Chunk.encode(t.chunks[r],e.uint32(18).fork()).ldelim();if(null!=t.matrix&&t.matrix.length)for(let r=0;r<t.matrix.length;++r)pe.Matrix.encode(t.matrix[r],e.uint32(26).fork()).ldelim();return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof le||(t=le.create(t));let r=void 0===e?t.len:t.pos+e,n=new pe.Mesh;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.name=t.string();break;case 2:n.chunks&&n.chunks.length||(n.chunks=[]),n.chunks.push(pe.Chunk.decode(t,t.uint32()));break;case 3:n.matrix&&n.matrix.length||(n.matrix=[]),n.matrix.push(pe.Matrix.decode(t,t.uint32()));break;default:t.skipType(7&e)}}if(!n.hasOwnProperty("name"))throw de.ProtocolError("missing required 'name'",{instance:n});return n},t.decodeDelimited=function(t){return t instanceof le||(t=new le(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(!de.isString(t.name))return"name: string expected";if(null!=t.chunks&&t.hasOwnProperty("chunks")){if(!Array.isArray(t.chunks))return"chunks: array expected";for(let e=0;e<t.chunks.length;++e){let r=pe.Chunk.verify(t.chunks[e]);if(r)return"chunks."+r}}if(null!=t.matrix&&t.hasOwnProperty("matrix")){if(!Array.isArray(t.matrix))return"matrix: array expected";for(let e=0;e<t.matrix.length;++e){let r=pe.Matrix.verify(t.matrix[e]);if(r)return"matrix."+r}}return null},t.fromObject=function(t){if(t instanceof pe.Mesh)return t;let e=new pe.Mesh;if(null!=t.name&&(e.name=String(t.name)),t.chunks){if(!Array.isArray(t.chunks))throw TypeError(".Mesh.chunks: array expected");e.chunks=[];for(let r=0;r<t.chunks.length;++r){if("object"!=typeof t.chunks[r])throw TypeError(".Mesh.chunks: object expected");e.chunks[r]=pe.Chunk.fromObject(t.chunks[r])}}if(t.matrix){if(!Array.isArray(t.matrix))throw TypeError(".Mesh.matrix: array expected");e.matrix=[];for(let r=0;r<t.matrix.length;++r){if("object"!=typeof t.matrix[r])throw TypeError(".Mesh.matrix: object expected");e.matrix[r]=pe.Matrix.fromObject(t.matrix[r])}}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.chunks=[],r.matrix=[]),e.defaults&&(r.name=""),null!=t.name&&t.hasOwnProperty("name")&&(r.name=t.name),t.chunks&&t.chunks.length){r.chunks=[];for(let n=0;n<t.chunks.length;++n)r.chunks[n]=pe.Chunk.toObject(t.chunks[n],e)}if(t.matrix&&t.matrix.length){r.matrix=[];for(let n=0;n<t.matrix.length;++n)r.matrix[n]=pe.Matrix.toObject(t.matrix[n],e)}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})(),pe.Matrix=(()=>{function t(t){if(this.elements=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.elements=de.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=fe.create()),null!=t.elements&&t.elements.length)for(let r=0;r<t.elements.length;++r)e.uint32(13).float(t.elements[r]);return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof le||(t=le.create(t));let r=void 0===e?t.len:t.pos+e,n=new pe.Matrix;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:if(n.elements&&n.elements.length||(n.elements=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.elements.push(t.float())}else n.elements.push(t.float());break;default:t.skipType(7&e)}}return n},t.decodeDelimited=function(t){return t instanceof le||(t=new le(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.elements&&t.hasOwnProperty("elements")){if(!Array.isArray(t.elements))return"elements: array expected";for(let e=0;e<t.elements.length;++e)if("number"!=typeof t.elements[e])return"elements: number[] expected"}return null},t.fromObject=function(t){if(t instanceof pe.Matrix)return t;let e=new pe.Matrix;if(t.elements){if(!Array.isArray(t.elements))throw TypeError(".Matrix.elements: array expected");e.elements=[];for(let r=0;r<t.elements.length;++r)e.elements[r]=Number(t.elements[r])}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.elements=[]),t.elements&&t.elements.length){r.elements=[];for(let n=0;n<t.elements.length;++n)r.elements[n]=e.json&&!isFinite(t.elements[n])?String(t.elements[n]):t.elements[n]}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})(),pe.Chunk=(()=>{function t(t){if(this.material=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.geometry=null,t.prototype.material=de.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=fe.create()),pe.Geometry.encode(t.geometry,e.uint32(18).fork()).ldelim(),null!=t.material&&t.material.length)for(let r=0;r<t.material.length;++r)pe.Material.encode(t.material[r],e.uint32(26).fork()).ldelim();return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof le||(t=le.create(t));let r=void 0===e?t.len:t.pos+e,n=new pe.Chunk;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 2:n.geometry=pe.Geometry.decode(t,t.uint32());break;case 3:n.material&&n.material.length||(n.material=[]),n.material.push(pe.Material.decode(t,t.uint32()));break;default:t.skipType(7&e)}}if(!n.hasOwnProperty("geometry"))throw de.ProtocolError("missing required 'geometry'",{instance:n});return n},t.decodeDelimited=function(t){return t instanceof le||(t=new le(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";{let e=pe.Geometry.verify(t.geometry);if(e)return"geometry."+e}if(null!=t.material&&t.hasOwnProperty("material")){if(!Array.isArray(t.material))return"material: array expected";for(let e=0;e<t.material.length;++e){let r=pe.Material.verify(t.material[e]);if(r)return"material."+r}}return null},t.fromObject=function(t){if(t instanceof pe.Chunk)return t;let e=new pe.Chunk;if(null!=t.geometry){if("object"!=typeof t.geometry)throw TypeError(".Chunk.geometry: object expected");e.geometry=pe.Geometry.fromObject(t.geometry)}if(t.material){if(!Array.isArray(t.material))throw TypeError(".Chunk.material: array expected");e.material=[];for(let r=0;r<t.material.length;++r){if("object"!=typeof t.material[r])throw TypeError(".Chunk.material: object expected");e.material[r]=pe.Material.fromObject(t.material[r])}}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.material=[]),e.defaults&&(r.geometry=null),null!=t.geometry&&t.hasOwnProperty("geometry")&&(r.geometry=pe.Geometry.toObject(t.geometry,e)),t.material&&t.material.length){r.material=[];for(let n=0;n<t.material.length;++n)r.material[n]=pe.Material.toObject(t.material[n],e)}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})(),pe.Geometry=(()=>{function t(t){if(this.groups=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.position=null,t.prototype.uv=null,t.prototype.uv2=null,t.prototype.normal=null,t.prototype.groups=de.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=fe.create()),pe.Position.encode(t.position,e.uint32(10).fork()).ldelim(),null!=t.uv&&Object.hasOwnProperty.call(t,"uv")&&pe.UV.encode(t.uv,e.uint32(18).fork()).ldelim(),null!=t.uv2&&Object.hasOwnProperty.call(t,"uv2")&&pe.UV.encode(t.uv2,e.uint32(26).fork()).ldelim(),pe.Normal.encode(t.normal,e.uint32(34).fork()).ldelim(),null!=t.groups&&t.groups.length)for(let r=0;r<t.groups.length;++r)pe.Group.encode(t.groups[r],e.uint32(42).fork()).ldelim();return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof le||(t=le.create(t));let r=void 0===e?t.len:t.pos+e,n=new pe.Geometry;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.position=pe.Position.decode(t,t.uint32());break;case 2:n.uv=pe.UV.decode(t,t.uint32());break;case 3:n.uv2=pe.UV.decode(t,t.uint32());break;case 4:n.normal=pe.Normal.decode(t,t.uint32());break;case 5:n.groups&&n.groups.length||(n.groups=[]),n.groups.push(pe.Group.decode(t,t.uint32()));break;default:t.skipType(7&e)}}if(!n.hasOwnProperty("position"))throw de.ProtocolError("missing required 'position'",{instance:n});if(!n.hasOwnProperty("normal"))throw de.ProtocolError("missing required 'normal'",{instance:n});return n},t.decodeDelimited=function(t){return t instanceof le||(t=new le(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";{let e=pe.Position.verify(t.position);if(e)return"position."+e}if(null!=t.uv&&t.hasOwnProperty("uv")){let e=pe.UV.verify(t.uv);if(e)return"uv."+e}if(null!=t.uv2&&t.hasOwnProperty("uv2")){let e=pe.UV.verify(t.uv2);if(e)return"uv2."+e}{let e=pe.Normal.verify(t.normal);if(e)return"normal."+e}if(null!=t.groups&&t.hasOwnProperty("groups")){if(!Array.isArray(t.groups))return"groups: array expected";for(let e=0;e<t.groups.length;++e){let r=pe.Group.verify(t.groups[e]);if(r)return"groups."+r}}return null},t.fromObject=function(t){if(t instanceof pe.Geometry)return t;let e=new pe.Geometry;if(null!=t.position){if("object"!=typeof t.position)throw TypeError(".Geometry.position: object expected");e.position=pe.Position.fromObject(t.position)}if(null!=t.uv){if("object"!=typeof t.uv)throw TypeError(".Geometry.uv: object expected");e.uv=pe.UV.fromObject(t.uv)}if(null!=t.uv2){if("object"!=typeof t.uv2)throw TypeError(".Geometry.uv2: object expected");e.uv2=pe.UV.fromObject(t.uv2)}if(null!=t.normal){if("object"!=typeof t.normal)throw TypeError(".Geometry.normal: object expected");e.normal=pe.Normal.fromObject(t.normal)}if(t.groups){if(!Array.isArray(t.groups))throw TypeError(".Geometry.groups: array expected");e.groups=[];for(let r=0;r<t.groups.length;++r){if("object"!=typeof t.groups[r])throw TypeError(".Geometry.groups: object expected");e.groups[r]=pe.Group.fromObject(t.groups[r])}}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.groups=[]),e.defaults&&(r.position=null,r.uv=null,r.uv2=null,r.normal=null),null!=t.position&&t.hasOwnProperty("position")&&(r.position=pe.Position.toObject(t.position,e)),null!=t.uv&&t.hasOwnProperty("uv")&&(r.uv=pe.UV.toObject(t.uv,e)),null!=t.uv2&&t.hasOwnProperty("uv2")&&(r.uv2=pe.UV.toObject(t.uv2,e)),null!=t.normal&&t.hasOwnProperty("normal")&&(r.normal=pe.Normal.toObject(t.normal,e)),t.groups&&t.groups.length){r.groups=[];for(let n=0;n<t.groups.length;++n)r.groups[n]=pe.Group.toObject(t.groups[n],e)}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})(),pe.Position=(()=>{function t(t){if(this.array=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.array=de.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=fe.create()),null!=t.array&&t.array.length){e.uint32(10).fork();for(let r=0;r<t.array.length;++r)e.float(t.array[r]);e.ldelim()}return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof le||(t=le.create(t));let r=void 0===e?t.len:t.pos+e,n=new pe.Position;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:if(n.array&&n.array.length||(n.array=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.array.push(t.float())}else n.array.push(t.float());break;default:t.skipType(7&e)}}return n},t.decodeDelimited=function(t){return t instanceof le||(t=new le(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.array&&t.hasOwnProperty("array")){if(!Array.isArray(t.array))return"array: array expected";for(let e=0;e<t.array.length;++e)if("number"!=typeof t.array[e])return"array: number[] expected"}return null},t.fromObject=function(t){if(t instanceof pe.Position)return t;let e=new pe.Position;if(t.array){if(!Array.isArray(t.array))throw TypeError(".Position.array: array expected");e.array=[];for(let r=0;r<t.array.length;++r)e.array[r]=Number(t.array[r])}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.array=[]),t.array&&t.array.length){r.array=[];for(let n=0;n<t.array.length;++n)r.array[n]=e.json&&!isFinite(t.array[n])?String(t.array[n]):t.array[n]}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})(),pe.UV=(()=>{function t(t){if(this.array=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.array=de.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=fe.create()),null!=t.array&&t.array.length){e.uint32(10).fork();for(let r=0;r<t.array.length;++r)e.float(t.array[r]);e.ldelim()}return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof le||(t=le.create(t));let r=void 0===e?t.len:t.pos+e,n=new pe.UV;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:if(n.array&&n.array.length||(n.array=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.array.push(t.float())}else n.array.push(t.float());break;default:t.skipType(7&e)}}return n},t.decodeDelimited=function(t){return t instanceof le||(t=new le(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.array&&t.hasOwnProperty("array")){if(!Array.isArray(t.array))return"array: array expected";for(let e=0;e<t.array.length;++e)if("number"!=typeof t.array[e])return"array: number[] expected"}return null},t.fromObject=function(t){if(t instanceof pe.UV)return t;let e=new pe.UV;if(t.array){if(!Array.isArray(t.array))throw TypeError(".UV.array: array expected");e.array=[];for(let r=0;r<t.array.length;++r)e.array[r]=Number(t.array[r])}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.array=[]),t.array&&t.array.length){r.array=[];for(let n=0;n<t.array.length;++n)r.array[n]=e.json&&!isFinite(t.array[n])?String(t.array[n]):t.array[n]}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})(),pe.Normal=(()=>{function t(t){if(this.array=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.array=de.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=fe.create()),null!=t.array&&t.array.length){e.uint32(10).fork();for(let r=0;r<t.array.length;++r)e.float(t.array[r]);e.ldelim()}return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof le||(t=le.create(t));let r=void 0===e?t.len:t.pos+e,n=new pe.Normal;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:if(n.array&&n.array.length||(n.array=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.array.push(t.float())}else n.array.push(t.float());break;default:t.skipType(7&e)}}return n},t.decodeDelimited=function(t){return t instanceof le||(t=new le(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.array&&t.hasOwnProperty("array")){if(!Array.isArray(t.array))return"array: array expected";for(let e=0;e<t.array.length;++e)if("number"!=typeof t.array[e])return"array: number[] expected"}return null},t.fromObject=function(t){if(t instanceof pe.Normal)return t;let e=new pe.Normal;if(t.array){if(!Array.isArray(t.array))throw TypeError(".Normal.array: array expected");e.array=[];for(let r=0;r<t.array.length;++r)e.array[r]=Number(t.array[r])}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.array=[]),t.array&&t.array.length){r.array=[];for(let n=0;n<t.array.length;++n)r.array[n]=e.json&&!isFinite(t.array[n])?String(t.array[n]):t.array[n]}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})(),pe.Group=(()=>{function t(t){if(t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.start=0,t.prototype.count=0,t.prototype.materialIndex=0,t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=fe.create()),e.uint32(8).uint32(t.start),e.uint32(16).uint32(t.count),e.uint32(24).uint32(t.materialIndex),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof le||(t=le.create(t));let r=void 0===e?t.len:t.pos+e,n=new pe.Group;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.start=t.uint32();break;case 2:n.count=t.uint32();break;case 3:n.materialIndex=t.uint32();break;default:t.skipType(7&e)}}if(!n.hasOwnProperty("start"))throw de.ProtocolError("missing required 'start'",{instance:n});if(!n.hasOwnProperty("count"))throw de.ProtocolError("missing required 'count'",{instance:n});if(!n.hasOwnProperty("materialIndex"))throw de.ProtocolError("missing required 'materialIndex'",{instance:n});return n},t.decodeDelimited=function(t){return t instanceof le||(t=new le(t)),this.decode(t,t.uint32())},t.verify=function(t){return"object"!=typeof t||null===t?"object expected":de.isInteger(t.start)?de.isInteger(t.count)?de.isInteger(t.materialIndex)?null:"materialIndex: integer expected":"count: integer expected":"start: integer expected"},t.fromObject=function(t){if(t instanceof pe.Group)return t;let e=new pe.Group;return null!=t.start&&(e.start=t.start>>>0),null!=t.count&&(e.count=t.count>>>0),null!=t.materialIndex&&(e.materialIndex=t.materialIndex>>>0),e},t.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(r.start=0,r.count=0,r.materialIndex=0),null!=t.start&&t.hasOwnProperty("start")&&(r.start=t.start),null!=t.count&&t.hasOwnProperty("count")&&(r.count=t.count),null!=t.materialIndex&&t.hasOwnProperty("materialIndex")&&(r.materialIndex=t.materialIndex),r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})(),pe.Material=(()=>{function t(t){if(t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.kd=null,t.prototype.ks=null,t.prototype.ke=null,t.prototype.mapkd="",t.prototype.mapks="",t.prototype.mapke="",t.prototype.norm="",t.prototype.mapbump="",t.prototype.bump="",t.prototype.mapd="",t.prototype.ns=0,t.prototype.d=0,t.prototype.tr=0,t.prototype.mapkdrepeat="",t.create=function(e){return new t(e)},t.encode=function(t,e){return e||(e=fe.create()),null!=t.kd&&Object.hasOwnProperty.call(t,"kd")&&pe.Color.encode(t.kd,e.uint32(10).fork()).ldelim(),null!=t.ks&&Object.hasOwnProperty.call(t,"ks")&&pe.Color.encode(t.ks,e.uint32(18).fork()).ldelim(),null!=t.ke&&Object.hasOwnProperty.call(t,"ke")&&pe.Color.encode(t.ke,e.uint32(26).fork()).ldelim(),null!=t.mapkd&&Object.hasOwnProperty.call(t,"mapkd")&&e.uint32(34).string(t.mapkd),null!=t.mapks&&Object.hasOwnProperty.call(t,"mapks")&&e.uint32(42).string(t.mapks),null!=t.mapke&&Object.hasOwnProperty.call(t,"mapke")&&e.uint32(50).string(t.mapke),null!=t.norm&&Object.hasOwnProperty.call(t,"norm")&&e.uint32(58).string(t.norm),null!=t.mapbump&&Object.hasOwnProperty.call(t,"mapbump")&&e.uint32(66).string(t.mapbump),null!=t.bump&&Object.hasOwnProperty.call(t,"bump")&&e.uint32(74).string(t.bump),null!=t.mapd&&Object.hasOwnProperty.call(t,"mapd")&&e.uint32(82).string(t.mapd),null!=t.ns&&Object.hasOwnProperty.call(t,"ns")&&e.uint32(93).float(t.ns),null!=t.d&&Object.hasOwnProperty.call(t,"d")&&e.uint32(101).float(t.d),null!=t.tr&&Object.hasOwnProperty.call(t,"tr")&&e.uint32(109).float(t.tr),null!=t.mapkdrepeat&&Object.hasOwnProperty.call(t,"mapkdrepeat")&&e.uint32(114).string(t.mapkdrepeat),e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof le||(t=le.create(t));let r=void 0===e?t.len:t.pos+e,n=new pe.Material;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:n.kd=pe.Color.decode(t,t.uint32());break;case 2:n.ks=pe.Color.decode(t,t.uint32());break;case 3:n.ke=pe.Color.decode(t,t.uint32());break;case 4:n.mapkd=t.string();break;case 5:n.mapks=t.string();break;case 6:n.mapke=t.string();break;case 7:n.norm=t.string();break;case 8:n.mapbump=t.string();break;case 9:n.bump=t.string();break;case 10:n.mapd=t.string();break;case 11:n.ns=t.float();break;case 12:n.d=t.float();break;case 13:n.tr=t.float();break;case 14:n.mapkdrepeat=t.string();break;default:t.skipType(7&e)}}return n},t.decodeDelimited=function(t){return t instanceof le||(t=new le(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.kd&&t.hasOwnProperty("kd")){let e=pe.Color.verify(t.kd);if(e)return"kd."+e}if(null!=t.ks&&t.hasOwnProperty("ks")){let e=pe.Color.verify(t.ks);if(e)return"ks."+e}if(null!=t.ke&&t.hasOwnProperty("ke")){let e=pe.Color.verify(t.ke);if(e)return"ke."+e}return null!=t.mapkd&&t.hasOwnProperty("mapkd")&&!de.isString(t.mapkd)?"mapkd: string expected":null!=t.mapks&&t.hasOwnProperty("mapks")&&!de.isString(t.mapks)?"mapks: string expected":null!=t.mapke&&t.hasOwnProperty("mapke")&&!de.isString(t.mapke)?"mapke: string expected":null!=t.norm&&t.hasOwnProperty("norm")&&!de.isString(t.norm)?"norm: string expected":null!=t.mapbump&&t.hasOwnProperty("mapbump")&&!de.isString(t.mapbump)?"mapbump: string expected":null!=t.bump&&t.hasOwnProperty("bump")&&!de.isString(t.bump)?"bump: string expected":null!=t.mapd&&t.hasOwnProperty("mapd")&&!de.isString(t.mapd)?"mapd: string expected":null!=t.ns&&t.hasOwnProperty("ns")&&"number"!=typeof t.ns?"ns: number expected":null!=t.d&&t.hasOwnProperty("d")&&"number"!=typeof t.d?"d: number expected":null!=t.tr&&t.hasOwnProperty("tr")&&"number"!=typeof t.tr?"tr: number expected":null!=t.mapkdrepeat&&t.hasOwnProperty("mapkdrepeat")&&!de.isString(t.mapkdrepeat)?"mapkdrepeat: string expected":null},t.fromObject=function(t){if(t instanceof pe.Material)return t;let e=new pe.Material;if(null!=t.kd){if("object"!=typeof t.kd)throw TypeError(".Material.kd: object expected");e.kd=pe.Color.fromObject(t.kd)}if(null!=t.ks){if("object"!=typeof t.ks)throw TypeError(".Material.ks: object expected");e.ks=pe.Color.fromObject(t.ks)}if(null!=t.ke){if("object"!=typeof t.ke)throw TypeError(".Material.ke: object expected");e.ke=pe.Color.fromObject(t.ke)}return null!=t.mapkd&&(e.mapkd=String(t.mapkd)),null!=t.mapks&&(e.mapks=String(t.mapks)),null!=t.mapke&&(e.mapke=String(t.mapke)),null!=t.norm&&(e.norm=String(t.norm)),null!=t.mapbump&&(e.mapbump=String(t.mapbump)),null!=t.bump&&(e.bump=String(t.bump)),null!=t.mapd&&(e.mapd=String(t.mapd)),null!=t.ns&&(e.ns=Number(t.ns)),null!=t.d&&(e.d=Number(t.d)),null!=t.tr&&(e.tr=Number(t.tr)),null!=t.mapkdrepeat&&(e.mapkdrepeat=String(t.mapkdrepeat)),e},t.toObject=function(t,e){e||(e={});let r={};return e.defaults&&(r.kd=null,r.ks=null,r.ke=null,r.mapkd="",r.mapks="",r.mapke="",r.norm="",r.mapbump="",r.bump="",r.mapd="",r.ns=0,r.d=0,r.tr=0,r.mapkdrepeat=""),null!=t.kd&&t.hasOwnProperty("kd")&&(r.kd=pe.Color.toObject(t.kd,e)),null!=t.ks&&t.hasOwnProperty("ks")&&(r.ks=pe.Color.toObject(t.ks,e)),null!=t.ke&&t.hasOwnProperty("ke")&&(r.ke=pe.Color.toObject(t.ke,e)),null!=t.mapkd&&t.hasOwnProperty("mapkd")&&(r.mapkd=t.mapkd),null!=t.mapks&&t.hasOwnProperty("mapks")&&(r.mapks=t.mapks),null!=t.mapke&&t.hasOwnProperty("mapke")&&(r.mapke=t.mapke),null!=t.norm&&t.hasOwnProperty("norm")&&(r.norm=t.norm),null!=t.mapbump&&t.hasOwnProperty("mapbump")&&(r.mapbump=t.mapbump),null!=t.bump&&t.hasOwnProperty("bump")&&(r.bump=t.bump),null!=t.mapd&&t.hasOwnProperty("mapd")&&(r.mapd=t.mapd),null!=t.ns&&t.hasOwnProperty("ns")&&(r.ns=e.json&&!isFinite(t.ns)?String(t.ns):t.ns),null!=t.d&&t.hasOwnProperty("d")&&(r.d=e.json&&!isFinite(t.d)?String(t.d):t.d),null!=t.tr&&t.hasOwnProperty("tr")&&(r.tr=e.json&&!isFinite(t.tr)?String(t.tr):t.tr),null!=t.mapkdrepeat&&t.hasOwnProperty("mapkdrepeat")&&(r.mapkdrepeat=t.mapkdrepeat),r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})(),pe.Color=(()=>{function t(t){if(this.rgb=[],t)for(let e=Object.keys(t),r=0;r<e.length;++r)null!=t[e[r]]&&(this[e[r]]=t[e[r]])}return t.prototype.rgb=de.emptyArray,t.create=function(e){return new t(e)},t.encode=function(t,e){if(e||(e=fe.create()),null!=t.rgb&&t.rgb.length)for(let r=0;r<t.rgb.length;++r)e.uint32(13).float(t.rgb[r]);return e},t.encodeDelimited=function(t,e){return this.encode(t,e).ldelim()},t.decode=function(t,e){t instanceof le||(t=le.create(t));let r=void 0===e?t.len:t.pos+e,n=new pe.Color;for(;t.pos<r;){let e=t.uint32();switch(e>>>3){case 1:if(n.rgb&&n.rgb.length||(n.rgb=[]),2==(7&e)){let e=t.uint32()+t.pos;for(;t.pos<e;)n.rgb.push(t.float())}else n.rgb.push(t.float());break;default:t.skipType(7&e)}}return n},t.decodeDelimited=function(t){return t instanceof le||(t=new le(t)),this.decode(t,t.uint32())},t.verify=function(t){if("object"!=typeof t||null===t)return"object expected";if(null!=t.rgb&&t.hasOwnProperty("rgb")){if(!Array.isArray(t.rgb))return"rgb: array expected";for(let e=0;e<t.rgb.length;++e)if("number"!=typeof t.rgb[e])return"rgb: number[] expected"}return null},t.fromObject=function(t){if(t instanceof pe.Color)return t;let e=new pe.Color;if(t.rgb){if(!Array.isArray(t.rgb))throw TypeError(".Color.rgb: array expected");e.rgb=[];for(let r=0;r<t.rgb.length;++r)e.rgb[r]=Number(t.rgb[r])}return e},t.toObject=function(t,e){e||(e={});let r={};if((e.arrays||e.defaults)&&(r.rgb=[]),t.rgb&&t.rgb.length){r.rgb=[];for(let n=0;n<t.rgb.length;++n)r.rgb[n]=e.json&&!isFinite(t.rgb[n])?String(t.rgb[n]):t.rgb[n]}return r},t.prototype.toJSON=function(){return this.constructor.toObject(this,c.util.toJSONOptions)},t})();var ye={};function me(t){var e,r=[];function n(t,e,r){var n=function(t){var e=t.position,r=t.normal,n=t.uv,i=t.uv2,s=t.groups,o=new a.BufferGeometry;return o.setAttribute("position",new a.BufferAttribute(new Float32Array(e.array),3)),r&&o.setAttribute("normal",new a.BufferAttribute(new Float32Array(r.array),3)),n&&o.setAttribute("uv",new a.BufferAttribute(new Float32Array(n.array),2)),i&&o.setAttribute("uv2",new a.BufferAttribute(new Float32Array(i.array),2)),s.forEach((function(t){return o.addGroup(t.start,t.count,t.materialIndex)})),o}(t);n.applyMatrix4(r);var i=new a.Vector3,s=new a.Quaternion,o=new a.Vector3;return r.decompose(i,s,o),o.x*o.y*o.z<0&&n.attributes.normal&&n.attributes.position&&n.attributes.uv&&function(t){for(var e=[0,0,0],r=0;r<t.attributes.normal.array.length/9;r++)e[0]=t.attributes.normal.array[9*r],e[1]=t.attributes.normal.array[9*r+1],e[2]=t.attributes.normal.array[9*r+2],t.attributes.normal.array[9*r]=t.attributes.normal.array[9*r+6],t.attributes.normal.array[9*r+1]=t.attributes.normal.array[9*r+7],t.attributes.normal.array[9*r+2]=t.attributes.normal.array[9*r+8],t.attributes.normal.array[9*r+6]=e[0],t.attributes.normal.array[9*r+7]=e[1],t.attributes.normal.array[9*r+8]=e[2];for(r=0;r<t.attributes.position.array.length/9;r++)e[0]=t.attributes.position.array[9*r],e[1]=t.attributes.position.array[9*r+1],e[2]=t.attributes.position.array[9*r+2],t.attributes.position.array[9*r]=t.attributes.position.array[9*r+6],t.attributes.position.array[9*r+1]=t.attributes.position.array[9*r+7],t.attributes.position.array[9*r+2]=t.attributes.position.array[9*r+8],t.attributes.position.array[9*r+6]=e[0],t.attributes.position.array[9*r+7]=e[1],t.attributes.position.array[9*r+8]=e[2];for(r=0;r<t.attributes.uv.array.length/6;r++)e[0]=t.attributes.uv.array[6*r],e[1]=t.attributes.uv.array[6*r+1],t.attributes.uv.array[6*r]=t.attributes.uv.array[6*r+4],t.attributes.uv.array[6*r+1]=t.attributes.uv.array[6*r+5],t.attributes.uv.array[6*r+4]=e[0],t.attributes.uv.array[6*r+5]=e[1];t.attributes.normal.needsUpdate=!0,t.attributes.position.needsUpdate=!0,t.attributes.uv.needsUpdate=!0}(n),new Wt(n)}return(e=t,ge.decode(e).meshes).forEach((function(t){var e=t.name,i=t.chunks,s=t.matrix;"Ceiling"!==e&&"CeilingDrop"!==e&&s.map((function(t){var s,o=new a.Matrix4;if(o.elements=t.elements,1===i.length){var u=i[0],h=u.geometry;u.material;s=n(h,0,o)}else s=new ce,i.forEach((function(t,e){var r=t.geometry,i=(t.material,n(r,0,o));i.name="chunk"+e,s.add(i)}));s.floorIndex=0,s.name=e,r.push(s)}))})),{objects:r}}function ve(){Object.keys(ye).forEach((function(t){ye[t].dispose(),delete ye[t]}))}var xe,be=(xe="$$FIVE_EVENT$$","undefined"==typeof Symbol?"$Symbol<".concat(xe,">$"):Symbol(xe));function we(t){return t[be]||(t[be]={}),t[be]}var Se=function(){function t(){}return t.prototype.hasListener=function(t){var e=we(this);return e&&e[t]&&e[t].length>0},t.prototype.on=function(t,e,r){var n=this,i=we(this);return i[t]||(i[t]=[]),i[t].push([e,r||!1]),function(){return n.off(t,e)}},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.off=function(t,e){if(void 0!==t){var r,n=we(this);if(n[t]||(n[t]=[]),void 0!==e){for(var i=0;i<n[t].length&&n[t][i][0]!==e;i++);i<n[t].length&&n[t].splice(i,1)}else n[t].length=0}else(r=this)[be]||delete r[be]},t.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];for(var n=!1,i=we(this),s=i[t]||[],o=0,a=s.slice();o<a.length;o++){var u=a[o],h=u[0],c=u[1],l=void 0!==c&&c,f=h.apply(void 0,e);l&&this.off(t,h),!1===f&&(n=!0)}return n},t}();function Ee(t){var r;return new((r=a.Triangle).bind.apply(r,e.__spreadArray([void 0],t.map((function(t){return new a.Vector3(t.x,t.y,t.z)})),!1)))}var Ae={at3d:function(t){return Promise.resolve().then((function(){return Xt(t.file)})).then((function(t){return he(t)})).then((function(t){for(var e=[],r=0,n=t;r<n.length;r++){var i=n[r],s=re.decode(i);e.push.apply(e,s.chunks)}return e})).then((function(t){return oe(t)}))},pbm:function(t){return Promise.resolve().then((function(){return Xt(t.file)})).then((function(t){var e=new Uint8Array(t),r=re.decode(e);return[].concat(r.chunks)})).then((function(t){return oe(t)}))},dome:function(t){return Promise.resolve().then((function(){return ve()})).then((function(){return Xt(t.file)})).then((function(t){return me(new Uint8Array(t))}))},domez:function(t){return Promise.resolve().then((function(){return ve()})).then((function(){return Xt(t.file)})).then((function(t){return he(t)})).then((function(t){var e=t.reduce((function(t,e){return t+e.length}),0),r=new Uint8Array(e),n=0;return t.forEach((function(t){r.set(t,n),n+=t.length})),r})).then((function(t){return me(t)}))}},Pe=function(t){function r(){var e=t.call(this)||this;return e.empty=!1,e.name="model",e.loaded=!1,e.bvhs=[],e.bounding=new a.Box3,e.shownfloor=null,e}return e.__extends(r,t),r.prototype.getEdges=function(t){var e;void 0===t&&(t=30/180*Math.PI);for(var r=Math.cos(t),n=[],i=0,s=this.children;i<s.length;i++){var o=s[i];if(o instanceof Wt){for(var u={},h=["a","b","c"],c=Yt.mergeVertices(o.geometry),l=c.getAttribute("position").array,f=(null===(e=c.getIndex())||void 0===e?void 0:e.array)||[],d=[],p=[],g=0,y=l.length;g<y;g+=3)d.push(new a.Vector3(l[g],l[g+1],l[g+2]));for(g=0,y=f.length;g<y;g+=3){var m=f[g],v=f[g+1],x=f[g+2],b=(new a.Vector3).crossVectors(d[v].clone().sub(d[m]),d[x].clone().sub(d[m])).normalize();p.push({a:m,b:v,c:x,normal:b})}for(g=0,y=p.length;g<y;g++)for(var w=p[g],S=0;S<3;S++){var E=w[h[S]],A=w[h[(S+1)%3]],P=[Math.min(E,A),Math.max(E,A)];void 0===u[D=P[0]+"-"+P[1]]?u[D]={index1:P[0],index2:P[1],face1:g}:u[D].face2=g}for(var D in u){var N=u[D];if(void 0===N.face2||p[N.face1].normal.dot(p[N.face2].normal)<=r){var O=d[N.index1],T=d[N.index2];n.push(new a.Line3(O,T))}}c.dispose(),d.length=0,p.length=0}}return n},r.prototype.hasFloors=function(){var t=[];return this.traverse((function(e){e instanceof Wt&&(t[e.floorIndex]=!0)})),t.length},r.prototype.show=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=0!==t.length;this.shownfloor=r?t[0]:null,this.needsRender=!0},r.prototype.intersectRaycaster=function(t,e){var r=t.ray,n=r.origin,i=r.direction;if(Zt(e))if(Zt(this.shownfloor)){var s=this.hasFloors();e=[];for(var o=0;o<s;o++)e.push(o)}else e=[this.shownfloor];var u=[],h=[];Array.isArray(e)?h.push.apply(h,e):h.push(e);for(var c=function(e){var r=l.bvhs&&l.bvhs[e];if(r){var s=new Ft(n.x,n.y,n.z),o=new Ft(i.x,i.y,i.z);(h=r.intersectRay(s,o,!0).map((function(t){var e=t.intersectionPoint,r=t.triangle,i=new a.Vector3(e.x,e.y,e.z);return{point:i,face:{normal:Ee(r).getNormal(new a.Vector3)},distance:n.distanceTo(i)}}))).length&&u.push.apply(u,h)}else{var h,c=[];l.traverse((function(t){t instanceof Wt&&t.floorIndex===e&&c.push(t)})),(h=t.intersectObjects(c).map((function(t){var e=t.face?{normal:t.face.normal}:void 0;return{point:t.point,face:e,distance:t.distance}}))).length&&u.push.apply(u,h)}},l=this,f=0,d=h;f<d.length;f++){c(d[f])}return u.filter((function(e){var r=e.distance;return r<=t.far&&r>=t.near})).sort((function(t,e){return t.distance-e.distance}))},r.prototype.buildBVH=function(){var t,e=[];this.traverse((function(t){t instanceof Wt&&(e[t.floorIndex]=e[t.floorIndex]||[],e[t.floorIndex].push(t.geometry))}));var r=e.map((function(t){var e=t.reduce((function(t,e){return t+(e.index?e.index.array.length:e.attributes.position.array.length)}),0),r=new Float32Array(3*e);return t.reduce((function(t,e){for(var n=e.index?e.index.array:null,i=e.attributes.position.array,s=n?n.length:i.length/3,o=0;o<s;o++){var a=3*(t+o),u=n?3*n[o]:3*o;r[a+0]=i[u+0],r[a+1]=i[u+1],r[a+2]=i[u+2]}return t+s}),0),new Qt(r,10)}));this.bvhs.length=0,(t=this.bvhs).push.apply(t,r),this.bvhs.loaded=!0,this.emit("bvhLoaded")},r.prototype.load=function(t){var e=this;if(!0===this.loaded)throw new Error("model 只能被 load 一次");var r=Ae[function(t,e){void 0===e&&(e=[]);var r=/([0-9a-z\.\_\-]+)([\?\#].*)?$/i.exec(t);if(r)for(var n=String(r[1]).trim().split("."),i=0,s=e;i<s.length;i++){var o=s[i];if(n.indexOf(o)>=0)return o}}(t.file,Object.keys(Ae))||""];if(!r)throw new Error("文件类型错误");return r(t).then((function(t){for(var r=t.objects,n=[],i=0,s=r;i<s.length;i++){var o=s[i];o.traverse((function(t){t instanceof Wt&&(t.geometry.computeBoundingBox(),t.geometry.computeBoundingSphere(),n.push(t.geometry.boundingBox))})),e.add(o)}e.emit("geometryLoaded"),n.length=0,e.emit("loaded"),e.loaded=!0})).catch((function(t){return e.emit("error",t),Promise.reject(t)}))},r.prototype.dispose=function(){for(this.off(),this.disposeGeometry();this.children.length;)this.remove(this.children[0]);this.bvhs.length=0,delete this.bvhs.loaded},r}(ce);Object.assign(Pe.prototype,{on:Se.prototype.on,once:Se.prototype.once,off:Se.prototype.off,emit:Se.prototype.emit,hasListener:Se.prototype.hasListener});var De=function(){function t(){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 t.prototype.toJSON=function(){return this.raw.work},t}();function Ne(t){return 0===t.indexOf("//")||/^[0-9a-z]+\:\/\//i.test(t)}function Oe(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=[];t=t.map((function(t){return t.trim()})).filter((function(t){return t.length>0&&!/^\/+$/.test(t)}));for(var n=0;n<t.length;n++){var i=0===n,s=n===t.length-1,o=t[n];i||(o=o.replace(/^\/+/,"")),s||(o=o.replace(/\/+$/,"")),r.push(o)}return r.join("/")}function Te(t){Object.freeze(t);var e="function"==typeof t,r=Object.prototype.hasOwnProperty;return Object.getOwnPropertyNames(t).forEach((function(n){!r.call(t,n)||e&&("caller"===n||"callee"===n||"arguments"===n)||null===t[n]||"object"!=typeof t[n]&&"function"!=typeof t[n]||Object.isFrozen(t[n])||Te(t[n])})),t}function Re(t){return t instanceof Error}function Ce(t,e){if(t===e)return!0;if(t&&e&&"object"==typeof t&&"object"==typeof e){if(t.constructor!==e.constructor)return!1;var r,n,i;if(Array.isArray(t)){if((r=t.length)!=e.length)return!1;for(n=r;0!=n--;)if(!Ce(t[n],e[n]))return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===e.toString();if((r=(i=Object.keys(t)).length)!==Object.keys(e).length)return!1;for(n=r;0!=n--;)if(!Object.prototype.hasOwnProperty.call(e,i[n]))return!1;for(n=r;0!=n--;){var s=i[n];if(!Ce(t[s],e[s]))return!1}return!0}return t!=t&&e!=e}function Ie(t){return"number"==typeof t}var ke=/^([^.]+)(\.([^.]+))*$/;function je(t,e){return ke.test(t)&&ke.test(e)&&function(t,e){if("*"===t)return!0;var r=t.split(".").reverse(),n=e.split(".").reverse();if(r.length<=1)return t===e;for(var i=0;i<r.length;i++)if(r[i]!==n[i])return!1;return!0}(t,e)}"undefined"!=typeof performance&&void 0!==performance.timing?performance.timing.navigationStart:Date.now();var _e=Te(JSON.parse(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=113,n=126,i=0,s="";return arguments[i].split(s).map((function(t){return t.charCodeAt(i)>n?t:String.fromCharCode((t.charCodeAt(i)+r)%n)})).join(s)}("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")));!function(t){function r(e,r,n){return t.call(this,"[NETWORK]: response error(type: ".concat(r,", reason: ").concat(n,"): ").concat(e))||this}e.__extends(r,t)}(Error),function(t){function r(e,r,n){var i=t.call(this,"[NETWORK]: response error(type: ".concat(r,", status: ").concat(n,"): ").concat(e))||this;return i.httpStatus=n,i}e.__extends(r,t)}(Error),function(t){function r(e,r){return t.call(this,"[NETWORK]: request abort(type: ".concat(r,"): ").concat(e))||this}e.__extends(r,t)}(Error),function(t){function r(e,r,n){return t.call(this,"[NETWORK]: request timeout(type: ".concat(r,", timeout: ").concat(n,"ms): ").concat(e))||this}e.__extends(r,t)}(Error),function(t){function r(e,r,n){return t.call(this,"[NETWORK]: request forbidden(type: ".concat(r,", reason: ").concat(n,"): ").concat(e))||this}e.__extends(r,t)}(Error),function(t){function r(){return null!==t&&t.apply(this,arguments)||this}e.__extends(r,t)}(Se);function Ve(t,e){void 0===e&&(e=!1);var r=typeof t;if("string"===r)return JSON.stringify(t);if(!0===t)return"true";if(!1===t)return"false";if(null===t)return"null";if(t instanceof Array){for(var n="[",i=t.length-1,s=0;s<i;s++)n+=Ve(t[s],!1)+",";return i>-1&&(n+=Ve(t[s],!1)),n+"]"}if(t instanceof Object){if("function"==typeof t.toJSON)return Ve(t.toJSON(),e);var o=Object.keys(t).sort(),a=o.length;for(n="",s=0;s<a;){var u=o[s],h=Ve(t[u],!0);void 0!==h&&(s&&""!==n&&(n+=","),n+=JSON.stringify(u)+":"+h),s++}return"{"+n+"}"}switch(r){case"function":case"undefined":return e?void 0:null;case"number":return 0;default:return isFinite(t)?t:null}}function Be(t){return String(Ve(t,!1))}function He(t){var e,r,n,i=JSON.parse(t),s="undefined"!=typeof location?location.hostname:"",o=Date.now();if("object"!=typeof i)return new Error("input is not an object");if(0===s.length||/^(([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])(\.(?!$)|$)){4}$/.test(s)||_e.filter((function(t){return je(t,s)})).length>0){var a=String(null!==(e=i.certificate)&&void 0!==e?e:"");if(a){var u=new kt;return u.readCertPEM(a),{issuer:u.getSubjectString()}}return{issuer:"none"}}var h=String(null!==(r=i.certificate)&&void 0!==r?r:"");if(!h)return new Error("certificate is not existed.");var c=new kt;c.readCertPEM(h);var l=String(null!==(n=i._signature)&&void 0!==n?n:"");if(!l)return new Error("signature is not existed.");if(!1===function(t,e,r){var n=new kt;if("string"==typeof r?n.readCertPEM(r):n.readCertHex(r.hex),!1===Ht(n))return!1;var i=new tt;return i.readCertPubKeyHex(n.hex,6),!!i.verify(t,K(e))}(Be(function(t,e){for(var r={},n=0,i=Object.keys(t);n<i.length;n++){var s=i[n];-1===e.indexOf(s)&&(r[s]=t[s])}return r}(i,["_signature"])),l,c))return new Error("signature verify failed.");var f=new Date("string"==typeof i.expire_at&&/^\d+$/.test(i.expire_at)?Number(i.expire_at):i.expire_at);return o<f.getTime()?0===(Array.isArray(i.allow_hosts)?i.allow_hosts:[]).filter((function(t){return je(t,s)})).length?function(t){return new Error("host(".concat(JSON.stringify(t),") is not allowed."))}(s):{issuer:c.getSubjectString()}:function(t){return new Error("date(".concat(t.toString(),") expired."))}(f)}var Me=new WeakMap;function Ke(t,e,r){var n,i=JSON.stringify(e),s=JSON.stringify(t),o=He(s);t=JSON.parse(s),e=JSON.parse(i);var u=new De;u.issuer=o instanceof Error?"none":o.issuer,u.raw={work:t,options:e};var h=null!==(n=t.base_url)&&void 0!==n?n:"";h&&"/"!==h[h.length-1]&&(h+="/");var c=function(t,e){return 0===t.indexOf(e)},l=function(t,n){var i,s=t;if(!0===e.jsonp){s=t.replace(/([\?\#].*)?$/i,"");var o=jt("".concat(s)).slice(0,7);s="".concat(s,".").concat(o,".jsonp")}if(!0===e.shortPath){var a=s.replace(h,"").split("."),u=null!==(i=a.shift())&&void 0!==i?i:"",c=a.join(".");s=Oe(h,jt(u))+(c?"."+c:"")}var l=s.replace(h,"");return e.baseURL&&(s=Oe(e.baseURL,l)),r&&r(t,s,l,n),s},f=function(e,r){var n,i,s,o,a,u,f=e;if(!Ne(e)){var d=null!==(u=null!==(o=null!==(i=null===(n=t.panorama)||void 0===n?void 0:n.pano_high_cube_base_url)&&void 0!==i?i:null===(s=t.panorama)||void 0===s?void 0:s.pano_cube_base_url)&&void 0!==o?o:null===(a=t.panorama)||void 0===a?void 0:a.base_url)&&void 0!==u?u:"";d&&(d=Oe(d,String(r))),f=Oe(d,f)}return Ne(f)||(f=Oe(h,f)),c(f,h)||console.warn("".concat(f," is not start with base_url(").concat(h,").")),l(f,"panorama")},d=function(t){var e=t;return Ne(e)||(e=Oe(h,t)),c(e,h)||console.warn("".concat(e," is not start with base_url(").concat(h,").")),l(e,"model")},p=function(t,e){void 0===e&&(e="");var r=t;return Ne(r)||(r=Oe(e,r)),Ne(r)||(r=Oe(h,r)),c(r,h)||console.warn("".concat(r," is not start with base_url(").concat(h,").")),l(r,"texture")};if(u.workCode=String(t.work_code||t.code||t.vr_code||t.workCode),u.name=String(t.name),u.expire=new Date("string"==typeof t.expire_at&&/^\d+$/.test(t.expire_at)?Number(t.expire_at):t.expire_at),u.allowHosts=t.allow_hosts||[],Re(o))return o;if(t.initial&&("Floorplan"!==t.initial.mode&&"Topview"!==t.initial.mode&&"Panorama"!==t.initial.mode&&"VRPanorama"!==t.initial.mode&&"Model"!==t.initial.mode&&"DepthPanorama"!==t.initial.mode||(u.initial.mode=t.initial.mode),Ie(t.initial.latitude)&&(u.initial.latitude=t.initial.latitude),Ie(t.initial.longitude)?u.initial.longitude=t.initial.longitude:Ie(t.initial.heading)&&(u.initial.longitude=-(360*(t.initial.heading-.25)+90)/180*Math.PI),Ie(t.initial.fov)&&(u.initial.fov=t.initial.fov),Ie(t.initial.panoIndex)?u.initial.panoIndex=t.initial.panoIndex:Ie(t.initial.pano_index)?u.initial.panoIndex=t.initial.pano_index:Ie(t.initial.pano)&&(u.initial.panoIndex=t.initial.pano)),Re(o))return o;if(t.model){var g={bvh:!0,async:!1,textureBase:"",textures:[]};"boolean"==typeof e.modelBvh?g.bvh=e.modelBvh:"boolean"==typeof t.model.bvh?g.bvh=t.model.bvh:"boolean"==typeof t.bvh&&(g.bvh=t.bvh),e.modelAsync,g.async=e.modelAsync,t.model.file?g.file=d(t.model.file):t.model.file_url&&(g.file=d(t.model.file_url)),t.model.textureBase?g.textureBase=t.model.textureBase:t.model.material_base_url&&(g.textureBase=t.model.material_base_url),Array.isArray(t.model.textures)?g.textures=t.model.textures.map((function(t){return p(t,g.textureBase)})):Array.isArray(t.model.material_textures)&&(g.textures=t.model.material_textures.map((function(t){return p(t,g.textureBase)}))),g.file&&(u.model=g)}if(Re(o))return o;if(t.observers&&Array.isArray(t.observers)){var y=[];t.panorama&&(Array.isArray(t.panorama)?y=t.panorama:Array.isArray(t.panorama.list)?y=t.panorama.list:Array.isArray(t.panorama.info)&&(y=t.panorama.info));for(var m=0;m<t.observers.length;m++){var v={},x=t.observers[m];if(!x)break;var b=y[m]||{};x=Object.assign({},x,b,{active:!1!==x.active&&!1!==b.active}),v.panoIndex=m,v.active=!1!==x.active,v.loadable=!0===x.loadable,v.images={up:f(x.images?x.images.up:x.up,m),down:f(x.images?x.images.down:x.down,m),right:f(x.images?x.images.right:x.right,m),left:f(x.images?x.images.left:x.left,m),front:f(x.images?x.images.front:x.front,m),back:f(x.images?x.images.back:x.back,m)};var w=x.images?x.images.depth:x.depth;w&&(v.images.depth=f(w,m));var S=x.images?x.images.luminance:x.luminance;S&&(v.images.luminance={up:f(S.up,m),down:f(S.down,m),right:f(S.right,m),left:f(S.left,m),front:f(S.front,m),back:f(S.back,m)});var E=x.images?x.images.tiles:x.tiles;if(E){for(var A=[],P=function(t){var e,r=t.match(/\/cube_(\d+)\//);if(r){var n=Number(r[1]);if(0==((e=n)&e-1)&&0!==e)return n}return!1},D=function(t,e){return t.replace(/\/cube_(\d+)\//,(function(){return"/cube_".concat(e,"/")}))},N=0,O=E;N<O.length;N++){var T=O[N];if("number"==typeof T){var R=T,C=P(v.images.front);if(!1===C)continue;if((H=Math.max(C,512*Math.pow(2,R)))>2048){var I=D(v.images.up,H),k=D(v.images.down,H),j=D(v.images.right,H),_=D(v.images.left,H),V=D(v.images.front,H),B=D(v.images.back,H);A.push({level:R,size:H,up:I,down:k,right:j,left:_,front:V,back:B})}else{I=v.images.up,k=v.images.down,j=v.images.right,_=v.images.left,V=v.images.front,B=v.images.back;A.push({level:R,size:H,up:I,down:k,right:j,left:_,front:V,back:B})}}else{var H;if("number"!=typeof(R=T.level))continue;if("number"!=typeof(H=T.size))continue;I=f(T.up,m),k=f(T.down,m),j=f(T.right,m),_=f(T.left,m),V=f(T.front,m),B=f(T.back,m);A.push({level:R,size:H,up:I,down:k,right:j,left:_,front:V,back:B})}}A.sort((function(t,e){return t.level-e.level})),v.images.tiles=A}if(x.position instanceof a.Vector3)v.position=x.position.clone();else{if(!Array.isArray(x.position))break;v.position=(new a.Vector3).fromArray(x.position)}if(x.standingPosition instanceof a.Vector3)v.standingPosition=x.standingPosition.clone();else if(Array.isArray(x.standingPosition))v.standingPosition=(new a.Vector3).fromArray(x.standingPosition);else if(x.standing_position instanceof a.Vector3)v.standingPosition=x.standing_position.clone();else{if(!Array.isArray(x.standing_position))break;v.standingPosition=(new a.Vector3).fromArray(x.standing_position)}if(x.quaternion instanceof a.Quaternion)v.quaternion=x.quaternion.clone();else if(Array.isArray(x.quaternion))v.quaternion=(new a.Quaternion).fromArray(x.quaternion);else{if(!x.quaternion)break;var M=x.quaternion,K=M.x,L=M.y,z=M.z,F=M.w;v.quaternion=new a.Quaternion(K,L,z,F)}if(Array.isArray(x.accessibleNodes)?v.accessibleNodes=x.accessibleNodes.slice():Array.isArray(x.accessible_nodes)&&(v.accessibleNodes=x.accessible_nodes.slice()),Array.isArray(x.visibleNodes)?v.visibleNodes=x.visibleNodes.slice():Array.isArray(x.visible_nodes)&&(v.visibleNodes=x.visible_nodes.slice()),Ie(x.floorIndex)?v.floorIndex=x.floorIndex:Ie(x.floor_index)?v.floorIndex=x.floor_index:v.floorIndex=0,x.video){var U={};"string"==typeof x.video.source&&(U.source=x.video.source),x.video.matrix instanceof a.Matrix4?U.matrix=x.video.matrix.clone():Array.isArray(x.video.matrix)&&(U.matrix=(new a.Matrix4).fromArray(x.video.matrix)),x.video.size instanceof a.Vector2?U.size=x.video.size.clone():Array.isArray(x.video.size)&&(U.size=(new a.Vector2).fromArray(x.video.size)),U.source&&U.matrix&&U.size&&(v.video=U)}u.observers[m]=v}}if(Re(o))return o;for(var q=0,G=u.observers;q<G.length;q++){if(!(v=G[q]).accessibleNodes){v.accessibleNodes=[];for(var Q=0;Q<u.observers.length;Q++)u.observers[Q]!==v&&v.accessibleNodes.push(Q)}if(!v.visibleNodes){v.visibleNodes=[];for(Q=0;Q<u.observers.length;Q++)u.observers[Q]!==v&&v.visibleNodes.push(Q)}}if(Re(o))return o;var Z=Te(u);return Me.set(Z,{work:s,options:i}),Z}exports.BVH=Qt,exports.BVHNode=Ut,exports.BVHVector3=Ft,exports.Model=Pe,exports.PBMGroup=ce,exports.PBMMesh=Wt,exports.Subscribe=Se,exports.parseWork=function(t,e,r){"string"==typeof t&&"{"===t.trim()[0]&&(t=JSON.parse(t));var n=Me.get(t);if(n){if(e&&!Ce(JSON.parse(n.options),e))throw new Error("[PARSE FAILED]: work is parsed with different options.");return t}var i=Ke(t,null!=e?e:{},r);if(Re(i))throw new Error("[PARSE FAILED]: "+i.message);return i};