graphdb-workbench 3.3.2-RC1 → 3.3.2-TR1

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 (174) hide show
  1. package/dist/13231.9b625e487e6385faa36f.bundle.js +2 -0
  2. package/dist/13231.9b625e487e6385faa36f.bundle.js.map +1 -0
  3. package/dist/21015.68c7c667ef64ad8e8e0d.bundle.js +2 -0
  4. package/dist/21015.68c7c667ef64ad8e8e0d.bundle.js.map +1 -0
  5. package/dist/{38644.b26373c67b397f88f3b4.bundle.js → 38644.37a8cd71112da94401d9.bundle.js} +2 -2
  6. package/dist/{38644.b26373c67b397f88f3b4.bundle.js.map → 38644.37a8cd71112da94401d9.bundle.js.map} +1 -1
  7. package/dist/{39518.e7e7353947905592bfea.bundle.js → 39518.2871b32c37b20075dba3.bundle.js} +2 -2
  8. package/dist/{39518.e7e7353947905592bfea.bundle.js.map → 39518.2871b32c37b20075dba3.bundle.js.map} +1 -1
  9. package/dist/39874.47a6948df3520a7bf37a.bundle.js +2 -0
  10. package/dist/39874.47a6948df3520a7bf37a.bundle.js.map +1 -0
  11. package/dist/60560.275a89ab1375e91de0aa.bundle.js +2 -0
  12. package/dist/60560.275a89ab1375e91de0aa.bundle.js.map +1 -0
  13. package/dist/{67888.367b7acbeaf58426d4f1.bundle.js → 67888.b75d9678cf65cd82f065.bundle.js} +2 -2
  14. package/dist/{67888.367b7acbeaf58426d4f1.bundle.js.map → 67888.b75d9678cf65cd82f065.bundle.js.map} +1 -1
  15. package/dist/7815.f09f8d6953d2c964e04d.bundle.js +2 -0
  16. package/dist/7815.f09f8d6953d2c964e04d.bundle.js.map +1 -0
  17. package/dist/78681.0cfa1e86d4dac1b7e7e8.bundle.js +2 -0
  18. package/dist/78681.0cfa1e86d4dac1b7e7e8.bundle.js.map +1 -0
  19. package/dist/{82926.4736d2184864699ddcdb.bundle.js → 82926.99231caacc379c66487a.bundle.js} +2 -2
  20. package/dist/{82926.4736d2184864699ddcdb.bundle.js.map → 82926.99231caacc379c66487a.bundle.js.map} +1 -1
  21. package/dist/94229.47dbdba202106c61dff1.bundle.js.map +1 -1
  22. package/dist/{99448.810956b817f8cf062851.bundle.js → 99448.272a4ba1ce8032167bea.bundle.js} +2 -2
  23. package/dist/{99448.810956b817f8cf062851.bundle.js.map → 99448.272a4ba1ce8032167bea.bundle.js.map} +1 -1
  24. package/dist/api/models/cookie/cookie-consent.d.ts +14 -0
  25. package/dist/api/models/cookie/index.d.ts +1 -1
  26. package/dist/api/models/security/authenticated-user.d.ts +0 -2
  27. package/dist/api/models/users/app-settings.d.ts +2 -2
  28. package/dist/api/ontotext-workbench-api.d.ts +1 -3
  29. package/dist/api/ontotext-workbench-api.js +1 -1
  30. package/dist/api/ontotext-workbench-api.js.map +1 -1
  31. package/dist/api/services/cookie/cookie.service.d.ts +7 -34
  32. package/dist/api/services/cookie/index.d.ts +0 -3
  33. package/dist/api/services/security/auth-strategies/tests/provider-response-mocks.d.ts +2 -2
  34. package/dist/api/services/security/security-context.service.d.ts +0 -6
  35. package/dist/api/services/users/response/user-response.d.ts +1 -1
  36. package/dist/api/services/utils/index.d.ts +0 -1
  37. package/dist/api/services/window/window.service.d.ts +0 -6
  38. package/dist/index.html +9 -9
  39. package/dist/js/angular/clustermanagement/templates/cluster-nodes-configuration.html +1 -1
  40. package/dist/js/angular/core/directives/autocomplete/templates/autocomplete.html +1 -1
  41. package/dist/js/angular/core/directives/dynamic-form/templates/dynamic-form.html +1 -1
  42. package/dist/js/angular/core/directives/operations-statuses-monitor/templates/operations-statuses-monitor.html +1 -1
  43. package/dist/js/angular/core/directives/rdfresourcesearch/templates/rdfResourceSearchTemplate.html +1 -1
  44. package/dist/js/angular/core/directives/shuttle-multiselect/templates/shuttle-multiselect.html +1 -1
  45. package/dist/js/angular/core/directives/yasgui-component/templates/yasgui-component.html +2 -2
  46. package/dist/js/angular/core/templates/cookie-policy/cookie-consent.html +1 -1
  47. package/dist/js/angular/core/templates/cookie-policy/cookie-policy.html +1 -1
  48. package/dist/js/angular/core/templates/editable-content/editable-content.html +1 -1
  49. package/dist/js/angular/core/templates/markdown-content/markdown-content.html +1 -1
  50. package/dist/js/angular/core/templates/search-resource-input.html +1 -1
  51. package/dist/js/angular/graphql/templates/create-graphql-endpoint.html +2 -2
  52. package/dist/js/angular/graphql/templates/graphql-endpoint-management.html +1 -1
  53. package/dist/js/angular/graphql/templates/graphql-playground.html +2 -2
  54. package/dist/js/angular/graphql/templates/modal/endpoint-configuration-modal.html +1 -1
  55. package/dist/js/angular/graphql/templates/modal/endpoint-generation-failure-result-modal.html +1 -1
  56. package/dist/js/angular/graphql/templates/modal/import-endpoint-definition-modal.html +1 -1
  57. package/dist/js/angular/security/templates/user.html +2 -5
  58. package/dist/js/angular/ttyg/templates/agent-list.html +1 -1
  59. package/dist/js/angular/ttyg/templates/agent-select-menu.html +1 -1
  60. package/dist/js/angular/ttyg/templates/chat-item-detail.html +1 -1
  61. package/dist/js/angular/ttyg/templates/chat-list.html +1 -1
  62. package/dist/js/angular/ttyg/templates/chat-panel.html +1 -1
  63. package/dist/js/angular/ttyg/templates/modal/agent-instructions-explain-modal.html +1 -1
  64. package/dist/js/angular/ttyg/templates/modal/agent-settings-modal.html +3 -3
  65. package/dist/js/angular/ttyg/templates/modal/external-integration-configuration-modal.html +1 -1
  66. package/dist/js/angular/ttyg/templates/no-agents-view.html +1 -1
  67. package/dist/js/angular/ttyg/templates/ttyg.html +1 -1
  68. package/dist/{legacyWorkbench.0128b90d53e9f14490a3.js → legacyWorkbench.88e1d4d209e51c6f9b65.js} +3 -3
  69. package/dist/{legacyWorkbench.0128b90d53e9f14490a3.js.map → legacyWorkbench.88e1d4d209e51c6f9b65.js.map} +1 -1
  70. package/dist/{main.44e04f2cf0ab7d48b25b.js → main.1be0fc11ab24b99f8800.js} +3 -3
  71. package/dist/main.1be0fc11ab24b99f8800.js.map +1 -0
  72. package/dist/pages/aclmanagement.html +1 -1
  73. package/dist/pages/autocomplete.html +1 -1
  74. package/dist/pages/choose-repository-type.html +1 -1
  75. package/dist/pages/cluster-management/clusterInfo.html +3 -3
  76. package/dist/pages/create-index.html +1 -1
  77. package/dist/pages/dependencies.html +1 -1
  78. package/dist/pages/domainRangeInfo.html +2 -2
  79. package/dist/pages/edit.html +1 -1
  80. package/dist/pages/explore.html +1 -1
  81. package/dist/pages/export.html +1 -1
  82. package/dist/pages/find.html +1 -1
  83. package/dist/pages/graph-config/saveGraphConfig.html +8 -8
  84. package/dist/pages/graphs-visualizations.html +7 -7
  85. package/dist/pages/guides.html +1 -1
  86. package/dist/pages/home.html +1 -1
  87. package/dist/pages/import.html +2 -2
  88. package/dist/pages/jdbc-create.html +1 -1
  89. package/dist/pages/jdbc.html +1 -1
  90. package/dist/pages/monitor/backup-and-restore.html +1 -1
  91. package/dist/pages/monitor/queries.html +1 -1
  92. package/dist/pages/monitor/resources.html +1 -1
  93. package/dist/pages/namespaces.html +2 -2
  94. package/dist/pages/plugins.html +1 -1
  95. package/dist/pages/rdfClassHierarchyInfo.html +7 -7
  96. package/dist/pages/rdfrank.html +2 -2
  97. package/dist/pages/repositories.html +1 -1
  98. package/dist/pages/repository.html +1 -1
  99. package/dist/pages/similarity-indexes.html +1 -1
  100. package/dist/pages/sparql-editor.html +1 -1
  101. package/dist/pages/sparql-template-create.html +1 -1
  102. package/dist/pages/sparql-templates.html +1 -1
  103. package/dist/pages/ux-test1.html +2 -2
  104. package/dist/pages/webapi.html +2 -2
  105. package/dist/res/swagger5/index.html +11 -11
  106. package/dist/shared-components/cjs/loader.cjs.js +1 -1
  107. package/dist/shared-components/cjs/onto-cookie-consent_2.cjs.entry.js +1 -1
  108. package/dist/shared-components/cjs/onto-dialog_2.cjs.entry.js +1 -1
  109. package/dist/shared-components/cjs/onto-footer_5.cjs.entry.js +1 -1
  110. package/dist/shared-components/cjs/onto-layout.cjs.entry.js +1 -1
  111. package/dist/shared-components/cjs/shared-components.cjs.js +1 -1
  112. package/dist/shared-components/collection/components/dialogs/onto-cookie-policy-dialog/onto-cookie-policy-dialog.js +1 -1
  113. package/dist/shared-components/collection/components/dialogs/onto-dialog.js +1 -1
  114. package/dist/shared-components/collection/components/onto-cookie-consent/onto-cookie-consent.css +1 -1
  115. package/dist/shared-components/collection/components/onto-cookie-consent/onto-cookie-consent.js +1 -1
  116. package/dist/shared-components/collection/components/onto-footer/onto-footer.js +1 -1
  117. package/dist/shared-components/collection/models/dialog/onto-dialog.js +1 -0
  118. package/dist/shared-components/esm/loader.js +1 -1
  119. package/dist/shared-components/esm/onto-cookie-consent_2.entry.js +1 -1
  120. package/dist/shared-components/esm/onto-dialog_2.entry.js +1 -1
  121. package/dist/shared-components/esm/onto-footer_5.entry.js +1 -1
  122. package/dist/shared-components/esm/onto-layout.entry.js +1 -1
  123. package/dist/shared-components/esm/shared-components.js +1 -1
  124. package/dist/shared-components/shared-components/p-2075209c.entry.js +1 -0
  125. package/dist/shared-components/shared-components/p-30e4880f.entry.js +1 -0
  126. package/dist/shared-components/shared-components/p-413b3789.entry.js +1 -0
  127. package/dist/shared-components/shared-components/p-67199a46.entry.js +1 -0
  128. package/dist/shared-components/shared-components/shared-components.esm.js +1 -1
  129. package/dist/shared-components/types/components/dialogs/onto-cookie-policy-dialog/onto-cookie-policy-dialog.d.ts +7 -31
  130. package/dist/shared-components/types/components/onto-cookie-consent/onto-cookie-consent.d.ts +2 -2
  131. package/dist/shared-components/types/components/onto-footer/onto-footer.d.ts +2 -9
  132. package/dist/shared-components/types/components.d.ts +8 -17
  133. package/dist/shared-components/types/models/dialog/dialog-handler.d.ts +0 -4
  134. package/dist/shared-components/types/models/dialog/onto-dialog.d.ts +4 -0
  135. package/package.json +1 -1
  136. package/dist/13231.d7107e7549453805e13a.bundle.js +0 -2
  137. package/dist/13231.d7107e7549453805e13a.bundle.js.map +0 -1
  138. package/dist/21015.ea34b563b4149ad0975e.bundle.js +0 -2
  139. package/dist/21015.ea34b563b4149ad0975e.bundle.js.map +0 -1
  140. package/dist/39874.710e94f211579215f997.bundle.js +0 -2
  141. package/dist/39874.710e94f211579215f997.bundle.js.map +0 -1
  142. package/dist/60560.6ba1b091a34af6c00770.bundle.js +0 -2
  143. package/dist/60560.6ba1b091a34af6c00770.bundle.js.map +0 -1
  144. package/dist/7815.2aec5ebbcd434f5582ff.bundle.js +0 -2
  145. package/dist/7815.2aec5ebbcd434f5582ff.bundle.js.map +0 -1
  146. package/dist/78681.9e1d4e064e9e1fb5fb21.bundle.js +0 -2
  147. package/dist/78681.9e1d4e064e9e1fb5fb21.bundle.js.map +0 -1
  148. package/dist/api/models/cookie/cookie-options.d.ts +0 -17
  149. package/dist/api/models/tracking/cookie-consent.d.ts +0 -39
  150. package/dist/api/models/tracking/index.d.ts +0 -1
  151. package/dist/api/services/cookie/browser-cookie-store.d.ts +0 -19
  152. package/dist/api/services/cookie/cookie-builder.d.ts +0 -77
  153. package/dist/api/services/cookie/cookie-store.d.ts +0 -16
  154. package/dist/api/services/cookie/error/invalid-cookie-expiration.d.ts +0 -8
  155. package/dist/api/services/cookie/test/cookie-builder.spec.d.ts +0 -1
  156. package/dist/api/services/cookie/test/in-memory-cookie-store.d.ts +0 -11
  157. package/dist/api/services/tracking/google-analytics-cookie.service.d.ts +0 -50
  158. package/dist/api/services/tracking/index.d.ts +0 -4
  159. package/dist/api/services/tracking/installation-cookie.service.d.ts +0 -37
  160. package/dist/api/services/tracking/test/tracking-storage.service.spec.d.ts +0 -1
  161. package/dist/api/services/tracking/test/tracking.service.spec.d.ts +0 -1
  162. package/dist/api/services/tracking/tracking-storage.service.d.ts +0 -27
  163. package/dist/api/services/tracking/tracking.service.d.ts +0 -56
  164. package/dist/api/services/utils/date-util.d.ts +0 -11
  165. package/dist/main.44e04f2cf0ab7d48b25b.js.map +0 -1
  166. package/dist/shared-components/cjs/function-utils-WB47AWpR.js +0 -1
  167. package/dist/shared-components/esm/function-utils-D1ZpXQQS.js +0 -1
  168. package/dist/shared-components/shared-components/p-598d33d7.entry.js +0 -1
  169. package/dist/shared-components/shared-components/p-6d34b2cb.entry.js +0 -1
  170. package/dist/shared-components/shared-components/p-74888633.entry.js +0 -1
  171. package/dist/shared-components/shared-components/p-D1ZpXQQS.js +0 -1
  172. package/dist/shared-components/shared-components/p-b5d4081d.entry.js +0 -1
  173. /package/dist/{legacyWorkbench.0128b90d53e9f14490a3.js.LICENSE.txt → legacyWorkbench.88e1d4d209e51c6f9b65.js.LICENSE.txt} +0 -0
  174. /package/dist/{main.44e04f2cf0ab7d48b25b.js.LICENSE.txt → main.1be0fc11ab24b99f8800.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see ontotext-workbench-api.js.LICENSE.txt */
2
- var t={355(t,e){var r,i,s,n,a,o,h,u,c,l,g,p={userAgent:!1},d={},f=f||(r=Math,s=(i={}).lib={},n=s.Base=function(){function t(){}return{extend:function(e){t.prototype=this;var r=new t;return e&&r.mixIn(e),r.hasOwnProperty("init")||(r.init=function(){r.$super.init.apply(this,arguments)}),r.init.prototype=r,r.$super=this,r},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),a=s.WordArray=n.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||h).stringify(this)},concat:function(t){var e=this.words,r=t.words,i=this.sigBytes,s=t.sigBytes;if(this.clamp(),i%4)for(var n=0;n<s;n++){var a=r[n>>>2]>>>24-n%4*8&255;e[i+n>>>2]|=a<<24-(i+n)%4*8}else for(n=0;n<s;n+=4)e[i+n>>>2]=r[n>>>2];return this.sigBytes+=s,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=r.ceil(e/4)},clone:function(){var t=n.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],i=0;i<t;i+=4)e.push(4294967296*r.random()|0);return new a.init(e,t)}}),o=i.enc={},h=o.Hex={stringify:function(t){for(var e=t.words,r=t.sigBytes,i=[],s=0;s<r;s++){var n=e[s>>>2]>>>24-s%4*8&255;i.push((n>>>4).toString(16)),i.push((15&n).toString(16))}return i.join("")},parse:function(t){for(var e=t.length,r=[],i=0;i<e;i+=2)r[i>>>3]|=parseInt(t.substr(i,2),16)<<24-i%8*4;return new a.init(r,e/2)}},u=o.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,i=[],s=0;s<r;s++){var n=e[s>>>2]>>>24-s%4*8&255;i.push(String.fromCharCode(n))}return i.join("")},parse:function(t){for(var e=t.length,r=[],i=0;i<e;i++)r[i>>>2]|=(255&t.charCodeAt(i))<<24-i%4*8;return new a.init(r,e)}},c=o.Utf8={stringify:function(t){try{return decodeURIComponent(escape(u.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return u.parse(unescape(encodeURIComponent(t)))}},l=s.BufferedBlockAlgorithm=n.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=c.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,i=e.words,s=e.sigBytes,n=this.blockSize,o=s/(4*n),h=(o=t?r.ceil(o):r.max((0|o)-this._minBufferSize,0))*n,u=r.min(4*h,s);if(h){for(var c=0;c<h;c+=n)this._doProcessBlock(i,c);var l=i.splice(0,h);e.sigBytes-=u}return new a.init(l,u)},clone:function(){var t=n.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),s.Hasher=l.extend({cfg:n.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(e,r){return new t.init(r).finalize(e)}},_createHmacHelper:function(t){return function(e,r){return new g.HMAC.init(t,r).finalize(e)}}}),g=i.algo={},i);!function(){var t,e=(t=f).lib,r=e.Base,i=e.WordArray;(t=t.x64={}).Word=r.extend({init:function(t,e){this.high=t,this.low=e}}),t.WordArray=r.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:8*t.length},toX32:function(){for(var t=this.words,e=t.length,r=[],s=0;s<e;s++){var n=t[s];r.push(n.high),r.push(n.low)}return i.create(r,this.sigBytes)},clone:function(){for(var t=r.clone.call(this),e=t.words=this.words.slice(0),i=e.length,s=0;s<i;s++)e[s]=e[s].clone();return t}})}(),f.lib.Cipher||function(){var t=(g=f).lib,e=t.Base,r=t.WordArray,i=t.BufferedBlockAlgorithm,s=g.enc.Base64,n=g.algo.EvpKDF,a=t.Cipher=i.extend({cfg:e.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){i.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(t){return{encrypt:function(e,r,i){return("string"==typeof r?p:l).encrypt(t,e,r,i)},decrypt:function(e,r,i){return("string"==typeof r?p:l).decrypt(t,e,r,i)}}}});t.StreamCipher=a.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var o=g.mode={},h=function(t,e,r){var i=this._iv;i?this._iv=void 0:i=this._prevBlock;for(var s=0;s<r;s++)t[e+s]^=i[s]},u=(t.BlockCipherMode=e.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}})).extend();u.Encryptor=u.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize;h.call(this,t,e,i),r.encryptBlock(t,e),this._prevBlock=t.slice(e,e+i)}}),u.Decryptor=u.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize,s=t.slice(e,e+i);r.decryptBlock(t,e),h.call(this,t,e,i),this._prevBlock=s}}),o=o.CBC=u,u=(g.pad={}).Pkcs7={pad:function(t,e){for(var i,s=(i=(i=4*e)-t.sigBytes%i)<<24|i<<16|i<<8|i,n=[],a=0;a<i;a+=4)n.push(s);i=r.create(n,i),t.concat(i)},unpad:function(t){t.sigBytes-=255&t.words[t.sigBytes-1>>>2]}},t.BlockCipher=a.extend({cfg:a.cfg.extend({mode:o,padding:u}),reset:function(){a.reset.call(this);var t=(e=this.cfg).iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var r=e.createEncryptor;else r=e.createDecryptor,this._minBufferSize=1;this._mode=r.call(e,this,t&&t.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else e=this._process(!0),t.unpad(e);return e},blockSize:4});var c=t.CipherParams=e.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),l=(o=(g.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?r.create([1398893684,1701076831]).concat(t).concat(e):e).toString(s)},parse:function(t){var e=(t=s.parse(t)).words;if(1398893684==e[0]&&1701076831==e[1]){var i=r.create(e.slice(2,4));e.splice(0,4),t.sigBytes-=16}return c.create({ciphertext:t,salt:i})}},t.SerializableCipher=e.extend({cfg:e.extend({format:o}),encrypt:function(t,e,r,i){i=this.cfg.extend(i);var s=t.createEncryptor(r,i);return e=s.finalize(e),s=s.cfg,c.create({ciphertext:e,key:r,iv:s.iv,algorithm:t,mode:s.mode,padding:s.padding,blockSize:t.blockSize,formatter:i.format})},decrypt:function(t,e,r,i){return i=this.cfg.extend(i),e=this._parse(e,i.format),t.createDecryptor(r,i).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),g=(g.kdf={}).OpenSSL={execute:function(t,e,i,s){return s||(s=r.random(8)),t=n.create({keySize:e+i}).compute(t,s),i=r.create(t.words.slice(e),4*i),t.sigBytes=4*e,c.create({key:t,iv:i,salt:s})}},p=t.PasswordBasedCipher=l.extend({cfg:l.cfg.extend({kdf:g}),encrypt:function(t,e,r,i){return r=(i=this.cfg.extend(i)).kdf.execute(r,t.keySize,t.ivSize),i.iv=r.iv,(t=l.encrypt.call(this,t,e,r.key,i)).mixIn(r),t},decrypt:function(t,e,r,i){return i=this.cfg.extend(i),e=this._parse(e,i.format),r=i.kdf.execute(r,t.keySize,t.ivSize,e.salt),i.iv=r.iv,l.decrypt.call(this,t,e,r.key,i)}})}(),function(){for(var t=f,e=t.lib.BlockCipher,r=t.algo,i=[],s=[],n=[],a=[],o=[],h=[],u=[],c=[],l=[],g=[],p=[],d=0;256>d;d++)p[d]=128>d?d<<1:d<<1^283;var y=0,v=0;for(d=0;256>d;d++){var m=(m=v^v<<1^v<<2^v<<3^v<<4)>>>8^255&m^99;i[y]=m,s[m]=y;var S=p[y],E=p[S],x=p[E],A=257*p[m]^16843008*m;n[y]=A<<24|A>>>8,a[y]=A<<16|A>>>16,o[y]=A<<8|A>>>24,h[y]=A,A=16843009*x^65537*E^257*S^16843008*y,u[m]=A<<24|A>>>8,c[m]=A<<16|A>>>16,l[m]=A<<8|A>>>24,g[m]=A,y?(y=S^p[p[p[x^S]]],v^=p[p[v]]):y=v=1}var w=[0,1,2,4,8,16,32,64,128,27,54];r=r.AES=e.extend({_doReset:function(){for(var t=(r=this._key).words,e=r.sigBytes/4,r=4*((this._nRounds=e+6)+1),s=this._keySchedule=[],n=0;n<r;n++)if(n<e)s[n]=t[n];else{var a=s[n-1];n%e?6<e&&4==n%e&&(a=i[a>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a]):(a=i[(a=a<<8|a>>>24)>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a],a^=w[n/e|0]<<24),s[n]=s[n-e]^a}for(t=this._invKeySchedule=[],e=0;e<r;e++)n=r-e,a=e%4?s[n]:s[n-4],t[e]=4>e||4>=n?a:u[i[a>>>24]]^c[i[a>>>16&255]]^l[i[a>>>8&255]]^g[i[255&a]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,n,a,o,h,i)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,u,c,l,g,s),r=t[e+1],t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,i,s,n,a,o){for(var h=this._nRounds,u=t[e]^r[0],c=t[e+1]^r[1],l=t[e+2]^r[2],g=t[e+3]^r[3],p=4,d=1;d<h;d++){var f=i[u>>>24]^s[c>>>16&255]^n[l>>>8&255]^a[255&g]^r[p++],y=i[c>>>24]^s[l>>>16&255]^n[g>>>8&255]^a[255&u]^r[p++],v=i[l>>>24]^s[g>>>16&255]^n[u>>>8&255]^a[255&c]^r[p++];g=i[g>>>24]^s[u>>>16&255]^n[c>>>8&255]^a[255&l]^r[p++],u=f,c=y,l=v}f=(o[u>>>24]<<24|o[c>>>16&255]<<16|o[l>>>8&255]<<8|o[255&g])^r[p++],y=(o[c>>>24]<<24|o[l>>>16&255]<<16|o[g>>>8&255]<<8|o[255&u])^r[p++],v=(o[l>>>24]<<24|o[g>>>16&255]<<16|o[u>>>8&255]<<8|o[255&c])^r[p++],g=(o[g>>>24]<<24|o[u>>>16&255]<<16|o[c>>>8&255]<<8|o[255&l])^r[p++],t[e]=f,t[e+1]=y,t[e+2]=v,t[e+3]=g},keySize:8}),t.AES=e._createHelper(r)}(),function(){function t(t,e){var r=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=r,this._lBlock^=r<<t}function e(t,e){var r=(this._rBlock>>>t^this._lBlock)&e;this._lBlock^=r,this._rBlock^=r<<t}var r=f,i=(s=r.lib).WordArray,s=s.BlockCipher,n=r.algo,a=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],o=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],h=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],u=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],c=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],l=n.DES=s.extend({_doReset:function(){for(var t=this._key.words,e=[],r=0;56>r;r++){var i=a[r]-1;e[r]=t[i>>>5]>>>31-i%32&1}for(t=this._subKeys=[],i=0;16>i;i++){var s=t[i]=[],n=h[i];for(r=0;24>r;r++)s[r/6|0]|=e[(o[r]-1+n)%28]<<31-r%6,s[4+(r/6|0)]|=e[28+(o[r+24]-1+n)%28]<<31-r%6;for(s[0]=s[0]<<1|s[0]>>>31,r=1;7>r;r++)s[r]>>>=4*(r-1)+3;s[7]=s[7]<<5|s[7]>>>27}for(e=this._invSubKeys=[],r=0;16>r;r++)e[r]=t[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(r,i,s){this._lBlock=r[i],this._rBlock=r[i+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var n=0;16>n;n++){for(var a=s[n],o=this._lBlock,h=this._rBlock,l=0,g=0;8>g;g++)l|=u[g][((h^a[g])&c[g])>>>0];this._lBlock=h,this._rBlock=o^l}s=this._lBlock,this._lBlock=this._rBlock,this._rBlock=s,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),r[i]=this._lBlock,r[i+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});r.DES=s._createHelper(l),n=n.TripleDES=s.extend({_doReset:function(){var t=this._key.words;this._des1=l.createEncryptor(i.create(t.slice(0,2))),this._des2=l.createEncryptor(i.create(t.slice(2,4))),this._des3=l.createEncryptor(i.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),r.TripleDES=s._createHelper(n)}(),function(){var t=f,e=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,r=t.sigBytes,i=this._map;t.clamp(),t=[];for(var s=0;s<r;s+=3)for(var n=(e[s>>>2]>>>24-s%4*8&255)<<16|(e[s+1>>>2]>>>24-(s+1)%4*8&255)<<8|e[s+2>>>2]>>>24-(s+2)%4*8&255,a=0;4>a&&s+.75*a<r;a++)t.push(i.charAt(n>>>6*(3-a)&63));if(e=i.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var r=t.length,i=this._map;(s=i.charAt(64))&&-1!=(s=t.indexOf(s))&&(r=s);for(var s=[],n=0,a=0;a<r;a++)if(a%4){var o=i.indexOf(t.charAt(a-1))<<a%4*2,h=i.indexOf(t.charAt(a))>>>6-a%4*2;s[n>>>2]|=(o|h)<<24-n%4*8,n++}return e.create(s,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,r,i,s,n,a){return((t=t+(e&r|~e&i)+s+a)<<n|t>>>32-n)+e}function r(t,e,r,i,s,n,a){return((t=t+(e&i|r&~i)+s+a)<<n|t>>>32-n)+e}function i(t,e,r,i,s,n,a){return((t=t+(e^r^i)+s+a)<<n|t>>>32-n)+e}function s(t,e,r,i,s,n,a){return((t=t+(r^(e|~i))+s+a)<<n|t>>>32-n)+e}for(var n=f,a=(h=n.lib).WordArray,o=h.Hasher,h=n.algo,u=[],c=0;64>c;c++)u[c]=4294967296*t.abs(t.sin(c+1))|0;h=h.MD5=o.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,n){for(var a=0;16>a;a++){var o=t[h=n+a];t[h]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}a=this._hash.words;var h=t[n+0],c=(o=t[n+1],t[n+2]),l=t[n+3],g=t[n+4],p=t[n+5],d=t[n+6],f=t[n+7],y=t[n+8],v=t[n+9],m=t[n+10],S=t[n+11],E=t[n+12],x=t[n+13],A=t[n+14],w=t[n+15],b=e(b=a[0],F=a[1],I=a[2],C=a[3],h,7,u[0]),C=e(C,b,F,I,o,12,u[1]),I=e(I,C,b,F,c,17,u[2]),F=e(F,I,C,b,l,22,u[3]);b=e(b,F,I,C,g,7,u[4]),C=e(C,b,F,I,p,12,u[5]),I=e(I,C,b,F,d,17,u[6]),F=e(F,I,C,b,f,22,u[7]),b=e(b,F,I,C,y,7,u[8]),C=e(C,b,F,I,v,12,u[9]),I=e(I,C,b,F,m,17,u[10]),F=e(F,I,C,b,S,22,u[11]),b=e(b,F,I,C,E,7,u[12]),C=e(C,b,F,I,x,12,u[13]),I=e(I,C,b,F,A,17,u[14]),b=r(b,F=e(F,I,C,b,w,22,u[15]),I,C,o,5,u[16]),C=r(C,b,F,I,d,9,u[17]),I=r(I,C,b,F,S,14,u[18]),F=r(F,I,C,b,h,20,u[19]),b=r(b,F,I,C,p,5,u[20]),C=r(C,b,F,I,m,9,u[21]),I=r(I,C,b,F,w,14,u[22]),F=r(F,I,C,b,g,20,u[23]),b=r(b,F,I,C,v,5,u[24]),C=r(C,b,F,I,A,9,u[25]),I=r(I,C,b,F,l,14,u[26]),F=r(F,I,C,b,y,20,u[27]),b=r(b,F,I,C,x,5,u[28]),C=r(C,b,F,I,c,9,u[29]),I=r(I,C,b,F,f,14,u[30]),b=i(b,F=r(F,I,C,b,E,20,u[31]),I,C,p,4,u[32]),C=i(C,b,F,I,y,11,u[33]),I=i(I,C,b,F,S,16,u[34]),F=i(F,I,C,b,A,23,u[35]),b=i(b,F,I,C,o,4,u[36]),C=i(C,b,F,I,g,11,u[37]),I=i(I,C,b,F,f,16,u[38]),F=i(F,I,C,b,m,23,u[39]),b=i(b,F,I,C,x,4,u[40]),C=i(C,b,F,I,h,11,u[41]),I=i(I,C,b,F,l,16,u[42]),F=i(F,I,C,b,d,23,u[43]),b=i(b,F,I,C,v,4,u[44]),C=i(C,b,F,I,E,11,u[45]),I=i(I,C,b,F,w,16,u[46]),b=s(b,F=i(F,I,C,b,c,23,u[47]),I,C,h,6,u[48]),C=s(C,b,F,I,f,10,u[49]),I=s(I,C,b,F,A,15,u[50]),F=s(F,I,C,b,p,21,u[51]),b=s(b,F,I,C,E,6,u[52]),C=s(C,b,F,I,l,10,u[53]),I=s(I,C,b,F,m,15,u[54]),F=s(F,I,C,b,o,21,u[55]),b=s(b,F,I,C,y,6,u[56]),C=s(C,b,F,I,w,10,u[57]),I=s(I,C,b,F,d,15,u[58]),F=s(F,I,C,b,x,21,u[59]),b=s(b,F,I,C,g,6,u[60]),C=s(C,b,F,I,S,10,u[61]),I=s(I,C,b,F,c,15,u[62]),F=s(F,I,C,b,v,21,u[63]),a[0]=a[0]+b|0,a[1]=a[1]+F|0,a[2]=a[2]+I|0,a[3]=a[3]+C|0},_doFinalize:function(){var e=this._data,r=e.words,i=8*this._nDataBytes,s=8*e.sigBytes;r[s>>>5]|=128<<24-s%32;var n=t.floor(i/4294967296);for(r[15+(s+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),r[14+(s+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),e.sigBytes=4*(r.length+1),this._process(),r=(e=this._hash).words,i=0;4>i;i++)s=r[i],r[i]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8);return e},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}}),n.MD5=o._createHelper(h),n.HmacMD5=o._createHmacHelper(h)}(Math),function(){var t=f,e=(s=t.lib).WordArray,r=s.Hasher,i=[],s=t.algo.SHA1=r.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=this._hash.words,s=r[0],n=r[1],a=r[2],o=r[3],h=r[4],u=0;80>u;u++){if(16>u)i[u]=0|t[e+u];else{var c=i[u-3]^i[u-8]^i[u-14]^i[u-16];i[u]=c<<1|c>>>31}c=(s<<5|s>>>27)+h+i[u],c=20>u?c+(1518500249+(n&a|~n&o)):40>u?c+(1859775393+(n^a^o)):60>u?c+((n&a|n&o|a&o)-1894007588):c+((n^a^o)-899497514),h=o,o=a,a=n<<30|n>>>2,n=s,s=c}r[0]=r[0]+s|0,r[1]=r[1]+n|0,r[2]=r[2]+a|0,r[3]=r[3]+o|0,r[4]=r[4]+h|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return e[i>>>5]|=128<<24-i%32,e[14+(i+64>>>9<<4)]=Math.floor(r/4294967296),e[15+(i+64>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=r._createHelper(s),t.HmacSHA1=r._createHmacHelper(s)}(),function(t){for(var e=f,r=(s=e.lib).WordArray,i=s.Hasher,s=e.algo,n=[],a=[],o=function(t){return 4294967296*(t-(0|t))|0},h=2,u=0;64>u;){var c;t:{c=h;for(var l=t.sqrt(c),g=2;g<=l;g++)if(!(c%g)){c=!1;break t}c=!0}c&&(8>u&&(n[u]=o(t.pow(h,.5))),a[u]=o(t.pow(h,1/3)),u++),h++}var p=[];s=s.SHA256=i.extend({_doReset:function(){this._hash=new r.init(n.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,i=r[0],s=r[1],n=r[2],o=r[3],h=r[4],u=r[5],c=r[6],l=r[7],g=0;64>g;g++){if(16>g)p[g]=0|t[e+g];else{var d=p[g-15],f=p[g-2];p[g]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+p[g-7]+((f<<15|f>>>17)^(f<<13|f>>>19)^f>>>10)+p[g-16]}d=l+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&u^~h&c)+a[g]+p[g],f=((i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22))+(i&s^i&n^s&n),l=c,c=u,u=h,h=o+d|0,o=n,n=s,s=i,i=d+f|0}r[0]=r[0]+i|0,r[1]=r[1]+s|0,r[2]=r[2]+n|0,r[3]=r[3]+o|0,r[4]=r[4]+h|0,r[5]=r[5]+u|0,r[6]=r[6]+c|0,r[7]=r[7]+l|0},_doFinalize:function(){var e=this._data,r=e.words,i=8*this._nDataBytes,s=8*e.sigBytes;return r[s>>>5]|=128<<24-s%32,r[14+(s+64>>>9<<4)]=t.floor(i/4294967296),r[15+(s+64>>>9<<4)]=i,e.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}}),e.SHA256=i._createHelper(s),e.HmacSHA256=i._createHmacHelper(s)}(Math),function(){var t=f,e=t.lib.WordArray,r=(i=t.algo).SHA256,i=i.SHA224=r.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=r._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=r._createHelper(i),t.HmacSHA224=r._createHmacHelper(i)}(),function(){function t(){return i.create.apply(i,arguments)}for(var e=f,r=e.lib.Hasher,i=(n=e.x64).Word,s=n.WordArray,n=e.algo,a=[t(1116352408,3609767458),t(1899447441,602891725),t(3049323471,3964484399),t(3921009573,2173295548),t(961987163,4081628472),t(1508970993,3053834265),t(2453635748,2937671579),t(2870763221,3664609560),t(3624381080,2734883394),t(310598401,1164996542),t(607225278,1323610764),t(1426881987,3590304994),t(1925078388,4068182383),t(2162078206,991336113),t(2614888103,633803317),t(3248222580,3479774868),t(3835390401,2666613458),t(4022224774,944711139),t(264347078,2341262773),t(604807628,2007800933),t(770255983,1495990901),t(1249150122,1856431235),t(1555081692,3175218132),t(1996064986,2198950837),t(2554220882,3999719339),t(2821834349,766784016),t(2952996808,2566594879),t(3210313671,3203337956),t(3336571891,1034457026),t(3584528711,2466948901),t(113926993,3758326383),t(338241895,168717936),t(666307205,1188179964),t(773529912,1546045734),t(1294757372,1522805485),t(1396182291,2643833823),t(1695183700,2343527390),t(1986661051,1014477480),t(2177026350,1206759142),t(2456956037,344077627),t(2730485921,1290863460),t(2820302411,3158454273),t(3259730800,3505952657),t(3345764771,106217008),t(3516065817,3606008344),t(3600352804,1432725776),t(4094571909,1467031594),t(275423344,851169720),t(430227734,3100823752),t(506948616,1363258195),t(659060556,3750685593),t(883997877,3785050280),t(958139571,3318307427),t(1322822218,3812723403),t(1537002063,2003034995),t(1747873779,3602036899),t(1955562222,1575990012),t(2024104815,1125592928),t(2227730452,2716904306),t(2361852424,442776044),t(2428436474,593698344),t(2756734187,3733110249),t(3204031479,2999351573),t(3329325298,3815920427),t(3391569614,3928383900),t(3515267271,566280711),t(3940187606,3454069534),t(4118630271,4000239992),t(116418474,1914138554),t(174292421,2731055270),t(289380356,3203993006),t(460393269,320620315),t(685471733,587496836),t(852142971,1086792851),t(1017036298,365543100),t(1126000580,2618297676),t(1288033470,3409855158),t(1501505948,4234509866),t(1607167915,987167468),t(1816402316,1246189591)],o=[],h=0;80>h;h++)o[h]=t();n=n.SHA512=r.extend({_doReset:function(){this._hash=new s.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var r=(l=this._hash.words)[0],i=l[1],s=l[2],n=l[3],h=l[4],u=l[5],c=l[6],l=l[7],g=r.high,p=r.low,d=i.high,f=i.low,y=s.high,v=s.low,m=n.high,S=n.low,E=h.high,x=h.low,A=u.high,w=u.low,b=c.high,C=c.low,I=l.high,F=l.low,R=g,T=p,P=d,D=f,N=y,O=v,_=m,B=S,L=E,H=x,k=A,U=w,V=b,j=C,M=I,K=F,q=0;80>q;q++){var G=o[q];if(16>q)var W=G.high=0|t[e+2*q],$=G.low=0|t[e+2*q+1];else{W=(($=(W=o[q-15]).high)>>>1|(X=W.low)<<31)^($>>>8|X<<24)^$>>>7;var X=(X>>>1|$<<31)^(X>>>8|$<<24)^(X>>>7|$<<25),z=(($=(z=o[q-2]).high)>>>19|(J=z.low)<<13)^($<<3|J>>>29)^$>>>6,J=(J>>>19|$<<13)^(J<<3|$>>>29)^(J>>>6|$<<26),Y=($=o[q-7]).high,Q=(Z=o[q-16]).high,Z=Z.low;W=(W=(W=W+Y+(($=X+$.low)>>>0<X>>>0?1:0))+z+(($+=J)>>>0<J>>>0?1:0))+Q+(($+=Z)>>>0<Z>>>0?1:0),G.high=W,G.low=$}Y=L&k^~L&V,Z=H&U^~H&j,G=R&P^R&N^P&N;var tt=T&D^T&O^D&O,et=(X=(R>>>28|T<<4)^(R<<30|T>>>2)^(R<<25|T>>>7),z=(T>>>28|R<<4)^(T<<30|R>>>2)^(T<<25|R>>>7),(J=a[q]).high),rt=J.low;Q=M+((L>>>14|H<<18)^(L>>>18|H<<14)^(L<<23|H>>>9))+((J=K+((H>>>14|L<<18)^(H>>>18|L<<14)^(H<<23|L>>>9)))>>>0<K>>>0?1:0),M=V,K=j,V=k,j=U,k=L,U=H,L=_+(Q=(Q=(Q=Q+Y+((J+=Z)>>>0<Z>>>0?1:0))+et+((J+=rt)>>>0<rt>>>0?1:0))+W+((J+=$)>>>0<$>>>0?1:0))+((H=B+J|0)>>>0<B>>>0?1:0)|0,_=N,B=O,N=P,O=D,P=R,D=T,R=Q+(G=X+G+(($=z+tt)>>>0<z>>>0?1:0))+((T=J+$|0)>>>0<J>>>0?1:0)|0}p=r.low=p+T,r.high=g+R+(p>>>0<T>>>0?1:0),f=i.low=f+D,i.high=d+P+(f>>>0<D>>>0?1:0),v=s.low=v+O,s.high=y+N+(v>>>0<O>>>0?1:0),S=n.low=S+B,n.high=m+_+(S>>>0<B>>>0?1:0),x=h.low=x+H,h.high=E+L+(x>>>0<H>>>0?1:0),w=u.low=w+U,u.high=A+k+(w>>>0<U>>>0?1:0),C=c.low=C+j,c.high=b+V+(C>>>0<j>>>0?1:0),F=l.low=F+K,l.high=I+M+(F>>>0<K>>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return e[i>>>5]|=128<<24-i%32,e[30+(i+128>>>10<<5)]=Math.floor(r/4294967296),e[31+(i+128>>>10<<5)]=r,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=r._createHelper(n),e.HmacSHA512=r._createHmacHelper(n)}(),function(){var t=f,e=(s=t.x64).Word,r=s.WordArray,i=(s=t.algo).SHA512,s=s.SHA384=i.extend({_doReset:function(){this._hash=new r.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=i._createHelper(s),t.HmacSHA384=i._createHmacHelper(s)}(),function(){var t=f,e=(i=t.lib).WordArray,r=i.Hasher,i=t.algo,s=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),n=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),a=e.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),o=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=e.create([0,1518500249,1859775393,2400959708,2840853838]),u=e.create([1352829926,1548603684,1836072691,2053994217,0]);i=i.RIPEMD160=r.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=0;16>r;r++){var i=t[x=e+r];t[x]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var c,l,g,p,d,f,y,v,m,S,E,x=this._hash.words,A=(i=h.words,u.words),w=s.words,b=n.words,C=a.words,I=o.words;for(f=c=x[0],y=l=x[1],v=g=x[2],m=p=x[3],S=d=x[4],r=0;80>r;r+=1)E=c+t[e+w[r]]|0,E=16>r?E+((l^g^p)+i[0]):32>r?E+((l&g|~l&p)+i[1]):48>r?E+(((l|~g)^p)+i[2]):64>r?E+((l&p|g&~p)+i[3]):E+((l^(g|~p))+i[4]),E=(E=(E|=0)<<C[r]|E>>>32-C[r])+d|0,c=d,d=p,p=g<<10|g>>>22,g=l,l=E,E=f+t[e+b[r]]|0,E=16>r?E+((y^(v|~m))+A[0]):32>r?E+((y&m|v&~m)+A[1]):48>r?E+(((y|~v)^m)+A[2]):64>r?E+((y&v|~y&m)+A[3]):E+((y^v^m)+A[4]),E=(E=(E|=0)<<I[r]|E>>>32-I[r])+S|0,f=S,S=m,m=v<<10|v>>>22,v=y,y=E;E=x[1]+g+m|0,x[1]=x[2]+p+S|0,x[2]=x[3]+d+f|0,x[3]=x[4]+c+y|0,x[4]=x[0]+l+v|0,x[0]=E},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;for(e[i>>>5]|=128<<24-i%32,e[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,r=0;5>r;r++)i=e[r],e[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return t},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}}),t.RIPEMD160=r._createHelper(i),t.HmacRIPEMD160=r._createHmacHelper(i)}(Math),function(){var t=f,e=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,r){t=this._hasher=new t.init,"string"==typeof r&&(r=e.parse(r));var i=t.blockSize,s=4*i;r.sigBytes>s&&(r=t.finalize(r)),r.clamp();for(var n=this._oKey=r.clone(),a=this._iKey=r.clone(),o=n.words,h=a.words,u=0;u<i;u++)o[u]^=1549556828,h[u]^=909522486;n.sigBytes=a.sigBytes=s,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher;return t=e.finalize(t),e.reset(),e.finalize(this._oKey.clone().concat(t))}})}(),function(){var t,e=f,r=(t=e.lib).Base,i=t.WordArray,s=(t=e.algo).HMAC,n=t.PBKDF2=r.extend({cfg:r.extend({keySize:4,hasher:t.SHA1,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){var r=this.cfg,n=s.create(r.hasher,t),a=i.create(),o=i.create([1]),h=a.words,u=o.words,c=r.keySize;for(r=r.iterations;h.length<c;){var l=n.update(e).finalize(o);n.reset();for(var g=l.words,p=g.length,d=l,f=1;f<r;f++){d=n.finalize(d),n.reset();for(var y=d.words,v=0;v<p;v++)g[v]^=y[v]}a.concat(l),u[0]++}return a.sigBytes=4*c,a}});e.PBKDF2=function(t,e,r){return n.create(r).compute(t,e)}}();var y,v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function m(t){var e,r,i="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),i+=v.charAt(r>>6)+v.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),i+=v.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),i+=v.charAt(r>>2)+v.charAt((3&r)<<4));(3&i.length)>0;)i+="=";return i}function S(t){var e,r,i,s="",n=0;for(e=0;e<t.length&&"="!=t.charAt(e);++e)(i=v.indexOf(t.charAt(e)))<0||(0==n?(s+=C(i>>2),r=3&i,n=1):1==n?(s+=C(r<<2|i>>4),r=15&i,n=2):2==n?(s+=C(r),s+=C(i>>2),r=3&i,n=3):(s+=C(r<<2|i>>4),s+=C(15&i),n=0));return 1==n&&(s+=C(r<<2)),s}function E(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function x(){return new E(null)}"Microsoft Internet Explorer"==p.appName?(E.prototype.am=function(t,e,r,i,s,n){for(var a=32767&e,o=e>>15;--n>=0;){var h=32767&this[t],u=this[t++]>>15,c=o*h+u*a;s=((h=a*h+((32767&c)<<15)+r[i]+(1073741823&s))>>>30)+(c>>>15)+o*u+(s>>>30),r[i++]=1073741823&h}return s},y=30):"Netscape"!=p.appName?(E.prototype.am=function(t,e,r,i,s,n){for(;--n>=0;){var a=e*this[t++]+r[i]+s;s=Math.floor(a/67108864),r[i++]=67108863&a}return s},y=26):(E.prototype.am=function(t,e,r,i,s,n){for(var a=16383&e,o=e>>14;--n>=0;){var h=16383&this[t],u=this[t++]>>14,c=o*h+u*a;s=((h=a*h+((16383&c)<<14)+r[i]+s)>>28)+(c>>14)+o*u,r[i++]=268435455&h}return s},y=28),E.prototype.DB=y,E.prototype.DM=(1<<y)-1,E.prototype.DV=1<<y,E.prototype.FV=Math.pow(2,52),E.prototype.F1=52-y,E.prototype.F2=2*y-52;var A,w,b=new Array;for(A="0".charCodeAt(0),w=0;w<=9;++w)b[A++]=w;for(A="a".charCodeAt(0),w=10;w<36;++w)b[A++]=w;for(A="A".charCodeAt(0),w=10;w<36;++w)b[A++]=w;function C(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function I(t,e){var r=b[t.charCodeAt(e)];return null==r?-1:r}function F(t){var e=x();return e.fromInt(t),e}function R(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function T(t){this.m=t}function P(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function D(t,e){return t&e}function N(t,e){return t|e}function O(t,e){return t^e}function _(t,e){return t&~e}function B(t){if(0==t)return-1;var e=0;return 65535&t||(t>>=16,e+=16),255&t||(t>>=8,e+=8),15&t||(t>>=4,e+=4),3&t||(t>>=2,e+=2),1&t||++e,e}function L(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function H(){}function k(t){return t}function U(t){this.r2=x(),this.q3=x(),E.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}T.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},T.prototype.revert=function(t){return t},T.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},T.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},T.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},P.prototype.convert=function(t){var e=x();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(E.ZERO)>0&&this.m.subTo(e,e),e},P.prototype.revert=function(t){var e=x();return t.copyTo(e),this.reduce(e),e},P.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],i=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,i,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},P.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},P.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},E.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},E.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},E.prototype.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var i=t.length,s=!1,n=0;--i>=0;){var a=8==r?255&t[i]:I(t,i);a<0?"-"==t.charAt(i)&&(s=!0):(s=!1,0==n?this[this.t++]=a:n+r>this.DB?(this[this.t-1]|=(a&(1<<this.DB-n)-1)<<n,this[this.t++]=a>>this.DB-n):this[this.t-1]|=a<<n,(n+=r)>=this.DB&&(n-=this.DB))}8==r&&128&t[0]&&(this.s=-1,n>0&&(this[this.t-1]|=(1<<this.DB-n)-1<<n)),this.clamp(),s&&E.ZERO.subTo(this,this)},E.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},E.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},E.prototype.drShiftTo=function(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s},E.prototype.lShiftTo=function(t,e){var r,i=t%this.DB,s=this.DB-i,n=(1<<s)-1,a=Math.floor(t/this.DB),o=this.s<<i&this.DM;for(r=this.t-1;r>=0;--r)e[r+a+1]=this[r]>>s|o,o=(this[r]&n)<<i;for(r=a-1;r>=0;--r)e[r]=0;e[a]=o,e.t=this.t+a+1,e.s=this.s,e.clamp()},E.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var i=t%this.DB,s=this.DB-i,n=(1<<i)-1;e[0]=this[r]>>i;for(var a=r+1;a<this.t;++a)e[a-r-1]|=(this[a]&n)<<s,e[a-r]=this[a]>>i;i>0&&(e[this.t-r-1]|=(this.s&n)<<s),e.t=this.t-r,e.clamp()}},E.prototype.subTo=function(t,e){for(var r=0,i=0,s=Math.min(t.t,this.t);r<s;)i+=this[r]-t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i-=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i-=t[r],e[r++]=i&this.DM,i>>=this.DB;i-=t.s}e.s=i<0?-1:0,i<-1?e[r++]=this.DV+i:i>0&&(e[r++]=i),e.t=r,e.clamp()},E.prototype.multiplyTo=function(t,e){var r=this.abs(),i=t.abs(),s=r.t;for(e.t=s+i.t;--s>=0;)e[s]=0;for(s=0;s<i.t;++s)e[s+r.t]=r.am(0,i[s],e,s,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&E.ZERO.subTo(e,e)},E.prototype.squareTo=function(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var i=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,i,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},E.prototype.divRemTo=function(t,e,r){var i=t.abs();if(!(i.t<=0)){var s=this.abs();if(s.t<i.t)return null!=e&&e.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=x());var n=x(),a=this.s,o=t.s,h=this.DB-R(i[i.t-1]);h>0?(i.lShiftTo(h,n),s.lShiftTo(h,r)):(i.copyTo(n),s.copyTo(r));var u=n.t,c=n[u-1];if(0!=c){var l=c*(1<<this.F1)+(u>1?n[u-2]>>this.F2:0),g=this.FV/l,p=(1<<this.F1)/l,d=1<<this.F2,f=r.t,y=f-u,v=null==e?x():e;for(n.dlShiftTo(y,v),r.compareTo(v)>=0&&(r[r.t++]=1,r.subTo(v,r)),E.ONE.dlShiftTo(u,v),v.subTo(n,n);n.t<u;)n[n.t++]=0;for(;--y>=0;){var m=r[--f]==c?this.DM:Math.floor(r[f]*g+(r[f-1]+d)*p);if((r[f]+=n.am(0,m,r,y,0,u))<m)for(n.dlShiftTo(y,v),r.subTo(v,r);r[f]<--m;)r.subTo(v,r)}null!=e&&(r.drShiftTo(u,e),a!=o&&E.ZERO.subTo(e,e)),r.t=u,r.clamp(),h>0&&r.rShiftTo(h,r),a<0&&E.ZERO.subTo(r,r)}}},E.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(!(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},E.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},E.prototype.exp=function(t,e){if(t>4294967295||t<1)return E.ONE;var r=x(),i=x(),s=e.convert(this),n=R(t)-1;for(s.copyTo(r);--n>=0;)if(e.sqrTo(r,i),(t&1<<n)>0)e.mulTo(i,s,r);else{var a=r;r=i,i=a}return e.revert(r)},E.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,i=(1<<e)-1,s=!1,n="",a=this.t,o=this.DB-a*this.DB%e;if(a-- >0)for(o<this.DB&&(r=this[a]>>o)>0&&(s=!0,n=C(r));a>=0;)o<e?(r=(this[a]&(1<<o)-1)<<e-o,r|=this[--a]>>(o+=this.DB-e)):(r=this[a]>>(o-=e)&i,o<=0&&(o+=this.DB,--a)),r>0&&(s=!0),s&&(n+=C(r));return s?n:"0"},E.prototype.negate=function(){var t=x();return E.ZERO.subTo(this,t),t},E.prototype.abs=function(){return this.s<0?this.negate():this},E.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},E.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+R(this[this.t-1]^this.s&this.DM)},E.prototype.mod=function(t){var e=x();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(E.ZERO)>0&&t.subTo(e,e),e},E.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new T(e):new P(e),this.exp(t,r)},E.ZERO=F(0),E.ONE=F(1),H.prototype.convert=k,H.prototype.revert=k,H.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},H.prototype.sqrTo=function(t,e){t.squareTo(e)},U.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=x();return t.copyTo(e),this.reduce(e),e},U.prototype.revert=function(t){return t},U.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},U.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},U.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var V,j,M,K=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],q=(1<<26)/K[K.length-1];function G(){this.i=0,this.j=0,this.S=new Array}function W(){!function(t){j[M++]^=255&t,j[M++]^=t>>8&255,j[M++]^=t>>16&255,j[M++]^=t>>24&255,M>=256&&(M-=256)}((new Date).getTime())}if(E.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},E.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),i=F(r),s=x(),n=x(),a="";for(this.divRemTo(i,s,n);s.signum()>0;)a=(r+n.intValue()).toString(t).substr(1)+a,s.divRemTo(i,s,n);return n.intValue().toString(t)+a},E.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),i=Math.pow(e,r),s=!1,n=0,a=0,o=0;o<t.length;++o){var h=I(t,o);h<0?"-"==t.charAt(o)&&0==this.signum()&&(s=!0):(a=e*a+h,++n>=r&&(this.dMultiply(i),this.dAddOffset(a,0),n=0,a=0))}n>0&&(this.dMultiply(Math.pow(e,n)),this.dAddOffset(a,0)),s&&E.ZERO.subTo(this,this)},E.prototype.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(E.ONE.shiftLeft(t-1),N,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(E.ONE.shiftLeft(t-1),this);else{var i=new Array,s=7&t;i.length=1+(t>>3),e.nextBytes(i),s>0?i[0]&=(1<<s)-1:i[0]=0,this.fromString(i,256)}},E.prototype.bitwiseTo=function(t,e,r){var i,s,n=Math.min(t.t,this.t);for(i=0;i<n;++i)r[i]=e(this[i],t[i]);if(t.t<this.t){for(s=t.s&this.DM,i=n;i<this.t;++i)r[i]=e(this[i],s);r.t=this.t}else{for(s=this.s&this.DM,i=n;i<t.t;++i)r[i]=e(s,t[i]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()},E.prototype.changeBit=function(t,e){var r=E.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r},E.prototype.addTo=function(t,e){for(var r=0,i=0,s=Math.min(t.t,this.t);r<s;)i+=this[r]+t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i+=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i+=t[r],e[r++]=i&this.DM,i>>=this.DB;i+=t.s}e.s=i<0?-1:0,i>0?e[r++]=i:i<-1&&(e[r++]=this.DV+i),e.t=r,e.clamp()},E.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},E.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},E.prototype.multiplyLowerTo=function(t,e,r){var i,s=Math.min(this.t+t.t,e);for(r.s=0,r.t=s;s>0;)r[--s]=0;for(i=r.t-this.t;s<i;++s)r[s+this.t]=this.am(0,t[s],r,s,0,this.t);for(i=Math.min(t.t,e);s<i;++s)this.am(0,t[s],r,s,0,e-s);r.clamp()},E.prototype.multiplyUpperTo=function(t,e,r){--e;var i=r.t=this.t+t.t-e;for(r.s=0;--i>=0;)r[i]=0;for(i=Math.max(e-this.t,0);i<t.t;++i)r[this.t+i-e]=this.am(e-i,t[i],r,0,0,this.t+i-e);r.clamp(),r.drShiftTo(1,r)},E.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var i=this.t-1;i>=0;--i)r=(e*r+this[i])%t;return r},E.prototype.millerRabin=function(t){var e=this.subtract(E.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var i=e.shiftRight(r);(t=t+1>>1)>K.length&&(t=K.length);for(var s=x(),n=0;n<t;++n){s.fromInt(K[Math.floor(Math.random()*K.length)]);var a=s.modPow(i,this);if(0!=a.compareTo(E.ONE)&&0!=a.compareTo(e)){for(var o=1;o++<r&&0!=a.compareTo(e);)if(0==(a=a.modPowInt(2,this)).compareTo(E.ONE))return!1;if(0!=a.compareTo(e))return!1}}return!0},E.prototype.clone=function(){var t=x();return this.copyTo(t),t},E.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},E.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},E.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},E.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},E.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,i=this.DB-t*this.DB%8,s=0;if(t-- >0)for(i<this.DB&&(r=this[t]>>i)!=(this.s&this.DM)>>i&&(e[s++]=r|this.s<<this.DB-i);t>=0;)i<8?(r=(this[t]&(1<<i)-1)<<8-i,r|=this[--t]>>(i+=this.DB-8)):(r=this[t]>>(i-=8)&255,i<=0&&(i+=this.DB,--t)),128&r&&(r|=-256),0==s&&(128&this.s)!=(128&r)&&++s,(s>0||r!=this.s)&&(e[s++]=r);return e},E.prototype.equals=function(t){return 0==this.compareTo(t)},E.prototype.min=function(t){return this.compareTo(t)<0?this:t},E.prototype.max=function(t){return this.compareTo(t)>0?this:t},E.prototype.and=function(t){var e=x();return this.bitwiseTo(t,D,e),e},E.prototype.or=function(t){var e=x();return this.bitwiseTo(t,N,e),e},E.prototype.xor=function(t){var e=x();return this.bitwiseTo(t,O,e),e},E.prototype.andNot=function(t){var e=x();return this.bitwiseTo(t,_,e),e},E.prototype.not=function(){for(var t=x(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},E.prototype.shiftLeft=function(t){var e=x();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},E.prototype.shiftRight=function(t){var e=x();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},E.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+B(this[t]);return this.s<0?this.t*this.DB:-1},E.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=L(this[r]^e);return t},E.prototype.testBit=function(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:!!(this[e]&1<<t%this.DB)},E.prototype.setBit=function(t){return this.changeBit(t,N)},E.prototype.clearBit=function(t){return this.changeBit(t,_)},E.prototype.flipBit=function(t){return this.changeBit(t,O)},E.prototype.add=function(t){var e=x();return this.addTo(t,e),e},E.prototype.subtract=function(t){var e=x();return this.subTo(t,e),e},E.prototype.multiply=function(t){var e=x();return this.multiplyTo(t,e),e},E.prototype.divide=function(t){var e=x();return this.divRemTo(t,e,null),e},E.prototype.remainder=function(t){var e=x();return this.divRemTo(t,null,e),e},E.prototype.divideAndRemainder=function(t){var e=x(),r=x();return this.divRemTo(t,e,r),new Array(e,r)},E.prototype.modPow=function(t,e){var r,i,s=t.bitLength(),n=F(1);if(s<=0)return n;r=s<18?1:s<48?3:s<144?4:s<768?5:6,i=s<8?new T(e):e.isEven()?new U(e):new P(e);var a=new Array,o=3,h=r-1,u=(1<<r)-1;if(a[1]=i.convert(this),r>1){var c=x();for(i.sqrTo(a[1],c);o<=u;)a[o]=x(),i.mulTo(c,a[o-2],a[o]),o+=2}var l,g,p=t.t-1,d=!0,f=x();for(s=R(t[p])-1;p>=0;){for(s>=h?l=t[p]>>s-h&u:(l=(t[p]&(1<<s+1)-1)<<h-s,p>0&&(l|=t[p-1]>>this.DB+s-h)),o=r;!(1&l);)l>>=1,--o;if((s-=o)<0&&(s+=this.DB,--p),d)a[l].copyTo(n),d=!1;else{for(;o>1;)i.sqrTo(n,f),i.sqrTo(f,n),o-=2;o>0?i.sqrTo(n,f):(g=n,n=f,f=g),i.mulTo(f,a[l],n)}for(;p>=0&&!(t[p]&1<<s);)i.sqrTo(n,f),g=n,n=f,f=g,--s<0&&(s=this.DB-1,--p)}return i.revert(n)},E.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return E.ZERO;for(var r=t.clone(),i=this.clone(),s=F(1),n=F(0),a=F(0),o=F(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(s.isEven()&&n.isEven()||(s.addTo(this,s),n.subTo(t,n)),s.rShiftTo(1,s)):n.isEven()||n.subTo(t,n),n.rShiftTo(1,n);for(;i.isEven();)i.rShiftTo(1,i),e?(a.isEven()&&o.isEven()||(a.addTo(this,a),o.subTo(t,o)),a.rShiftTo(1,a)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);r.compareTo(i)>=0?(r.subTo(i,r),e&&s.subTo(a,s),n.subTo(o,n)):(i.subTo(r,i),e&&a.subTo(s,a),o.subTo(n,o))}return 0!=i.compareTo(E.ONE)?E.ZERO:o.compareTo(t)>=0?o.subtract(t):o.signum()<0?(o.addTo(t,o),o.signum()<0?o.add(t):o):o},E.prototype.pow=function(t){return this.exp(t,new H)},E.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var i=e;e=r,r=i}var s=e.getLowestSetBit(),n=r.getLowestSetBit();if(n<0)return e;for(s<n&&(n=s),n>0&&(e.rShiftTo(n,e),r.rShiftTo(n,r));e.signum()>0;)(s=e.getLowestSetBit())>0&&e.rShiftTo(s,e),(s=r.getLowestSetBit())>0&&r.rShiftTo(s,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return n>0&&r.lShiftTo(n,r),r},E.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=K[K.length-1]){for(e=0;e<K.length;++e)if(r[0]==K[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<K.length;){for(var i=K[e],s=e+1;s<K.length&&i<q;)i*=K[s++];for(i=r.modInt(i);e<s;)if(i%K[e++]==0)return!1}return r.millerRabin(t)},E.prototype.square=function(){var t=x();return this.squareTo(t),t},G.prototype.init=function(t){var e,r,i;for(e=0;e<256;++e)this.S[e]=e;for(r=0,e=0;e<256;++e)r=r+this.S[e]+t[e%t.length]&255,i=this.S[e],this.S[e]=this.S[r],this.S[r]=i;this.i=0,this.j=0},G.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]},null==j){var $;if(j=new Array,M=0,void 0!==d&&(void 0!==d.crypto||void 0!==d.msCrypto)){var X=d.crypto||d.msCrypto;if(X.getRandomValues){var z=new Uint8Array(32);for(X.getRandomValues(z),$=0;$<32;++$)j[M++]=z[$]}else if("Netscape"==p.appName&&p.appVersion<"5"){var J=d.crypto.random(32);for($=0;$<J.length;++$)j[M++]=255&J.charCodeAt($)}}for(;M<256;)$=Math.floor(65536*Math.random()),j[M++]=$>>>8,j[M++]=255&$;M=0,W()}function Y(){if(null==V){for(W(),(V=new G).init(j),M=0;M<j.length;++M)j[M]=0;M=0}return V.next()}function Q(){}function Z(t,e){return new E(t,e)}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){this.x=e,this.q=t}function rt(t,e,r,i){this.curve=t,this.x=e,this.y=r,this.z=null==i?E.ONE:i,this.zinv=null}function it(t,e,r){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(r),this.infinity=new rt(this,null,null)}Q.prototype.nextBytes=function(t){var e;for(e=0;e<t.length;++e)t[e]=Y()},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=Z(t,16),this.e=parseInt(e,16)}},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=Z(t,16),this.e=parseInt(e,16),this.d=Z(r,16)}},tt.prototype.setPrivateEx=function(t,e,r,i,s,n,a,o){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=Z(t,16),this.e=parseInt(e,16),this.d=Z(r,16),this.p=Z(i,16),this.q=Z(s,16),this.dmp1=Z(n,16),this.dmq1=Z(a,16),this.coeff=Z(o,16)},tt.prototype.generate=function(t,e){var r=new Q,i=t>>1;this.e=parseInt(e,16);for(var s=new E(e,16),n=t/2-100,a=E.ONE.shiftLeft(n);;){for(;this.p=new E(t-i,1,r),0!=this.p.subtract(E.ONE).gcd(s).compareTo(E.ONE)||!this.p.isProbablePrime(10););for(;this.q=new E(i,1,r),0!=this.q.subtract(E.ONE).gcd(s).compareTo(E.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var o=this.p;this.p=this.q,this.q=o}var h=this.q.subtract(this.p).abs();if(!(h.bitLength()<n||h.compareTo(a)<=0)){var u=this.p.subtract(E.ONE),c=this.q.subtract(E.ONE),l=u.multiply(c);if(0==l.gcd(s).compareTo(E.ONE)&&(this.n=this.p.multiply(this.q),this.n.bitLength()==t)){this.d=s.modInverse(l),this.dmp1=this.d.mod(u),this.dmq1=this.d.mod(c),this.coeff=this.q.modInverse(this.p);break}}}this.isPrivate=!0},et.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},et.prototype.toBigInteger=function(){return this.x},et.prototype.negate=function(){return new et(this.q,this.x.negate().mod(this.q))},et.prototype.add=function(t){return new et(this.q,this.x.add(t.toBigInteger()).mod(this.q))},et.prototype.subtract=function(t){return new et(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},et.prototype.multiply=function(t){return new et(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},et.prototype.square=function(){return new et(this.q,this.x.square().mod(this.q))},et.prototype.divide=function(t){return new et(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},et.prototype.sqrt=function(){return new et(this.q,this.x.sqrt().mod(this.q))},rt.prototype.getX=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},rt.prototype.getY=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},rt.prototype.equals=function(t){return t==this||(this.isInfinity()?t.isInfinity():t.isInfinity()?this.isInfinity():!!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(E.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(E.ZERO))},rt.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(E.ZERO)&&!this.y.toBigInteger().equals(E.ZERO)},rt.prototype.negate=function(){return new rt(this.curve,this.x,this.y.negate(),this.z)},rt.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q),r=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q);if(E.ZERO.equals(r))return E.ZERO.equals(e)?this.twice():this.curve.getInfinity();var i=new E("3"),s=this.x.toBigInteger(),n=this.y.toBigInteger(),a=(t.x.toBigInteger(),t.y.toBigInteger(),r.square()),o=a.multiply(r),h=s.multiply(a),u=e.square().multiply(this.z),c=u.subtract(h.shiftLeft(1)).multiply(t.z).subtract(o).multiply(r).mod(this.curve.q),l=h.multiply(i).multiply(e).subtract(n.multiply(o)).subtract(u.multiply(e)).multiply(t.z).add(e.multiply(o)).mod(this.curve.q),g=o.multiply(this.z).multiply(t.z).mod(this.curve.q);return new rt(this.curve,this.curve.fromBigInteger(c),this.curve.fromBigInteger(l),g)},rt.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=new E("3"),e=this.x.toBigInteger(),r=this.y.toBigInteger(),i=r.multiply(this.z),s=i.multiply(r).mod(this.curve.q),n=this.curve.a.toBigInteger(),a=e.square().multiply(t);E.ZERO.equals(n)||(a=a.add(this.z.square().multiply(n)));var o=(a=a.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(s)).shiftLeft(1).multiply(i).mod(this.curve.q),h=a.multiply(t).multiply(e).subtract(s.shiftLeft(1)).shiftLeft(2).multiply(s).subtract(a.square().multiply(a)).mod(this.curve.q),u=i.square().multiply(i).shiftLeft(3).mod(this.curve.q);return new rt(this.curve,this.curve.fromBigInteger(o),this.curve.fromBigInteger(h),u)},rt.prototype.multiply=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,r=t,i=r.multiply(new E("3")),s=this.negate(),n=this,a=this.curve.q.subtract(t),o=a.multiply(new E("3")),h=new rt(this.curve,this.x,this.y),u=h.negate();for(e=i.bitLength()-2;e>0;--e){n=n.twice();var c=i.testBit(e);c!=r.testBit(e)&&(n=n.add(c?this:s))}for(e=o.bitLength()-2;e>0;--e){h=h.twice();var l=o.testBit(e);l!=a.testBit(e)&&(h=h.add(l?h:u))}return n},rt.prototype.multiplyTwo=function(t,e,r){var i;i=t.bitLength()>r.bitLength()?t.bitLength()-1:r.bitLength()-1;for(var s=this.curve.getInfinity(),n=this.add(e);i>=0;)s=s.twice(),t.testBit(i)?s=r.testBit(i)?s.add(n):s.add(this):r.testBit(i)&&(s=s.add(e)),--i;return s},it.prototype.getQ=function(){return this.q},it.prototype.getA=function(){return this.a},it.prototype.getB=function(){return this.b},it.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},it.prototype.getInfinity=function(){return this.infinity},it.prototype.fromBigInteger=function(t){return new et(this.q,t)},it.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:var e=t.substr(0,2),r=(t.substr(2),this.fromBigInteger(new E(o,16))),i=this.getA(),s=this.getB(),n=r.square().add(i).multiply(r).add(s).sqrt();return"03"==e&&(n=n.negate()),new rt(this,r,n);case 4:case 6:case 7:var a=(t.length-2)/2,o=t.substr(2,a),h=t.substr(a+2,a);return new rt(this,this.fromBigInteger(new E(o,16)),this.fromBigInteger(new E(h,16)));default:return null}},et.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},rt.prototype.getEncoded=function(t){var e=function(t,e){var r=t.toByteArrayUnsigned();if(e<r.length)r=r.slice(r.length-e);else for(;e>r.length;)r.unshift(0);return r},r=this.getX().toBigInteger(),i=this.getY().toBigInteger(),s=e(r,32);return t?i.isEven()?s.unshift(2):s.unshift(3):(s.unshift(4),s=s.concat(e(i,32))),s},rt.decodeFrom=function(t,e){e[0];var r=e.length-1,i=e.slice(1,1+r/2),s=e.slice(1+r/2,1+r);i.unshift(0),s.unshift(0);var n=new E(i),a=new E(s);return new rt(t,t.fromBigInteger(n),t.fromBigInteger(a))},rt.decodeFromHex=function(t,e){e.substr(0,2);var r=e.length-2,i=e.substr(2,r/2),s=e.substr(2+r/2,r/2),n=new E(i,16),a=new E(s,16);return new rt(t,t.fromBigInteger(n),t.fromBigInteger(a))},rt.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),r=t.y.subtract(this.y).divide(e),i=r.square().subtract(this.x).subtract(t.x),s=r.multiply(this.x.subtract(i)).subtract(this.y);return new rt(this.curve,i,s)},rt.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=this.curve.fromBigInteger(E.valueOf(2)),e=this.curve.fromBigInteger(E.valueOf(3)),r=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),i=r.square().subtract(this.x.multiply(t)),s=r.multiply(this.x.subtract(i)).subtract(this.y);return new rt(this.curve,i,s)},rt.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,r=t,i=r.multiply(new E("3")),s=this.negate(),n=this;for(e=i.bitLength()-2;e>0;--e){n=n.twice();var a=i.testBit(e);a!=r.testBit(e)&&(n=n.add2D(a?this:s))}return n},rt.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),r=this.curve.getA().toBigInteger(),i=this.curve.getB().toBigInteger(),s=this.curve.getQ(),n=e.multiply(e).mod(s),a=t.multiply(t).multiply(t).add(r.multiply(t)).add(i).mod(s);return n.equals(a)},rt.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},rt.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),r=this.getY().toBigInteger();if(e.compareTo(E.ONE)<0||e.compareTo(t.subtract(E.ONE))>0)throw new Error("x coordinate out of bounds");if(r.compareTo(E.ONE)<0||r.compareTo(t.subtract(E.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0};var st=function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),r={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function i(t,e,i){return e?r[e]:String.fromCharCode(parseInt(i,16))}var s=new String(""),n=Object.hasOwnProperty;return function(r,a){var o,h,u=r.match(t),c=u[0],l=!1;"{"===c?o={}:"["===c?o=[]:(o=[],l=!0);for(var g=[o],p=1-l,d=u.length;p<d;++p){var f;switch((c=u[p]).charCodeAt(0)){default:(f=g[0])[h||f.length]=+c,h=void 0;break;case 34:if(-1!==(c=c.substring(1,c.length-1)).indexOf("\\")&&(c=c.replace(e,i)),f=g[0],!h){if(!(f instanceof Array)){h=c||s;break}h=f.length}f[h]=c,h=void 0;break;case 91:f=g[0],g.unshift(f[h||f.length]=[]),h=void 0;break;case 93:case 125:g.shift();break;case 102:(f=g[0])[h||f.length]=!1,h=void 0;break;case 110:(f=g[0])[h||f.length]=null,h=void 0;break;case 116:(f=g[0])[h||f.length]=!0,h=void 0;break;case 123:f=g[0],g.unshift(f[h||f.length]={}),h=void 0}}if(l){if(1!==g.length)throw new Error;o=o[0]}else if(g.length)throw new Error;if(a){var y=function(t,e){var r=t[e];if(r&&"object"==typeof r){var i=null;for(var s in r)if(n.call(r,s)&&r!==t){var o=y(r,s);void 0!==o?r[s]=o:(i||(i=[]),i.push(s))}if(i)for(var h=i.length;--h>=0;)delete r[i[h]]}return a.call(t,e,r)};o=y({"":o},"")}return o}}();void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),nt.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){return Ht(t)},this.getPEMStringFromHex=function(t,e){return Et(t,e)},this.newObject=function(t){var e=nt.asn1,r=e.ASN1Object,i=e.DERBoolean,s=e.DERInteger,n=e.DERBitString,a=e.DEROctetString,o=e.DERNull,h=e.DERObjectIdentifier,u=e.DEREnumerated,c=e.DERUTF8String,l=e.DERNumericString,g=e.DERPrintableString,p=e.DERTeletexString,d=e.DERIA5String,f=e.DERUTCTime,y=e.DERGeneralizedTime,v=e.DERVisibleString,m=e.DERBMPString,S=e.DERSequence,E=e.DERSet,x=e.DERTaggedObject,A=e.ASN1Util.newObject;if(t instanceof e.ASN1Object)return t;var w=Object.keys(t);if(1!=w.length)throw new Error("key of param shall be only one.");var b=w[0];if(-1==":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+b+":"))throw new Error("undefined key: "+b);if("bool"==b)return new i(t[b]);if("int"==b)return new s(t[b]);if("bitstr"==b)return new n(t[b]);if("octstr"==b)return new a(t[b]);if("null"==b)return new o(t[b]);if("oid"==b)return new h(t[b]);if("enum"==b)return new u(t[b]);if("utf8str"==b)return new c(t[b]);if("numstr"==b)return new l(t[b]);if("prnstr"==b)return new g(t[b]);if("telstr"==b)return new p(t[b]);if("ia5str"==b)return new d(t[b]);if("utctime"==b)return new f(t[b]);if("gentime"==b)return new y(t[b]);if("visstr"==b)return new v(t[b]);if("bmpstr"==b)return new m(t[b]);if("asn1"==b)return new r(t[b]);if("seq"==b){for(var C=t[b],I=[],F=0;F<C.length;F++){var R=A(C[F]);I.push(R)}return new S({array:I})}if("set"==b){for(C=t[b],I=[],F=0;F<C.length;F++)R=A(C[F]),I.push(R);return new E({array:I})}if("tag"==b){var T=t[b];if("[object Array]"===Object.prototype.toString.call(T)&&3==T.length){var P=A(T[2]);return new x({tag:T[0],explicit:T[1],obj:P})}return new x(T)}},this.jsonToASN1HEX=function(t){return this.newObject(t).tohex()}},nt.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",r=parseInt(t.substr(0,2),16),i=(e=Math.floor(r/40)+"."+r%40,""),s=2;s<t.length;s+=2){var n=("00000000"+parseInt(t.substr(s,2),16).toString(2)).slice(-8);i+=n.substr(1,7),"0"==n.substr(0,1)&&(e=e+"."+new E(i,2).toString(10),i="")}return e},nt.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="",i=new E(t,10).toString(2),s=7-i.length%7;7==s&&(s=0);for(var n="",a=0;a<s;a++)n+="0";for(i=n+i,a=0;a<i.length-1;a+=7){var o=i.substr(a,7);a!=i.length-7&&(o="1"+o),r+=e(parseInt(o,2))}return r};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var i="",s=t.split("."),n=40*parseInt(s[0])+parseInt(s[1]);i+=e(n),s.splice(0,2);for(var a=0;a<s.length;a++)i+=r(s[a]);return i},nt.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=0,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 new Error("ASN.1 length too long to represent by 8x: n = "+t.toString(16));return(128+r).toString(16)+e},this.tohex=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.getEncodedHex=function(){return this.tohex()},this.getValueHex=function(){return this.tohex(),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)},nt.asn1.DERAbstractString=function(t){nt.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=ft(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))},jt(nt.asn1.DERAbstractString,nt.asn1.ASN1Object),nt.asn1.DERAbstractTime=function(t){nt.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 i=this.zeroPadding,s=this.localDateToUTC(t),n=String(s.getFullYear());"utc"==e&&(n=n.substr(2,2));var a=n+i(String(s.getMonth()+1),2)+i(String(s.getDate()),2)+i(String(s.getHours()),2)+i(String(s.getMinutes()),2)+i(String(s.getSeconds()),2);if(!0===r){var o=s.getMilliseconds();if(0!=o){var h=i(String(o),3);a=a+"."+(h=h.replace(/[0]+$/,""))}}return a+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.setByParam=function(t){this.hV=null,this.hTLV=null,this.params=t},this.getString=function(){},this.setString=function(t){this.hTLV=null,this.isModified=!0,null==this.params&&(this.params={}),this.params.str=t},this.setByDate=function(t){this.hTLV=null,this.isModified=!0,null==this.params&&(this.params={}),this.params.date=t},this.setByDateValue=function(t,e,r,i,s,n){var a=new Date(Date.UTC(t,e-1,r,i,s,n,0));this.setByDate(a)},this.getFreshValueHex=function(){return this.hV}},jt(nt.asn1.DERAbstractTime,nt.asn1.ASN1Object),nt.asn1.DERAbstractStructured=function(t){nt.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)},jt(nt.asn1.DERAbstractStructured,nt.asn1.ASN1Object),nt.asn1.DERBoolean=function(t){nt.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=0==t?"010100":"0101ff"},jt(nt.asn1.DERBoolean,nt.asn1.ASN1Object),nt.asn1.DERInteger=function(t){nt.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.params=null;var e=Ht;this.setByBigInteger=function(t){this.isModified=!0,this.params={bigint:t}},this.setByInteger=function(t){this.isModified=!0,this.params=t},this.setValueHex=function(t){this.isModified=!0,this.params={hex:t}},this.getFreshValueHex=function(){var t=this.params,r=null;if(null==t)throw new Error("value not set");if("object"==typeof t&&null!=t.hex)return this.hV=t.hex,this.hV;if("number"==typeof t)r=new E(String(t),10);else if(null!=t.int)r=new E(String(t.int),10);else{if(null==t.bigint)throw new Error("wrong parameter");r=t.bigint}return this.hV=e(r),this.hV},null!=t&&(this.params=t)},jt(nt.asn1.DERInteger,nt.asn1.ASN1Object),nt.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=nt.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.tohex()}nt.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),t+="0000000".substr(0,e);for(var r="",i=0;i<t.length-1;i+=8){var s=t.substr(i,8),n=parseInt(s,2).toString(16);1==n.length&&(n="0"+n),r+=n}this.hTLV=null,this.isModified=!0,this.hV="0"+e+r},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))},jt(nt.asn1.DERBitString,nt.asn1.ASN1Object),nt.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=nt.asn1.ASN1Util.newObject(t.obj);t.hex=e.tohex()}nt.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},jt(nt.asn1.DEROctetString,nt.asn1.DERAbstractString),nt.asn1.DERNull=function(){nt.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},jt(nt.asn1.DERNull,nt.asn1.ASN1Object),nt.asn1.DERObjectIdentifier=function(t){nt.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="",i=parseInt(t,10).toString(2),s=7-i.length%7;7==s&&(s=0);for(var n="",a=0;a<s;a++)n+="0";for(i=n+i,a=0;a<i.length-1;a+=7){var o=i.substr(a,7);a!=i.length-7&&(o="1"+o),r+=e(parseInt(o,2))}return r};try{if(!t.match(/^[0-9.]+$/))return null;var i="",s=t.split("."),n=40*parseInt(s[0],10)+parseInt(s[1],10);i+=e(n),s.splice(0,2);for(var a=0;a<s.length;a++)i+=r(s[a]);return i}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=nt.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)},jt(nt.asn1.DERObjectIdentifier,nt.asn1.ASN1Object),nt.asn1.DEREnumerated=function(t){nt.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=Ht(t)},this.setByInteger=function(t){var e=new E(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))},jt(nt.asn1.DEREnumerated,nt.asn1.ASN1Object),nt.asn1.DERUTF8String=function(t){nt.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},jt(nt.asn1.DERUTF8String,nt.asn1.DERAbstractString),nt.asn1.DERNumericString=function(t){nt.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},jt(nt.asn1.DERNumericString,nt.asn1.DERAbstractString),nt.asn1.DERPrintableString=function(t){nt.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},jt(nt.asn1.DERPrintableString,nt.asn1.DERAbstractString),nt.asn1.DERTeletexString=function(t){nt.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},jt(nt.asn1.DERTeletexString,nt.asn1.DERAbstractString),nt.asn1.DERIA5String=function(t){nt.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},jt(nt.asn1.DERIA5String,nt.asn1.DERAbstractString),nt.asn1.DERVisibleString=function(t){nt.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="1a"},jt(nt.asn1.DERVisibleString,nt.asn1.DERAbstractString),nt.asn1.DERBMPString=function(t){nt.asn1.DERBMPString.superclass.constructor.call(this,t),this.hT="1e"},jt(nt.asn1.DERBMPString,nt.asn1.DERAbstractString),nt.asn1.DERUTCTime=function(t){nt.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.params=void 0,this.getFreshValueHex=function(){var t=this.params;if(null==this.params&&(t={date:new Date}),"string"==typeof t){if(!t.match(/^[0-9]{12}Z$/)&&!t.match(/^[0-9]{12}\.[0-9]+Z$/))throw new Error("malformed string for UTCTime: "+t);this.hV=ct(t)}else if(null!=t.str)this.hV=ct(t.str);else if(null==t.date&&1==t.millis){var e=new Date;this.hV=ct(this.formatDate(e,"utc",!0))}else if(null!=t.date&&t.date instanceof Date){var r=!0===t.millis;this.hV=ct(this.formatDate(t.date,"utc",r))}else t instanceof Date&&(this.hV=ct(this.formatDate(t,"utc")));if(null==this.hV)throw new Error("parameter not specified properly for UTCTime");return this.hV},null!=t&&this.setByParam(t)},jt(nt.asn1.DERUTCTime,nt.asn1.DERAbstractTime),nt.asn1.DERGeneralizedTime=function(t){nt.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.params=t,this.getFreshValueHex=function(){var t=this.params;if(null==this.params&&(t={date:new Date}),"string"==typeof t){if(!t.match(/^[0-9]{14}Z$/)&&!t.match(/^[0-9]{14}\.[0-9]+Z$/))throw new Error("malformed string for GeneralizedTime: "+t);this.hV=ct(t)}else if(null!=t.str)this.hV=ct(t.str);else if(null==t.date&&1==t.millis){var e=new Date;this.hV=ct(this.formatDate(e,"gen",!0))}else if(null!=t.date&&t.date instanceof Date){var r=!0===t.millis;this.hV=ct(this.formatDate(t.date,"gen",r))}else t instanceof Date&&(this.hV=ct(this.formatDate(t,"gen")));if(null==this.hV)throw new Error("parameter not specified properly for GeneralizedTime");return this.hV},null!=t&&this.setByParam(t)},jt(nt.asn1.DERGeneralizedTime,nt.asn1.DERAbstractTime),nt.asn1.DERSequence=function(t){nt.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].tohex();return this.hV=t,this.hV}},jt(nt.asn1.DERSequence,nt.asn1.DERAbstractStructured),nt.asn1.DERSet=function(t){nt.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.tohex())}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)},jt(nt.asn1.DERSet,nt.asn1.DERAbstractStructured),nt.asn1.DERTaggedObject=function(t){nt.asn1.DERTaggedObject.superclass.constructor.call(this);var e=nt.asn1,r=ht,i=r.getV,s=(r.isASN1HEX,e.ASN1Util.newObject);this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.params={tag:"a0",explicit:!0},this.setASN1Object=function(t,e,r){this.params={tag:e,explicit:t,obj:r}},this.getFreshValueHex=function(){var t=this.params;if(null==t.explicit&&(t.explicit=!0),null!=t.tage&&(t.tag=t.tage,t.explicit=!0),null!=t.tagi&&(t.tag=t.tagi,t.explicit=!1),null!=t.str)this.hV=ft(t.str);else if(null!=t.hex)this.hV=t.hex;else{if(null==t.obj)throw new Error("str, hex nor obj not specified");var r;t.obj instanceof e.ASN1Object?r=t.obj.tohex():"object"==typeof t.obj&&(r=s(t.obj).tohex()),t.explicit?this.hV=r:this.hV=i(r,0)}return null==t.tag&&(t.tag="a0"),this.hT=t.tag,this.hTLV=null,this.isModified=!0,this.hV},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},jt(nt.asn1.DERTaggedObject,nt.asn1.ASN1Object);var nt,at,ot,ht=new function(){};function ut(t){for(var e="",r=0;r<t.length;r++){var i=t[r].toString(16);1==i.length&&(i="0"+i),e+=i}return e}function ct(t){return ut(function(t){for(var e=new Array,r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}(t))}function lt(t){return(t=(t=t.replace(/\=/g,"")).replace(/\+/g,"-")).replace(/\//g,"_")}function gt(t){return t.length%4==2?t+="==":t.length%4==3&&(t+="="),(t=t.replace(/-/g,"+")).replace(/_/g,"/")}function pt(t){return t.length%2==1&&(t="0"+t),lt(m(t))}function dt(t){return S(gt(t))}function ft(t){return At(Dt(t)).toLowerCase()}function yt(t){try{return decodeURIComponent(wt(t))}catch(t){return null}}function vt(t){return yt(function(t){for(var e=t.match(/.{1,2}/g),r=[],i=0;i<e.length;i++){var s=parseInt(e[i],16);161<=s&&s<=191?(r.push("c2"),r.push(e[i])):192<=s&&s<=255?(r.push("c3"),r.push((s-64).toString(16))):r.push(e[i])}return r.join("")}(t))}function mt(t){for(var e="",r=0;r<t.length-1;r+=2)e+=String.fromCharCode(parseInt(t.substr(r,2),16));return e}function St(t){for(var e="",r=0;r<t.length;r++)e+=("0"+t.charCodeAt(r).toString(16)).slice(-2);return e}function Et(t,e){return"-----BEGIN "+e+"-----\r\n"+function(t){return(t=t.replace(new RegExp("(.{64})","g"),"$1\r\n")).replace(/\s+$/,"")}(function(t){return m(t)}(t))+"\r\n-----END "+e+"-----\r\n"}function xt(t,e){if(-1==t.indexOf("-----BEGIN "))throw new Error("can't find PEM header");return function(t){return S(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 At(t){return t.replace(/%/g,"")}function wt(t){return t.replace(/(..)/g,"%$1")}function bt(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 i=":".repeat(7-r+2),s=(t=t.replace("::",i)).split(":");if(8!=s.length)throw e;for(var n=0;n<8;n++)s[n]=("0000"+s[n]).slice(-4);return s.join("")}function Ct(t){if(!t.match(/^[0-9A-Fa-f]{32}$/))throw new Error("malformed IPv6 address: "+t);var e=(t=t.toLowerCase()).match(/.{1,4}/g);e=e.map(function(t){return t.replace(/^0+/,"")}),e=e.map(function(t){return""==t?"0":t});var r=(t=":"+e.join(":")+":").match(/:(0:){2,}/g);if(null==r)return t.slice(1,-1);var i=r.sort().slice(-1)[0];return"::"!=(t=t.replace(i.substr(0,i.length-1),":")).substr(0,2)&&(t=t.substr(1)),"::"!=t.substr(-2,2)&&(t=t.substr(0,t.length-1)),t}function It(t){var e=new Error("malformed hex value");if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8==t.length)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}else if(16==t.length)try{return It(t.substr(0,8))+"/"+Ft(t.substr(8))}catch(t){throw e}else{if(32==t.length)return Ct(t);if(64!=t.length)return t;try{return Ct(t.substr(0,32))+"/"+Ft(t.substr(32))}catch(t){throw e}}}function Ft(t){var e,r=new Error("malformed mask");try{e=new E(t,16).toString(2)}catch(t){throw r}if(!e.match(/^1*0*$/))throw r;return e.replace(/0+$/,"").length}function Rt(t){var e=new Error("malformed IP address");if(!(t=t.toLowerCase(t)).match(/^[0-9a-f.:/]+$/))throw e;if(!t.match(/^[0-9.]+$/)){var r;if(t.match(/^[0-9.]+\/[0-9]+$/))return Rt((r=t.split("/"))[0])+Tt(parseInt(r[1]),32);if(t.match(/^[0-9a-f:]+$/)&&-1!==t.indexOf(":"))return bt(t);if(t.match(/^[0-9a-f:]+\/[0-9]+$/)&&-1!==t.indexOf(":"))return bt((r=t.split("/"))[0])+Tt(parseInt(r[1]),128);throw e}var i=t.split(".");if(4!==i.length)throw e;var s="";try{for(var n=0;n<4;n++)s+=("0"+parseInt(i[n]).toString(16)).slice(-2);return s}catch(t){throw e}}function Tt(t,e){return 32==e&&0==t?"00000000":128==e&&0==t?"00000000000000000000000000000000":new E(Array(t+1).join("1")+Array(e-t+1).join("0"),2).toString(16)}function Pt(t){var e=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 i=128|63&r;return yt((192|(7&e)<<3|(192&r)>>6).toString(16)+i.toString(16))}i=128|(15&e)<<2|(192&r)>>6;var s=128|63&r;return yt((224|(240&e)>>4).toString(16)+i.toString(16)+s.toString(16))});return e.join("")}function Dt(t){for(var e=encodeURIComponent(t),r="",i=0;i<e.length;i++)"%"==e[i]?(r+=e.substr(i,3),i+=2):r=r+"%"+ct(e[i]);return r}function Nt(t){return!(t.length%2!=0||!t.match(/^[0-9a-f]+$/)&&!t.match(/^[0-9A-F]+$/))}function Ot(t){return!!t.match(/^[0-9A-Za-z-_.]+$/)}function _t(t){return t.length%2==1?"0"+t:t.substr(0,1)>"7"?"00"+t:t}function Bt(t){if(!Nt(t))return null;try{var e=[],r=t.substr(0,2),i=parseInt(r,16);e[0]=new String(Math.floor(i/40)),e[1]=new String(i%40);for(var s=t.substr(2),n=[],a=0;a<s.length/2;a++)n.push(parseInt(s.substr(2*a,2),16));var o=[],h="";for(a=0;a<n.length;a++)128&n[a]?h+=kt((127&n[a]).toString(2),7):(h+=kt((127&n[a]).toString(2),7),o.push(new String(parseInt(h,2))),h="");var u=e.join(".");return o.length>0&&(u=u+"."+o.join(".")),u}catch(t){return null}}function Lt(t){return Ht(new E(String(t),10))}function Ht(t){var e=t.toString(16);if("-"!=e.substr(0,1))return e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e),e;var r=e.substr(1).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var i="",s=0;s<r;s++)i+="f";return new E(i,16).xor(t).add(E.ONE).toString(16).replace(/^-/,"")}ht.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},ht.getL=function(t,e){var r=ht.getLblen(t,e);return r<1?"":t.substr(e+2,2*r)},ht.getVblen=function(t,e){var r;return""==(r=ht.getL(t,e))?-1:("8"===r.substr(0,1)?new E(r.substr(2),16):new E(r,16)).intValue()},ht.getVidx=function(t,e){var r=ht.getLblen(t,e);return r<0?r:e+2*(r+1)},ht.getV=function(t,e){var r=ht.getVidx(t,e),i=ht.getVblen(t,e);return t.substr(r,2*i)},ht.getTLV=function(t,e){return t.substr(e,2)+ht.getL(t,e)+ht.getV(t,e)},ht.getTLVblen=function(t,e){return 2+2*ht.getLblen(t,e)+2*ht.getVblen(t,e)},ht.getNextSiblingIdx=function(t,e){return ht.getVidx(t,e)+2*ht.getVblen(t,e)},ht.getChildIdx=function(t,e){var r,i,s,n=ht,a=[];r=n.getVidx(t,e),i=2*n.getVblen(t,e),"03"==t.substr(e,2)&&(r+=2,i-=2),s=0;for(var o=r;s<=i;){var h=n.getTLVblen(t,o);if((s+=h)<=i&&a.push(o),o+=h,s>=i)break}return a},ht.getNthChildIdx=function(t,e,r){return ht.getChildIdx(t,e)[r]},ht.getIdxbyList=function(t,e,r,i){var s,n,a=ht;return 0==r.length?void 0!==i&&t.substr(e,2)!==i?-1:e:(s=r.shift())>=(n=a.getChildIdx(t,e)).length?-1:a.getIdxbyList(t,n[s],r,i)},ht.getIdxbyListEx=function(t,e,r,i){var s,n,a=ht;if(0==r.length)return void 0!==i&&t.substr(e,2)!==i?-1:e;s=r.shift(),n=a.getChildIdx(t,e);for(var o=0,h=0;h<n.length;h++){var u=t.substr(n[h],2);if("number"==typeof s&&!a.isContextTag(u)&&o==s||"string"==typeof s&&a.isContextTag(u,s))return a.getIdxbyListEx(t,n[h],r,i);a.isContextTag(u)||o++}return-1},ht.getTLVbyList=function(t,e,r,i){var s=ht,n=s.getIdxbyList(t,e,r,i);return-1==n||n>=t.length?null:s.getTLV(t,n)},ht.getTLVbyListEx=function(t,e,r,i){var s=ht,n=s.getIdxbyListEx(t,e,r,i);return-1==n?null:s.getTLV(t,n)},ht.getVbyList=function(t,e,r,i,s){var n,a,o=ht;return-1==(n=o.getIdxbyList(t,e,r,i))||n>=t.length?null:(a=o.getV(t,n),!0===s&&(a=a.substr(2)),a)},ht.getVbyListEx=function(t,e,r,i,s){var n,a,o=ht;return-1==(n=o.getIdxbyListEx(t,e,r,i))?null:(a=o.getV(t,n),"03"==t.substr(n,2)&&!1!==s&&(a=a.substr(2)),a)},ht.getInt=function(t,e,r){null==r&&(r=-1);try{var i=t.substr(e,2);if("02"!=i&&"03"!=i)return r;var s=ht.getV(t,e);return"02"==i?parseInt(s,16):function(t){if(t.length%2!=0)return-1;if(null==(t=t.toLowerCase()).match(/^[0-9a-f]+$/))return-1;try{var e=t.substr(0,2);if("00"==e)return parseInt(t.substr(2),16);var r=parseInt(e,16);if(r>7)return-1;var i=t.substr(2),s=parseInt(i,16).toString(2);"0"==s&&(s="00000000"),s=s.slice(0,0-r);var n=parseInt(s,2);return NaN==n?-1:n}catch(t){return-1}}(s)}catch(t){return r}},ht.getOID=function(t,e,r){null==r&&(r=null);try{return"06"!=t.substr(e,2)?r:Bt(ht.getV(t,e))}catch(t){return r}},ht.getOIDName=function(t,e,r){null==r&&(r=null);try{var i=ht.getOID(t,e,r);if(i==r)return r;var s=nt.asn1.x509.OID.oid2name(i);return""==s?i:s}catch(t){return r}},ht.getString=function(t,e,r){null==r&&(r=null);try{return mt(ht.getV(t,e))}catch(t){return r}},ht.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},r=[],i=t.substr(0,2),s=parseInt(i,16);r[0]=new String(Math.floor(s/40)),r[1]=new String(s%40);for(var n=t.substr(2),a=[],o=0;o<n.length/2;o++)a.push(parseInt(n.substr(2*o,2),16));var h=[],u="";for(o=0;o<a.length;o++)128&a[o]?u+=e((127&a[o]).toString(2),7):(u+=e((127&a[o]).toString(2),7),h.push(new String(parseInt(u,2))),u="");var c=r.join(".");return h.length>0&&(c=c+"."+h.join(".")),c},ht.dump=function(t,e,r,i){var s=ht,n=s.getV,a=s.dump,o=s.getChildIdx,h=t;t instanceof nt.asn1.ASN1Object&&(h=t.tohex());var u=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===i&&(i="");var c,l=e.ommit_long_octet;if("01"==(c=h.substr(r,2)))return"00"==(g=n(h,r))?i+"BOOLEAN FALSE\n":i+"BOOLEAN TRUE\n";if("02"==c)return i+"INTEGER "+u(g=n(h,r),l)+"\n";if("03"==c){var g=n(h,r);return s.isASN1HEX(g.substr(2))?(x=i+"BITSTRING, encapsulates\n")+a(g.substr(2),e,0,i+" "):i+"BITSTRING "+u(g,l)+"\n"}if("04"==c)return g=n(h,r),s.isASN1HEX(g)?(x=i+"OCTETSTRING, encapsulates\n")+a(g,e,0,i+" "):i+"OCTETSTRING "+u(g,l)+"\n";if("05"==c)return i+"NULL\n";if("06"==c){var p=n(h,r),d=nt.asn1.ASN1Util.oidHexToInt(p),f=nt.asn1.x509.OID.oid2name(d),y=d.replace(/\./g," ");return""!=f?i+"ObjectIdentifier "+f+" ("+y+")\n":i+"ObjectIdentifier ("+y+")\n"}if("0a"==c)return i+"ENUMERATED "+parseInt(n(h,r))+"\n";if("0c"==c)return i+"UTF8String '"+yt(n(h,r))+"'\n";if("13"==c)return i+"PrintableString '"+yt(n(h,r))+"'\n";if("14"==c)return i+"TeletexString '"+yt(n(h,r))+"'\n";if("16"==c)return i+"IA5String '"+yt(n(h,r))+"'\n";if("17"==c)return i+"UTCTime "+yt(n(h,r))+"\n";if("18"==c)return i+"GeneralizedTime "+yt(n(h,r))+"\n";if("1a"==c)return i+"VisualString '"+yt(n(h,r))+"'\n";if("1e"==c)return i+"BMPString '"+Pt(n(h,r))+"'\n";if("30"==c){if("3000"==h.substr(r,4))return i+"SEQUENCE {}\n";x=i+"SEQUENCE\n";var v=e;if((2==(E=o(h,r)).length||3==E.length)&&"06"==h.substr(E[0],2)&&"04"==h.substr(E[E.length-1],2)){f=s.oidname(n(h,E[0]));var m=JSON.parse(JSON.stringify(e));m.x509ExtName=f,v=m}for(var S=0;S<E.length;S++)x+=a(h,v,E[S],i+" ");return x}if("31"==c){x=i+"SET\n";var E=o(h,r);for(S=0;S<E.length;S++)x+=a(h,e,E[S],i+" ");return x}if(128&(c=parseInt(c,16))){var x,A=31&c;if(32&c){for(x=i+"["+A+"]\n",E=o(h,r),S=0;S<E.length;S++)x+=a(h,e,E[S],i+" ");return x}return g=n(h,r),ht.isASN1HEX(g)?(x=i+"["+A+"]\n")+a(g,e,0,i+" "):(("68747470"==g.substr(0,8)||"subjectAltName"===e.x509ExtName&&2==A)&&(g=yt(g)),i+"["+A+"] "+g+"\n")}return i+"UNKNOWN("+c+") "+n(h,r)+"\n"},ht.parse=function(t){var e=ht,r=e.parse,i=e.isASN1HEX,s=e.getV,n=e.getTLV,a=e.getChildIdx,o=nt.asn1,h=o.ASN1Util.oidHexToInt,u=o.x509.OID.oid2name,c=yt,l=Pt,g=vt,p={"0c":"utf8str",12:"numstr",13:"prnstr",14:"telstr",16:"ia5str",17:"utctime",18:"gentime","1a":"visstr","1e":"bmpstr",30:"seq",31:"set"},d=t.substr(0,2),f={},y=s(t,0);if("01"==d)return"0101ff"==t?{bool:!0}:{bool:!1};if("02"==d)return{int:{hex:y}};if("03"==d)try{if("00"!=y.substr(0,2))throw"not encap";var v=y.substr(2);if(!i(v))throw"not encap";return{bitstr:{obj:r(v)}}}catch(t){var m=null;return y.length<=10&&(m=function(t){if("string"!=typeof t)return null;if(t.length%2!=0)return null;if(!t.match(/^[0-9a-f]+$/))return null;try{var e=parseInt(t.substr(0,2),16);if(e<0||7<e)return null;for(var r=t.substr(2),i="",s=0;s<r.length;s+=2){var n=r.substr(s,2),a=parseInt(n,16).toString(2);i+=a=("0000000"+a).slice(-8)}return i.substr(0,i.length-e)}catch(t){return null}}(y)),null==m?{bitstr:{hex:y}}:{bitstr:{bin:m}}}else if("04"==d)try{if(!i(y))throw"not encap";return{octstr:{obj:r(y)}}}catch(t){return{octstr:{hex:y}}}else{if("05"==d)return{null:""};if("06"==d){var S=h(y),E=u(S);return""==E?{oid:S}:{oid:E}}if("0a"==d)return y.length>4?{enum:{hex:y}}:{enum:parseInt(y,16)};if("30"==d||"31"==d)return f[p[d]]=function(t){for(var e=[],i=a(t,0),s=0;s<i.length;s++){var o=i[s],h=n(t,o),u=r(h);e.push(u)}return e}(t),f;if("14"==d){var x=g(y);return f[p[d]]={str:x},f}if("1e"==d)return x=l(y),f[p[d]]={str:x},f;if(-1!=":0c:12:13:16:17:18:1a:".indexOf(d))return x=c(y),f[p[d]]={str:x},f;if(d.match(/^8[0-9]$/))return null==(x=c(y))|""==x||null!=x.match(/[\x00-\x1F\x7F-\x9F]/)||null!=x.match(/[\u0000-\u001F\u0080–\u009F]/)?{tag:{tag:d,explicit:!1,hex:y}}:{tag:{tag:d,explicit:!1,str:x}};if(!d.match(/^a[0-9]$/)){var A=new nt.asn1.ASN1Object;return A.hV=y,{asn1:{tlv:d+A.getLengthHexFromValue()+y}}}try{if(!i(y))throw new Error("not encap");return{tag:{tag:d,explicit:!0,obj:r(y)}}}catch(t){return{tag:{tag:d,explicit:!0,hex:y}}}}},ht.isContextTag=function(t,e){var r,i;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]+\]$/)&&!((i=parseInt(e.substr(1,e.length-1),10))>31)&&128==(192&r)&&(31&r)==i}catch(t){return!1}},ht.isASN1HEX=function(t){var e=ht;if(t.length%2==1)return!1;var r=e.getVblen(t,0),i=t.substr(0,2),s=e.getL(t,0);return t.length-i.length-s.length==2*r},ht.checkStrictDER=function(t,e,r,i,s){var n=ht;if(void 0===r){if("string"!=typeof t)throw new Error("not hex string");if(t=t.toLowerCase(),!nt.lang.String.isHex(t))throw new Error("not hex string");r=t.length,s=(i=t.length/2)<128?1:Math.ceil(i.toString(16))+1}if(n.getL(t,e).length>2*s)throw new Error("L of TLV too long: idx="+e);var a=n.getVblen(t,e);if(a>i)throw new Error("value of L too long than hex: idx="+e);var o=n.getTLV(t,e),h=o.length-2-n.getL(t,e).length;if(h!==2*a)throw new Error("V string length and L's value not the same:"+h+"/"+2*a);if(0===e&&t.length!=o.length)throw new Error("total length and TLV length unmatch:"+t.length+"!="+o.length);var u=t.substr(e,2);if("02"===u){var c=n.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(u,16)){for(var l=n.getVblen(t,e),g=0,p=n.getChildIdx(t,e),d=0;d<p.length;d++)g+=n.getTLV(t,p[d]).length,n.checkStrictDER(t,p[d],r,i,s);if(2*l!=g)throw new Error("sum of children's TLV length and L unmatch: "+2*l+"!="+g)}},ht.oidname=function(t){var e=nt.asn1;nt.lang.String.isHex(t)&&(t=e.ASN1Util.oidHexToInt(t));var r=e.x509.OID.oid2name(t);return""===r&&(r=t),r},void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),void 0!==nt.asn1.x509&&nt.asn1.x509||(nt.asn1.x509={}),nt.asn1.x509.Certificate=function(t){nt.asn1.x509.Certificate.superclass.constructor.call(this);var e=nt.asn1,r=e.DERBitString,i=e.DERSequence,s=e.x509,n=s.TBSCertificate,a=s.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.tohex(),i=new nt.crypto.Signature({alg:e});i.init(t.cakey),i.updateHex(r),t.sighex=i.sign()},this.getPEM=function(){return Et(this.tohex(),"CERTIFICATE")},this.tohex=function(){var t=this.params;if(null!=t.tbsobj&&null!=t.tbsobj||(t.tbsobj=new n(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 a({name:t.sigalg})),e.push(new r({hex:"00"+t.sighex})),new i({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&(this.params=t)},jt(nt.asn1.x509.Certificate,nt.asn1.ASN1Object),nt.asn1.x509.TBSCertificate=function(t){nt.asn1.x509.TBSCertificate.superclass.constructor.call(this);var e=nt.asn1,r=e.x509,i=e.DERTaggedObject,s=e.DERInteger,n=e.DERSequence,a=r.AlgorithmIdentifier,o=r.Time,h=r.X500Name,u=r.Extensions,c=r.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=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 i({obj:new s({int:r})});t.push(l)}return t.push(new s(e.serial)),t.push(new a({name:e.sigalg})),t.push(new h(e.issuer)),t.push(new n({array:[new o(e.notbefore),new o(e.notafter)]})),t.push(new h(e.subject)),t.push(new c(Mt.getKey(e.sbjpubkey))),void 0!==e.ext&&e.ext.length>0&&t.push(new i({tag:"a3",obj:new u(e.ext)})),new nt.asn1.DERSequence({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.x509.TBSCertificate,nt.asn1.ASN1Object),nt.asn1.x509.Extensions=function(t){nt.asn1.x509.Extensions.superclass.constructor.call(this);var e=nt.asn1,r=e.DERSequence,i=e.x509;this.aParam=[],this.setByParam=function(t){this.aParam=t},this.tohex=function(){for(var t=[],e=0;e<this.aParam.length;e++){var s=this.aParam[e],n=s.extname,a=null;if(null!=s.extn)a=new i.PrivateExtension(s);else if("subjectKeyIdentifier"==n)a=new i.SubjectKeyIdentifier(s);else if("keyUsage"==n)a=new i.KeyUsage(s);else if("subjectAltName"==n)a=new i.SubjectAltName(s);else if("issuerAltName"==n)a=new i.IssuerAltName(s);else if("basicConstraints"==n)a=new i.BasicConstraints(s);else if("nameConstraints"==n)a=new i.NameConstraints(s);else if("cRLDistributionPoints"==n)a=new i.CRLDistributionPoints(s);else if("certificatePolicies"==n)a=new i.CertificatePolicies(s);else if("policyMappings"==n)a=new i.PolicyMappings(s);else if("policyConstraints"==n)a=new i.PolicyConstraints(s);else if("inhibitAnyPolicy"==n)a=new i.InhibitAnyPolicy(s);else if("authorityKeyIdentifier"==n)a=new i.AuthorityKeyIdentifier(s);else if("extKeyUsage"==n)a=new i.ExtKeyUsage(s);else if("authorityInfoAccess"==n)a=new i.AuthorityInfoAccess(s);else if("cRLNumber"==n)a=new i.CRLNumber(s);else if("cRLReason"==n)a=new i.CRLReason(s);else if("ocspNonce"==n)a=new i.OCSPNonce(s);else if("ocspNoCheck"==n)a=new i.OCSPNoCheck(s);else if("adobeTimeStamp"==n)a=new i.AdobeTimeStamp(s);else{if("subjectDirectoryAttributes"!=n)throw new Error("extension not supported:"+JSON.stringify(s));a=new i.SubjectDirectoryAttributes(s)}null!=a&&t.push(a)}return new r({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.x509.Extensions,nt.asn1.ASN1Object),nt.asn1.x509.Extension=function(t){nt.asn1.x509.Extension.superclass.constructor.call(this);var e=nt.asn1,r=e.DERObjectIdentifier,i=e.DEROctetString,s=(e.DERBitString,e.DERBoolean),n=e.DERSequence;this.tohex=function(){var t=new r({oid:this.oid}),e=new i({hex:this.getExtnValueHex()}),a=new Array;return a.push(t),this.critical&&a.push(new s),a.push(e),new n({array:a}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},jt(nt.asn1.x509.Extension,nt.asn1.ASN1Object),nt.asn1.x509.KeyUsage=function(t){nt.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=Error,r={digitalSignature:0,nonRepudiation:1,keyEncipherment:2,dataEncipherment:3,keyAgreement:4,keyCertSign:5,cRLSign:6,encipherOnly:7,decipherOnly:8};this.getExtnValueHex=function(){var t=this.getBinValue();return this.asn1ExtnValue=new nt.asn1.DERBitString({bin:t}),this.asn1ExtnValue.tohex()},this.getBinValue=function(){var t=this.params;if("object"!=typeof t||"object"!=typeof t.names&&"string"!=typeof t.bin)throw new e("parameter not yet set");if(null!=t.names)return Ut(t.names,r);if(null!=t.bin)return t.bin;throw new e("parameter not set properly")},this.oid="2.5.29.15",void 0!==t&&(this.params=t)},jt(nt.asn1.x509.KeyUsage,nt.asn1.x509.Extension),nt.asn1.x509.BasicConstraints=function(t){nt.asn1.x509.BasicConstraints.superclass.constructor.call(this,t);var e=nt.asn1,r=e.DERBoolean,i=e.DERInteger,s=e.DERSequence;this.getExtnValueHex=function(){var t=new Array;this.cA&&t.push(new r),this.pathLen>-1&&t.push(new i({int:this.pathLen}));var e=new s({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.tohex()},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))},jt(nt.asn1.x509.BasicConstraints,nt.asn1.x509.Extension),nt.asn1.x509.CRLDistributionPoints=function(t){nt.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=nt.asn1,r=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.setByDPArray=function(t){for(var i=[],s=0;s<t.length;s++)if(t[s]instanceof nt.asn1.ASN1Object)i.push(t[s]);else{var n=new r.DistributionPoint(t[s]);i.push(n)}this.asn1ExtnValue=new e.DERSequence({array:i})},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))},jt(nt.asn1.x509.CRLDistributionPoints,nt.asn1.x509.Extension),nt.asn1.x509.DistributionPoint=function(t){nt.asn1.x509.DistributionPoint.superclass.constructor.call(this);var e=nt.asn1,r=e.x509.DistributionPointName;this.tohex=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.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},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}]})))},jt(nt.asn1.x509.DistributionPoint,nt.asn1.ASN1Object),nt.asn1.x509.DistributionPointName=function(t){nt.asn1.x509.DistributionPointName.superclass.constructor.call(this);var e=nt.asn1,r=e.DERTaggedObject;if(this.tohex=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.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},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)}},jt(nt.asn1.x509.DistributionPointName,nt.asn1.ASN1Object),nt.asn1.x509.CertificatePolicies=function(t){nt.asn1.x509.CertificatePolicies.superclass.constructor.call(this,t);var e=nt.asn1,r=e.x509,i=e.DERSequence,s=r.PolicyInformation;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++)t.push(new s(this.params.array[e]));var r=new i({array:t});return this.asn1ExtnValue=r,this.asn1ExtnValue.tohex()},this.oid="2.5.29.32",void 0!==t&&(this.params=t)},jt(nt.asn1.x509.CertificatePolicies,nt.asn1.x509.Extension),nt.asn1.x509.PolicyInformation=function(t){nt.asn1.x509.PolicyInformation.superclass.constructor.call(this,t);var e=nt.asn1,r=e.DERSequence,i=e.DERObjectIdentifier,s=e.x509.PolicyQualifierInfo;this.params=null,this.tohex=function(){if(void 0===this.params.policyoid&&void 0===this.params.array)throw new Error("parameter oid and array missing");var t=[new i(this.params.policyoid)];if(void 0!==this.params.array){for(var e=[],n=0;n<this.params.array.length;n++)e.push(new s(this.params.array[n]));e.length>0&&t.push(new r({array:e}))}return new r({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},jt(nt.asn1.x509.PolicyInformation,nt.asn1.ASN1Object),nt.asn1.x509.PolicyQualifierInfo=function(t){nt.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,t);var e=nt.asn1,r=e.DERSequence,i=e.DERIA5String,s=e.DERObjectIdentifier,n=e.x509.UserNotice;this.params=null,this.tohex=function(){return void 0!==this.params.cps?new r({array:[new s({oid:"1.3.6.1.5.5.7.2.1"}),new i({str:this.params.cps})]}).tohex():null!=this.params.unotice?new r({array:[new s({oid:"1.3.6.1.5.5.7.2.2"}),new n(this.params.unotice)]}).tohex():void 0},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},jt(nt.asn1.x509.PolicyQualifierInfo,nt.asn1.ASN1Object),nt.asn1.x509.UserNotice=function(t){nt.asn1.x509.UserNotice.superclass.constructor.call(this,t);var e=nt.asn1.DERSequence,r=(nt.asn1.DERInteger,nt.asn1.x509.DisplayText),i=nt.asn1.x509.NoticeReference;this.params=null,this.tohex=function(){var t=[];return void 0!==this.params.noticeref&&t.push(new i(this.params.noticeref)),void 0!==this.params.exptext&&t.push(new r(this.params.exptext)),new e({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},jt(nt.asn1.x509.UserNotice,nt.asn1.ASN1Object),nt.asn1.x509.NoticeReference=function(t){nt.asn1.x509.NoticeReference.superclass.constructor.call(this,t);var e=nt.asn1.DERSequence,r=nt.asn1.DERInteger,i=nt.asn1.x509.DisplayText;this.params=null,this.tohex=function(){var t=[];if(void 0!==this.params.org&&t.push(new i(this.params.org)),void 0!==this.params.noticenum){for(var s=[],n=this.params.noticenum,a=0;a<n.length;a++)s.push(new r(n[a]));t.push(new e({array:s}))}if(0==t.length)throw new Error("parameter is empty");return new e({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},jt(nt.asn1.x509.NoticeReference,nt.asn1.ASN1Object),nt.asn1.x509.DisplayText=function(t){nt.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"))},jt(nt.asn1.x509.DisplayText,nt.asn1.DERAbstractString),nt.asn1.x509.PolicyMappings=function(t){nt.asn1.x509.PolicyMappings.superclass.constructor.call(this,t);var e=nt.asn1,r=(e.x509,e.ASN1Util.newObject);this.params=null,this.getExtnValueHex=function(){for(var t=this.params,e=[],i=0;i<t.array.length;i++){var s=t.array[i];e.push({seq:[{oid:s[0]},{oid:s[1]}]})}return this.asn1ExtnValue=r({seq:e}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.33",void 0!==t&&(this.params=t)},jt(nt.asn1.x509.PolicyMappings,nt.asn1.x509.Extension),nt.asn1.x509.PolicyConstraints=function(t){nt.asn1.x509.PolicyConstraints.superclass.constructor.call(this,t);var e=nt.asn1,r=(e.x509,e.ASN1Util.newObject);this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[];return null!=t.reqexp&&e.push({tag:{tagi:"80",obj:{int:t.reqexp}}}),null!=t.inhibit&&e.push({tag:{tagi:"81",obj:{int:t.inhibit}}}),this.asn1ExtnValue=r({seq:e}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.36",void 0!==t&&(this.params=t)},jt(nt.asn1.x509.PolicyConstraints,nt.asn1.x509.Extension),nt.asn1.x509.InhibitAnyPolicy=function(t){nt.asn1.x509.InhibitAnyPolicy.superclass.constructor.call(this,t);var e=nt.asn1,r=(e.x509,e.ASN1Util.newObject);this.params=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=r({int:this.params.skip}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.54",void 0!==t&&(this.params=t)},jt(nt.asn1.x509.InhibitAnyPolicy,nt.asn1.x509.Extension),nt.asn1.x509.NameConstraints=function(t){nt.asn1.x509.NameConstraints.superclass.constructor.call(this,t);var e=nt.asn1,r=e.x509,i=e.ASN1Util.newObject,s=r.GeneralSubtree;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[];if(null!=t.permit&&null!=t.permit.length){for(var r=[],n=0;n<t.permit.length;n++)r.push(new s(t.permit[n]));e.push({tag:{tagi:"a0",obj:{seq:r}}})}if(null!=t.exclude&&null!=t.exclude.length){var a=[];for(n=0;n<t.exclude.length;n++)a.push(new s(t.exclude[n]));e.push({tag:{tagi:"a1",obj:{seq:a}}})}return this.asn1ExtnValue=i({seq:e}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.30",void 0!==t&&(this.params=t)},jt(nt.asn1.x509.NameConstraints,nt.asn1.x509.Extension),nt.asn1.x509.GeneralSubtree=function(t){nt.asn1.x509.GeneralSubtree.superclass.constructor.call(this);var e=nt.asn1,r=e.x509.GeneralName,i=e.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params,e=[new r(t)];return null!=t.min&&e.push({tag:{tagi:"80",obj:{int:t.min}}}),null!=t.max&&e.push({tag:{tagi:"81",obj:{int:t.max}}}),i({seq:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.x509.GeneralSubtree,nt.asn1.ASN1Object),nt.asn1.x509.ExtKeyUsage=function(t){nt.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=nt.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new e.DERSequence;for(var r=0;r<t.length;r++){var i=new e.DERObjectIdentifier(t[r]);this.asn1ExtnValue.appendASN1Object(i)}},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="2.5.29.37",void 0!==t&&void 0!==t.array&&this.setPurposeArray(t.array)},jt(nt.asn1.x509.ExtKeyUsage,nt.asn1.x509.Extension),nt.asn1.x509.AuthorityKeyIdentifier=function(t){nt.asn1.x509.AuthorityKeyIdentifier.superclass.constructor.call(this,t);var e=nt,r=e.asn1,i=r.DERTaggedObject,s=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 i({explicit:!1,tag:"80",obj:this.asn1KID})),this.asn1CertIssuer&&t.push(new i({explicit:!1,tag:"a1",obj:new s([{dn:this.asn1CertIssuer}])})),this.asn1CertSN&&t.push(new i({explicit:!1,tag:"82",obj:this.asn1CertSN}));var e=new r.DERSequence({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.tohex()},this.setKIDByParam=function(t){if(void 0!==t.str||void 0!==t.hex)this.asn1KID=new nt.asn1.DEROctetString(t);else if("object"==typeof t&&nt.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN ")){var e=t;"string"==typeof t&&(e=Mt.getKey(t));var r=Mt.getKeyID(e);this.asn1KID=new nt.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 nt.asn1.x509.X500Name(t):"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&-1!=t.indexOf("CERTIFICATE")&&(this.asn1CertIssuer=new nt.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 nt.asn1.DERInteger(t);else if("string"==typeof t&&-1!=t.indexOf("BEGIN ")&&t.indexOf("CERTIFICATE")){var e=new Wt;e.readCertPEM(t);var r=e.getSerialNumberHex();this.asn1CertSN=new nt.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)))},jt(nt.asn1.x509.AuthorityKeyIdentifier,nt.asn1.x509.Extension),nt.asn1.x509.SubjectKeyIdentifier=function(t){nt.asn1.x509.SubjectKeyIdentifier.superclass.constructor.call(this,t);var e=nt.asn1.DEROctetString;this.asn1KID=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=this.asn1KID,this.asn1ExtnValue.tohex()},this.setKIDByParam=function(t){if(void 0!==t.str||void 0!==t.hex)this.asn1KID=new e(t);else if("object"==typeof t&&nt.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN")){var r=t;"string"==typeof t&&(r=Mt.getKey(t));var i=Mt.getKeyID(r);this.asn1KID=new nt.asn1.DEROctetString({hex:i})}},this.oid="2.5.29.14",void 0!==t&&void 0!==t.kid&&this.setKIDByParam(t.kid)},jt(nt.asn1.x509.SubjectKeyIdentifier,nt.asn1.x509.Extension),nt.asn1.x509.AuthorityInfoAccess=function(t){nt.asn1.x509.AuthorityInfoAccess.superclass.constructor.call(this,t),this.setAccessDescriptionArray=function(t){for(var e=new Array,r=nt.asn1,i=r.DERSequence,s=r.DERObjectIdentifier,n=r.x509.GeneralName,a=0;a<t.length;a++){var o,h=t[a];if(void 0!==h.ocsp)o=new i({array:[new s({oid:"1.3.6.1.5.5.7.48.1"}),new n({uri:h.ocsp})]});else{if(void 0===h.caissuer)throw new Error("unknown AccessMethod parameter: "+JSON.stringify(h));o=new i({array:[new s({oid:"1.3.6.1.5.5.7.48.2"}),new n({uri:h.caissuer})]})}e.push(o)}this.asn1ExtnValue=new i({array:e})},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.1.1",void 0!==t&&void 0!==t.array&&this.setAccessDescriptionArray(t.array)},jt(nt.asn1.x509.AuthorityInfoAccess,nt.asn1.x509.Extension),nt.asn1.x509.SubjectAltName=function(t){nt.asn1.x509.SubjectAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new nt.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="2.5.29.17",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},jt(nt.asn1.x509.SubjectAltName,nt.asn1.x509.Extension),nt.asn1.x509.IssuerAltName=function(t){nt.asn1.x509.IssuerAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new nt.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="2.5.29.18",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},jt(nt.asn1.x509.IssuerAltName,nt.asn1.x509.Extension),nt.asn1.x509.SubjectDirectoryAttributes=function(t){nt.asn1.x509.SubjectDirectoryAttributes.superclass.constructor.call(this,t);var e=nt.asn1,r=e.DERSequence,i=e.ASN1Util.newObject,s=e.x509.OID.name2oid;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++){var n=this.params.array[e];if(null==n.attr||null==n.array){var a={seq:[{oid:"1.2.3.4"},{set:[{utf8str:"DE"}]}]};if("dateOfBirth"==n.attr)a.seq[0].oid=s(n.attr),a.seq[1].set[0]={gentime:n.str};else if("placeOfBirth"==n.attr)a.seq[0].oid=s(n.attr),a.seq[1].set[0]={utf8str:n.str};else if("gender"==n.attr)a.seq[0].oid=s(n.attr),a.seq[1].set[0]={prnstr:n.str};else if("countryOfCitizenship"==n.attr)a.seq[0].oid=s(n.attr),a.seq[1].set[0]={prnstr:n.str};else{if("countryOfResidence"!=n.attr)throw new Error("unsupported attribute: "+n.attr);a.seq[0].oid=s(n.attr),a.seq[1].set[0]={prnstr:n.str}}t.push(new i(a))}else{var o={seq:[{oid:n.attr},{set:n.array}]};t.push(i(o))}}var h=new r({array:t});return this.asn1ExtnValue=h,this.asn1ExtnValue.tohex()},this.oid="2.5.29.9",void 0!==t&&(this.params=t)},jt(nt.asn1.x509.SubjectDirectoryAttributes,nt.asn1.x509.Extension),nt.asn1.x509.PrivateExtension=function(t){nt.asn1.x509.PrivateExtension.superclass.constructor.call(this,t);var e=nt,r=e.lang.String.isHex,i=e.asn1,s=i.x509.OID.name2oid,n=i.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.oid=s(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 n(t).tohex()}catch(t){}throw new Error("unsupported extn value")},null!=t&&this.setByParam(t)},jt(nt.asn1.x509.PrivateExtension,nt.asn1.x509.Extension),nt.asn1.x509.CRL=function(t){nt.asn1.x509.CRL.superclass.constructor.call(this);var e=nt.asn1,r=e.DERSequence,i=e.DERBitString,s=e.x509,n=s.AlgorithmIdentifier,a=s.TBSCertList;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=new a(this.params).tohex(),e=new nt.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 Et(this.tohex(),"X509 CRL")},this.tohex=function(){var t=this.params;if(null==t.tbsobj&&(t.tbsobj=new a(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 n({name:t.sigalg})),e.push(new i({hex:"00"+t.sighex})),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&(this.params=t)},jt(nt.asn1.x509.CRL,nt.asn1.ASN1Object),nt.asn1.x509.TBSCertList=function(t){nt.asn1.x509.TBSCertList.superclass.constructor.call(this);var e=nt.asn1,r=e.DERInteger,i=e.DERSequence,s=e.DERTaggedObject,n=(e.DERObjectIdentifier,e.x509),a=n.AlgorithmIdentifier,o=n.Time,h=n.Extensions,u=n.X500Name;this.params=null,this.setByParam=function(t){this.params=t},this.getRevCertSequence=function(){for(var t=[],e=this.params.revcert,s=0;s<e.length;s++){var n=[new r(e[s].sn),new o(e[s].date)];null!=e[s].ext&&n.push(new h(e[s].ext)),t.push(new i({array:n}))}return new i({array:t})},this.tohex=function(){var t=[],e=this.params;if(null!=e.version){var n=e.version-1,c=new r({int:n});t.push(c)}if(t.push(new a({name:e.sigalg})),t.push(new u(e.issuer)),t.push(new o(e.thisupdate)),null!=e.nextupdate&&t.push(new o(e.nextupdate)),null!=e.revcert&&t.push(this.getRevCertSequence()),null!=e.ext){var l=new h(e.ext);t.push(new s({tag:"a0",explicit:!0,obj:l}))}return new i({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.x509.TBSCertList,nt.asn1.ASN1Object),nt.asn1.x509.CRLEntry=function(t){nt.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=nt.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.tohex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn&&this.setCertSerial(t.sn))},jt(nt.asn1.x509.CRLEntry,nt.asn1.ASN1Object),nt.asn1.x509.CRLNumber=function(t){nt.asn1.x509.CRLNumber.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new nt.asn1.DERInteger(this.params.num),this.asn1ExtnValue.tohex()},this.oid="2.5.29.20",null!=t&&(this.params=t)},jt(nt.asn1.x509.CRLNumber,nt.asn1.x509.Extension),nt.asn1.x509.CRLReason=function(t){nt.asn1.x509.CRLReason.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new nt.asn1.DEREnumerated(this.params.code),this.asn1ExtnValue.tohex()},this.oid="2.5.29.21",null!=t&&(this.params=t)},jt(nt.asn1.x509.CRLReason,nt.asn1.x509.Extension),nt.asn1.x509.OCSPNonce=function(t){nt.asn1.x509.OCSPNonce.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new nt.asn1.DEROctetString(this.params),this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.48.1.2",null!=t&&(this.params=t)},jt(nt.asn1.x509.OCSPNonce,nt.asn1.x509.Extension),nt.asn1.x509.OCSPNoCheck=function(t){nt.asn1.x509.OCSPNoCheck.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new nt.asn1.DERNull,this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.48.1.5",null!=t&&(this.params=t)},jt(nt.asn1.x509.OCSPNoCheck,nt.asn1.x509.Extension),nt.asn1.x509.AdobeTimeStamp=function(t){nt.asn1.x509.AdobeTimeStamp.superclass.constructor.call(this,t);var e=nt.asn1,r=e.DERInteger,i=e.DERBoolean,s=e.DERSequence,n=e.x509.GeneralName;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[new r(1)];return e.push(new n({uri:t.uri})),null!=t.reqauth&&e.push(new i(t.reqauth)),this.asn1ExtnValue=new s({array:e}),this.asn1ExtnValue.tohex()},this.oid="1.2.840.113583.1.1.9.1",void 0!==t&&this.setByParam(t)},jt(nt.asn1.x509.AdobeTimeStamp,nt.asn1.x509.Extension),nt.asn1.x509.X500Name=function(t){nt.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=nt.asn1,r=e.x509,i=r.RDN;this.setByString=function(t,e){void 0!==e&&(this.sRule=e);var r=t.split("/");r.shift();for(var s=[],n=0;n<r.length;n++)if(r[n].match(/^[^=]+=.+$/))s.push(r[n]);else{var a=s.length-1;s[a]=s[a]+"/"+r[n]}for(n=0;n<s.length;n++)this.asn1Array.push(new i({str:s[n],rule:this.sRule}))},this.setByLdapString=function(t,e){void 0!==e&&(this.sRule=e);var i=r.X500Name.ldapToCompat(t);this.setByString(i,e)},this.setByObject=function(t,e){for(var r in void 0!==e&&(this.sRule=e),t)if(t.hasOwnProperty(r)){var s=new i({str:r+"="+t[r],rule:this.sRule});this.asn1Array?this.asn1Array.push(s):this.asn1Array=[s]}},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 Wt).readCertPEM(t.certissuer),this.hTLV=e.getIssuerHex()):void 0!==t.certsubject?((e=new Wt).readCertPEM(t.certsubject),this.hTLV=e.getSubjectHex()):"object"==typeof t&&void 0===t.certsubject&&void 0===t.certissuer&&this.setByObject(t)},this.tohex=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 s=new i(r);this.asn1Array.push(s)}var n=new e.DERSequence({array:this.asn1Array});return this.hTLV=n.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.x509.X500Name,nt.asn1.ASN1Object),nt.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(/,/,"\\,")}),e.join(",")},nt.asn1.x509.X500Name.onelineToLDAP=function(t){return nt.asn1.x509.X500Name.compatToLDAP(t)},nt.asn1.x509.X500Name.ldapToCompat=function(t){for(var e=t.split(","),r=!1,i=[],s=0;e.length>0;s++){var n=e.shift();if(!0===r){var a=(i.pop()+","+n).replace(/\\,/g,",");i.push(a),r=!1}else i.push(n);"\\"===n.substr(-1,1)&&(r=!0)}return i=i.map(function(t){return t.replace("/","\\/")}),i.reverse(),"/"+i.join("/")},nt.asn1.x509.X500Name.ldapToOneline=function(t){return nt.asn1.x509.X500Name.ldapToCompat(t)},nt.asn1.x509.RDN=function(t){nt.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=nt.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 nt.asn1.x509.AttributeTypeAndValue({str:t,rule:this.sRule}))},this.addByMultiValuedString=function(t){for(var e=nt.asn1.x509.RDN.parseString(t),r=0;r<e.length;r++)this.addByString(e[r])},this.tohex=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 i=new e(r);this.asn1Array.push(i)}var s=new nt.asn1.DERSet({array:this.asn1Array});return this.TLV=s.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.x509.RDN,nt.asn1.ASN1Object),nt.asn1.x509.RDN.parseString=function(t){for(var e=t.split(/\+/),r=!1,i=[],s=0;e.length>0;s++){var n=e.shift();if(!0===r){var a=(i.pop()+"+"+n).replace(/\\\+/g,"+");i.push(a),r=!1}else i.push(n);"\\"===n.substr(-1,1)&&(r=!0)}var o=!1,h=[];for(s=0;i.length>0;s++){if(n=i.shift(),!0===o){var u=h.pop();n.match(/"$/)?(a=(u+"+"+n).replace(/^([^=]+)="(.*)"$/,"$1=$2"),h.push(a),o=!1):h.push(u+"+"+n)}else h.push(n);n.match(/^[^=]+="/)&&(o=!0)}return h},nt.asn1.x509.AttributeTypeAndValue=function(t){nt.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var e=nt,r=e.asn1,i=r.DERSequence,s=r.DERUTF8String,n=r.DERPrintableString,a=r.DERTeletexString,o=r.DERIA5String,h=r.DERVisibleString,u=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 s({str:e});if("prn"==t)return new n({str:e});if("tel"==t)return new a({str:e});if("ia5"==t)return new o({str:e});if("vis"==t)return new h({str:e});if("bmp"==t)return new u({str:e});throw new Error("unsupported directory string type: type="+t+" value="+e)},this.tohex=function(){null==this.dsType&&(this.dsType=this._getDsType());var t=nt.asn1.x509.OID.atype2obj(this.sType),e=this.getValueObj(this.dsType,this.sValue),r=new i({array:[t,e]});return this.TLV=r.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.x509.AttributeTypeAndValue,nt.asn1.ASN1Object),nt.asn1.x509.SubjectPublicKeyInfo=function(t){nt.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=nt,r=e.asn1,i=r.DERInteger,s=r.DERBitString,n=r.DERObjectIdentifier,a=r.DERSequence,o=r.ASN1Util.newObject,h=r.x509.AlgorithmIdentifier,u=e.crypto;u.ECDSA,u.DSA,this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new a({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.tohex=function(){var t=this.getASN1Object();return this.hTLV=t.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.setPubKey=function(t){try{if(t instanceof tt){var e=o({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).tohex();this.asn1AlgId=new h({name:"rsaEncryption"}),this.asn1SubjPKey=new s({hex:"00"+e})}}catch(t){}try{if(t instanceof nt.crypto.ECDSA){var r=new n({name:t.curveName});this.asn1AlgId=new h({name:"ecPublicKey",asn1params:r}),this.asn1SubjPKey=new s({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof nt.crypto.DSA){r=new o({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}),this.asn1AlgId=new h({name:"dsa",asn1params:r});var a=new i({bigint:t.y});this.asn1SubjPKey=new s({hex:"00"+a.tohex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},jt(nt.asn1.x509.SubjectPublicKeyInfo,nt.asn1.ASN1Object),nt.asn1.x509.Time=function(t){nt.asn1.x509.Time.superclass.constructor.call(this);var e=nt.asn1,r=e.DERUTCTime,i=e.DERGeneralizedTime;this.params=null,this.type=null,this.setTimeParams=function(t){this.timeParams=t},this.setByParam=function(t){this.params=t},this.getType=function(t){return t.match(/^[0-9]{12}Z$/)?"utc":t.match(/^[0-9]{14}Z$/)?"gen":t.match(/^[0-9]{12}\.[0-9]+Z$/)?"utc":t.match(/^[0-9]{14}\.[0-9]+Z$/)?"gen":null},this.tohex=function(){var t=this.params,e=null;if("string"==typeof t&&(t={str:t}),null==t||!t.str||null!=t.type&&null!=t.type||(t.type=this.getType(t.str)),null!=t&&t.str?("utc"==t.type&&(e=new r(t.str)),"gen"==t.type&&(e=new i(t.str))):e="gen"==this.type?new i:new r,null==e)throw new Error("wrong setting for Time");return this.TLV=e.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},nt.asn1.x509.Time_bak=function(t){nt.asn1.x509.Time_bak.superclass.constructor.call(this);var e=nt.asn1,r=e.DERUTCTime,i=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.tohex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new r(this.timeParams):new i(this.timeParams):"utc"==this.type?new r:new i,this.TLV=t.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},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)},jt(nt.asn1.x509.Time,nt.asn1.ASN1Object),nt.asn1.x509.AlgorithmIdentifier=function(t){nt.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=nt.asn1,r=e.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;if(this.tohex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw new Error("algorithm not specified");if(null!==this.nameAlg){var t=null;for(var i in r)i===this.nameAlg&&(t=r[i]);if(null!==t)return this.hTLV=t,this.hTLV}null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var s=[this.asn1Alg];null!==this.asn1Params&&s.push(this.asn1Params);var n=new e.DERSequence({array:s});return this.hTLV=n.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},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 i=this.nameAlg.toLowerCase();"withdsa"!==i.substr(-7,7)&&"withecdsa"!==i.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},jt(nt.asn1.x509.AlgorithmIdentifier,nt.asn1.ASN1Object),nt.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"},nt.asn1.x509.GeneralName=function(t){nt.asn1.x509.GeneralName.superclass.constructor.call(this);var e=nt.asn1,r=e.x509,i=r.X500Name,s=r.OtherName,n=e.DERIA5String,a=(e.DERPrintableString,e.DEROctetString),o=e.DERTaggedObject,h=e.ASN1Object,u=Error;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t,e,r=this.params,c=!1;if(void 0!==r.other)t="a0",e=new s(r.other);else if(void 0!==r.rfc822)t="81",e=new n({str:r.rfc822});else if(void 0!==r.dns)t="82",e=new n({str:r.dns});else if(void 0!==r.dn)t="a4",c=!0,e="string"==typeof r.dn?new i({str:r.dn}):r.dn instanceof nt.asn1.x509.X500Name?r.dn:new i(r.dn);else if(void 0!==r.ldapdn)t="a4",c=!0,e=new i({ldapstr:r.ldapdn});else if(void 0!==r.certissuer||void 0!==r.certsubj){var l,g;t="a4",c=!0;var p=null;if(void 0!==r.certsubj?(l=!1,g=r.certsubj):(l=!0,g=r.certissuer),g.match(/^[0-9A-Fa-f]+$/),-1!=g.indexOf("-----BEGIN ")&&(p=xt(g)),null==p)throw new Error("certsubj/certissuer not cert");var d,f=new Wt;f.hex=p,d=l?f.getIssuerHex():f.getSubjectHex(),(e=new h).hTLV=d}else if(void 0!==r.uri)t="86",e=new n({str:r.uri});else{if(void 0===r.ip)throw new u("improper params");var y;t="87";var v=r.ip;try{if(v.match(/^[0-9a-f]+$/)){var m=v.length;if(8!=m&&16!=m&&32!=m&&64!=m)throw"err";y=v}else y=Rt(v)}catch(t){throw new u("malformed IP address: "+r.ip+":"+t.message)}e=new a({hex:y})}return new o({tag:t,explicit:c,obj:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.x509.GeneralName,nt.asn1.ASN1Object),nt.asn1.x509.GeneralNames=function(t){nt.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=nt.asn1;this.setByParamArray=function(t){for(var r=0;r<t.length;r++){var i=new e.x509.GeneralName(t[r]);this.asn1Array.push(i)}},this.tohex=function(){return new e.DERSequence({array:this.asn1Array}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.asn1Array=new Array,void 0!==t&&this.setByParamArray(t)},jt(nt.asn1.x509.GeneralNames,nt.asn1.ASN1Object),nt.asn1.x509.OtherName=function(t){nt.asn1.x509.OtherName.superclass.constructor.call(this);var e=nt.asn1,r=e.DERObjectIdentifier,i=e.DERSequence,s=e.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if(null==t.oid||null==t.value)throw new Error("oid or value not specified");var e=new r({oid:t.oid}),n=s({tag:{tag:"a0",explicit:!0,obj:t.value}});return new i({array:[e,n]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.x509.OtherName,nt.asn1.ASN1Object),nt.asn1.x509.OID=new function(){var t=nt.asn1.DERObjectIdentifier;this.name2oidList={"aes128-CBC":"2.16.840.1.101.3.4.1.2","aes256-CBC":"2.16.840.1.101.3.4.1.42",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",hmacWithSHA1:"1.2.840.113549.2.7",hmacWithSHA224:"1.2.840.113549.2.8",hmacWithSHA256:"1.2.840.113549.2.9",hmacWithSHA384:"1.2.840.113549.2.10",hmacWithSHA512:"1.2.840.113549.2.11",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",policyMappings:"2.5.29.33",authorityKeyIdentifier:"2.5.29.35",policyConstraints:"2.5.29.36",extKeyUsage:"2.5.29.37",inhibitAnyPolicy:"2.5.29.54",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",smtpUTF8Mailbox:"1.3.6.1.5.5.7.8.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",secp521r1:"1.3.132.0.35",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",smimeMailboxLegacy:"2.23.140.1.5.1.1",smimeMailboxMulti:"2.23.140.1.5.1.2",smimeMailboxStrict:"2.23.140.1.5.1.3",smimeOrganizationLegacy:"2.23.140.1.5.2.1",smimeOrganizationMulti:"2.23.140.1.5.2.2",smimeOrganizationStrict:"2.23.140.1.5.2.3",smimeSponsorLegacy:"2.23.140.1.5.3.1",smimeSponsorMulti:"2.23.140.1.5.3.2",smimeSponsorStrict:"2.23.140.1.5.3.3",smimeIndividualLegacy:"2.23.140.1.5.4.1",smimeIndividualMulti:"2.23.140.1.5.4.2",smimeIndividualStrict:"2.23.140.1.5.4.3"},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",GN:"2.5.4.42",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.objCache={},this.name2obj=function(e){if(void 0!==this.objCache[e])return this.objCache[e];if(void 0===this.name2oidList[e])throw"Name of ObjectIdentifier not defined: "+e;var r=this.name2oidList[e],i=new t({oid:r});return this.objCache[e]=i,i},this.atype2obj=function(e){if(void 0!==this.objCache[e])return this.objCache[e];var r;if(e.match(/^\d+\.\d+\.[0-9.]+$/))r=e;else if(void 0!==this.atype2oidList[e])r=this.atype2oidList[e];else{if(void 0===this.name2oidList[e])throw new Error("AttributeType name undefined: "+e);r=this.name2oidList[e]}var i=new t({oid:r});return this.objCache[e]=i,i},this.registerOIDs=function(t){if(this.checkOIDs(t))for(var e in t)this.name2oidList[e]=t[e]},this.checkOIDs=function(t){try{var e=Object.keys(t);return 0!=e.length&&(e.map(function(t,e,r){if(!this[t].match(/^[0-2]\.[0-9.]+$/))throw new Error("value is not OID")},t),!0)}catch(t){return!1}}},nt.asn1.x509.OID.oid2name=function(t){var e=nt.asn1.x509.OID.name2oidList;for(var r in e)if(e[r]==t)return r;return""},nt.asn1.x509.OID.oid2atype=function(t){var e=nt.asn1.x509.OID.atype2oidList;for(var r in e)if(e[r]==t)return r;return t},nt.asn1.x509.OID.name2oid=function(t){if(t.match(/^[0-9.]+$/))return t;var e=nt.asn1.x509.OID.name2oidList;return void 0===e[t]?"":e[t]},nt.asn1.x509.X509Util={},nt.asn1.x509.X509Util.newCertPEM=function(t){var e=nt.asn1.x509;return e.TBSCertificate,new(0,e.Certificate)(t).getPEM()},void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),void 0!==nt.asn1.cms&&nt.asn1.cms||(nt.asn1.cms={}),nt.asn1.cms.Attribute=function(t){var e=Error,r=nt.asn1,i=r.DERSequence,s=r.DERSet,n=r.DERObjectIdentifier;this.params=null,this.typeOid=null,this.setByParam=function(t){this.params=t},this.getValueArray=function(){throw new e("not yet implemented abstract")},this.tohex=function(){var t=new n({oid:this.typeOid}),e=new s({array:this.getValueArray()});return new i({array:[t,e]}).tohex()},this.getEncodedHex=function(){return this.tohex()}},jt(nt.asn1.cms.Attribute,nt.asn1.ASN1Object),nt.asn1.cms.ContentType=function(t){var e=nt.asn1;e.cms.ContentType.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.3",this.getValueArray=function(){return[new e.DERObjectIdentifier(this.params.type)]},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.ContentType,nt.asn1.cms.Attribute),nt.asn1.cms.MessageDigest=function(t){var e=nt.asn1,r=e.DEROctetString;e.cms.MessageDigest.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.4",this.getValueArray=function(){return[new r(this.params)]},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.MessageDigest,nt.asn1.cms.Attribute),nt.asn1.cms.SigningTime=function(t){var e=nt.asn1;e.cms.SigningTime.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.5",this.getValueArray=function(){return[new e.x509.Time(this.params)]},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.SigningTime,nt.asn1.cms.Attribute),nt.asn1.cms.SigningCertificate=function(t){var e=Error,r=nt,i=r.asn1,s=i.DERSequence,n=i.cms,a=n.ESSCertID;r.crypto,n.SigningCertificate.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.12",this.getValueArray=function(){if(null==this.params||null==this.params||null==this.params.array)throw new e("parameter 'array' not specified");for(var r=this.params.array,i=[],n=0;n<r.length;n++){var o=r[n];0!=t.hasis||"string"!=typeof o||-1==o.indexOf("-----BEGIN")&&!ht.isASN1HEX(o)||(o={cert:o}),0!=o.hasis&&0==t.hasis&&(o.hasis=!1),i.push(new a(o))}var h=new s({array:i});return[new s({array:[h]})]},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.SigningCertificate,nt.asn1.cms.Attribute),nt.asn1.cms.ESSCertID=function(t){nt.asn1.cms.ESSCertID.superclass.constructor.call(this);var e=Error,r=nt,i=r.asn1,s=i.DEROctetString,n=i.DERSequence,a=i.cms.IssuerSerial;this.params=null,this.getCertHash=function(t,i){if(null!=t.hash)return t.hash;if("string"==typeof t&&-1==t.indexOf("-----BEGIN")&&!ht.isASN1HEX(t))return t;var s,n,a;if("string"==typeof t)s=t;else{if(null==t.cert)throw new e("hash nor cert unspecified");s=t.cert}if(n=-1!=s.indexOf("-----BEGIN")?xt(s):s,"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?n=xt(t):ht.isASN1HEX(t)&&(n=t)),null!=t.alg)a=t.alg;else{if(null==i)throw new e("hash alg unspecified");a=i}return r.crypto.Util.hashHex(n,a)},this.tohex=function(){var t=this.params,e=this.getCertHash(t,"sha1"),r=[];return r.push(new s({hex:e})),("string"==typeof t&&-1!=t.indexOf("-----BEGIN")||null!=t.cert&&0!=t.hasis||null!=t.issuer&&null!=t.serial)&&r.push(new a(t)),new n({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.ESSCertID,nt.asn1.ASN1Object),nt.asn1.cms.SigningCertificateV2=function(t){var e=Error,r=nt,i=r.asn1,s=i.DERSequence,n=(i.x509,i.cms),a=n.ESSCertIDv2;r.crypto,n.SigningCertificateV2.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.47",this.getValueArray=function(){if(null==this.params||null==this.params||null==this.params.array)throw new e("parameter 'array' not specified");for(var r=this.params.array,i=[],n=0;n<r.length;n++){var o=r[n];null==t.alg&&0!=t.hasis||"string"!=typeof o||-1==o.indexOf("-----BEGIN")&&!ht.isASN1HEX(o)||(o={cert:o}),null==o.alg&&null!=t.alg&&(o.alg=t.alg),0!=o.hasis&&0==t.hasis&&(o.hasis=!1),i.push(new a(o))}var h=new s({array:i});return[new s({array:[h]})]},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.SigningCertificateV2,nt.asn1.cms.Attribute),nt.asn1.cms.ESSCertIDv2=function(t){nt.asn1.cms.ESSCertIDv2.superclass.constructor.call(this),Error;var e=nt.asn1,r=e.DEROctetString,i=e.DERSequence,s=e.cms.IssuerSerial,n=e.x509.AlgorithmIdentifier;this.params=null,this.tohex=function(){var t=this.params,e=this.getCertHash(t,"sha256"),a=[];return null!=t.alg&&"sha256"!=t.alg&&a.push(new n({name:t.alg})),a.push(new r({hex:e})),("string"==typeof t&&-1!=t.indexOf("-----BEGIN")||null!=t.cert&&0!=t.hasis||null!=t.issuer&&null!=t.serial)&&a.push(new s(t)),new i({array:a}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.ESSCertIDv2,nt.asn1.cms.ESSCertID),nt.asn1.cms.IssuerSerial=function(t){var e=Error,r=nt.asn1,i=r.DERInteger,s=r.DERSequence,n=r.cms,a=r.x509.GeneralNames,o=Wt;n.IssuerSerial.superclass.constructor.call(this),this.setByParam=function(t){this.params=t},this.tohex=function(){var t,r,n=this.params;if("string"==typeof n&&-1!=n.indexOf("-----BEGIN")||null!=n.cert){var h;h=null!=n.cert?n.cert:n;var u=new o;u.readCertPEM(h),t=u.getIssuer(),r={hex:u.getSerialNumberHex()}}else{if(null==n.issuer||!n.serial)throw new e("cert or issuer and serial parameter not specified");t=n.issuer,r=n.serial}var c=new a([{dn:t}]),l=new i(r);return new s({array:[c,l]}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.IssuerSerial,nt.asn1.ASN1Object),nt.asn1.cms.SignerIdentifier=function(t){var e=nt.asn1,r=(e.DERInteger,e.DERSequence,e.cms),i=r.IssuerAndSerialNumber,s=r.SubjectKeyIdentifier;e.x509.X500Name,Error,r.SignerIdentifier.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if("isssn"==t.type)return new i(t).tohex();if("skid"==t.type)return new s(t).tohex();throw new Error("wrong property for isssn or skid")},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.SignerIdentifier,nt.asn1.ASN1Object),nt.asn1.cms.IssuerAndSerialNumber=function(t){var e=nt.asn1,r=e.DERInteger,i=e.DERSequence,s=e.cms,n=e.x509.X500Name,a=Wt,o=Error;s.IssuerAndSerialNumber.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t,e,s=this.params;if("string"==typeof s&&-1!=s.indexOf("-----BEGIN")||null!=s.cert){var h;h=null!=s.cert?s.cert:s;var u=new a;u.readCertPEM(h),t=u.getIssuer(),e={hex:u.getSerialNumberHex()}}else{if(null==s.issuer||!s.serial)throw new o("cert or issuer and serial parameter not specified");t=s.issuer,e=s.serial}var c=new n(t),l=new r(e);return new i({array:[c,l]}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.IssuerAndSerialNumber,nt.asn1.ASN1Object),nt.asn1.cms.SubjectKeyIdentifier=function(t){var e=nt.asn1,r=(e.DERInteger,e.DERSequence,e.ASN1Util.newObject),i=e.cms,s=(i.IssuerAndSerialName,i.SubjectKeyIdentifier,e.x509.X500Name,Wt),n=Error;i.SubjectKeyIdentifier.superclass.constructor.call(this),this.tohex=function(){var t,e=this.params;if(null==e.cert&&null==e.skid)throw new n("property cert nor skid undefined");return null!=e.cert?t=new s(e.cert).getExtSubjectKeyIdentifier().kid.hex:null!=e.skid&&(t=e.skid),r({tag:{tage:"a0",obj:{octstr:{hex:t}}}}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.SubjectKeyIdentifier,nt.asn1.ASN1Object),nt.asn1.cms.AttributeList=function(t){var e=Error,r=nt.asn1,i=r.DERSet,s=r.cms;s.AttributeList.superclass.constructor.call(this),this.params=null,this.hTLV=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if(null!=this.hTLV)return this.hTLV;var r=!0;null!=t.sortflag&&(r=t.sortflag);for(var n=t.array,a=[],o=0;o<n.length;o++){var h=n[o],u=h.attr;if("contentType"==u)a.push(new s.ContentType(h));else if("messageDigest"==u)a.push(new s.MessageDigest(h));else if("signingTime"==u)a.push(new s.SigningTime(h));else if("signingCertificate"==u)a.push(new s.SigningCertificate(h));else if("signingCertificateV2"==u)a.push(new s.SigningCertificateV2(h));else if("signaturePolicyIdentifier"==u)a.push(new nt.asn1.cades.SignaturePolicyIdentifier(h));else{if("signatureTimeStamp"!=u&&"timeStampToken"!=u)throw new e("unknown attr: "+u);a.push(new nt.asn1.cades.SignatureTimeStamp(h))}}var c=new i({array:a,sortflag:r});return this.hTLV=c.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.AttributeList,nt.asn1.ASN1Object),nt.asn1.cms.SignerInfo=function(t){var e=Error,r=nt,i=r.asn1,s=i.DERInteger,n=i.DEROctetString,a=i.DERSequence,o=i.DERTaggedObject,h=i.cms,u=h.SignerIdentifier,c=h.AttributeList,l=(h.ContentType,h.EncapsulatedContentInfo,h.MessageDigest,h.SignedData,i.x509.AlgorithmIdentifier),g=r.crypto,p=Mt;h.SignerInfo.superclass.constructor.call(this),this.params=null,this.sign=function(){var t=this.params,e=t.sigalg,r=new c(t.sattrs).tohex(),i=p.getKey(t.signkey),s=new g.Signature({alg:e});s.init(i),s.updateHex(r);var n=s.sign();t.sighex=n},this.tohex=function(){var t=this.params,r=[];if(r.push(new s({int:t.version})),r.push(new u(t.id)),r.push(new l({name:t.hashalg})),null!=t.sattrs){var i=new c(t.sattrs);try{r.push(new o({tag:"a0",explicit:!1,obj:i}))}catch(t){throw new e("si sattr error: "+t)}}if(null!=t.sigalgfield?r.push(new l({name:t.sigalgfield})):r.push(new l({name:t.sigalg})),null==t.sighex&&null!=t.signkey&&this.sign(),r.push(new n({hex:t.sighex})),null!=t.uattrs){i=new c(t.uattrs);try{r.push(new o({tag:"a1",explicit:!1,obj:i}))}catch(t){throw new e("si uattr error: "+t)}}return new a({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.SignerInfo,nt.asn1.ASN1Object),nt.asn1.cms.EncapsulatedContentInfo=function(t){var e=nt.asn1,r=e.DERTaggedObject,i=e.DERSequence,s=e.DERObjectIdentifier,n=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];if(e.push(new s(t.type)),null!=t.content&&(null!=t.content.hex||null!=t.content.str)&&1!=t.isDetached){var a=new n(t.content),o=new r({tag:"a0",explicit:!0,obj:a});e.push(o)}return new i({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.EncapsulatedContentInfo,nt.asn1.ASN1Object),nt.asn1.cms.ContentInfo=function(t){var e=nt.asn1,r=e.DERTaggedObject,i=e.DERSequence,s=e.DERObjectIdentifier;e.x509.OID.name2obj,nt.asn1.cms.ContentInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];e.push(new s(t.type));var n=new r({tag:"a0",explicit:!0,obj:t.obj});return e.push(n),new i({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.ContentInfo,nt.asn1.ASN1Object),nt.asn1.cms.SignedData=function(t){Error;var e=nt.asn1,r=(e.ASN1Object,e.DERInteger),i=e.DERSet,s=e.DERSequence,n=(e.DERTaggedObject,e.cms),a=n.EncapsulatedContentInfo,o=n.SignerInfo,h=n.ContentInfo,u=n.CertificateSet,c=n.RevocationInfoChoices,l=e.x509.AlgorithmIdentifier;nt.asn1.cms.SignedData.superclass.constructor.call(this),this.params=null,this.checkAndFixParam=function(){var t=this.params;this._setDigestAlgs(t),this._setContentTypeByEContent(t),this._setMessageDigestByEContent(t),this._setSignerInfoVersion(t),this._setSignedDataVersion(t)},this._setDigestAlgs=function(t){for(var e={},r=t.sinfos,i=0;i<r.length;i++)e[r[i].hashalg]=1;t.hashalgs=Object.keys(e).sort()},this._setContentTypeByEContent=function(t){for(var e=t.econtent.type,r=t.sinfos,i=0;i<r.length;i++){var s=r[i];this._getAttrParamByName(s,"contentType").type=e}},this._setMessageDigestByEContent=function(t){var e=t.econtent,r=(t.econtent.type,e.content.hex);null==r&&"data"==e.type&&null!=e.content.str&&(r=St(e.content.str));for(var i=t.sinfos,s=0;s<i.length;s++){var n=i[s],a=n.hashalg,o=this._getAttrParamByName(n,"messageDigest"),h=nt.crypto.Util.hashHex(r,a);o.hex=h}},this._getAttrParamByName=function(t,e){for(var r=t.sattrs.array,i=0;i<r.length;i++)if(r[i].attr==e)return r[i]},this._setSignerInfoVersion=function(t){for(var e=t.sinfos,r=0;r<e.length;r++){var i=e[r],s=1;"skid"==i.id.type&&(s=3),i.version=s}},this._setSignedDataVersion=function(t){var e=this._getSignedDataVersion(t);t.version=e},this._getSignedDataVersion=function(t){if(null!=t.revinfos)for(var e=t.revinfos,r=0;r<e.length;r++)if(null!=e[r].ocsp)return 5;var i=t.sinfos;for(r=0;r<i.length;r++)if(3==t.sinfos[r].version)return 3;return"data"!=t.econtent.type?3:1},this.tohex=function(){var t=this.params;null!=this.getEncodedHexPrepare&&this.getEncodedHexPrepare(),1!=t.fixed&&this.checkAndFixParam();var e=[];e.push(new r({int:t.version}));for(var n=[],h=0;h<t.hashalgs.length;h++){var g=t.hashalgs[h];n.push(new l({name:g}))}e.push(new i({array:n})),e.push(new a(t.econtent)),null!=t.certs&&e.push(new u(t.certs)),null!=t.revinfos&&e.push(new c(t.revinfos));var p=[];for(h=0;h<t.sinfos.length;h++){var d=t.sinfos[h];p.push(new o(d))}return e.push(new i({array:p})),new s({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.getContentInfo=function(){return new h({type:"signed-data",obj:this})},this.getContentInfoEncodedHex=function(){return this.getContentInfo().tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.SignedData,nt.asn1.ASN1Object),nt.asn1.cms.CertificateSet=function(t){nt.asn1.cms.CertificateSet.superclass.constructor.call(this);var e=Error,r=nt.asn1,i=r.DERTaggedObject,s=r.DERSet,n=r.ASN1Object;this.params=null,this.tohex=function(){var t,r=this.params,a=[];if(r instanceof Array)t=r;else{if(null==r.array)throw new e("cert array not specified");t=r.array}for(var o=0;o<t.length;o++){var h=xt(t[o]),u=new n;u.hTLV=h,a.push(u)}var c={array:a};0==r.sortflag&&(c.sortflag=!1);var l=new s(c);return new i({tag:"a0",explicit:!1,obj:l}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.CertificateSet,nt.asn1.ASN1Object),nt.asn1.cms.RevocationInfoChoices=function(t){nt.asn1.cms.RevocationInfoChoices.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(!t instanceof Array)throw new Error("params is not array");for(var e=[],r=0;r<t.length;r++)e.push(new nt.asn1.cms.RevocationInfoChoice(t[r]));return nt.asn1.ASN1Util.newObject({tag:{tagi:"a1",obj:{set:e}}}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.RevocationInfoChoices,nt.asn1.ASN1Object),nt.asn1.cms.RevocationInfoChoice=function(t){nt.asn1.cms.RevocationInfoChoice.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(null!=t.crl&&"string"==typeof t.crl){var e=t.crl;return-1!=t.crl.indexOf("-----BEGIN")&&(e=xt(t.crl)),e}if(null!=t.ocsp)return nt.asn1.ASN1Util.newObject({tag:{tagi:"a1",obj:new nt.asn1.cms.OtherRevocationFormat(t)}}).tohex();throw new Error("property crl or ocsp undefined")},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.RevocationInfoChoice,nt.asn1.ASN1Object),nt.asn1.cms.OtherRevocationFormat=function(t){nt.asn1.cms.OtherRevocationFormat.superclass.constructor.call(this);var e=Error,r=nt,i=r.asn1.ASN1Util.newObject,s=r.lang.String.isHex;this.params=null,this.tohex=function(){var t=this.params;if(null==t.ocsp)throw new e("property ocsp not specified");if(!s(t.ocsp)||!ht.isASN1HEX(t.ocsp))throw new e("ocsp value not ASN.1 hex string");return i({seq:[{oid:"1.3.6.1.5.5.7.16.2"},{asn1:{tlv:t.ocsp}}]}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.OtherRevocationFormat,nt.asn1.ASN1Object),nt.asn1.cms.CMSUtil=new function(){},nt.asn1.cms.CMSUtil.newSignedData=function(t){return new nt.asn1.cms.SignedData(t)},nt.asn1.cms.CMSUtil.verifySignedData=function(t){var e=nt,r=e.asn1,i=r.cms,s=(i.SignerInfo,i.SignedData,i.SigningTime,i.SigningCertificate,i.SigningCertificateV2,r.cades.SignaturePolicyIdentifier,e.lang.String.isHex),n=ht,a=n.getVbyList,o=n.getTLVbyList,h=n.getIdxbyList,u=n.getChildIdx,c=n.getTLV,l=n.oidname,g=e.crypto.Util.hashHex;void 0===t.cms&&s(t.cms);var p=t.cms,d=function(t,e){var r=e.idx;e.signerid_issuer1=o(t,r,[1,0],"30"),e.signerid_serial1=a(t,r,[1,1],"02"),e.hashalg=l(a(t,r,[2,0],"06"));var i=h(t,r,[3],"a0");e.idxSignedAttrs=i,f(t,e,i);var s=u(t,r).length;if(s<6)throw"malformed SignerInfo";e.sigalg=l(a(t,r,[s-2,0],"06")),e.sigval=a(t,r,[s-1],"04")},f=function(t,e,r){var i=u(t,r);e.signedAttrIdxList=i;for(var s=0;s<i.length;s++){var n,o=i[s],h=a(t,o,[0],"06");"2a864886f70d010905"===h?(n=yt(a(t,o,[1,0])),e.saSigningTime=n):"2a864886f70d010904"===h&&(n=a(t,o,[1,0],"04"),e.saMessageDigest=n)}},y=function(t,e,r,i){r.verifyDetail={};var s=r.verifyDetail,n=e.parse.econtent,a=r.hashalg,o=r.saMessageDigest;s.validMessageDigest=!1,g(n,a)===o&&(s.validMessageDigest=!0),function(t,e,r){var i,s=e.parse.certsIdx;if(void 0===e.certs){i=[],e.certkeys=[];for(var n=u(t,s),a=0;a<n.length;a++){var o=c(t,n[a]),h=new Wt;h.readCertHex(o),i[a]=h,e.certkeys[a]=h.getPublicKey()}e.certs=i}else i=e.certs;for(e.cccc=i.length,e.cccci=n.length,a=0;a<i.length;a++){var l=h.getIssuerHex(),g=h.getSerialNumberHex();r.signerid_issuer1===l&&r.signerid_serial1===g&&(r.certkey_idx=a)}}(t,e,r),s.validSignatureValue=!1;var h=r.sigalg,l="31"+c(t,r.idxSignedAttrs).substr(2);r.signedattrshex=l;var p=e.certs[r.certkey_idx].getPublicKey(),d=new nt.crypto.Signature({alg:h});d.init(p),d.updateHex(l);var f=d.verify(r.sigval);s.validSignatureValue_isValid=f,!0===f&&(s.validSignatureValue=!0),r.isValid=!1,s.validMessageDigest&&s.validSignatureValue&&(r.isValid=!0)},v={isValid:!1,parse:{}};return function(t,e){if("2a864886f70d010702"!==a(t,0,[0],"06"))return e;e.cmsType="signedData",e.econtent=a(t,0,[1,0,2,1,0]),function(t,e){for(var r,i=3;i<6;i++)if(void 0!==(r=h(t,0,[1,0,i]))){var s=t.substr(r,2);"a0"===s&&(e.certsIdx=r),"a1"===s&&(e.revinfosIdx=r),"31"===s&&(e.signerinfosIdx=r)}}(t,e),e.signerInfos=[],function(t,e){var r=e.signerinfosIdx;if(void 0!==r){var i=u(t,r);e.signerInfoIdxList=i;for(var s=0;s<i.length;s++){var n={idx:i[s]};d(t,n),e.signerInfos.push(n)}}}(t,e)}(p,v.parse),function(t,e){for(var r=e.parse.signerInfos,i=r.length,s=!0,n=0;n<i;n++){var a=r[n];y(t,e,a),a.isValid||(s=!1)}e.isValid=s}(p,v),v},nt.asn1.cms.CMSParser=function(){var t=Error,e=Wt,r=new e,i=ht,s=i.getV,n=i.getTLV,a=(i.getIdxbyList,i.getTLVbyList),o=i.getTLVbyListEx,h=i.getVbyList,u=i.getVbyListEx,c=i.getChildIdx;this.getCMSSignedData=function(t){var e=a(t,0,[1,0]);return this.getSignedData(e)},this.getSignedData=function(t){var e=c(t,0),r={},i=s(t,e[0]),a=parseInt(i,16);r.version=a;var h=n(t,e[1]);r.hashalgs=this.getHashAlgArray(h);var u=n(t,e[2]);r.econtent=this.getEContent(u);var l=o(t,0,["[0]"]);null!=l&&(r.certs=this.getCertificateSet(l)),o(t,0,["[1]"]);var g=o(t,0,[3]);return r.sinfos=this.getSignerInfos(g),r},this.getHashAlgArray=function(t){for(var r=c(t,0),i=new e,s=[],a=0;a<r.length;a++){var o=n(t,r[a]),h=i.getAlgorithmIdentifierName(o);s.push(h)}return s},this.getEContent=function(t){var e={},r=h(t,0,[0]),i=h(t,0,[1,0]);return e.type=nt.asn1.x509.OID.oid2name(ht.hextooidstr(r)),e.content={hex:i},e},this.getSignerInfos=function(t){for(var e=[],r=c(t,0),i=0;i<r.length;i++){var s=n(t,r[i]),a=this.getSignerInfo(s);e.push(a)}return e},this.getSignerInfo=function(t){var e={},s=c(t,0),a=i.getInt(t,s[0],-1);-1!=a&&(e.version=a);var h=n(t,s[1]),l=this.getIssuerAndSerialNumber(h);e.id=l;var g=n(t,s[2]),p=r.getAlgorithmIdentifierName(g);e.hashalg=p;var d=o(t,0,["[0]"]);if(null!=d){var f=this.getAttributeList(d);e.sattrs=f}var y=o(t,0,[3]),v=r.getAlgorithmIdentifierName(y);e.sigalg=v;var m=u(t,0,[4]);e.sighex=m;var S=o(t,0,["[1]"]);if(null!=S){var E=this.getAttributeList(S);e.uattrs=E}return e},this.getSignerIdentifier=function(t){if("30"==t.substr(0,2))return this.getIssuerAndSerialNumber(t);throw new Error("SKID of signerIdentifier not supported")},this.getIssuerAndSerialNumber=function(t){var e={type:"isssn"},i=c(t,0),a=n(t,i[0]);e.issuer=r.getX500Name(a);var o=s(t,i[1]);return e.serial={hex:o},e},this.getAttributeList=function(t){for(var e=[],r=c(t,0),i=0;i<r.length;i++){var s=n(t,r[i]),a=this.getAttribute(s);e.push(a)}return{array:e}},this.getAttribute=function(t){var e={},r=c(t,0),s=i.getOID(t,r[0]),a=nt.asn1.x509.OID.oid2name(s);e.attr=a;var o=n(t,r[1]),h=c(o,0);if(1==h.length)e.valhex=n(o,h[0]);else{for(var u=[],l=0;l<h.length;l++)u.push(n(o,h[l]));e.valhex=u}return"contentType"==a?this.setContentType(e):"messageDigest"==a?this.setMessageDigest(e):"signingTime"==a?this.setSigningTime(e):"signingCertificate"==a?this.setSigningCertificate(e):"signingCertificateV2"==a?this.setSigningCertificateV2(e):"signaturePolicyIdentifier"==a&&this.setSignaturePolicyIdentifier(e),e},this.setContentType=function(t){var e=i.getOIDName(t.valhex,0,null);null!=e&&(t.type=e,delete t.valhex)},this.setSigningTime=function(t){var e=yt(s(t.valhex,0));t.str=e,delete t.valhex},this.setMessageDigest=function(t){var e=s(t.valhex,0);t.hex=e,delete t.valhex},this.setSigningCertificate=function(t){var e=c(t.valhex,0);if(e.length>0){for(var r=n(t.valhex,e[0]),i=c(r,0),s=[],a=0;a<i.length;a++){var o=n(r,i[a]),h=this.getESSCertID(o);s.push(h)}t.array=s}if(e.length>1){var u=n(t.valhex,e[1]);t.polhex=u}delete t.valhex},this.setSignaturePolicyIdentifier=function(t){var r=c(t.valhex,0);if(r.length>0){var a=i.getOID(t.valhex,r[0]);t.oid=a}if(r.length>1){var o=new e,h=c(t.valhex,r[1]),u=n(t.valhex,h[0]),l=o.getAlgorithmIdentifierName(u);t.alg=l;var g=s(t.valhex,h[1]);t.hash=g}delete t.valhex},this.setSigningCertificateV2=function(t){var e=c(t.valhex,0);if(e.length>0){for(var r=n(t.valhex,e[0]),i=c(r,0),s=[],a=0;a<i.length;a++){var o=n(r,i[a]),h=this.getESSCertIDv2(o);s.push(h)}t.array=s}if(e.length>1){var u=n(t.valhex,e[1]);t.polhex=u}delete t.valhex},this.getESSCertID=function(t){var e={},r=c(t,0);if(r.length>0){var i=s(t,r[0]);e.hash=i}if(r.length>1){var a=n(t,r[1]),o=this.getIssuerSerial(a);null!=o.serial&&(e.serial=o.serial),null!=o.issuer&&(e.issuer=o.issuer)}return e},this.getESSCertIDv2=function(e){var i={},a=c(e,0);if(a.length<1||3<a.length)throw new t("wrong number of elements");var o=0;if("30"==e.substr(a[0],2)){var h=n(e,a[0]);i.alg=r.getAlgorithmIdentifierName(h),o++}else i.alg="sha256";var u=s(e,a[o]);if(i.hash=u,a.length>o+1){var l=n(e,a[o+1]),g=this.getIssuerSerial(l);i.issuer=g.issuer,i.serial=g.serial}return i},this.getIssuerSerial=function(t){var e={},i=c(t,0),a=n(t,i[0]),o=r.getGeneralNames(a)[0].dn;e.issuer=o;var h=s(t,i[1]);return e.serial={hex:h},e},this.getCertificateSet=function(t){for(var e=c(t,0),r=[],i=0;i<e.length;i++){var s=n(t,e[i]);if("30"==s.substr(0,2)){var a=Et(s,"CERTIFICATE");r.push(a)}}return{array:r,sortflag:!1}}},void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),void 0!==nt.asn1.tsp&&nt.asn1.tsp||(nt.asn1.tsp={}),nt.asn1.tsp.TimeStampToken=function(t){var e=nt.asn1.tsp;e.TimeStampToken.superclass.constructor.call(this),this.params=null,this.getEncodedHexPrepare=function(){var t=new e.TSTInfo(this.params.econtent.content);this.params.econtent.content.hex=t.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.tsp.TimeStampToken,nt.asn1.cms.SignedData),nt.asn1.tsp.TSTInfo=function(t){Error;var e=nt.asn1,r=e.DERSequence,i=e.DERInteger,s=e.DERBoolean,n=e.DERGeneralizedTime,a=e.DERObjectIdentifier,o=e.DERTaggedObject,h=e.tsp,u=h.MessageImprint,c=h.Accuracy,l=(e.x509.X500Name,e.x509.GeneralName);if(h.TSTInfo.superclass.constructor.call(this),this.dVersion=new i({int:1}),this.dPolicy=null,this.dMessageImprint=null,this.dSerial=null,this.dGenTime=null,this.dAccuracy=null,this.dOrdering=null,this.dNonce=null,this.dTsa=null,this.tohex=function(){var t=[this.dVersion];if(null==this.dPolicy)throw new Error("policy shall be specified.");if(t.push(this.dPolicy),null==this.dMessageImprint)throw new Error("messageImprint shall be specified.");if(t.push(this.dMessageImprint),null==this.dSerial)throw new Error("serialNumber shall be specified.");if(t.push(this.dSerial),null==this.dGenTime)throw new Error("genTime shall be specified.");t.push(this.dGenTime),null!=this.dAccuracy&&t.push(this.dAccuracy),null!=this.dOrdering&&t.push(this.dOrdering),null!=this.dNonce&&t.push(this.dNonce),null!=this.dTsa&&t.push(this.dTsa);var e=new r({array:t});return this.hTLV=e.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t){if("string"==typeof t.policy){if(!t.policy.match(/^[0-9.]+$/))throw"policy shall be oid like 0.1.4.134";this.dPolicy=new a({oid:t.policy})}void 0!==t.messageImprint&&(this.dMessageImprint=new u(t.messageImprint)),void 0!==t.serial&&(this.dSerial=new i(t.serial)),void 0!==t.genTime&&(this.dGenTime=new n(t.genTime)),void 0!==t.accuracy&&(this.dAccuracy=new c(t.accuracy)),void 0!==t.ordering&&1==t.ordering&&(this.dOrdering=new s),void 0!==t.nonce&&(this.dNonce=new i(t.nonce)),void 0!==t.tsa&&(this.dTsa=new o({tag:"a0",explicit:!0,obj:new l({dn:t.tsa})}))}},jt(nt.asn1.tsp.TSTInfo,nt.asn1.ASN1Object),nt.asn1.tsp.Accuracy=function(t){var e=nt.asn1,r=e.ASN1Util.newObject;e.tsp.Accuracy.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return null!=t.seconds&&"number"==typeof t.seconds&&e.push({int:t.seconds}),null!=t.millis&&"number"==typeof t.millis&&e.push({tag:{tagi:"80",obj:{int:t.millis}}}),null!=t.micros&&"number"==typeof t.micros&&e.push({tag:{tagi:"81",obj:{int:t.micros}}}),r({seq:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.tsp.Accuracy,nt.asn1.ASN1Object),nt.asn1.tsp.MessageImprint=function(t){var e=nt.asn1,r=e.DERSequence,i=e.DEROctetString,s=e.x509.AlgorithmIdentifier;e.tsp.MessageImprint.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=new s({name:t.alg}),n=new i({hex:t.hash});return new r({array:[e,n]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.tsp.MessageImprint,nt.asn1.ASN1Object),nt.asn1.tsp.TimeStampReq=function(t){var e=nt.asn1,r=e.DERSequence,i=e.DERInteger,s=e.DERBoolean,n=(e.ASN1Object,e.DERObjectIdentifier),a=e.tsp,o=a.MessageImprint;a.TimeStampReq.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return e.push(new i({int:1})),t.messageImprint instanceof nt.asn1.ASN1Object?e.push(t.messageImprint):e.push(new o(t.messageImprint)),null!=t.policy&&e.push(new n(t.policy)),null!=t.nonce&&e.push(new i(t.nonce)),1==t.certreq&&e.push(new s),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.tsp.TimeStampReq,nt.asn1.ASN1Object),nt.asn1.tsp.TimeStampResp=function(t){var e=nt.asn1,r=e.DERSequence,i=(e.ASN1Object,e.tsp),s=i.PKIStatusInfo;i.TimeStampResp.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,n=[];if(null!=t.econtent||null!=t.tst)if(null!=t.statusinfo?n.push(new s(t.statusinfo)):n.push(new s("granted")),null!=t.econtent)n.push(new i.TimeStampToken(t).getContentInfo());else{if(!(t.tst instanceof e.ASN1Object))throw new Error("improper member tst value");n.push(t.tst)}else{if(null==t.statusinfo)throw new Error("parameter for token nor statusinfo not specified");n.push(new s(t.statusinfo))}return new r({array:n}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.tsp.TimeStampResp,nt.asn1.ASN1Object),nt.asn1.tsp.PKIStatusInfo=function(t){var e=Error,r=nt.asn1,i=r.DERSequence,s=r.tsp,n=s.PKIStatus,a=s.PKIFreeText,o=s.PKIFailureInfo;s.PKIStatusInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,r=[];if("string"==typeof t)r.push(new n(t));else{if(null==t.status)throw new e("property 'status' unspecified");r.push(new n(t.status)),null!=t.statusstr&&r.push(new a(t.statusstr)),null!=t.failinfo&&r.push(new o(t.failinfo))}return new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.tsp.PKIStatusInfo,nt.asn1.ASN1Object),nt.asn1.tsp.PKIStatus=function(t){var e=Error,r=nt.asn1,i=r.DERInteger;r.tsp.PKIStatus.superclass.constructor.call(this);var s={granted:0,grantedWithMods:1,rejection:2,waiting:3,revocationWarning:4,revocationNotification:5};this.params=null,this.tohex=function(){var t,r=this.params;if("string"==typeof r)try{t=s[r]}catch(t){throw new e("undefined name: "+r)}else{if("number"!=typeof r)throw new e("unsupported params");t=r}return new i({int:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.tsp.PKIStatus,nt.asn1.ASN1Object),nt.asn1.tsp.PKIFreeText=function(t){var e=Error,r=nt.asn1,i=r.DERSequence,s=r.DERUTF8String;r.tsp.PKIFreeText.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(!t instanceof Array)throw new e("wrong params: not array");for(var r=[],n=0;n<t.length;n++)r.push(new s({str:t[n]}));return new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.tsp.PKIFreeText,nt.asn1.ASN1Object),nt.asn1.tsp.PKIFailureInfo=function(t){var e=Error,r=nt.asn1,i=r.DERBitString,s=r.tsp.PKIFailureInfo,n={badAlg:0,badRequest:2,badDataFormat:5,timeNotAvailable:14,unacceptedPolicy:15,unacceptedExtension:16,addInfoNotAvailable:17,systemFailure:25};s.superclass.constructor.call(this),this.params=null,this.getBinValue=function(){var t=this.params,r=0;if("number"==typeof t&&0<=t&&t<=25){for(var i=(r|=1<<t).toString(2),s="",a=i.length-1;a>=0;a--)s+=i[a];return s}if("string"==typeof t&&null!=n[t])return Ut([t],n);if("object"==typeof t&&null!=t.length)return Ut(t,n);throw new e("wrong params")},this.tohex=function(){this.params;var t=this.getBinValue();return new i({bin:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.tsp.PKIFailureInfo,nt.asn1.ASN1Object),nt.asn1.tsp.AbstractTSAAdapter=function(t){this.getTSTHex=function(t,e){throw"not implemented yet"}},nt.asn1.tsp.SimpleTSAAdapter=function(t){var e=nt,r=e.asn1.tsp,i=e.crypto.Util.hashHex;r.SimpleTSAAdapter.superclass.constructor.call(this),this.params=null,this.serial=0,this.getTSTHex=function(t,e){var s=i(t,e);this.params.econtent.content.messageImprint={alg:e,hash:s},this.params.econtent.content.serial={int:this.serial++};var n=Math.floor(1e9*Math.random());return this.params.econtent.content.nonce={int:n},new r.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},jt(nt.asn1.tsp.SimpleTSAAdapter,nt.asn1.tsp.AbstractTSAAdapter),nt.asn1.tsp.FixedTSAAdapter=function(t){var e=nt,r=e.asn1.tsp,i=e.crypto.Util.hashHex;r.FixedTSAAdapter.superclass.constructor.call(this),this.params=null,this.getTSTHex=function(t,e){var s=i(t,e);return this.params.econtent.content.messageImprint={alg:e,hash:s},new r.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},jt(nt.asn1.tsp.FixedTSAAdapter,nt.asn1.tsp.AbstractTSAAdapter),nt.asn1.tsp.TSPUtil=new function(){},nt.asn1.tsp.TSPUtil.newTimeStampToken=function(t){return new nt.asn1.tsp.TimeStampToken(t)},nt.asn1.tsp.TSPUtil.parseTimeStampReq=function(t){return(new nt.asn1.tsp.TSPParser).getTimeStampReq(t)},nt.asn1.tsp.TSPUtil.parseMessageImprint=function(t){return(new nt.asn1.tsp.TSPParser).getMessageImprint(t)},nt.asn1.tsp.TSPParser=function(){Error;var t=new Wt,e=ht,r=e.getV,i=e.getTLV,s=e.getIdxbyList,n=(e.getTLVbyListEx,e.getChildIdx),a=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"],o={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(t){var e=n(t,0);if(1==e.length)return this.getPKIStatusInfo(i(t,e[0]));if(e.length>1){var r=this.getPKIStatusInfo(i(t,e[0])),s=i(t,e[1]),a=this.getToken(s);return a.statusinfo=r,a}},this.getToken=function(t){var e=(new nt.asn1.cms.CMSParser).getCMSSignedData(t);return this.setTSTInfo(e),e},this.setTSTInfo=function(t){var e=t.econtent;if("tstinfo"==e.type){var r=e.content.hex,i=this.getTSTInfo(r);e.content=i}},this.getTSTInfo=function(e){var s={},a=n(e,0),o=r(e,a[1]);s.policy=Bt(o);var h=i(e,a[2]);s.messageImprint=this.getMessageImprint(h);var u=r(e,a[3]);s.serial={hex:u};var c=r(e,a[4]);s.genTime={str:yt(c)};var l=0;if(a.length>5&&"30"==e.substr(a[5],2)){var g=i(e,a[5]);s.accuracy=this.getAccuracy(g),l++}if(a.length>5+l&&"01"==e.substr(a[5+l],2)&&("ff"==r(e,a[5+l])&&(s.ordering=!0),l++),a.length>5+l&&"02"==e.substr(a[5+l],2)){var p=r(e,a[5+l]);s.nonce={hex:p},l++}if(a.length>5+l&&"a0"==e.substr(a[5+l],2)){var d=i(e,a[5+l]);d="30"+d.substr(2),pGeneralNames=t.getGeneralNames(d);var f=pGeneralNames[0].dn;s.tsa=f,l++}if(a.length>5+l&&"a1"==e.substr(a[5+l],2)){var y=i(e,a[5+l]);y="30"+y.substr(2);var v=t.getExtParamArray(y);s.ext=v,l++}return s},this.getAccuracy=function(t){for(var e={},i=n(t,0),s=0;s<i.length;s++){var a=t.substr(i[s],2),o=r(t,i[s]),h=parseInt(o,16);"02"==a?e.seconds=h:"80"==a?e.millis=h:"81"==a&&(e.micros=h)}return e},this.getMessageImprint=function(t){if("30"!=t.substr(0,2))throw new Error("head of messageImprint hex shall be x30");var i={},a=(n(t,0),s(t,0,[0,0])),o=r(t,a),h=e.hextooidstr(o),u=nt.asn1.x509.OID.oid2name(h);if(""==u)throw new Error("hashAlg name undefined: "+h);var c=u,l=s(t,0,[1]);return i.alg=c,i.hash=r(t,l),i},this.getPKIStatusInfo=function(t){var e={},s=n(t,0),o=0;try{var h=r(t,s[0]),u=parseInt(h,16);e.status=a[u]}catch(t){}if(s.length>1&&"30"==t.substr(s[1],2)){var c=i(t,s[1]);e.statusstr=this.getPKIFreeText(c),o++}if(s.length>o&&"03"==t.substr(s[1+o],2)){var l=i(t,s[1+o]);e.failinfo=this.getPKIFailureInfo(l)}return e},this.getPKIFreeText=function(t){for(var r=[],i=n(t,0),s=0;s<i.length;s++)r.push(e.getString(t,i[s]));return r},this.getPKIFailureInfo=function(t){var r=e.getInt(t,0);return null!=o[r]?o[r]:r},this.getTimeStampReq=function(t){var s={certreq:!1},a=n(t,0);if(a.length<2)throw new Error("TimeStampReq must have at least 2 items");var o=i(t,a[1]);s.messageImprint=nt.asn1.tsp.TSPUtil.parseMessageImprint(o);for(var h=2;h<a.length;h++){var u=a[h],c=t.substr(u,2);if("06"==c){var l=r(t,u);s.policy=e.hextooidstr(l)}"02"==c&&(s.nonce=r(t,u)),"01"==c&&(s.certreq=!0)}return s}},void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),void 0!==nt.asn1.cades&&nt.asn1.cades||(nt.asn1.cades={}),nt.asn1.cades.SignaturePolicyIdentifier=function(t){var e=nt.asn1.cades,r=e.SignaturePolicyId;e.SignaturePolicyIdentifier.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.15",this.params=null,this.getValueArray=function(){return[new r(this.params)]},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},jt(nt.asn1.cades.SignaturePolicyIdentifier,nt.asn1.cms.Attribute),nt.asn1.cades.SignaturePolicyId=function(t){var e=nt.asn1,r=e.DERSequence,i=e.DERObjectIdentifier,s=(e.x509.AlgorithmIdentifier,e.cades),n=s.SignaturePolicyId,a=s.OtherHashAlgAndValue;n.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return e.push(new i(t.oid)),e.push(new a(t)),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},jt(nt.asn1.cades.SignaturePolicyId,nt.asn1.ASN1Object),nt.asn1.cades.OtherHashAlgAndValue=function(t){var e=Error,r=nt.asn1,i=r.DERSequence,s=r.DEROctetString,n=r.x509.AlgorithmIdentifier;r.cades.OtherHashAlgAndValue.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(null==t.alg)throw new e("property 'alg' not specified");if(null==t.hash&&null==t.cert)throw new e("property 'hash' nor 'cert' not specified");var r=null;if(null!=t.hash)r=t.hash;else if(null!=t.cert){if("string"!=typeof t.cert)throw new e("cert not string");var a=t.cert;-1!=t.cert.indexOf("-----BEGIN")&&(a=xt(t.cert)),r=nt.crypto.Util.hashHex(a,t.alg)}var o=[];return o.push(new n({name:t.alg})),o.push(new s({hex:r})),new i({array:o}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cades.OtherHashAlgAndValue,nt.asn1.ASN1Object),nt.asn1.cades.OtherHashValue=function(t){nt.asn1.cades.OtherHashValue.superclass.constructor.call(this);var e=Error,r=nt,i=(r.lang.String.isHex,r.asn1.DEROctetString);r.crypto.Util.hashHex,this.params=null,this.tohex=function(){var t=this.params;if(null==t.hash&&null==t.cert)throw new e("hash or cert not specified");var r=null;if(null!=t.hash)r=t.hash;else if(null!=t.cert){if("string"!=typeof t.cert)throw new e("cert not string");var s=t.cert;-1!=t.cert.indexOf("-----BEGIN")&&(s=xt(t.cert)),r=nt.crypto.Util.hashHex(s,"sha1")}return new i({hex:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cades.OtherHashValue,nt.asn1.ASN1Object),nt.asn1.cades.SignatureTimeStamp=function(t){var e=Error,r=nt,i=r.lang.String.isHex,s=r.asn1,n=s.ASN1Object;s.x509,s.cades.SignatureTimeStamp.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.14",this.params=null,this.getValueArray=function(){var t=this.params;if(null!=t.tst){if(i(t.tst))return(r=new n).hTLV=t.tst,[r];if(t.tst instanceof n)return[t.tst];throw new e("params.tst has wrong value")}if(null!=t.res){var r,s=t.res;if(s instanceof n&&(s=s.tohex()),"string"!=typeof s||!i(s))throw new e("params.res has wrong value");return ht.getTLVbyList(s,0,[1]),(r=new n).hTLV=t.tst,[r]}},null!=t&&this.setByParam(t)},jt(nt.asn1.cades.SignatureTimeStamp,nt.asn1.cms.Attribute),nt.asn1.cades.CompleteCertificateRefs=function(t){var e=Error,r=nt,i=r.asn1,s=i.DERSequence,n=i.cades,a=n.OtherCertID,o=r.lang.String.isHex;n.CompleteCertificateRefs.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.21",this.params=null,this.getValueArray=function(){for(var t=this.params,r=[],i=0;i<t.array.length;i++){var n=t.array[i];if("string"==typeof n)if(-1!=n.indexOf("-----BEGIN"))n={cert:n};else{if(!o(n))throw new e("unsupported value: "+n);n={hash:n}}null!=t.alg&&null==n.alg&&(n.alg=t.alg),null!=t.hasis&&null==n.hasis&&(n.hasis=t.hasis);var h=new a(n);r.push(h)}return[new s({array:r})]},null!=t&&this.setByParam(t)},jt(nt.asn1.cades.CompleteCertificateRefs,nt.asn1.cms.Attribute),nt.asn1.cades.OtherCertID=function(t){var e=nt.asn1,r=e.DERSequence,i=e.cms.IssuerSerial,s=e.cades,n=s.OtherHashValue,a=s.OtherHashAlgAndValue;s.OtherCertID.superclass.constructor.call(this),this.params=t,this.tohex=function(){var t=this.params;"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?t={cert:t}:_isHex(t)&&(t={hash:t}));var e,s=[];if(e=null!=t.alg?new a(t):new n(t),s.push(e),null!=t.cert&&1==t.hasis||null!=t.issuer&&null!=t.serial){var o=new i(t);s.push(o)}return new r({array:s}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cades.OtherCertID,nt.asn1.ASN1Object),nt.asn1.cades.OtherHash=function(t){Error;var e=nt,r=e.asn1,i=(r.cms,r.cades),s=i.OtherHashAlgAndValue,n=i.OtherHashValue,a=(e.crypto.Util.hashHex,e.lang.String.isHex);i.OtherHash.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;return"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?t={cert:t}:a(t)&&(t={hash:t})),(null!=t.alg?new s(t):new n(t)).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cades.OtherHash,nt.asn1.ASN1Object),nt.asn1.cades.CAdESUtil=new function(){},nt.asn1.cades.CAdESUtil.parseSignedDataForAddingUnsigned=function(t){return(new nt.asn1.cms.CMSParser).getCMSSignedData(t)},nt.asn1.cades.CAdESUtil.parseSignerInfoForAddingUnsigned=function(t,e,r){var i=ht,s=i.getChildIdx,n=i.getTLV,a=i.getV,o=nt.asn1,h=o.ASN1Object,u=o.cms,c=u.AttributeList,l=u.SignerInfo,g={},p=s(t,e);if(6!=p.length)throw"not supported items for SignerInfo (!=6)";var d=p.shift();g.version=n(t,d);var f=p.shift();g.si=n(t,f);var y=p.shift();g.digalg=n(t,y);var v=p.shift();g.sattrs=n(t,v);var m=p.shift();g.sigalg=n(t,m);var S=p.shift();g.sig=n(t,S),g.sigval=a(t,S);var E=null;return g.obj=new l,(E=new h).hTLV=g.version,g.obj.dCMSVersion=E,(E=new h).hTLV=g.si,g.obj.dSignerIdentifier=E,(E=new h).hTLV=g.digalg,g.obj.dDigestAlgorithm=E,(E=new h).hTLV=g.sattrs,g.obj.dSignedAttrs=E,(E=new h).hTLV=g.sigalg,g.obj.dSigAlg=E,(E=new h).hTLV=g.sig,g.obj.dSig=E,g.obj.dUnsignedAttrs=new c,g},void 0!==nt.asn1.csr&&nt.asn1.csr||(nt.asn1.csr={}),nt.asn1.csr.CertificationRequest=function(t){var e=nt.asn1,r=e.DERBitString,i=e.DERSequence,s=e.csr,n=(e.x509,s.CertificationRequestInfo);s.CertificationRequest.superclass.constructor.call(this),this.setByParam=function(t){this.params=t},this.sign=function(){var t=new n(this.params).tohex(),e=new nt.crypto.Signature({alg:this.params.sigalg});e.init(this.params.sbjprvkey),e.updateHex(t);var r=e.sign();this.params.sighex=r},this.getPEM=function(){return Et(this.tohex(),"CERTIFICATE REQUEST")},this.tohex=function(){var t=this.params,e=new nt.asn1.csr.CertificationRequestInfo(this.params),s=new nt.asn1.x509.AlgorithmIdentifier({name:t.sigalg});if(null==t.sighex&&null!=t.sbjprvkey&&this.sign(),null==t.sighex)throw new Error("sighex or sbjprvkey parameter not defined");var n=new r({hex:"00"+t.sighex});return new i({array:[e,s,n]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.csr.CertificationRequest,nt.asn1.ASN1Object),nt.asn1.csr.CertificationRequestInfo=function(t){var e=nt.asn1,r=(e.DERBitString,e.DERSequence),i=e.DERInteger,s=e.DERUTF8String,n=e.DERTaggedObject,a=e.ASN1Util.newObject,o=e.csr,h=e.x509,u=h.X500Name,c=h.Extensions,l=h.SubjectPublicKeyInfo;o.AttributeList,o.CertificationRequestInfo.superclass.constructor.call(this),this.params=null,this.setByParam=function(t){null!=t&&(this.params=t)},this.tohex=function(){var t=this.params,e=[];if(e.push(new i({int:0})),e.push(new u(t.subject)),e.push(new l(Mt.getKey(t.sbjpubkey))),null!=t.attrs){var o=function(t){for(var e=Error,r=nt.asn1.x509.Extensions,i=[],s=0;s<t.length;s++){var n=t[s],a=n.attr;if("extensionRequest"==a){var o={seq:[{oid:"1.2.840.113549.1.9.14"},{set:[new r(n.ext)]}]};i.push(o)}else if("unstructuredName"==a)o={seq:[{oid:"1.2.840.113549.1.9.2"},{set:n.names}]},i.push(o);else{if("challengePassword"!=a)throw new e("unknown CSR attribute");o={seq:[{oid:"1.2.840.113549.1.9.7"},{set:[{utf8str:n.password}]}]},i.push(o)}}return{set:i}}(t.attrs),h=a({tag:{tage:"a0",obj:o}});e.push(h)}else if(null!=t.extreq){var g=new c(t.extreq);h=a({tag:{tage:"a0",obj:{seq:[{oid:"1.2.840.113549.1.9.14"},{set:[g]}]}}}),e.push(h)}else e.push(new n({tag:"a0",explicit:!1,obj:new s({str:""})}));return new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.csr.CertificationRequestInfo,nt.asn1.ASN1Object),nt.asn1.csr.AttributeList=function(t){},jt(nt.asn1.csr.AttributeList,nt.asn1.ASN1Object),nt.asn1.csr.CSRUtil=new function(){},nt.asn1.csr.CSRUtil.newCSRPEM=function(t){return new nt.asn1.csr.CertificationRequest(t).getPEM()},nt.asn1.csr.CSRUtil.getParam=function(t,e){var r=ht,i=r.getV,s=r.getIdxbyList,n=r.getTLVbyList,a=r.getTLVbyListEx,o=r.getVbyListEx,h={};if(-1==t.indexOf("-----BEGIN CERTIFICATE REQUEST"))throw new Error("argument is not PEM file");var u=xt(t,"CERTIFICATE REQUEST");e&&(h.tbs=n(u,0,[0]));try{var c=a(u,0,[0,1]);if("3000"==c)h.subject={};else{var l=new Wt;h.subject=l.getX500Name(c)}}catch(t){}var g=a(u,0,[0,2]),p=Mt.getKey(g,null,"pkcs8pub");h.sbjpubkey=Mt.getPEM(p,"PKCS8PUB");var d=function(t){var e=s(t,0,[0,3,0,0],"06");return"2a864886f70d01090e"!=i(t,e)?null:n(t,0,[0,3,0,1,0],"30")}(u);l=new Wt,null!=d&&(h.extreq=l.getExtParamArray(d));try{var f=a(u,0,[1],"30");l=new Wt,h.sigalg=l.getAlgorithmIdentifierName(f)}catch(t){}try{var y=o(u,0,[2]);h.sighex=y}catch(t){}return h},nt.asn1.csr.CSRUtil.verifySignature=function(t){try{var e=null;if("string"==typeof t&&-1!=t.indexOf("-----BEGIN CERTIFICATE REQUEST")?e=nt.asn1.csr.CSRUtil.getParam(t,!0):"object"==typeof t&&null!=t.sbjpubkey&&null!=t.sigalg&&null!=t.sighex&&null!=t.tbs&&(e=t),null==e)return!1;var r=new nt.crypto.Signature({alg:e.sigalg});return r.init(e.sbjpubkey),r.updateHex(e.tbs),r.verify(e.sighex)}catch(t){return alert(t),!1}},void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),void 0!==nt.asn1.ocsp&&nt.asn1.ocsp||(nt.asn1.ocsp={}),nt.asn1.ocsp.DEFAULT_HASH="sha1",nt.asn1.ocsp.OCSPResponse=function(t){nt.asn1.ocsp.OCSPResponse.superclass.constructor.call(this),nt.asn1.DEREnumerated;var e=nt.asn1.ASN1Util.newObject,r=nt.asn1.ocsp.ResponseBytes,i=["successful","malformedRequest","internalError","tryLater","_not_used_","sigRequired","unauthorized"];this.params=null,this._getStatusCode=function(){var t=this.params.resstatus;return"number"==typeof t?t:"string"!=typeof t?-1:i.indexOf(t)},this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params,i=this._getStatusCode();if(-1==i)throw new Error("responseStatus not supported: "+t.resstatus);if(0!=i)return e({seq:[{enum:{int:i}}]}).tohex();var s=new r(t);return e({seq:[{enum:{int:0}},{tag:{tag:"a0",explicit:!0,obj:s}}]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.ocsp.OCSPResponse,nt.asn1.ASN1Object),nt.asn1.ocsp.ResponseBytes=function(t){nt.asn1.ocsp.ResponseBytes.superclass.constructor.call(this);var e=nt.asn1,r=e.DERSequence,i=e.DERObjectIdentifier,s=e.DEROctetString,n=e.ocsp.BasicOCSPResponse;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if("ocspBasic"!=t.restype)throw new Error("not supported responseType: "+t.restype);var e=new n(t),a=[];return a.push(new i({name:"ocspBasic"})),a.push(new s({hex:e.tohex()})),new r({array:a}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.ocsp.ResponseBytes,nt.asn1.ASN1Object),nt.asn1.ocsp.BasicOCSPResponse=function(t){nt.asn1.ocsp.BasicOCSPResponse.superclass.constructor.call(this);var e=Error,r=nt.asn1,i=r.ASN1Object,s=r.DERSequence,n=(r.DERGeneralizedTime,r.DERTaggedObject),a=r.DERBitString,o=(r.x509.Extensions,r.x509.AlgorithmIdentifier),h=r.ocsp;h.ResponderID,_SingleResponseList=h.SingleResponseList,_ResponseData=h.ResponseData,this.params=null,this.setByParam=function(t){this.params=t},this.sign=function(){var t=this.params,e=t.tbsresp.tohex(),r=new nt.crypto.Signature({alg:t.sigalg});r.init(t.reskey),r.updateHex(e),t.sighex=r.sign()},this.tohex=function(){var t=this.params;null==t.tbsresp&&(t.tbsresp=new _ResponseData(t)),null==t.sighex&&null!=t.reskey&&this.sign();var r=[];if(r.push(t.tbsresp),r.push(new o({name:t.sigalg})),r.push(new a({hex:"00"+t.sighex})),null!=t.certs&&null!=t.certs.length){for(var h=[],u=0;u<t.certs.length;u++){var c=t.certs[u],l=null;if(ht.isASN1HEX(c))l=c;else{if(!c.match(/-----BEGIN/))throw new e("certs["+u+"] not hex or PEM");l=xt(c)}h.push(new i({tlv:l}))}var g=new s({array:h});r.push(new n({tag:"a0",explicit:!0,obj:g}))}return new s({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.ocsp.BasicOCSPResponse,nt.asn1.ASN1Object),nt.asn1.ocsp.ResponseData=function(t){nt.asn1.ocsp.ResponseData.superclass.constructor.call(this);var e=Error,r=nt.asn1,i=r.DERSequence,s=r.DERGeneralizedTime,n=r.DERTaggedObject,a=r.x509.Extensions,o=r.ocsp,h=o.ResponderID;_SingleResponseList=o.SingleResponseList,this.params=null,this.tohex=function(){var t=this.params;null!=t.respid&&new e("respid not specified"),null!=t.prodat&&new e("prodat not specified"),null!=t.array&&new e("array not specified");var r=[];if(r.push(new h(t.respid)),r.push(new s(t.prodat)),r.push(new _SingleResponseList(t.array)),null!=t.ext){var o=new a(t.ext);r.push(new n({tag:"a1",explicit:!0,obj:o}))}return new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},jt(nt.asn1.ocsp.ResponseData,nt.asn1.ASN1Object),nt.asn1.ocsp.ResponderID=function(t){nt.asn1.ocsp.ResponderID.superclass.constructor.call(this);var e=nt,r=e.asn1,i=r.ASN1Util.newObject,s=r.x509.X500Name,n=e.lang.String.isHex,a=Error;this.params=null,this.tohex=function(){var t=this.params;if(null!=t.key){var e,r=null;if("string"==typeof t.key?(n(t.key)&&(r=t.key),t.key.match(/-----BEGIN CERTIFICATE/)&&null!=(e=new Wt(t.key).getExtSubjectKeyIdentifier())&&(r=e.kid.hex)):t.key instanceof Wt&&null!=(e=t.key.getExtSubjectKeyIdentifier())&&(r=e.kid.hex),null==r)throw new a("wrong key member value");return i({tag:{tag:"a2",explicit:!0,obj:{octstr:{hex:r}}}}).tohex()}if(null!=t.name){var o=null;if("string"==typeof t.name&&t.name.match(/-----BEGIN CERTIFICATE/)?o=new Wt(t.name).getSubject():t.name instanceof Wt?o=t.name.getSubject():"object"!=typeof t.name||null==t.name.array&&null==t.name.str||(o=t.name),null==o)throw new a("wrong name member value");return i({tag:{tag:"a1",explicit:!0,obj:new s(o)}}).tohex()}throw new a("key or name not specified")},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},jt(nt.asn1.ocsp.ResponderID,nt.asn1.ASN1Object),nt.asn1.ocsp.SingleResponseList=function(t){nt.asn1.ocsp.SingleResponseList.superclass.constructor.call(this);var e=nt.asn1,r=e.DERSequence,i=e.ocsp.SingleResponse;this.params=null,this.tohex=function(){var t=this.params;if("object"!=typeof t||null==t.length)throw new Error("params not specified properly");for(var e=[],s=0;s<t.length;s++)e.push(new i(t[s]));return new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},jt(nt.asn1.ocsp.SingleResponseList,nt.asn1.ASN1Object),nt.asn1.ocsp.SingleResponse=function(t){var e=Error,r=nt.asn1,i=r.DERSequence,s=r.DERGeneralizedTime,n=r.DERTaggedObject,a=r.ocsp,o=a.CertID,h=a.CertStatus,u=r.x509.Extensions;a.SingleResponse.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,r=[];if(null==t.certid)throw new e("certid unspecified");if(null==t.status)throw new e("status unspecified");if(null==t.thisupdate)throw new e("thisupdate unspecified");if(r.push(new o(t.certid)),r.push(new h(t.status)),r.push(new s(t.thisupdate)),null!=t.nextupdate){var a=new s(t.nextupdate);r.push(new n({tag:"a0",explicit:!0,obj:a}))}if(null!=t.ext){var c=new u(t.ext);r.push(new n({tag:"a1",explicit:!0,obj:c}))}return new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},jt(nt.asn1.ocsp.SingleResponse,nt.asn1.ASN1Object),nt.asn1.ocsp.CertID=function(t){var e=nt,r=e.asn1,i=r.DEROctetString,s=r.DERInteger,n=r.DERSequence,a=r.x509.AlgorithmIdentifier,o=r.ocsp,h=(o.DEFAULT_HASH,e.crypto.Util.hashHex),u=Wt,c=ht.getVbyList;o.CertID.superclass.constructor.call(this),this.DEFAULT_HASH="sha1",this.params=null,this.setByValue=function(t,e,r,i){null==i&&(i=this.DEFAULT_HASH),this.params={alg:i,issname:t,isskey:e,sbjsn:r}},this.setByCert=function(t,e,r){null==r&&(r=this.DEFAULT_HASH),this.params={alg:r,issuerCert:t,subjectCert:e}},this.getParamByCerts=function(t,e,r){null==r&&(r=this.DEFAULT_HASH);var i=new u(t),s=new u(e),n=h(i.getSubjectHex(),r),a=i.getPublicKeyHex();return{alg:r,issname:n,isskey:h(c(a,0,[1],"03",!0),r),sbjsn:s.getSerialNumberHex()}},this.tohex=function(){if("object"!=typeof this.params)throw new Error("params not set");var t,e,r,o,h=this.params;if(o=null==h.alg?this.DEFAULT_HASH:h.alg,null!=h.issuerCert&&null!=h.subjectCert){var u=this.getParamByCerts(h.issuerCert,h.subjectCert,o);t=u.issname,e=u.isskey,r=u.sbjsn}else{if(null==h.issname||null==h.isskey||null==h.sbjsn)throw new Error("required param members not defined");t=h.issname,e=h.isskey,r=h.sbjsn}var c=new a({name:o}),l=new i({hex:t}),g=new i({hex:e}),p=new s({hex:r}),d=new n({array:[c,l,g,p]});return this.hTLV=d.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.ocsp.CertID,nt.asn1.ASN1Object),nt.asn1.ocsp.CertStatus=function(t){nt.asn1.ocsp.CertStatus.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if("good"==t.status)return"8000";if("unknown"==t.status)return"8200";if("revoked"==t.status){var e=[{gentime:{str:t.time}}];null!=t.reason&&e.push({tag:{tag:"a0",explicit:!0,obj:{enum:{int:t.reason}}}});var r={tag:"a1",explicit:!1,obj:{seq:e}};return nt.asn1.ASN1Util.newObject({tag:r}).tohex()}throw new Error("bad status")},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},jt(nt.asn1.ocsp.CertStatus,nt.asn1.ASN1Object),nt.asn1.ocsp.Request=function(t){var e=nt.asn1,r=e.DERSequence,i=e.ocsp;if(i.Request.superclass.constructor.call(this),this.dReqCert=null,this.dExt=null,this.tohex=function(){var t=[];if(null===this.dReqCert)throw"reqCert not set";t.push(this.dReqCert);var e=new r({array:t});return this.hTLV=e.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t){var s=new i.CertID(t);this.dReqCert=s}},jt(nt.asn1.ocsp.Request,nt.asn1.ASN1Object),nt.asn1.ocsp.TBSRequest=function(t){var e=nt.asn1,r=e.DERSequence,i=e.ocsp;i.TBSRequest.superclass.constructor.call(this),this.version=0,this.dRequestorName=null,this.dRequestList=[],this.dRequestExt=null,this.setRequestListByParam=function(t){for(var e=[],r=0;r<t.length;r++){var s=new i.Request(t[0]);e.push(s)}this.dRequestList=e},this.tohex=function(){var t=[];if(0!==this.version)throw"not supported version: "+this.version;if(null!==this.dRequestorName)throw"requestorName not supported";var e=new r({array:this.dRequestList});if(t.push(e),null!==this.dRequestExt)throw"requestExtensions not supported";var i=new r({array:t});return this.hTLV=i.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&void 0!==t.reqList&&this.setRequestListByParam(t.reqList)},jt(nt.asn1.ocsp.TBSRequest,nt.asn1.ASN1Object),nt.asn1.ocsp.OCSPRequest=function(t){var e=nt.asn1,r=e.DERSequence,i=e.ocsp;if(i.OCSPRequest.superclass.constructor.call(this),this.dTbsRequest=null,this.dOptionalSignature=null,this.tohex=function(){var t=[];if(null===this.dTbsRequest)throw"tbsRequest not set";if(t.push(this.dTbsRequest),null!==this.dOptionalSignature)throw"optionalSignature not supported";var e=new r({array:t});return this.hTLV=e.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&void 0!==t.reqList){var s=new i.TBSRequest(t);this.dTbsRequest=s}},jt(nt.asn1.ocsp.OCSPRequest,nt.asn1.ASN1Object),nt.asn1.ocsp.OCSPUtil={},nt.asn1.ocsp.OCSPUtil.getRequestHex=function(t,e,r){var i=nt.asn1.ocsp;void 0===r&&(r=i.DEFAULT_HASH);var s={alg:r,issuerCert:t,subjectCert:e};return new i.OCSPRequest({reqList:[s]}).tohex()},nt.asn1.ocsp.OCSPUtil.getOCSPResponseInfo=function(t){var e=ht,r=e.getVbyList,i=e.getVbyListEx,s=e.getIdxbyList,n=(e.getIdxbyListEx,e.getV),a={};try{var o=i(t,0,[0],"0a");a.responseStatus=parseInt(o,16)}catch(t){}if(0!==a.responseStatus)return a;try{var h=s(t,0,[1,0,1,0,0,2,0,1]);"80"===t.substr(h,2)?a.certStatus="good":"a1"===t.substr(h,2)?(a.certStatus="revoked",a.revocationTime=yt(r(t,h,[0]))):"82"===t.substr(h,2)&&(a.certStatus="unknown")}catch(t){}try{var u=s(t,0,[1,0,1,0,0,2,0,2]);a.thisUpdate=yt(n(t,u))}catch(t){}try{var c=s(t,0,[1,0,1,0,0,2,0,3]);"a0"===t.substr(c,2)&&(a.nextUpdate=yt(r(t,c,[0])))}catch(t){}return a},nt.asn1.ocsp.OCSPParser=function(){var t=Error,e=Wt,r=new e,i=ht,s=i.getV,n=i.getTLV,a=i.getIdxbyList,o=i.getVbyList,h=i.getTLVbyList,u=i.getVbyListEx,c=i.getTLVbyListEx,l=i.getChildIdx;this.getOCSPRequest=function(e){var r=l(e,0);if(1!=r.length&&2!=r.length)throw new t("wrong number elements: "+r.length);return this.getTBSRequest(n(e,r[0]))},this.getTBSRequest=function(t){var e={},i=c(t,0,[0],"30");e.array=this.getRequestList(i);var s=c(t,0,["[2]",0],"30");return null!=s&&(e.ext=r.getExtParamArray(s)),e},this.getRequestList=function(t){for(var e=[],r=l(t,0),i=0;i<r.length;i++)t=n(t,r[i]),e.push(this.getRequest(t));return e},this.getRequest=function(e){var i=l(e,0);if(1!=i.length&&2!=i.length)throw new t("wrong number elements: "+i.length);var s=this.getCertID(n(e,i[0]));if(2==i.length){var o=a(e,0,[1,0]);s.ext=r.getExtParamArray(n(e,o))}return s},this.getCertID=function(r){var i=l(r,0);if(4!=i.length)throw new t("wrong number elements: "+i.length);var a=new e,o={};return o.alg=a.getAlgorithmIdentifierName(n(r,i[0])),o.issname=s(r,i[1]),o.isskey=s(r,i[2]),o.sbjsn=s(r,i[3]),o},this.getOCSPResponse=function(t){var e,r=l(t,0),i=s(t,r[0]),n=parseInt(i);if(1==r.length)return{resstatus:n};var a=h(t,0,[1,0]);return(e=this.getResponseBytes(a)).resstatus=n,e},this.getResponseBytes=function(t){var e,r=l(t,0),i=h(t,0,[1,0]);e=this.getBasicOCSPResponse(i);var n=s(t,r[0]);return e.restype=nt.asn1.x509.OID.oid2name(Bt(n)),e},this.getBasicOCSPResponse=function(t){var e,r=l(t,0);e=this.getResponseData(n(t,r[0]));var i=new Wt;e.alg=i.getAlgorithmIdentifierName(n(t,r[1]));var a=s(t,r[2]);e.sighex=a.substr(2);var o=u(t,0,["[0]"]);if(null!=o){for(var h=l(o,0),c=[],g=0;g<h.length;g++){var p=n(o,h[g]);c.push(p)}e.certs=c}return e},this.getResponseData=function(t){var e=l(t,0),r=e.length,i={},a=0;"a0"==t.substr(e[0],2)&&a++,i.respid=this.getResponderID(n(t,e[a++]));var o=s(t,e[a++]);if(i.prodat=yt(o),i.array=this.getSingleResponseList(n(t,e[a++])),"a1"==t.substr(e[r-1],2)){var u=h(t,e[r-1],[0]),c=new Wt;i.ext=c.getExtParamArray(u)}return i},this.getResponderID=function(t){var e={};if("a2"==t.substr(0,2)){var r=o(t,0,[0]);e.key=r}if("a1"==t.substr(0,2)){var i=h(t,0,[0]),s=new Wt;e.name=s.getX500Name(i)}return e},this.getSingleResponseList=function(t){for(var e=l(t,0),r=[],i=0;i<e.length;i++){var s=this.getSingleResponse(n(t,e[i]));r.push(s)}return r},this.getSingleResponse=function(t){var e=l(t,0),r={},i=this.getCertID(n(t,e[0]));r.certid=i;var a=this.getCertStatus(n(t,e[1]));if(r.status=a,"18"==t.substr(e[2],2)){var u=s(t,e[2]);r.thisupdate=yt(u)}for(var c=3;c<e.length;c++){if("a0"==t.substr(e[c],2)){var g=o(t,e[c],[0],"18");r.nextupdate=yt(g)}if("a1"==t.substr(e[c],2)){var p=new Wt,d=h(t,0,[c,0]);r.ext=p.getExtParamArray(d)}}return r},this.getCertStatus=function(t){var e={};if("8000"==t)return{status:"good"};if("8200"==t)return{status:"unknown"};if("a1"==t.substr(0,2)){e.status="revoked";var r=yt(o(t,0,[0]));e.time=r}return e}},void 0!==nt&&nt||(nt={}),void 0!==nt.lang&&nt.lang||(nt.lang={}),nt.lang.String=function(){},"function"==typeof Buffer?(at=function(t){return lt(Buffer.from(t,"utf8").toString("base64"))},ot=function(t){return Buffer.from(gt(t),"base64").toString("utf8")}):(at=function(t){return pt(At(Dt(t)))},ot=function(t){return decodeURIComponent(wt(dt(t)))}),nt.lang.String.isInteger=function(t){return!!t.match(/^[0-9]+$/)||!!t.match(/^-[0-9]+$/)},nt.lang.String.isHex=function(t){return Nt(t)},nt.lang.String.isBase64=function(t){return!(!(t=t.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||t.length%4!=0)},nt.lang.String.isBase64URL=function(t){return!t.match(/[+/=]/)&&(t=gt(t),nt.lang.String.isBase64(t))},nt.lang.String.isIntegerArray=function(t){return!!(t=t.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)},nt.lang.String.isPrintable=function(t){return null!==t.match(/^[0-9A-Za-z '()+,-./:=?]*$/)},nt.lang.String.isIA5=function(t){return null!==t.match(/^[\x20-\x21\x23-\x7f]*$/)},nt.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 kt=function(t,e,r){return null==r&&(r="0"),t.length>=e?t:new Array(e-t.length+1).join(r)+t};function Ut(t,e){for(var r=0,i=0;i<t.length;i++)r|=1<<e[t[i]];var s=r.toString(2),n="";for(i=s.length-1;i>=0;i--)n+=s[i];return n}function Vt(t,e,r){if("object"==typeof t){e=String(e).split(".");for(var i=0;i<e.length&&t;i++){var s=e[i];s.match(/^[0-9]+$/)&&(s=parseInt(s)),t=t[s]}return t||!1===t?t:r}}function jt(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!==nt&&nt||(nt={}),void 0!==nt.crypto&&nt.crypto||(nt.crypto={}),nt.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:f.algo.MD5,sha1:f.algo.SHA1,sha224:f.algo.SHA224,sha256:f.algo.SHA256,sha384:f.algo.SHA384,sha512:f.algo.SHA512,ripemd160:f.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 i=this.getDigestInfoHex(t,e),s=r/4;if(i.length+22>s)throw"key is too short for SigAlg: keylen="+r+","+e;for(var n="00"+i,a="",o=s-4-n.length,h=0;h<o;h+=2)a+="ff";return"0001"+a+n},this.hashString=function(t,e){return new nt.crypto.MessageDigest({alg:e}).digestString(t)},this.hashHex=function(t,e){return new nt.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 nt.crypto.DSA||t instanceof nt.crypto.ECDSA}},nt.crypto.Util.md5=function(t){return new nt.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(t)},nt.crypto.Util.ripemd160=function(t){return new nt.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(t)},nt.crypto.Util.SECURERANDOMGEN=new Q,nt.crypto.Util.getRandomHexOfNbytes=function(t){var e=new Array(t);return nt.crypto.Util.SECURERANDOMGEN.nextBytes(e),ut(e)},nt.crypto.Util.getRandomBigIntegerOfNbytes=function(t){return new E(nt.crypto.Util.getRandomHexOfNbytes(t),16)},nt.crypto.Util.getRandomHexOfNbits=function(t){var e=t%8,r=new Array((t-e)/8+1);return nt.crypto.Util.SECURERANDOMGEN.nextBytes(r),r[0]=(255<<e&255^255)&r[0],ut(r)},nt.crypto.Util.getRandomBigIntegerOfNbits=function(t){return new E(nt.crypto.Util.getRandomHexOfNbits(t),16)},nt.crypto.Util.getRandomBigIntegerZeroToMax=function(t){for(var e=t.bitLength();;){var r=nt.crypto.Util.getRandomBigIntegerOfNbits(e);if(-1!=t.compareTo(r))return r}},nt.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 i=e.subtract(t);return nt.crypto.Util.getRandomBigIntegerZeroToMax(i).add(t)},nt.crypto.MessageDigest=function(t){this.setAlgAndProvider=function(t,e){if(null!==(t=nt.crypto.MessageDigest.getCanonicalAlgName(t))&&void 0===e&&(e=nt.crypto.Util.DEFAULTPROVIDER[t]),-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(t)&&"cryptojs"==e){try{this.md=nt.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=f.enc.Hex.parse(t);this.md.update(e)},this.digest=function(){return this.md.finalize().toString(f.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=nt.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},nt.crypto.MessageDigest.getCanonicalAlgName=function(t){return"string"==typeof t&&(t=(t=t.toLowerCase()).replace(/-/,"")),t},nt.crypto.MessageDigest.getHashLength=function(t){var e=nt.crypto.MessageDigest,r=e.getCanonicalAlgName(t);if(void 0===e.HASHLENGTH[r])throw"not supported algorithm: "+t;return e.HASHLENGTH[r]},nt.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},nt.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=nt.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 i=nt.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[r];this.mac=f.algo.HMAC.create(i,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=f.enc.Hex.parse(t);this.mac.update(e)},this.doFinal=function(){return this.mac.finalize().toString(f.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=St(t)),void(this.pass=f.enc.Hex.parse(e))}if("object"!=typeof t)throw"KJUR.crypto.Mac unsupported password type: "+t;if(e=null,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=ft(t.utf8)),void 0!==t.rstr&&(e=St(t.rstr)),void 0!==t.b64&&(e=S(t.b64)),void 0!==t.b64u&&(e=dt(t.b64u)),null==e)throw"KJUR.crypto.Mac unsupported password type: "+t;this.pass=f.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=nt.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))},nt.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="",i=e/4-t.length,s=0;s<i;s++)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 nt.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?Mt.getKey(t):Mt.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!==nt.crypto.ECDSA&&(this.prvKey=new nt.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 nt.crypto.ECDSA)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex);else{if(!(this.prvKey instanceof nt.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!==nt.crypto.ECDSA&&(this.pubKey=new nt.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!==nt.crypto.ECDSA&&this.pubKey instanceof nt.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==nt.crypto.DSA&&this.pubKey instanceof nt.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=nt.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=Mt.getKey(t.prvkeypem),this.init(e)}catch(t){throw"fatal error to load pem private key: "+t}}},nt.crypto.Cipher=function(t){},nt.crypto.Cipher.encrypt=function(t,e,r,i){if(null!=Vt(i,"enclag")&&(r=i.encalg),"string"==typeof r&&"-CBC"==r.substr(-4)){var s=e,n=t;null!=Vt(i,"key")&&(s=i.key),null!=Vt(i,"enc")&&(hEnc=i.enc);var a,o=f.enc.Hex.parse(s),h=f.enc.Hex.parse(n),u=f.enc.Hex.parse(i.iv);if("des-EDE3-CBC"==r)a=f.TripleDES.encrypt(h,o,{iv:u});else{if("aes128-CBC"!=r&&"aes256-CBC"!=r)throw new Error("unsupported algorithm: "+r);a=f.AES.encrypt(h,o,{iv:u})}return a+""}throw new Error("Cipher.encrypt: unsupported key or algorithm")},nt.crypto.Cipher.decrypt=function(t,e,r,i){if(null!=Vt(i,"enclag")&&(r=i.encalg),"string"==typeof r&&"-CBC"==r.substr(-4)){var s=e,n=t;null!=Vt(i,"key")&&(s=i.key),null!=Vt(i,"enc")&&(n=i.enc);var a,o=f.enc.Hex.parse(s),h=f.enc.Hex.parse(n),u=f.enc.Hex.parse(i.iv);if("des-EDE3-CBC"==r)a=f.TripleDES.decrypt({ciphertext:h},o,{iv:u});else{if("aes128-CBC"!=r&&"aes256-CBC"!=r)throw new Error("unsupported algorithm: "+r);a=f.AES.decrypt({ciphertext:h},o,{iv:u})}return f.enc.Hex.stringify(a)}throw new Error("Cipher.decrypt: unsupported key or algorithm")},nt.crypto.OID=new function(){this.oidhex2name={"2a864886f70d010101":"rsaEncryption","2a8648ce3d0201":"ecPublicKey","2a8648ce380401":"dsa","2a8648ce3d030107":"secp256r1","2b8104001f":"secp192k1","2b81040021":"secp224r1","2b8104000a":"secp256k1","2b81040022":"secp384r1","2b81040023":"secp521r1","2a8648ce380403":"SHA1withDSA","608648016503040301":"SHA224withDSA","608648016503040302":"SHA256withDSA"}},void 0!==nt&&nt||(nt={}),void 0!==nt.crypto&&nt.crypto||(nt.crypto={}),nt.crypto.ECDSA=function(t){var e=Error,r=E,i=rt,s=nt.crypto.ECDSA,n=nt.crypto.ECParameterDB,a=s.getName,o=ht,h=o.getVbyListEx,u=o.isASN1HEX,c=new Q;this.type="EC",this.isPrivate=!1,this.isPublic=!1,this.getBigRandom=function(t){return new r(t.bitLength(),c).mod(t.subtract(r.ONE)).add(r.ONE)},this.setNamedCurve=function(t){this.ecparams=n.getByName(t),this.prvKeyHex=null,this.pubKeyHex=null,this.curveName=t},this.setPrivateKeyHex=function(t){this.isPrivate=!0,this.prvKeyHex=t},this.setPublicKeyHex=function(t){this.isPublic=!0,this.pubKeyHex=t},this.getPublicKeyXYHex=function(){var t=this.pubKeyHex;if("04"!==t.substr(0,2))throw"this method supports uncompressed format(04) only";var e=this.ecparams.keycharlen;if(t.length!==2+2*e)throw"malformed public key hex length";var r={};return r.x=t.substr(2,e),r.y=t.substr(2+e),r},this.getShortNISTPCurveName=function(){var t=this.curveName;return"secp256r1"===t||"NIST P-256"===t||"P-256"===t||"prime256v1"===t?"P-256":"secp384r1"===t||"NIST P-384"===t||"P-384"===t?"P-384":"secp521r1"===t||"NIST P-521"===t||"P-521"===t?"P-521":null},this.generateKeyPairHex=function(){var t=this.ecparams.n,e=this.getBigRandom(t),r=this.ecparams.keycharlen,i=("0000000000"+e.toString(16)).slice(-r);return this.setPrivateKeyHex(i),{ecprvhex:i,ecpubhex:this.generatePublicKeyHex()}},this.generatePublicKeyHex=function(){var t=new r(this.prvKeyHex,16),e=this.ecparams.G.multiply(t),i=e.getX().toBigInteger(),s=e.getY().toBigInteger(),n=this.ecparams.keycharlen,a="04"+("0000000000"+i.toString(16)).slice(-n)+("0000000000"+s.toString(16)).slice(-n);return this.setPublicKeyHex(a),a},this.signWithMessageHash=function(t){return this.signHex(t,this.prvKeyHex)},this.signHex=function(t,e){var i=new r(e,16),n=this.ecparams.n,a=new r(t.substring(0,this.ecparams.keycharlen),16);do{var o=this.getBigRandom(n),h=this.ecparams.G.multiply(o).getX().toBigInteger().mod(n)}while(h.compareTo(r.ZERO)<=0);var u=o.modInverse(n).multiply(a.add(i.multiply(h))).mod(n);return s.biRSSigToASN1Sig(h,u)},this.sign=function(t,e){var i=e,s=this.ecparams.n,n=r.fromByteArrayUnsigned(t);do{var a=this.getBigRandom(s),o=this.ecparams.G.multiply(a).getX().toBigInteger().mod(s)}while(o.compareTo(E.ZERO)<=0);var h=a.modInverse(s).multiply(n.add(i.multiply(o))).mod(s);return this.serializeSig(o,h)},this.verifyWithMessageHash=function(t,e){return this.verifyHex(t,e,this.pubKeyHex)},this.verifyHex=function(t,e,n){try{var a,o,h=s.parseSigHex(e);a=h.r,o=h.s;var u=i.decodeFromHex(this.ecparams.curve,n),c=new r(t.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(c,a,o,u)}catch(t){return!1}},this.verify=function(t,e,s){var n,a,o;if(Bitcoin.Util.isArray(e)){var h=this.parseSig(e);n=h.r,a=h.s}else{if("object"!=typeof e||!e.r||!e.s)throw"Invalid value for signature";n=e.r,a=e.s}if(s instanceof rt)o=s;else{if(!Bitcoin.Util.isArray(s))throw"Invalid format for pubkey value, must be byte array or ECPointFp";o=i.decodeFrom(this.ecparams.curve,s)}var u=r.fromByteArrayUnsigned(t);return this.verifyRaw(u,n,a,o)},this.verifyRaw=function(t,e,i,s){var n=this.ecparams.n,a=this.ecparams.G;if(e.compareTo(r.ONE)<0||e.compareTo(n)>=0)return!1;if(i.compareTo(r.ONE)<0||i.compareTo(n)>=0)return!1;var o=i.modInverse(n),h=t.multiply(o).mod(n),u=e.multiply(o).mod(n);return a.multiply(h).add(s.multiply(u)).getX().toBigInteger().mod(n).equals(e)},this.serializeSig=function(t,e){var r=t.toByteArraySigned(),i=e.toByteArraySigned(),s=[];return s.push(2),s.push(r.length),(s=s.concat(r)).push(2),s.push(i.length),(s=s.concat(i)).unshift(s.length),s.unshift(48),s},this.parseSig=function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if(2!=t[e=2])throw new Error("First element in signature must be a DERInteger");var i=t.slice(e+2,e+2+t[e+1]);if(2!=t[e+=2+t[e+1]])throw new Error("Second element in signature must be a DERInteger");var s=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:r.fromByteArrayUnsigned(i),s:r.fromByteArrayUnsigned(s)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||e>7)throw"Invalid signature type";var i=this.ecparams.n;return{r:r.fromByteArrayUnsigned(t.slice(1,33)).mod(i),s:r.fromByteArrayUnsigned(t.slice(33,65)).mod(i),i:e}},this.readPKCS5PrvKeyHex=function(t){if(!1===u(t))throw new Error("not ASN.1 hex string");var e,r,i;try{e=h(t,0,["[0]",0],"06"),r=h(t,0,[1],"04");try{i=h(t,0,["[1]",0],"03")}catch(t){}}catch(t){throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=a(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(i),this.setPrivateKeyHex(r),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){if(!1===u(t))throw new e("not ASN.1 hex string");var r,i,s;try{h(t,0,[1,0],"06"),r=h(t,0,[1,1],"06"),i=h(t,0,[2,0,1],"04");try{s=h(t,0,[2,0,"[1]",0],"03")}catch(t){}}catch(t){throw new e("malformed PKCS#8 plain ECC private key")}if(this.curveName=a(r),void 0===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(s),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){if(!1===u(t))throw new e("not ASN.1 hex string");var r,i;try{h(t,0,[0,0],"06"),r=h(t,0,[0,1],"06"),i=h(t,0,[1],"03")}catch(t){throw new e("malformed PKCS#8 ECC public key")}if(this.curveName=a(r),null===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(i)},this.readCertPubKeyHex=function(t,r){if(!1===u(t))throw new e("not ASN.1 hex string");var i,s;try{i=h(t,0,[0,5,0,1],"06"),s=h(t,0,[0,5,1],"03")}catch(t){throw new e("malformed X.509 certificate ECC public key")}if(this.curveName=a(i),null===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(s)},void 0!==t&&void 0!==t.curve&&(this.curveName=t.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==t&&(void 0!==t.prv&&this.setPrivateKeyHex(t.prv),void 0!==t.pub&&this.setPublicKeyHex(t.pub))},nt.crypto.ECDSA.parseSigHex=function(t){var e=nt.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new E(e.r,16),s:new E(e.s,16)}},nt.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=ht,r=e.getChildIdx,i=e.getV;if(e.checkStrictDER(t,0),"30"!=t.substr(0,2))throw new Error("signature is not a ASN.1 sequence");var s=r(t,0);if(2!=s.length)throw new Error("signature shall have two elements");var n=s[0],a=s[1];if("02"!=t.substr(n,2))throw new Error("1st item not ASN.1 integer");if("02"!=t.substr(a,2))throw new Error("2nd item not ASN.1 integer");return{r:i(t,n),s:i(t,a)}},nt.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=nt.crypto.ECDSA.parseSigHexInHexRS(t),r=e.r,i=e.s;if(r.length>=130&&r.length<=134){if(r.length%2!=0)throw Error("unknown ECDSA sig r length error");if(i.length%2!=0)throw Error("unknown ECDSA sig s length error");"00"==r.substr(0,2)&&(r=r.substr(2)),"00"==i.substr(0,2)&&(i=i.substr(2));var s=Math.max(r.length,i.length);return(r=("000000"+r).slice(-s))+("000000"+i).slice(-s)}if("00"==r.substr(0,2)&&r.length%32==2&&(r=r.substr(2)),"00"==i.substr(0,2)&&i.length%32==2&&(i=i.substr(2)),r.length%32==30&&(r="00"+r),i.length%32==30&&(i="00"+i),r.length%32!=0)throw Error("unknown ECDSA sig r length error");if(i.length%32!=0)throw Error("unknown ECDSA sig s length error");return r+i},nt.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length%4!=0)throw Error("unknown ECDSA concatinated r-s sig length error");var e=t.substr(0,t.length/2),r=t.substr(t.length/2);return nt.crypto.ECDSA.hexRSSigToASN1Sig(e,r)},nt.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var r=new E(t,16),i=new E(e,16);return nt.crypto.ECDSA.biRSSigToASN1Sig(r,i)},nt.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var r=nt.asn1,i=new r.DERInteger({bigint:t}),s=new r.DERInteger({bigint:e});return new r.DERSequence({array:[i,s]}).tohex()},nt.crypto.ECDSA.getName=function(t){return"2b8104001f"===t?"secp192k1":"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040021"===t?"secp224r1":"2b81040022"===t?"secp384r1":"2b81040023"===t?"secp521r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp224r1|NIST P-224|P-224|".indexOf(t)?"secp224r1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":-1!=="|secp521r1|NIST P-521|P-521|".indexOf(t)?"secp521r1":null},void 0!==nt&&nt||(nt={}),void 0!==nt.crypto&&nt.crypto||(nt.crypto={}),nt.crypto.ECParameterDB=new function(){var t={},e={};function r(t){return new E(t,16)}this.getByName=function(r){var i=r;if(void 0!==e[i]&&(i=e[r]),void 0!==t[i])return t[i];throw"unregistered EC curve name: "+i},this.regist=function(i,s,n,a,o,h,u,c,l,g,p,d){t[i]={};var f=r(n),y=r(a),v=r(o),m=r(h),S=r(u),E=new it(f,y,v),x=E.decodePointHex("04"+c+l);t[i].name=i,t[i].keylen=s,t[i].keycharlen=2*Math.ceil(s/8),t[i].curve=E,t[i].G=x,t[i].n=m,t[i].h=S,t[i].oid=p,t[i].info=d;for(var A=0;A<g.length;A++)e[g[A]]=i}},nt.crypto.ECParameterDB.regist("secp128r1",128,"FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC","E87579C11079F43DD824993C2CEE5ED3","FFFFFFFE0000000075A30D1B9038A115","1","161FF7528B899B2D0C28607CA52C5B86","CF5AC8395BAFEB13C02DA292DDED7A83",[],"","secp128r1 : SECG curve over a 128 bit prime field"),nt.crypto.ECParameterDB.regist("secp160k1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73","0","7","0100000000000000000001B8FA16DFAB9ACA16B6B3","1","3B4C382CE37AA192A4019E763036F4F5DD4D7EBB","938CF935318FDCED6BC28286531733C3F03C4FEE",[],"","secp160k1 : SECG curve over a 160 bit prime field"),nt.crypto.ECParameterDB.regist("secp160r1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC","1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45","0100000000000000000001F4C8F927AED3CA752257","1","4A96B5688EF573284664698968C38BB913CBFC82","23A628553168947D59DCC912042351377AC5FB32",[],"","secp160r1 : SECG curve over a 160 bit prime field"),nt.crypto.ECParameterDB.regist("secp192k1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37","0","3","FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D","1","DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D","9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D",[]),nt.crypto.ECParameterDB.regist("secp192r1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC","64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1","FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831","1","188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012","07192B95FFC8DA78631011ED6B24CDD573F977A11E794811",[]),nt.crypto.ECParameterDB.regist("secp224r1",224,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE","B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4","FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D","1","B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21","BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34",[]),nt.crypto.ECParameterDB.regist("secp256k1",256,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F","0","7","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141","1","79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798","483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8",[]),nt.crypto.ECParameterDB.regist("secp256r1",256,"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC","5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B","FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551","1","6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296","4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5",["NIST P-256","P-256","prime256v1"]),nt.crypto.ECParameterDB.regist("secp384r1",384,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC","B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973","1","AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7","3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f",["NIST P-384","P-384"]),nt.crypto.ECParameterDB.regist("secp521r1",521,"1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC","051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409","1","00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66","011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650",["NIST P-521","P-521"]),void 0!==nt&&nt||(nt={}),void 0!==nt.crypto&&nt.crypto||(nt.crypto={}),nt.crypto.DSA=function(){var t=ht,e=(t.getVbyList,t.getVbyListEx),r=t.isASN1HEX,i=E;this.p=null,this.q=null,this.g=null,this.y=null,this.x=null,this.type="DSA",this.isPrivate=!1,this.isPublic=!1,this.setPrivate=function(t,e,r,i,s){this.isPrivate=!0,this.p=t,this.q=e,this.g=r,this.y=i,this.x=s},this.setPrivateHex=function(t,e,r,i,s){var n,a,o,h,u;n=new E(t,16),a=new E(e,16),o=new E(r,16),h="string"==typeof i&&i.length>1?new E(i,16):null,u=new E(s,16),this.setPrivate(n,a,o,h,u)},this.setPublic=function(t,e,r,i){this.isPublic=!0,this.p=t,this.q=e,this.g=r,this.y=i,this.x=null},this.setPublicHex=function(t,e,r,i){var s,n,a,o;s=new E(t,16),n=new E(e,16),a=new E(r,16),o=new E(i,16),this.setPublic(s,n,a,o)},this.signWithMessageHash=function(t){var e=this.p,r=this.q,i=this.g,s=(this.y,this.x),n=nt.crypto.Util.getRandomBigIntegerMinToMax(E.ONE.add(E.ONE),r.subtract(E.ONE)),a=new E(t.substr(0,r.bitLength()/4),16),o=i.modPow(n,e).mod(r),h=n.modInverse(r).multiply(a.add(s.multiply(o))).mod(r);return nt.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:o}},{int:{bigint:h}}]})},this.verifyWithMessageHash=function(t,e){var r=this.p,i=this.q,s=this.g,n=this.y,a=this.parseASN1Signature(e),o=a[0],h=a[1],u=new E(t.substr(0,i.bitLength()/4),16);if(E.ZERO.compareTo(o)>0||o.compareTo(i)>0)throw"invalid DSA signature";if(E.ZERO.compareTo(h)>=0||h.compareTo(i)>0)throw"invalid DSA signature";var c=h.modInverse(i),l=u.multiply(c).mod(i),g=o.multiply(c).mod(i);return 0==s.modPow(l,r).multiply(n.modPow(g,r)).mod(r).mod(i).compareTo(o)},this.parseASN1Signature=function(t){try{return[new i(e(t,0,[0],"02"),16),new i(e(t,0,[1],"02"),16)]}catch(t){throw new Error("malformed ASN.1 DSA signature")}},this.readPKCS5PrvKeyHex=function(t){var i,s,n,a,o;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[1],"02"),s=e(t,0,[2],"02"),n=e(t,0,[3],"02"),a=e(t,0,[4],"02"),o=e(t,0,[5],"02")}catch(t){throw new Error("malformed PKCS#1/5 plain DSA private key")}this.setPrivateHex(i,s,n,a,o)},this.readPKCS8PrvKeyHex=function(t){var i,s,n,a;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[1,1,0],"02"),s=e(t,0,[1,1,1],"02"),n=e(t,0,[1,1,2],"02"),a=e(t,0,[2,0],"02")}catch(t){throw new Error("malformed PKCS#8 plain DSA private key")}this.setPrivateHex(i,s,n,null,a)},this.readPKCS8PubKeyHex=function(t){var i,s,n,a;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[0,1,0],"02"),s=e(t,0,[0,1,1],"02"),n=e(t,0,[0,1,2],"02"),a=e(t,0,[1,0],"02")}catch(t){throw new Error("malformed PKCS#8 DSA public key")}this.setPublicHex(i,s,n,a)},this.readCertPubKeyHex=function(t,i){var s,n,a,o;if(!1===r(t))throw new Error("not ASN.1 hex string");try{s=e(t,0,[0,5,0,1,0],"02"),n=e(t,0,[0,5,0,1,1],"02"),a=e(t,0,[0,5,0,1,2],"02"),o=e(t,0,[0,5,1,0],"02")}catch(t){throw new Error("malformed X.509 certificate DSA public key")}this.setPublicHex(s,n,a,o)}};var Mt=function(){var t=function(t,r,i){return e(f.AES,t,r,i)},e=function(t,e,r,i){var s=f.enc.Hex.parse(e),n=f.enc.Hex.parse(r),a=f.enc.Hex.parse(i),o={};o.key=n,o.iv=a,o.ciphertext=s;var h=t.decrypt(o,n,{iv:a});return f.enc.Hex.stringify(h)},r=function(t,e,r){return i(f.AES,t,e,r)},i=function(t,e,r,i){var s=f.enc.Hex.parse(e),n=f.enc.Hex.parse(r),a=f.enc.Hex.parse(i),o=t.encrypt(s,n,{iv:a}),h=f.enc.Hex.parse(o.toString());return f.enc.Base64.stringify(h)},s={"AES-256-CBC":{proc:t,eproc:r,keylen:32,ivlen:16},"AES-192-CBC":{proc:t,eproc:r,keylen:24,ivlen:16},"AES-128-CBC":{proc:t,eproc:r,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,r,i){return e(f.TripleDES,t,r,i)},eproc:function(t,e,r){return i(f.TripleDES,t,e,r)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,r,i){return e(f.DES,t,r,i)},eproc:function(t,e,r){return i(f.DES,t,e,r)},keylen:8,ivlen:8}},n=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 i=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));i&&(e.type=i[1]);var s=-1,n=0;-1!=t.indexOf("\r\n\r\n")&&(s=t.indexOf("\r\n\r\n"),n=2),-1!=t.indexOf("\n\n")&&(s=t.indexOf("\n\n"),n=1);var a=t.indexOf("-----END");if(-1!=s&&-1!=a){var o=t.substring(s+2*n,a-n);o=o.replace(/\s+/g,""),e.data=o}return e},a=function(t,e,r){for(var i=r.substring(0,16),n=f.enc.Hex.parse(i),a=f.enc.Utf8.parse(e),o=s[t].keylen+s[t].ivlen,h="",u=null;;){var c=f.algo.MD5.create();if(null!=u&&c.update(u),c.update(a),c.update(n),u=c.finalize(),(h+=f.enc.Hex.stringify(u)).length>=2*o)break}var l={};return l.keyhex=h.substr(0,2*s[t].keylen),l.ivhex=h.substr(2*s[t].keylen,2*s[t].ivlen),l},o=function(t,e,r,i){var n=f.enc.Base64.parse(t),a=f.enc.Hex.stringify(n);return(0,s[e].proc)(a,r,i)};return{version:"1.0.0",parsePKCS5PEM:function(t){return n(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,r){return a(t,e,r)},decryptKeyB64:function(t,e,r,i){return o(t,e,r,i)},getDecryptedKeyHex:function(t,e){var r=n(t),i=(r.type,r.cipher),s=r.ivsalt,h=r.data,u=a(i,e,s).keyhex;return o(h,i,u,s)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,r,i,n){var o="";if(void 0!==i&&null!=i||(i="AES-256-CBC"),void 0===s[i])throw new Error("KEYUTIL unsupported algorithm: "+i);if(void 0===n||null==n){var h=function(t){var e=f.lib.WordArray.random(t);return f.enc.Hex.stringify(e)}(s[i].ivlen);n=h.toUpperCase()}var u=function(t,e,r,i){return(0,s[e].eproc)(t,r,i)}(e,i,a(i,r,n).keyhex,n);return o="-----BEGIN "+t+" PRIVATE KEY-----\r\n",o+="Proc-Type: 4,ENCRYPTED\r\n",o+="DEK-Info: "+i+","+n+"\r\n",o+="\r\n",(o+=u.replace(/(.{64})/g,"$1\r\n"))+"\r\n-----END "+t+" PRIVATE KEY-----\r\n"},getEncryptedPKCS8PEM:function(t,e,r){return Et(this.getEncryptedPKCS8Hex(t,e,r),"ENCRYPTED PRIVATE KEY")},getEncryptedPKCS8Hex:function(t,e,r){var i;(i=null==r||null==r?{}:JSON.parse(JSON.stringify(r))).plain=t,this.initPBES2Param(i),this.encryptPBES2Param(i,e);var s=this.generatePBES2ASN1Param(i);return nt.asn1.ASN1Util.newObject(s).tohex()},initPBES2Param:function(t){var e;null==Vt(t,"encalg")&&(t.encalg="aes256-CBC"),null==Vt(t,"iter")&&(t.iter=2048),null==Vt(t,"prf")&&(t.prf="hmacWithSHA256"),null==Vt(t,"salt")&&(t.salt=f.enc.Hex.stringify(f.lib.WordArray.random(8))),null==Vt(t,"enciv")&&("des-EDE3-CBC"==t.encalg&&(e=8),"aes128-CBC"==t.encalg&&(e=16),"aes256-CBC"==t.encalg&&(e=16),t.enciv=f.enc.Hex.stringify(f.lib.WordArray.random(e)))},encryptPBES2Param:function(t,e){var r=Mt.getDKFromPBES2Param(t,e);try{var i=nt.crypto.Cipher.encrypt(t.plain,r,t.encalg,{iv:t.enciv})}catch(e){throw new Error("encrypt error: "+t.plain+" "+r+" "+t.encalg+" "+t.enciv)}t.enc=i},generatePBES2ASN1Param:function(t){var e={seq:[{seq:[{oid:"pkcs5PBES2"},{seq:[{seq:[{oid:"pkcs5PBKDF2"},{seq:[{octstr:{hex:t.salt}},{int:{hex:Lt(t.iter)}}]}]},{seq:[{oid:t.encalg},{octstr:{hex:t.enciv}}]}]}]},{octstr:{hex:t.enc}}]};return"hmacWithSHA1"!=t.prf&&e.seq[0].seq[1].seq[0].seq[1].seq.push({seq:[{oid:t.prf},{null:""}]}),e},parseHexOfEncryptedPKCS8:function(t){var e=ht,r=e.getChildIdx,i=e.getV,s={},n=r(t,0);if(2!=n.length)throw new Error("malformed format: SEQUENCE(0).items != 2: "+n.length);s.ciphertext=i(t,n[1]);var a=r(t,n[0]);if(2!=a.length)throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+a.length);if("2a864886f70d01050d"!=i(t,a[0]))throw new Error("this only supports pkcs5PBES2");var o=r(t,a[1]);if(2!=a.length)throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+o.length);var h=r(t,o[1]);if(2!=h.length)throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+h.length);if("2a864886f70d0307"!=i(t,h[0]))throw"this only supports TripleDES";s.encryptionSchemeAlg="TripleDES",s.encryptionSchemeIV=i(t,h[1]);var u=r(t,o[0]);if(2!=u.length)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+u.length);if("2a864886f70d01050c"!=i(t,u[0]))throw new Error("this only supports pkcs5PBKDF2");var c=r(t,u[1]);if(c.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+c.length);s.pbkdf2Salt=i(t,c[0]);var l=i(t,c[1]);try{s.pbkdf2Iter=parseInt(l,16)}catch(t){throw new Error("malformed format pbkdf2Iter: "+l)}return s},getPBKDF2KeyHexFromParam:function(t,e){var r=f.enc.Hex.parse(t.pbkdf2Salt),i=t.pbkdf2Iter,s=f.PBKDF2(e,r,{keySize:6,iterations:i});return f.enc.Hex.stringify(s)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var r=xt(t,"ENCRYPTED PRIVATE KEY"),i=this.parseHexOfEncryptedPKCS8(r),s=Mt.getPBKDF2KeyHexFromParam(i,e),n={};n.ciphertext=f.enc.Hex.parse(i.ciphertext);var a=f.enc.Hex.parse(s),o=f.enc.Hex.parse(i.encryptionSchemeIV),h=f.TripleDES.decrypt(n,a,{iv:o});return f.enc.Hex.stringify(h)},parsePBES2:function(t){var e=ht.parse(t);if("pkcs5PBES2"!=Vt(e,"seq.0.seq.0.oid")||"pkcs5PBKDF2"!=Vt(e,"seq.0.seq.1.seq.0.seq.0.oid"))throw new Error("not pkcs5PBES2 and pkcs5PBKDF2 used");var r=Vt(e,"seq.0.seq.1.seq.0.seq.1.seq");if(null==r)throw new Error("PBKDF2 parameter not found");var i=Vt(r,"0.octstr.hex"),s=Vt(r,"1.int.hex"),n=Vt(r,"2.seq.0.oid","hmacWithSHA1"),a=-1;try{a=parseInt(s,16)}catch(t){throw new Error("iter not proper value")}var o=Vt(e,"seq.0.seq.1.seq.1.seq.0.oid"),h=Vt(e,"seq.0.seq.1.seq.1.seq.1.octstr.hex"),u=Vt(e,"seq.1.octstr.hex");if(null==o||null==h||null==u)throw new Error("encalg, enciv or enc is undefined");return{salt:i,iter:a,prf:n,encalg:o,enciv:h,enc:u}},getDKFromPBES2Param:function(t,e){var r={hmacWithSHA1:f.algo.SHA1,hmacWithSHA224:f.algo.SHA224,hmacWithSHA256:f.algo.SHA256,hmacWithSHA384:f.algo.SHA384,hmacWithSHA512:f.algo.SHA512}[t.prf];if(null==r)throw new Error("unsupported prf");var i={"des-EDE3-CBC":6,"aes128-CBC":4,"aes256-CBC":8}[t.encalg];if(null==i)throw new Error("unsupported encalg");var s=f.enc.Hex.parse(t.salt),n=t.iter;try{var a=f.PBKDF2(e,s,{keySize:i,iterations:n,hasher:r});return f.enc.Hex.stringify(a)}catch(r){throw new Error("PBKDF2 error: "+r+" "+JSON.stringify(t)+" "+e)}},getPlainHexFromEncryptedPKCS8PEM:function(t,e){if(-1==t.indexOf("BEGIN ENCRYPTED PRIVATE KEY"))throw new Error("not Encrypted PKCS#8 PEM string");var r,i=xt(t);try{r=Mt.parsePBES2(i)}catch(t){throw new Error("malformed PBES2 format: "+t.message)}var s=Mt.getDKFromPBES2Param(r,e);return nt.crypto.Cipher.decrypt(r.enc,s,r.encalg,{iv:r.enciv})},getKeyFromEncryptedPKCS8PEM:function(t,e){var r=this.getPlainHexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(r)},parsePlainPrivatePKCS8Hex:function(t){var e=ht,r=e.getChildIdx,i=e.getV,s={algparam:null};if("30"!=t.substr(0,2))throw new Error("malformed plain PKCS8 private key(code:001)");var n=r(t,0);if(n.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if("30"!=t.substr(n[1],2))throw new Error("malformed PKCS8 private key(code:003)");var a=r(t,n[1]);if(2!=a.length)throw new Error("malformed PKCS8 private key(code:004)");if("06"!=t.substr(a[0],2))throw new Error("malformed PKCS8 private key(code:005)");if(s.algoid=i(t,a[0]),"06"==t.substr(a[1],2)&&(s.algparam=i(t,a[1])),"04"!=t.substr(n[2],2))throw new Error("malformed PKCS8 private key(code:006)");return s.keyidx=e.getVidx(t,n[2]),s},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=xt(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 nt.crypto.DSA;else{if("2a8648ce3d0201"!=r.algoid)throw new Error("unsupported private key algorithm");e=new nt.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,r=ht.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===r)e=new tt;else if("2a8648ce380401"===r)e=new nt.crypto.DSA;else{if("2a8648ce3d0201"!==r)throw new Error("unsupported PKCS#8 public key hex");e=new nt.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=ht,r=e.getChildIdx,i=e.getV,s={};if("30"!=t.substr(0,2))throw new Error("malformed RSA key(code:001)");var n=r(t,0);if(2!=n.length)throw new Error("malformed RSA key(code:002)");if("02"!=t.substr(n[0],2))throw new Error("malformed RSA key(code:003)");if(s.n=i(t,n[0]),"02"!=t.substr(n[1],2))throw new Error("malformed RSA key(code:004)");return s.e=i(t,n[1]),s},parsePublicPKCS8Hex:function(t){var e=ht,r=e.getChildIdx,i=e.getV,s={algparam:null},n=r(t,0);if(2!=n.length)throw new Error("outer DERSequence shall have 2 elements: "+n.length);var a=n[0];if("30"!=t.substr(a,2))throw new Error("malformed PKCS8 public key(code:001)");var o=r(t,a);if(2!=o.length)throw new Error("malformed PKCS8 public key(code:002)");if("06"!=t.substr(o[0],2))throw new Error("malformed PKCS8 public key(code:003)");if(s.algoid=i(t,o[0]),"06"==t.substr(o[1],2)?s.algparam=i(t,o[1]):"30"==t.substr(o[1],2)&&(s.algparam={},s.algparam.p=e.getVbyList(t,o[1],[0],"02"),s.algparam.q=e.getVbyList(t,o[1],[1],"02"),s.algparam.g=e.getVbyList(t,o[1],[2],"02")),"03"!=t.substr(n[1],2))throw new Error("malformed PKCS8 public key(code:004)");return s.key=i(t,n[1]).substr(2),s}}}();function Kt(t,e){for(var r="",i=e/4-t.length,s=0;s<i;s++)r+="0";return r+t}function qt(t,e,r){for(var i="",s=0;i.length<e;)i+=mt(r(St(t+String.fromCharCode.apply(String,[(4278190080&s)>>24,(16711680&s)>>16,(65280&s)>>8,255&s])))),s+=1;return i}function Gt(t){for(var e in nt.crypto.Util.DIGESTINFOHEAD){var r=nt.crypto.Util.DIGESTINFOHEAD[e],i=r.length;if(t.substring(0,i)==r)return[e,t.substring(i)]}return[]}function Wt(t){var e,r=ht,i=r.getChildIdx,s=r.getV,n=(r.dump,r.parse),a=r.getTLV,o=r.getVbyList,h=r.getVbyListEx,u=r.getTLVbyList,c=r.getTLVbyListEx,l=r.getIdxbyList,g=r.getIdxbyListEx,p=r.getVidx,d=r.getInt,f=r.oidname,y=r.hextooidstr,v=xt,m=Error;try{e=nt.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=d(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 h(this.hex,0,[0,0],"02")},this.getSignatureAlgorithmField=function(){var t=c(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 f(h(t,0,[0],"06"))},this.getIssuer=function(t,e){return this.getX500Name(this.getIssuerHex(),t,e)},this.getIssuerHex=function(){return u(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return this.getIssuer().str},this.getSubject=function(t,e){return this.getX500Name(this.getSubjectHex(),t,e)},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"),decodeURIComponent(t)},this.getNotAfter=function(){var t=o(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),decodeURIComponent(t)},this.getPublicKeyHex=function(){return this.getSPKI()},this.getSPKI=function(){return u(this.hex,0,[0,6+this.foffset],"30")},this.getSPKIValue=function(){var t=this.getSPKI();return null==t?null:o(t,0,[1],"03",!0)},this.getPublicKeyIdx=function(){return l(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return l(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return Mt.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(),i=u(this.hex,0,[0],"30"),s=new nt.crypto.Signature({alg:e});return s.init(t),s.updateHex(i),s.verify(r)},this.parseExt=function(t){var e,n,a;if(void 0===t){if(a=this.hex,3!==this.version)return-1;e=l(a,0,[0,7,0],"30"),n=i(a,e)}else{a=xt(t);var h=l(a,0,[0,3,0,0],"06");if("2a864886f70d01090e"!=s(a,h))return void(this.aExtInfo=new Array);e=l(a,0,[0,3,0,1,0],"30"),n=i(a,e),this.hex=a}this.aExtInfo=new Array;for(var u=0;u<n.length;u++){var c={critical:!1},g=0;3===i(a,n[u]).length&&(c.critical=!0,g=1),c.oid=r.hextooidstr(o(a,n[u],[0],"06"));var d=l(a,n[u],[1+g]);c.vidx=p(a,d),this.aExtInfo.push(c)}},this.getExtInfo=function(t){var e=this.aExtInfo,r=t;if(t.match(/^[0-9.]+$/)||(r=nt.asn1.x509.OID.name2oid(t)),""!==r)for(var i=0;i<e.length;i++)if(e[i].oid===r)return e[i]},this.getCriticalExtV=function(t,e,r){if(null!=e)return[e,r];var i=this.getExtInfo(t);return null==i?[null,null]:[a(this.hex,i.vidx),i.critical]},this.getExtBasicConstraints=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("basicConstraints");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var i={extname:"basicConstraints"};if(e&&(i.critical=!0),"3000"===t)return i;if("30030101ff"===t)return i.cA=!0,i;if("30060101ff02"===t.substr(0,12)){var n=s(t,10),o=parseInt(n,16);return i.cA=!0,i.pathLen=o,i}throw new Error("hExtV parse error: "+t)},this.getExtNameConstraints=function(t,e){var r=this.getCriticalExtV("nameConstraints",t,e);if(t=r[0],e=r[1],null!=t){var s={extname:"nameConstraints"};e&&(s.critical=!0);for(var n=i(t,0),o=0;o<n.length;o++){for(var h=[],u=i(t,n[o]),c=0;c<u.length;c++){var l=a(t,u[c]),g=this.getGeneralSubtree(l);h.push(g)}var p=t.substr(n[o],2);"a0"==p?s.permit=h:"a1"==p&&(s.exclude=h)}return s}},this.getGeneralSubtree=function(t){var e=i(t,0),r=e.length;if(r<1||2<r)throw new Error("wrong num elements");for(var n=this.getGeneralName(a(t,e[0])),o=1;o<r;o++){var h=t.substr(e[o],2),u=s(t,e[o]),c=parseInt(u,16);"80"==h&&(n.min=c),"81"==h&&(n.max=c)}return n},this.getExtKeyUsage=function(t,e){var r=this.getCriticalExtV("keyUsage",t,e);if(t=r[0],e=r[1],null!=t){var i={extname:"keyUsage"};return e&&(i.critical=!0),i.names=this.getExtKeyUsageString(t).split(","),i}},this.getExtKeyUsageBin=function(t){if(void 0===t){var e=this.getExtInfo("keyUsage");if(void 0===e)return"";t=a(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,i=0;i<e.length;i++)"1"==e.substr(i,1)&&r.push(Wt.KEYUSAGE_NAME[i]);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=a(this.hex,r.vidx),e=r.critical}var i={extname:"subjectKeyIdentifier"};e&&(i.critical=!0);var n=s(t,0);return i.kid={hex:n},i},this.getExtAuthorityKeyIdentifier=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("authorityKeyIdentifier");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var n={extname:"authorityKeyIdentifier"};e&&(n.critical=!0);for(var o=i(t,0),h=0;h<o.length;h++){var u=t.substr(o[h],2);if("80"===u&&(n.kid={hex:s(t,o[h])}),"a1"===u){var c=a(t,o[h]),l=this.getGeneralNames(c);n.issuer=l[0].dn}"82"===u&&(n.sn={hex:s(t,o[h])})}return n},this.getExtExtKeyUsage=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("extKeyUsage");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var n={extname:"extKeyUsage",array:[]};e&&(n.critical=!0);for(var o=i(t,0),h=0;h<o.length;h++)n.array.push(f(s(t,o[h])));return n},this.getExtExtKeyUsageName=function(){var t=this.getExtInfo("extKeyUsage");if(void 0===t)return t;var e=new Array,r=a(this.hex,t.vidx);if(""===r)return e;for(var n=i(r,0),o=0;o<n.length;o++)e.push(f(s(r,n[o])));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=a(this.hex,r.vidx),e=r.critical}var i={extname:"subjectAltName",array:[]};return e&&(i.critical=!0),i.array=this.getGeneralNames(t),i},this.getExtIssuerAltName=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("issuerAltName");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var i={extname:"issuerAltName",array:[]};return e&&(i.critical=!0),i.array=this.getGeneralNames(t),i},this.getGeneralNames=function(t){for(var e=i(t,0),r=[],s=0;s<e.length;s++){var n=this.getGeneralName(a(t,e[s]));void 0!==n&&r.push(n)}return r},this.getGeneralName=function(t){var e=t.substr(0,2),r=s(t,0),i=mt(r);return"81"==e?{rfc822:i}:"82"==e?{dns:i}:"86"==e?{uri:i}:"87"==e?{ip:It(r)}:"a4"==e?{dn:this.getX500Name(r)}:"a0"==e?{other:this.getOtherName(t)}:void 0},this.getExtSubjectAltName2=function(){var t,e,r,n=this.getExtInfo("subjectAltName");if(void 0===n)return n;for(var o=new Array,h=a(this.hex,n.vidx),u=i(h,0),c=0;c<u.length;c++)r=h.substr(u[c],2),t=s(h,u[c]),"81"===r&&(e=yt(t),o.push(["MAIL",e])),"82"===r&&(e=yt(t),o.push(["DNS",e])),"84"===r&&(e=Wt.hex2dn(t,0),o.push(["DN",e])),"86"===r&&(e=yt(t),o.push(["URI",e])),"87"===r&&(e=It(t),o.push(["IP",e]));return o},this.getExtCRLDistributionPoints=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("cRLDistributionPoints");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var s={extname:"cRLDistributionPoints",array:[]};e&&(s.critical=!0);for(var n=i(t,0),o=0;o<n.length;o++){var h=a(t,n[o]);s.array.push(this.getDistributionPoint(h))}return s},this.getDistributionPoint=function(t){for(var e={},r=i(t,0),s=0;s<r.length;s++){var n=t.substr(r[s],2),o=a(t,r[s]);"a0"==n&&(e.dpname=this.getDistributionPointName(o))}return e},this.getDistributionPointName=function(t){for(var e={},r=i(t,0),s=0;s<r.length;s++){var n=t.substr(r[s],2),o=a(t,r[s]);"a0"==n&&(e.full=this.getGeneralNames(o))}return e},this.getExtCRLDistributionPointsURI=function(){var t=this.getExtCRLDistributionPoints();if(null==t)return t;for(var e=t.array,r=[],i=0;i<e.length;i++)try{null!=e[i].dpname.full[0].uri&&r.push(e[i].dpname.full[0].uri)}catch(t){}return r},this.getExtAIAInfo=function(){var t=this.getExtInfo("authorityInfoAccess");if(void 0===t)return t;for(var e={ocsp:[],caissuer:[]},r=i(this.hex,t.vidx),s=0;s<r.length;s++){var n=o(this.hex,r[s],[0],"06"),a=o(this.hex,r[s],[1],"86");"2b06010505073001"===n&&e.ocsp.push(yt(a)),"2b06010505073002"===n&&e.caissuer.push(yt(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=a(this.hex,r.vidx),e=r.critical}var s={extname:"authorityInfoAccess",array:[]};e&&(s.critical=!0);for(var n=i(t,0),u=0;u<n.length;u++){var c=h(t,n[u],[0],"06"),l=yt(o(t,n[u],[1],"86"));if("2b06010505073001"==c)s.array.push({ocsp:l});else{if("2b06010505073002"!=c)throw new Error("unknown method: "+c);s.array.push({caissuer:l})}}return s},this.getExtCertificatePolicies=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("certificatePolicies");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var s={extname:"certificatePolicies",array:[]};e&&(s.critical=!0);for(var n=i(t,0),o=0;o<n.length;o++){var h=a(t,n[o]),u=this.getPolicyInformation(h);s.array.push(u)}return s},this.getPolicyInformation=function(t){var e={},r=o(t,0,[0],"06");e.policyoid=f(r);var s=g(t,0,[1],"30");if(-1!=s){e.array=[];for(var n=i(t,s),h=0;h<n.length;h++){var u=a(t,n[h]),c=this.getPolicyQualifierInfo(u);e.array.push(c)}}return e},this.getOtherName=function(t){var e={},r=i(t,0),s=o(t,r[0],[],"06"),a=o(t,r[1],[]);return e.oid=f(s),e.value=n(a),e},this.getPolicyQualifierInfo=function(t){var e={},r=o(t,0,[0],"06");if("2b06010505070201"===r){var i=h(t,0,[1],"16");e.cps=mt(i)}else if("2b06010505070202"===r){var s=u(t,0,[1],"30");e.unotice=this.getUserNotice(s)}return e},this.getUserNotice=function(t){var e=null;try{return e=r.parse(t),this._asn1ToUnotice(e)}catch(t){return}},this._asn1ToUnotice=function(t){try{for(var e={},r=Vt(t,"seq"),i=0;i<r.length;i++){var s=this._asn1ToNoticeRef(r[i]);null!=s&&(e.noticeref=s);var n=this.asn1ToDisplayText(r[i]);null!=n&&(e.exptext=n)}return Object.keys(e).length>0?e:void 0}catch(t){return}},this._asn1ToNoticeRef=function(t){try{for(var e={},r=Vt(t,"seq"),i=0;i<r.length;i++){var s=this._asn1ToNoticeNum(r[i]);null!=s&&(e.noticenum=s);var n=this.asn1ToDisplayText(r[i]);null!=n&&(e.org=n)}return Object.keys(e).length>0?e:void 0}catch(t){return}},this._asn1ToNoticeNum=function(t){try{for(var e=Vt(t,"seq"),r=[],i=0;i<e.length;i++){var s=e[i];r.push(parseInt(Vt(s,"int.hex"),16))}return r}catch(t){return}},this.getDisplayText=function(t){var e={};return e.type={"0c":"utf8",16:"ia5","1a":"vis","1e":"bmp"}[t.substr(0,2)],e.str=mt(s(t,0)),e},this.asn1ToDisplayText=function(t){return null!=t.utf8str?{type:"utf8",str:t.utf8str.str}:null!=t.ia5str?{type:"ia5",str:t.ia5str.str}:null!=t.visstr?{type:"vis",str:t.visstr.str}:null!=t.bmpstr?{type:"bmp",str:t.bmpstr.str}:null!=t.prnstr?{type:"prn",str:t.prnstr.str}:void 0},this.getExtPolicyMappings=function(t,e){var r=this.getCriticalExtV("policyMappings",t,e);if(t=r[0],e=r[1],null!=t){var i={extname:"policyMappings"};e&&(i.critical=!0);try{for(var s=n(t).seq,a=[],o=0;o<s.length;o++){var h=s[o].seq;a.push([h[0].oid,h[1].oid])}i.array=a}catch(t){throw new m("malformed policyMappings")}return i}},this.getExtPolicyConstraints=function(t,e){var r=this.getCriticalExtV("policyConstraints",t,e);if(t=r[0],e=r[1],null!=t){var i={extname:"policyConstraints"};e&&(i.critical=!0);var s=n(t);try{for(var a=s.seq,o=0;o<a.length;o++){var h=a[o].tag;0==h.explicit&&("80"==h.tag&&(i.reqexp=parseInt(h.hex,16)),"81"==h.tag&&(i.inhibit=parseInt(h.hex,16)))}}catch(t){return new m("malformed policyConstraints value")}return i}},this.getExtInhibitAnyPolicy=function(t,e){var r=this.getCriticalExtV("inhibitAnyPolicy",t,e);if(t=r[0],e=r[1],null!=t){var i={extname:"inhibitAnyPolicy"};e&&(i.critical=!0);var s=d(t,0);return-1==s?new m("wrong value"):(i.skip=s,i)}},this.getExtCRLNumber=function(t,e){var r={extname:"cRLNumber"};if(e&&(r.critical=!0),"02"==t.substr(0,2))return r.num={hex:s(t,0)},r;throw new m("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(s(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 i=s(t,0);return r.hex=i,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=a(this.hex,r.vidx),e=r.critical}var s={extname:"adobeTimeStamp"};e&&(s.critical=!0);var n=i(t,0);if(n.length>1){var o=a(t,n[1]),h=this.getGeneralName(o);null!=h.uri&&(s.uri=h.uri)}if(n.length>2){var u=a(t,n[2]);"0101ff"==u&&(s.reqauth=!0),"010100"==u&&(s.reqauth=!1)}return s},this.getExtSubjectDirectoryAttributes=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectDirectoryAttributes");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var i={extname:"subjectDirectoryAttributes"};e&&(i.critical=!0);try{for(var s=n(t),o=[],h=0;h<s.seq.length;h++){var u=s.seq[h],c=Vt(u,"seq.0.oid"),l=Vt(u,"seq.1.set");if(null==c||null==l)throw"error";o.push({attr:c,array:l})}return i.array=o,i}catch(t){throw new Error("malformed subjectDirectoryAttributes extension value")}};var S=function(t){var e={};try{var r=t.seq[0].oid,i=nt.asn1.x509.OID.name2oid(r);e.type=nt.asn1.x509.OID.oid2atype(i);var s=t.seq[1];if(null!=s.utf8str)e.ds="utf8",e.value=s.utf8str.str;else if(null!=s.numstr)e.ds="num",e.value=s.numstr.str;else if(null!=s.telstr)e.ds="tel",e.value=s.telstr.str;else if(null!=s.prnstr)e.ds="prn",e.value=s.prnstr.str;else if(null!=s.ia5str)e.ds="ia5",e.value=s.ia5str.str;else if(null!=s.visstr)e.ds="vis",e.value=s.visstr.str;else{if(null==s.bmpstr)throw"error";e.ds="bmp",e.value=s.bmpstr.str}return e}catch(t){throw new Erorr("improper ASN.1 parsed AttrTypeAndValue")}},E=function(t){try{return t.set.map(function(t){return S(t)})}catch(t){throw new Error("improper ASN.1 parsed RDN: "+t)}};this.getX500NameRule=function(t){for(var e=null,r=[],i=0;i<t.length;i++)for(var s=t[i],n=0;n<s.length;n++)r.push(s[n]);for(i=0;i<r.length;i++){var a=r[i],o=a.ds,h=a.value,u=a.type;if("prn"!=o&&"utf8"!=o&&"ia5"!=o)return"mixed";if("ia5"==o){if("CN"!=u)return"mixed";if(nt.lang.String.isMail(h))continue;return"mixed"}if("C"==u){if("prn"==o)continue;return"mixed"}if(null==e)e=o;else if(e!==o)return"mixed"}return null==e?"prn":e},this.getAttrTypeAndValue=function(t){var e=n(t);return S(e)},this.getRDN=function(t){var e=n(t);return E(e)},this.getX500NameArray=function(t){return function(t){try{return t.seq.map(function(t){return E(t)})}catch(t){throw new Error("improper ASN.1 parsed X500Name: "+t)}}(n(t))},this.getX500Name=function(t,e,r){var i=this.getX500NameArray(t),s={str:this.dnarraytostr(i)};return s.array=i,1==r&&(s.hex=t),1==e&&(s.canon=this.c14nRDNArray(i)),s},this.readCertPEM=function(t){this.readCertHex(v(t))},this.readCertHex=function(t){this.hex=t,this.getVersion();try{l(this.hex,0,[0,7],"a3"),this.parseExt()}catch(t){}},this.getParam=function(t){var e={};return null==t&&(t={}),e.version=this.getVersion(),e.serial={hex:this.getSerialNumberHex()},e.sigalg=this.getSignatureAlgorithmField(),e.issuer=this.getIssuer(t.dncanon,t.dnhex),e.notbefore=this.getNotBefore(),e.notafter=this.getNotAfter(),e.subject=this.getSubject(t.dncanon,t.dnhex),e.sbjpubkey=Et(this.getPublicKeyHex(),"PUBLIC KEY"),null!=this.aExtInfo&&this.aExtInfo.length>0&&(e.ext=this.getExtParamArray()),e.sighex=this.getSignatureValueHex(),1==t.tbshex&&(e.tbshex=u(this.hex,0,[0])),1==t.nodnarray&&(delete e.issuer.array,delete e.subject.array),e},this.getExtParamArray=function(t){null==t&&-1!=g(this.hex,0,[0,"[3]"])&&(t=c(this.hex,0,[0,"[3]",0],"30"));for(var e=[],r=i(t,0),s=0;s<r.length;s++){var n=a(t,r[s]),o=this.getExtParam(n);null!=o&&e.push(o)}return e},this.getExtParam=function(t){var e=i(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")),s=!1;3==e&&"0101ff"==u(t,0,[1])&&(s=!0);var a=u(t,0,[e-1,0]),h=void 0;if("2.5.29.14"==r?h=this.getExtSubjectKeyIdentifier(a,s):"2.5.29.15"==r?h=this.getExtKeyUsage(a,s):"2.5.29.17"==r?h=this.getExtSubjectAltName(a,s):"2.5.29.18"==r?h=this.getExtIssuerAltName(a,s):"2.5.29.19"==r?h=this.getExtBasicConstraints(a,s):"2.5.29.30"==r?h=this.getExtNameConstraints(a,s):"2.5.29.31"==r?h=this.getExtCRLDistributionPoints(a,s):"2.5.29.32"==r?h=this.getExtCertificatePolicies(a,s):"2.5.29.33"==r?h=this.getExtPolicyMappings(a,s):"2.5.29.35"==r?h=this.getExtAuthorityKeyIdentifier(a,s):"2.5.29.36"==r?h=this.getExtPolicyConstraints(a,s):"2.5.29.37"==r?h=this.getExtExtKeyUsage(a,s):"2.5.29.54"==r?h=this.getExtInhibitAnyPolicy(a,s):"1.3.6.1.5.5.7.1.1"==r?h=this.getExtAuthorityInfoAccess(a,s):"2.5.29.20"==r?h=this.getExtCRLNumber(a,s):"2.5.29.21"==r?h=this.getExtCRLReason(a,s):"2.5.29.9"==r?h=this.getExtSubjectDirectoryAttributes(a,s):"1.3.6.1.5.5.7.48.1.2"==r?h=this.getExtOcspNonce(a,s):"1.3.6.1.5.5.7.48.1.5"==r?h=this.getExtOcspNoCheck(a,s):"1.2.840.113583.1.1.9.1"==r?h=this.getExtAdobeTimeStamp(a,s):null!=Wt.EXT_PARSER[r]&&(h=Wt.EXT_PARSER[r](r,s,a)),null!=h)return h;var c={extname:r,extn:a};try{c.extn=n(a)}catch(t){}return s&&(c.critical=!0),c},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 i=r.array,s=0;s<i.length;s++)if(null!=i[s].dpname&&null!=i[s].dpname.full)for(var n=i[s].dpname.full,a=0;a<n.length;a++){var o=n[s];null!=o.uri&&(o.uri=e)}},this.updateExtAIAOCSP=function(t,e){var r=this.findExt(t,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var i=r.array,s=0;s<i.length;s++)null!=i[s].ocsp&&(i[s].ocsp=e)},this.updateExtAIACAIssuer=function(t,e){var r=this.findExt(t,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var i=r.array,s=0;s<i.length;s++)null!=i[s].caissuer&&(i[s].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.setCanonicalizedDN=function(t){var e;if(null!=t.str&&null==t.array){var r=new nt.asn1.x509.X500Name({str:t.str}).tohex();e=this.getX500NameArray(r)}else e=t.array;null==t.canon&&(t.canon=this.c14nRDNArray(e))},this.c14nRDNArray=function(t){for(var e=[],r=0;r<t.length;r++){for(var i=t[r],s=[],n=0;n<i.length;n++){var a=i[n],o=a.value;o=(o=(o=(o=o.replace(/^\s*/,"")).replace(/\s*$/,"")).replace(/\s+/g," ")).toLowerCase(),s.push(a.type.toLowerCase()+"="+o)}e.push(s.join("+"))}return"/"+e.join("/")},this.getInfo=function(){var t,e,r,i=function(t){for(var e="",r=" ",i="\n",s=t.array,n=0;n<s.length;n++){var a=s[n];null!=a.dn&&(e+=r+"dn: "+a.dn.str+i),null!=a.ip&&(e+=r+"ip: "+a.ip+i),null!=a.rfc822&&(e+=r+"rfc822: "+a.rfc822+i),null!=a.dns&&(e+=r+"dns: "+a.dns+i),null!=a.uri&&(e+=r+"uri: "+a.uri+i),null!=a.other&&(e+=r+"other: "+a.other.oid+"="+JSON.stringify(a.other.value).replace(/\"/g,"")+i)}return e.replace(/\n$/,"")},s=function(t){for(var e="",r=t.array,i=0;i<r.length;i++){var s=r[i];if(e+=" policy oid: "+s.policyoid+"\n",void 0!==s.array)for(var n=0;n<s.array.length;n++){var a=s.array[n];void 0!==a.cps&&(e+=" cps: "+a.cps+"\n")}}return e},n=function(t){for(var e="",r=t.array,i=0;i<r.length;i++){var s=r[i];try{void 0!==s.dpname.full[0].uri&&(e+=" "+s.dpname.full[0].uri+"\n")}catch(t){}try{void 0!==s.dname.full[0].dn.hex&&(e+=" "+Wt.hex2dn(s.dpname.full[0].dn.hex)+"\n")}catch(t){}}return e},a=function(t){for(var e="",r=t.array,i=0;i<r.length;i++){var s=r[i];void 0!==s.caissuer&&(e+=" caissuer: "+s.caissuer+"\n"),void 0!==s.ocsp&&(e+=" ocsp: "+s.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="+_t(e.n.toString(16)).substr(0,16)+"...\n",t+=" e="+_t(e.e.toString(16))+"\n"),null!=(r=this.aExtInfo)){t+="X509v3 Extensions:\n";for(var o=0;o<r.length;o++){var h=r[o],u=nt.asn1.x509.OID.oid2name(h.oid);""===u&&(u=h.oid);var c="";if(!0===h.critical&&(c="CRITICAL"),t+=" "+u+" "+c+":\n","basicConstraints"===u){var l=this.getExtBasicConstraints();void 0===l.cA?t+=" {}\n":(t+=" cA=true",void 0!==l.pathLen&&(t+=", pathLen="+l.pathLen),t+="\n")}else{var g;if("policyMappings"==u)t+=" "+this.getExtPolicyMappings().array.map(function(t){var e=t;return e[0]+":"+e[1]}).join(", ")+"\n";else if("policyConstraints"==u)t+=" ",null!=(g=this.getExtPolicyConstraints()).reqexp&&(t+=" reqexp="+g.reqexp),null!=g.inhibit&&(t+=" inhibit="+g.inhibit),t+="\n";else if("inhibitAnyPolicy"==u)t+=" skip="+(g=this.getExtInhibitAnyPolicy()).skip+"\n";else if("keyUsage"==u)t+=" "+this.getExtKeyUsageString()+"\n";else if("subjectKeyIdentifier"==u)t+=" "+this.getExtSubjectKeyIdentifier().kid.hex+"\n";else if("authorityKeyIdentifier"==u){var p=this.getExtAuthorityKeyIdentifier();void 0!==p.kid&&(t+=" kid="+p.kid.hex+"\n")}else"extKeyUsage"==u?t+=" "+this.getExtExtKeyUsage().array.join(", ")+"\n":"subjectAltName"==u?t+=i(this.getExtSubjectAltName())+"\n":"cRLDistributionPoints"==u?t+=n(this.getExtCRLDistributionPoints()):"authorityInfoAccess"==u?t+=a(this.getExtAuthorityInfoAccess()):"certificatePolicies"==u&&(t+=s(this.getExtCertificatePolicies()))}}}return(t+="signature algorithm: "+this.getSignatureAlgorithmName()+"\n")+"signature: "+this.getSignatureValueHex().substr(0,16)+"...\n"},"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?this.readCertPEM(t):nt.lang.String.isHex(t)&&this.readCertHex(t))}Mt.getKey=function(t,e,r){var i,s=(v=ht).getChildIdx,n=(v.getV,v.getVbyList),a=nt.crypto,o=a.ECDSA,h=a.DSA,u=tt,c=xt,l=Mt;if(void 0!==u&&t instanceof u)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==h&&t instanceof h)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 h).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 h).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(dt(t.n),dt(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(dt(t.n),dt(t.e),dt(t.d),dt(t.p),dt(t.q),dt(t.dp),dt(t.dq),dt(t.qi)),T;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(T=new u).setPrivate(dt(t.n),dt(t.e),dt(t.d)),T;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var g=(R=new o({curve:t.crv})).ecparams.keycharlen,p="04"+("0000000000"+dt(t.x)).slice(-g)+("0000000000"+dt(t.y)).slice(-g);return R.setPublicKeyHex(p),R}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){g=(R=new o({curve:t.crv})).ecparams.keycharlen,p="04"+("0000000000"+dt(t.x)).slice(-g)+("0000000000"+dt(t.y)).slice(-g);var d=("0000000000"+dt(t.d)).slice(-g);return R.setPublicKeyHex(p),R.setPrivateKeyHex(d),R}if("pkcs5prv"===r){var f,y=t,v=ht;if(9===(f=s(y,0)).length)(T=new u).readPKCS5PrvKeyHex(y);else if(6===f.length)(T=new h).readPKCS5PrvKeyHex(y);else{if(!(f.length>2&&"04"===y.substr(f[1],2)))throw new Error("unsupported PKCS#1/5 hexadecimal key");(T=new o).readPKCS5PrvKeyHex(y)}return T}if("pkcs8prv"===r)return l.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===r)return l._getKeyFromPublicPKCS8Hex(t);if("x509pub"===r)return Wt.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return Wt.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var m=xt(t,"PUBLIC KEY");return l._getKeyFromPublicPKCS8Hex(m)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var S=c(t,"RSA PRIVATE KEY");return l.getKey(S,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var x=n(i=c(t,"DSA PRIVATE KEY"),0,[1],"02"),A=n(i,0,[2],"02"),w=n(i,0,[3],"02"),b=n(i,0,[4],"02"),C=n(i,0,[5],"02");return(T=new h).setPrivate(new E(x,16),new E(A,16),new E(w,16),new E(b,16),new E(C,16)),T}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED"))return S=c(t,"EC PRIVATE KEY"),l.getKey(S,null,"pkcs5prv");if(-1!=t.indexOf("-END PRIVATE KEY-"))return l.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var I=l.getDecryptedKeyHex(t,e),F=new tt;return F.readPKCS5PrvKeyHex(I),F}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var R,T=n(i=l.getDecryptedKeyHex(t,e),0,[1],"04"),P=n(i,0,[2,0],"06"),D=n(i,0,[3,0],"03").substr(2);if(void 0===nt.crypto.OID.oidhex2name[P])throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+P);return(R=new o({curve:nt.crypto.OID.oidhex2name[P]})).setPublicKeyHex(D),R.setPrivateKeyHex(T),R.isPublic=!1,R}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED"))return x=n(i=l.getDecryptedKeyHex(t,e),0,[1],"02"),A=n(i,0,[2],"02"),w=n(i,0,[3],"02"),b=n(i,0,[4],"02"),C=n(i,0,[5],"02"),(T=new h).setPrivate(new E(x,16),new E(A,16),new E(w,16),new E(b,16),new E(C,16)),T;if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return l.getKeyFromEncryptedPKCS8PEM(t,e);throw new Error("not supported argument")},Mt.generateKeypair=function(t,e){if("RSA"==t){var r=e;(a=new tt).generate(r,"10001"),a.isPrivate=!0,a.isPublic=!0;var i=new tt,s=a.n.toString(16),n=a.e.toString(16);return i.setPublic(s,n),i.isPrivate=!1,i.isPublic=!0,(o={}).prvKeyObj=a,o.pubKeyObj=i,o}if("EC"==t){var a,o,h=e,u=new nt.crypto.ECDSA({curve:h}).generateKeyPairHex();return(a=new nt.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),a.setPrivateKeyHex(u.ecprvhex),a.isPrivate=!0,a.isPublic=!1,(i=new nt.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),i.isPrivate=!1,i.isPublic=!0,(o={}).prvKeyObj=a,o.pubKeyObj=i,o}throw new Error("unknown algorithm: "+t)},Mt.getPEM=function(t,e,r,i,s,n){var a=nt,o=a.asn1,h=o.DERObjectIdentifier,u=o.DERInteger,c=o.ASN1Util.newObject,l=o.x509.SubjectPublicKeyInfo,g=a.crypto,p=g.DSA,d=g.ECDSA,f=tt;function y(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 v(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 m(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!==f&&t instanceof f||void 0!==p&&t instanceof p||void 0!==d&&t instanceof d)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return Et(A=new l(t).tohex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==f&&t instanceof f&&(void 0===r||null==r)&&1==t.isPrivate)return Et(A=y(t).tohex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==d&&t instanceof d&&(void 0===r||null==r)&&1==t.isPrivate){var S=new h({name:t.curveName}).tohex(),E=v(t).tohex(),x="";return(x+=Et(S,"EC PARAMETERS"))+Et(E,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==p&&t instanceof p&&(void 0===r||null==r)&&1==t.isPrivate)return Et(A=m(t).tohex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==f&&t instanceof f&&void 0!==r&&null!=r&&1==t.isPrivate){var A=y(t).tohex();return void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",A,r,i,n)}if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==r&&null!=r&&1==t.isPrivate)return A=v(t).tohex(),void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",A,r,i,n);if("PKCS5PRV"==e&&void 0!==p&&t instanceof p&&void 0!==r&&null!=r&&1==t.isPrivate)return A=m(t).tohex(),void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",A,r,i,n);var w=function(t,e){if("string"==typeof e)return Mt.getEncryptedPKCS8PEM(t,e);if("object"==typeof e&&null!=Vt(e,"passcode")){var r=JSON.parse(JSON.stringify(e)),i=r.passcode;return delete r.passcode,Mt.getEncryptedPKCS8PEM(t,i,r)}};if("PKCS8PRV"==e&&null!=f&&t instanceof f&&1==t.isPrivate){var b=y(t).tohex();return A=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:b}}]}).tohex(),void 0===r||null==r?Et(A,"PRIVATE KEY"):w(A,r)}if("PKCS8PRV"==e&&void 0!==d&&t instanceof d&&1==t.isPrivate){var C={seq:[{int:1},{octstr:{hex:t.prvKeyHex}}]};return"string"==typeof t.pubKeyHex&&C.seq.push({tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}),b=new c(C).tohex(),A=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:b}}]}).tohex(),void 0===r||null==r?Et(A,"PRIVATE KEY"):w(A,r)}if("PKCS8PRV"==e&&void 0!==p&&t instanceof p&&1==t.isPrivate)return b=new u({bigint:t.x}).tohex(),A=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:b}}]}).tohex(),void 0===r||null==r?Et(A,"PRIVATE KEY"):w(A,r);throw new Error("unsupported object nor format")},Mt.getKeyFromCSRPEM=function(t){var e=xt(t,"CERTIFICATE REQUEST");return Mt.getKeyFromCSRHex(e)},Mt.getKeyFromCSRHex=function(t){var e=Mt.parseCSRHex(t);return Mt.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Mt.parseCSRHex=function(t){var e=ht,r=e.getChildIdx,i=e.getTLV,s={},n=t;if("30"!=n.substr(0,2))throw new Error("malformed CSR(code:001)");var a=r(n,0);if(a.length<1)throw new Error("malformed CSR(code:002)");if("30"!=n.substr(a[0],2))throw new Error("malformed CSR(code:003)");var o=r(n,a[0]);if(o.length<3)throw new Error("malformed CSR(code:004)");return s.p8pubkeyhex=i(n,o[2]),s},Mt.getKeyID=function(t){var e=Mt,r=ht;"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&(t=e.getKey(t));var i=xt(e.getPEM(t)),s=r.getIdxbyList(i,0,[1]),n=r.getV(i,s).substring(2);return nt.crypto.Util.hashHex(n,"sha1")},Mt.getJWK=function(t,e,r,i,s){var n,a,o={},h=nt.crypto.Util.hashHex;if("string"==typeof t)n=Mt.getKey(t),-1!=t.indexOf("CERTIFICATE")&&(a=xt(t));else{if("object"!=typeof t)throw new Error("unsupported keyinfo type");t instanceof Wt?(n=t.getPublicKey(),a=t.hex):n=t}if(n instanceof tt&&n.isPrivate)o.kty="RSA",o.n=pt(n.n.toString(16)),o.e=pt(n.e.toString(16)),o.d=pt(n.d.toString(16)),o.p=pt(n.p.toString(16)),o.q=pt(n.q.toString(16)),o.dp=pt(n.dmp1.toString(16)),o.dq=pt(n.dmq1.toString(16)),o.qi=pt(n.coeff.toString(16));else if(n instanceof tt&&n.isPublic)o.kty="RSA",o.n=pt(n.n.toString(16)),o.e=pt(n.e.toString(16));else if(n instanceof nt.crypto.ECDSA&&n.isPrivate){if("P-256"!==(c=n.getShortNISTPCurveName())&&"P-384"!==c&&"P-521"!==c)throw new Error("unsupported curve name for JWT: "+c);var u=n.getPublicKeyXYHex();o.kty="EC",o.crv=c,o.x=pt(u.x),o.y=pt(u.y),o.d=pt(n.prvKeyHex)}else if(n instanceof nt.crypto.ECDSA&&n.isPublic){var c;if("P-256"!==(c=n.getShortNISTPCurveName())&&"P-384"!==c&&"P-521"!==c)throw new Error("unsupported curve name for JWT: "+c);u=n.getPublicKeyXYHex(),o.kty="EC",o.crv=c,o.x=pt(u.x),o.y=pt(u.y)}if(null==o.kty)throw new Error("unsupported keyinfo");return n.isPrivate||1==e||(o.kid=nt.jws.JWS.getJWKthumbprint(o)),null!=a&&1!=r&&(o.x5c=[m(a)]),null!=a&&1!=i&&(o.x5t=lt(m(h(a,"sha1")))),null!=a&&1!=s&&(o["x5t#S256"]=lt(m(h(a,"sha256")))),o},Mt.getJWKFromKey=function(t){return Mt.getJWK(t,!0,!0,!0,!0)},tt.getPosArrayOfChildrenFromHex=function(t){return ht.getChildIdx(t,0)},tt.getHexValueArrayOfChildrenFromHex=function(t){var e,r=ht.getV,i=r(t,(e=tt.getPosArrayOfChildrenFromHex(t))[0]),s=r(t,e[1]),n=r(t,e[2]),a=r(t,e[3]),o=r(t,e[4]),h=r(t,e[5]),u=r(t,e[6]),c=r(t,e[7]),l=r(t,e[8]);return(e=new Array).push(i,s,n,a,o,h,u,c,l),e},tt.prototype.readPrivateKeyFromPEMString=function(t){var e=xt(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,i,s,n,a,o,h,u=ht,c=u.getVbyListEx;if(!1===u.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"),i=c(t,0,[2,0,3],"02"),s=c(t,0,[2,0,4],"02"),n=c(t,0,[2,0,5],"02"),a=c(t,0,[2,0,6],"02"),o=c(t,0,[2,0,7],"02"),h=c(t,0,[2,0,8],"02")}catch(t){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(e,r,i,s,n,a,o,h)},tt.prototype.readPKCS5PubKeyHex=function(t){var e=ht,r=e.getV;if(!1===e.isASN1HEX(t))throw new Error("keyHex is not ASN.1 hex string");var i=e.getChildIdx(t,0);if(2!==i.length||"02"!==t.substr(i[0],2)||"02"!==t.substr(i[1],2))throw new Error("wrong hex for PKCS#5 public key");var s=r(t,i[0]),n=r(t,i[1]);this.setPublic(s,n)},tt.prototype.readPKCS8PubKeyHex=function(t){var e=ht;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,i;(r=new Wt).readCertHex(t),i=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(i)},tt.prototype.sign=function(t,e){var r=function(t){return nt.crypto.Util.hashString(t,e)}(t);return this.signWithMessageHash(r,e)},tt.prototype.signWithMessageHash=function(t,e){var r=Z(nt.crypto.Util.getPaddedDigestInfoHex(t,e,this.n.bitLength()),16);return Kt(this.doPrivate(r).toString(16),this.n.bitLength())},tt.prototype.signPSS=function(t,e,r){var i,s=(i=St(t),nt.crypto.Util.hashHex(i,e));return void 0===r&&(r=-1),this.signWithMessageHashPSS(s,e,r)},tt.prototype.signWithMessageHashPSS=function(t,e,r){var i,s=mt(t),n=s.length,a=this.n.bitLength()-1,o=Math.ceil(a/8),h=function(t){return nt.crypto.Util.hashHex(t,e)};if(-1===r||void 0===r)r=n;else if(-2===r)r=o-n-2;else if(r<-2)throw new Error("invalid salt length");if(o<n+r+2)throw new Error("data too long");var u="";r>0&&(u=new Array(r),(new Q).nextBytes(u),u=String.fromCharCode.apply(String,u));var c=mt(h(St("\0\0\0\0\0\0\0\0"+s+u))),l=[];for(i=0;i<o-r-n-2;i+=1)l[i]=0;var g=String.fromCharCode.apply(String,l)+""+u,p=qt(c,g.length,h),d=[];for(i=0;i<g.length;i+=1)d[i]=g.charCodeAt(i)^p.charCodeAt(i);var f=65280>>8*o-a&255;for(d[0]&=~f,i=0;i<n;i++)d.push(c.charCodeAt(i));return d.push(188),Kt(this.doPrivate(new E(d)).toString(16),this.n.bitLength())},tt.prototype.verify=function(t,e){if(null==(e=e.toLowerCase()).match(/^[0-9a-f]+$/))return!1;var r=Z(e,16),i=this.n.bitLength();if(r.bitLength()>i)return!1;var s=this.doPublic(r).toString(16);if(s.length+3!=i/4)return!1;var n=Gt(s.replace(/^1f+00/,""));if(0==n.length)return!1;var a=n[0],o=n[1],h=function(t){return nt.crypto.Util.hashString(t,a)}(t);return o==h},tt.prototype.verifyWithMessageHash=function(t,e){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=Z(e,16);if(r.bitLength()>this.n.bitLength())return 0;var i=Gt(this.doPublic(r).toString(16).replace(/^1f+00/,""));return 0!=i.length&&(i[0],i[1]==t)},tt.prototype.verifyPSS=function(t,e,r,i){var s,n=(s=St(t),nt.crypto.Util.hashHex(s,r));return void 0===i&&(i=-1),this.verifyWithMessageHashPSS(n,e,r,i)},tt.prototype.verifyWithMessageHashPSS=function(t,e,r,i){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var s,n=new E(e,16),a=function(t){return nt.crypto.Util.hashHex(t,r)},o=mt(t),h=o.length,u=this.n.bitLength()-1,c=Math.ceil(u/8);if(-1===i||void 0===i)i=h;else if(-2===i)i=c-h-2;else if(i<-2)throw new Error("invalid salt length");if(c<h+i+2)throw new Error("data too long");var l=this.doPublic(n).toByteArray();for(s=0;s<l.length;s+=1)l[s]&=255;for(;l.length<c;)l.unshift(0);if(188!==l[c-1])throw new Error("encoded message does not end in 0xbc");var g=(l=String.fromCharCode.apply(String,l)).substr(0,c-h-1),p=l.substr(g.length,h),d=65280>>8*c-u&255;if(0!==(g.charCodeAt(0)&d))throw new Error("bits beyond keysize not zero");var f=qt(p,g.length,a),y=[];for(s=0;s<g.length;s+=1)y[s]=g.charCodeAt(s)^f.charCodeAt(s);y[0]&=~d;var v=c-h-i-2;for(s=0;s<v;s+=1)if(0!==y[s])throw new Error("leftmost octets not zero");if(1!==y[v])throw new Error("0x01 marker not found");return p===mt(a(St("\0\0\0\0\0\0\0\0"+o+String.fromCharCode.apply(String,y.slice(-i)))))},tt.SALT_LEN_HLEN=-1,tt.SALT_LEN_MAX=-2,tt.SALT_LEN_RECOVER=-2,Wt.EXT_PARSER={},Wt.registExtParser=function(t,e){Wt.EXT_PARSER[t]=e},Wt.hex2dn=function(t,e){void 0===e&&(e=0);var r=new Wt;return ht.getTLV(t,e),r.getX500Name(t).str},Wt.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,i=ht.getChildIdx(t,e),s=0;s<i.length;s++)r.push(Wt.hex2attrTypeValue(t,i[s]));return r=r.map(function(t){return t.replace("+","\\+")}),r.join("+")},Wt.hex2attrTypeValue=function(t,e){var r=ht,i=r.getV;if(void 0===e&&(e=0),"30"!==t.substr(e,2))throw new Error("malformed attribute type and value");var s=r.getChildIdx(t,e);2!==s.length||t.substr(s[0],2);var n=i(t,s[0]),a=nt.asn1.ASN1Util.oidHexToInt(n);return nt.asn1.x509.OID.oid2atype(a)+"="+mt(i(t,s[1]))},Wt.getPublicKeyFromCertHex=function(t){var e=new Wt;return e.readCertHex(t),e.getPublicKey()},Wt.getPublicKeyFromCertPEM=function(t){var e=new Wt;return e.readCertPEM(t),e.getPublicKey()},Wt.getPublicKeyInfoPropOfCertPEM=function(t){var e,r,i=ht.getVbyList,s={algparam:null};return(e=new Wt).readCertPEM(t),r=e.getPublicKeyHex(),s.keyhex=i(r,0,[1],"03").substr(2),s.algoid=i(r,0,[0,0],"06"),"2a8648ce3d0201"===s.algoid&&(s.algparam=i(r,0,[0,1],"06")),s},Wt.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"],void 0!==nt&&nt||(nt={}),void 0!==nt.jws&&nt.jws||(nt.jws={}),nt.jws.JWS=function(){var t=nt.jws.JWS.isSafeJSONString;this.parseJWS=function(e,r){if(void 0===this.parsedJWS||!r&&void 0===this.parsedJWS.sigvalH){var i=e.match(/^([^.]+)\.([^.]+)\.([^.]+)$/);if(null==i)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";var s=i[1],n=i[2],a=i[3],o=s+"."+n;if(this.parsedJWS={},this.parsedJWS.headB64U=s,this.parsedJWS.payloadB64U=n,this.parsedJWS.sigvalB64U=a,this.parsedJWS.si=o,!r){var h=dt(a),u=Z(h,16);this.parsedJWS.sigvalH=h,this.parsedJWS.sigvalBI=u}var c=ot(s),l=ot(n);if(this.parsedJWS.headS=c,this.parsedJWS.payloadS=l,!t(c,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+c}}},nt.jws.JWS.sign=function(t,e,r,i,s){var n,a,o,h=nt,u=h.jws.JWS,c=u.readSafeJSONString,l=u.isSafeJSONString,g=h.crypto,p=(g.ECDSA,g.Mac),d=g.Signature,f=JSON;if("string"!=typeof e&&"object"!=typeof e)throw"spHeader must be JSON string or object: "+e;if("object"==typeof e&&(a=e,n=f.stringify(a)),"string"==typeof e){if(!l(n=e))throw"JWS Head is not safe JSON string: "+n;a=c(n)}if(o=r,"object"==typeof r&&(o=f.stringify(r)),""!=t&&null!=t||void 0===a.alg||(t=a.alg),""!=t&&null!=t&&void 0===a.alg&&(a.alg=t,n=f.stringify(a)),t!==a.alg)throw"alg and sHeader.alg doesn't match: "+t+"!="+a.alg;var y=null;if(void 0===u.jwsalg2sigalg[t])throw"unsupported alg name: "+t;y=u.jwsalg2sigalg[t];var v=at(n)+"."+at(o),m="";if("Hmac"==y.substr(0,4)){if(void 0===i)throw"mac key shall be specified for HS* alg";var S=new p({alg:y,prov:"cryptojs",pass:i});S.updateString(v),m=S.doFinal()}else if(-1!=y.indexOf("withECDSA")){(x=new d({alg:y})).init(i,s),x.updateString(v);var E=x.sign();m=nt.crypto.ECDSA.asn1SigToConcatSig(E)}else{var x;"none"!=y&&((x=new d({alg:y})).init(i,s),x.updateString(v),m=x.sign())}return v+"."+pt(m)},nt.jws.JWS.verify=function(t,e,r){var i,s=nt,n=s.jws.JWS,a=n.readSafeJSONString,o=s.crypto,h=o.ECDSA,u=o.Mac,c=o.Signature;if(i=tt,!Ot(t))return!1;var l=t.split(".");if(3!==l.length)return!1;var g,p=l[0]+"."+l[1],d=dt(l[2]),f=a(ot(l[0])),y=null;if(void 0===f.alg)throw"algorithm not specified in header";if(g=(y=f.alg).substr(0,2),null!=r&&"[object Array]"===Object.prototype.toString.call(r)&&r.length>0&&-1==(":"+r.join(":")+":").indexOf(":"+y+":"))throw"algorithm '"+y+"' not accepted in the list";if("none"!=y&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=Mt.getKey(e)),!("RS"!=g&&"PS"!=g||e instanceof i))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==g&&!(e instanceof h))throw"key shall be a ECDSA obj for ES* algs";var v=null;if(void 0===n.jwsalg2sigalg[f.alg])throw"unsupported alg name: "+y;if("none"==(v=n.jwsalg2sigalg[y]))throw"not supported";if("Hmac"==v.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var m=new u({alg:v,pass:e});return m.updateString(p),d==m.doFinal()}if(-1!=v.indexOf("withECDSA")){var S,E=null;try{E=h.concatSigToASN1Sig(d)}catch(t){return!1}return(S=new c({alg:v})).init(e),S.updateString(p),S.verify(E)}return(S=new c({alg:v})).init(e),S.updateString(p),S.verify(d)},nt.jws.JWS.parse=function(t){var e,r,i,s=t.split("."),n={};if(2!=s.length&&3!=s.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=s[0],r=s[1],3==s.length&&(i=s[2]),n.headerObj=nt.jws.JWS.readSafeJSONString(ot(e)),n.payloadObj=nt.jws.JWS.readSafeJSONString(ot(r)),n.headerPP=JSON.stringify(n.headerObj,null," "),null==n.payloadObj?n.payloadPP=ot(r):n.payloadPP=JSON.stringify(n.payloadObj,null," "),void 0!==i&&(n.sigHex=dt(i)),n},nt.jws.JWS.verifyJWT=function(t,e,r){var i=nt.jws,s=i.JWS,n=s.readSafeJSONString,a=s.inArray,o=s.includedArray;if(!Ot(t))return!1;var h=t.split(".");if(3!=h.length)return!1;var u=h[0],c=h[1],l=(dt(h[2]),n(ot(u))),g=n(ot(c));if(void 0===l.alg)return!1;if(void 0===r.alg)throw"acceptField.alg shall be specified";if(!a(l.alg,r.alg))return!1;if(void 0!==g.iss&&"object"==typeof r.iss&&!a(g.iss,r.iss))return!1;if(void 0!==g.sub&&"object"==typeof r.sub&&!a(g.sub,r.sub))return!1;if(void 0!==g.aud&&"object"==typeof r.aud)if("string"==typeof g.aud){if(!a(g.aud,r.aud))return!1}else if("object"==typeof g.aud&&!o(g.aud,r.aud))return!1;var p=i.IntDate.getNow();return void 0!==r.verifyAt&&"number"==typeof r.verifyAt&&(p=r.verifyAt),void 0!==r.gracePeriod&&"number"==typeof r.gracePeriod||(r.gracePeriod=0),!(void 0!==g.exp&&"number"==typeof g.exp&&g.exp+r.gracePeriod<p||void 0!==g.nbf&&"number"==typeof g.nbf&&p<g.nbf-r.gracePeriod||void 0!==g.iat&&"number"==typeof g.iat&&p<g.iat-r.gracePeriod||void 0!==g.jti&&void 0!==r.jti&&g.jti!==r.jti||!s.verify(t,e,r.alg))},nt.jws.JWS.includedArray=function(t,e){var r=nt.jws.JWS.inArray;if(null===t)return!1;if("object"!=typeof t)return!1;if("number"!=typeof t.length)return!1;for(var i=0;i<t.length;i++)if(!r(t[i],e))return!1;return!0},nt.jws.JWS.inArray=function(t,e){if(null===e)return!1;if("object"!=typeof e)return!1;if("number"!=typeof e.length)return!1;for(var r=0;r<e.length;r++)if(e[r]==t)return!0;return!1},nt.jws.JWS.jwsalg2sigalg={HS256:"HmacSHA256",HS384:"HmacSHA384",HS512:"HmacSHA512",RS256:"SHA256withRSA",RS384:"SHA384withRSA",RS512:"SHA512withRSA",ES256:"SHA256withECDSA",ES384:"SHA384withECDSA",ES512:"SHA512withECDSA",PS256:"SHA256withRSAandMGF1",PS384:"SHA384withRSAandMGF1",PS512:"SHA512withRSAandMGF1",none:"none"},nt.jws.JWS.isSafeJSONString=function(t,e,r){var i=null;try{return"object"!=typeof(i=st(t))||i.constructor===Array?0:(e&&(e[r]=i),1)}catch(t){return 0}},nt.jws.JWS.readSafeJSONString=function(t){var e=null;try{return"object"!=typeof(e=st(t))||e.constructor===Array?null:e}catch(t){return null}},nt.jws.JWS.getEncodedSignatureValueFromJWS=function(t){var e=t.match(/^[^.]+\.[^.]+\.([^.]+)$/);if(null==e)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";return e[1]},nt.jws.JWS.getJWKthumbprint=function(t){if("RSA"!==t.kty&&"EC"!==t.kty&&"oct"!==t.kty)throw"unsupported algorithm for JWK Thumprint";var e="{";if("RSA"===t.kty){if("string"!=typeof t.n||"string"!=typeof t.e)throw"wrong n and e value for RSA key";e+='"e":"'+t.e+'",',e+='"kty":"'+t.kty+'",',e+='"n":"'+t.n+'"}'}else if("EC"===t.kty){if("string"!=typeof t.crv||"string"!=typeof t.x||"string"!=typeof t.y)throw"wrong crv, x and y value for EC key";e+='"crv":"'+t.crv+'",',e+='"kty":"'+t.kty+'",',e+='"x":"'+t.x+'",',e+='"y":"'+t.y+'"}'}else if("oct"===t.kty){if("string"!=typeof t.k)throw"wrong k value for oct(symmetric) key";e+='"kty":"'+t.kty+'",',e+='"k":"'+t.k+'"}'}var r=St(e);return pt(nt.crypto.Util.hashHex(r,"sha256"))},nt.jws.IntDate={},nt.jws.IntDate.get=function(t){var e=nt.jws.IntDate,r=e.getNow,i=e.getZulu;if("now"==t)return r();if("now + 1hour"==t)return r()+3600;if("now + 1day"==t)return r()+86400;if("now + 1month"==t)return r()+2592e3;if("now + 1year"==t)return r()+31536e3;if(t.match(/Z$/))return i(t);if(t.match(/^[0-9]+$/))return parseInt(t);throw"unsupported format: "+t},nt.jws.IntDate.getZulu=function(t){return function(t){return Math.round(function(t){var e,r,i,s,n,a,o,h,u,c;if(c=(t=function(t){return t.match(/^[0-9]{12}Z$/)||t.match(/^[0-9]{12}[.][0-9]*Z$/)?t.match(/^[0-4]/)?"20"+t:"19"+t:t}(t)).match(/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(|\.\d+)Z$/))return e=parseInt(c[1]),r=parseInt(c[2])-1,i=parseInt(c[3]),s=parseInt(c[4]),n=parseInt(c[5]),a=parseInt(c[6]),o=0,""!==(h=c[7])&&(u=(h.substr(1)+"00").substr(0,3),o=parseInt(u)),Date.UTC(e,r,i,s,n,a,o);throw new Error("unsupported zulu format: "+t)}(t)/1e3)}(t)},nt.jws.IntDate.getNow=function(){return~~(new Date/1e3)},nt.jws.IntDate.intDate2UTCString=function(t){return new Date(1e3*t).toUTCString()},nt.jws.IntDate.intDate2Zulu=function(t){var e=new Date(1e3*t);return("0000"+e.getUTCFullYear()).slice(-4)+("00"+(e.getUTCMonth()+1)).slice(-2)+("00"+e.getUTCDate()).slice(-2)+("00"+e.getUTCHours()).slice(-2)+("00"+e.getUTCMinutes()).slice(-2)+("00"+e.getUTCSeconds()).slice(-2)+"Z"},void 0!==nt&&nt||(nt={}),void 0!==nt.jws&&nt.jws||(nt.jws={}),nt.jws.JWSJS=function(){var t=nt.jws.JWS,e=t.readSafeJSONString;this.aHeader=[],this.sPayload="",this.aSignature=[],this.init=function(){this.aHeader=[],this.sPayload=void 0,this.aSignature=[]},this.initWithJWS=function(t){this.init();var e=t.split(".");if(3!=e.length)throw"malformed input JWS";this.aHeader.push(e[0]),this.sPayload=e[1],this.aSignature.push(e[2])},this.addSignature=function(t,e,r,i){if(void 0===this.sPayload||null===this.sPayload)throw"there's no JSON-JS signature to add.";var s=this.aHeader.length;if(this.aHeader.length!=this.aSignature.length)throw"aHeader.length != aSignature.length";try{var n=nt.jws.JWS.sign(t,e,this.sPayload,r,i).split(".");n[0],n[2],this.aHeader.push(n[0]),this.aSignature.push(n[2])}catch(t){throw this.aHeader.length>s&&this.aHeader.pop(),this.aSignature.length>s&&this.aSignature.pop(),"addSignature failed: "+t}},this.verifyAll=function(t){if(this.aHeader.length!==t.length||this.aSignature.length!==t.length)return!1;for(var e=0;e<t.length;e++){var r=t[e];if(2!==r.length)return!1;if(!1===this.verifyNth(e,r[0],r[1]))return!1}return!0},this.verifyNth=function(e,r,i){if(this.aHeader.length<=e||this.aSignature.length<=e)return!1;var s=this.aHeader[e],n=this.aSignature[e],a=s+"."+this.sPayload+"."+n,o=!1;try{o=t.verify(a,r,i)}catch(t){return!1}return o},this.readJWSJS=function(t){if("string"==typeof t){var r=e(t);if(null==r)throw"argument is not safe JSON object string";this.aHeader=r.headers,this.sPayload=r.payload,this.aSignature=r.signatures}else try{if(!(t.headers.length>0))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(t.signatures.length>0))throw"malformed signatures";this.aSignature=t.signatures}catch(t){throw"malformed JWS-JS JSON object: "+t}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}},nt.crypto.ECDSA,nt.crypto.DSA,nt.crypto.Signature,nt.crypto.MessageDigest,nt.crypto.Mac,e.ym=Mt,e.wV=pt,e.cV=ot,e.pj=nt,nt.crypto,nt.asn1,nt.jws,nt.lang}},e={};function r(i){var s=e[i];if(void 0!==s)return s.exports;var n=e[i]={exports:{}};return t[i](n,n.exports,r),n.exports}r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let i=function(t){return t.light="light",t.dark="dark",t}({});class s{theme="default";themeMode=i.light;constructor(t){t&&(this.theme=t.theme??this.theme,this.themeMode=t.themeMode??this.themeMode)}toString(){return JSON.stringify(this)}}class n{static deepEqual(t,e){if(t===e)return!0;if(null==t||null==e)return!1;if("object"==typeof t&&"object"==typeof e){if(t.constructor!==e.constructor)return!1;if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!n.deepEqual(t[r],e[r]))return!1;return!0}if(!Array.isArray(t)&&!Array.isArray(e)){const r=Object.keys(t),i=Object.keys(e);if(r.length!==i.length)return!1;for(const i of r)if(!(i in e)||!n.deepEqual(t[i],e[i]))return!1;return!0}return!1}return!1}static deepCopy(t){if("object"!=typeof t||null==t||"function"==typeof t)return t;if(n.hasCopyMethod(t))return t.copy();const e=n.copyBuiltInType(t);return null!==e?e:n.copyPlainObject(t)}static copyBuiltInType(t){return Array.isArray(t)?t.map(t=>n.deepCopy(t)):t instanceof Date?new Date(t.getTime()):t instanceof RegExp?new RegExp(t.source,t.flags):t instanceof Map?new Map(Array.from(t.entries()).map(([t,e])=>[n.deepCopy(t),n.deepCopy(e)])):t instanceof Set?new Set(Array.from(t.values()).map(t=>n.deepCopy(t))):null}static copyPlainObject(t){const e=Object.create(Object.getPrototypeOf(t));for(const r of Object.keys(t))e[r]=n.deepCopy(t[r]);return e}static hasCopyMethod(t){return"object"==typeof t&&null!==t&&Object.prototype.hasOwnProperty.call(t,"copy")&&"function"==typeof t.copy}static isNullOrUndefined=t=>null==t}const a={BYTES:1,KB:1024,MB:1048576,GB:1024**3,TB:1024**4,PB:1024**5},o=/^(\d+(?:\.\d+)?)\s*(bytes|KB|MB|GB|TB|PB)$/i,h=/^\d+$/;class u{static convertToBytes(t){if(null==t)return 0;if("number"==typeof t)return t;if(t=t.trim(),h.test(t))return Number.parseInt(t,10);const e=o.exec(t);if(!e)return 0;const r=Number.parseFloat(e[1]),i=e[2];return r*a[i.toUpperCase()]}static convertToHumanReadable(t){if(!t)return"0 bytes";if("string"==typeof t&&(t=t.trim()),o.test(String(t)))return String(t);if("string"==typeof t&&(t=Number.parseFloat(t)),Number.isNaN(t)||t<=0)return"0 bytes";const e=Object.keys(a).reverse();for(const r of e){const e=a[r];if(t>=e){const i=t/e;return`${Number.isInteger(i)?i:i.toFixed(2)} ${"BYTES"===r?"bytes":r}`}}return"0 bytes"}}class c{static getWindow(){return window}static getDocument(){return c.getWindow().document}static getPluginRegistry(){return c.getWindow().PluginRegistry}static getCrypto(){return c.getWindow().crypto}static getLocationHref(){return c.getWindow().location.href}static setLocationHref(t){c.getWindow().location.href=t}static getLocationQueryParams(){return c.getWindow().location.search}static getLocationHash(){return c.getWindow().location.hash}static getLocationPathWithQueryParams(){return S()+c.getLocationQueryParams()}static matchMedia(t){return c.getWindow().matchMedia(t)}}class l{static isDevMode(){return c.getWindow().wbDevMode}}class g{static ABS_URI_REGEX=/^<?(http|urn).*>?/;static GRAPHS_VISUALIZATIONS_URL="graphs-visualizations";static RESOURCE_URL="resource";static BASE_DOCUMENTATION_URL="https://graphdb.ontotext.com/documentation/";static LATEST_UNOFFICIAL_VERSION="master";static shortenIri(t){const e=document.createElement("a");e.href=t;let r=e.hostname;return g.containsIPV4(e.hostname)||(r=e.hostname.split(".")[0]),r+":"+e.port}static containsIPV4(t){const e=t.split(".");for(let t=0,r=0;t<e.length;t++)if(parseInt(e[t],10)>=0&&parseInt(e[t],10)<=255?r++:r=0,4===r)return!0;return!1}static createAutocompleteRedirect(t,e){return`${t}?uri=${encodeURIComponent(e)}`}static removeAngleBrackets(t){return t?.startsWith("<")&&t?.endsWith(">")?t.substring(1,t.length-1):t}static isValidUri(t){let e=!1;if(this.hasValidProtocol(t))if(t.indexOf("http")>=0){const r=t.indexOf("//");e=r>4&&t.substring(r+2).length>0}else t.indexOf("urn")>=0&&(e=t.substring(4).length>0);return e}static resolveDocumentationUrl(t,e){if(!t||!e)throw new Error("Product version and endpoint path are required for documentation URL resolution.");const r=t.includes("-"),i=l.isDevMode()||r?this.LATEST_UNOFFICIAL_VERSION:t;return`${this.BASE_DOCUMENTATION_URL}${i}/${e}`}static hasAngleBrackets(t){return t.startsWith("<")&&t.endsWith(">")}static hasNoAngleBrackets(t){return!t.startsWith("<")&&!t.endsWith(">")}static hasValidProtocol(t){return this.ABS_URI_REGEX.test(t)&&(this.hasNoAngleBrackets(t)||this.hasAngleBrackets(t))}}class p{fibo1=0;fibo2=1;next(){const t=this.fibo2;return this.fibo2=this.fibo1+this.fibo2,this.fibo1=t,t}reset=()=>{this.fibo1=0,this.fibo2=1}}function d(t){return e=>{e&&e.preventDefault(),f(t)}}function f(t){t.startsWith(".")&&(t=t.slice(1)),t.startsWith("/")&&!t.startsWith(x())&&(t=x().slice(0,-1)+t),c.getWindow().singleSpa.navigateToUrl(t)}function y(t){c.getWindow().open(t,"_blank")}function v(){return"/"===S()}function m(){return"/login"===S()}function S(){return c.getWindow().location.pathname.substring(x().length-1)}function E(){return`${c.getWindow().location.origin}${x()}`}function x(){return document.querySelector("base")?.getAttribute("href")??"/"}function A(){return S().substring(1)}function w(t,e){if(Object.values(t).includes(e))return e;throw new Error(`Invalid enum value '${e}' for enum ${JSON.stringify(t)}`)}class b{static now(){return Date.now()}}class C{copy(){return n.deepCopy(this)}}class F extends C{constructor(t=[]){super(),this.items=t}size(){return this.items.length}getItems(){return this.items}getFirstItem(){return this.items[0]}sort(t){this.items.sort(t)}filter(t){return this.items.filter(t)}find(t){return this.items.find(t)}isEmpty(){return 0===this.items.length}addToStart(t){this.items.unshift(t)}addItems(t){this.items.push(...t)}remove(t){const e=this.items.indexOf(t);-1!==e&&this.items.splice(e,1)}}class I extends F{constructor(t){super(t)}add(t){this.items.push(t)}addAll(t){this.items.push(...t)}unsubscribeAll(){this.items.forEach(t=>t()),this.items=[]}}class R extends C{constructor(t){super(),this.id=t.id||"",this.title=t.title||"",this.type=t.type,this.sesameType=t.sesameType,this.uri=t.uri||"",this.externalUrl=t.externalUrl||"",this.location=t.location||"",this.state=t.state,this.local=t.local,this.readable=t.readable,this.writable=t.writable,this.unsupported=t.unsupported,this.isNew=t.isNew}toRepositoryReference(){return{id:this.id,location:this.location}}isOntop(){return"graphdb:OntopRepository"===this.sesameType}isFedx(){return"graphdb:FedXRepository"===this.sesameType}}const T=(t,e)=>{const r=t.location.localeCompare(e.location);return 0!==r?r:t.id.localeCompare(e.id)};class P extends F{constructor(t){super(t)}findRepository(t,e,r=!1){return super.find(i=>i.id===t&&(r||i.location===e))}sortByLocationAndId(){super.sort(T)}filterByRepository(t){return super.filter(this.createIdLocationFilter(t))}createIdLocationFilter(t){return e=>t.some(t=>t.id!==e.id||t.location!==e.location)}}class D extends C{constructor(t){super(),this.inferred=t?.inferred||0,this.total=t?.total||0,this.explicit=t?.explicit||0}}let N=function(t){return t.INACTIVE="INACTIVE",t.STARTING="STARTING",t.RUNNING="RUNNING",t.RESTARTING="RESTARTING",t.STOPPING="STOPPING",t}({}),O=function(t){return t.GRAPH_DB="graphdb",t.ONTOP="ontop",t.FEDX="fedx",t.SYSTEM="system",t}({});const _="repositoryId";class B extends C{constructor(t){super(),this.uri=t?.uri||"",this.label=t?.label||"",this.username=t?.username||"",this.password=t?.password||"",this.authType=t?.authType,this.locationType=t?.locationType,this.active=t?.active,this.local=t?.local,this.system=t?.system,this.errorMsg=t?.errorMsg||"",this.defaultRepository=t?.defaultRepository||""}}let H=function(t){return t.GDB="GDB",t.ONTOPIC="ONTOPIC",t.SPARQL="SPARQL",t}({});class L{constructor(t){this.namespaces=t}getByPrefix(t){return this.namespaces[t]||""}}class k{constructor(t,e){this.NAME=t,this.payload=e}}const U={NAVIGATION_END:"navigationEnd",NAVIGATION_START:"navigationStart",LOGIN:"login",LOGOUT:"logout",APP_DATA_LOADED:"applicationDataLoaded",APPLICATION_MOUNTED:"applicationMounted",APPLICATION_UNMOUNTED:"applicationUnmounted",APPLICATION_CHANGED:"applicationChanged",APPLICATION_BEFORE_CHANGE:"applicationBeforeChange"};class V extends k{constructor(t,e){super(U.NAVIGATION_END,{oldUrl:t,newUrl:e})}}class j{}class K extends k{constructor(t,e,r){super(U.NAVIGATION_START,{oldUrl:t,newUrl:e,cancelNavigation:r})}}class M extends k{constructor(){super(U.APPLICATION_MOUNTED)}}class q extends k{constructor(){super(U.APPLICATION_UNMOUNTED)}}class G extends k{constructor(){super(U.APPLICATION_BEFORE_CHANGE)}}class W extends k{constructor(){super(U.APPLICATION_CHANGED)}}class $ extends k{constructor(){super(U.LOGOUT)}}class z extends k{constructor(){super(U.LOGIN)}}let Y=function(t){return t.NONE="NONE",t.BASIC="BASIC",t.SIGNATURE="SIGNATURE",t}({}),X=function(t){return t.ROLE_ADMIN="ROLE_ADMIN",t.ROLE_USER="ROLE_USER",t.ROLE_MONITORING="ROLE_MONITORING",t.ROLE_REPO_MANAGER="ROLE_REPO_MANAGER",t.ROLE_CLUSTER="ROLE_CLUSTER",t.IS_AUTHENTICATED_FULLY="IS_AUTHENTICATED_FULLY",t.SYSTEM_REPO="SYSTEM",t.READ_REPO="READ_REPO",t.READ_REPO_PREFIX="READ_REPO_",t.WRITE_REPO="WRITE_REPO",t.GRAPHQL="GRAPHQL",t.WRITE_REPO_PREFIX="WRITE_REPO_",t.GRAPHQL_PREFIX="GRAPHQL_",t.SUFFIX_DELIMITER=":",t.CUSTOM_PREFIX="CUSTOM_",t}({});class J{static getRepoFromAuthority(t){return t.startsWith(X.READ_REPO_PREFIX)?{prefix:X.READ_REPO_PREFIX,repo:t.substring(X.READ_REPO_PREFIX.length)}:t.startsWith(X.WRITE_REPO_PREFIX)?{prefix:X.WRITE_REPO_PREFIX,repo:t.substring(X.WRITE_REPO_PREFIX.length)}:t.startsWith(X.GRAPHQL_PREFIX)?{prefix:X.GRAPHQL_PREFIX,repo:t.substring(X.GRAPHQL_PREFIX.length)}:null}}const Q=t=>{const e=X.SUFFIX_DELIMITER+X.GRAPHQL,r=t.getItems();if(!r.length)return r;const i=[],s={};let n=!1,a=!1,o=!1;r.forEach(t=>{const e=J.getRepoFromAuthority(t);if(e){const{prefix:t,repo:i}=e,h=(s[r=i]||(s[r]={read:!1,write:!1,graphql:!1}),s[r]);t===X.READ_REPO_PREFIX?(h.read=!0,"*"===i&&(n=!0)):t===X.WRITE_REPO_PREFIX?(h.write=!0,"*"===i&&(a=!0)):t===X.GRAPHQL_PREFIX&&(h.graphql=!0,"*"===i&&(o=!0))}else i.push(t);var r});const h=[];return Object.keys(s).forEach(t=>{const r=s[t];r.graphql||o?r.write||a?h.push(`${X.WRITE_REPO_PREFIX}${t}${e}`,`${X.READ_REPO_PREFIX}${t}${e}`):(r.read||n)&&h.push(`${X.READ_REPO_PREFIX}${t}${e}`):r.write?h.push(`${X.WRITE_REPO_PREFIX}${t}`,`${X.READ_REPO_PREFIX}${t}`):r.read&&h.push(`${X.READ_REPO_PREFIX}${t}`)}),[...i,...h]},Z=t=>{if(!t)return new et;const e=[],r=(t instanceof et?t.getItems():t)??[];for(const t of r)tt(t,e)||e.includes(t)||e.push(t);return new et(e)};function tt(t,e){if(!t.includes(X.SUFFIX_DELIMITER))return!1;const[r,i]=t.split(X.SUFFIX_DELIMITER);if(!r.startsWith(X.READ_REPO_PREFIX)&&!r.startsWith(X.WRITE_REPO_PREFIX)||i!==X.GRAPHQL)return!1;const s=J.getRepoFromAuthority(r);if(!s)return!1;const{repo:n}=s,a=X.GRAPHQL_PREFIX+n;return e.includes(r)||e.push(r),e.includes(a)||e.push(a),!0}class et extends F{WILDCARD="*";GQL_WILDCARD="*:GRAPHQL";constructor(t){super(t)}hasAuthority(t){return this.items.includes(t)}hasWildcardAuthority(t,e){const r=e?this.GQL_WILDCARD:this.WILDCARD;let i=!1;for(const e of this.items){if(!e.endsWith(r))continue;const s=e.substring(0,e.length-r.length);if(t.startsWith(s)){i=!0;break}}return i}getCustomRoles(){return this.getItems().filter(t=>0===t.indexOf(X.CUSTOM_PREFIX)).map(t=>t.substring(X.CUSTOM_PREFIX.length))}toUIModel(){const t={[X.READ_REPO]:{},[X.WRITE_REPO]:{},[X.GRAPHQL]:{}};return Z(this.getItems()).getItems().forEach(e=>{if(e.startsWith(X.READ_REPO_PREFIX)||e.startsWith(X.WRITE_REPO_PREFIX)||e.startsWith(X.GRAPHQL_PREFIX)){const r=J.getRepoFromAuthority(e);if(r){const{prefix:e,repo:i}=r;e===X.READ_REPO_PREFIX?t[X.READ_REPO][i]=!0:e===X.WRITE_REPO_PREFIX?t[X.WRITE_REPO][i]=!0:e===X.GRAPHQL_PREFIX&&(t[X.GRAPHQL][i]=!0)}}}),t}toGraphdbAuthoritiesModel(){return Q(this)}getRepositoriesPermissions(){const t={},e=this.getItems();for(const r of e){const e=J.getRepoFromAuthority(r);if(e){const{prefix:r,repo:i}=e,s=t[i]??{read:!1,write:!1,graphql:!1};r===X.READ_REPO_PREFIX?s.read=!0:r===X.WRITE_REPO_PREFIX?s.write=!0:r===X.GRAPHQL_PREFIX&&(s.graphql=!0),t[i]=s}}return t}}class rt{constructor(t){this.DEFAULT_VIS_GRAPH_SCHEMA=t?.DEFAULT_VIS_GRAPH_SCHEMA??!0,this.DEFAULT_INFERENCE=t?.DEFAULT_INFERENCE??!0,this.DEFAULT_SAMEAS=t?.DEFAULT_SAMEAS??!0,this.IGNORE_SHARED_QUERIES=t?.IGNORE_SHARED_QUERIES??!1,this.EXECUTE_COUNT=t?.EXECUTE_COUNT??!0,this.COOKIE_CONSENT=t?.COOKIE_CONSENT}toJSON(){return{DEFAULT_VIS_GRAPH_SCHEMA:this.DEFAULT_VIS_GRAPH_SCHEMA,DEFAULT_INFERENCE:this.DEFAULT_INFERENCE,DEFAULT_SAMEAS:this.DEFAULT_SAMEAS,IGNORE_SHARED_QUERIES:this.IGNORE_SHARED_QUERIES,EXECUTE_COUNT:this.EXECUTE_COUNT,COOKIE_CONSENT:this.COOKIE_CONSENT}}}let it=function(t){return t.ADMIN="admin",t.REPO_MANAGER="repoManager",t.USER="user",t}({});class st extends C{constructor(t){super(),this.username=t?.username??"",this.password=t?.password,this.confirmPassword=t?.confirmPassword,this.authorities=t?.authorities??new et,this.appSettings=t?.appSettings??new rt,this.dateCreated=t?.dateCreated??null,this.gptThreads=t?.gptThreads??[],this.external=t?.external??!1}getUserType(){return this.authorities.hasAuthority(X.ROLE_ADMIN)?it.ADMIN:this.authorities.hasAuthority(X.ROLE_REPO_MANAGER)?it.REPO_MANAGER:it.USER}getUserTypeDescription(){const t=this.getUserType();return t===it.USER?"User":t===it.REPO_MANAGER?"Repository manager":t===it.ADMIN?"Administrator":"Unknown"}}class nt extends C{toUser(){return new st({username:this.username,authorities:this.authorities,appSettings:this.appSettings,external:this.external})}static fromUser(t){return new nt({username:t.username,authorities:t.authorities,appSettings:t.appSettings,external:t.external})}constructor(t){super(),this.external=t?.external??!1,this.username=t?.username??"",this.password=t?.password??"",this.authorities=t?.authorities??new et,this.grantedAuthoritiesUiModel=Z(t?.authorities??[]),this.appSettings=t?.appSettings??new rt}getCookieConsent(){return this.appSettings.COOKIE_CONSENT}setAuthorities(t=new et){return this.authorities=t,this.grantedAuthoritiesUiModel=Z(t.getItems()),this}setAppSettings(t=new rt){return this.appSettings=t,this}}class at extends C{constructor(t){super(),t&&(this.clientId=t.clientId,this.issuer=t.issuer,this.tokenType=t.tokenType,this.tokenAudience=t.tokenAudience,this.tokenIssuer=t.tokenIssuer,this.oidcTokenEndpoint=t.oidcTokenEndpoint,this.oidcJwksUri=t.oidcJwksUri,this.oidcEndSessionEndpoint=t.oidcEndSessionEndpoint,this.oidcAuthorizationEndpoint=t.oidcAuthorizationEndpoint,this.oidcScopesSupported=t.oidcScopesSupported||[],this.oracleDomain=t.oracleDomain,this.proxyOidc=t.proxyOidc||!1,this.authFlow=t.authFlow,this.extraScopes=t.extraScopes,this.authorizeParameters=t.authorizeParameters,this.openIdTokenUrl=this.proxyOidc?"rest/openid/token":this.oidcTokenEndpoint,this.openIdKeysUri=this.proxyOidc?"rest/openid/jwks":this.oidcJwksUri,this.openIdEndSessionUrl=this.oidcEndSessionEndpoint,this.supportsOfflineAccess=this.oidcScopesSupported.includes("offline_access"))}}const ot=t=>new et(t);class ht extends C{constructor(t){super(),this.appSettings=t.appSettings,t.authorities instanceof et?this.authorities=t.authorities:this.authorities=ot(t.authorities??[]),this.enabled=t.enabled}}const ut=t=>{const e=new ht({});return e.appSettings=new rt(t.appSettings),e.authorities=ot(t.authorities||[]),e.enabled=t.enabled,e};class ct extends C{constructor(t){super(),this.authImplementation=t.authImplementation,this.enabled=t.enabled,this.passwordLoginEnabled=t.passwordLoginEnabled,this.freeAccess=ut(t.freeAccess),this.overrideAuth=ut(t.overrideAuth),this.openIdEnabled=t.openIdEnabled,this.freeAccessActive=t.freeAccess?.enabled,this.hasExternalAuth=t.hasExternalAuth,t.methodSettings?.openid&&(this.openidSecurityConfig=new at(t.methodSettings?.openid))}isEnabled(){return this.enabled??!1}isFreeAccessEnabled(){return this.freeAccess.enabled??!1}getFreeAccessAuthSettings(){return this.freeAccess}hasOverrideAuth(){return this.overrideAuth?.enabled??!1}}class lt extends C{pages={};isRestricted(t){return this.pages[t]??!1}setPageRestriction(t,e=!0){return this.pages[t]=e,this}}let gt=function(t){return t.READ="READ",t.WRITE="WRITE",t}({});class pt extends C{constructor(t){super(),this.expiryDate=t?.expiryDate,this.latestPublicationDate=t?.latestPublicationDate,this.licensee=t?.licensee||"",this.maxCpuCores=t?.maxCpuCores,this.product=t?.product,this.productType=t?.productType,this.licenseCapabilities=t?.licenseCapabilities,this.version=t?.version||"",this.installationId=t?.installationId||"",this.valid=t?.valid,this.typeOfUse=t?.typeOfUse||"",this.message=t?.message||"",this.present=t?.present||!1,this.usageRestriction=t?.usageRestriction||""}}class dt extends F{constructor(t){super(t)}}class ft{constructor(t){this.workbench=t.workbench,this.productType=t.productType,this.productVersion=t.productVersion,this.sesame=t.sesame,this.connectors=t.connectors,this.shortVersion=this.resolveShortVersion(t)}resolveShortVersion(t){const e=t.productVersion;if(!e)return"";const r=/^(\d+\.\d+)/.exec(e),i=r?.[1]??e,s=/(-[^-]+)/.exec(e);return i+(s?.[1]??"")}}let yt=function(t){return t.CONSOLE="console",t}({}),vt=function(t){return t.DEBUG="DEBUG",t.INFO="INFO",t.WARN="WARN",t.ERROR="ERROR",t}({});const mt=t=>St[t],St={[vt.DEBUG]:0,[vt.INFO]:1,[vt.WARN]:2,[vt.ERROR]:3};class Et{static SERVICE_INSTANCES=new Map;static get(t){if(!Et.SERVICE_INSTANCES.has(t.name)){const e=new t;Et.implementsLifecycleHooks(e)&&e.onCreated?.(),Et.SERVICE_INSTANCES.set(t.name,e)}return this.SERVICE_INSTANCES.get(t.name)}static implementsLifecycleHooks(t){return"object"==typeof t&&"function"==typeof t.onCreated}static getAllBySuperType(t){return Array.from(Et.SERVICE_INSTANCES.values()).filter(e=>e instanceof t)}}function xt(t){return Et.get(t)}const At=new Map([[yt.CONSOLE,xt(class{log(t,e,r){switch(t){case vt.DEBUG:console.debug(e,...r);break;case vt.INFO:console.info(e,...r);break;case vt.WARN:console.warn(e,...r);break;case vt.ERROR:console.error(e,...r);break;default:console.debug(e,...r)}}})]]);class wt{callbackFunctions=[];beforeChangeValidationPromises=[];afterValueChangeCallbackFunctions=[];setValue(t){n.deepEqual(this.value,t)||(this.value=this.getCopy(t),this.callbackFunctions.forEach(t=>t(this.getValue())),this.afterValueChangeCallbackFunctions.forEach(t=>t(this.getValue())))}getValue(){return this.getCopy(this.value)}subscribe(t,e,r){return this.callbackFunctions.push(t),e&&this.beforeChangeValidationPromises.push(e),r&&this.afterValueChangeCallbackFunctions.push(r),()=>{this.callbackFunctions=this.callbackFunctions.filter(e=>e!==t),this.beforeChangeValidationPromises=this.beforeChangeValidationPromises.filter(t=>t!==e),this.afterValueChangeCallbackFunctions=this.afterValueChangeCallbackFunctions.filter(t=>t!==r)}}async canUpdate(t){if(0===this.beforeChangeValidationPromises.length)return!0;const e=this.beforeChangeValidationPromises.map(e=>e(t));try{return(await Promise.all(e)).every(t=>t)}catch{return!1}}getCopy(t){if(null!=t)return n.hasCopyMethod(t)?t.copy():n.deepCopy(t)}}class bt{subscribers=[];unsubFns=new I;subscribeToService(t){const e=this.subscribers.map(e=>t.subscribeAll(e.callback,e.beforeChangeValidationPromise,e.afterChangeCallback));return this.unsubFns.addAll(e),()=>e.forEach(t=>t())}subscribeToAllRegisteredContexts(t,e,r){const i=Et.getAllBySuperType(Ct).filter(t=>t.canSubscribeAll);for(const s of i)this.unsubFns.add(s.subscribeAll(t,e,r));const s={callback:t,beforeChangeValidationPromise:e,afterChangeCallback:r};this.subscribers.push(s);let n=!1;return()=>{if(n)return;n=!0,this.unsubFns.unsubscribeAll();const t=this.subscribers.indexOf(s);t>=0&&this.subscribers.splice(t,1)}}}class Ct{context=new Map;_canSubscribeAll=!1;onCreated(){this._canSubscribeAll=!0,Et.get(bt).subscribeToService(this)}updateContextProperty(t,e){this.getOrCreateValueContext(t).setValue(e)}validatePropertyChange(t,e){return this.getOrCreateValueContext(t).canUpdate(e)}getContextPropertyValue(t){const e=this.context.get(t);return e?e.getValue():void 0}subscribe(t,e,r,i){return e&&e(this.getContextPropertyValue(t)),i&&i(this.getContextPropertyValue(t)),this.getOrCreateValueContext(t).subscribe(e,r,i)}getDeserializedContext(){}deserializeProperty(t,e){const r=this.getDeserializedContext()?.[t];return r?r(e):e}subscribeAll(t,e,r){const i=new I;for(const s of this.getContextFields())i.add(this.subscribe(s,t,e,r));return()=>i.unsubscribeAll()}getContextFields(){return Object.values(this).filter(t=>"string"==typeof t)}getOrCreateValueContext(t){let e=this.context.get(t);return e||(e=new wt,this.context.set(t,e)),e}canHandle(t){for(const e in this)if(this[e]===t)return!0;return!1}get canSubscribeAll(){return this._canSubscribeAll}}class Ft extends Ct{APPLICATION_CONFIGURATION="applicationConfiguration";updateApplicationConfiguration(t){this.updateContextProperty(this.APPLICATION_CONFIGURATION,t)}getApplicationConfiguration(){return this.getContextPropertyValue(this.APPLICATION_CONFIGURATION)}getApplicationLogoPath(t){const e=this.getApplicationConfiguration(),r=e.applicationLogoPaths,s=t===i.dark?i.light:i.dark;return r&&r[s]?r[s]:e.applicationLogoPath}}class It{loggers=At;constructor(t){this.module=t}debug(t,...e){this.log(vt.DEBUG,t,e)}error(t,...e){this.log(vt.ERROR,t,e)}info(t,...e){this.log(vt.INFO,t,e)}warn(t,...e){this.log(vt.WARN,t,e)}log(t,e,r){const i=this.loadConfiguration();i?.loggers.forEach(s=>{const n=this.loggers.get(s);if(!n)throw new Error(`Logger '${s}' not found`);if(mt(i.minLogLevel)<=mt(t)){const i=this.getFormattedMessage(t,e);n.log(t,i,r)}})}getFormattedMessage(t,e){return`[${t}] [${this.module}] [${(new Date).toLocaleString()}] ${e}`}loadConfiguration(){const t=xt(Ft).getApplicationConfiguration();return t?.loggerConfig}}class Rt{static loggerInstances=new Map;static getLoggerInstance(t){return this.loggerInstances.has(t)||this.loggerInstances.set(t,new It(t)),this.loggerInstances.get(t)}}class Tt{static get logger(){return Rt.getLoggerInstance("API")}}class Pt{logger=Tt.logger;constructor(t){this.value=t}getValue(){return this.value}isDefined(){return!n.isNullOrUndefined(this.value)}getValueOrDefault(t){return this.value||t}getAsJson(){if(null===this.value)return null;try{return JSON.parse(this.value)}catch(t){return this.logger.error("Error parsing JSON",t),null}}}class Dt{static GLOBAL_NAMESPACE="ontotext.gdb"}class Nt{constructor(t=[]){this.languages=t}getLanguageCodes(){return this.languages?.map(t=>t.key)}}const Ot=["en","fr"];class _t extends C{constructor(t){super(),this.defaultLanguage=t.defaultLanguage||"en",this.availableLanguages=t.availableLanguages||new Nt}}class Bt{constructor(t){this.policyAccepted=t?.policyAccepted,this.statistic=t?.statistic,this.thirdParty=t?.thirdParty,this.updatedAt=t?.updatedAt}hasChanged(){return void 0!==this.policyAccepted}static NOT_ACCEPTED_WITH_TRACKING(){return new Bt({policyAccepted:void 0,statistic:!0,thirdParty:!0})}static ACCEPTED_NO_TRACKING(){return new Bt({policyAccepted:!0,statistic:!1,thirdParty:!1})}static fromJSON(t){return new Bt({policyAccepted:t?.policyAccepted,statistic:t?.statistic,thirdParty:t?.thirdParty,updatedAt:t?.updatedAt})}}let Ht=function(t){return t.INFORMATION="INFORMATION",t.WARNING="WARNING",t.CRITICAL="CRITICAL",t}({});const Lt={[Ht.INFORMATION]:0,[Ht.WARNING]:1,[Ht.CRITICAL]:2};class kt extends C{constructor(t){super(),this.id=`${t.group}-${t.status}-${t.totalOperations}`,this.group=t.group,this.totalOperations=t.totalOperations,this.status=t.status}}class Ut extends F{constructor(t){super(t)}}class Vt extends C{constructor(t){super(),this.status=t.status,this.allRunningOperations=t.allRunningOperations}toOperationsGroupSummary(){const t=new Map;return this.allRunningOperations.getItems().forEach(e=>{t.has(e.group)||t.set(e.group,new kt({group:e.group,totalOperations:0,status:Ht.INFORMATION}));const r=t.get(e.group);r.totalOperations+=e.count,Lt[e.status]>Lt[r.status]&&(r.status=e.status)}),Array.from(t.values())}toOperationGroupSummaryList(){return new Ut(this.toOperationsGroupSummary())}}class jt extends F{constructor(t){super(t)}}let Kt=function(t){return t.UPDATES="updates",t.QUERIES="queries",t.IMPORT="imports",t.BACKUP_AND_RESTORE="backupAndRestore",t.CLUSTER_HEALTH="clusterHealth",t}({}),Mt=function(t){return t.QUERY="QUERY",t.BACKUP="BACKUP",t.CLUSTER="CLUSTER",t.IMPORT="IMPORT",t}({});const qt=[Kt.QUERIES,Kt.UPDATES,Kt.IMPORT],Gt={[Kt.UPDATES]:"monitor/queries",[Kt.QUERIES]:"monitor/queries",[Kt.BACKUP_AND_RESTORE]:"monitor/backup-and-restore",[Kt.IMPORT]:"import",[Kt.CLUSTER_HEALTH]:"cluster"},Wt={[Kt.QUERIES]:Mt.QUERY,[Kt.UPDATES]:Mt.QUERY,[Kt.BACKUP_AND_RESTORE]:Mt.BACKUP,[Kt.IMPORT]:Mt.IMPORT,[Kt.CLUSTER_HEALTH]:Mt.CLUSTER};class $t extends C{constructor(t){super(),this.value=t.value,this.status=t.status,this.type=t.type,this.id=`${t.status}-${t.type}-${t.value}`,this.count=this.getCount(this.type,this.value),this.group=Wt[this.type],this.href=Gt[this.type],this.labelKey=this.getLabelKey(this.type,this.value)}getCount(t,e){return qt.includes(t)?parseInt(e,10):0}getLabelKey(t,e){return qt.includes(t)?t:e}}let zt=function(t){return t.BOTTOM_RIGHT="bottom-right",t.BOTTOM_LEFT="bottom-left",t}({});class Yt{constructor(t){this.timeout=t?.timeout||5e3,this.onClick=t?.onClick,this.removeOnClick=t?.removeOnClick||!1,this.title=t?.title,this.translationParams=t?.translationParams}}class Xt extends Yt{constructor(t){super(),this.timeout=t.timeout,this.position=t.position}static getDefaultConfig(){return this.instance||(this.instance=new Xt({timeout:5e3,position:zt.BOTTOM_RIGHT})),this.instance}}let Jt=function(t){return t.ERROR="error",t.INFO="info",t.SUCCESS="success",t.WARNING="warning",t}({});class Qt{static uuid(){const t=16;let e=(new Date).getTime(),r=1e3*(performance?.now()??0);return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{let s=Math.random()*t;return e>0?(s=(e+s)%t|0,e=Math.floor(e/t)):(s=(r+s)%t|0,r=Math.floor(r/t)),("x"===i?s:3&s|8).toString(t)})}static generateRandomString(t){const e=new Uint32Array(t);return c.getCrypto().getRandomValues(e),Array.from(e,t=>("0"+t.toString(16)).substr(-2)).join("")}static hashCode(t){let e=0;for(let r=0,i=t.length;r<i;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return e}}class Zt extends C{constructor(){super(),this.id=Qt.uuid()}}class te extends Zt{constructor(t,e,r){super(),this.type=t,this.message=e,this.config=r}}const ee="create-toast-event";class re extends F{constructor(t){super(t)}}class ie extends F{constructor(t){super(t)}}class se extends C{constructor(t){super(),this.setRadio(t.isRadio),this.setButtons(new ie(t.buttons))}getButtons(){return this.buttons}setButtons(t){this.buttons=t}isRadio(){return this.radio}setRadio(t){this.radio=t}selectButton(t){return this.isRadio()&&!t.selected&&(this.deselectAll(),t.selected=!0,t.callback()),this.copy()}deselectAll(){this.buttons.getItems().forEach(t=>t.selected=!1)}}class ne extends C{constructor(t){super(),this.id=t.id,this.label=t.label,this.selected=t.selected,this.callback=t.callback}}class ae extends F{constructor(t){super(t)}findSuggestionByValue(t){return this.items.find(e=>e.getValue()===t)}findHoveredSuggestion(){return this.items.find(t=>t.isHovered())}getHoveredSuggestionIndex(){return this.items.findIndex(t=>t.isHovered())}setHoveredStateAtIndex(t,e){const r=this.items[t];r&&r.setHovered(e)}unhoverAllSuggestions(){this.items.forEach(t=>t.setHovered(!1))}deselectAllSuggestions(){this.items.forEach(t=>t.setSelected(!1))}}class oe extends C{constructor(t){super(),this.suggestions=t}hoverFirstSuggestion(){const t=this.suggestions.getFirstItem();if(t)return this.hoverSuggestion(t)}hoverSuggestion(t){return t&&(this.clearHoveredState(),t.setHovered(!0)),this.copy()}selectSuggestion(t){return t&&(this.clearSelectedState(),t.setSelected(!0)),this.copy()}getHoveredSuggestion(){return this.suggestions.findHoveredSuggestion()}hoverPreviousSuggestion(){const t=this.suggestions.getHoveredSuggestionIndex();return t>0&&(this.clearHoveredState(),this.suggestions.setHoveredStateAtIndex(t-1,!0)),this.copy()}hoverNextSuggestion(){const t=this.suggestions.getHoveredSuggestionIndex();return t<this.suggestions.size()-1&&(this.clearHoveredState(),this.suggestions.setHoveredStateAtIndex(t+1,!0)),this.copy()}clearSuggestions(){return this.suggestions=new ae,this.copy()}getByValue(t){return this.suggestions.findSuggestionByValue(t)}clearSelectedState(){this.suggestions.deselectAllSuggestions()}clearHoveredState(){this.suggestions.unhoverAllSuggestions()}}class he extends C{overrideToVisual=!1;constructor(t){super(),this.setId(t.id),this.setType(t.type),this.setValue(t.value),this.setDescription(t.description)}getId(){return this._id}setId(t){this._id=t}getType(){return this._type}setType(t){this._type=t}getValue(){return this._value}setValue(t){this._value=t}getDescription(){return this._description}setDescription(t){this._description=t}isHovered(){return this._hovered}setHovered(t){this._hovered=t}isSelected(){return this._selected}setSelected(t){this._selected=t}getOverrideToVisual(){return this.overrideToVisual}setOverrideToVisual(t){this.overrideToVisual=t}}let ue=function(t){return t.URI="uri",t.PREFIX="prefix",t}({});class ce{constructor(t,e){this.setSuggestion(t),this.setContext(e)}getSuggestion(){return this.suggestion}getContext(){return this.context}setContext(t){this.context=t}setSuggestion(t){this.suggestion=t}}let le=function(t){return t.DATA_LOADED="DATA_LOADED",t}({});class ge{constructor(t,e){this.entry=t,this.name=e}}class pe extends C{constructor(t){super(),this._pluginDefinitions=t}getPluginDefinitions(){return this._pluginDefinitions}}let de=function(t){return t.ROUTE="route",t.MAIN_MENU="main.menu",t}({});class fe extends F{constructor(t){super(t)}}let ye=function(t){return t.ERROR="error",t.INFO="info",t.SUCCESS="success",t.WARNING="warning",t}({});class ve extends Zt{constructor(t){super(),this.code=t}withTitle(t){return this.title=t,this}withType(t){return this.type=t,this}withParameters(t){return this.parameters=t,this}static info(t){return new ve(t).withType(ye.INFO)}static error(t){return new ve(t).withType(ye.ERROR)}static warning(t){return new ve(t).withType(ye.WARNING)}static success(t){return new ve(t).withType(ye.SUCCESS)}}let me=function(t){return t.SHOULD_TOAST="shouldToast",t}({});class Se{priority=0}class Ee extends F{constructor(t){super(t)}}let xe=function(t){return t.RETURN_URL="r",t.NO_ACCESS="noaccess",t.EXPIRED="expired",t}({});class Ae{getStorage(){return localStorage}get(t){const e=this.getStorage().getItem(this.getPrefixedKey(t));return new Pt(e)}getAsJson(t){const e=this.getStorage().getItem(t);if(e)try{return JSON.parse(e)}catch(e){return console.error(`Error parsing JSON from localStorage for key ${t}:`,e),null}return null}storeValue(t,e){this.getStorage().setItem(this.getPrefixedKey(t),e)}remove(t){this.getStorage().removeItem(this.getPrefixedKey(t))}getPrefixedKey(t){const e=`${Dt.GLOBAL_NAMESPACE}.${this.NAMESPACE}.`,r=`${this.NAMESPACE}.`;return t.startsWith(e)?t:t.startsWith(r)?`${Dt.GLOBAL_NAMESPACE}.${t}`:`${e}${t}`}}class we{logger=Tt.logger;handleStorageChange(t){const e=t.key?.substring(Dt.GLOBAL_NAMESPACE.length+1);let r="",i="";e&&(r=e.substring(0,e.indexOf(".")),i=e.substring(r.length+1));const s=this.resolveHandler(r,i);if(s){let e;null!==t.newValue&&(e=s.deserializeProperty(i,t.newValue)),s.updateContextProperty(i,e)}}resolveHandler(t,e){if(!t)return void this.logger.warn("Namespace is required to resolve a context property change handler.");const r=Et.getAllBySuperType(Ct).find(t=>t.canHandle(e));if(r)return r;this.logger.warn(`No context property change handler found for namespace: ${t} and property: ${e}`)}}class be extends Ae{NAMESPACE="application";SETTINGS="settings";logger=Tt.logger;OLD_SETTINGS_KEY="ls.workbench-settings";migrate(){if(this.get(this.SETTINGS).getValue())return;const t=this.getAsJson(this.OLD_SETTINGS_KEY);if(!t)return;this.logger.info("Begin migrating legacy application settings to new format...");const e=new s;e.theme=t.theme,t.mode&&t.mode===i.dark?e.themeMode=i.dark:e.themeMode=i.light,this.setApplicationSettings(e),this.getStorage().removeItem(this.OLD_SETTINGS_KEY),this.logger.info("Migration of legacy application settings completed. Old settings key removed.")}set(t,e){this.storeValue(t,e)}setApplicationSettings(t){this.set(this.SETTINGS,JSON.stringify(t))}getApplicationSettings(){const t=this.get(this.SETTINGS).getAsJson();return t?new s(t):new s}getThemeMode(){return this.getApplicationSettings().themeMode}isThemeModePresent(){const t=this.get(this.SETTINGS).getAsJson();return!!t&&void 0!==new s(t).themeMode}}class Ce extends Ct{RUNTIME_CONFIGURATION="runtimeConfiguration";THEME_MODE="themeMode";updateRuntimeConfiguration(t){const e={...this.getRuntimeConfiguration()??{},...t};this.updateContextProperty(this.RUNTIME_CONFIGURATION,e)}onRuntimeConfigurationChanged(t){return this.subscribe(this.RUNTIME_CONFIGURATION,t)}getRuntimeConfiguration(){return this.getContextPropertyValue(this.RUNTIME_CONFIGURATION)}updateThemeMode(t){this.updateContextProperty(this.THEME_MODE,t)}onThemeModeChanged(t){return this.subscribe(this.THEME_MODE,t)}}class Fe{applicationSettingsStorageService=xt(be);runtimeConfigurationContextService=xt(Ce);rootSelector=":root";darkClass=i.dark;static CODE_EDITOR_DARK_THEME="moxer";applyDarkModeIfEnabled(){const t=this.isDarkModeEnabledInSettings()?i.dark:i.light;this.setThemeMode(t)}setThemeMode(t){const e=this.getRootElement();if(!e)return;const r=t===i.dark;e.classList.toggle(this.darkClass,r),this.runtimeConfigurationContextService.updateThemeMode(r?i.dark:i.light)}applyColorScheme(){this.isThemeModeSet()?this.applyDarkModeIfEnabled():this.setThemeMode(this.getPreferredScheme())}applyNewColorScheme(t){this.isThemeModeSet()||this.setThemeMode(t)}isDarkModeApplied(){const t=this.getRootElement();if(!t)return!1;const e=i.dark;return t.classList.contains(e)}isDarkModeEnabledInSettings(){const t=this.applicationSettingsStorageService.getApplicationSettings();return t?.themeMode===i.dark}isThemeModeSet(){return this.applicationSettingsStorageService.isThemeModePresent()}getCodeEditorThemeName(){return this.isDarkModeApplied()?Fe.CODE_EDITOR_DARK_THEME:void 0}getPreferredScheme(){return c.matchMedia("(prefers-color-scheme: dark)").matches?i.dark:i.light}getRootElement(){return document.querySelector(this.rootSelector)??null}}class Ie{constructor(t){this.url=t.url,this.method=t.method,this.headers={...t.headers},this.body=t.body}}class Re{constructor(t){this.status=t.status,this.statusText=t.statusText,this.headers=t.headers,this.config=t.config,this.originalResponse=t.originalResponse}}class Te extends Re{constructor(t){super(t),this.data=t.data}}class Pe extends Re{constructor(t){super(t),this.data=t.data??null,this.status>=200&&this.status<300?this.message=`Http failure during parsing for ${t.config.url||"(unknown url)"}`:this.message=`Http failure response for ${t.config.url||"(unknown url)"}: ${t.status} ${t.statusText}`}get isClientError(){return this.status>=400&&this.status<500}get isServerError(){return this.status>=500&&this.status<600}}class De{preProcessors=new F;postProcessors=new F;async preProcess(t){let e=t;for(const t of this.preProcessors.getItems())t.shouldProcess(e)&&(e=await t.process(e));return e}async postProcess(t){let e=t;for(const t of this.postProcessors.getItems())t.shouldProcess(e)&&(e=await t.process(e));return e}registerRequestInterceptors(t){this.preProcessors.addItems(t.getItems()),this.sortInterceptors(this.preProcessors)}registerResponseInterceptors(t){this.postProcessors.addItems(t.getItems()),this.sortInterceptors(this.postProcessors)}sortInterceptors(t){t.sort((t,e)=>e.priority-t.priority)}}class Ne{emit(t){const e=new CustomEvent(t.NAME,{detail:t.payload});return this.getHostElement().dispatchEvent(e),e}subscribe(t,e){const r=t=>{t instanceof CustomEvent&&e(t.detail)};return this.getHostElement().addEventListener(t,r),()=>this.getHostElement().removeEventListener(t,r)}getHostElement(){return document.body}}const Oe="http-request-done-event";class _e{interceptorService=Et.get(De);eventEmitter=new Ne;get(t,e){const{params:r,headers:i,responseType:s="body"}=e??{};return"response"===s?this.request(t,"GET",{params:r,headers:i},"response"):this.request(t,"GET",{params:r,headers:i},"body")}post(t,e){const{body:r,headers:i,responseType:s="body"}=e??{};return"response"===s?this.request(t,"POST",{body:r,headers:i},"response"):this.request(t,"POST",{body:r,headers:i},"body")}put(t,e){const{body:r,headers:i,responseType:s="body"}=e??{};return"response"===s?this.request(t,"PUT",{body:r,headers:i},"response"):this.request(t,"PUT",{body:r,headers:i},"body")}patch(t,e){const{body:r,headers:i,responseType:s="body"}=e??{};return"response"===s?this.request(t,"PATCH",{body:r,headers:i},"response"):this.request(t,"PATCH",{body:r,headers:i},"body")}delete(t,e){const{headers:r,responseType:i="body"}=e??{};return"response"===i?this.request(t,"DELETE",{headers:r},"response"):this.request(t,"DELETE",{headers:r},"body")}uploadFile(t,e,r="file",i,s){const n=new FormData;n.append(r,e,e instanceof File?e.name:void 0),s&&Object.entries(s).forEach(([t,e])=>{n.append(t,e)});const a={...i};return delete a["Content-Type"],this.post(t,{body:n,headers:a,responseType:"response"})}encodeURIComponentStrict(t){return encodeURIComponent(t).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16)})}request(t,e,r={},i="response"){const{fullUrl:s,headers:n}=this.getRequestConfig(t,r),a=new Ie({url:s,method:e,headers:n,body:r.body});let o;return this.executeRequest(a).then(async t=>{if(o=t,!t.ok){const e=await this.getDataFromResponse(i,t),r=new Pe({status:t.status,statusText:t.statusText,headers:this.extractHeaders(t),config:a,originalResponse:t,data:e});return Promise.reject(r)}const e=await this.getDataFromResponse(i,t);return"body"===i?e:new Te({status:t.status,statusText:t.statusText,headers:this.extractHeaders(t),config:a,originalResponse:t,data:e})}).catch(t=>{if(t instanceof Pe)return Promise.reject(t);o??=t;const e=new Pe({status:o.status,statusText:o.statusText,headers:this.extractHeaders(o),config:a,originalResponse:o,data:null});return t?.message&&(e.message=t.message),Promise.reject(e)}).finally(()=>this.eventEmitter.emit({NAME:Oe,payload:void 0}))}async getDataFromResponse(t,e){let r=null;if(r=await e.text(),!t||"body"===t||"response"===t)try{r=JSON.parse(r)}catch{}return r}getRequestConfig(t,e){const r=this.buildQueryParams(e.params),i=`${t}${r?`?${r}`:""}`,s=e.body instanceof FormData,n={Accept:"application/json, text/plain, */*",...e.headers};return s||(n["Content-Type"]=e.headers?.["Content-Type"]??"application/json"),{fullUrl:i,headers:n}}formatBody(t,e){return e?e instanceof FormData?e:t["Content-Type"]?.includes("application/json")?JSON.stringify(e):(t["Content-Type"]?.includes("application/x-www-form-urlencoded"),e):null}executeRequest(t){return this.interceptorService.preProcess(t).then(t=>{const e=this.formatBody(t.headers,t.body);return fetch(t.url,{method:t.method,headers:t.headers,body:e})}).then(t=>this.interceptorService.postProcess(t))}extractHeaders(t){const e={};return t.headers.forEach((t,r)=>{e[r]=t}),e}buildQueryParams(t={}){return new URLSearchParams(t).toString()}}class Be extends _e{I18N_ENDPOINT="assets/i18n";getLanguage(t){return this.get(`${this.I18N_ENDPOINT}/${t}.json`)}getLanguageConfiguration(){return this.get(`${this.I18N_ENDPOINT}/language-config.json`)}}class He extends Ae{NAMESPACE="i18n";set(t,e){this.storeValue(t,e)}}class Le extends Ct{LANGUAGE_CONFIG="languageConfig";SELECTED_LANGUAGE="selectedLanguage";LANGUAGE_BUNDLE="languageBundle";DEFAULT_BUNDLE="defaultBundle";updateSelectedLanguage(t){this.validatePropertyChange(this.SELECTED_LANGUAGE,t).then(e=>{if(e){const e=t||Et.get(Ve).getDefaultLanguage();Et.get(He).set(this.SELECTED_LANGUAGE,e),this.updateContextProperty(this.SELECTED_LANGUAGE,t)}})}onSelectedLanguageChanged(t,e){return this.subscribe(this.SELECTED_LANGUAGE,t,e)}updateLanguageBundle(t){this.updateContextProperty(this.LANGUAGE_BUNDLE,t)}onLanguageBundleChanged(t){return this.subscribe(this.LANGUAGE_BUNDLE,t)}getLanguageBundle(){return this.getContextPropertyValue(this.LANGUAGE_BUNDLE)}updateDefaultBundle(t){this.updateContextProperty(this.DEFAULT_BUNDLE,t)}getDefaultBundle(){return this.getContextPropertyValue(this.DEFAULT_BUNDLE)}getLanguageConfig(){return this.getContextPropertyValue(this.LANGUAGE_CONFIG)}setLanguageConfig(t){this.updateContextProperty(this.LANGUAGE_CONFIG,t)}getSelectedLanguage(){return this.getContextPropertyValue(this.SELECTED_LANGUAGE)}}class ke extends C{constructor(t,e){super(),this.key=t,this.name=e}}function Ue(t){const e=t.map(t=>new ke(t.key,t.name));return new Nt(e)}class Ve{languageRestService=Et.get(Be);languageContextService=Et.get(Le);getSupportedLanguages(){const t=this.languageContextService.getLanguageConfig();return t?t.availableLanguages.getLanguageCodes():Ot}getLanguage(t){return this.languageRestService.getLanguage(t)}getLanguageConfiguration(){return this.languageRestService.getLanguageConfiguration().then(t=>{return new _t({defaultLanguage:(e=t).defaultLanguage,availableLanguages:Ue(e.availableLanguages)});var e})}getDefaultLanguage(){const t=this.languageContextService.getLanguageConfig();return t?t.defaultLanguage:"en"}}class je extends _e{static REPOSITORIES_ENDPOINT="rest/repositories";getRepositories(){return this.get(`${je.REPOSITORIES_ENDPOINT}/all`)}getRepositorySizeInfo(t){return this.get(`${je.REPOSITORIES_ENDPOINT}/${t.id}/size?location=${encodeURIComponent(t.location)}`)}}const Ke=t=>new D(t),Me=t=>{if(!t||"object"!=typeof t)return new P;const e=[];return Object.entries(t).forEach(([,t])=>{Array.isArray(t)&&t.forEach(t=>{const r=new R({id:t.id,title:t.title,type:w(O,t.type),sesameType:t.sesameType,uri:t.uri,externalUrl:t.externalUrl,location:t.location,state:w(N,t.state),local:t.local,readable:t.readable,writable:t.writable,unsupported:t.unsupported});e.push(r)})}),new P(e)};class qe{GRAPHQL_REPO_AUTHORITY="GRAPHQL";constructor(){this.repositoryRestService=Et.get(je)}getRepositories(){return this.repositoryRestService.getRepositories().then(t=>Me(t))}getRepositorySizeInfo(t){return this.repositoryRestService.getRepositorySizeInfo(t).then(Ke)}isSystemRepository(t){return"SYSTEM"===t.id}getCurrentGqlRepoAuthority(t,e){return`${this.getCurrentRepoAuthority(t,e)}:${this.GRAPHQL_REPO_AUTHORITY}`}getOverallGqlRepoAuthority(t){return`${this.getOverallRepoAuthority(t)}:${this.GRAPHQL_REPO_AUTHORITY}`}getLocationSpecificId(t){return t.location?`${t.id}@${t.location}`:t.id}getCurrentRepoAuthority(t,e){return`${t}_REPO_${e}`}getOverallRepoAuthority(t){return`${t}_REPO_*`}}class Ge extends Ae{NAMESPACE="repository";logger=Tt.logger;SELECTED_REPOSITORY="selectedRepository";set(t,e){e?this.storeValue(t,e):this.remove(t)}setRepositoryReference(t){this.set(this.SELECTED_REPOSITORY,this.serializeRepositoryReference(t))}getRepositoryReference(){return this.deserializeRepositoryReference(this.get(this.SELECTED_REPOSITORY).getValueOrDefault('{"id": "", "location": ""}'))}removeRepositoryReference(){this.remove(this.SELECTED_REPOSITORY)}serializeRepositoryReference(t){return JSON.stringify(t)}deserializeRepositoryReference(t){if("string"==typeof t)try{return JSON.parse(t)}catch(t){this.logger.error("Error parsing repository reference",t)}}}class We extends Ct{SELECTED_REPOSITORY="selectedRepository";REPOSITORY_LIST="repositoryList";updateSelectedRepository(t){const e=xt(Ge),r=this.findRepository(t);return this.validatePropertyChange(this.SELECTED_REPOSITORY,r).then(i=>{i&&(r?e.setRepositoryReference(r.toRepositoryReference()):t||e.removeRepositoryReference(),this.updateContextProperty(this.SELECTED_REPOSITORY,r))})}getSelectedRepository(){return this.getContextPropertyValue(this.SELECTED_REPOSITORY)}onSelectedRepositoryChanged(t,e){return this.subscribe(this.SELECTED_REPOSITORY,t,e)}updateRepositoryList(t){return this.updateContextProperty(this.REPOSITORY_LIST,t)}getRepositoryList(){return this.getContextPropertyValue(this.REPOSITORY_LIST)||new P([])}onRepositoryListChanged(t){return this.subscribe(this.REPOSITORY_LIST,t)}getDeserializedContext(){return{[this.SELECTED_REPOSITORY]:this.deserializeRepository}}deserializeRepository=t=>new R(JSON.parse(t));findRepository(t,e=!1){if(t)return this.getRepositoryList().findRepository(t.id,t.location,e)}repositoryExists(t,e=!1){return void 0!==this.findRepository(t,e)}}class $e extends _e{getActiveRepositoryLocation(){return this.get("rest/locations/active")}}const ze=t=>new B({uri:t.uri,label:t.label,username:t.username??void 0,password:t.password??void 0,authType:t.authType?w(Y,t.authType):void 0,locationType:t.locationType?w(H,t.locationType):void 0,active:t.active,local:t.local,system:t.system,errorMsg:t.errorMsg??"",defaultRepository:t.defaultRepository??void 0});class Ye{constructor(){this.locationRestService=Et.get($e)}getActiveRepositoryLocation(){return this.locationRestService.getActiveRepositoryLocation().then(ze)}}class Xe extends Ct{ACTIVE_REPOSITORY_LOCATION="activeRepositoryLocation";IS_LOADING="isLoading";updateActiveRepositoryLocation(t){this.updateContextProperty(this.ACTIVE_REPOSITORY_LOCATION,t)}onActiveLocationChanged(t){return this.subscribe(this.ACTIVE_REPOSITORY_LOCATION,t)}updateIsLoading(t){this.updateContextProperty(this.IS_LOADING,t)}onIsLoadingChanged(t){return this.subscribe(this.IS_LOADING,t)}}class Je extends _e{LICENSE_ENDPOINT="rest/graphdb-settings/license";LICENSE_INFO_ENDPOINT="rest/info/license";getLicense(){return this.get(this.LICENSE_ENDPOINT)}getIsLicenseHardcoded(){return this.get(`${this.LICENSE_ENDPOINT}/hardcoded`)}registerLicense(t){const e=new Uint8Array(t.length);for(let r=0;r<e.length;r++)e[r]=t.charCodeAt(r);return this.post(this.LICENSE_ENDPOINT,{body:e,headers:{"Content-Type":"application/octet-stream"}})}unregisterLicense(){return this.delete(this.LICENSE_ENDPOINT)}extractFromLicenseFile(t){return this.uploadFile(`${this.LICENSE_INFO_ENDPOINT}/to-base-64`,t,void 0,{Accept:"text/plain"}).then(t=>t.data)}validateLicense(t){return this.post(`${this.LICENSE_INFO_ENDPOINT}/validate`,{body:t,headers:{"Content-Type":"text/plain"}})}}let Qe=function(t){return t.GRAPHDB_LITE="GRAPHDB_LITE",t.GRAPHDB_SE="GRAPHDB_SE",t.GRAPHDB_ENTERPRISE="GRAPHDB_ENTERPRISE",t.GRAPHDB_SANDBOX="GRAPHDB_SANDBOX",t}({}),Ze=function(t){return t.FREE="free",t.STANDARD="standard",t.ENTERPRISE="enterprise",t.SANDBOX="sandbox",t}({});function tr(t){return Object.values(Ze).find(e=>e===t)}const er=t=>{return new pt({expiryDate:t?.expiryDate?new Date(t.expiryDate):void 0,latestPublicationDate:t?.latestPublicationDate?new Date(t.latestPublicationDate):void 0,licensee:t?.licensee||"",maxCpuCores:t?.maxCpuCores,product:(e=t?.product,Object.values(Qe).find(t=>t===e)),productType:tr(t?.productType),licenseCapabilities:rr(t?.licenseCapabilities),version:t?.version||"",installationId:t?.installationId||"",valid:t?.valid,typeOfUse:t?.typeOfUse||"",message:t?.message||"",present:t?.present||!1,usageRestriction:t?.usageRestriction||""});var e};function rr(t){const e=(t??[]).filter(t=>t?.trim());return new dt(e)}class ir extends Ct{GRAPHDB_LICENSE="graphDbLicense";IS_LICENSE_HARDCODED="isLicenseHardcoded";updateGraphdbLicense(t){this.updateContextProperty(this.GRAPHDB_LICENSE,t)}onLicenseChanged(t){return this.subscribe(this.GRAPHDB_LICENSE,t)}getLicenseSnapshot(){return this.getContextPropertyValue(this.GRAPHDB_LICENSE)}updateIsLicenseHardcoded(t){this.updateContextProperty(this.IS_LICENSE_HARDCODED,!!t)}onIsLicenseHardcodedChanged(t){return this.subscribe(this.IS_LICENSE_HARDCODED,t)}isLicenseHardcodedSnapshot(){return this.getContextPropertyValue(this.IS_LICENSE_HARDCODED)}}class sr{licenseRestService=xt(Je);licenseContextService=xt(ir);trackableProductTypes=[Ze.FREE,Ze.SANDBOX];trackableTypesOfUse=["evaluation","this is an evaluation license"];async updateLicenseStatus(){const t=await this.getIsLicenseHardcoded();this.licenseContextService.updateIsLicenseHardcoded(t);const e=await this.getLicense();return this.licenseContextService.updateGraphdbLicense(e),e}async getLicense(){const t=await this.licenseRestService.getLicense();return er(t)}registerLicense(t){return this.licenseRestService.registerLicense(t).then(t=>er(t))}unregisterLicense(){return this.licenseRestService.unregisterLicense()}extractFromLicenseFile(t){return this.licenseRestService.extractFromLicenseFile(t)}getIsLicenseHardcoded(){return this.licenseRestService.getIsLicenseHardcoded()}validateLicense(t){return this.licenseRestService.validateLicense(t).then(t=>er(t))}isTrackableLicense(){const t=this.licenseContextService.getLicenseSnapshot(),e=t?.typeOfUse?.toLowerCase()||"",r=t?.productType;return!t?.present||this.trackableProductTypes.some(t=>t===r)||this.trackableTypesOfUse.includes(e)}}class nr extends Ct{PRODUCT_INFO="productInfo";updateProductInfo(t){this.updateContextProperty(this.PRODUCT_INFO,t)}onProductInfoChanged(t){return this.subscribe(this.PRODUCT_INFO,t)}getProductInfo(){return this.getContextPropertyValue(this.PRODUCT_INFO)}}class ar extends _e{VERSION_URL="rest/info/version";getProductInfoLocal(){return this.get(`${this.VERSION_URL}?local=1`)}}class or{productInfoRestService=xt(ar);async getProductInfoLocal(){const t=await this.productInfoRestService.getProductInfoLocal();return new ft({workbench:(e=t).Workbench||"",productType:e.productType||"",productVersion:e.productVersion||"",sesame:e.sesame||"",connectors:e.connectors||""});var e}}class hr extends Ct{RESTRICTED_PAGES="restrictedPages";SECURITY_CONFIG="securityConfig";AUTHENTICATED_USER="authenticatedUser";JSON_WEB_KEYS_SET="jsonWebKeysSet";IS_LOGGED_IN="isLoggedIn";getRestrictedPages(){return this.getContextPropertyValue(this.RESTRICTED_PAGES)||new lt}updateRestrictedPages(t){this.updateContextProperty(this.RESTRICTED_PAGES,t)}onRestrictedPagesChanged(t){return this.subscribe(this.RESTRICTED_PAGES,t)}updateSecurityConfig(t){this.updateContextProperty(this.SECURITY_CONFIG,t)}onSecurityConfigChanged(t){return this.subscribe(this.SECURITY_CONFIG,t)}getSecurityConfig(){return this.getContextPropertyValue(this.SECURITY_CONFIG)}updateAuthenticatedUser(t){this.updateContextProperty(this.AUTHENTICATED_USER,t)}onAuthenticatedUserChanged(t){return this.subscribe(this.AUTHENTICATED_USER,t)}getAuthenticatedUser(){return this.getContextPropertyValue(this.AUTHENTICATED_USER)}updateJsonWebKeysSet(t){this.updateContextProperty(this.JSON_WEB_KEYS_SET,t)}getJsonWebKeysSet(){return this.getContextPropertyValue(this.JSON_WEB_KEYS_SET)}updateIsLoggedIn(t){this.updateContextProperty(this.IS_LOGGED_IN,t)}getIsLoggedIn(){return this.getContextPropertyValue(this.IS_LOGGED_IN)}onUserLoginStatusChanged(t){return this.subscribe(this.IS_LOGGED_IN,t)}}class ur extends Ae{accessToken="access_token";idToken="id_token";refreshToken="refresh_token";tokenType="token_type";pkceState="pkce_state";pkceCodeVerifier="pkce_code_verifier";nonce="nonce";returnUrl="return_url";NAMESPACE="auth.openid";set(t,e){this.storeValue(t,e)}setAccessToken(t){this.set(this.accessToken,t)}getAccessToken(){return this.get(this.accessToken)}clearAccessToken(){this.remove(this.accessToken)}setIdToken(t){this.set(this.idToken,t)}getIdToken(){return this.get(this.idToken)}clearIdToken(){this.remove(this.idToken)}setRefreshToken(t){this.set(this.refreshToken,t)}getRefreshToken(){return this.get(this.refreshToken)}clearRefreshToken(){this.remove(this.refreshToken)}setTokenType(t){this.set(this.tokenType,t)}getTokenType(){return this.get(this.tokenType)}clearTokenType(){this.remove(this.tokenType)}setPkceState(t){this.set(this.pkceState,t)}getPkceState(){return this.get(this.pkceState)}clearPkceState(){this.remove(this.pkceState)}setPkceCodeVerifier(t){this.set(this.pkceCodeVerifier,t)}getPkceCodeVerifier(){return this.get(this.pkceCodeVerifier)}clearPkceCodeVerifier(){this.remove(this.pkceCodeVerifier)}setNonce(t){this.set(this.nonce,t)}getNonce(){return this.get(this.nonce)}clearNonce(){this.remove(this.nonce)}setReturnUrl(t){this.set(this.returnUrl,t)}getReturnUrl(){return this.get(this.returnUrl)}clearReturnUrl(){this.remove(this.returnUrl)}clearTokens(){this.clearAccessToken(),this.clearIdToken(),this.clearRefreshToken()}}var cr=r(355);class lr extends Error{constructor(t){super(),this.text=t}get message(){return`${this.constructor.name}: ${this.text}`}}class gr extends lr{}class pr extends gr{constructor(){super("Invalid JWT token")}}let dr=function(t){return t.ACCESS="access",t.ID="id",t.REFRESH="refresh",t}({});class fr{logger=Tt.logger;openidStorageService=xt(ur);securityContextService=xt(hr);REFRESH_TOKEN_TOLERANCE=5e3;hasValidIdToken(t){return this.getTokenByType(dr.ID)?this.verifyToken(dr.ID,t)?(this.logger.debug("OpenID: valid id token found"),!0):(this.logger.debug("OpenID: stale id token"),!1):(this.logger.debug("OpenID: no id token"),!1)}hasValidRefreshToken(){const t=this.getTokenByType(dr.REFRESH);if(!t)return this.logger.debug("OpenID: no refresh token"),!1;let e;try{e=this.getTokenPayload(t)}catch{return!0}return!(e.nbf&&1e3*e.nbf-Date.now()>this.REFRESH_TOKEN_TOLERANCE||e.exp&&Date.now()-1e3*e.exp>this.REFRESH_TOKEN_TOLERANCE||!e.iat)}saveTokens(t,e){t.refresh_token?this.openidStorageService.setRefreshToken(t.refresh_token):this.openidStorageService.clearRefreshToken(),t.access_token?this.openidStorageService.setAccessToken(t.access_token):this.openidStorageService.clearAccessToken(),t.id_token?this.openidStorageService.setIdToken(t.id_token):this.openidStorageService.clearIdToken(),this.openidStorageService.setTokenType(e.tokenType),this.logger.debug("OpenID: saved tokens"),this.openidStorageService.clearPkceState(),this.openidStorageService.clearPkceCodeVerifier()}authHeaderGraphDB(){return this.openidStorageService.getTokenType().getValue()===dr.ID?"Bearer "+this.getTokenByType(dr.ID):"Bearer "+this.getTokenByType(dr.ACCESS)}getTokenHeader(t){try{const e=cr.pj.jws.JWS.readSafeJSONString((0,cr.cV)(t.split(".")[0]));if(e)return e}catch(t){throw this.logger.error("OpenID: token header decode failed",t),new pr}}getTokenPayload(t){try{const e=cr.pj.jws.JWS.readSafeJSONString((0,cr.cV)(t.split(".")[1]));if(e)return e}catch(t){throw this.logger.debug("Token payload decode error",t),new pr}}verifyToken(t,e){const r=this.getTokenByType(t);if(!r)return!1;let i;try{i=this.getTokenHeader(r)}catch{return!1}if(!i.kid)return t!==dr.ID?i.error?(this.logger.debug(`OpenID: token ${t} is not a JWT token (token considered valid)`),!0):(this.logger.debug(`OpenID: invalid token ${t} (token is empty)`),!1):(this.logger.debug("OpenID: invalid token id (not a JWT token)"),!1);const s=this.securityContextService.getJsonWebKeysSet()?.[i.kid];if(!s)return this.logger.debug("OpenID: no key to verify JWT token (token considered invalid)"),!1;const n=cr.ym.getKey(s),a={alg:[i.alg],iss:[e.issuer]};return"id"===t?(a.aud=[e.clientId,e.issuer],a.nonce=[this.openidStorageService.getNonce().getValue()||""]):"access"===t&&(a.aud=[e.tokenAudience],a.iss=[e.tokenIssuer]),cr.pj.jws.JWS.verifyJWT(r,n,a)}clearTokens(){this.openidStorageService.clearTokens()}getTokenByType(t){return t===dr.ID?this.openidStorageService.getIdToken().getValue():t===dr.ACCESS?this.openidStorageService.getAccessToken().getValue():t===dr.REFRESH?this.openidStorageService.getRefreshToken().getValue():null}}class yr{static pkceChallengeFromVerifier(t){const e=new cr.pj.crypto.MessageDigest({alg:"sha256",prov:"cryptojs"});return(0,cr.wV)(e.digestString(t))}static parseQueryString(t){const e={access_token:null,code:null,id_token:null,state:null};let r;if(t){const t=c.getLocationHash().substring(1);r=new URLSearchParams(t)}else r=new URLSearchParams(c.getLocationQueryParams());return 0===r.size||Object.keys(e).forEach(t=>{const i=r.get(t);i&&(e[t]=decodeURIComponent(i))}),e}}class vr extends gr{constructor(t){super(`Invalid OpenID authentication flow: ${t}`)}}class mr extends gr{constructor(){super("Missing authorization code")}}let Sr=function(t){return t.CODE="code",t.CODE_NO_PKCE="code_no_pkce",t.IMPLICIT="implicit",t}({}),Er=function(t){return t.CODE="code",t.TOKEN="token id_token",t}({});class xr{items=[];enqueue(t){this.items.push(t)}dequeue(){return this.items.shift()}dequeueAll(){const t=[...this.items];return this.items=[],t}peek(){return this.items[0]}peekAll(){return[...this.items]}isEmpty(){return 0===this.items.length}size(){return this.items.length}}class Ar{notificationAddedCallbackFunctions=[];notifications=new xr;addNotification(t){this.notifications.enqueue(t),this.notifyAllNotificationAdded(t)}removeAllNotifications(){return this.notifications.dequeueAll()}onNotificationAdded(t){return t&&!this.notifications.isEmpty()&&this.notifyNotificationAdded(t),this.notificationAddedCallbackFunctions.push(t),()=>{this.notificationAddedCallbackFunctions=this.notificationAddedCallbackFunctions.filter(e=>e!==t)}}notifyNotificationAdded(t){this.notifications.peekAll().forEach(e=>t(e))}notifyAllNotificationAdded(t){for(const e of this.notificationAddedCallbackFunctions)e(t)}}function wr(t){xt(Ar).addNotification(t)}class br{logger=Tt.logger;tokenUtils=xt(fr);openidStorageService=xt(ur);async handleAuthorizationCode(t,e,r){if(!e.code)throw this.logger.error("OpenID: Missing authorization code"),new mr;const i=`${E()}`;if(t.authFlow===Sr.CODE)await this.handlePkceFlow(e,i,r);else{if(t.authFlow!==Sr.CODE_NO_PKCE)throw this.logger.error("OpenID: Invalid OpenID authentication flow"),new vr(t.authFlow);await this.handleCodeNoPkceFlow(e.code,i,r)}return!0}async handleImplicitFlow(t,e){this.tokenUtils.saveTokens(e,t)}checkExistingAuthentication(t){const e=this.tokenUtils.hasValidIdToken(t),r=this.tokenUtils.hasValidRefreshToken();return e||r}storeCodeFlowData(t){this.openidStorageService.setPkceState(t),this.openidStorageService.setPkceCodeVerifier(Qt.generateRandomString(28))}getCodeChallengeForCodeFlow(){const t=this.openidStorageService.getPkceCodeVerifier().getValue();if(!t)throw new gr("Missing PKCE code verifier");return yr.pkceChallengeFromVerifier(t)}async handlePkceFlow(t,e,r){const i=this.openidStorageService.getPkceState().getValue();if(i!==t.state)throw this.logger.debug(`OpenID: PKCE state mismatch ${i} != ${t.state}`),wr(ve.error("openid.errors.invalid_pkce_state").withTitle("openid.errors.title").withParameters({[me.SHOULD_TOAST]:!0})),new gr(`PKCE state mismatch ${i} != ${t.state}`);if(!t.code)throw new mr;const s=this.openidStorageService.getPkceCodeVerifier().getValue();await r(t.code,e,s)}async handleCodeNoPkceFlow(t,e,r){await r(t,e)}}class Cr extends gr{constructor(){super("OpenID security configuration is not available")}}class Fr extends _e{securityContextService=xt(hr);OAUTH_IDENTITY_DOMAIN_NAME_HEADER="X-OAuth-Identity-Domain-Name";getJSONWebKeySet(){return this.get(this.getJWKSEndpoint(),{headers:this.getDomainHeaders()})}refreshToken(t){const e={grant_type:"refresh_token",client_id:this.getClientId(),refresh_token:t},r={...this.getDomainHeaders(),"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},i=this.transformURLEncodedRequest(e);return this.post(this.getTokensEndpoint(),{body:i,headers:r})}getTokens(t,e,r){const i={grant_type:"authorization_code",client_id:this.getClientId(),redirect_uri:t,code:e};r&&(i.code_verifier=r);const s={...this.getDomainHeaders(),"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},n=this.transformURLEncodedRequest(i);return this.post(this.getTokensEndpoint(),{body:n,headers:s})}transformURLEncodedRequest(t){const e=new URLSearchParams;return Object.entries(t).forEach(([t,r])=>{e.append(t,r)}),e}getClientId(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(t)return t.clientId;throw new Cr}getJWKSEndpoint(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(t)return t.openIdKeysUri;throw new Cr}getTokensEndpoint(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(t)return t.openIdTokenUrl;throw new Cr}getDomainHeaders(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;return t?.oracleDomain?{[this.OAUTH_IDENTITY_DOMAIN_NAME_HEADER]:t.oracleDomain}:{}}}class Ir{securityContextService=xt(hr);buildLoginUrl(t,e,r){const i=this.getResponseType(),s=[...this.buildBaseParameters(i,r),...this.buildFlowSpecificParameters(t,e),...this.buildAdditionalParameters()];return`${this.getOpenIdConfig().oidcAuthorizationEndpoint}?${s.join("&")}`}buildLogoutUrl(t){const e=this.getOpenIdConfig(),r=e.clientId;return`${e.openIdEndSessionUrl}?client_id=${encodeURIComponent(r)}&post_logout_redirect_uri=${encodeURIComponent(t)}`}getOpenIdConfig(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(!t)throw new Cr;return t}getResponseType(){const t=this.getOpenIdConfig().authFlow;if(t===Sr.CODE||t===Sr.CODE_NO_PKCE)return Er.CODE;if(t===Sr.IMPLICIT)return Er.TOKEN;throw new vr(t)}buildBaseParameters(t,e){return[`response_type=${encodeURIComponent(t)}`,`scope=${encodeURIComponent(this.getScope())}`,`client_id=${encodeURIComponent(this.getOpenIdConfig().clientId)}`,`redirect_uri=${encodeURIComponent(e)}`]}buildFlowSpecificParameters(t,e){const r=this.getOpenIdConfig().authFlow,i=[];return r===Sr.CODE?i.push(`state=${encodeURIComponent(t)}`,`code_challenge=${encodeURIComponent(e)}`,"code_challenge_method=S256"):r===Sr.IMPLICIT&&i.push(`nonce=${encodeURIComponent(t)}`),i}buildAdditionalParameters(){const t=this.getOpenIdConfig(),e=[];return t.oracleDomain&&e.push(`domain=${encodeURIComponent(t.oracleDomain)}`),t.authorizeParameters&&e.push(t.authorizeParameters),e}getScope(){const t=["openid"];this.getOpenIdConfig().supportsOfflineAccess&&t.push("offline_access");const e=this.getOpenIdConfig().extraScopes;return e&&t.push(e),t.join(" ")}}class Rr{DEFAULT_REFRESH_CONFIGURATION={refreshAheadMs:6e4,minDelayMs:1e3};logger=Tt.logger;tokenUtils=xt(fr);openidStorageService=xt(ur);async setupTokensRefresh(t){const e=this.openidStorageService.getRefreshToken().getValue();if(!e||!this.shouldSetupRefresh(e))return this.clearRefreshTimer(),void this.logger.debug("OpenID: no valid refresh token");const r=this.openidStorageService.getAccessToken().getValue(),i=this.calculateRefreshDelay(r);i<this.DEFAULT_REFRESH_CONFIGURATION.minDelayMs?(this.logger.debug("OpenID: tokens need refresh now, "+i),await this.executeImmediateRefresh(e,t)):(this.logger.debug("OpenID: scheduling token refresh in",i/1e3,"seconds"),this.scheduleTokenRefresh(e,i,t))}clearRefreshTimer(){this.refreshTokensTimer&&(c.getWindow().clearTimeout(this.refreshTokensTimer),delete this.refreshTokensTimer)}shouldSetupRefresh(t){return!(!t||!this.tokenUtils.hasValidRefreshToken())}calculateRefreshDelay(t){let e;try{e=this.tokenUtils.getTokenPayload(t)}catch{return 0}return!e.exp||e.exp<=0?0:1e3*e.exp-Date.now()-this.DEFAULT_REFRESH_CONFIGURATION.refreshAheadMs}async executeImmediateRefresh(t,e){this.clearRefreshTimer(),this.logger.debug("OpenID: tokens will refresh now"),await e(t)}scheduleTokenRefresh(t,e,r){this.clearRefreshTimer(),this.refreshTokensTimer=c.getWindow().setTimeout(async()=>{this.logger.debug("OpenID: tokens will refresh now, "+e),await r(t)},e)}}class Tr extends Ae{jwtKey="jwt";authenticatedKey="authenticated";NAMESPACE="auth";set(t,e){this.storeValue(t,e)}getAuthToken(){return this.get(this.jwtKey)}setAuthenticated(t){this.storeValue(this.authenticatedKey,t?.toString()||"")}isAuthenticated(){return"true"===this.get(this.authenticatedKey).getValue()}setAuthToken(t){this.setAuthenticated(!0),this.set(this.jwtKey,t)}clearAuthToken(){this.remove(this.jwtKey)}isGDBorOpenIDToken(){const t=this.getAuthToken().getValue();return!(!t||!t.startsWith("GDB")&&!t.startsWith("Bearer"))}}class Pr{constructor(t){this.notify=t}}class Dr{eventSubscribers=new Map;emit(t){const e=this.eventSubscribers.get(t.NAME);e&&e.forEach(e=>{e.notify(n.deepCopy(t.payload))})}subscribe(t,e){const r=new Pr(e),i=this.eventSubscribers.get(t);return i?i.push(r):this.eventSubscribers.set(t,[r]),()=>this.unsubscribe(t,r)}unsubscribe(t,e){const r=this.eventSubscribers.get(t);if(r){const i=r.indexOf(e);-1!==i&&r.splice(i,1),0===r.length&&this.eventSubscribers.delete(t)}}}class Nr{logger=Tt.logger;openIdRestService=xt(Fr);openidStorageService=xt(ur);securityContextService=xt(hr);tokenUtils=xt(fr);authenticationStorageService=xt(Tr);authFlowHandler=xt(br);tokenRefreshManager=xt(Rr);openIdUrlBuilder=xt(Ir);getJSONWebKeySet(){return this.openIdRestService.getJSONWebKeySet()}getTokens(t,e,r){return this.openIdRestService.getTokens(t,e,r)}async refreshTokens(t){const e=this.getOpenIdConfig();try{const r=await this.openIdRestService.refreshToken(t);this.logger.debug("OpenID: refreshed tokens"),this.tokenUtils.saveTokens(r,e),this.authenticationStorageService.setAuthToken(this.tokenUtils.authHeaderGraphDB()),await this.setupTokensRefresh()}catch(t){this.logger.debug("OpenID: could not refresh tokens",t);let e="unknown error";t instanceof Pe&&(e=t.data?.error_description??"unknown error"),wr(ve.error("openid.errors.cannot_refresh_token").withTitle("openid.errors.title").withParameters({error:e,[me.SHOULD_TOAST]:!0})),this.softLogout(),xt(Dr).emit(new $)}}async initializeOpenId(){const t=this.getOpenIdConfig();return await this.initializeJsonWebKeySet(),this.authFlowHandler.checkExistingAuthentication(t)?(await this.setupTokensRefresh(),!0):this.handleAuthenticationFlow()}async initializeJsonWebKeySet(){const t=await this.getJSONWebKeySet(),e=this.buildKeySet(t.keys);this.securityContextService.updateJsonWebKeysSet(e)}setupCodeFlow(t,e){this.authFlowHandler.storeCodeFlowData(t);const r=this.authFlowHandler.getCodeChallengeForCodeFlow(),i=this.getLoginUrl(t,r,e);this.redirectToUrl(i)}setupCodeNoPkceFlow(t,e){this.openidStorageService.clearPkceCodeVerifier();const r=this.getLoginUrl(t,"",e);this.redirectToUrl(r)}setupImplicitFlow(t,e){this.openidStorageService.setNonce(t);const r=this.getLoginUrl(t,"",e);this.redirectToUrl(r)}async setupTokensRefresh(){await this.tokenRefreshManager.setupTokensRefresh(this.refreshTokens.bind(this))}clearAuthentication(){this.authenticationStorageService.clearAuthToken(),this.tokenUtils.clearTokens(),this.tokenRefreshManager.clearRefreshTimer()}logout(t=!1){t?this.hardLogout(E()):this.softLogout()}getOpenIdConfig(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(!t)throw new Cr;return t}buildKeySet(t){const e={};return t.forEach(t=>{e[t.kid]=t}),e}async handleAuthenticationFlow(){const t=this.getOpenIdConfig();this.clearAuthentication();const e=t.authFlow===Sr.IMPLICIT,r=yr.parseQueryString(e);return r.code?this.authFlowHandler.handleAuthorizationCode(t,r,this.exchangeTokensForCode.bind(this)):!!r.id_token&&(await this.authFlowHandler.handleImplicitFlow(t,r),await this.setupTokensRefresh(),!0)}async exchangeTokensForCode(t,e,r){const i=this.getOpenIdConfig();try{const s=await this.getTokens(e,t,r);this.logger.debug("OpenID: successfully retrieved tokens"),this.tokenUtils.saveTokens(s,i),await this.setupTokensRefresh()}catch(t){throw this.logger.error("OpenID: Cannot retrieve token after login",{error:t}),wr(ve.error("openid.errors.cannot_retrieve_token").withTitle("openid.errors.title").withParameters({error:t instanceof Error?t.message:String(t),[me.SHOULD_TOAST]:!0})),new gr("Cannot retrieve token after login")}}softLogout(){this.clearAuthentication()}hardLogout(t){this.softLogout();const e=this.getLogoutUrl(t);this.redirectToUrl(e)}redirectToUrl(t){c.setLocationHref(t)}getLoginUrl(t,e,r){return this.openIdUrlBuilder.buildLoginUrl(t,e,r)}getLogoutUrl(t){return this.openIdUrlBuilder.buildLogoutUrl(t)}}let Or=function(t){return t.GDB_TOKEN="GDB_TOKEN",t.OPENID="OPENID",t.EXTERNAL="EXTERNAL",t.NO_SECURITY="NO_SECURITY",t}({});class _r{logger=Tt.logger;securityService=xt(Gr);securityContextService=xt(hr);type=Or.NO_SECURITY;initialize(){return this.fetchAuthenticatedUser().then(t=>(this.securityContextService.updateAuthenticatedUser(t),!0)).catch(t=>(this.logger.error("Could not load authenticated user",t),!1))}fetchAuthenticatedUser(){return this.securityService.getAuthenticatedAdminUser()}login(){return this.fetchAuthenticatedUser()}logout(){return Promise.resolve()}isAuthenticated(){return!!this.securityContextService.getAuthenticatedUser()}isExternal(){return!1}}class Br extends gr{constructor(){super("OpenID user has no access rights")}}class Hr{logger=Tt.logger;securityService=xt(Gr);authenticationStorageService=xt(Tr);authenticationService=xt(ii);securityContextService=xt(hr);openIdService=xt(Nr);openidStorageService=xt(ur);tokenUtils=xt(fr);type=Or.OPENID;constructor(){this.setupConfigurationListener()}async initialize(){this.loadSecurityConfiguration(),this.validateConfiguration();try{const t=await this.openIdService.initializeOpenId();t&&await this.handleSuccessfulAuthentication();const e=this.openidStorageService.getReturnUrl().getValue();return this.openidStorageService.clearReturnUrl(),t&&e&&f(e),t}catch(t){return this.handleAuthenticationError(t),!1}}fetchAuthenticatedUser(){return this.securityService.getAuthenticatedUser()}login(){this.validateConfiguration();const t=this.getReturnUrl(),e=Qt.generateRandomString(28),r=this.openIdSecurityConfig.authFlow;return this.executeAuthFlow(r,e,t),new Promise(()=>{})}logout(){return this.openIdService.logout(),Promise.resolve()}isAuthenticated(){const t=this.authenticationStorageService.getAuthToken().getValue();return!this.authenticationService.isSecurityEnabled()||null!==t}isExternal(){return!1}setupConfigurationListener(){this.securityContextService.onSecurityConfigChanged(t=>{t&&(this.openIdSecurityConfig=t.openidSecurityConfig)})}loadSecurityConfiguration(){this.openIdSecurityConfig=this.securityContextService.getSecurityConfig()?.openidSecurityConfig}validateConfiguration(){if(!this.openIdSecurityConfig)throw new Cr}async handleSuccessfulAuthentication(){this.logger.debug("OpenID: authentication initialized"),this.authenticationStorageService.setAuthToken(this.tokenUtils.authHeaderGraphDB());try{await this.loadAndSetAuthenticatedUser()}catch(t){throw this.logger.debug("Could not load authenticated user",t),wr(ve.error("openid.errors.user_no_access").withTitle("openid.errors.title").withParameters({[me.SHOULD_TOAST]:!0})),new Br}}async loadAndSetAuthenticatedUser(){const t=await this.fetchAuthenticatedUser();t&&this.securityContextService.updateAuthenticatedUser(t)}handleAuthenticationError(t){this.authenticationStorageService.clearAuthToken(),this.logger.debug("OpenID: not logged or login error"),this.logger.error("Could not initialize OpenID authentication",t),this.openIdService.clearAuthentication()}getReturnUrl(){return`${E()}`}executeAuthFlow(t,e,r){switch(t){case Sr.CODE:this.openIdService.setupCodeFlow(e,r);break;case Sr.CODE_NO_PKCE:this.openIdService.setupCodeNoPkceFlow(e,r);break;case Sr.IMPLICIT:this.openIdService.setupImplicitFlow(e,r);break;default:throw this.logger.debug(`OpenID: Invalid OpenID authentication flow: ${t}`),wr(ve.error("openid.errors.unknown_flow").withTitle("openid.errors.title").withParameters({authFlow:t,[me.SHOULD_TOAST]:!0})),new vr(t)}}}class Lr extends lr{constructor(){super("Missing token in authentication header")}}const kr=t=>new nt({username:t.username,password:t.password,authorities:new et(t.authorities),appSettings:new rt(t.appSettings),external:t.external});class Ur extends _e{SECURITY_ENDPOINT="rest/security";LOGIN_ENDPOINT="rest/login";SECURITY_USER_ENDPOINT=`${this.SECURITY_ENDPOINT}/users`;SECURITY_FREE_ACCESS_ENDPOINT=`${this.SECURITY_ENDPOINT}/free-access`;loginGdbToken(t,e){return this.post(this.LOGIN_ENDPOINT,{body:{username:t,password:e},responseType:"response"})}getSecurityConfig(){return this.get(`${this.SECURITY_ENDPOINT}/all`)}getAuthenticatedUser(){return this.get(`${this.SECURITY_ENDPOINT}/authenticated-user`)}getAdminUser(){return this.get(`${this.SECURITY_USER_ENDPOINT}/admin`)}getFreeAccess(){return this.get(this.SECURITY_FREE_ACCESS_ENDPOINT)}setFreeAccess(t){return this.post(this.SECURITY_FREE_ACCESS_ENDPOINT,{body:t})}}class Vr extends _e{SECURITY_ENDPOINT="rest/security";SECURITY_USER_ENDPOINT=`${this.SECURITY_ENDPOINT}/users`;getUser(t){return this.get(`${this.SECURITY_USER_ENDPOINT}/${this.encodeURIComponentStrict(t)}`)}getUsers(){return this.get(`${this.SECURITY_USER_ENDPOINT}`)}createUser(t,e){return this.post(`${this.SECURITY_USER_ENDPOINT}/${this.encodeURIComponentStrict(t)}`,{body:e})}updateUser(t,e){return this.put(`${this.SECURITY_USER_ENDPOINT}/${this.encodeURIComponentStrict(t)}`,{body:e})}updateCurrentUser(t,e){return this.patch(`${this.SECURITY_USER_ENDPOINT}/${this.encodeURIComponentStrict(t)}`,{body:e})}deleteUser(t){return this.delete(`${this.SECURITY_USER_ENDPOINT}/${this.encodeURIComponentStrict(t)}`)}}class jr{constructor(t){this.password=t?.password,this.grantedAuthorities=t?.grantedAuthorities??[],this.appSettings=t?.appSettings??{DEFAULT_SAMEAS:!0,DEFAULT_INFERENCE:!0,EXECUTE_COUNT:!0,IGNORE_SHARED_QUERIES:!1,DEFAULT_VIS_GRAPH_SCHEMA:!0}}}const Kr=t=>new jr({password:t.password,grantedAuthorities:t.authorities.toGraphdbAuthoritiesModel(),appSettings:t.appSettings.toJSON()}),Mr=t=>new st({username:t.username,authorities:new et(t.grantedAuthorities),appSettings:new rt({EXECUTE_COUNT:t.appSettings.EXECUTE_COUNT,DEFAULT_INFERENCE:t.appSettings.DEFAULT_INFERENCE,DEFAULT_SAMEAS:t.appSettings.DEFAULT_SAMEAS,DEFAULT_VIS_GRAPH_SCHEMA:t.appSettings.DEFAULT_VIS_GRAPH_SCHEMA,IGNORE_SHARED_QUERIES:t.appSettings.IGNORE_SHARED_QUERIES,COOKIE_CONSENT:t.appSettings.COOKIE_CONSENT?new Bt(t.appSettings.COOKIE_CONSENT):void 0}),dateCreated:new Date(t.dateCreated),gptThreads:t.gptThreads,external:t.external});class qr{static ADMIN_USERNAME="admin";usersRestService=xt(Vr);getUser(t){return this.usersRestService.getUser(t).then(t=>Mr(t))}getUsers(){return this.usersRestService.getUsers().then(t=>t.map(t=>Mr(t)))}getAdminUser(){return this.usersRestService.getUser(qr.ADMIN_USERNAME).then(t=>Mr(t))}createUser(t){const e=Kr(t);return this.usersRestService.createUser(t.username,e)}updateUser(t){const e=Kr(t);return this.usersRestService.updateUser(t.username,e)}deleteUser(t){return this.usersRestService.deleteUser(t)}updateCurrentUser(t){const e=Kr(t);return this.usersRestService.updateCurrentUser(t.username,e)}}class Gr{securityRestService=xt(Ur);securityContextService=xt(hr);usersService=xt(qr);updateAuthenticatedUser(t){return this.usersService.updateCurrentUser(t)}getSecurityConfig(){return this.securityRestService.getSecurityConfig().then(t=>new ct(t))}getFreeAccess(){return this.securityRestService.getFreeAccess().then(function(t){return ut(t)})}setFreeAccess(t,e){const r={enabled:t};if(t){if(!e)throw new Error("Free access settings must be provided when enabling free access");r.authorities=Q(e?.authorities),r.appSettings={...e?.appSettings}}return this.securityRestService.setFreeAccess(r).then(()=>this.getSecurityConfig()).then(t=>{this.securityContextService.updateSecurityConfig(t)})}getAuthenticatedUser(){return this.securityRestService.getAuthenticatedUser().then(t=>kr(t))}getAuthenticatedAdminUser(){return this.usersService.getAdminUser().then(t=>nt.fromUser(t))}isPasswordLoginEnabled(){return this.securityContextService.getSecurityConfig()?.passwordLoginEnabled??!1}isOpenIDEnabled(){return this.securityContextService.getSecurityConfig()?.openIdEnabled??!1}loginGdbToken(t,e){return this.securityRestService.loginGdbToken(t,e)}}class Wr{securityService=xt(Gr);logger=Tt.logger;authStorageService=xt(Tr);fetchAuthenticatedUser(){return this.securityService.getAuthenticatedUser()}async login(t){const{username:e,password:r}=t,i=await this.securityService.loginGdbToken(e,r),s=this.getAuthenticationHeader(i),n=kr(i.data);if(!s)throw new Lr;return this.authStorageService.setAuthToken(s),n}getAuthenticationHeader(t){return t.headers.authorization}}class $r extends Wr{securityContextService=xt(hr);type=Or.GDB_TOKEN;initialize(){const t=!!this.authStorageService.getAuthToken().getValue();return t?this.isCurrentRouteLogin()?Promise.resolve(t):Promise.resolve(!!this.securityContextService.getAuthenticatedUser()):Promise.resolve(!1)}fetchAuthenticatedUser(){return this.securityService.getAuthenticatedUser()}logout(){return this.authStorageService.clearAuthToken(),Promise.resolve()}isAuthenticated(){return null!==this.authStorageService.getAuthToken().getValue()}isExternal(){return!1}isCurrentRouteLogin(){return"login"===A()}}class zr extends lr{constructor(){super()}}class Yr extends Wr{securityContextService=xt(hr);type=Or.EXTERNAL;initialize(){return Promise.resolve(!0)}isAuthenticated(){return!!this.securityContextService.getAuthenticatedUser()}logout(){throw new zr}isExternal(){return!0}}class Xr{securityContextService=xt(hr);authStorageService=xt(Tr);resolveStrategy(t){return this.authStrategy=this._resolveStrategy(t),this.authStrategy}getAuthStrategy(){return this.authStrategy}_resolveStrategy(t){return t.isEnabled()?t.openIdEnabled?new Hr:this.securityContextService.getAuthenticatedUser()&&!this.authStorageService.isGDBorOpenIDToken()?new Yr:new $r:new _r}}class Jr{constructor(t,e){this.setRegex(t),this.setRouteParams(e)}getRegex(){return this.regex}setRegex(t){return this.regex=t,this}getRouteParams(){return this.routeParams}setRouteParams(t){return this.routeParams=t,this}}class Qr{constructor(t){this._url=t.url,this._module=t.module,this._path=t.path,this._chunk=t.chunk,this._controller=t.controller,this._templateUrl=t.templateUrl,this._title=t.title,this._reloadOnSearch=t.reloadOnSearch,this._helpInfo=t.helpInfo,this._documentationUrl=t.documentationUrl,this._allowAuthorities=t.allowAuthorities}get url(){return this._url}set url(t){this._url=t}get module(){return this._module}set module(t){this._module=t}get path(){return this._path}set path(t){this._path=t}get chunk(){return this._chunk}set chunk(t){this._chunk=t}get controller(){return this._controller}set controller(t){this._controller=t}get templateUrl(){return this._templateUrl}set templateUrl(t){this._templateUrl=t}get title(){return this._title}set title(t){this._title=t}get reloadOnSearch(){return this._reloadOnSearch}set reloadOnSearch(t){this._reloadOnSearch=t}get helpInfo(){return this._helpInfo}set helpInfo(t){this._helpInfo=t}get documentationUrl(){return this._documentationUrl}set documentationUrl(t){this._documentationUrl=t}get allowAuthorities(){return this._allowAuthorities}set allowAuthorities(t){this._allowAuthorities=t}}class Zr{routeConfig=c.getWindow().PluginRegistry.get(de.ROUTE);getActiveRoute(t=S()){const e=this.routeConfig.find(e=>this.routeToRegex(e.url).getRegex().test(t));return e?new Qr(e):void 0}routeToRegex(t){const e=[],r=t.replace(/([().])/g,"\\$1").replace(/(\/)?:(\w+)(\*\?|[?*])?/g,function(t,r,i,s){const n="?"===s||"*?"===s,a="*"===s||"*?"===s;return e.push(i),r=r||"",(n?"(?:"+r:r+"(?:")+(a?"(.+?)":"([^/]+)")+(n?"?)?":")")}).replace(/([/$*])/g,"\\$1");return new Jr(new RegExp("^"+r+"(?:[?#]|$)"),new F(e))}}class ti{repositoryService=xt(qe);securityContextService=xt(hr);repositoryStorageService=xt(Ge);repositoryContextService=xt(We);hasFreeAccess(){const t=this.getSecurityConfig();return!(!t?.isEnabled()||!t?.freeAccess?.enabled)}initializeFreeAccess(){const t=this.getSecurityConfig();if(t?.isEnabled()&&t?.isFreeAccessEnabled()){const e=(new nt).setAuthorities(t.freeAccess.authorities).setAppSettings(t.freeAccess.appSettings);this.securityContextService.updateAuthenticatedUser(e)}}initializeOverrideAuth(){const t=this.getSecurityConfig();if(!t?.isEnabled()&&t?.hasOverrideAuth()){const e=new nt;e.username="overrideauth",e.setAuthorities(t.overrideAuth.authorities),e.setAppSettings(t.overrideAuth.appSettings),this.securityContextService.updateAuthenticatedUser(e)}}isAdmin(){return this.hasRole(X.ROLE_ADMIN)}isRepoManager(){return this.hasRole(X.ROLE_REPO_MANAGER)}hasRole(t){const e=this.getSecurityConfig(),r=this.getAuthenticatedUser();if(!t||!e?.isEnabled()&&!e?.hasOverrideAuth())return!0;if(!(Object.keys(r||{}).length>0))return!1;const i=X.IS_AUTHENTICATED_FULLY===t,s=!!r?.authorities.hasAuthority(t);return i||s}canReadRepo(t){if(!t||""===t.id)return!1;const e=this.getSecurityConfig(),r=this.getAuthenticatedUser();return!e?.isEnabled()||!!r&&(!!this.isAdminOrRepoManager()||!this.repositoryService.isSystemRepository(t)&&this.hasBaseRights(gt.READ,t))}canWriteRepo(t){if(!t||""===t.id)return!1;const e=this.getSecurityConfig(),r=this.getAuthenticatedUser();return!e?.isEnabled()&&!e?.hasOverrideAuth()||!!r&&(!!this.isAdminOrRepoManager()||!this.repositoryService.isSystemRepository(t)&&this.hasBaseRights(gt.WRITE,t))}canReadGqlRepo(t){return!(!t||""===t.id)&&this.hasGraphqlAuthority(gt.READ,t)}canWriteGqlRepo(t){return!(!t||""===t.id)&&this.hasGraphqlAuthority(gt.WRITE,t)}hasGqlRights(t){return this.canReadGqlRepo(t)||this.canWriteGqlRepo(t)}hasGraphqlRightsOverCurrentRepo(){const t=this.repositoryStorageService.getRepositoryReference(),e=this.repositoryContextService.findRepository(t);return this.canReadGqlRepo(e)||this.canWriteGqlRepo(e)}hasAuthority(){if(this.isAdminOrRepoManager())return!0;const t=xt(Zr).getActiveRoute();if(!t)return!1;if(!t.allowAuthorities)return!0;if(!xt(Ge).getRepositoryReference()?.id)return!0;const e=this.getAuthenticatedUser();if(!e)return!0;if(t.allowAuthorities.length){const r=this.resolveAuthorities(t.allowAuthorities);return r.some(t=>e.authorities.hasAuthority(t))||r.some(t=>e.authorities.hasWildcardAuthority(t))}return!0}updatePermissions(){const t=this.securityContextService.getRestrictedPages(),e=this.securityContextService.getAuthenticatedUser(),r=this.isAdmin(),i=c.getWindow().PluginRegistry.get(de.ROUTE),s=c.getWindow().PluginRegistry.get(de.MAIN_MENU);i.forEach(i=>{const n=s.flatMap(t=>t.items).filter(t=>t.role?.startsWith("ROLE_")).find(t=>i.url.includes(t.href));if(!n)return;const a=!r&&!e?.authorities.hasAuthority(n.role??"");t.setPageRestriction(i.url,a)}),this.securityContextService.updateRestrictedPages(t)}resolveAuthorities(t){if(!t)return[];const e=xt(Ge).getRepositoryReference();return e?.id?[...t.map(t=>t.replace("{repoId}",e.id)),...t.map(t=>t.replace("{repoId}","*"))]:t}getSecurityConfig(){return xt(hr).getSecurityConfig()}getAuthenticatedUser(){return xt(hr).getAuthenticatedUser()}hasBaseRights(t,e){const r=this.repositoryService.getLocationSpecificId(e),i=this.repositoryService.getCurrentRepoAuthority(t,r),s=this.repositoryService.getOverallRepoAuthority(t),n=this.getAuthenticatedUser();return!!(n?.authorities.hasAuthority(i)||n?.authorities.hasAuthority(s)||n?.authorities.hasWildcardAuthority(i))}hasGraphqlAuthority(t,e){const r=this.securityContextService.getAuthenticatedUser();if(!r)return!1;const i=this.repositoryService.getLocationSpecificId(e),s=this.repositoryService.getCurrentGqlRepoAuthority(t,i),n=this.repositoryService.getOverallGqlRepoAuthority(t);return r.authorities.hasAuthority(s)||r.authorities.hasAuthority(n)||r.authorities.hasWildcardAuthority(s,!0)}isAdminOrRepoManager(){return this.hasRole(X.ROLE_ADMIN)||this.hasRole(X.ROLE_REPO_MANAGER)}}class ei extends lr{constructor(){super("Authentication strategy not set")}}class ri extends Ct{PREVIOUS_ROUTE="previousRoute";RETURN_URL="returnUrl";updatePreviousRoute(t){this.updateContextProperty(this.PREVIOUS_ROUTE,t)}getPreviousRoute(){let t=this.getContextPropertyValue(this.PREVIOUS_ROUTE);return t?.endsWith("#")&&(t=t.slice(0,-1)),t}updateReturnUrl(t){this.updateContextProperty(this.RETURN_URL,t)}getReturnUrl(){return this.getContextPropertyValue(this.RETURN_URL)}clearReturnUrl(){this.updateContextProperty(this.RETURN_URL,void 0)}}class ii{eventService=xt(Dr);authStrategyResolver=xt(Xr);authorizationService=xt(ti);securityContextService=xt(hr);authenticationStorageService=xt(Tr);navigationContextService=xt(ri);isAuthenticationStrategySet(){return!!this.authStrategyResolver.getAuthStrategy()}getCurrentUser(){return this.getAuthenticationStrategy().fetchAuthenticatedUser()}login(t,e){return this.getAuthenticationStrategy().login({username:t,password:e}).then(t=>{this.securityContextService.updateIsLoggedIn(!0),this.securityContextService.updateAuthenticatedUser(t),this.updateStrategy(),this.eventService.emit(new z)})}logout(){const t=this.getAuthenticationStrategy();this.authenticationStorageService.setAuthenticated(!1);const e=S();return t.logout().then(()=>{m()||this.navigationContextService.updateReturnUrl(e),this.securityContextService.updateIsLoggedIn(!1),this.authorizationService.hasFreeAccess()?(this.authorizationService.initializeFreeAccess(),this.eventService.emit(new z)):(f("login"),this.eventService.emit(new $))})}isLoggedIn(){const t=this.securityContextService.getIsLoggedIn()??!1,e=xt(hr).getAuthenticatedUser();return this.isSecurityEnabled()&&t&&!!e}isAuthenticated(){return this.getAuthenticationStrategy().isAuthenticated()}isExternalUser(){return this.getAuthenticationStrategy().isExternal()}isSecurityEnabled(){return!!this.getSecurityConfig()?.isEnabled()}getSecurityConfig(){return xt(hr).getSecurityConfig()}updateStrategy(){const t=this.getSecurityConfig();t&&this.authStrategyResolver.resolveStrategy(t)}getAuthenticationStrategy(){const t=this.authStrategyResolver.getAuthStrategy();if(!t)throw new ei;return t}}class si extends lr{constructor(t){super(t)}}class ni{static DEFAULT_PATH="/";static MILLISECONDS_PER_DAY=864e5;path=ni.DEFAULT_PATH;constructor(t,e,r={}){this.key=encodeURIComponent(t),this.value=encodeURIComponent(e),this.setOptions(r)}setOptions(t){const{expiration:e,path:r,domain:i,secure:s,httpOnly:n,sameSite:a}=t;return e&&this.setExpiration(e),this.setPath(r),i&&this.setDomain(i),s&&this.setSecure(),n&&this.setHttpOnly(),a&&this.setSameSite(a),this}setExpiration(t){if(!Number.isFinite(t))throw new si(`Invalid expiration value: ${t}`);const e=new Date(b.now()+t*ni.MILLISECONDS_PER_DAY);return this.expires=e.toUTCString(),this}setPath(t){return this.path=t||ni.DEFAULT_PATH,this}setDomain(t){return this.domain=t,this}setSecure(){return this.secure=!0,this}setHttpOnly(){return this.httpOnly=!0,this}setSameSite(t){return this.sameSite=t,this}build(){let t=`${this.key}=${this.value}`;return this.expires&&(t+=`; expires=${this.expires}`),t+=`; path=${this.path}`,this.domain&&(t+=`; domain=${this.domain}`),this.secure&&(t+="; secure"),this.httpOnly&&(t+="; HttpOnly"),this.sameSite&&(t+=`; SameSite=${this.sameSite}`),t}}class ai{read(){return c.getDocument().cookie}write(t){c.getDocument().cookie=t}}class oi{constructor(t){this.store=t??new ai}get(t){return this.parseCookies()[t]}set(t,e,r={}){this.store.write(new ni(t,e,r).build())}remove(t){this.store.write(new ni(t,"",{expiration:-1}).build())}getAll(){return this.parseCookies()}parseCookies(){const t={},e=this.store.read().split("; ");for(const r of e){const[e,i]=r.split("=");e&&i&&(t[decodeURIComponent(e)]=decodeURIComponent(i))}return t}}class hi extends Ae{NAMESPACE="tracking";COOKIE_CONSENT="cookieConsent";LEGACY_COOKIE_CONSENT="cookie-consent";logger=Tt.logger;set(t,e){this.storeValue(t,e)}setCookieConsent(t){this.set(this.COOKIE_CONSENT,JSON.stringify(t))}getCookieConsent(){this.migrateLegacyCookieConsent();const t=this.get(this.COOKIE_CONSENT).getAsJson();return t?new Bt(t):null}migrateLegacyCookieConsent(){const t=this.getAsJson(this.LEGACY_COOKIE_CONSENT);t&&(this.logger.info("Legacy cookie consent data found. Migrating to new key.",{legacyData:t}),this.setCookieConsent(t),this.remove(this.LEGACY_COOKIE_CONSENT))}}const ui="_wb";class ci{cookieService=xt(oi);timeProvider=b;get(){return this.cookieService.get(ui)}set(t){const e=`WB1.${t}.${this.timeProvider.now()}`;this.cookieService.set(ui,e,{expiration:400,sameSite:"Lax"})}setIfAbsent(t){this.get()||this.set(t)}remove(){this.cookieService.remove(ui)}}class li{cookieService=xt(oi);isSettingUp=!1;setIfAbsent(){if(!this.isSettingUp&&!this.gtmScriptExists()&&(this.isSettingUp=!0,!this.gtmScriptExists())){c.getWindow().dataLayer&&(c.getWindow().dataLayer=[]);const t=c.getDocument().createElement("script");t.text="(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'}); var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:''; j.async=true; j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl; f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-WBP6C6Z4');",c.getDocument().getElementsByTagName("head")[0].appendChild(t)}}remove(){this.isSettingUp=!1,this.gtmScriptExists()&&this.removeGoogleAnalyticsScripts(),this.removeGoogleAnalyticsCookies()}removeGoogleAnalyticsCookies(){const t=this.cookieService.getAll();for(const[e]of Object.entries(t))e.startsWith("_ga")&&this.cookieService.remove(e)}removeGoogleAnalyticsScripts(){c.getWindow().dataLayer&&(c.getWindow().dataLayer=[]);const t=c.getDocument().getElementsByTagName("script"),e=/googletagmanager/i;for(let r=t.length-1;r>=0;r--)(t[r].src&&e.test(t[r].src)||e.test(t[r].text))&&t[r].remove();c.getWindow().google_tag_manager&&delete c.getWindow().google_tag_manager,c.getWindow().google_tag_data&&delete c.getWindow().google_tag_data}gtmScriptExists(){const t=c.getDocument().getElementsByTagName("script");return Array.from(t).some(t=>t.src?.includes("googletagmanager"))}}const gi="cookie-consent-changed-event";class pi{securityService=xt(Gr);securityContextService=xt(hr);authenticationService=xt(ii);authorizationService=xt(ti);trackingStorageService=xt(hi);licenseService=xt(sr);licenseContextService=xt(ir);installationCookieService=xt(ci);googleAnalyticsCookieService=xt(li);eventEmitter=new Ne;isTrackingAllowed(){return this.licenseService.isTrackableLicense()&&!c.getWindow().wbDevMode}acceptCookiePolicy(){const t=this.securityContextService.getAuthenticatedUser();if(t){this.updateUserCookieConsent(t),this.securityContextService.updateAuthenticatedUser(t);const e=this.securityContextService.getIsLoggedIn(),r=this.securityContextService.getSecurityConfig()?.isEnabled();if(r&&!e){const e=t.getCookieConsent();return e&&this.trackingStorageService.setCookieConsent(e),Promise.resolve().finally(()=>this.applyTrackingConsent())}return this.securityService.updateAuthenticatedUser(t.toUser()).then(()=>{this.eventEmitter.emit({NAME:gi,payload:t.appSettings.COOKIE_CONSENT})}).finally(()=>this.applyTrackingConsent())}return Promise.reject(new Error("No authenticated user found"))}getCookieConsent(){const t=this.securityContextService.getAuthenticatedUser();return t?.username?t.appSettings?.COOKIE_CONSENT?Bt.fromJSON(t.appSettings.COOKIE_CONSENT):Bt.NOT_ACCEPTED_WITH_TRACKING():this.authorizationService.hasFreeAccess()?this.trackingStorageService.getCookieConsent()||Bt.NOT_ACCEPTED_WITH_TRACKING():Bt.ACCEPTED_NO_TRACKING()}applyTrackingConsent(){if(!this.isTrackingAllowed())return this.cleanUpTracking(),Promise.resolve();{const t=this.getCookieConsent();if(t.hasChanged()&&!t.policyAccepted)return void this.cleanUpTracking();if(t.statistic){const t=this.licenseContextService.getLicenseSnapshot()?.installationId||"";this.installationCookieService.setIfAbsent(t)}else this.installationCookieService.remove();t.thirdParty?this.googleAnalyticsCookieService.setIfAbsent():this.googleAnalyticsCookieService.remove()}}cleanUpTracking(){this.installationCookieService.remove(),this.googleAnalyticsCookieService.remove()}updateUserCookieConsent(t){let e;e=t.appSettings?.COOKIE_CONSENT?new Bt(t.appSettings.COOKIE_CONSENT):new Bt({thirdParty:!0,statistic:!0}),e.policyAccepted=!0,e.updatedAt=Date.now(),t.appSettings.COOKIE_CONSENT=e}}class di extends _e{MONITORING_ENDPOINT="rest/monitor";getOperations(t){return this.get(`${this.MONITORING_ENDPOINT}/repository/${t}/operations`)}}const fi={[Kt.CLUSTER_HEALTH]:0,[Kt.BACKUP_AND_RESTORE]:1,[Kt.IMPORT]:2,[Kt.QUERIES]:3,[Kt.UPDATES]:4},yi=t=>{if(!t?.status||!t.allRunningOperations)return new Vt({status:Ht.INFORMATION,allRunningOperations:new jt([])});const e=t.allRunningOperations.map(t=>new $t({value:t.value||"",status:w(Ht,t.status),type:w(Kt,t.type)})),r=new jt(e);return r.sort((t,e)=>fi[t.type]-fi[e.type]),new Vt({status:w(Ht,t.status),allRunningOperations:r})};class vi{getOperations(t){return Et.get(di).getOperations(t).then(t=>yi(t))}}class mi extends lr{constructor(){super("Class is not initializable")}}const Si={[ye.ERROR]:Jt.ERROR,[ye.SUCCESS]:Jt.SUCCESS,[ye.WARNING]:Jt.WARNING,[ye.INFO]:Jt.INFO};class Ei{constructor(){throw new mi}static fromNotification(t){const e=this.notificationTypeToToastType(t.type);return new te(e,t.code,{title:t.title,translationParams:this.toTranslationParams(t.parameters)})}static notificationTypeToToastType(t){return t?Si[t]:Jt.INFO}static toTranslationParams(t){return t?Object.entries(t).map(([t,e])=>({key:t,value:String(e)})):[]}}class xi{eventEmitter=new Ne;notificationService=xt(Ar);constructor(){this.subscribeToNotificationEvents()}error(t,e){this.createToastElement(t,Jt.ERROR,e)}info(t,e){this.createToastElement(t,Jt.INFO,e)}success(t,e){this.createToastElement(t,Jt.SUCCESS,e)}warning(t,e){this.createToastElement(t,Jt.WARNING,e)}createToastElement(t,e,r){this.eventEmitter.emit({NAME:ee,payload:new te(e,t,r)})}subscribeToNotificationEvents(){this.notificationService.onNotificationAdded(t=>{if(t.parameters?.[me.SHOULD_TOAST]){const e=Ei.fromNotification(t);this.createToastElement(e.message,e.type,e.config)}})}}class Ai extends _e{autocompleteRestPrefix="rest/autocomplete";search(t){return this.get(`${this.autocompleteRestPrefix}/query?q=${t}`)}enabled(){return this.get(`${this.autocompleteRestPrefix}/enabled`)}}class wi{search(t){return Et.get(Ai).search(t).then(t=>(t=>{const e=t.suggestions.map(t=>new he({id:Qt.hashCode(`${t.type}-${t.value}-${t.description}`),type:w(ue,t.type),value:t.value,description:t.description}));return new oe(new ae(e))})(t))}isAutocompleteEnabled(){return Et.get(Ai).enabled()}}class bi extends Ae{ENABLED_KEY="enabled";NAMESPACE="autocomplete";set(t,e){this.storeValue(t,e)}isEnabled(){return"true"===this.get(this.ENABLED_KEY).value}setEnabled(t){this.set(this.ENABLED_KEY,t.toString())}}class Ci extends Ct{AUTOCOMPLETE_ENABLED="isAutocompleteEnabled";updateAutocompleteEnabled(t){this.updateContextProperty(this.AUTOCOMPLETE_ENABLED,t),Et.get(bi).setEnabled(t)}onAutocompleteEnabledChanged(t){return this.subscribe(this.AUTOCOMPLETE_ENABLED,t)}}class Fi extends _e{REPOSITORIES_ENDPOINT="repositories";getNamespaces(t){return this.get(`${this.REPOSITORIES_ENDPOINT}/${t}/namespaces`)}}const Ii=t=>{const e=(t?.results.bindings||[]).reduce((t,e)=>(t[e.prefix.value]=e.namespace.value,t),{});return new L(e)};class Ri{namespacesRestService=Et.get(Fi);getNamespaces(t){return this.namespacesRestService.getNamespaces(t).then(t=>Ii(t))}}class Ti extends Ct{NAMESPACES="namespaces";updateNamespaces(t){this.updateContextProperty(this.NAMESPACES,t)}onNamespacesChanged(t){return this.subscribe(this.NAMESPACES,t)}}class Pi extends Ae{SELECTED_VIEW_KEY="selectedView";INPUT_KEY="input";LAST_SELECTED_KEY="lastSelected";NAMESPACE="resourceSearch";LEGACY_LAST_SELECTED_KEY="ls.rdf-search.resource-description";LEGACY_INPUT_KEY="ls.rdf-search.search-input";LEGACY_SELECTED_VIEW_KEY="ls.rdf-search.search-type";set(t,e){this.storeValue(t,e)}setSelectedView(t){this.set(this.SELECTED_VIEW_KEY,t),localStorage.setItem(this.LEGACY_SELECTED_VIEW_KEY,t)}getSelectedView(){return this.get(this.SELECTED_VIEW_KEY).getValue()||""}setInputValue(t){this.set(this.INPUT_KEY,t),localStorage.setItem(this.LEGACY_INPUT_KEY,t)}getInputValue(){return this.get(this.INPUT_KEY).getValue()||""}setLastSelected(t){this.set(this.LAST_SELECTED_KEY,t.getValue()),localStorage.setItem(this.LEGACY_LAST_SELECTED_KEY,t.getDescription()||"")}getLastSelectedValue(){return this.get(this.LAST_SELECTED_KEY).getValue()||""}clearStoredSearch(){this.remove(this.INPUT_KEY),this.remove(this.LAST_SELECTED_KEY),localStorage.removeItem(this.LEGACY_INPUT_KEY),localStorage.removeItem(this.LEGACY_LAST_SELECTED_KEY)}}class Di extends Ct{APPLICATION_DATA_STATE="applicationDataLoaded";APPLICATION_STATE_CHANGE="applicationStateChange";APPLICATION_STATE_BEFORE_CHANGE="applicationStateBeforeChange";updateApplicationDataState(t){this.updateContextProperty(this.APPLICATION_DATA_STATE,t)}onApplicationDataStateChanged(t){return this.subscribe(this.APPLICATION_DATA_STATE,t)}getApplicationDataState(){return this.getContextPropertyValue(this.APPLICATION_DATA_STATE)}updateApplicationStateChange(t){this.updateContextProperty(this.APPLICATION_STATE_CHANGE,t)}onApplicationStateChange(t){return this.subscribe(this.APPLICATION_STATE_CHANGE,t)}updateApplicationStateBeforeChange(t){this.updateContextProperty(this.APPLICATION_STATE_BEFORE_CHANGE,t)}onApplicationStateBeforeChange(t){return this.subscribe(this.APPLICATION_STATE_BEFORE_CHANGE,t)}}class Ni extends _e{configurationContextService=xt(Ft);logger=Tt.logger;getPluginsManifest(){const t=this.configurationContextService.getApplicationConfiguration();return this.get(t.pluginsManifestPath)}async loadPlugins(t){return await Promise.all(t.getPluginDefinitions().getItems().map(async t=>{try{const e=t.entry.startsWith("http")?t.entry:`${E()}${t.entry}`;return await import(e)}catch(e){this.logger.warn(`Failed to load plugin ${t.name}:`,e)}}))}}class Oi{logger=Tt.logger;constructor(){this.pluginsRestService=Et.get(Ni)}async getPluginsManifest(){return(t=>{const e=t.plugins.map(t=>new ge(t.entry,t.name));return new pe(new fe(e))})(await this.pluginsRestService.getPluginsManifest())}async loadPlugins(){let t;try{t=await this.getPluginsManifest()}catch(t){this.logger.warn("Failed to load plugins manifest. Continue with the built-in plugins only.",t)}t&&(await this.pluginsRestService.loadPlugins(t)).filter(t=>void 0!==t).forEach(t=>{void 0!==t.register?t.register(c.getPluginRegistry()):this.logger.warn("Plugin module is missing the register method. Skipping registration.",t)})}}const _i=JSON.parse('{"configUrl":"assets/configuration.default.json"}');class Bi extends lr{}class Hi extends _e{async getConfiguration(){let t,e=_i;try{e=await this.get("assets/env.json")}catch{console.warn('No downloadable "env.json" was found. Fallback to default:',e)}try{if(t=await this.get(e.configUrl),t)return console.info(`Configuration file ${e.configUrl} was downloaded`,t),t}catch{throw new Bi(`Failed to download configuration from "${e.configUrl}". Ensure that there is a\n "configuration.default.json" JSON file in the assets folder or provide an "env.json" file pointing to another\n configuration file.`)}}}class Li{configurationRestService=xt(Hi);configurationContextService=xt(Ft);async getConfiguration(){const t=await this.configurationRestService.getConfiguration();return t&&this.configurationContextService.updateApplicationConfiguration(t),t}}const ki=t=>{if(!t)return{items:[]};const e=xt(We).getSelectedRepository();let r="";return e&&(r=`${_}=${e.id}&`),{items:t.map(t=>({id:t,href:`sparql-template/create?${r}templateID=${encodeURIComponent(t)}`}))}};class Ui extends Se{authStorage=Et.get(Tr);repositoryStorageService=Et.get(Ge);securityContextService=Et.get(hr);process(t){return t.headers=t.headers||{},this.populateHeaders(t.headers),Promise.resolve(t)}shouldProcess(t){return!this.isOpenIdUrl(t.url)}populateHeaders(t){t["X-Requested-With"]="XMLHttpRequest";const e=this.authStorage.getAuthToken().getValue();if(e&&(t.Authorization=e),!t["X-GraphDB-Repository"]){const e=this.repositoryStorageService.getRepositoryReference();e?.id&&(t["X-GraphDB-Repository"]=e.id),e?.location&&(t["X-GraphDB-Repository-Location"]=e.location)}}isOpenIdUrl(t){const e=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;return!!e&&[e?.openIdKeysUri,e?.openIdTokenUrl].some(e=>e&&t.indexOf(e)>-1)}}class Vi extends Se{authenticationStorageService=xt(Tr);authenticationService=xt(ii);shouldProcess(t){return 401===t.status}process(t){return this.shouldRedirectToLogin(t.url)?(this.authenticationStorageService.clearAuthToken(),m()||(f("login"),c.getWindow().location.reload()),Promise.reject(t)):Promise.resolve(t)}shouldRedirectToLogin(t){let e;try{e=this.authenticationService.isExternalUser()}catch(t){e=!1}return!t.includes("rest/security/authenticated-user")&&!e}}class ji extends Se{securityContextService=xt(hr);authenticationService=xt(ii);logger=Tt.logger;shouldProcess(t){return 403===t.status}process(t){const e=S();return this.logger.warn("Permission to page denied. Some errors in the console are normal"),this.updateRestrictionsForPage(e),this.shouldRedirectToLogin()&&f("login"),Promise.reject(t)}updateRestrictionsForPage(t){const e=this.securityContextService.getRestrictedPages();e&&!e.isRestricted(t)&&(e.setPageRestriction(t),this.securityContextService.updateRestrictedPages(e))}shouldRedirectToLogin(){return!this.authenticationService.isAuthenticated()}}export{rt as AppSettings,G as ApplicationBeforeChange,W as ApplicationChanged,Di as ApplicationLifecycleContextService,M as ApplicationMounted,s as ApplicationSettings,be as ApplicationSettingsStorageService,q as ApplicationUnmounted,Ui as AuthRequestInterceptor,ht as AuthSettings,Xr as AuthStrategyResolver,nt as AuthenticatedUser,ii as AuthenticationService,Tr as AuthenticationStorageService,Y as AuthenticationType,X as Authority,et as AuthorityList,ti as AuthorizationService,Ci as AutocompleteContextService,oe as AutocompleteSearchResult,wi as AutocompleteService,bi as AutocompleteStorageService,Nt as AvailableLanguagesList,ai as BrowserCookieStore,l as BuildUtil,u as ByteUtils,gi as COOKIE_CONSENT_CHANGED_EVENT,ee as CREATE_TOAST_EVENT,dt as CapabilityList,Ft as ConfigurationContextService,Hi as ConfigurationRestService,Li as ConfigurationService,Ct as ContextService,bt as ContextSubscriptionManager,ni as CookieBuilder,Bt as CookieConsent,oi as CookieService,b as DateUtil,lr as ErrorBase,k as Event,Ne as EventEmitter,U as EventName,Dr as EventService,de as ExtensionPoint,p as FibonacciGenerator,li as GoogleAnalyticsCookieService,Oe as HTTP_REQUEST_DONE_EVENT,Se as HttpInterceptor,Ee as HttpInterceptorList,ci as InstallationCookieService,De as InterceptorService,_t as LanguageConfig,Le as LanguageContextService,Be as LanguageRestService,Ve as LanguageService,He as LanguageStorageService,pt as License,ir as LicenseContextService,sr as LicenseService,le as LifecycleState,Ae as LocalStorageService,we as LocalStorageSubscriptionHandlerService,It as LoggerService,Rt as Loggers,z as Login,$ as Logout,C as Model,F as ModelList,di as MonitoringRestService,vi as MonitoringService,L as NamespaceMap,Ti as NamespacesContextService,Fi as NamespacesRestService,Ri as NamespacesService,ri as NavigationContextService,V as NavigationEnd,j as NavigationEndPayload,K as NavigationStart,ve as Notification,me as NotificationParam,Ar as NotificationService,ye as NotificationType,n as ObjectUtil,xi as OntoToastrService,br as OpenIdAuthFlowHandler,Fr as OpenIdRestService,Nr as OpenIdService,Rr as OpenIdTokenRefreshManager,Ir as OpenIdUrlBuilder,yr as OpenIdUtils,at as OpenidSecurityConfig,ur as OpenidStorageService,$t as Operation,Mt as OperationGroup,kt as OperationGroupSummary,Ut as OperationGroupSummaryList,jt as OperationList,Ht as OperationStatus,Vt as OperationStatusSummary,Kt as OperationType,ge as PluginDefinition,fe as PluginDefinitionList,pe as PluginsManifest,Ni as PluginsRestService,Oi as PluginsService,ft as ProductInfo,nr as ProductInfoContextService,or as ProductInfoService,_ as REPOSITORY_ID_PARAM,R as Repository,We as RepositoryContextService,P as RepositoryList,B as RepositoryLocation,Xe as RepositoryLocationContextService,Ye as RepositoryLocationService,H as RepositoryLocationType,je as RepositoryRestService,qe as RepositoryService,D as RepositorySizeInfo,N as RepositoryState,Ge as RepositoryStorageService,O as RepositoryType,Pi as ResourceSearchStorageService,lt as RestrictedPages,gt as Rights,Ce as RuntimeConfigurationContextService,Lt as STATUS_ORDER,ne as SearchButton,se as SearchButtonConfig,ie as SearchButtonList,ct as SecurityConfig,hr as SecurityContextService,Gr as SecurityService,Et as ServiceProvider,Pt as StorageData,Dt as StorageKey,I as SubscriptionList,he as Suggestion,ae as SuggestionList,ce as SuggestionSelectedPayload,ue as SuggestionType,i as ThemeMode,Fe as ThemeService,te as ToastMessage,re as ToastMessageList,Jt as ToastType,Xt as ToastrConfig,zt as ToastrPosition,pi as TrackingService,hi as TrackingStorageService,Vi as UnauthenticatedInterceptor,ji as UnauthorizedInterceptor,g as UriUtil,xe as UrlPathParams,st as User,it as UserType,qr as UsersService,c as WindowService,x as getBasePath,A as getCurrentRoute,E as getOrigin,S as getPathName,v as isHomePage,m as isLoginPage,ut as mapAuthSettingsResponseToModel,kr as mapAuthenticatedUserResponseToModel,Z as mapGrantedAuthoritiesResponseToModel,Ii as mapNamespaceResponseToModel,yi as mapOperationSummaryResponseToModel,Me as mapRepositoryListResponseToModel,ki as mapSparqlTemplatesResponseToModel,Kr as mapUserModelToRequest,Mr as mapUserResponseToModel,f as navigate,d as navigateTo,wr as notify,y as openInNewTab,xt as service,w as toEnum};
2
+ var t={355(t,e){var r,i,s,n,a,o,h,u,c,l,g,p={userAgent:!1},d={},f=f||(r=Math,s=(i={}).lib={},n=s.Base=function(){function t(){}return{extend:function(e){t.prototype=this;var r=new t;return e&&r.mixIn(e),r.hasOwnProperty("init")||(r.init=function(){r.$super.init.apply(this,arguments)}),r.init.prototype=r,r.$super=this,r},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),a=s.WordArray=n.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||h).stringify(this)},concat:function(t){var e=this.words,r=t.words,i=this.sigBytes,s=t.sigBytes;if(this.clamp(),i%4)for(var n=0;n<s;n++){var a=r[n>>>2]>>>24-n%4*8&255;e[i+n>>>2]|=a<<24-(i+n)%4*8}else for(n=0;n<s;n+=4)e[i+n>>>2]=r[n>>>2];return this.sigBytes+=s,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=r.ceil(e/4)},clone:function(){var t=n.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],i=0;i<t;i+=4)e.push(4294967296*r.random()|0);return new a.init(e,t)}}),o=i.enc={},h=o.Hex={stringify:function(t){for(var e=t.words,r=t.sigBytes,i=[],s=0;s<r;s++){var n=e[s>>>2]>>>24-s%4*8&255;i.push((n>>>4).toString(16)),i.push((15&n).toString(16))}return i.join("")},parse:function(t){for(var e=t.length,r=[],i=0;i<e;i+=2)r[i>>>3]|=parseInt(t.substr(i,2),16)<<24-i%8*4;return new a.init(r,e/2)}},u=o.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,i=[],s=0;s<r;s++){var n=e[s>>>2]>>>24-s%4*8&255;i.push(String.fromCharCode(n))}return i.join("")},parse:function(t){for(var e=t.length,r=[],i=0;i<e;i++)r[i>>>2]|=(255&t.charCodeAt(i))<<24-i%4*8;return new a.init(r,e)}},c=o.Utf8={stringify:function(t){try{return decodeURIComponent(escape(u.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return u.parse(unescape(encodeURIComponent(t)))}},l=s.BufferedBlockAlgorithm=n.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=c.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,i=e.words,s=e.sigBytes,n=this.blockSize,o=s/(4*n),h=(o=t?r.ceil(o):r.max((0|o)-this._minBufferSize,0))*n,u=r.min(4*h,s);if(h){for(var c=0;c<h;c+=n)this._doProcessBlock(i,c);var l=i.splice(0,h);e.sigBytes-=u}return new a.init(l,u)},clone:function(){var t=n.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),s.Hasher=l.extend({cfg:n.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(e,r){return new t.init(r).finalize(e)}},_createHmacHelper:function(t){return function(e,r){return new g.HMAC.init(t,r).finalize(e)}}}),g=i.algo={},i);!function(){var t,e=(t=f).lib,r=e.Base,i=e.WordArray;(t=t.x64={}).Word=r.extend({init:function(t,e){this.high=t,this.low=e}}),t.WordArray=r.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:8*t.length},toX32:function(){for(var t=this.words,e=t.length,r=[],s=0;s<e;s++){var n=t[s];r.push(n.high),r.push(n.low)}return i.create(r,this.sigBytes)},clone:function(){for(var t=r.clone.call(this),e=t.words=this.words.slice(0),i=e.length,s=0;s<i;s++)e[s]=e[s].clone();return t}})}(),f.lib.Cipher||function(){var t=(g=f).lib,e=t.Base,r=t.WordArray,i=t.BufferedBlockAlgorithm,s=g.enc.Base64,n=g.algo.EvpKDF,a=t.Cipher=i.extend({cfg:e.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){i.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(t){return{encrypt:function(e,r,i){return("string"==typeof r?p:l).encrypt(t,e,r,i)},decrypt:function(e,r,i){return("string"==typeof r?p:l).decrypt(t,e,r,i)}}}});t.StreamCipher=a.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var o=g.mode={},h=function(t,e,r){var i=this._iv;i?this._iv=void 0:i=this._prevBlock;for(var s=0;s<r;s++)t[e+s]^=i[s]},u=(t.BlockCipherMode=e.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}})).extend();u.Encryptor=u.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize;h.call(this,t,e,i),r.encryptBlock(t,e),this._prevBlock=t.slice(e,e+i)}}),u.Decryptor=u.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize,s=t.slice(e,e+i);r.decryptBlock(t,e),h.call(this,t,e,i),this._prevBlock=s}}),o=o.CBC=u,u=(g.pad={}).Pkcs7={pad:function(t,e){for(var i,s=(i=(i=4*e)-t.sigBytes%i)<<24|i<<16|i<<8|i,n=[],a=0;a<i;a+=4)n.push(s);i=r.create(n,i),t.concat(i)},unpad:function(t){t.sigBytes-=255&t.words[t.sigBytes-1>>>2]}},t.BlockCipher=a.extend({cfg:a.cfg.extend({mode:o,padding:u}),reset:function(){a.reset.call(this);var t=(e=this.cfg).iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var r=e.createEncryptor;else r=e.createDecryptor,this._minBufferSize=1;this._mode=r.call(e,this,t&&t.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else e=this._process(!0),t.unpad(e);return e},blockSize:4});var c=t.CipherParams=e.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),l=(o=(g.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?r.create([1398893684,1701076831]).concat(t).concat(e):e).toString(s)},parse:function(t){var e=(t=s.parse(t)).words;if(1398893684==e[0]&&1701076831==e[1]){var i=r.create(e.slice(2,4));e.splice(0,4),t.sigBytes-=16}return c.create({ciphertext:t,salt:i})}},t.SerializableCipher=e.extend({cfg:e.extend({format:o}),encrypt:function(t,e,r,i){i=this.cfg.extend(i);var s=t.createEncryptor(r,i);return e=s.finalize(e),s=s.cfg,c.create({ciphertext:e,key:r,iv:s.iv,algorithm:t,mode:s.mode,padding:s.padding,blockSize:t.blockSize,formatter:i.format})},decrypt:function(t,e,r,i){return i=this.cfg.extend(i),e=this._parse(e,i.format),t.createDecryptor(r,i).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),g=(g.kdf={}).OpenSSL={execute:function(t,e,i,s){return s||(s=r.random(8)),t=n.create({keySize:e+i}).compute(t,s),i=r.create(t.words.slice(e),4*i),t.sigBytes=4*e,c.create({key:t,iv:i,salt:s})}},p=t.PasswordBasedCipher=l.extend({cfg:l.cfg.extend({kdf:g}),encrypt:function(t,e,r,i){return r=(i=this.cfg.extend(i)).kdf.execute(r,t.keySize,t.ivSize),i.iv=r.iv,(t=l.encrypt.call(this,t,e,r.key,i)).mixIn(r),t},decrypt:function(t,e,r,i){return i=this.cfg.extend(i),e=this._parse(e,i.format),r=i.kdf.execute(r,t.keySize,t.ivSize,e.salt),i.iv=r.iv,l.decrypt.call(this,t,e,r.key,i)}})}(),function(){for(var t=f,e=t.lib.BlockCipher,r=t.algo,i=[],s=[],n=[],a=[],o=[],h=[],u=[],c=[],l=[],g=[],p=[],d=0;256>d;d++)p[d]=128>d?d<<1:d<<1^283;var y=0,v=0;for(d=0;256>d;d++){var m=(m=v^v<<1^v<<2^v<<3^v<<4)>>>8^255&m^99;i[y]=m,s[m]=y;var S=p[y],E=p[S],x=p[E],A=257*p[m]^16843008*m;n[y]=A<<24|A>>>8,a[y]=A<<16|A>>>16,o[y]=A<<8|A>>>24,h[y]=A,A=16843009*x^65537*E^257*S^16843008*y,u[m]=A<<24|A>>>8,c[m]=A<<16|A>>>16,l[m]=A<<8|A>>>24,g[m]=A,y?(y=S^p[p[p[x^S]]],v^=p[p[v]]):y=v=1}var w=[0,1,2,4,8,16,32,64,128,27,54];r=r.AES=e.extend({_doReset:function(){for(var t=(r=this._key).words,e=r.sigBytes/4,r=4*((this._nRounds=e+6)+1),s=this._keySchedule=[],n=0;n<r;n++)if(n<e)s[n]=t[n];else{var a=s[n-1];n%e?6<e&&4==n%e&&(a=i[a>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a]):(a=i[(a=a<<8|a>>>24)>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a],a^=w[n/e|0]<<24),s[n]=s[n-e]^a}for(t=this._invKeySchedule=[],e=0;e<r;e++)n=r-e,a=e%4?s[n]:s[n-4],t[e]=4>e||4>=n?a:u[i[a>>>24]]^c[i[a>>>16&255]]^l[i[a>>>8&255]]^g[i[255&a]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,n,a,o,h,i)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,u,c,l,g,s),r=t[e+1],t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,i,s,n,a,o){for(var h=this._nRounds,u=t[e]^r[0],c=t[e+1]^r[1],l=t[e+2]^r[2],g=t[e+3]^r[3],p=4,d=1;d<h;d++){var f=i[u>>>24]^s[c>>>16&255]^n[l>>>8&255]^a[255&g]^r[p++],y=i[c>>>24]^s[l>>>16&255]^n[g>>>8&255]^a[255&u]^r[p++],v=i[l>>>24]^s[g>>>16&255]^n[u>>>8&255]^a[255&c]^r[p++];g=i[g>>>24]^s[u>>>16&255]^n[c>>>8&255]^a[255&l]^r[p++],u=f,c=y,l=v}f=(o[u>>>24]<<24|o[c>>>16&255]<<16|o[l>>>8&255]<<8|o[255&g])^r[p++],y=(o[c>>>24]<<24|o[l>>>16&255]<<16|o[g>>>8&255]<<8|o[255&u])^r[p++],v=(o[l>>>24]<<24|o[g>>>16&255]<<16|o[u>>>8&255]<<8|o[255&c])^r[p++],g=(o[g>>>24]<<24|o[u>>>16&255]<<16|o[c>>>8&255]<<8|o[255&l])^r[p++],t[e]=f,t[e+1]=y,t[e+2]=v,t[e+3]=g},keySize:8}),t.AES=e._createHelper(r)}(),function(){function t(t,e){var r=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=r,this._lBlock^=r<<t}function e(t,e){var r=(this._rBlock>>>t^this._lBlock)&e;this._lBlock^=r,this._rBlock^=r<<t}var r=f,i=(s=r.lib).WordArray,s=s.BlockCipher,n=r.algo,a=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],o=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],h=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],u=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],c=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],l=n.DES=s.extend({_doReset:function(){for(var t=this._key.words,e=[],r=0;56>r;r++){var i=a[r]-1;e[r]=t[i>>>5]>>>31-i%32&1}for(t=this._subKeys=[],i=0;16>i;i++){var s=t[i]=[],n=h[i];for(r=0;24>r;r++)s[r/6|0]|=e[(o[r]-1+n)%28]<<31-r%6,s[4+(r/6|0)]|=e[28+(o[r+24]-1+n)%28]<<31-r%6;for(s[0]=s[0]<<1|s[0]>>>31,r=1;7>r;r++)s[r]>>>=4*(r-1)+3;s[7]=s[7]<<5|s[7]>>>27}for(e=this._invSubKeys=[],r=0;16>r;r++)e[r]=t[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(r,i,s){this._lBlock=r[i],this._rBlock=r[i+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var n=0;16>n;n++){for(var a=s[n],o=this._lBlock,h=this._rBlock,l=0,g=0;8>g;g++)l|=u[g][((h^a[g])&c[g])>>>0];this._lBlock=h,this._rBlock=o^l}s=this._lBlock,this._lBlock=this._rBlock,this._rBlock=s,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),r[i]=this._lBlock,r[i+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});r.DES=s._createHelper(l),n=n.TripleDES=s.extend({_doReset:function(){var t=this._key.words;this._des1=l.createEncryptor(i.create(t.slice(0,2))),this._des2=l.createEncryptor(i.create(t.slice(2,4))),this._des3=l.createEncryptor(i.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),r.TripleDES=s._createHelper(n)}(),function(){var t=f,e=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,r=t.sigBytes,i=this._map;t.clamp(),t=[];for(var s=0;s<r;s+=3)for(var n=(e[s>>>2]>>>24-s%4*8&255)<<16|(e[s+1>>>2]>>>24-(s+1)%4*8&255)<<8|e[s+2>>>2]>>>24-(s+2)%4*8&255,a=0;4>a&&s+.75*a<r;a++)t.push(i.charAt(n>>>6*(3-a)&63));if(e=i.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var r=t.length,i=this._map;(s=i.charAt(64))&&-1!=(s=t.indexOf(s))&&(r=s);for(var s=[],n=0,a=0;a<r;a++)if(a%4){var o=i.indexOf(t.charAt(a-1))<<a%4*2,h=i.indexOf(t.charAt(a))>>>6-a%4*2;s[n>>>2]|=(o|h)<<24-n%4*8,n++}return e.create(s,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,r,i,s,n,a){return((t=t+(e&r|~e&i)+s+a)<<n|t>>>32-n)+e}function r(t,e,r,i,s,n,a){return((t=t+(e&i|r&~i)+s+a)<<n|t>>>32-n)+e}function i(t,e,r,i,s,n,a){return((t=t+(e^r^i)+s+a)<<n|t>>>32-n)+e}function s(t,e,r,i,s,n,a){return((t=t+(r^(e|~i))+s+a)<<n|t>>>32-n)+e}for(var n=f,a=(h=n.lib).WordArray,o=h.Hasher,h=n.algo,u=[],c=0;64>c;c++)u[c]=4294967296*t.abs(t.sin(c+1))|0;h=h.MD5=o.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,n){for(var a=0;16>a;a++){var o=t[h=n+a];t[h]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}a=this._hash.words;var h=t[n+0],c=(o=t[n+1],t[n+2]),l=t[n+3],g=t[n+4],p=t[n+5],d=t[n+6],f=t[n+7],y=t[n+8],v=t[n+9],m=t[n+10],S=t[n+11],E=t[n+12],x=t[n+13],A=t[n+14],w=t[n+15],b=e(b=a[0],C=a[1],I=a[2],F=a[3],h,7,u[0]),F=e(F,b,C,I,o,12,u[1]),I=e(I,F,b,C,c,17,u[2]),C=e(C,I,F,b,l,22,u[3]);b=e(b,C,I,F,g,7,u[4]),F=e(F,b,C,I,p,12,u[5]),I=e(I,F,b,C,d,17,u[6]),C=e(C,I,F,b,f,22,u[7]),b=e(b,C,I,F,y,7,u[8]),F=e(F,b,C,I,v,12,u[9]),I=e(I,F,b,C,m,17,u[10]),C=e(C,I,F,b,S,22,u[11]),b=e(b,C,I,F,E,7,u[12]),F=e(F,b,C,I,x,12,u[13]),I=e(I,F,b,C,A,17,u[14]),b=r(b,C=e(C,I,F,b,w,22,u[15]),I,F,o,5,u[16]),F=r(F,b,C,I,d,9,u[17]),I=r(I,F,b,C,S,14,u[18]),C=r(C,I,F,b,h,20,u[19]),b=r(b,C,I,F,p,5,u[20]),F=r(F,b,C,I,m,9,u[21]),I=r(I,F,b,C,w,14,u[22]),C=r(C,I,F,b,g,20,u[23]),b=r(b,C,I,F,v,5,u[24]),F=r(F,b,C,I,A,9,u[25]),I=r(I,F,b,C,l,14,u[26]),C=r(C,I,F,b,y,20,u[27]),b=r(b,C,I,F,x,5,u[28]),F=r(F,b,C,I,c,9,u[29]),I=r(I,F,b,C,f,14,u[30]),b=i(b,C=r(C,I,F,b,E,20,u[31]),I,F,p,4,u[32]),F=i(F,b,C,I,y,11,u[33]),I=i(I,F,b,C,S,16,u[34]),C=i(C,I,F,b,A,23,u[35]),b=i(b,C,I,F,o,4,u[36]),F=i(F,b,C,I,g,11,u[37]),I=i(I,F,b,C,f,16,u[38]),C=i(C,I,F,b,m,23,u[39]),b=i(b,C,I,F,x,4,u[40]),F=i(F,b,C,I,h,11,u[41]),I=i(I,F,b,C,l,16,u[42]),C=i(C,I,F,b,d,23,u[43]),b=i(b,C,I,F,v,4,u[44]),F=i(F,b,C,I,E,11,u[45]),I=i(I,F,b,C,w,16,u[46]),b=s(b,C=i(C,I,F,b,c,23,u[47]),I,F,h,6,u[48]),F=s(F,b,C,I,f,10,u[49]),I=s(I,F,b,C,A,15,u[50]),C=s(C,I,F,b,p,21,u[51]),b=s(b,C,I,F,E,6,u[52]),F=s(F,b,C,I,l,10,u[53]),I=s(I,F,b,C,m,15,u[54]),C=s(C,I,F,b,o,21,u[55]),b=s(b,C,I,F,y,6,u[56]),F=s(F,b,C,I,w,10,u[57]),I=s(I,F,b,C,d,15,u[58]),C=s(C,I,F,b,x,21,u[59]),b=s(b,C,I,F,g,6,u[60]),F=s(F,b,C,I,S,10,u[61]),I=s(I,F,b,C,c,15,u[62]),C=s(C,I,F,b,v,21,u[63]),a[0]=a[0]+b|0,a[1]=a[1]+C|0,a[2]=a[2]+I|0,a[3]=a[3]+F|0},_doFinalize:function(){var e=this._data,r=e.words,i=8*this._nDataBytes,s=8*e.sigBytes;r[s>>>5]|=128<<24-s%32;var n=t.floor(i/4294967296);for(r[15+(s+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),r[14+(s+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),e.sigBytes=4*(r.length+1),this._process(),r=(e=this._hash).words,i=0;4>i;i++)s=r[i],r[i]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8);return e},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}}),n.MD5=o._createHelper(h),n.HmacMD5=o._createHmacHelper(h)}(Math),function(){var t=f,e=(s=t.lib).WordArray,r=s.Hasher,i=[],s=t.algo.SHA1=r.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=this._hash.words,s=r[0],n=r[1],a=r[2],o=r[3],h=r[4],u=0;80>u;u++){if(16>u)i[u]=0|t[e+u];else{var c=i[u-3]^i[u-8]^i[u-14]^i[u-16];i[u]=c<<1|c>>>31}c=(s<<5|s>>>27)+h+i[u],c=20>u?c+(1518500249+(n&a|~n&o)):40>u?c+(1859775393+(n^a^o)):60>u?c+((n&a|n&o|a&o)-1894007588):c+((n^a^o)-899497514),h=o,o=a,a=n<<30|n>>>2,n=s,s=c}r[0]=r[0]+s|0,r[1]=r[1]+n|0,r[2]=r[2]+a|0,r[3]=r[3]+o|0,r[4]=r[4]+h|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return e[i>>>5]|=128<<24-i%32,e[14+(i+64>>>9<<4)]=Math.floor(r/4294967296),e[15+(i+64>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=r._createHelper(s),t.HmacSHA1=r._createHmacHelper(s)}(),function(t){for(var e=f,r=(s=e.lib).WordArray,i=s.Hasher,s=e.algo,n=[],a=[],o=function(t){return 4294967296*(t-(0|t))|0},h=2,u=0;64>u;){var c;t:{c=h;for(var l=t.sqrt(c),g=2;g<=l;g++)if(!(c%g)){c=!1;break t}c=!0}c&&(8>u&&(n[u]=o(t.pow(h,.5))),a[u]=o(t.pow(h,1/3)),u++),h++}var p=[];s=s.SHA256=i.extend({_doReset:function(){this._hash=new r.init(n.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,i=r[0],s=r[1],n=r[2],o=r[3],h=r[4],u=r[5],c=r[6],l=r[7],g=0;64>g;g++){if(16>g)p[g]=0|t[e+g];else{var d=p[g-15],f=p[g-2];p[g]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+p[g-7]+((f<<15|f>>>17)^(f<<13|f>>>19)^f>>>10)+p[g-16]}d=l+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&u^~h&c)+a[g]+p[g],f=((i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22))+(i&s^i&n^s&n),l=c,c=u,u=h,h=o+d|0,o=n,n=s,s=i,i=d+f|0}r[0]=r[0]+i|0,r[1]=r[1]+s|0,r[2]=r[2]+n|0,r[3]=r[3]+o|0,r[4]=r[4]+h|0,r[5]=r[5]+u|0,r[6]=r[6]+c|0,r[7]=r[7]+l|0},_doFinalize:function(){var e=this._data,r=e.words,i=8*this._nDataBytes,s=8*e.sigBytes;return r[s>>>5]|=128<<24-s%32,r[14+(s+64>>>9<<4)]=t.floor(i/4294967296),r[15+(s+64>>>9<<4)]=i,e.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}}),e.SHA256=i._createHelper(s),e.HmacSHA256=i._createHmacHelper(s)}(Math),function(){var t=f,e=t.lib.WordArray,r=(i=t.algo).SHA256,i=i.SHA224=r.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=r._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=r._createHelper(i),t.HmacSHA224=r._createHmacHelper(i)}(),function(){function t(){return i.create.apply(i,arguments)}for(var e=f,r=e.lib.Hasher,i=(n=e.x64).Word,s=n.WordArray,n=e.algo,a=[t(1116352408,3609767458),t(1899447441,602891725),t(3049323471,3964484399),t(3921009573,2173295548),t(961987163,4081628472),t(1508970993,3053834265),t(2453635748,2937671579),t(2870763221,3664609560),t(3624381080,2734883394),t(310598401,1164996542),t(607225278,1323610764),t(1426881987,3590304994),t(1925078388,4068182383),t(2162078206,991336113),t(2614888103,633803317),t(3248222580,3479774868),t(3835390401,2666613458),t(4022224774,944711139),t(264347078,2341262773),t(604807628,2007800933),t(770255983,1495990901),t(1249150122,1856431235),t(1555081692,3175218132),t(1996064986,2198950837),t(2554220882,3999719339),t(2821834349,766784016),t(2952996808,2566594879),t(3210313671,3203337956),t(3336571891,1034457026),t(3584528711,2466948901),t(113926993,3758326383),t(338241895,168717936),t(666307205,1188179964),t(773529912,1546045734),t(1294757372,1522805485),t(1396182291,2643833823),t(1695183700,2343527390),t(1986661051,1014477480),t(2177026350,1206759142),t(2456956037,344077627),t(2730485921,1290863460),t(2820302411,3158454273),t(3259730800,3505952657),t(3345764771,106217008),t(3516065817,3606008344),t(3600352804,1432725776),t(4094571909,1467031594),t(275423344,851169720),t(430227734,3100823752),t(506948616,1363258195),t(659060556,3750685593),t(883997877,3785050280),t(958139571,3318307427),t(1322822218,3812723403),t(1537002063,2003034995),t(1747873779,3602036899),t(1955562222,1575990012),t(2024104815,1125592928),t(2227730452,2716904306),t(2361852424,442776044),t(2428436474,593698344),t(2756734187,3733110249),t(3204031479,2999351573),t(3329325298,3815920427),t(3391569614,3928383900),t(3515267271,566280711),t(3940187606,3454069534),t(4118630271,4000239992),t(116418474,1914138554),t(174292421,2731055270),t(289380356,3203993006),t(460393269,320620315),t(685471733,587496836),t(852142971,1086792851),t(1017036298,365543100),t(1126000580,2618297676),t(1288033470,3409855158),t(1501505948,4234509866),t(1607167915,987167468),t(1816402316,1246189591)],o=[],h=0;80>h;h++)o[h]=t();n=n.SHA512=r.extend({_doReset:function(){this._hash=new s.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var r=(l=this._hash.words)[0],i=l[1],s=l[2],n=l[3],h=l[4],u=l[5],c=l[6],l=l[7],g=r.high,p=r.low,d=i.high,f=i.low,y=s.high,v=s.low,m=n.high,S=n.low,E=h.high,x=h.low,A=u.high,w=u.low,b=c.high,F=c.low,I=l.high,C=l.low,R=g,T=p,P=d,D=f,N=y,O=v,_=m,B=S,L=E,H=x,k=A,U=w,V=b,j=F,M=I,K=C,q=0;80>q;q++){var G=o[q];if(16>q)var W=G.high=0|t[e+2*q],$=G.low=0|t[e+2*q+1];else{W=(($=(W=o[q-15]).high)>>>1|(X=W.low)<<31)^($>>>8|X<<24)^$>>>7;var X=(X>>>1|$<<31)^(X>>>8|$<<24)^(X>>>7|$<<25),z=(($=(z=o[q-2]).high)>>>19|(Y=z.low)<<13)^($<<3|Y>>>29)^$>>>6,Y=(Y>>>19|$<<13)^(Y<<3|$>>>29)^(Y>>>6|$<<26),J=($=o[q-7]).high,Q=(Z=o[q-16]).high,Z=Z.low;W=(W=(W=W+J+(($=X+$.low)>>>0<X>>>0?1:0))+z+(($+=Y)>>>0<Y>>>0?1:0))+Q+(($+=Z)>>>0<Z>>>0?1:0),G.high=W,G.low=$}J=L&k^~L&V,Z=H&U^~H&j,G=R&P^R&N^P&N;var tt=T&D^T&O^D&O,et=(X=(R>>>28|T<<4)^(R<<30|T>>>2)^(R<<25|T>>>7),z=(T>>>28|R<<4)^(T<<30|R>>>2)^(T<<25|R>>>7),(Y=a[q]).high),rt=Y.low;Q=M+((L>>>14|H<<18)^(L>>>18|H<<14)^(L<<23|H>>>9))+((Y=K+((H>>>14|L<<18)^(H>>>18|L<<14)^(H<<23|L>>>9)))>>>0<K>>>0?1:0),M=V,K=j,V=k,j=U,k=L,U=H,L=_+(Q=(Q=(Q=Q+J+((Y+=Z)>>>0<Z>>>0?1:0))+et+((Y+=rt)>>>0<rt>>>0?1:0))+W+((Y+=$)>>>0<$>>>0?1:0))+((H=B+Y|0)>>>0<B>>>0?1:0)|0,_=N,B=O,N=P,O=D,P=R,D=T,R=Q+(G=X+G+(($=z+tt)>>>0<z>>>0?1:0))+((T=Y+$|0)>>>0<Y>>>0?1:0)|0}p=r.low=p+T,r.high=g+R+(p>>>0<T>>>0?1:0),f=i.low=f+D,i.high=d+P+(f>>>0<D>>>0?1:0),v=s.low=v+O,s.high=y+N+(v>>>0<O>>>0?1:0),S=n.low=S+B,n.high=m+_+(S>>>0<B>>>0?1:0),x=h.low=x+H,h.high=E+L+(x>>>0<H>>>0?1:0),w=u.low=w+U,u.high=A+k+(w>>>0<U>>>0?1:0),F=c.low=F+j,c.high=b+V+(F>>>0<j>>>0?1:0),C=l.low=C+K,l.high=I+M+(C>>>0<K>>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return e[i>>>5]|=128<<24-i%32,e[30+(i+128>>>10<<5)]=Math.floor(r/4294967296),e[31+(i+128>>>10<<5)]=r,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=r._createHelper(n),e.HmacSHA512=r._createHmacHelper(n)}(),function(){var t=f,e=(s=t.x64).Word,r=s.WordArray,i=(s=t.algo).SHA512,s=s.SHA384=i.extend({_doReset:function(){this._hash=new r.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=i._createHelper(s),t.HmacSHA384=i._createHmacHelper(s)}(),function(){var t=f,e=(i=t.lib).WordArray,r=i.Hasher,i=t.algo,s=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),n=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),a=e.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),o=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=e.create([0,1518500249,1859775393,2400959708,2840853838]),u=e.create([1352829926,1548603684,1836072691,2053994217,0]);i=i.RIPEMD160=r.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=0;16>r;r++){var i=t[x=e+r];t[x]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var c,l,g,p,d,f,y,v,m,S,E,x=this._hash.words,A=(i=h.words,u.words),w=s.words,b=n.words,F=a.words,I=o.words;for(f=c=x[0],y=l=x[1],v=g=x[2],m=p=x[3],S=d=x[4],r=0;80>r;r+=1)E=c+t[e+w[r]]|0,E=16>r?E+((l^g^p)+i[0]):32>r?E+((l&g|~l&p)+i[1]):48>r?E+(((l|~g)^p)+i[2]):64>r?E+((l&p|g&~p)+i[3]):E+((l^(g|~p))+i[4]),E=(E=(E|=0)<<F[r]|E>>>32-F[r])+d|0,c=d,d=p,p=g<<10|g>>>22,g=l,l=E,E=f+t[e+b[r]]|0,E=16>r?E+((y^(v|~m))+A[0]):32>r?E+((y&m|v&~m)+A[1]):48>r?E+(((y|~v)^m)+A[2]):64>r?E+((y&v|~y&m)+A[3]):E+((y^v^m)+A[4]),E=(E=(E|=0)<<I[r]|E>>>32-I[r])+S|0,f=S,S=m,m=v<<10|v>>>22,v=y,y=E;E=x[1]+g+m|0,x[1]=x[2]+p+S|0,x[2]=x[3]+d+f|0,x[3]=x[4]+c+y|0,x[4]=x[0]+l+v|0,x[0]=E},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;for(e[i>>>5]|=128<<24-i%32,e[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,r=0;5>r;r++)i=e[r],e[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return t},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}}),t.RIPEMD160=r._createHelper(i),t.HmacRIPEMD160=r._createHmacHelper(i)}(Math),function(){var t=f,e=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,r){t=this._hasher=new t.init,"string"==typeof r&&(r=e.parse(r));var i=t.blockSize,s=4*i;r.sigBytes>s&&(r=t.finalize(r)),r.clamp();for(var n=this._oKey=r.clone(),a=this._iKey=r.clone(),o=n.words,h=a.words,u=0;u<i;u++)o[u]^=1549556828,h[u]^=909522486;n.sigBytes=a.sigBytes=s,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher;return t=e.finalize(t),e.reset(),e.finalize(this._oKey.clone().concat(t))}})}(),function(){var t,e=f,r=(t=e.lib).Base,i=t.WordArray,s=(t=e.algo).HMAC,n=t.PBKDF2=r.extend({cfg:r.extend({keySize:4,hasher:t.SHA1,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){var r=this.cfg,n=s.create(r.hasher,t),a=i.create(),o=i.create([1]),h=a.words,u=o.words,c=r.keySize;for(r=r.iterations;h.length<c;){var l=n.update(e).finalize(o);n.reset();for(var g=l.words,p=g.length,d=l,f=1;f<r;f++){d=n.finalize(d),n.reset();for(var y=d.words,v=0;v<p;v++)g[v]^=y[v]}a.concat(l),u[0]++}return a.sigBytes=4*c,a}});e.PBKDF2=function(t,e,r){return n.create(r).compute(t,e)}}();var y,v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function m(t){var e,r,i="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),i+=v.charAt(r>>6)+v.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),i+=v.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),i+=v.charAt(r>>2)+v.charAt((3&r)<<4));(3&i.length)>0;)i+="=";return i}function S(t){var e,r,i,s="",n=0;for(e=0;e<t.length&&"="!=t.charAt(e);++e)(i=v.indexOf(t.charAt(e)))<0||(0==n?(s+=F(i>>2),r=3&i,n=1):1==n?(s+=F(r<<2|i>>4),r=15&i,n=2):2==n?(s+=F(r),s+=F(i>>2),r=3&i,n=3):(s+=F(r<<2|i>>4),s+=F(15&i),n=0));return 1==n&&(s+=F(r<<2)),s}function E(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function x(){return new E(null)}"Microsoft Internet Explorer"==p.appName?(E.prototype.am=function(t,e,r,i,s,n){for(var a=32767&e,o=e>>15;--n>=0;){var h=32767&this[t],u=this[t++]>>15,c=o*h+u*a;s=((h=a*h+((32767&c)<<15)+r[i]+(1073741823&s))>>>30)+(c>>>15)+o*u+(s>>>30),r[i++]=1073741823&h}return s},y=30):"Netscape"!=p.appName?(E.prototype.am=function(t,e,r,i,s,n){for(;--n>=0;){var a=e*this[t++]+r[i]+s;s=Math.floor(a/67108864),r[i++]=67108863&a}return s},y=26):(E.prototype.am=function(t,e,r,i,s,n){for(var a=16383&e,o=e>>14;--n>=0;){var h=16383&this[t],u=this[t++]>>14,c=o*h+u*a;s=((h=a*h+((16383&c)<<14)+r[i]+s)>>28)+(c>>14)+o*u,r[i++]=268435455&h}return s},y=28),E.prototype.DB=y,E.prototype.DM=(1<<y)-1,E.prototype.DV=1<<y,E.prototype.FV=Math.pow(2,52),E.prototype.F1=52-y,E.prototype.F2=2*y-52;var A,w,b=new Array;for(A="0".charCodeAt(0),w=0;w<=9;++w)b[A++]=w;for(A="a".charCodeAt(0),w=10;w<36;++w)b[A++]=w;for(A="A".charCodeAt(0),w=10;w<36;++w)b[A++]=w;function F(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function I(t,e){var r=b[t.charCodeAt(e)];return null==r?-1:r}function C(t){var e=x();return e.fromInt(t),e}function R(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function T(t){this.m=t}function P(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function D(t,e){return t&e}function N(t,e){return t|e}function O(t,e){return t^e}function _(t,e){return t&~e}function B(t){if(0==t)return-1;var e=0;return 65535&t||(t>>=16,e+=16),255&t||(t>>=8,e+=8),15&t||(t>>=4,e+=4),3&t||(t>>=2,e+=2),1&t||++e,e}function L(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function H(){}function k(t){return t}function U(t){this.r2=x(),this.q3=x(),E.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}T.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},T.prototype.revert=function(t){return t},T.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},T.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},T.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},P.prototype.convert=function(t){var e=x();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(E.ZERO)>0&&this.m.subTo(e,e),e},P.prototype.revert=function(t){var e=x();return t.copyTo(e),this.reduce(e),e},P.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],i=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,i,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},P.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},P.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},E.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},E.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},E.prototype.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var i=t.length,s=!1,n=0;--i>=0;){var a=8==r?255&t[i]:I(t,i);a<0?"-"==t.charAt(i)&&(s=!0):(s=!1,0==n?this[this.t++]=a:n+r>this.DB?(this[this.t-1]|=(a&(1<<this.DB-n)-1)<<n,this[this.t++]=a>>this.DB-n):this[this.t-1]|=a<<n,(n+=r)>=this.DB&&(n-=this.DB))}8==r&&128&t[0]&&(this.s=-1,n>0&&(this[this.t-1]|=(1<<this.DB-n)-1<<n)),this.clamp(),s&&E.ZERO.subTo(this,this)},E.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},E.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},E.prototype.drShiftTo=function(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s},E.prototype.lShiftTo=function(t,e){var r,i=t%this.DB,s=this.DB-i,n=(1<<s)-1,a=Math.floor(t/this.DB),o=this.s<<i&this.DM;for(r=this.t-1;r>=0;--r)e[r+a+1]=this[r]>>s|o,o=(this[r]&n)<<i;for(r=a-1;r>=0;--r)e[r]=0;e[a]=o,e.t=this.t+a+1,e.s=this.s,e.clamp()},E.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var i=t%this.DB,s=this.DB-i,n=(1<<i)-1;e[0]=this[r]>>i;for(var a=r+1;a<this.t;++a)e[a-r-1]|=(this[a]&n)<<s,e[a-r]=this[a]>>i;i>0&&(e[this.t-r-1]|=(this.s&n)<<s),e.t=this.t-r,e.clamp()}},E.prototype.subTo=function(t,e){for(var r=0,i=0,s=Math.min(t.t,this.t);r<s;)i+=this[r]-t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i-=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i-=t[r],e[r++]=i&this.DM,i>>=this.DB;i-=t.s}e.s=i<0?-1:0,i<-1?e[r++]=this.DV+i:i>0&&(e[r++]=i),e.t=r,e.clamp()},E.prototype.multiplyTo=function(t,e){var r=this.abs(),i=t.abs(),s=r.t;for(e.t=s+i.t;--s>=0;)e[s]=0;for(s=0;s<i.t;++s)e[s+r.t]=r.am(0,i[s],e,s,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&E.ZERO.subTo(e,e)},E.prototype.squareTo=function(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var i=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,i,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},E.prototype.divRemTo=function(t,e,r){var i=t.abs();if(!(i.t<=0)){var s=this.abs();if(s.t<i.t)return null!=e&&e.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=x());var n=x(),a=this.s,o=t.s,h=this.DB-R(i[i.t-1]);h>0?(i.lShiftTo(h,n),s.lShiftTo(h,r)):(i.copyTo(n),s.copyTo(r));var u=n.t,c=n[u-1];if(0!=c){var l=c*(1<<this.F1)+(u>1?n[u-2]>>this.F2:0),g=this.FV/l,p=(1<<this.F1)/l,d=1<<this.F2,f=r.t,y=f-u,v=null==e?x():e;for(n.dlShiftTo(y,v),r.compareTo(v)>=0&&(r[r.t++]=1,r.subTo(v,r)),E.ONE.dlShiftTo(u,v),v.subTo(n,n);n.t<u;)n[n.t++]=0;for(;--y>=0;){var m=r[--f]==c?this.DM:Math.floor(r[f]*g+(r[f-1]+d)*p);if((r[f]+=n.am(0,m,r,y,0,u))<m)for(n.dlShiftTo(y,v),r.subTo(v,r);r[f]<--m;)r.subTo(v,r)}null!=e&&(r.drShiftTo(u,e),a!=o&&E.ZERO.subTo(e,e)),r.t=u,r.clamp(),h>0&&r.rShiftTo(h,r),a<0&&E.ZERO.subTo(r,r)}}},E.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(!(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},E.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},E.prototype.exp=function(t,e){if(t>4294967295||t<1)return E.ONE;var r=x(),i=x(),s=e.convert(this),n=R(t)-1;for(s.copyTo(r);--n>=0;)if(e.sqrTo(r,i),(t&1<<n)>0)e.mulTo(i,s,r);else{var a=r;r=i,i=a}return e.revert(r)},E.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,i=(1<<e)-1,s=!1,n="",a=this.t,o=this.DB-a*this.DB%e;if(a-- >0)for(o<this.DB&&(r=this[a]>>o)>0&&(s=!0,n=F(r));a>=0;)o<e?(r=(this[a]&(1<<o)-1)<<e-o,r|=this[--a]>>(o+=this.DB-e)):(r=this[a]>>(o-=e)&i,o<=0&&(o+=this.DB,--a)),r>0&&(s=!0),s&&(n+=F(r));return s?n:"0"},E.prototype.negate=function(){var t=x();return E.ZERO.subTo(this,t),t},E.prototype.abs=function(){return this.s<0?this.negate():this},E.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},E.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+R(this[this.t-1]^this.s&this.DM)},E.prototype.mod=function(t){var e=x();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(E.ZERO)>0&&t.subTo(e,e),e},E.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new T(e):new P(e),this.exp(t,r)},E.ZERO=C(0),E.ONE=C(1),H.prototype.convert=k,H.prototype.revert=k,H.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},H.prototype.sqrTo=function(t,e){t.squareTo(e)},U.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=x();return t.copyTo(e),this.reduce(e),e},U.prototype.revert=function(t){return t},U.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},U.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},U.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var V,j,M,K=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],q=(1<<26)/K[K.length-1];function G(){this.i=0,this.j=0,this.S=new Array}function W(){!function(t){j[M++]^=255&t,j[M++]^=t>>8&255,j[M++]^=t>>16&255,j[M++]^=t>>24&255,M>=256&&(M-=256)}((new Date).getTime())}if(E.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},E.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),i=C(r),s=x(),n=x(),a="";for(this.divRemTo(i,s,n);s.signum()>0;)a=(r+n.intValue()).toString(t).substr(1)+a,s.divRemTo(i,s,n);return n.intValue().toString(t)+a},E.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),i=Math.pow(e,r),s=!1,n=0,a=0,o=0;o<t.length;++o){var h=I(t,o);h<0?"-"==t.charAt(o)&&0==this.signum()&&(s=!0):(a=e*a+h,++n>=r&&(this.dMultiply(i),this.dAddOffset(a,0),n=0,a=0))}n>0&&(this.dMultiply(Math.pow(e,n)),this.dAddOffset(a,0)),s&&E.ZERO.subTo(this,this)},E.prototype.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(E.ONE.shiftLeft(t-1),N,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(E.ONE.shiftLeft(t-1),this);else{var i=new Array,s=7&t;i.length=1+(t>>3),e.nextBytes(i),s>0?i[0]&=(1<<s)-1:i[0]=0,this.fromString(i,256)}},E.prototype.bitwiseTo=function(t,e,r){var i,s,n=Math.min(t.t,this.t);for(i=0;i<n;++i)r[i]=e(this[i],t[i]);if(t.t<this.t){for(s=t.s&this.DM,i=n;i<this.t;++i)r[i]=e(this[i],s);r.t=this.t}else{for(s=this.s&this.DM,i=n;i<t.t;++i)r[i]=e(s,t[i]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()},E.prototype.changeBit=function(t,e){var r=E.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r},E.prototype.addTo=function(t,e){for(var r=0,i=0,s=Math.min(t.t,this.t);r<s;)i+=this[r]+t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i+=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i+=t[r],e[r++]=i&this.DM,i>>=this.DB;i+=t.s}e.s=i<0?-1:0,i>0?e[r++]=i:i<-1&&(e[r++]=this.DV+i),e.t=r,e.clamp()},E.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},E.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},E.prototype.multiplyLowerTo=function(t,e,r){var i,s=Math.min(this.t+t.t,e);for(r.s=0,r.t=s;s>0;)r[--s]=0;for(i=r.t-this.t;s<i;++s)r[s+this.t]=this.am(0,t[s],r,s,0,this.t);for(i=Math.min(t.t,e);s<i;++s)this.am(0,t[s],r,s,0,e-s);r.clamp()},E.prototype.multiplyUpperTo=function(t,e,r){--e;var i=r.t=this.t+t.t-e;for(r.s=0;--i>=0;)r[i]=0;for(i=Math.max(e-this.t,0);i<t.t;++i)r[this.t+i-e]=this.am(e-i,t[i],r,0,0,this.t+i-e);r.clamp(),r.drShiftTo(1,r)},E.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var i=this.t-1;i>=0;--i)r=(e*r+this[i])%t;return r},E.prototype.millerRabin=function(t){var e=this.subtract(E.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var i=e.shiftRight(r);(t=t+1>>1)>K.length&&(t=K.length);for(var s=x(),n=0;n<t;++n){s.fromInt(K[Math.floor(Math.random()*K.length)]);var a=s.modPow(i,this);if(0!=a.compareTo(E.ONE)&&0!=a.compareTo(e)){for(var o=1;o++<r&&0!=a.compareTo(e);)if(0==(a=a.modPowInt(2,this)).compareTo(E.ONE))return!1;if(0!=a.compareTo(e))return!1}}return!0},E.prototype.clone=function(){var t=x();return this.copyTo(t),t},E.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},E.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},E.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},E.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},E.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,i=this.DB-t*this.DB%8,s=0;if(t-- >0)for(i<this.DB&&(r=this[t]>>i)!=(this.s&this.DM)>>i&&(e[s++]=r|this.s<<this.DB-i);t>=0;)i<8?(r=(this[t]&(1<<i)-1)<<8-i,r|=this[--t]>>(i+=this.DB-8)):(r=this[t]>>(i-=8)&255,i<=0&&(i+=this.DB,--t)),128&r&&(r|=-256),0==s&&(128&this.s)!=(128&r)&&++s,(s>0||r!=this.s)&&(e[s++]=r);return e},E.prototype.equals=function(t){return 0==this.compareTo(t)},E.prototype.min=function(t){return this.compareTo(t)<0?this:t},E.prototype.max=function(t){return this.compareTo(t)>0?this:t},E.prototype.and=function(t){var e=x();return this.bitwiseTo(t,D,e),e},E.prototype.or=function(t){var e=x();return this.bitwiseTo(t,N,e),e},E.prototype.xor=function(t){var e=x();return this.bitwiseTo(t,O,e),e},E.prototype.andNot=function(t){var e=x();return this.bitwiseTo(t,_,e),e},E.prototype.not=function(){for(var t=x(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},E.prototype.shiftLeft=function(t){var e=x();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},E.prototype.shiftRight=function(t){var e=x();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},E.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+B(this[t]);return this.s<0?this.t*this.DB:-1},E.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=L(this[r]^e);return t},E.prototype.testBit=function(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:!!(this[e]&1<<t%this.DB)},E.prototype.setBit=function(t){return this.changeBit(t,N)},E.prototype.clearBit=function(t){return this.changeBit(t,_)},E.prototype.flipBit=function(t){return this.changeBit(t,O)},E.prototype.add=function(t){var e=x();return this.addTo(t,e),e},E.prototype.subtract=function(t){var e=x();return this.subTo(t,e),e},E.prototype.multiply=function(t){var e=x();return this.multiplyTo(t,e),e},E.prototype.divide=function(t){var e=x();return this.divRemTo(t,e,null),e},E.prototype.remainder=function(t){var e=x();return this.divRemTo(t,null,e),e},E.prototype.divideAndRemainder=function(t){var e=x(),r=x();return this.divRemTo(t,e,r),new Array(e,r)},E.prototype.modPow=function(t,e){var r,i,s=t.bitLength(),n=C(1);if(s<=0)return n;r=s<18?1:s<48?3:s<144?4:s<768?5:6,i=s<8?new T(e):e.isEven()?new U(e):new P(e);var a=new Array,o=3,h=r-1,u=(1<<r)-1;if(a[1]=i.convert(this),r>1){var c=x();for(i.sqrTo(a[1],c);o<=u;)a[o]=x(),i.mulTo(c,a[o-2],a[o]),o+=2}var l,g,p=t.t-1,d=!0,f=x();for(s=R(t[p])-1;p>=0;){for(s>=h?l=t[p]>>s-h&u:(l=(t[p]&(1<<s+1)-1)<<h-s,p>0&&(l|=t[p-1]>>this.DB+s-h)),o=r;!(1&l);)l>>=1,--o;if((s-=o)<0&&(s+=this.DB,--p),d)a[l].copyTo(n),d=!1;else{for(;o>1;)i.sqrTo(n,f),i.sqrTo(f,n),o-=2;o>0?i.sqrTo(n,f):(g=n,n=f,f=g),i.mulTo(f,a[l],n)}for(;p>=0&&!(t[p]&1<<s);)i.sqrTo(n,f),g=n,n=f,f=g,--s<0&&(s=this.DB-1,--p)}return i.revert(n)},E.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return E.ZERO;for(var r=t.clone(),i=this.clone(),s=C(1),n=C(0),a=C(0),o=C(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(s.isEven()&&n.isEven()||(s.addTo(this,s),n.subTo(t,n)),s.rShiftTo(1,s)):n.isEven()||n.subTo(t,n),n.rShiftTo(1,n);for(;i.isEven();)i.rShiftTo(1,i),e?(a.isEven()&&o.isEven()||(a.addTo(this,a),o.subTo(t,o)),a.rShiftTo(1,a)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);r.compareTo(i)>=0?(r.subTo(i,r),e&&s.subTo(a,s),n.subTo(o,n)):(i.subTo(r,i),e&&a.subTo(s,a),o.subTo(n,o))}return 0!=i.compareTo(E.ONE)?E.ZERO:o.compareTo(t)>=0?o.subtract(t):o.signum()<0?(o.addTo(t,o),o.signum()<0?o.add(t):o):o},E.prototype.pow=function(t){return this.exp(t,new H)},E.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var i=e;e=r,r=i}var s=e.getLowestSetBit(),n=r.getLowestSetBit();if(n<0)return e;for(s<n&&(n=s),n>0&&(e.rShiftTo(n,e),r.rShiftTo(n,r));e.signum()>0;)(s=e.getLowestSetBit())>0&&e.rShiftTo(s,e),(s=r.getLowestSetBit())>0&&r.rShiftTo(s,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return n>0&&r.lShiftTo(n,r),r},E.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=K[K.length-1]){for(e=0;e<K.length;++e)if(r[0]==K[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<K.length;){for(var i=K[e],s=e+1;s<K.length&&i<q;)i*=K[s++];for(i=r.modInt(i);e<s;)if(i%K[e++]==0)return!1}return r.millerRabin(t)},E.prototype.square=function(){var t=x();return this.squareTo(t),t},G.prototype.init=function(t){var e,r,i;for(e=0;e<256;++e)this.S[e]=e;for(r=0,e=0;e<256;++e)r=r+this.S[e]+t[e%t.length]&255,i=this.S[e],this.S[e]=this.S[r],this.S[r]=i;this.i=0,this.j=0},G.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]},null==j){var $;if(j=new Array,M=0,void 0!==d&&(void 0!==d.crypto||void 0!==d.msCrypto)){var X=d.crypto||d.msCrypto;if(X.getRandomValues){var z=new Uint8Array(32);for(X.getRandomValues(z),$=0;$<32;++$)j[M++]=z[$]}else if("Netscape"==p.appName&&p.appVersion<"5"){var Y=d.crypto.random(32);for($=0;$<Y.length;++$)j[M++]=255&Y.charCodeAt($)}}for(;M<256;)$=Math.floor(65536*Math.random()),j[M++]=$>>>8,j[M++]=255&$;M=0,W()}function J(){if(null==V){for(W(),(V=new G).init(j),M=0;M<j.length;++M)j[M]=0;M=0}return V.next()}function Q(){}function Z(t,e){return new E(t,e)}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){this.x=e,this.q=t}function rt(t,e,r,i){this.curve=t,this.x=e,this.y=r,this.z=null==i?E.ONE:i,this.zinv=null}function it(t,e,r){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(r),this.infinity=new rt(this,null,null)}Q.prototype.nextBytes=function(t){var e;for(e=0;e<t.length;++e)t[e]=J()},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=Z(t,16),this.e=parseInt(e,16)}},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=Z(t,16),this.e=parseInt(e,16),this.d=Z(r,16)}},tt.prototype.setPrivateEx=function(t,e,r,i,s,n,a,o){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=Z(t,16),this.e=parseInt(e,16),this.d=Z(r,16),this.p=Z(i,16),this.q=Z(s,16),this.dmp1=Z(n,16),this.dmq1=Z(a,16),this.coeff=Z(o,16)},tt.prototype.generate=function(t,e){var r=new Q,i=t>>1;this.e=parseInt(e,16);for(var s=new E(e,16),n=t/2-100,a=E.ONE.shiftLeft(n);;){for(;this.p=new E(t-i,1,r),0!=this.p.subtract(E.ONE).gcd(s).compareTo(E.ONE)||!this.p.isProbablePrime(10););for(;this.q=new E(i,1,r),0!=this.q.subtract(E.ONE).gcd(s).compareTo(E.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var o=this.p;this.p=this.q,this.q=o}var h=this.q.subtract(this.p).abs();if(!(h.bitLength()<n||h.compareTo(a)<=0)){var u=this.p.subtract(E.ONE),c=this.q.subtract(E.ONE),l=u.multiply(c);if(0==l.gcd(s).compareTo(E.ONE)&&(this.n=this.p.multiply(this.q),this.n.bitLength()==t)){this.d=s.modInverse(l),this.dmp1=this.d.mod(u),this.dmq1=this.d.mod(c),this.coeff=this.q.modInverse(this.p);break}}}this.isPrivate=!0},et.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},et.prototype.toBigInteger=function(){return this.x},et.prototype.negate=function(){return new et(this.q,this.x.negate().mod(this.q))},et.prototype.add=function(t){return new et(this.q,this.x.add(t.toBigInteger()).mod(this.q))},et.prototype.subtract=function(t){return new et(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},et.prototype.multiply=function(t){return new et(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},et.prototype.square=function(){return new et(this.q,this.x.square().mod(this.q))},et.prototype.divide=function(t){return new et(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},et.prototype.sqrt=function(){return new et(this.q,this.x.sqrt().mod(this.q))},rt.prototype.getX=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},rt.prototype.getY=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},rt.prototype.equals=function(t){return t==this||(this.isInfinity()?t.isInfinity():t.isInfinity()?this.isInfinity():!!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(E.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(E.ZERO))},rt.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(E.ZERO)&&!this.y.toBigInteger().equals(E.ZERO)},rt.prototype.negate=function(){return new rt(this.curve,this.x,this.y.negate(),this.z)},rt.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q),r=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q);if(E.ZERO.equals(r))return E.ZERO.equals(e)?this.twice():this.curve.getInfinity();var i=new E("3"),s=this.x.toBigInteger(),n=this.y.toBigInteger(),a=(t.x.toBigInteger(),t.y.toBigInteger(),r.square()),o=a.multiply(r),h=s.multiply(a),u=e.square().multiply(this.z),c=u.subtract(h.shiftLeft(1)).multiply(t.z).subtract(o).multiply(r).mod(this.curve.q),l=h.multiply(i).multiply(e).subtract(n.multiply(o)).subtract(u.multiply(e)).multiply(t.z).add(e.multiply(o)).mod(this.curve.q),g=o.multiply(this.z).multiply(t.z).mod(this.curve.q);return new rt(this.curve,this.curve.fromBigInteger(c),this.curve.fromBigInteger(l),g)},rt.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=new E("3"),e=this.x.toBigInteger(),r=this.y.toBigInteger(),i=r.multiply(this.z),s=i.multiply(r).mod(this.curve.q),n=this.curve.a.toBigInteger(),a=e.square().multiply(t);E.ZERO.equals(n)||(a=a.add(this.z.square().multiply(n)));var o=(a=a.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(s)).shiftLeft(1).multiply(i).mod(this.curve.q),h=a.multiply(t).multiply(e).subtract(s.shiftLeft(1)).shiftLeft(2).multiply(s).subtract(a.square().multiply(a)).mod(this.curve.q),u=i.square().multiply(i).shiftLeft(3).mod(this.curve.q);return new rt(this.curve,this.curve.fromBigInteger(o),this.curve.fromBigInteger(h),u)},rt.prototype.multiply=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,r=t,i=r.multiply(new E("3")),s=this.negate(),n=this,a=this.curve.q.subtract(t),o=a.multiply(new E("3")),h=new rt(this.curve,this.x,this.y),u=h.negate();for(e=i.bitLength()-2;e>0;--e){n=n.twice();var c=i.testBit(e);c!=r.testBit(e)&&(n=n.add(c?this:s))}for(e=o.bitLength()-2;e>0;--e){h=h.twice();var l=o.testBit(e);l!=a.testBit(e)&&(h=h.add(l?h:u))}return n},rt.prototype.multiplyTwo=function(t,e,r){var i;i=t.bitLength()>r.bitLength()?t.bitLength()-1:r.bitLength()-1;for(var s=this.curve.getInfinity(),n=this.add(e);i>=0;)s=s.twice(),t.testBit(i)?s=r.testBit(i)?s.add(n):s.add(this):r.testBit(i)&&(s=s.add(e)),--i;return s},it.prototype.getQ=function(){return this.q},it.prototype.getA=function(){return this.a},it.prototype.getB=function(){return this.b},it.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},it.prototype.getInfinity=function(){return this.infinity},it.prototype.fromBigInteger=function(t){return new et(this.q,t)},it.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:var e=t.substr(0,2),r=(t.substr(2),this.fromBigInteger(new E(o,16))),i=this.getA(),s=this.getB(),n=r.square().add(i).multiply(r).add(s).sqrt();return"03"==e&&(n=n.negate()),new rt(this,r,n);case 4:case 6:case 7:var a=(t.length-2)/2,o=t.substr(2,a),h=t.substr(a+2,a);return new rt(this,this.fromBigInteger(new E(o,16)),this.fromBigInteger(new E(h,16)));default:return null}},et.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},rt.prototype.getEncoded=function(t){var e=function(t,e){var r=t.toByteArrayUnsigned();if(e<r.length)r=r.slice(r.length-e);else for(;e>r.length;)r.unshift(0);return r},r=this.getX().toBigInteger(),i=this.getY().toBigInteger(),s=e(r,32);return t?i.isEven()?s.unshift(2):s.unshift(3):(s.unshift(4),s=s.concat(e(i,32))),s},rt.decodeFrom=function(t,e){e[0];var r=e.length-1,i=e.slice(1,1+r/2),s=e.slice(1+r/2,1+r);i.unshift(0),s.unshift(0);var n=new E(i),a=new E(s);return new rt(t,t.fromBigInteger(n),t.fromBigInteger(a))},rt.decodeFromHex=function(t,e){e.substr(0,2);var r=e.length-2,i=e.substr(2,r/2),s=e.substr(2+r/2,r/2),n=new E(i,16),a=new E(s,16);return new rt(t,t.fromBigInteger(n),t.fromBigInteger(a))},rt.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),r=t.y.subtract(this.y).divide(e),i=r.square().subtract(this.x).subtract(t.x),s=r.multiply(this.x.subtract(i)).subtract(this.y);return new rt(this.curve,i,s)},rt.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=this.curve.fromBigInteger(E.valueOf(2)),e=this.curve.fromBigInteger(E.valueOf(3)),r=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),i=r.square().subtract(this.x.multiply(t)),s=r.multiply(this.x.subtract(i)).subtract(this.y);return new rt(this.curve,i,s)},rt.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,r=t,i=r.multiply(new E("3")),s=this.negate(),n=this;for(e=i.bitLength()-2;e>0;--e){n=n.twice();var a=i.testBit(e);a!=r.testBit(e)&&(n=n.add2D(a?this:s))}return n},rt.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),r=this.curve.getA().toBigInteger(),i=this.curve.getB().toBigInteger(),s=this.curve.getQ(),n=e.multiply(e).mod(s),a=t.multiply(t).multiply(t).add(r.multiply(t)).add(i).mod(s);return n.equals(a)},rt.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},rt.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),r=this.getY().toBigInteger();if(e.compareTo(E.ONE)<0||e.compareTo(t.subtract(E.ONE))>0)throw new Error("x coordinate out of bounds");if(r.compareTo(E.ONE)<0||r.compareTo(t.subtract(E.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0};var st=function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),r={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function i(t,e,i){return e?r[e]:String.fromCharCode(parseInt(i,16))}var s=new String(""),n=Object.hasOwnProperty;return function(r,a){var o,h,u=r.match(t),c=u[0],l=!1;"{"===c?o={}:"["===c?o=[]:(o=[],l=!0);for(var g=[o],p=1-l,d=u.length;p<d;++p){var f;switch((c=u[p]).charCodeAt(0)){default:(f=g[0])[h||f.length]=+c,h=void 0;break;case 34:if(-1!==(c=c.substring(1,c.length-1)).indexOf("\\")&&(c=c.replace(e,i)),f=g[0],!h){if(!(f instanceof Array)){h=c||s;break}h=f.length}f[h]=c,h=void 0;break;case 91:f=g[0],g.unshift(f[h||f.length]=[]),h=void 0;break;case 93:case 125:g.shift();break;case 102:(f=g[0])[h||f.length]=!1,h=void 0;break;case 110:(f=g[0])[h||f.length]=null,h=void 0;break;case 116:(f=g[0])[h||f.length]=!0,h=void 0;break;case 123:f=g[0],g.unshift(f[h||f.length]={}),h=void 0}}if(l){if(1!==g.length)throw new Error;o=o[0]}else if(g.length)throw new Error;if(a){var y=function(t,e){var r=t[e];if(r&&"object"==typeof r){var i=null;for(var s in r)if(n.call(r,s)&&r!==t){var o=y(r,s);void 0!==o?r[s]=o:(i||(i=[]),i.push(s))}if(i)for(var h=i.length;--h>=0;)delete r[i[h]]}return a.call(t,e,r)};o=y({"":o},"")}return o}}();void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),nt.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){return Ht(t)},this.getPEMStringFromHex=function(t,e){return Et(t,e)},this.newObject=function(t){var e=nt.asn1,r=e.ASN1Object,i=e.DERBoolean,s=e.DERInteger,n=e.DERBitString,a=e.DEROctetString,o=e.DERNull,h=e.DERObjectIdentifier,u=e.DEREnumerated,c=e.DERUTF8String,l=e.DERNumericString,g=e.DERPrintableString,p=e.DERTeletexString,d=e.DERIA5String,f=e.DERUTCTime,y=e.DERGeneralizedTime,v=e.DERVisibleString,m=e.DERBMPString,S=e.DERSequence,E=e.DERSet,x=e.DERTaggedObject,A=e.ASN1Util.newObject;if(t instanceof e.ASN1Object)return t;var w=Object.keys(t);if(1!=w.length)throw new Error("key of param shall be only one.");var b=w[0];if(-1==":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+b+":"))throw new Error("undefined key: "+b);if("bool"==b)return new i(t[b]);if("int"==b)return new s(t[b]);if("bitstr"==b)return new n(t[b]);if("octstr"==b)return new a(t[b]);if("null"==b)return new o(t[b]);if("oid"==b)return new h(t[b]);if("enum"==b)return new u(t[b]);if("utf8str"==b)return new c(t[b]);if("numstr"==b)return new l(t[b]);if("prnstr"==b)return new g(t[b]);if("telstr"==b)return new p(t[b]);if("ia5str"==b)return new d(t[b]);if("utctime"==b)return new f(t[b]);if("gentime"==b)return new y(t[b]);if("visstr"==b)return new v(t[b]);if("bmpstr"==b)return new m(t[b]);if("asn1"==b)return new r(t[b]);if("seq"==b){for(var F=t[b],I=[],C=0;C<F.length;C++){var R=A(F[C]);I.push(R)}return new S({array:I})}if("set"==b){for(F=t[b],I=[],C=0;C<F.length;C++)R=A(F[C]),I.push(R);return new E({array:I})}if("tag"==b){var T=t[b];if("[object Array]"===Object.prototype.toString.call(T)&&3==T.length){var P=A(T[2]);return new x({tag:T[0],explicit:T[1],obj:P})}return new x(T)}},this.jsonToASN1HEX=function(t){return this.newObject(t).tohex()}},nt.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",r=parseInt(t.substr(0,2),16),i=(e=Math.floor(r/40)+"."+r%40,""),s=2;s<t.length;s+=2){var n=("00000000"+parseInt(t.substr(s,2),16).toString(2)).slice(-8);i+=n.substr(1,7),"0"==n.substr(0,1)&&(e=e+"."+new E(i,2).toString(10),i="")}return e},nt.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="",i=new E(t,10).toString(2),s=7-i.length%7;7==s&&(s=0);for(var n="",a=0;a<s;a++)n+="0";for(i=n+i,a=0;a<i.length-1;a+=7){var o=i.substr(a,7);a!=i.length-7&&(o="1"+o),r+=e(parseInt(o,2))}return r};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var i="",s=t.split("."),n=40*parseInt(s[0])+parseInt(s[1]);i+=e(n),s.splice(0,2);for(var a=0;a<s.length;a++)i+=r(s[a]);return i},nt.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=0,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 new Error("ASN.1 length too long to represent by 8x: n = "+t.toString(16));return(128+r).toString(16)+e},this.tohex=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.getEncodedHex=function(){return this.tohex()},this.getValueHex=function(){return this.tohex(),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)},nt.asn1.DERAbstractString=function(t){nt.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=ft(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))},jt(nt.asn1.DERAbstractString,nt.asn1.ASN1Object),nt.asn1.DERAbstractTime=function(t){nt.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 i=this.zeroPadding,s=this.localDateToUTC(t),n=String(s.getFullYear());"utc"==e&&(n=n.substr(2,2));var a=n+i(String(s.getMonth()+1),2)+i(String(s.getDate()),2)+i(String(s.getHours()),2)+i(String(s.getMinutes()),2)+i(String(s.getSeconds()),2);if(!0===r){var o=s.getMilliseconds();if(0!=o){var h=i(String(o),3);a=a+"."+(h=h.replace(/[0]+$/,""))}}return a+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.setByParam=function(t){this.hV=null,this.hTLV=null,this.params=t},this.getString=function(){},this.setString=function(t){this.hTLV=null,this.isModified=!0,null==this.params&&(this.params={}),this.params.str=t},this.setByDate=function(t){this.hTLV=null,this.isModified=!0,null==this.params&&(this.params={}),this.params.date=t},this.setByDateValue=function(t,e,r,i,s,n){var a=new Date(Date.UTC(t,e-1,r,i,s,n,0));this.setByDate(a)},this.getFreshValueHex=function(){return this.hV}},jt(nt.asn1.DERAbstractTime,nt.asn1.ASN1Object),nt.asn1.DERAbstractStructured=function(t){nt.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)},jt(nt.asn1.DERAbstractStructured,nt.asn1.ASN1Object),nt.asn1.DERBoolean=function(t){nt.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=0==t?"010100":"0101ff"},jt(nt.asn1.DERBoolean,nt.asn1.ASN1Object),nt.asn1.DERInteger=function(t){nt.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.params=null;var e=Ht;this.setByBigInteger=function(t){this.isModified=!0,this.params={bigint:t}},this.setByInteger=function(t){this.isModified=!0,this.params=t},this.setValueHex=function(t){this.isModified=!0,this.params={hex:t}},this.getFreshValueHex=function(){var t=this.params,r=null;if(null==t)throw new Error("value not set");if("object"==typeof t&&null!=t.hex)return this.hV=t.hex,this.hV;if("number"==typeof t)r=new E(String(t),10);else if(null!=t.int)r=new E(String(t.int),10);else{if(null==t.bigint)throw new Error("wrong parameter");r=t.bigint}return this.hV=e(r),this.hV},null!=t&&(this.params=t)},jt(nt.asn1.DERInteger,nt.asn1.ASN1Object),nt.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=nt.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.tohex()}nt.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),t+="0000000".substr(0,e);for(var r="",i=0;i<t.length-1;i+=8){var s=t.substr(i,8),n=parseInt(s,2).toString(16);1==n.length&&(n="0"+n),r+=n}this.hTLV=null,this.isModified=!0,this.hV="0"+e+r},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))},jt(nt.asn1.DERBitString,nt.asn1.ASN1Object),nt.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=nt.asn1.ASN1Util.newObject(t.obj);t.hex=e.tohex()}nt.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},jt(nt.asn1.DEROctetString,nt.asn1.DERAbstractString),nt.asn1.DERNull=function(){nt.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},jt(nt.asn1.DERNull,nt.asn1.ASN1Object),nt.asn1.DERObjectIdentifier=function(t){nt.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="",i=parseInt(t,10).toString(2),s=7-i.length%7;7==s&&(s=0);for(var n="",a=0;a<s;a++)n+="0";for(i=n+i,a=0;a<i.length-1;a+=7){var o=i.substr(a,7);a!=i.length-7&&(o="1"+o),r+=e(parseInt(o,2))}return r};try{if(!t.match(/^[0-9.]+$/))return null;var i="",s=t.split("."),n=40*parseInt(s[0],10)+parseInt(s[1],10);i+=e(n),s.splice(0,2);for(var a=0;a<s.length;a++)i+=r(s[a]);return i}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=nt.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)},jt(nt.asn1.DERObjectIdentifier,nt.asn1.ASN1Object),nt.asn1.DEREnumerated=function(t){nt.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=Ht(t)},this.setByInteger=function(t){var e=new E(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))},jt(nt.asn1.DEREnumerated,nt.asn1.ASN1Object),nt.asn1.DERUTF8String=function(t){nt.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},jt(nt.asn1.DERUTF8String,nt.asn1.DERAbstractString),nt.asn1.DERNumericString=function(t){nt.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},jt(nt.asn1.DERNumericString,nt.asn1.DERAbstractString),nt.asn1.DERPrintableString=function(t){nt.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},jt(nt.asn1.DERPrintableString,nt.asn1.DERAbstractString),nt.asn1.DERTeletexString=function(t){nt.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},jt(nt.asn1.DERTeletexString,nt.asn1.DERAbstractString),nt.asn1.DERIA5String=function(t){nt.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},jt(nt.asn1.DERIA5String,nt.asn1.DERAbstractString),nt.asn1.DERVisibleString=function(t){nt.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="1a"},jt(nt.asn1.DERVisibleString,nt.asn1.DERAbstractString),nt.asn1.DERBMPString=function(t){nt.asn1.DERBMPString.superclass.constructor.call(this,t),this.hT="1e"},jt(nt.asn1.DERBMPString,nt.asn1.DERAbstractString),nt.asn1.DERUTCTime=function(t){nt.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.params=void 0,this.getFreshValueHex=function(){var t=this.params;if(null==this.params&&(t={date:new Date}),"string"==typeof t){if(!t.match(/^[0-9]{12}Z$/)&&!t.match(/^[0-9]{12}\.[0-9]+Z$/))throw new Error("malformed string for UTCTime: "+t);this.hV=ct(t)}else if(null!=t.str)this.hV=ct(t.str);else if(null==t.date&&1==t.millis){var e=new Date;this.hV=ct(this.formatDate(e,"utc",!0))}else if(null!=t.date&&t.date instanceof Date){var r=!0===t.millis;this.hV=ct(this.formatDate(t.date,"utc",r))}else t instanceof Date&&(this.hV=ct(this.formatDate(t,"utc")));if(null==this.hV)throw new Error("parameter not specified properly for UTCTime");return this.hV},null!=t&&this.setByParam(t)},jt(nt.asn1.DERUTCTime,nt.asn1.DERAbstractTime),nt.asn1.DERGeneralizedTime=function(t){nt.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.params=t,this.getFreshValueHex=function(){var t=this.params;if(null==this.params&&(t={date:new Date}),"string"==typeof t){if(!t.match(/^[0-9]{14}Z$/)&&!t.match(/^[0-9]{14}\.[0-9]+Z$/))throw new Error("malformed string for GeneralizedTime: "+t);this.hV=ct(t)}else if(null!=t.str)this.hV=ct(t.str);else if(null==t.date&&1==t.millis){var e=new Date;this.hV=ct(this.formatDate(e,"gen",!0))}else if(null!=t.date&&t.date instanceof Date){var r=!0===t.millis;this.hV=ct(this.formatDate(t.date,"gen",r))}else t instanceof Date&&(this.hV=ct(this.formatDate(t,"gen")));if(null==this.hV)throw new Error("parameter not specified properly for GeneralizedTime");return this.hV},null!=t&&this.setByParam(t)},jt(nt.asn1.DERGeneralizedTime,nt.asn1.DERAbstractTime),nt.asn1.DERSequence=function(t){nt.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].tohex();return this.hV=t,this.hV}},jt(nt.asn1.DERSequence,nt.asn1.DERAbstractStructured),nt.asn1.DERSet=function(t){nt.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.tohex())}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)},jt(nt.asn1.DERSet,nt.asn1.DERAbstractStructured),nt.asn1.DERTaggedObject=function(t){nt.asn1.DERTaggedObject.superclass.constructor.call(this);var e=nt.asn1,r=ht,i=r.getV,s=(r.isASN1HEX,e.ASN1Util.newObject);this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.params={tag:"a0",explicit:!0},this.setASN1Object=function(t,e,r){this.params={tag:e,explicit:t,obj:r}},this.getFreshValueHex=function(){var t=this.params;if(null==t.explicit&&(t.explicit=!0),null!=t.tage&&(t.tag=t.tage,t.explicit=!0),null!=t.tagi&&(t.tag=t.tagi,t.explicit=!1),null!=t.str)this.hV=ft(t.str);else if(null!=t.hex)this.hV=t.hex;else{if(null==t.obj)throw new Error("str, hex nor obj not specified");var r;t.obj instanceof e.ASN1Object?r=t.obj.tohex():"object"==typeof t.obj&&(r=s(t.obj).tohex()),t.explicit?this.hV=r:this.hV=i(r,0)}return null==t.tag&&(t.tag="a0"),this.hT=t.tag,this.hTLV=null,this.isModified=!0,this.hV},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},jt(nt.asn1.DERTaggedObject,nt.asn1.ASN1Object);var nt,at,ot,ht=new function(){};function ut(t){for(var e="",r=0;r<t.length;r++){var i=t[r].toString(16);1==i.length&&(i="0"+i),e+=i}return e}function ct(t){return ut(function(t){for(var e=new Array,r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}(t))}function lt(t){return(t=(t=t.replace(/\=/g,"")).replace(/\+/g,"-")).replace(/\//g,"_")}function gt(t){return t.length%4==2?t+="==":t.length%4==3&&(t+="="),(t=t.replace(/-/g,"+")).replace(/_/g,"/")}function pt(t){return t.length%2==1&&(t="0"+t),lt(m(t))}function dt(t){return S(gt(t))}function ft(t){return At(Dt(t)).toLowerCase()}function yt(t){try{return decodeURIComponent(wt(t))}catch(t){return null}}function vt(t){return yt(function(t){for(var e=t.match(/.{1,2}/g),r=[],i=0;i<e.length;i++){var s=parseInt(e[i],16);161<=s&&s<=191?(r.push("c2"),r.push(e[i])):192<=s&&s<=255?(r.push("c3"),r.push((s-64).toString(16))):r.push(e[i])}return r.join("")}(t))}function mt(t){for(var e="",r=0;r<t.length-1;r+=2)e+=String.fromCharCode(parseInt(t.substr(r,2),16));return e}function St(t){for(var e="",r=0;r<t.length;r++)e+=("0"+t.charCodeAt(r).toString(16)).slice(-2);return e}function Et(t,e){return"-----BEGIN "+e+"-----\r\n"+function(t){return(t=t.replace(new RegExp("(.{64})","g"),"$1\r\n")).replace(/\s+$/,"")}(function(t){return m(t)}(t))+"\r\n-----END "+e+"-----\r\n"}function xt(t,e){if(-1==t.indexOf("-----BEGIN "))throw new Error("can't find PEM header");return function(t){return S(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 At(t){return t.replace(/%/g,"")}function wt(t){return t.replace(/(..)/g,"%$1")}function bt(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 i=":".repeat(7-r+2),s=(t=t.replace("::",i)).split(":");if(8!=s.length)throw e;for(var n=0;n<8;n++)s[n]=("0000"+s[n]).slice(-4);return s.join("")}function Ft(t){if(!t.match(/^[0-9A-Fa-f]{32}$/))throw new Error("malformed IPv6 address: "+t);var e=(t=t.toLowerCase()).match(/.{1,4}/g);e=e.map(function(t){return t.replace(/^0+/,"")}),e=e.map(function(t){return""==t?"0":t});var r=(t=":"+e.join(":")+":").match(/:(0:){2,}/g);if(null==r)return t.slice(1,-1);var i=r.sort().slice(-1)[0];return"::"!=(t=t.replace(i.substr(0,i.length-1),":")).substr(0,2)&&(t=t.substr(1)),"::"!=t.substr(-2,2)&&(t=t.substr(0,t.length-1)),t}function It(t){var e=new Error("malformed hex value");if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8==t.length)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}else if(16==t.length)try{return It(t.substr(0,8))+"/"+Ct(t.substr(8))}catch(t){throw e}else{if(32==t.length)return Ft(t);if(64!=t.length)return t;try{return Ft(t.substr(0,32))+"/"+Ct(t.substr(32))}catch(t){throw e}}}function Ct(t){var e,r=new Error("malformed mask");try{e=new E(t,16).toString(2)}catch(t){throw r}if(!e.match(/^1*0*$/))throw r;return e.replace(/0+$/,"").length}function Rt(t){var e=new Error("malformed IP address");if(!(t=t.toLowerCase(t)).match(/^[0-9a-f.:/]+$/))throw e;if(!t.match(/^[0-9.]+$/)){var r;if(t.match(/^[0-9.]+\/[0-9]+$/))return Rt((r=t.split("/"))[0])+Tt(parseInt(r[1]),32);if(t.match(/^[0-9a-f:]+$/)&&-1!==t.indexOf(":"))return bt(t);if(t.match(/^[0-9a-f:]+\/[0-9]+$/)&&-1!==t.indexOf(":"))return bt((r=t.split("/"))[0])+Tt(parseInt(r[1]),128);throw e}var i=t.split(".");if(4!==i.length)throw e;var s="";try{for(var n=0;n<4;n++)s+=("0"+parseInt(i[n]).toString(16)).slice(-2);return s}catch(t){throw e}}function Tt(t,e){return 32==e&&0==t?"00000000":128==e&&0==t?"00000000000000000000000000000000":new E(Array(t+1).join("1")+Array(e-t+1).join("0"),2).toString(16)}function Pt(t){var e=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 i=128|63&r;return yt((192|(7&e)<<3|(192&r)>>6).toString(16)+i.toString(16))}i=128|(15&e)<<2|(192&r)>>6;var s=128|63&r;return yt((224|(240&e)>>4).toString(16)+i.toString(16)+s.toString(16))});return e.join("")}function Dt(t){for(var e=encodeURIComponent(t),r="",i=0;i<e.length;i++)"%"==e[i]?(r+=e.substr(i,3),i+=2):r=r+"%"+ct(e[i]);return r}function Nt(t){return!(t.length%2!=0||!t.match(/^[0-9a-f]+$/)&&!t.match(/^[0-9A-F]+$/))}function Ot(t){return!!t.match(/^[0-9A-Za-z-_.]+$/)}function _t(t){return t.length%2==1?"0"+t:t.substr(0,1)>"7"?"00"+t:t}function Bt(t){if(!Nt(t))return null;try{var e=[],r=t.substr(0,2),i=parseInt(r,16);e[0]=new String(Math.floor(i/40)),e[1]=new String(i%40);for(var s=t.substr(2),n=[],a=0;a<s.length/2;a++)n.push(parseInt(s.substr(2*a,2),16));var o=[],h="";for(a=0;a<n.length;a++)128&n[a]?h+=kt((127&n[a]).toString(2),7):(h+=kt((127&n[a]).toString(2),7),o.push(new String(parseInt(h,2))),h="");var u=e.join(".");return o.length>0&&(u=u+"."+o.join(".")),u}catch(t){return null}}function Lt(t){return Ht(new E(String(t),10))}function Ht(t){var e=t.toString(16);if("-"!=e.substr(0,1))return e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e),e;var r=e.substr(1).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var i="",s=0;s<r;s++)i+="f";return new E(i,16).xor(t).add(E.ONE).toString(16).replace(/^-/,"")}ht.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},ht.getL=function(t,e){var r=ht.getLblen(t,e);return r<1?"":t.substr(e+2,2*r)},ht.getVblen=function(t,e){var r;return""==(r=ht.getL(t,e))?-1:("8"===r.substr(0,1)?new E(r.substr(2),16):new E(r,16)).intValue()},ht.getVidx=function(t,e){var r=ht.getLblen(t,e);return r<0?r:e+2*(r+1)},ht.getV=function(t,e){var r=ht.getVidx(t,e),i=ht.getVblen(t,e);return t.substr(r,2*i)},ht.getTLV=function(t,e){return t.substr(e,2)+ht.getL(t,e)+ht.getV(t,e)},ht.getTLVblen=function(t,e){return 2+2*ht.getLblen(t,e)+2*ht.getVblen(t,e)},ht.getNextSiblingIdx=function(t,e){return ht.getVidx(t,e)+2*ht.getVblen(t,e)},ht.getChildIdx=function(t,e){var r,i,s,n=ht,a=[];r=n.getVidx(t,e),i=2*n.getVblen(t,e),"03"==t.substr(e,2)&&(r+=2,i-=2),s=0;for(var o=r;s<=i;){var h=n.getTLVblen(t,o);if((s+=h)<=i&&a.push(o),o+=h,s>=i)break}return a},ht.getNthChildIdx=function(t,e,r){return ht.getChildIdx(t,e)[r]},ht.getIdxbyList=function(t,e,r,i){var s,n,a=ht;return 0==r.length?void 0!==i&&t.substr(e,2)!==i?-1:e:(s=r.shift())>=(n=a.getChildIdx(t,e)).length?-1:a.getIdxbyList(t,n[s],r,i)},ht.getIdxbyListEx=function(t,e,r,i){var s,n,a=ht;if(0==r.length)return void 0!==i&&t.substr(e,2)!==i?-1:e;s=r.shift(),n=a.getChildIdx(t,e);for(var o=0,h=0;h<n.length;h++){var u=t.substr(n[h],2);if("number"==typeof s&&!a.isContextTag(u)&&o==s||"string"==typeof s&&a.isContextTag(u,s))return a.getIdxbyListEx(t,n[h],r,i);a.isContextTag(u)||o++}return-1},ht.getTLVbyList=function(t,e,r,i){var s=ht,n=s.getIdxbyList(t,e,r,i);return-1==n||n>=t.length?null:s.getTLV(t,n)},ht.getTLVbyListEx=function(t,e,r,i){var s=ht,n=s.getIdxbyListEx(t,e,r,i);return-1==n?null:s.getTLV(t,n)},ht.getVbyList=function(t,e,r,i,s){var n,a,o=ht;return-1==(n=o.getIdxbyList(t,e,r,i))||n>=t.length?null:(a=o.getV(t,n),!0===s&&(a=a.substr(2)),a)},ht.getVbyListEx=function(t,e,r,i,s){var n,a,o=ht;return-1==(n=o.getIdxbyListEx(t,e,r,i))?null:(a=o.getV(t,n),"03"==t.substr(n,2)&&!1!==s&&(a=a.substr(2)),a)},ht.getInt=function(t,e,r){null==r&&(r=-1);try{var i=t.substr(e,2);if("02"!=i&&"03"!=i)return r;var s=ht.getV(t,e);return"02"==i?parseInt(s,16):function(t){if(t.length%2!=0)return-1;if(null==(t=t.toLowerCase()).match(/^[0-9a-f]+$/))return-1;try{var e=t.substr(0,2);if("00"==e)return parseInt(t.substr(2),16);var r=parseInt(e,16);if(r>7)return-1;var i=t.substr(2),s=parseInt(i,16).toString(2);"0"==s&&(s="00000000"),s=s.slice(0,0-r);var n=parseInt(s,2);return NaN==n?-1:n}catch(t){return-1}}(s)}catch(t){return r}},ht.getOID=function(t,e,r){null==r&&(r=null);try{return"06"!=t.substr(e,2)?r:Bt(ht.getV(t,e))}catch(t){return r}},ht.getOIDName=function(t,e,r){null==r&&(r=null);try{var i=ht.getOID(t,e,r);if(i==r)return r;var s=nt.asn1.x509.OID.oid2name(i);return""==s?i:s}catch(t){return r}},ht.getString=function(t,e,r){null==r&&(r=null);try{return mt(ht.getV(t,e))}catch(t){return r}},ht.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},r=[],i=t.substr(0,2),s=parseInt(i,16);r[0]=new String(Math.floor(s/40)),r[1]=new String(s%40);for(var n=t.substr(2),a=[],o=0;o<n.length/2;o++)a.push(parseInt(n.substr(2*o,2),16));var h=[],u="";for(o=0;o<a.length;o++)128&a[o]?u+=e((127&a[o]).toString(2),7):(u+=e((127&a[o]).toString(2),7),h.push(new String(parseInt(u,2))),u="");var c=r.join(".");return h.length>0&&(c=c+"."+h.join(".")),c},ht.dump=function(t,e,r,i){var s=ht,n=s.getV,a=s.dump,o=s.getChildIdx,h=t;t instanceof nt.asn1.ASN1Object&&(h=t.tohex());var u=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===i&&(i="");var c,l=e.ommit_long_octet;if("01"==(c=h.substr(r,2)))return"00"==(g=n(h,r))?i+"BOOLEAN FALSE\n":i+"BOOLEAN TRUE\n";if("02"==c)return i+"INTEGER "+u(g=n(h,r),l)+"\n";if("03"==c){var g=n(h,r);return s.isASN1HEX(g.substr(2))?(x=i+"BITSTRING, encapsulates\n")+a(g.substr(2),e,0,i+" "):i+"BITSTRING "+u(g,l)+"\n"}if("04"==c)return g=n(h,r),s.isASN1HEX(g)?(x=i+"OCTETSTRING, encapsulates\n")+a(g,e,0,i+" "):i+"OCTETSTRING "+u(g,l)+"\n";if("05"==c)return i+"NULL\n";if("06"==c){var p=n(h,r),d=nt.asn1.ASN1Util.oidHexToInt(p),f=nt.asn1.x509.OID.oid2name(d),y=d.replace(/\./g," ");return""!=f?i+"ObjectIdentifier "+f+" ("+y+")\n":i+"ObjectIdentifier ("+y+")\n"}if("0a"==c)return i+"ENUMERATED "+parseInt(n(h,r))+"\n";if("0c"==c)return i+"UTF8String '"+yt(n(h,r))+"'\n";if("13"==c)return i+"PrintableString '"+yt(n(h,r))+"'\n";if("14"==c)return i+"TeletexString '"+yt(n(h,r))+"'\n";if("16"==c)return i+"IA5String '"+yt(n(h,r))+"'\n";if("17"==c)return i+"UTCTime "+yt(n(h,r))+"\n";if("18"==c)return i+"GeneralizedTime "+yt(n(h,r))+"\n";if("1a"==c)return i+"VisualString '"+yt(n(h,r))+"'\n";if("1e"==c)return i+"BMPString '"+Pt(n(h,r))+"'\n";if("30"==c){if("3000"==h.substr(r,4))return i+"SEQUENCE {}\n";x=i+"SEQUENCE\n";var v=e;if((2==(E=o(h,r)).length||3==E.length)&&"06"==h.substr(E[0],2)&&"04"==h.substr(E[E.length-1],2)){f=s.oidname(n(h,E[0]));var m=JSON.parse(JSON.stringify(e));m.x509ExtName=f,v=m}for(var S=0;S<E.length;S++)x+=a(h,v,E[S],i+" ");return x}if("31"==c){x=i+"SET\n";var E=o(h,r);for(S=0;S<E.length;S++)x+=a(h,e,E[S],i+" ");return x}if(128&(c=parseInt(c,16))){var x,A=31&c;if(32&c){for(x=i+"["+A+"]\n",E=o(h,r),S=0;S<E.length;S++)x+=a(h,e,E[S],i+" ");return x}return g=n(h,r),ht.isASN1HEX(g)?(x=i+"["+A+"]\n")+a(g,e,0,i+" "):(("68747470"==g.substr(0,8)||"subjectAltName"===e.x509ExtName&&2==A)&&(g=yt(g)),i+"["+A+"] "+g+"\n")}return i+"UNKNOWN("+c+") "+n(h,r)+"\n"},ht.parse=function(t){var e=ht,r=e.parse,i=e.isASN1HEX,s=e.getV,n=e.getTLV,a=e.getChildIdx,o=nt.asn1,h=o.ASN1Util.oidHexToInt,u=o.x509.OID.oid2name,c=yt,l=Pt,g=vt,p={"0c":"utf8str",12:"numstr",13:"prnstr",14:"telstr",16:"ia5str",17:"utctime",18:"gentime","1a":"visstr","1e":"bmpstr",30:"seq",31:"set"},d=t.substr(0,2),f={},y=s(t,0);if("01"==d)return"0101ff"==t?{bool:!0}:{bool:!1};if("02"==d)return{int:{hex:y}};if("03"==d)try{if("00"!=y.substr(0,2))throw"not encap";var v=y.substr(2);if(!i(v))throw"not encap";return{bitstr:{obj:r(v)}}}catch(t){var m=null;return y.length<=10&&(m=function(t){if("string"!=typeof t)return null;if(t.length%2!=0)return null;if(!t.match(/^[0-9a-f]+$/))return null;try{var e=parseInt(t.substr(0,2),16);if(e<0||7<e)return null;for(var r=t.substr(2),i="",s=0;s<r.length;s+=2){var n=r.substr(s,2),a=parseInt(n,16).toString(2);i+=a=("0000000"+a).slice(-8)}return i.substr(0,i.length-e)}catch(t){return null}}(y)),null==m?{bitstr:{hex:y}}:{bitstr:{bin:m}}}else if("04"==d)try{if(!i(y))throw"not encap";return{octstr:{obj:r(y)}}}catch(t){return{octstr:{hex:y}}}else{if("05"==d)return{null:""};if("06"==d){var S=h(y),E=u(S);return""==E?{oid:S}:{oid:E}}if("0a"==d)return y.length>4?{enum:{hex:y}}:{enum:parseInt(y,16)};if("30"==d||"31"==d)return f[p[d]]=function(t){for(var e=[],i=a(t,0),s=0;s<i.length;s++){var o=i[s],h=n(t,o),u=r(h);e.push(u)}return e}(t),f;if("14"==d){var x=g(y);return f[p[d]]={str:x},f}if("1e"==d)return x=l(y),f[p[d]]={str:x},f;if(-1!=":0c:12:13:16:17:18:1a:".indexOf(d))return x=c(y),f[p[d]]={str:x},f;if(d.match(/^8[0-9]$/))return null==(x=c(y))|""==x||null!=x.match(/[\x00-\x1F\x7F-\x9F]/)||null!=x.match(/[\u0000-\u001F\u0080–\u009F]/)?{tag:{tag:d,explicit:!1,hex:y}}:{tag:{tag:d,explicit:!1,str:x}};if(!d.match(/^a[0-9]$/)){var A=new nt.asn1.ASN1Object;return A.hV=y,{asn1:{tlv:d+A.getLengthHexFromValue()+y}}}try{if(!i(y))throw new Error("not encap");return{tag:{tag:d,explicit:!0,obj:r(y)}}}catch(t){return{tag:{tag:d,explicit:!0,hex:y}}}}},ht.isContextTag=function(t,e){var r,i;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]+\]$/)&&!((i=parseInt(e.substr(1,e.length-1),10))>31)&&128==(192&r)&&(31&r)==i}catch(t){return!1}},ht.isASN1HEX=function(t){var e=ht;if(t.length%2==1)return!1;var r=e.getVblen(t,0),i=t.substr(0,2),s=e.getL(t,0);return t.length-i.length-s.length==2*r},ht.checkStrictDER=function(t,e,r,i,s){var n=ht;if(void 0===r){if("string"!=typeof t)throw new Error("not hex string");if(t=t.toLowerCase(),!nt.lang.String.isHex(t))throw new Error("not hex string");r=t.length,s=(i=t.length/2)<128?1:Math.ceil(i.toString(16))+1}if(n.getL(t,e).length>2*s)throw new Error("L of TLV too long: idx="+e);var a=n.getVblen(t,e);if(a>i)throw new Error("value of L too long than hex: idx="+e);var o=n.getTLV(t,e),h=o.length-2-n.getL(t,e).length;if(h!==2*a)throw new Error("V string length and L's value not the same:"+h+"/"+2*a);if(0===e&&t.length!=o.length)throw new Error("total length and TLV length unmatch:"+t.length+"!="+o.length);var u=t.substr(e,2);if("02"===u){var c=n.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(u,16)){for(var l=n.getVblen(t,e),g=0,p=n.getChildIdx(t,e),d=0;d<p.length;d++)g+=n.getTLV(t,p[d]).length,n.checkStrictDER(t,p[d],r,i,s);if(2*l!=g)throw new Error("sum of children's TLV length and L unmatch: "+2*l+"!="+g)}},ht.oidname=function(t){var e=nt.asn1;nt.lang.String.isHex(t)&&(t=e.ASN1Util.oidHexToInt(t));var r=e.x509.OID.oid2name(t);return""===r&&(r=t),r},void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),void 0!==nt.asn1.x509&&nt.asn1.x509||(nt.asn1.x509={}),nt.asn1.x509.Certificate=function(t){nt.asn1.x509.Certificate.superclass.constructor.call(this);var e=nt.asn1,r=e.DERBitString,i=e.DERSequence,s=e.x509,n=s.TBSCertificate,a=s.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.tohex(),i=new nt.crypto.Signature({alg:e});i.init(t.cakey),i.updateHex(r),t.sighex=i.sign()},this.getPEM=function(){return Et(this.tohex(),"CERTIFICATE")},this.tohex=function(){var t=this.params;if(null!=t.tbsobj&&null!=t.tbsobj||(t.tbsobj=new n(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 a({name:t.sigalg})),e.push(new r({hex:"00"+t.sighex})),new i({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&(this.params=t)},jt(nt.asn1.x509.Certificate,nt.asn1.ASN1Object),nt.asn1.x509.TBSCertificate=function(t){nt.asn1.x509.TBSCertificate.superclass.constructor.call(this);var e=nt.asn1,r=e.x509,i=e.DERTaggedObject,s=e.DERInteger,n=e.DERSequence,a=r.AlgorithmIdentifier,o=r.Time,h=r.X500Name,u=r.Extensions,c=r.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=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 i({obj:new s({int:r})});t.push(l)}return t.push(new s(e.serial)),t.push(new a({name:e.sigalg})),t.push(new h(e.issuer)),t.push(new n({array:[new o(e.notbefore),new o(e.notafter)]})),t.push(new h(e.subject)),t.push(new c(Mt.getKey(e.sbjpubkey))),void 0!==e.ext&&e.ext.length>0&&t.push(new i({tag:"a3",obj:new u(e.ext)})),new nt.asn1.DERSequence({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.x509.TBSCertificate,nt.asn1.ASN1Object),nt.asn1.x509.Extensions=function(t){nt.asn1.x509.Extensions.superclass.constructor.call(this);var e=nt.asn1,r=e.DERSequence,i=e.x509;this.aParam=[],this.setByParam=function(t){this.aParam=t},this.tohex=function(){for(var t=[],e=0;e<this.aParam.length;e++){var s=this.aParam[e],n=s.extname,a=null;if(null!=s.extn)a=new i.PrivateExtension(s);else if("subjectKeyIdentifier"==n)a=new i.SubjectKeyIdentifier(s);else if("keyUsage"==n)a=new i.KeyUsage(s);else if("subjectAltName"==n)a=new i.SubjectAltName(s);else if("issuerAltName"==n)a=new i.IssuerAltName(s);else if("basicConstraints"==n)a=new i.BasicConstraints(s);else if("nameConstraints"==n)a=new i.NameConstraints(s);else if("cRLDistributionPoints"==n)a=new i.CRLDistributionPoints(s);else if("certificatePolicies"==n)a=new i.CertificatePolicies(s);else if("policyMappings"==n)a=new i.PolicyMappings(s);else if("policyConstraints"==n)a=new i.PolicyConstraints(s);else if("inhibitAnyPolicy"==n)a=new i.InhibitAnyPolicy(s);else if("authorityKeyIdentifier"==n)a=new i.AuthorityKeyIdentifier(s);else if("extKeyUsage"==n)a=new i.ExtKeyUsage(s);else if("authorityInfoAccess"==n)a=new i.AuthorityInfoAccess(s);else if("cRLNumber"==n)a=new i.CRLNumber(s);else if("cRLReason"==n)a=new i.CRLReason(s);else if("ocspNonce"==n)a=new i.OCSPNonce(s);else if("ocspNoCheck"==n)a=new i.OCSPNoCheck(s);else if("adobeTimeStamp"==n)a=new i.AdobeTimeStamp(s);else{if("subjectDirectoryAttributes"!=n)throw new Error("extension not supported:"+JSON.stringify(s));a=new i.SubjectDirectoryAttributes(s)}null!=a&&t.push(a)}return new r({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.x509.Extensions,nt.asn1.ASN1Object),nt.asn1.x509.Extension=function(t){nt.asn1.x509.Extension.superclass.constructor.call(this);var e=nt.asn1,r=e.DERObjectIdentifier,i=e.DEROctetString,s=(e.DERBitString,e.DERBoolean),n=e.DERSequence;this.tohex=function(){var t=new r({oid:this.oid}),e=new i({hex:this.getExtnValueHex()}),a=new Array;return a.push(t),this.critical&&a.push(new s),a.push(e),new n({array:a}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},jt(nt.asn1.x509.Extension,nt.asn1.ASN1Object),nt.asn1.x509.KeyUsage=function(t){nt.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=Error,r={digitalSignature:0,nonRepudiation:1,keyEncipherment:2,dataEncipherment:3,keyAgreement:4,keyCertSign:5,cRLSign:6,encipherOnly:7,decipherOnly:8};this.getExtnValueHex=function(){var t=this.getBinValue();return this.asn1ExtnValue=new nt.asn1.DERBitString({bin:t}),this.asn1ExtnValue.tohex()},this.getBinValue=function(){var t=this.params;if("object"!=typeof t||"object"!=typeof t.names&&"string"!=typeof t.bin)throw new e("parameter not yet set");if(null!=t.names)return Ut(t.names,r);if(null!=t.bin)return t.bin;throw new e("parameter not set properly")},this.oid="2.5.29.15",void 0!==t&&(this.params=t)},jt(nt.asn1.x509.KeyUsage,nt.asn1.x509.Extension),nt.asn1.x509.BasicConstraints=function(t){nt.asn1.x509.BasicConstraints.superclass.constructor.call(this,t);var e=nt.asn1,r=e.DERBoolean,i=e.DERInteger,s=e.DERSequence;this.getExtnValueHex=function(){var t=new Array;this.cA&&t.push(new r),this.pathLen>-1&&t.push(new i({int:this.pathLen}));var e=new s({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.tohex()},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))},jt(nt.asn1.x509.BasicConstraints,nt.asn1.x509.Extension),nt.asn1.x509.CRLDistributionPoints=function(t){nt.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=nt.asn1,r=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.setByDPArray=function(t){for(var i=[],s=0;s<t.length;s++)if(t[s]instanceof nt.asn1.ASN1Object)i.push(t[s]);else{var n=new r.DistributionPoint(t[s]);i.push(n)}this.asn1ExtnValue=new e.DERSequence({array:i})},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))},jt(nt.asn1.x509.CRLDistributionPoints,nt.asn1.x509.Extension),nt.asn1.x509.DistributionPoint=function(t){nt.asn1.x509.DistributionPoint.superclass.constructor.call(this);var e=nt.asn1,r=e.x509.DistributionPointName;this.tohex=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.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},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}]})))},jt(nt.asn1.x509.DistributionPoint,nt.asn1.ASN1Object),nt.asn1.x509.DistributionPointName=function(t){nt.asn1.x509.DistributionPointName.superclass.constructor.call(this);var e=nt.asn1,r=e.DERTaggedObject;if(this.tohex=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.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},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)}},jt(nt.asn1.x509.DistributionPointName,nt.asn1.ASN1Object),nt.asn1.x509.CertificatePolicies=function(t){nt.asn1.x509.CertificatePolicies.superclass.constructor.call(this,t);var e=nt.asn1,r=e.x509,i=e.DERSequence,s=r.PolicyInformation;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++)t.push(new s(this.params.array[e]));var r=new i({array:t});return this.asn1ExtnValue=r,this.asn1ExtnValue.tohex()},this.oid="2.5.29.32",void 0!==t&&(this.params=t)},jt(nt.asn1.x509.CertificatePolicies,nt.asn1.x509.Extension),nt.asn1.x509.PolicyInformation=function(t){nt.asn1.x509.PolicyInformation.superclass.constructor.call(this,t);var e=nt.asn1,r=e.DERSequence,i=e.DERObjectIdentifier,s=e.x509.PolicyQualifierInfo;this.params=null,this.tohex=function(){if(void 0===this.params.policyoid&&void 0===this.params.array)throw new Error("parameter oid and array missing");var t=[new i(this.params.policyoid)];if(void 0!==this.params.array){for(var e=[],n=0;n<this.params.array.length;n++)e.push(new s(this.params.array[n]));e.length>0&&t.push(new r({array:e}))}return new r({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},jt(nt.asn1.x509.PolicyInformation,nt.asn1.ASN1Object),nt.asn1.x509.PolicyQualifierInfo=function(t){nt.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,t);var e=nt.asn1,r=e.DERSequence,i=e.DERIA5String,s=e.DERObjectIdentifier,n=e.x509.UserNotice;this.params=null,this.tohex=function(){return void 0!==this.params.cps?new r({array:[new s({oid:"1.3.6.1.5.5.7.2.1"}),new i({str:this.params.cps})]}).tohex():null!=this.params.unotice?new r({array:[new s({oid:"1.3.6.1.5.5.7.2.2"}),new n(this.params.unotice)]}).tohex():void 0},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},jt(nt.asn1.x509.PolicyQualifierInfo,nt.asn1.ASN1Object),nt.asn1.x509.UserNotice=function(t){nt.asn1.x509.UserNotice.superclass.constructor.call(this,t);var e=nt.asn1.DERSequence,r=(nt.asn1.DERInteger,nt.asn1.x509.DisplayText),i=nt.asn1.x509.NoticeReference;this.params=null,this.tohex=function(){var t=[];return void 0!==this.params.noticeref&&t.push(new i(this.params.noticeref)),void 0!==this.params.exptext&&t.push(new r(this.params.exptext)),new e({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},jt(nt.asn1.x509.UserNotice,nt.asn1.ASN1Object),nt.asn1.x509.NoticeReference=function(t){nt.asn1.x509.NoticeReference.superclass.constructor.call(this,t);var e=nt.asn1.DERSequence,r=nt.asn1.DERInteger,i=nt.asn1.x509.DisplayText;this.params=null,this.tohex=function(){var t=[];if(void 0!==this.params.org&&t.push(new i(this.params.org)),void 0!==this.params.noticenum){for(var s=[],n=this.params.noticenum,a=0;a<n.length;a++)s.push(new r(n[a]));t.push(new e({array:s}))}if(0==t.length)throw new Error("parameter is empty");return new e({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},jt(nt.asn1.x509.NoticeReference,nt.asn1.ASN1Object),nt.asn1.x509.DisplayText=function(t){nt.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"))},jt(nt.asn1.x509.DisplayText,nt.asn1.DERAbstractString),nt.asn1.x509.PolicyMappings=function(t){nt.asn1.x509.PolicyMappings.superclass.constructor.call(this,t);var e=nt.asn1,r=(e.x509,e.ASN1Util.newObject);this.params=null,this.getExtnValueHex=function(){for(var t=this.params,e=[],i=0;i<t.array.length;i++){var s=t.array[i];e.push({seq:[{oid:s[0]},{oid:s[1]}]})}return this.asn1ExtnValue=r({seq:e}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.33",void 0!==t&&(this.params=t)},jt(nt.asn1.x509.PolicyMappings,nt.asn1.x509.Extension),nt.asn1.x509.PolicyConstraints=function(t){nt.asn1.x509.PolicyConstraints.superclass.constructor.call(this,t);var e=nt.asn1,r=(e.x509,e.ASN1Util.newObject);this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[];return null!=t.reqexp&&e.push({tag:{tagi:"80",obj:{int:t.reqexp}}}),null!=t.inhibit&&e.push({tag:{tagi:"81",obj:{int:t.inhibit}}}),this.asn1ExtnValue=r({seq:e}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.36",void 0!==t&&(this.params=t)},jt(nt.asn1.x509.PolicyConstraints,nt.asn1.x509.Extension),nt.asn1.x509.InhibitAnyPolicy=function(t){nt.asn1.x509.InhibitAnyPolicy.superclass.constructor.call(this,t);var e=nt.asn1,r=(e.x509,e.ASN1Util.newObject);this.params=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=r({int:this.params.skip}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.54",void 0!==t&&(this.params=t)},jt(nt.asn1.x509.InhibitAnyPolicy,nt.asn1.x509.Extension),nt.asn1.x509.NameConstraints=function(t){nt.asn1.x509.NameConstraints.superclass.constructor.call(this,t);var e=nt.asn1,r=e.x509,i=e.ASN1Util.newObject,s=r.GeneralSubtree;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[];if(null!=t.permit&&null!=t.permit.length){for(var r=[],n=0;n<t.permit.length;n++)r.push(new s(t.permit[n]));e.push({tag:{tagi:"a0",obj:{seq:r}}})}if(null!=t.exclude&&null!=t.exclude.length){var a=[];for(n=0;n<t.exclude.length;n++)a.push(new s(t.exclude[n]));e.push({tag:{tagi:"a1",obj:{seq:a}}})}return this.asn1ExtnValue=i({seq:e}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.30",void 0!==t&&(this.params=t)},jt(nt.asn1.x509.NameConstraints,nt.asn1.x509.Extension),nt.asn1.x509.GeneralSubtree=function(t){nt.asn1.x509.GeneralSubtree.superclass.constructor.call(this);var e=nt.asn1,r=e.x509.GeneralName,i=e.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params,e=[new r(t)];return null!=t.min&&e.push({tag:{tagi:"80",obj:{int:t.min}}}),null!=t.max&&e.push({tag:{tagi:"81",obj:{int:t.max}}}),i({seq:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.x509.GeneralSubtree,nt.asn1.ASN1Object),nt.asn1.x509.ExtKeyUsage=function(t){nt.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=nt.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new e.DERSequence;for(var r=0;r<t.length;r++){var i=new e.DERObjectIdentifier(t[r]);this.asn1ExtnValue.appendASN1Object(i)}},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="2.5.29.37",void 0!==t&&void 0!==t.array&&this.setPurposeArray(t.array)},jt(nt.asn1.x509.ExtKeyUsage,nt.asn1.x509.Extension),nt.asn1.x509.AuthorityKeyIdentifier=function(t){nt.asn1.x509.AuthorityKeyIdentifier.superclass.constructor.call(this,t);var e=nt,r=e.asn1,i=r.DERTaggedObject,s=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 i({explicit:!1,tag:"80",obj:this.asn1KID})),this.asn1CertIssuer&&t.push(new i({explicit:!1,tag:"a1",obj:new s([{dn:this.asn1CertIssuer}])})),this.asn1CertSN&&t.push(new i({explicit:!1,tag:"82",obj:this.asn1CertSN}));var e=new r.DERSequence({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.tohex()},this.setKIDByParam=function(t){if(void 0!==t.str||void 0!==t.hex)this.asn1KID=new nt.asn1.DEROctetString(t);else if("object"==typeof t&&nt.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN ")){var e=t;"string"==typeof t&&(e=Mt.getKey(t));var r=Mt.getKeyID(e);this.asn1KID=new nt.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 nt.asn1.x509.X500Name(t):"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&-1!=t.indexOf("CERTIFICATE")&&(this.asn1CertIssuer=new nt.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 nt.asn1.DERInteger(t);else if("string"==typeof t&&-1!=t.indexOf("BEGIN ")&&t.indexOf("CERTIFICATE")){var e=new Wt;e.readCertPEM(t);var r=e.getSerialNumberHex();this.asn1CertSN=new nt.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)))},jt(nt.asn1.x509.AuthorityKeyIdentifier,nt.asn1.x509.Extension),nt.asn1.x509.SubjectKeyIdentifier=function(t){nt.asn1.x509.SubjectKeyIdentifier.superclass.constructor.call(this,t);var e=nt.asn1.DEROctetString;this.asn1KID=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=this.asn1KID,this.asn1ExtnValue.tohex()},this.setKIDByParam=function(t){if(void 0!==t.str||void 0!==t.hex)this.asn1KID=new e(t);else if("object"==typeof t&&nt.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN")){var r=t;"string"==typeof t&&(r=Mt.getKey(t));var i=Mt.getKeyID(r);this.asn1KID=new nt.asn1.DEROctetString({hex:i})}},this.oid="2.5.29.14",void 0!==t&&void 0!==t.kid&&this.setKIDByParam(t.kid)},jt(nt.asn1.x509.SubjectKeyIdentifier,nt.asn1.x509.Extension),nt.asn1.x509.AuthorityInfoAccess=function(t){nt.asn1.x509.AuthorityInfoAccess.superclass.constructor.call(this,t),this.setAccessDescriptionArray=function(t){for(var e=new Array,r=nt.asn1,i=r.DERSequence,s=r.DERObjectIdentifier,n=r.x509.GeneralName,a=0;a<t.length;a++){var o,h=t[a];if(void 0!==h.ocsp)o=new i({array:[new s({oid:"1.3.6.1.5.5.7.48.1"}),new n({uri:h.ocsp})]});else{if(void 0===h.caissuer)throw new Error("unknown AccessMethod parameter: "+JSON.stringify(h));o=new i({array:[new s({oid:"1.3.6.1.5.5.7.48.2"}),new n({uri:h.caissuer})]})}e.push(o)}this.asn1ExtnValue=new i({array:e})},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.1.1",void 0!==t&&void 0!==t.array&&this.setAccessDescriptionArray(t.array)},jt(nt.asn1.x509.AuthorityInfoAccess,nt.asn1.x509.Extension),nt.asn1.x509.SubjectAltName=function(t){nt.asn1.x509.SubjectAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new nt.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="2.5.29.17",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},jt(nt.asn1.x509.SubjectAltName,nt.asn1.x509.Extension),nt.asn1.x509.IssuerAltName=function(t){nt.asn1.x509.IssuerAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new nt.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="2.5.29.18",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},jt(nt.asn1.x509.IssuerAltName,nt.asn1.x509.Extension),nt.asn1.x509.SubjectDirectoryAttributes=function(t){nt.asn1.x509.SubjectDirectoryAttributes.superclass.constructor.call(this,t);var e=nt.asn1,r=e.DERSequence,i=e.ASN1Util.newObject,s=e.x509.OID.name2oid;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++){var n=this.params.array[e];if(null==n.attr||null==n.array){var a={seq:[{oid:"1.2.3.4"},{set:[{utf8str:"DE"}]}]};if("dateOfBirth"==n.attr)a.seq[0].oid=s(n.attr),a.seq[1].set[0]={gentime:n.str};else if("placeOfBirth"==n.attr)a.seq[0].oid=s(n.attr),a.seq[1].set[0]={utf8str:n.str};else if("gender"==n.attr)a.seq[0].oid=s(n.attr),a.seq[1].set[0]={prnstr:n.str};else if("countryOfCitizenship"==n.attr)a.seq[0].oid=s(n.attr),a.seq[1].set[0]={prnstr:n.str};else{if("countryOfResidence"!=n.attr)throw new Error("unsupported attribute: "+n.attr);a.seq[0].oid=s(n.attr),a.seq[1].set[0]={prnstr:n.str}}t.push(new i(a))}else{var o={seq:[{oid:n.attr},{set:n.array}]};t.push(i(o))}}var h=new r({array:t});return this.asn1ExtnValue=h,this.asn1ExtnValue.tohex()},this.oid="2.5.29.9",void 0!==t&&(this.params=t)},jt(nt.asn1.x509.SubjectDirectoryAttributes,nt.asn1.x509.Extension),nt.asn1.x509.PrivateExtension=function(t){nt.asn1.x509.PrivateExtension.superclass.constructor.call(this,t);var e=nt,r=e.lang.String.isHex,i=e.asn1,s=i.x509.OID.name2oid,n=i.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.oid=s(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 n(t).tohex()}catch(t){}throw new Error("unsupported extn value")},null!=t&&this.setByParam(t)},jt(nt.asn1.x509.PrivateExtension,nt.asn1.x509.Extension),nt.asn1.x509.CRL=function(t){nt.asn1.x509.CRL.superclass.constructor.call(this);var e=nt.asn1,r=e.DERSequence,i=e.DERBitString,s=e.x509,n=s.AlgorithmIdentifier,a=s.TBSCertList;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=new a(this.params).tohex(),e=new nt.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 Et(this.tohex(),"X509 CRL")},this.tohex=function(){var t=this.params;if(null==t.tbsobj&&(t.tbsobj=new a(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 n({name:t.sigalg})),e.push(new i({hex:"00"+t.sighex})),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&(this.params=t)},jt(nt.asn1.x509.CRL,nt.asn1.ASN1Object),nt.asn1.x509.TBSCertList=function(t){nt.asn1.x509.TBSCertList.superclass.constructor.call(this);var e=nt.asn1,r=e.DERInteger,i=e.DERSequence,s=e.DERTaggedObject,n=(e.DERObjectIdentifier,e.x509),a=n.AlgorithmIdentifier,o=n.Time,h=n.Extensions,u=n.X500Name;this.params=null,this.setByParam=function(t){this.params=t},this.getRevCertSequence=function(){for(var t=[],e=this.params.revcert,s=0;s<e.length;s++){var n=[new r(e[s].sn),new o(e[s].date)];null!=e[s].ext&&n.push(new h(e[s].ext)),t.push(new i({array:n}))}return new i({array:t})},this.tohex=function(){var t=[],e=this.params;if(null!=e.version){var n=e.version-1,c=new r({int:n});t.push(c)}if(t.push(new a({name:e.sigalg})),t.push(new u(e.issuer)),t.push(new o(e.thisupdate)),null!=e.nextupdate&&t.push(new o(e.nextupdate)),null!=e.revcert&&t.push(this.getRevCertSequence()),null!=e.ext){var l=new h(e.ext);t.push(new s({tag:"a0",explicit:!0,obj:l}))}return new i({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.x509.TBSCertList,nt.asn1.ASN1Object),nt.asn1.x509.CRLEntry=function(t){nt.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=nt.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.tohex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn&&this.setCertSerial(t.sn))},jt(nt.asn1.x509.CRLEntry,nt.asn1.ASN1Object),nt.asn1.x509.CRLNumber=function(t){nt.asn1.x509.CRLNumber.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new nt.asn1.DERInteger(this.params.num),this.asn1ExtnValue.tohex()},this.oid="2.5.29.20",null!=t&&(this.params=t)},jt(nt.asn1.x509.CRLNumber,nt.asn1.x509.Extension),nt.asn1.x509.CRLReason=function(t){nt.asn1.x509.CRLReason.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new nt.asn1.DEREnumerated(this.params.code),this.asn1ExtnValue.tohex()},this.oid="2.5.29.21",null!=t&&(this.params=t)},jt(nt.asn1.x509.CRLReason,nt.asn1.x509.Extension),nt.asn1.x509.OCSPNonce=function(t){nt.asn1.x509.OCSPNonce.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new nt.asn1.DEROctetString(this.params),this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.48.1.2",null!=t&&(this.params=t)},jt(nt.asn1.x509.OCSPNonce,nt.asn1.x509.Extension),nt.asn1.x509.OCSPNoCheck=function(t){nt.asn1.x509.OCSPNoCheck.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new nt.asn1.DERNull,this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.48.1.5",null!=t&&(this.params=t)},jt(nt.asn1.x509.OCSPNoCheck,nt.asn1.x509.Extension),nt.asn1.x509.AdobeTimeStamp=function(t){nt.asn1.x509.AdobeTimeStamp.superclass.constructor.call(this,t);var e=nt.asn1,r=e.DERInteger,i=e.DERBoolean,s=e.DERSequence,n=e.x509.GeneralName;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[new r(1)];return e.push(new n({uri:t.uri})),null!=t.reqauth&&e.push(new i(t.reqauth)),this.asn1ExtnValue=new s({array:e}),this.asn1ExtnValue.tohex()},this.oid="1.2.840.113583.1.1.9.1",void 0!==t&&this.setByParam(t)},jt(nt.asn1.x509.AdobeTimeStamp,nt.asn1.x509.Extension),nt.asn1.x509.X500Name=function(t){nt.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=nt.asn1,r=e.x509,i=r.RDN;this.setByString=function(t,e){void 0!==e&&(this.sRule=e);var r=t.split("/");r.shift();for(var s=[],n=0;n<r.length;n++)if(r[n].match(/^[^=]+=.+$/))s.push(r[n]);else{var a=s.length-1;s[a]=s[a]+"/"+r[n]}for(n=0;n<s.length;n++)this.asn1Array.push(new i({str:s[n],rule:this.sRule}))},this.setByLdapString=function(t,e){void 0!==e&&(this.sRule=e);var i=r.X500Name.ldapToCompat(t);this.setByString(i,e)},this.setByObject=function(t,e){for(var r in void 0!==e&&(this.sRule=e),t)if(t.hasOwnProperty(r)){var s=new i({str:r+"="+t[r],rule:this.sRule});this.asn1Array?this.asn1Array.push(s):this.asn1Array=[s]}},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 Wt).readCertPEM(t.certissuer),this.hTLV=e.getIssuerHex()):void 0!==t.certsubject?((e=new Wt).readCertPEM(t.certsubject),this.hTLV=e.getSubjectHex()):"object"==typeof t&&void 0===t.certsubject&&void 0===t.certissuer&&this.setByObject(t)},this.tohex=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 s=new i(r);this.asn1Array.push(s)}var n=new e.DERSequence({array:this.asn1Array});return this.hTLV=n.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.x509.X500Name,nt.asn1.ASN1Object),nt.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(/,/,"\\,")}),e.join(",")},nt.asn1.x509.X500Name.onelineToLDAP=function(t){return nt.asn1.x509.X500Name.compatToLDAP(t)},nt.asn1.x509.X500Name.ldapToCompat=function(t){for(var e=t.split(","),r=!1,i=[],s=0;e.length>0;s++){var n=e.shift();if(!0===r){var a=(i.pop()+","+n).replace(/\\,/g,",");i.push(a),r=!1}else i.push(n);"\\"===n.substr(-1,1)&&(r=!0)}return i=i.map(function(t){return t.replace("/","\\/")}),i.reverse(),"/"+i.join("/")},nt.asn1.x509.X500Name.ldapToOneline=function(t){return nt.asn1.x509.X500Name.ldapToCompat(t)},nt.asn1.x509.RDN=function(t){nt.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=nt.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 nt.asn1.x509.AttributeTypeAndValue({str:t,rule:this.sRule}))},this.addByMultiValuedString=function(t){for(var e=nt.asn1.x509.RDN.parseString(t),r=0;r<e.length;r++)this.addByString(e[r])},this.tohex=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 i=new e(r);this.asn1Array.push(i)}var s=new nt.asn1.DERSet({array:this.asn1Array});return this.TLV=s.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.x509.RDN,nt.asn1.ASN1Object),nt.asn1.x509.RDN.parseString=function(t){for(var e=t.split(/\+/),r=!1,i=[],s=0;e.length>0;s++){var n=e.shift();if(!0===r){var a=(i.pop()+"+"+n).replace(/\\\+/g,"+");i.push(a),r=!1}else i.push(n);"\\"===n.substr(-1,1)&&(r=!0)}var o=!1,h=[];for(s=0;i.length>0;s++){if(n=i.shift(),!0===o){var u=h.pop();n.match(/"$/)?(a=(u+"+"+n).replace(/^([^=]+)="(.*)"$/,"$1=$2"),h.push(a),o=!1):h.push(u+"+"+n)}else h.push(n);n.match(/^[^=]+="/)&&(o=!0)}return h},nt.asn1.x509.AttributeTypeAndValue=function(t){nt.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var e=nt,r=e.asn1,i=r.DERSequence,s=r.DERUTF8String,n=r.DERPrintableString,a=r.DERTeletexString,o=r.DERIA5String,h=r.DERVisibleString,u=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 s({str:e});if("prn"==t)return new n({str:e});if("tel"==t)return new a({str:e});if("ia5"==t)return new o({str:e});if("vis"==t)return new h({str:e});if("bmp"==t)return new u({str:e});throw new Error("unsupported directory string type: type="+t+" value="+e)},this.tohex=function(){null==this.dsType&&(this.dsType=this._getDsType());var t=nt.asn1.x509.OID.atype2obj(this.sType),e=this.getValueObj(this.dsType,this.sValue),r=new i({array:[t,e]});return this.TLV=r.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.x509.AttributeTypeAndValue,nt.asn1.ASN1Object),nt.asn1.x509.SubjectPublicKeyInfo=function(t){nt.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=nt,r=e.asn1,i=r.DERInteger,s=r.DERBitString,n=r.DERObjectIdentifier,a=r.DERSequence,o=r.ASN1Util.newObject,h=r.x509.AlgorithmIdentifier,u=e.crypto;u.ECDSA,u.DSA,this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new a({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.tohex=function(){var t=this.getASN1Object();return this.hTLV=t.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.setPubKey=function(t){try{if(t instanceof tt){var e=o({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).tohex();this.asn1AlgId=new h({name:"rsaEncryption"}),this.asn1SubjPKey=new s({hex:"00"+e})}}catch(t){}try{if(t instanceof nt.crypto.ECDSA){var r=new n({name:t.curveName});this.asn1AlgId=new h({name:"ecPublicKey",asn1params:r}),this.asn1SubjPKey=new s({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof nt.crypto.DSA){r=new o({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}),this.asn1AlgId=new h({name:"dsa",asn1params:r});var a=new i({bigint:t.y});this.asn1SubjPKey=new s({hex:"00"+a.tohex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},jt(nt.asn1.x509.SubjectPublicKeyInfo,nt.asn1.ASN1Object),nt.asn1.x509.Time=function(t){nt.asn1.x509.Time.superclass.constructor.call(this);var e=nt.asn1,r=e.DERUTCTime,i=e.DERGeneralizedTime;this.params=null,this.type=null,this.setTimeParams=function(t){this.timeParams=t},this.setByParam=function(t){this.params=t},this.getType=function(t){return t.match(/^[0-9]{12}Z$/)?"utc":t.match(/^[0-9]{14}Z$/)?"gen":t.match(/^[0-9]{12}\.[0-9]+Z$/)?"utc":t.match(/^[0-9]{14}\.[0-9]+Z$/)?"gen":null},this.tohex=function(){var t=this.params,e=null;if("string"==typeof t&&(t={str:t}),null==t||!t.str||null!=t.type&&null!=t.type||(t.type=this.getType(t.str)),null!=t&&t.str?("utc"==t.type&&(e=new r(t.str)),"gen"==t.type&&(e=new i(t.str))):e="gen"==this.type?new i:new r,null==e)throw new Error("wrong setting for Time");return this.TLV=e.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},nt.asn1.x509.Time_bak=function(t){nt.asn1.x509.Time_bak.superclass.constructor.call(this);var e=nt.asn1,r=e.DERUTCTime,i=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.tohex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new r(this.timeParams):new i(this.timeParams):"utc"==this.type?new r:new i,this.TLV=t.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},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)},jt(nt.asn1.x509.Time,nt.asn1.ASN1Object),nt.asn1.x509.AlgorithmIdentifier=function(t){nt.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=nt.asn1,r=e.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;if(this.tohex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw new Error("algorithm not specified");if(null!==this.nameAlg){var t=null;for(var i in r)i===this.nameAlg&&(t=r[i]);if(null!==t)return this.hTLV=t,this.hTLV}null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var s=[this.asn1Alg];null!==this.asn1Params&&s.push(this.asn1Params);var n=new e.DERSequence({array:s});return this.hTLV=n.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},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 i=this.nameAlg.toLowerCase();"withdsa"!==i.substr(-7,7)&&"withecdsa"!==i.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},jt(nt.asn1.x509.AlgorithmIdentifier,nt.asn1.ASN1Object),nt.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"},nt.asn1.x509.GeneralName=function(t){nt.asn1.x509.GeneralName.superclass.constructor.call(this);var e=nt.asn1,r=e.x509,i=r.X500Name,s=r.OtherName,n=e.DERIA5String,a=(e.DERPrintableString,e.DEROctetString),o=e.DERTaggedObject,h=e.ASN1Object,u=Error;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t,e,r=this.params,c=!1;if(void 0!==r.other)t="a0",e=new s(r.other);else if(void 0!==r.rfc822)t="81",e=new n({str:r.rfc822});else if(void 0!==r.dns)t="82",e=new n({str:r.dns});else if(void 0!==r.dn)t="a4",c=!0,e="string"==typeof r.dn?new i({str:r.dn}):r.dn instanceof nt.asn1.x509.X500Name?r.dn:new i(r.dn);else if(void 0!==r.ldapdn)t="a4",c=!0,e=new i({ldapstr:r.ldapdn});else if(void 0!==r.certissuer||void 0!==r.certsubj){var l,g;t="a4",c=!0;var p=null;if(void 0!==r.certsubj?(l=!1,g=r.certsubj):(l=!0,g=r.certissuer),g.match(/^[0-9A-Fa-f]+$/),-1!=g.indexOf("-----BEGIN ")&&(p=xt(g)),null==p)throw new Error("certsubj/certissuer not cert");var d,f=new Wt;f.hex=p,d=l?f.getIssuerHex():f.getSubjectHex(),(e=new h).hTLV=d}else if(void 0!==r.uri)t="86",e=new n({str:r.uri});else{if(void 0===r.ip)throw new u("improper params");var y;t="87";var v=r.ip;try{if(v.match(/^[0-9a-f]+$/)){var m=v.length;if(8!=m&&16!=m&&32!=m&&64!=m)throw"err";y=v}else y=Rt(v)}catch(t){throw new u("malformed IP address: "+r.ip+":"+t.message)}e=new a({hex:y})}return new o({tag:t,explicit:c,obj:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.x509.GeneralName,nt.asn1.ASN1Object),nt.asn1.x509.GeneralNames=function(t){nt.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=nt.asn1;this.setByParamArray=function(t){for(var r=0;r<t.length;r++){var i=new e.x509.GeneralName(t[r]);this.asn1Array.push(i)}},this.tohex=function(){return new e.DERSequence({array:this.asn1Array}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.asn1Array=new Array,void 0!==t&&this.setByParamArray(t)},jt(nt.asn1.x509.GeneralNames,nt.asn1.ASN1Object),nt.asn1.x509.OtherName=function(t){nt.asn1.x509.OtherName.superclass.constructor.call(this);var e=nt.asn1,r=e.DERObjectIdentifier,i=e.DERSequence,s=e.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if(null==t.oid||null==t.value)throw new Error("oid or value not specified");var e=new r({oid:t.oid}),n=s({tag:{tag:"a0",explicit:!0,obj:t.value}});return new i({array:[e,n]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.x509.OtherName,nt.asn1.ASN1Object),nt.asn1.x509.OID=new function(){var t=nt.asn1.DERObjectIdentifier;this.name2oidList={"aes128-CBC":"2.16.840.1.101.3.4.1.2","aes256-CBC":"2.16.840.1.101.3.4.1.42",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",hmacWithSHA1:"1.2.840.113549.2.7",hmacWithSHA224:"1.2.840.113549.2.8",hmacWithSHA256:"1.2.840.113549.2.9",hmacWithSHA384:"1.2.840.113549.2.10",hmacWithSHA512:"1.2.840.113549.2.11",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",policyMappings:"2.5.29.33",authorityKeyIdentifier:"2.5.29.35",policyConstraints:"2.5.29.36",extKeyUsage:"2.5.29.37",inhibitAnyPolicy:"2.5.29.54",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",smtpUTF8Mailbox:"1.3.6.1.5.5.7.8.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",secp521r1:"1.3.132.0.35",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",smimeMailboxLegacy:"2.23.140.1.5.1.1",smimeMailboxMulti:"2.23.140.1.5.1.2",smimeMailboxStrict:"2.23.140.1.5.1.3",smimeOrganizationLegacy:"2.23.140.1.5.2.1",smimeOrganizationMulti:"2.23.140.1.5.2.2",smimeOrganizationStrict:"2.23.140.1.5.2.3",smimeSponsorLegacy:"2.23.140.1.5.3.1",smimeSponsorMulti:"2.23.140.1.5.3.2",smimeSponsorStrict:"2.23.140.1.5.3.3",smimeIndividualLegacy:"2.23.140.1.5.4.1",smimeIndividualMulti:"2.23.140.1.5.4.2",smimeIndividualStrict:"2.23.140.1.5.4.3"},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",GN:"2.5.4.42",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.objCache={},this.name2obj=function(e){if(void 0!==this.objCache[e])return this.objCache[e];if(void 0===this.name2oidList[e])throw"Name of ObjectIdentifier not defined: "+e;var r=this.name2oidList[e],i=new t({oid:r});return this.objCache[e]=i,i},this.atype2obj=function(e){if(void 0!==this.objCache[e])return this.objCache[e];var r;if(e.match(/^\d+\.\d+\.[0-9.]+$/))r=e;else if(void 0!==this.atype2oidList[e])r=this.atype2oidList[e];else{if(void 0===this.name2oidList[e])throw new Error("AttributeType name undefined: "+e);r=this.name2oidList[e]}var i=new t({oid:r});return this.objCache[e]=i,i},this.registerOIDs=function(t){if(this.checkOIDs(t))for(var e in t)this.name2oidList[e]=t[e]},this.checkOIDs=function(t){try{var e=Object.keys(t);return 0!=e.length&&(e.map(function(t,e,r){if(!this[t].match(/^[0-2]\.[0-9.]+$/))throw new Error("value is not OID")},t),!0)}catch(t){return!1}}},nt.asn1.x509.OID.oid2name=function(t){var e=nt.asn1.x509.OID.name2oidList;for(var r in e)if(e[r]==t)return r;return""},nt.asn1.x509.OID.oid2atype=function(t){var e=nt.asn1.x509.OID.atype2oidList;for(var r in e)if(e[r]==t)return r;return t},nt.asn1.x509.OID.name2oid=function(t){if(t.match(/^[0-9.]+$/))return t;var e=nt.asn1.x509.OID.name2oidList;return void 0===e[t]?"":e[t]},nt.asn1.x509.X509Util={},nt.asn1.x509.X509Util.newCertPEM=function(t){var e=nt.asn1.x509;return e.TBSCertificate,new(0,e.Certificate)(t).getPEM()},void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),void 0!==nt.asn1.cms&&nt.asn1.cms||(nt.asn1.cms={}),nt.asn1.cms.Attribute=function(t){var e=Error,r=nt.asn1,i=r.DERSequence,s=r.DERSet,n=r.DERObjectIdentifier;this.params=null,this.typeOid=null,this.setByParam=function(t){this.params=t},this.getValueArray=function(){throw new e("not yet implemented abstract")},this.tohex=function(){var t=new n({oid:this.typeOid}),e=new s({array:this.getValueArray()});return new i({array:[t,e]}).tohex()},this.getEncodedHex=function(){return this.tohex()}},jt(nt.asn1.cms.Attribute,nt.asn1.ASN1Object),nt.asn1.cms.ContentType=function(t){var e=nt.asn1;e.cms.ContentType.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.3",this.getValueArray=function(){return[new e.DERObjectIdentifier(this.params.type)]},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.ContentType,nt.asn1.cms.Attribute),nt.asn1.cms.MessageDigest=function(t){var e=nt.asn1,r=e.DEROctetString;e.cms.MessageDigest.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.4",this.getValueArray=function(){return[new r(this.params)]},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.MessageDigest,nt.asn1.cms.Attribute),nt.asn1.cms.SigningTime=function(t){var e=nt.asn1;e.cms.SigningTime.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.5",this.getValueArray=function(){return[new e.x509.Time(this.params)]},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.SigningTime,nt.asn1.cms.Attribute),nt.asn1.cms.SigningCertificate=function(t){var e=Error,r=nt,i=r.asn1,s=i.DERSequence,n=i.cms,a=n.ESSCertID;r.crypto,n.SigningCertificate.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.12",this.getValueArray=function(){if(null==this.params||null==this.params||null==this.params.array)throw new e("parameter 'array' not specified");for(var r=this.params.array,i=[],n=0;n<r.length;n++){var o=r[n];0!=t.hasis||"string"!=typeof o||-1==o.indexOf("-----BEGIN")&&!ht.isASN1HEX(o)||(o={cert:o}),0!=o.hasis&&0==t.hasis&&(o.hasis=!1),i.push(new a(o))}var h=new s({array:i});return[new s({array:[h]})]},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.SigningCertificate,nt.asn1.cms.Attribute),nt.asn1.cms.ESSCertID=function(t){nt.asn1.cms.ESSCertID.superclass.constructor.call(this);var e=Error,r=nt,i=r.asn1,s=i.DEROctetString,n=i.DERSequence,a=i.cms.IssuerSerial;this.params=null,this.getCertHash=function(t,i){if(null!=t.hash)return t.hash;if("string"==typeof t&&-1==t.indexOf("-----BEGIN")&&!ht.isASN1HEX(t))return t;var s,n,a;if("string"==typeof t)s=t;else{if(null==t.cert)throw new e("hash nor cert unspecified");s=t.cert}if(n=-1!=s.indexOf("-----BEGIN")?xt(s):s,"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?n=xt(t):ht.isASN1HEX(t)&&(n=t)),null!=t.alg)a=t.alg;else{if(null==i)throw new e("hash alg unspecified");a=i}return r.crypto.Util.hashHex(n,a)},this.tohex=function(){var t=this.params,e=this.getCertHash(t,"sha1"),r=[];return r.push(new s({hex:e})),("string"==typeof t&&-1!=t.indexOf("-----BEGIN")||null!=t.cert&&0!=t.hasis||null!=t.issuer&&null!=t.serial)&&r.push(new a(t)),new n({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.ESSCertID,nt.asn1.ASN1Object),nt.asn1.cms.SigningCertificateV2=function(t){var e=Error,r=nt,i=r.asn1,s=i.DERSequence,n=(i.x509,i.cms),a=n.ESSCertIDv2;r.crypto,n.SigningCertificateV2.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.47",this.getValueArray=function(){if(null==this.params||null==this.params||null==this.params.array)throw new e("parameter 'array' not specified");for(var r=this.params.array,i=[],n=0;n<r.length;n++){var o=r[n];null==t.alg&&0!=t.hasis||"string"!=typeof o||-1==o.indexOf("-----BEGIN")&&!ht.isASN1HEX(o)||(o={cert:o}),null==o.alg&&null!=t.alg&&(o.alg=t.alg),0!=o.hasis&&0==t.hasis&&(o.hasis=!1),i.push(new a(o))}var h=new s({array:i});return[new s({array:[h]})]},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.SigningCertificateV2,nt.asn1.cms.Attribute),nt.asn1.cms.ESSCertIDv2=function(t){nt.asn1.cms.ESSCertIDv2.superclass.constructor.call(this),Error;var e=nt.asn1,r=e.DEROctetString,i=e.DERSequence,s=e.cms.IssuerSerial,n=e.x509.AlgorithmIdentifier;this.params=null,this.tohex=function(){var t=this.params,e=this.getCertHash(t,"sha256"),a=[];return null!=t.alg&&"sha256"!=t.alg&&a.push(new n({name:t.alg})),a.push(new r({hex:e})),("string"==typeof t&&-1!=t.indexOf("-----BEGIN")||null!=t.cert&&0!=t.hasis||null!=t.issuer&&null!=t.serial)&&a.push(new s(t)),new i({array:a}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.ESSCertIDv2,nt.asn1.cms.ESSCertID),nt.asn1.cms.IssuerSerial=function(t){var e=Error,r=nt.asn1,i=r.DERInteger,s=r.DERSequence,n=r.cms,a=r.x509.GeneralNames,o=Wt;n.IssuerSerial.superclass.constructor.call(this),this.setByParam=function(t){this.params=t},this.tohex=function(){var t,r,n=this.params;if("string"==typeof n&&-1!=n.indexOf("-----BEGIN")||null!=n.cert){var h;h=null!=n.cert?n.cert:n;var u=new o;u.readCertPEM(h),t=u.getIssuer(),r={hex:u.getSerialNumberHex()}}else{if(null==n.issuer||!n.serial)throw new e("cert or issuer and serial parameter not specified");t=n.issuer,r=n.serial}var c=new a([{dn:t}]),l=new i(r);return new s({array:[c,l]}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.IssuerSerial,nt.asn1.ASN1Object),nt.asn1.cms.SignerIdentifier=function(t){var e=nt.asn1,r=(e.DERInteger,e.DERSequence,e.cms),i=r.IssuerAndSerialNumber,s=r.SubjectKeyIdentifier;e.x509.X500Name,Error,r.SignerIdentifier.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if("isssn"==t.type)return new i(t).tohex();if("skid"==t.type)return new s(t).tohex();throw new Error("wrong property for isssn or skid")},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.SignerIdentifier,nt.asn1.ASN1Object),nt.asn1.cms.IssuerAndSerialNumber=function(t){var e=nt.asn1,r=e.DERInteger,i=e.DERSequence,s=e.cms,n=e.x509.X500Name,a=Wt,o=Error;s.IssuerAndSerialNumber.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t,e,s=this.params;if("string"==typeof s&&-1!=s.indexOf("-----BEGIN")||null!=s.cert){var h;h=null!=s.cert?s.cert:s;var u=new a;u.readCertPEM(h),t=u.getIssuer(),e={hex:u.getSerialNumberHex()}}else{if(null==s.issuer||!s.serial)throw new o("cert or issuer and serial parameter not specified");t=s.issuer,e=s.serial}var c=new n(t),l=new r(e);return new i({array:[c,l]}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.IssuerAndSerialNumber,nt.asn1.ASN1Object),nt.asn1.cms.SubjectKeyIdentifier=function(t){var e=nt.asn1,r=(e.DERInteger,e.DERSequence,e.ASN1Util.newObject),i=e.cms,s=(i.IssuerAndSerialName,i.SubjectKeyIdentifier,e.x509.X500Name,Wt),n=Error;i.SubjectKeyIdentifier.superclass.constructor.call(this),this.tohex=function(){var t,e=this.params;if(null==e.cert&&null==e.skid)throw new n("property cert nor skid undefined");return null!=e.cert?t=new s(e.cert).getExtSubjectKeyIdentifier().kid.hex:null!=e.skid&&(t=e.skid),r({tag:{tage:"a0",obj:{octstr:{hex:t}}}}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.SubjectKeyIdentifier,nt.asn1.ASN1Object),nt.asn1.cms.AttributeList=function(t){var e=Error,r=nt.asn1,i=r.DERSet,s=r.cms;s.AttributeList.superclass.constructor.call(this),this.params=null,this.hTLV=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if(null!=this.hTLV)return this.hTLV;var r=!0;null!=t.sortflag&&(r=t.sortflag);for(var n=t.array,a=[],o=0;o<n.length;o++){var h=n[o],u=h.attr;if("contentType"==u)a.push(new s.ContentType(h));else if("messageDigest"==u)a.push(new s.MessageDigest(h));else if("signingTime"==u)a.push(new s.SigningTime(h));else if("signingCertificate"==u)a.push(new s.SigningCertificate(h));else if("signingCertificateV2"==u)a.push(new s.SigningCertificateV2(h));else if("signaturePolicyIdentifier"==u)a.push(new nt.asn1.cades.SignaturePolicyIdentifier(h));else{if("signatureTimeStamp"!=u&&"timeStampToken"!=u)throw new e("unknown attr: "+u);a.push(new nt.asn1.cades.SignatureTimeStamp(h))}}var c=new i({array:a,sortflag:r});return this.hTLV=c.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.AttributeList,nt.asn1.ASN1Object),nt.asn1.cms.SignerInfo=function(t){var e=Error,r=nt,i=r.asn1,s=i.DERInteger,n=i.DEROctetString,a=i.DERSequence,o=i.DERTaggedObject,h=i.cms,u=h.SignerIdentifier,c=h.AttributeList,l=(h.ContentType,h.EncapsulatedContentInfo,h.MessageDigest,h.SignedData,i.x509.AlgorithmIdentifier),g=r.crypto,p=Mt;h.SignerInfo.superclass.constructor.call(this),this.params=null,this.sign=function(){var t=this.params,e=t.sigalg,r=new c(t.sattrs).tohex(),i=p.getKey(t.signkey),s=new g.Signature({alg:e});s.init(i),s.updateHex(r);var n=s.sign();t.sighex=n},this.tohex=function(){var t=this.params,r=[];if(r.push(new s({int:t.version})),r.push(new u(t.id)),r.push(new l({name:t.hashalg})),null!=t.sattrs){var i=new c(t.sattrs);try{r.push(new o({tag:"a0",explicit:!1,obj:i}))}catch(t){throw new e("si sattr error: "+t)}}if(null!=t.sigalgfield?r.push(new l({name:t.sigalgfield})):r.push(new l({name:t.sigalg})),null==t.sighex&&null!=t.signkey&&this.sign(),r.push(new n({hex:t.sighex})),null!=t.uattrs){i=new c(t.uattrs);try{r.push(new o({tag:"a1",explicit:!1,obj:i}))}catch(t){throw new e("si uattr error: "+t)}}return new a({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.SignerInfo,nt.asn1.ASN1Object),nt.asn1.cms.EncapsulatedContentInfo=function(t){var e=nt.asn1,r=e.DERTaggedObject,i=e.DERSequence,s=e.DERObjectIdentifier,n=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];if(e.push(new s(t.type)),null!=t.content&&(null!=t.content.hex||null!=t.content.str)&&1!=t.isDetached){var a=new n(t.content),o=new r({tag:"a0",explicit:!0,obj:a});e.push(o)}return new i({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.EncapsulatedContentInfo,nt.asn1.ASN1Object),nt.asn1.cms.ContentInfo=function(t){var e=nt.asn1,r=e.DERTaggedObject,i=e.DERSequence,s=e.DERObjectIdentifier;e.x509.OID.name2obj,nt.asn1.cms.ContentInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];e.push(new s(t.type));var n=new r({tag:"a0",explicit:!0,obj:t.obj});return e.push(n),new i({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.ContentInfo,nt.asn1.ASN1Object),nt.asn1.cms.SignedData=function(t){Error;var e=nt.asn1,r=(e.ASN1Object,e.DERInteger),i=e.DERSet,s=e.DERSequence,n=(e.DERTaggedObject,e.cms),a=n.EncapsulatedContentInfo,o=n.SignerInfo,h=n.ContentInfo,u=n.CertificateSet,c=n.RevocationInfoChoices,l=e.x509.AlgorithmIdentifier;nt.asn1.cms.SignedData.superclass.constructor.call(this),this.params=null,this.checkAndFixParam=function(){var t=this.params;this._setDigestAlgs(t),this._setContentTypeByEContent(t),this._setMessageDigestByEContent(t),this._setSignerInfoVersion(t),this._setSignedDataVersion(t)},this._setDigestAlgs=function(t){for(var e={},r=t.sinfos,i=0;i<r.length;i++)e[r[i].hashalg]=1;t.hashalgs=Object.keys(e).sort()},this._setContentTypeByEContent=function(t){for(var e=t.econtent.type,r=t.sinfos,i=0;i<r.length;i++){var s=r[i];this._getAttrParamByName(s,"contentType").type=e}},this._setMessageDigestByEContent=function(t){var e=t.econtent,r=(t.econtent.type,e.content.hex);null==r&&"data"==e.type&&null!=e.content.str&&(r=St(e.content.str));for(var i=t.sinfos,s=0;s<i.length;s++){var n=i[s],a=n.hashalg,o=this._getAttrParamByName(n,"messageDigest"),h=nt.crypto.Util.hashHex(r,a);o.hex=h}},this._getAttrParamByName=function(t,e){for(var r=t.sattrs.array,i=0;i<r.length;i++)if(r[i].attr==e)return r[i]},this._setSignerInfoVersion=function(t){for(var e=t.sinfos,r=0;r<e.length;r++){var i=e[r],s=1;"skid"==i.id.type&&(s=3),i.version=s}},this._setSignedDataVersion=function(t){var e=this._getSignedDataVersion(t);t.version=e},this._getSignedDataVersion=function(t){if(null!=t.revinfos)for(var e=t.revinfos,r=0;r<e.length;r++)if(null!=e[r].ocsp)return 5;var i=t.sinfos;for(r=0;r<i.length;r++)if(3==t.sinfos[r].version)return 3;return"data"!=t.econtent.type?3:1},this.tohex=function(){var t=this.params;null!=this.getEncodedHexPrepare&&this.getEncodedHexPrepare(),1!=t.fixed&&this.checkAndFixParam();var e=[];e.push(new r({int:t.version}));for(var n=[],h=0;h<t.hashalgs.length;h++){var g=t.hashalgs[h];n.push(new l({name:g}))}e.push(new i({array:n})),e.push(new a(t.econtent)),null!=t.certs&&e.push(new u(t.certs)),null!=t.revinfos&&e.push(new c(t.revinfos));var p=[];for(h=0;h<t.sinfos.length;h++){var d=t.sinfos[h];p.push(new o(d))}return e.push(new i({array:p})),new s({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.getContentInfo=function(){return new h({type:"signed-data",obj:this})},this.getContentInfoEncodedHex=function(){return this.getContentInfo().tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.SignedData,nt.asn1.ASN1Object),nt.asn1.cms.CertificateSet=function(t){nt.asn1.cms.CertificateSet.superclass.constructor.call(this);var e=Error,r=nt.asn1,i=r.DERTaggedObject,s=r.DERSet,n=r.ASN1Object;this.params=null,this.tohex=function(){var t,r=this.params,a=[];if(r instanceof Array)t=r;else{if(null==r.array)throw new e("cert array not specified");t=r.array}for(var o=0;o<t.length;o++){var h=xt(t[o]),u=new n;u.hTLV=h,a.push(u)}var c={array:a};0==r.sortflag&&(c.sortflag=!1);var l=new s(c);return new i({tag:"a0",explicit:!1,obj:l}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.CertificateSet,nt.asn1.ASN1Object),nt.asn1.cms.RevocationInfoChoices=function(t){nt.asn1.cms.RevocationInfoChoices.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(!t instanceof Array)throw new Error("params is not array");for(var e=[],r=0;r<t.length;r++)e.push(new nt.asn1.cms.RevocationInfoChoice(t[r]));return nt.asn1.ASN1Util.newObject({tag:{tagi:"a1",obj:{set:e}}}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.RevocationInfoChoices,nt.asn1.ASN1Object),nt.asn1.cms.RevocationInfoChoice=function(t){nt.asn1.cms.RevocationInfoChoice.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(null!=t.crl&&"string"==typeof t.crl){var e=t.crl;return-1!=t.crl.indexOf("-----BEGIN")&&(e=xt(t.crl)),e}if(null!=t.ocsp)return nt.asn1.ASN1Util.newObject({tag:{tagi:"a1",obj:new nt.asn1.cms.OtherRevocationFormat(t)}}).tohex();throw new Error("property crl or ocsp undefined")},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.RevocationInfoChoice,nt.asn1.ASN1Object),nt.asn1.cms.OtherRevocationFormat=function(t){nt.asn1.cms.OtherRevocationFormat.superclass.constructor.call(this);var e=Error,r=nt,i=r.asn1.ASN1Util.newObject,s=r.lang.String.isHex;this.params=null,this.tohex=function(){var t=this.params;if(null==t.ocsp)throw new e("property ocsp not specified");if(!s(t.ocsp)||!ht.isASN1HEX(t.ocsp))throw new e("ocsp value not ASN.1 hex string");return i({seq:[{oid:"1.3.6.1.5.5.7.16.2"},{asn1:{tlv:t.ocsp}}]}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cms.OtherRevocationFormat,nt.asn1.ASN1Object),nt.asn1.cms.CMSUtil=new function(){},nt.asn1.cms.CMSUtil.newSignedData=function(t){return new nt.asn1.cms.SignedData(t)},nt.asn1.cms.CMSUtil.verifySignedData=function(t){var e=nt,r=e.asn1,i=r.cms,s=(i.SignerInfo,i.SignedData,i.SigningTime,i.SigningCertificate,i.SigningCertificateV2,r.cades.SignaturePolicyIdentifier,e.lang.String.isHex),n=ht,a=n.getVbyList,o=n.getTLVbyList,h=n.getIdxbyList,u=n.getChildIdx,c=n.getTLV,l=n.oidname,g=e.crypto.Util.hashHex;void 0===t.cms&&s(t.cms);var p=t.cms,d=function(t,e){var r=e.idx;e.signerid_issuer1=o(t,r,[1,0],"30"),e.signerid_serial1=a(t,r,[1,1],"02"),e.hashalg=l(a(t,r,[2,0],"06"));var i=h(t,r,[3],"a0");e.idxSignedAttrs=i,f(t,e,i);var s=u(t,r).length;if(s<6)throw"malformed SignerInfo";e.sigalg=l(a(t,r,[s-2,0],"06")),e.sigval=a(t,r,[s-1],"04")},f=function(t,e,r){var i=u(t,r);e.signedAttrIdxList=i;for(var s=0;s<i.length;s++){var n,o=i[s],h=a(t,o,[0],"06");"2a864886f70d010905"===h?(n=yt(a(t,o,[1,0])),e.saSigningTime=n):"2a864886f70d010904"===h&&(n=a(t,o,[1,0],"04"),e.saMessageDigest=n)}},y=function(t,e,r,i){r.verifyDetail={};var s=r.verifyDetail,n=e.parse.econtent,a=r.hashalg,o=r.saMessageDigest;s.validMessageDigest=!1,g(n,a)===o&&(s.validMessageDigest=!0),function(t,e,r){var i,s=e.parse.certsIdx;if(void 0===e.certs){i=[],e.certkeys=[];for(var n=u(t,s),a=0;a<n.length;a++){var o=c(t,n[a]),h=new Wt;h.readCertHex(o),i[a]=h,e.certkeys[a]=h.getPublicKey()}e.certs=i}else i=e.certs;for(e.cccc=i.length,e.cccci=n.length,a=0;a<i.length;a++){var l=h.getIssuerHex(),g=h.getSerialNumberHex();r.signerid_issuer1===l&&r.signerid_serial1===g&&(r.certkey_idx=a)}}(t,e,r),s.validSignatureValue=!1;var h=r.sigalg,l="31"+c(t,r.idxSignedAttrs).substr(2);r.signedattrshex=l;var p=e.certs[r.certkey_idx].getPublicKey(),d=new nt.crypto.Signature({alg:h});d.init(p),d.updateHex(l);var f=d.verify(r.sigval);s.validSignatureValue_isValid=f,!0===f&&(s.validSignatureValue=!0),r.isValid=!1,s.validMessageDigest&&s.validSignatureValue&&(r.isValid=!0)},v={isValid:!1,parse:{}};return function(t,e){if("2a864886f70d010702"!==a(t,0,[0],"06"))return e;e.cmsType="signedData",e.econtent=a(t,0,[1,0,2,1,0]),function(t,e){for(var r,i=3;i<6;i++)if(void 0!==(r=h(t,0,[1,0,i]))){var s=t.substr(r,2);"a0"===s&&(e.certsIdx=r),"a1"===s&&(e.revinfosIdx=r),"31"===s&&(e.signerinfosIdx=r)}}(t,e),e.signerInfos=[],function(t,e){var r=e.signerinfosIdx;if(void 0!==r){var i=u(t,r);e.signerInfoIdxList=i;for(var s=0;s<i.length;s++){var n={idx:i[s]};d(t,n),e.signerInfos.push(n)}}}(t,e)}(p,v.parse),function(t,e){for(var r=e.parse.signerInfos,i=r.length,s=!0,n=0;n<i;n++){var a=r[n];y(t,e,a),a.isValid||(s=!1)}e.isValid=s}(p,v),v},nt.asn1.cms.CMSParser=function(){var t=Error,e=Wt,r=new e,i=ht,s=i.getV,n=i.getTLV,a=(i.getIdxbyList,i.getTLVbyList),o=i.getTLVbyListEx,h=i.getVbyList,u=i.getVbyListEx,c=i.getChildIdx;this.getCMSSignedData=function(t){var e=a(t,0,[1,0]);return this.getSignedData(e)},this.getSignedData=function(t){var e=c(t,0),r={},i=s(t,e[0]),a=parseInt(i,16);r.version=a;var h=n(t,e[1]);r.hashalgs=this.getHashAlgArray(h);var u=n(t,e[2]);r.econtent=this.getEContent(u);var l=o(t,0,["[0]"]);null!=l&&(r.certs=this.getCertificateSet(l)),o(t,0,["[1]"]);var g=o(t,0,[3]);return r.sinfos=this.getSignerInfos(g),r},this.getHashAlgArray=function(t){for(var r=c(t,0),i=new e,s=[],a=0;a<r.length;a++){var o=n(t,r[a]),h=i.getAlgorithmIdentifierName(o);s.push(h)}return s},this.getEContent=function(t){var e={},r=h(t,0,[0]),i=h(t,0,[1,0]);return e.type=nt.asn1.x509.OID.oid2name(ht.hextooidstr(r)),e.content={hex:i},e},this.getSignerInfos=function(t){for(var e=[],r=c(t,0),i=0;i<r.length;i++){var s=n(t,r[i]),a=this.getSignerInfo(s);e.push(a)}return e},this.getSignerInfo=function(t){var e={},s=c(t,0),a=i.getInt(t,s[0],-1);-1!=a&&(e.version=a);var h=n(t,s[1]),l=this.getIssuerAndSerialNumber(h);e.id=l;var g=n(t,s[2]),p=r.getAlgorithmIdentifierName(g);e.hashalg=p;var d=o(t,0,["[0]"]);if(null!=d){var f=this.getAttributeList(d);e.sattrs=f}var y=o(t,0,[3]),v=r.getAlgorithmIdentifierName(y);e.sigalg=v;var m=u(t,0,[4]);e.sighex=m;var S=o(t,0,["[1]"]);if(null!=S){var E=this.getAttributeList(S);e.uattrs=E}return e},this.getSignerIdentifier=function(t){if("30"==t.substr(0,2))return this.getIssuerAndSerialNumber(t);throw new Error("SKID of signerIdentifier not supported")},this.getIssuerAndSerialNumber=function(t){var e={type:"isssn"},i=c(t,0),a=n(t,i[0]);e.issuer=r.getX500Name(a);var o=s(t,i[1]);return e.serial={hex:o},e},this.getAttributeList=function(t){for(var e=[],r=c(t,0),i=0;i<r.length;i++){var s=n(t,r[i]),a=this.getAttribute(s);e.push(a)}return{array:e}},this.getAttribute=function(t){var e={},r=c(t,0),s=i.getOID(t,r[0]),a=nt.asn1.x509.OID.oid2name(s);e.attr=a;var o=n(t,r[1]),h=c(o,0);if(1==h.length)e.valhex=n(o,h[0]);else{for(var u=[],l=0;l<h.length;l++)u.push(n(o,h[l]));e.valhex=u}return"contentType"==a?this.setContentType(e):"messageDigest"==a?this.setMessageDigest(e):"signingTime"==a?this.setSigningTime(e):"signingCertificate"==a?this.setSigningCertificate(e):"signingCertificateV2"==a?this.setSigningCertificateV2(e):"signaturePolicyIdentifier"==a&&this.setSignaturePolicyIdentifier(e),e},this.setContentType=function(t){var e=i.getOIDName(t.valhex,0,null);null!=e&&(t.type=e,delete t.valhex)},this.setSigningTime=function(t){var e=yt(s(t.valhex,0));t.str=e,delete t.valhex},this.setMessageDigest=function(t){var e=s(t.valhex,0);t.hex=e,delete t.valhex},this.setSigningCertificate=function(t){var e=c(t.valhex,0);if(e.length>0){for(var r=n(t.valhex,e[0]),i=c(r,0),s=[],a=0;a<i.length;a++){var o=n(r,i[a]),h=this.getESSCertID(o);s.push(h)}t.array=s}if(e.length>1){var u=n(t.valhex,e[1]);t.polhex=u}delete t.valhex},this.setSignaturePolicyIdentifier=function(t){var r=c(t.valhex,0);if(r.length>0){var a=i.getOID(t.valhex,r[0]);t.oid=a}if(r.length>1){var o=new e,h=c(t.valhex,r[1]),u=n(t.valhex,h[0]),l=o.getAlgorithmIdentifierName(u);t.alg=l;var g=s(t.valhex,h[1]);t.hash=g}delete t.valhex},this.setSigningCertificateV2=function(t){var e=c(t.valhex,0);if(e.length>0){for(var r=n(t.valhex,e[0]),i=c(r,0),s=[],a=0;a<i.length;a++){var o=n(r,i[a]),h=this.getESSCertIDv2(o);s.push(h)}t.array=s}if(e.length>1){var u=n(t.valhex,e[1]);t.polhex=u}delete t.valhex},this.getESSCertID=function(t){var e={},r=c(t,0);if(r.length>0){var i=s(t,r[0]);e.hash=i}if(r.length>1){var a=n(t,r[1]),o=this.getIssuerSerial(a);null!=o.serial&&(e.serial=o.serial),null!=o.issuer&&(e.issuer=o.issuer)}return e},this.getESSCertIDv2=function(e){var i={},a=c(e,0);if(a.length<1||3<a.length)throw new t("wrong number of elements");var o=0;if("30"==e.substr(a[0],2)){var h=n(e,a[0]);i.alg=r.getAlgorithmIdentifierName(h),o++}else i.alg="sha256";var u=s(e,a[o]);if(i.hash=u,a.length>o+1){var l=n(e,a[o+1]),g=this.getIssuerSerial(l);i.issuer=g.issuer,i.serial=g.serial}return i},this.getIssuerSerial=function(t){var e={},i=c(t,0),a=n(t,i[0]),o=r.getGeneralNames(a)[0].dn;e.issuer=o;var h=s(t,i[1]);return e.serial={hex:h},e},this.getCertificateSet=function(t){for(var e=c(t,0),r=[],i=0;i<e.length;i++){var s=n(t,e[i]);if("30"==s.substr(0,2)){var a=Et(s,"CERTIFICATE");r.push(a)}}return{array:r,sortflag:!1}}},void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),void 0!==nt.asn1.tsp&&nt.asn1.tsp||(nt.asn1.tsp={}),nt.asn1.tsp.TimeStampToken=function(t){var e=nt.asn1.tsp;e.TimeStampToken.superclass.constructor.call(this),this.params=null,this.getEncodedHexPrepare=function(){var t=new e.TSTInfo(this.params.econtent.content);this.params.econtent.content.hex=t.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.tsp.TimeStampToken,nt.asn1.cms.SignedData),nt.asn1.tsp.TSTInfo=function(t){Error;var e=nt.asn1,r=e.DERSequence,i=e.DERInteger,s=e.DERBoolean,n=e.DERGeneralizedTime,a=e.DERObjectIdentifier,o=e.DERTaggedObject,h=e.tsp,u=h.MessageImprint,c=h.Accuracy,l=(e.x509.X500Name,e.x509.GeneralName);if(h.TSTInfo.superclass.constructor.call(this),this.dVersion=new i({int:1}),this.dPolicy=null,this.dMessageImprint=null,this.dSerial=null,this.dGenTime=null,this.dAccuracy=null,this.dOrdering=null,this.dNonce=null,this.dTsa=null,this.tohex=function(){var t=[this.dVersion];if(null==this.dPolicy)throw new Error("policy shall be specified.");if(t.push(this.dPolicy),null==this.dMessageImprint)throw new Error("messageImprint shall be specified.");if(t.push(this.dMessageImprint),null==this.dSerial)throw new Error("serialNumber shall be specified.");if(t.push(this.dSerial),null==this.dGenTime)throw new Error("genTime shall be specified.");t.push(this.dGenTime),null!=this.dAccuracy&&t.push(this.dAccuracy),null!=this.dOrdering&&t.push(this.dOrdering),null!=this.dNonce&&t.push(this.dNonce),null!=this.dTsa&&t.push(this.dTsa);var e=new r({array:t});return this.hTLV=e.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t){if("string"==typeof t.policy){if(!t.policy.match(/^[0-9.]+$/))throw"policy shall be oid like 0.1.4.134";this.dPolicy=new a({oid:t.policy})}void 0!==t.messageImprint&&(this.dMessageImprint=new u(t.messageImprint)),void 0!==t.serial&&(this.dSerial=new i(t.serial)),void 0!==t.genTime&&(this.dGenTime=new n(t.genTime)),void 0!==t.accuracy&&(this.dAccuracy=new c(t.accuracy)),void 0!==t.ordering&&1==t.ordering&&(this.dOrdering=new s),void 0!==t.nonce&&(this.dNonce=new i(t.nonce)),void 0!==t.tsa&&(this.dTsa=new o({tag:"a0",explicit:!0,obj:new l({dn:t.tsa})}))}},jt(nt.asn1.tsp.TSTInfo,nt.asn1.ASN1Object),nt.asn1.tsp.Accuracy=function(t){var e=nt.asn1,r=e.ASN1Util.newObject;e.tsp.Accuracy.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return null!=t.seconds&&"number"==typeof t.seconds&&e.push({int:t.seconds}),null!=t.millis&&"number"==typeof t.millis&&e.push({tag:{tagi:"80",obj:{int:t.millis}}}),null!=t.micros&&"number"==typeof t.micros&&e.push({tag:{tagi:"81",obj:{int:t.micros}}}),r({seq:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.tsp.Accuracy,nt.asn1.ASN1Object),nt.asn1.tsp.MessageImprint=function(t){var e=nt.asn1,r=e.DERSequence,i=e.DEROctetString,s=e.x509.AlgorithmIdentifier;e.tsp.MessageImprint.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=new s({name:t.alg}),n=new i({hex:t.hash});return new r({array:[e,n]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.tsp.MessageImprint,nt.asn1.ASN1Object),nt.asn1.tsp.TimeStampReq=function(t){var e=nt.asn1,r=e.DERSequence,i=e.DERInteger,s=e.DERBoolean,n=(e.ASN1Object,e.DERObjectIdentifier),a=e.tsp,o=a.MessageImprint;a.TimeStampReq.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return e.push(new i({int:1})),t.messageImprint instanceof nt.asn1.ASN1Object?e.push(t.messageImprint):e.push(new o(t.messageImprint)),null!=t.policy&&e.push(new n(t.policy)),null!=t.nonce&&e.push(new i(t.nonce)),1==t.certreq&&e.push(new s),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.tsp.TimeStampReq,nt.asn1.ASN1Object),nt.asn1.tsp.TimeStampResp=function(t){var e=nt.asn1,r=e.DERSequence,i=(e.ASN1Object,e.tsp),s=i.PKIStatusInfo;i.TimeStampResp.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,n=[];if(null!=t.econtent||null!=t.tst)if(null!=t.statusinfo?n.push(new s(t.statusinfo)):n.push(new s("granted")),null!=t.econtent)n.push(new i.TimeStampToken(t).getContentInfo());else{if(!(t.tst instanceof e.ASN1Object))throw new Error("improper member tst value");n.push(t.tst)}else{if(null==t.statusinfo)throw new Error("parameter for token nor statusinfo not specified");n.push(new s(t.statusinfo))}return new r({array:n}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.tsp.TimeStampResp,nt.asn1.ASN1Object),nt.asn1.tsp.PKIStatusInfo=function(t){var e=Error,r=nt.asn1,i=r.DERSequence,s=r.tsp,n=s.PKIStatus,a=s.PKIFreeText,o=s.PKIFailureInfo;s.PKIStatusInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,r=[];if("string"==typeof t)r.push(new n(t));else{if(null==t.status)throw new e("property 'status' unspecified");r.push(new n(t.status)),null!=t.statusstr&&r.push(new a(t.statusstr)),null!=t.failinfo&&r.push(new o(t.failinfo))}return new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.tsp.PKIStatusInfo,nt.asn1.ASN1Object),nt.asn1.tsp.PKIStatus=function(t){var e=Error,r=nt.asn1,i=r.DERInteger;r.tsp.PKIStatus.superclass.constructor.call(this);var s={granted:0,grantedWithMods:1,rejection:2,waiting:3,revocationWarning:4,revocationNotification:5};this.params=null,this.tohex=function(){var t,r=this.params;if("string"==typeof r)try{t=s[r]}catch(t){throw new e("undefined name: "+r)}else{if("number"!=typeof r)throw new e("unsupported params");t=r}return new i({int:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.tsp.PKIStatus,nt.asn1.ASN1Object),nt.asn1.tsp.PKIFreeText=function(t){var e=Error,r=nt.asn1,i=r.DERSequence,s=r.DERUTF8String;r.tsp.PKIFreeText.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(!t instanceof Array)throw new e("wrong params: not array");for(var r=[],n=0;n<t.length;n++)r.push(new s({str:t[n]}));return new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.tsp.PKIFreeText,nt.asn1.ASN1Object),nt.asn1.tsp.PKIFailureInfo=function(t){var e=Error,r=nt.asn1,i=r.DERBitString,s=r.tsp.PKIFailureInfo,n={badAlg:0,badRequest:2,badDataFormat:5,timeNotAvailable:14,unacceptedPolicy:15,unacceptedExtension:16,addInfoNotAvailable:17,systemFailure:25};s.superclass.constructor.call(this),this.params=null,this.getBinValue=function(){var t=this.params,r=0;if("number"==typeof t&&0<=t&&t<=25){for(var i=(r|=1<<t).toString(2),s="",a=i.length-1;a>=0;a--)s+=i[a];return s}if("string"==typeof t&&null!=n[t])return Ut([t],n);if("object"==typeof t&&null!=t.length)return Ut(t,n);throw new e("wrong params")},this.tohex=function(){this.params;var t=this.getBinValue();return new i({bin:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.tsp.PKIFailureInfo,nt.asn1.ASN1Object),nt.asn1.tsp.AbstractTSAAdapter=function(t){this.getTSTHex=function(t,e){throw"not implemented yet"}},nt.asn1.tsp.SimpleTSAAdapter=function(t){var e=nt,r=e.asn1.tsp,i=e.crypto.Util.hashHex;r.SimpleTSAAdapter.superclass.constructor.call(this),this.params=null,this.serial=0,this.getTSTHex=function(t,e){var s=i(t,e);this.params.econtent.content.messageImprint={alg:e,hash:s},this.params.econtent.content.serial={int:this.serial++};var n=Math.floor(1e9*Math.random());return this.params.econtent.content.nonce={int:n},new r.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},jt(nt.asn1.tsp.SimpleTSAAdapter,nt.asn1.tsp.AbstractTSAAdapter),nt.asn1.tsp.FixedTSAAdapter=function(t){var e=nt,r=e.asn1.tsp,i=e.crypto.Util.hashHex;r.FixedTSAAdapter.superclass.constructor.call(this),this.params=null,this.getTSTHex=function(t,e){var s=i(t,e);return this.params.econtent.content.messageImprint={alg:e,hash:s},new r.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},jt(nt.asn1.tsp.FixedTSAAdapter,nt.asn1.tsp.AbstractTSAAdapter),nt.asn1.tsp.TSPUtil=new function(){},nt.asn1.tsp.TSPUtil.newTimeStampToken=function(t){return new nt.asn1.tsp.TimeStampToken(t)},nt.asn1.tsp.TSPUtil.parseTimeStampReq=function(t){return(new nt.asn1.tsp.TSPParser).getTimeStampReq(t)},nt.asn1.tsp.TSPUtil.parseMessageImprint=function(t){return(new nt.asn1.tsp.TSPParser).getMessageImprint(t)},nt.asn1.tsp.TSPParser=function(){Error;var t=new Wt,e=ht,r=e.getV,i=e.getTLV,s=e.getIdxbyList,n=(e.getTLVbyListEx,e.getChildIdx),a=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"],o={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(t){var e=n(t,0);if(1==e.length)return this.getPKIStatusInfo(i(t,e[0]));if(e.length>1){var r=this.getPKIStatusInfo(i(t,e[0])),s=i(t,e[1]),a=this.getToken(s);return a.statusinfo=r,a}},this.getToken=function(t){var e=(new nt.asn1.cms.CMSParser).getCMSSignedData(t);return this.setTSTInfo(e),e},this.setTSTInfo=function(t){var e=t.econtent;if("tstinfo"==e.type){var r=e.content.hex,i=this.getTSTInfo(r);e.content=i}},this.getTSTInfo=function(e){var s={},a=n(e,0),o=r(e,a[1]);s.policy=Bt(o);var h=i(e,a[2]);s.messageImprint=this.getMessageImprint(h);var u=r(e,a[3]);s.serial={hex:u};var c=r(e,a[4]);s.genTime={str:yt(c)};var l=0;if(a.length>5&&"30"==e.substr(a[5],2)){var g=i(e,a[5]);s.accuracy=this.getAccuracy(g),l++}if(a.length>5+l&&"01"==e.substr(a[5+l],2)&&("ff"==r(e,a[5+l])&&(s.ordering=!0),l++),a.length>5+l&&"02"==e.substr(a[5+l],2)){var p=r(e,a[5+l]);s.nonce={hex:p},l++}if(a.length>5+l&&"a0"==e.substr(a[5+l],2)){var d=i(e,a[5+l]);d="30"+d.substr(2),pGeneralNames=t.getGeneralNames(d);var f=pGeneralNames[0].dn;s.tsa=f,l++}if(a.length>5+l&&"a1"==e.substr(a[5+l],2)){var y=i(e,a[5+l]);y="30"+y.substr(2);var v=t.getExtParamArray(y);s.ext=v,l++}return s},this.getAccuracy=function(t){for(var e={},i=n(t,0),s=0;s<i.length;s++){var a=t.substr(i[s],2),o=r(t,i[s]),h=parseInt(o,16);"02"==a?e.seconds=h:"80"==a?e.millis=h:"81"==a&&(e.micros=h)}return e},this.getMessageImprint=function(t){if("30"!=t.substr(0,2))throw new Error("head of messageImprint hex shall be x30");var i={},a=(n(t,0),s(t,0,[0,0])),o=r(t,a),h=e.hextooidstr(o),u=nt.asn1.x509.OID.oid2name(h);if(""==u)throw new Error("hashAlg name undefined: "+h);var c=u,l=s(t,0,[1]);return i.alg=c,i.hash=r(t,l),i},this.getPKIStatusInfo=function(t){var e={},s=n(t,0),o=0;try{var h=r(t,s[0]),u=parseInt(h,16);e.status=a[u]}catch(t){}if(s.length>1&&"30"==t.substr(s[1],2)){var c=i(t,s[1]);e.statusstr=this.getPKIFreeText(c),o++}if(s.length>o&&"03"==t.substr(s[1+o],2)){var l=i(t,s[1+o]);e.failinfo=this.getPKIFailureInfo(l)}return e},this.getPKIFreeText=function(t){for(var r=[],i=n(t,0),s=0;s<i.length;s++)r.push(e.getString(t,i[s]));return r},this.getPKIFailureInfo=function(t){var r=e.getInt(t,0);return null!=o[r]?o[r]:r},this.getTimeStampReq=function(t){var s={certreq:!1},a=n(t,0);if(a.length<2)throw new Error("TimeStampReq must have at least 2 items");var o=i(t,a[1]);s.messageImprint=nt.asn1.tsp.TSPUtil.parseMessageImprint(o);for(var h=2;h<a.length;h++){var u=a[h],c=t.substr(u,2);if("06"==c){var l=r(t,u);s.policy=e.hextooidstr(l)}"02"==c&&(s.nonce=r(t,u)),"01"==c&&(s.certreq=!0)}return s}},void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),void 0!==nt.asn1.cades&&nt.asn1.cades||(nt.asn1.cades={}),nt.asn1.cades.SignaturePolicyIdentifier=function(t){var e=nt.asn1.cades,r=e.SignaturePolicyId;e.SignaturePolicyIdentifier.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.15",this.params=null,this.getValueArray=function(){return[new r(this.params)]},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},jt(nt.asn1.cades.SignaturePolicyIdentifier,nt.asn1.cms.Attribute),nt.asn1.cades.SignaturePolicyId=function(t){var e=nt.asn1,r=e.DERSequence,i=e.DERObjectIdentifier,s=(e.x509.AlgorithmIdentifier,e.cades),n=s.SignaturePolicyId,a=s.OtherHashAlgAndValue;n.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return e.push(new i(t.oid)),e.push(new a(t)),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},jt(nt.asn1.cades.SignaturePolicyId,nt.asn1.ASN1Object),nt.asn1.cades.OtherHashAlgAndValue=function(t){var e=Error,r=nt.asn1,i=r.DERSequence,s=r.DEROctetString,n=r.x509.AlgorithmIdentifier;r.cades.OtherHashAlgAndValue.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(null==t.alg)throw new e("property 'alg' not specified");if(null==t.hash&&null==t.cert)throw new e("property 'hash' nor 'cert' not specified");var r=null;if(null!=t.hash)r=t.hash;else if(null!=t.cert){if("string"!=typeof t.cert)throw new e("cert not string");var a=t.cert;-1!=t.cert.indexOf("-----BEGIN")&&(a=xt(t.cert)),r=nt.crypto.Util.hashHex(a,t.alg)}var o=[];return o.push(new n({name:t.alg})),o.push(new s({hex:r})),new i({array:o}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cades.OtherHashAlgAndValue,nt.asn1.ASN1Object),nt.asn1.cades.OtherHashValue=function(t){nt.asn1.cades.OtherHashValue.superclass.constructor.call(this);var e=Error,r=nt,i=(r.lang.String.isHex,r.asn1.DEROctetString);r.crypto.Util.hashHex,this.params=null,this.tohex=function(){var t=this.params;if(null==t.hash&&null==t.cert)throw new e("hash or cert not specified");var r=null;if(null!=t.hash)r=t.hash;else if(null!=t.cert){if("string"!=typeof t.cert)throw new e("cert not string");var s=t.cert;-1!=t.cert.indexOf("-----BEGIN")&&(s=xt(t.cert)),r=nt.crypto.Util.hashHex(s,"sha1")}return new i({hex:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cades.OtherHashValue,nt.asn1.ASN1Object),nt.asn1.cades.SignatureTimeStamp=function(t){var e=Error,r=nt,i=r.lang.String.isHex,s=r.asn1,n=s.ASN1Object;s.x509,s.cades.SignatureTimeStamp.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.14",this.params=null,this.getValueArray=function(){var t=this.params;if(null!=t.tst){if(i(t.tst))return(r=new n).hTLV=t.tst,[r];if(t.tst instanceof n)return[t.tst];throw new e("params.tst has wrong value")}if(null!=t.res){var r,s=t.res;if(s instanceof n&&(s=s.tohex()),"string"!=typeof s||!i(s))throw new e("params.res has wrong value");return ht.getTLVbyList(s,0,[1]),(r=new n).hTLV=t.tst,[r]}},null!=t&&this.setByParam(t)},jt(nt.asn1.cades.SignatureTimeStamp,nt.asn1.cms.Attribute),nt.asn1.cades.CompleteCertificateRefs=function(t){var e=Error,r=nt,i=r.asn1,s=i.DERSequence,n=i.cades,a=n.OtherCertID,o=r.lang.String.isHex;n.CompleteCertificateRefs.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.21",this.params=null,this.getValueArray=function(){for(var t=this.params,r=[],i=0;i<t.array.length;i++){var n=t.array[i];if("string"==typeof n)if(-1!=n.indexOf("-----BEGIN"))n={cert:n};else{if(!o(n))throw new e("unsupported value: "+n);n={hash:n}}null!=t.alg&&null==n.alg&&(n.alg=t.alg),null!=t.hasis&&null==n.hasis&&(n.hasis=t.hasis);var h=new a(n);r.push(h)}return[new s({array:r})]},null!=t&&this.setByParam(t)},jt(nt.asn1.cades.CompleteCertificateRefs,nt.asn1.cms.Attribute),nt.asn1.cades.OtherCertID=function(t){var e=nt.asn1,r=e.DERSequence,i=e.cms.IssuerSerial,s=e.cades,n=s.OtherHashValue,a=s.OtherHashAlgAndValue;s.OtherCertID.superclass.constructor.call(this),this.params=t,this.tohex=function(){var t=this.params;"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?t={cert:t}:_isHex(t)&&(t={hash:t}));var e,s=[];if(e=null!=t.alg?new a(t):new n(t),s.push(e),null!=t.cert&&1==t.hasis||null!=t.issuer&&null!=t.serial){var o=new i(t);s.push(o)}return new r({array:s}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cades.OtherCertID,nt.asn1.ASN1Object),nt.asn1.cades.OtherHash=function(t){Error;var e=nt,r=e.asn1,i=(r.cms,r.cades),s=i.OtherHashAlgAndValue,n=i.OtherHashValue,a=(e.crypto.Util.hashHex,e.lang.String.isHex);i.OtherHash.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;return"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?t={cert:t}:a(t)&&(t={hash:t})),(null!=t.alg?new s(t):new n(t)).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.cades.OtherHash,nt.asn1.ASN1Object),nt.asn1.cades.CAdESUtil=new function(){},nt.asn1.cades.CAdESUtil.parseSignedDataForAddingUnsigned=function(t){return(new nt.asn1.cms.CMSParser).getCMSSignedData(t)},nt.asn1.cades.CAdESUtil.parseSignerInfoForAddingUnsigned=function(t,e,r){var i=ht,s=i.getChildIdx,n=i.getTLV,a=i.getV,o=nt.asn1,h=o.ASN1Object,u=o.cms,c=u.AttributeList,l=u.SignerInfo,g={},p=s(t,e);if(6!=p.length)throw"not supported items for SignerInfo (!=6)";var d=p.shift();g.version=n(t,d);var f=p.shift();g.si=n(t,f);var y=p.shift();g.digalg=n(t,y);var v=p.shift();g.sattrs=n(t,v);var m=p.shift();g.sigalg=n(t,m);var S=p.shift();g.sig=n(t,S),g.sigval=a(t,S);var E=null;return g.obj=new l,(E=new h).hTLV=g.version,g.obj.dCMSVersion=E,(E=new h).hTLV=g.si,g.obj.dSignerIdentifier=E,(E=new h).hTLV=g.digalg,g.obj.dDigestAlgorithm=E,(E=new h).hTLV=g.sattrs,g.obj.dSignedAttrs=E,(E=new h).hTLV=g.sigalg,g.obj.dSigAlg=E,(E=new h).hTLV=g.sig,g.obj.dSig=E,g.obj.dUnsignedAttrs=new c,g},void 0!==nt.asn1.csr&&nt.asn1.csr||(nt.asn1.csr={}),nt.asn1.csr.CertificationRequest=function(t){var e=nt.asn1,r=e.DERBitString,i=e.DERSequence,s=e.csr,n=(e.x509,s.CertificationRequestInfo);s.CertificationRequest.superclass.constructor.call(this),this.setByParam=function(t){this.params=t},this.sign=function(){var t=new n(this.params).tohex(),e=new nt.crypto.Signature({alg:this.params.sigalg});e.init(this.params.sbjprvkey),e.updateHex(t);var r=e.sign();this.params.sighex=r},this.getPEM=function(){return Et(this.tohex(),"CERTIFICATE REQUEST")},this.tohex=function(){var t=this.params,e=new nt.asn1.csr.CertificationRequestInfo(this.params),s=new nt.asn1.x509.AlgorithmIdentifier({name:t.sigalg});if(null==t.sighex&&null!=t.sbjprvkey&&this.sign(),null==t.sighex)throw new Error("sighex or sbjprvkey parameter not defined");var n=new r({hex:"00"+t.sighex});return new i({array:[e,s,n]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.csr.CertificationRequest,nt.asn1.ASN1Object),nt.asn1.csr.CertificationRequestInfo=function(t){var e=nt.asn1,r=(e.DERBitString,e.DERSequence),i=e.DERInteger,s=e.DERUTF8String,n=e.DERTaggedObject,a=e.ASN1Util.newObject,o=e.csr,h=e.x509,u=h.X500Name,c=h.Extensions,l=h.SubjectPublicKeyInfo;o.AttributeList,o.CertificationRequestInfo.superclass.constructor.call(this),this.params=null,this.setByParam=function(t){null!=t&&(this.params=t)},this.tohex=function(){var t=this.params,e=[];if(e.push(new i({int:0})),e.push(new u(t.subject)),e.push(new l(Mt.getKey(t.sbjpubkey))),null!=t.attrs){var o=function(t){for(var e=Error,r=nt.asn1.x509.Extensions,i=[],s=0;s<t.length;s++){var n=t[s],a=n.attr;if("extensionRequest"==a){var o={seq:[{oid:"1.2.840.113549.1.9.14"},{set:[new r(n.ext)]}]};i.push(o)}else if("unstructuredName"==a)o={seq:[{oid:"1.2.840.113549.1.9.2"},{set:n.names}]},i.push(o);else{if("challengePassword"!=a)throw new e("unknown CSR attribute");o={seq:[{oid:"1.2.840.113549.1.9.7"},{set:[{utf8str:n.password}]}]},i.push(o)}}return{set:i}}(t.attrs),h=a({tag:{tage:"a0",obj:o}});e.push(h)}else if(null!=t.extreq){var g=new c(t.extreq);h=a({tag:{tage:"a0",obj:{seq:[{oid:"1.2.840.113549.1.9.14"},{set:[g]}]}}}),e.push(h)}else e.push(new n({tag:"a0",explicit:!1,obj:new s({str:""})}));return new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},jt(nt.asn1.csr.CertificationRequestInfo,nt.asn1.ASN1Object),nt.asn1.csr.AttributeList=function(t){},jt(nt.asn1.csr.AttributeList,nt.asn1.ASN1Object),nt.asn1.csr.CSRUtil=new function(){},nt.asn1.csr.CSRUtil.newCSRPEM=function(t){return new nt.asn1.csr.CertificationRequest(t).getPEM()},nt.asn1.csr.CSRUtil.getParam=function(t,e){var r=ht,i=r.getV,s=r.getIdxbyList,n=r.getTLVbyList,a=r.getTLVbyListEx,o=r.getVbyListEx,h={};if(-1==t.indexOf("-----BEGIN CERTIFICATE REQUEST"))throw new Error("argument is not PEM file");var u=xt(t,"CERTIFICATE REQUEST");e&&(h.tbs=n(u,0,[0]));try{var c=a(u,0,[0,1]);if("3000"==c)h.subject={};else{var l=new Wt;h.subject=l.getX500Name(c)}}catch(t){}var g=a(u,0,[0,2]),p=Mt.getKey(g,null,"pkcs8pub");h.sbjpubkey=Mt.getPEM(p,"PKCS8PUB");var d=function(t){var e=s(t,0,[0,3,0,0],"06");return"2a864886f70d01090e"!=i(t,e)?null:n(t,0,[0,3,0,1,0],"30")}(u);l=new Wt,null!=d&&(h.extreq=l.getExtParamArray(d));try{var f=a(u,0,[1],"30");l=new Wt,h.sigalg=l.getAlgorithmIdentifierName(f)}catch(t){}try{var y=o(u,0,[2]);h.sighex=y}catch(t){}return h},nt.asn1.csr.CSRUtil.verifySignature=function(t){try{var e=null;if("string"==typeof t&&-1!=t.indexOf("-----BEGIN CERTIFICATE REQUEST")?e=nt.asn1.csr.CSRUtil.getParam(t,!0):"object"==typeof t&&null!=t.sbjpubkey&&null!=t.sigalg&&null!=t.sighex&&null!=t.tbs&&(e=t),null==e)return!1;var r=new nt.crypto.Signature({alg:e.sigalg});return r.init(e.sbjpubkey),r.updateHex(e.tbs),r.verify(e.sighex)}catch(t){return alert(t),!1}},void 0!==nt&&nt||(nt={}),void 0!==nt.asn1&&nt.asn1||(nt.asn1={}),void 0!==nt.asn1.ocsp&&nt.asn1.ocsp||(nt.asn1.ocsp={}),nt.asn1.ocsp.DEFAULT_HASH="sha1",nt.asn1.ocsp.OCSPResponse=function(t){nt.asn1.ocsp.OCSPResponse.superclass.constructor.call(this),nt.asn1.DEREnumerated;var e=nt.asn1.ASN1Util.newObject,r=nt.asn1.ocsp.ResponseBytes,i=["successful","malformedRequest","internalError","tryLater","_not_used_","sigRequired","unauthorized"];this.params=null,this._getStatusCode=function(){var t=this.params.resstatus;return"number"==typeof t?t:"string"!=typeof t?-1:i.indexOf(t)},this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params,i=this._getStatusCode();if(-1==i)throw new Error("responseStatus not supported: "+t.resstatus);if(0!=i)return e({seq:[{enum:{int:i}}]}).tohex();var s=new r(t);return e({seq:[{enum:{int:0}},{tag:{tag:"a0",explicit:!0,obj:s}}]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.ocsp.OCSPResponse,nt.asn1.ASN1Object),nt.asn1.ocsp.ResponseBytes=function(t){nt.asn1.ocsp.ResponseBytes.superclass.constructor.call(this);var e=nt.asn1,r=e.DERSequence,i=e.DERObjectIdentifier,s=e.DEROctetString,n=e.ocsp.BasicOCSPResponse;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if("ocspBasic"!=t.restype)throw new Error("not supported responseType: "+t.restype);var e=new n(t),a=[];return a.push(new i({name:"ocspBasic"})),a.push(new s({hex:e.tohex()})),new r({array:a}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.ocsp.ResponseBytes,nt.asn1.ASN1Object),nt.asn1.ocsp.BasicOCSPResponse=function(t){nt.asn1.ocsp.BasicOCSPResponse.superclass.constructor.call(this);var e=Error,r=nt.asn1,i=r.ASN1Object,s=r.DERSequence,n=(r.DERGeneralizedTime,r.DERTaggedObject),a=r.DERBitString,o=(r.x509.Extensions,r.x509.AlgorithmIdentifier),h=r.ocsp;h.ResponderID,_SingleResponseList=h.SingleResponseList,_ResponseData=h.ResponseData,this.params=null,this.setByParam=function(t){this.params=t},this.sign=function(){var t=this.params,e=t.tbsresp.tohex(),r=new nt.crypto.Signature({alg:t.sigalg});r.init(t.reskey),r.updateHex(e),t.sighex=r.sign()},this.tohex=function(){var t=this.params;null==t.tbsresp&&(t.tbsresp=new _ResponseData(t)),null==t.sighex&&null!=t.reskey&&this.sign();var r=[];if(r.push(t.tbsresp),r.push(new o({name:t.sigalg})),r.push(new a({hex:"00"+t.sighex})),null!=t.certs&&null!=t.certs.length){for(var h=[],u=0;u<t.certs.length;u++){var c=t.certs[u],l=null;if(ht.isASN1HEX(c))l=c;else{if(!c.match(/-----BEGIN/))throw new e("certs["+u+"] not hex or PEM");l=xt(c)}h.push(new i({tlv:l}))}var g=new s({array:h});r.push(new n({tag:"a0",explicit:!0,obj:g}))}return new s({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.ocsp.BasicOCSPResponse,nt.asn1.ASN1Object),nt.asn1.ocsp.ResponseData=function(t){nt.asn1.ocsp.ResponseData.superclass.constructor.call(this);var e=Error,r=nt.asn1,i=r.DERSequence,s=r.DERGeneralizedTime,n=r.DERTaggedObject,a=r.x509.Extensions,o=r.ocsp,h=o.ResponderID;_SingleResponseList=o.SingleResponseList,this.params=null,this.tohex=function(){var t=this.params;null!=t.respid&&new e("respid not specified"),null!=t.prodat&&new e("prodat not specified"),null!=t.array&&new e("array not specified");var r=[];if(r.push(new h(t.respid)),r.push(new s(t.prodat)),r.push(new _SingleResponseList(t.array)),null!=t.ext){var o=new a(t.ext);r.push(new n({tag:"a1",explicit:!0,obj:o}))}return new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},jt(nt.asn1.ocsp.ResponseData,nt.asn1.ASN1Object),nt.asn1.ocsp.ResponderID=function(t){nt.asn1.ocsp.ResponderID.superclass.constructor.call(this);var e=nt,r=e.asn1,i=r.ASN1Util.newObject,s=r.x509.X500Name,n=e.lang.String.isHex,a=Error;this.params=null,this.tohex=function(){var t=this.params;if(null!=t.key){var e,r=null;if("string"==typeof t.key?(n(t.key)&&(r=t.key),t.key.match(/-----BEGIN CERTIFICATE/)&&null!=(e=new Wt(t.key).getExtSubjectKeyIdentifier())&&(r=e.kid.hex)):t.key instanceof Wt&&null!=(e=t.key.getExtSubjectKeyIdentifier())&&(r=e.kid.hex),null==r)throw new a("wrong key member value");return i({tag:{tag:"a2",explicit:!0,obj:{octstr:{hex:r}}}}).tohex()}if(null!=t.name){var o=null;if("string"==typeof t.name&&t.name.match(/-----BEGIN CERTIFICATE/)?o=new Wt(t.name).getSubject():t.name instanceof Wt?o=t.name.getSubject():"object"!=typeof t.name||null==t.name.array&&null==t.name.str||(o=t.name),null==o)throw new a("wrong name member value");return i({tag:{tag:"a1",explicit:!0,obj:new s(o)}}).tohex()}throw new a("key or name not specified")},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},jt(nt.asn1.ocsp.ResponderID,nt.asn1.ASN1Object),nt.asn1.ocsp.SingleResponseList=function(t){nt.asn1.ocsp.SingleResponseList.superclass.constructor.call(this);var e=nt.asn1,r=e.DERSequence,i=e.ocsp.SingleResponse;this.params=null,this.tohex=function(){var t=this.params;if("object"!=typeof t||null==t.length)throw new Error("params not specified properly");for(var e=[],s=0;s<t.length;s++)e.push(new i(t[s]));return new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},jt(nt.asn1.ocsp.SingleResponseList,nt.asn1.ASN1Object),nt.asn1.ocsp.SingleResponse=function(t){var e=Error,r=nt.asn1,i=r.DERSequence,s=r.DERGeneralizedTime,n=r.DERTaggedObject,a=r.ocsp,o=a.CertID,h=a.CertStatus,u=r.x509.Extensions;a.SingleResponse.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,r=[];if(null==t.certid)throw new e("certid unspecified");if(null==t.status)throw new e("status unspecified");if(null==t.thisupdate)throw new e("thisupdate unspecified");if(r.push(new o(t.certid)),r.push(new h(t.status)),r.push(new s(t.thisupdate)),null!=t.nextupdate){var a=new s(t.nextupdate);r.push(new n({tag:"a0",explicit:!0,obj:a}))}if(null!=t.ext){var c=new u(t.ext);r.push(new n({tag:"a1",explicit:!0,obj:c}))}return new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},jt(nt.asn1.ocsp.SingleResponse,nt.asn1.ASN1Object),nt.asn1.ocsp.CertID=function(t){var e=nt,r=e.asn1,i=r.DEROctetString,s=r.DERInteger,n=r.DERSequence,a=r.x509.AlgorithmIdentifier,o=r.ocsp,h=(o.DEFAULT_HASH,e.crypto.Util.hashHex),u=Wt,c=ht.getVbyList;o.CertID.superclass.constructor.call(this),this.DEFAULT_HASH="sha1",this.params=null,this.setByValue=function(t,e,r,i){null==i&&(i=this.DEFAULT_HASH),this.params={alg:i,issname:t,isskey:e,sbjsn:r}},this.setByCert=function(t,e,r){null==r&&(r=this.DEFAULT_HASH),this.params={alg:r,issuerCert:t,subjectCert:e}},this.getParamByCerts=function(t,e,r){null==r&&(r=this.DEFAULT_HASH);var i=new u(t),s=new u(e),n=h(i.getSubjectHex(),r),a=i.getPublicKeyHex();return{alg:r,issname:n,isskey:h(c(a,0,[1],"03",!0),r),sbjsn:s.getSerialNumberHex()}},this.tohex=function(){if("object"!=typeof this.params)throw new Error("params not set");var t,e,r,o,h=this.params;if(o=null==h.alg?this.DEFAULT_HASH:h.alg,null!=h.issuerCert&&null!=h.subjectCert){var u=this.getParamByCerts(h.issuerCert,h.subjectCert,o);t=u.issname,e=u.isskey,r=u.sbjsn}else{if(null==h.issname||null==h.isskey||null==h.sbjsn)throw new Error("required param members not defined");t=h.issname,e=h.isskey,r=h.sbjsn}var c=new a({name:o}),l=new i({hex:t}),g=new i({hex:e}),p=new s({hex:r}),d=new n({array:[c,l,g,p]});return this.hTLV=d.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},jt(nt.asn1.ocsp.CertID,nt.asn1.ASN1Object),nt.asn1.ocsp.CertStatus=function(t){nt.asn1.ocsp.CertStatus.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if("good"==t.status)return"8000";if("unknown"==t.status)return"8200";if("revoked"==t.status){var e=[{gentime:{str:t.time}}];null!=t.reason&&e.push({tag:{tag:"a0",explicit:!0,obj:{enum:{int:t.reason}}}});var r={tag:"a1",explicit:!1,obj:{seq:e}};return nt.asn1.ASN1Util.newObject({tag:r}).tohex()}throw new Error("bad status")},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},jt(nt.asn1.ocsp.CertStatus,nt.asn1.ASN1Object),nt.asn1.ocsp.Request=function(t){var e=nt.asn1,r=e.DERSequence,i=e.ocsp;if(i.Request.superclass.constructor.call(this),this.dReqCert=null,this.dExt=null,this.tohex=function(){var t=[];if(null===this.dReqCert)throw"reqCert not set";t.push(this.dReqCert);var e=new r({array:t});return this.hTLV=e.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t){var s=new i.CertID(t);this.dReqCert=s}},jt(nt.asn1.ocsp.Request,nt.asn1.ASN1Object),nt.asn1.ocsp.TBSRequest=function(t){var e=nt.asn1,r=e.DERSequence,i=e.ocsp;i.TBSRequest.superclass.constructor.call(this),this.version=0,this.dRequestorName=null,this.dRequestList=[],this.dRequestExt=null,this.setRequestListByParam=function(t){for(var e=[],r=0;r<t.length;r++){var s=new i.Request(t[0]);e.push(s)}this.dRequestList=e},this.tohex=function(){var t=[];if(0!==this.version)throw"not supported version: "+this.version;if(null!==this.dRequestorName)throw"requestorName not supported";var e=new r({array:this.dRequestList});if(t.push(e),null!==this.dRequestExt)throw"requestExtensions not supported";var i=new r({array:t});return this.hTLV=i.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&void 0!==t.reqList&&this.setRequestListByParam(t.reqList)},jt(nt.asn1.ocsp.TBSRequest,nt.asn1.ASN1Object),nt.asn1.ocsp.OCSPRequest=function(t){var e=nt.asn1,r=e.DERSequence,i=e.ocsp;if(i.OCSPRequest.superclass.constructor.call(this),this.dTbsRequest=null,this.dOptionalSignature=null,this.tohex=function(){var t=[];if(null===this.dTbsRequest)throw"tbsRequest not set";if(t.push(this.dTbsRequest),null!==this.dOptionalSignature)throw"optionalSignature not supported";var e=new r({array:t});return this.hTLV=e.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&void 0!==t.reqList){var s=new i.TBSRequest(t);this.dTbsRequest=s}},jt(nt.asn1.ocsp.OCSPRequest,nt.asn1.ASN1Object),nt.asn1.ocsp.OCSPUtil={},nt.asn1.ocsp.OCSPUtil.getRequestHex=function(t,e,r){var i=nt.asn1.ocsp;void 0===r&&(r=i.DEFAULT_HASH);var s={alg:r,issuerCert:t,subjectCert:e};return new i.OCSPRequest({reqList:[s]}).tohex()},nt.asn1.ocsp.OCSPUtil.getOCSPResponseInfo=function(t){var e=ht,r=e.getVbyList,i=e.getVbyListEx,s=e.getIdxbyList,n=(e.getIdxbyListEx,e.getV),a={};try{var o=i(t,0,[0],"0a");a.responseStatus=parseInt(o,16)}catch(t){}if(0!==a.responseStatus)return a;try{var h=s(t,0,[1,0,1,0,0,2,0,1]);"80"===t.substr(h,2)?a.certStatus="good":"a1"===t.substr(h,2)?(a.certStatus="revoked",a.revocationTime=yt(r(t,h,[0]))):"82"===t.substr(h,2)&&(a.certStatus="unknown")}catch(t){}try{var u=s(t,0,[1,0,1,0,0,2,0,2]);a.thisUpdate=yt(n(t,u))}catch(t){}try{var c=s(t,0,[1,0,1,0,0,2,0,3]);"a0"===t.substr(c,2)&&(a.nextUpdate=yt(r(t,c,[0])))}catch(t){}return a},nt.asn1.ocsp.OCSPParser=function(){var t=Error,e=Wt,r=new e,i=ht,s=i.getV,n=i.getTLV,a=i.getIdxbyList,o=i.getVbyList,h=i.getTLVbyList,u=i.getVbyListEx,c=i.getTLVbyListEx,l=i.getChildIdx;this.getOCSPRequest=function(e){var r=l(e,0);if(1!=r.length&&2!=r.length)throw new t("wrong number elements: "+r.length);return this.getTBSRequest(n(e,r[0]))},this.getTBSRequest=function(t){var e={},i=c(t,0,[0],"30");e.array=this.getRequestList(i);var s=c(t,0,["[2]",0],"30");return null!=s&&(e.ext=r.getExtParamArray(s)),e},this.getRequestList=function(t){for(var e=[],r=l(t,0),i=0;i<r.length;i++)t=n(t,r[i]),e.push(this.getRequest(t));return e},this.getRequest=function(e){var i=l(e,0);if(1!=i.length&&2!=i.length)throw new t("wrong number elements: "+i.length);var s=this.getCertID(n(e,i[0]));if(2==i.length){var o=a(e,0,[1,0]);s.ext=r.getExtParamArray(n(e,o))}return s},this.getCertID=function(r){var i=l(r,0);if(4!=i.length)throw new t("wrong number elements: "+i.length);var a=new e,o={};return o.alg=a.getAlgorithmIdentifierName(n(r,i[0])),o.issname=s(r,i[1]),o.isskey=s(r,i[2]),o.sbjsn=s(r,i[3]),o},this.getOCSPResponse=function(t){var e,r=l(t,0),i=s(t,r[0]),n=parseInt(i);if(1==r.length)return{resstatus:n};var a=h(t,0,[1,0]);return(e=this.getResponseBytes(a)).resstatus=n,e},this.getResponseBytes=function(t){var e,r=l(t,0),i=h(t,0,[1,0]);e=this.getBasicOCSPResponse(i);var n=s(t,r[0]);return e.restype=nt.asn1.x509.OID.oid2name(Bt(n)),e},this.getBasicOCSPResponse=function(t){var e,r=l(t,0);e=this.getResponseData(n(t,r[0]));var i=new Wt;e.alg=i.getAlgorithmIdentifierName(n(t,r[1]));var a=s(t,r[2]);e.sighex=a.substr(2);var o=u(t,0,["[0]"]);if(null!=o){for(var h=l(o,0),c=[],g=0;g<h.length;g++){var p=n(o,h[g]);c.push(p)}e.certs=c}return e},this.getResponseData=function(t){var e=l(t,0),r=e.length,i={},a=0;"a0"==t.substr(e[0],2)&&a++,i.respid=this.getResponderID(n(t,e[a++]));var o=s(t,e[a++]);if(i.prodat=yt(o),i.array=this.getSingleResponseList(n(t,e[a++])),"a1"==t.substr(e[r-1],2)){var u=h(t,e[r-1],[0]),c=new Wt;i.ext=c.getExtParamArray(u)}return i},this.getResponderID=function(t){var e={};if("a2"==t.substr(0,2)){var r=o(t,0,[0]);e.key=r}if("a1"==t.substr(0,2)){var i=h(t,0,[0]),s=new Wt;e.name=s.getX500Name(i)}return e},this.getSingleResponseList=function(t){for(var e=l(t,0),r=[],i=0;i<e.length;i++){var s=this.getSingleResponse(n(t,e[i]));r.push(s)}return r},this.getSingleResponse=function(t){var e=l(t,0),r={},i=this.getCertID(n(t,e[0]));r.certid=i;var a=this.getCertStatus(n(t,e[1]));if(r.status=a,"18"==t.substr(e[2],2)){var u=s(t,e[2]);r.thisupdate=yt(u)}for(var c=3;c<e.length;c++){if("a0"==t.substr(e[c],2)){var g=o(t,e[c],[0],"18");r.nextupdate=yt(g)}if("a1"==t.substr(e[c],2)){var p=new Wt,d=h(t,0,[c,0]);r.ext=p.getExtParamArray(d)}}return r},this.getCertStatus=function(t){var e={};if("8000"==t)return{status:"good"};if("8200"==t)return{status:"unknown"};if("a1"==t.substr(0,2)){e.status="revoked";var r=yt(o(t,0,[0]));e.time=r}return e}},void 0!==nt&&nt||(nt={}),void 0!==nt.lang&&nt.lang||(nt.lang={}),nt.lang.String=function(){},"function"==typeof Buffer?(at=function(t){return lt(Buffer.from(t,"utf8").toString("base64"))},ot=function(t){return Buffer.from(gt(t),"base64").toString("utf8")}):(at=function(t){return pt(At(Dt(t)))},ot=function(t){return decodeURIComponent(wt(dt(t)))}),nt.lang.String.isInteger=function(t){return!!t.match(/^[0-9]+$/)||!!t.match(/^-[0-9]+$/)},nt.lang.String.isHex=function(t){return Nt(t)},nt.lang.String.isBase64=function(t){return!(!(t=t.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||t.length%4!=0)},nt.lang.String.isBase64URL=function(t){return!t.match(/[+/=]/)&&(t=gt(t),nt.lang.String.isBase64(t))},nt.lang.String.isIntegerArray=function(t){return!!(t=t.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)},nt.lang.String.isPrintable=function(t){return null!==t.match(/^[0-9A-Za-z '()+,-./:=?]*$/)},nt.lang.String.isIA5=function(t){return null!==t.match(/^[\x20-\x21\x23-\x7f]*$/)},nt.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 kt=function(t,e,r){return null==r&&(r="0"),t.length>=e?t:new Array(e-t.length+1).join(r)+t};function Ut(t,e){for(var r=0,i=0;i<t.length;i++)r|=1<<e[t[i]];var s=r.toString(2),n="";for(i=s.length-1;i>=0;i--)n+=s[i];return n}function Vt(t,e,r){if("object"==typeof t){e=String(e).split(".");for(var i=0;i<e.length&&t;i++){var s=e[i];s.match(/^[0-9]+$/)&&(s=parseInt(s)),t=t[s]}return t||!1===t?t:r}}function jt(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!==nt&&nt||(nt={}),void 0!==nt.crypto&&nt.crypto||(nt.crypto={}),nt.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:f.algo.MD5,sha1:f.algo.SHA1,sha224:f.algo.SHA224,sha256:f.algo.SHA256,sha384:f.algo.SHA384,sha512:f.algo.SHA512,ripemd160:f.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 i=this.getDigestInfoHex(t,e),s=r/4;if(i.length+22>s)throw"key is too short for SigAlg: keylen="+r+","+e;for(var n="00"+i,a="",o=s-4-n.length,h=0;h<o;h+=2)a+="ff";return"0001"+a+n},this.hashString=function(t,e){return new nt.crypto.MessageDigest({alg:e}).digestString(t)},this.hashHex=function(t,e){return new nt.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 nt.crypto.DSA||t instanceof nt.crypto.ECDSA}},nt.crypto.Util.md5=function(t){return new nt.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(t)},nt.crypto.Util.ripemd160=function(t){return new nt.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(t)},nt.crypto.Util.SECURERANDOMGEN=new Q,nt.crypto.Util.getRandomHexOfNbytes=function(t){var e=new Array(t);return nt.crypto.Util.SECURERANDOMGEN.nextBytes(e),ut(e)},nt.crypto.Util.getRandomBigIntegerOfNbytes=function(t){return new E(nt.crypto.Util.getRandomHexOfNbytes(t),16)},nt.crypto.Util.getRandomHexOfNbits=function(t){var e=t%8,r=new Array((t-e)/8+1);return nt.crypto.Util.SECURERANDOMGEN.nextBytes(r),r[0]=(255<<e&255^255)&r[0],ut(r)},nt.crypto.Util.getRandomBigIntegerOfNbits=function(t){return new E(nt.crypto.Util.getRandomHexOfNbits(t),16)},nt.crypto.Util.getRandomBigIntegerZeroToMax=function(t){for(var e=t.bitLength();;){var r=nt.crypto.Util.getRandomBigIntegerOfNbits(e);if(-1!=t.compareTo(r))return r}},nt.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 i=e.subtract(t);return nt.crypto.Util.getRandomBigIntegerZeroToMax(i).add(t)},nt.crypto.MessageDigest=function(t){this.setAlgAndProvider=function(t,e){if(null!==(t=nt.crypto.MessageDigest.getCanonicalAlgName(t))&&void 0===e&&(e=nt.crypto.Util.DEFAULTPROVIDER[t]),-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(t)&&"cryptojs"==e){try{this.md=nt.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=f.enc.Hex.parse(t);this.md.update(e)},this.digest=function(){return this.md.finalize().toString(f.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=nt.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},nt.crypto.MessageDigest.getCanonicalAlgName=function(t){return"string"==typeof t&&(t=(t=t.toLowerCase()).replace(/-/,"")),t},nt.crypto.MessageDigest.getHashLength=function(t){var e=nt.crypto.MessageDigest,r=e.getCanonicalAlgName(t);if(void 0===e.HASHLENGTH[r])throw"not supported algorithm: "+t;return e.HASHLENGTH[r]},nt.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},nt.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=nt.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 i=nt.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[r];this.mac=f.algo.HMAC.create(i,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=f.enc.Hex.parse(t);this.mac.update(e)},this.doFinal=function(){return this.mac.finalize().toString(f.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=St(t)),void(this.pass=f.enc.Hex.parse(e))}if("object"!=typeof t)throw"KJUR.crypto.Mac unsupported password type: "+t;if(e=null,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=ft(t.utf8)),void 0!==t.rstr&&(e=St(t.rstr)),void 0!==t.b64&&(e=S(t.b64)),void 0!==t.b64u&&(e=dt(t.b64u)),null==e)throw"KJUR.crypto.Mac unsupported password type: "+t;this.pass=f.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=nt.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))},nt.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="",i=e/4-t.length,s=0;s<i;s++)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 nt.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?Mt.getKey(t):Mt.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!==nt.crypto.ECDSA&&(this.prvKey=new nt.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 nt.crypto.ECDSA)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex);else{if(!(this.prvKey instanceof nt.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!==nt.crypto.ECDSA&&(this.pubKey=new nt.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!==nt.crypto.ECDSA&&this.pubKey instanceof nt.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==nt.crypto.DSA&&this.pubKey instanceof nt.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=nt.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=Mt.getKey(t.prvkeypem),this.init(e)}catch(t){throw"fatal error to load pem private key: "+t}}},nt.crypto.Cipher=function(t){},nt.crypto.Cipher.encrypt=function(t,e,r,i){if(null!=Vt(i,"enclag")&&(r=i.encalg),"string"==typeof r&&"-CBC"==r.substr(-4)){var s=e,n=t;null!=Vt(i,"key")&&(s=i.key),null!=Vt(i,"enc")&&(hEnc=i.enc);var a,o=f.enc.Hex.parse(s),h=f.enc.Hex.parse(n),u=f.enc.Hex.parse(i.iv);if("des-EDE3-CBC"==r)a=f.TripleDES.encrypt(h,o,{iv:u});else{if("aes128-CBC"!=r&&"aes256-CBC"!=r)throw new Error("unsupported algorithm: "+r);a=f.AES.encrypt(h,o,{iv:u})}return a+""}throw new Error("Cipher.encrypt: unsupported key or algorithm")},nt.crypto.Cipher.decrypt=function(t,e,r,i){if(null!=Vt(i,"enclag")&&(r=i.encalg),"string"==typeof r&&"-CBC"==r.substr(-4)){var s=e,n=t;null!=Vt(i,"key")&&(s=i.key),null!=Vt(i,"enc")&&(n=i.enc);var a,o=f.enc.Hex.parse(s),h=f.enc.Hex.parse(n),u=f.enc.Hex.parse(i.iv);if("des-EDE3-CBC"==r)a=f.TripleDES.decrypt({ciphertext:h},o,{iv:u});else{if("aes128-CBC"!=r&&"aes256-CBC"!=r)throw new Error("unsupported algorithm: "+r);a=f.AES.decrypt({ciphertext:h},o,{iv:u})}return f.enc.Hex.stringify(a)}throw new Error("Cipher.decrypt: unsupported key or algorithm")},nt.crypto.OID=new function(){this.oidhex2name={"2a864886f70d010101":"rsaEncryption","2a8648ce3d0201":"ecPublicKey","2a8648ce380401":"dsa","2a8648ce3d030107":"secp256r1","2b8104001f":"secp192k1","2b81040021":"secp224r1","2b8104000a":"secp256k1","2b81040022":"secp384r1","2b81040023":"secp521r1","2a8648ce380403":"SHA1withDSA","608648016503040301":"SHA224withDSA","608648016503040302":"SHA256withDSA"}},void 0!==nt&&nt||(nt={}),void 0!==nt.crypto&&nt.crypto||(nt.crypto={}),nt.crypto.ECDSA=function(t){var e=Error,r=E,i=rt,s=nt.crypto.ECDSA,n=nt.crypto.ECParameterDB,a=s.getName,o=ht,h=o.getVbyListEx,u=o.isASN1HEX,c=new Q;this.type="EC",this.isPrivate=!1,this.isPublic=!1,this.getBigRandom=function(t){return new r(t.bitLength(),c).mod(t.subtract(r.ONE)).add(r.ONE)},this.setNamedCurve=function(t){this.ecparams=n.getByName(t),this.prvKeyHex=null,this.pubKeyHex=null,this.curveName=t},this.setPrivateKeyHex=function(t){this.isPrivate=!0,this.prvKeyHex=t},this.setPublicKeyHex=function(t){this.isPublic=!0,this.pubKeyHex=t},this.getPublicKeyXYHex=function(){var t=this.pubKeyHex;if("04"!==t.substr(0,2))throw"this method supports uncompressed format(04) only";var e=this.ecparams.keycharlen;if(t.length!==2+2*e)throw"malformed public key hex length";var r={};return r.x=t.substr(2,e),r.y=t.substr(2+e),r},this.getShortNISTPCurveName=function(){var t=this.curveName;return"secp256r1"===t||"NIST P-256"===t||"P-256"===t||"prime256v1"===t?"P-256":"secp384r1"===t||"NIST P-384"===t||"P-384"===t?"P-384":"secp521r1"===t||"NIST P-521"===t||"P-521"===t?"P-521":null},this.generateKeyPairHex=function(){var t=this.ecparams.n,e=this.getBigRandom(t),r=this.ecparams.keycharlen,i=("0000000000"+e.toString(16)).slice(-r);return this.setPrivateKeyHex(i),{ecprvhex:i,ecpubhex:this.generatePublicKeyHex()}},this.generatePublicKeyHex=function(){var t=new r(this.prvKeyHex,16),e=this.ecparams.G.multiply(t),i=e.getX().toBigInteger(),s=e.getY().toBigInteger(),n=this.ecparams.keycharlen,a="04"+("0000000000"+i.toString(16)).slice(-n)+("0000000000"+s.toString(16)).slice(-n);return this.setPublicKeyHex(a),a},this.signWithMessageHash=function(t){return this.signHex(t,this.prvKeyHex)},this.signHex=function(t,e){var i=new r(e,16),n=this.ecparams.n,a=new r(t.substring(0,this.ecparams.keycharlen),16);do{var o=this.getBigRandom(n),h=this.ecparams.G.multiply(o).getX().toBigInteger().mod(n)}while(h.compareTo(r.ZERO)<=0);var u=o.modInverse(n).multiply(a.add(i.multiply(h))).mod(n);return s.biRSSigToASN1Sig(h,u)},this.sign=function(t,e){var i=e,s=this.ecparams.n,n=r.fromByteArrayUnsigned(t);do{var a=this.getBigRandom(s),o=this.ecparams.G.multiply(a).getX().toBigInteger().mod(s)}while(o.compareTo(E.ZERO)<=0);var h=a.modInverse(s).multiply(n.add(i.multiply(o))).mod(s);return this.serializeSig(o,h)},this.verifyWithMessageHash=function(t,e){return this.verifyHex(t,e,this.pubKeyHex)},this.verifyHex=function(t,e,n){try{var a,o,h=s.parseSigHex(e);a=h.r,o=h.s;var u=i.decodeFromHex(this.ecparams.curve,n),c=new r(t.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(c,a,o,u)}catch(t){return!1}},this.verify=function(t,e,s){var n,a,o;if(Bitcoin.Util.isArray(e)){var h=this.parseSig(e);n=h.r,a=h.s}else{if("object"!=typeof e||!e.r||!e.s)throw"Invalid value for signature";n=e.r,a=e.s}if(s instanceof rt)o=s;else{if(!Bitcoin.Util.isArray(s))throw"Invalid format for pubkey value, must be byte array or ECPointFp";o=i.decodeFrom(this.ecparams.curve,s)}var u=r.fromByteArrayUnsigned(t);return this.verifyRaw(u,n,a,o)},this.verifyRaw=function(t,e,i,s){var n=this.ecparams.n,a=this.ecparams.G;if(e.compareTo(r.ONE)<0||e.compareTo(n)>=0)return!1;if(i.compareTo(r.ONE)<0||i.compareTo(n)>=0)return!1;var o=i.modInverse(n),h=t.multiply(o).mod(n),u=e.multiply(o).mod(n);return a.multiply(h).add(s.multiply(u)).getX().toBigInteger().mod(n).equals(e)},this.serializeSig=function(t,e){var r=t.toByteArraySigned(),i=e.toByteArraySigned(),s=[];return s.push(2),s.push(r.length),(s=s.concat(r)).push(2),s.push(i.length),(s=s.concat(i)).unshift(s.length),s.unshift(48),s},this.parseSig=function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if(2!=t[e=2])throw new Error("First element in signature must be a DERInteger");var i=t.slice(e+2,e+2+t[e+1]);if(2!=t[e+=2+t[e+1]])throw new Error("Second element in signature must be a DERInteger");var s=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:r.fromByteArrayUnsigned(i),s:r.fromByteArrayUnsigned(s)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||e>7)throw"Invalid signature type";var i=this.ecparams.n;return{r:r.fromByteArrayUnsigned(t.slice(1,33)).mod(i),s:r.fromByteArrayUnsigned(t.slice(33,65)).mod(i),i:e}},this.readPKCS5PrvKeyHex=function(t){if(!1===u(t))throw new Error("not ASN.1 hex string");var e,r,i;try{e=h(t,0,["[0]",0],"06"),r=h(t,0,[1],"04");try{i=h(t,0,["[1]",0],"03")}catch(t){}}catch(t){throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=a(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(i),this.setPrivateKeyHex(r),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){if(!1===u(t))throw new e("not ASN.1 hex string");var r,i,s;try{h(t,0,[1,0],"06"),r=h(t,0,[1,1],"06"),i=h(t,0,[2,0,1],"04");try{s=h(t,0,[2,0,"[1]",0],"03")}catch(t){}}catch(t){throw new e("malformed PKCS#8 plain ECC private key")}if(this.curveName=a(r),void 0===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(s),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){if(!1===u(t))throw new e("not ASN.1 hex string");var r,i;try{h(t,0,[0,0],"06"),r=h(t,0,[0,1],"06"),i=h(t,0,[1],"03")}catch(t){throw new e("malformed PKCS#8 ECC public key")}if(this.curveName=a(r),null===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(i)},this.readCertPubKeyHex=function(t,r){if(!1===u(t))throw new e("not ASN.1 hex string");var i,s;try{i=h(t,0,[0,5,0,1],"06"),s=h(t,0,[0,5,1],"03")}catch(t){throw new e("malformed X.509 certificate ECC public key")}if(this.curveName=a(i),null===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(s)},void 0!==t&&void 0!==t.curve&&(this.curveName=t.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==t&&(void 0!==t.prv&&this.setPrivateKeyHex(t.prv),void 0!==t.pub&&this.setPublicKeyHex(t.pub))},nt.crypto.ECDSA.parseSigHex=function(t){var e=nt.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new E(e.r,16),s:new E(e.s,16)}},nt.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=ht,r=e.getChildIdx,i=e.getV;if(e.checkStrictDER(t,0),"30"!=t.substr(0,2))throw new Error("signature is not a ASN.1 sequence");var s=r(t,0);if(2!=s.length)throw new Error("signature shall have two elements");var n=s[0],a=s[1];if("02"!=t.substr(n,2))throw new Error("1st item not ASN.1 integer");if("02"!=t.substr(a,2))throw new Error("2nd item not ASN.1 integer");return{r:i(t,n),s:i(t,a)}},nt.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=nt.crypto.ECDSA.parseSigHexInHexRS(t),r=e.r,i=e.s;if(r.length>=130&&r.length<=134){if(r.length%2!=0)throw Error("unknown ECDSA sig r length error");if(i.length%2!=0)throw Error("unknown ECDSA sig s length error");"00"==r.substr(0,2)&&(r=r.substr(2)),"00"==i.substr(0,2)&&(i=i.substr(2));var s=Math.max(r.length,i.length);return(r=("000000"+r).slice(-s))+("000000"+i).slice(-s)}if("00"==r.substr(0,2)&&r.length%32==2&&(r=r.substr(2)),"00"==i.substr(0,2)&&i.length%32==2&&(i=i.substr(2)),r.length%32==30&&(r="00"+r),i.length%32==30&&(i="00"+i),r.length%32!=0)throw Error("unknown ECDSA sig r length error");if(i.length%32!=0)throw Error("unknown ECDSA sig s length error");return r+i},nt.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length%4!=0)throw Error("unknown ECDSA concatinated r-s sig length error");var e=t.substr(0,t.length/2),r=t.substr(t.length/2);return nt.crypto.ECDSA.hexRSSigToASN1Sig(e,r)},nt.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var r=new E(t,16),i=new E(e,16);return nt.crypto.ECDSA.biRSSigToASN1Sig(r,i)},nt.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var r=nt.asn1,i=new r.DERInteger({bigint:t}),s=new r.DERInteger({bigint:e});return new r.DERSequence({array:[i,s]}).tohex()},nt.crypto.ECDSA.getName=function(t){return"2b8104001f"===t?"secp192k1":"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040021"===t?"secp224r1":"2b81040022"===t?"secp384r1":"2b81040023"===t?"secp521r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp224r1|NIST P-224|P-224|".indexOf(t)?"secp224r1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":-1!=="|secp521r1|NIST P-521|P-521|".indexOf(t)?"secp521r1":null},void 0!==nt&&nt||(nt={}),void 0!==nt.crypto&&nt.crypto||(nt.crypto={}),nt.crypto.ECParameterDB=new function(){var t={},e={};function r(t){return new E(t,16)}this.getByName=function(r){var i=r;if(void 0!==e[i]&&(i=e[r]),void 0!==t[i])return t[i];throw"unregistered EC curve name: "+i},this.regist=function(i,s,n,a,o,h,u,c,l,g,p,d){t[i]={};var f=r(n),y=r(a),v=r(o),m=r(h),S=r(u),E=new it(f,y,v),x=E.decodePointHex("04"+c+l);t[i].name=i,t[i].keylen=s,t[i].keycharlen=2*Math.ceil(s/8),t[i].curve=E,t[i].G=x,t[i].n=m,t[i].h=S,t[i].oid=p,t[i].info=d;for(var A=0;A<g.length;A++)e[g[A]]=i}},nt.crypto.ECParameterDB.regist("secp128r1",128,"FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC","E87579C11079F43DD824993C2CEE5ED3","FFFFFFFE0000000075A30D1B9038A115","1","161FF7528B899B2D0C28607CA52C5B86","CF5AC8395BAFEB13C02DA292DDED7A83",[],"","secp128r1 : SECG curve over a 128 bit prime field"),nt.crypto.ECParameterDB.regist("secp160k1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73","0","7","0100000000000000000001B8FA16DFAB9ACA16B6B3","1","3B4C382CE37AA192A4019E763036F4F5DD4D7EBB","938CF935318FDCED6BC28286531733C3F03C4FEE",[],"","secp160k1 : SECG curve over a 160 bit prime field"),nt.crypto.ECParameterDB.regist("secp160r1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC","1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45","0100000000000000000001F4C8F927AED3CA752257","1","4A96B5688EF573284664698968C38BB913CBFC82","23A628553168947D59DCC912042351377AC5FB32",[],"","secp160r1 : SECG curve over a 160 bit prime field"),nt.crypto.ECParameterDB.regist("secp192k1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37","0","3","FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D","1","DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D","9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D",[]),nt.crypto.ECParameterDB.regist("secp192r1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC","64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1","FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831","1","188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012","07192B95FFC8DA78631011ED6B24CDD573F977A11E794811",[]),nt.crypto.ECParameterDB.regist("secp224r1",224,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE","B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4","FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D","1","B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21","BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34",[]),nt.crypto.ECParameterDB.regist("secp256k1",256,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F","0","7","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141","1","79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798","483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8",[]),nt.crypto.ECParameterDB.regist("secp256r1",256,"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC","5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B","FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551","1","6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296","4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5",["NIST P-256","P-256","prime256v1"]),nt.crypto.ECParameterDB.regist("secp384r1",384,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC","B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973","1","AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7","3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f",["NIST P-384","P-384"]),nt.crypto.ECParameterDB.regist("secp521r1",521,"1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC","051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409","1","00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66","011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650",["NIST P-521","P-521"]),void 0!==nt&&nt||(nt={}),void 0!==nt.crypto&&nt.crypto||(nt.crypto={}),nt.crypto.DSA=function(){var t=ht,e=(t.getVbyList,t.getVbyListEx),r=t.isASN1HEX,i=E;this.p=null,this.q=null,this.g=null,this.y=null,this.x=null,this.type="DSA",this.isPrivate=!1,this.isPublic=!1,this.setPrivate=function(t,e,r,i,s){this.isPrivate=!0,this.p=t,this.q=e,this.g=r,this.y=i,this.x=s},this.setPrivateHex=function(t,e,r,i,s){var n,a,o,h,u;n=new E(t,16),a=new E(e,16),o=new E(r,16),h="string"==typeof i&&i.length>1?new E(i,16):null,u=new E(s,16),this.setPrivate(n,a,o,h,u)},this.setPublic=function(t,e,r,i){this.isPublic=!0,this.p=t,this.q=e,this.g=r,this.y=i,this.x=null},this.setPublicHex=function(t,e,r,i){var s,n,a,o;s=new E(t,16),n=new E(e,16),a=new E(r,16),o=new E(i,16),this.setPublic(s,n,a,o)},this.signWithMessageHash=function(t){var e=this.p,r=this.q,i=this.g,s=(this.y,this.x),n=nt.crypto.Util.getRandomBigIntegerMinToMax(E.ONE.add(E.ONE),r.subtract(E.ONE)),a=new E(t.substr(0,r.bitLength()/4),16),o=i.modPow(n,e).mod(r),h=n.modInverse(r).multiply(a.add(s.multiply(o))).mod(r);return nt.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:o}},{int:{bigint:h}}]})},this.verifyWithMessageHash=function(t,e){var r=this.p,i=this.q,s=this.g,n=this.y,a=this.parseASN1Signature(e),o=a[0],h=a[1],u=new E(t.substr(0,i.bitLength()/4),16);if(E.ZERO.compareTo(o)>0||o.compareTo(i)>0)throw"invalid DSA signature";if(E.ZERO.compareTo(h)>=0||h.compareTo(i)>0)throw"invalid DSA signature";var c=h.modInverse(i),l=u.multiply(c).mod(i),g=o.multiply(c).mod(i);return 0==s.modPow(l,r).multiply(n.modPow(g,r)).mod(r).mod(i).compareTo(o)},this.parseASN1Signature=function(t){try{return[new i(e(t,0,[0],"02"),16),new i(e(t,0,[1],"02"),16)]}catch(t){throw new Error("malformed ASN.1 DSA signature")}},this.readPKCS5PrvKeyHex=function(t){var i,s,n,a,o;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[1],"02"),s=e(t,0,[2],"02"),n=e(t,0,[3],"02"),a=e(t,0,[4],"02"),o=e(t,0,[5],"02")}catch(t){throw new Error("malformed PKCS#1/5 plain DSA private key")}this.setPrivateHex(i,s,n,a,o)},this.readPKCS8PrvKeyHex=function(t){var i,s,n,a;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[1,1,0],"02"),s=e(t,0,[1,1,1],"02"),n=e(t,0,[1,1,2],"02"),a=e(t,0,[2,0],"02")}catch(t){throw new Error("malformed PKCS#8 plain DSA private key")}this.setPrivateHex(i,s,n,null,a)},this.readPKCS8PubKeyHex=function(t){var i,s,n,a;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[0,1,0],"02"),s=e(t,0,[0,1,1],"02"),n=e(t,0,[0,1,2],"02"),a=e(t,0,[1,0],"02")}catch(t){throw new Error("malformed PKCS#8 DSA public key")}this.setPublicHex(i,s,n,a)},this.readCertPubKeyHex=function(t,i){var s,n,a,o;if(!1===r(t))throw new Error("not ASN.1 hex string");try{s=e(t,0,[0,5,0,1,0],"02"),n=e(t,0,[0,5,0,1,1],"02"),a=e(t,0,[0,5,0,1,2],"02"),o=e(t,0,[0,5,1,0],"02")}catch(t){throw new Error("malformed X.509 certificate DSA public key")}this.setPublicHex(s,n,a,o)}};var Mt=function(){var t=function(t,r,i){return e(f.AES,t,r,i)},e=function(t,e,r,i){var s=f.enc.Hex.parse(e),n=f.enc.Hex.parse(r),a=f.enc.Hex.parse(i),o={};o.key=n,o.iv=a,o.ciphertext=s;var h=t.decrypt(o,n,{iv:a});return f.enc.Hex.stringify(h)},r=function(t,e,r){return i(f.AES,t,e,r)},i=function(t,e,r,i){var s=f.enc.Hex.parse(e),n=f.enc.Hex.parse(r),a=f.enc.Hex.parse(i),o=t.encrypt(s,n,{iv:a}),h=f.enc.Hex.parse(o.toString());return f.enc.Base64.stringify(h)},s={"AES-256-CBC":{proc:t,eproc:r,keylen:32,ivlen:16},"AES-192-CBC":{proc:t,eproc:r,keylen:24,ivlen:16},"AES-128-CBC":{proc:t,eproc:r,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,r,i){return e(f.TripleDES,t,r,i)},eproc:function(t,e,r){return i(f.TripleDES,t,e,r)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,r,i){return e(f.DES,t,r,i)},eproc:function(t,e,r){return i(f.DES,t,e,r)},keylen:8,ivlen:8}},n=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 i=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));i&&(e.type=i[1]);var s=-1,n=0;-1!=t.indexOf("\r\n\r\n")&&(s=t.indexOf("\r\n\r\n"),n=2),-1!=t.indexOf("\n\n")&&(s=t.indexOf("\n\n"),n=1);var a=t.indexOf("-----END");if(-1!=s&&-1!=a){var o=t.substring(s+2*n,a-n);o=o.replace(/\s+/g,""),e.data=o}return e},a=function(t,e,r){for(var i=r.substring(0,16),n=f.enc.Hex.parse(i),a=f.enc.Utf8.parse(e),o=s[t].keylen+s[t].ivlen,h="",u=null;;){var c=f.algo.MD5.create();if(null!=u&&c.update(u),c.update(a),c.update(n),u=c.finalize(),(h+=f.enc.Hex.stringify(u)).length>=2*o)break}var l={};return l.keyhex=h.substr(0,2*s[t].keylen),l.ivhex=h.substr(2*s[t].keylen,2*s[t].ivlen),l},o=function(t,e,r,i){var n=f.enc.Base64.parse(t),a=f.enc.Hex.stringify(n);return(0,s[e].proc)(a,r,i)};return{version:"1.0.0",parsePKCS5PEM:function(t){return n(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,r){return a(t,e,r)},decryptKeyB64:function(t,e,r,i){return o(t,e,r,i)},getDecryptedKeyHex:function(t,e){var r=n(t),i=(r.type,r.cipher),s=r.ivsalt,h=r.data,u=a(i,e,s).keyhex;return o(h,i,u,s)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,r,i,n){var o="";if(void 0!==i&&null!=i||(i="AES-256-CBC"),void 0===s[i])throw new Error("KEYUTIL unsupported algorithm: "+i);if(void 0===n||null==n){var h=function(t){var e=f.lib.WordArray.random(t);return f.enc.Hex.stringify(e)}(s[i].ivlen);n=h.toUpperCase()}var u=function(t,e,r,i){return(0,s[e].eproc)(t,r,i)}(e,i,a(i,r,n).keyhex,n);return o="-----BEGIN "+t+" PRIVATE KEY-----\r\n",o+="Proc-Type: 4,ENCRYPTED\r\n",o+="DEK-Info: "+i+","+n+"\r\n",o+="\r\n",(o+=u.replace(/(.{64})/g,"$1\r\n"))+"\r\n-----END "+t+" PRIVATE KEY-----\r\n"},getEncryptedPKCS8PEM:function(t,e,r){return Et(this.getEncryptedPKCS8Hex(t,e,r),"ENCRYPTED PRIVATE KEY")},getEncryptedPKCS8Hex:function(t,e,r){var i;(i=null==r||null==r?{}:JSON.parse(JSON.stringify(r))).plain=t,this.initPBES2Param(i),this.encryptPBES2Param(i,e);var s=this.generatePBES2ASN1Param(i);return nt.asn1.ASN1Util.newObject(s).tohex()},initPBES2Param:function(t){var e;null==Vt(t,"encalg")&&(t.encalg="aes256-CBC"),null==Vt(t,"iter")&&(t.iter=2048),null==Vt(t,"prf")&&(t.prf="hmacWithSHA256"),null==Vt(t,"salt")&&(t.salt=f.enc.Hex.stringify(f.lib.WordArray.random(8))),null==Vt(t,"enciv")&&("des-EDE3-CBC"==t.encalg&&(e=8),"aes128-CBC"==t.encalg&&(e=16),"aes256-CBC"==t.encalg&&(e=16),t.enciv=f.enc.Hex.stringify(f.lib.WordArray.random(e)))},encryptPBES2Param:function(t,e){var r=Mt.getDKFromPBES2Param(t,e);try{var i=nt.crypto.Cipher.encrypt(t.plain,r,t.encalg,{iv:t.enciv})}catch(e){throw new Error("encrypt error: "+t.plain+" "+r+" "+t.encalg+" "+t.enciv)}t.enc=i},generatePBES2ASN1Param:function(t){var e={seq:[{seq:[{oid:"pkcs5PBES2"},{seq:[{seq:[{oid:"pkcs5PBKDF2"},{seq:[{octstr:{hex:t.salt}},{int:{hex:Lt(t.iter)}}]}]},{seq:[{oid:t.encalg},{octstr:{hex:t.enciv}}]}]}]},{octstr:{hex:t.enc}}]};return"hmacWithSHA1"!=t.prf&&e.seq[0].seq[1].seq[0].seq[1].seq.push({seq:[{oid:t.prf},{null:""}]}),e},parseHexOfEncryptedPKCS8:function(t){var e=ht,r=e.getChildIdx,i=e.getV,s={},n=r(t,0);if(2!=n.length)throw new Error("malformed format: SEQUENCE(0).items != 2: "+n.length);s.ciphertext=i(t,n[1]);var a=r(t,n[0]);if(2!=a.length)throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+a.length);if("2a864886f70d01050d"!=i(t,a[0]))throw new Error("this only supports pkcs5PBES2");var o=r(t,a[1]);if(2!=a.length)throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+o.length);var h=r(t,o[1]);if(2!=h.length)throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+h.length);if("2a864886f70d0307"!=i(t,h[0]))throw"this only supports TripleDES";s.encryptionSchemeAlg="TripleDES",s.encryptionSchemeIV=i(t,h[1]);var u=r(t,o[0]);if(2!=u.length)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+u.length);if("2a864886f70d01050c"!=i(t,u[0]))throw new Error("this only supports pkcs5PBKDF2");var c=r(t,u[1]);if(c.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+c.length);s.pbkdf2Salt=i(t,c[0]);var l=i(t,c[1]);try{s.pbkdf2Iter=parseInt(l,16)}catch(t){throw new Error("malformed format pbkdf2Iter: "+l)}return s},getPBKDF2KeyHexFromParam:function(t,e){var r=f.enc.Hex.parse(t.pbkdf2Salt),i=t.pbkdf2Iter,s=f.PBKDF2(e,r,{keySize:6,iterations:i});return f.enc.Hex.stringify(s)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var r=xt(t,"ENCRYPTED PRIVATE KEY"),i=this.parseHexOfEncryptedPKCS8(r),s=Mt.getPBKDF2KeyHexFromParam(i,e),n={};n.ciphertext=f.enc.Hex.parse(i.ciphertext);var a=f.enc.Hex.parse(s),o=f.enc.Hex.parse(i.encryptionSchemeIV),h=f.TripleDES.decrypt(n,a,{iv:o});return f.enc.Hex.stringify(h)},parsePBES2:function(t){var e=ht.parse(t);if("pkcs5PBES2"!=Vt(e,"seq.0.seq.0.oid")||"pkcs5PBKDF2"!=Vt(e,"seq.0.seq.1.seq.0.seq.0.oid"))throw new Error("not pkcs5PBES2 and pkcs5PBKDF2 used");var r=Vt(e,"seq.0.seq.1.seq.0.seq.1.seq");if(null==r)throw new Error("PBKDF2 parameter not found");var i=Vt(r,"0.octstr.hex"),s=Vt(r,"1.int.hex"),n=Vt(r,"2.seq.0.oid","hmacWithSHA1"),a=-1;try{a=parseInt(s,16)}catch(t){throw new Error("iter not proper value")}var o=Vt(e,"seq.0.seq.1.seq.1.seq.0.oid"),h=Vt(e,"seq.0.seq.1.seq.1.seq.1.octstr.hex"),u=Vt(e,"seq.1.octstr.hex");if(null==o||null==h||null==u)throw new Error("encalg, enciv or enc is undefined");return{salt:i,iter:a,prf:n,encalg:o,enciv:h,enc:u}},getDKFromPBES2Param:function(t,e){var r={hmacWithSHA1:f.algo.SHA1,hmacWithSHA224:f.algo.SHA224,hmacWithSHA256:f.algo.SHA256,hmacWithSHA384:f.algo.SHA384,hmacWithSHA512:f.algo.SHA512}[t.prf];if(null==r)throw new Error("unsupported prf");var i={"des-EDE3-CBC":6,"aes128-CBC":4,"aes256-CBC":8}[t.encalg];if(null==i)throw new Error("unsupported encalg");var s=f.enc.Hex.parse(t.salt),n=t.iter;try{var a=f.PBKDF2(e,s,{keySize:i,iterations:n,hasher:r});return f.enc.Hex.stringify(a)}catch(r){throw new Error("PBKDF2 error: "+r+" "+JSON.stringify(t)+" "+e)}},getPlainHexFromEncryptedPKCS8PEM:function(t,e){if(-1==t.indexOf("BEGIN ENCRYPTED PRIVATE KEY"))throw new Error("not Encrypted PKCS#8 PEM string");var r,i=xt(t);try{r=Mt.parsePBES2(i)}catch(t){throw new Error("malformed PBES2 format: "+t.message)}var s=Mt.getDKFromPBES2Param(r,e);return nt.crypto.Cipher.decrypt(r.enc,s,r.encalg,{iv:r.enciv})},getKeyFromEncryptedPKCS8PEM:function(t,e){var r=this.getPlainHexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(r)},parsePlainPrivatePKCS8Hex:function(t){var e=ht,r=e.getChildIdx,i=e.getV,s={algparam:null};if("30"!=t.substr(0,2))throw new Error("malformed plain PKCS8 private key(code:001)");var n=r(t,0);if(n.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if("30"!=t.substr(n[1],2))throw new Error("malformed PKCS8 private key(code:003)");var a=r(t,n[1]);if(2!=a.length)throw new Error("malformed PKCS8 private key(code:004)");if("06"!=t.substr(a[0],2))throw new Error("malformed PKCS8 private key(code:005)");if(s.algoid=i(t,a[0]),"06"==t.substr(a[1],2)&&(s.algparam=i(t,a[1])),"04"!=t.substr(n[2],2))throw new Error("malformed PKCS8 private key(code:006)");return s.keyidx=e.getVidx(t,n[2]),s},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=xt(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 nt.crypto.DSA;else{if("2a8648ce3d0201"!=r.algoid)throw new Error("unsupported private key algorithm");e=new nt.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,r=ht.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===r)e=new tt;else if("2a8648ce380401"===r)e=new nt.crypto.DSA;else{if("2a8648ce3d0201"!==r)throw new Error("unsupported PKCS#8 public key hex");e=new nt.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=ht,r=e.getChildIdx,i=e.getV,s={};if("30"!=t.substr(0,2))throw new Error("malformed RSA key(code:001)");var n=r(t,0);if(2!=n.length)throw new Error("malformed RSA key(code:002)");if("02"!=t.substr(n[0],2))throw new Error("malformed RSA key(code:003)");if(s.n=i(t,n[0]),"02"!=t.substr(n[1],2))throw new Error("malformed RSA key(code:004)");return s.e=i(t,n[1]),s},parsePublicPKCS8Hex:function(t){var e=ht,r=e.getChildIdx,i=e.getV,s={algparam:null},n=r(t,0);if(2!=n.length)throw new Error("outer DERSequence shall have 2 elements: "+n.length);var a=n[0];if("30"!=t.substr(a,2))throw new Error("malformed PKCS8 public key(code:001)");var o=r(t,a);if(2!=o.length)throw new Error("malformed PKCS8 public key(code:002)");if("06"!=t.substr(o[0],2))throw new Error("malformed PKCS8 public key(code:003)");if(s.algoid=i(t,o[0]),"06"==t.substr(o[1],2)?s.algparam=i(t,o[1]):"30"==t.substr(o[1],2)&&(s.algparam={},s.algparam.p=e.getVbyList(t,o[1],[0],"02"),s.algparam.q=e.getVbyList(t,o[1],[1],"02"),s.algparam.g=e.getVbyList(t,o[1],[2],"02")),"03"!=t.substr(n[1],2))throw new Error("malformed PKCS8 public key(code:004)");return s.key=i(t,n[1]).substr(2),s}}}();function Kt(t,e){for(var r="",i=e/4-t.length,s=0;s<i;s++)r+="0";return r+t}function qt(t,e,r){for(var i="",s=0;i.length<e;)i+=mt(r(St(t+String.fromCharCode.apply(String,[(4278190080&s)>>24,(16711680&s)>>16,(65280&s)>>8,255&s])))),s+=1;return i}function Gt(t){for(var e in nt.crypto.Util.DIGESTINFOHEAD){var r=nt.crypto.Util.DIGESTINFOHEAD[e],i=r.length;if(t.substring(0,i)==r)return[e,t.substring(i)]}return[]}function Wt(t){var e,r=ht,i=r.getChildIdx,s=r.getV,n=(r.dump,r.parse),a=r.getTLV,o=r.getVbyList,h=r.getVbyListEx,u=r.getTLVbyList,c=r.getTLVbyListEx,l=r.getIdxbyList,g=r.getIdxbyListEx,p=r.getVidx,d=r.getInt,f=r.oidname,y=r.hextooidstr,v=xt,m=Error;try{e=nt.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=d(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 h(this.hex,0,[0,0],"02")},this.getSignatureAlgorithmField=function(){var t=c(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 f(h(t,0,[0],"06"))},this.getIssuer=function(t,e){return this.getX500Name(this.getIssuerHex(),t,e)},this.getIssuerHex=function(){return u(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return this.getIssuer().str},this.getSubject=function(t,e){return this.getX500Name(this.getSubjectHex(),t,e)},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"),decodeURIComponent(t)},this.getNotAfter=function(){var t=o(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),decodeURIComponent(t)},this.getPublicKeyHex=function(){return this.getSPKI()},this.getSPKI=function(){return u(this.hex,0,[0,6+this.foffset],"30")},this.getSPKIValue=function(){var t=this.getSPKI();return null==t?null:o(t,0,[1],"03",!0)},this.getPublicKeyIdx=function(){return l(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return l(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return Mt.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(),i=u(this.hex,0,[0],"30"),s=new nt.crypto.Signature({alg:e});return s.init(t),s.updateHex(i),s.verify(r)},this.parseExt=function(t){var e,n,a;if(void 0===t){if(a=this.hex,3!==this.version)return-1;e=l(a,0,[0,7,0],"30"),n=i(a,e)}else{a=xt(t);var h=l(a,0,[0,3,0,0],"06");if("2a864886f70d01090e"!=s(a,h))return void(this.aExtInfo=new Array);e=l(a,0,[0,3,0,1,0],"30"),n=i(a,e),this.hex=a}this.aExtInfo=new Array;for(var u=0;u<n.length;u++){var c={critical:!1},g=0;3===i(a,n[u]).length&&(c.critical=!0,g=1),c.oid=r.hextooidstr(o(a,n[u],[0],"06"));var d=l(a,n[u],[1+g]);c.vidx=p(a,d),this.aExtInfo.push(c)}},this.getExtInfo=function(t){var e=this.aExtInfo,r=t;if(t.match(/^[0-9.]+$/)||(r=nt.asn1.x509.OID.name2oid(t)),""!==r)for(var i=0;i<e.length;i++)if(e[i].oid===r)return e[i]},this.getCriticalExtV=function(t,e,r){if(null!=e)return[e,r];var i=this.getExtInfo(t);return null==i?[null,null]:[a(this.hex,i.vidx),i.critical]},this.getExtBasicConstraints=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("basicConstraints");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var i={extname:"basicConstraints"};if(e&&(i.critical=!0),"3000"===t)return i;if("30030101ff"===t)return i.cA=!0,i;if("30060101ff02"===t.substr(0,12)){var n=s(t,10),o=parseInt(n,16);return i.cA=!0,i.pathLen=o,i}throw new Error("hExtV parse error: "+t)},this.getExtNameConstraints=function(t,e){var r=this.getCriticalExtV("nameConstraints",t,e);if(t=r[0],e=r[1],null!=t){var s={extname:"nameConstraints"};e&&(s.critical=!0);for(var n=i(t,0),o=0;o<n.length;o++){for(var h=[],u=i(t,n[o]),c=0;c<u.length;c++){var l=a(t,u[c]),g=this.getGeneralSubtree(l);h.push(g)}var p=t.substr(n[o],2);"a0"==p?s.permit=h:"a1"==p&&(s.exclude=h)}return s}},this.getGeneralSubtree=function(t){var e=i(t,0),r=e.length;if(r<1||2<r)throw new Error("wrong num elements");for(var n=this.getGeneralName(a(t,e[0])),o=1;o<r;o++){var h=t.substr(e[o],2),u=s(t,e[o]),c=parseInt(u,16);"80"==h&&(n.min=c),"81"==h&&(n.max=c)}return n},this.getExtKeyUsage=function(t,e){var r=this.getCriticalExtV("keyUsage",t,e);if(t=r[0],e=r[1],null!=t){var i={extname:"keyUsage"};return e&&(i.critical=!0),i.names=this.getExtKeyUsageString(t).split(","),i}},this.getExtKeyUsageBin=function(t){if(void 0===t){var e=this.getExtInfo("keyUsage");if(void 0===e)return"";t=a(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,i=0;i<e.length;i++)"1"==e.substr(i,1)&&r.push(Wt.KEYUSAGE_NAME[i]);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=a(this.hex,r.vidx),e=r.critical}var i={extname:"subjectKeyIdentifier"};e&&(i.critical=!0);var n=s(t,0);return i.kid={hex:n},i},this.getExtAuthorityKeyIdentifier=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("authorityKeyIdentifier");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var n={extname:"authorityKeyIdentifier"};e&&(n.critical=!0);for(var o=i(t,0),h=0;h<o.length;h++){var u=t.substr(o[h],2);if("80"===u&&(n.kid={hex:s(t,o[h])}),"a1"===u){var c=a(t,o[h]),l=this.getGeneralNames(c);n.issuer=l[0].dn}"82"===u&&(n.sn={hex:s(t,o[h])})}return n},this.getExtExtKeyUsage=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("extKeyUsage");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var n={extname:"extKeyUsage",array:[]};e&&(n.critical=!0);for(var o=i(t,0),h=0;h<o.length;h++)n.array.push(f(s(t,o[h])));return n},this.getExtExtKeyUsageName=function(){var t=this.getExtInfo("extKeyUsage");if(void 0===t)return t;var e=new Array,r=a(this.hex,t.vidx);if(""===r)return e;for(var n=i(r,0),o=0;o<n.length;o++)e.push(f(s(r,n[o])));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=a(this.hex,r.vidx),e=r.critical}var i={extname:"subjectAltName",array:[]};return e&&(i.critical=!0),i.array=this.getGeneralNames(t),i},this.getExtIssuerAltName=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("issuerAltName");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var i={extname:"issuerAltName",array:[]};return e&&(i.critical=!0),i.array=this.getGeneralNames(t),i},this.getGeneralNames=function(t){for(var e=i(t,0),r=[],s=0;s<e.length;s++){var n=this.getGeneralName(a(t,e[s]));void 0!==n&&r.push(n)}return r},this.getGeneralName=function(t){var e=t.substr(0,2),r=s(t,0),i=mt(r);return"81"==e?{rfc822:i}:"82"==e?{dns:i}:"86"==e?{uri:i}:"87"==e?{ip:It(r)}:"a4"==e?{dn:this.getX500Name(r)}:"a0"==e?{other:this.getOtherName(t)}:void 0},this.getExtSubjectAltName2=function(){var t,e,r,n=this.getExtInfo("subjectAltName");if(void 0===n)return n;for(var o=new Array,h=a(this.hex,n.vidx),u=i(h,0),c=0;c<u.length;c++)r=h.substr(u[c],2),t=s(h,u[c]),"81"===r&&(e=yt(t),o.push(["MAIL",e])),"82"===r&&(e=yt(t),o.push(["DNS",e])),"84"===r&&(e=Wt.hex2dn(t,0),o.push(["DN",e])),"86"===r&&(e=yt(t),o.push(["URI",e])),"87"===r&&(e=It(t),o.push(["IP",e]));return o},this.getExtCRLDistributionPoints=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("cRLDistributionPoints");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var s={extname:"cRLDistributionPoints",array:[]};e&&(s.critical=!0);for(var n=i(t,0),o=0;o<n.length;o++){var h=a(t,n[o]);s.array.push(this.getDistributionPoint(h))}return s},this.getDistributionPoint=function(t){for(var e={},r=i(t,0),s=0;s<r.length;s++){var n=t.substr(r[s],2),o=a(t,r[s]);"a0"==n&&(e.dpname=this.getDistributionPointName(o))}return e},this.getDistributionPointName=function(t){for(var e={},r=i(t,0),s=0;s<r.length;s++){var n=t.substr(r[s],2),o=a(t,r[s]);"a0"==n&&(e.full=this.getGeneralNames(o))}return e},this.getExtCRLDistributionPointsURI=function(){var t=this.getExtCRLDistributionPoints();if(null==t)return t;for(var e=t.array,r=[],i=0;i<e.length;i++)try{null!=e[i].dpname.full[0].uri&&r.push(e[i].dpname.full[0].uri)}catch(t){}return r},this.getExtAIAInfo=function(){var t=this.getExtInfo("authorityInfoAccess");if(void 0===t)return t;for(var e={ocsp:[],caissuer:[]},r=i(this.hex,t.vidx),s=0;s<r.length;s++){var n=o(this.hex,r[s],[0],"06"),a=o(this.hex,r[s],[1],"86");"2b06010505073001"===n&&e.ocsp.push(yt(a)),"2b06010505073002"===n&&e.caissuer.push(yt(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=a(this.hex,r.vidx),e=r.critical}var s={extname:"authorityInfoAccess",array:[]};e&&(s.critical=!0);for(var n=i(t,0),u=0;u<n.length;u++){var c=h(t,n[u],[0],"06"),l=yt(o(t,n[u],[1],"86"));if("2b06010505073001"==c)s.array.push({ocsp:l});else{if("2b06010505073002"!=c)throw new Error("unknown method: "+c);s.array.push({caissuer:l})}}return s},this.getExtCertificatePolicies=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("certificatePolicies");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var s={extname:"certificatePolicies",array:[]};e&&(s.critical=!0);for(var n=i(t,0),o=0;o<n.length;o++){var h=a(t,n[o]),u=this.getPolicyInformation(h);s.array.push(u)}return s},this.getPolicyInformation=function(t){var e={},r=o(t,0,[0],"06");e.policyoid=f(r);var s=g(t,0,[1],"30");if(-1!=s){e.array=[];for(var n=i(t,s),h=0;h<n.length;h++){var u=a(t,n[h]),c=this.getPolicyQualifierInfo(u);e.array.push(c)}}return e},this.getOtherName=function(t){var e={},r=i(t,0),s=o(t,r[0],[],"06"),a=o(t,r[1],[]);return e.oid=f(s),e.value=n(a),e},this.getPolicyQualifierInfo=function(t){var e={},r=o(t,0,[0],"06");if("2b06010505070201"===r){var i=h(t,0,[1],"16");e.cps=mt(i)}else if("2b06010505070202"===r){var s=u(t,0,[1],"30");e.unotice=this.getUserNotice(s)}return e},this.getUserNotice=function(t){var e=null;try{return e=r.parse(t),this._asn1ToUnotice(e)}catch(t){return}},this._asn1ToUnotice=function(t){try{for(var e={},r=Vt(t,"seq"),i=0;i<r.length;i++){var s=this._asn1ToNoticeRef(r[i]);null!=s&&(e.noticeref=s);var n=this.asn1ToDisplayText(r[i]);null!=n&&(e.exptext=n)}return Object.keys(e).length>0?e:void 0}catch(t){return}},this._asn1ToNoticeRef=function(t){try{for(var e={},r=Vt(t,"seq"),i=0;i<r.length;i++){var s=this._asn1ToNoticeNum(r[i]);null!=s&&(e.noticenum=s);var n=this.asn1ToDisplayText(r[i]);null!=n&&(e.org=n)}return Object.keys(e).length>0?e:void 0}catch(t){return}},this._asn1ToNoticeNum=function(t){try{for(var e=Vt(t,"seq"),r=[],i=0;i<e.length;i++){var s=e[i];r.push(parseInt(Vt(s,"int.hex"),16))}return r}catch(t){return}},this.getDisplayText=function(t){var e={};return e.type={"0c":"utf8",16:"ia5","1a":"vis","1e":"bmp"}[t.substr(0,2)],e.str=mt(s(t,0)),e},this.asn1ToDisplayText=function(t){return null!=t.utf8str?{type:"utf8",str:t.utf8str.str}:null!=t.ia5str?{type:"ia5",str:t.ia5str.str}:null!=t.visstr?{type:"vis",str:t.visstr.str}:null!=t.bmpstr?{type:"bmp",str:t.bmpstr.str}:null!=t.prnstr?{type:"prn",str:t.prnstr.str}:void 0},this.getExtPolicyMappings=function(t,e){var r=this.getCriticalExtV("policyMappings",t,e);if(t=r[0],e=r[1],null!=t){var i={extname:"policyMappings"};e&&(i.critical=!0);try{for(var s=n(t).seq,a=[],o=0;o<s.length;o++){var h=s[o].seq;a.push([h[0].oid,h[1].oid])}i.array=a}catch(t){throw new m("malformed policyMappings")}return i}},this.getExtPolicyConstraints=function(t,e){var r=this.getCriticalExtV("policyConstraints",t,e);if(t=r[0],e=r[1],null!=t){var i={extname:"policyConstraints"};e&&(i.critical=!0);var s=n(t);try{for(var a=s.seq,o=0;o<a.length;o++){var h=a[o].tag;0==h.explicit&&("80"==h.tag&&(i.reqexp=parseInt(h.hex,16)),"81"==h.tag&&(i.inhibit=parseInt(h.hex,16)))}}catch(t){return new m("malformed policyConstraints value")}return i}},this.getExtInhibitAnyPolicy=function(t,e){var r=this.getCriticalExtV("inhibitAnyPolicy",t,e);if(t=r[0],e=r[1],null!=t){var i={extname:"inhibitAnyPolicy"};e&&(i.critical=!0);var s=d(t,0);return-1==s?new m("wrong value"):(i.skip=s,i)}},this.getExtCRLNumber=function(t,e){var r={extname:"cRLNumber"};if(e&&(r.critical=!0),"02"==t.substr(0,2))return r.num={hex:s(t,0)},r;throw new m("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(s(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 i=s(t,0);return r.hex=i,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=a(this.hex,r.vidx),e=r.critical}var s={extname:"adobeTimeStamp"};e&&(s.critical=!0);var n=i(t,0);if(n.length>1){var o=a(t,n[1]),h=this.getGeneralName(o);null!=h.uri&&(s.uri=h.uri)}if(n.length>2){var u=a(t,n[2]);"0101ff"==u&&(s.reqauth=!0),"010100"==u&&(s.reqauth=!1)}return s},this.getExtSubjectDirectoryAttributes=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectDirectoryAttributes");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var i={extname:"subjectDirectoryAttributes"};e&&(i.critical=!0);try{for(var s=n(t),o=[],h=0;h<s.seq.length;h++){var u=s.seq[h],c=Vt(u,"seq.0.oid"),l=Vt(u,"seq.1.set");if(null==c||null==l)throw"error";o.push({attr:c,array:l})}return i.array=o,i}catch(t){throw new Error("malformed subjectDirectoryAttributes extension value")}};var S=function(t){var e={};try{var r=t.seq[0].oid,i=nt.asn1.x509.OID.name2oid(r);e.type=nt.asn1.x509.OID.oid2atype(i);var s=t.seq[1];if(null!=s.utf8str)e.ds="utf8",e.value=s.utf8str.str;else if(null!=s.numstr)e.ds="num",e.value=s.numstr.str;else if(null!=s.telstr)e.ds="tel",e.value=s.telstr.str;else if(null!=s.prnstr)e.ds="prn",e.value=s.prnstr.str;else if(null!=s.ia5str)e.ds="ia5",e.value=s.ia5str.str;else if(null!=s.visstr)e.ds="vis",e.value=s.visstr.str;else{if(null==s.bmpstr)throw"error";e.ds="bmp",e.value=s.bmpstr.str}return e}catch(t){throw new Erorr("improper ASN.1 parsed AttrTypeAndValue")}},E=function(t){try{return t.set.map(function(t){return S(t)})}catch(t){throw new Error("improper ASN.1 parsed RDN: "+t)}};this.getX500NameRule=function(t){for(var e=null,r=[],i=0;i<t.length;i++)for(var s=t[i],n=0;n<s.length;n++)r.push(s[n]);for(i=0;i<r.length;i++){var a=r[i],o=a.ds,h=a.value,u=a.type;if("prn"!=o&&"utf8"!=o&&"ia5"!=o)return"mixed";if("ia5"==o){if("CN"!=u)return"mixed";if(nt.lang.String.isMail(h))continue;return"mixed"}if("C"==u){if("prn"==o)continue;return"mixed"}if(null==e)e=o;else if(e!==o)return"mixed"}return null==e?"prn":e},this.getAttrTypeAndValue=function(t){var e=n(t);return S(e)},this.getRDN=function(t){var e=n(t);return E(e)},this.getX500NameArray=function(t){return function(t){try{return t.seq.map(function(t){return E(t)})}catch(t){throw new Error("improper ASN.1 parsed X500Name: "+t)}}(n(t))},this.getX500Name=function(t,e,r){var i=this.getX500NameArray(t),s={str:this.dnarraytostr(i)};return s.array=i,1==r&&(s.hex=t),1==e&&(s.canon=this.c14nRDNArray(i)),s},this.readCertPEM=function(t){this.readCertHex(v(t))},this.readCertHex=function(t){this.hex=t,this.getVersion();try{l(this.hex,0,[0,7],"a3"),this.parseExt()}catch(t){}},this.getParam=function(t){var e={};return null==t&&(t={}),e.version=this.getVersion(),e.serial={hex:this.getSerialNumberHex()},e.sigalg=this.getSignatureAlgorithmField(),e.issuer=this.getIssuer(t.dncanon,t.dnhex),e.notbefore=this.getNotBefore(),e.notafter=this.getNotAfter(),e.subject=this.getSubject(t.dncanon,t.dnhex),e.sbjpubkey=Et(this.getPublicKeyHex(),"PUBLIC KEY"),null!=this.aExtInfo&&this.aExtInfo.length>0&&(e.ext=this.getExtParamArray()),e.sighex=this.getSignatureValueHex(),1==t.tbshex&&(e.tbshex=u(this.hex,0,[0])),1==t.nodnarray&&(delete e.issuer.array,delete e.subject.array),e},this.getExtParamArray=function(t){null==t&&-1!=g(this.hex,0,[0,"[3]"])&&(t=c(this.hex,0,[0,"[3]",0],"30"));for(var e=[],r=i(t,0),s=0;s<r.length;s++){var n=a(t,r[s]),o=this.getExtParam(n);null!=o&&e.push(o)}return e},this.getExtParam=function(t){var e=i(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")),s=!1;3==e&&"0101ff"==u(t,0,[1])&&(s=!0);var a=u(t,0,[e-1,0]),h=void 0;if("2.5.29.14"==r?h=this.getExtSubjectKeyIdentifier(a,s):"2.5.29.15"==r?h=this.getExtKeyUsage(a,s):"2.5.29.17"==r?h=this.getExtSubjectAltName(a,s):"2.5.29.18"==r?h=this.getExtIssuerAltName(a,s):"2.5.29.19"==r?h=this.getExtBasicConstraints(a,s):"2.5.29.30"==r?h=this.getExtNameConstraints(a,s):"2.5.29.31"==r?h=this.getExtCRLDistributionPoints(a,s):"2.5.29.32"==r?h=this.getExtCertificatePolicies(a,s):"2.5.29.33"==r?h=this.getExtPolicyMappings(a,s):"2.5.29.35"==r?h=this.getExtAuthorityKeyIdentifier(a,s):"2.5.29.36"==r?h=this.getExtPolicyConstraints(a,s):"2.5.29.37"==r?h=this.getExtExtKeyUsage(a,s):"2.5.29.54"==r?h=this.getExtInhibitAnyPolicy(a,s):"1.3.6.1.5.5.7.1.1"==r?h=this.getExtAuthorityInfoAccess(a,s):"2.5.29.20"==r?h=this.getExtCRLNumber(a,s):"2.5.29.21"==r?h=this.getExtCRLReason(a,s):"2.5.29.9"==r?h=this.getExtSubjectDirectoryAttributes(a,s):"1.3.6.1.5.5.7.48.1.2"==r?h=this.getExtOcspNonce(a,s):"1.3.6.1.5.5.7.48.1.5"==r?h=this.getExtOcspNoCheck(a,s):"1.2.840.113583.1.1.9.1"==r?h=this.getExtAdobeTimeStamp(a,s):null!=Wt.EXT_PARSER[r]&&(h=Wt.EXT_PARSER[r](r,s,a)),null!=h)return h;var c={extname:r,extn:a};try{c.extn=n(a)}catch(t){}return s&&(c.critical=!0),c},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 i=r.array,s=0;s<i.length;s++)if(null!=i[s].dpname&&null!=i[s].dpname.full)for(var n=i[s].dpname.full,a=0;a<n.length;a++){var o=n[s];null!=o.uri&&(o.uri=e)}},this.updateExtAIAOCSP=function(t,e){var r=this.findExt(t,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var i=r.array,s=0;s<i.length;s++)null!=i[s].ocsp&&(i[s].ocsp=e)},this.updateExtAIACAIssuer=function(t,e){var r=this.findExt(t,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var i=r.array,s=0;s<i.length;s++)null!=i[s].caissuer&&(i[s].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.setCanonicalizedDN=function(t){var e;if(null!=t.str&&null==t.array){var r=new nt.asn1.x509.X500Name({str:t.str}).tohex();e=this.getX500NameArray(r)}else e=t.array;null==t.canon&&(t.canon=this.c14nRDNArray(e))},this.c14nRDNArray=function(t){for(var e=[],r=0;r<t.length;r++){for(var i=t[r],s=[],n=0;n<i.length;n++){var a=i[n],o=a.value;o=(o=(o=(o=o.replace(/^\s*/,"")).replace(/\s*$/,"")).replace(/\s+/g," ")).toLowerCase(),s.push(a.type.toLowerCase()+"="+o)}e.push(s.join("+"))}return"/"+e.join("/")},this.getInfo=function(){var t,e,r,i=function(t){for(var e="",r=" ",i="\n",s=t.array,n=0;n<s.length;n++){var a=s[n];null!=a.dn&&(e+=r+"dn: "+a.dn.str+i),null!=a.ip&&(e+=r+"ip: "+a.ip+i),null!=a.rfc822&&(e+=r+"rfc822: "+a.rfc822+i),null!=a.dns&&(e+=r+"dns: "+a.dns+i),null!=a.uri&&(e+=r+"uri: "+a.uri+i),null!=a.other&&(e+=r+"other: "+a.other.oid+"="+JSON.stringify(a.other.value).replace(/\"/g,"")+i)}return e.replace(/\n$/,"")},s=function(t){for(var e="",r=t.array,i=0;i<r.length;i++){var s=r[i];if(e+=" policy oid: "+s.policyoid+"\n",void 0!==s.array)for(var n=0;n<s.array.length;n++){var a=s.array[n];void 0!==a.cps&&(e+=" cps: "+a.cps+"\n")}}return e},n=function(t){for(var e="",r=t.array,i=0;i<r.length;i++){var s=r[i];try{void 0!==s.dpname.full[0].uri&&(e+=" "+s.dpname.full[0].uri+"\n")}catch(t){}try{void 0!==s.dname.full[0].dn.hex&&(e+=" "+Wt.hex2dn(s.dpname.full[0].dn.hex)+"\n")}catch(t){}}return e},a=function(t){for(var e="",r=t.array,i=0;i<r.length;i++){var s=r[i];void 0!==s.caissuer&&(e+=" caissuer: "+s.caissuer+"\n"),void 0!==s.ocsp&&(e+=" ocsp: "+s.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="+_t(e.n.toString(16)).substr(0,16)+"...\n",t+=" e="+_t(e.e.toString(16))+"\n"),null!=(r=this.aExtInfo)){t+="X509v3 Extensions:\n";for(var o=0;o<r.length;o++){var h=r[o],u=nt.asn1.x509.OID.oid2name(h.oid);""===u&&(u=h.oid);var c="";if(!0===h.critical&&(c="CRITICAL"),t+=" "+u+" "+c+":\n","basicConstraints"===u){var l=this.getExtBasicConstraints();void 0===l.cA?t+=" {}\n":(t+=" cA=true",void 0!==l.pathLen&&(t+=", pathLen="+l.pathLen),t+="\n")}else{var g;if("policyMappings"==u)t+=" "+this.getExtPolicyMappings().array.map(function(t){var e=t;return e[0]+":"+e[1]}).join(", ")+"\n";else if("policyConstraints"==u)t+=" ",null!=(g=this.getExtPolicyConstraints()).reqexp&&(t+=" reqexp="+g.reqexp),null!=g.inhibit&&(t+=" inhibit="+g.inhibit),t+="\n";else if("inhibitAnyPolicy"==u)t+=" skip="+(g=this.getExtInhibitAnyPolicy()).skip+"\n";else if("keyUsage"==u)t+=" "+this.getExtKeyUsageString()+"\n";else if("subjectKeyIdentifier"==u)t+=" "+this.getExtSubjectKeyIdentifier().kid.hex+"\n";else if("authorityKeyIdentifier"==u){var p=this.getExtAuthorityKeyIdentifier();void 0!==p.kid&&(t+=" kid="+p.kid.hex+"\n")}else"extKeyUsage"==u?t+=" "+this.getExtExtKeyUsage().array.join(", ")+"\n":"subjectAltName"==u?t+=i(this.getExtSubjectAltName())+"\n":"cRLDistributionPoints"==u?t+=n(this.getExtCRLDistributionPoints()):"authorityInfoAccess"==u?t+=a(this.getExtAuthorityInfoAccess()):"certificatePolicies"==u&&(t+=s(this.getExtCertificatePolicies()))}}}return(t+="signature algorithm: "+this.getSignatureAlgorithmName()+"\n")+"signature: "+this.getSignatureValueHex().substr(0,16)+"...\n"},"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?this.readCertPEM(t):nt.lang.String.isHex(t)&&this.readCertHex(t))}Mt.getKey=function(t,e,r){var i,s=(v=ht).getChildIdx,n=(v.getV,v.getVbyList),a=nt.crypto,o=a.ECDSA,h=a.DSA,u=tt,c=xt,l=Mt;if(void 0!==u&&t instanceof u)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==h&&t instanceof h)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 h).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 h).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(dt(t.n),dt(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(dt(t.n),dt(t.e),dt(t.d),dt(t.p),dt(t.q),dt(t.dp),dt(t.dq),dt(t.qi)),T;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(T=new u).setPrivate(dt(t.n),dt(t.e),dt(t.d)),T;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var g=(R=new o({curve:t.crv})).ecparams.keycharlen,p="04"+("0000000000"+dt(t.x)).slice(-g)+("0000000000"+dt(t.y)).slice(-g);return R.setPublicKeyHex(p),R}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){g=(R=new o({curve:t.crv})).ecparams.keycharlen,p="04"+("0000000000"+dt(t.x)).slice(-g)+("0000000000"+dt(t.y)).slice(-g);var d=("0000000000"+dt(t.d)).slice(-g);return R.setPublicKeyHex(p),R.setPrivateKeyHex(d),R}if("pkcs5prv"===r){var f,y=t,v=ht;if(9===(f=s(y,0)).length)(T=new u).readPKCS5PrvKeyHex(y);else if(6===f.length)(T=new h).readPKCS5PrvKeyHex(y);else{if(!(f.length>2&&"04"===y.substr(f[1],2)))throw new Error("unsupported PKCS#1/5 hexadecimal key");(T=new o).readPKCS5PrvKeyHex(y)}return T}if("pkcs8prv"===r)return l.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===r)return l._getKeyFromPublicPKCS8Hex(t);if("x509pub"===r)return Wt.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return Wt.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var m=xt(t,"PUBLIC KEY");return l._getKeyFromPublicPKCS8Hex(m)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var S=c(t,"RSA PRIVATE KEY");return l.getKey(S,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var x=n(i=c(t,"DSA PRIVATE KEY"),0,[1],"02"),A=n(i,0,[2],"02"),w=n(i,0,[3],"02"),b=n(i,0,[4],"02"),F=n(i,0,[5],"02");return(T=new h).setPrivate(new E(x,16),new E(A,16),new E(w,16),new E(b,16),new E(F,16)),T}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED"))return S=c(t,"EC PRIVATE KEY"),l.getKey(S,null,"pkcs5prv");if(-1!=t.indexOf("-END PRIVATE KEY-"))return l.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var I=l.getDecryptedKeyHex(t,e),C=new tt;return C.readPKCS5PrvKeyHex(I),C}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var R,T=n(i=l.getDecryptedKeyHex(t,e),0,[1],"04"),P=n(i,0,[2,0],"06"),D=n(i,0,[3,0],"03").substr(2);if(void 0===nt.crypto.OID.oidhex2name[P])throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+P);return(R=new o({curve:nt.crypto.OID.oidhex2name[P]})).setPublicKeyHex(D),R.setPrivateKeyHex(T),R.isPublic=!1,R}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED"))return x=n(i=l.getDecryptedKeyHex(t,e),0,[1],"02"),A=n(i,0,[2],"02"),w=n(i,0,[3],"02"),b=n(i,0,[4],"02"),F=n(i,0,[5],"02"),(T=new h).setPrivate(new E(x,16),new E(A,16),new E(w,16),new E(b,16),new E(F,16)),T;if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return l.getKeyFromEncryptedPKCS8PEM(t,e);throw new Error("not supported argument")},Mt.generateKeypair=function(t,e){if("RSA"==t){var r=e;(a=new tt).generate(r,"10001"),a.isPrivate=!0,a.isPublic=!0;var i=new tt,s=a.n.toString(16),n=a.e.toString(16);return i.setPublic(s,n),i.isPrivate=!1,i.isPublic=!0,(o={}).prvKeyObj=a,o.pubKeyObj=i,o}if("EC"==t){var a,o,h=e,u=new nt.crypto.ECDSA({curve:h}).generateKeyPairHex();return(a=new nt.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),a.setPrivateKeyHex(u.ecprvhex),a.isPrivate=!0,a.isPublic=!1,(i=new nt.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),i.isPrivate=!1,i.isPublic=!0,(o={}).prvKeyObj=a,o.pubKeyObj=i,o}throw new Error("unknown algorithm: "+t)},Mt.getPEM=function(t,e,r,i,s,n){var a=nt,o=a.asn1,h=o.DERObjectIdentifier,u=o.DERInteger,c=o.ASN1Util.newObject,l=o.x509.SubjectPublicKeyInfo,g=a.crypto,p=g.DSA,d=g.ECDSA,f=tt;function y(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 v(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 m(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!==f&&t instanceof f||void 0!==p&&t instanceof p||void 0!==d&&t instanceof d)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return Et(A=new l(t).tohex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==f&&t instanceof f&&(void 0===r||null==r)&&1==t.isPrivate)return Et(A=y(t).tohex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==d&&t instanceof d&&(void 0===r||null==r)&&1==t.isPrivate){var S=new h({name:t.curveName}).tohex(),E=v(t).tohex(),x="";return(x+=Et(S,"EC PARAMETERS"))+Et(E,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==p&&t instanceof p&&(void 0===r||null==r)&&1==t.isPrivate)return Et(A=m(t).tohex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==f&&t instanceof f&&void 0!==r&&null!=r&&1==t.isPrivate){var A=y(t).tohex();return void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",A,r,i,n)}if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==r&&null!=r&&1==t.isPrivate)return A=v(t).tohex(),void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",A,r,i,n);if("PKCS5PRV"==e&&void 0!==p&&t instanceof p&&void 0!==r&&null!=r&&1==t.isPrivate)return A=m(t).tohex(),void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",A,r,i,n);var w=function(t,e){if("string"==typeof e)return Mt.getEncryptedPKCS8PEM(t,e);if("object"==typeof e&&null!=Vt(e,"passcode")){var r=JSON.parse(JSON.stringify(e)),i=r.passcode;return delete r.passcode,Mt.getEncryptedPKCS8PEM(t,i,r)}};if("PKCS8PRV"==e&&null!=f&&t instanceof f&&1==t.isPrivate){var b=y(t).tohex();return A=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:b}}]}).tohex(),void 0===r||null==r?Et(A,"PRIVATE KEY"):w(A,r)}if("PKCS8PRV"==e&&void 0!==d&&t instanceof d&&1==t.isPrivate){var F={seq:[{int:1},{octstr:{hex:t.prvKeyHex}}]};return"string"==typeof t.pubKeyHex&&F.seq.push({tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}),b=new c(F).tohex(),A=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:b}}]}).tohex(),void 0===r||null==r?Et(A,"PRIVATE KEY"):w(A,r)}if("PKCS8PRV"==e&&void 0!==p&&t instanceof p&&1==t.isPrivate)return b=new u({bigint:t.x}).tohex(),A=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:b}}]}).tohex(),void 0===r||null==r?Et(A,"PRIVATE KEY"):w(A,r);throw new Error("unsupported object nor format")},Mt.getKeyFromCSRPEM=function(t){var e=xt(t,"CERTIFICATE REQUEST");return Mt.getKeyFromCSRHex(e)},Mt.getKeyFromCSRHex=function(t){var e=Mt.parseCSRHex(t);return Mt.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Mt.parseCSRHex=function(t){var e=ht,r=e.getChildIdx,i=e.getTLV,s={},n=t;if("30"!=n.substr(0,2))throw new Error("malformed CSR(code:001)");var a=r(n,0);if(a.length<1)throw new Error("malformed CSR(code:002)");if("30"!=n.substr(a[0],2))throw new Error("malformed CSR(code:003)");var o=r(n,a[0]);if(o.length<3)throw new Error("malformed CSR(code:004)");return s.p8pubkeyhex=i(n,o[2]),s},Mt.getKeyID=function(t){var e=Mt,r=ht;"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&(t=e.getKey(t));var i=xt(e.getPEM(t)),s=r.getIdxbyList(i,0,[1]),n=r.getV(i,s).substring(2);return nt.crypto.Util.hashHex(n,"sha1")},Mt.getJWK=function(t,e,r,i,s){var n,a,o={},h=nt.crypto.Util.hashHex;if("string"==typeof t)n=Mt.getKey(t),-1!=t.indexOf("CERTIFICATE")&&(a=xt(t));else{if("object"!=typeof t)throw new Error("unsupported keyinfo type");t instanceof Wt?(n=t.getPublicKey(),a=t.hex):n=t}if(n instanceof tt&&n.isPrivate)o.kty="RSA",o.n=pt(n.n.toString(16)),o.e=pt(n.e.toString(16)),o.d=pt(n.d.toString(16)),o.p=pt(n.p.toString(16)),o.q=pt(n.q.toString(16)),o.dp=pt(n.dmp1.toString(16)),o.dq=pt(n.dmq1.toString(16)),o.qi=pt(n.coeff.toString(16));else if(n instanceof tt&&n.isPublic)o.kty="RSA",o.n=pt(n.n.toString(16)),o.e=pt(n.e.toString(16));else if(n instanceof nt.crypto.ECDSA&&n.isPrivate){if("P-256"!==(c=n.getShortNISTPCurveName())&&"P-384"!==c&&"P-521"!==c)throw new Error("unsupported curve name for JWT: "+c);var u=n.getPublicKeyXYHex();o.kty="EC",o.crv=c,o.x=pt(u.x),o.y=pt(u.y),o.d=pt(n.prvKeyHex)}else if(n instanceof nt.crypto.ECDSA&&n.isPublic){var c;if("P-256"!==(c=n.getShortNISTPCurveName())&&"P-384"!==c&&"P-521"!==c)throw new Error("unsupported curve name for JWT: "+c);u=n.getPublicKeyXYHex(),o.kty="EC",o.crv=c,o.x=pt(u.x),o.y=pt(u.y)}if(null==o.kty)throw new Error("unsupported keyinfo");return n.isPrivate||1==e||(o.kid=nt.jws.JWS.getJWKthumbprint(o)),null!=a&&1!=r&&(o.x5c=[m(a)]),null!=a&&1!=i&&(o.x5t=lt(m(h(a,"sha1")))),null!=a&&1!=s&&(o["x5t#S256"]=lt(m(h(a,"sha256")))),o},Mt.getJWKFromKey=function(t){return Mt.getJWK(t,!0,!0,!0,!0)},tt.getPosArrayOfChildrenFromHex=function(t){return ht.getChildIdx(t,0)},tt.getHexValueArrayOfChildrenFromHex=function(t){var e,r=ht.getV,i=r(t,(e=tt.getPosArrayOfChildrenFromHex(t))[0]),s=r(t,e[1]),n=r(t,e[2]),a=r(t,e[3]),o=r(t,e[4]),h=r(t,e[5]),u=r(t,e[6]),c=r(t,e[7]),l=r(t,e[8]);return(e=new Array).push(i,s,n,a,o,h,u,c,l),e},tt.prototype.readPrivateKeyFromPEMString=function(t){var e=xt(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,i,s,n,a,o,h,u=ht,c=u.getVbyListEx;if(!1===u.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"),i=c(t,0,[2,0,3],"02"),s=c(t,0,[2,0,4],"02"),n=c(t,0,[2,0,5],"02"),a=c(t,0,[2,0,6],"02"),o=c(t,0,[2,0,7],"02"),h=c(t,0,[2,0,8],"02")}catch(t){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(e,r,i,s,n,a,o,h)},tt.prototype.readPKCS5PubKeyHex=function(t){var e=ht,r=e.getV;if(!1===e.isASN1HEX(t))throw new Error("keyHex is not ASN.1 hex string");var i=e.getChildIdx(t,0);if(2!==i.length||"02"!==t.substr(i[0],2)||"02"!==t.substr(i[1],2))throw new Error("wrong hex for PKCS#5 public key");var s=r(t,i[0]),n=r(t,i[1]);this.setPublic(s,n)},tt.prototype.readPKCS8PubKeyHex=function(t){var e=ht;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,i;(r=new Wt).readCertHex(t),i=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(i)},tt.prototype.sign=function(t,e){var r=function(t){return nt.crypto.Util.hashString(t,e)}(t);return this.signWithMessageHash(r,e)},tt.prototype.signWithMessageHash=function(t,e){var r=Z(nt.crypto.Util.getPaddedDigestInfoHex(t,e,this.n.bitLength()),16);return Kt(this.doPrivate(r).toString(16),this.n.bitLength())},tt.prototype.signPSS=function(t,e,r){var i,s=(i=St(t),nt.crypto.Util.hashHex(i,e));return void 0===r&&(r=-1),this.signWithMessageHashPSS(s,e,r)},tt.prototype.signWithMessageHashPSS=function(t,e,r){var i,s=mt(t),n=s.length,a=this.n.bitLength()-1,o=Math.ceil(a/8),h=function(t){return nt.crypto.Util.hashHex(t,e)};if(-1===r||void 0===r)r=n;else if(-2===r)r=o-n-2;else if(r<-2)throw new Error("invalid salt length");if(o<n+r+2)throw new Error("data too long");var u="";r>0&&(u=new Array(r),(new Q).nextBytes(u),u=String.fromCharCode.apply(String,u));var c=mt(h(St("\0\0\0\0\0\0\0\0"+s+u))),l=[];for(i=0;i<o-r-n-2;i+=1)l[i]=0;var g=String.fromCharCode.apply(String,l)+""+u,p=qt(c,g.length,h),d=[];for(i=0;i<g.length;i+=1)d[i]=g.charCodeAt(i)^p.charCodeAt(i);var f=65280>>8*o-a&255;for(d[0]&=~f,i=0;i<n;i++)d.push(c.charCodeAt(i));return d.push(188),Kt(this.doPrivate(new E(d)).toString(16),this.n.bitLength())},tt.prototype.verify=function(t,e){if(null==(e=e.toLowerCase()).match(/^[0-9a-f]+$/))return!1;var r=Z(e,16),i=this.n.bitLength();if(r.bitLength()>i)return!1;var s=this.doPublic(r).toString(16);if(s.length+3!=i/4)return!1;var n=Gt(s.replace(/^1f+00/,""));if(0==n.length)return!1;var a=n[0],o=n[1],h=function(t){return nt.crypto.Util.hashString(t,a)}(t);return o==h},tt.prototype.verifyWithMessageHash=function(t,e){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=Z(e,16);if(r.bitLength()>this.n.bitLength())return 0;var i=Gt(this.doPublic(r).toString(16).replace(/^1f+00/,""));return 0!=i.length&&(i[0],i[1]==t)},tt.prototype.verifyPSS=function(t,e,r,i){var s,n=(s=St(t),nt.crypto.Util.hashHex(s,r));return void 0===i&&(i=-1),this.verifyWithMessageHashPSS(n,e,r,i)},tt.prototype.verifyWithMessageHashPSS=function(t,e,r,i){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var s,n=new E(e,16),a=function(t){return nt.crypto.Util.hashHex(t,r)},o=mt(t),h=o.length,u=this.n.bitLength()-1,c=Math.ceil(u/8);if(-1===i||void 0===i)i=h;else if(-2===i)i=c-h-2;else if(i<-2)throw new Error("invalid salt length");if(c<h+i+2)throw new Error("data too long");var l=this.doPublic(n).toByteArray();for(s=0;s<l.length;s+=1)l[s]&=255;for(;l.length<c;)l.unshift(0);if(188!==l[c-1])throw new Error("encoded message does not end in 0xbc");var g=(l=String.fromCharCode.apply(String,l)).substr(0,c-h-1),p=l.substr(g.length,h),d=65280>>8*c-u&255;if(0!==(g.charCodeAt(0)&d))throw new Error("bits beyond keysize not zero");var f=qt(p,g.length,a),y=[];for(s=0;s<g.length;s+=1)y[s]=g.charCodeAt(s)^f.charCodeAt(s);y[0]&=~d;var v=c-h-i-2;for(s=0;s<v;s+=1)if(0!==y[s])throw new Error("leftmost octets not zero");if(1!==y[v])throw new Error("0x01 marker not found");return p===mt(a(St("\0\0\0\0\0\0\0\0"+o+String.fromCharCode.apply(String,y.slice(-i)))))},tt.SALT_LEN_HLEN=-1,tt.SALT_LEN_MAX=-2,tt.SALT_LEN_RECOVER=-2,Wt.EXT_PARSER={},Wt.registExtParser=function(t,e){Wt.EXT_PARSER[t]=e},Wt.hex2dn=function(t,e){void 0===e&&(e=0);var r=new Wt;return ht.getTLV(t,e),r.getX500Name(t).str},Wt.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,i=ht.getChildIdx(t,e),s=0;s<i.length;s++)r.push(Wt.hex2attrTypeValue(t,i[s]));return r=r.map(function(t){return t.replace("+","\\+")}),r.join("+")},Wt.hex2attrTypeValue=function(t,e){var r=ht,i=r.getV;if(void 0===e&&(e=0),"30"!==t.substr(e,2))throw new Error("malformed attribute type and value");var s=r.getChildIdx(t,e);2!==s.length||t.substr(s[0],2);var n=i(t,s[0]),a=nt.asn1.ASN1Util.oidHexToInt(n);return nt.asn1.x509.OID.oid2atype(a)+"="+mt(i(t,s[1]))},Wt.getPublicKeyFromCertHex=function(t){var e=new Wt;return e.readCertHex(t),e.getPublicKey()},Wt.getPublicKeyFromCertPEM=function(t){var e=new Wt;return e.readCertPEM(t),e.getPublicKey()},Wt.getPublicKeyInfoPropOfCertPEM=function(t){var e,r,i=ht.getVbyList,s={algparam:null};return(e=new Wt).readCertPEM(t),r=e.getPublicKeyHex(),s.keyhex=i(r,0,[1],"03").substr(2),s.algoid=i(r,0,[0,0],"06"),"2a8648ce3d0201"===s.algoid&&(s.algparam=i(r,0,[0,1],"06")),s},Wt.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"],void 0!==nt&&nt||(nt={}),void 0!==nt.jws&&nt.jws||(nt.jws={}),nt.jws.JWS=function(){var t=nt.jws.JWS.isSafeJSONString;this.parseJWS=function(e,r){if(void 0===this.parsedJWS||!r&&void 0===this.parsedJWS.sigvalH){var i=e.match(/^([^.]+)\.([^.]+)\.([^.]+)$/);if(null==i)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";var s=i[1],n=i[2],a=i[3],o=s+"."+n;if(this.parsedJWS={},this.parsedJWS.headB64U=s,this.parsedJWS.payloadB64U=n,this.parsedJWS.sigvalB64U=a,this.parsedJWS.si=o,!r){var h=dt(a),u=Z(h,16);this.parsedJWS.sigvalH=h,this.parsedJWS.sigvalBI=u}var c=ot(s),l=ot(n);if(this.parsedJWS.headS=c,this.parsedJWS.payloadS=l,!t(c,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+c}}},nt.jws.JWS.sign=function(t,e,r,i,s){var n,a,o,h=nt,u=h.jws.JWS,c=u.readSafeJSONString,l=u.isSafeJSONString,g=h.crypto,p=(g.ECDSA,g.Mac),d=g.Signature,f=JSON;if("string"!=typeof e&&"object"!=typeof e)throw"spHeader must be JSON string or object: "+e;if("object"==typeof e&&(a=e,n=f.stringify(a)),"string"==typeof e){if(!l(n=e))throw"JWS Head is not safe JSON string: "+n;a=c(n)}if(o=r,"object"==typeof r&&(o=f.stringify(r)),""!=t&&null!=t||void 0===a.alg||(t=a.alg),""!=t&&null!=t&&void 0===a.alg&&(a.alg=t,n=f.stringify(a)),t!==a.alg)throw"alg and sHeader.alg doesn't match: "+t+"!="+a.alg;var y=null;if(void 0===u.jwsalg2sigalg[t])throw"unsupported alg name: "+t;y=u.jwsalg2sigalg[t];var v=at(n)+"."+at(o),m="";if("Hmac"==y.substr(0,4)){if(void 0===i)throw"mac key shall be specified for HS* alg";var S=new p({alg:y,prov:"cryptojs",pass:i});S.updateString(v),m=S.doFinal()}else if(-1!=y.indexOf("withECDSA")){(x=new d({alg:y})).init(i,s),x.updateString(v);var E=x.sign();m=nt.crypto.ECDSA.asn1SigToConcatSig(E)}else{var x;"none"!=y&&((x=new d({alg:y})).init(i,s),x.updateString(v),m=x.sign())}return v+"."+pt(m)},nt.jws.JWS.verify=function(t,e,r){var i,s=nt,n=s.jws.JWS,a=n.readSafeJSONString,o=s.crypto,h=o.ECDSA,u=o.Mac,c=o.Signature;if(i=tt,!Ot(t))return!1;var l=t.split(".");if(3!==l.length)return!1;var g,p=l[0]+"."+l[1],d=dt(l[2]),f=a(ot(l[0])),y=null;if(void 0===f.alg)throw"algorithm not specified in header";if(g=(y=f.alg).substr(0,2),null!=r&&"[object Array]"===Object.prototype.toString.call(r)&&r.length>0&&-1==(":"+r.join(":")+":").indexOf(":"+y+":"))throw"algorithm '"+y+"' not accepted in the list";if("none"!=y&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=Mt.getKey(e)),!("RS"!=g&&"PS"!=g||e instanceof i))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==g&&!(e instanceof h))throw"key shall be a ECDSA obj for ES* algs";var v=null;if(void 0===n.jwsalg2sigalg[f.alg])throw"unsupported alg name: "+y;if("none"==(v=n.jwsalg2sigalg[y]))throw"not supported";if("Hmac"==v.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var m=new u({alg:v,pass:e});return m.updateString(p),d==m.doFinal()}if(-1!=v.indexOf("withECDSA")){var S,E=null;try{E=h.concatSigToASN1Sig(d)}catch(t){return!1}return(S=new c({alg:v})).init(e),S.updateString(p),S.verify(E)}return(S=new c({alg:v})).init(e),S.updateString(p),S.verify(d)},nt.jws.JWS.parse=function(t){var e,r,i,s=t.split("."),n={};if(2!=s.length&&3!=s.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=s[0],r=s[1],3==s.length&&(i=s[2]),n.headerObj=nt.jws.JWS.readSafeJSONString(ot(e)),n.payloadObj=nt.jws.JWS.readSafeJSONString(ot(r)),n.headerPP=JSON.stringify(n.headerObj,null," "),null==n.payloadObj?n.payloadPP=ot(r):n.payloadPP=JSON.stringify(n.payloadObj,null," "),void 0!==i&&(n.sigHex=dt(i)),n},nt.jws.JWS.verifyJWT=function(t,e,r){var i=nt.jws,s=i.JWS,n=s.readSafeJSONString,a=s.inArray,o=s.includedArray;if(!Ot(t))return!1;var h=t.split(".");if(3!=h.length)return!1;var u=h[0],c=h[1],l=(dt(h[2]),n(ot(u))),g=n(ot(c));if(void 0===l.alg)return!1;if(void 0===r.alg)throw"acceptField.alg shall be specified";if(!a(l.alg,r.alg))return!1;if(void 0!==g.iss&&"object"==typeof r.iss&&!a(g.iss,r.iss))return!1;if(void 0!==g.sub&&"object"==typeof r.sub&&!a(g.sub,r.sub))return!1;if(void 0!==g.aud&&"object"==typeof r.aud)if("string"==typeof g.aud){if(!a(g.aud,r.aud))return!1}else if("object"==typeof g.aud&&!o(g.aud,r.aud))return!1;var p=i.IntDate.getNow();return void 0!==r.verifyAt&&"number"==typeof r.verifyAt&&(p=r.verifyAt),void 0!==r.gracePeriod&&"number"==typeof r.gracePeriod||(r.gracePeriod=0),!(void 0!==g.exp&&"number"==typeof g.exp&&g.exp+r.gracePeriod<p||void 0!==g.nbf&&"number"==typeof g.nbf&&p<g.nbf-r.gracePeriod||void 0!==g.iat&&"number"==typeof g.iat&&p<g.iat-r.gracePeriod||void 0!==g.jti&&void 0!==r.jti&&g.jti!==r.jti||!s.verify(t,e,r.alg))},nt.jws.JWS.includedArray=function(t,e){var r=nt.jws.JWS.inArray;if(null===t)return!1;if("object"!=typeof t)return!1;if("number"!=typeof t.length)return!1;for(var i=0;i<t.length;i++)if(!r(t[i],e))return!1;return!0},nt.jws.JWS.inArray=function(t,e){if(null===e)return!1;if("object"!=typeof e)return!1;if("number"!=typeof e.length)return!1;for(var r=0;r<e.length;r++)if(e[r]==t)return!0;return!1},nt.jws.JWS.jwsalg2sigalg={HS256:"HmacSHA256",HS384:"HmacSHA384",HS512:"HmacSHA512",RS256:"SHA256withRSA",RS384:"SHA384withRSA",RS512:"SHA512withRSA",ES256:"SHA256withECDSA",ES384:"SHA384withECDSA",ES512:"SHA512withECDSA",PS256:"SHA256withRSAandMGF1",PS384:"SHA384withRSAandMGF1",PS512:"SHA512withRSAandMGF1",none:"none"},nt.jws.JWS.isSafeJSONString=function(t,e,r){var i=null;try{return"object"!=typeof(i=st(t))||i.constructor===Array?0:(e&&(e[r]=i),1)}catch(t){return 0}},nt.jws.JWS.readSafeJSONString=function(t){var e=null;try{return"object"!=typeof(e=st(t))||e.constructor===Array?null:e}catch(t){return null}},nt.jws.JWS.getEncodedSignatureValueFromJWS=function(t){var e=t.match(/^[^.]+\.[^.]+\.([^.]+)$/);if(null==e)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";return e[1]},nt.jws.JWS.getJWKthumbprint=function(t){if("RSA"!==t.kty&&"EC"!==t.kty&&"oct"!==t.kty)throw"unsupported algorithm for JWK Thumprint";var e="{";if("RSA"===t.kty){if("string"!=typeof t.n||"string"!=typeof t.e)throw"wrong n and e value for RSA key";e+='"e":"'+t.e+'",',e+='"kty":"'+t.kty+'",',e+='"n":"'+t.n+'"}'}else if("EC"===t.kty){if("string"!=typeof t.crv||"string"!=typeof t.x||"string"!=typeof t.y)throw"wrong crv, x and y value for EC key";e+='"crv":"'+t.crv+'",',e+='"kty":"'+t.kty+'",',e+='"x":"'+t.x+'",',e+='"y":"'+t.y+'"}'}else if("oct"===t.kty){if("string"!=typeof t.k)throw"wrong k value for oct(symmetric) key";e+='"kty":"'+t.kty+'",',e+='"k":"'+t.k+'"}'}var r=St(e);return pt(nt.crypto.Util.hashHex(r,"sha256"))},nt.jws.IntDate={},nt.jws.IntDate.get=function(t){var e=nt.jws.IntDate,r=e.getNow,i=e.getZulu;if("now"==t)return r();if("now + 1hour"==t)return r()+3600;if("now + 1day"==t)return r()+86400;if("now + 1month"==t)return r()+2592e3;if("now + 1year"==t)return r()+31536e3;if(t.match(/Z$/))return i(t);if(t.match(/^[0-9]+$/))return parseInt(t);throw"unsupported format: "+t},nt.jws.IntDate.getZulu=function(t){return function(t){return Math.round(function(t){var e,r,i,s,n,a,o,h,u,c;if(c=(t=function(t){return t.match(/^[0-9]{12}Z$/)||t.match(/^[0-9]{12}[.][0-9]*Z$/)?t.match(/^[0-4]/)?"20"+t:"19"+t:t}(t)).match(/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(|\.\d+)Z$/))return e=parseInt(c[1]),r=parseInt(c[2])-1,i=parseInt(c[3]),s=parseInt(c[4]),n=parseInt(c[5]),a=parseInt(c[6]),o=0,""!==(h=c[7])&&(u=(h.substr(1)+"00").substr(0,3),o=parseInt(u)),Date.UTC(e,r,i,s,n,a,o);throw new Error("unsupported zulu format: "+t)}(t)/1e3)}(t)},nt.jws.IntDate.getNow=function(){return~~(new Date/1e3)},nt.jws.IntDate.intDate2UTCString=function(t){return new Date(1e3*t).toUTCString()},nt.jws.IntDate.intDate2Zulu=function(t){var e=new Date(1e3*t);return("0000"+e.getUTCFullYear()).slice(-4)+("00"+(e.getUTCMonth()+1)).slice(-2)+("00"+e.getUTCDate()).slice(-2)+("00"+e.getUTCHours()).slice(-2)+("00"+e.getUTCMinutes()).slice(-2)+("00"+e.getUTCSeconds()).slice(-2)+"Z"},void 0!==nt&&nt||(nt={}),void 0!==nt.jws&&nt.jws||(nt.jws={}),nt.jws.JWSJS=function(){var t=nt.jws.JWS,e=t.readSafeJSONString;this.aHeader=[],this.sPayload="",this.aSignature=[],this.init=function(){this.aHeader=[],this.sPayload=void 0,this.aSignature=[]},this.initWithJWS=function(t){this.init();var e=t.split(".");if(3!=e.length)throw"malformed input JWS";this.aHeader.push(e[0]),this.sPayload=e[1],this.aSignature.push(e[2])},this.addSignature=function(t,e,r,i){if(void 0===this.sPayload||null===this.sPayload)throw"there's no JSON-JS signature to add.";var s=this.aHeader.length;if(this.aHeader.length!=this.aSignature.length)throw"aHeader.length != aSignature.length";try{var n=nt.jws.JWS.sign(t,e,this.sPayload,r,i).split(".");n[0],n[2],this.aHeader.push(n[0]),this.aSignature.push(n[2])}catch(t){throw this.aHeader.length>s&&this.aHeader.pop(),this.aSignature.length>s&&this.aSignature.pop(),"addSignature failed: "+t}},this.verifyAll=function(t){if(this.aHeader.length!==t.length||this.aSignature.length!==t.length)return!1;for(var e=0;e<t.length;e++){var r=t[e];if(2!==r.length)return!1;if(!1===this.verifyNth(e,r[0],r[1]))return!1}return!0},this.verifyNth=function(e,r,i){if(this.aHeader.length<=e||this.aSignature.length<=e)return!1;var s=this.aHeader[e],n=this.aSignature[e],a=s+"."+this.sPayload+"."+n,o=!1;try{o=t.verify(a,r,i)}catch(t){return!1}return o},this.readJWSJS=function(t){if("string"==typeof t){var r=e(t);if(null==r)throw"argument is not safe JSON object string";this.aHeader=r.headers,this.sPayload=r.payload,this.aSignature=r.signatures}else try{if(!(t.headers.length>0))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(t.signatures.length>0))throw"malformed signatures";this.aSignature=t.signatures}catch(t){throw"malformed JWS-JS JSON object: "+t}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}},nt.crypto.ECDSA,nt.crypto.DSA,nt.crypto.Signature,nt.crypto.MessageDigest,nt.crypto.Mac,e.ym=Mt,e.wV=pt,e.cV=ot,e.pj=nt,nt.crypto,nt.asn1,nt.jws,nt.lang}},e={};function r(i){var s=e[i];if(void 0!==s)return s.exports;var n=e[i]={exports:{}};return t[i](n,n.exports,r),n.exports}r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let i=function(t){return t.light="light",t.dark="dark",t}({});class s{theme="default";themeMode=i.light;constructor(t){t&&(this.theme=t.theme??this.theme,this.themeMode=t.themeMode??this.themeMode)}toString(){return JSON.stringify(this)}}class n{static deepEqual(t,e){if(t===e)return!0;if(null==t||null==e)return!1;if("object"==typeof t&&"object"==typeof e){if(t.constructor!==e.constructor)return!1;if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!n.deepEqual(t[r],e[r]))return!1;return!0}if(!Array.isArray(t)&&!Array.isArray(e)){const r=Object.keys(t),i=Object.keys(e);if(r.length!==i.length)return!1;for(const i of r)if(!(i in e)||!n.deepEqual(t[i],e[i]))return!1;return!0}return!1}return!1}static deepCopy(t){if("object"!=typeof t||null==t||"function"==typeof t)return t;if(n.hasCopyMethod(t))return t.copy();const e=n.copyBuiltInType(t);return null!==e?e:n.copyPlainObject(t)}static copyBuiltInType(t){return Array.isArray(t)?t.map(t=>n.deepCopy(t)):t instanceof Date?new Date(t.getTime()):t instanceof RegExp?new RegExp(t.source,t.flags):t instanceof Map?new Map(Array.from(t.entries()).map(([t,e])=>[n.deepCopy(t),n.deepCopy(e)])):t instanceof Set?new Set(Array.from(t.values()).map(t=>n.deepCopy(t))):null}static copyPlainObject(t){const e=Object.create(Object.getPrototypeOf(t));for(const r of Object.keys(t))e[r]=n.deepCopy(t[r]);return e}static hasCopyMethod(t){return"object"==typeof t&&null!==t&&Object.prototype.hasOwnProperty.call(t,"copy")&&"function"==typeof t.copy}static isNullOrUndefined=t=>null==t}const a={BYTES:1,KB:1024,MB:1048576,GB:1024**3,TB:1024**4,PB:1024**5},o=/^(\d+(?:\.\d+)?)\s*(bytes|KB|MB|GB|TB|PB)$/i,h=/^\d+$/;class u{static convertToBytes(t){if(null==t)return 0;if("number"==typeof t)return t;if(t=t.trim(),h.test(t))return Number.parseInt(t,10);const e=o.exec(t);if(!e)return 0;const r=Number.parseFloat(e[1]),i=e[2];return r*a[i.toUpperCase()]}static convertToHumanReadable(t){if(!t)return"0 bytes";if("string"==typeof t&&(t=t.trim()),o.test(String(t)))return String(t);if("string"==typeof t&&(t=Number.parseFloat(t)),Number.isNaN(t)||t<=0)return"0 bytes";const e=Object.keys(a).reverse();for(const r of e){const e=a[r];if(t>=e){const i=t/e;return`${Number.isInteger(i)?i:i.toFixed(2)} ${"BYTES"===r?"bytes":r}`}}return"0 bytes"}}class c{static getWindow(){return window}static getPluginRegistry(){return c.getWindow().PluginRegistry}static getCrypto(){return c.getWindow().crypto}static getLocationHref(){return c.getWindow().location.href}static setLocationHref(t){c.getWindow().location.href=t}static getLocationQueryParams(){return c.getWindow().location.search}static getLocationHash(){return c.getWindow().location.hash}static getLocationPathWithQueryParams(){return S()+c.getLocationQueryParams()}static matchMedia(t){return c.getWindow().matchMedia(t)}}class l{static isDevMode(){return c.getWindow().wbDevMode}}class g{static ABS_URI_REGEX=/^<?(http|urn).*>?/;static GRAPHS_VISUALIZATIONS_URL="graphs-visualizations";static RESOURCE_URL="resource";static BASE_DOCUMENTATION_URL="https://graphdb.ontotext.com/documentation/";static LATEST_UNOFFICIAL_VERSION="master";static shortenIri(t){const e=document.createElement("a");e.href=t;let r=e.hostname;return g.containsIPV4(e.hostname)||(r=e.hostname.split(".")[0]),r+":"+e.port}static containsIPV4(t){const e=t.split(".");for(let t=0,r=0;t<e.length;t++)if(parseInt(e[t],10)>=0&&parseInt(e[t],10)<=255?r++:r=0,4===r)return!0;return!1}static createAutocompleteRedirect(t,e){return`${t}?uri=${encodeURIComponent(e)}`}static removeAngleBrackets(t){return t?.startsWith("<")&&t?.endsWith(">")?t.substring(1,t.length-1):t}static isValidUri(t){let e=!1;if(this.hasValidProtocol(t))if(t.indexOf("http")>=0){const r=t.indexOf("//");e=r>4&&t.substring(r+2).length>0}else t.indexOf("urn")>=0&&(e=t.substring(4).length>0);return e}static resolveDocumentationUrl(t,e){if(!t||!e)throw new Error("Product version and endpoint path are required for documentation URL resolution.");const r=t.includes("-"),i=l.isDevMode()||r?this.LATEST_UNOFFICIAL_VERSION:t;return`${this.BASE_DOCUMENTATION_URL}${i}/${e}`}static hasAngleBrackets(t){return t.startsWith("<")&&t.endsWith(">")}static hasNoAngleBrackets(t){return!t.startsWith("<")&&!t.endsWith(">")}static hasValidProtocol(t){return this.ABS_URI_REGEX.test(t)&&(this.hasNoAngleBrackets(t)||this.hasAngleBrackets(t))}}class p{fibo1=0;fibo2=1;next(){const t=this.fibo2;return this.fibo2=this.fibo1+this.fibo2,this.fibo1=t,t}reset=()=>{this.fibo1=0,this.fibo2=1}}function d(t){return e=>{e&&e.preventDefault(),f(t)}}function f(t){t.startsWith(".")&&(t=t.slice(1)),t.startsWith("/")&&!t.startsWith(x())&&(t=x().slice(0,-1)+t),c.getWindow().singleSpa.navigateToUrl(t)}function y(t){c.getWindow().open(t,"_blank")}function v(){return"/"===S()}function m(){return"/login"===S()}function S(){return c.getWindow().location.pathname.substring(x().length-1)}function E(){return`${c.getWindow().location.origin}${x()}`}function x(){return document.querySelector("base")?.getAttribute("href")??"/"}function A(){return S().substring(1)}function w(t,e){if(Object.values(t).includes(e))return e;throw new Error(`Invalid enum value '${e}' for enum ${JSON.stringify(t)}`)}class b{copy(){return n.deepCopy(this)}}class F extends b{constructor(t=[]){super(),this.items=t}size(){return this.items.length}getItems(){return this.items}getFirstItem(){return this.items[0]}sort(t){this.items.sort(t)}filter(t){return this.items.filter(t)}find(t){return this.items.find(t)}isEmpty(){return 0===this.items.length}addToStart(t){this.items.unshift(t)}addItems(t){this.items.push(...t)}remove(t){const e=this.items.indexOf(t);-1!==e&&this.items.splice(e,1)}}class I extends F{constructor(t){super(t)}add(t){this.items.push(t)}addAll(t){this.items.push(...t)}unsubscribeAll(){this.items.forEach(t=>t()),this.items=[]}}class R extends b{constructor(t){super(),this.id=t.id||"",this.title=t.title||"",this.type=t.type,this.sesameType=t.sesameType,this.uri=t.uri||"",this.externalUrl=t.externalUrl||"",this.location=t.location||"",this.state=t.state,this.local=t.local,this.readable=t.readable,this.writable=t.writable,this.unsupported=t.unsupported,this.isNew=t.isNew}toRepositoryReference(){return{id:this.id,location:this.location}}isOntop(){return"graphdb:OntopRepository"===this.sesameType}isFedx(){return"graphdb:FedXRepository"===this.sesameType}}const C=(t,e)=>{const r=t.location.localeCompare(e.location);return 0!==r?r:t.id.localeCompare(e.id)};class T extends F{constructor(t){super(t)}findRepository(t,e,r=!1){return super.find(i=>i.id===t&&(r||i.location===e))}sortByLocationAndId(){super.sort(C)}filterByRepository(t){return super.filter(this.createIdLocationFilter(t))}createIdLocationFilter(t){return e=>t.some(t=>t.id!==e.id||t.location!==e.location)}}class P extends b{constructor(t){super(),this.inferred=t?.inferred||0,this.total=t?.total||0,this.explicit=t?.explicit||0}}let D=function(t){return t.INACTIVE="INACTIVE",t.STARTING="STARTING",t.RUNNING="RUNNING",t.RESTARTING="RESTARTING",t.STOPPING="STOPPING",t}({}),N=function(t){return t.GRAPH_DB="graphdb",t.ONTOP="ontop",t.FEDX="fedx",t.SYSTEM="system",t}({});const O="repositoryId";class B extends b{constructor(t){super(),this.uri=t?.uri||"",this.label=t?.label||"",this.username=t?.username||"",this.password=t?.password||"",this.authType=t?.authType,this.locationType=t?.locationType,this.active=t?.active,this.local=t?.local,this.system=t?.system,this.errorMsg=t?.errorMsg||"",this.defaultRepository=t?.defaultRepository||""}}let _=function(t){return t.GDB="GDB",t.ONTOPIC="ONTOPIC",t.SPARQL="SPARQL",t}({});class H{constructor(t){this.namespaces=t}getByPrefix(t){return this.namespaces[t]||""}}class L{constructor(t,e){this.NAME=t,this.payload=e}}const k={NAVIGATION_END:"navigationEnd",NAVIGATION_START:"navigationStart",LOGIN:"login",LOGOUT:"logout",APP_DATA_LOADED:"applicationDataLoaded",APPLICATION_MOUNTED:"applicationMounted",APPLICATION_UNMOUNTED:"applicationUnmounted",APPLICATION_CHANGED:"applicationChanged",APPLICATION_BEFORE_CHANGE:"applicationBeforeChange"};class U extends L{constructor(t,e){super(k.NAVIGATION_END,{oldUrl:t,newUrl:e})}}class V{}class j extends L{constructor(t,e,r){super(k.NAVIGATION_START,{oldUrl:t,newUrl:e,cancelNavigation:r})}}class M extends L{constructor(){super(k.APPLICATION_MOUNTED)}}class K extends L{constructor(){super(k.APPLICATION_UNMOUNTED)}}class q extends L{constructor(){super(k.APPLICATION_BEFORE_CHANGE)}}class G extends L{constructor(){super(k.APPLICATION_CHANGED)}}class W extends L{constructor(){super(k.LOGOUT)}}class $ extends L{constructor(){super(k.LOGIN)}}let z=function(t){return t.NONE="NONE",t.BASIC="BASIC",t.SIGNATURE="SIGNATURE",t}({}),X=function(t){return t.ROLE_ADMIN="ROLE_ADMIN",t.ROLE_USER="ROLE_USER",t.ROLE_MONITORING="ROLE_MONITORING",t.ROLE_REPO_MANAGER="ROLE_REPO_MANAGER",t.ROLE_CLUSTER="ROLE_CLUSTER",t.IS_AUTHENTICATED_FULLY="IS_AUTHENTICATED_FULLY",t.SYSTEM_REPO="SYSTEM",t.READ_REPO="READ_REPO",t.READ_REPO_PREFIX="READ_REPO_",t.WRITE_REPO="WRITE_REPO",t.GRAPHQL="GRAPHQL",t.WRITE_REPO_PREFIX="WRITE_REPO_",t.GRAPHQL_PREFIX="GRAPHQL_",t.SUFFIX_DELIMITER=":",t.CUSTOM_PREFIX="CUSTOM_",t}({});class Y{static getRepoFromAuthority(t){return t.startsWith(X.READ_REPO_PREFIX)?{prefix:X.READ_REPO_PREFIX,repo:t.substring(X.READ_REPO_PREFIX.length)}:t.startsWith(X.WRITE_REPO_PREFIX)?{prefix:X.WRITE_REPO_PREFIX,repo:t.substring(X.WRITE_REPO_PREFIX.length)}:t.startsWith(X.GRAPHQL_PREFIX)?{prefix:X.GRAPHQL_PREFIX,repo:t.substring(X.GRAPHQL_PREFIX.length)}:null}}const J=t=>{const e=X.SUFFIX_DELIMITER+X.GRAPHQL,r=t.getItems();if(!r.length)return r;const i=[],s={};let n=!1,a=!1,o=!1;r.forEach(t=>{const e=Y.getRepoFromAuthority(t);if(e){const{prefix:t,repo:i}=e,h=(s[r=i]||(s[r]={read:!1,write:!1,graphql:!1}),s[r]);t===X.READ_REPO_PREFIX?(h.read=!0,"*"===i&&(n=!0)):t===X.WRITE_REPO_PREFIX?(h.write=!0,"*"===i&&(a=!0)):t===X.GRAPHQL_PREFIX&&(h.graphql=!0,"*"===i&&(o=!0))}else i.push(t);var r});const h=[];return Object.keys(s).forEach(t=>{const r=s[t];r.graphql||o?r.write||a?h.push(`${X.WRITE_REPO_PREFIX}${t}${e}`,`${X.READ_REPO_PREFIX}${t}${e}`):(r.read||n)&&h.push(`${X.READ_REPO_PREFIX}${t}${e}`):r.write?h.push(`${X.WRITE_REPO_PREFIX}${t}`,`${X.READ_REPO_PREFIX}${t}`):r.read&&h.push(`${X.READ_REPO_PREFIX}${t}`)}),[...i,...h]},Q=t=>{if(!t)return new tt;const e=[],r=(t instanceof tt?t.getItems():t)??[];for(const t of r)Z(t,e)||e.includes(t)||e.push(t);return new tt(e)};function Z(t,e){if(!t.includes(X.SUFFIX_DELIMITER))return!1;const[r,i]=t.split(X.SUFFIX_DELIMITER);if(!r.startsWith(X.READ_REPO_PREFIX)&&!r.startsWith(X.WRITE_REPO_PREFIX)||i!==X.GRAPHQL)return!1;const s=Y.getRepoFromAuthority(r);if(!s)return!1;const{repo:n}=s,a=X.GRAPHQL_PREFIX+n;return e.includes(r)||e.push(r),e.includes(a)||e.push(a),!0}class tt extends F{WILDCARD="*";GQL_WILDCARD="*:GRAPHQL";constructor(t){super(t)}hasAuthority(t){return this.items.includes(t)}hasWildcardAuthority(t,e){const r=e?this.GQL_WILDCARD:this.WILDCARD;let i=!1;for(const e of this.items){if(!e.endsWith(r))continue;const s=e.substring(0,e.length-r.length);if(t.startsWith(s)){i=!0;break}}return i}getCustomRoles(){return this.getItems().filter(t=>0===t.indexOf(X.CUSTOM_PREFIX)).map(t=>t.substring(X.CUSTOM_PREFIX.length))}toUIModel(){const t={[X.READ_REPO]:{},[X.WRITE_REPO]:{},[X.GRAPHQL]:{}};return Q(this.getItems()).getItems().forEach(e=>{if(e.startsWith(X.READ_REPO_PREFIX)||e.startsWith(X.WRITE_REPO_PREFIX)||e.startsWith(X.GRAPHQL_PREFIX)){const r=Y.getRepoFromAuthority(e);if(r){const{prefix:e,repo:i}=r;e===X.READ_REPO_PREFIX?t[X.READ_REPO][i]=!0:e===X.WRITE_REPO_PREFIX?t[X.WRITE_REPO][i]=!0:e===X.GRAPHQL_PREFIX&&(t[X.GRAPHQL][i]=!0)}}}),t}toGraphdbAuthoritiesModel(){return J(this)}getRepositoriesPermissions(){const t={},e=this.getItems();for(const r of e){const e=Y.getRepoFromAuthority(r);if(e){const{prefix:r,repo:i}=e,s=t[i]??{read:!1,write:!1,graphql:!1};r===X.READ_REPO_PREFIX?s.read=!0:r===X.WRITE_REPO_PREFIX?s.write=!0:r===X.GRAPHQL_PREFIX&&(s.graphql=!0),t[i]=s}}return t}}class et{constructor(t){this.DEFAULT_VIS_GRAPH_SCHEMA=t?.DEFAULT_VIS_GRAPH_SCHEMA??!0,this.DEFAULT_INFERENCE=t?.DEFAULT_INFERENCE??!0,this.DEFAULT_SAMEAS=t?.DEFAULT_SAMEAS??!0,this.IGNORE_SHARED_QUERIES=t?.IGNORE_SHARED_QUERIES??!1,this.EXECUTE_COUNT=t?.EXECUTE_COUNT??!0,this.COOKIE_CONSENT=t?.COOKIE_CONSENT}toJSON(){return{DEFAULT_VIS_GRAPH_SCHEMA:this.DEFAULT_VIS_GRAPH_SCHEMA,DEFAULT_INFERENCE:this.DEFAULT_INFERENCE,DEFAULT_SAMEAS:this.DEFAULT_SAMEAS,IGNORE_SHARED_QUERIES:this.IGNORE_SHARED_QUERIES,EXECUTE_COUNT:this.EXECUTE_COUNT,COOKIE_CONSENT:this.COOKIE_CONSENT}}}let rt=function(t){return t.ADMIN="admin",t.REPO_MANAGER="repoManager",t.USER="user",t}({});class it extends b{constructor(t){super(),this.username=t?.username??"",this.password=t?.password,this.confirmPassword=t?.confirmPassword,this.authorities=t?.authorities??new tt,this.appSettings=t?.appSettings??new et,this.dateCreated=t?.dateCreated??null,this.gptThreads=t?.gptThreads??[],this.external=t?.external??!1}getUserType(){return this.authorities.hasAuthority(X.ROLE_ADMIN)?rt.ADMIN:this.authorities.hasAuthority(X.ROLE_REPO_MANAGER)?rt.REPO_MANAGER:rt.USER}getUserTypeDescription(){const t=this.getUserType();return t===rt.USER?"User":t===rt.REPO_MANAGER?"Repository manager":t===rt.ADMIN?"Administrator":"Unknown"}}class st extends b{toUser(){return new it({username:this.username,authorities:this.authorities,appSettings:this.appSettings,external:this.external})}static fromUser(t){return new st({username:t.username,authorities:t.authorities,appSettings:t.appSettings,external:t.external})}constructor(t){super(),this.external=t?.external??!1,this.username=t?.username??"",this.password=t?.password??"",this.authorities=t?.authorities??new tt,this.grantedAuthoritiesUiModel=Q(t?.authorities??[]),this.appSettings=t?.appSettings??new et}setAuthorities(t=new tt){return this.authorities=t,this.grantedAuthoritiesUiModel=Q(t.getItems()),this}setAppSettings(t=new et){return this.appSettings=t,this}}class nt extends b{constructor(t){super(),t&&(this.clientId=t.clientId,this.issuer=t.issuer,this.tokenType=t.tokenType,this.tokenAudience=t.tokenAudience,this.tokenIssuer=t.tokenIssuer,this.oidcTokenEndpoint=t.oidcTokenEndpoint,this.oidcJwksUri=t.oidcJwksUri,this.oidcEndSessionEndpoint=t.oidcEndSessionEndpoint,this.oidcAuthorizationEndpoint=t.oidcAuthorizationEndpoint,this.oidcScopesSupported=t.oidcScopesSupported||[],this.oracleDomain=t.oracleDomain,this.proxyOidc=t.proxyOidc||!1,this.authFlow=t.authFlow,this.extraScopes=t.extraScopes,this.authorizeParameters=t.authorizeParameters,this.openIdTokenUrl=this.proxyOidc?"rest/openid/token":this.oidcTokenEndpoint,this.openIdKeysUri=this.proxyOidc?"rest/openid/jwks":this.oidcJwksUri,this.openIdEndSessionUrl=this.oidcEndSessionEndpoint,this.supportsOfflineAccess=this.oidcScopesSupported.includes("offline_access"))}}const at=t=>new tt(t);class ot extends b{constructor(t){super(),this.appSettings=t.appSettings,t.authorities instanceof tt?this.authorities=t.authorities:this.authorities=at(t.authorities??[]),this.enabled=t.enabled}}const ht=t=>{const e=new ot({});return e.appSettings=new et(t.appSettings),e.authorities=at(t.authorities||[]),e.enabled=t.enabled,e};class ut extends b{constructor(t){super(),this.authImplementation=t.authImplementation,this.enabled=t.enabled,this.passwordLoginEnabled=t.passwordLoginEnabled,this.freeAccess=ht(t.freeAccess),this.overrideAuth=ht(t.overrideAuth),this.openIdEnabled=t.openIdEnabled,this.freeAccessActive=t.freeAccess?.enabled,this.hasExternalAuth=t.hasExternalAuth,t.methodSettings?.openid&&(this.openidSecurityConfig=new nt(t.methodSettings?.openid))}isEnabled(){return this.enabled??!1}isFreeAccessEnabled(){return this.freeAccess.enabled??!1}getFreeAccessAuthSettings(){return this.freeAccess}hasOverrideAuth(){return this.overrideAuth?.enabled??!1}}class ct extends b{pages={};isRestricted(t){return this.pages[t]??!1}setPageRestriction(t,e=!0){return this.pages[t]=e,this}}let lt=function(t){return t.READ="READ",t.WRITE="WRITE",t}({});class gt extends b{constructor(t){super(),this.expiryDate=t?.expiryDate,this.latestPublicationDate=t?.latestPublicationDate,this.licensee=t?.licensee||"",this.maxCpuCores=t?.maxCpuCores,this.product=t?.product,this.productType=t?.productType,this.licenseCapabilities=t?.licenseCapabilities,this.version=t?.version||"",this.installationId=t?.installationId||"",this.valid=t?.valid,this.typeOfUse=t?.typeOfUse||"",this.message=t?.message||"",this.present=t?.present||!1,this.usageRestriction=t?.usageRestriction||""}}class pt extends F{constructor(t){super(t)}}class dt{constructor(t){this.workbench=t.workbench,this.productType=t.productType,this.productVersion=t.productVersion,this.sesame=t.sesame,this.connectors=t.connectors,this.shortVersion=this.resolveShortVersion(t)}resolveShortVersion(t){const e=t.productVersion;if(!e)return"";const r=/^(\d+\.\d+)/.exec(e),i=r?.[1]??e,s=/(-[^-]+)/.exec(e);return i+(s?.[1]??"")}}let ft=function(t){return t.CONSOLE="console",t}({}),yt=function(t){return t.DEBUG="DEBUG",t.INFO="INFO",t.WARN="WARN",t.ERROR="ERROR",t}({});const vt=t=>mt[t],mt={[yt.DEBUG]:0,[yt.INFO]:1,[yt.WARN]:2,[yt.ERROR]:3};class St{static SERVICE_INSTANCES=new Map;static get(t){if(!St.SERVICE_INSTANCES.has(t.name)){const e=new t;St.implementsLifecycleHooks(e)&&e.onCreated?.(),St.SERVICE_INSTANCES.set(t.name,e)}return this.SERVICE_INSTANCES.get(t.name)}static implementsLifecycleHooks(t){return"object"==typeof t&&"function"==typeof t.onCreated}static getAllBySuperType(t){return Array.from(St.SERVICE_INSTANCES.values()).filter(e=>e instanceof t)}}function Et(t){return St.get(t)}const xt=new Map([[ft.CONSOLE,Et(class{log(t,e,r){switch(t){case yt.DEBUG:console.debug(e,...r);break;case yt.INFO:console.info(e,...r);break;case yt.WARN:console.warn(e,...r);break;case yt.ERROR:console.error(e,...r);break;default:console.debug(e,...r)}}})]]);class At{callbackFunctions=[];beforeChangeValidationPromises=[];afterValueChangeCallbackFunctions=[];setValue(t){n.deepEqual(this.value,t)||(this.value=this.getCopy(t),this.callbackFunctions.forEach(t=>t(this.getValue())),this.afterValueChangeCallbackFunctions.forEach(t=>t(this.getValue())))}getValue(){return this.getCopy(this.value)}subscribe(t,e,r){return this.callbackFunctions.push(t),e&&this.beforeChangeValidationPromises.push(e),r&&this.afterValueChangeCallbackFunctions.push(r),()=>{this.callbackFunctions=this.callbackFunctions.filter(e=>e!==t),this.beforeChangeValidationPromises=this.beforeChangeValidationPromises.filter(t=>t!==e),this.afterValueChangeCallbackFunctions=this.afterValueChangeCallbackFunctions.filter(t=>t!==r)}}async canUpdate(t){if(0===this.beforeChangeValidationPromises.length)return!0;const e=this.beforeChangeValidationPromises.map(e=>e(t));try{return(await Promise.all(e)).every(t=>t)}catch{return!1}}getCopy(t){if(null!=t)return n.hasCopyMethod(t)?t.copy():n.deepCopy(t)}}class wt{subscribers=[];unsubFns=new I;subscribeToService(t){const e=this.subscribers.map(e=>t.subscribeAll(e.callback,e.beforeChangeValidationPromise,e.afterChangeCallback));return this.unsubFns.addAll(e),()=>e.forEach(t=>t())}subscribeToAllRegisteredContexts(t,e,r){const i=St.getAllBySuperType(bt).filter(t=>t.canSubscribeAll);for(const s of i)this.unsubFns.add(s.subscribeAll(t,e,r));const s={callback:t,beforeChangeValidationPromise:e,afterChangeCallback:r};this.subscribers.push(s);let n=!1;return()=>{if(n)return;n=!0,this.unsubFns.unsubscribeAll();const t=this.subscribers.indexOf(s);t>=0&&this.subscribers.splice(t,1)}}}class bt{context=new Map;_canSubscribeAll=!1;onCreated(){this._canSubscribeAll=!0,St.get(wt).subscribeToService(this)}updateContextProperty(t,e){this.getOrCreateValueContext(t).setValue(e)}validatePropertyChange(t,e){return this.getOrCreateValueContext(t).canUpdate(e)}getContextPropertyValue(t){const e=this.context.get(t);return e?e.getValue():void 0}subscribe(t,e,r,i){return e&&e(this.getContextPropertyValue(t)),i&&i(this.getContextPropertyValue(t)),this.getOrCreateValueContext(t).subscribe(e,r,i)}getDeserializedContext(){}deserializeProperty(t,e){const r=this.getDeserializedContext()?.[t];return r?r(e):e}subscribeAll(t,e,r){const i=new I;for(const s of this.getContextFields())i.add(this.subscribe(s,t,e,r));return()=>i.unsubscribeAll()}getContextFields(){return Object.values(this).filter(t=>"string"==typeof t)}getOrCreateValueContext(t){let e=this.context.get(t);return e||(e=new At,this.context.set(t,e)),e}canHandle(t){for(const e in this)if(this[e]===t)return!0;return!1}get canSubscribeAll(){return this._canSubscribeAll}}class Ft extends bt{APPLICATION_CONFIGURATION="applicationConfiguration";updateApplicationConfiguration(t){this.updateContextProperty(this.APPLICATION_CONFIGURATION,t)}getApplicationConfiguration(){return this.getContextPropertyValue(this.APPLICATION_CONFIGURATION)}getApplicationLogoPath(t){const e=this.getApplicationConfiguration(),r=e.applicationLogoPaths,s=t===i.dark?i.light:i.dark;return r&&r[s]?r[s]:e.applicationLogoPath}}class It{loggers=xt;constructor(t){this.module=t}debug(t,...e){this.log(yt.DEBUG,t,e)}error(t,...e){this.log(yt.ERROR,t,e)}info(t,...e){this.log(yt.INFO,t,e)}warn(t,...e){this.log(yt.WARN,t,e)}log(t,e,r){const i=this.loadConfiguration();i?.loggers.forEach(s=>{const n=this.loggers.get(s);if(!n)throw new Error(`Logger '${s}' not found`);if(vt(i.minLogLevel)<=vt(t)){const i=this.getFormattedMessage(t,e);n.log(t,i,r)}})}getFormattedMessage(t,e){return`[${t}] [${this.module}] [${(new Date).toLocaleString()}] ${e}`}loadConfiguration(){const t=Et(Ft).getApplicationConfiguration();return t?.loggerConfig}}class Rt{static loggerInstances=new Map;static getLoggerInstance(t){return this.loggerInstances.has(t)||this.loggerInstances.set(t,new It(t)),this.loggerInstances.get(t)}}class Ct{static get logger(){return Rt.getLoggerInstance("API")}}class Tt{logger=Ct.logger;constructor(t){this.value=t}getValue(){return this.value}isDefined(){return!n.isNullOrUndefined(this.value)}getValueOrDefault(t){return this.value||t}getAsJson(){if(null===this.value)return null;try{return JSON.parse(this.value)}catch(t){return this.logger.error("Error parsing JSON",t),null}}}class Pt{static GLOBAL_NAMESPACE="ontotext.gdb"}class Dt{constructor(t=[]){this.languages=t}getLanguageCodes(){return this.languages?.map(t=>t.key)}}const Nt=["en","fr"];class Ot extends b{constructor(t){super(),this.defaultLanguage=t.defaultLanguage||"en",this.availableLanguages=t.availableLanguages||new Dt}}class Bt{constructor(t){"boolean"==typeof t?this.policyAccepted=t:(this.policyAccepted=t?.policyAccepted,this.statistic=t?.statistic,this.thirdParty=t?.thirdParty,this.updatedAt=t?.updatedAt)}}let _t=function(t){return t.INFORMATION="INFORMATION",t.WARNING="WARNING",t.CRITICAL="CRITICAL",t}({});const Ht={[_t.INFORMATION]:0,[_t.WARNING]:1,[_t.CRITICAL]:2};class Lt extends b{constructor(t){super(),this.id=`${t.group}-${t.status}-${t.totalOperations}`,this.group=t.group,this.totalOperations=t.totalOperations,this.status=t.status}}class kt extends F{constructor(t){super(t)}}class Ut extends b{constructor(t){super(),this.status=t.status,this.allRunningOperations=t.allRunningOperations}toOperationsGroupSummary(){const t=new Map;return this.allRunningOperations.getItems().forEach(e=>{t.has(e.group)||t.set(e.group,new Lt({group:e.group,totalOperations:0,status:_t.INFORMATION}));const r=t.get(e.group);r.totalOperations+=e.count,Ht[e.status]>Ht[r.status]&&(r.status=e.status)}),Array.from(t.values())}toOperationGroupSummaryList(){return new kt(this.toOperationsGroupSummary())}}class Vt extends F{constructor(t){super(t)}}let jt=function(t){return t.UPDATES="updates",t.QUERIES="queries",t.IMPORT="imports",t.BACKUP_AND_RESTORE="backupAndRestore",t.CLUSTER_HEALTH="clusterHealth",t}({}),Mt=function(t){return t.QUERY="QUERY",t.BACKUP="BACKUP",t.CLUSTER="CLUSTER",t.IMPORT="IMPORT",t}({});const Kt=[jt.QUERIES,jt.UPDATES,jt.IMPORT],qt={[jt.UPDATES]:"monitor/queries",[jt.QUERIES]:"monitor/queries",[jt.BACKUP_AND_RESTORE]:"monitor/backup-and-restore",[jt.IMPORT]:"import",[jt.CLUSTER_HEALTH]:"cluster"},Gt={[jt.QUERIES]:Mt.QUERY,[jt.UPDATES]:Mt.QUERY,[jt.BACKUP_AND_RESTORE]:Mt.BACKUP,[jt.IMPORT]:Mt.IMPORT,[jt.CLUSTER_HEALTH]:Mt.CLUSTER};class Wt extends b{constructor(t){super(),this.value=t.value,this.status=t.status,this.type=t.type,this.id=`${t.status}-${t.type}-${t.value}`,this.count=this.getCount(this.type,this.value),this.group=Gt[this.type],this.href=qt[this.type],this.labelKey=this.getLabelKey(this.type,this.value)}getCount(t,e){return Kt.includes(t)?parseInt(e,10):0}getLabelKey(t,e){return Kt.includes(t)?t:e}}let $t=function(t){return t.BOTTOM_RIGHT="bottom-right",t.BOTTOM_LEFT="bottom-left",t}({});class zt{constructor(t){this.timeout=t?.timeout||5e3,this.onClick=t?.onClick,this.removeOnClick=t?.removeOnClick||!1,this.title=t?.title,this.translationParams=t?.translationParams}}class Xt extends zt{constructor(t){super(),this.timeout=t.timeout,this.position=t.position}static getDefaultConfig(){return this.instance||(this.instance=new Xt({timeout:5e3,position:$t.BOTTOM_RIGHT})),this.instance}}let Yt=function(t){return t.ERROR="error",t.INFO="info",t.SUCCESS="success",t.WARNING="warning",t}({});class Jt{static uuid(){const t=16;let e=(new Date).getTime(),r=1e3*(performance?.now()??0);return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{let s=Math.random()*t;return e>0?(s=(e+s)%t|0,e=Math.floor(e/t)):(s=(r+s)%t|0,r=Math.floor(r/t)),("x"===i?s:3&s|8).toString(t)})}static generateRandomString(t){const e=new Uint32Array(t);return c.getCrypto().getRandomValues(e),Array.from(e,t=>("0"+t.toString(16)).substr(-2)).join("")}static hashCode(t){let e=0;for(let r=0,i=t.length;r<i;r++)e=(e<<5)-e+t.charCodeAt(r),e|=0;return e}}class Qt extends b{constructor(){super(),this.id=Jt.uuid()}}class Zt extends Qt{constructor(t,e,r){super(),this.type=t,this.message=e,this.config=r}}const te="create-toast-event";class ee extends F{constructor(t){super(t)}}class re extends F{constructor(t){super(t)}}class ie extends b{constructor(t){super(),this.setRadio(t.isRadio),this.setButtons(new re(t.buttons))}getButtons(){return this.buttons}setButtons(t){this.buttons=t}isRadio(){return this.radio}setRadio(t){this.radio=t}selectButton(t){return this.isRadio()&&!t.selected&&(this.deselectAll(),t.selected=!0,t.callback()),this.copy()}deselectAll(){this.buttons.getItems().forEach(t=>t.selected=!1)}}class se extends b{constructor(t){super(),this.id=t.id,this.label=t.label,this.selected=t.selected,this.callback=t.callback}}class ne extends F{constructor(t){super(t)}findSuggestionByValue(t){return this.items.find(e=>e.getValue()===t)}findHoveredSuggestion(){return this.items.find(t=>t.isHovered())}getHoveredSuggestionIndex(){return this.items.findIndex(t=>t.isHovered())}setHoveredStateAtIndex(t,e){const r=this.items[t];r&&r.setHovered(e)}unhoverAllSuggestions(){this.items.forEach(t=>t.setHovered(!1))}deselectAllSuggestions(){this.items.forEach(t=>t.setSelected(!1))}}class ae extends b{constructor(t){super(),this.suggestions=t}hoverFirstSuggestion(){const t=this.suggestions.getFirstItem();if(t)return this.hoverSuggestion(t)}hoverSuggestion(t){return t&&(this.clearHoveredState(),t.setHovered(!0)),this.copy()}selectSuggestion(t){return t&&(this.clearSelectedState(),t.setSelected(!0)),this.copy()}getHoveredSuggestion(){return this.suggestions.findHoveredSuggestion()}hoverPreviousSuggestion(){const t=this.suggestions.getHoveredSuggestionIndex();return t>0&&(this.clearHoveredState(),this.suggestions.setHoveredStateAtIndex(t-1,!0)),this.copy()}hoverNextSuggestion(){const t=this.suggestions.getHoveredSuggestionIndex();return t<this.suggestions.size()-1&&(this.clearHoveredState(),this.suggestions.setHoveredStateAtIndex(t+1,!0)),this.copy()}clearSuggestions(){return this.suggestions=new ne,this.copy()}getByValue(t){return this.suggestions.findSuggestionByValue(t)}clearSelectedState(){this.suggestions.deselectAllSuggestions()}clearHoveredState(){this.suggestions.unhoverAllSuggestions()}}class oe extends b{overrideToVisual=!1;constructor(t){super(),this.setId(t.id),this.setType(t.type),this.setValue(t.value),this.setDescription(t.description)}getId(){return this._id}setId(t){this._id=t}getType(){return this._type}setType(t){this._type=t}getValue(){return this._value}setValue(t){this._value=t}getDescription(){return this._description}setDescription(t){this._description=t}isHovered(){return this._hovered}setHovered(t){this._hovered=t}isSelected(){return this._selected}setSelected(t){this._selected=t}getOverrideToVisual(){return this.overrideToVisual}setOverrideToVisual(t){this.overrideToVisual=t}}let he=function(t){return t.URI="uri",t.PREFIX="prefix",t}({});class ue{constructor(t,e){this.setSuggestion(t),this.setContext(e)}getSuggestion(){return this.suggestion}getContext(){return this.context}setContext(t){this.context=t}setSuggestion(t){this.suggestion=t}}let ce=function(t){return t.DATA_LOADED="DATA_LOADED",t}({});class le{constructor(t,e){this.entry=t,this.name=e}}class ge extends b{constructor(t){super(),this._pluginDefinitions=t}getPluginDefinitions(){return this._pluginDefinitions}}let pe=function(t){return t.ROUTE="route",t.MAIN_MENU="main.menu",t}({});class de extends F{constructor(t){super(t)}}let fe=function(t){return t.ERROR="error",t.INFO="info",t.SUCCESS="success",t.WARNING="warning",t}({});class ye extends Qt{constructor(t){super(),this.code=t}withTitle(t){return this.title=t,this}withType(t){return this.type=t,this}withParameters(t){return this.parameters=t,this}static info(t){return new ye(t).withType(fe.INFO)}static error(t){return new ye(t).withType(fe.ERROR)}static warning(t){return new ye(t).withType(fe.WARNING)}static success(t){return new ye(t).withType(fe.SUCCESS)}}let ve=function(t){return t.SHOULD_TOAST="shouldToast",t}({});class me{priority=0}class Se extends F{constructor(t){super(t)}}let Ee=function(t){return t.RETURN_URL="r",t.NO_ACCESS="noaccess",t.EXPIRED="expired",t}({});class xe{getStorage(){return localStorage}get(t){const e=this.getStorage().getItem(this.getPrefixedKey(t));return new Tt(e)}getAsJson(t){const e=this.getStorage().getItem(t);if(e)try{return JSON.parse(e)}catch(e){return console.error(`Error parsing JSON from localStorage for key ${t}:`,e),null}return null}storeValue(t,e){this.getStorage().setItem(this.getPrefixedKey(t),e)}remove(t){this.getStorage().removeItem(this.getPrefixedKey(t))}getPrefixedKey(t){const e=`${Pt.GLOBAL_NAMESPACE}.${this.NAMESPACE}.`,r=`${this.NAMESPACE}.`;return t.startsWith(e)?t:t.startsWith(r)?`${Pt.GLOBAL_NAMESPACE}.${t}`:`${e}${t}`}}class Ae{logger=Ct.logger;handleStorageChange(t){const e=t.key?.substring(Pt.GLOBAL_NAMESPACE.length+1);let r="",i="";e&&(r=e.substring(0,e.indexOf(".")),i=e.substring(r.length+1));const s=this.resolveHandler(r,i);if(s){let e;null!==t.newValue&&(e=s.deserializeProperty(i,t.newValue)),s.updateContextProperty(i,e)}}resolveHandler(t,e){if(!t)return void this.logger.warn("Namespace is required to resolve a context property change handler.");const r=St.getAllBySuperType(bt).find(t=>t.canHandle(e));if(r)return r;this.logger.warn(`No context property change handler found for namespace: ${t} and property: ${e}`)}}class we extends xe{NAMESPACE="application";SETTINGS="settings";logger=Ct.logger;OLD_SETTINGS_KEY="ls.workbench-settings";migrate(){if(this.get(this.SETTINGS).getValue())return;const t=this.getAsJson(this.OLD_SETTINGS_KEY);if(!t)return;this.logger.info("Begin migrating legacy application settings to new format...");const e=new s;e.theme=t.theme,t.mode&&t.mode===i.dark?e.themeMode=i.dark:e.themeMode=i.light,this.setApplicationSettings(e),this.getStorage().removeItem(this.OLD_SETTINGS_KEY),this.logger.info("Migration of legacy application settings completed. Old settings key removed.")}set(t,e){this.storeValue(t,e)}setApplicationSettings(t){this.set(this.SETTINGS,JSON.stringify(t))}getApplicationSettings(){const t=this.get(this.SETTINGS).getAsJson();return t?new s(t):new s}getThemeMode(){return this.getApplicationSettings().themeMode}isThemeModePresent(){const t=this.get(this.SETTINGS).getAsJson();return!!t&&void 0!==new s(t).themeMode}}class be extends bt{RUNTIME_CONFIGURATION="runtimeConfiguration";THEME_MODE="themeMode";updateRuntimeConfiguration(t){const e={...this.getRuntimeConfiguration()??{},...t};this.updateContextProperty(this.RUNTIME_CONFIGURATION,e)}onRuntimeConfigurationChanged(t){return this.subscribe(this.RUNTIME_CONFIGURATION,t)}getRuntimeConfiguration(){return this.getContextPropertyValue(this.RUNTIME_CONFIGURATION)}updateThemeMode(t){this.updateContextProperty(this.THEME_MODE,t)}onThemeModeChanged(t){return this.subscribe(this.THEME_MODE,t)}}class Fe{applicationSettingsStorageService=Et(we);runtimeConfigurationContextService=Et(be);rootSelector=":root";darkClass=i.dark;static CODE_EDITOR_DARK_THEME="moxer";applyDarkModeIfEnabled(){const t=this.isDarkModeEnabledInSettings()?i.dark:i.light;this.setThemeMode(t)}setThemeMode(t){const e=this.getRootElement();if(!e)return;const r=t===i.dark;e.classList.toggle(this.darkClass,r),this.runtimeConfigurationContextService.updateThemeMode(r?i.dark:i.light)}applyColorScheme(){this.isThemeModeSet()?this.applyDarkModeIfEnabled():this.setThemeMode(this.getPreferredScheme())}applyNewColorScheme(t){this.isThemeModeSet()||this.setThemeMode(t)}isDarkModeApplied(){const t=this.getRootElement();if(!t)return!1;const e=i.dark;return t.classList.contains(e)}isDarkModeEnabledInSettings(){const t=this.applicationSettingsStorageService.getApplicationSettings();return t?.themeMode===i.dark}isThemeModeSet(){return this.applicationSettingsStorageService.isThemeModePresent()}getCodeEditorThemeName(){return this.isDarkModeApplied()?Fe.CODE_EDITOR_DARK_THEME:void 0}getPreferredScheme(){return c.matchMedia("(prefers-color-scheme: dark)").matches?i.dark:i.light}getRootElement(){return document.querySelector(this.rootSelector)??null}}class Ie{constructor(t){this.url=t.url,this.method=t.method,this.headers={...t.headers},this.body=t.body}}class Re{constructor(t){this.status=t.status,this.statusText=t.statusText,this.headers=t.headers,this.config=t.config,this.originalResponse=t.originalResponse}}class Ce extends Re{constructor(t){super(t),this.data=t.data}}class Te extends Re{constructor(t){super(t),this.data=t.data??null,this.status>=200&&this.status<300?this.message=`Http failure during parsing for ${t.config.url||"(unknown url)"}`:this.message=`Http failure response for ${t.config.url||"(unknown url)"}: ${t.status} ${t.statusText}`}get isClientError(){return this.status>=400&&this.status<500}get isServerError(){return this.status>=500&&this.status<600}}class Pe{preProcessors=new F;postProcessors=new F;async preProcess(t){let e=t;for(const t of this.preProcessors.getItems())t.shouldProcess(e)&&(e=await t.process(e));return e}async postProcess(t){let e=t;for(const t of this.postProcessors.getItems())t.shouldProcess(e)&&(e=await t.process(e));return e}registerRequestInterceptors(t){this.preProcessors.addItems(t.getItems()),this.sortInterceptors(this.preProcessors)}registerResponseInterceptors(t){this.postProcessors.addItems(t.getItems()),this.sortInterceptors(this.postProcessors)}sortInterceptors(t){t.sort((t,e)=>e.priority-t.priority)}}class De{emit(t){const e=new CustomEvent(t.NAME,{detail:t.payload});return this.getHostElement().dispatchEvent(e),e}subscribe(t,e){const r=t=>{t instanceof CustomEvent&&e(t.detail)};return this.getHostElement().addEventListener(t,r),()=>this.getHostElement().removeEventListener(t,r)}getHostElement(){return document.body}}const Ne="http-request-done-event";class Oe{interceptorService=St.get(Pe);eventEmitter=new De;get(t,e){const{params:r,headers:i,responseType:s="body"}=e??{};return"response"===s?this.request(t,"GET",{params:r,headers:i},"response"):this.request(t,"GET",{params:r,headers:i},"body")}post(t,e){const{body:r,headers:i,responseType:s="body"}=e??{};return"response"===s?this.request(t,"POST",{body:r,headers:i},"response"):this.request(t,"POST",{body:r,headers:i},"body")}put(t,e){const{body:r,headers:i,responseType:s="body"}=e??{};return"response"===s?this.request(t,"PUT",{body:r,headers:i},"response"):this.request(t,"PUT",{body:r,headers:i},"body")}patch(t,e){const{body:r,headers:i,responseType:s="body"}=e??{};return"response"===s?this.request(t,"PATCH",{body:r,headers:i},"response"):this.request(t,"PATCH",{body:r,headers:i},"body")}delete(t,e){const{headers:r,responseType:i="body"}=e??{};return"response"===i?this.request(t,"DELETE",{headers:r},"response"):this.request(t,"DELETE",{headers:r},"body")}uploadFile(t,e,r="file",i,s){const n=new FormData;n.append(r,e,e instanceof File?e.name:void 0),s&&Object.entries(s).forEach(([t,e])=>{n.append(t,e)});const a={...i};return delete a["Content-Type"],this.post(t,{body:n,headers:a,responseType:"response"})}encodeURIComponentStrict(t){return encodeURIComponent(t).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16)})}request(t,e,r={},i="response"){const{fullUrl:s,headers:n}=this.getRequestConfig(t,r),a=new Ie({url:s,method:e,headers:n,body:r.body});let o;return this.executeRequest(a).then(async t=>{if(o=t,!t.ok){const e=await this.getDataFromResponse(i,t),r=new Te({status:t.status,statusText:t.statusText,headers:this.extractHeaders(t),config:a,originalResponse:t,data:e});return Promise.reject(r)}const e=await this.getDataFromResponse(i,t);return"body"===i?e:new Ce({status:t.status,statusText:t.statusText,headers:this.extractHeaders(t),config:a,originalResponse:t,data:e})}).catch(t=>{if(t instanceof Te)return Promise.reject(t);o??=t;const e=new Te({status:o.status,statusText:o.statusText,headers:this.extractHeaders(o),config:a,originalResponse:o,data:null});return t?.message&&(e.message=t.message),Promise.reject(e)}).finally(()=>this.eventEmitter.emit({NAME:Ne,payload:void 0}))}async getDataFromResponse(t,e){let r=null;if(r=await e.text(),!t||"body"===t||"response"===t)try{r=JSON.parse(r)}catch{}return r}getRequestConfig(t,e){const r=this.buildQueryParams(e.params),i=`${t}${r?`?${r}`:""}`,s=e.body instanceof FormData,n={Accept:"application/json, text/plain, */*",...e.headers};return s||(n["Content-Type"]=e.headers?.["Content-Type"]??"application/json"),{fullUrl:i,headers:n}}formatBody(t,e){return e?e instanceof FormData?e:t["Content-Type"]?.includes("application/json")?JSON.stringify(e):(t["Content-Type"]?.includes("application/x-www-form-urlencoded"),e):null}executeRequest(t){return this.interceptorService.preProcess(t).then(t=>{const e=this.formatBody(t.headers,t.body);return fetch(t.url,{method:t.method,headers:t.headers,body:e})}).then(t=>this.interceptorService.postProcess(t))}extractHeaders(t){const e={};return t.headers.forEach((t,r)=>{e[r]=t}),e}buildQueryParams(t={}){return new URLSearchParams(t).toString()}}class Be extends Oe{I18N_ENDPOINT="assets/i18n";getLanguage(t){return this.get(`${this.I18N_ENDPOINT}/${t}.json`)}getLanguageConfiguration(){return this.get(`${this.I18N_ENDPOINT}/language-config.json`)}}class _e extends xe{NAMESPACE="i18n";set(t,e){this.storeValue(t,e)}}class He extends bt{LANGUAGE_CONFIG="languageConfig";SELECTED_LANGUAGE="selectedLanguage";LANGUAGE_BUNDLE="languageBundle";DEFAULT_BUNDLE="defaultBundle";updateSelectedLanguage(t){this.validatePropertyChange(this.SELECTED_LANGUAGE,t).then(e=>{if(e){const e=t||St.get(Ue).getDefaultLanguage();St.get(_e).set(this.SELECTED_LANGUAGE,e),this.updateContextProperty(this.SELECTED_LANGUAGE,t)}})}onSelectedLanguageChanged(t,e){return this.subscribe(this.SELECTED_LANGUAGE,t,e)}updateLanguageBundle(t){this.updateContextProperty(this.LANGUAGE_BUNDLE,t)}onLanguageBundleChanged(t){return this.subscribe(this.LANGUAGE_BUNDLE,t)}getLanguageBundle(){return this.getContextPropertyValue(this.LANGUAGE_BUNDLE)}updateDefaultBundle(t){this.updateContextProperty(this.DEFAULT_BUNDLE,t)}getDefaultBundle(){return this.getContextPropertyValue(this.DEFAULT_BUNDLE)}getLanguageConfig(){return this.getContextPropertyValue(this.LANGUAGE_CONFIG)}setLanguageConfig(t){this.updateContextProperty(this.LANGUAGE_CONFIG,t)}getSelectedLanguage(){return this.getContextPropertyValue(this.SELECTED_LANGUAGE)}}class Le extends b{constructor(t,e){super(),this.key=t,this.name=e}}function ke(t){const e=t.map(t=>new Le(t.key,t.name));return new Dt(e)}class Ue{languageRestService=St.get(Be);languageContextService=St.get(He);getSupportedLanguages(){const t=this.languageContextService.getLanguageConfig();return t?t.availableLanguages.getLanguageCodes():Nt}getLanguage(t){return this.languageRestService.getLanguage(t)}getLanguageConfiguration(){return this.languageRestService.getLanguageConfiguration().then(t=>{return new Ot({defaultLanguage:(e=t).defaultLanguage,availableLanguages:ke(e.availableLanguages)});var e})}getDefaultLanguage(){const t=this.languageContextService.getLanguageConfig();return t?t.defaultLanguage:"en"}}class Ve extends Oe{static REPOSITORIES_ENDPOINT="rest/repositories";getRepositories(){return this.get(`${Ve.REPOSITORIES_ENDPOINT}/all`)}getRepositorySizeInfo(t){return this.get(`${Ve.REPOSITORIES_ENDPOINT}/${t.id}/size?location=${encodeURIComponent(t.location)}`)}}const je=t=>new P(t),Me=t=>{if(!t||"object"!=typeof t)return new T;const e=[];return Object.entries(t).forEach(([,t])=>{Array.isArray(t)&&t.forEach(t=>{const r=new R({id:t.id,title:t.title,type:w(N,t.type),sesameType:t.sesameType,uri:t.uri,externalUrl:t.externalUrl,location:t.location,state:w(D,t.state),local:t.local,readable:t.readable,writable:t.writable,unsupported:t.unsupported});e.push(r)})}),new T(e)};class Ke{GRAPHQL_REPO_AUTHORITY="GRAPHQL";constructor(){this.repositoryRestService=St.get(Ve)}getRepositories(){return this.repositoryRestService.getRepositories().then(t=>Me(t))}getRepositorySizeInfo(t){return this.repositoryRestService.getRepositorySizeInfo(t).then(je)}isSystemRepository(t){return"SYSTEM"===t.id}getCurrentGqlRepoAuthority(t,e){return`${this.getCurrentRepoAuthority(t,e)}:${this.GRAPHQL_REPO_AUTHORITY}`}getOverallGqlRepoAuthority(t){return`${this.getOverallRepoAuthority(t)}:${this.GRAPHQL_REPO_AUTHORITY}`}getLocationSpecificId(t){return t.location?`${t.id}@${t.location}`:t.id}getCurrentRepoAuthority(t,e){return`${t}_REPO_${e}`}getOverallRepoAuthority(t){return`${t}_REPO_*`}}class qe extends xe{NAMESPACE="repository";logger=Ct.logger;SELECTED_REPOSITORY="selectedRepository";set(t,e){e?this.storeValue(t,e):this.remove(t)}setRepositoryReference(t){this.set(this.SELECTED_REPOSITORY,this.serializeRepositoryReference(t))}getRepositoryReference(){return this.deserializeRepositoryReference(this.get(this.SELECTED_REPOSITORY).getValueOrDefault('{"id": "", "location": ""}'))}removeRepositoryReference(){this.remove(this.SELECTED_REPOSITORY)}serializeRepositoryReference(t){return JSON.stringify(t)}deserializeRepositoryReference(t){if("string"==typeof t)try{return JSON.parse(t)}catch(t){this.logger.error("Error parsing repository reference",t)}}}class Ge extends bt{SELECTED_REPOSITORY="selectedRepository";REPOSITORY_LIST="repositoryList";updateSelectedRepository(t){const e=Et(qe),r=this.findRepository(t);return this.validatePropertyChange(this.SELECTED_REPOSITORY,r).then(i=>{i&&(r?e.setRepositoryReference(r.toRepositoryReference()):t||e.removeRepositoryReference(),this.updateContextProperty(this.SELECTED_REPOSITORY,r))})}getSelectedRepository(){return this.getContextPropertyValue(this.SELECTED_REPOSITORY)}onSelectedRepositoryChanged(t,e){return this.subscribe(this.SELECTED_REPOSITORY,t,e)}updateRepositoryList(t){return this.updateContextProperty(this.REPOSITORY_LIST,t)}getRepositoryList(){return this.getContextPropertyValue(this.REPOSITORY_LIST)||new T([])}onRepositoryListChanged(t){return this.subscribe(this.REPOSITORY_LIST,t)}getDeserializedContext(){return{[this.SELECTED_REPOSITORY]:this.deserializeRepository}}deserializeRepository=t=>new R(JSON.parse(t));findRepository(t,e=!1){if(t)return this.getRepositoryList().findRepository(t.id,t.location,e)}repositoryExists(t,e=!1){return void 0!==this.findRepository(t,e)}}class We extends Oe{getActiveRepositoryLocation(){return this.get("rest/locations/active")}}const $e=t=>new B({uri:t.uri,label:t.label,username:t.username??void 0,password:t.password??void 0,authType:t.authType?w(z,t.authType):void 0,locationType:t.locationType?w(_,t.locationType):void 0,active:t.active,local:t.local,system:t.system,errorMsg:t.errorMsg??"",defaultRepository:t.defaultRepository??void 0});class ze{constructor(){this.locationRestService=St.get(We)}getActiveRepositoryLocation(){return this.locationRestService.getActiveRepositoryLocation().then($e)}}class Xe extends bt{ACTIVE_REPOSITORY_LOCATION="activeRepositoryLocation";IS_LOADING="isLoading";updateActiveRepositoryLocation(t){this.updateContextProperty(this.ACTIVE_REPOSITORY_LOCATION,t)}onActiveLocationChanged(t){return this.subscribe(this.ACTIVE_REPOSITORY_LOCATION,t)}updateIsLoading(t){this.updateContextProperty(this.IS_LOADING,t)}onIsLoadingChanged(t){return this.subscribe(this.IS_LOADING,t)}}class Ye extends Oe{LICENSE_ENDPOINT="rest/graphdb-settings/license";LICENSE_INFO_ENDPOINT="rest/info/license";getLicense(){return this.get(this.LICENSE_ENDPOINT)}getIsLicenseHardcoded(){return this.get(`${this.LICENSE_ENDPOINT}/hardcoded`)}registerLicense(t){const e=new Uint8Array(t.length);for(let r=0;r<e.length;r++)e[r]=t.charCodeAt(r);return this.post(this.LICENSE_ENDPOINT,{body:e,headers:{"Content-Type":"application/octet-stream"}})}unregisterLicense(){return this.delete(this.LICENSE_ENDPOINT)}extractFromLicenseFile(t){return this.uploadFile(`${this.LICENSE_INFO_ENDPOINT}/to-base-64`,t,void 0,{Accept:"text/plain"}).then(t=>t.data)}validateLicense(t){return this.post(`${this.LICENSE_INFO_ENDPOINT}/validate`,{body:t,headers:{"Content-Type":"text/plain"}})}}let Je=function(t){return t.GRAPHDB_LITE="GRAPHDB_LITE",t.GRAPHDB_SE="GRAPHDB_SE",t.GRAPHDB_ENTERPRISE="GRAPHDB_ENTERPRISE",t.GRAPHDB_SANDBOX="GRAPHDB_SANDBOX",t}({}),Qe=function(t){return t.FREE="free",t.STANDARD="standard",t.ENTERPRISE="enterprise",t.SANDBOX="sandbox",t}({});function Ze(t){return Object.values(Qe).find(e=>e===t)}const tr=t=>{return new gt({expiryDate:t?.expiryDate?new Date(t.expiryDate):void 0,latestPublicationDate:t?.latestPublicationDate?new Date(t.latestPublicationDate):void 0,licensee:t?.licensee||"",maxCpuCores:t?.maxCpuCores,product:(e=t?.product,Object.values(Je).find(t=>t===e)),productType:Ze(t?.productType),licenseCapabilities:er(t?.licenseCapabilities),version:t?.version||"",installationId:t?.installationId||"",valid:t?.valid,typeOfUse:t?.typeOfUse||"",message:t?.message||"",present:t?.present||!1,usageRestriction:t?.usageRestriction||""});var e};function er(t){const e=(t??[]).filter(t=>t?.trim());return new pt(e)}class rr extends bt{GRAPHDB_LICENSE="graphDbLicense";IS_LICENSE_HARDCODED="isLicenseHardcoded";updateGraphdbLicense(t){this.updateContextProperty(this.GRAPHDB_LICENSE,t)}onLicenseChanged(t){return this.subscribe(this.GRAPHDB_LICENSE,t)}getLicenseSnapshot(){return this.getContextPropertyValue(this.GRAPHDB_LICENSE)}updateIsLicenseHardcoded(t){this.updateContextProperty(this.IS_LICENSE_HARDCODED,!!t)}onIsLicenseHardcodedChanged(t){return this.subscribe(this.IS_LICENSE_HARDCODED,t)}isLicenseHardcodedSnapshot(){return this.getContextPropertyValue(this.IS_LICENSE_HARDCODED)}}class ir{licenseRestService=Et(Ye);licenseContextService=Et(rr);trackableProductTypes=[Qe.FREE,Qe.SANDBOX];trackableTypesOfUse=["evaluation","this is an evaluation license"];async updateLicenseStatus(){const t=await this.getIsLicenseHardcoded();this.licenseContextService.updateIsLicenseHardcoded(t);const e=await this.getLicense();return this.licenseContextService.updateGraphdbLicense(e),e}async getLicense(){const t=await this.licenseRestService.getLicense();return tr(t)}registerLicense(t){return this.licenseRestService.registerLicense(t).then(t=>tr(t))}unregisterLicense(){return this.licenseRestService.unregisterLicense()}extractFromLicenseFile(t){return this.licenseRestService.extractFromLicenseFile(t)}getIsLicenseHardcoded(){return this.licenseRestService.getIsLicenseHardcoded()}validateLicense(t){return this.licenseRestService.validateLicense(t).then(t=>tr(t))}isTrackableLicense(){const t=this.licenseContextService.getLicenseSnapshot(),e=t?.typeOfUse?.toLowerCase()||"",r=t?.productType;return!t?.present||this.trackableProductTypes.some(t=>t===r)||this.trackableTypesOfUse.includes(e)}}class sr extends bt{PRODUCT_INFO="productInfo";updateProductInfo(t){this.updateContextProperty(this.PRODUCT_INFO,t)}onProductInfoChanged(t){return this.subscribe(this.PRODUCT_INFO,t)}getProductInfo(){return this.getContextPropertyValue(this.PRODUCT_INFO)}}class nr extends Oe{VERSION_URL="rest/info/version";getProductInfoLocal(){return this.get(`${this.VERSION_URL}?local=1`)}}class ar{productInfoRestService=Et(nr);async getProductInfoLocal(){const t=await this.productInfoRestService.getProductInfoLocal();return new dt({workbench:(e=t).Workbench||"",productType:e.productType||"",productVersion:e.productVersion||"",sesame:e.sesame||"",connectors:e.connectors||""});var e}}class or extends bt{RESTRICTED_PAGES="restrictedPages";SECURITY_CONFIG="securityConfig";AUTHENTICATED_USER="authenticatedUser";JSON_WEB_KEYS_SET="jsonWebKeysSet";IS_LOGGED_IN="isLoggedIn";getRestrictedPages(){return this.getContextPropertyValue(this.RESTRICTED_PAGES)||new ct}updateRestrictedPages(t){this.updateContextProperty(this.RESTRICTED_PAGES,t)}onRestrictedPagesChanged(t){return this.subscribe(this.RESTRICTED_PAGES,t)}updateSecurityConfig(t){this.updateContextProperty(this.SECURITY_CONFIG,t)}onSecurityConfigChanged(t){return this.subscribe(this.SECURITY_CONFIG,t)}getSecurityConfig(){return this.getContextPropertyValue(this.SECURITY_CONFIG)}updateAuthenticatedUser(t){this.updateContextProperty(this.AUTHENTICATED_USER,t)}onAuthenticatedUserChanged(t){return this.subscribe(this.AUTHENTICATED_USER,t)}getAuthenticatedUser(){return this.getContextPropertyValue(this.AUTHENTICATED_USER)}updateJsonWebKeysSet(t){this.updateContextProperty(this.JSON_WEB_KEYS_SET,t)}getJsonWebKeysSet(){return this.getContextPropertyValue(this.JSON_WEB_KEYS_SET)}updateIsLoggedIn(t){this.updateContextProperty(this.IS_LOGGED_IN,t)}getIsLoggedIn(){return this.getContextPropertyValue(this.IS_LOGGED_IN)}}class hr extends xe{accessToken="access_token";idToken="id_token";refreshToken="refresh_token";tokenType="token_type";pkceState="pkce_state";pkceCodeVerifier="pkce_code_verifier";nonce="nonce";returnUrl="return_url";NAMESPACE="auth.openid";set(t,e){this.storeValue(t,e)}setAccessToken(t){this.set(this.accessToken,t)}getAccessToken(){return this.get(this.accessToken)}clearAccessToken(){this.remove(this.accessToken)}setIdToken(t){this.set(this.idToken,t)}getIdToken(){return this.get(this.idToken)}clearIdToken(){this.remove(this.idToken)}setRefreshToken(t){this.set(this.refreshToken,t)}getRefreshToken(){return this.get(this.refreshToken)}clearRefreshToken(){this.remove(this.refreshToken)}setTokenType(t){this.set(this.tokenType,t)}getTokenType(){return this.get(this.tokenType)}clearTokenType(){this.remove(this.tokenType)}setPkceState(t){this.set(this.pkceState,t)}getPkceState(){return this.get(this.pkceState)}clearPkceState(){this.remove(this.pkceState)}setPkceCodeVerifier(t){this.set(this.pkceCodeVerifier,t)}getPkceCodeVerifier(){return this.get(this.pkceCodeVerifier)}clearPkceCodeVerifier(){this.remove(this.pkceCodeVerifier)}setNonce(t){this.set(this.nonce,t)}getNonce(){return this.get(this.nonce)}clearNonce(){this.remove(this.nonce)}setReturnUrl(t){this.set(this.returnUrl,t)}getReturnUrl(){return this.get(this.returnUrl)}clearReturnUrl(){this.remove(this.returnUrl)}clearTokens(){this.clearAccessToken(),this.clearIdToken(),this.clearRefreshToken()}}var ur=r(355);class cr extends Error{constructor(t){super(),this.text=t}get message(){return`${this.constructor.name}: ${this.text}`}}class lr extends cr{}class gr extends lr{constructor(){super("Invalid JWT token")}}let pr=function(t){return t.ACCESS="access",t.ID="id",t.REFRESH="refresh",t}({});class dr{logger=Ct.logger;openidStorageService=Et(hr);securityContextService=Et(or);REFRESH_TOKEN_TOLERANCE=5e3;hasValidIdToken(t){return this.getTokenByType(pr.ID)?this.verifyToken(pr.ID,t)?(this.logger.debug("OpenID: valid id token found"),!0):(this.logger.debug("OpenID: stale id token"),!1):(this.logger.debug("OpenID: no id token"),!1)}hasValidRefreshToken(){const t=this.getTokenByType(pr.REFRESH);if(!t)return this.logger.debug("OpenID: no refresh token"),!1;let e;try{e=this.getTokenPayload(t)}catch{return!0}return!(e.nbf&&1e3*e.nbf-Date.now()>this.REFRESH_TOKEN_TOLERANCE||e.exp&&Date.now()-1e3*e.exp>this.REFRESH_TOKEN_TOLERANCE||!e.iat)}saveTokens(t,e){t.refresh_token?this.openidStorageService.setRefreshToken(t.refresh_token):this.openidStorageService.clearRefreshToken(),t.access_token?this.openidStorageService.setAccessToken(t.access_token):this.openidStorageService.clearAccessToken(),t.id_token?this.openidStorageService.setIdToken(t.id_token):this.openidStorageService.clearIdToken(),this.openidStorageService.setTokenType(e.tokenType),this.logger.debug("OpenID: saved tokens"),this.openidStorageService.clearPkceState(),this.openidStorageService.clearPkceCodeVerifier()}authHeaderGraphDB(){return this.openidStorageService.getTokenType().getValue()===pr.ID?"Bearer "+this.getTokenByType(pr.ID):"Bearer "+this.getTokenByType(pr.ACCESS)}getTokenHeader(t){try{const e=ur.pj.jws.JWS.readSafeJSONString((0,ur.cV)(t.split(".")[0]));if(e)return e}catch(t){throw this.logger.error("OpenID: token header decode failed",t),new gr}}getTokenPayload(t){try{const e=ur.pj.jws.JWS.readSafeJSONString((0,ur.cV)(t.split(".")[1]));if(e)return e}catch(t){throw this.logger.debug("Token payload decode error",t),new gr}}verifyToken(t,e){const r=this.getTokenByType(t);if(!r)return!1;let i;try{i=this.getTokenHeader(r)}catch{return!1}if(!i.kid)return t!==pr.ID?i.error?(this.logger.debug(`OpenID: token ${t} is not a JWT token (token considered valid)`),!0):(this.logger.debug(`OpenID: invalid token ${t} (token is empty)`),!1):(this.logger.debug("OpenID: invalid token id (not a JWT token)"),!1);const s=this.securityContextService.getJsonWebKeysSet()?.[i.kid];if(!s)return this.logger.debug("OpenID: no key to verify JWT token (token considered invalid)"),!1;const n=ur.ym.getKey(s),a={alg:[i.alg],iss:[e.issuer]};return"id"===t?(a.aud=[e.clientId,e.issuer],a.nonce=[this.openidStorageService.getNonce().getValue()||""]):"access"===t&&(a.aud=[e.tokenAudience],a.iss=[e.tokenIssuer]),ur.pj.jws.JWS.verifyJWT(r,n,a)}clearTokens(){this.openidStorageService.clearTokens()}getTokenByType(t){return t===pr.ID?this.openidStorageService.getIdToken().getValue():t===pr.ACCESS?this.openidStorageService.getAccessToken().getValue():t===pr.REFRESH?this.openidStorageService.getRefreshToken().getValue():null}}class fr{static pkceChallengeFromVerifier(t){const e=new ur.pj.crypto.MessageDigest({alg:"sha256",prov:"cryptojs"});return(0,ur.wV)(e.digestString(t))}static parseQueryString(t){const e={access_token:null,code:null,id_token:null,state:null};let r;if(t){const t=c.getLocationHash().substring(1);r=new URLSearchParams(t)}else r=new URLSearchParams(c.getLocationQueryParams());return 0===r.size||Object.keys(e).forEach(t=>{const i=r.get(t);i&&(e[t]=decodeURIComponent(i))}),e}}class yr extends lr{constructor(t){super(`Invalid OpenID authentication flow: ${t}`)}}class vr extends lr{constructor(){super("Missing authorization code")}}let mr=function(t){return t.CODE="code",t.CODE_NO_PKCE="code_no_pkce",t.IMPLICIT="implicit",t}({}),Sr=function(t){return t.CODE="code",t.TOKEN="token id_token",t}({});class Er{items=[];enqueue(t){this.items.push(t)}dequeue(){return this.items.shift()}dequeueAll(){const t=[...this.items];return this.items=[],t}peek(){return this.items[0]}peekAll(){return[...this.items]}isEmpty(){return 0===this.items.length}size(){return this.items.length}}class xr{notificationAddedCallbackFunctions=[];notifications=new Er;addNotification(t){this.notifications.enqueue(t),this.notifyAllNotificationAdded(t)}removeAllNotifications(){return this.notifications.dequeueAll()}onNotificationAdded(t){return t&&!this.notifications.isEmpty()&&this.notifyNotificationAdded(t),this.notificationAddedCallbackFunctions.push(t),()=>{this.notificationAddedCallbackFunctions=this.notificationAddedCallbackFunctions.filter(e=>e!==t)}}notifyNotificationAdded(t){this.notifications.peekAll().forEach(e=>t(e))}notifyAllNotificationAdded(t){for(const e of this.notificationAddedCallbackFunctions)e(t)}}function Ar(t){Et(xr).addNotification(t)}class wr{logger=Ct.logger;tokenUtils=Et(dr);openidStorageService=Et(hr);async handleAuthorizationCode(t,e,r){if(!e.code)throw this.logger.error("OpenID: Missing authorization code"),new vr;const i=`${E()}`;if(t.authFlow===mr.CODE)await this.handlePkceFlow(e,i,r);else{if(t.authFlow!==mr.CODE_NO_PKCE)throw this.logger.error("OpenID: Invalid OpenID authentication flow"),new yr(t.authFlow);await this.handleCodeNoPkceFlow(e.code,i,r)}return!0}async handleImplicitFlow(t,e){this.tokenUtils.saveTokens(e,t)}checkExistingAuthentication(t){const e=this.tokenUtils.hasValidIdToken(t),r=this.tokenUtils.hasValidRefreshToken();return e||r}storeCodeFlowData(t){this.openidStorageService.setPkceState(t),this.openidStorageService.setPkceCodeVerifier(Jt.generateRandomString(28))}getCodeChallengeForCodeFlow(){const t=this.openidStorageService.getPkceCodeVerifier().getValue();if(!t)throw new lr("Missing PKCE code verifier");return fr.pkceChallengeFromVerifier(t)}async handlePkceFlow(t,e,r){const i=this.openidStorageService.getPkceState().getValue();if(i!==t.state)throw this.logger.debug(`OpenID: PKCE state mismatch ${i} != ${t.state}`),Ar(ye.error("openid.errors.invalid_pkce_state").withTitle("openid.errors.title").withParameters({[ve.SHOULD_TOAST]:!0})),new lr(`PKCE state mismatch ${i} != ${t.state}`);if(!t.code)throw new vr;const s=this.openidStorageService.getPkceCodeVerifier().getValue();await r(t.code,e,s)}async handleCodeNoPkceFlow(t,e,r){await r(t,e)}}class br extends lr{constructor(){super("OpenID security configuration is not available")}}class Fr extends Oe{securityContextService=Et(or);OAUTH_IDENTITY_DOMAIN_NAME_HEADER="X-OAuth-Identity-Domain-Name";getJSONWebKeySet(){return this.get(this.getJWKSEndpoint(),{headers:this.getDomainHeaders()})}refreshToken(t){const e={grant_type:"refresh_token",client_id:this.getClientId(),refresh_token:t},r={...this.getDomainHeaders(),"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},i=this.transformURLEncodedRequest(e);return this.post(this.getTokensEndpoint(),{body:i,headers:r})}getTokens(t,e,r){const i={grant_type:"authorization_code",client_id:this.getClientId(),redirect_uri:t,code:e};r&&(i.code_verifier=r);const s={...this.getDomainHeaders(),"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},n=this.transformURLEncodedRequest(i);return this.post(this.getTokensEndpoint(),{body:n,headers:s})}transformURLEncodedRequest(t){const e=new URLSearchParams;return Object.entries(t).forEach(([t,r])=>{e.append(t,r)}),e}getClientId(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(t)return t.clientId;throw new br}getJWKSEndpoint(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(t)return t.openIdKeysUri;throw new br}getTokensEndpoint(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(t)return t.openIdTokenUrl;throw new br}getDomainHeaders(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;return t?.oracleDomain?{[this.OAUTH_IDENTITY_DOMAIN_NAME_HEADER]:t.oracleDomain}:{}}}class Ir{securityContextService=Et(or);buildLoginUrl(t,e,r){const i=this.getResponseType(),s=[...this.buildBaseParameters(i,r),...this.buildFlowSpecificParameters(t,e),...this.buildAdditionalParameters()];return`${this.getOpenIdConfig().oidcAuthorizationEndpoint}?${s.join("&")}`}buildLogoutUrl(t){const e=this.getOpenIdConfig(),r=e.clientId;return`${e.openIdEndSessionUrl}?client_id=${encodeURIComponent(r)}&post_logout_redirect_uri=${encodeURIComponent(t)}`}getOpenIdConfig(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(!t)throw new br;return t}getResponseType(){const t=this.getOpenIdConfig().authFlow;if(t===mr.CODE||t===mr.CODE_NO_PKCE)return Sr.CODE;if(t===mr.IMPLICIT)return Sr.TOKEN;throw new yr(t)}buildBaseParameters(t,e){return[`response_type=${encodeURIComponent(t)}`,`scope=${encodeURIComponent(this.getScope())}`,`client_id=${encodeURIComponent(this.getOpenIdConfig().clientId)}`,`redirect_uri=${encodeURIComponent(e)}`]}buildFlowSpecificParameters(t,e){const r=this.getOpenIdConfig().authFlow,i=[];return r===mr.CODE?i.push(`state=${encodeURIComponent(t)}`,`code_challenge=${encodeURIComponent(e)}`,"code_challenge_method=S256"):r===mr.IMPLICIT&&i.push(`nonce=${encodeURIComponent(t)}`),i}buildAdditionalParameters(){const t=this.getOpenIdConfig(),e=[];return t.oracleDomain&&e.push(`domain=${encodeURIComponent(t.oracleDomain)}`),t.authorizeParameters&&e.push(t.authorizeParameters),e}getScope(){const t=["openid"];this.getOpenIdConfig().supportsOfflineAccess&&t.push("offline_access");const e=this.getOpenIdConfig().extraScopes;return e&&t.push(e),t.join(" ")}}class Rr{DEFAULT_REFRESH_CONFIGURATION={refreshAheadMs:6e4,minDelayMs:1e3};logger=Ct.logger;tokenUtils=Et(dr);openidStorageService=Et(hr);async setupTokensRefresh(t){const e=this.openidStorageService.getRefreshToken().getValue();if(!e||!this.shouldSetupRefresh(e))return this.clearRefreshTimer(),void this.logger.debug("OpenID: no valid refresh token");const r=this.openidStorageService.getAccessToken().getValue(),i=this.calculateRefreshDelay(r);i<this.DEFAULT_REFRESH_CONFIGURATION.minDelayMs?(this.logger.debug("OpenID: tokens need refresh now, "+i),await this.executeImmediateRefresh(e,t)):(this.logger.debug("OpenID: scheduling token refresh in",i/1e3,"seconds"),this.scheduleTokenRefresh(e,i,t))}clearRefreshTimer(){this.refreshTokensTimer&&(c.getWindow().clearTimeout(this.refreshTokensTimer),delete this.refreshTokensTimer)}shouldSetupRefresh(t){return!(!t||!this.tokenUtils.hasValidRefreshToken())}calculateRefreshDelay(t){let e;try{e=this.tokenUtils.getTokenPayload(t)}catch{return 0}return!e.exp||e.exp<=0?0:1e3*e.exp-Date.now()-this.DEFAULT_REFRESH_CONFIGURATION.refreshAheadMs}async executeImmediateRefresh(t,e){this.clearRefreshTimer(),this.logger.debug("OpenID: tokens will refresh now"),await e(t)}scheduleTokenRefresh(t,e,r){this.clearRefreshTimer(),this.refreshTokensTimer=c.getWindow().setTimeout(async()=>{this.logger.debug("OpenID: tokens will refresh now, "+e),await r(t)},e)}}class Cr extends xe{jwtKey="jwt";authenticatedKey="authenticated";NAMESPACE="auth";set(t,e){this.storeValue(t,e)}getAuthToken(){return this.get(this.jwtKey)}setAuthenticated(t){this.storeValue(this.authenticatedKey,t?.toString()||"")}isAuthenticated(){return"true"===this.get(this.authenticatedKey).getValue()}setAuthToken(t){this.setAuthenticated(!0),this.set(this.jwtKey,t)}clearAuthToken(){this.remove(this.jwtKey)}isGDBorOpenIDToken(){const t=this.getAuthToken().getValue();return!(!t||!t.startsWith("GDB")&&!t.startsWith("Bearer"))}}class Tr{constructor(t){this.notify=t}}class Pr{eventSubscribers=new Map;emit(t){const e=this.eventSubscribers.get(t.NAME);e&&e.forEach(e=>{e.notify(n.deepCopy(t.payload))})}subscribe(t,e){const r=new Tr(e),i=this.eventSubscribers.get(t);return i?i.push(r):this.eventSubscribers.set(t,[r]),()=>this.unsubscribe(t,r)}unsubscribe(t,e){const r=this.eventSubscribers.get(t);if(r){const i=r.indexOf(e);-1!==i&&r.splice(i,1),0===r.length&&this.eventSubscribers.delete(t)}}}class Dr{logger=Ct.logger;openIdRestService=Et(Fr);openidStorageService=Et(hr);securityContextService=Et(or);tokenUtils=Et(dr);authenticationStorageService=Et(Cr);authFlowHandler=Et(wr);tokenRefreshManager=Et(Rr);openIdUrlBuilder=Et(Ir);getJSONWebKeySet(){return this.openIdRestService.getJSONWebKeySet()}getTokens(t,e,r){return this.openIdRestService.getTokens(t,e,r)}async refreshTokens(t){const e=this.getOpenIdConfig();try{const r=await this.openIdRestService.refreshToken(t);this.logger.debug("OpenID: refreshed tokens"),this.tokenUtils.saveTokens(r,e),this.authenticationStorageService.setAuthToken(this.tokenUtils.authHeaderGraphDB()),await this.setupTokensRefresh()}catch(t){this.logger.debug("OpenID: could not refresh tokens",t);let e="unknown error";t instanceof Te&&(e=t.data?.error_description??"unknown error"),Ar(ye.error("openid.errors.cannot_refresh_token").withTitle("openid.errors.title").withParameters({error:e,[ve.SHOULD_TOAST]:!0})),this.softLogout(),Et(Pr).emit(new W)}}async initializeOpenId(){const t=this.getOpenIdConfig();return await this.initializeJsonWebKeySet(),this.authFlowHandler.checkExistingAuthentication(t)?(await this.setupTokensRefresh(),!0):this.handleAuthenticationFlow()}async initializeJsonWebKeySet(){const t=await this.getJSONWebKeySet(),e=this.buildKeySet(t.keys);this.securityContextService.updateJsonWebKeysSet(e)}setupCodeFlow(t,e){this.authFlowHandler.storeCodeFlowData(t);const r=this.authFlowHandler.getCodeChallengeForCodeFlow(),i=this.getLoginUrl(t,r,e);this.redirectToUrl(i)}setupCodeNoPkceFlow(t,e){this.openidStorageService.clearPkceCodeVerifier();const r=this.getLoginUrl(t,"",e);this.redirectToUrl(r)}setupImplicitFlow(t,e){this.openidStorageService.setNonce(t);const r=this.getLoginUrl(t,"",e);this.redirectToUrl(r)}async setupTokensRefresh(){await this.tokenRefreshManager.setupTokensRefresh(this.refreshTokens.bind(this))}clearAuthentication(){this.authenticationStorageService.clearAuthToken(),this.tokenUtils.clearTokens(),this.tokenRefreshManager.clearRefreshTimer()}logout(t=!1){t?this.hardLogout(E()):this.softLogout()}getOpenIdConfig(){const t=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;if(!t)throw new br;return t}buildKeySet(t){const e={};return t.forEach(t=>{e[t.kid]=t}),e}async handleAuthenticationFlow(){const t=this.getOpenIdConfig();this.clearAuthentication();const e=t.authFlow===mr.IMPLICIT,r=fr.parseQueryString(e);return r.code?this.authFlowHandler.handleAuthorizationCode(t,r,this.exchangeTokensForCode.bind(this)):!!r.id_token&&(await this.authFlowHandler.handleImplicitFlow(t,r),await this.setupTokensRefresh(),!0)}async exchangeTokensForCode(t,e,r){const i=this.getOpenIdConfig();try{const s=await this.getTokens(e,t,r);this.logger.debug("OpenID: successfully retrieved tokens"),this.tokenUtils.saveTokens(s,i),await this.setupTokensRefresh()}catch(t){throw this.logger.error("OpenID: Cannot retrieve token after login",{error:t}),Ar(ye.error("openid.errors.cannot_retrieve_token").withTitle("openid.errors.title").withParameters({error:t instanceof Error?t.message:String(t),[ve.SHOULD_TOAST]:!0})),new lr("Cannot retrieve token after login")}}softLogout(){this.clearAuthentication()}hardLogout(t){this.softLogout();const e=this.getLogoutUrl(t);this.redirectToUrl(e)}redirectToUrl(t){c.setLocationHref(t)}getLoginUrl(t,e,r){return this.openIdUrlBuilder.buildLoginUrl(t,e,r)}getLogoutUrl(t){return this.openIdUrlBuilder.buildLogoutUrl(t)}}let Nr=function(t){return t.GDB_TOKEN="GDB_TOKEN",t.OPENID="OPENID",t.EXTERNAL="EXTERNAL",t.NO_SECURITY="NO_SECURITY",t}({});class Or{logger=Ct.logger;securityService=Et(qr);securityContextService=Et(or);type=Nr.NO_SECURITY;initialize(){return this.fetchAuthenticatedUser().then(t=>(this.securityContextService.updateAuthenticatedUser(t),!0)).catch(t=>(this.logger.error("Could not load authenticated user",t),!1))}fetchAuthenticatedUser(){return this.securityService.getAuthenticatedAdminUser()}login(){return this.fetchAuthenticatedUser()}logout(){return Promise.resolve()}isAuthenticated(){return!!this.securityContextService.getAuthenticatedUser()}isExternal(){return!1}}class Br extends lr{constructor(){super("OpenID user has no access rights")}}class _r{logger=Ct.logger;securityService=Et(qr);authenticationStorageService=Et(Cr);authenticationService=Et(ri);securityContextService=Et(or);openIdService=Et(Dr);openidStorageService=Et(hr);tokenUtils=Et(dr);type=Nr.OPENID;constructor(){this.setupConfigurationListener()}async initialize(){this.loadSecurityConfiguration(),this.validateConfiguration();try{const t=await this.openIdService.initializeOpenId();t&&await this.handleSuccessfulAuthentication();const e=this.openidStorageService.getReturnUrl().getValue();return this.openidStorageService.clearReturnUrl(),t&&e&&f(e),t}catch(t){return this.handleAuthenticationError(t),!1}}fetchAuthenticatedUser(){return this.securityService.getAuthenticatedUser()}login(){this.validateConfiguration();const t=this.getReturnUrl(),e=Jt.generateRandomString(28),r=this.openIdSecurityConfig.authFlow;return this.executeAuthFlow(r,e,t),new Promise(()=>{})}logout(){return this.openIdService.logout(),Promise.resolve()}isAuthenticated(){const t=this.authenticationStorageService.getAuthToken().getValue();return!this.authenticationService.isSecurityEnabled()||null!==t}isExternal(){return!1}setupConfigurationListener(){this.securityContextService.onSecurityConfigChanged(t=>{t&&(this.openIdSecurityConfig=t.openidSecurityConfig)})}loadSecurityConfiguration(){this.openIdSecurityConfig=this.securityContextService.getSecurityConfig()?.openidSecurityConfig}validateConfiguration(){if(!this.openIdSecurityConfig)throw new br}async handleSuccessfulAuthentication(){this.logger.debug("OpenID: authentication initialized"),this.authenticationStorageService.setAuthToken(this.tokenUtils.authHeaderGraphDB());try{await this.loadAndSetAuthenticatedUser()}catch(t){throw this.logger.debug("Could not load authenticated user",t),Ar(ye.error("openid.errors.user_no_access").withTitle("openid.errors.title").withParameters({[ve.SHOULD_TOAST]:!0})),new Br}}async loadAndSetAuthenticatedUser(){const t=await this.fetchAuthenticatedUser();t&&this.securityContextService.updateAuthenticatedUser(t)}handleAuthenticationError(t){this.authenticationStorageService.clearAuthToken(),this.logger.debug("OpenID: not logged or login error"),this.logger.error("Could not initialize OpenID authentication",t),this.openIdService.clearAuthentication()}getReturnUrl(){return`${E()}`}executeAuthFlow(t,e,r){switch(t){case mr.CODE:this.openIdService.setupCodeFlow(e,r);break;case mr.CODE_NO_PKCE:this.openIdService.setupCodeNoPkceFlow(e,r);break;case mr.IMPLICIT:this.openIdService.setupImplicitFlow(e,r);break;default:throw this.logger.debug(`OpenID: Invalid OpenID authentication flow: ${t}`),Ar(ye.error("openid.errors.unknown_flow").withTitle("openid.errors.title").withParameters({authFlow:t,[ve.SHOULD_TOAST]:!0})),new yr(t)}}}class Hr extends cr{constructor(){super("Missing token in authentication header")}}const Lr=t=>new st({username:t.username,password:t.password,authorities:new tt(t.authorities),appSettings:new et(t.appSettings),external:t.external});class kr extends Oe{SECURITY_ENDPOINT="rest/security";LOGIN_ENDPOINT="rest/login";SECURITY_USER_ENDPOINT=`${this.SECURITY_ENDPOINT}/users`;SECURITY_FREE_ACCESS_ENDPOINT=`${this.SECURITY_ENDPOINT}/free-access`;loginGdbToken(t,e){return this.post(this.LOGIN_ENDPOINT,{body:{username:t,password:e},responseType:"response"})}getSecurityConfig(){return this.get(`${this.SECURITY_ENDPOINT}/all`)}getAuthenticatedUser(){return this.get(`${this.SECURITY_ENDPOINT}/authenticated-user`)}getAdminUser(){return this.get(`${this.SECURITY_USER_ENDPOINT}/admin`)}getFreeAccess(){return this.get(this.SECURITY_FREE_ACCESS_ENDPOINT)}setFreeAccess(t){return this.post(this.SECURITY_FREE_ACCESS_ENDPOINT,{body:t})}}class Ur extends Oe{SECURITY_ENDPOINT="rest/security";SECURITY_USER_ENDPOINT=`${this.SECURITY_ENDPOINT}/users`;getUser(t){return this.get(`${this.SECURITY_USER_ENDPOINT}/${this.encodeURIComponentStrict(t)}`)}getUsers(){return this.get(`${this.SECURITY_USER_ENDPOINT}`)}createUser(t,e){return this.post(`${this.SECURITY_USER_ENDPOINT}/${this.encodeURIComponentStrict(t)}`,{body:e})}updateUser(t,e){return this.put(`${this.SECURITY_USER_ENDPOINT}/${this.encodeURIComponentStrict(t)}`,{body:e})}updateCurrentUser(t,e){return this.patch(`${this.SECURITY_USER_ENDPOINT}/${this.encodeURIComponentStrict(t)}`,{body:e})}deleteUser(t){return this.delete(`${this.SECURITY_USER_ENDPOINT}/${this.encodeURIComponentStrict(t)}`)}}class Vr{constructor(t){this.password=t?.password,this.grantedAuthorities=t?.grantedAuthorities??[],this.appSettings=t?.appSettings??{DEFAULT_SAMEAS:!0,DEFAULT_INFERENCE:!0,EXECUTE_COUNT:!0,IGNORE_SHARED_QUERIES:!1,DEFAULT_VIS_GRAPH_SCHEMA:!0}}}const jr=t=>new Vr({password:t.password,grantedAuthorities:t.authorities.toGraphdbAuthoritiesModel(),appSettings:t.appSettings.toJSON()}),Mr=t=>new it({username:t.username,authorities:new tt(t.grantedAuthorities),appSettings:new et({EXECUTE_COUNT:t.appSettings.EXECUTE_COUNT,DEFAULT_INFERENCE:t.appSettings.DEFAULT_INFERENCE,DEFAULT_SAMEAS:t.appSettings.DEFAULT_SAMEAS,DEFAULT_VIS_GRAPH_SCHEMA:t.appSettings.DEFAULT_VIS_GRAPH_SCHEMA,IGNORE_SHARED_QUERIES:t.appSettings.IGNORE_SHARED_QUERIES,COOKIE_CONSENT:t.appSettings.COOKIE_CONSENT?new Bt(t.appSettings.COOKIE_CONSENT):void 0}),dateCreated:new Date(t.dateCreated),gptThreads:t.gptThreads,external:t.external});class Kr{static ADMIN_USERNAME="admin";usersRestService=Et(Ur);getUser(t){return this.usersRestService.getUser(t).then(t=>Mr(t))}getUsers(){return this.usersRestService.getUsers().then(t=>t.map(t=>Mr(t)))}getAdminUser(){return this.usersRestService.getUser(Kr.ADMIN_USERNAME).then(t=>Mr(t))}createUser(t){const e=jr(t);return this.usersRestService.createUser(t.username,e)}updateUser(t){const e=jr(t);return this.usersRestService.updateUser(t.username,e)}deleteUser(t){return this.usersRestService.deleteUser(t)}updateCurrentUser(t){const e=jr(t);return this.usersRestService.updateCurrentUser(t.username,e)}}class qr{securityRestService=Et(kr);securityContextService=Et(or);usersService=Et(Kr);updateAuthenticatedUser(t){return this.usersService.updateCurrentUser(t)}getSecurityConfig(){return this.securityRestService.getSecurityConfig().then(t=>new ut(t))}getFreeAccess(){return this.securityRestService.getFreeAccess().then(function(t){return ht(t)})}setFreeAccess(t,e){const r={enabled:t};if(t){if(!e)throw new Error("Free access settings must be provided when enabling free access");r.authorities=J(e?.authorities),r.appSettings={...e?.appSettings}}return this.securityRestService.setFreeAccess(r).then(()=>this.getSecurityConfig()).then(t=>this.securityContextService.updateSecurityConfig(t))}getAuthenticatedUser(){return this.securityRestService.getAuthenticatedUser().then(t=>Lr(t))}getAuthenticatedAdminUser(){return this.usersService.getAdminUser().then(t=>st.fromUser(t))}isPasswordLoginEnabled(){return this.securityContextService.getSecurityConfig()?.passwordLoginEnabled??!1}isOpenIDEnabled(){return this.securityContextService.getSecurityConfig()?.openIdEnabled??!1}loginGdbToken(t,e){return this.securityRestService.loginGdbToken(t,e)}}class Gr{securityService=Et(qr);logger=Ct.logger;authStorageService=Et(Cr);fetchAuthenticatedUser(){return this.securityService.getAuthenticatedUser()}async login(t){const{username:e,password:r}=t,i=await this.securityService.loginGdbToken(e,r),s=this.getAuthenticationHeader(i),n=Lr(i.data);if(!s)throw new Hr;return this.authStorageService.setAuthToken(s),n}getAuthenticationHeader(t){return t.headers.authorization}}class Wr extends Gr{securityContextService=Et(or);type=Nr.GDB_TOKEN;initialize(){const t=!!this.authStorageService.getAuthToken().getValue();return t?this.isCurrentRouteLogin()?Promise.resolve(t):Promise.resolve(!!this.securityContextService.getAuthenticatedUser()):Promise.resolve(!1)}fetchAuthenticatedUser(){return this.securityService.getAuthenticatedUser()}logout(){return this.authStorageService.clearAuthToken(),Promise.resolve()}isAuthenticated(){return null!==this.authStorageService.getAuthToken().getValue()}isExternal(){return!1}isCurrentRouteLogin(){return"login"===A()}}class $r extends cr{constructor(){super()}}class zr extends Gr{securityContextService=Et(or);type=Nr.EXTERNAL;initialize(){return Promise.resolve(!0)}isAuthenticated(){return!!this.securityContextService.getAuthenticatedUser()}logout(){throw new $r}isExternal(){return!0}}class Xr{securityContextService=Et(or);authStorageService=Et(Cr);resolveStrategy(t){return this.authStrategy=this._resolveStrategy(t),this.authStrategy}getAuthStrategy(){return this.authStrategy}_resolveStrategy(t){return t.isEnabled()?t.openIdEnabled?new _r:this.securityContextService.getAuthenticatedUser()&&!this.authStorageService.isGDBorOpenIDToken()?new zr:new Wr:new Or}}class Yr{constructor(t,e){this.setRegex(t),this.setRouteParams(e)}getRegex(){return this.regex}setRegex(t){return this.regex=t,this}getRouteParams(){return this.routeParams}setRouteParams(t){return this.routeParams=t,this}}class Jr{constructor(t){this._url=t.url,this._module=t.module,this._path=t.path,this._chunk=t.chunk,this._controller=t.controller,this._templateUrl=t.templateUrl,this._title=t.title,this._reloadOnSearch=t.reloadOnSearch,this._helpInfo=t.helpInfo,this._documentationUrl=t.documentationUrl,this._allowAuthorities=t.allowAuthorities}get url(){return this._url}set url(t){this._url=t}get module(){return this._module}set module(t){this._module=t}get path(){return this._path}set path(t){this._path=t}get chunk(){return this._chunk}set chunk(t){this._chunk=t}get controller(){return this._controller}set controller(t){this._controller=t}get templateUrl(){return this._templateUrl}set templateUrl(t){this._templateUrl=t}get title(){return this._title}set title(t){this._title=t}get reloadOnSearch(){return this._reloadOnSearch}set reloadOnSearch(t){this._reloadOnSearch=t}get helpInfo(){return this._helpInfo}set helpInfo(t){this._helpInfo=t}get documentationUrl(){return this._documentationUrl}set documentationUrl(t){this._documentationUrl=t}get allowAuthorities(){return this._allowAuthorities}set allowAuthorities(t){this._allowAuthorities=t}}class Qr{routeConfig=c.getWindow().PluginRegistry.get(pe.ROUTE);getActiveRoute(t=S()){const e=this.routeConfig.find(e=>this.routeToRegex(e.url).getRegex().test(t));return e?new Jr(e):void 0}routeToRegex(t){const e=[],r=t.replace(/([().])/g,"\\$1").replace(/(\/)?:(\w+)(\*\?|[?*])?/g,function(t,r,i,s){const n="?"===s||"*?"===s,a="*"===s||"*?"===s;return e.push(i),r=r||"",(n?"(?:"+r:r+"(?:")+(a?"(.+?)":"([^/]+)")+(n?"?)?":")")}).replace(/([/$*])/g,"\\$1");return new Yr(new RegExp("^"+r+"(?:[?#]|$)"),new F(e))}}class Zr{repositoryService=Et(Ke);securityContextService=Et(or);repositoryStorageService=Et(qe);repositoryContextService=Et(Ge);hasFreeAccess(){const t=this.getSecurityConfig();return!(!t?.isEnabled()||!t?.freeAccess?.enabled)}initializeFreeAccess(){const t=this.getSecurityConfig();if(t?.isEnabled()&&t?.isFreeAccessEnabled()){const e=(new st).setAuthorities(t.freeAccess.authorities).setAppSettings(t.freeAccess.appSettings);this.securityContextService.updateAuthenticatedUser(e)}}initializeOverrideAuth(){const t=this.getSecurityConfig();if(!t?.isEnabled()&&t?.hasOverrideAuth()){const e=new st;e.username="overrideauth",e.setAuthorities(t.overrideAuth.authorities),e.setAppSettings(t.overrideAuth.appSettings),this.securityContextService.updateAuthenticatedUser(e)}}isAdmin(){return this.hasRole(X.ROLE_ADMIN)}isRepoManager(){return this.hasRole(X.ROLE_REPO_MANAGER)}hasRole(t){const e=this.getSecurityConfig(),r=this.getAuthenticatedUser();if(!t||!e?.isEnabled()&&!e?.hasOverrideAuth())return!0;if(!(Object.keys(r||{}).length>0))return!1;const i=X.IS_AUTHENTICATED_FULLY===t,s=!!r?.authorities.hasAuthority(t);return i||s}canReadRepo(t){if(!t||""===t.id)return!1;const e=this.getSecurityConfig(),r=this.getAuthenticatedUser();return!e?.isEnabled()||!!r&&(!!this.isAdminOrRepoManager()||!this.repositoryService.isSystemRepository(t)&&this.hasBaseRights(lt.READ,t))}canWriteRepo(t){if(!t||""===t.id)return!1;const e=this.getSecurityConfig(),r=this.getAuthenticatedUser();return!e?.isEnabled()&&!e?.hasOverrideAuth()||!!r&&(!!this.isAdminOrRepoManager()||!this.repositoryService.isSystemRepository(t)&&this.hasBaseRights(lt.WRITE,t))}canReadGqlRepo(t){return!(!t||""===t.id)&&this.hasGraphqlAuthority(lt.READ,t)}canWriteGqlRepo(t){return!(!t||""===t.id)&&this.hasGraphqlAuthority(lt.WRITE,t)}hasGqlRights(t){return this.canReadGqlRepo(t)||this.canWriteGqlRepo(t)}hasGraphqlRightsOverCurrentRepo(){const t=this.repositoryStorageService.getRepositoryReference(),e=this.repositoryContextService.findRepository(t);return this.canReadGqlRepo(e)||this.canWriteGqlRepo(e)}hasAuthority(){if(this.isAdminOrRepoManager())return!0;const t=Et(Qr).getActiveRoute();if(!t)return!1;if(!t.allowAuthorities)return!0;if(!Et(qe).getRepositoryReference()?.id)return!0;const e=this.getAuthenticatedUser();if(!e)return!0;if(t.allowAuthorities.length){const r=this.resolveAuthorities(t.allowAuthorities);return r.some(t=>e.authorities.hasAuthority(t))||r.some(t=>e.authorities.hasWildcardAuthority(t))}return!0}updatePermissions(){const t=this.securityContextService.getRestrictedPages(),e=this.securityContextService.getAuthenticatedUser(),r=this.isAdmin(),i=c.getWindow().PluginRegistry.get(pe.ROUTE),s=c.getWindow().PluginRegistry.get(pe.MAIN_MENU);i.forEach(i=>{const n=s.flatMap(t=>t.items).filter(t=>t.role?.startsWith("ROLE_")).find(t=>i.url.includes(t.href));if(!n)return;const a=!r&&!e?.authorities.hasAuthority(n.role??"");t.setPageRestriction(i.url,a)}),this.securityContextService.updateRestrictedPages(t)}resolveAuthorities(t){if(!t)return[];const e=Et(qe).getRepositoryReference();return e?.id?[...t.map(t=>t.replace("{repoId}",e.id)),...t.map(t=>t.replace("{repoId}","*"))]:t}getSecurityConfig(){return Et(or).getSecurityConfig()}getAuthenticatedUser(){return Et(or).getAuthenticatedUser()}hasBaseRights(t,e){const r=this.repositoryService.getLocationSpecificId(e),i=this.repositoryService.getCurrentRepoAuthority(t,r),s=this.repositoryService.getOverallRepoAuthority(t),n=this.getAuthenticatedUser();return!!(n?.authorities.hasAuthority(i)||n?.authorities.hasAuthority(s)||n?.authorities.hasWildcardAuthority(i))}hasGraphqlAuthority(t,e){const r=this.securityContextService.getAuthenticatedUser();if(!r)return!1;const i=this.repositoryService.getLocationSpecificId(e),s=this.repositoryService.getCurrentGqlRepoAuthority(t,i),n=this.repositoryService.getOverallGqlRepoAuthority(t);return r.authorities.hasAuthority(s)||r.authorities.hasAuthority(n)||r.authorities.hasWildcardAuthority(s,!0)}isAdminOrRepoManager(){return this.hasRole(X.ROLE_ADMIN)||this.hasRole(X.ROLE_REPO_MANAGER)}}class ti extends cr{constructor(){super("Authentication strategy not set")}}class ei extends bt{PREVIOUS_ROUTE="previousRoute";RETURN_URL="returnUrl";updatePreviousRoute(t){this.updateContextProperty(this.PREVIOUS_ROUTE,t)}getPreviousRoute(){let t=this.getContextPropertyValue(this.PREVIOUS_ROUTE);return t?.endsWith("#")&&(t=t.slice(0,-1)),t}updateReturnUrl(t){this.updateContextProperty(this.RETURN_URL,t)}getReturnUrl(){return this.getContextPropertyValue(this.RETURN_URL)}clearReturnUrl(){this.updateContextProperty(this.RETURN_URL,void 0)}}class ri{eventService=Et(Pr);authStrategyResolver=Et(Xr);authorizationService=Et(Zr);securityContextService=Et(or);authenticationStorageService=Et(Cr);navigationContextService=Et(ei);isAuthenticationStrategySet(){return!!this.authStrategyResolver.getAuthStrategy()}getCurrentUser(){return this.getAuthenticationStrategy().fetchAuthenticatedUser()}login(t,e){return this.getAuthenticationStrategy().login({username:t,password:e}).then(t=>{this.securityContextService.updateIsLoggedIn(!0),this.securityContextService.updateAuthenticatedUser(t),this.updateStrategy(),this.eventService.emit(new $)})}logout(){const t=this.getAuthenticationStrategy();this.authenticationStorageService.setAuthenticated(!1);const e=S();return t.logout().then(()=>{m()||this.navigationContextService.updateReturnUrl(e),this.securityContextService.updateIsLoggedIn(!1),this.authorizationService.hasFreeAccess()?(this.authorizationService.initializeFreeAccess(),this.eventService.emit(new $)):(f("login"),this.eventService.emit(new W))})}isLoggedIn(){const t=this.securityContextService.getIsLoggedIn()??!1,e=Et(or).getAuthenticatedUser();return this.isSecurityEnabled()&&t&&!!e}isAuthenticated(){return this.getAuthenticationStrategy().isAuthenticated()}isExternalUser(){return this.getAuthenticationStrategy().isExternal()}isSecurityEnabled(){return!!this.getSecurityConfig()?.isEnabled()}getSecurityConfig(){return Et(or).getSecurityConfig()}updateStrategy(){const t=this.getSecurityConfig();t&&this.authStrategyResolver.resolveStrategy(t)}getAuthenticationStrategy(){const t=this.authStrategyResolver.getAuthStrategy();if(!t)throw new ti;return t}}const ii="cookie-consent-changed-event";class si{eventEmitter=new De;acceptCookiePolicy(){const t=this.setAcceptedCookiePolicy();return St.get(qr).updateAuthenticatedUser(t.toUser()).then(()=>{this.eventEmitter.emit({NAME:ii,payload:t.appSettings.COOKIE_CONSENT})})}setAcceptedCookiePolicy(){const t=St.get(or).getAuthenticatedUser()||new st({});let e;return e=t.appSettings?.COOKIE_CONSENT?new Bt(t.appSettings.COOKIE_CONSENT):new Bt({thirdParty:!0,statistic:!0}),e.policyAccepted=!0,e.updatedAt=Date.now(),t.appSettings.COOKIE_CONSENT=e,t}}class ni extends Oe{MONITORING_ENDPOINT="rest/monitor";getOperations(t){return this.get(`${this.MONITORING_ENDPOINT}/repository/${t}/operations`)}}const ai={[jt.CLUSTER_HEALTH]:0,[jt.BACKUP_AND_RESTORE]:1,[jt.IMPORT]:2,[jt.QUERIES]:3,[jt.UPDATES]:4},oi=t=>{if(!t?.status||!t.allRunningOperations)return new Ut({status:_t.INFORMATION,allRunningOperations:new Vt([])});const e=t.allRunningOperations.map(t=>new Wt({value:t.value||"",status:w(_t,t.status),type:w(jt,t.type)})),r=new Vt(e);return r.sort((t,e)=>ai[t.type]-ai[e.type]),new Ut({status:w(_t,t.status),allRunningOperations:r})};class hi{getOperations(t){return St.get(ni).getOperations(t).then(t=>oi(t))}}class ui extends cr{constructor(){super("Class is not initializable")}}const ci={[fe.ERROR]:Yt.ERROR,[fe.SUCCESS]:Yt.SUCCESS,[fe.WARNING]:Yt.WARNING,[fe.INFO]:Yt.INFO};class li{constructor(){throw new ui}static fromNotification(t){const e=this.notificationTypeToToastType(t.type);return new Zt(e,t.code,{title:t.title,translationParams:this.toTranslationParams(t.parameters)})}static notificationTypeToToastType(t){return t?ci[t]:Yt.INFO}static toTranslationParams(t){return t?Object.entries(t).map(([t,e])=>({key:t,value:String(e)})):[]}}class gi{eventEmitter=new De;notificationService=Et(xr);constructor(){this.subscribeToNotificationEvents()}error(t,e){this.createToastElement(t,Yt.ERROR,e)}info(t,e){this.createToastElement(t,Yt.INFO,e)}success(t,e){this.createToastElement(t,Yt.SUCCESS,e)}warning(t,e){this.createToastElement(t,Yt.WARNING,e)}createToastElement(t,e,r){this.eventEmitter.emit({NAME:te,payload:new Zt(e,t,r)})}subscribeToNotificationEvents(){this.notificationService.onNotificationAdded(t=>{if(t.parameters?.[ve.SHOULD_TOAST]){const e=li.fromNotification(t);this.createToastElement(e.message,e.type,e.config)}})}}class pi extends Oe{autocompleteRestPrefix="rest/autocomplete";search(t){return this.get(`${this.autocompleteRestPrefix}/query?q=${t}`)}enabled(){return this.get(`${this.autocompleteRestPrefix}/enabled`)}}class di{search(t){return St.get(pi).search(t).then(t=>(t=>{const e=t.suggestions.map(t=>new oe({id:Jt.hashCode(`${t.type}-${t.value}-${t.description}`),type:w(he,t.type),value:t.value,description:t.description}));return new ae(new ne(e))})(t))}isAutocompleteEnabled(){return St.get(pi).enabled()}}class fi extends xe{ENABLED_KEY="enabled";NAMESPACE="autocomplete";set(t,e){this.storeValue(t,e)}isEnabled(){return"true"===this.get(this.ENABLED_KEY).value}setEnabled(t){this.set(this.ENABLED_KEY,t.toString())}}class yi extends bt{AUTOCOMPLETE_ENABLED="isAutocompleteEnabled";updateAutocompleteEnabled(t){this.updateContextProperty(this.AUTOCOMPLETE_ENABLED,t),St.get(fi).setEnabled(t)}onAutocompleteEnabledChanged(t){return this.subscribe(this.AUTOCOMPLETE_ENABLED,t)}}class vi extends Oe{REPOSITORIES_ENDPOINT="repositories";getNamespaces(t){return this.get(`${this.REPOSITORIES_ENDPOINT}/${t}/namespaces`)}}const mi=t=>{const e=(t?.results.bindings||[]).reduce((t,e)=>(t[e.prefix.value]=e.namespace.value,t),{});return new H(e)};class Si{namespacesRestService=St.get(vi);getNamespaces(t){return this.namespacesRestService.getNamespaces(t).then(t=>mi(t))}}class Ei extends bt{NAMESPACES="namespaces";updateNamespaces(t){this.updateContextProperty(this.NAMESPACES,t)}onNamespacesChanged(t){return this.subscribe(this.NAMESPACES,t)}}class xi extends xe{SELECTED_VIEW_KEY="selectedView";INPUT_KEY="input";LAST_SELECTED_KEY="lastSelected";NAMESPACE="resourceSearch";LEGACY_LAST_SELECTED_KEY="ls.rdf-search.resource-description";LEGACY_INPUT_KEY="ls.rdf-search.search-input";LEGACY_SELECTED_VIEW_KEY="ls.rdf-search.search-type";set(t,e){this.storeValue(t,e)}setSelectedView(t){this.set(this.SELECTED_VIEW_KEY,t),localStorage.setItem(this.LEGACY_SELECTED_VIEW_KEY,t)}getSelectedView(){return this.get(this.SELECTED_VIEW_KEY).getValue()||""}setInputValue(t){this.set(this.INPUT_KEY,t),localStorage.setItem(this.LEGACY_INPUT_KEY,t)}getInputValue(){return this.get(this.INPUT_KEY).getValue()||""}setLastSelected(t){this.set(this.LAST_SELECTED_KEY,t.getValue()),localStorage.setItem(this.LEGACY_LAST_SELECTED_KEY,t.getDescription()||"")}getLastSelectedValue(){return this.get(this.LAST_SELECTED_KEY).getValue()||""}clearStoredSearch(){this.remove(this.INPUT_KEY),this.remove(this.LAST_SELECTED_KEY),localStorage.removeItem(this.LEGACY_INPUT_KEY),localStorage.removeItem(this.LEGACY_LAST_SELECTED_KEY)}}class Ai extends bt{APPLICATION_DATA_STATE="applicationDataLoaded";APPLICATION_STATE_CHANGE="applicationStateChange";APPLICATION_STATE_BEFORE_CHANGE="applicationStateBeforeChange";updateApplicationDataState(t){this.updateContextProperty(this.APPLICATION_DATA_STATE,t)}onApplicationDataStateChanged(t){return this.subscribe(this.APPLICATION_DATA_STATE,t)}getApplicationDataState(){return this.getContextPropertyValue(this.APPLICATION_DATA_STATE)}updateApplicationStateChange(t){this.updateContextProperty(this.APPLICATION_STATE_CHANGE,t)}onApplicationStateChange(t){return this.subscribe(this.APPLICATION_STATE_CHANGE,t)}updateApplicationStateBeforeChange(t){this.updateContextProperty(this.APPLICATION_STATE_BEFORE_CHANGE,t)}onApplicationStateBeforeChange(t){return this.subscribe(this.APPLICATION_STATE_BEFORE_CHANGE,t)}}class wi extends Oe{configurationContextService=Et(Ft);logger=Ct.logger;getPluginsManifest(){const t=this.configurationContextService.getApplicationConfiguration();return this.get(t.pluginsManifestPath)}async loadPlugins(t){return await Promise.all(t.getPluginDefinitions().getItems().map(async t=>{try{const e=t.entry.startsWith("http")?t.entry:`${E()}${t.entry}`;return await import(e)}catch(e){this.logger.warn(`Failed to load plugin ${t.name}:`,e)}}))}}class bi{logger=Ct.logger;constructor(){this.pluginsRestService=St.get(wi)}async getPluginsManifest(){return(t=>{const e=t.plugins.map(t=>new le(t.entry,t.name));return new ge(new de(e))})(await this.pluginsRestService.getPluginsManifest())}async loadPlugins(){let t;try{t=await this.getPluginsManifest()}catch(t){this.logger.warn("Failed to load plugins manifest. Continue with the built-in plugins only.",t)}t&&(await this.pluginsRestService.loadPlugins(t)).filter(t=>void 0!==t).forEach(t=>{void 0!==t.register?t.register(c.getPluginRegistry()):this.logger.warn("Plugin module is missing the register method. Skipping registration.",t)})}}const Fi=JSON.parse('{"configUrl":"assets/configuration.default.json"}');class Ii extends cr{}class Ri extends Oe{async getConfiguration(){let t,e=Fi;try{e=await this.get("assets/env.json")}catch{console.warn('No downloadable "env.json" was found. Fallback to default:',e)}try{if(t=await this.get(e.configUrl),t)return console.info(`Configuration file ${e.configUrl} was downloaded`,t),t}catch{throw new Ii(`Failed to download configuration from "${e.configUrl}". Ensure that there is a\n "configuration.default.json" JSON file in the assets folder or provide an "env.json" file pointing to another\n configuration file.`)}}}class Ci{configurationRestService=Et(Ri);configurationContextService=Et(Ft);async getConfiguration(){const t=await this.configurationRestService.getConfiguration();return t&&this.configurationContextService.updateApplicationConfiguration(t),t}}const Ti=t=>{if(!t)return{items:[]};const e=Et(Ge).getSelectedRepository();let r="";return e&&(r=`${O}=${e.id}&`),{items:t.map(t=>({id:t,href:`sparql-template/create?${r}templateID=${encodeURIComponent(t)}`}))}};class Pi extends me{authStorage=St.get(Cr);repositoryStorageService=St.get(qe);securityContextService=St.get(or);process(t){return t.headers=t.headers||{},this.populateHeaders(t.headers),Promise.resolve(t)}shouldProcess(t){return!this.isOpenIdUrl(t.url)}populateHeaders(t){t["X-Requested-With"]="XMLHttpRequest";const e=this.authStorage.getAuthToken().getValue();if(e&&(t.Authorization=e),!t["X-GraphDB-Repository"]){const e=this.repositoryStorageService.getRepositoryReference();e?.id&&(t["X-GraphDB-Repository"]=e.id),e?.location&&(t["X-GraphDB-Repository-Location"]=e.location)}}isOpenIdUrl(t){const e=this.securityContextService.getSecurityConfig()?.openidSecurityConfig;return!!e&&[e?.openIdKeysUri,e?.openIdTokenUrl].some(e=>e&&t.indexOf(e)>-1)}}class Di extends me{authenticationStorageService=Et(Cr);authenticationService=Et(ri);shouldProcess(t){return 401===t.status}process(t){return this.shouldRedirectToLogin(t.url)?(this.authenticationStorageService.clearAuthToken(),m()||(f("login"),c.getWindow().location.reload()),Promise.reject(t)):Promise.resolve(t)}shouldRedirectToLogin(t){let e;try{e=this.authenticationService.isExternalUser()}catch(t){e=!1}return!t.includes("rest/security/authenticated-user")&&!e}}class Ni extends me{securityContextService=Et(or);authenticationService=Et(ri);logger=Ct.logger;shouldProcess(t){return 403===t.status}process(t){const e=S();return this.logger.warn("Permission to page denied. Some errors in the console are normal"),this.updateRestrictionsForPage(e),this.shouldRedirectToLogin()&&f("login"),Promise.reject(t)}updateRestrictionsForPage(t){const e=this.securityContextService.getRestrictedPages();e&&!e.isRestricted(t)&&(e.setPageRestriction(t),this.securityContextService.updateRestrictedPages(e))}shouldRedirectToLogin(){return!this.authenticationService.isAuthenticated()}}export{et as AppSettings,q as ApplicationBeforeChange,G as ApplicationChanged,Ai as ApplicationLifecycleContextService,M as ApplicationMounted,s as ApplicationSettings,we as ApplicationSettingsStorageService,K as ApplicationUnmounted,Pi as AuthRequestInterceptor,ot as AuthSettings,Xr as AuthStrategyResolver,st as AuthenticatedUser,ri as AuthenticationService,Cr as AuthenticationStorageService,z as AuthenticationType,X as Authority,tt as AuthorityList,Zr as AuthorizationService,yi as AutocompleteContextService,ae as AutocompleteSearchResult,di as AutocompleteService,fi as AutocompleteStorageService,Dt as AvailableLanguagesList,l as BuildUtil,u as ByteUtils,ii as COOKIE_CONSENT_CHANGED_EVENT,te as CREATE_TOAST_EVENT,pt as CapabilityList,Ft as ConfigurationContextService,Ri as ConfigurationRestService,Ci as ConfigurationService,bt as ContextService,wt as ContextSubscriptionManager,Bt as CookieConsent,si as CookieService,cr as ErrorBase,L as Event,De as EventEmitter,k as EventName,Pr as EventService,pe as ExtensionPoint,p as FibonacciGenerator,Ne as HTTP_REQUEST_DONE_EVENT,me as HttpInterceptor,Se as HttpInterceptorList,Pe as InterceptorService,Ot as LanguageConfig,He as LanguageContextService,Be as LanguageRestService,Ue as LanguageService,_e as LanguageStorageService,gt as License,rr as LicenseContextService,ir as LicenseService,ce as LifecycleState,xe as LocalStorageService,Ae as LocalStorageSubscriptionHandlerService,It as LoggerService,Rt as Loggers,$ as Login,W as Logout,b as Model,F as ModelList,ni as MonitoringRestService,hi as MonitoringService,H as NamespaceMap,Ei as NamespacesContextService,vi as NamespacesRestService,Si as NamespacesService,ei as NavigationContextService,U as NavigationEnd,V as NavigationEndPayload,j as NavigationStart,ye as Notification,ve as NotificationParam,xr as NotificationService,fe as NotificationType,n as ObjectUtil,gi as OntoToastrService,wr as OpenIdAuthFlowHandler,Fr as OpenIdRestService,Dr as OpenIdService,Rr as OpenIdTokenRefreshManager,Ir as OpenIdUrlBuilder,fr as OpenIdUtils,nt as OpenidSecurityConfig,hr as OpenidStorageService,Wt as Operation,Mt as OperationGroup,Lt as OperationGroupSummary,kt as OperationGroupSummaryList,Vt as OperationList,_t as OperationStatus,Ut as OperationStatusSummary,jt as OperationType,le as PluginDefinition,de as PluginDefinitionList,ge as PluginsManifest,wi as PluginsRestService,bi as PluginsService,dt as ProductInfo,sr as ProductInfoContextService,ar as ProductInfoService,O as REPOSITORY_ID_PARAM,R as Repository,Ge as RepositoryContextService,T as RepositoryList,B as RepositoryLocation,Xe as RepositoryLocationContextService,ze as RepositoryLocationService,_ as RepositoryLocationType,Ve as RepositoryRestService,Ke as RepositoryService,P as RepositorySizeInfo,D as RepositoryState,qe as RepositoryStorageService,N as RepositoryType,xi as ResourceSearchStorageService,ct as RestrictedPages,lt as Rights,be as RuntimeConfigurationContextService,Ht as STATUS_ORDER,se as SearchButton,ie as SearchButtonConfig,re as SearchButtonList,ut as SecurityConfig,or as SecurityContextService,qr as SecurityService,St as ServiceProvider,Tt as StorageData,Pt as StorageKey,I as SubscriptionList,oe as Suggestion,ne as SuggestionList,ue as SuggestionSelectedPayload,he as SuggestionType,i as ThemeMode,Fe as ThemeService,Zt as ToastMessage,ee as ToastMessageList,Yt as ToastType,Xt as ToastrConfig,$t as ToastrPosition,Di as UnauthenticatedInterceptor,Ni as UnauthorizedInterceptor,g as UriUtil,Ee as UrlPathParams,it as User,rt as UserType,Kr as UsersService,c as WindowService,x as getBasePath,A as getCurrentRoute,E as getOrigin,S as getPathName,v as isHomePage,m as isLoginPage,ht as mapAuthSettingsResponseToModel,Lr as mapAuthenticatedUserResponseToModel,Q as mapGrantedAuthoritiesResponseToModel,mi as mapNamespaceResponseToModel,oi as mapOperationSummaryResponseToModel,Me as mapRepositoryListResponseToModel,Ti as mapSparqlTemplatesResponseToModel,jr as mapUserModelToRequest,Mr as mapUserResponseToModel,f as navigate,d as navigateTo,Ar as notify,y as openInNewTab,Et as service,w as toEnum};